/**
 * Set up vuetify instance
 */
import "../assets/styles/layers.css"
import "vuetify/styles"
import { createVuetify } from "vuetify"
import * as components from "vuetify/components"
import * as directives from "vuetify/directives"
import lightTheme from "../assets/styles/themes/light"
import darkTheme from "../assets/styles/themes/dark"
import DateFnsAdapter from "@date-io/date-fns"

const dark = {
  dark: true,
  colors: darkTheme,
}

const light = {
  dark: false,
  colors: lightTheme,
}
let vuetifyInstance
const initVuetify = (instanceAdapter, dateLocale) => {
  if (vuetifyInstance) {
    return vuetifyInstance
  }

  vuetifyInstance = createVuetify({
    locale: instanceAdapter,
    date: {
      adapter: DateFnsAdapter,
      locale: dateLocale,
    },
    components,
    directives,
    theme: {
      themes: {
        dark,
        light,
      },
    },
    utilities: false,
  })
  return vuetifyInstance
}

export default initVuetify
export { vuetifyInstance, initVuetify }
