///|
/// # MoonBit Inquirer
/// 
/// 一个用于MoonBit的命令行交互式问答库,灵感来自npm的Inquirer.js。
/// 
/// ## 功能特性
/// 
/// MoonBit Inquirer提供优雅的方式来创建交互式命令行界面,支持以下问题类型:
/// 
/// - **Input**: 文本输入
/// - **Confirm**: 确认(是/否)
/// - **List**: 列表选择
/// - **RawList**: 带数字的列表选择
/// - **Expand**: 展开式选择
/// - **Checkbox**: 多选框
/// - **Password**: 密码输入
/// - **Editor**: 多行文本输入
/// 
/// ## 快速开始
/// 
/// ```mbt nocheck
/// import { "wangmingfa/promptx" }
/// import { "moonbitlang/async" }
///
/// async fn main {
///   // 创建问题数组
///   let questions : Array[Question] = [
///     input(
///       question_name="username",
///       question_message="What is your name?",
///       question_default=Some(AnswerValue::StringValue("Guest"))
///     ),
///     confirm(
///       question_name="subscribe",
///       question_message="Do you want to subscribe?"
///     ),
///     list(
///       question_name="color",
///       question_message="Choose your favorite color:",
///       question_choices=["Red", "Green", "Blue"]
///     ),
///   ]
///   
///   // 执行提示并获取答案
///   let answers = prompt(questions)
///   
///   // 处理答案
///   match answers["username"] {
///     AnswerValue::StringValue(name) => println("Hello, \{name}!")
///     _ => println("Hello, Guest!")
///   }
/// }
/// ```
pub using @inquirer {
  type QuestionType,
  type AnswerValue,
  type Answer,
  type Question,
  input,
  confirm,
  list,
  rawlist,
  expand,
  checkbox,
  password,
  editor,
  prompt,
  parse_int,
}

///|
/// # 核心函数
/// 
/// ## prompt
/// 
/// 处理问题数组并返回用户答案。
/// 
/// ### 函数签名
/// 
/// `pub async fn prompt(questions : Array[Question]) -> Answer`
/// 
/// ### 参数
/// 
/// - `questions : Array[Question]` - 问题数组
/// 
/// ### 返回值
/// 
/// 返回 `Answer` 类型(`Map[String, AnswerValue]`),包含每个问题的答案。
/// 
/// ### 示例
/// 
/// ```mbt nocheck
/// let questions : Array[Question] = [
///   input(question_name="name", question_message="Your name?"),
/// ]
/// let answers = prompt(questions)
/// match answers["name"] {
///   AnswerValue::StringValue(name) => println("Hello, \{name}!")
///   _ => {}
/// }
/// ```

///|
/// # 问题构造函数
/// 
/// ## input
/// 
/// 创建文本输入问题。
/// 
/// ### 函数签名
/// 
/// `pub fn input(question_name~ : String, question_message~ : String, question_default? : AnswerValue? = None) -> Question`
/// 
/// ### 参数
/// 
/// - `question_name~ : String` - 问题名称,用于在答案中获取结果
/// - `question_message~ : String` - 显示给用户的问题文本
/// - `question_default? : AnswerValue?` - 可选的默认值,使用 `AnswerValue::StringValue("...")` 
/// 
/// ### 示例
/// 
/// ```mbt nocheck
/// let q = input(
///   question_name="username",
///   question_message="What is your username?",
///   question_default=Some(AnswerValue::StringValue("admin"))
/// )
/// ```

///|
/// # 问题构造函数
/// 
/// ## confirm
/// 
/// 创建确认问题(是/否)。
/// 
/// ### 函数签名
/// 
/// `pub fn confirm(question_name~ : String, question_message~ : String, question_default? : AnswerValue? = None) -> Question`
/// 
/// ### 参数
/// 
/// - `question_name~ : String` - 问题名称
/// - `question_message~ : String` - 问题文本
/// - `question_default? : AnswerValue?` - 可选的默认值,使用 `AnswerValue::BoolValue(true)` 或 `AnswerValue::BoolValue(false)`
/// 
/// ### 返回值
/// 
/// 用户输入 Y/y/yes/true/1 返回 `BoolValue(true)`,输入 N/n/no/false/0 返回 `BoolValue(false)`。
/// 
/// ### 示例
/// 
/// ```mbt nocheck
/// let q = confirm(
///   question_name="agree",
///   question_message="Do you agree to the terms?",
///   question_default=Some(AnswerValue::BoolValue(true))
/// )
/// ```

