@formatjs/intl-durationformat 0.13.1 → 0.13.2

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/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { LookupSupportedLocales, ResolveLocale } from "@formatjs/intl-localematcher";
1
+ import { FilterLocales, ResolveLocale } from "@formatjs/intl-localematcher";
2
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 = [
@@ -102,23 +102,33 @@ const numberingSystemNames = [
102
102
  ];
103
103
  // packages/ecma402-abstract/IsUnicodeLocaleIdentifierType.js
104
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;
105
+ const charCodeAt = String.prototype.charCodeAt;
107
106
  /** Tests the Unicode locale identifier `type` grammar, not locale support. */
108
107
  function IsUnicodeLocaleIdentifierType(value) {
109
- return typeApply(typeExec, typePattern, [value]) !== null;
110
- }
111
- // packages/ecma262-abstract/OrdinaryHasInstance.js
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]);
108
+ let length = 0;
109
+ for (let index = 0; index < value.length; index++) {
110
+ const code = typeApply(charCodeAt, value, [index]);
111
+ if (code === 45) {
112
+ if (length < 3) return false;
113
+ length = 0;
114
+ continue;
115
+ }
116
+ const letter = code | 32;
117
+ if (!(letter >= 97 && letter <= 122) && !(code >= 48 && code <= 57)) return false;
118
+ if (++length > 8) return false;
119
+ }
120
+ return length >= 3;
117
121
  }
118
122
  // packages/ecma262-abstract/intrinsics.js
119
123
  const floor = Math.floor;
124
+ const numberFrom = Number;
120
125
  const bigIntFrom = BigInt;
121
126
  const objectFrom = Object;
127
+ const objectCreate = Object.create;
128
+ function createFromConstructor(newTarget, defaultPrototype) {
129
+ const prototype = newTarget.prototype;
130
+ return objectCreate(objectFrom(prototype) === prototype ? prototype : defaultPrototype);
131
+ }
122
132
  const mathAbs = Math.abs;
123
133
  const numberIsInteger = Number.isInteger;
124
134
  const numberIsFinite = Number.isFinite;
@@ -144,64 +154,42 @@ function setDataProperty(target, key, value) {
144
154
  configurable: true
145
155
  });
146
156
  }
147
- // packages/ecma262-abstract/ToObject.js
148
- /**
149
- * https://tc39.es/ecma262/#sec-toobject
150
- */
151
- function ToObject(arg) {
152
- if (arg === void 0 || arg === null) throw new TypeErrorConstructor$1("undefined/null cannot be converted to object");
153
- return objectFrom(arg);
154
- }
155
157
  // packages/ecma402-abstract/CanonicalizeLocaleList.js
156
158
  let canonicalIntl = globalThis.Intl;
157
159
  const canonicalDescriptor = Object.getOwnPropertyDescriptor;
158
160
  const canonicalApply = Reflect.apply;
161
+ const providerKey = Symbol.for("@formatjs/intlCanonicalizeLocaleList");
159
162
  function ownCanonicalProvider() {
160
163
  const descriptor = canonicalIntl && canonicalDescriptor(canonicalIntl, "getCanonicalLocales");
161
164
  return (descriptor && canonicalDescriptor(descriptor, "value"))?.value;
162
165
  }
163
166
  let canonicalProvider = ownCanonicalProvider();
164
- /**
165
- * http://ecma-international.org/ecma-402/7.0/index.html#sec-canonicalizelocalelist
166
- * @param locales
167
- */
167
+ function registeredCanonicalProvider() {
168
+ try {
169
+ const descriptor = canonicalIntl && canonicalDescriptor(canonicalIntl, providerKey);
170
+ return descriptor && canonicalDescriptor(descriptor, "value")?.value;
171
+ } catch {}
172
+ }
168
173
  function CanonicalizeLocaleList(locales) {
169
174
  if (canonicalIntl === void 0) canonicalIntl = globalThis.Intl;
170
- const candidate = ownCanonicalProvider();
171
- if (typeof candidate === "function") canonicalProvider = candidate;
175
+ const registered = registeredCanonicalProvider();
176
+ if (typeof registered === "function") return canonicalApply(registered, canonicalIntl, [locales]);
177
+ if (typeof canonicalProvider !== "function") canonicalProvider = ownCanonicalProvider();
172
178
  return canonicalApply(canonicalProvider, canonicalIntl, [locales]);
173
179
  }
174
180
  // packages/ecma402-abstract/DefaultNumberOption.js
175
- /**
176
- * ECMA-402 §9.2.13 DefaultNumberOption, step 2.
177
- * https://tc39.es/ecma402/#sec-defaultnumberoption
178
- * https://github.com/tc39/ecma402/blob/b1c961988b9a07894b1dc3dc2b5626ea48387d61/spec/negotiation.html#L437
179
- * @param val
180
- * @param min
181
- * @param max
182
- * @param fallback
183
- */
184
181
  function DefaultNumberOption(inputVal, min, max, fallback) {
185
182
  if (inputVal === void 0) return fallback;
186
183
  const val = +inputVal;
187
- if (val !== val || val < min || val > max) throw new RangeErrorConstructor(`${val} is outside of range [${min}, ${max}]`);
188
- return floor(val);
184
+ if (!numberIsFinite(val) || val < min || val > max) throw new RangeErrorConstructor(`${val} is outside of range [${min}, ${max}]`);
185
+ return val === 0 ? 0 : floor(val);
189
186
  }
