@angular/common 20.0.0-next.3 → 20.0.0-next.5

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,4601 @@
1
+ /**
2
+ * @license Angular v20.0.0-next.5
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, ɵRuntimeError as _RuntimeError, ɵformatRuntimeError as _formatRuntimeError, LOCALE_ID, ɵstringify as _stringify, Input, Directive, createNgModule, NgModuleRef, Host, Attribute, RendererStyleFlags2, inject, ɵINTERNAL_APPLICATION_ERROR_HANDLER as _INTERNAL_APPLICATION_ERROR_HANDLER, ɵisPromise as _isPromise, ɵisSubscribable as _isSubscribable, untracked, Pipe, InjectionToken, DEFAULT_CURRENCY_CODE, NgModule } from '@angular/core';
9
+ import { a as LocationStrategy, j as joinWithSlash, n as normalizeQueryParams, c as PlatformLocation, A as APP_BASE_HREF } from './location-DL4aRLmc.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: "20.0.0-next.5", 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: "20.0.0-next.5", ngImport: i0, type: HashLocationStrategy });
86
+ }
87
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.0-next.5", 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 _RuntimeError(2303 /* RuntimeErrorCode.MISSING_EXTRA_LOCALE_DATA_FOR_LOCALE */, ngDevMode &&
647
+ `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.`);
648
+ }
649
+ }
650
+ /**
651
+ * Retrieves locale-specific rules used to determine which day period to use
652
+ * when more than one period is defined for a locale.
653
+ *
654
+ * There is a rule for each defined day period. The
655
+ * first rule is applied to the first day period and so on.
656
+ * Fall back to AM/PM when no rules are available.
657
+ *
658
+ * A rule can specify a period as time range, or as a single time value.
659
+ *
660
+ * This functionality is only available when you have loaded the full locale data.
661
+ * See the ["I18n guide"](guide/i18n/format-data-locale).
662
+ *
663
+ * @param locale A locale code for the locale format rules to use.
664
+ * @returns The rules for the locale, a single time value or array of *from-time, to-time*,
665
+ * or null if no periods are available.
666
+ *
667
+ * @see {@link getLocaleExtraDayPeriods}
668
+ * @see [Internationalization (i18n) Guide](guide/i18n)
669
+ *
670
+ * @publicApi
671
+ *
672
+ * @deprecated Angular recommends relying on the `Intl` API for i18n.
673
+ * Let `Intl.DateTimeFormat` determine the day period instead.
674
+ */
675
+ function getLocaleExtraDayPeriodRules(locale) {
676
+ const data = _findLocaleData(locale);
677
+ checkFullData(data);
678
+ const rules = data[_LocaleDataIndex.ExtraData][2 /* ɵExtraLocaleDataIndex.ExtraDayPeriodsRules */] || [];
679
+ return rules.map((rule) => {
680
+ if (typeof rule === 'string') {
681
+ return extractTime(rule);
682
+ }
683
+ return [extractTime(rule[0]), extractTime(rule[1])];
684
+ });
685
+ }
686
+ /**
687
+ * Retrieves locale-specific day periods, which indicate roughly how a day is broken up
688
+ * in different languages.
689
+ * For example, for `en-US`, periods are morning, noon, afternoon, evening, and midnight.
690
+ *
691
+ * This functionality is only available when you have loaded the full locale data.
692
+ * See the ["I18n guide"](guide/i18n/format-data-locale).
693
+ *
694
+ * @param locale A locale code for the locale format rules to use.
695
+ * @param formStyle The required grammatical form.
696
+ * @param width The required character width.
697
+ * @returns The translated day-period strings.
698
+ * @see {@link getLocaleExtraDayPeriodRules}
699
+ * @see [Internationalization (i18n) Guide](guide/i18n)
700
+ *
701
+ * @publicApi
702
+ *
703
+ * @deprecated Angular recommends relying on the `Intl` API for i18n.
704
+ * To extract a day period use `Intl.DateTimeFormat` with the `dayPeriod` option instead.
705
+ */
706
+ function getLocaleExtraDayPeriods(locale, formStyle, width) {
707
+ const data = _findLocaleData(locale);
708
+ checkFullData(data);
709
+ const dayPeriodsData = [
710
+ data[_LocaleDataIndex.ExtraData][0 /* ɵExtraLocaleDataIndex.ExtraDayPeriodFormats */],
711
+ data[_LocaleDataIndex.ExtraData][1 /* ɵExtraLocaleDataIndex.ExtraDayPeriodStandalone */],
712
+ ];
713
+ const dayPeriods = getLastDefinedValue(dayPeriodsData, formStyle) || [];
714
+ return getLastDefinedValue(dayPeriods, width) || [];
715
+ }
716
+ /**
717
+ * Retrieves the writing direction of a specified locale
718
+ * @param locale A locale code for the locale format rules to use.
719
+ * @publicApi
720
+ * @returns 'rtl' or 'ltr'
721
+ * @see [Internationalization (i18n) Guide](guide/i18n)
722
+ *
723
+ * @deprecated Angular recommends relying on the `Intl` API for i18n.
724
+ * For dates and numbers, let `Intl.DateTimeFormat()` and `Intl.NumberFormat()` determine the writing direction.
725
+ * The `Intl` alternative [`getTextInfo`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/getTextInfo).
726
+ * has only partial support (Chromium M99 & Safari 17).
727
+ * 3rd party alternatives like [`rtl-detect`](https://www.npmjs.com/package/rtl-detect) can work around this issue.
728
+ */
729
+ function getLocaleDirection(locale) {
730
+ const data = _findLocaleData(locale);
731
+ return data[_LocaleDataIndex.Directionality];
732
+ }
733
+ /**
734
+ * Retrieves the first value that is defined in an array, going backwards from an index position.
735
+ *
736
+ * To avoid repeating the same data (as when the "format" and "standalone" forms are the same)
737
+ * add the first value to the locale data arrays, and add other values only if they are different.
738
+ *
739
+ * @param data The data array to retrieve from.
740
+ * @param index A 0-based index into the array to start from.
741
+ * @returns The value immediately before the given index position.
742
+ * @see [Internationalization (i18n) Guide](guide/i18n)
743
+ *
744
+ */
745
+ function getLastDefinedValue(data, index) {
746
+ for (let i = index; i > -1; i--) {
747
+ if (typeof data[i] !== 'undefined') {
748
+ return data[i];
749
+ }
750
+ }
751
+ throw new _RuntimeError(2304 /* RuntimeErrorCode.LOCALE_DATA_UNDEFINED */, ngDevMode && 'Locale data API: locale data undefined');
752
+ }
753
+ /**
754
+ * Extracts the hours and minutes from a string like "15:45"
755
+ */
756
+ function extractTime(time) {
757
+ const [h, m] = time.split(':');
758
+ return { hours: +h, minutes: +m };
759
+ }
760
+ /**
761
+ * Retrieves the currency symbol for a given currency code.
762
+ *
763
+ * For example, for the default `en-US` locale, the code `USD` can
764
+ * be represented by the narrow symbol `$` or the wide symbol `US$`.
765
+ *
766
+ * @param code The currency code.
767
+ * @param format The format, `wide` or `narrow`.
768
+ * @param locale A locale code for the locale format rules to use.
769
+ *
770
+ * @returns The symbol, or the currency code if no symbol is available.
771
+ * @see [Internationalization (i18n) Guide](guide/i18n)
772
+ *
773
+ * @publicApi
774
+ *
775
+ * @deprecated Angular recommends relying on the `Intl` API for i18n.
776
+ * You can use `Intl.NumberFormat().formatToParts()` to extract the currency symbol.
777
+ * For example: `Intl.NumberFormat('en', {style:'currency', currency: 'USD'}).formatToParts().find(part => part.type === 'currency').value`
778
+ * returns `$` for USD currency code in the `en` locale.
779
+ * Note: `US$` is a currency symbol for the `en-ca` locale but not the `en-us` locale.
780
+ */
781
+ function getCurrencySymbol(code, format, locale = 'en') {
782
+ const currency = getLocaleCurrencies(locale)[code] || CURRENCIES_EN[code] || [];
783
+ const symbolNarrow = currency[1 /* ɵCurrencyIndex.SymbolNarrow */];
784
+ if (format === 'narrow' && typeof symbolNarrow === 'string') {
785
+ return symbolNarrow;
786
+ }
787
+ return currency[0 /* ɵCurrencyIndex.Symbol */] || code;
788
+ }
789
+ // Most currencies have cents, that's why the default is 2
790
+ const DEFAULT_NB_OF_CURRENCY_DIGITS = 2;
791
+ /**
792
+ * Reports the number of decimal digits for a given currency.
793
+ * The value depends upon the presence of cents in that particular currency.
794
+ *
795
+ * @param code The currency code.
796
+ * @returns The number of decimal digits, typically 0 or 2.
797
+ * @see [Internationalization (i18n) Guide](guide/i18n)
798
+ *
799
+ * @publicApi
800
+ *
801
+ * @deprecated Angular recommends relying on the `Intl` API for i18n.
802
+ * This function should not be used anymore. Let `Intl.NumberFormat` determine the number of digits to display for the currency
803
+ */
804
+ function getNumberOfCurrencyDigits(code) {
805
+ let digits;
806
+ const currency = CURRENCIES_EN[code];
807
+ if (currency) {
808
+ digits = currency[2 /* ɵCurrencyIndex.NbOfDigits */];
809
+ }
810
+ return typeof digits === 'number' ? digits : DEFAULT_NB_OF_CURRENCY_DIGITS;
811
+ }
812
+
813
+ const ISO8601_DATE_REGEX = /^(\d{4,})-?(\d\d)-?(\d\d)(?:T(\d\d)(?::?(\d\d)(?::?(\d\d)(?:\.(\d+))?)?)?(Z|([+-])(\d\d):?(\d\d))?)?$/;
814
+ // 1 2 3 4 5 6 7 8 9 10 11
815
+ const NAMED_FORMATS = {};
816
+ 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]*)/;
817
+ /**
818
+ * @ngModule CommonModule
819
+ * @description
820
+ *
821
+ * Formats a date according to locale rules.
822
+ *
823
+ * @param value The date to format, as a Date, or a number (milliseconds since UTC epoch)
824
+ * or an [ISO date-time string](https://www.w3.org/TR/NOTE-datetime).
825
+ * @param format The date-time components to include. See `DatePipe` for details.
826
+ * @param locale A locale code for the locale format rules to use.
827
+ * @param timezone The time zone. A time zone offset from GMT (such as `'+0430'`).
828
+ * If not specified, uses host system settings.
829
+ *
830
+ * @returns The formatted date string.
831
+ *
832
+ * @see {@link DatePipe}
833
+ * @see [Internationalization (i18n) Guide](guide/i18n)
834
+ *
835
+ * @publicApi
836
+ */
837
+ function formatDate(value, format, locale, timezone) {
838
+ let date = toDate(value);
839
+ const namedFormat = getNamedFormat(locale, format);
840
+ format = namedFormat || format;
841
+ let parts = [];
842
+ let match;
843
+ while (format) {
844
+ match = DATE_FORMATS_SPLIT.exec(format);
845
+ if (match) {
846
+ parts = parts.concat(match.slice(1));
847
+ const part = parts.pop();
848
+ if (!part) {
849
+ break;
850
+ }
851
+ format = part;
852
+ }
853
+ else {
854
+ parts.push(format);
855
+ break;
856
+ }
857
+ }
858
+ if (typeof ngDevMode === 'undefined' || ngDevMode) {
859
+ assertValidDateFormat(parts);
860
+ }
861
+ let dateTimezoneOffset = date.getTimezoneOffset();
862
+ if (timezone) {
863
+ dateTimezoneOffset = timezoneToOffset(timezone, dateTimezoneOffset);
864
+ date = convertTimezoneToLocal(date, timezone);
865
+ }
866
+ let text = '';
867
+ parts.forEach((value) => {
868
+ const dateFormatter = getDateFormatter(value);
869
+ text += dateFormatter
870
+ ? dateFormatter(date, locale, dateTimezoneOffset)
871
+ : value === "''"
872
+ ? "'"
873
+ : value.replace(/(^'|'$)/g, '').replace(/''/g, "'");
874
+ });
875
+ return text;
876
+ }
877
+ /**
878
+ * Asserts that the given date format is free from common mistakes. Throws an
879
+ * error if one is found (except for the case of all "Y", in which case we just
880
+ * log a warning). This should only be called in development mode.
881
+ */
882
+ function assertValidDateFormat(parts) {
883
+ if (parts.some((part) => /^Y+$/.test(part)) && !parts.some((part) => /^w+$/.test(part))) {
884
+ // "Y" indicates "week-based year", which differs from the actual calendar
885
+ // year for a few days around Jan 1 most years. Unless "w" is also
886
+ // present (e.g. a date like "2024-W52") this is likely a mistake. Users
887
+ // probably meant "y" instead.
888
+ const message = `Suspicious use of week-based year "Y" in date pattern "${parts.join('')}". Did you mean to use calendar year "y" instead?`;
889
+ if (parts.length === 1) {
890
+ // NOTE: allow "YYYY" with just a warning, since it's used in tests.
891
+ console.error(_formatRuntimeError(2300 /* RuntimeErrorCode.SUSPICIOUS_DATE_FORMAT */, message));
892
+ }
893
+ else {
894
+ throw new _RuntimeError(2300 /* RuntimeErrorCode.SUSPICIOUS_DATE_FORMAT */, message);
895
+ }
896
+ }
897
+ }
898
+ /**
899
+ * Create a new Date object with the given date value, and the time set to midnight.
900
+ *
901
+ * We cannot use `new Date(year, month, date)` because it maps years between 0 and 99 to 1900-1999.
902
+ * See: https://github.com/angular/angular/issues/40377
903
+ *
904
+ * Note that this function returns a Date object whose time is midnight in the current locale's
905
+ * timezone. In the future we might want to change this to be midnight in UTC, but this would be a
906
+ * considerable breaking change.
907
+ */
908
+ function createDate(year, month, date) {
909
+ // The `newDate` is set to midnight (UTC) on January 1st 1970.
910
+ // - In PST this will be December 31st 1969 at 4pm.
911
+ // - In GMT this will be January 1st 1970 at 1am.
912
+ // Note that they even have different years, dates and months!
913
+ const newDate = new Date(0);
914
+ // `setFullYear()` allows years like 0001 to be set correctly. This function does not
915
+ // change the internal time of the date.
916
+ // Consider calling `setFullYear(2019, 8, 20)` (September 20, 2019).
917
+ // - In PST this will now be September 20, 2019 at 4pm
918
+ // - In GMT this will now be September 20, 2019 at 1am
919
+ newDate.setFullYear(year, month, date);
920
+ // We want the final date to be at local midnight, so we reset the time.
921
+ // - In PST this will now be September 20, 2019 at 12am
922
+ // - In GMT this will now be September 20, 2019 at 12am
923
+ newDate.setHours(0, 0, 0);
924
+ return newDate;
925
+ }
926
+ function getNamedFormat(locale, format) {
927
+ const localeId = getLocaleId(locale);
928
+ NAMED_FORMATS[localeId] ??= {};
929
+ if (NAMED_FORMATS[localeId][format]) {
930
+ return NAMED_FORMATS[localeId][format];
931
+ }
932
+ let formatValue = '';
933
+ switch (format) {
934
+ case 'shortDate':
935
+ formatValue = getLocaleDateFormat(locale, FormatWidth.Short);
936
+ break;
937
+ case 'mediumDate':
938
+ formatValue = getLocaleDateFormat(locale, FormatWidth.Medium);
939
+ break;
940
+ case 'longDate':
941
+ formatValue = getLocaleDateFormat(locale, FormatWidth.Long);
942
+ break;
943
+ case 'fullDate':
944
+ formatValue = getLocaleDateFormat(locale, FormatWidth.Full);
945
+ break;
946
+ case 'shortTime':
947
+ formatValue = getLocaleTimeFormat(locale, FormatWidth.Short);
948
+ break;
949
+ case 'mediumTime':
950
+ formatValue = getLocaleTimeFormat(locale, FormatWidth.Medium);
951
+ break;
952
+ case 'longTime':
953
+ formatValue = getLocaleTimeFormat(locale, FormatWidth.Long);
954
+ break;
955
+ case 'fullTime':
956
+ formatValue = getLocaleTimeFormat(locale, FormatWidth.Full);
957
+ break;
958
+ case 'short':
959
+ const shortTime = getNamedFormat(locale, 'shortTime');
960
+ const shortDate = getNamedFormat(locale, 'shortDate');
961
+ formatValue = formatDateTime(getLocaleDateTimeFormat(locale, FormatWidth.Short), [
962
+ shortTime,
963
+ shortDate,
964
+ ]);
965
+ break;
966
+ case 'medium':
967
+ const mediumTime = getNamedFormat(locale, 'mediumTime');
968
+ const mediumDate = getNamedFormat(locale, 'mediumDate');
969
+ formatValue = formatDateTime(getLocaleDateTimeFormat(locale, FormatWidth.Medium), [
970
+ mediumTime,
971
+ mediumDate,
972
+ ]);
973
+ break;
974
+ case 'long':
975
+ const longTime = getNamedFormat(locale, 'longTime');
976
+ const longDate = getNamedFormat(locale, 'longDate');
977
+ formatValue = formatDateTime(getLocaleDateTimeFormat(locale, FormatWidth.Long), [
978
+ longTime,
979
+ longDate,
980
+ ]);
981
+ break;
982
+ case 'full':
983
+ const fullTime = getNamedFormat(locale, 'fullTime');
984
+ const fullDate = getNamedFormat(locale, 'fullDate');
985
+ formatValue = formatDateTime(getLocaleDateTimeFormat(locale, FormatWidth.Full), [
986
+ fullTime,
987
+ fullDate,
988
+ ]);
989
+ break;
990
+ }
991
+ if (formatValue) {
992
+ NAMED_FORMATS[localeId][format] = formatValue;
993
+ }
994
+ return formatValue;
995
+ }
996
+ function formatDateTime(str, opt_values) {
997
+ if (opt_values) {
998
+ str = str.replace(/\{([^}]+)}/g, function (match, key) {
999
+ return opt_values != null && key in opt_values ? opt_values[key] : match;
1000
+ });
1001
+ }
1002
+ return str;
1003
+ }
1004
+ function padNumber(num, digits, minusSign = '-', trim, negWrap) {
1005
+ let neg = '';
1006
+ if (num < 0 || (negWrap && num <= 0)) {
1007
+ if (negWrap) {
1008
+ num = -num + 1;
1009
+ }
1010
+ else {
1011
+ num = -num;
1012
+ neg = minusSign;
1013
+ }
1014
+ }
1015
+ let strNum = String(num);
1016
+ while (strNum.length < digits) {
1017
+ strNum = '0' + strNum;
1018
+ }
1019
+ if (trim) {
1020
+ strNum = strNum.slice(strNum.length - digits);
1021
+ }
1022
+ return neg + strNum;
1023
+ }
1024
+ function formatFractionalSeconds(milliseconds, digits) {
1025
+ const strMs = padNumber(milliseconds, 3);
1026
+ return strMs.substring(0, digits);
1027
+ }
1028
+ /**
1029
+ * Returns a date formatter that transforms a date into its locale digit representation
1030
+ */
1031
+ function dateGetter(name, size, offset = 0, trim = false, negWrap = false) {
1032
+ return function (date, locale) {
1033
+ let part = getDatePart(name, date);
1034
+ if (offset > 0 || part > -offset) {
1035
+ part += offset;
1036
+ }
1037
+ if (name === 3 /* DateType.Hours */) {
1038
+ if (part === 0 && offset === -12) {
1039
+ part = 12;
1040
+ }
1041
+ }
1042
+ else if (name === 6 /* DateType.FractionalSeconds */) {
1043
+ return formatFractionalSeconds(part, size);
1044
+ }
1045
+ const localeMinus = getLocaleNumberSymbol(locale, NumberSymbol.MinusSign);
1046
+ return padNumber(part, size, localeMinus, trim, negWrap);
1047
+ };
1048
+ }
1049
+ function getDatePart(part, date) {
1050
+ switch (part) {
1051
+ case 0 /* DateType.FullYear */:
1052
+ return date.getFullYear();
1053
+ case 1 /* DateType.Month */:
1054
+ return date.getMonth();
1055
+ case 2 /* DateType.Date */:
1056
+ return date.getDate();
1057
+ case 3 /* DateType.Hours */:
1058
+ return date.getHours();
1059
+ case 4 /* DateType.Minutes */:
1060
+ return date.getMinutes();
1061
+ case 5 /* DateType.Seconds */:
1062
+ return date.getSeconds();
1063
+ case 6 /* DateType.FractionalSeconds */:
1064
+ return date.getMilliseconds();
1065
+ case 7 /* DateType.Day */:
1066
+ return date.getDay();
1067
+ default:
1068
+ throw new _RuntimeError(2301 /* RuntimeErrorCode.UNKNOWN_DATE_TYPE_VALUE */, ngDevMode && `Unknown DateType value "${part}".`);
1069
+ }
1070
+ }
1071
+ /**
1072
+ * Returns a date formatter that transforms a date into its locale string representation
1073
+ */
1074
+ function dateStrGetter(name, width, form = FormStyle.Format, extended = false) {
1075
+ return function (date, locale) {
1076
+ return getDateTranslation(date, locale, name, width, form, extended);
1077
+ };
1078
+ }
1079
+ /**
1080
+ * Returns the locale translation of a date for a given form, type and width
1081
+ */
1082
+ function getDateTranslation(date, locale, name, width, form, extended) {
1083
+ switch (name) {
1084
+ case 2 /* TranslationType.Months */:
1085
+ return getLocaleMonthNames(locale, form, width)[date.getMonth()];
1086
+ case 1 /* TranslationType.Days */:
1087
+ return getLocaleDayNames(locale, form, width)[date.getDay()];
1088
+ case 0 /* TranslationType.DayPeriods */:
1089
+ const currentHours = date.getHours();
1090
+ const currentMinutes = date.getMinutes();
1091
+ if (extended) {
1092
+ const rules = getLocaleExtraDayPeriodRules(locale);
1093
+ const dayPeriods = getLocaleExtraDayPeriods(locale, form, width);
1094
+ const index = rules.findIndex((rule) => {
1095
+ if (Array.isArray(rule)) {
1096
+ // morning, afternoon, evening, night
1097
+ const [from, to] = rule;
1098
+ const afterFrom = currentHours >= from.hours && currentMinutes >= from.minutes;
1099
+ const beforeTo = currentHours < to.hours || (currentHours === to.hours && currentMinutes < to.minutes);
1100
+ // We must account for normal rules that span a period during the day (e.g. 6am-9am)
1101
+ // where `from` is less (earlier) than `to`. But also rules that span midnight (e.g.
1102
+ // 10pm - 5am) where `from` is greater (later!) than `to`.
1103
+ //
1104
+ // In the first case the current time must be BOTH after `from` AND before `to`
1105
+ // (e.g. 8am is after 6am AND before 10am).
1106
+ //
1107
+ // In the second case the current time must be EITHER after `from` OR before `to`
1108
+ // (e.g. 4am is before 5am but not after 10pm; and 11pm is not before 5am but it is
1109
+ // after 10pm).
1110
+ if (from.hours < to.hours) {
1111
+ if (afterFrom && beforeTo) {
1112
+ return true;
1113
+ }
1114
+ }
1115
+ else if (afterFrom || beforeTo) {
1116
+ return true;
1117
+ }
1118
+ }
1119
+ else {
1120
+ // noon or midnight
1121
+ if (rule.hours === currentHours && rule.minutes === currentMinutes) {
1122
+ return true;
1123
+ }
1124
+ }
1125
+ return false;
1126
+ });
1127
+ if (index !== -1) {
1128
+ return dayPeriods[index];
1129
+ }
1130
+ }
1131
+ // if no rules for the day periods, we use am/pm by default
1132
+ return getLocaleDayPeriods(locale, form, width)[currentHours < 12 ? 0 : 1];
1133
+ case 3 /* TranslationType.Eras */:
1134
+ return getLocaleEraNames(locale, width)[date.getFullYear() <= 0 ? 0 : 1];
1135
+ default:
1136
+ // This default case is not needed by TypeScript compiler, as the switch is exhaustive.
1137
+ // However Closure Compiler does not understand that and reports an error in typed mode.
1138
+ // The `throw new Error` below works around the problem, and the unexpected: never variable
1139
+ // makes sure tsc still checks this code is unreachable.
1140
+ const unexpected = name;
1141
+ throw new _RuntimeError(2302 /* RuntimeErrorCode.UNEXPECTED_TRANSLATION_TYPE */, ngDevMode && `unexpected translation type ${unexpected}`);
1142
+ }
1143
+ }
1144
+ /**
1145
+ * Returns a date formatter that transforms a date and an offset into a timezone with ISO8601 or
1146
+ * GMT format depending on the width (eg: short = +0430, short:GMT = GMT+4, long = GMT+04:30,
1147
+ * extended = +04:30)
1148
+ */
1149
+ function timeZoneGetter(width) {
1150
+ return function (date, locale, offset) {
1151
+ const zone = -1 * offset;
1152
+ const minusSign = getLocaleNumberSymbol(locale, NumberSymbol.MinusSign);
1153
+ const hours = zone > 0 ? Math.floor(zone / 60) : Math.ceil(zone / 60);
1154
+ switch (width) {
1155
+ case 0 /* ZoneWidth.Short */:
1156
+ return ((zone >= 0 ? '+' : '') +
1157
+ padNumber(hours, 2, minusSign) +
1158
+ padNumber(Math.abs(zone % 60), 2, minusSign));
1159
+ case 1 /* ZoneWidth.ShortGMT */:
1160
+ return 'GMT' + (zone >= 0 ? '+' : '') + padNumber(hours, 1, minusSign);
1161
+ case 2 /* ZoneWidth.Long */:
1162
+ return ('GMT' +
1163
+ (zone >= 0 ? '+' : '') +
1164
+ padNumber(hours, 2, minusSign) +
1165
+ ':' +
1166
+ padNumber(Math.abs(zone % 60), 2, minusSign));
1167
+ case 3 /* ZoneWidth.Extended */:
1168
+ if (offset === 0) {
1169
+ return 'Z';
1170
+ }
1171
+ else {
1172
+ return ((zone >= 0 ? '+' : '') +
1173
+ padNumber(hours, 2, minusSign) +
1174
+ ':' +
1175
+ padNumber(Math.abs(zone % 60), 2, minusSign));
1176
+ }
1177
+ default:
1178
+ throw new _RuntimeError(2302 /* RuntimeErrorCode.UNKNOWN_ZONE_WIDTH */, ngDevMode && `Unknown zone width "${width}"`);
1179
+ }
1180
+ };
1181
+ }
1182
+ const JANUARY = 0;
1183
+ const THURSDAY = 4;
1184
+ function getFirstThursdayOfYear(year) {
1185
+ const firstDayOfYear = createDate(year, JANUARY, 1).getDay();
1186
+ return createDate(year, 0, 1 + (firstDayOfYear <= THURSDAY ? THURSDAY : THURSDAY + 7) - firstDayOfYear);
1187
+ }
1188
+ /**
1189
+ * ISO Week starts on day 1 (Monday) and ends with day 0 (Sunday)
1190
+ */
1191
+ function getThursdayThisIsoWeek(datetime) {
1192
+ // getDay returns 0-6 range with sunday as 0.
1193
+ const currentDay = datetime.getDay();
1194
+ // On a Sunday, read the previous Thursday since ISO weeks start on Monday.
1195
+ const deltaToThursday = currentDay === 0 ? -3 : THURSDAY - currentDay;
1196
+ return createDate(datetime.getFullYear(), datetime.getMonth(), datetime.getDate() + deltaToThursday);
1197
+ }
1198
+ function weekGetter(size, monthBased = false) {
1199
+ return function (date, locale) {
1200
+ let result;
1201
+ if (monthBased) {
1202
+ const nbDaysBefore1stDayOfMonth = new Date(date.getFullYear(), date.getMonth(), 1).getDay() - 1;
1203
+ const today = date.getDate();
1204
+ result = 1 + Math.floor((today + nbDaysBefore1stDayOfMonth) / 7);
1205
+ }
1206
+ else {
1207
+ const thisThurs = getThursdayThisIsoWeek(date);
1208
+ // Some days of a year are part of next year according to ISO 8601.
1209
+ // Compute the firstThurs from the year of this week's Thursday
1210
+ const firstThurs = getFirstThursdayOfYear(thisThurs.getFullYear());
1211
+ const diff = thisThurs.getTime() - firstThurs.getTime();
1212
+ result = 1 + Math.round(diff / 6.048e8); // 6.048e8 ms per week
1213
+ }
1214
+ return padNumber(result, size, getLocaleNumberSymbol(locale, NumberSymbol.MinusSign));
1215
+ };
1216
+ }
1217
+ /**
1218
+ * Returns a date formatter that provides the week-numbering year for the input date.
1219
+ */
1220
+ function weekNumberingYearGetter(size, trim = false) {
1221
+ return function (date, locale) {
1222
+ const thisThurs = getThursdayThisIsoWeek(date);
1223
+ const weekNumberingYear = thisThurs.getFullYear();
1224
+ return padNumber(weekNumberingYear, size, getLocaleNumberSymbol(locale, NumberSymbol.MinusSign), trim);
1225
+ };
1226
+ }
1227
+ const DATE_FORMATS = {};
1228
+ // Based on CLDR formats:
1229
+ // See complete list: http://www.unicode.org/reports/tr35/tr35-dates.html#Date_Field_Symbol_Table
1230
+ // See also explanations: http://cldr.unicode.org/translation/date-time
1231
+ // TODO(ocombe): support all missing cldr formats: U, Q, D, F, e, j, J, C, A, v, V, X, x
1232
+ function getDateFormatter(format) {
1233
+ if (DATE_FORMATS[format]) {
1234
+ return DATE_FORMATS[format];
1235
+ }
1236
+ let formatter;
1237
+ switch (format) {
1238
+ // Era name (AD/BC)
1239
+ case 'G':
1240
+ case 'GG':
1241
+ case 'GGG':
1242
+ formatter = dateStrGetter(3 /* TranslationType.Eras */, TranslationWidth.Abbreviated);
1243
+ break;
1244
+ case 'GGGG':
1245
+ formatter = dateStrGetter(3 /* TranslationType.Eras */, TranslationWidth.Wide);
1246
+ break;
1247
+ case 'GGGGG':
1248
+ formatter = dateStrGetter(3 /* TranslationType.Eras */, TranslationWidth.Narrow);
1249
+ break;
1250
+ // 1 digit representation of the year, e.g. (AD 1 => 1, AD 199 => 199)
1251
+ case 'y':
1252
+ formatter = dateGetter(0 /* DateType.FullYear */, 1, 0, false, true);
1253
+ break;
1254
+ // 2 digit representation of the year, padded (00-99). (e.g. AD 2001 => 01, AD 2010 => 10)
1255
+ case 'yy':
1256
+ formatter = dateGetter(0 /* DateType.FullYear */, 2, 0, true, true);
1257
+ break;
1258
+ // 3 digit representation of the year, padded (000-999). (e.g. AD 2001 => 01, AD 2010 => 10)
1259
+ case 'yyy':
1260
+ formatter = dateGetter(0 /* DateType.FullYear */, 3, 0, false, true);
1261
+ break;
1262
+ // 4 digit representation of the year (e.g. AD 1 => 0001, AD 2010 => 2010)
1263
+ case 'yyyy':
1264
+ formatter = dateGetter(0 /* DateType.FullYear */, 4, 0, false, true);
1265
+ break;
1266
+ // 1 digit representation of the week-numbering year, e.g. (AD 1 => 1, AD 199 => 199)
1267
+ case 'Y':
1268
+ formatter = weekNumberingYearGetter(1);
1269
+ break;
1270
+ // 2 digit representation of the week-numbering year, padded (00-99). (e.g. AD 2001 => 01, AD
1271
+ // 2010 => 10)
1272
+ case 'YY':
1273
+ formatter = weekNumberingYearGetter(2, true);
1274
+ break;
1275
+ // 3 digit representation of the week-numbering year, padded (000-999). (e.g. AD 1 => 001, AD
1276
+ // 2010 => 2010)
1277
+ case 'YYY':
1278
+ formatter = weekNumberingYearGetter(3);
1279
+ break;
1280
+ // 4 digit representation of the week-numbering year (e.g. AD 1 => 0001, AD 2010 => 2010)
1281
+ case 'YYYY':
1282
+ formatter = weekNumberingYearGetter(4);
1283
+ break;
1284
+ // Month of the year (1-12), numeric
1285
+ case 'M':
1286
+ case 'L':
1287
+ formatter = dateGetter(1 /* DateType.Month */, 1, 1);
1288
+ break;
1289
+ case 'MM':
1290
+ case 'LL':
1291
+ formatter = dateGetter(1 /* DateType.Month */, 2, 1);
1292
+ break;
1293
+ // Month of the year (January, ...), string, format
1294
+ case 'MMM':
1295
+ formatter = dateStrGetter(2 /* TranslationType.Months */, TranslationWidth.Abbreviated);
1296
+ break;
1297
+ case 'MMMM':
1298
+ formatter = dateStrGetter(2 /* TranslationType.Months */, TranslationWidth.Wide);
1299
+ break;
1300
+ case 'MMMMM':
1301
+ formatter = dateStrGetter(2 /* TranslationType.Months */, TranslationWidth.Narrow);
1302
+ break;
1303
+ // Month of the year (January, ...), string, standalone
1304
+ case 'LLL':
1305
+ formatter = dateStrGetter(2 /* TranslationType.Months */, TranslationWidth.Abbreviated, FormStyle.Standalone);
1306
+ break;
1307
+ case 'LLLL':
1308
+ formatter = dateStrGetter(2 /* TranslationType.Months */, TranslationWidth.Wide, FormStyle.Standalone);
1309
+ break;
1310
+ case 'LLLLL':
1311
+ formatter = dateStrGetter(2 /* TranslationType.Months */, TranslationWidth.Narrow, FormStyle.Standalone);
1312
+ break;
1313
+ // Week of the year (1, ... 52)
1314
+ case 'w':
1315
+ formatter = weekGetter(1);
1316
+ break;
1317
+ case 'ww':
1318
+ formatter = weekGetter(2);
1319
+ break;
1320
+ // Week of the month (1, ...)
1321
+ case 'W':
1322
+ formatter = weekGetter(1, true);
1323
+ break;
1324
+ // Day of the month (1-31)
1325
+ case 'd':
1326
+ formatter = dateGetter(2 /* DateType.Date */, 1);
1327
+ break;
1328
+ case 'dd':
1329
+ formatter = dateGetter(2 /* DateType.Date */, 2);
1330
+ break;
1331
+ // Day of the Week StandAlone (1, 1, Mon, Monday, M, Mo)
1332
+ case 'c':
1333
+ case 'cc':
1334
+ formatter = dateGetter(7 /* DateType.Day */, 1);
1335
+ break;
1336
+ case 'ccc':
1337
+ formatter = dateStrGetter(1 /* TranslationType.Days */, TranslationWidth.Abbreviated, FormStyle.Standalone);
1338
+ break;
1339
+ case 'cccc':
1340
+ formatter = dateStrGetter(1 /* TranslationType.Days */, TranslationWidth.Wide, FormStyle.Standalone);
1341
+ break;
1342
+ case 'ccccc':
1343
+ formatter = dateStrGetter(1 /* TranslationType.Days */, TranslationWidth.Narrow, FormStyle.Standalone);
1344
+ break;
1345
+ case 'cccccc':
1346
+ formatter = dateStrGetter(1 /* TranslationType.Days */, TranslationWidth.Short, FormStyle.Standalone);
1347
+ break;
1348
+ // Day of the Week
1349
+ case 'E':
1350
+ case 'EE':
1351
+ case 'EEE':
1352
+ formatter = dateStrGetter(1 /* TranslationType.Days */, TranslationWidth.Abbreviated);
1353
+ break;
1354
+ case 'EEEE':
1355
+ formatter = dateStrGetter(1 /* TranslationType.Days */, TranslationWidth.Wide);
1356
+ break;
1357
+ case 'EEEEE':
1358
+ formatter = dateStrGetter(1 /* TranslationType.Days */, TranslationWidth.Narrow);
1359
+ break;
1360
+ case 'EEEEEE':
1361
+ formatter = dateStrGetter(1 /* TranslationType.Days */, TranslationWidth.Short);
1362
+ break;
1363
+ // Generic period of the day (am-pm)
1364
+ case 'a':
1365
+ case 'aa':
1366
+ case 'aaa':
1367
+ formatter = dateStrGetter(0 /* TranslationType.DayPeriods */, TranslationWidth.Abbreviated);
1368
+ break;
1369
+ case 'aaaa':
1370
+ formatter = dateStrGetter(0 /* TranslationType.DayPeriods */, TranslationWidth.Wide);
1371
+ break;
1372
+ case 'aaaaa':
1373
+ formatter = dateStrGetter(0 /* TranslationType.DayPeriods */, TranslationWidth.Narrow);
1374
+ break;
1375
+ // Extended period of the day (midnight, at night, ...), standalone
1376
+ case 'b':
1377
+ case 'bb':
1378
+ case 'bbb':
1379
+ formatter = dateStrGetter(0 /* TranslationType.DayPeriods */, TranslationWidth.Abbreviated, FormStyle.Standalone, true);
1380
+ break;
1381
+ case 'bbbb':
1382
+ formatter = dateStrGetter(0 /* TranslationType.DayPeriods */, TranslationWidth.Wide, FormStyle.Standalone, true);
1383
+ break;
1384
+ case 'bbbbb':
1385
+ formatter = dateStrGetter(0 /* TranslationType.DayPeriods */, TranslationWidth.Narrow, FormStyle.Standalone, true);
1386
+ break;
1387
+ // Extended period of the day (midnight, night, ...), standalone
1388
+ case 'B':
1389
+ case 'BB':
1390
+ case 'BBB':
1391
+ formatter = dateStrGetter(0 /* TranslationType.DayPeriods */, TranslationWidth.Abbreviated, FormStyle.Format, true);
1392
+ break;
1393
+ case 'BBBB':
1394
+ formatter = dateStrGetter(0 /* TranslationType.DayPeriods */, TranslationWidth.Wide, FormStyle.Format, true);
1395
+ break;
1396
+ case 'BBBBB':
1397
+ formatter = dateStrGetter(0 /* TranslationType.DayPeriods */, TranslationWidth.Narrow, FormStyle.Format, true);
1398
+ break;
1399
+ // Hour in AM/PM, (1-12)
1400
+ case 'h':
1401
+ formatter = dateGetter(3 /* DateType.Hours */, 1, -12);
1402
+ break;
1403
+ case 'hh':
1404
+ formatter = dateGetter(3 /* DateType.Hours */, 2, -12);
1405
+ break;
1406
+ // Hour of the day (0-23)
1407
+ case 'H':
1408
+ formatter = dateGetter(3 /* DateType.Hours */, 1);
1409
+ break;
1410
+ // Hour in day, padded (00-23)
1411
+ case 'HH':
1412
+ formatter = dateGetter(3 /* DateType.Hours */, 2);
1413
+ break;
1414
+ // Minute of the hour (0-59)
1415
+ case 'm':
1416
+ formatter = dateGetter(4 /* DateType.Minutes */, 1);
1417
+ break;
1418
+ case 'mm':
1419
+ formatter = dateGetter(4 /* DateType.Minutes */, 2);
1420
+ break;
1421
+ // Second of the minute (0-59)
1422
+ case 's':
1423
+ formatter = dateGetter(5 /* DateType.Seconds */, 1);
1424
+ break;
1425
+ case 'ss':
1426
+ formatter = dateGetter(5 /* DateType.Seconds */, 2);
1427
+ break;
1428
+ // Fractional second
1429
+ case 'S':
1430
+ formatter = dateGetter(6 /* DateType.FractionalSeconds */, 1);
1431
+ break;
1432
+ case 'SS':
1433
+ formatter = dateGetter(6 /* DateType.FractionalSeconds */, 2);
1434
+ break;
1435
+ case 'SSS':
1436
+ formatter = dateGetter(6 /* DateType.FractionalSeconds */, 3);
1437
+ break;
1438
+ // Timezone ISO8601 short format (-0430)
1439
+ case 'Z':
1440
+ case 'ZZ':
1441
+ case 'ZZZ':
1442
+ formatter = timeZoneGetter(0 /* ZoneWidth.Short */);
1443
+ break;
1444
+ // Timezone ISO8601 extended format (-04:30)
1445
+ case 'ZZZZZ':
1446
+ formatter = timeZoneGetter(3 /* ZoneWidth.Extended */);
1447
+ break;
1448
+ // Timezone GMT short format (GMT+4)
1449
+ case 'O':
1450
+ case 'OO':
1451
+ case 'OOO':
1452
+ // Should be location, but fallback to format O instead because we don't have the data yet
1453
+ case 'z':
1454
+ case 'zz':
1455
+ case 'zzz':
1456
+ formatter = timeZoneGetter(1 /* ZoneWidth.ShortGMT */);
1457
+ break;
1458
+ // Timezone GMT long format (GMT+0430)
1459
+ case 'OOOO':
1460
+ case 'ZZZZ':
1461
+ // Should be location, but fallback to format O instead because we don't have the data yet
1462
+ case 'zzzz':
1463
+ formatter = timeZoneGetter(2 /* ZoneWidth.Long */);
1464
+ break;
1465
+ default:
1466
+ return null;
1467
+ }
1468
+ DATE_FORMATS[format] = formatter;
1469
+ return formatter;
1470
+ }
1471
+ function timezoneToOffset(timezone, fallback) {
1472
+ // Support: IE 11 only, Edge 13-15+
1473
+ // IE/Edge do not "understand" colon (`:`) in timezone
1474
+ timezone = timezone.replace(/:/g, '');
1475
+ const requestedTimezoneOffset = Date.parse('Jan 01, 1970 00:00:00 ' + timezone) / 60000;
1476
+ return isNaN(requestedTimezoneOffset) ? fallback : requestedTimezoneOffset;
1477
+ }
1478
+ function addDateMinutes(date, minutes) {
1479
+ date = new Date(date.getTime());
1480
+ date.setMinutes(date.getMinutes() + minutes);
1481
+ return date;
1482
+ }
1483
+ function convertTimezoneToLocal(date, timezone, reverse) {
1484
+ const reverseValue = -1 ;
1485
+ const dateTimezoneOffset = date.getTimezoneOffset();
1486
+ const timezoneOffset = timezoneToOffset(timezone, dateTimezoneOffset);
1487
+ return addDateMinutes(date, reverseValue * (timezoneOffset - dateTimezoneOffset));
1488
+ }
1489
+ /**
1490
+ * Converts a value to date.
1491
+ *
1492
+ * Supported input formats:
1493
+ * - `Date`
1494
+ * - number: timestamp
1495
+ * - string: numeric (e.g. "1234"), ISO and date strings in a format supported by
1496
+ * [Date.parse()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/parse).
1497
+ * Note: ISO strings without time return a date without timeoffset.
1498
+ *
1499
+ * Throws if unable to convert to a date.
1500
+ */
1501
+ function toDate(value) {
1502
+ if (isDate(value)) {
1503
+ return value;
1504
+ }
1505
+ if (typeof value === 'number' && !isNaN(value)) {
1506
+ return new Date(value);
1507
+ }
1508
+ if (typeof value === 'string') {
1509
+ value = value.trim();
1510
+ if (/^(\d{4}(-\d{1,2}(-\d{1,2})?)?)$/.test(value)) {
1511
+ /* For ISO Strings without time the day, month and year must be extracted from the ISO String
1512
+ before Date creation to avoid time offset and errors in the new Date.
1513
+ If we only replace '-' with ',' in the ISO String ("2015,01,01"), and try to create a new
1514
+ date, some browsers (e.g. IE 9) will throw an invalid Date error.
1515
+ If we leave the '-' ("2015-01-01") and try to create a new Date("2015-01-01") the timeoffset
1516
+ is applied.
1517
+ Note: ISO months are 0 for January, 1 for February, ... */
1518
+ const [y, m = 1, d = 1] = value.split('-').map((val) => +val);
1519
+ return createDate(y, m - 1, d);
1520
+ }
1521
+ const parsedNb = parseFloat(value);
1522
+ // any string that only contains numbers, like "1234" but not like "1234hello"
1523
+ if (!isNaN(value - parsedNb)) {
1524
+ return new Date(parsedNb);
1525
+ }
1526
+ let match;
1527
+ if ((match = value.match(ISO8601_DATE_REGEX))) {
1528
+ return isoStringToDate(match);
1529
+ }
1530
+ }
1531
+ const date = new Date(value);
1532
+ if (!isDate(date)) {
1533
+ throw new _RuntimeError(2302 /* RuntimeErrorCode.INVALID_TO_DATE_CONVERSION */, ngDevMode && `Unable to convert "${value}" into a date`);
1534
+ }
1535
+ return date;
1536
+ }
1537
+ /**
1538
+ * Converts a date in ISO8601 to a Date.
1539
+ * Used instead of `Date.parse` because of browser discrepancies.
1540
+ */
1541
+ function isoStringToDate(match) {
1542
+ const date = new Date(0);
1543
+ let tzHour = 0;
1544
+ let tzMin = 0;
1545
+ // match[8] means that the string contains "Z" (UTC) or a timezone like "+01:00" or "+0100"
1546
+ const dateSetter = match[8] ? date.setUTCFullYear : date.setFullYear;
1547
+ const timeSetter = match[8] ? date.setUTCHours : date.setHours;
1548
+ // if there is a timezone defined like "+01:00" or "+0100"
1549
+ if (match[9]) {
1550
+ tzHour = Number(match[9] + match[10]);
1551
+ tzMin = Number(match[9] + match[11]);
1552
+ }
1553
+ dateSetter.call(date, Number(match[1]), Number(match[2]) - 1, Number(match[3]));
1554
+ const h = Number(match[4] || 0) - tzHour;
1555
+ const m = Number(match[5] || 0) - tzMin;
1556
+ const s = Number(match[6] || 0);
1557
+ // The ECMAScript specification (https://www.ecma-international.org/ecma-262/5.1/#sec-15.9.1.11)
1558
+ // defines that `DateTime` milliseconds should always be rounded down, so that `999.9ms`
1559
+ // becomes `999ms`.
1560
+ const ms = Math.floor(parseFloat('0.' + (match[7] || 0)) * 1000);
1561
+ timeSetter.call(date, h, m, s, ms);
1562
+ return date;
1563
+ }
1564
+ function isDate(value) {
1565
+ return value instanceof Date && !isNaN(value.valueOf());
1566
+ }
1567
+
1568
+ const NUMBER_FORMAT_REGEXP = /^(\d+)?\.((\d+)(-(\d+))?)?$/;
1569
+ const MAX_DIGITS = 22;
1570
+ const DECIMAL_SEP = '.';
1571
+ const ZERO_CHAR = '0';
1572
+ const PATTERN_SEP = ';';
1573
+ const GROUP_SEP = ',';
1574
+ const DIGIT_CHAR = '#';
1575
+ const CURRENCY_CHAR = '¤';
1576
+ const PERCENT_CHAR = '%';
1577
+ /**
1578
+ * Transforms a number to a locale string based on a style and a format.
1579
+ */
1580
+ function formatNumberToLocaleString(value, pattern, locale, groupSymbol, decimalSymbol, digitsInfo, isPercent = false) {
1581
+ let formattedText = '';
1582
+ let isZero = false;
1583
+ if (!isFinite(value)) {
1584
+ formattedText = getLocaleNumberSymbol(locale, NumberSymbol.Infinity);
1585
+ }
1586
+ else {
1587
+ let parsedNumber = parseNumber(value);
1588
+ if (isPercent) {
1589
+ parsedNumber = toPercent(parsedNumber);
1590
+ }
1591
+ let minInt = pattern.minInt;
1592
+ let minFraction = pattern.minFrac;
1593
+ let maxFraction = pattern.maxFrac;
1594
+ if (digitsInfo) {
1595
+ const parts = digitsInfo.match(NUMBER_FORMAT_REGEXP);
1596
+ if (parts === null) {
1597
+ throw new _RuntimeError(2306 /* RuntimeErrorCode.INVALID_DIGIT_INFO */, ngDevMode && `${digitsInfo} is not a valid digit info`);
1598
+ }
1599
+ const minIntPart = parts[1];
1600
+ const minFractionPart = parts[3];
1601
+ const maxFractionPart = parts[5];
1602
+ if (minIntPart != null) {
1603
+ minInt = parseIntAutoRadix(minIntPart);
1604
+ }
1605
+ if (minFractionPart != null) {
1606
+ minFraction = parseIntAutoRadix(minFractionPart);
1607
+ }
1608
+ if (maxFractionPart != null) {
1609
+ maxFraction = parseIntAutoRadix(maxFractionPart);
1610
+ }
1611
+ else if (minFractionPart != null && minFraction > maxFraction) {
1612
+ maxFraction = minFraction;
1613
+ }
1614
+ }
1615
+ roundNumber(parsedNumber, minFraction, maxFraction);
1616
+ let digits = parsedNumber.digits;
1617
+ let integerLen = parsedNumber.integerLen;
1618
+ const exponent = parsedNumber.exponent;
1619
+ let decimals = [];
1620
+ isZero = digits.every((d) => !d);
1621
+ // pad zeros for small numbers
1622
+ for (; integerLen < minInt; integerLen++) {
1623
+ digits.unshift(0);
1624
+ }
1625
+ // pad zeros for small numbers
1626
+ for (; integerLen < 0; integerLen++) {
1627
+ digits.unshift(0);
1628
+ }
1629
+ // extract decimals digits
1630
+ if (integerLen > 0) {
1631
+ decimals = digits.splice(integerLen, digits.length);
1632
+ }
1633
+ else {
1634
+ decimals = digits;
1635
+ digits = [0];
1636
+ }
1637
+ // format the integer digits with grouping separators
1638
+ const groups = [];
1639
+ if (digits.length >= pattern.lgSize) {
1640
+ groups.unshift(digits.splice(-pattern.lgSize, digits.length).join(''));
1641
+ }
1642
+ while (digits.length > pattern.gSize) {
1643
+ groups.unshift(digits.splice(-pattern.gSize, digits.length).join(''));
1644
+ }
1645
+ if (digits.length) {
1646
+ groups.unshift(digits.join(''));
1647
+ }
1648
+ formattedText = groups.join(getLocaleNumberSymbol(locale, groupSymbol));
1649
+ // append the decimal digits
1650
+ if (decimals.length) {
1651
+ formattedText += getLocaleNumberSymbol(locale, decimalSymbol) + decimals.join('');
1652
+ }
1653
+ if (exponent) {
1654
+ formattedText += getLocaleNumberSymbol(locale, NumberSymbol.Exponential) + '+' + exponent;
1655
+ }
1656
+ }
1657
+ if (value < 0 && !isZero) {
1658
+ formattedText = pattern.negPre + formattedText + pattern.negSuf;
1659
+ }
1660
+ else {
1661
+ formattedText = pattern.posPre + formattedText + pattern.posSuf;
1662
+ }
1663
+ return formattedText;
1664
+ }
1665
+ /**
1666
+ * @ngModule CommonModule
1667
+ * @description
1668
+ *
1669
+ * Formats a number as currency using locale rules.
1670
+ *
1671
+ * @param value The number to format.
1672
+ * @param locale A locale code for the locale format rules to use.
1673
+ * @param currency A string containing the currency symbol or its name,
1674
+ * such as "$" or "Canadian Dollar". Used in output string, but does not affect the operation
1675
+ * of the function.
1676
+ * @param currencyCode The [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217)
1677
+ * currency code, such as `USD` for the US dollar and `EUR` for the euro.
1678
+ * Used to determine the number of digits in the decimal part.
1679
+ * @param digitsInfo Decimal representation options, specified by a string in the following format:
1680
+ * `{minIntegerDigits}.{minFractionDigits}-{maxFractionDigits}`. See `DecimalPipe` for more details.
1681
+ *
1682
+ * @returns The formatted currency value.
1683
+ *
1684
+ * @see {@link formatNumber}
1685
+ * @see {@link DecimalPipe}
1686
+ * @see [Internationalization (i18n) Guide](guide/i18n)
1687
+ *
1688
+ * @publicApi
1689
+ */
1690
+ function formatCurrency(value, locale, currency, currencyCode, digitsInfo) {
1691
+ const format = getLocaleNumberFormat(locale, NumberFormatStyle.Currency);
1692
+ const pattern = parseNumberFormat(format, getLocaleNumberSymbol(locale, NumberSymbol.MinusSign));
1693
+ pattern.minFrac = getNumberOfCurrencyDigits(currencyCode);
1694
+ pattern.maxFrac = pattern.minFrac;
1695
+ const res = formatNumberToLocaleString(value, pattern, locale, NumberSymbol.CurrencyGroup, NumberSymbol.CurrencyDecimal, digitsInfo);
1696
+ return (res
1697
+ .replace(CURRENCY_CHAR, currency)
1698
+ // if we have 2 time the currency character, the second one is ignored
1699
+ .replace(CURRENCY_CHAR, '')
1700
+ // If there is a spacing between currency character and the value and
1701
+ // the currency character is suppressed by passing an empty string, the
1702
+ // spacing character would remain as part of the string. Then we
1703
+ // should remove it.
1704
+ .trim());
1705
+ }
1706
+ /**
1707
+ * @ngModule CommonModule
1708
+ * @description
1709
+ *
1710
+ * Formats a number as a percentage according to locale rules.
1711
+ *
1712
+ * @param value The number to format.
1713
+ * @param locale A locale code for the locale format rules to use.
1714
+ * @param digitsInfo Decimal representation options, specified by a string in the following format:
1715
+ * `{minIntegerDigits}.{minFractionDigits}-{maxFractionDigits}`. See `DecimalPipe` for more details.
1716
+ *
1717
+ * @returns The formatted percentage value.
1718
+ *
1719
+ * @see {@link formatNumber}
1720
+ * @see {@link DecimalPipe}
1721
+ * @see [Internationalization (i18n) Guide](guide/i18n)
1722
+ * @publicApi
1723
+ *
1724
+ */
1725
+ function formatPercent(value, locale, digitsInfo) {
1726
+ const format = getLocaleNumberFormat(locale, NumberFormatStyle.Percent);
1727
+ const pattern = parseNumberFormat(format, getLocaleNumberSymbol(locale, NumberSymbol.MinusSign));
1728
+ const res = formatNumberToLocaleString(value, pattern, locale, NumberSymbol.Group, NumberSymbol.Decimal, digitsInfo, true);
1729
+ return res.replace(new RegExp(PERCENT_CHAR, 'g'), getLocaleNumberSymbol(locale, NumberSymbol.PercentSign));
1730
+ }
1731
+ /**
1732
+ * @ngModule CommonModule
1733
+ * @description
1734
+ *
1735
+ * Formats a number as text, with group sizing, separator, and other
1736
+ * parameters based on the locale.
1737
+ *
1738
+ * @param value The number to format.
1739
+ * @param locale A locale code for the locale format rules to use.
1740
+ * @param digitsInfo Decimal representation options, specified by a string in the following format:
1741
+ * `{minIntegerDigits}.{minFractionDigits}-{maxFractionDigits}`. See `DecimalPipe` for more details.
1742
+ *
1743
+ * @returns The formatted text string.
1744
+ * @see [Internationalization (i18n) Guide](guide/i18n)
1745
+ *
1746
+ * @publicApi
1747
+ */
1748
+ function formatNumber(value, locale, digitsInfo) {
1749
+ const format = getLocaleNumberFormat(locale, NumberFormatStyle.Decimal);
1750
+ const pattern = parseNumberFormat(format, getLocaleNumberSymbol(locale, NumberSymbol.MinusSign));
1751
+ return formatNumberToLocaleString(value, pattern, locale, NumberSymbol.Group, NumberSymbol.Decimal, digitsInfo);
1752
+ }
1753
+ function parseNumberFormat(format, minusSign = '-') {
1754
+ const p = {
1755
+ minInt: 1,
1756
+ minFrac: 0,
1757
+ maxFrac: 0,
1758
+ posPre: '',
1759
+ posSuf: '',
1760
+ negPre: '',
1761
+ negSuf: '',
1762
+ gSize: 0,
1763
+ lgSize: 0,
1764
+ };
1765
+ const patternParts = format.split(PATTERN_SEP);
1766
+ const positive = patternParts[0];
1767
+ const negative = patternParts[1];
1768
+ const positiveParts = positive.indexOf(DECIMAL_SEP) !== -1
1769
+ ? positive.split(DECIMAL_SEP)
1770
+ : [
1771
+ positive.substring(0, positive.lastIndexOf(ZERO_CHAR) + 1),
1772
+ positive.substring(positive.lastIndexOf(ZERO_CHAR) + 1),
1773
+ ], integer = positiveParts[0], fraction = positiveParts[1] || '';
1774
+ p.posPre = integer.substring(0, integer.indexOf(DIGIT_CHAR));
1775
+ for (let i = 0; i < fraction.length; i++) {
1776
+ const ch = fraction.charAt(i);
1777
+ if (ch === ZERO_CHAR) {
1778
+ p.minFrac = p.maxFrac = i + 1;
1779
+ }
1780
+ else if (ch === DIGIT_CHAR) {
1781
+ p.maxFrac = i + 1;
1782
+ }
1783
+ else {
1784
+ p.posSuf += ch;
1785
+ }
1786
+ }
1787
+ const groups = integer.split(GROUP_SEP);
1788
+ p.gSize = groups[1] ? groups[1].length : 0;
1789
+ p.lgSize = groups[2] || groups[1] ? (groups[2] || groups[1]).length : 0;
1790
+ if (negative) {
1791
+ const trunkLen = positive.length - p.posPre.length - p.posSuf.length, pos = negative.indexOf(DIGIT_CHAR);
1792
+ p.negPre = negative.substring(0, pos).replace(/'/g, '');
1793
+ p.negSuf = negative.slice(pos + trunkLen).replace(/'/g, '');
1794
+ }
1795
+ else {
1796
+ p.negPre = minusSign + p.posPre;
1797
+ p.negSuf = p.posSuf;
1798
+ }
1799
+ return p;
1800
+ }
1801
+ // Transforms a parsed number into a percentage by multiplying it by 100
1802
+ function toPercent(parsedNumber) {
1803
+ // if the number is 0, don't do anything
1804
+ if (parsedNumber.digits[0] === 0) {
1805
+ return parsedNumber;
1806
+ }
1807
+ // Getting the current number of decimals
1808
+ const fractionLen = parsedNumber.digits.length - parsedNumber.integerLen;
1809
+ if (parsedNumber.exponent) {
1810
+ parsedNumber.exponent += 2;
1811
+ }
1812
+ else {
1813
+ if (fractionLen === 0) {
1814
+ parsedNumber.digits.push(0, 0);
1815
+ }
1816
+ else if (fractionLen === 1) {
1817
+ parsedNumber.digits.push(0);
1818
+ }
1819
+ parsedNumber.integerLen += 2;
1820
+ }
1821
+ return parsedNumber;
1822
+ }
1823
+ /**
1824
+ * Parses a number.
1825
+ * Significant bits of this parse algorithm came from https://github.com/MikeMcl/big.js/
1826
+ */
1827
+ function parseNumber(num) {
1828
+ let numStr = Math.abs(num) + '';
1829
+ let exponent = 0, digits, integerLen;
1830
+ let i, j, zeros;
1831
+ // Decimal point?
1832
+ if ((integerLen = numStr.indexOf(DECIMAL_SEP)) > -1) {
1833
+ numStr = numStr.replace(DECIMAL_SEP, '');
1834
+ }
1835
+ // Exponential form?
1836
+ if ((i = numStr.search(/e/i)) > 0) {
1837
+ // Work out the exponent.
1838
+ if (integerLen < 0)
1839
+ integerLen = i;
1840
+ integerLen += +numStr.slice(i + 1);
1841
+ numStr = numStr.substring(0, i);
1842
+ }
1843
+ else if (integerLen < 0) {
1844
+ // There was no decimal point or exponent so it is an integer.
1845
+ integerLen = numStr.length;
1846
+ }
1847
+ // Count the number of leading zeros.
1848
+ for (i = 0; numStr.charAt(i) === ZERO_CHAR; i++) {
1849
+ /* empty */
1850
+ }
1851
+ if (i === (zeros = numStr.length)) {
1852
+ // The digits are all zero.
1853
+ digits = [0];
1854
+ integerLen = 1;
1855
+ }
1856
+ else {
1857
+ // Count the number of trailing zeros
1858
+ zeros--;
1859
+ while (numStr.charAt(zeros) === ZERO_CHAR)
1860
+ zeros--;
1861
+ // Trailing zeros are insignificant so ignore them
1862
+ integerLen -= i;
1863
+ digits = [];
1864
+ // Convert string to array of digits without leading/trailing zeros.
1865
+ for (j = 0; i <= zeros; i++, j++) {
1866
+ digits[j] = Number(numStr.charAt(i));
1867
+ }
1868
+ }
1869
+ // If the number overflows the maximum allowed digits then use an exponent.
1870
+ if (integerLen > MAX_DIGITS) {
1871
+ digits = digits.splice(0, MAX_DIGITS - 1);
1872
+ exponent = integerLen - 1;
1873
+ integerLen = 1;
1874
+ }
1875
+ return { digits, exponent, integerLen };
1876
+ }
1877
+ /**
1878
+ * Round the parsed number to the specified number of decimal places
1879
+ * This function changes the parsedNumber in-place
1880
+ */
1881
+ function roundNumber(parsedNumber, minFrac, maxFrac) {
1882
+ if (minFrac > maxFrac) {
1883
+ throw new _RuntimeError(2307 /* RuntimeErrorCode.INVALID_NUMBER_OF_DIGITS_AFTER_FRACTION */, ngDevMode &&
1884
+ `The minimum number of digits after fraction (${minFrac}) is higher than the maximum (${maxFrac}).`);
1885
+ }
1886
+ let digits = parsedNumber.digits;
1887
+ let fractionLen = digits.length - parsedNumber.integerLen;
1888
+ const fractionSize = Math.min(Math.max(minFrac, fractionLen), maxFrac);
1889
+ // The index of the digit to where rounding is to occur
1890
+ let roundAt = fractionSize + parsedNumber.integerLen;
1891
+ let digit = digits[roundAt];
1892
+ if (roundAt > 0) {
1893
+ // Drop fractional digits beyond `roundAt`
1894
+ digits.splice(Math.max(parsedNumber.integerLen, roundAt));
1895
+ // Set non-fractional digits beyond `roundAt` to 0
1896
+ for (let j = roundAt; j < digits.length; j++) {
1897
+ digits[j] = 0;
1898
+ }
1899
+ }
1900
+ else {
1901
+ // We rounded to zero so reset the parsedNumber
1902
+ fractionLen = Math.max(0, fractionLen);
1903
+ parsedNumber.integerLen = 1;
1904
+ digits.length = Math.max(1, (roundAt = fractionSize + 1));
1905
+ digits[0] = 0;
1906
+ for (let i = 1; i < roundAt; i++)
1907
+ digits[i] = 0;
1908
+ }
1909
+ if (digit >= 5) {
1910
+ if (roundAt - 1 < 0) {
1911
+ for (let k = 0; k > roundAt; k--) {
1912
+ digits.unshift(0);
1913
+ parsedNumber.integerLen++;
1914
+ }
1915
+ digits.unshift(1);
1916
+ parsedNumber.integerLen++;
1917
+ }
1918
+ else {
1919
+ digits[roundAt - 1]++;
1920
+ }
1921
+ }
1922
+ // Pad out with zeros to get the required fraction length
1923
+ for (; fractionLen < Math.max(0, fractionSize); fractionLen++)
1924
+ digits.push(0);
1925
+ let dropTrailingZeros = fractionSize !== 0;
1926
+ // Minimal length = nb of decimals required + current nb of integers
1927
+ // Any number besides that is optional and can be removed if it's a trailing 0
1928
+ const minLen = minFrac + parsedNumber.integerLen;
1929
+ // Do any carrying, e.g. a digit was rounded up to 10
1930
+ const carry = digits.reduceRight(function (carry, d, i, digits) {
1931
+ d = d + carry;
1932
+ digits[i] = d < 10 ? d : d - 10; // d % 10
1933
+ if (dropTrailingZeros) {
1934
+ // Do not keep meaningless fractional trailing zeros (e.g. 15.52000 --> 15.52)
1935
+ if (digits[i] === 0 && i >= minLen) {
1936
+ digits.pop();
1937
+ }
1938
+ else {
1939
+ dropTrailingZeros = false;
1940
+ }
1941
+ }
1942
+ return d >= 10 ? 1 : 0; // Math.floor(d / 10);
1943
+ }, 0);
1944
+ if (carry) {
1945
+ digits.unshift(carry);
1946
+ parsedNumber.integerLen++;
1947
+ }
1948
+ }
1949
+ function parseIntAutoRadix(text) {
1950
+ const result = parseInt(text);
1951
+ if (isNaN(result)) {
1952
+ throw new _RuntimeError(2305 /* RuntimeErrorCode.INVALID_INTEGER_LITERAL */, ngDevMode && 'Invalid integer literal when parsing ' + text);
1953
+ }
1954
+ return result;
1955
+ }
1956
+
1957
+ /**
1958
+ * @publicApi
1959
+ */
1960
+ class NgLocalization {
1961
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.0-next.5", ngImport: i0, type: NgLocalization, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
1962
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.0.0-next.5", ngImport: i0, type: NgLocalization, providedIn: 'root', useFactory: (locale) => new NgLocaleLocalization(locale), deps: [{ token: LOCALE_ID }] });
1963
+ }
1964
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.0-next.5", ngImport: i0, type: NgLocalization, decorators: [{
1965
+ type: Injectable,
1966
+ args: [{
1967
+ providedIn: 'root',
1968
+ useFactory: (locale) => new NgLocaleLocalization(locale),
1969
+ deps: [LOCALE_ID],
1970
+ }]
1971
+ }] });
1972
+ /**
1973
+ * Returns the plural category for a given value.
1974
+ * - "=value" when the case exists,
1975
+ * - the plural category otherwise
1976
+ */
1977
+ function getPluralCategory(value, cases, ngLocalization, locale) {
1978
+ let key = `=${value}`;
1979
+ if (cases.indexOf(key) > -1) {
1980
+ return key;
1981
+ }
1982
+ key = ngLocalization.getPluralCategory(value, locale);
1983
+ if (cases.indexOf(key) > -1) {
1984
+ return key;
1985
+ }
1986
+ if (cases.indexOf('other') > -1) {
1987
+ return 'other';
1988
+ }
1989
+ throw new _RuntimeError(2308 /* RuntimeErrorCode.NO_PLURAL_MESSAGE_FOUND */, ngDevMode && `No plural message found for value "${value}"`);
1990
+ }
1991
+ /**
1992
+ * Returns the plural case based on the locale
1993
+ *
1994
+ * @publicApi
1995
+ */
1996
+ class NgLocaleLocalization extends NgLocalization {
1997
+ locale;
1998
+ constructor(locale) {
1999
+ super();
2000
+ this.locale = locale;
2001
+ }
2002
+ getPluralCategory(value, locale) {
2003
+ const plural = getLocalePluralCase(locale || this.locale)(value);
2004
+ switch (plural) {
2005
+ case Plural.Zero:
2006
+ return 'zero';
2007
+ case Plural.One:
2008
+ return 'one';
2009
+ case Plural.Two:
2010
+ return 'two';
2011
+ case Plural.Few:
2012
+ return 'few';
2013
+ case Plural.Many:
2014
+ return 'many';
2015
+ default:
2016
+ return 'other';
2017
+ }
2018
+ }
2019
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.0-next.5", ngImport: i0, type: NgLocaleLocalization, deps: [{ token: LOCALE_ID }], target: i0.ɵɵFactoryTarget.Injectable });
2020
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.0.0-next.5", ngImport: i0, type: NgLocaleLocalization });
2021
+ }
2022
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.0-next.5", ngImport: i0, type: NgLocaleLocalization, decorators: [{
2023
+ type: Injectable
2024
+ }], ctorParameters: () => [{ type: undefined, decorators: [{
2025
+ type: Inject,
2026
+ args: [LOCALE_ID]
2027
+ }] }] });
2028
+
2029
+ const WS_REGEXP = /\s+/;
2030
+ const EMPTY_ARRAY = [];
2031
+ /**
2032
+ * @ngModule CommonModule
2033
+ *
2034
+ * @usageNotes
2035
+ * ```html
2036
+ * <some-element [ngClass]="stringExp|arrayExp|objExp|Set">...</some-element>
2037
+ *
2038
+ * <some-element [ngClass]="{'class1 class2 class3' : true}">...</some-element>
2039
+ * ```
2040
+ *
2041
+ * For more simple use cases you can use the [class bindings](/guide/templates/binding#css-class-and-style-property-bindings) directly.
2042
+ * It doesn't require importing a directive.
2043
+ *
2044
+ * ```html
2045
+ * <some-element [class]="'first second'">...</some-element>
2046
+ *
2047
+ * <some-element [class.expanded]="isExpanded">...</some-element>
2048
+ *
2049
+ * <some-element [class]="['first', 'second']">...</some-element>
2050
+ *
2051
+ * <some-element [class]="{'first': true, 'second': true, 'third': false}">...</some-element>
2052
+ * ```
2053
+ * @description
2054
+ *
2055
+ * Adds and removes CSS classes on an HTML element.
2056
+ *
2057
+ * The CSS classes are updated as follows, depending on the type of the expression evaluation:
2058
+ * - `string` - the CSS classes listed in the string (space delimited) are added,
2059
+ * - `Array` - the CSS classes declared as Array elements are added,
2060
+ * - `Object` - keys are CSS classes that get added when the expression given in the value
2061
+ * evaluates to a truthy value, otherwise they are removed.
2062
+ *
2063
+ *
2064
+ * @see [Class bindings](/guide/templates/binding#css-class-and-style-property-bindings)
2065
+ *
2066
+ * @publicApi
2067
+ */
2068
+ class NgClass {
2069
+ _ngEl;
2070
+ _renderer;
2071
+ initialClasses = EMPTY_ARRAY;
2072
+ rawClass;
2073
+ stateMap = new Map();
2074
+ constructor(_ngEl, _renderer) {
2075
+ this._ngEl = _ngEl;
2076
+ this._renderer = _renderer;
2077
+ }
2078
+ set klass(value) {
2079
+ this.initialClasses = value != null ? value.trim().split(WS_REGEXP) : EMPTY_ARRAY;
2080
+ }
2081
+ set ngClass(value) {
2082
+ this.rawClass = typeof value === 'string' ? value.trim().split(WS_REGEXP) : value;
2083
+ }
2084
+ /*
2085
+ The NgClass directive uses the custom change detection algorithm for its inputs. The custom
2086
+ algorithm is necessary since inputs are represented as complex object or arrays that need to be
2087
+ deeply-compared.
2088
+
2089
+ This algorithm is perf-sensitive since NgClass is used very frequently and its poor performance
2090
+ might negatively impact runtime performance of the entire change detection cycle. The design of
2091
+ this algorithm is making sure that:
2092
+ - there is no unnecessary DOM manipulation (CSS classes are added / removed from the DOM only when
2093
+ needed), even if references to bound objects change;
2094
+ - there is no memory allocation if nothing changes (even relatively modest memory allocation
2095
+ during the change detection cycle can result in GC pauses for some of the CD cycles).
2096
+
2097
+ The algorithm works by iterating over the set of bound classes, staring with [class] binding and
2098
+ then going over [ngClass] binding. For each CSS class name:
2099
+ - check if it was seen before (this information is tracked in the state map) and if its value
2100
+ changed;
2101
+ - mark it as "touched" - names that are not marked are not present in the latest set of binding
2102
+ and we can remove such class name from the internal data structures;
2103
+
2104
+ After iteration over all the CSS class names we've got data structure with all the information
2105
+ necessary to synchronize changes to the DOM - it is enough to iterate over the state map, flush
2106
+ changes to the DOM and reset internal data structures so those are ready for the next change
2107
+ detection cycle.
2108
+ */
2109
+ ngDoCheck() {
2110
+ // classes from the [class] binding
2111
+ for (const klass of this.initialClasses) {
2112
+ this._updateState(klass, true);
2113
+ }
2114
+ // classes from the [ngClass] binding
2115
+ const rawClass = this.rawClass;
2116
+ if (Array.isArray(rawClass) || rawClass instanceof Set) {
2117
+ for (const klass of rawClass) {
2118
+ this._updateState(klass, true);
2119
+ }
2120
+ }
2121
+ else if (rawClass != null) {
2122
+ for (const klass of Object.keys(rawClass)) {
2123
+ this._updateState(klass, Boolean(rawClass[klass]));
2124
+ }
2125
+ }
2126
+ this._applyStateDiff();
2127
+ }
2128
+ _updateState(klass, nextEnabled) {
2129
+ const state = this.stateMap.get(klass);
2130
+ if (state !== undefined) {
2131
+ if (state.enabled !== nextEnabled) {
2132
+ state.changed = true;
2133
+ state.enabled = nextEnabled;
2134
+ }
2135
+ state.touched = true;
2136
+ }
2137
+ else {
2138
+ this.stateMap.set(klass, { enabled: nextEnabled, changed: true, touched: true });
2139
+ }
2140
+ }
2141
+ _applyStateDiff() {
2142
+ for (const stateEntry of this.stateMap) {
2143
+ const klass = stateEntry[0];
2144
+ const state = stateEntry[1];
2145
+ if (state.changed) {
2146
+ this._toggleClass(klass, state.enabled);
2147
+ state.changed = false;
2148
+ }
2149
+ else if (!state.touched) {
2150
+ // A class that was previously active got removed from the new collection of classes -
2151
+ // remove from the DOM as well.
2152
+ if (state.enabled) {
2153
+ this._toggleClass(klass, false);
2154
+ }
2155
+ this.stateMap.delete(klass);
2156
+ }
2157
+ state.touched = false;
2158
+ }
2159
+ }
2160
+ _toggleClass(klass, enabled) {
2161
+ if (ngDevMode) {
2162
+ if (typeof klass !== 'string') {
2163
+ throw new Error(`NgClass can only toggle CSS classes expressed as strings, got ${_stringify(klass)}`);
2164
+ }
2165
+ }
2166
+ klass = klass.trim();
2167
+ if (klass.length > 0) {
2168
+ klass.split(WS_REGEXP).forEach((klass) => {
2169
+ if (enabled) {
2170
+ this._renderer.addClass(this._ngEl.nativeElement, klass);
2171
+ }
2172
+ else {
2173
+ this._renderer.removeClass(this._ngEl.nativeElement, klass);
2174
+ }
2175
+ });
2176
+ }
2177
+ }
2178
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.0-next.5", ngImport: i0, type: NgClass, deps: [{ token: i0.ElementRef }, { token: i0.Renderer2 }], target: i0.ɵɵFactoryTarget.Directive });
2179
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "20.0.0-next.5", type: NgClass, isStandalone: true, selector: "[ngClass]", inputs: { klass: ["class", "klass"], ngClass: "ngClass" }, ngImport: i0 });
2180
+ }
2181
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.0-next.5", ngImport: i0, type: NgClass, decorators: [{
2182
+ type: Directive,
2183
+ args: [{
2184
+ selector: '[ngClass]',
2185
+ }]
2186
+ }], ctorParameters: () => [{ type: i0.ElementRef }, { type: i0.Renderer2 }], propDecorators: { klass: [{
2187
+ type: Input,
2188
+ args: ['class']
2189
+ }], ngClass: [{
2190
+ type: Input,
2191
+ args: ['ngClass']
2192
+ }] } });
2193
+
2194
+ /**
2195
+ * Instantiates a {@link /api/core/Component Component} type and inserts its Host View into the current View.
2196
+ * `NgComponentOutlet` provides a declarative approach for dynamic component creation.
2197
+ *
2198
+ * `NgComponentOutlet` requires a component type, if a falsy value is set the view will clear and
2199
+ * any existing component will be destroyed.
2200
+ *
2201
+ * @usageNotes
2202
+ *
2203
+ * ### Fine tune control
2204
+ *
2205
+ * You can control the component creation process by using the following optional attributes:
2206
+ *
2207
+ * * `ngComponentOutletInputs`: Optional component inputs object, which will be bind to the
2208
+ * component.
2209
+ *
2210
+ * * `ngComponentOutletInjector`: Optional custom {@link Injector} that will be used as parent for
2211
+ * the Component. Defaults to the injector of the current view container.
2212
+ *
2213
+ * * `ngComponentOutletContent`: Optional list of projectable nodes to insert into the content
2214
+ * section of the component, if it exists.
2215
+ *
2216
+ * * `ngComponentOutletNgModule`: Optional NgModule class reference to allow loading another
2217
+ * module dynamically, then loading a component from that module.
2218
+ *
2219
+ * * `ngComponentOutletNgModuleFactory`: Deprecated config option that allows providing optional
2220
+ * NgModule factory to allow loading another module dynamically, then loading a component from that
2221
+ * module. Use `ngComponentOutletNgModule` instead.
2222
+ *
2223
+ * ### Syntax
2224
+ *
2225
+ * Simple
2226
+ * ```html
2227
+ * <ng-container *ngComponentOutlet="componentTypeExpression"></ng-container>
2228
+ * ```
2229
+ *
2230
+ * With inputs
2231
+ * ```html
2232
+ * <ng-container *ngComponentOutlet="componentTypeExpression;
2233
+ * inputs: inputsExpression;">
2234
+ * </ng-container>
2235
+ * ```
2236
+ *
2237
+ * Customized injector/content
2238
+ * ```html
2239
+ * <ng-container *ngComponentOutlet="componentTypeExpression;
2240
+ * injector: injectorExpression;
2241
+ * content: contentNodesExpression;">
2242
+ * </ng-container>
2243
+ * ```
2244
+ *
2245
+ * Customized NgModule reference
2246
+ * ```html
2247
+ * <ng-container *ngComponentOutlet="componentTypeExpression;
2248
+ * ngModule: ngModuleClass;">
2249
+ * </ng-container>
2250
+ * ```
2251
+ *
2252
+ * ### A simple example
2253
+ *
2254
+ * {@example common/ngComponentOutlet/ts/module.ts region='SimpleExample'}
2255
+ *
2256
+ * A more complete example with additional options:
2257
+ *
2258
+ * {@example common/ngComponentOutlet/ts/module.ts region='CompleteExample'}
2259
+ *
2260
+ * @publicApi
2261
+ * @ngModule CommonModule
2262
+ */
2263
+ class NgComponentOutlet {
2264
+ _viewContainerRef;
2265
+ // TODO(crisbeto): this should be `Type<T>`, but doing so broke a few
2266
+ // targets in a TGP so we need to do it in a major version.
2267
+ /** Component that should be rendered in the outlet. */
2268
+ ngComponentOutlet = null;
2269
+ ngComponentOutletInputs;
2270
+ ngComponentOutletInjector;
2271
+ ngComponentOutletContent;
2272
+ ngComponentOutletNgModule;
2273
+ /**
2274
+ * @deprecated This input is deprecated, use `ngComponentOutletNgModule` instead.
2275
+ */
2276
+ ngComponentOutletNgModuleFactory;
2277
+ _componentRef;
2278
+ _moduleRef;
2279
+ /**
2280
+ * A helper data structure that allows us to track inputs that were part of the
2281
+ * ngComponentOutletInputs expression. Tracking inputs is necessary for proper removal of ones
2282
+ * that are no longer referenced.
2283
+ */
2284
+ _inputsUsed = new Map();
2285
+ /**
2286
+ * Gets the instance of the currently-rendered component.
2287
+ * Will be null if no component has been rendered.
2288
+ */
2289
+ get componentInstance() {
2290
+ return this._componentRef?.instance ?? null;
2291
+ }
2292
+ constructor(_viewContainerRef) {
2293
+ this._viewContainerRef = _viewContainerRef;
2294
+ }
2295
+ _needToReCreateNgModuleInstance(changes) {
2296
+ // Note: square brackets property accessor is safe for Closure compiler optimizations (the
2297
+ // `changes` argument of the `ngOnChanges` lifecycle hook retains the names of the fields that
2298
+ // were changed).
2299
+ return (changes['ngComponentOutletNgModule'] !== undefined ||
2300
+ changes['ngComponentOutletNgModuleFactory'] !== undefined);
2301
+ }
2302
+ _needToReCreateComponentInstance(changes) {
2303
+ // Note: square brackets property accessor is safe for Closure compiler optimizations (the
2304
+ // `changes` argument of the `ngOnChanges` lifecycle hook retains the names of the fields that
2305
+ // were changed).
2306
+ return (changes['ngComponentOutlet'] !== undefined ||
2307
+ changes['ngComponentOutletContent'] !== undefined ||
2308
+ changes['ngComponentOutletInjector'] !== undefined ||
2309
+ this._needToReCreateNgModuleInstance(changes));
2310
+ }
2311
+ /** @nodoc */
2312
+ ngOnChanges(changes) {
2313
+ if (this._needToReCreateComponentInstance(changes)) {
2314
+ this._viewContainerRef.clear();
2315
+ this._inputsUsed.clear();
2316
+ this._componentRef = undefined;
2317
+ if (this.ngComponentOutlet) {
2318
+ const injector = this.ngComponentOutletInjector || this._viewContainerRef.parentInjector;
2319
+ if (this._needToReCreateNgModuleInstance(changes)) {
2320
+ this._moduleRef?.destroy();
2321
+ if (this.ngComponentOutletNgModule) {
2322
+ this._moduleRef = createNgModule(this.ngComponentOutletNgModule, getParentInjector(injector));
2323
+ }
2324
+ else if (this.ngComponentOutletNgModuleFactory) {
2325
+ this._moduleRef = this.ngComponentOutletNgModuleFactory.create(getParentInjector(injector));
2326
+ }
2327
+ else {
2328
+ this._moduleRef = undefined;
2329
+ }
2330
+ }
2331
+ this._componentRef = this._viewContainerRef.createComponent(this.ngComponentOutlet, {
2332
+ injector,
2333
+ ngModuleRef: this._moduleRef,
2334
+ projectableNodes: this.ngComponentOutletContent,
2335
+ });
2336
+ }
2337
+ }
2338
+ }
2339
+ /** @nodoc */
2340
+ ngDoCheck() {
2341
+ if (this._componentRef) {
2342
+ if (this.ngComponentOutletInputs) {
2343
+ for (const inputName of Object.keys(this.ngComponentOutletInputs)) {
2344
+ this._inputsUsed.set(inputName, true);
2345
+ }
2346
+ }
2347
+ this._applyInputStateDiff(this._componentRef);
2348
+ }
2349
+ }
2350
+ /** @nodoc */
2351
+ ngOnDestroy() {
2352
+ this._moduleRef?.destroy();
2353
+ }
2354
+ _applyInputStateDiff(componentRef) {
2355
+ for (const [inputName, touched] of this._inputsUsed) {
2356
+ if (!touched) {
2357
+ // The input that was previously active no longer exists and needs to be set to undefined.
2358
+ componentRef.setInput(inputName, undefined);
2359
+ this._inputsUsed.delete(inputName);
2360
+ }
2361
+ else {
2362
+ // Since touched is true, it can be asserted that the inputs object is not empty.
2363
+ componentRef.setInput(inputName, this.ngComponentOutletInputs[inputName]);
2364
+ this._inputsUsed.set(inputName, false);
2365
+ }
2366
+ }
2367
+ }
2368
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.0-next.5", ngImport: i0, type: NgComponentOutlet, deps: [{ token: i0.ViewContainerRef }], target: i0.ɵɵFactoryTarget.Directive });
2369
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "20.0.0-next.5", 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 });
2370
+ }
2371
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.0-next.5", ngImport: i0, type: NgComponentOutlet, decorators: [{
2372
+ type: Directive,
2373
+ args: [{
2374
+ selector: '[ngComponentOutlet]',
2375
+ exportAs: 'ngComponentOutlet',
2376
+ }]
2377
+ }], ctorParameters: () => [{ type: i0.ViewContainerRef }], propDecorators: { ngComponentOutlet: [{
2378
+ type: Input
2379
+ }], ngComponentOutletInputs: [{
2380
+ type: Input
2381
+ }], ngComponentOutletInjector: [{
2382
+ type: Input
2383
+ }], ngComponentOutletContent: [{
2384
+ type: Input
2385
+ }], ngComponentOutletNgModule: [{
2386
+ type: Input
2387
+ }], ngComponentOutletNgModuleFactory: [{
2388
+ type: Input
2389
+ }] } });
2390
+ // Helper function that returns an Injector instance of a parent NgModule.
2391
+ function getParentInjector(injector) {
2392
+ const parentNgModule = injector.get(NgModuleRef);
2393
+ return parentNgModule.injector;
2394
+ }
2395
+
2396
+ /**
2397
+ * @publicApi
2398
+ *
2399
+ * @deprecated The `ngFor` directive is deprecated. Use the `@for` block instead.
2400
+ */
2401
+ class NgForOfContext {
2402
+ $implicit;
2403
+ ngForOf;
2404
+ index;
2405
+ count;
2406
+ constructor(
2407
+ /** Reference to the current item from the collection. */
2408
+ $implicit,
2409
+ /**
2410
+ * The value of the iterable expression. Useful when the expression is
2411
+ * more complex then a property access, for example when using the async pipe
2412
+ * (`userStreams | async`).
2413
+ */
2414
+ ngForOf,
2415
+ /** Returns an index of the current item in the collection. */
2416
+ index,
2417
+ /** Returns total amount of items in the collection. */
2418
+ count) {
2419
+ this.$implicit = $implicit;
2420
+ this.ngForOf = ngForOf;
2421
+ this.index = index;
2422
+ this.count = count;
2423
+ }
2424
+ // Indicates whether this is the first item in the collection.
2425
+ get first() {
2426
+ return this.index === 0;
2427
+ }
2428
+ // Indicates whether this is the last item in the collection.
2429
+ get last() {
2430
+ return this.index === this.count - 1;
2431
+ }
2432
+ // Indicates whether an index of this item in the collection is even.
2433
+ get even() {
2434
+ return this.index % 2 === 0;
2435
+ }
2436
+ // Indicates whether an index of this item in the collection is odd.
2437
+ get odd() {
2438
+ return !this.even;
2439
+ }
2440
+ }
2441
+ /**
2442
+ * A [structural directive](guide/directives/structural-directives) that renders
2443
+ * a template for each item in a collection.
2444
+ * The directive is placed on an element, which becomes the parent
2445
+ * of the cloned templates.
2446
+ *
2447
+ * The `ngForOf` directive is generally used in the
2448
+ * [shorthand form](guide/directives/structural-directives#asterisk) `*ngFor`.
2449
+ * In this form, the template to be rendered for each iteration is the content
2450
+ * of an anchor element containing the directive.
2451
+ *
2452
+ * The following example shows the shorthand syntax with some options,
2453
+ * contained in an `<li>` element.
2454
+ *
2455
+ * ```html
2456
+ * <li *ngFor="let item of items; index as i; trackBy: trackByFn">...</li>
2457
+ * ```
2458
+ *
2459
+ * The shorthand form expands into a long form that uses the `ngForOf` selector
2460
+ * on an `<ng-template>` element.
2461
+ * The content of the `<ng-template>` element is the `<li>` element that held the
2462
+ * short-form directive.
2463
+ *
2464
+ * Here is the expanded version of the short-form example.
2465
+ *
2466
+ * ```html
2467
+ * <ng-template ngFor let-item [ngForOf]="items" let-i="index" [ngForTrackBy]="trackByFn">
2468
+ * <li>...</li>
2469
+ * </ng-template>
2470
+ * ```
2471
+ *
2472
+ * Angular automatically expands the shorthand syntax as it compiles the template.
2473
+ * The context for each embedded view is logically merged to the current component
2474
+ * context according to its lexical position.
2475
+ *
2476
+ * When using the shorthand syntax, Angular allows only [one structural directive
2477
+ * on an element](guide/directives/structural-directives#one-per-element).
2478
+ * If you want to iterate conditionally, for example,
2479
+ * put the `*ngIf` on a container element that wraps the `*ngFor` element.
2480
+ * For further discussion, see
2481
+ * [Structural Directives](guide/directives/structural-directives#one-per-element).
2482
+ *
2483
+ * @usageNotes
2484
+ *
2485
+ * ### Local variables
2486
+ *
2487
+ * `NgForOf` provides exported values that can be aliased to local variables.
2488
+ * For example:
2489
+ *
2490
+ * ```html
2491
+ * <li *ngFor="let user of users; index as i; first as isFirst">
2492
+ * {{i}}/{{users.length}}. {{user}} <span *ngIf="isFirst">default</span>
2493
+ * </li>
2494
+ * ```
2495
+ *
2496
+ * The following exported values can be aliased to local variables:
2497
+ *
2498
+ * - `$implicit: T`: The value of the individual items in the iterable (`ngForOf`).
2499
+ * - `ngForOf: NgIterable<T>`: The value of the iterable expression. Useful when the expression is
2500
+ * more complex then a property access, for example when using the async pipe (`userStreams |
2501
+ * async`).
2502
+ * - `index: number`: The index of the current item in the iterable.
2503
+ * - `count: number`: The length of the iterable.
2504
+ * - `first: boolean`: True when the item is the first item in the iterable.
2505
+ * - `last: boolean`: True when the item is the last item in the iterable.
2506
+ * - `even: boolean`: True when the item has an even index in the iterable.
2507
+ * - `odd: boolean`: True when the item has an odd index in the iterable.
2508
+ *
2509
+ * ### Change propagation
2510
+ *
2511
+ * When the contents of the iterator changes, `NgForOf` makes the corresponding changes to the DOM:
2512
+ *
2513
+ * * When an item is added, a new instance of the template is added to the DOM.
2514
+ * * When an item is removed, its template instance is removed from the DOM.
2515
+ * * When items are reordered, their respective templates are reordered in the DOM.
2516
+ *
2517
+ * Angular uses object identity to track insertions and deletions within the iterator and reproduce
2518
+ * those changes in the DOM. This has important implications for animations and any stateful
2519
+ * controls that are present, such as `<input>` elements that accept user input. Inserted rows can
2520
+ * be animated in, deleted rows can be animated out, and unchanged rows retain any unsaved state
2521
+ * such as user input.
2522
+ * For more on animations, see [Transitions and Triggers](guide/animations/transition-and-triggers).
2523
+ *
2524
+ * The identities of elements in the iterator can change while the data does not.
2525
+ * This can happen, for example, if the iterator is produced from an RPC to the server, and that
2526
+ * RPC is re-run. Even if the data hasn't changed, the second response produces objects with
2527
+ * different identities, and Angular must tear down the entire DOM and rebuild it (as if all old
2528
+ * elements were deleted and all new elements inserted).
2529
+ *
2530
+ * To avoid this expensive operation, you can customize the default tracking algorithm.
2531
+ * by supplying the `trackBy` option to `NgForOf`.
2532
+ * `trackBy` takes a function that has two arguments: `index` and `item`.
2533
+ * If `trackBy` is given, Angular tracks changes by the return value of the function.
2534
+ *
2535
+ * @see [Structural Directives](guide/directives/structural-directives)
2536
+ * @ngModule CommonModule
2537
+ * @publicApi
2538
+ *
2539
+ * @deprecated Use the @for block instead. Intent to remove in v22
2540
+ */
2541
+ class NgForOf {
2542
+ _viewContainer;
2543
+ _template;
2544
+ _differs;
2545
+ /**
2546
+ * The value of the iterable expression, which can be used as a
2547
+ * [template input variable](guide/directives/structural-directives#shorthand).
2548
+ */
2549
+ set ngForOf(ngForOf) {
2550
+ this._ngForOf = ngForOf;
2551
+ this._ngForOfDirty = true;
2552
+ }
2553
+ /**
2554
+ * Specifies a custom `TrackByFunction` to compute the identity of items in an iterable.
2555
+ *
2556
+ * If a custom `TrackByFunction` is not provided, `NgForOf` will use the item's [object
2557
+ * identity](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is)
2558
+ * as the key.
2559
+ *
2560
+ * `NgForOf` uses the computed key to associate items in an iterable with DOM elements
2561
+ * it produces for these items.
2562
+ *
2563
+ * A custom `TrackByFunction` is useful to provide good user experience in cases when items in an
2564
+ * iterable rendered using `NgForOf` have a natural identifier (for example, custom ID or a
2565
+ * primary key), and this iterable could be updated with new object instances that still
2566
+ * represent the same underlying entity (for example, when data is re-fetched from the server,
2567
+ * and the iterable is recreated and re-rendered, but most of the data is still the same).
2568
+ *
2569
+ * @see {@link TrackByFunction}
2570
+ */
2571
+ set ngForTrackBy(fn) {
2572
+ if ((typeof ngDevMode === 'undefined' || ngDevMode) && fn != null && typeof fn !== 'function') {
2573
+ console.warn(`trackBy must be a function, but received ${JSON.stringify(fn)}. ` +
2574
+ `See https://angular.io/api/common/NgForOf#change-propagation for more information.`);
2575
+ }
2576
+ this._trackByFn = fn;
2577
+ }
2578
+ get ngForTrackBy() {
2579
+ return this._trackByFn;
2580
+ }
2581
+ _ngForOf = null;
2582
+ _ngForOfDirty = true;
2583
+ _differ = null;
2584
+ // waiting for microsoft/typescript#43662 to allow the return type `TrackByFunction|undefined` for
2585
+ // the getter
2586
+ _trackByFn;
2587
+ constructor(_viewContainer, _template, _differs) {
2588
+ this._viewContainer = _viewContainer;
2589
+ this._template = _template;
2590
+ this._differs = _differs;
2591
+ }
2592
+ /**
2593
+ * A reference to the template that is stamped out for each item in the iterable.
2594
+ * @see [template reference variable](guide/templates/variables#template-reference-variables)
2595
+ */
2596
+ set ngForTemplate(value) {
2597
+ // TODO(TS2.1): make TemplateRef<Partial<NgForRowOf<T>>> once we move to TS v2.1
2598
+ // The current type is too restrictive; a template that just uses index, for example,
2599
+ // should be acceptable.
2600
+ if (value) {
2601
+ this._template = value;
2602
+ }
2603
+ }
2604
+ /**
2605
+ * Applies the changes when needed.
2606
+ * @nodoc
2607
+ */
2608
+ ngDoCheck() {
2609
+ if (this._ngForOfDirty) {
2610
+ this._ngForOfDirty = false;
2611
+ // React on ngForOf changes only once all inputs have been initialized
2612
+ const value = this._ngForOf;
2613
+ if (!this._differ && value) {
2614
+ if (typeof ngDevMode === 'undefined' || ngDevMode) {
2615
+ try {
2616
+ // CAUTION: this logic is duplicated for production mode below, as the try-catch
2617
+ // is only present in development builds.
2618
+ this._differ = this._differs.find(value).create(this.ngForTrackBy);
2619
+ }
2620
+ catch {
2621
+ let errorMessage = `Cannot find a differ supporting object '${value}' of type '` +
2622
+ `${getTypeName(value)}'. NgFor only supports binding to Iterables, such as Arrays.`;
2623
+ if (typeof value === 'object') {
2624
+ errorMessage += ' Did you mean to use the keyvalue pipe?';
2625
+ }
2626
+ throw new _RuntimeError(-2200 /* RuntimeErrorCode.NG_FOR_MISSING_DIFFER */, errorMessage);
2627
+ }
2628
+ }
2629
+ else {
2630
+ // CAUTION: this logic is duplicated for development mode above, as the try-catch
2631
+ // is only present in development builds.
2632
+ this._differ = this._differs.find(value).create(this.ngForTrackBy);
2633
+ }
2634
+ }
2635
+ }
2636
+ if (this._differ) {
2637
+ const changes = this._differ.diff(this._ngForOf);
2638
+ if (changes)
2639
+ this._applyChanges(changes);
2640
+ }
2641
+ }
2642
+ _applyChanges(changes) {
2643
+ const viewContainer = this._viewContainer;
2644
+ changes.forEachOperation((item, adjustedPreviousIndex, currentIndex) => {
2645
+ if (item.previousIndex == null) {
2646
+ // NgForOf is never "null" or "undefined" here because the differ detected
2647
+ // that a new item needs to be inserted from the iterable. This implies that
2648
+ // there is an iterable value for "_ngForOf".
2649
+ viewContainer.createEmbeddedView(this._template, new NgForOfContext(item.item, this._ngForOf, -1, -1), currentIndex === null ? undefined : currentIndex);
2650
+ }
2651
+ else if (currentIndex == null) {
2652
+ viewContainer.remove(adjustedPreviousIndex === null ? undefined : adjustedPreviousIndex);
2653
+ }
2654
+ else if (adjustedPreviousIndex !== null) {
2655
+ const view = viewContainer.get(adjustedPreviousIndex);
2656
+ viewContainer.move(view, currentIndex);
2657
+ applyViewChange(view, item);
2658
+ }
2659
+ });
2660
+ for (let i = 0, ilen = viewContainer.length; i < ilen; i++) {
2661
+ const viewRef = viewContainer.get(i);
2662
+ const context = viewRef.context;
2663
+ context.index = i;
2664
+ context.count = ilen;
2665
+ context.ngForOf = this._ngForOf;
2666
+ }
2667
+ changes.forEachIdentityChange((record) => {
2668
+ const viewRef = viewContainer.get(record.currentIndex);
2669
+ applyViewChange(viewRef, record);
2670
+ });
2671
+ }
2672
+ /**
2673
+ * Asserts the correct type of the context for the template that `NgForOf` will render.
2674
+ *
2675
+ * The presence of this method is a signal to the Ivy template type-check compiler that the
2676
+ * `NgForOf` structural directive renders its template with a specific context type.
2677
+ */
2678
+ static ngTemplateContextGuard(dir, ctx) {
2679
+ return true;
2680
+ }
2681
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.0-next.5", ngImport: i0, type: NgForOf, deps: [{ token: i0.ViewContainerRef }, { token: i0.TemplateRef }, { token: i0.IterableDiffers }], target: i0.ɵɵFactoryTarget.Directive });
2682
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "20.0.0-next.5", type: NgForOf, isStandalone: true, selector: "[ngFor][ngForOf]", inputs: { ngForOf: "ngForOf", ngForTrackBy: "ngForTrackBy", ngForTemplate: "ngForTemplate" }, ngImport: i0 });
2683
+ }
2684
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.0-next.5", ngImport: i0, type: NgForOf, decorators: [{
2685
+ type: Directive,
2686
+ args: [{
2687
+ selector: '[ngFor][ngForOf]',
2688
+ }]
2689
+ }], ctorParameters: () => [{ type: i0.ViewContainerRef }, { type: i0.TemplateRef }, { type: i0.IterableDiffers }], propDecorators: { ngForOf: [{
2690
+ type: Input
2691
+ }], ngForTrackBy: [{
2692
+ type: Input
2693
+ }], ngForTemplate: [{
2694
+ type: Input
2695
+ }] } });
2696
+ function applyViewChange(view, record) {
2697
+ view.context.$implicit = record.item;
2698
+ }
2699
+ function getTypeName(type) {
2700
+ return type['name'] || typeof type;
2701
+ }
2702
+
2703
+ /**
2704
+ * A structural directive that conditionally includes a template based on the value of
2705
+ * an expression coerced to Boolean.
2706
+ * When the expression evaluates to true, Angular renders the template
2707
+ * provided in a `then` clause, and when false or null,
2708
+ * Angular renders the template provided in an optional `else` clause. The default
2709
+ * template for the `else` clause is blank.
2710
+ *
2711
+ * A [shorthand form](guide/directives/structural-directives#asterisk) of the directive,
2712
+ * `*ngIf="condition"`, is generally used, provided
2713
+ * as an attribute of the anchor element for the inserted template.
2714
+ * Angular expands this into a more explicit version, in which the anchor element
2715
+ * is contained in an `<ng-template>` element.
2716
+ *
2717
+ * Simple form with shorthand syntax:
2718
+ *
2719
+ * ```html
2720
+ * <div *ngIf="condition">Content to render when condition is true.</div>
2721
+ * ```
2722
+ *
2723
+ * Simple form with expanded syntax:
2724
+ *
2725
+ * ```html
2726
+ * <ng-template [ngIf]="condition"><div>Content to render when condition is
2727
+ * true.</div></ng-template>
2728
+ * ```
2729
+ *
2730
+ * Form with an "else" block:
2731
+ *
2732
+ * ```html
2733
+ * <div *ngIf="condition; else elseBlock">Content to render when condition is true.</div>
2734
+ * <ng-template #elseBlock>Content to render when condition is false.</ng-template>
2735
+ * ```
2736
+ *
2737
+ * Shorthand form with "then" and "else" blocks:
2738
+ *
2739
+ * ```html
2740
+ * <div *ngIf="condition; then thenBlock else elseBlock"></div>
2741
+ * <ng-template #thenBlock>Content to render when condition is true.</ng-template>
2742
+ * <ng-template #elseBlock>Content to render when condition is false.</ng-template>
2743
+ * ```
2744
+ *
2745
+ * Form with storing the value locally:
2746
+ *
2747
+ * ```html
2748
+ * <div *ngIf="condition as value; else elseBlock">{{value}}</div>
2749
+ * <ng-template #elseBlock>Content to render when value is null.</ng-template>
2750
+ * ```
2751
+ *
2752
+ * @usageNotes
2753
+ *
2754
+ * The `*ngIf` directive is most commonly used to conditionally show an inline template,
2755
+ * as seen in the following example.
2756
+ * The default `else` template is blank.
2757
+ *
2758
+ * {@example common/ngIf/ts/module.ts region='NgIfSimple'}
2759
+ *
2760
+ * ### Showing an alternative template using `else`
2761
+ *
2762
+ * To display a template when `expression` evaluates to false, use an `else` template
2763
+ * binding as shown in the following example.
2764
+ * The `else` binding points to an `<ng-template>` element labeled `#elseBlock`.
2765
+ * The template can be defined anywhere in the component view, but is typically placed right after
2766
+ * `ngIf` for readability.
2767
+ *
2768
+ * {@example common/ngIf/ts/module.ts region='NgIfElse'}
2769
+ *
2770
+ * ### Using an external `then` template
2771
+ *
2772
+ * In the previous example, the then-clause template is specified inline, as the content of the
2773
+ * tag that contains the `ngIf` directive. You can also specify a template that is defined
2774
+ * externally, by referencing a labeled `<ng-template>` element. When you do this, you can
2775
+ * change which template to use at runtime, as shown in the following example.
2776
+ *
2777
+ * {@example common/ngIf/ts/module.ts region='NgIfThenElse'}
2778
+ *
2779
+ * ### Storing a conditional result in a variable
2780
+ *
2781
+ * You might want to show a set of properties from the same object. If you are waiting
2782
+ * for asynchronous data, the object can be undefined.
2783
+ * In this case, you can use `ngIf` and store the result of the condition in a local
2784
+ * variable as shown in the following example.
2785
+ *
2786
+ * {@example common/ngIf/ts/module.ts region='NgIfAs'}
2787
+ *
2788
+ * This code uses only one `AsyncPipe`, so only one subscription is created.
2789
+ * The conditional statement stores the result of `userStream|async` in the local variable `user`.
2790
+ * You can then bind the local `user` repeatedly.
2791
+ *
2792
+ * The conditional displays the data only if `userStream` returns a value,
2793
+ * so you don't need to use the
2794
+ * safe-navigation-operator (`?.`)
2795
+ * to guard against null values when accessing properties.
2796
+ * You can display an alternative template while waiting for the data.
2797
+ *
2798
+ * ### Shorthand syntax
2799
+ *
2800
+ * The shorthand syntax `*ngIf` expands into two separate template specifications
2801
+ * for the "then" and "else" clauses. For example, consider the following shorthand statement,
2802
+ * that is meant to show a loading page while waiting for data to be loaded.
2803
+ *
2804
+ * ```html
2805
+ * <div class="hero-list" *ngIf="heroes else loading">
2806
+ * ...
2807
+ * </div>
2808
+ *
2809
+ * <ng-template #loading>
2810
+ * <div>Loading...</div>
2811
+ * </ng-template>
2812
+ * ```
2813
+ *
2814
+ * You can see that the "else" clause references the `<ng-template>`
2815
+ * with the `#loading` label, and the template for the "then" clause
2816
+ * is provided as the content of the anchor element.
2817
+ *
2818
+ * However, when Angular expands the shorthand syntax, it creates
2819
+ * another `<ng-template>` tag, with `ngIf` and `ngIfElse` directives.
2820
+ * The anchor element containing the template for the "then" clause becomes
2821
+ * the content of this unlabeled `<ng-template>` tag.
2822
+ *
2823
+ * ```html
2824
+ * <ng-template [ngIf]="heroes" [ngIfElse]="loading">
2825
+ * <div class="hero-list">
2826
+ * ...
2827
+ * </div>
2828
+ * </ng-template>
2829
+ *
2830
+ * <ng-template #loading>
2831
+ * <div>Loading...</div>
2832
+ * </ng-template>
2833
+ * ```
2834
+ *
2835
+ * The presence of the implicit template object has implications for the nesting of
2836
+ * structural directives. For more on this subject, see
2837
+ * [Structural Directives](guide/directives/structural-directives#one-per-element).
2838
+ *
2839
+ * @ngModule CommonModule
2840
+ * @publicApi
2841
+ *
2842
+ * @deprecated Use the @if block instead. Intent to remove in v22
2843
+ */
2844
+ class NgIf {
2845
+ _viewContainer;
2846
+ _context = new NgIfContext();
2847
+ _thenTemplateRef = null;
2848
+ _elseTemplateRef = null;
2849
+ _thenViewRef = null;
2850
+ _elseViewRef = null;
2851
+ constructor(_viewContainer, templateRef) {
2852
+ this._viewContainer = _viewContainer;
2853
+ this._thenTemplateRef = templateRef;
2854
+ }
2855
+ /**
2856
+ * The Boolean expression to evaluate as the condition for showing a template.
2857
+ */
2858
+ set ngIf(condition) {
2859
+ this._context.$implicit = this._context.ngIf = condition;
2860
+ this._updateView();
2861
+ }
2862
+ /**
2863
+ * A template to show if the condition expression evaluates to true.
2864
+ */
2865
+ set ngIfThen(templateRef) {
2866
+ assertTemplate(templateRef, (typeof ngDevMode === 'undefined' || ngDevMode) && 'ngIfThen');
2867
+ this._thenTemplateRef = templateRef;
2868
+ this._thenViewRef = null; // clear previous view if any.
2869
+ this._updateView();
2870
+ }
2871
+ /**
2872
+ * A template to show if the condition expression evaluates to false.
2873
+ */
2874
+ set ngIfElse(templateRef) {
2875
+ assertTemplate(templateRef, (typeof ngDevMode === 'undefined' || ngDevMode) && 'ngIfElse');
2876
+ this._elseTemplateRef = templateRef;
2877
+ this._elseViewRef = null; // clear previous view if any.
2878
+ this._updateView();
2879
+ }
2880
+ _updateView() {
2881
+ if (this._context.$implicit) {
2882
+ if (!this._thenViewRef) {
2883
+ this._viewContainer.clear();
2884
+ this._elseViewRef = null;
2885
+ if (this._thenTemplateRef) {
2886
+ this._thenViewRef = this._viewContainer.createEmbeddedView(this._thenTemplateRef, this._context);
2887
+ }
2888
+ }
2889
+ }
2890
+ else {
2891
+ if (!this._elseViewRef) {
2892
+ this._viewContainer.clear();
2893
+ this._thenViewRef = null;
2894
+ if (this._elseTemplateRef) {
2895
+ this._elseViewRef = this._viewContainer.createEmbeddedView(this._elseTemplateRef, this._context);
2896
+ }
2897
+ }
2898
+ }
2899
+ }
2900
+ /** @internal */
2901
+ static ngIfUseIfTypeGuard;
2902
+ /**
2903
+ * Assert the correct type of the expression bound to the `ngIf` input within the template.
2904
+ *
2905
+ * The presence of this static field is a signal to the Ivy template type check compiler that
2906
+ * when the `NgIf` structural directive renders its template, the type of the expression bound
2907
+ * to `ngIf` should be narrowed in some way. For `NgIf`, the binding expression itself is used to
2908
+ * narrow its type, which allows the strictNullChecks feature of TypeScript to work with `NgIf`.
2909
+ */
2910
+ static ngTemplateGuard_ngIf;
2911
+ /**
2912
+ * Asserts the correct type of the context for the template that `NgIf` will render.
2913
+ *
2914
+ * The presence of this method is a signal to the Ivy template type-check compiler that the
2915
+ * `NgIf` structural directive renders its template with a specific context type.
2916
+ */
2917
+ static ngTemplateContextGuard(dir, ctx) {
2918
+ return true;
2919
+ }
2920
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.0-next.5", ngImport: i0, type: NgIf, deps: [{ token: i0.ViewContainerRef }, { token: i0.TemplateRef }], target: i0.ɵɵFactoryTarget.Directive });
2921
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "20.0.0-next.5", type: NgIf, isStandalone: true, selector: "[ngIf]", inputs: { ngIf: "ngIf", ngIfThen: "ngIfThen", ngIfElse: "ngIfElse" }, ngImport: i0 });
2922
+ }
2923
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.0-next.5", ngImport: i0, type: NgIf, decorators: [{
2924
+ type: Directive,
2925
+ args: [{
2926
+ selector: '[ngIf]',
2927
+ }]
2928
+ }], ctorParameters: () => [{ type: i0.ViewContainerRef }, { type: i0.TemplateRef }], propDecorators: { ngIf: [{
2929
+ type: Input
2930
+ }], ngIfThen: [{
2931
+ type: Input
2932
+ }], ngIfElse: [{
2933
+ type: Input
2934
+ }] } });
2935
+ /**
2936
+ * @publicApi
2937
+ */
2938
+ class NgIfContext {
2939
+ $implicit = null;
2940
+ ngIf = null;
2941
+ }
2942
+ function assertTemplate(templateRef, property) {
2943
+ if (templateRef && !templateRef.createEmbeddedView) {
2944
+ throw new _RuntimeError(2020 /* RuntimeErrorCode.NG_IF_NOT_A_TEMPLATE_REF */, (typeof ngDevMode === 'undefined' || ngDevMode) &&
2945
+ `${property} must be a TemplateRef, but received '${_stringify(templateRef)}'.`);
2946
+ }
2947
+ }
2948
+
2949
+ class SwitchView {
2950
+ _viewContainerRef;
2951
+ _templateRef;
2952
+ _created = false;
2953
+ constructor(_viewContainerRef, _templateRef) {
2954
+ this._viewContainerRef = _viewContainerRef;
2955
+ this._templateRef = _templateRef;
2956
+ }
2957
+ create() {
2958
+ this._created = true;
2959
+ this._viewContainerRef.createEmbeddedView(this._templateRef);
2960
+ }
2961
+ destroy() {
2962
+ this._created = false;
2963
+ this._viewContainerRef.clear();
2964
+ }
2965
+ enforceState(created) {
2966
+ if (created && !this._created) {
2967
+ this.create();
2968
+ }
2969
+ else if (!created && this._created) {
2970
+ this.destroy();
2971
+ }
2972
+ }
2973
+ }
2974
+ /**
2975
+ * @ngModule CommonModule
2976
+ *
2977
+ * @description
2978
+ * The `[ngSwitch]` directive on a container specifies an expression to match against.
2979
+ * The expressions to match are provided by `ngSwitchCase` directives on views within the container.
2980
+ * - Every view that matches is rendered.
2981
+ * - If there are no matches, a view with the `ngSwitchDefault` directive is rendered.
2982
+ * - Elements within the `[NgSwitch]` statement but outside of any `NgSwitchCase`
2983
+ * or `ngSwitchDefault` directive are preserved at the location.
2984
+ *
2985
+ * @usageNotes
2986
+ * Define a container element for the directive, and specify the switch expression
2987
+ * to match against as an attribute:
2988
+ *
2989
+ * ```html
2990
+ * <container-element [ngSwitch]="switch_expression">
2991
+ * ```
2992
+ *
2993
+ * Within the container, `*ngSwitchCase` statements specify the match expressions
2994
+ * as attributes. Include `*ngSwitchDefault` as the final case.
2995
+ *
2996
+ * ```html
2997
+ * <container-element [ngSwitch]="switch_expression">
2998
+ * <some-element *ngSwitchCase="match_expression_1">...</some-element>
2999
+ * ...
3000
+ * <some-element *ngSwitchDefault>...</some-element>
3001
+ * </container-element>
3002
+ * ```
3003
+ *
3004
+ * ### Usage Examples
3005
+ *
3006
+ * The following example shows how to use more than one case to display the same view:
3007
+ *
3008
+ * ```html
3009
+ * <container-element [ngSwitch]="switch_expression">
3010
+ * <!-- the same view can be shown in more than one case -->
3011
+ * <some-element *ngSwitchCase="match_expression_1">...</some-element>
3012
+ * <some-element *ngSwitchCase="match_expression_2">...</some-element>
3013
+ * <some-other-element *ngSwitchCase="match_expression_3">...</some-other-element>
3014
+ * <!--default case when there are no matches -->
3015
+ * <some-element *ngSwitchDefault>...</some-element>
3016
+ * </container-element>
3017
+ * ```
3018
+ *
3019
+ * The following example shows how cases can be nested:
3020
+ * ```html
3021
+ * <container-element [ngSwitch]="switch_expression">
3022
+ * <some-element *ngSwitchCase="match_expression_1">...</some-element>
3023
+ * <some-element *ngSwitchCase="match_expression_2">...</some-element>
3024
+ * <some-other-element *ngSwitchCase="match_expression_3">...</some-other-element>
3025
+ * <ng-container *ngSwitchCase="match_expression_3">
3026
+ * <!-- use a ng-container to group multiple root nodes -->
3027
+ * <inner-element></inner-element>
3028
+ * <inner-other-element></inner-other-element>
3029
+ * </ng-container>
3030
+ * <some-element *ngSwitchDefault>...</some-element>
3031
+ * </container-element>
3032
+ * ```
3033
+ *
3034
+ * @publicApi
3035
+ * @see {@link NgSwitchCase}
3036
+ * @see {@link NgSwitchDefault}
3037
+ * @see [Structural Directives](guide/directives/structural-directives)
3038
+ *
3039
+ * @deprecated Use the @switch block instead. Intent to remove in v22
3040
+ */
3041
+ class NgSwitch {
3042
+ _defaultViews = [];
3043
+ _defaultUsed = false;
3044
+ _caseCount = 0;
3045
+ _lastCaseCheckIndex = 0;
3046
+ _lastCasesMatched = false;
3047
+ _ngSwitch;
3048
+ set ngSwitch(newValue) {
3049
+ this._ngSwitch = newValue;
3050
+ if (this._caseCount === 0) {
3051
+ this._updateDefaultCases(true);
3052
+ }
3053
+ }
3054
+ /** @internal */
3055
+ _addCase() {
3056
+ return this._caseCount++;
3057
+ }
3058
+ /** @internal */
3059
+ _addDefault(view) {
3060
+ this._defaultViews.push(view);
3061
+ }
3062
+ /** @internal */
3063
+ _matchCase(value) {
3064
+ const matched = value === this._ngSwitch;
3065
+ this._lastCasesMatched ||= matched;
3066
+ this._lastCaseCheckIndex++;
3067
+ if (this._lastCaseCheckIndex === this._caseCount) {
3068
+ this._updateDefaultCases(!this._lastCasesMatched);
3069
+ this._lastCaseCheckIndex = 0;
3070
+ this._lastCasesMatched = false;
3071
+ }
3072
+ return matched;
3073
+ }
3074
+ _updateDefaultCases(useDefault) {
3075
+ if (this._defaultViews.length > 0 && useDefault !== this._defaultUsed) {
3076
+ this._defaultUsed = useDefault;
3077
+ for (const defaultView of this._defaultViews) {
3078
+ defaultView.enforceState(useDefault);
3079
+ }
3080
+ }
3081
+ }
3082
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.0-next.5", ngImport: i0, type: NgSwitch, deps: [], target: i0.ɵɵFactoryTarget.Directive });
3083
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "20.0.0-next.5", type: NgSwitch, isStandalone: true, selector: "[ngSwitch]", inputs: { ngSwitch: "ngSwitch" }, ngImport: i0 });
3084
+ }
3085
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.0-next.5", ngImport: i0, type: NgSwitch, decorators: [{
3086
+ type: Directive,
3087
+ args: [{
3088
+ selector: '[ngSwitch]',
3089
+ }]
3090
+ }], propDecorators: { ngSwitch: [{
3091
+ type: Input
3092
+ }] } });
3093
+ /**
3094
+ * @ngModule CommonModule
3095
+ *
3096
+ * @description
3097
+ * Provides a switch case expression to match against an enclosing `ngSwitch` expression.
3098
+ * When the expressions match, the given `NgSwitchCase` template is rendered.
3099
+ * If multiple match expressions match the switch expression value, all of them are displayed.
3100
+ *
3101
+ * @usageNotes
3102
+ *
3103
+ * Within a switch container, `*ngSwitchCase` statements specify the match expressions
3104
+ * as attributes. Include `*ngSwitchDefault` as the final case.
3105
+ *
3106
+ * ```html
3107
+ * <container-element [ngSwitch]="switch_expression">
3108
+ * <some-element *ngSwitchCase="match_expression_1">...</some-element>
3109
+ * ...
3110
+ * <some-element *ngSwitchDefault>...</some-element>
3111
+ * </container-element>
3112
+ * ```
3113
+ *
3114
+ * Each switch-case statement contains an in-line HTML template or template reference
3115
+ * that defines the subtree to be selected if the value of the match expression
3116
+ * matches the value of the switch expression.
3117
+ *
3118
+ * As of Angular v17 the NgSwitch directive uses strict equality comparison (`===`) instead of
3119
+ * loose equality (`==`) to match different cases.
3120
+ *
3121
+ * @publicApi
3122
+ * @see {@link NgSwitch}
3123
+ * @see {@link NgSwitchDefault}
3124
+ *
3125
+ * @deprecated Use the @case block within a @switch block instead. Intent to remove in v22
3126
+ */
3127
+ class NgSwitchCase {
3128
+ ngSwitch;
3129
+ _view;
3130
+ /**
3131
+ * Stores the HTML template to be selected on match.
3132
+ */
3133
+ ngSwitchCase;
3134
+ constructor(viewContainer, templateRef, ngSwitch) {
3135
+ this.ngSwitch = ngSwitch;
3136
+ if ((typeof ngDevMode === 'undefined' || ngDevMode) && !ngSwitch) {
3137
+ throwNgSwitchProviderNotFoundError('ngSwitchCase', 'NgSwitchCase');
3138
+ }
3139
+ ngSwitch._addCase();
3140
+ this._view = new SwitchView(viewContainer, templateRef);
3141
+ }
3142
+ /**
3143
+ * Performs case matching. For internal use only.
3144
+ * @nodoc
3145
+ */
3146
+ ngDoCheck() {
3147
+ this._view.enforceState(this.ngSwitch._matchCase(this.ngSwitchCase));
3148
+ }
3149
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.0-next.5", ngImport: i0, type: NgSwitchCase, deps: [{ token: i0.ViewContainerRef }, { token: i0.TemplateRef }, { token: NgSwitch, host: true, optional: true }], target: i0.ɵɵFactoryTarget.Directive });
3150
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "20.0.0-next.5", type: NgSwitchCase, isStandalone: true, selector: "[ngSwitchCase]", inputs: { ngSwitchCase: "ngSwitchCase" }, ngImport: i0 });
3151
+ }
3152
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.0-next.5", ngImport: i0, type: NgSwitchCase, decorators: [{
3153
+ type: Directive,
3154
+ args: [{
3155
+ selector: '[ngSwitchCase]',
3156
+ }]
3157
+ }], ctorParameters: () => [{ type: i0.ViewContainerRef }, { type: i0.TemplateRef }, { type: NgSwitch, decorators: [{
3158
+ type: Optional
3159
+ }, {
3160
+ type: Host
3161
+ }] }], propDecorators: { ngSwitchCase: [{
3162
+ type: Input
3163
+ }] } });
3164
+ /**
3165
+ * @ngModule CommonModule
3166
+ *
3167
+ * @description
3168
+ *
3169
+ * Creates a view that is rendered when no `NgSwitchCase` expressions
3170
+ * match the `NgSwitch` expression.
3171
+ * This statement should be the final case in an `NgSwitch`.
3172
+ *
3173
+ * @publicApi
3174
+ * @see {@link NgSwitch}
3175
+ * @see {@link NgSwitchCase}
3176
+ *
3177
+ * @deprecated Use the @default block within a @switch block instead. Intent to remove in v22
3178
+ */
3179
+ class NgSwitchDefault {
3180
+ constructor(viewContainer, templateRef, ngSwitch) {
3181
+ if ((typeof ngDevMode === 'undefined' || ngDevMode) && !ngSwitch) {
3182
+ throwNgSwitchProviderNotFoundError('ngSwitchDefault', 'NgSwitchDefault');
3183
+ }
3184
+ ngSwitch._addDefault(new SwitchView(viewContainer, templateRef));
3185
+ }
3186
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.0-next.5", ngImport: i0, type: NgSwitchDefault, deps: [{ token: i0.ViewContainerRef }, { token: i0.TemplateRef }, { token: NgSwitch, host: true, optional: true }], target: i0.ɵɵFactoryTarget.Directive });
3187
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "20.0.0-next.5", type: NgSwitchDefault, isStandalone: true, selector: "[ngSwitchDefault]", ngImport: i0 });
3188
+ }
3189
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.0-next.5", ngImport: i0, type: NgSwitchDefault, decorators: [{
3190
+ type: Directive,
3191
+ args: [{
3192
+ selector: '[ngSwitchDefault]',
3193
+ }]
3194
+ }], ctorParameters: () => [{ type: i0.ViewContainerRef }, { type: i0.TemplateRef }, { type: NgSwitch, decorators: [{
3195
+ type: Optional
3196
+ }, {
3197
+ type: Host
3198
+ }] }] });
3199
+ function throwNgSwitchProviderNotFoundError(attrName, directiveName) {
3200
+ throw new _RuntimeError(2000 /* RuntimeErrorCode.PARENT_NG_SWITCH_NOT_FOUND */, `An element with the "${attrName}" attribute ` +
3201
+ `(matching the "${directiveName}" directive) must be located inside an element with the "ngSwitch" attribute ` +
3202
+ `(matching "NgSwitch" directive)`);
3203
+ }
3204
+
3205
+ /**
3206
+ * @ngModule CommonModule
3207
+ *
3208
+ * @usageNotes
3209
+ * ```html
3210
+ * <some-element [ngPlural]="value">
3211
+ * <ng-template ngPluralCase="=0">there is nothing</ng-template>
3212
+ * <ng-template ngPluralCase="=1">there is one</ng-template>
3213
+ * <ng-template ngPluralCase="few">there are a few</ng-template>
3214
+ * </some-element>
3215
+ * ```
3216
+ *
3217
+ * @description
3218
+ *
3219
+ * Adds / removes DOM sub-trees based on a numeric value. Tailored for pluralization.
3220
+ *
3221
+ * Displays DOM sub-trees that match the switch expression value, or failing that, DOM sub-trees
3222
+ * that match the switch expression's pluralization category.
3223
+ *
3224
+ * To use this directive you must provide a container element that sets the `[ngPlural]` attribute
3225
+ * to a switch expression. Inner elements with a `[ngPluralCase]` will display based on their
3226
+ * expression:
3227
+ * - if `[ngPluralCase]` is set to a value starting with `=`, it will only display if the value
3228
+ * matches the switch expression exactly,
3229
+ * - otherwise, the view will be treated as a "category match", and will only display if exact
3230
+ * value matches aren't found and the value maps to its category for the defined locale.
3231
+ *
3232
+ * See http://cldr.unicode.org/index/cldr-spec/plural-rules
3233
+ *
3234
+ * @publicApi
3235
+ */
3236
+ class NgPlural {
3237
+ _localization;
3238
+ _activeView;
3239
+ _caseViews = {};
3240
+ constructor(_localization) {
3241
+ this._localization = _localization;
3242
+ }
3243
+ set ngPlural(value) {
3244
+ this._updateView(value);
3245
+ }
3246
+ addCase(value, switchView) {
3247
+ this._caseViews[value] = switchView;
3248
+ }
3249
+ _updateView(switchValue) {
3250
+ this._clearViews();
3251
+ const cases = Object.keys(this._caseViews);
3252
+ const key = getPluralCategory(switchValue, cases, this._localization);
3253
+ this._activateView(this._caseViews[key]);
3254
+ }
3255
+ _clearViews() {
3256
+ if (this._activeView)
3257
+ this._activeView.destroy();
3258
+ }
3259
+ _activateView(view) {
3260
+ if (view) {
3261
+ this._activeView = view;
3262
+ this._activeView.create();
3263
+ }
3264
+ }
3265
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.0-next.5", ngImport: i0, type: NgPlural, deps: [{ token: NgLocalization }], target: i0.ɵɵFactoryTarget.Directive });
3266
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "20.0.0-next.5", type: NgPlural, isStandalone: true, selector: "[ngPlural]", inputs: { ngPlural: "ngPlural" }, ngImport: i0 });
3267
+ }
3268
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.0-next.5", ngImport: i0, type: NgPlural, decorators: [{
3269
+ type: Directive,
3270
+ args: [{
3271
+ selector: '[ngPlural]',
3272
+ }]
3273
+ }], ctorParameters: () => [{ type: NgLocalization }], propDecorators: { ngPlural: [{
3274
+ type: Input
3275
+ }] } });
3276
+ /**
3277
+ * @ngModule CommonModule
3278
+ *
3279
+ * @description
3280
+ *
3281
+ * Creates a view that will be added/removed from the parent {@link NgPlural} when the
3282
+ * given expression matches the plural expression according to CLDR rules.
3283
+ *
3284
+ * @usageNotes
3285
+ * ```html
3286
+ * <some-element [ngPlural]="value">
3287
+ * <ng-template ngPluralCase="=0">...</ng-template>
3288
+ * <ng-template ngPluralCase="other">...</ng-template>
3289
+ * </some-element>
3290
+ *```
3291
+ *
3292
+ * See {@link NgPlural} for more details and example.
3293
+ *
3294
+ * @publicApi
3295
+ */
3296
+ class NgPluralCase {
3297
+ value;
3298
+ constructor(value, template, viewContainer, ngPlural) {
3299
+ this.value = value;
3300
+ const isANumber = !isNaN(Number(value));
3301
+ ngPlural.addCase(isANumber ? `=${value}` : value, new SwitchView(viewContainer, template));
3302
+ }
3303
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.0-next.5", ngImport: i0, type: NgPluralCase, deps: [{ token: 'ngPluralCase', attribute: true }, { token: i0.TemplateRef }, { token: i0.ViewContainerRef }, { token: NgPlural, host: true }], target: i0.ɵɵFactoryTarget.Directive });
3304
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "20.0.0-next.5", type: NgPluralCase, isStandalone: true, selector: "[ngPluralCase]", ngImport: i0 });
3305
+ }
3306
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.0-next.5", ngImport: i0, type: NgPluralCase, decorators: [{
3307
+ type: Directive,
3308
+ args: [{
3309
+ selector: '[ngPluralCase]',
3310
+ }]
3311
+ }], ctorParameters: () => [{ type: undefined, decorators: [{
3312
+ type: Attribute,
3313
+ args: ['ngPluralCase']
3314
+ }] }, { type: i0.TemplateRef }, { type: i0.ViewContainerRef }, { type: NgPlural, decorators: [{
3315
+ type: Host
3316
+ }] }] });
3317
+
3318
+ /**
3319
+ * @ngModule CommonModule
3320
+ *
3321
+ * @usageNotes
3322
+ *
3323
+ * Set the width of the containing element to a pixel value returned by an expression.
3324
+ *
3325
+ * ```html
3326
+ * <some-element [ngStyle]="{'max-width.px': widthExp}">...</some-element>
3327
+ * ```
3328
+ *
3329
+ * Set a collection of style values using an expression that returns key-value pairs.
3330
+ *
3331
+ * ```html
3332
+ * <some-element [ngStyle]="objExp">...</some-element>
3333
+ * ```
3334
+ *
3335
+ * For more simple use cases you can use the [style bindings](/guide/templates/binding#css-class-and-style-property-bindings) directly.
3336
+ * It doesn't require importing a directive.
3337
+ *
3338
+ * Set the font of the containing element to the result of an expression.
3339
+ *
3340
+ * ```html
3341
+ * <some-element [style]="{'font-style': styleExp}">...</some-element>
3342
+ * ```
3343
+ *
3344
+ * @description
3345
+ *
3346
+ * An attribute directive that updates styles for the containing HTML element.
3347
+ * Sets one or more style properties, specified as colon-separated key-value pairs.
3348
+ * The key is a style name, with an optional `.<unit>` suffix
3349
+ * (such as 'top.px', 'font-style.em').
3350
+ * The value is an expression to be evaluated.
3351
+ * The resulting non-null value, expressed in the given unit,
3352
+ * is assigned to the given style property.
3353
+ * If the result of evaluation is null, the corresponding style is removed.
3354
+ *
3355
+ * @see [Style bindings](/guide/templates/binding#css-class-and-style-property-bindings)
3356
+ *
3357
+ * @publicApi
3358
+ */
3359
+ class NgStyle {
3360
+ _ngEl;
3361
+ _differs;
3362
+ _renderer;
3363
+ _ngStyle = null;
3364
+ _differ = null;
3365
+ constructor(_ngEl, _differs, _renderer) {
3366
+ this._ngEl = _ngEl;
3367
+ this._differs = _differs;
3368
+ this._renderer = _renderer;
3369
+ }
3370
+ set ngStyle(values) {
3371
+ this._ngStyle = values;
3372
+ if (!this._differ && values) {
3373
+ this._differ = this._differs.find(values).create();
3374
+ }
3375
+ }
3376
+ ngDoCheck() {
3377
+ if (this._differ) {
3378
+ const changes = this._differ.diff(this._ngStyle);
3379
+ if (changes) {
3380
+ this._applyChanges(changes);
3381
+ }
3382
+ }
3383
+ }
3384
+ _setStyle(nameAndUnit, value) {
3385
+ const [name, unit] = nameAndUnit.split('.');
3386
+ const flags = name.indexOf('-') === -1 ? undefined : RendererStyleFlags2.DashCase;
3387
+ if (value != null) {
3388
+ this._renderer.setStyle(this._ngEl.nativeElement, name, unit ? `${value}${unit}` : value, flags);
3389
+ }
3390
+ else {
3391
+ this._renderer.removeStyle(this._ngEl.nativeElement, name, flags);
3392
+ }
3393
+ }
3394
+ _applyChanges(changes) {
3395
+ changes.forEachRemovedItem((record) => this._setStyle(record.key, null));
3396
+ changes.forEachAddedItem((record) => this._setStyle(record.key, record.currentValue));
3397
+ changes.forEachChangedItem((record) => this._setStyle(record.key, record.currentValue));
3398
+ }
3399
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.0-next.5", ngImport: i0, type: NgStyle, deps: [{ token: i0.ElementRef }, { token: i0.KeyValueDiffers }, { token: i0.Renderer2 }], target: i0.ɵɵFactoryTarget.Directive });
3400
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "20.0.0-next.5", type: NgStyle, isStandalone: true, selector: "[ngStyle]", inputs: { ngStyle: "ngStyle" }, ngImport: i0 });
3401
+ }
3402
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.0-next.5", ngImport: i0, type: NgStyle, decorators: [{
3403
+ type: Directive,
3404
+ args: [{
3405
+ selector: '[ngStyle]',
3406
+ }]
3407
+ }], ctorParameters: () => [{ type: i0.ElementRef }, { type: i0.KeyValueDiffers }, { type: i0.Renderer2 }], propDecorators: { ngStyle: [{
3408
+ type: Input,
3409
+ args: ['ngStyle']
3410
+ }] } });
3411
+
3412
+ /**
3413
+ * @ngModule CommonModule
3414
+ *
3415
+ * @description
3416
+ *
3417
+ * Inserts an embedded view from a prepared `TemplateRef`.
3418
+ *
3419
+ * You can attach a context object to the `EmbeddedViewRef` by setting `[ngTemplateOutletContext]`.
3420
+ * `[ngTemplateOutletContext]` should be an object, the object's keys will be available for binding
3421
+ * by the local template `let` declarations.
3422
+ *
3423
+ * @usageNotes
3424
+ * ```html
3425
+ * <ng-container *ngTemplateOutlet="templateRefExp; context: contextExp"></ng-container>
3426
+ * ```
3427
+ *
3428
+ * Using the key `$implicit` in the context object will set its value as default.
3429
+ *
3430
+ * ### Example
3431
+ *
3432
+ * {@example common/ngTemplateOutlet/ts/module.ts region='NgTemplateOutlet'}
3433
+ *
3434
+ * @publicApi
3435
+ */
3436
+ class NgTemplateOutlet {
3437
+ _viewContainerRef;
3438
+ _viewRef = null;
3439
+ /**
3440
+ * A context object to attach to the {@link EmbeddedViewRef}. This should be an
3441
+ * object, the object's keys will be available for binding by the local template `let`
3442
+ * declarations.
3443
+ * Using the key `$implicit` in the context object will set its value as default.
3444
+ */
3445
+ ngTemplateOutletContext = null;
3446
+ /**
3447
+ * A string defining the template reference and optionally the context object for the template.
3448
+ */
3449
+ ngTemplateOutlet = null;
3450
+ /** Injector to be used within the embedded view. */
3451
+ ngTemplateOutletInjector = null;
3452
+ constructor(_viewContainerRef) {
3453
+ this._viewContainerRef = _viewContainerRef;
3454
+ }
3455
+ ngOnChanges(changes) {
3456
+ if (this._shouldRecreateView(changes)) {
3457
+ const viewContainerRef = this._viewContainerRef;
3458
+ if (this._viewRef) {
3459
+ viewContainerRef.remove(viewContainerRef.indexOf(this._viewRef));
3460
+ }
3461
+ // If there is no outlet, clear the destroyed view ref.
3462
+ if (!this.ngTemplateOutlet) {
3463
+ this._viewRef = null;
3464
+ return;
3465
+ }
3466
+ // Create a context forward `Proxy` that will always bind to the user-specified context,
3467
+ // without having to destroy and re-create views whenever the context changes.
3468
+ const viewContext = this._createContextForwardProxy();
3469
+ this._viewRef = viewContainerRef.createEmbeddedView(this.ngTemplateOutlet, viewContext, {
3470
+ injector: this.ngTemplateOutletInjector ?? undefined,
3471
+ });
3472
+ }
3473
+ }
3474
+ /**
3475
+ * We need to re-create existing embedded view if either is true:
3476
+ * - the outlet changed.
3477
+ * - the injector changed.
3478
+ */
3479
+ _shouldRecreateView(changes) {
3480
+ return !!changes['ngTemplateOutlet'] || !!changes['ngTemplateOutletInjector'];
3481
+ }
3482
+ /**
3483
+ * For a given outlet instance, we create a proxy object that delegates
3484
+ * to the user-specified context. This allows changing, or swapping out
3485
+ * the context object completely without having to destroy/re-create the view.
3486
+ */
3487
+ _createContextForwardProxy() {
3488
+ return new Proxy({}, {
3489
+ set: (_target, prop, newValue) => {
3490
+ if (!this.ngTemplateOutletContext) {
3491
+ return false;
3492
+ }
3493
+ return Reflect.set(this.ngTemplateOutletContext, prop, newValue);
3494
+ },
3495
+ get: (_target, prop, receiver) => {
3496
+ if (!this.ngTemplateOutletContext) {
3497
+ return undefined;
3498
+ }
3499
+ return Reflect.get(this.ngTemplateOutletContext, prop, receiver);
3500
+ },
3501
+ });
3502
+ }
3503
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.0-next.5", ngImport: i0, type: NgTemplateOutlet, deps: [{ token: i0.ViewContainerRef }], target: i0.ɵɵFactoryTarget.Directive });
3504
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "20.0.0-next.5", type: NgTemplateOutlet, isStandalone: true, selector: "[ngTemplateOutlet]", inputs: { ngTemplateOutletContext: "ngTemplateOutletContext", ngTemplateOutlet: "ngTemplateOutlet", ngTemplateOutletInjector: "ngTemplateOutletInjector" }, usesOnChanges: true, ngImport: i0 });
3505
+ }
3506
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.0-next.5", ngImport: i0, type: NgTemplateOutlet, decorators: [{
3507
+ type: Directive,
3508
+ args: [{
3509
+ selector: '[ngTemplateOutlet]',
3510
+ }]
3511
+ }], ctorParameters: () => [{ type: i0.ViewContainerRef }], propDecorators: { ngTemplateOutletContext: [{
3512
+ type: Input
3513
+ }], ngTemplateOutlet: [{
3514
+ type: Input
3515
+ }], ngTemplateOutletInjector: [{
3516
+ type: Input
3517
+ }] } });
3518
+
3519
+ /**
3520
+ * A collection of Angular directives that are likely to be used in each and every Angular
3521
+ * application.
3522
+ */
3523
+ const COMMON_DIRECTIVES = [
3524
+ NgClass,
3525
+ NgComponentOutlet,
3526
+ NgForOf,
3527
+ NgIf,
3528
+ NgTemplateOutlet,
3529
+ NgStyle,
3530
+ NgSwitch,
3531
+ NgSwitchCase,
3532
+ NgSwitchDefault,
3533
+ NgPlural,
3534
+ NgPluralCase,
3535
+ ];
3536
+
3537
+ function invalidPipeArgumentError(type, value) {
3538
+ return new _RuntimeError(2100 /* RuntimeErrorCode.INVALID_PIPE_ARGUMENT */, ngDevMode && `InvalidPipeArgument: '${value}' for pipe '${_stringify(type)}'`);
3539
+ }
3540
+
3541
+ class SubscribableStrategy {
3542
+ createSubscription(async, updateLatestValue, onError) {
3543
+ // Subscription can be side-effectful, and we don't want any signal reads which happen in the
3544
+ // side effect of the subscription to be tracked by a component's template when that
3545
+ // subscription is triggered via the async pipe. So we wrap the subscription in `untracked` to
3546
+ // decouple from the current reactive context.
3547
+ //
3548
+ // `untracked` also prevents signal _writes_ which happen in the subscription side effect from
3549
+ // being treated as signal writes during the template evaluation (which throws errors).
3550
+ return untracked(() => async.subscribe({
3551
+ next: updateLatestValue,
3552
+ error: onError,
3553
+ }));
3554
+ }
3555
+ dispose(subscription) {
3556
+ // See the comment in `createSubscription` above on the use of `untracked`.
3557
+ untracked(() => subscription.unsubscribe());
3558
+ }
3559
+ }
3560
+ class PromiseStrategy {
3561
+ createSubscription(async, updateLatestValue, onError) {
3562
+ return async.then(updateLatestValue, onError);
3563
+ }
3564
+ dispose(subscription) { }
3565
+ }
3566
+ const _promiseStrategy = new PromiseStrategy();
3567
+ const _subscribableStrategy = new SubscribableStrategy();
3568
+ /**
3569
+ * @ngModule CommonModule
3570
+ * @description
3571
+ *
3572
+ * Unwraps a value from an asynchronous primitive.
3573
+ *
3574
+ * The `async` pipe subscribes to an `Observable` or `Promise` and returns the latest value it has
3575
+ * emitted. When a new value is emitted, the `async` pipe marks the component to be checked for
3576
+ * changes. When the component gets destroyed, the `async` pipe unsubscribes automatically to avoid
3577
+ * potential memory leaks. When the reference of the expression changes, the `async` pipe
3578
+ * automatically unsubscribes from the old `Observable` or `Promise` and subscribes to the new one.
3579
+ *
3580
+ * @usageNotes
3581
+ *
3582
+ * ### Examples
3583
+ *
3584
+ * This example binds a `Promise` to the view. Clicking the `Resolve` button resolves the
3585
+ * promise.
3586
+ *
3587
+ * {@example common/pipes/ts/async_pipe.ts region='AsyncPipePromise'}
3588
+ *
3589
+ * It's also possible to use `async` with Observables. The example below binds the `time` Observable
3590
+ * to the view. The Observable continuously updates the view with the current time.
3591
+ *
3592
+ * {@example common/pipes/ts/async_pipe.ts region='AsyncPipeObservable'}
3593
+ *
3594
+ * @publicApi
3595
+ */
3596
+ class AsyncPipe {
3597
+ _ref;
3598
+ _latestValue = null;
3599
+ markForCheckOnValueUpdate = true;
3600
+ _subscription = null;
3601
+ _obj = null;
3602
+ _strategy = null;
3603
+ applicationErrorHandler = inject(_INTERNAL_APPLICATION_ERROR_HANDLER);
3604
+ constructor(ref) {
3605
+ // Assign `ref` into `this._ref` manually instead of declaring `_ref` in the constructor
3606
+ // parameter list, as the type of `this._ref` includes `null` unlike the type of `ref`.
3607
+ this._ref = ref;
3608
+ }
3609
+ ngOnDestroy() {
3610
+ if (this._subscription) {
3611
+ this._dispose();
3612
+ }
3613
+ // Clear the `ChangeDetectorRef` and its association with the view data, to mitigate
3614
+ // potential memory leaks in Observables that could otherwise cause the view data to
3615
+ // be retained.
3616
+ // https://github.com/angular/angular/issues/17624
3617
+ this._ref = null;
3618
+ }
3619
+ transform(obj) {
3620
+ if (!this._obj) {
3621
+ if (obj) {
3622
+ try {
3623
+ // Only call `markForCheck` if the value is updated asynchronously.
3624
+ // Synchronous updates _during_ subscription should not wastefully mark for check -
3625
+ // this value is already going to be returned from the transform function.
3626
+ this.markForCheckOnValueUpdate = false;
3627
+ this._subscribe(obj);
3628
+ }
3629
+ finally {
3630
+ this.markForCheckOnValueUpdate = true;
3631
+ }
3632
+ }
3633
+ return this._latestValue;
3634
+ }
3635
+ if (obj !== this._obj) {
3636
+ this._dispose();
3637
+ return this.transform(obj);
3638
+ }
3639
+ return this._latestValue;
3640
+ }
3641
+ _subscribe(obj) {
3642
+ this._obj = obj;
3643
+ this._strategy = this._selectStrategy(obj);
3644
+ this._subscription = this._strategy.createSubscription(obj, (value) => this._updateLatestValue(obj, value), (e) => this.applicationErrorHandler(e));
3645
+ }
3646
+ _selectStrategy(obj) {
3647
+ if (_isPromise(obj)) {
3648
+ return _promiseStrategy;
3649
+ }
3650
+ if (_isSubscribable(obj)) {
3651
+ return _subscribableStrategy;
3652
+ }
3653
+ throw invalidPipeArgumentError(AsyncPipe, obj);
3654
+ }
3655
+ _dispose() {
3656
+ // Note: `dispose` is only called if a subscription has been initialized before, indicating
3657
+ // that `this._strategy` is also available.
3658
+ this._strategy.dispose(this._subscription);
3659
+ this._latestValue = null;
3660
+ this._subscription = null;
3661
+ this._obj = null;
3662
+ }
3663
+ _updateLatestValue(async, value) {
3664
+ if (async === this._obj) {
3665
+ this._latestValue = value;
3666
+ if (this.markForCheckOnValueUpdate) {
3667
+ this._ref?.markForCheck();
3668
+ }
3669
+ }
3670
+ }
3671
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.0-next.5", ngImport: i0, type: AsyncPipe, deps: [{ token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Pipe });
3672
+ static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "20.0.0-next.5", ngImport: i0, type: AsyncPipe, isStandalone: true, name: "async", pure: false });
3673
+ }
3674
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.0-next.5", ngImport: i0, type: AsyncPipe, decorators: [{
3675
+ type: Pipe,
3676
+ args: [{
3677
+ name: 'async',
3678
+ pure: false,
3679
+ }]
3680
+ }], ctorParameters: () => [{ type: i0.ChangeDetectorRef }] });
3681
+
3682
+ /**
3683
+ * Transforms text to all lower case.
3684
+ *
3685
+ * @see {@link UpperCasePipe}
3686
+ * @see {@link TitleCasePipe}
3687
+ * @usageNotes
3688
+ *
3689
+ * The following example defines a view that allows the user to enter
3690
+ * text, and then uses the pipe to convert the input text to all lower case.
3691
+ *
3692
+ * {@example common/pipes/ts/lowerupper_pipe.ts region='LowerUpperPipe'}
3693
+ *
3694
+ * @ngModule CommonModule
3695
+ * @publicApi
3696
+ */
3697
+ class LowerCasePipe {
3698
+ transform(value) {
3699
+ if (value == null)
3700
+ return null;
3701
+ if (typeof value !== 'string') {
3702
+ throw invalidPipeArgumentError(LowerCasePipe, value);
3703
+ }
3704
+ return value.toLowerCase();
3705
+ }
3706
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.0-next.5", ngImport: i0, type: LowerCasePipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
3707
+ static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "20.0.0-next.5", ngImport: i0, type: LowerCasePipe, isStandalone: true, name: "lowercase" });
3708
+ }
3709
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.0-next.5", ngImport: i0, type: LowerCasePipe, decorators: [{
3710
+ type: Pipe,
3711
+ args: [{
3712
+ name: 'lowercase',
3713
+ }]
3714
+ }] });
3715
+ //
3716
+ // Regex below matches any Unicode word and number compatible with ES5. In ES2018 the same result
3717
+ // can be achieved by using /[0-9\p{L}]\S*/gu and also known as Unicode Property Escapes
3718
+ // (https://2ality.com/2017/07/regexp-unicode-property-escapes.html). Since there is no
3719
+ // transpilation of this functionality down to ES5 without external tool, the only solution is
3720
+ // to use already transpiled form. Example can be found here -
3721
+ // https://mothereff.in/regexpu#input=var+regex+%3D+%2F%5B0-9%5Cp%7BL%7D%5D%5CS*%2Fgu%3B%0A%0A&unicodePropertyEscape=1
3722
+ //
3723
+ 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;
3724
+ /**
3725
+ * Transforms text to title case.
3726
+ * Capitalizes the first letter of each word and transforms the
3727
+ * rest of the word to lower case.
3728
+ * Words are delimited by any whitespace character, such as a space, tab, or line-feed character.
3729
+ *
3730
+ * @see {@link LowerCasePipe}
3731
+ * @see {@link UpperCasePipe}
3732
+ *
3733
+ * @usageNotes
3734
+ * The following example shows the result of transforming various strings into title case.
3735
+ *
3736
+ * {@example common/pipes/ts/titlecase_pipe.ts region='TitleCasePipe'}
3737
+ *
3738
+ * @ngModule CommonModule
3739
+ * @publicApi
3740
+ */
3741
+ class TitleCasePipe {
3742
+ transform(value) {
3743
+ if (value == null)
3744
+ return null;
3745
+ if (typeof value !== 'string') {
3746
+ throw invalidPipeArgumentError(TitleCasePipe, value);
3747
+ }
3748
+ return value.replace(unicodeWordMatch, (txt) => txt[0].toUpperCase() + txt.slice(1).toLowerCase());
3749
+ }
3750
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.0-next.5", ngImport: i0, type: TitleCasePipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
3751
+ static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "20.0.0-next.5", ngImport: i0, type: TitleCasePipe, isStandalone: true, name: "titlecase" });
3752
+ }
3753
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.0-next.5", ngImport: i0, type: TitleCasePipe, decorators: [{
3754
+ type: Pipe,
3755
+ args: [{
3756
+ name: 'titlecase',
3757
+ }]
3758
+ }] });
3759
+ /**
3760
+ * Transforms text to all upper case.
3761
+ * @see {@link LowerCasePipe}
3762
+ * @see {@link TitleCasePipe}
3763
+ *
3764
+ * @ngModule CommonModule
3765
+ * @publicApi
3766
+ */
3767
+ class UpperCasePipe {
3768
+ transform(value) {
3769
+ if (value == null)
3770
+ return null;
3771
+ if (typeof value !== 'string') {
3772
+ throw invalidPipeArgumentError(UpperCasePipe, value);
3773
+ }
3774
+ return value.toUpperCase();
3775
+ }
3776
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.0-next.5", ngImport: i0, type: UpperCasePipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
3777
+ static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "20.0.0-next.5", ngImport: i0, type: UpperCasePipe, isStandalone: true, name: "uppercase" });
3778
+ }
3779
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.0-next.5", ngImport: i0, type: UpperCasePipe, decorators: [{
3780
+ type: Pipe,
3781
+ args: [{
3782
+ name: 'uppercase',
3783
+ }]
3784
+ }] });
3785
+
3786
+ /**
3787
+ * The default date format of Angular date pipe, which corresponds to the following format:
3788
+ * `'MMM d,y'` (e.g. `Jun 15, 2015`)
3789
+ */
3790
+ const DEFAULT_DATE_FORMAT = 'mediumDate';
3791
+
3792
+ /**
3793
+ * Optionally-provided default timezone to use for all instances of `DatePipe` (such as `'+0430'`).
3794
+ * If the value isn't provided, the `DatePipe` will use the end-user's local system timezone.
3795
+ *
3796
+ * @deprecated use DATE_PIPE_DEFAULT_OPTIONS token to configure DatePipe
3797
+ */
3798
+ const DATE_PIPE_DEFAULT_TIMEZONE = new InjectionToken(ngDevMode ? 'DATE_PIPE_DEFAULT_TIMEZONE' : '');
3799
+ /**
3800
+ * DI token that allows to provide default configuration for the `DatePipe` instances in an
3801
+ * application. The value is an object which can include the following fields:
3802
+ * - `dateFormat`: configures the default date format. If not provided, the `DatePipe`
3803
+ * will use the 'mediumDate' as a value.
3804
+ * - `timezone`: configures the default timezone. If not provided, the `DatePipe` will
3805
+ * use the end-user's local system timezone.
3806
+ *
3807
+ * @see {@link DatePipeConfig}
3808
+ *
3809
+ * @usageNotes
3810
+ *
3811
+ * Various date pipe default values can be overwritten by providing this token with
3812
+ * the value that has this interface.
3813
+ *
3814
+ * For example:
3815
+ *
3816
+ * Override the default date format by providing a value using the token:
3817
+ * ```ts
3818
+ * providers: [
3819
+ * {provide: DATE_PIPE_DEFAULT_OPTIONS, useValue: {dateFormat: 'shortDate'}}
3820
+ * ]
3821
+ * ```
3822
+ *
3823
+ * Override the default timezone by providing a value using the token:
3824
+ * ```ts
3825
+ * providers: [
3826
+ * {provide: DATE_PIPE_DEFAULT_OPTIONS, useValue: {timezone: '-1200'}}
3827
+ * ]
3828
+ * ```
3829
+ */
3830
+ const DATE_PIPE_DEFAULT_OPTIONS = new InjectionToken(ngDevMode ? 'DATE_PIPE_DEFAULT_OPTIONS' : '');
3831
+ /**
3832
+ * @ngModule CommonModule
3833
+ * @description
3834
+ *
3835
+ * Formats a date value according to locale rules.
3836
+ *
3837
+ * `DatePipe` is executed only when it detects a pure change to the input value.
3838
+ * A pure change is either a change to a primitive input value
3839
+ * (such as `String`, `Number`, `Boolean`, or `Symbol`),
3840
+ * or a changed object reference (such as `Date`, `Array`, `Function`, or `Object`).
3841
+ *
3842
+ * Note that mutating a `Date` object does not cause the pipe to be rendered again.
3843
+ * To ensure that the pipe is executed, you must create a new `Date` object.
3844
+ *
3845
+ * Only the `en-US` locale data comes with Angular. To localize dates
3846
+ * in another language, you must import the corresponding locale data.
3847
+ * See the [I18n guide](guide/i18n/format-data-locale) for more information.
3848
+ *
3849
+ * The time zone of the formatted value can be specified either by passing it in as the second
3850
+ * parameter of the pipe, or by setting the default through the `DATE_PIPE_DEFAULT_OPTIONS`
3851
+ * injection token. The value that is passed in as the second parameter takes precedence over
3852
+ * the one defined using the injection token.
3853
+ *
3854
+ * @see {@link formatDate}
3855
+ *
3856
+ *
3857
+ * @usageNotes
3858
+ *
3859
+ * The result of this pipe is not reevaluated when the input is mutated. To avoid the need to
3860
+ * reformat the date on every change-detection cycle, treat the date as an immutable object
3861
+ * and change the reference when the pipe needs to run again.
3862
+ *
3863
+ * ### Pre-defined format options
3864
+ *
3865
+ * | Option | Equivalent to | Examples (given in `en-US` locale) |
3866
+ * |---------------|-------------------------------------|-------------------------------------------------|
3867
+ * | `'short'` | `'M/d/yy, h:mm a'` | `6/15/15, 9:03 AM` |
3868
+ * | `'medium'` | `'MMM d, y, h:mm:ss a'` | `Jun 15, 2015, 9:03:01 AM` |
3869
+ * | `'long'` | `'MMMM d, y, h:mm:ss a z'` | `June 15, 2015 at 9:03:01 AM GMT+1` |
3870
+ * | `'full'` | `'EEEE, MMMM d, y, h:mm:ss a zzzz'` | `Monday, June 15, 2015 at 9:03:01 AM GMT+01:00` |
3871
+ * | `'shortDate'` | `'M/d/yy'` | `6/15/15` |
3872
+ * | `'mediumDate'`| `'MMM d, y'` | `Jun 15, 2015` |
3873
+ * | `'longDate'` | `'MMMM d, y'` | `June 15, 2015` |
3874
+ * | `'fullDate'` | `'EEEE, MMMM d, y'` | `Monday, June 15, 2015` |
3875
+ * | `'shortTime'` | `'h:mm a'` | `9:03 AM` |
3876
+ * | `'mediumTime'`| `'h:mm:ss a'` | `9:03:01 AM` |
3877
+ * | `'longTime'` | `'h:mm:ss a z'` | `9:03:01 AM GMT+1` |
3878
+ * | `'fullTime'` | `'h:mm:ss a zzzz'` | `9:03:01 AM GMT+01:00` |
3879
+ *
3880
+ * ### Custom format options
3881
+ *
3882
+ * You can construct a format string using symbols to specify the components
3883
+ * of a date-time value, as described in the following table.
3884
+ * Format details depend on the locale.
3885
+ * Fields marked with (*) are only available in the extra data set for the given locale.
3886
+ *
3887
+ * | Field type | Format | Description | Example Value |
3888
+ * |-------------------------|-------------|---------------------------------------------------------------|------------------------------------------------------------|
3889
+ * | Era | G, GG & GGG | Abbreviated | AD |
3890
+ * | | GGGG | Wide | Anno Domini |
3891
+ * | | GGGGG | Narrow | A |
3892
+ * | Year | y | Numeric: minimum digits | 2, 20, 201, 2017, 20173 |
3893
+ * | | yy | Numeric: 2 digits + zero padded | 02, 20, 01, 17, 73 |
3894
+ * | | yyy | Numeric: 3 digits + zero padded | 002, 020, 201, 2017, 20173 |
3895
+ * | | yyyy | Numeric: 4 digits or more + zero padded | 0002, 0020, 0201, 2017, 20173 |
3896
+ * | ISO Week-numbering year | Y | Numeric: minimum digits | 2, 20, 201, 2017, 20173 |
3897
+ * | | YY | Numeric: 2 digits + zero padded | 02, 20, 01, 17, 73 |
3898
+ * | | YYY | Numeric: 3 digits + zero padded | 002, 020, 201, 2017, 20173 |
3899
+ * | | YYYY | Numeric: 4 digits or more + zero padded | 0002, 0020, 0201, 2017, 20173 |
3900
+ * | Month | M | Numeric: 1 digit | 9, 12 |
3901
+ * | | MM | Numeric: 2 digits + zero padded | 09, 12 |
3902
+ * | | MMM | Abbreviated | Sep |
3903
+ * | | MMMM | Wide | September |
3904
+ * | | MMMMM | Narrow | S |
3905
+ * | Month standalone | L | Numeric: 1 digit | 9, 12 |
3906
+ * | | LL | Numeric: 2 digits + zero padded | 09, 12 |
3907
+ * | | LLL | Abbreviated | Sep |
3908
+ * | | LLLL | Wide | September |
3909
+ * | | LLLLL | Narrow | S |
3910
+ * | ISO Week of year | w | Numeric: minimum digits | 1... 53 |
3911
+ * | | ww | Numeric: 2 digits + zero padded | 01... 53 |
3912
+ * | Week of month | W | Numeric: 1 digit | 1... 5 |
3913
+ * | Day of month | d | Numeric: minimum digits | 1 |
3914
+ * | | dd | Numeric: 2 digits + zero padded | 01 |
3915
+ * | Week day | E, EE & EEE | Abbreviated | Tue |
3916
+ * | | EEEE | Wide | Tuesday |
3917
+ * | | EEEEE | Narrow | T |
3918
+ * | | EEEEEE | Short | Tu |
3919
+ * | Week day standalone | c, cc | Numeric: 1 digit | 2 |
3920
+ * | | ccc | Abbreviated | Tue |
3921
+ * | | cccc | Wide | Tuesday |
3922
+ * | | ccccc | Narrow | T |
3923
+ * | | cccccc | Short | Tu |
3924
+ * | Period | a, aa & aaa | Abbreviated | am/pm or AM/PM |
3925
+ * | | aaaa | Wide (fallback to `a` when missing) | ante meridiem/post meridiem |
3926
+ * | | aaaaa | Narrow | a/p |
3927
+ * | Period* | B, BB & BBB | Abbreviated | mid. |
3928
+ * | | BBBB | Wide | am, pm, midnight, noon, morning, afternoon, evening, night |
3929
+ * | | BBBBB | Narrow | md |
3930
+ * | Period standalone* | b, bb & bbb | Abbreviated | mid. |
3931
+ * | | bbbb | Wide | am, pm, midnight, noon, morning, afternoon, evening, night |
3932
+ * | | bbbbb | Narrow | md |
3933
+ * | Hour 1-12 | h | Numeric: minimum digits | 1, 12 |
3934
+ * | | hh | Numeric: 2 digits + zero padded | 01, 12 |
3935
+ * | Hour 0-23 | H | Numeric: minimum digits | 0, 23 |
3936
+ * | | HH | Numeric: 2 digits + zero padded | 00, 23 |
3937
+ * | Minute | m | Numeric: minimum digits | 8, 59 |
3938
+ * | | mm | Numeric: 2 digits + zero padded | 08, 59 |
3939
+ * | Second | s | Numeric: minimum digits | 0... 59 |
3940
+ * | | ss | Numeric: 2 digits + zero padded | 00... 59 |
3941
+ * | Fractional seconds | S | Numeric: 1 digit | 0... 9 |
3942
+ * | | SS | Numeric: 2 digits + zero padded | 00... 99 |
3943
+ * | | SSS | Numeric: 3 digits + zero padded (= milliseconds) | 000... 999 |
3944
+ * | Zone | z, zz & zzz | Short specific non location format (fallback to O) | GMT-8 |
3945
+ * | | zzzz | Long specific non location format (fallback to OOOO) | GMT-08:00 |
3946
+ * | | Z, ZZ & ZZZ | ISO8601 basic format | -0800 |
3947
+ * | | ZZZZ | Long localized GMT format | GMT-8:00 |
3948
+ * | | ZZZZZ | ISO8601 extended format + Z indicator for offset 0 (= XXXXX) | -08:00 |
3949
+ * | | O, OO & OOO | Short localized GMT format | GMT-8 |
3950
+ * | | OOOO | Long localized GMT format | GMT-08:00 |
3951
+ *
3952
+ *
3953
+ * ### Format examples
3954
+ *
3955
+ * These examples transform a date into various formats,
3956
+ * assuming that `dateObj` is a JavaScript `Date` object for
3957
+ * year: 2015, month: 6, day: 15, hour: 21, minute: 43, second: 11,
3958
+ * given in the local time for the `en-US` locale.
3959
+ *
3960
+ * ```
3961
+ * {{ dateObj | date }} // output is 'Jun 15, 2015'
3962
+ * {{ dateObj | date:'medium' }} // output is 'Jun 15, 2015, 9:43:11 PM'
3963
+ * {{ dateObj | date:'shortTime' }} // output is '9:43 PM'
3964
+ * {{ dateObj | date:'mm:ss' }} // output is '43:11'
3965
+ * {{ dateObj | date:"MMM dd, yyyy 'at' hh:mm a" }} // output is 'Jun 15, 2015 at 09:43 PM'
3966
+ * ```
3967
+ *
3968
+ * ### Usage example
3969
+ *
3970
+ * The following component uses a date pipe to display the current date in different formats.
3971
+ *
3972
+ * ```angular-ts
3973
+ * @Component({
3974
+ * selector: 'date-pipe',
3975
+ * template: `<div>
3976
+ * <p>Today is {{today | date}}</p>
3977
+ * <p>Or if you prefer, {{today | date:'fullDate'}}</p>
3978
+ * <p>The time is {{today | date:'h:mm a z'}}</p>
3979
+ * </div>`
3980
+ * })
3981
+ * // Get the current date and time as a date-time value.
3982
+ * export class DatePipeComponent {
3983
+ * today: number = Date.now();
3984
+ * }
3985
+ * ```
3986
+ *
3987
+ * @publicApi
3988
+ */
3989
+ class DatePipe {
3990
+ locale;
3991
+ defaultTimezone;
3992
+ defaultOptions;
3993
+ constructor(locale, defaultTimezone, defaultOptions) {
3994
+ this.locale = locale;
3995
+ this.defaultTimezone = defaultTimezone;
3996
+ this.defaultOptions = defaultOptions;
3997
+ }
3998
+ transform(value, format, timezone, locale) {
3999
+ if (value == null || value === '' || value !== value)
4000
+ return null;
4001
+ try {
4002
+ const _format = format ?? this.defaultOptions?.dateFormat ?? DEFAULT_DATE_FORMAT;
4003
+ const _timezone = timezone ?? this.defaultOptions?.timezone ?? this.defaultTimezone ?? undefined;
4004
+ return formatDate(value, _format, locale || this.locale, _timezone);
4005
+ }
4006
+ catch (error) {
4007
+ throw invalidPipeArgumentError(DatePipe, error.message);
4008
+ }
4009
+ }
4010
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.0-next.5", 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 });
4011
+ static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "20.0.0-next.5", ngImport: i0, type: DatePipe, isStandalone: true, name: "date" });
4012
+ }
4013
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.0-next.5", ngImport: i0, type: DatePipe, decorators: [{
4014
+ type: Pipe,
4015
+ args: [{
4016
+ name: 'date',
4017
+ }]
4018
+ }], ctorParameters: () => [{ type: undefined, decorators: [{
4019
+ type: Inject,
4020
+ args: [LOCALE_ID]
4021
+ }] }, { type: undefined, decorators: [{
4022
+ type: Inject,
4023
+ args: [DATE_PIPE_DEFAULT_TIMEZONE]
4024
+ }, {
4025
+ type: Optional
4026
+ }] }, { type: undefined, decorators: [{
4027
+ type: Inject,
4028
+ args: [DATE_PIPE_DEFAULT_OPTIONS]
4029
+ }, {
4030
+ type: Optional
4031
+ }] }] });
4032
+
4033
+ const _INTERPOLATION_REGEXP = /#/g;
4034
+ /**
4035
+ * @ngModule CommonModule
4036
+ * @description
4037
+ *
4038
+ * Maps a value to a string that pluralizes the value according to locale rules.
4039
+ *
4040
+ * @usageNotes
4041
+ *
4042
+ * ### Example
4043
+ *
4044
+ * {@example common/pipes/ts/i18n_pipe.ts region='I18nPluralPipeComponent'}
4045
+ *
4046
+ * @publicApi
4047
+ */
4048
+ class I18nPluralPipe {
4049
+ _localization;
4050
+ constructor(_localization) {
4051
+ this._localization = _localization;
4052
+ }
4053
+ /**
4054
+ * @param value the number to be formatted
4055
+ * @param pluralMap an object that mimics the ICU format, see
4056
+ * https://unicode-org.github.io/icu/userguide/format_parse/messages/.
4057
+ * @param locale a `string` defining the locale to use (uses the current {@link LOCALE_ID} by
4058
+ * default).
4059
+ */
4060
+ transform(value, pluralMap, locale) {
4061
+ if (value == null)
4062
+ return '';
4063
+ if (typeof pluralMap !== 'object' || pluralMap === null) {
4064
+ throw invalidPipeArgumentError(I18nPluralPipe, pluralMap);
4065
+ }
4066
+ const key = getPluralCategory(value, Object.keys(pluralMap), this._localization, locale);
4067
+ return pluralMap[key].replace(_INTERPOLATION_REGEXP, value.toString());
4068
+ }
4069
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.0-next.5", ngImport: i0, type: I18nPluralPipe, deps: [{ token: NgLocalization }], target: i0.ɵɵFactoryTarget.Pipe });
4070
+ static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "20.0.0-next.5", ngImport: i0, type: I18nPluralPipe, isStandalone: true, name: "i18nPlural" });
4071
+ }
4072
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.0-next.5", ngImport: i0, type: I18nPluralPipe, decorators: [{
4073
+ type: Pipe,
4074
+ args: [{
4075
+ name: 'i18nPlural',
4076
+ }]
4077
+ }], ctorParameters: () => [{ type: NgLocalization }] });
4078
+
4079
+ /**
4080
+ * @ngModule CommonModule
4081
+ * @description
4082
+ *
4083
+ * Generic selector that displays the string that matches the current value.
4084
+ *
4085
+ * If none of the keys of the `mapping` match the `value`, then the content
4086
+ * of the `other` key is returned when present, otherwise an empty string is returned.
4087
+ *
4088
+ * @usageNotes
4089
+ *
4090
+ * ### Example
4091
+ *
4092
+ * {@example common/pipes/ts/i18n_pipe.ts region='I18nSelectPipeComponent'}
4093
+ *
4094
+ * @publicApi
4095
+ */
4096
+ class I18nSelectPipe {
4097
+ /**
4098
+ * @param value a string to be internationalized.
4099
+ * @param mapping an object that indicates the text that should be displayed
4100
+ * for different values of the provided `value`.
4101
+ */
4102
+ transform(value, mapping) {
4103
+ if (value == null)
4104
+ return '';
4105
+ if (typeof mapping !== 'object' || typeof value !== 'string') {
4106
+ throw invalidPipeArgumentError(I18nSelectPipe, mapping);
4107
+ }
4108
+ if (mapping.hasOwnProperty(value)) {
4109
+ return mapping[value];
4110
+ }
4111
+ if (mapping.hasOwnProperty('other')) {
4112
+ return mapping['other'];
4113
+ }
4114
+ return '';
4115
+ }
4116
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.0-next.5", ngImport: i0, type: I18nSelectPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
4117
+ static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "20.0.0-next.5", ngImport: i0, type: I18nSelectPipe, isStandalone: true, name: "i18nSelect" });
4118
+ }
4119
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.0-next.5", ngImport: i0, type: I18nSelectPipe, decorators: [{
4120
+ type: Pipe,
4121
+ args: [{
4122
+ name: 'i18nSelect',
4123
+ }]
4124
+ }] });
4125
+
4126
+ /**
4127
+ * @ngModule CommonModule
4128
+ * @description
4129
+ *
4130
+ * Converts a value into its JSON-format representation. Useful for debugging.
4131
+ *
4132
+ * @usageNotes
4133
+ *
4134
+ * The following component uses a JSON pipe to convert an object
4135
+ * to JSON format, and displays the string in both formats for comparison.
4136
+ *
4137
+ * {@example common/pipes/ts/json_pipe.ts region='JsonPipe'}
4138
+ *
4139
+ * @publicApi
4140
+ */
4141
+ class JsonPipe {
4142
+ /**
4143
+ * @param value A value of any type to convert into a JSON-format string.
4144
+ */
4145
+ transform(value) {
4146
+ return JSON.stringify(value, null, 2);
4147
+ }
4148
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.0-next.5", ngImport: i0, type: JsonPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
4149
+ static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "20.0.0-next.5", ngImport: i0, type: JsonPipe, isStandalone: true, name: "json", pure: false });
4150
+ }
4151
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.0-next.5", ngImport: i0, type: JsonPipe, decorators: [{
4152
+ type: Pipe,
4153
+ args: [{
4154
+ name: 'json',
4155
+ pure: false,
4156
+ }]
4157
+ }] });
4158
+
4159
+ function makeKeyValuePair(key, value) {
4160
+ return { key: key, value: value };
4161
+ }
4162
+ /**
4163
+ * @ngModule CommonModule
4164
+ * @description
4165
+ *
4166
+ * Transforms Object or Map into an array of key value pairs.
4167
+ *
4168
+ * The output array will be ordered by keys.
4169
+ * By default the comparator will be by Unicode point value.
4170
+ * You can optionally pass a compareFn if your keys are complex types.
4171
+ * Passing `null` as the compareFn will use natural ordering of the input.
4172
+ *
4173
+ * @usageNotes
4174
+ * ### Examples
4175
+ *
4176
+ * This examples show how an Object or a Map can be iterated by ngFor with the use of this
4177
+ * keyvalue pipe.
4178
+ *
4179
+ * {@example common/pipes/ts/keyvalue_pipe.ts region='KeyValuePipe'}
4180
+ *
4181
+ * @publicApi
4182
+ */
4183
+ class KeyValuePipe {
4184
+ differs;
4185
+ constructor(differs) {
4186
+ this.differs = differs;
4187
+ }
4188
+ differ;
4189
+ keyValues = [];
4190
+ compareFn = defaultComparator;
4191
+ transform(input, compareFn = defaultComparator) {
4192
+ if (!input || (!(input instanceof Map) && typeof input !== 'object')) {
4193
+ return null;
4194
+ }
4195
+ // make a differ for whatever type we've been passed in
4196
+ this.differ ??= this.differs.find(input).create();
4197
+ const differChanges = this.differ.diff(input);
4198
+ const compareFnChanged = compareFn !== this.compareFn;
4199
+ if (differChanges) {
4200
+ this.keyValues = [];
4201
+ differChanges.forEachItem((r) => {
4202
+ this.keyValues.push(makeKeyValuePair(r.key, r.currentValue));
4203
+ });
4204
+ }
4205
+ if (differChanges || compareFnChanged) {
4206
+ if (compareFn) {
4207
+ this.keyValues.sort(compareFn);
4208
+ }
4209
+ this.compareFn = compareFn;
4210
+ }
4211
+ return this.keyValues;
4212
+ }
4213
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.0-next.5", ngImport: i0, type: KeyValuePipe, deps: [{ token: i0.KeyValueDiffers }], target: i0.ɵɵFactoryTarget.Pipe });
4214
+ static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "20.0.0-next.5", ngImport: i0, type: KeyValuePipe, isStandalone: true, name: "keyvalue", pure: false });
4215
+ }
4216
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.0-next.5", ngImport: i0, type: KeyValuePipe, decorators: [{
4217
+ type: Pipe,
4218
+ args: [{
4219
+ name: 'keyvalue',
4220
+ pure: false,
4221
+ }]
4222
+ }], ctorParameters: () => [{ type: i0.KeyValueDiffers }] });
4223
+ function defaultComparator(keyValueA, keyValueB) {
4224
+ const a = keyValueA.key;
4225
+ const b = keyValueB.key;
4226
+ // If both keys are the same, return 0 (no sorting needed).
4227
+ if (a === b)
4228
+ return 0;
4229
+ // If one of the keys is `null` or `undefined`, place it at the end of the sort.
4230
+ if (a == null)
4231
+ return 1; // `a` comes after `b`.
4232
+ if (b == null)
4233
+ return -1; // `b` comes after `a`.
4234
+ // If both keys are strings, compare them lexicographically.
4235
+ if (typeof a == 'string' && typeof b == 'string') {
4236
+ return a < b ? -1 : 1;
4237
+ }
4238
+ // If both keys are numbers, sort them numerically.
4239
+ if (typeof a == 'number' && typeof b == 'number') {
4240
+ return a - b;
4241
+ }
4242
+ // If both keys are booleans, sort `false` before `true`.
4243
+ if (typeof a == 'boolean' && typeof b == 'boolean') {
4244
+ return a < b ? -1 : 1;
4245
+ }
4246
+ // Fallback case: if keys are of different types, compare their string representations.
4247
+ const aString = String(a);
4248
+ const bString = String(b);
4249
+ // Compare the string representations lexicographically.
4250
+ return aString == bString ? 0 : aString < bString ? -1 : 1;
4251
+ }
4252
+
4253
+ /**
4254
+ * @ngModule CommonModule
4255
+ * @description
4256
+ *
4257
+ * Formats a value according to digit options and locale rules.
4258
+ * Locale determines group sizing and separator,
4259
+ * decimal point character, and other locale-specific configurations.
4260
+ *
4261
+ * @see {@link formatNumber}
4262
+ *
4263
+ * @usageNotes
4264
+ *
4265
+ * ### digitsInfo
4266
+ *
4267
+ * The value's decimal representation is specified by the `digitsInfo`
4268
+ * parameter, written in the following format:<br>
4269
+ *
4270
+ * ```
4271
+ * {minIntegerDigits}.{minFractionDigits}-{maxFractionDigits}
4272
+ * ```
4273
+ *
4274
+ * - `minIntegerDigits`:
4275
+ * The minimum number of integer digits before the decimal point.
4276
+ * Default is 1.
4277
+ *
4278
+ * - `minFractionDigits`:
4279
+ * The minimum number of digits after the decimal point.
4280
+ * Default is 0.
4281
+ *
4282
+ * - `maxFractionDigits`:
4283
+ * The maximum number of digits after the decimal point.
4284
+ * Default is 3.
4285
+ *
4286
+ * If the formatted value is truncated it will be rounded using the "to-nearest" method:
4287
+ *
4288
+ * ```
4289
+ * {{3.6 | number: '1.0-0'}}
4290
+ * <!--will output '4'-->
4291
+ *
4292
+ * {{-3.6 | number:'1.0-0'}}
4293
+ * <!--will output '-4'-->
4294
+ * ```
4295
+ *
4296
+ * ### locale
4297
+ *
4298
+ * `locale` will format a value according to locale rules.
4299
+ * Locale determines group sizing and separator,
4300
+ * decimal point character, and other locale-specific configurations.
4301
+ *
4302
+ * When not supplied, uses the value of `LOCALE_ID`, which is `en-US` by default.
4303
+ *
4304
+ * See [Setting your app locale](guide/i18n/locale-id).
4305
+ *
4306
+ * ### Example
4307
+ *
4308
+ * The following code shows how the pipe transforms values
4309
+ * according to various format specifications,
4310
+ * where the caller's default locale is `en-US`.
4311
+ *
4312
+ * {@example common/pipes/ts/number_pipe.ts region='NumberPipe'}
4313
+ *
4314
+ * @publicApi
4315
+ */
4316
+ class DecimalPipe {
4317
+ _locale;
4318
+ constructor(_locale) {
4319
+ this._locale = _locale;
4320
+ }
4321
+ transform(value, digitsInfo, locale) {
4322
+ if (!isValue(value))
4323
+ return null;
4324
+ locale ||= this._locale;
4325
+ try {
4326
+ const num = strToNumber(value);
4327
+ return formatNumber(num, locale, digitsInfo);
4328
+ }
4329
+ catch (error) {
4330
+ throw invalidPipeArgumentError(DecimalPipe, error.message);
4331
+ }
4332
+ }
4333
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.0-next.5", ngImport: i0, type: DecimalPipe, deps: [{ token: LOCALE_ID }], target: i0.ɵɵFactoryTarget.Pipe });
4334
+ static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "20.0.0-next.5", ngImport: i0, type: DecimalPipe, isStandalone: true, name: "number" });
4335
+ }
4336
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.0-next.5", ngImport: i0, type: DecimalPipe, decorators: [{
4337
+ type: Pipe,
4338
+ args: [{
4339
+ name: 'number',
4340
+ }]
4341
+ }], ctorParameters: () => [{ type: undefined, decorators: [{
4342
+ type: Inject,
4343
+ args: [LOCALE_ID]
4344
+ }] }] });
4345
+ /**
4346
+ * @ngModule CommonModule
4347
+ * @description
4348
+ *
4349
+ * Transforms a number to a percentage
4350
+ * string, formatted according to locale rules that determine group sizing and
4351
+ * separator, decimal-point character, and other locale-specific
4352
+ * configurations.
4353
+ *
4354
+ * @see {@link formatPercent}
4355
+ *
4356
+ * @usageNotes
4357
+ * The following code shows how the pipe transforms numbers
4358
+ * into text strings, according to various format specifications,
4359
+ * where the caller's default locale is `en-US`.
4360
+ *
4361
+ * {@example common/pipes/ts/percent_pipe.ts region='PercentPipe'}
4362
+ *
4363
+ * @publicApi
4364
+ */
4365
+ class PercentPipe {
4366
+ _locale;
4367
+ constructor(_locale) {
4368
+ this._locale = _locale;
4369
+ }
4370
+ /**
4371
+ *
4372
+ * @param value The number to be formatted as a percentage.
4373
+ * @param digitsInfo Decimal representation options, specified by a string
4374
+ * in the following format:<br>
4375
+ * <code>{minIntegerDigits}.{minFractionDigits}-{maxFractionDigits}</code>.
4376
+ * - `minIntegerDigits`: The minimum number of integer digits before the decimal point.
4377
+ * Default is `1`.
4378
+ * - `minFractionDigits`: The minimum number of digits after the decimal point.
4379
+ * Default is `0`.
4380
+ * - `maxFractionDigits`: The maximum number of digits after the decimal point.
4381
+ * Default is `0`.
4382
+ * @param locale A locale code for the locale format rules to use.
4383
+ * When not supplied, uses the value of `LOCALE_ID`, which is `en-US` by default.
4384
+ * See [Setting your app locale](guide/i18n/locale-id).
4385
+ */
4386
+ transform(value, digitsInfo, locale) {
4387
+ if (!isValue(value))
4388
+ return null;
4389
+ locale ||= this._locale;
4390
+ try {
4391
+ const num = strToNumber(value);
4392
+ return formatPercent(num, locale, digitsInfo);
4393
+ }
4394
+ catch (error) {
4395
+ throw invalidPipeArgumentError(PercentPipe, error.message);
4396
+ }
4397
+ }
4398
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.0-next.5", ngImport: i0, type: PercentPipe, deps: [{ token: LOCALE_ID }], target: i0.ɵɵFactoryTarget.Pipe });
4399
+ static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "20.0.0-next.5", ngImport: i0, type: PercentPipe, isStandalone: true, name: "percent" });
4400
+ }
4401
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.0-next.5", ngImport: i0, type: PercentPipe, decorators: [{
4402
+ type: Pipe,
4403
+ args: [{
4404
+ name: 'percent',
4405
+ }]
4406
+ }], ctorParameters: () => [{ type: undefined, decorators: [{
4407
+ type: Inject,
4408
+ args: [LOCALE_ID]
4409
+ }] }] });
4410
+ /**
4411
+ * @ngModule CommonModule
4412
+ * @description
4413
+ *
4414
+ * Transforms a number to a currency string, formatted according to locale rules
4415
+ * that determine group sizing and separator, decimal-point character,
4416
+ * and other locale-specific configurations.
4417
+ *
4418
+ *
4419
+ * @see {@link getCurrencySymbol}
4420
+ * @see {@link formatCurrency}
4421
+ *
4422
+ * @usageNotes
4423
+ * The following code shows how the pipe transforms numbers
4424
+ * into text strings, according to various format specifications,
4425
+ * where the caller's default locale is `en-US`.
4426
+ *
4427
+ * {@example common/pipes/ts/currency_pipe.ts region='CurrencyPipe'}
4428
+ *
4429
+ * @publicApi
4430
+ */
4431
+ class CurrencyPipe {
4432
+ _locale;
4433
+ _defaultCurrencyCode;
4434
+ constructor(_locale, _defaultCurrencyCode = 'USD') {
4435
+ this._locale = _locale;
4436
+ this._defaultCurrencyCode = _defaultCurrencyCode;
4437
+ }
4438
+ transform(value, currencyCode = this._defaultCurrencyCode, display = 'symbol', digitsInfo, locale) {
4439
+ if (!isValue(value))
4440
+ return null;
4441
+ locale ||= this._locale;
4442
+ if (typeof display === 'boolean') {
4443
+ if ((typeof ngDevMode === 'undefined' || ngDevMode) && console && console.warn) {
4444
+ 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".`);
4445
+ }
4446
+ display = display ? 'symbol' : 'code';
4447
+ }
4448
+ let currency = currencyCode || this._defaultCurrencyCode;
4449
+ if (display !== 'code') {
4450
+ if (display === 'symbol' || display === 'symbol-narrow') {
4451
+ currency = getCurrencySymbol(currency, display === 'symbol' ? 'wide' : 'narrow', locale);
4452
+ }
4453
+ else {
4454
+ currency = display;
4455
+ }
4456
+ }
4457
+ try {
4458
+ const num = strToNumber(value);
4459
+ return formatCurrency(num, locale, currency, currencyCode, digitsInfo);
4460
+ }
4461
+ catch (error) {
4462
+ throw invalidPipeArgumentError(CurrencyPipe, error.message);
4463
+ }
4464
+ }
4465
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.0-next.5", ngImport: i0, type: CurrencyPipe, deps: [{ token: LOCALE_ID }, { token: DEFAULT_CURRENCY_CODE }], target: i0.ɵɵFactoryTarget.Pipe });
4466
+ static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "20.0.0-next.5", ngImport: i0, type: CurrencyPipe, isStandalone: true, name: "currency" });
4467
+ }
4468
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.0-next.5", ngImport: i0, type: CurrencyPipe, decorators: [{
4469
+ type: Pipe,
4470
+ args: [{
4471
+ name: 'currency',
4472
+ }]
4473
+ }], ctorParameters: () => [{ type: undefined, decorators: [{
4474
+ type: Inject,
4475
+ args: [LOCALE_ID]
4476
+ }] }, { type: undefined, decorators: [{
4477
+ type: Inject,
4478
+ args: [DEFAULT_CURRENCY_CODE]
4479
+ }] }] });
4480
+ function isValue(value) {
4481
+ return !(value == null || value === '' || value !== value);
4482
+ }
4483
+ /**
4484
+ * Transforms a string into a number (if needed).
4485
+ */
4486
+ function strToNumber(value) {
4487
+ // Convert strings to numbers
4488
+ if (typeof value === 'string' && !isNaN(Number(value) - parseFloat(value))) {
4489
+ return Number(value);
4490
+ }
4491
+ if (typeof value !== 'number') {
4492
+ throw new Error(`${value} is not a number`);
4493
+ }
4494
+ return value;
4495
+ }
4496
+
4497
+ /**
4498
+ * @ngModule CommonModule
4499
+ * @description
4500
+ *
4501
+ * Creates a new `Array` or `String` containing a subset (slice) of the elements.
4502
+ *
4503
+ * @usageNotes
4504
+ *
4505
+ * All behavior is based on the expected behavior of the JavaScript API `Array.prototype.slice()`
4506
+ * and `String.prototype.slice()`.
4507
+ *
4508
+ * When operating on an `Array`, the returned `Array` is always a copy even when all
4509
+ * the elements are being returned.
4510
+ *
4511
+ * When operating on a blank value, the pipe returns the blank value.
4512
+ *
4513
+ * ### List Example
4514
+ *
4515
+ * This `ngFor` example:
4516
+ *
4517
+ * {@example common/pipes/ts/slice_pipe.ts region='SlicePipe_list'}
4518
+ *
4519
+ * produces the following:
4520
+ *
4521
+ * ```html
4522
+ * <li>b</li>
4523
+ * <li>c</li>
4524
+ * ```
4525
+ *
4526
+ * ### String Examples
4527
+ *
4528
+ * {@example common/pipes/ts/slice_pipe.ts region='SlicePipe_string'}
4529
+ *
4530
+ * @publicApi
4531
+ */
4532
+ class SlicePipe {
4533
+ transform(value, start, end) {
4534
+ if (value == null)
4535
+ return null;
4536
+ const supports = typeof value === 'string' || Array.isArray(value);
4537
+ if (!supports) {
4538
+ throw invalidPipeArgumentError(SlicePipe, value);
4539
+ }
4540
+ return value.slice(start, end);
4541
+ }
4542
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.0-next.5", ngImport: i0, type: SlicePipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
4543
+ static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "20.0.0-next.5", ngImport: i0, type: SlicePipe, isStandalone: true, name: "slice", pure: false });
4544
+ }
4545
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.0-next.5", ngImport: i0, type: SlicePipe, decorators: [{
4546
+ type: Pipe,
4547
+ args: [{
4548
+ name: 'slice',
4549
+ pure: false,
4550
+ }]
4551
+ }] });
4552
+
4553
+ /**
4554
+ * @module
4555
+ * @description
4556
+ * This module provides a set of common Pipes.
4557
+ */
4558
+ /**
4559
+ * A collection of Angular pipes that are likely to be used in each and every application.
4560
+ */
4561
+ const COMMON_PIPES = [
4562
+ AsyncPipe,
4563
+ UpperCasePipe,
4564
+ LowerCasePipe,
4565
+ JsonPipe,
4566
+ SlicePipe,
4567
+ DecimalPipe,
4568
+ PercentPipe,
4569
+ TitleCasePipe,
4570
+ CurrencyPipe,
4571
+ DatePipe,
4572
+ I18nPluralPipe,
4573
+ I18nSelectPipe,
4574
+ KeyValuePipe,
4575
+ ];
4576
+
4577
+ // Note: This does not contain the location providers,
4578
+ // as they need some platform specific implementations to work.
4579
+ /**
4580
+ * Exports all the basic Angular directives and pipes,
4581
+ * such as `NgIf`, `NgForOf`, `DecimalPipe`, and so on.
4582
+ * Re-exported by `BrowserModule`, which is included automatically in the root
4583
+ * `AppModule` when you create a new app with the CLI `new` command.
4584
+ *
4585
+ * @publicApi
4586
+ */
4587
+ class CommonModule {
4588
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.0-next.5", ngImport: i0, type: CommonModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
4589
+ static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.0.0-next.5", 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] });
4590
+ static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.0.0-next.5", ngImport: i0, type: CommonModule });
4591
+ }
4592
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.0-next.5", ngImport: i0, type: CommonModule, decorators: [{
4593
+ type: NgModule,
4594
+ args: [{
4595
+ imports: [COMMON_DIRECTIVES, COMMON_PIPES],
4596
+ exports: [COMMON_DIRECTIVES, COMMON_PIPES],
4597
+ }]
4598
+ }] });
4599
+
4600
+ export { I18nSelectPipe as $, getLocaleCurrencyName as A, getLocaleCurrencySymbol as B, getLocaleDirection as C, CommonModule as D, NgClass as E, FormStyle as F, NgForOf as G, NgForOfContext as H, NgIf as I, NgIfContext as J, NgPlural as K, NgPluralCase as L, NgStyle as M, NgLocaleLocalization as N, NgSwitch as O, Plural as P, NgSwitchCase as Q, NgSwitchDefault as R, NgTemplateOutlet as S, TranslationWidth as T, NgComponentOutlet as U, AsyncPipe as V, WeekDay as W, DatePipe as X, DATE_PIPE_DEFAULT_TIMEZONE as Y, DATE_PIPE_DEFAULT_OPTIONS as Z, I18nPluralPipe as _, formatCurrency as a, JsonPipe as a0, LowerCasePipe as a1, CurrencyPipe as a2, DecimalPipe as a3, PercentPipe as a4, SlicePipe as a5, UpperCasePipe as a6, TitleCasePipe as a7, KeyValuePipe as a8, HashLocationStrategy as a9, formatNumber as b, formatPercent as c, NgLocalization as d, NumberFormatStyle as e, formatDate as f, FormatWidth as g, NumberSymbol as h, getNumberOfCurrencyDigits as i, getCurrencySymbol as j, getLocaleDayPeriods as k, getLocaleDayNames as l, getLocaleMonthNames as m, getLocaleId as n, getLocaleEraNames as o, getLocaleWeekEndRange as p, getLocaleFirstDayOfWeek as q, getLocaleDateFormat as r, getLocaleDateTimeFormat as s, getLocaleExtraDayPeriodRules as t, getLocaleExtraDayPeriods as u, getLocalePluralCase as v, getLocaleTimeFormat as w, getLocaleNumberSymbol as x, getLocaleNumberFormat as y, getLocaleCurrencyCode as z };
4601
+ //# sourceMappingURL=common_module-DXqIruqL.mjs.map