import './bootstrap'
import '@styles/styles.scss'

import { createApp, h } from 'vue'
import { createInertiaApp } from '@inertiajs/vue3'
import { resolvePageComponent } from 'laravel-vite-plugin/inertia-helpers'
import { createPinia } from 'pinia'
import installVuetify from '@/plugins/vuetify'

const appName = import.meta.env.VITE_APP_NAME || 'EZSCALE'

createInertiaApp({
  title: (title: string) => title ? `${title} - ${appName}` : appName,
  resolve: (name: string) => resolvePageComponent(
    `./Pages/${name}.vue`,
    import.meta.glob('./Pages/**/*.vue'),
  ),
  setup({ el, App, props, plugin }) {
    const app = createApp({ render: () => h(App, props) })

    app.use(plugin)
    app.use(createPinia())
    installVuetify(app)

    app.mount(el)
  },
  progress: {
    color: '#2563EB',
  },
})