190
187
  // packages/ecma402-abstract/GetNumberOption.js
191
- /**
192
- * https://tc39.es/ecma402/#sec-getnumberoption
193
- * @param options
194
- * @param property
195
- * @param min
196
- * @param max
197
- * @param fallback
198
- */
199
188
  function GetNumberOption(options, property, minimum, maximum, fallback) {
200
189
  const val = options[property];
201
190
  return DefaultNumberOption(val, minimum, maximum, fallback);
202
191
  }
203
192
  // packages/ecma262-abstract/IsObject.js
204
- /** Includes browser host objects such as document.all. */
205
193
  function IsObject(value) {
206
194
  return value !== null && (typeof value === "object" || typeof value === "function" || typeof value === "undefined" && value !== void 0);
207
195
  }
@@ -231,28 +219,49 @@ function GetOption(opts, prop, type, values, fallback) {
231
219
  let value = opts[prop];
232
220
  if (value !== void 0) {
233
221
  if (type !== "boolean" && type !== "string") throw new TypeErrorConstructor$1("invalid type");
234
- if (type === "boolean") value = Boolean(value);
222
+ if (type === "boolean") value = !!value;
235
223
  if (type === "string") value = ToString(value);
236
- if (values !== void 0 && !arraySome(values, (val) => val == value)) throw new RangeErrorConstructor(`${value} is not within ${optionApply(optionJoin, values, [", "])}`);
224
+ if (values?.length && !arraySome(values, (val) => val === value)) throw new RangeErrorConstructor(`${value} is not within ${optionApply(optionJoin, values, [", "])}`);
237
225
  return value;
238
226
  }
239
227
  return fallback;
240
228
  }
241
- // packages/ecma402-abstract/SupportedLocales.js
229
+ // packages/ecma402-abstract/GetOptionsObject.js
230
+ const createObject$2 = Object.create;
231
+ /**
232
+ * ECMA-262 §7.3.36 GetOptionsObject, steps 1–3.
233
+ * https://tc39.es/ecma262/#sec-getoptionsobject
234
+ * @param options
235
+ * @returns
236
+ */
237
+ function GetOptionsObject(options) {
238
+ if (options === void 0) return createObject$2(null);
239
+ if (IsObject(options)) return options;
240
+ throw new TypeErrorConstructor$1("Options must be an object");
241
+ }
242
+ // packages/ecma262-abstract/ToObject.js
243
+ /**
244
+ * https://tc39.es/ecma262/#sec-toobject
245
+ */
246
+ function ToObject(arg) {
247
+ if (arg === void 0 || arg === null) throw new TypeErrorConstructor$1("undefined/null cannot be converted to object");
248
+ return objectFrom(arg);
249
+ }
250
+ // packages/ecma402-abstract/CoerceOptionsToObject.js
251
+ const createObject$1 = Object.create;
242
252
  /**
243
- * https://tc39.es/ecma402/#sec-supportedlocales
244
- * @param availableLocales
245
- * @param requestedLocales
253
+ * https://tc39.es/ecma402/#sec-coerceoptionstoobject
246
254
  * @param options
255
+ * @returns
247
256
  */
257
+ function CoerceOptionsToObject(options) {
258
+ if (options === void 0) return createObject$1(null);
259
+ return ToObject(options);
260
+ }
261
+ // packages/ecma402-abstract/SupportedLocales.js
248
262
  function SupportedLocales(availableLocales, requestedLocales, options) {
249
- let matcher = "best fit";
250
- if (options !== void 0) {
251
- options = ToObject(options);
252
- matcher = GetOption(options, "localeMatcher", "string", ["lookup", "best fit"], "best fit");
253
- }
254
- if (matcher === "best fit") return LookupSupportedLocales(Array.from(availableLocales), requestedLocales);
255
- return LookupSupportedLocales(Array.from(availableLocales), requestedLocales);
263
+ const matcher = GetOption(CoerceOptionsToObject(options), "localeMatcher", "string", ["lookup", "best fit"], "best fit");
264
+ return FilterLocales(availableLocales, requestedLocales, matcher, true);
256
265
  }
257
266
  // node_modules/.aspect_rules_js/@formatjs+fast-memoize@0.0.0/node_modules/@formatjs/fast-memoize/index.js
258
267
  const apply$2 = Reflect.apply;
@@ -339,12 +348,13 @@ const strategies = {
339
348
  variadic: strategyVariadic,
340
349
  monadic: strategyMonadic
341
350
  };
342
- // packages/ecma402-abstract/utils.js
351
+ String.prototype.repeat;
352
+ Array.from;
353
+ Array.prototype.join;
343
354
  function invariant(condition, message, Err = ErrorConstructor) {
344
355
  if (!condition) throw new Err(message);
345
356
  }
346
357
  memoize((...args) => new Intl.NumberFormat(...args), { strategy: strategies.variadic });
347
- memoize((...args) => new Intl.PluralRules(...args), { strategy: strategies.variadic });
348
358
  memoize((...args) => new Intl.ListFormat(...args), { strategy: strategies.variadic });
