@angular/common 19.2.4 → 19.2.6

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.
@@ -0,0 +1,4569 @@
1
+ /**
2
+ * @license Angular v19.2.6
3
+ * (c) 2010-2025 Google LLC. https://angular.io/
4
+ * License: MIT
5
+ */
6
+
7
+ import * as i0 from '@angular/core';
8
+ import { Optional, Inject, Injectable, ɵgetLocalePluralCase as _getLocalePluralCase, ɵfindLocaleData as _findLocaleData, ɵLocaleDataIndex as _LocaleDataIndex, ɵgetLocaleCurrencyCode as _getLocaleCurrencyCode, LOCALE_ID, ɵstringify as _stringify, Input, Directive, createNgModule, NgModuleRef, ɵRuntimeError as _RuntimeError, Host, Attribute, RendererStyleFlags2, ɵisPromise as _isPromise, ɵisSubscribable as _isSubscribable, untracked, Pipe, InjectionToken, DEFAULT_CURRENCY_CODE, NgModule } from '@angular/core';
9
+ import { LocationStrategy, joinWithSlash, normalizeQueryParams, PlatformLocation, APP_BASE_HREF } from './location-DpBxd_aX.mjs';
10
+
11
+ /**
12
+ * @description
13
+ * A {@link LocationStrategy} used to configure the {@link Location} service to
14
+ * represent its state in the
15
+ * [hash fragment](https://en.wikipedia.org/wiki/Uniform_Resource_Locator#Syntax)
16
+ * of the browser's URL.
17
+ *
18
+ * For instance, if you call `location.go('/foo')`, the browser's URL will become
19
+ * `example.com#/foo`.
20
+ *
21
+ * @usageNotes
22
+ *
23
+ * ### Example
24
+ *
25
+ * {@example common/location/ts/hash_location_component.ts region='LocationComponent'}
26
+ *
27
+ * @publicApi
28
+ */
29
+ class HashLocationStrategy extends LocationStrategy {
30
+ _platformLocation;
31
+ _baseHref = '';
32
+ _removeListenerFns = [];
33
+ constructor(_platformLocation, _baseHref) {
34
+ super();
35
+ this._platformLocation = _platformLocation;
36
+ if (_baseHref != null) {
37
+ this._baseHref = _baseHref;
38
+ }
39
+ }
40
+ /** @nodoc */
41
+ ngOnDestroy() {
42
+ while (this._removeListenerFns.length) {
43
+ this._removeListenerFns.pop()();
44
+ }
45
+ }
46
+ onPopState(fn) {
47
+ this._removeListenerFns.push(this._platformLocation.onPopState(fn), this._platformLocation.onHashChange(fn));
48
+ }
49
+ getBaseHref() {
50
+ return this._baseHref;
51
+ }
52
+ path(includeHash = false) {
53
+ // the hash value is always prefixed with a `#`
54
+ // and if it is empty then it will stay empty
55
+ const path = this._platformLocation.hash ?? '#';
56
+ return path.length > 0 ? path.substring(1) : path;
57
+ }
58
+ prepareExternalUrl(internal) {
59
+ const url = joinWithSlash(this._baseHref, internal);
60
+ return url.length > 0 ? '#' + url : url;
61
+ }
62
+ pushState(state, title, path, queryParams) {
63
+ const url = this.prepareExternalUrl(path + normalizeQueryParams(queryParams)) ||
64
+ this._platformLocation.pathname;
65
+ this._platformLocation.pushState(state, title, url);
66
+ }
67
+ replaceState(state, title, path, queryParams) {
68
+ const url = this.prepareExternalUrl(path + normalizeQueryParams(queryParams)) ||
69
+ this._platformLocation.pathname;
70
+ this._platformLocation.replaceState(state, title, url);
71
+ }
72
+ forward() {
73
+ this._platformLocation.forward();
74
+ }
75
+ back() {
76
+ this._platformLocation.back();
77
+ }
78
+ getState() {
79
+ return this._platformLocation.getState();
80
+ }
81
+ historyGo(relativePosition = 0) {
82
+ this._platformLocation.historyGo?.(relativePosition);
83
+ }
84
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: HashLocationStrategy, deps: [{ token: PlatformLocation }, { token: APP_BASE_HREF, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
85
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: HashLocationStrategy });
86
+ }
87
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: HashLocationStrategy, decorators: [{
88
+ type: Injectable
89
+ }], ctorParameters: () => [{ type: PlatformLocation }, { type: undefined, decorators: [{
90
+ type: Optional
91
+ }, {
92
+ type: Inject,
93
+ args: [APP_BASE_HREF]
94
+ }] }] });
95
+
96
+ /** @internal */
97
+ const CURRENCIES_EN = { "ADP": [undefined, undefined, 0], "AFN": [undefined, "؋", 0], "ALL": [undefined, undefined, 0], "AMD": [undefined, "֏", 2], "AOA": [undefined, "Kz"], "ARS": [undefined, "$"], "AUD": ["A$", "$"], "AZN": [undefined, "₼"], "BAM": [undefined, "KM"], "BBD": [undefined, "$"], "BDT": [undefined, "৳"], "BHD": [undefined, undefined, 3], "BIF": [undefined, undefined, 0], "BMD": [undefined, "$"], "BND": [undefined, "$"], "BOB": [undefined, "Bs"], "BRL": ["R$"], "BSD": [undefined, "$"], "BWP": [undefined, "P"], "BYN": [undefined, undefined, 2], "BYR": [undefined, undefined, 0], "BZD": [undefined, "$"], "CAD": ["CA$", "$", 2], "CHF": [undefined, undefined, 2], "CLF": [undefined, undefined, 4], "CLP": [undefined, "$", 0], "CNY": ["CN¥", "¥"], "COP": [undefined, "$", 2], "CRC": [undefined, "₡", 2], "CUC": [undefined, "$"], "CUP": [undefined, "$"], "CZK": [undefined, "Kč", 2], "DJF": [undefined, undefined, 0], "DKK": [undefined, "kr", 2], "DOP": [undefined, "$"], "EGP": [undefined, "E£"], "ESP": [undefined, "₧", 0], "EUR": ["€"], "FJD": [undefined, "$"], "FKP": [undefined, "£"], "GBP": ["£"], "GEL": [undefined, "₾"], "GHS": [undefined, "GH₵"], "GIP": [undefined, "£"], "GNF": [undefined, "FG", 0], "GTQ": [undefined, "Q"], "GYD": [undefined, "$", 2], "HKD": ["HK$", "$"], "HNL": [undefined, "L"], "HRK": [undefined, "kn"], "HUF": [undefined, "Ft", 2], "IDR": [undefined, "Rp", 2], "ILS": ["₪"], "INR": ["₹"], "IQD": [undefined, undefined, 0], "IRR": [undefined, undefined, 0], "ISK": [undefined, "kr", 0], "ITL": [undefined, undefined, 0], "JMD": [undefined, "$"], "JOD": [undefined, undefined, 3], "JPY": ["¥", undefined, 0], "KHR": [undefined, "៛"], "KMF": [undefined, "CF", 0], "KPW": [undefined, "₩", 0], "KRW": ["₩", undefined, 0], "KWD": [undefined, undefined, 3], "KYD": [undefined, "$"], "KZT": [undefined, "₸"], "LAK": [undefined, "₭", 0], "LBP": [undefined, "L£", 0], "LKR": [undefined, "Rs"], "LRD": [undefined, "$"], "LTL": [undefined, "Lt"], "LUF": [undefined, undefined, 0], "LVL": [undefined, "Ls"], "LYD": [undefined, undefined, 3], "MGA": [undefined, "Ar", 0], "MGF": [undefined, undefined, 0], "MMK": [undefined, "K", 0], "MNT": [undefined, "₮", 2], "MRO": [undefined, undefined, 0], "MUR": [undefined, "Rs", 2], "MXN": ["MX$", "$"], "MYR": [undefined, "RM"], "NAD": [undefined, "$"], "NGN": [undefined, "₦"], "NIO": [undefined, "C$"], "NOK": [undefined, "kr", 2], "NPR": [undefined, "Rs"], "NZD": ["NZ$", "$"], "OMR": [undefined, undefined, 3], "PHP": ["₱"], "PKR": [undefined, "Rs", 2], "PLN": [undefined, "zł"], "PYG": [undefined, "₲", 0], "RON": [undefined, "lei"], "RSD": [undefined, undefined, 0], "RUB": [undefined, "₽"], "RWF": [undefined, "RF", 0], "SBD": [undefined, "$"], "SEK": [undefined, "kr", 2], "SGD": [undefined, "$"], "SHP": [undefined, "£"], "SLE": [undefined, undefined, 2], "SLL": [undefined, undefined, 0], "SOS": [undefined, undefined, 0], "SRD": [undefined, "$"], "SSP": [undefined, "£"], "STD": [undefined, undefined, 0], "STN": [undefined, "Db"], "SYP": [undefined, "£", 0], "THB": [undefined, "฿"], "TMM": [undefined, undefined, 0], "TND": [undefined, undefined, 3], "TOP": [undefined, "T$"], "TRL": [undefined, undefined, 0], "TRY": [undefined, "₺"], "TTD": [undefined, "$"], "TWD": ["NT$", "$", 2], "TZS": [undefined, undefined, 2], "UAH": [undefined, "₴"], "UGX": [undefined, undefined, 0], "USD": ["$"], "UYI": [undefined, undefined, 0], "UYU": [undefined, "$"], "UYW": [undefined, undefined, 4], "UZS": [undefined, undefined, 2], "VEF": [undefined, "Bs", 2], "VND": ["₫", undefined, 0], "VUV": [undefined, undefined, 0], "XAF": ["FCFA", undefined, 0], "XCD": ["EC$", "$"], "XOF": ["F CFA", undefined, 0], "XPF": ["CFPF", undefined, 0], "XXX": ["¤"], "YER": [undefined, undefined, 0], "ZAR": [undefined, "R"], "ZMK": [undefined, undefined, 0], "ZMW": [undefined, "ZK"], "ZWD": [undefined, undefined, 0] };
98
+
99
+ /**
100
+ * Format styles that can be used to represent numbers.
101
+ * @see {@link getLocaleNumberFormat}
102
+ * @see [Internationalization (i18n) Guide](guide/i18n)
103
+ *
104
+ * @publicApi
105
+ *
106
+ * @deprecated `getLocaleNumberFormat` is deprecated
107
+ */
108
+ var NumberFormatStyle;
109
+ (function (NumberFormatStyle) {
110
+ NumberFormatStyle[NumberFormatStyle["Decimal"] = 0] = "Decimal";
111
+ NumberFormatStyle[NumberFormatStyle["Percent"] = 1] = "Percent";
112
+ NumberFormatStyle[NumberFormatStyle["Currency"] = 2] = "Currency";
113
+ NumberFormatStyle[NumberFormatStyle["Scientific"] = 3] = "Scientific";
114
+ })(NumberFormatStyle || (NumberFormatStyle = {}));
115
+ /**
116
+ * Plurality cases used for translating plurals to different languages.
117
+ *
118
+ * @see {@link NgPlural}
119
+ * @see {@link NgPluralCase}
120
+ * @see [Internationalization (i18n) Guide](guide/i18n)
121
+ *
122
+ * @publicApi
123
+ *
124
+ * @deprecated `getLocalePluralCase` is deprecated
125
+ */
126
+ var Plural;
127
+ (function (Plural) {
128
+ Plural[Plural["Zero"] = 0] = "Zero";
129
+ Plural[Plural["One"] = 1] = "One";
130
+ Plural[Plural["Two"] = 2] = "Two";
131
+ Plural[Plural["Few"] = 3] = "Few";
132
+ Plural[Plural["Many"] = 4] = "Many";
133
+ Plural[Plural["Other"] = 5] = "Other";
134
+ })(Plural || (Plural = {}));
135
+ /**
136
+ * Context-dependant translation forms for strings.
137
+ * Typically the standalone version is for the nominative form of the word,
138
+ * and the format version is used for the genitive case.
139
+ * @see [CLDR website](http://cldr.unicode.org/translation/date-time-1/date-time#TOC-Standalone-vs.-Format-Styles)
140
+ * @see [Internationalization (i18n) Guide](guide/i18n)
141
+ *
142
+ * @publicApi
143
+ *
144
+ * @deprecated locale data getters are deprecated
145
+ */
146
+ var FormStyle;
147
+ (function (FormStyle) {
148
+ FormStyle[FormStyle["Format"] = 0] = "Format";
149
+ FormStyle[FormStyle["Standalone"] = 1] = "Standalone";
150
+ })(FormStyle || (FormStyle = {}));
151
+ /**
152
+ * String widths available for translations.
153
+ * The specific character widths are locale-specific.
154
+ * Examples are given for the word "Sunday" in English.
155
+ *
156
+ * @publicApi
157
+ *
158
+ * @deprecated locale data getters are deprecated
159
+ */
160
+ var TranslationWidth;
161
+ (function (TranslationWidth) {
162
+ /** 1 character for `en-US`. For example: 'S' */
163
+ TranslationWidth[TranslationWidth["Narrow"] = 0] = "Narrow";
164
+ /** 3 characters for `en-US`. For example: 'Sun' */
165
+ TranslationWidth[TranslationWidth["Abbreviated"] = 1] = "Abbreviated";
166
+ /** Full length for `en-US`. For example: "Sunday" */
167
+ TranslationWidth[TranslationWidth["Wide"] = 2] = "Wide";
168
+ /** 2 characters for `en-US`, For example: "Su" */
169
+ TranslationWidth[TranslationWidth["Short"] = 3] = "Short";
170
+ })(TranslationWidth || (TranslationWidth = {}));
171
+ /**
172
+ * String widths available for date-time formats.
173
+ * The specific character widths are locale-specific.
174
+ * Examples are given for `en-US`.
175
+ *
176
+ * @see {@link getLocaleDateFormat}
177
+ * @see {@link getLocaleTimeFormat}
178
+ * @see {@link getLocaleDateTimeFormat}
179
+ * @see [Internationalization (i18n) Guide](guide/i18n)
180
+ * @publicApi
181
+ *
182
+ * @deprecated Date locale data getters are deprecated
183
+ */
184
+ var FormatWidth;
185
+ (function (FormatWidth) {
186
+ /**
187
+ * For `en-US`, `'M/d/yy, h:mm a'`
188
+ * (Example: `6/15/15, 9:03 AM`)
189
+ */
190
+ FormatWidth[FormatWidth["Short"] = 0] = "Short";
191
+ /**
192
+ * For `en-US`, `'MMM d, y, h:mm:ss a'`
193
+ * (Example: `Jun 15, 2015, 9:03:01 AM`)
194
+ */
195
+ FormatWidth[FormatWidth["Medium"] = 1] = "Medium";
196
+ /**
197
+ * For `en-US`, `'MMMM d, y, h:mm:ss a z'`
198
+ * (Example: `June 15, 2015 at 9:03:01 AM GMT+1`)
199
+ */
200
+ FormatWidth[FormatWidth["Long"] = 2] = "Long";
201
+ /**
202
+ * For `en-US`, `'EEEE, MMMM d, y, h:mm:ss a zzzz'`
203
+ * (Example: `Monday, June 15, 2015 at 9:03:01 AM GMT+01:00`)
204
+ */
205
+ FormatWidth[FormatWidth["Full"] = 3] = "Full";
206
+ })(FormatWidth || (FormatWidth = {}));
207
+ // This needs to be an object literal, rather than an enum, because TypeScript 5.4+
208
+ // doesn't allow numeric keys and we have `Infinity` and `NaN`.
209
+ /**
210
+ * Symbols that can be used to replace placeholders in number patterns.
211
+ * Examples are based on `en-US` values.
212
+ *
213
+ * @see {@link getLocaleNumberSymbol}
214
+ * @see [Internationalization (i18n) Guide](guide/i18n)
215
+ *
216
+ * @publicApi
217
+ *
218
+ * @deprecated `getLocaleNumberSymbol` is deprecated
219
+ *
220
+ * @object-literal-as-enum
221
+ */
222
+ const NumberSymbol = {
223
+ /**
224
+ * Decimal separator.
225
+ * For `en-US`, the dot character.
226
+ * Example: 2,345`.`67
227
+ */
228
+ Decimal: 0,
229
+ /**
230
+ * Grouping separator, typically for thousands.
231
+ * For `en-US`, the comma character.
232
+ * Example: 2`,`345.67
233
+ */
234
+ Group: 1,
235
+ /**
236
+ * List-item separator.
237
+ * Example: "one, two, and three"
238
+ */
239
+ List: 2,
240
+ /**
241
+ * Sign for percentage (out of 100).
242
+ * Example: 23.4%
243
+ */
244
+ PercentSign: 3,
245
+ /**
246
+ * Sign for positive numbers.
247
+ * Example: +23
248
+ */
249
+ PlusSign: 4,
250
+ /**
251
+ * Sign for negative numbers.
252
+ * Example: -23
253
+ */
254
+ MinusSign: 5,
255
+ /**
256
+ * Computer notation for exponential value (n times a power of 10).
257
+ * Example: 1.2E3
258
+ */
259
+ Exponential: 6,
260
+ /**
261
+ * Human-readable format of exponential.
262
+ * Example: 1.2x103
263
+ */
264
+ SuperscriptingExponent: 7,
265
+ /**
266
+ * Sign for permille (out of 1000).
267
+ * Example: 23.4‰
268
+ */
269
+ PerMille: 8,
270
+ /**
271
+ * Infinity, can be used with plus and minus.
272
+ * Example: ∞, +∞, -∞
273
+ */
274
+ Infinity: 9,
275
+ /**
276
+ * Not a number.
277
+ * Example: NaN
278
+ */
279
+ NaN: 10,
280
+ /**
281
+ * Symbol used between time units.
282
+ * Example: 10:52
283
+ */
284
+ TimeSeparator: 11,
285
+ /**
286
+ * Decimal separator for currency values (fallback to `Decimal`).
287
+ * Example: $2,345.67
288
+ */
289
+ CurrencyDecimal: 12,
290
+ /**
291
+ * Group separator for currency values (fallback to `Group`).
292
+ * Example: $2,345.67
293
+ */
294
+ CurrencyGroup: 13,
295
+ };
296
+ /**
297
+ * The value for each day of the week, based on the `en-US` locale
298
+ *
299
+ * @publicApi
300
+ *
301
+ * @deprecated Week locale getters are deprecated
302
+ */
303
+ var WeekDay;
304
+ (function (WeekDay) {
305
+ WeekDay[WeekDay["Sunday"] = 0] = "Sunday";
306
+ WeekDay[WeekDay["Monday"] = 1] = "Monday";
307
+ WeekDay[WeekDay["Tuesday"] = 2] = "Tuesday";
308
+ WeekDay[WeekDay["Wednesday"] = 3] = "Wednesday";
309
+ WeekDay[WeekDay["Thursday"] = 4] = "Thursday";
310
+ WeekDay[WeekDay["Friday"] = 5] = "Friday";
311
+ WeekDay[WeekDay["Saturday"] = 6] = "Saturday";
312
+ })(WeekDay || (WeekDay = {}));
313
+ /**
314
+ * Retrieves the locale ID from the currently loaded locale.
315
+ * The loaded locale could be, for example, a global one rather than a regional one.
316
+ * @param locale A locale code, such as `fr-FR`.
317
+ * @returns The locale code. For example, `fr`.
318
+ * @see [Internationalization (i18n) Guide](guide/i18n)
319
+ *
320
+ * @publicApi
321
+ *
322
+ * @deprecated Angular recommends relying on the `Intl` API for i18n.
323
+ * This function serves no purpose when relying on the `Intl` API.
324
+ */
325
+ function getLocaleId(locale) {
326
+ return _findLocaleData(locale)[_LocaleDataIndex.LocaleId];
327
+ }
328
+ /**
329
+ * Retrieves day period strings for the given locale.
330
+ *
331
+ * @param locale A locale code for the locale format rules to use.
332
+ * @param formStyle The required grammatical form.
333
+ * @param width The required character width.
334
+ * @returns An array of localized period strings. For example, `[AM, PM]` for `en-US`.
335
+ * @see [Internationalization (i18n) Guide](guide/i18n)
336
+ *
337
+ * @publicApi
338
+ *
339
+ * @deprecated Angular recommends relying on the `Intl` API for i18n.
340
+ * Use `Intl.DateTimeFormat` for date formating instead.
341
+ */
342
+ function getLocaleDayPeriods(locale, formStyle, width) {
343
+ const data = _findLocaleData(locale);
344
+ const amPmData = [
345
+ data[_LocaleDataIndex.DayPeriodsFormat],
346
+ data[_LocaleDataIndex.DayPeriodsStandalone],
347
+ ];
348
+ const amPm = getLastDefinedValue(amPmData, formStyle);
349
+ return getLastDefinedValue(amPm, width);
350
+ }
351
+ /**
352
+ * Retrieves days of the week for the given locale, using the Gregorian calendar.
353
+ *
354
+ * @param locale A locale code for the locale format rules to use.
355
+ * @param formStyle The required grammatical form.
356
+ * @param width The required character width.
357
+ * @returns An array of localized name strings.
358
+ * For example,`[Sunday, Monday, ... Saturday]` for `en-US`.
359
+ * @see [Internationalization (i18n) Guide](guide/i18n)
360
+ *
361
+ * @publicApi
362
+ *
363
+ * @deprecated Angular recommends relying on the `Intl` API for i18n.
364
+ * Use `Intl.DateTimeFormat` for date formating instead.
365
+ */
366
+ function getLocaleDayNames(locale, formStyle, width) {
367
+ const data = _findLocaleData(locale);
368
+ const daysData = [
369
+ data[_LocaleDataIndex.DaysFormat],
370
+ data[_LocaleDataIndex.DaysStandalone],
371
+ ];
372
+ const days = getLastDefinedValue(daysData, formStyle);
373
+ return getLastDefinedValue(days, width);
374
+ }
375
+ /**
376
+ * Retrieves months of the year for the given locale, using the Gregorian calendar.
377
+ *
378
+ * @param locale A locale code for the locale format rules to use.
379
+ * @param formStyle The required grammatical form.
380
+ * @param width The required character width.
381
+ * @returns An array of localized name strings.
382
+ * For example, `[January, February, ...]` for `en-US`.
383
+ * @see [Internationalization (i18n) Guide](guide/i18n)
384
+ *
385
+ * @publicApi
386
+ *
387
+ * @deprecated Angular recommends relying on the `Intl` API for i18n.
388
+ * Use `Intl.DateTimeFormat` for date formating instead.
389
+ */
390
+ function getLocaleMonthNames(locale, formStyle, width) {
391
+ const data = _findLocaleData(locale);
392
+ const monthsData = [
393
+ data[_LocaleDataIndex.MonthsFormat],
394
+ data[_LocaleDataIndex.MonthsStandalone],
395
+ ];
396
+ const months = getLastDefinedValue(monthsData, formStyle);
397
+ return getLastDefinedValue(months, width);
398
+ }
399
+ /**
400
+ * Retrieves Gregorian-calendar eras for the given locale.
401
+ * @param locale A locale code for the locale format rules to use.
402
+ * @param width The required character width.
403
+
404
+ * @returns An array of localized era strings.
405
+ * For example, `[AD, BC]` for `en-US`.
406
+ * @see [Internationalization (i18n) Guide](guide/i18n)
407
+ *
408
+ * @publicApi
409
+ *
410
+ * @deprecated Angular recommends relying on the `Intl` API for i18n.
411
+ * Use `Intl.DateTimeFormat` for date formating instead.
412
+ */
413
+ function getLocaleEraNames(locale, width) {
414
+ const data = _findLocaleData(locale);
415
+ const erasData = data[_LocaleDataIndex.Eras];
416
+ return getLastDefinedValue(erasData, width);
417
+ }
418
+ /**
419
+ * Retrieves the first day of the week for the given locale.
420
+ *
421
+ * @param locale A locale code for the locale format rules to use.
422
+ * @returns A day index number, using the 0-based week-day index for `en-US`
423
+ * (Sunday = 0, Monday = 1, ...).
424
+ * For example, for `fr-FR`, returns 1 to indicate that the first day is Monday.
425
+ * @see [Internationalization (i18n) Guide](guide/i18n)
426
+ *
427
+ * @publicApi
428
+ *
429
+ * @deprecated Angular recommends relying on the `Intl` API for i18n.
430
+ * Intl's [`getWeekInfo`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/getWeekInfo) has partial support (Chromium M99 & Safari 17).
431
+ * You may want to rely on the following alternatives:
432
+ * - Libraries like [`Luxon`](https://moment.github.io/luxon/#/) rely on `Intl` but fallback on the ISO 8601 definition (monday) if `getWeekInfo` is not supported.
433
+ * - Other librairies like [`date-fns`](https://date-fns.org/), [`day.js`](https://day.js.org/en/) or [`weekstart`](https://www.npmjs.com/package/weekstart) library provide their own locale based data for the first day of the week.
434
+ */
435
+ function getLocaleFirstDayOfWeek(locale) {
436
+ const data = _findLocaleData(locale);
437
+ return data[_LocaleDataIndex.FirstDayOfWeek];
438
+ }
439
+ /**
440
+ * Range of week days that are considered the week-end for the given locale.
441
+ *
442
+ * @param locale A locale code for the locale format rules to use.
443
+ * @returns The range of day values, `[startDay, endDay]`.
444
+ * @see [Internationalization (i18n) Guide](guide/i18n)
445
+ *
446
+ * @publicApi
447
+ *
448
+ * @deprecated Angular recommends relying on the `Intl` API for i18n.
449
+ * Intl's [`getWeekInfo`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/getWeekInfo) has partial support (Chromium M99 & Safari 17).
450
+ * Libraries like [`Luxon`](https://moment.github.io/luxon/#/) rely on `Intl` but fallback on the ISO 8601 definition (Saturday+Sunday) if `getWeekInfo` is not supported .
451
+ */
452
+ function getLocaleWeekEndRange(locale) {
453
+ const data = _findLocaleData(locale);
454
+ return data[_LocaleDataIndex.WeekendRange];
455
+ }
456
+ /**
457
+ * Retrieves a localized date-value formatting string.
458
+ *
459
+ * @param locale A locale code for the locale format rules to use.
460
+ * @param width The format type.
461
+ * @returns The localized formatting string.
462
+ * @see {@link FormatWidth}
463
+ * @see [Internationalization (i18n) Guide](guide/i18n)
464
+ *
465
+ * @publicApi
466
+ *
467
+ * @deprecated Angular recommends relying on the `Intl` API for i18n.
468
+ * Use `Intl.DateTimeFormat` for date formating instead.
469
+ */
470
+ function getLocaleDateFormat(locale, width) {
471
+ const data = _findLocaleData(locale);
472
+ return getLastDefinedValue(data[_LocaleDataIndex.DateFormat], width);
473
+ }
474
+ /**
475
+ * Retrieves a localized time-value formatting string.
476
+ *
477
+ * @param locale A locale code for the locale format rules to use.
478
+ * @param width The format type.
479
+ * @returns The localized formatting string.
480
+ * @see {@link FormatWidth}
481
+ * @see [Internationalization (i18n) Guide](guide/i18n)
482
+
483
+ * @publicApi
484
+ * @deprecated Angular recommends relying on the `Intl` API for i18n.
485
+ * Use `Intl.DateTimeFormat` for date formating instead.
486
+ */
487
+ function getLocaleTimeFormat(locale, width) {
488
+ const data = _findLocaleData(locale);
489
+ return getLastDefinedValue(data[_LocaleDataIndex.TimeFormat], width);
490
+ }
491
+ /**
492
+ * Retrieves a localized date-time formatting string.
493
+ *
494
+ * @param locale A locale code for the locale format rules to use.
495
+ * @param width The format type.
496
+ * @returns The localized formatting string.
497
+ * @see {@link FormatWidth}
498
+ * @see [Internationalization (i18n) Guide](guide/i18n)
499
+ *
500
+ * @publicApi
501
+ *
502
+ * @deprecated Angular recommends relying on the `Intl` API for i18n.
503
+ * Use `Intl.DateTimeFormat` for date formating instead.
504
+ */
505
+ function getLocaleDateTimeFormat(locale, width) {
506
+ const data = _findLocaleData(locale);
507
+ const dateTimeFormatData = data[_LocaleDataIndex.DateTimeFormat];
508
+ return getLastDefinedValue(dateTimeFormatData, width);
509
+ }
510
+ /**
511
+ * Retrieves a localized number symbol that can be used to replace placeholders in number formats.
512
+ * @param locale The locale code.
513
+ * @param symbol The symbol to localize. Must be one of `NumberSymbol`.
514
+ * @returns The character for the localized symbol.
515
+ * @see {@link NumberSymbol}
516
+ * @see [Internationalization (i18n) Guide](guide/i18n)
517
+ *
518
+ * @publicApi
519
+ *
520
+ * @deprecated Angular recommends relying on the `Intl` API for i18n.
521
+ * Use `Intl.NumberFormat` to format numbers instead.
522
+ */
523
+ function getLocaleNumberSymbol(locale, symbol) {
524
+ const data = _findLocaleData(locale);
525
+ const res = data[_LocaleDataIndex.NumberSymbols][symbol];
526
+ if (typeof res === 'undefined') {
527
+ if (symbol === NumberSymbol.CurrencyDecimal) {
528
+ return data[_LocaleDataIndex.NumberSymbols][NumberSymbol.Decimal];
529
+ }
530
+ else if (symbol === NumberSymbol.CurrencyGroup) {
531
+ return data[_LocaleDataIndex.NumberSymbols][NumberSymbol.Group];
532
+ }
533
+ }
534
+ return res;
535
+ }
536
+ /**
537
+ * Retrieves a number format for a given locale.
538
+ *
539
+ * Numbers are formatted using patterns, like `#,###.00`. For example, the pattern `#,###.00`
540
+ * when used to format the number 12345.678 could result in "12'345,678". That would happen if the
541
+ * grouping separator for your language is an apostrophe, and the decimal separator is a comma.
542
+ *
543
+ * <b>Important:</b> The characters `.` `,` `0` `#` (and others below) are special placeholders
544
+ * that stand for the decimal separator, and so on, and are NOT real characters.
545
+ * You must NOT "translate" the placeholders. For example, don't change `.` to `,` even though in
546
+ * your language the decimal point is written with a comma. The symbols should be replaced by the
547
+ * local equivalents, using the appropriate `NumberSymbol` for your language.
548
+ *
549
+ * Here are the special characters used in number patterns:
550
+ *
551
+ * | Symbol | Meaning |
552
+ * |--------|---------|
553
+ * | . | Replaced automatically by the character used for the decimal point. |
554
+ * | , | Replaced by the "grouping" (thousands) separator. |
555
+ * | 0 | Replaced by a digit (or zero if there aren't enough digits). |
556
+ * | # | Replaced by a digit (or nothing if there aren't enough). |
557
+ * | ¤ | Replaced by a currency symbol, such as $ or USD. |
558
+ * | % | Marks a percent format. The % symbol may change position, but must be retained. |
559
+ * | E | Marks a scientific format. The E symbol may change position, but must be retained. |
560
+ * | ' | Special characters used as literal characters are quoted with ASCII single quotes. |
561
+ *
562
+ * @param locale A locale code for the locale format rules to use.
563
+ * @param type The type of numeric value to be formatted (such as `Decimal` or `Currency`.)
564
+ * @returns The localized format string.
565
+ * @see {@link NumberFormatStyle}
566
+ * @see [CLDR website](http://cldr.unicode.org/translation/number-patterns)
567
+ * @see [Internationalization (i18n) Guide](guide/i18n)
568
+ *
569
+ * @publicApi
570
+ *
571
+ * @deprecated Angular recommends relying on the `Intl` API for i18n.
572
+ * Let `Intl.NumberFormat` determine the number format instead
573
+ */
574
+ function getLocaleNumberFormat(locale, type) {
575
+ const data = _findLocaleData(locale);
576
+ return data[_LocaleDataIndex.NumberFormats][type];
577
+ }
578
+ /**
579
+ * Retrieves the symbol used to represent the currency for the main country
580
+ * corresponding to a given locale. For example, '$' for `en-US`.
581
+ *
582
+ * @param locale A locale code for the locale format rules to use.
583
+ * @returns The localized symbol character,
584
+ * or `null` if the main country cannot be determined.
585
+ * @see [Internationalization (i18n) Guide](guide/i18n)
586
+ *
587
+ * @publicApi
588
+ *
589
+ * @deprecated Use the `Intl` API to format a currency with from currency code
590
+ */
591
+ function getLocaleCurrencySymbol(locale) {
592
+ const data = _findLocaleData(locale);
593
+ return data[_LocaleDataIndex.CurrencySymbol] || null;
594
+ }
595
+ /**
596
+ * Retrieves the name of the currency for the main country corresponding
597
+ * to a given locale. For example, 'US Dollar' for `en-US`.
598
+ * @param locale A locale code for the locale format rules to use.
599
+ * @returns The currency name,
600
+ * or `null` if the main country cannot be determined.
601
+ * @see [Internationalization (i18n) Guide](guide/i18n)
602
+ *
603
+ * @publicApi
604
+ *
605
+ * @deprecated Use the `Intl` API to format a currency with from currency code
606
+ */
607
+ function getLocaleCurrencyName(locale) {
608
+ const data = _findLocaleData(locale);
609
+ return data[_LocaleDataIndex.CurrencyName] || null;
610
+ }
611
+ /**
612
+ * Retrieves the default currency code for the given locale.
613
+ *
614
+ * The default is defined as the first currency which is still in use.
615
+ *
616
+ * @param locale The code of the locale whose currency code we want.
617
+ * @returns The code of the default currency for the given locale.
618
+ *
619
+ * @publicApi
620
+ *
621
+ * @deprecated We recommend you create a map of locale to ISO 4217 currency codes.
622
+ * Time relative currency data is provided by the CLDR project. See https://www.unicode.org/cldr/charts/44/supplemental/detailed_territory_currency_information.html
623
+ */
624
+ function getLocaleCurrencyCode(locale) {
625
+ return _getLocaleCurrencyCode(locale);
626
+ }
627
+ /**
628
+ * Retrieves the currency values for a given locale.
629
+ * @param locale A locale code for the locale format rules to use.
630
+ * @returns The currency values.
631
+ * @see [Internationalization (i18n) Guide](guide/i18n)
632
+ */
633
+ function getLocaleCurrencies(locale) {
634
+ const data = _findLocaleData(locale);
635
+ return data[_LocaleDataIndex.Currencies];
636
+ }
637
+ /**
638
+ * @publicApi
639
+ *
640
+ * @deprecated Angular recommends relying on the `Intl` API for i18n.
641
+ * Use `Intl.PluralRules` instead
642
+ */
643
+ const getLocalePluralCase = _getLocalePluralCase;
644
+ function checkFullData(data) {
645
+ if (!data[_LocaleDataIndex.ExtraData]) {
646
+ throw new Error(`Missing extra locale data for the locale "${data[_LocaleDataIndex.LocaleId]}". Use "registerLocaleData" to load new data. See the "I18n guide" on angular.io to know more.`);
647
+ }
648
+ }
649
+ /**
650
+ * Retrieves locale-specific rules used to determine which day period to use
651
+ * when more than one period is defined for a locale.
652
+ *
653
+ * There is a rule for each defined day period. The
654
+ * first rule is applied to the first day period and so on.
655
+ * Fall back to AM/PM when no rules are available.
656
+ *
657
+ * A rule can specify a period as time range, or as a single time value.
658
+ *
659
+ * This functionality is only available when you have loaded the full locale data.
660
+ * See the ["I18n guide"](guide/i18n/format-data-locale).
661
+ *
662
+ * @param locale A locale code for the locale format rules to use.
663
+ * @returns The rules for the locale, a single time value or array of *from-time, to-time*,
664
+ * or null if no periods are available.
665
+ *
666
+ * @see {@link getLocaleExtraDayPeriods}
667
+ * @see [Internationalization (i18n) Guide](guide/i18n)
668
+ *
669
+ * @publicApi
670
+ *
671
+ * @deprecated Angular recommends relying on the `Intl` API for i18n.
672
+ * Let `Intl.DateTimeFormat` determine the day period instead.
673
+ */
674
+ function getLocaleExtraDayPeriodRules(locale) {
675
+ const data = _findLocaleData(locale);
676
+ checkFullData(data);
677
+ const rules = data[_LocaleDataIndex.ExtraData][2 /* ɵExtraLocaleDataIndex.ExtraDayPeriodsRules */] || [];
678
+ return rules.map((rule) => {
679
+ if (typeof rule === 'string') {
680
+ return extractTime(rule);
681
+ }
682
+ return [extractTime(rule[0]), extractTime(rule[1])];
683
+ });
684
+ }
685
+ /**
686
+ * Retrieves locale-specific day periods, which indicate roughly how a day is broken up
687
+ * in different languages.
688
+ * For example, for `en-US`, periods are morning, noon, afternoon, evening, and midnight.
689
+ *
690
+ * This functionality is only available when you have loaded the full locale data.
691
+ * See the ["I18n guide"](guide/i18n/format-data-locale).
692
+ *
693
+ * @param locale A locale code for the locale format rules to use.
694
+ * @param formStyle The required grammatical form.
695
+ * @param width The required character width.
696
+ * @returns The translated day-period strings.
697
+ * @see {@link getLocaleExtraDayPeriodRules}
698
+ * @see [Internationalization (i18n) Guide](guide/i18n)
699
+ *
700
+ * @publicApi
701
+ *
702
+ * @deprecated Angular recommends relying on the `Intl` API for i18n.
703
+ * To extract a day period use `Intl.DateTimeFormat` with the `dayPeriod` option instead.
704
+ */
705
+ function getLocaleExtraDayPeriods(locale, formStyle, width) {
706
+ const data = _findLocaleData(locale);
707
+ checkFullData(data);
708
+ const dayPeriodsData = [
709
+ data[_LocaleDataIndex.ExtraData][0 /* ɵExtraLocaleDataIndex.ExtraDayPeriodFormats */],
710
+ data[_LocaleDataIndex.ExtraData][1 /* ɵExtraLocaleDataIndex.ExtraDayPeriodStandalone */],
711
+ ];
712
+ const dayPeriods = getLastDefinedValue(dayPeriodsData, formStyle) || [];
713
+ return getLastDefinedValue(dayPeriods, width) || [];
714
+ }
715
+ /**
716
+ * Retrieves the writing direction of a specified locale
717
+ * @param locale A locale code for the locale format rules to use.
718
+ * @publicApi
719
+ * @returns 'rtl' or 'ltr'
720
+ * @see [Internationalization (i18n) Guide](guide/i18n)
721
+ *
722
+ * @deprecated Angular recommends relying on the `Intl` API for i18n.
723
+ * For dates and numbers, let `Intl.DateTimeFormat()` and `Intl.NumberFormat()` determine the writing direction.
724
+ * The `Intl` alternative [`getTextInfo`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/getTextInfo).
725
+ * has only partial support (Chromium M99 & Safari 17).
726
+ * 3rd party alternatives like [`rtl-detect`](https://www.npmjs.com/package/rtl-detect) can work around this issue.
727
+ */
728
+ function getLocaleDirection(locale) {
729
+ const data = _findLocaleData(locale);
730
+ return data[_LocaleDataIndex.Directionality];
731
+ }
732
+ /**
733
+ * Retrieves the first value that is defined in an array, going backwards from an index position.
734
+ *
735
+ * To avoid repeating the same data (as when the "format" and "standalone" forms are the same)
736
+ * add the first value to the locale data arrays, and add other values only if they are different.
737
+ *
738
+ * @param data The data array to retrieve from.
739
+ * @param index A 0-based index into the array to start from.
740
+ * @returns The value immediately before the given index position.
741
+ * @see [Internationalization (i18n) Guide](guide/i18n)
742
+ *
743
+ */
744
+ function getLastDefinedValue(data, index) {
745
+ for (let i = index; i > -1; i--) {
746
+ if (typeof data[i] !== 'undefined') {
747
+ return data[i];
748
+ }
749
+ }
750
+ throw new Error('Locale data API: locale data undefined');
751
+ }
752
+ /**
753
+ * Extracts the hours and minutes from a string like "15:45"
754
+ */
755
+ function extractTime(time) {
756
+ const [h, m] = time.split(':');
757
+ return { hours: +h, minutes: +m };
758
+ }
759
+ /**
760
+ * Retrieves the currency symbol for a given currency code.
761
+ *
762
+ * For example, for the default `en-US` locale, the code `USD` can
763
+ * be represented by the narrow symbol `$` or the wide symbol `US$`.
764
+ *
765
+ * @param code The currency code.
766
+ * @param format The format, `wide` or `narrow`.
767
+ * @param locale A locale code for the locale format rules to use.
768
+ *
769
+ * @returns The symbol, or the currency code if no symbol is available.
770
+ * @see [Internationalization (i18n) Guide](guide/i18n)
771
+ *
772
+ * @publicApi
773
+ *
774
+ * @deprecated Angular recommends relying on the `Intl` API for i18n.
775
+ * You can use `Intl.NumberFormat().formatToParts()` to extract the currency symbol.
776
+ * For example: `Intl.NumberFormat('en', {style:'currency', currency: 'USD'}).formatToParts().find(part => part.type === 'currency').value`
777
+ * returns `$` for USD currency code in the `en` locale.
778
+ * Note: `US$` is a currency symbol for the `en-ca` locale but not the `en-us` locale.
779
+ */
780
+ function getCurrencySymbol(code, format, locale = 'en') {
781
+ const currency = getLocaleCurrencies(locale)[code] || CURRENCIES_EN[code] || [];
782
+ const symbolNarrow = currency[1 /* ɵCurrencyIndex.SymbolNarrow */];
783
+ if (format === 'narrow' && typeof symbolNarrow === 'string') {
784
+ return symbolNarrow;
785
+ }
786
+ return currency[0 /* ɵCurrencyIndex.Symbol */] || code;
787
+ }
788
+ // Most currencies have cents, that's why the default is 2
789
+ const DEFAULT_NB_OF_CURRENCY_DIGITS = 2;
790
+ /**
791
+ * Reports the number of decimal digits for a given currency.
792
+ * The value depends upon the presence of cents in that particular currency.
793
+ *
794
+ * @param code The currency code.
795
+ * @returns The number of decimal digits, typically 0 or 2.
796
+ * @see [Internationalization (i18n) Guide](guide/i18n)
797
+ *
798
+ * @publicApi
799
+ *
800
+ * @deprecated Angular recommends relying on the `Intl` API for i18n.
801
+ * This function should not be used anymore. Let `Intl.NumberFormat` determine the number of digits to display for the currency
802
+ */
803
+ function getNumberOfCurrencyDigits(code) {
804
+ let digits;
805
+ const currency = CURRENCIES_EN[code];
806
+ if (currency) {
807
+ digits = currency[2 /* ɵCurrencyIndex.NbOfDigits */];
808
+ }
809
+ return typeof digits === 'number' ? digits : DEFAULT_NB_OF_CURRENCY_DIGITS;
810
+ }
811
+
812
+ const ISO8601_DATE_REGEX = /^(\d{4,})-?(\d\d)-?(\d\d)(?:T(\d\d)(?::?(\d\d)(?::?(\d\d)(?:\.(\d+))?)?)?(Z|([+-])(\d\d):?(\d\d))?)?$/;
813
+ // 1 2 3 4 5 6 7 8 9 10 11
814
+ const NAMED_FORMATS = {};
815
+ const DATE_FORMATS_SPLIT = /((?:[^BEGHLMOSWYZabcdhmswyz']+)|(?:'(?:[^']|'')*')|(?:G{1,5}|y{1,4}|Y{1,4}|M{1,5}|L{1,5}|w{1,2}|W{1}|d{1,2}|E{1,6}|c{1,6}|a{1,5}|b{1,5}|B{1,5}|h{1,2}|H{1,2}|m{1,2}|s{1,2}|S{1,3}|z{1,4}|Z{1,5}|O{1,4}))([\s\S]*)/;
816
+ /**
817
+ * @ngModule CommonModule
818
+ * @description
819
+ *
820
+ * Formats a date according to locale rules.
821
+ *
822
+ * @param value The date to format, as a Date, or a number (milliseconds since UTC epoch)
823
+ * or an [ISO date-time string](https://www.w3.org/TR/NOTE-datetime).
824
+ * @param format The date-time components to include. See `DatePipe` for details.
825
+ * @param locale A locale code for the locale format rules to use.
826
+ * @param timezone The time zone. A time zone offset from GMT (such as `'+0430'`).
827
+ * If not specified, uses host system settings.
828
+ *
829
+ * @returns The formatted date string.
830
+ *
831
+ * @see {@link DatePipe}
832
+ * @see [Internationalization (i18n) Guide](guide/i18n)
833
+ *
834
+ * @publicApi
835
+ */
836
+ function formatDate(value, format, locale, timezone) {
837
+ let date = toDate(value);
838
+ const namedFormat = getNamedFormat(locale, format);
839
+ format = namedFormat || format;
840
+ let parts = [];
841
+ let match;
842
+ while (format) {
843
+ match = DATE_FORMATS_SPLIT.exec(format);
844
+ if (match) {
845
+ parts = parts.concat(match.slice(1));
846
+ const part = parts.pop();
847
+ if (!part) {
848
+ break;
849
+ }
850
+ format = part;
851
+ }
852
+ else {
853
+ parts.push(format);
854
+ break;
855
+ }
856
+ }
857
+ let dateTimezoneOffset = date.getTimezoneOffset();
858
+ if (timezone) {
859
+ dateTimezoneOffset = timezoneToOffset(timezone, dateTimezoneOffset);
860
+ date = convertTimezoneToLocal(date, timezone);
861
+ }
862
+ let text = '';
863
+ parts.forEach((value) => {
864
+ const dateFormatter = getDateFormatter(value);
865
+ text += dateFormatter
866
+ ? dateFormatter(date, locale, dateTimezoneOffset)
867
+ : value === "''"
868
+ ? "'"
869
+ : value.replace(/(^'|'$)/g, '').replace(/''/g, "'");
870
+ });
871
+ return text;
872
+ }
873
+ /**
874
+ * Create a new Date object with the given date value, and the time set to midnight.
875
+ *
876
+ * We cannot use `new Date(year, month, date)` because it maps years between 0 and 99 to 1900-1999.
877
+ * See: https://github.com/angular/angular/issues/40377
878
+ *
879
+ * Note that this function returns a Date object whose time is midnight in the current locale's
880
+ * timezone. In the future we might want to change this to be midnight in UTC, but this would be a
881
+ * considerable breaking change.
882
+ */
883
+ function createDate(year, month, date) {
884
+ // The `newDate` is set to midnight (UTC) on January 1st 1970.
885
+ // - In PST this will be December 31st 1969 at 4pm.
886
+ // - In GMT this will be January 1st 1970 at 1am.
887
+ // Note that they even have different years, dates and months!
888
+ const newDate = new Date(0);
889
+ // `setFullYear()` allows years like 0001 to be set correctly. This function does not
890
+ // change the internal time of the date.
891
+ // Consider calling `setFullYear(2019, 8, 20)` (September 20, 2019).
892
+ // - In PST this will now be September 20, 2019 at 4pm
893
+ // - In GMT this will now be September 20, 2019 at 1am
894
+ newDate.setFullYear(year, month, date);
895
+ // We want the final date to be at local midnight, so we reset the time.
896
+ // - In PST this will now be September 20, 2019 at 12am
897
+ // - In GMT this will now be September 20, 2019 at 12am
898
+ newDate.setHours(0, 0, 0);
899
+ return newDate;
900
+ }
901
+ function getNamedFormat(locale, format) {
902
+ const localeId = getLocaleId(locale);
903
+ NAMED_FORMATS[localeId] ??= {};
904
+ if (NAMED_FORMATS[localeId][format]) {
905
+ return NAMED_FORMATS[localeId][format];
906
+ }
907
+ let formatValue = '';
908
+ switch (format) {
909
+ case 'shortDate':
910
+ formatValue = getLocaleDateFormat(locale, FormatWidth.Short);
911
+ break;
912
+ case 'mediumDate':
913
+ formatValue = getLocaleDateFormat(locale, FormatWidth.Medium);
914
+ break;
915
+ case 'longDate':
916
+ formatValue = getLocaleDateFormat(locale, FormatWidth.Long);
917
+ break;
918
+ case 'fullDate':
919
+ formatValue = getLocaleDateFormat(locale, FormatWidth.Full);
920
+ break;
921
+ case 'shortTime':
922
+ formatValue = getLocaleTimeFormat(locale, FormatWidth.Short);
923
+ break;
924
+ case 'mediumTime':
925
+ formatValue = getLocaleTimeFormat(locale, FormatWidth.Medium);
926
+ break;
927
+ case 'longTime':
928
+ formatValue = getLocaleTimeFormat(locale, FormatWidth.Long);
929
+ break;
930
+ case 'fullTime':
931
+ formatValue = getLocaleTimeFormat(locale, FormatWidth.Full);
932
+ break;
933
+ case 'short':
934
+ const shortTime = getNamedFormat(locale, 'shortTime');
935
+ const shortDate = getNamedFormat(locale, 'shortDate');
936
+ formatValue = formatDateTime(getLocaleDateTimeFormat(locale, FormatWidth.Short), [
937
+ shortTime,
938
+ shortDate,
939
+ ]);
940
+ break;
941
+ case 'medium':
942
+ const mediumTime = getNamedFormat(locale, 'mediumTime');
943
+ const mediumDate = getNamedFormat(locale, 'mediumDate');
944
+ formatValue = formatDateTime(getLocaleDateTimeFormat(locale, FormatWidth.Medium), [
945
+ mediumTime,
946
+ mediumDate,
947
+ ]);
948
+ break;
949
+ case 'long':
950
+ const longTime = getNamedFormat(locale, 'longTime');
951
+ const longDate = getNamedFormat(locale, 'longDate');
952
+ formatValue = formatDateTime(getLocaleDateTimeFormat(locale, FormatWidth.Long), [
953
+ longTime,
954
+ longDate,
955
+ ]);
956
+ break;
957
+ case 'full':
958
+ const fullTime = getNamedFormat(locale, 'fullTime');
959
+ const fullDate = getNamedFormat(locale, 'fullDate');
960
+ formatValue = formatDateTime(getLocaleDateTimeFormat(locale, FormatWidth.Full), [
961
+ fullTime,
962
+ fullDate,
963
+ ]);
964
+ break;
965
+ }
966
+ if (formatValue) {
967
+ NAMED_FORMATS[localeId][format] = formatValue;
968
+ }
969
+ return formatValue;
970
+ }
971
+ function formatDateTime(str, opt_values) {
972
+ if (opt_values) {
973
+ str = str.replace(/\{([^}]+)}/g, function (match, key) {
974
+ return opt_values != null && key in opt_values ? opt_values[key] : match;
975
+ });
976
+ }
977
+ return str;
978
+ }
979
+ function padNumber(num, digits, minusSign = '-', trim, negWrap) {
980
+ let neg = '';
981
+ if (num < 0 || (negWrap && num <= 0)) {
982
+ if (negWrap) {
983
+ num = -num + 1;
984
+ }
985
+ else {
986
+ num = -num;
987
+ neg = minusSign;
988
+ }
989
+ }
990
+ let strNum = String(num);
991
+ while (strNum.length < digits) {
992
+ strNum = '0' + strNum;
993
+ }
994
+ if (trim) {
995
+ strNum = strNum.slice(strNum.length - digits);
996
+ }
997
+ return neg + strNum;
998
+ }
999
+ function formatFractionalSeconds(milliseconds, digits) {
1000
+ const strMs = padNumber(milliseconds, 3);
1001
+ return strMs.substring(0, digits);
1002
+ }
1003
+ /**
1004
+ * Returns a date formatter that transforms a date into its locale digit representation
1005
+ */
1006
+ function dateGetter(name, size, offset = 0, trim = false, negWrap = false) {
1007
+ return function (date, locale) {
1008
+ let part = getDatePart(name, date);
1009
+ if (offset > 0 || part > -offset) {
1010
+ part += offset;
1011
+ }
1012
+ if (name === 3 /* DateType.Hours */) {
1013
+ if (part === 0 && offset === -12) {
1014
+ part = 12;
1015
+ }
1016
+ }
1017
+ else if (name === 6 /* DateType.FractionalSeconds */) {
1018
+ return formatFractionalSeconds(part, size);
1019
+ }
1020
+ const localeMinus = getLocaleNumberSymbol(locale, NumberSymbol.MinusSign);
1021
+ return padNumber(part, size, localeMinus, trim, negWrap);
1022
+ };
1023
+ }
1024
+ function getDatePart(part, date) {
1025
+ switch (part) {
1026
+ case 0 /* DateType.FullYear */:
1027
+ return date.getFullYear();
1028
+ case 1 /* DateType.Month */:
1029
+ return date.getMonth();
1030
+ case 2 /* DateType.Date */:
1031
+ return date.getDate();
1032
+ case 3 /* DateType.Hours */:
1033
+ return date.getHours();
1034
+ case 4 /* DateType.Minutes */:
1035
+ return date.getMinutes();
1036
+ case 5 /* DateType.Seconds */:
1037
+ return date.getSeconds();
1038
+ case 6 /* DateType.FractionalSeconds */:
1039
+ return date.getMilliseconds();
1040
+ case 7 /* DateType.Day */:
1041
+ return date.getDay();
1042
+ default:
1043
+ throw new Error(`Unknown DateType value "${part}".`);
1044
+ }
1045
+ }
1046
+ /**
1047
+ * Returns a date formatter that transforms a date into its locale string representation
1048
+ */
1049
+ function dateStrGetter(name, width, form = FormStyle.Format, extended = false) {
1050
+ return function (date, locale) {
1051
+ return getDateTranslation(date, locale, name, width, form, extended);
1052
+ };
1053
+ }
1054
+ /**
1055
+ * Returns the locale translation of a date for a given form, type and width
1056
+ */
1057
+ function getDateTranslation(date, locale, name, width, form, extended) {
1058
+ switch (name) {
1059
+ case 2 /* TranslationType.Months */:
1060
+ return getLocaleMonthNames(locale, form, width)[date.getMonth()];
1061
+ case 1 /* TranslationType.Days */:
1062
+ return getLocaleDayNames(locale, form, width)[date.getDay()];
1063
+ case 0 /* TranslationType.DayPeriods */:
1064
+ const currentHours = date.getHours();
1065
+ const currentMinutes = date.getMinutes();
1066
+ if (extended) {
1067
+ const rules = getLocaleExtraDayPeriodRules(locale);
1068
+ const dayPeriods = getLocaleExtraDayPeriods(locale, form, width);
1069
+ const index = rules.findIndex((rule) => {
1070
+ if (Array.isArray(rule)) {
1071
+ // morning, afternoon, evening, night
1072
+ const [from, to] = rule;
1073
+ const afterFrom = currentHours >= from.hours && currentMinutes >= from.minutes;
1074
+ const beforeTo = currentHours < to.hours || (currentHours === to.hours && currentMinutes < to.minutes);
1075
+ // We must account for normal rules that span a period during the day (e.g. 6am-9am)
1076
+ // where `from` is less (earlier) than `to`. But also rules that span midnight (e.g.
1077
+ // 10pm - 5am) where `from` is greater (later!) than `to`.
1078
+ //
1079
+ // In the first case the current time must be BOTH after `from` AND before `to`
1080
+ // (e.g. 8am is after 6am AND before 10am).
1081
+ //
1082
+ // In the second case the current time must be EITHER after `from` OR before `to`
1083
+ // (e.g. 4am is before 5am but not after 10pm; and 11pm is not before 5am but it is
1084
+ // after 10pm).
1085
+ if (from.hours < to.hours) {
1086
+ if (afterFrom && beforeTo) {
1087
+ return true;
1088
+ }
1089
+ }
1090
+ else if (afterFrom || beforeTo) {
1091
+ return true;
1092
+ }
1093
+ }
1094
+ else {
1095
+ // noon or midnight
1096
+ if (rule.hours === currentHours && rule.minutes === currentMinutes) {
1097
+ return true;
1098
+ }
1099
+ }
1100
+ return false;
1101
+ });
1102
+ if (index !== -1) {
1103
+ return dayPeriods[index];
1104
+ }
1105
+ }
1106
+ // if no rules for the day periods, we use am/pm by default
1107
+ return getLocaleDayPeriods(locale, form, width)[currentHours < 12 ? 0 : 1];
1108
+ case 3 /* TranslationType.Eras */:
1109
+ return getLocaleEraNames(locale, width)[date.getFullYear() <= 0 ? 0 : 1];
1110
+ default:
1111
+ // This default case is not needed by TypeScript compiler, as the switch is exhaustive.
1112
+ // However Closure Compiler does not understand that and reports an error in typed mode.
1113
+ // The `throw new Error` below works around the problem, and the unexpected: never variable
1114
+ // makes sure tsc still checks this code is unreachable.
1115
+ const unexpected = name;
1116
+ throw new Error(`unexpected translation type ${unexpected}`);
1117
+ }
1118
+ }
1119
+ /**
1120
+ * Returns a date formatter that transforms a date and an offset into a timezone with ISO8601 or
1121
+ * GMT format depending on the width (eg: short = +0430, short:GMT = GMT+4, long = GMT+04:30,
1122
+ * extended = +04:30)
1123
+ */
1124
+ function timeZoneGetter(width) {
1125
+ return function (date, locale, offset) {
1126
+ const zone = -1 * offset;
1127
+ const minusSign = getLocaleNumberSymbol(locale, NumberSymbol.MinusSign);
1128
+ const hours = zone > 0 ? Math.floor(zone / 60) : Math.ceil(zone / 60);
1129
+ switch (width) {
1130
+ case 0 /* ZoneWidth.Short */:
1131
+ return ((zone >= 0 ? '+' : '') +
1132
+ padNumber(hours, 2, minusSign) +
1133
+ padNumber(Math.abs(zone % 60), 2, minusSign));
1134
+ case 1 /* ZoneWidth.ShortGMT */:
1135
+ return 'GMT' + (zone >= 0 ? '+' : '') + padNumber(hours, 1, minusSign);
1136
+ case 2 /* ZoneWidth.Long */:
1137
+ return ('GMT' +
1138
+ (zone >= 0 ? '+' : '') +
1139
+ padNumber(hours, 2, minusSign) +
1140
+ ':' +
1141
+ padNumber(Math.abs(zone % 60), 2, minusSign));
1142
+ case 3 /* ZoneWidth.Extended */:
1143
+ if (offset === 0) {
1144
+ return 'Z';
1145
+ }
1146
+ else {
1147
+ return ((zone >= 0 ? '+' : '') +
1148
+ padNumber(hours, 2, minusSign) +
1149
+ ':' +
1150
+ padNumber(Math.abs(zone % 60), 2, minusSign));
1151
+ }
1152
+ default:
1153
+ throw new Error(`Unknown zone width "${width}"`);
1154
+ }
1155
+ };
1156
+ }
1157
+ const JANUARY = 0;
1158
+ const THURSDAY = 4;
1159
+ function getFirstThursdayOfYear(year) {
1160
+ const firstDayOfYear = createDate(year, JANUARY, 1).getDay();
1161
+ return createDate(year, 0, 1 + (firstDayOfYear <= THURSDAY ? THURSDAY : THURSDAY + 7) - firstDayOfYear);
1162
+ }
1163
+ /**
1164
+ * ISO Week starts on day 1 (Monday) and ends with day 0 (Sunday)
1165
+ */
1166
+ function getThursdayThisIsoWeek(datetime) {
1167
+ // getDay returns 0-6 range with sunday as 0.
1168
+ const currentDay = datetime.getDay();
1169
+ // On a Sunday, read the previous Thursday since ISO weeks start on Monday.
1170
+ const deltaToThursday = currentDay === 0 ? -3 : THURSDAY - currentDay;
1171
+ return createDate(datetime.getFullYear(), datetime.getMonth(), datetime.getDate() + deltaToThursday);
1172
+ }
1173
+ function weekGetter(size, monthBased = false) {
1174
+ return function (date, locale) {
1175
+ let result;
1176
+ if (monthBased) {
1177
+ const nbDaysBefore1stDayOfMonth = new Date(date.getFullYear(), date.getMonth(), 1).getDay() - 1;
1178
+ const today = date.getDate();
1179
+ result = 1 + Math.floor((today + nbDaysBefore1stDayOfMonth) / 7);
1180
+ }
1181
+ else {
1182
+ const thisThurs = getThursdayThisIsoWeek(date);
1183
+ // Some days of a year are part of next year according to ISO 8601.
1184
+ // Compute the firstThurs from the year of this week's Thursday
1185
+ const firstThurs = getFirstThursdayOfYear(thisThurs.getFullYear());
1186
+ const diff = thisThurs.getTime() - firstThurs.getTime();
1187
+ result = 1 + Math.round(diff / 6.048e8); // 6.048e8 ms per week
1188
+ }
1189
+ return padNumber(result, size, getLocaleNumberSymbol(locale, NumberSymbol.MinusSign));
1190
+ };
1191
+ }
1192
+ /**
1193
+ * Returns a date formatter that provides the week-numbering year for the input date.
1194
+ */
1195
+ function weekNumberingYearGetter(size, trim = false) {
1196
+ return function (date, locale) {
1197
+ const thisThurs = getThursdayThisIsoWeek(date);
1198
+ const weekNumberingYear = thisThurs.getFullYear();
1199
+ return padNumber(weekNumberingYear, size, getLocaleNumberSymbol(locale, NumberSymbol.MinusSign), trim);
1200
+ };
1201
+ }
1202
+ const DATE_FORMATS = {};
1203
+ // Based on CLDR formats:
1204
+ // See complete list: http://www.unicode.org/reports/tr35/tr35-dates.html#Date_Field_Symbol_Table
1205
+ // See also explanations: http://cldr.unicode.org/translation/date-time
1206
+ // TODO(ocombe): support all missing cldr formats: U, Q, D, F, e, j, J, C, A, v, V, X, x
1207
+ function getDateFormatter(format) {
1208
+ if (DATE_FORMATS[format]) {
1209
+ return DATE_FORMATS[format];
1210
+ }
1211
+ let formatter;
1212
+ switch (format) {
1213
+ // Era name (AD/BC)
1214
+ case 'G':
1215
+ case 'GG':
1216
+ case 'GGG':
1217
+ formatter = dateStrGetter(3 /* TranslationType.Eras */, TranslationWidth.Abbreviated);
1218
+ break;
1219
+ case 'GGGG':
1220
+ formatter = dateStrGetter(3 /* TranslationType.Eras */, TranslationWidth.Wide);
1221
+ break;
1222
+ case 'GGGGG':
1223
+ formatter = dateStrGetter(3 /* TranslationType.Eras */, TranslationWidth.Narrow);
1224
+ break;
1225
+ // 1 digit representation of the year, e.g. (AD 1 => 1, AD 199 => 199)
1226
+ case 'y':
1227
+ formatter = dateGetter(0 /* DateType.FullYear */, 1, 0, false, true);
1228
+ break;
1229
+ // 2 digit representation of the year, padded (00-99). (e.g. AD 2001 => 01, AD 2010 => 10)
1230
+ case 'yy':
1231
+ formatter = dateGetter(0 /* DateType.FullYear */, 2, 0, true, true);
1232
+ break;
1233
+ // 3 digit representation of the year, padded (000-999). (e.g. AD 2001 => 01, AD 2010 => 10)
1234
+ case 'yyy':
1235
+ formatter = dateGetter(0 /* DateType.FullYear */, 3, 0, false, true);
1236
+ break;
1237
+ // 4 digit representation of the year (e.g. AD 1 => 0001, AD 2010 => 2010)
1238
+ case 'yyyy':
1239
+ formatter = dateGetter(0 /* DateType.FullYear */, 4, 0, false, true);
1240
+ break;
1241
+ // 1 digit representation of the week-numbering year, e.g. (AD 1 => 1, AD 199 => 199)
1242
+ case 'Y':
1243
+ formatter = weekNumberingYearGetter(1);
1244
+ break;
1245
+ // 2 digit representation of the week-numbering year, padded (00-99). (e.g. AD 2001 => 01, AD
1246
+ // 2010 => 10)
1247
+ case 'YY':
1248
+ formatter = weekNumberingYearGetter(2, true);
1249
+ break;
1250
+ // 3 digit representation of the week-numbering year, padded (000-999). (e.g. AD 1 => 001, AD
1251
+ // 2010 => 2010)
1252
+ case 'YYY':
1253
+ formatter = weekNumberingYearGetter(3);
1254
+ break;
1255
+ // 4 digit representation of the week-numbering year (e.g. AD 1 => 0001, AD 2010 => 2010)
1256
+ case 'YYYY':
1257
+ formatter = weekNumberingYearGetter(4);
1258
+ break;
1259
+ // Month of the year (1-12), numeric
1260
+ case 'M':
1261
+ case 'L':
1262
+ formatter = dateGetter(1 /* DateType.Month */, 1, 1);
1263
+ break;
1264
+ case 'MM':
1265
+ case 'LL':
1266
+ formatter = dateGetter(1 /* DateType.Month */, 2, 1);
1267
+ break;
1268
+ // Month of the year (January, ...), string, format
1269
+ case 'MMM':
1270
+ formatter = dateStrGetter(2 /* TranslationType.Months */, TranslationWidth.Abbreviated);
1271
+ break;
1272
+ case 'MMMM':
1273
+ formatter = dateStrGetter(2 /* TranslationType.Months */, TranslationWidth.Wide);
1274
+ break;
1275
+ case 'MMMMM':
1276
+ formatter = dateStrGetter(2 /* TranslationType.Months */, TranslationWidth.Narrow);
1277
+ break;
1278
+ // Month of the year (January, ...), string, standalone
1279
+ case 'LLL':
1280
+ formatter = dateStrGetter(2 /* TranslationType.Months */, TranslationWidth.Abbreviated, FormStyle.Standalone);
1281
+ break;
1282
+ case 'LLLL':
1283
+ formatter = dateStrGetter(2 /* TranslationType.Months */, TranslationWidth.Wide, FormStyle.Standalone);
1284
+ break;
1285
+ case 'LLLLL':
1286
+ formatter = dateStrGetter(2 /* TranslationType.Months */, TranslationWidth.Narrow, FormStyle.Standalone);
1287
+ break;
1288
+ // Week of the year (1, ... 52)
1289
+ case 'w':
1290
+ formatter = weekGetter(1);
1291
+ break;
1292
+ case 'ww':
1293
+ formatter = weekGetter(2);
1294
+ break;
1295
+ // Week of the month (1, ...)
1296
+ case 'W':
1297
+ formatter = weekGetter(1, true);
1298
+ break;
1299
+ // Day of the month (1-31)
1300
+ case 'd':
1301
+ formatter = dateGetter(2 /* DateType.Date */, 1);
1302
+ break;
1303
+ case 'dd':
1304
+ formatter = dateGetter(2 /* DateType.Date */, 2);
1305
+ break;
1306
+ // Day of the Week StandAlone (1, 1, Mon, Monday, M, Mo)
1307
+ case 'c':
1308
+ case 'cc':
1309
+ formatter = dateGetter(7 /* DateType.Day */, 1);
1310
+ break;
1311
+ case 'ccc':
1312
+ formatter = dateStrGetter(1 /* TranslationType.Days */, TranslationWidth.Abbreviated, FormStyle.Standalone);
1313
+ break;
1314
+ case 'cccc':
1315
+ formatter = dateStrGetter(1 /* TranslationType.Days */, TranslationWidth.Wide, FormStyle.Standalone);
1316
+ break;
1317
+ case 'ccccc':
1318
+ formatter = dateStrGetter(1 /* TranslationType.Days */, TranslationWidth.Narrow, FormStyle.Standalone);
1319
+ break;
1320
+ case 'cccccc':
1321
+ formatter = dateStrGetter(1 /* TranslationType.Days */, TranslationWidth.Short, FormStyle.Standalone);
1322
+ break;
1323
+ // Day of the Week
1324
+ case 'E':
1325
+ case 'EE':
1326
+ case 'EEE':
1327
+ formatter = dateStrGetter(1 /* TranslationType.Days */, TranslationWidth.Abbreviated);
1328
+ break;
1329
+ case 'EEEE':
1330
+ formatter = dateStrGetter(1 /* TranslationType.Days */, TranslationWidth.Wide);
1331
+ break;
1332
+ case 'EEEEE':
1333
+ formatter = dateStrGetter(1 /* TranslationType.Days */, TranslationWidth.Narrow);
1334
+ break;
1335
+ case 'EEEEEE':
1336
+ formatter = dateStrGetter(1 /* TranslationType.Days */, TranslationWidth.Short);
1337
+ break;
1338
+ // Generic period of the day (am-pm)
1339
+ case 'a':
1340
+ case 'aa':
1341
+ case 'aaa':
1342
+ formatter = dateStrGetter(0 /* TranslationType.DayPeriods */, TranslationWidth.Abbreviated);
1343
+ break;
1344
+ case 'aaaa':
1345
+ formatter = dateStrGetter(0 /* TranslationType.DayPeriods */, TranslationWidth.Wide);
1346
+ break;
1347
+ case 'aaaaa':
1348
+ formatter = dateStrGetter(0 /* TranslationType.DayPeriods */, TranslationWidth.Narrow);
1349
+ break;
1350
+ // Extended period of the day (midnight, at night, ...), standalone
1351
+ case 'b':
1352
+ case 'bb':
1353
+ case 'bbb':
1354
+ formatter = dateStrGetter(0 /* TranslationType.DayPeriods */, TranslationWidth.Abbreviated, FormStyle.Standalone, true);
1355
+ break;
1356
+ case 'bbbb':
1357
+ formatter = dateStrGetter(0 /* TranslationType.DayPeriods */, TranslationWidth.Wide, FormStyle.Standalone, true);
1358
+ break;
1359
+ case 'bbbbb':
1360
+ formatter = dateStrGetter(0 /* TranslationType.DayPeriods */, TranslationWidth.Narrow, FormStyle.Standalone, true);
1361
+ break;
1362
+ // Extended period of the day (midnight, night, ...), standalone
1363
+ case 'B':
1364
+ case 'BB':
1365
+ case 'BBB':
1366
+ formatter = dateStrGetter(0 /* TranslationType.DayPeriods */, TranslationWidth.Abbreviated, FormStyle.Format, true);
1367
+ break;
1368
+ case 'BBBB':
1369
+ formatter = dateStrGetter(0 /* TranslationType.DayPeriods */, TranslationWidth.Wide, FormStyle.Format, true);
1370
+ break;
1371
+ case 'BBBBB':
1372
+ formatter = dateStrGetter(0 /* TranslationType.DayPeriods */, TranslationWidth.Narrow, FormStyle.Format, true);
1373
+ break;
1374
+ // Hour in AM/PM, (1-12)
1375
+ case 'h':
1376
+ formatter = dateGetter(3 /* DateType.Hours */, 1, -12);
1377
+ break;
1378
+ case 'hh':
1379
+ formatter = dateGetter(3 /* DateType.Hours */, 2, -12);
1380
+ break;
1381
+ // Hour of the day (0-23)
1382
+ case 'H':
1383
+ formatter = dateGetter(3 /* DateType.Hours */, 1);
1384
+ break;
1385
+ // Hour in day, padded (00-23)
1386
+ case 'HH':
1387
+ formatter = dateGetter(3 /* DateType.Hours */, 2);
1388
+ break;
1389
+ // Minute of the hour (0-59)
1390
+ case 'm':
1391
+ formatter = dateGetter(4 /* DateType.Minutes */, 1);
1392
+ break;
1393
+ case 'mm':
1394
+ formatter = dateGetter(4 /* DateType.Minutes */, 2);
1395
+ break;
1396
+ // Second of the minute (0-59)
1397
+ case 's':
1398
+ formatter = dateGetter(5 /* DateType.Seconds */, 1);
1399
+ break;
1400
+ case 'ss':
1401
+ formatter = dateGetter(5 /* DateType.Seconds */, 2);
1402
+ break;
1403
+ // Fractional second
1404
+ case 'S':
1405
+ formatter = dateGetter(6 /* DateType.FractionalSeconds */, 1);
1406
+ break;
1407
+ case 'SS':
1408
+ formatter = dateGetter(6 /* DateType.FractionalSeconds */, 2);
1409
+ break;
1410
+ case 'SSS':
1411
+ formatter = dateGetter(6 /* DateType.FractionalSeconds */, 3);
1412
+ break;
1413
+ // Timezone ISO8601 short format (-0430)
1414
+ case 'Z':
1415
+ case 'ZZ':
1416
+ case 'ZZZ':
1417
+ formatter = timeZoneGetter(0 /* ZoneWidth.Short */);
1418
+ break;
1419
+ // Timezone ISO8601 extended format (-04:30)
1420
+ case 'ZZZZZ':
1421
+ formatter = timeZoneGetter(3 /* ZoneWidth.Extended */);
1422
+ break;
1423
+ // Timezone GMT short format (GMT+4)
1424
+ case 'O':
1425
+ case 'OO':
1426
+ case 'OOO':
1427
+ // Should be location, but fallback to format O instead because we don't have the data yet
1428
+ case 'z':
1429
+ case 'zz':
1430
+ case 'zzz':
1431
+ formatter = timeZoneGetter(1 /* ZoneWidth.ShortGMT */);
1432
+ break;
1433
+ // Timezone GMT long format (GMT+0430)
1434
+ case 'OOOO':
1435
+ case 'ZZZZ':
1436
+ // Should be location, but fallback to format O instead because we don't have the data yet
1437
+ case 'zzzz':
1438
+ formatter = timeZoneGetter(2 /* ZoneWidth.Long */);
1439
+ break;
1440
+ default:
1441
+ return null;
1442
+ }
1443
+ DATE_FORMATS[format] = formatter;
1444
+ return formatter;
1445
+ }
1446
+ function timezoneToOffset(timezone, fallback) {
1447
+ // Support: IE 11 only, Edge 13-15+
1448
+ // IE/Edge do not "understand" colon (`:`) in timezone
1449
+ timezone = timezone.replace(/:/g, '');
1450
+ const requestedTimezoneOffset = Date.parse('Jan 01, 1970 00:00:00 ' + timezone) / 60000;
1451
+ return isNaN(requestedTimezoneOffset) ? fallback : requestedTimezoneOffset;
1452
+ }
1453
+ function addDateMinutes(date, minutes) {
1454
+ date = new Date(date.getTime());
1455
+ date.setMinutes(date.getMinutes() + minutes);
1456
+ return date;
1457
+ }
1458
+ function convertTimezoneToLocal(date, timezone, reverse) {
1459
+ const reverseValue = -1 ;
1460
+ const dateTimezoneOffset = date.getTimezoneOffset();
1461
+ const timezoneOffset = timezoneToOffset(timezone, dateTimezoneOffset);
1462
+ return addDateMinutes(date, reverseValue * (timezoneOffset - dateTimezoneOffset));
1463
+ }
1464
+ /**
1465
+ * Converts a value to date.
1466
+ *
1467
+ * Supported input formats:
1468
+ * - `Date`
1469
+ * - number: timestamp
1470
+ * - string: numeric (e.g. "1234"), ISO and date strings in a format supported by
1471
+ * [Date.parse()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/parse).
1472
+ * Note: ISO strings without time return a date without timeoffset.
1473
+ *
1474
+ * Throws if unable to convert to a date.
1475
+ */
1476
+ function toDate(value) {
1477
+ if (isDate(value)) {
1478
+ return value;
1479
+ }
1480
+ if (typeof value === 'number' && !isNaN(value)) {
1481
+ return new Date(value);
1482
+ }
1483
+ if (typeof value === 'string') {
1484
+ value = value.trim();
1485
+ if (/^(\d{4}(-\d{1,2}(-\d{1,2})?)?)$/.test(value)) {
1486
+ /* For ISO Strings without time the day, month and year must be extracted from the ISO String
1487
+ before Date creation to avoid time offset and errors in the new Date.
1488
+ If we only replace '-' with ',' in the ISO String ("2015,01,01"), and try to create a new
1489
+ date, some browsers (e.g. IE 9) will throw an invalid Date error.
1490
+ If we leave the '-' ("2015-01-01") and try to create a new Date("2015-01-01") the timeoffset
1491
+ is applied.
1492
+ Note: ISO months are 0 for January, 1 for February, ... */
1493
+ const [y, m = 1, d = 1] = value.split('-').map((val) => +val);
1494
+ return createDate(y, m - 1, d);
1495
+ }
1496
+ const parsedNb = parseFloat(value);
1497
+ // any string that only contains numbers, like "1234" but not like "1234hello"
1498
+ if (!isNaN(value - parsedNb)) {
1499
+ return new Date(parsedNb);
1500
+ }
1501
+ let match;
1502
+ if ((match = value.match(ISO8601_DATE_REGEX))) {
1503
+ return isoStringToDate(match);
1504
+ }
1505
+ }
1506
+ const date = new Date(value);
1507
+ if (!isDate(date)) {
1508
+ throw new Error(`Unable to convert "${value}" into a date`);
1509
+ }
1510
+ return date;
1511
+ }
1512
+ /**
1513
+ * Converts a date in ISO8601 to a Date.
1514
+ * Used instead of `Date.parse` because of browser discrepancies.
1515
+ */
1516
+ function isoStringToDate(match) {
1517
+ const date = new Date(0);
1518
+ let tzHour = 0;
1519
+ let tzMin = 0;
1520
+ // match[8] means that the string contains "Z" (UTC) or a timezone like "+01:00" or "+0100"
1521
+ const dateSetter = match[8] ? date.setUTCFullYear : date.setFullYear;
1522
+ const timeSetter = match[8] ? date.setUTCHours : date.setHours;
1523
+ // if there is a timezone defined like "+01:00" or "+0100"
1524
+ if (match[9]) {
1525
+ tzHour = Number(match[9] + match[10]);
1526
+ tzMin = Number(match[9] + match[11]);
1527
+ }
1528
+ dateSetter.call(date, Number(match[1]), Number(match[2]) - 1, Number(match[3]));
1529
+ const h = Number(match[4] || 0) - tzHour;
1530
+ const m = Number(match[5] || 0) - tzMin;
1531
+ const s = Number(match[6] || 0);
1532
+ // The ECMAScript specification (https://www.ecma-international.org/ecma-262/5.1/#sec-15.9.1.11)
1533
+ // defines that `DateTime` milliseconds should always be rounded down, so that `999.9ms`
1534
+ // becomes `999ms`.
1535
+ const ms = Math.floor(parseFloat('0.' + (match[7] || 0)) * 1000);
1536
+ timeSetter.call(date, h, m, s, ms);
1537
+ return date;
1538
+ }
1539
+ function isDate(value) {
1540
+ return value instanceof Date && !isNaN(value.valueOf());
1541
+ }
1542
+
1543
+ const NUMBER_FORMAT_REGEXP = /^(\d+)?\.((\d+)(-(\d+))?)?$/;
1544
+ const MAX_DIGITS = 22;
1545
+ const DECIMAL_SEP = '.';
1546
+ const ZERO_CHAR = '0';
1547
+ const PATTERN_SEP = ';';
1548
+ const GROUP_SEP = ',';
1549
+ const DIGIT_CHAR = '#';
1550
+ const CURRENCY_CHAR = '¤';
1551
+ const PERCENT_CHAR = '%';
1552
+ /**
1553
+ * Transforms a number to a locale string based on a style and a format.
1554
+ */
1555
+ function formatNumberToLocaleString(value, pattern, locale, groupSymbol, decimalSymbol, digitsInfo, isPercent = false) {
1556
+ let formattedText = '';
1557
+ let isZero = false;
1558
+ if (!isFinite(value)) {
1559
+ formattedText = getLocaleNumberSymbol(locale, NumberSymbol.Infinity);
1560
+ }
1561
+ else {
1562
+ let parsedNumber = parseNumber(value);
1563
+ if (isPercent) {
1564
+ parsedNumber = toPercent(parsedNumber);
1565
+ }
1566
+ let minInt = pattern.minInt;
1567
+ let minFraction = pattern.minFrac;
1568
+ let maxFraction = pattern.maxFrac;
1569
+ if (digitsInfo) {
1570
+ const parts = digitsInfo.match(NUMBER_FORMAT_REGEXP);
1571
+ if (parts === null) {
1572
+ throw new Error(`${digitsInfo} is not a valid digit info`);
1573
+ }
1574
+ const minIntPart = parts[1];
1575
+ const minFractionPart = parts[3];
1576
+ const maxFractionPart = parts[5];
1577
+ if (minIntPart != null) {
1578
+ minInt = parseIntAutoRadix(minIntPart);
1579
+ }
1580
+ if (minFractionPart != null) {
1581
+ minFraction = parseIntAutoRadix(minFractionPart);
1582
+ }
1583
+ if (maxFractionPart != null) {
1584
+ maxFraction = parseIntAutoRadix(maxFractionPart);
1585
+ }
1586
+ else if (minFractionPart != null && minFraction > maxFraction) {
1587
+ maxFraction = minFraction;
1588
+ }
1589
+ }
1590
+ roundNumber(parsedNumber, minFraction, maxFraction);
1591
+ let digits = parsedNumber.digits;
1592
+ let integerLen = parsedNumber.integerLen;
1593
+ const exponent = parsedNumber.exponent;
1594
+ let decimals = [];
1595
+ isZero = digits.every((d) => !d);
1596
+ // pad zeros for small numbers
1597
+ for (; integerLen < minInt; integerLen++) {
1598
+ digits.unshift(0);
1599
+ }
1600
+ // pad zeros for small numbers
1601
+ for (; integerLen < 0; integerLen++) {
1602
+ digits.unshift(0);
1603
+ }
1604
+ // extract decimals digits
1605
+ if (integerLen > 0) {
1606
+ decimals = digits.splice(integerLen, digits.length);
1607
+ }
1608
+ else {
1609
+ decimals = digits;
1610
+ digits = [0];
1611
+ }
1612
+ // format the integer digits with grouping separators
1613
+ const groups = [];
1614
+ if (digits.length >= pattern.lgSize) {
1615
+ groups.unshift(digits.splice(-pattern.lgSize, digits.length).join(''));
1616
+ }
1617
+ while (digits.length > pattern.gSize) {
1618
+ groups.unshift(digits.splice(-pattern.gSize, digits.length).join(''));
1619
+ }
1620
+ if (digits.length) {
1621
+ groups.unshift(digits.join(''));
1622
+ }
1623
+ formattedText = groups.join(getLocaleNumberSymbol(locale, groupSymbol));
1624
+ // append the decimal digits
1625
+ if (decimals.length) {
1626
+ formattedText += getLocaleNumberSymbol(locale, decimalSymbol) + decimals.join('');
1627
+ }
1628
+ if (exponent) {
1629
+ formattedText += getLocaleNumberSymbol(locale, NumberSymbol.Exponential) + '+' + exponent;
1630
+ }
1631
+ }
1632
+ if (value < 0 && !isZero) {
1633
+ formattedText = pattern.negPre + formattedText + pattern.negSuf;
1634
+ }
1635
+ else {
1636
+ formattedText = pattern.posPre + formattedText + pattern.posSuf;
1637
+ }
1638
+ return formattedText;
1639
+ }
1640
+ /**
1641
+ * @ngModule CommonModule
1642
+ * @description
1643
+ *
1644
+ * Formats a number as currency using locale rules.
1645
+ *
1646
+ * @param value The number to format.
1647
+ * @param locale A locale code for the locale format rules to use.
1648
+ * @param currency A string containing the currency symbol or its name,
1649
+ * such as "$" or "Canadian Dollar". Used in output string, but does not affect the operation
1650
+ * of the function.
1651
+ * @param currencyCode The [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217)
1652
+ * currency code, such as `USD` for the US dollar and `EUR` for the euro.
1653
+ * Used to determine the number of digits in the decimal part.
1654
+ * @param digitsInfo Decimal representation options, specified by a string in the following format:
1655
+ * `{minIntegerDigits}.{minFractionDigits}-{maxFractionDigits}`. See `DecimalPipe` for more details.
1656
+ *
1657
+ * @returns The formatted currency value.
1658
+ *
1659
+ * @see {@link formatNumber}
1660
+ * @see {@link DecimalPipe}
1661
+ * @see [Internationalization (i18n) Guide](guide/i18n)
1662
+ *
1663
+ * @publicApi
1664
+ */
1665
+ function formatCurrency(value, locale, currency, currencyCode, digitsInfo) {
1666
+ const format = getLocaleNumberFormat(locale, NumberFormatStyle.Currency);
1667
+ const pattern = parseNumberFormat(format, getLocaleNumberSymbol(locale, NumberSymbol.MinusSign));
1668
+ pattern.minFrac = getNumberOfCurrencyDigits(currencyCode);
1669
+ pattern.maxFrac = pattern.minFrac;
1670
+ const res = formatNumberToLocaleString(value, pattern, locale, NumberSymbol.CurrencyGroup, NumberSymbol.CurrencyDecimal, digitsInfo);
1671
+ return (res
1672
+ .replace(CURRENCY_CHAR, currency)
1673
+ // if we have 2 time the currency character, the second one is ignored
1674
+ .replace(CURRENCY_CHAR, '')
1675
+ // If there is a spacing between currency character and the value and
1676
+ // the currency character is suppressed by passing an empty string, the
1677
+ // spacing character would remain as part of the string. Then we
1678
+ // should remove it.
1679
+ .trim());
1680
+ }
1681
+ /**
1682
+ * @ngModule CommonModule
1683
+ * @description
1684
+ *
1685
+ * Formats a number as a percentage according to locale rules.
1686
+ *
1687
+ * @param value The number to format.
1688
+ * @param locale A locale code for the locale format rules to use.
1689
+ * @param digitsInfo Decimal representation options, specified by a string in the following format:
1690
+ * `{minIntegerDigits}.{minFractionDigits}-{maxFractionDigits}`. See `DecimalPipe` for more details.
1691
+ *
1692
+ * @returns The formatted percentage value.
1693
+ *
1694
+ * @see {@link formatNumber}
1695
+ * @see {@link DecimalPipe}
1696
+ * @see [Internationalization (i18n) Guide](guide/i18n)
1697
+ * @publicApi
1698
+ *
1699
+ */
1700
+ function formatPercent(value, locale, digitsInfo) {
1701
+ const format = getLocaleNumberFormat(locale, NumberFormatStyle.Percent);
1702
+ const pattern = parseNumberFormat(format, getLocaleNumberSymbol(locale, NumberSymbol.MinusSign));
1703
+ const res = formatNumberToLocaleString(value, pattern, locale, NumberSymbol.Group, NumberSymbol.Decimal, digitsInfo, true);
1704
+ return res.replace(new RegExp(PERCENT_CHAR, 'g'), getLocaleNumberSymbol(locale, NumberSymbol.PercentSign));
1705
+ }
1706
+ /**
1707
+ * @ngModule CommonModule
1708
+ * @description
1709
+ *
1710
+ * Formats a number as text, with group sizing, separator, and other
1711
+ * parameters based on the locale.
1712
+ *
1713
+ * @param value The number to format.
1714
+ * @param locale A locale code for the locale format rules to use.
1715
+ * @param digitsInfo Decimal representation options, specified by a string in the following format:
1716
+ * `{minIntegerDigits}.{minFractionDigits}-{maxFractionDigits}`. See `DecimalPipe` for more details.
1717
+ *
1718
+ * @returns The formatted text string.
1719
+ * @see [Internationalization (i18n) Guide](guide/i18n)
1720
+ *
1721
+ * @publicApi
1722
+ */
1723
+ function formatNumber(value, locale, digitsInfo) {
1724
+ const format = getLocaleNumberFormat(locale, NumberFormatStyle.Decimal);
1725
+ const pattern = parseNumberFormat(format, getLocaleNumberSymbol(locale, NumberSymbol.MinusSign));
1726
+ return formatNumberToLocaleString(value, pattern, locale, NumberSymbol.Group, NumberSymbol.Decimal, digitsInfo);
1727
+ }
1728
+ function parseNumberFormat(format, minusSign = '-') {
1729
+ const p = {
1730
+ minInt: 1,
1731
+ minFrac: 0,
1732
+ maxFrac: 0,
1733
+ posPre: '',
1734
+ posSuf: '',
1735
+ negPre: '',
1736
+ negSuf: '',
1737
+ gSize: 0,
1738
+ lgSize: 0,
1739
+ };
1740
+ const patternParts = format.split(PATTERN_SEP);
1741
+ const positive = patternParts[0];
1742
+ const negative = patternParts[1];
1743
+ const positiveParts = positive.indexOf(DECIMAL_SEP) !== -1
1744
+ ? positive.split(DECIMAL_SEP)
1745
+ : [
1746
+ positive.substring(0, positive.lastIndexOf(ZERO_CHAR) + 1),
1747
+ positive.substring(positive.lastIndexOf(ZERO_CHAR) + 1),
1748
+ ], integer = positiveParts[0], fraction = positiveParts[1] || '';
1749
+ p.posPre = integer.substring(0, integer.indexOf(DIGIT_CHAR));
1750
+ for (let i = 0; i < fraction.length; i++) {
1751
+ const ch = fraction.charAt(i);
1752
+ if (ch === ZERO_CHAR) {
1753
+ p.minFrac = p.maxFrac = i + 1;
1754
+ }
1755
+ else if (ch === DIGIT_CHAR) {
1756
+ p.maxFrac = i + 1;
1757
+ }
1758
+ else {
1759
+ p.posSuf += ch;
1760
+ }
1761
+ }
1762
+ const groups = integer.split(GROUP_SEP);
1763
+ p.gSize = groups[1] ? groups[1].length : 0;
1764
+ p.lgSize = groups[2] || groups[1] ? (groups[2] || groups[1]).length : 0;
1765
+ if (negative) {
1766
+ const trunkLen = positive.length - p.posPre.length - p.posSuf.length, pos = negative.indexOf(DIGIT_CHAR);
1767
+ p.negPre = negative.substring(0, pos).replace(/'/g, '');
1768
+ p.negSuf = negative.slice(pos + trunkLen).replace(/'/g, '');
1769
+ }
1770
+ else {
1771
+ p.negPre = minusSign + p.posPre;
1772
+ p.negSuf = p.posSuf;
1773
+ }
1774
+ return p;
1775
+ }
1776
+ // Transforms a parsed number into a percentage by multiplying it by 100
1777
+ function toPercent(parsedNumber) {
1778
+ // if the number is 0, don't do anything
1779
+ if (parsedNumber.digits[0] === 0) {
1780
+ return parsedNumber;
1781
+ }
1782
+ // Getting the current number of decimals
1783
+ const fractionLen = parsedNumber.digits.length - parsedNumber.integerLen;
1784
+ if (parsedNumber.exponent) {
1785
+ parsedNumber.exponent += 2;
1786
+ }
1787
+ else {
1788
+ if (fractionLen === 0) {
1789
+ parsedNumber.digits.push(0, 0);
1790
+ }
1791
+ else if (fractionLen === 1) {
1792
+ parsedNumber.digits.push(0);
1793
+ }
1794
+ parsedNumber.integerLen += 2;
1795
+ }
1796
+ return parsedNumber;
1797
+ }
1798
+ /**
1799
+ * Parses a number.
1800
+ * Significant bits of this parse algorithm came from https://github.com/MikeMcl/big.js/
1801
+ */
1802
+ function parseNumber(num) {
1803
+ let numStr = Math.abs(num) + '';
1804
+ let exponent = 0, digits, integerLen;
1805
+ let i, j, zeros;
1806
+ // Decimal point?
1807
+ if ((integerLen = numStr.indexOf(DECIMAL_SEP)) > -1) {
1808
+ numStr = numStr.replace(DECIMAL_SEP, '');
1809
+ }
1810
+ // Exponential form?
1811
+ if ((i = numStr.search(/e/i)) > 0) {
1812
+ // Work out the exponent.
1813
+ if (integerLen < 0)
1814
+ integerLen = i;
1815
+ integerLen += +numStr.slice(i + 1);
1816
+ numStr = numStr.substring(0, i);
1817
+ }
1818
+ else if (integerLen < 0) {
1819
+ // There was no decimal point or exponent so it is an integer.
1820
+ integerLen = numStr.length;
1821
+ }
1822
+ // Count the number of leading zeros.
1823
+ for (i = 0; numStr.charAt(i) === ZERO_CHAR; i++) {
1824
+ /* empty */
1825
+ }
1826
+ if (i === (zeros = numStr.length)) {
1827
+ // The digits are all zero.
1828
+ digits = [0];
1829
+ integerLen = 1;
1830
+ }
1831
+ else {
1832
+ // Count the number of trailing zeros
1833
+ zeros--;
1834
+ while (numStr.charAt(zeros) === ZERO_CHAR)
1835
+ zeros--;
1836
+ // Trailing zeros are insignificant so ignore them
1837
+ integerLen -= i;
1838
+ digits = [];
1839
+ // Convert string to array of digits without leading/trailing zeros.
1840
+ for (j = 0; i <= zeros; i++, j++) {
1841
+ digits[j] = Number(numStr.charAt(i));
1842
+ }
1843
+ }
1844
+ // If the number overflows the maximum allowed digits then use an exponent.
1845
+ if (integerLen > MAX_DIGITS) {
1846
+ digits = digits.splice(0, MAX_DIGITS - 1);
1847
+ exponent = integerLen - 1;
1848
+ integerLen = 1;
1849
+ }
1850
+ return { digits, exponent, integerLen };
1851
+ }
1852
+ /**
1853
+ * Round the parsed number to the specified number of decimal places
1854
+ * This function changes the parsedNumber in-place
1855
+ */
1856
+ function roundNumber(parsedNumber, minFrac, maxFrac) {
1857
+ if (minFrac > maxFrac) {
1858
+ throw new Error(`The minimum number of digits after fraction (${minFrac}) is higher than the maximum (${maxFrac}).`);
1859
+ }
1860
+ let digits = parsedNumber.digits;
1861
+ let fractionLen = digits.length - parsedNumber.integerLen;
1862
+ const fractionSize = Math.min(Math.max(minFrac, fractionLen), maxFrac);
1863
+ // The index of the digit to where rounding is to occur
1864
+ let roundAt = fractionSize + parsedNumber.integerLen;
1865
+ let digit = digits[roundAt];
1866
+ if (roundAt > 0) {
1867
+ // Drop fractional digits beyond `roundAt`
1868
+ digits.splice(Math.max(parsedNumber.integerLen, roundAt));
1869
+ // Set non-fractional digits beyond `roundAt` to 0
1870
+ for (let j = roundAt; j < digits.length; j++) {
1871
+ digits[j] = 0;
1872
+ }
1873
+ }
1874
+ else {
1875
+ // We rounded to zero so reset the parsedNumber
1876
+ fractionLen = Math.max(0, fractionLen);
1877
+ parsedNumber.integerLen = 1;
1878
+ digits.length = Math.max(1, (roundAt = fractionSize + 1));
1879
+ digits[0] = 0;
1880
+ for (let i = 1; i < roundAt; i++)
1881
+ digits[i] = 0;
1882
+ }
1883
+ if (digit >= 5) {
1884
+ if (roundAt - 1 < 0) {
1885
+ for (let k = 0; k > roundAt; k--) {
1886
+ digits.unshift(0);
1887
+ parsedNumber.integerLen++;
1888
+ }
1889
+ digits.unshift(1);
1890
+ parsedNumber.integerLen++;
1891
+ }
1892
+ else {
1893
+ digits[roundAt - 1]++;
1894
+ }
1895
+ }
1896
+ // Pad out with zeros to get the required fraction length
1897
+ for (; fractionLen < Math.max(0, fractionSize); fractionLen++)
1898
+ digits.push(0);
1899
+ let dropTrailingZeros = fractionSize !== 0;
1900
+ // Minimal length = nb of decimals required + current nb of integers
1901
+ // Any number besides that is optional and can be removed if it's a trailing 0
1902
+ const minLen = minFrac + parsedNumber.integerLen;
1903
+ // Do any carrying, e.g. a digit was rounded up to 10
1904
+ const carry = digits.reduceRight(function (carry, d, i, digits) {
1905
+ d = d + carry;
1906
+ digits[i] = d < 10 ? d : d - 10; // d % 10
1907
+ if (dropTrailingZeros) {
1908
+ // Do not keep meaningless fractional trailing zeros (e.g. 15.52000 --> 15.52)
1909
+ if (digits[i] === 0 && i >= minLen) {
1910
+ digits.pop();
1911
+ }
1912
+ else {
1913
+ dropTrailingZeros = false;
1914
+ }
1915
+ }
1916
+ return d >= 10 ? 1 : 0; // Math.floor(d / 10);
1917
+ }, 0);
1918
+ if (carry) {
1919
+ digits.unshift(carry);
1920
+ parsedNumber.integerLen++;
1921
+ }
1922
+ }
1923
+ function parseIntAutoRadix(text) {
1924
+ const result = parseInt(text);
1925
+ if (isNaN(result)) {
1926
+ throw new Error('Invalid integer literal when parsing ' + text);
1927
+ }
1928
+ return result;
1929
+ }
1930
+
1931
+ /**
1932
+ * @publicApi
1933
+ */
1934
+ class NgLocalization {
1935
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: NgLocalization, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
1936
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: NgLocalization, providedIn: 'root', useFactory: (locale) => new NgLocaleLocalization(locale), deps: [{ token: LOCALE_ID }] });
1937
+ }
1938
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: NgLocalization, decorators: [{
1939
+ type: Injectable,
1940
+ args: [{
1941
+ providedIn: 'root',
1942
+ useFactory: (locale) => new NgLocaleLocalization(locale),
1943
+ deps: [LOCALE_ID],
1944
+ }]
1945
+ }] });
1946
+ /**
1947
+ * Returns the plural category for a given value.
1948
+ * - "=value" when the case exists,
1949
+ * - the plural category otherwise
1950
+ */
1951
+ function getPluralCategory(value, cases, ngLocalization, locale) {
1952
+ let key = `=${value}`;
1953
+ if (cases.indexOf(key) > -1) {
1954
+ return key;
1955
+ }
1956
+ key = ngLocalization.getPluralCategory(value, locale);
1957
+ if (cases.indexOf(key) > -1) {
1958
+ return key;
1959
+ }
1960
+ if (cases.indexOf('other') > -1) {
1961
+ return 'other';
1962
+ }
1963
+ throw new Error(`No plural message found for value "${value}"`);
1964
+ }
1965
+ /**
1966
+ * Returns the plural case based on the locale
1967
+ *
1968
+ * @publicApi
1969
+ */
1970
+ class NgLocaleLocalization extends NgLocalization {
1971
+ locale;
1972
+ constructor(locale) {
1973
+ super();
1974
+ this.locale = locale;
1975
+ }
1976
+ getPluralCategory(value, locale) {
1977
+ const plural = getLocalePluralCase(locale || this.locale)(value);
1978
+ switch (plural) {
1979
+ case Plural.Zero:
1980
+ return 'zero';
1981
+ case Plural.One:
1982
+ return 'one';
1983
+ case Plural.Two:
1984
+ return 'two';
1985
+ case Plural.Few:
1986
+ return 'few';
1987
+ case Plural.Many:
1988
+ return 'many';
1989
+ default:
1990
+ return 'other';
1991
+ }
1992
+ }
1993
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: NgLocaleLocalization, deps: [{ token: LOCALE_ID }], target: i0.ɵɵFactoryTarget.Injectable });
1994
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: NgLocaleLocalization });
1995
+ }
1996
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: NgLocaleLocalization, decorators: [{
1997
+ type: Injectable
1998
+ }], ctorParameters: () => [{ type: undefined, decorators: [{
1999
+ type: Inject,
2000
+ args: [LOCALE_ID]
2001
+ }] }] });
2002
+
2003
+ const WS_REGEXP = /\s+/;
2004
+ const EMPTY_ARRAY = [];
2005
+ /**
2006
+ * @ngModule CommonModule
2007
+ *
2008
+ * @usageNotes
2009
+ * ```html
2010
+ * <some-element [ngClass]="stringExp|arrayExp|objExp|Set">...</some-element>
2011
+ *
2012
+ * <some-element [ngClass]="{'class1 class2 class3' : true}">...</some-element>
2013
+ * ```
2014
+ *
2015
+ * For more simple use cases you can use the [class bindings](/guide/templates/binding#css-class-and-style-property-bindings) directly.
2016
+ * It doesn't require importing a directive.
2017
+ *
2018
+ * ```html
2019
+ * <some-element [class]="'first second'">...</some-element>
2020
+ *
2021
+ * <some-element [class.expanded]="isExpanded">...</some-element>
2022
+ *
2023
+ * <some-element [class]="['first', 'second']">...</some-element>
2024
+ *
2025
+ * <some-element [class]="{'first': true, 'second': true, 'third': false}">...</some-element>
2026
+ * ```
2027
+ * @description
2028
+ *
2029
+ * Adds and removes CSS classes on an HTML element.
2030
+ *
2031
+ * The CSS classes are updated as follows, depending on the type of the expression evaluation:
2032
+ * - `string` - the CSS classes listed in the string (space delimited) are added,
2033
+ * - `Array` - the CSS classes declared as Array elements are added,
2034
+ * - `Object` - keys are CSS classes that get added when the expression given in the value
2035
+ * evaluates to a truthy value, otherwise they are removed.
2036
+ *
2037
+ *
2038
+ * @see [Class bindings](/guide/templates/binding#css-class-and-style-property-bindings)
2039
+ *
2040
+ * @publicApi
2041
+ */
2042
+ class NgClass {
2043
+ _ngEl;
2044
+ _renderer;
2045
+ initialClasses = EMPTY_ARRAY;
2046
+ rawClass;
2047
+ stateMap = new Map();
2048
+ constructor(_ngEl, _renderer) {
2049
+ this._ngEl = _ngEl;
2050
+ this._renderer = _renderer;
2051
+ }
2052
+ set klass(value) {
2053
+ this.initialClasses = value != null ? value.trim().split(WS_REGEXP) : EMPTY_ARRAY;
2054
+ }
2055
+ set ngClass(value) {
2056
+ this.rawClass = typeof value === 'string' ? value.trim().split(WS_REGEXP) : value;
2057
+ }
2058
+ /*
2059
+ The NgClass directive uses the custom change detection algorithm for its inputs. The custom
2060
+ algorithm is necessary since inputs are represented as complex object or arrays that need to be
2061
+ deeply-compared.
2062
+
2063
+ This algorithm is perf-sensitive since NgClass is used very frequently and its poor performance
2064
+ might negatively impact runtime performance of the entire change detection cycle. The design of
2065
+ this algorithm is making sure that:
2066
+ - there is no unnecessary DOM manipulation (CSS classes are added / removed from the DOM only when
2067
+ needed), even if references to bound objects change;
2068
+ - there is no memory allocation if nothing changes (even relatively modest memory allocation
2069
+ during the change detection cycle can result in GC pauses for some of the CD cycles).
2070
+
2071
+ The algorithm works by iterating over the set of bound classes, staring with [class] binding and
2072
+ then going over [ngClass] binding. For each CSS class name:
2073
+ - check if it was seen before (this information is tracked in the state map) and if its value
2074
+ changed;
2075
+ - mark it as "touched" - names that are not marked are not present in the latest set of binding
2076
+ and we can remove such class name from the internal data structures;
2077
+
2078
+ After iteration over all the CSS class names we've got data structure with all the information
2079
+ necessary to synchronize changes to the DOM - it is enough to iterate over the state map, flush
2080
+ changes to the DOM and reset internal data structures so those are ready for the next change
2081
+ detection cycle.
2082
+ */
2083
+ ngDoCheck() {
2084
+ // classes from the [class] binding
2085
+ for (const klass of this.initialClasses) {
2086
+ this._updateState(klass, true);
2087
+ }
2088
+ // classes from the [ngClass] binding
2089
+ const rawClass = this.rawClass;
2090
+ if (Array.isArray(rawClass) || rawClass instanceof Set) {
2091
+ for (const klass of rawClass) {
2092
+ this._updateState(klass, true);
2093
+ }
2094
+ }
2095
+ else if (rawClass != null) {
2096
+ for (const klass of Object.keys(rawClass)) {
2097
+ this._updateState(klass, Boolean(rawClass[klass]));
2098
+ }
2099
+ }
2100
+ this._applyStateDiff();
2101
+ }
2102
+ _updateState(klass, nextEnabled) {
2103
+ const state = this.stateMap.get(klass);
2104
+ if (state !== undefined) {
2105
+ if (state.enabled !== nextEnabled) {
2106
+ state.changed = true;
2107
+ state.enabled = nextEnabled;
2108
+ }
2109
+ state.touched = true;
2110
+ }
2111
+ else {
2112
+ this.stateMap.set(klass, { enabled: nextEnabled, changed: true, touched: true });
2113
+ }
2114
+ }
2115
+ _applyStateDiff() {
2116
+ for (const stateEntry of this.stateMap) {
2117
+ const klass = stateEntry[0];
2118
+ const state = stateEntry[1];
2119
+ if (state.changed) {
2120
+ this._toggleClass(klass, state.enabled);
2121
+ state.changed = false;
2122
+ }
2123
+ else if (!state.touched) {
2124
+ // A class that was previously active got removed from the new collection of classes -
2125
+ // remove from the DOM as well.
2126
+ if (state.enabled) {
2127
+ this._toggleClass(klass, false);
2128
+ }
2129
+ this.stateMap.delete(klass);
2130
+ }
2131
+ state.touched = false;
2132
+ }
2133
+ }
2134
+ _toggleClass(klass, enabled) {
2135
+ if (ngDevMode) {
2136
+ if (typeof klass !== 'string') {
2137
+ throw new Error(`NgClass can only toggle CSS classes expressed as strings, got ${_stringify(klass)}`);
2138
+ }
2139
+ }
2140
+ klass = klass.trim();
2141
+ if (klass.length > 0) {
2142
+ klass.split(WS_REGEXP).forEach((klass) => {
2143
+ if (enabled) {
2144
+ this._renderer.addClass(this._ngEl.nativeElement, klass);
2145
+ }
2146
+ else {
2147
+ this._renderer.removeClass(this._ngEl.nativeElement, klass);
2148
+ }
2149
+ });
2150
+ }
2151
+ }
2152
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: NgClass, deps: [{ token: i0.ElementRef }, { token: i0.Renderer2 }], target: i0.ɵɵFactoryTarget.Directive });
2153
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.2.6", type: NgClass, isStandalone: true, selector: "[ngClass]", inputs: { klass: ["class", "klass"], ngClass: "ngClass" }, ngImport: i0 });
2154
+ }
2155
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: NgClass, decorators: [{
2156
+ type: Directive,
2157
+ args: [{
2158
+ selector: '[ngClass]',
2159
+ }]
2160
+ }], ctorParameters: () => [{ type: i0.ElementRef }, { type: i0.Renderer2 }], propDecorators: { klass: [{
2161
+ type: Input,
2162
+ args: ['class']
2163
+ }], ngClass: [{
2164
+ type: Input,
2165
+ args: ['ngClass']
2166
+ }] } });
2167
+
2168
+ /**
2169
+ * Instantiates a {@link /api/core/Component Component} type and inserts its Host View into the current View.
2170
+ * `NgComponentOutlet` provides a declarative approach for dynamic component creation.
2171
+ *
2172
+ * `NgComponentOutlet` requires a component type, if a falsy value is set the view will clear and
2173
+ * any existing component will be destroyed.
2174
+ *
2175
+ * @usageNotes
2176
+ *
2177
+ * ### Fine tune control
2178
+ *
2179
+ * You can control the component creation process by using the following optional attributes:
2180
+ *
2181
+ * * `ngComponentOutletInputs`: Optional component inputs object, which will be bind to the
2182
+ * component.
2183
+ *
2184
+ * * `ngComponentOutletInjector`: Optional custom {@link Injector} that will be used as parent for
2185
+ * the Component. Defaults to the injector of the current view container.
2186
+ *
2187
+ * * `ngComponentOutletContent`: Optional list of projectable nodes to insert into the content
2188
+ * section of the component, if it exists.
2189
+ *
2190
+ * * `ngComponentOutletNgModule`: Optional NgModule class reference to allow loading another
2191
+ * module dynamically, then loading a component from that module.
2192
+ *
2193
+ * * `ngComponentOutletNgModuleFactory`: Deprecated config option that allows providing optional
2194
+ * NgModule factory to allow loading another module dynamically, then loading a component from that
2195
+ * module. Use `ngComponentOutletNgModule` instead.
2196
+ *
2197
+ * ### Syntax
2198
+ *
2199
+ * Simple
2200
+ * ```html
2201
+ * <ng-container *ngComponentOutlet="componentTypeExpression"></ng-container>
2202
+ * ```
2203
+ *
2204
+ * With inputs
2205
+ * ```html
2206
+ * <ng-container *ngComponentOutlet="componentTypeExpression;
2207
+ * inputs: inputsExpression;">
2208
+ * </ng-container>
2209
+ * ```
2210
+ *
2211
+ * Customized injector/content
2212
+ * ```html
2213
+ * <ng-container *ngComponentOutlet="componentTypeExpression;
2214
+ * injector: injectorExpression;
2215
+ * content: contentNodesExpression;">
2216
+ * </ng-container>
2217
+ * ```
2218
+ *
2219
+ * Customized NgModule reference
2220
+ * ```html
2221
+ * <ng-container *ngComponentOutlet="componentTypeExpression;
2222
+ * ngModule: ngModuleClass;">
2223
+ * </ng-container>
2224
+ * ```
2225
+ *
2226
+ * ### A simple example
2227
+ *
2228
+ * {@example common/ngComponentOutlet/ts/module.ts region='SimpleExample'}
2229
+ *
2230
+ * A more complete example with additional options:
2231
+ *
2232
+ * {@example common/ngComponentOutlet/ts/module.ts region='CompleteExample'}
2233
+ *
2234
+ * @publicApi
2235
+ * @ngModule CommonModule
2236
+ */
2237
+ class NgComponentOutlet {
2238
+ _viewContainerRef;
2239
+ // TODO(crisbeto): this should be `Type<T>`, but doing so broke a few
2240
+ // targets in a TGP so we need to do it in a major version.
2241
+ /** Component that should be rendered in the outlet. */
2242
+ ngComponentOutlet = null;
2243
+ ngComponentOutletInputs;
2244
+ ngComponentOutletInjector;
2245
+ ngComponentOutletContent;
2246
+ ngComponentOutletNgModule;
2247
+ /**
2248
+ * @deprecated This input is deprecated, use `ngComponentOutletNgModule` instead.
2249
+ */
2250
+ ngComponentOutletNgModuleFactory;
2251
+ _componentRef;
2252
+ _moduleRef;
2253
+ /**
2254
+ * A helper data structure that allows us to track inputs that were part of the
2255
+ * ngComponentOutletInputs expression. Tracking inputs is necessary for proper removal of ones
2256
+ * that are no longer referenced.
2257
+ */
2258
+ _inputsUsed = new Map();
2259
+ /**
2260
+ * Gets the instance of the currently-rendered component.
2261
+ * Will be null if no component has been rendered.
2262
+ */
2263
+ get componentInstance() {
2264
+ return this._componentRef?.instance ?? null;
2265
+ }
2266
+ constructor(_viewContainerRef) {
2267
+ this._viewContainerRef = _viewContainerRef;
2268
+ }
2269
+ _needToReCreateNgModuleInstance(changes) {
2270
+ // Note: square brackets property accessor is safe for Closure compiler optimizations (the
2271
+ // `changes` argument of the `ngOnChanges` lifecycle hook retains the names of the fields that
2272
+ // were changed).
2273
+ return (changes['ngComponentOutletNgModule'] !== undefined ||
2274
+ changes['ngComponentOutletNgModuleFactory'] !== undefined);
2275
+ }
2276
+ _needToReCreateComponentInstance(changes) {
2277
+ // Note: square brackets property accessor is safe for Closure compiler optimizations (the
2278
+ // `changes` argument of the `ngOnChanges` lifecycle hook retains the names of the fields that
2279
+ // were changed).
2280
+ return (changes['ngComponentOutlet'] !== undefined ||
2281
+ changes['ngComponentOutletContent'] !== undefined ||
2282
+ changes['ngComponentOutletInjector'] !== undefined ||
2283
+ this._needToReCreateNgModuleInstance(changes));
2284
+ }
2285
+ /** @nodoc */
2286
+ ngOnChanges(changes) {
2287
+ if (this._needToReCreateComponentInstance(changes)) {
2288
+ this._viewContainerRef.clear();
2289
+ this._inputsUsed.clear();
2290
+ this._componentRef = undefined;
2291
+ if (this.ngComponentOutlet) {
2292
+ const injector = this.ngComponentOutletInjector || this._viewContainerRef.parentInjector;
2293
+ if (this._needToReCreateNgModuleInstance(changes)) {
2294
+ this._moduleRef?.destroy();
2295
+ if (this.ngComponentOutletNgModule) {
2296
+ this._moduleRef = createNgModule(this.ngComponentOutletNgModule, getParentInjector(injector));
2297
+ }
2298
+ else if (this.ngComponentOutletNgModuleFactory) {
2299
+ this._moduleRef = this.ngComponentOutletNgModuleFactory.create(getParentInjector(injector));
2300
+ }
2301
+ else {
2302
+ this._moduleRef = undefined;
2303
+ }
2304
+ }
2305
+ this._componentRef = this._viewContainerRef.createComponent(this.ngComponentOutlet, {
2306
+ injector,
2307
+ ngModuleRef: this._moduleRef,
2308
+ projectableNodes: this.ngComponentOutletContent,
2309
+ });
2310
+ }
2311
+ }
2312
+ }
2313
+ /** @nodoc */
2314
+ ngDoCheck() {
2315
+ if (this._componentRef) {
2316
+ if (this.ngComponentOutletInputs) {
2317
+ for (const inputName of Object.keys(this.ngComponentOutletInputs)) {
2318
+ this._inputsUsed.set(inputName, true);
2319
+ }
2320
+ }
2321
+ this._applyInputStateDiff(this._componentRef);
2322
+ }
2323
+ }
2324
+ /** @nodoc */
2325
+ ngOnDestroy() {
2326
+ this._moduleRef?.destroy();
2327
+ }
2328
+ _applyInputStateDiff(componentRef) {
2329
+ for (const [inputName, touched] of this._inputsUsed) {
2330
+ if (!touched) {
2331
+ // The input that was previously active no longer exists and needs to be set to undefined.
2332
+ componentRef.setInput(inputName, undefined);
2333
+ this._inputsUsed.delete(inputName);
2334
+ }
2335
+ else {
2336
+ // Since touched is true, it can be asserted that the inputs object is not empty.
2337
+ componentRef.setInput(inputName, this.ngComponentOutletInputs[inputName]);
2338
+ this._inputsUsed.set(inputName, false);
2339
+ }
2340
+ }
2341
+ }
2342
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: NgComponentOutlet, deps: [{ token: i0.ViewContainerRef }], target: i0.ɵɵFactoryTarget.Directive });
2343
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.2.6", type: NgComponentOutlet, isStandalone: true, selector: "[ngComponentOutlet]", inputs: { ngComponentOutlet: "ngComponentOutlet", ngComponentOutletInputs: "ngComponentOutletInputs", ngComponentOutletInjector: "ngComponentOutletInjector", ngComponentOutletContent: "ngComponentOutletContent", ngComponentOutletNgModule: "ngComponentOutletNgModule", ngComponentOutletNgModuleFactory: "ngComponentOutletNgModuleFactory" }, exportAs: ["ngComponentOutlet"], usesOnChanges: true, ngImport: i0 });
2344
+ }
2345
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: NgComponentOutlet, decorators: [{
2346
+ type: Directive,
2347
+ args: [{
2348
+ selector: '[ngComponentOutlet]',
2349
+ exportAs: 'ngComponentOutlet',
2350
+ }]
2351
+ }], ctorParameters: () => [{ type: i0.ViewContainerRef }], propDecorators: { ngComponentOutlet: [{
2352
+ type: Input
2353
+ }], ngComponentOutletInputs: [{
2354
+ type: Input
2355
+ }], ngComponentOutletInjector: [{
2356
+ type: Input
2357
+ }], ngComponentOutletContent: [{
2358
+ type: Input
2359
+ }], ngComponentOutletNgModule: [{
2360
+ type: Input
2361
+ }], ngComponentOutletNgModuleFactory: [{
2362
+ type: Input
2363
+ }] } });
2364
+ // Helper function that returns an Injector instance of a parent NgModule.
2365
+ function getParentInjector(injector) {
2366
+ const parentNgModule = injector.get(NgModuleRef);
2367
+ return parentNgModule.injector;
2368
+ }
2369
+
2370
+ /**
2371
+ * @publicApi
2372
+ */
2373
+ class NgForOfContext {
2374
+ $implicit;
2375
+ ngForOf;
2376
+ index;
2377
+ count;
2378
+ constructor(
2379
+ /** Reference to the current item from the collection. */
2380
+ $implicit,
2381
+ /**
2382
+ * The value of the iterable expression. Useful when the expression is
2383
+ * more complex then a property access, for example when using the async pipe
2384
+ * (`userStreams | async`).
2385
+ */
2386
+ ngForOf,
2387
+ /** Returns an index of the current item in the collection. */
2388
+ index,
2389
+ /** Returns total amount of items in the collection. */
2390
+ count) {
2391
+ this.$implicit = $implicit;
2392
+ this.ngForOf = ngForOf;
2393
+ this.index = index;
2394
+ this.count = count;
2395
+ }
2396
+ // Indicates whether this is the first item in the collection.
2397
+ get first() {
2398
+ return this.index === 0;
2399
+ }
2400
+ // Indicates whether this is the last item in the collection.
2401
+ get last() {
2402
+ return this.index === this.count - 1;
2403
+ }
2404
+ // Indicates whether an index of this item in the collection is even.
2405
+ get even() {
2406
+ return this.index % 2 === 0;
2407
+ }
2408
+ // Indicates whether an index of this item in the collection is odd.
2409
+ get odd() {
2410
+ return !this.even;
2411
+ }
2412
+ }
2413
+ /**
2414
+ * A [structural directive](guide/directives/structural-directives) that renders
2415
+ * a template for each item in a collection.
2416
+ * The directive is placed on an element, which becomes the parent
2417
+ * of the cloned templates.
2418
+ *
2419
+ * The `ngForOf` directive is generally used in the
2420
+ * [shorthand form](guide/directives/structural-directives#asterisk) `*ngFor`.
2421
+ * In this form, the template to be rendered for each iteration is the content
2422
+ * of an anchor element containing the directive.
2423
+ *
2424
+ * The following example shows the shorthand syntax with some options,
2425
+ * contained in an `<li>` element.
2426
+ *
2427
+ * ```html
2428
+ * <li *ngFor="let item of items; index as i; trackBy: trackByFn">...</li>
2429
+ * ```
2430
+ *
2431
+ * The shorthand form expands into a long form that uses the `ngForOf` selector
2432
+ * on an `<ng-template>` element.
2433
+ * The content of the `<ng-template>` element is the `<li>` element that held the
2434
+ * short-form directive.
2435
+ *
2436
+ * Here is the expanded version of the short-form example.
2437
+ *
2438
+ * ```html
2439
+ * <ng-template ngFor let-item [ngForOf]="items" let-i="index" [ngForTrackBy]="trackByFn">
2440
+ * <li>...</li>
2441
+ * </ng-template>
2442
+ * ```
2443
+ *
2444
+ * Angular automatically expands the shorthand syntax as it compiles the template.
2445
+ * The context for each embedded view is logically merged to the current component
2446
+ * context according to its lexical position.
2447
+ *
2448
+ * When using the shorthand syntax, Angular allows only [one structural directive
2449
+ * on an element](guide/directives/structural-directives#one-per-element).
2450
+ * If you want to iterate conditionally, for example,
2451
+ * put the `*ngIf` on a container element that wraps the `*ngFor` element.
2452
+ * For further discussion, see
2453
+ * [Structural Directives](guide/directives/structural-directives#one-per-element).
2454
+ *
2455
+ * @usageNotes
2456
+ *
2457
+ * ### Local variables
2458
+ *
2459
+ * `NgForOf` provides exported values that can be aliased to local variables.
2460
+ * For example:
2461
+ *
2462
+ * ```html
2463
+ * <li *ngFor="let user of users; index as i; first as isFirst">
2464
+ * {{i}}/{{users.length}}. {{user}} <span *ngIf="isFirst">default</span>
2465
+ * </li>
2466
+ * ```
2467
+ *
2468
+ * The following exported values can be aliased to local variables:
2469
+ *
2470
+ * - `$implicit: T`: The value of the individual items in the iterable (`ngForOf`).
2471
+ * - `ngForOf: NgIterable<T>`: The value of the iterable expression. Useful when the expression is
2472
+ * more complex then a property access, for example when using the async pipe (`userStreams |
2473
+ * async`).
2474
+ * - `index: number`: The index of the current item in the iterable.
2475
+ * - `count: number`: The length of the iterable.
2476
+ * - `first: boolean`: True when the item is the first item in the iterable.
2477
+ * - `last: boolean`: True when the item is the last item in the iterable.
2478
+ * - `even: boolean`: True when the item has an even index in the iterable.
2479
+ * - `odd: boolean`: True when the item has an odd index in the iterable.
2480
+ *
2481
+ * ### Change propagation
2482
+ *
2483
+ * When the contents of the iterator changes, `NgForOf` makes the corresponding changes to the DOM:
2484
+ *
2485
+ * * When an item is added, a new instance of the template is added to the DOM.
2486
+ * * When an item is removed, its template instance is removed from the DOM.
2487
+ * * When items are reordered, their respective templates are reordered in the DOM.
2488
+ *
2489
+ * Angular uses object identity to track insertions and deletions within the iterator and reproduce
2490
+ * those changes in the DOM. This has important implications for animations and any stateful
2491
+ * controls that are present, such as `<input>` elements that accept user input. Inserted rows can
2492
+ * be animated in, deleted rows can be animated out, and unchanged rows retain any unsaved state
2493
+ * such as user input.
2494
+ * For more on animations, see [Transitions and Triggers](guide/animations/transition-and-triggers).
2495
+ *
2496
+ * The identities of elements in the iterator can change while the data does not.
2497
+ * This can happen, for example, if the iterator is produced from an RPC to the server, and that
2498
+ * RPC is re-run. Even if the data hasn't changed, the second response produces objects with
2499
+ * different identities, and Angular must tear down the entire DOM and rebuild it (as if all old
2500
+ * elements were deleted and all new elements inserted).
2501
+ *
2502
+ * To avoid this expensive operation, you can customize the default tracking algorithm.
2503
+ * by supplying the `trackBy` option to `NgForOf`.
2504
+ * `trackBy` takes a function that has two arguments: `index` and `item`.
2505
+ * If `trackBy` is given, Angular tracks changes by the return value of the function.
2506
+ *
2507
+ * @see [Structural Directives](guide/directives/structural-directives)
2508
+ * @ngModule CommonModule
2509
+ * @publicApi
2510
+ */
2511
+ class NgForOf {
2512
+ _viewContainer;
2513
+ _template;
2514
+ _differs;
2515
+ /**
2516
+ * The value of the iterable expression, which can be used as a
2517
+ * [template input variable](guide/directives/structural-directives#shorthand).
2518
+ */
2519
+ set ngForOf(ngForOf) {
2520
+ this._ngForOf = ngForOf;
2521
+ this._ngForOfDirty = true;
2522
+ }
2523
+ /**
2524
+ * Specifies a custom `TrackByFunction` to compute the identity of items in an iterable.
2525
+ *
2526
+ * If a custom `TrackByFunction` is not provided, `NgForOf` will use the item's [object
2527
+ * identity](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is)
2528
+ * as the key.
2529
+ *
2530
+ * `NgForOf` uses the computed key to associate items in an iterable with DOM elements
2531
+ * it produces for these items.
2532
+ *
2533
+ * A custom `TrackByFunction` is useful to provide good user experience in cases when items in an
2534
+ * iterable rendered using `NgForOf` have a natural identifier (for example, custom ID or a
2535
+ * primary key), and this iterable could be updated with new object instances that still
2536
+ * represent the same underlying entity (for example, when data is re-fetched from the server,
2537
+ * and the iterable is recreated and re-rendered, but most of the data is still the same).
2538
+ *
2539
+ * @see {@link TrackByFunction}
2540
+ */
2541
+ set ngForTrackBy(fn) {
2542
+ if ((typeof ngDevMode === 'undefined' || ngDevMode) && fn != null && typeof fn !== 'function') {
2543
+ console.warn(`trackBy must be a function, but received ${JSON.stringify(fn)}. ` +
2544
+ `See https://angular.io/api/common/NgForOf#change-propagation for more information.`);
2545
+ }
2546
+ this._trackByFn = fn;
2547
+ }
2548
+ get ngForTrackBy() {
2549
+ return this._trackByFn;
2550
+ }
2551
+ _ngForOf = null;
2552
+ _ngForOfDirty = true;
2553
+ _differ = null;
2554
+ // waiting for microsoft/typescript#43662 to allow the return type `TrackByFunction|undefined` for
2555
+ // the getter
2556
+ _trackByFn;
2557
+ constructor(_viewContainer, _template, _differs) {
2558
+ this._viewContainer = _viewContainer;
2559
+ this._template = _template;
2560
+ this._differs = _differs;
2561
+ }
2562
+ /**
2563
+ * A reference to the template that is stamped out for each item in the iterable.
2564
+ * @see [template reference variable](guide/templates/variables#template-reference-variables)
2565
+ */
2566
+ set ngForTemplate(value) {
2567
+ // TODO(TS2.1): make TemplateRef<Partial<NgForRowOf<T>>> once we move to TS v2.1
2568
+ // The current type is too restrictive; a template that just uses index, for example,
2569
+ // should be acceptable.
2570
+ if (value) {
2571
+ this._template = value;
2572
+ }
2573
+ }
2574
+ /**
2575
+ * Applies the changes when needed.
2576
+ * @nodoc
2577
+ */
2578
+ ngDoCheck() {
2579
+ if (this._ngForOfDirty) {
2580
+ this._ngForOfDirty = false;
2581
+ // React on ngForOf changes only once all inputs have been initialized
2582
+ const value = this._ngForOf;
2583
+ if (!this._differ && value) {
2584
+ if (typeof ngDevMode === 'undefined' || ngDevMode) {
2585
+ try {
2586
+ // CAUTION: this logic is duplicated for production mode below, as the try-catch
2587
+ // is only present in development builds.
2588
+ this._differ = this._differs.find(value).create(this.ngForTrackBy);
2589
+ }
2590
+ catch {
2591
+ let errorMessage = `Cannot find a differ supporting object '${value}' of type '` +
2592
+ `${getTypeName(value)}'. NgFor only supports binding to Iterables, such as Arrays.`;
2593
+ if (typeof value === 'object') {
2594
+ errorMessage += ' Did you mean to use the keyvalue pipe?';
2595
+ }
2596
+ throw new _RuntimeError(-2200 /* RuntimeErrorCode.NG_FOR_MISSING_DIFFER */, errorMessage);
2597
+ }
2598
+ }
2599
+ else {
2600
+ // CAUTION: this logic is duplicated for development mode above, as the try-catch
2601
+ // is only present in development builds.
2602
+ this._differ = this._differs.find(value).create(this.ngForTrackBy);
2603
+ }
2604
+ }
2605
+ }
2606
+ if (this._differ) {
2607
+ const changes = this._differ.diff(this._ngForOf);
2608
+ if (changes)
2609
+ this._applyChanges(changes);
2610
+ }
2611
+ }
2612
+ _applyChanges(changes) {
2613
+ const viewContainer = this._viewContainer;
2614
+ changes.forEachOperation((item, adjustedPreviousIndex, currentIndex) => {
2615
+ if (item.previousIndex == null) {
2616
+ // NgForOf is never "null" or "undefined" here because the differ detected
2617
+ // that a new item needs to be inserted from the iterable. This implies that
2618
+ // there is an iterable value for "_ngForOf".
2619
+ viewContainer.createEmbeddedView(this._template, new NgForOfContext(item.item, this._ngForOf, -1, -1), currentIndex === null ? undefined : currentIndex);
2620
+ }
2621
+ else if (currentIndex == null) {
2622
+ viewContainer.remove(adjustedPreviousIndex === null ? undefined : adjustedPreviousIndex);
2623
+ }
2624
+ else if (adjustedPreviousIndex !== null) {
2625
+ const view = viewContainer.get(adjustedPreviousIndex);
2626
+ viewContainer.move(view, currentIndex);
2627
+ applyViewChange(view, item);
2628
+ }
2629
+ });
2630
+ for (let i = 0, ilen = viewContainer.length; i < ilen; i++) {
2631
+ const viewRef = viewContainer.get(i);
2632
+ const context = viewRef.context;
2633
+ context.index = i;
2634
+ context.count = ilen;
2635
+ context.ngForOf = this._ngForOf;
2636
+ }
2637
+ changes.forEachIdentityChange((record) => {
2638
+ const viewRef = viewContainer.get(record.currentIndex);
2639
+ applyViewChange(viewRef, record);
2640
+ });
2641
+ }
2642
+ /**
2643
+ * Asserts the correct type of the context for the template that `NgForOf` will render.
2644
+ *
2645
+ * The presence of this method is a signal to the Ivy template type-check compiler that the
2646
+ * `NgForOf` structural directive renders its template with a specific context type.
2647
+ */
2648
+ static ngTemplateContextGuard(dir, ctx) {
2649
+ return true;
2650
+ }
2651
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: NgForOf, deps: [{ token: i0.ViewContainerRef }, { token: i0.TemplateRef }, { token: i0.IterableDiffers }], target: i0.ɵɵFactoryTarget.Directive });
2652
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.2.6", type: NgForOf, isStandalone: true, selector: "[ngFor][ngForOf]", inputs: { ngForOf: "ngForOf", ngForTrackBy: "ngForTrackBy", ngForTemplate: "ngForTemplate" }, ngImport: i0 });
2653
+ }
2654
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: NgForOf, decorators: [{
2655
+ type: Directive,
2656
+ args: [{
2657
+ selector: '[ngFor][ngForOf]',
2658
+ }]
2659
+ }], ctorParameters: () => [{ type: i0.ViewContainerRef }, { type: i0.TemplateRef }, { type: i0.IterableDiffers }], propDecorators: { ngForOf: [{
2660
+ type: Input
2661
+ }], ngForTrackBy: [{
2662
+ type: Input
2663
+ }], ngForTemplate: [{
2664
+ type: Input
2665
+ }] } });
2666
+ function applyViewChange(view, record) {
2667
+ view.context.$implicit = record.item;
2668
+ }
2669
+ function getTypeName(type) {
2670
+ return type['name'] || typeof type;
2671
+ }
2672
+
2673
+ /**
2674
+ * A structural directive that conditionally includes a template based on the value of
2675
+ * an expression coerced to Boolean.
2676
+ * When the expression evaluates to true, Angular renders the template
2677
+ * provided in a `then` clause, and when false or null,
2678
+ * Angular renders the template provided in an optional `else` clause. The default
2679
+ * template for the `else` clause is blank.
2680
+ *
2681
+ * A [shorthand form](guide/directives/structural-directives#asterisk) of the directive,
2682
+ * `*ngIf="condition"`, is generally used, provided
2683
+ * as an attribute of the anchor element for the inserted template.
2684
+ * Angular expands this into a more explicit version, in which the anchor element
2685
+ * is contained in an `<ng-template>` element.
2686
+ *
2687
+ * Simple form with shorthand syntax:
2688
+ *
2689
+ * ```html
2690
+ * <div *ngIf="condition">Content to render when condition is true.</div>
2691
+ * ```
2692
+ *
2693
+ * Simple form with expanded syntax:
2694
+ *
2695
+ * ```html
2696
+ * <ng-template [ngIf]="condition"><div>Content to render when condition is
2697
+ * true.</div></ng-template>
2698
+ * ```
2699
+ *
2700
+ * Form with an "else" block:
2701
+ *
2702
+ * ```html
2703
+ * <div *ngIf="condition; else elseBlock">Content to render when condition is true.</div>
2704
+ * <ng-template #elseBlock>Content to render when condition is false.</ng-template>
2705
+ * ```
2706
+ *
2707
+ * Shorthand form with "then" and "else" blocks:
2708
+ *
2709
+ * ```html
2710
+ * <div *ngIf="condition; then thenBlock else elseBlock"></div>
2711
+ * <ng-template #thenBlock>Content to render when condition is true.</ng-template>
2712
+ * <ng-template #elseBlock>Content to render when condition is false.</ng-template>
2713
+ * ```
2714
+ *
2715
+ * Form with storing the value locally:
2716
+ *
2717
+ * ```html
2718
+ * <div *ngIf="condition as value; else elseBlock">{{value}}</div>
2719
+ * <ng-template #elseBlock>Content to render when value is null.</ng-template>
2720
+ * ```
2721
+ *
2722
+ * @usageNotes
2723
+ *
2724
+ * The `*ngIf` directive is most commonly used to conditionally show an inline template,
2725
+ * as seen in the following example.
2726
+ * The default `else` template is blank.
2727
+ *
2728
+ * {@example common/ngIf/ts/module.ts region='NgIfSimple'}
2729
+ *
2730
+ * ### Showing an alternative template using `else`
2731
+ *
2732
+ * To display a template when `expression` evaluates to false, use an `else` template
2733
+ * binding as shown in the following example.
2734
+ * The `else` binding points to an `<ng-template>` element labeled `#elseBlock`.
2735
+ * The template can be defined anywhere in the component view, but is typically placed right after
2736
+ * `ngIf` for readability.
2737
+ *
2738
+ * {@example common/ngIf/ts/module.ts region='NgIfElse'}
2739
+ *
2740
+ * ### Using an external `then` template
2741
+ *
2742
+ * In the previous example, the then-clause template is specified inline, as the content of the
2743
+ * tag that contains the `ngIf` directive. You can also specify a template that is defined
2744
+ * externally, by referencing a labeled `<ng-template>` element. When you do this, you can
2745
+ * change which template to use at runtime, as shown in the following example.
2746
+ *
2747
+ * {@example common/ngIf/ts/module.ts region='NgIfThenElse'}
2748
+ *
2749
+ * ### Storing a conditional result in a variable
2750
+ *
2751
+ * You might want to show a set of properties from the same object. If you are waiting
2752
+ * for asynchronous data, the object can be undefined.
2753
+ * In this case, you can use `ngIf` and store the result of the condition in a local
2754
+ * variable as shown in the following example.
2755
+ *
2756
+ * {@example common/ngIf/ts/module.ts region='NgIfAs'}
2757
+ *
2758
+ * This code uses only one `AsyncPipe`, so only one subscription is created.
2759
+ * The conditional statement stores the result of `userStream|async` in the local variable `user`.
2760
+ * You can then bind the local `user` repeatedly.
2761
+ *
2762
+ * The conditional displays the data only if `userStream` returns a value,
2763
+ * so you don't need to use the
2764
+ * safe-navigation-operator (`?.`)
2765
+ * to guard against null values when accessing properties.
2766
+ * You can display an alternative template while waiting for the data.
2767
+ *
2768
+ * ### Shorthand syntax
2769
+ *
2770
+ * The shorthand syntax `*ngIf` expands into two separate template specifications
2771
+ * for the "then" and "else" clauses. For example, consider the following shorthand statement,
2772
+ * that is meant to show a loading page while waiting for data to be loaded.
2773
+ *
2774
+ * ```html
2775
+ * <div class="hero-list" *ngIf="heroes else loading">
2776
+ * ...
2777
+ * </div>
2778
+ *
2779
+ * <ng-template #loading>
2780
+ * <div>Loading...</div>
2781
+ * </ng-template>
2782
+ * ```
2783
+ *
2784
+ * You can see that the "else" clause references the `<ng-template>`
2785
+ * with the `#loading` label, and the template for the "then" clause
2786
+ * is provided as the content of the anchor element.
2787
+ *
2788
+ * However, when Angular expands the shorthand syntax, it creates
2789
+ * another `<ng-template>` tag, with `ngIf` and `ngIfElse` directives.
2790
+ * The anchor element containing the template for the "then" clause becomes
2791
+ * the content of this unlabeled `<ng-template>` tag.
2792
+ *
2793
+ * ```html
2794
+ * <ng-template [ngIf]="heroes" [ngIfElse]="loading">
2795
+ * <div class="hero-list">
2796
+ * ...
2797
+ * </div>
2798
+ * </ng-template>
2799
+ *
2800
+ * <ng-template #loading>
2801
+ * <div>Loading...</div>
2802
+ * </ng-template>
2803
+ * ```
2804
+ *
2805
+ * The presence of the implicit template object has implications for the nesting of
2806
+ * structural directives. For more on this subject, see
2807
+ * [Structural Directives](guide/directives/structural-directives#one-per-element).
2808
+ *
2809
+ * @ngModule CommonModule
2810
+ * @publicApi
2811
+ */
2812
+ class NgIf {
2813
+ _viewContainer;
2814
+ _context = new NgIfContext();
2815
+ _thenTemplateRef = null;
2816
+ _elseTemplateRef = null;
2817
+ _thenViewRef = null;
2818
+ _elseViewRef = null;
2819
+ constructor(_viewContainer, templateRef) {
2820
+ this._viewContainer = _viewContainer;
2821
+ this._thenTemplateRef = templateRef;
2822
+ }
2823
+ /**
2824
+ * The Boolean expression to evaluate as the condition for showing a template.
2825
+ */
2826
+ set ngIf(condition) {
2827
+ this._context.$implicit = this._context.ngIf = condition;
2828
+ this._updateView();
2829
+ }
2830
+ /**
2831
+ * A template to show if the condition expression evaluates to true.
2832
+ */
2833
+ set ngIfThen(templateRef) {
2834
+ assertTemplate(templateRef, (typeof ngDevMode === 'undefined' || ngDevMode) && 'ngIfThen');
2835
+ this._thenTemplateRef = templateRef;
2836
+ this._thenViewRef = null; // clear previous view if any.
2837
+ this._updateView();
2838
+ }
2839
+ /**
2840
+ * A template to show if the condition expression evaluates to false.
2841
+ */
2842
+ set ngIfElse(templateRef) {
2843
+ assertTemplate(templateRef, (typeof ngDevMode === 'undefined' || ngDevMode) && 'ngIfElse');
2844
+ this._elseTemplateRef = templateRef;
2845
+ this._elseViewRef = null; // clear previous view if any.
2846
+ this._updateView();
2847
+ }
2848
+ _updateView() {
2849
+ if (this._context.$implicit) {
2850
+ if (!this._thenViewRef) {
2851
+ this._viewContainer.clear();
2852
+ this._elseViewRef = null;
2853
+ if (this._thenTemplateRef) {
2854
+ this._thenViewRef = this._viewContainer.createEmbeddedView(this._thenTemplateRef, this._context);
2855
+ }
2856
+ }
2857
+ }
2858
+ else {
2859
+ if (!this._elseViewRef) {
2860
+ this._viewContainer.clear();
2861
+ this._thenViewRef = null;
2862
+ if (this._elseTemplateRef) {
2863
+ this._elseViewRef = this._viewContainer.createEmbeddedView(this._elseTemplateRef, this._context);
2864
+ }
2865
+ }
2866
+ }
2867
+ }
2868
+ /** @internal */
2869
+ static ngIfUseIfTypeGuard;
2870
+ /**
2871
+ * Assert the correct type of the expression bound to the `ngIf` input within the template.
2872
+ *
2873
+ * The presence of this static field is a signal to the Ivy template type check compiler that
2874
+ * when the `NgIf` structural directive renders its template, the type of the expression bound
2875
+ * to `ngIf` should be narrowed in some way. For `NgIf`, the binding expression itself is used to
2876
+ * narrow its type, which allows the strictNullChecks feature of TypeScript to work with `NgIf`.
2877
+ */
2878
+ static ngTemplateGuard_ngIf;
2879
+ /**
2880
+ * Asserts the correct type of the context for the template that `NgIf` will render.
2881
+ *
2882
+ * The presence of this method is a signal to the Ivy template type-check compiler that the
2883
+ * `NgIf` structural directive renders its template with a specific context type.
2884
+ */
2885
+ static ngTemplateContextGuard(dir, ctx) {
2886
+ return true;
2887
+ }
2888
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: NgIf, deps: [{ token: i0.ViewContainerRef }, { token: i0.TemplateRef }], target: i0.ɵɵFactoryTarget.Directive });
2889
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.2.6", type: NgIf, isStandalone: true, selector: "[ngIf]", inputs: { ngIf: "ngIf", ngIfThen: "ngIfThen", ngIfElse: "ngIfElse" }, ngImport: i0 });
2890
+ }
2891
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: NgIf, decorators: [{
2892
+ type: Directive,
2893
+ args: [{
2894
+ selector: '[ngIf]',
2895
+ }]
2896
+ }], ctorParameters: () => [{ type: i0.ViewContainerRef }, { type: i0.TemplateRef }], propDecorators: { ngIf: [{
2897
+ type: Input
2898
+ }], ngIfThen: [{
2899
+ type: Input
2900
+ }], ngIfElse: [{
2901
+ type: Input
2902
+ }] } });
2903
+ /**
2904
+ * @publicApi
2905
+ */
2906
+ class NgIfContext {
2907
+ $implicit = null;
2908
+ ngIf = null;
2909
+ }
2910
+ function assertTemplate(templateRef, property) {
2911
+ if (templateRef && !templateRef.createEmbeddedView) {
2912
+ throw new _RuntimeError(2020 /* RuntimeErrorCode.NG_IF_NOT_A_TEMPLATE_REF */, (typeof ngDevMode === 'undefined' || ngDevMode) &&
2913
+ `${property} must be a TemplateRef, but received '${_stringify(templateRef)}'.`);
2914
+ }
2915
+ }
2916
+
2917
+ class SwitchView {
2918
+ _viewContainerRef;
2919
+ _templateRef;
2920
+ _created = false;
2921
+ constructor(_viewContainerRef, _templateRef) {
2922
+ this._viewContainerRef = _viewContainerRef;
2923
+ this._templateRef = _templateRef;
2924
+ }
2925
+ create() {
2926
+ this._created = true;
2927
+ this._viewContainerRef.createEmbeddedView(this._templateRef);
2928
+ }
2929
+ destroy() {
2930
+ this._created = false;
2931
+ this._viewContainerRef.clear();
2932
+ }
2933
+ enforceState(created) {
2934
+ if (created && !this._created) {
2935
+ this.create();
2936
+ }
2937
+ else if (!created && this._created) {
2938
+ this.destroy();
2939
+ }
2940
+ }
2941
+ }
2942
+ /**
2943
+ * @ngModule CommonModule
2944
+ *
2945
+ * @description
2946
+ * The `[ngSwitch]` directive on a container specifies an expression to match against.
2947
+ * The expressions to match are provided by `ngSwitchCase` directives on views within the container.
2948
+ * - Every view that matches is rendered.
2949
+ * - If there are no matches, a view with the `ngSwitchDefault` directive is rendered.
2950
+ * - Elements within the `[NgSwitch]` statement but outside of any `NgSwitchCase`
2951
+ * or `ngSwitchDefault` directive are preserved at the location.
2952
+ *
2953
+ * @usageNotes
2954
+ * Define a container element for the directive, and specify the switch expression
2955
+ * to match against as an attribute:
2956
+ *
2957
+ * ```html
2958
+ * <container-element [ngSwitch]="switch_expression">
2959
+ * ```
2960
+ *
2961
+ * Within the container, `*ngSwitchCase` statements specify the match expressions
2962
+ * as attributes. Include `*ngSwitchDefault` as the final case.
2963
+ *
2964
+ * ```html
2965
+ * <container-element [ngSwitch]="switch_expression">
2966
+ * <some-element *ngSwitchCase="match_expression_1">...</some-element>
2967
+ * ...
2968
+ * <some-element *ngSwitchDefault>...</some-element>
2969
+ * </container-element>
2970
+ * ```
2971
+ *
2972
+ * ### Usage Examples
2973
+ *
2974
+ * The following example shows how to use more than one case to display the same view:
2975
+ *
2976
+ * ```html
2977
+ * <container-element [ngSwitch]="switch_expression">
2978
+ * <!-- the same view can be shown in more than one case -->
2979
+ * <some-element *ngSwitchCase="match_expression_1">...</some-element>
2980
+ * <some-element *ngSwitchCase="match_expression_2">...</some-element>
2981
+ * <some-other-element *ngSwitchCase="match_expression_3">...</some-other-element>
2982
+ * <!--default case when there are no matches -->
2983
+ * <some-element *ngSwitchDefault>...</some-element>
2984
+ * </container-element>
2985
+ * ```
2986
+ *
2987
+ * The following example shows how cases can be nested:
2988
+ * ```html
2989
+ * <container-element [ngSwitch]="switch_expression">
2990
+ * <some-element *ngSwitchCase="match_expression_1">...</some-element>
2991
+ * <some-element *ngSwitchCase="match_expression_2">...</some-element>
2992
+ * <some-other-element *ngSwitchCase="match_expression_3">...</some-other-element>
2993
+ * <ng-container *ngSwitchCase="match_expression_3">
2994
+ * <!-- use a ng-container to group multiple root nodes -->
2995
+ * <inner-element></inner-element>
2996
+ * <inner-other-element></inner-other-element>
2997
+ * </ng-container>
2998
+ * <some-element *ngSwitchDefault>...</some-element>
2999
+ * </container-element>
3000
+ * ```
3001
+ *
3002
+ * @publicApi
3003
+ * @see {@link NgSwitchCase}
3004
+ * @see {@link NgSwitchDefault}
3005
+ * @see [Structural Directives](guide/directives/structural-directives)
3006
+ *
3007
+ */
3008
+ class NgSwitch {
3009
+ _defaultViews = [];
3010
+ _defaultUsed = false;
3011
+ _caseCount = 0;
3012
+ _lastCaseCheckIndex = 0;
3013
+ _lastCasesMatched = false;
3014
+ _ngSwitch;
3015
+ set ngSwitch(newValue) {
3016
+ this._ngSwitch = newValue;
3017
+ if (this._caseCount === 0) {
3018
+ this._updateDefaultCases(true);
3019
+ }
3020
+ }
3021
+ /** @internal */
3022
+ _addCase() {
3023
+ return this._caseCount++;
3024
+ }
3025
+ /** @internal */
3026
+ _addDefault(view) {
3027
+ this._defaultViews.push(view);
3028
+ }
3029
+ /** @internal */
3030
+ _matchCase(value) {
3031
+ const matched = value === this._ngSwitch;
3032
+ this._lastCasesMatched ||= matched;
3033
+ this._lastCaseCheckIndex++;
3034
+ if (this._lastCaseCheckIndex === this._caseCount) {
3035
+ this._updateDefaultCases(!this._lastCasesMatched);
3036
+ this._lastCaseCheckIndex = 0;
3037
+ this._lastCasesMatched = false;
3038
+ }
3039
+ return matched;
3040
+ }
3041
+ _updateDefaultCases(useDefault) {
3042
+ if (this._defaultViews.length > 0 && useDefault !== this._defaultUsed) {
3043
+ this._defaultUsed = useDefault;
3044
+ for (const defaultView of this._defaultViews) {
3045
+ defaultView.enforceState(useDefault);
3046
+ }
3047
+ }
3048
+ }
3049
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: NgSwitch, deps: [], target: i0.ɵɵFactoryTarget.Directive });
3050
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.2.6", type: NgSwitch, isStandalone: true, selector: "[ngSwitch]", inputs: { ngSwitch: "ngSwitch" }, ngImport: i0 });
3051
+ }
3052
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: NgSwitch, decorators: [{
3053
+ type: Directive,
3054
+ args: [{
3055
+ selector: '[ngSwitch]',
3056
+ }]
3057
+ }], propDecorators: { ngSwitch: [{
3058
+ type: Input
3059
+ }] } });
3060
+ /**
3061
+ * @ngModule CommonModule
3062
+ *
3063
+ * @description
3064
+ * Provides a switch case expression to match against an enclosing `ngSwitch` expression.
3065
+ * When the expressions match, the given `NgSwitchCase` template is rendered.
3066
+ * If multiple match expressions match the switch expression value, all of them are displayed.
3067
+ *
3068
+ * @usageNotes
3069
+ *
3070
+ * Within a switch container, `*ngSwitchCase` statements specify the match expressions
3071
+ * as attributes. Include `*ngSwitchDefault` as the final case.
3072
+ *
3073
+ * ```html
3074
+ * <container-element [ngSwitch]="switch_expression">
3075
+ * <some-element *ngSwitchCase="match_expression_1">...</some-element>
3076
+ * ...
3077
+ * <some-element *ngSwitchDefault>...</some-element>
3078
+ * </container-element>
3079
+ * ```
3080
+ *
3081
+ * Each switch-case statement contains an in-line HTML template or template reference
3082
+ * that defines the subtree to be selected if the value of the match expression
3083
+ * matches the value of the switch expression.
3084
+ *
3085
+ * As of Angular v17 the NgSwitch directive uses strict equality comparison (`===`) instead of
3086
+ * loose equality (`==`) to match different cases.
3087
+ *
3088
+ * @publicApi
3089
+ * @see {@link NgSwitch}
3090
+ * @see {@link NgSwitchDefault}
3091
+ *
3092
+ */
3093
+ class NgSwitchCase {
3094
+ ngSwitch;
3095
+ _view;
3096
+ /**
3097
+ * Stores the HTML template to be selected on match.
3098
+ */
3099
+ ngSwitchCase;
3100
+ constructor(viewContainer, templateRef, ngSwitch) {
3101
+ this.ngSwitch = ngSwitch;
3102
+ if ((typeof ngDevMode === 'undefined' || ngDevMode) && !ngSwitch) {
3103
+ throwNgSwitchProviderNotFoundError('ngSwitchCase', 'NgSwitchCase');
3104
+ }
3105
+ ngSwitch._addCase();
3106
+ this._view = new SwitchView(viewContainer, templateRef);
3107
+ }
3108
+ /**
3109
+ * Performs case matching. For internal use only.
3110
+ * @nodoc
3111
+ */
3112
+ ngDoCheck() {
3113
+ this._view.enforceState(this.ngSwitch._matchCase(this.ngSwitchCase));
3114
+ }
3115
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: NgSwitchCase, deps: [{ token: i0.ViewContainerRef }, { token: i0.TemplateRef }, { token: NgSwitch, host: true, optional: true }], target: i0.ɵɵFactoryTarget.Directive });
3116
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.2.6", type: NgSwitchCase, isStandalone: true, selector: "[ngSwitchCase]", inputs: { ngSwitchCase: "ngSwitchCase" }, ngImport: i0 });
3117
+ }
3118
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: NgSwitchCase, decorators: [{
3119
+ type: Directive,
3120
+ args: [{
3121
+ selector: '[ngSwitchCase]',
3122
+ }]
3123
+ }], ctorParameters: () => [{ type: i0.ViewContainerRef }, { type: i0.TemplateRef }, { type: NgSwitch, decorators: [{
3124
+ type: Optional
3125
+ }, {
3126
+ type: Host
3127
+ }] }], propDecorators: { ngSwitchCase: [{
3128
+ type: Input
3129
+ }] } });
3130
+ /**
3131
+ * @ngModule CommonModule
3132
+ *
3133
+ * @description
3134
+ *
3135
+ * Creates a view that is rendered when no `NgSwitchCase` expressions
3136
+ * match the `NgSwitch` expression.
3137
+ * This statement should be the final case in an `NgSwitch`.
3138
+ *
3139
+ * @publicApi
3140
+ * @see {@link NgSwitch}
3141
+ * @see {@link NgSwitchCase}
3142
+ *
3143
+ */
3144
+ class NgSwitchDefault {
3145
+ constructor(viewContainer, templateRef, ngSwitch) {
3146
+ if ((typeof ngDevMode === 'undefined' || ngDevMode) && !ngSwitch) {
3147
+ throwNgSwitchProviderNotFoundError('ngSwitchDefault', 'NgSwitchDefault');
3148
+ }
3149
+ ngSwitch._addDefault(new SwitchView(viewContainer, templateRef));
3150
+ }
3151
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: NgSwitchDefault, deps: [{ token: i0.ViewContainerRef }, { token: i0.TemplateRef }, { token: NgSwitch, host: true, optional: true }], target: i0.ɵɵFactoryTarget.Directive });
3152
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.2.6", type: NgSwitchDefault, isStandalone: true, selector: "[ngSwitchDefault]", ngImport: i0 });
3153
+ }
3154
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: NgSwitchDefault, decorators: [{
3155
+ type: Directive,
3156
+ args: [{
3157
+ selector: '[ngSwitchDefault]',
3158
+ }]
3159
+ }], ctorParameters: () => [{ type: i0.ViewContainerRef }, { type: i0.TemplateRef }, { type: NgSwitch, decorators: [{
3160
+ type: Optional
3161
+ }, {
3162
+ type: Host
3163
+ }] }] });
3164
+ function throwNgSwitchProviderNotFoundError(attrName, directiveName) {
3165
+ throw new _RuntimeError(2000 /* RuntimeErrorCode.PARENT_NG_SWITCH_NOT_FOUND */, `An element with the "${attrName}" attribute ` +
3166
+ `(matching the "${directiveName}" directive) must be located inside an element with the "ngSwitch" attribute ` +
3167
+ `(matching "NgSwitch" directive)`);
3168
+ }
3169
+
3170
+ /**
3171
+ * @ngModule CommonModule
3172
+ *
3173
+ * @usageNotes
3174
+ * ```html
3175
+ * <some-element [ngPlural]="value">
3176
+ * <ng-template ngPluralCase="=0">there is nothing</ng-template>
3177
+ * <ng-template ngPluralCase="=1">there is one</ng-template>
3178
+ * <ng-template ngPluralCase="few">there are a few</ng-template>
3179
+ * </some-element>
3180
+ * ```
3181
+ *
3182
+ * @description
3183
+ *
3184
+ * Adds / removes DOM sub-trees based on a numeric value. Tailored for pluralization.
3185
+ *
3186
+ * Displays DOM sub-trees that match the switch expression value, or failing that, DOM sub-trees
3187
+ * that match the switch expression's pluralization category.
3188
+ *
3189
+ * To use this directive you must provide a container element that sets the `[ngPlural]` attribute
3190
+ * to a switch expression. Inner elements with a `[ngPluralCase]` will display based on their
3191
+ * expression:
3192
+ * - if `[ngPluralCase]` is set to a value starting with `=`, it will only display if the value
3193
+ * matches the switch expression exactly,
3194
+ * - otherwise, the view will be treated as a "category match", and will only display if exact
3195
+ * value matches aren't found and the value maps to its category for the defined locale.
3196
+ *
3197
+ * See http://cldr.unicode.org/index/cldr-spec/plural-rules
3198
+ *
3199
+ * @publicApi
3200
+ */
3201
+ class NgPlural {
3202
+ _localization;
3203
+ _activeView;
3204
+ _caseViews = {};
3205
+ constructor(_localization) {
3206
+ this._localization = _localization;
3207
+ }
3208
+ set ngPlural(value) {
3209
+ this._updateView(value);
3210
+ }
3211
+ addCase(value, switchView) {
3212
+ this._caseViews[value] = switchView;
3213
+ }
3214
+ _updateView(switchValue) {
3215
+ this._clearViews();
3216
+ const cases = Object.keys(this._caseViews);
3217
+ const key = getPluralCategory(switchValue, cases, this._localization);
3218
+ this._activateView(this._caseViews[key]);
3219
+ }
3220
+ _clearViews() {
3221
+ if (this._activeView)
3222
+ this._activeView.destroy();
3223
+ }
3224
+ _activateView(view) {
3225
+ if (view) {
3226
+ this._activeView = view;
3227
+ this._activeView.create();
3228
+ }
3229
+ }
3230
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: NgPlural, deps: [{ token: NgLocalization }], target: i0.ɵɵFactoryTarget.Directive });
3231
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.2.6", type: NgPlural, isStandalone: true, selector: "[ngPlural]", inputs: { ngPlural: "ngPlural" }, ngImport: i0 });
3232
+ }
3233
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: NgPlural, decorators: [{
3234
+ type: Directive,
3235
+ args: [{
3236
+ selector: '[ngPlural]',
3237
+ }]
3238
+ }], ctorParameters: () => [{ type: NgLocalization }], propDecorators: { ngPlural: [{
3239
+ type: Input
3240
+ }] } });
3241
+ /**
3242
+ * @ngModule CommonModule
3243
+ *
3244
+ * @description
3245
+ *
3246
+ * Creates a view that will be added/removed from the parent {@link NgPlural} when the
3247
+ * given expression matches the plural expression according to CLDR rules.
3248
+ *
3249
+ * @usageNotes
3250
+ * ```html
3251
+ * <some-element [ngPlural]="value">
3252
+ * <ng-template ngPluralCase="=0">...</ng-template>
3253
+ * <ng-template ngPluralCase="other">...</ng-template>
3254
+ * </some-element>
3255
+ *```
3256
+ *
3257
+ * See {@link NgPlural} for more details and example.
3258
+ *
3259
+ * @publicApi
3260
+ */
3261
+ class NgPluralCase {
3262
+ value;
3263
+ constructor(value, template, viewContainer, ngPlural) {
3264
+ this.value = value;
3265
+ const isANumber = !isNaN(Number(value));
3266
+ ngPlural.addCase(isANumber ? `=${value}` : value, new SwitchView(viewContainer, template));
3267
+ }
3268
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: NgPluralCase, deps: [{ token: 'ngPluralCase', attribute: true }, { token: i0.TemplateRef }, { token: i0.ViewContainerRef }, { token: NgPlural, host: true }], target: i0.ɵɵFactoryTarget.Directive });
3269
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.2.6", type: NgPluralCase, isStandalone: true, selector: "[ngPluralCase]", ngImport: i0 });
3270
+ }
3271
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: NgPluralCase, decorators: [{
3272
+ type: Directive,
3273
+ args: [{
3274
+ selector: '[ngPluralCase]',
3275
+ }]
3276
+ }], ctorParameters: () => [{ type: undefined, decorators: [{
3277
+ type: Attribute,
3278
+ args: ['ngPluralCase']
3279
+ }] }, { type: i0.TemplateRef }, { type: i0.ViewContainerRef }, { type: NgPlural, decorators: [{
3280
+ type: Host
3281
+ }] }] });
3282
+
3283
+ /**
3284
+ * @ngModule CommonModule
3285
+ *
3286
+ * @usageNotes
3287
+ *
3288
+ * Set the width of the containing element to a pixel value returned by an expression.
3289
+ *
3290
+ * ```html
3291
+ * <some-element [ngStyle]="{'max-width.px': widthExp}">...</some-element>
3292
+ * ```
3293
+ *
3294
+ * Set a collection of style values using an expression that returns key-value pairs.
3295
+ *
3296
+ * ```html
3297
+ * <some-element [ngStyle]="objExp">...</some-element>
3298
+ * ```
3299
+ *
3300
+ * For more simple use cases you can use the [style bindings](/guide/templates/binding#css-class-and-style-property-bindings) directly.
3301
+ * It doesn't require importing a directive.
3302
+ *
3303
+ * Set the font of the containing element to the result of an expression.
3304
+ *
3305
+ * ```html
3306
+ * <some-element [style]="{'font-style': styleExp}">...</some-element>
3307
+ * ```
3308
+ *
3309
+ * @description
3310
+ *
3311
+ * An attribute directive that updates styles for the containing HTML element.
3312
+ * Sets one or more style properties, specified as colon-separated key-value pairs.
3313
+ * The key is a style name, with an optional `.<unit>` suffix
3314
+ * (such as 'top.px', 'font-style.em').
3315
+ * The value is an expression to be evaluated.
3316
+ * The resulting non-null value, expressed in the given unit,
3317
+ * is assigned to the given style property.
3318
+ * If the result of evaluation is null, the corresponding style is removed.
3319
+ *
3320
+ * @see [Style bindings](/guide/templates/binding#css-class-and-style-property-bindings)
3321
+ *
3322
+ * @publicApi
3323
+ */
3324
+ class NgStyle {
3325
+ _ngEl;
3326
+ _differs;
3327
+ _renderer;
3328
+ _ngStyle = null;
3329
+ _differ = null;
3330
+ constructor(_ngEl, _differs, _renderer) {
3331
+ this._ngEl = _ngEl;
3332
+ this._differs = _differs;
3333
+ this._renderer = _renderer;
3334
+ }
3335
+ set ngStyle(values) {
3336
+ this._ngStyle = values;
3337
+ if (!this._differ && values) {
3338
+ this._differ = this._differs.find(values).create();
3339
+ }
3340
+ }
3341
+ ngDoCheck() {
3342
+ if (this._differ) {
3343
+ const changes = this._differ.diff(this._ngStyle);
3344
+ if (changes) {
3345
+ this._applyChanges(changes);
3346
+ }
3347
+ }
3348
+ }
3349
+ _setStyle(nameAndUnit, value) {
3350
+ const [name, unit] = nameAndUnit.split('.');
3351
+ const flags = name.indexOf('-') === -1 ? undefined : RendererStyleFlags2.DashCase;
3352
+ if (value != null) {
3353
+ this._renderer.setStyle(this._ngEl.nativeElement, name, unit ? `${value}${unit}` : value, flags);
3354
+ }
3355
+ else {
3356
+ this._renderer.removeStyle(this._ngEl.nativeElement, name, flags);
3357
+ }
3358
+ }
3359
+ _applyChanges(changes) {
3360
+ changes.forEachRemovedItem((record) => this._setStyle(record.key, null));
3361
+ changes.forEachAddedItem((record) => this._setStyle(record.key, record.currentValue));
3362
+ changes.forEachChangedItem((record) => this._setStyle(record.key, record.currentValue));
3363
+ }
3364
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: NgStyle, deps: [{ token: i0.ElementRef }, { token: i0.KeyValueDiffers }, { token: i0.Renderer2 }], target: i0.ɵɵFactoryTarget.Directive });
3365
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.2.6", type: NgStyle, isStandalone: true, selector: "[ngStyle]", inputs: { ngStyle: "ngStyle" }, ngImport: i0 });
3366
+ }
3367
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: NgStyle, decorators: [{
3368
+ type: Directive,
3369
+ args: [{
3370
+ selector: '[ngStyle]',
3371
+ }]
3372
+ }], ctorParameters: () => [{ type: i0.ElementRef }, { type: i0.KeyValueDiffers }, { type: i0.Renderer2 }], propDecorators: { ngStyle: [{
3373
+ type: Input,
3374
+ args: ['ngStyle']
3375
+ }] } });
3376
+
3377
+ /**
3378
+ * @ngModule CommonModule
3379
+ *
3380
+ * @description
3381
+ *
3382
+ * Inserts an embedded view from a prepared `TemplateRef`.
3383
+ *
3384
+ * You can attach a context object to the `EmbeddedViewRef` by setting `[ngTemplateOutletContext]`.
3385
+ * `[ngTemplateOutletContext]` should be an object, the object's keys will be available for binding
3386
+ * by the local template `let` declarations.
3387
+ *
3388
+ * @usageNotes
3389
+ * ```html
3390
+ * <ng-container *ngTemplateOutlet="templateRefExp; context: contextExp"></ng-container>
3391
+ * ```
3392
+ *
3393
+ * Using the key `$implicit` in the context object will set its value as default.
3394
+ *
3395
+ * ### Example
3396
+ *
3397
+ * {@example common/ngTemplateOutlet/ts/module.ts region='NgTemplateOutlet'}
3398
+ *
3399
+ * @publicApi
3400
+ */
3401
+ class NgTemplateOutlet {
3402
+ _viewContainerRef;
3403
+ _viewRef = null;
3404
+ /**
3405
+ * A context object to attach to the {@link EmbeddedViewRef}. This should be an
3406
+ * object, the object's keys will be available for binding by the local template `let`
3407
+ * declarations.
3408
+ * Using the key `$implicit` in the context object will set its value as default.
3409
+ */
3410
+ ngTemplateOutletContext = null;
3411
+ /**
3412
+ * A string defining the template reference and optionally the context object for the template.
3413
+ */
3414
+ ngTemplateOutlet = null;
3415
+ /** Injector to be used within the embedded view. */
3416
+ ngTemplateOutletInjector = null;
3417
+ constructor(_viewContainerRef) {
3418
+ this._viewContainerRef = _viewContainerRef;
3419
+ }
3420
+ ngOnChanges(changes) {
3421
+ if (this._shouldRecreateView(changes)) {
3422
+ const viewContainerRef = this._viewContainerRef;
3423
+ if (this._viewRef) {
3424
+ viewContainerRef.remove(viewContainerRef.indexOf(this._viewRef));
3425
+ }
3426
+ // If there is no outlet, clear the destroyed view ref.
3427
+ if (!this.ngTemplateOutlet) {
3428
+ this._viewRef = null;
3429
+ return;
3430
+ }
3431
+ // Create a context forward `Proxy` that will always bind to the user-specified context,
3432
+ // without having to destroy and re-create views whenever the context changes.
3433
+ const viewContext = this._createContextForwardProxy();
3434
+ this._viewRef = viewContainerRef.createEmbeddedView(this.ngTemplateOutlet, viewContext, {
3435
+ injector: this.ngTemplateOutletInjector ?? undefined,
3436
+ });
3437
+ }
3438
+ }
3439
+ /**
3440
+ * We need to re-create existing embedded view if either is true:
3441
+ * - the outlet changed.
3442
+ * - the injector changed.
3443
+ */
3444
+ _shouldRecreateView(changes) {
3445
+ return !!changes['ngTemplateOutlet'] || !!changes['ngTemplateOutletInjector'];
3446
+ }
3447
+ /**
3448
+ * For a given outlet instance, we create a proxy object that delegates
3449
+ * to the user-specified context. This allows changing, or swapping out
3450
+ * the context object completely without having to destroy/re-create the view.
3451
+ */
3452
+ _createContextForwardProxy() {
3453
+ return new Proxy({}, {
3454
+ set: (_target, prop, newValue) => {
3455
+ if (!this.ngTemplateOutletContext) {
3456
+ return false;
3457
+ }
3458
+ return Reflect.set(this.ngTemplateOutletContext, prop, newValue);
3459
+ },
3460
+ get: (_target, prop, receiver) => {
3461
+ if (!this.ngTemplateOutletContext) {
3462
+ return undefined;
3463
+ }
3464
+ return Reflect.get(this.ngTemplateOutletContext, prop, receiver);
3465
+ },
3466
+ });
3467
+ }
3468
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: NgTemplateOutlet, deps: [{ token: i0.ViewContainerRef }], target: i0.ɵɵFactoryTarget.Directive });
3469
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.2.6", type: NgTemplateOutlet, isStandalone: true, selector: "[ngTemplateOutlet]", inputs: { ngTemplateOutletContext: "ngTemplateOutletContext", ngTemplateOutlet: "ngTemplateOutlet", ngTemplateOutletInjector: "ngTemplateOutletInjector" }, usesOnChanges: true, ngImport: i0 });
3470
+ }
3471
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: NgTemplateOutlet, decorators: [{
3472
+ type: Directive,
3473
+ args: [{
3474
+ selector: '[ngTemplateOutlet]',
3475
+ }]
3476
+ }], ctorParameters: () => [{ type: i0.ViewContainerRef }], propDecorators: { ngTemplateOutletContext: [{
3477
+ type: Input
3478
+ }], ngTemplateOutlet: [{
3479
+ type: Input
3480
+ }], ngTemplateOutletInjector: [{
3481
+ type: Input
3482
+ }] } });
3483
+
3484
+ /**
3485
+ * A collection of Angular directives that are likely to be used in each and every Angular
3486
+ * application.
3487
+ */
3488
+ const COMMON_DIRECTIVES = [
3489
+ NgClass,
3490
+ NgComponentOutlet,
3491
+ NgForOf,
3492
+ NgIf,
3493
+ NgTemplateOutlet,
3494
+ NgStyle,
3495
+ NgSwitch,
3496
+ NgSwitchCase,
3497
+ NgSwitchDefault,
3498
+ NgPlural,
3499
+ NgPluralCase,
3500
+ ];
3501
+
3502
+ function invalidPipeArgumentError(type, value) {
3503
+ return new _RuntimeError(2100 /* RuntimeErrorCode.INVALID_PIPE_ARGUMENT */, ngDevMode && `InvalidPipeArgument: '${value}' for pipe '${_stringify(type)}'`);
3504
+ }
3505
+
3506
+ class SubscribableStrategy {
3507
+ createSubscription(async, updateLatestValue) {
3508
+ // Subscription can be side-effectful, and we don't want any signal reads which happen in the
3509
+ // side effect of the subscription to be tracked by a component's template when that
3510
+ // subscription is triggered via the async pipe. So we wrap the subscription in `untracked` to
3511
+ // decouple from the current reactive context.
3512
+ //
3513
+ // `untracked` also prevents signal _writes_ which happen in the subscription side effect from
3514
+ // being treated as signal writes during the template evaluation (which throws errors).
3515
+ return untracked(() => async.subscribe({
3516
+ next: updateLatestValue,
3517
+ error: (e) => {
3518
+ throw e;
3519
+ },
3520
+ }));
3521
+ }
3522
+ dispose(subscription) {
3523
+ // See the comment in `createSubscription` above on the use of `untracked`.
3524
+ untracked(() => subscription.unsubscribe());
3525
+ }
3526
+ }
3527
+ class PromiseStrategy {
3528
+ createSubscription(async, updateLatestValue) {
3529
+ return async.then(updateLatestValue, (e) => {
3530
+ throw e;
3531
+ });
3532
+ }
3533
+ dispose(subscription) { }
3534
+ }
3535
+ const _promiseStrategy = new PromiseStrategy();
3536
+ const _subscribableStrategy = new SubscribableStrategy();
3537
+ /**
3538
+ * @ngModule CommonModule
3539
+ * @description
3540
+ *
3541
+ * Unwraps a value from an asynchronous primitive.
3542
+ *
3543
+ * The `async` pipe subscribes to an `Observable` or `Promise` and returns the latest value it has
3544
+ * emitted. When a new value is emitted, the `async` pipe marks the component to be checked for
3545
+ * changes. When the component gets destroyed, the `async` pipe unsubscribes automatically to avoid
3546
+ * potential memory leaks. When the reference of the expression changes, the `async` pipe
3547
+ * automatically unsubscribes from the old `Observable` or `Promise` and subscribes to the new one.
3548
+ *
3549
+ * @usageNotes
3550
+ *
3551
+ * ### Examples
3552
+ *
3553
+ * This example binds a `Promise` to the view. Clicking the `Resolve` button resolves the
3554
+ * promise.
3555
+ *
3556
+ * {@example common/pipes/ts/async_pipe.ts region='AsyncPipePromise'}
3557
+ *
3558
+ * It's also possible to use `async` with Observables. The example below binds the `time` Observable
3559
+ * to the view. The Observable continuously updates the view with the current time.
3560
+ *
3561
+ * {@example common/pipes/ts/async_pipe.ts region='AsyncPipeObservable'}
3562
+ *
3563
+ * @publicApi
3564
+ */
3565
+ class AsyncPipe {
3566
+ _ref;
3567
+ _latestValue = null;
3568
+ markForCheckOnValueUpdate = true;
3569
+ _subscription = null;
3570
+ _obj = null;
3571
+ _strategy = null;
3572
+ constructor(ref) {
3573
+ // Assign `ref` into `this._ref` manually instead of declaring `_ref` in the constructor
3574
+ // parameter list, as the type of `this._ref` includes `null` unlike the type of `ref`.
3575
+ this._ref = ref;
3576
+ }
3577
+ ngOnDestroy() {
3578
+ if (this._subscription) {
3579
+ this._dispose();
3580
+ }
3581
+ // Clear the `ChangeDetectorRef` and its association with the view data, to mitigate
3582
+ // potential memory leaks in Observables that could otherwise cause the view data to
3583
+ // be retained.
3584
+ // https://github.com/angular/angular/issues/17624
3585
+ this._ref = null;
3586
+ }
3587
+ transform(obj) {
3588
+ if (!this._obj) {
3589
+ if (obj) {
3590
+ try {
3591
+ // Only call `markForCheck` if the value is updated asynchronously.
3592
+ // Synchronous updates _during_ subscription should not wastefully mark for check -
3593
+ // this value is already going to be returned from the transform function.
3594
+ this.markForCheckOnValueUpdate = false;
3595
+ this._subscribe(obj);
3596
+ }
3597
+ finally {
3598
+ this.markForCheckOnValueUpdate = true;
3599
+ }
3600
+ }
3601
+ return this._latestValue;
3602
+ }
3603
+ if (obj !== this._obj) {
3604
+ this._dispose();
3605
+ return this.transform(obj);
3606
+ }
3607
+ return this._latestValue;
3608
+ }
3609
+ _subscribe(obj) {
3610
+ this._obj = obj;
3611
+ this._strategy = this._selectStrategy(obj);
3612
+ this._subscription = this._strategy.createSubscription(obj, (value) => this._updateLatestValue(obj, value));
3613
+ }
3614
+ _selectStrategy(obj) {
3615
+ if (_isPromise(obj)) {
3616
+ return _promiseStrategy;
3617
+ }
3618
+ if (_isSubscribable(obj)) {
3619
+ return _subscribableStrategy;
3620
+ }
3621
+ throw invalidPipeArgumentError(AsyncPipe, obj);
3622
+ }
3623
+ _dispose() {
3624
+ // Note: `dispose` is only called if a subscription has been initialized before, indicating
3625
+ // that `this._strategy` is also available.
3626
+ this._strategy.dispose(this._subscription);
3627
+ this._latestValue = null;
3628
+ this._subscription = null;
3629
+ this._obj = null;
3630
+ }
3631
+ _updateLatestValue(async, value) {
3632
+ if (async === this._obj) {
3633
+ this._latestValue = value;
3634
+ if (this.markForCheckOnValueUpdate) {
3635
+ this._ref?.markForCheck();
3636
+ }
3637
+ }
3638
+ }
3639
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: AsyncPipe, deps: [{ token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Pipe });
3640
+ static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "19.2.6", ngImport: i0, type: AsyncPipe, isStandalone: true, name: "async", pure: false });
3641
+ }
3642
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: AsyncPipe, decorators: [{
3643
+ type: Pipe,
3644
+ args: [{
3645
+ name: 'async',
3646
+ pure: false,
3647
+ }]
3648
+ }], ctorParameters: () => [{ type: i0.ChangeDetectorRef }] });
3649
+
3650
+ /**
3651
+ * Transforms text to all lower case.
3652
+ *
3653
+ * @see {@link UpperCasePipe}
3654
+ * @see {@link TitleCasePipe}
3655
+ * @usageNotes
3656
+ *
3657
+ * The following example defines a view that allows the user to enter
3658
+ * text, and then uses the pipe to convert the input text to all lower case.
3659
+ *
3660
+ * {@example common/pipes/ts/lowerupper_pipe.ts region='LowerUpperPipe'}
3661
+ *
3662
+ * @ngModule CommonModule
3663
+ * @publicApi
3664
+ */
3665
+ class LowerCasePipe {
3666
+ transform(value) {
3667
+ if (value == null)
3668
+ return null;
3669
+ if (typeof value !== 'string') {
3670
+ throw invalidPipeArgumentError(LowerCasePipe, value);
3671
+ }
3672
+ return value.toLowerCase();
3673
+ }
3674
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: LowerCasePipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
3675
+ static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "19.2.6", ngImport: i0, type: LowerCasePipe, isStandalone: true, name: "lowercase" });
3676
+ }
3677
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: LowerCasePipe, decorators: [{
3678
+ type: Pipe,
3679
+ args: [{
3680
+ name: 'lowercase',
3681
+ }]
3682
+ }] });
3683
+ //
3684
+ // Regex below matches any Unicode word and number compatible with ES5. In ES2018 the same result
3685
+ // can be achieved by using /[0-9\p{L}]\S*/gu and also known as Unicode Property Escapes
3686
+ // (https://2ality.com/2017/07/regexp-unicode-property-escapes.html). Since there is no
3687
+ // transpilation of this functionality down to ES5 without external tool, the only solution is
3688
+ // to use already transpiled form. Example can be found here -
3689
+ // https://mothereff.in/regexpu#input=var+regex+%3D+%2F%5B0-9%5Cp%7BL%7D%5D%5CS*%2Fgu%3B%0A%0A&unicodePropertyEscape=1
3690
+ //
3691
+ const unicodeWordMatch = /(?:[0-9A-Za-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u0870-\u0887\u0889-\u088E\u08A0-\u08C9\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C5D\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16F1-\u16F8\u1700-\u1711\u171F-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4C\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA7CA\uA7D0\uA7D1\uA7D3\uA7D5-\uA7D9\uA7F2-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF40\uDF42-\uDF49\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDD70-\uDD7A\uDD7C-\uDD8A\uDD8C-\uDD92\uDD94\uDD95\uDD97-\uDDA1\uDDA3-\uDDB1\uDDB3-\uDDB9\uDDBB\uDDBC\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67\uDF80-\uDF85\uDF87-\uDFB0\uDFB2-\uDFBA]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDD00-\uDD23\uDE80-\uDEA9\uDEB0\uDEB1\uDF00-\uDF1C\uDF27\uDF30-\uDF45\uDF70-\uDF81\uDFB0-\uDFC4\uDFE0-\uDFF6]|\uD804[\uDC03-\uDC37\uDC71\uDC72\uDC75\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD44\uDD47\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC5F-\uDC61\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDEB8\uDF00-\uDF1A\uDF40-\uDF46]|\uD806[\uDC00-\uDC2B\uDCA0-\uDCDF\uDCFF-\uDD06\uDD09\uDD0C-\uDD13\uDD15\uDD16\uDD18-\uDD2F\uDD3F\uDD41\uDDA0-\uDDA7\uDDAA-\uDDD0\uDDE1\uDDE3\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE89\uDE9D\uDEB0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD89\uDD98\uDEE0-\uDEF2\uDFB0]|\uD808[\uDC00-\uDF99]|\uD809[\uDC80-\uDD43]|\uD80B[\uDF90-\uDFF0]|[\uD80C\uD81C-\uD820\uD822\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879\uD880-\uD883][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE70-\uDEBE\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDE40-\uDE7F\uDF00-\uDF4A\uDF50\uDF93-\uDF9F\uDFE0\uDFE1\uDFE3]|\uD821[\uDC00-\uDFF7]|\uD823[\uDC00-\uDCD5\uDD00-\uDD08]|\uD82B[\uDFF0-\uDFF3\uDFF5-\uDFFB\uDFFD\uDFFE]|\uD82C[\uDC00-\uDD22\uDD50-\uDD52\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD837[\uDF00-\uDF1E]|\uD838[\uDD00-\uDD2C\uDD37-\uDD3D\uDD4E\uDE90-\uDEAD\uDEC0-\uDEEB]|\uD839[\uDFE0-\uDFE6\uDFE8-\uDFEB\uDFED\uDFEE\uDFF0-\uDFFE]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43\uDD4B]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDEDF\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF38\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A])\S*/g;
3692
+ /**
3693
+ * Transforms text to title case.
3694
+ * Capitalizes the first letter of each word and transforms the
3695
+ * rest of the word to lower case.
3696
+ * Words are delimited by any whitespace character, such as a space, tab, or line-feed character.
3697
+ *
3698
+ * @see {@link LowerCasePipe}
3699
+ * @see {@link UpperCasePipe}
3700
+ *
3701
+ * @usageNotes
3702
+ * The following example shows the result of transforming various strings into title case.
3703
+ *
3704
+ * {@example common/pipes/ts/titlecase_pipe.ts region='TitleCasePipe'}
3705
+ *
3706
+ * @ngModule CommonModule
3707
+ * @publicApi
3708
+ */
3709
+ class TitleCasePipe {
3710
+ transform(value) {
3711
+ if (value == null)
3712
+ return null;
3713
+ if (typeof value !== 'string') {
3714
+ throw invalidPipeArgumentError(TitleCasePipe, value);
3715
+ }
3716
+ return value.replace(unicodeWordMatch, (txt) => txt[0].toUpperCase() + txt.slice(1).toLowerCase());
3717
+ }
3718
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: TitleCasePipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
3719
+ static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "19.2.6", ngImport: i0, type: TitleCasePipe, isStandalone: true, name: "titlecase" });
3720
+ }
3721
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: TitleCasePipe, decorators: [{
3722
+ type: Pipe,
3723
+ args: [{
3724
+ name: 'titlecase',
3725
+ }]
3726
+ }] });
3727
+ /**
3728
+ * Transforms text to all upper case.
3729
+ * @see {@link LowerCasePipe}
3730
+ * @see {@link TitleCasePipe}
3731
+ *
3732
+ * @ngModule CommonModule
3733
+ * @publicApi
3734
+ */
3735
+ class UpperCasePipe {
3736
+ transform(value) {
3737
+ if (value == null)
3738
+ return null;
3739
+ if (typeof value !== 'string') {
3740
+ throw invalidPipeArgumentError(UpperCasePipe, value);
3741
+ }
3742
+ return value.toUpperCase();
3743
+ }
3744
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: UpperCasePipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
3745
+ static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "19.2.6", ngImport: i0, type: UpperCasePipe, isStandalone: true, name: "uppercase" });
3746
+ }
3747
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: UpperCasePipe, decorators: [{
3748
+ type: Pipe,
3749
+ args: [{
3750
+ name: 'uppercase',
3751
+ }]
3752
+ }] });
3753
+
3754
+ /**
3755
+ * The default date format of Angular date pipe, which corresponds to the following format:
3756
+ * `'MMM d,y'` (e.g. `Jun 15, 2015`)
3757
+ */
3758
+ const DEFAULT_DATE_FORMAT = 'mediumDate';
3759
+
3760
+ /**
3761
+ * Optionally-provided default timezone to use for all instances of `DatePipe` (such as `'+0430'`).
3762
+ * If the value isn't provided, the `DatePipe` will use the end-user's local system timezone.
3763
+ *
3764
+ * @deprecated use DATE_PIPE_DEFAULT_OPTIONS token to configure DatePipe
3765
+ */
3766
+ const DATE_PIPE_DEFAULT_TIMEZONE = new InjectionToken(ngDevMode ? 'DATE_PIPE_DEFAULT_TIMEZONE' : '');
3767
+ /**
3768
+ * DI token that allows to provide default configuration for the `DatePipe` instances in an
3769
+ * application. The value is an object which can include the following fields:
3770
+ * - `dateFormat`: configures the default date format. If not provided, the `DatePipe`
3771
+ * will use the 'mediumDate' as a value.
3772
+ * - `timezone`: configures the default timezone. If not provided, the `DatePipe` will
3773
+ * use the end-user's local system timezone.
3774
+ *
3775
+ * @see {@link DatePipeConfig}
3776
+ *
3777
+ * @usageNotes
3778
+ *
3779
+ * Various date pipe default values can be overwritten by providing this token with
3780
+ * the value that has this interface.
3781
+ *
3782
+ * For example:
3783
+ *
3784
+ * Override the default date format by providing a value using the token:
3785
+ * ```ts
3786
+ * providers: [
3787
+ * {provide: DATE_PIPE_DEFAULT_OPTIONS, useValue: {dateFormat: 'shortDate'}}
3788
+ * ]
3789
+ * ```
3790
+ *
3791
+ * Override the default timezone by providing a value using the token:
3792
+ * ```ts
3793
+ * providers: [
3794
+ * {provide: DATE_PIPE_DEFAULT_OPTIONS, useValue: {timezone: '-1200'}}
3795
+ * ]
3796
+ * ```
3797
+ */
3798
+ const DATE_PIPE_DEFAULT_OPTIONS = new InjectionToken(ngDevMode ? 'DATE_PIPE_DEFAULT_OPTIONS' : '');
3799
+ /**
3800
+ * @ngModule CommonModule
3801
+ * @description
3802
+ *
3803
+ * Formats a date value according to locale rules.
3804
+ *
3805
+ * `DatePipe` is executed only when it detects a pure change to the input value.
3806
+ * A pure change is either a change to a primitive input value
3807
+ * (such as `String`, `Number`, `Boolean`, or `Symbol`),
3808
+ * or a changed object reference (such as `Date`, `Array`, `Function`, or `Object`).
3809
+ *
3810
+ * Note that mutating a `Date` object does not cause the pipe to be rendered again.
3811
+ * To ensure that the pipe is executed, you must create a new `Date` object.
3812
+ *
3813
+ * Only the `en-US` locale data comes with Angular. To localize dates
3814
+ * in another language, you must import the corresponding locale data.
3815
+ * See the [I18n guide](guide/i18n/format-data-locale) for more information.
3816
+ *
3817
+ * The time zone of the formatted value can be specified either by passing it in as the second
3818
+ * parameter of the pipe, or by setting the default through the `DATE_PIPE_DEFAULT_OPTIONS`
3819
+ * injection token. The value that is passed in as the second parameter takes precedence over
3820
+ * the one defined using the injection token.
3821
+ *
3822
+ * @see {@link formatDate}
3823
+ *
3824
+ *
3825
+ * @usageNotes
3826
+ *
3827
+ * The result of this pipe is not reevaluated when the input is mutated. To avoid the need to
3828
+ * reformat the date on every change-detection cycle, treat the date as an immutable object
3829
+ * and change the reference when the pipe needs to run again.
3830
+ *
3831
+ * ### Pre-defined format options
3832
+ *
3833
+ * | Option | Equivalent to | Examples (given in `en-US` locale) |
3834
+ * |---------------|-------------------------------------|-------------------------------------------------|
3835
+ * | `'short'` | `'M/d/yy, h:mm a'` | `6/15/15, 9:03 AM` |
3836
+ * | `'medium'` | `'MMM d, y, h:mm:ss a'` | `Jun 15, 2015, 9:03:01 AM` |
3837
+ * | `'long'` | `'MMMM d, y, h:mm:ss a z'` | `June 15, 2015 at 9:03:01 AM GMT+1` |
3838
+ * | `'full'` | `'EEEE, MMMM d, y, h:mm:ss a zzzz'` | `Monday, June 15, 2015 at 9:03:01 AM GMT+01:00` |
3839
+ * | `'shortDate'` | `'M/d/yy'` | `6/15/15` |
3840
+ * | `'mediumDate'`| `'MMM d, y'` | `Jun 15, 2015` |
3841
+ * | `'longDate'` | `'MMMM d, y'` | `June 15, 2015` |
3842
+ * | `'fullDate'` | `'EEEE, MMMM d, y'` | `Monday, June 15, 2015` |
3843
+ * | `'shortTime'` | `'h:mm a'` | `9:03 AM` |
3844
+ * | `'mediumTime'`| `'h:mm:ss a'` | `9:03:01 AM` |
3845
+ * | `'longTime'` | `'h:mm:ss a z'` | `9:03:01 AM GMT+1` |
3846
+ * | `'fullTime'` | `'h:mm:ss a zzzz'` | `9:03:01 AM GMT+01:00` |
3847
+ *
3848
+ * ### Custom format options
3849
+ *
3850
+ * You can construct a format string using symbols to specify the components
3851
+ * of a date-time value, as described in the following table.
3852
+ * Format details depend on the locale.
3853
+ * Fields marked with (*) are only available in the extra data set for the given locale.
3854
+ *
3855
+ * | Field type | Format | Description | Example Value |
3856
+ * |-------------------------|-------------|---------------------------------------------------------------|------------------------------------------------------------|
3857
+ * | Era | G, GG & GGG | Abbreviated | AD |
3858
+ * | | GGGG | Wide | Anno Domini |
3859
+ * | | GGGGG | Narrow | A |
3860
+ * | Year | y | Numeric: minimum digits | 2, 20, 201, 2017, 20173 |
3861
+ * | | yy | Numeric: 2 digits + zero padded | 02, 20, 01, 17, 73 |
3862
+ * | | yyy | Numeric: 3 digits + zero padded | 002, 020, 201, 2017, 20173 |
3863
+ * | | yyyy | Numeric: 4 digits or more + zero padded | 0002, 0020, 0201, 2017, 20173 |
3864
+ * | ISO Week-numbering year | Y | Numeric: minimum digits | 2, 20, 201, 2017, 20173 |
3865
+ * | | YY | Numeric: 2 digits + zero padded | 02, 20, 01, 17, 73 |
3866
+ * | | YYY | Numeric: 3 digits + zero padded | 002, 020, 201, 2017, 20173 |
3867
+ * | | YYYY | Numeric: 4 digits or more + zero padded | 0002, 0020, 0201, 2017, 20173 |
3868
+ * | Month | M | Numeric: 1 digit | 9, 12 |
3869
+ * | | MM | Numeric: 2 digits + zero padded | 09, 12 |
3870
+ * | | MMM | Abbreviated | Sep |
3871
+ * | | MMMM | Wide | September |
3872
+ * | | MMMMM | Narrow | S |
3873
+ * | Month standalone | L | Numeric: 1 digit | 9, 12 |
3874
+ * | | LL | Numeric: 2 digits + zero padded | 09, 12 |
3875
+ * | | LLL | Abbreviated | Sep |
3876
+ * | | LLLL | Wide | September |
3877
+ * | | LLLLL | Narrow | S |
3878
+ * | ISO Week of year | w | Numeric: minimum digits | 1... 53 |
3879
+ * | | ww | Numeric: 2 digits + zero padded | 01... 53 |
3880
+ * | Week of month | W | Numeric: 1 digit | 1... 5 |
3881
+ * | Day of month | d | Numeric: minimum digits | 1 |
3882
+ * | | dd | Numeric: 2 digits + zero padded | 01 |
3883
+ * | Week day | E, EE & EEE | Abbreviated | Tue |
3884
+ * | | EEEE | Wide | Tuesday |
3885
+ * | | EEEEE | Narrow | T |
3886
+ * | | EEEEEE | Short | Tu |
3887
+ * | Week day standalone | c, cc | Numeric: 1 digit | 2 |
3888
+ * | | ccc | Abbreviated | Tue |
3889
+ * | | cccc | Wide | Tuesday |
3890
+ * | | ccccc | Narrow | T |
3891
+ * | | cccccc | Short | Tu |
3892
+ * | Period | a, aa & aaa | Abbreviated | am/pm or AM/PM |
3893
+ * | | aaaa | Wide (fallback to `a` when missing) | ante meridiem/post meridiem |
3894
+ * | | aaaaa | Narrow | a/p |
3895
+ * | Period* | B, BB & BBB | Abbreviated | mid. |
3896
+ * | | BBBB | Wide | am, pm, midnight, noon, morning, afternoon, evening, night |
3897
+ * | | BBBBB | Narrow | md |
3898
+ * | Period standalone* | b, bb & bbb | Abbreviated | mid. |
3899
+ * | | bbbb | Wide | am, pm, midnight, noon, morning, afternoon, evening, night |
3900
+ * | | bbbbb | Narrow | md |
3901
+ * | Hour 1-12 | h | Numeric: minimum digits | 1, 12 |
3902
+ * | | hh | Numeric: 2 digits + zero padded | 01, 12 |
3903
+ * | Hour 0-23 | H | Numeric: minimum digits | 0, 23 |
3904
+ * | | HH | Numeric: 2 digits + zero padded | 00, 23 |
3905
+ * | Minute | m | Numeric: minimum digits | 8, 59 |
3906
+ * | | mm | Numeric: 2 digits + zero padded | 08, 59 |
3907
+ * | Second | s | Numeric: minimum digits | 0... 59 |
3908
+ * | | ss | Numeric: 2 digits + zero padded | 00... 59 |
3909
+ * | Fractional seconds | S | Numeric: 1 digit | 0... 9 |
3910
+ * | | SS | Numeric: 2 digits + zero padded | 00... 99 |
3911
+ * | | SSS | Numeric: 3 digits + zero padded (= milliseconds) | 000... 999 |
3912
+ * | Zone | z, zz & zzz | Short specific non location format (fallback to O) | GMT-8 |
3913
+ * | | zzzz | Long specific non location format (fallback to OOOO) | GMT-08:00 |
3914
+ * | | Z, ZZ & ZZZ | ISO8601 basic format | -0800 |
3915
+ * | | ZZZZ | Long localized GMT format | GMT-8:00 |
3916
+ * | | ZZZZZ | ISO8601 extended format + Z indicator for offset 0 (= XXXXX) | -08:00 |
3917
+ * | | O, OO & OOO | Short localized GMT format | GMT-8 |
3918
+ * | | OOOO | Long localized GMT format | GMT-08:00 |
3919
+ *
3920
+ *
3921
+ * ### Format examples
3922
+ *
3923
+ * These examples transform a date into various formats,
3924
+ * assuming that `dateObj` is a JavaScript `Date` object for
3925
+ * year: 2015, month: 6, day: 15, hour: 21, minute: 43, second: 11,
3926
+ * given in the local time for the `en-US` locale.
3927
+ *
3928
+ * ```
3929
+ * {{ dateObj | date }} // output is 'Jun 15, 2015'
3930
+ * {{ dateObj | date:'medium' }} // output is 'Jun 15, 2015, 9:43:11 PM'
3931
+ * {{ dateObj | date:'shortTime' }} // output is '9:43 PM'
3932
+ * {{ dateObj | date:'mm:ss' }} // output is '43:11'
3933
+ * {{ dateObj | date:"MMM dd, yyyy 'at' hh:mm a" }} // output is 'Jun 15, 2015 at 09:43 PM'
3934
+ * ```
3935
+ *
3936
+ * ### Usage example
3937
+ *
3938
+ * The following component uses a date pipe to display the current date in different formats.
3939
+ *
3940
+ * ```angular-ts
3941
+ * @Component({
3942
+ * selector: 'date-pipe',
3943
+ * template: `<div>
3944
+ * <p>Today is {{today | date}}</p>
3945
+ * <p>Or if you prefer, {{today | date:'fullDate'}}</p>
3946
+ * <p>The time is {{today | date:'h:mm a z'}}</p>
3947
+ * </div>`
3948
+ * })
3949
+ * // Get the current date and time as a date-time value.
3950
+ * export class DatePipeComponent {
3951
+ * today: number = Date.now();
3952
+ * }
3953
+ * ```
3954
+ *
3955
+ * @publicApi
3956
+ */
3957
+ class DatePipe {
3958
+ locale;
3959
+ defaultTimezone;
3960
+ defaultOptions;
3961
+ constructor(locale, defaultTimezone, defaultOptions) {
3962
+ this.locale = locale;
3963
+ this.defaultTimezone = defaultTimezone;
3964
+ this.defaultOptions = defaultOptions;
3965
+ }
3966
+ transform(value, format, timezone, locale) {
3967
+ if (value == null || value === '' || value !== value)
3968
+ return null;
3969
+ try {
3970
+ const _format = format ?? this.defaultOptions?.dateFormat ?? DEFAULT_DATE_FORMAT;
3971
+ const _timezone = timezone ?? this.defaultOptions?.timezone ?? this.defaultTimezone ?? undefined;
3972
+ return formatDate(value, _format, locale || this.locale, _timezone);
3973
+ }
3974
+ catch (error) {
3975
+ throw invalidPipeArgumentError(DatePipe, error.message);
3976
+ }
3977
+ }
3978
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: DatePipe, deps: [{ token: LOCALE_ID }, { token: DATE_PIPE_DEFAULT_TIMEZONE, optional: true }, { token: DATE_PIPE_DEFAULT_OPTIONS, optional: true }], target: i0.ɵɵFactoryTarget.Pipe });
3979
+ static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "19.2.6", ngImport: i0, type: DatePipe, isStandalone: true, name: "date" });
3980
+ }
3981
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: DatePipe, decorators: [{
3982
+ type: Pipe,
3983
+ args: [{
3984
+ name: 'date',
3985
+ }]
3986
+ }], ctorParameters: () => [{ type: undefined, decorators: [{
3987
+ type: Inject,
3988
+ args: [LOCALE_ID]
3989
+ }] }, { type: undefined, decorators: [{
3990
+ type: Inject,
3991
+ args: [DATE_PIPE_DEFAULT_TIMEZONE]
3992
+ }, {
3993
+ type: Optional
3994
+ }] }, { type: undefined, decorators: [{
3995
+ type: Inject,
3996
+ args: [DATE_PIPE_DEFAULT_OPTIONS]
3997
+ }, {
3998
+ type: Optional
3999
+ }] }] });
4000
+
4001
+ const _INTERPOLATION_REGEXP = /#/g;
4002
+ /**
4003
+ * @ngModule CommonModule
4004
+ * @description
4005
+ *
4006
+ * Maps a value to a string that pluralizes the value according to locale rules.
4007
+ *
4008
+ * @usageNotes
4009
+ *
4010
+ * ### Example
4011
+ *
4012
+ * {@example common/pipes/ts/i18n_pipe.ts region='I18nPluralPipeComponent'}
4013
+ *
4014
+ * @publicApi
4015
+ */
4016
+ class I18nPluralPipe {
4017
+ _localization;
4018
+ constructor(_localization) {
4019
+ this._localization = _localization;
4020
+ }
4021
+ /**
4022
+ * @param value the number to be formatted
4023
+ * @param pluralMap an object that mimics the ICU format, see
4024
+ * https://unicode-org.github.io/icu/userguide/format_parse/messages/.
4025
+ * @param locale a `string` defining the locale to use (uses the current {@link LOCALE_ID} by
4026
+ * default).
4027
+ */
4028
+ transform(value, pluralMap, locale) {
4029
+ if (value == null)
4030
+ return '';
4031
+ if (typeof pluralMap !== 'object' || pluralMap === null) {
4032
+ throw invalidPipeArgumentError(I18nPluralPipe, pluralMap);
4033
+ }
4034
+ const key = getPluralCategory(value, Object.keys(pluralMap), this._localization, locale);
4035
+ return pluralMap[key].replace(_INTERPOLATION_REGEXP, value.toString());
4036
+ }
4037
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: I18nPluralPipe, deps: [{ token: NgLocalization }], target: i0.ɵɵFactoryTarget.Pipe });
4038
+ static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "19.2.6", ngImport: i0, type: I18nPluralPipe, isStandalone: true, name: "i18nPlural" });
4039
+ }
4040
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: I18nPluralPipe, decorators: [{
4041
+ type: Pipe,
4042
+ args: [{
4043
+ name: 'i18nPlural',
4044
+ }]
4045
+ }], ctorParameters: () => [{ type: NgLocalization }] });
4046
+
4047
+ /**
4048
+ * @ngModule CommonModule
4049
+ * @description
4050
+ *
4051
+ * Generic selector that displays the string that matches the current value.
4052
+ *
4053
+ * If none of the keys of the `mapping` match the `value`, then the content
4054
+ * of the `other` key is returned when present, otherwise an empty string is returned.
4055
+ *
4056
+ * @usageNotes
4057
+ *
4058
+ * ### Example
4059
+ *
4060
+ * {@example common/pipes/ts/i18n_pipe.ts region='I18nSelectPipeComponent'}
4061
+ *
4062
+ * @publicApi
4063
+ */
4064
+ class I18nSelectPipe {
4065
+ /**
4066
+ * @param value a string to be internationalized.
4067
+ * @param mapping an object that indicates the text that should be displayed
4068
+ * for different values of the provided `value`.
4069
+ */
4070
+ transform(value, mapping) {
4071
+ if (value == null)
4072
+ return '';
4073
+ if (typeof mapping !== 'object' || typeof value !== 'string') {
4074
+ throw invalidPipeArgumentError(I18nSelectPipe, mapping);
4075
+ }
4076
+ if (mapping.hasOwnProperty(value)) {
4077
+ return mapping[value];
4078
+ }
4079
+ if (mapping.hasOwnProperty('other')) {
4080
+ return mapping['other'];
4081
+ }
4082
+ return '';
4083
+ }
4084
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: I18nSelectPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
4085
+ static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "19.2.6", ngImport: i0, type: I18nSelectPipe, isStandalone: true, name: "i18nSelect" });
4086
+ }
4087
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: I18nSelectPipe, decorators: [{
4088
+ type: Pipe,
4089
+ args: [{
4090
+ name: 'i18nSelect',
4091
+ }]
4092
+ }] });
4093
+
4094
+ /**
4095
+ * @ngModule CommonModule
4096
+ * @description
4097
+ *
4098
+ * Converts a value into its JSON-format representation. Useful for debugging.
4099
+ *
4100
+ * @usageNotes
4101
+ *
4102
+ * The following component uses a JSON pipe to convert an object
4103
+ * to JSON format, and displays the string in both formats for comparison.
4104
+ *
4105
+ * {@example common/pipes/ts/json_pipe.ts region='JsonPipe'}
4106
+ *
4107
+ * @publicApi
4108
+ */
4109
+ class JsonPipe {
4110
+ /**
4111
+ * @param value A value of any type to convert into a JSON-format string.
4112
+ */
4113
+ transform(value) {
4114
+ return JSON.stringify(value, null, 2);
4115
+ }
4116
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: JsonPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
4117
+ static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "19.2.6", ngImport: i0, type: JsonPipe, isStandalone: true, name: "json", pure: false });
4118
+ }
4119
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: JsonPipe, decorators: [{
4120
+ type: Pipe,
4121
+ args: [{
4122
+ name: 'json',
4123
+ pure: false,
4124
+ }]
4125
+ }] });
4126
+
4127
+ function makeKeyValuePair(key, value) {
4128
+ return { key: key, value: value };
4129
+ }
4130
+ /**
4131
+ * @ngModule CommonModule
4132
+ * @description
4133
+ *
4134
+ * Transforms Object or Map into an array of key value pairs.
4135
+ *
4136
+ * The output array will be ordered by keys.
4137
+ * By default the comparator will be by Unicode point value.
4138
+ * You can optionally pass a compareFn if your keys are complex types.
4139
+ * Passing `null` as the compareFn will use natural ordering of the input.
4140
+ *
4141
+ * @usageNotes
4142
+ * ### Examples
4143
+ *
4144
+ * This examples show how an Object or a Map can be iterated by ngFor with the use of this
4145
+ * keyvalue pipe.
4146
+ *
4147
+ * {@example common/pipes/ts/keyvalue_pipe.ts region='KeyValuePipe'}
4148
+ *
4149
+ * @publicApi
4150
+ */
4151
+ class KeyValuePipe {
4152
+ differs;
4153
+ constructor(differs) {
4154
+ this.differs = differs;
4155
+ }
4156
+ differ;
4157
+ keyValues = [];
4158
+ compareFn = defaultComparator;
4159
+ transform(input, compareFn = defaultComparator) {
4160
+ if (!input || (!(input instanceof Map) && typeof input !== 'object')) {
4161
+ return null;
4162
+ }
4163
+ // make a differ for whatever type we've been passed in
4164
+ this.differ ??= this.differs.find(input).create();
4165
+ const differChanges = this.differ.diff(input);
4166
+ const compareFnChanged = compareFn !== this.compareFn;
4167
+ if (differChanges) {
4168
+ this.keyValues = [];
4169
+ differChanges.forEachItem((r) => {
4170
+ this.keyValues.push(makeKeyValuePair(r.key, r.currentValue));
4171
+ });
4172
+ }
4173
+ if (differChanges || compareFnChanged) {
4174
+ if (compareFn) {
4175
+ this.keyValues.sort(compareFn);
4176
+ }
4177
+ this.compareFn = compareFn;
4178
+ }
4179
+ return this.keyValues;
4180
+ }
4181
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: KeyValuePipe, deps: [{ token: i0.KeyValueDiffers }], target: i0.ɵɵFactoryTarget.Pipe });
4182
+ static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "19.2.6", ngImport: i0, type: KeyValuePipe, isStandalone: true, name: "keyvalue", pure: false });
4183
+ }
4184
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: KeyValuePipe, decorators: [{
4185
+ type: Pipe,
4186
+ args: [{
4187
+ name: 'keyvalue',
4188
+ pure: false,
4189
+ }]
4190
+ }], ctorParameters: () => [{ type: i0.KeyValueDiffers }] });
4191
+ function defaultComparator(keyValueA, keyValueB) {
4192
+ const a = keyValueA.key;
4193
+ const b = keyValueB.key;
4194
+ // If both keys are the same, return 0 (no sorting needed).
4195
+ if (a === b)
4196
+ return 0;
4197
+ // If one of the keys is `null` or `undefined`, place it at the end of the sort.
4198
+ if (a == null)
4199
+ return 1; // `a` comes after `b`.
4200
+ if (b == null)
4201
+ return -1; // `b` comes after `a`.
4202
+ // If both keys are strings, compare them lexicographically.
4203
+ if (typeof a == 'string' && typeof b == 'string') {
4204
+ return a < b ? -1 : 1;
4205
+ }
4206
+ // If both keys are numbers, sort them numerically.
4207
+ if (typeof a == 'number' && typeof b == 'number') {
4208
+ return a - b;
4209
+ }
4210
+ // If both keys are booleans, sort `false` before `true`.
4211
+ if (typeof a == 'boolean' && typeof b == 'boolean') {
4212
+ return a < b ? -1 : 1;
4213
+ }
4214
+ // Fallback case: if keys are of different types, compare their string representations.
4215
+ const aString = String(a);
4216
+ const bString = String(b);
4217
+ // Compare the string representations lexicographically.
4218
+ return aString == bString ? 0 : aString < bString ? -1 : 1;
4219
+ }
4220
+
4221
+ /**
4222
+ * @ngModule CommonModule
4223
+ * @description
4224
+ *
4225
+ * Formats a value according to digit options and locale rules.
4226
+ * Locale determines group sizing and separator,
4227
+ * decimal point character, and other locale-specific configurations.
4228
+ *
4229
+ * @see {@link formatNumber}
4230
+ *
4231
+ * @usageNotes
4232
+ *
4233
+ * ### digitsInfo
4234
+ *
4235
+ * The value's decimal representation is specified by the `digitsInfo`
4236
+ * parameter, written in the following format:<br>
4237
+ *
4238
+ * ```
4239
+ * {minIntegerDigits}.{minFractionDigits}-{maxFractionDigits}
4240
+ * ```
4241
+ *
4242
+ * - `minIntegerDigits`:
4243
+ * The minimum number of integer digits before the decimal point.
4244
+ * Default is 1.
4245
+ *
4246
+ * - `minFractionDigits`:
4247
+ * The minimum number of digits after the decimal point.
4248
+ * Default is 0.
4249
+ *
4250
+ * - `maxFractionDigits`:
4251
+ * The maximum number of digits after the decimal point.
4252
+ * Default is 3.
4253
+ *
4254
+ * If the formatted value is truncated it will be rounded using the "to-nearest" method:
4255
+ *
4256
+ * ```
4257
+ * {{3.6 | number: '1.0-0'}}
4258
+ * <!--will output '4'-->
4259
+ *
4260
+ * {{-3.6 | number:'1.0-0'}}
4261
+ * <!--will output '-4'-->
4262
+ * ```
4263
+ *
4264
+ * ### locale
4265
+ *
4266
+ * `locale` will format a value according to locale rules.
4267
+ * Locale determines group sizing and separator,
4268
+ * decimal point character, and other locale-specific configurations.
4269
+ *
4270
+ * When not supplied, uses the value of `LOCALE_ID`, which is `en-US` by default.
4271
+ *
4272
+ * See [Setting your app locale](guide/i18n/locale-id).
4273
+ *
4274
+ * ### Example
4275
+ *
4276
+ * The following code shows how the pipe transforms values
4277
+ * according to various format specifications,
4278
+ * where the caller's default locale is `en-US`.
4279
+ *
4280
+ * {@example common/pipes/ts/number_pipe.ts region='NumberPipe'}
4281
+ *
4282
+ * @publicApi
4283
+ */
4284
+ class DecimalPipe {
4285
+ _locale;
4286
+ constructor(_locale) {
4287
+ this._locale = _locale;
4288
+ }
4289
+ transform(value, digitsInfo, locale) {
4290
+ if (!isValue(value))
4291
+ return null;
4292
+ locale ||= this._locale;
4293
+ try {
4294
+ const num = strToNumber(value);
4295
+ return formatNumber(num, locale, digitsInfo);
4296
+ }
4297
+ catch (error) {
4298
+ throw invalidPipeArgumentError(DecimalPipe, error.message);
4299
+ }
4300
+ }
4301
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: DecimalPipe, deps: [{ token: LOCALE_ID }], target: i0.ɵɵFactoryTarget.Pipe });
4302
+ static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "19.2.6", ngImport: i0, type: DecimalPipe, isStandalone: true, name: "number" });
4303
+ }
4304
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: DecimalPipe, decorators: [{
4305
+ type: Pipe,
4306
+ args: [{
4307
+ name: 'number',
4308
+ }]
4309
+ }], ctorParameters: () => [{ type: undefined, decorators: [{
4310
+ type: Inject,
4311
+ args: [LOCALE_ID]
4312
+ }] }] });
4313
+ /**
4314
+ * @ngModule CommonModule
4315
+ * @description
4316
+ *
4317
+ * Transforms a number to a percentage
4318
+ * string, formatted according to locale rules that determine group sizing and
4319
+ * separator, decimal-point character, and other locale-specific
4320
+ * configurations.
4321
+ *
4322
+ * @see {@link formatPercent}
4323
+ *
4324
+ * @usageNotes
4325
+ * The following code shows how the pipe transforms numbers
4326
+ * into text strings, according to various format specifications,
4327
+ * where the caller's default locale is `en-US`.
4328
+ *
4329
+ * {@example common/pipes/ts/percent_pipe.ts region='PercentPipe'}
4330
+ *
4331
+ * @publicApi
4332
+ */
4333
+ class PercentPipe {
4334
+ _locale;
4335
+ constructor(_locale) {
4336
+ this._locale = _locale;
4337
+ }
4338
+ /**
4339
+ *
4340
+ * @param value The number to be formatted as a percentage.
4341
+ * @param digitsInfo Decimal representation options, specified by a string
4342
+ * in the following format:<br>
4343
+ * <code>{minIntegerDigits}.{minFractionDigits}-{maxFractionDigits}</code>.
4344
+ * - `minIntegerDigits`: The minimum number of integer digits before the decimal point.
4345
+ * Default is `1`.
4346
+ * - `minFractionDigits`: The minimum number of digits after the decimal point.
4347
+ * Default is `0`.
4348
+ * - `maxFractionDigits`: The maximum number of digits after the decimal point.
4349
+ * Default is `0`.
4350
+ * @param locale A locale code for the locale format rules to use.
4351
+ * When not supplied, uses the value of `LOCALE_ID`, which is `en-US` by default.
4352
+ * See [Setting your app locale](guide/i18n/locale-id).
4353
+ */
4354
+ transform(value, digitsInfo, locale) {
4355
+ if (!isValue(value))
4356
+ return null;
4357
+ locale ||= this._locale;
4358
+ try {
4359
+ const num = strToNumber(value);
4360
+ return formatPercent(num, locale, digitsInfo);
4361
+ }
4362
+ catch (error) {
4363
+ throw invalidPipeArgumentError(PercentPipe, error.message);
4364
+ }
4365
+ }
4366
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: PercentPipe, deps: [{ token: LOCALE_ID }], target: i0.ɵɵFactoryTarget.Pipe });
4367
+ static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "19.2.6", ngImport: i0, type: PercentPipe, isStandalone: true, name: "percent" });
4368
+ }
4369
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: PercentPipe, decorators: [{
4370
+ type: Pipe,
4371
+ args: [{
4372
+ name: 'percent',
4373
+ }]
4374
+ }], ctorParameters: () => [{ type: undefined, decorators: [{
4375
+ type: Inject,
4376
+ args: [LOCALE_ID]
4377
+ }] }] });
4378
+ /**
4379
+ * @ngModule CommonModule
4380
+ * @description
4381
+ *
4382
+ * Transforms a number to a currency string, formatted according to locale rules
4383
+ * that determine group sizing and separator, decimal-point character,
4384
+ * and other locale-specific configurations.
4385
+ *
4386
+ *
4387
+ * @see {@link getCurrencySymbol}
4388
+ * @see {@link formatCurrency}
4389
+ *
4390
+ * @usageNotes
4391
+ * The following code shows how the pipe transforms numbers
4392
+ * into text strings, according to various format specifications,
4393
+ * where the caller's default locale is `en-US`.
4394
+ *
4395
+ * {@example common/pipes/ts/currency_pipe.ts region='CurrencyPipe'}
4396
+ *
4397
+ * @publicApi
4398
+ */
4399
+ class CurrencyPipe {
4400
+ _locale;
4401
+ _defaultCurrencyCode;
4402
+ constructor(_locale, _defaultCurrencyCode = 'USD') {
4403
+ this._locale = _locale;
4404
+ this._defaultCurrencyCode = _defaultCurrencyCode;
4405
+ }
4406
+ transform(value, currencyCode = this._defaultCurrencyCode, display = 'symbol', digitsInfo, locale) {
4407
+ if (!isValue(value))
4408
+ return null;
4409
+ locale ||= this._locale;
4410
+ if (typeof display === 'boolean') {
4411
+ if ((typeof ngDevMode === 'undefined' || ngDevMode) && console && console.warn) {
4412
+ console.warn(`Warning: the currency pipe has been changed in Angular v5. The symbolDisplay option (third parameter) is now a string instead of a boolean. The accepted values are "code", "symbol" or "symbol-narrow".`);
4413
+ }
4414
+ display = display ? 'symbol' : 'code';
4415
+ }
4416
+ let currency = currencyCode || this._defaultCurrencyCode;
4417
+ if (display !== 'code') {
4418
+ if (display === 'symbol' || display === 'symbol-narrow') {
4419
+ currency = getCurrencySymbol(currency, display === 'symbol' ? 'wide' : 'narrow', locale);
4420
+ }
4421
+ else {
4422
+ currency = display;
4423
+ }
4424
+ }
4425
+ try {
4426
+ const num = strToNumber(value);
4427
+ return formatCurrency(num, locale, currency, currencyCode, digitsInfo);
4428
+ }
4429
+ catch (error) {
4430
+ throw invalidPipeArgumentError(CurrencyPipe, error.message);
4431
+ }
4432
+ }
4433
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: CurrencyPipe, deps: [{ token: LOCALE_ID }, { token: DEFAULT_CURRENCY_CODE }], target: i0.ɵɵFactoryTarget.Pipe });
4434
+ static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "19.2.6", ngImport: i0, type: CurrencyPipe, isStandalone: true, name: "currency" });
4435
+ }
4436
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: CurrencyPipe, decorators: [{
4437
+ type: Pipe,
4438
+ args: [{
4439
+ name: 'currency',
4440
+ }]
4441
+ }], ctorParameters: () => [{ type: undefined, decorators: [{
4442
+ type: Inject,
4443
+ args: [LOCALE_ID]
4444
+ }] }, { type: undefined, decorators: [{
4445
+ type: Inject,
4446
+ args: [DEFAULT_CURRENCY_CODE]
4447
+ }] }] });
4448
+ function isValue(value) {
4449
+ return !(value == null || value === '' || value !== value);
4450
+ }
4451
+ /**
4452
+ * Transforms a string into a number (if needed).
4453
+ */
4454
+ function strToNumber(value) {
4455
+ // Convert strings to numbers
4456
+ if (typeof value === 'string' && !isNaN(Number(value) - parseFloat(value))) {
4457
+ return Number(value);
4458
+ }
4459
+ if (typeof value !== 'number') {
4460
+ throw new Error(`${value} is not a number`);
4461
+ }
4462
+ return value;
4463
+ }
4464
+
4465
+ /**
4466
+ * @ngModule CommonModule
4467
+ * @description
4468
+ *
4469
+ * Creates a new `Array` or `String` containing a subset (slice) of the elements.
4470
+ *
4471
+ * @usageNotes
4472
+ *
4473
+ * All behavior is based on the expected behavior of the JavaScript API `Array.prototype.slice()`
4474
+ * and `String.prototype.slice()`.
4475
+ *
4476
+ * When operating on an `Array`, the returned `Array` is always a copy even when all
4477
+ * the elements are being returned.
4478
+ *
4479
+ * When operating on a blank value, the pipe returns the blank value.
4480
+ *
4481
+ * ### List Example
4482
+ *
4483
+ * This `ngFor` example:
4484
+ *
4485
+ * {@example common/pipes/ts/slice_pipe.ts region='SlicePipe_list'}
4486
+ *
4487
+ * produces the following:
4488
+ *
4489
+ * ```html
4490
+ * <li>b</li>
4491
+ * <li>c</li>
4492
+ * ```
4493
+ *
4494
+ * ### String Examples
4495
+ *
4496
+ * {@example common/pipes/ts/slice_pipe.ts region='SlicePipe_string'}
4497
+ *
4498
+ * @publicApi
4499
+ */
4500
+ class SlicePipe {
4501
+ transform(value, start, end) {
4502
+ if (value == null)
4503
+ return null;
4504
+ const supports = typeof value === 'string' || Array.isArray(value);
4505
+ if (!supports) {
4506
+ throw invalidPipeArgumentError(SlicePipe, value);
4507
+ }
4508
+ return value.slice(start, end);
4509
+ }
4510
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: SlicePipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
4511
+ static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "19.2.6", ngImport: i0, type: SlicePipe, isStandalone: true, name: "slice", pure: false });
4512
+ }
4513
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: SlicePipe, decorators: [{
4514
+ type: Pipe,
4515
+ args: [{
4516
+ name: 'slice',
4517
+ pure: false,
4518
+ }]
4519
+ }] });
4520
+
4521
+ /**
4522
+ * @module
4523
+ * @description
4524
+ * This module provides a set of common Pipes.
4525
+ */
4526
+ /**
4527
+ * A collection of Angular pipes that are likely to be used in each and every application.
4528
+ */
4529
+ const COMMON_PIPES = [
4530
+ AsyncPipe,
4531
+ UpperCasePipe,
4532
+ LowerCasePipe,
4533
+ JsonPipe,
4534
+ SlicePipe,
4535
+ DecimalPipe,
4536
+ PercentPipe,
4537
+ TitleCasePipe,
4538
+ CurrencyPipe,
4539
+ DatePipe,
4540
+ I18nPluralPipe,
4541
+ I18nSelectPipe,
4542
+ KeyValuePipe,
4543
+ ];
4544
+
4545
+ // Note: This does not contain the location providers,
4546
+ // as they need some platform specific implementations to work.
4547
+ /**
4548
+ * Exports all the basic Angular directives and pipes,
4549
+ * such as `NgIf`, `NgForOf`, `DecimalPipe`, and so on.
4550
+ * Re-exported by `BrowserModule`, which is included automatically in the root
4551
+ * `AppModule` when you create a new app with the CLI `new` command.
4552
+ *
4553
+ * @publicApi
4554
+ */
4555
+ class CommonModule {
4556
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: CommonModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
4557
+ static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "19.2.6", ngImport: i0, type: CommonModule, imports: [NgClass, NgComponentOutlet, NgForOf, NgIf, NgTemplateOutlet, NgStyle, NgSwitch, NgSwitchCase, NgSwitchDefault, NgPlural, NgPluralCase, AsyncPipe, UpperCasePipe, LowerCasePipe, JsonPipe, SlicePipe, DecimalPipe, PercentPipe, TitleCasePipe, CurrencyPipe, DatePipe, I18nPluralPipe, I18nSelectPipe, KeyValuePipe], exports: [NgClass, NgComponentOutlet, NgForOf, NgIf, NgTemplateOutlet, NgStyle, NgSwitch, NgSwitchCase, NgSwitchDefault, NgPlural, NgPluralCase, AsyncPipe, UpperCasePipe, LowerCasePipe, JsonPipe, SlicePipe, DecimalPipe, PercentPipe, TitleCasePipe, CurrencyPipe, DatePipe, I18nPluralPipe, I18nSelectPipe, KeyValuePipe] });
4558
+ static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: CommonModule });
4559
+ }
4560
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: CommonModule, decorators: [{
4561
+ type: NgModule,
4562
+ args: [{
4563
+ imports: [COMMON_DIRECTIVES, COMMON_PIPES],
4564
+ exports: [COMMON_DIRECTIVES, COMMON_PIPES],
4565
+ }]
4566
+ }] });
4567
+
4568
+ export { AsyncPipe, CommonModule, CurrencyPipe, DATE_PIPE_DEFAULT_OPTIONS, DATE_PIPE_DEFAULT_TIMEZONE, DatePipe, DecimalPipe, FormStyle, FormatWidth, HashLocationStrategy, I18nPluralPipe, I18nSelectPipe, JsonPipe, KeyValuePipe, LowerCasePipe, NgClass, NgComponentOutlet, NgForOf, NgForOfContext, NgIf, NgIfContext, NgLocaleLocalization, NgLocalization, NgPlural, NgPluralCase, NgStyle, NgSwitch, NgSwitchCase, NgSwitchDefault, NgTemplateOutlet, NumberFormatStyle, NumberSymbol, PercentPipe, Plural, SlicePipe, TitleCasePipe, TranslationWidth, UpperCasePipe, WeekDay, formatCurrency, formatDate, formatNumber, formatPercent, getCurrencySymbol, getLocaleCurrencyCode, getLocaleCurrencyName, getLocaleCurrencySymbol, getLocaleDateFormat, getLocaleDateTimeFormat, getLocaleDayNames, getLocaleDayPeriods, getLocaleDirection, getLocaleEraNames, getLocaleExtraDayPeriodRules, getLocaleExtraDayPeriods, getLocaleFirstDayOfWeek, getLocaleId, getLocaleMonthNames, getLocaleNumberFormat, getLocaleNumberSymbol, getLocalePluralCase, getLocaleTimeFormat, getLocaleWeekEndRange, getNumberOfCurrencyDigits };
4569
+ //# sourceMappingURL=common_module-CBrzkrmd.mjs.map