@formatjs/intl-durationformat 0.13.0 → 0.13.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/polyfill.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { LookupSupportedLocales, ResolveLocale } from "@formatjs/intl-localematcher";
2
- import { BigDecimal, Decimal } from "@formatjs/bigdecimal";
2
+ import { BigDecimal } from "@formatjs/bigdecimal";
3
3
  // node_modules/.aspect_rules_js/@formatjs_generated+cldr.number@0.0.0/node_modules/@formatjs_generated/cldr.number/numbering-systems.js
4
4
  const numberingSystemNames = [
5
5
  "adlm",
@@ -101,40 +101,75 @@ const numberingSystemNames = [
101
101
  "wcho"
102
102
  ];
103
103
  // packages/ecma402-abstract/IsUnicodeLocaleIdentifierType.js
104
+ const typeApply = Reflect.apply;
105
+ const typeExec = RegExp.prototype.exec;
106
+ const typePattern = /^[a-z0-9]{3,8}(-[a-z0-9]{3,8})*(?![\s\S])/i;
104
107
  /** Tests the Unicode locale identifier `type` grammar, not locale support. */
105
108
  function IsUnicodeLocaleIdentifierType(value) {
106
- return /^[a-z0-9]{3,8}(-[a-z0-9]{3,8})*(?![\s\S])/i.test(value);
109
+ return typeApply(typeExec, typePattern, [value]) !== null;
107
110
  }
108
111
  // packages/ecma262-abstract/OrdinaryHasInstance.js
109
- function IsCallable(fn) {
110
- return typeof fn === "function";
112
+ const apply$3 = Reflect.apply;
113
+ const hasInstance = Function.prototype[Symbol.hasInstance];
114
+ /** ECMA-262 §7.3.21, via §20.2.3.6 step 2. */
115
+ function OrdinaryHasInstance(constructor, instance) {
116
+ return apply$3(hasInstance, constructor, [instance]);
111
117
  }
112
- /**
113
- * https://tc39.es/ecma262/#sec-ordinaryhasinstance
114
- */
115
- function OrdinaryHasInstance(C, O, internalSlots) {
116
- if (!IsCallable(C)) return false;
117
- if (internalSlots?.boundTargetFunction) return O instanceof internalSlots?.boundTargetFunction;
118
- if (O === null || typeof O !== "object" && typeof O !== "function") return false;
119
- let P = C.prototype;
120
- if (P === null || typeof P !== "object" && typeof P !== "function") throw new TypeError("OrdinaryHasInstance called on an object with an invalid prototype property.");
121
- return Object.prototype.isPrototypeOf.call(P, O);
118
+ // packages/ecma262-abstract/intrinsics.js
119
+ const floor = Math.floor;
120
+ const bigIntFrom = BigInt;
121
+ const objectFrom = Object;
122
+ const mathAbs = Math.abs;
123
+ const numberIsInteger = Number.isInteger;
124
+ const numberIsFinite = Number.isFinite;
125
+ Number.isSafeInteger;
126
+ const ErrorConstructor = Error;
127
+ const TypeErrorConstructor$1 = TypeError;
128
+ const RangeErrorConstructor = RangeError;
129
+ const arrayApply = Reflect.apply;
130
+ Array.prototype.every;
131
+ const some = Array.prototype.some;
132
+ function arraySome(values, predicate) {
133
+ return arrayApply(some, values, [predicate]);
134
+ }
135
+ Array.prototype.includes;
136
+ Array.prototype.indexOf;
137
+ const defineProperty$2 = Object.defineProperty;
138
+ function setDataProperty(target, key, value) {
139
+ defineProperty$2(target, key, {
140
+ __proto__: null,
141
+ value,
142
+ writable: true,
143
+ enumerable: true,
144
+ configurable: true
145
+ });
122
146
  }
123
147
  // packages/ecma262-abstract/ToObject.js
124
148
  /**
125
149
  * https://tc39.es/ecma262/#sec-toobject
126
150
  */
127
151
  function ToObject(arg) {
128
- if (arg == null) throw new TypeError("undefined/null cannot be converted to object");
129
- return Object(arg);
152
+ if (arg === void 0 || arg === null) throw new TypeErrorConstructor$1("undefined/null cannot be converted to object");
153
+ return objectFrom(arg);
130
154
  }
131
155
  // packages/ecma402-abstract/CanonicalizeLocaleList.js
156
+ let canonicalIntl = globalThis.Intl;
157
+ const canonicalDescriptor = Object.getOwnPropertyDescriptor;
158
+ const canonicalApply = Reflect.apply;
159
+ function ownCanonicalProvider() {
160
+ const descriptor = canonicalIntl && canonicalDescriptor(canonicalIntl, "getCanonicalLocales");
161
+ return (descriptor && canonicalDescriptor(descriptor, "value"))?.value;
162
+ }
163
+ let canonicalProvider = ownCanonicalProvider();
132
164
  /**
133
165
  * http://ecma-international.org/ecma-402/7.0/index.html#sec-canonicalizelocalelist
134
166
  * @param locales
135
167
  */
136
168
  function CanonicalizeLocaleList(locales) {
137
- return Intl.getCanonicalLocales(locales);
169
+ if (canonicalIntl === void 0) canonicalIntl = globalThis.Intl;
170
+ const candidate = ownCanonicalProvider();
171
+ if (typeof candidate === "function") canonicalProvider = candidate;
172
+ return canonicalApply(canonicalProvider, canonicalIntl, [locales]);
138
173
  }
139
174
  // packages/ecma402-abstract/DefaultNumberOption.js
140
175
  /**
@@ -149,8 +184,8 @@ function CanonicalizeLocaleList(locales) {
149
184
  function DefaultNumberOption(inputVal, min, max, fallback) {
150
185
  if (inputVal === void 0) return fallback;
151
186
  const val = +inputVal;
152
- if (isNaN(val) || val < min || val > max) throw new RangeError(`${val} is outside of range [${min}, ${max}]`);
153
- return Math.floor(val);
187
+ if (val !== val || val < min || val > max) throw new RangeErrorConstructor(`${val} is outside of range [${min}, ${max}]`);
188
+ return floor(val);
154
189
  }
155
190
  // packages/ecma402-abstract/GetNumberOption.js
156
191
  /**
@@ -165,15 +200,24 @@ function GetNumberOption(options, property, minimum, maximum, fallback) {
165
200
  const val = options[property];
166
201
  return DefaultNumberOption(val, minimum, maximum, fallback);
167
202
  }
203
+ // packages/ecma262-abstract/IsObject.js
204
+ /** Includes browser host objects such as document.all. */
205
+ function IsObject(value) {
206
+ return value !== null && (typeof value === "object" || typeof value === "function" || typeof value === "undefined" && value !== void 0);
207
+ }
168
208
  // packages/ecma262-abstract/ToString.js
209
+ const StringConstructor = String;
210
+ const TypeErrorConstructor = TypeError;
169
211
  /**
170
212
  * https://tc39.es/ecma262/#sec-tostring
171
213
  */
172
214
  function ToString(o) {
173
- if (typeof o === "symbol") throw TypeError("Cannot convert a Symbol value to a string");
174
- return String(o);
215
+ if (typeof o === "symbol") throw TypeErrorConstructor("Cannot convert a Symbol value to a string");
216
+ return StringConstructor(o);
175
217
  }
176
218
  // packages/ecma402-abstract/GetOption.js
219
+ const optionApply = Reflect.apply;
220
+ const optionJoin = Array.prototype.join;
177
221
  /**
178
222
  * https://tc39.es/ecma402/#sec-getoption
179
223
  * @param opts
@@ -183,13 +227,13 @@ function ToString(o) {
183
227
  * @param fallback
184
228
  */
185
229
  function GetOption(opts, prop, type, values, fallback) {
186
- if (opts === null || typeof opts !== "object" && typeof opts !== "function") throw new TypeError("Options must be an object");
230
+ if (!IsObject(opts)) throw new TypeErrorConstructor$1("Options must be an object");
187
231
  let value = opts[prop];
188
232
  if (value !== void 0) {
189
- if (type !== "boolean" && type !== "string") throw new TypeError("invalid type");
233
+ if (type !== "boolean" && type !== "string") throw new TypeErrorConstructor$1("invalid type");
190
234
  if (type === "boolean") value = Boolean(value);
191
235
  if (type === "string") value = ToString(value);
192
- if (values !== void 0 && !values.filter((val) => val == value).length) throw new RangeError(`${value} is not within ${values.join(", ")}`);
236
+ if (values !== void 0 && !arraySome(values, (val) => val == value)) throw new RangeErrorConstructor(`${value} is not within ${optionApply(optionJoin, values, [", "])}`);
193
237
  return value;
194
238
  }
195
239
  return fallback;
@@ -211,6 +255,13 @@ function SupportedLocales(availableLocales, requestedLocales, options) {
211
255
  return LookupSupportedLocales(Array.from(availableLocales), requestedLocales);
212
256
  }
213
257
  // node_modules/.aspect_rules_js/@formatjs+fast-memoize@0.0.0/node_modules/@formatjs/fast-memoize/index.js
258
+ const apply$2 = Reflect.apply;
259
+ const bind = Function.prototype.bind;
260
+ const slice = Array.prototype.slice;
261
+ const stringify = JSON.stringify;
262
+ const create = Object.create;
263
+ const defineProperty$1 = Object.defineProperty;
264
+ const setPrototypeOf = Object.setPrototypeOf;
214
265
  function memoize(fn, options) {
215
266
  const cache = options && options.cache ? options.cache : cacheDefault;
216
267
  const serializer = options && options.serializer ? options.serializer : serializerDefault;
@@ -226,23 +277,29 @@ function monadic(fn, cache, serializer, arg) {
226
277
  const cacheKey = isPrimitive(arg) ? arg : serializer(arg);
227
278
  let computedValue = cache.get(cacheKey);
228
279
  if (typeof computedValue === "undefined") {
229
- computedValue = fn.call(this, arg);
280
+ computedValue = apply$2(fn, this, [arg]);
230
281
  cache.set(cacheKey, computedValue);
231
282
  }
232
283
  return computedValue;
233
284
  }
234
285
  function variadic(fn, cache, serializer) {
235
- const args = Array.prototype.slice.call(arguments, 3);
286
+ const args = apply$2(slice, arguments, [3]);
287
+ if (serializer === serializerDefault) setPrototypeOf(args, null);
236
288
  const cacheKey = serializer(args);
237
289
  let computedValue = cache.get(cacheKey);
238
290
  if (typeof computedValue === "undefined") {
239
- computedValue = fn.apply(this, args);
291
+ computedValue = apply$2(fn, this, args);
240
292
  cache.set(cacheKey, computedValue);
241
293
  }
242
294
  return computedValue;
243
295
  }
244
296
  function assemble(fn, context, strategy, cache, serialize) {
245
- return strategy.bind(context, fn, cache, serialize);
297
+ return apply$2(bind, strategy, [
298
+ context,
299
+ fn,
300
+ cache,
301
+ serialize
302
+ ]);
246
303
  }
247
304
  function strategyDefault(fn, options) {
248
305
  const strategy = fn.length === 1 ? monadic : variadic;
@@ -255,11 +312,18 @@ function strategyMonadic(fn, options) {
255
312
  return assemble(fn, this, monadic, options.cache.create(), options.serializer);
256
313
  }
257
314
  const serializerDefault = function() {
258
- return JSON.stringify(arguments);
315
+ setPrototypeOf(arguments, null);
316
+ return stringify(arguments);
259
317
  };
260
318
  var ObjectWithoutPrototypeCache = class {
261
319
  constructor() {
262
- this.cache = Object.create(null);
320
+ defineProperty$1(this, "cache", {
321
+ __proto__: null,
322
+ value: create(null),
323
+ writable: true,
324
+ enumerable: true,
325
+ configurable: true
326
+ });
263
327
  }
264
328
  get(key) {
265
329
  return this.cache[key];
@@ -291,14 +355,93 @@ function ensureIntl() {
291
355
  writable: true,
292
356
  value: {}
293
357
  });
358
+ if (providerIntl === void 0) providerIntl = Intl;
294
359
  return Intl;
295
360
  }
296
- function invariant(condition, message, Err = Error) {
361
+ function invariant(condition, message, Err = ErrorConstructor) {
297
362
  if (!condition) throw new Err(message);
298
363
  }
299
- const createMemoizedNumberFormat = memoize((...args) => new Intl.NumberFormat(...args), { strategy: strategies.variadic });
364
+ memoize((...args) => new Intl.NumberFormat(...args), { strategy: strategies.variadic });
300
365
  memoize((...args) => new Intl.PluralRules(...args), { strategy: strategies.variadic });
301
- const createMemoizedListFormat = memoize((...args) => new Intl.ListFormat(...args), { strategy: strategies.variadic });
366
+ memoize((...args) => new Intl.ListFormat(...args), { strategy: strategies.variadic });
367
+ const getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
368
+ const formatterMemoizeOptions = {
369
+ __proto__: null,
370
+ strategy: strategies.variadic
371
+ };
372
+ let providerIntl = globalThis.Intl;
373
+ function ownIntlProvider(name) {
374
+ const descriptor = providerIntl && getOwnPropertyDescriptor(providerIntl, name);
375
+ return (descriptor && getOwnPropertyDescriptor(descriptor, "value"))?.value;
376
+ }
377
+ let numberFormatProvider = ownIntlProvider("NumberFormat");
378
+ let listFormatProvider = ownIntlProvider("ListFormat");
379
+ function getNumberFormatProvider() {
380
+ const candidate = ownIntlProvider("NumberFormat");
381
+ if (typeof candidate === "function") numberFormatProvider = candidate;
382
+ return numberFormatProvider;
383
+ }
384
+ function getListFormatProvider() {
385
+ const candidate = ownIntlProvider("ListFormat");
386
+ if (typeof candidate === "function") listFormatProvider = candidate;
387
+ return listFormatProvider;
388
+ }
389
+ const getFormatterPrototype = Object.getPrototypeOf;
390
+ const formatterPartsMethods = /* @__PURE__ */ new WeakMap();
391
+ const formatterPartsOwners = /* @__PURE__ */ new WeakMap();
392
+ const getPartsMethod = formatterPartsMethods.get.bind(formatterPartsMethods);
393
+ const setPartsMethod = formatterPartsMethods.set.bind(formatterPartsMethods);
394
+ const getPartsOwner = formatterPartsOwners.get.bind(formatterPartsOwners);
395
+ const setPartsOwner = formatterPartsOwners.set.bind(formatterPartsOwners);
396
+ function findFormatterPartsMethod(Constructor) {
397
+ const cached = getPartsMethod(Constructor);
398
+ if (cached) return cached;
399
+ let prototype = getOwnPropertyDescriptor(Constructor, "prototype")?.value;
400
+ while (prototype != null) {
401
+ const inherited = getPartsOwner(prototype);
402
+ if (inherited) {
403
+ setPartsMethod(Constructor, inherited);
404
+ return inherited;
405
+ }
406
+ const descriptor = getOwnPropertyDescriptor(prototype, "formatToParts");
407
+ const value = descriptor && getOwnPropertyDescriptor(descriptor, "value");
408
+ if (value && typeof value.value === "function") {
409
+ setPartsMethod(Constructor, value.value);
410
+ setPartsOwner(prototype, value.value);
411
+ return value.value;
412
+ }
413
+ prototype = getFormatterPrototype(prototype);
414
+ }
415
+ }
416
+ function getFormatterPartsMethod(Constructor) {
417
+ const method = findFormatterPartsMethod(Constructor);
418
+ if (!method) throw new TypeErrorConstructor$1("Missing supplied formatter parts method");
419
+ return method;
420
+ }
421
+ if (typeof numberFormatProvider === "function") findFormatterPartsMethod(numberFormatProvider);
422
+ if (typeof listFormatProvider === "function") findFormatterPartsMethod(listFormatProvider);
423
+ const numberFormatMemoizers = /* @__PURE__ */ new WeakMap();
424
+ const getNumberFormatMemoizer = numberFormatMemoizers.get.bind(numberFormatMemoizers);
425
+ const setNumberFormatMemoizer = numberFormatMemoizers.set.bind(numberFormatMemoizers);
426
+ const listFormatMemoizers = /* @__PURE__ */ new WeakMap();
427
+ const getListFormatMemoizer = listFormatMemoizers.get.bind(listFormatMemoizers);
428
+ const setListFormatMemoizer = listFormatMemoizers.set.bind(listFormatMemoizers);
429
+ function createMemoizedNumberFormatForConstructor(Constructor) {
430
+ let factory = getNumberFormatMemoizer(Constructor);
431
+ if (!factory) {
432
+ factory = memoize((...args) => new Constructor(args[0], args[1]), formatterMemoizeOptions);
433
+ setNumberFormatMemoizer(Constructor, factory);
434
+ }
435
+ return factory;
436
+ }
437
+ function createMemoizedListFormatForConstructor(Constructor) {
438
+ let factory = getListFormatMemoizer(Constructor);
439
+ if (!factory) {
440
+ factory = memoize((...args) => new Constructor(args[0], args[1]), formatterMemoizeOptions);
441
+ setListFormatMemoizer(Constructor, factory);
442
+ }
443
+ return factory;
444
+ }
302
445
  // packages/ecma402-abstract/DurationFormat/GetDurationUnitOptions.js
303
446
  function GetDurationUnitOptions(unit, options, baseStyle, stylesList, digitalBase, prevStyle, twoDigitHours = false) {
304
447
  let style = GetOption(options, unit, "string", stylesList, void 0);
@@ -320,9 +463,9 @@ function GetDurationUnitOptions(unit, options, baseStyle, stylesList, digitalBas
320
463
  displayDefault = "auto";
321
464
  }
322
465
  const display = GetOption(options, `${unit}Display`, "string", ["always", "auto"], displayDefault);
323
- if (display === "always" && style === "fractional") throw new RangeError("Fractional units cannot use always display");
324
- if (prevStyle === "fractional" && style !== "fractional") throw new RangeError("Fractional units must be followed by fractional units");
325
- if ((prevStyle === "numeric" || prevStyle === "2-digit") && style !== "fractional" && style !== "numeric" && style !== "2-digit") throw new RangeError("Can't mix numeric and non-numeric styles");
466
+ if (display === "always" && style === "fractional") throw new RangeErrorConstructor("Fractional units cannot use always display");
467
+ if (prevStyle === "fractional" && style !== "fractional") throw new RangeErrorConstructor("Fractional units must be followed by fractional units");
468
+ if ((prevStyle === "numeric" || prevStyle === "2-digit") && style !== "fractional" && style !== "numeric" && style !== "2-digit") throw new RangeErrorConstructor("Can't mix numeric and non-numeric styles");
326
469
  if (twoDigitHours && unit === "hours") style = "2-digit";
327
470
  if ((unit === "minutes" || unit === "seconds") && (prevStyle === "numeric" || prevStyle === "2-digit")) style = "2-digit";
328
471
  return {
@@ -405,22 +548,42 @@ const TABLE_2 = [
405
548
  ];
406
549
  // packages/intl-durationformat/get_internal_slots.ts
407
550
  const internalSlotMap = /* @__PURE__ */ new WeakMap();
551
+ const getSlots = internalSlotMap.get.bind(internalSlotMap);
552
+ const setSlots = internalSlotMap.set.bind(internalSlotMap);
553
+ const createSlots = Object.create;
408
554
  function getInternalSlots(x) {
409
- let internalSlots = internalSlotMap.get(x);
555
+ let internalSlots = getSlots(x);
410
556
  if (!internalSlots) {
411
- internalSlots = Object.create(null);
412
- internalSlotMap.set(x, internalSlots);
557
+ internalSlots = createSlots(null);
558
+ setSlots(x, internalSlots);
413
559
  }
414
560
  return internalSlots;
415
561
  }
416
562
  // packages/intl-durationformat/abstract/PartitionDurationFormatPattern.ts
563
+ const apply$1 = Reflect.apply;
564
+ const stringListIterator = Array.prototype[Symbol.iterator];
565
+ const stringListIteratorNext = Object.getPrototypeOf(apply$1(stringListIterator, [], [])).next;
566
+ const formatterProviders = /* @__PURE__ */ new WeakMap();
567
+ const getFormatterProviders = formatterProviders.get.bind(formatterProviders);
568
+ const setFormatterProviders = formatterProviders.set.bind(formatterProviders);
569
+ function initializeDurationFormatProviders(df) {
570
+ const NumberFormat = getNumberFormatProvider();
571
+ const ListFormat = getListFormatProvider();
572
+ setFormatterProviders(df, {
573
+ numberFormat: createMemoizedNumberFormatForConstructor(NumberFormat),
574
+ listFormat: createMemoizedListFormatForConstructor(ListFormat),
575
+ numberFormatToParts: getFormatterPartsMethod(NumberFormat),
576
+ listFormatToParts: getFormatterPartsMethod(ListFormat)
577
+ });
578
+ }
417
579
  function PartitionDurationFormatPattern(df, duration) {
418
580
  const result = [];
419
581
  let done = false;
420
582
  let separated = false;
421
583
  let signDisplayed = true;
422
- const negative = TABLE_2.some((row) => duration[row.valueField] < 0);
584
+ const negative = arraySome(TABLE_2, (row) => duration[row.valueField] < 0);
423
585
  const internalSlots = getInternalSlots(df);
586
+ const providers = getFormatterProviders(df);
424
587
  let dataLocale = internalSlots.dataLocale;
425
588
  const dataLocaleData = DurationFormat.localeData[dataLocale];
426
589
  if (!dataLocaleData) throw new TypeError("Invalid locale");
@@ -428,20 +591,20 @@ function PartitionDurationFormatPattern(df, duration) {
428
591
  const separator = dataLocaleData.digitalFormat[numberingSystem] ?? dataLocaleData.digitalFormat.default;
429
592
  for (let i = 0; i < TABLE_2.length && !done; i++) {
430
593
  const row = TABLE_2[i];
431
- let value = new BigDecimal(BigInt(duration[row.valueField]));
594
+ let value = new BigDecimal(bigIntFrom(duration[row.valueField]));
432
595
  const style = internalSlots[row.styleSlot];
433
596
  const display = internalSlots[row.displaySlot];
434
597
  const { unit, numberFormatUnit } = row;
435
- const nfOpts = Object.create(null);
598
+ const nfOpts = { __proto__: null };
436
599
  if (unit === "seconds" || unit === "milliseconds" || unit === "microseconds") {
437
600
  let nextStyle;
438
601
  if (unit === "seconds") nextStyle = internalSlots.milliseconds;
439
602
  else if (unit === "milliseconds") nextStyle = internalSlots.microseconds;
440
603
  else nextStyle = internalSlots.nanoseconds;
441
604
  if (nextStyle === "numeric" || nextStyle === "fractional") {
442
- if (unit === "seconds") value = value.plus(new BigDecimal(BigInt(duration.milliseconds)).div(1e3)).plus(new BigDecimal(BigInt(duration.microseconds)).div(1e6)).plus(new BigDecimal(BigInt(duration.nanoseconds)).div(1e9));
443
- else if (unit === "milliseconds") value = value.plus(new BigDecimal(BigInt(duration.microseconds)).div(1e3)).plus(new BigDecimal(BigInt(duration.nanoseconds)).div(1e6));
444
- else value = value.plus(new BigDecimal(BigInt(duration.nanoseconds)).div(1e3));
605
+ if (unit === "seconds") value = value.plus(new BigDecimal(bigIntFrom(duration.milliseconds)).div(bigIntFrom(1e3))).plus(new BigDecimal(bigIntFrom(duration.microseconds)).div(bigIntFrom(1e6))).plus(new BigDecimal(bigIntFrom(duration.nanoseconds)).div(bigIntFrom(1e9)));
606
+ else if (unit === "milliseconds") value = value.plus(new BigDecimal(bigIntFrom(duration.microseconds)).div(bigIntFrom(1e3))).plus(new BigDecimal(bigIntFrom(duration.nanoseconds)).div(bigIntFrom(1e6)));
607
+ else value = value.plus(new BigDecimal(bigIntFrom(duration.nanoseconds)).div(bigIntFrom(1e3)));
445
608
  if (internalSlots.fractionalDigits === void 0) {
446
609
  nfOpts.maximumFractionDigits = 9;
447
610
  nfOpts.minimumFractionDigits = 0;
@@ -467,56 +630,71 @@ function PartitionDurationFormatPattern(df, duration) {
467
630
  nfOpts.unit = numberFormatUnit;
468
631
  nfOpts.unitDisplay = style;
469
632
  }
470
- const nf = createMemoizedNumberFormat(internalSlots.locale, nfOpts);
633
+ const nf = providers.numberFormat(internalSlots.locale, nfOpts);
471
634
  let list;
472
635
  if (!separated) list = [];
473
636
  else {
474
637
  list = result[result.length - 1];
475
- list.push({
638
+ setDataProperty(list, `${list.length}`, {
476
639
  type: "literal",
477
640
  value: separator
478
641
  });
479
642
  }
480
- nf.formatToParts(value.isZero() && value.isNegative() ? -0 : value).forEach(({ type, value }) => {
481
- list.push({
643
+ let parts = apply$1(providers.numberFormatToParts, nf, [value.isZero() && value.isNegative() ? -0 : value]);
644
+ for (let index = 0; index < parts.length; index++) {
645
+ const { type, value } = parts[index];
646
+ setDataProperty(list, `${list.length}`, {
482
647
  type,
483
648
  value,
484
649
  unit: numberFormatUnit
485
650
  });
486
- });
651
+ }
487
652
  if (!separated) {
488
653
  if (style === "2-digit" || style === "numeric") separated = true;
489
- result.push(list);
654
+ setDataProperty(result, `${result.length}`, list);
490
655
  }
491
656
  } else separated = false;
492
657
  }
493
- const lfOpts = Object.create(null);
658
+ const lfOpts = { __proto__: null };
494
659
  lfOpts.type = "unit";
495
660
  let listStyle = internalSlots.style;
496
661
  if (listStyle === "digital") listStyle = "short";
497
662
  lfOpts.style = listStyle;
498
- const lf = createMemoizedListFormat(internalSlots.locale, lfOpts);
663
+ const lf = providers.listFormat(internalSlots.locale, lfOpts);
499
664
  const strings = [];
500
- for (const parts of result) {
665
+ for (let index = 0; index < result.length; index++) {
666
+ const parts = result[index];
501
667
  let string = "";
502
- for (const { value } of parts) string += value;
503
- strings.push(string);
668
+ for (let partIndex = 0; partIndex < parts.length; partIndex++) string += parts[partIndex].value;
669
+ setDataProperty(strings, `${strings.length}`, string);
504
670
  }
505
- let formatted = lf.formatToParts(strings);
671
+ setDataProperty(strings, Symbol.iterator, () => {
672
+ const iterator = apply$1(stringListIterator, strings, []);
673
+ return {
674
+ __proto__: null,
675
+ next() {
676
+ return apply$1(stringListIteratorNext, iterator, []);
677
+ }
678
+ };
679
+ });
680
+ let formatted = apply$1(providers.listFormatToParts, lf, [strings]);
506
681
  let resultIndex = 0;
507
682
  let resultLength = result.length;
508
- let flattened = [];
509
- for (const { type, value } of formatted) if (type === "element") {
510
- invariant(resultIndex < resultLength, "Index out of bounds");
511
- let parts = result[resultIndex];
512
- for (const part of parts) flattened.push(part);
513
- resultIndex++;
514
- } else {
515
- invariant(type === "literal", "Type must be literal");
516
- flattened.push({
517
- type: "literal",
518
- value
519
- });
683
+ const flattened = [];
684
+ for (let index = 0; index < formatted.length; index++) {
685
+ const { type, value } = formatted[index];
686
+ if (type === "element") {
687
+ invariant(resultIndex < resultLength, "Index out of bounds");
688
+ let parts = result[resultIndex];
689
+ for (let index = 0; index < parts.length; index++) setDataProperty(flattened, `${flattened.length}`, parts[index]);
690
+ resultIndex++;
691
+ } else {
692
+ invariant(type === "literal", "Type must be literal");
693
+ setDataProperty(flattened, `${flattened.length}`, {
694
+ type: "literal",
695
+ value
696
+ });
697
+ }
520
698
  }
521
699
  return flattened;
522
700
  }
@@ -535,7 +713,8 @@ const TABLE_1 = [
535
713
  ];
536
714
  // packages/ecma402-abstract/DurationFormat/DurationRecordSign.js
537
715
  function DurationRecordSign(record) {
538
- for (const key of TABLE_1) {
716
+ for (let index = 0; index < TABLE_1.length; index++) {
717
+ const key = TABLE_1[index];
539
718
  if (record[key] < 0) return -1;
540
719
  if (record[key] > 0) return 1;
541
720
  }
@@ -544,42 +723,51 @@ function DurationRecordSign(record) {
544
723
  // packages/ecma402-abstract/DurationFormat/IsValidDurationRecord.js
545
724
  function IsValidDurationRecord(record) {
546
725
  const sign = DurationRecordSign(record);
547
- for (const key of TABLE_1) {
548
- const v = record[key];
549
- if (!Number.isFinite(v)) return false;
726
+ for (let index = 0; index < TABLE_1.length; index++) {
727
+ const v = record[TABLE_1[index]];
728
+ if (!numberIsFinite(v)) return false;
550
729
  if (v < 0 && sign > 0) return false;
551
730
  if (v > 0 && sign < 0) return false;
552
731
  }
553
- if ([
732
+ if (arraySome([
554
733
  "years",
555
734
  "months",
556
735
  "weeks"
557
- ].some((unit) => Math.abs(record[unit]) >= 2 ** 32)) return false;
558
- const billion = BigInt(1e9);
559
- const normalizedNanoseconds = BigInt(record.days) * BigInt(86400) * billion + BigInt(record.hours) * BigInt(3600) * billion + BigInt(record.minutes) * BigInt(60) * billion + BigInt(record.seconds) * billion + BigInt(record.milliseconds) * BigInt(1e6) + BigInt(record.microseconds) * BigInt(1e3) + BigInt(record.nanoseconds);
560
- const limit = BigInt(2 ** 53) * billion;
736
+ ], (unit) => mathAbs(record[unit]) >= 2 ** 32)) return false;
737
+ const billion = bigIntFrom(1e9);
738
+ const normalizedNanoseconds = bigIntFrom(record.days) * bigIntFrom(86400) * billion + bigIntFrom(record.hours) * bigIntFrom(3600) * billion + bigIntFrom(record.minutes) * bigIntFrom(60) * billion + bigIntFrom(record.seconds) * billion + bigIntFrom(record.milliseconds) * bigIntFrom(1e6) + bigIntFrom(record.microseconds) * bigIntFrom(1e3) + bigIntFrom(record.nanoseconds);
739
+ const limit = bigIntFrom(2 ** 53) * billion;
561
740
  return normalizedNanoseconds > -limit && normalizedNanoseconds < limit;
562
741
  }
563
742
  // packages/ecma262-abstract/ToNumber.js
564
- /**
565
- * ECMA-262 §7.1.4 ToNumber, steps 2, 8–10.
566
- * https://tc39.es/ecma262/#sec-tonumber
567
- * https://github.com/tc39/ecma262/blob/dcf59856a8184792a9e42f0ffb7dc064094a5dcc/spec.html#L5183-L5191
568
- */
743
+ /** ECMA-262 §7.1.4, via §13.5.4.1 step 2. */
569
744
  function ToNumber(arg) {
570
- return new Decimal(+arg);
745
+ return +arg;
571
746
  }
572
747
  // packages/ecma402-abstract/DurationFormat/ToIntegerIfIntegral.js
748
+ /** ECMA-402 §13.5.2 steps 1–3. */
573
749
  function ToIntegerIfIntegral(arg) {
574
750
  const number = ToNumber(arg);
575
- invariant(number.isInteger(), "Duration field is not an integer", RangeError);
576
- return number.isZero() ? 0 : number.toNumber();
751
+ if (!numberIsInteger(number)) throw new RangeErrorConstructor("Duration field is not an integer");
752
+ return number === 0 ? 0 : number;
577
753
  }
578
754
  // packages/ecma402-abstract/DurationFormat/ToDurationRecord.js
755
+ const durationPropertyNames = [
756
+ "days",
757
+ "hours",
758
+ "microseconds",
759
+ "milliseconds",
760
+ "minutes",
761
+ "months",
762
+ "nanoseconds",
763
+ "seconds",
764
+ "weeks",
765
+ "years"
766
+ ];
579
767
  function ToDurationRecord(input) {
580
- if ((typeof input !== "object" || input === null) && typeof input !== "function") {
581
- if (typeof input === "string") throw new RangeError("Invalid duration format");
582
- throw new TypeError("Invalid duration");
768
+ if (!IsObject(input)) {
769
+ if (typeof input === "string") throw new RangeErrorConstructor("Invalid duration format");
770
+ throw new TypeErrorConstructor$1("Invalid duration");
583
771
  }
584
772
  const result = {
585
773
  years: 0,
@@ -594,26 +782,16 @@ function ToDurationRecord(input) {
594
782
  nanoseconds: 0
595
783
  };
596
784
  let anyDefined = false;
597
- for (const field of [
598
- "days",
599
- "hours",
600
- "microseconds",
601
- "milliseconds",
602
- "minutes",
603
- "months",
604
- "nanoseconds",
605
- "seconds",
606
- "weeks",
607
- "years"
608
- ]) {
785
+ for (let index = 0; index < durationPropertyNames.length; index++) {
786
+ const field = durationPropertyNames[index];
609
787
  const value = input[field];
610
788
  if (value !== void 0) {
611
789
  anyDefined = true;
612
790
  result[field] = ToIntegerIfIntegral(value);
613
791
  }
614
792
  }
615
- if (!anyDefined) throw new TypeError("Invalid duration format");
616
- if (!IsValidDurationRecord(result)) throw new RangeError("Invalid duration format");
793
+ if (!anyDefined) throw new TypeErrorConstructor$1("Invalid duration format");
794
+ if (!IsValidDurationRecord(result)) throw new RangeErrorConstructor("Invalid duration format");
617
795
  return result;
618
796
  }
619
797
  // packages/ecma402-abstract/DurationFormat/ToTemporalDurationRecord.js
@@ -633,11 +811,11 @@ const apply = Reflect.apply;
633
811
  const readers = [];
634
812
  function registerTemporalDurationNamespace(namespace) {
635
813
  const constructor = namespace?.Duration;
636
- if (!constructor || readers.some((reader) => reader.constructor === constructor)) return;
814
+ if (!constructor || arraySome(readers, (reader) => reader.constructor === constructor)) return;
637
815
  const from = constructor.from, prototype = constructor.prototype;
638
816
  if (typeof from !== "function" || prototype === null || typeof prototype !== "object" && typeof prototype !== "function") return;
639
817
  const getters = fields.map((field) => Object.getOwnPropertyDescriptor(prototype, field)?.get);
640
- if (getters.some((getter) => typeof getter !== "function")) return;
818
+ if (arraySome(getters, (getter) => typeof getter !== "function")) return;
641
819
  readers.push({
642
820
  constructor,
643
821
  from,
@@ -651,14 +829,15 @@ function ToTemporalDurationRecord(input) {
651
829
  const reader = readers[readers.length - 1];
652
830
  input = apply(reader.from, reader.constructor, [input]);
653
831
  }
654
- if (input !== null && (typeof input === "object" || typeof input === "function")) for (const reader of readers) {
832
+ if (input !== null && (typeof input === "object" || typeof input === "function")) for (let index = 0; index < readers.length; index++) {
833
+ const reader = readers[index];
655
834
  let years;
656
835
  try {
657
836
  years = apply(reader.getters[0], input, []);
658
837
  } catch {
659
838
  continue;
660
839
  }
661
- const record = Object.create(null);
840
+ const record = { __proto__: null };
662
841
  record.years = years;
663
842
  for (let index = 1; index < fields.length; index++) record[fields[index]] = apply(reader.getters[index], input, []);
664
843
  return record;
@@ -1372,20 +1551,63 @@ const TIME_SEPARATORS = {
1372
1551
  };
1373
1552
  // packages/intl-durationformat/core.ts
1374
1553
  const numberingSystemsByConstructor = /* @__PURE__ */ new WeakMap();
1554
+ const getNumberingSystems = numberingSystemsByConstructor.get.bind(numberingSystemsByConstructor);
1555
+ const setNumberingSystems = numberingSystemsByConstructor.set.bind(numberingSystemsByConstructor);
1556
+ const createObject = Object.create;
1557
+ const providerApply = Reflect.apply;
1558
+ const providerDescriptor = Object.getOwnPropertyDescriptor;
1559
+ const providerPrototype = Object.getPrototypeOf;
1560
+ const resolvedMethods = /* @__PURE__ */ new WeakMap();
1561
+ const getResolvedMethod = resolvedMethods.get.bind(resolvedMethods);
1562
+ const setResolvedMethod = resolvedMethods.set.bind(resolvedMethods);
1563
+ function numberFormatResolvedOptions(Constructor) {
1564
+ let prototype = Constructor.prototype;
1565
+ while (prototype !== null) {
1566
+ const cached = getResolvedMethod(prototype);
1567
+ if (cached) return cached;
1568
+ const descriptor = providerDescriptor(prototype, "resolvedOptions");
1569
+ const value = descriptor && providerDescriptor(descriptor, "value");
1570
+ if (typeof value?.value === "function") {
1571
+ const method = value.value;
1572
+ setResolvedMethod(prototype, method);
1573
+ return method;
1574
+ }
1575
+ prototype = providerPrototype(prototype);
1576
+ }
1577
+ }
1578
+ const initialNumberFormat = getNumberFormatProvider();
1579
+ if (typeof initialNumberFormat === "function") numberFormatResolvedOptions(initialNumberFormat);
1580
+ const NumberingSet = Set;
1581
+ const numberingAdd = Set.prototype.add;
1582
+ const numberingValues = Set.prototype.values;
1583
+ const numberingNext = providerPrototype(new NumberingSet().values()).next;
1584
+ function numberingUnion(first, second) {
1585
+ const unique = new NumberingSet();
1586
+ for (let index = 0; index < first.length; index++) providerApply(numberingAdd, unique, [first[index]]);
1587
+ for (let index = 0; index < second.length; index++) providerApply(numberingAdd, unique, [second[index]]);
1588
+ const iterator = providerApply(numberingValues, unique, []);
1589
+ const result = [];
1590
+ for (;;) {
1591
+ const next = providerApply(numberingNext, iterator, []);
1592
+ if (next.done) return result;
1593
+ setDataProperty(result, `${result.length}`, next.value);
1594
+ }
1595
+ }
1375
1596
  function supportedNumberingSystems() {
1376
- const NumberFormat = Intl.NumberFormat;
1377
- let systems = numberingSystemsByConstructor.get(NumberFormat);
1597
+ const NumberFormat = getNumberFormatProvider();
1598
+ let systems = getNumberingSystems(NumberFormat);
1378
1599
  if (!systems) {
1379
- systems = numberingSystemNames.filter((numberingSystem) => {
1380
- const options = Object.create(null);
1600
+ systems = [];
1601
+ const resolvedOptions = numberFormatResolvedOptions(NumberFormat);
1602
+ for (let index = 0; index < numberingSystemNames.length; index++) {
1603
+ const numberingSystem = numberingSystemNames[index];
1604
+ const options = createObject(null);
1381
1605
  options.numberingSystem = numberingSystem;
1382
1606
  try {
1383
- return new NumberFormat("en", options).resolvedOptions().numberingSystem === numberingSystem;
1384
- } catch {
1385
- return false;
1386
- }
1387
- });
1388
- if (systems.length) numberingSystemsByConstructor.set(NumberFormat, systems);
1607
+ if (resolvedOptions && providerApply(resolvedOptions, new NumberFormat("en", options), []).numberingSystem === numberingSystem) setDataProperty(systems, `${systems.length}`, numberingSystem);
1608
+ } catch {}
1609
+ }
1610
+ if (systems.length) setNumberingSystems(NumberFormat, systems);
1389
1611
  }
1390
1612
  return systems;
1391
1613
  }
@@ -1545,13 +1767,13 @@ var DurationFormat = class DurationFormat {
1545
1767
  registerTemporalDurationNamespace(namespace);
1546
1768
  }
1547
1769
  constructor(locales, options) {
1548
- if (!(this && this instanceof DurationFormat ? this.constructor : void 0)) throw new TypeError("Intl.DurationFormat must be called with 'new'");
1770
+ if (!new.target) throw new TypeErrorConstructor$1("Intl.DurationFormat must be called with 'new'");
1549
1771
  const requestedLocales = CanonicalizeLocaleList(locales);
1550
- const opt = Object.create(null);
1551
- const opts = options === void 0 ? Object.create(null) : ToObject(options);
1772
+ const opt = createObject(null);
1773
+ const opts = options === void 0 ? createObject(null) : ToObject(options);
1552
1774
  const matcher = GetOption(opts, "localeMatcher", "string", ["best fit", "lookup"], "best fit");
1553
1775
  const numberingSystem = GetOption(opts, "numberingSystem", "string", void 0, void 0);
1554
- if (numberingSystem !== void 0 && !IsUnicodeLocaleIdentifierType(numberingSystem)) throw RangeError(`Invalid numberingSystems: ${numberingSystem}`);
1776
+ if (numberingSystem !== void 0 && !IsUnicodeLocaleIdentifierType(numberingSystem)) throw RangeErrorConstructor(`Invalid numberingSystems: ${numberingSystem}`);
1555
1777
  opt.nu = numberingSystem;
1556
1778
  opt.localeMatcher = matcher;
1557
1779
  const { localeData, availableLocales } = DurationFormat;
@@ -1570,14 +1792,15 @@ var DurationFormat = class DurationFormat {
1570
1792
  internalSlots.style = style;
1571
1793
  internalSlots.dataLocale = r.dataLocale;
1572
1794
  let prevStyle = "";
1573
- TABLE_3.forEach((row) => {
1574
- const { styleSlot, displaySlot, unit, values: valueList, digitalDefault: digitalBase } = row;
1795
+ for (let index = 0; index < TABLE_3.length; index++) {
1796
+ const { styleSlot, displaySlot, unit, values: valueList, digitalDefault: digitalBase } = TABLE_3[index];
1575
1797
  const unitOptions = GetDurationUnitOptions(unit, opts, style, valueList, digitalBase, prevStyle);
1576
1798
  internalSlots[styleSlot] = unitOptions.style;
1577
1799
  internalSlots[displaySlot] = unitOptions.display;
1578
1800
  if (unit === "hours" || unit === "minutes" || unit === "seconds" || unit === "milliseconds" || unit === "microseconds") prevStyle = unitOptions.style;
1579
- });
1801
+ }
1580
1802
  internalSlots.fractionalDigits = GetNumberOption(opts, "fractionalDigits", 0, 9, void 0);
1803
+ initializeDurationFormatProviders(this);
1581
1804
  }
1582
1805
  resolvedOptions() {
1583
1806
  if (typeof this !== "object" || !OrdinaryHasInstance(DurationFormat, this)) throw TypeError("Method Intl.DurationFormat.prototype.resolvedOptions called on incompatible receiver");
@@ -1599,13 +1822,14 @@ var DurationFormat = class DurationFormat {
1599
1822
  const record = ToTemporalDurationRecord(duration);
1600
1823
  const parts = PartitionDurationFormatPattern(this, record);
1601
1824
  const result = [];
1602
- for (const { type, unit, value } of parts) {
1825
+ for (let index = 0; index < parts.length; index++) {
1826
+ const { type, unit, value } = parts[index];
1603
1827
  const obj = {
1604
1828
  type,
1605
1829
  value
1606
1830
  };
1607
- if (unit) obj.unit = unit;
1608
- result.push(obj);
1831
+ if (unit) setDataProperty(obj, "unit", unit);
1832
+ setDataProperty(result, `${result.length}`, obj);
1609
1833
  }
1610
1834
  return result;
1611
1835
  }
@@ -1614,7 +1838,7 @@ var DurationFormat = class DurationFormat {
1614
1838
  const record = ToTemporalDurationRecord(duration);
1615
1839
  const parts = PartitionDurationFormatPattern(this, record);
1616
1840
  let result = "";
1617
- for (const { value } of parts) result += value;
1841
+ for (let index = 0; index < parts.length; index++) result += parts[index].value;
1618
1842
  return result;
1619
1843
  }
1620
1844
  static supportedLocalesOf(locales, options) {
@@ -1632,7 +1856,7 @@ var DurationFormat = class DurationFormat {
1632
1856
  all[locale] = {
1633
1857
  get nu() {
1634
1858
  const defaults = TIME_SEPARATORS.localeData[locale].nu;
1635
- return [.../* @__PURE__ */ new Set([...defaults, ...supportedNumberingSystems()])];
1859
+ return numberingUnion(defaults, supportedNumberingSystems());
1636
1860
  },
1637
1861
  digitalFormat: {
1638
1862
  default: TIME_SEPARATORS.default,