349
359
  const getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
350
360
  const formatterMemoizeOptions = {
@@ -356,58 +366,77 @@ function ownIntlProvider(name) {
356
366
  const descriptor = providerIntl && getOwnPropertyDescriptor(providerIntl, name);
357
367
  return (descriptor && getOwnPropertyDescriptor(descriptor, "value"))?.value;
358
368
  }
359
- let numberFormatProvider = ownIntlProvider("NumberFormat");
360
- let listFormatProvider = ownIntlProvider("ListFormat");
361
- function getNumberFormatProvider() {
362
- const candidate = ownIntlProvider("NumberFormat");
363
- if (typeof candidate === "function") numberFormatProvider = candidate;
364
- return numberFormatProvider;
369
+ let numberFormatIntrinsic = ownIntlProvider("NumberFormat");
370
+ let listFormatIntrinsic = ownIntlProvider("ListFormat");
371
+ let pluralRulesProvider = ownIntlProvider("PluralRules");
372
+ const formatterIntrinsicKeys = {
373
+ NumberFormat: Symbol.for("@formatjs/intlNumberFormat"),
374
+ ListFormat: Symbol.for("@formatjs/intlListFormat"),
375
+ PluralRules: Symbol.for("@formatjs/intlPluralRules")
376
+ };
377
+ function getNumberFormatIntrinsic() {
378
+ if (providerIntl === void 0) providerIntl = globalThis.Intl;
379
+ const registered = ownIntlProvider(formatterIntrinsicKeys.NumberFormat);
380
+ if (typeof registered === "function") return registered;
381
+ if (typeof numberFormatIntrinsic !== "function") numberFormatIntrinsic = ownIntlProvider("NumberFormat");
382
+ return numberFormatIntrinsic;
365
383
  }
366
- function getListFormatProvider() {
367
- const candidate = ownIntlProvider("ListFormat");
368
- if (typeof candidate === "function") listFormatProvider = candidate;
369
- return listFormatProvider;
384
+ function getListFormatIntrinsic() {
385
+ if (providerIntl === void 0) providerIntl = globalThis.Intl;
386
+ const registered = ownIntlProvider(formatterIntrinsicKeys.ListFormat);
387
+ if (typeof registered === "function") return registered;
388
+ if (typeof listFormatIntrinsic !== "function") listFormatIntrinsic = ownIntlProvider("ListFormat");
389
+ return listFormatIntrinsic;
370
390
  }
371
391
  const getFormatterPrototype = Object.getPrototypeOf;
372
- const formatterPartsMethods = /* @__PURE__ */ new WeakMap();
373
- const formatterPartsOwners = /* @__PURE__ */ new WeakMap();
374
- const getPartsMethod = formatterPartsMethods.get.bind(formatterPartsMethods);
375
- const setPartsMethod = formatterPartsMethods.set.bind(formatterPartsMethods);
376
- const getPartsOwner = formatterPartsOwners.get.bind(formatterPartsOwners);
377
- const setPartsOwner = formatterPartsOwners.set.bind(formatterPartsOwners);
378
- function findFormatterPartsMethod(Constructor) {
379
- const cached = getPartsMethod(Constructor);
380
- if (cached) return cached;
381
- let prototype = getOwnPropertyDescriptor(Constructor, "prototype")?.value;
382
- while (prototype != null) {
383
- const inherited = getPartsOwner(prototype);
384
- if (inherited) {
385
- setPartsMethod(Constructor, inherited);
386
- return inherited;
387
- }
388
- const descriptor = getOwnPropertyDescriptor(prototype, "formatToParts");
389
- const value = descriptor && getOwnPropertyDescriptor(descriptor, "value");
390
- if (value && typeof value.value === "function") {
391
- setPartsMethod(Constructor, value.value);
392
- setPartsOwner(prototype, value.value);
393
- return value.value;
392
+ function formatterMethodLookup(name) {
393
+ const methods = /* @__PURE__ */ new WeakMap();
394
+ const owners = /* @__PURE__ */ new WeakMap();
395
+ const getMethod = methods.get.bind(methods);
396
+ const setMethod = methods.set.bind(methods);
397
+ const getOwner = owners.get.bind(owners);
398
+ const setOwner = owners.set.bind(owners);
399
+ return (Constructor) => {
400
+ const cached = getMethod(Constructor);
401
+ if (cached) return cached;
402
+ let prototype = getOwnPropertyDescriptor(Constructor, "prototype")?.value;
403
+ while (prototype != null) {
404
+ const inherited = getOwner(prototype);
405
+ if (inherited) {
406
+ setMethod(Constructor, inherited);
407
+ return inherited;
408
+ }
409
+ const descriptor = getOwnPropertyDescriptor(prototype, name);
410
+ const value = descriptor && getOwnPropertyDescriptor(descriptor, "value");
411
+ if (value && typeof value.value === "function") {
412
+ const method = value.value;
413
+ setMethod(Constructor, method);
414
+ setOwner(prototype, method);
415
+ return method;
416
+ }
417
+ prototype = getFormatterPrototype(prototype);
394
418
  }
395
- prototype = getFormatterPrototype(prototype);
396
- }
419
+ };
397
420
  }
421
+ const findFormatterPartsMethod = formatterMethodLookup("formatToParts");
422
+ const findPluralRulesSelectMethod = formatterMethodLookup("select");
398
423
  function getFormatterPartsMethod(Constructor) {
399
424
  const method = findFormatterPartsMethod(Constructor);
400
425
  if (!method) throw new TypeErrorConstructor$1("Missing supplied formatter parts method");
401
426
  return method;
402
427
  }
403
- if (typeof numberFormatProvider === "function") findFormatterPartsMethod(numberFormatProvider);
404
- if (typeof listFormatProvider === "function") findFormatterPartsMethod(listFormatProvider);
428
+ if (typeof numberFormatIntrinsic === "function") findFormatterPartsMethod(numberFormatIntrinsic);
429
+ if (typeof listFormatIntrinsic === "function") findFormatterPartsMethod(listFormatIntrinsic);
430
+ if (typeof pluralRulesProvider === "function") findPluralRulesSelectMethod(pluralRulesProvider);
405
431
  const numberFormatMemoizers = /* @__PURE__ */ new WeakMap();
406
432
  const getNumberFormatMemoizer = numberFormatMemoizers.get.bind(numberFormatMemoizers);
407
433
  const setNumberFormatMemoizer = numberFormatMemoizers.set.bind(numberFormatMemoizers);
408
434
  const listFormatMemoizers = /* @__PURE__ */ new WeakMap();
409
435
  const getListFormatMemoizer = listFormatMemoizers.get.bind(listFormatMemoizers);
410
436
  const setListFormatMemoizer = listFormatMemoizers.set.bind(listFormatMemoizers);
437
+ const pluralRulesMemoizers = /* @__PURE__ */ new WeakMap();
438
+ pluralRulesMemoizers.get.bind(pluralRulesMemoizers);
439
+ pluralRulesMemoizers.set.bind(pluralRulesMemoizers);
411
440
  function createMemoizedNumberFormatForConstructor(Constructor) {
412
441
  let factory = getNumberFormatMemoizer(Constructor);
413
442
  if (!factory) {
@@ -426,7 +455,8 @@ function createMemoizedListFormatForConstructor(Constructor) {
426
455
  }
427
456
  // packages/ecma402-abstract/DurationFormat/GetDurationUnitOptions.js
428
457
  function GetDurationUnitOptions(unit, options, baseStyle, stylesList, digitalBase, prevStyle, twoDigitHours = false) {
429
- let style = GetOption(options, unit, "string", stylesList, void 0);
458
+ const unitOptions = options;
459
+ let style = GetOption(unitOptions, unit, "string", stylesList, void 0);
430
460
  let displayDefault = "always";
431
461
  if (style === void 0) {
432
462
  if (baseStyle === "digital") {
@@ -444,7 +474,7 @@ function GetDurationUnitOptions(unit, options, baseStyle, stylesList, digitalBas
444
474
  style = "fractional";
445
475
  displayDefault = "auto";
446
476
  }
447
- const display = GetOption(options, `${unit}Display`, "string", ["always", "auto"], displayDefault);
477
+ const display = GetOption(unitOptions, `${unit}Display`, "string", ["always", "auto"], displayDefault);
448
478
  if (display === "always" && style === "fractional") throw new RangeErrorConstructor("Fractional units cannot use always display");
449
479
  if (prevStyle === "fractional" && style !== "fractional") throw new RangeErrorConstructor("Fractional units must be followed by fractional units");
450
480
  if ((prevStyle === "numeric" || prevStyle === "2-digit") && style !== "fractional" && style !== "numeric" && style !== "2-digit") throw new RangeErrorConstructor("Can't mix numeric and non-numeric styles");
@@ -533,6 +563,11 @@ const internalSlotMap = /* @__PURE__ */ new WeakMap();
533
563
  const getSlots = internalSlotMap.get.bind(internalSlotMap);
534
564
  const setSlots = internalSlotMap.set.bind(internalSlotMap);
535
565
  const createSlots = Object.create;
566
+ function requireInternalSlots(x) {
567
+ const slots = getSlots(x);
568
+ if (!slots?.initializedDurationFormat) throw new TypeErrorConstructor$1("Incompatible Intl.DurationFormat receiver");
569
+ return slots;
570
+ }
536
571
  function getInternalSlots(x) {
537
572
  let internalSlots = getSlots(x);
538
573
  if (!internalSlots) {
@@ -549,8 +584,8 @@ const formatterProviders = /* @__PURE__ */ new WeakMap();
549
584
  const getFormatterProviders = formatterProviders.get.bind(formatterProviders);
550
585
  const setFormatterProviders = formatterProviders.set.bind(formatterProviders);
551
586
  function initializeDurationFormatProviders(df) {
552
- const NumberFormat = getNumberFormatProvider();
553
- const ListFormat = getListFormatProvider();
587
+ const NumberFormat = getNumberFormatIntrinsic();
588
+ const ListFormat = getListFormatIntrinsic();
554
589
  setFormatterProviders(df, {
555
590
  numberFormat: createMemoizedNumberFormatForConstructor(NumberFormat),
556
591
  listFormat: createMemoizedListFormatForConstructor(ListFormat),
@@ -566,11 +601,6 @@ function PartitionDurationFormatPattern(df, duration) {
566
601
  const negative = arraySome(TABLE_2, (row) => duration[row.valueField] < 0);
567
602
  const internalSlots = getInternalSlots(df);
568
603
  const providers = getFormatterProviders(df);
569
- let dataLocale = internalSlots.dataLocale;
570
- const dataLocaleData = DurationFormat.localeData[dataLocale];
571
- if (!dataLocaleData) throw new TypeError("Invalid locale");
572
- const numberingSystem = internalSlots.numberingSystem;
573
- const separator = dataLocaleData.digitalFormat[numberingSystem] ?? dataLocaleData.digitalFormat.default;
574
604
  for (let i = 0; i < TABLE_2.length && !done; i++) {
575
605
  const row = TABLE_2[i];
576
606
  let value = new BigDecimal(bigIntFrom(duration[row.valueField]));
@@ -583,7 +613,7 @@ function PartitionDurationFormatPattern(df, duration) {
583
613
  if (unit === "seconds") nextStyle = internalSlots.milliseconds;
584
614
  else if (unit === "milliseconds") nextStyle = internalSlots.microseconds;
585
615
  else nextStyle = internalSlots.nanoseconds;
586
- if (nextStyle === "numeric" || nextStyle === "fractional") {
616
+ if (nextStyle === "fractional") {
587
617
  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)));
588
618
  else if (unit === "milliseconds") value = value.plus(new BigDecimal(bigIntFrom(duration.microseconds)).div(bigIntFrom(1e3))).plus(new BigDecimal(bigIntFrom(duration.nanoseconds)).div(bigIntFrom(1e6)));
589
619
  else value = value.plus(new BigDecimal(bigIntFrom(duration.nanoseconds)).div(bigIntFrom(1e3)));
@@ -619,7 +649,8 @@ function PartitionDurationFormatPattern(df, duration) {
619
649
  list = result[result.length - 1];
620
650
  setDataProperty(list, `${list.length}`, {
621
651
  type: "literal",
622
- value: separator
652
+ value: unit === "minutes" ? internalSlots.hourMinuteSeparator : internalSlots.minuteSecondSeparator,
653
+ unit: void 0
623
654
  });
624
655
  }
625
656
  let parts = apply$1(providers.numberFormatToParts, nf, [value.isZero() && value.isNegative() ? -0 : value]);
@@ -674,7 +705,8 @@ function PartitionDurationFormatPattern(df, duration) {
674
705
  invariant(type === "literal", "Type must be literal");
675
706
  setDataProperty(flattened, `${flattened.length}`, {
676
707
  type: "literal",
677
- value
708
+ value,
709
+ unit: void 0
678
710
  });
679
711
  }
680
712
  }
@@ -722,12 +754,10 @@ function IsValidDurationRecord(record) {
722
754
  return normalizedNanoseconds > -limit && normalizedNanoseconds < limit;
723
755
  }
724
756
  // packages/ecma262-abstract/ToNumber.js
725
- /** ECMA-262 §7.1.4, via §13.5.4.1 step 2. */
726
757
  function ToNumber(arg) {
727
758
  return +arg;
728
759
  }
729
760
  // packages/ecma402-abstract/DurationFormat/ToIntegerIfIntegral.js
730
- /** ECMA-402 §13.5.2 steps 1–3. */
731
761
  function ToIntegerIfIntegral(arg) {
732
762
  const number = ToNumber(arg);
733
763
  if (!numberIsInteger(number)) throw new RangeErrorConstructor("Duration field is not an integer");
@@ -873,6 +903,7 @@ const TIME_SEPARATORS = {
873
903
  "az-Cyrl": { "nu": ["latn"] },
874
904
  "az-Latn": { "nu": ["latn"] },
875
905
  "ba": { "nu": ["latn"] },
906
+ "bal": { "nu": ["latn"] },
876
907
  "bal-Latn": { "nu": ["latn"] },
877
908
  "bas": { "nu": ["latn"] },
878
909
  "be": { "nu": ["latn"] },
@@ -896,6 +927,7 @@ const TIME_SEPARATORS = {
896
927
  "bua": { "nu": ["latn"] },
897
928
  "ca": { "nu": ["latn"] },
898
929
  "ca-AD": { "nu": ["latn"] },
930
+ "ca-ES": { "nu": ["latn"] },
899
931
  "ca-ES-valencia": { "nu": ["latn"] },
900
932
  "ca-FR": { "nu": ["latn"] },
901
933
  "ca-IT": { "nu": ["latn"] },
@@ -1117,6 +1149,13 @@ const TIME_SEPARATORS = {
1117
1149
  "ff-Adlm-NG": { "nu": ["adlm"] },
1118
1150
  "ff-Adlm-SL": { "nu": ["adlm"] },
1119
1151
  "ff-Adlm-SN": { "nu": ["adlm"] },
1152
+ "ff-BF": { "nu": ["latn"] },
1153
+ "ff-CM": { "nu": ["latn"] },
1154
+ "ff-GH": { "nu": ["latn"] },
1155
+ "ff-GM": { "nu": ["latn"] },
1156
+ "ff-GN": { "nu": ["latn"] },
1157
+ "ff-GW": { "nu": ["latn"] },
1158
+ "ff-LR": { "nu": ["latn"] },
1120
1159
  "ff-Latn": { "nu": ["latn"] },
1121
1160
  "ff-Latn-BF": { "nu": ["latn"] },
1122
1161
  "ff-Latn-CM": { "nu": ["latn"] },
@@ -1129,6 +1168,11 @@ const TIME_SEPARATORS = {
1129
1168
  "ff-Latn-NE": { "nu": ["latn"] },
1130
1169
  "ff-Latn-NG": { "nu": ["latn"] },
1131
1170
  "ff-Latn-SL": { "nu": ["latn"] },
1171
+ "ff-MR": { "nu": ["latn"] },
1172
+ "ff-NE": { "nu": ["latn"] },
1173
+ "ff-NG": { "nu": ["latn"] },
1174
+ "ff-SL": { "nu": ["latn"] },
1175
+ "ff-SN": { "nu": ["adlm"] },
1132
1176
  "fi": {
1133
1177
  "nu": ["latn"],
1134
1178
  "separator": { "latn": "." }
@@ -1257,9 +1301,11 @@ const TIME_SEPARATORS = {
1257
1301
  "ksf": { "nu": ["latn"] },
1258
1302
  "ksh": { "nu": ["latn"] },
1259
1303
  "ku": { "nu": ["latn"] },
1304
+ "ku-IQ": { "nu": ["latn"] },
1260
1305
  "ku-Latn": { "nu": ["latn"] },
1261
1306
  "ku-Latn-IQ": { "nu": ["latn"] },
1262
1307
  "ku-Latn-SY": { "nu": ["latn"] },
1308
+ "ku-SY": { "nu": ["latn"] },
1263
1309
  "ku-TR": { "nu": ["latn"] },
1264
1310
  "kw": { "nu": ["latn"] },
1265
1311
  "kxv": { "nu": ["latn"] },
@@ -1420,6 +1466,7 @@ const TIME_SEPARATORS = {
1420
1466
  "sq-MK": { "nu": ["latn"] },
1421
1467
  "sq-XK": { "nu": ["latn"] },
1422
1468
  "sr": { "nu": ["latn"] },
1469
+ "sr-BA": { "nu": ["latn"] },
1423
1470
  "sr-Cyrl": { "nu": ["latn"] },
1424
1471
  "sr-Cyrl-BA": { "nu": ["latn"] },
1425
1472
  "sr-Cyrl-ME": { "nu": ["latn"] },
@@ -1428,6 +1475,8 @@ const TIME_SEPARATORS = {
1428
1475
  "sr-Latn-BA": { "nu": ["latn"] },
1429
1476
  "sr-Latn-ME": { "nu": ["latn"] },
1430
1477
  "sr-Latn-XK": { "nu": ["latn"] },
1478
+ "sr-ME": { "nu": ["latn"] },
1479
+ "sr-XK": { "nu": ["latn"] },
1431
1480
  "st": { "nu": ["latn"] },
1432
1481
  "st-LS": { "nu": ["latn"] },
1433
1482
  "su": {
@@ -1438,6 +1487,7 @@ const TIME_SEPARATORS = {
1438
1487
  "nu": ["latn"],
1439
1488
  "separator": { "latn": "." }
1440
1489
  },
1490
+ "suz": { "nu": ["latn"] },
1441
1491
  "suz-Sunu": { "nu": ["latn"] },
1442
1492
  "sv": { "nu": ["latn"] },
1443
1493
  "sv-AX": { "nu": ["latn"] },
@@ -1512,13 +1562,16 @@ const TIME_SEPARATORS = {
1512
1562
  "yrl-CO": { "nu": ["latn"] },
1513
1563
  "yrl-VE": { "nu": ["latn"] },
1514
1564
  "yue": { "nu": ["latn"] },
1565
+ "yue-CN": { "nu": ["latn"] },
1515
1566
  "yue-Hans": { "nu": ["latn"] },
1516
1567
  "yue-Hant": { "nu": ["latn"] },
1517
1568
  "yue-Hant-CN": { "nu": ["latn"] },
1518
1569
  "yue-Hant-MO": { "nu": ["latn"] },
1570
+ "yue-MO": { "nu": ["latn"] },
1519
1571
  "za": { "nu": ["latn"] },
1520
1572
  "zgh": { "nu": ["latn"] },
1521
1573
  "zh": { "nu": ["latn"] },
1574
+ "zh-HK": { "nu": ["latn"] },
1522
1575
  "zh-Hans": { "nu": ["latn"] },
1523
1576
  "zh-Hans-HK": { "nu": ["latn"] },
1524
1577
  "zh-Hans-MO": { "nu": ["latn"] },
@@ -1528,14 +1581,22 @@ const TIME_SEPARATORS = {
1528
1581
  "zh-Hant-HK": { "nu": ["latn"] },
1529
1582
  "zh-Hant-MO": { "nu": ["latn"] },
1530
1583
  "zh-Hant-MY": { "nu": ["latn"] },
1584
+ "zh-MO": { "nu": ["latn"] },
1585
+ "zh-MY": { "nu": ["latn"] },
1586
+ "zh-SG": { "nu": ["latn"] },
1531
1587
  "zu": { "nu": ["latn"] }
1532
1588
  }
1533
1589
  };
1534
1590
  // packages/intl-durationformat/core.ts
1591
+ let defaultLocale = "en";
1592
+ function getDefaultLocale() {
1593
+ return defaultLocale;
1594
+ }
1535
1595
  const numberingSystemsByConstructor = /* @__PURE__ */ new WeakMap();
1536
1596
  const getNumberingSystems = numberingSystemsByConstructor.get.bind(numberingSystemsByConstructor);
1537
1597
  const setNumberingSystems = numberingSystemsByConstructor.set.bind(numberingSystemsByConstructor);
1538
1598
  const createObject = Object.create;
1599
+ const hasOwn = Function.prototype.call.bind(Object.prototype.hasOwnProperty);
1539
1600
  const providerApply = Reflect.apply;
1540
1601
  const providerDescriptor = Object.getOwnPropertyDescriptor;
1541
1602
  const providerPrototype = Object.getPrototypeOf;
@@ -1557,7 +1618,7 @@ function numberFormatResolvedOptions(Constructor) {
1557
1618
  prototype = providerPrototype(prototype);
1558
1619
  }
1559
1620
  }
1560
- const initialNumberFormat = getNumberFormatProvider();
1621
+ const initialNumberFormat = getNumberFormatIntrinsic();
1561
1622
  if (typeof initialNumberFormat === "function") numberFormatResolvedOptions(initialNumberFormat);
1562
1623
  const NumberingSet = Set;
1563
1624
  const numberingAdd = Set.prototype.add;
@@ -1576,7 +1637,7 @@ function numberingUnion(first, second) {
1576
1637
  }
1577
1638
  }
1578
1639
  function supportedNumberingSystems() {
1579
- const NumberFormat = getNumberFormatProvider();
1640
+ const NumberFormat = getNumberFormatIntrinsic();
1580
1641
  let systems = getNumberingSystems(NumberFormat);
1581
1642
  if (!systems) {
1582
1643
  systems = [];
@@ -1744,27 +1805,33 @@ const TABLE_3 = [
1744
1805
  * DurationFormat provides locale-sensitive duration formatting
1745
1806
  * Implements the Intl.DurationFormat API from the TC39 proposal
1746
1807
  */
1747
- var DurationFormat = class DurationFormat {
1808
+ var DurationFormat = class DurationFormat extends null {
1748
1809
  static __addTemporalNamespace(namespace) {
1749
1810
  registerTemporalDurationNamespace(namespace);
1750
1811
  }
1751
1812
  constructor(locales, options) {
1752
- if (!new.target) throw new TypeErrorConstructor$1("Intl.DurationFormat must be called with 'new'");
1813
+ const receiver = createFromConstructor(new.target, DurationFormat.prototype);
1753
1814
  const requestedLocales = CanonicalizeLocaleList(locales);
1754
1815
  const opt = createObject(null);
1755
- const opts = options === void 0 ? createObject(null) : ToObject(options);
1816
+ const opts = GetOptionsObject(options);
1756
1817
  const matcher = GetOption(opts, "localeMatcher", "string", ["best fit", "lookup"], "best fit");
1757
1818
  const numberingSystem = GetOption(opts, "numberingSystem", "string", void 0, void 0);
1758
1819
  if (numberingSystem !== void 0 && !IsUnicodeLocaleIdentifierType(numberingSystem)) throw RangeErrorConstructor(`Invalid numberingSystems: ${numberingSystem}`);
1759
1820
  opt.nu = numberingSystem;
1760
1821
  opt.localeMatcher = matcher;
1761
1822
  const { localeData, availableLocales } = DurationFormat;
1762
- const r = ResolveLocale(availableLocales, requestedLocales, opt, ["nu"], localeData, DurationFormat.getDefaultLocale);
1823
+ const r = ResolveLocale(availableLocales, requestedLocales, opt, ["nu"], localeData, getDefaultLocale, "hostDefaultWithLocaleData");
1763
1824
  const locale = r.locale;
1764
- const internalSlots = getInternalSlots(this);
1825
+ const internalSlots = getInternalSlots(receiver);
1765
1826
  internalSlots.initializedDurationFormat = true;
1766
1827
  internalSlots.locale = locale;
1767
1828
  internalSlots.numberingSystem = r.nu;
1829
+ internalSlots.dataLocale = r.dataLocale;
1830
+ const digitalFormat = r.localeData?.digitalFormat;
1831
+ invariant(!!digitalFormat, `Invalid locale ${r.dataLocale}`);
1832
+ const separator = hasOwn(digitalFormat, r.nu) ? digitalFormat[r.nu] : digitalFormat.default;
1833
+ internalSlots.hourMinuteSeparator = separator;
1834
+ internalSlots.minuteSecondSeparator = separator;
1768
1835
  const style = GetOption(opts, "style", "string", [
1769
1836
  "long",
1770
1837
  "short",
@@ -1772,35 +1839,36 @@ var DurationFormat = class DurationFormat {
1772
1839
  "digital"
1773
1840
  ], "short");
1774
1841
  internalSlots.style = style;
1775
- internalSlots.dataLocale = r.dataLocale;
1776
1842
  let prevStyle = "";
1843
+ const unitStyles = internalSlots;
1777
1844
  for (let index = 0; index < TABLE_3.length; index++) {
1778
1845
  const { styleSlot, displaySlot, unit, values: valueList, digitalDefault: digitalBase } = TABLE_3[index];
1779
1846
  const unitOptions = GetDurationUnitOptions(unit, opts, style, valueList, digitalBase, prevStyle);
1780
- internalSlots[styleSlot] = unitOptions.style;
1847
+ unitStyles[styleSlot] = unitOptions.style;
1781
1848
  internalSlots[displaySlot] = unitOptions.display;
1782
1849
  if (unit === "hours" || unit === "minutes" || unit === "seconds" || unit === "milliseconds" || unit === "microseconds") prevStyle = unitOptions.style;
1783
1850
  }
1784
1851
  internalSlots.fractionalDigits = GetNumberOption(opts, "fractionalDigits", 0, 9, void 0);
1785
- initializeDurationFormatProviders(this);
1852
+ initializeDurationFormatProviders(receiver);
1853
+ return receiver;
1786
1854
  }
1787
1855
  resolvedOptions() {
1788
- if (typeof this !== "object" || !OrdinaryHasInstance(DurationFormat, this)) throw TypeError("Method Intl.DurationFormat.prototype.resolvedOptions called on incompatible receiver");
1789
- const internalSlots = getInternalSlots(this);
1856
+ const internalSlots = requireInternalSlots(this);
1790
1857
  const ro = {};
1791
- for (const key of RESOLVED_OPTIONS_KEYS) {
1858
+ for (let index = 0; index < RESOLVED_OPTIONS_KEYS.length; index++) {
1859
+ const key = RESOLVED_OPTIONS_KEYS[index];
1792
1860
  let v = internalSlots[key];
1793
1861
  if (key === "fractionalDigits") {
1794
1862
  if (v === void 0) continue;
1795
- v = Number(v);
1863
+ v = numberFrom(v);
1796
1864
  } else if (v === "fractional") v = "numeric";
1797
1865
  else invariant(v !== void 0, `Missing internal slot ${key}`);
1798
- ro[key] = v;
1866
+ setDataProperty(ro, key, v);
1799
1867
  }
1800
1868
  return ro;
1801
1869
  }
1802
1870
  formatToParts(duration) {
1803
- if (getInternalSlots(this).initializedDurationFormat === void 0) throw new TypeError("Error uninitialized locale");
1871
+ requireInternalSlots(this);
1804
1872
  const record = ToTemporalDurationRecord(duration);
1805
1873
  const parts = PartitionDurationFormatPattern(this, record);
1806
1874
  const result = [];
@@ -1816,7 +1884,7 @@ var DurationFormat = class DurationFormat {
1816
1884
  return result;
1817
1885
  }
1818
1886
  format(duration) {
1819
- if (getInternalSlots(this).initializedDurationFormat === void 0) throw new TypeError("Error uninitialized locale");
1887
+ requireInternalSlots(this);
1820
1888
  const record = ToTemporalDurationRecord(duration);
1821
1889
  const parts = PartitionDurationFormatPattern(this, record);
1822
1890
  let result = "";
@@ -1826,9 +1894,6 @@ var DurationFormat = class DurationFormat {
1826
1894
  static supportedLocalesOf(locales, options) {
1827
1895
  return SupportedLocales(DurationFormat.availableLocales, CanonicalizeLocaleList(locales), options);
1828
1896
  }
1829
- static {
1830
- this.__defaultLocale = "en";
1831
- }
1832
1897
  static {
1833
1898
  this.availableLocales = /* @__PURE__ */ new Set();
1834
1899
  }
@@ -1849,14 +1914,20 @@ var DurationFormat = class DurationFormat {
1849
1914
  }, {});
1850
1915
  }
1851
1916
  static {
1852
- this.getDefaultLocale = () => {
1853
- return DurationFormat.__defaultLocale;
1854
- };
1917
+ this.getDefaultLocale = getDefaultLocale;
1855
1918
  }
1856
1919
  static {
1857
1920
  this.polyfilled = true;
1858
1921
  }
1859
1922
  };
1923
+ Object.defineProperty(DurationFormat, "__defaultLocale", {
1924
+ configurable: true,
1925
+ enumerable: true,
1926
+ get: getDefaultLocale,
1927
+ set(locale) {
1928
+ defaultLocale = locale;
1929
+ }
1930
+ });
1860
1931
  Object.defineProperty(DurationFormat, "length", {
1861
1932
  value: 0,
1862
1933
  configurable: true
@@ -1865,6 +1936,7 @@ Object.defineProperty(DurationFormat.supportedLocalesOf, "length", {
1865
1936
  value: 1,
1866
1937
  configurable: true
1867
1938
  });
1939
+ Object.setPrototypeOf(DurationFormat.prototype, Object.prototype);
1868
1940
  Object.defineProperty(DurationFormat.prototype, Symbol.toStringTag, {
1869
1941
  value: "Intl.DurationFormat",
1870
1942
  configurable: true