///|
/// # 问题构造函数
/// 
/// ## list
/// 
/// 创建列表选择问题。
/// 
/// ### 函数签名
/// 
/// `pub fn list(question_name~ : String, question_message~ : String, question_choices~ : Array[String], question_default? : AnswerValue? = None) -> Question`
/// 
/// ### 参数
/// 
/// - `question_name~ : String` - 问题名称
/// - `question_message~ : String` - 问题文本
/// - `question_choices~ : Array[String]` - 选项数组
/// - `question_default? : AnswerValue?` - 可选的默认选项索引,使用 `AnswerValue::IntValue(0)` 表示第一个选项
/// 
/// ### 返回值
/// 
/// 返回用户选择的选项值:`AnswerValue::StringValue("selected_option")`
/// 
/// ### 示例
/// 
/// ```mbt nocheck
/// let q = list(
///   question_name="color",
///   question_message="Choose your favorite color:",
///   question_choices=["Red", "Green", "Blue", "Yellow"],
///   question_default=Some(AnswerValue::IntValue(0))
/// )
/// ```

///|
/// # 问题构造函数
/// 
/// ## rawlist
/// 
/// 创建带数字前缀的列表选择问题。
/// 
/// ### 函数签名
/// 
/// `pub fn rawlist(question_name~ : String, question_message~ : String, question_choices~ : Array[String], question_default? : AnswerValue? = None) -> Question`
/// 
/// ### 参数
/// 
/// - `question_name~ : String` - 问题名称
/// - `question_message~ : String` - 问题文本
/// - `question_choices~ : Array[String]` - 选项数组
/// - `question_default? : AnswerValue?` - 可选的默认选项索引
/// 
/// ### 返回值
/// 
/// 返回用户选择的选项值:`AnswerValue::StringValue("selected_option")`
/// 
/// ### 示例
/// 
/// ```mbt nocheck
/// let q = rawlist(
///   question_name="action",
///   question_message="Select an action:",
///   question_choices=["Run", "Debug", "Build", "Test"]
/// )
/// ```

///|
/// # 问题构造函数
/// 
/// ## expand
/// 
/// 创建展开式选择问题(按字母选择)。
/// 
/// ### 函数签名
/// 
/// `pub fn expand(question_name~ : String, question_message~ : String, question_choices~ : Array[String], question_default? : AnswerValue? = None) -> Question`
/// 
/// ### 参数
/// 
/// - `question_name~ : String` - 问题名称
/// - `question_message~ : String` - 问题文本
/// - `question_choices~ : Array[String]` - 选项数组
/// - `question_default? : AnswerValue?` - 可选的默认选项索引
/// 
/// ### 返回值
/// 
/// 返回用户选择的选项值:`AnswerValue::StringValue("selected_option")`
/// 
/// ### 示例
/// 
/// ```mbt nocheck
/// let q = expand(
///   question_name="format",
///   question_message="Select output format:",
///   question_choices=["JSON", "XML", "YAML"]
/// )
/// ```

///|
/// # 问题构造函数
/// 
/// ## checkbox
/// 
/// 创建多选框问题(可选择多个选项)。
/// 
/// ### 函数签名
/// 
/// `pub fn checkbox(question_name~ : String, question_message~ : String, question_choices~ : Array[String], question_default? : AnswerValue? = None) -> Question`
/// 
/// ### 参数
/// 
/// - `question_name~ : String` - 问题名称
/// - `question_message~ : String` - 问题文本
/// - `question_choices~ : Array[String]` - 选项数组
/// - `question_default? : AnswerValue?` - 可选的默认选项
/// 
/// ### 返回值
/// 
/// 返回用户选择的选项数组:`AnswerValue::ArrayValue(["option1", "option2"])`
/// 
/// ### 示例
/// 
/// ```mbt nocheck
/// let q = checkbox(
///   question_name="hobbies",
///   question_message="Select your hobbies:",
///   question_choices=["Reading", "Gaming", "Sports", "Music"]
/// )
/// ```

