text: import Vue from 'vue'
  import App from './views/App'
  import router from './router';
  import VueRouter from 'vue-router'
  import BootstrapVue from 'bootstrap-vue'
  import * as VueGoogleMaps from "vue2-google-maps";
  import VueMoment from 'vue-moment'
  import moment from 'moment-timezone'
  
  Vue.use(VueMoment, {
      moment,
  });
  
  Vue.use(BootstrapVue)
  Vue.use(VueRouter)
  Vue.use(VueGoogleMaps, {
      load: {
          key: "",
          libraries: "places"
      }
  });
  
  window.$ = window.jQuery = require('jquery')
  window.axios = require('axios');
  
  const app = new Vue({
      el: '#app',
      data: {
          app_name: process.env.MIX_APP_NAME,
          client_id: process.env.MIX_CLIENT_ID,
          client_secret: process.env.MIX_CLIENT_SECRET,
          user: null,
          appLoaded: false,
          loadingInProgress: false,
      },
      mounted() {
          this.setBearer();
          this.setUser();
      },
      components: {App},
      router,
      computed: {
          currentRouteName() {
              return this.$route.name;
          }
      },
      methods: {
  
          setBearer(oauthData = null) {
  
              let token = null;
  
              if (oauthData) {
                  token = oauthData.access_token;
                  localStorage.setItem('oauthData', JSON.stringify(oauthData));
              } else {
                  let oauthData = localStorage.getItem('oauthData');
                  if (oauthData) {
                      oauthData = JSON.parse(oauthData);
                      token = oauthData.access_token;
                  }
              }
  
              if (token) axios.defaults.headers.common['Authorization'] = 'Bearer ' + token;
  
          },
          setUser() {
  
              let vm = this;
              vm.appLoaded = false;
  
              axios.get(route('company.user.index')).then(response => {
                  vm.user = response.data;
  
                  if ((
                      vm.currentRouteName === 'login' ||
                      vm.currentRouteName === 'register' ||
                      vm.currentRouteName === 'lost.password'
                  ) && (vm.user && vm.user.company)) {
                      vm.$root.navigate('company.index');
                  }
  
              }).catch((error) => {
                  console.log(error);
              }).then(function () {
                  setTimeout(function () {
                      vm.appLoaded = true;
                  }, 1500);
              });
  
          },
          navigate(routeName) {
  
              router.push({name: routeName});
  
          },
          logout() {
  
              this.user = null;
              axios.defaults.headers.common['Authorization'] = 'Bearer ';
              localStorage.clear();
              this.$root.navigate('login');
          },
  
      }
  });
  
  