import type { RouteRecordRaw } from 'vue-router'

export const adminRoutes: RouteRecordRaw[] = [
  {
    path: '',
    redirect: { name: 'admin-dashboard' },
  },
  {
    path: 'dashboard',
    name: 'admin-dashboard',
    component: () => import('../views/admin/AdminDashboardView.vue'),
    meta: { keepAlive: true },
  },
  {
    path: 'seasons',
    redirect: { name: 'admin-years' },
  },
  {
    path: 'years',
    name: 'admin-years',
    component: () => import('../views/admin/AdminSeasonsView.vue'),
    meta: { keepAlive: true },
  },
  {
    path: 'nominations',
    name: 'admin-nominations',
    component: () => import('../views/admin/AdminNominationsView.vue'),
    meta: { keepAlive: true },
  },
  {
    path: 'categories',
    name: 'admin-categories',
    component: () => import('../views/admin/AdminCategoriesView.vue'),
    meta: { keepAlive: true },
  },
  {
    path: 'candidates',
    name: 'admin-candidates',
    component: () => import('../views/admin/AdminCandidatesView.vue'),
    meta: { keepAlive: true },
  },
  {
    path: 'archive',
    name: 'admin-archive',
    component: () => import('../views/admin/AdminArchiveView.vue'),
    meta: { keepAlive: true },
  },
  {
    path: 'clips',
    name: 'admin-clips',
    component: () => import('../views/admin/AdminClipsView.vue'),
    meta: { keepAlive: true },
  },
  {
    path: 'reviews',
    name: 'admin-reviews',
    redirect: (to) => ({
      name: 'admin-nominations',
      query: { ...to.query, review: '1' },
    }),
  },
  {
    path: 'risk',
    name: 'admin-risk',
    component: () => import('../views/admin/AdminRiskView.vue'),
    meta: { keepAlive: true },
  },
  {
    path: 'users-logs',
    name: 'admin-users-logs',
    component: () => import('../views/admin/AdminUsersLogsView.vue'),
    meta: { keepAlive: true },
  },
  {
    path: 'team',
    name: 'admin-team',
    component: () => import('../views/admin/AdminTeamView.vue'),
    meta: { keepAlive: true },
  },
  {
    path: 'analytics',
    name: 'admin-analytics',
    component: () => import('../views/admin/AdminAnalyticsView.vue'),
    meta: { keepAlive: true },
  },
  {
    path: 'voting',
    name: 'admin-voting',
    component: () => import('../views/admin/AdminVotingView.vue'),
    meta: { keepAlive: true },
  },
  {
    path: 'winners',
    name: 'admin-winners',
    component: () => import('../views/admin/AdminWinnersView.vue'),
    meta: { keepAlive: true },
  },
  {
    path: 'content',
    name: 'admin-content',
    component: () => import('../views/admin/AdminContentView.vue'),
    meta: { keepAlive: true },
  },
  {
    path: 'settings',
    name: 'admin-settings',
    component: () => import('../views/admin/AdminSettingsView.vue'),
    meta: { keepAlive: true },
  },
  {
    path: 'settings/access',
    name: 'admin-settings-access',
    component: () => import('../views/admin/AdminAccessSettingsView.vue'),
    meta: { keepAlive: true },
  },
  {
    path: 'settings/demo-preview',
    redirect: { name: 'admin-settings-access' },
  },
  {
    path: 'settings/maintenance-mode',
    redirect: { name: 'admin-settings-access' },
  },
  {
    path: 'settings/workflows',
    name: 'admin-settings-workflows',
    component: () => import('../views/admin/AdminWorkflowSettingsView.vue'),
    meta: { keepAlive: true },
  },
  {
    path: 'settings/workflow-rules',
    redirect: { name: 'admin-settings-workflows' },
  },
  {
    path: 'settings/optional-workflows',
    redirect: { name: 'admin-settings-workflows' },
  },
  {
    path: 'tracking-rules',
    name: 'admin-tracking-rules',
    component: () => import('../views/admin/AdminTrackingRulesView.vue'),
    meta: { keepAlive: true },
  },
]

export const routes: RouteRecordRaw[] = [
  {
    path: '/',
    name: 'home',
    component: () => import('../views/HomeView.vue'),
  },
  {
    path: '/login',
    name: 'login',
    component: () => import('../views/LoginView.vue'),
    meta: {
      bareShell: true,
    },
  },
  {
    path: '/auth/twitch/callback',
    name: 'twitch-auth-callback',
    component: () => import('../views/TwitchAuthCallbackView.vue'),
    meta: {
      bareShell: true,
    },
  },
  {
    path: '/status/network-error',
    name: 'network-error',
    component: () => import('../views/NetworkErrorView.vue'),
    meta: {
      bareShell: true,
    },
  },
  {
    path: '/maintenance',
    name: 'maintenance',
    component: () => import('../views/MaintenanceView.vue'),
    meta: {
      bareShell: true,
    },
  },
  {
    path: '/admin',
    component: () => import('../views/admin/AdminLayoutView.vue'),
    meta: {
      requiresAdmin: true,
    },
    children: adminRoutes,
  },
  {
    path: '/:pathMatch(.*)*',
    name: 'not-found',
    component: () => import('../views/NotFoundView.vue'),
    meta: {
      bareShell: true,
    },
  },
]
