import { createRouter, createWebHistory } from 'vue-router'

const LoginPage = () => import('../pages/LoginPage.vue')
const RegisterPage = () => import('../pages/RegisterPage.vue')
const ResetPasswordPage = () => import('../pages/ResetPasswordPage.vue')
const SocialBindCallbackPage = () => import('../pages/SocialBindCallbackPage.vue')
const VerifyResultPage = () => import('../pages/VerifyResultPage.vue')
const AppLayout = () => import('../layouts/AppLayout.vue')

const AccountsPage = () => import('../pages/AccountsPage.vue')
const SchedulesPage = () => import('../pages/SchedulesPage.vue')
const ScreenshotsPage = () => import('../pages/ScreenshotsPage.vue')

const routes = [
  { path: '/', redirect: '/login' },
  { path: '/login', name: 'login', component: LoginPage },
  { path: '/register', name: 'register', component: RegisterPage },
  { path: '/reset-password/:token', name: 'reset_password', component: ResetPasswordPage },
  { path: '/social-bind-callback', name: 'social_bind_callback', component: SocialBindCallbackPage },
  { path: '/api/verify-email/:token', name: 'verify_email', component: VerifyResultPage },
  { path: '/api/verify-bind-email/:token', name: 'verify_bind_email', component: VerifyResultPage },
  {
    path: '/app',
    component: AppLayout,
    children: [
      { path: '', redirect: '/app/accounts' },
      { path: 'accounts', name: 'accounts', component: AccountsPage },
      { path: 'schedules', name: 'schedules', component: SchedulesPage },
      { path: 'screenshots', name: 'screenshots', component: ScreenshotsPage },
    ],
  },
  { path: '/:pathMatch(.*)*', redirect: '/login' },
]

const router = createRouter({
  history: createWebHistory(),
  routes,
})

export default router
