import type { DefaultTheme } from 'vitepress';

import { defineConfig } from 'vitepress';

import { version } from '../../../package.json';

export const zh = defineConfig({
  description: '悦码 & 低代码管理系统',
  lang: 'zh-Hans',
  themeConfig: {
    darkModeSwitchLabel: '主题',
    darkModeSwitchTitle: '切换到深色模式',
    docFooter: {
      next: '下一页',
      prev: '上一页',
    },
    // editLink: {
    //   pattern:
    //     'https://github.com/vbenjs/vue-vben-admin/edit/main/docs/src/:path',
    //   text: '在 GitHub 上编辑此页面',
    // },
    // footer: {
    //   copyright: `Copyright © 2020-${new Date().getFullYear()} Vben`,
    //   message: '基于 MIT 许可发布.',
    // },
    // langMenuLabel: '多语言',
    lastUpdated: {
      formatOptions: {
        dateStyle: 'short',
        timeStyle: 'medium',
      },
      text: '最后更新于',
    },
    lightModeSwitchTitle: '切换到浅色模式',
    nav: nav(),

    outline: {
      label: '页面导航',
    },
    returnToTopLabel: '回到顶部',

    sidebar: {
      '/commercial/': { base: '/commercial/', items: sidebarCommercial() },
      '/components/': { base: '/components/', items: sidebarComponents() },
      '/guide/': { base: '/guide/', items: sidebarGuide() },
    },
    sidebarMenuLabel: '菜单',
  },
});

function sidebarGuide(): DefaultTheme.SidebarItem[] {
  return [
    {
      collapsed: false,
      text: '简介',
      items: [
        {
          link: 'introduction/platform',
          text: '关于悦码',
        },
        { link: 'introduction/quick-start', text: '快速开始' },
        {
          base: '/',
          link: 'components/index',
          text: '组件文档',
        },
      ],
    },
    {
      text: '基础',
      items: [
        { link: 'essentials/concept', text: '基础概念' },
        { link: 'essentials/icons', text: '图标' },
        { link: 'essentials/styles', text: '样式' },
      ],
    },
    {
      text: '深入',
      items: [{ link: 'in-depth/features', text: '常用功能' }],
    },
    {
      text: '其他',
      items: [
        // { link: 'other/project-update', text: '项目更新' },
        // { link: 'other/remove-code', text: '移除代码' },
        // { link: 'other/faq', text: '常见问题' },
      ],
    },
  ];
}

function sidebarCommercial(): DefaultTheme.SidebarItem[] {
  return [
    {
      link: 'community',
      text: '交流群',
    },
    {
      link: 'technical-support',
      text: '技术支持',
    },
  ];
}

function sidebarComponents(): DefaultTheme.SidebarItem[] {
  return [
    {
      text: '组件',
      items: [
        {
          link: 'introduction',
          text: '介绍',
        },
      ],
    },
    {
      collapsed: false,
      text: '布局组件',
      items: [
        {
          link: 'layout-ui/page',
          text: 'Page 页面',
        },
      ],
    },
    {
      collapsed: false,
      text: '通用组件',
      items: [
        {
          link: 'common-ui/vben-api-component',
          text: 'ApiComponent Api组件包装器',
        },
        {
          link: 'common-ui/vben-modal',
          text: 'Modal 模态框',
        },
        {
          link: 'common-ui/vben-drawer',
          text: 'Drawer 抽屉',
        },
        {
          link: 'common-ui/vben-form',
          text: 'Form 表单',
        },
        {
          link: 'common-ui/vben-vxe-table',
          text: 'Vxe Table 表格',
        },
        {
          link: 'common-ui/vben-count-to-animator',
          text: 'CountToAnimator 数字动画',
        },
        {
          link: 'common-ui/vben-ellipsis-text',
          text: 'EllipsisText 省略文本',
        },
      ],
    },
  ];
}

function nav(): DefaultTheme.NavItem[] {
  return [
    {
      activeMatch: '^/(guide|components)/',
      text: '文档',
      items: [
        {
          activeMatch: '^/guide/',
          link: '/guide/introduction/platform',
          text: '低代码管理平台',
        },
        {
          activeMatch: '^/renderer/',
          link: '/renderer/index',
          text: '渲染器',
        },
        {
          activeMatch: '^/designer/',
          link: '/designer/index',
          text: '设计器',
        },
        {
          activeMatch: '^/materials/',
          link: '/materials/index',
          text: '物料',
        },
      ],
    },
    {
      text: '低代码管理平台',
      items: [
        {
          text: '悦码 2.0',
          items: [
            {
              link: 'https://y-code-platform.shiyuegame.com',
              text: '生产版本',
            },
            {
              link: 'https://y-code-platform-pre.shiyue.com',
              text: '预发布版本',
            },
            {
              link: 'https://y-code-platform.shiyuegame.com',
              text: '演示版本',
            },
          ],
        },
        {
          text: '其他',
          items: [
            {
              link: 'https://custom-chart.shiyuegame.com/',
              text: '悦码 1.0（已废弃，不再更新功能）',
            },
          ],
        },
      ],
    },
    {
      text: version,
      items: [
        {
          link: './changelog',
          text: '更新日志',
        },
        {
          link: 'https://doc.weixin.qq.com/smartsheet/s3_Aa0ASwZ0AOEr2TbPuaMRoCvs1yzjA?scode=AOwAYgeoAAkoT6VFa0Aa0ASwZ0AOE&tab=q979lj&viewId=vpDUFs',
          text: '更新路线图',
        },
      ],
    },
    {
      text: '👨‍👦‍👦 问题反馈',
      items: [
        {
          link: 'https://qun.qq.com/qqweb/qunpro/share?_wv=3&_wwv=128&appChannel=share&inviteCode=22ySzj7pKiw&businessType=9&from=246610&biz=ka&mainSourceId=share&subSourceId=others&jumpsource=shorturl#/pc',
          text: '热心大姐',
        },
      ],
    },
  ];
}

export const search: DefaultTheme.AlgoliaSearchOptions['locales'] = {
  root: {
    placeholder: '搜索文档',
    translations: {
      button: {
        buttonAriaLabel: '搜索文档',
        buttonText: '搜索文档',
      },
      modal: {
        errorScreen: {
          helpText: '你可能需要检查你的网络连接',
          titleText: '无法获取结果',
        },
        footer: {
          closeText: '关闭',
          navigateText: '切换',
          searchByText: '搜索提供者',
          selectText: '选择',
        },
        noResultsScreen: {
          noResultsText: '无法找到相关结果',
          reportMissingResultsLinkText: '点击反馈',
          reportMissingResultsText: '你认为该查询应该有结果？',
          suggestedQueryText: '你可以尝试查询',
        },
        searchBox: {
          cancelButtonAriaLabel: '取消',
          cancelButtonText: '取消',
          resetButtonAriaLabel: '清除查询条件',
          resetButtonTitle: '清除查询条件',
        },
        startScreen: {
          favoriteSearchesTitle: '收藏',
          noRecentSearchesText: '没有搜索历史',
          recentSearchesTitle: '搜索历史',
          removeFavoriteSearchButtonTitle: '从收藏中移除',
          removeRecentSearchButtonTitle: '从搜索历史中移除',
          saveRecentSearchButtonTitle: '保存至搜索历史',
        },
      },
    },
  },
};
