"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.LocalesHelper = void 0;
const countries_list_1 = require("countries-list");
const lodash_1 = require("lodash");
class LocalesHelper {
    static getValidLocales(locale) {
        // TODO : waiting for internationalization :
        locale = 'fr-FR';
        if (locale) {
            let language = locale.length === 2 || locale.length === 5
                ? locale.substr(0, 2).toLowerCase()
                : undefined;
            if (language) {
                let country = locale.length === 5 ? locale.substr(3, 2) : language.toUpperCase();
                if (country in countries_list_1.countries) {
                    if (-1 ===
                        lodash_1.indexOf(countries_list_1.countries[country].languages, language)) {
                        language = countries_list_1.countries[country]
                            .languages[0];
                    }
                    return language + '-' + country;
                }
                else if (language !== 'en') {
                    country = lodash_1.find(Object.keys(countries_list_1.countries), (oneCountry) => {
                        return (language ===
                            countries_list_1.countries[oneCountry].languages[0]);
                    });
                    if (country) {
                        return language + '-' + country;
                    }
                }
            }
        }
        return 'en-US';
    }
}
exports.LocalesHelper = LocalesHelper;
//# sourceMappingURL=locales-helper.js.map