import Vue from 'vue'
import App from './app/App'
import store from './store'
import router from './router'
import vuexI18n from 'vuex-i18n'
import { sync } from 'vuex-router-sync'
import langEn from './locales/locales-en.json'
import { BootstrapVue, IconsPlugin } from 'bootstrap-vue'
import constants from './config/const'

Vue.use(BootstrapVue)
Vue.use(IconsPlugin)
// Vuex sync route
sync(store, router)

// Translation Plugin Sync to store
Vue.use(vuexI18n.plugin, store)

Vue.i18n.add('en', langEn)
Vue.i18n.set('en')
Vue.i18n.fallback('en')

constants.install = function() {
  Object.defineProperty(Vue.prototype, '$const', {
    get() {
      return constants
    },
  })
}
Vue.use(constants)

const mountEl = document.querySelector('#app-center')

export default new Vue({
  store,
  router,
  render: h =>
    h(App, {
      props: { ...mountEl.dataset },
    }),
}).$mount(mountEl)
