@formatjs/intl 4.1.19 → 4.2.0
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.d.ts +69 -1
- package/index.js +66 -7
- package/index.js.map +1 -1
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -1,5 +1,58 @@
|
|
|
1
1
|
import { FormatError, FormatXMLElementFn, Formats, Formatters as Formatters$1, IntlMessageFormat, Options, PrimitiveType } from "intl-messageformat";
|
|
2
2
|
import { MessageFormatElement } from "@formatjs/icu-messageformat-parser";
|
|
3
|
+
//#region packages/ecma402-abstract/types/duration.d.ts
|
|
4
|
+
interface DurationInput {
|
|
5
|
+
years?: number;
|
|
6
|
+
months?: number;
|
|
7
|
+
weeks?: number;
|
|
8
|
+
days?: number;
|
|
9
|
+
hours?: number;
|
|
10
|
+
minutes?: number;
|
|
11
|
+
seconds?: number;
|
|
12
|
+
milliseconds?: number;
|
|
13
|
+
microseconds?: number;
|
|
14
|
+
nanoseconds?: number;
|
|
15
|
+
}
|
|
16
|
+
type DurationFormatOptions = Partial<Omit<ResolvedDurationFormatOptions, "locale">> & {
|
|
17
|
+
localeMatcher?: "best fit" | "lookup";
|
|
18
|
+
};
|
|
19
|
+
interface ResolvedDurationFormatOptions {
|
|
20
|
+
locale: string;
|
|
21
|
+
style: "long" | "short" | "narrow" | "digital";
|
|
22
|
+
years: "long" | "short" | "narrow";
|
|
23
|
+
yearsDisplay: "always" | "auto";
|
|
24
|
+
months: "long" | "short" | "narrow";
|
|
25
|
+
monthsDisplay: "always" | "auto";
|
|
26
|
+
weeks: "long" | "short" | "narrow";
|
|
27
|
+
weeksDisplay: "always" | "auto";
|
|
28
|
+
days: "long" | "short" | "narrow";
|
|
29
|
+
daysDisplay: "always" | "auto";
|
|
30
|
+
hours: "long" | "short" | "narrow" | "numeric" | "2-digit";
|
|
31
|
+
hoursDisplay: "always" | "auto";
|
|
32
|
+
minutes: "long" | "short" | "narrow" | "numeric" | "2-digit";
|
|
33
|
+
minutesDisplay: "always" | "auto";
|
|
34
|
+
seconds: "long" | "short" | "narrow" | "numeric" | "2-digit";
|
|
35
|
+
secondsDisplay: "always" | "auto";
|
|
36
|
+
milliseconds: "long" | "short" | "narrow" | "numeric";
|
|
37
|
+
millisecondsDisplay: "always" | "auto";
|
|
38
|
+
microseconds: "long" | "short" | "narrow" | "numeric";
|
|
39
|
+
microsecondsDisplay: "always" | "auto";
|
|
40
|
+
nanoseconds: "long" | "short" | "narrow" | "numeric";
|
|
41
|
+
nanosecondsDisplay: "always" | "auto";
|
|
42
|
+
fractionalDigits?: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9;
|
|
43
|
+
numberingSystem: string;
|
|
44
|
+
}
|
|
45
|
+
interface DurationFormatPart {
|
|
46
|
+
unit?: string;
|
|
47
|
+
type: unknown;
|
|
48
|
+
value: string;
|
|
49
|
+
}
|
|
50
|
+
interface DurationFormat {
|
|
51
|
+
resolvedOptions(): ResolvedDurationFormatOptions;
|
|
52
|
+
formatToParts(duration: DurationInput | string): DurationFormatPart[];
|
|
53
|
+
format(duration: DurationInput | string): string;
|
|
54
|
+
}
|
|
55
|
+
//#endregion
|
|
3
56
|
//#region packages/ecma402-abstract/types/number.d.ts
|
|
4
57
|
type NumberFormatNotation = "standard" | "scientific" | "engineering" | "compact";
|
|
5
58
|
type RoundingPriorityType = "auto" | "morePrecision" | "lessPrecision";
|
|
@@ -88,7 +141,7 @@ export declare function createIntlCache(): IntlCache;
|
|
|
88
141
|
* @param cache explicit cache to prevent leaking memory
|
|
89
142
|
*/
|
|
90
143
|
export declare function createFormatters(cache?: IntlCache): Formatters;
|
|
91
|
-
export declare function getNamedFormat<T extends keyof CustomFormats>(formats: CustomFormats, type: T, name: string, onError: OnErrorFn): NumberFormatOptions | Intl.DateTimeFormatOptions | Intl.RelativeTimeFormatOptions | undefined;
|
|
144
|
+
export declare function getNamedFormat<T extends keyof CustomFormats>(formats: CustomFormats, type: T, name: string, onError: OnErrorFn): NumberFormatOptions | Intl.DateTimeFormatOptions | Intl.RelativeTimeFormatOptions | DurationFormatOptions | undefined;
|
|
92
145
|
//#endregion
|
|
93
146
|
//#region packages/intl/types.d.ts
|
|
94
147
|
export interface Part<T = string> {
|
|
@@ -128,6 +181,7 @@ export interface ResolvedIntlConfig<T = string> {
|
|
|
128
181
|
onWarn?: OnWarnFn;
|
|
129
182
|
}
|
|
130
183
|
export interface CustomFormats extends Partial<Formats> {
|
|
184
|
+
duration?: Record<string, DurationFormatOptions>;
|
|
131
185
|
relative?: Record<string, Intl.RelativeTimeFormatOptions>;
|
|
132
186
|
dateTimeRange?: Record<string, Intl.DateTimeFormatOptions>;
|
|
133
187
|
}
|
|
@@ -140,6 +194,7 @@ export type FormatTimeOptions = Omit<Intl.DateTimeFormatOptions, "localeMatcher"
|
|
|
140
194
|
export type FormatNumberOptions = Omit<NumberFormatOptions, "localeMatcher"> & CustomFormatConfig<"number">;
|
|
141
195
|
export type FormatRelativeTimeOptions = Omit<Intl.RelativeTimeFormatOptions, "localeMatcher"> & CustomFormatConfig<"time">;
|
|
142
196
|
export type FormatPluralOptions = Omit<Intl.PluralRulesOptions, "localeMatcher"> & CustomFormatConfig;
|
|
197
|
+
export type FormatDurationOptions = Omit<DurationFormatOptions, "localeMatcher"> & CustomFormatConfig<"duration">;
|
|
143
198
|
export type FormatListOptions = Omit<Intl.ListFormatOptions, "localeMatcher">;
|
|
144
199
|
export type FormatDisplayNameOptions = Omit<Intl.DisplayNamesOptions, "localeMatcher">;
|
|
145
200
|
/**
|
|
@@ -152,6 +207,8 @@ export interface IntlFormatters<TBase = unknown> {
|
|
|
152
207
|
formatTime(this: void, value: Parameters<Intl.DateTimeFormat["format"]>[0] | string, opts?: FormatTimeOptions): string;
|
|
153
208
|
formatDateToParts(this: void, value: Parameters<Intl.DateTimeFormat["format"]>[0] | string, opts?: FormatDateOptions): Intl.DateTimeFormatPart[];
|
|
154
209
|
formatTimeToParts(this: void, value: Parameters<Intl.DateTimeFormat["format"]>[0] | string, opts?: FormatDateOptions): Intl.DateTimeFormatPart[];
|
|
210
|
+
formatDuration(this: void, value: DurationInput, opts?: FormatDurationOptions): string;
|
|
211
|
+
formatDurationToParts(this: void, value: DurationInput, opts?: FormatDurationOptions): DurationFormatPart[];
|
|
155
212
|
formatRelativeTime(this: void, value: Parameters<Intl.RelativeTimeFormat["format"]>[0], unit?: Parameters<Intl.RelativeTimeFormat["format"]>[1], opts?: FormatRelativeTimeOptions): string;
|
|
156
213
|
formatNumber(this: void, value: Parameters<Intl.NumberFormat["format"]>[0], opts?: FormatNumberOptions): string;
|
|
157
214
|
formatNumberToParts(this: void, value: Parameters<Intl.NumberFormat["format"]>[0], opts?: FormatNumberOptions): Intl.NumberFormatPart[];
|
|
@@ -169,6 +226,7 @@ export interface Formatters {
|
|
|
169
226
|
getDateTimeFormat(this: void, ...args: ConstructorParameters<typeof Intl.DateTimeFormat>): Intl.DateTimeFormat;
|
|
170
227
|
getNumberFormat(this: void, locales?: string | string[], opts?: NumberFormatOptions): Intl.NumberFormat;
|
|
171
228
|
getMessageFormat(this: void, ...args: ConstructorParameters<typeof IntlMessageFormat>): IntlMessageFormat;
|
|
229
|
+
getDurationFormat(this: void, locales?: string | string[], opts?: DurationFormatOptions): DurationFormat;
|
|
172
230
|
getRelativeTimeFormat(this: void, ...args: ConstructorParameters<typeof Intl.RelativeTimeFormat>): Intl.RelativeTimeFormat;
|
|
173
231
|
getPluralRules(this: void, ...args: ConstructorParameters<typeof Intl.PluralRules>): Intl.PluralRules;
|
|
174
232
|
getListFormat(this: void, ...args: ConstructorParameters<typeof Intl.ListFormat>): Intl.ListFormat;
|
|
@@ -181,6 +239,7 @@ export interface IntlCache {
|
|
|
181
239
|
dateTime: Record<string, Intl.DateTimeFormat>;
|
|
182
240
|
number: Record<string, Intl.NumberFormat>;
|
|
183
241
|
message: Record<string, IntlMessageFormat>;
|
|
242
|
+
duration: Record<string, DurationFormat>;
|
|
184
243
|
relativeTime: Record<string, Intl.RelativeTimeFormat>;
|
|
185
244
|
pluralRules: Record<string, Intl.PluralRules>;
|
|
186
245
|
list: Record<string, Intl.ListFormat>;
|
|
@@ -233,6 +292,15 @@ export declare function formatTimeToParts(config: {
|
|
|
233
292
|
onError: OnErrorFn;
|
|
234
293
|
}, getDateTimeFormat: Formatters["getDateTimeFormat"], value: Parameters<IntlFormatters["formatTimeToParts"]>[0], options?: Parameters<IntlFormatters["formatTimeToParts"]>[1]): Intl.DateTimeFormatPart[];
|
|
235
294
|
//#endregion
|
|
295
|
+
//#region packages/intl/duration.d.ts
|
|
296
|
+
type Config = {
|
|
297
|
+
locale: string;
|
|
298
|
+
formats: CustomFormats;
|
|
299
|
+
onError: OnErrorFn;
|
|
300
|
+
};
|
|
301
|
+
export declare function formatDuration(config: Config, getDurationFormat: Formatters["getDurationFormat"], value: Parameters<IntlFormatters["formatDuration"]>[0], options?: FormatDurationOptions): string;
|
|
302
|
+
export declare function formatDurationToParts(config: Config, getDurationFormat: Formatters["getDurationFormat"], value: Parameters<IntlFormatters["formatDuration"]>[0], options?: FormatDurationOptions): ReturnType<IntlFormatters["formatDurationToParts"]>;
|
|
303
|
+
//#endregion
|
|
236
304
|
//#region packages/intl/displayName.d.ts
|
|
237
305
|
export declare function formatDisplayName({ locale, onError }: {
|
|
238
306
|
locale: string;
|
package/index.js
CHANGED
|
@@ -92,6 +92,7 @@ function createIntlCache() {
|
|
|
92
92
|
dateTime: {},
|
|
93
93
|
number: {},
|
|
94
94
|
message: {},
|
|
95
|
+
duration: {},
|
|
95
96
|
relativeTime: {},
|
|
96
97
|
pluralRules: {},
|
|
97
98
|
list: {},
|
|
@@ -144,6 +145,10 @@ function createFormatters(cache = createIntlCache()) {
|
|
|
144
145
|
cache: createFastMemoizeCache(cache.message),
|
|
145
146
|
strategy: strategies.variadic
|
|
146
147
|
}),
|
|
148
|
+
getDurationFormat: memoize((...args) => new Intl.DurationFormat(...args), {
|
|
149
|
+
cache: createFastMemoizeCache(cache.duration),
|
|
150
|
+
strategy: strategies.variadic
|
|
151
|
+
}),
|
|
147
152
|
getRelativeTimeFormat: memoize((...args) => new RelativeTimeFormat(...args), {
|
|
148
153
|
cache: createFastMemoizeCache(cache.relativeTime),
|
|
149
154
|
strategy: strategies.variadic
|
|
@@ -273,7 +278,7 @@ const DATE_TIME_FORMAT_OPTIONS = [
|
|
|
273
278
|
"numberingSystem",
|
|
274
279
|
"fractionalSecondDigits"
|
|
275
280
|
];
|
|
276
|
-
function getFormatter$
|
|
281
|
+
function getFormatter$3({ locale, formats, onError, timeZone }, type, getDateTimeFormat, options = {}) {
|
|
277
282
|
const { format } = options;
|
|
278
283
|
const defaults = {
|
|
279
284
|
...timeZone && { timeZone },
|
|
@@ -290,7 +295,7 @@ function getFormatter$2({ locale, formats, onError, timeZone }, type, getDateTim
|
|
|
290
295
|
function formatDate(config, getDateTimeFormat, value, options = {}) {
|
|
291
296
|
const date = typeof value === "string" ? new Date(value || 0) : value;
|
|
292
297
|
try {
|
|
293
|
-
return getFormatter$
|
|
298
|
+
return getFormatter$3(config, "date", getDateTimeFormat, options).format(date);
|
|
294
299
|
} catch (e) {
|
|
295
300
|
config.onError(new IntlFormatError("Error formatting date.", config.locale, e));
|
|
296
301
|
}
|
|
@@ -299,7 +304,7 @@ function formatDate(config, getDateTimeFormat, value, options = {}) {
|
|
|
299
304
|
function formatTime(config, getDateTimeFormat, value, options = {}) {
|
|
300
305
|
const date = typeof value === "string" ? new Date(value || 0) : value;
|
|
301
306
|
try {
|
|
302
|
-
return getFormatter$
|
|
307
|
+
return getFormatter$3(config, "time", getDateTimeFormat, options).format(date);
|
|
303
308
|
} catch (e) {
|
|
304
309
|
config.onError(new IntlFormatError("Error formatting time.", config.locale, e));
|
|
305
310
|
}
|
|
@@ -309,7 +314,7 @@ function formatDateTimeRange(config, getDateTimeFormat, from, to, options = {})
|
|
|
309
314
|
const fromDate = typeof from === "string" ? new Date(from || 0) : from;
|
|
310
315
|
const toDate = typeof to === "string" ? new Date(to || 0) : to;
|
|
311
316
|
try {
|
|
312
|
-
return getFormatter$
|
|
317
|
+
return getFormatter$3(config, "dateTimeRange", getDateTimeFormat, options).formatRange(fromDate, toDate);
|
|
313
318
|
} catch (e) {
|
|
314
319
|
config.onError(new IntlFormatError("Error formatting date time range.", config.locale, e));
|
|
315
320
|
}
|
|
@@ -318,7 +323,7 @@ function formatDateTimeRange(config, getDateTimeFormat, from, to, options = {})
|
|
|
318
323
|
function formatDateToParts(config, getDateTimeFormat, value, options = {}) {
|
|
319
324
|
const date = typeof value === "string" ? new Date(value || 0) : value;
|
|
320
325
|
try {
|
|
321
|
-
return getFormatter$
|
|
326
|
+
return getFormatter$3(config, "date", getDateTimeFormat, options).formatToParts(date);
|
|
322
327
|
} catch (e) {
|
|
323
328
|
config.onError(new IntlFormatError("Error formatting date.", config.locale, e));
|
|
324
329
|
}
|
|
@@ -327,13 +332,65 @@ function formatDateToParts(config, getDateTimeFormat, value, options = {}) {
|
|
|
327
332
|
function formatTimeToParts(config, getDateTimeFormat, value, options = {}) {
|
|
328
333
|
const date = typeof value === "string" ? new Date(value || 0) : value;
|
|
329
334
|
try {
|
|
330
|
-
return getFormatter$
|
|
335
|
+
return getFormatter$3(config, "time", getDateTimeFormat, options).formatToParts(date);
|
|
331
336
|
} catch (e) {
|
|
332
337
|
config.onError(new IntlFormatError("Error formatting time.", config.locale, e));
|
|
333
338
|
}
|
|
334
339
|
return [];
|
|
335
340
|
}
|
|
336
341
|
//#endregion
|
|
342
|
+
//#region packages/intl/duration.ts
|
|
343
|
+
const DURATION_FORMAT_OPTIONS = [
|
|
344
|
+
"style",
|
|
345
|
+
"numberingSystem",
|
|
346
|
+
"years",
|
|
347
|
+
"yearsDisplay",
|
|
348
|
+
"months",
|
|
349
|
+
"monthsDisplay",
|
|
350
|
+
"weeks",
|
|
351
|
+
"weeksDisplay",
|
|
352
|
+
"days",
|
|
353
|
+
"daysDisplay",
|
|
354
|
+
"hours",
|
|
355
|
+
"hoursDisplay",
|
|
356
|
+
"minutes",
|
|
357
|
+
"minutesDisplay",
|
|
358
|
+
"seconds",
|
|
359
|
+
"secondsDisplay",
|
|
360
|
+
"milliseconds",
|
|
361
|
+
"millisecondsDisplay",
|
|
362
|
+
"microseconds",
|
|
363
|
+
"microsecondsDisplay",
|
|
364
|
+
"nanoseconds",
|
|
365
|
+
"nanosecondsDisplay",
|
|
366
|
+
"fractionalDigits"
|
|
367
|
+
];
|
|
368
|
+
function getFormatter$2({ locale, formats, onError }, getDurationFormat, options) {
|
|
369
|
+
if (!Intl.DurationFormat) {
|
|
370
|
+
onError(new FormatError("Intl.DurationFormat is not available in this environment.\nTry polyfilling it using \"@formatjs/intl-durationformat\"", ErrorCode.MISSING_INTL_API));
|
|
371
|
+
return;
|
|
372
|
+
}
|
|
373
|
+
const { format } = options;
|
|
374
|
+
const defaults = format && getNamedFormat(formats, "duration", format, onError) || {};
|
|
375
|
+
return getDurationFormat(locale, filterProps(options, DURATION_FORMAT_OPTIONS, defaults));
|
|
376
|
+
}
|
|
377
|
+
function formatDuration(config, getDurationFormat, value, options = {}) {
|
|
378
|
+
try {
|
|
379
|
+
return getFormatter$2(config, getDurationFormat, options)?.format(value) ?? "";
|
|
380
|
+
} catch (e) {
|
|
381
|
+
config.onError(new IntlFormatError("Error formatting duration.", config.locale, e));
|
|
382
|
+
}
|
|
383
|
+
return "";
|
|
384
|
+
}
|
|
385
|
+
function formatDurationToParts(config, getDurationFormat, value, options = {}) {
|
|
386
|
+
try {
|
|
387
|
+
return getFormatter$2(config, getDurationFormat, options)?.formatToParts(value) ?? [];
|
|
388
|
+
} catch (e) {
|
|
389
|
+
config.onError(new IntlFormatError("Error formatting duration.", config.locale, e));
|
|
390
|
+
}
|
|
391
|
+
return [];
|
|
392
|
+
}
|
|
393
|
+
//#endregion
|
|
337
394
|
//#region packages/intl/displayName.ts
|
|
338
395
|
const DISPLAY_NAMES_OPTONS = [
|
|
339
396
|
"style",
|
|
@@ -508,6 +565,8 @@ function createIntl(config, cache) {
|
|
|
508
565
|
formatters,
|
|
509
566
|
formatNumber: formatNumber.bind(null, resolvedConfig, formatters.getNumberFormat),
|
|
510
567
|
formatNumberToParts: formatNumberToParts.bind(null, resolvedConfig, formatters.getNumberFormat),
|
|
568
|
+
formatDuration: formatDuration.bind(null, resolvedConfig, formatters.getDurationFormat),
|
|
569
|
+
formatDurationToParts: formatDurationToParts.bind(null, resolvedConfig, formatters.getDurationFormat),
|
|
511
570
|
formatRelativeTime: formatRelativeTime.bind(null, resolvedConfig, formatters.getRelativeTimeFormat),
|
|
512
571
|
formatDate: formatDate.bind(null, resolvedConfig, formatters.getDateTimeFormat),
|
|
513
572
|
formatDateToParts: formatDateToParts.bind(null, resolvedConfig, formatters.getDateTimeFormat),
|
|
@@ -531,6 +590,6 @@ function defineMessage(msg) {
|
|
|
531
590
|
return msg;
|
|
532
591
|
}
|
|
533
592
|
//#endregion
|
|
534
|
-
export { DEFAULT_INTL_CONFIG, IntlError, IntlErrorCode, IntlFormatError, InvalidConfigError, MessageFormatError, MissingDataError, MissingTranslationError, UnsupportedFormatterError, createFormatters, createIntl, createIntlCache, defineMessage, defineMessages, filterProps, formatDate, formatDateToParts, formatDisplayName, formatList, formatMessage, formatNumber, formatNumberToParts, formatPlural, formatRelativeTime, formatTime, formatTimeToParts, getNamedFormat };
|
|
593
|
+
export { DEFAULT_INTL_CONFIG, IntlError, IntlErrorCode, IntlFormatError, InvalidConfigError, MessageFormatError, MissingDataError, MissingTranslationError, UnsupportedFormatterError, createFormatters, createIntl, createIntlCache, defineMessage, defineMessages, filterProps, formatDate, formatDateToParts, formatDisplayName, formatDuration, formatDurationToParts, formatList, formatMessage, formatNumber, formatNumberToParts, formatPlural, formatRelativeTime, formatTime, formatTimeToParts, getNamedFormat };
|
|
535
594
|
|
|
536
595
|
//# sourceMappingURL=index.js.map
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["getFormatter","getFormatter"],"sources":["../error.ts","../utils.ts","../message.ts","../dateTime.ts","../displayName.ts","../list.ts","../plural.ts","../relativeTime.ts","../number.ts","../create-intl.ts","../index.ts"],"sourcesContent":["import {type MessageDescriptor} from '#packages/intl/types.js'\n\nexport enum IntlErrorCode {\n FORMAT_ERROR = 'FORMAT_ERROR',\n UNSUPPORTED_FORMATTER = 'UNSUPPORTED_FORMATTER',\n INVALID_CONFIG = 'INVALID_CONFIG',\n MISSING_DATA = 'MISSING_DATA',\n MISSING_TRANSLATION = 'MISSING_TRANSLATION',\n}\n\nexport class IntlError<\n T extends IntlErrorCode = IntlErrorCode.FORMAT_ERROR,\n> extends Error {\n public readonly code: T\n\n constructor(code: T, message: string, exception?: Error | unknown) {\n const err = exception\n ? exception instanceof Error\n ? exception\n : new Error(String(exception))\n : undefined\n super(\n `[@formatjs/intl Error ${code}] ${message}\n${err ? `\\n${err.message}\\n${err.stack}` : ''}`\n )\n this.code = code\n // @ts-ignore just so we don't need to declare dep on @types/node\n if (typeof Error.captureStackTrace === 'function') {\n // @ts-ignore just so we don't need to declare dep on @types/node\n Error.captureStackTrace(this, IntlError)\n }\n }\n}\n\nexport class UnsupportedFormatterError extends IntlError<IntlErrorCode.UNSUPPORTED_FORMATTER> {\n constructor(message: string, exception?: Error | unknown) {\n super(IntlErrorCode.UNSUPPORTED_FORMATTER, message, exception)\n }\n}\n\nexport class InvalidConfigError extends IntlError<IntlErrorCode.INVALID_CONFIG> {\n constructor(message: string, exception?: Error | unknown) {\n super(IntlErrorCode.INVALID_CONFIG, message, exception)\n }\n}\n\nexport class MissingDataError extends IntlError<IntlErrorCode.MISSING_DATA> {\n constructor(message: string, exception?: Error | unknown) {\n super(IntlErrorCode.MISSING_DATA, message, exception)\n }\n}\n\nexport class IntlFormatError extends IntlError<IntlErrorCode.FORMAT_ERROR> {\n public readonly descriptor?: MessageDescriptor\n public readonly locale: string\n constructor(message: string, locale: string, exception?: Error | unknown) {\n super(\n IntlErrorCode.FORMAT_ERROR,\n `${message}\nLocale: ${locale}\n`,\n exception\n )\n this.locale = locale\n }\n}\n\nexport class MessageFormatError extends IntlFormatError {\n public readonly descriptor?: MessageDescriptor\n public readonly locale: string\n constructor(\n message: string,\n locale: string,\n descriptor?: MessageDescriptor,\n exception?: Error | unknown\n ) {\n super(\n `${message}\nMessageID: ${descriptor?.id}\nDefault Message: ${descriptor?.defaultMessage}\nDescription: ${descriptor?.description}\n`,\n locale,\n exception\n )\n this.descriptor = descriptor\n this.locale = locale\n }\n}\n\nexport class MissingTranslationError extends IntlError<IntlErrorCode.MISSING_TRANSLATION> {\n public readonly descriptor?: MessageDescriptor\n constructor(descriptor: MessageDescriptor, locale: string) {\n super(\n IntlErrorCode.MISSING_TRANSLATION,\n `Missing message: \"${descriptor.id}\" for locale \"${locale}\", using ${\n descriptor.defaultMessage\n ? `default message (${\n typeof descriptor.defaultMessage === 'string'\n ? descriptor.defaultMessage\n : descriptor.defaultMessage\n .map((e: any) => e.value ?? JSON.stringify(e))\n .join()\n })`\n : 'id'\n } as fallback.`\n )\n this.descriptor = descriptor\n }\n}\n","import {type NumberFormatOptions} from '#packages/ecma402-abstract/types/number.js'\nimport {type Cache, memoize, strategies} from '@formatjs/fast-memoize'\nimport {IntlMessageFormat} from 'intl-messageformat'\nimport {UnsupportedFormatterError} from '#packages/intl/error.js'\nimport {\n type CustomFormats,\n type Formatters,\n type IntlCache,\n type OnErrorFn,\n type OnWarnFn,\n type ResolvedIntlConfig,\n} from '#packages/intl/types.js'\n\nexport function invariant(\n condition: boolean,\n message: string,\n Err: any = Error\n): asserts condition {\n if (!condition) {\n throw new Err(message)\n }\n}\n\nexport function filterProps<T extends Record<string, any>, K extends string>(\n props: T,\n allowlist: Array<K>,\n defaults: Partial<T> = {}\n): Pick<T, K> {\n return allowlist.reduce(\n (filtered, name) => {\n if (name in props) {\n filtered[name] = props[name]\n } else if (name in defaults) {\n filtered[name] = defaults[name]!\n }\n\n return filtered\n },\n {} as Pick<T, K>\n )\n}\n\nconst defaultErrorHandler: OnErrorFn = error => {\n // @ts-ignore just so we don't need to declare dep on @types/node\n if (process.env.NODE_ENV !== 'production') {\n console.error(error)\n }\n}\n\nconst defaultWarnHandler: OnWarnFn = (warning: string) => {\n // @ts-ignore just so we don't need to declare dep on @types/node\n if (process.env.NODE_ENV !== 'production') {\n console.warn(warning)\n }\n}\n\nexport const DEFAULT_INTL_CONFIG: Pick<\n ResolvedIntlConfig<any>,\n | 'fallbackOnEmptyString'\n | 'formats'\n | 'messages'\n | 'timeZone'\n | 'defaultLocale'\n | 'defaultFormats'\n | 'onError'\n | 'onWarn'\n> = {\n formats: {},\n messages: {},\n timeZone: undefined,\n\n defaultLocale: 'en',\n defaultFormats: {},\n\n fallbackOnEmptyString: true,\n\n onError: defaultErrorHandler,\n onWarn: defaultWarnHandler,\n}\n\nexport function createIntlCache(): IntlCache {\n return {\n dateTime: {},\n number: {},\n message: {},\n relativeTime: {},\n pluralRules: {},\n list: {},\n displayNames: {},\n }\n}\n\nfunction createFastMemoizeCache<V>(\n store: Record<string, V | undefined>\n): Cache<string, V> {\n return {\n create() {\n return {\n get(key) {\n return store[key]\n },\n set(key, value) {\n store[key] = value\n },\n }\n },\n }\n}\n\n/**\n * Create intl formatters and populate cache\n * @param cache explicit cache to prevent leaking memory\n */\nexport function createFormatters(\n cache: IntlCache = createIntlCache()\n): Formatters {\n const RelativeTimeFormat = (Intl as any).RelativeTimeFormat\n const ListFormat = (Intl as any).ListFormat\n const DisplayNames = (Intl as any).DisplayNames\n const getDateTimeFormat = memoize(\n (...args) => new Intl.DateTimeFormat(...args),\n {\n cache: createFastMemoizeCache(cache.dateTime),\n strategy: strategies.variadic,\n }\n )\n const getNumberFormat = memoize((...args) => new Intl.NumberFormat(...args), {\n cache: createFastMemoizeCache(cache.number),\n strategy: strategies.variadic,\n })\n const getPluralRules = memoize((...args) => new Intl.PluralRules(...args), {\n cache: createFastMemoizeCache(cache.pluralRules),\n strategy: strategies.variadic,\n })\n return {\n getDateTimeFormat,\n getNumberFormat,\n getMessageFormat: memoize(\n (message, locales, overrideFormats, opts) =>\n new IntlMessageFormat(message, locales, overrideFormats, {\n formatters: {\n getNumberFormat,\n getDateTimeFormat,\n getPluralRules,\n },\n ...opts,\n }),\n {\n cache: createFastMemoizeCache(cache.message),\n strategy: strategies.variadic,\n }\n ),\n getRelativeTimeFormat: memoize(\n (...args) => new RelativeTimeFormat(...args),\n {\n cache: createFastMemoizeCache(cache.relativeTime),\n strategy: strategies.variadic,\n }\n ),\n getPluralRules,\n getListFormat: memoize((...args) => new ListFormat(...args), {\n cache: createFastMemoizeCache(cache.list),\n strategy: strategies.variadic,\n }),\n getDisplayNames: memoize((...args) => new DisplayNames(...args), {\n cache: createFastMemoizeCache(cache.displayNames),\n strategy: strategies.variadic,\n }),\n }\n}\n\nexport function getNamedFormat<T extends keyof CustomFormats>(\n formats: CustomFormats,\n type: T,\n name: string,\n onError: OnErrorFn\n):\n | NumberFormatOptions\n | Intl.DateTimeFormatOptions\n | Intl.RelativeTimeFormatOptions\n | undefined {\n const formatType = formats && formats[type]\n let format\n if (formatType) {\n format = formatType[name]\n }\n if (format) {\n return format\n }\n\n onError(new UnsupportedFormatterError(`No ${type} format named: ${name}`))\n}\n","import {\n type CustomFormats,\n type Formatters,\n type MessageDescriptor,\n type OnErrorFn,\n} from '#packages/intl/types.js'\n\nimport {\n type MessageFormatElement,\n TYPE,\n} from '@formatjs/icu-messageformat-parser'\nimport {\n type FormatXMLElementFn,\n IntlMessageFormat,\n type Formatters as IntlMessageFormatFormatters,\n type Options,\n type PrimitiveType,\n} from 'intl-messageformat'\nimport {\n MessageFormatError,\n MissingTranslationError,\n} from '#packages/intl/error.js'\nimport {invariant} from '#packages/intl/utils.js'\n\nfunction setTimeZoneInOptions(\n opts: Record<string, Intl.DateTimeFormatOptions>,\n timeZone: string\n): Record<string, Intl.DateTimeFormatOptions> {\n return Object.keys(opts).reduce(\n (all: Record<string, Intl.DateTimeFormatOptions>, k) => {\n all[k] = {\n timeZone,\n ...opts[k],\n }\n return all\n },\n {}\n )\n}\n\nfunction deepMergeOptions(\n opts1: Record<string, Intl.DateTimeFormatOptions>,\n opts2: Record<string, Intl.DateTimeFormatOptions>\n): Record<string, Intl.DateTimeFormatOptions> {\n const keys = Object.keys({...opts1, ...opts2})\n return keys.reduce((all: Record<string, Intl.DateTimeFormatOptions>, k) => {\n all[k] = {\n ...opts1[k],\n ...opts2[k],\n }\n return all\n }, {})\n}\n\nfunction deepMergeFormatsAndSetTimeZone(\n f1: CustomFormats,\n timeZone?: string\n): CustomFormats {\n if (!timeZone) {\n return f1\n }\n const mfFormats = IntlMessageFormat.formats\n return {\n ...mfFormats,\n ...f1,\n date: deepMergeOptions(\n setTimeZoneInOptions(mfFormats.date, timeZone),\n setTimeZoneInOptions(f1.date || {}, timeZone)\n ),\n time: deepMergeOptions(\n setTimeZoneInOptions(mfFormats.time, timeZone),\n setTimeZoneInOptions(f1.time || {}, timeZone)\n ),\n }\n}\n\nexport type FormatMessageFn<T> = (\n {\n locale,\n formats,\n messages,\n defaultLocale,\n defaultFormats,\n fallbackOnEmptyString,\n onError,\n timeZone,\n defaultRichTextElements,\n }: {\n locale: string\n timeZone?: string\n formats: CustomFormats\n messages: Record<string, string> | Record<string, MessageFormatElement[]>\n defaultLocale: string\n defaultFormats: CustomFormats\n defaultRichTextElements?: Record<string, FormatXMLElementFn<T>>\n fallbackOnEmptyString?: boolean\n onError: OnErrorFn\n },\n state: IntlMessageFormatFormatters & Pick<Formatters, 'getMessageFormat'>,\n messageDescriptor: MessageDescriptor,\n values?: Record<string, PrimitiveType | T | FormatXMLElementFn<T>>,\n opts?: Options\n) => T extends string ? string : Array<T | string> | string | T\n\nfunction getMessageDescriptorContext(\n messageDescriptor: MessageDescriptor\n): string {\n const {defaultMessage} = messageDescriptor\n try {\n return defaultMessage !== undefined\n ? `\\nDefault Message: ${\n typeof defaultMessage === 'string'\n ? defaultMessage\n : JSON.stringify(defaultMessage)\n }`\n : `\\nMessage Descriptor: ${JSON.stringify(messageDescriptor)}`\n } catch {\n return ''\n }\n}\n\nexport const formatMessage: FormatMessageFn<any> = (\n {\n locale,\n formats,\n messages,\n defaultLocale,\n defaultFormats,\n fallbackOnEmptyString,\n onError,\n timeZone,\n defaultRichTextElements,\n },\n state,\n messageDescriptor = {id: ''},\n values,\n opts\n) => {\n const {id: msgId, defaultMessage} = messageDescriptor\n\n // `id` is a required field of a Message Descriptor.\n if (!msgId) {\n invariant(\n false,\n `[@formatjs/intl] An \\`id\\` must be provided to format a message. You can either:\n1. Configure your build toolchain with [babel-plugin-formatjs](https://formatjs.github.io/docs/tooling/babel-plugin)\nor [@formatjs/ts-transformer](https://formatjs.github.io/docs/tooling/ts-transformer) OR\n2. Configure your \\`eslint\\` config to include [eslint-plugin-formatjs](https://formatjs.github.io/docs/tooling/linter#enforce-id)\nto autofix this issue${getMessageDescriptorContext(messageDescriptor)}`\n )\n }\n const id = String(msgId)\n const message =\n // In case messages is Object.create(null)\n // e.g import('foo.json') from webpack)\n // See https://github.com/formatjs/formatjs/issues/1914\n messages &&\n Object.prototype.hasOwnProperty.call(messages, id) &&\n messages[id]\n\n // IMPORTANT: Hot path if `message` is AST with a single literal node\n if (\n Array.isArray(message) &&\n message.length === 1 &&\n message[0].type === TYPE.literal\n ) {\n return message[0].value\n }\n\n values = {\n ...defaultRichTextElements,\n ...values,\n }\n formats = deepMergeFormatsAndSetTimeZone(formats, timeZone)\n defaultFormats = deepMergeFormatsAndSetTimeZone(defaultFormats, timeZone)\n\n if (!message) {\n if (fallbackOnEmptyString === false && message === '') {\n return message\n }\n\n if (\n !defaultMessage ||\n (locale && locale.toLowerCase() !== defaultLocale.toLowerCase())\n ) {\n // This prevents warnings from littering the console in development\n // when no `messages` are passed into the <IntlProvider> for the\n // default locale.\n onError(new MissingTranslationError(messageDescriptor, locale))\n }\n if (defaultMessage) {\n try {\n const formatter = state.getMessageFormat(\n defaultMessage,\n defaultLocale,\n defaultFormats,\n opts\n )\n\n return formatter.format(values)\n } catch (e) {\n onError(\n new MessageFormatError(\n `Error formatting default message for: \"${id}\", rendering default message verbatim`,\n locale,\n messageDescriptor,\n e\n )\n )\n return typeof defaultMessage === 'string' ? defaultMessage : id\n }\n }\n return id\n }\n\n // We have the translated message\n try {\n const formatter = state.getMessageFormat(message, locale, formats, {\n formatters: state,\n ...opts,\n })\n\n return formatter.format<any>(values)\n } catch (e) {\n onError(\n new MessageFormatError(\n `Error formatting message: \"${id}\", using ${\n defaultMessage ? 'default message' : 'id'\n } as fallback.`,\n locale,\n messageDescriptor,\n e\n )\n )\n }\n\n if (defaultMessage) {\n try {\n const formatter = state.getMessageFormat(\n defaultMessage,\n defaultLocale,\n defaultFormats,\n opts\n )\n\n return formatter.format(values)\n } catch (e) {\n onError(\n new MessageFormatError(\n `Error formatting the default message for: \"${id}\", rendering message verbatim`,\n locale,\n messageDescriptor,\n e\n )\n )\n }\n }\n\n if (typeof message === 'string') {\n return message\n }\n if (typeof defaultMessage === 'string') {\n return defaultMessage\n }\n return id\n}\n","import {\n type CustomFormats,\n type Formatters,\n type IntlFormatters,\n type OnErrorFn,\n} from '#packages/intl/types.js'\n\nimport {IntlFormatError} from '#packages/intl/error.js'\nimport {filterProps, getNamedFormat} from '#packages/intl/utils.js'\n\nconst DATE_TIME_FORMAT_OPTIONS: Array<keyof Intl.DateTimeFormatOptions> = [\n 'formatMatcher',\n\n 'timeZone',\n 'hour12',\n\n 'weekday',\n 'era',\n 'year',\n 'month',\n 'day',\n 'hour',\n 'minute',\n 'second',\n 'timeZoneName',\n 'hourCycle',\n 'dateStyle',\n 'timeStyle',\n 'calendar',\n // 'dayPeriod',\n 'numberingSystem',\n 'fractionalSecondDigits',\n]\n\nexport function getFormatter(\n {\n locale,\n formats,\n onError,\n timeZone,\n }: {\n locale: string\n timeZone?: string\n formats: CustomFormats\n onError: OnErrorFn\n },\n type: 'date' | 'time' | 'dateTimeRange',\n getDateTimeFormat: Formatters['getDateTimeFormat'],\n options: Parameters<IntlFormatters['formatDate']>[1] = {}\n): Intl.DateTimeFormat {\n const {format} = options\n const defaults = {\n ...(timeZone && {timeZone}),\n ...(format && getNamedFormat(formats!, type, format, onError)),\n }\n\n let filteredOptions = filterProps(\n options,\n DATE_TIME_FORMAT_OPTIONS,\n defaults\n ) as Intl.DateTimeFormatOptions\n\n if (\n type === 'time' &&\n !filteredOptions.hour &&\n !filteredOptions.minute &&\n !filteredOptions.second &&\n !filteredOptions.timeStyle &&\n !filteredOptions.dateStyle\n ) {\n // Add default formatting options if hour, minute, or second isn't defined.\n filteredOptions = {...filteredOptions, hour: 'numeric', minute: 'numeric'}\n }\n\n return getDateTimeFormat(locale, filteredOptions)\n}\n\nexport function formatDate(\n config: {\n locale: string\n timeZone?: string\n formats: CustomFormats\n onError: OnErrorFn\n },\n getDateTimeFormat: Formatters['getDateTimeFormat'],\n value: Parameters<IntlFormatters['formatDate']>[0],\n options: Parameters<IntlFormatters['formatDate']>[1] = {}\n): string {\n const date = typeof value === 'string' ? new Date(value || 0) : value\n try {\n return getFormatter(config, 'date', getDateTimeFormat, options).format(date)\n } catch (e) {\n config.onError(\n new IntlFormatError('Error formatting date.', config.locale, e)\n )\n }\n\n return String(date)\n}\n\nexport function formatTime(\n config: {\n locale: string\n timeZone?: string\n formats: CustomFormats\n onError: OnErrorFn\n },\n getDateTimeFormat: Formatters['getDateTimeFormat'],\n value: Parameters<IntlFormatters['formatTime']>[0],\n options: Parameters<IntlFormatters['formatTime']>[1] = {}\n): string {\n const date = typeof value === 'string' ? new Date(value || 0) : value\n\n try {\n return getFormatter(config, 'time', getDateTimeFormat, options).format(date)\n } catch (e) {\n config.onError(\n new IntlFormatError('Error formatting time.', config.locale, e)\n )\n }\n\n return String(date)\n}\n\nexport function formatDateTimeRange(\n config: {\n locale: string\n timeZone?: string\n formats: CustomFormats\n onError: OnErrorFn\n },\n getDateTimeFormat: Formatters['getDateTimeFormat'],\n from: Parameters<IntlFormatters['formatDateTimeRange']>[0],\n to: Parameters<IntlFormatters['formatDateTimeRange']>[1],\n options: Parameters<IntlFormatters['formatDateTimeRange']>[2] = {}\n): string {\n const fromDate = typeof from === 'string' ? new Date(from || 0) : from\n const toDate = typeof to === 'string' ? new Date(to || 0) : to\n\n try {\n return getFormatter(\n config,\n 'dateTimeRange',\n getDateTimeFormat,\n options\n ).formatRange(fromDate, toDate)\n } catch (e) {\n config.onError(\n new IntlFormatError('Error formatting date time range.', config.locale, e)\n )\n }\n\n return String(fromDate)\n}\n\nexport function formatDateToParts(\n config: {\n locale: string\n timeZone?: string\n formats: CustomFormats\n onError: OnErrorFn\n },\n getDateTimeFormat: Formatters['getDateTimeFormat'],\n value: Parameters<IntlFormatters['formatDate']>[0],\n options: Parameters<IntlFormatters['formatDate']>[1] = {}\n): Intl.DateTimeFormatPart[] {\n const date = typeof value === 'string' ? new Date(value || 0) : value\n try {\n return getFormatter(\n config,\n 'date',\n getDateTimeFormat,\n options\n ).formatToParts(date) as Intl.DateTimeFormatPart[] // TODO: remove this when https://github.com/microsoft/TypeScript/pull/50402 is merged\n } catch (e) {\n config.onError(\n new IntlFormatError('Error formatting date.', config.locale, e)\n )\n }\n\n return []\n}\n\nexport function formatTimeToParts(\n config: {\n locale: string\n timeZone?: string\n formats: CustomFormats\n onError: OnErrorFn\n },\n getDateTimeFormat: Formatters['getDateTimeFormat'],\n value: Parameters<IntlFormatters['formatTimeToParts']>[0],\n options: Parameters<IntlFormatters['formatTimeToParts']>[1] = {}\n): Intl.DateTimeFormatPart[] {\n const date = typeof value === 'string' ? new Date(value || 0) : value\n\n try {\n return getFormatter(\n config,\n 'time',\n getDateTimeFormat,\n options\n ).formatToParts(date) as Intl.DateTimeFormatPart[] // TODO: remove this when https://github.com/microsoft/TypeScript/pull/50402 is merged\n } catch (e) {\n config.onError(\n new IntlFormatError('Error formatting time.', config.locale, e)\n )\n }\n\n return []\n}\n","import {\n type Formatters,\n type IntlFormatters,\n type OnErrorFn,\n} from '#packages/intl/types.js'\nimport {filterProps} from '#packages/intl/utils.js'\n\nimport {ErrorCode, FormatError} from 'intl-messageformat'\nimport {IntlFormatError} from '#packages/intl/error.js'\n\nconst DISPLAY_NAMES_OPTONS: Array<keyof Intl.DisplayNamesOptions> = [\n 'style',\n 'type',\n 'fallback',\n 'languageDisplay',\n]\n\nexport function formatDisplayName(\n {\n locale,\n onError,\n }: {\n locale: string\n onError: OnErrorFn\n },\n getDisplayNames: Formatters['getDisplayNames'],\n value: Parameters<IntlFormatters['formatDisplayName']>[0],\n options: Parameters<IntlFormatters['formatDisplayName']>[1]\n): string | undefined {\n const DisplayNames: typeof Intl.DisplayNames = (Intl as any).DisplayNames\n if (!DisplayNames) {\n onError(\n new FormatError(\n `Intl.DisplayNames is not available in this environment.\nTry polyfilling it using \"@formatjs/intl-displaynames\"\n`,\n ErrorCode.MISSING_INTL_API\n )\n )\n }\n const filteredOptions = filterProps(\n options,\n DISPLAY_NAMES_OPTONS\n ) as Intl.DisplayNamesOptions\n try {\n return getDisplayNames(locale, filteredOptions).of(value)\n } catch (e) {\n onError(new IntlFormatError('Error formatting display name.', locale, e))\n }\n}\n","import {ErrorCode, FormatError} from 'intl-messageformat'\nimport {IntlFormatError} from '#packages/intl/error.js'\nimport {\n type Formatters,\n type IntlFormatters,\n type OnErrorFn,\n type Part,\n} from '#packages/intl/types.js'\nimport {filterProps} from '#packages/intl/utils.js'\n\nconst LIST_FORMAT_OPTIONS: Array<keyof Intl.ListFormatOptions> = [\n 'type',\n 'style',\n]\n\nconst now = Date.now()\n\nfunction generateToken(i: number): string {\n return `${now}_${i}_${now}`\n}\n\nexport function formatList(\n opts: {\n locale: string\n onError: OnErrorFn\n },\n getListFormat: Formatters['getListFormat'],\n values: Iterable<string>,\n options: Parameters<IntlFormatters['formatList']>[1]\n): string\nexport function formatList<T>(\n opts: {\n locale: string\n onError: OnErrorFn\n },\n getListFormat: Formatters['getListFormat'],\n values: Iterable<string | T>,\n options: Parameters<IntlFormatters['formatList']>[1] = {}\n): Array<T | string> | T | string {\n const results = formatListToParts(\n opts,\n getListFormat,\n values,\n options\n ).reduce((all: Array<string | T>, el) => {\n const val = el.value\n if (typeof val !== 'string') {\n all.push(val)\n } else if (typeof all[all.length - 1] === 'string') {\n all[all.length - 1] += val\n } else {\n all.push(val)\n }\n return all\n }, [])\n return results.length === 1 ? results[0] : results.length === 0 ? '' : results\n}\n\nexport function formatListToParts<T>(\n opts: {\n locale: string\n onError: OnErrorFn\n },\n getListFormat: Formatters['getListFormat'],\n values: Iterable<string | T>,\n options: Parameters<IntlFormatters['formatList']>[1]\n): Part[]\nexport function formatListToParts<T>(\n {\n locale,\n onError,\n }: {\n locale: string\n onError: OnErrorFn\n },\n getListFormat: Formatters['getListFormat'],\n values: Parameters<IntlFormatters['formatList']>[0],\n options: Parameters<IntlFormatters['formatList']>[1] = {}\n): Part<T>[] {\n const ListFormat: typeof Intl.ListFormat = Intl.ListFormat\n if (!ListFormat) {\n onError(\n new FormatError(\n `Intl.ListFormat is not available in this environment.\nTry polyfilling it using \"@formatjs/intl-listformat\"\n`,\n ErrorCode.MISSING_INTL_API\n )\n )\n }\n const filteredOptions = filterProps(\n options,\n LIST_FORMAT_OPTIONS\n ) as Intl.ListFormatOptions\n\n try {\n const richValues: Record<string, T> = {}\n const serializedValues = Array.from(values).map((v, i) => {\n if (typeof v === 'object' && v !== null) {\n const id = generateToken(i)\n richValues[id] = v as any\n return id\n }\n return String(v)\n })\n return getListFormat(locale, filteredOptions)\n .formatToParts(serializedValues)\n .map(\n part =>\n (part.type === 'literal'\n ? part\n : {...part, value: richValues[part.value] || part.value}) as Part<T>\n )\n } catch (e) {\n onError(new IntlFormatError('Error formatting list.', locale, e))\n }\n\n // @ts-ignore\n return values\n}\n","import {ErrorCode, FormatError} from 'intl-messageformat'\nimport {IntlFormatError} from '#packages/intl/error.js'\nimport {\n type Formatters,\n type IntlFormatters,\n type OnErrorFn,\n} from '#packages/intl/types.js'\nimport {filterProps} from '#packages/intl/utils.js'\n\nconst PLURAL_FORMAT_OPTIONS: Array<keyof Intl.PluralRulesOptions> = ['type']\n\nexport function formatPlural(\n {\n locale,\n onError,\n }: {\n locale: string\n onError: OnErrorFn\n },\n getPluralRules: Formatters['getPluralRules'],\n value: Parameters<IntlFormatters['formatPlural']>[0],\n options: Parameters<IntlFormatters['formatPlural']>[1] = {}\n): Intl.LDMLPluralRule {\n if (!Intl.PluralRules) {\n onError(\n new FormatError(\n `Intl.PluralRules is not available in this environment.\nTry polyfilling it using \"@formatjs/intl-pluralrules\"\n`,\n ErrorCode.MISSING_INTL_API\n )\n )\n }\n const filteredOptions = filterProps(\n options,\n PLURAL_FORMAT_OPTIONS\n ) as Intl.PluralRulesOptions\n\n try {\n return getPluralRules(locale, filteredOptions).select(\n value\n ) as Intl.LDMLPluralRule\n } catch (e) {\n onError(new IntlFormatError('Error formatting plural.', locale, e))\n }\n\n return 'other'\n}\n","import {\n type IntlFormatters,\n type Formatters,\n type CustomFormats,\n type OnErrorFn,\n} from '#packages/intl/types.js'\n\nimport {getNamedFormat, filterProps} from '#packages/intl/utils.js'\nimport {FormatError, ErrorCode} from 'intl-messageformat'\nimport {IntlFormatError} from '#packages/intl/error.js'\n\nconst RELATIVE_TIME_FORMAT_OPTIONS: Array<\n keyof Intl.RelativeTimeFormatOptions\n> = ['numeric', 'style']\n\nfunction getFormatter(\n {\n locale,\n formats,\n onError,\n }: {\n locale: string\n formats: CustomFormats\n onError: OnErrorFn\n },\n getRelativeTimeFormat: Formatters['getRelativeTimeFormat'],\n options: Parameters<IntlFormatters['formatRelativeTime']>[2] = {}\n): Intl.RelativeTimeFormat {\n const {format} = options\n\n const defaults =\n (!!format && getNamedFormat(formats, 'relative', format, onError)) || {}\n const filteredOptions = filterProps(\n options,\n RELATIVE_TIME_FORMAT_OPTIONS,\n defaults as Intl.RelativeTimeFormatOptions\n ) as Intl.RelativeTimeFormatOptions\n\n return getRelativeTimeFormat(locale, filteredOptions)\n}\n\nexport function formatRelativeTime(\n config: {\n locale: string\n formats: CustomFormats\n onError: OnErrorFn\n },\n getRelativeTimeFormat: Formatters['getRelativeTimeFormat'],\n value: Parameters<IntlFormatters['formatRelativeTime']>[0],\n unit?: Parameters<IntlFormatters['formatRelativeTime']>[1],\n options: Parameters<IntlFormatters['formatRelativeTime']>[2] = {}\n): string {\n if (!unit) {\n unit = 'second'\n }\n const RelativeTimeFormat = Intl.RelativeTimeFormat\n if (!RelativeTimeFormat) {\n config.onError(\n new FormatError(\n `Intl.RelativeTimeFormat is not available in this environment.\nTry polyfilling it using \"@formatjs/intl-relativetimeformat\"\n`,\n ErrorCode.MISSING_INTL_API\n )\n )\n }\n try {\n return getFormatter(config, getRelativeTimeFormat, options).format(\n value,\n unit\n )\n } catch (e) {\n config.onError(\n new IntlFormatError('Error formatting relative time.', config.locale, e)\n )\n }\n\n return String(value)\n}\n","import {type NumberFormatOptions} from '#packages/ecma402-abstract/types/number.js'\nimport {IntlFormatError} from '#packages/intl/error.js'\nimport {\n type CustomFormats,\n type Formatters,\n type IntlFormatters,\n type OnErrorFn,\n} from '#packages/intl/types.js'\nimport {filterProps, getNamedFormat} from '#packages/intl/utils.js'\n\nconst NUMBER_FORMAT_OPTIONS: Array<keyof NumberFormatOptions> = [\n 'style',\n 'currency',\n 'unit',\n 'unitDisplay',\n 'useGrouping',\n\n 'minimumIntegerDigits',\n 'minimumFractionDigits',\n 'maximumFractionDigits',\n 'minimumSignificantDigits',\n 'maximumSignificantDigits',\n\n // ES2020 NumberFormat\n 'compactDisplay',\n 'currencyDisplay',\n 'currencySign',\n 'notation',\n 'signDisplay',\n 'unit',\n 'unitDisplay',\n 'numberingSystem',\n\n // ES2023 NumberFormat\n 'trailingZeroDisplay',\n 'roundingPriority',\n 'roundingIncrement',\n 'roundingMode',\n]\n\nexport function getFormatter(\n {\n locale,\n formats,\n onError,\n }: {\n locale: string\n\n formats: CustomFormats\n onError: OnErrorFn\n },\n getNumberFormat: Formatters['getNumberFormat'],\n options: Parameters<IntlFormatters['formatNumber']>[1] = {}\n): Intl.NumberFormat {\n const {format} = options\n const defaults = ((format &&\n getNamedFormat(formats!, 'number', format, onError)) ||\n {}) as NumberFormatOptions\n const filteredOptions = filterProps(\n options,\n NUMBER_FORMAT_OPTIONS,\n defaults\n ) as NumberFormatOptions\n\n return getNumberFormat(locale, filteredOptions)\n}\n\nexport function formatNumber(\n config: {\n locale: string\n\n formats: CustomFormats\n onError: OnErrorFn\n },\n getNumberFormat: Formatters['getNumberFormat'],\n value: Parameters<IntlFormatters['formatNumber']>[0],\n options: Parameters<IntlFormatters['formatNumber']>[1] = {}\n): string {\n try {\n return getFormatter(config, getNumberFormat, options).format(value)\n } catch (e) {\n config.onError(\n new IntlFormatError('Error formatting number.', config.locale, e)\n )\n }\n\n return String(value)\n}\n\nexport function formatNumberToParts(\n config: {\n locale: string\n formats: CustomFormats\n onError: OnErrorFn\n },\n getNumberFormat: Formatters['getNumberFormat'],\n value: Parameters<IntlFormatters['formatNumber']>[0],\n options: Parameters<IntlFormatters['formatNumber']>[1] = {}\n): Intl.NumberFormatPart[] {\n try {\n return getFormatter(config, getNumberFormat, options).formatToParts(\n value as number\n )\n } catch (e) {\n config.onError(\n new IntlFormatError('Error formatting number.', config.locale, e)\n )\n }\n\n return []\n}\n","import {type MessageFormatElement} from '@formatjs/icu-messageformat-parser'\nimport {\n formatDate,\n formatDateTimeRange,\n formatDateToParts,\n formatTime,\n formatTimeToParts,\n} from '#packages/intl/dateTime.js'\nimport {formatDisplayName} from '#packages/intl/displayName.js'\nimport {InvalidConfigError, MissingDataError} from '#packages/intl/error.js'\nimport {formatList, formatListToParts} from '#packages/intl/list.js'\nimport {formatMessage} from '#packages/intl/message.js'\nimport {formatNumber, formatNumberToParts} from '#packages/intl/number.js'\nimport {formatPlural} from '#packages/intl/plural.js'\nimport {formatRelativeTime} from '#packages/intl/relativeTime.js'\nimport {\n type IntlCache,\n type IntlConfig,\n type IntlShape,\n type ResolvedIntlConfig,\n} from '#packages/intl/types.js'\nimport {createFormatters, DEFAULT_INTL_CONFIG} from '#packages/intl/utils.js'\n\nexport interface CreateIntlFn<\n T = string,\n C extends IntlConfig<T> = IntlConfig<T>,\n S extends IntlShape<T> = IntlShape<T>,\n> {\n (config: C, cache?: IntlCache): S\n}\n\nfunction messagesContainString(\n messages: Record<string, string> | Record<string, MessageFormatElement[]>\n): messages is Record<string, MessageFormatElement[]> {\n const firstMessage = messages ? messages[Object.keys(messages)[0]] : undefined\n\n return typeof firstMessage === 'string'\n}\n\nfunction verifyConfigMessages<T = string>(config: IntlConfig<T>) {\n if (\n config.onWarn &&\n config.defaultRichTextElements &&\n messagesContainString(config.messages || {})\n ) {\n config.onWarn(`[@formatjs/intl] \"defaultRichTextElements\" was specified but \"message\" was not pre-compiled. \nPlease consider using \"@formatjs/cli\" to pre-compile your messages for performance.\nFor more details see https://formatjs.github.io/docs/getting-started/message-distribution`)\n }\n}\n\n/**\n * Create intl object\n * @param config intl config\n * @param cache cache for formatter instances to prevent memory leak\n */\nexport function createIntl<T = string>(\n config: IntlConfig<T>,\n cache?: IntlCache\n): IntlShape<T> {\n const formatters = createFormatters(cache)\n const resolvedConfig: ResolvedIntlConfig<T> = {\n ...DEFAULT_INTL_CONFIG,\n ...config,\n }\n\n const {locale, defaultLocale, onError} = resolvedConfig\n if (!locale) {\n if (onError) {\n onError(\n new InvalidConfigError(\n `\"locale\" was not configured, using \"${defaultLocale}\" as fallback. See https://formatjs.github.io/docs/react-intl/api#intlshape for more details`\n )\n )\n }\n // Since there's no registered locale data for `locale`, this will\n // fallback to the `defaultLocale` to make sure things can render.\n // The `messages` are overridden to the `defaultProps` empty object\n // to maintain referential equality across re-renders. It's assumed\n // each <FormattedMessage> contains a `defaultMessage` prop.\n resolvedConfig.locale = resolvedConfig.defaultLocale || 'en'\n } else if (!Intl.NumberFormat.supportedLocalesOf(locale).length && onError) {\n onError(\n new MissingDataError(\n `Missing locale data for locale: \"${locale}\" in Intl.NumberFormat. Using default locale: \"${defaultLocale}\" as fallback. See https://formatjs.github.io/docs/react-intl#runtime-requirements for more details`\n )\n )\n } else if (\n !Intl.DateTimeFormat.supportedLocalesOf(locale).length &&\n onError\n ) {\n onError(\n new MissingDataError(\n `Missing locale data for locale: \"${locale}\" in Intl.DateTimeFormat. Using default locale: \"${defaultLocale}\" as fallback. See https://formatjs.github.io/docs/react-intl#runtime-requirements for more details`\n )\n )\n }\n\n verifyConfigMessages(resolvedConfig)\n return {\n ...resolvedConfig,\n formatters,\n formatNumber: formatNumber.bind(\n null,\n resolvedConfig,\n formatters.getNumberFormat\n ),\n formatNumberToParts: formatNumberToParts.bind(\n null,\n resolvedConfig,\n formatters.getNumberFormat\n ),\n formatRelativeTime: formatRelativeTime.bind(\n null,\n resolvedConfig,\n formatters.getRelativeTimeFormat\n ),\n formatDate: formatDate.bind(\n null,\n resolvedConfig,\n formatters.getDateTimeFormat\n ),\n formatDateToParts: formatDateToParts.bind(\n null,\n resolvedConfig,\n formatters.getDateTimeFormat\n ),\n formatTime: formatTime.bind(\n null,\n resolvedConfig,\n formatters.getDateTimeFormat\n ),\n formatDateTimeRange: formatDateTimeRange.bind(\n null,\n resolvedConfig,\n formatters.getDateTimeFormat\n ),\n formatTimeToParts: formatTimeToParts.bind(\n null,\n resolvedConfig,\n formatters.getDateTimeFormat\n ),\n formatPlural: formatPlural.bind(\n null,\n resolvedConfig,\n formatters.getPluralRules\n ),\n formatMessage: formatMessage.bind(null, resolvedConfig, formatters),\n $t: formatMessage.bind(null, resolvedConfig, formatters),\n formatList: formatList.bind(null, resolvedConfig, formatters.getListFormat),\n formatListToParts: formatListToParts.bind(\n null,\n resolvedConfig,\n formatters.getListFormat\n ),\n formatDisplayName: formatDisplayName.bind(\n null,\n resolvedConfig,\n formatters.getDisplayNames\n ),\n }\n}\n","import {type MessageDescriptor} from '#packages/intl/types.js'\nexport * from '#packages/intl/types.js'\n\nexport function defineMessages<\n K extends keyof any,\n T = MessageDescriptor,\n U extends Record<K, T> = Record<K, T>,\n>(msgs: U): U {\n return msgs\n}\n\nexport function defineMessage<T>(msg: T): T {\n return msg\n}\n\nexport {\n createIntlCache,\n filterProps,\n DEFAULT_INTL_CONFIG,\n createFormatters,\n getNamedFormat,\n} from '#packages/intl/utils.js'\nexport * from '#packages/intl/error.js'\nexport {formatMessage} from '#packages/intl/message.js'\nexport type {FormatMessageFn} from '#packages/intl/message.js'\nexport {\n formatDate,\n formatDateToParts,\n formatTime,\n formatTimeToParts,\n} from '#packages/intl/dateTime.js'\nexport {formatDisplayName} from '#packages/intl/displayName.js'\nexport {formatList} from '#packages/intl/list.js'\nexport {formatPlural} from '#packages/intl/plural.js'\nexport {formatRelativeTime} from '#packages/intl/relativeTime.js'\nexport {formatNumber, formatNumberToParts} from '#packages/intl/number.js'\nexport {createIntl} from '#packages/intl/create-intl.js'\nexport type {CreateIntlFn} from '#packages/intl/create-intl.js'\n"],"mappings":";;;;AAEA,IAAY,gBAAL,yBAAA,eAAA;CACL,cAAA,kBAAA;CACA,cAAA,2BAAA;CACA,cAAA,oBAAA;CACA,cAAA,kBAAA;CACA,cAAA,yBAAA;;AACF,EAAA,CAAA,CAAA;AAEA,IAAa,YAAb,MAAa,kBAEH,MAAM;CAGd,YAAY,MAAS,SAAiB,WAA6B;EACjE,MAAM,MAAM,YACR,qBAAqB,QACnB,YACA,IAAI,MAAM,OAAO,SAAS,CAAC,IAC7B,KAAA;EACJ,MACE,yBAAyB,KAAK,IAAI,QAAQ;EAC9C,MAAM,KAAK,IAAI,QAAQ,IAAI,IAAI,UAAU,IACvC;EACA,KAAK,OAAO;EAEZ,IAAI,OAAO,MAAM,sBAAsB,YAErC,MAAM,kBAAkB,MAAM,SAAS;CAE3C;AACF;AAEA,IAAa,4BAAb,cAA+C,UAA+C;CAC5F,YAAY,SAAiB,WAA6B;EACxD,MAAA,yBAA2C,SAAS,SAAS;CAC/D;AACF;AAEA,IAAa,qBAAb,cAAwC,UAAwC;CAC9E,YAAY,SAAiB,WAA6B;EACxD,MAAA,kBAAoC,SAAS,SAAS;CACxD;A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,iBACb;EACA,mBAAmB,kBAAkB,KACnC,MACA,gBACA,WAAW,iBACb;EACA,cAAc,aAAa,KACzB,MACA,gBACA,WAAW,cACb;EACA,eAAe,cAAc,KAAK,MAAM,gBAAgB,UAAU;EAClE,IAAI,cAAc,KAAK,MAAM,gBAAgB,UAAU;EACvD,YAAY,WAAW,KAAK,MAAM,gBAAgB,WAAW,aAAa;EAC1E,mBAAmB,kBAAkB,KACnC,MACA,gBACA,WAAW,aACb;EACA,mBAAmB,kBAAkB,KACnC,MACA,gBACA,WAAW,eACb;CACF;AACF;;;AC9JA,SAAgB,eAId,MAAY;CACZ,OAAO;AACT;AAEA,SAAgB,cAAiB,KAAW;CAC1C,OAAO;AACT"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["getFormatter","getFormatter","getFormatter"],"sources":["../error.ts","../utils.ts","../message.ts","../dateTime.ts","../duration.ts","../displayName.ts","../list.ts","../plural.ts","../relativeTime.ts","../number.ts","../create-intl.ts","../index.ts"],"sourcesContent":["import {type MessageDescriptor} from '#packages/intl/types.js'\n\nexport enum IntlErrorCode {\n FORMAT_ERROR = 'FORMAT_ERROR',\n UNSUPPORTED_FORMATTER = 'UNSUPPORTED_FORMATTER',\n INVALID_CONFIG = 'INVALID_CONFIG',\n MISSING_DATA = 'MISSING_DATA',\n MISSING_TRANSLATION = 'MISSING_TRANSLATION',\n}\n\nexport class IntlError<\n T extends IntlErrorCode = IntlErrorCode.FORMAT_ERROR,\n> extends Error {\n public readonly code: T\n\n constructor(code: T, message: string, exception?: Error | unknown) {\n const err = exception\n ? exception instanceof Error\n ? exception\n : new Error(String(exception))\n : undefined\n super(\n `[@formatjs/intl Error ${code}] ${message}\n${err ? `\\n${err.message}\\n${err.stack}` : ''}`\n )\n this.code = code\n // @ts-ignore just so we don't need to declare dep on @types/node\n if (typeof Error.captureStackTrace === 'function') {\n // @ts-ignore just so we don't need to declare dep on @types/node\n Error.captureStackTrace(this, IntlError)\n }\n }\n}\n\nexport class UnsupportedFormatterError extends IntlError<IntlErrorCode.UNSUPPORTED_FORMATTER> {\n constructor(message: string, exception?: Error | unknown) {\n super(IntlErrorCode.UNSUPPORTED_FORMATTER, message, exception)\n }\n}\n\nexport class InvalidConfigError extends IntlError<IntlErrorCode.INVALID_CONFIG> {\n constructor(message: string, exception?: Error | unknown) {\n super(IntlErrorCode.INVALID_CONFIG, message, exception)\n }\n}\n\nexport class MissingDataError extends IntlError<IntlErrorCode.MISSING_DATA> {\n constructor(message: string, exception?: Error | unknown) {\n super(IntlErrorCode.MISSING_DATA, message, exception)\n }\n}\n\nexport class IntlFormatError extends IntlError<IntlErrorCode.FORMAT_ERROR> {\n public readonly descriptor?: MessageDescriptor\n public readonly locale: string\n constructor(message: string, locale: string, exception?: Error | unknown) {\n super(\n IntlErrorCode.FORMAT_ERROR,\n `${message}\nLocale: ${locale}\n`,\n exception\n )\n this.locale = locale\n }\n}\n\nexport class MessageFormatError extends IntlFormatError {\n public readonly descriptor?: MessageDescriptor\n public readonly locale: string\n constructor(\n message: string,\n locale: string,\n descriptor?: MessageDescriptor,\n exception?: Error | unknown\n ) {\n super(\n `${message}\nMessageID: ${descriptor?.id}\nDefault Message: ${descriptor?.defaultMessage}\nDescription: ${descriptor?.description}\n`,\n locale,\n exception\n )\n this.descriptor = descriptor\n this.locale = locale\n }\n}\n\nexport class MissingTranslationError extends IntlError<IntlErrorCode.MISSING_TRANSLATION> {\n public readonly descriptor?: MessageDescriptor\n constructor(descriptor: MessageDescriptor, locale: string) {\n super(\n IntlErrorCode.MISSING_TRANSLATION,\n `Missing message: \"${descriptor.id}\" for locale \"${locale}\", using ${\n descriptor.defaultMessage\n ? `default message (${\n typeof descriptor.defaultMessage === 'string'\n ? descriptor.defaultMessage\n : descriptor.defaultMessage\n .map((e: any) => e.value ?? JSON.stringify(e))\n .join()\n })`\n : 'id'\n } as fallback.`\n )\n this.descriptor = descriptor\n }\n}\n","import type {DurationFormatOptions} from '#packages/ecma402-abstract/types/duration.js'\nimport {type NumberFormatOptions} from '#packages/ecma402-abstract/types/number.js'\nimport {type Cache, memoize, strategies} from '@formatjs/fast-memoize'\nimport {IntlMessageFormat} from 'intl-messageformat'\nimport {UnsupportedFormatterError} from '#packages/intl/error.js'\nimport {\n type CustomFormats,\n type Formatters,\n type IntlCache,\n type OnErrorFn,\n type OnWarnFn,\n type ResolvedIntlConfig,\n} from '#packages/intl/types.js'\n\nexport function invariant(\n condition: boolean,\n message: string,\n Err: any = Error\n): asserts condition {\n if (!condition) {\n throw new Err(message)\n }\n}\n\nexport function filterProps<T extends Record<string, any>, K extends string>(\n props: T,\n allowlist: Array<K>,\n defaults: Partial<T> = {}\n): Pick<T, K> {\n return allowlist.reduce(\n (filtered, name) => {\n if (name in props) {\n filtered[name] = props[name]\n } else if (name in defaults) {\n filtered[name] = defaults[name]!\n }\n\n return filtered\n },\n {} as Pick<T, K>\n )\n}\n\nconst defaultErrorHandler: OnErrorFn = error => {\n // @ts-ignore just so we don't need to declare dep on @types/node\n if (process.env.NODE_ENV !== 'production') {\n console.error(error)\n }\n}\n\nconst defaultWarnHandler: OnWarnFn = (warning: string) => {\n // @ts-ignore just so we don't need to declare dep on @types/node\n if (process.env.NODE_ENV !== 'production') {\n console.warn(warning)\n }\n}\n\nexport const DEFAULT_INTL_CONFIG: Pick<\n ResolvedIntlConfig<any>,\n | 'fallbackOnEmptyString'\n | 'formats'\n | 'messages'\n | 'timeZone'\n | 'defaultLocale'\n | 'defaultFormats'\n | 'onError'\n | 'onWarn'\n> = {\n formats: {},\n messages: {},\n timeZone: undefined,\n\n defaultLocale: 'en',\n defaultFormats: {},\n\n fallbackOnEmptyString: true,\n\n onError: defaultErrorHandler,\n onWarn: defaultWarnHandler,\n}\n\nexport function createIntlCache(): IntlCache {\n return {\n dateTime: {},\n number: {},\n message: {},\n duration: {},\n relativeTime: {},\n pluralRules: {},\n list: {},\n displayNames: {},\n }\n}\n\nfunction createFastMemoizeCache<V>(\n store: Record<string, V | undefined>\n): Cache<string, V> {\n return {\n create() {\n return {\n get(key) {\n return store[key]\n },\n set(key, value) {\n store[key] = value\n },\n }\n },\n }\n}\n\n/**\n * Create intl formatters and populate cache\n * @param cache explicit cache to prevent leaking memory\n */\nexport function createFormatters(\n cache: IntlCache = createIntlCache()\n): Formatters {\n const RelativeTimeFormat = (Intl as any).RelativeTimeFormat\n const ListFormat = (Intl as any).ListFormat\n const DisplayNames = (Intl as any).DisplayNames\n const getDateTimeFormat = memoize(\n (...args) => new Intl.DateTimeFormat(...args),\n {\n cache: createFastMemoizeCache(cache.dateTime),\n strategy: strategies.variadic,\n }\n )\n const getNumberFormat = memoize((...args) => new Intl.NumberFormat(...args), {\n cache: createFastMemoizeCache(cache.number),\n strategy: strategies.variadic,\n })\n const getPluralRules = memoize((...args) => new Intl.PluralRules(...args), {\n cache: createFastMemoizeCache(cache.pluralRules),\n strategy: strategies.variadic,\n })\n return {\n getDateTimeFormat,\n getNumberFormat,\n getMessageFormat: memoize(\n (message, locales, overrideFormats, opts) =>\n new IntlMessageFormat(message, locales, overrideFormats, {\n formatters: {\n getNumberFormat,\n getDateTimeFormat,\n getPluralRules,\n },\n ...opts,\n }),\n {\n cache: createFastMemoizeCache(cache.message),\n strategy: strategies.variadic,\n }\n ),\n getDurationFormat: memoize((...args) => new Intl.DurationFormat(...args), {\n cache: createFastMemoizeCache(cache.duration),\n strategy: strategies.variadic,\n }),\n getRelativeTimeFormat: memoize(\n (...args) => new RelativeTimeFormat(...args),\n {\n cache: createFastMemoizeCache(cache.relativeTime),\n strategy: strategies.variadic,\n }\n ),\n getPluralRules,\n getListFormat: memoize((...args) => new ListFormat(...args), {\n cache: createFastMemoizeCache(cache.list),\n strategy: strategies.variadic,\n }),\n getDisplayNames: memoize((...args) => new DisplayNames(...args), {\n cache: createFastMemoizeCache(cache.displayNames),\n strategy: strategies.variadic,\n }),\n }\n}\n\nexport function getNamedFormat<T extends keyof CustomFormats>(\n formats: CustomFormats,\n type: T,\n name: string,\n onError: OnErrorFn\n):\n | NumberFormatOptions\n | Intl.DateTimeFormatOptions\n | Intl.RelativeTimeFormatOptions\n | DurationFormatOptions\n | undefined {\n const formatType = formats && formats[type]\n let format\n if (formatType) {\n format = formatType[name]\n }\n if (format) {\n return format\n }\n\n onError(new UnsupportedFormatterError(`No ${type} format named: ${name}`))\n}\n","import {\n type CustomFormats,\n type Formatters,\n type MessageDescriptor,\n type OnErrorFn,\n} from '#packages/intl/types.js'\n\nimport {\n type MessageFormatElement,\n TYPE,\n} from '@formatjs/icu-messageformat-parser'\nimport {\n type FormatXMLElementFn,\n IntlMessageFormat,\n type Formatters as IntlMessageFormatFormatters,\n type Options,\n type PrimitiveType,\n} from 'intl-messageformat'\nimport {\n MessageFormatError,\n MissingTranslationError,\n} from '#packages/intl/error.js'\nimport {invariant} from '#packages/intl/utils.js'\n\nfunction setTimeZoneInOptions(\n opts: Record<string, Intl.DateTimeFormatOptions>,\n timeZone: string\n): Record<string, Intl.DateTimeFormatOptions> {\n return Object.keys(opts).reduce(\n (all: Record<string, Intl.DateTimeFormatOptions>, k) => {\n all[k] = {\n timeZone,\n ...opts[k],\n }\n return all\n },\n {}\n )\n}\n\nfunction deepMergeOptions(\n opts1: Record<string, Intl.DateTimeFormatOptions>,\n opts2: Record<string, Intl.DateTimeFormatOptions>\n): Record<string, Intl.DateTimeFormatOptions> {\n const keys = Object.keys({...opts1, ...opts2})\n return keys.reduce((all: Record<string, Intl.DateTimeFormatOptions>, k) => {\n all[k] = {\n ...opts1[k],\n ...opts2[k],\n }\n return all\n }, {})\n}\n\nfunction deepMergeFormatsAndSetTimeZone(\n f1: CustomFormats,\n timeZone?: string\n): CustomFormats {\n if (!timeZone) {\n return f1\n }\n const mfFormats = IntlMessageFormat.formats\n return {\n ...mfFormats,\n ...f1,\n date: deepMergeOptions(\n setTimeZoneInOptions(mfFormats.date, timeZone),\n setTimeZoneInOptions(f1.date || {}, timeZone)\n ),\n time: deepMergeOptions(\n setTimeZoneInOptions(mfFormats.time, timeZone),\n setTimeZoneInOptions(f1.time || {}, timeZone)\n ),\n }\n}\n\nexport type FormatMessageFn<T> = (\n {\n locale,\n formats,\n messages,\n defaultLocale,\n defaultFormats,\n fallbackOnEmptyString,\n onError,\n timeZone,\n defaultRichTextElements,\n }: {\n locale: string\n timeZone?: string\n formats: CustomFormats\n messages: Record<string, string> | Record<string, MessageFormatElement[]>\n defaultLocale: string\n defaultFormats: CustomFormats\n defaultRichTextElements?: Record<string, FormatXMLElementFn<T>>\n fallbackOnEmptyString?: boolean\n onError: OnErrorFn\n },\n state: IntlMessageFormatFormatters & Pick<Formatters, 'getMessageFormat'>,\n messageDescriptor: MessageDescriptor,\n values?: Record<string, PrimitiveType | T | FormatXMLElementFn<T>>,\n opts?: Options\n) => T extends string ? string : Array<T | string> | string | T\n\nfunction getMessageDescriptorContext(\n messageDescriptor: MessageDescriptor\n): string {\n const {defaultMessage} = messageDescriptor\n try {\n return defaultMessage !== undefined\n ? `\\nDefault Message: ${\n typeof defaultMessage === 'string'\n ? defaultMessage\n : JSON.stringify(defaultMessage)\n }`\n : `\\nMessage Descriptor: ${JSON.stringify(messageDescriptor)}`\n } catch {\n return ''\n }\n}\n\nexport const formatMessage: FormatMessageFn<any> = (\n {\n locale,\n formats,\n messages,\n defaultLocale,\n defaultFormats,\n fallbackOnEmptyString,\n onError,\n timeZone,\n defaultRichTextElements,\n },\n state,\n messageDescriptor = {id: ''},\n values,\n opts\n) => {\n const {id: msgId, defaultMessage} = messageDescriptor\n\n // `id` is a required field of a Message Descriptor.\n if (!msgId) {\n invariant(\n false,\n `[@formatjs/intl] An \\`id\\` must be provided to format a message. You can either:\n1. Configure your build toolchain with [babel-plugin-formatjs](https://formatjs.github.io/docs/tooling/babel-plugin)\nor [@formatjs/ts-transformer](https://formatjs.github.io/docs/tooling/ts-transformer) OR\n2. Configure your \\`eslint\\` config to include [eslint-plugin-formatjs](https://formatjs.github.io/docs/tooling/linter#enforce-id)\nto autofix this issue${getMessageDescriptorContext(messageDescriptor)}`\n )\n }\n const id = String(msgId)\n const message =\n // In case messages is Object.create(null)\n // e.g import('foo.json') from webpack)\n // See https://github.com/formatjs/formatjs/issues/1914\n messages &&\n Object.prototype.hasOwnProperty.call(messages, id) &&\n messages[id]\n\n // IMPORTANT: Hot path if `message` is AST with a single literal node\n if (\n Array.isArray(message) &&\n message.length === 1 &&\n message[0].type === TYPE.literal\n ) {\n return message[0].value\n }\n\n values = {\n ...defaultRichTextElements,\n ...values,\n }\n formats = deepMergeFormatsAndSetTimeZone(formats, timeZone)\n defaultFormats = deepMergeFormatsAndSetTimeZone(defaultFormats, timeZone)\n\n if (!message) {\n if (fallbackOnEmptyString === false && message === '') {\n return message\n }\n\n if (\n !defaultMessage ||\n (locale && locale.toLowerCase() !== defaultLocale.toLowerCase())\n ) {\n // This prevents warnings from littering the console in development\n // when no `messages` are passed into the <IntlProvider> for the\n // default locale.\n onError(new MissingTranslationError(messageDescriptor, locale))\n }\n if (defaultMessage) {\n try {\n const formatter = state.getMessageFormat(\n defaultMessage,\n defaultLocale,\n defaultFormats,\n opts\n )\n\n return formatter.format(values)\n } catch (e) {\n onError(\n new MessageFormatError(\n `Error formatting default message for: \"${id}\", rendering default message verbatim`,\n locale,\n messageDescriptor,\n e\n )\n )\n return typeof defaultMessage === 'string' ? defaultMessage : id\n }\n }\n return id\n }\n\n // We have the translated message\n try {\n const formatter = state.getMessageFormat(message, locale, formats, {\n formatters: state,\n ...opts,\n })\n\n return formatter.format<any>(values)\n } catch (e) {\n onError(\n new MessageFormatError(\n `Error formatting message: \"${id}\", using ${\n defaultMessage ? 'default message' : 'id'\n } as fallback.`,\n locale,\n messageDescriptor,\n e\n )\n )\n }\n\n if (defaultMessage) {\n try {\n const formatter = state.getMessageFormat(\n defaultMessage,\n defaultLocale,\n defaultFormats,\n opts\n )\n\n return formatter.format(values)\n } catch (e) {\n onError(\n new MessageFormatError(\n `Error formatting the default message for: \"${id}\", rendering message verbatim`,\n locale,\n messageDescriptor,\n e\n )\n )\n }\n }\n\n if (typeof message === 'string') {\n return message\n }\n if (typeof defaultMessage === 'string') {\n return defaultMessage\n }\n return id\n}\n","import {\n type CustomFormats,\n type Formatters,\n type IntlFormatters,\n type OnErrorFn,\n} from '#packages/intl/types.js'\n\nimport {IntlFormatError} from '#packages/intl/error.js'\nimport {filterProps, getNamedFormat} from '#packages/intl/utils.js'\n\nconst DATE_TIME_FORMAT_OPTIONS: Array<keyof Intl.DateTimeFormatOptions> = [\n 'formatMatcher',\n\n 'timeZone',\n 'hour12',\n\n 'weekday',\n 'era',\n 'year',\n 'month',\n 'day',\n 'hour',\n 'minute',\n 'second',\n 'timeZoneName',\n 'hourCycle',\n 'dateStyle',\n 'timeStyle',\n 'calendar',\n // 'dayPeriod',\n 'numberingSystem',\n 'fractionalSecondDigits',\n]\n\nexport function getFormatter(\n {\n locale,\n formats,\n onError,\n timeZone,\n }: {\n locale: string\n timeZone?: string\n formats: CustomFormats\n onError: OnErrorFn\n },\n type: 'date' | 'time' | 'dateTimeRange',\n getDateTimeFormat: Formatters['getDateTimeFormat'],\n options: Parameters<IntlFormatters['formatDate']>[1] = {}\n): Intl.DateTimeFormat {\n const {format} = options\n const defaults = {\n ...(timeZone && {timeZone}),\n ...(format && getNamedFormat(formats!, type, format, onError)),\n }\n\n let filteredOptions = filterProps(\n options,\n DATE_TIME_FORMAT_OPTIONS,\n defaults\n ) as Intl.DateTimeFormatOptions\n\n if (\n type === 'time' &&\n !filteredOptions.hour &&\n !filteredOptions.minute &&\n !filteredOptions.second &&\n !filteredOptions.timeStyle &&\n !filteredOptions.dateStyle\n ) {\n // Add default formatting options if hour, minute, or second isn't defined.\n filteredOptions = {...filteredOptions, hour: 'numeric', minute: 'numeric'}\n }\n\n return getDateTimeFormat(locale, filteredOptions)\n}\n\nexport function formatDate(\n config: {\n locale: string\n timeZone?: string\n formats: CustomFormats\n onError: OnErrorFn\n },\n getDateTimeFormat: Formatters['getDateTimeFormat'],\n value: Parameters<IntlFormatters['formatDate']>[0],\n options: Parameters<IntlFormatters['formatDate']>[1] = {}\n): string {\n const date = typeof value === 'string' ? new Date(value || 0) : value\n try {\n return getFormatter(config, 'date', getDateTimeFormat, options).format(date)\n } catch (e) {\n config.onError(\n new IntlFormatError('Error formatting date.', config.locale, e)\n )\n }\n\n return String(date)\n}\n\nexport function formatTime(\n config: {\n locale: string\n timeZone?: string\n formats: CustomFormats\n onError: OnErrorFn\n },\n getDateTimeFormat: Formatters['getDateTimeFormat'],\n value: Parameters<IntlFormatters['formatTime']>[0],\n options: Parameters<IntlFormatters['formatTime']>[1] = {}\n): string {\n const date = typeof value === 'string' ? new Date(value || 0) : value\n\n try {\n return getFormatter(config, 'time', getDateTimeFormat, options).format(date)\n } catch (e) {\n config.onError(\n new IntlFormatError('Error formatting time.', config.locale, e)\n )\n }\n\n return String(date)\n}\n\nexport function formatDateTimeRange(\n config: {\n locale: string\n timeZone?: string\n formats: CustomFormats\n onError: OnErrorFn\n },\n getDateTimeFormat: Formatters['getDateTimeFormat'],\n from: Parameters<IntlFormatters['formatDateTimeRange']>[0],\n to: Parameters<IntlFormatters['formatDateTimeRange']>[1],\n options: Parameters<IntlFormatters['formatDateTimeRange']>[2] = {}\n): string {\n const fromDate = typeof from === 'string' ? new Date(from || 0) : from\n const toDate = typeof to === 'string' ? new Date(to || 0) : to\n\n try {\n return getFormatter(\n config,\n 'dateTimeRange',\n getDateTimeFormat,\n options\n ).formatRange(fromDate, toDate)\n } catch (e) {\n config.onError(\n new IntlFormatError('Error formatting date time range.', config.locale, e)\n )\n }\n\n return String(fromDate)\n}\n\nexport function formatDateToParts(\n config: {\n locale: string\n timeZone?: string\n formats: CustomFormats\n onError: OnErrorFn\n },\n getDateTimeFormat: Formatters['getDateTimeFormat'],\n value: Parameters<IntlFormatters['formatDate']>[0],\n options: Parameters<IntlFormatters['formatDate']>[1] = {}\n): Intl.DateTimeFormatPart[] {\n const date = typeof value === 'string' ? new Date(value || 0) : value\n try {\n return getFormatter(\n config,\n 'date',\n getDateTimeFormat,\n options\n ).formatToParts(date) as Intl.DateTimeFormatPart[] // TODO: remove this when https://github.com/microsoft/TypeScript/pull/50402 is merged\n } catch (e) {\n config.onError(\n new IntlFormatError('Error formatting date.', config.locale, e)\n )\n }\n\n return []\n}\n\nexport function formatTimeToParts(\n config: {\n locale: string\n timeZone?: string\n formats: CustomFormats\n onError: OnErrorFn\n },\n getDateTimeFormat: Formatters['getDateTimeFormat'],\n value: Parameters<IntlFormatters['formatTimeToParts']>[0],\n options: Parameters<IntlFormatters['formatTimeToParts']>[1] = {}\n): Intl.DateTimeFormatPart[] {\n const date = typeof value === 'string' ? new Date(value || 0) : value\n\n try {\n return getFormatter(\n config,\n 'time',\n getDateTimeFormat,\n options\n ).formatToParts(date) as Intl.DateTimeFormatPart[] // TODO: remove this when https://github.com/microsoft/TypeScript/pull/50402 is merged\n } catch (e) {\n config.onError(\n new IntlFormatError('Error formatting time.', config.locale, e)\n )\n }\n\n return []\n}\n","import {IntlFormatError} from '#packages/intl/error.js'\nimport type {\n CustomFormats,\n FormatDurationOptions,\n Formatters,\n IntlFormatters,\n OnErrorFn,\n} from '#packages/intl/types.js'\nimport {filterProps, getNamedFormat} from '#packages/intl/utils.js'\nimport {ErrorCode, FormatError} from 'intl-messageformat'\n\nconst DURATION_FORMAT_OPTIONS: Array<\n Exclude<keyof FormatDurationOptions, 'format'>\n> = [\n 'style',\n 'numberingSystem',\n 'years',\n 'yearsDisplay',\n 'months',\n 'monthsDisplay',\n 'weeks',\n 'weeksDisplay',\n 'days',\n 'daysDisplay',\n 'hours',\n 'hoursDisplay',\n 'minutes',\n 'minutesDisplay',\n 'seconds',\n 'secondsDisplay',\n 'milliseconds',\n 'millisecondsDisplay',\n 'microseconds',\n 'microsecondsDisplay',\n 'nanoseconds',\n 'nanosecondsDisplay',\n 'fractionalDigits',\n]\n\ntype Config = {\n locale: string\n formats: CustomFormats\n onError: OnErrorFn\n}\n\nfunction getFormatter(\n {locale, formats, onError}: Config,\n getDurationFormat: Formatters['getDurationFormat'],\n options: FormatDurationOptions\n): ReturnType<Formatters['getDurationFormat']> | undefined {\n if (!Intl.DurationFormat) {\n onError(\n new FormatError(\n 'Intl.DurationFormat is not available in this environment.\\nTry polyfilling it using \"@formatjs/intl-durationformat\"',\n ErrorCode.MISSING_INTL_API\n )\n )\n return\n }\n\n const {format} = options\n const defaults = ((format &&\n getNamedFormat(formats, 'duration', format, onError)) ||\n {}) as FormatDurationOptions\n return getDurationFormat(\n locale,\n filterProps(options, DURATION_FORMAT_OPTIONS, defaults)\n )\n}\n\nexport function formatDuration(\n config: Config,\n getDurationFormat: Formatters['getDurationFormat'],\n value: Parameters<IntlFormatters['formatDuration']>[0],\n options: FormatDurationOptions = {}\n): string {\n try {\n return getFormatter(config, getDurationFormat, options)?.format(value) ?? ''\n } catch (e) {\n config.onError(\n new IntlFormatError('Error formatting duration.', config.locale, e)\n )\n }\n return ''\n}\n\nexport function formatDurationToParts(\n config: Config,\n getDurationFormat: Formatters['getDurationFormat'],\n value: Parameters<IntlFormatters['formatDuration']>[0],\n options: FormatDurationOptions = {}\n): ReturnType<IntlFormatters['formatDurationToParts']> {\n try {\n return (\n getFormatter(config, getDurationFormat, options)?.formatToParts(value) ??\n []\n )\n } catch (e) {\n config.onError(\n new IntlFormatError('Error formatting duration.', config.locale, e)\n )\n }\n return []\n}\n","import {\n type Formatters,\n type IntlFormatters,\n type OnErrorFn,\n} from '#packages/intl/types.js'\nimport {filterProps} from '#packages/intl/utils.js'\n\nimport {ErrorCode, FormatError} from 'intl-messageformat'\nimport {IntlFormatError} from '#packages/intl/error.js'\n\nconst DISPLAY_NAMES_OPTONS: Array<keyof Intl.DisplayNamesOptions> = [\n 'style',\n 'type',\n 'fallback',\n 'languageDisplay',\n]\n\nexport function formatDisplayName(\n {\n locale,\n onError,\n }: {\n locale: string\n onError: OnErrorFn\n },\n getDisplayNames: Formatters['getDisplayNames'],\n value: Parameters<IntlFormatters['formatDisplayName']>[0],\n options: Parameters<IntlFormatters['formatDisplayName']>[1]\n): string | undefined {\n const DisplayNames: typeof Intl.DisplayNames = (Intl as any).DisplayNames\n if (!DisplayNames) {\n onError(\n new FormatError(\n `Intl.DisplayNames is not available in this environment.\nTry polyfilling it using \"@formatjs/intl-displaynames\"\n`,\n ErrorCode.MISSING_INTL_API\n )\n )\n }\n const filteredOptions = filterProps(\n options,\n DISPLAY_NAMES_OPTONS\n ) as Intl.DisplayNamesOptions\n try {\n return getDisplayNames(locale, filteredOptions).of(value)\n } catch (e) {\n onError(new IntlFormatError('Error formatting display name.', locale, e))\n }\n}\n","import {ErrorCode, FormatError} from 'intl-messageformat'\nimport {IntlFormatError} from '#packages/intl/error.js'\nimport {\n type Formatters,\n type IntlFormatters,\n type OnErrorFn,\n type Part,\n} from '#packages/intl/types.js'\nimport {filterProps} from '#packages/intl/utils.js'\n\nconst LIST_FORMAT_OPTIONS: Array<keyof Intl.ListFormatOptions> = [\n 'type',\n 'style',\n]\n\nconst now = Date.now()\n\nfunction generateToken(i: number): string {\n return `${now}_${i}_${now}`\n}\n\nexport function formatList(\n opts: {\n locale: string\n onError: OnErrorFn\n },\n getListFormat: Formatters['getListFormat'],\n values: Iterable<string>,\n options: Parameters<IntlFormatters['formatList']>[1]\n): string\nexport function formatList<T>(\n opts: {\n locale: string\n onError: OnErrorFn\n },\n getListFormat: Formatters['getListFormat'],\n values: Iterable<string | T>,\n options: Parameters<IntlFormatters['formatList']>[1] = {}\n): Array<T | string> | T | string {\n const results = formatListToParts(\n opts,\n getListFormat,\n values,\n options\n ).reduce((all: Array<string | T>, el) => {\n const val = el.value\n if (typeof val !== 'string') {\n all.push(val)\n } else if (typeof all[all.length - 1] === 'string') {\n all[all.length - 1] += val\n } else {\n all.push(val)\n }\n return all\n }, [])\n return results.length === 1 ? results[0] : results.length === 0 ? '' : results\n}\n\nexport function formatListToParts<T>(\n opts: {\n locale: string\n onError: OnErrorFn\n },\n getListFormat: Formatters['getListFormat'],\n values: Iterable<string | T>,\n options: Parameters<IntlFormatters['formatList']>[1]\n): Part[]\nexport function formatListToParts<T>(\n {\n locale,\n onError,\n }: {\n locale: string\n onError: OnErrorFn\n },\n getListFormat: Formatters['getListFormat'],\n values: Parameters<IntlFormatters['formatList']>[0],\n options: Parameters<IntlFormatters['formatList']>[1] = {}\n): Part<T>[] {\n const ListFormat: typeof Intl.ListFormat = Intl.ListFormat\n if (!ListFormat) {\n onError(\n new FormatError(\n `Intl.ListFormat is not available in this environment.\nTry polyfilling it using \"@formatjs/intl-listformat\"\n`,\n ErrorCode.MISSING_INTL_API\n )\n )\n }\n const filteredOptions = filterProps(\n options,\n LIST_FORMAT_OPTIONS\n ) as Intl.ListFormatOptions\n\n try {\n const richValues: Record<string, T> = {}\n const serializedValues = Array.from(values).map((v, i) => {\n if (typeof v === 'object' && v !== null) {\n const id = generateToken(i)\n richValues[id] = v as any\n return id\n }\n return String(v)\n })\n return getListFormat(locale, filteredOptions)\n .formatToParts(serializedValues)\n .map(\n part =>\n (part.type === 'literal'\n ? part\n : {...part, value: richValues[part.value] || part.value}) as Part<T>\n )\n } catch (e) {\n onError(new IntlFormatError('Error formatting list.', locale, e))\n }\n\n // @ts-ignore\n return values\n}\n","import {ErrorCode, FormatError} from 'intl-messageformat'\nimport {IntlFormatError} from '#packages/intl/error.js'\nimport {\n type Formatters,\n type IntlFormatters,\n type OnErrorFn,\n} from '#packages/intl/types.js'\nimport {filterProps} from '#packages/intl/utils.js'\n\nconst PLURAL_FORMAT_OPTIONS: Array<keyof Intl.PluralRulesOptions> = ['type']\n\nexport function formatPlural(\n {\n locale,\n onError,\n }: {\n locale: string\n onError: OnErrorFn\n },\n getPluralRules: Formatters['getPluralRules'],\n value: Parameters<IntlFormatters['formatPlural']>[0],\n options: Parameters<IntlFormatters['formatPlural']>[1] = {}\n): Intl.LDMLPluralRule {\n if (!Intl.PluralRules) {\n onError(\n new FormatError(\n `Intl.PluralRules is not available in this environment.\nTry polyfilling it using \"@formatjs/intl-pluralrules\"\n`,\n ErrorCode.MISSING_INTL_API\n )\n )\n }\n const filteredOptions = filterProps(\n options,\n PLURAL_FORMAT_OPTIONS\n ) as Intl.PluralRulesOptions\n\n try {\n return getPluralRules(locale, filteredOptions).select(\n value\n ) as Intl.LDMLPluralRule\n } catch (e) {\n onError(new IntlFormatError('Error formatting plural.', locale, e))\n }\n\n return 'other'\n}\n","import {\n type IntlFormatters,\n type Formatters,\n type CustomFormats,\n type OnErrorFn,\n} from '#packages/intl/types.js'\n\nimport {getNamedFormat, filterProps} from '#packages/intl/utils.js'\nimport {FormatError, ErrorCode} from 'intl-messageformat'\nimport {IntlFormatError} from '#packages/intl/error.js'\n\nconst RELATIVE_TIME_FORMAT_OPTIONS: Array<\n keyof Intl.RelativeTimeFormatOptions\n> = ['numeric', 'style']\n\nfunction getFormatter(\n {\n locale,\n formats,\n onError,\n }: {\n locale: string\n formats: CustomFormats\n onError: OnErrorFn\n },\n getRelativeTimeFormat: Formatters['getRelativeTimeFormat'],\n options: Parameters<IntlFormatters['formatRelativeTime']>[2] = {}\n): Intl.RelativeTimeFormat {\n const {format} = options\n\n const defaults =\n (!!format && getNamedFormat(formats, 'relative', format, onError)) || {}\n const filteredOptions = filterProps(\n options,\n RELATIVE_TIME_FORMAT_OPTIONS,\n defaults as Intl.RelativeTimeFormatOptions\n ) as Intl.RelativeTimeFormatOptions\n\n return getRelativeTimeFormat(locale, filteredOptions)\n}\n\nexport function formatRelativeTime(\n config: {\n locale: string\n formats: CustomFormats\n onError: OnErrorFn\n },\n getRelativeTimeFormat: Formatters['getRelativeTimeFormat'],\n value: Parameters<IntlFormatters['formatRelativeTime']>[0],\n unit?: Parameters<IntlFormatters['formatRelativeTime']>[1],\n options: Parameters<IntlFormatters['formatRelativeTime']>[2] = {}\n): string {\n if (!unit) {\n unit = 'second'\n }\n const RelativeTimeFormat = Intl.RelativeTimeFormat\n if (!RelativeTimeFormat) {\n config.onError(\n new FormatError(\n `Intl.RelativeTimeFormat is not available in this environment.\nTry polyfilling it using \"@formatjs/intl-relativetimeformat\"\n`,\n ErrorCode.MISSING_INTL_API\n )\n )\n }\n try {\n return getFormatter(config, getRelativeTimeFormat, options).format(\n value,\n unit\n )\n } catch (e) {\n config.onError(\n new IntlFormatError('Error formatting relative time.', config.locale, e)\n )\n }\n\n return String(value)\n}\n","import {type NumberFormatOptions} from '#packages/ecma402-abstract/types/number.js'\nimport {IntlFormatError} from '#packages/intl/error.js'\nimport {\n type CustomFormats,\n type Formatters,\n type IntlFormatters,\n type OnErrorFn,\n} from '#packages/intl/types.js'\nimport {filterProps, getNamedFormat} from '#packages/intl/utils.js'\n\nconst NUMBER_FORMAT_OPTIONS: Array<keyof NumberFormatOptions> = [\n 'style',\n 'currency',\n 'unit',\n 'unitDisplay',\n 'useGrouping',\n\n 'minimumIntegerDigits',\n 'minimumFractionDigits',\n 'maximumFractionDigits',\n 'minimumSignificantDigits',\n 'maximumSignificantDigits',\n\n // ES2020 NumberFormat\n 'compactDisplay',\n 'currencyDisplay',\n 'currencySign',\n 'notation',\n 'signDisplay',\n 'unit',\n 'unitDisplay',\n 'numberingSystem',\n\n // ES2023 NumberFormat\n 'trailingZeroDisplay',\n 'roundingPriority',\n 'roundingIncrement',\n 'roundingMode',\n]\n\nexport function getFormatter(\n {\n locale,\n formats,\n onError,\n }: {\n locale: string\n\n formats: CustomFormats\n onError: OnErrorFn\n },\n getNumberFormat: Formatters['getNumberFormat'],\n options: Parameters<IntlFormatters['formatNumber']>[1] = {}\n): Intl.NumberFormat {\n const {format} = options\n const defaults = ((format &&\n getNamedFormat(formats!, 'number', format, onError)) ||\n {}) as NumberFormatOptions\n const filteredOptions = filterProps(\n options,\n NUMBER_FORMAT_OPTIONS,\n defaults\n ) as NumberFormatOptions\n\n return getNumberFormat(locale, filteredOptions)\n}\n\nexport function formatNumber(\n config: {\n locale: string\n\n formats: CustomFormats\n onError: OnErrorFn\n },\n getNumberFormat: Formatters['getNumberFormat'],\n value: Parameters<IntlFormatters['formatNumber']>[0],\n options: Parameters<IntlFormatters['formatNumber']>[1] = {}\n): string {\n try {\n return getFormatter(config, getNumberFormat, options).format(value)\n } catch (e) {\n config.onError(\n new IntlFormatError('Error formatting number.', config.locale, e)\n )\n }\n\n return String(value)\n}\n\nexport function formatNumberToParts(\n config: {\n locale: string\n formats: CustomFormats\n onError: OnErrorFn\n },\n getNumberFormat: Formatters['getNumberFormat'],\n value: Parameters<IntlFormatters['formatNumber']>[0],\n options: Parameters<IntlFormatters['formatNumber']>[1] = {}\n): Intl.NumberFormatPart[] {\n try {\n return getFormatter(config, getNumberFormat, options).formatToParts(\n value as number\n )\n } catch (e) {\n config.onError(\n new IntlFormatError('Error formatting number.', config.locale, e)\n )\n }\n\n return []\n}\n","import {\n formatDate,\n formatDateTimeRange,\n formatDateToParts,\n formatTime,\n formatTimeToParts,\n} from '#packages/intl/dateTime.js'\nimport {formatDisplayName} from '#packages/intl/displayName.js'\nimport {formatDuration, formatDurationToParts} from '#packages/intl/duration.js'\nimport {InvalidConfigError, MissingDataError} from '#packages/intl/error.js'\nimport {formatList, formatListToParts} from '#packages/intl/list.js'\nimport {formatMessage} from '#packages/intl/message.js'\nimport {formatNumber, formatNumberToParts} from '#packages/intl/number.js'\nimport {formatPlural} from '#packages/intl/plural.js'\nimport {formatRelativeTime} from '#packages/intl/relativeTime.js'\nimport {\n type IntlCache,\n type IntlConfig,\n type IntlShape,\n type ResolvedIntlConfig,\n} from '#packages/intl/types.js'\nimport {createFormatters, DEFAULT_INTL_CONFIG} from '#packages/intl/utils.js'\nimport {type MessageFormatElement} from '@formatjs/icu-messageformat-parser'\n\nexport interface CreateIntlFn<\n T = string,\n C extends IntlConfig<T> = IntlConfig<T>,\n S extends IntlShape<T> = IntlShape<T>,\n> {\n (config: C, cache?: IntlCache): S\n}\n\nfunction messagesContainString(\n messages: Record<string, string> | Record<string, MessageFormatElement[]>\n): messages is Record<string, MessageFormatElement[]> {\n const firstMessage = messages ? messages[Object.keys(messages)[0]] : undefined\n\n return typeof firstMessage === 'string'\n}\n\nfunction verifyConfigMessages<T = string>(config: IntlConfig<T>) {\n if (\n config.onWarn &&\n config.defaultRichTextElements &&\n messagesContainString(config.messages || {})\n ) {\n config.onWarn(`[@formatjs/intl] \"defaultRichTextElements\" was specified but \"message\" was not pre-compiled. \nPlease consider using \"@formatjs/cli\" to pre-compile your messages for performance.\nFor more details see https://formatjs.github.io/docs/getting-started/message-distribution`)\n }\n}\n\n/**\n * Create intl object\n * @param config intl config\n * @param cache cache for formatter instances to prevent memory leak\n */\nexport function createIntl<T = string>(\n config: IntlConfig<T>,\n cache?: IntlCache\n): IntlShape<T> {\n const formatters = createFormatters(cache)\n const resolvedConfig: ResolvedIntlConfig<T> = {\n ...DEFAULT_INTL_CONFIG,\n ...config,\n }\n\n const {locale, defaultLocale, onError} = resolvedConfig\n if (!locale) {\n if (onError) {\n onError(\n new InvalidConfigError(\n `\"locale\" was not configured, using \"${defaultLocale}\" as fallback. See https://formatjs.github.io/docs/react-intl/api#intlshape for more details`\n )\n )\n }\n // Since there's no registered locale data for `locale`, this will\n // fallback to the `defaultLocale` to make sure things can render.\n // The `messages` are overridden to the `defaultProps` empty object\n // to maintain referential equality across re-renders. It's assumed\n // each <FormattedMessage> contains a `defaultMessage` prop.\n resolvedConfig.locale = resolvedConfig.defaultLocale || 'en'\n } else if (!Intl.NumberFormat.supportedLocalesOf(locale).length && onError) {\n onError(\n new MissingDataError(\n `Missing locale data for locale: \"${locale}\" in Intl.NumberFormat. Using default locale: \"${defaultLocale}\" as fallback. See https://formatjs.github.io/docs/react-intl#runtime-requirements for more details`\n )\n )\n } else if (\n !Intl.DateTimeFormat.supportedLocalesOf(locale).length &&\n onError\n ) {\n onError(\n new MissingDataError(\n `Missing locale data for locale: \"${locale}\" in Intl.DateTimeFormat. Using default locale: \"${defaultLocale}\" as fallback. See https://formatjs.github.io/docs/react-intl#runtime-requirements for more details`\n )\n )\n }\n\n verifyConfigMessages(resolvedConfig)\n return {\n ...resolvedConfig,\n formatters,\n formatNumber: formatNumber.bind(\n null,\n resolvedConfig,\n formatters.getNumberFormat\n ),\n formatNumberToParts: formatNumberToParts.bind(\n null,\n resolvedConfig,\n formatters.getNumberFormat\n ),\n formatDuration: formatDuration.bind(\n null,\n resolvedConfig,\n formatters.getDurationFormat\n ),\n formatDurationToParts: formatDurationToParts.bind(\n null,\n resolvedConfig,\n formatters.getDurationFormat\n ),\n formatRelativeTime: formatRelativeTime.bind(\n null,\n resolvedConfig,\n formatters.getRelativeTimeFormat\n ),\n formatDate: formatDate.bind(\n null,\n resolvedConfig,\n formatters.getDateTimeFormat\n ),\n formatDateToParts: formatDateToParts.bind(\n null,\n resolvedConfig,\n formatters.getDateTimeFormat\n ),\n formatTime: formatTime.bind(\n null,\n resolvedConfig,\n formatters.getDateTimeFormat\n ),\n formatDateTimeRange: formatDateTimeRange.bind(\n null,\n resolvedConfig,\n formatters.getDateTimeFormat\n ),\n formatTimeToParts: formatTimeToParts.bind(\n null,\n resolvedConfig,\n formatters.getDateTimeFormat\n ),\n formatPlural: formatPlural.bind(\n null,\n resolvedConfig,\n formatters.getPluralRules\n ),\n formatMessage: formatMessage.bind(null, resolvedConfig, formatters),\n $t: formatMessage.bind(null, resolvedConfig, formatters),\n formatList: formatList.bind(null, resolvedConfig, formatters.getListFormat),\n formatListToParts: formatListToParts.bind(\n null,\n resolvedConfig,\n formatters.getListFormat\n ),\n formatDisplayName: formatDisplayName.bind(\n null,\n resolvedConfig,\n formatters.getDisplayNames\n ),\n }\n}\n","import {type MessageDescriptor} from '#packages/intl/types.js'\nexport * from '#packages/intl/types.js'\n\nexport function defineMessages<\n K extends keyof any,\n T = MessageDescriptor,\n U extends Record<K, T> = Record<K, T>,\n>(msgs: U): U {\n return msgs\n}\n\nexport function defineMessage<T>(msg: T): T {\n return msg\n}\n\nexport {\n createIntlCache,\n filterProps,\n DEFAULT_INTL_CONFIG,\n createFormatters,\n getNamedFormat,\n} from '#packages/intl/utils.js'\nexport * from '#packages/intl/error.js'\nexport {formatMessage} from '#packages/intl/message.js'\nexport type {FormatMessageFn} from '#packages/intl/message.js'\nexport {\n formatDate,\n formatDateToParts,\n formatTime,\n formatTimeToParts,\n} from '#packages/intl/dateTime.js'\nexport {formatDuration, formatDurationToParts} from '#packages/intl/duration.js'\nexport {formatDisplayName} from '#packages/intl/displayName.js'\nexport {formatList} from '#packages/intl/list.js'\nexport {formatPlural} from '#packages/intl/plural.js'\nexport {formatRelativeTime} from '#packages/intl/relativeTime.js'\nexport {formatNumber, formatNumberToParts} from '#packages/intl/number.js'\nexport {createIntl} from '#packages/intl/create-intl.js'\nexport type {CreateIntlFn} from '#packages/intl/create-intl.js'\n"],"mappings":";;;;AAEA,IAAY,gBAAL,yBAAA,eAAA;CACL,cAAA,kBAAA;CACA,cAAA,2BAAA;CACA,cAAA,oBAAA;CACA,cAAA,kBAAA;CACA,cAAA,yBAAA;;AACF,EAAA,CAAA,CAAA;AAEA,IAAa,YAAb,MAAa,kBAEH,MAAM;CAGd,YAAY,MAAS,SAAiB,WAA6B;EACjE,MAAM,MAAM,YACR,qBAAqB,QACnB,YACA,IAAI,MAAM,OAAO,SAAS,CAAC,IAC7B,KAAA;EACJ,MACE,yBAAyB,KAAK,IAAI,QAAQ;EAC9C,MAAM,KAAK,IAAI,QAAQ,IAAI,IAAI,UAAU,IACvC;EACA,KAAK,OAAO;EAEZ,IAAI,OAAO,MAAM,sBAAsB,YAErC,MAAM,kBAAkB,MAAM,SAAS;CAE3C;AACF;AAEA,IAAa,4BAAb,cAA+C,UAA+C;CAC5F,YAAY,SAAiB,WAA6B;EACxD,MAAA,yBAA2C,SAAS,SAAS;CAC/D;AACF;AAEA,IAAa,qBAAb,cAAwC,UAAwC;CAC9E,YAAY,SAAiB,WAA6B;EACxD,MAAA,kBAAoC,SAAS,SAAS;CACxD;AACF;AAEA,IAAa,mBAAb,cAAsC,UAAsC;CAC1E,YAAY,SAAiB,WAA6B;EACxD,MAAA,gBAAkC,SAAS,SAAS;CACtD;AACF;AAEA,IAAa,kBAAb,cAAqC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