use super::{ManagerSection, NoteSection, OptionsSection};
use serde::{Deserialize, Serialize};

// 维护者条目可以是简单字符串（名字）或对象（包含name、link、type）
/// AUTO-GENERATED BY Kam/scripts/add_missing_docs.py: placeholder documentation for public enum 'MaintainerEntry'. Replace with real documentation. (2025-12-30T22:23:21Z)
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq)]
#[serde(untagged)]
pub enum MaintainerEntry {
    /// AUTO-GENERATED BY Kam/scripts/add_missing_docs.py: placeholder documentation for public enum variant 'Name' in 'MaintainerEntry'. Replace with real documentation. (2025-12-30T22:23:21Z)
    Name(String),
    /// AUTO-GENERATED BY Kam/scripts/add_missing_docs.py: placeholder documentation for public enum variant 'Object' in 'MaintainerEntry'. Replace with real documentation. (2025-12-30T22:23:21Z)
    Object(Maintainer),
}

/// AUTO-GENERATED BY Kam/scripts/add_missing_docs.py: placeholder documentation for public struct 'Maintainer'. Replace with real documentation. (2025-12-30T22:23:21Z)
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq)]
#[allow(non_snake_case)]
pub struct Maintainer {
    /// Optional maintainer type (e.g., "author", "maintainer"). This field
    /// maps to the TOML key `type` and is kept as a raw identifier because
    /// `type` is a Rust keyword.
    #[serde(rename = "type")]
    pub r#type: Option<String>,
    /// AUTO-GENERATED BY Kam/scripts/add_missing_docs.py: placeholder documentation for public field 'name' in 'Maintainer'. Replace with real documentation. (2025-12-30T22:23:21Z)
    pub name: String,
    /// AUTO-GENERATED BY Kam/scripts/add_missing_docs.py: placeholder documentation for public field 'link' in 'Maintainer'. Replace with real documentation. (2025-12-30T22:23:21Z)
    pub link: Option<String>,
}

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq)]
#[allow(non_snake_case)]
// 仓库/发布信息节，包含展示与分发相关的元数据（匹配repo.json规范）
/// AUTO-GENERATED BY Kam/scripts/add_missing_docs.py: placeholder documentation for public struct 'RepoSection'. Replace with real documentation. (2025-12-30T22:23:21Z)
pub struct RepoSection {
    // SPDX许可证标识符（例如 "MIT"），见 https://spdx.org/licenses/
    /// AUTO-GENERATED BY Kam/scripts/add_missing_docs.py: placeholder documentation for public field 'license' in 'RepoSection'. Replace with real documentation. (2025-12-30T22:23:21Z)
    pub license: Option<String>,
    // 许可证文件名（相对路径），例如 LICENSE
    /// AUTO-GENERATED BY Kam/scripts/add_missing_docs.py: placeholder documentation for public field 'license_file' in 'RepoSection'. Replace with real documentation. (2025-12-30T22:23:21Z)
    pub license_file: Option<String>,
    // 项目主页URL
    /// AUTO-GENERATED BY Kam/scripts/add_missing_docs.py: placeholder documentation for public field 'homepage' in 'RepoSection'. Replace with real documentation. (2025-12-30T22:23:21Z)
    pub homepage: Option<String>,
    // README URL（例如GitHub README链接）
    /// AUTO-GENERATED BY Kam/scripts/add_missing_docs.py: placeholder documentation for public field 'readme' in 'RepoSection'. Replace with real documentation. (2025-12-30T22:23:21Z)
    pub readme: Option<String>,
    // README文件名（相对路径），例如 README.md
    /// AUTO-GENERATED BY Kam/scripts/add_missing_docs.py: placeholder documentation for public field 'readme_file' in 'RepoSection'. Replace with real documentation. (2025-12-30T22:23:21Z)
    pub readme_file: Option<String>,
    // Changelog URL
    /// AUTO-GENERATED BY Kam/scripts/add_missing_docs.py: placeholder documentation for public field 'changelog' in 'RepoSection'. Replace with real documentation. (2025-12-30T22:23:21Z)
    pub changelog: Option<String>,
    // Changelog文件名（相对路径），例如 CHANGELOG.md
    /// AUTO-GENERATED BY Kam/scripts/add_missing_docs.py: placeholder documentation for public field 'changelog_file' in 'RepoSection'. Replace with real documentation. (2025-12-30T22:23:21Z)
    pub changelog_file: Option<String>,
    // 屏幕截图URL列表
    /// AUTO-GENERATED BY Kam/scripts/add_missing_docs.py: placeholder documentation for public field 'screenshots' in 'RepoSection'. Replace with real documentation. (2025-12-30T22:23:21Z)
    pub screenshots: Option<Vec<String>>,
    // 类别标签列表
    /// AUTO-GENERATED BY Kam/scripts/add_missing_docs.py: placeholder documentation for public field 'categories' in 'RepoSection'. Replace with real documentation. (2025-12-30T22:23:21Z)
    pub categories: Option<Vec<String>>,
    // 关键字标签列表，便于搜索或索引
    /// AUTO-GENERATED BY Kam/scripts/add_missing_docs.py: placeholder documentation for public field 'keywords' in 'RepoSection'. Replace with real documentation. (2025-12-30T22:23:21Z)
    pub keywords: Option<Vec<String>>,
    // 维护者列表（可支持字符串或对象形式）
    /// AUTO-GENERATED BY Kam/scripts/add_missing_docs.py: placeholder documentation for public field 'maintainers' in 'RepoSection'. Replace with real documentation. (2025-12-30T22:23:21Z)
    pub maintainers: Option<Vec<MaintainerEntry>>,
    // 源代码仓库地址（例如GitHub仓库URL）
    /// AUTO-GENERATED BY Kam/scripts/add_missing_docs.py: placeholder documentation for public field 'repository' in 'RepoSection'. Replace with real documentation. (2025-12-30T22:23:21Z)
    pub repository: Option<String>,
    // 文档链接（外部文档或站点）
    /// AUTO-GENERATED BY Kam/scripts/add_missing_docs.py: placeholder documentation for public field 'documentation' in 'RepoSection'. Replace with real documentation. (2025-12-30T22:23:21Z)
    pub documentation: Option<String>,
    /// 问题跟踪（issues）链接
    pub issues: Option<String>,
    /// 资助/捐赠链接集合或描述
    pub funding: Option<String>,
    /// 官方支持入口（例如 issue 页面或支持站点）
    pub support: Option<String>,
    /// 捐赠链接（例如 PayPal 等）
    pub donate: Option<String>,
    /// 封面图片 URL（适用于展示）
    pub cover: Option<String>,
    /// 图标 URL（可用于 UI 显示）
    pub icon: Option<String>,
    /// 支持或针对的设备列表（字符串标识）
    pub devices: Option<Vec<String>>,
    /// 支持的 CPU 架构列表（如 arm64-v8a）
    pub arch: Option<Vec<String>>,
    /// 运行或安装所需的其它模块/组件标识列表
    pub require: Option<Vec<String>>,
    /// 可显示的提示/通知块（标题、消息）
    pub note: Option<NoteSection>,
    /// 各种包管理器/平台的最小版本或需求配置
    pub manager: Option<ManagerSection>,
    /// 与模块不兼容/禁用的功能标签
    pub antifeatures: Option<Vec<String>>,
    /// 额外选项（例如归档压缩配置）
    pub options: Option<OptionsSection>,
    /// 最大数量（语义依赖于上层使用场景，默认 0 表示未设置）
    pub max_num: Option<i64>,
    /// 模块所需的最小 Kam API 版本
    pub min_api: Option<u32>,
    /// 模块支持的最大 Kam API 版本
    pub max_api: Option<u32>,
    /// 是否经过验证（verified 标记）
    pub verified: Option<bool>,
    /// 模块提供的功能/特性列表，用于展示、索引或描述模块能力。
    pub features: Option<Vec<String>>,
}

