import { createRouter, createWebHashHistory, createWebHistory } from 'vue-router'
import { routes } from './route'

const router = createRouter({
  history: import.meta.env.NODE_ENV ? createWebHistory() : createWebHashHistory(),
  routes,
})

// Navigation guards
router.beforeEach((to, _from, next) => {
  const hasWallet = true // useNeptuneStore().hasWallet

  if (to.meta.requiresAuth) {
    if (!hasWallet) {
      next({ name: 'auth' })
      return
    }
  }

  next()
})

export default router