///|
/// # 问题构造函数
/// 
/// ## password
/// 
/// 创建密码输入问题(输入不可见)。
/// 
/// ### 函数签名
/// 
/// `pub fn password(question_name~ : String, question_message~ : String, question_default? : AnswerValue? = None) -> Question`
/// 
/// ### 参数
/// 
/// - `question_name~ : String` - 问题名称
/// - `question_message~ : String` - 问题文本
/// - `question_default? : AnswerValue?` - 可选的默认值
/// 
/// ### 返回值
/// 
/// 返回输入的密码:`AnswerValue::StringValue("password")`
/// 
/// ### 示例
/// 
/// ```mbt nocheck
/// let q = password(
///   question_name="pwd",
///   question_message="Enter your password:"
/// )
/// ```

///|
/// # 问题构造函数
/// 
/// ## editor
/// 
/// 创建多行文本输入问题。
/// 
/// ### 函数签名
/// 
/// `pub fn editor(question_name~ : String, question_message~ : String, question_default? : AnswerValue? = None) -> Question`
/// 
/// ### 参数
/// 
/// - `question_name~ : String` - 问题名称
/// - `question_message~ : String` - 问题文本
/// - `question_default? : AnswerValue?` - 可选的默认值
/// 
/// ### 返回值
/// 
/// 返回输入的文本:`AnswerValue::StringValue("multiline text")`
/// 
/// ### 示例
/// 
/// ```mbt nocheck
/// let q = editor(
///   question_name="bio",
///   question_message="Write your bio:",
///   question_default=Some(AnswerValue::StringValue("No bio provided"))
/// )
/// ```

///|
/// # 数据类型
/// 
/// ## QuestionType
/// 
/// 问题的类型枚举。
/// 
/// ```mbt nocheck
/// pub enum QuestionType {
///   Input       // 文本输入
///   Confirm     // 确认(是/否)
///   List        // 列表选择
///   RawList     // 带数字的列表选择
///   Expand      // 展开式选择
///   Checkbox    // 多选框
///   Password    // 密码输入
///   Editor      // 多行文本输入
/// }
/// ```

///|
/// # 数据类型
/// 
/// ## AnswerValue
/// 
/// 问题答案的值类型枚举。
/// 
/// ```mbt nocheck
/// pub enum AnswerValue {
///   StringValue(String)        // 字符串值(Input、List、Password、Editor)
///   BoolValue(Bool)             // 布尔值(Confirm)
///   ArrayValue(Array[String])   // 数组值(Checkbox)
///   IntValue(Int)              // 整数值(用于指定默认选项索引)
/// }
/// ```

///|
/// # 数据类型
/// 
/// ## Answer
/// 
/// 答案映射类型。
/// 
/// `pub type Answer = Map[String, AnswerValue]`
/// 
/// 用于存储问题名称到答案值的映射。
/// 
/// ```mbt nocheck
/// let answers : Answer = prompt(questions)
/// match answers["username"] {
///   AnswerValue::StringValue(name) => println("Hello, \{name}!")
///   _ => {}
/// }
/// ```

///|
/// # 数据类型
/// 
/// ## Question
/// 
/// 问题结构体定义。
/// 
/// ```mbt nocheck
/// pub struct Question {
///   question_type : QuestionType        // 问题类型
///   question_name : String             // 问题名称(用于获取答案)
///   question_message : String          // 问题文本
///   question_default : AnswerValue?    // 可选的默认值
///   question_choices : Array[String]?   // 可选的选项列表
/// }
/// ```

///|
/// # 工具函数
/// 
/// ## parse_int
/// 
/// 将字符串解析为整数。
/// 
/// ### 函数签名
/// 
/// `pub fn parse_int(s : String) -> Int?`
/// 
/// ### 参数
/// 
/// - `s : String` - 要解析的字符串
/// 
/// ### 返回值
/// 
/// - `Some(Int)` - 解析成功
/// - `None` - 解析失败
/// 
/// ### 示例
/// 
/// ```mbt nocheck
/// match parse_int("123") {
///   Some(n) => println("Number: \{n}")
///   None => println("Not a number")
/// }
/// ```