import dayjs from 'dayjs'
import 'dayjs/locale/tr.js'
import 'dayjs/locale/en.js'
import 'dayjs/locale/de.js'
import 'dayjs/locale/it.js'
import 'dayjs/locale/es.js'
import 'dayjs/locale/ru.js'
import 'dayjs/locale/ar.js'

import { normalizeLocale } from './languages.js'

export const DATE_LOCALE_MAP = {
  tr: 'tr-TR',
  en: 'en-US',
  de: 'de-DE',
  it: 'it-IT',
  es: 'es-ES',
  ru: 'ru-RU',
  ar: 'ar'
}

export function applyDayjsLocale(locale) {
  const normalized = normalizeLocale(locale)
  dayjs.locale(normalized)
}

export function getDateLocale(locale) {
  const normalized = normalizeLocale(locale)
  return DATE_LOCALE_MAP[normalized] || DATE_LOCALE_MAP.tr
}
