use serde::{Deserialize, Serialize};
use std::collections::BTreeMap;

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq)]
#[allow(non_snake_case)]
// 模板变量的定义
// 用来描述模板中可被替换的变量的类型、是否必需、默认值等
/// AUTO-GENERATED BY Kam/scripts/add_missing_docs.py: placeholder documentation for public struct 'VariableDefinition'. Replace with real documentation. (2025-12-30T22:23:21Z)
pub struct VariableDefinition {
    // 变量类型（例如 "string"、"bool"、"number" 等，自由约定）
    /// AUTO-GENERATED BY Kam/scripts/add_missing_docs.py: placeholder documentation for public field 'var_type' in 'VariableDefinition'. Replace with real documentation. (2025-12-30T22:23:21Z)
    pub var_type: String,
    // 是否为必需变量（未提供时模板引擎应报错或提示）
    /// AUTO-GENERATED BY Kam/scripts/add_missing_docs.py: placeholder documentation for public field 'required' in 'VariableDefinition'. Replace with real documentation. (2025-12-30T22:23:21Z)
    pub required: bool,
    // 可选的默认值（作为字符串表示）
    /// AUTO-GENERATED BY Kam/scripts/add_missing_docs.py: placeholder documentation for public field 'default' in 'VariableDefinition'. Replace with real documentation. (2025-12-30T22:23:21Z)
    pub default: Option<String>,
    // 可选的提示信息（模板作者可提供）
    // 当变量为必需且未提供时，模板会使用此字段作为更友好的错误或提示文本
    // 例如："请运行 `kam init ... --var name=...` 来设置模块名称"
    /// AUTO-GENERATED BY Kam/scripts/add_missing_docs.py: placeholder documentation for public field 'note' in 'VariableDefinition'. Replace with real documentation. (2025-12-30T22:23:21Z)
    pub note: Option<String>,
    // 更详细的帮助文本，适合显示给用户，解释该变量的语义或格式
    /// AUTO-GENERATED BY Kam/scripts/add_missing_docs.py: placeholder documentation for public field 'help' in 'VariableDefinition'. Replace with real documentation. (2025-12-30T22:23:21Z)
    pub help: Option<String>,
    // 示例值，供模板作者给出可选的示例输入
    /// AUTO-GENERATED BY Kam/scripts/add_missing_docs.py: placeholder documentation for public field 'example' in 'VariableDefinition'. Replace with real documentation. (2025-12-30T22:23:21Z)
    pub example: Option<String>,
    // 可选的枚举候选项，模板或交互式提示可以用来展示可选值
    /// AUTO-GENERATED BY Kam/scripts/add_missing_docs.py: placeholder documentation for public field 'choices' in 'VariableDefinition'. Replace with real documentation. (2025-12-30T22:23:21Z)
    pub choices: Option<Vec<String>>,
}

impl Default for VariableDefinition {
    fn default() -> Self {
        Self {
            var_type: "string".to_string(),
            required: false,
            default: None,
            note: None,
            help: None,
            example: None,
            choices: None,
        }
    }
}

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq)]
#[allow(non_snake_case)]
// 模板相关配置节，用于在模块中引用/配置子模板
// - used_template：可选引用的内置或自定义模板id
// - variables：模板变量定义表（变量名 -> 定义）
/// AUTO-GENERATED BY Kam/scripts/add_missing_docs.py: placeholder documentation for public struct 'TmplSection'. Replace with real documentation. (2025-12-30T22:23:21Z)
pub struct TmplSection {
    /// AUTO-GENERATED BY Kam/scripts/add_missing_docs.py: placeholder documentation for public field 'used_template' in 'TmplSection'. Replace with real documentation. (2025-12-30T22:23:21Z)
    pub used_template: Option<String>,
    /// AUTO-GENERATED BY Kam/scripts/add_missing_docs.py: placeholder documentation for public field 'variables' in 'TmplSection'. Replace with real documentation. (2025-12-30T22:23:21Z)
    pub variables: BTreeMap<String, VariableDefinition>,
}

impl Default for TmplSection {
    fn default() -> Self {
        Self {
            used_template: Some("kam_template".to_string()),
            variables: BTreeMap::new(),
        }
    }
}
