import { osLocaleSync } from 'os-locale';
import { findLanguageForTag, supportedLanguages } from './languages.mjs';
const detectLanguage = (languages = supportedLanguages) => {
    const locale = osLocaleSync();
    if (locale) {
        const language = findLanguageForTag(locale.toLowerCase(), languages) ?? findLanguageForTag(locale.split('-')[0], languages);
        if (language) {
            return language.languageTag;
        }
    }
    return 'zh-cn';
};
export default detectLanguage;
