import type { RouteRecordRaw } from 'vue-router'

const routes: RouteRecordRaw[] = [
  {
    path: '/',
    component: () => import('layouts/MainLayout.vue'),
    children: [
      {
        path: '',
        redirect: { name: 'projects' }
      },
      {
        name: 'projects',
        path: '/projects',
        component: () => import('pages/ProjectsPage.vue'),
        meta: { 
          hideBackButton: true
        }
      },
      {
        name: 'project_add',
        path: '/project/add',
        component: () => import('pages/ProjectAddPage.vue')
      },
      {
        name: 'project_info',
        path: '/project/:id(\\d+)/info',
        component: () => import('pages/ProjectEditPage.vue')
      },
      {
        name: 'company_mask',
        path: '/project/:id(\\d+)/company-mask',
        component: () => import('pages/CompanyMaskPage.vue')
      },
      {
        path: '/project/:id(\\d+)',
        component: () => import('pages/ProjectPage.vue'),
        children: [
          {
            name: 'project',
            path: '',
            redirect: { name: 'chats' }
          },
          {
            name: 'chats',
            path: 'chats',
            component: () => import('pages/project-page/ProjectPageChats.vue'),
            props: true,
            meta: { 
              backRoute: 'projects'
            }
          },
          {
            name: 'users',
            path: 'users',
            props: true,
            component: () => import('pages/project-page/ProjectPageUsers.vue'),
            meta: { 
              backRoute: 'projects'
            }
          },
          {
            name: 'companies',
            path: 'companies',
            props: true,
            component: () => import('pages/project-page/ProjectPageCompanies.vue'),
            meta: { 
              backRoute: 'projects'
            }
          },
          {
            name: 'backup',
            path: 'backup',
            props: true,
            component: () => import('pages/project-page/ProjectPageBackup.vue'),
            meta: { 
              backRoute: 'projects'
            }
          }
        ]
      },
      {
        name: 'chat_info',
        path: '/project/:id(\\d+)/chat/:chatId',
        component: () => import('pages/ChatPage.vue')
      },
      {
        name: 'add_company',
        path: '/project/:id(\\d+)/add-company',
        component: () => import('pages/CompanyAddPage.vue')
      },
      {
        name: 'company_info',
        path: '/project/:id(\\d+)/company/:companyId',
        component: () => import('pages/CompanyEditPage.vue')
      },
      {
        name: 'user_info',
        path: '/project/:id(\\d+)/user/:userId',
        component: () => import('pages/UserEditPage.vue')
      },
      {
        name: 'account',
        path: '/account',
        component: () => import('pages/AccountPage.vue')
      },
      {
        name: 'create_account',
        path: '/create-account',
        component: () => import('pages/AccountCreatePage.vue')
      },
      {
        name: 'change_account_password',
        path: '/change-password',
        component: () => import('pages/account/ChangePasswordPage.vue')
      },
      {
        name: 'change_account_email',
        path: '/change-email',
        component: () => import('pages/account/ChangeEmailPage.vue')
      },
      {
        name: 'change_account_auth_method',
        path: '/change-auth-method',
        component: () => import('pages/account/ChangeAuthMethodPage.vue')
      },
      {
        name: 'subscribe',
        path: '/subscribe',
        component: () => import('pages/account/SubscribePage.vue')
      },
      {
        name: 'agreements',
        path: '/agreements',
        component: () => import('pages/AgreementsPage.vue')
      },
      {
        name: 'terms',
        path: '/terms-of-use',
        component: () => import('pages/account/TermsPage.vue'),
      },
      {
        name: 'privacy',
        path: '/privacy',
        component: () => import('pages/account/PrivacyPage.vue')
      },
      {
        name: 'consent',
        path: '/consent-pd',
        component: () => import('pages/account/ConsentPage.vue')
      },
      {
        name: 'tariffs_info',
        path: '/tariffs-info',
        component: () => import('pages/account/TariffsInfoPage.vue')
      },
      {
        name: 'support',
        path: '/support',
        component: () => import('pages/account/SupportPage.vue')
      },
      {
        name: 'storage',
        path: '/storage',
        component: () => import('pages/account/StoragePage.vue')
      },
      {
        name: 'your_company',
        path: '/your-company',
        component: () => import('pages/account/CompanyYourPage.vue')
      },
      {
        name: 'login',
        path: '/login',
        component: () => import('pages/LoginPage.vue'),
        meta: { 
          hideBackButton: true
        }
      },
      {
        name: 'recovery_password',
        path: '/recovery-password',
        component: () => import('pages/AccountForgotPasswordPage.vue')
      },
      {
        name: 'settings',
        path: '/settings',
        component: () => import('pages/account/SettingsPage.vue')
      }
    ]
  },
  {
    name: 'telegram_only',
    path: '/telegram-only',
    component: () => import('pages/TelegramOnlyPage.vue')
  },
  {
    path: '/:catchAll(.*)*',
    component: () => import('pages/ErrorNotFound.vue')
  }
]

export default routes