import { createApp } from 'vue'
import router from './router'
import App from './App.vue'
import './style.css'

const DISABLE_AUTH = import.meta.env.VITE_DISABLE_AUTH === 'true'

async function main() {
  const app = createApp(App)
  app.use(router)

  if (!DISABLE_AUTH) {
    const PUBLISHABLE_KEY = import.meta.env.VITE_CLERK_PUBLISHABLE_KEY
    if (!PUBLISHABLE_KEY) throw new Error('Thiếu VITE_CLERK_PUBLISHABLE_KEY trong .env')

    const { clerkPlugin } = await import('@clerk/vue')
    app.use(clerkPlugin, { publishableKey: PUBLISHABLE_KEY })
  }

  app.mount('#app')
}

main()
