(window["webpackJsonp"] = window["webpackJsonp"] || []).push([["vendor"],{ /***/ "./node_modules/@angular/common/fesm5/common.js": /*!******************************************************!*\ !*** ./node_modules/@angular/common/fesm5/common.js ***! \******************************************************/ /*! exports provided: ɵangular_packages_common_common_e, ɵangular_packages_common_common_d, ɵangular_packages_common_common_a, ɵangular_packages_common_common_b, ɵangular_packages_common_common_g, ɵangular_packages_common_common_f, ɵregisterLocaleData, registerLocaleData, formatDate, formatCurrency, formatNumber, formatPercent, NgLocaleLocalization, NgLocalization, Plural, NumberFormatStyle, FormStyle, TranslationWidth, FormatWidth, NumberSymbol, WeekDay, getNumberOfCurrencyDigits, getCurrencySymbol, getLocaleDayPeriods, getLocaleDayNames, getLocaleMonthNames, getLocaleId, getLocaleEraNames, getLocaleWeekEndRange, getLocaleFirstDayOfWeek, getLocaleDateFormat, getLocaleDateTimeFormat, getLocaleExtraDayPeriodRules, getLocaleExtraDayPeriods, getLocalePluralCase, getLocaleTimeFormat, getLocaleNumberSymbol, getLocaleNumberFormat, getLocaleCurrencyName, getLocaleCurrencySymbol, ɵparseCookieValue, CommonModule, DeprecatedI18NPipesModule, NgClass, NgForOf, NgForOfContext, NgIf, NgIfContext, NgPlural, NgPluralCase, NgStyle, NgSwitch, NgSwitchCase, NgSwitchDefault, NgTemplateOutlet, NgComponentOutlet, DOCUMENT, AsyncPipe, DatePipe, I18nPluralPipe, I18nSelectPipe, JsonPipe, LowerCasePipe, CurrencyPipe, DecimalPipe, PercentPipe, SlicePipe, UpperCasePipe, TitleCasePipe, KeyValuePipe, DeprecatedDatePipe, DeprecatedCurrencyPipe, DeprecatedDecimalPipe, DeprecatedPercentPipe, ɵPLATFORM_BROWSER_ID, ɵPLATFORM_SERVER_ID, ɵPLATFORM_WORKER_APP_ID, ɵPLATFORM_WORKER_UI_ID, isPlatformBrowser, isPlatformServer, isPlatformWorkerApp, isPlatformWorkerUi, VERSION, ViewportScroller, ɵNullViewportScroller, PlatformLocation, LOCATION_INITIALIZED, LocationStrategy, APP_BASE_HREF, HashLocationStrategy, PathLocationStrategy, Location */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ɵangular_packages_common_common_e", function() { return COMMON_DIRECTIVES; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ɵangular_packages_common_common_d", function() { return findLocaleData; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ɵangular_packages_common_common_a", function() { return DEPRECATED_PLURAL_FN; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ɵangular_packages_common_common_b", function() { return getPluralCase; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ɵangular_packages_common_common_g", function() { return COMMON_DEPRECATED_I18N_PIPES; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ɵangular_packages_common_common_f", function() { return COMMON_PIPES; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ɵregisterLocaleData", function() { return registerLocaleData; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "registerLocaleData", function() { return registerLocaleData; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "formatDate", function() { return formatDate; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "formatCurrency", function() { return formatCurrency; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "formatNumber", function() { return formatNumber; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "formatPercent", function() { return formatPercent; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "NgLocaleLocalization", function() { return NgLocaleLocalization; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "NgLocalization", function() { return NgLocalization; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Plural", function() { return Plural; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "NumberFormatStyle", function() { return NumberFormatStyle; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FormStyle", function() { return FormStyle; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TranslationWidth", function() { return TranslationWidth; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FormatWidth", function() { return FormatWidth; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "NumberSymbol", function() { return NumberSymbol; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WeekDay", function() { return WeekDay; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getNumberOfCurrencyDigits", function() { return getNumberOfCurrencyDigits; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getCurrencySymbol", function() { return getCurrencySymbol; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getLocaleDayPeriods", function() { return getLocaleDayPeriods; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getLocaleDayNames", function() { return getLocaleDayNames; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getLocaleMonthNames", function() { return getLocaleMonthNames; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getLocaleId", function() { return getLocaleId; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getLocaleEraNames", function() { return getLocaleEraNames; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getLocaleWeekEndRange", function() { return getLocaleWeekEndRange; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getLocaleFirstDayOfWeek", function() { return getLocaleFirstDayOfWeek; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getLocaleDateFormat", function() { return getLocaleDateFormat; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getLocaleDateTimeFormat", function() { return getLocaleDateTimeFormat; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getLocaleExtraDayPeriodRules", function() { return getLocaleExtraDayPeriodRules; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getLocaleExtraDayPeriods", function() { return getLocaleExtraDayPeriods; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getLocalePluralCase", function() { return getLocalePluralCase; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getLocaleTimeFormat", function() { return getLocaleTimeFormat; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getLocaleNumberSymbol", function() { return getLocaleNumberSymbol; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getLocaleNumberFormat", function() { return getLocaleNumberFormat; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getLocaleCurrencyName", function() { return getLocaleCurrencyName; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getLocaleCurrencySymbol", function() { return getLocaleCurrencySymbol; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ɵparseCookieValue", function() { return parseCookieValue; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CommonModule", function() { return CommonModule; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DeprecatedI18NPipesModule", function() { return DeprecatedI18NPipesModule; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "NgClass", function() { return NgClass; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "NgForOf", function() { return NgForOf; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "NgForOfContext", function() { return NgForOfContext; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "NgIf", function() { return NgIf; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "NgIfContext", function() { return NgIfContext; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "NgPlural", function() { return NgPlural; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "NgPluralCase", function() { return NgPluralCase; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "NgStyle", function() { return NgStyle; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "NgSwitch", function() { return NgSwitch; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "NgSwitchCase", function() { return NgSwitchCase; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "NgSwitchDefault", function() { return NgSwitchDefault; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "NgTemplateOutlet", function() { return NgTemplateOutlet; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "NgComponentOutlet", function() { return NgComponentOutlet; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DOCUMENT", function() { return DOCUMENT; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AsyncPipe", function() { return AsyncPipe; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DatePipe", function() { return DatePipe; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "I18nPluralPipe", function() { return I18nPluralPipe; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "I18nSelectPipe", function() { return I18nSelectPipe; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "JsonPipe", function() { return JsonPipe; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LowerCasePipe", function() { return LowerCasePipe; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CurrencyPipe", function() { return CurrencyPipe; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DecimalPipe", function() { return DecimalPipe; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PercentPipe", function() { return PercentPipe; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SlicePipe", function() { return SlicePipe; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "UpperCasePipe", function() { return UpperCasePipe; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TitleCasePipe", function() { return TitleCasePipe; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "KeyValuePipe", function() { return KeyValuePipe; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DeprecatedDatePipe", function() { return DeprecatedDatePipe; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DeprecatedCurrencyPipe", function() { return DeprecatedCurrencyPipe; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DeprecatedDecimalPipe", function() { return DeprecatedDecimalPipe; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DeprecatedPercentPipe", function() { return DeprecatedPercentPipe; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ɵPLATFORM_BROWSER_ID", function() { return PLATFORM_BROWSER_ID; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ɵPLATFORM_SERVER_ID", function() { return PLATFORM_SERVER_ID; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ɵPLATFORM_WORKER_APP_ID", function() { return PLATFORM_WORKER_APP_ID; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ɵPLATFORM_WORKER_UI_ID", function() { return PLATFORM_WORKER_UI_ID; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isPlatformBrowser", function() { return isPlatformBrowser; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isPlatformServer", function() { return isPlatformServer; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isPlatformWorkerApp", function() { return isPlatformWorkerApp; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isPlatformWorkerUi", function() { return isPlatformWorkerUi; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VERSION", function() { return VERSION; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ViewportScroller", function() { return ViewportScroller; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ɵNullViewportScroller", function() { return NullViewportScroller; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PlatformLocation", function() { return PlatformLocation; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LOCATION_INITIALIZED", function() { return LOCATION_INITIALIZED; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LocationStrategy", function() { return LocationStrategy; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "APP_BASE_HREF", function() { return APP_BASE_HREF; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HashLocationStrategy", function() { return HashLocationStrategy; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PathLocationStrategy", function() { return PathLocationStrategy; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Location", function() { return Location; }); /* harmony import */ var _angular_core__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @angular/core */ "./node_modules/@angular/core/fesm5/core.js"); /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! tslib */ "./node_modules/tslib/tslib.es6.js"); /** * @license Angular v7.2.3 * (c) 2010-2018 Google, Inc. https://angular.io/ * License: MIT */ /** * @license * Copyright Google Inc. All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ /** * This class should not be used directly by an application developer. Instead, use * {@link Location}. * * `PlatformLocation` encapsulates all calls to DOM apis, which allows the Router to be platform * agnostic. * This means that we can have different implementation of `PlatformLocation` for the different * platforms that angular supports. For example, `@angular/platform-browser` provides an * implementation specific to the browser environment, while `@angular/platform-webworker` provides * one suitable for use with web workers. * * The `PlatformLocation` class is used directly by all implementations of {@link LocationStrategy} * when they need to interact with the DOM apis like pushState, popState, etc... * * {@link LocationStrategy} in turn is used by the {@link Location} service which is used directly * by the {@link Router} in order to navigate between routes. Since all interactions between {@link * Router} / * {@link Location} / {@link LocationStrategy} and DOM apis flow through the `PlatformLocation` * class they are all platform independent. * * @publicApi */ var PlatformLocation = /** @class */ (function () { function PlatformLocation() { } return PlatformLocation; }()); /** * @description * Indicates when a location is initialized. * * @publicApi */ var LOCATION_INITIALIZED = new _angular_core__WEBPACK_IMPORTED_MODULE_0__["InjectionToken"]('Location Initialized'); /** * @license * Copyright Google Inc. All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ /** * `LocationStrategy` is responsible for representing and reading route state * from the browser's URL. Angular provides two strategies: * {@link HashLocationStrategy} and {@link PathLocationStrategy}. * * This is used under the hood of the {@link Location} service. * * Applications should use the {@link Router} or {@link Location} services to * interact with application route state. * * For instance, {@link HashLocationStrategy} produces URLs like * `http://example.com#/foo`, and {@link PathLocationStrategy} produces * `http://example.com/foo` as an equivalent URL. * * See these two classes for more. * * @publicApi */ var LocationStrategy = /** @class */ (function () { function LocationStrategy() { } return LocationStrategy; }()); /** * The `APP_BASE_HREF` token represents the base href to be used with the * {@link PathLocationStrategy}. * * If you're using {@link PathLocationStrategy}, you must provide a provider to a string * representing the URL prefix that should be preserved when generating and recognizing * URLs. * * @usageNotes * * ### Example * * ```typescript * import {Component, NgModule} from '@angular/core'; * import {APP_BASE_HREF} from '@angular/common'; * * @NgModule({ * providers: [{provide: APP_BASE_HREF, useValue: '/my/app'}] * }) * class AppModule {} * ``` * * @publicApi */ var APP_BASE_HREF = new _angular_core__WEBPACK_IMPORTED_MODULE_0__["InjectionToken"]('appBaseHref'); /** * @license * Copyright Google Inc. All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ /** * @description * * A service that applications can use to interact with a browser's URL. * * Depending on which {@link LocationStrategy} is used, `Location` will either persist * to the URL's path or the URL's hash segment. * * @usageNotes * * It's better to use {@link Router#navigate} service to trigger route changes. Use * `Location` only if you need to interact with or create normalized URLs outside of * routing. * * `Location` is responsible for normalizing the URL against the application's base href. * A normalized URL is absolute from the URL host, includes the application's base href, and has no * trailing slash: * - `/my/app/user/123` is normalized * - `my/app/user/123` **is not** normalized * - `/my/app/user/123/` **is not** normalized * * ### Example * * {@example common/location/ts/path_location_component.ts region='LocationComponent'} * * @publicApi */ var Location = /** @class */ (function () { function Location(platformStrategy) { var _this = this; /** @internal */ this._subject = new _angular_core__WEBPACK_IMPORTED_MODULE_0__["EventEmitter"](); this._platformStrategy = platformStrategy; var browserBaseHref = this._platformStrategy.getBaseHref(); this._baseHref = Location_1.stripTrailingSlash(_stripIndexHtml(browserBaseHref)); this._platformStrategy.onPopState(function (ev) { _this._subject.emit({ 'url': _this.path(true), 'pop': true, 'state': ev.state, 'type': ev.type, }); }); } Location_1 = Location; /** * Returns the normalized URL path. */ // TODO: vsavkin. Remove the boolean flag and always include hash once the deprecated router is // removed. Location.prototype.path = function (includeHash) { if (includeHash === void 0) { includeHash = false; } return this.normalize(this._platformStrategy.path(includeHash)); }; /** * Normalizes the given path and compares to the current normalized path. */ Location.prototype.isCurrentPathEqualTo = function (path, query) { if (query === void 0) { query = ''; } return this.path() == this.normalize(path + Location_1.normalizeQueryParams(query)); }; /** * Given a string representing a URL, returns the normalized URL path without leading or * trailing slashes. */ Location.prototype.normalize = function (url) { return Location_1.stripTrailingSlash(_stripBaseHref(this._baseHref, _stripIndexHtml(url))); }; /** * Given a string representing a URL, returns the platform-specific external URL path. * If the given URL doesn't begin with a leading slash (`'/'`), this method adds one * before normalizing. This method will also add a hash if `HashLocationStrategy` is * used, or the `APP_BASE_HREF` if the `PathLocationStrategy` is in use. */ Location.prototype.prepareExternalUrl = function (url) { if (url && url[0] !== '/') { url = '/' + url; } return this._platformStrategy.prepareExternalUrl(url); }; // TODO: rename this method to pushState /** * Changes the browsers URL to the normalized version of the given URL, and pushes a * new item onto the platform's history. */ Location.prototype.go = function (path, query, state) { if (query === void 0) { query = ''; } if (state === void 0) { state = null; } this._platformStrategy.pushState(state, '', path, query); }; /** * Changes the browsers URL to the normalized version of the given URL, and replaces * the top item on the platform's history stack. */ Location.prototype.replaceState = function (path, query, state) { if (query === void 0) { query = ''; } if (state === void 0) { state = null; } this._platformStrategy.replaceState(state, '', path, query); }; /** * Navigates forward in the platform's history. */ Location.prototype.forward = function () { this._platformStrategy.forward(); }; /** * Navigates back in the platform's history. */ Location.prototype.back = function () { this._platformStrategy.back(); }; /** * Subscribe to the platform's `popState` events. */ Location.prototype.subscribe = function (onNext, onThrow, onReturn) { return this._subject.subscribe({ next: onNext, error: onThrow, complete: onReturn }); }; /** * Given a string of url parameters, prepend with '?' if needed, otherwise return parameters as * is. */ Location.normalizeQueryParams = function (params) { return params && params[0] !== '?' ? '?' + params : params; }; /** * Given 2 parts of a url, join them with a slash if needed. */ Location.joinWithSlash = function (start, end) { if (start.length == 0) { return end; } if (end.length == 0) { return start; } var slashes = 0; if (start.endsWith('/')) { slashes++; } if (end.startsWith('/')) { slashes++; } if (slashes == 2) { return start + end.substring(1); } if (slashes == 1) { return start + end; } return start + '/' + end; }; /** * If url has a trailing slash, remove it, otherwise return url as is. This * method looks for the first occurrence of either #, ?, or the end of the * line as `/` characters after any of these should not be replaced. */ Location.stripTrailingSlash = function (url) { var match = url.match(/#|\?|$/); var pathEndIdx = match && match.index || url.length; var droppedSlashIdx = pathEndIdx - (url[pathEndIdx - 1] === '/' ? 1 : 0); return url.slice(0, droppedSlashIdx) + url.slice(pathEndIdx); }; var Location_1; Location = Location_1 = Object(tslib__WEBPACK_IMPORTED_MODULE_1__["__decorate"])([ Object(_angular_core__WEBPACK_IMPORTED_MODULE_0__["Injectable"])(), Object(tslib__WEBPACK_IMPORTED_MODULE_1__["__metadata"])("design:paramtypes", [LocationStrategy]) ], Location); return Location; }()); function _stripBaseHref(baseHref, url) { return baseHref && url.startsWith(baseHref) ? url.substring(baseHref.length) : url; } function _stripIndexHtml(url) { return url.replace(/\/index.html$/, ''); } /** * @license * Copyright Google Inc. All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ /** * @description * A {@link LocationStrategy} used to configure the {@link Location} service to * represent its state in the * [hash fragment](https://en.wikipedia.org/wiki/Uniform_Resource_Locator#Syntax) * of the browser's URL. * * For instance, if you call `location.go('/foo')`, the browser's URL will become * `example.com#/foo`. * * @usageNotes * * ### Example * * {@example common/location/ts/hash_location_component.ts region='LocationComponent'} * * @publicApi */ var HashLocationStrategy = /** @class */ (function (_super) { Object(tslib__WEBPACK_IMPORTED_MODULE_1__["__extends"])(HashLocationStrategy, _super); function HashLocationStrategy(_platformLocation, _baseHref) { var _this = _super.call(this) || this; _this._platformLocation = _platformLocation; _this._baseHref = ''; if (_baseHref != null) { _this._baseHref = _baseHref; } return _this; } HashLocationStrategy.prototype.onPopState = function (fn) { this._platformLocation.onPopState(fn); this._platformLocation.onHashChange(fn); }; HashLocationStrategy.prototype.getBaseHref = function () { return this._baseHref; }; HashLocationStrategy.prototype.path = function (includeHash) { if (includeHash === void 0) { includeHash = false; } // the hash value is always prefixed with a `#` // and if it is empty then it will stay empty var path = this._platformLocation.hash; if (path == null) path = '#'; return path.length > 0 ? path.substring(1) : path; }; HashLocationStrategy.prototype.prepareExternalUrl = function (internal) { var url = Location.joinWithSlash(this._baseHref, internal); return url.length > 0 ? ('#' + url) : url; }; HashLocationStrategy.prototype.pushState = function (state, title, path, queryParams) { var url = this.prepareExternalUrl(path + Location.normalizeQueryParams(queryParams)); if (url.length == 0) { url = this._platformLocation.pathname; } this._platformLocation.pushState(state, title, url); }; HashLocationStrategy.prototype.replaceState = function (state, title, path, queryParams) { var url = this.prepareExternalUrl(path + Location.normalizeQueryParams(queryParams)); if (url.length == 0) { url = this._platformLocation.pathname; } this._platformLocation.replaceState(state, title, url); }; HashLocationStrategy.prototype.forward = function () { this._platformLocation.forward(); }; HashLocationStrategy.prototype.back = function () { this._platformLocation.back(); }; HashLocationStrategy = Object(tslib__WEBPACK_IMPORTED_MODULE_1__["__decorate"])([ Object(_angular_core__WEBPACK_IMPORTED_MODULE_0__["Injectable"])(), Object(tslib__WEBPACK_IMPORTED_MODULE_1__["__param"])(1, Object(_angular_core__WEBPACK_IMPORTED_MODULE_0__["Optional"])()), Object(tslib__WEBPACK_IMPORTED_MODULE_1__["__param"])(1, Object(_angular_core__WEBPACK_IMPORTED_MODULE_0__["Inject"])(APP_BASE_HREF)), Object(tslib__WEBPACK_IMPORTED_MODULE_1__["__metadata"])("design:paramtypes", [PlatformLocation, String]) ], HashLocationStrategy); return HashLocationStrategy; }(LocationStrategy)); /** * @license * Copyright Google Inc. All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ /** * @description * A {@link LocationStrategy} used to configure the {@link Location} service to * represent its state in the * [path](https://en.wikipedia.org/wiki/Uniform_Resource_Locator#Syntax) of the * browser's URL. * * If you're using `PathLocationStrategy`, you must provide a {@link APP_BASE_HREF} * or add a base element to the document. This URL prefix that will be preserved * when generating and recognizing URLs. * * For instance, if you provide an `APP_BASE_HREF` of `'/my/app'` and call * `location.go('/foo')`, the browser's URL will become * `example.com/my/app/foo`. * * Similarly, if you add `` to the document and call * `location.go('/foo')`, the browser's URL will become * `example.com/my/app/foo`. * * @usageNotes * * ### Example * * {@example common/location/ts/path_location_component.ts region='LocationComponent'} * * @publicApi */ var PathLocationStrategy = /** @class */ (function (_super) { Object(tslib__WEBPACK_IMPORTED_MODULE_1__["__extends"])(PathLocationStrategy, _super); function PathLocationStrategy(_platformLocation, href) { var _this = _super.call(this) || this; _this._platformLocation = _platformLocation; if (href == null) { href = _this._platformLocation.getBaseHrefFromDOM(); } if (href == null) { throw new Error("No base href set. Please provide a value for the APP_BASE_HREF token or add a base element to the document."); } _this._baseHref = href; return _this; } PathLocationStrategy.prototype.onPopState = function (fn) { this._platformLocation.onPopState(fn); this._platformLocation.onHashChange(fn); }; PathLocationStrategy.prototype.getBaseHref = function () { return this._baseHref; }; PathLocationStrategy.prototype.prepareExternalUrl = function (internal) { return Location.joinWithSlash(this._baseHref, internal); }; PathLocationStrategy.prototype.path = function (includeHash) { if (includeHash === void 0) { includeHash = false; } var pathname = this._platformLocation.pathname + Location.normalizeQueryParams(this._platformLocation.search); var hash = this._platformLocation.hash; return hash && includeHash ? "" + pathname + hash : pathname; }; PathLocationStrategy.prototype.pushState = function (state, title, url, queryParams) { var externalUrl = this.prepareExternalUrl(url + Location.normalizeQueryParams(queryParams)); this._platformLocation.pushState(state, title, externalUrl); }; PathLocationStrategy.prototype.replaceState = function (state, title, url, queryParams) { var externalUrl = this.prepareExternalUrl(url + Location.normalizeQueryParams(queryParams)); this._platformLocation.replaceState(state, title, externalUrl); }; PathLocationStrategy.prototype.forward = function () { this._platformLocation.forward(); }; PathLocationStrategy.prototype.back = function () { this._platformLocation.back(); }; PathLocationStrategy = Object(tslib__WEBPACK_IMPORTED_MODULE_1__["__decorate"])([ Object(_angular_core__WEBPACK_IMPORTED_MODULE_0__["Injectable"])(), Object(tslib__WEBPACK_IMPORTED_MODULE_1__["__param"])(1, Object(_angular_core__WEBPACK_IMPORTED_MODULE_0__["Optional"])()), Object(tslib__WEBPACK_IMPORTED_MODULE_1__["__param"])(1, Object(_angular_core__WEBPACK_IMPORTED_MODULE_0__["Inject"])(APP_BASE_HREF)), Object(tslib__WEBPACK_IMPORTED_MODULE_1__["__metadata"])("design:paramtypes", [PlatformLocation, String]) ], PathLocationStrategy); return PathLocationStrategy; }(LocationStrategy)); /** * @license * Copyright Google Inc. All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ /** * @license * Copyright Google Inc. All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ // THIS CODE IS GENERATED - DO NOT MODIFY // See angular/tools/gulp-tasks/cldr/extract.js var u = undefined; function plural(n) { var i = Math.floor(Math.abs(n)), v = n.toString().replace(/^[^.]*\.?/, '').length; if (i === 1 && v === 0) return 1; return 5; } var localeEn = [ 'en', [['a', 'p'], ['AM', 'PM'], u], [['AM', 'PM'], u, u], [ ['S', 'M', 'T', 'W', 'T', 'F', 'S'], ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'], ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'], ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'] ], u, [ ['J', 'F', 'M', 'A', 'M', 'J', 'J', 'A', 'S', 'O', 'N', 'D'], ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'], [ 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December' ] ], u, [['B', 'A'], ['BC', 'AD'], ['Before Christ', 'Anno Domini']], 0, [6, 0], ['M/d/yy', 'MMM d, y', 'MMMM d, y', 'EEEE, MMMM d, y'], ['h:mm a', 'h:mm:ss a', 'h:mm:ss a z', 'h:mm:ss a zzzz'], ['{1}, {0}', u, '{1} \'at\' {0}', u], ['.', ',', ';', '%', '+', '-', 'E', '×', '‰', '∞', 'NaN', ':'], ['#,##0.###', '#,##0%', '¤#,##0.00', '#E0'], '$', 'US Dollar', {}, plural ]; /** * @license * Copyright Google Inc. All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ /** * @publicApi */ var LOCALE_DATA = {}; /** * Register global data to be used internally by Angular. See the * ["I18n guide"](guide/i18n#i18n-pipes) to know how to import additional locale data. * * @publicApi */ // The signature registerLocaleData(data: any, extraData?: any) is deprecated since v5.1 function registerLocaleData(data, localeId, extraData) { if (typeof localeId !== 'string') { extraData = localeId; localeId = data[0 /* LocaleId */]; } localeId = localeId.toLowerCase().replace(/_/g, '-'); LOCALE_DATA[localeId] = data; if (extraData) { LOCALE_DATA[localeId][19 /* ExtraData */] = extraData; } } /** * @license * Copyright Google Inc. All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ /** @internal */ var CURRENCIES_EN = { 'ADP': [undefined, undefined, 0], 'AFN': [undefined, undefined, 0], 'ALL': [undefined, undefined, 0], 'AMD': [undefined, undefined, 0], 'AOA': [undefined, 'Kz'], 'ARS': [undefined, '$'], 'AUD': ['A$', '$'], '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, 'р.', 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, '$', 0], '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, '₾'], 'GIP': [undefined, '£'], 'GNF': [undefined, 'FG', 0], 'GTQ': [undefined, 'Q'], 'GYD': [undefined, '$', 0], 'HKD': ['HK$', '$'], 'HNL': [undefined, 'L'], 'HRK': [undefined, 'kn'], 'HUF': [undefined, 'Ft', 2], 'IDR': [undefined, 'Rp', 0], '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, '₮', 0], 'MRO': [undefined, undefined, 0], 'MUR': [undefined, 'Rs', 0], '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': [undefined, '₱'], 'PKR': [undefined, 'Rs', 0], 'PLN': [undefined, 'zł'], 'PYG': [undefined, '₲', 0], 'RON': [undefined, 'lei'], 'RSD': [undefined, undefined, 0], 'RUB': [undefined, '₽'], 'RUR': [undefined, 'р.'], 'RWF': [undefined, 'RF', 0], 'SBD': [undefined, '$'], 'SEK': [undefined, 'kr', 2], 'SGD': [undefined, '$'], 'SHP': [undefined, '£'], '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, 0], 'UAH': [undefined, '₴'], 'UGX': [undefined, undefined, 0], 'USD': ['$'], 'UYI': [undefined, undefined, 0], 'UYU': [undefined, '$'], 'UZS': [undefined, undefined, 0], 'VEF': [undefined, 'Bs'], 'VND': ['₫', undefined, 0], 'VUV': [undefined, undefined, 0], 'XAF': ['FCFA', undefined, 0], 'XCD': ['EC$', '$'], 'XOF': ['CFA', undefined, 0], 'XPF': ['CFPF', undefined, 0], 'YER': [undefined, undefined, 0], 'ZAR': [undefined, 'R'], 'ZMK': [undefined, undefined, 0], 'ZMW': [undefined, 'ZK'], 'ZWD': [undefined, undefined, 0] }; /** * @license * Copyright Google Inc. All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ /** * The different format styles that can be used to represent numbers. * Used by the function {@link getLocaleNumberFormat}. * * @publicApi */ var NumberFormatStyle; (function (NumberFormatStyle) { NumberFormatStyle[NumberFormatStyle["Decimal"] = 0] = "Decimal"; NumberFormatStyle[NumberFormatStyle["Percent"] = 1] = "Percent"; NumberFormatStyle[NumberFormatStyle["Currency"] = 2] = "Currency"; NumberFormatStyle[NumberFormatStyle["Scientific"] = 3] = "Scientific"; })(NumberFormatStyle || (NumberFormatStyle = {})); /** @publicApi */ var Plural; (function (Plural) { Plural[Plural["Zero"] = 0] = "Zero"; Plural[Plural["One"] = 1] = "One"; Plural[Plural["Two"] = 2] = "Two"; Plural[Plural["Few"] = 3] = "Few"; Plural[Plural["Many"] = 4] = "Many"; Plural[Plural["Other"] = 5] = "Other"; })(Plural || (Plural = {})); /** * Some languages use two different forms of strings (standalone and format) depending on the * context. * Typically the standalone version is the nominative form of the word, and the format version is in * the genitive. * See [the CLDR website](http://cldr.unicode.org/translation/date-time) for more information. * * @publicApi */ var FormStyle; (function (FormStyle) { FormStyle[FormStyle["Format"] = 0] = "Format"; FormStyle[FormStyle["Standalone"] = 1] = "Standalone"; })(FormStyle || (FormStyle = {})); /** * Multiple widths are available for translations: narrow (1 character), abbreviated (3 characters), * wide (full length), and short (2 characters, only for days). * * For example the day `Sunday` will be: * - Narrow: `S` * - Short: `Su` * - Abbreviated: `Sun` * - Wide: `Sunday` * * @publicApi */ var TranslationWidth; (function (TranslationWidth) { TranslationWidth[TranslationWidth["Narrow"] = 0] = "Narrow"; TranslationWidth[TranslationWidth["Abbreviated"] = 1] = "Abbreviated"; TranslationWidth[TranslationWidth["Wide"] = 2] = "Wide"; TranslationWidth[TranslationWidth["Short"] = 3] = "Short"; })(TranslationWidth || (TranslationWidth = {})); /** * Multiple widths are available for formats: short (minimal amount of data), medium (small amount * of data), long (complete amount of data), full (complete amount of data and extra information). * * For example the date-time formats for the english locale will be: * - `'short'`: `'M/d/yy, h:mm a'` (e.g. `6/15/15, 9:03 AM`) * - `'medium'`: `'MMM d, y, h:mm:ss a'` (e.g. `Jun 15, 2015, 9:03:01 AM`) * - `'long'`: `'MMMM d, y, h:mm:ss a z'` (e.g. `June 15, 2015 at 9:03:01 AM GMT+1`) * - `'full'`: `'EEEE, MMMM d, y, h:mm:ss a zzzz'` (e.g. `Monday, June 15, 2015 at * 9:03:01 AM GMT+01:00`) * * @publicApi */ var FormatWidth; (function (FormatWidth) { FormatWidth[FormatWidth["Short"] = 0] = "Short"; FormatWidth[FormatWidth["Medium"] = 1] = "Medium"; FormatWidth[FormatWidth["Long"] = 2] = "Long"; FormatWidth[FormatWidth["Full"] = 3] = "Full"; })(FormatWidth || (FormatWidth = {})); /** * Number symbol that can be used to replace placeholders in number patterns. * The placeholders are based on english values: * * | Name | Example for en-US | Meaning | * |------------------------|-------------------|---------------------------------------------| * | decimal | 2,345`.`67 | decimal separator | * | group | 2`,`345.67 | grouping separator, typically for thousands | * | plusSign | `+`23 | the plus sign used with numbers | * | minusSign | `-`23 | the minus sign used with numbers | * | percentSign | 23.4`%` | the percent sign (out of 100) | * | perMille | 234`‰` | the permille sign (out of 1000) | * | exponential | 1.2`E`3 | used in computers for 1.2×10³. | * | superscriptingExponent | 1.2`×`103 | human-readable format of exponential | * | infinity | `∞` | used in +∞ and -∞. | * | nan | `NaN` | "not a number". | * | timeSeparator | 10`:`52 | symbol used between time units | * | currencyDecimal | $2,345`.`67 | decimal separator, fallback to "decimal" | * | currencyGroup | $2`,`345.67 | grouping separator, fallback to "group" | * * @publicApi */ var NumberSymbol; (function (NumberSymbol) { NumberSymbol[NumberSymbol["Decimal"] = 0] = "Decimal"; NumberSymbol[NumberSymbol["Group"] = 1] = "Group"; NumberSymbol[NumberSymbol["List"] = 2] = "List"; NumberSymbol[NumberSymbol["PercentSign"] = 3] = "PercentSign"; NumberSymbol[NumberSymbol["PlusSign"] = 4] = "PlusSign"; NumberSymbol[NumberSymbol["MinusSign"] = 5] = "MinusSign"; NumberSymbol[NumberSymbol["Exponential"] = 6] = "Exponential"; NumberSymbol[NumberSymbol["SuperscriptingExponent"] = 7] = "SuperscriptingExponent"; NumberSymbol[NumberSymbol["PerMille"] = 8] = "PerMille"; NumberSymbol[NumberSymbol["Infinity"] = 9] = "Infinity"; NumberSymbol[NumberSymbol["NaN"] = 10] = "NaN"; NumberSymbol[NumberSymbol["TimeSeparator"] = 11] = "TimeSeparator"; NumberSymbol[NumberSymbol["CurrencyDecimal"] = 12] = "CurrencyDecimal"; NumberSymbol[NumberSymbol["CurrencyGroup"] = 13] = "CurrencyGroup"; })(NumberSymbol || (NumberSymbol = {})); /** * The value for each day of the week, based on the en-US locale * * @publicApi */ var WeekDay; (function (WeekDay) { WeekDay[WeekDay["Sunday"] = 0] = "Sunday"; WeekDay[WeekDay["Monday"] = 1] = "Monday"; WeekDay[WeekDay["Tuesday"] = 2] = "Tuesday"; WeekDay[WeekDay["Wednesday"] = 3] = "Wednesday"; WeekDay[WeekDay["Thursday"] = 4] = "Thursday"; WeekDay[WeekDay["Friday"] = 5] = "Friday"; WeekDay[WeekDay["Saturday"] = 6] = "Saturday"; })(WeekDay || (WeekDay = {})); /** * The locale id for the chosen locale (e.g `en-GB`). * * @publicApi */ function getLocaleId(locale) { return findLocaleData(locale)[0 /* LocaleId */]; } /** * Periods of the day (e.g. `[AM, PM]` for en-US). * * @publicApi */ function getLocaleDayPeriods(locale, formStyle, width) { var data = findLocaleData(locale); var amPmData = [data[1 /* DayPeriodsFormat */], data[2 /* DayPeriodsStandalone */]]; var amPm = getLastDefinedValue(amPmData, formStyle); return getLastDefinedValue(amPm, width); } /** * Days of the week for the Gregorian calendar (e.g. `[Sunday, Monday, ... Saturday]` for en-US). * * @publicApi */ function getLocaleDayNames(locale, formStyle, width) { var data = findLocaleData(locale); var daysData = [data[3 /* DaysFormat */], data[4 /* DaysStandalone */]]; var days = getLastDefinedValue(daysData, formStyle); return getLastDefinedValue(days, width); } /** * Months of the year for the Gregorian calendar (e.g. `[January, February, ...]` for en-US). * * @publicApi */ function getLocaleMonthNames(locale, formStyle, width) { var data = findLocaleData(locale); var monthsData = [data[5 /* MonthsFormat */], data[6 /* MonthsStandalone */]]; var months = getLastDefinedValue(monthsData, formStyle); return getLastDefinedValue(months, width); } /** * Eras for the Gregorian calendar (e.g. AD/BC). * * @publicApi */ function getLocaleEraNames(locale, width) { var data = findLocaleData(locale); var erasData = data[7 /* Eras */]; return getLastDefinedValue(erasData, width); } /** * First day of the week for this locale, based on english days (Sunday = 0, Monday = 1, ...). * For example in french the value would be 1 because the first day of the week is Monday. * * @publicApi */ function getLocaleFirstDayOfWeek(locale) { var data = findLocaleData(locale); return data[8 /* FirstDayOfWeek */]; } /** * Range of days in the week that represent the week-end for this locale, based on english days * (Sunday = 0, Monday = 1, ...). * For example in english the value would be [6,0] for Saturday to Sunday. * * @publicApi */ function getLocaleWeekEndRange(locale) { var data = findLocaleData(locale); return data[9 /* WeekendRange */]; } /** * Date format that depends on the locale. * * There are four basic date formats: * - `full` should contain long-weekday (EEEE), year (y), long-month (MMMM), day (d). * * For example, English uses `EEEE, MMMM d, y`, corresponding to a date like * "Tuesday, September 14, 1999". * * - `long` should contain year, long-month, day. * * For example, `MMMM d, y`, corresponding to a date like "September 14, 1999". * * - `medium` should contain year, abbreviated-month (MMM), day. * * For example, `MMM d, y`, corresponding to a date like "Sep 14, 1999". * For languages that do not use abbreviated months, use the numeric month (MM/M). For example, * `y/MM/dd`, corresponding to a date like "1999/09/14". * * - `short` should contain year, numeric-month (MM/M), and day. * * For example, `M/d/yy`, corresponding to a date like "9/14/99". * * @publicApi */ function getLocaleDateFormat(locale, width) { var data = findLocaleData(locale); return getLastDefinedValue(data[10 /* DateFormat */], width); } /** * Time format that depends on the locale. * * The standard formats include four basic time formats: * - `full` should contain hour (h/H), minute (mm), second (ss), and zone (zzzz). * - `long` should contain hour, minute, second, and zone (z) * - `medium` should contain hour, minute, second. * - `short` should contain hour, minute. * * Note: The patterns depend on whether the main country using your language uses 12-hour time or * not: * - For 12-hour time, use a pattern like `hh:mm a` using h to mean a 12-hour clock cycle running * 1 through 12 (midnight plus 1 minute is 12:01), or using K to mean a 12-hour clock cycle * running 0 through 11 (midnight plus 1 minute is 0:01). * - For 24-hour time, use a pattern like `HH:mm` using H to mean a 24-hour clock cycle running 0 * through 23 (midnight plus 1 minute is 0:01), or using k to mean a 24-hour clock cycle running * 1 through 24 (midnight plus 1 minute is 24:01). * * @publicApi */ function getLocaleTimeFormat(locale, width) { var data = findLocaleData(locale); return getLastDefinedValue(data[11 /* TimeFormat */], width); } /** * Date-time format that depends on the locale. * * The date-time pattern shows how to combine separate patterns for date (represented by {1}) * and time (represented by {0}) into a single pattern. It usually doesn't need to be changed. * What you want to pay attention to are: * - possibly removing a space for languages that don't use it, such as many East Asian languages * - possibly adding a comma, other punctuation, or a combining word * * For example: * - English uses `{1} 'at' {0}` or `{1}, {0}` (depending on date style), while Japanese uses * `{1}{0}`. * - An English formatted date-time using the combining pattern `{1}, {0}` could be * `Dec 10, 2010, 3:59:49 PM`. Notice the comma and space between the date portion and the time * portion. * * There are four formats (`full`, `long`, `medium`, `short`); the determination of which to use * is normally based on the date style. For example, if the date has a full month and weekday * name, the full combining pattern will be used to combine that with a time. If the date has * numeric month, the short version of the combining pattern will be used to combine that with a * time. English uses `{1} 'at' {0}` for full and long styles, and `{1}, {0}` for medium and short * styles. * * @publicApi */ function getLocaleDateTimeFormat(locale, width) { var data = findLocaleData(locale); var dateTimeFormatData = data[12 /* DateTimeFormat */]; return getLastDefinedValue(dateTimeFormatData, width); } /** * Number symbol that can be used to replace placeholders in number formats. * See {@link NumberSymbol} for more information. * * @publicApi */ function getLocaleNumberSymbol(locale, symbol) { var data = findLocaleData(locale); var res = data[13 /* NumberSymbols */][symbol]; if (typeof res === 'undefined') { if (symbol === NumberSymbol.CurrencyDecimal) { return data[13 /* NumberSymbols */][NumberSymbol.Decimal]; } else if (symbol === NumberSymbol.CurrencyGroup) { return data[13 /* NumberSymbols */][NumberSymbol.Group]; } } return res; } /** * Number format that depends on the locale. * * Numbers are formatted using patterns, like `#,###.00`. For example, the pattern `#,###.00` * when used to format the number 12345.678 could result in "12'345,67". That would happen if the * grouping separator for your language is an apostrophe, and the decimal separator is a comma. * * Important: The characters `.` `,` `0` `#` (and others below) are special placeholders; * they stand for the decimal separator, and so on, and are NOT real characters. * You must NOT "translate" the placeholders; for example, don't change `.` to `,` even though in * your language the decimal point is written with a comma. The symbols should be replaced by the * local equivalents, using the Number Symbols for your language. * * Here are the special characters used in number patterns: * * | Symbol | Meaning | * |--------|---------| * | . | Replaced automatically by the character used for the decimal point. | * | , | Replaced by the "grouping" (thousands) separator. | * | 0 | Replaced by a digit (or zero if there aren't enough digits). | * | # | Replaced by a digit (or nothing if there aren't enough). | * | ¤ | This will be replaced by a currency symbol, such as $ or USD. | * | % | This marks a percent format. The % symbol may change position, but must be retained. | * | E | This marks a scientific format. The E symbol may change position, but must be retained. | * | ' | Special characters used as literal characters are quoted with ASCII single quotes. | * * You can find more information * [on the CLDR website](http://cldr.unicode.org/translation/number-patterns) * * @publicApi */ function getLocaleNumberFormat(locale, type) { var data = findLocaleData(locale); return data[14 /* NumberFormats */][type]; } /** * The symbol used to represent the currency for the main country using this locale (e.g. $ for * the locale en-US). * The symbol will be `null` if the main country cannot be determined. * * @publicApi */ function getLocaleCurrencySymbol(locale) { var data = findLocaleData(locale); return data[15 /* CurrencySymbol */] || null; } /** * The name of the currency for the main country using this locale (e.g. 'US Dollar' for the locale * en-US). * The name will be `null` if the main country cannot be determined. * * @publicApi */ function getLocaleCurrencyName(locale) { var data = findLocaleData(locale); return data[16 /* CurrencyName */] || null; } /** * Returns the currency values for the locale */ function getLocaleCurrencies(locale) { var data = findLocaleData(locale); return data[17 /* Currencies */]; } /** * The locale plural function used by ICU expressions to determine the plural case to use. * See {@link NgPlural} for more information. * * @publicApi */ function getLocalePluralCase(locale) { var data = findLocaleData(locale); return data[18 /* PluralCase */]; } function checkFullData(data) { if (!data[19 /* ExtraData */]) { throw new Error("Missing extra locale data for the locale \"" + data[0 /* LocaleId */] + "\". Use \"registerLocaleData\" to load new data. See the \"I18n guide\" on angular.io to know more."); } } /** * Rules used to determine which day period to use (See `dayPeriods` below). * The rules can either be an array or a single value. If it's an array, consider it as "from" * and "to". If it's a single value then it means that the period is only valid at this exact * value. * There is always the same number of rules as the number of day periods, which means that the * first rule is applied to the first day period and so on. * You should fallback to AM/PM when there are no rules available. * * Note: this is only available if you load the full locale data. * See the ["I18n guide"](guide/i18n#i18n-pipes) to know how to import additional locale * data. * * @publicApi */ function getLocaleExtraDayPeriodRules(locale) { var data = findLocaleData(locale); checkFullData(data); var rules = data[19 /* ExtraData */][2 /* ExtraDayPeriodsRules */] || []; return rules.map(function (rule) { if (typeof rule === 'string') { return extractTime(rule); } return [extractTime(rule[0]), extractTime(rule[1])]; }); } /** * Day Periods indicate roughly how the day is broken up in different languages (e.g. morning, * noon, afternoon, midnight, ...). * You should use the function {@link getLocaleExtraDayPeriodRules} to determine which period to * use. * You should fallback to AM/PM when there are no day periods available. * * Note: this is only available if you load the full locale data. * See the ["I18n guide"](guide/i18n#i18n-pipes) to know how to import additional locale * data. * * @publicApi */ function getLocaleExtraDayPeriods(locale, formStyle, width) { var data = findLocaleData(locale); checkFullData(data); var dayPeriodsData = [ data[19 /* ExtraData */][0 /* ExtraDayPeriodFormats */], data[19 /* ExtraData */][1 /* ExtraDayPeriodStandalone */] ]; var dayPeriods = getLastDefinedValue(dayPeriodsData, formStyle) || []; return getLastDefinedValue(dayPeriods, width) || []; } /** * Returns the first value that is defined in an array, going backwards. * * To avoid repeating the same data (e.g. when "format" and "standalone" are the same) we only * add the first one to the locale data arrays, the other ones are only defined when different. * We use this function to retrieve the first defined value. * * @publicApi */ function getLastDefinedValue(data, index) { for (var i = index; i > -1; i--) { if (typeof data[i] !== 'undefined') { return data[i]; } } throw new Error('Locale data API: locale data undefined'); } /** * Extract the hours and minutes from a string like "15:45" */ function extractTime(time) { var _a = Object(tslib__WEBPACK_IMPORTED_MODULE_1__["__read"])(time.split(':'), 2), h = _a[0], m = _a[1]; return { hours: +h, minutes: +m }; } /** * Finds the locale data for a locale id * * @publicApi */ function findLocaleData(locale) { var normalizedLocale = locale.toLowerCase().replace(/_/g, '-'); var match = LOCALE_DATA[normalizedLocale]; if (match) { return match; } // let's try to find a parent locale var parentLocale = normalizedLocale.split('-')[0]; match = LOCALE_DATA[parentLocale]; if (match) { return match; } if (parentLocale === 'en') { return localeEn; } throw new Error("Missing locale data for the locale \"" + locale + "\"."); } /** * Returns the currency symbol for a given currency code, or the code if no symbol available * (e.g.: format narrow = $, format wide = US$, code = USD) * If no locale is provided, it uses the locale "en" by default * * @publicApi */ function getCurrencySymbol(code, format, locale) { if (locale === void 0) { locale = 'en'; } var currency = getLocaleCurrencies(locale)[code] || CURRENCIES_EN[code] || []; var symbolNarrow = currency[1 /* SymbolNarrow */]; if (format === 'narrow' && typeof symbolNarrow === 'string') { return symbolNarrow; } return currency[0 /* Symbol */] || code; } // Most currencies have cents, that's why the default is 2 var DEFAULT_NB_OF_CURRENCY_DIGITS = 2; /** * Returns the number of decimal digits for the given currency. * Its value depends upon the presence of cents in that particular currency. * * @publicApi */ function getNumberOfCurrencyDigits(code) { var digits; var currency = CURRENCIES_EN[code]; if (currency) { digits = currency[2 /* NbOfDigits */]; } return typeof digits === 'number' ? digits : DEFAULT_NB_OF_CURRENCY_DIGITS; } /** * @license * Copyright Google Inc. All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ var ISO8601_DATE_REGEX = /^(\d{4})-?(\d\d)-?(\d\d)(?:T(\d\d)(?::?(\d\d)(?::?(\d\d)(?:\.(\d+))?)?)?(Z|([+-])(\d\d):?(\d\d))?)?$/; // 1 2 3 4 5 6 7 8 9 10 11 var NAMED_FORMATS = {}; var DATE_FORMATS_SPLIT = /((?:[^GyMLwWdEabBhHmsSzZO']+)|(?:'(?:[^']|'')*')|(?:G{1,5}|y{1,4}|M{1,5}|L{1,5}|w{1,2}|W{1}|d{1,2}|E{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]*)/; var ZoneWidth; (function (ZoneWidth) { ZoneWidth[ZoneWidth["Short"] = 0] = "Short"; ZoneWidth[ZoneWidth["ShortGMT"] = 1] = "ShortGMT"; ZoneWidth[ZoneWidth["Long"] = 2] = "Long"; ZoneWidth[ZoneWidth["Extended"] = 3] = "Extended"; })(ZoneWidth || (ZoneWidth = {})); var DateType; (function (DateType) { DateType[DateType["FullYear"] = 0] = "FullYear"; DateType[DateType["Month"] = 1] = "Month"; DateType[DateType["Date"] = 2] = "Date"; DateType[DateType["Hours"] = 3] = "Hours"; DateType[DateType["Minutes"] = 4] = "Minutes"; DateType[DateType["Seconds"] = 5] = "Seconds"; DateType[DateType["FractionalSeconds"] = 6] = "FractionalSeconds"; DateType[DateType["Day"] = 7] = "Day"; })(DateType || (DateType = {})); var TranslationType; (function (TranslationType) { TranslationType[TranslationType["DayPeriods"] = 0] = "DayPeriods"; TranslationType[TranslationType["Days"] = 1] = "Days"; TranslationType[TranslationType["Months"] = 2] = "Months"; TranslationType[TranslationType["Eras"] = 3] = "Eras"; })(TranslationType || (TranslationType = {})); /** * @ngModule CommonModule * @description * * Formats a date according to locale rules. * * Where: * - `value` is a Date, a number (milliseconds since UTC epoch) or an ISO string * (https://www.w3.org/TR/NOTE-datetime). * - `format` indicates which date/time components to include. See {@link DatePipe} for more * details. * - `locale` is a `string` defining the locale to use. * - `timezone` to be used for formatting. It understands UTC/GMT and the continental US time zone * abbreviations, but for general use, use a time zone offset (e.g. `'+0430'`). * If not specified, host system settings are used. * * See {@link DatePipe} for more details. * * @publicApi */ function formatDate(value, format, locale, timezone) { var date = toDate(value); var namedFormat = getNamedFormat(locale, format); format = namedFormat || format; var parts = []; var match; while (format) { match = DATE_FORMATS_SPLIT.exec(format); if (match) { parts = parts.concat(match.slice(1)); var part = parts.pop(); if (!part) { break; } format = part; } else { parts.push(format); break; } } var dateTimezoneOffset = date.getTimezoneOffset(); if (timezone) { dateTimezoneOffset = timezoneToOffset(timezone, dateTimezoneOffset); date = convertTimezoneToLocal(date, timezone, true); } var text = ''; parts.forEach(function (value) { var dateFormatter = getDateFormatter(value); text += dateFormatter ? dateFormatter(date, locale, dateTimezoneOffset) : value === '\'\'' ? '\'' : value.replace(/(^'|'$)/g, '').replace(/''/g, '\''); }); return text; } function getNamedFormat(locale, format) { var localeId = getLocaleId(locale); NAMED_FORMATS[localeId] = NAMED_FORMATS[localeId] || {}; if (NAMED_FORMATS[localeId][format]) { return NAMED_FORMATS[localeId][format]; } var formatValue = ''; switch (format) { case 'shortDate': formatValue = getLocaleDateFormat(locale, FormatWidth.Short); break; case 'mediumDate': formatValue = getLocaleDateFormat(locale, FormatWidth.Medium); break; case 'longDate': formatValue = getLocaleDateFormat(locale, FormatWidth.Long); break; case 'fullDate': formatValue = getLocaleDateFormat(locale, FormatWidth.Full); break; case 'shortTime': formatValue = getLocaleTimeFormat(locale, FormatWidth.Short); break; case 'mediumTime': formatValue = getLocaleTimeFormat(locale, FormatWidth.Medium); break; case 'longTime': formatValue = getLocaleTimeFormat(locale, FormatWidth.Long); break; case 'fullTime': formatValue = getLocaleTimeFormat(locale, FormatWidth.Full); break; case 'short': var shortTime = getNamedFormat(locale, 'shortTime'); var shortDate = getNamedFormat(locale, 'shortDate'); formatValue = formatDateTime(getLocaleDateTimeFormat(locale, FormatWidth.Short), [shortTime, shortDate]); break; case 'medium': var mediumTime = getNamedFormat(locale, 'mediumTime'); var mediumDate = getNamedFormat(locale, 'mediumDate'); formatValue = formatDateTime(getLocaleDateTimeFormat(locale, FormatWidth.Medium), [mediumTime, mediumDate]); break; case 'long': var longTime = getNamedFormat(locale, 'longTime'); var longDate = getNamedFormat(locale, 'longDate'); formatValue = formatDateTime(getLocaleDateTimeFormat(locale, FormatWidth.Long), [longTime, longDate]); break; case 'full': var fullTime = getNamedFormat(locale, 'fullTime'); var fullDate = getNamedFormat(locale, 'fullDate'); formatValue = formatDateTime(getLocaleDateTimeFormat(locale, FormatWidth.Full), [fullTime, fullDate]); break; } if (formatValue) { NAMED_FORMATS[localeId][format] = formatValue; } return formatValue; } function formatDateTime(str, opt_values) { if (opt_values) { str = str.replace(/\{([^}]+)}/g, function (match, key) { return (opt_values != null && key in opt_values) ? opt_values[key] : match; }); } return str; } function padNumber(num, digits, minusSign, trim, negWrap) { if (minusSign === void 0) { minusSign = '-'; } var neg = ''; if (num < 0 || (negWrap && num <= 0)) { if (negWrap) { num = -num + 1; } else { num = -num; neg = minusSign; } } var strNum = String(num); while (strNum.length < digits) { strNum = '0' + strNum; } if (trim) { strNum = strNum.substr(strNum.length - digits); } return neg + strNum; } function formatFractionalSeconds(milliseconds, digits) { var strMs = padNumber(milliseconds, 3); return strMs.substr(0, digits); } /** * Returns a date formatter that transforms a date into its locale digit representation */ function dateGetter(name, size, offset, trim, negWrap) { if (offset === void 0) { offset = 0; } if (trim === void 0) { trim = false; } if (negWrap === void 0) { negWrap = false; } return function (date, locale) { var part = getDatePart(name, date); if (offset > 0 || part > -offset) { part += offset; } if (name === DateType.Hours) { if (part === 0 && offset === -12) { part = 12; } } else if (name === DateType.FractionalSeconds) { return formatFractionalSeconds(part, size); } var localeMinus = getLocaleNumberSymbol(locale, NumberSymbol.MinusSign); return padNumber(part, size, localeMinus, trim, negWrap); }; } function getDatePart(part, date) { switch (part) { case DateType.FullYear: return date.getFullYear(); case DateType.Month: return date.getMonth(); case DateType.Date: return date.getDate(); case DateType.Hours: return date.getHours(); case DateType.Minutes: return date.getMinutes(); case DateType.Seconds: return date.getSeconds(); case DateType.FractionalSeconds: return date.getMilliseconds(); case DateType.Day: return date.getDay(); default: throw new Error("Unknown DateType value \"" + part + "\"."); } } /** * Returns a date formatter that transforms a date into its locale string representation */ function dateStrGetter(name, width, form, extended) { if (form === void 0) { form = FormStyle.Format; } if (extended === void 0) { extended = false; } return function (date, locale) { return getDateTranslation(date, locale, name, width, form, extended); }; } /** * Returns the locale translation of a date for a given form, type and width */ function getDateTranslation(date, locale, name, width, form, extended) { switch (name) { case TranslationType.Months: return getLocaleMonthNames(locale, form, width)[date.getMonth()]; case TranslationType.Days: return getLocaleDayNames(locale, form, width)[date.getDay()]; case TranslationType.DayPeriods: var currentHours_1 = date.getHours(); var currentMinutes_1 = date.getMinutes(); if (extended) { var rules = getLocaleExtraDayPeriodRules(locale); var dayPeriods_1 = getLocaleExtraDayPeriods(locale, form, width); var result_1; rules.forEach(function (rule, index) { if (Array.isArray(rule)) { // morning, afternoon, evening, night var _a = rule[0], hoursFrom = _a.hours, minutesFrom = _a.minutes; var _b = rule[1], hoursTo = _b.hours, minutesTo = _b.minutes; if (currentHours_1 >= hoursFrom && currentMinutes_1 >= minutesFrom && (currentHours_1 < hoursTo || (currentHours_1 === hoursTo && currentMinutes_1 < minutesTo))) { result_1 = dayPeriods_1[index]; } } else { // noon or midnight var hours = rule.hours, minutes = rule.minutes; if (hours === currentHours_1 && minutes === currentMinutes_1) { result_1 = dayPeriods_1[index]; } } }); if (result_1) { return result_1; } } // if no rules for the day periods, we use am/pm by default return getLocaleDayPeriods(locale, form, width)[currentHours_1 < 12 ? 0 : 1]; case TranslationType.Eras: return getLocaleEraNames(locale, width)[date.getFullYear() <= 0 ? 0 : 1]; default: // This default case is not needed by TypeScript compiler, as the switch is exhaustive. // However Closure Compiler does not understand that and reports an error in typed mode. // The `throw new Error` below works around the problem, and the unexpected: never variable // makes sure tsc still checks this code is unreachable. var unexpected = name; throw new Error("unexpected translation type " + unexpected); } } /** * Returns a date formatter that transforms a date and an offset into a timezone with ISO8601 or * GMT format depending on the width (eg: short = +0430, short:GMT = GMT+4, long = GMT+04:30, * extended = +04:30) */ function timeZoneGetter(width) { return function (date, locale, offset) { var zone = -1 * offset; var minusSign = getLocaleNumberSymbol(locale, NumberSymbol.MinusSign); var hours = zone > 0 ? Math.floor(zone / 60) : Math.ceil(zone / 60); switch (width) { case ZoneWidth.Short: return ((zone >= 0) ? '+' : '') + padNumber(hours, 2, minusSign) + padNumber(Math.abs(zone % 60), 2, minusSign); case ZoneWidth.ShortGMT: return 'GMT' + ((zone >= 0) ? '+' : '') + padNumber(hours, 1, minusSign); case ZoneWidth.Long: return 'GMT' + ((zone >= 0) ? '+' : '') + padNumber(hours, 2, minusSign) + ':' + padNumber(Math.abs(zone % 60), 2, minusSign); case ZoneWidth.Extended: if (offset === 0) { return 'Z'; } else { return ((zone >= 0) ? '+' : '') + padNumber(hours, 2, minusSign) + ':' + padNumber(Math.abs(zone % 60), 2, minusSign); } default: throw new Error("Unknown zone width \"" + width + "\""); } }; } var JANUARY = 0; var THURSDAY = 4; function getFirstThursdayOfYear(year) { var firstDayOfYear = (new Date(year, JANUARY, 1)).getDay(); return new Date(year, 0, 1 + ((firstDayOfYear <= THURSDAY) ? THURSDAY : THURSDAY + 7) - firstDayOfYear); } function getThursdayThisWeek(datetime) { return new Date(datetime.getFullYear(), datetime.getMonth(), datetime.getDate() + (THURSDAY - datetime.getDay())); } function weekGetter(size, monthBased) { if (monthBased === void 0) { monthBased = false; } return function (date, locale) { var result; if (monthBased) { var nbDaysBefore1stDayOfMonth = new Date(date.getFullYear(), date.getMonth(), 1).getDay() - 1; var today = date.getDate(); result = 1 + Math.floor((today + nbDaysBefore1stDayOfMonth) / 7); } else { var firstThurs = getFirstThursdayOfYear(date.getFullYear()); var thisThurs = getThursdayThisWeek(date); var diff = thisThurs.getTime() - firstThurs.getTime(); result = 1 + Math.round(diff / 6.048e8); // 6.048e8 ms per week } return padNumber(result, size, getLocaleNumberSymbol(locale, NumberSymbol.MinusSign)); }; } var DATE_FORMATS = {}; // Based on CLDR formats: // See complete list: http://www.unicode.org/reports/tr35/tr35-dates.html#Date_Field_Symbol_Table // See also explanations: http://cldr.unicode.org/translation/date-time // TODO(ocombe): support all missing cldr formats: Y, U, Q, D, F, e, c, j, J, C, A, v, V, X, x function getDateFormatter(format) { if (DATE_FORMATS[format]) { return DATE_FORMATS[format]; } var formatter; switch (format) { // Era name (AD/BC) case 'G': case 'GG': case 'GGG': formatter = dateStrGetter(TranslationType.Eras, TranslationWidth.Abbreviated); break; case 'GGGG': formatter = dateStrGetter(TranslationType.Eras, TranslationWidth.Wide); break; case 'GGGGG': formatter = dateStrGetter(TranslationType.Eras, TranslationWidth.Narrow); break; // 1 digit representation of the year, e.g. (AD 1 => 1, AD 199 => 199) case 'y': formatter = dateGetter(DateType.FullYear, 1, 0, false, true); break; // 2 digit representation of the year, padded (00-99). (e.g. AD 2001 => 01, AD 2010 => 10) case 'yy': formatter = dateGetter(DateType.FullYear, 2, 0, true, true); break; // 3 digit representation of the year, padded (000-999). (e.g. AD 2001 => 01, AD 2010 => 10) case 'yyy': formatter = dateGetter(DateType.FullYear, 3, 0, false, true); break; // 4 digit representation of the year (e.g. AD 1 => 0001, AD 2010 => 2010) case 'yyyy': formatter = dateGetter(DateType.FullYear, 4, 0, false, true); break; // Month of the year (1-12), numeric case 'M': case 'L': formatter = dateGetter(DateType.Month, 1, 1); break; case 'MM': case 'LL': formatter = dateGetter(DateType.Month, 2, 1); break; // Month of the year (January, ...), string, format case 'MMM': formatter = dateStrGetter(TranslationType.Months, TranslationWidth.Abbreviated); break; case 'MMMM': formatter = dateStrGetter(TranslationType.Months, TranslationWidth.Wide); break; case 'MMMMM': formatter = dateStrGetter(TranslationType.Months, TranslationWidth.Narrow); break; // Month of the year (January, ...), string, standalone case 'LLL': formatter = dateStrGetter(TranslationType.Months, TranslationWidth.Abbreviated, FormStyle.Standalone); break; case 'LLLL': formatter = dateStrGetter(TranslationType.Months, TranslationWidth.Wide, FormStyle.Standalone); break; case 'LLLLL': formatter = dateStrGetter(TranslationType.Months, TranslationWidth.Narrow, FormStyle.Standalone); break; // Week of the year (1, ... 52) case 'w': formatter = weekGetter(1); break; case 'ww': formatter = weekGetter(2); break; // Week of the month (1, ...) case 'W': formatter = weekGetter(1, true); break; // Day of the month (1-31) case 'd': formatter = dateGetter(DateType.Date, 1); break; case 'dd': formatter = dateGetter(DateType.Date, 2); break; // Day of the Week case 'E': case 'EE': case 'EEE': formatter = dateStrGetter(TranslationType.Days, TranslationWidth.Abbreviated); break; case 'EEEE': formatter = dateStrGetter(TranslationType.Days, TranslationWidth.Wide); break; case 'EEEEE': formatter = dateStrGetter(TranslationType.Days, TranslationWidth.Narrow); break; case 'EEEEEE': formatter = dateStrGetter(TranslationType.Days, TranslationWidth.Short); break; // Generic period of the day (am-pm) case 'a': case 'aa': case 'aaa': formatter = dateStrGetter(TranslationType.DayPeriods, TranslationWidth.Abbreviated); break; case 'aaaa': formatter = dateStrGetter(TranslationType.DayPeriods, TranslationWidth.Wide); break; case 'aaaaa': formatter = dateStrGetter(TranslationType.DayPeriods, TranslationWidth.Narrow); break; // Extended period of the day (midnight, at night, ...), standalone case 'b': case 'bb': case 'bbb': formatter = dateStrGetter(TranslationType.DayPeriods, TranslationWidth.Abbreviated, FormStyle.Standalone, true); break; case 'bbbb': formatter = dateStrGetter(TranslationType.DayPeriods, TranslationWidth.Wide, FormStyle.Standalone, true); break; case 'bbbbb': formatter = dateStrGetter(TranslationType.DayPeriods, TranslationWidth.Narrow, FormStyle.Standalone, true); break; // Extended period of the day (midnight, night, ...), standalone case 'B': case 'BB': case 'BBB': formatter = dateStrGetter(TranslationType.DayPeriods, TranslationWidth.Abbreviated, FormStyle.Format, true); break; case 'BBBB': formatter = dateStrGetter(TranslationType.DayPeriods, TranslationWidth.Wide, FormStyle.Format, true); break; case 'BBBBB': formatter = dateStrGetter(TranslationType.DayPeriods, TranslationWidth.Narrow, FormStyle.Format, true); break; // Hour in AM/PM, (1-12) case 'h': formatter = dateGetter(DateType.Hours, 1, -12); break; case 'hh': formatter = dateGetter(DateType.Hours, 2, -12); break; // Hour of the day (0-23) case 'H': formatter = dateGetter(DateType.Hours, 1); break; // Hour in day, padded (00-23) case 'HH': formatter = dateGetter(DateType.Hours, 2); break; // Minute of the hour (0-59) case 'm': formatter = dateGetter(DateType.Minutes, 1); break; case 'mm': formatter = dateGetter(DateType.Minutes, 2); break; // Second of the minute (0-59) case 's': formatter = dateGetter(DateType.Seconds, 1); break; case 'ss': formatter = dateGetter(DateType.Seconds, 2); break; // Fractional second case 'S': formatter = dateGetter(DateType.FractionalSeconds, 1); break; case 'SS': formatter = dateGetter(DateType.FractionalSeconds, 2); break; case 'SSS': formatter = dateGetter(DateType.FractionalSeconds, 3); break; // Timezone ISO8601 short format (-0430) case 'Z': case 'ZZ': case 'ZZZ': formatter = timeZoneGetter(ZoneWidth.Short); break; // Timezone ISO8601 extended format (-04:30) case 'ZZZZZ': formatter = timeZoneGetter(ZoneWidth.Extended); break; // Timezone GMT short format (GMT+4) case 'O': case 'OO': case 'OOO': // Should be location, but fallback to format O instead because we don't have the data yet case 'z': case 'zz': case 'zzz': formatter = timeZoneGetter(ZoneWidth.ShortGMT); break; // Timezone GMT long format (GMT+0430) case 'OOOO': case 'ZZZZ': // Should be location, but fallback to format O instead because we don't have the data yet case 'zzzz': formatter = timeZoneGetter(ZoneWidth.Long); break; default: return null; } DATE_FORMATS[format] = formatter; return formatter; } function timezoneToOffset(timezone, fallback) { // Support: IE 9-11 only, Edge 13-15+ // IE/Edge do not "understand" colon (`:`) in timezone timezone = timezone.replace(/:/g, ''); var requestedTimezoneOffset = Date.parse('Jan 01, 1970 00:00:00 ' + timezone) / 60000; return isNaN(requestedTimezoneOffset) ? fallback : requestedTimezoneOffset; } function addDateMinutes(date, minutes) { date = new Date(date.getTime()); date.setMinutes(date.getMinutes() + minutes); return date; } function convertTimezoneToLocal(date, timezone, reverse) { var reverseValue = reverse ? -1 : 1; var dateTimezoneOffset = date.getTimezoneOffset(); var timezoneOffset = timezoneToOffset(timezone, dateTimezoneOffset); return addDateMinutes(date, reverseValue * (timezoneOffset - dateTimezoneOffset)); } /** * Converts a value to date. * * Supported input formats: * - `Date` * - number: timestamp * - string: numeric (e.g. "1234"), ISO and date strings in a format supported by * [Date.parse()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/parse). * Note: ISO strings without time return a date without timeoffset. * * Throws if unable to convert to a date. */ function toDate(value) { if (isDate(value)) { return value; } if (typeof value === 'number' && !isNaN(value)) { return new Date(value); } if (typeof value === 'string') { value = value.trim(); var parsedNb = parseFloat(value); // any string that only contains numbers, like "1234" but not like "1234hello" if (!isNaN(value - parsedNb)) { return new Date(parsedNb); } if (/^(\d{4}-\d{1,2}-\d{1,2})$/.test(value)) { /* For ISO Strings without time the day, month and year must be extracted from the ISO String before Date creation to avoid time offset and errors in the new Date. If we only replace '-' with ',' in the ISO String ("2015,01,01"), and try to create a new date, some browsers (e.g. IE 9) will throw an invalid Date error. If we leave the '-' ("2015-01-01") and try to create a new Date("2015-01-01") the timeoffset is applied. Note: ISO months are 0 for January, 1 for February, ... */ var _a = Object(tslib__WEBPACK_IMPORTED_MODULE_1__["__read"])(value.split('-').map(function (val) { return +val; }), 3), y = _a[0], m = _a[1], d = _a[2]; return new Date(y, m - 1, d); } var match = void 0; if (match = value.match(ISO8601_DATE_REGEX)) { return isoStringToDate(match); } } var date = new Date(value); if (!isDate(date)) { throw new Error("Unable to convert \"" + value + "\" into a date"); } return date; } /** * Converts a date in ISO8601 to a Date. * Used instead of `Date.parse` because of browser discrepancies. */ function isoStringToDate(match) { var date = new Date(0); var tzHour = 0; var tzMin = 0; // match[8] means that the string contains "Z" (UTC) or a timezone like "+01:00" or "+0100" var dateSetter = match[8] ? date.setUTCFullYear : date.setFullYear; var timeSetter = match[8] ? date.setUTCHours : date.setHours; // if there is a timezone defined like "+01:00" or "+0100" if (match[9]) { tzHour = Number(match[9] + match[10]); tzMin = Number(match[9] + match[11]); } dateSetter.call(date, Number(match[1]), Number(match[2]) - 1, Number(match[3])); var h = Number(match[4] || 0) - tzHour; var m = Number(match[5] || 0) - tzMin; var s = Number(match[6] || 0); var ms = Math.round(parseFloat('0.' + (match[7] || 0)) * 1000); timeSetter.call(date, h, m, s, ms); return date; } function isDate(value) { return value instanceof Date && !isNaN(value.valueOf()); } /** * @license * Copyright Google Inc. All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ var NUMBER_FORMAT_REGEXP = /^(\d+)?\.((\d+)(-(\d+))?)?$/; var MAX_DIGITS = 22; var DECIMAL_SEP = '.'; var ZERO_CHAR = '0'; var PATTERN_SEP = ';'; var GROUP_SEP = ','; var DIGIT_CHAR = '#'; var CURRENCY_CHAR = '¤'; var PERCENT_CHAR = '%'; /** * Transforms a number to a locale string based on a style and a format */ function formatNumberToLocaleString(value, pattern, locale, groupSymbol, decimalSymbol, digitsInfo, isPercent) { if (isPercent === void 0) { isPercent = false; } var formattedText = ''; var isZero = false; if (!isFinite(value)) { formattedText = getLocaleNumberSymbol(locale, NumberSymbol.Infinity); } else { var parsedNumber = parseNumber(value); if (isPercent) { parsedNumber = toPercent(parsedNumber); } var minInt = pattern.minInt; var minFraction = pattern.minFrac; var maxFraction = pattern.maxFrac; if (digitsInfo) { var parts = digitsInfo.match(NUMBER_FORMAT_REGEXP); if (parts === null) { throw new Error(digitsInfo + " is not a valid digit info"); } var minIntPart = parts[1]; var minFractionPart = parts[3]; var maxFractionPart = parts[5]; if (minIntPart != null) { minInt = parseIntAutoRadix(minIntPart); } if (minFractionPart != null) { minFraction = parseIntAutoRadix(minFractionPart); } if (maxFractionPart != null) { maxFraction = parseIntAutoRadix(maxFractionPart); } else if (minFractionPart != null && minFraction > maxFraction) { maxFraction = minFraction; } } roundNumber(parsedNumber, minFraction, maxFraction); var digits = parsedNumber.digits; var integerLen = parsedNumber.integerLen; var exponent = parsedNumber.exponent; var decimals = []; isZero = digits.every(function (d) { return !d; }); // pad zeros for small numbers for (; integerLen < minInt; integerLen++) { digits.unshift(0); } // pad zeros for small numbers for (; integerLen < 0; integerLen++) { digits.unshift(0); } // extract decimals digits if (integerLen > 0) { decimals = digits.splice(integerLen, digits.length); } else { decimals = digits; digits = [0]; } // format the integer digits with grouping separators var groups = []; if (digits.length >= pattern.lgSize) { groups.unshift(digits.splice(-pattern.lgSize, digits.length).join('')); } while (digits.length > pattern.gSize) { groups.unshift(digits.splice(-pattern.gSize, digits.length).join('')); } if (digits.length) { groups.unshift(digits.join('')); } formattedText = groups.join(getLocaleNumberSymbol(locale, groupSymbol)); // append the decimal digits if (decimals.length) { formattedText += getLocaleNumberSymbol(locale, decimalSymbol) + decimals.join(''); } if (exponent) { formattedText += getLocaleNumberSymbol(locale, NumberSymbol.Exponential) + '+' + exponent; } } if (value < 0 && !isZero) { formattedText = pattern.negPre + formattedText + pattern.negSuf; } else { formattedText = pattern.posPre + formattedText + pattern.posSuf; } return formattedText; } /** * @ngModule CommonModule * @description * * Formats a number as currency using locale rules. * * Use `currency` to format a number as currency. * * Where: * - `value` is a number. * - `locale` is a `string` defining the locale to use. * - `currency` is the string that represents the currency, it can be its symbol or its name. * - `currencyCode` is the [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) currency code, such * as `USD` for the US dollar and `EUR` for the euro. * - `digitInfo` See {@link DecimalPipe} for more details. * * @publicApi */ function formatCurrency(value, locale, currency, currencyCode, digitsInfo) { var format = getLocaleNumberFormat(locale, NumberFormatStyle.Currency); var pattern = parseNumberFormat(format, getLocaleNumberSymbol(locale, NumberSymbol.MinusSign)); pattern.minFrac = getNumberOfCurrencyDigits(currencyCode); pattern.maxFrac = pattern.minFrac; var res = formatNumberToLocaleString(value, pattern, locale, NumberSymbol.CurrencyGroup, NumberSymbol.CurrencyDecimal, digitsInfo); return res .replace(CURRENCY_CHAR, currency) // if we have 2 time the currency character, the second one is ignored .replace(CURRENCY_CHAR, ''); } /** * @ngModule CommonModule * @description * * Formats a number as a percentage according to locale rules. * * Where: * - `value` is a number. * - `locale` is a `string` defining the locale to use. * - `digitInfo` See {@link DecimalPipe} for more details. * * @publicApi */ function formatPercent(value, locale, digitsInfo) { var format = getLocaleNumberFormat(locale, NumberFormatStyle.Percent); var pattern = parseNumberFormat(format, getLocaleNumberSymbol(locale, NumberSymbol.MinusSign)); var res = formatNumberToLocaleString(value, pattern, locale, NumberSymbol.Group, NumberSymbol.Decimal, digitsInfo, true); return res.replace(new RegExp(PERCENT_CHAR, 'g'), getLocaleNumberSymbol(locale, NumberSymbol.PercentSign)); } /** * @ngModule CommonModule * @description * * Formats a number as text. Group sizing and separator and other locale-specific * configurations are based on the locale. * * Where: * - `value` is a number. * - `locale` is a `string` defining the locale to use. * - `digitInfo` See {@link DecimalPipe} for more details. * * @publicApi */ function formatNumber(value, locale, digitsInfo) { var format = getLocaleNumberFormat(locale, NumberFormatStyle.Decimal); var pattern = parseNumberFormat(format, getLocaleNumberSymbol(locale, NumberSymbol.MinusSign)); return formatNumberToLocaleString(value, pattern, locale, NumberSymbol.Group, NumberSymbol.Decimal, digitsInfo); } function parseNumberFormat(format, minusSign) { if (minusSign === void 0) { minusSign = '-'; } var p = { minInt: 1, minFrac: 0, maxFrac: 0, posPre: '', posSuf: '', negPre: '', negSuf: '', gSize: 0, lgSize: 0 }; var patternParts = format.split(PATTERN_SEP); var positive = patternParts[0]; var negative = patternParts[1]; var positiveParts = positive.indexOf(DECIMAL_SEP) !== -1 ? positive.split(DECIMAL_SEP) : [ positive.substring(0, positive.lastIndexOf(ZERO_CHAR) + 1), positive.substring(positive.lastIndexOf(ZERO_CHAR) + 1) ], integer = positiveParts[0], fraction = positiveParts[1] || ''; p.posPre = integer.substr(0, integer.indexOf(DIGIT_CHAR)); for (var i = 0; i < fraction.length; i++) { var ch = fraction.charAt(i); if (ch === ZERO_CHAR) { p.minFrac = p.maxFrac = i + 1; } else if (ch === DIGIT_CHAR) { p.maxFrac = i + 1; } else { p.posSuf += ch; } } var groups = integer.split(GROUP_SEP); p.gSize = groups[1] ? groups[1].length : 0; p.lgSize = (groups[2] || groups[1]) ? (groups[2] || groups[1]).length : 0; if (negative) { var trunkLen = positive.length - p.posPre.length - p.posSuf.length, pos = negative.indexOf(DIGIT_CHAR); p.negPre = negative.substr(0, pos).replace(/'/g, ''); p.negSuf = negative.substr(pos + trunkLen).replace(/'/g, ''); } else { p.negPre = minusSign + p.posPre; p.negSuf = p.posSuf; } return p; } // Transforms a parsed number into a percentage by multiplying it by 100 function toPercent(parsedNumber) { // if the number is 0, don't do anything if (parsedNumber.digits[0] === 0) { return parsedNumber; } // Getting the current number of decimals var fractionLen = parsedNumber.digits.length - parsedNumber.integerLen; if (parsedNumber.exponent) { parsedNumber.exponent += 2; } else { if (fractionLen === 0) { parsedNumber.digits.push(0, 0); } else if (fractionLen === 1) { parsedNumber.digits.push(0); } parsedNumber.integerLen += 2; } return parsedNumber; } /** * Parses a number. * Significant bits of this parse algorithm came from https://github.com/MikeMcl/big.js/ */ function parseNumber(num) { var numStr = Math.abs(num) + ''; var exponent = 0, digits, integerLen; var i, j, zeros; // Decimal point? if ((integerLen = numStr.indexOf(DECIMAL_SEP)) > -1) { numStr = numStr.replace(DECIMAL_SEP, ''); } // Exponential form? if ((i = numStr.search(/e/i)) > 0) { // Work out the exponent. if (integerLen < 0) integerLen = i; integerLen += +numStr.slice(i + 1); numStr = numStr.substring(0, i); } else if (integerLen < 0) { // There was no decimal point or exponent so it is an integer. integerLen = numStr.length; } // Count the number of leading zeros. for (i = 0; numStr.charAt(i) === ZERO_CHAR; i++) { /* empty */ } if (i === (zeros = numStr.length)) { // The digits are all zero. digits = [0]; integerLen = 1; } else { // Count the number of trailing zeros zeros--; while (numStr.charAt(zeros) === ZERO_CHAR) zeros--; // Trailing zeros are insignificant so ignore them integerLen -= i; digits = []; // Convert string to array of digits without leading/trailing zeros. for (j = 0; i <= zeros; i++, j++) { digits[j] = Number(numStr.charAt(i)); } } // If the number overflows the maximum allowed digits then use an exponent. if (integerLen > MAX_DIGITS) { digits = digits.splice(0, MAX_DIGITS - 1); exponent = integerLen - 1; integerLen = 1; } return { digits: digits, exponent: exponent, integerLen: integerLen }; } /** * Round the parsed number to the specified number of decimal places * This function changes the parsedNumber in-place */ function roundNumber(parsedNumber, minFrac, maxFrac) { if (minFrac > maxFrac) { throw new Error("The minimum number of digits after fraction (" + minFrac + ") is higher than the maximum (" + maxFrac + ")."); } var digits = parsedNumber.digits; var fractionLen = digits.length - parsedNumber.integerLen; var fractionSize = Math.min(Math.max(minFrac, fractionLen), maxFrac); // The index of the digit to where rounding is to occur var roundAt = fractionSize + parsedNumber.integerLen; var digit = digits[roundAt]; if (roundAt > 0) { // Drop fractional digits beyond `roundAt` digits.splice(Math.max(parsedNumber.integerLen, roundAt)); // Set non-fractional digits beyond `roundAt` to 0 for (var j = roundAt; j < digits.length; j++) { digits[j] = 0; } } else { // We rounded to zero so reset the parsedNumber fractionLen = Math.max(0, fractionLen); parsedNumber.integerLen = 1; digits.length = Math.max(1, roundAt = fractionSize + 1); digits[0] = 0; for (var i = 1; i < roundAt; i++) digits[i] = 0; } if (digit >= 5) { if (roundAt - 1 < 0) { for (var k = 0; k > roundAt; k--) { digits.unshift(0); parsedNumber.integerLen++; } digits.unshift(1); parsedNumber.integerLen++; } else { digits[roundAt - 1]++; } } // Pad out with zeros to get the required fraction length for (; fractionLen < Math.max(0, fractionSize); fractionLen++) digits.push(0); var dropTrailingZeros = fractionSize !== 0; // Minimal length = nb of decimals required + current nb of integers // Any number besides that is optional and can be removed if it's a trailing 0 var minLen = minFrac + parsedNumber.integerLen; // Do any carrying, e.g. a digit was rounded up to 10 var carry = digits.reduceRight(function (carry, d, i, digits) { d = d + carry; digits[i] = d < 10 ? d : d - 10; // d % 10 if (dropTrailingZeros) { // Do not keep meaningless fractional trailing zeros (e.g. 15.52000 --> 15.52) if (digits[i] === 0 && i >= minLen) { digits.pop(); } else { dropTrailingZeros = false; } } return d >= 10 ? 1 : 0; // Math.floor(d / 10); }, 0); if (carry) { digits.unshift(carry); parsedNumber.integerLen++; } } function parseIntAutoRadix(text) { var result = parseInt(text); if (isNaN(result)) { throw new Error('Invalid integer literal when parsing ' + text); } return result; } /** * @license * Copyright Google Inc. All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ /** * @deprecated from v5 */ var DEPRECATED_PLURAL_FN = new _angular_core__WEBPACK_IMPORTED_MODULE_0__["InjectionToken"]('UseV4Plurals'); /** * @publicApi */ var NgLocalization = /** @class */ (function () { function NgLocalization() { } return NgLocalization; }()); /** * Returns the plural category for a given value. * - "=value" when the case exists, * - the plural category otherwise */ function getPluralCategory(value, cases, ngLocalization, locale) { var key = "=" + value; if (cases.indexOf(key) > -1) { return key; } key = ngLocalization.getPluralCategory(value, locale); if (cases.indexOf(key) > -1) { return key; } if (cases.indexOf('other') > -1) { return 'other'; } throw new Error("No plural message found for value \"" + value + "\""); } /** * Returns the plural case based on the locale * * @publicApi */ var NgLocaleLocalization = /** @class */ (function (_super) { Object(tslib__WEBPACK_IMPORTED_MODULE_1__["__extends"])(NgLocaleLocalization, _super); function NgLocaleLocalization(locale, /** @deprecated from v5 */ deprecatedPluralFn) { var _this = _super.call(this) || this; _this.locale = locale; _this.deprecatedPluralFn = deprecatedPluralFn; return _this; } NgLocaleLocalization.prototype.getPluralCategory = function (value, locale) { var plural = this.deprecatedPluralFn ? this.deprecatedPluralFn(locale || this.locale, value) : getLocalePluralCase(locale || this.locale)(value); switch (plural) { case Plural.Zero: return 'zero'; case Plural.One: return 'one'; case Plural.Two: return 'two'; case Plural.Few: return 'few'; case Plural.Many: return 'many'; default: return 'other'; } }; NgLocaleLocalization = Object(tslib__WEBPACK_IMPORTED_MODULE_1__["__decorate"])([ Object(_angular_core__WEBPACK_IMPORTED_MODULE_0__["Injectable"])(), Object(tslib__WEBPACK_IMPORTED_MODULE_1__["__param"])(0, Object(_angular_core__WEBPACK_IMPORTED_MODULE_0__["Inject"])(_angular_core__WEBPACK_IMPORTED_MODULE_0__["LOCALE_ID"])), Object(tslib__WEBPACK_IMPORTED_MODULE_1__["__param"])(1, Object(_angular_core__WEBPACK_IMPORTED_MODULE_0__["Optional"])()), Object(tslib__WEBPACK_IMPORTED_MODULE_1__["__param"])(1, Object(_angular_core__WEBPACK_IMPORTED_MODULE_0__["Inject"])(DEPRECATED_PLURAL_FN)), Object(tslib__WEBPACK_IMPORTED_MODULE_1__["__metadata"])("design:paramtypes", [String, Object]) ], NgLocaleLocalization); return NgLocaleLocalization; }(NgLocalization)); /** * Returns the plural case based on the locale * * @deprecated from v5 the plural case function is in locale data files common/locales/*.ts * @publicApi */ function getPluralCase(locale, nLike) { // TODO(vicb): lazy compute if (typeof nLike === 'string') { nLike = parseInt(nLike, 10); } var n = nLike; var nDecimal = n.toString().replace(/^[^.]*\.?/, ''); var i = Math.floor(Math.abs(n)); var v = nDecimal.length; var f = parseInt(nDecimal, 10); var t = parseInt(n.toString().replace(/^[^.]*\.?|0+$/g, ''), 10) || 0; var lang = locale.split('-')[0].toLowerCase(); switch (lang) { case 'af': case 'asa': case 'az': case 'bem': case 'bez': case 'bg': case 'brx': case 'ce': case 'cgg': case 'chr': case 'ckb': case 'ee': case 'el': case 'eo': case 'es': case 'eu': case 'fo': case 'fur': case 'gsw': case 'ha': case 'haw': case 'hu': case 'jgo': case 'jmc': case 'ka': case 'kk': case 'kkj': case 'kl': case 'ks': case 'ksb': case 'ky': case 'lb': case 'lg': case 'mas': case 'mgo': case 'ml': case 'mn': case 'nb': case 'nd': case 'ne': case 'nn': case 'nnh': case 'nyn': case 'om': case 'or': case 'os': case 'ps': case 'rm': case 'rof': case 'rwk': case 'saq': case 'seh': case 'sn': case 'so': case 'sq': case 'ta': case 'te': case 'teo': case 'tk': case 'tr': case 'ug': case 'uz': case 'vo': case 'vun': case 'wae': case 'xog': if (n === 1) return Plural.One; return Plural.Other; case 'ak': case 'ln': case 'mg': case 'pa': case 'ti': if (n === Math.floor(n) && n >= 0 && n <= 1) return Plural.One; return Plural.Other; case 'am': case 'as': case 'bn': case 'fa': case 'gu': case 'hi': case 'kn': case 'mr': case 'zu': if (i === 0 || n === 1) return Plural.One; return Plural.Other; case 'ar': if (n === 0) return Plural.Zero; if (n === 1) return Plural.One; if (n === 2) return Plural.Two; if (n % 100 === Math.floor(n % 100) && n % 100 >= 3 && n % 100 <= 10) return Plural.Few; if (n % 100 === Math.floor(n % 100) && n % 100 >= 11 && n % 100 <= 99) return Plural.Many; return Plural.Other; case 'ast': case 'ca': case 'de': case 'en': case 'et': case 'fi': case 'fy': case 'gl': case 'it': case 'nl': case 'sv': case 'sw': case 'ur': case 'yi': if (i === 1 && v === 0) return Plural.One; return Plural.Other; case 'be': if (n % 10 === 1 && !(n % 100 === 11)) return Plural.One; if (n % 10 === Math.floor(n % 10) && n % 10 >= 2 && n % 10 <= 4 && !(n % 100 >= 12 && n % 100 <= 14)) return Plural.Few; if (n % 10 === 0 || n % 10 === Math.floor(n % 10) && n % 10 >= 5 && n % 10 <= 9 || n % 100 === Math.floor(n % 100) && n % 100 >= 11 && n % 100 <= 14) return Plural.Many; return Plural.Other; case 'br': if (n % 10 === 1 && !(n % 100 === 11 || n % 100 === 71 || n % 100 === 91)) return Plural.One; if (n % 10 === 2 && !(n % 100 === 12 || n % 100 === 72 || n % 100 === 92)) return Plural.Two; if (n % 10 === Math.floor(n % 10) && (n % 10 >= 3 && n % 10 <= 4 || n % 10 === 9) && !(n % 100 >= 10 && n % 100 <= 19 || n % 100 >= 70 && n % 100 <= 79 || n % 100 >= 90 && n % 100 <= 99)) return Plural.Few; if (!(n === 0) && n % 1e6 === 0) return Plural.Many; return Plural.Other; case 'bs': case 'hr': case 'sr': if (v === 0 && i % 10 === 1 && !(i % 100 === 11) || f % 10 === 1 && !(f % 100 === 11)) return Plural.One; if (v === 0 && i % 10 === Math.floor(i % 10) && i % 10 >= 2 && i % 10 <= 4 && !(i % 100 >= 12 && i % 100 <= 14) || f % 10 === Math.floor(f % 10) && f % 10 >= 2 && f % 10 <= 4 && !(f % 100 >= 12 && f % 100 <= 14)) return Plural.Few; return Plural.Other; case 'cs': case 'sk': if (i === 1 && v === 0) return Plural.One; if (i === Math.floor(i) && i >= 2 && i <= 4 && v === 0) return Plural.Few; if (!(v === 0)) return Plural.Many; return Plural.Other; case 'cy': if (n === 0) return Plural.Zero; if (n === 1) return Plural.One; if (n === 2) return Plural.Two; if (n === 3) return Plural.Few; if (n === 6) return Plural.Many; return Plural.Other; case 'da': if (n === 1 || !(t === 0) && (i === 0 || i === 1)) return Plural.One; return Plural.Other; case 'dsb': case 'hsb': if (v === 0 && i % 100 === 1 || f % 100 === 1) return Plural.One; if (v === 0 && i % 100 === 2 || f % 100 === 2) return Plural.Two; if (v === 0 && i % 100 === Math.floor(i % 100) && i % 100 >= 3 && i % 100 <= 4 || f % 100 === Math.floor(f % 100) && f % 100 >= 3 && f % 100 <= 4) return Plural.Few; return Plural.Other; case 'ff': case 'fr': case 'hy': case 'kab': if (i === 0 || i === 1) return Plural.One; return Plural.Other; case 'fil': if (v === 0 && (i === 1 || i === 2 || i === 3) || v === 0 && !(i % 10 === 4 || i % 10 === 6 || i % 10 === 9) || !(v === 0) && !(f % 10 === 4 || f % 10 === 6 || f % 10 === 9)) return Plural.One; return Plural.Other; case 'ga': if (n === 1) return Plural.One; if (n === 2) return Plural.Two; if (n === Math.floor(n) && n >= 3 && n <= 6) return Plural.Few; if (n === Math.floor(n) && n >= 7 && n <= 10) return Plural.Many; return Plural.Other; case 'gd': if (n === 1 || n === 11) return Plural.One; if (n === 2 || n === 12) return Plural.Two; if (n === Math.floor(n) && (n >= 3 && n <= 10 || n >= 13 && n <= 19)) return Plural.Few; return Plural.Other; case 'gv': if (v === 0 && i % 10 === 1) return Plural.One; if (v === 0 && i % 10 === 2) return Plural.Two; if (v === 0 && (i % 100 === 0 || i % 100 === 20 || i % 100 === 40 || i % 100 === 60 || i % 100 === 80)) return Plural.Few; if (!(v === 0)) return Plural.Many; return Plural.Other; case 'he': if (i === 1 && v === 0) return Plural.One; if (i === 2 && v === 0) return Plural.Two; if (v === 0 && !(n >= 0 && n <= 10) && n % 10 === 0) return Plural.Many; return Plural.Other; case 'is': if (t === 0 && i % 10 === 1 && !(i % 100 === 11) || !(t === 0)) return Plural.One; return Plural.Other; case 'ksh': if (n === 0) return Plural.Zero; if (n === 1) return Plural.One; return Plural.Other; case 'kw': case 'naq': case 'se': case 'smn': if (n === 1) return Plural.One; if (n === 2) return Plural.Two; return Plural.Other; case 'lag': if (n === 0) return Plural.Zero; if ((i === 0 || i === 1) && !(n === 0)) return Plural.One; return Plural.Other; case 'lt': if (n % 10 === 1 && !(n % 100 >= 11 && n % 100 <= 19)) return Plural.One; if (n % 10 === Math.floor(n % 10) && n % 10 >= 2 && n % 10 <= 9 && !(n % 100 >= 11 && n % 100 <= 19)) return Plural.Few; if (!(f === 0)) return Plural.Many; return Plural.Other; case 'lv': case 'prg': if (n % 10 === 0 || n % 100 === Math.floor(n % 100) && n % 100 >= 11 && n % 100 <= 19 || v === 2 && f % 100 === Math.floor(f % 100) && f % 100 >= 11 && f % 100 <= 19) return Plural.Zero; if (n % 10 === 1 && !(n % 100 === 11) || v === 2 && f % 10 === 1 && !(f % 100 === 11) || !(v === 2) && f % 10 === 1) return Plural.One; return Plural.Other; case 'mk': if (v === 0 && i % 10 === 1 || f % 10 === 1) return Plural.One; return Plural.Other; case 'mt': if (n === 1) return Plural.One; if (n === 0 || n % 100 === Math.floor(n % 100) && n % 100 >= 2 && n % 100 <= 10) return Plural.Few; if (n % 100 === Math.floor(n % 100) && n % 100 >= 11 && n % 100 <= 19) return Plural.Many; return Plural.Other; case 'pl': if (i === 1 && v === 0) return Plural.One; if (v === 0 && i % 10 === Math.floor(i % 10) && i % 10 >= 2 && i % 10 <= 4 && !(i % 100 >= 12 && i % 100 <= 14)) return Plural.Few; if (v === 0 && !(i === 1) && i % 10 === Math.floor(i % 10) && i % 10 >= 0 && i % 10 <= 1 || v === 0 && i % 10 === Math.floor(i % 10) && i % 10 >= 5 && i % 10 <= 9 || v === 0 && i % 100 === Math.floor(i % 100) && i % 100 >= 12 && i % 100 <= 14) return Plural.Many; return Plural.Other; case 'pt': if (n === Math.floor(n) && n >= 0 && n <= 2 && !(n === 2)) return Plural.One; return Plural.Other; case 'ro': if (i === 1 && v === 0) return Plural.One; if (!(v === 0) || n === 0 || !(n === 1) && n % 100 === Math.floor(n % 100) && n % 100 >= 1 && n % 100 <= 19) return Plural.Few; return Plural.Other; case 'ru': case 'uk': if (v === 0 && i % 10 === 1 && !(i % 100 === 11)) return Plural.One; if (v === 0 && i % 10 === Math.floor(i % 10) && i % 10 >= 2 && i % 10 <= 4 && !(i % 100 >= 12 && i % 100 <= 14)) return Plural.Few; if (v === 0 && i % 10 === 0 || v === 0 && i % 10 === Math.floor(i % 10) && i % 10 >= 5 && i % 10 <= 9 || v === 0 && i % 100 === Math.floor(i % 100) && i % 100 >= 11 && i % 100 <= 14) return Plural.Many; return Plural.Other; case 'shi': if (i === 0 || n === 1) return Plural.One; if (n === Math.floor(n) && n >= 2 && n <= 10) return Plural.Few; return Plural.Other; case 'si': if (n === 0 || n === 1 || i === 0 && f === 1) return Plural.One; return Plural.Other; case 'sl': if (v === 0 && i % 100 === 1) return Plural.One; if (v === 0 && i % 100 === 2) return Plural.Two; if (v === 0 && i % 100 === Math.floor(i % 100) && i % 100 >= 3 && i % 100 <= 4 || !(v === 0)) return Plural.Few; return Plural.Other; case 'tzm': if (n === Math.floor(n) && n >= 0 && n <= 1 || n === Math.floor(n) && n >= 11 && n <= 99) return Plural.One; return Plural.Other; // When there is no specification, the default is always "other" // Spec: http://cldr.unicode.org/index/cldr-spec/plural-rules // > other (required—general plural form — also used if the language only has a single form) default: return Plural.Other; } } /** * @license * Copyright Google Inc. All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ function parseCookieValue(cookieStr, name) { var e_1, _a; name = encodeURIComponent(name); try { for (var _b = Object(tslib__WEBPACK_IMPORTED_MODULE_1__["__values"])(cookieStr.split(';')), _c = _b.next(); !_c.done; _c = _b.next()) { var cookie = _c.value; var eqIndex = cookie.indexOf('='); var _d = Object(tslib__WEBPACK_IMPORTED_MODULE_1__["__read"])(eqIndex == -1 ? [cookie, ''] : [cookie.slice(0, eqIndex), cookie.slice(eqIndex + 1)], 2), cookieName = _d[0], cookieValue = _d[1]; if (cookieName.trim() === name) { return decodeURIComponent(cookieValue); } } } catch (e_1_1) { e_1 = { error: e_1_1 }; } finally { try { if (_c && !_c.done && (_a = _b.return)) _a.call(_b); } finally { if (e_1) throw e_1.error; } } return null; } /** * @license * Copyright Google Inc. All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ /** * @ngModule CommonModule * * @usageNotes * ``` * ... * * ... * * ... * * ... * * ... * ``` * * @description * * Adds and removes CSS classes on an HTML element. * * The CSS classes are updated as follows, depending on the type of the expression evaluation: * - `string` - the CSS classes listed in the string (space delimited) are added, * - `Array` - the CSS classes declared as Array elements are added, * - `Object` - keys are CSS classes that get added when the expression given in the value * evaluates to a truthy value, otherwise they are removed. * * @publicApi */ var NgClass = /** @class */ (function () { function NgClass(_iterableDiffers, _keyValueDiffers, _ngEl, _renderer) { this._iterableDiffers = _iterableDiffers; this._keyValueDiffers = _keyValueDiffers; this._ngEl = _ngEl; this._renderer = _renderer; this._initialClasses = []; } Object.defineProperty(NgClass.prototype, "klass", { set: function (value) { this._removeClasses(this._initialClasses); this._initialClasses = typeof value === 'string' ? value.split(/\s+/) : []; this._applyClasses(this._initialClasses); this._applyClasses(this._rawClass); }, enumerable: true, configurable: true }); Object.defineProperty(NgClass.prototype, "ngClass", { set: function (value) { this._removeClasses(this._rawClass); this._applyClasses(this._initialClasses); this._iterableDiffer = null; this._keyValueDiffer = null; this._rawClass = typeof value === 'string' ? value.split(/\s+/) : value; if (this._rawClass) { if (Object(_angular_core__WEBPACK_IMPORTED_MODULE_0__["ɵisListLikeIterable"])(this._rawClass)) { this._iterableDiffer = this._iterableDiffers.find(this._rawClass).create(); } else { this._keyValueDiffer = this._keyValueDiffers.find(this._rawClass).create(); } } }, enumerable: true, configurable: true }); NgClass.prototype.ngDoCheck = function () { if (this._iterableDiffer) { var iterableChanges = this._iterableDiffer.diff(this._rawClass); if (iterableChanges) { this._applyIterableChanges(iterableChanges); } } else if (this._keyValueDiffer) { var keyValueChanges = this._keyValueDiffer.diff(this._rawClass); if (keyValueChanges) { this._applyKeyValueChanges(keyValueChanges); } } }; NgClass.prototype._applyKeyValueChanges = function (changes) { var _this = this; changes.forEachAddedItem(function (record) { return _this._toggleClass(record.key, record.currentValue); }); changes.forEachChangedItem(function (record) { return _this._toggleClass(record.key, record.currentValue); }); changes.forEachRemovedItem(function (record) { if (record.previousValue) { _this._toggleClass(record.key, false); } }); }; NgClass.prototype._applyIterableChanges = function (changes) { var _this = this; changes.forEachAddedItem(function (record) { if (typeof record.item === 'string') { _this._toggleClass(record.item, true); } else { throw new Error("NgClass can only toggle CSS classes expressed as strings, got " + Object(_angular_core__WEBPACK_IMPORTED_MODULE_0__["ɵstringify"])(record.item)); } }); changes.forEachRemovedItem(function (record) { return _this._toggleClass(record.item, false); }); }; /** * Applies a collection of CSS classes to the DOM element. * * For argument of type Set and Array CSS class names contained in those collections are always * added. * For argument of type Map CSS class name in the map's key is toggled based on the value (added * for truthy and removed for falsy). */ NgClass.prototype._applyClasses = function (rawClassVal) { var _this = this; if (rawClassVal) { if (Array.isArray(rawClassVal) || rawClassVal instanceof Set) { rawClassVal.forEach(function (klass) { return _this._toggleClass(klass, true); }); } else { Object.keys(rawClassVal).forEach(function (klass) { return _this._toggleClass(klass, !!rawClassVal[klass]); }); } } }; /** * Removes a collection of CSS classes from the DOM element. This is mostly useful for cleanup * purposes. */ NgClass.prototype._removeClasses = function (rawClassVal) { var _this = this; if (rawClassVal) { if (Array.isArray(rawClassVal) || rawClassVal instanceof Set) { rawClassVal.forEach(function (klass) { return _this._toggleClass(klass, false); }); } else { Object.keys(rawClassVal).forEach(function (klass) { return _this._toggleClass(klass, false); }); } } }; NgClass.prototype._toggleClass = function (klass, enabled) { var _this = this; klass = klass.trim(); if (klass) { klass.split(/\s+/g).forEach(function (klass) { if (enabled) { _this._renderer.addClass(_this._ngEl.nativeElement, klass); } else { _this._renderer.removeClass(_this._ngEl.nativeElement, klass); } }); } }; Object(tslib__WEBPACK_IMPORTED_MODULE_1__["__decorate"])([ Object(_angular_core__WEBPACK_IMPORTED_MODULE_0__["Input"])('class'), Object(tslib__WEBPACK_IMPORTED_MODULE_1__["__metadata"])("design:type", String), Object(tslib__WEBPACK_IMPORTED_MODULE_1__["__metadata"])("design:paramtypes", [String]) ], NgClass.prototype, "klass", null); Object(tslib__WEBPACK_IMPORTED_MODULE_1__["__decorate"])([ Object(_angular_core__WEBPACK_IMPORTED_MODULE_0__["Input"])(), Object(tslib__WEBPACK_IMPORTED_MODULE_1__["__metadata"])("design:type", Object), Object(tslib__WEBPACK_IMPORTED_MODULE_1__["__metadata"])("design:paramtypes", [Object]) ], NgClass.prototype, "ngClass", null); NgClass = Object(tslib__WEBPACK_IMPORTED_MODULE_1__["__decorate"])([ Object(_angular_core__WEBPACK_IMPORTED_MODULE_0__["Directive"])({ selector: '[ngClass]' }), Object(tslib__WEBPACK_IMPORTED_MODULE_1__["__metadata"])("design:paramtypes", [_angular_core__WEBPACK_IMPORTED_MODULE_0__["IterableDiffers"], _angular_core__WEBPACK_IMPORTED_MODULE_0__["KeyValueDiffers"], _angular_core__WEBPACK_IMPORTED_MODULE_0__["ElementRef"], _angular_core__WEBPACK_IMPORTED_MODULE_0__["Renderer2"]]) ], NgClass); return NgClass; }()); /** * @license * Copyright Google Inc. All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ /** * Instantiates a single {@link Component} type and inserts its Host View into current View. * `NgComponentOutlet` provides a declarative approach for dynamic component creation. * * `NgComponentOutlet` requires a component type, if a falsy value is set the view will clear and * any existing component will get destroyed. * * @usageNotes * * ### Fine tune control * * You can control the component creation process by using the following optional attributes: * * * `ngComponentOutletInjector`: Optional custom {@link Injector} that will be used as parent for * the Component. Defaults to the injector of the current view container. * * * `ngComponentOutletContent`: Optional list of projectable nodes to insert into the content * section of the component, if exists. * * * `ngComponentOutletNgModuleFactory`: Optional module factory to allow dynamically loading other * module, then load a component from that module. * * ### Syntax * * Simple * ``` * * ``` * * Customized injector/content * ``` * * * ``` * * Customized ngModuleFactory * ``` * * * ``` * * ### A simple example * * {@example common/ngComponentOutlet/ts/module.ts region='SimpleExample'} * * A more complete example with additional options: * * {@example common/ngComponentOutlet/ts/module.ts region='CompleteExample'} * A more complete example with ngModuleFactory: * * {@example common/ngComponentOutlet/ts/module.ts region='NgModuleFactoryExample'} * * @publicApi * @ngModule CommonModule */ var NgComponentOutlet = /** @class */ (function () { function NgComponentOutlet(_viewContainerRef) { this._viewContainerRef = _viewContainerRef; this._componentRef = null; this._moduleRef = null; } NgComponentOutlet.prototype.ngOnChanges = function (changes) { this._viewContainerRef.clear(); this._componentRef = null; if (this.ngComponentOutlet) { var elInjector = this.ngComponentOutletInjector || this._viewContainerRef.parentInjector; if (changes['ngComponentOutletNgModuleFactory']) { if (this._moduleRef) this._moduleRef.destroy(); if (this.ngComponentOutletNgModuleFactory) { var parentModule = elInjector.get(_angular_core__WEBPACK_IMPORTED_MODULE_0__["NgModuleRef"]); this._moduleRef = this.ngComponentOutletNgModuleFactory.create(parentModule.injector); } else { this._moduleRef = null; } } var componentFactoryResolver = this._moduleRef ? this._moduleRef.componentFactoryResolver : elInjector.get(_angular_core__WEBPACK_IMPORTED_MODULE_0__["ComponentFactoryResolver"]); var componentFactory = componentFactoryResolver.resolveComponentFactory(this.ngComponentOutlet); this._componentRef = this._viewContainerRef.createComponent(componentFactory, this._viewContainerRef.length, elInjector, this.ngComponentOutletContent); } }; NgComponentOutlet.prototype.ngOnDestroy = function () { if (this._moduleRef) this._moduleRef.destroy(); }; Object(tslib__WEBPACK_IMPORTED_MODULE_1__["__decorate"])([ Object(_angular_core__WEBPACK_IMPORTED_MODULE_0__["Input"])(), Object(tslib__WEBPACK_IMPORTED_MODULE_1__["__metadata"])("design:type", _angular_core__WEBPACK_IMPORTED_MODULE_0__["Type"]) ], NgComponentOutlet.prototype, "ngComponentOutlet", void 0); Object(tslib__WEBPACK_IMPORTED_MODULE_1__["__decorate"])([ Object(_angular_core__WEBPACK_IMPORTED_MODULE_0__["Input"])(), Object(tslib__WEBPACK_IMPORTED_MODULE_1__["__metadata"])("design:type", _angular_core__WEBPACK_IMPORTED_MODULE_0__["Injector"]) ], NgComponentOutlet.prototype, "ngComponentOutletInjector", void 0); Object(tslib__WEBPACK_IMPORTED_MODULE_1__["__decorate"])([ Object(_angular_core__WEBPACK_IMPORTED_MODULE_0__["Input"])(), Object(tslib__WEBPACK_IMPORTED_MODULE_1__["__metadata"])("design:type", Array) ], NgComponentOutlet.prototype, "ngComponentOutletContent", void 0); Object(tslib__WEBPACK_IMPORTED_MODULE_1__["__decorate"])([ Object(_angular_core__WEBPACK_IMPORTED_MODULE_0__["Input"])(), Object(tslib__WEBPACK_IMPORTED_MODULE_1__["__metadata"])("design:type", _angular_core__WEBPACK_IMPORTED_MODULE_0__["NgModuleFactory"]) ], NgComponentOutlet.prototype, "ngComponentOutletNgModuleFactory", void 0); NgComponentOutlet = Object(tslib__WEBPACK_IMPORTED_MODULE_1__["__decorate"])([ Object(_angular_core__WEBPACK_IMPORTED_MODULE_0__["Directive"])({ selector: '[ngComponentOutlet]' }), Object(tslib__WEBPACK_IMPORTED_MODULE_1__["__metadata"])("design:paramtypes", [_angular_core__WEBPACK_IMPORTED_MODULE_0__["ViewContainerRef"]]) ], NgComponentOutlet); return NgComponentOutlet; }()); /** * @license * Copyright Google Inc. All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ /** * @publicApi */ var NgForOfContext = /** @class */ (function () { function NgForOfContext($implicit, ngForOf, index, count) { this.$implicit = $implicit; this.ngForOf = ngForOf; this.index = index; this.count = count; } Object.defineProperty(NgForOfContext.prototype, "first", { get: function () { return this.index === 0; }, enumerable: true, configurable: true }); Object.defineProperty(NgForOfContext.prototype, "last", { get: function () { return this.index === this.count - 1; }, enumerable: true, configurable: true }); Object.defineProperty(NgForOfContext.prototype, "even", { get: function () { return this.index % 2 === 0; }, enumerable: true, configurable: true }); Object.defineProperty(NgForOfContext.prototype, "odd", { get: function () { return !this.even; }, enumerable: true, configurable: true }); return NgForOfContext; }()); /** * A [structural directive](guide/structural-directives) that renders * a template for each item in a collection. * The directive is placed on an element, which becomes the parent * of the cloned templates. * * The `ngForOf` is generally used in the * [shorthand form](guide/structural-directives#the-asterisk--prefix) `*ngFor`. * In this form, the template to be rendered for each iteration is the content * of an anchor element containing the directive. * * The following example shows the shorthand syntax with some options, * contained in an `
  • ` element. * * ``` *
  • ...
  • * ``` * * The shorthand form expands into a long form that uses the `ngForOf` selector * on an `` element. * The content of the `` element is the `
  • ` element that held the * short-form directive. * * Here is the expanded version of the short-form example. * * ``` * *
  • ...
  • *
    * ``` * * Angular automatically expands the shorthand syntax as it compiles the template. * The context for each embedded view is logically merged to the current component * context according to its lexical position. * * When using the shorthand syntax, Angular allows only [one structural directive * on an element](guide/structural-directives#one-structural-directive-per-host-element). * If you want to iterate conditionally, for example, * put the `*ngIf` on a container element that wraps the `*ngFor` element. * For futher discussion, see * [Structural Directives](guide/structural-directives#one-per-element). * * @usageNotes * * ### Local variables * * `NgForOf` provides exported values that can be aliased to local variables. * For example: * * ``` *
  • * {{i}}/{{users.length}}. {{user}} default *
  • * ``` * * The following exported values can be aliased to local variables: * * - `$implicit: T`: The value of the individual items in the iterable (`ngForOf`). * - `ngForOf: NgIterable`: The value of the iterable expression. Useful when the expression is * more complex then a property access, for example when using the async pipe (`userStreams | * async`). * - `index: number`: The index of the current item in the iterable. * - `first: boolean`: True when the item is the first item in the iterable. * - `last: boolean`: True when the item is the last item in the iterable. * - `even: boolean`: True when the item has an even index in the iterable. * - `odd: boolean`: True when the item has an odd index in the iterable. * * ### Change propagation * * When the contents of the iterator changes, `NgForOf` makes the corresponding changes to the DOM: * * * When an item is added, a new instance of the template is added to the DOM. * * When an item is removed, its template instance is removed from the DOM. * * When items are reordered, their respective templates are reordered in the DOM. * * Angular uses object identity to track insertions and deletions within the iterator and reproduce * those changes in the DOM. This has important implications for animations and any stateful * controls that are present, such as `` elements that accept user input. Inserted rows can * be animated in, deleted rows can be animated out, and unchanged rows retain any unsaved state * such as user input. * For more on animations, see [Transitions and Triggers](guide/transition-and-triggers). * * The identities of elements in the iterator can change while the data does not. * This can happen, for example, if the iterator is produced from an RPC to the server, and that * RPC is re-run. Even if the data hasn't changed, the second response produces objects with * different identities, and Angular must tear down the entire DOM and rebuild it (as if all old * elements were deleted and all new elements inserted). * * To avoid this expensive operation, you can customize the default tracking algorithm. * by supplying the `trackBy` option to `NgForOf`. * `trackBy` takes a function that has two arguments: `index` and `item`. * If `trackBy` is given, Angular tracks changes by the return value of the function. * * @see [Structural Directives](guide/structural-directives) * @ngModule CommonModule * @publicApi */ var NgForOf = /** @class */ (function () { function NgForOf(_viewContainer, _template, _differs) { this._viewContainer = _viewContainer; this._template = _template; this._differs = _differs; this._ngForOfDirty = true; this._differ = null; } Object.defineProperty(NgForOf.prototype, "ngForOf", { set: function (ngForOf) { this._ngForOf = ngForOf; this._ngForOfDirty = true; }, enumerable: true, configurable: true }); Object.defineProperty(NgForOf.prototype, "ngForTrackBy", { get: function () { return this._trackByFn; }, set: function (fn) { if (Object(_angular_core__WEBPACK_IMPORTED_MODULE_0__["isDevMode"])() && fn != null && typeof fn !== 'function') { // TODO(vicb): use a log service once there is a public one available if (console && console.warn) { console.warn("trackBy must be a function, but received " + JSON.stringify(fn) + ". " + "See https://angular.io/docs/ts/latest/api/common/index/NgFor-directive.html#!#change-propagation for more information."); } } this._trackByFn = fn; }, enumerable: true, configurable: true }); Object.defineProperty(NgForOf.prototype, "ngForTemplate", { set: function (value) { // TODO(TS2.1): make TemplateRef>> once we move to TS v2.1 // The current type is too restrictive; a template that just uses index, for example, // should be acceptable. if (value) { this._template = value; } }, enumerable: true, configurable: true }); NgForOf.prototype.ngDoCheck = function () { if (this._ngForOfDirty) { this._ngForOfDirty = false; // React on ngForOf changes only once all inputs have been initialized var value = this._ngForOf; if (!this._differ && value) { try { this._differ = this._differs.find(value).create(this.ngForTrackBy); } catch (_a) { throw new Error("Cannot find a differ supporting object '" + value + "' of type '" + getTypeNameForDebugging(value) + "'. NgFor only supports binding to Iterables such as Arrays."); } } } if (this._differ) { var changes = this._differ.diff(this._ngForOf); if (changes) this._applyChanges(changes); } }; NgForOf.prototype._applyChanges = function (changes) { var _this = this; var insertTuples = []; changes.forEachOperation(function (item, adjustedPreviousIndex, currentIndex) { if (item.previousIndex == null) { var view = _this._viewContainer.createEmbeddedView(_this._template, new NgForOfContext(null, _this._ngForOf, -1, -1), currentIndex); var tuple = new RecordViewTuple(item, view); insertTuples.push(tuple); } else if (currentIndex == null) { _this._viewContainer.remove(adjustedPreviousIndex); } else { var view = _this._viewContainer.get(adjustedPreviousIndex); _this._viewContainer.move(view, currentIndex); var tuple = new RecordViewTuple(item, view); insertTuples.push(tuple); } }); for (var i = 0; i < insertTuples.length; i++) { this._perViewChange(insertTuples[i].view, insertTuples[i].record); } for (var i = 0, ilen = this._viewContainer.length; i < ilen; i++) { var viewRef = this._viewContainer.get(i); viewRef.context.index = i; viewRef.context.count = ilen; viewRef.context.ngForOf = this._ngForOf; } changes.forEachIdentityChange(function (record) { var viewRef = _this._viewContainer.get(record.currentIndex); viewRef.context.$implicit = record.item; }); }; NgForOf.prototype._perViewChange = function (view, record) { view.context.$implicit = record.item; }; /** * Asserts the correct type of the context for the template that `NgForOf` will render. * * The presence of this method is a signal to the Ivy template type-check compiler that the * `NgForOf` structural directive renders its template with a specific context type. */ NgForOf.ngTemplateContextGuard = function (dir, ctx) { return true; }; Object(tslib__WEBPACK_IMPORTED_MODULE_1__["__decorate"])([ Object(_angular_core__WEBPACK_IMPORTED_MODULE_0__["Input"])(), Object(tslib__WEBPACK_IMPORTED_MODULE_1__["__metadata"])("design:type", Object), Object(tslib__WEBPACK_IMPORTED_MODULE_1__["__metadata"])("design:paramtypes", [Object]) ], NgForOf.prototype, "ngForOf", null); Object(tslib__WEBPACK_IMPORTED_MODULE_1__["__decorate"])([ Object(_angular_core__WEBPACK_IMPORTED_MODULE_0__["Input"])(), Object(tslib__WEBPACK_IMPORTED_MODULE_1__["__metadata"])("design:type", Function), Object(tslib__WEBPACK_IMPORTED_MODULE_1__["__metadata"])("design:paramtypes", [Function]) ], NgForOf.prototype, "ngForTrackBy", null); Object(tslib__WEBPACK_IMPORTED_MODULE_1__["__decorate"])([ Object(_angular_core__WEBPACK_IMPORTED_MODULE_0__["Input"])(), Object(tslib__WEBPACK_IMPORTED_MODULE_1__["__metadata"])("design:type", _angular_core__WEBPACK_IMPORTED_MODULE_0__["TemplateRef"]), Object(tslib__WEBPACK_IMPORTED_MODULE_1__["__metadata"])("design:paramtypes", [_angular_core__WEBPACK_IMPORTED_MODULE_0__["TemplateRef"]]) ], NgForOf.prototype, "ngForTemplate", null); NgForOf = Object(tslib__WEBPACK_IMPORTED_MODULE_1__["__decorate"])([ Object(_angular_core__WEBPACK_IMPORTED_MODULE_0__["Directive"])({ selector: '[ngFor][ngForOf]' }), Object(tslib__WEBPACK_IMPORTED_MODULE_1__["__metadata"])("design:paramtypes", [_angular_core__WEBPACK_IMPORTED_MODULE_0__["ViewContainerRef"], _angular_core__WEBPACK_IMPORTED_MODULE_0__["TemplateRef"], _angular_core__WEBPACK_IMPORTED_MODULE_0__["IterableDiffers"]]) ], NgForOf); return NgForOf; }()); var RecordViewTuple = /** @class */ (function () { function RecordViewTuple(record, view) { this.record = record; this.view = view; } return RecordViewTuple; }()); function getTypeNameForDebugging(type) { return type['name'] || typeof type; } /** * @license * Copyright Google Inc. All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ /** * A structural directive that conditionally includes a template based on the value of * an expression coerced to Boolean. * When the expression evaluates to true, Angular renders the template * provided in a `then` clause, and when false or null, * Angular renders the template provided in an optional `else` clause. The default * template for the `else` clause is blank. * * A [shorthand form](guide/structural-directives#the-asterisk--prefix) of the directive, * `*ngIf="condition"`, is generally used, provided * as an attribute of the anchor element for the inserted template. * Angular expands this into a more explicit version, in which the anchor element * is contained in an `` element. * * Simple form with shorthand syntax: * * ``` *
    Content to render when condition is true.
    * ``` * * Simple form with expanded syntax: * * ``` *
    Content to render when condition is * true.
    * ``` * * Form with an "else" block: * * ``` *
    Content to render when condition is true.
    * Content to render when condition is false. * ``` * * Shorthand form with "then" and "else" blocks: * * ``` *
    * Content to render when condition is true. * Content to render when condition is false. * ``` * * Form with storing the value locally: * * ``` *
    {{value}}
    * Content to render when value is null. * ``` * * @usageNotes * * The `*ngIf` directive is most commonly used to conditionally show an inline template, * as seen in the following example. * The default `else` template is blank. * * {@example common/ngIf/ts/module.ts region='NgIfSimple'} * * ### Showing an alternative template using `else` * * To display a template when `expression` evaluates to false, use an `else` template * binding as shown in the following example. * The `else` binding points to an `` element labeled `#elseBlock`. * The template can be defined anywhere in the component view, but is typically placed right after * `ngIf` for readability. * * {@example common/ngIf/ts/module.ts region='NgIfElse'} * * ### Using an external `then` template * * In the previous example, the then-clause template is specified inline, as the content of the * tag that contains the `ngIf` directive. You can also specify a template that is defined * externally, by referencing a labeled `` element. When you do this, you can * change which template to use at runtime, as shown in the following example. * * {@example common/ngIf/ts/module.ts region='NgIfThenElse'} * * ### Storing a conditional result in a variable * * You might want to show a set of properties from the same object. If you are waiting * for asynchronous data, the object can be undefined. * In this case, you can use `ngIf` and store the result of the condition in a local * variable as shown in the the following example. * * {@example common/ngIf/ts/module.ts region='NgIfAs'} * * This code uses only one `AsyncPipe`, so only one subscription is created. * The conditional statement stores the result of `userStream|async` in the local variable `user`. * You can then bind the local `user` repeatedly. * * The conditional displays the data only if `userStream` returns a value, * so you don't need to use the * [safe-navigation-operator](guide/template-syntax#safe-navigation-operator) (`?.`) * to guard against null values when accessing properties. * You can display an alternative template while waiting for the data. * * ### Shorthand syntax * * The shorthand syntax `*ngIf` expands into two separate template specifications * for the "then" and "else" clauses. For example, consider the following shorthand statement, * that is meant to show a loading page while waiting for data to be loaded. * * ``` *
    * ... *
    * * *
    Loading...
    *
    * ``` * * You can see that the "else" clause references the `` * with the `#loading` label, and the template for the "then" clause * is provided as the content of the anchor element. * * However, when Angular expands the shorthand syntax, it creates * another `` tag, with `ngIf` and `ngIfElse` directives. * The anchor element containing the template for the "then" clause becomes * the content of this unlabeled `` tag. * * ``` * *
    * ... *
    *
    * * *
    Loading...
    *
    * ``` * * The presence of the implicit template object has implications for the nesting of * structural directives. For more on this subject, see * [Structural Directives](https://angular.io/guide/structural-directives#one-per-element). * * @ngModule CommonModule * @publicApi */ var NgIf = /** @class */ (function () { function NgIf(_viewContainer, templateRef) { this._viewContainer = _viewContainer; this._context = new NgIfContext(); this._thenTemplateRef = null; this._elseTemplateRef = null; this._thenViewRef = null; this._elseViewRef = null; this._thenTemplateRef = templateRef; } Object.defineProperty(NgIf.prototype, "ngIf", { set: function (condition) { this._context.$implicit = this._context.ngIf = condition; this._updateView(); }, enumerable: true, configurable: true }); Object.defineProperty(NgIf.prototype, "ngIfThen", { set: function (templateRef) { assertTemplate('ngIfThen', templateRef); this._thenTemplateRef = templateRef; this._thenViewRef = null; // clear previous view if any. this._updateView(); }, enumerable: true, configurable: true }); Object.defineProperty(NgIf.prototype, "ngIfElse", { set: function (templateRef) { assertTemplate('ngIfElse', templateRef); this._elseTemplateRef = templateRef; this._elseViewRef = null; // clear previous view if any. this._updateView(); }, enumerable: true, configurable: true }); NgIf.prototype._updateView = function () { if (this._context.$implicit) { if (!this._thenViewRef) { this._viewContainer.clear(); this._elseViewRef = null; if (this._thenTemplateRef) { this._thenViewRef = this._viewContainer.createEmbeddedView(this._thenTemplateRef, this._context); } } } else { if (!this._elseViewRef) { this._viewContainer.clear(); this._thenViewRef = null; if (this._elseTemplateRef) { this._elseViewRef = this._viewContainer.createEmbeddedView(this._elseTemplateRef, this._context); } } } }; /** * Assert the correct type of the expression bound to the `ngIf` input within the template. * * The presence of this method is a signal to the Ivy template type check compiler that when the * `NgIf` structural directive renders its template, the type of the expression bound to `ngIf` * should be narrowed in some way. For `NgIf`, it is narrowed to be non-null, which allows the * strictNullChecks feature of TypeScript to work with `NgIf`. */ NgIf.ngTemplateGuard_ngIf = function (dir, expr) { return true; }; Object(tslib__WEBPACK_IMPORTED_MODULE_1__["__decorate"])([ Object(_angular_core__WEBPACK_IMPORTED_MODULE_0__["Input"])(), Object(tslib__WEBPACK_IMPORTED_MODULE_1__["__metadata"])("design:type", Object), Object(tslib__WEBPACK_IMPORTED_MODULE_1__["__metadata"])("design:paramtypes", [Object]) ], NgIf.prototype, "ngIf", null); Object(tslib__WEBPACK_IMPORTED_MODULE_1__["__decorate"])([ Object(_angular_core__WEBPACK_IMPORTED_MODULE_0__["Input"])(), Object(tslib__WEBPACK_IMPORTED_MODULE_1__["__metadata"])("design:type", Object), Object(tslib__WEBPACK_IMPORTED_MODULE_1__["__metadata"])("design:paramtypes", [Object]) ], NgIf.prototype, "ngIfThen", null); Object(tslib__WEBPACK_IMPORTED_MODULE_1__["__decorate"])([ Object(_angular_core__WEBPACK_IMPORTED_MODULE_0__["Input"])(), Object(tslib__WEBPACK_IMPORTED_MODULE_1__["__metadata"])("design:type", Object), Object(tslib__WEBPACK_IMPORTED_MODULE_1__["__metadata"])("design:paramtypes", [Object]) ], NgIf.prototype, "ngIfElse", null); NgIf = Object(tslib__WEBPACK_IMPORTED_MODULE_1__["__decorate"])([ Object(_angular_core__WEBPACK_IMPORTED_MODULE_0__["Directive"])({ selector: '[ngIf]' }), Object(tslib__WEBPACK_IMPORTED_MODULE_1__["__metadata"])("design:paramtypes", [_angular_core__WEBPACK_IMPORTED_MODULE_0__["ViewContainerRef"], _angular_core__WEBPACK_IMPORTED_MODULE_0__["TemplateRef"]]) ], NgIf); return NgIf; }()); /** * @publicApi */ var NgIfContext = /** @class */ (function () { function NgIfContext() { this.$implicit = null; this.ngIf = null; } return NgIfContext; }()); function assertTemplate(property, templateRef) { var isTemplateRefOrNull = !!(!templateRef || templateRef.createEmbeddedView); if (!isTemplateRefOrNull) { throw new Error(property + " must be a TemplateRef, but received '" + Object(_angular_core__WEBPACK_IMPORTED_MODULE_0__["ɵstringify"])(templateRef) + "'."); } } /** * @license * Copyright Google Inc. All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ var SwitchView = /** @class */ (function () { function SwitchView(_viewContainerRef, _templateRef) { this._viewContainerRef = _viewContainerRef; this._templateRef = _templateRef; this._created = false; } SwitchView.prototype.create = function () { this._created = true; this._viewContainerRef.createEmbeddedView(this._templateRef); }; SwitchView.prototype.destroy = function () { this._created = false; this._viewContainerRef.clear(); }; SwitchView.prototype.enforceState = function (created) { if (created && !this._created) { this.create(); } else if (!created && this._created) { this.destroy(); } }; return SwitchView; }()); /** * @ngModule CommonModule * * @description A structural directive that adds or removes templates (displaying or hiding views) * when the next match expression matches the switch expression. * * The `[ngSwitch]` directive on a container specifies an expression to match against. * The expressions to match are provided by `ngSwitchCase` directives on views within the container. * - Every view that matches is rendered. * - If there are no matches, a view with the `ngSwitchDefault` directive is rendered. * - Elements within the `[NgSwitch]` statement but outside of any `NgSwitchCase` * or `ngSwitchDefault` directive are preserved at the location. * * @usageNotes * Define a container element for the directive, and specify the switch expression * to match against as an attribute: * * ``` * * ``` * * Within the container, `*ngSwitchCase` statements specify the match expressions * as attributes. Include `*ngSwitchDefault` as the final case. * * ``` * * ... * ... * ... * * ``` * * ### Usage Examples * * The following example shows how to use more than one case to display the same view: * * ``` * * * ... * ... * ... * * ... * * ``` * * The following example shows how cases can be nested: * ``` * * ... * ... * ... * * * * * * ... * * ``` * * @publicApi * @see `NgSwitchCase` * @see `NgSwitchDefault` * @see [Stuctural Directives](guide/structural-directives) * */ var NgSwitch = /** @class */ (function () { function NgSwitch() { this._defaultUsed = false; this._caseCount = 0; this._lastCaseCheckIndex = 0; this._lastCasesMatched = false; } Object.defineProperty(NgSwitch.prototype, "ngSwitch", { set: function (newValue) { this._ngSwitch = newValue; if (this._caseCount === 0) { this._updateDefaultCases(true); } }, enumerable: true, configurable: true }); /** @internal */ NgSwitch.prototype._addCase = function () { return this._caseCount++; }; /** @internal */ NgSwitch.prototype._addDefault = function (view) { if (!this._defaultViews) { this._defaultViews = []; } this._defaultViews.push(view); }; /** @internal */ NgSwitch.prototype._matchCase = function (value) { var matched = value == this._ngSwitch; this._lastCasesMatched = this._lastCasesMatched || matched; this._lastCaseCheckIndex++; if (this._lastCaseCheckIndex === this._caseCount) { this._updateDefaultCases(!this._lastCasesMatched); this._lastCaseCheckIndex = 0; this._lastCasesMatched = false; } return matched; }; NgSwitch.prototype._updateDefaultCases = function (useDefault) { if (this._defaultViews && useDefault !== this._defaultUsed) { this._defaultUsed = useDefault; for (var i = 0; i < this._defaultViews.length; i++) { var defaultView = this._defaultViews[i]; defaultView.enforceState(useDefault); } } }; Object(tslib__WEBPACK_IMPORTED_MODULE_1__["__decorate"])([ Object(_angular_core__WEBPACK_IMPORTED_MODULE_0__["Input"])(), Object(tslib__WEBPACK_IMPORTED_MODULE_1__["__metadata"])("design:type", Object), Object(tslib__WEBPACK_IMPORTED_MODULE_1__["__metadata"])("design:paramtypes", [Object]) ], NgSwitch.prototype, "ngSwitch", null); NgSwitch = Object(tslib__WEBPACK_IMPORTED_MODULE_1__["__decorate"])([ Object(_angular_core__WEBPACK_IMPORTED_MODULE_0__["Directive"])({ selector: '[ngSwitch]' }) ], NgSwitch); return NgSwitch; }()); /** * @ngModule CommonModule * * @description * Provides a switch case expression to match against an enclosing `ngSwitch` expression. * When the expressions match, the given `NgSwitchCase` template is rendered. * If multiple match expressions match the switch expression value, all of them are displayed. * * @usageNotes * * Within a switch container, `*ngSwitchCase` statements specify the match expressions * as attributes. Include `*ngSwitchDefault` as the final case. * * ``` * * ... * ... * ... * * ``` * * Each switch-case statement contains an in-line HTML template or template reference * that defines the subtree to be selected if the value of the match expression * matches the value of the switch expression. * * Unlike JavaScript, which uses strict equality, Angular uses loose equality. * This means that the empty string, `""` matches 0. * * @publicApi * @see `NgSwitch` * @see `NgSwitchDefault` * */ var NgSwitchCase = /** @class */ (function () { function NgSwitchCase(viewContainer, templateRef, ngSwitch) { this.ngSwitch = ngSwitch; ngSwitch._addCase(); this._view = new SwitchView(viewContainer, templateRef); } /** * Performs case matching. For internal use only. */ NgSwitchCase.prototype.ngDoCheck = function () { this._view.enforceState(this.ngSwitch._matchCase(this.ngSwitchCase)); }; Object(tslib__WEBPACK_IMPORTED_MODULE_1__["__decorate"])([ Object(_angular_core__WEBPACK_IMPORTED_MODULE_0__["Input"])(), Object(tslib__WEBPACK_IMPORTED_MODULE_1__["__metadata"])("design:type", Object) ], NgSwitchCase.prototype, "ngSwitchCase", void 0); NgSwitchCase = Object(tslib__WEBPACK_IMPORTED_MODULE_1__["__decorate"])([ Object(_angular_core__WEBPACK_IMPORTED_MODULE_0__["Directive"])({ selector: '[ngSwitchCase]' }), Object(tslib__WEBPACK_IMPORTED_MODULE_1__["__param"])(2, Object(_angular_core__WEBPACK_IMPORTED_MODULE_0__["Host"])()), Object(tslib__WEBPACK_IMPORTED_MODULE_1__["__metadata"])("design:paramtypes", [_angular_core__WEBPACK_IMPORTED_MODULE_0__["ViewContainerRef"], _angular_core__WEBPACK_IMPORTED_MODULE_0__["TemplateRef"], NgSwitch]) ], NgSwitchCase); return NgSwitchCase; }()); /** * @ngModule CommonModule * * @description * * Creates a view that is rendered when no `NgSwitchCase` expressions * match the `NgSwitch` expression. * This statement should be the final case in an `NgSwitch`. * * @publicApi * @see `NgSwitch` * @see `NgSwitchCase` * */ var NgSwitchDefault = /** @class */ (function () { function NgSwitchDefault(viewContainer, templateRef, ngSwitch) { ngSwitch._addDefault(new SwitchView(viewContainer, templateRef)); } NgSwitchDefault = Object(tslib__WEBPACK_IMPORTED_MODULE_1__["__decorate"])([ Object(_angular_core__WEBPACK_IMPORTED_MODULE_0__["Directive"])({ selector: '[ngSwitchDefault]' }), Object(tslib__WEBPACK_IMPORTED_MODULE_1__["__param"])(2, Object(_angular_core__WEBPACK_IMPORTED_MODULE_0__["Host"])()), Object(tslib__WEBPACK_IMPORTED_MODULE_1__["__metadata"])("design:paramtypes", [_angular_core__WEBPACK_IMPORTED_MODULE_0__["ViewContainerRef"], _angular_core__WEBPACK_IMPORTED_MODULE_0__["TemplateRef"], NgSwitch]) ], NgSwitchDefault); return NgSwitchDefault; }()); /** * @license * Copyright Google Inc. All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ /** * @ngModule CommonModule * * @usageNotes * ``` * * there is nothing * there is one * there are a few * * ``` * * @description * * Adds / removes DOM sub-trees based on a numeric value. Tailored for pluralization. * * Displays DOM sub-trees that match the switch expression value, or failing that, DOM sub-trees * that match the switch expression's pluralization category. * * To use this directive you must provide a container element that sets the `[ngPlural]` attribute * to a switch expression. Inner elements with a `[ngPluralCase]` will display based on their * expression: * - if `[ngPluralCase]` is set to a value starting with `=`, it will only display if the value * matches the switch expression exactly, * - otherwise, the view will be treated as a "category match", and will only display if exact * value matches aren't found and the value maps to its category for the defined locale. * * See http://cldr.unicode.org/index/cldr-spec/plural-rules * * @publicApi */ var NgPlural = /** @class */ (function () { function NgPlural(_localization) { this._localization = _localization; this._caseViews = {}; } Object.defineProperty(NgPlural.prototype, "ngPlural", { set: function (value) { this._switchValue = value; this._updateView(); }, enumerable: true, configurable: true }); NgPlural.prototype.addCase = function (value, switchView) { this._caseViews[value] = switchView; }; NgPlural.prototype._updateView = function () { this._clearViews(); var cases = Object.keys(this._caseViews); var key = getPluralCategory(this._switchValue, cases, this._localization); this._activateView(this._caseViews[key]); }; NgPlural.prototype._clearViews = function () { if (this._activeView) this._activeView.destroy(); }; NgPlural.prototype._activateView = function (view) { if (view) { this._activeView = view; this._activeView.create(); } }; Object(tslib__WEBPACK_IMPORTED_MODULE_1__["__decorate"])([ Object(_angular_core__WEBPACK_IMPORTED_MODULE_0__["Input"])(), Object(tslib__WEBPACK_IMPORTED_MODULE_1__["__metadata"])("design:type", Number), Object(tslib__WEBPACK_IMPORTED_MODULE_1__["__metadata"])("design:paramtypes", [Number]) ], NgPlural.prototype, "ngPlural", null); NgPlural = Object(tslib__WEBPACK_IMPORTED_MODULE_1__["__decorate"])([ Object(_angular_core__WEBPACK_IMPORTED_MODULE_0__["Directive"])({ selector: '[ngPlural]' }), Object(tslib__WEBPACK_IMPORTED_MODULE_1__["__metadata"])("design:paramtypes", [NgLocalization]) ], NgPlural); return NgPlural; }()); /** * @ngModule CommonModule * * @description * * Creates a view that will be added/removed from the parent {@link NgPlural} when the * given expression matches the plural expression according to CLDR rules. * * @usageNotes * ``` * * ... * ... * *``` * * See {@link NgPlural} for more details and example. * * @publicApi */ var NgPluralCase = /** @class */ (function () { function NgPluralCase(value, template, viewContainer, ngPlural) { this.value = value; var isANumber = !isNaN(Number(value)); ngPlural.addCase(isANumber ? "=" + value : value, new SwitchView(viewContainer, template)); } NgPluralCase = Object(tslib__WEBPACK_IMPORTED_MODULE_1__["__decorate"])([ Object(_angular_core__WEBPACK_IMPORTED_MODULE_0__["Directive"])({ selector: '[ngPluralCase]' }), Object(tslib__WEBPACK_IMPORTED_MODULE_1__["__param"])(0, Object(_angular_core__WEBPACK_IMPORTED_MODULE_0__["Attribute"])('ngPluralCase')), Object(tslib__WEBPACK_IMPORTED_MODULE_1__["__param"])(3, Object(_angular_core__WEBPACK_IMPORTED_MODULE_0__["Host"])()), Object(tslib__WEBPACK_IMPORTED_MODULE_1__["__metadata"])("design:paramtypes", [String, _angular_core__WEBPACK_IMPORTED_MODULE_0__["TemplateRef"], _angular_core__WEBPACK_IMPORTED_MODULE_0__["ViewContainerRef"], NgPlural]) ], NgPluralCase); return NgPluralCase; }()); /** * @license * Copyright Google Inc. All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ /** * @ngModule CommonModule * * @usageNotes * * Set the font of the containing element to the result of an expression. * * ``` * ... * ``` * * Set the width of the containing element to a pixel value returned by an expression. * * ``` * ... * ``` * * Set a collection of style values using an expression that returns key-value pairs. * * ``` * ... * ``` * * @description * * An attribute directive that updates styles for the containing HTML element. * Sets one or more style properties, specified as colon-separated key-value pairs. * The key is a style name, with an optional `.` suffix * (such as 'top.px', 'font-style.em'). * The value is an expression to be evaluated. * The resulting non-null value, expressed in the given unit, * is assigned to the given style property. * If the result of evaluation is null, the corresponding style is removed. * * @publicApi */ var NgStyle = /** @class */ (function () { function NgStyle(_differs, _ngEl, _renderer) { this._differs = _differs; this._ngEl = _ngEl; this._renderer = _renderer; } Object.defineProperty(NgStyle.prototype, "ngStyle", { set: function ( /** * A map of style properties, specified as colon-separated * key-value pairs. * * The key is a style name, with an optional `.` suffix * (such as 'top.px', 'font-style.em'). * * The value is an expression to be evaluated. */ values) { this._ngStyle = values; if (!this._differ && values) { this._differ = this._differs.find(values).create(); } }, enumerable: true, configurable: true }); /** * Applies the new styles if needed. */ NgStyle.prototype.ngDoCheck = function () { if (this._differ) { var changes = this._differ.diff(this._ngStyle); if (changes) { this._applyChanges(changes); } } }; NgStyle.prototype._applyChanges = function (changes) { var _this = this; changes.forEachRemovedItem(function (record) { return _this._setStyle(record.key, null); }); changes.forEachAddedItem(function (record) { return _this._setStyle(record.key, record.currentValue); }); changes.forEachChangedItem(function (record) { return _this._setStyle(record.key, record.currentValue); }); }; NgStyle.prototype._setStyle = function (nameAndUnit, value) { var _a = Object(tslib__WEBPACK_IMPORTED_MODULE_1__["__read"])(nameAndUnit.split('.'), 2), name = _a[0], unit = _a[1]; value = value != null && unit ? "" + value + unit : value; if (value != null) { this._renderer.setStyle(this._ngEl.nativeElement, name, value); } else { this._renderer.removeStyle(this._ngEl.nativeElement, name); } }; Object(tslib__WEBPACK_IMPORTED_MODULE_1__["__decorate"])([ Object(_angular_core__WEBPACK_IMPORTED_MODULE_0__["Input"])(), Object(tslib__WEBPACK_IMPORTED_MODULE_1__["__metadata"])("design:type", Object), Object(tslib__WEBPACK_IMPORTED_MODULE_1__["__metadata"])("design:paramtypes", [Object]) ], NgStyle.prototype, "ngStyle", null); NgStyle = Object(tslib__WEBPACK_IMPORTED_MODULE_1__["__decorate"])([ Object(_angular_core__WEBPACK_IMPORTED_MODULE_0__["Directive"])({ selector: '[ngStyle]' }), Object(tslib__WEBPACK_IMPORTED_MODULE_1__["__metadata"])("design:paramtypes", [_angular_core__WEBPACK_IMPORTED_MODULE_0__["KeyValueDiffers"], _angular_core__WEBPACK_IMPORTED_MODULE_0__["ElementRef"], _angular_core__WEBPACK_IMPORTED_MODULE_0__["Renderer2"]]) ], NgStyle); return NgStyle; }()); /** * @license * Copyright Google Inc. All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ /** * @ngModule CommonModule * * @description * * Inserts an embedded view from a prepared `TemplateRef`. * * You can attach a context object to the `EmbeddedViewRef` by setting `[ngTemplateOutletContext]`. * `[ngTemplateOutletContext]` should be an object, the object's keys will be available for binding * by the local template `let` declarations. * * @usageNotes * ``` * * ``` * * Using the key `$implicit` in the context object will set its value as default. * * ### Example * * {@example common/ngTemplateOutlet/ts/module.ts region='NgTemplateOutlet'} * * @publicApi */ var NgTemplateOutlet = /** @class */ (function () { function NgTemplateOutlet(_viewContainerRef) { this._viewContainerRef = _viewContainerRef; } NgTemplateOutlet.prototype.ngOnChanges = function (changes) { var recreateView = this._shouldRecreateView(changes); if (recreateView) { if (this._viewRef) { this._viewContainerRef.remove(this._viewContainerRef.indexOf(this._viewRef)); } if (this.ngTemplateOutlet) { this._viewRef = this._viewContainerRef.createEmbeddedView(this.ngTemplateOutlet, this.ngTemplateOutletContext); } } else { if (this._viewRef && this.ngTemplateOutletContext) { this._updateExistingContext(this.ngTemplateOutletContext); } } }; /** * We need to re-create existing embedded view if: * - templateRef has changed * - context has changes * * We mark context object as changed when the corresponding object * shape changes (new properties are added or existing properties are removed). * In other words we consider context with the same properties as "the same" even * if object reference changes (see https://github.com/angular/angular/issues/13407). */ NgTemplateOutlet.prototype._shouldRecreateView = function (changes) { var ctxChange = changes['ngTemplateOutletContext']; return !!changes['ngTemplateOutlet'] || (ctxChange && this._hasContextShapeChanged(ctxChange)); }; NgTemplateOutlet.prototype._hasContextShapeChanged = function (ctxChange) { var e_1, _a; var prevCtxKeys = Object.keys(ctxChange.previousValue || {}); var currCtxKeys = Object.keys(ctxChange.currentValue || {}); if (prevCtxKeys.length === currCtxKeys.length) { try { for (var currCtxKeys_1 = Object(tslib__WEBPACK_IMPORTED_MODULE_1__["__values"])(currCtxKeys), currCtxKeys_1_1 = currCtxKeys_1.next(); !currCtxKeys_1_1.done; currCtxKeys_1_1 = currCtxKeys_1.next()) { var propName = currCtxKeys_1_1.value; if (prevCtxKeys.indexOf(propName) === -1) { return true; } } } catch (e_1_1) { e_1 = { error: e_1_1 }; } finally { try { if (currCtxKeys_1_1 && !currCtxKeys_1_1.done && (_a = currCtxKeys_1.return)) _a.call(currCtxKeys_1); } finally { if (e_1) throw e_1.error; } } return false; } else { return true; } }; NgTemplateOutlet.prototype._updateExistingContext = function (ctx) { var e_2, _a; try { for (var _b = Object(tslib__WEBPACK_IMPORTED_MODULE_1__["__values"])(Object.keys(ctx)), _c = _b.next(); !_c.done; _c = _b.next()) { var propName = _c.value; this._viewRef.context[propName] = this.ngTemplateOutletContext[propName]; } } catch (e_2_1) { e_2 = { error: e_2_1 }; } finally { try { if (_c && !_c.done && (_a = _b.return)) _a.call(_b); } finally { if (e_2) throw e_2.error; } } }; Object(tslib__WEBPACK_IMPORTED_MODULE_1__["__decorate"])([ Object(_angular_core__WEBPACK_IMPORTED_MODULE_0__["Input"])(), Object(tslib__WEBPACK_IMPORTED_MODULE_1__["__metadata"])("design:type", Object) ], NgTemplateOutlet.prototype, "ngTemplateOutletContext", void 0); Object(tslib__WEBPACK_IMPORTED_MODULE_1__["__decorate"])([ Object(_angular_core__WEBPACK_IMPORTED_MODULE_0__["Input"])(), Object(tslib__WEBPACK_IMPORTED_MODULE_1__["__metadata"])("design:type", _angular_core__WEBPACK_IMPORTED_MODULE_0__["TemplateRef"]) ], NgTemplateOutlet.prototype, "ngTemplateOutlet", void 0); NgTemplateOutlet = Object(tslib__WEBPACK_IMPORTED_MODULE_1__["__decorate"])([ Object(_angular_core__WEBPACK_IMPORTED_MODULE_0__["Directive"])({ selector: '[ngTemplateOutlet]' }), Object(tslib__WEBPACK_IMPORTED_MODULE_1__["__metadata"])("design:paramtypes", [_angular_core__WEBPACK_IMPORTED_MODULE_0__["ViewContainerRef"]]) ], NgTemplateOutlet); return NgTemplateOutlet; }()); /** * @license * Copyright Google Inc. All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ /** * A collection of Angular directives that are likely to be used in each and every Angular * application. */ var COMMON_DIRECTIVES = [ NgClass, NgComponentOutlet, NgForOf, NgIf, NgTemplateOutlet, NgStyle, NgSwitch, NgSwitchCase, NgSwitchDefault, NgPlural, NgPluralCase, ]; /** * @license * Copyright Google Inc. All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ function invalidPipeArgumentError(type, value) { return Error("InvalidPipeArgument: '" + value + "' for pipe '" + Object(_angular_core__WEBPACK_IMPORTED_MODULE_0__["ɵstringify"])(type) + "'"); } var NumberFormatter = /** @class */ (function () { function NumberFormatter() { } NumberFormatter.format = function (num, locale, style, opts) { if (opts === void 0) { opts = {}; } var minimumIntegerDigits = opts.minimumIntegerDigits, minimumFractionDigits = opts.minimumFractionDigits, maximumFractionDigits = opts.maximumFractionDigits, currency = opts.currency, _a = opts.currencyAsSymbol, currencyAsSymbol = _a === void 0 ? false : _a; var options = { minimumIntegerDigits: minimumIntegerDigits, minimumFractionDigits: minimumFractionDigits, maximumFractionDigits: maximumFractionDigits, style: NumberFormatStyle[style].toLowerCase() }; if (style == NumberFormatStyle.Currency) { options.currency = typeof currency == 'string' ? currency : undefined; options.currencyDisplay = currencyAsSymbol ? 'symbol' : 'code'; } return new Intl.NumberFormat(locale, options).format(num); }; return NumberFormatter; }()); var DATE_FORMATS_SPLIT$1 = /((?:[^yMLdHhmsazZEwGjJ']+)|(?:'(?:[^']|'')*')|(?:E+|y+|M+|L+|d+|H+|h+|J+|j+|m+|s+|a|z|Z|G+|w+))(.*)/; var PATTERN_ALIASES = { // Keys are quoted so they do not get renamed during closure compilation. 'yMMMdjms': datePartGetterFactory(combine([ digitCondition('year', 1), nameCondition('month', 3), digitCondition('day', 1), digitCondition('hour', 1), digitCondition('minute', 1), digitCondition('second', 1), ])), 'yMdjm': datePartGetterFactory(combine([ digitCondition('year', 1), digitCondition('month', 1), digitCondition('day', 1), digitCondition('hour', 1), digitCondition('minute', 1) ])), 'yMMMMEEEEd': datePartGetterFactory(combine([ digitCondition('year', 1), nameCondition('month', 4), nameCondition('weekday', 4), digitCondition('day', 1) ])), 'yMMMMd': datePartGetterFactory(combine([digitCondition('year', 1), nameCondition('month', 4), digitCondition('day', 1)])), 'yMMMd': datePartGetterFactory(combine([digitCondition('year', 1), nameCondition('month', 3), digitCondition('day', 1)])), 'yMd': datePartGetterFactory(combine([digitCondition('year', 1), digitCondition('month', 1), digitCondition('day', 1)])), 'jms': datePartGetterFactory(combine([digitCondition('hour', 1), digitCondition('second', 1), digitCondition('minute', 1)])), 'jm': datePartGetterFactory(combine([digitCondition('hour', 1), digitCondition('minute', 1)])) }; var DATE_FORMATS$1 = { // Keys are quoted so they do not get renamed. 'yyyy': datePartGetterFactory(digitCondition('year', 4)), 'yy': datePartGetterFactory(digitCondition('year', 2)), 'y': datePartGetterFactory(digitCondition('year', 1)), 'MMMM': datePartGetterFactory(nameCondition('month', 4)), 'MMM': datePartGetterFactory(nameCondition('month', 3)), 'MM': datePartGetterFactory(digitCondition('month', 2)), 'M': datePartGetterFactory(digitCondition('month', 1)), 'LLLL': datePartGetterFactory(nameCondition('month', 4)), 'L': datePartGetterFactory(nameCondition('month', 1)), 'dd': datePartGetterFactory(digitCondition('day', 2)), 'd': datePartGetterFactory(digitCondition('day', 1)), 'HH': digitModifier(hourExtractor(datePartGetterFactory(hour12Modify(digitCondition('hour', 2), false)))), 'H': hourExtractor(datePartGetterFactory(hour12Modify(digitCondition('hour', 1), false))), 'hh': digitModifier(hourExtractor(datePartGetterFactory(hour12Modify(digitCondition('hour', 2), true)))), 'h': hourExtractor(datePartGetterFactory(hour12Modify(digitCondition('hour', 1), true))), 'jj': datePartGetterFactory(digitCondition('hour', 2)), 'j': datePartGetterFactory(digitCondition('hour', 1)), 'mm': digitModifier(datePartGetterFactory(digitCondition('minute', 2))), 'm': datePartGetterFactory(digitCondition('minute', 1)), 'ss': digitModifier(datePartGetterFactory(digitCondition('second', 2))), 's': datePartGetterFactory(digitCondition('second', 1)), // while ISO 8601 requires fractions to be prefixed with `.` or `,` // we can be just safely rely on using `sss` since we currently don't support single or two digit // fractions 'sss': datePartGetterFactory(digitCondition('second', 3)), 'EEEE': datePartGetterFactory(nameCondition('weekday', 4)), 'EEE': datePartGetterFactory(nameCondition('weekday', 3)), 'EE': datePartGetterFactory(nameCondition('weekday', 2)), 'E': datePartGetterFactory(nameCondition('weekday', 1)), 'a': hourClockExtractor(datePartGetterFactory(hour12Modify(digitCondition('hour', 1), true))), 'Z': timeZoneGetter$1('short'), 'z': timeZoneGetter$1('long'), 'ww': datePartGetterFactory({}), // first Thursday of the year. not support ? 'w': datePartGetterFactory({}), // of the year not support ? 'G': datePartGetterFactory(nameCondition('era', 1)), 'GG': datePartGetterFactory(nameCondition('era', 2)), 'GGG': datePartGetterFactory(nameCondition('era', 3)), 'GGGG': datePartGetterFactory(nameCondition('era', 4)) }; function digitModifier(inner) { return function (date, locale) { var result = inner(date, locale); return result.length == 1 ? '0' + result : result; }; } function hourClockExtractor(inner) { return function (date, locale) { return inner(date, locale).split(' ')[1]; }; } function hourExtractor(inner) { return function (date, locale) { return inner(date, locale).split(' ')[0]; }; } function intlDateFormat(date, locale, options) { return new Intl.DateTimeFormat(locale, options).format(date).replace(/[\u200e\u200f]/g, ''); } function timeZoneGetter$1(timezone) { // To workaround `Intl` API restriction for single timezone let format with 24 hours var options = { hour: '2-digit', hour12: false, timeZoneName: timezone }; return function (date, locale) { var result = intlDateFormat(date, locale, options); // Then extract first 3 letters that related to hours return result ? result.substring(3) : ''; }; } function hour12Modify(options, value) { options.hour12 = value; return options; } function digitCondition(prop, len) { var result = {}; result[prop] = len === 2 ? '2-digit' : 'numeric'; return result; } function nameCondition(prop, len) { var result = {}; if (len < 4) { result[prop] = len > 1 ? 'short' : 'narrow'; } else { result[prop] = 'long'; } return result; } function combine(options) { return options.reduce(function (merged, opt) { return (Object(tslib__WEBPACK_IMPORTED_MODULE_1__["__assign"])({}, merged, opt)); }, {}); } function datePartGetterFactory(ret) { return function (date, locale) { return intlDateFormat(date, locale, ret); }; } var DATE_FORMATTER_CACHE = new Map(); function dateFormatter(format, date, locale) { var fn = PATTERN_ALIASES[format]; if (fn) return fn(date, locale); var cacheKey = format; var parts = DATE_FORMATTER_CACHE.get(cacheKey); if (!parts) { parts = []; var match = void 0; DATE_FORMATS_SPLIT$1.exec(format); var _format = format; while (_format) { match = DATE_FORMATS_SPLIT$1.exec(_format); if (match) { parts = parts.concat(match.slice(1)); _format = parts.pop(); } else { parts.push(_format); _format = null; } } DATE_FORMATTER_CACHE.set(cacheKey, parts); } return parts.reduce(function (text, part) { var fn = DATE_FORMATS$1[part]; return text + (fn ? fn(date, locale) : partToTime(part)); }, ''); } function partToTime(part) { return part === '\'\'' ? '\'' : part.replace(/(^'|'$)/g, '').replace(/''/g, '\''); } var DateFormatter = /** @class */ (function () { function DateFormatter() { } DateFormatter.format = function (date, locale, pattern) { return dateFormatter(pattern, date, locale); }; return DateFormatter; }()); /** * @license * Copyright Google Inc. All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ /** * @ngModule CommonModule * @description * * Formats a date according to locale rules. * * Where: * - `expression` is a date object or a number (milliseconds since UTC epoch) or an ISO string * (https://www.w3.org/TR/NOTE-datetime). * - `format` indicates which date/time components to include. The format can be predefined as * shown below or custom as shown in the table. * - `'medium'`: equivalent to `'yMMMdjms'` (e.g. `Sep 3, 2010, 12:05:08 PM` for `en-US`) * - `'short'`: equivalent to `'yMdjm'` (e.g. `9/3/2010, 12:05 PM` for `en-US`) * - `'fullDate'`: equivalent to `'yMMMMEEEEd'` (e.g. `Friday, September 3, 2010` for `en-US`) * - `'longDate'`: equivalent to `'yMMMMd'` (e.g. `September 3, 2010` for `en-US`) * - `'mediumDate'`: equivalent to `'yMMMd'` (e.g. `Sep 3, 2010` for `en-US`) * - `'shortDate'`: equivalent to `'yMd'` (e.g. `9/3/2010` for `en-US`) * - `'mediumTime'`: equivalent to `'jms'` (e.g. `12:05:08 PM` for `en-US`) * - `'shortTime'`: equivalent to `'jm'` (e.g. `12:05 PM` for `en-US`) * * * | Component | Symbol | Narrow | Short Form | Long Form | Numeric | 2-digit | * |-----------|:------:|--------|--------------|-------------------|-----------|-----------| * | era | G | G (A) | GGG (AD) | GGGG (Anno Domini)| - | - | * | year | y | - | - | - | y (2015) | yy (15) | * | month | M | L (S) | MMM (Sep) | MMMM (September) | M (9) | MM (09) | * | day | d | - | - | - | d (3) | dd (03) | * | weekday | E | E (S) | EEE (Sun) | EEEE (Sunday) | - | - | * | hour | j | - | - | - | j (13) | jj (13) | * | hour12 | h | - | - | - | h (1 PM) | hh (01 PM)| * | hour24 | H | - | - | - | H (13) | HH (13) | * | minute | m | - | - | - | m (5) | mm (05) | * | second | s | - | - | - | s (9) | ss (09) | * | timezone | z | - | - | z (Pacific Standard Time)| - | - | * | timezone | Z | - | Z (GMT-8:00) | - | - | - | * | timezone | a | - | a (PM) | - | - | - | * * In javascript, only the components specified will be respected (not the ordering, * punctuations, ...) and details of the formatting will be dependent on the locale. * * Timezone of the formatted text will be the local system timezone of the end-user's machine. * * When the expression is a ISO string without time (e.g. 2016-09-19) the time zone offset is not * applied and the formatted text will have the same day, month and year of the expression. * * WARNINGS: * - this pipe is marked as pure hence it will not be re-evaluated when the input is mutated. * Instead users should treat the date as an immutable object and change the reference when the * pipe needs to re-run (this is to avoid reformatting the date on every change detection run * which would be an expensive operation). * - this pipe uses the Internationalization API. Therefore it is only reliable in Chrome and Opera * browsers. * * @usageNotes * * ### Examples * * Assuming `dateObj` is (year: 2010, month: 9, day: 3, hour: 12 PM, minute: 05, second: 08) * in the _local_ time and locale is 'en-US': * * {@example common/pipes/ts/date_pipe.ts region='DeprecatedDatePipe'} * * @publicApi */ var DeprecatedDatePipe = /** @class */ (function () { function DeprecatedDatePipe(_locale) { this._locale = _locale; } DeprecatedDatePipe_1 = DeprecatedDatePipe; DeprecatedDatePipe.prototype.transform = function (value, pattern) { if (pattern === void 0) { pattern = 'mediumDate'; } if (value == null || value === '' || value !== value) return null; var date; if (typeof value === 'string') { value = value.trim(); } if (isDate$1(value)) { date = value; } else if (!isNaN(value - parseFloat(value))) { date = new Date(parseFloat(value)); } else if (typeof value === 'string' && /^(\d{4}-\d{1,2}-\d{1,2})$/.test(value)) { /** * For ISO Strings without time the day, month and year must be extracted from the ISO String * before Date creation to avoid time offset and errors in the new Date. * If we only replace '-' with ',' in the ISO String ("2015,01,01"), and try to create a new * date, some browsers (e.g. IE 9) will throw an invalid Date error * If we leave the '-' ("2015-01-01") and try to create a new Date("2015-01-01") the * timeoffset * is applied * Note: ISO months are 0 for January, 1 for February, ... */ var _a = Object(tslib__WEBPACK_IMPORTED_MODULE_1__["__read"])(value.split('-').map(function (val) { return parseInt(val, 10); }), 3), y = _a[0], m = _a[1], d = _a[2]; date = new Date(y, m - 1, d); } else { date = new Date(value); } if (!isDate$1(date)) { var match = void 0; if ((typeof value === 'string') && (match = value.match(ISO8601_DATE_REGEX))) { date = isoStringToDate(match); } else { throw invalidPipeArgumentError(DeprecatedDatePipe_1, value); } } return DateFormatter.format(date, this._locale, DeprecatedDatePipe_1._ALIASES[pattern] || pattern); }; var DeprecatedDatePipe_1; /** @internal */ DeprecatedDatePipe._ALIASES = { 'medium': 'yMMMdjms', 'short': 'yMdjm', 'fullDate': 'yMMMMEEEEd', 'longDate': 'yMMMMd', 'mediumDate': 'yMMMd', 'shortDate': 'yMd', 'mediumTime': 'jms', 'shortTime': 'jm' }; DeprecatedDatePipe = DeprecatedDatePipe_1 = Object(tslib__WEBPACK_IMPORTED_MODULE_1__["__decorate"])([ Object(_angular_core__WEBPACK_IMPORTED_MODULE_0__["Pipe"])({ name: 'date', pure: true }), Object(tslib__WEBPACK_IMPORTED_MODULE_1__["__param"])(0, Object(_angular_core__WEBPACK_IMPORTED_MODULE_0__["Inject"])(_angular_core__WEBPACK_IMPORTED_MODULE_0__["LOCALE_ID"])), Object(tslib__WEBPACK_IMPORTED_MODULE_1__["__metadata"])("design:paramtypes", [String]) ], DeprecatedDatePipe); return DeprecatedDatePipe; }()); function isDate$1(value) { return value instanceof Date && !isNaN(value.valueOf()); } /** * @license * Copyright Google Inc. All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ function formatNumber$1(pipe, locale, value, style, digits, currency, currencyAsSymbol) { if (currency === void 0) { currency = null; } if (currencyAsSymbol === void 0) { currencyAsSymbol = false; } if (value == null) return null; // Convert strings to numbers value = typeof value === 'string' && !isNaN(+value - parseFloat(value)) ? +value : value; if (typeof value !== 'number') { throw invalidPipeArgumentError(pipe, value); } var minInt; var minFraction; var maxFraction; if (style !== NumberFormatStyle.Currency) { // rely on Intl default for currency minInt = 1; minFraction = 0; maxFraction = 3; } if (digits) { var parts = digits.match(NUMBER_FORMAT_REGEXP); if (parts === null) { throw new Error(digits + " is not a valid digit info for number pipes"); } if (parts[1] != null) { // min integer digits minInt = parseIntAutoRadix(parts[1]); } if (parts[3] != null) { // min fraction digits minFraction = parseIntAutoRadix(parts[3]); } if (parts[5] != null) { // max fraction digits maxFraction = parseIntAutoRadix(parts[5]); } } return NumberFormatter.format(value, locale, style, { minimumIntegerDigits: minInt, minimumFractionDigits: minFraction, maximumFractionDigits: maxFraction, currency: currency, currencyAsSymbol: currencyAsSymbol, }); } /** * Formats a number as text. Group sizing and separator and other locale-specific * configurations are based on the active locale. * * where `expression` is a number: * - `digitInfo` is a `string` which has a following format:
    * {minIntegerDigits}.{minFractionDigits}-{maxFractionDigits} * - `minIntegerDigits` is the minimum number of integer digits to use. Defaults to `1`. * - `minFractionDigits` is the minimum number of digits after fraction. Defaults to `0`. * - `maxFractionDigits` is the maximum number of digits after fraction. Defaults to `3`. * * For more information on the acceptable range for each of these numbers and other * details see your native internationalization library. * * WARNING: this pipe uses the Internationalization API which is not yet available in all browsers * and may require a polyfill. See [Browser Support](guide/browser-support) for details. * * @usageNotes * * ### Example * * {@example common/pipes/ts/number_pipe.ts region='DeprecatedNumberPipe'} * * @ngModule CommonModule * @publicApi */ var DeprecatedDecimalPipe = /** @class */ (function () { function DeprecatedDecimalPipe(_locale) { this._locale = _locale; } DeprecatedDecimalPipe_1 = DeprecatedDecimalPipe; DeprecatedDecimalPipe.prototype.transform = function (value, digits) { return formatNumber$1(DeprecatedDecimalPipe_1, this._locale, value, NumberFormatStyle.Decimal, digits); }; var DeprecatedDecimalPipe_1; DeprecatedDecimalPipe = DeprecatedDecimalPipe_1 = Object(tslib__WEBPACK_IMPORTED_MODULE_1__["__decorate"])([ Object(_angular_core__WEBPACK_IMPORTED_MODULE_0__["Pipe"])({ name: 'number' }), Object(tslib__WEBPACK_IMPORTED_MODULE_1__["__param"])(0, Object(_angular_core__WEBPACK_IMPORTED_MODULE_0__["Inject"])(_angular_core__WEBPACK_IMPORTED_MODULE_0__["LOCALE_ID"])), Object(tslib__WEBPACK_IMPORTED_MODULE_1__["__metadata"])("design:paramtypes", [String]) ], DeprecatedDecimalPipe); return DeprecatedDecimalPipe; }()); /** * @ngModule CommonModule * * @description * * Formats a number as percentage according to locale rules. * * - `digitInfo` See {@link DecimalPipe} for detailed description. * * WARNING: this pipe uses the Internationalization API which is not yet available in all browsers * and may require a polyfill. See [Browser Support](guide/browser-support) for details. * * @usageNotes * * ### Example * * {@example common/pipes/ts/percent_pipe.ts region='DeprecatedPercentPipe'} * * @publicApi */ var DeprecatedPercentPipe = /** @class */ (function () { function DeprecatedPercentPipe(_locale) { this._locale = _locale; } DeprecatedPercentPipe_1 = DeprecatedPercentPipe; DeprecatedPercentPipe.prototype.transform = function (value, digits) { return formatNumber$1(DeprecatedPercentPipe_1, this._locale, value, NumberFormatStyle.Percent, digits); }; var DeprecatedPercentPipe_1; DeprecatedPercentPipe = DeprecatedPercentPipe_1 = Object(tslib__WEBPACK_IMPORTED_MODULE_1__["__decorate"])([ Object(_angular_core__WEBPACK_IMPORTED_MODULE_0__["Pipe"])({ name: 'percent' }), Object(tslib__WEBPACK_IMPORTED_MODULE_1__["__param"])(0, Object(_angular_core__WEBPACK_IMPORTED_MODULE_0__["Inject"])(_angular_core__WEBPACK_IMPORTED_MODULE_0__["LOCALE_ID"])), Object(tslib__WEBPACK_IMPORTED_MODULE_1__["__metadata"])("design:paramtypes", [String]) ], DeprecatedPercentPipe); return DeprecatedPercentPipe; }()); /** * @ngModule CommonModule * @description * * Formats a number as currency using locale rules. * * Use `currency` to format a number as currency. * * - `currencyCode` is the [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) currency code, such * as `USD` for the US dollar and `EUR` for the euro. * - `symbolDisplay` is a boolean indicating whether to use the currency symbol or code. * - `true`: use symbol (e.g. `$`). * - `false`(default): use code (e.g. `USD`). * - `digitInfo` See {@link DecimalPipe} for detailed description. * * WARNING: this pipe uses the Internationalization API which is not yet available in all browsers * and may require a polyfill. See [Browser Support](guide/browser-support) for details. * * @usageNotes * * ### Example * * {@example common/pipes/ts/currency_pipe.ts region='DeprecatedCurrencyPipe'} * * @publicApi */ var DeprecatedCurrencyPipe = /** @class */ (function () { function DeprecatedCurrencyPipe(_locale) { this._locale = _locale; } DeprecatedCurrencyPipe_1 = DeprecatedCurrencyPipe; DeprecatedCurrencyPipe.prototype.transform = function (value, currencyCode, symbolDisplay, digits) { if (currencyCode === void 0) { currencyCode = 'USD'; } if (symbolDisplay === void 0) { symbolDisplay = false; } return formatNumber$1(DeprecatedCurrencyPipe_1, this._locale, value, NumberFormatStyle.Currency, digits, currencyCode, symbolDisplay); }; var DeprecatedCurrencyPipe_1; DeprecatedCurrencyPipe = DeprecatedCurrencyPipe_1 = Object(tslib__WEBPACK_IMPORTED_MODULE_1__["__decorate"])([ Object(_angular_core__WEBPACK_IMPORTED_MODULE_0__["Pipe"])({ name: 'currency' }), Object(tslib__WEBPACK_IMPORTED_MODULE_1__["__param"])(0, Object(_angular_core__WEBPACK_IMPORTED_MODULE_0__["Inject"])(_angular_core__WEBPACK_IMPORTED_MODULE_0__["LOCALE_ID"])), Object(tslib__WEBPACK_IMPORTED_MODULE_1__["__metadata"])("design:paramtypes", [String]) ], DeprecatedCurrencyPipe); return DeprecatedCurrencyPipe; }()); /** * @license * Copyright Google Inc. All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ /** * A collection of deprecated i18n pipes that require intl api * * @deprecated from v5 */ var COMMON_DEPRECATED_I18N_PIPES = [DeprecatedDecimalPipe, DeprecatedPercentPipe, DeprecatedCurrencyPipe, DeprecatedDatePipe]; /** * @license * Copyright Google Inc. All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ var ObservableStrategy = /** @class */ (function () { function ObservableStrategy() { } ObservableStrategy.prototype.createSubscription = function (async, updateLatestValue) { return async.subscribe({ next: updateLatestValue, error: function (e) { throw e; } }); }; ObservableStrategy.prototype.dispose = function (subscription) { subscription.unsubscribe(); }; ObservableStrategy.prototype.onDestroy = function (subscription) { subscription.unsubscribe(); }; return ObservableStrategy; }()); var PromiseStrategy = /** @class */ (function () { function PromiseStrategy() { } PromiseStrategy.prototype.createSubscription = function (async, updateLatestValue) { return async.then(updateLatestValue, function (e) { throw e; }); }; PromiseStrategy.prototype.dispose = function (subscription) { }; PromiseStrategy.prototype.onDestroy = function (subscription) { }; return PromiseStrategy; }()); var _promiseStrategy = new PromiseStrategy(); var _observableStrategy = new ObservableStrategy(); /** * @ngModule CommonModule * @description * * Unwraps a value from an asynchronous primitive. * * The `async` pipe subscribes to an `Observable` or `Promise` and returns the latest value it has * emitted. When a new value is emitted, the `async` pipe marks the component to be checked for * changes. When the component gets destroyed, the `async` pipe unsubscribes automatically to avoid * potential memory leaks. * * @usageNotes * * ### Examples * * This example binds a `Promise` to the view. Clicking the `Resolve` button resolves the * promise. * * {@example common/pipes/ts/async_pipe.ts region='AsyncPipePromise'} * * It's also possible to use `async` with Observables. The example below binds the `time` Observable * to the view. The Observable continuously updates the view with the current time. * * {@example common/pipes/ts/async_pipe.ts region='AsyncPipeObservable'} * * @publicApi */ var AsyncPipe = /** @class */ (function () { function AsyncPipe(_ref) { this._ref = _ref; this._latestValue = null; this._latestReturnedValue = null; this._subscription = null; this._obj = null; this._strategy = null; } AsyncPipe_1 = AsyncPipe; AsyncPipe.prototype.ngOnDestroy = function () { if (this._subscription) { this._dispose(); } }; AsyncPipe.prototype.transform = function (obj) { if (!this._obj) { if (obj) { this._subscribe(obj); } this._latestReturnedValue = this._latestValue; return this._latestValue; } if (obj !== this._obj) { this._dispose(); return this.transform(obj); } if (this._latestValue === this._latestReturnedValue) { return this._latestReturnedValue; } this._latestReturnedValue = this._latestValue; return _angular_core__WEBPACK_IMPORTED_MODULE_0__["WrappedValue"].wrap(this._latestValue); }; AsyncPipe.prototype._subscribe = function (obj) { var _this = this; this._obj = obj; this._strategy = this._selectStrategy(obj); this._subscription = this._strategy.createSubscription(obj, function (value) { return _this._updateLatestValue(obj, value); }); }; AsyncPipe.prototype._selectStrategy = function (obj) { if (Object(_angular_core__WEBPACK_IMPORTED_MODULE_0__["ɵisPromise"])(obj)) { return _promiseStrategy; } if (Object(_angular_core__WEBPACK_IMPORTED_MODULE_0__["ɵisObservable"])(obj)) { return _observableStrategy; } throw invalidPipeArgumentError(AsyncPipe_1, obj); }; AsyncPipe.prototype._dispose = function () { this._strategy.dispose(this._subscription); this._latestValue = null; this._latestReturnedValue = null; this._subscription = null; this._obj = null; }; AsyncPipe.prototype._updateLatestValue = function (async, value) { if (async === this._obj) { this._latestValue = value; this._ref.markForCheck(); } }; var AsyncPipe_1; AsyncPipe = AsyncPipe_1 = Object(tslib__WEBPACK_IMPORTED_MODULE_1__["__decorate"])([ Object(_angular_core__WEBPACK_IMPORTED_MODULE_0__["Pipe"])({ name: 'async', pure: false }), Object(tslib__WEBPACK_IMPORTED_MODULE_1__["__metadata"])("design:paramtypes", [_angular_core__WEBPACK_IMPORTED_MODULE_0__["ChangeDetectorRef"]]) ], AsyncPipe); return AsyncPipe; }()); /** * @license * Copyright Google Inc. All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ /** * Transforms text to all lower case. * * @see `UpperCasePipe` * @see `TitleCasePipe` * @usageNotes * * The following example defines a view that allows the user to enter * text, and then uses the pipe to convert the input text to all lower case. * * * * @ngModule CommonModule * @publicApi */ var LowerCasePipe = /** @class */ (function () { function LowerCasePipe() { } LowerCasePipe_1 = LowerCasePipe; /** * @param value The string to transform to lower case. */ LowerCasePipe.prototype.transform = function (value) { if (!value) return value; if (typeof value !== 'string') { throw invalidPipeArgumentError(LowerCasePipe_1, value); } return value.toLowerCase(); }; var LowerCasePipe_1; LowerCasePipe = LowerCasePipe_1 = Object(tslib__WEBPACK_IMPORTED_MODULE_1__["__decorate"])([ Object(_angular_core__WEBPACK_IMPORTED_MODULE_0__["Pipe"])({ name: 'lowercase' }) ], LowerCasePipe); return LowerCasePipe; }()); // // Regex below matches any Unicode word and compatible with ES5. In ES2018 the same result // can be achieved by using /\p{L}\S*/gu and also known as Unicode Property Escapes // (http://2ality.com/2017/07/regexp-unicode-property-escapes.html). Since there is no // transpilation of this functionality down to ES5 without external tool, the only solution is // to use already transpiled form. Example can be found here - // https://mothereff.in/regexpu#input=var+regex+%3D+/%5Cp%7BL%7D/u%3B&unicodePropertyEscape=1 // var unicodeWordMatch = /(?:[A-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\u0561-\u0587\u05D0-\u05EA\u05F0-\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\u08A0-\u08B4\u08B6-\u08BD\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\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\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\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\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-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\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-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\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-\u2C2E\u2C30-\u2C5E\u2C60-\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-\u312E\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FEA\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AE\uA7B0-\uA7B7\uA7F7-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\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-\uAB65\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\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\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-\uDE33\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\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\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDF00-\uDF19]|\uD806[\uDCA0-\uDCDF\uDCFF\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE83\uDE86-\uDE89\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46]|\uD808[\uDC00-\uDF99]|\uD809[\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50\uDF93-\uDF9F\uDFE0\uDFE1]|\uD821[\uDC00-\uDFEC]|\uD822[\uDC00-\uDEF2]|\uD82C[\uDC00-\uDD1E\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]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43]|\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-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D])\S*/g; /** * Transforms text to title case. * Capitalizes the first letter of each word, and transforms the * rest of the word to lower case. * Words are delimited by any whitespace character, such as a space, tab, or line-feed character. * * @see `LowerCasePipe` * @see `UpperCasePipe` * * @usageNotes * The following example shows the result of transforming various strings into title case. * * * * @ngModule CommonModule * @publicApi */ var TitleCasePipe = /** @class */ (function () { function TitleCasePipe() { } TitleCasePipe_1 = TitleCasePipe; /** * @param value The string to transform to title case. */ TitleCasePipe.prototype.transform = function (value) { if (!value) return value; if (typeof value !== 'string') { throw invalidPipeArgumentError(TitleCasePipe_1, value); } return value.replace(unicodeWordMatch, (function (txt) { return txt[0].toUpperCase() + txt.substr(1).toLowerCase(); })); }; var TitleCasePipe_1; TitleCasePipe = TitleCasePipe_1 = Object(tslib__WEBPACK_IMPORTED_MODULE_1__["__decorate"])([ Object(_angular_core__WEBPACK_IMPORTED_MODULE_0__["Pipe"])({ name: 'titlecase' }) ], TitleCasePipe); return TitleCasePipe; }()); /** * Transforms text to all upper case. * @see `LowerCasePipe` * @see `TitleCasePipe` * * @ngModule CommonModule * @publicApi */ var UpperCasePipe = /** @class */ (function () { function UpperCasePipe() { } UpperCasePipe_1 = UpperCasePipe; /** * @param value The string to transform to upper case. */ UpperCasePipe.prototype.transform = function (value) { if (!value) return value; if (typeof value !== 'string') { throw invalidPipeArgumentError(UpperCasePipe_1, value); } return value.toUpperCase(); }; var UpperCasePipe_1; UpperCasePipe = UpperCasePipe_1 = Object(tslib__WEBPACK_IMPORTED_MODULE_1__["__decorate"])([ Object(_angular_core__WEBPACK_IMPORTED_MODULE_0__["Pipe"])({ name: 'uppercase' }) ], UpperCasePipe); return UpperCasePipe; }()); /** * @license * Copyright Google Inc. All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ // clang-format off /** * @ngModule CommonModule * @description * * Formats a date value according to locale rules. * * Only the `en-US` locale data comes with Angular. To localize dates * in another language, you must import the corresponding locale data. * See the [I18n guide](guide/i18n#i18n-pipes) for more information. * * @see `formatDate()` * * * @usageNotes * * The result of this pipe is not reevaluated when the input is mutated. To avoid the need to * reformat the date on every change-detection cycle, treat the date as an immutable object * and change the reference when the pipe needs to run again. * * ### Pre-defined format options * * Examples are given in `en-US` locale. * * - `'short'`: equivalent to `'M/d/yy, h:mm a'` (`6/15/15, 9:03 AM`). * - `'medium'`: equivalent to `'MMM d, y, h:mm:ss a'` (`Jun 15, 2015, 9:03:01 AM`). * - `'long'`: equivalent to `'MMMM d, y, h:mm:ss a z'` (`June 15, 2015 at 9:03:01 AM * GMT+1`). * - `'full'`: equivalent to `'EEEE, MMMM d, y, h:mm:ss a zzzz'` (`Monday, June 15, 2015 at * 9:03:01 AM GMT+01:00`). * - `'shortDate'`: equivalent to `'M/d/yy'` (`6/15/15`). * - `'mediumDate'`: equivalent to `'MMM d, y'` (`Jun 15, 2015`). * - `'longDate'`: equivalent to `'MMMM d, y'` (`June 15, 2015`). * - `'fullDate'`: equivalent to `'EEEE, MMMM d, y'` (`Monday, June 15, 2015`). * - `'shortTime'`: equivalent to `'h:mm a'` (`9:03 AM`). * - `'mediumTime'`: equivalent to `'h:mm:ss a'` (`9:03:01 AM`). * - `'longTime'`: equivalent to `'h:mm:ss a z'` (`9:03:01 AM GMT+1`). * - `'fullTime'`: equivalent to `'h:mm:ss a zzzz'` (`9:03:01 AM GMT+01:00`). * * ### Custom format options * * You can construct a format string using symbols to specify the components * of a date-time value, as described in the following table. * Format details depend on the locale. * Fields marked with (*) are only available in the extra data set for the given locale. * * | Field type | Format | Description | Example Value | * |--------------------|-------------|---------------------------------------------------------------|------------------------------------------------------------| * | Era | G, GG & GGG | Abbreviated | AD | * | | GGGG | Wide | Anno Domini | * | | GGGGG | Narrow | A | * | Year | y | Numeric: minimum digits | 2, 20, 201, 2017, 20173 | * | | yy | Numeric: 2 digits + zero padded | 02, 20, 01, 17, 73 | * | | yyy | Numeric: 3 digits + zero padded | 002, 020, 201, 2017, 20173 | * | | yyyy | Numeric: 4 digits or more + zero padded | 0002, 0020, 0201, 2017, 20173 | * | Month | M | Numeric: 1 digit | 9, 12 | * | | MM | Numeric: 2 digits + zero padded | 09, 12 | * | | MMM | Abbreviated | Sep | * | | MMMM | Wide | September | * | | MMMMM | Narrow | S | * | Month standalone | L | Numeric: 1 digit | 9, 12 | * | | LL | Numeric: 2 digits + zero padded | 09, 12 | * | | LLL | Abbreviated | Sep | * | | LLLL | Wide | September | * | | LLLLL | Narrow | S | * | Week of year | w | Numeric: minimum digits | 1... 53 | * | | ww | Numeric: 2 digits + zero padded | 01... 53 | * | Week of month | W | Numeric: 1 digit | 1... 5 | * | Day of month | d | Numeric: minimum digits | 1 | * | | dd | Numeric: 2 digits + zero padded | 01 | * | Week day | E, EE & EEE | Abbreviated | Tue | * | | EEEE | Wide | Tuesday | * | | EEEEE | Narrow | T | * | | EEEEEE | Short | Tu | * | Period | a, aa & aaa | Abbreviated | am/pm or AM/PM | * | | aaaa | Wide (fallback to `a` when missing) | ante meridiem/post meridiem | * | | aaaaa | Narrow | a/p | * | Period* | B, BB & BBB | Abbreviated | mid. | * | | BBBB | Wide | am, pm, midnight, noon, morning, afternoon, evening, night | * | | BBBBB | Narrow | md | * | Period standalone* | b, bb & bbb | Abbreviated | mid. | * | | bbbb | Wide | am, pm, midnight, noon, morning, afternoon, evening, night | * | | bbbbb | Narrow | md | * | Hour 1-12 | h | Numeric: minimum digits | 1, 12 | * | | hh | Numeric: 2 digits + zero padded | 01, 12 | * | Hour 0-23 | H | Numeric: minimum digits | 0, 23 | * | | HH | Numeric: 2 digits + zero padded | 00, 23 | * | Minute | m | Numeric: minimum digits | 8, 59 | * | | mm | Numeric: 2 digits + zero padded | 08, 59 | * | Second | s | Numeric: minimum digits | 0... 59 | * | | ss | Numeric: 2 digits + zero padded | 00... 59 | * | Fractional seconds | S | Numeric: 1 digit | 0... 9 | * | | SS | Numeric: 2 digits + zero padded | 00... 99 | * | | SSS | Numeric: 3 digits + zero padded (= milliseconds) | 000... 999 | * | Zone | z, zz & zzz | Short specific non location format (fallback to O) | GMT-8 | * | | zzzz | Long specific non location format (fallback to OOOO) | GMT-08:00 | * | | Z, ZZ & ZZZ | ISO8601 basic format | -0800 | * | | ZZZZ | Long localized GMT format | GMT-8:00 | * | | ZZZZZ | ISO8601 extended format + Z indicator for offset 0 (= XXXXX) | -08:00 | * | | O, OO & OOO | Short localized GMT format | GMT-8 | * | | OOOO | Long localized GMT format | GMT-08:00 | * * Note that timezone correction is not applied to an ISO string that has no time component, such as "2016-09-19" * * ### Format examples * * These examples transform a date into various formats, * assuming that `dateObj` is a JavaScript `Date` object for * year: 2015, month: 6, day: 15, hour: 21, minute: 43, second: 11, * given in the local time for the `en-US` locale. * * ``` * {{ dateObj | date }} // output is 'Jun 15, 2015' * {{ dateObj | date:'medium' }} // output is 'Jun 15, 2015, 9:43:11 PM' * {{ dateObj | date:'shortTime' }} // output is '9:43 PM' * {{ dateObj | date:'mmss' }} // output is '43:11' * ``` * * ### Usage example * * The following component uses a date pipe to display the current date in different formats. * * ``` * @Component({ * selector: 'date-pipe', * template: `
    *

    Today is {{today | date}}

    *

    Or if you prefer, {{today | date:'fullDate'}}

    *

    The time is {{today | date:'h:mm a z'}}

    *
    ` * }) * // Get the current date and time as a date-time value. * export class DatePipeComponent { * today: number = Date.now(); * } * ``` * * @publicApi */ // clang-format on var DatePipe = /** @class */ (function () { function DatePipe(locale) { this.locale = locale; } DatePipe_1 = DatePipe; /** * @param value The date expression: a `Date` object, a number * (milliseconds since UTC epoch), or an ISO string (https://www.w3.org/TR/NOTE-datetime). * @param format The date/time components to include, using predefined options or a * custom format string. * @param timezone A timezone offset (such as `'+0430'`), or a standard * UTC/GMT or continental US timezone abbreviation. Default is * the local system timezone of the end-user's machine. * @param locale A locale code for the locale format rules to use. * When not supplied, uses the value of `LOCALE_ID`, which is `en-US` by default. * See [Setting your app locale](guide/i18n#setting-up-the-locale-of-your-app). * @returns A date string in the desired format. */ DatePipe.prototype.transform = function (value, format, timezone, locale) { if (format === void 0) { format = 'mediumDate'; } if (value == null || value === '' || value !== value) return null; try { return formatDate(value, format, locale || this.locale, timezone); } catch (error) { throw invalidPipeArgumentError(DatePipe_1, error.message); } }; var DatePipe_1; DatePipe = DatePipe_1 = Object(tslib__WEBPACK_IMPORTED_MODULE_1__["__decorate"])([ Object(_angular_core__WEBPACK_IMPORTED_MODULE_0__["Pipe"])({ name: 'date', pure: true }), Object(tslib__WEBPACK_IMPORTED_MODULE_1__["__param"])(0, Object(_angular_core__WEBPACK_IMPORTED_MODULE_0__["Inject"])(_angular_core__WEBPACK_IMPORTED_MODULE_0__["LOCALE_ID"])), Object(tslib__WEBPACK_IMPORTED_MODULE_1__["__metadata"])("design:paramtypes", [String]) ], DatePipe); return DatePipe; }()); /** * @license * Copyright Google Inc. All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ var _INTERPOLATION_REGEXP = /#/g; /** * @ngModule CommonModule * @description * * Maps a value to a string that pluralizes the value according to locale rules. * * @usageNotes * * ### Example * * {@example common/pipes/ts/i18n_pipe.ts region='I18nPluralPipeComponent'} * * @publicApi */ var I18nPluralPipe = /** @class */ (function () { function I18nPluralPipe(_localization) { this._localization = _localization; } I18nPluralPipe_1 = I18nPluralPipe; /** * @param value the number to be formatted * @param pluralMap an object that mimics the ICU format, see * http://userguide.icu-project.org/formatparse/messages. * @param locale a `string` defining the locale to use (uses the current {@link LOCALE_ID} by * default). */ I18nPluralPipe.prototype.transform = function (value, pluralMap, locale) { if (value == null) return ''; if (typeof pluralMap !== 'object' || pluralMap === null) { throw invalidPipeArgumentError(I18nPluralPipe_1, pluralMap); } var key = getPluralCategory(value, Object.keys(pluralMap), this._localization, locale); return pluralMap[key].replace(_INTERPOLATION_REGEXP, value.toString()); }; var I18nPluralPipe_1; I18nPluralPipe = I18nPluralPipe_1 = Object(tslib__WEBPACK_IMPORTED_MODULE_1__["__decorate"])([ Object(_angular_core__WEBPACK_IMPORTED_MODULE_0__["Pipe"])({ name: 'i18nPlural', pure: true }), Object(tslib__WEBPACK_IMPORTED_MODULE_1__["__metadata"])("design:paramtypes", [NgLocalization]) ], I18nPluralPipe); return I18nPluralPipe; }()); /** * @license * Copyright Google Inc. All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ /** * @ngModule CommonModule * @description * * Generic selector that displays the string that matches the current value. * * If none of the keys of the `mapping` match the `value`, then the content * of the `other` key is returned when present, otherwise an empty string is returned. * * @usageNotes * * ### Example * * {@example common/pipes/ts/i18n_pipe.ts region='I18nSelectPipeComponent'} * * @publicApi */ var I18nSelectPipe = /** @class */ (function () { function I18nSelectPipe() { } I18nSelectPipe_1 = I18nSelectPipe; /** * @param value a string to be internationalized. * @param mapping an object that indicates the text that should be displayed * for different values of the provided `value`. */ I18nSelectPipe.prototype.transform = function (value, mapping) { if (value == null) return ''; if (typeof mapping !== 'object' || typeof value !== 'string') { throw invalidPipeArgumentError(I18nSelectPipe_1, mapping); } if (mapping.hasOwnProperty(value)) { return mapping[value]; } if (mapping.hasOwnProperty('other')) { return mapping['other']; } return ''; }; var I18nSelectPipe_1; I18nSelectPipe = I18nSelectPipe_1 = Object(tslib__WEBPACK_IMPORTED_MODULE_1__["__decorate"])([ Object(_angular_core__WEBPACK_IMPORTED_MODULE_0__["Pipe"])({ name: 'i18nSelect', pure: true }) ], I18nSelectPipe); return I18nSelectPipe; }()); /** * @license * Copyright Google Inc. All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ /** * @ngModule CommonModule * @description * * Converts a value into its JSON-format representation. Useful for debugging. * * @usageNotes * * The following component uses a JSON pipe to convert an object * to JSON format, and displays the string in both formats for comparison. * * {@example common/pipes/ts/json_pipe.ts region='JsonPipe'} * * @publicApi */ var JsonPipe = /** @class */ (function () { function JsonPipe() { } /** * @param value A value of any type to convert into a JSON-format string. */ JsonPipe.prototype.transform = function (value) { return JSON.stringify(value, null, 2); }; JsonPipe = Object(tslib__WEBPACK_IMPORTED_MODULE_1__["__decorate"])([ Object(_angular_core__WEBPACK_IMPORTED_MODULE_0__["Pipe"])({ name: 'json', pure: false }) ], JsonPipe); return JsonPipe; }()); /** * @license * Copyright Google Inc. All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ function makeKeyValuePair(key, value) { return { key: key, value: value }; } /** * @ngModule CommonModule * @description * * Transforms Object or Map into an array of key value pairs. * * The output array will be ordered by keys. * By default the comparator will be by Unicode point value. * You can optionally pass a compareFn if your keys are complex types. * * @usageNotes * ### Examples * * This examples show how an Object or a Map can be iterated by ngFor with the use of this keyvalue * pipe. * * {@example common/pipes/ts/keyvalue_pipe.ts region='KeyValuePipe'} * * @publicApi */ var KeyValuePipe = /** @class */ (function () { function KeyValuePipe(differs) { this.differs = differs; this.keyValues = []; } KeyValuePipe.prototype.transform = function (input, compareFn) { var _this = this; if (compareFn === void 0) { compareFn = defaultComparator; } if (!input || (!(input instanceof Map) && typeof input !== 'object')) { return null; } if (!this.differ) { // make a differ for whatever type we've been passed in this.differ = this.differs.find(input).create(); } var differChanges = this.differ.diff(input); if (differChanges) { this.keyValues = []; differChanges.forEachItem(function (r) { _this.keyValues.push(makeKeyValuePair(r.key, r.currentValue)); }); this.keyValues.sort(compareFn); } return this.keyValues; }; KeyValuePipe = Object(tslib__WEBPACK_IMPORTED_MODULE_1__["__decorate"])([ Object(_angular_core__WEBPACK_IMPORTED_MODULE_0__["Pipe"])({ name: 'keyvalue', pure: false }), Object(tslib__WEBPACK_IMPORTED_MODULE_1__["__metadata"])("design:paramtypes", [_angular_core__WEBPACK_IMPORTED_MODULE_0__["KeyValueDiffers"]]) ], KeyValuePipe); return KeyValuePipe; }()); function defaultComparator(keyValueA, keyValueB) { var a = keyValueA.key; var b = keyValueB.key; // if same exit with 0; if (a === b) return 0; // make sure that undefined are at the end of the sort. if (a === undefined) return 1; if (b === undefined) return -1; // make sure that nulls are at the end of the sort. if (a === null) return 1; if (b === null) return -1; if (typeof a == 'string' && typeof b == 'string') { return a < b ? -1 : 1; } if (typeof a == 'number' && typeof b == 'number') { return a - b; } if (typeof a == 'boolean' && typeof b == 'boolean') { return a < b ? -1 : 1; } // `a` and `b` are of different types. Compare their string values. var aString = String(a); var bString = String(b); return aString == bString ? 0 : aString < bString ? -1 : 1; } /** * @license * Copyright Google Inc. All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ /** * @ngModule CommonModule * @description * * Transforms a number into a string, * formatted according to locale rules that determine group sizing and * separator, decimal-point character, and other locale-specific * configurations. * * If no parameters are specified, the function rounds off to the nearest value using this * [rounding method](https://en.wikibooks.org/wiki/Arithmetic/Rounding). * The behavior differs from that of the JavaScript ```Math.round()``` function. * In the following case for example, the pipe rounds down where * ```Math.round()``` rounds up: * * ```html * -2.5 | number:'1.0-0' * > -3 * Math.round(-2.5) * > -2 * ``` * * @see `formatNumber()` * * @usageNotes * The following code shows how the pipe transforms numbers * into text strings, according to various format specifications, * where the caller's default locale is `en-US`. * * ### Example * * * * @publicApi */ var DecimalPipe = /** @class */ (function () { function DecimalPipe(_locale) { this._locale = _locale; } DecimalPipe_1 = DecimalPipe; /** * @param value The number to be formatted. * @param digitsInfo Decimal representation options, specified by a string * in the following format:
    * {minIntegerDigits}.{minFractionDigits}-{maxFractionDigits}. * - `minIntegerDigits`: The minimum number of integer digits before the decimal point. * Default is `1`. * - `minFractionDigits`: The minimum number of digits after the decimal point. * Default is `0`. * - `maxFractionDigits`: The maximum number of digits after the decimal point. * Default is `3`. * @param locale A locale code for the locale format rules to use. * When not supplied, uses the value of `LOCALE_ID`, which is `en-US` by default. * See [Setting your app locale](guide/i18n#setting-up-the-locale-of-your-app). */ DecimalPipe.prototype.transform = function (value, digitsInfo, locale) { if (isEmpty(value)) return null; locale = locale || this._locale; try { var num = strToNumber(value); return formatNumber(num, locale, digitsInfo); } catch (error) { throw invalidPipeArgumentError(DecimalPipe_1, error.message); } }; var DecimalPipe_1; DecimalPipe = DecimalPipe_1 = Object(tslib__WEBPACK_IMPORTED_MODULE_1__["__decorate"])([ Object(_angular_core__WEBPACK_IMPORTED_MODULE_0__["Pipe"])({ name: 'number' }), Object(tslib__WEBPACK_IMPORTED_MODULE_1__["__param"])(0, Object(_angular_core__WEBPACK_IMPORTED_MODULE_0__["Inject"])(_angular_core__WEBPACK_IMPORTED_MODULE_0__["LOCALE_ID"])), Object(tslib__WEBPACK_IMPORTED_MODULE_1__["__metadata"])("design:paramtypes", [String]) ], DecimalPipe); return DecimalPipe; }()); /** * @ngModule CommonModule * @description * * Transforms a number to a percentage * string, formatted according to locale rules that determine group sizing and * separator, decimal-point character, and other locale-specific * configurations. * * @see `formatPercent()` * * @usageNotes * The following code shows how the pipe transforms numbers * into text strings, according to various format specifications, * where the caller's default locale is `en-US`. * * * * @publicApi */ var PercentPipe = /** @class */ (function () { function PercentPipe(_locale) { this._locale = _locale; } PercentPipe_1 = PercentPipe; /** * * @param value The number to be formatted as a percentage. * @param digitsInfo Decimal representation options, specified by a string * in the following format:
    * {minIntegerDigits}.{minFractionDigits}-{maxFractionDigits}. * - `minIntegerDigits`: The minimum number of integer digits before the decimal point. * Default is `1`. * - `minFractionDigits`: The minimum number of digits after the decimal point. * Default is `0`. * - `maxFractionDigits`: The maximum number of digits after the decimal point. * Default is `0`. * @param locale A locale code for the locale format rules to use. * When not supplied, uses the value of `LOCALE_ID`, which is `en-US` by default. * See [Setting your app locale](guide/i18n#setting-up-the-locale-of-your-app). */ PercentPipe.prototype.transform = function (value, digitsInfo, locale) { if (isEmpty(value)) return null; locale = locale || this._locale; try { var num = strToNumber(value); return formatPercent(num, locale, digitsInfo); } catch (error) { throw invalidPipeArgumentError(PercentPipe_1, error.message); } }; var PercentPipe_1; PercentPipe = PercentPipe_1 = Object(tslib__WEBPACK_IMPORTED_MODULE_1__["__decorate"])([ Object(_angular_core__WEBPACK_IMPORTED_MODULE_0__["Pipe"])({ name: 'percent' }), Object(tslib__WEBPACK_IMPORTED_MODULE_1__["__param"])(0, Object(_angular_core__WEBPACK_IMPORTED_MODULE_0__["Inject"])(_angular_core__WEBPACK_IMPORTED_MODULE_0__["LOCALE_ID"])), Object(tslib__WEBPACK_IMPORTED_MODULE_1__["__metadata"])("design:paramtypes", [String]) ], PercentPipe); return PercentPipe; }()); /** * @ngModule CommonModule * @description * * Transforms a number to a currency string, formatted according to locale rules * that determine group sizing and separator, decimal-point character, * and other locale-specific configurations. * * @see `getCurrencySymbol()` * @see `formatCurrency()` * * @usageNotes * The following code shows how the pipe transforms numbers * into text strings, according to various format specifications, * where the caller's default locale is `en-US`. * * * * @publicApi */ var CurrencyPipe = /** @class */ (function () { function CurrencyPipe(_locale) { this._locale = _locale; } CurrencyPipe_1 = CurrencyPipe; /** * * @param value The number to be formatted as currency. * @param currencyCode The [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) currency code, * such as `USD` for the US dollar and `EUR` for the euro. * @param display The format for the currency indicator. One of the following: * - `code`: Show the code (such as `USD`). * - `symbol`(default): Show the symbol (such as `$`). * - `symbol-narrow`: Use the narrow symbol for locales that have two symbols for their * currency. * For example, the Canadian dollar CAD has the symbol `CA$` and the symbol-narrow `$`. If the * locale has no narrow symbol, uses the standard symbol for the locale. * - String: Use the given string value instead of a code or a symbol. * For example, an empty string will suppress the currency & symbol. * - Boolean (marked deprecated in v5): `true` for symbol and false for `code`. * * @param digitsInfo Decimal representation options, specified by a string * in the following format:
    * {minIntegerDigits}.{minFractionDigits}-{maxFractionDigits}. * - `minIntegerDigits`: The minimum number of integer digits before the decimal point. * Default is `1`. * - `minFractionDigits`: The minimum number of digits after the decimal point. * Default is `2`. * - `maxFractionDigits`: The maximum number of digits after the decimal point. * Default is `2`. * If not provided, the number will be formatted with the proper amount of digits, * depending on what the [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) specifies. * For example, the Canadian dollar has 2 digits, whereas the Chilean peso has none. * @param locale A locale code for the locale format rules to use. * When not supplied, uses the value of `LOCALE_ID`, which is `en-US` by default. * See [Setting your app locale](guide/i18n#setting-up-the-locale-of-your-app). */ CurrencyPipe.prototype.transform = function (value, currencyCode, display, digitsInfo, locale) { if (display === void 0) { display = 'symbol'; } if (isEmpty(value)) return null; locale = locale || this._locale; if (typeof display === 'boolean') { if (console && console.warn) { 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\"."); } display = display ? 'symbol' : 'code'; } var currency = currencyCode || 'USD'; if (display !== 'code') { if (display === 'symbol' || display === 'symbol-narrow') { currency = getCurrencySymbol(currency, display === 'symbol' ? 'wide' : 'narrow', locale); } else { currency = display; } } try { var num = strToNumber(value); return formatCurrency(num, locale, currency, currencyCode, digitsInfo); } catch (error) { throw invalidPipeArgumentError(CurrencyPipe_1, error.message); } }; var CurrencyPipe_1; CurrencyPipe = CurrencyPipe_1 = Object(tslib__WEBPACK_IMPORTED_MODULE_1__["__decorate"])([ Object(_angular_core__WEBPACK_IMPORTED_MODULE_0__["Pipe"])({ name: 'currency' }), Object(tslib__WEBPACK_IMPORTED_MODULE_1__["__param"])(0, Object(_angular_core__WEBPACK_IMPORTED_MODULE_0__["Inject"])(_angular_core__WEBPACK_IMPORTED_MODULE_0__["LOCALE_ID"])), Object(tslib__WEBPACK_IMPORTED_MODULE_1__["__metadata"])("design:paramtypes", [String]) ], CurrencyPipe); return CurrencyPipe; }()); function isEmpty(value) { return value == null || value === '' || value !== value; } /** * Transforms a string into a number (if needed). */ function strToNumber(value) { // Convert strings to numbers if (typeof value === 'string' && !isNaN(Number(value) - parseFloat(value))) { return Number(value); } if (typeof value !== 'number') { throw new Error(value + " is not a number"); } return value; } /** * @license * Copyright Google Inc. All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ /** * @ngModule CommonModule * @description * * Creates a new `Array` or `String` containing a subset (slice) of the elements. * * @usageNotes * * All behavior is based on the expected behavior of the JavaScript API `Array.prototype.slice()` * and `String.prototype.slice()`. * * When operating on an `Array`, the returned `Array` is always a copy even when all * the elements are being returned. * * When operating on a blank value, the pipe returns the blank value. * * ### List Example * * This `ngFor` example: * * {@example common/pipes/ts/slice_pipe.ts region='SlicePipe_list'} * * produces the following: * * ```html *
  • b
  • *
  • c
  • * ``` * * ### String Examples * * {@example common/pipes/ts/slice_pipe.ts region='SlicePipe_string'} * * @publicApi */ var SlicePipe = /** @class */ (function () { function SlicePipe() { } SlicePipe_1 = SlicePipe; /** * @param value a list or a string to be sliced. * @param start the starting index of the subset to return: * - **a positive integer**: return the item at `start` index and all items after * in the list or string expression. * - **a negative integer**: return the item at `start` index from the end and all items after * in the list or string expression. * - **if positive and greater than the size of the expression**: return an empty list or * string. * - **if negative and greater than the size of the expression**: return entire list or string. * @param end the ending index of the subset to return: * - **omitted**: return all items until the end. * - **if positive**: return all items before `end` index of the list or string. * - **if negative**: return all items before `end` index from the end of the list or string. */ SlicePipe.prototype.transform = function (value, start, end) { if (value == null) return value; if (!this.supports(value)) { throw invalidPipeArgumentError(SlicePipe_1, value); } return value.slice(start, end); }; SlicePipe.prototype.supports = function (obj) { return typeof obj === 'string' || Array.isArray(obj); }; var SlicePipe_1; SlicePipe = SlicePipe_1 = Object(tslib__WEBPACK_IMPORTED_MODULE_1__["__decorate"])([ Object(_angular_core__WEBPACK_IMPORTED_MODULE_0__["Pipe"])({ name: 'slice', pure: false }) ], SlicePipe); return SlicePipe; }()); /** * @license * Copyright Google Inc. All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ /** * A collection of Angular pipes that are likely to be used in each and every application. */ var COMMON_PIPES = [ AsyncPipe, UpperCasePipe, LowerCasePipe, JsonPipe, SlicePipe, DecimalPipe, PercentPipe, TitleCasePipe, CurrencyPipe, DatePipe, I18nPluralPipe, I18nSelectPipe, KeyValuePipe, ]; /** * @license * Copyright Google Inc. All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ // Note: This does not contain the location providers, // as they need some platform specific implementations to work. /** * Exports all the basic Angular directives and pipes, * such as `NgIf`, `NgForOf`, `DecimalPipe`, and so on. * Re-exported by `BrowserModule`, which is included automatically in the root * `AppModule` when you create a new app with the CLI `new` command. * * * The `providers` options configure the NgModule's injector to provide * localization dependencies to members. * * The `exports` options make the declared directives and pipes available for import * by other NgModules. * * @publicApi */ var CommonModule = /** @class */ (function () { function CommonModule() { } CommonModule = Object(tslib__WEBPACK_IMPORTED_MODULE_1__["__decorate"])([ Object(_angular_core__WEBPACK_IMPORTED_MODULE_0__["NgModule"])({ declarations: [COMMON_DIRECTIVES, COMMON_PIPES], exports: [COMMON_DIRECTIVES, COMMON_PIPES], providers: [ { provide: NgLocalization, useClass: NgLocaleLocalization }, ], }) ], CommonModule); return CommonModule; }()); var ɵ0 = getPluralCase; /** * A module that contains the deprecated i18n pipes. * * @deprecated from v5 * @publicApi */ var DeprecatedI18NPipesModule = /** @class */ (function () { function DeprecatedI18NPipesModule() { } DeprecatedI18NPipesModule = Object(tslib__WEBPACK_IMPORTED_MODULE_1__["__decorate"])([ Object(_angular_core__WEBPACK_IMPORTED_MODULE_0__["NgModule"])({ declarations: [COMMON_DEPRECATED_I18N_PIPES], exports: [COMMON_DEPRECATED_I18N_PIPES], providers: [{ provide: DEPRECATED_PLURAL_FN, useValue: ɵ0 }], }) ], DeprecatedI18NPipesModule); return DeprecatedI18NPipesModule; }()); /** * @license * Copyright Google Inc. All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ /** * A DI Token representing the main rendering context. In a browser this is the DOM Document. * * Note: Document might not be available in the Application Context when Application and Rendering * Contexts are not the same (e.g. when running the application into a Web Worker). * * @publicApi */ var DOCUMENT = new _angular_core__WEBPACK_IMPORTED_MODULE_0__["InjectionToken"]('DocumentToken'); /** * @license * Copyright Google Inc. All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ var PLATFORM_BROWSER_ID = 'browser'; var PLATFORM_SERVER_ID = 'server'; var PLATFORM_WORKER_APP_ID = 'browserWorkerApp'; var PLATFORM_WORKER_UI_ID = 'browserWorkerUi'; /** * Returns whether a platform id represents a browser platform. * @publicApi */ function isPlatformBrowser(platformId) { return platformId === PLATFORM_BROWSER_ID; } /** * Returns whether a platform id represents a server platform. * @publicApi */ function isPlatformServer(platformId) { return platformId === PLATFORM_SERVER_ID; } /** * Returns whether a platform id represents a web worker app platform. * @publicApi */ function isPlatformWorkerApp(platformId) { return platformId === PLATFORM_WORKER_APP_ID; } /** * Returns whether a platform id represents a web worker UI platform. * @publicApi */ function isPlatformWorkerUi(platformId) { return platformId === PLATFORM_WORKER_UI_ID; } /** * @license * Copyright Google Inc. All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ /** * @publicApi */ var VERSION = new _angular_core__WEBPACK_IMPORTED_MODULE_0__["Version"]('7.2.3'); /** * @license * Copyright Google Inc. All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ /** * Defines a scroll position manager. Implemented by `BrowserViewportScroller`. * * @publicApi */ var ViewportScroller = /** @class */ (function () { function ViewportScroller() { } // De-sugared tree-shakable injection // See #23917 /** @nocollapse */ ViewportScroller.ngInjectableDef = Object(_angular_core__WEBPACK_IMPORTED_MODULE_0__["defineInjectable"])({ providedIn: 'root', factory: function () { return new BrowserViewportScroller(Object(_angular_core__WEBPACK_IMPORTED_MODULE_0__["inject"])(DOCUMENT), window); } }); return ViewportScroller; }()); /** * Manages the scroll position for a browser window. */ var BrowserViewportScroller = /** @class */ (function () { function BrowserViewportScroller(document, window) { this.document = document; this.window = window; this.offset = function () { return [0, 0]; }; } /** * Configures the top offset used when scrolling to an anchor. * @param offset A position in screen coordinates (a tuple with x and y values) * or a function that returns the top offset position. * */ BrowserViewportScroller.prototype.setOffset = function (offset) { if (Array.isArray(offset)) { this.offset = function () { return offset; }; } else { this.offset = offset; } }; /** * Retrieves the current scroll position. * @returns The position in screen coordinates. */ BrowserViewportScroller.prototype.getScrollPosition = function () { if (this.supportScrollRestoration()) { return [this.window.scrollX, this.window.scrollY]; } else { return [0, 0]; } }; /** * Sets the scroll position. * @param position The new position in screen coordinates. */ BrowserViewportScroller.prototype.scrollToPosition = function (position) { if (this.supportScrollRestoration()) { this.window.scrollTo(position[0], position[1]); } }; /** * Scrolls to an anchor element. * @param anchor The ID of the anchor element. */ BrowserViewportScroller.prototype.scrollToAnchor = function (anchor) { if (this.supportScrollRestoration()) { var elSelectedById = this.document.querySelector("#" + anchor); if (elSelectedById) { this.scrollToElement(elSelectedById); return; } var elSelectedByName = this.document.querySelector("[name='" + anchor + "']"); if (elSelectedByName) { this.scrollToElement(elSelectedByName); return; } } }; /** * Disables automatic scroll restoration provided by the browser. */ BrowserViewportScroller.prototype.setHistoryScrollRestoration = function (scrollRestoration) { if (this.supportScrollRestoration()) { var history_1 = this.window.history; if (history_1 && history_1.scrollRestoration) { history_1.scrollRestoration = scrollRestoration; } } }; BrowserViewportScroller.prototype.scrollToElement = function (el) { var rect = el.getBoundingClientRect(); var left = rect.left + this.window.pageXOffset; var top = rect.top + this.window.pageYOffset; var offset = this.offset(); this.window.scrollTo(left - offset[0], top - offset[1]); }; /** * We only support scroll restoration when we can get a hold of window. * This means that we do not support this behavior when running in a web worker. * * Lifting this restriction right now would require more changes in the dom adapter. * Since webworkers aren't widely used, we will lift it once RouterScroller is * battle-tested. */ BrowserViewportScroller.prototype.supportScrollRestoration = function () { try { return !!this.window && !!this.window.scrollTo; } catch (_a) { return false; } }; return BrowserViewportScroller; }()); /** * Provides an empty implementation of the viewport scroller. This will * live in @angular/common as it will be used by both platform-server and platform-webworker. */ var NullViewportScroller = /** @class */ (function () { function NullViewportScroller() { } /** * Empty implementation */ NullViewportScroller.prototype.setOffset = function (offset) { }; /** * Empty implementation */ NullViewportScroller.prototype.getScrollPosition = function () { return [0, 0]; }; /** * Empty implementation */ NullViewportScroller.prototype.scrollToPosition = function (position) { }; /** * Empty implementation */ NullViewportScroller.prototype.scrollToAnchor = function (anchor) { }; /** * Empty implementation */ NullViewportScroller.prototype.setHistoryScrollRestoration = function (scrollRestoration) { }; return NullViewportScroller; }()); /** * @license * Copyright Google Inc. All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ /** * @license * Copyright Google Inc. All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ // This file only reexports content of the `src` folder. Keep it that way. /** * @license * Copyright Google Inc. All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ /** * Generated bundle index. Do not edit. */ //# sourceMappingURL=common.js.map /***/ }), /***/ "./node_modules/@angular/compiler/fesm5/compiler.js": /*!**********************************************************!*\ !*** ./node_modules/@angular/compiler/fesm5/compiler.js ***! \**********************************************************/ /*! exports provided: core, CompilerConfig, preserveWhitespacesDefault, isLoweredSymbol, createLoweredSymbol, Identifiers, JitCompiler, ConstantPool, DirectiveResolver, PipeResolver, NgModuleResolver, DEFAULT_INTERPOLATION_CONFIG, InterpolationConfig, NgModuleCompiler, ArrayType, AssertNotNull, BinaryOperator, BinaryOperatorExpr, BuiltinMethod, BuiltinType, BuiltinTypeName, BuiltinVar, CastExpr, ClassField, ClassMethod, ClassStmt, CommaExpr, CommentStmt, ConditionalExpr, DeclareFunctionStmt, DeclareVarStmt, Expression, ExpressionStatement, ExpressionType, ExternalExpr, ExternalReference, FunctionExpr, IfStmt, InstantiateExpr, InvokeFunctionExpr, InvokeMethodExpr, JSDocCommentStmt, LiteralArrayExpr, LiteralExpr, LiteralMapExpr, MapType, NotExpr, ReadKeyExpr, ReadPropExpr, ReadVarExpr, ReturnStatement, ThrowStmt, TryCatchStmt, Type, WrappedNodeExpr, WriteKeyExpr, WritePropExpr, WriteVarExpr, StmtModifier, Statement, TypeofExpr, collectExternalReferences, EmitterVisitorContext, ViewCompiler, getParseErrors, isSyntaxError, syntaxError, Version, TmplAstBoundAttribute, TmplAstBoundEvent, TmplAstBoundText, TmplAstContent, TmplAstElement, TmplAstReference, TmplAstTemplate, TmplAstText, TmplAstTextAttribute, TmplAstVariable, jitExpression, R3ResolvedDependencyType, compileInjector, compileNgModule, compilePipeFromMetadata, makeBindingParser, parseTemplate, compileBaseDefFromMetadata, compileComponentFromMetadata, compileDirectiveFromMetadata, parseHostBindings, publishFacade, VERSION, TextAst, BoundTextAst, AttrAst, BoundElementPropertyAst, BoundEventAst, ReferenceAst, VariableAst, ElementAst, EmbeddedTemplateAst, BoundDirectivePropertyAst, DirectiveAst, ProviderAst, ProviderAstType, NgContentAst, NullTemplateVisitor, RecursiveTemplateAstVisitor, templateVisitAll, sanitizeIdentifier, identifierName, identifierModuleUrl, viewClassName, rendererTypeName, hostViewClassName, componentFactoryName, CompileSummaryKind, tokenName, tokenReference, CompileStylesheetMetadata, CompileTemplateMetadata, CompileDirectiveMetadata, CompilePipeMetadata, CompileShallowModuleMetadata, CompileNgModuleMetadata, TransitiveCompileNgModuleMetadata, ProviderMeta, flatten, templateSourceUrl, sharedStylesheetJitUrl, ngModuleJitUrl, templateJitUrl, createAotUrlResolver, createAotCompiler, AotCompiler, analyzeNgModules, analyzeAndValidateNgModules, analyzeFile, analyzeFileForInjectables, mergeAnalyzedFiles, GeneratedFile, toTypeScript, formattedError, isFormattedError, StaticReflector, StaticSymbol, StaticSymbolCache, ResolvedStaticSymbol, StaticSymbolResolver, unescapeIdentifier, unwrapResolvedMetadata, AotSummaryResolver, AstPath, SummaryResolver, JitSummaryResolver, CompileReflector, createUrlResolverWithoutPackagePrefix, createOfflineCompileUrlResolver, UrlResolver, getUrlScheme, ResourceLoader, ElementSchemaRegistry, Extractor, I18NHtmlParser, MessageBundle, Serializer, Xliff, Xliff2, Xmb, Xtb, DirectiveNormalizer, ParserError, ParseSpan, AST, Quote, EmptyExpr, ImplicitReceiver, Chain, Conditional, PropertyRead, PropertyWrite, SafePropertyRead, KeyedRead, KeyedWrite, BindingPipe, LiteralPrimitive, LiteralArray, LiteralMap, Interpolation, Binary, PrefixNot, NonNullAssert, MethodCall, SafeMethodCall, FunctionCall, ASTWithSource, TemplateBinding, NullAstVisitor, RecursiveAstVisitor, AstTransformer, AstMemoryEfficientTransformer, visitAstChildren, ParsedProperty, ParsedPropertyType, ParsedEvent, ParsedVariable, BoundElementProperty, TokenType, Lexer, Token, EOF, isIdentifier, isQuote, SplitInterpolation, TemplateBindingParseResult, Parser, _ParseAST, ERROR_COMPONENT_TYPE, CompileMetadataResolver, Text, Expansion, ExpansionCase, Attribute, Element, Comment, visitAll, RecursiveVisitor, findNode, HtmlParser, ParseTreeResult, TreeError, HtmlTagDefinition, getHtmlTagDefinition, TagContentType, splitNsName, isNgContainer, isNgContent, isNgTemplate, getNsPrefix, mergeNsAndName, NAMED_ENTITIES, NGSP_UNICODE, debugOutputAstAsTypeScript, TypeScriptEmitter, ParseLocation, ParseSourceFile, ParseSourceSpan, ParseErrorLevel, ParseError, typeSourceSpan, DomElementSchemaRegistry, CssSelector, SelectorMatcher, SelectorListContext, SelectorContext, HOST_ATTR, CONTENT_ATTR, StylesCompileDependency, CompiledStylesheet, StyleCompiler, TemplateParseError, TemplateParseResult, TemplateParser, splitClasses, createElementCssSelector, removeSummaryDuplicates, compileInjectable, R3TargetBinder, R3BoundTarget */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "core", function() { return core; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CompilerConfig", function() { return CompilerConfig; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "preserveWhitespacesDefault", function() { return preserveWhitespacesDefault; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isLoweredSymbol", function() { return isLoweredSymbol; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "createLoweredSymbol", function() { return createLoweredSymbol; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Identifiers", function() { return Identifiers; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "JitCompiler", function() { return JitCompiler; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ConstantPool", function() { return ConstantPool; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DirectiveResolver", function() { return DirectiveResolver; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PipeResolver", function() { return PipeResolver; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "NgModuleResolver", function() { return NgModuleResolver; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DEFAULT_INTERPOLATION_CONFIG", function() { return DEFAULT_INTERPOLATION_CONFIG; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InterpolationConfig", function() { return InterpolationConfig; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "NgModuleCompiler", function() { return NgModuleCompiler; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArrayType", function() { return ArrayType; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AssertNotNull", function() { return AssertNotNull; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BinaryOperator", function() { return BinaryOperator; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BinaryOperatorExpr", function() { return BinaryOperatorExpr; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BuiltinMethod", function() { return BuiltinMethod; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BuiltinType", function() { return BuiltinType; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BuiltinTypeName", function() { return BuiltinTypeName; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BuiltinVar", function() { return BuiltinVar; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CastExpr", function() { return CastExpr; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ClassField", function() { return ClassField; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ClassMethod", function() { return ClassMethod; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ClassStmt", function() { return ClassStmt; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CommaExpr", function() { return CommaExpr; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CommentStmt", function() { return CommentStmt; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ConditionalExpr", function() { return ConditionalExpr; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DeclareFunctionStmt", function() { return DeclareFunctionStmt; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DeclareVarStmt", function() { return DeclareVarStmt; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Expression", function() { return Expression; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ExpressionStatement", function() { return ExpressionStatement; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ExpressionType", function() { return ExpressionType; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ExternalExpr", function() { return ExternalExpr; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ExternalReference", function() { return ExternalReference; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FunctionExpr", function() { return FunctionExpr; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "IfStmt", function() { return IfStmt; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InstantiateExpr", function() { return InstantiateExpr; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InvokeFunctionExpr", function() { return InvokeFunctionExpr; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InvokeMethodExpr", function() { return InvokeMethodExpr; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "JSDocCommentStmt", function() { return JSDocCommentStmt; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LiteralArrayExpr", function() { return LiteralArrayExpr; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LiteralExpr", function() { return LiteralExpr; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LiteralMapExpr", function() { return LiteralMapExpr; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MapType", function() { return MapType; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "NotExpr", function() { return NotExpr; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ReadKeyExpr", function() { return ReadKeyExpr; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ReadPropExpr", function() { return ReadPropExpr; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ReadVarExpr", function() { return ReadVarExpr; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ReturnStatement", function() { return ReturnStatement; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ThrowStmt", function() { return ThrowStmt; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TryCatchStmt", function() { return TryCatchStmt; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Type", function() { return Type$1; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WrappedNodeExpr", function() { return WrappedNodeExpr; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WriteKeyExpr", function() { return WriteKeyExpr; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WritePropExpr", function() { return WritePropExpr; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WriteVarExpr", function() { return WriteVarExpr; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StmtModifier", function() { return StmtModifier; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Statement", function() { return Statement; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TypeofExpr", function() { return TypeofExpr; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "collectExternalReferences", function() { return collectExternalReferences; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EmitterVisitorContext", function() { return EmitterVisitorContext; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ViewCompiler", function() { return ViewCompiler; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getParseErrors", function() { return getParseErrors; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isSyntaxError", function() { return isSyntaxError; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "syntaxError", function() { return syntaxError; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Version", function() { return Version; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TmplAstBoundAttribute", function() { return BoundAttribute; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TmplAstBoundEvent", function() { return BoundEvent; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TmplAstBoundText", function() { return BoundText; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TmplAstContent", function() { return Content; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TmplAstElement", function() { return Element$1; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TmplAstReference", function() { return Reference; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TmplAstTemplate", function() { return Template; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TmplAstText", function() { return Text$3; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TmplAstTextAttribute", function() { return TextAttribute; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TmplAstVariable", function() { return Variable; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "jitExpression", function() { return jitExpression; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "R3ResolvedDependencyType", function() { return R3ResolvedDependencyType; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "compileInjector", function() { return compileInjector; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "compileNgModule", function() { return compileNgModule; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "compilePipeFromMetadata", function() { return compilePipeFromMetadata; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "makeBindingParser", function() { return makeBindingParser; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "parseTemplate", function() { return parseTemplate; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "compileBaseDefFromMetadata", function() { return compileBaseDefFromMetadata; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "compileComponentFromMetadata", function() { return compileComponentFromMetadata; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "compileDirectiveFromMetadata", function() { return compileDirectiveFromMetadata; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "parseHostBindings", function() { return parseHostBindings; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "publishFacade", function() { return publishFacade; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VERSION", function() { return VERSION$1; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextAst", function() { return TextAst; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoundTextAst", function() { return BoundTextAst; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AttrAst", function() { return AttrAst; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoundElementPropertyAst", function() { return BoundElementPropertyAst; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoundEventAst", function() { return BoundEventAst; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ReferenceAst", function() { return ReferenceAst; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VariableAst", function() { return VariableAst; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ElementAst", function() { return ElementAst; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EmbeddedTemplateAst", function() { return EmbeddedTemplateAst; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoundDirectivePropertyAst", function() { return BoundDirectivePropertyAst; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DirectiveAst", function() { return DirectiveAst; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ProviderAst", function() { return ProviderAst; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ProviderAstType", function() { return ProviderAstType; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "NgContentAst", function() { return NgContentAst; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "NullTemplateVisitor", function() { return NullTemplateVisitor; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RecursiveTemplateAstVisitor", function() { return RecursiveTemplateAstVisitor; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "templateVisitAll", function() { return templateVisitAll; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "sanitizeIdentifier", function() { return sanitizeIdentifier; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "identifierName", function() { return identifierName; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "identifierModuleUrl", function() { return identifierModuleUrl; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "viewClassName", function() { return viewClassName; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "rendererTypeName", function() { return rendererTypeName; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "hostViewClassName", function() { return hostViewClassName; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "componentFactoryName", function() { return componentFactoryName; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CompileSummaryKind", function() { return CompileSummaryKind; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "tokenName", function() { return tokenName; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "tokenReference", function() { return tokenReference; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CompileStylesheetMetadata", function() { return CompileStylesheetMetadata; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CompileTemplateMetadata", function() { return CompileTemplateMetadata; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CompileDirectiveMetadata", function() { return CompileDirectiveMetadata; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CompilePipeMetadata", function() { return CompilePipeMetadata; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CompileShallowModuleMetadata", function() { return CompileShallowModuleMetadata; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CompileNgModuleMetadata", function() { return CompileNgModuleMetadata; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TransitiveCompileNgModuleMetadata", function() { return TransitiveCompileNgModuleMetadata; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ProviderMeta", function() { return ProviderMeta; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "flatten", function() { return flatten; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "templateSourceUrl", function() { return templateSourceUrl; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "sharedStylesheetJitUrl", function() { return sharedStylesheetJitUrl; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ngModuleJitUrl", function() { return ngModuleJitUrl; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "templateJitUrl", function() { return templateJitUrl; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "createAotUrlResolver", function() { return createAotUrlResolver; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "createAotCompiler", function() { return createAotCompiler; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AotCompiler", function() { return AotCompiler; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "analyzeNgModules", function() { return analyzeNgModules; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "analyzeAndValidateNgModules", function() { return analyzeAndValidateNgModules; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "analyzeFile", function() { return analyzeFile; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "analyzeFileForInjectables", function() { return analyzeFileForInjectables; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "mergeAnalyzedFiles", function() { return mergeAnalyzedFiles; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GeneratedFile", function() { return GeneratedFile; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "toTypeScript", function() { return toTypeScript; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "formattedError", function() { return formattedError; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isFormattedError", function() { return isFormattedError; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StaticReflector", function() { return StaticReflector; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StaticSymbol", function() { return StaticSymbol; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StaticSymbolCache", function() { return StaticSymbolCache; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ResolvedStaticSymbol", function() { return ResolvedStaticSymbol; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StaticSymbolResolver", function() { return StaticSymbolResolver; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "unescapeIdentifier", function() { return unescapeIdentifier; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "unwrapResolvedMetadata", function() { return unwrapResolvedMetadata; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AotSummaryResolver", function() { return AotSummaryResolver; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AstPath", function() { return AstPath; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SummaryResolver", function() { return SummaryResolver; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "JitSummaryResolver", function() { return JitSummaryResolver; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CompileReflector", function() { return CompileReflector; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "createUrlResolverWithoutPackagePrefix", function() { return createUrlResolverWithoutPackagePrefix; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "createOfflineCompileUrlResolver", function() { return createOfflineCompileUrlResolver; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "UrlResolver", function() { return UrlResolver; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getUrlScheme", function() { return getUrlScheme; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ResourceLoader", function() { return ResourceLoader; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ElementSchemaRegistry", function() { return ElementSchemaRegistry; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Extractor", function() { return Extractor; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "I18NHtmlParser", function() { return I18NHtmlParser; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MessageBundle", function() { return MessageBundle; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Serializer", function() { return Serializer; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Xliff", function() { return Xliff; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Xliff2", function() { return Xliff2; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Xmb", function() { return Xmb; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Xtb", function() { return Xtb; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DirectiveNormalizer", function() { return DirectiveNormalizer; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ParserError", function() { return ParserError; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ParseSpan", function() { return ParseSpan; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AST", function() { return AST; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Quote", function() { return Quote; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EmptyExpr", function() { return EmptyExpr; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ImplicitReceiver", function() { return ImplicitReceiver; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Chain", function() { return Chain; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Conditional", function() { return Conditional; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PropertyRead", function() { return PropertyRead; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PropertyWrite", function() { return PropertyWrite; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SafePropertyRead", function() { return SafePropertyRead; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "KeyedRead", function() { return KeyedRead; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "KeyedWrite", function() { return KeyedWrite; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BindingPipe", function() { return BindingPipe; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LiteralPrimitive", function() { return LiteralPrimitive; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LiteralArray", function() { return LiteralArray; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LiteralMap", function() { return LiteralMap; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Interpolation", function() { return Interpolation; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Binary", function() { return Binary; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PrefixNot", function() { return PrefixNot; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "NonNullAssert", function() { return NonNullAssert; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MethodCall", function() { return MethodCall; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SafeMethodCall", function() { return SafeMethodCall; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FunctionCall", function() { return FunctionCall; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ASTWithSource", function() { return ASTWithSource; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TemplateBinding", function() { return TemplateBinding; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "NullAstVisitor", function() { return NullAstVisitor; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RecursiveAstVisitor", function() { return RecursiveAstVisitor$1; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AstTransformer", function() { return AstTransformer$1; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AstMemoryEfficientTransformer", function() { return AstMemoryEfficientTransformer; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "visitAstChildren", function() { return visitAstChildren; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ParsedProperty", function() { return ParsedProperty; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ParsedPropertyType", function() { return ParsedPropertyType; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ParsedEvent", function() { return ParsedEvent; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ParsedVariable", function() { return ParsedVariable; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoundElementProperty", function() { return BoundElementProperty; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TokenType", function() { return TokenType; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Lexer", function() { return Lexer; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Token", function() { return Token; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EOF", function() { return EOF; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isIdentifier", function() { return isIdentifier; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isQuote", function() { return isQuote; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SplitInterpolation", function() { return SplitInterpolation; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TemplateBindingParseResult", function() { return TemplateBindingParseResult; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Parser", function() { return Parser; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_ParseAST", function() { return _ParseAST; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ERROR_COMPONENT_TYPE", function() { return ERROR_COMPONENT_TYPE; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CompileMetadataResolver", function() { return CompileMetadataResolver; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Text", function() { return Text$2; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Expansion", function() { return Expansion; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ExpansionCase", function() { return ExpansionCase; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Attribute", function() { return Attribute; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Element", function() { return Element; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Comment", function() { return Comment; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "visitAll", function() { return visitAll; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RecursiveVisitor", function() { return RecursiveVisitor; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "findNode", function() { return findNode; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HtmlParser", function() { return HtmlParser; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ParseTreeResult", function() { return ParseTreeResult; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TreeError", function() { return TreeError; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HtmlTagDefinition", function() { return HtmlTagDefinition; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getHtmlTagDefinition", function() { return getHtmlTagDefinition; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TagContentType", function() { return TagContentType; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "splitNsName", function() { return splitNsName; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isNgContainer", function() { return isNgContainer; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isNgContent", function() { return isNgContent; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isNgTemplate", function() { return isNgTemplate; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getNsPrefix", function() { return getNsPrefix; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "mergeNsAndName", function() { return mergeNsAndName; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "NAMED_ENTITIES", function() { return NAMED_ENTITIES; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "NGSP_UNICODE", function() { return NGSP_UNICODE; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "debugOutputAstAsTypeScript", function() { return debugOutputAstAsTypeScript; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TypeScriptEmitter", function() { return TypeScriptEmitter; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ParseLocation", function() { return ParseLocation; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ParseSourceFile", function() { return ParseSourceFile; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ParseSourceSpan", function() { return ParseSourceSpan; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ParseErrorLevel", function() { return ParseErrorLevel; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ParseError", function() { return ParseError; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "typeSourceSpan", function() { return typeSourceSpan; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DomElementSchemaRegistry", function() { return DomElementSchemaRegistry; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CssSelector", function() { return CssSelector; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SelectorMatcher", function() { return SelectorMatcher; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SelectorListContext", function() { return SelectorListContext; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SelectorContext", function() { return SelectorContext; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HOST_ATTR", function() { return HOST_ATTR; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CONTENT_ATTR", function() { return CONTENT_ATTR; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StylesCompileDependency", function() { return StylesCompileDependency; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CompiledStylesheet", function() { return CompiledStylesheet; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StyleCompiler", function() { return StyleCompiler; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TemplateParseError", function() { return TemplateParseError; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TemplateParseResult", function() { return TemplateParseResult; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TemplateParser", function() { return TemplateParser; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "splitClasses", function() { return splitClasses; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "createElementCssSelector", function() { return createElementCssSelector; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "removeSummaryDuplicates", function() { return removeSummaryDuplicates; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "compileInjectable", function() { return compileInjectable; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "R3TargetBinder", function() { return R3TargetBinder; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "R3BoundTarget", function() { return R3BoundTarget; }); /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "./node_modules/tslib/tslib.es6.js"); /** * @license Angular v7.2.3 * (c) 2010-2018 Google, Inc. https://angular.io/ * License: MIT */ /** * @license * Copyright Google Inc. All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ var TagContentType; (function (TagContentType) { TagContentType[TagContentType["RAW_TEXT"] = 0] = "RAW_TEXT"; TagContentType[TagContentType["ESCAPABLE_RAW_TEXT"] = 1] = "ESCAPABLE_RAW_TEXT"; TagContentType[TagContentType["PARSABLE_DATA"] = 2] = "PARSABLE_DATA"; })(TagContentType || (TagContentType = {})); function splitNsName(elementName) { if (elementName[0] != ':') { return [null, elementName]; } var colonIndex = elementName.indexOf(':', 1); if (colonIndex == -1) { throw new Error("Unsupported format \"" + elementName + "\" expecting \":namespace:name\""); } return [elementName.slice(1, colonIndex), elementName.slice(colonIndex + 1)]; } // `` tags work the same regardless the namespace function isNgContainer(tagName) { return splitNsName(tagName)[1] === 'ng-container'; } // `` tags work the same regardless the namespace function isNgContent(tagName) { return splitNsName(tagName)[1] === 'ng-content'; } // `` tags work the same regardless the namespace function isNgTemplate(tagName) { return splitNsName(tagName)[1] === 'ng-template'; } function getNsPrefix(fullName) { return fullName === null ? null : splitNsName(fullName)[0]; } function mergeNsAndName(prefix, localName) { return prefix ? ":" + prefix + ":" + localName : localName; } // see http://www.w3.org/TR/html51/syntax.html#named-character-references // see https://html.spec.whatwg.org/multipage/entities.json // This list is not exhaustive to keep the compiler footprint low. // The `{` / `ƫ` syntax should be used when the named character reference does not // exist. var NAMED_ENTITIES = { 'Aacute': '\u00C1', 'aacute': '\u00E1', 'Acirc': '\u00C2', 'acirc': '\u00E2', 'acute': '\u00B4', 'AElig': '\u00C6', 'aelig': '\u00E6', 'Agrave': '\u00C0', 'agrave': '\u00E0', 'alefsym': '\u2135', 'Alpha': '\u0391', 'alpha': '\u03B1', 'amp': '&', 'and': '\u2227', 'ang': '\u2220', 'apos': '\u0027', 'Aring': '\u00C5', 'aring': '\u00E5', 'asymp': '\u2248', 'Atilde': '\u00C3', 'atilde': '\u00E3', 'Auml': '\u00C4', 'auml': '\u00E4', 'bdquo': '\u201E', 'Beta': '\u0392', 'beta': '\u03B2', 'brvbar': '\u00A6', 'bull': '\u2022', 'cap': '\u2229', 'Ccedil': '\u00C7', 'ccedil': '\u00E7', 'cedil': '\u00B8', 'cent': '\u00A2', 'Chi': '\u03A7', 'chi': '\u03C7', 'circ': '\u02C6', 'clubs': '\u2663', 'cong': '\u2245', 'copy': '\u00A9', 'crarr': '\u21B5', 'cup': '\u222A', 'curren': '\u00A4', 'dagger': '\u2020', 'Dagger': '\u2021', 'darr': '\u2193', 'dArr': '\u21D3', 'deg': '\u00B0', 'Delta': '\u0394', 'delta': '\u03B4', 'diams': '\u2666', 'divide': '\u00F7', 'Eacute': '\u00C9', 'eacute': '\u00E9', 'Ecirc': '\u00CA', 'ecirc': '\u00EA', 'Egrave': '\u00C8', 'egrave': '\u00E8', 'empty': '\u2205', 'emsp': '\u2003', 'ensp': '\u2002', 'Epsilon': '\u0395', 'epsilon': '\u03B5', 'equiv': '\u2261', 'Eta': '\u0397', 'eta': '\u03B7', 'ETH': '\u00D0', 'eth': '\u00F0', 'Euml': '\u00CB', 'euml': '\u00EB', 'euro': '\u20AC', 'exist': '\u2203', 'fnof': '\u0192', 'forall': '\u2200', 'frac12': '\u00BD', 'frac14': '\u00BC', 'frac34': '\u00BE', 'frasl': '\u2044', 'Gamma': '\u0393', 'gamma': '\u03B3', 'ge': '\u2265', 'gt': '>', 'harr': '\u2194', 'hArr': '\u21D4', 'hearts': '\u2665', 'hellip': '\u2026', 'Iacute': '\u00CD', 'iacute': '\u00ED', 'Icirc': '\u00CE', 'icirc': '\u00EE', 'iexcl': '\u00A1', 'Igrave': '\u00CC', 'igrave': '\u00EC', 'image': '\u2111', 'infin': '\u221E', 'int': '\u222B', 'Iota': '\u0399', 'iota': '\u03B9', 'iquest': '\u00BF', 'isin': '\u2208', 'Iuml': '\u00CF', 'iuml': '\u00EF', 'Kappa': '\u039A', 'kappa': '\u03BA', 'Lambda': '\u039B', 'lambda': '\u03BB', 'lang': '\u27E8', 'laquo': '\u00AB', 'larr': '\u2190', 'lArr': '\u21D0', 'lceil': '\u2308', 'ldquo': '\u201C', 'le': '\u2264', 'lfloor': '\u230A', 'lowast': '\u2217', 'loz': '\u25CA', 'lrm': '\u200E', 'lsaquo': '\u2039', 'lsquo': '\u2018', 'lt': '<', 'macr': '\u00AF', 'mdash': '\u2014', 'micro': '\u00B5', 'middot': '\u00B7', 'minus': '\u2212', 'Mu': '\u039C', 'mu': '\u03BC', 'nabla': '\u2207', 'nbsp': '\u00A0', 'ndash': '\u2013', 'ne': '\u2260', 'ni': '\u220B', 'not': '\u00AC', 'notin': '\u2209', 'nsub': '\u2284', 'Ntilde': '\u00D1', 'ntilde': '\u00F1', 'Nu': '\u039D', 'nu': '\u03BD', 'Oacute': '\u00D3', 'oacute': '\u00F3', 'Ocirc': '\u00D4', 'ocirc': '\u00F4', 'OElig': '\u0152', 'oelig': '\u0153', 'Ograve': '\u00D2', 'ograve': '\u00F2', 'oline': '\u203E', 'Omega': '\u03A9', 'omega': '\u03C9', 'Omicron': '\u039F', 'omicron': '\u03BF', 'oplus': '\u2295', 'or': '\u2228', 'ordf': '\u00AA', 'ordm': '\u00BA', 'Oslash': '\u00D8', 'oslash': '\u00F8', 'Otilde': '\u00D5', 'otilde': '\u00F5', 'otimes': '\u2297', 'Ouml': '\u00D6', 'ouml': '\u00F6', 'para': '\u00B6', 'permil': '\u2030', 'perp': '\u22A5', 'Phi': '\u03A6', 'phi': '\u03C6', 'Pi': '\u03A0', 'pi': '\u03C0', 'piv': '\u03D6', 'plusmn': '\u00B1', 'pound': '\u00A3', 'prime': '\u2032', 'Prime': '\u2033', 'prod': '\u220F', 'prop': '\u221D', 'Psi': '\u03A8', 'psi': '\u03C8', 'quot': '\u0022', 'radic': '\u221A', 'rang': '\u27E9', 'raquo': '\u00BB', 'rarr': '\u2192', 'rArr': '\u21D2', 'rceil': '\u2309', 'rdquo': '\u201D', 'real': '\u211C', 'reg': '\u00AE', 'rfloor': '\u230B', 'Rho': '\u03A1', 'rho': '\u03C1', 'rlm': '\u200F', 'rsaquo': '\u203A', 'rsquo': '\u2019', 'sbquo': '\u201A', 'Scaron': '\u0160', 'scaron': '\u0161', 'sdot': '\u22C5', 'sect': '\u00A7', 'shy': '\u00AD', 'Sigma': '\u03A3', 'sigma': '\u03C3', 'sigmaf': '\u03C2', 'sim': '\u223C', 'spades': '\u2660', 'sub': '\u2282', 'sube': '\u2286', 'sum': '\u2211', 'sup': '\u2283', 'sup1': '\u00B9', 'sup2': '\u00B2', 'sup3': '\u00B3', 'supe': '\u2287', 'szlig': '\u00DF', 'Tau': '\u03A4', 'tau': '\u03C4', 'there4': '\u2234', 'Theta': '\u0398', 'theta': '\u03B8', 'thetasym': '\u03D1', 'thinsp': '\u2009', 'THORN': '\u00DE', 'thorn': '\u00FE', 'tilde': '\u02DC', 'times': '\u00D7', 'trade': '\u2122', 'Uacute': '\u00DA', 'uacute': '\u00FA', 'uarr': '\u2191', 'uArr': '\u21D1', 'Ucirc': '\u00DB', 'ucirc': '\u00FB', 'Ugrave': '\u00D9', 'ugrave': '\u00F9', 'uml': '\u00A8', 'upsih': '\u03D2', 'Upsilon': '\u03A5', 'upsilon': '\u03C5', 'Uuml': '\u00DC', 'uuml': '\u00FC', 'weierp': '\u2118', 'Xi': '\u039E', 'xi': '\u03BE', 'Yacute': '\u00DD', 'yacute': '\u00FD', 'yen': '\u00A5', 'yuml': '\u00FF', 'Yuml': '\u0178', 'Zeta': '\u0396', 'zeta': '\u03B6', 'zwj': '\u200D', 'zwnj': '\u200C', }; // The &ngsp; pseudo-entity is denoting a space. see: // https://github.com/dart-lang/angular/blob/0bb611387d29d65b5af7f9d2515ab571fd3fbee4/_tests/test/compiler/preserve_whitespace_test.dart var NGSP_UNICODE = '\uE500'; NAMED_ENTITIES['ngsp'] = NGSP_UNICODE; /** * @license * Copyright Google Inc. All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ var HtmlTagDefinition = /** @class */ (function () { function HtmlTagDefinition(_a) { var _b = _a === void 0 ? {} : _a, closedByChildren = _b.closedByChildren, requiredParents = _b.requiredParents, implicitNamespacePrefix = _b.implicitNamespacePrefix, _c = _b.contentType, contentType = _c === void 0 ? TagContentType.PARSABLE_DATA : _c, _d = _b.closedByParent, closedByParent = _d === void 0 ? false : _d, _e = _b.isVoid, isVoid = _e === void 0 ? false : _e, _f = _b.ignoreFirstLf, ignoreFirstLf = _f === void 0 ? false : _f; var _this = this; this.closedByChildren = {}; this.closedByParent = false; this.canSelfClose = false; if (closedByChildren && closedByChildren.length > 0) { closedByChildren.forEach(function (tagName) { return _this.closedByChildren[tagName] = true; }); } this.isVoid = isVoid; this.closedByParent = closedByParent || isVoid; if (requiredParents && requiredParents.length > 0) { this.requiredParents = {}; // The first parent is the list is automatically when none of the listed parents are present this.parentToAdd = requiredParents[0]; requiredParents.forEach(function (tagName) { return _this.requiredParents[tagName] = true; }); } this.implicitNamespacePrefix = implicitNamespacePrefix || null; this.contentType = contentType; this.ignoreFirstLf = ignoreFirstLf; } HtmlTagDefinition.prototype.requireExtraParent = function (currentParent) { if (!this.requiredParents) { return false; } if (!currentParent) { return true; } var lcParent = currentParent.toLowerCase(); var isParentTemplate = lcParent === 'template' || currentParent === 'ng-template'; return !isParentTemplate && this.requiredParents[lcParent] != true; }; HtmlTagDefinition.prototype.isClosedByChild = function (name) { return this.isVoid || name.toLowerCase() in this.closedByChildren; }; return HtmlTagDefinition; }()); var _DEFAULT_TAG_DEFINITION; // see http://www.w3.org/TR/html51/syntax.html#optional-tags // This implementation does not fully conform to the HTML5 spec. var TAG_DEFINITIONS; function getHtmlTagDefinition(tagName) { if (!TAG_DEFINITIONS) { _DEFAULT_TAG_DEFINITION = new HtmlTagDefinition(); TAG_DEFINITIONS = { 'base': new HtmlTagDefinition({ isVoid: true }), 'meta': new HtmlTagDefinition({ isVoid: true }), 'area': new HtmlTagDefinition({ isVoid: true }), 'embed': new HtmlTagDefinition({ isVoid: true }), 'link': new HtmlTagDefinition({ isVoid: true }), 'img': new HtmlTagDefinition({ isVoid: true }), 'input': new HtmlTagDefinition({ isVoid: true }), 'param': new HtmlTagDefinition({ isVoid: true }), 'hr': new HtmlTagDefinition({ isVoid: true }), 'br': new HtmlTagDefinition({ isVoid: true }), 'source': new HtmlTagDefinition({ isVoid: true }), 'track': new HtmlTagDefinition({ isVoid: true }), 'wbr': new HtmlTagDefinition({ isVoid: true }), 'p': new HtmlTagDefinition({ closedByChildren: [ 'address', 'article', 'aside', 'blockquote', 'div', 'dl', 'fieldset', 'footer', 'form', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'header', 'hgroup', 'hr', 'main', 'nav', 'ol', 'p', 'pre', 'section', 'table', 'ul' ], closedByParent: true }), 'thead': new HtmlTagDefinition({ closedByChildren: ['tbody', 'tfoot'] }), 'tbody': new HtmlTagDefinition({ closedByChildren: ['tbody', 'tfoot'], closedByParent: true }), 'tfoot': new HtmlTagDefinition({ closedByChildren: ['tbody'], closedByParent: true }), 'tr': new HtmlTagDefinition({ closedByChildren: ['tr'], requiredParents: ['tbody', 'tfoot', 'thead'], closedByParent: true }), 'td': new HtmlTagDefinition({ closedByChildren: ['td', 'th'], closedByParent: true }), 'th': new HtmlTagDefinition({ closedByChildren: ['td', 'th'], closedByParent: true }), 'col': new HtmlTagDefinition({ requiredParents: ['colgroup'], isVoid: true }), 'svg': new HtmlTagDefinition({ implicitNamespacePrefix: 'svg' }), 'math': new HtmlTagDefinition({ implicitNamespacePrefix: 'math' }), 'li': new HtmlTagDefinition({ closedByChildren: ['li'], closedByParent: true }), 'dt': new HtmlTagDefinition({ closedByChildren: ['dt', 'dd'] }), 'dd': new HtmlTagDefinition({ closedByChildren: ['dt', 'dd'], closedByParent: true }), 'rb': new HtmlTagDefinition({ closedByChildren: ['rb', 'rt', 'rtc', 'rp'], closedByParent: true }), 'rt': new HtmlTagDefinition({ closedByChildren: ['rb', 'rt', 'rtc', 'rp'], closedByParent: true }), 'rtc': new HtmlTagDefinition({ closedByChildren: ['rb', 'rtc', 'rp'], closedByParent: true }), 'rp': new HtmlTagDefinition({ closedByChildren: ['rb', 'rt', 'rtc', 'rp'], closedByParent: true }), 'optgroup': new HtmlTagDefinition({ closedByChildren: ['optgroup'], closedByParent: true }), 'option': new HtmlTagDefinition({ closedByChildren: ['option', 'optgroup'], closedByParent: true }), 'pre': new HtmlTagDefinition({ ignoreFirstLf: true }), 'listing': new HtmlTagDefinition({ ignoreFirstLf: true }), 'style': new HtmlTagDefinition({ contentType: TagContentType.RAW_TEXT }), 'script': new HtmlTagDefinition({ contentType: TagContentType.RAW_TEXT }), 'title': new HtmlTagDefinition({ contentType: TagContentType.ESCAPABLE_RAW_TEXT }), 'textarea': new HtmlTagDefinition({ contentType: TagContentType.ESCAPABLE_RAW_TEXT, ignoreFirstLf: true }), }; } return TAG_DEFINITIONS[tagName.toLowerCase()] || _DEFAULT_TAG_DEFINITION; } /** * @license * Copyright Google Inc. All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ var _SELECTOR_REGEXP = new RegExp('(\\:not\\()|' + //":not(" '([-\\w]+)|' + // "tag" '(?:\\.([-\\w]+))|' + // ".class" // "-" should appear first in the regexp below as FF31 parses "[.-\w]" as a range '(?:\\[([-.\\w*]+)(?:=([\"\']?)([^\\]\"\']*)\\5)?\\])|' + // "[name]", "[name=value]", // "[name="value"]", // "[name='value']" '(\\))|' + // ")" '(\\s*,\\s*)', // "," 'g'); /** * A css selector contains an element name, * css classes and attribute/value pairs with the purpose * of selecting subsets out of them. */ var CssSelector = /** @class */ (function () { function CssSelector() { this.element = null; this.classNames = []; /** * The selectors are encoded in pairs where: * - even locations are attribute names * - odd locations are attribute values. * * Example: * Selector: `[key1=value1][key2]` would parse to: * ``` * ['key1', 'value1', 'key2', ''] * ``` */ this.attrs = []; this.notSelectors = []; } CssSelector.parse = function (selector) { var results = []; var _addResult = function (res, cssSel) { if (cssSel.notSelectors.length > 0 && !cssSel.element && cssSel.classNames.length == 0 && cssSel.attrs.length == 0) { cssSel.element = '*'; } res.push(cssSel); }; var cssSelector = new CssSelector(); var match; var current = cssSelector; var inNot = false; _SELECTOR_REGEXP.lastIndex = 0; while (match = _SELECTOR_REGEXP.exec(selector)) { if (match[1]) { if (inNot) { throw new Error('Nesting :not is not allowed in a selector'); } inNot = true; current = new CssSelector(); cssSelector.notSelectors.push(current); } if (match[2]) { current.setElement(match[2]); } if (match[3]) { current.addClassName(match[3]); } if (match[4]) { current.addAttribute(match[4], match[6]); } if (match[7]) { inNot = false; current = cssSelector; } if (match[8]) { if (inNot) { throw new Error('Multiple selectors in :not are not supported'); } _addResult(results, cssSelector); cssSelector = current = new CssSelector(); } } _addResult(results, cssSelector); return results; }; CssSelector.prototype.isElementSelector = function () { return this.hasElementSelector() && this.classNames.length == 0 && this.attrs.length == 0 && this.notSelectors.length === 0; }; CssSelector.prototype.hasElementSelector = function () { return !!this.element; }; CssSelector.prototype.setElement = function (element) { if (element === void 0) { element = null; } this.element = element; }; /** Gets a template string for an element that matches the selector. */ CssSelector.prototype.getMatchingElementTemplate = function () { var tagName = this.element || 'div'; var classAttr = this.classNames.length > 0 ? " class=\"" + this.classNames.join(' ') + "\"" : ''; var attrs = ''; for (var i = 0; i < this.attrs.length; i += 2) { var attrName = this.attrs[i]; var attrValue = this.attrs[i + 1] !== '' ? "=\"" + this.attrs[i + 1] + "\"" : ''; attrs += " " + attrName + attrValue; } return getHtmlTagDefinition(tagName).isVoid ? "<" + tagName + classAttr + attrs + "/>" : "<" + tagName + classAttr + attrs + ">"; }; CssSelector.prototype.getAttrs = function () { var result = []; if (this.classNames.length > 0) { result.push('class', this.classNames.join(' ')); } return result.concat(this.attrs); }; CssSelector.prototype.addAttribute = function (name, value) { if (value === void 0) { value = ''; } this.attrs.push(name, value && value.toLowerCase() || ''); }; CssSelector.prototype.addClassName = function (name) { this.classNames.push(name.toLowerCase()); }; CssSelector.prototype.toString = function () { var res = this.element || ''; if (this.classNames) { this.classNames.forEach(function (klass) { return res += "." + klass; }); } if (this.attrs) { for (var i = 0; i < this.attrs.length; i += 2) { var name_1 = this.attrs[i]; var value = this.attrs[i + 1]; res += "[" + name_1 + (value ? '=' + value : '') + "]"; } } this.notSelectors.forEach(function (notSelector) { return res += ":not(" + notSelector + ")"; }); return res; }; return CssSelector; }()); /** * Reads a list of CssSelectors and allows to calculate which ones * are contained in a given CssSelector. */ var SelectorMatcher = /** @class */ (function () { function SelectorMatcher() { this._elementMap = new Map(); this._elementPartialMap = new Map(); this._classMap = new Map(); this._classPartialMap = new Map(); this._attrValueMap = new Map(); this._attrValuePartialMap = new Map(); this._listContexts = []; } SelectorMatcher.createNotMatcher = function (notSelectors) { var notMatcher = new SelectorMatcher(); notMatcher.addSelectables(notSelectors, null); return notMatcher; }; SelectorMatcher.prototype.addSelectables = function (cssSelectors, callbackCtxt) { var listContext = null; if (cssSelectors.length > 1) { listContext = new SelectorListContext(cssSelectors); this._listContexts.push(listContext); } for (var i = 0; i < cssSelectors.length; i++) { this._addSelectable(cssSelectors[i], callbackCtxt, listContext); } }; /** * Add an object that can be found later on by calling `match`. * @param cssSelector A css selector * @param callbackCtxt An opaque object that will be given to the callback of the `match` function */ SelectorMatcher.prototype._addSelectable = function (cssSelector, callbackCtxt, listContext) { var matcher = this; var element = cssSelector.element; var classNames = cssSelector.classNames; var attrs = cssSelector.attrs; var selectable = new SelectorContext(cssSelector, callbackCtxt, listContext); if (element) { var isTerminal = attrs.length === 0 && classNames.length === 0; if (isTerminal) { this._addTerminal(matcher._elementMap, element, selectable); } else { matcher = this._addPartial(matcher._elementPartialMap, element); } } if (classNames) { for (var i = 0; i < classNames.length; i++) { var isTerminal = attrs.length === 0 && i === classNames.length - 1; var className = classNames[i]; if (isTerminal) { this._addTerminal(matcher._classMap, className, selectable); } else { matcher = this._addPartial(matcher._classPartialMap, className); } } } if (attrs) { for (var i = 0; i < attrs.length; i += 2) { var isTerminal = i === attrs.length - 2; var name_2 = attrs[i]; var value = attrs[i + 1]; if (isTerminal) { var terminalMap = matcher._attrValueMap; var terminalValuesMap = terminalMap.get(name_2); if (!terminalValuesMap) { terminalValuesMap = new Map(); terminalMap.set(name_2, terminalValuesMap); } this._addTerminal(terminalValuesMap, value, selectable); } else { var partialMap = matcher._attrValuePartialMap; var partialValuesMap = partialMap.get(name_2); if (!partialValuesMap) { partialValuesMap = new Map(); partialMap.set(name_2, partialValuesMap); } matcher = this._addPartial(partialValuesMap, value); } } } }; SelectorMatcher.prototype._addTerminal = function (map, name, selectable) { var terminalList = map.get(name); if (!terminalList) { terminalList = []; map.set(name, terminalList); } terminalList.push(selectable); }; SelectorMatcher.prototype._addPartial = function (map, name) { var matcher = map.get(name); if (!matcher) { matcher = new SelectorMatcher(); map.set(name, matcher); } return matcher; }; /** * Find the objects that have been added via `addSelectable` * whose css selector is contained in the given css selector. * @param cssSelector A css selector * @param matchedCallback This callback will be called with the object handed into `addSelectable` * @return boolean true if a match was found */ SelectorMatcher.prototype.match = function (cssSelector, matchedCallback) { var result = false; var element = cssSelector.element; var classNames = cssSelector.classNames; var attrs = cssSelector.attrs; for (var i = 0; i < this._listContexts.length; i++) { this._listContexts[i].alreadyMatched = false; } result = this._matchTerminal(this._elementMap, element, cssSelector, matchedCallback) || result; result = this._matchPartial(this._elementPartialMap, element, cssSelector, matchedCallback) || result; if (classNames) { for (var i = 0; i < classNames.length; i++) { var className = classNames[i]; result = this._matchTerminal(this._classMap, className, cssSelector, matchedCallback) || result; result = this._matchPartial(this._classPartialMap, className, cssSelector, matchedCallback) || result; } } if (attrs) { for (var i = 0; i < attrs.length; i += 2) { var name_3 = attrs[i]; var value = attrs[i + 1]; var terminalValuesMap = this._attrValueMap.get(name_3); if (value) { result = this._matchTerminal(terminalValuesMap, '', cssSelector, matchedCallback) || result; } result = this._matchTerminal(terminalValuesMap, value, cssSelector, matchedCallback) || result; var partialValuesMap = this._attrValuePartialMap.get(name_3); if (value) { result = this._matchPartial(partialValuesMap, '', cssSelector, matchedCallback) || result; } result = this._matchPartial(partialValuesMap, value, cssSelector, matchedCallback) || result; } } return result; }; /** @internal */ SelectorMatcher.prototype._matchTerminal = function (map, name, cssSelector, matchedCallback) { if (!map || typeof name !== 'string') { return false; } var selectables = map.get(name) || []; var starSelectables = map.get('*'); if (starSelectables) { selectables = selectables.concat(starSelectables); } if (selectables.length === 0) { return false; } var selectable; var result = false; for (var i = 0; i < selectables.length; i++) { selectable = selectables[i]; result = selectable.finalize(cssSelector, matchedCallback) || result; } return result; }; /** @internal */ SelectorMatcher.prototype._matchPartial = function (map, name, cssSelector, matchedCallback) { if (!map || typeof name !== 'string') { return false; } var nestedSelector = map.get(name); if (!nestedSelector) { return false; } // TODO(perf): get rid of recursion and measure again // TODO(perf): don't pass the whole selector into the recursion, // but only the not processed parts return nestedSelector.match(cssSelector, matchedCallback); }; return SelectorMatcher; }()); var SelectorListContext = /** @class */ (function () { function SelectorListContext(selectors) { this.selectors = selectors; this.alreadyMatched = false; } return SelectorListContext; }()); // Store context to pass back selector and context when a selector is matched var SelectorContext = /** @class */ (function () { function SelectorContext(selector, cbContext, listContext) { this.selector = selector; this.cbContext = cbContext; this.listContext = listContext; this.notSelectors = selector.notSelectors; } SelectorContext.prototype.finalize = function (cssSelector, callback) { var result = true; if (this.notSelectors.length > 0 && (!this.listContext || !this.listContext.alreadyMatched)) { var notMatcher = SelectorMatcher.createNotMatcher(this.notSelectors); result = !notMatcher.match(cssSelector, null); } if (result && callback && (!this.listContext || !this.listContext.alreadyMatched)) { if (this.listContext) { this.listContext.alreadyMatched = true; } callback(this.selector, this.cbContext); } return result; }; return SelectorContext; }()); /** * @license * Copyright Google Inc. All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ var createInject = makeMetadataFactory('Inject', function (token) { return ({ token: token }); }); var createInjectionToken = makeMetadataFactory('InjectionToken', function (desc) { return ({ _desc: desc, ngInjectableDef: undefined }); }); var createAttribute = makeMetadataFactory('Attribute', function (attributeName) { return ({ attributeName: attributeName }); }); var createContentChildren = makeMetadataFactory('ContentChildren', function (selector, data) { if (data === void 0) { data = {}; } return (Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"])({ selector: selector, first: false, isViewQuery: false, descendants: false }, data)); }); var createContentChild = makeMetadataFactory('ContentChild', function (selector, data) { if (data === void 0) { data = {}; } return (Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"])({ selector: selector, first: true, isViewQuery: false, descendants: true }, data)); }); var createViewChildren = makeMetadataFactory('ViewChildren', function (selector, data) { if (data === void 0) { data = {}; } return (Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"])({ selector: selector, first: false, isViewQuery: true, descendants: true }, data)); }); var createViewChild = makeMetadataFactory('ViewChild', function (selector, data) { return (Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"])({ selector: selector, first: true, isViewQuery: true, descendants: true }, data)); }); var createDirective = makeMetadataFactory('Directive', function (dir) { if (dir === void 0) { dir = {}; } return dir; }); var ViewEncapsulation; (function (ViewEncapsulation) { ViewEncapsulation[ViewEncapsulation["Emulated"] = 0] = "Emulated"; ViewEncapsulation[ViewEncapsulation["Native"] = 1] = "Native"; ViewEncapsulation[ViewEncapsulation["None"] = 2] = "None"; ViewEncapsulation[ViewEncapsulation["ShadowDom"] = 3] = "ShadowDom"; })(ViewEncapsulation || (ViewEncapsulation = {})); var ChangeDetectionStrategy; (function (ChangeDetectionStrategy) { ChangeDetectionStrategy[ChangeDetectionStrategy["OnPush"] = 0] = "OnPush"; ChangeDetectionStrategy[ChangeDetectionStrategy["Default"] = 1] = "Default"; })(ChangeDetectionStrategy || (ChangeDetectionStrategy = {})); var createComponent = makeMetadataFactory('Component', function (c) { if (c === void 0) { c = {}; } return (Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"])({ changeDetection: ChangeDetectionStrategy.Default }, c)); }); var createPipe = makeMetadataFactory('Pipe', function (p) { return (Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"])({ pure: true }, p)); }); var createInput = makeMetadataFactory('Input', function (bindingPropertyName) { return ({ bindingPropertyName: bindingPropertyName }); }); var createOutput = makeMetadataFactory('Output', function (bindingPropertyName) { return ({ bindingPropertyName: bindingPropertyName }); }); var createHostBinding = makeMetadataFactory('HostBinding', function (hostPropertyName) { return ({ hostPropertyName: hostPropertyName }); }); var createHostListener = makeMetadataFactory('HostListener', function (eventName, args) { return ({ eventName: eventName, args: args }); }); var createNgModule = makeMetadataFactory('NgModule', function (ngModule) { return ngModule; }); var createInjectable = makeMetadataFactory('Injectable', function (injectable) { if (injectable === void 0) { injectable = {}; } return injectable; }); var CUSTOM_ELEMENTS_SCHEMA = { name: 'custom-elements' }; var NO_ERRORS_SCHEMA = { name: 'no-errors-schema' }; var createOptional = makeMetadataFactory('Optional'); var createSelf = makeMetadataFactory('Self'); var createSkipSelf = makeMetadataFactory('SkipSelf'); var createHost = makeMetadataFactory('Host'); var Type = Function; var SecurityContext; (function (SecurityContext) { SecurityContext[SecurityContext["NONE"] = 0] = "NONE"; SecurityContext[SecurityContext["HTML"] = 1] = "HTML"; SecurityContext[SecurityContext["STYLE"] = 2] = "STYLE"; SecurityContext[SecurityContext["SCRIPT"] = 3] = "SCRIPT"; SecurityContext[SecurityContext["URL"] = 4] = "URL"; SecurityContext[SecurityContext["RESOURCE_URL"] = 5] = "RESOURCE_URL"; })(SecurityContext || (SecurityContext = {})); var MissingTranslationStrategy; (function (MissingTranslationStrategy) { MissingTranslationStrategy[MissingTranslationStrategy["Error"] = 0] = "Error"; MissingTranslationStrategy[MissingTranslationStrategy["Warning"] = 1] = "Warning"; MissingTranslationStrategy[MissingTranslationStrategy["Ignore"] = 2] = "Ignore"; })(MissingTranslationStrategy || (MissingTranslationStrategy = {})); function makeMetadataFactory(name, props) { var factory = function () { var args = []; for (var _i = 0; _i < arguments.length; _i++) { args[_i] = arguments[_i]; } var values = props ? props.apply(void 0, Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__spread"])(args)) : {}; return Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"])({ ngMetadataName: name }, values); }; factory.isTypeOf = function (obj) { return obj && obj.ngMetadataName === name; }; factory.ngMetadataName = name; return factory; } function parserSelectorToSimpleSelector(selector) { var classes = selector.classNames && selector.classNames.length ? Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__spread"])([8 /* CLASS */], selector.classNames) : []; var elementName = selector.element && selector.element !== '*' ? selector.element : ''; return Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__spread"])([elementName], selector.attrs, classes); } function parserSelectorToNegativeSelector(selector) { var classes = selector.classNames && selector.classNames.length ? Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__spread"])([8 /* CLASS */], selector.classNames) : []; if (selector.element) { return Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__spread"])([ 1 /* NOT */ | 4 /* ELEMENT */, selector.element ], selector.attrs, classes); } else if (selector.attrs.length) { return Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__spread"])([1 /* NOT */ | 2 /* ATTRIBUTE */], selector.attrs, classes); } else { return selector.classNames && selector.classNames.length ? Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__spread"])([1 /* NOT */ | 8 /* CLASS */], selector.classNames) : []; } } function parserSelectorToR3Selector(selector) { var positive = parserSelectorToSimpleSelector(selector); var negative = selector.notSelectors && selector.notSelectors.length ? selector.notSelectors.map(function (notSelector) { return parserSelectorToNegativeSelector(notSelector); }) : []; return positive.concat.apply(positive, Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__spread"])(negative)); } function parseSelectorToR3Selector(selector) { return selector ? CssSelector.parse(selector).map(parserSelectorToR3Selector) : []; } var core = /*#__PURE__*/Object.freeze({ createInject: createInject, createInjectionToken: createInjectionToken, createAttribute: createAttribute, createContentChildren: createContentChildren, createContentChild: createContentChild, createViewChildren: createViewChildren, createViewChild: createViewChild, createDirective: createDirective, get ViewEncapsulation () { return ViewEncapsulation; }, get ChangeDetectionStrategy () { return ChangeDetectionStrategy; }, createComponent: createComponent, createPipe: createPipe, createInput: createInput, createOutput: createOutput, createHostBinding: createHostBinding, createHostListener: createHostListener, createNgModule: createNgModule, createInjectable: createInjectable, CUSTOM_ELEMENTS_SCHEMA: CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA: NO_ERRORS_SCHEMA, createOptional: createOptional, createSelf: createSelf, createSkipSelf: createSkipSelf, createHost: createHost, Type: Type, get SecurityContext () { return SecurityContext; }, get MissingTranslationStrategy () { return MissingTranslationStrategy; }, parseSelectorToR3Selector: parseSelectorToR3Selector }); /** * @license * Copyright Google Inc. All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ //// Types var TypeModifier; (function (TypeModifier) { TypeModifier[TypeModifier["Const"] = 0] = "Const"; })(TypeModifier || (TypeModifier = {})); var Type$1 = /** @class */ (function () { function Type(modifiers) { if (modifiers === void 0) { modifiers = null; } this.modifiers = modifiers; if (!modifiers) { this.modifiers = []; } } Type.prototype.hasModifier = function (modifier) { return this.modifiers.indexOf(modifier) !== -1; }; return Type; }()); var BuiltinTypeName; (function (BuiltinTypeName) { BuiltinTypeName[BuiltinTypeName["Dynamic"] = 0] = "Dynamic"; BuiltinTypeName[BuiltinTypeName["Bool"] = 1] = "Bool"; BuiltinTypeName[BuiltinTypeName["String"] = 2] = "String"; BuiltinTypeName[BuiltinTypeName["Int"] = 3] = "Int"; BuiltinTypeName[BuiltinTypeName["Number"] = 4] = "Number"; BuiltinTypeName[BuiltinTypeName["Function"] = 5] = "Function"; BuiltinTypeName[BuiltinTypeName["Inferred"] = 6] = "Inferred"; BuiltinTypeName[BuiltinTypeName["None"] = 7] = "None"; })(BuiltinTypeName || (BuiltinTypeName = {})); var BuiltinType = /** @class */ (function (_super) { Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(BuiltinType, _super); function BuiltinType(name, modifiers) { if (modifiers === void 0) { modifiers = null; } var _this = _super.call(this, modifiers) || this; _this.name = name; return _this; } BuiltinType.prototype.visitType = function (visitor, context) { return visitor.visitBuiltinType(this, context); }; return BuiltinType; }(Type$1)); var ExpressionType = /** @class */ (function (_super) { Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(ExpressionType, _super); function ExpressionType(value, modifiers, typeParams) { if (modifiers === void 0) { modifiers = null; } if (typeParams === void 0) { typeParams = null; } var _this = _super.call(this, modifiers) || this; _this.value = value; _this.typeParams = typeParams; return _this; } ExpressionType.prototype.visitType = function (visitor, context) { return visitor.visitExpressionType(this, context); }; return ExpressionType; }(Type$1)); var ArrayType = /** @class */ (function (_super) { Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(ArrayType, _super); function ArrayType(of, modifiers) { if (modifiers === void 0) { modifiers = null; } var _this = _super.call(this, modifiers) || this; _this.of = of; return _this; } ArrayType.prototype.visitType = function (visitor, context) { return visitor.visitArrayType(this, context); }; return ArrayType; }(Type$1)); var MapType = /** @class */ (function (_super) { Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(MapType, _super); function MapType(valueType, modifiers) { if (modifiers === void 0) { modifiers = null; } var _this = _super.call(this, modifiers) || this; _this.valueType = valueType || null; return _this; } MapType.prototype.visitType = function (visitor, context) { return visitor.visitMapType(this, context); }; return MapType; }(Type$1)); var DYNAMIC_TYPE = new BuiltinType(BuiltinTypeName.Dynamic); var INFERRED_TYPE = new BuiltinType(BuiltinTypeName.Inferred); var BOOL_TYPE = new BuiltinType(BuiltinTypeName.Bool); var INT_TYPE = new BuiltinType(BuiltinTypeName.Int); var NUMBER_TYPE = new BuiltinType(BuiltinTypeName.Number); var STRING_TYPE = new BuiltinType(BuiltinTypeName.String); var FUNCTION_TYPE = new BuiltinType(BuiltinTypeName.Function); var NONE_TYPE = new BuiltinType(BuiltinTypeName.None); ///// Expressions var BinaryOperator; (function (BinaryOperator) { BinaryOperator[BinaryOperator["Equals"] = 0] = "Equals"; BinaryOperator[BinaryOperator["NotEquals"] = 1] = "NotEquals"; BinaryOperator[BinaryOperator["Identical"] = 2] = "Identical"; BinaryOperator[BinaryOperator["NotIdentical"] = 3] = "NotIdentical"; BinaryOperator[BinaryOperator["Minus"] = 4] = "Minus"; BinaryOperator[BinaryOperator["Plus"] = 5] = "Plus"; BinaryOperator[BinaryOperator["Divide"] = 6] = "Divide"; BinaryOperator[BinaryOperator["Multiply"] = 7] = "Multiply"; BinaryOperator[BinaryOperator["Modulo"] = 8] = "Modulo"; BinaryOperator[BinaryOperator["And"] = 9] = "And"; BinaryOperator[BinaryOperator["Or"] = 10] = "Or"; BinaryOperator[BinaryOperator["BitwiseAnd"] = 11] = "BitwiseAnd"; BinaryOperator[BinaryOperator["Lower"] = 12] = "Lower"; BinaryOperator[BinaryOperator["LowerEquals"] = 13] = "LowerEquals"; BinaryOperator[BinaryOperator["Bigger"] = 14] = "Bigger"; BinaryOperator[BinaryOperator["BiggerEquals"] = 15] = "BiggerEquals"; })(BinaryOperator || (BinaryOperator = {})); function nullSafeIsEquivalent(base, other) { if (base == null || other == null) { return base == other; } return base.isEquivalent(other); } function areAllEquivalent(base, other) { var len = base.length; if (len !== other.length) { return false; } for (var i = 0; i < len; i++) { if (!base[i].isEquivalent(other[i])) { return false; } } return true; } var Expression = /** @class */ (function () { function Expression(type, sourceSpan) { this.type = type || null; this.sourceSpan = sourceSpan || null; } Expression.prototype.prop = function (name, sourceSpan) { return new ReadPropExpr(this, name, null, sourceSpan); }; Expression.prototype.key = function (index, type, sourceSpan) { return new ReadKeyExpr(this, index, type, sourceSpan); }; Expression.prototype.callMethod = function (name, params, sourceSpan) { return new InvokeMethodExpr(this, name, params, null, sourceSpan); }; Expression.prototype.callFn = function (params, sourceSpan) { return new InvokeFunctionExpr(this, params, null, sourceSpan); }; Expression.prototype.instantiate = function (params, type, sourceSpan) { return new InstantiateExpr(this, params, type, sourceSpan); }; Expression.prototype.conditional = function (trueCase, falseCase, sourceSpan) { if (falseCase === void 0) { falseCase = null; } return new ConditionalExpr(this, trueCase, falseCase, null, sourceSpan); }; Expression.prototype.equals = function (rhs, sourceSpan) { return new BinaryOperatorExpr(BinaryOperator.Equals, this, rhs, null, sourceSpan); }; Expression.prototype.notEquals = function (rhs, sourceSpan) { return new BinaryOperatorExpr(BinaryOperator.NotEquals, this, rhs, null, sourceSpan); }; Expression.prototype.identical = function (rhs, sourceSpan) { return new BinaryOperatorExpr(BinaryOperator.Identical, this, rhs, null, sourceSpan); }; Expression.prototype.notIdentical = function (rhs, sourceSpan) { return new BinaryOperatorExpr(BinaryOperator.NotIdentical, this, rhs, null, sourceSpan); }; Expression.prototype.minus = function (rhs, sourceSpan) { return new BinaryOperatorExpr(BinaryOperator.Minus, this, rhs, null, sourceSpan); }; Expression.prototype.plus = function (rhs, sourceSpan) { return new BinaryOperatorExpr(BinaryOperator.Plus, this, rhs, null, sourceSpan); }; Expression.prototype.divide = function (rhs, sourceSpan) { return new BinaryOperatorExpr(BinaryOperator.Divide, this, rhs, null, sourceSpan); }; Expression.prototype.multiply = function (rhs, sourceSpan) { return new BinaryOperatorExpr(BinaryOperator.Multiply, this, rhs, null, sourceSpan); }; Expression.prototype.modulo = function (rhs, sourceSpan) { return new BinaryOperatorExpr(BinaryOperator.Modulo, this, rhs, null, sourceSpan); }; Expression.prototype.and = function (rhs, sourceSpan) { return new BinaryOperatorExpr(BinaryOperator.And, this, rhs, null, sourceSpan); }; Expression.prototype.bitwiseAnd = function (rhs, sourceSpan, parens) { if (parens === void 0) { parens = true; } return new BinaryOperatorExpr(BinaryOperator.BitwiseAnd, this, rhs, null, sourceSpan, parens); }; Expression.prototype.or = function (rhs, sourceSpan) { return new BinaryOperatorExpr(BinaryOperator.Or, this, rhs, null, sourceSpan); }; Expression.prototype.lower = function (rhs, sourceSpan) { return new BinaryOperatorExpr(BinaryOperator.Lower, this, rhs, null, sourceSpan); }; Expression.prototype.lowerEquals = function (rhs, sourceSpan) { return new BinaryOperatorExpr(BinaryOperator.LowerEquals, this, rhs, null, sourceSpan); }; Expression.prototype.bigger = function (rhs, sourceSpan) { return new BinaryOperatorExpr(BinaryOperator.Bigger, this, rhs, null, sourceSpan); }; Expression.prototype.biggerEquals = function (rhs, sourceSpan) { return new BinaryOperatorExpr(BinaryOperator.BiggerEquals, this, rhs, null, sourceSpan); }; Expression.prototype.isBlank = function (sourceSpan) { // Note: We use equals by purpose here to compare to null and undefined in JS. // We use the typed null to allow strictNullChecks to narrow types. return this.equals(TYPED_NULL_EXPR, sourceSpan); }; Expression.prototype.cast = function (type, sourceSpan) { return new CastExpr(this, type, sourceSpan); }; Expression.prototype.toStmt = function () { return new ExpressionStatement(this, null); }; return Expression; }()); var BuiltinVar; (function (BuiltinVar) { BuiltinVar[BuiltinVar["This"] = 0] = "This"; BuiltinVar[BuiltinVar["Super"] = 1] = "Super"; BuiltinVar[BuiltinVar["CatchError"] = 2] = "CatchError"; BuiltinVar[BuiltinVar["CatchStack"] = 3] = "CatchStack"; })(BuiltinVar || (BuiltinVar = {})); var ReadVarExpr = /** @class */ (function (_super) { Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(ReadVarExpr, _super); function ReadVarExpr(name, type, sourceSpan) { var _this = _super.call(this, type, sourceSpan) || this; if (typeof name === 'string') { _this.name = name; _this.builtin = null; } else { _this.name = null; _this.builtin = name; } return _this; } ReadVarExpr.prototype.isEquivalent = function (e) { return e instanceof ReadVarExpr && this.name === e.name && this.builtin === e.builtin; }; ReadVarExpr.prototype.isConstant = function () { return false; }; ReadVarExpr.prototype.visitExpression = function (visitor, context) { return visitor.visitReadVarExpr(this, context); }; ReadVarExpr.prototype.set = function (value) { if (!this.name) { throw new Error("Built in variable " + this.builtin + " can not be assigned to."); } return new WriteVarExpr(this.name, value, null, this.sourceSpan); }; return ReadVarExpr; }(Expression)); var TypeofExpr = /** @class */ (function (_super) { Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(TypeofExpr, _super); function TypeofExpr(expr, type, sourceSpan) { var _this = _super.call(this, type, sourceSpan) || this; _this.expr = expr; return _this; } TypeofExpr.prototype.visitExpression = function (visitor, context) { return visitor.visitTypeofExpr(this, context); }; TypeofExpr.prototype.isEquivalent = function (e) { return e instanceof TypeofExpr && e.expr.isEquivalent(this.expr); }; TypeofExpr.prototype.isConstant = function () { return this.expr.isConstant(); }; return TypeofExpr; }(Expression)); var WrappedNodeExpr = /** @class */ (function (_super) { Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(WrappedNodeExpr, _super); function WrappedNodeExpr(node, type, sourceSpan) { var _this = _super.call(this, type, sourceSpan) || this; _this.node = node; return _this; } WrappedNodeExpr.prototype.isEquivalent = function (e) { return e instanceof WrappedNodeExpr && this.node === e.node; }; WrappedNodeExpr.prototype.isConstant = function () { return false; }; WrappedNodeExpr.prototype.visitExpression = function (visitor, context) { return visitor.visitWrappedNodeExpr(this, context); }; return WrappedNodeExpr; }(Expression)); var WriteVarExpr = /** @class */ (function (_super) { Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(WriteVarExpr, _super); function WriteVarExpr(name, value, type, sourceSpan) { var _this = _super.call(this, type || value.type, sourceSpan) || this; _this.name = name; _this.value = value; return _this; } WriteVarExpr.prototype.isEquivalent = function (e) { return e instanceof WriteVarExpr && this.name === e.name && this.value.isEquivalent(e.value); }; WriteVarExpr.prototype.isConstant = function () { return false; }; WriteVarExpr.prototype.visitExpression = function (visitor, context) { return visitor.visitWriteVarExpr(this, context); }; WriteVarExpr.prototype.toDeclStmt = function (type, modifiers) { return new DeclareVarStmt(this.name, this.value, type, modifiers, this.sourceSpan); }; WriteVarExpr.prototype.toConstDecl = function () { return this.toDeclStmt(INFERRED_TYPE, [StmtModifier.Final]); }; return WriteVarExpr; }(Expression)); var WriteKeyExpr = /** @class */ (function (_super) { Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(WriteKeyExpr, _super); function WriteKeyExpr(receiver, index, value, type, sourceSpan) { var _this = _super.call(this, type || value.type, sourceSpan) || this; _this.receiver = receiver; _this.index = index; _this.value = value; return _this; } WriteKeyExpr.prototype.isEquivalent = function (e) { return e instanceof WriteKeyExpr && this.receiver.isEquivalent(e.receiver) && this.index.isEquivalent(e.index) && this.value.isEquivalent(e.value); }; WriteKeyExpr.prototype.isConstant = function () { return false; }; WriteKeyExpr.prototype.visitExpression = function (visitor, context) { return visitor.visitWriteKeyExpr(this, context); }; return WriteKeyExpr; }(Expression)); var WritePropExpr = /** @class */ (function (_super) { Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(WritePropExpr, _super); function WritePropExpr(receiver, name, value, type, sourceSpan) { var _this = _super.call(this, type || value.type, sourceSpan) || this; _this.receiver = receiver; _this.name = name; _this.value = value; return _this; } WritePropExpr.prototype.isEquivalent = function (e) { return e instanceof WritePropExpr && this.receiver.isEquivalent(e.receiver) && this.name === e.name && this.value.isEquivalent(e.value); }; WritePropExpr.prototype.isConstant = function () { return false; }; WritePropExpr.prototype.visitExpression = function (visitor, context) { return visitor.visitWritePropExpr(this, context); }; return WritePropExpr; }(Expression)); var BuiltinMethod; (function (BuiltinMethod) { BuiltinMethod[BuiltinMethod["ConcatArray"] = 0] = "ConcatArray"; BuiltinMethod[BuiltinMethod["SubscribeObservable"] = 1] = "SubscribeObservable"; BuiltinMethod[BuiltinMethod["Bind"] = 2] = "Bind"; })(BuiltinMethod || (BuiltinMethod = {})); var InvokeMethodExpr = /** @class */ (function (_super) { Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(InvokeMethodExpr, _super); function InvokeMethodExpr(receiver, method, args, type, sourceSpan) { var _this = _super.call(this, type, sourceSpan) || this; _this.receiver = receiver; _this.args = args; if (typeof method === 'string') { _this.name = method; _this.builtin = null; } else { _this.name = null; _this.builtin = method; } return _this; } InvokeMethodExpr.prototype.isEquivalent = function (e) { return e instanceof InvokeMethodExpr && this.receiver.isEquivalent(e.receiver) && this.name === e.name && this.builtin === e.builtin && areAllEquivalent(this.args, e.args); }; InvokeMethodExpr.prototype.isConstant = function () { return false; }; InvokeMethodExpr.prototype.visitExpression = function (visitor, context) { return visitor.visitInvokeMethodExpr(this, context); }; return InvokeMethodExpr; }(Expression)); var InvokeFunctionExpr = /** @class */ (function (_super) { Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(InvokeFunctionExpr, _super); function InvokeFunctionExpr(fn, args, type, sourceSpan, pure) { if (pure === void 0) { pure = false; } var _this = _super.call(this, type, sourceSpan) || this; _this.fn = fn; _this.args = args; _this.pure = pure; return _this; } InvokeFunctionExpr.prototype.isEquivalent = function (e) { return e instanceof InvokeFunctionExpr && this.fn.isEquivalent(e.fn) && areAllEquivalent(this.args, e.args) && this.pure === e.pure; }; InvokeFunctionExpr.prototype.isConstant = function () { return false; }; InvokeFunctionExpr.prototype.visitExpression = function (visitor, context) { return visitor.visitInvokeFunctionExpr(this, context); }; return InvokeFunctionExpr; }(Expression)); var InstantiateExpr = /** @class */ (function (_super) { Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(InstantiateExpr, _super); function InstantiateExpr(classExpr, args, type, sourceSpan) { var _this = _super.call(this, type, sourceSpan) || this; _this.classExpr = classExpr; _this.args = args; return _this; } InstantiateExpr.prototype.isEquivalent = function (e) { return e instanceof InstantiateExpr && this.classExpr.isEquivalent(e.classExpr) && areAllEquivalent(this.args, e.args); }; InstantiateExpr.prototype.isConstant = function () { return false; }; InstantiateExpr.prototype.visitExpression = function (visitor, context) { return visitor.visitInstantiateExpr(this, context); }; return InstantiateExpr; }(Expression)); var LiteralExpr = /** @class */ (function (_super) { Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(LiteralExpr, _super); function LiteralExpr(value, type, sourceSpan) { var _this = _super.call(this, type, sourceSpan) || this; _this.value = value; return _this; } LiteralExpr.prototype.isEquivalent = function (e) { return e instanceof LiteralExpr && this.value === e.value; }; LiteralExpr.prototype.isConstant = function () { return true; }; LiteralExpr.prototype.visitExpression = function (visitor, context) { return visitor.visitLiteralExpr(this, context); }; return LiteralExpr; }(Expression)); var ExternalExpr = /** @class */ (function (_super) { Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(ExternalExpr, _super); function ExternalExpr(value, type, typeParams, sourceSpan) { if (typeParams === void 0) { typeParams = null; } var _this = _super.call(this, type, sourceSpan) || this; _this.value = value; _this.typeParams = typeParams; return _this; } ExternalExpr.prototype.isEquivalent = function (e) { return e instanceof ExternalExpr && this.value.name === e.value.name && this.value.moduleName === e.value.moduleName && this.value.runtime === e.value.runtime; }; ExternalExpr.prototype.isConstant = function () { return false; }; ExternalExpr.prototype.visitExpression = function (visitor, context) { return visitor.visitExternalExpr(this, context); }; return ExternalExpr; }(Expression)); var ExternalReference = /** @class */ (function () { function ExternalReference(moduleName, name, runtime) { this.moduleName = moduleName; this.name = name; this.runtime = runtime; } return ExternalReference; }()); var ConditionalExpr = /** @class */ (function (_super) { Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(ConditionalExpr, _super); function ConditionalExpr(condition, trueCase, falseCase, type, sourceSpan) { if (falseCase === void 0) { falseCase = null; } var _this = _super.call(this, type || trueCase.type, sourceSpan) || this; _this.condition = condition; _this.falseCase = falseCase; _this.trueCase = trueCase; return _this; } ConditionalExpr.prototype.isEquivalent = function (e) { return e instanceof ConditionalExpr && this.condition.isEquivalent(e.condition) && this.trueCase.isEquivalent(e.trueCase) && nullSafeIsEquivalent(this.falseCase, e.falseCase); }; ConditionalExpr.prototype.isConstant = function () { return false; }; ConditionalExpr.prototype.visitExpression = function (visitor, context) { return visitor.visitConditionalExpr(this, context); }; return ConditionalExpr; }(Expression)); var NotExpr = /** @class */ (function (_super) { Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(NotExpr, _super); function NotExpr(condition, sourceSpan) { var _this = _super.call(this, BOOL_TYPE, sourceSpan) || this; _this.condition = condition; return _this; } NotExpr.prototype.isEquivalent = function (e) { return e instanceof NotExpr && this.condition.isEquivalent(e.condition); }; NotExpr.prototype.isConstant = function () { return false; }; NotExpr.prototype.visitExpression = function (visitor, context) { return visitor.visitNotExpr(this, context); }; return NotExpr; }(Expression)); var AssertNotNull = /** @class */ (function (_super) { Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(AssertNotNull, _super); function AssertNotNull(condition, sourceSpan) { var _this = _super.call(this, condition.type, sourceSpan) || this; _this.condition = condition; return _this; } AssertNotNull.prototype.isEquivalent = function (e) { return e instanceof AssertNotNull && this.condition.isEquivalent(e.condition); }; AssertNotNull.prototype.isConstant = function () { return false; }; AssertNotNull.prototype.visitExpression = function (visitor, context) { return visitor.visitAssertNotNullExpr(this, context); }; return AssertNotNull; }(Expression)); var CastExpr = /** @class */ (function (_super) { Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(CastExpr, _super); function CastExpr(value, type, sourceSpan) { var _this = _super.call(this, type, sourceSpan) || this; _this.value = value; return _this; } CastExpr.prototype.isEquivalent = function (e) { return e instanceof CastExpr && this.value.isEquivalent(e.value); }; CastExpr.prototype.isConstant = function () { return false; }; CastExpr.prototype.visitExpression = function (visitor, context) { return visitor.visitCastExpr(this, context); }; return CastExpr; }(Expression)); var FnParam = /** @class */ (function () { function FnParam(name, type) { if (type === void 0) { type = null; } this.name = name; this.type = type; } FnParam.prototype.isEquivalent = function (param) { return this.name === param.name; }; return FnParam; }()); var FunctionExpr = /** @class */ (function (_super) { Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(FunctionExpr, _super); function FunctionExpr(params, statements, type, sourceSpan, name) { var _this = _super.call(this, type, sourceSpan) || this; _this.params = params; _this.statements = statements; _this.name = name; return _this; } FunctionExpr.prototype.isEquivalent = function (e) { return e instanceof FunctionExpr && areAllEquivalent(this.params, e.params) && areAllEquivalent(this.statements, e.statements); }; FunctionExpr.prototype.isConstant = function () { return false; }; FunctionExpr.prototype.visitExpression = function (visitor, context) { return visitor.visitFunctionExpr(this, context); }; FunctionExpr.prototype.toDeclStmt = function (name, modifiers) { if (modifiers === void 0) { modifiers = null; } return new DeclareFunctionStmt(name, this.params, this.statements, this.type, modifiers, this.sourceSpan); }; return FunctionExpr; }(Expression)); var BinaryOperatorExpr = /** @class */ (function (_super) { Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(BinaryOperatorExpr, _super); function BinaryOperatorExpr(operator, lhs, rhs, type, sourceSpan, parens) { if (parens === void 0) { parens = true; } var _this = _super.call(this, type || lhs.type, sourceSpan) || this; _this.operator = operator; _this.rhs = rhs; _this.parens = parens; _this.lhs = lhs; return _this; } BinaryOperatorExpr.prototype.isEquivalent = function (e) { return e instanceof BinaryOperatorExpr && this.operator === e.operator && this.lhs.isEquivalent(e.lhs) && this.rhs.isEquivalent(e.rhs); }; BinaryOperatorExpr.prototype.isConstant = function () { return false; }; BinaryOperatorExpr.prototype.visitExpression = function (visitor, context) { return visitor.visitBinaryOperatorExpr(this, context); }; return BinaryOperatorExpr; }(Expression)); var ReadPropExpr = /** @class */ (function (_super) { Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(ReadPropExpr, _super); function ReadPropExpr(receiver, name, type, sourceSpan) { var _this = _super.call(this, type, sourceSpan) || this; _this.receiver = receiver; _this.name = name; return _this; } ReadPropExpr.prototype.isEquivalent = function (e) { return e instanceof ReadPropExpr && this.receiver.isEquivalent(e.receiver) && this.name === e.name; }; ReadPropExpr.prototype.isConstant = function () { return false; }; ReadPropExpr.prototype.visitExpression = function (visitor, context) { return visitor.visitReadPropExpr(this, context); }; ReadPropExpr.prototype.set = function (value) { return new WritePropExpr(this.receiver, this.name, value, null, this.sourceSpan); }; return ReadPropExpr; }(Expression)); var ReadKeyExpr = /** @class */ (function (_super) { Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(ReadKeyExpr, _super); function ReadKeyExpr(receiver, index, type, sourceSpan) { var _this = _super.call(this, type, sourceSpan) || this; _this.receiver = receiver; _this.index = index; return _this; } ReadKeyExpr.prototype.isEquivalent = function (e) { return e instanceof ReadKeyExpr && this.receiver.isEquivalent(e.receiver) && this.index.isEquivalent(e.index); }; ReadKeyExpr.prototype.isConstant = function () { return false; }; ReadKeyExpr.prototype.visitExpression = function (visitor, context) { return visitor.visitReadKeyExpr(this, context); }; ReadKeyExpr.prototype.set = function (value) { return new WriteKeyExpr(this.receiver, this.index, value, null, this.sourceSpan); }; return ReadKeyExpr; }(Expression)); var LiteralArrayExpr = /** @class */ (function (_super) { Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(LiteralArrayExpr, _super); function LiteralArrayExpr(entries, type, sourceSpan) { var _this = _super.call(this, type, sourceSpan) || this; _this.entries = entries; return _this; } LiteralArrayExpr.prototype.isConstant = function () { return this.entries.every(function (e) { return e.isConstant(); }); }; LiteralArrayExpr.prototype.isEquivalent = function (e) { return e instanceof LiteralArrayExpr && areAllEquivalent(this.entries, e.entries); }; LiteralArrayExpr.prototype.visitExpression = function (visitor, context) { return visitor.visitLiteralArrayExpr(this, context); }; return LiteralArrayExpr; }(Expression)); var LiteralMapEntry = /** @class */ (function () { function LiteralMapEntry(key, value, quoted) { this.key = key; this.value = value; this.quoted = quoted; } LiteralMapEntry.prototype.isEquivalent = function (e) { return this.key === e.key && this.value.isEquivalent(e.value); }; return LiteralMapEntry; }()); var LiteralMapExpr = /** @class */ (function (_super) { Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(LiteralMapExpr, _super); function LiteralMapExpr(entries, type, sourceSpan) { var _this = _super.call(this, type, sourceSpan) || this; _this.entries = entries; _this.valueType = null; if (type) { _this.valueType = type.valueType; } return _this; } LiteralMapExpr.prototype.isEquivalent = function (e) { return e instanceof LiteralMapExpr && areAllEquivalent(this.entries, e.entries); }; LiteralMapExpr.prototype.isConstant = function () { return this.entries.every(function (e) { return e.value.isConstant(); }); }; LiteralMapExpr.prototype.visitExpression = function (visitor, context) { return visitor.visitLiteralMapExpr(this, context); }; return LiteralMapExpr; }(Expression)); var CommaExpr = /** @class */ (function (_super) { Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(CommaExpr, _super); function CommaExpr(parts, sourceSpan) { var _this = _super.call(this, parts[parts.length - 1].type, sourceSpan) || this; _this.parts = parts; return _this; } CommaExpr.prototype.isEquivalent = function (e) { return e instanceof CommaExpr && areAllEquivalent(this.parts, e.parts); }; CommaExpr.prototype.isConstant = function () { return false; }; CommaExpr.prototype.visitExpression = function (visitor, context) { return visitor.visitCommaExpr(this, context); }; return CommaExpr; }(Expression)); var THIS_EXPR = new ReadVarExpr(BuiltinVar.This, null, null); var SUPER_EXPR = new ReadVarExpr(BuiltinVar.Super, null, null); var CATCH_ERROR_VAR = new ReadVarExpr(BuiltinVar.CatchError, null, null); var CATCH_STACK_VAR = new ReadVarExpr(BuiltinVar.CatchStack, null, null); var NULL_EXPR = new LiteralExpr(null, null, null); var TYPED_NULL_EXPR = new LiteralExpr(null, INFERRED_TYPE, null); //// Statements var StmtModifier; (function (StmtModifier) { StmtModifier[StmtModifier["Final"] = 0] = "Final"; StmtModifier[StmtModifier["Private"] = 1] = "Private"; StmtModifier[StmtModifier["Exported"] = 2] = "Exported"; StmtModifier[StmtModifier["Static"] = 3] = "Static"; })(StmtModifier || (StmtModifier = {})); var Statement = /** @class */ (function () { function Statement(modifiers, sourceSpan) { this.modifiers = modifiers || []; this.sourceSpan = sourceSpan || null; } Statement.prototype.hasModifier = function (modifier) { return this.modifiers.indexOf(modifier) !== -1; }; return Statement; }()); var DeclareVarStmt = /** @class */ (function (_super) { Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(DeclareVarStmt, _super); function DeclareVarStmt(name, value, type, modifiers, sourceSpan) { if (modifiers === void 0) { modifiers = null; } var _this = _super.call(this, modifiers, sourceSpan) || this; _this.name = name; _this.value = value; _this.type = type || (value && value.type) || null; return _this; } DeclareVarStmt.prototype.isEquivalent = function (stmt) { return stmt instanceof DeclareVarStmt && this.name === stmt.name && (this.value ? !!stmt.value && this.value.isEquivalent(stmt.value) : !stmt.value); }; DeclareVarStmt.prototype.visitStatement = function (visitor, context) { return visitor.visitDeclareVarStmt(this, context); }; return DeclareVarStmt; }(Statement)); var DeclareFunctionStmt = /** @class */ (function (_super) { Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(DeclareFunctionStmt, _super); function DeclareFunctionStmt(name, params, statements, type, modifiers, sourceSpan) { if (modifiers === void 0) { modifiers = null; } var _this = _super.call(this, modifiers, sourceSpan) || this; _this.name = name; _this.params = params; _this.statements = statements; _this.type = type || null; return _this; } DeclareFunctionStmt.prototype.isEquivalent = function (stmt) { return stmt instanceof DeclareFunctionStmt && areAllEquivalent(this.params, stmt.params) && areAllEquivalent(this.statements, stmt.statements); }; DeclareFunctionStmt.prototype.visitStatement = function (visitor, context) { return visitor.visitDeclareFunctionStmt(this, context); }; return DeclareFunctionStmt; }(Statement)); var ExpressionStatement = /** @class */ (function (_super) { Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(ExpressionStatement, _super); function ExpressionStatement(expr, sourceSpan) { var _this = _super.call(this, null, sourceSpan) || this; _this.expr = expr; return _this; } ExpressionStatement.prototype.isEquivalent = function (stmt) { return stmt instanceof ExpressionStatement && this.expr.isEquivalent(stmt.expr); }; ExpressionStatement.prototype.visitStatement = function (visitor, context) { return visitor.visitExpressionStmt(this, context); }; return ExpressionStatement; }(Statement)); var ReturnStatement = /** @class */ (function (_super) { Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(ReturnStatement, _super); function ReturnStatement(value, sourceSpan) { var _this = _super.call(this, null, sourceSpan) || this; _this.value = value; return _this; } ReturnStatement.prototype.isEquivalent = function (stmt) { return stmt instanceof ReturnStatement && this.value.isEquivalent(stmt.value); }; ReturnStatement.prototype.visitStatement = function (visitor, context) { return visitor.visitReturnStmt(this, context); }; return ReturnStatement; }(Statement)); var AbstractClassPart = /** @class */ (function () { function AbstractClassPart(type, modifiers) { this.modifiers = modifiers; if (!modifiers) { this.modifiers = []; } this.type = type || null; } AbstractClassPart.prototype.hasModifier = function (modifier) { return this.modifiers.indexOf(modifier) !== -1; }; return AbstractClassPart; }()); var ClassField = /** @class */ (function (_super) { Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(ClassField, _super); function ClassField(name, type, modifiers, initializer) { if (modifiers === void 0) { modifiers = null; } var _this = _super.call(this, type, modifiers) || this; _this.name = name; _this.initializer = initializer; return _this; } ClassField.prototype.isEquivalent = function (f) { return this.name === f.name; }; return ClassField; }(AbstractClassPart)); var ClassMethod = /** @class */ (function (_super) { Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(ClassMethod, _super); function ClassMethod(name, params, body, type, modifiers) { if (modifiers === void 0) { modifiers = null; } var _this = _super.call(this, type, modifiers) || this; _this.name = name; _this.params = params; _this.body = body; return _this; } ClassMethod.prototype.isEquivalent = function (m) { return this.name === m.name && areAllEquivalent(this.body, m.body); }; return ClassMethod; }(AbstractClassPart)); var ClassGetter = /** @class */ (function (_super) { Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(ClassGetter, _super); function ClassGetter(name, body, type, modifiers) { if (modifiers === void 0) { modifiers = null; } var _this = _super.call(this, type, modifiers) || this; _this.name = name; _this.body = body; return _this; } ClassGetter.prototype.isEquivalent = function (m) { return this.name === m.name && areAllEquivalent(this.body, m.body); }; return ClassGetter; }(AbstractClassPart)); var ClassStmt = /** @class */ (function (_super) { Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(ClassStmt, _super); function ClassStmt(name, parent, fields, getters, constructorMethod, methods, modifiers, sourceSpan) { if (modifiers === void 0) { modifiers = null; } var _this = _super.call(this, modifiers, sourceSpan) || this; _this.name = name; _this.parent = parent; _this.fields = fields; _this.getters = getters; _this.constructorMethod = constructorMethod; _this.methods = methods; return _this; } ClassStmt.prototype.isEquivalent = function (stmt) { return stmt instanceof ClassStmt && this.name === stmt.name && nullSafeIsEquivalent(this.parent, stmt.parent) && areAllEquivalent(this.fields, stmt.fields) && areAllEquivalent(this.getters, stmt.getters) && this.constructorMethod.isEquivalent(stmt.constructorMethod) && areAllEquivalent(this.methods, stmt.methods); }; ClassStmt.prototype.visitStatement = function (visitor, context) { return visitor.visitDeclareClassStmt(this, context); }; return ClassStmt; }(Statement)); var IfStmt = /** @class */ (function (_super) { Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(IfStmt, _super); function IfStmt(condition, trueCase, falseCase, sourceSpan) { if (falseCase === void 0) { falseCase = []; } var _this = _super.call(this, null, sourceSpan) || this; _this.condition = condition; _this.trueCase = trueCase; _this.falseCase = falseCase; return _this; } IfStmt.prototype.isEquivalent = function (stmt) { return stmt instanceof IfStmt && this.condition.isEquivalent(stmt.condition) && areAllEquivalent(this.trueCase, stmt.trueCase) && areAllEquivalent(this.falseCase, stmt.falseCase); }; IfStmt.prototype.visitStatement = function (visitor, context) { return visitor.visitIfStmt(this, context); }; return IfStmt; }(Statement)); var CommentStmt = /** @class */ (function (_super) { Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(CommentStmt, _super); function CommentStmt(comment, multiline, sourceSpan) { if (multiline === void 0) { multiline = false; } var _this = _super.call(this, null, sourceSpan) || this; _this.comment = comment; _this.multiline = multiline; return _this; } CommentStmt.prototype.isEquivalent = function (stmt) { return stmt instanceof CommentStmt; }; CommentStmt.prototype.visitStatement = function (visitor, context) { return visitor.visitCommentStmt(this, context); }; return CommentStmt; }(Statement)); var JSDocCommentStmt = /** @class */ (function (_super) { Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(JSDocCommentStmt, _super); function JSDocCommentStmt(tags, sourceSpan) { if (tags === void 0) { tags = []; } var _this = _super.call(this, null, sourceSpan) || this; _this.tags = tags; return _this; } JSDocCommentStmt.prototype.isEquivalent = function (stmt) { return stmt instanceof JSDocCommentStmt && this.toString() === stmt.toString(); }; JSDocCommentStmt.prototype.visitStatement = function (visitor, context) { return visitor.visitJSDocCommentStmt(this, context); }; JSDocCommentStmt.prototype.toString = function () { return serializeTags(this.tags); }; return JSDocCommentStmt; }(Statement)); var TryCatchStmt = /** @class */ (function (_super) { Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(TryCatchStmt, _super); function TryCatchStmt(bodyStmts, catchStmts, sourceSpan) { var _this = _super.call(this, null, sourceSpan) || this; _this.bodyStmts = bodyStmts; _this.catchStmts = catchStmts; return _this; } TryCatchStmt.prototype.isEquivalent = function (stmt) { return stmt instanceof TryCatchStmt && areAllEquivalent(this.bodyStmts, stmt.bodyStmts) && areAllEquivalent(this.catchStmts, stmt.catchStmts); }; TryCatchStmt.prototype.visitStatement = function (visitor, context) { return visitor.visitTryCatchStmt(this, context); }; return TryCatchStmt; }(Statement)); var ThrowStmt = /** @class */ (function (_super) { Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(ThrowStmt, _super); function ThrowStmt(error, sourceSpan) { var _this = _super.call(this, null, sourceSpan) || this; _this.error = error; return _this; } ThrowStmt.prototype.isEquivalent = function (stmt) { return stmt instanceof TryCatchStmt && this.error.isEquivalent(stmt.error); }; ThrowStmt.prototype.visitStatement = function (visitor, context) { return visitor.visitThrowStmt(this, context); }; return ThrowStmt; }(Statement)); var AstTransformer = /** @class */ (function () { function AstTransformer() { } AstTransformer.prototype.transformExpr = function (expr, context) { return expr; }; AstTransformer.prototype.transformStmt = function (stmt, context) { return stmt; }; AstTransformer.prototype.visitReadVarExpr = function (ast, context) { return this.transformExpr(ast, context); }; AstTransformer.prototype.visitWrappedNodeExpr = function (ast, context) { return this.transformExpr(ast, context); }; AstTransformer.prototype.visitTypeofExpr = function (expr, context) { return this.transformExpr(new TypeofExpr(expr.expr.visitExpression(this, context), expr.type, expr.sourceSpan), context); }; AstTransformer.prototype.visitWriteVarExpr = function (expr, context) { return this.transformExpr(new WriteVarExpr(expr.name, expr.value.visitExpression(this, context), expr.type, expr.sourceSpan), context); }; AstTransformer.prototype.visitWriteKeyExpr = function (expr, context) { return this.transformExpr(new WriteKeyExpr(expr.receiver.visitExpression(this, context), expr.index.visitExpression(this, context), expr.value.visitExpression(this, context), expr.type, expr.sourceSpan), context); }; AstTransformer.prototype.visitWritePropExpr = function (expr, context) { return this.transformExpr(new WritePropExpr(expr.receiver.visitExpression(this, context), expr.name, expr.value.visitExpression(this, context), expr.type, expr.sourceSpan), context); }; AstTransformer.prototype.visitInvokeMethodExpr = function (ast, context) { var method = ast.builtin || ast.name; return this.transformExpr(new InvokeMethodExpr(ast.receiver.visitExpression(this, context), method, this.visitAllExpressions(ast.args, context), ast.type, ast.sourceSpan), context); }; AstTransformer.prototype.visitInvokeFunctionExpr = function (ast, context) { return this.transformExpr(new InvokeFunctionExpr(ast.fn.visitExpression(this, context), this.visitAllExpressions(ast.args, context), ast.type, ast.sourceSpan), context); }; AstTransformer.prototype.visitInstantiateExpr = function (ast, context) { return this.transformExpr(new InstantiateExpr(ast.classExpr.visitExpression(this, context), this.visitAllExpressions(ast.args, context), ast.type, ast.sourceSpan), context); }; AstTransformer.prototype.visitLiteralExpr = function (ast, context) { return this.transformExpr(ast, context); }; AstTransformer.prototype.visitExternalExpr = function (ast, context) { return this.transformExpr(ast, context); }; AstTransformer.prototype.visitConditionalExpr = function (ast, context) { return this.transformExpr(new ConditionalExpr(ast.condition.visitExpression(this, context), ast.trueCase.visitExpression(this, context), ast.falseCase.visitExpression(this, context), ast.type, ast.sourceSpan), context); }; AstTransformer.prototype.visitNotExpr = function (ast, context) { return this.transformExpr(new NotExpr(ast.condition.visitExpression(this, context), ast.sourceSpan), context); }; AstTransformer.prototype.visitAssertNotNullExpr = function (ast, context) { return this.transformExpr(new AssertNotNull(ast.condition.visitExpression(this, context), ast.sourceSpan), context); }; AstTransformer.prototype.visitCastExpr = function (ast, context) { return this.transformExpr(new CastExpr(ast.value.visitExpression(this, context), ast.type, ast.sourceSpan), context); }; AstTransformer.prototype.visitFunctionExpr = function (ast, context) { return this.transformExpr(new FunctionExpr(ast.params, this.visitAllStatements(ast.statements, context), ast.type, ast.sourceSpan), context); }; AstTransformer.prototype.visitBinaryOperatorExpr = function (ast, context) { return this.transformExpr(new BinaryOperatorExpr(ast.operator, ast.lhs.visitExpression(this, context), ast.rhs.visitExpression(this, context), ast.type, ast.sourceSpan), context); }; AstTransformer.prototype.visitReadPropExpr = function (ast, context) { return this.transformExpr(new ReadPropExpr(ast.receiver.visitExpression(this, context), ast.name, ast.type, ast.sourceSpan), context); }; AstTransformer.prototype.visitReadKeyExpr = function (ast, context) { return this.transformExpr(new ReadKeyExpr(ast.receiver.visitExpression(this, context), ast.index.visitExpression(this, context), ast.type, ast.sourceSpan), context); }; AstTransformer.prototype.visitLiteralArrayExpr = function (ast, context) { return this.transformExpr(new LiteralArrayExpr(this.visitAllExpressions(ast.entries, context), ast.type, ast.sourceSpan), context); }; AstTransformer.prototype.visitLiteralMapExpr = function (ast, context) { var _this = this; var entries = ast.entries.map(function (entry) { return new LiteralMapEntry(entry.key, entry.value.visitExpression(_this, context), entry.quoted); }); var mapType = new MapType(ast.valueType, null); return this.transformExpr(new LiteralMapExpr(entries, mapType, ast.sourceSpan), context); }; AstTransformer.prototype.visitCommaExpr = function (ast, context) { return this.transformExpr(new CommaExpr(this.visitAllExpressions(ast.parts, context), ast.sourceSpan), context); }; AstTransformer.prototype.visitAllExpressions = function (exprs, context) { var _this = this; return exprs.map(function (expr) { return expr.visitExpression(_this, context); }); }; AstTransformer.prototype.visitDeclareVarStmt = function (stmt, context) { var value = stmt.value && stmt.value.visitExpression(this, context); return this.transformStmt(new DeclareVarStmt(stmt.name, value, stmt.type, stmt.modifiers, stmt.sourceSpan), context); }; AstTransformer.prototype.visitDeclareFunctionStmt = function (stmt, context) { return this.transformStmt(new DeclareFunctionStmt(stmt.name, stmt.params, this.visitAllStatements(stmt.statements, context), stmt.type, stmt.modifiers, stmt.sourceSpan), context); }; AstTransformer.prototype.visitExpressionStmt = function (stmt, context) { return this.transformStmt(new ExpressionStatement(stmt.expr.visitExpression(this, context), stmt.sourceSpan), context); }; AstTransformer.prototype.visitReturnStmt = function (stmt, context) { return this.transformStmt(new ReturnStatement(stmt.value.visitExpression(this, context), stmt.sourceSpan), context); }; AstTransformer.prototype.visitDeclareClassStmt = function (stmt, context) { var _this = this; var parent = stmt.parent.visitExpression(this, context); var getters = stmt.getters.map(function (getter) { return new ClassGetter(getter.name, _this.visitAllStatements(getter.body, context), getter.type, getter.modifiers); }); var ctorMethod = stmt.constructorMethod && new ClassMethod(stmt.constructorMethod.name, stmt.constructorMethod.params, this.visitAllStatements(stmt.constructorMethod.body, context), stmt.constructorMethod.type, stmt.constructorMethod.modifiers); var methods = stmt.methods.map(function (method) { return new ClassMethod(method.name, method.params, _this.visitAllStatements(method.body, context), method.type, method.modifiers); }); return this.transformStmt(new ClassStmt(stmt.name, parent, stmt.fields, getters, ctorMethod, methods, stmt.modifiers, stmt.sourceSpan), context); }; AstTransformer.prototype.visitIfStmt = function (stmt, context) { return this.transformStmt(new IfStmt(stmt.condition.visitExpression(this, context), this.visitAllStatements(stmt.trueCase, context), this.visitAllStatements(stmt.falseCase, context), stmt.sourceSpan), context); }; AstTransformer.prototype.visitTryCatchStmt = function (stmt, context) { return this.transformStmt(new TryCatchStmt(this.visitAllStatements(stmt.bodyStmts, context), this.visitAllStatements(stmt.catchStmts, context), stmt.sourceSpan), context); }; AstTransformer.prototype.visitThrowStmt = function (stmt, context) { return this.transformStmt(new ThrowStmt(stmt.error.visitExpression(this, context), stmt.sourceSpan), context); }; AstTransformer.prototype.visitCommentStmt = function (stmt, context) { return this.transformStmt(stmt, context); }; AstTransformer.prototype.visitJSDocCommentStmt = function (stmt, context) { return this.transformStmt(stmt, context); }; AstTransformer.prototype.visitAllStatements = function (stmts, context) { var _this = this; return stmts.map(function (stmt) { return stmt.visitStatement(_this, context); }); }; return AstTransformer; }()); var RecursiveAstVisitor = /** @class */ (function () { function RecursiveAstVisitor() { } RecursiveAstVisitor.prototype.visitType = function (ast, context) { return ast; }; RecursiveAstVisitor.prototype.visitExpression = function (ast, context) { if (ast.type) { ast.type.visitType(this, context); } return ast; }; RecursiveAstVisitor.prototype.visitBuiltinType = function (type, context) { return this.visitType(type, context); }; RecursiveAstVisitor.prototype.visitExpressionType = function (type, context) { var _this = this; type.value.visitExpression(this, context); if (type.typeParams !== null) { type.typeParams.forEach(function (param) { return _this.visitType(param, context); }); } return this.visitType(type, context); }; RecursiveAstVisitor.prototype.visitArrayType = function (type, context) { return this.visitType(type, context); }; RecursiveAstVisitor.prototype.visitMapType = function (type, context) { return this.visitType(type, context); }; RecursiveAstVisitor.prototype.visitWrappedNodeExpr = function (ast, context) { return ast; }; RecursiveAstVisitor.prototype.visitTypeofExpr = function (ast, context) { return this.visitExpression(ast, context); }; RecursiveAstVisitor.prototype.visitReadVarExpr = function (ast, context) { return this.visitExpression(ast, context); }; RecursiveAstVisitor.prototype.visitWriteVarExpr = function (ast, context) { ast.value.visitExpression(this, context); return this.visitExpression(ast, context); }; RecursiveAstVisitor.prototype.visitWriteKeyExpr = function (ast, context) { ast.receiver.visitExpression(this, context); ast.index.visitExpression(this, context); ast.value.visitExpression(this, context); return this.visitExpression(ast, context); }; RecursiveAstVisitor.prototype.visitWritePropExpr = function (ast, context) { ast.receiver.visitExpression(this, context); ast.value.visitExpression(this, context); return this.visitExpression(ast, context); }; RecursiveAstVisitor.prototype.visitInvokeMethodExpr = function (ast, context) { ast.receiver.visitExpression(this, context); this.visitAllExpressions(ast.args, context); return this.visitExpression(ast, context); }; RecursiveAstVisitor.prototype.visitInvokeFunctionExpr = function (ast, context) { ast.fn.visitExpression(this, context); this.visitAllExpressions(ast.args, context); return this.visitExpression(ast, context); }; RecursiveAstVisitor.prototype.visitInstantiateExpr = function (ast, context) { ast.classExpr.visitExpression(this, context); this.visitAllExpressions(ast.args, context); return this.visitExpression(ast, context); }; RecursiveAstVisitor.prototype.visitLiteralExpr = function (ast, context) { return this.visitExpression(ast, context); }; RecursiveAstVisitor.prototype.visitExternalExpr = function (ast, context) { var _this = this; if (ast.typeParams) { ast.typeParams.forEach(function (type) { return type.visitType(_this, context); }); } return this.visitExpression(ast, context); }; RecursiveAstVisitor.prototype.visitConditionalExpr = function (ast, context) { ast.condition.visitExpression(this, context); ast.trueCase.visitExpression(this, context); ast.falseCase.visitExpression(this, context); return this.visitExpression(ast, context); }; RecursiveAstVisitor.prototype.visitNotExpr = function (ast, context) { ast.condition.visitExpression(this, context); return this.visitExpression(ast, context); }; RecursiveAstVisitor.prototype.visitAssertNotNullExpr = function (ast, context) { ast.condition.visitExpression(this, context); return this.visitExpression(ast, context); }; RecursiveAstVisitor.prototype.visitCastExpr = function (ast, context) { ast.value.visitExpression(this, context); return this.visitExpression(ast, context); }; RecursiveAstVisitor.prototype.visitFunctionExpr = function (ast, context) { this.visitAllStatements(ast.statements, context); return this.visitExpression(ast, context); }; RecursiveAstVisitor.prototype.visitBinaryOperatorExpr = function (ast, context) { ast.lhs.visitExpression(this, context); ast.rhs.visitExpression(this, context); return this.visitExpression(ast, context); }; RecursiveAstVisitor.prototype.visitReadPropExpr = function (ast, context) { ast.receiver.visitExpression(this, context); return this.visitExpression(ast, context); }; RecursiveAstVisitor.prototype.visitReadKeyExpr = function (ast, context) { ast.receiver.visitExpression(this, context); ast.index.visitExpression(this, context); return this.visitExpression(ast, context); }; RecursiveAstVisitor.prototype.visitLiteralArrayExpr = function (ast, context) { this.visitAllExpressions(ast.entries, context); return this.visitExpression(ast, context); }; RecursiveAstVisitor.prototype.visitLiteralMapExpr = function (ast, context) { var _this = this; ast.entries.forEach(function (entry) { return entry.value.visitExpression(_this, context); }); return this.visitExpression(ast, context); }; RecursiveAstVisitor.prototype.visitCommaExpr = function (ast, context) { this.visitAllExpressions(ast.parts, context); return this.visitExpression(ast, context); }; RecursiveAstVisitor.prototype.visitAllExpressions = function (exprs, context) { var _this = this; exprs.forEach(function (expr) { return expr.visitExpression(_this, context); }); }; RecursiveAstVisitor.prototype.visitDeclareVarStmt = function (stmt, context) { if (stmt.value) { stmt.value.visitExpression(this, context); } if (stmt.type) { stmt.type.visitType(this, context); } return stmt; }; RecursiveAstVisitor.prototype.visitDeclareFunctionStmt = function (stmt, context) { this.visitAllStatements(stmt.statements, context); if (stmt.type) { stmt.type.visitType(this, context); } return stmt; }; RecursiveAstVisitor.prototype.visitExpressionStmt = function (stmt, context) { stmt.expr.visitExpression(this, context); return stmt; }; RecursiveAstVisitor.prototype.visitReturnStmt = function (stmt, context) { stmt.value.visitExpression(this, context); return stmt; }; RecursiveAstVisitor.prototype.visitDeclareClassStmt = function (stmt, context) { var _this = this; stmt.parent.visitExpression(this, context); stmt.getters.forEach(function (getter) { return _this.visitAllStatements(getter.body, context); }); if (stmt.constructorMethod) { this.visitAllStatements(stmt.constructorMethod.body, context); } stmt.methods.forEach(function (method) { return _this.visitAllStatements(method.body, context); }); return stmt; }; RecursiveAstVisitor.prototype.visitIfStmt = function (stmt, context) { stmt.condition.visitExpression(this, context); this.visitAllStatements(stmt.trueCase, context); this.visitAllStatements(stmt.falseCase, context); return stmt; }; RecursiveAstVisitor.prototype.visitTryCatchStmt = function (stmt, context) { this.visitAllStatements(stmt.bodyStmts, context); this.visitAllStatements(stmt.catchStmts, context); return stmt; }; RecursiveAstVisitor.prototype.visitThrowStmt = function (stmt, context) { stmt.error.visitExpression(this, context); return stmt; }; RecursiveAstVisitor.prototype.visitCommentStmt = function (stmt, context) { return stmt; }; RecursiveAstVisitor.prototype.visitJSDocCommentStmt = function (stmt, context) { return stmt; }; RecursiveAstVisitor.prototype.visitAllStatements = function (stmts, context) { var _this = this; stmts.forEach(function (stmt) { return stmt.visitStatement(_this, context); }); }; return RecursiveAstVisitor; }()); function findReadVarNames(stmts) { var visitor = new _ReadVarVisitor(); visitor.visitAllStatements(stmts, null); return visitor.varNames; } var _ReadVarVisitor = /** @class */ (function (_super) { Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(_ReadVarVisitor, _super); function _ReadVarVisitor() { var _this = _super !== null && _super.apply(this, arguments) || this; _this.varNames = new Set(); return _this; } _ReadVarVisitor.prototype.visitDeclareFunctionStmt = function (stmt, context) { // Don't descend into nested functions return stmt; }; _ReadVarVisitor.prototype.visitDeclareClassStmt = function (stmt, context) { // Don't descend into nested classes return stmt; }; _ReadVarVisitor.prototype.visitReadVarExpr = function (ast, context) { if (ast.name) { this.varNames.add(ast.name); } return null; }; return _ReadVarVisitor; }(RecursiveAstVisitor)); function collectExternalReferences(stmts) { var visitor = new _FindExternalReferencesVisitor(); visitor.visitAllStatements(stmts, null); return visitor.externalReferences; } var _FindExternalReferencesVisitor = /** @class */ (function (_super) { Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(_FindExternalReferencesVisitor, _super); function _FindExternalReferencesVisitor() { var _this = _super !== null && _super.apply(this, arguments) || this; _this.externalReferences = []; return _this; } _FindExternalReferencesVisitor.prototype.visitExternalExpr = function (e, context) { this.externalReferences.push(e.value); return _super.prototype.visitExternalExpr.call(this, e, context); }; return _FindExternalReferencesVisitor; }(RecursiveAstVisitor)); function applySourceSpanToStatementIfNeeded(stmt, sourceSpan) { if (!sourceSpan) { return stmt; } var transformer = new _ApplySourceSpanTransformer(sourceSpan); return stmt.visitStatement(transformer, null); } function applySourceSpanToExpressionIfNeeded(expr, sourceSpan) { if (!sourceSpan) { return expr; } var transformer = new _ApplySourceSpanTransformer(sourceSpan); return expr.visitExpression(transformer, null); } var _ApplySourceSpanTransformer = /** @class */ (function (_super) { Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(_ApplySourceSpanTransformer, _super); function _ApplySourceSpanTransformer(sourceSpan) { var _this = _super.call(this) || this; _this.sourceSpan = sourceSpan; return _this; } _ApplySourceSpanTransformer.prototype._clone = function (obj) { var clone = Object.create(obj.constructor.prototype); for (var prop in obj) { clone[prop] = obj[prop]; } return clone; }; _ApplySourceSpanTransformer.prototype.transformExpr = function (expr, context) { if (!expr.sourceSpan) { expr = this._clone(expr); expr.sourceSpan = this.sourceSpan; } return expr; }; _ApplySourceSpanTransformer.prototype.transformStmt = function (stmt, context) { if (!stmt.sourceSpan) { stmt = this._clone(stmt); stmt.sourceSpan = this.sourceSpan; } return stmt; }; return _ApplySourceSpanTransformer; }(AstTransformer)); function variable(name, type, sourceSpan) { return new ReadVarExpr(name, type, sourceSpan); } function importExpr(id, typeParams, sourceSpan) { if (typeParams === void 0) { typeParams = null; } return new ExternalExpr(id, null, typeParams, sourceSpan); } function importType(id, typeParams, typeModifiers) { if (typeParams === void 0) { typeParams = null; } if (typeModifiers === void 0) { typeModifiers = null; } return id != null ? expressionType(importExpr(id, typeParams, null), typeModifiers) : null; } function expressionType(expr, typeModifiers, typeParams) { if (typeModifiers === void 0) { typeModifiers = null; } if (typeParams === void 0) { typeParams = null; } return new ExpressionType(expr, typeModifiers, typeParams); } function typeofExpr(expr) { return new TypeofExpr(expr); } function literalArr(values, type, sourceSpan) { return new LiteralArrayExpr(values, type, sourceSpan); } function literalMap(values, type) { if (type === void 0) { type = null; } return new LiteralMapExpr(values.map(function (e) { return new LiteralMapEntry(e.key, e.value, e.quoted); }), type, null); } function not(expr, sourceSpan) { return new NotExpr(expr, sourceSpan); } function assertNotNull(expr, sourceSpan) { return new AssertNotNull(expr, sourceSpan); } function fn(params, body, type, sourceSpan, name) { return new FunctionExpr(params, body, type, sourceSpan, name); } function ifStmt(condition, thenClause, elseClause) { return new IfStmt(condition, thenClause, elseClause); } function literal(value, type, sourceSpan) { return new LiteralExpr(value, type, sourceSpan); } function isNull(exp) { return exp instanceof LiteralExpr && exp.value === null; } /* * Serializes a `Tag` into a string. * Returns a string like " @foo {bar} baz" (note the leading whitespace before `@foo`). */ function tagToString(tag) { var out = ''; if (tag.tagName) { out += " @" + tag.tagName; } if (tag.text) { if (tag.text.match(/\/\*|\*\//)) { throw new Error('JSDoc text cannot contain "/*" and "*/"'); } out += ' ' + tag.text.replace(/@/g, '\\@'); } return out; } function serializeTags(tags) { var e_1, _a; if (tags.length === 0) return ''; var out = '*\n'; try { for (var tags_1 = Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__values"])(tags), tags_1_1 = tags_1.next(); !tags_1_1.done; tags_1_1 = tags_1.next()) { var tag = tags_1_1.value; out += ' *'; // If the tagToString is multi-line, insert " * " prefixes on subsequent lines. out += tagToString(tag).replace(/\n/g, '\n * '); out += '\n'; } } catch (e_1_1) { e_1 = { error: e_1_1 }; } finally { try { if (tags_1_1 && !tags_1_1.done && (_a = tags_1.return)) _a.call(tags_1); } finally { if (e_1) throw e_1.error; } } out += ' '; return out; } /** * @license * Copyright Google Inc. All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ var DASH_CASE_REGEXP = /-+([a-z0-9])/g; function dashCaseToCamelCase(input) { return input.replace(DASH_CASE_REGEXP, function () { var m = []; for (var _i = 0; _i < arguments.length; _i++) { m[_i] = arguments[_i]; } return m[1].toUpperCase(); }); } function splitAtColon(input, defaultValues) { return _splitAt(input, ':', defaultValues); } function splitAtPeriod(input, defaultValues) { return _splitAt(input, '.', defaultValues); } function _splitAt(input, character, defaultValues) { var characterIndex = input.indexOf(character); if (characterIndex == -1) return defaultValues; return [input.slice(0, characterIndex).trim(), input.slice(characterIndex + 1).trim()]; } function visitValue(value, visitor, context) { if (Array.isArray(value)) { return visitor.visitArray(value, context); } if (isStrictStringMap(value)) { return visitor.visitStringMap(value, context); } if (value == null || typeof value == 'string' || typeof value == 'number' || typeof value == 'boolean') { return visitor.visitPrimitive(value, context); } return visitor.visitOther(value, context); } function isDefined(val) { return val !== null && val !== undefined; } function noUndefined(val) { return val === undefined ? null : val; } var ValueTransformer = /** @class */ (function () { function ValueTransformer() { } ValueTransformer.prototype.visitArray = function (arr, context) { var _this = this; return arr.map(function (value) { return visitValue(value, _this, context); }); }; ValueTransformer.prototype.visitStringMap = function (map, context) { var _this = this; var result = {}; Object.keys(map).forEach(function (key) { result[key] = visitValue(map[key], _this, context); }); return result; }; ValueTransformer.prototype.visitPrimitive = function (value, context) { return value; }; ValueTransformer.prototype.visitOther = function (value, context) { return value; }; return ValueTransformer; }()); var SyncAsync = { assertSync: function (value) { if (isPromise(value)) { throw new Error("Illegal state: value cannot be a promise"); } return value; }, then: function (value, cb) { return isPromise(value) ? value.then(cb) : cb(value); }, all: function (syncAsyncValues) { return syncAsyncValues.some(isPromise) ? Promise.all(syncAsyncValues) : syncAsyncValues; } }; function error(msg) { throw new Error("Internal Error: " + msg); } function syntaxError(msg, parseErrors) { var error = Error(msg); error[ERROR_SYNTAX_ERROR] = true; if (parseErrors) error[ERROR_PARSE_ERRORS] = parseErrors; return error; } var ERROR_SYNTAX_ERROR = 'ngSyntaxError'; var ERROR_PARSE_ERRORS = 'ngParseErrors'; function isSyntaxError(error) { return error[ERROR_SYNTAX_ERROR]; } function getParseErrors(error) { return error[ERROR_PARSE_ERRORS] || []; } // Escape characters that have a special meaning in Regular Expressions function escapeRegExp(s) { return s.replace(/([.*+?^=!:${}()|[\]\/\\])/g, '\\$1'); } var STRING_MAP_PROTO = Object.getPrototypeOf({}); function isStrictStringMap(obj) { return typeof obj === 'object' && obj !== null && Object.getPrototypeOf(obj) === STRING_MAP_PROTO; } function utf8Encode(str) { var encoded = ''; for (var index = 0; index < str.length; index++) { var codePoint = str.charCodeAt(index); // decode surrogate // see https://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae if (codePoint >= 0xd800 && codePoint <= 0xdbff && str.length > (index + 1)) { var low = str.charCodeAt(index + 1); if (low >= 0xdc00 && low <= 0xdfff) { index++; codePoint = ((codePoint - 0xd800) << 10) + low - 0xdc00 + 0x10000; } } if (codePoint <= 0x7f) { encoded += String.fromCharCode(codePoint); } else if (codePoint <= 0x7ff) { encoded += String.fromCharCode(((codePoint >> 6) & 0x1F) | 0xc0, (codePoint & 0x3f) | 0x80); } else if (codePoint <= 0xffff) { encoded += String.fromCharCode((codePoint >> 12) | 0xe0, ((codePoint >> 6) & 0x3f) | 0x80, (codePoint & 0x3f) | 0x80); } else if (codePoint <= 0x1fffff) { encoded += String.fromCharCode(((codePoint >> 18) & 0x07) | 0xf0, ((codePoint >> 12) & 0x3f) | 0x80, ((codePoint >> 6) & 0x3f) | 0x80, (codePoint & 0x3f) | 0x80); } } return encoded; } function stringify(token) { if (typeof token === 'string') { return token; } if (token instanceof Array) { return '[' + token.map(stringify).join(', ') + ']'; } if (token == null) { return '' + token; } if (token.overriddenName) { return "" + token.overriddenName; } if (token.name) { return "" + token.name; } // WARNING: do not try to `JSON.stringify(token)` here // see https://github.com/angular/angular/issues/23440 var res = token.toString(); if (res == null) { return '' + res; } var newLineIndex = res.indexOf('\n'); return newLineIndex === -1 ? res : res.substring(0, newLineIndex); } /** * Lazily retrieves the reference value from a forwardRef. */ function resolveForwardRef(type) { if (typeof type === 'function' && type.hasOwnProperty('__forward_ref__')) { return type(); } else { return type; } } /** * Determine if the argument is shaped like a Promise */ function isPromise(obj) { // allow any Promise/A+ compliant thenable. // It's up to the caller to ensure that obj.then conforms to the spec return !!obj && typeof obj.then === 'function'; } var Version = /** @class */ (function () { function Version(full) { this.full = full; var splits = full.split('.'); this.major = splits[0]; this.minor = splits[1]; this.patch = splits.slice(2).join('.'); } return Version; }()); var __window = typeof window !== 'undefined' && window; var __self = typeof self !== 'undefined' && typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope && self; var __global = typeof global !== 'undefined' && global; // Check __global first, because in Node tests both __global and __window may be defined and _global // should be __global in that case. var _global = __global || __window || __self; /** * @license * Copyright Google Inc. All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ var CONSTANT_PREFIX = '_c'; /** * Context to use when producing a key. * * This ensures we see the constant not the reference variable when producing * a key. */ var KEY_CONTEXT = {}; /** * A node that is a place-holder that allows the node to be replaced when the actual * node is known. * * This allows the constant pool to change an expression from a direct reference to * a constant to a shared constant. It returns a fix-up node that is later allowed to * change the referenced expression. */ var FixupExpression = /** @class */ (function (_super) { Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(FixupExpression, _super); function FixupExpression(resolved) { var _this = _super.call(this, resolved.type) || this; _this.resolved = resolved; _this.original = resolved; return _this; } FixupExpression.prototype.visitExpression = function (visitor, context) { if (context === KEY_CONTEXT) { // When producing a key we want to traverse the constant not the // variable used to refer to it. return this.original.visitExpression(visitor, context); } else { return this.resolved.visitExpression(visitor, context); } }; FixupExpression.prototype.isEquivalent = function (e) { return e instanceof FixupExpression && this.resolved.isEquivalent(e.resolved); }; FixupExpression.prototype.isConstant = function () { return true; }; FixupExpression.prototype.fixup = function (expression) { this.resolved = expression; this.shared = true; }; return FixupExpression; }(Expression)); /** * A constant pool allows a code emitter to share constant in an output context. * * The constant pool also supports sharing access to ivy definitions references. */ var ConstantPool = /** @class */ (function () { function ConstantPool() { this.statements = []; this.literals = new Map(); this.literalFactories = new Map(); this.injectorDefinitions = new Map(); this.directiveDefinitions = new Map(); this.componentDefinitions = new Map(); this.pipeDefinitions = new Map(); this.nextNameIndex = 0; } ConstantPool.prototype.getConstLiteral = function (literal$$1, forceShared) { if (literal$$1 instanceof LiteralExpr || literal$$1 instanceof FixupExpression) { // Do no put simple literals into the constant pool or try to produce a constant for a // reference to a constant. return literal$$1; } var key = this.keyOf(literal$$1); var fixup = this.literals.get(key); var newValue = false; if (!fixup) { fixup = new FixupExpression(literal$$1); this.literals.set(key, fixup); newValue = true; } if ((!newValue && !fixup.shared) || (newValue && forceShared)) { // Replace the expression with a variable var name_1 = this.freshName(); this.statements.push(variable(name_1).set(literal$$1).toDeclStmt(INFERRED_TYPE, [StmtModifier.Final])); fixup.fixup(variable(name_1)); } return fixup; }; ConstantPool.prototype.getDefinition = function (type, kind, ctx, forceShared) { if (forceShared === void 0) { forceShared = false; } var definitions = this.definitionsOf(kind); var fixup = definitions.get(type); var newValue = false; if (!fixup) { var property = this.propertyNameOf(kind); fixup = new FixupExpression(ctx.importExpr(type).prop(property)); definitions.set(type, fixup); newValue = true; } if ((!newValue && !fixup.shared) || (newValue && forceShared)) { var name_2 = this.freshName(); this.statements.push(variable(name_2).set(fixup.resolved).toDeclStmt(INFERRED_TYPE, [StmtModifier.Final])); fixup.fixup(variable(name_2)); } return fixup; }; ConstantPool.prototype.getLiteralFactory = function (literal$$1) { // Create a pure function that builds an array of a mix of constant and variable expressions if (literal$$1 instanceof LiteralArrayExpr) { var argumentsForKey = literal$$1.entries.map(function (e) { return e.isConstant() ? e : literal(null); }); var key = this.keyOf(literalArr(argumentsForKey)); return this._getLiteralFactory(key, literal$$1.entries, function (entries) { return literalArr(entries); }); } else { var expressionForKey = literalMap(literal$$1.entries.map(function (e) { return ({ key: e.key, value: e.value.isConstant() ? e.value : literal(null), quoted: e.quoted }); })); var key = this.keyOf(expressionForKey); return this._getLiteralFactory(key, literal$$1.entries.map(function (e) { return e.value; }), function (entries) { return literalMap(entries.map(function (value, index) { return ({ key: literal$$1.entries[index].key, value: value, quoted: literal$$1.entries[index].quoted }); })); }); } }; ConstantPool.prototype._getLiteralFactory = function (key, values, resultMap) { var _this = this; var literalFactory = this.literalFactories.get(key); var literalFactoryArguments = values.filter((function (e) { return !e.isConstant(); })); if (!literalFactory) { var resultExpressions = values.map(function (e, index) { return e.isConstant() ? _this.getConstLiteral(e, true) : variable("a" + index); }); var parameters = resultExpressions.filter(isVariable).map(function (e) { return new FnParam(e.name, DYNAMIC_TYPE); }); var pureFunctionDeclaration = fn(parameters, [new ReturnStatement(resultMap(resultExpressions))], INFERRED_TYPE); var name_3 = this.freshName(); this.statements.push(variable(name_3).set(pureFunctionDeclaration).toDeclStmt(INFERRED_TYPE, [ StmtModifier.Final ])); literalFactory = variable(name_3); this.literalFactories.set(key, literalFactory); } return { literalFactory: literalFactory, literalFactoryArguments: literalFactoryArguments }; }; /** * Produce a unique name. * * The name might be unique among different prefixes if any of the prefixes end in * a digit so the prefix should be a constant string (not based on user input) and * must not end in a digit. */ ConstantPool.prototype.uniqueName = function (prefix) { return "" + prefix + this.nextNameIndex++; }; ConstantPool.prototype.definitionsOf = function (kind) { switch (kind) { case 2 /* Component */: return this.componentDefinitions; case 1 /* Directive */: return this.directiveDefinitions; case 0 /* Injector */: return this.injectorDefinitions; case 3 /* Pipe */: return this.pipeDefinitions; } error("Unknown definition kind " + kind); return this.componentDefinitions; }; ConstantPool.prototype.propertyNameOf = function (kind) { switch (kind) { case 2 /* Component */: return 'ngComponentDef'; case 1 /* Directive */: return 'ngDirectiveDef'; case 0 /* Injector */: return 'ngInjectorDef'; case 3 /* Pipe */: return 'ngPipeDef'; } error("Unknown definition kind " + kind); return ''; }; ConstantPool.prototype.freshName = function () { return this.uniqueName(CONSTANT_PREFIX); }; ConstantPool.prototype.keyOf = function (expression) { return expression.visitExpression(new KeyVisitor(), KEY_CONTEXT); }; return ConstantPool; }()); /** * Visitor used to determine if 2 expressions are equivalent and can be shared in the * `ConstantPool`. * * When the id (string) generated by the visitor is equal, expressions are considered equivalent. */ var KeyVisitor = /** @class */ (function () { function KeyVisitor() { this.visitWrappedNodeExpr = invalid; this.visitWriteVarExpr = invalid; this.visitWriteKeyExpr = invalid; this.visitWritePropExpr = invalid; this.visitInvokeMethodExpr = invalid; this.visitInvokeFunctionExpr = invalid; this.visitInstantiateExpr = invalid; this.visitConditionalExpr = invalid; this.visitNotExpr = invalid; this.visitAssertNotNullExpr = invalid; this.visitCastExpr = invalid; this.visitFunctionExpr = invalid; this.visitBinaryOperatorExpr = invalid; this.visitReadPropExpr = invalid; this.visitReadKeyExpr = invalid; this.visitCommaExpr = invalid; } KeyVisitor.prototype.visitLiteralExpr = function (ast) { return "" + (typeof ast.value === 'string' ? '"' + ast.value + '"' : ast.value); }; KeyVisitor.prototype.visitLiteralArrayExpr = function (ast, context) { var _this = this; return "[" + ast.entries.map(function (entry) { return entry.visitExpression(_this, context); }).join(',') + "]"; }; KeyVisitor.prototype.visitLiteralMapExpr = function (ast, context) { var _this = this; var mapKey = function (entry) { var quote = entry.quoted ? '"' : ''; return "" + quote + entry.key + quote; }; var mapEntry = function (entry) { return mapKey(entry) + ":" + entry.value.visitExpression(_this, context); }; return "{" + ast.entries.map(mapEntry).join(','); }; KeyVisitor.prototype.visitExternalExpr = function (ast) { return ast.value.moduleName ? "EX:" + ast.value.moduleName + ":" + ast.value.name : "EX:" + ast.value.runtime.name; }; KeyVisitor.prototype.visitReadVarExpr = function (node) { return "VAR:" + node.name; }; KeyVisitor.prototype.visitTypeofExpr = function (node, context) { return "TYPEOF:" + node.expr.visitExpression(this, context); }; return KeyVisitor; }()); function invalid(arg) { throw new Error("Invalid state: Visitor " + this.constructor.name + " doesn't handle " + arg.constructor.name); } function isVariable(e) { return e instanceof ReadVarExpr; } /** * @license * Copyright Google Inc. All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ var CORE = '@angular/core'; var Identifiers = /** @class */ (function () { function Identifiers() { } Identifiers.ANALYZE_FOR_ENTRY_COMPONENTS = { name: 'ANALYZE_FOR_ENTRY_COMPONENTS', moduleName: CORE, }; Identifiers.ElementRef = { name: 'ElementRef', moduleName: CORE }; Identifiers.NgModuleRef = { name: 'NgModuleRef', moduleName: CORE }; Identifiers.ViewContainerRef = { name: 'ViewContainerRef', moduleName: CORE }; Identifiers.ChangeDetectorRef = { name: 'ChangeDetectorRef', moduleName: CORE, }; Identifiers.QueryList = { name: 'QueryList', moduleName: CORE }; Identifiers.TemplateRef = { name: 'TemplateRef', moduleName: CORE }; Identifiers.Renderer2 = { name: 'Renderer2', moduleName: CORE }; Identifiers.CodegenComponentFactoryResolver = { name: 'ɵCodegenComponentFactoryResolver', moduleName: CORE, }; Identifiers.ComponentFactoryResolver = { name: 'ComponentFactoryResolver', moduleName: CORE, }; Identifiers.ComponentFactory = { name: 'ComponentFactory', moduleName: CORE }; Identifiers.ComponentRef = { name: 'ComponentRef', moduleName: CORE }; Identifiers.NgModuleFactory = { name: 'NgModuleFactory', moduleName: CORE }; Identifiers.createModuleFactory = { name: 'ɵcmf', moduleName: CORE, }; Identifiers.moduleDef = { name: 'ɵmod', moduleName: CORE, }; Identifiers.moduleProviderDef = { name: 'ɵmpd', moduleName: CORE, }; Identifiers.RegisterModuleFactoryFn = { name: 'ɵregisterModuleFactory', moduleName: CORE, }; Identifiers.inject = { name: 'inject', moduleName: CORE }; Identifiers.INJECTOR = { name: 'INJECTOR', moduleName: CORE }; Identifiers.Injector = { name: 'Injector', moduleName: CORE }; Identifiers.defineInjectable = { name: 'defineInjectable', moduleName: CORE }; Identifiers.InjectableDef = { name: 'ɵInjectableDef', moduleName: CORE }; Identifiers.ViewEncapsulation = { name: 'ViewEncapsulation', moduleName: CORE, }; Identifiers.ChangeDetectionStrategy = { name: 'ChangeDetectionStrategy', moduleName: CORE, }; Identifiers.SecurityContext = { name: 'SecurityContext', moduleName: CORE, }; Identifiers.LOCALE_ID = { name: 'LOCALE_ID', moduleName: CORE }; Identifiers.TRANSLATIONS_FORMAT = { name: 'TRANSLATIONS_FORMAT', moduleName: CORE, }; Identifiers.inlineInterpolate = { name: 'ɵinlineInterpolate', moduleName: CORE, }; Identifiers.interpolate = { name: 'ɵinterpolate', moduleName: CORE }; Identifiers.EMPTY_ARRAY = { name: 'ɵEMPTY_ARRAY', moduleName: CORE }; Identifiers.EMPTY_MAP = { name: 'ɵEMPTY_MAP', moduleName: CORE }; Identifiers.Renderer = { name: 'Renderer', moduleName: CORE }; Identifiers.viewDef = { name: 'ɵvid', moduleName: CORE }; Identifiers.elementDef = { name: 'ɵeld', moduleName: CORE }; Identifiers.anchorDef = { name: 'ɵand', moduleName: CORE }; Identifiers.textDef = { name: 'ɵted', moduleName: CORE }; Identifiers.directiveDef = { name: 'ɵdid', moduleName: CORE }; Identifiers.providerDef = { name: 'ɵprd', moduleName: CORE }; Identifiers.queryDef = { name: 'ɵqud', moduleName: CORE }; Identifiers.pureArrayDef = { name: 'ɵpad', moduleName: CORE }; Identifiers.pureObjectDef = { name: 'ɵpod', moduleName: CORE }; Identifiers.purePipeDef = { name: 'ɵppd', moduleName: CORE }; Identifiers.pipeDef = { name: 'ɵpid', moduleName: CORE }; Identifiers.nodeValue = { name: 'ɵnov', moduleName: CORE }; Identifiers.ngContentDef = { name: 'ɵncd', moduleName: CORE }; Identifiers.unwrapValue = { name: 'ɵunv', moduleName: CORE }; Identifiers.createRendererType2 = { name: 'ɵcrt', moduleName: CORE }; // type only Identifiers.RendererType2 = { name: 'RendererType2', moduleName: CORE, }; // type only Identifiers.ViewDefinition = { name: 'ɵViewDefinition', moduleName: CORE, }; Identifiers.createComponentFactory = { name: 'ɵccf', moduleName: CORE }; Identifiers.setClassMetadata = { name: 'ɵsetClassMetadata', moduleName: CORE }; return Identifiers; }()); function createTokenForReference(reference) { return { identifier: { reference: reference } }; } function createTokenForExternalReference(reflector, reference) { return createTokenForReference(reflector.resolveExternalReference(reference)); } /** * @license * Copyright Google Inc. All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ /** * A token representing the a reference to a static type. * * This token is unique for a filePath and name and can be used as a hash table key. */ var StaticSymbol = /** @class */ (function () { function StaticSymbol(filePath, name, members) { this.filePath = filePath; this.name = name; this.members = members; } StaticSymbol.prototype.assertNoMembers = function () { if (this.members.length) { throw new Error("Illegal state: symbol without members expected, but got " + JSON.stringify(this) + "."); } }; return StaticSymbol; }()); /** * A cache of static symbol used by the StaticReflector to return the same symbol for the * same symbol values. */ var StaticSymbolCache = /** @class */ (function () { function StaticSymbolCache() { this.cache = new Map(); } StaticSymbolCache.prototype.get = function (declarationFile, name, members) { members = members || []; var memberSuffix = members.length ? "." + members.join('.') : ''; var key = "\"" + declarationFile + "\"." + name + memberSuffix; var result = this.cache.get(key); if (!result) { result = new StaticSymbol(declarationFile, name, members); this.cache.set(key, result); } return result; }; return StaticSymbolCache; }()); /** * @license * Copyright Google Inc. All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ // group 0: "[prop] or (event) or @trigger" // group 1: "prop" from "[prop]" // group 2: "event" from "(event)" // group 3: "@trigger" from "@trigger" var HOST_REG_EXP = /^(?:(?:\[([^\]]+)\])|(?:\(([^\)]+)\)))|(\@[-\w]+)$/; function sanitizeIdentifier(name) { return name.replace(/\W/g, '_'); } var _anonymousTypeIndex = 0; function identifierName(compileIdentifier) { if (!compileIdentifier || !compileIdentifier.reference) { return null; } var ref = compileIdentifier.reference; if (ref instanceof StaticSymbol) { return ref.name; } if (ref['__anonymousType']) { return ref['__anonymousType']; } var identifier = stringify(ref); if (identifier.indexOf('(') >= 0) { // case: anonymous functions! identifier = "anonymous_" + _anonymousTypeIndex++; ref['__anonymousType'] = identifier; } else { identifier = sanitizeIdentifier(identifier); } return identifier; } function identifierModuleUrl(compileIdentifier) { var ref = compileIdentifier.reference; if (ref instanceof StaticSymbol) { return ref.filePath; } // Runtime type return "./" + stringify(ref); } function viewClassName(compType, embeddedTemplateIndex) { return "View_" + identifierName({ reference: compType }) + "_" + embeddedTemplateIndex; } function rendererTypeName(compType) { return "RenderType_" + identifierName({ reference: compType }); } function hostViewClassName(compType) { return "HostView_" + identifierName({ reference: compType }); } function componentFactoryName(compType) { return identifierName({ reference: compType }) + "NgFactory"; } var CompileSummaryKind; (function (CompileSummaryKind) { CompileSummaryKind[CompileSummaryKind["Pipe"] = 0] = "Pipe"; CompileSummaryKind[CompileSummaryKind["Directive"] = 1] = "Directive"; CompileSummaryKind[CompileSummaryKind["NgModule"] = 2] = "NgModule"; CompileSummaryKind[CompileSummaryKind["Injectable"] = 3] = "Injectable"; })(CompileSummaryKind || (CompileSummaryKind = {})); function tokenName(token) { return token.value != null ? sanitizeIdentifier(token.value) : identifierName(token.identifier); } function tokenReference(token) { if (token.identifier != null) { return token.identifier.reference; } else { return token.value; } } /** * Metadata about a stylesheet */ var CompileStylesheetMetadata = /** @class */ (function () { function CompileStylesheetMetadata(_a) { var _b = _a === void 0 ? {} : _a, moduleUrl = _b.moduleUrl, styles = _b.styles, styleUrls = _b.styleUrls; this.moduleUrl = moduleUrl || null; this.styles = _normalizeArray(styles); this.styleUrls = _normalizeArray(styleUrls); } return CompileStylesheetMetadata; }()); /** * Metadata regarding compilation of a template. */ var CompileTemplateMetadata = /** @class */ (function () { function CompileTemplateMetadata(_a) { var encapsulation = _a.encapsulation, template = _a.template, templateUrl = _a.templateUrl, htmlAst = _a.htmlAst, styles = _a.styles, styleUrls = _a.styleUrls, externalStylesheets = _a.externalStylesheets, animations = _a.animations, ngContentSelectors = _a.ngContentSelectors, interpolation = _a.interpolation, isInline = _a.isInline, preserveWhitespaces = _a.preserveWhitespaces; this.encapsulation = encapsulation; this.template = template; this.templateUrl = templateUrl; this.htmlAst = htmlAst; this.styles = _normalizeArray(styles); this.styleUrls = _normalizeArray(styleUrls); this.externalStylesheets = _normalizeArray(externalStylesheets); this.animations = animations ? flatten(animations) : []; this.ngContentSelectors = ngContentSelectors || []; if (interpolation && interpolation.length != 2) { throw new Error("'interpolation' should have a start and an end symbol."); } this.interpolation = interpolation; this.isInline = isInline; this.preserveWhitespaces = preserveWhitespaces; } CompileTemplateMetadata.prototype.toSummary = function () { return { ngContentSelectors: this.ngContentSelectors, encapsulation: this.encapsulation, styles: this.styles, animations: this.animations }; }; return CompileTemplateMetadata; }()); /** * Metadata regarding compilation of a directive. */ var CompileDirectiveMetadata = /** @class */ (function () { function CompileDirectiveMetadata(_a) { var isHost = _a.isHost, type = _a.type, isComponent = _a.isComponent, selector = _a.selector, exportAs = _a.exportAs, changeDetection = _a.changeDetection, inputs = _a.inputs, outputs = _a.outputs, hostListeners = _a.hostListeners, hostProperties = _a.hostProperties, hostAttributes = _a.hostAttributes, providers = _a.providers, viewProviders = _a.viewProviders, queries = _a.queries, guards = _a.guards, viewQueries = _a.viewQueries, entryComponents = _a.entryComponents, template = _a.template, componentViewType = _a.componentViewType, rendererType = _a.rendererType, componentFactory = _a.componentFactory; this.isHost = !!isHost; this.type = type; this.isComponent = isComponent; this.selector = selector; this.exportAs = exportAs; this.changeDetection = changeDetection; this.inputs = inputs; this.outputs = outputs; this.hostListeners = hostListeners; this.hostProperties = hostProperties; this.hostAttributes = hostAttributes; this.providers = _normalizeArray(providers); this.viewProviders = _normalizeArray(viewProviders); this.queries = _normalizeArray(queries); this.guards = guards; this.viewQueries = _normalizeArray(viewQueries); this.entryComponents = _normalizeArray(entryComponents); this.template = template; this.componentViewType = componentViewType; this.rendererType = rendererType; this.componentFactory = componentFactory; } CompileDirectiveMetadata.create = function (_a) { var isHost = _a.isHost, type = _a.type, isComponent = _a.isComponent, selector = _a.selector, exportAs = _a.exportAs, changeDetection = _a.changeDetection, inputs = _a.inputs, outputs = _a.outputs, host = _a.host, providers = _a.providers, viewProviders = _a.viewProviders, queries = _a.queries, guards = _a.guards, viewQueries = _a.viewQueries, entryComponents = _a.entryComponents, template = _a.template, componentViewType = _a.componentViewType, rendererType = _a.rendererType, componentFactory = _a.componentFactory; var hostListeners = {}; var hostProperties = {}; var hostAttributes = {}; if (host != null) { Object.keys(host).forEach(function (key) { var value = host[key]; var matches = key.match(HOST_REG_EXP); if (matches === null) { hostAttributes[key] = value; } else if (matches[1] != null) { hostProperties[matches[1]] = value; } else if (matches[2] != null) { hostListeners[matches[2]] = value; } }); } var inputsMap = {}; if (inputs != null) { inputs.forEach(function (bindConfig) { // canonical syntax: `dirProp: elProp` // if there is no `:`, use dirProp = elProp var parts = splitAtColon(bindConfig, [bindConfig, bindConfig]); inputsMap[parts[0]] = parts[1]; }); } var outputsMap = {}; if (outputs != null) { outputs.forEach(function (bindConfig) { // canonical syntax: `dirProp: elProp` // if there is no `:`, use dirProp = elProp var parts = splitAtColon(bindConfig, [bindConfig, bindConfig]); outputsMap[parts[0]] = parts[1]; }); } return new CompileDirectiveMetadata({ isHost: isHost, type: type, isComponent: !!isComponent, selector: selector, exportAs: exportAs, changeDetection: changeDetection, inputs: inputsMap, outputs: outputsMap, hostListeners: hostListeners, hostProperties: hostProperties, hostAttributes: hostAttributes, providers: providers, viewProviders: viewProviders, queries: queries, guards: guards, viewQueries: viewQueries, entryComponents: entryComponents, template: template, componentViewType: componentViewType, rendererType: rendererType, componentFactory: componentFactory, }); }; CompileDirectiveMetadata.prototype.toSummary = function () { return { summaryKind: CompileSummaryKind.Directive, type: this.type, isComponent: this.isComponent, selector: this.selector, exportAs: this.exportAs, inputs: this.inputs, outputs: this.outputs, hostListeners: this.hostListeners, hostProperties: this.hostProperties, hostAttributes: this.hostAttributes, providers: this.providers, viewProviders: this.viewProviders, queries: this.queries, guards: this.guards, viewQueries: this.viewQueries, entryComponents: this.entryComponents, changeDetection: this.changeDetection, template: this.template && this.template.toSummary(), componentViewType: this.componentViewType, rendererType: this.rendererType, componentFactory: this.componentFactory }; }; return CompileDirectiveMetadata; }()); var CompilePipeMetadata = /** @class */ (function () { function CompilePipeMetadata(_a) { var type = _a.type, name = _a.name, pure = _a.pure; this.type = type; this.name = name; this.pure = !!pure; } CompilePipeMetadata.prototype.toSummary = function () { return { summaryKind: CompileSummaryKind.Pipe, type: this.type, name: this.name, pure: this.pure }; }; return CompilePipeMetadata; }()); var CompileShallowModuleMetadata = /** @class */ (function () { function CompileShallowModuleMetadata() { } return CompileShallowModuleMetadata; }()); /** * Metadata regarding compilation of a module. */ var CompileNgModuleMetadata = /** @class */ (function () { function CompileNgModuleMetadata(_a) { var type = _a.type, providers = _a.providers, declaredDirectives = _a.declaredDirectives, exportedDirectives = _a.exportedDirectives, declaredPipes = _a.declaredPipes, exportedPipes = _a.exportedPipes, entryComponents = _a.entryComponents, bootstrapComponents = _a.bootstrapComponents, importedModules = _a.importedModules, exportedModules = _a.exportedModules, schemas = _a.schemas, transitiveModule = _a.transitiveModule, id = _a.id; this.type = type || null; this.declaredDirectives = _normalizeArray(declaredDirectives); this.exportedDirectives = _normalizeArray(exportedDirectives); this.declaredPipes = _normalizeArray(declaredPipes); this.exportedPipes = _normalizeArray(exportedPipes); this.providers = _normalizeArray(providers); this.entryComponents = _normalizeArray(entryComponents); this.bootstrapComponents = _normalizeArray(bootstrapComponents); this.importedModules = _normalizeArray(importedModules); this.exportedModules = _normalizeArray(exportedModules); this.schemas = _normalizeArray(schemas); this.id = id || null; this.transitiveModule = transitiveModule || null; } CompileNgModuleMetadata.prototype.toSummary = function () { var module = this.transitiveModule; return { summaryKind: CompileSummaryKind.NgModule, type: this.type, entryComponents: module.entryComponents, providers: module.providers, modules: module.modules, exportedDirectives: module.exportedDirectives, exportedPipes: module.exportedPipes }; }; return CompileNgModuleMetadata; }()); var TransitiveCompileNgModuleMetadata = /** @class */ (function () { function TransitiveCompileNgModuleMetadata() { this.directivesSet = new Set(); this.directives = []; this.exportedDirectivesSet = new Set(); this.exportedDirectives = []; this.pipesSet = new Set(); this.pipes = []; this.exportedPipesSet = new Set(); this.exportedPipes = []; this.modulesSet = new Set(); this.modules = []; this.entryComponentsSet = new Set(); this.entryComponents = []; this.providers = []; } TransitiveCompileNgModuleMetadata.prototype.addProvider = function (provider, module) { this.providers.push({ provider: provider, module: module }); }; TransitiveCompileNgModuleMetadata.prototype.addDirective = function (id) { if (!this.directivesSet.has(id.reference)) { this.directivesSet.add(id.reference); this.directives.push(id); } }; TransitiveCompileNgModuleMetadata.prototype.addExportedDirective = function (id) { if (!this.exportedDirectivesSet.has(id.reference)) { this.exportedDirectivesSet.add(id.reference); this.exportedDirectives.push(id); } }; TransitiveCompileNgModuleMetadata.prototype.addPipe = function (id) { if (!this.pipesSet.has(id.reference)) { this.pipesSet.add(id.reference); this.pipes.push(id); } }; TransitiveCompileNgModuleMetadata.prototype.addExportedPipe = function (id) { if (!this.exportedPipesSet.has(id.reference)) { this.exportedPipesSet.add(id.reference); this.exportedPipes.push(id); } }; TransitiveCompileNgModuleMetadata.prototype.addModule = function (id) { if (!this.modulesSet.has(id.reference)) { this.modulesSet.add(id.reference); this.modules.push(id); } }; TransitiveCompileNgModuleMetadata.prototype.addEntryComponent = function (ec) { if (!this.entryComponentsSet.has(ec.componentType)) { this.entryComponentsSet.add(ec.componentType); this.entryComponents.push(ec); } }; return TransitiveCompileNgModuleMetadata; }()); function _normalizeArray(obj) { return obj || []; } var ProviderMeta = /** @class */ (function () { function ProviderMeta(token, _a) { var useClass = _a.useClass, useValue = _a.useValue, useExisting = _a.useExisting, useFactory = _a.useFactory, deps = _a.deps, multi = _a.multi; this.token = token; this.useClass = useClass || null; this.useValue = useValue; this.useExisting = useExisting; this.useFactory = useFactory || null; this.dependencies = deps || null; this.multi = !!multi; } return ProviderMeta; }()); function flatten(list) { return list.reduce(function (flat, item) { var flatItem = Array.isArray(item) ? flatten(item) : item; return flat.concat(flatItem); }, []); } function jitSourceUrl(url) { // Note: We need 3 "/" so that ng shows up as a separate domain // in the chrome dev tools. return url.replace(/(\w+:\/\/[\w:-]+)?(\/+)?/, 'ng:///'); } function templateSourceUrl(ngModuleType, compMeta, templateMeta) { var url; if (templateMeta.isInline) { if (compMeta.type.reference instanceof StaticSymbol) { // Note: a .ts file might contain multiple components with inline templates, // so we need to give them unique urls, as these will be used for sourcemaps. url = compMeta.type.reference.filePath + "." + compMeta.type.reference.name + ".html"; } else { url = identifierName(ngModuleType) + "/" + identifierName(compMeta.type) + ".html"; } } else { url = templateMeta.templateUrl; } return compMeta.type.reference instanceof StaticSymbol ? url : jitSourceUrl(url); } function sharedStylesheetJitUrl(meta, id) { var pathParts = meta.moduleUrl.split(/\/\\/g); var baseName = pathParts[pathParts.length - 1]; return jitSourceUrl("css/" + id + baseName + ".ngstyle.js"); } function ngModuleJitUrl(moduleMeta) { return jitSourceUrl(identifierName(moduleMeta.type) + "/module.ngfactory.js"); } function templateJitUrl(ngModuleType, compMeta) { return jitSourceUrl(identifierName(ngModuleType) + "/" + identifierName(compMeta.type) + ".ngfactory.js"); } /** * @license * Copyright Google Inc. All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ var CORE$1 = '@angular/core'; var Identifiers$1 = /** @class */ (function () { function Identifiers() { } /* Methods */ Identifiers.NEW_METHOD = 'factory'; Identifiers.TRANSFORM_METHOD = 'transform'; Identifiers.PATCH_DEPS = 'patchedDeps'; /* Instructions */ Identifiers.namespaceHTML = { name: 'ɵnamespaceHTML', moduleName: CORE$1 }; Identifiers.namespaceMathML = { name: 'ɵnamespaceMathML', moduleName: CORE$1 }; Identifiers.namespaceSVG = { name: 'ɵnamespaceSVG', moduleName: CORE$1 }; Identifiers.element = { name: 'ɵelement', moduleName: CORE$1 }; Identifiers.elementStart = { name: 'ɵelementStart', moduleName: CORE$1 }; Identifiers.elementEnd = { name: 'ɵelementEnd', moduleName: CORE$1 }; Identifiers.elementProperty = { name: 'ɵelementProperty', moduleName: CORE$1 }; Identifiers.componentHostSyntheticProperty = { name: 'ɵcomponentHostSyntheticProperty', moduleName: CORE$1 }; Identifiers.elementAttribute = { name: 'ɵelementAttribute', moduleName: CORE$1 }; Identifiers.elementClassProp = { name: 'ɵelementClassProp', moduleName: CORE$1 }; Identifiers.elementContainerStart = { name: 'ɵelementContainerStart', moduleName: CORE$1 }; Identifiers.elementContainerEnd = { name: 'ɵelementContainerEnd', moduleName: CORE$1 }; Identifiers.elementStyling = { name: 'ɵelementStyling', moduleName: CORE$1 }; Identifiers.elementHostAttrs = { name: 'ɵelementHostAttrs', moduleName: CORE$1 }; Identifiers.elementStylingMap = { name: 'ɵelementStylingMap', moduleName: CORE$1 }; Identifiers.elementStyleProp = { name: 'ɵelementStyleProp', moduleName: CORE$1 }; Identifiers.elementStylingApply = { name: 'ɵelementStylingApply', moduleName: CORE$1 }; Identifiers.containerCreate = { name: 'ɵcontainer', moduleName: CORE$1 }; Identifiers.nextContext = { name: 'ɵnextContext', moduleName: CORE$1 }; Identifiers.templateCreate = { name: 'ɵtemplate', moduleName: CORE$1 }; Identifiers.text = { name: 'ɵtext', moduleName: CORE$1 }; Identifiers.textBinding = { name: 'ɵtextBinding', moduleName: CORE$1 }; Identifiers.bind = { name: 'ɵbind', moduleName: CORE$1 }; Identifiers.enableBindings = { name: 'ɵenableBindings', moduleName: CORE$1 }; Identifiers.disableBindings = { name: 'ɵdisableBindings', moduleName: CORE$1 }; Identifiers.allocHostVars = { name: 'ɵallocHostVars', moduleName: CORE$1 }; Identifiers.getCurrentView = { name: 'ɵgetCurrentView', moduleName: CORE$1 }; Identifiers.restoreView = { name: 'ɵrestoreView', moduleName: CORE$1 }; Identifiers.interpolation1 = { name: 'ɵinterpolation1', moduleName: CORE$1 }; Identifiers.interpolation2 = { name: 'ɵinterpolation2', moduleName: CORE$1 }; Identifiers.interpolation3 = { name: 'ɵinterpolation3', moduleName: CORE$1 }; Identifiers.interpolation4 = { name: 'ɵinterpolation4', moduleName: CORE$1 }; Identifiers.interpolation5 = { name: 'ɵinterpolation5', moduleName: CORE$1 }; Identifiers.interpolation6 = { name: 'ɵinterpolation6', moduleName: CORE$1 }; Identifiers.interpolation7 = { name: 'ɵinterpolation7', moduleName: CORE$1 }; Identifiers.interpolation8 = { name: 'ɵinterpolation8', moduleName: CORE$1 }; Identifiers.interpolationV = { name: 'ɵinterpolationV', moduleName: CORE$1 }; Identifiers.pureFunction0 = { name: 'ɵpureFunction0', moduleName: CORE$1 }; Identifiers.pureFunction1 = { name: 'ɵpureFunction1', moduleName: CORE$1 }; Identifiers.pureFunction2 = { name: 'ɵpureFunction2', moduleName: CORE$1 }; Identifiers.pureFunction3 = { name: 'ɵpureFunction3', moduleName: CORE$1 }; Identifiers.pureFunction4 = { name: 'ɵpureFunction4', moduleName: CORE$1 }; Identifiers.pureFunction5 = { name: 'ɵpureFunction5', moduleName: CORE$1 }; Identifiers.pureFunction6 = { name: 'ɵpureFunction6', moduleName: CORE$1 }; Identifiers.pureFunction7 = { name: 'ɵpureFunction7', moduleName: CORE$1 }; Identifiers.pureFunction8 = { name: 'ɵpureFunction8', moduleName: CORE$1 }; Identifiers.pureFunctionV = { name: 'ɵpureFunctionV', moduleName: CORE$1 }; Identifiers.pipeBind1 = { name: 'ɵpipeBind1', moduleName: CORE$1 }; Identifiers.pipeBind2 = { name: 'ɵpipeBind2', moduleName: CORE$1 }; Identifiers.pipeBind3 = { name: 'ɵpipeBind3', moduleName: CORE$1 }; Identifiers.pipeBind4 = { name: 'ɵpipeBind4', moduleName: CORE$1 }; Identifiers.pipeBindV = { name: 'ɵpipeBindV', moduleName: CORE$1 }; Identifiers.i18n = { name: 'ɵi18n', moduleName: CORE$1 }; Identifiers.i18nAttributes = { name: 'ɵi18nAttributes', moduleName: CORE$1 }; Identifiers.i18nExp = { name: 'ɵi18nExp', moduleName: CORE$1 }; Identifiers.i18nStart = { name: 'ɵi18nStart', moduleName: CORE$1 }; Identifiers.i18nEnd = { name: 'ɵi18nEnd', moduleName: CORE$1 }; Identifiers.i18nApply = { name: 'ɵi18nApply', moduleName: CORE$1 }; Identifiers.i18nPostprocess = { name: 'ɵi18nPostprocess', moduleName: CORE$1 }; Identifiers.load = { name: 'ɵload', moduleName: CORE$1 }; Identifiers.loadQueryList = { name: 'ɵloadQueryList', moduleName: CORE$1 }; Identifiers.pipe = { name: 'ɵpipe', moduleName: CORE$1 }; Identifiers.projection = { name: 'ɵprojection', moduleName: CORE$1 }; Identifiers.projectionDef = { name: 'ɵprojectionDef', moduleName: CORE$1 }; Identifiers.reference = { name: 'ɵreference', moduleName: CORE$1 }; Identifiers.inject = { name: 'inject', moduleName: CORE$1 }; Identifiers.injectAttribute = { name: 'ɵinjectAttribute', moduleName: CORE$1 }; Identifiers.directiveInject = { name: 'ɵdirectiveInject', moduleName: CORE$1 }; Identifiers.templateRefExtractor = { name: 'ɵtemplateRefExtractor', moduleName: CORE$1 }; Identifiers.defineBase = { name: 'ɵdefineBase', moduleName: CORE$1 }; Identifiers.BaseDef = { name: 'ɵBaseDef', moduleName: CORE$1, }; Identifiers.defineComponent = { name: 'ɵdefineComponent', moduleName: CORE$1 }; Identifiers.ComponentDefWithMeta = { name: 'ɵComponentDefWithMeta', moduleName: CORE$1, }; Identifiers.defineDirective = { name: 'ɵdefineDirective', moduleName: CORE$1, }; Identifiers.DirectiveDefWithMeta = { name: 'ɵDirectiveDefWithMeta', moduleName: CORE$1, }; Identifiers.InjectorDef = { name: 'ɵInjectorDef', moduleName: CORE$1, }; Identifiers.defineInjector = { name: 'defineInjector', moduleName: CORE$1, }; Identifiers.NgModuleDefWithMeta = { name: 'ɵNgModuleDefWithMeta', moduleName: CORE$1, }; Identifiers.defineNgModule = { name: 'ɵdefineNgModule', moduleName: CORE$1 }; Identifiers.PipeDefWithMeta = { name: 'ɵPipeDefWithMeta', moduleName: CORE$1 }; Identifiers.definePipe = { name: 'ɵdefinePipe', moduleName: CORE$1 }; Identifiers.query = { name: 'ɵquery', moduleName: CORE$1 }; Identifiers.queryRefresh = { name: 'ɵqueryRefresh', moduleName: CORE$1 }; Identifiers.registerContentQuery = { name: 'ɵregisterContentQuery', moduleName: CORE$1 }; Identifiers.NgOnChangesFeature = { name: 'ɵNgOnChangesFeature', moduleName: CORE$1 }; Identifiers.InheritDefinitionFeature = { name: 'ɵInheritDefinitionFeature', moduleName: CORE$1 }; Identifiers.ProvidersFeature = { name: 'ɵProvidersFeature', moduleName: CORE$1 }; Identifiers.listener = { name: 'ɵlistener', moduleName: CORE$1 }; Identifiers.getFactoryOf = { name: 'ɵgetFactoryOf', moduleName: CORE$1, }; Identifiers.getInheritedFactory = { name: 'ɵgetInheritedFactory', moduleName: CORE$1, }; // sanitization-related functions Identifiers.sanitizeHtml = { name: 'ɵsanitizeHtml', moduleName: CORE$1 }; Identifiers.sanitizeStyle = { name: 'ɵsanitizeStyle', moduleName: CORE$1 }; Identifiers.defaultStyleSanitizer = { name: 'ɵdefaultStyleSanitizer', moduleName: CORE$1 }; Identifiers.sanitizeResourceUrl = { name: 'ɵsanitizeResourceUrl', moduleName: CORE$1 }; Identifiers.sanitizeScript = { name: 'ɵsanitizeScript', moduleName: CORE$1 }; Identifiers.sanitizeUrl = { name: 'ɵsanitizeUrl', moduleName: CORE$1 }; return Identifiers; }()); /** * @license * Copyright Google Inc. All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ var Message = /** @class */ (function () { /** * @param nodes message AST * @param placeholders maps placeholder names to static content * @param placeholderToMessage maps placeholder names to messages (used for nested ICU messages) * @param meaning * @param description * @param id */ function Message(nodes, placeholders, placeholderToMessage, meaning, description, id) { this.nodes = nodes; this.placeholders = placeholders; this.placeholderToMessage = placeholderToMessage; this.meaning = meaning; this.description = description; this.id = id; if (nodes.length) { this.sources = [{ filePath: nodes[0].sourceSpan.start.file.url, startLine: nodes[0].sourceSpan.start.line + 1, startCol: nodes[0].sourceSpan.start.col + 1, endLine: nodes[nodes.length - 1].sourceSpan.end.line + 1, endCol: nodes[0].sourceSpan.start.col + 1 }]; } else { this.sources = []; } } return Message; }()); var Text = /** @class */ (function () { function Text(value, sourceSpan) { this.value = value; this.sourceSpan = sourceSpan; } Text.prototype.visit = function (visitor, context) { return visitor.visitText(this, context); }; return Text; }()); // TODO(vicb): do we really need this node (vs an array) ? var Container = /** @class */ (function () { function Container(children, sourceSpan) { this.children = children; this.sourceSpan = sourceSpan; } Container.prototype.visit = function (visitor, context) { return visitor.visitContainer(this, context); }; return Container; }()); var Icu = /** @class */ (function () { function Icu(expression, type, cases, sourceSpan) { this.expression = expression; this.type = type; this.cases = cases; this.sourceSpan = sourceSpan; } Icu.prototype.visit = function (visitor, context) { return visitor.visitIcu(this, context); }; return Icu; }()); var TagPlaceholder = /** @class */ (function () { function TagPlaceholder(tag, attrs, startName, closeName, children, isVoid, sourceSpan) { this.tag = tag; this.attrs = attrs; this.startName = startName; this.closeName = closeName; this.children = children; this.isVoid = isVoid; this.sourceSpan = sourceSpan; } TagPlaceholder.prototype.visit = function (visitor, context) { return visitor.visitTagPlaceholder(this, context); }; return TagPlaceholder; }()); var Placeholder = /** @class */ (function () { function Placeholder(value, name, sourceSpan) { this.value = value; this.name = name; this.sourceSpan = sourceSpan; } Placeholder.prototype.visit = function (visitor, context) { return visitor.visitPlaceholder(this, context); }; return Placeholder; }()); var IcuPlaceholder = /** @class */ (function () { function IcuPlaceholder(value, name, sourceSpan) { this.value = value; this.name = name; this.sourceSpan = sourceSpan; } IcuPlaceholder.prototype.visit = function (visitor, context) { return visitor.visitIcuPlaceholder(this, context); }; return IcuPlaceholder; }()); // Clone the AST var CloneVisitor = /** @class */ (function () { function CloneVisitor() { } CloneVisitor.prototype.visitText = function (text, context) { return new Text(text.value, text.sourceSpan); }; CloneVisitor.prototype.visitContainer = function (container, context) { var _this = this; var children = container.children.map(function (n) { return n.visit(_this, context); }); return new Container(children, container.sourceSpan); }; CloneVisitor.prototype.visitIcu = function (icu, context) { var _this = this; var cases = {}; Object.keys(icu.cases).forEach(function (key) { return cases[key] = icu.cases[key].visit(_this, context); }); var msg = new Icu(icu.expression, icu.type, cases, icu.sourceSpan); msg.expressionPlaceholder = icu.expressionPlaceholder; return msg; }; CloneVisitor.prototype.visitTagPlaceholder = function (ph, context) { var _this = this; var children = ph.children.map(function (n) { return n.visit(_this, context); }); return new TagPlaceholder(ph.tag, ph.attrs, ph.startName, ph.closeName, children, ph.isVoid, ph.sourceSpan); }; CloneVisitor.prototype.visitPlaceholder = function (ph, context) { return new Placeholder(ph.value, ph.name, ph.sourceSpan); }; CloneVisitor.prototype.visitIcuPlaceholder = function (ph, context) { return new IcuPlaceholder(ph.value, ph.name, ph.sourceSpan); }; return CloneVisitor; }()); // Visit all the nodes recursively var RecurseVisitor = /** @class */ (function () { function RecurseVisitor() { } RecurseVisitor.prototype.visitText = function (text, context) { }; RecurseVisitor.prototype.visitContainer = function (container, context) { var _this = this; container.children.forEach(function (child) { return child.visit(_this); }); }; RecurseVisitor.prototype.visitIcu = function (icu, context) { var _this = this; Object.keys(icu.cases).forEach(function (k) { icu.cases[k].visit(_this); }); }; RecurseVisitor.prototype.visitTagPlaceholder = function (ph, context) { var _this = this; ph.children.forEach(function (child) { return child.visit(_this); }); }; RecurseVisitor.prototype.visitPlaceholder = function (ph, context) { }; RecurseVisitor.prototype.visitIcuPlaceholder = function (ph, context) { }; return RecurseVisitor; }()); /** * @license * Copyright Google Inc. All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ function digest(message) { return message.id || sha1(serializeNodes(message.nodes).join('') + ("[" + message.meaning + "]")); } function decimalDigest(message) { if (message.id) { return message.id; } var visitor = new _SerializerIgnoreIcuExpVisitor(); var parts = message.nodes.map(function (a) { return a.visit(visitor, null); }); return computeMsgId(parts.join(''), message.meaning); } /** * Serialize the i18n ast to something xml-like in order to generate an UID. * * The visitor is also used in the i18n parser tests * * @internal */ var _SerializerVisitor = /** @class */ (function () { function _SerializerVisitor() { } _SerializerVisitor.prototype.visitText = function (text, context) { return text.value; }; _SerializerVisitor.prototype.visitContainer = function (container, context) { var _this = this; return "[" + container.children.map(function (child) { return child.visit(_this); }).join(', ') + "]"; }; _SerializerVisitor.prototype.visitIcu = function (icu, context) { var _this = this; var strCases = Object.keys(icu.cases).map(function (k) { return k + " {" + icu.cases[k].visit(_this) + "}"; }); return "{" + icu.expression + ", " + icu.type + ", " + strCases.join(', ') + "}"; }; _SerializerVisitor.prototype.visitTagPlaceholder = function (ph, context) { var _this = this; return ph.isVoid ? "" : "" + ph.children.map(function (child) { return child.visit(_this); }).join(', ') + ""; }; _SerializerVisitor.prototype.visitPlaceholder = function (ph, context) { return ph.value ? "" + ph.value + "" : ""; }; _SerializerVisitor.prototype.visitIcuPlaceholder = function (ph, context) { return "" + ph.value.visit(this) + ""; }; return _SerializerVisitor; }()); var serializerVisitor = new _SerializerVisitor(); function serializeNodes(nodes) { return nodes.map(function (a) { return a.visit(serializerVisitor, null); }); } /** * Serialize the i18n ast to something xml-like in order to generate an UID. * * Ignore the ICU expressions so that message IDs stays identical if only the expression changes. * * @internal */ var _SerializerIgnoreIcuExpVisitor = /** @class */ (function (_super) { Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(_SerializerIgnoreIcuExpVisitor, _super); function _SerializerIgnoreIcuExpVisitor() { return _super !== null && _super.apply(this, arguments) || this; } _SerializerIgnoreIcuExpVisitor.prototype.visitIcu = function (icu, context) { var _this = this; var strCases = Object.keys(icu.cases).map(function (k) { return k + " {" + icu.cases[k].visit(_this) + "}"; }); // Do not take the expression into account return "{" + icu.type + ", " + strCases.join(', ') + "}"; }; return _SerializerIgnoreIcuExpVisitor; }(_SerializerVisitor)); /** * Compute the SHA1 of the given string * * see http://csrc.nist.gov/publications/fips/fips180-4/fips-180-4.pdf * * WARNING: this function has not been designed not tested with security in mind. * DO NOT USE IT IN A SECURITY SENSITIVE CONTEXT. */ function sha1(str) { var _a, _b; var utf8 = utf8Encode(str); var words32 = stringToWords32(utf8, Endian.Big); var len = utf8.length * 8; var w = new Array(80); var _c = Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__read"])([0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476, 0xc3d2e1f0], 5), a = _c[0], b = _c[1], c = _c[2], d = _c[3], e = _c[4]; words32[len >> 5] |= 0x80 << (24 - len % 32); words32[((len + 64 >> 9) << 4) + 15] = len; for (var i = 0; i < words32.length; i += 16) { var _d = Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__read"])([a, b, c, d, e], 5), h0 = _d[0], h1 = _d[1], h2 = _d[2], h3 = _d[3], h4 = _d[4]; for (var j = 0; j < 80; j++) { if (j < 16) { w[j] = words32[i + j]; } else { w[j] = rol32(w[j - 3] ^ w[j - 8] ^ w[j - 14] ^ w[j - 16], 1); } var _e = Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__read"])(fk(j, b, c, d), 2), f = _e[0], k = _e[1]; var temp = [rol32(a, 5), f, e, k, w[j]].reduce(add32); _a = Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__read"])([d, c, rol32(b, 30), a, temp], 5), e = _a[0], d = _a[1], c = _a[2], b = _a[3], a = _a[4]; } _b = Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__read"])([add32(a, h0), add32(b, h1), add32(c, h2), add32(d, h3), add32(e, h4)], 5), a = _b[0], b = _b[1], c = _b[2], d = _b[3], e = _b[4]; } return byteStringToHexString(words32ToByteString([a, b, c, d, e])); } function fk(index, b, c, d) { if (index < 20) { return [(b & c) | (~b & d), 0x5a827999]; } if (index < 40) { return [b ^ c ^ d, 0x6ed9eba1]; } if (index < 60) { return [(b & c) | (b & d) | (c & d), 0x8f1bbcdc]; } return [b ^ c ^ d, 0xca62c1d6]; } /** * Compute the fingerprint of the given string * * The output is 64 bit number encoded as a decimal string * * based on: * https://github.com/google/closure-compiler/blob/master/src/com/google/javascript/jscomp/GoogleJsMessageIdGenerator.java */ function fingerprint(str) { var utf8 = utf8Encode(str); var _a = Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__read"])([hash32(utf8, 0), hash32(utf8, 102072)], 2), hi = _a[0], lo = _a[1]; if (hi == 0 && (lo == 0 || lo == 1)) { hi = hi ^ 0x130f9bef; lo = lo ^ -0x6b5f56d8; } return [hi, lo]; } function computeMsgId(msg, meaning) { var _a; var _b = Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__read"])(fingerprint(msg), 2), hi = _b[0], lo = _b[1]; if (meaning) { var _c = Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__read"])(fingerprint(meaning), 2), him = _c[0], lom = _c[1]; _a = Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__read"])(add64(rol64([hi, lo], 1), [him, lom]), 2), hi = _a[0], lo = _a[1]; } return byteStringToDecString(words32ToByteString([hi & 0x7fffffff, lo])); } function hash32(str, c) { var _a; var _b = Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__read"])([0x9e3779b9, 0x9e3779b9], 2), a = _b[0], b = _b[1]; var i; var len = str.length; for (i = 0; i + 12 <= len; i += 12) { a = add32(a, wordAt(str, i, Endian.Little)); b = add32(b, wordAt(str, i + 4, Endian.Little)); c = add32(c, wordAt(str, i + 8, Endian.Little)); _a = Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__read"])(mix([a, b, c]), 3), a = _a[0], b = _a[1], c = _a[2]; } a = add32(a, wordAt(str, i, Endian.Little)); b = add32(b, wordAt(str, i + 4, Endian.Little)); // the first byte of c is reserved for the length c = add32(c, len); c = add32(c, wordAt(str, i + 8, Endian.Little) << 8); return mix([a, b, c])[2]; } // clang-format off function mix(_a) { var _b = Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__read"])(_a, 3), a = _b[0], b = _b[1], c = _b[2]; a = sub32(a, b); a = sub32(a, c); a ^= c >>> 13; b = sub32(b, c); b = sub32(b, a); b ^= a << 8; c = sub32(c, a); c = sub32(c, b); c ^= b >>> 13; a = sub32(a, b); a = sub32(a, c); a ^= c >>> 12; b = sub32(b, c); b = sub32(b, a); b ^= a << 16; c = sub32(c, a); c = sub32(c, b); c ^= b >>> 5; a = sub32(a, b); a = sub32(a, c); a ^= c >>> 3; b = sub32(b, c); b = sub32(b, a); b ^= a << 10; c = sub32(c, a); c = sub32(c, b); c ^= b >>> 15; return [a, b, c]; } // clang-format on // Utils var Endian; (function (Endian) { Endian[Endian["Little"] = 0] = "Little"; Endian[Endian["Big"] = 1] = "Big"; })(Endian || (Endian = {})); function add32(a, b) { return add32to64(a, b)[1]; } function add32to64(a, b) { var low = (a & 0xffff) + (b & 0xffff); var high = (a >>> 16) + (b >>> 16) + (low >>> 16); return [high >>> 16, (high << 16) | (low & 0xffff)]; } function add64(_a, _b) { var _c = Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__read"])(_a, 2), ah = _c[0], al = _c[1]; var _d = Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__read"])(_b, 2), bh = _d[0], bl = _d[1]; var _e = Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__read"])(add32to64(al, bl), 2), carry = _e[0], l = _e[1]; var h = add32(add32(ah, bh), carry); return [h, l]; } function sub32(a, b) { var low = (a & 0xffff) - (b & 0xffff); var high = (a >> 16) - (b >> 16) + (low >> 16); return (high << 16) | (low & 0xffff); } // Rotate a 32b number left `count` position function rol32(a, count) { return (a << count) | (a >>> (32 - count)); } // Rotate a 64b number left `count` position function rol64(_a, count) { var _b = Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__read"])(_a, 2), hi = _b[0], lo = _b[1]; var h = (hi << count) | (lo >>> (32 - count)); var l = (lo << count) | (hi >>> (32 - count)); return [h, l]; } function stringToWords32(str, endian) { var words32 = Array((str.length + 3) >>> 2); for (var i = 0; i < words32.length; i++) { words32[i] = wordAt(str, i * 4, endian); } return words32; } function byteAt(str, index) { return index >= str.length ? 0 : str.charCodeAt(index) & 0xff; } function wordAt(str, index, endian) { var word = 0; if (endian === Endian.Big) { for (var i = 0; i < 4; i++) { word += byteAt(str, index + i) << (24 - 8 * i); } } else { for (var i = 0; i < 4; i++) { word += byteAt(str, index + i) << 8 * i; } } return word; } function words32ToByteString(words32) { return words32.reduce(function (str, word) { return str + word32ToByteString(word); }, ''); } function word32ToByteString(word) { var str = ''; for (var i = 0; i < 4; i++) { str += String.fromCharCode((word >>> 8 * (3 - i)) & 0xff); } return str; } function byteStringToHexString(str) { var hex = ''; for (var i = 0; i < str.length; i++) { var b = byteAt(str, i); hex += (b >>> 4).toString(16) + (b & 0x0f).toString(16); } return hex.toLowerCase(); } // based on http://www.danvk.org/hex2dec.html (JS can not handle more than 56b) function byteStringToDecString(str) { var decimal = ''; var toThePower = '1'; for (var i = str.length - 1; i >= 0; i--) { decimal = addBigInt(decimal, numberTimesBigInt(byteAt(str, i), toThePower)); toThePower = numberTimesBigInt(256, toThePower); } return decimal.split('').reverse().join(''); } // x and y decimal, lowest significant digit first function addBigInt(x, y) { var sum = ''; var len = Math.max(x.length, y.length); for (var i = 0, carry = 0; i < len || carry; i++) { var tmpSum = carry + +(x[i] || 0) + +(y[i] || 0); if (tmpSum >= 10) { carry = 1; sum += tmpSum - 10; } else { carry = 0; sum += tmpSum; } } return sum; } function numberTimesBigInt(num, b) { var product = ''; var bToThePower = b; for (; num !== 0; num = num >>> 1) { if (num & 1) product = addBigInt(product, bToThePower); bToThePower = addBigInt(bToThePower, bToThePower); } return product; } /** * @license * Copyright Google Inc. All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ var Serializer = /** @class */ (function () { function Serializer() { } // Creates a name mapper, see `PlaceholderMapper` // Returning `null` means that no name mapping is used. Serializer.prototype.createNameMapper = function (message) { return null; }; return Serializer; }()); /** * A simple mapper that take a function to transform an internal name to a public name */ var SimplePlaceholderMapper = /** @class */ (function (_super) { Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(SimplePlaceholderMapper, _super); // create a mapping from the message function SimplePlaceholderMapper(message, mapName) { var _this = _super.call(this) || this; _this.mapName = mapName; _this.internalToPublic = {}; _this.publicToNextId = {}; _this.publicToInternal = {}; message.nodes.forEach(function (node) { return node.visit(_this); }); return _this; } SimplePlaceholderMapper.prototype.toPublicName = function (internalName) { return this.internalToPublic.hasOwnProperty(internalName) ? this.internalToPublic[internalName] : null; }; SimplePlaceholderMapper.prototype.toInternalName = function (publicName) { return this.publicToInternal.hasOwnProperty(publicName) ? this.publicToInternal[publicName] : null; }; SimplePlaceholderMapper.prototype.visitText = function (text, context) { return null; }; SimplePlaceholderMapper.prototype.visitTagPlaceholder = function (ph, context) { this.visitPlaceholderName(ph.startName); _super.prototype.visitTagPlaceholder.call(this, ph, context); this.visitPlaceholderName(ph.closeName); }; SimplePlaceholderMapper.prototype.visitPlaceholder = function (ph, context) { this.visitPlaceholderName(ph.name); }; SimplePlaceholderMapper.prototype.visitIcuPlaceholder = function (ph, context) { this.visitPlaceholderName(ph.name); }; // XMB placeholders could only contains A-Z, 0-9 and _ SimplePlaceholderMapper.prototype.visitPlaceholderName = function (internalName) { if (!internalName || this.internalToPublic.hasOwnProperty(internalName)) { return; } var publicName = this.mapName(internalName); if (this.publicToInternal.hasOwnProperty(publicName)) { // Create a new XMB when it has already been used var nextId = this.publicToNextId[publicName]; this.publicToNextId[publicName] = nextId + 1; publicName = publicName + "_" + nextId; } else { this.publicToNextId[publicName] = 1; } this.internalToPublic[internalName] = publicName; this.publicToInternal[publicName] = internalName; }; return SimplePlaceholderMapper; }(RecurseVisitor)); /** * @license * Copyright Google Inc. All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ var _Visitor = /** @class */ (function () { function _Visitor() { } _Visitor.prototype.visitTag = function (tag) { var _this = this; var strAttrs = this._serializeAttributes(tag.attrs); if (tag.children.length == 0) { return "<" + tag.name + strAttrs + "/>"; } var strChildren = tag.children.map(function (node) { return node.visit(_this); }); return "<" + tag.name + strAttrs + ">" + strChildren.join('') + ""; }; _Visitor.prototype.visitText = function (text) { return text.value; }; _Visitor.prototype.visitDeclaration = function (decl) { return ""; }; _Visitor.prototype._serializeAttributes = function (attrs) { var strAttrs = Object.keys(attrs).map(function (name) { return name + "=\"" + attrs[name] + "\""; }).join(' '); return strAttrs.length > 0 ? ' ' + strAttrs : ''; }; _Visitor.prototype.visitDoctype = function (doctype) { return ""; }; return _Visitor; }()); var _visitor = new _Visitor(); function serialize(nodes) { return nodes.map(function (node) { return node.visit(_visitor); }).join(''); } var Declaration = /** @class */ (function () { function Declaration(unescapedAttrs) { var _this = this; this.attrs = {}; Object.keys(unescapedAttrs).forEach(function (k) { _this.attrs[k] = escapeXml(unescapedAttrs[k]); }); } Declaration.prototype.visit = function (visitor) { return visitor.visitDeclaration(this); }; return Declaration; }()); var Doctype = /** @class */ (function () { function Doctype(rootTag, dtd) { this.rootTag = rootTag; this.dtd = dtd; } Doctype.prototype.visit = function (visitor) { return visitor.visitDoctype(this); }; return Doctype; }()); var Tag = /** @class */ (function () { function Tag(name, unescapedAttrs, children) { if (unescapedAttrs === void 0) { unescapedAttrs = {}; } if (children === void 0) { children = []; } var _this = this; this.name = name; this.children = children; this.attrs = {}; Object.keys(unescapedAttrs).forEach(function (k) { _this.attrs[k] = escapeXml(unescapedAttrs[k]); }); } Tag.prototype.visit = function (visitor) { return visitor.visitTag(this); }; return Tag; }()); var Text$1 = /** @class */ (function () { function Text(unescapedValue) { this.value = escapeXml(unescapedValue); } Text.prototype.visit = function (visitor) { return visitor.visitText(this); }; return Text; }()); var CR = /** @class */ (function (_super) { Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(CR, _super); function CR(ws) { if (ws === void 0) { ws = 0; } return _super.call(this, "\n" + new Array(ws + 1).join(' ')) || this; } return CR; }(Text$1)); var _ESCAPED_CHARS = [ [/&/g, '&'], [/"/g, '"'], [/'/g, '''], [//g, '>'], ]; // Escape `_ESCAPED_CHARS` characters in the given text with encoded entities function escapeXml(text) { return _ESCAPED_CHARS.reduce(function (text, entry) { return text.replace(entry[0], entry[1]); }, text); } /** * @license * Copyright Google Inc. All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ var _MESSAGES_TAG = 'messagebundle'; var _MESSAGE_TAG = 'msg'; var _PLACEHOLDER_TAG = 'ph'; var _EXAMPLE_TAG = 'ex'; var _SOURCE_TAG = 'source'; var _DOCTYPE = "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"; var Xmb = /** @class */ (function (_super) { Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Xmb, _super); function Xmb() { return _super !== null && _super.apply(this, arguments) || this; } Xmb.prototype.write = function (messages, locale) { var exampleVisitor = new ExampleVisitor(); var visitor = new _Visitor$1(); var rootNode = new Tag(_MESSAGES_TAG); messages.forEach(function (message) { var attrs = { id: message.id }; if (message.description) { attrs['desc'] = message.description; } if (message.meaning) { attrs['meaning'] = message.meaning; } var sourceTags = []; message.sources.forEach(function (source) { sourceTags.push(new Tag(_SOURCE_TAG, {}, [ new Text$1(source.filePath + ":" + source.startLine + (source.endLine !== source.startLine ? ',' + source.endLine : '')) ])); }); rootNode.children.push(new CR(2), new Tag(_MESSAGE_TAG, attrs, Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__spread"])(sourceTags, visitor.serialize(message.nodes)))); }); rootNode.children.push(new CR()); return serialize([ new Declaration({ version: '1.0', encoding: 'UTF-8' }), new CR(), new Doctype(_MESSAGES_TAG, _DOCTYPE), new CR(), exampleVisitor.addDefaultExamples(rootNode), new CR(), ]); }; Xmb.prototype.load = function (content, url) { throw new Error('Unsupported'); }; Xmb.prototype.digest = function (message) { return digest$1(message); }; Xmb.prototype.createNameMapper = function (message) { return new SimplePlaceholderMapper(message, toPublicName); }; return Xmb; }(Serializer)); var _Visitor$1 = /** @class */ (function () { function _Visitor() { } _Visitor.prototype.visitText = function (text, context) { return [new Text$1(text.value)]; }; _Visitor.prototype.visitContainer = function (container, context) { var _this = this; var nodes = []; container.children.forEach(function (node) { return nodes.push.apply(nodes, Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__spread"])(node.visit(_this))); }); return nodes; }; _Visitor.prototype.visitIcu = function (icu, context) { var _this = this; var nodes = [new Text$1("{" + icu.expressionPlaceholder + ", " + icu.type + ", ")]; Object.keys(icu.cases).forEach(function (c) { nodes.push.apply(nodes, Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__spread"])([new Text$1(c + " {")], icu.cases[c].visit(_this), [new Text$1("} ")])); }); nodes.push(new Text$1("}")); return nodes; }; _Visitor.prototype.visitTagPlaceholder = function (ph, context) { var startTagAsText = new Text$1("<" + ph.tag + ">"); var startEx = new Tag(_EXAMPLE_TAG, {}, [startTagAsText]); // TC requires PH to have a non empty EX, and uses the text node to show the "original" value. var startTagPh = new Tag(_PLACEHOLDER_TAG, { name: ph.startName }, [startEx, startTagAsText]); if (ph.isVoid) { // void tags have no children nor closing tags return [startTagPh]; } var closeTagAsText = new Text$1(""); var closeEx = new Tag(_EXAMPLE_TAG, {}, [closeTagAsText]); // TC requires PH to have a non empty EX, and uses the text node to show the "original" value. var closeTagPh = new Tag(_PLACEHOLDER_TAG, { name: ph.closeName }, [closeEx, closeTagAsText]); return Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__spread"])([startTagPh], this.serialize(ph.children), [closeTagPh]); }; _Visitor.prototype.visitPlaceholder = function (ph, context) { var interpolationAsText = new Text$1("{{" + ph.value + "}}"); // Example tag needs to be not-empty for TC. var exTag = new Tag(_EXAMPLE_TAG, {}, [interpolationAsText]); return [ // TC requires PH to have a non empty EX, and uses the text node to show the "original" value. new Tag(_PLACEHOLDER_TAG, { name: ph.name }, [exTag, interpolationAsText]) ]; }; _Visitor.prototype.visitIcuPlaceholder = function (ph, context) { var icuExpression = ph.value.expression; var icuType = ph.value.type; var icuCases = Object.keys(ph.value.cases).map(function (value) { return value + ' {...}'; }).join(' '); var icuAsText = new Text$1("{" + icuExpression + ", " + icuType + ", " + icuCases + "}"); var exTag = new Tag(_EXAMPLE_TAG, {}, [icuAsText]); return [ // TC requires PH to have a non empty EX, and uses the text node to show the "original" value. new Tag(_PLACEHOLDER_TAG, { name: ph.name }, [exTag, icuAsText]) ]; }; _Visitor.prototype.serialize = function (nodes) { var _this = this; return [].concat.apply([], Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__spread"])(nodes.map(function (node) { return node.visit(_this); }))); }; return _Visitor; }()); function digest$1(message) { return decimalDigest(message); } // TC requires at least one non-empty example on placeholders var ExampleVisitor = /** @class */ (function () { function ExampleVisitor() { } ExampleVisitor.prototype.addDefaultExamples = function (node) { node.visit(this); return node; }; ExampleVisitor.prototype.visitTag = function (tag) { var _this = this; if (tag.name === _PLACEHOLDER_TAG) { if (!tag.children || tag.children.length == 0) { var exText = new Text$1(tag.attrs['name'] || '...'); tag.children = [new Tag(_EXAMPLE_TAG, {}, [exText])]; } } else if (tag.children) { tag.children.forEach(function (node) { return node.visit(_this); }); } }; ExampleVisitor.prototype.visitText = function (text) { }; ExampleVisitor.prototype.visitDeclaration = function (decl) { }; ExampleVisitor.prototype.visitDoctype = function (doctype) { }; return ExampleVisitor; }()); // XMB/XTB placeholders can only contain A-Z, 0-9 and _ function toPublicName(internalName) { return internalName.toUpperCase().replace(/[^A-Z0-9_]/g, '_'); } /** * @license * Copyright Google Inc. All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ function mapLiteral(obj, quoted) { if (quoted === void 0) { quoted = false; } return literalMap(Object.keys(obj).map(function (key) { return ({ key: key, quoted: quoted, value: obj[key], }); })); } /** * @license * Copyright Google Inc. All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ /* Closure variables holding messages must be named `MSG_[A-Z0-9]+` */ var CLOSURE_TRANSLATION_PREFIX = 'MSG_'; var CLOSURE_TRANSLATION_MATCHER_REGEXP = new RegExp("^" + CLOSURE_TRANSLATION_PREFIX); /* Prefix for non-`goog.getMsg` i18n-related vars */ var TRANSLATION_PREFIX = 'I18N_'; /** Closure uses `goog.getMsg(message)` to lookup translations */ var GOOG_GET_MSG = 'goog.getMsg'; /** I18n separators for metadata **/ var I18N_MEANING_SEPARATOR = '|'; var I18N_ID_SEPARATOR = '@@'; /** Name of the i18n attributes **/ var I18N_ATTR = 'i18n'; var I18N_ATTR_PREFIX = 'i18n-'; /** Prefix of var expressions used in ICUs */ var I18N_ICU_VAR_PREFIX = 'VAR_'; /** Prefix of ICU expressions for post processing */ var I18N_ICU_MAPPING_PREFIX = 'I18N_EXP_'; /** Placeholder wrapper for i18n expressions **/ var I18N_PLACEHOLDER_SYMBOL = '�'; function i18nTranslationToDeclStmt(variable$$1, message, params) { var args = [literal(message)]; if (params && Object.keys(params).length) { args.push(mapLiteral(params, true)); } var fnCall = variable(GOOG_GET_MSG).callFn(args); return variable$$1.set(fnCall).toDeclStmt(INFERRED_TYPE, [StmtModifier.Final]); } // Converts i18n meta informations for a message (id, description, meaning) // to a JsDoc statement formatted as expected by the Closure compiler. function i18nMetaToDocStmt(meta) { var tags = []; if (meta.description) { tags.push({ tagName: "desc" /* Desc */, text: meta.description }); } if (meta.meaning) { tags.push({ tagName: "meaning" /* Meaning */, text: meta.meaning }); } return tags.length == 0 ? null : new JSDocCommentStmt(tags); } function isI18nAttribute(name) { return name === I18N_ATTR || name.startsWith(I18N_ATTR_PREFIX); } function isI18nRootNode(meta) { return meta instanceof Message; } function isSingleI18nIcu(meta) { return isI18nRootNode(meta) && meta.nodes.length === 1 && meta.nodes[0] instanceof Icu; } function hasI18nAttrs(element) { return element.attrs.some(function (attr) { return isI18nAttribute(attr.name); }); } function metaFromI18nMessage(message, id) { if (id === void 0) { id = null; } return { id: typeof id === 'string' ? id : message.id || '', meaning: message.meaning || '', description: message.description || '' }; } function icuFromI18nMessage(message) { return message.nodes[0]; } function wrapI18nPlaceholder(content, contextId) { if (contextId === void 0) { contextId = 0; } var blockId = contextId > 0 ? ":" + contextId : ''; return "" + I18N_PLACEHOLDER_SYMBOL + content + blockId + I18N_PLACEHOLDER_SYMBOL; } function assembleI18nBoundString(strings, bindingStartIndex, contextId) { if (bindingStartIndex === void 0) { bindingStartIndex = 0; } if (contextId === void 0) { contextId = 0; } if (!strings.length) return ''; var acc = ''; var lastIdx = strings.length - 1; for (var i = 0; i < lastIdx; i++) { acc += "" + strings[i] + wrapI18nPlaceholder(bindingStartIndex + i, contextId); } acc += strings[lastIdx]; return acc; } function getSeqNumberGenerator(startsAt) { if (startsAt === void 0) { startsAt = 0; } var current = startsAt; return function () { return current++; }; } function placeholdersToParams(placeholders) { var params = {}; placeholders.forEach(function (values, key) { params[key] = literal(values.length > 1 ? "[" + values.join('|') + "]" : values[0]); }); return params; } function updatePlaceholderMap(map, name) { var values = []; for (var _i = 2; _i < arguments.length; _i++) { values[_i - 2] = arguments[_i]; } var current = map.get(name) || []; current.push.apply(current, Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__spread"])(values)); map.set(name, current); } function assembleBoundTextPlaceholders(meta, bindingStartIndex, contextId) { if (bindingStartIndex === void 0) { bindingStartIndex = 0; } if (contextId === void 0) { contextId = 0; } var startIdx = bindingStartIndex; var placeholders = new Map(); var node = meta instanceof Message ? meta.nodes.find(function (node) { return node instanceof Container; }) : meta; if (node) { node .children.filter(function (child) { return child instanceof Placeholder; }) .forEach(function (child, idx) { var content = wrapI18nPlaceholder(startIdx + idx, contextId); updatePlaceholderMap(placeholders, child.name, content); }); } return placeholders; } function findIndex(items, callback) { for (var i = 0; i < items.length; i++) { if (callback(items[i])) { return i; } } return -1; } /** * Parses i18n metas like: * - "@@id", * - "description[@@id]", * - "meaning|description[@@id]" * and returns an object with parsed output. * * @param meta String that represents i18n meta * @returns Object with id, meaning and description fields */ function parseI18nMeta(meta) { var _a, _b; var id; var meaning; var description; if (meta) { var idIndex = meta.indexOf(I18N_ID_SEPARATOR); var descIndex = meta.indexOf(I18N_MEANING_SEPARATOR); var meaningAndDesc = void 0; _a = Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__read"])((idIndex > -1) ? [meta.slice(0, idIndex), meta.slice(idIndex + 2)] : [meta, ''], 2), meaningAndDesc = _a[0], id = _a[1]; _b = Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__read"])((descIndex > -1) ? [meaningAndDesc.slice(0, descIndex), meaningAndDesc.slice(descIndex + 1)] : ['', meaningAndDesc], 2), meaning = _b[0], description = _b[1]; } return { id: id, meaning: meaning, description: description }; } /** * Converts internal placeholder names to public-facing format * (for example to use in goog.getMsg call). * Example: `START_TAG_DIV_1` is converted to `startTagDiv_1`. * * @param name The placeholder name that should be formatted * @returns Formatted placeholder name */ function formatI18nPlaceholderName(name) { var chunks = toPublicName(name).split('_'); if (chunks.length === 1) { // if no "_" found - just lowercase the value return name.toLowerCase(); } var postfix; // eject last element if it's a number if (/^\d+$/.test(chunks[chunks.length - 1])) { postfix = chunks.pop(); } var raw = chunks.shift().toLowerCase(); if (chunks.length) { raw += chunks.map(function (c) { return c.charAt(0).toUpperCase() + c.slice(1).toLowerCase(); }).join(''); } return postfix ? raw + "_" + postfix : raw; } /** * Generates a prefix for translation const name. * * @param extra Additional local prefix that should be injected into translation var name * @returns Complete translation const prefix */ function getTranslationConstPrefix(extra) { return ("" + CLOSURE_TRANSLATION_PREFIX + extra).toUpperCase(); } /** * Generates translation declaration statements. * * @param variable Translation value reference * @param message Text message to be translated * @param meta Object that contains meta information (id, meaning and description) * @param params Object with placeholders key-value pairs * @param transformFn Optional transformation (post processing) function reference * @returns Array of Statements that represent a given translation */ function getTranslationDeclStmts(variable$$1, message, meta, params, transformFn) { if (params === void 0) { params = {}; } var statements = []; var docStatements = i18nMetaToDocStmt(meta); if (docStatements) { statements.push(docStatements); } if (transformFn) { statements.push(i18nTranslationToDeclStmt(variable$$1, message, params)); // Closure Compiler doesn't allow non-goo.getMsg const names to start with `MSG_`, // so we update variable name prefix in case post processing is required, so we can // assign the result of post-processing function to the var that starts with `I18N_` var raw = variable(variable$$1.name); variable$$1.name = variable$$1.name.replace(CLOSURE_TRANSLATION_MATCHER_REGEXP, TRANSLATION_PREFIX); statements.push(variable$$1.set(transformFn(raw)).toDeclStmt(INFERRED_TYPE, [StmtModifier.Final])); } else { statements.push(i18nTranslationToDeclStmt(variable$$1, message, params)); } return statements; } /** * @license * Copyright Google Inc. All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ /** Name of the temporary to use during data binding */ var TEMPORARY_NAME = '_t'; /** Name of the context parameter passed into a template function */ var CONTEXT_NAME = 'ctx'; /** Name of the RenderFlag passed into a template function */ var RENDER_FLAGS = 'rf'; /** The prefix reference variables */ var REFERENCE_PREFIX = '_r'; /** The name of the implicit context reference */ var IMPLICIT_REFERENCE = '$implicit'; /** Non bindable attribute name **/ var NON_BINDABLE_ATTR = 'ngNonBindable'; /** * Creates an allocator for a temporary variable. * * A variable declaration is added to the statements the first time the allocator is invoked. */ function temporaryAllocator(statements, name) { var temp = null; return function () { if (!temp) { statements.push(new DeclareVarStmt(TEMPORARY_NAME, undefined, DYNAMIC_TYPE)); temp = variable(name); } return temp; }; } function unsupported(feature) { if (this) { throw new Error("Builder " + this.constructor.name + " doesn't support " + feature + " yet"); } throw new Error("Feature " + feature + " is not supported yet"); } function invalid$1(arg) { throw new Error("Invalid state: Visitor " + this.constructor.name + " doesn't handle " + undefined); } function asLiteral(value) { if (Array.isArray(value)) { return literalArr(value.map(asLiteral)); } return literal(value, INFERRED_TYPE); } function conditionallyCreateMapObjectLiteral(keys, keepDeclared) { if (Object.getOwnPropertyNames(keys).length > 0) { return mapToExpression(keys, keepDeclared); } return null; } function mapToExpression(map, keepDeclared) { return literalMap(Object.getOwnPropertyNames(map).map(function (key) { var _a, _b; // canonical syntax: `dirProp: publicProp` // if there is no `:`, use dirProp = elProp var value = map[key]; var declaredName; var publicName; var minifiedName; if (Array.isArray(value)) { _a = Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__read"])(value, 2), publicName = _a[0], declaredName = _a[1]; } else { _b = Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__read"])(splitAtColon(key, [key, value]), 2), declaredName = _b[0], publicName = _b[1]; } minifiedName = declaredName; return { key: minifiedName, quoted: false, value: (keepDeclared && publicName !== declaredName) ? literalArr([asLiteral(publicName), asLiteral(declaredName)]) : asLiteral(publicName) }; })); } /** * Remove trailing null nodes as they are implied. */ function trimTrailingNulls(parameters) { while (isNull(parameters[parameters.length - 1])) { parameters.pop(); } return parameters; } function getQueryPredicate(query, constantPool) { if (Array.isArray(query.predicate)) { var predicate_1 = []; query.predicate.forEach(function (selector) { // Each item in predicates array may contain strings with comma-separated refs // (for ex. 'ref, ref1, ..., refN'), thus we extract individual refs and store them // as separate array entities var selectors = selector.split(',').map(function (token) { return literal(token.trim()); }); predicate_1.push.apply(predicate_1, Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__spread"])(selectors)); }); return constantPool.getConstLiteral(literalArr(predicate_1), true); } else { return query.predicate; } } var DefinitionMap = /** @class */ (function () { function DefinitionMap() { this.values = []; } DefinitionMap.prototype.set = function (key, value) { if (value) { this.values.push({ key: key, value: value, quoted: false }); } }; DefinitionMap.prototype.toLiteralMap = function () { return literalMap(this.values); }; return DefinitionMap; }()); /** * Extract a map of properties to values for a given element or template node, which can be used * by the directive matching machinery. * * @param elOrTpl the element or template in question * @return an object set up for directive matching. For attributes on the element/template, this * object maps a property name to its (static) value. For any bindings, this map simply maps the * property name to an empty string. */ function getAttrsForDirectiveMatching(elOrTpl) { var attributesMap = {}; elOrTpl.attributes.forEach(function (a) { if (!isI18nAttribute(a.name)) { attributesMap[a.name] = a.value; } }); elOrTpl.inputs.forEach(function (i) { attributesMap[i.name] = ''; }); elOrTpl.outputs.forEach(function (o) { attributesMap[o.name] = ''; }); return attributesMap; } /** * @license * Copyright Google Inc. All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ var R3FactoryDelegateType; (function (R3FactoryDelegateType) { R3FactoryDelegateType[R3FactoryDelegateType["Class"] = 0] = "Class"; R3FactoryDelegateType[R3FactoryDelegateType["Function"] = 1] = "Function"; R3FactoryDelegateType[R3FactoryDelegateType["Factory"] = 2] = "Factory"; })(R3FactoryDelegateType || (R3FactoryDelegateType = {})); /** * Resolved type of a dependency. * * Occasionally, dependencies will have special significance which is known statically. In that * case the `R3ResolvedDependencyType` informs the factory generator that a particular dependency * should be generated specially (usually by calling a special injection function instead of the * standard one). */ var R3ResolvedDependencyType; (function (R3ResolvedDependencyType) { /** * A normal token dependency. */ R3ResolvedDependencyType[R3ResolvedDependencyType["Token"] = 0] = "Token"; /** * The dependency is for an attribute. * * The token expression is a string representing the attribute name. */ R3ResolvedDependencyType[R3ResolvedDependencyType["Attribute"] = 1] = "Attribute"; })(R3ResolvedDependencyType || (R3ResolvedDependencyType = {})); /** * Construct a factory function expression for the given `R3FactoryMetadata`. */ function compileFactoryFunction(meta) { var t = variable('t'); var statements = []; // The type to instantiate via constructor invocation. If there is no delegated factory, meaning // this type is always created by constructor invocation, then this is the type-to-create // parameter provided by the user (t) if specified, or the current type if not. If there is a // delegated factory (which is used to create the current type) then this is only the type-to- // create parameter (t). var typeForCtor = !isDelegatedMetadata(meta) ? new BinaryOperatorExpr(BinaryOperator.Or, t, meta.type) : t; var ctorExpr = null; if (meta.deps !== null) { // There is a constructor (either explicitly or implicitly defined). ctorExpr = new InstantiateExpr(typeForCtor, injectDependencies(meta.deps, meta.injectFn)); } else { var baseFactory = variable("\u0275" + meta.name + "_BaseFactory"); var getInheritedFactory = importExpr(Identifiers$1.getInheritedFactory); var baseFactoryStmt = baseFactory.set(getInheritedFactory.callFn([meta.type])).toDeclStmt(INFERRED_TYPE, [ StmtModifier.Exported, StmtModifier.Final ]); statements.push(baseFactoryStmt); // There is no constructor, use the base class' factory to construct typeForCtor. ctorExpr = baseFactory.callFn([typeForCtor]); } var ctorExprFinal = ctorExpr; var body = []; var retExpr = null; function makeConditionalFactory(nonCtorExpr) { var r = variable('r'); body.push(r.set(NULL_EXPR).toDeclStmt()); body.push(ifStmt(t, [r.set(ctorExprFinal).toStmt()], [r.set(nonCtorExpr).toStmt()])); return r; } if (isDelegatedMetadata(meta) && meta.delegateType === R3FactoryDelegateType.Factory) { var delegateFactory = variable("\u0275" + meta.name + "_BaseFactory"); var getFactoryOf = importExpr(Identifiers$1.getFactoryOf); if (meta.delegate.isEquivalent(meta.type)) { throw new Error("Illegal state: compiling factory that delegates to itself"); } var delegateFactoryStmt = delegateFactory.set(getFactoryOf.callFn([meta.delegate])).toDeclStmt(INFERRED_TYPE, [ StmtModifier.Exported, StmtModifier.Final ]); statements.push(delegateFactoryStmt); retExpr = makeConditionalFactory(delegateFactory.callFn([])); } else if (isDelegatedMetadata(meta)) { // This type is created with a delegated factory. If a type parameter is not specified, call // the factory instead. var delegateArgs = injectDependencies(meta.delegateDeps, meta.injectFn); // Either call `new delegate(...)` or `delegate(...)` depending on meta.useNewForDelegate. var factoryExpr = new (meta.delegateType === R3FactoryDelegateType.Class ? InstantiateExpr : InvokeFunctionExpr)(meta.delegate, delegateArgs); retExpr = makeConditionalFactory(factoryExpr); } else if (isExpressionFactoryMetadata(meta)) { // TODO(alxhub): decide whether to lower the value here or in the caller retExpr = makeConditionalFactory(meta.expression); } else { retExpr = ctorExpr; } return { factory: fn([new FnParam('t', DYNAMIC_TYPE)], Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__spread"])(body, [new ReturnStatement(retExpr)]), INFERRED_TYPE, undefined, meta.name + "_Factory"), statements: statements, }; } function injectDependencies(deps, injectFn) { return deps.map(function (dep) { return compileInjectDependency(dep, injectFn); }); } function compileInjectDependency(dep, injectFn) { // Interpret the dependency according to its resolved type. switch (dep.resolved) { case R3ResolvedDependencyType.Token: { // Build up the injection flags according to the metadata. var flags = 0 /* Default */ | (dep.self ? 2 /* Self */ : 0) | (dep.skipSelf ? 4 /* SkipSelf */ : 0) | (dep.host ? 1 /* Host */ : 0) | (dep.optional ? 8 /* Optional */ : 0); // Build up the arguments to the injectFn call. var injectArgs = [dep.token]; // If this dependency is optional or otherwise has non-default flags, then additional // parameters describing how to inject the dependency must be passed to the inject function // that's being used. if (flags !== 0 /* Default */ || dep.optional) { injectArgs.push(literal(flags)); } return importExpr(injectFn).callFn(injectArgs); } case R3ResolvedDependencyType.Attribute: // In the case of attributes, the attribute name in question is given as the token. return importExpr(Identifiers$1.injectAttribute).callFn([dep.token]); default: return unsupported("Unknown R3ResolvedDependencyType: " + R3ResolvedDependencyType[dep.resolved]); } } /** * A helper function useful for extracting `R3DependencyMetadata` from a Render2 * `CompileTypeMetadata` instance. */ function dependenciesFromGlobalMetadata(type, outputCtx, reflector) { var e_1, _a; // Use the `CompileReflector` to look up references to some well-known Angular types. These will // be compared with the token to statically determine whether the token has significance to // Angular, and set the correct `R3ResolvedDependencyType` as a result. var injectorRef = reflector.resolveExternalReference(Identifiers.Injector); // Iterate through the type's DI dependencies and produce `R3DependencyMetadata` for each of them. var deps = []; try { for (var _b = Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__values"])(type.diDeps), _c = _b.next(); !_c.done; _c = _b.next()) { var dependency = _c.value; if (dependency.token) { var tokenRef = tokenReference(dependency.token); var resolved = dependency.isAttribute ? R3ResolvedDependencyType.Attribute : R3ResolvedDependencyType.Token; // In the case of most dependencies, the token will be a reference to a type. Sometimes, // however, it can be a string, in the case of older Angular code or @Attribute injection. var token = tokenRef instanceof StaticSymbol ? outputCtx.importExpr(tokenRef) : literal(tokenRef); // Construct the dependency. deps.push({ token: token, resolved: resolved, host: !!dependency.isHost, optional: !!dependency.isOptional, self: !!dependency.isSelf, skipSelf: !!dependency.isSkipSelf, }); } else { unsupported('dependency without a token'); } } } catch (e_1_1) { e_1 = { error: e_1_1 }; } finally { try { if (_c && !_c.done && (_a = _b.return)) _a.call(_b); } finally { if (e_1) throw e_1.error; } } return deps; } function isDelegatedMetadata(meta) { return meta.delegateType !== undefined; } function isExpressionFactoryMetadata(meta) { return meta.expression !== undefined; } /** * @license * Copyright Google Inc. All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ /** * Convert an object map with `Expression` values into a `LiteralMapExpr`. */ function mapToMapExpression(map) { var result = Object.keys(map).map(function (key) { return ({ key: key, value: map[key], quoted: false }); }); return literalMap(result); } /** * Convert metadata into an `Expression` in the given `OutputContext`. * * This operation will handle arrays, references to symbols, or literal `null` or `undefined`. */ function convertMetaToOutput(meta, ctx) { if (Array.isArray(meta)) { return literalArr(meta.map(function (entry) { return convertMetaToOutput(entry, ctx); })); } if (meta instanceof StaticSymbol) { return ctx.importExpr(meta); } if (meta == null) { return literal(meta); } throw new Error("Internal error: Unsupported or unknown metadata: " + meta); } function typeWithParameters(type, numParams) { var params = null; if (numParams > 0) { params = []; for (var i = 0; i < numParams; i++) { params.push(DYNAMIC_TYPE); } } return expressionType(type, null, params); } var ANIMATE_SYMBOL_PREFIX = '@'; function prepareSyntheticPropertyName(name) { return "" + ANIMATE_SYMBOL_PREFIX + name; } function prepareSyntheticListenerName(name, phase) { return "" + ANIMATE_SYMBOL_PREFIX + name + "." + phase; } function getSyntheticPropertyName(name) { // this will strip out listener phase values... // @foo.start => @foo var i = name.indexOf('.'); name = i > 0 ? name.substring(0, i) : name; if (name.charAt(0) !== ANIMATE_SYMBOL_PREFIX) { name = ANIMATE_SYMBOL_PREFIX + name; } return name; } function prepareSyntheticListenerFunctionName(name, phase) { return "animation_" + name + "_" + phase; } /** * @license * Copyright Google Inc. All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ function compileInjectable(meta) { var result = null; var factoryMeta = { name: meta.name, type: meta.type, deps: meta.ctorDeps, injectFn: Identifiers.inject, }; if (meta.useClass !== undefined) { // meta.useClass has two modes of operation. Either deps are specified, in which case `new` is // used to instantiate the class with dependencies injected, or deps are not specified and // the factory of the class is used to instantiate it. // // A special case exists for useClass: Type where Type is the injectable type itself, in which // case omitting deps just uses the constructor dependencies instead. var useClassOnSelf = meta.useClass.isEquivalent(meta.type); var deps = meta.userDeps || (useClassOnSelf && meta.ctorDeps) || undefined; if (deps !== undefined) { // factory: () => new meta.useClass(...deps) result = compileFactoryFunction(Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"])({}, factoryMeta, { delegate: meta.useClass, delegateDeps: deps, delegateType: R3FactoryDelegateType.Class })); } else { result = compileFactoryFunction(Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"])({}, factoryMeta, { delegate: meta.useClass, delegateType: R3FactoryDelegateType.Factory })); } } else if (meta.useFactory !== undefined) { result = compileFactoryFunction(Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"])({}, factoryMeta, { delegate: meta.useFactory, delegateDeps: meta.userDeps || [], delegateType: R3FactoryDelegateType.Function })); } else if (meta.useValue !== undefined) { // Note: it's safe to use `meta.useValue` instead of the `USE_VALUE in meta` check used for // client code because meta.useValue is an Expression which will be defined even if the actual // value is undefined. result = compileFactoryFunction(Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"])({}, factoryMeta, { expression: meta.useValue })); } else if (meta.useExisting !== undefined) { // useExisting is an `inject` call on the existing token. result = compileFactoryFunction(Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"])({}, factoryMeta, { expression: importExpr(Identifiers.inject).callFn([meta.useExisting]) })); } else { result = compileFactoryFunction(factoryMeta); } var token = meta.type; var providedIn = meta.providedIn; var expression = importExpr(Identifiers.defineInjectable).callFn([mapToMapExpression({ token: token, factory: result.factory, providedIn: providedIn })]); var type = new ExpressionType(importExpr(Identifiers.InjectableDef, [typeWithParameters(meta.type, meta.typeArgumentCount)])); return { expression: expression, type: type, statements: result.statements, }; } /** * @license * Copyright Google Inc. All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ function assertArrayOfStrings(identifier, value) { if (value == null) { return; } if (!Array.isArray(value)) { throw new Error("Expected '" + identifier + "' to be an array of strings."); } for (var i = 0; i < value.length; i += 1) { if (typeof value[i] !== 'string') { throw new Error("Expected '" + identifier + "' to be an array of strings."); } } } var INTERPOLATION_BLACKLIST_REGEXPS = [ /^\s*$/, /[<>]/, /^[{}]$/, /&(#|[a-z])/i, /^\/\//, ]; function assertInterpolationSymbols(identifier, value) { if (value != null && !(Array.isArray(value) && value.length == 2)) { throw new Error("Expected '" + identifier + "' to be an array, [start, end]."); } else if (value != null) { var start_1 = value[0]; var end_1 = value[1]; // black list checking INTERPOLATION_BLACKLIST_REGEXPS.forEach(function (regexp) { if (regexp.test(start_1) || regexp.test(end_1)) { throw new Error("['" + start_1 + "', '" + end_1 + "'] contains unusable interpolation symbol."); } }); } } /** * @license * Copyright Google Inc. All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ var InterpolationConfig = /** @class */ (function () { function InterpolationConfig(start, end) { this.start = start; this.end = end; } InterpolationConfig.fromArray = function (markers) { if (!markers) { return DEFAULT_INTERPOLATION_CONFIG; } assertInterpolationSymbols('interpolation', markers); return new InterpolationConfig(markers[0], markers[1]); }; return InterpolationConfig; }()); var DEFAULT_INTERPOLATION_CONFIG = new InterpolationConfig('{{', '}}'); /** * @license * Copyright Google Inc. All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ // https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit var VERSION = 3; var JS_B64_PREFIX = '# sourceMappingURL=data:application/json;base64,'; var SourceMapGenerator = /** @class */ (function () { function SourceMapGenerator(file) { if (file === void 0) { file = null; } this.file = file; this.sourcesContent = new Map(); this.lines = []; this.lastCol0 = 0; this.hasMappings = false; } // The content is `null` when the content is expected to be loaded using the URL SourceMapGenerator.prototype.addSource = function (url, content) { if (content === void 0) { content = null; } if (!this.sourcesContent.has(url)) { this.sourcesContent.set(url, content); } return this; }; SourceMapGenerator.prototype.addLine = function () { this.lines.push([]); this.lastCol0 = 0; return this; }; SourceMapGenerator.prototype.addMapping = function (col0, sourceUrl, sourceLine0, sourceCol0) { if (!this.currentLine) { throw new Error("A line must be added before mappings can be added"); } if (sourceUrl != null && !this.sourcesContent.has(sourceUrl)) { throw new Error("Unknown source file \"" + sourceUrl + "\""); } if (col0 == null) { throw new Error("The column in the generated code must be provided"); } if (col0 < this.lastCol0) { throw new Error("Mapping should be added in output order"); } if (sourceUrl && (sourceLine0 == null || sourceCol0 == null)) { throw new Error("The source location must be provided when a source url is provided"); } this.hasMappings = true; this.lastCol0 = col0; this.currentLine.push({ col0: col0, sourceUrl: sourceUrl, sourceLine0: sourceLine0, sourceCol0: sourceCol0 }); return this; }; Object.defineProperty(SourceMapGenerator.prototype, "currentLine", { get: function () { return this.lines.slice(-1)[0]; }, enumerable: true, configurable: true }); SourceMapGenerator.prototype.toJSON = function () { var _this = this; if (!this.hasMappings) { return null; } var sourcesIndex = new Map(); var sources = []; var sourcesContent = []; Array.from(this.sourcesContent.keys()).forEach(function (url, i) { sourcesIndex.set(url, i); sources.push(url); sourcesContent.push(_this.sourcesContent.get(url) || null); }); var mappings = ''; var lastCol0 = 0; var lastSourceIndex = 0; var lastSourceLine0 = 0; var lastSourceCol0 = 0; this.lines.forEach(function (segments) { lastCol0 = 0; mappings += segments .map(function (segment) { // zero-based starting column of the line in the generated code var segAsStr = toBase64VLQ(segment.col0 - lastCol0); lastCol0 = segment.col0; if (segment.sourceUrl != null) { // zero-based index into the “sources” list segAsStr += toBase64VLQ(sourcesIndex.get(segment.sourceUrl) - lastSourceIndex); lastSourceIndex = sourcesIndex.get(segment.sourceUrl); // the zero-based starting line in the original source segAsStr += toBase64VLQ(segment.sourceLine0 - lastSourceLine0); lastSourceLine0 = segment.sourceLine0; // the zero-based starting column in the original source segAsStr += toBase64VLQ(segment.sourceCol0 - lastSourceCol0); lastSourceCol0 = segment.sourceCol0; } return segAsStr; }) .join(','); mappings += ';'; }); mappings = mappings.slice(0, -1); return { 'file': this.file || '', 'version': VERSION, 'sourceRoot': '', 'sources': sources, 'sourcesContent': sourcesContent, 'mappings': mappings, }; }; SourceMapGenerator.prototype.toJsComment = function () { return this.hasMappings ? '//' + JS_B64_PREFIX + toBase64String(JSON.stringify(this, null, 0)) : ''; }; return SourceMapGenerator; }()); function toBase64String(value) { var b64 = ''; value = utf8Encode(value); for (var i = 0; i < value.length;) { var i1 = value.charCodeAt(i++); var i2 = value.charCodeAt(i++); var i3 = value.charCodeAt(i++); b64 += toBase64Digit(i1 >> 2); b64 += toBase64Digit(((i1 & 3) << 4) | (isNaN(i2) ? 0 : i2 >> 4)); b64 += isNaN(i2) ? '=' : toBase64Digit(((i2 & 15) << 2) | (i3 >> 6)); b64 += isNaN(i2) || isNaN(i3) ? '=' : toBase64Digit(i3 & 63); } return b64; } function toBase64VLQ(value) { value = value < 0 ? ((-value) << 1) + 1 : value << 1; var out = ''; do { var digit = value & 31; value = value >> 5; if (value > 0) { digit = digit | 32; } out += toBase64Digit(digit); } while (value > 0); return out; } var B64_DIGITS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'; function toBase64Digit(value) { if (value < 0 || value >= 64) { throw new Error("Can only encode value in the range [0, 63]"); } return B64_DIGITS[value]; } /** * @license * Copyright Google Inc. All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ var _SINGLE_QUOTE_ESCAPE_STRING_RE = /'|\\|\n|\r|\$/g; var _LEGAL_IDENTIFIER_RE = /^[$A-Z_][0-9A-Z_$]*$/i; var _INDENT_WITH = ' '; var CATCH_ERROR_VAR$1 = variable('error', null, null); var CATCH_STACK_VAR$1 = variable('stack', null, null); var _EmittedLine = /** @class */ (function () { function _EmittedLine(indent) { this.indent = indent; this.partsLength = 0; this.parts = []; this.srcSpans = []; } return _EmittedLine; }()); var EmitterVisitorContext = /** @class */ (function () { function EmitterVisitorContext(_indent) { this._indent = _indent; this._classes = []; this._preambleLineCount = 0; this._lines = [new _EmittedLine(_indent)]; } EmitterVisitorContext.createRoot = function () { return new EmitterVisitorContext(0); }; Object.defineProperty(EmitterVisitorContext.prototype, "_currentLine", { get: function () { return this._lines[this._lines.length - 1]; }, enumerable: true, configurable: true }); EmitterVisitorContext.prototype.println = function (from, lastPart) { if (lastPart === void 0) { lastPart = ''; } this.print(from || null, lastPart, true); }; EmitterVisitorContext.prototype.lineIsEmpty = function () { return this._currentLine.parts.length === 0; }; EmitterVisitorContext.prototype.lineLength = function () { return this._currentLine.indent * _INDENT_WITH.length + this._currentLine.partsLength; }; EmitterVisitorContext.prototype.print = function (from, part, newLine) { if (newLine === void 0) { newLine = false; } if (part.length > 0) { this._currentLine.parts.push(part); this._currentLine.partsLength += part.length; this._currentLine.srcSpans.push(from && from.sourceSpan || null); } if (newLine) { this._lines.push(new _EmittedLine(this._indent)); } }; EmitterVisitorContext.prototype.removeEmptyLastLine = function () { if (this.lineIsEmpty()) { this._lines.pop(); } }; EmitterVisitorContext.prototype.incIndent = function () { this._indent++; if (this.lineIsEmpty()) { this._currentLine.indent = this._indent; } }; EmitterVisitorContext.prototype.decIndent = function () { this._indent--; if (this.lineIsEmpty()) { this._currentLine.indent = this._indent; } }; EmitterVisitorContext.prototype.pushClass = function (clazz) { this._classes.push(clazz); }; EmitterVisitorContext.prototype.popClass = function () { return this._classes.pop(); }; Object.defineProperty(EmitterVisitorContext.prototype, "currentClass", { get: function () { return this._classes.length > 0 ? this._classes[this._classes.length - 1] : null; }, enumerable: true, configurable: true }); EmitterVisitorContext.prototype.toSource = function () { return this.sourceLines .map(function (l) { return l.parts.length > 0 ? _createIndent(l.indent) + l.parts.join('') : ''; }) .join('\n'); }; EmitterVisitorContext.prototype.toSourceMapGenerator = function (genFilePath, startsAtLine) { if (startsAtLine === void 0) { startsAtLine = 0; } var map = new SourceMapGenerator(genFilePath); var firstOffsetMapped = false; var mapFirstOffsetIfNeeded = function () { if (!firstOffsetMapped) { // Add a single space so that tools won't try to load the file from disk. // Note: We are using virtual urls like `ng:///`, so we have to // provide a content here. map.addSource(genFilePath, ' ').addMapping(0, genFilePath, 0, 0); firstOffsetMapped = true; } }; for (var i = 0; i < startsAtLine; i++) { map.addLine(); mapFirstOffsetIfNeeded(); } this.sourceLines.forEach(function (line, lineIdx) { map.addLine(); var spans = line.srcSpans; var parts = line.parts; var col0 = line.indent * _INDENT_WITH.length; var spanIdx = 0; // skip leading parts without source spans while (spanIdx < spans.length && !spans[spanIdx]) { col0 += parts[spanIdx].length; spanIdx++; } if (spanIdx < spans.length && lineIdx === 0 && col0 === 0) { firstOffsetMapped = true; } else { mapFirstOffsetIfNeeded(); } while (spanIdx < spans.length) { var span = spans[spanIdx]; var source = span.start.file; var sourceLine = span.start.line; var sourceCol = span.start.col; map.addSource(source.url, source.content) .addMapping(col0, source.url, sourceLine, sourceCol); col0 += parts[spanIdx].length; spanIdx++; // assign parts without span or the same span to the previous segment while (spanIdx < spans.length && (span === spans[spanIdx] || !spans[spanIdx])) { col0 += parts[spanIdx].length; spanIdx++; } } }); return map; }; EmitterVisitorContext.prototype.setPreambleLineCount = function (count) { return this._preambleLineCount = count; }; EmitterVisitorContext.prototype.spanOf = function (line, column) { var emittedLine = this._lines[line - this._preambleLineCount]; if (emittedLine) { var columnsLeft = column - _createIndent(emittedLine.indent).length; for (var partIndex = 0; partIndex < emittedLine.parts.length; partIndex++) { var part = emittedLine.parts[partIndex]; if (part.length > columnsLeft) { return emittedLine.srcSpans[partIndex]; } columnsLeft -= part.length; } } return null; }; Object.defineProperty(EmitterVisitorContext.prototype, "sourceLines", { get: function () { if (this._lines.length && this._lines[this._lines.length - 1].parts.length === 0) { return this._lines.slice(0, -1); } return this._lines; }, enumerable: true, configurable: true }); return EmitterVisitorContext; }()); var AbstractEmitterVisitor = /** @class */ (function () { function AbstractEmitterVisitor(_escapeDollarInStrings) { this._escapeDollarInStrings = _escapeDollarInStrings; } AbstractEmitterVisitor.prototype.visitExpressionStmt = function (stmt, ctx) { stmt.expr.visitExpression(this, ctx); ctx.println(stmt, ';'); return null; }; AbstractEmitterVisitor.prototype.visitReturnStmt = function (stmt, ctx) { ctx.print(stmt, "return "); stmt.value.visitExpression(this, ctx); ctx.println(stmt, ';'); return null; }; AbstractEmitterVisitor.prototype.visitIfStmt = function (stmt, ctx) { ctx.print(stmt, "if ("); stmt.condition.visitExpression(this, ctx); ctx.print(stmt, ") {"); var hasElseCase = stmt.falseCase != null && stmt.falseCase.length > 0; if (stmt.trueCase.length <= 1 && !hasElseCase) { ctx.print(stmt, " "); this.visitAllStatements(stmt.trueCase, ctx); ctx.removeEmptyLastLine(); ctx.print(stmt, " "); } else { ctx.println(); ctx.incIndent(); this.visitAllStatements(stmt.trueCase, ctx); ctx.decIndent(); if (hasElseCase) { ctx.println(stmt, "} else {"); ctx.incIndent(); this.visitAllStatements(stmt.falseCase, ctx); ctx.decIndent(); } } ctx.println(stmt, "}"); return null; }; AbstractEmitterVisitor.prototype.visitThrowStmt = function (stmt, ctx) { ctx.print(stmt, "throw "); stmt.error.visitExpression(this, ctx); ctx.println(stmt, ";"); return null; }; AbstractEmitterVisitor.prototype.visitCommentStmt = function (stmt, ctx) { if (stmt.multiline) { ctx.println(stmt, "/* " + stmt.comment + " */"); } else { stmt.comment.split('\n').forEach(function (line) { ctx.println(stmt, "// " + line); }); } return null; }; AbstractEmitterVisitor.prototype.visitJSDocCommentStmt = function (stmt, ctx) { ctx.println(stmt, "/*" + stmt.toString() + "*/"); return null; }; AbstractEmitterVisitor.prototype.visitWriteVarExpr = function (expr, ctx) { var lineWasEmpty = ctx.lineIsEmpty(); if (!lineWasEmpty) { ctx.print(expr, '('); } ctx.print(expr, expr.name + " = "); expr.value.visitExpression(this, ctx); if (!lineWasEmpty) { ctx.print(expr, ')'); } return null; }; AbstractEmitterVisitor.prototype.visitWriteKeyExpr = function (expr, ctx) { var lineWasEmpty = ctx.lineIsEmpty(); if (!lineWasEmpty) { ctx.print(expr, '('); } expr.receiver.visitExpression(this, ctx); ctx.print(expr, "["); expr.index.visitExpression(this, ctx); ctx.print(expr, "] = "); expr.value.visitExpression(this, ctx); if (!lineWasEmpty) { ctx.print(expr, ')'); } return null; }; AbstractEmitterVisitor.prototype.visitWritePropExpr = function (expr, ctx) { var lineWasEmpty = ctx.lineIsEmpty(); if (!lineWasEmpty) { ctx.print(expr, '('); } expr.receiver.visitExpression(this, ctx); ctx.print(expr, "." + expr.name + " = "); expr.value.visitExpression(this, ctx); if (!lineWasEmpty) { ctx.print(expr, ')'); } return null; }; AbstractEmitterVisitor.prototype.visitInvokeMethodExpr = function (expr, ctx) { expr.receiver.visitExpression(this, ctx); var name = expr.name; if (expr.builtin != null) { name = this.getBuiltinMethodName(expr.builtin); if (name == null) { // some builtins just mean to skip the call. return null; } } ctx.print(expr, "." + name + "("); this.visitAllExpressions(expr.args, ctx, ","); ctx.print(expr, ")"); return null; }; AbstractEmitterVisitor.prototype.visitInvokeFunctionExpr = function (expr, ctx) { expr.fn.visitExpression(this, ctx); ctx.print(expr, "("); this.visitAllExpressions(expr.args, ctx, ','); ctx.print(expr, ")"); return null; }; AbstractEmitterVisitor.prototype.visitWrappedNodeExpr = function (ast, ctx) { throw new Error('Abstract emitter cannot visit WrappedNodeExpr.'); }; AbstractEmitterVisitor.prototype.visitTypeofExpr = function (expr, ctx) { ctx.print(expr, 'typeof '); expr.expr.visitExpression(this, ctx); }; AbstractEmitterVisitor.prototype.visitReadVarExpr = function (ast, ctx) { var varName = ast.name; if (ast.builtin != null) { switch (ast.builtin) { case BuiltinVar.Super: varName = 'super'; break; case BuiltinVar.This: varName = 'this'; break; case BuiltinVar.CatchError: varName = CATCH_ERROR_VAR$1.name; break; case BuiltinVar.CatchStack: varName = CATCH_STACK_VAR$1.name; break; default: throw new Error("Unknown builtin variable " + ast.builtin); } } ctx.print(ast, varName); return null; }; AbstractEmitterVisitor.prototype.visitInstantiateExpr = function (ast, ctx) { ctx.print(ast, "new "); ast.classExpr.visitExpression(this, ctx); ctx.print(ast, "("); this.visitAllExpressions(ast.args, ctx, ','); ctx.print(ast, ")"); return null; }; AbstractEmitterVisitor.prototype.visitLiteralExpr = function (ast, ctx) { var value = ast.value; if (typeof value === 'string') { ctx.print(ast, escapeIdentifier(value, this._escapeDollarInStrings)); } else { ctx.print(ast, "" + value); } return null; }; AbstractEmitterVisitor.prototype.visitConditionalExpr = function (ast, ctx) { ctx.print(ast, "("); ast.condition.visitExpression(this, ctx); ctx.print(ast, '? '); ast.trueCase.visitExpression(this, ctx); ctx.print(ast, ': '); ast.falseCase.visitExpression(this, ctx); ctx.print(ast, ")"); return null; }; AbstractEmitterVisitor.prototype.visitNotExpr = function (ast, ctx) { ctx.print(ast, '!'); ast.condition.visitExpression(this, ctx); return null; }; AbstractEmitterVisitor.prototype.visitAssertNotNullExpr = function (ast, ctx) { ast.condition.visitExpression(this, ctx); return null; }; AbstractEmitterVisitor.prototype.visitBinaryOperatorExpr = function (ast, ctx) { var opStr; switch (ast.operator) { case BinaryOperator.Equals: opStr = '=='; break; case BinaryOperator.Identical: opStr = '==='; break; case BinaryOperator.NotEquals: opStr = '!='; break; case BinaryOperator.NotIdentical: opStr = '!=='; break; case BinaryOperator.And: opStr = '&&'; break; case BinaryOperator.BitwiseAnd: opStr = '&'; break; case BinaryOperator.Or: opStr = '||'; break; case BinaryOperator.Plus: opStr = '+'; break; case BinaryOperator.Minus: opStr = '-'; break; case BinaryOperator.Divide: opStr = '/'; break; case BinaryOperator.Multiply: opStr = '*'; break; case BinaryOperator.Modulo: opStr = '%'; break; case BinaryOperator.Lower: opStr = '<'; break; case BinaryOperator.LowerEquals: opStr = '<='; break; case BinaryOperator.Bigger: opStr = '>'; break; case BinaryOperator.BiggerEquals: opStr = '>='; break; default: throw new Error("Unknown operator " + ast.operator); } if (ast.parens) ctx.print(ast, "("); ast.lhs.visitExpression(this, ctx); ctx.print(ast, " " + opStr + " "); ast.rhs.visitExpression(this, ctx); if (ast.parens) ctx.print(ast, ")"); return null; }; AbstractEmitterVisitor.prototype.visitReadPropExpr = function (ast, ctx) { ast.receiver.visitExpression(this, ctx); ctx.print(ast, "."); ctx.print(ast, ast.name); return null; }; AbstractEmitterVisitor.prototype.visitReadKeyExpr = function (ast, ctx) { ast.receiver.visitExpression(this, ctx); ctx.print(ast, "["); ast.index.visitExpression(this, ctx); ctx.print(ast, "]"); return null; }; AbstractEmitterVisitor.prototype.visitLiteralArrayExpr = function (ast, ctx) { ctx.print(ast, "["); this.visitAllExpressions(ast.entries, ctx, ','); ctx.print(ast, "]"); return null; }; AbstractEmitterVisitor.prototype.visitLiteralMapExpr = function (ast, ctx) { var _this = this; ctx.print(ast, "{"); this.visitAllObjects(function (entry) { ctx.print(ast, escapeIdentifier(entry.key, _this._escapeDollarInStrings, entry.quoted) + ":"); entry.value.visitExpression(_this, ctx); }, ast.entries, ctx, ','); ctx.print(ast, "}"); return null; }; AbstractEmitterVisitor.prototype.visitCommaExpr = function (ast, ctx) { ctx.print(ast, '('); this.visitAllExpressions(ast.parts, ctx, ','); ctx.print(ast, ')'); return null; }; AbstractEmitterVisitor.prototype.visitAllExpressions = function (expressions, ctx, separator) { var _this = this; this.visitAllObjects(function (expr) { return expr.visitExpression(_this, ctx); }, expressions, ctx, separator); }; AbstractEmitterVisitor.prototype.visitAllObjects = function (handler, expressions, ctx, separator) { var incrementedIndent = false; for (var i = 0; i < expressions.length; i++) { if (i > 0) { if (ctx.lineLength() > 80) { ctx.print(null, separator, true); if (!incrementedIndent) { // continuation are marked with double indent. ctx.incIndent(); ctx.incIndent(); incrementedIndent = true; } } else { ctx.print(null, separator, false); } } handler(expressions[i]); } if (incrementedIndent) { // continuation are marked with double indent. ctx.decIndent(); ctx.decIndent(); } }; AbstractEmitterVisitor.prototype.visitAllStatements = function (statements, ctx) { var _this = this; statements.forEach(function (stmt) { return stmt.visitStatement(_this, ctx); }); }; return AbstractEmitterVisitor; }()); function escapeIdentifier(input, escapeDollar, alwaysQuote) { if (alwaysQuote === void 0) { alwaysQuote = true; } if (input == null) { return null; } var body = input.replace(_SINGLE_QUOTE_ESCAPE_STRING_RE, function () { var match = []; for (var _i = 0; _i < arguments.length; _i++) { match[_i] = arguments[_i]; } if (match[0] == '$') { return escapeDollar ? '\\$' : '$'; } else if (match[0] == '\n') { return '\\n'; } else if (match[0] == '\r') { return '\\r'; } else { return "\\" + match[0]; } }); var requiresQuotes = alwaysQuote || !_LEGAL_IDENTIFIER_RE.test(body); return requiresQuotes ? "'" + body + "'" : body; } function _createIndent(count) { var res = ''; for (var i = 0; i < count; i++) { res += _INDENT_WITH; } return res; } /** * @license * Copyright Google Inc. All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ var AbstractJsEmitterVisitor = /** @class */ (function (_super) { Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(AbstractJsEmitterVisitor, _super); function AbstractJsEmitterVisitor() { return _super.call(this, false) || this; } AbstractJsEmitterVisitor.prototype.visitDeclareClassStmt = function (stmt, ctx) { var _this = this; ctx.pushClass(stmt); this._visitClassConstructor(stmt, ctx); if (stmt.parent != null) { ctx.print(stmt, stmt.name + ".prototype = Object.create("); stmt.parent.visitExpression(this, ctx); ctx.println(stmt, ".prototype);"); } stmt.getters.forEach(function (getter) { return _this._visitClassGetter(stmt, getter, ctx); }); stmt.methods.forEach(function (method) { return _this._visitClassMethod(stmt, method, ctx); }); ctx.popClass(); return null; }; AbstractJsEmitterVisitor.prototype._visitClassConstructor = function (stmt, ctx) { ctx.print(stmt, "function " + stmt.name + "("); if (stmt.constructorMethod != null) { this._visitParams(stmt.constructorMethod.params, ctx); } ctx.println(stmt, ") {"); ctx.incIndent(); if (stmt.constructorMethod != null) { if (stmt.constructorMethod.body.length > 0) { ctx.println(stmt, "var self = this;"); this.visitAllStatements(stmt.constructorMethod.body, ctx); } } ctx.decIndent(); ctx.println(stmt, "}"); }; AbstractJsEmitterVisitor.prototype._visitClassGetter = function (stmt, getter, ctx) { ctx.println(stmt, "Object.defineProperty(" + stmt.name + ".prototype, '" + getter.name + "', { get: function() {"); ctx.incIndent(); if (getter.body.length > 0) { ctx.println(stmt, "var self = this;"); this.visitAllStatements(getter.body, ctx); } ctx.decIndent(); ctx.println(stmt, "}});"); }; AbstractJsEmitterVisitor.prototype._visitClassMethod = function (stmt, method, ctx) { ctx.print(stmt, stmt.name + ".prototype." + method.name + " = function("); this._visitParams(method.params, ctx); ctx.println(stmt, ") {"); ctx.incIndent(); if (method.body.length > 0) { ctx.println(stmt, "var self = this;"); this.visitAllStatements(method.body, ctx); } ctx.decIndent(); ctx.println(stmt, "};"); }; AbstractJsEmitterVisitor.prototype.visitWrappedNodeExpr = function (ast, ctx) { throw new Error('Cannot emit a WrappedNodeExpr in Javascript.'); }; AbstractJsEmitterVisitor.prototype.visitReadVarExpr = function (ast, ctx) { if (ast.builtin === BuiltinVar.This) { ctx.print(ast, 'self'); } else if (ast.builtin === BuiltinVar.Super) { throw new Error("'super' needs to be handled at a parent ast node, not at the variable level!"); } else { _super.prototype.visitReadVarExpr.call(this, ast, ctx); } return null; }; AbstractJsEmitterVisitor.prototype.visitDeclareVarStmt = function (stmt, ctx) { ctx.print(stmt, "var " + stmt.name); if (stmt.value) { ctx.print(stmt, ' = '); stmt.value.visitExpression(this, ctx); } ctx.println(stmt, ";"); return null; }; AbstractJsEmitterVisitor.prototype.visitCastExpr = function (ast, ctx) { ast.value.visitExpression(this, ctx); return null; }; AbstractJsEmitterVisitor.prototype.visitInvokeFunctionExpr = function (expr, ctx) { var fnExpr = expr.fn; if (fnExpr instanceof ReadVarExpr && fnExpr.builtin === BuiltinVar.Super) { ctx.currentClass.parent.visitExpression(this, ctx); ctx.print(expr, ".call(this"); if (expr.args.length > 0) { ctx.print(expr, ", "); this.visitAllExpressions(expr.args, ctx, ','); } ctx.print(expr, ")"); } else { _super.prototype.visitInvokeFunctionExpr.call(this, expr, ctx); } return null; }; AbstractJsEmitterVisitor.prototype.visitFunctionExpr = function (ast, ctx) { ctx.print(ast, "function" + (ast.name ? ' ' + ast.name : '') + "("); this._visitParams(ast.params, ctx); ctx.println(ast, ") {"); ctx.incIndent(); this.visitAllStatements(ast.statements, ctx); ctx.decIndent(); ctx.print(ast, "}"); return null; }; AbstractJsEmitterVisitor.prototype.visitDeclareFunctionStmt = function (stmt, ctx) { ctx.print(stmt, "function " + stmt.name + "("); this._visitParams(stmt.params, ctx); ctx.println(stmt, ") {"); ctx.incIndent(); this.visitAllStatements(stmt.statements, ctx); ctx.decIndent(); ctx.println(stmt, "}"); return null; }; AbstractJsEmitterVisitor.prototype.visitTryCatchStmt = function (stmt, ctx) { ctx.println(stmt, "try {"); ctx.incIndent(); this.visitAllStatements(stmt.bodyStmts, ctx); ctx.decIndent(); ctx.println(stmt, "} catch (" + CATCH_ERROR_VAR$1.name + ") {"); ctx.incIndent(); var catchStmts = [CATCH_STACK_VAR$1.set(CATCH_ERROR_VAR$1.prop('stack')).toDeclStmt(null, [ StmtModifier.Final ])].concat(stmt.catchStmts); this.visitAllStatements(catchStmts, ctx); ctx.decIndent(); ctx.println(stmt, "}"); return null; }; AbstractJsEmitterVisitor.prototype._visitParams = function (params, ctx) { this.visitAllObjects(function (param) { return ctx.print(null, param.name); }, params, ctx, ','); }; AbstractJsEmitterVisitor.prototype.getBuiltinMethodName = function (method) { var name; switch (method) { case BuiltinMethod.ConcatArray: name = 'concat'; break; case BuiltinMethod.SubscribeObservable: name = 'subscribe'; break; case BuiltinMethod.Bind: name = 'bind'; break; default: throw new Error("Unknown builtin method: " + method); } return name; }; return AbstractJsEmitterVisitor; }(AbstractEmitterVisitor)); /** * @license * Copyright Google Inc. All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ function evalExpression(sourceUrl, ctx, vars, createSourceMap) { var fnBody = ctx.toSource() + "\n//# sourceURL=" + sourceUrl; var fnArgNames = []; var fnArgValues = []; for (var argName in vars) { fnArgNames.push(argName); fnArgValues.push(vars[argName]); } if (createSourceMap) { // using `new Function(...)` generates a header, 1 line of no arguments, 2 lines otherwise // E.g. ``` // function anonymous(a,b,c // /**/) { ... }``` // We don't want to hard code this fact, so we auto detect it via an empty function first. var emptyFn = new (Function.bind.apply(Function, Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__spread"])([void 0], fnArgNames.concat('return null;'))))().toString(); var headerLines = emptyFn.slice(0, emptyFn.indexOf('return null;')).split('\n').length - 1; fnBody += "\n" + ctx.toSourceMapGenerator(sourceUrl, headerLines).toJsComment(); } return new (Function.bind.apply(Function, Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__spread"])([void 0], fnArgNames.concat(fnBody))))().apply(void 0, Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__spread"])(fnArgValues)); } function jitStatements(sourceUrl, statements, reflector, createSourceMaps) { var converter = new JitEmitterVisitor(reflector); var ctx = EmitterVisitorContext.createRoot(); converter.visitAllStatements(statements, ctx); converter.createReturnStmt(ctx); return evalExpression(sourceUrl, ctx, converter.getArgs(), createSourceMaps); } var JitEmitterVisitor = /** @class */ (function (_super) { Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(JitEmitterVisitor, _super); function JitEmitterVisitor(reflector) { var _this = _super.call(this) || this; _this.reflector = reflector; _this._evalArgNames = []; _this._evalArgValues = []; _this._evalExportedVars = []; return _this; } JitEmitterVisitor.prototype.createReturnStmt = function (ctx) { var stmt = new ReturnStatement(new LiteralMapExpr(this._evalExportedVars.map(function (resultVar) { return new LiteralMapEntry(resultVar, variable(resultVar), false); }))); stmt.visitStatement(this, ctx); }; JitEmitterVisitor.prototype.getArgs = function () { var result = {}; for (var i = 0; i < this._evalArgNames.length; i++) { result[this._evalArgNames[i]] = this._evalArgValues[i]; } return result; }; JitEmitterVisitor.prototype.visitExternalExpr = function (ast, ctx) { this._emitReferenceToExternal(ast, this.reflector.resolveExternalReference(ast.value), ctx); return null; }; JitEmitterVisitor.prototype.visitWrappedNodeExpr = function (ast, ctx) { this._emitReferenceToExternal(ast, ast.node, ctx); return null; }; JitEmitterVisitor.prototype.visitDeclareVarStmt = function (stmt, ctx) { if (stmt.hasModifier(StmtModifier.Exported)) { this._evalExportedVars.push(stmt.name); } return _super.prototype.visitDeclareVarStmt.call(this, stmt, ctx); }; JitEmitterVisitor.prototype.visitDeclareFunctionStmt = function (stmt, ctx) { if (stmt.hasModifier(StmtModifier.Exported)) { this._evalExportedVars.push(stmt.name); } return _super.prototype.visitDeclareFunctionStmt.call(this, stmt, ctx); }; JitEmitterVisitor.prototype.visitDeclareClassStmt = function (stmt, ctx) { if (stmt.hasModifier(StmtModifier.Exported)) { this._evalExportedVars.push(stmt.name); } return _super.prototype.visitDeclareClassStmt.call(this, stmt, ctx); }; JitEmitterVisitor.prototype._emitReferenceToExternal = function (ast, value, ctx) { var id = this._evalArgValues.indexOf(value); if (id === -1) { id = this._evalArgValues.length; this._evalArgValues.push(value); var name_1 = identifierName({ reference: value }) || 'val'; this._evalArgNames.push("jit_" + name_1 + "_" + id); } ctx.print(ast, this._evalArgNames[id]); }; return JitEmitterVisitor; }(AbstractJsEmitterVisitor)); /** * @license * Copyright Google Inc. All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ /** * Implementation of `CompileReflector` which resolves references to @angular/core * symbols at runtime, according to a consumer-provided mapping. * * Only supports `resolveExternalReference`, all other methods throw. */ var R3JitReflector = /** @class */ (function () { function R3JitReflector(context) { this.context = context; } R3JitReflector.prototype.resolveExternalReference = function (ref) { // This reflector only handles @angular/core imports. if (ref.moduleName !== '@angular/core') { throw new Error("Cannot resolve external reference to " + ref.moduleName + ", only references to @angular/core are supported."); } if (!this.context.hasOwnProperty(ref.name)) { throw new Error("No value provided for @angular/core symbol '" + ref.name + "'."); } return this.context[ref.name]; }; R3JitReflector.prototype.parameters = function (typeOrFunc) { throw new Error('Not implemented.'); }; R3JitReflector.prototype.annotations = function (typeOrFunc) { throw new Error('Not implemented.'); }; R3JitReflector.prototype.shallowAnnotations = function (typeOrFunc) { throw new Error('Not implemented.'); }; R3JitReflector.prototype.tryAnnotations = function (typeOrFunc) { throw new Error('Not implemented.'); }; R3JitReflector.prototype.propMetadata = function (typeOrFunc) { throw new Error('Not implemented.'); }; R3JitReflector.prototype.hasLifecycleHook = function (type, lcProperty) { throw new Error('Not implemented.'); }; R3JitReflector.prototype.guards = function (typeOrFunc) { throw new Error('Not implemented.'); }; R3JitReflector.prototype.componentModuleUrl = function (type, cmpMetadata) { throw new Error('Not implemented.'); }; return R3JitReflector; }()); /** * JIT compiles an expression and returns the result of executing that expression. * * @param def the definition which will be compiled and executed to get the value to patch * @param context an object map of @angular/core symbol names to symbols which will be available in * the context of the compiled expression * @param sourceUrl a URL to use for the source map of the compiled expression * @param constantPool an optional `ConstantPool` which contains constants used in the expression */ function jitExpression(def, context, sourceUrl, preStatements) { // The ConstantPool may contain Statements which declare variables used in the final expression. // Therefore, its statements need to precede the actual JIT operation. The final statement is a // declaration of $def which is set to the expression being compiled. var statements = Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__spread"])(preStatements, [ new DeclareVarStmt('$def', def, undefined, [StmtModifier.Exported]), ]); var res = jitStatements(sourceUrl, statements, new R3JitReflector(context), false); return res['$def']; } /** * @license * Copyright Google Inc. All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ /** * Construct an `R3NgModuleDef` for the given `R3NgModuleMetadata`. */ function compileNgModule(meta) { var moduleType = meta.type, bootstrap = meta.bootstrap, declarations = meta.declarations, imports = meta.imports, exports = meta.exports; var expression = importExpr(Identifiers$1.defineNgModule).callFn([mapToMapExpression({ type: moduleType, bootstrap: literalArr(bootstrap.map(function (ref) { return ref.value; })), declarations: literalArr(declarations.map(function (ref) { return ref.value; })), imports: literalArr(imports.map(function (ref) { return ref.value; })), exports: literalArr(exports.map(function (ref) { return ref.value; })), })]); var type = new ExpressionType(importExpr(Identifiers$1.NgModuleDefWithMeta, [ new ExpressionType(moduleType), tupleTypeOf(declarations), tupleTypeOf(imports), tupleTypeOf(exports) ])); var additionalStatements = []; return { expression: expression, type: type, additionalStatements: additionalStatements }; } function compileInjector(meta) { var result = compileFactoryFunction({ name: meta.name, type: meta.type, deps: meta.deps, injectFn: Identifiers$1.inject, }); var expression = importExpr(Identifiers$1.defineInjector).callFn([mapToMapExpression({ factory: result.factory, providers: meta.providers, imports: meta.imports, })]); var type = new ExpressionType(importExpr(Identifiers$1.InjectorDef, [new ExpressionType(meta.type)])); return { expression: expression, type: type, statements: result.statements }; } // TODO(alxhub): integrate this with `compileNgModule`. Currently the two are separate operations. function compileNgModuleFromRender2(ctx, ngModule, injectableCompiler) { var className = identifierName(ngModule.type); var rawImports = ngModule.rawImports ? [ngModule.rawImports] : []; var rawExports = ngModule.rawExports ? [ngModule.rawExports] : []; var injectorDefArg = mapLiteral({ 'factory': injectableCompiler.factoryFor({ type: ngModule.type, symbol: ngModule.type.reference }, ctx), 'providers': convertMetaToOutput(ngModule.rawProviders, ctx), 'imports': convertMetaToOutput(Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__spread"])(rawImports, rawExports), ctx), }); var injectorDef = importExpr(Identifiers$1.defineInjector).callFn([injectorDefArg]); ctx.statements.push(new ClassStmt( /* name */ className, /* parent */ null, /* fields */ [new ClassField( /* name */ 'ngInjectorDef', /* type */ INFERRED_TYPE, /* modifiers */ [StmtModifier.Static], /* initializer */ injectorDef)], /* getters */ [], /* constructorMethod */ new ClassMethod(null, [], []), /* methods */ [])); } function tupleTypeOf(exp) { var types = exp.map(function (ref) { return typeofExpr(ref.type); }); return exp.length > 0 ? expressionType(literalArr(types)) : NONE_TYPE; } /** * @license * Copyright Google Inc. All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ function compilePipeFromMetadata(metadata) { var definitionMapValues = []; // e.g. `name: 'myPipe'` definitionMapValues.push({ key: 'name', value: literal(metadata.pipeName), quoted: false }); // e.g. `type: MyPipe` definitionMapValues.push({ key: 'type', value: metadata.type, quoted: false }); var templateFactory = compileFactoryFunction({ name: metadata.name, type: metadata.type, deps: metadata.deps, injectFn: Identifiers$1.directiveInject, }); definitionMapValues.push({ key: 'factory', value: templateFactory.factory, quoted: false }); // e.g. `pure: true` definitionMapValues.push({ key: 'pure', value: literal(metadata.pure), quoted: false }); var expression = importExpr(Identifiers$1.definePipe).callFn([literalMap(definitionMapValues)]); var type = new ExpressionType(importExpr(Identifiers$1.PipeDefWithMeta, [ new ExpressionType(metadata.type), new ExpressionType(new LiteralExpr(metadata.pipeName)), ])); return { expression: expression, type: type, statements: templateFactory.statements }; } /** * Write a pipe definition to the output context. */ function compilePipeFromRender2(outputCtx, pipe, reflector) { var name = identifierName(pipe.type); if (!name) { return error("Cannot resolve the name of " + pipe.type); } var metadata = { name: name, pipeName: pipe.name, type: outputCtx.importExpr(pipe.type.reference), deps: dependenciesFromGlobalMetadata(pipe.type, outputCtx, reflector), pure: pipe.pure, }; var res = compilePipeFromMetadata(metadata); var definitionField = outputCtx.constantPool.propertyNameOf(3 /* Pipe */); outputCtx.statements.push(new ClassStmt( /* name */ name, /* parent */ null, /* fields */ [new ClassField( /* name */ definitionField, /* type */ INFERRED_TYPE, /* modifiers */ [StmtModifier.Static], /* initializer */ res.expression)], /* getters */ [], /* constructorMethod */ new ClassMethod(null, [], []), /* methods */ [])); } /** * @license * Copyright Google Inc. All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ var ParserError = /** @class */ (function () { function ParserError(message, input, errLocation, ctxLocation) { this.input = input; this.errLocation = errLocation; this.ctxLocation = ctxLocation; this.message = "Parser Error: " + message + " " + errLocation + " [" + input + "] in " + ctxLocation; } return ParserError; }()); var ParseSpan = /** @class */ (function () { function ParseSpan(start, end) { this.start = start; this.end = end; } return ParseSpan; }()); var AST = /** @class */ (function () { function AST(span) { this.span = span; } AST.prototype.visit = function (visitor, context) { if (context === void 0) { context = null; } return null; }; AST.prototype.toString = function () { return 'AST'; }; return AST; }()); /** * Represents a quoted expression of the form: * * quote = prefix `:` uninterpretedExpression * prefix = identifier * uninterpretedExpression = arbitrary string * * A quoted expression is meant to be pre-processed by an AST transformer that * converts it into another AST that no longer contains quoted expressions. * It is meant to allow third-party developers to extend Angular template * expression language. The `uninterpretedExpression` part of the quote is * therefore not interpreted by the Angular's own expression parser. */ var Quote = /** @class */ (function (_super) { Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Quote, _super); function Quote(span, prefix, uninterpretedExpression, location) { var _this = _super.call(this, span) || this; _this.prefix = prefix; _this.uninterpretedExpression = uninterpretedExpression; _this.location = location; return _this; } Quote.prototype.visit = function (visitor, context) { if (context === void 0) { context = null; } return visitor.visitQuote(this, context); }; Quote.prototype.toString = function () { return 'Quote'; }; return Quote; }(AST)); var EmptyExpr = /** @class */ (function (_super) { Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(EmptyExpr, _super); function EmptyExpr() { return _super !== null && _super.apply(this, arguments) || this; } EmptyExpr.prototype.visit = function (visitor, context) { if (context === void 0) { context = null; } // do nothing }; return EmptyExpr; }(AST)); var ImplicitReceiver = /** @class */ (function (_super) { Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(ImplicitReceiver, _super); function ImplicitReceiver() { return _super !== null && _super.apply(this, arguments) || this; } ImplicitReceiver.prototype.visit = function (visitor, context) { if (context === void 0) { context = null; } return visitor.visitImplicitReceiver(this, context); }; return ImplicitReceiver; }(AST)); /** * Multiple expressions separated by a semicolon. */ var Chain = /** @class */ (function (_super) { Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Chain, _super); function Chain(span, expressions) { var _this = _super.call(this, span) || this; _this.expressions = expressions; return _this; } Chain.prototype.visit = function (visitor, context) { if (context === void 0) { context = null; } return visitor.visitChain(this, context); }; return Chain; }(AST)); var Conditional = /** @class */ (function (_super) { Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Conditional, _super); function Conditional(span, condition, trueExp, falseExp) { var _this = _super.call(this, span) || this; _this.condition = condition; _this.trueExp = trueExp; _this.falseExp = falseExp; return _this; } Conditional.prototype.visit = function (visitor, context) { if (context === void 0) { context = null; } return visitor.visitConditional(this, context); }; return Conditional; }(AST)); var PropertyRead = /** @class */ (function (_super) { Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(PropertyRead, _super); function PropertyRead(span, receiver, name) { var _this = _super.call(this, span) || this; _this.receiver = receiver; _this.name = name; return _this; } PropertyRead.prototype.visit = function (visitor, context) { if (context === void 0) { context = null; } return visitor.visitPropertyRead(this, context); }; return PropertyRead; }(AST)); var PropertyWrite = /** @class */ (function (_super) { Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(PropertyWrite, _super); function PropertyWrite(span, receiver, name, value) { var _this = _super.call(this, span) || this; _this.receiver = receiver; _this.name = name; _this.value = value; return _this; } PropertyWrite.prototype.visit = function (visitor, context) { if (context === void 0) { context = null; } return visitor.visitPropertyWrite(this, context); }; return PropertyWrite; }(AST)); var SafePropertyRead = /** @class */ (function (_super) { Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(SafePropertyRead, _super); function SafePropertyRead(span, receiver, name) { var _this = _super.call(this, span) || this; _this.receiver = receiver; _this.name = name; return _this; } SafePropertyRead.prototype.visit = function (visitor, context) { if (context === void 0) { context = null; } return visitor.visitSafePropertyRead(this, context); }; return SafePropertyRead; }(AST)); var KeyedRead = /** @class */ (function (_super) { Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(KeyedRead, _super); function KeyedRead(span, obj, key) { var _this = _super.call(this, span) || this; _this.obj = obj; _this.key = key; return _this; } KeyedRead.prototype.visit = function (visitor, context) { if (context === void 0) { context = null; } return visitor.visitKeyedRead(this, context); }; return KeyedRead; }(AST)); var KeyedWrite = /** @class */ (function (_super) { Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(KeyedWrite, _super); function KeyedWrite(span, obj, key, value) { var _this = _super.call(this, span) || this; _this.obj = obj; _this.key = key; _this.value = value; return _this; } KeyedWrite.prototype.visit = function (visitor, context) { if (context === void 0) { context = null; } return visitor.visitKeyedWrite(this, context); }; return KeyedWrite; }(AST)); var BindingPipe = /** @class */ (function (_super) { Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(BindingPipe, _super); function BindingPipe(span, exp, name, args) { var _this = _super.call(this, span) || this; _this.exp = exp; _this.name = name; _this.args = args; return _this; } BindingPipe.prototype.visit = function (visitor, context) { if (context === void 0) { context = null; } return visitor.visitPipe(this, context); }; return BindingPipe; }(AST)); var LiteralPrimitive = /** @class */ (function (_super) { Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(LiteralPrimitive, _super); function LiteralPrimitive(span, value) { var _this = _super.call(this, span) || this; _this.value = value; return _this; } LiteralPrimitive.prototype.visit = function (visitor, context) { if (context === void 0) { context = null; } return visitor.visitLiteralPrimitive(this, context); }; return LiteralPrimitive; }(AST)); var LiteralArray = /** @class */ (function (_super) { Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(LiteralArray, _super); function LiteralArray(span, expressions) { var _this = _super.call(this, span) || this; _this.expressions = expressions; return _this; } LiteralArray.prototype.visit = function (visitor, context) { if (context === void 0) { context = null; } return visitor.visitLiteralArray(this, context); }; return LiteralArray; }(AST)); var LiteralMap = /** @class */ (function (_super) { Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(LiteralMap, _super); function LiteralMap(span, keys, values) { var _this = _super.call(this, span) || this; _this.keys = keys; _this.values = values; return _this; } LiteralMap.prototype.visit = function (visitor, context) { if (context === void 0) { context = null; } return visitor.visitLiteralMap(this, context); }; return LiteralMap; }(AST)); var Interpolation = /** @class */ (function (_super) { Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Interpolation, _super); function Interpolation(span, strings, expressions) { var _this = _super.call(this, span) || this; _this.strings = strings; _this.expressions = expressions; return _this; } Interpolation.prototype.visit = function (visitor, context) { if (context === void 0) { context = null; } return visitor.visitInterpolation(this, context); }; return Interpolation; }(AST)); var Binary = /** @class */ (function (_super) { Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Binary, _super); function Binary(span, operation, left, right) { var _this = _super.call(this, span) || this; _this.operation = operation; _this.left = left; _this.right = right; return _this; } Binary.prototype.visit = function (visitor, context) { if (context === void 0) { context = null; } return visitor.visitBinary(this, context); }; return Binary; }(AST)); var PrefixNot = /** @class */ (function (_super) { Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(PrefixNot, _super); function PrefixNot(span, expression) { var _this = _super.call(this, span) || this; _this.expression = expression; return _this; } PrefixNot.prototype.visit = function (visitor, context) { if (context === void 0) { context = null; } return visitor.visitPrefixNot(this, context); }; return PrefixNot; }(AST)); var NonNullAssert = /** @class */ (function (_super) { Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(NonNullAssert, _super); function NonNullAssert(span, expression) { var _this = _super.call(this, span) || this; _this.expression = expression; return _this; } NonNullAssert.prototype.visit = function (visitor, context) { if (context === void 0) { context = null; } return visitor.visitNonNullAssert(this, context); }; return NonNullAssert; }(AST)); var MethodCall = /** @class */ (function (_super) { Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(MethodCall, _super); function MethodCall(span, receiver, name, args) { var _this = _super.call(this, span) || this; _this.receiver = receiver; _this.name = name; _this.args = args; return _this; } MethodCall.prototype.visit = function (visitor, context) { if (context === void 0) { context = null; } return visitor.visitMethodCall(this, context); }; return MethodCall; }(AST)); var SafeMethodCall = /** @class */ (function (_super) { Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(SafeMethodCall, _super); function SafeMethodCall(span, receiver, name, args) { var _this = _super.call(this, span) || this; _this.receiver = receiver; _this.name = name; _this.args = args; return _this; } SafeMethodCall.prototype.visit = function (visitor, context) { if (context === void 0) { context = null; } return visitor.visitSafeMethodCall(this, context); }; return SafeMethodCall; }(AST)); var FunctionCall = /** @class */ (function (_super) { Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(FunctionCall, _super); function FunctionCall(span, target, args) { var _this = _super.call(this, span) || this; _this.target = target; _this.args = args; return _this; } FunctionCall.prototype.visit = function (visitor, context) { if (context === void 0) { context = null; } return visitor.visitFunctionCall(this, context); }; return FunctionCall; }(AST)); var ASTWithSource = /** @class */ (function (_super) { Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(ASTWithSource, _super); function ASTWithSource(ast, source, location, errors) { var _this = _super.call(this, new ParseSpan(0, source == null ? 0 : source.length)) || this; _this.ast = ast; _this.source = source; _this.location = location; _this.errors = errors; return _this; } ASTWithSource.prototype.visit = function (visitor, context) { if (context === void 0) { context = null; } return this.ast.visit(visitor, context); }; ASTWithSource.prototype.toString = function () { return this.source + " in " + this.location; }; return ASTWithSource; }(AST)); var TemplateBinding = /** @class */ (function () { function TemplateBinding(span, key, keyIsVar, name, expression) { this.span = span; this.key = key; this.keyIsVar = keyIsVar; this.name = name; this.expression = expression; } return TemplateBinding; }()); var NullAstVisitor = /** @class */ (function () { function NullAstVisitor() { } NullAstVisitor.prototype.visitBinary = function (ast, context) { }; NullAstVisitor.prototype.visitChain = function (ast, context) { }; NullAstVisitor.prototype.visitConditional = function (ast, context) { }; NullAstVisitor.prototype.visitFunctionCall = function (ast, context) { }; NullAstVisitor.prototype.visitImplicitReceiver = function (ast, context) { }; NullAstVisitor.prototype.visitInterpolation = function (ast, context) { }; NullAstVisitor.prototype.visitKeyedRead = function (ast, context) { }; NullAstVisitor.prototype.visitKeyedWrite = function (ast, context) { }; NullAstVisitor.prototype.visitLiteralArray = function (ast, context) { }; NullAstVisitor.prototype.visitLiteralMap = function (ast, context) { }; NullAstVisitor.prototype.visitLiteralPrimitive = function (ast, context) { }; NullAstVisitor.prototype.visitMethodCall = function (ast, context) { }; NullAstVisitor.prototype.visitPipe = function (ast, context) { }; NullAstVisitor.prototype.visitPrefixNot = function (ast, context) { }; NullAstVisitor.prototype.visitNonNullAssert = function (ast, context) { }; NullAstVisitor.prototype.visitPropertyRead = function (ast, context) { }; NullAstVisitor.prototype.visitPropertyWrite = function (ast, context) { }; NullAstVisitor.prototype.visitQuote = function (ast, context) { }; NullAstVisitor.prototype.visitSafeMethodCall = function (ast, context) { }; NullAstVisitor.prototype.visitSafePropertyRead = function (ast, context) { }; return NullAstVisitor; }()); var RecursiveAstVisitor$1 = /** @class */ (function () { function RecursiveAstVisitor() { } RecursiveAstVisitor.prototype.visitBinary = function (ast, context) { ast.left.visit(this); ast.right.visit(this); return null; }; RecursiveAstVisitor.prototype.visitChain = function (ast, context) { return this.visitAll(ast.expressions, context); }; RecursiveAstVisitor.prototype.visitConditional = function (ast, context) { ast.condition.visit(this); ast.trueExp.visit(this); ast.falseExp.visit(this); return null; }; RecursiveAstVisitor.prototype.visitPipe = function (ast, context) { ast.exp.visit(this); this.visitAll(ast.args, context); return null; }; RecursiveAstVisitor.prototype.visitFunctionCall = function (ast, context) { ast.target.visit(this); this.visitAll(ast.args, context); return null; }; RecursiveAstVisitor.prototype.visitImplicitReceiver = function (ast, context) { return null; }; RecursiveAstVisitor.prototype.visitInterpolation = function (ast, context) { return this.visitAll(ast.expressions, context); }; RecursiveAstVisitor.prototype.visitKeyedRead = function (ast, context) { ast.obj.visit(this); ast.key.visit(this); return null; }; RecursiveAstVisitor.prototype.visitKeyedWrite = function (ast, context) { ast.obj.visit(this); ast.key.visit(this); ast.value.visit(this); return null; }; RecursiveAstVisitor.prototype.visitLiteralArray = function (ast, context) { return this.visitAll(ast.expressions, context); }; RecursiveAstVisitor.prototype.visitLiteralMap = function (ast, context) { return this.visitAll(ast.values, context); }; RecursiveAstVisitor.prototype.visitLiteralPrimitive = function (ast, context) { return null; }; RecursiveAstVisitor.prototype.visitMethodCall = function (ast, context) { ast.receiver.visit(this); return this.visitAll(ast.args, context); }; RecursiveAstVisitor.prototype.visitPrefixNot = function (ast, context) { ast.expression.visit(this); return null; }; RecursiveAstVisitor.prototype.visitNonNullAssert = function (ast, context) { ast.expression.visit(this); return null; }; RecursiveAstVisitor.prototype.visitPropertyRead = function (ast, context) { ast.receiver.visit(this); return null; }; RecursiveAstVisitor.prototype.visitPropertyWrite = function (ast, context) { ast.receiver.visit(this); ast.value.visit(this); return null; }; RecursiveAstVisitor.prototype.visitSafePropertyRead = function (ast, context) { ast.receiver.visit(this); return null; }; RecursiveAstVisitor.prototype.visitSafeMethodCall = function (ast, context) { ast.receiver.visit(this); return this.visitAll(ast.args, context); }; RecursiveAstVisitor.prototype.visitAll = function (asts, context) { var _this = this; asts.forEach(function (ast) { return ast.visit(_this, context); }); return null; }; RecursiveAstVisitor.prototype.visitQuote = function (ast, context) { return null; }; return RecursiveAstVisitor; }()); var AstTransformer$1 = /** @class */ (function () { function AstTransformer() { } AstTransformer.prototype.visitImplicitReceiver = function (ast, context) { return ast; }; AstTransformer.prototype.visitInterpolation = function (ast, context) { return new Interpolation(ast.span, ast.strings, this.visitAll(ast.expressions)); }; AstTransformer.prototype.visitLiteralPrimitive = function (ast, context) { return new LiteralPrimitive(ast.span, ast.value); }; AstTransformer.prototype.visitPropertyRead = function (ast, context) { return new PropertyRead(ast.span, ast.receiver.visit(this), ast.name); }; AstTransformer.prototype.visitPropertyWrite = function (ast, context) { return new PropertyWrite(ast.span, ast.receiver.visit(this), ast.name, ast.value.visit(this)); }; AstTransformer.prototype.visitSafePropertyRead = function (ast, context) { return new SafePropertyRead(ast.span, ast.receiver.visit(this), ast.name); }; AstTransformer.prototype.visitMethodCall = function (ast, context) { return new MethodCall(ast.span, ast.receiver.visit(this), ast.name, this.visitAll(ast.args)); }; AstTransformer.prototype.visitSafeMethodCall = function (ast, context) { return new SafeMethodCall(ast.span, ast.receiver.visit(this), ast.name, this.visitAll(ast.args)); }; AstTransformer.prototype.visitFunctionCall = function (ast, context) { return new FunctionCall(ast.span, ast.target.visit(this), this.visitAll(ast.args)); }; AstTransformer.prototype.visitLiteralArray = function (ast, context) { return new LiteralArray(ast.span, this.visitAll(ast.expressions)); }; AstTransformer.prototype.visitLiteralMap = function (ast, context) { return new LiteralMap(ast.span, ast.keys, this.visitAll(ast.values)); }; AstTransformer.prototype.visitBinary = function (ast, context) { return new Binary(ast.span, ast.operation, ast.left.visit(this), ast.right.visit(this)); }; AstTransformer.prototype.visitPrefixNot = function (ast, context) { return new PrefixNot(ast.span, ast.expression.visit(this)); }; AstTransformer.prototype.visitNonNullAssert = function (ast, context) { return new NonNullAssert(ast.span, ast.expression.visit(this)); }; AstTransformer.prototype.visitConditional = function (ast, context) { return new Conditional(ast.span, ast.condition.visit(this), ast.trueExp.visit(this), ast.falseExp.visit(this)); }; AstTransformer.prototype.visitPipe = function (ast, context) { return new BindingPipe(ast.span, ast.exp.visit(this), ast.name, this.visitAll(ast.args)); }; AstTransformer.prototype.visitKeyedRead = function (ast, context) { return new KeyedRead(ast.span, ast.obj.visit(this), ast.key.visit(this)); }; AstTransformer.prototype.visitKeyedWrite = function (ast, context) { return new KeyedWrite(ast.span, ast.obj.visit(this), ast.key.visit(this), ast.value.visit(this)); }; AstTransformer.prototype.visitAll = function (asts) { var res = new Array(asts.length); for (var i = 0; i < asts.length; ++i) { res[i] = asts[i].visit(this); } return res; }; AstTransformer.prototype.visitChain = function (ast, context) { return new Chain(ast.span, this.visitAll(ast.expressions)); }; AstTransformer.prototype.visitQuote = function (ast, context) { return new Quote(ast.span, ast.prefix, ast.uninterpretedExpression, ast.location); }; return AstTransformer; }()); // A transformer that only creates new nodes if the transformer makes a change or // a change is made a child node. var AstMemoryEfficientTransformer = /** @class */ (function () { function AstMemoryEfficientTransformer() { } AstMemoryEfficientTransformer.prototype.visitImplicitReceiver = function (ast, context) { return ast; }; AstMemoryEfficientTransformer.prototype.visitInterpolation = function (ast, context) { var expressions = this.visitAll(ast.expressions); if (expressions !== ast.expressions) return new Interpolation(ast.span, ast.strings, expressions); return ast; }; AstMemoryEfficientTransformer.prototype.visitLiteralPrimitive = function (ast, context) { return ast; }; AstMemoryEfficientTransformer.prototype.visitPropertyRead = function (ast, context) { var receiver = ast.receiver.visit(this); if (receiver !== ast.receiver) { return new PropertyRead(ast.span, receiver, ast.name); } return ast; }; AstMemoryEfficientTransformer.prototype.visitPropertyWrite = function (ast, context) { var receiver = ast.receiver.visit(this); var value = ast.value.visit(this); if (receiver !== ast.receiver || value !== ast.value) { return new PropertyWrite(ast.span, receiver, ast.name, value); } return ast; }; AstMemoryEfficientTransformer.prototype.visitSafePropertyRead = function (ast, context) { var receiver = ast.receiver.visit(this); if (receiver !== ast.receiver) { return new SafePropertyRead(ast.span, receiver, ast.name); } return ast; }; AstMemoryEfficientTransformer.prototype.visitMethodCall = function (ast, context) { var receiver = ast.receiver.visit(this); if (receiver !== ast.receiver) { return new MethodCall(ast.span, receiver, ast.name, this.visitAll(ast.args)); } return ast; }; AstMemoryEfficientTransformer.prototype.visitSafeMethodCall = function (ast, context) { var receiver = ast.receiver.visit(this); var args = this.visitAll(ast.args); if (receiver !== ast.receiver || args !== ast.args) { return new SafeMethodCall(ast.span, receiver, ast.name, args); } return ast; }; AstMemoryEfficientTransformer.prototype.visitFunctionCall = function (ast, context) { var target = ast.target && ast.target.visit(this); var args = this.visitAll(ast.args); if (target !== ast.target || args !== ast.args) { return new FunctionCall(ast.span, target, args); } return ast; }; AstMemoryEfficientTransformer.prototype.visitLiteralArray = function (ast, context) { var expressions = this.visitAll(ast.expressions); if (expressions !== ast.expressions) { return new LiteralArray(ast.span, expressions); } return ast; }; AstMemoryEfficientTransformer.prototype.visitLiteralMap = function (ast, context) { var values = this.visitAll(ast.values); if (values !== ast.values) { return new LiteralMap(ast.span, ast.keys, values); } return ast; }; AstMemoryEfficientTransformer.prototype.visitBinary = function (ast, context) { var left = ast.left.visit(this); var right = ast.right.visit(this); if (left !== ast.left || right !== ast.right) { return new Binary(ast.span, ast.operation, left, right); } return ast; }; AstMemoryEfficientTransformer.prototype.visitPrefixNot = function (ast, context) { var expression = ast.expression.visit(this); if (expression !== ast.expression) { return new PrefixNot(ast.span, expression); } return ast; }; AstMemoryEfficientTransformer.prototype.visitNonNullAssert = function (ast, context) { var expression = ast.expression.visit(this); if (expression !== ast.expression) { return new NonNullAssert(ast.span, expression); } return ast; }; AstMemoryEfficientTransformer.prototype.visitConditional = function (ast, context) { var condition = ast.condition.visit(this); var trueExp = ast.trueExp.visit(this); var falseExp = ast.falseExp.visit(this); if (condition !== ast.condition || trueExp !== ast.trueExp || falseExp !== falseExp) { return new Conditional(ast.span, condition, trueExp, falseExp); } return ast; }; AstMemoryEfficientTransformer.prototype.visitPipe = function (ast, context) { var exp = ast.exp.visit(this); var args = this.visitAll(ast.args); if (exp !== ast.exp || args !== ast.args) { return new BindingPipe(ast.span, exp, ast.name, args); } return ast; }; AstMemoryEfficientTransformer.prototype.visitKeyedRead = function (ast, context) { var obj = ast.obj.visit(this); var key = ast.key.visit(this); if (obj !== ast.obj || key !== ast.key) { return new KeyedRead(ast.span, obj, key); } return ast; }; AstMemoryEfficientTransformer.prototype.visitKeyedWrite = function (ast, context) { var obj = ast.obj.visit(this); var key = ast.key.visit(this); var value = ast.value.visit(this); if (obj !== ast.obj || key !== ast.key || value !== ast.value) { return new KeyedWrite(ast.span, obj, key, value); } return ast; }; AstMemoryEfficientTransformer.prototype.visitAll = function (asts) { var res = new Array(asts.length); var modified = false; for (var i = 0; i < asts.length; ++i) { var original = asts[i]; var value = original.visit(this); res[i] = value; modified = modified || value !== original; } return modified ? res : asts; }; AstMemoryEfficientTransformer.prototype.visitChain = function (ast, context) { var expressions = this.visitAll(ast.expressions); if (expressions !== ast.expressions) { return new Chain(ast.span, expressions); } return ast; }; AstMemoryEfficientTransformer.prototype.visitQuote = function (ast, context) { return ast; }; return AstMemoryEfficientTransformer; }()); function visitAstChildren(ast, visitor, context) { function visit(ast) { visitor.visit && visitor.visit(ast, context) || ast.visit(visitor, context); } function visitAll(asts) { asts.forEach(visit); } ast.visit({ visitBinary: function (ast) { visit(ast.left); visit(ast.right); }, visitChain: function (ast) { visitAll(ast.expressions); }, visitConditional: function (ast) { visit(ast.condition); visit(ast.trueExp); visit(ast.falseExp); }, visitFunctionCall: function (ast) { if (ast.target) { visit(ast.target); } visitAll(ast.args); }, visitImplicitReceiver: function (ast) { }, visitInterpolation: function (ast) { visitAll(ast.expressions); }, visitKeyedRead: function (ast) { visit(ast.obj); visit(ast.key); }, visitKeyedWrite: function (ast) { visit(ast.obj); visit(ast.key); visit(ast.obj); }, visitLiteralArray: function (ast) { visitAll(ast.expressions); }, visitLiteralMap: function (ast) { }, visitLiteralPrimitive: function (ast) { }, visitMethodCall: function (ast) { visit(ast.receiver); visitAll(ast.args); }, visitPipe: function (ast) { visit(ast.exp); visitAll(ast.args); }, visitPrefixNot: function (ast) { visit(ast.expression); }, visitNonNullAssert: function (ast) { visit(ast.expression); }, visitPropertyRead: function (ast) { visit(ast.receiver); }, visitPropertyWrite: function (ast) { visit(ast.receiver); visit(ast.value); }, visitQuote: function (ast) { }, visitSafeMethodCall: function (ast) { visit(ast.receiver); visitAll(ast.args); }, visitSafePropertyRead: function (ast) { visit(ast.receiver); }, }); } // Bindings var ParsedProperty = /** @class */ (function () { function ParsedProperty(name, expression, type, sourceSpan) { this.name = name; this.expression = expression; this.type = type; this.sourceSpan = sourceSpan; this.isLiteral = this.type === ParsedPropertyType.LITERAL_ATTR; this.isAnimation = this.type === ParsedPropertyType.ANIMATION; } return ParsedProperty; }()); var ParsedPropertyType; (function (ParsedPropertyType) { ParsedPropertyType[ParsedPropertyType["DEFAULT"] = 0] = "DEFAULT"; ParsedPropertyType[ParsedPropertyType["LITERAL_ATTR"] = 1] = "LITERAL_ATTR"; ParsedPropertyType[ParsedPropertyType["ANIMATION"] = 2] = "ANIMATION"; })(ParsedPropertyType || (ParsedPropertyType = {})); var ParsedEvent = /** @class */ (function () { // Regular events have a target // Animation events have a phase function ParsedEvent(name, targetOrPhase, type, handler, sourceSpan) { this.name = name; this.targetOrPhase = targetOrPhase; this.type = type; this.handler = handler; this.sourceSpan = sourceSpan; } return ParsedEvent; }()); var ParsedVariable = /** @class */ (function () { function ParsedVariable(name, value, sourceSpan) { this.name = name; this.value = value; this.sourceSpan = sourceSpan; } return ParsedVariable; }()); var BoundElementProperty = /** @class */ (function () { function BoundElementProperty(name, type, securityContext, value, unit, sourceSpan) { this.name = name; this.type = type; this.securityContext = securityContext; this.value = value; this.unit = unit; this.sourceSpan = sourceSpan; } return BoundElementProperty; }()); /** * @license * Copyright Google Inc. All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ var EventHandlerVars = /** @class */ (function () { function EventHandlerVars() { } EventHandlerVars.event = variable('$event'); return EventHandlerVars; }()); var ConvertActionBindingResult = /** @class */ (function () { function ConvertActionBindingResult( /** * Render2 compatible statements, */ stmts, /** * Variable name used with render2 compatible statements. */ allowDefault) { this.stmts = stmts; this.allowDefault = allowDefault; /** * This is bit of a hack. It converts statements which render2 expects to statements which are * expected by render3. * * Example: `
    ` will generate: * * Render3: * ``` * const pd_b:any = ((ctx.doSomething($event)) !== false); * return pd_b; * ``` * * but render2 expects: * ``` * return ctx.doSomething($event); * ``` */ // TODO(misko): remove this hack once we no longer support ViewEngine. this.render3Stmts = stmts.map(function (statement) { if (statement instanceof DeclareVarStmt && statement.name == allowDefault.name && statement.value instanceof BinaryOperatorExpr) { var lhs = statement.value.lhs; return new ReturnStatement(lhs.value); } return statement; }); } return ConvertActionBindingResult; }()); /** * Converts the given expression AST into an executable output AST, assuming the expression is * used in an action binding (e.g. an event handler). */ function convertActionBinding(localResolver, implicitReceiver, action, bindingId, interpolationFunction) { if (!localResolver) { localResolver = new DefaultLocalResolver(); } var actionWithoutBuiltins = convertPropertyBindingBuiltins({ createLiteralArrayConverter: function (argCount) { // Note: no caching for literal arrays in actions. return function (args) { return literalArr(args); }; }, createLiteralMapConverter: function (keys) { // Note: no caching for literal maps in actions. return function (values) { var entries = keys.map(function (k, i) { return ({ key: k.key, value: values[i], quoted: k.quoted, }); }); return literalMap(entries); }; }, createPipeConverter: function (name) { throw new Error("Illegal State: Actions are not allowed to contain pipes. Pipe: " + name); } }, action); var visitor = new _AstToIrVisitor(localResolver, implicitReceiver, bindingId, interpolationFunction); var actionStmts = []; flattenStatements(actionWithoutBuiltins.visit(visitor, _Mode.Statement), actionStmts); prependTemporaryDecls(visitor.temporaryCount, bindingId, actionStmts); var lastIndex = actionStmts.length - 1; var preventDefaultVar = null; if (lastIndex >= 0) { var lastStatement = actionStmts[lastIndex]; var returnExpr = convertStmtIntoExpression(lastStatement); if (returnExpr) { // Note: We need to cast the result of the method call to dynamic, // as it might be a void method! preventDefaultVar = createPreventDefaultVar(bindingId); actionStmts[lastIndex] = preventDefaultVar.set(returnExpr.cast(DYNAMIC_TYPE).notIdentical(literal(false))) .toDeclStmt(null, [StmtModifier.Final]); } } return new ConvertActionBindingResult(actionStmts, preventDefaultVar); } function convertPropertyBindingBuiltins(converterFactory, ast) { return convertBuiltins(converterFactory, ast); } var ConvertPropertyBindingResult = /** @class */ (function () { function ConvertPropertyBindingResult(stmts, currValExpr) { this.stmts = stmts; this.currValExpr = currValExpr; } return ConvertPropertyBindingResult; }()); var BindingForm; (function (BindingForm) { // The general form of binding expression, supports all expressions. BindingForm[BindingForm["General"] = 0] = "General"; // Try to generate a simple binding (no temporaries or statements) // otherwise generate a general binding BindingForm[BindingForm["TrySimple"] = 1] = "TrySimple"; })(BindingForm || (BindingForm = {})); /** * Converts the given expression AST into an executable output AST, assuming the expression * is used in property binding. The expression has to be preprocessed via * `convertPropertyBindingBuiltins`. */ function convertPropertyBinding(localResolver, implicitReceiver, expressionWithoutBuiltins, bindingId, form, interpolationFunction) { if (!localResolver) { localResolver = new DefaultLocalResolver(); } var currValExpr = createCurrValueExpr(bindingId); var stmts = []; var visitor = new _AstToIrVisitor(localResolver, implicitReceiver, bindingId, interpolationFunction); var outputExpr = expressionWithoutBuiltins.visit(visitor, _Mode.Expression); if (visitor.temporaryCount) { for (var i = 0; i < visitor.temporaryCount; i++) { stmts.push(temporaryDeclaration(bindingId, i)); } } else if (form == BindingForm.TrySimple) { return new ConvertPropertyBindingResult([], outputExpr); } stmts.push(currValExpr.set(outputExpr).toDeclStmt(DYNAMIC_TYPE, [StmtModifier.Final])); return new ConvertPropertyBindingResult(stmts, currValExpr); } function convertBuiltins(converterFactory, ast) { var visitor = new _BuiltinAstConverter(converterFactory); return ast.visit(visitor); } function temporaryName(bindingId, temporaryNumber) { return "tmp_" + bindingId + "_" + temporaryNumber; } function temporaryDeclaration(bindingId, temporaryNumber) { return new DeclareVarStmt(temporaryName(bindingId, temporaryNumber), NULL_EXPR); } function prependTemporaryDecls(temporaryCount, bindingId, statements) { for (var i = temporaryCount - 1; i >= 0; i--) { statements.unshift(temporaryDeclaration(bindingId, i)); } } var _Mode; (function (_Mode) { _Mode[_Mode["Statement"] = 0] = "Statement"; _Mode[_Mode["Expression"] = 1] = "Expression"; })(_Mode || (_Mode = {})); function ensureStatementMode(mode, ast) { if (mode !== _Mode.Statement) { throw new Error("Expected a statement, but saw " + ast); } } function ensureExpressionMode(mode, ast) { if (mode !== _Mode.Expression) { throw new Error("Expected an expression, but saw " + ast); } } function convertToStatementIfNeeded(mode, expr) { if (mode === _Mode.Statement) { return expr.toStmt(); } else { return expr; } } var _BuiltinAstConverter = /** @class */ (function (_super) { Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(_BuiltinAstConverter, _super); function _BuiltinAstConverter(_converterFactory) { var _this = _super.call(this) || this; _this._converterFactory = _converterFactory; return _this; } _BuiltinAstConverter.prototype.visitPipe = function (ast, context) { var _this = this; var args = Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__spread"])([ast.exp], ast.args).map(function (ast) { return ast.visit(_this, context); }); return new BuiltinFunctionCall(ast.span, args, this._converterFactory.createPipeConverter(ast.name, args.length)); }; _BuiltinAstConverter.prototype.visitLiteralArray = function (ast, context) { var _this = this; var args = ast.expressions.map(function (ast) { return ast.visit(_this, context); }); return new BuiltinFunctionCall(ast.span, args, this._converterFactory.createLiteralArrayConverter(ast.expressions.length)); }; _BuiltinAstConverter.prototype.visitLiteralMap = function (ast, context) { var _this = this; var args = ast.values.map(function (ast) { return ast.visit(_this, context); }); return new BuiltinFunctionCall(ast.span, args, this._converterFactory.createLiteralMapConverter(ast.keys)); }; return _BuiltinAstConverter; }(AstTransformer$1)); var _AstToIrVisitor = /** @class */ (function () { function _AstToIrVisitor(_localResolver, _implicitReceiver, bindingId, interpolationFunction) { this._localResolver = _localResolver; this._implicitReceiver = _implicitReceiver; this.bindingId = bindingId; this.interpolationFunction = interpolationFunction; this._nodeMap = new Map(); this._resultMap = new Map(); this._currentTemporary = 0; this.temporaryCount = 0; } _AstToIrVisitor.prototype.visitBinary = function (ast, mode) { var op; switch (ast.operation) { case '+': op = BinaryOperator.Plus; break; case '-': op = BinaryOperator.Minus; break; case '*': op = BinaryOperator.Multiply; break; case '/': op = BinaryOperator.Divide; break; case '%': op = BinaryOperator.Modulo; break; case '&&': op = BinaryOperator.And; break; case '||': op = BinaryOperator.Or; break; case '==': op = BinaryOperator.Equals; break; case '!=': op = BinaryOperator.NotEquals; break; case '===': op = BinaryOperator.Identical; break; case '!==': op = BinaryOperator.NotIdentical; break; case '<': op = BinaryOperator.Lower; break; case '>': op = BinaryOperator.Bigger; break; case '<=': op = BinaryOperator.LowerEquals; break; case '>=': op = BinaryOperator.BiggerEquals; break; default: throw new Error("Unsupported operation " + ast.operation); } return convertToStatementIfNeeded(mode, new BinaryOperatorExpr(op, this._visit(ast.left, _Mode.Expression), this._visit(ast.right, _Mode.Expression))); }; _AstToIrVisitor.prototype.visitChain = function (ast, mode) { ensureStatementMode(mode, ast); return this.visitAll(ast.expressions, mode); }; _AstToIrVisitor.prototype.visitConditional = function (ast, mode) { var value = this._visit(ast.condition, _Mode.Expression); return convertToStatementIfNeeded(mode, value.conditional(this._visit(ast.trueExp, _Mode.Expression), this._visit(ast.falseExp, _Mode.Expression))); }; _AstToIrVisitor.prototype.visitPipe = function (ast, mode) { throw new Error("Illegal state: Pipes should have been converted into functions. Pipe: " + ast.name); }; _AstToIrVisitor.prototype.visitFunctionCall = function (ast, mode) { var convertedArgs = this.visitAll(ast.args, _Mode.Expression); var fnResult; if (ast instanceof BuiltinFunctionCall) { fnResult = ast.converter(convertedArgs); } else { fnResult = this._visit(ast.target, _Mode.Expression).callFn(convertedArgs); } return convertToStatementIfNeeded(mode, fnResult); }; _AstToIrVisitor.prototype.visitImplicitReceiver = function (ast, mode) { ensureExpressionMode(mode, ast); return this._implicitReceiver; }; _AstToIrVisitor.prototype.visitInterpolation = function (ast, mode) { ensureExpressionMode(mode, ast); var args = [literal(ast.expressions.length)]; for (var i = 0; i < ast.strings.length - 1; i++) { args.push(literal(ast.strings[i])); args.push(this._visit(ast.expressions[i], _Mode.Expression)); } args.push(literal(ast.strings[ast.strings.length - 1])); if (this.interpolationFunction) { return this.interpolationFunction(args); } return ast.expressions.length <= 9 ? importExpr(Identifiers.inlineInterpolate).callFn(args) : importExpr(Identifiers.interpolate).callFn([args[0], literalArr(args.slice(1))]); }; _AstToIrVisitor.prototype.visitKeyedRead = function (ast, mode) { var leftMostSafe = this.leftMostSafeNode(ast); if (leftMostSafe) { return this.convertSafeAccess(ast, leftMostSafe, mode); } else { return convertToStatementIfNeeded(mode, this._visit(ast.obj, _Mode.Expression).key(this._visit(ast.key, _Mode.Expression))); } }; _AstToIrVisitor.prototype.visitKeyedWrite = function (ast, mode) { var obj = this._visit(ast.obj, _Mode.Expression); var key = this._visit(ast.key, _Mode.Expression); var value = this._visit(ast.value, _Mode.Expression); return convertToStatementIfNeeded(mode, obj.key(key).set(value)); }; _AstToIrVisitor.prototype.visitLiteralArray = function (ast, mode) { throw new Error("Illegal State: literal arrays should have been converted into functions"); }; _AstToIrVisitor.prototype.visitLiteralMap = function (ast, mode) { throw new Error("Illegal State: literal maps should have been converted into functions"); }; _AstToIrVisitor.prototype.visitLiteralPrimitive = function (ast, mode) { // For literal values of null, undefined, true, or false allow type interference // to infer the type. var type = ast.value === null || ast.value === undefined || ast.value === true || ast.value === true ? INFERRED_TYPE : undefined; return convertToStatementIfNeeded(mode, literal(ast.value, type)); }; _AstToIrVisitor.prototype._getLocal = function (name) { return this._localResolver.getLocal(name); }; _AstToIrVisitor.prototype.visitMethodCall = function (ast, mode) { if (ast.receiver instanceof ImplicitReceiver && ast.name == '$any') { var args = this.visitAll(ast.args, _Mode.Expression); if (args.length != 1) { throw new Error("Invalid call to $any, expected 1 argument but received " + (args.length || 'none')); } return args[0].cast(DYNAMIC_TYPE); } var leftMostSafe = this.leftMostSafeNode(ast); if (leftMostSafe) { return this.convertSafeAccess(ast, leftMostSafe, mode); } else { var args = this.visitAll(ast.args, _Mode.Expression); var result = null; var receiver = this._visit(ast.receiver, _Mode.Expression); if (receiver === this._implicitReceiver) { var varExpr = this._getLocal(ast.name); if (varExpr) { result = varExpr.callFn(args); } } if (result == null) { result = receiver.callMethod(ast.name, args); } return convertToStatementIfNeeded(mode, result); } }; _AstToIrVisitor.prototype.visitPrefixNot = function (ast, mode) { return convertToStatementIfNeeded(mode, not(this._visit(ast.expression, _Mode.Expression))); }; _AstToIrVisitor.prototype.visitNonNullAssert = function (ast, mode) { return convertToStatementIfNeeded(mode, assertNotNull(this._visit(ast.expression, _Mode.Expression))); }; _AstToIrVisitor.prototype.visitPropertyRead = function (ast, mode) { var leftMostSafe = this.leftMostSafeNode(ast); if (leftMostSafe) { return this.convertSafeAccess(ast, leftMostSafe, mode); } else { var result = null; var receiver = this._visit(ast.receiver, _Mode.Expression); if (receiver === this._implicitReceiver) { result = this._getLocal(ast.name); } if (result == null) { result = receiver.prop(ast.name); } return convertToStatementIfNeeded(mode, result); } }; _AstToIrVisitor.prototype.visitPropertyWrite = function (ast, mode) { var receiver = this._visit(ast.receiver, _Mode.Expression); var varExpr = null; if (receiver === this._implicitReceiver) { var localExpr = this._getLocal(ast.name); if (localExpr) { if (localExpr instanceof ReadPropExpr) { // If the local variable is a property read expression, it's a reference // to a 'context.property' value and will be used as the target of the // write expression. varExpr = localExpr; } else { // Otherwise it's an error. throw new Error('Cannot assign to a reference or variable!'); } } } // If no local expression could be produced, use the original receiver's // property as the target. if (varExpr === null) { varExpr = receiver.prop(ast.name); } return convertToStatementIfNeeded(mode, varExpr.set(this._visit(ast.value, _Mode.Expression))); }; _AstToIrVisitor.prototype.visitSafePropertyRead = function (ast, mode) { return this.convertSafeAccess(ast, this.leftMostSafeNode(ast), mode); }; _AstToIrVisitor.prototype.visitSafeMethodCall = function (ast, mode) { return this.convertSafeAccess(ast, this.leftMostSafeNode(ast), mode); }; _AstToIrVisitor.prototype.visitAll = function (asts, mode) { var _this = this; return asts.map(function (ast) { return _this._visit(ast, mode); }); }; _AstToIrVisitor.prototype.visitQuote = function (ast, mode) { throw new Error("Quotes are not supported for evaluation!\n Statement: " + ast.uninterpretedExpression + " located at " + ast.location); }; _AstToIrVisitor.prototype._visit = function (ast, mode) { var result = this._resultMap.get(ast); if (result) return result; return (this._nodeMap.get(ast) || ast).visit(this, mode); }; _AstToIrVisitor.prototype.convertSafeAccess = function (ast, leftMostSafe, mode) { // If the expression contains a safe access node on the left it needs to be converted to // an expression that guards the access to the member by checking the receiver for blank. As // execution proceeds from left to right, the left most part of the expression must be guarded // first but, because member access is left associative, the right side of the expression is at // the top of the AST. The desired result requires lifting a copy of the the left part of the // expression up to test it for blank before generating the unguarded version. // Consider, for example the following expression: a?.b.c?.d.e // This results in the ast: // . // / \ // ?. e // / \ // . d // / \ // ?. c // / \ // a b // The following tree should be generated: // // /---- ? ----\ // / | \ // a /--- ? ---\ null // / | \ // . . null // / \ / \ // . c . e // / \ / \ // a b , d // / \ // . c // / \ // a b // // Notice that the first guard condition is the left hand of the left most safe access node // which comes in as leftMostSafe to this routine. var guardedExpression = this._visit(leftMostSafe.receiver, _Mode.Expression); var temporary = undefined; if (this.needsTemporary(leftMostSafe.receiver)) { // If the expression has method calls or pipes then we need to save the result into a // temporary variable to avoid calling stateful or impure code more than once. temporary = this.allocateTemporary(); // Preserve the result in the temporary variable guardedExpression = temporary.set(guardedExpression); // Ensure all further references to the guarded expression refer to the temporary instead. this._resultMap.set(leftMostSafe.receiver, temporary); } var condition = guardedExpression.isBlank(); // Convert the ast to an unguarded access to the receiver's member. The map will substitute // leftMostNode with its unguarded version in the call to `this.visit()`. if (leftMostSafe instanceof SafeMethodCall) { this._nodeMap.set(leftMostSafe, new MethodCall(leftMostSafe.span, leftMostSafe.receiver, leftMostSafe.name, leftMostSafe.args)); } else { this._nodeMap.set(leftMostSafe, new PropertyRead(leftMostSafe.span, leftMostSafe.receiver, leftMostSafe.name)); } // Recursively convert the node now without the guarded member access. var access = this._visit(ast, _Mode.Expression); // Remove the mapping. This is not strictly required as the converter only traverses each node // once but is safer if the conversion is changed to traverse the nodes more than once. this._nodeMap.delete(leftMostSafe); // If we allocated a temporary, release it. if (temporary) { this.releaseTemporary(temporary); } // Produce the conditional return convertToStatementIfNeeded(mode, condition.conditional(literal(null), access)); }; // Given a expression of the form a?.b.c?.d.e the the left most safe node is // the (a?.b). The . and ?. are left associative thus can be rewritten as: // ((((a?.c).b).c)?.d).e. This returns the most deeply nested safe read or // safe method call as this needs be transform initially to: // a == null ? null : a.c.b.c?.d.e // then to: // a == null ? null : a.b.c == null ? null : a.b.c.d.e _AstToIrVisitor.prototype.leftMostSafeNode = function (ast) { var _this = this; var visit = function (visitor, ast) { return (_this._nodeMap.get(ast) || ast).visit(visitor); }; return ast.visit({ visitBinary: function (ast) { return null; }, visitChain: function (ast) { return null; }, visitConditional: function (ast) { return null; }, visitFunctionCall: function (ast) { return null; }, visitImplicitReceiver: function (ast) { return null; }, visitInterpolation: function (ast) { return null; }, visitKeyedRead: function (ast) { return visit(this, ast.obj); }, visitKeyedWrite: function (ast) { return null; }, visitLiteralArray: function (ast) { return null; }, visitLiteralMap: function (ast) { return null; }, visitLiteralPrimitive: function (ast) { return null; }, visitMethodCall: function (ast) { return visit(this, ast.receiver); }, visitPipe: function (ast) { return null; }, visitPrefixNot: function (ast) { return null; }, visitNonNullAssert: function (ast) { return null; }, visitPropertyRead: function (ast) { return visit(this, ast.receiver); }, visitPropertyWrite: function (ast) { return null; }, visitQuote: function (ast) { return null; }, visitSafeMethodCall: function (ast) { return visit(this, ast.receiver) || ast; }, visitSafePropertyRead: function (ast) { return visit(this, ast.receiver) || ast; } }); }; // Returns true of the AST includes a method or a pipe indicating that, if the // expression is used as the target of a safe property or method access then // the expression should be stored into a temporary variable. _AstToIrVisitor.prototype.needsTemporary = function (ast) { var _this = this; var visit = function (visitor, ast) { return ast && (_this._nodeMap.get(ast) || ast).visit(visitor); }; var visitSome = function (visitor, ast) { return ast.some(function (ast) { return visit(visitor, ast); }); }; return ast.visit({ visitBinary: function (ast) { return visit(this, ast.left) || visit(this, ast.right); }, visitChain: function (ast) { return false; }, visitConditional: function (ast) { return visit(this, ast.condition) || visit(this, ast.trueExp) || visit(this, ast.falseExp); }, visitFunctionCall: function (ast) { return true; }, visitImplicitReceiver: function (ast) { return false; }, visitInterpolation: function (ast) { return visitSome(this, ast.expressions); }, visitKeyedRead: function (ast) { return false; }, visitKeyedWrite: function (ast) { return false; }, visitLiteralArray: function (ast) { return true; }, visitLiteralMap: function (ast) { return true; }, visitLiteralPrimitive: function (ast) { return false; }, visitMethodCall: function (ast) { return true; }, visitPipe: function (ast) { return true; }, visitPrefixNot: function (ast) { return visit(this, ast.expression); }, visitNonNullAssert: function (ast) { return visit(this, ast.expression); }, visitPropertyRead: function (ast) { return false; }, visitPropertyWrite: function (ast) { return false; }, visitQuote: function (ast) { return false; }, visitSafeMethodCall: function (ast) { return true; }, visitSafePropertyRead: function (ast) { return false; } }); }; _AstToIrVisitor.prototype.allocateTemporary = function () { var tempNumber = this._currentTemporary++; this.temporaryCount = Math.max(this._currentTemporary, this.temporaryCount); return new ReadVarExpr(temporaryName(this.bindingId, tempNumber)); }; _AstToIrVisitor.prototype.releaseTemporary = function (temporary) { this._currentTemporary--; if (temporary.name != temporaryName(this.bindingId, this._currentTemporary)) { throw new Error("Temporary " + temporary.name + " released out of order"); } }; return _AstToIrVisitor; }()); function flattenStatements(arg, output) { if (Array.isArray(arg)) { arg.forEach(function (entry) { return flattenStatements(entry, output); }); } else { output.push(arg); } } var DefaultLocalResolver = /** @class */ (function () { function DefaultLocalResolver() { } DefaultLocalResolver.prototype.getLocal = function (name) { if (name === EventHandlerVars.event.name) { return EventHandlerVars.event; } return null; }; return DefaultLocalResolver; }()); function createCurrValueExpr(bindingId) { return variable("currVal_" + bindingId); // fix syntax highlighting: ` } function createPreventDefaultVar(bindingId) { return variable("pd_" + bindingId); } function convertStmtIntoExpression(stmt) { if (stmt instanceof ExpressionStatement) { return stmt.expr; } else if (stmt instanceof ReturnStatement) { return stmt.value; } return null; } var BuiltinFunctionCall = /** @class */ (function (_super) { Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(BuiltinFunctionCall, _super); function BuiltinFunctionCall(span, args, converter) { var _this = _super.call(this, span, null, args) || this; _this.args = args; _this.converter = converter; return _this; } return BuiltinFunctionCall; }(FunctionCall)); /** * @license * Copyright Google Inc. All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ var LifecycleHooks; (function (LifecycleHooks) { LifecycleHooks[LifecycleHooks["OnInit"] = 0] = "OnInit"; LifecycleHooks[LifecycleHooks["OnDestroy"] = 1] = "OnDestroy"; LifecycleHooks[LifecycleHooks["DoCheck"] = 2] = "DoCheck"; LifecycleHooks[LifecycleHooks["OnChanges"] = 3] = "OnChanges"; LifecycleHooks[LifecycleHooks["AfterContentInit"] = 4] = "AfterContentInit"; LifecycleHooks[LifecycleHooks["AfterContentChecked"] = 5] = "AfterContentChecked"; LifecycleHooks[LifecycleHooks["AfterViewInit"] = 6] = "AfterViewInit"; LifecycleHooks[LifecycleHooks["AfterViewChecked"] = 7] = "AfterViewChecked"; })(LifecycleHooks || (LifecycleHooks = {})); var LIFECYCLE_HOOKS_VALUES = [ LifecycleHooks.OnInit, LifecycleHooks.OnDestroy, LifecycleHooks.DoCheck, LifecycleHooks.OnChanges, LifecycleHooks.AfterContentInit, LifecycleHooks.AfterContentChecked, LifecycleHooks.AfterViewInit, LifecycleHooks.AfterViewChecked ]; function hasLifecycleHook(reflector, hook, token) { return reflector.hasLifecycleHook(token, getHookName(hook)); } function getAllLifecycleHooks(reflector, token) { return LIFECYCLE_HOOKS_VALUES.filter(function (hook) { return hasLifecycleHook(reflector, hook, token); }); } function getHookName(hook) { switch (hook) { case LifecycleHooks.OnInit: return 'ngOnInit'; case LifecycleHooks.OnDestroy: return 'ngOnDestroy'; case LifecycleHooks.DoCheck: return 'ngDoCheck'; case LifecycleHooks.OnChanges: return 'ngOnChanges'; case LifecycleHooks.AfterContentInit: return 'ngAfterContentInit'; case LifecycleHooks.AfterContentChecked: return 'ngAfterContentChecked'; case LifecycleHooks.AfterViewInit: return 'ngAfterViewInit'; case LifecycleHooks.AfterViewChecked: return 'ngAfterViewChecked'; default: // This default case is not needed by TypeScript compiler, as the switch is exhaustive. // However Closure Compiler does not understand that and reports an error in typed mode. // The `throw new Error` below works around the problem, and the unexpected: never variable // makes sure tsc still checks this code is unreachable. var unexpected = hook; throw new Error("unexpected " + unexpected); } } /** * @license * Copyright Google Inc. All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ var $EOF = 0; var $TAB = 9; var $LF = 10; var $VTAB = 11; var $FF = 12; var $CR = 13; var $SPACE = 32; var $BANG = 33; var $DQ = 34; var $HASH = 35; var $$ = 36; var $PERCENT = 37; var $AMPERSAND = 38; var $SQ = 39; var $LPAREN = 40; var $RPAREN = 41; var $STAR = 42; var $PLUS = 43; var $COMMA = 44; var $MINUS = 45; var $PERIOD = 46; var $SLASH = 47; var $COLON = 58; var $SEMICOLON = 59; var $LT = 60; var $EQ = 61; var $GT = 62; var $QUESTION = 63; var $0 = 48; var $9 = 57; var $A = 65; var $E = 69; var $F = 70; var $X = 88; var $Z = 90; var $LBRACKET = 91; var $BACKSLASH = 92; var $RBRACKET = 93; var $CARET = 94; var $_ = 95; var $a = 97; var $e = 101; var $f = 102; var $n = 110; var $r = 114; var $t = 116; var $u = 117; var $v = 118; var $x = 120; var $z = 122; var $LBRACE = 123; var $BAR = 124; var $RBRACE = 125; var $NBSP = 160; var $BT = 96; function isWhitespace(code) { return (code >= $TAB && code <= $SPACE) || (code == $NBSP); } function isDigit(code) { return $0 <= code && code <= $9; } function isAsciiLetter(code) { return code >= $a && code <= $z || code >= $A && code <= $Z; } function isAsciiHexDigit(code) { return code >= $a && code <= $f || code >= $A && code <= $F || isDigit(code); } /** * @license * Copyright Google Inc. All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ var ParseLocation = /** @class */ (function () { function ParseLocation(file, offset, line, col) { this.file = file; this.offset = offset; this.line = line; this.col = col; } ParseLocation.prototype.toString = function () { return this.offset != null ? this.file.url + "@" + this.line + ":" + this.col : this.file.url; }; ParseLocation.prototype.moveBy = function (delta) { var source = this.file.content; var len = source.length; var offset = this.offset; var line = this.line; var col = this.col; while (offset > 0 && delta < 0) { offset--; delta++; var ch = source.charCodeAt(offset); if (ch == $LF) { line--; var priorLine = source.substr(0, offset - 1).lastIndexOf(String.fromCharCode($LF)); col = priorLine > 0 ? offset - priorLine : offset; } else { col--; } } while (offset < len && delta > 0) { var ch = source.charCodeAt(offset); offset++; delta--; if (ch == $LF) { line++; col = 0; } else { col++; } } return new ParseLocation(this.file, offset, line, col); }; // Return the source around the location // Up to `maxChars` or `maxLines` on each side of the location ParseLocation.prototype.getContext = function (maxChars, maxLines) { var content = this.file.content; var startOffset = this.offset; if (startOffset != null) { if (startOffset > content.length - 1) { startOffset = content.length - 1; } var endOffset = startOffset; var ctxChars = 0; var ctxLines = 0; while (ctxChars < maxChars && startOffset > 0) { startOffset--; ctxChars++; if (content[startOffset] == '\n') { if (++ctxLines == maxLines) { break; } } } ctxChars = 0; ctxLines = 0; while (ctxChars < maxChars && endOffset < content.length - 1) { endOffset++; ctxChars++; if (content[endOffset] == '\n') { if (++ctxLines == maxLines) { break; } } } return { before: content.substring(startOffset, this.offset), after: content.substring(this.offset, endOffset + 1), }; } return null; }; return ParseLocation; }()); var ParseSourceFile = /** @class */ (function () { function ParseSourceFile(content, url) { this.content = content; this.url = url; } return ParseSourceFile; }()); var ParseSourceSpan = /** @class */ (function () { function ParseSourceSpan(start, end, details) { if (details === void 0) { details = null; } this.start = start; this.end = end; this.details = details; } ParseSourceSpan.prototype.toString = function () { return this.start.file.content.substring(this.start.offset, this.end.offset); }; return ParseSourceSpan; }()); var ParseErrorLevel; (function (ParseErrorLevel) { ParseErrorLevel[ParseErrorLevel["WARNING"] = 0] = "WARNING"; ParseErrorLevel[ParseErrorLevel["ERROR"] = 1] = "ERROR"; })(ParseErrorLevel || (ParseErrorLevel = {})); var ParseError = /** @class */ (function () { function ParseError(span, msg, level) { if (level === void 0) { level = ParseErrorLevel.ERROR; } this.span = span; this.msg = msg; this.level = level; } ParseError.prototype.contextualMessage = function () { var ctx = this.span.start.getContext(100, 3); return ctx ? this.msg + " (\"" + ctx.before + "[" + ParseErrorLevel[this.level] + " ->]" + ctx.after + "\")" : this.msg; }; ParseError.prototype.toString = function () { var details = this.span.details ? ", " + this.span.details : ''; return this.contextualMessage() + ": " + this.span.start + details; }; return ParseError; }()); function typeSourceSpan(kind, type) { var moduleUrl = identifierModuleUrl(type); var sourceFileName = moduleUrl != null ? "in " + kind + " " + identifierName(type) + " in " + moduleUrl : "in " + kind + " " + identifierName(type); var sourceFile = new ParseSourceFile('', sourceFileName); return new ParseSourceSpan(new ParseLocation(sourceFile, -1, -1, -1), new ParseLocation(sourceFile, -1, -1, -1)); } /** * @license * Copyright Google Inc. All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ /** * This file is a port of shadowCSS from webcomponents.js to TypeScript. * * Please make sure to keep to edits in sync with the source file. * * Source: * https://github.com/webcomponents/webcomponentsjs/blob/4efecd7e0e/src/ShadowCSS/ShadowCSS.js * * The original file level comment is reproduced below */ /* This is a limited shim for ShadowDOM css styling. https://dvcs.w3.org/hg/webcomponents/raw-file/tip/spec/shadow/index.html#styles The intention here is to support only the styling features which can be relatively simply implemented. The goal is to allow users to avoid the most obvious pitfalls and do so without compromising performance significantly. For ShadowDOM styling that's not covered here, a set of best practices can be provided that should allow users to accomplish more complex styling. The following is a list of specific ShadowDOM styling features and a brief discussion of the approach used to shim. Shimmed features: * :host, :host-context: ShadowDOM allows styling of the shadowRoot's host element using the :host rule. To shim this feature, the :host styles are reformatted and prefixed with a given scope name and promoted to a document level stylesheet. For example, given a scope name of .foo, a rule like this: :host { background: red; } } becomes: .foo { background: red; } * encapsulation: Styles defined within ShadowDOM, apply only to dom inside the ShadowDOM. Polymer uses one of two techniques to implement this feature. By default, rules are prefixed with the host element tag name as a descendant selector. This ensures styling does not leak out of the 'top' of the element's ShadowDOM. For example, div { font-weight: bold; } becomes: x-foo div { font-weight: bold; } becomes: Alternatively, if WebComponents.ShadowCSS.strictStyling is set to true then selectors are scoped by adding an attribute selector suffix to each simple selector that contains the host element tag name. Each element in the element's ShadowDOM template is also given the scope attribute. Thus, these rules match only elements that have the scope attribute. For example, given a scope name of x-foo, a rule like this: div { font-weight: bold; } becomes: div[x-foo] { font-weight: bold; } Note that elements that are dynamically added to a scope must have the scope selector added to them manually. * upper/lower bound encapsulation: Styles which are defined outside a shadowRoot should not cross the ShadowDOM boundary and should not apply inside a shadowRoot. This styling behavior is not emulated. Some possible ways to do this that were rejected due to complexity and/or performance concerns include: (1) reset every possible property for every possible selector for a given scope name; (2) re-implement css in javascript. As an alternative, users should make sure to use selectors specific to the scope in which they are working. * ::distributed: This behavior is not emulated. It's often not necessary to style the contents of a specific insertion point and instead, descendants of the host element can be styled selectively. Users can also create an extra node around an insertion point and style that node's contents via descendent selectors. For example, with a shadowRoot like this: could become:
    Note the use of @polyfill in the comment above a ShadowDOM specific style declaration. This is a directive to the styling shim to use the selector in comments in lieu of the next selector when running under polyfill. */ var ShadowCss = /** @class */ (function () { function ShadowCss() { this.strictStyling = true; } /* * Shim some cssText with the given selector. Returns cssText that can * be included in the document via WebComponents.ShadowCSS.addCssToDocument(css). * * When strictStyling is true: * - selector is the attribute added to all elements inside the host, * - hostSelector is the attribute added to the host itself. */ ShadowCss.prototype.shimCssText = function (cssText, selector, hostSelector) { if (hostSelector === void 0) { hostSelector = ''; } var commentsWithHash = extractCommentsWithHash(cssText); cssText = stripComments(cssText); cssText = this._insertDirectives(cssText); var scopedCssText = this._scopeCssText(cssText, selector, hostSelector); return Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__spread"])([scopedCssText], commentsWithHash).join('\n'); }; ShadowCss.prototype._insertDirectives = function (cssText) { cssText = this._insertPolyfillDirectivesInCssText(cssText); return this._insertPolyfillRulesInCssText(cssText); }; /* * Process styles to convert native ShadowDOM rules that will trip * up the css parser; we rely on decorating the stylesheet with inert rules. * * For example, we convert this rule: * * polyfill-next-selector { content: ':host menu-item'; } * ::content menu-item { * * to this: * * scopeName menu-item { * **/ ShadowCss.prototype._insertPolyfillDirectivesInCssText = function (cssText) { // Difference with webcomponents.js: does not handle comments return cssText.replace(_cssContentNextSelectorRe, function () { var m = []; for (var _i = 0; _i < arguments.length; _i++) { m[_i] = arguments[_i]; } return m[2] + '{'; }); }; /* * Process styles to add rules which will only apply under the polyfill * * For example, we convert this rule: * * polyfill-rule { * content: ':host menu-item'; * ... * } * * to this: * * scopeName menu-item {...} * **/ ShadowCss.prototype._insertPolyfillRulesInCssText = function (cssText) { // Difference with webcomponents.js: does not handle comments return cssText.replace(_cssContentRuleRe, function () { var m = []; for (var _i = 0; _i < arguments.length; _i++) { m[_i] = arguments[_i]; } var rule = m[0].replace(m[1], '').replace(m[2], ''); return m[4] + rule; }); }; /* Ensure styles are scoped. Pseudo-scoping takes a rule like: * * .foo {... } * * and converts this to * * scopeName .foo { ... } */ ShadowCss.prototype._scopeCssText = function (cssText, scopeSelector, hostSelector) { var unscopedRules = this._extractUnscopedRulesFromCssText(cssText); // replace :host and :host-context -shadowcsshost and -shadowcsshost respectively cssText = this._insertPolyfillHostInCssText(cssText); cssText = this._convertColonHost(cssText); cssText = this._convertColonHostContext(cssText); cssText = this._convertShadowDOMSelectors(cssText); if (scopeSelector) { cssText = this._scopeSelectors(cssText, scopeSelector, hostSelector); } cssText = cssText + '\n' + unscopedRules; return cssText.trim(); }; /* * Process styles to add rules which will only apply under the polyfill * and do not process via CSSOM. (CSSOM is destructive to rules on rare * occasions, e.g. -webkit-calc on Safari.) * For example, we convert this rule: * * @polyfill-unscoped-rule { * content: 'menu-item'; * ... } * * to this: * * menu-item {...} * **/ ShadowCss.prototype._extractUnscopedRulesFromCssText = function (cssText) { // Difference with webcomponents.js: does not handle comments var r = ''; var m; _cssContentUnscopedRuleRe.lastIndex = 0; while ((m = _cssContentUnscopedRuleRe.exec(cssText)) !== null) { var rule = m[0].replace(m[2], '').replace(m[1], m[4]); r += rule + '\n\n'; } return r; }; /* * convert a rule like :host(.foo) > .bar { } * * to * * .foo > .bar */ ShadowCss.prototype._convertColonHost = function (cssText) { return this._convertColonRule(cssText, _cssColonHostRe, this._colonHostPartReplacer); }; /* * convert a rule like :host-context(.foo) > .bar { } * * to * * .foo > .bar, .foo scopeName > .bar { } * * and * * :host-context(.foo:host) .bar { ... } * * to * * .foo .bar { ... } */ ShadowCss.prototype._convertColonHostContext = function (cssText) { return this._convertColonRule(cssText, _cssColonHostContextRe, this._colonHostContextPartReplacer); }; ShadowCss.prototype._convertColonRule = function (cssText, regExp, partReplacer) { // m[1] = :host(-context), m[2] = contents of (), m[3] rest of rule return cssText.replace(regExp, function () { var m = []; for (var _i = 0; _i < arguments.length; _i++) { m[_i] = arguments[_i]; } if (m[2]) { var parts = m[2].split(','); var r = []; for (var i = 0; i < parts.length; i++) { var p = parts[i].trim(); if (!p) break; r.push(partReplacer(_polyfillHostNoCombinator, p, m[3])); } return r.join(','); } else { return _polyfillHostNoCombinator + m[3]; } }); }; ShadowCss.prototype._colonHostContextPartReplacer = function (host, part, suffix) { if (part.indexOf(_polyfillHost) > -1) { return this._colonHostPartReplacer(host, part, suffix); } else { return host + part + suffix + ', ' + part + ' ' + host + suffix; } }; ShadowCss.prototype._colonHostPartReplacer = function (host, part, suffix) { return host + part.replace(_polyfillHost, '') + suffix; }; /* * Convert combinators like ::shadow and pseudo-elements like ::content * by replacing with space. */ ShadowCss.prototype._convertShadowDOMSelectors = function (cssText) { return _shadowDOMSelectorsRe.reduce(function (result, pattern) { return result.replace(pattern, ' '); }, cssText); }; // change a selector like 'div' to 'name div' ShadowCss.prototype._scopeSelectors = function (cssText, scopeSelector, hostSelector) { var _this = this; return processRules(cssText, function (rule) { var selector = rule.selector; var content = rule.content; if (rule.selector[0] != '@') { selector = _this._scopeSelector(rule.selector, scopeSelector, hostSelector, _this.strictStyling); } else if (rule.selector.startsWith('@media') || rule.selector.startsWith('@supports') || rule.selector.startsWith('@page') || rule.selector.startsWith('@document')) { content = _this._scopeSelectors(rule.content, scopeSelector, hostSelector); } return new CssRule(selector, content); }); }; ShadowCss.prototype._scopeSelector = function (selector, scopeSelector, hostSelector, strict) { var _this = this; return selector.split(',') .map(function (part) { return part.trim().split(_shadowDeepSelectors); }) .map(function (deepParts) { var _a = Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__read"])(deepParts), shallowPart = _a[0], otherParts = _a.slice(1); var applyScope = function (shallowPart) { if (_this._selectorNeedsScoping(shallowPart, scopeSelector)) { return strict ? _this._applyStrictSelectorScope(shallowPart, scopeSelector, hostSelector) : _this._applySelectorScope(shallowPart, scopeSelector, hostSelector); } else { return shallowPart; } }; return Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__spread"])([applyScope(shallowPart)], otherParts).join(' '); }) .join(', '); }; ShadowCss.prototype._selectorNeedsScoping = function (selector, scopeSelector) { var re = this._makeScopeMatcher(scopeSelector); return !re.test(selector); }; ShadowCss.prototype._makeScopeMatcher = function (scopeSelector) { var lre = /\[/g; var rre = /\]/g; scopeSelector = scopeSelector.replace(lre, '\\[').replace(rre, '\\]'); return new RegExp('^(' + scopeSelector + ')' + _selectorReSuffix, 'm'); }; ShadowCss.prototype._applySelectorScope = function (selector, scopeSelector, hostSelector) { // Difference from webcomponents.js: scopeSelector could not be an array return this._applySimpleSelectorScope(selector, scopeSelector, hostSelector); }; // scope via name and [is=name] ShadowCss.prototype._applySimpleSelectorScope = function (selector, scopeSelector, hostSelector) { // In Android browser, the lastIndex is not reset when the regex is used in String.replace() _polyfillHostRe.lastIndex = 0; if (_polyfillHostRe.test(selector)) { var replaceBy_1 = this.strictStyling ? "[" + hostSelector + "]" : scopeSelector; return selector .replace(_polyfillHostNoCombinatorRe, function (hnc, selector) { return selector.replace(/([^:]*)(:*)(.*)/, function (_, before, colon, after) { return before + replaceBy_1 + colon + after; }); }) .replace(_polyfillHostRe, replaceBy_1 + ' '); } return scopeSelector + ' ' + selector; }; // return a selector with [name] suffix on each simple selector // e.g. .foo.bar > .zot becomes .foo[name].bar[name] > .zot[name] /** @internal */ ShadowCss.prototype._applyStrictSelectorScope = function (selector, scopeSelector, hostSelector) { var _this = this; var isRe = /\[is=([^\]]*)\]/g; scopeSelector = scopeSelector.replace(isRe, function (_) { var parts = []; for (var _i = 1; _i < arguments.length; _i++) { parts[_i - 1] = arguments[_i]; } return parts[0]; }); var attrName = '[' + scopeSelector + ']'; var _scopeSelectorPart = function (p) { var scopedP = p.trim(); if (!scopedP) { return ''; } if (p.indexOf(_polyfillHostNoCombinator) > -1) { scopedP = _this._applySimpleSelectorScope(p, scopeSelector, hostSelector); } else { // remove :host since it should be unnecessary var t = p.replace(_polyfillHostRe, ''); if (t.length > 0) { var matches = t.match(/([^:]*)(:*)(.*)/); if (matches) { scopedP = matches[1] + attrName + matches[2] + matches[3]; } } } return scopedP; }; var safeContent = new SafeSelector(selector); selector = safeContent.content(); var scopedSelector = ''; var startIndex = 0; var res; var sep = /( |>|\+|~(?!=))\s*/g; // If a selector appears before :host it should not be shimmed as it // matches on ancestor elements and not on elements in the host's shadow // `:host-context(div)` is transformed to // `-shadowcsshost-no-combinatordiv, div -shadowcsshost-no-combinator` // the `div` is not part of the component in the 2nd selectors and should not be scoped. // Historically `component-tag:host` was matching the component so we also want to preserve // this behavior to avoid breaking legacy apps (it should not match). // The behavior should be: // - `tag:host` -> `tag[h]` (this is to avoid breaking legacy apps, should not match anything) // - `tag :host` -> `tag [h]` (`tag` is not scoped because it's considered part of a // `:host-context(tag)`) var hasHost = selector.indexOf(_polyfillHostNoCombinator) > -1; // Only scope parts after the first `-shadowcsshost-no-combinator` when it is present var shouldScope = !hasHost; while ((res = sep.exec(selector)) !== null) { var separator = res[1]; var part_1 = selector.slice(startIndex, res.index).trim(); shouldScope = shouldScope || part_1.indexOf(_polyfillHostNoCombinator) > -1; var scopedPart = shouldScope ? _scopeSelectorPart(part_1) : part_1; scopedSelector += scopedPart + " " + separator + " "; startIndex = sep.lastIndex; } var part = selector.substring(startIndex); shouldScope = shouldScope || part.indexOf(_polyfillHostNoCombinator) > -1; scopedSelector += shouldScope ? _scopeSelectorPart(part) : part; // replace the placeholders with their original values return safeContent.restore(scopedSelector); }; ShadowCss.prototype._insertPolyfillHostInCssText = function (selector) { return selector.replace(_colonHostContextRe, _polyfillHostContext) .replace(_colonHostRe, _polyfillHost); }; return ShadowCss; }()); var SafeSelector = /** @class */ (function () { function SafeSelector(selector) { var _this = this; this.placeholders = []; this.index = 0; // Replaces attribute selectors with placeholders. // The WS in [attr="va lue"] would otherwise be interpreted as a selector separator. selector = selector.replace(/(\[[^\]]*\])/g, function (_, keep) { var replaceBy = "__ph-" + _this.index + "__"; _this.placeholders.push(keep); _this.index++; return replaceBy; }); // Replaces the expression in `:nth-child(2n + 1)` with a placeholder. // WS and "+" would otherwise be interpreted as selector separators. this._content = selector.replace(/(:nth-[-\w]+)(\([^)]+\))/g, function (_, pseudo, exp) { var replaceBy = "__ph-" + _this.index + "__"; _this.placeholders.push(exp); _this.index++; return pseudo + replaceBy; }); } SafeSelector.prototype.restore = function (content) { var _this = this; return content.replace(/__ph-(\d+)__/g, function (ph, index) { return _this.placeholders[+index]; }); }; SafeSelector.prototype.content = function () { return this._content; }; return SafeSelector; }()); var _cssContentNextSelectorRe = /polyfill-next-selector[^}]*content:[\s]*?(['"])(.*?)\1[;\s]*}([^{]*?){/gim; var _cssContentRuleRe = /(polyfill-rule)[^}]*(content:[\s]*(['"])(.*?)\3)[;\s]*[^}]*}/gim; var _cssContentUnscopedRuleRe = /(polyfill-unscoped-rule)[^}]*(content:[\s]*(['"])(.*?)\3)[;\s]*[^}]*}/gim; var _polyfillHost = '-shadowcsshost'; // note: :host-context pre-processed to -shadowcsshostcontext. var _polyfillHostContext = '-shadowcsscontext'; var _parenSuffix = ')(?:\\((' + '(?:\\([^)(]*\\)|[^)(]*)+?' + ')\\))?([^,{]*)'; var _cssColonHostRe = new RegExp('(' + _polyfillHost + _parenSuffix, 'gim'); var _cssColonHostContextRe = new RegExp('(' + _polyfillHostContext + _parenSuffix, 'gim'); var _polyfillHostNoCombinator = _polyfillHost + '-no-combinator'; var _polyfillHostNoCombinatorRe = /-shadowcsshost-no-combinator([^\s]*)/; var _shadowDOMSelectorsRe = [ /::shadow/g, /::content/g, // Deprecated selectors /\/shadow-deep\//g, /\/shadow\//g, ]; // The deep combinator is deprecated in the CSS spec // Support for `>>>`, `deep`, `::ng-deep` is then also deprecated and will be removed in the future. // see https://github.com/angular/angular/pull/17677 var _shadowDeepSelectors = /(?:>>>)|(?:\/deep\/)|(?:::ng-deep)/g; var _selectorReSuffix = '([>\\s~+\[.,{:][\\s\\S]*)?$'; var _polyfillHostRe = /-shadowcsshost/gim; var _colonHostRe = /:host/gim; var _colonHostContextRe = /:host-context/gim; var _commentRe = /\/\*\s*[\s\S]*?\*\//g; function stripComments(input) { return input.replace(_commentRe, ''); } var _commentWithHashRe = /\/\*\s*#\s*source(Mapping)?URL=[\s\S]+?\*\//g; function extractCommentsWithHash(input) { return input.match(_commentWithHashRe) || []; } var _ruleRe = /(\s*)([^;\{\}]+?)(\s*)((?:{%BLOCK%}?\s*;?)|(?:\s*;))/g; var _curlyRe = /([{}])/g; var OPEN_CURLY = '{'; var CLOSE_CURLY = '}'; var BLOCK_PLACEHOLDER = '%BLOCK%'; var CssRule = /** @class */ (function () { function CssRule(selector, content) { this.selector = selector; this.content = content; } return CssRule; }()); function processRules(input, ruleCallback) { var inputWithEscapedBlocks = escapeBlocks(input); var nextBlockIndex = 0; return inputWithEscapedBlocks.escapedString.replace(_ruleRe, function () { var m = []; for (var _i = 0; _i < arguments.length; _i++) { m[_i] = arguments[_i]; } var selector = m[2]; var content = ''; var suffix = m[4]; var contentPrefix = ''; if (suffix && suffix.startsWith('{' + BLOCK_PLACEHOLDER)) { content = inputWithEscapedBlocks.blocks[nextBlockIndex++]; suffix = suffix.substring(BLOCK_PLACEHOLDER.length + 1); contentPrefix = '{'; } var rule = ruleCallback(new CssRule(selector, content)); return "" + m[1] + rule.selector + m[3] + contentPrefix + rule.content + suffix; }); } var StringWithEscapedBlocks = /** @class */ (function () { function StringWithEscapedBlocks(escapedString, blocks) { this.escapedString = escapedString; this.blocks = blocks; } return StringWithEscapedBlocks; }()); function escapeBlocks(input) { var inputParts = input.split(_curlyRe); var resultParts = []; var escapedBlocks = []; var bracketCount = 0; var currentBlockParts = []; for (var partIndex = 0; partIndex < inputParts.length; partIndex++) { var part = inputParts[partIndex]; if (part == CLOSE_CURLY) { bracketCount--; } if (bracketCount > 0) { currentBlockParts.push(part); } else { if (currentBlockParts.length > 0) { escapedBlocks.push(currentBlockParts.join('')); resultParts.push(BLOCK_PLACEHOLDER); currentBlockParts = []; } resultParts.push(part); } if (part == OPEN_CURLY) { bracketCount++; } } if (currentBlockParts.length > 0) { escapedBlocks.push(currentBlockParts.join('')); resultParts.push(BLOCK_PLACEHOLDER); } return new StringWithEscapedBlocks(resultParts.join(''), escapedBlocks); } /** * @license * Copyright Google Inc. All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ var COMPONENT_VARIABLE = '%COMP%'; var HOST_ATTR = "_nghost-" + COMPONENT_VARIABLE; var CONTENT_ATTR = "_ngcontent-" + COMPONENT_VARIABLE; var StylesCompileDependency = /** @class */ (function () { function StylesCompileDependency(name, moduleUrl, setValue) { this.name = name; this.moduleUrl = moduleUrl; this.setValue = setValue; } return StylesCompileDependency; }()); var CompiledStylesheet = /** @class */ (function () { function CompiledStylesheet(outputCtx, stylesVar, dependencies, isShimmed, meta) { this.outputCtx = outputCtx; this.stylesVar = stylesVar; this.dependencies = dependencies; this.isShimmed = isShimmed; this.meta = meta; } return CompiledStylesheet; }()); var StyleCompiler = /** @class */ (function () { function StyleCompiler(_urlResolver) { this._urlResolver = _urlResolver; this._shadowCss = new ShadowCss(); } StyleCompiler.prototype.compileComponent = function (outputCtx, comp) { var template = comp.template; return this._compileStyles(outputCtx, comp, new CompileStylesheetMetadata({ styles: template.styles, styleUrls: template.styleUrls, moduleUrl: identifierModuleUrl(comp.type) }), this.needsStyleShim(comp), true); }; StyleCompiler.prototype.compileStyles = function (outputCtx, comp, stylesheet, shim) { if (shim === void 0) { shim = this.needsStyleShim(comp); } return this._compileStyles(outputCtx, comp, stylesheet, shim, false); }; StyleCompiler.prototype.needsStyleShim = function (comp) { return comp.template.encapsulation === ViewEncapsulation.Emulated; }; StyleCompiler.prototype._compileStyles = function (outputCtx, comp, stylesheet, shim, isComponentStylesheet) { var _this = this; var styleExpressions = stylesheet.styles.map(function (plainStyle) { return literal(_this._shimIfNeeded(plainStyle, shim)); }); var dependencies = []; stylesheet.styleUrls.forEach(function (styleUrl) { var exprIndex = styleExpressions.length; // Note: This placeholder will be filled later. styleExpressions.push(null); dependencies.push(new StylesCompileDependency(getStylesVarName(null), styleUrl, function (value) { return styleExpressions[exprIndex] = outputCtx.importExpr(value); })); }); // styles variable contains plain strings and arrays of other styles arrays (recursive), // so we set its type to dynamic. var stylesVar = getStylesVarName(isComponentStylesheet ? comp : null); var stmt = variable(stylesVar) .set(literalArr(styleExpressions, new ArrayType(DYNAMIC_TYPE, [TypeModifier.Const]))) .toDeclStmt(null, isComponentStylesheet ? [StmtModifier.Final] : [ StmtModifier.Final, StmtModifier.Exported ]); outputCtx.statements.push(stmt); return new CompiledStylesheet(outputCtx, stylesVar, dependencies, shim, stylesheet); }; StyleCompiler.prototype._shimIfNeeded = function (style, shim) { return shim ? this._shadowCss.shimCssText(style, CONTENT_ATTR, HOST_ATTR) : style; }; return StyleCompiler; }()); function getStylesVarName(component) { var result = "styles"; if (component) { result += "_" + identifierName(component.type); } return result; } /** * @license * Copyright Google Inc. All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ /** * Parses string representation of a style and converts it into object literal. * * @param value string representation of style as used in the `style` attribute in HTML. * Example: `color: red; height: auto`. * @returns An array of style property name and value pairs, e.g. `['color', 'red', 'height', * 'auto']` */ function parse(value) { // we use a string array here instead of a string map // because a string-map is not guaranteed to retain the // order of the entries whereas a string array can be // construted in a [key, value, key, value] format. var styles = []; var i = 0; var parenDepth = 0; var quote = 0 /* QuoteNone */; var valueStart = 0; var propStart = 0; var currentProp = null; var valueHasQuotes = false; while (i < value.length) { var token = value.charCodeAt(i++); switch (token) { case 40 /* OpenParen */: parenDepth++; break; case 41 /* CloseParen */: parenDepth--; break; case 39 /* QuoteSingle */: // valueStart needs to be there since prop values don't // have quotes in CSS valueHasQuotes = valueHasQuotes || valueStart > 0; if (quote === 0 /* QuoteNone */) { quote = 39 /* QuoteSingle */; } else if (quote === 39 /* QuoteSingle */ && value.charCodeAt(i - 1) !== 92 /* BackSlash */) { quote = 0 /* QuoteNone */; } break; case 34 /* QuoteDouble */: // same logic as above valueHasQuotes = valueHasQuotes || valueStart > 0; if (quote === 0 /* QuoteNone */) { quote = 34 /* QuoteDouble */; } else if (quote === 34 /* QuoteDouble */ && value.charCodeAt(i - 1) !== 92 /* BackSlash */) { quote = 0 /* QuoteNone */; } break; case 58 /* Colon */: if (!currentProp && parenDepth === 0 && quote === 0 /* QuoteNone */) { currentProp = hyphenate(value.substring(propStart, i - 1).trim()); valueStart = i; } break; case 59 /* Semicolon */: if (currentProp && valueStart > 0 && parenDepth === 0 && quote === 0 /* QuoteNone */) { var styleVal = value.substring(valueStart, i - 1).trim(); styles.push(currentProp, valueHasQuotes ? stripUnnecessaryQuotes(styleVal) : styleVal); propStart = i; valueStart = 0; currentProp = null; valueHasQuotes = false; } break; } } if (currentProp && valueStart) { var styleVal = value.substr(valueStart).trim(); styles.push(currentProp, valueHasQuotes ? stripUnnecessaryQuotes(styleVal) : styleVal); } return styles; } function stripUnnecessaryQuotes(value) { var qS = value.charCodeAt(0); var qE = value.charCodeAt(value.length - 1); if (qS == qE && (qS == 39 /* QuoteSingle */ || qS == 34 /* QuoteDouble */)) { var tempValue = value.substring(1, value.length - 1); // special case to avoid using a multi-quoted string that was just chomped // (e.g. `font-family: "Verdana", "sans-serif"`) if (tempValue.indexOf('\'') == -1 && tempValue.indexOf('"') == -1) { value = tempValue; } } return value; } function hyphenate(value) { return value.replace(/[a-z][A-Z]/g, function (v) { return v.charAt(0) + '-' + v.charAt(1); }).toLowerCase(); } /** * Produces creation/update instructions for all styling bindings (class and style) * * It also produces the creation instruction to register all initial styling values * (which are all the static class="..." and style="..." attribute values that exist * on an element within a template). * * The builder class below handles producing instructions for the following cases: * * - Static style/class attributes (style="..." and class="...") * - Dynamic style/class map bindings ([style]="map" and [class]="map|string") * - Dynamic style/class property bindings ([style.prop]="exp" and [class.name]="exp") * * Due to the complex relationship of all of these cases, the instructions generated * for these attributes/properties/bindings must be done so in the correct order. The * order which these must be generated is as follows: * * if (createMode) { * elementStyling(...) * } * if (updateMode) { * elementStylingMap(...) * elementStyleProp(...) * elementClassProp(...) * elementStylingApp(...) * } * * The creation/update methods within the builder class produce these instructions. */ var StylingBuilder = /** @class */ (function () { function StylingBuilder(_elementIndexExpr, _directiveExpr) { this._elementIndexExpr = _elementIndexExpr; this._directiveExpr = _directiveExpr; /** Whether or not there are any static styling values present */ this._hasInitialValues = false; /** * Whether or not there are any styling bindings present * (i.e. `[style]`, `[class]`, `[style.prop]` or `[class.name]`) */ this._hasBindings = false; /** the input for [class] (if it exists) */ this._classMapInput = null; /** the input for [style] (if it exists) */ this._styleMapInput = null; /** an array of each [style.prop] input */ this._singleStyleInputs = null; /** an array of each [class.name] input */ this._singleClassInputs = null; this._lastStylingInput = null; // maps are used instead of hash maps because a Map will // retain the ordering of the keys /** * Represents the location of each style binding in the template * (e.g. `
    ` implies * that `width=0` and `height=1`) */ this._stylesIndex = new Map(); /** * Represents the location of each class binding in the template * (e.g. `
    ` implies * that `big=0` and `hidden=1`) */ this._classesIndex = new Map(); this._initialStyleValues = []; this._initialClassValues = []; // certain style properties ALWAYS need sanitization // this is checked each time new styles are encountered this._useDefaultSanitizer = false; } StylingBuilder.prototype.hasBindingsOrInitialValues = function () { return this._hasBindings || this._hasInitialValues; }; /** * Registers a given input to the styling builder to be later used when producing AOT code. * * The code below will only accept the input if it is somehow tied to styling (whether it be * style/class bindings or static style/class attributes). */ StylingBuilder.prototype.registerBoundInput = function (input) { // [attr.style] or [attr.class] are skipped in the code below, // they should not be treated as styling-based bindings since // they are intended to be written directly to the attr and // will therefore skip all style/class resolution that is present // with style="", [style]="" and [style.prop]="", class="", // [class.prop]="". [class]="" assignments var name = input.name; var binding = null; switch (input.type) { case 0 /* Property */: if (name == 'style') { binding = this.registerStyleInput(null, input.value, '', input.sourceSpan); } else if (isClassBinding(input.name)) { binding = this.registerClassInput(null, input.value, input.sourceSpan); } break; case 3 /* Style */: binding = this.registerStyleInput(input.name, input.value, input.unit, input.sourceSpan); break; case 2 /* Class */: binding = this.registerClassInput(input.name, input.value, input.sourceSpan); break; } return binding ? true : false; }; StylingBuilder.prototype.registerStyleInput = function (propertyName, value, unit, sourceSpan) { var entry = { name: propertyName, unit: unit, value: value, sourceSpan: sourceSpan }; if (propertyName) { (this._singleStyleInputs = this._singleStyleInputs || []).push(entry); this._useDefaultSanitizer = this._useDefaultSanitizer || isStyleSanitizable(propertyName); registerIntoMap(this._stylesIndex, propertyName); } else { this._useDefaultSanitizer = true; this._styleMapInput = entry; } this._lastStylingInput = entry; this._hasBindings = true; return entry; }; StylingBuilder.prototype.registerClassInput = function (className, value, sourceSpan) { var entry = { name: className, value: value, sourceSpan: sourceSpan }; if (className) { (this._singleClassInputs = this._singleClassInputs || []).push(entry); registerIntoMap(this._classesIndex, className); } else { this._classMapInput = entry; } this._lastStylingInput = entry; this._hasBindings = true; return entry; }; /** * Registers the element's static style string value to the builder. * * @param value the style string (e.g. `width:100px; height:200px;`) */ StylingBuilder.prototype.registerStyleAttr = function (value) { this._initialStyleValues = parse(value); this._hasInitialValues = true; }; /** * Registers the element's static class string value to the builder. * * @param value the className string (e.g. `disabled gold zoom`) */ StylingBuilder.prototype.registerClassAttr = function (value) { this._initialClassValues = value.trim().split(/\s+/g); this._hasInitialValues = true; }; /** * Appends all styling-related expressions to the provided attrs array. * * @param attrs an existing array where each of the styling expressions * will be inserted into. */ StylingBuilder.prototype.populateInitialStylingAttrs = function (attrs) { // [CLASS_MARKER, 'foo', 'bar', 'baz' ...] if (this._initialClassValues.length) { attrs.push(literal(1 /* Classes */)); for (var i = 0; i < this._initialClassValues.length; i++) { attrs.push(literal(this._initialClassValues[i])); } } // [STYLE_MARKER, 'width', '200px', 'height', '100px', ...] if (this._initialStyleValues.length) { attrs.push(literal(2 /* Styles */)); for (var i = 0; i < this._initialStyleValues.length; i += 2) { attrs.push(literal(this._initialStyleValues[i]), literal(this._initialStyleValues[i + 1])); } } }; /** * Builds an instruction with all the expressions and parameters for `elementHostAttrs`. * * The instruction generation code below is used for producing the AOT statement code which is * responsible for registering initial styles (within a directive hostBindings' creation block) * to the directive host element. */ StylingBuilder.prototype.buildDirectiveHostAttrsInstruction = function (sourceSpan, constantPool) { var _this = this; if (this._hasInitialValues && this._directiveExpr) { return { sourceSpan: sourceSpan, reference: Identifiers$1.elementHostAttrs, buildParams: function () { var attrs = []; _this.populateInitialStylingAttrs(attrs); return [_this._directiveExpr, getConstantLiteralFromArray(constantPool, attrs)]; } }; } return null; }; /** * Builds an instruction with all the expressions and parameters for `elementStyling`. * * The instruction generation code below is used for producing the AOT statement code which is * responsible for registering style/class bindings to an element. */ StylingBuilder.prototype.buildElementStylingInstruction = function (sourceSpan, constantPool) { var _this = this; if (this._hasBindings) { return { sourceSpan: sourceSpan, reference: Identifiers$1.elementStyling, buildParams: function () { // a string array of every style-based binding var styleBindingProps = _this._singleStyleInputs ? _this._singleStyleInputs.map(function (i) { return literal(i.name); }) : []; // a string array of every class-based binding var classBindingNames = _this._singleClassInputs ? _this._singleClassInputs.map(function (i) { return literal(i.name); }) : []; // to salvage space in the AOT generated code, there is no point in passing // in `null` into a param if any follow-up params are not used. Therefore, // only when a trailing param is used then it will be filled with nulls in between // (otherwise a shorter amount of params will be filled). The code below helps // determine how many params are required in the expression code. // // min params => elementStyling() // max params => elementStyling(classBindings, styleBindings, sanitizer, directive) var expectedNumberOfArgs = 0; if (_this._directiveExpr) { expectedNumberOfArgs = 4; } else if (_this._useDefaultSanitizer) { expectedNumberOfArgs = 3; } else if (styleBindingProps.length) { expectedNumberOfArgs = 2; } else if (classBindingNames.length) { expectedNumberOfArgs = 1; } var params = []; addParam(params, classBindingNames.length > 0, getConstantLiteralFromArray(constantPool, classBindingNames), 1, expectedNumberOfArgs); addParam(params, styleBindingProps.length > 0, getConstantLiteralFromArray(constantPool, styleBindingProps), 2, expectedNumberOfArgs); addParam(params, _this._useDefaultSanitizer, importExpr(Identifiers$1.defaultStyleSanitizer), 3, expectedNumberOfArgs); if (_this._directiveExpr) { params.push(_this._directiveExpr); } return params; } }; } return null; }; /** * Builds an instruction with all the expressions and parameters for `elementStylingMap`. * * The instruction data will contain all expressions for `elementStylingMap` to function * which include the `[style]` and `[class]` expression params (if they exist) as well as * the sanitizer and directive reference expression. */ StylingBuilder.prototype.buildElementStylingMapInstruction = function (valueConverter) { var _this = this; if (this._classMapInput || this._styleMapInput) { var stylingInput = this._classMapInput || this._styleMapInput; // these values must be outside of the update block so that they can // be evaluted (the AST visit call) during creation time so that any // pipes can be picked up in time before the template is built var mapBasedClassValue_1 = this._classMapInput ? this._classMapInput.value.visit(valueConverter) : null; var mapBasedStyleValue_1 = this._styleMapInput ? this._styleMapInput.value.visit(valueConverter) : null; return { sourceSpan: stylingInput.sourceSpan, reference: Identifiers$1.elementStylingMap, buildParams: function (convertFn) { var params = [_this._elementIndexExpr]; if (mapBasedClassValue_1) { params.push(convertFn(mapBasedClassValue_1)); } else if (_this._styleMapInput) { params.push(NULL_EXPR); } if (mapBasedStyleValue_1) { params.push(convertFn(mapBasedStyleValue_1)); } else if (_this._directiveExpr) { params.push(NULL_EXPR); } if (_this._directiveExpr) { params.push(_this._directiveExpr); } return params; } }; } return null; }; StylingBuilder.prototype._buildSingleInputs = function (reference, inputs, mapIndex, allowUnits, valueConverter) { var _this = this; return inputs.map(function (input) { var bindingIndex = mapIndex.get(input.name); var value = input.value.visit(valueConverter); return { sourceSpan: input.sourceSpan, reference: reference, buildParams: function (convertFn) { var params = [_this._elementIndexExpr, literal(bindingIndex), convertFn(value)]; if (allowUnits) { if (input.unit) { params.push(literal(input.unit)); } else if (_this._directiveExpr) { params.push(NULL_EXPR); } } if (_this._directiveExpr) { params.push(_this._directiveExpr); } return params; } }; }); }; StylingBuilder.prototype._buildClassInputs = function (valueConverter) { if (this._singleClassInputs) { return this._buildSingleInputs(Identifiers$1.elementClassProp, this._singleClassInputs, this._classesIndex, false, valueConverter); } return []; }; StylingBuilder.prototype._buildStyleInputs = function (valueConverter) { if (this._singleStyleInputs) { return this._buildSingleInputs(Identifiers$1.elementStyleProp, this._singleStyleInputs, this._stylesIndex, true, valueConverter); } return []; }; StylingBuilder.prototype._buildApplyFn = function () { var _this = this; return { sourceSpan: this._lastStylingInput ? this._lastStylingInput.sourceSpan : null, reference: Identifiers$1.elementStylingApply, buildParams: function () { var params = [_this._elementIndexExpr]; if (_this._directiveExpr) { params.push(_this._directiveExpr); } return params; } }; }; /** * Constructs all instructions which contain the expressions that will be placed * into the update block of a template function or a directive hostBindings function. */ StylingBuilder.prototype.buildUpdateLevelInstructions = function (valueConverter) { var instructions = []; if (this._hasBindings) { var mapInstruction = this.buildElementStylingMapInstruction(valueConverter); if (mapInstruction) { instructions.push(mapInstruction); } instructions.push.apply(instructions, Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__spread"])(this._buildStyleInputs(valueConverter))); instructions.push.apply(instructions, Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__spread"])(this._buildClassInputs(valueConverter))); instructions.push(this._buildApplyFn()); } return instructions; }; return StylingBuilder; }()); function isClassBinding(name) { return name == 'className' || name == 'class'; } function registerIntoMap(map, key) { if (!map.has(key)) { map.set(key, map.size); } } function isStyleSanitizable(prop) { return prop === 'background-image' || prop === 'background' || prop === 'border-image' || prop === 'filter' || prop === 'list-style' || prop === 'list-style-image'; } /** * Simple helper function to either provide the constant literal that will house the value * here or a null value if the provided values are empty. */ function getConstantLiteralFromArray(constantPool, values) { return values.length ? constantPool.getConstLiteral(literalArr(values), true) : NULL_EXPR; } /** * Simple helper function that adds a parameter or does nothing at all depending on the provided * predicate and totalExpectedArgs values */ function addParam(params, predicate, value, argNumber, totalExpectedArgs) { if (predicate) { params.push(value); } else if (argNumber < totalExpectedArgs) { params.push(NULL_EXPR); } } /** * @license * Copyright Google Inc. All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ var TokenType; (function (TokenType) { TokenType[TokenType["Character"] = 0] = "Character"; TokenType[TokenType["Identifier"] = 1] = "Identifier"; TokenType[TokenType["Keyword"] = 2] = "Keyword"; TokenType[TokenType["String"] = 3] = "String"; TokenType[TokenType["Operator"] = 4] = "Operator"; TokenType[TokenType["Number"] = 5] = "Number"; TokenType[TokenType["Error"] = 6] = "Error"; })(TokenType || (TokenType = {})); var KEYWORDS = ['var', 'let', 'as', 'null', 'undefined', 'true', 'false', 'if', 'else', 'this']; var Lexer = /** @class */ (function () { function Lexer() { } Lexer.prototype.tokenize = function (text) { var scanner = new _Scanner(text); var tokens = []; var token = scanner.scanToken(); while (token != null) { tokens.push(token); token = scanner.scanToken(); } return tokens; }; return Lexer; }()); var Token = /** @class */ (function () { function Token(index, type, numValue, strValue) { this.index = index; this.type = type; this.numValue = numValue; this.strValue = strValue; } Token.prototype.isCharacter = function (code) { return this.type == TokenType.Character && this.numValue == code; }; Token.prototype.isNumber = function () { return this.type == TokenType.Number; }; Token.prototype.isString = function () { return this.type == TokenType.String; }; Token.prototype.isOperator = function (operator) { return this.type == TokenType.Operator && this.strValue == operator; }; Token.prototype.isIdentifier = function () { return this.type == TokenType.Identifier; }; Token.prototype.isKeyword = function () { return this.type == TokenType.Keyword; }; Token.prototype.isKeywordLet = function () { return this.type == TokenType.Keyword && this.strValue == 'let'; }; Token.prototype.isKeywordAs = function () { return this.type == TokenType.Keyword && this.strValue == 'as'; }; Token.prototype.isKeywordNull = function () { return this.type == TokenType.Keyword && this.strValue == 'null'; }; Token.prototype.isKeywordUndefined = function () { return this.type == TokenType.Keyword && this.strValue == 'undefined'; }; Token.prototype.isKeywordTrue = function () { return this.type == TokenType.Keyword && this.strValue == 'true'; }; Token.prototype.isKeywordFalse = function () { return this.type == TokenType.Keyword && this.strValue == 'false'; }; Token.prototype.isKeywordThis = function () { return this.type == TokenType.Keyword && this.strValue == 'this'; }; Token.prototype.isError = function () { return this.type == TokenType.Error; }; Token.prototype.toNumber = function () { return this.type == TokenType.Number ? this.numValue : -1; }; Token.prototype.toString = function () { switch (this.type) { case TokenType.Character: case TokenType.Identifier: case TokenType.Keyword: case TokenType.Operator: case TokenType.String: case TokenType.Error: return this.strValue; case TokenType.Number: return this.numValue.toString(); default: return null; } }; return Token; }()); function newCharacterToken(index, code) { return new Token(index, TokenType.Character, code, String.fromCharCode(code)); } function newIdentifierToken(index, text) { return new Token(index, TokenType.Identifier, 0, text); } function newKeywordToken(index, text) { return new Token(index, TokenType.Keyword, 0, text); } function newOperatorToken(index, text) { return new Token(index, TokenType.Operator, 0, text); } function newStringToken(index, text) { return new Token(index, TokenType.String, 0, text); } function newNumberToken(index, n) { return new Token(index, TokenType.Number, n, ''); } function newErrorToken(index, message) { return new Token(index, TokenType.Error, 0, message); } var EOF = new Token(-1, TokenType.Character, 0, ''); var _Scanner = /** @class */ (function () { function _Scanner(input) { this.input = input; this.peek = 0; this.index = -1; this.length = input.length; this.advance(); } _Scanner.prototype.advance = function () { this.peek = ++this.index >= this.length ? $EOF : this.input.charCodeAt(this.index); }; _Scanner.prototype.scanToken = function () { var input = this.input, length = this.length; var peek = this.peek, index = this.index; // Skip whitespace. while (peek <= $SPACE) { if (++index >= length) { peek = $EOF; break; } else { peek = input.charCodeAt(index); } } this.peek = peek; this.index = index; if (index >= length) { return null; } // Handle identifiers and numbers. if (isIdentifierStart(peek)) return this.scanIdentifier(); if (isDigit(peek)) return this.scanNumber(index); var start = index; switch (peek) { case $PERIOD: this.advance(); return isDigit(this.peek) ? this.scanNumber(start) : newCharacterToken(start, $PERIOD); case $LPAREN: case $RPAREN: case $LBRACE: case $RBRACE: case $LBRACKET: case $RBRACKET: case $COMMA: case $COLON: case $SEMICOLON: return this.scanCharacter(start, peek); case $SQ: case $DQ: return this.scanString(); case $HASH: case $PLUS: case $MINUS: case $STAR: case $SLASH: case $PERCENT: case $CARET: return this.scanOperator(start, String.fromCharCode(peek)); case $QUESTION: return this.scanComplexOperator(start, '?', $PERIOD, '.'); case $LT: case $GT: return this.scanComplexOperator(start, String.fromCharCode(peek), $EQ, '='); case $BANG: case $EQ: return this.scanComplexOperator(start, String.fromCharCode(peek), $EQ, '=', $EQ, '='); case $AMPERSAND: return this.scanComplexOperator(start, '&', $AMPERSAND, '&'); case $BAR: return this.scanComplexOperator(start, '|', $BAR, '|'); case $NBSP: while (isWhitespace(this.peek)) this.advance(); return this.scanToken(); } this.advance(); return this.error("Unexpected character [" + String.fromCharCode(peek) + "]", 0); }; _Scanner.prototype.scanCharacter = function (start, code) { this.advance(); return newCharacterToken(start, code); }; _Scanner.prototype.scanOperator = function (start, str) { this.advance(); return newOperatorToken(start, str); }; /** * Tokenize a 2/3 char long operator * * @param start start index in the expression * @param one first symbol (always part of the operator) * @param twoCode code point for the second symbol * @param two second symbol (part of the operator when the second code point matches) * @param threeCode code point for the third symbol * @param three third symbol (part of the operator when provided and matches source expression) */ _Scanner.prototype.scanComplexOperator = function (start, one, twoCode, two, threeCode, three) { this.advance(); var str = one; if (this.peek == twoCode) { this.advance(); str += two; } if (threeCode != null && this.peek == threeCode) { this.advance(); str += three; } return newOperatorToken(start, str); }; _Scanner.prototype.scanIdentifier = function () { var start = this.index; this.advance(); while (isIdentifierPart(this.peek)) this.advance(); var str = this.input.substring(start, this.index); return KEYWORDS.indexOf(str) > -1 ? newKeywordToken(start, str) : newIdentifierToken(start, str); }; _Scanner.prototype.scanNumber = function (start) { var simple = (this.index === start); this.advance(); // Skip initial digit. while (true) { if (isDigit(this.peek)) ; else if (this.peek == $PERIOD) { simple = false; } else if (isExponentStart(this.peek)) { this.advance(); if (isExponentSign(this.peek)) this.advance(); if (!isDigit(this.peek)) return this.error('Invalid exponent', -1); simple = false; } else { break; } this.advance(); } var str = this.input.substring(start, this.index); var value = simple ? parseIntAutoRadix(str) : parseFloat(str); return newNumberToken(start, value); }; _Scanner.prototype.scanString = function () { var start = this.index; var quote = this.peek; this.advance(); // Skip initial quote. var buffer = ''; var marker = this.index; var input = this.input; while (this.peek != quote) { if (this.peek == $BACKSLASH) { buffer += input.substring(marker, this.index); this.advance(); var unescapedCode = void 0; // Workaround for TS2.1-introduced type strictness this.peek = this.peek; if (this.peek == $u) { // 4 character hex code for unicode character. var hex = input.substring(this.index + 1, this.index + 5); if (/^[0-9a-f]+$/i.test(hex)) { unescapedCode = parseInt(hex, 16); } else { return this.error("Invalid unicode escape [\\u" + hex + "]", 0); } for (var i = 0; i < 5; i++) { this.advance(); } } else { unescapedCode = unescape(this.peek); this.advance(); } buffer += String.fromCharCode(unescapedCode); marker = this.index; } else if (this.peek == $EOF) { return this.error('Unterminated quote', 0); } else { this.advance(); } } var last = input.substring(marker, this.index); this.advance(); // Skip terminating quote. return newStringToken(start, buffer + last); }; _Scanner.prototype.error = function (message, offset) { var position = this.index + offset; return newErrorToken(position, "Lexer Error: " + message + " at column " + position + " in expression [" + this.input + "]"); }; return _Scanner; }()); function isIdentifierStart(code) { return ($a <= code && code <= $z) || ($A <= code && code <= $Z) || (code == $_) || (code == $$); } function isIdentifier(input) { if (input.length == 0) return false; var scanner = new _Scanner(input); if (!isIdentifierStart(scanner.peek)) return false; scanner.advance(); while (scanner.peek !== $EOF) { if (!isIdentifierPart(scanner.peek)) return false; scanner.advance(); } return true; } function isIdentifierPart(code) { return isAsciiLetter(code) || isDigit(code) || (code == $_) || (code == $$); } function isExponentStart(code) { return code == $e || code == $E; } function isExponentSign(code) { return code == $MINUS || code == $PLUS; } function isQuote(code) { return code === $SQ || code === $DQ || code === $BT; } function unescape(code) { switch (code) { case $n: return $LF; case $f: return $FF; case $r: return $CR; case $t: return $TAB; case $v: return $VTAB; default: return code; } } function parseIntAutoRadix(text) { var result = parseInt(text); if (isNaN(result)) { throw new Error('Invalid integer literal when parsing ' + text); } return result; } /** * @license * Copyright Google Inc. All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ var SplitInterpolation = /** @class */ (function () { function SplitInterpolation(strings, expressions, offsets) { this.strings = strings; this.expressions = expressions; this.offsets = offsets; } return SplitInterpolation; }()); var TemplateBindingParseResult = /** @class */ (function () { function TemplateBindingParseResult(templateBindings, warnings, errors) { this.templateBindings = templateBindings; this.warnings = warnings; this.errors = errors; } return TemplateBindingParseResult; }()); function _createInterpolateRegExp(config) { var pattern = escapeRegExp(config.start) + '([\\s\\S]*?)' + escapeRegExp(config.end); return new RegExp(pattern, 'g'); } var Parser = /** @class */ (function () { function Parser(_lexer) { this._lexer = _lexer; this.errors = []; } Parser.prototype.parseAction = function (input, location, interpolationConfig) { if (interpolationConfig === void 0) { interpolationConfig = DEFAULT_INTERPOLATION_CONFIG; } this._checkNoInterpolation(input, location, interpolationConfig); var sourceToLex = this._stripComments(input); var tokens = this._lexer.tokenize(this._stripComments(input)); var ast = new _ParseAST(input, location, tokens, sourceToLex.length, true, this.errors, input.length - sourceToLex.length) .parseChain(); return new ASTWithSource(ast, input, location, this.errors); }; Parser.prototype.parseBinding = function (input, location, interpolationConfig) { if (interpolationConfig === void 0) { interpolationConfig = DEFAULT_INTERPOLATION_CONFIG; } var ast = this._parseBindingAst(input, location, interpolationConfig); return new ASTWithSource(ast, input, location, this.errors); }; Parser.prototype.parseSimpleBinding = function (input, location, interpolationConfig) { if (interpolationConfig === void 0) { interpolationConfig = DEFAULT_INTERPOLATION_CONFIG; } var ast = this._parseBindingAst(input, location, interpolationConfig); var errors = SimpleExpressionChecker.check(ast); if (errors.length > 0) { this._reportError("Host binding expression cannot contain " + errors.join(' '), input, location); } return new ASTWithSource(ast, input, location, this.errors); }; Parser.prototype._reportError = function (message, input, errLocation, ctxLocation) { this.errors.push(new ParserError(message, input, errLocation, ctxLocation)); }; Parser.prototype._parseBindingAst = function (input, location, interpolationConfig) { // Quotes expressions use 3rd-party expression language. We don't want to use // our lexer or parser for that, so we check for that ahead of time. var quote = this._parseQuote(input, location); if (quote != null) { return quote; } this._checkNoInterpolation(input, location, interpolationConfig); var sourceToLex = this._stripComments(input); var tokens = this._lexer.tokenize(sourceToLex); return new _ParseAST(input, location, tokens, sourceToLex.length, false, this.errors, input.length - sourceToLex.length) .parseChain(); }; Parser.prototype._parseQuote = function (input, location) { if (input == null) return null; var prefixSeparatorIndex = input.indexOf(':'); if (prefixSeparatorIndex == -1) return null; var prefix = input.substring(0, prefixSeparatorIndex).trim(); if (!isIdentifier(prefix)) return null; var uninterpretedExpression = input.substring(prefixSeparatorIndex + 1); return new Quote(new ParseSpan(0, input.length), prefix, uninterpretedExpression, location); }; Parser.prototype.parseTemplateBindings = function (tplKey, tplValue, location) { var tokens = this._lexer.tokenize(tplValue); return new _ParseAST(tplValue, location, tokens, tplValue.length, false, this.errors, 0) .parseTemplateBindings(tplKey); }; Parser.prototype.parseInterpolation = function (input, location, interpolationConfig) { if (interpolationConfig === void 0) { interpolationConfig = DEFAULT_INTERPOLATION_CONFIG; } var split = this.splitInterpolation(input, location, interpolationConfig); if (split == null) return null; var expressions = []; for (var i = 0; i < split.expressions.length; ++i) { var expressionText = split.expressions[i]; var sourceToLex = this._stripComments(expressionText); var tokens = this._lexer.tokenize(sourceToLex); var ast = new _ParseAST(input, location, tokens, sourceToLex.length, false, this.errors, split.offsets[i] + (expressionText.length - sourceToLex.length)) .parseChain(); expressions.push(ast); } return new ASTWithSource(new Interpolation(new ParseSpan(0, input == null ? 0 : input.length), split.strings, expressions), input, location, this.errors); }; Parser.prototype.splitInterpolation = function (input, location, interpolationConfig) { if (interpolationConfig === void 0) { interpolationConfig = DEFAULT_INTERPOLATION_CONFIG; } var regexp = _createInterpolateRegExp(interpolationConfig); var parts = input.split(regexp); if (parts.length <= 1) { return null; } var strings = []; var expressions = []; var offsets = []; var offset = 0; for (var i = 0; i < parts.length; i++) { var part = parts[i]; if (i % 2 === 0) { // fixed string strings.push(part); offset += part.length; } else if (part.trim().length > 0) { offset += interpolationConfig.start.length; expressions.push(part); offsets.push(offset); offset += part.length + interpolationConfig.end.length; } else { this._reportError('Blank expressions are not allowed in interpolated strings', input, "at column " + this._findInterpolationErrorColumn(parts, i, interpolationConfig) + " in", location); expressions.push('$implict'); offsets.push(offset); } } return new SplitInterpolation(strings, expressions, offsets); }; Parser.prototype.wrapLiteralPrimitive = function (input, location) { return new ASTWithSource(new LiteralPrimitive(new ParseSpan(0, input == null ? 0 : input.length), input), input, location, this.errors); }; Parser.prototype._stripComments = function (input) { var i = this._commentStart(input); return i != null ? input.substring(0, i).trim() : input; }; Parser.prototype._commentStart = function (input) { var outerQuote = null; for (var i = 0; i < input.length - 1; i++) { var char = input.charCodeAt(i); var nextChar = input.charCodeAt(i + 1); if (char === $SLASH && nextChar == $SLASH && outerQuote == null) return i; if (outerQuote === char) { outerQuote = null; } else if (outerQuote == null && isQuote(char)) { outerQuote = char; } } return null; }; Parser.prototype._checkNoInterpolation = function (input, location, interpolationConfig) { var regexp = _createInterpolateRegExp(interpolationConfig); var parts = input.split(regexp); if (parts.length > 1) { this._reportError("Got interpolation (" + interpolationConfig.start + interpolationConfig.end + ") where expression was expected", input, "at column " + this._findInterpolationErrorColumn(parts, 1, interpolationConfig) + " in", location); } }; Parser.prototype._findInterpolationErrorColumn = function (parts, partInErrIdx, interpolationConfig) { var errLocation = ''; for (var j = 0; j < partInErrIdx; j++) { errLocation += j % 2 === 0 ? parts[j] : "" + interpolationConfig.start + parts[j] + interpolationConfig.end; } return errLocation.length; }; return Parser; }()); var _ParseAST = /** @class */ (function () { function _ParseAST(input, location, tokens, inputLength, parseAction, errors, offset) { this.input = input; this.location = location; this.tokens = tokens; this.inputLength = inputLength; this.parseAction = parseAction; this.errors = errors; this.offset = offset; this.rparensExpected = 0; this.rbracketsExpected = 0; this.rbracesExpected = 0; this.index = 0; } _ParseAST.prototype.peek = function (offset) { var i = this.index + offset; return i < this.tokens.length ? this.tokens[i] : EOF; }; Object.defineProperty(_ParseAST.prototype, "next", { get: function () { return this.peek(0); }, enumerable: true, configurable: true }); Object.defineProperty(_ParseAST.prototype, "inputIndex", { get: function () { return (this.index < this.tokens.length) ? this.next.index + this.offset : this.inputLength + this.offset; }, enumerable: true, configurable: true }); _ParseAST.prototype.span = function (start) { return new ParseSpan(start, this.inputIndex); }; _ParseAST.prototype.advance = function () { this.index++; }; _ParseAST.prototype.optionalCharacter = function (code) { if (this.next.isCharacter(code)) { this.advance(); return true; } else { return false; } }; _ParseAST.prototype.peekKeywordLet = function () { return this.next.isKeywordLet(); }; _ParseAST.prototype.peekKeywordAs = function () { return this.next.isKeywordAs(); }; _ParseAST.prototype.expectCharacter = function (code) { if (this.optionalCharacter(code)) return; this.error("Missing expected " + String.fromCharCode(code)); }; _ParseAST.prototype.optionalOperator = function (op) { if (this.next.isOperator(op)) { this.advance(); return true; } else { return false; } }; _ParseAST.prototype.expectOperator = function (operator) { if (this.optionalOperator(operator)) return; this.error("Missing expected operator " + operator); }; _ParseAST.prototype.expectIdentifierOrKeyword = function () { var n = this.next; if (!n.isIdentifier() && !n.isKeyword()) { this.error("Unexpected token " + n + ", expected identifier or keyword"); return ''; } this.advance(); return n.toString(); }; _ParseAST.prototype.expectIdentifierOrKeywordOrString = function () { var n = this.next; if (!n.isIdentifier() && !n.isKeyword() && !n.isString()) { this.error("Unexpected token " + n + ", expected identifier, keyword, or string"); return ''; } this.advance(); return n.toString(); }; _ParseAST.prototype.parseChain = function () { var exprs = []; var start = this.inputIndex; while (this.index < this.tokens.length) { var expr = this.parsePipe(); exprs.push(expr); if (this.optionalCharacter($SEMICOLON)) { if (!this.parseAction) { this.error('Binding expression cannot contain chained expression'); } while (this.optionalCharacter($SEMICOLON)) { } // read all semicolons } else if (this.index < this.tokens.length) { this.error("Unexpected token '" + this.next + "'"); } } if (exprs.length == 0) return new EmptyExpr(this.span(start)); if (exprs.length == 1) return exprs[0]; return new Chain(this.span(start), exprs); }; _ParseAST.prototype.parsePipe = function () { var result = this.parseExpression(); if (this.optionalOperator('|')) { if (this.parseAction) { this.error('Cannot have a pipe in an action expression'); } do { var name_1 = this.expectIdentifierOrKeyword(); var args = []; while (this.optionalCharacter($COLON)) { args.push(this.parseExpression()); } result = new BindingPipe(this.span(result.span.start), result, name_1, args); } while (this.optionalOperator('|')); } return result; }; _ParseAST.prototype.parseExpression = function () { return this.parseConditional(); }; _ParseAST.prototype.parseConditional = function () { var start = this.inputIndex; var result = this.parseLogicalOr(); if (this.optionalOperator('?')) { var yes = this.parsePipe(); var no = void 0; if (!this.optionalCharacter($COLON)) { var end = this.inputIndex; var expression = this.input.substring(start, end); this.error("Conditional expression " + expression + " requires all 3 expressions"); no = new EmptyExpr(this.span(start)); } else { no = this.parsePipe(); } return new Conditional(this.span(start), result, yes, no); } else { return result; } }; _ParseAST.prototype.parseLogicalOr = function () { // '||' var result = this.parseLogicalAnd(); while (this.optionalOperator('||')) { var right = this.parseLogicalAnd(); result = new Binary(this.span(result.span.start), '||', result, right); } return result; }; _ParseAST.prototype.parseLogicalAnd = function () { // '&&' var result = this.parseEquality(); while (this.optionalOperator('&&')) { var right = this.parseEquality(); result = new Binary(this.span(result.span.start), '&&', result, right); } return result; }; _ParseAST.prototype.parseEquality = function () { // '==','!=','===','!==' var result = this.parseRelational(); while (this.next.type == TokenType.Operator) { var operator = this.next.strValue; switch (operator) { case '==': case '===': case '!=': case '!==': this.advance(); var right = this.parseRelational(); result = new Binary(this.span(result.span.start), operator, result, right); continue; } break; } return result; }; _ParseAST.prototype.parseRelational = function () { // '<', '>', '<=', '>=' var result = this.parseAdditive(); while (this.next.type == TokenType.Operator) { var operator = this.next.strValue; switch (operator) { case '<': case '>': case '<=': case '>=': this.advance(); var right = this.parseAdditive(); result = new Binary(this.span(result.span.start), operator, result, right); continue; } break; } return result; }; _ParseAST.prototype.parseAdditive = function () { // '+', '-' var result = this.parseMultiplicative(); while (this.next.type == TokenType.Operator) { var operator = this.next.strValue; switch (operator) { case '+': case '-': this.advance(); var right = this.parseMultiplicative(); result = new Binary(this.span(result.span.start), operator, result, right); continue; } break; } return result; }; _ParseAST.prototype.parseMultiplicative = function () { // '*', '%', '/' var result = this.parsePrefix(); while (this.next.type == TokenType.Operator) { var operator = this.next.strValue; switch (operator) { case '*': case '%': case '/': this.advance(); var right = this.parsePrefix(); result = new Binary(this.span(result.span.start), operator, result, right); continue; } break; } return result; }; _ParseAST.prototype.parsePrefix = function () { if (this.next.type == TokenType.Operator) { var start = this.inputIndex; var operator = this.next.strValue; var result = void 0; switch (operator) { case '+': this.advance(); result = this.parsePrefix(); return new Binary(this.span(start), '-', result, new LiteralPrimitive(new ParseSpan(start, start), 0)); case '-': this.advance(); result = this.parsePrefix(); return new Binary(this.span(start), operator, new LiteralPrimitive(new ParseSpan(start, start), 0), result); case '!': this.advance(); result = this.parsePrefix(); return new PrefixNot(this.span(start), result); } } return this.parseCallChain(); }; _ParseAST.prototype.parseCallChain = function () { var result = this.parsePrimary(); while (true) { if (this.optionalCharacter($PERIOD)) { result = this.parseAccessMemberOrMethodCall(result, false); } else if (this.optionalOperator('?.')) { result = this.parseAccessMemberOrMethodCall(result, true); } else if (this.optionalCharacter($LBRACKET)) { this.rbracketsExpected++; var key = this.parsePipe(); this.rbracketsExpected--; this.expectCharacter($RBRACKET); if (this.optionalOperator('=')) { var value = this.parseConditional(); result = new KeyedWrite(this.span(result.span.start), result, key, value); } else { result = new KeyedRead(this.span(result.span.start), result, key); } } else if (this.optionalCharacter($LPAREN)) { this.rparensExpected++; var args = this.parseCallArguments(); this.rparensExpected--; this.expectCharacter($RPAREN); result = new FunctionCall(this.span(result.span.start), result, args); } else if (this.optionalOperator('!')) { result = new NonNullAssert(this.span(result.span.start), result); } else { return result; } } }; _ParseAST.prototype.parsePrimary = function () { var start = this.inputIndex; if (this.optionalCharacter($LPAREN)) { this.rparensExpected++; var result = this.parsePipe(); this.rparensExpected--; this.expectCharacter($RPAREN); return result; } else if (this.next.isKeywordNull()) { this.advance(); return new LiteralPrimitive(this.span(start), null); } else if (this.next.isKeywordUndefined()) { this.advance(); return new LiteralPrimitive(this.span(start), void 0); } else if (this.next.isKeywordTrue()) { this.advance(); return new LiteralPrimitive(this.span(start), true); } else if (this.next.isKeywordFalse()) { this.advance(); return new LiteralPrimitive(this.span(start), false); } else if (this.next.isKeywordThis()) { this.advance(); return new ImplicitReceiver(this.span(start)); } else if (this.optionalCharacter($LBRACKET)) { this.rbracketsExpected++; var elements = this.parseExpressionList($RBRACKET); this.rbracketsExpected--; this.expectCharacter($RBRACKET); return new LiteralArray(this.span(start), elements); } else if (this.next.isCharacter($LBRACE)) { return this.parseLiteralMap(); } else if (this.next.isIdentifier()) { return this.parseAccessMemberOrMethodCall(new ImplicitReceiver(this.span(start)), false); } else if (this.next.isNumber()) { var value = this.next.toNumber(); this.advance(); return new LiteralPrimitive(this.span(start), value); } else if (this.next.isString()) { var literalValue = this.next.toString(); this.advance(); return new LiteralPrimitive(this.span(start), literalValue); } else if (this.index >= this.tokens.length) { this.error("Unexpected end of expression: " + this.input); return new EmptyExpr(this.span(start)); } else { this.error("Unexpected token " + this.next); return new EmptyExpr(this.span(start)); } }; _ParseAST.prototype.parseExpressionList = function (terminator) { var result = []; if (!this.next.isCharacter(terminator)) { do { result.push(this.parsePipe()); } while (this.optionalCharacter($COMMA)); } return result; }; _ParseAST.prototype.parseLiteralMap = function () { var keys = []; var values = []; var start = this.inputIndex; this.expectCharacter($LBRACE); if (!this.optionalCharacter($RBRACE)) { this.rbracesExpected++; do { var quoted = this.next.isString(); var key = this.expectIdentifierOrKeywordOrString(); keys.push({ key: key, quoted: quoted }); this.expectCharacter($COLON); values.push(this.parsePipe()); } while (this.optionalCharacter($COMMA)); this.rbracesExpected--; this.expectCharacter($RBRACE); } return new LiteralMap(this.span(start), keys, values); }; _ParseAST.prototype.parseAccessMemberOrMethodCall = function (receiver, isSafe) { if (isSafe === void 0) { isSafe = false; } var start = receiver.span.start; var id = this.expectIdentifierOrKeyword(); if (this.optionalCharacter($LPAREN)) { this.rparensExpected++; var args = this.parseCallArguments(); this.expectCharacter($RPAREN); this.rparensExpected--; var span = this.span(start); return isSafe ? new SafeMethodCall(span, receiver, id, args) : new MethodCall(span, receiver, id, args); } else { if (isSafe) { if (this.optionalOperator('=')) { this.error('The \'?.\' operator cannot be used in the assignment'); return new EmptyExpr(this.span(start)); } else { return new SafePropertyRead(this.span(start), receiver, id); } } else { if (this.optionalOperator('=')) { if (!this.parseAction) { this.error('Bindings cannot contain assignments'); return new EmptyExpr(this.span(start)); } var value = this.parseConditional(); return new PropertyWrite(this.span(start), receiver, id, value); } else { return new PropertyRead(this.span(start), receiver, id); } } } }; _ParseAST.prototype.parseCallArguments = function () { if (this.next.isCharacter($RPAREN)) return []; var positionals = []; do { positionals.push(this.parsePipe()); } while (this.optionalCharacter($COMMA)); return positionals; }; /** * An identifier, a keyword, a string with an optional `-` in between. */ _ParseAST.prototype.expectTemplateBindingKey = function () { var result = ''; var operatorFound = false; do { result += this.expectIdentifierOrKeywordOrString(); operatorFound = this.optionalOperator('-'); if (operatorFound) { result += '-'; } } while (operatorFound); return result.toString(); }; // Parses the AST for `` _ParseAST.prototype.parseTemplateBindings = function (tplKey) { var firstBinding = true; var bindings = []; var warnings = []; do { var start = this.inputIndex; var rawKey = void 0; var key = void 0; var isVar = false; if (firstBinding) { rawKey = key = tplKey; firstBinding = false; } else { isVar = this.peekKeywordLet(); if (isVar) this.advance(); rawKey = this.expectTemplateBindingKey(); key = isVar ? rawKey : tplKey + rawKey[0].toUpperCase() + rawKey.substring(1); this.optionalCharacter($COLON); } var name_2 = null; var expression = null; if (isVar) { if (this.optionalOperator('=')) { name_2 = this.expectTemplateBindingKey(); } else { name_2 = '\$implicit'; } } else if (this.peekKeywordAs()) { this.advance(); // consume `as` name_2 = rawKey; key = this.expectTemplateBindingKey(); // read local var name isVar = true; } else if (this.next !== EOF && !this.peekKeywordLet()) { var start_1 = this.inputIndex; var ast = this.parsePipe(); var source = this.input.substring(start_1 - this.offset, this.inputIndex - this.offset); expression = new ASTWithSource(ast, source, this.location, this.errors); } bindings.push(new TemplateBinding(this.span(start), key, isVar, name_2, expression)); if (this.peekKeywordAs() && !isVar) { var letStart = this.inputIndex; this.advance(); // consume `as` var letName = this.expectTemplateBindingKey(); // read local var name bindings.push(new TemplateBinding(this.span(letStart), letName, true, key, null)); } if (!this.optionalCharacter($SEMICOLON)) { this.optionalCharacter($COMMA); } } while (this.index < this.tokens.length); return new TemplateBindingParseResult(bindings, warnings, this.errors); }; _ParseAST.prototype.error = function (message, index) { if (index === void 0) { index = null; } this.errors.push(new ParserError(message, this.input, this.locationText(index), this.location)); this.skip(); }; _ParseAST.prototype.locationText = function (index) { if (index === void 0) { index = null; } if (index == null) index = this.index; return (index < this.tokens.length) ? "at column " + (this.tokens[index].index + 1) + " in" : "at the end of the expression"; }; // Error recovery should skip tokens until it encounters a recovery point. skip() treats // the end of input and a ';' as unconditionally a recovery point. It also treats ')', // '}' and ']' as conditional recovery points if one of calling productions is expecting // one of these symbols. This allows skip() to recover from errors such as '(a.) + 1' allowing // more of the AST to be retained (it doesn't skip any tokens as the ')' is retained because // of the '(' begins an '(' ')' production). The recovery points of grouping symbols // must be conditional as they must be skipped if none of the calling productions are not // expecting the closing token else we will never make progress in the case of an // extraneous group closing symbol (such as a stray ')'). This is not the case for ';' because // parseChain() is always the root production and it expects a ';'. // If a production expects one of these token it increments the corresponding nesting count, // and then decrements it just prior to checking if the token is in the input. _ParseAST.prototype.skip = function () { var n = this.next; while (this.index < this.tokens.length && !n.isCharacter($SEMICOLON) && (this.rparensExpected <= 0 || !n.isCharacter($RPAREN)) && (this.rbracesExpected <= 0 || !n.isCharacter($RBRACE)) && (this.rbracketsExpected <= 0 || !n.isCharacter($RBRACKET))) { if (this.next.isError()) { this.errors.push(new ParserError(this.next.toString(), this.input, this.locationText(), this.location)); } this.advance(); n = this.next; } }; return _ParseAST; }()); var SimpleExpressionChecker = /** @class */ (function () { function SimpleExpressionChecker() { this.errors = []; } SimpleExpressionChecker.check = function (ast) { var s = new SimpleExpressionChecker(); ast.visit(s); return s.errors; }; SimpleExpressionChecker.prototype.visitImplicitReceiver = function (ast, context) { }; SimpleExpressionChecker.prototype.visitInterpolation = function (ast, context) { }; SimpleExpressionChecker.prototype.visitLiteralPrimitive = function (ast, context) { }; SimpleExpressionChecker.prototype.visitPropertyRead = function (ast, context) { }; SimpleExpressionChecker.prototype.visitPropertyWrite = function (ast, context) { }; SimpleExpressionChecker.prototype.visitSafePropertyRead = function (ast, context) { }; SimpleExpressionChecker.prototype.visitMethodCall = function (ast, context) { }; SimpleExpressionChecker.prototype.visitSafeMethodCall = function (ast, context) { }; SimpleExpressionChecker.prototype.visitFunctionCall = function (ast, context) { }; SimpleExpressionChecker.prototype.visitLiteralArray = function (ast, context) { this.visitAll(ast.expressions); }; SimpleExpressionChecker.prototype.visitLiteralMap = function (ast, context) { this.visitAll(ast.values); }; SimpleExpressionChecker.prototype.visitBinary = function (ast, context) { }; SimpleExpressionChecker.prototype.visitPrefixNot = function (ast, context) { }; SimpleExpressionChecker.prototype.visitNonNullAssert = function (ast, context) { }; SimpleExpressionChecker.prototype.visitConditional = function (ast, context) { }; SimpleExpressionChecker.prototype.visitPipe = function (ast, context) { this.errors.push('pipes'); }; SimpleExpressionChecker.prototype.visitKeyedRead = function (ast, context) { }; SimpleExpressionChecker.prototype.visitKeyedWrite = function (ast, context) { }; SimpleExpressionChecker.prototype.visitAll = function (asts) { var _this = this; return asts.map(function (node) { return node.visit(_this); }); }; SimpleExpressionChecker.prototype.visitChain = function (ast, context) { }; SimpleExpressionChecker.prototype.visitQuote = function (ast, context) { }; return SimpleExpressionChecker; }()); /** * @license * Copyright Google Inc. All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ /** * A path is an ordered set of elements. Typically a path is to a * particular offset in a source file. The head of the list is the top * most node. The tail is the node that contains the offset directly. * * For example, the expression `a + b + c` might have an ast that looks * like: * + * / \ * a + * / \ * b c * * The path to the node at offset 9 would be `['+' at 1-10, '+' at 7-10, * 'c' at 9-10]` and the path the node at offset 1 would be * `['+' at 1-10, 'a' at 1-2]`. */ var AstPath = /** @class */ (function () { function AstPath(path, position) { if (position === void 0) { position = -1; } this.path = path; this.position = position; } Object.defineProperty(AstPath.prototype, "empty", { get: function () { return !this.path || !this.path.length; }, enumerable: true, configurable: true }); Object.defineProperty(AstPath.prototype, "head", { get: function () { return this.path[0]; }, enumerable: true, configurable: true }); Object.defineProperty(AstPath.prototype, "tail", { get: function () { return this.path[this.path.length - 1]; }, enumerable: true, configurable: true }); AstPath.prototype.parentOf = function (node) { return node && this.path[this.path.indexOf(node) - 1]; }; AstPath.prototype.childOf = function (node) { return this.path[this.path.indexOf(node) + 1]; }; AstPath.prototype.first = function (ctor) { for (var i = this.path.length - 1; i >= 0; i--) { var item = this.path[i]; if (item instanceof ctor) return item; } }; AstPath.prototype.push = function (node) { this.path.push(node); }; AstPath.prototype.pop = function () { return this.path.pop(); }; return AstPath; }()); /** * @license * Copyright Google Inc. All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ var Text$2 = /** @class */ (function () { function Text(value, sourceSpan, i18n) { this.value = value; this.sourceSpan = sourceSpan; this.i18n = i18n; } Text.prototype.visit = function (visitor, context) { return visitor.visitText(this, context); }; return Text; }()); var Expansion = /** @class */ (function () { function Expansion(switchValue, type, cases, sourceSpan, switchValueSourceSpan, i18n) { this.switchValue = switchValue; this.type = type; this.cases = cases; this.sourceSpan = sourceSpan; this.switchValueSourceSpan = switchValueSourceSpan; this.i18n = i18n; } Expansion.prototype.visit = function (visitor, context) { return visitor.visitExpansion(this, context); }; return Expansion; }()); var ExpansionCase = /** @class */ (function () { function ExpansionCase(value, expression, sourceSpan, valueSourceSpan, expSourceSpan) { this.value = value; this.expression = expression; this.sourceSpan = sourceSpan; this.valueSourceSpan = valueSourceSpan; this.expSourceSpan = expSourceSpan; } ExpansionCase.prototype.visit = function (visitor, context) { return visitor.visitExpansionCase(this, context); }; return ExpansionCase; }()); var Attribute = /** @class */ (function () { function Attribute(name, value, sourceSpan, valueSpan, i18n) { this.name = name; this.value = value; this.sourceSpan = sourceSpan; this.valueSpan = valueSpan; this.i18n = i18n; } Attribute.prototype.visit = function (visitor, context) { return visitor.visitAttribute(this, context); }; return Attribute; }()); var Element = /** @class */ (function () { function Element(name, attrs, children, sourceSpan, startSourceSpan, endSourceSpan, i18n) { if (startSourceSpan === void 0) { startSourceSpan = null; } if (endSourceSpan === void 0) { endSourceSpan = null; } this.name = name; this.attrs = attrs; this.children = children; this.sourceSpan = sourceSpan; this.startSourceSpan = startSourceSpan; this.endSourceSpan = endSourceSpan; this.i18n = i18n; } Element.prototype.visit = function (visitor, context) { return visitor.visitElement(this, context); }; return Element; }()); var Comment = /** @class */ (function () { function Comment(value, sourceSpan) { this.value = value; this.sourceSpan = sourceSpan; } Comment.prototype.visit = function (visitor, context) { return visitor.visitComment(this, context); }; return Comment; }()); function visitAll(visitor, nodes, context) { if (context === void 0) { context = null; } var result = []; var visit = visitor.visit ? function (ast) { return visitor.visit(ast, context) || ast.visit(visitor, context); } : function (ast) { return ast.visit(visitor, context); }; nodes.forEach(function (ast) { var astResult = visit(ast); if (astResult) { result.push(astResult); } }); return result; } var RecursiveVisitor = /** @class */ (function () { function RecursiveVisitor() { } RecursiveVisitor.prototype.visitElement = function (ast, context) { this.visitChildren(context, function (visit) { visit(ast.attrs); visit(ast.children); }); }; RecursiveVisitor.prototype.visitAttribute = function (ast, context) { }; RecursiveVisitor.prototype.visitText = function (ast, context) { }; RecursiveVisitor.prototype.visitComment = function (ast, context) { }; RecursiveVisitor.prototype.visitExpansion = function (ast, context) { return this.visitChildren(context, function (visit) { visit(ast.cases); }); }; RecursiveVisitor.prototype.visitExpansionCase = function (ast, context) { }; RecursiveVisitor.prototype.visitChildren = function (context, cb) { var results = []; var t = this; function visit(children) { if (children) results.push(visitAll(t, children, context)); } cb(visit); return [].concat.apply([], results); }; return RecursiveVisitor; }()); function spanOf(ast) { var start = ast.sourceSpan.start.offset; var end = ast.sourceSpan.end.offset; if (ast instanceof Element) { if (ast.endSourceSpan) { end = ast.endSourceSpan.end.offset; } else if (ast.children && ast.children.length) { end = spanOf(ast.children[ast.children.length - 1]).end; } } return { start: start, end: end }; } function findNode(nodes, position) { var path = []; var visitor = new /** @class */ (function (_super) { Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(class_1, _super); function class_1() { return _super !== null && _super.apply(this, arguments) || this; } class_1.prototype.visit = function (ast, context) { var span = spanOf(ast); if (span.start <= position && position < span.end) { path.push(ast); } else { // Returning a value here will result in the children being skipped. return true; } }; return class_1; }(RecursiveVisitor)); visitAll(visitor, nodes); return new AstPath(path, position); } /** * @license * Copyright Google Inc. All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ var TokenType$1; (function (TokenType) { TokenType[TokenType["TAG_OPEN_START"] = 0] = "TAG_OPEN_START"; TokenType[TokenType["TAG_OPEN_END"] = 1] = "TAG_OPEN_END"; TokenType[TokenType["TAG_OPEN_END_VOID"] = 2] = "TAG_OPEN_END_VOID"; TokenType[TokenType["TAG_CLOSE"] = 3] = "TAG_CLOSE"; TokenType[TokenType["TEXT"] = 4] = "TEXT"; TokenType[TokenType["ESCAPABLE_RAW_TEXT"] = 5] = "ESCAPABLE_RAW_TEXT"; TokenType[TokenType["RAW_TEXT"] = 6] = "RAW_TEXT"; TokenType[TokenType["COMMENT_START"] = 7] = "COMMENT_START"; TokenType[TokenType["COMMENT_END"] = 8] = "COMMENT_END"; TokenType[TokenType["CDATA_START"] = 9] = "CDATA_START"; TokenType[TokenType["CDATA_END"] = 10] = "CDATA_END"; TokenType[TokenType["ATTR_NAME"] = 11] = "ATTR_NAME"; TokenType[TokenType["ATTR_VALUE"] = 12] = "ATTR_VALUE"; TokenType[TokenType["DOC_TYPE"] = 13] = "DOC_TYPE"; TokenType[TokenType["EXPANSION_FORM_START"] = 14] = "EXPANSION_FORM_START"; TokenType[TokenType["EXPANSION_CASE_VALUE"] = 15] = "EXPANSION_CASE_VALUE"; TokenType[TokenType["EXPANSION_CASE_EXP_START"] = 16] = "EXPANSION_CASE_EXP_START"; TokenType[TokenType["EXPANSION_CASE_EXP_END"] = 17] = "EXPANSION_CASE_EXP_END"; TokenType[TokenType["EXPANSION_FORM_END"] = 18] = "EXPANSION_FORM_END"; TokenType[TokenType["EOF"] = 19] = "EOF"; })(TokenType$1 || (TokenType$1 = {})); var Token$1 = /** @class */ (function () { function Token(type, parts, sourceSpan) { this.type = type; this.parts = parts; this.sourceSpan = sourceSpan; } return Token; }()); var TokenError = /** @class */ (function (_super) { Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(TokenError, _super); function TokenError(errorMsg, tokenType, span) { var _this = _super.call(this, span, errorMsg) || this; _this.tokenType = tokenType; return _this; } return TokenError; }(ParseError)); var TokenizeResult = /** @class */ (function () { function TokenizeResult(tokens, errors) { this.tokens = tokens; this.errors = errors; } return TokenizeResult; }()); function tokenize(source, url, getTagDefinition, tokenizeExpansionForms, interpolationConfig) { if (tokenizeExpansionForms === void 0) { tokenizeExpansionForms = false; } if (interpolationConfig === void 0) { interpolationConfig = DEFAULT_INTERPOLATION_CONFIG; } return new _Tokenizer(new ParseSourceFile(source, url), getTagDefinition, tokenizeExpansionForms, interpolationConfig) .tokenize(); } var _CR_OR_CRLF_REGEXP = /\r\n?/g; function _unexpectedCharacterErrorMsg(charCode) { var char = charCode === $EOF ? 'EOF' : String.fromCharCode(charCode); return "Unexpected character \"" + char + "\""; } function _unknownEntityErrorMsg(entitySrc) { return "Unknown entity \"" + entitySrc + "\" - use the \"&#;\" or \"&#x;\" syntax"; } var _ControlFlowError = /** @class */ (function () { function _ControlFlowError(error) { this.error = error; } return _ControlFlowError; }()); // See http://www.w3.org/TR/html51/syntax.html#writing var _Tokenizer = /** @class */ (function () { /** * @param _file The html source * @param _getTagDefinition * @param _tokenizeIcu Whether to tokenize ICU messages (considered as text nodes when false) * @param _interpolationConfig */ function _Tokenizer(_file, _getTagDefinition, _tokenizeIcu, _interpolationConfig) { if (_interpolationConfig === void 0) { _interpolationConfig = DEFAULT_INTERPOLATION_CONFIG; } this._file = _file; this._getTagDefinition = _getTagDefinition; this._tokenizeIcu = _tokenizeIcu; this._interpolationConfig = _interpolationConfig; // Note: this is always lowercase! this._peek = -1; this._nextPeek = -1; this._index = -1; this._line = 0; this._column = -1; this._expansionCaseStack = []; this._inInterpolation = false; this.tokens = []; this.errors = []; this._input = _file.content; this._length = _file.content.length; this._advance(); } _Tokenizer.prototype._processCarriageReturns = function (content) { // http://www.w3.org/TR/html5/syntax.html#preprocessing-the-input-stream // In order to keep the original position in the source, we can not // pre-process it. // Instead CRs are processed right before instantiating the tokens. return content.replace(_CR_OR_CRLF_REGEXP, '\n'); }; _Tokenizer.prototype.tokenize = function () { while (this._peek !== $EOF) { var start = this._getLocation(); try { if (this._attemptCharCode($LT)) { if (this._attemptCharCode($BANG)) { if (this._attemptCharCode($LBRACKET)) { this._consumeCdata(start); } else if (this._attemptCharCode($MINUS)) { this._consumeComment(start); } else { this._consumeDocType(start); } } else if (this._attemptCharCode($SLASH)) { this._consumeTagClose(start); } else { this._consumeTagOpen(start); } } else if (!(this._tokenizeIcu && this._tokenizeExpansionForm())) { this._consumeText(); } } catch (e) { if (e instanceof _ControlFlowError) { this.errors.push(e.error); } else { throw e; } } } this._beginToken(TokenType$1.EOF); this._endToken([]); return new TokenizeResult(mergeTextTokens(this.tokens), this.errors); }; /** * @returns whether an ICU token has been created * @internal */ _Tokenizer.prototype._tokenizeExpansionForm = function () { if (isExpansionFormStart(this._input, this._index, this._interpolationConfig)) { this._consumeExpansionFormStart(); return true; } if (isExpansionCaseStart(this._peek) && this._isInExpansionForm()) { this._consumeExpansionCaseStart(); return true; } if (this._peek === $RBRACE) { if (this._isInExpansionCase()) { this._consumeExpansionCaseEnd(); return true; } if (this._isInExpansionForm()) { this._consumeExpansionFormEnd(); return true; } } return false; }; _Tokenizer.prototype._getLocation = function () { return new ParseLocation(this._file, this._index, this._line, this._column); }; _Tokenizer.prototype._getSpan = function (start, end) { if (start === void 0) { start = this._getLocation(); } if (end === void 0) { end = this._getLocation(); } return new ParseSourceSpan(start, end); }; _Tokenizer.prototype._beginToken = function (type, start) { if (start === void 0) { start = this._getLocation(); } this._currentTokenStart = start; this._currentTokenType = type; }; _Tokenizer.prototype._endToken = function (parts, end) { if (end === void 0) { end = this._getLocation(); } var token = new Token$1(this._currentTokenType, parts, new ParseSourceSpan(this._currentTokenStart, end)); this.tokens.push(token); this._currentTokenStart = null; this._currentTokenType = null; return token; }; _Tokenizer.prototype._createError = function (msg, span) { if (this._isInExpansionForm()) { msg += " (Do you have an unescaped \"{\" in your template? Use \"{{ '{' }}\") to escape it.)"; } var error = new TokenError(msg, this._currentTokenType, span); this._currentTokenStart = null; this._currentTokenType = null; return new _ControlFlowError(error); }; _Tokenizer.prototype._advance = function () { if (this._index >= this._length) { throw this._createError(_unexpectedCharacterErrorMsg($EOF), this._getSpan()); } if (this._peek === $LF) { this._line++; this._column = 0; } else if (this._peek !== $LF && this._peek !== $CR) { this._column++; } this._index++; this._peek = this._index >= this._length ? $EOF : this._input.charCodeAt(this._index); this._nextPeek = this._index + 1 >= this._length ? $EOF : this._input.charCodeAt(this._index + 1); }; _Tokenizer.prototype._attemptCharCode = function (charCode) { if (this._peek === charCode) { this._advance(); return true; } return false; }; _Tokenizer.prototype._attemptCharCodeCaseInsensitive = function (charCode) { if (compareCharCodeCaseInsensitive(this._peek, charCode)) { this._advance(); return true; } return false; }; _Tokenizer.prototype._requireCharCode = function (charCode) { var location = this._getLocation(); if (!this._attemptCharCode(charCode)) { throw this._createError(_unexpectedCharacterErrorMsg(this._peek), this._getSpan(location, location)); } }; _Tokenizer.prototype._attemptStr = function (chars) { var len = chars.length; if (this._index + len > this._length) { return false; } var initialPosition = this._savePosition(); for (var i = 0; i < len; i++) { if (!this._attemptCharCode(chars.charCodeAt(i))) { // If attempting to parse the string fails, we want to reset the parser // to where it was before the attempt this._restorePosition(initialPosition); return false; } } return true; }; _Tokenizer.prototype._attemptStrCaseInsensitive = function (chars) { for (var i = 0; i < chars.length; i++) { if (!this._attemptCharCodeCaseInsensitive(chars.charCodeAt(i))) { return false; } } return true; }; _Tokenizer.prototype._requireStr = function (chars) { var location = this._getLocation(); if (!this._attemptStr(chars)) { throw this._createError(_unexpectedCharacterErrorMsg(this._peek), this._getSpan(location)); } }; _Tokenizer.prototype._attemptCharCodeUntilFn = function (predicate) { while (!predicate(this._peek)) { this._advance(); } }; _Tokenizer.prototype._requireCharCodeUntilFn = function (predicate, len) { var start = this._getLocation(); this._attemptCharCodeUntilFn(predicate); if (this._index - start.offset < len) { throw this._createError(_unexpectedCharacterErrorMsg(this._peek), this._getSpan(start, start)); } }; _Tokenizer.prototype._attemptUntilChar = function (char) { while (this._peek !== char) { this._advance(); } }; _Tokenizer.prototype._readChar = function (decodeEntities) { if (decodeEntities && this._peek === $AMPERSAND) { return this._decodeEntity(); } else { var index = this._index; this._advance(); return this._input[index]; } }; _Tokenizer.prototype._decodeEntity = function () { var start = this._getLocation(); this._advance(); if (this._attemptCharCode($HASH)) { var isHex = this._attemptCharCode($x) || this._attemptCharCode($X); var numberStart = this._getLocation().offset; this._attemptCharCodeUntilFn(isDigitEntityEnd); if (this._peek != $SEMICOLON) { throw this._createError(_unexpectedCharacterErrorMsg(this._peek), this._getSpan()); } this._advance(); var strNum = this._input.substring(numberStart, this._index - 1); try { var charCode = parseInt(strNum, isHex ? 16 : 10); return String.fromCharCode(charCode); } catch (_a) { var entity = this._input.substring(start.offset + 1, this._index - 1); throw this._createError(_unknownEntityErrorMsg(entity), this._getSpan(start)); } } else { var startPosition = this._savePosition(); this._attemptCharCodeUntilFn(isNamedEntityEnd); if (this._peek != $SEMICOLON) { this._restorePosition(startPosition); return '&'; } this._advance(); var name_1 = this._input.substring(start.offset + 1, this._index - 1); var char = NAMED_ENTITIES[name_1]; if (!char) { throw this._createError(_unknownEntityErrorMsg(name_1), this._getSpan(start)); } return char; } }; _Tokenizer.prototype._consumeRawText = function (decodeEntities, firstCharOfEnd, attemptEndRest) { var tagCloseStart; var textStart = this._getLocation(); this._beginToken(decodeEntities ? TokenType$1.ESCAPABLE_RAW_TEXT : TokenType$1.RAW_TEXT, textStart); var parts = []; while (true) { tagCloseStart = this._getLocation(); if (this._attemptCharCode(firstCharOfEnd) && attemptEndRest()) { break; } if (this._index > tagCloseStart.offset) { // add the characters consumed by the previous if statement to the output parts.push(this._input.substring(tagCloseStart.offset, this._index)); } while (this._peek !== firstCharOfEnd) { parts.push(this._readChar(decodeEntities)); } } return this._endToken([this._processCarriageReturns(parts.join(''))], tagCloseStart); }; _Tokenizer.prototype._consumeComment = function (start) { var _this = this; this._beginToken(TokenType$1.COMMENT_START, start); this._requireCharCode($MINUS); this._endToken([]); var textToken = this._consumeRawText(false, $MINUS, function () { return _this._attemptStr('->'); }); this._beginToken(TokenType$1.COMMENT_END, textToken.sourceSpan.end); this._endToken([]); }; _Tokenizer.prototype._consumeCdata = function (start) { var _this = this; this._beginToken(TokenType$1.CDATA_START, start); this._requireStr('CDATA['); this._endToken([]); var textToken = this._consumeRawText(false, $RBRACKET, function () { return _this._attemptStr(']>'); }); this._beginToken(TokenType$1.CDATA_END, textToken.sourceSpan.end); this._endToken([]); }; _Tokenizer.prototype._consumeDocType = function (start) { this._beginToken(TokenType$1.DOC_TYPE, start); this._attemptUntilChar($GT); this._advance(); this._endToken([this._input.substring(start.offset + 2, this._index - 1)]); }; _Tokenizer.prototype._consumePrefixAndName = function () { var nameOrPrefixStart = this._index; var prefix = null; while (this._peek !== $COLON && !isPrefixEnd(this._peek)) { this._advance(); } var nameStart; if (this._peek === $COLON) { this._advance(); prefix = this._input.substring(nameOrPrefixStart, this._index - 1); nameStart = this._index; } else { nameStart = nameOrPrefixStart; } this._requireCharCodeUntilFn(isNameEnd, this._index === nameStart ? 1 : 0); var name = this._input.substring(nameStart, this._index); return [prefix, name]; }; _Tokenizer.prototype._consumeTagOpen = function (start) { var savedPos = this._savePosition(); var tagName; var lowercaseTagName; try { if (!isAsciiLetter(this._peek)) { throw this._createError(_unexpectedCharacterErrorMsg(this._peek), this._getSpan()); } var nameStart = this._index; this._consumeTagOpenStart(start); tagName = this._input.substring(nameStart, this._index); lowercaseTagName = tagName.toLowerCase(); this._attemptCharCodeUntilFn(isNotWhitespace); while (this._peek !== $SLASH && this._peek !== $GT) { this._consumeAttributeName(); this._attemptCharCodeUntilFn(isNotWhitespace); if (this._attemptCharCode($EQ)) { this._attemptCharCodeUntilFn(isNotWhitespace); this._consumeAttributeValue(); } this._attemptCharCodeUntilFn(isNotWhitespace); } this._consumeTagOpenEnd(); } catch (e) { if (e instanceof _ControlFlowError) { // When the start tag is invalid, assume we want a "<" this._restorePosition(savedPos); // Back to back text tokens are merged at the end this._beginToken(TokenType$1.TEXT, start); this._endToken(['<']); return; } throw e; } var contentTokenType = this._getTagDefinition(tagName).contentType; if (contentTokenType === TagContentType.RAW_TEXT) { this._consumeRawTextWithTagClose(lowercaseTagName, false); } else if (contentTokenType === TagContentType.ESCAPABLE_RAW_TEXT) { this._consumeRawTextWithTagClose(lowercaseTagName, true); } }; _Tokenizer.prototype._consumeRawTextWithTagClose = function (lowercaseTagName, decodeEntities) { var _this = this; var textToken = this._consumeRawText(decodeEntities, $LT, function () { if (!_this._attemptCharCode($SLASH)) return false; _this._attemptCharCodeUntilFn(isNotWhitespace); if (!_this._attemptStrCaseInsensitive(lowercaseTagName)) return false; _this._attemptCharCodeUntilFn(isNotWhitespace); return _this._attemptCharCode($GT); }); this._beginToken(TokenType$1.TAG_CLOSE, textToken.sourceSpan.end); this._endToken([null, lowercaseTagName]); }; _Tokenizer.prototype._consumeTagOpenStart = function (start) { this._beginToken(TokenType$1.TAG_OPEN_START, start); var parts = this._consumePrefixAndName(); this._endToken(parts); }; _Tokenizer.prototype._consumeAttributeName = function () { this._beginToken(TokenType$1.ATTR_NAME); var prefixAndName = this._consumePrefixAndName(); this._endToken(prefixAndName); }; _Tokenizer.prototype._consumeAttributeValue = function () { this._beginToken(TokenType$1.ATTR_VALUE); var value; if (this._peek === $SQ || this._peek === $DQ) { var quoteChar = this._peek; this._advance(); var parts = []; while (this._peek !== quoteChar) { parts.push(this._readChar(true)); } value = parts.join(''); this._advance(); } else { var valueStart = this._index; this._requireCharCodeUntilFn(isNameEnd, 1); value = this._input.substring(valueStart, this._index); } this._endToken([this._processCarriageReturns(value)]); }; _Tokenizer.prototype._consumeTagOpenEnd = function () { var tokenType = this._attemptCharCode($SLASH) ? TokenType$1.TAG_OPEN_END_VOID : TokenType$1.TAG_OPEN_END; this._beginToken(tokenType); this._requireCharCode($GT); this._endToken([]); }; _Tokenizer.prototype._consumeTagClose = function (start) { this._beginToken(TokenType$1.TAG_CLOSE, start); this._attemptCharCodeUntilFn(isNotWhitespace); var prefixAndName = this._consumePrefixAndName(); this._attemptCharCodeUntilFn(isNotWhitespace); this._requireCharCode($GT); this._endToken(prefixAndName); }; _Tokenizer.prototype._consumeExpansionFormStart = function () { this._beginToken(TokenType$1.EXPANSION_FORM_START, this._getLocation()); this._requireCharCode($LBRACE); this._endToken([]); this._expansionCaseStack.push(TokenType$1.EXPANSION_FORM_START); this._beginToken(TokenType$1.RAW_TEXT, this._getLocation()); var condition = this._readUntil($COMMA); this._endToken([condition], this._getLocation()); this._requireCharCode($COMMA); this._attemptCharCodeUntilFn(isNotWhitespace); this._beginToken(TokenType$1.RAW_TEXT, this._getLocation()); var type = this._readUntil($COMMA); this._endToken([type], this._getLocation()); this._requireCharCode($COMMA); this._attemptCharCodeUntilFn(isNotWhitespace); }; _Tokenizer.prototype._consumeExpansionCaseStart = function () { this._beginToken(TokenType$1.EXPANSION_CASE_VALUE, this._getLocation()); var value = this._readUntil($LBRACE).trim(); this._endToken([value], this._getLocation()); this._attemptCharCodeUntilFn(isNotWhitespace); this._beginToken(TokenType$1.EXPANSION_CASE_EXP_START, this._getLocation()); this._requireCharCode($LBRACE); this._endToken([], this._getLocation()); this._attemptCharCodeUntilFn(isNotWhitespace); this._expansionCaseStack.push(TokenType$1.EXPANSION_CASE_EXP_START); }; _Tokenizer.prototype._consumeExpansionCaseEnd = function () { this._beginToken(TokenType$1.EXPANSION_CASE_EXP_END, this._getLocation()); this._requireCharCode($RBRACE); this._endToken([], this._getLocation()); this._attemptCharCodeUntilFn(isNotWhitespace); this._expansionCaseStack.pop(); }; _Tokenizer.prototype._consumeExpansionFormEnd = function () { this._beginToken(TokenType$1.EXPANSION_FORM_END, this._getLocation()); this._requireCharCode($RBRACE); this._endToken([]); this._expansionCaseStack.pop(); }; _Tokenizer.prototype._consumeText = function () { var start = this._getLocation(); this._beginToken(TokenType$1.TEXT, start); var parts = []; do { if (this._interpolationConfig && this._attemptStr(this._interpolationConfig.start)) { parts.push(this._interpolationConfig.start); this._inInterpolation = true; } else if (this._interpolationConfig && this._inInterpolation && this._attemptStr(this._interpolationConfig.end)) { parts.push(this._interpolationConfig.end); this._inInterpolation = false; } else { parts.push(this._readChar(true)); } } while (!this._isTextEnd()); this._endToken([this._processCarriageReturns(parts.join(''))]); }; _Tokenizer.prototype._isTextEnd = function () { if (this._peek === $LT || this._peek === $EOF) { return true; } if (this._tokenizeIcu && !this._inInterpolation) { if (isExpansionFormStart(this._input, this._index, this._interpolationConfig)) { // start of an expansion form return true; } if (this._peek === $RBRACE && this._isInExpansionCase()) { // end of and expansion case return true; } } return false; }; _Tokenizer.prototype._savePosition = function () { return [this._peek, this._index, this._column, this._line, this.tokens.length]; }; _Tokenizer.prototype._readUntil = function (char) { var start = this._index; this._attemptUntilChar(char); return this._input.substring(start, this._index); }; _Tokenizer.prototype._restorePosition = function (position) { this._peek = position[0]; this._index = position[1]; this._column = position[2]; this._line = position[3]; var nbTokens = position[4]; if (nbTokens < this.tokens.length) { // remove any extra tokens this.tokens = this.tokens.slice(0, nbTokens); } }; _Tokenizer.prototype._isInExpansionCase = function () { return this._expansionCaseStack.length > 0 && this._expansionCaseStack[this._expansionCaseStack.length - 1] === TokenType$1.EXPANSION_CASE_EXP_START; }; _Tokenizer.prototype._isInExpansionForm = function () { return this._expansionCaseStack.length > 0 && this._expansionCaseStack[this._expansionCaseStack.length - 1] === TokenType$1.EXPANSION_FORM_START; }; return _Tokenizer; }()); function isNotWhitespace(code) { return !isWhitespace(code) || code === $EOF; } function isNameEnd(code) { return isWhitespace(code) || code === $GT || code === $SLASH || code === $SQ || code === $DQ || code === $EQ; } function isPrefixEnd(code) { return (code < $a || $z < code) && (code < $A || $Z < code) && (code < $0 || code > $9); } function isDigitEntityEnd(code) { return code == $SEMICOLON || code == $EOF || !isAsciiHexDigit(code); } function isNamedEntityEnd(code) { return code == $SEMICOLON || code == $EOF || !isAsciiLetter(code); } function isExpansionFormStart(input, offset, interpolationConfig) { var isInterpolationStart = interpolationConfig ? input.indexOf(interpolationConfig.start, offset) == offset : false; return input.charCodeAt(offset) == $LBRACE && !isInterpolationStart; } function isExpansionCaseStart(peek) { return peek === $EQ || isAsciiLetter(peek) || isDigit(peek); } function compareCharCodeCaseInsensitive(code1, code2) { return toUpperCaseCharCode(code1) == toUpperCaseCharCode(code2); } function toUpperCaseCharCode(code) { return code >= $a && code <= $z ? code - $a + $A : code; } function mergeTextTokens(srcTokens) { var dstTokens = []; var lastDstToken = undefined; for (var i = 0; i < srcTokens.length; i++) { var token = srcTokens[i]; if (lastDstToken && lastDstToken.type == TokenType$1.TEXT && token.type == TokenType$1.TEXT) { lastDstToken.parts[0] += token.parts[0]; lastDstToken.sourceSpan.end = token.sourceSpan.end; } else { lastDstToken = token; dstTokens.push(lastDstToken); } } return dstTokens; } /** * @license * Copyright Google Inc. All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ var TreeError = /** @class */ (function (_super) { Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(TreeError, _super); function TreeError(elementName, span, msg) { var _this = _super.call(this, span, msg) || this; _this.elementName = elementName; return _this; } TreeError.create = function (elementName, span, msg) { return new TreeError(elementName, span, msg); }; return TreeError; }(ParseError)); var ParseTreeResult = /** @class */ (function () { function ParseTreeResult(rootNodes, errors) { this.rootNodes = rootNodes; this.errors = errors; } return ParseTreeResult; }()); var Parser$1 = /** @class */ (function () { function Parser(getTagDefinition) { this.getTagDefinition = getTagDefinition; } Parser.prototype.parse = function (source, url, parseExpansionForms, interpolationConfig) { if (parseExpansionForms === void 0) { parseExpansionForms = false; } if (interpolationConfig === void 0) { interpolationConfig = DEFAULT_INTERPOLATION_CONFIG; } var tokensAndErrors = tokenize(source, url, this.getTagDefinition, parseExpansionForms, interpolationConfig); var treeAndErrors = new _TreeBuilder(tokensAndErrors.tokens, this.getTagDefinition).build(); return new ParseTreeResult(treeAndErrors.rootNodes, tokensAndErrors.errors.concat(treeAndErrors.errors)); }; return Parser; }()); var _TreeBuilder = /** @class */ (function () { function _TreeBuilder(tokens, getTagDefinition) { this.tokens = tokens; this.getTagDefinition = getTagDefinition; this._index = -1; this._rootNodes = []; this._errors = []; this._elementStack = []; this._advance(); } _TreeBuilder.prototype.build = function () { while (this._peek.type !== TokenType$1.EOF) { if (this._peek.type === TokenType$1.TAG_OPEN_START) { this._consumeStartTag(this._advance()); } else if (this._peek.type === TokenType$1.TAG_CLOSE) { this._consumeEndTag(this._advance()); } else if (this._peek.type === TokenType$1.CDATA_START) { this._closeVoidElement(); this._consumeCdata(this._advance()); } else if (this._peek.type === TokenType$1.COMMENT_START) { this._closeVoidElement(); this._consumeComment(this._advance()); } else if (this._peek.type === TokenType$1.TEXT || this._peek.type === TokenType$1.RAW_TEXT || this._peek.type === TokenType$1.ESCAPABLE_RAW_TEXT) { this._closeVoidElement(); this._consumeText(this._advance()); } else if (this._peek.type === TokenType$1.EXPANSION_FORM_START) { this._consumeExpansion(this._advance()); } else { // Skip all other tokens... this._advance(); } } return new ParseTreeResult(this._rootNodes, this._errors); }; _TreeBuilder.prototype._advance = function () { var prev = this._peek; if (this._index < this.tokens.length - 1) { // Note: there is always an EOF token at the end this._index++; } this._peek = this.tokens[this._index]; return prev; }; _TreeBuilder.prototype._advanceIf = function (type) { if (this._peek.type === type) { return this._advance(); } return null; }; _TreeBuilder.prototype._consumeCdata = function (startToken) { this._consumeText(this._advance()); this._advanceIf(TokenType$1.CDATA_END); }; _TreeBuilder.prototype._consumeComment = function (token) { var text = this._advanceIf(TokenType$1.RAW_TEXT); this._advanceIf(TokenType$1.COMMENT_END); var value = text != null ? text.parts[0].trim() : null; this._addToParent(new Comment(value, token.sourceSpan)); }; _TreeBuilder.prototype._consumeExpansion = function (token) { var switchValue = this._advance(); var type = this._advance(); var cases = []; // read = while (this._peek.type === TokenType$1.EXPANSION_CASE_VALUE) { var expCase = this._parseExpansionCase(); if (!expCase) return; // error cases.push(expCase); } // read the final } if (this._peek.type !== TokenType$1.EXPANSION_FORM_END) { this._errors.push(TreeError.create(null, this._peek.sourceSpan, "Invalid ICU message. Missing '}'.")); return; } var sourceSpan = new ParseSourceSpan(token.sourceSpan.start, this._peek.sourceSpan.end); this._addToParent(new Expansion(switchValue.parts[0], type.parts[0], cases, sourceSpan, switchValue.sourceSpan)); this._advance(); }; _TreeBuilder.prototype._parseExpansionCase = function () { var value = this._advance(); // read { if (this._peek.type !== TokenType$1.EXPANSION_CASE_EXP_START) { this._errors.push(TreeError.create(null, this._peek.sourceSpan, "Invalid ICU message. Missing '{'.")); return null; } // read until } var start = this._advance(); var exp = this._collectExpansionExpTokens(start); if (!exp) return null; var end = this._advance(); exp.push(new Token$1(TokenType$1.EOF, [], end.sourceSpan)); // parse everything in between { and } var parsedExp = new _TreeBuilder(exp, this.getTagDefinition).build(); if (parsedExp.errors.length > 0) { this._errors = this._errors.concat(parsedExp.errors); return null; } var sourceSpan = new ParseSourceSpan(value.sourceSpan.start, end.sourceSpan.end); var expSourceSpan = new ParseSourceSpan(start.sourceSpan.start, end.sourceSpan.end); return new ExpansionCase(value.parts[0], parsedExp.rootNodes, sourceSpan, value.sourceSpan, expSourceSpan); }; _TreeBuilder.prototype._collectExpansionExpTokens = function (start) { var exp = []; var expansionFormStack = [TokenType$1.EXPANSION_CASE_EXP_START]; while (true) { if (this._peek.type === TokenType$1.EXPANSION_FORM_START || this._peek.type === TokenType$1.EXPANSION_CASE_EXP_START) { expansionFormStack.push(this._peek.type); } if (this._peek.type === TokenType$1.EXPANSION_CASE_EXP_END) { if (lastOnStack(expansionFormStack, TokenType$1.EXPANSION_CASE_EXP_START)) { expansionFormStack.pop(); if (expansionFormStack.length == 0) return exp; } else { this._errors.push(TreeError.create(null, start.sourceSpan, "Invalid ICU message. Missing '}'.")); return null; } } if (this._peek.type === TokenType$1.EXPANSION_FORM_END) { if (lastOnStack(expansionFormStack, TokenType$1.EXPANSION_FORM_START)) { expansionFormStack.pop(); } else { this._errors.push(TreeError.create(null, start.sourceSpan, "Invalid ICU message. Missing '}'.")); return null; } } if (this._peek.type === TokenType$1.EOF) { this._errors.push(TreeError.create(null, start.sourceSpan, "Invalid ICU message. Missing '}'.")); return null; } exp.push(this._advance()); } }; _TreeBuilder.prototype._consumeText = function (token) { var text = token.parts[0]; if (text.length > 0 && text[0] == '\n') { var parent_1 = this._getParentElement(); if (parent_1 != null && parent_1.children.length == 0 && this.getTagDefinition(parent_1.name).ignoreFirstLf) { text = text.substring(1); } } if (text.length > 0) { this._addToParent(new Text$2(text, token.sourceSpan)); } }; _TreeBuilder.prototype._closeVoidElement = function () { var el = this._getParentElement(); if (el && this.getTagDefinition(el.name).isVoid) { this._elementStack.pop(); } }; _TreeBuilder.prototype._consumeStartTag = function (startTagToken) { var prefix = startTagToken.parts[0]; var name = startTagToken.parts[1]; var attrs = []; while (this._peek.type === TokenType$1.ATTR_NAME) { attrs.push(this._consumeAttr(this._advance())); } var fullName = this._getElementFullName(prefix, name, this._getParentElement()); var selfClosing = false; // Note: There could have been a tokenizer error // so that we don't get a token for the end tag... if (this._peek.type === TokenType$1.TAG_OPEN_END_VOID) { this._advance(); selfClosing = true; var tagDef = this.getTagDefinition(fullName); if (!(tagDef.canSelfClose || getNsPrefix(fullName) !== null || tagDef.isVoid)) { this._errors.push(TreeError.create(fullName, startTagToken.sourceSpan, "Only void and foreign elements can be self closed \"" + startTagToken.parts[1] + "\"")); } } else if (this._peek.type === TokenType$1.TAG_OPEN_END) { this._advance(); selfClosing = false; } var end = this._peek.sourceSpan.start; var span = new ParseSourceSpan(startTagToken.sourceSpan.start, end); var el = new Element(fullName, attrs, [], span, span, undefined); this._pushElement(el); if (selfClosing) { this._popElement(fullName); el.endSourceSpan = span; } }; _TreeBuilder.prototype._pushElement = function (el) { var parentEl = this._getParentElement(); if (parentEl && this.getTagDefinition(parentEl.name).isClosedByChild(el.name)) { this._elementStack.pop(); } var tagDef = this.getTagDefinition(el.name); var _a = this._getParentElementSkippingContainers(), parent = _a.parent, container = _a.container; if (parent && tagDef.requireExtraParent(parent.name)) { var newParent = new Element(tagDef.parentToAdd, [], [], el.sourceSpan, el.startSourceSpan, el.endSourceSpan); this._insertBeforeContainer(parent, container, newParent); } this._addToParent(el); this._elementStack.push(el); }; _TreeBuilder.prototype._consumeEndTag = function (endTagToken) { var fullName = this._getElementFullName(endTagToken.parts[0], endTagToken.parts[1], this._getParentElement()); if (this._getParentElement()) { this._getParentElement().endSourceSpan = endTagToken.sourceSpan; } if (this.getTagDefinition(fullName).isVoid) { this._errors.push(TreeError.create(fullName, endTagToken.sourceSpan, "Void elements do not have end tags \"" + endTagToken.parts[1] + "\"")); } else if (!this._popElement(fullName)) { var errMsg = "Unexpected closing tag \"" + fullName + "\". It may happen when the tag has already been closed by another tag. For more info see https://www.w3.org/TR/html5/syntax.html#closing-elements-that-have-implied-end-tags"; this._errors.push(TreeError.create(fullName, endTagToken.sourceSpan, errMsg)); } }; _TreeBuilder.prototype._popElement = function (fullName) { for (var stackIndex = this._elementStack.length - 1; stackIndex >= 0; stackIndex--) { var el = this._elementStack[stackIndex]; if (el.name == fullName) { this._elementStack.splice(stackIndex, this._elementStack.length - stackIndex); return true; } if (!this.getTagDefinition(el.name).closedByParent) { return false; } } return false; }; _TreeBuilder.prototype._consumeAttr = function (attrName) { var fullName = mergeNsAndName(attrName.parts[0], attrName.parts[1]); var end = attrName.sourceSpan.end; var value = ''; var valueSpan = undefined; if (this._peek.type === TokenType$1.ATTR_VALUE) { var valueToken = this._advance(); value = valueToken.parts[0]; end = valueToken.sourceSpan.end; valueSpan = valueToken.sourceSpan; } return new Attribute(fullName, value, new ParseSourceSpan(attrName.sourceSpan.start, end), valueSpan); }; _TreeBuilder.prototype._getParentElement = function () { return this._elementStack.length > 0 ? this._elementStack[this._elementStack.length - 1] : null; }; /** * Returns the parent in the DOM and the container. * * `` elements are skipped as they are not rendered as DOM element. */ _TreeBuilder.prototype._getParentElementSkippingContainers = function () { var container = null; for (var i = this._elementStack.length - 1; i >= 0; i--) { if (!isNgContainer(this._elementStack[i].name)) { return { parent: this._elementStack[i], container: container }; } container = this._elementStack[i]; } return { parent: null, container: container }; }; _TreeBuilder.prototype._addToParent = function (node) { var parent = this._getParentElement(); if (parent != null) { parent.children.push(node); } else { this._rootNodes.push(node); } }; /** * Insert a node between the parent and the container. * When no container is given, the node is appended as a child of the parent. * Also updates the element stack accordingly. * * @internal */ _TreeBuilder.prototype._insertBeforeContainer = function (parent, container, node) { if (!container) { this._addToParent(node); this._elementStack.push(node); } else { if (parent) { // replace the container with the new node in the children var index = parent.children.indexOf(container); parent.children[index] = node; } else { this._rootNodes.push(node); } node.children.push(container); this._elementStack.splice(this._elementStack.indexOf(container), 0, node); } }; _TreeBuilder.prototype._getElementFullName = function (prefix, localName, parentElement) { if (prefix == null) { prefix = this.getTagDefinition(localName).implicitNamespacePrefix; if (prefix == null && parentElement != null) { prefix = getNsPrefix(parentElement.name); } } return mergeNsAndName(prefix, localName); }; return _TreeBuilder; }()); function lastOnStack(stack, element) { return stack.length > 0 && stack[stack.length - 1] === element; } /** * @license * Copyright Google Inc. All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ var HtmlParser = /** @class */ (function (_super) { Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(HtmlParser, _super); function HtmlParser() { return _super.call(this, getHtmlTagDefinition) || this; } HtmlParser.prototype.parse = function (source, url, parseExpansionForms, interpolationConfig) { if (parseExpansionForms === void 0) { parseExpansionForms = false; } if (interpolationConfig === void 0) { interpolationConfig = DEFAULT_INTERPOLATION_CONFIG; } return _super.prototype.parse.call(this, source, url, parseExpansionForms, interpolationConfig); }; return HtmlParser; }(Parser$1)); /** * @license * Copyright Google Inc. All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ var PRESERVE_WS_ATTR_NAME = 'ngPreserveWhitespaces'; var SKIP_WS_TRIM_TAGS = new Set(['pre', 'template', 'textarea', 'script', 'style']); // Equivalent to \s with \u00a0 (non-breaking space) excluded. // Based on https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp var WS_CHARS = ' \f\n\r\t\v\u1680\u180e\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff'; var NO_WS_REGEXP = new RegExp("[^" + WS_CHARS + "]"); var WS_REPLACE_REGEXP = new RegExp("[" + WS_CHARS + "]{2,}", 'g'); function hasPreserveWhitespacesAttr(attrs) { return attrs.some(function (attr) { return attr.name === PRESERVE_WS_ATTR_NAME; }); } /** * Angular Dart introduced &ngsp; as a placeholder for non-removable space, see: * https://github.com/dart-lang/angular/blob/0bb611387d29d65b5af7f9d2515ab571fd3fbee4/_tests/test/compiler/preserve_whitespace_test.dart#L25-L32 * In Angular Dart &ngsp; is converted to the 0xE500 PUA (Private Use Areas) unicode character * and later on replaced by a space. We are re-implementing the same idea here. */ function replaceNgsp(value) { // lexer is replacing the &ngsp; pseudo-entity with NGSP_UNICODE return value.replace(new RegExp(NGSP_UNICODE, 'g'), ' '); } /** * This visitor can walk HTML parse tree and remove / trim text nodes using the following rules: * - consider spaces, tabs and new lines as whitespace characters; * - drop text nodes consisting of whitespace characters only; * - for all other text nodes replace consecutive whitespace characters with one space; * - convert &ngsp; pseudo-entity to a single space; * * Removal and trimming of whitespaces have positive performance impact (less code to generate * while compiling templates, faster view creation). At the same time it can be "destructive" * in some cases (whitespaces can influence layout). Because of the potential of breaking layout * this visitor is not activated by default in Angular 5 and people need to explicitly opt-in for * whitespace removal. The default option for whitespace removal will be revisited in Angular 6 * and might be changed to "on" by default. */ var WhitespaceVisitor = /** @class */ (function () { function WhitespaceVisitor() { } WhitespaceVisitor.prototype.visitElement = function (element, context) { if (SKIP_WS_TRIM_TAGS.has(element.name) || hasPreserveWhitespacesAttr(element.attrs)) { // don't descent into elements where we need to preserve whitespaces // but still visit all attributes to eliminate one used as a market to preserve WS return new Element(element.name, visitAll(this, element.attrs), element.children, element.sourceSpan, element.startSourceSpan, element.endSourceSpan, element.i18n); } return new Element(element.name, element.attrs, visitAll(this, element.children), element.sourceSpan, element.startSourceSpan, element.endSourceSpan, element.i18n); }; WhitespaceVisitor.prototype.visitAttribute = function (attribute, context) { return attribute.name !== PRESERVE_WS_ATTR_NAME ? attribute : null; }; WhitespaceVisitor.prototype.visitText = function (text, context) { var isNotBlank = text.value.match(NO_WS_REGEXP); if (isNotBlank) { return new Text$2(replaceNgsp(text.value).replace(WS_REPLACE_REGEXP, ' '), text.sourceSpan, text.i18n); } return null; }; WhitespaceVisitor.prototype.visitComment = function (comment, context) { return comment; }; WhitespaceVisitor.prototype.visitExpansion = function (expansion, context) { return expansion; }; WhitespaceVisitor.prototype.visitExpansionCase = function (expansionCase, context) { return expansionCase; }; return WhitespaceVisitor; }()); function removeWhitespaces(htmlAstWithErrors) { return new ParseTreeResult(visitAll(new WhitespaceVisitor(), htmlAstWithErrors.rootNodes), htmlAstWithErrors.errors); } /** * @license * Copyright Google Inc. All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ // ================================================================================================= // ================================================================================================= // =========== S T O P - S T O P - S T O P - S T O P - S T O P - S T O P =========== // ================================================================================================= // ================================================================================================= // // DO NOT EDIT THIS LIST OF SECURITY SENSITIVE PROPERTIES WITHOUT A SECURITY REVIEW! // Reach out to mprobst for details. // // ================================================================================================= /** Map from tagName|propertyName SecurityContext. Properties applying to all tags use '*'. */ var _SECURITY_SCHEMA; function SECURITY_SCHEMA() { if (!_SECURITY_SCHEMA) { _SECURITY_SCHEMA = {}; // Case is insignificant below, all element and attribute names are lower-cased for lookup. registerContext(SecurityContext.HTML, [ 'iframe|srcdoc', '*|innerHTML', '*|outerHTML', ]); registerContext(SecurityContext.STYLE, ['*|style']); // NB: no SCRIPT contexts here, they are never allowed due to the parser stripping them. registerContext(SecurityContext.URL, [ '*|formAction', 'area|href', 'area|ping', 'audio|src', 'a|href', 'a|ping', 'blockquote|cite', 'body|background', 'del|cite', 'form|action', 'img|src', 'img|srcset', 'input|src', 'ins|cite', 'q|cite', 'source|src', 'source|srcset', 'track|src', 'video|poster', 'video|src', ]); registerContext(SecurityContext.RESOURCE_URL, [ 'applet|code', 'applet|codebase', 'base|href', 'embed|src', 'frame|src', 'head|profile', 'html|manifest', 'iframe|src', 'link|href', 'media|src', 'object|codebase', 'object|data', 'script|src', ]); } return _SECURITY_SCHEMA; } function registerContext(ctx, specs) { var e_1, _a; try { for (var specs_1 = Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__values"])(specs), specs_1_1 = specs_1.next(); !specs_1_1.done; specs_1_1 = specs_1.next()) { var spec = specs_1_1.value; _SECURITY_SCHEMA[spec.toLowerCase()] = ctx; } } catch (e_1_1) { e_1 = { error: e_1_1 }; } finally { try { if (specs_1_1 && !specs_1_1.done && (_a = specs_1.return)) _a.call(specs_1); } finally { if (e_1) throw e_1.error; } } } /** * @license * Copyright Google Inc. All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ var ElementSchemaRegistry = /** @class */ (function () { function ElementSchemaRegistry() { } return ElementSchemaRegistry; }()); /** * @license * Copyright Google Inc. All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ var BOOLEAN = 'boolean'; var NUMBER = 'number'; var STRING = 'string'; var OBJECT = 'object'; /** * This array represents the DOM schema. It encodes inheritance, properties, and events. * * ## Overview * * Each line represents one kind of element. The `element_inheritance` and properties are joined * using `element_inheritance|properties` syntax. * * ## Element Inheritance * * The `element_inheritance` can be further subdivided as `element1,element2,...^parentElement`. * Here the individual elements are separated by `,` (commas). Every element in the list * has identical properties. * * An `element` may inherit additional properties from `parentElement` If no `^parentElement` is * specified then `""` (blank) element is assumed. * * NOTE: The blank element inherits from root `[Element]` element, the super element of all * elements. * * NOTE an element prefix such as `:svg:` has no special meaning to the schema. * * ## Properties * * Each element has a set of properties separated by `,` (commas). Each property can be prefixed * by a special character designating its type: * * - (no prefix): property is a string. * - `*`: property represents an event. * - `!`: property is a boolean. * - `#`: property is a number. * - `%`: property is an object. * * ## Query * * The class creates an internal squas representation which allows to easily answer the query of * if a given property exist on a given element. * * NOTE: We don't yet support querying for types or events. * NOTE: This schema is auto extracted from `schema_extractor.ts` located in the test folder, * see dom_element_schema_registry_spec.ts */ // ================================================================================================= // ================================================================================================= // =========== S T O P - S T O P - S T O P - S T O P - S T O P - S T O P =========== // ================================================================================================= // ================================================================================================= // // DO NOT EDIT THIS DOM SCHEMA WITHOUT A SECURITY REVIEW! // // Newly added properties must be security reviewed and assigned an appropriate SecurityContext in // dom_security_schema.ts. Reach out to mprobst & rjamet for details. // // ================================================================================================= var SCHEMA = [ '[Element]|textContent,%classList,className,id,innerHTML,*beforecopy,*beforecut,*beforepaste,*copy,*cut,*paste,*search,*selectstart,*webkitfullscreenchange,*webkitfullscreenerror,*wheel,outerHTML,#scrollLeft,#scrollTop,slot' + /* added manually to avoid breaking changes */ ',*message,*mozfullscreenchange,*mozfullscreenerror,*mozpointerlockchange,*mozpointerlockerror,*webglcontextcreationerror,*webglcontextlost,*webglcontextrestored', '[HTMLElement]^[Element]|accessKey,contentEditable,dir,!draggable,!hidden,innerText,lang,*abort,*auxclick,*blur,*cancel,*canplay,*canplaythrough,*change,*click,*close,*contextmenu,*cuechange,*dblclick,*drag,*dragend,*dragenter,*dragleave,*dragover,*dragstart,*drop,*durationchange,*emptied,*ended,*error,*focus,*gotpointercapture,*input,*invalid,*keydown,*keypress,*keyup,*load,*loadeddata,*loadedmetadata,*loadstart,*lostpointercapture,*mousedown,*mouseenter,*mouseleave,*mousemove,*mouseout,*mouseover,*mouseup,*mousewheel,*pause,*play,*playing,*pointercancel,*pointerdown,*pointerenter,*pointerleave,*pointermove,*pointerout,*pointerover,*pointerup,*progress,*ratechange,*reset,*resize,*scroll,*seeked,*seeking,*select,*show,*stalled,*submit,*suspend,*timeupdate,*toggle,*volumechange,*waiting,outerText,!spellcheck,%style,#tabIndex,title,!translate', 'abbr,address,article,aside,b,bdi,bdo,cite,code,dd,dfn,dt,em,figcaption,figure,footer,header,i,kbd,main,mark,nav,noscript,rb,rp,rt,rtc,ruby,s,samp,section,small,strong,sub,sup,u,var,wbr^[HTMLElement]|accessKey,contentEditable,dir,!draggable,!hidden,innerText,lang,*abort,*auxclick,*blur,*cancel,*canplay,*canplaythrough,*change,*click,*close,*contextmenu,*cuechange,*dblclick,*drag,*dragend,*dragenter,*dragleave,*dragover,*dragstart,*drop,*durationchange,*emptied,*ended,*error,*focus,*gotpointercapture,*input,*invalid,*keydown,*keypress,*keyup,*load,*loadeddata,*loadedmetadata,*loadstart,*lostpointercapture,*mousedown,*mouseenter,*mouseleave,*mousemove,*mouseout,*mouseover,*mouseup,*mousewheel,*pause,*play,*playing,*pointercancel,*pointerdown,*pointerenter,*pointerleave,*pointermove,*pointerout,*pointerover,*pointerup,*progress,*ratechange,*reset,*resize,*scroll,*seeked,*seeking,*select,*show,*stalled,*submit,*suspend,*timeupdate,*toggle,*volumechange,*waiting,outerText,!spellcheck,%style,#tabIndex,title,!translate', 'media^[HTMLElement]|!autoplay,!controls,%controlsList,%crossOrigin,#currentTime,!defaultMuted,#defaultPlaybackRate,!disableRemotePlayback,!loop,!muted,*encrypted,*waitingforkey,#playbackRate,preload,src,%srcObject,#volume', ':svg:^[HTMLElement]|*abort,*auxclick,*blur,*cancel,*canplay,*canplaythrough,*change,*click,*close,*contextmenu,*cuechange,*dblclick,*drag,*dragend,*dragenter,*dragleave,*dragover,*dragstart,*drop,*durationchange,*emptied,*ended,*error,*focus,*gotpointercapture,*input,*invalid,*keydown,*keypress,*keyup,*load,*loadeddata,*loadedmetadata,*loadstart,*lostpointercapture,*mousedown,*mouseenter,*mouseleave,*mousemove,*mouseout,*mouseover,*mouseup,*mousewheel,*pause,*play,*playing,*pointercancel,*pointerdown,*pointerenter,*pointerleave,*pointermove,*pointerout,*pointerover,*pointerup,*progress,*ratechange,*reset,*resize,*scroll,*seeked,*seeking,*select,*show,*stalled,*submit,*suspend,*timeupdate,*toggle,*volumechange,*waiting,%style,#tabIndex', ':svg:graphics^:svg:|', ':svg:animation^:svg:|*begin,*end,*repeat', ':svg:geometry^:svg:|', ':svg:componentTransferFunction^:svg:|', ':svg:gradient^:svg:|', ':svg:textContent^:svg:graphics|', ':svg:textPositioning^:svg:textContent|', 'a^[HTMLElement]|charset,coords,download,hash,host,hostname,href,hreflang,name,password,pathname,ping,port,protocol,referrerPolicy,rel,rev,search,shape,target,text,type,username', 'area^[HTMLElement]|alt,coords,download,hash,host,hostname,href,!noHref,password,pathname,ping,port,protocol,referrerPolicy,rel,search,shape,target,username', 'audio^media|', 'br^[HTMLElement]|clear', 'base^[HTMLElement]|href,target', 'body^[HTMLElement]|aLink,background,bgColor,link,*beforeunload,*blur,*error,*focus,*hashchange,*languagechange,*load,*message,*offline,*online,*pagehide,*pageshow,*popstate,*rejectionhandled,*resize,*scroll,*storage,*unhandledrejection,*unload,text,vLink', 'button^[HTMLElement]|!autofocus,!disabled,formAction,formEnctype,formMethod,!formNoValidate,formTarget,name,type,value', 'canvas^[HTMLElement]|#height,#width', 'content^[HTMLElement]|select', 'dl^[HTMLElement]|!compact', 'datalist^[HTMLElement]|', 'details^[HTMLElement]|!open', 'dialog^[HTMLElement]|!open,returnValue', 'dir^[HTMLElement]|!compact', 'div^[HTMLElement]|align', 'embed^[HTMLElement]|align,height,name,src,type,width', 'fieldset^[HTMLElement]|!disabled,name', 'font^[HTMLElement]|color,face,size', 'form^[HTMLElement]|acceptCharset,action,autocomplete,encoding,enctype,method,name,!noValidate,target', 'frame^[HTMLElement]|frameBorder,longDesc,marginHeight,marginWidth,name,!noResize,scrolling,src', 'frameset^[HTMLElement]|cols,*beforeunload,*blur,*error,*focus,*hashchange,*languagechange,*load,*message,*offline,*online,*pagehide,*pageshow,*popstate,*rejectionhandled,*resize,*scroll,*storage,*unhandledrejection,*unload,rows', 'hr^[HTMLElement]|align,color,!noShade,size,width', 'head^[HTMLElement]|', 'h1,h2,h3,h4,h5,h6^[HTMLElement]|align', 'html^[HTMLElement]|version', 'iframe^[HTMLElement]|align,!allowFullscreen,frameBorder,height,longDesc,marginHeight,marginWidth,name,referrerPolicy,%sandbox,scrolling,src,srcdoc,width', 'img^[HTMLElement]|align,alt,border,%crossOrigin,#height,#hspace,!isMap,longDesc,lowsrc,name,referrerPolicy,sizes,src,srcset,useMap,#vspace,#width', 'input^[HTMLElement]|accept,align,alt,autocapitalize,autocomplete,!autofocus,!checked,!defaultChecked,defaultValue,dirName,!disabled,%files,formAction,formEnctype,formMethod,!formNoValidate,formTarget,#height,!incremental,!indeterminate,max,#maxLength,min,#minLength,!multiple,name,pattern,placeholder,!readOnly,!required,selectionDirection,#selectionEnd,#selectionStart,#size,src,step,type,useMap,value,%valueAsDate,#valueAsNumber,#width', 'li^[HTMLElement]|type,#value', 'label^[HTMLElement]|htmlFor', 'legend^[HTMLElement]|align', 'link^[HTMLElement]|as,charset,%crossOrigin,!disabled,href,hreflang,integrity,media,referrerPolicy,rel,%relList,rev,%sizes,target,type', 'map^[HTMLElement]|name', 'marquee^[HTMLElement]|behavior,bgColor,direction,height,#hspace,#loop,#scrollAmount,#scrollDelay,!trueSpeed,#vspace,width', 'menu^[HTMLElement]|!compact', 'meta^[HTMLElement]|content,httpEquiv,name,scheme', 'meter^[HTMLElement]|#high,#low,#max,#min,#optimum,#value', 'ins,del^[HTMLElement]|cite,dateTime', 'ol^[HTMLElement]|!compact,!reversed,#start,type', 'object^[HTMLElement]|align,archive,border,code,codeBase,codeType,data,!declare,height,#hspace,name,standby,type,useMap,#vspace,width', 'optgroup^[HTMLElement]|!disabled,label', 'option^[HTMLElement]|!defaultSelected,!disabled,label,!selected,text,value', 'output^[HTMLElement]|defaultValue,%htmlFor,name,value', 'p^[HTMLElement]|align', 'param^[HTMLElement]|name,type,value,valueType', 'picture^[HTMLElement]|', 'pre^[HTMLElement]|#width', 'progress^[HTMLElement]|#max,#value', 'q,blockquote,cite^[HTMLElement]|', 'script^[HTMLElement]|!async,charset,%crossOrigin,!defer,event,htmlFor,integrity,src,text,type', 'select^[HTMLElement]|!autofocus,!disabled,#length,!multiple,name,!required,#selectedIndex,#size,value', 'shadow^[HTMLElement]|', 'slot^[HTMLElement]|name', 'source^[HTMLElement]|media,sizes,src,srcset,type', 'span^[HTMLElement]|', 'style^[HTMLElement]|!disabled,media,type', 'caption^[HTMLElement]|align', 'th,td^[HTMLElement]|abbr,align,axis,bgColor,ch,chOff,#colSpan,headers,height,!noWrap,#rowSpan,scope,vAlign,width', 'col,colgroup^[HTMLElement]|align,ch,chOff,#span,vAlign,width', 'table^[HTMLElement]|align,bgColor,border,%caption,cellPadding,cellSpacing,frame,rules,summary,%tFoot,%tHead,width', 'tr^[HTMLElement]|align,bgColor,ch,chOff,vAlign', 'tfoot,thead,tbody^[HTMLElement]|align,ch,chOff,vAlign', 'template^[HTMLElement]|', 'textarea^[HTMLElement]|autocapitalize,!autofocus,#cols,defaultValue,dirName,!disabled,#maxLength,#minLength,name,placeholder,!readOnly,!required,#rows,selectionDirection,#selectionEnd,#selectionStart,value,wrap', 'title^[HTMLElement]|text', 'track^[HTMLElement]|!default,kind,label,src,srclang', 'ul^[HTMLElement]|!compact,type', 'unknown^[HTMLElement]|', 'video^media|#height,poster,#width', ':svg:a^:svg:graphics|', ':svg:animate^:svg:animation|', ':svg:animateMotion^:svg:animation|', ':svg:animateTransform^:svg:animation|', ':svg:circle^:svg:geometry|', ':svg:clipPath^:svg:graphics|', ':svg:defs^:svg:graphics|', ':svg:desc^:svg:|', ':svg:discard^:svg:|', ':svg:ellipse^:svg:geometry|', ':svg:feBlend^:svg:|', ':svg:feColorMatrix^:svg:|', ':svg:feComponentTransfer^:svg:|', ':svg:feComposite^:svg:|', ':svg:feConvolveMatrix^:svg:|', ':svg:feDiffuseLighting^:svg:|', ':svg:feDisplacementMap^:svg:|', ':svg:feDistantLight^:svg:|', ':svg:feDropShadow^:svg:|', ':svg:feFlood^:svg:|', ':svg:feFuncA^:svg:componentTransferFunction|', ':svg:feFuncB^:svg:componentTransferFunction|', ':svg:feFuncG^:svg:componentTransferFunction|', ':svg:feFuncR^:svg:componentTransferFunction|', ':svg:feGaussianBlur^:svg:|', ':svg:feImage^:svg:|', ':svg:feMerge^:svg:|', ':svg:feMergeNode^:svg:|', ':svg:feMorphology^:svg:|', ':svg:feOffset^:svg:|', ':svg:fePointLight^:svg:|', ':svg:feSpecularLighting^:svg:|', ':svg:feSpotLight^:svg:|', ':svg:feTile^:svg:|', ':svg:feTurbulence^:svg:|', ':svg:filter^:svg:|', ':svg:foreignObject^:svg:graphics|', ':svg:g^:svg:graphics|', ':svg:image^:svg:graphics|', ':svg:line^:svg:geometry|', ':svg:linearGradient^:svg:gradient|', ':svg:mpath^:svg:|', ':svg:marker^:svg:|', ':svg:mask^:svg:|', ':svg:metadata^:svg:|', ':svg:path^:svg:geometry|', ':svg:pattern^:svg:|', ':svg:polygon^:svg:geometry|', ':svg:polyline^:svg:geometry|', ':svg:radialGradient^:svg:gradient|', ':svg:rect^:svg:geometry|', ':svg:svg^:svg:graphics|#currentScale,#zoomAndPan', ':svg:script^:svg:|type', ':svg:set^:svg:animation|', ':svg:stop^:svg:|', ':svg:style^:svg:|!disabled,media,title,type', ':svg:switch^:svg:graphics|', ':svg:symbol^:svg:|', ':svg:tspan^:svg:textPositioning|', ':svg:text^:svg:textPositioning|', ':svg:textPath^:svg:textContent|', ':svg:title^:svg:|', ':svg:use^:svg:graphics|', ':svg:view^:svg:|#zoomAndPan', 'data^[HTMLElement]|value', 'keygen^[HTMLElement]|!autofocus,challenge,!disabled,form,keytype,name', 'menuitem^[HTMLElement]|type,label,icon,!disabled,!checked,radiogroup,!default', 'summary^[HTMLElement]|', 'time^[HTMLElement]|dateTime', ':svg:cursor^:svg:|', ]; var _ATTR_TO_PROP = { 'class': 'className', 'for': 'htmlFor', 'formaction': 'formAction', 'innerHtml': 'innerHTML', 'readonly': 'readOnly', 'tabindex': 'tabIndex', }; var DomElementSchemaRegistry = /** @class */ (function (_super) { Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(DomElementSchemaRegistry, _super); function DomElementSchemaRegistry() { var _this = _super.call(this) || this; _this._schema = {}; SCHEMA.forEach(function (encodedType) { var type = {}; var _a = Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__read"])(encodedType.split('|'), 2), strType = _a[0], strProperties = _a[1]; var properties = strProperties.split(','); var _b = Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__read"])(strType.split('^'), 2), typeNames = _b[0], superName = _b[1]; typeNames.split(',').forEach(function (tag) { return _this._schema[tag.toLowerCase()] = type; }); var superType = superName && _this._schema[superName.toLowerCase()]; if (superType) { Object.keys(superType).forEach(function (prop) { type[prop] = superType[prop]; }); } properties.forEach(function (property) { if (property.length > 0) { switch (property[0]) { case '*': // We don't yet support events. // If ever allowing to bind to events, GO THROUGH A SECURITY REVIEW, allowing events // will // almost certainly introduce bad XSS vulnerabilities. // type[property.substring(1)] = EVENT; break; case '!': type[property.substring(1)] = BOOLEAN; break; case '#': type[property.substring(1)] = NUMBER; break; case '%': type[property.substring(1)] = OBJECT; break; default: type[property] = STRING; } } }); }); return _this; } DomElementSchemaRegistry.prototype.hasProperty = function (tagName, propName, schemaMetas) { if (schemaMetas.some(function (schema) { return schema.name === NO_ERRORS_SCHEMA.name; })) { return true; } if (tagName.indexOf('-') > -1) { if (isNgContainer(tagName) || isNgContent(tagName)) { return false; } if (schemaMetas.some(function (schema) { return schema.name === CUSTOM_ELEMENTS_SCHEMA.name; })) { // Can't tell now as we don't know which properties a custom element will get // once it is instantiated return true; } } var elementProperties = this._schema[tagName.toLowerCase()] || this._schema['unknown']; return !!elementProperties[propName]; }; DomElementSchemaRegistry.prototype.hasElement = function (tagName, schemaMetas) { if (schemaMetas.some(function (schema) { return schema.name === NO_ERRORS_SCHEMA.name; })) { return true; } if (tagName.indexOf('-') > -1) { if (isNgContainer(tagName) || isNgContent(tagName)) { return true; } if (schemaMetas.some(function (schema) { return schema.name === CUSTOM_ELEMENTS_SCHEMA.name; })) { // Allow any custom elements return true; } } return !!this._schema[tagName.toLowerCase()]; }; /** * securityContext returns the security context for the given property on the given DOM tag. * * Tag and property name are statically known and cannot change at runtime, i.e. it is not * possible to bind a value into a changing attribute or tag name. * * The filtering is white list based. All attributes in the schema above are assumed to have the * 'NONE' security context, i.e. that they are safe inert string values. Only specific well known * attack vectors are assigned their appropriate context. */ DomElementSchemaRegistry.prototype.securityContext = function (tagName, propName, isAttribute) { if (isAttribute) { // NB: For security purposes, use the mapped property name, not the attribute name. propName = this.getMappedPropName(propName); } // Make sure comparisons are case insensitive, so that case differences between attribute and // property names do not have a security impact. tagName = tagName.toLowerCase(); propName = propName.toLowerCase(); var ctx = SECURITY_SCHEMA()[tagName + '|' + propName]; if (ctx) { return ctx; } ctx = SECURITY_SCHEMA()['*|' + propName]; return ctx ? ctx : SecurityContext.NONE; }; DomElementSchemaRegistry.prototype.getMappedPropName = function (propName) { return _ATTR_TO_PROP[propName] || propName; }; DomElementSchemaRegistry.prototype.getDefaultComponentElementName = function () { return 'ng-component'; }; DomElementSchemaRegistry.prototype.validateProperty = function (name) { if (name.toLowerCase().startsWith('on')) { var msg = "Binding to event property '" + name + "' is disallowed for security reasons, " + ("please use (" + name.slice(2) + ")=...") + ("\nIf '" + name + "' is a directive input, make sure the directive is imported by the") + " current module."; return { error: true, msg: msg }; } else { return { error: false }; } }; DomElementSchemaRegistry.prototype.validateAttribute = function (name) { if (name.toLowerCase().startsWith('on')) { var msg = "Binding to event attribute '" + name + "' is disallowed for security reasons, " + ("please use (" + name.slice(2) + ")=..."); return { error: true, msg: msg }; } else { return { error: false }; } }; DomElementSchemaRegistry.prototype.allKnownElementNames = function () { return Object.keys(this._schema); }; DomElementSchemaRegistry.prototype.normalizeAnimationStyleProperty = function (propName) { return dashCaseToCamelCase(propName); }; DomElementSchemaRegistry.prototype.normalizeAnimationStyleValue = function (camelCaseProp, userProvidedProp, val) { var unit = ''; var strVal = val.toString().trim(); var errorMsg = null; if (_isPixelDimensionStyle(camelCaseProp) && val !== 0 && val !== '0') { if (typeof val === 'number') { unit = 'px'; } else { var valAndSuffixMatch = val.match(/^[+-]?[\d\.]+([a-z]*)$/); if (valAndSuffixMatch && valAndSuffixMatch[1].length == 0) { errorMsg = "Please provide a CSS unit value for " + userProvidedProp + ":" + val; } } } return { error: errorMsg, value: strVal + unit }; }; return DomElementSchemaRegistry; }(ElementSchemaRegistry)); function _isPixelDimensionStyle(prop) { switch (prop) { case 'width': case 'height': case 'minWidth': case 'minHeight': case 'maxWidth': case 'maxHeight': case 'left': case 'top': case 'bottom': case 'right': case 'fontSize': case 'outlineWidth': case 'outlineOffset': case 'paddingTop': case 'paddingLeft': case 'paddingBottom': case 'paddingRight': case 'marginTop': case 'marginLeft': case 'marginBottom': case 'marginRight': case 'borderRadius': case 'borderWidth': case 'borderTopWidth': case 'borderLeftWidth': case 'borderRightWidth': case 'borderBottomWidth': case 'textIndent': return true; default: return false; } } /** * @license * Copyright Google Inc. All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ var PROPERTY_PARTS_SEPARATOR = '.'; var ATTRIBUTE_PREFIX = 'attr'; var CLASS_PREFIX = 'class'; var STYLE_PREFIX = 'style'; var ANIMATE_PROP_PREFIX = 'animate-'; /** * Parses bindings in templates and in the directive host area. */ var BindingParser = /** @class */ (function () { function BindingParser(_exprParser, _interpolationConfig, _schemaRegistry, pipes, errors) { this._exprParser = _exprParser; this._interpolationConfig = _interpolationConfig; this._schemaRegistry = _schemaRegistry; this.errors = errors; this.pipesByName = null; this._usedPipes = new Map(); // When the `pipes` parameter is `null`, do not check for used pipes // This is used in IVY when we might not know the available pipes at compile time if (pipes) { var pipesByName_1 = new Map(); pipes.forEach(function (pipe) { return pipesByName_1.set(pipe.name, pipe); }); this.pipesByName = pipesByName_1; } } Object.defineProperty(BindingParser.prototype, "interpolationConfig", { get: function () { return this._interpolationConfig; }, enumerable: true, configurable: true }); BindingParser.prototype.getUsedPipes = function () { return Array.from(this._usedPipes.values()); }; BindingParser.prototype.createBoundHostProperties = function (dirMeta, sourceSpan) { var _this = this; if (dirMeta.hostProperties) { var boundProps_1 = []; Object.keys(dirMeta.hostProperties).forEach(function (propName) { var expression = dirMeta.hostProperties[propName]; if (typeof expression === 'string') { _this.parsePropertyBinding(propName, expression, true, sourceSpan, [], boundProps_1); } else { _this._reportError("Value of the host property binding \"" + propName + "\" needs to be a string representing an expression but got \"" + expression + "\" (" + typeof expression + ")", sourceSpan); } }); return boundProps_1; } return null; }; BindingParser.prototype.createDirectiveHostPropertyAsts = function (dirMeta, elementSelector, sourceSpan) { var _this = this; var boundProps = this.createBoundHostProperties(dirMeta, sourceSpan); return boundProps && boundProps.map(function (prop) { return _this.createBoundElementProperty(elementSelector, prop); }); }; BindingParser.prototype.createDirectiveHostEventAsts = function (dirMeta, sourceSpan) { var _this = this; if (dirMeta.hostListeners) { var targetEvents_1 = []; Object.keys(dirMeta.hostListeners).forEach(function (propName) { var expression = dirMeta.hostListeners[propName]; if (typeof expression === 'string') { _this.parseEvent(propName, expression, sourceSpan, [], targetEvents_1); } else { _this._reportError("Value of the host listener \"" + propName + "\" needs to be a string representing an expression but got \"" + expression + "\" (" + typeof expression + ")", sourceSpan); } }); return targetEvents_1; } return null; }; BindingParser.prototype.parseInterpolation = function (value, sourceSpan) { var sourceInfo = sourceSpan.start.toString(); try { var ast = this._exprParser.parseInterpolation(value, sourceInfo, this._interpolationConfig); if (ast) this._reportExpressionParserErrors(ast.errors, sourceSpan); this._checkPipes(ast, sourceSpan); return ast; } catch (e) { this._reportError("" + e, sourceSpan); return this._exprParser.wrapLiteralPrimitive('ERROR', sourceInfo); } }; // Parse an inline template binding. ie `` BindingParser.prototype.parseInlineTemplateBinding = function (tplKey, tplValue, sourceSpan, targetMatchableAttrs, targetProps, targetVars) { var bindings = this._parseTemplateBindings(tplKey, tplValue, sourceSpan); for (var i = 0; i < bindings.length; i++) { var binding = bindings[i]; if (binding.keyIsVar) { targetVars.push(new ParsedVariable(binding.key, binding.name, sourceSpan)); } else if (binding.expression) { this._parsePropertyAst(binding.key, binding.expression, sourceSpan, targetMatchableAttrs, targetProps); } else { targetMatchableAttrs.push([binding.key, '']); this.parseLiteralAttr(binding.key, null, sourceSpan, targetMatchableAttrs, targetProps); } } }; BindingParser.prototype._parseTemplateBindings = function (tplKey, tplValue, sourceSpan) { var _this = this; var sourceInfo = sourceSpan.start.toString(); try { var bindingsResult = this._exprParser.parseTemplateBindings(tplKey, tplValue, sourceInfo); this._reportExpressionParserErrors(bindingsResult.errors, sourceSpan); bindingsResult.templateBindings.forEach(function (binding) { if (binding.expression) { _this._checkPipes(binding.expression, sourceSpan); } }); bindingsResult.warnings.forEach(function (warning) { _this._reportError(warning, sourceSpan, ParseErrorLevel.WARNING); }); return bindingsResult.templateBindings; } catch (e) { this._reportError("" + e, sourceSpan); return []; } }; BindingParser.prototype.parseLiteralAttr = function (name, value, sourceSpan, targetMatchableAttrs, targetProps) { if (isAnimationLabel(name)) { name = name.substring(1); if (value) { this._reportError("Assigning animation triggers via @prop=\"exp\" attributes with an expression is invalid." + " Use property bindings (e.g. [@prop]=\"exp\") or use an attribute without a value (e.g. @prop) instead.", sourceSpan, ParseErrorLevel.ERROR); } this._parseAnimation(name, value, sourceSpan, targetMatchableAttrs, targetProps); } else { targetProps.push(new ParsedProperty(name, this._exprParser.wrapLiteralPrimitive(value, ''), ParsedPropertyType.LITERAL_ATTR, sourceSpan)); } }; BindingParser.prototype.parsePropertyBinding = function (name, expression, isHost, sourceSpan, targetMatchableAttrs, targetProps) { var isAnimationProp = false; if (name.startsWith(ANIMATE_PROP_PREFIX)) { isAnimationProp = true; name = name.substring(ANIMATE_PROP_PREFIX.length); } else if (isAnimationLabel(name)) { isAnimationProp = true; name = name.substring(1); } if (isAnimationProp) { this._parseAnimation(name, expression, sourceSpan, targetMatchableAttrs, targetProps); } else { this._parsePropertyAst(name, this._parseBinding(expression, isHost, sourceSpan), sourceSpan, targetMatchableAttrs, targetProps); } }; BindingParser.prototype.parsePropertyInterpolation = function (name, value, sourceSpan, targetMatchableAttrs, targetProps) { var expr = this.parseInterpolation(value, sourceSpan); if (expr) { this._parsePropertyAst(name, expr, sourceSpan, targetMatchableAttrs, targetProps); return true; } return false; }; BindingParser.prototype._parsePropertyAst = function (name, ast, sourceSpan, targetMatchableAttrs, targetProps) { targetMatchableAttrs.push([name, ast.source]); targetProps.push(new ParsedProperty(name, ast, ParsedPropertyType.DEFAULT, sourceSpan)); }; BindingParser.prototype._parseAnimation = function (name, expression, sourceSpan, targetMatchableAttrs, targetProps) { // This will occur when a @trigger is not paired with an expression. // For animations it is valid to not have an expression since */void // states will be applied by angular when the element is attached/detached var ast = this._parseBinding(expression || 'undefined', false, sourceSpan); targetMatchableAttrs.push([name, ast.source]); targetProps.push(new ParsedProperty(name, ast, ParsedPropertyType.ANIMATION, sourceSpan)); }; BindingParser.prototype._parseBinding = function (value, isHostBinding, sourceSpan) { var sourceInfo = (sourceSpan && sourceSpan.start || '(unknown)').toString(); try { var ast = isHostBinding ? this._exprParser.parseSimpleBinding(value, sourceInfo, this._interpolationConfig) : this._exprParser.parseBinding(value, sourceInfo, this._interpolationConfig); if (ast) this._reportExpressionParserErrors(ast.errors, sourceSpan); this._checkPipes(ast, sourceSpan); return ast; } catch (e) { this._reportError("" + e, sourceSpan); return this._exprParser.wrapLiteralPrimitive('ERROR', sourceInfo); } }; BindingParser.prototype.createBoundElementProperty = function (elementSelector, boundProp) { if (boundProp.isAnimation) { return new BoundElementProperty(boundProp.name, 4 /* Animation */, SecurityContext.NONE, boundProp.expression, null, boundProp.sourceSpan); } var unit = null; var bindingType = undefined; var boundPropertyName = null; var parts = boundProp.name.split(PROPERTY_PARTS_SEPARATOR); var securityContexts = undefined; // Check check for special cases (prefix style, attr, class) if (parts.length > 1) { if (parts[0] == ATTRIBUTE_PREFIX) { boundPropertyName = parts[1]; this._validatePropertyOrAttributeName(boundPropertyName, boundProp.sourceSpan, true); securityContexts = calcPossibleSecurityContexts(this._schemaRegistry, elementSelector, boundPropertyName, true); var nsSeparatorIdx = boundPropertyName.indexOf(':'); if (nsSeparatorIdx > -1) { var ns = boundPropertyName.substring(0, nsSeparatorIdx); var name_1 = boundPropertyName.substring(nsSeparatorIdx + 1); boundPropertyName = mergeNsAndName(ns, name_1); } bindingType = 1 /* Attribute */; } else if (parts[0] == CLASS_PREFIX) { boundPropertyName = parts[1]; bindingType = 2 /* Class */; securityContexts = [SecurityContext.NONE]; } else if (parts[0] == STYLE_PREFIX) { unit = parts.length > 2 ? parts[2] : null; boundPropertyName = parts[1]; bindingType = 3 /* Style */; securityContexts = [SecurityContext.STYLE]; } } // If not a special case, use the full property name if (boundPropertyName === null) { boundPropertyName = this._schemaRegistry.getMappedPropName(boundProp.name); securityContexts = calcPossibleSecurityContexts(this._schemaRegistry, elementSelector, boundPropertyName, false); bindingType = 0 /* Property */; this._validatePropertyOrAttributeName(boundPropertyName, boundProp.sourceSpan, false); } return new BoundElementProperty(boundPropertyName, bindingType, securityContexts[0], boundProp.expression, unit, boundProp.sourceSpan); }; BindingParser.prototype.parseEvent = function (name, expression, sourceSpan, targetMatchableAttrs, targetEvents) { if (isAnimationLabel(name)) { name = name.substr(1); this._parseAnimationEvent(name, expression, sourceSpan, targetEvents); } else { this._parseRegularEvent(name, expression, sourceSpan, targetMatchableAttrs, targetEvents); } }; BindingParser.prototype._parseAnimationEvent = function (name, expression, sourceSpan, targetEvents) { var matches = splitAtPeriod(name, [name, '']); var eventName = matches[0]; var phase = matches[1].toLowerCase(); if (phase) { switch (phase) { case 'start': case 'done': var ast = this._parseAction(expression, sourceSpan); targetEvents.push(new ParsedEvent(eventName, phase, 1 /* Animation */, ast, sourceSpan)); break; default: this._reportError("The provided animation output phase value \"" + phase + "\" for \"@" + eventName + "\" is not supported (use start or done)", sourceSpan); break; } } else { this._reportError("The animation trigger output event (@" + eventName + ") is missing its phase value name (start or done are currently supported)", sourceSpan); } }; BindingParser.prototype._parseRegularEvent = function (name, expression, sourceSpan, targetMatchableAttrs, targetEvents) { // long format: 'target: eventName' var _a = Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__read"])(splitAtColon(name, [null, name]), 2), target = _a[0], eventName = _a[1]; var ast = this._parseAction(expression, sourceSpan); targetMatchableAttrs.push([name, ast.source]); targetEvents.push(new ParsedEvent(eventName, target, 0 /* Regular */, ast, sourceSpan)); // Don't detect directives for event names for now, // so don't add the event name to the matchableAttrs }; BindingParser.prototype._parseAction = function (value, sourceSpan) { var sourceInfo = (sourceSpan && sourceSpan.start || '(unknown').toString(); try { var ast = this._exprParser.parseAction(value, sourceInfo, this._interpolationConfig); if (ast) { this._reportExpressionParserErrors(ast.errors, sourceSpan); } if (!ast || ast.ast instanceof EmptyExpr) { this._reportError("Empty expressions are not allowed", sourceSpan); return this._exprParser.wrapLiteralPrimitive('ERROR', sourceInfo); } this._checkPipes(ast, sourceSpan); return ast; } catch (e) { this._reportError("" + e, sourceSpan); return this._exprParser.wrapLiteralPrimitive('ERROR', sourceInfo); } }; BindingParser.prototype._reportError = function (message, sourceSpan, level) { if (level === void 0) { level = ParseErrorLevel.ERROR; } this.errors.push(new ParseError(sourceSpan, message, level)); }; BindingParser.prototype._reportExpressionParserErrors = function (errors, sourceSpan) { var e_1, _a; try { for (var errors_1 = Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__values"])(errors), errors_1_1 = errors_1.next(); !errors_1_1.done; errors_1_1 = errors_1.next()) { var error$$1 = errors_1_1.value; this._reportError(error$$1.message, sourceSpan); } } catch (e_1_1) { e_1 = { error: e_1_1 }; } finally { try { if (errors_1_1 && !errors_1_1.done && (_a = errors_1.return)) _a.call(errors_1); } finally { if (e_1) throw e_1.error; } } }; // Make sure all the used pipes are known in `this.pipesByName` BindingParser.prototype._checkPipes = function (ast, sourceSpan) { var _this = this; if (ast && this.pipesByName) { var collector = new PipeCollector(); ast.visit(collector); collector.pipes.forEach(function (ast, pipeName) { var pipeMeta = _this.pipesByName.get(pipeName); if (!pipeMeta) { _this._reportError("The pipe '" + pipeName + "' could not be found", new ParseSourceSpan(sourceSpan.start.moveBy(ast.span.start), sourceSpan.start.moveBy(ast.span.end))); } else { _this._usedPipes.set(pipeName, pipeMeta); } }); } }; /** * @param propName the name of the property / attribute * @param sourceSpan * @param isAttr true when binding to an attribute */ BindingParser.prototype._validatePropertyOrAttributeName = function (propName, sourceSpan, isAttr) { var report = isAttr ? this._schemaRegistry.validateAttribute(propName) : this._schemaRegistry.validateProperty(propName); if (report.error) { this._reportError(report.msg, sourceSpan, ParseErrorLevel.ERROR); } }; return BindingParser; }()); var PipeCollector = /** @class */ (function (_super) { Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(PipeCollector, _super); function PipeCollector() { var _this = _super !== null && _super.apply(this, arguments) || this; _this.pipes = new Map(); return _this; } PipeCollector.prototype.visitPipe = function (ast, context) { this.pipes.set(ast.name, ast); ast.exp.visit(this); this.visitAll(ast.args, context); return null; }; return PipeCollector; }(RecursiveAstVisitor$1)); function isAnimationLabel(name) { return name[0] == '@'; } function calcPossibleSecurityContexts(registry, selector, propName, isAttribute) { var ctxs = []; CssSelector.parse(selector).forEach(function (selector) { var elementNames = selector.element ? [selector.element] : registry.allKnownElementNames(); var notElementNames = new Set(selector.notSelectors.filter(function (selector) { return selector.isElementSelector(); }) .map(function (selector) { return selector.element; })); var possibleElementNames = elementNames.filter(function (elementName) { return !notElementNames.has(elementName); }); ctxs.push.apply(ctxs, Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__spread"])(possibleElementNames.map(function (elementName) { return registry.securityContext(elementName, propName, isAttribute); }))); }); return ctxs.length === 0 ? [SecurityContext.NONE] : Array.from(new Set(ctxs)).sort(); } /** * @license * Copyright Google Inc. All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ var Text$3 = /** @class */ (function () { function Text(value, sourceSpan) { this.value = value; this.sourceSpan = sourceSpan; } Text.prototype.visit = function (visitor) { return visitor.visitText(this); }; return Text; }()); var BoundText = /** @class */ (function () { function BoundText(value, sourceSpan, i18n) { this.value = value; this.sourceSpan = sourceSpan; this.i18n = i18n; } BoundText.prototype.visit = function (visitor) { return visitor.visitBoundText(this); }; return BoundText; }()); var TextAttribute = /** @class */ (function () { function TextAttribute(name, value, sourceSpan, valueSpan, i18n) { this.name = name; this.value = value; this.sourceSpan = sourceSpan; this.valueSpan = valueSpan; this.i18n = i18n; } TextAttribute.prototype.visit = function (visitor) { return visitor.visitTextAttribute(this); }; return TextAttribute; }()); var BoundAttribute = /** @class */ (function () { function BoundAttribute(name, type, securityContext, value, unit, sourceSpan, i18n) { this.name = name; this.type = type; this.securityContext = securityContext; this.value = value; this.unit = unit; this.sourceSpan = sourceSpan; this.i18n = i18n; } BoundAttribute.fromBoundElementProperty = function (prop, i18n) { return new BoundAttribute(prop.name, prop.type, prop.securityContext, prop.value, prop.unit, prop.sourceSpan, i18n); }; BoundAttribute.prototype.visit = function (visitor) { return visitor.visitBoundAttribute(this); }; return BoundAttribute; }()); var BoundEvent = /** @class */ (function () { function BoundEvent(name, type, handler, target, phase, sourceSpan) { this.name = name; this.type = type; this.handler = handler; this.target = target; this.phase = phase; this.sourceSpan = sourceSpan; } BoundEvent.fromParsedEvent = function (event) { var target = event.type === 0 /* Regular */ ? event.targetOrPhase : null; var phase = event.type === 1 /* Animation */ ? event.targetOrPhase : null; return new BoundEvent(event.name, event.type, event.handler, target, phase, event.sourceSpan); }; BoundEvent.prototype.visit = function (visitor) { return visitor.visitBoundEvent(this); }; return BoundEvent; }()); var Element$1 = /** @class */ (function () { function Element(name, attributes, inputs, outputs, children, references, sourceSpan, startSourceSpan, endSourceSpan, i18n) { this.name = name; this.attributes = attributes; this.inputs = inputs; this.outputs = outputs; this.children = children; this.references = references; this.sourceSpan = sourceSpan; this.startSourceSpan = startSourceSpan; this.endSourceSpan = endSourceSpan; this.i18n = i18n; } Element.prototype.visit = function (visitor) { return visitor.visitElement(this); }; return Element; }()); var Template = /** @class */ (function () { function Template(tagName, attributes, inputs, outputs, children, references, variables, sourceSpan, startSourceSpan, endSourceSpan, i18n) { this.tagName = tagName; this.attributes = attributes; this.inputs = inputs; this.outputs = outputs; this.children = children; this.references = references; this.variables = variables; this.sourceSpan = sourceSpan; this.startSourceSpan = startSourceSpan; this.endSourceSpan = endSourceSpan; this.i18n = i18n; } Template.prototype.visit = function (visitor) { return visitor.visitTemplate(this); }; return Template; }()); var Content = /** @class */ (function () { function Content(selector, attributes, sourceSpan, i18n) { this.selector = selector; this.attributes = attributes; this.sourceSpan = sourceSpan; this.i18n = i18n; } Content.prototype.visit = function (visitor) { return visitor.visitContent(this); }; return Content; }()); var Variable = /** @class */ (function () { function Variable(name, value, sourceSpan) { this.name = name; this.value = value; this.sourceSpan = sourceSpan; } Variable.prototype.visit = function (visitor) { return visitor.visitVariable(this); }; return Variable; }()); var Reference = /** @class */ (function () { function Reference(name, value, sourceSpan) { this.name = name; this.value = value; this.sourceSpan = sourceSpan; } Reference.prototype.visit = function (visitor) { return visitor.visitReference(this); }; return Reference; }()); var Icu$1 = /** @class */ (function () { function Icu(vars, placeholders, sourceSpan, i18n) { this.vars = vars; this.placeholders = placeholders; this.sourceSpan = sourceSpan; this.i18n = i18n; } Icu.prototype.visit = function (visitor) { return visitor.visitIcu(this); }; return Icu; }()); function visitAll$1(visitor, nodes) { var e_1, _a, e_2, _b; var result = []; if (visitor.visit) { try { for (var nodes_1 = Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__values"])(nodes), nodes_1_1 = nodes_1.next(); !nodes_1_1.done; nodes_1_1 = nodes_1.next()) { var node = nodes_1_1.value; var newNode = visitor.visit(node) || node.visit(visitor); } } catch (e_1_1) { e_1 = { error: e_1_1 }; } finally { try { if (nodes_1_1 && !nodes_1_1.done && (_a = nodes_1.return)) _a.call(nodes_1); } finally { if (e_1) throw e_1.error; } } } else { try { for (var nodes_2 = Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__values"])(nodes), nodes_2_1 = nodes_2.next(); !nodes_2_1.done; nodes_2_1 = nodes_2.next()) { var node = nodes_2_1.value; var newNode = node.visit(visitor); if (newNode) { result.push(newNode); } } } catch (e_2_1) { e_2 = { error: e_2_1 }; } finally { try { if (nodes_2_1 && !nodes_2_1.done && (_b = nodes_2.return)) _b.call(nodes_2); } finally { if (e_2) throw e_2.error; } } } return result; } /** * @license * Copyright Google Inc. All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ var StyleWithImports = /** @class */ (function () { function StyleWithImports(style, styleUrls) { this.style = style; this.styleUrls = styleUrls; } return StyleWithImports; }()); function isStyleUrlResolvable(url) { if (url == null || url.length === 0 || url[0] == '/') return false; var schemeMatch = url.match(URL_WITH_SCHEMA_REGEXP); return schemeMatch === null || schemeMatch[1] == 'package' || schemeMatch[1] == 'asset'; } /** * Rewrites stylesheets by resolving and removing the @import urls that * are either relative or don't have a `package:` scheme */ function extractStyleUrls(resolver, baseUrl, cssText) { var foundUrls = []; var modifiedCssText = cssText.replace(CSS_STRIPPABLE_COMMENT_REGEXP, '') .replace(CSS_IMPORT_REGEXP, function () { var m = []; for (var _i = 0; _i < arguments.length; _i++) { m[_i] = arguments[_i]; } var url = m[1] || m[2]; if (!isStyleUrlResolvable(url)) { // Do not attempt to resolve non-package absolute URLs with URI // scheme return m[0]; } foundUrls.push(resolver.resolve(baseUrl, url)); return ''; }); return new StyleWithImports(modifiedCssText, foundUrls); } var CSS_IMPORT_REGEXP = /@import\s+(?:url\()?\s*(?:(?:['"]([^'"]*))|([^;\)\s]*))[^;]*;?/g; var CSS_STRIPPABLE_COMMENT_REGEXP = /\/\*(?!#\s*(?:sourceURL|sourceMappingURL)=)[\s\S]+?\*\//g; var URL_WITH_SCHEMA_REGEXP = /^([^:/?#]+):/; /** * @license * Copyright Google Inc. All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ var NG_CONTENT_SELECT_ATTR = 'select'; var LINK_ELEMENT = 'link'; var LINK_STYLE_REL_ATTR = 'rel'; var LINK_STYLE_HREF_ATTR = 'href'; var LINK_STYLE_REL_VALUE = 'stylesheet'; var STYLE_ELEMENT = 'style'; var SCRIPT_ELEMENT = 'script'; var NG_NON_BINDABLE_ATTR = 'ngNonBindable'; var NG_PROJECT_AS = 'ngProjectAs'; function preparseElement(ast) { var selectAttr = null; var hrefAttr = null; var relAttr = null; var nonBindable = false; var projectAs = ''; ast.attrs.forEach(function (attr) { var lcAttrName = attr.name.toLowerCase(); if (lcAttrName == NG_CONTENT_SELECT_ATTR) { selectAttr = attr.value; } else if (lcAttrName == LINK_STYLE_HREF_ATTR) { hrefAttr = attr.value; } else if (lcAttrName == LINK_STYLE_REL_ATTR) { relAttr = attr.value; } else if (attr.name == NG_NON_BINDABLE_ATTR) { nonBindable = true; } else if (attr.name == NG_PROJECT_AS) { if (attr.value.length > 0) { projectAs = attr.value; } } }); selectAttr = normalizeNgContentSelect(selectAttr); var nodeName = ast.name.toLowerCase(); var type = PreparsedElementType.OTHER; if (isNgContent(nodeName)) { type = PreparsedElementType.NG_CONTENT; } else if (nodeName == STYLE_ELEMENT) { type = PreparsedElementType.STYLE; } else if (nodeName == SCRIPT_ELEMENT) { type = PreparsedElementType.SCRIPT; } else if (nodeName == LINK_ELEMENT && relAttr == LINK_STYLE_REL_VALUE) { type = PreparsedElementType.STYLESHEET; } return new PreparsedElement(type, selectAttr, hrefAttr, nonBindable, projectAs); } var PreparsedElementType; (function (PreparsedElementType) { PreparsedElementType[PreparsedElementType["NG_CONTENT"] = 0] = "NG_CONTENT"; PreparsedElementType[PreparsedElementType["STYLE"] = 1] = "STYLE"; PreparsedElementType[PreparsedElementType["STYLESHEET"] = 2] = "STYLESHEET"; PreparsedElementType[PreparsedElementType["SCRIPT"] = 3] = "SCRIPT"; PreparsedElementType[PreparsedElementType["OTHER"] = 4] = "OTHER"; })(PreparsedElementType || (PreparsedElementType = {})); var PreparsedElement = /** @class */ (function () { function PreparsedElement(type, selectAttr, hrefAttr, nonBindable, projectAs) { this.type = type; this.selectAttr = selectAttr; this.hrefAttr = hrefAttr; this.nonBindable = nonBindable; this.projectAs = projectAs; } return PreparsedElement; }()); function normalizeNgContentSelect(selectAttr) { if (selectAttr === null || selectAttr.length === 0) { return '*'; } return selectAttr; } /** * @license * Copyright Google Inc. All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ var BIND_NAME_REGEXP = /^(?:(?:(?:(bind-)|(let-)|(ref-|#)|(on-)|(bindon-)|(@))(.+))|\[\(([^\)]+)\)\]|\[([^\]]+)\]|\(([^\)]+)\))$/; // Group 1 = "bind-" var KW_BIND_IDX = 1; // Group 2 = "let-" var KW_LET_IDX = 2; // Group 3 = "ref-/#" var KW_REF_IDX = 3; // Group 4 = "on-" var KW_ON_IDX = 4; // Group 5 = "bindon-" var KW_BINDON_IDX = 5; // Group 6 = "@" var KW_AT_IDX = 6; // Group 7 = the identifier after "bind-", "let-", "ref-/#", "on-", "bindon-" or "@" var IDENT_KW_IDX = 7; // Group 8 = identifier inside [()] var IDENT_BANANA_BOX_IDX = 8; // Group 9 = identifier inside [] var IDENT_PROPERTY_IDX = 9; // Group 10 = identifier inside () var IDENT_EVENT_IDX = 10; var TEMPLATE_ATTR_PREFIX = '*'; function htmlAstToRender3Ast(htmlNodes, bindingParser) { var transformer = new HtmlAstToIvyAst(bindingParser); var ivyNodes = visitAll(transformer, htmlNodes); // Errors might originate in either the binding parser or the html to ivy transformer var allErrors = bindingParser.errors.concat(transformer.errors); var errors = allErrors.filter(function (e) { return e.level === ParseErrorLevel.ERROR; }); if (errors.length > 0) { var errorString = errors.join('\n'); throw syntaxError("Template parse errors:\n" + errorString, errors); } return { nodes: ivyNodes, errors: allErrors, }; } var HtmlAstToIvyAst = /** @class */ (function () { function HtmlAstToIvyAst(bindingParser) { this.bindingParser = bindingParser; this.errors = []; } // HTML visitor HtmlAstToIvyAst.prototype.visitElement = function (element) { var _this = this; var e_1, _a; var preparsedElement = preparseElement(element); if (preparsedElement.type === PreparsedElementType.SCRIPT || preparsedElement.type === PreparsedElementType.STYLE) { // Skipping