import { createRouter, createWebHistory } from 'vue-router';
import { authGuard } from './authGuard';

const basePath = import.meta.env.VITE_BASE_PATH || '/app/';

const router = createRouter({
  history: createWebHistory(basePath),
  routes: [
    {
      path: '/',
      name: 'home',
      redirect: '/stake',
    },
    {
      path: '/stake',
      name: 'stake',
      meta: {
        title: 'Stake',
        group: 'navbar',
        layout: 'NavbarLayout',
      },
      beforeEnter: authGuard,
      component: () => import('../views/StakeView.vue'),
    },
    {
      path: '/login',
      name: 'login',
      meta: {
        layout: 'DefaultLayout',
      },
      component: () => import('../views/LoginView.vue'),
    },
    {
      path: '/get-krk',
      name: 'get-krk',
      meta: {
        title: 'Get KRK',
        layout: 'NavbarLayout',
      },
      component: () => import('../views/GetKrkView.vue'),
    },
    {
      path: '/cheats',
      name: 'cheats',
      meta: {
        title: 'Cheat Console',
        layout: 'NavbarLayout',
      },
      component: () => import('../views/CheatsView.vue'),
    },
    {
      path: '/wallet/:address',
      name: 'wallet',
      meta: {
        title: 'Wallet',
        layout: 'NavbarLayout',
      },
      component: () => import('../views/WalletView.vue'),
    },
    {
      path: '/position/:id',
      name: 'position',
      meta: {
        title: 'Position',
        layout: 'NavbarLayout',
      },
      component: () => import('../views/PositionView.vue'),
    },
  ],
});

export default router;
