import Vue from 'vue'
import Vuex from 'vuex'
import modules from './modules'
import plugins from './plugins'
import security from '@/plugins/security'
import {
  IS_LOGGED_IN_GETTER_NAME,
  LOG_IN_MUTATION_TYPE,
  LOG_OUT_MUTATION_TYPE,
  MEMBER_AUTHORITY_GETTER,
  MEMBER_AUTHORITY_INITIALIZED_GETTER,
} from '@/config/defaults'

Vue.use(Vuex)

const debug = process.env.NODE_ENV !== 'production'
// const debug = false

export const store = {
  namespaced: true,
  modules: modules,
  plugins: [
    ...plugins,
    security.registerStorePlugin(
      LOG_IN_MUTATION_TYPE,
      LOG_OUT_MUTATION_TYPE,
      IS_LOGGED_IN_GETTER_NAME,
      MEMBER_AUTHORITY_GETTER,
      MEMBER_AUTHORITY_INITIALIZED_GETTER
    ),
  ],
  strict: debug,
}

export default new Vuex.Store(store)
