@formatjs/intl-relativetimeformat
Version:
Formats JavaScript dates to relative time strings.
5,556 lines • 94.6 kB
JavaScript
//#region node_modules/.aspect_rules_js/@formatjs_generated+cldr.supported-locales@0.0.0/node_modules/@formatjs_generated/cldr.supported-locales/default-content.js
const defaultContent = {
"aa": ["aa-ET"],
"ab": ["ab-GE"],
"af": ["af-ZA"],
"agq": ["agq-CM"],
"ak": ["ak-GH"],
"am": ["am-ET"],
"an": ["an-ES"],
"ann": ["ann-NG"],
"apc": ["apc-SY"],
"ar": ["ar-001"],
"arn": ["arn-CL"],
"as": ["as-IN"],
"asa": ["asa-TZ"],
"ast": ["ast-ES"],
"az-Arab": ["az-Arab-IR"],
"az-Cyrl": ["az-Cyrl-AZ"],
"az-Latn": ["az-Latn-AZ"],
"ba": ["ba-RU"],
"bal-Arab": ["bal-Arab-PK"],
"bal-Latn": ["bal-Latn-PK"],
"bas": ["bas-CM"],
"be": ["be-BY"],
"bem": ["bem-ZM"],
"bew": ["bew-ID"],
"bez": ["bez-TZ"],
"bg": ["bg-BG"],
"bgc": ["bgc-IN"],
"bgn": ["bgn-PK"],
"bho": ["bho-IN"],
"blo": ["blo-BJ"],
"blt": ["blt-VN"],
"bm": ["bm-ML"],
"bm-Nkoo": ["bm-Nkoo-ML"],
"bn": ["bn-BD"],
"bo": ["bo-CN"],
"bqi": ["bqi-IR"],
"br": ["br-FR"],
"brx": ["brx-IN"],
"bs-Cyrl": ["bs-Cyrl-BA"],
"bs-Latn": ["bs-Latn-BA"],
"bss": ["bss-CM"],
"bua": ["bua-RU"],
"byn": ["byn-ER"],
"ca": ["ca-ES"],
"cad": ["cad-US"],
"cch": ["cch-NG"],
"ccp": ["ccp-BD"],
"ce": ["ce-RU"],
"ceb": ["ceb-PH"],
"cgg": ["cgg-UG"],
"cho": ["cho-US"],
"chr": ["chr-US"],
"cic": ["cic-US"],
"ckb": ["ckb-IQ"],
"co": ["co-FR"],
"cop": ["cop-EG"],
"cs": ["cs-CZ"],
"csw": ["csw-CA"],
"cu": ["cu-RU"],
"cv": ["cv-RU"],
"cy": ["cy-GB"],
"da": ["da-DK"],
"dav": ["dav-KE"],
"de": ["de-DE"],
"dje": ["dje-NE"],
"doi": ["doi-IN"],
"dsb": ["dsb-DE"],
"dua": ["dua-CM"],
"dv": ["dv-MV"],
"dyo": ["dyo-SN"],
"dz": ["dz-BT"],
"ebu": ["ebu-KE"],
"ee": ["ee-GH"],
"el": ["el-GR"],
"en-Dsrt": ["en-Dsrt-US"],
"en-Shaw": ["en-Shaw-GB"],
"en": ["en-US"],
"eo": ["eo-001"],
"es": ["es-ES"],
"et": ["et-EE"],
"eu": ["eu-ES"],
"ewo": ["ewo-CM"],
"fa": ["fa-IR"],
"ff-Adlm": ["ff-Adlm-GN"],
"ff-Latn": ["ff-Latn-SN"],
"fi": ["fi-FI"],
"fil": ["fil-PH"],
"fo": ["fo-FO"],
"fr": ["fr-FR"],
"frr": ["frr-DE"],
"fur": ["fur-IT"],
"fy": ["fy-NL"],
"ga": ["ga-IE"],
"gaa": ["gaa-GH"],
"gd": ["gd-GB"],
"gez": ["gez-ET"],
"gl": ["gl-ES"],
"gn": ["gn-PY"],
"gsw": ["gsw-CH"],
"gu": ["gu-IN"],
"guz": ["guz-KE"],
"gv": ["gv-IM"],
"ha-Arab": ["ha-Arab-NG"],
"ha": ["ha-NG"],
"haw": ["haw-US"],
"he": ["he-IL"],
"hi": ["hi-IN"],
"hi-Latn": ["hi-Latn-IN"],
"hnj-Hmnp": ["hnj-Hmnp-US"],
"hr": ["hr-HR"],
"hsb": ["hsb-DE"],
"ht": ["ht-HT"],
"hu": ["hu-HU"],
"hy": ["hy-AM"],
"ia": ["ia-001"],
"id": ["id-ID"],
"ie": ["ie-EE"],
"ig": ["ig-NG"],
"ii": ["ii-CN"],
"io": ["io-001"],
"is": ["is-IS"],
"it": ["it-IT"],
"iu": ["iu-CA"],
"iu-Latn": ["iu-Latn-CA"],
"ja": ["ja-JP"],
"jbo": ["jbo-001"],
"jgo": ["jgo-CM"],
"jmc": ["jmc-TZ"],
"jv": ["jv-ID"],
"ka": ["ka-GE"],
"kaa-Cyrl": ["kaa-Cyrl-UZ"],
"kaa-Latn": ["kaa-Latn-UZ"],
"kab": ["kab-DZ"],
"kaj": ["kaj-NG"],
"kam": ["kam-KE"],
"kcg": ["kcg-NG"],
"kde": ["kde-TZ"],
"kea": ["kea-CV"],
"kek": ["kek-GT"],
"ken": ["ken-CM"],
"kgp": ["kgp-BR"],
"khq": ["khq-ML"],
"ki": ["ki-KE"],
"kk-Arab": ["kk-Arab-CN"],
"kk-Cyrl": ["kk-Cyrl-KZ"],
"kkj": ["kkj-CM"],
"kl": ["kl-GL"],
"kln": ["kln-KE"],
"km": ["km-KH"],
"kn": ["kn-IN"],
"ko": ["ko-KR"],
"kok-Deva": ["kok-Deva-IN"],
"kok-Latn": ["kok-Latn-IN"],
"kpe": ["kpe-LR"],
"ks-Arab": ["ks-Arab-IN"],
"ks-Deva": ["ks-Deva-IN"],
"ksb": ["ksb-TZ"],
"ksf": ["ksf-CM"],
"ksh": ["ksh-DE"],
"ku-Arab": ["ku-Arab-IQ"],
"ku-Latn": ["ku-Latn-TR"],
"kw": ["kw-GB"],
"kxv-Deva": ["kxv-Deva-IN"],
"kxv-Latn": ["kxv-Latn-IN"],
"kxv-Orya": ["kxv-Orya-IN"],
"kxv-Telu": ["kxv-Telu-IN"],
"ky": ["ky-KG"],
"la": ["la-VA"],
"lag": ["lag-TZ"],
"lb": ["lb-LU"],
"lg": ["lg-UG"],
"lij": ["lij-IT"],
"lkt": ["lkt-US"],
"lld": ["lld-IT"],
"lmo": ["lmo-IT"],
"ln": ["ln-CD"],
"lo": ["lo-LA"],
"lrc": ["lrc-IR"],
"lt": ["lt-LT"],
"ltg": ["ltg-LV"],
"lu": ["lu-CD"],
"luo": ["luo-KE"],
"luy": ["luy-KE"],
"lv": ["lv-LV"],
"lzz": ["lzz-TR"],
"mai": ["mai-IN"],
"mas": ["mas-KE"],
"mdf": ["mdf-RU"],
"mer": ["mer-KE"],
"mfe": ["mfe-MU"],
"mg": ["mg-MG"],
"mgh": ["mgh-MZ"],
"mgo": ["mgo-CM"],
"mhn": ["mhn-IT"],
"mi": ["mi-NZ"],
"mic": ["mic-CA"],
"mk": ["mk-MK"],
"ml": ["ml-IN"],
"mn": ["mn-MN"],
"mn-Mong": ["mn-Mong-CN"],
"mni-Beng": ["mni-Beng-IN"],
"mni-Mtei": ["mni-Mtei-IN"],
"moh": ["moh-CA"],
"mr": ["mr-IN"],
"ms-Arab": ["ms-Arab-MY"],
"ms": ["ms-MY"],
"mt": ["mt-MT"],
"mua": ["mua-CM"],
"mus": ["mus-US"],
"mww-Hmnp": ["mww-Hmnp-US"],
"my": ["my-MM"],
"myv": ["myv-RU"],
"mzn": ["mzn-IR"],
"naq": ["naq-NA"],
"nb": ["nb-NO"],
"nd": ["nd-ZW"],
"nds": ["nds-DE"],
"ne": ["ne-NP"],
"nl": ["nl-NL"],
"nmg": ["nmg-CM"],
"nn": ["nn-NO"],
"nnh": ["nnh-CM"],
"nqo": ["nqo-GN"],
"nr": ["nr-ZA"],
"nso": ["nso-ZA"],
"nus": ["nus-SS"],
"nv": ["nv-US"],
"ny": ["ny-MW"],
"nyn": ["nyn-UG"],
"oc": ["oc-FR"],
"oka": ["oka-CA"],
"om": ["om-ET"],
"or": ["or-IN"],
"os": ["os-GE"],
"osa": ["osa-US"],
"pa-Arab": ["pa-Arab-PK"],
"pa-Guru": ["pa-Guru-IN"],
"pap": ["pap-CW"],
"pcm": ["pcm-NG"],
"pi-Latn": ["pi-Latn-GB"],
"pis": ["pis-SB"],
"pl": ["pl-PL"],
"pms": ["pms-IT"],
"prg": ["prg-PL"],
"ps": ["ps-AF"],
"pt": ["pt-BR"],
"qu": ["qu-PE"],
"quc": ["quc-GT"],
"raj": ["raj-IN"],
"rhg-Rohg": ["rhg-Rohg-MM"],
"rif": ["rif-MA"],
"rm": ["rm-CH"],
"rn": ["rn-BI"],
"ro": ["ro-RO"],
"rof": ["rof-TZ"],
"ru": ["ru-RU"],
"rw": ["rw-RW"],
"rwk": ["rwk-TZ"],
"sa": ["sa-IN"],
"sah": ["sah-RU"],
"saq": ["saq-KE"],
"sat-Deva": ["sat-Deva-IN"],
"sat-Olck": ["sat-Olck-IN"],
"sbp": ["sbp-TZ"],
"sc": ["sc-IT"],
"scn": ["scn-IT"],
"sd-Arab": ["sd-Arab-PK"],
"sd-Deva": ["sd-Deva-IN"],
"sdh": ["sdh-IR"],
"se": ["se-NO"],
"seh": ["seh-MZ"],
"ses": ["ses-ML"],
"sg": ["sg-CF"],
"sgs": ["sgs-LT"],
"shi-Latn": ["shi-Latn-MA"],
"shi-Tfng": ["shi-Tfng-MA"],
"shn": ["shn-MM"],
"si": ["si-LK"],
"sid": ["sid-ET"],
"sk": ["sk-SK"],
"skr": ["skr-PK"],
"sl": ["sl-SI"],
"sma": ["sma-SE"],
"smj": ["smj-SE"],
"smn": ["smn-FI"],
"sms": ["sms-FI"],
"sn": ["sn-ZW"],
"so": ["so-SO"],
"sq": ["sq-AL"],
"sr-Cyrl": ["sr-Cyrl-RS"],
"sr-Latn": ["sr-Latn-RS"],
"ss": ["ss-ZA"],
"ssy": ["ssy-ER"],
"st": ["st-ZA"],
"su-Latn": ["su-Latn-ID"],
"suz-Deva": ["suz-Deva-NP"],
"suz-Sunu": ["suz-Sunu-NP"],
"sv": ["sv-SE"],
"sw": ["sw-TZ"],
"syr": ["syr-IQ"],
"szl": ["szl-PL"],
"ta": ["ta-IN"],
"te": ["te-IN"],
"teo": ["teo-UG"],
"tg": ["tg-TJ"],
"th": ["th-TH"],
"ti": ["ti-ET"],
"tig": ["tig-ER"],
"tk": ["tk-TM"],
"tn": ["tn-ZA"],
"to": ["to-TO"],
"tok": ["tok-001"],
"tpi": ["tpi-PG"],
"tr": ["tr-TR"],
"trv": ["trv-TW"],
"trw": ["trw-PK"],
"ts": ["ts-ZA"],
"tt": ["tt-RU"],
"twq": ["twq-NE"],
"tyv": ["tyv-RU"],
"tzm": ["tzm-MA"],
"ug": ["ug-CN"],
"uk": ["uk-UA"],
"ur": ["ur-PK"],
"uz-Arab": ["uz-Arab-AF"],
"uz-Cyrl": ["uz-Cyrl-UZ"],
"uz-Latn": ["uz-Latn-UZ"],
"vai-Latn": ["vai-Latn-LR"],
"vai-Vaii": ["vai-Vaii-LR"],
"ve": ["ve-ZA"],
"vec": ["vec-IT"],
"vi": ["vi-VN"],
"vmw": ["vmw-MZ"],
"vo": ["vo-001"],
"vun": ["vun-TZ"],
"wa": ["wa-BE"],
"wae": ["wae-CH"],
"wal": ["wal-ET"],
"wbp": ["wbp-AU"],
"wo": ["wo-SN"],
"xh": ["xh-ZA"],
"xnr": ["xnr-IN"],
"xog": ["xog-UG"],
"yav": ["yav-CM"],
"yi": ["yi-UA"],
"yo": ["yo-NG"],
"yrl": ["yrl-BR"],
"yue-Hans": ["yue-Hans-CN"],
"yue-Hant": ["yue-Hant-HK"],
"za": ["za-CN"],
"zgh": ["zgh-MA"],
"zh-Hans": ["zh-Hans-CN"],
"zh-Hant": ["zh-Hant-TW"],
"zh-Latn": ["zh-Latn-CN"],
"zu": ["zu-ZA"]
};
//#endregion
//#region packages/ecma402-abstract/registerLocaleData.js
const explicitLocales = /* @__PURE__ */ new WeakMap();
function registerLocaleData(locale, data, localeData, availableLocales) {
let loaded = explicitLocales.get(localeData);
if (!loaded) {
loaded = /* @__PURE__ */ new Set();
explicitLocales.set(localeData, loaded);
}
loaded.add(locale);
const locales = [locale, ...defaultContent[locale] || []];
for (const tag of locales) {
if (tag === locale || !loaded.has(tag) || localeData[tag] === void 0) localeData[tag] = data;
availableLocales.add(tag);
}
for (const tag of locales) {
const parts = tag.split("-");
const fallbacks = [];
while (parts.length > 1) {
if (parts.length > 2 && parts[1].length === 4) fallbacks.push([parts[0], ...parts.slice(2)].join("-"));
parts.pop();
fallbacks.push(parts.join("-"));
}
for (const fallback of fallbacks) {
if (localeData[fallback] === void 0) localeData[fallback] = localeData[tag];
availableLocales.add(fallback);
}
}
}
//#endregion
//#region packages/ecma262-abstract/ToString.js
/**
* https://tc39.es/ecma262/#sec-tostring
*/
function ToString(o) {
if (typeof o === "symbol") throw TypeError("Cannot convert a Symbol value to a string");
return String(o);
}
//#endregion
//#region packages/ecma402-abstract/CanonicalizeLocaleList.js
/**
* http://ecma-international.org/ecma-402/7.0/index.html#sec-canonicalizelocalelist
* @param locales
*/
function CanonicalizeLocaleList$1(locales) {
return Intl.getCanonicalLocales(locales);
}
//#endregion
//#region node_modules/.aspect_rules_js/@formatjs+fast-memoize@0.0.0/node_modules/@formatjs/fast-memoize/index.js
function memoize(fn, options) {
const cache = options && options.cache ? options.cache : cacheDefault;
const serializer = options && options.serializer ? options.serializer : serializerDefault;
return (options && options.strategy ? options.strategy : strategyDefault)(fn, {
cache,
serializer
});
}
function isPrimitive(value) {
return value == null || typeof value === "number" || typeof value === "boolean";
}
function monadic(fn, cache, serializer, arg) {
const cacheKey = isPrimitive(arg) ? arg : serializer(arg);
let computedValue = cache.get(cacheKey);
if (typeof computedValue === "undefined") {
computedValue = fn.call(this, arg);
cache.set(cacheKey, computedValue);
}
return computedValue;
}
function variadic(fn, cache, serializer) {
const args = Array.prototype.slice.call(arguments, 3);
const cacheKey = serializer(args);
let computedValue = cache.get(cacheKey);
if (typeof computedValue === "undefined") {
computedValue = fn.apply(this, args);
cache.set(cacheKey, computedValue);
}
return computedValue;
}
function assemble(fn, context, strategy, cache, serialize) {
return strategy.bind(context, fn, cache, serialize);
}
function strategyDefault(fn, options) {
const strategy = fn.length === 1 ? monadic : variadic;
return assemble(fn, this, strategy, options.cache.create(), options.serializer);
}
function strategyVariadic(fn, options) {
return assemble(fn, this, variadic, options.cache.create(), options.serializer);
}
function strategyMonadic(fn, options) {
return assemble(fn, this, monadic, options.cache.create(), options.serializer);
}
const serializerDefault = function() {
return JSON.stringify(arguments);
};
var ObjectWithoutPrototypeCache = class {
constructor() {
this.cache = Object.create(null);
}
get(key) {
return this.cache[key];
}
set(key, value) {
this.cache[key] = value;
}
};
const cacheDefault = { create: function create() {
return new ObjectWithoutPrototypeCache();
} };
const strategies = {
variadic: strategyVariadic,
monadic: strategyMonadic
};
//#endregion
//#region node_modules/.aspect_rules_js/@formatjs+intl-localematcher@0.0.0/node_modules/@formatjs/intl-localematcher/index.js
/**
* http://ecma-international.org/ecma-402/7.0/index.html#sec-canonicalizelocalelist
* @param locales
*/
function CanonicalizeLocaleList(locales) {
return Intl.getCanonicalLocales(locales);
}
const data = { supplemental: { languageMatching: { "written-new": [
{ paradigmLocales: { _locales: "en en_GB es es_419 pt_BR pt_PT" } },
{ $enUS: { _value: "AS+CA+GU+MH+MP+PH+PR+UM+US+VI" } },
{ $cnsar: { _value: "HK+MO" } },
{ $americas: { _value: "019" } },
{ $maghreb: { _value: "MA+DZ+TN+LY+MR+EH" } },
{ no: {
_desired: "nb",
_distance: "1"
} },
{ bs: {
_desired: "hr",
_distance: "4"
} },
{ bs: {
_desired: "sh",
_distance: "4"
} },
{ hr: {
_desired: "sh",
_distance: "4"
} },
{ sr: {
_desired: "sh",
_distance: "4"
} },
{ aa: {
_desired: "ssy",
_distance: "4"
} },
{ de: {
_desired: "gsw",
_distance: "4",
_oneway: "true"
} },
{ de: {
_desired: "lb",
_distance: "4",
_oneway: "true"
} },
{ no: {
_desired: "da",
_distance: "8"
} },
{ nb: {
_desired: "da",
_distance: "8"
} },
{ ru: {
_desired: "ab",
_distance: "30",
_oneway: "true"
} },
{ en: {
_desired: "ach",
_distance: "30",
_oneway: "true"
} },
{ nl: {
_desired: "af",
_distance: "20",
_oneway: "true"
} },
{ en: {
_desired: "ak",
_distance: "30",
_oneway: "true"
} },
{ en: {
_desired: "am",
_distance: "30",
_oneway: "true"
} },
{ es: {
_desired: "ay",
_distance: "20",
_oneway: "true"
} },
{ ru: {
_desired: "az",
_distance: "30",
_oneway: "true"
} },
{ ur: {
_desired: "bal",
_distance: "20",
_oneway: "true"
} },
{ ru: {
_desired: "be",
_distance: "20",
_oneway: "true"
} },
{ en: {
_desired: "bem",
_distance: "30",
_oneway: "true"
} },
{ hi: {
_desired: "bh",
_distance: "30",
_oneway: "true"
} },
{ en: {
_desired: "bn",
_distance: "30",
_oneway: "true"
} },
{ zh: {
_desired: "bo",
_distance: "20",
_oneway: "true"
} },
{ fr: {
_desired: "br",
_distance: "20",
_oneway: "true"
} },
{ es: {
_desired: "ca",
_distance: "20",
_oneway: "true"
} },
{ fil: {
_desired: "ceb",
_distance: "30",
_oneway: "true"
} },
{ en: {
_desired: "chr",
_distance: "20",
_oneway: "true"
} },
{ ar: {
_desired: "ckb",
_distance: "30",
_oneway: "true"
} },
{ fr: {
_desired: "co",
_distance: "20",
_oneway: "true"
} },
{ fr: {
_desired: "crs",
_distance: "20",
_oneway: "true"
} },
{ sk: {
_desired: "cs",
_distance: "20"
} },
{ en: {
_desired: "cy",
_distance: "20",
_oneway: "true"
} },
{ en: {
_desired: "ee",
_distance: "30",
_oneway: "true"
} },
{ en: {
_desired: "eo",
_distance: "30",
_oneway: "true"
} },
{ es: {
_desired: "eu",
_distance: "20",
_oneway: "true"
} },
{ da: {
_desired: "fo",
_distance: "20",
_oneway: "true"
} },
{ nl: {
_desired: "fy",
_distance: "20",
_oneway: "true"
} },
{ en: {
_desired: "ga",
_distance: "20",
_oneway: "true"
} },
{ en: {
_desired: "gaa",
_distance: "30",
_oneway: "true"
} },
{ en: {
_desired: "gd",
_distance: "20",
_oneway: "true"
} },
{ es: {
_desired: "gl",
_distance: "20",
_oneway: "true"
} },
{ es: {
_desired: "gn",
_distance: "20",
_oneway: "true"
} },
{ hi: {
_desired: "gu",
_distance: "30",
_oneway: "true"
} },
{ en: {
_desired: "ha",
_distance: "30",
_oneway: "true"
} },
{ en: {
_desired: "haw",
_distance: "20",
_oneway: "true"
} },
{ fr: {
_desired: "ht",
_distance: "20",
_oneway: "true"
} },
{ ru: {
_desired: "hy",
_distance: "30",
_oneway: "true"
} },
{ en: {
_desired: "ia",
_distance: "30",
_oneway: "true"
} },
{ en: {
_desired: "ig",
_distance: "30",
_oneway: "true"
} },
{ en: {
_desired: "is",
_distance: "20",
_oneway: "true"
} },
{ id: {
_desired: "jv",
_distance: "20",
_oneway: "true"
} },
{ en: {
_desired: "ka",
_distance: "30",
_oneway: "true"
} },
{ fr: {
_desired: "kg",
_distance: "30",
_oneway: "true"
} },
{ ru: {
_desired: "kk",
_distance: "30",
_oneway: "true"
} },
{ en: {
_desired: "km",
_distance: "30",
_oneway: "true"
} },
{ en: {
_desired: "kn",
_distance: "30",
_oneway: "true"
} },
{ en: {
_desired: "kri",
_distance: "30",
_oneway: "true"
} },
{ tr: {
_desired: "ku",
_distance: "30",
_oneway: "true"
} },
{ ru: {
_desired: "ky",
_distance: "30",
_oneway: "true"
} },
{ it: {
_desired: "la",
_distance: "20",
_oneway: "true"
} },
{ en: {
_desired: "lg",
_distance: "30",
_oneway: "true"
} },
{ fr: {
_desired: "ln",
_distance: "30",
_oneway: "true"
} },
{ en: {
_desired: "lo",
_distance: "30",
_oneway: "true"
} },
{ en: {
_desired: "loz",
_distance: "30",
_oneway: "true"
} },
{ fr: {
_desired: "lua",
_distance: "30",
_oneway: "true"
} },
{ hi: {
_desired: "mai",
_distance: "20",
_oneway: "true"
} },
{ en: {
_desired: "mfe",
_distance: "30",
_oneway: "true"
} },
{ fr: {
_desired: "mg",
_distance: "30",
_oneway: "true"
} },
{ en: {
_desired: "mi",
_distance: "20",
_oneway: "true"
} },
{ en: {
_desired: "ml",
_distance: "30",
_oneway: "true"
} },
{ ru: {
_desired: "mn",
_distance: "30",
_oneway: "true"
} },
{ hi: {
_desired: "mr",
_distance: "30",
_oneway: "true"
} },
{ id: {
_desired: "ms",
_distance: "30",
_oneway: "true"
} },
{ en: {
_desired: "mt",
_distance: "30",
_oneway: "true"
} },
{ en: {
_desired: "my",
_distance: "30",
_oneway: "true"
} },
{ en: {
_desired: "ne",
_distance: "30",
_oneway: "true"
} },
{ nb: {
_desired: "nn",
_distance: "20"
} },
{ no: {
_desired: "nn",
_distance: "20"
} },
{ en: {
_desired: "nso",
_distance: "30",
_oneway: "true"
} },
{ en: {
_desired: "ny",
_distance: "30",
_oneway: "true"
} },
{ en: {
_desired: "nyn",
_distance: "30",
_oneway: "true"
} },
{ fr: {
_desired: "oc",
_distance: "20",
_oneway: "true"
} },
{ en: {
_desired: "om",
_distance: "30",
_oneway: "true"
} },
{ en: {
_desired: "or",
_distance: "30",
_oneway: "true"
} },
{ en: {
_desired: "pa",
_distance: "30",
_oneway: "true"
} },
{ en: {
_desired: "pcm",
_distance: "20",
_oneway: "true"
} },
{ en: {
_desired: "ps",
_distance: "30",
_oneway: "true"
} },
{ es: {
_desired: "qu",
_distance: "30",
_oneway: "true"
} },
{ de: {
_desired: "rm",
_distance: "20",
_oneway: "true"
} },
{ en: {
_desired: "rn",
_distance: "30",
_oneway: "true"
} },
{ fr: {
_desired: "rw",
_distance: "30",
_oneway: "true"
} },
{ hi: {
_desired: "sa",
_distance: "30",
_oneway: "true"
} },
{ en: {
_desired: "sd",
_distance: "30",
_oneway: "true"
} },
{ en: {
_desired: "si",
_distance: "30",
_oneway: "true"
} },
{ en: {
_desired: "sn",
_distance: "30",
_oneway: "true"
} },
{ en: {
_desired: "so",
_distance: "30",
_oneway: "true"
} },
{ en: {
_desired: "sq",
_distance: "30",
_oneway: "true"
} },
{ en: {
_desired: "st",
_distance: "30",
_oneway: "true"
} },
{ id: {
_desired: "su",
_distance: "20",
_oneway: "true"
} },
{ en: {
_desired: "sw",
_distance: "30",
_oneway: "true"
} },
{ en: {
_desired: "ta",
_distance: "30",
_oneway: "true"
} },
{ en: {
_desired: "te",
_distance: "30",
_oneway: "true"
} },
{ ru: {
_desired: "tg",
_distance: "30",
_oneway: "true"
} },
{ en: {
_desired: "ti",
_distance: "30",
_oneway: "true"
} },
{ ru: {
_desired: "tk",
_distance: "30",
_oneway: "true"
} },
{ en: {
_desired: "tlh",
_distance: "30",
_oneway: "true"
} },
{ en: {
_desired: "tn",
_distance: "30",
_oneway: "true"
} },
{ en: {
_desired: "to",
_distance: "30",
_oneway: "true"
} },
{ ru: {
_desired: "tt",
_distance: "30",
_oneway: "true"
} },
{ en: {
_desired: "tum",
_distance: "30",
_oneway: "true"
} },
{ zh: {
_desired: "ug",
_distance: "20",
_oneway: "true"
} },
{ ru: {
_desired: "uk",
_distance: "20",
_oneway: "true"
} },
{ en: {
_desired: "ur",
_distance: "30",
_oneway: "true"
} },
{ ru: {
_desired: "uz",
_distance: "30",
_oneway: "true"
} },
{ fr: {
_desired: "wo",
_distance: "30",
_oneway: "true"
} },
{ en: {
_desired: "xh",
_distance: "30",
_oneway: "true"
} },
{ en: {
_desired: "yi",
_distance: "30",
_oneway: "true"
} },
{ en: {
_desired: "yo",
_distance: "30",
_oneway: "true"
} },
{ zh: {
_desired: "za",
_distance: "20",
_oneway: "true"
} },
{ en: {
_desired: "zu",
_distance: "30",
_oneway: "true"
} },
{ ar: {
_desired: "aao",
_distance: "10",
_oneway: "true"
} },
{ ar: {
_desired: "abh",
_distance: "10",
_oneway: "true"
} },
{ ar: {
_desired: "abv",
_distance: "10",
_oneway: "true"
} },
{ ar: {
_desired: "acm",
_distance: "10",
_oneway: "true"
} },
{ ar: {
_desired: "acq",
_distance: "10",
_oneway: "true"
} },
{ ar: {
_desired: "acw",
_distance: "10",
_oneway: "true"
} },
{ ar: {
_desired: "acx",
_distance: "10",
_oneway: "true"
} },
{ ar: {
_desired: "acy",
_distance: "10",
_oneway: "true"
} },
{ ar: {
_desired: "adf",
_distance: "10",
_oneway: "true"
} },
{ ar: {
_desired: "aeb",
_distance: "10",
_oneway: "true"
} },
{ ar: {
_desired: "aec",
_distance: "10",
_oneway: "true"
} },
{ ar: {
_desired: "afb",
_distance: "10",
_oneway: "true"
} },
{ ar: {
_desired: "ajp",
_distance: "10",
_oneway: "true"
} },
{ ar: {
_desired: "apc",
_distance: "10",
_oneway: "true"
} },
{ ar: {
_desired: "apd",
_distance: "10",
_oneway: "true"
} },
{ ar: {
_desired: "arq",
_distance: "10",
_oneway: "true"
} },
{ ar: {
_desired: "ars",
_distance: "10",
_oneway: "true"
} },
{ ar: {
_desired: "ary",
_distance: "10",
_oneway: "true"
} },
{ ar: {
_desired: "arz",
_distance: "10",
_oneway: "true"
} },
{ ar: {
_desired: "auz",
_distance: "10",
_oneway: "true"
} },
{ ar: {
_desired: "avl",
_distance: "10",
_oneway: "true"
} },
{ ar: {
_desired: "ayh",
_distance: "10",
_oneway: "true"
} },
{ ar: {
_desired: "ayl",
_distance: "10",
_oneway: "true"
} },
{ ar: {
_desired: "ayn",
_distance: "10",
_oneway: "true"
} },
{ ar: {
_desired: "ayp",
_distance: "10",
_oneway: "true"
} },
{ ar: {
_desired: "bbz",
_distance: "10",
_oneway: "true"
} },
{ ar: {
_desired: "pga",
_distance: "10",
_oneway: "true"
} },
{ ar: {
_desired: "shu",
_distance: "10",
_oneway: "true"
} },
{ ar: {
_desired: "ssh",
_distance: "10",
_oneway: "true"
} },
{ az: {
_desired: "azb",
_distance: "10",
_oneway: "true"
} },
{ et: {
_desired: "vro",
_distance: "10",
_oneway: "true"
} },
{ ff: {
_desired: "ffm",
_distance: "10",
_oneway: "true"
} },
{ ff: {
_desired: "fub",
_distance: "10",
_oneway: "true"
} },
{ ff: {
_desired: "fue",
_distance: "10",
_oneway: "true"
} },
{ ff: {
_desired: "fuf",
_distance: "10",
_oneway: "true"
} },
{ ff: {
_desired: "fuh",
_distance: "10",
_oneway: "true"
} },
{ ff: {
_desired: "fui",
_distance: "10",
_oneway: "true"
} },
{ ff: {
_desired: "fuq",
_distance: "10",
_oneway: "true"
} },
{ ff: {
_desired: "fuv",
_distance: "10",
_oneway: "true"
} },
{ gn: {
_desired: "gnw",
_distance: "10",
_oneway: "true"
} },
{ gn: {
_desired: "gui",
_distance: "10",
_oneway: "true"
} },
{ gn: {
_desired: "gun",
_distance: "10",
_oneway: "true"
} },
{ gn: {
_desired: "nhd",
_distance: "10",
_oneway: "true"
} },
{ iu: {
_desired: "ikt",
_distance: "10",
_oneway: "true"
} },
{ kln: {
_desired: "enb",
_distance: "10",
_oneway: "true"
} },
{ kln: {
_desired: "eyo",
_distance: "10",
_oneway: "true"
} },
{ kln: {
_desired: "niq",
_distance: "10",
_oneway: "true"
} },
{ kln: {
_desired: "oki",
_distance: "10",
_oneway: "true"
} },
{ kln: {
_desired: "pko",
_distance: "10",
_oneway: "true"
} },
{ kln: {
_desired: "sgc",
_distance: "10",
_oneway: "true"
} },
{ kln: {
_desired: "tec",
_distance: "10",
_oneway: "true"
} },
{ kln: {
_desired: "tuy",
_distance: "10",
_oneway: "true"
} },
{ kok: {
_desired: "gom",
_distance: "10",
_oneway: "true"
} },
{ kpe: {
_desired: "gkp",
_distance: "10",
_oneway: "true"
} },
{ luy: {
_desired: "ida",
_distance: "10",
_oneway: "true"
} },
{ luy: {
_desired: "lkb",
_distance: "10",
_oneway: "true"
} },
{ luy: {
_desired: "lko",
_distance: "10",
_oneway: "true"
} },
{ luy: {
_desired: "lks",
_distance: "10",
_oneway: "true"
} },
{ luy: {
_desired: "lri",
_distance: "10",
_oneway: "true"
} },
{ luy: {
_desired: "lrm",
_distance: "10",
_oneway: "true"
} },
{ luy: {
_desired: "lsm",
_distance: "10",
_oneway: "true"
} },
{ luy: {
_desired: "lto",
_distance: "10",
_oneway: "true"
} },
{ luy: {
_desired: "lts",
_distance: "10",
_oneway: "true"
} },
{ luy: {
_desired: "lwg",
_distance: "10",
_oneway: "true"
} },
{ luy: {
_desired: "nle",
_distance: "10",
_oneway: "true"
} },
{ luy: {
_desired: "nyd",
_distance: "10",
_oneway: "true"
} },
{ luy: {
_desired: "rag",
_distance: "10",
_oneway: "true"
} },
{ lv: {
_desired: "ltg",
_distance: "10",
_oneway: "true"
} },
{ mg: {
_desired: "bhr",
_distance: "10",
_oneway: "true"
} },
{ mg: {
_desired: "bjq",
_distance: "10",
_oneway: "true"
} },
{ mg: {
_desired: "bmm",
_distance: "10",
_oneway: "true"
} },
{ mg: {
_desired: "bzc",
_distance: "10",
_oneway: "true"
} },
{ mg: {
_desired: "msh",
_distance: "10",
_oneway: "true"
} },
{ mg: {
_desired: "skg",
_distance: "10",
_oneway: "true"
} },
{ mg: {
_desired: "tdx",
_distance: "10",
_oneway: "true"
} },
{ mg: {
_desired: "tkg",
_distance: "10",
_oneway: "true"
} },
{ mg: {
_desired: "txy",
_distance: "10",
_oneway: "true"
} },
{ mg: {
_desired: "xmv",
_distance: "10",
_oneway: "true"
} },
{ mg: {
_desired: "xmw",
_distance: "10",
_oneway: "true"
} },
{ mn: {
_desired: "mvf",
_distance: "10",
_oneway: "true"
} },
{ ms: {
_desired: "bjn",
_distance: "10",
_oneway: "true"
} },
{ ms: {
_desired: "btj",
_distance: "10",
_oneway: "true"
} },
{ ms: {
_desired: "bve",
_distance: "10",
_oneway: "true"
} },
{ ms: {
_desired: "bvu",
_distance: "10",
_oneway: "true"
} },
{ ms: {
_desired: "coa",
_distance: "10",
_oneway: "true"
} },
{ ms: {
_desired: "dup",
_distance: "10",
_oneway: "true"
} },
{ ms: {
_desired: "hji",
_distance: "10",
_oneway: "true"
} },
{ ms: {
_desired: "id",
_distance: "10",
_oneway: "true"
} },
{ ms: {
_desired: "jak",
_distance: "10",
_oneway: "true"
} },
{ ms: {
_desired: "jax",
_distance: "10",
_oneway: "true"
} },
{ ms: {
_desired: "kvb",
_distance: "10",
_oneway: "true"
} },
{ ms: {
_desired: "kvr",
_distance: "10",
_oneway: "true"
} },
{ ms: {
_desired: "kxd",
_distance: "10",
_oneway: "true"
} },
{ ms: {
_desired: "lce",
_distance: "10",
_oneway: "true"
} },
{ ms: {
_desired: "lcf",
_distance: "10",
_oneway: "true"
} },
{ ms: {
_desired: "liw",
_distance: "10",
_oneway: "true"
} },
{ ms: {
_desired: "max",
_distance: "10",
_oneway: "true"
} },
{ ms: {
_desired: "meo",
_distance: "10",
_oneway: "true"
} },
{ ms: {
_desired: "mfa",
_distance: "10",
_oneway: "true"
} },
{ ms: {
_desired: "mfb",
_distance: "10",
_oneway: "true"
} },
{ ms: {
_desired: "min",
_distance: "10",
_oneway: "true"
} },
{ ms: {
_desired: "mqg",
_distance: "10",
_oneway: "true"
} },
{ ms: {
_desired: "msi",
_distance: "10",
_oneway: "true"
} },
{ ms: {
_desired: "mui",
_distance: "10",
_oneway: "true"
} },
{ ms: {
_desired: "orn",
_distance: "10",
_oneway: "true"
} },
{ ms: {
_desired: "ors",
_distance: "10",
_oneway: "true"
} },
{ ms: {
_desired: "pel",
_distance: "10",
_oneway: "true"
} },
{ ms: {
_desired: "pse",
_distance: "10",
_oneway: "true"
} },
{ ms: {
_desired: "tmw",
_distance: "10",
_oneway: "true"
} },
{ ms: {
_desired: "urk",
_distance: "10",
_oneway: "true"
} },
{ ms: {
_desired: "vkk",
_distance: "10",
_oneway: "true"
} },
{ ms: {
_desired: "vkt",
_distance: "10",
_oneway: "true"
} },
{ ms: {
_desired: "xmm",
_distance: "10",
_oneway: "true"
} },
{ ms: {
_desired: "zlm",
_distance: "10",
_oneway: "true"
} },
{ ms: {
_desired: "zmi",
_distance: "10",
_oneway: "true"
} },
{ ne: {
_desired: "dty",
_distance: "10",
_oneway: "true"
} },
{ om: {
_desired: "gax",
_distance: "10",
_oneway: "true"
} },
{ om: {
_desired: "hae",
_distance: "10",
_oneway: "true"
} },
{ om: {
_desired: "orc",
_distance: "10",
_oneway: "true"
} },
{ or: {
_desired: "spv",
_distance: "10",
_oneway: "true"
} },
{ ps: {
_desired: "pbt",
_distance: "10",
_oneway: "true"
} },
{ ps: {
_desired: "pst",
_distance: "10",
_oneway: "true"
} },
{ qu: {
_desired: "qub",
_distance: "10",
_oneway: "true"
} },
{ qu: {
_desired: "qud",
_distance: "10",
_oneway: "true"
} },
{ qu: {
_desired: "quf",
_distance: "10",
_oneway: "true"
} },
{ qu: {
_desired: "qug",
_distance: "10",
_oneway: "true"
} },
{ qu: {
_desired: "quh",
_distance: "10",
_oneway: "true"
} },
{ qu: {
_desired: "quk",
_distance: "10",
_oneway: "true"
} },
{ qu: {
_desired: "qul",
_distance: "10",
_oneway: "true"
} },
{ qu: {
_desired: "qup",
_distance: "10",
_oneway: "true"
} },
{ qu: {
_desired: "qur",
_distance: "10",
_oneway: "true"
} },
{ qu: {
_desired: "qus",
_distance: "10",
_oneway: "true"
} },
{ qu: {
_desired: "quw",
_distance: "10",
_oneway: "true"
} },
{ qu: {
_desired: "qux",
_distance: "10",
_oneway: "true"
} },
{ qu: {
_desired: "quy",
_distance: "10",
_oneway: "true"
} },
{ qu: {
_desired: "qva",
_distance: "10",
_oneway: "true"
} },
{ qu: {
_desired: "qvc",
_distance: "10",
_oneway: "true"
} },
{ qu: {
_desired: "qve",
_distance: "10",
_oneway: "true"
} },
{ qu: {
_desired: "qvh",
_distance: "10",
_oneway: "true"
} },
{ qu: {
_desired: "qvi",
_distance: "10",
_oneway: "true"
} },
{ qu: {
_desired: "qvj",
_distance: "10",
_oneway: "true"
} },
{ qu: {
_desired: "qvl",
_distance: "10",
_oneway: "true"
} },
{ qu: {
_desired: "qvm",
_distance: "10",
_oneway: "true"
} },
{ qu: {
_desired: "qvn",
_distance: "10",
_oneway: "true"
} },
{ qu: {
_desired: "qvo",
_distance: "10",
_oneway: "true"
} },
{ qu: {
_desired: "qvp",
_distance: "10",
_oneway: "true"
} },
{ qu: {
_desired: "qvs",
_distance: "10",
_oneway: "true"
} },
{ qu: {
_desired: "qvw",
_distance: "10",
_oneway: "true"
} },
{ qu: {
_desired: "qvz",
_distance: "10",
_oneway: "true"
} },
{ qu: {
_desired: "qwa",
_distance: "10",
_oneway: "true"
} },
{ qu: {
_desired: "qwc",
_distance: "10",
_oneway: "true"
} },
{ qu: {
_desired: "qwh",
_distance: "10",
_oneway: "true"
} },
{ qu: {
_desired: "qws",
_distance: "10",
_oneway: "true"
} },
{ qu: {
_desired: "qxa",
_distance: "10",
_oneway: "true"
} },
{ qu: {
_desired: "qxc",
_distance: "10",
_oneway: "true"
} },
{ qu: {
_desired: "qxh",
_distance: "10",
_oneway: "true"
} },
{ qu: {
_desired: "qxl",
_distance: "10",
_oneway: "true"
} },
{ qu: {
_desired: "qxn",
_distance: "10",
_oneway: "true"
} },
{ qu: {
_desired: "qxo",
_distance: "10",
_oneway: "true"
} },
{ qu: {
_desired: "qxp",
_distance: "10",
_oneway: "true"
} },
{ qu: {
_desired: "qxr",
_distance: "10",
_oneway: "true"
} },
{ qu: {
_desired: "qxt",
_distance: "10",
_oneway: "true"
} },
{ qu: {
_desired: "qxu",
_distance: "10",
_oneway: "true"
} },
{ qu: {
_desired: "qxw",
_distance: "10",
_oneway: "true"
} },
{ sc: {
_desired: "sdc",
_distance: "10",
_oneway: "true"
} },
{ sc: {
_desired: "sdn",
_distance: "10",
_oneway: "true"
} },
{ sc: {
_desired: "sro",
_distance: "10",
_oneway: "true"
} },
{ sq: {
_desired: "aae",
_distance: "10",
_oneway: "true"
} },
{ sq: {
_desired: "aat",
_distance: "10",
_oneway: "true"
} },
{ sq: {
_desired: "aln",
_distance: "10",
_oneway: "true"
} },
{ syr: {
_desired: "aii",
_distance: "10",
_oneway: "true"
} },
{ uz: {
_desired: "uzs",
_distance: "10",
_oneway: "true"
} },
{ yi: {
_desired: "yih",
_distance: "10",
_oneway: "true"
} },
{ zh: {
_desired: "cdo",
_distance: "10",
_oneway: "true"
} },
{ zh: {
_desired: "cjy",
_distance: "10",
_oneway: "true"
} },
{ zh: {
_desired: "cpx",
_distance: "10",
_oneway: "true"
} },
{ zh: {
_desired: "czh",
_distance: "10",
_oneway: "true"
} },
{ zh: {
_desired: "czo",
_distance: "10",
_oneway: "true"
} },
{ zh: {
_desired: "gan",
_distance: "10",
_oneway: "true"
} },
{ zh: {
_desired: "hak",
_distance: "10",
_oneway: "true"
} },
{ zh: {
_desired: "hsn",
_distance: "10",
_oneway: "true"
} },
{ zh: {
_desired: "lzh",
_distance: "10",
_oneway: "true"
} },
{ zh: {
_desired: "mnp",
_distance: "10",
_oneway: "true"
} },
{ zh: {
_desired: "nan",
_distance: "10",
_oneway: "true"
} },
{ zh: {
_desired: "wuu",
_distance: "10",
_oneway: "true"
} },
{ zh: {
_desired: "yue",
_distance: "10",
_oneway: "true"
} },
{ "*": {
_desired: "*",
_distance: "80"
} },
{ "en-Latn": {
_desired: "am-Ethi",
_distance: "10",
_oneway: "true"
} },
{ "ru-Cyrl": {
_desired: "az-Latn",
_distance: "10",
_oneway: "true"
} },
{ "en-Latn": {
_desired: "bn-Beng",
_distance: "10",
_oneway: "true"
} },
{ "zh-Hans": {
_desired: "bo-Tibt",
_distance: "10",
_oneway: "true"
} },
{ "ru-Cyrl": {
_desired: "hy-Armn",
_distance: "10",
_oneway: "true"
} },
{ "en-Latn": {
_desired: "ka-Geor",
_distance: "10",
_oneway: "true"
} },
{ "en-Latn": {
_desired: "km-Khmr",
_distance: "10",
_oneway: "true"
} },
{ "en-Latn": {
_desired: "kn-Knda",
_distance: "10",
_oneway: "true"
} },
{ "en-Latn": {
_desired: "lo-Laoo",
_distance: "10",
_oneway: "true"
} },
{ "en-Latn": {
_desired: "ml-Mlym",
_distance: "10",
_oneway: "true"
} },
{ "en-Latn": {
_desired: "my-Mymr",
_distance: "10",
_oneway: "true"
} },
{ "en-Latn": {
_desired: "ne-Deva",
_distance: "10",
_oneway: "true"
} },
{ "en-Latn": {
_desired: "or-Orya",
_distance: "10",
_oneway: "true"
} },
{ "en-Latn": {
_desired: "pa-Guru",
_distance: "10",
_oneway: "true"
} },
{ "en-Latn": {
_desired: "ps-Arab",
_distance: "10",
_oneway: "true"
} },
{ "en-Latn": {
_desired: "sd-Arab",
_distance: "10",
_oneway: "true"
} },
{ "en-Latn": {
_desired: "si-Sinh",
_distance: "10",
_oneway: "true"
} },
{ "en-Latn": {
_desired: "ta-Taml",
_distance: "10",
_oneway: "true"
} },
{ "en-Latn": {
_desired: "te-Telu",
_distance: "10",
_oneway: "true"
} },
{ "en-Latn": {
_desired: "ti-Ethi",
_distance: "10",
_oneway: "true"
} },
{ "ru-Cyrl": {
_desired: "tk-Latn",
_distance: "10",
_oneway: "true"
} },
{ "en-Latn": {
_desired: "ur-Arab",
_distance: "10",
_oneway: "true"
} },
{ "ru-Cyrl": {
_desired: "uz-Latn",
_distance: "10",
_oneway: "true"
} },
{ "en-Latn": {
_desired: "yi-Hebr",
_distance: "10",
_oneway: "true"
} },
{ "sr-Cyrl": {
_desired: "sr-Latn",
_distance: "5"
} },
{ "zh-Hans": {
_desired: "za-Latn",
_distance: "10",
_oneway: "true"
} },
{ "zh-Hans": {
_desired: "zh-Hani",
_distance: "20",
_oneway: "true"
} },
{ "zh-Hant": {
_desired: "zh-Hani",
_distance: "20",
_oneway: "true"
} },
{ "ar-Arab": {
_desired: "ar-Latn",
_distance: "20",
_oneway: "true"
} },
{ "bn-Beng": {
_desired: "bn-Latn",
_distance: "20",
_oneway: "true"
} },
{ "gu-Gujr": {
_desired: "gu-Latn",
_distance: "20",
_oneway: "true"
} },
{ "hi-Deva": {
_desired: "hi-Latn",
_distance: "20",
_oneway: "true"
} },
{ "kn-Knda": {
_desired: "kn-Latn",
_distance: "20",
_oneway: "true"
} },
{ "ml-Mlym": {
_desired: "ml-Latn",
_distance: "20",
_oneway: "true"
} },
{ "mr-Deva": {
_desired: "mr-Latn",
_distance: "20",
_oneway: "true"
} },
{ "ta-Taml": {
_desired: "ta-Latn",
_distance: "20",
_oneway: "true"
} },
{ "te-Telu": {
_desired: "te-Latn",
_distance: "20",
_oneway: "true"
} },
{ "zh-Hans": {
_desired: "zh-Latn",
_distance: "20",
_oneway: "true"
} },
{ "ja-Jpan": {
_desired: "ja-Latn",
_distance: "5",
_oneway: "true"
} },
{ "ja-Jpan": {
_desired: "ja-Hani",
_distance: "5",
_oneway: "true"
} },
{ "ja-Jpan": {
_desired: "ja-Hira",
_distance: "5",
_oneway: "true"
} },
{ "ja-Jpan": {
_desired: "ja-Kana",
_distance: "5",
_oneway: "true"
} },
{ "ja-Jpan": {
_desired: "ja-Hrkt",
_distance: "5",
_oneway: "true"
} },
{ "ja-Hrkt": {
_desired: "ja-Hira",
_distance: "5",
_oneway: "true"
} },
{ "ja-Hrkt": {
_desired: "ja-Kana",
_distance: "5",
_oneway: "true"
} },
{ "ko-Kore": {
_desired: "ko-Hani",
_distance: "5",
_oneway: "true"
} },
{ "ko-Kore": {
_desired: "ko-Hang",
_distance: "5",
_oneway: "true"
} },
{ "ko-Kore": {
_desired: "ko-Jamo",
_distance: "5",
_oneway: "true"
} },
{ "ko-Hang": {
_desired: "ko-Jamo",
_distance: "5",
_oneway: "true"
} },
{ "*-*": {
_desired: "*-*",
_distance: "50"
} },
{ "ar-*-$maghreb": {
_desired: "ar-*-$maghreb",
_distance: "4"
} },
{ "ar-*-$!maghreb": {
_desired: "ar-*-$!maghreb",
_distance: "4"
} },
{ "ar-*-*": {
_desired: "ar-*-*",
_distance: "5"
} },
{ "en-*-$enUS": {
_desired: "en-*-$enUS",
_distance: "4"
} },
{ "en-*-GB": {
_desired: "en-*-$!enUS",
_distance: "3"
} },
{ "en-*-$!enUS": {
_desired: "en-*-$!enUS",
_distance: "4"
} },
{ "en-*-*": {
_desired: "en-*-*",
_distance: "5"
} },
{ "es-*-$americas": {
_desired: "es-*-$americas",
_distance: "4"
} },
{ "es-*-$!americas": {
_desired: "es-*-$!americas",
_distance: "4"
} },
{ "es-*-*": {
_desired: "es-*-*",
_distance: "5"
} },
{ "pt-*-$americas": {
_desired: "pt-*-$americas",
_distance: "4"
} },
{ "pt-*-$!americas": {
_desired: "pt-*-$!americas",
_distance: "4"
} },
{ "pt-*-*": {
_desired: "pt-*-*",
_distance: "5"
} },
{ "zh-Hant-$cnsar": {
_desired: "zh-Hant-$cnsar",
_distance: "4"
} },
{ "zh-Hant-$!cnsar": {
_desired: "zh-Hant-$!cnsar",
_distance: "4"
} },
{ "zh-Hant-*": {
_desired: "zh-Hant-*",
_distance: "5"
} },
{ "*-*-*": {
_desired: "*-*-*",
_distance: "4"
} }
] } } };
const regions = {
"001": [
"001",
"001-status-grouping",
"002",
"005",
"009",
"011",
"013",
"014",
"015",
"017",
"018",
"019",
"021",
"029",
"030",
"034",
"035",
"039",
"053",
"054",
"057",
"061",
"142",
"143",
"145",
"150",
"151",
"154",
"155",
"AC",
"AD",
"AE",
"AF",
"AG",
"AI",
"AL",
"AM",
"AO",
"AQ",
"AR",
"AS",
"AT",
"AU",
"AW",
"AX",
"AZ",
"BA",
"BB",
"BD",
"BE",
"BF",
"BG",
"BH",
"BI",
"BJ",
"BL",
"BM",
"BN",
"BO",
"BQ",
"BR",
"BS",
"BT",
"BV",
"BW",
"BY",
"BZ",
"CA",
"CC",
"CD",
"CF",
"CG",
"CH",
"CI",
"CK",
"CL",
"CM",
"CN",
"CO",
"CP",
"CQ",
"CR",
"CU",
"CV",
"CW",
"CX",
"CY",
"CZ",
"DE",
"DG",
"DJ",
"DK",
"DM",
"DO",
"DZ",
"EA",
"EC",
"EE",
"EG",
"EH",
"ER",
"ES",
"ET",
"EU",
"EZ",
"FI",
"FJ",
"FK",
"FM",
"FO",
"FR",
"GA",
"GB",
"GD",
"GE",
"GF",
"GG",
"GH",
"GI",
"GL",
"GM",
"GN",
"GP",
"GQ",
"GR",
"GS",
"GT",
"GU",
"GW",
"GY",
"HK",
"HM",
"HN",
"HR",
"HT",
"HU",
"IC",
"ID",
"IE",
"IL",
"IM",
"IN",
"IO",
"IQ",
"IR",
"IS",
"IT",
"JE",
"JM",
"JO",
"JP",
"KE",
"KG",
"KH",
"KI",
"KM",
"KN",
"KP",
"KR",
"KW",
"KY",
"KZ",
"LA",
"LB",
"LC",
"LI",
"LK",
"LR",
"LS",
"LT",
"LU",
"LV",
"LY",
"MA",
"MC",
"MD",
"ME",
"MF",
"MG",
"MH",
"MK",
"ML",
"MM",
"MN",
"MO",
"MP",
"MQ",
"MR",
"MS",
"MT",
"MU",
"MV",
"MW",
"MX",
"MY",
"MZ",
"NA",
"NC",
"NE",
"NF",
"NG",
"NI",
"NL",
"NO",
"NP",
"NR",
"NU",
"NZ",
"OM",
"PA",
"PE",
"PF",
"PG",
"PH",
"PK",
"PL",
"PM",
"PN",
"PR",
"PS",
"PT",
"PW",
"PY",
"QA",
"QO",
"RE",
"RO",
"RS",
"RU",
"RW",
"SA",
"SB",
"SC",
"SD",
"SE",
"SG",
"SH",
"SI",
"SJ",
"SK",
"SL",
"SM",
"SN",
"SO",
"SR",
"SS",
"ST",
"SV",
"SX",
"SY",
"SZ",
"TA",
"TC",
"TD",
"TF",
"TG",
"TH",
"TJ",
"TK",
"TL",
"TM",
"TN",
"TO",
"TR",
"TT",
"TV",
"TW",
"TZ",
"UA",
"UG",
"UM",
"UN",
"US",
"UY",
"UZ",
"VA",
"VC",
"VE",
"VG",
"VI",
"VN",
"VU",
"WF",
"WS",
"XK",
"YE",
"YT",
"ZA",
"ZM",
"ZW"
],
"002": [
"002",
"002-status-grouping",
"011",
"014",
"015",
"017",
"018",
"202",
"AO",
"BF",
"BI",
"BJ",
"BW",
"CD",
"CF",
"CG",
"CI",
"CM",
"CV",
"DJ",
"DZ",
"EA",
"EG",
"EH",
"ER",
"ET",
"GA",
"GH",
"GM",
"GN",
"GQ",
"GW",
"IC",
"IO",
"KE",
"KM",
"LR",
"LS",
"LY",
"MA",
"MG",
"ML",
"MR",
"MU",
"MW",
"MZ",
"NA",
"NE",
"NG",
"RE",
"RW",
"SC",
"SD",
"SH",
"SL",
"SN",
"SO",
"SS",
"ST",
"SZ",
"TD",
"TF",
"TG",
"TN",
"TZ",
"UG",
"YT",
"ZA",
"ZM",
"ZW"
],
"003": [
"003",
"013",
"021",
"029",
"AG",
"AI",
"AW",
"BB",
"BL",
"BM",
"BQ",
"BS",
"BZ",
"CA",
"CR",
"CU",
"CW",
"DM",
"DO",
"GD",
"GL",
"GP",
"GT",
"HN",
"HT",
"JM",
"KN",
"KY",
"LC",
"MF",
"MQ",
"MS",
"MX",
"NI",
"PA",
"PM",
"PR",
"SV",
"SX",
"TC",
"TT",
"US",
"VC",
"VG",
"VI"
],
"005": [
"005",
"AR",
"BO",
"BR",
"BV",
"CL",
"CO",
"EC",
"FK",
"GF",
"GS",
"GY",
"PE",
"PY",
"SR",
"UY",
"VE"
],
"009": [
"009",
"053",
"054",
"057",
"061",
"AC",
"AQ",
"AS",
"AU",
"CC",
"CK",
"CP",
"CX",
"DG",
"FJ",
"FM",
"GU",
"HM",
"KI",
"MH",
"MP",
"NC",
"NF",
"NR",
"NU",
"NZ",
"PF",
"PG",
"PN",
"PW",
"QO",
"SB",
"TA",
"TK",
"TO",
"TV",
"UM",
"VU",
"WF",
"WS"
],
"011": [
"011",
"BF",
"BJ",
"CI",
"CV",
"GH",
"GM",
"GN",
"GW",
"LR",
"ML",
"MR",
"NE",
"NG",
"SH",
"SL",
"SN",
"TG"
],
"013": [
"013",
"BZ",
"CR",
"GT",
"HN",
"MX",
"NI",
"PA",
"SV"
],
"014": [
"014",
"BI",
"DJ",
"ER",
"ET",
"IO",
"KE",
"KM",
"MG",
"MU",
"MW",
"MZ",
"RE",
"RW",
"SC",
"SO",
"SS",
"TF",
"TZ",
"UG",
"YT",
"ZM",
"ZW"
],
"015": [
"015",
"DZ",
"EA",
"EG",
"EH",
"IC",
"LY",
"MA",
"SD",
"TN"
],
"017": [
"017",
"AO",
"CD",
"CF",
"CG",
"CM",
"GA",
"GQ",
"ST",
"TD"
],
"018": [
"018",
"BW",
"LS",
"NA",
"SZ",
"ZA"
],
"019": [
"003",
"005",
"013",
"019",
"019-status-grouping",
"021",
"029",
"419",
"AG",
"AI",
"AR",
"AW",
"BB",
"BL",
"BM",
"BO",
"BQ",
"BR",
"BS",
"BV",
"BZ",
"CA",
"CL",
"CO",
"CR",
"CU",
"CW",
"DM",
"DO",
"EC",
"FK",
"GD",
"GF",
"GL",
"GP",
"GS",
"GT",
"GY",
"HN",
"HT",
"JM",
"KN",
"KY",
"LC",
"MF",
"MQ",
"MS",
"MX",
"NI",
"PA",
"PE",
"PM",
"PR",
"PY",
"SR",
"SV",
"SX",
"TC",
"TT",
"US",
"UY",
"VC",
"VE",
"VG",
"VI"
],
"021": [
"021",
"BM",
"CA",
"GL",
"PM",
"US"
],
"029": [
"029",
"AG",
"AI",
"AW",
"BB",
"BL",
"BQ",
"BS",
"CU",
"CW",
"DM",
"DO",
"GD",
"GP",
"HT",
"JM",
"KN",
"KY",
"LC",
"MF",
"MQ",
"MS",
"PR",
"SX",
"TC",
"TT",
"VC",
"VG",
"VI"
],
"030": [
"030",
"CN",
"HK",
"JP",
"KP",
"KR",
"MN",
"MO",
"TW"
],
"034": [
"034",
"AF",
"BD",
"BT",
"IN",
"IR",
"LK",
"MV",
"NP",
"PK"
],
"035": [
"035",
"BN",
"ID",
"KH",
"LA",
"MM",
"MY",
"PH",
"SG",
"TH",
"TL",
"VN"
],
"039": [
"039",
"AD",
"AL",
"BA",
"ES",
"GI",
"GR",
"HR",
"IT",
"ME",
"MK",
"MT",
"PT",
"RS",
"SI",
"SM",
"VA",
"XK"
],
"053": [
"053",
"AU",
"CC",
"CX",
"HM",
"NF",
"NZ"
],
"054": [
"054",
"FJ",
"NC",
"PG",
"SB",
"VU"
],
"057": [
"057",
"FM",
"GU",
"KI",
"MH",
"MP",
"NR",
"PW",
"UM"
],
"061": [
"061",
"AS",
"CK",
"NU",
"PF",
"PN",
"TK",
"TO",
"TV",
"WF",
"WS"
],
"142": [
"030",
"034",
"035",
"142",
"143",
"145",
"AE",
"AF",
"AM",
"AZ",
"BD",
"BH",
"BN",
"BT",
"CN",
"CY",
"GE",
"HK",
"ID",
"IL",
"IN",
"IQ",
"IR",
"JO",
"JP",
"KG",
"KH",
"KP",
"KR",
"KW",
"KZ",
"LA",
"LB",
"LK",
"MM",
"MN",
"MO",
"MV",
"MY",
"NP",
"OM",
"PH",
"PK",
"PS",
"QA",
"SA",
"SG",
"SY",
"TH",
"TJ",
"TL",
"TM",
"TR",
"TW",
"UZ",
"VN",
"YE"
],
"143": [
"143",
"KG",
"KZ",
"TJ",
"TM",
"UZ"
],
"145": [
"145",
"AE",
"AM",
"AZ",
"BH",
"CY",
"GE",
"IL",
"IQ",
"JO",
"KW",
"LB",
"OM",
"PS",
"QA",
"SA",
"SY",
"TR",
"YE"
],
"150": [
"039",
"150",
"151",
"154",
"155",
"AD",
"AL",
"AT",
"AX",
"BA",
"BE",
"BG",
"BY",
"CH",
"CQ",
"CZ",
"DE",
"DK",
"EE",
"ES",
"FI",
"FO",
"FR",
"GB",
"GG",
"GI",
"GR",
"HR",
"HU",
"IE",
"IM",
"IS",
"IT",
"JE",
"LI",
"LT",
"LU",
"LV",
"MC",
"MD",
"ME",
"MK",
"MT",
"NL",
"NO",
"PL",
"PT",
"RO",
"RS",
"RU",
"SE",
"SI",
"SJ",
"SK",
"SM",
"UA",
"VA",
"XK"
],
"151": [
"151",
"BG",
"BY",
"CZ",
"HU",
"MD",
"PL",
"RO",
"RU",
"SK",
"UA"
],
"154": [
"154",
"AX",
"CQ",
"DK",
"EE",
"FI",
"FO",
"GB",
"GG",
"IE",
"IM",
"IS",
"JE",
"LT",
"LV",
"NO",
"SE",
"SJ"
],
"155": [
"155",
"AT",
"BE",
"CH",
"DE",
"FR",
"LI",
"LU",
"MC",
"NL"
],
"202": [
"011",
"014",
"017",
"018",
"202",
"AO",
"BF",
"BI",
"BJ",
"BW",
"CD",
"CF",
"CG",
"CI",
"CM",
"CV",
"DJ",
"ER",
"ET",
"GA",
"GH",
"GM",
"GN",
"GQ",
"GW",
"IO",
"KE",
"KM",
"LR",
"LS",
"MG",
"ML",
"MR",
"MU",
"MW",
"MZ",
"NA",
"NE",
"NG",
"RE",
"RW",
"SC",
"SH",
"SL",
"SN",
"SO",
"SS",
"ST",
"SZ",
"TD",
"TF",
"TG",
"TZ",
"UG",
"YT",
"ZA",
"ZM",
"ZW"
],
"419": [
"005",
"013",
"029",
"419",
"AG",
"AI",
"AR",
"AW",
"BB",
"BL",
"BO",
"BQ",
"BR",
"BS",
"BV",
"BZ",
"CL",
"CO",
"CR",
"CU",
"CW",
"DM",
"DO",
"EC",
"FK",
"GD",
"GF",
"GP",
"GS",
"GT",
"GY",
"HN",
"HT",
"JM",
"KN",
"KY",
"LC",
"MF",
"MQ",
"MS",
"MX",
"NI",
"PA",
"PE",
"PR",
"PY",
"SR",
"SV",
"SX",
"TC",
"TT",
"UY",
"VC",
"VE",
"VG",
"VI"
],
"EU": [
"AT",
"BE",
"BG",
"CY",
"CZ",
"DE",
"DK",
"EE",
"ES",
"EU",
"FI",
"FR",
"GR",
"HR",
"HU",
"IE",
"IT",
"LT",
"LU",
"LV",
"MT",
"NL",
"PL",
"PT",
"RO",
"SE",
"SI",
"SK"
],
"EZ": [
"AT",
"BE",
"CY",
"DE",
"EE",
"ES",
"EZ",
"FI",
"FR",
"GR",
"IE",
"IT",
"LT",
"LU",
"LV",
"MT",
"NL",
"PT",
"SI",
"SK"
],
"QO": [
"AC",
"AQ",
"CP",
"DG",
"QO",
"TA"
],
"UN": [
"AD",
"AE",
"AF",
"AG",
"AL",
"AM",
"AO",
"AR",
"AT",
"AU",
"AZ",
"BA",
"BB",
"BD",
"BE",
"BF",
"BG",
"BH",
"BI",
"BJ",
"BN",
"BO",
"BR",
"BS",
"BT",
"BW",
"BY",
"BZ",
"CA",
"CD",
"CF",
"CG",
"CH",
"CI",
"CL",
"CM",
"CN",
"CO",
"CR",
"CU",
"CV",
"CY",
"CZ",
"DE",
"DJ",
"DK",
"DM",
"DO",
"DZ",
"EC",
"EE",
"EG",
"ER",
"ES",
"ET",
"FI",
"FJ",
"FM",
"FR",
"GA",
"GB",
"GD",
"GE",
"GH",
"GM",
"GN",
"GQ",
"GR",
"GT",
"GW",
"GY",
"HN",
"HR",
"HT",
"HU",
"ID",
"IE",
"IL",
"IN",
"IQ",
"IR",
"IS",
"IT",
"JM",
"JO",
"JP",
"KE",
"KG",
"KH",
"KI",
"KM",
"KN",
"KP",
"KR",
"KW",
"KZ",
"LA",
"LB",
"LC",
"LI",
"LK",
"LR",
"LS",
"LT",
"LU",
"LV",
"LY",
"MA",
"MC",
"MD",
"ME",
"MG",
"MH",
"MK",
"ML",
"MM",
"MN",
"MR",
"MT",
"MU",
"MV",
"MW",
"MX",
"MY",
"MZ",
"NA",
"NE",
"NG",
"NI",
"NL",
"NO",
"NP",
"NR",
"NZ",
"OM",
"PA",
"PE",
"PG",
"PH",
"PK",
"PL",
"PT",
"PW",
"PY",
"QA",
"RO",
"RS",
"RU",
"RW",
"SA",
"SB",
"SC",
"SD",
"SE",
"SG",
"SI",
"SK",
"SL",
"SM",
"SN",
"SO",
"SR",
"SS",
"ST",
"SV",
"SY",
"SZ",
"TD",
"TG",
"TH",
"TJ",
"TL",
"TM",
"TN",
"TO",
"TR",
"TT",
"TV",
"TZ",
"UA",
"UG",
"UN",
"US",
"UY",
"UZ",
"VC",
"VE",
"VN",
"VU",
"WS",
"YE",
"ZA",
"ZM",
"ZW"
]
};
function splitUnicodeExtension(locale) {
const subtags = locale.split("-");
for (let i = 1; i < subtags.length; i++) {
if (subtags[i] === "x") break;
if (subtags[i] !== "u") continue;
let end = i + 1;
while (end < subtags.length && subtags[end].length > 1) end++;
return {
locale: [...subtags.slice(0, i), ...subtags.slice(end)].join("-"),
extension: "-" + subtags.slice(i, end).join("-")
};
}
return { locale };
}
/**
* Asserts that a condition is true, throwing an error if it is not.
* Used for runtime validation and type narrowing.
*
* @param condition - The condition to check
* @param message - Error message if condition is false
* @param Err - Error constructor to use (defaults to Error)
* @throws {Error} When condition is false
*
* @example
* ```ts
* invariant(locale !== undefined, 'Locale must be defined')
* // locale is now narrowed to non-undefined type
* ```
*/
function invariant$1(condition, message, Err = Error) {
if (!condition) throw new Err(message);
}
const DEFAULT_MATCHING_THRESHOLD = 838;
let PROCESSED_DATA;
function processData() {
if (!PROCESSED_DATA) {
const paradigmLocales = data.supplemental.languageMatching["written-new"][0]?.paradigmLocales?._locales.split(" ");
const matchVariables = data.supplemental.languageMatching["written-new"].slice(1, 5);
PROCESSED_DATA = {
matches: data.supplemental.languageMatching["written-new"].slice(5).map((d) => {
const key = Object.keys(d)[0];
const value = d[key];
return {
supported: key,
desired: value._desired,
distance: +value._distance,
oneway: value.oneway === "true" ? true : false
};
}, {}),
matchVariables: matchVariables.reduce((all, d) => {
const key = Object.keys(d)[0];
const value = d[key];
all[key.slice(1)] = value._value.split("+");
return all;
}, {}),
paradigmLocales: [...paradigmLocales, ...paradigmLocales.map((l) => new Intl.Locale(l.replace(/_/g, "-")).maximize().toString())]
};
}
return PROCESSED_DATA;
}
function isMatched(locale, languageMatchInfoLocale, matchVariables) {
const [language, script, region] = languageMatchInfoLocale.split("-");
let matches = true;
if (region && region[0] === "$") {
const shouldInclude = region[1] !== "!";
const expandedMatchedRegions = (shouldInclude ? matchVariables[region.slice(1)] : matchVariables[region.slice(2)]).map((r) => regions[r] || [r]).reduce((all, list) => [...all, ...list], []);
matches &&= !(expandedMatchedRegions.indexOf(locale.region || "") > -1 != shouldInclude);
} else matches &&= locale.region ? region === "*" || region === locale.region : true;
matches &&= locale.script ? script === "*" || script === locale.script : true;
matches &&= locale.language ? language === "*" || language === locale.language : true;
return matches;
}
function serializeLSR(lsr) {
return [
lsr.language,
lsr.script,
lsr.region
].filter(Boolean).join("-");
}
function findMatchingDistanceForLSR(desired, supported, data) {
for (const d of data.matches) {
let matches = isMatched(desired, d.desired, data.matchVariables) && isMatched(supported, d.supported, data.matchVariables);
if (!d.oneway && !matches) matches = isMatched(desired, d.supported, data.matchVariables) && isMatched(supported, d.desired, data.matchVariables);
if (matches) {
const distance = d.distance * 10;
if (data.paradigmLocales.indexOf(serializeLSR(desired)) > -1 != data.paradigmLocales.indexOf(serializeLSR(supported)) > -1) return distance - 1;
return distance;
}
}
throw new Error("No matching distance found");
}
function findMatchingDistanceImpl(desired, supported) {
const desiredLocale = new Intl.Locale(desired).maximize();
const supportedLocale = new Intl.Locale(supported).maximize();
const desiredLSR = {
language: desiredLocale.language,
script: desiredLocale.script || "",
region: desiredLocale.region || ""
};
const supportedLSR = {
language: supportedLocale.language,
script: supportedLocale.script || "",
region: supportedLocale.region || ""
};
let matchingDistance = 0;
const data = processData();
if (desiredLSR.language !== supportedLSR.language) matchingDistance += findMatchingDistanceForLSR({
language: desiredLocale.language,
script: "",
region: ""
}, {
language: supportedLocale.language,
script: "",
region: ""
}, data);
if (desiredLSR.script !== supportedLSR.script) matchingDistance += findMatchingDistanceForLSR({
language: desiredLocale.language,
script: desiredLSR.script,
region: ""
}, {
language: supportedLocale.language,
script: supportedLSR.script,
region: ""
}, data);
if (desiredLSR.region !== supportedLSR.region) matchingDistance += findMatchingDistanceForLSR(desiredLSR, supportedLSR, data);
return matchingDistance;
}
/**
* Calculates the matching distance between two locales using the CLDR Enhanced Language Matching algorithm.
* This function is memoized for performance, as distance calculations are expensive.
*
* The distance represents how "far apart" two locales are, with 0 being identical (after maximization).
* Distances are calculated based on Language-Script-Region (LSR) differences using CLDR data.
*
* @param desired - The desired locale (e.g., "en-US")
* @param supported - The supported locale to compare against (e.g., "en-GB")
* @returns The calculated distance between the locales
*
* @example
* ```ts
* findMatchingDistance('en-US', 'en-US') // 0 - identical
* findMatchingDistance('en-US', 'en-GB') // 40 - same language/script, different region
* findMatchingDistance('es-CO', 'es-419') // 39 - regional variant
* findMatchingDistance('en', 'fr') // 840 - completely different languages
* ```
*
* @see https://unicode.org/reports/tr35/#EnhancedLanguageMatching
*/
const findMatchingDistance = memoize(findMatchingDistanceImpl, { serializer: (args) => `${args[0]}|${args[1]}` });
/**
* Generates fallback candidates by progressively removing subtags
* e.g., "en-US" -> ["en-US", "en"]
* "zh-Hans-CN" -> ["zh-Hans-CN", "zh-Hans", "zh"]
*/
function getFallbackCandidates(locale) {
const candidates = [];
let current = locale;
while (current) {
candidates.push(current);
const lastDash = current.lastIndexOf("-");
if (lastDash === -1) break;
current = current.substring(0, lastDash);
}
return candidates;
}
/**
* Finds the best locale match using a three-tier optimization hierarchy.
*
* ## Three-Tier Matching Algorithm:
*
* **Tier 1 - Fast Path** (O(n)): Exact string matching via Set lookup
* - Example: 'en' matches 'en' exactly → distance 0
* - Solves #4936: 48x faster than baseline (12ms vs 610ms with 700+ locales)
*
* **Tier 2 - Fallback Path** (O(k×n)): Maximization + progressive subtag removal
* - Maximizes requested locale, then removes subtags right-to-left
* - Example: "zh-TW" → "zh-Hant-TW" → ["zh-Hant-TW", "zh-Hant", "zh"]
* - Distance: 0 for maximized match, 10 per removed subtag + position penalty
* - 40-50x faster than full UTS #35, handles 99% of real-world cases correctly
*
* **Tier 3 - Slow Path** (O(n×m), memoized): Full UTS #35 CLDR matching
* - Calculates Language-Script-Region distances using CLDR data
* - Handles complex cases like cross-script matching (sr-Cyrl ↔ sr-Latn)
* - Only used when Tiers 1 & 2 find no match
* - Still 6x faster than baseline due to memoization
*
* ## Performance Impact of Maximization:
*
* While Tier 2 now calls `Intl.Locale().maximize()` once per requested locale,
* this is still much faster than Tier 3's full distance calculation:
* - Tier 1: ~12ms (exact match, no maximization)
* - Tier 2: ~13-15ms (maximization + fallback)
* - Tier 3: ~100ms+ (full UTS #35 with all supported locales)
*
* @param requestedLocales - Locale identifiers in preference order
* @param supportedLocales - Available locale identifiers
* @param threshold - Maximum distance (default: 838, from CLDR)
* @returns Matching result with distances
*
* @example
* ```ts
* // Tier 1: Exact match
* findBestMatch(['en'], ['en', 'fr'])
* // → { matchedSupportedLocale: 'en', distances: { en: { en: 0 } } }
*
* // Tier 2: Fallback with maximization
* findBestMatch(['zh-TW'], ['zh-Hant'])
* // → zh-TW maximizes to zh-Hant-TW, falls back to zh-Hant (distance 0)
*
* findBestMatch(['en-US'], ['en'])
* // → en-US maximizes to en-Latn-US, falls back to en (distance 10)
*
* // Tier 3: Full calculation
* findBestMatch(['en-XZ'], ['ja', 'ko'])
* // → No fallback match, uses UTS #35 to find closest match
* ```
*
* @see https://unicode.org/reports/tr35/#EnhancedLanguageMatching
* @see https://github.com/formatjs/formatjs/issues/4936
*/
const canonicalizedSupportedCache = /* @__PURE__ */ new WeakMap();
function findBestMatch(requestedLocales, supportedLocales, threshold = DEFAULT_MATCHING_THRESHOLD) {
let lowestDistance = Infinity;
let result = {
matchedDesiredLocale: "",
distances: {}
};
let canonicalizedSupportedLocales = canonicalizedSupportedCache.get(supportedLocales);
if (!canonicalizedSupportedLocales) {
canonicalizedSupportedLocales = supportedLocales.map((locale) => {
try {
return Intl.getCanonicalLocales([locale])[0] || locale;
} catch {
return locale;
}
});
canonicalizedSupportedCache.set(supportedLocales, canonicalizedSupportedLocales);
}
const supportedSet = new Set(canonicalizedSupportedLocales);
for (let i = 0; i < requestedLocales.length; i++) {
const desired = requestedLocales[i];
if (supportedSet.has(desired)) {
const distance = 0 + i * 40;
result.distances[desired] = { [desired]: distance };
if (distance < lowestDistance) {
lowestDistance = distance;
result.matchedDesiredLocale = desired;
result.matchedSupportedLocale = desired;
}
if (i === 0) return result;
}
}
for (let i = 0; i < requestedLocales.length; i++) {
const desired = requestedLocales[i];
try {
const maximized = new Intl.Locale(desired).maximize().toString();
if (maximized !== desired) {
const maximizedCandidates = getFallbackCandidates(maximized);
for (let j = 0; j < maximizedCandidates.length; j++) {
const candidate = maximizedCandidates[j];
if (candidate === desired) continue;
if (supportedSet.has(candidate)) {
let distance;
try {
distance = new Intl.Locale(candidate).maximize().toString() === maximized ? 0 + i * 40 : j * 10 + i * 40;
} catch {
distance = j * 10 + i * 40;
}
if (!result.distances[desired]) result.distances[desired] = {};
result.distances[desired][candidate] = distance;
if (distance < lowestDistance) {
lowestDistance = distance;
result.matchedDesiredLocale = desired;
result.matchedSupportedLocale = candidate;
}
break;
}
}
}
} catch {}
}
if (result.matchedSupportedLocale && lowestDistance === 0) return result;
lowestDistance = Infinity;
requestedLocales.forEach((desired, i) => {
if (!result.distances[desired]) result.distances[desired] = {};
canonicalizedSupportedLocales.forEach((canonicalLocale, supportedIndex) => {
const originalSupported = supportedLocales[supportedIndex];
const finalDistance = findMatchingDistance(desired, canonicalLocale) + 0 + i * 40;
result.distances[desired][originalSupported] = finalDistance;
if (finalDistance < lowestDistance) {
lowestDistance = finalDistance;
result.matchedDesiredLocale = desired;
result.matchedSupportedLocale = originalSupported;
}
});
});
if (lowestDistance >= threshold) {
result.matchedDesiredLocale = void 0;
result.matchedSupportedLocale = void 0;
}
return result;
}
/**
* https://tc39.es/ecma402/#sec-bestfitmatcher
* @param availableLocales
* @param requestedLocales
* @param getDefaultLocale
*/
function BestFitMatcher(availableLocales, requestedLocales, getDefaultLocale) {
let foundLocale;
let extension;
const noExtensionLocales = [];
const noExtensionLocaleMap = requestedLocales.reduce((all, l) => {
const { locale: noExtensionLocale } = splitUnicodeExtension(l);
noExtensionLocales.push(noExtensionLocale);
all[noExtensionLocale] = l;
return all;
}, {});
const result = findBestMatch(noExtensionLocales, availableLocales);
if (result.matchedSupportedLocale && result.matchedDesiredLocale) {
foundLocale = result.matchedSupportedLocale;
extension = splitUnicodeExtension(noExtensionLocaleMap[result.matchedDesiredLocale]).extension;
}
if (!foundLocale) return { locale: getDefaultLocale() };
return {
locale: foundLocale,
extension
};
}
const subdivisionAlias = {
"cn11": "cnbj",
"cn12": "cntj",
"cn13": "cnhe",
"cn14": "cnsx",
"cn15": "cnmn",
"cn21": "cnln",
"cn22": "cnjl",
"cn23": "cnhl",
"cn31": "cnsh",
"cn32": "cnjs",
"cn33": "cnzj",
"cn34": "cnah",
"cn35": "cnfj",
"cn36": "cnjx",
"cn37": "cnsd",
"cn41": "cnha",
"cn42": "cnhb",
"cn43": "cnhn",
"cn44": "cngd",
"cn45": "cngx",
"cn46": "cnhi",
"cn50": "cncq",
"cn51": "cnsc",
"cn52": "cngz",
"cn53": "cnyn",
"cn54": "cnxz",
"cn61": "cnsn",
"cn62": "cngs",
"cn63": "cnqh",
"cn64": "cnnx",
"cn65": "cnxj",
"cn71": "twzzzz",
"cn91": "hkzzzz",
"cn92": "mozzzz",
"cz10a": "cz110",
"cz10b": "cz111",
"cz10c": "cz112",
"cz10d": "cz113",
"cz10e": "cz114",
"cz10f": "cz115",
"cz611": "cz663",
"cz612": "cz632",
"cz613": "cz633",
"cz614": "cz634",
"cz615": "cz635",
"cz621": "cz641",
"cz622": "cz642",
"cz623": "cz643",
"cz624": "cz644",
"cz626": "cz646",
"cz627": "cz647",
"czjc": "cz31",
"czjm": "cz64",
"czka": "cz41",
"czkr": "cz52",
"czli": "cz51",
"czmo": "cz80",
"czol": "cz71",
"czpa": "cz53",
"czpl": "cz32",
"czpr": "cz10",
"czst": "cz20",
"czus": "cz42",
"czvy": "cz63",
"czzl": "cz72",
"fi01": "axzzzz",
"fra": "frges",
"frb": "frnaq",
"frbl": "blzzzz",
"frc": "frara",
"frcp": "cpzzzz",
"frd": "frbfc",
"fre": "frbre",
"frf": "frcvl",
"frg": "frges",
"frgf": "gfzzzz",
"frgp": "gpzzzz",
"frgua": "gpzzzz",
"frh": "frcor",
"fri": "frbfc",
"frj": "fridf",
"frk": "frocc",
"frl": "frnaq",
"frlre": "rezzzz",
"frm": "frges",
"frmay": "ytzzzz",
"frmf": "mfzzzz",
"frmq": "mqzzzz",
"frn": "frocc",
"frnc": "nczzzz",
"fro": "frhdf",
"frp": "frnor",
"frpf": "pfzzzz",
"frpm": "pmzzzz",
"frq": "frnor",
"frr": "frpdl",
"frre": "rezzzz",
"frs": "frhdf",
"frt": "frnaq",
"frtf": "tfzzzz",
"fru": "frpac",
"frv": "frara",
"frwf": "wfzzzz",
"fryt": "ytzzzz",
"laxn": "laxs",
"lud": "lucl",
"lug": "luec",
"lul": "luca",
"mrnkc": "mr13",
"nlaw": "awzzzz",
"nlcw": "cwzzzz",
"nlsx": "sxzzzz",
"no23": "no50",
"nzn": "nzauk",
"nzs": "nzcan",
"omba": "ombj",
"omsh": "omsj",
"plds": "pl02",
"plkp": "pl04",
"pllb": "pl08",
"plld": "pl10",
"pllu": "pl06",
"plma": "pl12",
"plmz": "pl14",
"plop": "pl16",
"plpd": "pl20",
"plpk": "pl18",
"plpm": "pl22",
"plsk": "pl26",
"plsl": "pl24",
"plwn": "pl28",
"plwp": "pl30",
"plzp": "pl32",
"shta": "tazzzz",
"tteto": "tttob",
"ttrcm": "ttmrc",
"ttwto": "tttob",
"twkhq": "twkhh",
"twtnq": "twtnn",
"twtpq": "twnwt",
"twtxq": "twtxg",
"usas": "aszzzz",
"usgu": "guzzzz",
"usmp": "mpzzzz",
"uspr": "przzzz",
"usum": "umzzzz",
"usvi": "vizzzz"
};
const extensionAlias = {
"t": {
"d0": { "name": "charname" },
"m0": {
"beta-metsehaf": "betamets",
"ies-jes": "iesjes",
"names": "prprname",
"tekie-alibekit": "tekieali"
}
},
"u": {
"ca": {
"ethiopic-amete-alem": "ethioaa",
"islamicc": "islamic-civil"
},
"kb": { "yes": "true" },
"kc": { "yes": "true" },
"kh": { "yes": "true" },
"kk": { "yes": "true" },
"kn": { "yes": "true" },
"ks": {
"primary": "level1",
"tertiary": "level3"
},
"ms": { "imperial": "uksystem" },
"tz": {
"aqams": "aqmcm",
"aukns": "auhba",
"caffs": "cawnp",
"camtr": "cator",
"canpg": "cator",
"capnt": "caiql",
"cathu": "cator",
"cayzf": "caedm",
"cet": "bebru",
"cnckg": "cnsha",
"cnhrb": "cnsha",
"cnkhg": "cnurc",
"cst6cdt": "uschi",
"cuba": "cuhav",
"eet": "grath",
"egypt": "egcai",
"eire": "iedub",
"est": "papty",
"est5edt": "usnyc",
"factory": "unk",
"gaza": "gazastrp",
"gmt0": "gmt",
"hongkong": "hkhkg",
"hst": "ushnl",
"iceland": "isrey",
"iran": "irthr",
"israel": "jeruslm",
"jamaica": "jmkin",
"japan": "jptyo",
"libya": "lytip",
"met": "bebru",
"mncoq": "mnuln",
"mst": "usphx",
"mst7mdt": "usden",
"mxstis": "mxtij",
"navajo": "usden",
"poland": "plwaw",
"portugal": "ptlis",
"prc": "cnsha",
"pst8pdt": "uslax",
"roc": "twtpe",
"rok": "krsel",
"turkey": "trist",
"uaozh": "uaiev",
"uauzh": "uaiev",
"uct": "utc",
"umjon": "ushnl",
"usnavajo": "usden",
"wet": "ptlis",
"zulu": "utc"
}
}
};
function CanonicalizeUValue(ukey, uvalue) {
invariant$1(ukey !== void 0, `ukey must be defined`);
let canonicalized = "";
for (let i = 0; i < uvalue.length; i++) {
const code = uvalue.charCodeAt(i);
canonicalized += code >= 65 && code <= 90 ? String.fromCharCode(code + 32) : uvalue[i];
}
const aliases = Object.prototype.hasOwnProperty.call(extensionAlias.u, ukey) ? extensionAlias.u[ukey] : void 0;
if (aliases && Object.prototype.hasOwnProperty.call(aliases, canonicalized)) canonicalized = aliases[canonicalized];
if ((ukey === "rg" || ukey === "sd") && Object.prototype.hasOwnProperty.call(subdivisionAlias, canonicalized)) canonicalized = subdivisionAlias[canonicalized];
return canonicalized === "true" ? "" : canonicalized;
}
function CanonicalizeUnicodeLocaleId(locale) {
return Intl.getCanonicalLocales(locale)[0];
}
function InsertUnicodeExtensionAndCanonicalize(locale, attributes, keywords) {
invariant$1(splitUnicodeExtension(locale).extension === void 0, "Expected locale to not have a Unicode locale extension");
let extension = "-u";
for (const attr of attributes) extension += `-${attr}`;
for (const kw of keywords) {
const { key, value } = kw;
extension += `-${key}`;
if (value !== "") extension += `-${value}`;
}
if (extension === "-u") return CanonicalizeUnicodeLocaleId(locale);
let privateIndex = locale.indexOf("-x-");
let newLocale;
if (privateIndex === -1) newLocale = locale + extension;
else {
let preExtension = locale.slice(0, privateIndex);
let postExtension = locale.slice(privateIndex);
newLocale = preExtension + extension + postExtension;
}
return CanonicalizeUnicodeLocaleId(newLocale);
}
const availableLocalesSetCache = /* @__PURE__ */ new WeakMap();
/**
* https://tc39.es/ecma402/#sec-bestavailablelocale
* @param availableLocales
* @param locale
*/
function BestAvailableLocale(availableLocales, locale) {
let availableSet = availableLocalesSetCache.get(availableLocales);
if (!availableSet) {
availableSet = new Set(availableLocales);
availableLocalesSetCache.set(availableLocales, availableSet);
}
let candidate = locale;
while (true) {
if (availableSet.has(candidate)) return candidate;
let pos = candidate.lastIndexOf("-");
if (!~pos) return;
if (pos >= 2 && candidate[pos - 2] === "-") pos -= 2;
candidate = candidate.slice(0, pos);
}
}
/**
* https://tc39.es/ecma402/#sec-lookupmatcher
* @param availableLocales
* @param requestedLocales
* @param getDefaultLocale
*/
function LookupMatcher(availableLocales, requestedLocales, getDefaultLocale) {
const result = { locale: "" };
for (const locale of requestedLocales) {
const { locale: noExtensionLocale, extension } = splitUnicodeExtension(locale);
const availableLocale = BestAvailableLocale(availableLocales, noExtensionLocale);
if (availableLocale) {
result.locale = availableLocale;
if (extension) result.extension = extension;
return result;
}
}
result.locale = getDefaultLocale();
return result;
}
function UnicodeExtensionComponents(extension) {
invariant$1(extension === extension.toLowerCase(), "Expected extension to be lowercase");
invariant$1(extension.slice(0, 3) === "-u-", "Expected extension to be a Unicode locale extension");
const attributes = [];
const keywords = [];
let keyword;
let size = extension.length;
let k = 3;
while (k < size) {
let e = extension.indexOf("-", k);
let len;
if (e === -1) len = size - k;
else len = e - k;
let subtag = extension.slice(k, k + len);
invariant$1(len >= 2, "Expected a subtag to have at least 2 characters");
if (keyword === void 0 && len != 2) {
if (attributes.indexOf(subtag) === -1) attributes.push(subtag);
} else if (len === 2) {
keyword = {
key: subtag,
value: ""
};
if (keywords.find((k) => k.key === keyword?.key) === void 0) keywords.push(keyword);
} else if (keyword?.value === "") keyword.value = subtag;
else {
invariant$1(keyword !== void 0, "Expected keyword to be defined");
keyword.value += "-" + subtag;
}
k += len + 1;
}
return {
attributes,
keywords
};
}
/**
* https://tc39.es/ecma402/#sec-resolvelocale
*/
function ResolveLocale(availableLocales, requestedLocales, options, relevantExtensionKeys, localeData, getDefaultLocale) {
const matcher = options.localeMatcher;
let r;
if (matcher === "lookup") r = LookupMatcher(Array.from(availableLocales), requestedLocales, getDefaultLocale);
else r = BestFitMatcher(Array.from(availableLocales), requestedLocales, getDefaultLocale);
if (r == null) r = {
locale: getDefaultLocale(),
extension: ""
};
let foundLocale = r.locale;
let foundLocaleData = localeData[foundLocale];
const result = Object.create(null);
result.locale = "en";
result.dataLocale = foundLocale;
let components;
let keywords;
if (r.extension) {
components = UnicodeExtensionComponents(r.extension);
keywords = components.keywords;
} else keywords = [];
let supportedKeywords = [];
for (const key of relevantExtensionKeys) {
let keyLocaleData = foundLocaleData?.[key] ?? [];
invariant$1(Array.isArray(keyLocaleData), `keyLocaleData for ${key} must be an array`);
let value = keyLocaleData[0];
invariant$1(value == null || typeof value === "string", `value must be a string, null, or undefined`);
let supportedKeyword;
let entry = keywords.find((k) => k.key === key);
if (entry) {
let requestedValue = entry.value;
if (requestedValue !== "") {
if (keyLocaleData.indexOf(requestedValue) > -1) {
value = requestedValue;
supportedKeyword = {
key,
value
};
}
} else if (keyLocaleData.indexOf("true") > -1) {
value = "true";
supportedKeyword = {
key,
value
};
}
}
let optionsValue = options[key];
invariant$1(optionsValue == null || typeof optionsValue === "string", `optionsValue must be a string or undefined`);
if (typeof optionsValue === "string") {
optionsValue = CanonicalizeUValue(key.toLowerCase(), optionsValue);
if (optionsValue === "") optionsValue = "true";
}
if (optionsValue !== void 0 && optionsValue !== value && keyLocaleData.indexOf(optionsValue) > -1) {
value = optionsValue;
supportedKeyword = void 0;
}
if (supportedKeyword) supportedKeywords.push(supportedKeyword);
result[key] = value;
}
let supportedAttributes = [];
if (supportedKeywords.length > 0) {
supportedAttributes = [];
foundLocale = InsertUnicodeExtensionAndCanonicalize(foundLocale, supportedAttributes, supportedKeywords);
}
result.locale = foundLocale;
return result;
}
/**
* https://tc39.es/ecma402/#sec-lookupsupportedlocales
* @param availableLocales
* @param requestedLocales
*/
function LookupSupportedLocales(availableLocales, requestedLocales) {
const subset = [];
for (const locale of requestedLocales) {
const { locale: noExtensionLocale } = splitUnicodeExtension(locale);
if (BestAvailableLocale(availableLocales, noExtensionLocale)) subset.push(locale);
}
return subset;
}
function match(requestedLocales, availableLocales, defaultLocale, opts) {
return ResolveLocale(availableLocales, CanonicalizeLocaleList(requestedLocales), { localeMatcher: opts?.algorithm || "best fit" }, [], {}, () => defaultLocale).locale;
}
//#endregion
//#region packages/ecma262-abstract/ToObject.js
/**
* https://tc39.es/ecma262/#sec-toobject
*/
function ToObject(arg) {
if (arg == null) throw new TypeError("undefined/null cannot be converted to object");
return Object(arg);
}
//#endregion
//#region packages/ecma402-abstract/GetOption.js
/**
* https://tc39.es/ecma402/#sec-getoption
* @param opts
* @param prop
* @param type
* @param values
* @param fallback
*/
function GetOption(opts, prop, type, values, fallback) {
if (opts === null || typeof opts !== "object" && typeof opts !== "function") throw new TypeError("Options must be an object");
let value = opts[prop];
if (value !== void 0) {
if (type !== "boolean" && type !== "string") throw new TypeError("invalid type");
if (type === "boolean") value = Boolean(value);
if (type === "string") value = ToString(value);
if (values !== void 0 && !values.filter((val) => val == value).length) throw new RangeError(`${value} is not within ${values.join(", ")}`);
return value;
}
return fallback;
}
//#endregion
//#region packages/ecma402-abstract/SupportedLocales.js
/**
* https://tc39.es/ecma402/#sec-supportedlocales
* @param availableLocales
* @param requestedLocales
* @param options
*/
function SupportedLocales(availableLocales, requestedLocales, options) {
let matcher = "best fit";
if (options !== void 0) {
options = ToObject(options);
matcher = GetOption(options, "localeMatcher", "string", ["lookup", "best fit"], "best fit");
}
if (matcher === "best fit") return LookupSupportedLocales(Array.from(availableLocales), requestedLocales);
return LookupSupportedLocales(Array.from(availableLocales), requestedLocales);
}
//#endregion
//#region packages/ecma402-abstract/IsUnicodeLocaleIdentifierType.js
/** Tests the Unicode locale identifier `type` grammar, not locale support. */
function IsUnicodeLocaleIdentifierType(value) {
return /^[a-z0-9]{3,8}(-[a-z0-9]{3,8})*(?![\s\S])/i.test(value);
}
//#endregion
//#region packages/ecma402-abstract/CoerceOptionsToObject.js
/**
* https://tc39.es/ecma402/#sec-coerceoptionstoobject
* @param options
* @returns
*/
function CoerceOptionsToObject(options) {
if (typeof options === "undefined") return Object.create(null);
return ToObject(options);
}
//#endregion
//#region packages/ecma402-abstract/utils.js
function defineProperty(target, name, { value }) {
Object.defineProperty(target, name, {
configurable: true,
enumerable: false,
writable: true,
value
});
}
function ensureIntl() {
if (typeof Intl === "undefined") Object.defineProperty(globalThis, "Intl", {
configurable: true,
enumerable: false,
writable: true,
value: {}
});
return Intl;
}
function invariant(condition, message, Err = Error) {
if (!condition) throw new Err(message);
}
const createMemoizedNumberFormat = memoize((...args) => new Intl.NumberFormat(...args), { strategy: strategies.variadic });
const createMemoizedPluralRules = memoize((...args) => new Intl.PluralRules(...args), { strategy: strategies.variadic });
memoize((...args) => new Intl.ListFormat(...args), { strategy: strategies.variadic });
//#endregion
//#region packages/ecma402-abstract/RelativeTimeFormat/InitializeRelativeTimeFormat.js
function InitializeRelativeTimeFormat(rtf, locales, options, { getInternalSlots, availableLocales, relevantExtensionKeys, localeData, getDefaultLocale }) {
const internalSlots = getInternalSlots(rtf);
internalSlots.initializedRelativeTimeFormat = true;
const requestedLocales = CanonicalizeLocaleList$1(locales);
const opt = Object.create(null);
const opts = CoerceOptionsToObject(options);
opt.localeMatcher = GetOption(opts, "localeMatcher", "string", ["best fit", "lookup"], "best fit");
const numberingSystem = GetOption(opts, "numberingSystem", "string", void 0, void 0);
if (numberingSystem !== void 0) {
if (!IsUnicodeLocaleIdentifierType(numberingSystem)) throw new RangeError(`Invalid numbering system ${numberingSystem}`);
}
opt.nu = numberingSystem;
const r = ResolveLocale(availableLocales, requestedLocales, opt, relevantExtensionKeys, localeData, getDefaultLocale);
const { locale, nu } = r;
internalSlots.locale = locale;
internalSlots.style = GetOption(opts, "style", "string", [
"long",
"narrow",
"short"
], "long");
internalSlots.numeric = GetOption(opts, "numeric", "string", ["always", "auto"], "always");
const fields = localeData[r.dataLocale];
invariant(!!fields, `Missing locale data for ${r.dataLocale}`);
internalSlots.fields = fields;
const nfOptions = Object.create(null);
nfOptions.numberingSystem = nu;
internalSlots.numberFormat = createMemoizedNumberFormat(locale, nfOptions);
internalSlots.pluralRules = createMemoizedPluralRules(locale);
internalSlots.numberingSystem = nu;
return rtf;
}
//#endregion
//#region packages/ecma262-abstract/SameValue.js
/**
* https://www.ecma-international.org/ecma-262/11.0/index.html#sec-samevalue
*/
function SameValue(x, y) {
if (Object.is) return Object.is(x, y);
if (x === y) return x !== 0 || 1 / x === 1 / y;
return x !== x && y !== y;
}
//#endregion
//#region packages/ecma262-abstract/Type.js
/**
* https://www.ecma-international.org/ecma-262/11.0/index.html#sec-type
*/
function Type(x) {
if (x === null) return "Null";
if (typeof x === "undefined") return "Undefined";
if (typeof x === "function" || typeof x === "object") return "Object";
if (typeof x === "number") return "Number";
if (typeof x === "boolean") return "Boolean";
if (typeof x === "string") return "String";
if (typeof x === "symbol") return "Symbol";
if (typeof x === "bigint") return "BigInt";
}
//#endregion
//#region packages/ecma402-abstract/RelativeTimeFormat/SingularRelativeTimeUnit.js
/**
* https://tc39.es/proposal-intl-relative-time/#sec-singularrelativetimeunit
* @param unit
*/
function SingularRelativeTimeUnit(unit) {
invariant(Type(unit) === "String", "unit must be a string");
if (unit === "seconds") return "second";
if (unit === "minutes") return "minute";
if (unit === "hours") return "hour";
if (unit === "days") return "day";
if (unit === "weeks") return "week";
if (unit === "months") return "month";
if (unit === "quarters") return "quarter";
if (unit === "years") return "year";
if (unit !== "second" && unit !== "minute" && unit !== "hour" && unit !== "day" && unit !== "week" && unit !== "month" && unit !== "quarter" && unit !== "year") throw new RangeError("invalid unit");
return unit;
}
//#endregion
//#region packages/ecma402-abstract/PartitionPattern.js
/**
* Partition a pattern into a list of literals and placeholders
* https://tc39.es/ecma402/#sec-partitionpattern
* @param pattern
*/
function PartitionPattern(pattern) {
const result = [];
let beginIndex = pattern.indexOf("{");
let endIndex = 0;
let nextIndex = 0;
const length = pattern.length;
while (beginIndex < pattern.length && beginIndex > -1) {
endIndex = pattern.indexOf("}", beginIndex);
invariant(endIndex > beginIndex, `Invalid pattern ${pattern}`);
if (beginIndex > nextIndex) result.push({
type: "literal",
value: pattern.substring(nextIndex, beginIndex)
});
result.push({
type: pattern.substring(beginIndex + 1, endIndex),
value: void 0
});
nextIndex = endIndex + 1;
beginIndex = pattern.indexOf("{", nextIndex);
}
if (nextIndex < length) result.push({
type: "literal",
value: pattern.substring(nextIndex, length)
});
return result;
}
//#endregion
//#region packages/ecma402-abstract/RelativeTimeFormat/MakePartsList.js
function MakePartsList(pattern, unit, parts) {
const patternParts = PartitionPattern(pattern);
const result = [];
for (const patternPart of patternParts) if (patternPart.type === "literal") result.push({
type: "literal",
value: patternPart.value
});
else {
invariant(patternPart.type === "0", `Malformed pattern ${pattern}`);
for (const part of parts) result.push({
type: part.type,
value: part.value,
unit
});
}
return result;
}
//#endregion
//#region packages/ecma402-abstract/RelativeTimeFormat/PartitionRelativeTimePattern.js
function PartitionRelativeTimePattern(rtf, value, unit, { getInternalSlots }) {
invariant(Type(value) === "Number", `value must be number, instead got ${typeof value}`, TypeError);
invariant(Type(unit) === "String", `unit must be number, instead got ${typeof value}`, TypeError);
if (isNaN(value) || !isFinite(value)) throw new RangeError(`Invalid value ${value}`);
const resolvedUnit = SingularRelativeTimeUnit(unit);
const { fields, style, numeric, pluralRules, numberFormat } = getInternalSlots(rtf);
let entry = resolvedUnit;
if (style === "short") entry = `${resolvedUnit}-short`;
else if (style === "narrow") entry = `${resolvedUnit}-narrow`;
if (!(entry in fields)) entry = resolvedUnit;
const patterns = fields[entry];
if (numeric === "auto") {
if (ToString(value) in patterns) return [{
type: "literal",
value: patterns[ToString(value)]
}];
}
let tl = "future";
if (SameValue(value, -0) || value < 0) tl = "past";
const po = patterns[tl];
const fv = typeof numberFormat.formatToParts === "function" ? numberFormat.formatToParts(Math.abs(value)) : [{
type: "literal",
value: numberFormat.format(Math.abs(value)),
unit
}];
const pattern = po[pluralRules.select(value)];
return MakePartsList(pattern, resolvedUnit, fv);
}
//#endregion
//#region packages/intl-relativetimeformat/get_internal_slots.ts
const internalSlotMap = /* @__PURE__ */ new WeakMap();
function getInternalSlots(x) {
let internalSlots = internalSlotMap.get(x);
if (!internalSlots) {
internalSlots = Object.create(null);
internalSlotMap.set(x, internalSlots);
}
return internalSlots;
}
//#endregion
//#region packages/intl-relativetimeformat/index.ts
var RelativeTimeFormat = class RelativeTimeFormat {
constructor(locales, options) {
if (!(this && this instanceof RelativeTimeFormat ? this.constructor : void 0)) throw new TypeError("Intl.RelativeTimeFormat must be called with 'new'");
return InitializeRelativeTimeFormat(this, locales, options, {
getInternalSlots,
availableLocales: RelativeTimeFormat.availableLocales,
relevantExtensionKeys: RelativeTimeFormat.relevantExtensionKeys,
localeData: RelativeTimeFormat.localeData,
getDefaultLocale: RelativeTimeFormat.getDefaultLocale
});
}
format(value, unit) {
if (typeof this !== "object") throw new TypeError("format was called on a non-object");
if (!getInternalSlots(this).initializedRelativeTimeFormat) throw new TypeError("format was called on a invalid context");
return PartitionRelativeTimePattern(this, +value, ToString(unit), { getInternalSlots }).map((el) => el.value).join("");
}
formatToParts(value, unit) {
if (typeof this !== "object") throw new TypeError("formatToParts was called on a non-object");
if (!getInternalSlots(this).initializedRelativeTimeFormat) throw new TypeError("formatToParts was called on a invalid context");
return PartitionRelativeTimePattern(this, +value, ToString(unit), { getInternalSlots });
}
resolvedOptions() {
if (typeof this !== "object") throw new TypeError("resolvedOptions was called on a non-object");
const internalSlots = getInternalSlots(this);
if (!internalSlots.initializedRelativeTimeFormat) throw new TypeError("resolvedOptions was called on a invalid context");
return {
locale: internalSlots.locale,
style: internalSlots.style,
numeric: internalSlots.numeric,
numberingSystem: internalSlots.numberingSystem
};
}
static supportedLocalesOf(locales, options) {
return SupportedLocales(RelativeTimeFormat.availableLocales, CanonicalizeLocaleList$1(locales), options);
}
static __addLocaleData(...data) {
for (const { data: d, locale } of data) {
registerLocaleData(locale, d, RelativeTimeFormat.localeData, RelativeTimeFormat.availableLocales);
if (!RelativeTimeFormat.__defaultLocale) RelativeTimeFormat.__defaultLocale = locale;
}
}
static {
this.localeData = {};
}
static {
this.availableLocales = /* @__PURE__ */ new Set();
}
static {
this.__defaultLocale = "";
}
static getDefaultLocale() {
return RelativeTimeFormat.__defaultLocale;
}
static {
this.relevantExtensionKeys = ["nu"];
}
static {
this.polyfilled = true;
}
};
try {
if (typeof Symbol !== "undefined") Object.defineProperty(RelativeTimeFormat.prototype, Symbol.toStringTag, {
value: "Intl.RelativeTimeFormat",
writable: false,
enumerable: false,
configurable: true
});
Object.defineProperty(RelativeTimeFormat.prototype.constructor, "length", {
value: 0,
writable: false,
enumerable: false,
configurable: true
});
Object.defineProperty(RelativeTimeFormat.supportedLocalesOf, "length", {
value: 1,
writable: false,
enumerable: false,
configurable: true
});
} catch {}
//#endregion
//#region node_modules/.aspect_rules_js/@formatjs_generated+cldr.supported-locales@0.0.0/node_modules/@formatjs_generated/cldr.supported-locales/intl-relativetimeformat.js
const supportedLocales = [
"aa",
"aa-DJ",
"aa-ER",
"ab",
"af",
"af-NA",
"agq",
"ak",
"am",
"an",
"ann",
"apc",
"ar",
"ar-AE",
"ar-BH",
"ar-DJ",
"ar-DZ",
"ar-EG",
"ar-EH",
"ar-ER",
"ar-IL",
"ar-IQ",
"ar-JO",
"ar-KM",
"ar-KW",
"ar-LB",
"ar-LY",
"ar-MA",
"ar-MR",
"ar-OM",
"ar-PS",
"ar-QA",
"ar-SA",
"ar-SD",
"ar-SO",
"ar-SS",
"ar-SY",
"ar-TD",
"ar-TN",
"ar-YE",
"arn",
"as",
"asa",
"ast",
"az",
"az-Arab",
"az-Arab-IQ",
"az-Arab-TR",
"az-Cyrl",
"az-Latn",
"ba",
"bal",
"bal-Arab",
"bal-Latn",
"bas",
"be",
"be-tarask",
"bem",
"bew",
"bez",
"bg",
"bgc",
"bgn",
"bgn-AE",
"bgn-AF",
"bgn-IR",
"bgn-OM",
"bho",
"blo",
"blt",
"bm",
"bm-Nkoo",
"bn",
"bn-IN",
"bo",
"bo-IN",
"bqi",
"br",
"brx",
"bs",
"bs-Cyrl",
"bs-Latn",
"bss",
"bua",
"byn",
"ca",
"ca-AD",
"ca-ES-valencia",
"ca-FR",
"ca-IT",
"cad",
"cch",
"ccp",
"ccp-IN",
"ce",
"ceb",
"cgg",
"cho",
"chr",
"cic",
"ckb",
"ckb-IR",
"co",
"cop",
"cs",
"csw",
"cu",
"cv",
"cy",
"da",
"da-GL",
"dav",
"de",
"de-AT",
"de-BE",
"de-CH",
"de-IT",
"de-LI",
"de-LU",
"dje",
"doi",
"dsb",
"dua",
"dv",
"dyo",
"dz",
"ebu",
"ee",
"ee-TG",
"el",
"el-CY",
"el-polyton",
"en",
"en-001",
"en-150",
"en-AE",
"en-AG",
"en-AI",
"en-AS",
"en-AT",
"en-AU",
"en-BB",
"en-BE",
"en-BI",
"en-BM",
"en-BS",
"en-BW",
"en-BZ",
"en-CA",
"en-CC",
"en-CH",
"en-CK",
"en-CM",
"en-CX",
"en-CY",
"en-CZ",
"en-DE",
"en-DG",
"en-DK",
"en-DM",
"en-Dsrt",
"en-EE",
"en-ER",
"en-ES",
"en-FI",
"en-FJ",
"en-FK",
"en-FM",
"en-FR",
"en-GB",
"en-GD",
"en-GE",
"en-GG",
"en-GH",
"en-GI",
"en-GM",
"en-GS",
"en-GU",
"en-GY",
"en-HK",
"en-HU",
"en-ID",
"en-IE",
"en-IL",
"en-IM",
"en-IN",
"en-IO",
"en-IT",
"en-JE",
"en-JM",
"en-JP",
"en-KE",
"en-KI",
"en-KN",
"en-KY",
"en-LC",
"en-LR",
"en-LS",
"en-LT",
"en-LV",
"en-MG",
"en-MH",
"en-MO",
"en-MP",
"en-MS",
"en-MT",
"en-MU",
"en-MV",
"en-MW",
"en-MY",
"en-NA",
"en-NF",
"en-NG",
"en-NL",
"en-NO",
"en-NR",
"en-NU",
"en-NZ",
"en-PG",
"en-PH",
"en-PK",
"en-PL",
"en-PN",
"en-PR",
"en-PT",
"en-PW",
"en-RO",
"en-RW",
"en-SB",
"en-SC",
"en-SD",
"en-SE",
"en-SG",
"en-SH",
"en-SI",
"en-SK",
"en-SL",
"en-SS",
"en-SX",
"en-SZ",
"en-Shaw",
"en-TC",
"en-TK",
"en-TO",
"en-TT",
"en-TV",
"en-TZ",
"en-UA",
"en-UG",
"en-UM",
"en-VC",
"en-VG",
"en-VI",
"en-VU",
"en-WS",
"en-ZA",
"en-ZM",
"en-ZW",
"eo",
"es",
"es-419",
"es-AR",
"es-BO",
"es-BR",
"es-BZ",
"es-CL",
"es-CO",
"es-CR",
"es-CU",
"es-DO",
"es-EA",
"es-EC",
"es-GQ",
"es-GT",
"es-HN",
"es-IC",
"es-MX",
"es-NI",
"es-PA",
"es-PE",
"es-PH",
"es-PR",
"es-PY",
"es-SV",
"es-US",
"es-UY",
"es-VE",
"et",
"eu",
"ewo",
"fa",
"fa-AF",
"ff",
"ff-Adlm",
"ff-Adlm-BF",
"ff-Adlm-CM",
"ff-Adlm-GH",
"ff-Adlm-GM",
"ff-Adlm-GW",
"ff-Adlm-LR",
"ff-Adlm-MR",
"ff-Adlm-NE",
"ff-Adlm-NG",
"ff-Adlm-SL",
"ff-Adlm-SN",
"ff-Latn",
"ff-Latn-BF",
"ff-Latn-CM",
"ff-Latn-GH",
"ff-Latn-GM",
"ff-Latn-GN",
"ff-Latn-GW",
"ff-Latn-LR",
"ff-Latn-MR",
"ff-Latn-NE",
"ff-Latn-NG",
"ff-Latn-SL",
"fi",
"fil",
"fo",
"fo-DK",
"fr",
"fr-BE",
"fr-BF",
"fr-BI",
"fr-BJ",
"fr-BL",
"fr-CA",
"fr-CD",
"fr-CF",
"fr-CG",
"fr-CH",
"fr-CI",
"fr-CM",
"fr-DJ",
"fr-DZ",
"fr-GA",
"fr-GF",
"fr-GN",
"fr-GP",
"fr-GQ",
"fr-HT",
"fr-KM",
"fr-LU",
"fr-MA",
"fr-MC",
"fr-MF",
"fr-MG",
"fr-ML",
"fr-MQ",
"fr-MR",
"fr-MU",
"fr-NC",
"fr-NE",
"fr-PF",
"fr-PM",
"fr-RE",
"fr-RW",
"fr-SC",
"fr-SN",
"fr-SY",
"fr-TD",
"fr-TG",
"fr-TN",
"fr-VU",
"fr-WF",
"fr-YT",
"frr",
"fur",
"fy",
"ga",
"ga-GB",
"gaa",
"gd",
"gez",
"gez-ER",
"gl",
"gn",
"gsw",
"gsw-FR",
"gsw-LI",
"gu",
"guz",
"gv",
"ha",
"ha-Arab",
"ha-Arab-SD",
"ha-GH",
"ha-NE",
"haw",
"he",
"hi",
"hi-Latn",
"hnj",
"hnj-Hmnp",
"hr",
"hr-BA",
"hsb",
"ht",
"hu",
"hy",
"ia",
"id",
"ie",
"ig",
"ii",
"io",
"is",
"it",
"it-CH",
"it-SM",
"it-VA",
"iu",
"iu-Latn",
"ja",
"jbo",
"jgo",
"jmc",
"jv",
"ka",
"kaa",
"kaa-Cyrl",
"kaa-Latn",
"kab",
"kaj",
"kam",
"kcg",
"kde",
"kea",
"kek",
"ken",
"kgp",
"khq",
"ki",
"kk",
"kk-Arab",
"kk-Cyrl",
"kk-KZ",
"kkj",
"kl",
"kln",
"km",
"kn",
"ko",
"ko-CN",
"ko-KP",
"kok",
"kok-Deva",
"kok-Latn",
"kpe",
"kpe-GN",
"ks",
"ks-Arab",
"ks-Deva",
"ksb",
"ksf",
"ksh",
"ku",
"ku-Arab",
"ku-Arab-IR",
"ku-Latn",
"ku-Latn-IQ",
"ku-Latn-SY",
"ku-TR",
"kw",
"kxv",
"kxv-Deva",
"kxv-Latn",
"kxv-Orya",
"kxv-Telu",
"ky",
"la",
"lag",
"lb",
"lg",
"lij",
"lkt",
"lld",
"lmo",
"ln",
"ln-AO",
"ln-CF",
"ln-CG",
"lo",
"lrc",
"lrc-IQ",
"lt",
"ltg",
"lu",
"luo",
"luy",
"lv",
"lzz",
"mai",
"mas",
"mas-TZ",
"mdf",
"mer",
"mfe",
"mg",
"mgh",
"mgo",
"mhn",
"mi",
"mic",
"mk",
"ml",
"mn",
"mn-Mong",
"mn-Mong-MN",
"mni",
"mni-Beng",
"mni-Mtei",
"moh",
"mr",
"ms",
"ms-Arab",
"ms-Arab-BN",
"ms-BN",
"ms-ID",
"ms-SG",
"mt",
"mua",
"mus",
"mww",
"mww-Hmnp",
"my",
"myv",
"mzn",
"naq",
"nb",
"nb-SJ",
"nd",
"nds",
"nds-NL",
"ne",
"ne-IN",
"nl",
"nl-AW",
"nl-BE",
"nl-BQ",
"nl-CW",
"nl-SR",
"nl-SX",
"nmg",
"nn",
"nnh",
"no",
"nqo",
"nr",
"nso",
"nus",
"nv",
"ny",
"nyn",
"oc",
"oc-ES",
"oka",
"oka-US",
"om",
"om-KE",
"or",
"os",
"os-RU",
"osa",
"pa",
"pa-Arab",
"pa-Guru",
"pap",
"pap-AW",
"pcm",
"pi",
"pi-Latn",
"pis",
"pl",
"pms",
"prg",
"ps",
"ps-PK",
"pt",
"pt-AO",
"pt-CH",
"pt-CV",
"pt-GQ",
"pt-GW",
"pt-LU",
"pt-MO",
"pt-MZ",
"pt-PT",
"pt-ST",
"pt-TL",
"qu",
"qu-BO",
"qu-EC",
"quc",
"raj",
"rhg",
"rhg-Rohg",
"rhg-Rohg-BD",
"rif",
"rm",
"rn",
"ro",
"ro-MD",
"rof",
"ru",
"ru-BY",
"ru-KG",
"ru-KZ",
"ru-MD",
"ru-UA",
"rw",
"rwk",
"sa",
"sah",
"saq",
"sat",
"sat-Deva",
"sat-Olck",
"sbp",
"sc",
"scn",
"sd",
"sd-Arab",
"sd-Deva",
"sdh",
"sdh-IQ",
"se",
"se-FI",
"se-SE",
"seh",
"ses",
"sg",
"sgs",
"shi",
"shi-Latn",
"shi-Tfng",
"shn",
"shn-TH",
"si",
"sid",
"sk",
"skr",
"sl",
"sma",
"sma-NO",
"smj",
"smj-NO",
"smn",
"sms",
"sn",
"so",
"so-DJ",
"so-ET",
"so-KE",
"sq",
"sq-MK",
"sq-XK",
"sr",
"sr-Cyrl",
"sr-Cyrl-BA",
"sr-Cyrl-ME",
"sr-Cyrl-XK",
"sr-Latn",
"sr-Latn-BA",
"sr-Latn-ME",
"sr-Latn-XK",
"ss",
"ss-SZ",
"ssy",
"st",
"st-LS",
"su",
"su-Latn",
"suz",
"suz-Deva",
"suz-Sunu",
"sv",
"sv-AX",
"sv-FI",
"sw",
"sw-CD",
"sw-KE",
"sw-UG",
"syr",
"syr-SY",
"szl",
"ta",
"ta-LK",
"ta-MY",
"ta-SG",
"te",
"teo",
"teo-KE",
"tg",
"th",
"ti",
"ti-ER",
"tig",
"tk",
"tn",
"tn-BW",
"to",
"tok",
"tpi",
"tr",
"tr-CY",
"trv",
"trw",
"ts",
"tt",
"twq",
"tyv",
"tzm",
"ug",
"uk",
"und",
"ur",
"ur-IN",
"uz",
"uz-Arab",
"uz-Cyrl",
"uz-Latn",
"vai",
"vai-Latn",
"vai-Vaii",
"ve",
"vec",
"vi",
"vmw",
"vo",
"vun",
"wa",
"wae",
"wal",
"wbp",
"wo",
"xh",
"xnr",
"xog",
"yav",
"yi",
"yo",
"yo-BJ",
"yrl",
"yrl-CO",
"yrl-VE",
"yue",
"yue-Hans",
"yue-Hant",
"yue-Hant-CN",
"yue-Hant-MO",
"za",
"zgh",
"zh",
"zh-Hans",
"zh-Hans-HK",
"zh-Hans-MO",
"zh-Hans-MY",
"zh-Hans-SG",
"zh-Hant",
"zh-Hant-HK",
"zh-Hant-MO",
"zh-Hant-MY",
"zh-Latn",
"zu"
];
//#endregion
//#region packages/intl-relativetimeformat/should-polyfill.ts
function supportedLocalesOf(locale) {
if (!locale) return true;
const locales = Array.isArray(locale) ? locale : [locale];
return Intl.RelativeTimeFormat.supportedLocalesOf(locales).length === locales.length;
}
function hasResolvedOptionsNumberingSystem(locale) {
try {
return "numberingSystem" in new Intl.RelativeTimeFormat(locale || "en", { numeric: "auto" }).resolvedOptions();
} catch {
return false;
}
}
function shouldPolyfill(locale = "en") {
if (typeof Intl === "undefined" || !("RelativeTimeFormat" in Intl) || !supportedLocalesOf(locale) || !hasResolvedOptionsNumberingSystem(locale)) return match([locale], supportedLocales, "en");
}
//#endregion
//#region packages/intl-relativetimeformat/polyfill.ts
const intl = ensureIntl();
if (shouldPolyfill()) {
defineProperty(intl, "RelativeTimeFormat", { value: RelativeTimeFormat });
const buf = globalThis.__FORMATJS_RELATIVETIMEFORMAT_DATA__;
if (buf) {
for (const d of buf) RelativeTimeFormat.__addLocaleData(d);
delete globalThis.__FORMATJS_RELATIVETIMEFORMAT_DATA__;
}
}
//#endregion
//# sourceMappingURL=polyfill.iife.js.map