text: import { createRouter, createWebHistory } from 'vue-router';
  import HomeView from '../views/HomeView.vue';
  import MovieDetail from '../views/MovieDetail.vue';
  import FirstHome from '../views/FirstHome.vue';
  import LogIn from '../views/LogIn.vue';
  import SignUp from '../views/SignUp.vue';
  import { auth } from '../firebase';
  
  const routes = [
    {
      path: '/home',
      name: 'Home',
      component: HomeView,
      meta: {
        requiresAuth: true
      }
    },
    {
      path: '/movie/:id',
      name: 'Detail',
      component: MovieDetail
    },
    {
      path: '/login',
      name: 'LogIn',
      component: LogIn
    },
    {
      path: '/signup',
      name: 'SignUp',
      component: SignUp
    },
    {
      path: '/',
      name: 'FirstHome',
      component: FirstHome,
      meta: {
        requiresAuth: false
      }
    }
  ]
  
  const router = createRouter({
    history: createWebHistory(process.env.BASE_URL),
    routes
  })
  
  router.beforeEach((to, from, next) => {
    if (to.path === '/login' && auth.currentUser) {
      next('/')
      return;
    }
  
    if (to.path === '/signup' && auth.currentUser) {
      next('/')
      return;
    }
  
    if (to.matched.some(record => record.meta.requiresAuth) && !auth.currentUser) {
      next('/home')
      return;
    }
  
    next();
  })
  
  export default router