impl Default for RepoSection {
    fn default() -> Self {
        Self {
            license: Some("MIT".to_string()),
            license_file: Some("LICENSE".to_string()),
            homepage: Some(String::new()),
            readme: Some(String::new()),
            readme_file: Some("README.md".to_string()),
            changelog: Some(String::new()),
            changelog_file: Some("CHANGELOG.md".to_string()),
            screenshots: Some(vec![]),
            categories: Some(vec!["tools".to_string()]),
            keywords: Some(vec![
                "kam".to_string(),
                "module".to_string(),
                "android".to_string(),
            ]),
            maintainers: Some(vec![]),
            repository: Some(String::new()),
            documentation: Some(String::new()),
            issues: Some(String::new()),
            funding: Some(String::new()),
            support: Some(String::new()),
            donate: Some(String::new()),
            cover: Some(String::new()),
            icon: Some(String::new()),
            devices: Some(vec![]),
            arch: Some(vec![]),
            require: Some(vec![]),
            note: Some(NoteSection::default()),
            manager: Some(ManagerSection::default()),
            antifeatures: Some(vec![]),
            options: Some(OptionsSection::default()),
            max_num: Some(0i64),
            min_api: Some(0),
            max_api: Some(0),
            verified: Some(false),
            features: Some(vec![
                "module-template".to_string(),
                "customization".to_string(),
            ]),
        }
    }
}
