import dayjs from "dayjs";
import { locales } from "../generated/dayjs-locales-data.js";
const warn = (language)=>console.warn(`Cannot load dayjs locale file for "${language}"`);
const resolveLanguage = (languageInput)=>{
    if (locales[languageInput]) return languageInput;
    if (languageInput.includes('-')) {
        const regionlessLanguage = languageInput.split('-')[0];
        if (locales[regionlessLanguage]) return regionlessLanguage;
    }
    return languageInput;
};
function loadDayjsLocale(languageInput) {
    const language = resolveLanguage(languageInput);
    if (!locales[language]) return void warn(language);
    try {
        locales[language]().then(()=>dayjs.locale(language));
    } catch (_) {
        warn(language);
    }
}
export { loadDayjsLocale };
