378 lines
13 KiB
JavaScript
378 lines
13 KiB
JavaScript
// Metro module 13292 (f13293).
|
|
import { __importDefault } from "./Module1281";
|
|
import * as _digitsToString from "./digitsToString";
|
|
import { S_UNICODE_REGEX } from "./Module13293";
|
|
import { GetUnsignedRoundingMode } from "./Module13288";
|
|
import { digitMapping } from "./Module13294";
|
|
import { ToRawFixed } from "./Module13290";
|
|
let c9223_2, c9223_3, c9223_4, c9223_5;
|
|
export default function formatToParts(a0, a1, a2, a3) {
|
|
let r86, r91, r141, r336, r500, value7;
|
|
const { sign: sign2, exponent, magnitude } = a0;
|
|
const { notation, style, numberingSystem } = a3;
|
|
const r25 = a1.numbers.nu[0];
|
|
const r70 = notation === "compact" && magnitude;
|
|
let r44 = null;
|
|
if (r70) {
|
|
L31: {
|
|
const { compactDisplay, currencyDisplay } = a3;
|
|
const { roundedNumber, sign } = a0;
|
|
const r75 = String(Math.pow(10, a0.magnitude));
|
|
const r78 = a1.numbers.nu[0];
|
|
if (style === "currency" && currencyDisplay !== "name") {
|
|
const currency = a1.numbers.currency;
|
|
const short = (currency[numberingSystem] || currency[r78]).short;
|
|
const r96 = short !== null ? short !== void 0 ? short[r75] : void 0 : void 0;
|
|
r86 = null;
|
|
if (!r96) {
|
|
break L31;
|
|
}
|
|
r91 = r96[a2.select(roundedNumber.toNumber())] || r96.other;
|
|
} else {
|
|
const decimal = a1.numbers.decimal;
|
|
const r85 = (decimal[numberingSystem] || decimal[r78])[compactDisplay][r75];
|
|
r86 = null;
|
|
if (!r85) {
|
|
break L31;
|
|
}
|
|
r91 = r85[a2.select(roundedNumber.toNumber())] || r85.other;
|
|
}
|
|
r86 = null;
|
|
if (r91 !== "0") {
|
|
const r113 = (r91.indexOf(";") < 0 ? "".concat(r91, ";-").concat(r91) : r91).split(";");
|
|
const r114 = r113[0];
|
|
const r115 = r113[1];
|
|
r86 = (sign === 0 ? r114 : sign !== -1 ? r115.indexOf("-") >= 0 ? r115.replace(/-/g, "+") : "+".concat(r114) : r115).replace(/([^\s;\-\+\d¤]+)/g, "{c:$1}").replace(/0+/, "0");
|
|
}
|
|
}
|
|
r44 = r86;
|
|
}
|
|
const r15 = style === "currency";
|
|
let value = void 0;
|
|
if (r15) {
|
|
const currencyDisplay2 = a3.currencyDisplay;
|
|
value = void 0;
|
|
if (currencyDisplay2 !== "name") {
|
|
const r137 = a1.currencies[a3.currency];
|
|
if (r137) {
|
|
const currencyDisplay3 = a3.currencyDisplay;
|
|
value = currencyDisplay3 === "code" ? a3.currency : currencyDisplay3 === "symbol" ? r137.symbol : r137.narrow;
|
|
} else {
|
|
value = a3.currency;
|
|
}
|
|
}
|
|
}
|
|
L83: {
|
|
r141 = r44;
|
|
if (!r141) {
|
|
L71: {
|
|
if (style !== "decimal" && style !== "unit") {
|
|
if (r15 && a3.currencyDisplay === "name") {
|
|
break L71;
|
|
}
|
|
const numbers = a1.numbers;
|
|
if (r15) {
|
|
const r181 = (numbers.currency[numberingSystem] || a1.numbers.currency[r25])[a3.currencySign];
|
|
const r193 = (r181.indexOf(";") < 0 ? "".concat(r181, ";-").concat(r181) : r181).split(";");
|
|
const r194 = r193[0];
|
|
const r195 = r193[1];
|
|
r141 = sign2 === 0 ? r194 : sign2 !== -1 ? r195.indexOf("-") >= 0 ? r195.replace(/-/g, "+") : "+".concat(r194) : r195;
|
|
break L83;
|
|
}
|
|
const r148 = numbers.percent[numberingSystem] || a1.numbers.percent[r25];
|
|
const r153 = r148.indexOf(";");
|
|
const r163 = (r153 < 0 ? "".concat(r148, ";-").concat(r148) : r148).split(";");
|
|
const r164 = r163[0];
|
|
const r35 = r163[1];
|
|
r141 = sign2 === 0 ? r164 : sign2 !== -1 ? r35.indexOf("-") >= 0 ? r35.replace(/-/g, "+") : "+".concat(r164) : r35;
|
|
break L83;
|
|
}
|
|
}
|
|
const standard = (a1.numbers.decimal[numberingSystem] || a1.numbers.decimal[r25]).standard;
|
|
const r224 = (standard.indexOf(";") < 0 ? "".concat(standard, ";-").concat(standard) : standard).split(";");
|
|
const r225 = r224[0];
|
|
const r226 = r224[1];
|
|
r141 = sign2 === 0 ? r225 : sign2 !== -1 ? r226.indexOf("-") >= 0 ? r226.replace(/-/g, "+") : "+".concat(r225) : r226;
|
|
}
|
|
}
|
|
const r42 = c9223_5.exec(r141)[0];
|
|
const r248 = r141.replace(c9223_5, "{0}").replace(/'(.)'/g, "$1");
|
|
let r249 = r248;
|
|
if (r15) {
|
|
const currencyDisplay4 = a3.currencyDisplay;
|
|
r249 = r248;
|
|
if (currencyDisplay4 !== "name") {
|
|
const r254 = a1.numbers.currency[numberingSystem] || a1.numbers.currency[r25];
|
|
const afterInsertBetween = r254.currencySpacing.afterInsertBetween;
|
|
const r262 = afterInsertBetween && !c9223_4.test(value) ? r248.replace("¤{0}", "¤".concat(afterInsertBetween, "{0}")) : r248;
|
|
const beforeInsertBetween = r254.currencySpacing.beforeInsertBetween;
|
|
r249 = beforeInsertBetween && !c9223_3.test(value) ? r262.replace("{0}¤", "{0}".concat(beforeInsertBetween, "¤")) : r262;
|
|
}
|
|
}
|
|
const r41 = r249.split(/({c:[^}]+}|\{0\}|[¤%\-\+])/g);
|
|
const r40 = a1.numbers.symbols[numberingSystem] || a1.numbers.symbols[r25];
|
|
const r285 = [];
|
|
const r9 = 0 < r41.length;
|
|
const r12 = notation !== "compact";
|
|
const r293 = sign2 === -1;
|
|
let r298 = 0;
|
|
if (r9) {
|
|
do {
|
|
const value2 = r41[r298];
|
|
const r7 = r298;
|
|
if (value2) {
|
|
if (value2 === "{0}") {
|
|
const push = r285.push;
|
|
let r54 = !r44;
|
|
if (!r44) {
|
|
const useGrouping = a3.useGrouping;
|
|
r54 = useGrouping === null || useGrouping === void 0 || useGrouping;
|
|
}
|
|
let c20442_0;
|
|
L165: {
|
|
const roundingIncrement = a3.roundingIncrement;
|
|
const r52 = (0, GetUnsignedRoundingMode)(a3.roundingMode, r293);
|
|
c20442_0 = void 0;
|
|
const { formattedString, roundedNumber: roundedNumber2 } = a0;
|
|
if (roundedNumber2.isNaN()) {
|
|
r336 = [{
|
|
type: "nan",
|
|
value: formattedString
|
|
}];
|
|
} else if (roundedNumber2.isFinite()) {
|
|
const r340 = digitMapping[numberingSystem];
|
|
c20442_0 = r340;
|
|
const r341 = r340 ? formattedString.replace(/\d/g, function(a0) {
|
|
return c20442_0[+a0] || a0;
|
|
}) : formattedString;
|
|
const r346 = r341.indexOf(".");
|
|
const r347 = r346 > 0;
|
|
let value4 = void 0;
|
|
let value3 = r341;
|
|
if (r347) {
|
|
value3 = r341.slice(0, r346);
|
|
value4 = r341.slice(r346 + 1);
|
|
}
|
|
const r352 = r54 !== "always" ? r54 === "min2" ? roundedNumber2.greaterThanOrEqualTo(10000) : r54 === "auto" || r54 ? r12 || roundedNumber2.greaterThanOrEqualTo(10000) : false : true;
|
|
const r357 = [];
|
|
if (r352) {
|
|
const value5 = r15 && r40.currencyGroup != null ? r40.currencyGroup : r40.group;
|
|
const r367 = r42.split(".")[0].split(",");
|
|
const r370 = r367.length > 1 ? r367[r367.length - 1].length : 3;
|
|
const r60 = r367.length > 2 ? r367[r367.length - 2].length : 3;
|
|
const r379 = [];
|
|
const r381 = value3.length - r370;
|
|
if (r381 > 0) {
|
|
r379.push(value3.slice(r381, r381 + r370));
|
|
let r387 = r381 - r60;
|
|
let r388 = r387;
|
|
while (r388 > 0) {
|
|
r379.push(value3.slice(r387, r387 + r60));
|
|
r387 = r387 - r60;
|
|
r388 = r387;
|
|
}
|
|
r379.push(value3.slice(0, r388 + r60));
|
|
} else {
|
|
r379.push(value3);
|
|
}
|
|
while (r379.length > 0) {
|
|
r357.push({
|
|
type: "integer",
|
|
value: r379.pop()
|
|
});
|
|
if (r379.length > 0) {
|
|
r357.push({
|
|
type: "group",
|
|
value: value5
|
|
});
|
|
}
|
|
}
|
|
} else {
|
|
r357.push({
|
|
type: "integer",
|
|
value: value3
|
|
});
|
|
}
|
|
if (value4 !== void 0) {
|
|
r357.push({
|
|
type: "decimal",
|
|
value: r15 && r40.currencyDecimal != null ? r40.currencyDecimal : r40.decimal
|
|
}, {
|
|
type: "fraction",
|
|
value: value4
|
|
});
|
|
}
|
|
if (notation !== "scientific") {
|
|
r336 = r357;
|
|
if (notation !== "engineering") {
|
|
break L165;
|
|
}
|
|
}
|
|
const isFinite2 = roundedNumber2.isFinite();
|
|
r336 = r357;
|
|
if (isFinite2) {
|
|
r357.push({
|
|
type: "exponentSeparator",
|
|
value: r40.exponential
|
|
});
|
|
let r421 = exponent;
|
|
if (r421 < 0) {
|
|
r357.push({
|
|
type: "exponentMinusSign",
|
|
value: r40.minusSign
|
|
});
|
|
r421 = -exponent;
|
|
}
|
|
r357.push({
|
|
type: "exponentInteger",
|
|
value: (0, ToRawFixed)(new c9223_2.default(r421), 0, 0, roundingIncrement, r52).formattedString
|
|
});
|
|
r336 = r357;
|
|
}
|
|
} else {
|
|
r336 = [{
|
|
type: "infinity",
|
|
value: formattedString
|
|
}];
|
|
}
|
|
}
|
|
push.apply(r285, r336);
|
|
} else if (value2 === "-") {
|
|
r285.push({
|
|
type: "minusSign",
|
|
value: r40.minusSign
|
|
});
|
|
} else if (value2 === "+") {
|
|
r285.push({
|
|
type: "plusSign",
|
|
value: r40.plusSign
|
|
});
|
|
} else if (value2 === "%") {
|
|
r285.push({
|
|
type: "percentSign",
|
|
value: r40.percentSign
|
|
});
|
|
} else if (value2 === "¤") {
|
|
r285.push({
|
|
type: "currency",
|
|
value
|
|
});
|
|
} else if (/^\{c:/.test(value2)) {
|
|
r285.push({
|
|
type: "compact",
|
|
value: value2.substring(3, value2.length - 1)
|
|
});
|
|
} else {
|
|
r285.push({
|
|
type: "literal",
|
|
value: value2
|
|
});
|
|
}
|
|
}
|
|
r298 = r7 + 1;
|
|
} while (r298 < r41.length);
|
|
}
|
|
if (style === "currency") {
|
|
if (a3.currencyDisplay === "name") {
|
|
const unitPattern = (a1.numbers.currency[numberingSystem] || a1.numbers.currency[r25]).unitPattern;
|
|
const r558 = a1.currencies[a3.currency];
|
|
if (r558) {
|
|
const r569 = a0.roundedNumber.times(c9223_2.default.pow(10, exponent)).toNumber();
|
|
const displayName = r558.displayName;
|
|
value7 = displayName[a2.select(r569)] || displayName.other;
|
|
} else {
|
|
value7 = a3.currency;
|
|
}
|
|
const r574 = [];
|
|
const r577 = unitPattern.split(/(\{[01]\})/g);
|
|
const r579 = 0 < r577.length;
|
|
let r581 = 0;
|
|
if (r579) {
|
|
do {
|
|
const value8 = r577[r581];
|
|
const r583 = r581;
|
|
if (value8 === "{0}") {
|
|
r574.push.apply(r574, r285);
|
|
} else if (value8 === "{1}") {
|
|
r574.push({
|
|
type: "currency",
|
|
value: value7
|
|
});
|
|
} else if (value8) {
|
|
r574.push({
|
|
type: "literal",
|
|
value: value8
|
|
});
|
|
}
|
|
r581 = r583 + 1;
|
|
} while (r581 < r577.length);
|
|
}
|
|
return r574;
|
|
}
|
|
return r285;
|
|
}
|
|
if (style === "unit") {
|
|
const { unit, unitDisplay } = a3;
|
|
if (a1.units.simple[unit]) {
|
|
const r511 = a0.roundedNumber.times(c9223_2.default.pow(10, exponent)).toNumber();
|
|
const r515 = a1.units.simple[unit][unitDisplay];
|
|
r500 = r515[a2.select(r511)] || r515.other;
|
|
} else {
|
|
const r454 = unit.split("-per-");
|
|
const r455 = r454[0];
|
|
const r456 = r454[1];
|
|
a1.units.simple[r455];
|
|
const r469 = a0.roundedNumber.times(c9223_2.default.pow(10, exponent)).toNumber();
|
|
const r473 = a1.units.simple[r455][unitDisplay];
|
|
const r476 = r473[a2.select(r469)] || r473.other;
|
|
const r481 = a1.units.simple[r456].perUnit[unitDisplay];
|
|
if (r481) {
|
|
r500 = r481.replace("{0}", r476);
|
|
} else {
|
|
const r485 = a1.units.compound.per[unitDisplay];
|
|
const r489 = a1.units.simple[r456][unitDisplay];
|
|
const r492 = r489[a2.select(1)] || r489.other;
|
|
r500 = r485.replace("{0}", r476).replace("{1}", r492.replace("{0}", ""));
|
|
}
|
|
}
|
|
const r519 = [];
|
|
const r522 = r500.split(/(\s*\{0\}\s*)/);
|
|
const r524 = 0 < r522.length;
|
|
let r525 = 0;
|
|
if (r524) {
|
|
do {
|
|
const value6 = r522[r525];
|
|
const r529 = /^(\s*)\{0\}(\s*)$/.exec(value6);
|
|
const r530 = r525;
|
|
if (r529) {
|
|
if (r529[1]) {
|
|
r519.push({
|
|
type: "literal",
|
|
value: r529[1]
|
|
});
|
|
}
|
|
r519.push.apply(r519, r285);
|
|
if (r529[2]) {
|
|
r519.push({
|
|
type: "literal",
|
|
value: r529[2]
|
|
});
|
|
}
|
|
} else if (value6) {
|
|
r519.push({
|
|
type: "unit",
|
|
value: value6
|
|
});
|
|
}
|
|
r525 = r530 + 1;
|
|
} while (r525 < r522.length);
|
|
}
|
|
return r519;
|
|
}
|
|
return r285;
|
|
};
|
|
c9223_2 = __importDefault(_digitsToString);
|
|
c9223_3 = new RegExp("^".concat(S_UNICODE_REGEX.source));
|
|
c9223_4 = new RegExp("".concat(S_UNICODE_REGEX.source, "$"));
|
|
c9223_5 = /[#0](?:[\.,][#0]+)*/g;
|