/**
 * Locale configuration.
 *
 * Arabic is the primary language and the default. Direction is derived from the locale
 * rather than stored, so there is exactly one place that decides RTL.
 */

export const LOCALES = ['ar', 'en'] as const
export type Locale = (typeof LOCALES)[number]

export const DEFAULT_LOCALE: Locale = 'ar'
export const LOCALE_COOKIE = 'nabdh_locale'

export function isLocale(value: unknown): value is Locale {
  return typeof value === 'string' && (LOCALES as readonly string[]).includes(value)
}

export function dirFor(locale: Locale): 'rtl' | 'ltr' {
  return locale === 'ar' ? 'rtl' : 'ltr'
}

/**
 * Intl locale tags.
 *
 * Arabic uses the `latn` numbering system on purpose: this is a control-room console
 * where operators read megawatts, kilovolts and asset codes, and Western digits keep
 * numeric values scannable and consistent with the equipment nameplates and the codes
 * (T-108, DNA-387) that appear beside them.
 */
export const INTL_LOCALE: Record<Locale, string> = {
  ar: 'ar-SA-u-nu-latn-ca-gregory',
  en: 'en-GB',
}

export const LOCALE_LABELS: Record<Locale, { native: string; english: string }> = {
  ar: { native: 'العربية', english: 'Arabic' },
  en: { native: 'English', english: 'English' },
}
