text: import router from "./router";
  
  require('./bootstrap');
  import Vue from 'vue'
  import routes from './router/index'
  import store from './pages/store/index'
  
  import CxltToastr from 'cxlt-vue2-toastr'
  import 'cxlt-vue2-toastr/dist/css/cxlt-vue2-toastr.css'
  
  var toastrConfigs = {
      position: 'top right',
      showDuration: 1000,
      timeout: 5000,
      closeButton: true,
      showMethod: 'fadeIn',
      hideMethod: 'fadeOut'
  }
  Vue.use(CxltToastr, toastrConfigs)
  
  Vue.component('app-header', require('./components/Header.vue').default);
  
  //Vue Router Navigation Guard
  function isLoggedIn() {
      return store.getters.getAuthenticated;
  }
  
  routes.beforeEach((to, from, next) => {
      if (to.matched.some(record => record.meta.requiresAuth)) {
          // this route requires auth, check if logged in
          // if not, redirect to login page.
          if (!isLoggedIn()) {
              next({
                  name: 'login',
              })
          } else {
              next()
          }
      }else if (to.matched.some(record => record.meta.requiresVisitor)) {
          // this route requires auth, check if logged in
          // if not, redirect to login page.
          if (isLoggedIn()) {
              next({
                  name: 'dashboard',
              })
          } else {
              next()
          }
      } else {
          next() // make sure to always call next()!
      }
  })
  
  // check authentication
  let auth = localStorage.getItem("auth");
  
  if(auth){
      store.dispatch('authUser').then(() => {
          const app = new Vue({
              el: '#app',
              router: routes,
              store,
          });
      });
  }else {
      const app = new Vue({
          el: '#app',
          router: routes,
          store,
      });
  }
  