decord/source/15784_MessageFormat.js
2026-07-21 22:01:30 +00:00

218 lines
6.8 KiB
JavaScript

// Module ID: 15784
// Function ID: 120782
// Name: MessageFormat
// Dependencies: []
// Module 15784 (MessageFormat)
class MessageFormat {
constructor(arg0, arg1, arg2) {
self = this;
__parseResult = global;
if ("string" === typeof global) {
tmp2 = MessageFormat;
__parseResult = MessageFormat.__parse(global);
}
if (__parseResult) {
str = "messageFormatPattern";
if ("messageFormatPattern" === __parseResult.type) {
tmp4 = MessageFormat;
tmp5 = importDefault;
_mergeFormatsResult = self._mergeFormats(MessageFormat.formats, importDefault);
tmp7 = require;
tmp8 = dependencyMap;
num = 0;
obj = require(dependencyMap[0]);
obj = {};
obj.value = self._resolveLocale(require);
str2 = "_locale";
definePropertyResult = obj.defineProperty(self, "_locale", obj);
tmp10 = self;
tmp11 = __parseResult;
tmp12 = require;
tmp13 = _mergeFormatsResult;
require = self._compilePattern(__parseResult, require, _mergeFormatsResult, self._findPluralRuleFunction(self._locale));
dependencyMap = self;
self.format = (arg0) => self._format(closure_0, arg0);
return;
}
}
typeError = new TypeError("A message must be provided as a String or AST.");
throw typeError;
}
resolvedOptions() {
obj = { locale: this._locale };
return obj;
}
_compilePattern(arg0, arg1, arg2, arg3) {
_default = new require(dependencyMap[2]).default(require, importDefault, importAll);
return _default.compile(global);
}
_findPluralRuleFunction(arg0) {
__localeData__ = MessageFormat.__localeData__;
parentLocale = __localeData__[global.toLowerCase(global)];
if (parentLocale) {
while (!parentLocale.pluralRuleFunction) {
parentLocale = parentLocale.parentLocale;
if (parentLocale) {
str = tmp.parentLocale;
parentLocale = __localeData__[str.toLowerCase(str)];
}
}
return parentLocale.pluralRuleFunction;
}
error = new Error("Locale data added to IntlMessageFormat is missing a `pluralRuleFunction` for :" + global);
throw error;
}
_format(arg0, arg1) {
self = this;
length = global.length;
num = 0;
str = "";
str2 = "";
if (0 < length) {
while (true) {
obj = global[num];
if ("string" !== typeof obj) {
id = obj.id;
if (!require) {
break;
} else {
tmp2 = require;
tmp3 = dependencyMap;
hop = require(dependencyMap[3]).hop;
if (!hop.call(require, id)) {
break;
} else {
tmp9 = require[id];
if (obj.options) {
text = `${tmp12(obj.getOption(tmp9), require)}`;
tmp13 = id;
tmp14 = tmp9;
} else {
text = `${obj.format(tmp9)}`;
tmp10 = id;
tmp11 = tmp9;
}
}
}
} else {
text = str + obj;
}
num = num + 1;
str = text;
str2 = text;
}
tmp4 = globalThis;
_Error = Error;
str3 = "A value must be provided for: ";
prototype = Error.prototype;
tmp5 = new.target;
tmp6 = new.target;
error = new Error("A value must be provided for: " + id);
tmp8 = error;
throw error;
}
return str2;
}
_mergeFormats(arg0, arg1) {
obj = {};
for (const key10009 in arg0) {
tmp12 = key10009;
tmp13 = closure_0;
tmp14 = closure_1;
hop2 = closure_0(closure_1[3]).hop;
if (!hop2.call(arg0, key10009)) {
continue;
} else {
tmp = closure_0;
tmp2 = closure_1;
obj2 = closure_0(closure_1[0]);
objCreateResult = obj2.objCreate(arg0[key10009]);
obj[key10009] = objCreateResult;
callResult = arg1;
if (!arg1) {
} else {
tmp5 = closure_0;
tmp6 = closure_1;
hop = closure_0(closure_1[3]).hop;
callResult = hop.call(arg1, key10009);
}
tmp7 = objCreateResult;
if (!callResult) {
continue;
} else {
tmp8 = closure_0;
tmp9 = closure_1;
obj3 = closure_0(closure_1[3]);
extendResult = obj3.extend(objCreateResult, arg1[key10009]);
tmp11 = objCreateResult;
// continue
}
continue;
}
continue;
}
return obj;
}
_resolveLocale(arg0) {
items1 = global;
if ("string" === typeof global) {
items = [];
items[0] = global;
items1 = items;
}
if (!items1) {
items1 = [];
}
combined = items1.concat(MessageFormat.defaultLocale);
length = combined.length;
num = 0;
if (0 < length) {
while (true) {
str = combined[num];
str2 = str.toLowerCase();
parts = str2.split("-");
if (parts.length) {
tmp2 = tmp[parts.join(parts, "-")];
while (!tmp2) {
arr = parts.pop();
tmp4 = tmp2;
continue;
}
return tmp2.locale;
}
num = num + 1;
}
}
arr1 = combined.pop();
error = new Error("No locale data has been added to IntlMessageFormat for: " + combined.join(", ") + ", or the default locale: " + arr1);
throw error;
}
}
const _module = require(dependencyMap[0]);
_module.defineProperty(MessageFormat, "formats", { enumerable: true, value: { number: { currency: { style: "currency" }, percent: { style: "percent" } }, date: { short: { <string:3478312518>: false, <string:4217799105>: false, <string:1449286816>: false }, medium: { <string:3478312518>: true, <string:4217799105>: true, <string:1449286816>: true }, long: {}, full: {} }, time: { short: { state: false, sk: false }, medium: {}, long: {}, full: {} } } });
const _module1 = require(dependencyMap[0]);
let obj = {};
const _module2 = require(dependencyMap[0]);
obj.value = _module2.objCreate(null);
_module1.defineProperty(MessageFormat, "__localeData__", obj);
const _module3 = require(dependencyMap[0]);
obj = {
value(locale) {
if (locale) {
if (locale.locale) {
MessageFormat.__localeData__[locale.locale.toLowerCase()] = locale;
}
}
const error = new Error("Locale data provided to IntlMessageFormat is missing a `locale` property");
throw error;
}
};
_module3.defineProperty(MessageFormat, "__addLocaleData", obj);
const _module4 = require(dependencyMap[0]);
_module4.defineProperty(MessageFormat, "__parse", { value: require(dependencyMap[1]).default.parse });
const _module5 = require(dependencyMap[0]);
const obj2 = { __constants: null, OS: null, value: undefined };
_module5.defineProperty(MessageFormat, "defaultLocale", obj2);
export default MessageFormat;