import type { UiProvider } from './UiProvider'
import { nativeUiProvider } from '../adapter/native/installNativeAdapter'
import { primeVueUiProvider } from '../adapter/primevue/installPrimeVueAdapter'

export type UiProviderName = 'primevue' | 'native'

export function resolveUiProvider(name: string | undefined): UiProvider {
  const normalized = (name ?? 'primevue').trim().toLowerCase()
  if (normalized === 'primevue') return primeVueUiProvider
  if (normalized === 'native') return nativeUiProvider
  throw new Error(`Unsupported VITE_UI_ADAPTER '${name}'. Allowed values: primevue, native.`)
}
