import { defineConfig } from 'vitepress'
import { withMermaid } from 'vitepress-plugin-mermaid'

// https://vitepress.dev/reference/site-config
export default withMermaid(defineConfig({
    title: "GoodGo Platform",
    description: "Microservices Platform Documentation",

    // Source directory - points to the docs folder
    srcDir: '../../docs',

    // Multi-language support
    locales: {
        en: {
            label: 'English',
            lang: 'en',
            link: '/en/',
            themeConfig: {
                nav: [
                    { text: 'Home', link: '/en/' },
                    { text: 'Guides', link: '/en/guides/getting-started' },
                    { text: 'Architecture', link: '/en/architecture/system-design' },
                    { text: 'Templates', link: '/en/templates/' },
                    { text: 'Skills', link: '/en/skills/' },
                    { text: 'Runbooks', link: '/en/runbooks/' }
                ],
                sidebar: {
                    '/en/guides/': [
                        {
                            text: 'Guides',
                            items: [
                                { text: 'Getting Started', link: '/en/guides/getting-started' },
                                { text: 'Development', link: '/en/guides/development' },
                                { text: 'Local Development', link: '/en/guides/local-development' },
                                { text: 'Local Deployment', link: '/en/guides/local-deployment' },
                                { text: 'Deployment', link: '/en/guides/deployment' },
                                { text: 'Kubernetes Local', link: '/en/guides/kubernetes-local' },
                                { text: 'Neon Database', link: '/en/guides/neon-database' },
                                { text: 'Observability', link: '/en/guides/observability' },
                                { text: 'IAM Migration', link: '/en/guides/iam-migration' },
                                { text: 'Mermaid', link: '/en/guides/mermaid' },
                                { text: 'Troubleshooting', link: '/en/guides/troubleshooting' }
                            ]
                        }
                    ],
                    '/en/architecture/': [
                        {
                            text: 'Architecture',
                            items: [
                                { text: 'System Design', link: '/en/architecture/system-design' },
                                { text: 'Microservices Communication', link: '/en/architecture/microservices-communication' },
                                { text: 'Event-Driven Architecture', link: '/en/architecture/event-driven-architecture' },
                                { text: 'Data Consistency Patterns', link: '/en/architecture/data-consistency-patterns' },
                                { text: 'Caching Architecture', link: '/en/architecture/caching-architecture' },
                                { text: 'Security Architecture', link: '/en/architecture/security-architecture' },
                                { text: 'Observability Architecture', link: '/en/architecture/observability-architecture' },
                                { text: 'IAM Proposal', link: '/en/architecture/iam-proposal' }
                            ]
                        }
                    ],
                    '/en/templates/': [
                        {
                            text: 'Templates',
                            items: [
                                { text: 'Overview', link: '/en/templates/' },
                                { text: 'Node.js Template', link: '/en/templates/nodejs-template' },
                                { text: '.NET Template', link: '/en/templates/dotnet-template' },
                                { text: 'Architecture', link: '/en/templates/architecture' },
                                { text: 'Guide', link: '/en/templates/guide' },
                                { text: 'Mermaid Guide', link: '/en/templates/mermaid-guide' },
                                { text: 'Skill Pattern', link: '/en/templates/skill-pattern' }
                            ]
                        }
                    ],
                    '/en/skills/': [
                        {
                            text: 'Skills',
                            items: [
                                { text: 'Overview', link: '/en/skills/' },
                                { text: 'API Design', link: '/en/skills/api-design' },
                                { text: 'API Gateway', link: '/en/skills/api-gateway-advanced' },
                                { text: 'API Versioning', link: '/en/skills/api-versioning-strategy' },
                                { text: 'Caching Patterns', link: '/en/skills/caching-patterns' },
                                { text: 'CI/CD Patterns', link: '/en/skills/cicd-advanced-patterns' },
                                { text: 'Code Comments', link: '/en/skills/comment-code' },
                                { text: 'Configuration', link: '/en/skills/configuration-management' },
                                { text: 'Data Consistency', link: '/en/skills/data-consistency-patterns' },
                                { text: 'Database Prisma', link: '/en/skills/database-prisma' },
                                { text: 'Deployment K8s', link: '/en/skills/deployment-kubernetes' },
                                { text: 'Documentation', link: '/en/skills/documentation' },
                                { text: 'Error Handling', link: '/en/skills/error-handling-patterns' },
                                { text: 'Event-Driven', link: '/en/skills/event-driven-architecture' },
                                { text: 'Infrastructure', link: '/en/skills/infrastructure-as-code' },
                                { text: 'Inter-Service Comm', link: '/en/skills/inter-service-communication' },
                                { text: 'Microservices Dev', link: '/en/skills/microservices-development-process' },
                                { text: 'Middleware', link: '/en/skills/middleware-patterns' },
                                { text: 'Observability', link: '/en/skills/observability-monitoring' },
                                { text: 'Performance', link: '/en/skills/performance-optimization' },
                                { text: 'Project Rules', link: '/en/skills/project-rules' },
                                { text: 'Repository Pattern', link: '/en/skills/repository-pattern' },
                                { text: 'Resilience', link: '/en/skills/resilience-patterns' },
                                { text: 'Security', link: '/en/skills/security' },
                                { text: 'Service Discovery', link: '/en/skills/service-discovery-registry' },
                                { text: 'Service Layer', link: '/en/skills/service-layer-patterns' },
                                { text: 'Testing', link: '/en/skills/testing-patterns' }
                            ]
                        }
                    ],
                    '/en/runbooks/': [
                        {
                            text: 'Runbooks',
                            items: [
                                { text: 'Overview', link: '/en/runbooks/' },
                                { text: 'Incident Response', link: '/en/runbooks/incident-response' },
                                { text: 'Rollback Procedure', link: '/en/runbooks/rollback-procedure' }
                            ]
                        }
                    ]
                }
            }
        },
        vi: {
            label: 'Tiếng Việt',
            lang: 'vi',
            link: '/vi/',
            themeConfig: {
                nav: [
                    { text: 'Trang chủ', link: '/vi/' },
                    { text: 'Hướng dẫn', link: '/vi/guides/getting-started' },
                    { text: 'Kiến trúc', link: '/vi/architecture/system-design' },
                    { text: 'Templates', link: '/vi/templates/' },
                    { text: 'Skills', link: '/vi/skills/' },
                    { text: 'Runbooks', link: '/vi/runbooks/' }
                ],
                sidebar: {
                    '/vi/guides/': [
                        {
                            text: 'Hướng dẫn',
                            items: [
                                { text: 'Bắt đầu', link: '/vi/guides/getting-started' },
                                { text: 'Phát triển', link: '/vi/guides/development' },
                                { text: 'Phát triển Local', link: '/vi/guides/local-development' },
                                { text: 'Triển khai Local', link: '/vi/guides/local-deployment' },
                                { text: 'Triển khai', link: '/vi/guides/deployment' },
                                { text: 'Kubernetes Local', link: '/vi/guides/kubernetes-local' },
                                { text: 'Neon Database', link: '/vi/guides/neon-database' },
                                { text: 'Observability', link: '/vi/guides/observability' },
                                { text: 'IAM Migration', link: '/vi/guides/iam-migration' },
                                { text: 'Mermaid', link: '/vi/guides/mermaid' },
                                { text: 'Xử lý sự cố', link: '/vi/guides/troubleshooting' }
                            ]
                        }
                    ],
                    '/vi/architecture/': [
                        {
                            text: 'Kiến trúc',
                            items: [
                                { text: 'Thiết kế hệ thống', link: '/vi/architecture/system-design' },
                                { text: 'Giao tiếp Microservices', link: '/vi/architecture/microservices-communication' },
                                { text: 'Event-Driven', link: '/vi/architecture/event-driven-architecture' },
                                { text: 'Data Consistency', link: '/vi/architecture/data-consistency-patterns' },
                                { text: 'Caching', link: '/vi/architecture/caching-architecture' },
                                { text: 'Bảo mật', link: '/vi/architecture/security-architecture' },
                                { text: 'Observability', link: '/vi/architecture/observability-architecture' },
                                { text: 'IAM Proposal', link: '/vi/architecture/iam-proposal' }
                            ]
                        }
                    ],
                    '/vi/templates/': [
                        {
                            text: 'Templates',
                            items: [
                                { text: 'Tổng quan', link: '/vi/templates/' },
                                { text: 'Node.js Template', link: '/vi/templates/nodejs-template' },
                                { text: '.NET Template', link: '/vi/templates/dotnet-template' },
                                { text: 'Kiến trúc', link: '/vi/templates/architecture' },
                                { text: 'Hướng dẫn', link: '/vi/templates/guide' },
                                { text: 'Mermaid Guide', link: '/vi/templates/mermaid-guide' },
                                { text: 'Skill Pattern', link: '/vi/templates/skill-pattern' }
                            ]
                        }
                    ],
                    '/vi/skills/': [
                        {
                            text: 'Skills',
                            items: [
                                { text: 'Tổng quan', link: '/vi/skills/' },
                                { text: 'API Design', link: '/vi/skills/api-design' },
                                { text: 'API Gateway', link: '/vi/skills/api-gateway-advanced' },
                                { text: 'API Versioning', link: '/vi/skills/api-versioning-strategy' },
                                { text: 'Caching Patterns', link: '/vi/skills/caching-patterns' },
                                { text: 'CI/CD Patterns', link: '/vi/skills/cicd-advanced-patterns' },
                                { text: 'Code Comments', link: '/vi/skills/comment-code' },
                                { text: 'Configuration', link: '/vi/skills/configuration-management' },
                                { text: 'Data Consistency', link: '/vi/skills/data-consistency-patterns' },
                                { text: 'Database Prisma', link: '/vi/skills/database-prisma' },
                                { text: 'Deployment K8s', link: '/vi/skills/deployment-kubernetes' },
                                { text: 'Documentation', link: '/vi/skills/documentation' },
                                { text: 'Error Handling', link: '/vi/skills/error-handling-patterns' },
                                { text: 'Event-Driven', link: '/vi/skills/event-driven-architecture' },
                                { text: 'Infrastructure', link: '/vi/skills/infrastructure-as-code' },
                                { text: 'Inter-Service Comm', link: '/vi/skills/inter-service-communication' },
                                { text: 'Microservices Dev', link: '/vi/skills/microservices-development-process' },
                                { text: 'Middleware', link: '/vi/skills/middleware-patterns' },
                                { text: 'Observability', link: '/vi/skills/observability-monitoring' },
                                { text: 'Performance', link: '/vi/skills/performance-optimization' },
                                { text: 'Project Rules', link: '/vi/skills/project-rules' },
                                { text: 'Repository Pattern', link: '/vi/skills/repository-pattern' },
                                { text: 'Resilience', link: '/vi/skills/resilience-patterns' },
                                { text: 'Security', link: '/vi/skills/security' },
                                { text: 'Service Discovery', link: '/vi/skills/service-discovery-registry' },
                                { text: 'Service Layer', link: '/vi/skills/service-layer-patterns' },
                                { text: 'Testing', link: '/vi/skills/testing-patterns' }
                            ]
                        }
                    ],
                    '/vi/runbooks/': [
                        {
                            text: 'Runbooks',
                            items: [
                                { text: 'Tổng quan', link: '/vi/runbooks/' },
                                { text: 'Xử lý sự cố', link: '/vi/runbooks/incident-response' },
                                { text: 'Quy trình Rollback', link: '/vi/runbooks/rollback-procedure' }
                            ]
                        }
                    ]
                }
            }
        }
    },

    themeConfig: {
        // https://vitepress.dev/reference/default-theme-config
        logo: '/logo.svg',

        socialLinks: [
            { icon: 'github', link: 'https://github.com/goodgo/platform' }
        ],

        search: {
            provider: 'local'
        },

        footer: {
            message: 'GoodGo Microservices Platform',
            copyright: 'Copyright © 2024'
        }
    },

    // Vite configuration to fix ESM issues
    vite: {
        optimizeDeps: {
            include: ['mermaid']
        },
        ssr: {
            noExternal: ['mermaid']
        }
    },

    // Mermaid configuration
    mermaid: {
        // https://mermaid.js.org/config/setup/modules/mermaidAPI.html#mermaidapi-configuration-defaults
        theme: 'dark'
    },

    mermaidPlugin: {
        class: 'mermaid'
    }
}))
