UNPKG

@formatjs/intl-pluralrules

Version:

Polyfill for Intl.PluralRules

1,476 lines (1,475 loc) • 49.3 kB
import { FilterLocales, ResolveLocale } from "@formatjs/intl-localematcher"; import { Decimal } from "@formatjs/bigdecimal"; // packages/ecma262-abstract/HasOwnProperty.js const hasOwn = Function.prototype.call.bind(Object.prototype.hasOwnProperty); function HasOwnProperty(o, prop) { return hasOwn(o, prop); } // packages/ecma262-abstract/intrinsics.js const floor = Math.floor; const numberFrom = Number; const bigIntFrom = BigInt; const objectFrom = Object; const objectCreate = Object.create; function createFromConstructor(newTarget, defaultPrototype) { const prototype = newTarget.prototype; return objectCreate(objectFrom(prototype) === prototype ? prototype : defaultPrototype); } const mathMin = Math.min; const mathMax = Math.max; const numberIsInteger = Number.isInteger; const numberIsFinite = Number.isFinite; Number.isSafeInteger; const ErrorConstructor$1 = Error; const TypeErrorConstructor$2 = TypeError; const RangeErrorConstructor = RangeError; const arrayApply = Reflect.apply; Array.prototype.every; const some = Array.prototype.some; function arraySome(values, predicate) { return arrayApply(some, values, [predicate]); } const includes$1 = Array.prototype.includes; Array.prototype.indexOf; function arrayIncludes(values, search) { return arrayApply(includes$1, values, [search]); } const defineProperty$1 = Object.defineProperty; function setDataProperty(target, key, value) { defineProperty$1(target, key, { __proto__: null, value, writable: true, enumerable: true, configurable: true }); } // packages/ecma402-abstract/CanonicalizeLocaleList.js let canonicalIntl = globalThis.Intl; const canonicalDescriptor = Object.getOwnPropertyDescriptor; const canonicalApply = Reflect.apply; const providerKey = Symbol.for("@formatjs/intlCanonicalizeLocaleList"); function ownCanonicalProvider() { const descriptor = canonicalIntl && canonicalDescriptor(canonicalIntl, "getCanonicalLocales"); return (descriptor && canonicalDescriptor(descriptor, "value"))?.value; } let canonicalProvider = ownCanonicalProvider(); function registeredCanonicalProvider() { try { const descriptor = canonicalIntl && canonicalDescriptor(canonicalIntl, providerKey); return descriptor && canonicalDescriptor(descriptor, "value")?.value; } catch {} } function CanonicalizeLocaleList(locales) { if (canonicalIntl === void 0) canonicalIntl = globalThis.Intl; const registered = registeredCanonicalProvider(); if (typeof registered === "function") return canonicalApply(registered, canonicalIntl, [locales]); if (typeof canonicalProvider !== "function") canonicalProvider = ownCanonicalProvider(); return canonicalApply(canonicalProvider, canonicalIntl, [locales]); } // packages/ecma402-abstract/Locale/splitUnicodeExtension.js const apply$8 = Reflect.apply; const split$1 = String.prototype.split; const hyphen = { __proto__: null, toString: () => "-" }; function splitLocaleSubtags(value) { return apply$8(split$1, value, [hyphen]); } function splitUnicodeExtension(locale) { const subtags = splitLocaleSubtags(locale); 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++; let base = subtags[0]; for (let j = 1; j < i; j++) base += "-" + subtags[j]; for (let j = end; j < subtags.length; j++) base += "-" + subtags[j]; let extension = ""; for (let j = i; j < end; j++) extension += "-" + subtags[j]; return { locale: base, extension }; } return { locale, extension: void 0 }; } // 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 = { "ady": ["ady-RU"], "af": ["af-ZA"], "agq": ["agq-CM"], "ak": ["ak-GH"], "am": ["am-ET"], "ar": ["ar-001"], "as": ["as-IN"], "asa": ["asa-TZ"], "ast": ["ast-ES"], "az-Cyrl": ["az-Cyrl-AZ"], "az-Latn": ["az-Latn-AZ"], "ba": ["ba-RU"], "bal-Latn": ["bal-Latn-PK"], "bas": ["bas-CM"], "be": ["be-BY"], "bem": ["bem-ZM"], "bez": ["bez-TZ"], "bg": ["bg-BG"], "bgc": ["bgc-IN"], "bho": ["bho-IN"], "blo": ["blo-BJ"], "bm": ["bm-ML"], "bn": ["bn-BD"], "bo": ["bo-CN"], "br": ["br-FR"], "brx": ["brx-IN"], "bs-Cyrl": ["bs-Cyrl-BA"], "bs-Latn": ["bs-Latn-BA"], "bua": ["bua-RU"], "ca": ["ca-ES"], "ccp": ["ccp-BD"], "ce": ["ce-RU"], "ceb": ["ceb-PH"], "cgg": ["cgg-UG"], "chr": ["chr-US"], "ckb": ["ckb-IQ"], "cop": ["cop-EG"], "cs": ["cs-CZ"], "csw": ["csw-CA"], "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"], "dyo": ["dyo-SN"], "dz": ["dz-BT"], "ebu": ["ebu-KE"], "ee": ["ee-GH"], "el": ["el-GR"], "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"], "fur": ["fur-IT"], "fy": ["fy-NL"], "ga": ["ga-IE"], "gaa": ["gaa-GH"], "gd": ["gd-GB"], "gl": ["gl-ES"], "gsw": ["gsw-CH"], "gu": ["gu-IN"], "guz": ["guz-KE"], "gv": ["gv-IM"], "ha": ["ha-NG"], "haw": ["haw-US"], "he": ["he-IL"], "hi": ["hi-IN"], "hi-Latn": ["hi-Latn-IN"], "hr": ["hr-HR"], "hsb": ["hsb-DE"], "hu": ["hu-HU"], "hy": ["hy-AM"], "ia": ["ia-001"], "id": ["id-ID"], "ie": ["ie-EE"], "ig": ["ig-NG"], "ii": ["ii-CN"], "is": ["is-IS"], "it": ["it-IT"], "ja": ["ja-JP"], "jgo": ["jgo-CM"], "jmc": ["jmc-TZ"], "jv": ["jv-ID"], "ka": ["ka-GE"], "kab": ["kab-DZ"], "kam": ["kam-KE"], "kbd": ["kbd-RU"], "kde": ["kde-TZ"], "kea": ["kea-CV"], "kek": ["kek-GT"], "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"], "ks-Arab": ["ks-Arab-IN"], "ks-Deva": ["ks-Deva-IN"], "ksb": ["ksb-TZ"], "ksf": ["ksf-CM"], "ksh": ["ksh-DE"], "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"], "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"], "lu": ["lu-CD"], "luo": ["luo-KE"], "luy": ["luy-KE"], "lv": ["lv-LV"], "mai": ["mai-IN"], "mas": ["mas-KE"], "mer": ["mer-KE"], "mfe": ["mfe-MU"], "mg": ["mg-MG"], "mgh": ["mgh-MZ"], "mgo": ["mgo-CM"], "mi": ["mi-NZ"], "mk": ["mk-MK"], "ml": ["ml-IN"], "mn": ["mn-MN"], "mni-Beng": ["mni-Beng-IN"], "mr": ["mr-IN"], "ms": ["ms-MY"], "mt": ["mt-MT"], "mua": ["mua-CM"], "my": ["my-MM"], "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"], "nso": ["nso-ZA"], "nus": ["nus-SS"], "nyn": ["nyn-UG"], "oc": ["oc-FR"], "om": ["om-ET"], "or": ["or-IN"], "os": ["os-GE"], "pa-Arab": ["pa-Arab-PK"], "pa-Guru": ["pa-Guru-IN"], "pcm": ["pcm-NG"], "pl": ["pl-PL"], "pms": ["pms-IT"], "prg": ["prg-PL"], "ps": ["ps-AF"], "pt": ["pt-BR"], "qu": ["qu-PE"], "quc": ["quc-GT"], "raj": ["raj-IN"], "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-Olck": ["sat-Olck-IN"], "sbp": ["sbp-TZ"], "sc": ["sc-IT"], "scn": ["scn-IT"], "sd-Arab": ["sd-Arab-PK"], "sd-Deva": ["sd-Deva-IN"], "se": ["se-NO"], "seh": ["seh-MZ"], "ses": ["ses-ML"], "sg": ["sg-CF"], "shi-Latn": ["shi-Latn-MA"], "shi-Tfng": ["shi-Tfng-MA"], "shn": ["shn-MM"], "si": ["si-LK"], "sk": ["sk-SK"], "sl": ["sl-SI"], "smn": ["smn-FI"], "sn": ["sn-ZW"], "so": ["so-SO"], "sq": ["sq-AL"], "sr-Cyrl": ["sr-Cyrl-RS"], "sr-Latn": ["sr-Latn-RS"], "st": ["st-ZA"], "su-Latn": ["su-Latn-ID"], "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"], "tk": ["tk-TM"], "tn": ["tn-ZA"], "to": ["to-TO"], "tok": ["tok-001"], "tr": ["tr-TR"], "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"], "vec": ["vec-IT"], "vi": ["vi-VN"], "vmw": ["vmw-MZ"], "vun": ["vun-TZ"], "wae": ["wae-CH"], "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"], "zu": ["zu-ZA"] }; // packages/ecma402-abstract/registerLocaleData.js const registrations = /* @__PURE__ */ new WeakMap(); const getRegistrations = registrations.get.bind(registrations); const setRegistrations = registrations.set.bind(registrations); const LocaleMap = Map; const apply$7 = Reflect.apply; const add = Set.prototype.add; const getOwner = Map.prototype.get; const setOwner = Map.prototype.set; const forEachOwner = Map.prototype.forEach; const split = String.prototype.split; const slice$5 = String.prototype.slice; function canonicalizeLocaleDataTag(tag) { const [locale] = CanonicalizeLocaleList(tag); return splitUnicodeExtension(locale).locale; } function registerLocaleData(locale, data, localeData, availableLocales) { let owners = getRegistrations(localeData); if (!owners) { owners = new LocaleMap(); setRegistrations(localeData, owners); } if (apply$7(getOwner, owners, [locale]) === locale) apply$7(forEachOwner, owners, [(owner, tag) => { if (owner === locale) setDataProperty(localeData, tag, data); }]); apply$7(setOwner, owners, [locale, locale]); setDataProperty(localeData, locale, data); apply$7(add, availableLocales, [locale]); const aliases = HasOwnProperty(defaultContent, locale) ? defaultContent[locale] : void 0; for (let index = 0; index < (aliases?.length ?? 0); index++) { const tag = aliases[index]; if (apply$7(getOwner, owners, [tag]) !== tag) { setDataProperty(localeData, tag, data); apply$7(setOwner, owners, [tag, locale]); } apply$7(add, availableLocales, [tag]); } for (let index = -1; index < (aliases?.length ?? 0); index++) { const tag = index === -1 ? locale : aliases[index]; const owner = apply$7(getOwner, owners, [tag]) ?? tag; const selected = localeData[tag]; const addFallback = (fallback) => { if (!HasOwnProperty(localeData, fallback)) { setDataProperty(localeData, fallback, selected); apply$7(setOwner, owners, [fallback, owner]); } apply$7(add, availableLocales, [fallback]); }; const parts = apply$7(split, tag, ["-"]); const scriptEnd = parts[0].length + 5; let parent = tag; let length = 1; let end = parts[0].length; for (; length < parts.length && parts[length].length > 1; length++) end += parts[length].length + 1; if (length < parts.length) { parent = apply$7(slice$5, parent, [0, end]); addFallback(parent); } for (; length > 1; length--) { if (length > 2 && parts[1].length === 4) addFallback(parts[0] + apply$7(slice$5, parent, [scriptEnd])); parent = apply$7(slice$5, parent, [0, parent.length - parts[length - 1].length - 1]); addFallback(parent); } } } // packages/ecma262-abstract/ToObject.js /** * https://tc39.es/ecma262/#sec-toobject */ function ToObject(arg) { if (arg === void 0 || arg === null) throw new TypeErrorConstructor$2("undefined/null cannot be converted to object"); return objectFrom(arg); } // packages/ecma402-abstract/CoerceOptionsToObject.js const createObject = Object.create; /** * https://tc39.es/ecma402/#sec-coerceoptionstoobject * @param options * @returns */ function CoerceOptionsToObject(options) { if (options === void 0) return createObject(null); return ToObject(options); } // packages/ecma262-abstract/IsObject.js function IsObject(value) { return value !== null && (typeof value === "object" || typeof value === "function" || typeof value === "undefined" && value !== void 0); } // packages/ecma262-abstract/ToString.js const StringConstructor = String; const TypeErrorConstructor$1 = TypeError; /** * https://tc39.es/ecma262/#sec-tostring */ function ToString(o) { if (typeof o === "symbol") throw TypeErrorConstructor$1("Cannot convert a Symbol value to a string"); return StringConstructor(o); } // packages/ecma402-abstract/GetOption.js const optionApply = Reflect.apply; const optionJoin = Array.prototype.join; /** * https://tc39.es/ecma402/#sec-getoption * @param opts * @param prop * @param type * @param values * @param fallback */ function GetOption(opts, prop, type, values, fallback) { if (!IsObject(opts)) throw new TypeErrorConstructor$2("Options must be an object"); let value = opts[prop]; if (value !== void 0) { if (type !== "boolean" && type !== "string") throw new TypeErrorConstructor$2("invalid type"); if (type === "boolean") value = !!value; if (type === "string") value = ToString(value); if (values?.length && !arraySome(values, (val) => val === value)) throw new RangeErrorConstructor(`${value} is not within ${optionApply(optionJoin, values, [", "])}`); return value; } return fallback; } // packages/ecma402-abstract/SupportedLocales.js function SupportedLocales(availableLocales, requestedLocales, options) { const matcher = GetOption(CoerceOptionsToObject(options), "localeMatcher", "string", ["lookup", "best fit"], "best fit"); return FilterLocales(availableLocales, requestedLocales, matcher, true); } // packages/ecma262-abstract/ToPrimitive.js const functionToString = Function.prototype.toString; const apply$6 = Reflect.apply; const toPrimitiveSymbol = Symbol.toPrimitive; const TypeErrorConstructor = TypeError; const ErrorConstructor = Error; function IsPrimitive(value) { return !IsObject(value); } function invariant$1(condition, message, Err = ErrorConstructor) { if (!condition) throw new Err(message); } function IsCallable(fn) { if (typeof fn === "function") return true; if (typeof fn !== "undefined" || fn === void 0) return false; try { apply$6(functionToString, fn, []); return true; } catch { return false; } } function OrdinaryToPrimitive(O, hint) { let methodNames; if (hint === "string") methodNames = ["toString", "valueOf"]; else methodNames = ["valueOf", "toString"]; for (let index = 0; index < methodNames.length; index++) { const method = O[methodNames[index]]; if (IsCallable(method)) { let result = apply$6(method, O, []); if (IsPrimitive(result)) return result; } } throw new TypeErrorConstructor("Cannot convert object to primitive value"); } /** * https://tc39.es/ecma262/#sec-toprimitive */ function ToPrimitive(input, preferredType) { if (IsObject(input)) { const exoticToPrim = input[toPrimitiveSymbol]; let hint; if (exoticToPrim !== void 0 && exoticToPrim !== null) { if (preferredType === void 0) hint = "default"; else if (preferredType === "string") hint = "string"; else { invariant$1(preferredType === "number", "preferredType must be \"string\" or \"number\""); hint = "number"; } let result = apply$6(exoticToPrim, input, [hint]); if (IsPrimitive(result)) return result; throw new TypeErrorConstructor("Cannot convert exotic object to primitive."); } if (preferredType === void 0) preferredType = "number"; return OrdinaryToPrimitive(input, preferredType); } return input; } // packages/ecma402-abstract/ToIntlMathematicalValue.js const apply$5 = Reflect.apply; const trim = String.prototype.trim; const slice$4 = String.prototype.slice; function ToIntlMathematicalValue(input) { const primitive = ToPrimitive(input, "number"); let stringDigitCount = 0; let stringFractionDigitCount = 0; if (typeof primitive === "bigint") return { value: new Decimal(primitive), stringDigitCount, stringFractionDigitCount }; if (typeof primitive === "symbol") throw new TypeErrorConstructor$2("Cannot convert a Symbol value to a number"); const rounded = +primitive; let exact = rounded; if (typeof primitive === "string" && rounded === rounded) { const text = apply$5(trim, primitive, []); const first = text.length > 0 ? text[0] : ""; const prefix = first === "0" && text.length > 1 ? text[1] : ""; const base = prefix === "x" || prefix === "X" || prefix === "o" || prefix === "O" || prefix === "b" || prefix === "B"; const finite = numberIsFinite(rounded); if (base) { if (finite && rounded !== 0) exact = bigIntFrom(text); } else { const start = first === "+" || first === "-" ? 1 : 0; if (start < text.length && text[start] !== "I") { let fraction = 0; let exponent = 0; let fractional = false; for (let index = start; index < text.length; index++) { const digit = text[index]; if (digit === "e" || digit === "E") { exponent = +apply$5(slice$4, text, [index + 1]); break; } if (digit === ".") { fractional = true; continue; } if (fractional) fraction++; if (stringDigitCount || digit !== "0") stringDigitCount++; } stringDigitCount = finite ? stringDigitCount || 1 + fraction : 0; stringFractionDigitCount = mathMin(9007199254740991, mathMax(0, fraction - exponent)); if (finite && rounded !== 0) exact = text; } } } return { value: new Decimal(exact), stringDigitCount, stringFractionDigitCount }; } // packages/ecma402-abstract/DefaultNumberOption.js function DefaultNumberOption(inputVal, min, max, fallback) { if (inputVal === void 0) return fallback; const val = +inputVal; if (!numberIsFinite(val) || val < min || val > max) throw new RangeErrorConstructor(`${val} is outside of range [${min}, ${max}]`); return val === 0 ? 0 : floor(val); } // packages/ecma402-abstract/GetNumberOption.js function GetNumberOption(options, property, minimum, maximum, fallback) { const val = options[property]; return DefaultNumberOption(val, minimum, maximum, fallback); } // node_modules/.aspect_rules_js/@formatjs+fast-memoize@0.0.0/node_modules/@formatjs/fast-memoize/index.js const apply$4 = Reflect.apply; const bind = Function.prototype.bind; const slice$3 = Array.prototype.slice; const stringify = JSON.stringify; const create = Object.create; const defineProperty = Object.defineProperty; const setPrototypeOf = Object.setPrototypeOf; 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 = apply$4(fn, this, [arg]); cache.set(cacheKey, computedValue); } return computedValue; } function variadic(fn, cache, serializer) { const args = apply$4(slice$3, arguments, [3]); if (serializer === serializerDefault) setPrototypeOf(args, null); const cacheKey = serializer(args); let computedValue = cache.get(cacheKey); if (typeof computedValue === "undefined") { computedValue = apply$4(fn, this, args); cache.set(cacheKey, computedValue); } return computedValue; } function assemble(fn, context, strategy, cache, serialize) { return apply$4(bind, strategy, [ 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() { setPrototypeOf(arguments, null); return stringify(arguments); }; var ObjectWithoutPrototypeCache = class { constructor() { defineProperty(this, "cache", { __proto__: null, value: create(null), writable: true, enumerable: true, configurable: true }); } 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 }; // packages/ecma402-abstract/utils.js const apply$3 = Reflect.apply; const stringRepeat = String.prototype.repeat; const arrayFrom = Array.from; const arrayJoin = Array.prototype.join; function repeat(s, times) { if (typeof stringRepeat === "function") return apply$3(stringRepeat, s, [times]); const arr = arrayFrom({ length: times }); for (let i = 0; i < arr.length; i++) arr[i] = s; return apply$3(arrayJoin, arr, [""]); } function invariant(condition, message, Err = ErrorConstructor$1) { if (!condition) throw new Err(message); } memoize((...args) => new Intl.NumberFormat(...args), { strategy: strategies.variadic }); memoize((...args) => new Intl.ListFormat(...args), { strategy: strategies.variadic }); const getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; strategies.variadic; let providerIntl = globalThis.Intl; function ownIntlProvider(name) { const descriptor = providerIntl && getOwnPropertyDescriptor(providerIntl, name); return (descriptor && getOwnPropertyDescriptor(descriptor, "value"))?.value; } let numberFormatIntrinsic = ownIntlProvider("NumberFormat"); let listFormatIntrinsic = ownIntlProvider("ListFormat"); let pluralRulesProvider = ownIntlProvider("PluralRules"); const getFormatterPrototype = Object.getPrototypeOf; function formatterMethodLookup(name) { const methods = /* @__PURE__ */ new WeakMap(); const owners = /* @__PURE__ */ new WeakMap(); const getMethod = methods.get.bind(methods); const setMethod = methods.set.bind(methods); const getOwner = owners.get.bind(owners); const setOwner = owners.set.bind(owners); return (Constructor) => { const cached = getMethod(Constructor); if (cached) return cached; let prototype = getOwnPropertyDescriptor(Constructor, "prototype")?.value; while (prototype != null) { const inherited = getOwner(prototype); if (inherited) { setMethod(Constructor, inherited); return inherited; } const descriptor = getOwnPropertyDescriptor(prototype, name); const value = descriptor && getOwnPropertyDescriptor(descriptor, "value"); if (value && typeof value.value === "function") { const method = value.value; setMethod(Constructor, method); setOwner(prototype, method); return method; } prototype = getFormatterPrototype(prototype); } }; } const findFormatterPartsMethod = formatterMethodLookup("formatToParts"); const findPluralRulesSelectMethod = formatterMethodLookup("select"); if (typeof numberFormatIntrinsic === "function") findFormatterPartsMethod(numberFormatIntrinsic); if (typeof listFormatIntrinsic === "function") findFormatterPartsMethod(listFormatIntrinsic); if (typeof pluralRulesProvider === "function") findPluralRulesSelectMethod(pluralRulesProvider); const numberFormatMemoizers = /* @__PURE__ */ new WeakMap(); numberFormatMemoizers.get.bind(numberFormatMemoizers); numberFormatMemoizers.set.bind(numberFormatMemoizers); const listFormatMemoizers = /* @__PURE__ */ new WeakMap(); listFormatMemoizers.get.bind(listFormatMemoizers); listFormatMemoizers.set.bind(listFormatMemoizers); const pluralRulesMemoizers = /* @__PURE__ */ new WeakMap(); pluralRulesMemoizers.get.bind(pluralRulesMemoizers); pluralRulesMemoizers.set.bind(pluralRulesMemoizers); // packages/ecma402-abstract/NumberFormat/SetNumberFormatDigitOptions.js const VALID_ROUNDING_INCREMENTS = [ 1, 2, 5, 10, 20, 25, 50, 100, 200, 250, 500, 1e3, 2e3, 2500, 5e3 ]; const validRoundingIncrementList = VALID_ROUNDING_INCREMENTS.join(", "); /** * https://tc39.es/ecma402/#sec-setnfdigitoptions */ function SetNumberFormatDigitOptions(internalSlots, opts, mnfdDefault, mxfdDefault, notation) { const mnid = GetNumberOption(opts, "minimumIntegerDigits", 1, 21, 1); let mnfd = opts.minimumFractionDigits; let mxfd = opts.maximumFractionDigits; let mnsd = opts.minimumSignificantDigits; let mxsd = opts.maximumSignificantDigits; const roundingIncrement = GetNumberOption(opts, "roundingIncrement", 1, 5e3, 1); if (!arrayIncludes(VALID_ROUNDING_INCREMENTS, roundingIncrement)) throw new RangeErrorConstructor(`Invalid rounding increment value: ${roundingIncrement}. Valid values are ${validRoundingIncrementList}.`); const roundingMode = GetOption(opts, "roundingMode", "string", [ "ceil", "floor", "expand", "trunc", "halfCeil", "halfFloor", "halfExpand", "halfTrunc", "halfEven" ], "halfExpand"); const roundingPriority = GetOption(opts, "roundingPriority", "string", [ "auto", "morePrecision", "lessPrecision" ], "auto"); const trailingZeroDisplay = GetOption(opts, "trailingZeroDisplay", "string", [ "auto", "stripIfInteger", "stripToMinimum" ], "auto"); if (roundingIncrement !== 1) mxfdDefault = mnfdDefault; internalSlots.minimumIntegerDigits = mnid; internalSlots.roundingIncrement = roundingIncrement; internalSlots.roundingMode = roundingMode; internalSlots.trailingZeroDisplay = trailingZeroDisplay; const hasSd = mnsd !== void 0 || mxsd !== void 0; const hasFd = mnfd !== void 0 || mxfd !== void 0; let needSd = true; let needFd = true; if (roundingPriority === "auto") { needSd = hasSd; if (hasSd || !hasFd && notation === "compact") needFd = false; } if (needSd) { if (hasSd) { internalSlots.minimumSignificantDigits = DefaultNumberOption(mnsd, 1, 21, 1); internalSlots.maximumSignificantDigits = DefaultNumberOption(mxsd, internalSlots.minimumSignificantDigits, 21, 21); } else { internalSlots.minimumSignificantDigits = 1; internalSlots.maximumSignificantDigits = 21; } } if (needFd) { if (hasFd) { mnfd = DefaultNumberOption(mnfd, 0, 100, void 0); mxfd = DefaultNumberOption(mxfd, 0, 100, void 0); if (mnfd === void 0) { invariant(mxfd !== void 0, "maximumFractionDigits must be defined"); mnfd = mathMin(mnfdDefault, mxfd); } else if (mxfd === void 0) mxfd = mathMax(mxfdDefault, mnfd); else if (mnfd > mxfd) throw new RangeErrorConstructor(`Invalid range, ${mnfd} > ${mxfd}`); internalSlots.minimumFractionDigits = mnfd; internalSlots.maximumFractionDigits = mxfd; } else { internalSlots.minimumFractionDigits = mnfdDefault; internalSlots.maximumFractionDigits = mxfdDefault; } } if (!needSd && !needFd) { internalSlots.minimumFractionDigits = 0; internalSlots.maximumFractionDigits = 0; internalSlots.minimumSignificantDigits = 1; internalSlots.maximumSignificantDigits = 2; internalSlots.roundingType = "morePrecision"; internalSlots.roundingPriority = "morePrecision"; } else if (roundingPriority === "morePrecision") { internalSlots.roundingType = "morePrecision"; internalSlots.roundingPriority = "morePrecision"; } else if (roundingPriority === "lessPrecision") { internalSlots.roundingType = "lessPrecision"; internalSlots.roundingPriority = "lessPrecision"; } else if (hasSd) { internalSlots.roundingType = "significantDigits"; internalSlots.roundingPriority = "auto"; } else { internalSlots.roundingType = "fractionDigits"; internalSlots.roundingPriority = "auto"; } if (roundingIncrement !== 1) { invariant(internalSlots.roundingType === "fractionDigits", "Invalid roundingType", TypeErrorConstructor$2); invariant(internalSlots.maximumFractionDigits === internalSlots.minimumFractionDigits, "With roundingIncrement > 1, maximumFractionDigits and minimumFractionDigits must be equal.", RangeErrorConstructor); } } // packages/ecma402-abstract/PluralRules/InitializePluralRules.js function InitializePluralRules(pl, locales, options, { availableLocales, relevantExtensionKeys, localeData, getDefaultLocale, getInternalSlots }) { const requestedLocales = CanonicalizeLocaleList(locales); const opt = { __proto__: null }; const opts = CoerceOptionsToObject(options); const internalSlots = getInternalSlots(pl); internalSlots.initializedPluralRules = true; opt.localeMatcher = GetOption(opts, "localeMatcher", "string", ["best fit", "lookup"], "best fit"); const r = ResolveLocale(availableLocales, requestedLocales, opt, relevantExtensionKeys, localeData, getDefaultLocale, "hostDefaultWithLocaleData"); internalSlots.locale = r.locale; internalSlots.localeData = r.localeData; internalSlots.type = GetOption(opts, "type", "string", ["cardinal", "ordinal"], "cardinal"); const notation = GetOption(opts, "notation", "string", [ "standard", "scientific", "engineering", "compact" ], "standard"); internalSlots.notation = notation; const compactDisplay = GetOption(opts, "compactDisplay", "string", ["short", "long"], "short"); if (notation === "compact") { internalSlots.compactDisplay = compactDisplay; const data = r.localeData; if (data && HasOwnProperty(data, "compactExponents")) internalSlots.compactExponents = data.compactExponents; } SetNumberFormatDigitOptions(internalSlots, opts, 0, 3, notation); return pl; } // packages/ecma262-abstract/Type.js function Type(x) { if (x === null) return "Null"; if (x === void 0) return "Undefined"; if (IsObject(x)) 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"; } // packages/ecma402-abstract/constants.js const ZERO = new Decimal(0); const NEGATIVE_ZERO = new Decimal(-0); // packages/ecma402-abstract/NumberFormat/GetUnsignedRoundingMode.js const negativeMapping = { ceil: "zero", floor: "infinity", expand: "infinity", trunc: "zero", halfCeil: "half-zero", halfFloor: "half-infinity", halfExpand: "half-infinity", halfTrunc: "half-zero", halfEven: "half-even" }; const positiveMapping = { ceil: "infinity", floor: "zero", expand: "infinity", trunc: "zero", halfCeil: "half-infinity", halfFloor: "half-zero", halfExpand: "half-infinity", halfTrunc: "half-zero", halfEven: "half-even" }; function GetUnsignedRoundingMode(roundingMode, isNegative) { if (isNegative) return negativeMapping[roundingMode]; return positiveMapping[roundingMode]; } // packages/ecma402-abstract/NumberFormat/ApplyUnsignedRoundingMode.js function ApplyUnsignedRoundingMode(x, r1, r2, unsignedRoundingMode) { if (x.eq(r1) || r1.eq(r2)) return r1; if (x.eq(r2)) return r2; invariant(r1.lessThan(x) && x.lessThan(r2), `x should be between r1 and r2 but x=${x}, r1=${r1}, r2=${r2}`); if (unsignedRoundingMode === "zero") return r1; if (unsignedRoundingMode === "infinity") return r2; const d1 = x.minus(r1); const d2 = r2.minus(x); if (d1.lessThan(d2)) return r1; if (d2.lessThan(d1)) return r2; invariant(d1.eq(d2), "d1 should be equal to d2"); if (unsignedRoundingMode === "half-zero") return r1; if (unsignedRoundingMode === "half-infinity") return r2; invariant(unsignedRoundingMode === "half-even", "unsignedRoundingMode should be half-even"); if (r1.div(r2.minus(r1)).mod(2).isZero()) return r1; return r2; } // packages/ecma402-abstract/NumberFormat/decimal-cache.js const powersOfTen = /* @__PURE__ */ new Map(); const readPower = powersOfTen.get.bind(powersOfTen); const storePower = powersOfTen.set.bind(powersOfTen); const powerOf = Decimal.pow; function decimalMagnitude(value) { return `${value._mantissa}`.length - 1 + value._exponent; } function getPowerOf10(exponent) { const n = typeof exponent === "number" ? exponent : exponent.toNumber(); const cached = readPower(n); if (cached !== void 0) return cached; const power = powerOf(10, n); if (numberIsInteger(n) && n >= -324 && n <= 324) storePower(n, power); return power; } // packages/ecma402-abstract/NumberFormat/ToRawFixed.js const apply$2 = Reflect.apply; const slice$2 = String.prototype.slice; function ToRawFixedFn(n, f) { return n.times(getPowerOf10(-f)); } function findN1R1(x, f, roundingIncrement) { const n1 = x.times(getPowerOf10(f)).floor().div(roundingIncrement).floor().times(roundingIncrement); return { n1, r1: ToRawFixedFn(n1, f) }; } function findN2R2(x, f, roundingIncrement) { const n2 = x.times(getPowerOf10(f)).ceil().div(roundingIncrement).ceil().times(roundingIncrement); return { n2, r2: ToRawFixedFn(n2, f) }; } /** * https://tc39.es/ecma402/#sec-torawfixed * https://tc39.es/proposal-intl-keep-trailing-zeros/ * @param x a finite non-negative mathematical value * @param minFraction an integer between 0 and 100 * @param maxFraction an integer between 0 and 100 */ function ToRawFixed(x, minFraction, maxFraction, roundingIncrement, unsignedRoundingMode, digitCount = 0, fractionDigitCount = 0) { if (roundingIncrement === 1 && x.isInteger()) { const integer = x.toString(); const minimum = mathMin(maxFraction, mathMax(minFraction, x.isZero() ? fractionDigitCount : digitCount - integer.length)); return { formattedString: integer + (minimum === 0 ? "" : "." + repeat("0", minimum)), roundedNumber: x, integerDigitsCount: integer.length, roundingMagnitude: -maxFraction }; } const f = maxFraction; const { n1, r1 } = findN1R1(x, f, roundingIncrement); const { n2, r2 } = findN2R2(x, f, roundingIncrement); const r = ApplyUnsignedRoundingMode(x, r1, r2, unsignedRoundingMode); let n, xFinal; let m; if (r.eq(r1)) { n = n1; xFinal = r1; } else { n = n2; xFinal = r2; } if (n.isZero()) m = "0"; else m = n.toString(); let int; let leadingZeros = 0; if (f !== 0) { let k = m.length; if (k <= f) { leadingZeros = f - k + 1; m = repeat("0", leadingZeros) + m; k = f + 1; } const a = apply$2(slice$2, m, [0, k - f]); const b = apply$2(slice$2, m, [m.length - f]); m = a + "." + b; int = a.length; } else int = m.length; const sourceFraction = n.isZero() ? fractionDigitCount : digitCount - int + leadingZeros; let cut = maxFraction - mathMax(minFraction, sourceFraction); while (cut > 0 && m[m.length - 1] === "0") { m = apply$2(slice$2, m, [0, m.length - 1]); cut--; } if (m[m.length - 1] === ".") m = apply$2(slice$2, m, [0, m.length - 1]); return { formattedString: m, roundedNumber: xFinal, integerDigitsCount: int, roundingMagnitude: -f }; } // packages/ecma402-abstract/NumberFormat/ToRawPrecision.js const apply$1 = Reflect.apply; const { includes, slice: slice$1 } = String.prototype; /** * https://tc39.es/ecma402/#sec-torawprecision * https://tc39.es/proposal-intl-keep-trailing-zeros/ * @param x a finite non-negative mathematical value * @param minPrecision an integer between 1 and 21 * @param maxPrecision an integer between 1 and 21 */ function ToRawPrecision(x, minPrecision, maxPrecision, unsignedRoundingMode, digitCount = 0, fractionDigitCount = 0) { const p = maxPrecision; let m; let e; let xFinal; if (x.isZero()) { m = repeat("0", p); e = 0; xFinal = ZERO; } else { e = decimalMagnitude(x); const step = getPowerOf10(e - p + 1); const scaled = x.div(step); const n1 = scaled.floor(); const n2 = scaled.ceil(); const r1 = n1.times(step); xFinal = ApplyUnsignedRoundingMode(x, r1, n2.times(step), unsignedRoundingMode); m = (xFinal.eq(r1) ? n1 : n2).toString(); if (m.length > p) { e++; m = apply$1(slice$1, m, [0, p]); } } let int; if (e >= p - 1) { m = m + repeat("0", e - p + 1); int = e + 1; } else if (e >= 0) { m = apply$1(slice$1, m, [0, e + 1]) + "." + apply$1(slice$1, m, [e + 1]); int = e + 1; } else { invariant(e < 0, "e should be less than 0"); m = "0." + repeat("0", -e - 1) + m; int = 1; } const resolvedMinPrecision = mathMax(minPrecision, xFinal.isZero() ? fractionDigitCount + 1 : digitCount); if (apply$1(includes, m, ["."]) && maxPrecision > resolvedMinPrecision) { let cut = maxPrecision - resolvedMinPrecision; while (cut > 0 && m[m.length - 1] === "0") { m = apply$1(slice$1, m, [0, m.length - 1]); cut--; } if (m[m.length - 1] === ".") m = apply$1(slice$1, m, [0, m.length - 1]); } return { formattedString: m, roundedNumber: xFinal, integerDigitsCount: int, roundingMagnitude: e - p + 1 }; } // packages/ecma402-abstract/NumberFormat/FormatNumericToString.js const apply = Reflect.apply; const { indexOf, slice } = String.prototype; function FormatNumericToString(intlObject, _x, digitCount = 0, fractionDigitCount = 0) { if (intlObject.trailingZeroDisplay === "stripToMinimum") { digitCount = 0; fractionDigitCount = 0; } let x = _x; let sign; if (x.isZero() && x.isNegative()) { sign = "negative"; x = ZERO; } else { invariant(x.isFinite(), "NumberFormatDigitInternalSlots value is not finite"); if (x.lessThan(0)) sign = "negative"; else sign = "positive"; if (sign === "negative") x = x.negated(); } let result; const roundingType = intlObject.roundingType; const unsignedRoundingMode = GetUnsignedRoundingMode(intlObject.roundingMode, sign === "negative"); switch (roundingType) { case "significantDigits": result = ToRawPrecision(x, intlObject.minimumSignificantDigits, intlObject.maximumSignificantDigits, unsignedRoundingMode, digitCount, fractionDigitCount); break; case "fractionDigits": result = ToRawFixed(x, intlObject.minimumFractionDigits, intlObject.maximumFractionDigits, intlObject.roundingIncrement, unsignedRoundingMode, digitCount, fractionDigitCount); break; default: let sResult = ToRawPrecision(x, intlObject.minimumSignificantDigits, intlObject.maximumSignificantDigits, unsignedRoundingMode, digitCount, fractionDigitCount); let fResult = ToRawFixed(x, intlObject.minimumFractionDigits, intlObject.maximumFractionDigits, intlObject.roundingIncrement, unsignedRoundingMode, digitCount, fractionDigitCount); if (intlObject.roundingType === "morePrecision") { if (sResult.roundingMagnitude <= fResult.roundingMagnitude) result = sResult; else result = fResult; } else { invariant(intlObject.roundingType === "lessPrecision", "Invalid roundingType"); if (sResult.roundingMagnitude <= fResult.roundingMagnitude) result = fResult; else result = sResult; } } x = result.roundedNumber; let string = result.formattedString; if (intlObject.trailingZeroDisplay === "stripIfInteger" && x.isInteger()) { const i = apply(indexOf, string, ["."]); if (i > -1) string = apply(slice, string, [0, i]); } const int = result.integerDigitsCount; const minInteger = intlObject.minimumIntegerDigits; if (int < minInteger) string = repeat("0", minInteger - int) + string; if (sign === "negative") { if (x.isZero()) x = NEGATIVE_ZERO; else x = x.negated(); } return { roundedNumber: x, formattedString: string }; } // packages/ecma402-abstract/PluralRules/ResolvePlural.js const objectKeys = Object.keys; /** * ResolvePluralInternal ( pluralRules, n ) * * Internal version of ResolvePlural that returns both the formatted string and plural category. * This is needed for selectRange, which must compare formatted strings to determine if the * start and end values are identical. * * The formatted string is obtained by applying the number formatting options (digit options) * from the PluralRules object to the input number. This ensures that formatting-sensitive * plural rules work correctly (e.g., rules that depend on visible fraction digits). * * @param pl - An initialized PluralRules object * @param n - Mathematical value to resolve * @returns Record containing the formatted string and plural category */ function ResolvePluralInternal(pl, n, { getInternalSlots, PluralRuleSelect }) { const record = "value" in n ? n : void 0; n = "value" in n ? n.value : n; const internalSlots = getInternalSlots(pl); invariant(Type(internalSlots) === "Object", "pl has to be an object"); invariant("initializedPluralRules" in internalSlots, "pluralrules must be initialized"); if (!n.isFinite()) return { formattedString: n.isNaN() ? "NaN" : n.isNegative() ? "-Infinity" : "Infinity", pluralCategory: "other" }; const { localeData, type, notation } = internalSlots; const s = FormatNumericToString(internalSlots, n, record?.stringDigitCount || 0, record?.stringFractionDigitCount || 0).formattedString; let exponent = 0; if (notation === "compact") { const patterns = internalSlots.compactExponents?.[internalSlots.compactDisplay || "short"]; if (patterns) { let first = 0; while (first < s.length && s[first] === "0") first++; let end = first; while (end < s.length && s[end] !== ".") end++; const magnitude = end - first - 1; let selectedMagnitude = -1; const keys = objectKeys(patterns); for (let i = 0; i < keys.length; i++) { const threshold = numberFrom(keys[i]); if (threshold <= magnitude && threshold > selectedMagnitude) { selectedMagnitude = threshold; exponent = patterns[threshold]; } } } } return { formattedString: s, pluralCategory: PluralRuleSelect(localeData, type, s, exponent) }; } /** * https://tc39.es/ecma402/#sec-resolveplural * @param pl * @param n * @param PluralRuleSelect Has to pass in bc it's implementation-specific */ function ResolvePlural(pl, n, { getInternalSlots, PluralRuleSelect }) { return ResolvePluralInternal(pl, n, { getInternalSlots, PluralRuleSelect }).pluralCategory; } // packages/ecma402-abstract/PluralRules/ResolvePluralRange.js /** * ResolvePluralRange ( pluralRules, x, y ) * * The ResolvePluralRange abstract operation is called with arguments pluralRules (which must be * an object initialized as a PluralRules), x (a mathematical value), and y (a mathematical value). * It resolves the appropriate plural form for a range by determining the plural forms of both the * start and end values, then consulting locale-specific range data. * * ECMA-402 §17.5.4 ResolvePluralRange, steps 1–3. * Specification: https://tc39.es/ecma402/#sec-resolvepluralrange * * @param pluralRules - An initialized PluralRules object * @param x - Mathematical value for the range start * @param y - Mathematical value for the range end * @returns The plural category for the range (zero, one, two, few, many, or other) */ function ResolvePluralRange(pluralRules, x, y, { getInternalSlots, PluralRuleSelect, PluralRuleSelectRange }) { if (("value" in x ? x.value : x).isNaN() || ("value" in y ? y.value : y).isNaN()) throw new RangeErrorConstructor("selectRange requires start and end values not to be NaN"); const internalSlots = getInternalSlots(pluralRules); invariant(Type(internalSlots) === "Object", "pluralRules has to be an object"); invariant("initializedPluralRules" in internalSlots, "pluralrules must be initialized"); const xp = ResolvePluralInternal(pluralRules, x, { getInternalSlots, PluralRuleSelect }); const yp = ResolvePluralInternal(pluralRules, y, { getInternalSlots, PluralRuleSelect }); if (xp.formattedString === yp.formattedString) return xp.pluralCategory; const { localeData, type } = internalSlots; return PluralRuleSelectRange(localeData, type, xp.pluralCategory, yp.pluralCategory); } // packages/intl-pluralrules/get_internal_slots.ts const internalSlotMap = /* @__PURE__ */ new WeakMap(); const readInternalSlots = internalSlotMap.get.bind(internalSlotMap); const writeInternalSlots = internalSlotMap.set.bind(internalSlotMap); function requireInternalSlots(receiver) { const slots = readInternalSlots(receiver); if (!slots?.initializedPluralRules) throw new TypeErrorConstructor$2("Incompatible Intl.PluralRules receiver"); return slots; } function getInternalSlots(x) { let internalSlots = readInternalSlots(x); if (!internalSlots) { internalSlots = { __proto__: null }; writeInternalSlots(x, internalSlots); } return internalSlots; } // packages/intl-pluralrules/index.ts /** * https://tc39.es/ecma402/#sec-pluralruleselect */ function PluralRuleSelect(localeData, type, decimalString, exponent) { return localeData.fn(decimalString, type === "ordinal", exponent); } function PluralRuleSelectRange(localeData, type, xp, yp) { const ranges = localeData && HasOwnProperty(localeData, "pluralRanges") ? localeData.pluralRanges : void 0; const rangeData = ranges && HasOwnProperty(ranges, type) ? ranges[type] : void 0; const key = `${xp}_${yp}`; return rangeData && HasOwnProperty(rangeData, key) ? rangeData[key] ?? yp : yp; } let defaultLocale = ""; function getDefaultLocale() { return defaultLocale; } const relevantExtensionKeys = []; var PluralRules = class PluralRules extends null { constructor(locales, options) { return InitializePluralRules(createFromConstructor(new.target, PluralRules.prototype), locales, options, { availableLocales: PluralRules.availableLocales, relevantExtensionKeys, localeData: PluralRules.localeData, getDefaultLocale, getInternalSlots }); } resolvedOptions() { const internalSlots = requireInternalSlots(this); const opts = {}; const fields = [ "locale", "type", "notation", "compactDisplay", "minimumIntegerDigits", "minimumFractionDigits", "maximumFractionDigits", "minimumSignificantDigits", "maximumSignificantDigits" ]; for (let index = 0; index < fields.length; index++) { const field = fields[index]; const val = internalSlots[field]; if (val !== void 0) setDataProperty(opts, field, val); } const categories = internalSlots.localeData.categories[internalSlots.type]; const ordered = [ "zero", "one", "two", "few", "many", "other" ]; const pluralCategories = []; for (let index = 0; index < ordered.length; index++) { const category = ordered[index]; if (arrayIncludes(categories, category)) setDataProperty(pluralCategories, pluralCategories.length, category); } setDataProperty(opts, "pluralCategories", pluralCategories); setDataProperty(opts, "roundingIncrement", internalSlots.roundingIncrement); setDataProperty(opts, "roundingMode", internalSlots.roundingMode); setDataProperty(opts, "roundingPriority", internalSlots.roundingPriority); setDataProperty(opts, "trailingZeroDisplay", internalSlots.trailingZeroDisplay); return opts; } select(val) { requireInternalSlots(this); const n = ToIntlMathematicalValue(val); return ResolvePlural(this, n, { getInternalSlots, PluralRuleSelect }); } selectRange(start, end) { requireInternalSlots(this); if (start === void 0 || end === void 0) throw new TypeErrorConstructor$2("selectRange requires both start and end arguments"); const x = ToIntlMathematicalValue(start); const y = ToIntlMathematicalValue(end); return ResolvePluralRange(this, x, y, { getInternalSlots, PluralRuleSelect, PluralRuleSelectRange }); } static supportedLocalesOf(locales, options) { return SupportedLocales(PluralRules.availableLocales, CanonicalizeLocaleList(locales), options); } static __addLocaleData(...data) { for (const { data: d, locale: tag } of data) { const locale = canonicalizeLocaleDataTag(tag); registerLocaleData(locale, d, PluralRules.localeData, PluralRules.availableLocales); if (!defaultLocale) defaultLocale = locale; } } static { this.localeData = Object.create(null); } static { this.availableLocales = /* @__PURE__ */ new Set(); } static getDefaultLocale() { return getDefaultLocale(); } static { this.relevantExtensionKeys = []; } static { this.polyfilled = true; } }; Object.defineProperty(PluralRules, "__defaultLocale", { configurable: true, enumerable: true, get: getDefaultLocale, set(locale) { defaultLocale = locale; } }); Object.setPrototypeOf(PluralRules.prototype, Object.prototype); try { if (typeof Symbol !== "undefined") Object.defineProperty(PluralRules.prototype, Symbol.toStringTag, { value: "Intl.PluralRules", writable: false, enumerable: false, configurable: true }); try { Object.defineProperty(PluralRules, "length", { value: 0, writable: false, enumerable: false, configurable: true }); } catch {} Object.defineProperty(PluralRules.prototype.constructor, "length", { value: 0, writable: false, enumerable: false, configurable: true }); Object.defineProperty(PluralRules.supportedLocalesOf, "length", { value: 1, writable: false, enumerable: false, configurable: true }); Object.defineProperty(PluralRules, "name", { value: "PluralRules", writable: false, enumerable: false, configurable: true }); } catch {} export { PluralRules }; //# sourceMappingURL=index.js.map