159 lines
5.2 KiB
JavaScript
159 lines
5.2 KiB
JavaScript
// Metro module 13306 (f13307).
|
|
import { data } from "./Module13307";
|
|
import { __spreadArray } from "./Module1281";
|
|
import { regions } from "./Module13308";
|
|
let c9234_2, c9234_3, findMatchingDistanceForLSR, findMatchingDistance;
|
|
const isMatched = function isMatched(a0, a1, matchVariables) {
|
|
let r1;
|
|
const r12 = a1.split("-");
|
|
const r13 = r12[0];
|
|
const r14 = r12[1];
|
|
const r10 = r12[2];
|
|
if (r10 && r10[0] === "$") {
|
|
const r3 = r10[1] !== "!";
|
|
r1 = !((r3 ? matchVariables[r10.slice(1)] : matchVariables[r10.slice(2)]).map(function(item) {
|
|
return regions[item] || [item];
|
|
}).reduce(function(acc, item) {
|
|
return __spreadArray(__spreadArray([], acc, true), item, true);
|
|
}, []).indexOf(a0.region || "") > -1 !== r3);
|
|
} else {
|
|
const region = a0.region;
|
|
r1 = region ? r10 === "*" || r10 === a0.region : !region;
|
|
}
|
|
if (r1) {
|
|
const script = a0.script;
|
|
r1 = script ? r14 === "*" || r14 === a0.script : !script;
|
|
}
|
|
if (r1) {
|
|
const language = a0.language;
|
|
r1 = language ? r13 === "*" || r13 === a0.language : !language;
|
|
}
|
|
return r1;
|
|
};
|
|
findMatchingDistanceForLSR = function findMatchingDistanceForLSR(a0, a1, a2) {
|
|
const matches = a2.matches;
|
|
const r4 = 0 < matches.length;
|
|
let r0 = 0;
|
|
if (r4) {
|
|
do {
|
|
const r20 = matches[r0];
|
|
let r21 = isMatched(a0, r20.desired, a2.matchVariables);
|
|
const r2 = r0;
|
|
if (r21) {
|
|
r21 = isMatched(a1, r20.supported, a2.matchVariables);
|
|
}
|
|
if (!(r20.oneway || r21)) {
|
|
r21 = isMatched(a0, r20.supported, a2.matchVariables) && isMatched(a1, r20.desired, a2.matchVariables);
|
|
}
|
|
if (r21) {
|
|
const r37 = 10 * r20.distance;
|
|
return a2.paradigmLocales.indexOf([a0.language, a0.script, a0.region].filter(Boolean).join("-")) > -1 !== a2.paradigmLocales.indexOf([a1.language, a1.script, a1.region].filter(Boolean).join("-")) > -1 ? r37 - 1 : r37;
|
|
}
|
|
r0 = r2 + 1;
|
|
} while (r0 < matches.length);
|
|
}
|
|
throw new Error("No matching distance found");
|
|
};
|
|
findMatchingDistance = function findMatchingDistance(matchedDesiredLocale, a1) {
|
|
const r10 = new Intl.Locale(matchedDesiredLocale).maximize();
|
|
const r13 = new Intl.Locale(a1).maximize();
|
|
const r36 = {
|
|
language: r10.language,
|
|
script: r10.script || "",
|
|
region: r10.region || ""
|
|
};
|
|
const r40 = {
|
|
language: r13.language,
|
|
script: r13.script || "",
|
|
region: r13.region || ""
|
|
};
|
|
let r44 = c9234_2;
|
|
if (!r44) {
|
|
const r15 = data.supplemental.languageMatching["written-new"][0];
|
|
const r50 = r15 !== null ? r15 !== void 0 ? r15.paradigmLocales : void 0 : void 0;
|
|
const r18 = r50 !== null ? r50 !== void 0 ? r50._locales.split(" ") : void 0 : void 0;
|
|
const r19 = data.supplemental.languageMatching["written-new"].slice(1, 5);
|
|
const r71 = {
|
|
matches: data.supplemental.languageMatching["written-new"].slice(5).map(function(item) {
|
|
const supported = Object.keys(item)[0];
|
|
const r8 = item[supported];
|
|
return {
|
|
supported,
|
|
desired: r8._desired,
|
|
distance: +r8._distance,
|
|
oneway: r8.oneway === "true"
|
|
};
|
|
}, {}),
|
|
matchVariables: r19.reduce(function(acc, item) {
|
|
const r8 = Object.keys(item)[0];
|
|
const r9 = item[r8];
|
|
acc[r8.slice(1)] = r9._value.split("+");
|
|
return acc;
|
|
}, {}),
|
|
paradigmLocales: __spreadArray(__spreadArray([], r18, true), r18.map(function(item) {
|
|
return new Intl.Locale(item.replace(/_/g, "-")).maximize().toString();
|
|
}), true)
|
|
};
|
|
c9234_2 = r71;
|
|
r44 = r71;
|
|
}
|
|
const r2 = r36.language !== r40.language ? 0 + findMatchingDistanceForLSR({
|
|
language: r10.language,
|
|
script: "",
|
|
region: ""
|
|
}, {
|
|
language: r13.language,
|
|
script: "",
|
|
region: ""
|
|
}, r44) : 0;
|
|
const r3 = r36.script !== r40.script ? r2 + findMatchingDistanceForLSR({
|
|
language: r10.language,
|
|
script: r36.script,
|
|
region: ""
|
|
}, {
|
|
language: r13.language,
|
|
script: r40.script,
|
|
region: ""
|
|
}, r44) : r2;
|
|
return r36.region !== r40.region ? r3 + findMatchingDistanceForLSR(r36, r40, r44) : r3;
|
|
};
|
|
export function invariant(a0, a1, a2) {
|
|
const r3 = a2 === void 0 ? Error : a2;
|
|
if (a0) {
|
|
return void 0;
|
|
}
|
|
throw new r3(a1);
|
|
}
|
|
export { findMatchingDistance };
|
|
export function findBestMatch(a0, c20446_0, a2) {
|
|
const r4 = a2 === void 0 ? c9234_3 : a2;
|
|
let c20446_1 = Infinity;
|
|
const r10 = {
|
|
matchedDesiredLocale: "",
|
|
distances: {}
|
|
};
|
|
let c20446_2 = r10;
|
|
a0.forEach(function(item, c27441_1) {
|
|
const matchedDesiredLocale = item;
|
|
if (!c20446_2.distances[item]) {
|
|
c20446_2.distances[item] = {};
|
|
}
|
|
c20446_0.forEach(function(item) {
|
|
const r14 = findMatchingDistance(matchedDesiredLocale, item) + 0 + 40 * c27441_1;
|
|
c20446_2.distances[matchedDesiredLocale][item] = r14;
|
|
if (r14 < c20446_1) {
|
|
c20446_1 = r14;
|
|
c20446_2.matchedDesiredLocale = matchedDesiredLocale;
|
|
c20446_2.matchedSupportedLocale = item;
|
|
}
|
|
});
|
|
});
|
|
if (c20446_1 >= r4) {
|
|
r10.matchedDesiredLocale = void 0;
|
|
r10.matchedSupportedLocale = void 0;
|
|
}
|
|
return r10;
|
|
}
|
|
export const UNICODE_EXTENSION_SEQUENCE_REGEX = /-u(?:-[0-9a-z]{2,8})+/gi;
|
|
c9234_3 = 838;
|