diff --git a/ApiApp/Startup.cs b/ApiApp/Startup.cs index 6053d53..50ce1ce 100644 --- a/ApiApp/Startup.cs +++ b/ApiApp/Startup.cs @@ -24,7 +24,7 @@ public void ConfigureServices(IServiceCollection services) options.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme; }).AddJwtBearer(o => { - o.Authority = "http://localhost:5000"; + o.Authority = Configuration["IdentityServerAddress"]; o.Audience = "apiApp"; o.RequireHttpsMetadata = false; }); @@ -33,7 +33,7 @@ public void ConfigureServices(IServiceCollection services) { options.AddPolicy("default", policy => { - policy.WithOrigins("http://localhost:5002") + policy.WithOrigins(Configuration["ClientAddress"]) .AllowAnyHeader() .AllowAnyMethod(); }); diff --git a/ApiApp/appsettings.json b/ApiApp/appsettings.json index 5766595..f63c144 100644 --- a/ApiApp/appsettings.json +++ b/ApiApp/appsettings.json @@ -4,5 +4,7 @@ "LogLevel": { "Default": "Warning" } - } + }, + "IdentityServerAddress": "http://localhost:5000", + "ClientAddress": "http://localhost:5002" } diff --git a/ClientApp/ClientApp/app/app.module.browser.ts b/ClientApp/ClientApp/app/app.module.browser.ts index 911f987..5f96bca 100644 --- a/ClientApp/ClientApp/app/app.module.browser.ts +++ b/ClientApp/ClientApp/app/app.module.browser.ts @@ -10,10 +10,23 @@ import { AppComponent } from './components/app/app.component'; AppModuleShared ], providers: [ + { provide: 'ORIGIN_URL', useFactory: getBaseUrl }, + { provide: 'API_URL', useFactory: apiUrlFactory }, + { provide: 'IDENTITY_URL', useFactory: identityUrlFactory }, AppModuleShared ] }) export class AppModule { } +export function getBaseUrl() { + return document.getElementsByTagName('base')[0].href; +} + +export function apiUrlFactory() { + return (window as any).url_Config.apiUrl; +} +export function identityUrlFactory() { + return (window as any).url_Config.identityUrl; +} \ No newline at end of file diff --git a/ClientApp/ClientApp/app/app.module.shared.ts b/ClientApp/ClientApp/app/app.module.shared.ts index 3983b7e..2c13f1f 100644 --- a/ClientApp/ClientApp/app/app.module.shared.ts +++ b/ClientApp/ClientApp/app/app.module.shared.ts @@ -39,18 +39,9 @@ import { AuthService } from './components/services/auth.service'; ], providers: [ AuthService, - OidcSecurityService, - { provide: 'ORIGIN_URL', useFactory: getBaseUrl }, - { provide: 'API_URL', useFactory: getApiUrl } + OidcSecurityService ] }) export class AppModuleShared { } -export function getBaseUrl() { - return document.getElementsByTagName('base')[0].href; -} - -export function getApiUrl() { - return "http://localhost:5001/api/"; -} diff --git a/ClientApp/ClientApp/app/components/services/auth.service.ts b/ClientApp/ClientApp/app/components/services/auth.service.ts index 2d1dfbd..34d1980 100644 --- a/ClientApp/ClientApp/app/components/services/auth.service.ts +++ b/ClientApp/ClientApp/app/components/services/auth.service.ts @@ -1,4 +1,4 @@ -import { Injectable, Component, OnInit, OnDestroy } from '@angular/core'; +import { Injectable, Component, OnInit, OnDestroy, Inject } from '@angular/core'; import { Http, Headers, RequestOptions, Response } from '@angular/http'; import { Observable } from 'rxjs/Rx'; import { Subscription } from 'rxjs/Subscription'; @@ -11,15 +11,17 @@ export class AuthService implements OnInit, OnDestroy { isAuthorized: boolean; constructor(public oidcSecurityService: OidcSecurityService, - private http: Http) { - + private http: Http, + @Inject('ORIGIN_URL') originUrl: string, + @Inject('IDENTITY_URL') identityUrl: string + ) { const openIdImplicitFlowConfiguration = new OpenIDImplicitFlowConfiguration(); - openIdImplicitFlowConfiguration.stsServer = 'http://localhost:5000'; - openIdImplicitFlowConfiguration.redirect_url = 'http://localhost:5002/callback'; + openIdImplicitFlowConfiguration.stsServer = identityUrl; + openIdImplicitFlowConfiguration.redirect_url = originUrl + 'callback'; openIdImplicitFlowConfiguration.client_id = 'ng'; openIdImplicitFlowConfiguration.response_type = 'id_token token'; openIdImplicitFlowConfiguration.scope = 'openid profile apiApp'; - openIdImplicitFlowConfiguration.post_logout_redirect_uri = 'http://localhost:5002/home'; + openIdImplicitFlowConfiguration.post_logout_redirect_uri = originUrl + 'home'; openIdImplicitFlowConfiguration.startup_route = '/home'; openIdImplicitFlowConfiguration.forbidden_route = '/forbidden'; openIdImplicitFlowConfiguration.unauthorized_route = '/unauthorized'; diff --git a/ClientApp/ClientApp/boot.server.ts b/ClientApp/ClientApp/boot.server.ts index 991c0f3..166bcb1 100644 --- a/ClientApp/ClientApp/boot.server.ts +++ b/ClientApp/ClientApp/boot.server.ts @@ -14,6 +14,10 @@ export default createServerRenderer(params => { { provide: INITIAL_CONFIG, useValue: { document: '', url: params.url } }, { provide: APP_BASE_HREF, useValue: params.baseUrl }, { provide: 'BASE_URL', useValue: params.origin + params.baseUrl }, + { provide: 'ORIGIN_URL', useValue: params.origin + params.baseUrl }, + { provide: 'API_URL', useValue: params.data.apiUrl }, + { provide: 'IDENTITY_URL', useValue: params.data.identityUrl }, + { provide: 'URL_CONFIG', useValue: params.data} ]; return platformDynamicServer(providers).bootstrapModule(AppModule).then(moduleRef => { @@ -28,7 +32,8 @@ export default createServerRenderer(params => { // completing the request in case there's an error to report setImmediate(() => { resolve({ - html: state.renderToString() + html: state.renderToString(), + globals: {url_Config: params.data} }); moduleRef.destroy(); }); diff --git a/ClientApp/ClientApp/dist/main-server.js b/ClientApp/ClientApp/dist/main-server.js index 19c8855..d8ebe33 100644 --- a/ClientApp/ClientApp/dist/main-server.js +++ b/ClientApp/ClientApp/dist/main-server.js @@ -63,7 +63,7 @@ /******/ __webpack_require__.p = "dist/"; /******/ /******/ // Load entry module and return exports -/******/ return __webpack_require__(__webpack_require__.s = 100); +/******/ return __webpack_require__(__webpack_require__.s = 108); /******/ }) /************************************************************************/ /******/ ([ @@ -120,8 +120,8 @@ module.exports = (__webpack_require__(1))(92); "use strict"; -var AsyncAction_1 = __webpack_require__(20); -var AsyncScheduler_1 = __webpack_require__(21); +var AsyncAction_1 = __webpack_require__(21); +var AsyncScheduler_1 = __webpack_require__(22); /** * * Async Scheduler @@ -468,36 +468,154 @@ module.exports = (__webpack_require__(1))(4); /* 13 */ /***/ (function(module, exports, __webpack_require__) { -module.exports = (__webpack_require__(1))(34); +module.exports = (__webpack_require__(1))(7); /***/ }), /* 14 */ /***/ (function(module, exports, __webpack_require__) { -module.exports = (__webpack_require__(1))(11); +module.exports = (__webpack_require__(1))(34); /***/ }), /* 15 */ -/***/ (function(module, exports, __webpack_require__) { +/***/ (function(module, __webpack_exports__, __webpack_require__) { -module.exports = (__webpack_require__(1))(18); +"use strict"; +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return AuthService; }); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__angular_core__ = __webpack_require__(10); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__angular_core___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0__angular_core__); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__angular_http__ = __webpack_require__(30); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__angular_http___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1__angular_http__); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_angular_auth_oidc_client__ = __webpack_require__(57); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_angular_auth_oidc_client___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_2_angular_auth_oidc_client__); + + + +var AuthService = (function () { + function AuthService(oidcSecurityService, http, originUrl, identityUrl) { + var _this = this; + this.oidcSecurityService = oidcSecurityService; + this.http = http; + var openIdImplicitFlowConfiguration = new __WEBPACK_IMPORTED_MODULE_2_angular_auth_oidc_client__["OpenIDImplicitFlowConfiguration"](); + openIdImplicitFlowConfiguration.stsServer = identityUrl; + openIdImplicitFlowConfiguration.redirect_url = originUrl + 'callback'; + openIdImplicitFlowConfiguration.client_id = 'ng'; + openIdImplicitFlowConfiguration.response_type = 'id_token token'; + openIdImplicitFlowConfiguration.scope = 'openid profile apiApp'; + openIdImplicitFlowConfiguration.post_logout_redirect_uri = originUrl + 'home'; + openIdImplicitFlowConfiguration.startup_route = '/home'; + openIdImplicitFlowConfiguration.forbidden_route = '/forbidden'; + openIdImplicitFlowConfiguration.unauthorized_route = '/unauthorized'; + openIdImplicitFlowConfiguration.auto_userinfo = true; + openIdImplicitFlowConfiguration.log_console_warning_active = true; + openIdImplicitFlowConfiguration.log_console_debug_active = false; + openIdImplicitFlowConfiguration.max_id_token_iat_offset_allowed_in_seconds = 10; + this.oidcSecurityService.setupModule(openIdImplicitFlowConfiguration); + if (this.oidcSecurityService.moduleSetup) { + this.doCallbackLogicIfRequired(); + } + else { + this.oidcSecurityService.onModuleSetup.subscribe(function () { + _this.doCallbackLogicIfRequired(); + }); + } + } + AuthService.prototype.ngOnInit = function () { + var _this = this; + this.isAuthorizedSubscription = this.oidcSecurityService.getIsAuthorized().subscribe(function (isAuthorized) { + _this.isAuthorized = isAuthorized; + }); + }; + AuthService.prototype.ngOnDestroy = function () { + this.isAuthorizedSubscription.unsubscribe(); + this.oidcSecurityService.onModuleSetup.unsubscribe(); + }; + AuthService.prototype.getIsAuthorized = function () { + return this.oidcSecurityService.getIsAuthorized(); + }; + AuthService.prototype.login = function () { + console.log('start login'); + this.oidcSecurityService.authorize(); + }; + AuthService.prototype.refreshSession = function () { + console.log('start refreshSession'); + this.oidcSecurityService.authorize(); + }; + AuthService.prototype.logout = function () { + console.log('start logoff'); + this.oidcSecurityService.logoff(); + }; + AuthService.prototype.doCallbackLogicIfRequired = function () { + if (typeof location !== "undefined" && window.location.hash) { + this.oidcSecurityService.authorizedCallback(); + } + }; + AuthService.prototype.get = function (url, options) { + return this.http.get(url, this.setRequestOptions(options)); + }; + AuthService.prototype.put = function (url, data, options) { + var body = JSON.stringify(data); + return this.http.put(url, body, this.setRequestOptions(options)); + }; + AuthService.prototype.delete = function (url, options) { + return this.http.delete(url, this.setRequestOptions(options)); + }; + AuthService.prototype.post = function (url, data, options) { + var body = JSON.stringify(data); + return this.http.post(url, body, this.setRequestOptions(options)); + }; + AuthService.prototype.setRequestOptions = function (options) { + if (options) { + this.appendAuthHeader(options.headers); + } + else { + options = new __WEBPACK_IMPORTED_MODULE_1__angular_http__["RequestOptions"]({ headers: this.getHeaders(), body: "" }); + } + return options; + }; + AuthService.prototype.getHeaders = function () { + var headers = new __WEBPACK_IMPORTED_MODULE_1__angular_http__["Headers"](); + headers.append('Content-Type', 'application/json'); + this.appendAuthHeader(headers); + return headers; + }; + AuthService.prototype.appendAuthHeader = function (headers) { + if (headers == null) + headers = this.getHeaders(); + var token = this.oidcSecurityService.getToken(); + if (token == '') + return; + var tokenValue = 'Bearer ' + token; + headers.append('Authorization', tokenValue); + }; + AuthService.ctorParameters = function () { return [{ type: __WEBPACK_IMPORTED_MODULE_2_angular_auth_oidc_client__["OidcSecurityService"] }, { type: __WEBPACK_IMPORTED_MODULE_1__angular_http__["Http"] }, { type: null, decorators: [{ type: __WEBPACK_IMPORTED_MODULE_0__angular_core__["Inject"], args: ['ORIGIN_URL'] }] }, { type: null, decorators: [{ type: __WEBPACK_IMPORTED_MODULE_0__angular_core__["Inject"], args: ['IDENTITY_URL'] }] }]; }; + return AuthService; +}()); + +//# sourceMappingURL=auth.service.js.map /***/ }), /* 16 */ /***/ (function(module, exports, __webpack_require__) { -module.exports = (__webpack_require__(1))(86); +module.exports = (__webpack_require__(1))(11); /***/ }), /* 17 */ /***/ (function(module, exports, __webpack_require__) { -module.exports = (__webpack_require__(1))(7); +module.exports = (__webpack_require__(1))(18); /***/ }), /* 18 */ /***/ (function(module, exports, __webpack_require__) { +module.exports = (__webpack_require__(1))(86); + +/***/ }), +/* 19 */ +/***/ (function(module, exports, __webpack_require__) { + "use strict"; @@ -549,7 +667,7 @@ exports.CODE_POINT_SEQUENCES = { /***/ }), -/* 19 */ +/* 20 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -557,7 +675,7 @@ exports.CODE_POINT_SEQUENCES = { var Preprocessor = __webpack_require__(119), locationInfoMixin = __webpack_require__(111), - UNICODE = __webpack_require__(18), + UNICODE = __webpack_require__(19), neTree = __webpack_require__(118); //Aliases @@ -2704,7 +2822,7 @@ _[CDATA_SECTION_STATE] = function cdataSectionState(cp) { /***/ }), -/* 20 */ +/* 21 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -2852,7 +2970,7 @@ exports.AsyncAction = AsyncAction; //# sourceMappingURL=AsyncAction.js.map /***/ }), -/* 21 */ +/* 22 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -2909,7 +3027,7 @@ exports.AsyncScheduler = AsyncScheduler; //# sourceMappingURL=AsyncScheduler.js.map /***/ }), -/* 22 */ +/* 23 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -2943,19 +3061,19 @@ exports.ArgumentOutOfRangeError = ArgumentOutOfRangeError; //# sourceMappingURL=ArgumentOutOfRangeError.js.map /***/ }), -/* 23 */ +/* 24 */ /***/ (function(module, exports, __webpack_require__) { module.exports = (__webpack_require__(1))(12); /***/ }), -/* 24 */ +/* 25 */ /***/ (function(module, exports) { module.exports = require("util"); /***/ }), -/* 25 */ +/* 26 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -3014,7 +3132,7 @@ exports.AsyncSubject = AsyncSubject; //# sourceMappingURL=AsyncSubject.js.map /***/ }), -/* 26 */ +/* 27 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -3025,11 +3143,11 @@ var __extends = (this && this.__extends) || function (d, b) { d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var Subject_1 = __webpack_require__(6); -var queue_1 = __webpack_require__(71); +var queue_1 = __webpack_require__(80); var Subscription_1 = __webpack_require__(9); -var observeOn_1 = __webpack_require__(87); -var ObjectUnsubscribedError_1 = __webpack_require__(80); -var SubjectSubscription_1 = __webpack_require__(385); +var observeOn_1 = __webpack_require__(92); +var ObjectUnsubscribedError_1 = __webpack_require__(89); +var SubjectSubscription_1 = __webpack_require__(383); /** * @class ReplaySubject */ @@ -3122,7 +3240,7 @@ var ReplayEvent = (function () { //# sourceMappingURL=ReplaySubject.js.map /***/ }), -/* 27 */ +/* 28 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -3134,12 +3252,12 @@ exports.isDate = isDate; //# sourceMappingURL=isDate.js.map /***/ }), -/* 28 */ +/* 29 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; -var isArray_1 = __webpack_require__(15); +var isArray_1 = __webpack_require__(17); function isNumeric(val) { // parseFloat NaNs numeric-cast false positives (null|true|false|"") // ...but misinterprets leading-number strings, particularly hex literals ("0x...") @@ -3152,4128 +3270,4512 @@ exports.isNumeric = isNumeric; //# sourceMappingURL=isNumeric.js.map /***/ }), -/* 29 */ +/* 30 */ /***/ (function(module, exports, __webpack_require__) { module.exports = (__webpack_require__(1))(38); /***/ }), -/* 30 */ +/* 31 */ +/***/ (function(module, exports, __webpack_require__) { + +module.exports = (__webpack_require__(1))(40); + +/***/ }), +/* 32 */ /***/ (function(module, exports, __webpack_require__) { module.exports = (__webpack_require__(1))(67); /***/ }), -/* 31 */ +/* 33 */ /***/ (function(module, exports) { module.exports = require("stream"); /***/ }), -/* 32 */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { +/* 34 */ +/***/ (function(module, exports, __webpack_require__) { -"use strict"; -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return AuthService; }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__angular_core__ = __webpack_require__(10); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__angular_core___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0__angular_core__); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__angular_http__ = __webpack_require__(29); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__angular_http___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1__angular_http__); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_angular_auth_oidc_client__ = __webpack_require__(47); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_angular_auth_oidc_client___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_2_angular_auth_oidc_client__); -var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { - var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); - else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; - return c > 3 && r && Object.defineProperty(target, key, r), r; -}; -var __metadata = (this && this.__metadata) || function (k, v) { - if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); -}; +/** + * @license Angular v4.2.5 + * (c) 2010-2017 Google, Inc. https://angular.io/ + * License: MIT + */ +(function (global, factory) { + true ? factory(exports, __webpack_require__(43)) : + typeof define === 'function' && define.amd ? define(['exports', '@angular/animations'], factory) : + (factory((global.ng = global.ng || {}, global.ng.animations = global.ng.animations || {}, global.ng.animations.browser = global.ng.animations.browser || {}),global.ng.animations)); +}(this, (function (exports,_angular_animations) { 'use strict'; + +/*! ***************************************************************************** +Copyright (c) Microsoft Corporation. All rights reserved. +Licensed under the Apache License, Version 2.0 (the "License"); you may not use +this file except in compliance with the License. You may obtain a copy of the +License at http://www.apache.org/licenses/LICENSE-2.0 +THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED +WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, +MERCHANTABLITY OR NON-INFRINGEMENT. +See the Apache Version 2.0 License for specific language governing permissions +and limitations under the License. +***************************************************************************** */ +/* global Reflect, Promise */ -var AuthService = (function () { - function AuthService(oidcSecurityService, http) { - var _this = this; - this.oidcSecurityService = oidcSecurityService; - this.http = http; - var openIdImplicitFlowConfiguration = new __WEBPACK_IMPORTED_MODULE_2_angular_auth_oidc_client__["OpenIDImplicitFlowConfiguration"](); - openIdImplicitFlowConfiguration.stsServer = 'http://localhost:5000'; - openIdImplicitFlowConfiguration.redirect_url = 'http://localhost:5002/callback'; - openIdImplicitFlowConfiguration.client_id = 'ng'; - openIdImplicitFlowConfiguration.response_type = 'id_token token'; - openIdImplicitFlowConfiguration.scope = 'openid profile apiApp'; - openIdImplicitFlowConfiguration.post_logout_redirect_uri = 'http://localhost:5002/home'; - openIdImplicitFlowConfiguration.startup_route = '/home'; - openIdImplicitFlowConfiguration.forbidden_route = '/forbidden'; - openIdImplicitFlowConfiguration.unauthorized_route = '/unauthorized'; - openIdImplicitFlowConfiguration.auto_userinfo = true; - openIdImplicitFlowConfiguration.log_console_warning_active = true; - openIdImplicitFlowConfiguration.log_console_debug_active = false; - openIdImplicitFlowConfiguration.max_id_token_iat_offset_allowed_in_seconds = 10; - this.oidcSecurityService.setupModule(openIdImplicitFlowConfiguration); - if (this.oidcSecurityService.moduleSetup) { - this.doCallbackLogicIfRequired(); - } - else { - this.oidcSecurityService.onModuleSetup.subscribe(function () { - _this.doCallbackLogicIfRequired(); - }); - } - } - AuthService.prototype.ngOnInit = function () { - var _this = this; - this.isAuthorizedSubscription = this.oidcSecurityService.getIsAuthorized().subscribe(function (isAuthorized) { - _this.isAuthorized = isAuthorized; - }); - }; - AuthService.prototype.ngOnDestroy = function () { - this.isAuthorizedSubscription.unsubscribe(); - this.oidcSecurityService.onModuleSetup.unsubscribe(); - }; - AuthService.prototype.getIsAuthorized = function () { - return this.oidcSecurityService.getIsAuthorized(); - }; - AuthService.prototype.login = function () { - console.log('start login'); - this.oidcSecurityService.authorize(); - }; - AuthService.prototype.refreshSession = function () { - console.log('start refreshSession'); - this.oidcSecurityService.authorize(); - }; - AuthService.prototype.logout = function () { - console.log('start logoff'); - this.oidcSecurityService.logoff(); - }; - AuthService.prototype.doCallbackLogicIfRequired = function () { - if (typeof location !== "undefined" && window.location.hash) { - this.oidcSecurityService.authorizedCallback(); - } - }; - AuthService.prototype.get = function (url, options) { - return this.http.get(url, this.setRequestOptions(options)); - }; - AuthService.prototype.put = function (url, data, options) { - var body = JSON.stringify(data); - return this.http.put(url, body, this.setRequestOptions(options)); - }; - AuthService.prototype.delete = function (url, options) { - return this.http.delete(url, this.setRequestOptions(options)); - }; - AuthService.prototype.post = function (url, data, options) { - var body = JSON.stringify(data); - return this.http.post(url, body, this.setRequestOptions(options)); - }; - AuthService.prototype.setRequestOptions = function (options) { - if (options) { - this.appendAuthHeader(options.headers); - } - else { - options = new __WEBPACK_IMPORTED_MODULE_1__angular_http__["RequestOptions"]({ headers: this.getHeaders(), body: "" }); - } - return options; - }; - AuthService.prototype.getHeaders = function () { - var headers = new __WEBPACK_IMPORTED_MODULE_1__angular_http__["Headers"](); - headers.append('Content-Type', 'application/json'); - this.appendAuthHeader(headers); - return headers; - }; - AuthService.prototype.appendAuthHeader = function (headers) { - if (headers == null) - headers = this.getHeaders(); - var token = this.oidcSecurityService.getToken(); - if (token == '') - return; - var tokenValue = 'Bearer ' + token; - headers.append('Authorization', tokenValue); - }; - AuthService = __decorate([ - __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__angular_core__["Injectable"])(), - __metadata("design:paramtypes", [__WEBPACK_IMPORTED_MODULE_2_angular_auth_oidc_client__["OidcSecurityService"], - __WEBPACK_IMPORTED_MODULE_1__angular_http__["Http"]]) - ], AuthService); - return AuthService; -}()); +var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; - - -/***/ }), -/* 33 */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - - -var DOCUMENT_MODE = __webpack_require__(11).DOCUMENT_MODE; - -//Const -var VALID_DOCTYPE_NAME = 'html', - QUIRKS_MODE_SYSTEM_ID = 'http://www.ibm.com/data/dtd/v11/ibmxhtml1-transitional.dtd', - QUIRKS_MODE_PUBLIC_ID_PREFIXES = [ - '+//silmaril//dtd html pro v0r11 19970101//en', - '-//advasoft ltd//dtd html 3.0 aswedit + extensions//en', - '-//as//dtd html 3.0 aswedit + extensions//en', - '-//ietf//dtd html 2.0 level 1//en', - '-//ietf//dtd html 2.0 level 2//en', - '-//ietf//dtd html 2.0 strict level 1//en', - '-//ietf//dtd html 2.0 strict level 2//en', - '-//ietf//dtd html 2.0 strict//en', - '-//ietf//dtd html 2.0//en', - '-//ietf//dtd html 2.1e//en', - '-//ietf//dtd html 3.0//en', - '-//ietf//dtd html 3.0//en//', - '-//ietf//dtd html 3.2 final//en', - '-//ietf//dtd html 3.2//en', - '-//ietf//dtd html 3//en', - '-//ietf//dtd html level 0//en', - '-//ietf//dtd html level 0//en//2.0', - '-//ietf//dtd html level 1//en', - '-//ietf//dtd html level 1//en//2.0', - '-//ietf//dtd html level 2//en', - '-//ietf//dtd html level 2//en//2.0', - '-//ietf//dtd html level 3//en', - '-//ietf//dtd html level 3//en//3.0', - '-//ietf//dtd html strict level 0//en', - '-//ietf//dtd html strict level 0//en//2.0', - '-//ietf//dtd html strict level 1//en', - '-//ietf//dtd html strict level 1//en//2.0', - '-//ietf//dtd html strict level 2//en', - '-//ietf//dtd html strict level 2//en//2.0', - '-//ietf//dtd html strict level 3//en', - '-//ietf//dtd html strict level 3//en//3.0', - '-//ietf//dtd html strict//en', - '-//ietf//dtd html strict//en//2.0', - '-//ietf//dtd html strict//en//3.0', - '-//ietf//dtd html//en', - '-//ietf//dtd html//en//2.0', - '-//ietf//dtd html//en//3.0', - '-//metrius//dtd metrius presentational//en', - '-//microsoft//dtd internet explorer 2.0 html strict//en', - '-//microsoft//dtd internet explorer 2.0 html//en', - '-//microsoft//dtd internet explorer 2.0 tables//en', - '-//microsoft//dtd internet explorer 3.0 html strict//en', - '-//microsoft//dtd internet explorer 3.0 html//en', - '-//microsoft//dtd internet explorer 3.0 tables//en', - '-//netscape comm. corp.//dtd html//en', - '-//netscape comm. corp.//dtd strict html//en', - '-//o\'reilly and associates//dtd html 2.0//en', - '-//o\'reilly and associates//dtd html extended 1.0//en', - '-//spyglass//dtd html 2.0 extended//en', - '-//sq//dtd html 2.0 hotmetal + extensions//en', - '-//sun microsystems corp.//dtd hotjava html//en', - '-//sun microsystems corp.//dtd hotjava strict html//en', - '-//w3c//dtd html 3 1995-03-24//en', - '-//w3c//dtd html 3.2 draft//en', - '-//w3c//dtd html 3.2 final//en', - '-//w3c//dtd html 3.2//en', - '-//w3c//dtd html 3.2s draft//en', - '-//w3c//dtd html 4.0 frameset//en', - '-//w3c//dtd html 4.0 transitional//en', - '-//w3c//dtd html experimental 19960712//en', - '-//w3c//dtd html experimental 970421//en', - '-//w3c//dtd w3 html//en', - '-//w3o//dtd w3 html 3.0//en', - '-//w3o//dtd w3 html 3.0//en//', - '-//webtechs//dtd mozilla html 2.0//en', - '-//webtechs//dtd mozilla html//en' - ], - QUIRKS_MODE_NO_SYSTEM_ID_PUBLIC_ID_PREFIXES = QUIRKS_MODE_PUBLIC_ID_PREFIXES.concat([ - '-//w3c//dtd html 4.01 frameset//', - '-//w3c//dtd html 4.01 transitional//' - ]), - QUIRKS_MODE_PUBLIC_IDS = [ - '-//w3o//dtd w3 html strict 3.0//en//', - '-/w3c/dtd html 4.0 transitional/en', - 'html' - ], - LIMITED_QUIRKS_PUBLIC_ID_PREFIXES = [ - '-//W3C//DTD XHTML 1.0 Frameset//', - '-//W3C//DTD XHTML 1.0 Transitional//' - ], - LIMITED_QUIRKS_WITH_SYSTEM_ID_PUBLIC_ID_PREFIXES = LIMITED_QUIRKS_PUBLIC_ID_PREFIXES.concat([ - '-//W3C//DTD HTML 4.01 Frameset//', - '-//W3C//DTD HTML 4.01 Transitional//' - ]); - - -//Utils -function enquoteDoctypeId(id) { - var quote = id.indexOf('"') !== -1 ? '\'' : '"'; - - return quote + id + quote; +function __extends(d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); } -function hasPrefix(publicId, prefixes) { - for (var i = 0; i < prefixes.length; i++) { - if (publicId.indexOf(prefixes[i]) === 0) - return true; +/** + * @license Angular v4.2.5 + * (c) 2010-2017 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 + */ +function optimizeGroupPlayer(players) { + switch (players.length) { + case 0: + return new _angular_animations.NoopAnimationPlayer(); + case 1: + return players[0]; + default: + return new _angular_animations.ɵAnimationGroupPlayer(players); } - - return false; } - - -//API -exports.getDocumentMode = function (name, publicId, systemId) { - if (name !== VALID_DOCTYPE_NAME) - return DOCUMENT_MODE.QUIRKS; - - if (systemId && systemId.toLowerCase() === QUIRKS_MODE_SYSTEM_ID) - return DOCUMENT_MODE.QUIRKS; - - if (publicId !== null) { - publicId = publicId.toLowerCase(); - - if (QUIRKS_MODE_PUBLIC_IDS.indexOf(publicId) > -1) - return DOCUMENT_MODE.QUIRKS; - - var prefixes = systemId === null ? QUIRKS_MODE_NO_SYSTEM_ID_PUBLIC_ID_PREFIXES : QUIRKS_MODE_PUBLIC_ID_PREFIXES; - - if (hasPrefix(publicId, prefixes)) - return DOCUMENT_MODE.QUIRKS; - - prefixes = systemId === null ? LIMITED_QUIRKS_PUBLIC_ID_PREFIXES : LIMITED_QUIRKS_WITH_SYSTEM_ID_PUBLIC_ID_PREFIXES; - - if (hasPrefix(publicId, prefixes)) - return DOCUMENT_MODE.LIMITED_QUIRKS; - } - - return DOCUMENT_MODE.NO_QUIRKS; -}; - -exports.serializeContent = function (name, publicId, systemId) { - var str = '!DOCTYPE '; - - if (name) - str += name; - - if (publicId !== null) - str += ' PUBLIC ' + enquoteDoctypeId(publicId); - - else if (systemId !== null) - str += ' SYSTEM'; - - if (systemId !== null) - str += ' ' + enquoteDoctypeId(systemId); - - return str; -}; - - -/***/ }), -/* 34 */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - - -module.exports = function mergeOptions(defaults, options) { - options = options || Object.create(null); - - return [defaults, options].reduce(function (merged, optObj) { - Object.keys(optObj).forEach(function (key) { - merged[key] = optObj[key]; +function normalizeKeyframes(driver, normalizer, element, keyframes, preStyles, postStyles) { + if (preStyles === void 0) { preStyles = {}; } + if (postStyles === void 0) { postStyles = {}; } + var errors = []; + var normalizedKeyframes = []; + var previousOffset = -1; + var previousKeyframe = null; + keyframes.forEach(function (kf) { + var offset = kf['offset']; + var isSameOffset = offset == previousOffset; + var normalizedKeyframe = (isSameOffset && previousKeyframe) || {}; + Object.keys(kf).forEach(function (prop) { + var normalizedProp = prop; + var normalizedValue = kf[prop]; + if (normalizedValue == _angular_animations.ɵPRE_STYLE) { + normalizedValue = preStyles[prop]; + } + else if (normalizedValue == _angular_animations.AUTO_STYLE) { + normalizedValue = postStyles[prop]; + } + else if (prop != 'offset') { + normalizedProp = normalizer.normalizePropertyName(prop, errors); + normalizedValue = normalizer.normalizeStyleValue(prop, normalizedProp, kf[prop], errors); + } + normalizedKeyframe[normalizedProp] = normalizedValue; }); - - return merged; - }, Object.create(null)); -}; - - -/***/ }), -/* 35 */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - - -var Parser = __webpack_require__(50), - Serializer = __webpack_require__(53); - - -// Shorthands -exports.parse = function parse(html, options) { - var parser = new Parser(options); - - return parser.parse(html); -}; - -exports.parseFragment = function parseFragment(fragmentContext, html, options) { - if (typeof fragmentContext === 'string') { - options = html; - html = fragmentContext; - fragmentContext = null; + if (!isSameOffset) { + normalizedKeyframes.push(normalizedKeyframe); + } + previousKeyframe = normalizedKeyframe; + previousOffset = offset; + }); + if (errors.length) { + var LINE_START = '\n - '; + throw new Error("Unable to animate due to the following errors:" + LINE_START + errors.join(LINE_START)); } - - var parser = new Parser(options); - - return parser.parseFragment(html, fragmentContext); -}; - -exports.serialize = function (node, options) { - var serializer = new Serializer(node, options); - - return serializer.serialize(); -}; - - -// Tree adapters -exports.treeAdapters = { - default: __webpack_require__(36), - htmlparser2: __webpack_require__(120) -}; - - -// Streaming -exports.ParserStream = __webpack_require__(52); -exports.PlainTextConversionStream = __webpack_require__(113); -exports.SerializerStream = __webpack_require__(117); -exports.SAXParser = __webpack_require__(115); - - -/***/ }), -/* 36 */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - - -var DOCUMENT_MODE = __webpack_require__(11).DOCUMENT_MODE; - -//Node construction -exports.createDocument = function () { - return { - nodeName: '#document', - mode: DOCUMENT_MODE.NO_QUIRKS, - childNodes: [] - }; -}; - -exports.createDocumentFragment = function () { - return { - nodeName: '#document-fragment', - childNodes: [] - }; -}; - -exports.createElement = function (tagName, namespaceURI, attrs) { - return { - nodeName: tagName, - tagName: tagName, - attrs: attrs, - namespaceURI: namespaceURI, - childNodes: [], - parentNode: null - }; -}; - -exports.createCommentNode = function (data) { - return { - nodeName: '#comment', - data: data, - parentNode: null - }; -}; - -var createTextNode = function (value) { - return { - nodeName: '#text', - value: value, - parentNode: null - }; -}; - - -//Tree mutation -var appendChild = exports.appendChild = function (parentNode, newNode) { - parentNode.childNodes.push(newNode); - newNode.parentNode = parentNode; -}; - -var insertBefore = exports.insertBefore = function (parentNode, newNode, referenceNode) { - var insertionIdx = parentNode.childNodes.indexOf(referenceNode); - - parentNode.childNodes.splice(insertionIdx, 0, newNode); - newNode.parentNode = parentNode; -}; - -exports.setTemplateContent = function (templateElement, contentElement) { - templateElement.content = contentElement; -}; - -exports.getTemplateContent = function (templateElement) { - return templateElement.content; -}; - -exports.setDocumentType = function (document, name, publicId, systemId) { - var doctypeNode = null; - - for (var i = 0; i < document.childNodes.length; i++) { - if (document.childNodes[i].nodeName === '#documentType') { - doctypeNode = document.childNodes[i]; + return normalizedKeyframes; +} +function listenOnPlayer(player, eventName, event, callback) { + switch (eventName) { + case 'start': + player.onStart(function () { return callback(event && copyAnimationEvent(event, 'start', player.totalTime)); }); + break; + case 'done': + player.onDone(function () { return callback(event && copyAnimationEvent(event, 'done', player.totalTime)); }); + break; + case 'destroy': + player.onDestroy(function () { return callback(event && copyAnimationEvent(event, 'destroy', player.totalTime)); }); break; - } } - - if (doctypeNode) { - doctypeNode.name = name; - doctypeNode.publicId = publicId; - doctypeNode.systemId = systemId; +} +function copyAnimationEvent(e, phaseName, totalTime) { + var event = makeAnimationEvent(e.element, e.triggerName, e.fromState, e.toState, phaseName || e.phaseName, totalTime == undefined ? e.totalTime : totalTime); + var data = e['_data']; + if (data != null) { + event['_data'] = data; + } + return event; +} +function makeAnimationEvent(element, triggerName, fromState, toState, phaseName, totalTime) { + if (phaseName === void 0) { phaseName = ''; } + if (totalTime === void 0) { totalTime = 0; } + return { element: element, triggerName: triggerName, fromState: fromState, toState: toState, phaseName: phaseName, totalTime: totalTime }; +} +function getOrSetAsInMap(map, key, defaultValue) { + var value; + if (map instanceof Map) { + value = map.get(key); + if (!value) { + map.set(key, value = defaultValue); + } } - else { - appendChild(document, { - nodeName: '#documentType', - name: name, - publicId: publicId, - systemId: systemId - }); + value = map[key]; + if (!value) { + value = map[key] = defaultValue; + } } + return value; +} +function parseTimelineCommand(command) { + var separatorPos = command.indexOf(':'); + var id = command.substring(1, separatorPos); + var action = command.substr(separatorPos + 1); + return [id, action]; +} +var _contains = function (elm1, elm2) { return false; }; +var _matches = function (element, selector) { return false; }; +var _query = function (element, selector, multi) { + return []; }; - -exports.setDocumentMode = function (document, mode) { - document.mode = mode; -}; - -exports.getDocumentMode = function (document) { - return document.mode; -}; - -exports.detachNode = function (node) { - if (node.parentNode) { - var idx = node.parentNode.childNodes.indexOf(node); - - node.parentNode.childNodes.splice(idx, 1); - node.parentNode = null; +if (typeof Element != 'undefined') { + // this is well supported in all browsers + _contains = function (elm1, elm2) { return elm1.contains(elm2); }; + if (Element.prototype.matches) { + _matches = function (element, selector) { return element.matches(selector); }; } -}; - -exports.insertText = function (parentNode, text) { - if (parentNode.childNodes.length) { - var prevNode = parentNode.childNodes[parentNode.childNodes.length - 1]; - - if (prevNode.nodeName === '#text') { - prevNode.value += text; - return; + else { + var proto = Element.prototype; + var fn_1 = proto.matchesSelector || proto.mozMatchesSelector || proto.msMatchesSelector || + proto.oMatchesSelector || proto.webkitMatchesSelector; + if (fn_1) { + _matches = function (element, selector) { return fn_1.apply(element, [selector]); }; } } - - appendChild(parentNode, createTextNode(text)); -}; - -exports.insertTextBefore = function (parentNode, text, referenceNode) { - var prevNode = parentNode.childNodes[parentNode.childNodes.indexOf(referenceNode) - 1]; - - if (prevNode && prevNode.nodeName === '#text') - prevNode.value += text; - else - insertBefore(parentNode, createTextNode(text), referenceNode); -}; - -exports.adoptAttributes = function (recipient, attrs) { - var recipientAttrsMap = []; - - for (var i = 0; i < recipient.attrs.length; i++) - recipientAttrsMap.push(recipient.attrs[i].name); - - for (var j = 0; j < attrs.length; j++) { - if (recipientAttrsMap.indexOf(attrs[j].name) === -1) - recipient.attrs.push(attrs[j]); - } -}; - - -//Tree traversing -exports.getFirstChild = function (node) { - return node.childNodes[0]; -}; - -exports.getChildNodes = function (node) { - return node.childNodes; -}; - -exports.getParentNode = function (node) { - return node.parentNode; -}; - -exports.getAttrList = function (element) { - return element.attrs; -}; - -//Node data -exports.getTagName = function (element) { - return element.tagName; -}; - -exports.getNamespaceURI = function (element) { - return element.namespaceURI; -}; - -exports.getTextNodeContent = function (textNode) { - return textNode.value; -}; - -exports.getCommentNodeContent = function (commentNode) { - return commentNode.data; -}; - -exports.getDocumentTypeNodeName = function (doctypeNode) { - return doctypeNode.name; -}; - -exports.getDocumentTypeNodePublicId = function (doctypeNode) { - return doctypeNode.publicId; -}; - -exports.getDocumentTypeNodeSystemId = function (doctypeNode) { - return doctypeNode.systemId; -}; - -//Node types -exports.isTextNode = function (node) { - return node.nodeName === '#text'; -}; - -exports.isCommentNode = function (node) { - return node.nodeName === '#comment'; -}; - -exports.isDocumentTypeNode = function (node) { - return node.nodeName === '#documentType'; -}; - -exports.isElementNode = function (node) { - return !!node.tagName; -}; - - -/***/ }), -/* 37 */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - -var __extends = (this && this.__extends) || function (d, b) { - for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); -}; -var ArrayObservable_1 = __webpack_require__(14); -var isArray_1 = __webpack_require__(15); -var OuterSubscriber_1 = __webpack_require__(4); -var subscribeToResult_1 = __webpack_require__(3); -var none = {}; -/* tslint:enable:max-line-length */ + _query = function (element, selector, multi) { + var results = []; + if (multi) { + results.push.apply(results, element.querySelectorAll(selector)); + } + else { + var elm = element.querySelector(selector); + if (elm) { + results.push(elm); + } + } + return results; + }; +} +var matchesElement = _matches; +var containsElement = _contains; +var invokeQuery = _query; /** - * Combines multiple Observables to create an Observable whose values are - * calculated from the latest values of each of its input Observables. - * - * Whenever any input Observable emits a value, it - * computes a formula using the latest values from all the inputs, then emits - * the output of that formula. - * - * - * - * `combineLatest` combines the values from this Observable with values from - * Observables passed as arguments. This is done by subscribing to each - * Observable, in order, and collecting an array of each of the most recent - * values any time any of the input Observables emits, then either taking that - * array and passing it as arguments to an optional `project` function and - * emitting the return value of that, or just emitting the array of recent - * values directly if there is no `project` function. - * - * @example Dynamically calculate the Body-Mass Index from an Observable of weight and one for height - * var weight = Rx.Observable.of(70, 72, 76, 79, 75); - * var height = Rx.Observable.of(1.76, 1.77, 1.78); - * var bmi = weight.combineLatest(height, (w, h) => w / (h * h)); - * bmi.subscribe(x => console.log('BMI is ' + x)); - * - * // With output to console: - * // BMI is 24.212293388429753 - * // BMI is 23.93948099205209 - * // BMI is 23.671253629592222 - * - * @see {@link combineAll} - * @see {@link merge} - * @see {@link withLatestFrom} + * @license + * Copyright Google Inc. All Rights Reserved. * - * @param {ObservableInput} other An input Observable to combine with the source - * Observable. More than one input Observables may be given as argument. - * @param {function} [project] An optional function to project the values from - * the combined latest values into a new value on the output Observable. - * @return {Observable} An Observable of projected values from the most recent - * values from each input Observable, or an array of the most recent values from - * each input Observable. - * @method combineLatest - * @owner Observable + * 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 combineLatest() { - var observables = []; - for (var _i = 0; _i < arguments.length; _i++) { - observables[_i - 0] = arguments[_i]; - } - var project = null; - if (typeof observables[observables.length - 1] === 'function') { - project = observables.pop(); - } - // if the first and only other argument besides the resultSelector is an array - // assume it's been called with `combineLatest([obs1, obs2, obs3], project)` - if (observables.length === 1 && isArray_1.isArray(observables[0])) { - observables = observables[0].slice(); - } - observables.unshift(this); - return this.lift.call(new ArrayObservable_1.ArrayObservable(observables), new CombineLatestOperator(project)); -} -exports.combineLatest = combineLatest; -var CombineLatestOperator = (function () { - function CombineLatestOperator(project) { - this.project = project; - } - CombineLatestOperator.prototype.call = function (subscriber, source) { - return source.subscribe(new CombineLatestSubscriber(subscriber, this.project)); - }; - return CombineLatestOperator; -}()); -exports.CombineLatestOperator = CombineLatestOperator; /** - * We need this JSDoc comment for affecting ESDoc. - * @ignore - * @extends {Ignored} + * @experimental */ -var CombineLatestSubscriber = (function (_super) { - __extends(CombineLatestSubscriber, _super); - function CombineLatestSubscriber(destination, project) { - _super.call(this, destination); - this.project = project; - this.active = 0; - this.values = []; - this.observables = []; +var NoopAnimationDriver = (function () { + function NoopAnimationDriver() { } - CombineLatestSubscriber.prototype._next = function (observable) { - this.values.push(none); - this.observables.push(observable); - }; - CombineLatestSubscriber.prototype._complete = function () { - var observables = this.observables; - var len = observables.length; - if (len === 0) { - this.destination.complete(); - } - else { - this.active = len; - this.toRespond = len; - for (var i = 0; i < len; i++) { - var observable = observables[i]; - this.add(subscribeToResult_1.subscribeToResult(this, observable, observable, i)); - } - } + NoopAnimationDriver.prototype.matchesElement = function (element, selector) { + return matchesElement(element, selector); }; - CombineLatestSubscriber.prototype.notifyComplete = function (unused) { - if ((this.active -= 1) === 0) { - this.destination.complete(); - } + NoopAnimationDriver.prototype.containsElement = function (elm1, elm2) { return containsElement(elm1, elm2); }; + NoopAnimationDriver.prototype.query = function (element, selector, multi) { + return invokeQuery(element, selector, multi); }; - CombineLatestSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) { - var values = this.values; - var oldVal = values[outerIndex]; - var toRespond = !this.toRespond - ? 0 - : oldVal === none ? --this.toRespond : this.toRespond; - values[outerIndex] = innerValue; - if (toRespond === 0) { - if (this.project) { - this._tryProject(values); - } - else { - this.destination.next(values.slice()); - } - } + NoopAnimationDriver.prototype.computeStyle = function (element, prop, defaultValue) { + return defaultValue || ''; }; - CombineLatestSubscriber.prototype._tryProject = function (values) { - var result; - try { - result = this.project.apply(this, values); - } - catch (err) { - this.destination.error(err); - return; - } - this.destination.next(result); + NoopAnimationDriver.prototype.animate = function (element, keyframes, duration, delay, easing, previousPlayers) { + if (previousPlayers === void 0) { previousPlayers = []; } + return new _angular_animations.NoopAnimationPlayer(); }; - return CombineLatestSubscriber; -}(OuterSubscriber_1.OuterSubscriber)); -exports.CombineLatestSubscriber = CombineLatestSubscriber; -//# sourceMappingURL=combineLatest.js.map - -/***/ }), -/* 38 */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - -var Observable_1 = __webpack_require__(0); -var isScheduler_1 = __webpack_require__(13); -var ArrayObservable_1 = __webpack_require__(14); -var mergeAll_1 = __webpack_require__(77); -/* tslint:enable:max-line-length */ + return NoopAnimationDriver; +}()); /** - * Creates an output Observable which sequentially emits all values from every - * given input Observable after the current Observable. - * - * Concatenates multiple Observables together by - * sequentially emitting their values, one Observable after the other. - * - * - * - * Joins this Observable with multiple other Observables by subscribing to them - * one at a time, starting with the source, and merging their results into the - * output Observable. Will wait for each Observable to complete before moving - * on to the next. - * - * @example Concatenate a timer counting from 0 to 3 with a synchronous sequence from 1 to 10 - * var timer = Rx.Observable.interval(1000).take(4); - * var sequence = Rx.Observable.range(1, 10); - * var result = timer.concat(sequence); - * result.subscribe(x => console.log(x)); - * - * // results in: - * // 1000ms-> 0 -1000ms-> 1 -1000ms-> 2 -1000ms-> 3 -immediate-> 1 ... 10 - * - * @example Concatenate 3 Observables - * var timer1 = Rx.Observable.interval(1000).take(10); - * var timer2 = Rx.Observable.interval(2000).take(6); - * var timer3 = Rx.Observable.interval(500).take(10); - * var result = timer1.concat(timer2, timer3); - * result.subscribe(x => console.log(x)); - * - * // results in the following: - * // (Prints to console sequentially) - * // -1000ms-> 0 -1000ms-> 1 -1000ms-> ... 9 - * // -2000ms-> 0 -2000ms-> 1 -2000ms-> ... 5 - * // -500ms-> 0 -500ms-> 1 -500ms-> ... 9 - * - * @see {@link concatAll} - * @see {@link concatMap} - * @see {@link concatMapTo} - * - * @param {ObservableInput} other An input Observable to concatenate after the source - * Observable. More than one input Observables may be given as argument. - * @param {Scheduler} [scheduler=null] An optional IScheduler to schedule each - * Observable subscription on. - * @return {Observable} All values of each passed Observable merged into a - * single Observable, in order, in serial fashion. - * @method concat - * @owner Observable + * @experimental */ -function concat() { - var observables = []; - for (var _i = 0; _i < arguments.length; _i++) { - observables[_i - 0] = arguments[_i]; +var AnimationDriver = (function () { + function AnimationDriver() { } - return this.lift.call(concatStatic.apply(void 0, [this].concat(observables))); -} -exports.concat = concat; -/* tslint:enable:max-line-length */ + return AnimationDriver; +}()); +AnimationDriver.NOOP = new NoopAnimationDriver(); /** - * Creates an output Observable which sequentially emits all values from given - * Observable and then moves on to the next. - * - * Concatenates multiple Observables together by - * sequentially emitting their values, one Observable after the other. - * - * - * - * `concat` joins multiple Observables together, by subscribing to them one at a time and - * merging their results into the output Observable. You can pass either an array of - * Observables, or put them directly as arguments. Passing an empty array will result - * in Observable that completes immediately. - * - * `concat` will subscribe to first input Observable and emit all its values, without - * changing or affecting them in any way. When that Observable completes, it will - * subscribe to then next Observable passed and, again, emit its values. This will be - * repeated, until the operator runs out of Observables. When last input Observable completes, - * `concat` will complete as well. At any given moment only one Observable passed to operator - * emits values. If you would like to emit values from passed Observables concurrently, check out - * {@link merge} instead, especially with optional `concurrent` parameter. As a matter of fact, - * `concat` is an equivalent of `merge` operator with `concurrent` parameter set to `1`. - * - * Note that if some input Observable never completes, `concat` will also never complete - * and Observables following the one that did not complete will never be subscribed. On the other - * hand, if some Observable simply completes immediately after it is subscribed, it will be - * invisible for `concat`, which will just move on to the next Observable. - * - * If any Observable in chain errors, instead of passing control to the next Observable, - * `concat` will error immediately as well. Observables that would be subscribed after - * the one that emitted error, never will. - * - * If you pass to `concat` the same Observable many times, its stream of values - * will be "replayed" on every subscription, which means you can repeat given Observable - * as many times as you like. If passing the same Observable to `concat` 1000 times becomes tedious, - * you can always use {@link repeat}. - * - * @example Concatenate a timer counting from 0 to 3 with a synchronous sequence from 1 to 10 - * var timer = Rx.Observable.interval(1000).take(4); - * var sequence = Rx.Observable.range(1, 10); - * var result = Rx.Observable.concat(timer, sequence); - * result.subscribe(x => console.log(x)); - * - * // results in: - * // 0 -1000ms-> 1 -1000ms-> 2 -1000ms-> 3 -immediate-> 1 ... 10 - * - * - * @example Concatenate an array of 3 Observables - * var timer1 = Rx.Observable.interval(1000).take(10); - * var timer2 = Rx.Observable.interval(2000).take(6); - * var timer3 = Rx.Observable.interval(500).take(10); - * var result = Rx.Observable.concat([timer1, timer2, timer3]); // note that array is passed - * result.subscribe(x => console.log(x)); - * - * // results in the following: - * // (Prints to console sequentially) - * // -1000ms-> 0 -1000ms-> 1 -1000ms-> ... 9 - * // -2000ms-> 0 -2000ms-> 1 -2000ms-> ... 5 - * // -500ms-> 0 -500ms-> 1 -500ms-> ... 9 - * - * - * @example Concatenate the same Observable to repeat it - * const timer = Rx.Observable.interval(1000).take(2); - * - * Rx.Observable.concat(timer, timer) // concating the same Observable! - * .subscribe( - * value => console.log(value), - * err => {}, - * () => console.log('...and it is done!') - * ); - * - * // Logs: - * // 0 after 1s - * // 1 after 2s - * // 0 after 3s - * // 1 after 4s - * // "...and it is done!" also after 4s - * - * @see {@link concatAll} - * @see {@link concatMap} - * @see {@link concatMapTo} + * @license + * Copyright Google Inc. All Rights Reserved. * - * @param {ObservableInput} input1 An input Observable to concatenate with others. - * @param {ObservableInput} input2 An input Observable to concatenate with others. - * More than one input Observables may be given as argument. - * @param {Scheduler} [scheduler=null] An optional IScheduler to schedule each - * Observable subscription on. - * @return {Observable} All values of each passed Observable merged into a - * single Observable, in order, in serial fashion. - * @static true - * @name concat - * @owner Observable + * 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 concatStatic() { - var observables = []; - for (var _i = 0; _i < arguments.length; _i++) { - observables[_i - 0] = arguments[_i]; - } - var scheduler = null; - var args = observables; - if (isScheduler_1.isScheduler(args[observables.length - 1])) { - scheduler = args.pop(); - } - if (scheduler === null && observables.length === 1 && observables[0] instanceof Observable_1.Observable) { - return observables[0]; - } - return new ArrayObservable_1.ArrayObservable(observables, scheduler).lift(new mergeAll_1.MergeAllOperator(1)); +var ONE_SECOND = 1000; +var ENTER_CLASSNAME = 'ng-enter'; +var LEAVE_CLASSNAME = 'ng-leave'; +var ENTER_SELECTOR = '.ng-enter'; +var LEAVE_SELECTOR = '.ng-leave'; +var NG_TRIGGER_CLASSNAME = 'ng-trigger'; +var NG_TRIGGER_SELECTOR = '.ng-trigger'; +var NG_ANIMATING_CLASSNAME = 'ng-animating'; +var NG_ANIMATING_SELECTOR = '.ng-animating'; +/** + * @param {?} value + * @return {?} + */ +function resolveTimingValue(value) { + if (typeof value == 'number') + return value; + var /** @type {?} */ matches = ((value)).match(/^(-?[\.\d]+)(m?s)/); + if (!matches || matches.length < 2) + return 0; + return _convertTimeValueToMS(parseFloat(matches[1]), matches[2]); } -exports.concatStatic = concatStatic; -//# sourceMappingURL=concat.js.map - -/***/ }), -/* 39 */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - -var __extends = (this && this.__extends) || function (d, b) { - for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); -}; -var ArrayObservable_1 = __webpack_require__(14); -var isArray_1 = __webpack_require__(15); -var Subscriber_1 = __webpack_require__(2); -var OuterSubscriber_1 = __webpack_require__(4); -var subscribeToResult_1 = __webpack_require__(3); -var iterator_1 = __webpack_require__(78); -/* tslint:enable:max-line-length */ /** - * @param observables - * @return {Observable} - * @method zip - * @owner Observable + * @param {?} value + * @param {?} unit + * @return {?} */ -function zipProto() { - var observables = []; - for (var _i = 0; _i < arguments.length; _i++) { - observables[_i - 0] = arguments[_i]; +function _convertTimeValueToMS(value, unit) { + switch (unit) { + case 's': + return value * ONE_SECOND; + default: + return value; } - return this.lift.call(zipStatic.apply(void 0, [this].concat(observables))); } -exports.zipProto = zipProto; -/* tslint:enable:max-line-length */ /** - * Combines multiple Observables to create an Observable whose values are calculated from the values, in order, of each - * of its input Observables. - * - * If the latest parameter is a function, this function is used to compute the created value from the input values. - * Otherwise, an array of the input values is returned. - * - * @example Combine age and name from different sources - * - * let age$ = Observable.of(27, 25, 29); - * let name$ = Observable.of('Foo', 'Bar', 'Beer'); - * let isDev$ = Observable.of(true, true, false); - * - * Observable - * .zip(age$, - * name$, - * isDev$, - * (age: number, name: string, isDev: boolean) => ({ age, name, isDev })) - * .subscribe(x => console.log(x)); - * - * // outputs - * // { age: 27, name: 'Foo', isDev: true } - * // { age: 25, name: 'Bar', isDev: true } - * // { age: 29, name: 'Beer', isDev: false } - * - * @param observables - * @return {Observable} - * @static true - * @name zip - * @owner Observable + * @param {?} timings + * @param {?} errors + * @param {?=} allowNegativeValues + * @return {?} */ -function zipStatic() { - var observables = []; - for (var _i = 0; _i < arguments.length; _i++) { - observables[_i - 0] = arguments[_i]; - } - var project = observables[observables.length - 1]; - if (typeof project === 'function') { - observables.pop(); - } - return new ArrayObservable_1.ArrayObservable(observables).lift(new ZipOperator(project)); +function resolveTiming(timings, errors, allowNegativeValues) { + return timings.hasOwnProperty('duration') ? (timings) : + parseTimeExpression(/** @type {?} */ (timings), errors, allowNegativeValues); } -exports.zipStatic = zipStatic; -var ZipOperator = (function () { - function ZipOperator(project) { - this.project = project; - } - ZipOperator.prototype.call = function (subscriber, source) { - return source.subscribe(new ZipSubscriber(subscriber, this.project)); - }; - return ZipOperator; -}()); -exports.ZipOperator = ZipOperator; /** - * We need this JSDoc comment for affecting ESDoc. - * @ignore - * @extends {Ignored} + * @param {?} exp + * @param {?} errors + * @param {?=} allowNegativeValues + * @return {?} */ -var ZipSubscriber = (function (_super) { - __extends(ZipSubscriber, _super); - function ZipSubscriber(destination, project, values) { - if (values === void 0) { values = Object.create(null); } - _super.call(this, destination); - this.iterators = []; - this.active = 0; - this.project = (typeof project === 'function') ? project : null; - this.values = values; - } - ZipSubscriber.prototype._next = function (value) { - var iterators = this.iterators; - if (isArray_1.isArray(value)) { - iterators.push(new StaticArrayIterator(value)); - } - else if (typeof value[iterator_1.iterator] === 'function') { - iterators.push(new StaticIterator(value[iterator_1.iterator]())); - } - else { - iterators.push(new ZipBufferIterator(this.destination, this, value)); - } - }; - ZipSubscriber.prototype._complete = function () { - var iterators = this.iterators; - var len = iterators.length; - if (len === 0) { - this.destination.complete(); - return; - } - this.active = len; - for (var i = 0; i < len; i++) { - var iterator = iterators[i]; - if (iterator.stillUnsubscribed) { - this.add(iterator.subscribe(iterator, i)); - } - else { - this.active--; // not an observable - } - } - }; - ZipSubscriber.prototype.notifyInactive = function () { - this.active--; - if (this.active === 0) { - this.destination.complete(); - } - }; - ZipSubscriber.prototype.checkIterators = function () { - var iterators = this.iterators; - var len = iterators.length; - var destination = this.destination; - // abort if not all of them have values - for (var i = 0; i < len; i++) { - var iterator = iterators[i]; - if (typeof iterator.hasValue === 'function' && !iterator.hasValue()) { - return; - } - } - var shouldComplete = false; - var args = []; - for (var i = 0; i < len; i++) { - var iterator = iterators[i]; - var result = iterator.next(); - // check to see if it's completed now that you've gotten - // the next value. - if (iterator.hasCompleted()) { - shouldComplete = true; - } - if (result.done) { - destination.complete(); - return; - } - args.push(result.value); +function parseTimeExpression(exp, errors, allowNegativeValues) { + var /** @type {?} */ regex = /^(-?[\.\d]+)(m?s)(?:\s+(-?[\.\d]+)(m?s))?(?:\s+([-a-z]+(?:\(.+?\))?))?$/i; + var /** @type {?} */ duration; + var /** @type {?} */ delay = 0; + var /** @type {?} */ easing = ''; + if (typeof exp === 'string') { + var /** @type {?} */ matches = exp.match(regex); + if (matches === null) { + errors.push("The provided timing value \"" + exp + "\" is invalid."); + return { duration: 0, delay: 0, easing: '' }; } - if (this.project) { - this._tryProject(args); + duration = _convertTimeValueToMS(parseFloat(matches[1]), matches[2]); + var /** @type {?} */ delayMatch = matches[3]; + if (delayMatch != null) { + delay = _convertTimeValueToMS(Math.floor(parseFloat(delayMatch)), matches[4]); } - else { - destination.next(args); + var /** @type {?} */ easingVal = matches[5]; + if (easingVal) { + easing = easingVal; } - if (shouldComplete) { - destination.complete(); + } + else { + duration = (exp); + } + if (!allowNegativeValues) { + var /** @type {?} */ containsErrors = false; + var /** @type {?} */ startIndex = errors.length; + if (duration < 0) { + errors.push("Duration values below 0 are not allowed for this animation step."); + containsErrors = true; } - }; - ZipSubscriber.prototype._tryProject = function (args) { - var result; - try { - result = this.project.apply(this, args); + if (delay < 0) { + errors.push("Delay values below 0 are not allowed for this animation step."); + containsErrors = true; } - catch (err) { - this.destination.error(err); - return; + if (containsErrors) { + errors.splice(startIndex, 0, "The provided timing value \"" + exp + "\" is invalid."); } - this.destination.next(result); - }; - return ZipSubscriber; -}(Subscriber_1.Subscriber)); -exports.ZipSubscriber = ZipSubscriber; -var StaticIterator = (function () { - function StaticIterator(iterator) { - this.iterator = iterator; - this.nextResult = iterator.next(); } - StaticIterator.prototype.hasValue = function () { - return true; - }; - StaticIterator.prototype.next = function () { - var result = this.nextResult; - this.nextResult = this.iterator.next(); - return result; - }; - StaticIterator.prototype.hasCompleted = function () { - var nextResult = this.nextResult; - return nextResult && nextResult.done; - }; - return StaticIterator; -}()); -var StaticArrayIterator = (function () { - function StaticArrayIterator(array) { - this.array = array; - this.index = 0; - this.length = 0; - this.length = array.length; + return { duration: duration, delay: delay, easing: easing }; +} +/** + * @param {?} obj + * @param {?=} destination + * @return {?} + */ +function copyObj(obj, destination) { + if (destination === void 0) { destination = {}; } + Object.keys(obj).forEach(function (prop) { destination[prop] = obj[prop]; }); + return destination; +} +/** + * @param {?} styles + * @return {?} + */ +function normalizeStyles(styles) { + var /** @type {?} */ normalizedStyles = {}; + if (Array.isArray(styles)) { + styles.forEach(function (data) { return copyStyles(data, false, normalizedStyles); }); } - StaticArrayIterator.prototype[iterator_1.iterator] = function () { - return this; - }; - StaticArrayIterator.prototype.next = function (value) { - var i = this.index++; - var array = this.array; - return i < this.length ? { value: array[i], done: false } : { value: null, done: true }; - }; - StaticArrayIterator.prototype.hasValue = function () { - return this.array.length > this.index; - }; - StaticArrayIterator.prototype.hasCompleted = function () { - return this.array.length === this.index; - }; - return StaticArrayIterator; -}()); + else { + copyStyles(styles, false, normalizedStyles); + } + return normalizedStyles; +} /** - * We need this JSDoc comment for affecting ESDoc. - * @ignore - * @extends {Ignored} + * @param {?} styles + * @param {?} readPrototype + * @param {?=} destination + * @return {?} */ -var ZipBufferIterator = (function (_super) { - __extends(ZipBufferIterator, _super); - function ZipBufferIterator(destination, parent, observable) { - _super.call(this, destination); - this.parent = parent; - this.observable = observable; - this.stillUnsubscribed = true; - this.buffer = []; - this.isComplete = false; +function copyStyles(styles, readPrototype, destination) { + if (destination === void 0) { destination = {}; } + if (readPrototype) { + // we make use of a for-in loop so that the + // prototypically inherited properties are + // revealed from the backFill map + for (var /** @type {?} */ prop in styles) { + destination[prop] = styles[prop]; + } } - ZipBufferIterator.prototype[iterator_1.iterator] = function () { - return this; - }; - // NOTE: there is actually a name collision here with Subscriber.next and Iterator.next - // this is legit because `next()` will never be called by a subscription in this case. - ZipBufferIterator.prototype.next = function () { - var buffer = this.buffer; - if (buffer.length === 0 && this.isComplete) { - return { value: null, done: true }; - } - else { - return { value: buffer.shift(), done: false }; - } - }; - ZipBufferIterator.prototype.hasValue = function () { - return this.buffer.length > 0; - }; - ZipBufferIterator.prototype.hasCompleted = function () { - return this.buffer.length === 0 && this.isComplete; - }; - ZipBufferIterator.prototype.notifyComplete = function () { - if (this.buffer.length > 0) { - this.isComplete = true; - this.parent.notifyInactive(); - } - else { - this.destination.complete(); - } - }; - ZipBufferIterator.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) { - this.buffer.push(innerValue); - this.parent.checkIterators(); - }; - ZipBufferIterator.prototype.subscribe = function (value, index) { - return subscribeToResult_1.subscribeToResult(this, this.observable, this, index); - }; - return ZipBufferIterator; -}(OuterSubscriber_1.OuterSubscriber)); -//# sourceMappingURL=zip.js.map - -/***/ }), -/* 40 */ -/***/ (function(module, exports, __webpack_require__) { - -module.exports = (__webpack_require__(1))(26); - -/***/ }), -/* 41 */ -/***/ (function(module, exports, __webpack_require__) { - -module.exports = (__webpack_require__(1))(65); - -/***/ }), -/* 42 */ -/***/ (function(module, exports, __webpack_require__) { - -module.exports = (__webpack_require__(1))(82); - -/***/ }), -/* 43 */ -/***/ (function(module, exports, __webpack_require__) { - -module.exports = (__webpack_require__(1))(88); - -/***/ }), -/* 44 */ -/***/ (function(module, exports, __webpack_require__) { - + else { + copyObj(styles, destination); + } + return destination; +} /** - * @license Angular v4.2.5 - * (c) 2010-2017 Google, Inc. https://angular.io/ - * License: MIT + * @param {?} element + * @param {?} styles + * @return {?} */ -(function (global, factory) { - true ? factory(exports, __webpack_require__(10), __webpack_require__(84), __webpack_require__(46), __webpack_require__(17), __webpack_require__(380), __webpack_require__(29), __webpack_require__(93), __webpack_require__(0), __webpack_require__(6), __webpack_require__(88), __webpack_require__(42), __webpack_require__(86), __webpack_require__(68)) : - typeof define === 'function' && define.amd ? define(['exports', '@angular/core', '@angular/platform-browser', '@angular/animations/browser', '@angular/common', '@angular/compiler', '@angular/http', '@angular/platform-browser/animations', 'rxjs/Observable', 'rxjs/Subject', 'url', 'rxjs/operator/filter', 'rxjs/operator/first', 'rxjs/operator/toPromise'], factory) : - (factory((global.ng = global.ng || {}, global.ng.platformServer = global.ng.platformServer || {}),global.ng.core,global.ng.platformBrowser,global._angular_animations_browser,global.ng.common,global.ng.compiler,global._angular_http,global._angular_platformBrowser_animations,global.Rx,global.Rx,global.url,global.Rx.Observable.prototype,global.Rx.Observable.prototype,global.Rx.Observable.prototype)); -}(this, (function (exports,_angular_core,_angular_platformBrowser,_angular_animations_browser,_angular_common,_angular_compiler,_angular_http,_angular_platformBrowser_animations,rxjs_Observable,rxjs_Subject,url,rxjs_operator_filter,rxjs_operator_first,rxjs_operator_toPromise) { 'use strict'; - -/*! ***************************************************************************** -Copyright (c) Microsoft Corporation. All rights reserved. -Licensed under the Apache License, Version 2.0 (the "License"); you may not use -this file except in compliance with the License. You may obtain a copy of the -License at http://www.apache.org/licenses/LICENSE-2.0 - -THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED -WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, -MERCHANTABLITY OR NON-INFRINGEMENT. - -See the Apache Version 2.0 License for specific language governing permissions -and limitations under the License. -***************************************************************************** */ -/* global Reflect, Promise */ - -var extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; - -function __extends(d, b) { - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); +function setStyles(element, styles) { + if (element['style']) { + Object.keys(styles).forEach(function (prop) { + var /** @type {?} */ camelProp = dashCaseToCamelCase(prop); + element.style[camelProp] = styles[prop]; + }); + } } - /** - * @license Angular v4.2.5 - * (c) 2010-2017 Google, Inc. https://angular.io/ - * License: MIT + * @param {?} element + * @param {?} styles + * @return {?} */ +function eraseStyles(element, styles) { + if (element['style']) { + Object.keys(styles).forEach(function (prop) { + var /** @type {?} */ camelProp = dashCaseToCamelCase(prop); + element.style[camelProp] = ''; + }); + } +} /** - * @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 + * @param {?} steps + * @return {?} */ -var parse5 = __webpack_require__(35); +function normalizeAnimationEntry(steps) { + if (Array.isArray(steps)) { + if (steps.length == 1) + return steps[0]; + return _angular_animations.sequence(steps); + } + return (steps); +} /** - * Representation of the current platform state. - * - * \@experimental + * @param {?} value + * @param {?} options + * @param {?} errors + * @return {?} */ -var PlatformState = (function () { - /** - * @param {?} _doc - */ - function PlatformState(_doc) { - this._doc = _doc; +function validateStyleParams(value, options, errors) { + var /** @type {?} */ params = options.params || {}; + if (typeof value !== 'string') + return; + var /** @type {?} */ matches = value.toString().match(PARAM_REGEX); + if (matches) { + matches.forEach(function (varName) { + if (!params.hasOwnProperty(varName)) { + errors.push("Unable to resolve the local animation param " + varName + " in the given list of values"); + } + }); } - /** - * Renders the current state of the platform to string. - * @return {?} - */ - PlatformState.prototype.renderToString = function () { return _angular_platformBrowser.ɵgetDOM().getInnerHTML(this._doc); }; - /** - * Returns the current DOM state. - * @return {?} - */ - PlatformState.prototype.getDocument = function () { return this._doc; }; - return PlatformState; -}()); -PlatformState.decorators = [ - { type: _angular_core.Injectable }, -]; +} +var PARAM_REGEX = /\{\{\s*(.+?)\s*\}\}/g; /** - * @nocollapse + * @param {?} value + * @param {?} params + * @param {?} errors + * @return {?} */ -PlatformState.ctorParameters = function () { return [ - { type: undefined, decorators: [{ type: _angular_core.Inject, args: [_angular_platformBrowser.DOCUMENT,] },] }, -]; }; +function interpolateParams(value, params, errors) { + var /** @type {?} */ original = value.toString(); + var /** @type {?} */ str = original.replace(PARAM_REGEX, function (_, varName) { + var /** @type {?} */ localVal = params[varName]; + // this means that the value was never overidden by the data passed in by the user + if (!params.hasOwnProperty(varName)) { + errors.push("Please provide a value for the animation param " + varName); + localVal = ''; + } + return localVal.toString(); + }); + // we do this to assert that numeric values stay as they are + return str == original ? value : str; +} /** - * @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 + * @param {?} iterator + * @return {?} */ -var xhr2 = __webpack_require__(377); -var isAbsoluteUrl = /^[a-zA-Z\-\+.]+:\/\//; +function iteratorToArray(iterator) { + var /** @type {?} */ arr = []; + var /** @type {?} */ item = iterator.next(); + while (!item.done) { + arr.push(item.value); + item = iterator.next(); + } + return arr; +} /** - * @param {?} url + * @param {?} source + * @param {?} destination * @return {?} */ -function validateRequestUrl(url$$1) { - if (!isAbsoluteUrl.test(url$$1)) { - throw new Error("URLs requested via Http on the server must be absolute. URL: " + url$$1); +function mergeAnimationOptions(source, destination) { + if (source.params) { + var /** @type {?} */ p0_1 = source.params; + if (!destination.params) { + destination.params = {}; + } + var /** @type {?} */ p1_1 = destination.params; + Object.keys(p0_1).forEach(function (param) { + if (!p1_1.hasOwnProperty(param)) { + p1_1[param] = p0_1[param]; + } + }); } + return destination; } -var ServerXhr = (function () { - function ServerXhr() { - } - /** - * @return {?} - */ - ServerXhr.prototype.build = function () { return new xhr2.XMLHttpRequest(); }; - return ServerXhr; -}()); -ServerXhr.decorators = [ - { type: _angular_core.Injectable }, -]; +var DASH_CASE_REGEXP = /-+([a-z0-9])/g; /** - * @nocollapse + * @param {?} input + * @return {?} */ -ServerXhr.ctorParameters = function () { return []; }; -var ServerXsrfStrategy = (function () { - function ServerXsrfStrategy() { - } - /** - * @param {?} req - * @return {?} - */ - ServerXsrfStrategy.prototype.configureRequest = function (req) { }; - return ServerXsrfStrategy; -}()); -ServerXsrfStrategy.decorators = [ - { type: _angular_core.Injectable }, -]; +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(); + }); +} /** - * @nocollapse + * @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 */ -ServerXsrfStrategy.ctorParameters = function () { return []; }; -var ZoneMacroTaskConnection = (function () { +var EMPTY_ANIMATION_OPTIONS = {}; +/** + * @abstract + */ +var Ast = (function () { + function Ast() { + this.options = EMPTY_ANIMATION_OPTIONS; + } /** - * @param {?} request - * @param {?} backend + * @abstract + * @param {?} ast + * @param {?} context + * @return {?} */ - function ZoneMacroTaskConnection(request, backend) { - var _this = this; - this.request = request; - validateRequestUrl(request.url); - this.response = new rxjs_Observable.Observable(function (observer) { - var task = null; - var scheduled = false; - var sub = null; - var savedResult = null; - var savedError = null; - var scheduleTask = function (_task) { - task = _task; - scheduled = true; - _this.lastConnection = backend.createConnection(request); - sub = _this.lastConnection.response - .subscribe(function (res) { return savedResult = res; }, function (err) { - if (!scheduled) { - throw new Error('invoke twice'); - } - savedError = err; - scheduled = false; - task.invoke(); - }, function () { - if (!scheduled) { - throw new Error('invoke twice'); - } - scheduled = false; - task.invoke(); - }); - }; - var cancelTask = function (_task) { - if (!scheduled) { - return; - } - scheduled = false; - if (sub) { - sub.unsubscribe(); - sub = null; - } - }; - var onComplete = function () { - if (savedError !== null) { - observer.error(savedError); - } - else { - observer.next(savedResult); - observer.complete(); - } - }; - // MockBackend is currently synchronous, which means that if scheduleTask is by - // scheduleMacroTask, the request will hit MockBackend and the response will be - // sent, causing task.invoke() to be called. - var _task = Zone.current.scheduleMacroTask('ZoneMacroTaskConnection.subscribe', onComplete, {}, function () { return null; }, cancelTask); - scheduleTask(_task); - return function () { - if (scheduled && task) { - task.zone.cancelTask(task); - scheduled = false; - } - if (sub) { - sub.unsubscribe(); - sub = null; - } - }; - }); - } - Object.defineProperty(ZoneMacroTaskConnection.prototype, "readyState", { + Ast.prototype.visit = function (ast, context) { }; + Object.defineProperty(Ast.prototype, "params", { /** * @return {?} */ - get: function () { - return !!this.lastConnection ? this.lastConnection.readyState : _angular_http.ReadyState.Unsent; - }, + get: function () { return this.options['params'] || null; }, enumerable: true, configurable: true }); - return ZoneMacroTaskConnection; + return Ast; }()); -var ZoneMacroTaskBackend = (function () { +var TriggerAst = (function (_super) { + __extends(TriggerAst, _super); /** - * @param {?} backend + * @param {?} name + * @param {?} states + * @param {?} transitions */ - function ZoneMacroTaskBackend(backend) { - this.backend = backend; + function TriggerAst(name, states, transitions) { + var _this = _super.call(this) || this; + _this.name = name; + _this.states = states; + _this.transitions = transitions; + _this.queryCount = 0; + _this.depCount = 0; + return _this; } /** - * @param {?} request + * @param {?} visitor + * @param {?} context * @return {?} */ - ZoneMacroTaskBackend.prototype.createConnection = function (request) { - return new ZoneMacroTaskConnection(request, this.backend); - }; - return ZoneMacroTaskBackend; -}()); -/** - * @param {?} xhrBackend - * @param {?} options - * @return {?} - */ -function httpFactory(xhrBackend, options) { - var /** @type {?} */ macroBackend = new ZoneMacroTaskBackend(xhrBackend); - return new _angular_http.Http(macroBackend, options); -} -var SERVER_HTTP_PROVIDERS = [ - { provide: _angular_http.Http, useFactory: httpFactory, deps: [_angular_http.XHRBackend, _angular_http.RequestOptions] }, - { provide: _angular_http.BrowserXhr, useClass: ServerXhr }, - { provide: _angular_http.XSRFStrategy, useClass: ServerXsrfStrategy }, -]; -/** - * @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 DI token for setting the initial config for the platform. - * - * \@experimental - */ -var INITIAL_CONFIG = new _angular_core.InjectionToken('Server.INITIAL_CONFIG'); -/** - * @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 - */ -/** - * @param {?} urlStr - * @return {?} - */ -function parseUrl(urlStr) { - var /** @type {?} */ parsedUrl = url.parse(urlStr); - return { - pathname: parsedUrl.pathname || '', - search: parsedUrl.search || '', - hash: parsedUrl.hash || '', - }; -} -/** - * Server-side implementation of URL state. Implements `pathname`, `search`, and `hash` - * but not the state stack. - */ -var ServerPlatformLocation = (function () { + TriggerAst.prototype.visit = function (visitor, context) { return visitor.visitTrigger(this, context); }; + return TriggerAst; +}(Ast)); +var StateAst = (function (_super) { + __extends(StateAst, _super); /** - * @param {?} _doc - * @param {?} _config + * @param {?} name + * @param {?} style */ - function ServerPlatformLocation(_doc, _config) { - this._doc = _doc; - this._path = '/'; - this._search = ''; - this._hash = ''; - this._hashUpdate = new rxjs_Subject.Subject(); - var config = _config; - if (!!config && !!config.url) { - var parsedUrl = parseUrl(config.url); - this._path = parsedUrl.pathname; - this._search = parsedUrl.search; - this._hash = parsedUrl.hash; - } + function StateAst(name, style$$1) { + var _this = _super.call(this) || this; + _this.name = name; + _this.style = style$$1; + return _this; } /** + * @param {?} visitor + * @param {?} context * @return {?} */ - ServerPlatformLocation.prototype.getBaseHrefFromDOM = function () { return ((_angular_platformBrowser.ɵgetDOM().getBaseHref(this._doc))); }; + StateAst.prototype.visit = function (visitor, context) { return visitor.visitState(this, context); }; + return StateAst; +}(Ast)); +var TransitionAst = (function (_super) { + __extends(TransitionAst, _super); /** - * @param {?} fn - * @return {?} + * @param {?} matchers + * @param {?} animation */ - ServerPlatformLocation.prototype.onPopState = function (fn) { - // No-op: a state stack is not implemented, so - // no events will ever come. - }; + function TransitionAst(matchers, animation) { + var _this = _super.call(this) || this; + _this.matchers = matchers; + _this.animation = animation; + _this.queryCount = 0; + _this.depCount = 0; + return _this; + } /** - * @param {?} fn + * @param {?} visitor + * @param {?} context * @return {?} */ - ServerPlatformLocation.prototype.onHashChange = function (fn) { this._hashUpdate.subscribe(fn); }; - Object.defineProperty(ServerPlatformLocation.prototype, "pathname", { - /** - * @return {?} - */ - get: function () { return this._path; }, - enumerable: true, - configurable: true - }); - Object.defineProperty(ServerPlatformLocation.prototype, "search", { - /** - * @return {?} - */ - get: function () { return this._search; }, - enumerable: true, - configurable: true - }); - Object.defineProperty(ServerPlatformLocation.prototype, "hash", { - /** - * @return {?} - */ - get: function () { return this._hash; }, - enumerable: true, - configurable: true - }); - Object.defineProperty(ServerPlatformLocation.prototype, "url", { - /** - * @return {?} - */ - get: function () { return "" + this.pathname + this.search + this.hash; }, - enumerable: true, - configurable: true - }); + TransitionAst.prototype.visit = function (visitor, context) { return visitor.visitTransition(this, context); }; + return TransitionAst; +}(Ast)); +var SequenceAst = (function (_super) { + __extends(SequenceAst, _super); /** - * @param {?} value - * @param {?} oldUrl - * @return {?} + * @param {?} steps */ - ServerPlatformLocation.prototype.setHash = function (value, oldUrl) { - var _this = this; - if (this._hash === value) { - // Don't fire events if the hash has not changed. - return; - } - this._hash = value; - var /** @type {?} */ newUrl = this.url; - scheduleMicroTask(function () { return _this._hashUpdate.next(/** @type {?} */ ({ type: 'hashchange', oldUrl: oldUrl, newUrl: newUrl })); }); - }; + function SequenceAst(steps) { + var _this = _super.call(this) || this; + _this.steps = steps; + return _this; + } /** - * @param {?} state - * @param {?} title - * @param {?} newUrl + * @param {?} visitor + * @param {?} context * @return {?} */ - ServerPlatformLocation.prototype.replaceState = function (state, title, newUrl) { - var /** @type {?} */ oldUrl = this.url; - var /** @type {?} */ parsedUrl = parseUrl(newUrl); - this._path = parsedUrl.pathname; - this._search = parsedUrl.search; - this.setHash(parsedUrl.hash, oldUrl); - }; + SequenceAst.prototype.visit = function (visitor, context) { return visitor.visitSequence(this, context); }; + return SequenceAst; +}(Ast)); +var GroupAst = (function (_super) { + __extends(GroupAst, _super); /** - * @param {?} state - * @param {?} title - * @param {?} newUrl - * @return {?} + * @param {?} steps */ - ServerPlatformLocation.prototype.pushState = function (state, title, newUrl) { - this.replaceState(state, title, newUrl); - }; + function GroupAst(steps) { + var _this = _super.call(this) || this; + _this.steps = steps; + return _this; + } /** + * @param {?} visitor + * @param {?} context * @return {?} */ - ServerPlatformLocation.prototype.forward = function () { throw new Error('Not implemented'); }; + GroupAst.prototype.visit = function (visitor, context) { return visitor.visitGroup(this, context); }; + return GroupAst; +}(Ast)); +var AnimateAst = (function (_super) { + __extends(AnimateAst, _super); /** - * @return {?} + * @param {?} timings + * @param {?} style */ - ServerPlatformLocation.prototype.back = function () { throw new Error('Not implemented'); }; - return ServerPlatformLocation; -}()); -ServerPlatformLocation.decorators = [ - { type: _angular_core.Injectable }, -]; -/** - * @nocollapse - */ -ServerPlatformLocation.ctorParameters = function () { return [ - { type: undefined, decorators: [{ type: _angular_core.Inject, args: [_angular_platformBrowser.DOCUMENT,] },] }, - { type: undefined, decorators: [{ type: _angular_core.Optional }, { type: _angular_core.Inject, args: [INITIAL_CONFIG,] },] }, -]; }; -/** - * @param {?} fn - * @return {?} - */ -function scheduleMicroTask(fn) { - Zone.current.scheduleMicroTask('scheduleMicrotask', fn); -} -/** - * @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 parse5$1 = __webpack_require__(35); -var treeAdapter; -var _attrToPropMap = { - 'class': 'className', - 'innerHtml': 'innerHTML', - 'readonly': 'readOnly', - 'tabindex': 'tabIndex', -}; -var mapProps = ['attribs', 'x-attribsNamespace', 'x-attribsPrefix']; -/** - * @param {?} methodName - * @return {?} - */ -function _notImplemented(methodName) { - return new Error('This method is not implemented in Parse5DomAdapter: ' + methodName); -} -/** - * @param {?} el - * @param {?} name - * @return {?} - */ -function _getElement(el, name) { - for (var /** @type {?} */ i = 0; i < el.childNodes.length; i++) { - var /** @type {?} */ node = el.childNodes[i]; - if (node.name === name) { - return node; - } - } - return null; -} -/** - * Parses a document string to a Document object. - * @param {?} html - * @return {?} - */ -function parseDocument(html) { - var /** @type {?} */ doc = parse5$1.parse(html, { treeAdapter: parse5$1.treeAdapters.htmlparser2 }); - var /** @type {?} */ docElement = _getElement(doc, 'html'); - doc['head'] = _getElement(docElement, 'head'); - doc['body'] = _getElement(docElement, 'body'); - doc['_window'] = {}; - return doc; -} -/** - * A `DomAdapter` powered by the `parse5` NodeJS module. - * - * \@security Tread carefully! Interacting with the DOM directly is dangerous and - * can introduce XSS risks. - */ -var Parse5DomAdapter = (function (_super) { - __extends(Parse5DomAdapter, _super); - function Parse5DomAdapter() { - return _super !== null && _super.apply(this, arguments) || this; + function AnimateAst(timings, style$$1) { + var _this = _super.call(this) || this; + _this.timings = timings; + _this.style = style$$1; + return _this; } /** + * @param {?} visitor + * @param {?} context * @return {?} */ - Parse5DomAdapter.makeCurrent = function () { - treeAdapter = parse5$1.treeAdapters.htmlparser2; - _angular_platformBrowser.ɵsetRootDomAdapter(new Parse5DomAdapter()); - }; - /** - * @param {?} nodeA - * @param {?} nodeB - * @return {?} - */ - Parse5DomAdapter.prototype.contains = function (nodeA, nodeB) { - var /** @type {?} */ inner = nodeB; - while (inner) { - if (inner === nodeA) - return true; - inner = inner.parent; - } - return false; - }; + AnimateAst.prototype.visit = function (visitor, context) { return visitor.visitAnimate(this, context); }; + return AnimateAst; +}(Ast)); +var StyleAst = (function (_super) { + __extends(StyleAst, _super); /** - * @param {?} element - * @param {?} name - * @return {?} + * @param {?} styles + * @param {?} easing + * @param {?} offset */ - Parse5DomAdapter.prototype.hasProperty = function (element, name) { - return _HTMLElementPropertyList.indexOf(name) > -1; - }; + function StyleAst(styles, easing, offset) { + var _this = _super.call(this) || this; + _this.styles = styles; + _this.easing = easing; + _this.offset = offset; + _this.isEmptyStep = false; + return _this; + } /** - * @param {?} el - * @param {?} name - * @param {?} value + * @param {?} visitor + * @param {?} context * @return {?} */ - Parse5DomAdapter.prototype.setProperty = function (el, name, value) { - if (name === 'innerHTML') { - this.setInnerHTML(el, value); - } - else if (name === 'innerText') { - this.setText(el, value); - } - else if (name === 'className') { - el.attribs['class'] = el.className = value; - } - else { - el[name] = value; - } - }; + StyleAst.prototype.visit = function (visitor, context) { return visitor.visitStyle(this, context); }; + return StyleAst; +}(Ast)); +var KeyframesAst = (function (_super) { + __extends(KeyframesAst, _super); /** - * @param {?} el - * @param {?} name - * @return {?} + * @param {?} styles */ - Parse5DomAdapter.prototype.getProperty = function (el, name) { return el[name]; }; + function KeyframesAst(styles) { + var _this = _super.call(this) || this; + _this.styles = styles; + return _this; + } /** - * @param {?} error + * @param {?} visitor + * @param {?} context * @return {?} */ - Parse5DomAdapter.prototype.logError = function (error) { console.error(error); }; + KeyframesAst.prototype.visit = function (visitor, context) { return visitor.visitKeyframes(this, context); }; + return KeyframesAst; +}(Ast)); +var ReferenceAst = (function (_super) { + __extends(ReferenceAst, _super); /** - * @param {?} error - * @return {?} + * @param {?} animation */ - Parse5DomAdapter.prototype.log = function (error) { console.log(error); }; + function ReferenceAst(animation) { + var _this = _super.call(this) || this; + _this.animation = animation; + return _this; + } /** - * @param {?} error + * @param {?} visitor + * @param {?} context * @return {?} */ - Parse5DomAdapter.prototype.logGroup = function (error) { console.error(error); }; + ReferenceAst.prototype.visit = function (visitor, context) { return visitor.visitReference(this, context); }; + return ReferenceAst; +}(Ast)); +var AnimateChildAst = (function (_super) { + __extends(AnimateChildAst, _super); + function AnimateChildAst() { + return _super.call(this) || this; + } /** + * @param {?} visitor + * @param {?} context * @return {?} */ - Parse5DomAdapter.prototype.logGroupEnd = function () { }; - Object.defineProperty(Parse5DomAdapter.prototype, "attrToPropMap", { - /** - * @return {?} - */ - get: function () { return _attrToPropMap; }, - enumerable: true, - configurable: true - }); + AnimateChildAst.prototype.visit = function (visitor, context) { return visitor.visitAnimateChild(this, context); }; + return AnimateChildAst; +}(Ast)); +var AnimateRefAst = (function (_super) { + __extends(AnimateRefAst, _super); /** - * @param {?} el - * @param {?} selector - * @return {?} + * @param {?} animation */ - Parse5DomAdapter.prototype.querySelector = function (el, selector) { - return this.querySelectorAll(el, selector)[0] || null; - }; + function AnimateRefAst(animation) { + var _this = _super.call(this) || this; + _this.animation = animation; + return _this; + } /** - * @param {?} el - * @param {?} selector + * @param {?} visitor + * @param {?} context * @return {?} */ - Parse5DomAdapter.prototype.querySelectorAll = function (el, selector) { - var _this = this; - var /** @type {?} */ res = []; - var /** @type {?} */ _recursive = function (result, node, selector, matcher) { - var /** @type {?} */ cNodes = node.childNodes; - if (cNodes && cNodes.length > 0) { - for (var /** @type {?} */ i = 0; i < cNodes.length; i++) { - var /** @type {?} */ childNode = cNodes[i]; - if (_this.elementMatches(childNode, selector, matcher)) { - result.push(childNode); - } - _recursive(result, childNode, selector, matcher); - } - } - }; - var /** @type {?} */ matcher = new _angular_compiler.SelectorMatcher(); - matcher.addSelectables(_angular_compiler.CssSelector.parse(selector)); - _recursive(res, el, selector, matcher); - return res; - }; + AnimateRefAst.prototype.visit = function (visitor, context) { return visitor.visitAnimateRef(this, context); }; + return AnimateRefAst; +}(Ast)); +var QueryAst = (function (_super) { + __extends(QueryAst, _super); /** - * @param {?} node * @param {?} selector - * @param {?=} matcher - * @return {?} - */ - Parse5DomAdapter.prototype.elementMatches = function (node, selector, matcher) { - if (matcher === void 0) { matcher = null; } - if (this.isElementNode(node) && selector === '*') { - return true; - } - var /** @type {?} */ result = false; - if (selector && selector.charAt(0) == '#') { - result = this.getAttribute(node, 'id') == selector.substring(1); - } - else if (selector) { - if (!matcher) { - matcher = new _angular_compiler.SelectorMatcher(); - matcher.addSelectables(_angular_compiler.CssSelector.parse(selector)); - } - var /** @type {?} */ cssSelector = new _angular_compiler.CssSelector(); - cssSelector.setElement(this.tagName(node)); - if (node.attribs) { - for (var /** @type {?} */ attrName in node.attribs) { - cssSelector.addAttribute(attrName, node.attribs[attrName]); - } - } - var /** @type {?} */ classList = this.classList(node); - for (var /** @type {?} */ i = 0; i < classList.length; i++) { - cssSelector.addClassName(classList[i]); - } - matcher.match(cssSelector, function (selector, cb) { result = true; }); - } - return result; - }; - /** - * @param {?} el - * @param {?} evt - * @param {?} listener - * @return {?} - */ - Parse5DomAdapter.prototype.on = function (el, evt, listener) { - var /** @type {?} */ listenersMap = el._eventListenersMap; - if (!listenersMap) { - listenersMap = {}; - el._eventListenersMap = listenersMap; - } - var /** @type {?} */ listeners = listenersMap[evt] || []; - listenersMap[evt] = listeners.concat([listener]); - }; - /** - * @param {?} el - * @param {?} evt - * @param {?} listener - * @return {?} - */ - Parse5DomAdapter.prototype.onAndCancel = function (el, evt, listener) { - this.on(el, evt, listener); - return function () { remove(/** @type {?} */ ((el._eventListenersMap[evt])), listener); }; - }; - /** - * @param {?} el - * @param {?} evt - * @return {?} + * @param {?} limit + * @param {?} optional + * @param {?} includeSelf + * @param {?} animation */ - Parse5DomAdapter.prototype.dispatchEvent = function (el, evt) { - if (!evt.target) { - evt.target = el; - } - if (el._eventListenersMap) { - var /** @type {?} */ listeners = el._eventListenersMap[evt.type]; - if (listeners) { - for (var /** @type {?} */ i = 0; i < listeners.length; i++) { - listeners[i](evt); - } - } - } - if (el.parent) { - this.dispatchEvent(el.parent, evt); - } - if (el._window) { - this.dispatchEvent(el._window, evt); - } - }; + function QueryAst(selector, limit, optional, includeSelf, animation) { + var _this = _super.call(this) || this; + _this.selector = selector; + _this.limit = limit; + _this.optional = optional; + _this.includeSelf = includeSelf; + _this.animation = animation; + return _this; + } /** - * @param {?} eventType + * @param {?} visitor + * @param {?} context * @return {?} */ - Parse5DomAdapter.prototype.createMouseEvent = function (eventType) { return this.createEvent(eventType); }; + QueryAst.prototype.visit = function (visitor, context) { return visitor.visitQuery(this, context); }; + return QueryAst; +}(Ast)); +var StaggerAst = (function (_super) { + __extends(StaggerAst, _super); /** - * @param {?} eventType - * @return {?} + * @param {?} timings + * @param {?} animation */ - Parse5DomAdapter.prototype.createEvent = function (eventType) { - var /** @type {?} */ event = ({ - type: eventType, - defaultPrevented: false, - preventDefault: function () { ((event)).defaultPrevented = true; } - }); - return event; - }; + function StaggerAst(timings, animation) { + var _this = _super.call(this) || this; + _this.timings = timings; + _this.animation = animation; + return _this; + } /** - * @param {?} event + * @param {?} visitor + * @param {?} context * @return {?} */ - Parse5DomAdapter.prototype.preventDefault = function (event) { event.returnValue = false; }; + StaggerAst.prototype.visit = function (visitor, context) { return visitor.visitStagger(this, context); }; + return StaggerAst; +}(Ast)); +var TimingAst = (function (_super) { + __extends(TimingAst, _super); /** - * @param {?} event - * @return {?} + * @param {?} duration + * @param {?=} delay + * @param {?=} easing */ - Parse5DomAdapter.prototype.isPrevented = function (event) { return event.returnValue != null && !event.returnValue; }; + function TimingAst(duration, delay, easing) { + if (delay === void 0) { delay = 0; } + if (easing === void 0) { easing = null; } + var _this = _super.call(this) || this; + _this.duration = duration; + _this.delay = delay; + _this.easing = easing; + return _this; + } /** - * @param {?} el + * @param {?} visitor + * @param {?} context * @return {?} */ - Parse5DomAdapter.prototype.getInnerHTML = function (el) { - return parse5$1.serialize(this.templateAwareRoot(el), { treeAdapter: treeAdapter }); - }; + TimingAst.prototype.visit = function (visitor, context) { return visitor.visitTiming(this, context); }; + return TimingAst; +}(Ast)); +var DynamicTimingAst = (function (_super) { + __extends(DynamicTimingAst, _super); /** - * @param {?} el - * @return {?} + * @param {?} value */ - Parse5DomAdapter.prototype.getTemplateContent = function (el) { return null; }; + function DynamicTimingAst(value) { + var _this = _super.call(this, 0, 0, '') || this; + _this.value = value; + return _this; + } /** - * @param {?} el + * @param {?} visitor + * @param {?} context * @return {?} */ - Parse5DomAdapter.prototype.getOuterHTML = function (el) { - var /** @type {?} */ fragment = treeAdapter.createDocumentFragment(); - this.appendChild(fragment, el); - return parse5$1.serialize(fragment, { treeAdapter: treeAdapter }); - }; - /** - * @param {?} node - * @return {?} - */ - Parse5DomAdapter.prototype.nodeName = function (node) { return node.tagName; }; + DynamicTimingAst.prototype.visit = function (visitor, context) { return visitor.visitTiming(this, context); }; + return DynamicTimingAst; +}(TimingAst)); +/** + * @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 + */ +/** + * @param {?} visitor + * @param {?} node + * @param {?} context + * @return {?} + */ +function visitAnimationNode(visitor, node, context) { + switch (node.type) { + case 7 /* Trigger */: + return visitor.visitTrigger(/** @type {?} */ (node), context); + case 0 /* State */: + return visitor.visitState(/** @type {?} */ (node), context); + case 1 /* Transition */: + return visitor.visitTransition(/** @type {?} */ (node), context); + case 2 /* Sequence */: + return visitor.visitSequence(/** @type {?} */ (node), context); + case 3 /* Group */: + return visitor.visitGroup(/** @type {?} */ (node), context); + case 4 /* Animate */: + return visitor.visitAnimate(/** @type {?} */ (node), context); + case 5 /* Keyframes */: + return visitor.visitKeyframes(/** @type {?} */ (node), context); + case 6 /* Style */: + return visitor.visitStyle(/** @type {?} */ (node), context); + case 8 /* Reference */: + return visitor.visitReference(/** @type {?} */ (node), context); + case 9 /* AnimateChild */: + return visitor.visitAnimateChild(/** @type {?} */ (node), context); + case 10 /* AnimateRef */: + return visitor.visitAnimateRef(/** @type {?} */ (node), context); + case 11 /* Query */: + return visitor.visitQuery(/** @type {?} */ (node), context); + case 12 /* Stagger */: + return visitor.visitStagger(/** @type {?} */ (node), context); + default: + throw new Error("Unable to resolve animation metadata node #" + node.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 + */ +var ANY_STATE = '*'; +/** + * @param {?} transitionValue + * @param {?} errors + * @return {?} + */ +function parseTransitionExpr(transitionValue, errors) { + var /** @type {?} */ expressions = []; + if (typeof transitionValue == 'string') { + ((transitionValue)) + .split(/\s*,\s*/) + .forEach(function (str) { return parseInnerTransitionStr(str, expressions, errors); }); + } + else { + expressions.push(/** @type {?} */ (transitionValue)); + } + return expressions; +} +/** + * @param {?} eventStr + * @param {?} expressions + * @param {?} errors + * @return {?} + */ +function parseInnerTransitionStr(eventStr, expressions, errors) { + if (eventStr[0] == ':') { + eventStr = parseAnimationAlias(eventStr, errors); + } + var /** @type {?} */ match = eventStr.match(/^(\*|[-\w]+)\s*()\s*(\*|[-\w]+)$/); + if (match == null || match.length < 4) { + errors.push("The provided transition expression \"" + eventStr + "\" is not supported"); + return expressions; + } + var /** @type {?} */ fromState = match[1]; + var /** @type {?} */ separator = match[2]; + var /** @type {?} */ toState = match[3]; + expressions.push(makeLambdaFromStates(fromState, toState)); + var /** @type {?} */ isFullAnyStateExpr = fromState == ANY_STATE && toState == ANY_STATE; + if (separator[0] == '<' && !isFullAnyStateExpr) { + expressions.push(makeLambdaFromStates(toState, fromState)); + } +} +/** + * @param {?} alias + * @param {?} errors + * @return {?} + */ +function parseAnimationAlias(alias, errors) { + switch (alias) { + case ':enter': + return 'void => *'; + case ':leave': + return '* => void'; + default: + errors.push("The transition alias value \"" + alias + "\" is not supported"); + return '* => *'; + } +} +/** + * @param {?} lhs + * @param {?} rhs + * @return {?} + */ +function makeLambdaFromStates(lhs, rhs) { + return function (fromState, toState) { + var /** @type {?} */ lhsMatch = lhs == ANY_STATE || lhs == fromState; + var /** @type {?} */ rhsMatch = rhs == ANY_STATE || rhs == toState; + if (!lhsMatch && typeof fromState === 'boolean') { + lhsMatch = fromState ? lhs === 'true' : lhs === 'false'; + } + if (!rhsMatch && typeof toState === 'boolean') { + rhsMatch = toState ? rhs === 'true' : rhs === 'false'; + } + return lhsMatch && rhsMatch; + }; +} +/** + * @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 SELF_TOKEN = ':self'; +var SELF_TOKEN_REGEX = new RegExp("s*" + SELF_TOKEN + "s*,?", 'g'); +/** + * @param {?} metadata + * @param {?} errors + * @return {?} + */ +function buildAnimationAst(metadata, errors) { + return new AnimationAstBuilderVisitor().build(metadata, errors); +} +var LEAVE_TOKEN = ':leave'; +var LEAVE_TOKEN_REGEX = new RegExp(LEAVE_TOKEN, 'g'); +var ENTER_TOKEN = ':enter'; +var ENTER_TOKEN_REGEX = new RegExp(ENTER_TOKEN, 'g'); +var ROOT_SELECTOR = ''; +var AnimationAstBuilderVisitor = (function () { + function AnimationAstBuilderVisitor() { + } /** - * @param {?} node + * @param {?} metadata + * @param {?} errors * @return {?} */ - Parse5DomAdapter.prototype.nodeValue = function (node) { return node.nodeValue; }; + AnimationAstBuilderVisitor.prototype.build = function (metadata, errors) { + var /** @type {?} */ context = new AnimationAstBuilderContext(errors); + this._resetContextStyleTimingState(context); + return (visitAnimationNode(this, normalizeAnimationEntry(metadata), context)); + }; /** - * @param {?} node + * @param {?} context * @return {?} */ - Parse5DomAdapter.prototype.type = function (node) { throw _notImplemented('type'); }; + AnimationAstBuilderVisitor.prototype._resetContextStyleTimingState = function (context) { + context.currentQuerySelector = ROOT_SELECTOR; + context.collectedStyles = {}; + context.collectedStyles[ROOT_SELECTOR] = {}; + context.currentTime = 0; + }; /** - * @param {?} node + * @param {?} metadata + * @param {?} context * @return {?} */ - Parse5DomAdapter.prototype.content = function (node) { return node.childNodes[0]; }; + AnimationAstBuilderVisitor.prototype.visitTrigger = function (metadata, context) { + var _this = this; + var /** @type {?} */ queryCount = context.queryCount = 0; + var /** @type {?} */ depCount = context.depCount = 0; + var /** @type {?} */ states = []; + var /** @type {?} */ transitions = []; + metadata.definitions.forEach(function (def) { + _this._resetContextStyleTimingState(context); + if (def.type == 0 /* State */) { + var /** @type {?} */ stateDef_1 = (def); + var /** @type {?} */ name = stateDef_1.name; + name.split(/\s*,\s*/).forEach(function (n) { + stateDef_1.name = n; + states.push(_this.visitState(stateDef_1, context)); + }); + stateDef_1.name = name; + } + else if (def.type == 1 /* Transition */) { + var /** @type {?} */ transition = _this.visitTransition(/** @type {?} */ (def), context); + queryCount += transition.queryCount; + depCount += transition.depCount; + transitions.push(transition); + } + else { + context.errors.push('only state() and transition() definitions can sit inside of a trigger()'); + } + }); + var /** @type {?} */ ast = new TriggerAst(metadata.name, states, transitions); + ast.options = normalizeAnimationOptions(metadata.options); + ast.queryCount = queryCount; + ast.depCount = depCount; + return ast; + }; /** - * @param {?} el + * @param {?} metadata + * @param {?} context * @return {?} */ - Parse5DomAdapter.prototype.firstChild = function (el) { return el.firstChild; }; + AnimationAstBuilderVisitor.prototype.visitState = function (metadata, context) { + return new StateAst(metadata.name, this.visitStyle(metadata.styles, context)); + }; /** - * @param {?} el + * @param {?} metadata + * @param {?} context * @return {?} */ - Parse5DomAdapter.prototype.nextSibling = function (el) { return el.nextSibling; }; + AnimationAstBuilderVisitor.prototype.visitTransition = function (metadata, context) { + context.queryCount = 0; + context.depCount = 0; + var /** @type {?} */ entry = visitAnimationNode(this, normalizeAnimationEntry(metadata.animation), context); + var /** @type {?} */ matchers = parseTransitionExpr(metadata.expr, context.errors); + var /** @type {?} */ ast = new TransitionAst(matchers, entry); + ast.options = normalizeAnimationOptions(metadata.options); + ast.queryCount = context.queryCount; + ast.depCount = context.depCount; + return ast; + }; /** - * @param {?} el + * @param {?} metadata + * @param {?} context * @return {?} */ - Parse5DomAdapter.prototype.parentElement = function (el) { return el.parent; }; + AnimationAstBuilderVisitor.prototype.visitSequence = function (metadata, context) { + var _this = this; + var /** @type {?} */ ast = new SequenceAst(metadata.steps.map(function (s) { return visitAnimationNode(_this, s, context); })); + ast.options = normalizeAnimationOptions(metadata.options); + return ast; + }; /** - * @param {?} el + * @param {?} metadata + * @param {?} context * @return {?} */ - Parse5DomAdapter.prototype.childNodes = function (el) { return el.childNodes; }; + AnimationAstBuilderVisitor.prototype.visitGroup = function (metadata, context) { + var _this = this; + var /** @type {?} */ currentTime = context.currentTime; + var /** @type {?} */ furthestTime = 0; + var /** @type {?} */ steps = metadata.steps.map(function (step) { + context.currentTime = currentTime; + var /** @type {?} */ innerAst = visitAnimationNode(_this, step, context); + furthestTime = Math.max(furthestTime, context.currentTime); + return innerAst; + }); + context.currentTime = furthestTime; + var /** @type {?} */ ast = new GroupAst(steps); + ast.options = normalizeAnimationOptions(metadata.options); + return ast; + }; /** - * @param {?} el + * @param {?} metadata + * @param {?} context * @return {?} */ - Parse5DomAdapter.prototype.childNodesAsList = function (el) { - var /** @type {?} */ childNodes = el.childNodes; - var /** @type {?} */ res = new Array(childNodes.length); - for (var /** @type {?} */ i = 0; i < childNodes.length; i++) { - res[i] = childNodes[i]; + AnimationAstBuilderVisitor.prototype.visitAnimate = function (metadata, context) { + var /** @type {?} */ timingAst = constructTimingAst(metadata.timings, context.errors); + context.currentAnimateTimings = timingAst; + var /** @type {?} */ styles; + var /** @type {?} */ styleMetadata = metadata.styles ? metadata.styles : _angular_animations.style({}); + if (styleMetadata.type == 5 /* Keyframes */) { + styles = this.visitKeyframes(/** @type {?} */ (styleMetadata), context); } - return res; + else { + var /** @type {?} */ styleMetadata_1 = (metadata.styles); + var /** @type {?} */ isEmpty = false; + if (!styleMetadata_1) { + isEmpty = true; + var /** @type {?} */ newStyleData = {}; + if (timingAst.easing) { + newStyleData['easing'] = timingAst.easing; + } + styleMetadata_1 = _angular_animations.style(newStyleData); + } + context.currentTime += timingAst.duration + timingAst.delay; + var /** @type {?} */ styleAst = this.visitStyle(styleMetadata_1, context); + styleAst.isEmptyStep = isEmpty; + styles = styleAst; + } + context.currentAnimateTimings = null; + return new AnimateAst(timingAst, styles); }; /** - * @param {?} el + * @param {?} metadata + * @param {?} context * @return {?} */ - Parse5DomAdapter.prototype.clearNodes = function (el) { - while (el.childNodes.length > 0) { - this.remove(el.childNodes[0]); - } + AnimationAstBuilderVisitor.prototype.visitStyle = function (metadata, context) { + var /** @type {?} */ ast = this._makeStyleAst(metadata, context); + this._validateStyleAst(ast, context); + return ast; }; /** - * @param {?} el - * @param {?} node + * @param {?} metadata + * @param {?} context * @return {?} */ - Parse5DomAdapter.prototype.appendChild = function (el, node) { - this.remove(node); - treeAdapter.appendChild(this.templateAwareRoot(el), node); + AnimationAstBuilderVisitor.prototype._makeStyleAst = function (metadata, context) { + var /** @type {?} */ styles = []; + if (Array.isArray(metadata.styles)) { + ((metadata.styles)).forEach(function (styleTuple) { + if (typeof styleTuple == 'string') { + if (styleTuple == _angular_animations.AUTO_STYLE) { + styles.push(/** @type {?} */ (styleTuple)); + } + else { + context.errors.push("The provided style string value " + styleTuple + " is not allowed."); + } + } + else { + styles.push(/** @type {?} */ (styleTuple)); + } + }); + } + else { + styles.push(metadata.styles); + } + var /** @type {?} */ collectedEasing = null; + styles.forEach(function (styleData) { + if (isObject(styleData)) { + var /** @type {?} */ styleMap = (styleData); + var /** @type {?} */ easing = styleMap['easing']; + if (easing) { + collectedEasing = (easing); + delete styleMap['easing']; + } + } + }); + return new StyleAst(styles, collectedEasing, metadata.offset); }; /** - * @param {?} el - * @param {?} node + * @param {?} ast + * @param {?} context * @return {?} */ - Parse5DomAdapter.prototype.removeChild = function (el, node) { - if (el.childNodes.indexOf(node) > -1) { - this.remove(node); + AnimationAstBuilderVisitor.prototype._validateStyleAst = function (ast, context) { + var /** @type {?} */ timings = context.currentAnimateTimings; + var /** @type {?} */ endTime = context.currentTime; + var /** @type {?} */ startTime = context.currentTime; + if (timings && startTime > 0) { + startTime -= timings.duration + timings.delay; } + ast.styles.forEach(function (tuple) { + if (typeof tuple == 'string') + return; + Object.keys(tuple).forEach(function (prop) { + var /** @type {?} */ collectedStyles = context.collectedStyles[((context.currentQuerySelector))]; + var /** @type {?} */ collectedEntry = collectedStyles[prop]; + var /** @type {?} */ updateCollectedStyle = true; + if (collectedEntry) { + if (startTime != endTime && startTime >= collectedEntry.startTime && + endTime <= collectedEntry.endTime) { + context.errors.push("The CSS property \"" + prop + "\" that exists between the times of \"" + collectedEntry.startTime + "ms\" and \"" + collectedEntry.endTime + "ms\" is also being animated in a parallel animation between the times of \"" + startTime + "ms\" and \"" + endTime + "ms\""); + updateCollectedStyle = false; + } + // we always choose the smaller start time value since we + // want to have a record of the entire animation window where + // the style property is being animated in between + startTime = collectedEntry.startTime; + } + if (updateCollectedStyle) { + collectedStyles[prop] = { startTime: startTime, endTime: endTime }; + } + if (context.options) { + validateStyleParams(tuple[prop], context.options, context.errors); + } + }); + }); }; /** - * @param {?} el + * @param {?} metadata + * @param {?} context * @return {?} */ - Parse5DomAdapter.prototype.remove = function (el) { - var /** @type {?} */ parent = el.parent; - if (parent) { - var /** @type {?} */ index = parent.childNodes.indexOf(el); - parent.childNodes.splice(index, 1); + AnimationAstBuilderVisitor.prototype.visitKeyframes = function (metadata, context) { + var _this = this; + if (!context.currentAnimateTimings) { + context.errors.push("keyframes() must be placed inside of a call to animate()"); + return new KeyframesAst([]); } - var /** @type {?} */ prev = el.previousSibling; - var /** @type {?} */ next = el.nextSibling; - if (prev) { - prev.next = next; + var /** @type {?} */ MAX_KEYFRAME_OFFSET = 1; + var /** @type {?} */ totalKeyframesWithOffsets = 0; + var /** @type {?} */ offsets = []; + var /** @type {?} */ offsetsOutOfOrder = false; + var /** @type {?} */ keyframesOutOfRange = false; + var /** @type {?} */ previousOffset = 0; + var /** @type {?} */ keyframes = metadata.steps.map(function (styles) { + var /** @type {?} */ style$$1 = _this._makeStyleAst(styles, context); + var /** @type {?} */ offsetVal = style$$1.offset != null ? style$$1.offset : consumeOffset(style$$1.styles); + var /** @type {?} */ offset = 0; + if (offsetVal != null) { + totalKeyframesWithOffsets++; + offset = style$$1.offset = offsetVal; + } + keyframesOutOfRange = keyframesOutOfRange || offset < 0 || offset > 1; + offsetsOutOfOrder = offsetsOutOfOrder || offset < previousOffset; + previousOffset = offset; + offsets.push(offset); + return style$$1; + }); + if (keyframesOutOfRange) { + context.errors.push("Please ensure that all keyframe offsets are between 0 and 1"); } - if (next) { - next.prev = prev; + if (offsetsOutOfOrder) { + context.errors.push("Please ensure that all keyframe offsets are in order"); } - el.prev = null; - el.next = null; - el.parent = null; - return el; + var /** @type {?} */ length = metadata.steps.length; + var /** @type {?} */ generatedOffset = 0; + if (totalKeyframesWithOffsets > 0 && totalKeyframesWithOffsets < length) { + context.errors.push("Not all style() steps within the declared keyframes() contain offsets"); + } + else if (totalKeyframesWithOffsets == 0) { + generatedOffset = MAX_KEYFRAME_OFFSET / (length - 1); + } + var /** @type {?} */ limit = length - 1; + var /** @type {?} */ currentTime = context.currentTime; + var /** @type {?} */ currentAnimateTimings = ((context.currentAnimateTimings)); + var /** @type {?} */ animateDuration = currentAnimateTimings.duration; + keyframes.forEach(function (kf, i) { + var /** @type {?} */ offset = generatedOffset > 0 ? (i == limit ? 1 : (generatedOffset * i)) : offsets[i]; + var /** @type {?} */ durationUpToThisFrame = offset * animateDuration; + context.currentTime = currentTime + currentAnimateTimings.delay + durationUpToThisFrame; + currentAnimateTimings.duration = durationUpToThisFrame; + _this._validateStyleAst(kf, context); + kf.offset = offset; + }); + return new KeyframesAst(keyframes); }; /** - * @param {?} parent - * @param {?} ref - * @param {?} newNode + * @param {?} metadata + * @param {?} context * @return {?} */ - Parse5DomAdapter.prototype.insertBefore = function (parent, ref, newNode) { - this.remove(newNode); - if (ref) { - treeAdapter.insertBefore(parent, newNode, ref); - } - else { - this.appendChild(parent, newNode); - } + AnimationAstBuilderVisitor.prototype.visitReference = function (metadata, context) { + var /** @type {?} */ entry = visitAnimationNode(this, normalizeAnimationEntry(metadata.animation), context); + var /** @type {?} */ ast = new ReferenceAst(entry); + ast.options = normalizeAnimationOptions(metadata.options); + return ast; }; /** - * @param {?} parent - * @param {?} ref - * @param {?} nodes + * @param {?} metadata + * @param {?} context * @return {?} */ - Parse5DomAdapter.prototype.insertAllBefore = function (parent, ref, nodes) { - var _this = this; - nodes.forEach(function (n) { return _this.insertBefore(parent, ref, n); }); + AnimationAstBuilderVisitor.prototype.visitAnimateChild = function (metadata, context) { + context.depCount++; + var /** @type {?} */ ast = new AnimateChildAst(); + ast.options = normalizeAnimationOptions(metadata.options); + return ast; }; /** - * @param {?} parent - * @param {?} ref - * @param {?} node + * @param {?} metadata + * @param {?} context * @return {?} */ - Parse5DomAdapter.prototype.insertAfter = function (parent, ref, node) { - if (ref.nextSibling) { - this.insertBefore(parent, ref.nextSibling, node); - } - else { - this.appendChild(parent, node); - } + AnimationAstBuilderVisitor.prototype.visitAnimateRef = function (metadata, context) { + var /** @type {?} */ animation = this.visitReference(metadata.animation, context); + var /** @type {?} */ ast = new AnimateRefAst(animation); + ast.options = normalizeAnimationOptions(metadata.options); + return ast; }; /** - * @param {?} el - * @param {?} value + * @param {?} metadata + * @param {?} context * @return {?} */ - Parse5DomAdapter.prototype.setInnerHTML = function (el, value) { - this.clearNodes(el); - var /** @type {?} */ content = parse5$1.parseFragment(value, { treeAdapter: treeAdapter }); - for (var /** @type {?} */ i = 0; i < content.childNodes.length; i++) { - treeAdapter.appendChild(el, content.childNodes[i]); - } + AnimationAstBuilderVisitor.prototype.visitQuery = function (metadata, context) { + var /** @type {?} */ parentSelector = ((context.currentQuerySelector)); + var /** @type {?} */ options = ((metadata.options || {})); + context.queryCount++; + context.currentQuery = metadata; + var _a = normalizeSelector(metadata.selector), selector = _a[0], includeSelf = _a[1]; + context.currentQuerySelector = + parentSelector.length ? (parentSelector + ' ' + selector) : selector; + getOrSetAsInMap(context.collectedStyles, context.currentQuerySelector, {}); + var /** @type {?} */ entry = visitAnimationNode(this, normalizeAnimationEntry(metadata.animation), context); + context.currentQuery = null; + context.currentQuerySelector = parentSelector; + var /** @type {?} */ ast = new QueryAst(selector, options.limit || 0, !!options.optional, includeSelf, entry); + ast.originalSelector = metadata.selector; + ast.options = normalizeAnimationOptions(metadata.options); + return ast; }; /** - * @param {?} el - * @param {?=} isRecursive + * @param {?} metadata + * @param {?} context * @return {?} */ - Parse5DomAdapter.prototype.getText = function (el, isRecursive) { - if (this.isTextNode(el)) { - return el.data; - } - if (this.isCommentNode(el)) { - // In the DOM, comments within an element return an empty string for textContent - // However, comment node instances return the comment content for textContent getter - return isRecursive ? '' : el.data; - } - if (!el.childNodes || el.childNodes.length == 0) { - return ''; + AnimationAstBuilderVisitor.prototype.visitStagger = function (metadata, context) { + if (!context.currentQuery) { + context.errors.push("stagger() can only be used inside of query()"); } - var /** @type {?} */ textContent = ''; - for (var /** @type {?} */ i = 0; i < el.childNodes.length; i++) { - textContent += this.getText(el.childNodes[i], true); + var /** @type {?} */ timings = metadata.timings === 'full' ? + { duration: 0, delay: 0, easing: 'full' } : + resolveTiming(metadata.timings, context.errors, true); + var /** @type {?} */ animation = visitAnimationNode(this, normalizeAnimationEntry(metadata.animation), context); + return new StaggerAst(timings, animation); + }; + return AnimationAstBuilderVisitor; +}()); +/** + * @param {?} selector + * @return {?} + */ +function normalizeSelector(selector) { + var /** @type {?} */ hasAmpersand = selector.split(/\s*,\s*/).find(function (token) { return token == SELF_TOKEN; }) ? true : false; + if (hasAmpersand) { + selector = selector.replace(SELF_TOKEN_REGEX, ''); + } + selector = selector.replace(ENTER_TOKEN_REGEX, ENTER_SELECTOR) + .replace(LEAVE_TOKEN_REGEX, LEAVE_SELECTOR) + .replace(/@\*/g, NG_TRIGGER_SELECTOR) + .replace(/@\w+/g, function (match) { return NG_TRIGGER_SELECTOR + '-' + match.substr(1); }) + .replace(/:animating/g, NG_ANIMATING_SELECTOR); + return [selector, hasAmpersand]; +} +/** + * @param {?} obj + * @return {?} + */ +function normalizeParams(obj) { + return obj ? copyObj(obj) : null; +} +var AnimationAstBuilderContext = (function () { + /** + * @param {?} errors + */ + function AnimationAstBuilderContext(errors) { + this.errors = errors; + this.queryCount = 0; + this.depCount = 0; + this.currentTransition = null; + this.currentQuery = null; + this.currentQuerySelector = null; + this.currentAnimateTimings = null; + this.currentTime = 0; + this.collectedStyles = {}; + this.options = null; + } + return AnimationAstBuilderContext; +}()); +/** + * @param {?} styles + * @return {?} + */ +function consumeOffset(styles) { + if (typeof styles == 'string') + return null; + var /** @type {?} */ offset = null; + if (Array.isArray(styles)) { + styles.forEach(function (styleTuple) { + if (isObject(styleTuple) && styleTuple.hasOwnProperty('offset')) { + var /** @type {?} */ obj = (styleTuple); + offset = parseFloat(/** @type {?} */ (obj['offset'])); + delete obj['offset']; + } + }); + } + else if (isObject(styles) && styles.hasOwnProperty('offset')) { + var /** @type {?} */ obj = (styles); + offset = parseFloat(/** @type {?} */ (obj['offset'])); + delete obj['offset']; + } + return offset; +} +/** + * @param {?} value + * @return {?} + */ +function isObject(value) { + return !Array.isArray(value) && typeof value == 'object'; +} +/** + * @param {?} value + * @param {?} errors + * @return {?} + */ +function constructTimingAst(value, errors) { + var /** @type {?} */ timings = null; + if (value.hasOwnProperty('duration')) { + timings = (value); + } + else if (typeof value == 'number') { + var /** @type {?} */ duration = resolveTiming(/** @type {?} */ (value), errors).duration; + return new TimingAst(/** @type {?} */ (value), 0, ''); + } + var /** @type {?} */ strValue = (value); + var /** @type {?} */ isDynamic = strValue.split(/\s+/).some(function (v) { return v.charAt(0) == '{' && v.charAt(1) == '{'; }); + if (isDynamic) { + return new DynamicTimingAst(strValue); + } + timings = timings || resolveTiming(strValue, errors); + return new TimingAst(timings.duration, timings.delay, timings.easing); +} +/** + * @param {?} options + * @return {?} + */ +function normalizeAnimationOptions(options) { + if (options) { + options = copyObj(options); + if (options['params']) { + options['params'] = ((normalizeParams(options['params']))); } - return textContent; + } + else { + options = {}; + } + return options; +} +/** + * @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 + */ +/** + * @param {?} element + * @param {?} keyframes + * @param {?} preStyleProps + * @param {?} postStyleProps + * @param {?} duration + * @param {?} delay + * @param {?=} easing + * @param {?=} subTimeline + * @return {?} + */ +function createTimelineInstruction(element, keyframes, preStyleProps, postStyleProps, duration, delay, easing, subTimeline) { + if (easing === void 0) { easing = null; } + if (subTimeline === void 0) { subTimeline = false; } + return { + type: 1 /* TimelineAnimation */, + element: element, + keyframes: keyframes, + preStyleProps: preStyleProps, + postStyleProps: postStyleProps, + duration: duration, + delay: delay, + totalTime: duration + delay, easing: easing, subTimeline: subTimeline }; +} +/** + * @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 ElementInstructionMap = (function () { + function ElementInstructionMap() { + this._map = new Map(); + } /** - * @param {?} el - * @param {?} value + * @param {?} element * @return {?} */ - Parse5DomAdapter.prototype.setText = function (el, value) { - if (this.isTextNode(el) || this.isCommentNode(el)) { - el.data = value; + ElementInstructionMap.prototype.consume = function (element) { + var /** @type {?} */ instructions = this._map.get(element); + if (instructions) { + this._map.delete(element); } else { - this.clearNodes(el); - if (value !== '') - treeAdapter.insertText(el, value); + instructions = []; } + return instructions; }; /** - * @param {?} el - * @return {?} - */ - Parse5DomAdapter.prototype.getValue = function (el) { return el.value; }; - /** - * @param {?} el - * @param {?} value - * @return {?} - */ - Parse5DomAdapter.prototype.setValue = function (el, value) { el.value = value; }; - /** - * @param {?} el + * @param {?} element + * @param {?} instructions * @return {?} */ - Parse5DomAdapter.prototype.getChecked = function (el) { return el.checked; }; + ElementInstructionMap.prototype.append = function (element, instructions) { + var /** @type {?} */ existingInstructions = this._map.get(element); + if (!existingInstructions) { + this._map.set(element, existingInstructions = []); + } + existingInstructions.push.apply(existingInstructions, instructions); + }; /** - * @param {?} el - * @param {?} value + * @param {?} element * @return {?} */ - Parse5DomAdapter.prototype.setChecked = function (el, value) { el.checked = value; }; + ElementInstructionMap.prototype.has = function (element) { return this._map.has(element); }; /** - * @param {?} text * @return {?} */ - Parse5DomAdapter.prototype.createComment = function (text) { return treeAdapter.createCommentNode(text); }; + ElementInstructionMap.prototype.clear = function () { this._map.clear(); }; + return ElementInstructionMap; +}()); +/** + * @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 ONE_FRAME_IN_MILLISECONDS = 1; +/** + * @param {?} driver + * @param {?} rootElement + * @param {?} ast + * @param {?=} startingStyles + * @param {?=} finalStyles + * @param {?=} options + * @param {?=} subInstructions + * @param {?=} errors + * @return {?} + */ +function buildAnimationTimelines(driver, rootElement, ast, startingStyles, finalStyles, options, subInstructions, errors) { + if (startingStyles === void 0) { startingStyles = {}; } + if (finalStyles === void 0) { finalStyles = {}; } + if (errors === void 0) { errors = []; } + return new AnimationTimelineBuilderVisitor().buildKeyframes(driver, rootElement, ast, startingStyles, finalStyles, options, subInstructions, errors); +} +var AnimationTimelineBuilderVisitor = (function () { + function AnimationTimelineBuilderVisitor() { + } /** - * @param {?} html + * @param {?} driver + * @param {?} rootElement + * @param {?} ast + * @param {?} startingStyles + * @param {?} finalStyles + * @param {?} options + * @param {?=} subInstructions + * @param {?=} errors * @return {?} */ - Parse5DomAdapter.prototype.createTemplate = function (html) { - var /** @type {?} */ template = treeAdapter.createElement('template', 'http://www.w3.org/1999/xhtml', []); - var /** @type {?} */ content = parse5$1.parseFragment(html, { treeAdapter: treeAdapter }); - treeAdapter.setTemplateContent(template, content); - return template; + AnimationTimelineBuilderVisitor.prototype.buildKeyframes = function (driver, rootElement, ast, startingStyles, finalStyles, options, subInstructions, errors) { + if (errors === void 0) { errors = []; } + subInstructions = subInstructions || new ElementInstructionMap(); + var /** @type {?} */ context = new AnimationTimelineContext(driver, rootElement, subInstructions, errors, []); + context.options = options; + context.currentTimeline.setStyles([startingStyles], null, context.errors, options); + ast.visit(this, context); + // this checks to see if an actual animation happened + var /** @type {?} */ timelines = context.timelines.filter(function (timeline) { return timeline.containsAnimation(); }); + if (timelines.length && Object.keys(finalStyles).length) { + var /** @type {?} */ tl = timelines[timelines.length - 1]; + if (!tl.allowOnlyTimelineStyles()) { + tl.setStyles([finalStyles], null, context.errors, options); + } + } + return timelines.length ? timelines.map(function (timeline) { return timeline.buildKeyframes(); }) : + [createTimelineInstruction(rootElement, [], [], [], 0, 0, '', false)]; }; /** - * @param {?} tagName + * @param {?} ast + * @param {?} context * @return {?} */ - Parse5DomAdapter.prototype.createElement = function (tagName) { - return treeAdapter.createElement(tagName, 'http://www.w3.org/1999/xhtml', []); + AnimationTimelineBuilderVisitor.prototype.visitTrigger = function (ast, context) { + // these values are not visited in this AST }; /** - * @param {?} ns - * @param {?} tagName + * @param {?} ast + * @param {?} context * @return {?} */ - Parse5DomAdapter.prototype.createElementNS = function (ns, tagName) { - return treeAdapter.createElement(tagName, ns, []); + AnimationTimelineBuilderVisitor.prototype.visitState = function (ast, context) { + // these values are not visited in this AST }; /** - * @param {?} text + * @param {?} ast + * @param {?} context * @return {?} */ - Parse5DomAdapter.prototype.createTextNode = function (text) { - var /** @type {?} */ t = (this.createComment(text)); - t.type = 'text'; - return t; + AnimationTimelineBuilderVisitor.prototype.visitTransition = function (ast, context) { + // these values are not visited in this AST }; /** - * @param {?} attrName - * @param {?} attrValue + * @param {?} ast + * @param {?} context * @return {?} */ - Parse5DomAdapter.prototype.createScriptTag = function (attrName, attrValue) { - return treeAdapter.createElement('script', 'http://www.w3.org/1999/xhtml', [{ name: attrName, value: attrValue }]); + AnimationTimelineBuilderVisitor.prototype.visitAnimateChild = function (ast, context) { + var /** @type {?} */ elementInstructions = context.subInstructions.consume(context.element); + if (elementInstructions) { + var /** @type {?} */ innerContext = context.createSubContext(ast.options); + var /** @type {?} */ startTime = context.currentTimeline.currentTime; + var /** @type {?} */ endTime = this._visitSubInstructions(elementInstructions, innerContext, /** @type {?} */ (innerContext.options)); + if (startTime != endTime) { + // we do this on the upper context because we created a sub context for + // the sub child animations + context.transformIntoNewTimeline(endTime); + } + } + context.previousNode = ast; }; /** - * @param {?} css + * @param {?} ast + * @param {?} context * @return {?} */ - Parse5DomAdapter.prototype.createStyleElement = function (css) { - var /** @type {?} */ style = this.createElement('style'); - this.setText(style, css); - return (style); + AnimationTimelineBuilderVisitor.prototype.visitAnimateRef = function (ast, context) { + var /** @type {?} */ innerContext = context.createSubContext(ast.options); + innerContext.transformIntoNewTimeline(); + this.visitReference(ast.animation, innerContext); + context.transformIntoNewTimeline(innerContext.currentTimeline.currentTime); + context.previousNode = ast; }; /** - * @param {?} el + * @param {?} instructions + * @param {?} context + * @param {?} options * @return {?} */ - Parse5DomAdapter.prototype.createShadowRoot = function (el) { - el.shadowRoot = treeAdapter.createDocumentFragment(); - el.shadowRoot.parent = el; - return el.shadowRoot; + AnimationTimelineBuilderVisitor.prototype._visitSubInstructions = function (instructions, context, options) { + var /** @type {?} */ startTime = context.currentTimeline.currentTime; + var /** @type {?} */ furthestTime = startTime; + // this is a special-case for when a user wants to skip a sub + // animation from being fired entirely. + var /** @type {?} */ duration = options.duration != null ? resolveTimingValue(options.duration) : null; + var /** @type {?} */ delay = options.delay != null ? resolveTimingValue(options.delay) : null; + if (duration !== 0) { + instructions.forEach(function (instruction) { + var /** @type {?} */ instructionTimings = context.appendInstructionToTimeline(instruction, duration, delay); + furthestTime = + Math.max(furthestTime, instructionTimings.duration + instructionTimings.delay); + }); + } + return furthestTime; }; /** - * @param {?} el - * @return {?} - */ - Parse5DomAdapter.prototype.getShadowRoot = function (el) { return el.shadowRoot; }; - /** - * @param {?} el - * @return {?} - */ - Parse5DomAdapter.prototype.getHost = function (el) { return el.host; }; - /** - * @param {?} el + * @param {?} ast + * @param {?} context * @return {?} */ - Parse5DomAdapter.prototype.getDistributedNodes = function (el) { throw _notImplemented('getDistributedNodes'); }; + AnimationTimelineBuilderVisitor.prototype.visitReference = function (ast, context) { + context.updateOptions(ast.options, true); + ast.animation.visit(this, context); + context.previousNode = ast; + }; /** - * @param {?} node + * @param {?} ast + * @param {?} context * @return {?} */ - Parse5DomAdapter.prototype.clone = function (node) { - var /** @type {?} */ _recursive = function (node) { - var /** @type {?} */ nodeClone = Object.create(Object.getPrototypeOf(node)); - for (var /** @type {?} */ prop in node) { - var /** @type {?} */ desc = Object.getOwnPropertyDescriptor(node, prop); - if (desc && 'value' in desc && typeof desc.value !== 'object') { - nodeClone[prop] = node[prop]; + AnimationTimelineBuilderVisitor.prototype.visitSequence = function (ast, context) { + var _this = this; + var /** @type {?} */ subContextCount = context.subContextCount; + var /** @type {?} */ ctx = context; + var /** @type {?} */ options = ast.options; + if (options && (options.params || options.delay)) { + ctx = context.createSubContext(options); + ctx.transformIntoNewTimeline(); + if (options.delay != null) { + if (ctx.previousNode instanceof StyleAst) { + ctx.currentTimeline.snapshotCurrentStyles(); + ctx.previousNode = DEFAULT_NOOP_PREVIOUS_NODE; } + var /** @type {?} */ delay = resolveTimingValue(options.delay); + ctx.delayNextStep(delay); } - nodeClone.parent = null; - nodeClone.prev = null; - nodeClone.next = null; - nodeClone.children = null; - mapProps.forEach(function (mapName) { - if (node[mapName] != null) { - nodeClone[mapName] = {}; - for (var /** @type {?} */ prop in node[mapName]) { - nodeClone[mapName][prop] = node[mapName][prop]; - } - } - }); - var /** @type {?} */ cNodes = node.children; - if (cNodes) { - var /** @type {?} */ cNodesClone = new Array(cNodes.length); - for (var /** @type {?} */ i = 0; i < cNodes.length; i++) { - var /** @type {?} */ childNode = cNodes[i]; - var /** @type {?} */ childNodeClone = _recursive(childNode); - cNodesClone[i] = childNodeClone; - if (i > 0) { - childNodeClone.prev = cNodesClone[i - 1]; - cNodesClone[i - 1].next = childNodeClone; - } - childNodeClone.parent = nodeClone; - } - nodeClone.children = cNodesClone; + } + if (ast.steps.length) { + ast.steps.forEach(function (s) { return s.visit(_this, ctx); }); + // this is here just incase the inner steps only contain or end with a style() call + ctx.currentTimeline.applyStylesToKeyframe(); + // this means that some animation function within the sequence + // ended up creating a sub timeline (which means the current + // timeline cannot overlap with the contents of the sequence) + if (ctx.subContextCount > subContextCount) { + ctx.transformIntoNewTimeline(); } - return nodeClone; - }; - return _recursive(node); + } + context.previousNode = ast; }; /** - * @param {?} element - * @param {?} name + * @param {?} ast + * @param {?} context * @return {?} */ - Parse5DomAdapter.prototype.getElementsByClassName = function (element, name) { - return this.querySelectorAll(element, '.' + name); + AnimationTimelineBuilderVisitor.prototype.visitGroup = function (ast, context) { + var _this = this; + var /** @type {?} */ innerTimelines = []; + var /** @type {?} */ furthestTime = context.currentTimeline.currentTime; + var /** @type {?} */ delay = ast.options && ast.options.delay ? resolveTimingValue(ast.options.delay) : 0; + ast.steps.forEach(function (s) { + var /** @type {?} */ innerContext = context.createSubContext(ast.options); + if (delay) { + innerContext.delayNextStep(delay); + } + s.visit(_this, innerContext); + furthestTime = Math.max(furthestTime, innerContext.currentTimeline.currentTime); + innerTimelines.push(innerContext.currentTimeline); + }); + // this operation is run after the AST loop because otherwise + // if the parent timeline's collected styles were updated then + // it would pass in invalid data into the new-to-be forked items + innerTimelines.forEach(function (timeline) { return context.currentTimeline.mergeTimelineCollectedStyles(timeline); }); + context.transformIntoNewTimeline(furthestTime); + context.previousNode = ast; }; /** - * @param {?} element - * @param {?} name + * @param {?} ast + * @param {?} context * @return {?} */ - Parse5DomAdapter.prototype.getElementsByTagName = function (element, name) { - return this.querySelectorAll(element, name); + AnimationTimelineBuilderVisitor.prototype.visitTiming = function (ast, context) { + if (ast instanceof DynamicTimingAst) { + var /** @type {?} */ strValue = context.params ? + interpolateParams(ast.value, context.params, context.errors) : + ast.value.toString(); + return resolveTiming(strValue, context.errors); + } + else { + return { duration: ast.duration, delay: ast.delay, easing: ast.easing }; + } }; /** - * @param {?} element + * @param {?} ast + * @param {?} context * @return {?} */ - Parse5DomAdapter.prototype.classList = function (element) { - var /** @type {?} */ classAttrValue = null; - var /** @type {?} */ attributes = element.attribs; - if (attributes && attributes['class'] != null) { - classAttrValue = attributes['class']; + AnimationTimelineBuilderVisitor.prototype.visitAnimate = function (ast, context) { + var /** @type {?} */ timings = context.currentAnimateTimings = this.visitTiming(ast.timings, context); + var /** @type {?} */ timeline = context.currentTimeline; + if (timings.delay) { + context.incrementTime(timings.delay); + timeline.snapshotCurrentStyles(); } - return classAttrValue ? classAttrValue.trim().split(/\s+/g) : []; + var /** @type {?} */ style$$1 = ast.style; + if (style$$1 instanceof KeyframesAst) { + this.visitKeyframes(style$$1, context); + } + else { + context.incrementTime(timings.duration); + this.visitStyle(/** @type {?} */ (style$$1), context); + timeline.applyStylesToKeyframe(); + } + context.currentAnimateTimings = null; + context.previousNode = ast; }; /** - * @param {?} element - * @param {?} className + * @param {?} ast + * @param {?} context * @return {?} */ - Parse5DomAdapter.prototype.addClass = function (element, className) { - var /** @type {?} */ classList = this.classList(element); - var /** @type {?} */ index = classList.indexOf(className); - if (index == -1) { - classList.push(className); - element.attribs['class'] = element.className = classList.join(' '); + AnimationTimelineBuilderVisitor.prototype.visitStyle = function (ast, context) { + var /** @type {?} */ timeline = context.currentTimeline; + var /** @type {?} */ timings = ((context.currentAnimateTimings)); + // this is a special case for when a style() call + // directly follows an animate() call (but not inside of an animate() call) + if (!timings && timeline.getCurrentStyleProperties().length) { + timeline.forwardFrame(); + } + var /** @type {?} */ easing = (timings && timings.easing) || ast.easing; + if (ast.isEmptyStep) { + timeline.applyEmptyStep(easing); + } + else { + timeline.setStyles(ast.styles, easing, context.errors, context.options); } + context.previousNode = ast; }; /** - * @param {?} element - * @param {?} className + * @param {?} ast + * @param {?} context * @return {?} */ - Parse5DomAdapter.prototype.removeClass = function (element, className) { - var /** @type {?} */ classList = this.classList(element); - var /** @type {?} */ index = classList.indexOf(className); - if (index > -1) { - classList.splice(index, 1); - element.attribs['class'] = element.className = classList.join(' '); - } + AnimationTimelineBuilderVisitor.prototype.visitKeyframes = function (ast, context) { + var /** @type {?} */ currentAnimateTimings = ((context.currentAnimateTimings)); + var /** @type {?} */ startTime = (((context.currentTimeline))).duration; + var /** @type {?} */ duration = currentAnimateTimings.duration; + var /** @type {?} */ innerContext = context.createSubContext(); + var /** @type {?} */ innerTimeline = innerContext.currentTimeline; + innerTimeline.easing = currentAnimateTimings.easing; + ast.styles.forEach(function (step) { + var /** @type {?} */ offset = step.offset || 0; + innerTimeline.forwardTime(offset * duration); + innerTimeline.setStyles(step.styles, step.easing, context.errors, context.options); + innerTimeline.applyStylesToKeyframe(); + }); + // this will ensure that the parent timeline gets all the styles from + // the child even if the new timeline below is not used + context.currentTimeline.mergeTimelineCollectedStyles(innerTimeline); + // we do this because the window between this timeline and the sub timeline + // should ensure that the styles within are exactly the same as they were before + context.transformIntoNewTimeline(startTime + duration); + context.previousNode = ast; }; /** - * @param {?} element - * @param {?} className + * @param {?} ast + * @param {?} context * @return {?} */ - Parse5DomAdapter.prototype.hasClass = function (element, className) { - return this.classList(element).indexOf(className) > -1; + AnimationTimelineBuilderVisitor.prototype.visitQuery = function (ast, context) { + var _this = this; + // in the event that the first step before this is a style step we need + // to ensure the styles are applied before the children are animated + var /** @type {?} */ startTime = context.currentTimeline.currentTime; + var /** @type {?} */ options = ((ast.options || {})); + var /** @type {?} */ delay = options.delay ? resolveTimingValue(options.delay) : 0; + if (delay && (context.previousNode instanceof StyleAst || + (startTime == 0 && context.currentTimeline.getCurrentStyleProperties().length))) { + context.currentTimeline.snapshotCurrentStyles(); + context.previousNode = DEFAULT_NOOP_PREVIOUS_NODE; + } + var /** @type {?} */ furthestTime = startTime; + var /** @type {?} */ elms = context.invokeQuery(ast.selector, ast.originalSelector, ast.limit, ast.includeSelf, options.optional ? true : false, context.errors); + context.currentQueryTotal = elms.length; + var /** @type {?} */ sameElementTimeline = null; + elms.forEach(function (element, i) { + context.currentQueryIndex = i; + var /** @type {?} */ innerContext = context.createSubContext(ast.options, element); + if (delay) { + innerContext.delayNextStep(delay); + } + if (element === context.element) { + sameElementTimeline = innerContext.currentTimeline; + } + ast.animation.visit(_this, innerContext); + // this is here just incase the inner steps only contain or end + // with a style() call (which is here to signal that this is a preparatory + // call to style an element before it is animated again) + innerContext.currentTimeline.applyStylesToKeyframe(); + var /** @type {?} */ endTime = innerContext.currentTimeline.currentTime; + furthestTime = Math.max(furthestTime, endTime); + }); + context.currentQueryIndex = 0; + context.currentQueryTotal = 0; + context.transformIntoNewTimeline(furthestTime); + if (sameElementTimeline) { + context.currentTimeline.mergeTimelineCollectedStyles(sameElementTimeline); + context.currentTimeline.snapshotCurrentStyles(); + } + context.previousNode = ast; }; /** - * @param {?} element - * @param {?} styleName - * @param {?=} styleValue + * @param {?} ast + * @param {?} context * @return {?} */ - Parse5DomAdapter.prototype.hasStyle = function (element, styleName, styleValue) { - var /** @type {?} */ value = this.getStyle(element, styleName) || ''; - return styleValue ? value == styleValue : value.length > 0; + AnimationTimelineBuilderVisitor.prototype.visitStagger = function (ast, context) { + var /** @type {?} */ parentContext = ((context.parentContext)); + var /** @type {?} */ tl = context.currentTimeline; + var /** @type {?} */ timings = ast.timings; + var /** @type {?} */ duration = Math.abs(timings.duration); + var /** @type {?} */ maxTime = duration * (context.currentQueryTotal - 1); + var /** @type {?} */ delay = duration * context.currentQueryIndex; + var /** @type {?} */ staggerTransformer = timings.duration < 0 ? 'reverse' : timings.easing; + switch (staggerTransformer) { + case 'reverse': + delay = maxTime - delay; + break; + case 'full': + delay = parentContext.currentStaggerTime; + break; + } + var /** @type {?} */ timeline = context.currentTimeline; + if (delay) { + timeline.delayNextStep(delay); + } + var /** @type {?} */ startingTime = timeline.currentTime; + ast.animation.visit(this, context); + context.previousNode = ast; + // time = duration + delay + // the reason why this computation is so complex is because + // the inner timeline may either have a delay value or a stretched + // keyframe depending on if a subtimeline is not used or is used. + parentContext.currentStaggerTime = + (tl.currentTime - startingTime) + (tl.startTime - parentContext.currentTimeline.startTime); }; + return AnimationTimelineBuilderVisitor; +}()); +var DEFAULT_NOOP_PREVIOUS_NODE = ({}); +var AnimationTimelineContext = (function () { /** - * \@internal + * @param {?} _driver * @param {?} element + * @param {?} subInstructions + * @param {?} errors + * @param {?} timelines + * @param {?=} initialTimeline + */ + function AnimationTimelineContext(_driver, element, subInstructions, errors, timelines, initialTimeline) { + this._driver = _driver; + this.element = element; + this.subInstructions = subInstructions; + this.errors = errors; + this.timelines = timelines; + this.parentContext = null; + this.currentAnimateTimings = null; + this.previousNode = DEFAULT_NOOP_PREVIOUS_NODE; + this.subContextCount = 0; + this.options = {}; + this.currentQueryIndex = 0; + this.currentQueryTotal = 0; + this.currentStaggerTime = 0; + this.currentTimeline = initialTimeline || new TimelineBuilder(element, 0); + timelines.push(this.currentTimeline); + } + Object.defineProperty(AnimationTimelineContext.prototype, "params", { + /** + * @return {?} + */ + get: function () { return this.options.params; }, + enumerable: true, + configurable: true + }); + /** + * @param {?} options + * @param {?=} skipIfExists * @return {?} */ - Parse5DomAdapter.prototype._readStyleAttribute = function (element) { - var /** @type {?} */ styleMap = {}; - var /** @type {?} */ attributes = element.attribs; - if (attributes && attributes['style'] != null) { - var /** @type {?} */ styleAttrValue = attributes['style']; - var /** @type {?} */ styleList = styleAttrValue.split(/;+/g); - for (var /** @type {?} */ i = 0; i < styleList.length; i++) { - if (styleList[i].length > 0) { - var /** @type {?} */ style = (styleList[i]); - var /** @type {?} */ colon = style.indexOf(':'); - if (colon === -1) { - throw new Error("Invalid CSS style: " + style); - } - ((styleMap))[style.substr(0, colon).trim()] = style.substr(colon + 1).trim(); - } + AnimationTimelineContext.prototype.updateOptions = function (options, skipIfExists) { + var _this = this; + if (!options) + return; + var /** @type {?} */ newOptions = (options); + var /** @type {?} */ optionsToUpdate = this.options; + // NOTE: this will get patched up when other animation methods support duration overrides + if (newOptions.duration != null) { + ((optionsToUpdate)).duration = resolveTimingValue(newOptions.duration); + } + if (newOptions.delay != null) { + optionsToUpdate.delay = resolveTimingValue(newOptions.delay); + } + var /** @type {?} */ newParams = newOptions.params; + if (newParams) { + var /** @type {?} */ paramsToUpdate_1 = ((optionsToUpdate.params)); + if (!paramsToUpdate_1) { + paramsToUpdate_1 = this.options.params = {}; } + Object.keys(newParams).forEach(function (name) { + if (!skipIfExists || !paramsToUpdate_1.hasOwnProperty(name)) { + paramsToUpdate_1[name] = interpolateParams(newParams[name], paramsToUpdate_1, _this.errors); + } + }); } - return styleMap; }; /** - * \@internal - * @param {?} element - * @param {?} styleMap * @return {?} */ - Parse5DomAdapter.prototype._writeStyleAttribute = function (element, styleMap) { - var /** @type {?} */ styleAttrValue = ''; - for (var /** @type {?} */ key in styleMap) { - var /** @type {?} */ newValue = styleMap[key]; - if (newValue) { - styleAttrValue += key + ':' + styleMap[key] + ';'; + AnimationTimelineContext.prototype._copyOptions = function () { + var /** @type {?} */ options = {}; + if (this.options) { + var /** @type {?} */ oldParams_1 = this.options.params; + if (oldParams_1) { + var /** @type {?} */ params_1 = options['params'] = {}; + Object.keys(this.options.params).forEach(function (name) { params_1[name] = oldParams_1[name]; }); } } - element.attribs['style'] = styleAttrValue; + return options; }; /** - * @param {?} element - * @param {?} styleName - * @param {?=} styleValue + * @param {?=} options + * @param {?=} element + * @param {?=} newTime * @return {?} */ - Parse5DomAdapter.prototype.setStyle = function (element, styleName, styleValue) { - var /** @type {?} */ styleMap = this._readStyleAttribute(element); - ((styleMap))[styleName] = styleValue; - this._writeStyleAttribute(element, styleMap); + AnimationTimelineContext.prototype.createSubContext = function (options, element, newTime) { + if (options === void 0) { options = null; } + var /** @type {?} */ target = element || this.element; + var /** @type {?} */ context = new AnimationTimelineContext(this._driver, target, this.subInstructions, this.errors, this.timelines, this.currentTimeline.fork(target, newTime || 0)); + context.previousNode = this.previousNode; + context.currentAnimateTimings = this.currentAnimateTimings; + context.options = this._copyOptions(); + context.updateOptions(options); + context.currentQueryIndex = this.currentQueryIndex; + context.currentQueryTotal = this.currentQueryTotal; + context.parentContext = this; + this.subContextCount++; + return context; }; /** - * @param {?} element - * @param {?} styleName + * @param {?=} newTime * @return {?} */ - Parse5DomAdapter.prototype.removeStyle = function (element, styleName) { this.setStyle(element, styleName, null); }; + AnimationTimelineContext.prototype.transformIntoNewTimeline = function (newTime) { + this.previousNode = DEFAULT_NOOP_PREVIOUS_NODE; + this.currentTimeline = this.currentTimeline.fork(this.element, newTime); + this.timelines.push(this.currentTimeline); + return this.currentTimeline; + }; /** - * @param {?} element - * @param {?} styleName + * @param {?} instruction + * @param {?} duration + * @param {?} delay * @return {?} */ - Parse5DomAdapter.prototype.getStyle = function (element, styleName) { - var /** @type {?} */ styleMap = this._readStyleAttribute(element); - return styleMap.hasOwnProperty(styleName) ? ((styleMap))[styleName] : ''; + AnimationTimelineContext.prototype.appendInstructionToTimeline = function (instruction, duration, delay) { + var /** @type {?} */ updatedTimings = { + duration: duration != null ? duration : instruction.duration, + delay: this.currentTimeline.currentTime + (delay != null ? delay : 0) + instruction.delay, + easing: '' + }; + var /** @type {?} */ builder = new SubTimelineBuilder(instruction.element, instruction.keyframes, instruction.preStyleProps, instruction.postStyleProps, updatedTimings, instruction.stretchStartingKeyframe); + this.timelines.push(builder); + return updatedTimings; }; /** - * @param {?} element + * @param {?} time * @return {?} */ - Parse5DomAdapter.prototype.tagName = function (element) { return element.tagName == 'style' ? 'STYLE' : element.tagName; }; + AnimationTimelineContext.prototype.incrementTime = function (time) { + this.currentTimeline.forwardTime(this.currentTimeline.duration + time); + }; /** - * @param {?} element + * @param {?} delay * @return {?} */ - Parse5DomAdapter.prototype.attributeMap = function (element) { - var /** @type {?} */ res = new Map(); - var /** @type {?} */ elAttrs = treeAdapter.getAttrList(element); - for (var /** @type {?} */ i = 0; i < elAttrs.length; i++) { - var /** @type {?} */ attrib = elAttrs[i]; - res.set(attrib.name, attrib.value); + AnimationTimelineContext.prototype.delayNextStep = function (delay) { + // negative delays are not yet supported + if (delay > 0) { + this.currentTimeline.delayNextStep(delay); } - return res; }; /** - * @param {?} element - * @param {?} attribute + * @param {?} selector + * @param {?} originalSelector + * @param {?} limit + * @param {?} includeSelf + * @param {?} optional + * @param {?} errors * @return {?} */ - Parse5DomAdapter.prototype.hasAttribute = function (element, attribute) { - return element.attribs && element.attribs[attribute] != null; + AnimationTimelineContext.prototype.invokeQuery = function (selector, originalSelector, limit, includeSelf, optional, errors) { + var /** @type {?} */ results = []; + if (includeSelf) { + results.push(this.element); + } + if (selector.length > 0) { + var /** @type {?} */ multi = limit != 1; + results.push.apply(results, this._driver.query(this.element, selector, multi)); + } + if (!optional && results.length == 0) { + errors.push("`query(\"" + originalSelector + "\")` returned zero elements. (Use `query(\"" + originalSelector + "\", { optional: true })` if you wish to allow this.)"); + } + return results; }; + return AnimationTimelineContext; +}()); +var TimelineBuilder = (function () { /** * @param {?} element - * @param {?} ns - * @param {?} attribute - * @return {?} + * @param {?} startTime + * @param {?=} _elementTimelineStylesLookup */ - Parse5DomAdapter.prototype.hasAttributeNS = function (element, ns, attribute) { - return this.hasAttribute(element, attribute); - }; + function TimelineBuilder(element, startTime, _elementTimelineStylesLookup) { + this.element = element; + this.startTime = startTime; + this._elementTimelineStylesLookup = _elementTimelineStylesLookup; + this.duration = 0; + this._previousKeyframe = {}; + this._currentKeyframe = {}; + this._keyframes = new Map(); + this._styleSummary = {}; + this._pendingStyles = {}; + this._backFill = {}; + this._currentEmptyStepKeyframe = null; + if (!this._elementTimelineStylesLookup) { + this._elementTimelineStylesLookup = new Map(); + } + this._localTimelineStyles = Object.create(this._backFill, {}); + this._globalTimelineStyles = this._elementTimelineStylesLookup.get(element); + if (!this._globalTimelineStyles) { + this._globalTimelineStyles = this._localTimelineStyles; + this._elementTimelineStylesLookup.set(element, this._localTimelineStyles); + } + this._loadKeyframe(); + } /** - * @param {?} element - * @param {?} attribute * @return {?} */ - Parse5DomAdapter.prototype.getAttribute = function (element, attribute) { - return this.hasAttribute(element, attribute) ? element.attribs[attribute] : null; + TimelineBuilder.prototype.containsAnimation = function () { + switch (this._keyframes.size) { + case 0: + return false; + case 1: + return this.getCurrentStyleProperties().length > 0; + default: + return true; + } }; /** - * @param {?} element - * @param {?} ns - * @param {?} attribute * @return {?} */ - Parse5DomAdapter.prototype.getAttributeNS = function (element, ns, attribute) { - return this.getAttribute(element, attribute); - }; + TimelineBuilder.prototype.getCurrentStyleProperties = function () { return Object.keys(this._currentKeyframe); }; + Object.defineProperty(TimelineBuilder.prototype, "currentTime", { + /** + * @return {?} + */ + get: function () { return this.startTime + this.duration; }, + enumerable: true, + configurable: true + }); /** - * @param {?} element - * @param {?} attribute - * @param {?} value + * @param {?} delay * @return {?} */ - Parse5DomAdapter.prototype.setAttribute = function (element, attribute, value) { - if (attribute) { - element.attribs[attribute] = value; - if (attribute === 'class') { - element.className = value; + TimelineBuilder.prototype.delayNextStep = function (delay) { + // in the event that a style() step is placed right before a stagger() + // and that style() step is the very first style() value in the animation + // then we need to make a copy of the keyframe [0, copy, 1] so that the delay + // properly applies the style() values to work with the stagger... + var /** @type {?} */ hasPreStyleStep = this._keyframes.size == 1 && Object.keys(this._pendingStyles).length; + if (this.duration || hasPreStyleStep) { + this.forwardTime(this.currentTime + delay); + if (hasPreStyleStep) { + this.snapshotCurrentStyles(); } } + else { + this.startTime += delay; + } }; /** * @param {?} element - * @param {?} ns - * @param {?} attribute - * @param {?} value + * @param {?=} currentTime * @return {?} */ - Parse5DomAdapter.prototype.setAttributeNS = function (element, ns, attribute, value) { - this.setAttribute(element, attribute, value); + TimelineBuilder.prototype.fork = function (element, currentTime) { + this.applyStylesToKeyframe(); + return new TimelineBuilder(element, currentTime || this.currentTime, this._elementTimelineStylesLookup); }; /** - * @param {?} element - * @param {?} attribute * @return {?} */ - Parse5DomAdapter.prototype.removeAttribute = function (element, attribute) { - if (attribute) { - delete element.attribs[attribute]; + TimelineBuilder.prototype._loadKeyframe = function () { + if (this._currentKeyframe) { + this._previousKeyframe = this._currentKeyframe; + } + this._currentKeyframe = ((this._keyframes.get(this.duration))); + if (!this._currentKeyframe) { + this._currentKeyframe = Object.create(this._backFill, {}); + this._keyframes.set(this.duration, this._currentKeyframe); } }; /** - * @param {?} element - * @param {?} ns - * @param {?} name - * @return {?} - */ - Parse5DomAdapter.prototype.removeAttributeNS = function (element, ns, name) { throw 'not implemented'; }; - /** - * @param {?} el * @return {?} */ - Parse5DomAdapter.prototype.templateAwareRoot = function (el) { - return this.isTemplateElement(el) ? treeAdapter.getTemplateContent(el) : el; + TimelineBuilder.prototype.forwardFrame = function () { + this.duration += ONE_FRAME_IN_MILLISECONDS; + this._loadKeyframe(); }; /** + * @param {?} time * @return {?} */ - Parse5DomAdapter.prototype.createHtmlDocument = function () { - var /** @type {?} */ newDoc = treeAdapter.createDocument(); - newDoc.title = 'fakeTitle'; - var /** @type {?} */ head = treeAdapter.createElement('head', null, []); - var /** @type {?} */ body = treeAdapter.createElement('body', 'http://www.w3.org/1999/xhtml', []); - this.appendChild(newDoc, head); - this.appendChild(newDoc, body); - newDoc['head'] = head; - newDoc['body'] = body; - newDoc['_window'] = {}; - return newDoc; + TimelineBuilder.prototype.forwardTime = function (time) { + this.applyStylesToKeyframe(); + this.duration = time; + this._loadKeyframe(); }; /** - * @param {?} el - * @return {?} - */ - Parse5DomAdapter.prototype.getBoundingClientRect = function (el) { return { left: 0, top: 0, width: 0, height: 0 }; }; - /** - * @param {?} doc + * @param {?} prop + * @param {?} value * @return {?} */ - Parse5DomAdapter.prototype.getTitle = function (doc) { return this.getText(this.getTitleNode(doc)) || ''; }; + TimelineBuilder.prototype._updateStyle = function (prop, value) { + this._localTimelineStyles[prop] = value; + this._globalTimelineStyles[prop] = value; + this._styleSummary[prop] = { time: this.currentTime, value: value }; + }; /** - * @param {?} doc - * @param {?} newTitle * @return {?} */ - Parse5DomAdapter.prototype.setTitle = function (doc, newTitle) { - this.setText(this.getTitleNode(doc), newTitle || ''); - }; + TimelineBuilder.prototype.allowOnlyTimelineStyles = function () { return this._currentEmptyStepKeyframe !== this._currentKeyframe; }; /** - * @param {?} el + * @param {?} easing * @return {?} */ - Parse5DomAdapter.prototype.isTemplateElement = function (el) { - return this.isElementNode(el) && this.tagName(el) === 'template'; + TimelineBuilder.prototype.applyEmptyStep = function (easing) { + var _this = this; + if (easing) { + this._previousKeyframe['easing'] = easing; + } + // special case for animate(duration): + // all missing styles are filled with a `*` value then + // if any destination styles are filled in later on the same + // keyframe then they will override the overridden styles + // We use `_globalTimelineStyles` here because there may be + // styles in previous keyframes that are not present in this timeline + Object.keys(this._globalTimelineStyles).forEach(function (prop) { + _this._backFill[prop] = _this._globalTimelineStyles[prop] || _angular_animations.AUTO_STYLE; + _this._currentKeyframe[prop] = _angular_animations.AUTO_STYLE; + }); + this._currentEmptyStepKeyframe = this._currentKeyframe; }; /** - * @param {?} node - * @return {?} - */ - Parse5DomAdapter.prototype.isTextNode = function (node) { return treeAdapter.isTextNode(node); }; - /** - * @param {?} node - * @return {?} - */ - Parse5DomAdapter.prototype.isCommentNode = function (node) { return treeAdapter.isCommentNode(node); }; - /** - * @param {?} node - * @return {?} - */ - Parse5DomAdapter.prototype.isElementNode = function (node) { return node ? treeAdapter.isElementNode(node) : false; }; - /** - * @param {?} node - * @return {?} - */ - Parse5DomAdapter.prototype.hasShadowRoot = function (node) { return node.shadowRoot != null; }; - /** - * @param {?} node + * @param {?} input + * @param {?} easing + * @param {?} errors + * @param {?=} options * @return {?} */ - Parse5DomAdapter.prototype.isShadowRoot = function (node) { return this.getShadowRoot(node) == node; }; + TimelineBuilder.prototype.setStyles = function (input, easing, errors, options) { + var _this = this; + if (easing) { + this._previousKeyframe['easing'] = easing; + } + var /** @type {?} */ params = (options && options.params) || {}; + var /** @type {?} */ styles = flattenStyles(input, this._globalTimelineStyles); + Object.keys(styles).forEach(function (prop) { + var /** @type {?} */ val = interpolateParams(styles[prop], params, errors); + _this._pendingStyles[prop] = val; + if (!_this._localTimelineStyles.hasOwnProperty(prop)) { + _this._backFill[prop] = _this._globalTimelineStyles.hasOwnProperty(prop) ? + _this._globalTimelineStyles[prop] : + _angular_animations.AUTO_STYLE; + } + _this._updateStyle(prop, val); + }); + }; /** - * @param {?} node * @return {?} */ - Parse5DomAdapter.prototype.importIntoDoc = function (node) { return this.clone(node); }; + TimelineBuilder.prototype.applyStylesToKeyframe = function () { + var _this = this; + var /** @type {?} */ styles = this._pendingStyles; + var /** @type {?} */ props = Object.keys(styles); + if (props.length == 0) + return; + this._pendingStyles = {}; + props.forEach(function (prop) { + var /** @type {?} */ val = styles[prop]; + _this._currentKeyframe[prop] = val; + }); + Object.keys(this._localTimelineStyles).forEach(function (prop) { + if (!_this._currentKeyframe.hasOwnProperty(prop)) { + _this._currentKeyframe[prop] = _this._localTimelineStyles[prop]; + } + }); + }; /** - * @param {?} node * @return {?} */ - Parse5DomAdapter.prototype.adoptNode = function (node) { return node; }; + TimelineBuilder.prototype.snapshotCurrentStyles = function () { + var _this = this; + Object.keys(this._localTimelineStyles).forEach(function (prop) { + var /** @type {?} */ val = _this._localTimelineStyles[prop]; + _this._pendingStyles[prop] = val; + _this._updateStyle(prop, val); + }); + }; /** - * @param {?} el * @return {?} */ - Parse5DomAdapter.prototype.getHref = function (el) { return this.getAttribute(el, 'href'); }; + TimelineBuilder.prototype.getFinalKeyframe = function () { return this._keyframes.get(this.duration); }; + Object.defineProperty(TimelineBuilder.prototype, "properties", { + /** + * @return {?} + */ + get: function () { + var /** @type {?} */ properties = []; + for (var /** @type {?} */ prop in this._currentKeyframe) { + properties.push(prop); + } + return properties; + }, + enumerable: true, + configurable: true + }); /** - * @param {?} el - * @param {?} baseUrl - * @param {?} href + * @param {?} timeline * @return {?} */ - Parse5DomAdapter.prototype.resolveAndSetHref = function (el, baseUrl, href) { - if (href == null) { - el.href = baseUrl; - } - else { - el.href = baseUrl + '/../' + href; - } + TimelineBuilder.prototype.mergeTimelineCollectedStyles = function (timeline) { + var _this = this; + Object.keys(timeline._styleSummary).forEach(function (prop) { + var /** @type {?} */ details0 = _this._styleSummary[prop]; + var /** @type {?} */ details1 = timeline._styleSummary[prop]; + if (!details0 || details1.time > details0.time) { + _this._updateStyle(prop, details1.value); + } + }); }; /** - * \@internal - * @param {?} parsedRules - * @param {?=} css * @return {?} */ - Parse5DomAdapter.prototype._buildRules = function (parsedRules, css) { - var /** @type {?} */ rules = []; - for (var /** @type {?} */ i = 0; i < parsedRules.length; i++) { - var /** @type {?} */ parsedRule = parsedRules[i]; - var /** @type {?} */ rule = {}; - rule['cssText'] = css; - rule['style'] = { content: '', cssText: '' }; - if (parsedRule.type == 'rule') { - rule['type'] = 1; - rule['selectorText'] = - parsedRule.selectors.join(', '.replace(/\s{2,}/g, ' ') - .replace(/\s*~\s*/g, ' ~ ') - .replace(/\s*\+\s*/g, ' + ') - .replace(/\s*>\s*/g, ' > ') - .replace(/\[(\w+)=(\w+)\]/g, '[$1="$2"]')); - if (parsedRule.declarations == null) { - continue; - } - for (var /** @type {?} */ j = 0; j < parsedRule.declarations.length; j++) { - var /** @type {?} */ declaration = parsedRule.declarations[j]; - rule['style'] = declaration.property[declaration.value]; - rule['style'].cssText += declaration.property + ': ' + declaration.value + ';'; + TimelineBuilder.prototype.buildKeyframes = function () { + var _this = this; + this.applyStylesToKeyframe(); + var /** @type {?} */ preStyleProps = new Set(); + var /** @type {?} */ postStyleProps = new Set(); + var /** @type {?} */ isEmpty = this._keyframes.size === 1 && this.duration === 0; + var /** @type {?} */ finalKeyframes = []; + this._keyframes.forEach(function (keyframe, time) { + var /** @type {?} */ finalKeyframe = copyStyles(keyframe, true); + Object.keys(finalKeyframe).forEach(function (prop) { + var /** @type {?} */ value = finalKeyframe[prop]; + if (value == _angular_animations.ɵPRE_STYLE) { + preStyleProps.add(prop); } - } - else if (parsedRule.type == 'media') { - rule['type'] = 4; - rule['media'] = { mediaText: parsedRule.media }; - if (parsedRule.rules) { - rule['cssRules'] = this._buildRules(parsedRule.rules); + else if (value == _angular_animations.AUTO_STYLE) { + postStyleProps.add(prop); } + }); + if (!isEmpty) { + finalKeyframe['offset'] = time / _this.duration; } - rules.push(rule); + finalKeyframes.push(finalKeyframe); + }); + var /** @type {?} */ preProps = preStyleProps.size ? iteratorToArray(preStyleProps.values()) : []; + var /** @type {?} */ postProps = postStyleProps.size ? iteratorToArray(postStyleProps.values()) : []; + // special case for a 0-second animation (which is designed just to place styles onscreen) + if (isEmpty) { + var /** @type {?} */ kf0 = finalKeyframes[0]; + var /** @type {?} */ kf1 = copyObj(kf0); + kf0['offset'] = 0; + kf1['offset'] = 1; + finalKeyframes = [kf0, kf1]; } - return rules; + return createTimelineInstruction(this.element, finalKeyframes, preProps, postProps, this.duration, this.startTime, this.easing, false); }; + return TimelineBuilder; +}()); +var SubTimelineBuilder = (function (_super) { + __extends(SubTimelineBuilder, _super); /** - * @return {?} + * @param {?} element + * @param {?} keyframes + * @param {?} preStyleProps + * @param {?} postStyleProps + * @param {?} timings + * @param {?=} _stretchStartingKeyframe */ - Parse5DomAdapter.prototype.supportsDOMEvents = function () { return false; }; + function SubTimelineBuilder(element, keyframes, preStyleProps, postStyleProps, timings, _stretchStartingKeyframe) { + if (_stretchStartingKeyframe === void 0) { _stretchStartingKeyframe = false; } + var _this = _super.call(this, element, timings.delay) || this; + _this.element = element; + _this.keyframes = keyframes; + _this.preStyleProps = preStyleProps; + _this.postStyleProps = postStyleProps; + _this._stretchStartingKeyframe = _stretchStartingKeyframe; + _this.timings = { duration: timings.duration, delay: timings.delay, easing: timings.easing }; + return _this; + } /** * @return {?} */ - Parse5DomAdapter.prototype.supportsNativeShadowDOM = function () { return false; }; + SubTimelineBuilder.prototype.containsAnimation = function () { return this.keyframes.length > 1; }; /** - * @param {?} doc - * @param {?} target * @return {?} */ - Parse5DomAdapter.prototype.getGlobalEventTarget = function (doc, target) { - if (target == 'window') { - return ((doc))._window; + SubTimelineBuilder.prototype.buildKeyframes = function () { + var /** @type {?} */ keyframes = this.keyframes; + var _a = this.timings, delay = _a.delay, duration = _a.duration, easing = _a.easing; + if (this._stretchStartingKeyframe && delay) { + var /** @type {?} */ newKeyframes = []; + var /** @type {?} */ totalTime = duration + delay; + var /** @type {?} */ startingGap = delay / totalTime; + // the original starting keyframe now starts once the delay is done + var /** @type {?} */ newFirstKeyframe = copyStyles(keyframes[0], false); + newFirstKeyframe['offset'] = 0; + newKeyframes.push(newFirstKeyframe); + var /** @type {?} */ oldFirstKeyframe = copyStyles(keyframes[0], false); + oldFirstKeyframe['offset'] = roundOffset(startingGap); + newKeyframes.push(oldFirstKeyframe); + /* + When the keyframe is stretched then it means that the delay before the animation + starts is gone. Instead the first keyframe is placed at the start of the animation + and it is then copied to where it starts when the original delay is over. This basically + means nothing animates during that delay, but the styles are still renderered. For this + to work the original offset values that exist in the original keyframes must be "warped" + so that they can take the new keyframe + delay into account. + + delay=1000, duration=1000, keyframes = 0 .5 1 + + turns into + + delay=0, duration=2000, keyframes = 0 .33 .66 1 + */ + // offsets between 1 ... n -1 are all warped by the keyframe stretch + var /** @type {?} */ limit = keyframes.length - 1; + for (var /** @type {?} */ i = 1; i <= limit; i++) { + var /** @type {?} */ kf = copyStyles(keyframes[i], false); + var /** @type {?} */ oldOffset = (kf['offset']); + var /** @type {?} */ timeAtKeyframe = delay + oldOffset * duration; + kf['offset'] = roundOffset(timeAtKeyframe / totalTime); + newKeyframes.push(kf); + } + // the new starting keyframe should be added at the start + duration = totalTime; + delay = 0; + easing = ''; + keyframes = newKeyframes; } - else if (target == 'document') { - return doc; + return createTimelineInstruction(this.element, keyframes, this.preStyleProps, this.postStyleProps, duration, delay, easing, true); + }; + return SubTimelineBuilder; +}(TimelineBuilder)); +/** + * @param {?} offset + * @param {?=} decimalPoints + * @return {?} + */ +function roundOffset(offset, decimalPoints) { + if (decimalPoints === void 0) { decimalPoints = 3; } + var /** @type {?} */ mult = Math.pow(10, decimalPoints - 1); + return Math.round(offset * mult) / mult; +} +/** + * @param {?} input + * @param {?} allStyles + * @return {?} + */ +function flattenStyles(input, allStyles) { + var /** @type {?} */ styles = {}; + var /** @type {?} */ allProperties; + input.forEach(function (token) { + if (token === '*') { + allProperties = allProperties || Object.keys(allStyles); + allProperties.forEach(function (prop) { styles[prop] = _angular_animations.AUTO_STYLE; }); } - else if (target == 'body') { - return doc.body; + else { + copyStyles(/** @type {?} */ (token), false, styles); } - }; + }); + return styles; +} +/** + * @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 Animation = (function () { /** - * @param {?} doc - * @return {?} + * @param {?} _driver + * @param {?} input */ - Parse5DomAdapter.prototype.getBaseHref = function (doc) { - var /** @type {?} */ base = this.querySelector(doc, 'base'); - var /** @type {?} */ href = ''; - if (base) { - href = this.getHref(base); + function Animation(_driver, input) { + this._driver = _driver; + var errors = []; + var ast = buildAnimationAst(input, errors); + if (errors.length) { + var errorMessage = "animation validation failed:\n" + errors.join("\n"); + throw new Error(errorMessage); } - // TODO(alxhub): Need relative path logic from BrowserDomAdapter here? - return href == null ? null : href; - }; - /** - * @return {?} - */ - Parse5DomAdapter.prototype.resetBaseElement = function () { throw 'not implemented'; }; + this._animationAst = ast; + } /** + * @param {?} element + * @param {?} startingStyles + * @param {?} destinationStyles + * @param {?} options + * @param {?=} subInstructions * @return {?} */ - Parse5DomAdapter.prototype.getHistory = function () { throw 'not implemented'; }; + Animation.prototype.buildTimelines = function (element, startingStyles, destinationStyles, options, subInstructions) { + var /** @type {?} */ start = Array.isArray(startingStyles) ? normalizeStyles(startingStyles) : (startingStyles); + var /** @type {?} */ dest = Array.isArray(destinationStyles) ? normalizeStyles(destinationStyles) : (destinationStyles); + var /** @type {?} */ errors = []; + subInstructions = subInstructions || new ElementInstructionMap(); + var /** @type {?} */ result = buildAnimationTimelines(this._driver, element, this._animationAst, start, dest, options, subInstructions, errors); + if (errors.length) { + var /** @type {?} */ errorMessage = "animation building failed:\n" + errors.join("\n"); + throw new Error(errorMessage); + } + return result; + }; + return Animation; +}()); +/** + * @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 + */ +/** + * @experimental Animation support is experimental. + */ +/** + * @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 AnimationStyleNormalizer = (function () { + function AnimationStyleNormalizer() { + } + return AnimationStyleNormalizer; +}()); +/** + * @experimental Animation support is experimental. + */ +var NoopAnimationStyleNormalizer = (function () { + function NoopAnimationStyleNormalizer() { + } + NoopAnimationStyleNormalizer.prototype.normalizePropertyName = function (propertyName, errors) { return propertyName; }; + NoopAnimationStyleNormalizer.prototype.normalizeStyleValue = function (userProvidedProperty, normalizedProperty, value, errors) { + return value; + }; + return NoopAnimationStyleNormalizer; +}()); +/** + * @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 WebAnimationsStyleNormalizer = (function (_super) { + __extends(WebAnimationsStyleNormalizer, _super); + function WebAnimationsStyleNormalizer() { + return _super !== null && _super.apply(this, arguments) || this; + } /** + * @param {?} propertyName + * @param {?} errors * @return {?} */ - Parse5DomAdapter.prototype.getLocation = function () { throw 'not implemented'; }; + WebAnimationsStyleNormalizer.prototype.normalizePropertyName = function (propertyName, errors) { + return dashCaseToCamelCase(propertyName); + }; /** + * @param {?} userProvidedProperty + * @param {?} normalizedProperty + * @param {?} value + * @param {?} errors * @return {?} */ - Parse5DomAdapter.prototype.getUserAgent = function () { return 'Fake user agent'; }; + WebAnimationsStyleNormalizer.prototype.normalizeStyleValue = function (userProvidedProperty, normalizedProperty, value, errors) { + var /** @type {?} */ unit = ''; + var /** @type {?} */ strVal = value.toString().trim(); + if (DIMENSIONAL_PROP_MAP[normalizedProperty] && value !== 0 && value !== '0') { + if (typeof value === 'number') { + unit = 'px'; + } + else { + var /** @type {?} */ valAndSuffixMatch = value.match(/^[+-]?[\d\.]+([a-z]*)$/); + if (valAndSuffixMatch && valAndSuffixMatch[1].length == 0) { + errors.push("Please provide a CSS unit value for " + userProvidedProperty + ":" + value); + } + } + } + return strVal + unit; + }; + return WebAnimationsStyleNormalizer; +}(AnimationStyleNormalizer)); +var DIMENSIONAL_PROP_MAP = makeBooleanMap('width,height,minWidth,minHeight,maxWidth,maxHeight,left,top,bottom,right,fontSize,outlineWidth,outlineOffset,paddingTop,paddingLeft,paddingBottom,paddingRight,marginTop,marginLeft,marginBottom,marginRight,borderRadius,borderWidth,borderTopWidth,borderLeftWidth,borderRightWidth,borderBottomWidth,textIndent,perspective' + .split(',')); +/** + * @param {?} keys + * @return {?} + */ +function makeBooleanMap(keys) { + var /** @type {?} */ map = {}; + keys.forEach(function (key) { return map[key] = true; }); + return map; +} +/** + * @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 + */ +/** + * @param {?} element + * @param {?} triggerName + * @param {?} fromState + * @param {?} toState + * @param {?} isRemovalTransition + * @param {?} fromStyles + * @param {?} toStyles + * @param {?} timelines + * @param {?} queriedElements + * @param {?} preStyleProps + * @param {?} postStyleProps + * @return {?} + */ +function createTransitionInstruction(element, triggerName, fromState, toState, isRemovalTransition, fromStyles, toStyles, timelines, queriedElements, preStyleProps, postStyleProps) { + return { + type: 0 /* TransitionAnimation */, + element: element, + triggerName: triggerName, + isRemovalTransition: isRemovalTransition, + fromState: fromState, + fromStyles: fromStyles, + toState: toState, + toStyles: toStyles, + timelines: timelines, + queriedElements: queriedElements, + preStyleProps: preStyleProps, + postStyleProps: postStyleProps + }; +} +/** + * @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 AnimationTransitionFactory = (function () { /** - * @param {?} el - * @param {?} name - * @return {?} + * @param {?} _triggerName + * @param {?} ast + * @param {?} _stateStyles */ - Parse5DomAdapter.prototype.getData = function (el, name) { return this.getAttribute(el, 'data-' + name); }; + function AnimationTransitionFactory(_triggerName, ast, _stateStyles) { + this._triggerName = _triggerName; + this.ast = ast; + this._stateStyles = _stateStyles; + } /** - * @param {?} el + * @param {?} currentState + * @param {?} nextState * @return {?} */ - Parse5DomAdapter.prototype.getComputedStyle = function (el) { throw 'not implemented'; }; + AnimationTransitionFactory.prototype.match = function (currentState, nextState) { + return oneOrMoreTransitionsMatch(this.ast.matchers, currentState, nextState); + }; /** - * @param {?} el - * @param {?} name - * @param {?} value + * @param {?} driver + * @param {?} element + * @param {?} currentState + * @param {?} nextState + * @param {?=} options + * @param {?=} subInstructions * @return {?} */ - Parse5DomAdapter.prototype.setData = function (el, name, value) { this.setAttribute(el, 'data-' + name, value); }; - /** - * @return {?} + AnimationTransitionFactory.prototype.build = function (driver, element, currentState, nextState, options, subInstructions) { + var /** @type {?} */ animationOptions = mergeAnimationOptions(this.ast.options || {}, options || {}); + var /** @type {?} */ backupStateStyles = this._stateStyles['*'] || {}; + var /** @type {?} */ currentStateStyles = this._stateStyles[currentState] || backupStateStyles; + var /** @type {?} */ nextStateStyles = this._stateStyles[nextState] || backupStateStyles; + var /** @type {?} */ errors = []; + var /** @type {?} */ timelines = buildAnimationTimelines(driver, element, this.ast.animation, currentStateStyles, nextStateStyles, animationOptions, subInstructions, errors); + if (errors.length) { + var /** @type {?} */ errorMessage = "animation building failed:\n" + errors.join("\n"); + throw new Error(errorMessage); + } + var /** @type {?} */ preStyleMap = new Map(); + var /** @type {?} */ postStyleMap = new Map(); + var /** @type {?} */ queriedElements = new Set(); + timelines.forEach(function (tl) { + var /** @type {?} */ elm = tl.element; + var /** @type {?} */ preProps = getOrSetAsInMap(preStyleMap, elm, {}); + tl.preStyleProps.forEach(function (prop) { return preProps[prop] = true; }); + var /** @type {?} */ postProps = getOrSetAsInMap(postStyleMap, elm, {}); + tl.postStyleProps.forEach(function (prop) { return postProps[prop] = true; }); + if (elm !== element) { + queriedElements.add(elm); + } + }); + var /** @type {?} */ queriedElementsList = iteratorToArray(queriedElements.values()); + return createTransitionInstruction(element, this._triggerName, currentState, nextState, nextState === 'void', currentStateStyles, nextStateStyles, timelines, queriedElementsList, preStyleMap, postStyleMap); + }; + return AnimationTransitionFactory; +}()); +/** + * @param {?} matchFns + * @param {?} currentState + * @param {?} nextState + * @return {?} + */ +function oneOrMoreTransitionsMatch(matchFns, currentState, nextState) { + return matchFns.some(function (fn) { return fn(currentState, nextState); }); +} +/** + * @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 + */ +/** + * \@experimental Animation support is experimental. + * @param {?} name + * @param {?} ast + * @return {?} + */ +function buildTrigger(name, ast) { + return new AnimationTrigger(name, ast); +} +/** + * \@experimental Animation support is experimental. + */ +var AnimationTrigger = (function () { + /** + * @param {?} name + * @param {?} ast */ - Parse5DomAdapter.prototype.supportsWebAnimation = function () { return false; }; + function AnimationTrigger(name, ast) { + var _this = this; + this.name = name; + this.ast = ast; + this.transitionFactories = []; + this.states = {}; + ast.states.forEach(function (ast) { + var obj = _this.states[ast.name] = {}; + ast.style.styles.forEach(function (styleTuple) { + if (typeof styleTuple == 'object') { + copyStyles(styleTuple, false, obj); + } + }); + }); + balanceProperties(this.states, 'true', '1'); + balanceProperties(this.states, 'false', '0'); + ast.transitions.forEach(function (ast) { + _this.transitionFactories.push(new AnimationTransitionFactory(name, ast, _this.states)); + }); + this.fallbackTransition = createFallbackTransition(name, this.states); + } + Object.defineProperty(AnimationTrigger.prototype, "containsQueries", { + /** + * @return {?} + */ + get: function () { return this.ast.queryCount > 0; }, + enumerable: true, + configurable: true + }); /** + * @param {?} currentState + * @param {?} nextState * @return {?} */ - Parse5DomAdapter.prototype.performanceNow = function () { return Date.now(); }; + AnimationTrigger.prototype.matchTransition = function (currentState, nextState) { + var /** @type {?} */ entry = this.transitionFactories.find(function (f) { return f.match(currentState, nextState); }); + return entry || null; + }; + return AnimationTrigger; +}()); +/** + * @param {?} triggerName + * @param {?} states + * @return {?} + */ +function createFallbackTransition(triggerName, states) { + var /** @type {?} */ matchers = [function (fromState, toState) { return true; }]; + var /** @type {?} */ animation = new SequenceAst([]); + var /** @type {?} */ transition = new TransitionAst(matchers, animation); + return new AnimationTransitionFactory(triggerName, transition, states); +} +/** + * @param {?} obj + * @param {?} key1 + * @param {?} key2 + * @return {?} + */ +function balanceProperties(obj, key1, key2) { + if (obj.hasOwnProperty(key1)) { + if (!obj.hasOwnProperty(key2)) { + obj[key2] = obj[key1]; + } + } + else if (obj.hasOwnProperty(key2)) { + obj[key1] = obj[key2]; + } +} +/** + * @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 EMPTY_INSTRUCTION_MAP = new ElementInstructionMap(); +var TimelineAnimationEngine = (function () { + /** + * @param {?} _driver + * @param {?} _normalizer + */ + function TimelineAnimationEngine(_driver, _normalizer) { + this._driver = _driver; + this._normalizer = _normalizer; + this._animations = {}; + this._playersById = {}; + this.players = []; + } /** + * @param {?} id + * @param {?} metadata * @return {?} */ - Parse5DomAdapter.prototype.getAnimationPrefix = function () { return ''; }; + TimelineAnimationEngine.prototype.register = function (id, metadata) { + var /** @type {?} */ errors = []; + var /** @type {?} */ ast = buildAnimationAst(metadata, errors); + if (errors.length) { + throw new Error("Unable to build the animation due to the following errors: " + errors.join("\n")); + } + else { + this._animations[id] = ast; + } + }; /** + * @param {?} i + * @param {?} preStyles + * @param {?=} postStyles * @return {?} */ - Parse5DomAdapter.prototype.getTransitionEnd = function () { return 'transitionend'; }; + TimelineAnimationEngine.prototype._buildPlayer = function (i, preStyles, postStyles) { + var /** @type {?} */ element = i.element; + var /** @type {?} */ keyframes = normalizeKeyframes(this._driver, this._normalizer, element, i.keyframes, preStyles, postStyles); + return this._driver.animate(element, keyframes, i.duration, i.delay, i.easing, []); + }; /** + * @param {?} id + * @param {?} element + * @param {?=} options * @return {?} */ - Parse5DomAdapter.prototype.supportsAnimation = function () { return true; }; + TimelineAnimationEngine.prototype.create = function (id, element, options) { + var _this = this; + if (options === void 0) { options = {}; } + var /** @type {?} */ errors = []; + var /** @type {?} */ ast = this._animations[id]; + var /** @type {?} */ instructions; + var /** @type {?} */ autoStylesMap = new Map(); + if (ast) { + instructions = buildAnimationTimelines(this._driver, element, ast, {}, {}, options, EMPTY_INSTRUCTION_MAP, errors); + instructions.forEach(function (inst) { + var /** @type {?} */ styles = getOrSetAsInMap(autoStylesMap, inst.element, {}); + inst.postStyleProps.forEach(function (prop) { return styles[prop] = null; }); + }); + } + else { + errors.push('The requested animation doesn\'t exist or has already been destroyed'); + instructions = []; + } + if (errors.length) { + throw new Error("Unable to create the animation due to the following errors: " + errors.join("\n")); + } + autoStylesMap.forEach(function (styles, element) { + Object.keys(styles).forEach(function (prop) { styles[prop] = _this._driver.computeStyle(element, prop, _angular_animations.AUTO_STYLE); }); + }); + var /** @type {?} */ players = instructions.map(function (i) { + var /** @type {?} */ styles = autoStylesMap.get(i.element); + return _this._buildPlayer(i, {}, styles); + }); + var /** @type {?} */ player = optimizeGroupPlayer(players); + this._playersById[id] = player; + player.onDestroy(function () { return _this.destroy(id); }); + this.players.push(player); + return player; + }; /** - * @param {?} el - * @param {?} newNode - * @param {?} oldNode + * @param {?} id * @return {?} */ - Parse5DomAdapter.prototype.replaceChild = function (el, newNode, oldNode) { throw new Error('not implemented'); }; + TimelineAnimationEngine.prototype.destroy = function (id) { + var /** @type {?} */ player = this._getPlayer(id); + player.destroy(); + delete this._playersById[id]; + var /** @type {?} */ index = this.players.indexOf(player); + if (index >= 0) { + this.players.splice(index, 1); + } + }; /** - * @param {?} templateHtml + * @param {?} id * @return {?} */ - Parse5DomAdapter.prototype.parse = function (templateHtml) { throw new Error('not implemented'); }; + TimelineAnimationEngine.prototype._getPlayer = function (id) { + var /** @type {?} */ player = this._playersById[id]; + if (!player) { + throw new Error("Unable to find the timeline player referenced by " + id); + } + return player; + }; /** - * @param {?} el - * @param {?} methodName - * @param {?} args + * @param {?} id + * @param {?} element + * @param {?} eventName + * @param {?} callback * @return {?} */ - Parse5DomAdapter.prototype.invoke = function (el, methodName, args) { throw new Error('not implemented'); }; + TimelineAnimationEngine.prototype.listen = function (id, element, eventName, callback) { + // triggerName, fromState, toState are all ignored for timeline animations + var /** @type {?} */ baseEvent = makeAnimationEvent(element, '', '', ''); + listenOnPlayer(this._getPlayer(id), eventName, baseEvent, callback); + return function () { }; + }; /** - * @param {?} event + * @param {?} id + * @param {?} element + * @param {?} command + * @param {?} args * @return {?} */ - Parse5DomAdapter.prototype.getEventKey = function (event) { throw new Error('not implemented'); }; + TimelineAnimationEngine.prototype.command = function (id, element, command, args) { + if (command == 'register') { + this.register(id, /** @type {?} */ (args[0])); + return; + } + if (command == 'create') { + var /** @type {?} */ options = ((args[0] || {})); + this.create(id, element, options); + return; + } + var /** @type {?} */ player = this._getPlayer(id); + switch (command) { + case 'play': + player.play(); + break; + case 'pause': + player.pause(); + break; + case 'reset': + player.reset(); + break; + case 'restart': + player.restart(); + break; + case 'finish': + player.finish(); + break; + case 'init': + player.init(); + break; + case 'setPosition': + player.setPosition(parseFloat(/** @type {?} */ (args[0]))); + break; + case 'destroy': + this.destroy(id); + break; + } + }; + return TimelineAnimationEngine; +}()); +/** + * @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 EMPTY_PLAYER_ARRAY = []; +var NULL_REMOVAL_STATE = { + namespaceId: '', + setForRemoval: null, + hasAnimation: false, + removedBeforeQueried: false +}; +var NULL_REMOVED_QUERIED_STATE = { + namespaceId: '', + setForRemoval: null, + hasAnimation: false, + removedBeforeQueried: true +}; +var REMOVAL_FLAG = '__ng_removed'; +var StateValue = (function () { + /** + * @param {?} input + */ + function StateValue(input) { + var isObj = input && input.hasOwnProperty('value'); + var value = isObj ? input['value'] : input; + this.value = normalizeTriggerValue(value); + if (isObj) { + var options = copyObj(input); + delete options['value']; + this.options = options; + } + else { + this.options = {}; + } + if (!this.options.params) { + this.options.params = {}; + } + } /** + * @param {?} options * @return {?} */ - Parse5DomAdapter.prototype.supportsCookies = function () { return false; }; + StateValue.prototype.absorbOptions = function (options) { + var /** @type {?} */ newParams = options.params; + if (newParams) { + var /** @type {?} */ oldParams_2 = ((this.options.params)); + Object.keys(newParams).forEach(function (prop) { + if (oldParams_2[prop] == null) { + oldParams_2[prop] = newParams[prop]; + } + }); + } + }; + return StateValue; +}()); +var VOID_VALUE = 'void'; +var DEFAULT_STATE_VALUE = new StateValue(VOID_VALUE); +var DELETED_STATE_VALUE = new StateValue('DELETED'); +var AnimationTransitionNamespace = (function () { + /** + * @param {?} id + * @param {?} hostElement + * @param {?} _engine + */ + function AnimationTransitionNamespace(id, hostElement, _engine) { + this.id = id; + this.hostElement = hostElement; + this._engine = _engine; + this.players = []; + this._triggers = {}; + this._queue = []; + this._elementListeners = new Map(); + this._hostClassName = 'ng-tns-' + id; + addClass(hostElement, this._hostClassName); + } /** + * @param {?} element * @param {?} name + * @param {?} phase + * @param {?} callback * @return {?} */ - Parse5DomAdapter.prototype.getCookie = function (name) { throw new Error('not implemented'); }; + AnimationTransitionNamespace.prototype.listen = function (element, name, phase, callback) { + var _this = this; + if (!this._triggers.hasOwnProperty(name)) { + throw new Error("Unable to listen on the animation trigger event \"" + phase + "\" because the animation trigger \"" + name + "\" doesn't exist!"); + } + if (phase == null || phase.length == 0) { + throw new Error("Unable to listen on the animation trigger \"" + name + "\" because the provided event is undefined!"); + } + if (!isTriggerEventValid(phase)) { + throw new Error("The provided animation trigger event \"" + phase + "\" for the animation trigger \"" + name + "\" is not supported!"); + } + var /** @type {?} */ listeners = getOrSetAsInMap(this._elementListeners, element, []); + var /** @type {?} */ data = { name: name, phase: phase, callback: callback }; + listeners.push(data); + var /** @type {?} */ triggersWithStates = getOrSetAsInMap(this._engine.statesByElement, element, {}); + if (!triggersWithStates.hasOwnProperty(name)) { + addClass(element, NG_TRIGGER_CLASSNAME); + addClass(element, NG_TRIGGER_CLASSNAME + '-' + name); + triggersWithStates[name] = null; + } + return function () { + // the event listener is removed AFTER the flush has occurred such + // that leave animations callbacks can fire (otherwise if the node + // is removed in between then the listeners would be deregistered) + _this._engine.afterFlush(function () { + var /** @type {?} */ index = listeners.indexOf(data); + if (index >= 0) { + listeners.splice(index, 1); + } + if (!_this._triggers[name]) { + delete triggersWithStates[name]; + } + }); + }; + }; /** * @param {?} name - * @param {?} value + * @param {?} ast * @return {?} */ - Parse5DomAdapter.prototype.setCookie = function (name, value) { throw new Error('not implemented'); }; + AnimationTransitionNamespace.prototype.register = function (name, ast) { + if (this._triggers[name]) { + // throw + return false; + } + else { + this._triggers[name] = ast; + return true; + } + }; /** - * @param {?} element - * @param {?} keyframes - * @param {?} options + * @param {?} name * @return {?} */ - Parse5DomAdapter.prototype.animate = function (element, keyframes, options) { throw new Error('not implemented'); }; + AnimationTransitionNamespace.prototype._getTrigger = function (name) { + var /** @type {?} */ trigger = this._triggers[name]; + if (!trigger) { + throw new Error("The provided animation trigger \"" + name + "\" has not been registered!"); + } + return trigger; + }; /** - * @param {?} doc + * @param {?} element + * @param {?} triggerName + * @param {?} value + * @param {?=} defaultToFallback * @return {?} */ - Parse5DomAdapter.prototype.getTitleNode = function (doc) { - var /** @type {?} */ title = this.querySelector(doc, 'title'); - if (!title) { - title = (this.createElement('title')); - this.appendChild(this.querySelector(doc, 'head'), title); + AnimationTransitionNamespace.prototype.trigger = function (element, triggerName, value, defaultToFallback) { + var _this = this; + if (defaultToFallback === void 0) { defaultToFallback = true; } + var /** @type {?} */ trigger = this._getTrigger(triggerName); + var /** @type {?} */ player = new TransitionAnimationPlayer(this.id, triggerName, element); + var /** @type {?} */ triggersWithStates = this._engine.statesByElement.get(element); + if (!triggersWithStates) { + addClass(element, NG_TRIGGER_CLASSNAME); + addClass(element, NG_TRIGGER_CLASSNAME + '-' + triggerName); + this._engine.statesByElement.set(element, triggersWithStates = {}); } - return title; + var /** @type {?} */ fromState = triggersWithStates[triggerName]; + var /** @type {?} */ toState = new StateValue(value); + var /** @type {?} */ isObj = value && value.hasOwnProperty('value'); + if (!isObj && fromState) { + toState.absorbOptions(fromState.options); + } + triggersWithStates[triggerName] = toState; + if (!fromState) { + fromState = DEFAULT_STATE_VALUE; + } + else if (fromState === DELETED_STATE_VALUE) { + return player; + } + var /** @type {?} */ playersOnElement = getOrSetAsInMap(this._engine.playersByElement, element, []); + playersOnElement.forEach(function (player) { + // only remove the player if it is queued on the EXACT same trigger/namespace + // we only also deal with queued players here because if the animation has + // started then we want to keep the player alive until the flush happens + // (which is where the previousPlayers are passed into the new palyer) + if (player.namespaceId == _this.id && player.triggerName == triggerName && player.queued) { + player.destroy(); + } + }); + var /** @type {?} */ transition = trigger.matchTransition(fromState.value, toState.value); + var /** @type {?} */ isFallbackTransition = false; + if (!transition) { + if (!defaultToFallback) + return; + transition = trigger.fallbackTransition; + isFallbackTransition = true; + } + this._engine.totalQueuedPlayers++; + this._queue.push({ element: element, triggerName: triggerName, transition: transition, fromState: fromState, toState: toState, player: player, isFallbackTransition: isFallbackTransition }); + if (!isFallbackTransition) { + addClass(element, NG_ANIMATING_CLASSNAME); + } + player.onDone(function () { + removeClass(element, NG_ANIMATING_CLASSNAME); + var /** @type {?} */ index = _this.players.indexOf(player); + if (index >= 0) { + _this.players.splice(index, 1); + } + var /** @type {?} */ players = _this._engine.playersByElement.get(element); + if (players) { + var /** @type {?} */ index_1 = players.indexOf(player); + if (index_1 >= 0) { + players.splice(index_1, 1); + } + } + }); + this.players.push(player); + playersOnElement.push(player); + return player; }; - return Parse5DomAdapter; -}(_angular_platformBrowser.ɵDomAdapter)); -// TODO: build a proper list, this one is all the keys of a HTMLInputElement -var _HTMLElementPropertyList = [ - 'webkitEntries', - 'incremental', - 'webkitdirectory', - 'selectionDirection', - 'selectionEnd', - 'selectionStart', - 'labels', - 'validationMessage', - 'validity', - 'willValidate', - 'width', - 'valueAsNumber', - 'valueAsDate', - 'value', - 'useMap', - 'defaultValue', - 'type', - 'step', - 'src', - 'size', - 'required', - 'readOnly', - 'placeholder', - 'pattern', - 'name', - 'multiple', - 'min', - 'minLength', - 'maxLength', - 'max', - 'list', - 'indeterminate', - 'height', - 'formTarget', - 'formNoValidate', - 'formMethod', - 'formEnctype', - 'formAction', - 'files', - 'form', - 'disabled', - 'dirName', - 'checked', - 'defaultChecked', - 'autofocus', - 'autocomplete', - 'alt', - 'align', - 'accept', - 'onautocompleteerror', - 'onautocomplete', - 'onwaiting', - 'onvolumechange', - 'ontoggle', - 'ontimeupdate', - 'onsuspend', - 'onsubmit', - 'onstalled', - 'onshow', - 'onselect', - 'onseeking', - 'onseeked', - 'onscroll', - 'onresize', - 'onreset', - 'onratechange', - 'onprogress', - 'onplaying', - 'onplay', - 'onpause', - 'onmousewheel', - 'onmouseup', - 'onmouseover', - 'onmouseout', - 'onmousemove', - 'onmouseleave', - 'onmouseenter', - 'onmousedown', - 'onloadstart', - 'onloadedmetadata', - 'onloadeddata', - 'onload', - 'onkeyup', - 'onkeypress', - 'onkeydown', - 'oninvalid', - 'oninput', - 'onfocus', - 'onerror', - 'onended', - 'onemptied', - 'ondurationchange', - 'ondrop', - 'ondragstart', - 'ondragover', - 'ondragleave', - 'ondragenter', - 'ondragend', - 'ondrag', - 'ondblclick', - 'oncuechange', - 'oncontextmenu', - 'onclose', - 'onclick', - 'onchange', - 'oncanplaythrough', - 'oncanplay', - 'oncancel', - 'onblur', - 'onabort', - 'spellcheck', - 'isContentEditable', - 'contentEditable', - 'outerText', - 'innerText', - 'accessKey', - 'hidden', - 'webkitdropzone', - 'draggable', - 'tabIndex', - 'dir', - 'translate', - 'lang', - 'title', - 'childElementCount', - 'lastElementChild', - 'firstElementChild', - 'children', - 'onwebkitfullscreenerror', - 'onwebkitfullscreenchange', - 'nextElementSibling', - 'previousElementSibling', - 'onwheel', - 'onselectstart', - 'onsearch', - 'onpaste', - 'oncut', - 'oncopy', - 'onbeforepaste', - 'onbeforecut', - 'onbeforecopy', - 'shadowRoot', - 'dataset', - 'classList', - 'className', - 'outerHTML', - 'innerHTML', - 'scrollHeight', - 'scrollWidth', - 'scrollTop', - 'scrollLeft', - 'clientHeight', - 'clientWidth', - 'clientTop', - 'clientLeft', - 'offsetParent', - 'offsetHeight', - 'offsetWidth', - 'offsetTop', - 'offsetLeft', - 'localName', - 'prefix', - 'namespaceURI', - 'id', - 'style', - 'attributes', - 'tagName', - 'parentElement', - 'textContent', - 'baseURI', - 'ownerDocument', - 'nextSibling', - 'previousSibling', - 'lastChild', - 'firstChild', - 'childNodes', - 'parentNode', - 'nodeType', - 'nodeValue', - 'nodeName', - 'closure_lm_714617', - '__jsaction', -]; -/** - * @template T - * @param {?} list - * @param {?} el - * @return {?} - */ -function remove(list, el) { - var /** @type {?} */ index = list.indexOf(el); - if (index > -1) { - list.splice(index, 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 EMPTY_ARRAY = []; -var ServerRendererFactory2 = (function () { /** - * @param {?} ngZone - * @param {?} document - * @param {?} sharedStylesHost + * @param {?} name + * @return {?} */ - function ServerRendererFactory2(ngZone, document, sharedStylesHost) { - this.ngZone = ngZone; - this.document = document; - this.sharedStylesHost = sharedStylesHost; - this.rendererByCompId = new Map(); - this.schema = new _angular_compiler.DomElementSchemaRegistry(); - this.defaultRenderer = new DefaultServerRenderer2(document, ngZone, this.schema); - } - + AnimationTransitionNamespace.prototype.deregister = function (name) { + var _this = this; + delete this._triggers[name]; + this._engine.statesByElement.forEach(function (stateMap, element) { delete stateMap[name]; }); + this._elementListeners.forEach(function (listeners, element) { + _this._elementListeners.set(element, listeners.filter(function (entry) { return entry.name != name; })); + }); + }; /** * @param {?} element - * @param {?} type * @return {?} */ - ServerRendererFactory2.prototype.createRenderer = function (element, type) { - if (!element || !type) { - return this.defaultRenderer; - } - switch (type.encapsulation) { - case _angular_core.ViewEncapsulation.Native: - case _angular_core.ViewEncapsulation.Emulated: { - var /** @type {?} */ renderer = this.rendererByCompId.get(type.id); - if (!renderer) { - renderer = new EmulatedEncapsulationServerRenderer2(this.document, this.ngZone, this.sharedStylesHost, this.schema, type); - this.rendererByCompId.set(type.id, renderer); - } - ((renderer)).applyToHost(element); - return renderer; - } - case _angular_core.ViewEncapsulation.Native: - throw new Error('Native encapsulation is not supported on the server!'); - default: { - if (!this.rendererByCompId.has(type.id)) { - var /** @type {?} */ styles = _angular_platformBrowser.ɵflattenStyles(type.id, type.styles, []); - this.sharedStylesHost.addStyles(styles); - this.rendererByCompId.set(type.id, this.defaultRenderer); - } - return this.defaultRenderer; - } + AnimationTransitionNamespace.prototype.clearElementCache = function (element) { + this._engine.statesByElement.delete(element); + this._elementListeners.delete(element); + var /** @type {?} */ elementPlayers = this._engine.playersByElement.get(element); + if (elementPlayers) { + elementPlayers.forEach(function (player) { return player.destroy(); }); + this._engine.playersByElement.delete(element); } }; /** + * @param {?} rootElement + * @param {?} context + * @param {?=} animate * @return {?} */ - ServerRendererFactory2.prototype.begin = function () { }; - /** - * @return {?} - */ - ServerRendererFactory2.prototype.end = function () { }; - return ServerRendererFactory2; -}()); -ServerRendererFactory2.decorators = [ - { type: _angular_core.Injectable }, -]; -/** - * @nocollapse - */ -ServerRendererFactory2.ctorParameters = function () { return [ - { type: _angular_core.NgZone, }, - { type: undefined, decorators: [{ type: _angular_core.Inject, args: [_angular_platformBrowser.DOCUMENT,] },] }, - { type: _angular_platformBrowser.ɵSharedStylesHost, }, -]; }; -var DefaultServerRenderer2 = (function () { - /** - * @param {?} document - * @param {?} ngZone - * @param {?} schema - */ - function DefaultServerRenderer2(document, ngZone, schema) { - this.document = document; - this.ngZone = ngZone; - this.schema = schema; - this.data = Object.create(null); - } - /** - * @return {?} - */ - DefaultServerRenderer2.prototype.destroy = function () { }; + AnimationTransitionNamespace.prototype._destroyInnerNodes = function (rootElement, context, animate) { + var _this = this; + if (animate === void 0) { animate = false; } + this._engine.driver.query(rootElement, NG_TRIGGER_SELECTOR, true).forEach(function (elm) { + if (animate && containsClass(elm, _this._hostClassName)) { + var /** @type {?} */ innerNs = _this._engine.namespacesByHostElement.get(elm); + // special case for a host element with animations on the same element + if (innerNs) { + innerNs.removeNode(elm, context, true); + } + _this.removeNode(elm, context, true); + } + else { + _this.clearElementCache(elm); + } + }); + }; /** - * @param {?} name - * @param {?=} namespace - * @param {?=} debugInfo + * @param {?} element + * @param {?} context + * @param {?=} doNotRecurse * @return {?} */ - DefaultServerRenderer2.prototype.createElement = function (name, namespace, debugInfo) { - if (namespace) { - return _angular_platformBrowser.ɵgetDOM().createElementNS(_angular_platformBrowser.ɵNAMESPACE_URIS[namespace], name); + AnimationTransitionNamespace.prototype.removeNode = function (element, context, doNotRecurse) { + var _this = this; + var /** @type {?} */ engine = this._engine; + if (!doNotRecurse && element.childElementCount) { + this._destroyInnerNodes(element, context, true); + } + var /** @type {?} */ triggerStates = engine.statesByElement.get(element); + if (triggerStates) { + var /** @type {?} */ players_1 = []; + Object.keys(triggerStates).forEach(function (triggerName) { + // this check is here in the event that an element is removed + // twice (both on the host level and the component level) + if (_this._triggers[triggerName]) { + var /** @type {?} */ player = _this.trigger(element, triggerName, VOID_VALUE, false); + if (player) { + players_1.push(player); + } + } + }); + if (players_1.length) { + engine.markElementAsRemoved(this.id, element, true, context); + optimizeGroupPlayer(players_1).onDone(function () { return engine.processLeaveNode(element); }); + return; + } + } + // find the player that is animating and make sure that the + // removal is delayed until that player has completed + var /** @type {?} */ containsPotentialParentTransition = false; + if (engine.totalAnimations) { + var /** @type {?} */ currentPlayers = engine.players.length ? engine.playersByQueriedElement.get(element) : []; + // when this `if statement` does not continue forward it means that + // a previous animation query has selected the current element and + // is animating it. In this situation want to continue fowards and + // allow the element to be queued up for animation later. + if (currentPlayers && currentPlayers.length) { + containsPotentialParentTransition = true; + } + else { + var /** @type {?} */ parent = element; + while (parent = parent.parentNode) { + var /** @type {?} */ triggers = engine.statesByElement.get(parent); + if (triggers) { + containsPotentialParentTransition = true; + break; + } + } + } + } + // at this stage we know that the element will either get removed + // during flush or will be picked up by a parent query. Either way + // we need to fire the listeners for this element when it DOES get + // removed (once the query parent animation is done or after flush) + var /** @type {?} */ listeners = this._elementListeners.get(element); + if (listeners) { + var /** @type {?} */ visitedTriggers_1 = new Set(); + listeners.forEach(function (listener) { + var /** @type {?} */ triggerName = listener.name; + if (visitedTriggers_1.has(triggerName)) + return; + visitedTriggers_1.add(triggerName); + var /** @type {?} */ trigger = _this._triggers[triggerName]; + var /** @type {?} */ transition = trigger.fallbackTransition; + var /** @type {?} */ elementStates = ((engine.statesByElement.get(element))); + var /** @type {?} */ fromState = elementStates[triggerName] || DEFAULT_STATE_VALUE; + var /** @type {?} */ toState = new StateValue(VOID_VALUE); + var /** @type {?} */ player = new TransitionAnimationPlayer(_this.id, triggerName, element); + _this._engine.totalQueuedPlayers++; + _this._queue.push({ + element: element, + triggerName: triggerName, + transition: transition, + fromState: fromState, + toState: toState, + player: player, + isFallbackTransition: true + }); + }); + } + // whether or not a parent has an animation we need to delay the deferral of the leave + // operation until we have more information (which we do after flush() has been called) + if (containsPotentialParentTransition) { + engine.markElementAsRemoved(this.id, element, false, context); + } + else { + // we do this after the flush has occurred such + // that the callbacks can be fired + engine.afterFlush(function () { return _this.clearElementCache(element); }); + engine.destroyInnerAnimations(element); + engine._onRemovalComplete(element, context); } - return _angular_platformBrowser.ɵgetDOM().createElement(name); }; /** - * @param {?} value - * @param {?=} debugInfo - * @return {?} - */ - DefaultServerRenderer2.prototype.createComment = function (value, debugInfo) { return _angular_platformBrowser.ɵgetDOM().createComment(value); }; - /** - * @param {?} value - * @param {?=} debugInfo - * @return {?} - */ - DefaultServerRenderer2.prototype.createText = function (value, debugInfo) { return _angular_platformBrowser.ɵgetDOM().createTextNode(value); }; - /** + * @param {?} element * @param {?} parent - * @param {?} newChild * @return {?} */ - DefaultServerRenderer2.prototype.appendChild = function (parent, newChild) { _angular_platformBrowser.ɵgetDOM().appendChild(parent, newChild); }; + AnimationTransitionNamespace.prototype.insertNode = function (element, parent) { addClass(element, this._hostClassName); }; /** - * @param {?} parent - * @param {?} newChild - * @param {?} refChild + * @param {?} microtaskId * @return {?} */ - DefaultServerRenderer2.prototype.insertBefore = function (parent, newChild, refChild) { - if (parent) { - _angular_platformBrowser.ɵgetDOM().insertBefore(parent, refChild, newChild); - } + AnimationTransitionNamespace.prototype.drainQueuedTransitions = function (microtaskId) { + var _this = this; + var /** @type {?} */ instructions = []; + this._queue.forEach(function (entry) { + var /** @type {?} */ player = entry.player; + if (player.destroyed) + return; + var /** @type {?} */ element = entry.element; + var /** @type {?} */ listeners = _this._elementListeners.get(element); + if (listeners) { + listeners.forEach(function (listener) { + if (listener.name == entry.triggerName) { + var /** @type {?} */ baseEvent = makeAnimationEvent(element, entry.triggerName, entry.fromState.value, entry.toState.value); + ((baseEvent))['_data'] = microtaskId; + listenOnPlayer(entry.player, listener.phase, baseEvent, listener.callback); + } + }); + } + if (player.markedForDestroy) { + _this._engine.afterFlush(function () { + // now we can destroy the element properly since the event listeners have + // been bound to the player + player.destroy(); + }); + } + else { + instructions.push(entry); + } + }); + this._queue = []; + return instructions.sort(function (a, b) { + // if depCount == 0 them move to front + // otherwise if a contains b then move back + var /** @type {?} */ d0 = a.transition.ast.depCount; + var /** @type {?} */ d1 = b.transition.ast.depCount; + if (d0 == 0 || d1 == 0) { + return d0 - d1; + } + return _this._engine.driver.containsElement(a.element, b.element) ? 1 : -1; + }); }; /** - * @param {?} parent - * @param {?} oldChild + * @param {?} context * @return {?} */ - DefaultServerRenderer2.prototype.removeChild = function (parent, oldChild) { - if (parent) { - _angular_platformBrowser.ɵgetDOM().removeChild(parent, oldChild); - } + AnimationTransitionNamespace.prototype.destroy = function (context) { + this.players.forEach(function (p) { return p.destroy(); }); + this._destroyInnerNodes(this.hostElement, context); }; /** - * @param {?} selectorOrNode - * @param {?=} debugInfo + * @param {?} element * @return {?} */ - DefaultServerRenderer2.prototype.selectRootElement = function (selectorOrNode, debugInfo) { - var /** @type {?} */ el; - if (typeof selectorOrNode === 'string') { - el = _angular_platformBrowser.ɵgetDOM().querySelector(this.document, selectorOrNode); - if (!el) { - throw new Error("The selector \"" + selectorOrNode + "\" did not match any elements"); - } - } - else { - el = selectorOrNode; - } - _angular_platformBrowser.ɵgetDOM().clearNodes(el); - return el; + AnimationTransitionNamespace.prototype.elementContainsData = function (element) { + var /** @type {?} */ containsData = false; + if (this._elementListeners.has(element)) + containsData = true; + containsData = + (this._queue.find(function (entry) { return entry.element === element; }) ? true : false) || containsData; + return containsData; }; + return AnimationTransitionNamespace; +}()); +var TransitionAnimationEngine = (function () { /** - * @param {?} node - * @return {?} - */ - DefaultServerRenderer2.prototype.parentNode = function (node) { return _angular_platformBrowser.ɵgetDOM().parentElement(node); }; + * @param {?} driver + * @param {?} _normalizer + */ + function TransitionAnimationEngine(driver, _normalizer) { + this.driver = driver; + this._normalizer = _normalizer; + this.players = []; + this.newHostElements = new Map(); + this.playersByElement = new Map(); + this.playersByQueriedElement = new Map(); + this.statesByElement = new Map(); + this.totalAnimations = 0; + this.totalQueuedPlayers = 0; + this._namespaceLookup = {}; + this._namespaceList = []; + this._flushFns = []; + this._whenQuietFns = []; + this.namespacesByHostElement = new Map(); + this.collectedEnterElements = []; + this.collectedLeaveElements = []; + this.onRemovalComplete = function (element, context) { }; + } /** - * @param {?} node + * @param {?} element + * @param {?} context * @return {?} */ - DefaultServerRenderer2.prototype.nextSibling = function (node) { return _angular_platformBrowser.ɵgetDOM().nextSibling(node); }; + TransitionAnimationEngine.prototype._onRemovalComplete = function (element, context) { this.onRemovalComplete(element, context); }; + Object.defineProperty(TransitionAnimationEngine.prototype, "queuedPlayers", { + /** + * @return {?} + */ + get: function () { + var /** @type {?} */ players = []; + this._namespaceList.forEach(function (ns) { + ns.players.forEach(function (player) { + if (player.queued) { + players.push(player); + } + }); + }); + return players; + }, + enumerable: true, + configurable: true + }); /** - * @param {?} el - * @param {?} name - * @param {?} value - * @param {?=} namespace + * @param {?} namespaceId + * @param {?} hostElement * @return {?} */ - DefaultServerRenderer2.prototype.setAttribute = function (el, name, value, namespace) { - if (namespace) { - _angular_platformBrowser.ɵgetDOM().setAttributeNS(el, _angular_platformBrowser.ɵNAMESPACE_URIS[namespace], namespace + ':' + name, value); + TransitionAnimationEngine.prototype.createNamespace = function (namespaceId, hostElement) { + var /** @type {?} */ ns = new AnimationTransitionNamespace(namespaceId, hostElement, this); + if (hostElement.parentNode) { + this._balanceNamespaceList(ns, hostElement); } else { - _angular_platformBrowser.ɵgetDOM().setAttribute(el, name, value); + // defer this later until flush during when the host element has + // been inserted so that we know exactly where to place it in + // the namespace list + this.newHostElements.set(hostElement, ns); + // given that this host element is apart of the animation code, it + // may or may not be inserted by a parent node that is an of an + // animation renderer type. If this happens then we can still have + // access to this item when we query for :enter nodes. If the parent + // is a renderer then the set data-structure will normalize the entry + this.collectEnterElement(hostElement); } + return this._namespaceLookup[namespaceId] = ns; }; /** - * @param {?} el - * @param {?} name - * @param {?=} namespace + * @param {?} ns + * @param {?} hostElement * @return {?} */ - DefaultServerRenderer2.prototype.removeAttribute = function (el, name, namespace) { - if (namespace) { - _angular_platformBrowser.ɵgetDOM().removeAttributeNS(el, _angular_platformBrowser.ɵNAMESPACE_URIS[namespace], name); + TransitionAnimationEngine.prototype._balanceNamespaceList = function (ns, hostElement) { + var /** @type {?} */ limit = this._namespaceList.length - 1; + if (limit >= 0) { + var /** @type {?} */ found = false; + for (var /** @type {?} */ i = limit; i >= 0; i--) { + var /** @type {?} */ nextNamespace = this._namespaceList[i]; + if (this.driver.containsElement(nextNamespace.hostElement, hostElement)) { + this._namespaceList.splice(i + 1, 0, ns); + found = true; + break; + } + } + if (!found) { + this._namespaceList.splice(0, 0, ns); + } } else { - _angular_platformBrowser.ɵgetDOM().removeAttribute(el, name); + this._namespaceList.push(ns); } + this.namespacesByHostElement.set(hostElement, ns); + return ns; }; /** - * @param {?} el - * @param {?} name + * @param {?} namespaceId + * @param {?} hostElement * @return {?} */ - DefaultServerRenderer2.prototype.addClass = function (el, name) { _angular_platformBrowser.ɵgetDOM().addClass(el, name); }; + TransitionAnimationEngine.prototype.register = function (namespaceId, hostElement) { + var /** @type {?} */ ns = this._namespaceLookup[namespaceId]; + if (!ns) { + ns = this.createNamespace(namespaceId, hostElement); + } + return ns; + }; /** - * @param {?} el + * @param {?} namespaceId * @param {?} name + * @param {?} trigger * @return {?} */ - DefaultServerRenderer2.prototype.removeClass = function (el, name) { _angular_platformBrowser.ɵgetDOM().removeClass(el, name); }; + TransitionAnimationEngine.prototype.registerTrigger = function (namespaceId, name, trigger) { + var /** @type {?} */ ns = this._namespaceLookup[namespaceId]; + if (ns && ns.register(name, trigger)) { + this.totalAnimations++; + } + }; /** - * @param {?} el - * @param {?} style - * @param {?} value - * @param {?} flags + * @param {?} namespaceId + * @param {?} context * @return {?} */ - DefaultServerRenderer2.prototype.setStyle = function (el, style, value, flags) { - _angular_platformBrowser.ɵgetDOM().setStyle(el, style, value); + TransitionAnimationEngine.prototype.destroy = function (namespaceId, context) { + var _this = this; + if (!namespaceId) + return; + var /** @type {?} */ ns = this._fetchNamespace(namespaceId); + this.afterFlush(function () { + _this.namespacesByHostElement.delete(ns.hostElement); + delete _this._namespaceLookup[namespaceId]; + var /** @type {?} */ index = _this._namespaceList.indexOf(ns); + if (index >= 0) { + _this._namespaceList.splice(index, 1); + } + }); + this.afterFlushAnimationsDone(function () { return ns.destroy(context); }); }; /** - * @param {?} el - * @param {?} style - * @param {?} flags + * @param {?} id * @return {?} */ - DefaultServerRenderer2.prototype.removeStyle = function (el, style, flags) { - _angular_platformBrowser.ɵgetDOM().removeStyle(el, style); - }; + TransitionAnimationEngine.prototype._fetchNamespace = function (id) { return this._namespaceLookup[id]; }; /** - * @param {?} tagName - * @param {?} propertyName + * @param {?} namespaceId + * @param {?} element + * @param {?} name + * @param {?} value * @return {?} */ - DefaultServerRenderer2.prototype._isSafeToReflectProperty = function (tagName, propertyName) { - return this.schema.securityContext(tagName, propertyName, true) === - this.schema.securityContext(tagName, propertyName, false); + TransitionAnimationEngine.prototype.trigger = function (namespaceId, element, name, value) { + if (isElementNode(element)) { + this._fetchNamespace(namespaceId).trigger(element, name, value); + return true; + } + return false; }; /** - * @param {?} el - * @param {?} name - * @param {?} value + * @param {?} namespaceId + * @param {?} element + * @param {?} parent + * @param {?} insertBefore * @return {?} */ - DefaultServerRenderer2.prototype.setProperty = function (el, name, value) { - checkNoSyntheticProp(name, 'property'); - _angular_platformBrowser.ɵgetDOM().setProperty(el, name, value); - // Mirror property values for known HTML element properties in the attributes. - var /** @type {?} */ tagName = ((el.tagName)).toLowerCase(); - if (value != null && (typeof value === 'number' || typeof value == 'string') && - this.schema.hasElement(tagName, EMPTY_ARRAY) && - this.schema.hasProperty(tagName, name, EMPTY_ARRAY) && - this._isSafeToReflectProperty(tagName, name)) { - this.setAttribute(el, name, value.toString()); + TransitionAnimationEngine.prototype.insertNode = function (namespaceId, element, parent, insertBefore) { + if (!isElementNode(element)) + return; + // special case for when an element is removed and reinserted (move operation) + // when this occurs we do not want to use the element for deletion later + var /** @type {?} */ details = (element[REMOVAL_FLAG]); + if (details && details.setForRemoval) { + details.setForRemoval = false; + } + // in the event that the namespaceId is blank then the caller + // code does not contain any animation code in it, but it is + // just being called so that the node is marked as being inserted + if (namespaceId) { + this._fetchNamespace(namespaceId).insertNode(element, parent); + } + // only *directives and host elements are inserted before + if (insertBefore) { + this.collectEnterElement(element); } }; /** - * @param {?} node - * @param {?} value + * @param {?} element * @return {?} */ - DefaultServerRenderer2.prototype.setValue = function (node, value) { _angular_platformBrowser.ɵgetDOM().setText(node, value); }; + TransitionAnimationEngine.prototype.collectEnterElement = function (element) { this.collectedEnterElements.push(element); }; /** - * @param {?} target - * @param {?} eventName - * @param {?} callback + * @param {?} namespaceId + * @param {?} element + * @param {?} context + * @param {?=} doNotRecurse * @return {?} */ - DefaultServerRenderer2.prototype.listen = function (target, eventName, callback) { - var _this = this; - // Note: We are not using the EventsPlugin here as this is not needed - // to run our tests. - checkNoSyntheticProp(eventName, 'listener'); - var /** @type {?} */ el = typeof target === 'string' ? _angular_platformBrowser.ɵgetDOM().getGlobalEventTarget(this.document, target) : target; - var /** @type {?} */ outsideHandler = function (event) { return _this.ngZone.runGuarded(function () { return callback(event); }); }; - return this.ngZone.runOutsideAngular(function () { return _angular_platformBrowser.ɵgetDOM().onAndCancel(el, eventName, outsideHandler); }); + TransitionAnimationEngine.prototype.removeNode = function (namespaceId, element, context, doNotRecurse) { + if (!isElementNode(element)) { + this._onRemovalComplete(element, context); + return; + } + var /** @type {?} */ ns = namespaceId ? this._fetchNamespace(namespaceId) : null; + if (ns) { + ns.removeNode(element, context, doNotRecurse); + } + else { + this.markElementAsRemoved(namespaceId, element, false, context); + } }; - return DefaultServerRenderer2; -}()); -var AT_CHARCODE = '@'.charCodeAt(0); -/** - * @param {?} name - * @param {?} nameKind - * @return {?} - */ -function checkNoSyntheticProp(name, nameKind) { - if (name.charCodeAt(0) === AT_CHARCODE) { - throw new Error("Found the synthetic " + nameKind + " " + name + ". Please include either \"BrowserAnimationsModule\" or \"NoopAnimationsModule\" in your application."); - } -} -var EmulatedEncapsulationServerRenderer2 = (function (_super) { - __extends(EmulatedEncapsulationServerRenderer2, _super); /** - * @param {?} document - * @param {?} ngZone - * @param {?} sharedStylesHost - * @param {?} schema - * @param {?} component + * @param {?} namespaceId + * @param {?} element + * @param {?=} hasAnimation + * @param {?=} context + * @return {?} */ - function EmulatedEncapsulationServerRenderer2(document, ngZone, sharedStylesHost, schema, component) { - var _this = _super.call(this, document, ngZone, schema) || this; - _this.component = component; - var styles = _angular_platformBrowser.ɵflattenStyles(component.id, component.styles, []); - sharedStylesHost.addStyles(styles); - _this.contentAttr = _angular_platformBrowser.ɵshimContentAttribute(component.id); - _this.hostAttr = _angular_platformBrowser.ɵshimHostAttribute(component.id); - return _this; - } + TransitionAnimationEngine.prototype.markElementAsRemoved = function (namespaceId, element, hasAnimation, context) { + this.collectedLeaveElements.push(element); + element[REMOVAL_FLAG] = { + namespaceId: namespaceId, + setForRemoval: context, hasAnimation: hasAnimation, + removedBeforeQueried: false + }; + }; /** + * @param {?} namespaceId * @param {?} element + * @param {?} name + * @param {?} phase + * @param {?} callback * @return {?} */ - EmulatedEncapsulationServerRenderer2.prototype.applyToHost = function (element) { _super.prototype.setAttribute.call(this, element, this.hostAttr, ''); }; + TransitionAnimationEngine.prototype.listen = function (namespaceId, element, name, phase, callback) { + if (isElementNode(element)) { + return this._fetchNamespace(namespaceId).listen(element, name, phase, callback); + } + return function () { }; + }; /** - * @param {?} parent - * @param {?} name + * @param {?} entry + * @param {?} subTimelines * @return {?} */ - EmulatedEncapsulationServerRenderer2.prototype.createElement = function (parent, name) { - var /** @type {?} */ el = _super.prototype.createElement.call(this, parent, name); - _super.prototype.setAttribute.call(this, el, this.contentAttr, ''); - return el; + TransitionAnimationEngine.prototype._buildInstruction = function (entry, subTimelines) { + return entry.transition.build(this.driver, entry.element, entry.fromState.value, entry.toState.value, entry.toState.options, subTimelines); }; - return EmulatedEncapsulationServerRenderer2; -}(DefaultServerRenderer2)); -/** - * @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 ServerStylesHost = (function (_super) { - __extends(ServerStylesHost, _super); /** - * @param {?} doc - * @param {?} transitionId + * @param {?} containerElement + * @return {?} */ - function ServerStylesHost(doc, transitionId) { - var _this = _super.call(this) || this; - _this.doc = doc; - _this.transitionId = transitionId; - _this.head = null; - _this.head = _angular_platformBrowser.ɵgetDOM().getElementsByTagName(doc, 'head')[0]; - return _this; - } + TransitionAnimationEngine.prototype.destroyInnerAnimations = function (containerElement) { + var _this = this; + var /** @type {?} */ elements = this.driver.query(containerElement, NG_TRIGGER_SELECTOR, true); + elements.forEach(function (element) { + var /** @type {?} */ players = _this.playersByElement.get(element); + if (players) { + players.forEach(function (player) { + // special case for when an element is set for destruction, but hasn't started. + // in this situation we want to delay the destruction until the flush occurs + // so that any event listeners attached to the player are triggered. + if (player.queued) { + player.markedForDestroy = true; + } + else { + player.destroy(); + } + }); + } + var /** @type {?} */ stateMap = _this.statesByElement.get(element); + if (stateMap) { + Object.keys(stateMap).forEach(function (triggerName) { return stateMap[triggerName] = DELETED_STATE_VALUE; }); + } + }); + if (this.playersByQueriedElement.size == 0) + return; + elements = this.driver.query(containerElement, NG_ANIMATING_SELECTOR, true); + if (elements.length) { + elements.forEach(function (element) { + var /** @type {?} */ players = _this.playersByQueriedElement.get(element); + if (players) { + players.forEach(function (player) { return player.finish(); }); + } + }); + } + }; /** - * @param {?} style * @return {?} */ - ServerStylesHost.prototype._addStyle = function (style) { - var /** @type {?} */ adapter = (_angular_platformBrowser.ɵgetDOM()); - var /** @type {?} */ el = adapter.createElement('style'); - adapter.setText(el, style); - if (!!this.transitionId) { - adapter.setAttribute(el, 'ng-transition', this.transitionId); + TransitionAnimationEngine.prototype.whenRenderingDone = function () { + var _this = this; + return new Promise(function (resolve) { + if (_this.players.length) { + return optimizeGroupPlayer(_this.players).onDone(function () { return resolve(); }); + } + else { + resolve(); + } + }); + }; + /** + * @param {?} element + * @return {?} + */ + TransitionAnimationEngine.prototype.processLeaveNode = function (element) { + var /** @type {?} */ details = (element[REMOVAL_FLAG]); + if (details && details.setForRemoval) { + // this will prevent it from removing it twice + element[REMOVAL_FLAG] = NULL_REMOVAL_STATE; + if (details.namespaceId) { + this.destroyInnerAnimations(element); + var /** @type {?} */ ns = this._fetchNamespace(details.namespaceId); + if (ns) { + ns.clearElementCache(element); + } + } + this._onRemovalComplete(element, details.setForRemoval); } - adapter.appendChild(this.head, el); }; /** - * @param {?} additions + * @param {?=} microtaskId * @return {?} */ - ServerStylesHost.prototype.onStylesAdded = function (additions) { + TransitionAnimationEngine.prototype.flush = function (microtaskId) { var _this = this; - additions.forEach(function (style) { return _this._addStyle(style); }); + if (microtaskId === void 0) { microtaskId = -1; } + var /** @type {?} */ players = []; + if (this.newHostElements.size) { + this.newHostElements.forEach(function (ns, element) { return _this._balanceNamespaceList(ns, element); }); + this.newHostElements.clear(); + } + if (this._namespaceList.length && + (this.totalQueuedPlayers || this.collectedLeaveElements.length)) { + players = this._flushAnimations(microtaskId); + } + else { + for (var /** @type {?} */ i = 0; i < this.collectedLeaveElements.length; i++) { + var /** @type {?} */ element = this.collectedLeaveElements[i]; + this.processLeaveNode(element); + } + } + this.totalQueuedPlayers = 0; + this.collectedEnterElements.length = 0; + this.collectedLeaveElements.length = 0; + this._flushFns.forEach(function (fn) { return fn(); }); + this._flushFns = []; + if (this._whenQuietFns.length) { + // we move these over to a variable so that + // if any new callbacks are registered in another + // flush they do not populate the existing set + var /** @type {?} */ quietFns_1 = this._whenQuietFns; + this._whenQuietFns = []; + if (players.length) { + optimizeGroupPlayer(players).onDone(function () { quietFns_1.forEach(function (fn) { return fn(); }); }); + } + else { + quietFns_1.forEach(function (fn) { return fn(); }); + } + } }; - return ServerStylesHost; -}(_angular_platformBrowser.ɵSharedStylesHost)); -ServerStylesHost.decorators = [ - { type: _angular_core.Injectable }, -]; -/** - * @nocollapse - */ -ServerStylesHost.ctorParameters = function () { return [ - { type: undefined, decorators: [{ type: _angular_core.Inject, args: [_angular_platformBrowser.DOCUMENT,] },] }, - { type: undefined, decorators: [{ type: _angular_core.Optional }, { type: _angular_core.Inject, args: [_angular_platformBrowser.ɵTRANSITION_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 - */ -var INTERNAL_SERVER_PLATFORM_PROVIDERS = [ - { provide: _angular_platformBrowser.DOCUMENT, useFactory: _document, deps: [_angular_core.Injector] }, - { provide: _angular_core.PLATFORM_ID, useValue: _angular_common.ɵPLATFORM_SERVER_ID }, - { provide: _angular_core.PLATFORM_INITIALIZER, useFactory: initParse5Adapter, multi: true, deps: [_angular_core.Injector] }, - { provide: _angular_common.PlatformLocation, useClass: ServerPlatformLocation }, PlatformState, - // Add special provider that allows multiple instances of platformServer* to be created. - { provide: _angular_core.ɵALLOW_MULTIPLE_PLATFORMS, useValue: true } -]; -/** - * @param {?} injector - * @return {?} - */ -function initParse5Adapter(injector) { - return function () { Parse5DomAdapter.makeCurrent(); }; -} -/** - * @param {?} renderer - * @param {?} engine - * @param {?} zone - * @return {?} - */ -function instantiateServerRendererFactory(renderer, engine, zone) { - return new _angular_platformBrowser_animations.ɵAnimationRendererFactory(renderer, engine, zone); -} -var SERVER_RENDER_PROVIDERS = [ - ServerRendererFactory2, - { - provide: _angular_core.RendererFactory2, - useFactory: instantiateServerRendererFactory, - deps: [ServerRendererFactory2, _angular_animations_browser.ɵAnimationEngine, _angular_core.NgZone] - }, - ServerStylesHost, - { provide: _angular_platformBrowser.ɵSharedStylesHost, useExisting: ServerStylesHost }, -]; -/** - * The ng module for the server. - * - * \@experimental - */ -var ServerModule = (function () { - function ServerModule() { - } - return ServerModule; -}()); -ServerModule.decorators = [ - { type: _angular_core.NgModule, args: [{ - exports: [_angular_platformBrowser.BrowserModule], - imports: [_angular_http.HttpModule, _angular_platformBrowser_animations.NoopAnimationsModule], - providers: [ - SERVER_RENDER_PROVIDERS, - SERVER_HTTP_PROVIDERS, - { provide: _angular_core.Testability, useValue: null }, - ], - },] }, -]; -/** - * @nocollapse - */ -ServerModule.ctorParameters = function () { return []; }; -/** - * @param {?} injector - * @return {?} - */ -function _document(injector) { - var /** @type {?} */ config = injector.get(INITIAL_CONFIG, null); - if (config && config.document) { - return parseDocument(config.document); - } - else { - return _angular_platformBrowser.ɵgetDOM().createHtmlDocument(); - } -} -/** - * \@experimental - */ -var platformServer = _angular_core.createPlatformFactory(_angular_core.platformCore, 'server', INTERNAL_SERVER_PLATFORM_PROVIDERS); -/** - * The server platform that supports the runtime compiler. - * - * \@experimental - */ -var platformDynamicServer = _angular_core.createPlatformFactory(_angular_compiler.platformCoreDynamic, 'serverDynamic', INTERNAL_SERVER_PLATFORM_PROVIDERS); -/** - * @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 parse5$2 = __webpack_require__(35); -/** - * @param {?} platformFactory - * @param {?} options - * @return {?} - */ -function _getPlatform(platformFactory, options) { - var /** @type {?} */ extraProviders = options.extraProviders ? options.extraProviders : []; - return platformFactory([ - { provide: INITIAL_CONFIG, useValue: { document: options.document, url: options.url } }, - extraProviders - ]); -} -/** - * @template T - * @param {?} platform - * @param {?} moduleRefPromise - * @return {?} - */ -function _render(platform, moduleRefPromise) { - return moduleRefPromise.then(function (moduleRef) { - var /** @type {?} */ transitionId = moduleRef.injector.get(_angular_platformBrowser.ɵTRANSITION_ID, null); - if (!transitionId) { - throw new Error("renderModule[Factory]() requires the use of BrowserModule.withServerTransition() to ensure\nthe server-rendered app can be properly bootstrapped into a client app."); + /** + * @param {?} microtaskId + * @return {?} + */ + TransitionAnimationEngine.prototype._flushAnimations = function (microtaskId) { + var _this = this; + var /** @type {?} */ subTimelines = new ElementInstructionMap(); + var /** @type {?} */ skippedPlayers = []; + var /** @type {?} */ skippedPlayersMap = new Map(); + var /** @type {?} */ queuedInstructions = []; + var /** @type {?} */ queriedElements = new Map(); + var /** @type {?} */ allPreStyleElements = new Map(); + var /** @type {?} */ allPostStyleElements = new Map(); + var /** @type {?} */ bodyNode = getBodyNode(); + var /** @type {?} */ allEnterNodes = this.collectedEnterElements.length ? + this.collectedEnterElements.filter(createIsRootFilterFn(this.collectedEnterElements)) : + []; + // this must occur before the instructions are built below such that + // the :enter queries match the elements (since the timeline queries + // are fired during instruction building). + for (var /** @type {?} */ i = 0; i < allEnterNodes.length; i++) { + addClass(allEnterNodes[i], ENTER_CLASSNAME); } - var /** @type {?} */ applicationRef = moduleRef.injector.get(_angular_core.ApplicationRef); - return rxjs_operator_toPromise.toPromise - .call(rxjs_operator_first.first.call(rxjs_operator_filter.filter.call(applicationRef.isStable, function (isStable) { return isStable; }))) - .then(function () { - var /** @type {?} */ output = platform.injector.get(PlatformState).renderToString(); - platform.destroy(); - return output; + var /** @type {?} */ allLeaveNodes = []; + var /** @type {?} */ leaveNodesWithoutAnimations = []; + for (var /** @type {?} */ i = 0; i < this.collectedLeaveElements.length; i++) { + var /** @type {?} */ element = this.collectedLeaveElements[i]; + var /** @type {?} */ details = (element[REMOVAL_FLAG]); + if (details && details.setForRemoval) { + addClass(element, LEAVE_CLASSNAME); + allLeaveNodes.push(element); + if (!details.hasAnimation) { + leaveNodesWithoutAnimations.push(element); + } + } + } + for (var /** @type {?} */ i = this._namespaceList.length - 1; i >= 0; i--) { + var /** @type {?} */ ns = this._namespaceList[i]; + ns.drainQueuedTransitions(microtaskId).forEach(function (entry) { + var /** @type {?} */ player = entry.player; + var /** @type {?} */ element = entry.element; + if (!bodyNode || !_this.driver.containsElement(bodyNode, element)) { + player.destroy(); + return; + } + var /** @type {?} */ instruction = _this._buildInstruction(entry, subTimelines); + if (!instruction) + return; + // if a unmatched transition is queued to go then it SHOULD NOT render + // an animation and cancel the previously running animations. + if (entry.isFallbackTransition) { + player.onStart(function () { return eraseStyles(element, instruction.fromStyles); }); + player.onDestroy(function () { return setStyles(element, instruction.toStyles); }); + skippedPlayers.push(player); + return; + } + // this means that if a parent animation uses this animation as a sub trigger + // then it will instruct the timeline builder to not add a player delay, but + // instead stretch the first keyframe gap up until the animation starts. The + // reason this is important is to prevent extra initialization styles from being + // required by the user in the animation. + instruction.timelines.forEach(function (tl) { return tl.stretchStartingKeyframe = true; }); + subTimelines.append(element, instruction.timelines); + var /** @type {?} */ tuple = { instruction: instruction, player: player, element: element }; + queuedInstructions.push(tuple); + instruction.queriedElements.forEach(function (element) { return getOrSetAsInMap(queriedElements, element, []).push(player); }); + instruction.preStyleProps.forEach(function (stringMap, element) { + var /** @type {?} */ props = Object.keys(stringMap); + if (props.length) { + var /** @type {?} */ setVal_1 = ((allPreStyleElements.get(element))); + if (!setVal_1) { + allPreStyleElements.set(element, setVal_1 = new Set()); + } + props.forEach(function (prop) { return setVal_1.add(prop); }); + } + }); + instruction.postStyleProps.forEach(function (stringMap, element) { + var /** @type {?} */ props = Object.keys(stringMap); + var /** @type {?} */ setVal = ((allPostStyleElements.get(element))); + if (!setVal) { + allPostStyleElements.set(element, setVal = new Set()); + } + props.forEach(function (prop) { return setVal.add(prop); }); + }); + }); + } + // these can only be detected here since we have a map of all the elements + // that have animations attached to them... + var /** @type {?} */ enterNodesWithoutAnimations = []; + for (var /** @type {?} */ i = 0; i < allEnterNodes.length; i++) { + var /** @type {?} */ element = allEnterNodes[i]; + if (!subTimelines.has(element)) { + enterNodesWithoutAnimations.push(element); + } + } + var /** @type {?} */ allPreviousPlayersMap = new Map(); + var /** @type {?} */ sortedParentElements = []; + queuedInstructions.forEach(function (entry) { + var /** @type {?} */ element = entry.element; + if (subTimelines.has(element)) { + sortedParentElements.unshift(element); + _this._beforeAnimationBuild(entry.player.namespaceId, entry.instruction, allPreviousPlayersMap); + } }); - }); -} -/** - * Renders a Module to string. - * - * Do not use this in a production server environment. Use pre-compiled {\@link NgModuleFactory} with - * {link renderModuleFactory} instead. - * - * \@experimental - * @template T - * @param {?} module - * @param {?} options - * @return {?} - */ -function renderModule(module, options) { - var /** @type {?} */ platform = _getPlatform(platformDynamicServer, options); - return _render(platform, platform.bootstrapModule(module)); -} -/** - * Renders a {\@link NgModuleFactory} to string. - * - * \@experimental - * @template T - * @param {?} moduleFactory - * @param {?} options - * @return {?} - */ -function renderModuleFactory(moduleFactory, options) { - var /** @type {?} */ platform = _getPlatform(platformServer, options); - return _render(platform, platform.bootstrapModuleFactory(moduleFactory)); -} -/** - * @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 - */ -/** - * @module - * @description - * Entry point for all public APIs of the common package. - */ -/** - * \@stable - */ -var VERSION = new _angular_core.Version('4.2.5'); - -exports.PlatformState = PlatformState; -exports.ServerModule = ServerModule; -exports.platformDynamicServer = platformDynamicServer; -exports.platformServer = platformServer; -exports.INITIAL_CONFIG = INITIAL_CONFIG; -exports.renderModule = renderModule; -exports.renderModuleFactory = renderModuleFactory; -exports.VERSION = VERSION; -exports.ɵINTERNAL_SERVER_PLATFORM_PROVIDERS = INTERNAL_SERVER_PLATFORM_PROVIDERS; -exports.ɵSERVER_RENDER_PROVIDERS = SERVER_RENDER_PROVIDERS; -exports.ɵServerRendererFactory2 = ServerRendererFactory2; -exports.ɵf = SERVER_HTTP_PROVIDERS; -exports.ɵc = ServerXhr; -exports.ɵd = ServerXsrfStrategy; -exports.ɵe = httpFactory; -exports.ɵa = instantiateServerRendererFactory; -exports.ɵb = ServerStylesHost; - -Object.defineProperty(exports, '__esModule', { value: true }); - -}))); -//# sourceMappingURL=platform-server.umd.js.map - - -/***/ }), -/* 45 */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - -var Observable_1 = __webpack_require__(0); -var first_1 = __webpack_require__(86); -Observable_1.Observable.prototype.first = first_1.first; -//# sourceMappingURL=first.js.map - -/***/ }), -/* 46 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @license Angular v4.2.5 - * (c) 2010-2017 Google, Inc. https://angular.io/ - * License: MIT - */ -(function (global, factory) { - true ? factory(exports, __webpack_require__(82)) : - typeof define === 'function' && define.amd ? define(['exports', '@angular/animations'], factory) : - (factory((global.ng = global.ng || {}, global.ng.animations = global.ng.animations || {}, global.ng.animations.browser = global.ng.animations.browser || {}),global.ng.animations)); -}(this, (function (exports,_angular_animations) { 'use strict'; - -/*! ***************************************************************************** -Copyright (c) Microsoft Corporation. All rights reserved. -Licensed under the Apache License, Version 2.0 (the "License"); you may not use -this file except in compliance with the License. You may obtain a copy of the -License at http://www.apache.org/licenses/LICENSE-2.0 - -THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED -WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, -MERCHANTABLITY OR NON-INFRINGEMENT. - -See the Apache Version 2.0 License for specific language governing permissions -and limitations under the License. -***************************************************************************** */ -/* global Reflect, Promise */ - -var extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; - -function __extends(d, b) { - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); -} - -/** - * @license Angular v4.2.5 - * (c) 2010-2017 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 - */ -function optimizeGroupPlayer(players) { - switch (players.length) { - case 0: - return new _angular_animations.NoopAnimationPlayer(); - case 1: - return players[0]; - default: - return new _angular_animations.ɵAnimationGroupPlayer(players); - } -} -function normalizeKeyframes(driver, normalizer, element, keyframes, preStyles, postStyles) { - if (preStyles === void 0) { preStyles = {}; } - if (postStyles === void 0) { postStyles = {}; } - var errors = []; - var normalizedKeyframes = []; - var previousOffset = -1; - var previousKeyframe = null; - keyframes.forEach(function (kf) { - var offset = kf['offset']; - var isSameOffset = offset == previousOffset; - var normalizedKeyframe = (isSameOffset && previousKeyframe) || {}; - Object.keys(kf).forEach(function (prop) { - var normalizedProp = prop; - var normalizedValue = kf[prop]; - if (normalizedValue == _angular_animations.ɵPRE_STYLE) { - normalizedValue = preStyles[prop]; + skippedPlayers.forEach(function (player) { + var /** @type {?} */ element = player.element; + var /** @type {?} */ previousPlayers = _this._getPreviousPlayers(element, false, player.namespaceId, player.triggerName, null); + previousPlayers.forEach(function (prevPlayer) { getOrSetAsInMap(allPreviousPlayersMap, element, []).push(prevPlayer); }); + }); + allPreviousPlayersMap.forEach(function (players) { return players.forEach(function (player) { return player.destroy(); }); }); + // PRE STAGE: fill the ! styles + var /** @type {?} */ preStylesMap = allPreStyleElements.size ? + cloakAndComputeStyles(this.driver, enterNodesWithoutAnimations, allPreStyleElements, _angular_animations.ɵPRE_STYLE) : + new Map(); + // POST STAGE: fill the * styles + var /** @type {?} */ postStylesMap = cloakAndComputeStyles(this.driver, leaveNodesWithoutAnimations, allPostStyleElements, _angular_animations.AUTO_STYLE); + var /** @type {?} */ rootPlayers = []; + var /** @type {?} */ subPlayers = []; + queuedInstructions.forEach(function (entry) { + var element = entry.element, player = entry.player, instruction = entry.instruction; + // this means that it was never consumed by a parent animation which + // means that it is independent and therefore should be set for animation + if (subTimelines.has(element)) { + var /** @type {?} */ innerPlayer = _this._buildAnimation(player.namespaceId, instruction, allPreviousPlayersMap, skippedPlayersMap, preStylesMap, postStylesMap); + player.setRealPlayer(innerPlayer); + var /** @type {?} */ parentHasPriority = null; + for (var /** @type {?} */ i = 0; i < sortedParentElements.length; i++) { + var /** @type {?} */ parent = sortedParentElements[i]; + if (parent === element) + break; + if (_this.driver.containsElement(parent, element)) { + parentHasPriority = parent; + break; + } + } + if (parentHasPriority) { + var /** @type {?} */ parentPlayers = _this.playersByElement.get(parentHasPriority); + if (parentPlayers && parentPlayers.length) { + player.parentPlayer = optimizeGroupPlayer(parentPlayers); + } + skippedPlayers.push(player); + } + else { + rootPlayers.push(player); + } } - else if (normalizedValue == _angular_animations.AUTO_STYLE) { - normalizedValue = postStyles[prop]; + else { + eraseStyles(element, instruction.fromStyles); + player.onDestroy(function () { return setStyles(element, instruction.toStyles); }); + subPlayers.push(player); } - else if (prop != 'offset') { - normalizedProp = normalizer.normalizePropertyName(prop, errors); - normalizedValue = normalizer.normalizeStyleValue(prop, normalizedProp, kf[prop], errors); + }); + subPlayers.forEach(function (player) { + var /** @type {?} */ playersForElement = skippedPlayersMap.get(player.element); + if (playersForElement && playersForElement.length) { + var /** @type {?} */ innerPlayer = optimizeGroupPlayer(playersForElement); + player.setRealPlayer(innerPlayer); } - normalizedKeyframe[normalizedProp] = normalizedValue; }); - if (!isSameOffset) { - normalizedKeyframes.push(normalizedKeyframe); - } - previousKeyframe = normalizedKeyframe; - previousOffset = offset; - }); - if (errors.length) { - var LINE_START = '\n - '; - throw new Error("Unable to animate due to the following errors:" + LINE_START + errors.join(LINE_START)); - } - return normalizedKeyframes; -} -function listenOnPlayer(player, eventName, event, callback) { - switch (eventName) { - case 'start': - player.onStart(function () { return callback(event && copyAnimationEvent(event, 'start', player.totalTime)); }); - break; - case 'done': - player.onDone(function () { return callback(event && copyAnimationEvent(event, 'done', player.totalTime)); }); - break; - case 'destroy': - player.onDestroy(function () { return callback(event && copyAnimationEvent(event, 'destroy', player.totalTime)); }); - break; - } -} -function copyAnimationEvent(e, phaseName, totalTime) { - var event = makeAnimationEvent(e.element, e.triggerName, e.fromState, e.toState, phaseName || e.phaseName, totalTime == undefined ? e.totalTime : totalTime); - var data = e['_data']; - if (data != null) { - event['_data'] = data; - } - return event; -} -function makeAnimationEvent(element, triggerName, fromState, toState, phaseName, totalTime) { - if (phaseName === void 0) { phaseName = ''; } - if (totalTime === void 0) { totalTime = 0; } - return { element: element, triggerName: triggerName, fromState: fromState, toState: toState, phaseName: phaseName, totalTime: totalTime }; -} -function getOrSetAsInMap(map, key, defaultValue) { - var value; - if (map instanceof Map) { - value = map.get(key); - if (!value) { - map.set(key, value = defaultValue); - } - } - else { - value = map[key]; - if (!value) { - value = map[key] = defaultValue; - } - } - return value; -} -function parseTimelineCommand(command) { - var separatorPos = command.indexOf(':'); - var id = command.substring(1, separatorPos); - var action = command.substr(separatorPos + 1); - return [id, action]; -} -var _contains = function (elm1, elm2) { return false; }; -var _matches = function (element, selector) { return false; }; -var _query = function (element, selector, multi) { - return []; -}; -if (typeof Element != 'undefined') { - // this is well supported in all browsers - _contains = function (elm1, elm2) { return elm1.contains(elm2); }; - if (Element.prototype.matches) { - _matches = function (element, selector) { return element.matches(selector); }; - } - else { - var proto = Element.prototype; - var fn_1 = proto.matchesSelector || proto.mozMatchesSelector || proto.msMatchesSelector || - proto.oMatchesSelector || proto.webkitMatchesSelector; - if (fn_1) { - _matches = function (element, selector) { return fn_1.apply(element, [selector]); }; - } - } - _query = function (element, selector, multi) { - var results = []; - if (multi) { - results.push.apply(results, element.querySelectorAll(selector)); - } - else { - var elm = element.querySelector(selector); - if (elm) { - results.push(elm); + // the reason why we don't actually play the animation is + // because all that a skipped player is designed to do is to + // fire the start/done transition callback events + skippedPlayers.forEach(function (player) { + if (player.parentPlayer) { + player.parentPlayer.onDestroy(function () { return player.destroy(); }); + } + else { + player.destroy(); + } + }); + // run through all of the queued removals and see if they + // were picked up by a query. If not then perform the removal + // operation right away unless a parent animation is ongoing. + for (var /** @type {?} */ i = 0; i < allLeaveNodes.length; i++) { + var /** @type {?} */ element = allLeaveNodes[i]; + var /** @type {?} */ details = (element[REMOVAL_FLAG]); + // this means the element has a removal animation that is being + // taken care of and therefore the inner elements will hang around + // until that animation is over (or the parent queried animation) + if (details && details.hasAnimation) + continue; + var /** @type {?} */ players = []; + // if this element is queried or if it contains queried children + // then we want for the element not to be removed from the page + // until the queried animations have finished + if (queriedElements.size) { + var /** @type {?} */ queriedPlayerResults = queriedElements.get(element); + if (queriedPlayerResults && queriedPlayerResults.length) { + players.push.apply(players, queriedPlayerResults); + } + var /** @type {?} */ queriedInnerElements = this.driver.query(element, NG_ANIMATING_SELECTOR, true); + for (var /** @type {?} */ j = 0; j < queriedInnerElements.length; j++) { + var /** @type {?} */ queriedPlayers = queriedElements.get(queriedInnerElements[j]); + if (queriedPlayers && queriedPlayers.length) { + players.push.apply(players, queriedPlayers); + } + } + } + if (players.length) { + removeNodesAfterAnimationDone(this, element, players); + } + else { + this.processLeaveNode(element); } } - return results; + rootPlayers.forEach(function (player) { + _this.players.push(player); + player.onDone(function () { + player.destroy(); + var /** @type {?} */ index = _this.players.indexOf(player); + _this.players.splice(index, 1); + }); + player.play(); + }); + allEnterNodes.forEach(function (element) { return removeClass(element, ENTER_CLASSNAME); }); + return rootPlayers; }; -} -var matchesElement = _matches; -var containsElement = _contains; -var invokeQuery = _query; -/** - * @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 - */ -/** - * @experimental - */ -var NoopAnimationDriver = (function () { - function NoopAnimationDriver() { - } - NoopAnimationDriver.prototype.matchesElement = function (element, selector) { - return matchesElement(element, selector); + /** + * @param {?} namespaceId + * @param {?} element + * @return {?} + */ + TransitionAnimationEngine.prototype.elementContainsData = function (namespaceId, element) { + var /** @type {?} */ containsData = false; + var /** @type {?} */ details = (element[REMOVAL_FLAG]); + if (details && details.setForRemoval) + containsData = true; + if (this.playersByElement.has(element)) + containsData = true; + if (this.playersByQueriedElement.has(element)) + containsData = true; + if (this.statesByElement.has(element)) + containsData = true; + return this._fetchNamespace(namespaceId).elementContainsData(element) || containsData; }; - NoopAnimationDriver.prototype.containsElement = function (elm1, elm2) { return containsElement(elm1, elm2); }; - NoopAnimationDriver.prototype.query = function (element, selector, multi) { - return invokeQuery(element, selector, multi); + /** + * @param {?} callback + * @return {?} + */ + TransitionAnimationEngine.prototype.afterFlush = function (callback) { this._flushFns.push(callback); }; + /** + * @param {?} callback + * @return {?} + */ + TransitionAnimationEngine.prototype.afterFlushAnimationsDone = function (callback) { this._whenQuietFns.push(callback); }; + /** + * @param {?} element + * @param {?} isQueriedElement + * @param {?=} namespaceId + * @param {?=} triggerName + * @param {?=} toStateValue + * @return {?} + */ + TransitionAnimationEngine.prototype._getPreviousPlayers = function (element, isQueriedElement, namespaceId, triggerName, toStateValue) { + var /** @type {?} */ players = []; + if (isQueriedElement) { + var /** @type {?} */ queriedElementPlayers = this.playersByQueriedElement.get(element); + if (queriedElementPlayers) { + players = queriedElementPlayers; + } + } + else { + var /** @type {?} */ elementPlayers = this.playersByElement.get(element); + if (elementPlayers) { + var /** @type {?} */ isRemovalAnimation_1 = !toStateValue || toStateValue == VOID_VALUE; + elementPlayers.forEach(function (player) { + if (player.queued) + return; + if (!isRemovalAnimation_1 && player.triggerName != triggerName) + return; + players.push(player); + }); + } + } + if (namespaceId || triggerName) { + players = players.filter(function (player) { + if (namespaceId && namespaceId != player.namespaceId) + return false; + if (triggerName && triggerName != player.triggerName) + return false; + return true; + }); + } + return players; }; - NoopAnimationDriver.prototype.computeStyle = function (element, prop, defaultValue) { - return defaultValue || ''; + /** + * @param {?} namespaceId + * @param {?} instruction + * @param {?} allPreviousPlayersMap + * @return {?} + */ + TransitionAnimationEngine.prototype._beforeAnimationBuild = function (namespaceId, instruction, allPreviousPlayersMap) { + var _this = this; + // it's important to do this step before destroying the players + // so that the onDone callback below won't fire before this + eraseStyles(instruction.element, instruction.fromStyles); + var /** @type {?} */ triggerName = instruction.triggerName; + var /** @type {?} */ rootElement = instruction.element; + // when a removal animation occurs, ALL previous players are collected + // and destroyed (even if they are outside of the current namespace) + var /** @type {?} */ targetNameSpaceId = instruction.isRemovalTransition ? undefined : namespaceId; + var /** @type {?} */ targetTriggerName = instruction.isRemovalTransition ? undefined : triggerName; + instruction.timelines.map(function (timelineInstruction) { + var /** @type {?} */ element = timelineInstruction.element; + var /** @type {?} */ isQueriedElement = element !== rootElement; + var /** @type {?} */ players = getOrSetAsInMap(allPreviousPlayersMap, element, []); + var /** @type {?} */ previousPlayers = _this._getPreviousPlayers(element, isQueriedElement, targetNameSpaceId, targetTriggerName, instruction.toState); + previousPlayers.forEach(function (player) { + var /** @type {?} */ realPlayer = (player.getRealPlayer()); + if (realPlayer.beforeDestroy) { + realPlayer.beforeDestroy(); + } + players.push(player); + }); + }); }; - NoopAnimationDriver.prototype.animate = function (element, keyframes, duration, delay, easing, previousPlayers) { - if (previousPlayers === void 0) { previousPlayers = []; } + /** + * @param {?} namespaceId + * @param {?} instruction + * @param {?} allPreviousPlayersMap + * @param {?} skippedPlayersMap + * @param {?} preStylesMap + * @param {?} postStylesMap + * @return {?} + */ + TransitionAnimationEngine.prototype._buildAnimation = function (namespaceId, instruction, allPreviousPlayersMap, skippedPlayersMap, preStylesMap, postStylesMap) { + var _this = this; + var /** @type {?} */ triggerName = instruction.triggerName; + var /** @type {?} */ rootElement = instruction.element; + // we first run this so that the previous animation player + // data can be passed into the successive animation players + var /** @type {?} */ allQueriedPlayers = []; + var /** @type {?} */ allConsumedElements = new Set(); + var /** @type {?} */ allSubElements = new Set(); + var /** @type {?} */ allNewPlayers = instruction.timelines.map(function (timelineInstruction) { + var /** @type {?} */ element = timelineInstruction.element; + // FIXME (matsko): make sure to-be-removed animations are removed properly + var /** @type {?} */ details = element[REMOVAL_FLAG]; + if (details && details.removedBeforeQueried) + return new _angular_animations.NoopAnimationPlayer(); + var /** @type {?} */ isQueriedElement = element !== rootElement; + var /** @type {?} */ previousPlayers = EMPTY_PLAYER_ARRAY; + if (!allConsumedElements.has(element)) { + allConsumedElements.add(element); + var /** @type {?} */ _previousPlayers = allPreviousPlayersMap.get(element); + if (_previousPlayers) { + previousPlayers = _previousPlayers.map(function (p) { return p.getRealPlayer(); }); + } + } + var /** @type {?} */ preStyles = preStylesMap.get(element); + var /** @type {?} */ postStyles = postStylesMap.get(element); + var /** @type {?} */ keyframes = normalizeKeyframes(_this.driver, _this._normalizer, element, timelineInstruction.keyframes, preStyles, postStyles); + var /** @type {?} */ player = _this._buildPlayer(timelineInstruction, keyframes, previousPlayers); + // this means that this particular player belongs to a sub trigger. It is + // important that we match this player up with the corresponding (@trigger.listener) + if (timelineInstruction.subTimeline && skippedPlayersMap) { + allSubElements.add(element); + } + if (isQueriedElement) { + var /** @type {?} */ wrappedPlayer = new TransitionAnimationPlayer(namespaceId, triggerName, element); + wrappedPlayer.setRealPlayer(player); + allQueriedPlayers.push(wrappedPlayer); + } + return player; + }); + allQueriedPlayers.forEach(function (player) { + getOrSetAsInMap(_this.playersByQueriedElement, player.element, []).push(player); + player.onDone(function () { return deleteOrUnsetInMap(_this.playersByQueriedElement, player.element, player); }); + }); + allConsumedElements.forEach(function (element) { return addClass(element, NG_ANIMATING_CLASSNAME); }); + var /** @type {?} */ player = optimizeGroupPlayer(allNewPlayers); + player.onDestroy(function () { + allConsumedElements.forEach(function (element) { return removeClass(element, NG_ANIMATING_CLASSNAME); }); + setStyles(rootElement, instruction.toStyles); + }); + // this basically makes all of the callbacks for sub element animations + // be dependent on the upper players for when they finish + allSubElements.forEach(function (element) { getOrSetAsInMap(skippedPlayersMap, element, []).push(player); }); + return player; + }; + /** + * @param {?} instruction + * @param {?} keyframes + * @param {?} previousPlayers + * @return {?} + */ + TransitionAnimationEngine.prototype._buildPlayer = function (instruction, keyframes, previousPlayers) { + if (keyframes.length > 0) { + return this.driver.animate(instruction.element, keyframes, instruction.duration, instruction.delay, instruction.easing, previousPlayers); + } + // special case for when an empty transition|definition is provided + // ... there is no point in rendering an empty animation return new _angular_animations.NoopAnimationPlayer(); }; - return NoopAnimationDriver; + return TransitionAnimationEngine; }()); -/** - * @experimental - */ -var AnimationDriver = (function () { - function AnimationDriver() { +var TransitionAnimationPlayer = (function () { + /** + * @param {?} namespaceId + * @param {?} triggerName + * @param {?} element + */ + function TransitionAnimationPlayer(namespaceId, triggerName, element) { + this.namespaceId = namespaceId; + this.triggerName = triggerName; + this.element = element; + this._player = new _angular_animations.NoopAnimationPlayer(); + this._containsRealPlayer = false; + this._queuedCallbacks = {}; + this._destroyed = false; + this.markedForDestroy = false; } - return AnimationDriver; + Object.defineProperty(TransitionAnimationPlayer.prototype, "queued", { + /** + * @return {?} + */ + get: function () { return this._containsRealPlayer == false; }, + enumerable: true, + configurable: true + }); + Object.defineProperty(TransitionAnimationPlayer.prototype, "destroyed", { + /** + * @return {?} + */ + get: function () { return this._destroyed; }, + enumerable: true, + configurable: true + }); + /** + * @param {?} player + * @return {?} + */ + TransitionAnimationPlayer.prototype.setRealPlayer = function (player) { + var _this = this; + if (this._containsRealPlayer) + return; + this._player = player; + Object.keys(this._queuedCallbacks).forEach(function (phase) { + _this._queuedCallbacks[phase].forEach(function (callback) { return listenOnPlayer(player, phase, undefined, callback); }); + }); + this._queuedCallbacks = {}; + this._containsRealPlayer = true; + }; + /** + * @return {?} + */ + TransitionAnimationPlayer.prototype.getRealPlayer = function () { return this._player; }; + /** + * @param {?} name + * @param {?} callback + * @return {?} + */ + TransitionAnimationPlayer.prototype._queueEvent = function (name, callback) { + getOrSetAsInMap(this._queuedCallbacks, name, []).push(callback); + }; + /** + * @param {?} fn + * @return {?} + */ + TransitionAnimationPlayer.prototype.onDone = function (fn) { + if (this.queued) { + this._queueEvent('done', fn); + } + this._player.onDone(fn); + }; + /** + * @param {?} fn + * @return {?} + */ + TransitionAnimationPlayer.prototype.onStart = function (fn) { + if (this.queued) { + this._queueEvent('start', fn); + } + this._player.onStart(fn); + }; + /** + * @param {?} fn + * @return {?} + */ + TransitionAnimationPlayer.prototype.onDestroy = function (fn) { + if (this.queued) { + this._queueEvent('destroy', fn); + } + this._player.onDestroy(fn); + }; + /** + * @return {?} + */ + TransitionAnimationPlayer.prototype.init = function () { this._player.init(); }; + /** + * @return {?} + */ + TransitionAnimationPlayer.prototype.hasStarted = function () { return this.queued ? false : this._player.hasStarted(); }; + /** + * @return {?} + */ + TransitionAnimationPlayer.prototype.play = function () { !this.queued && this._player.play(); }; + /** + * @return {?} + */ + TransitionAnimationPlayer.prototype.pause = function () { !this.queued && this._player.pause(); }; + /** + * @return {?} + */ + TransitionAnimationPlayer.prototype.restart = function () { !this.queued && this._player.restart(); }; + /** + * @return {?} + */ + TransitionAnimationPlayer.prototype.finish = function () { this._player.finish(); }; + /** + * @return {?} + */ + TransitionAnimationPlayer.prototype.destroy = function () { + this._destroyed = true; + this._player.destroy(); + }; + /** + * @return {?} + */ + TransitionAnimationPlayer.prototype.reset = function () { !this.queued && this._player.reset(); }; + /** + * @param {?} p + * @return {?} + */ + TransitionAnimationPlayer.prototype.setPosition = function (p) { + if (!this.queued) { + this._player.setPosition(p); + } + }; + /** + * @return {?} + */ + TransitionAnimationPlayer.prototype.getPosition = function () { return this.queued ? 0 : this._player.getPosition(); }; + Object.defineProperty(TransitionAnimationPlayer.prototype, "totalTime", { + /** + * @return {?} + */ + get: function () { return this._player.totalTime; }, + enumerable: true, + configurable: true + }); + return TransitionAnimationPlayer; }()); -AnimationDriver.NOOP = new NoopAnimationDriver(); -/** - * @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 ONE_SECOND = 1000; -var ENTER_CLASSNAME = 'ng-enter'; -var LEAVE_CLASSNAME = 'ng-leave'; -var ENTER_SELECTOR = '.ng-enter'; -var LEAVE_SELECTOR = '.ng-leave'; -var NG_TRIGGER_CLASSNAME = 'ng-trigger'; -var NG_TRIGGER_SELECTOR = '.ng-trigger'; -var NG_ANIMATING_CLASSNAME = 'ng-animating'; -var NG_ANIMATING_SELECTOR = '.ng-animating'; /** + * @param {?} map + * @param {?} key * @param {?} value * @return {?} */ -function resolveTimingValue(value) { - if (typeof value == 'number') - return value; - var /** @type {?} */ matches = ((value)).match(/^(-?[\.\d]+)(m?s)/); - if (!matches || matches.length < 2) - return 0; - return _convertTimeValueToMS(parseFloat(matches[1]), matches[2]); +function deleteOrUnsetInMap(map, key, value) { + var /** @type {?} */ currentValues; + if (map instanceof Map) { + currentValues = map.get(key); + if (currentValues) { + if (currentValues.length) { + var /** @type {?} */ index = currentValues.indexOf(value); + currentValues.splice(index, 1); + } + if (currentValues.length == 0) { + map.delete(key); + } + } + } + else { + currentValues = map[key]; + if (currentValues) { + if (currentValues.length) { + var /** @type {?} */ index = currentValues.indexOf(value); + currentValues.splice(index, 1); + } + if (currentValues.length == 0) { + delete map[key]; + } + } + } + return currentValues; } /** * @param {?} value - * @param {?} unit * @return {?} */ -function _convertTimeValueToMS(value, unit) { - switch (unit) { - case 's': - return value * ONE_SECOND; +function normalizeTriggerValue(value) { + switch (typeof value) { + case 'boolean': + return value ? '1' : '0'; default: - return value; + return value != null ? value.toString() : null; } } /** - * @param {?} timings - * @param {?} errors - * @param {?=} allowNegativeValues + * @param {?} node * @return {?} */ -function resolveTiming(timings, errors, allowNegativeValues) { - return timings.hasOwnProperty('duration') ? (timings) : - parseTimeExpression(/** @type {?} */ (timings), errors, allowNegativeValues); +function isElementNode(node) { + return node && node['nodeType'] === 1; } /** - * @param {?} exp - * @param {?} errors - * @param {?=} allowNegativeValues + * @param {?} eventName * @return {?} */ -function parseTimeExpression(exp, errors, allowNegativeValues) { - var /** @type {?} */ regex = /^(-?[\.\d]+)(m?s)(?:\s+(-?[\.\d]+)(m?s))?(?:\s+([-a-z]+(?:\(.+?\))?))?$/i; - var /** @type {?} */ duration; - var /** @type {?} */ delay = 0; - var /** @type {?} */ easing = ''; - if (typeof exp === 'string') { - var /** @type {?} */ matches = exp.match(regex); - if (matches === null) { - errors.push("The provided timing value \"" + exp + "\" is invalid."); - return { duration: 0, delay: 0, easing: '' }; - } - duration = _convertTimeValueToMS(parseFloat(matches[1]), matches[2]); - var /** @type {?} */ delayMatch = matches[3]; - if (delayMatch != null) { - delay = _convertTimeValueToMS(Math.floor(parseFloat(delayMatch)), matches[4]); - } - var /** @type {?} */ easingVal = matches[5]; - if (easingVal) { - easing = easingVal; - } - } - else { - duration = (exp); - } - if (!allowNegativeValues) { - var /** @type {?} */ containsErrors = false; - var /** @type {?} */ startIndex = errors.length; - if (duration < 0) { - errors.push("Duration values below 0 are not allowed for this animation step."); - containsErrors = true; - } - if (delay < 0) { - errors.push("Delay values below 0 are not allowed for this animation step."); - containsErrors = true; - } - if (containsErrors) { - errors.splice(startIndex, 0, "The provided timing value \"" + exp + "\" is invalid."); - } - } - return { duration: duration, delay: delay, easing: easing }; +function isTriggerEventValid(eventName) { + return eventName == 'start' || eventName == 'done'; } /** - * @param {?} obj - * @param {?=} destination + * @param {?} element + * @param {?=} value * @return {?} */ -function copyObj(obj, destination) { - if (destination === void 0) { destination = {}; } - Object.keys(obj).forEach(function (prop) { destination[prop] = obj[prop]; }); - return destination; +function cloakElement(element, value) { + var /** @type {?} */ oldValue = element.style.display; + element.style.display = value != null ? value : 'none'; + return oldValue; } /** - * @param {?} styles + * @param {?} driver + * @param {?} elements + * @param {?} elementPropsMap + * @param {?} defaultStyle * @return {?} */ -function normalizeStyles(styles) { - var /** @type {?} */ normalizedStyles = {}; - if (Array.isArray(styles)) { - styles.forEach(function (data) { return copyStyles(data, false, normalizedStyles); }); - } - else { - copyStyles(styles, false, normalizedStyles); - } - return normalizedStyles; -} -/** - * @param {?} styles - * @param {?} readPrototype - * @param {?=} destination +function cloakAndComputeStyles(driver, elements, elementPropsMap, defaultStyle) { + var /** @type {?} */ cloakVals = elements.map(function (element) { return cloakElement(element); }); + var /** @type {?} */ valuesMap = new Map(); + elementPropsMap.forEach(function (props, element) { + var /** @type {?} */ styles = {}; + props.forEach(function (prop) { + var /** @type {?} */ value = styles[prop] = driver.computeStyle(element, prop, defaultStyle); + // there is no easy way to detect this because a sub element could be removed + // by a parent animation element being detached. + if (!value || value.length == 0) { + element[REMOVAL_FLAG] = NULL_REMOVED_QUERIED_STATE; + } + }); + valuesMap.set(element, styles); + }); + elements.forEach(function (element, i) { return cloakElement(element, cloakVals[i]); }); + return valuesMap; +} +/** + * @param {?} nodes * @return {?} */ -function copyStyles(styles, readPrototype, destination) { - if (destination === void 0) { destination = {}; } - if (readPrototype) { - // we make use of a for-in loop so that the - // prototypically inherited properties are - // revealed from the backFill map - for (var /** @type {?} */ prop in styles) { - destination[prop] = styles[prop]; +function createIsRootFilterFn(nodes) { + var /** @type {?} */ nodeSet = new Set(nodes); + var /** @type {?} */ knownRootContainer = new Set(); + var /** @type {?} */ isRoot; + isRoot = function (node) { + if (!node) + return true; + if (nodeSet.has(node.parentNode)) + return false; + if (knownRootContainer.has(node.parentNode)) + return true; + if (isRoot(node.parentNode)) { + knownRootContainer.add(node); + return true; } - } - else { - copyObj(styles, destination); - } - return destination; + return false; + }; + return isRoot; } +var CLASSES_CACHE_KEY = '$$classes'; /** * @param {?} element - * @param {?} styles + * @param {?} className * @return {?} */ -function setStyles(element, styles) { - if (element['style']) { - Object.keys(styles).forEach(function (prop) { - var /** @type {?} */ camelProp = dashCaseToCamelCase(prop); - element.style[camelProp] = styles[prop]; - }); +function containsClass(element, className) { + if (element.classList) { + return element.classList.contains(className); + } + else { + var /** @type {?} */ classes = element[CLASSES_CACHE_KEY]; + return classes && classes[className]; } } /** * @param {?} element - * @param {?} styles + * @param {?} className * @return {?} */ -function eraseStyles(element, styles) { - if (element['style']) { - Object.keys(styles).forEach(function (prop) { - var /** @type {?} */ camelProp = dashCaseToCamelCase(prop); - element.style[camelProp] = ''; - }); +function addClass(element, className) { + if (element.classList) { + element.classList.add(className); } -} -/** - * @param {?} steps - * @return {?} - */ -function normalizeAnimationEntry(steps) { - if (Array.isArray(steps)) { - if (steps.length == 1) - return steps[0]; - return _angular_animations.sequence(steps); + else { + var /** @type {?} */ classes = element[CLASSES_CACHE_KEY]; + if (!classes) { + classes = element[CLASSES_CACHE_KEY] = {}; + } + classes[className] = true; } - return (steps); } /** - * @param {?} value - * @param {?} options - * @param {?} errors + * @param {?} element + * @param {?} className * @return {?} */ -function validateStyleParams(value, options, errors) { - var /** @type {?} */ params = options.params || {}; - if (typeof value !== 'string') - return; - var /** @type {?} */ matches = value.toString().match(PARAM_REGEX); - if (matches) { - matches.forEach(function (varName) { - if (!params.hasOwnProperty(varName)) { - errors.push("Unable to resolve the local animation param " + varName + " in the given list of values"); - } - }); +function removeClass(element, className) { + if (element.classList) { + element.classList.remove(className); } -} -var PARAM_REGEX = /\{\{\s*(.+?)\s*\}\}/g; -/** - * @param {?} value - * @param {?} params - * @param {?} errors - * @return {?} - */ -function interpolateParams(value, params, errors) { - var /** @type {?} */ original = value.toString(); - var /** @type {?} */ str = original.replace(PARAM_REGEX, function (_, varName) { - var /** @type {?} */ localVal = params[varName]; - // this means that the value was never overidden by the data passed in by the user - if (!params.hasOwnProperty(varName)) { - errors.push("Please provide a value for the animation param " + varName); - localVal = ''; + else { + var /** @type {?} */ classes = element[CLASSES_CACHE_KEY]; + if (classes) { + delete classes[className]; } - return localVal.toString(); - }); - // we do this to assert that numeric values stay as they are - return str == original ? value : str; -} -/** - * @param {?} iterator - * @return {?} - */ -function iteratorToArray(iterator) { - var /** @type {?} */ arr = []; - var /** @type {?} */ item = iterator.next(); - while (!item.done) { - arr.push(item.value); - item = iterator.next(); } - return arr; } /** - * @param {?} source - * @param {?} destination * @return {?} */ -function mergeAnimationOptions(source, destination) { - if (source.params) { - var /** @type {?} */ p0_1 = source.params; - if (!destination.params) { - destination.params = {}; - } - var /** @type {?} */ p1_1 = destination.params; - Object.keys(p0_1).forEach(function (param) { - if (!p1_1.hasOwnProperty(param)) { - p1_1[param] = p0_1[param]; - } - }); +function getBodyNode() { + if (typeof document != 'undefined') { + return document.body; } - return destination; + return null; } -var DASH_CASE_REGEXP = /-+([a-z0-9])/g; /** - * @param {?} input + * @param {?} engine + * @param {?} element + * @param {?} players * @return {?} */ -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 removeNodesAfterAnimationDone(engine, element, players) { + optimizeGroupPlayer(players).onDone(function () { return engine.processLeaveNode(element); }); } /** * @license @@ -7282,4128 +7784,3370 @@ function dashCaseToCamelCase(input) { * 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 EMPTY_ANIMATION_OPTIONS = {}; -/** - * @abstract - */ -var Ast = (function () { - function Ast() { - this.options = EMPTY_ANIMATION_OPTIONS; - } - /** - * @abstract - * @param {?} ast - * @param {?} context - * @return {?} - */ - Ast.prototype.visit = function (ast, context) { }; - Object.defineProperty(Ast.prototype, "params", { - /** - * @return {?} - */ - get: function () { return this.options['params'] || null; }, - enumerable: true, - configurable: true - }); - return Ast; -}()); -var TriggerAst = (function (_super) { - __extends(TriggerAst, _super); +var AnimationEngine = (function () { /** - * @param {?} name - * @param {?} states - * @param {?} transitions + * @param {?} driver + * @param {?} normalizer */ - function TriggerAst(name, states, transitions) { - var _this = _super.call(this) || this; - _this.name = name; - _this.states = states; - _this.transitions = transitions; - _this.queryCount = 0; - _this.depCount = 0; - return _this; + function AnimationEngine(driver, normalizer) { + var _this = this; + this._triggerCache = {}; + this.onRemovalComplete = function (element, context) { }; + this._transitionEngine = new TransitionAnimationEngine(driver, normalizer); + this._timelineEngine = new TimelineAnimationEngine(driver, normalizer); + this._transitionEngine.onRemovalComplete = + function (element, context) { _this.onRemovalComplete(element, context); }; } /** - * @param {?} visitor - * @param {?} context - * @return {?} - */ - TriggerAst.prototype.visit = function (visitor, context) { return visitor.visitTrigger(this, context); }; - return TriggerAst; -}(Ast)); -var StateAst = (function (_super) { - __extends(StateAst, _super); - /** + * @param {?} componentId + * @param {?} namespaceId + * @param {?} hostElement * @param {?} name - * @param {?} style - */ - function StateAst(name, style$$1) { - var _this = _super.call(this) || this; - _this.name = name; - _this.style = style$$1; - return _this; - } - /** - * @param {?} visitor - * @param {?} context + * @param {?} metadata * @return {?} */ - StateAst.prototype.visit = function (visitor, context) { return visitor.visitState(this, context); }; - return StateAst; -}(Ast)); -var TransitionAst = (function (_super) { - __extends(TransitionAst, _super); - /** - * @param {?} matchers - * @param {?} animation - */ - function TransitionAst(matchers, animation) { - var _this = _super.call(this) || this; - _this.matchers = matchers; - _this.animation = animation; - _this.queryCount = 0; - _this.depCount = 0; - return _this; - } + AnimationEngine.prototype.registerTrigger = function (componentId, namespaceId, hostElement, name, metadata) { + var /** @type {?} */ cacheKey = componentId + '-' + name; + var /** @type {?} */ trigger = this._triggerCache[cacheKey]; + if (!trigger) { + var /** @type {?} */ errors = []; + var /** @type {?} */ ast = (buildAnimationAst(/** @type {?} */ (metadata), errors)); + if (errors.length) { + throw new Error("The animation trigger \"" + name + "\" has failed to build due to the following errors:\n - " + errors.join("\n - ")); + } + trigger = buildTrigger(name, ast); + this._triggerCache[cacheKey] = trigger; + } + this._transitionEngine.registerTrigger(namespaceId, name, trigger); + }; /** - * @param {?} visitor - * @param {?} context + * @param {?} namespaceId + * @param {?} hostElement * @return {?} */ - TransitionAst.prototype.visit = function (visitor, context) { return visitor.visitTransition(this, context); }; - return TransitionAst; -}(Ast)); -var SequenceAst = (function (_super) { - __extends(SequenceAst, _super); - /** - * @param {?} steps - */ - function SequenceAst(steps) { - var _this = _super.call(this) || this; - _this.steps = steps; - return _this; - } + AnimationEngine.prototype.register = function (namespaceId, hostElement) { + this._transitionEngine.register(namespaceId, hostElement); + }; /** - * @param {?} visitor + * @param {?} namespaceId * @param {?} context * @return {?} */ - SequenceAst.prototype.visit = function (visitor, context) { return visitor.visitSequence(this, context); }; - return SequenceAst; -}(Ast)); -var GroupAst = (function (_super) { - __extends(GroupAst, _super); + AnimationEngine.prototype.destroy = function (namespaceId, context) { + this._transitionEngine.destroy(namespaceId, context); + }; /** - * @param {?} steps + * @param {?} namespaceId + * @param {?} element + * @param {?} parent + * @param {?} insertBefore + * @return {?} */ - function GroupAst(steps) { - var _this = _super.call(this) || this; - _this.steps = steps; - return _this; - } + AnimationEngine.prototype.onInsert = function (namespaceId, element, parent, insertBefore) { + this._transitionEngine.insertNode(namespaceId, element, parent, insertBefore); + }; /** - * @param {?} visitor + * @param {?} namespaceId + * @param {?} element * @param {?} context * @return {?} */ - GroupAst.prototype.visit = function (visitor, context) { return visitor.visitGroup(this, context); }; - return GroupAst; -}(Ast)); -var AnimateAst = (function (_super) { - __extends(AnimateAst, _super); + AnimationEngine.prototype.onRemove = function (namespaceId, element, context) { + this._transitionEngine.removeNode(namespaceId, element, context); + }; /** - * @param {?} timings - * @param {?} style + * @param {?} namespaceId + * @param {?} element + * @param {?} property + * @param {?} value + * @return {?} */ - function AnimateAst(timings, style$$1) { - var _this = _super.call(this) || this; - _this.timings = timings; - _this.style = style$$1; - return _this; - } + AnimationEngine.prototype.setProperty = function (namespaceId, element, property, value) { + // @@property + if (property.charAt(0) == '@') { + var _a = parseTimelineCommand(property), id = _a[0], action = _a[1]; + var /** @type {?} */ args = (value); + this._timelineEngine.command(id, element, action, args); + return false; + } + return this._transitionEngine.trigger(namespaceId, element, property, value); + }; /** - * @param {?} visitor - * @param {?} context + * @param {?} namespaceId + * @param {?} element + * @param {?} eventName + * @param {?} eventPhase + * @param {?} callback * @return {?} */ - AnimateAst.prototype.visit = function (visitor, context) { return visitor.visitAnimate(this, context); }; - return AnimateAst; -}(Ast)); -var StyleAst = (function (_super) { - __extends(StyleAst, _super); + AnimationEngine.prototype.listen = function (namespaceId, element, eventName, eventPhase, callback) { + // @@listen + if (eventName.charAt(0) == '@') { + var _a = parseTimelineCommand(eventName), id = _a[0], action = _a[1]; + return this._timelineEngine.listen(id, element, action, callback); + } + return this._transitionEngine.listen(namespaceId, element, eventName, eventPhase, callback); + }; /** - * @param {?} styles - * @param {?} easing - * @param {?} offset + * @param {?=} microtaskId + * @return {?} */ - function StyleAst(styles, easing, offset) { - var _this = _super.call(this) || this; - _this.styles = styles; - _this.easing = easing; - _this.offset = offset; - _this.isEmptyStep = false; - return _this; - } + AnimationEngine.prototype.flush = function (microtaskId) { + if (microtaskId === void 0) { microtaskId = -1; } + this._transitionEngine.flush(microtaskId); + }; + Object.defineProperty(AnimationEngine.prototype, "players", { + /** + * @return {?} + */ + get: function () { + return ((this._transitionEngine.players)) + .concat(/** @type {?} */ (this._timelineEngine.players)); + }, + enumerable: true, + configurable: true + }); /** - * @param {?} visitor - * @param {?} context * @return {?} */ - StyleAst.prototype.visit = function (visitor, context) { return visitor.visitStyle(this, context); }; - return StyleAst; -}(Ast)); -var KeyframesAst = (function (_super) { - __extends(KeyframesAst, _super); + AnimationEngine.prototype.whenRenderingDone = function () { return this._transitionEngine.whenRenderingDone(); }; + return AnimationEngine; +}()); +/** + * @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 WebAnimationsPlayer = (function () { /** - * @param {?} styles + * @param {?} element + * @param {?} keyframes + * @param {?} options + * @param {?=} previousPlayers */ - function KeyframesAst(styles) { - var _this = _super.call(this) || this; - _this.styles = styles; - return _this; + function WebAnimationsPlayer(element, keyframes, options, previousPlayers) { + if (previousPlayers === void 0) { previousPlayers = []; } + var _this = this; + this.element = element; + this.keyframes = keyframes; + this.options = options; + this.previousPlayers = previousPlayers; + this._onDoneFns = []; + this._onStartFns = []; + this._onDestroyFns = []; + this._initialized = false; + this._finished = false; + this._started = false; + this._destroyed = false; + this.time = 0; + this.parentPlayer = null; + this.currentSnapshot = {}; + this._duration = options['duration']; + this._delay = options['delay'] || 0; + this.time = this._duration + this._delay; + this.previousStyles = {}; + previousPlayers.forEach(function (player) { + var styles = player.currentSnapshot; + Object.keys(styles).forEach(function (prop) { return _this.previousStyles[prop] = styles[prop]; }); + }); } /** - * @param {?} visitor - * @param {?} context * @return {?} */ - KeyframesAst.prototype.visit = function (visitor, context) { return visitor.visitKeyframes(this, context); }; - return KeyframesAst; -}(Ast)); -var ReferenceAst = (function (_super) { - __extends(ReferenceAst, _super); - /** - * @param {?} animation - */ - function ReferenceAst(animation) { - var _this = _super.call(this) || this; - _this.animation = animation; - return _this; - } + WebAnimationsPlayer.prototype._onFinish = function () { + if (!this._finished) { + this._finished = true; + this._onDoneFns.forEach(function (fn) { return fn(); }); + this._onDoneFns = []; + } + }; /** - * @param {?} visitor - * @param {?} context * @return {?} */ - ReferenceAst.prototype.visit = function (visitor, context) { return visitor.visitReference(this, context); }; - return ReferenceAst; -}(Ast)); -var AnimateChildAst = (function (_super) { - __extends(AnimateChildAst, _super); - function AnimateChildAst() { - return _super.call(this) || this; - } + WebAnimationsPlayer.prototype.init = function () { + this._buildPlayer(); + this._preparePlayerBeforeStart(); + }; /** - * @param {?} visitor - * @param {?} context * @return {?} */ - AnimateChildAst.prototype.visit = function (visitor, context) { return visitor.visitAnimateChild(this, context); }; - return AnimateChildAst; -}(Ast)); -var AnimateRefAst = (function (_super) { - __extends(AnimateRefAst, _super); - /** - * @param {?} animation - */ - function AnimateRefAst(animation) { - var _this = _super.call(this) || this; - _this.animation = animation; - return _this; - } + WebAnimationsPlayer.prototype._buildPlayer = function () { + var _this = this; + if (this._initialized) + return; + this._initialized = true; + var /** @type {?} */ keyframes = this.keyframes.map(function (styles) { return copyStyles(styles, false); }); + var /** @type {?} */ previousStyleProps = Object.keys(this.previousStyles); + if (previousStyleProps.length) { + var /** @type {?} */ startingKeyframe_1 = keyframes[0]; + var /** @type {?} */ missingStyleProps_1 = []; + previousStyleProps.forEach(function (prop) { + if (!startingKeyframe_1.hasOwnProperty(prop)) { + missingStyleProps_1.push(prop); + } + startingKeyframe_1[prop] = _this.previousStyles[prop]; + }); + if (missingStyleProps_1.length) { + var /** @type {?} */ self_1 = this; + var _loop_1 = function () { + var /** @type {?} */ kf = keyframes[i]; + missingStyleProps_1.forEach(function (prop) { + kf[prop] = _computeStyle(self_1.element, prop); + }); + }; + // tslint:disable-next-line + for (var /** @type {?} */ i = 1; i < keyframes.length; i++) { + _loop_1(); + } + } + } + this._player = this._triggerWebAnimation(this.element, keyframes, this.options); + this._finalKeyframe = keyframes.length ? keyframes[keyframes.length - 1] : {}; + this._player.addEventListener('finish', function () { return _this._onFinish(); }); + }; /** - * @param {?} visitor - * @param {?} context * @return {?} */ - AnimateRefAst.prototype.visit = function (visitor, context) { return visitor.visitAnimateRef(this, context); }; - return AnimateRefAst; -}(Ast)); -var QueryAst = (function (_super) { - __extends(QueryAst, _super); - /** - * @param {?} selector - * @param {?} limit - * @param {?} optional - * @param {?} includeSelf - * @param {?} animation - */ - function QueryAst(selector, limit, optional, includeSelf, animation) { - var _this = _super.call(this) || this; - _this.selector = selector; - _this.limit = limit; - _this.optional = optional; - _this.includeSelf = includeSelf; - _this.animation = animation; - return _this; - } + WebAnimationsPlayer.prototype._preparePlayerBeforeStart = function () { + // this is required so that the player doesn't start to animate right away + if (this._delay) { + this._resetDomPlayerState(); + } + else { + this._player.pause(); + } + }; /** - * @param {?} visitor - * @param {?} context + * \@internal + * @param {?} element + * @param {?} keyframes + * @param {?} options * @return {?} */ - QueryAst.prototype.visit = function (visitor, context) { return visitor.visitQuery(this, context); }; - return QueryAst; -}(Ast)); -var StaggerAst = (function (_super) { - __extends(StaggerAst, _super); + WebAnimationsPlayer.prototype._triggerWebAnimation = function (element, keyframes, options) { + // jscompiler doesn't seem to know animate is a native property because it's not fully + // supported yet across common browsers (we polyfill it for Edge/Safari) [CL #143630929] + return (element['animate'](keyframes, options)); + }; + Object.defineProperty(WebAnimationsPlayer.prototype, "domPlayer", { + /** + * @return {?} + */ + get: function () { return this._player; }, + enumerable: true, + configurable: true + }); /** - * @param {?} timings - * @param {?} animation + * @param {?} fn + * @return {?} */ - function StaggerAst(timings, animation) { - var _this = _super.call(this) || this; - _this.timings = timings; - _this.animation = animation; - return _this; - } + WebAnimationsPlayer.prototype.onStart = function (fn) { this._onStartFns.push(fn); }; /** - * @param {?} visitor - * @param {?} context + * @param {?} fn * @return {?} */ - StaggerAst.prototype.visit = function (visitor, context) { return visitor.visitStagger(this, context); }; - return StaggerAst; -}(Ast)); -var TimingAst = (function (_super) { - __extends(TimingAst, _super); + WebAnimationsPlayer.prototype.onDone = function (fn) { this._onDoneFns.push(fn); }; /** - * @param {?} duration - * @param {?=} delay - * @param {?=} easing + * @param {?} fn + * @return {?} */ - function TimingAst(duration, delay, easing) { - if (delay === void 0) { delay = 0; } - if (easing === void 0) { easing = null; } - var _this = _super.call(this) || this; - _this.duration = duration; - _this.delay = delay; - _this.easing = easing; - return _this; - } + WebAnimationsPlayer.prototype.onDestroy = function (fn) { this._onDestroyFns.push(fn); }; /** - * @param {?} visitor - * @param {?} context * @return {?} */ - TimingAst.prototype.visit = function (visitor, context) { return visitor.visitTiming(this, context); }; - return TimingAst; -}(Ast)); -var DynamicTimingAst = (function (_super) { - __extends(DynamicTimingAst, _super); + WebAnimationsPlayer.prototype.play = function () { + this._buildPlayer(); + if (!this.hasStarted()) { + this._onStartFns.forEach(function (fn) { return fn(); }); + this._onStartFns = []; + this._started = true; + } + this._player.play(); + }; /** - * @param {?} value + * @return {?} */ - function DynamicTimingAst(value) { - var _this = _super.call(this, 0, 0, '') || this; - _this.value = value; - return _this; - } + WebAnimationsPlayer.prototype.pause = function () { + this.init(); + this._player.pause(); + }; /** - * @param {?} visitor - * @param {?} context * @return {?} */ - DynamicTimingAst.prototype.visit = function (visitor, context) { return visitor.visitTiming(this, context); }; - return DynamicTimingAst; -}(TimingAst)); -/** - * @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 - */ -/** - * @param {?} visitor - * @param {?} node - * @param {?} context - * @return {?} - */ -function visitAnimationNode(visitor, node, context) { - switch (node.type) { - case 7 /* Trigger */: - return visitor.visitTrigger(/** @type {?} */ (node), context); - case 0 /* State */: - return visitor.visitState(/** @type {?} */ (node), context); - case 1 /* Transition */: - return visitor.visitTransition(/** @type {?} */ (node), context); - case 2 /* Sequence */: - return visitor.visitSequence(/** @type {?} */ (node), context); - case 3 /* Group */: - return visitor.visitGroup(/** @type {?} */ (node), context); - case 4 /* Animate */: - return visitor.visitAnimate(/** @type {?} */ (node), context); - case 5 /* Keyframes */: - return visitor.visitKeyframes(/** @type {?} */ (node), context); - case 6 /* Style */: - return visitor.visitStyle(/** @type {?} */ (node), context); - case 8 /* Reference */: - return visitor.visitReference(/** @type {?} */ (node), context); - case 9 /* AnimateChild */: - return visitor.visitAnimateChild(/** @type {?} */ (node), context); - case 10 /* AnimateRef */: - return visitor.visitAnimateRef(/** @type {?} */ (node), context); - case 11 /* Query */: - return visitor.visitQuery(/** @type {?} */ (node), context); - case 12 /* Stagger */: - return visitor.visitStagger(/** @type {?} */ (node), context); - default: - throw new Error("Unable to resolve animation metadata node #" + node.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 - */ -var ANY_STATE = '*'; -/** - * @param {?} transitionValue - * @param {?} errors - * @return {?} - */ -function parseTransitionExpr(transitionValue, errors) { - var /** @type {?} */ expressions = []; - if (typeof transitionValue == 'string') { - ((transitionValue)) - .split(/\s*,\s*/) - .forEach(function (str) { return parseInnerTransitionStr(str, expressions, errors); }); - } - else { - expressions.push(/** @type {?} */ (transitionValue)); - } - return expressions; -} -/** - * @param {?} eventStr - * @param {?} expressions - * @param {?} errors - * @return {?} - */ -function parseInnerTransitionStr(eventStr, expressions, errors) { - if (eventStr[0] == ':') { - eventStr = parseAnimationAlias(eventStr, errors); - } - var /** @type {?} */ match = eventStr.match(/^(\*|[-\w]+)\s*()\s*(\*|[-\w]+)$/); - if (match == null || match.length < 4) { - errors.push("The provided transition expression \"" + eventStr + "\" is not supported"); - return expressions; - } - var /** @type {?} */ fromState = match[1]; - var /** @type {?} */ separator = match[2]; - var /** @type {?} */ toState = match[3]; - expressions.push(makeLambdaFromStates(fromState, toState)); - var /** @type {?} */ isFullAnyStateExpr = fromState == ANY_STATE && toState == ANY_STATE; - if (separator[0] == '<' && !isFullAnyStateExpr) { - expressions.push(makeLambdaFromStates(toState, fromState)); - } -} -/** - * @param {?} alias - * @param {?} errors - * @return {?} - */ -function parseAnimationAlias(alias, errors) { - switch (alias) { - case ':enter': - return 'void => *'; - case ':leave': - return '* => void'; - default: - errors.push("The transition alias value \"" + alias + "\" is not supported"); - return '* => *'; - } -} -/** - * @param {?} lhs - * @param {?} rhs - * @return {?} - */ -function makeLambdaFromStates(lhs, rhs) { - return function (fromState, toState) { - var /** @type {?} */ lhsMatch = lhs == ANY_STATE || lhs == fromState; - var /** @type {?} */ rhsMatch = rhs == ANY_STATE || rhs == toState; - if (!lhsMatch && typeof fromState === 'boolean') { - lhsMatch = fromState ? lhs === 'true' : lhs === 'false'; - } - if (!rhsMatch && typeof toState === 'boolean') { - rhsMatch = toState ? rhs === 'true' : rhs === 'false'; - } - return lhsMatch && rhsMatch; + WebAnimationsPlayer.prototype.finish = function () { + this.init(); + this._onFinish(); + this._player.finish(); }; -} -/** - * @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 SELF_TOKEN = ':self'; -var SELF_TOKEN_REGEX = new RegExp("s*" + SELF_TOKEN + "s*,?", 'g'); -/** - * @param {?} metadata - * @param {?} errors - * @return {?} - */ -function buildAnimationAst(metadata, errors) { - return new AnimationAstBuilderVisitor().build(metadata, errors); -} -var LEAVE_TOKEN = ':leave'; -var LEAVE_TOKEN_REGEX = new RegExp(LEAVE_TOKEN, 'g'); -var ENTER_TOKEN = ':enter'; -var ENTER_TOKEN_REGEX = new RegExp(ENTER_TOKEN, 'g'); -var ROOT_SELECTOR = ''; -var AnimationAstBuilderVisitor = (function () { - function AnimationAstBuilderVisitor() { - } /** - * @param {?} metadata - * @param {?} errors * @return {?} */ - AnimationAstBuilderVisitor.prototype.build = function (metadata, errors) { - var /** @type {?} */ context = new AnimationAstBuilderContext(errors); - this._resetContextStyleTimingState(context); - return (visitAnimationNode(this, normalizeAnimationEntry(metadata), context)); + WebAnimationsPlayer.prototype.reset = function () { + this._resetDomPlayerState(); + this._destroyed = false; + this._finished = false; + this._started = false; }; /** - * @param {?} context * @return {?} */ - AnimationAstBuilderVisitor.prototype._resetContextStyleTimingState = function (context) { - context.currentQuerySelector = ROOT_SELECTOR; - context.collectedStyles = {}; - context.collectedStyles[ROOT_SELECTOR] = {}; - context.currentTime = 0; + WebAnimationsPlayer.prototype._resetDomPlayerState = function () { + if (this._player) { + this._player.cancel(); + } }; /** - * @param {?} metadata - * @param {?} context * @return {?} */ - AnimationAstBuilderVisitor.prototype.visitTrigger = function (metadata, context) { - var _this = this; - var /** @type {?} */ queryCount = context.queryCount = 0; - var /** @type {?} */ depCount = context.depCount = 0; - var /** @type {?} */ states = []; - var /** @type {?} */ transitions = []; - metadata.definitions.forEach(function (def) { - _this._resetContextStyleTimingState(context); - if (def.type == 0 /* State */) { - var /** @type {?} */ stateDef_1 = (def); - var /** @type {?} */ name = stateDef_1.name; - name.split(/\s*,\s*/).forEach(function (n) { - stateDef_1.name = n; - states.push(_this.visitState(stateDef_1, context)); - }); - stateDef_1.name = name; - } - else if (def.type == 1 /* Transition */) { - var /** @type {?} */ transition = _this.visitTransition(/** @type {?} */ (def), context); - queryCount += transition.queryCount; - depCount += transition.depCount; - transitions.push(transition); - } - else { - context.errors.push('only state() and transition() definitions can sit inside of a trigger()'); - } - }); - var /** @type {?} */ ast = new TriggerAst(metadata.name, states, transitions); - ast.options = normalizeAnimationOptions(metadata.options); - ast.queryCount = queryCount; - ast.depCount = depCount; - return ast; + WebAnimationsPlayer.prototype.restart = function () { + this.reset(); + this.play(); }; /** - * @param {?} metadata - * @param {?} context * @return {?} */ - AnimationAstBuilderVisitor.prototype.visitState = function (metadata, context) { - return new StateAst(metadata.name, this.visitStyle(metadata.styles, context)); - }; + WebAnimationsPlayer.prototype.hasStarted = function () { return this._started; }; /** - * @param {?} metadata - * @param {?} context * @return {?} */ - AnimationAstBuilderVisitor.prototype.visitTransition = function (metadata, context) { - context.queryCount = 0; - context.depCount = 0; - var /** @type {?} */ entry = visitAnimationNode(this, normalizeAnimationEntry(metadata.animation), context); - var /** @type {?} */ matchers = parseTransitionExpr(metadata.expr, context.errors); - var /** @type {?} */ ast = new TransitionAst(matchers, entry); - ast.options = normalizeAnimationOptions(metadata.options); - ast.queryCount = context.queryCount; - ast.depCount = context.depCount; - return ast; + WebAnimationsPlayer.prototype.destroy = function () { + if (!this._destroyed) { + this._resetDomPlayerState(); + this._onFinish(); + this._destroyed = true; + this._onDestroyFns.forEach(function (fn) { return fn(); }); + this._onDestroyFns = []; + } }; /** - * @param {?} metadata - * @param {?} context + * @param {?} p * @return {?} */ - AnimationAstBuilderVisitor.prototype.visitSequence = function (metadata, context) { - var _this = this; - var /** @type {?} */ ast = new SequenceAst(metadata.steps.map(function (s) { return visitAnimationNode(_this, s, context); })); - ast.options = normalizeAnimationOptions(metadata.options); - return ast; - }; + WebAnimationsPlayer.prototype.setPosition = function (p) { this._player.currentTime = p * this.time; }; /** - * @param {?} metadata - * @param {?} context * @return {?} */ - AnimationAstBuilderVisitor.prototype.visitGroup = function (metadata, context) { - var _this = this; - var /** @type {?} */ currentTime = context.currentTime; - var /** @type {?} */ furthestTime = 0; - var /** @type {?} */ steps = metadata.steps.map(function (step) { - context.currentTime = currentTime; - var /** @type {?} */ innerAst = visitAnimationNode(_this, step, context); - furthestTime = Math.max(furthestTime, context.currentTime); - return innerAst; - }); - context.currentTime = furthestTime; - var /** @type {?} */ ast = new GroupAst(steps); - ast.options = normalizeAnimationOptions(metadata.options); - return ast; - }; + WebAnimationsPlayer.prototype.getPosition = function () { return this._player.currentTime / this.time; }; + Object.defineProperty(WebAnimationsPlayer.prototype, "totalTime", { + /** + * @return {?} + */ + get: function () { return this._delay + this._duration; }, + enumerable: true, + configurable: true + }); /** - * @param {?} metadata - * @param {?} context * @return {?} */ - AnimationAstBuilderVisitor.prototype.visitAnimate = function (metadata, context) { - var /** @type {?} */ timingAst = constructTimingAst(metadata.timings, context.errors); - context.currentAnimateTimings = timingAst; - var /** @type {?} */ styles; - var /** @type {?} */ styleMetadata = metadata.styles ? metadata.styles : _angular_animations.style({}); - if (styleMetadata.type == 5 /* Keyframes */) { - styles = this.visitKeyframes(/** @type {?} */ (styleMetadata), context); - } - else { - var /** @type {?} */ styleMetadata_1 = (metadata.styles); - var /** @type {?} */ isEmpty = false; - if (!styleMetadata_1) { - isEmpty = true; - var /** @type {?} */ newStyleData = {}; - if (timingAst.easing) { - newStyleData['easing'] = timingAst.easing; + WebAnimationsPlayer.prototype.beforeDestroy = function () { + var _this = this; + var /** @type {?} */ styles = {}; + if (this.hasStarted()) { + Object.keys(this._finalKeyframe).forEach(function (prop) { + if (prop != 'offset') { + styles[prop] = + _this._finished ? _this._finalKeyframe[prop] : _computeStyle(_this.element, prop); } - styleMetadata_1 = _angular_animations.style(newStyleData); - } - context.currentTime += timingAst.duration + timingAst.delay; - var /** @type {?} */ styleAst = this.visitStyle(styleMetadata_1, context); - styleAst.isEmptyStep = isEmpty; - styles = styleAst; + }); } - context.currentAnimateTimings = null; - return new AnimateAst(timingAst, styles); + this.currentSnapshot = styles; }; + return WebAnimationsPlayer; +}()); +/** + * @param {?} element + * @param {?} prop + * @return {?} + */ +function _computeStyle(element, prop) { + return ((window.getComputedStyle(element)))[prop]; +} +/** + * @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 WebAnimationsDriver = (function () { + function WebAnimationsDriver() { + } /** - * @param {?} metadata - * @param {?} context + * @param {?} element + * @param {?} selector * @return {?} */ - AnimationAstBuilderVisitor.prototype.visitStyle = function (metadata, context) { - var /** @type {?} */ ast = this._makeStyleAst(metadata, context); - this._validateStyleAst(ast, context); - return ast; + WebAnimationsDriver.prototype.matchesElement = function (element, selector) { + return matchesElement(element, selector); }; /** - * @param {?} metadata - * @param {?} context + * @param {?} elm1 + * @param {?} elm2 * @return {?} */ - AnimationAstBuilderVisitor.prototype._makeStyleAst = function (metadata, context) { - var /** @type {?} */ styles = []; - if (Array.isArray(metadata.styles)) { - ((metadata.styles)).forEach(function (styleTuple) { - if (typeof styleTuple == 'string') { - if (styleTuple == _angular_animations.AUTO_STYLE) { - styles.push(/** @type {?} */ (styleTuple)); - } - else { - context.errors.push("The provided style string value " + styleTuple + " is not allowed."); - } - } - else { - styles.push(/** @type {?} */ (styleTuple)); - } - }); - } - else { - styles.push(metadata.styles); - } - var /** @type {?} */ collectedEasing = null; - styles.forEach(function (styleData) { - if (isObject(styleData)) { - var /** @type {?} */ styleMap = (styleData); - var /** @type {?} */ easing = styleMap['easing']; - if (easing) { - collectedEasing = (easing); - delete styleMap['easing']; - } - } - }); - return new StyleAst(styles, collectedEasing, metadata.offset); - }; - /** - * @param {?} ast - * @param {?} context - * @return {?} - */ - AnimationAstBuilderVisitor.prototype._validateStyleAst = function (ast, context) { - var /** @type {?} */ timings = context.currentAnimateTimings; - var /** @type {?} */ endTime = context.currentTime; - var /** @type {?} */ startTime = context.currentTime; - if (timings && startTime > 0) { - startTime -= timings.duration + timings.delay; - } - ast.styles.forEach(function (tuple) { - if (typeof tuple == 'string') - return; - Object.keys(tuple).forEach(function (prop) { - var /** @type {?} */ collectedStyles = context.collectedStyles[((context.currentQuerySelector))]; - var /** @type {?} */ collectedEntry = collectedStyles[prop]; - var /** @type {?} */ updateCollectedStyle = true; - if (collectedEntry) { - if (startTime != endTime && startTime >= collectedEntry.startTime && - endTime <= collectedEntry.endTime) { - context.errors.push("The CSS property \"" + prop + "\" that exists between the times of \"" + collectedEntry.startTime + "ms\" and \"" + collectedEntry.endTime + "ms\" is also being animated in a parallel animation between the times of \"" + startTime + "ms\" and \"" + endTime + "ms\""); - updateCollectedStyle = false; - } - // we always choose the smaller start time value since we - // want to have a record of the entire animation window where - // the style property is being animated in between - startTime = collectedEntry.startTime; - } - if (updateCollectedStyle) { - collectedStyles[prop] = { startTime: startTime, endTime: endTime }; - } - if (context.options) { - validateStyleParams(tuple[prop], context.options, context.errors); - } - }); - }); - }; - /** - * @param {?} metadata - * @param {?} context - * @return {?} - */ - AnimationAstBuilderVisitor.prototype.visitKeyframes = function (metadata, context) { - var _this = this; - if (!context.currentAnimateTimings) { - context.errors.push("keyframes() must be placed inside of a call to animate()"); - return new KeyframesAst([]); - } - var /** @type {?} */ MAX_KEYFRAME_OFFSET = 1; - var /** @type {?} */ totalKeyframesWithOffsets = 0; - var /** @type {?} */ offsets = []; - var /** @type {?} */ offsetsOutOfOrder = false; - var /** @type {?} */ keyframesOutOfRange = false; - var /** @type {?} */ previousOffset = 0; - var /** @type {?} */ keyframes = metadata.steps.map(function (styles) { - var /** @type {?} */ style$$1 = _this._makeStyleAst(styles, context); - var /** @type {?} */ offsetVal = style$$1.offset != null ? style$$1.offset : consumeOffset(style$$1.styles); - var /** @type {?} */ offset = 0; - if (offsetVal != null) { - totalKeyframesWithOffsets++; - offset = style$$1.offset = offsetVal; - } - keyframesOutOfRange = keyframesOutOfRange || offset < 0 || offset > 1; - offsetsOutOfOrder = offsetsOutOfOrder || offset < previousOffset; - previousOffset = offset; - offsets.push(offset); - return style$$1; - }); - if (keyframesOutOfRange) { - context.errors.push("Please ensure that all keyframe offsets are between 0 and 1"); - } - if (offsetsOutOfOrder) { - context.errors.push("Please ensure that all keyframe offsets are in order"); - } - var /** @type {?} */ length = metadata.steps.length; - var /** @type {?} */ generatedOffset = 0; - if (totalKeyframesWithOffsets > 0 && totalKeyframesWithOffsets < length) { - context.errors.push("Not all style() steps within the declared keyframes() contain offsets"); - } - else if (totalKeyframesWithOffsets == 0) { - generatedOffset = MAX_KEYFRAME_OFFSET / (length - 1); - } - var /** @type {?} */ limit = length - 1; - var /** @type {?} */ currentTime = context.currentTime; - var /** @type {?} */ currentAnimateTimings = ((context.currentAnimateTimings)); - var /** @type {?} */ animateDuration = currentAnimateTimings.duration; - keyframes.forEach(function (kf, i) { - var /** @type {?} */ offset = generatedOffset > 0 ? (i == limit ? 1 : (generatedOffset * i)) : offsets[i]; - var /** @type {?} */ durationUpToThisFrame = offset * animateDuration; - context.currentTime = currentTime + currentAnimateTimings.delay + durationUpToThisFrame; - currentAnimateTimings.duration = durationUpToThisFrame; - _this._validateStyleAst(kf, context); - kf.offset = offset; - }); - return new KeyframesAst(keyframes); - }; - /** - * @param {?} metadata - * @param {?} context - * @return {?} - */ - AnimationAstBuilderVisitor.prototype.visitReference = function (metadata, context) { - var /** @type {?} */ entry = visitAnimationNode(this, normalizeAnimationEntry(metadata.animation), context); - var /** @type {?} */ ast = new ReferenceAst(entry); - ast.options = normalizeAnimationOptions(metadata.options); - return ast; - }; - /** - * @param {?} metadata - * @param {?} context - * @return {?} - */ - AnimationAstBuilderVisitor.prototype.visitAnimateChild = function (metadata, context) { - context.depCount++; - var /** @type {?} */ ast = new AnimateChildAst(); - ast.options = normalizeAnimationOptions(metadata.options); - return ast; - }; + WebAnimationsDriver.prototype.containsElement = function (elm1, elm2) { return containsElement(elm1, elm2); }; /** - * @param {?} metadata - * @param {?} context + * @param {?} element + * @param {?} selector + * @param {?} multi * @return {?} */ - AnimationAstBuilderVisitor.prototype.visitAnimateRef = function (metadata, context) { - var /** @type {?} */ animation = this.visitReference(metadata.animation, context); - var /** @type {?} */ ast = new AnimateRefAst(animation); - ast.options = normalizeAnimationOptions(metadata.options); - return ast; + WebAnimationsDriver.prototype.query = function (element, selector, multi) { + return invokeQuery(element, selector, multi); }; /** - * @param {?} metadata - * @param {?} context + * @param {?} element + * @param {?} prop + * @param {?=} defaultValue * @return {?} */ - AnimationAstBuilderVisitor.prototype.visitQuery = function (metadata, context) { - var /** @type {?} */ parentSelector = ((context.currentQuerySelector)); - var /** @type {?} */ options = ((metadata.options || {})); - context.queryCount++; - context.currentQuery = metadata; - var _a = normalizeSelector(metadata.selector), selector = _a[0], includeSelf = _a[1]; - context.currentQuerySelector = - parentSelector.length ? (parentSelector + ' ' + selector) : selector; - getOrSetAsInMap(context.collectedStyles, context.currentQuerySelector, {}); - var /** @type {?} */ entry = visitAnimationNode(this, normalizeAnimationEntry(metadata.animation), context); - context.currentQuery = null; - context.currentQuerySelector = parentSelector; - var /** @type {?} */ ast = new QueryAst(selector, options.limit || 0, !!options.optional, includeSelf, entry); - ast.originalSelector = metadata.selector; - ast.options = normalizeAnimationOptions(metadata.options); - return ast; + WebAnimationsDriver.prototype.computeStyle = function (element, prop, defaultValue) { + return (((window.getComputedStyle(element)))[prop]); }; /** - * @param {?} metadata - * @param {?} context + * @param {?} element + * @param {?} keyframes + * @param {?} duration + * @param {?} delay + * @param {?} easing + * @param {?=} previousPlayers * @return {?} */ - AnimationAstBuilderVisitor.prototype.visitStagger = function (metadata, context) { - if (!context.currentQuery) { - context.errors.push("stagger() can only be used inside of query()"); + WebAnimationsDriver.prototype.animate = function (element, keyframes, duration, delay, easing, previousPlayers) { + if (previousPlayers === void 0) { previousPlayers = []; } + var /** @type {?} */ fill = delay == 0 ? 'both' : 'forwards'; + var /** @type {?} */ playerOptions = { duration: duration, delay: delay, fill: fill }; + // we check for this to avoid having a null|undefined value be present + // for the easing (which results in an error for certain browsers #9752) + if (easing) { + playerOptions['easing'] = easing; } - var /** @type {?} */ timings = metadata.timings === 'full' ? - { duration: 0, delay: 0, easing: 'full' } : - resolveTiming(metadata.timings, context.errors, true); - var /** @type {?} */ animation = visitAnimationNode(this, normalizeAnimationEntry(metadata.animation), context); - return new StaggerAst(timings, animation); + var /** @type {?} */ previousWebAnimationPlayers = (previousPlayers.filter(function (player) { return player instanceof WebAnimationsPlayer; })); + return new WebAnimationsPlayer(element, keyframes, playerOptions, previousWebAnimationPlayers); }; - return AnimationAstBuilderVisitor; + return WebAnimationsDriver; }()); /** - * @param {?} selector * @return {?} */ -function normalizeSelector(selector) { - var /** @type {?} */ hasAmpersand = selector.split(/\s*,\s*/).find(function (token) { return token == SELF_TOKEN; }) ? true : false; - if (hasAmpersand) { - selector = selector.replace(SELF_TOKEN_REGEX, ''); - } - selector = selector.replace(ENTER_TOKEN_REGEX, ENTER_SELECTOR) - .replace(LEAVE_TOKEN_REGEX, LEAVE_SELECTOR) - .replace(/@\*/g, NG_TRIGGER_SELECTOR) - .replace(/@\w+/g, function (match) { return NG_TRIGGER_SELECTOR + '-' + match.substr(1); }) - .replace(/:animating/g, NG_ANIMATING_SELECTOR); - return [selector, hasAmpersand]; +function supportsWebAnimations() { + return typeof Element !== 'undefined' && typeof ((Element)).prototype['animate'] === 'function'; } -/** - * @param {?} obj - * @return {?} - */ -function normalizeParams(obj) { - return obj ? copyObj(obj) : null; + +exports.AnimationDriver = AnimationDriver; +exports.ɵAnimation = Animation; +exports.ɵAnimationStyleNormalizer = AnimationStyleNormalizer; +exports.ɵNoopAnimationStyleNormalizer = NoopAnimationStyleNormalizer; +exports.ɵWebAnimationsStyleNormalizer = WebAnimationsStyleNormalizer; +exports.ɵNoopAnimationDriver = NoopAnimationDriver; +exports.ɵAnimationEngine = AnimationEngine; +exports.ɵWebAnimationsDriver = WebAnimationsDriver; +exports.ɵsupportsWebAnimations = supportsWebAnimations; +exports.ɵWebAnimationsPlayer = WebAnimationsPlayer; + +Object.defineProperty(exports, '__esModule', { value: true }); + +}))); +//# sourceMappingURL=animations-browser.umd.js.map + + +/***/ }), +/* 35 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var DOCUMENT_MODE = __webpack_require__(11).DOCUMENT_MODE; + +//Const +var VALID_DOCTYPE_NAME = 'html', + QUIRKS_MODE_SYSTEM_ID = 'http://www.ibm.com/data/dtd/v11/ibmxhtml1-transitional.dtd', + QUIRKS_MODE_PUBLIC_ID_PREFIXES = [ + '+//silmaril//dtd html pro v0r11 19970101//en', + '-//advasoft ltd//dtd html 3.0 aswedit + extensions//en', + '-//as//dtd html 3.0 aswedit + extensions//en', + '-//ietf//dtd html 2.0 level 1//en', + '-//ietf//dtd html 2.0 level 2//en', + '-//ietf//dtd html 2.0 strict level 1//en', + '-//ietf//dtd html 2.0 strict level 2//en', + '-//ietf//dtd html 2.0 strict//en', + '-//ietf//dtd html 2.0//en', + '-//ietf//dtd html 2.1e//en', + '-//ietf//dtd html 3.0//en', + '-//ietf//dtd html 3.0//en//', + '-//ietf//dtd html 3.2 final//en', + '-//ietf//dtd html 3.2//en', + '-//ietf//dtd html 3//en', + '-//ietf//dtd html level 0//en', + '-//ietf//dtd html level 0//en//2.0', + '-//ietf//dtd html level 1//en', + '-//ietf//dtd html level 1//en//2.0', + '-//ietf//dtd html level 2//en', + '-//ietf//dtd html level 2//en//2.0', + '-//ietf//dtd html level 3//en', + '-//ietf//dtd html level 3//en//3.0', + '-//ietf//dtd html strict level 0//en', + '-//ietf//dtd html strict level 0//en//2.0', + '-//ietf//dtd html strict level 1//en', + '-//ietf//dtd html strict level 1//en//2.0', + '-//ietf//dtd html strict level 2//en', + '-//ietf//dtd html strict level 2//en//2.0', + '-//ietf//dtd html strict level 3//en', + '-//ietf//dtd html strict level 3//en//3.0', + '-//ietf//dtd html strict//en', + '-//ietf//dtd html strict//en//2.0', + '-//ietf//dtd html strict//en//3.0', + '-//ietf//dtd html//en', + '-//ietf//dtd html//en//2.0', + '-//ietf//dtd html//en//3.0', + '-//metrius//dtd metrius presentational//en', + '-//microsoft//dtd internet explorer 2.0 html strict//en', + '-//microsoft//dtd internet explorer 2.0 html//en', + '-//microsoft//dtd internet explorer 2.0 tables//en', + '-//microsoft//dtd internet explorer 3.0 html strict//en', + '-//microsoft//dtd internet explorer 3.0 html//en', + '-//microsoft//dtd internet explorer 3.0 tables//en', + '-//netscape comm. corp.//dtd html//en', + '-//netscape comm. corp.//dtd strict html//en', + '-//o\'reilly and associates//dtd html 2.0//en', + '-//o\'reilly and associates//dtd html extended 1.0//en', + '-//spyglass//dtd html 2.0 extended//en', + '-//sq//dtd html 2.0 hotmetal + extensions//en', + '-//sun microsystems corp.//dtd hotjava html//en', + '-//sun microsystems corp.//dtd hotjava strict html//en', + '-//w3c//dtd html 3 1995-03-24//en', + '-//w3c//dtd html 3.2 draft//en', + '-//w3c//dtd html 3.2 final//en', + '-//w3c//dtd html 3.2//en', + '-//w3c//dtd html 3.2s draft//en', + '-//w3c//dtd html 4.0 frameset//en', + '-//w3c//dtd html 4.0 transitional//en', + '-//w3c//dtd html experimental 19960712//en', + '-//w3c//dtd html experimental 970421//en', + '-//w3c//dtd w3 html//en', + '-//w3o//dtd w3 html 3.0//en', + '-//w3o//dtd w3 html 3.0//en//', + '-//webtechs//dtd mozilla html 2.0//en', + '-//webtechs//dtd mozilla html//en' + ], + QUIRKS_MODE_NO_SYSTEM_ID_PUBLIC_ID_PREFIXES = QUIRKS_MODE_PUBLIC_ID_PREFIXES.concat([ + '-//w3c//dtd html 4.01 frameset//', + '-//w3c//dtd html 4.01 transitional//' + ]), + QUIRKS_MODE_PUBLIC_IDS = [ + '-//w3o//dtd w3 html strict 3.0//en//', + '-/w3c/dtd html 4.0 transitional/en', + 'html' + ], + LIMITED_QUIRKS_PUBLIC_ID_PREFIXES = [ + '-//W3C//DTD XHTML 1.0 Frameset//', + '-//W3C//DTD XHTML 1.0 Transitional//' + ], + LIMITED_QUIRKS_WITH_SYSTEM_ID_PUBLIC_ID_PREFIXES = LIMITED_QUIRKS_PUBLIC_ID_PREFIXES.concat([ + '-//W3C//DTD HTML 4.01 Frameset//', + '-//W3C//DTD HTML 4.01 Transitional//' + ]); + + +//Utils +function enquoteDoctypeId(id) { + var quote = id.indexOf('"') !== -1 ? '\'' : '"'; + + return quote + id + quote; } -var AnimationAstBuilderContext = (function () { - /** - * @param {?} errors - */ - function AnimationAstBuilderContext(errors) { - this.errors = errors; - this.queryCount = 0; - this.depCount = 0; - this.currentTransition = null; - this.currentQuery = null; - this.currentQuerySelector = null; - this.currentAnimateTimings = null; - this.currentTime = 0; - this.collectedStyles = {}; - this.options = null; - } - return AnimationAstBuilderContext; -}()); -/** - * @param {?} styles - * @return {?} - */ -function consumeOffset(styles) { - if (typeof styles == 'string') - return null; - var /** @type {?} */ offset = null; - if (Array.isArray(styles)) { - styles.forEach(function (styleTuple) { - if (isObject(styleTuple) && styleTuple.hasOwnProperty('offset')) { - var /** @type {?} */ obj = (styleTuple); - offset = parseFloat(/** @type {?} */ (obj['offset'])); - delete obj['offset']; - } - }); - } - else if (isObject(styles) && styles.hasOwnProperty('offset')) { - var /** @type {?} */ obj = (styles); - offset = parseFloat(/** @type {?} */ (obj['offset'])); - delete obj['offset']; + +function hasPrefix(publicId, prefixes) { + for (var i = 0; i < prefixes.length; i++) { + if (publicId.indexOf(prefixes[i]) === 0) + return true; } - return offset; -} -/** - * @param {?} value - * @return {?} - */ -function isObject(value) { - return !Array.isArray(value) && typeof value == 'object'; + + return false; } -/** - * @param {?} value - * @param {?} errors - * @return {?} - */ -function constructTimingAst(value, errors) { - var /** @type {?} */ timings = null; - if (value.hasOwnProperty('duration')) { - timings = (value); + + +//API +exports.getDocumentMode = function (name, publicId, systemId) { + if (name !== VALID_DOCTYPE_NAME) + return DOCUMENT_MODE.QUIRKS; + + if (systemId && systemId.toLowerCase() === QUIRKS_MODE_SYSTEM_ID) + return DOCUMENT_MODE.QUIRKS; + + if (publicId !== null) { + publicId = publicId.toLowerCase(); + + if (QUIRKS_MODE_PUBLIC_IDS.indexOf(publicId) > -1) + return DOCUMENT_MODE.QUIRKS; + + var prefixes = systemId === null ? QUIRKS_MODE_NO_SYSTEM_ID_PUBLIC_ID_PREFIXES : QUIRKS_MODE_PUBLIC_ID_PREFIXES; + + if (hasPrefix(publicId, prefixes)) + return DOCUMENT_MODE.QUIRKS; + + prefixes = systemId === null ? LIMITED_QUIRKS_PUBLIC_ID_PREFIXES : LIMITED_QUIRKS_WITH_SYSTEM_ID_PUBLIC_ID_PREFIXES; + + if (hasPrefix(publicId, prefixes)) + return DOCUMENT_MODE.LIMITED_QUIRKS; } - else if (typeof value == 'number') { - var /** @type {?} */ duration = resolveTiming(/** @type {?} */ (value), errors).duration; - return new TimingAst(/** @type {?} */ (value), 0, ''); + + return DOCUMENT_MODE.NO_QUIRKS; +}; + +exports.serializeContent = function (name, publicId, systemId) { + var str = '!DOCTYPE '; + + if (name) + str += name; + + if (publicId !== null) + str += ' PUBLIC ' + enquoteDoctypeId(publicId); + + else if (systemId !== null) + str += ' SYSTEM'; + + if (systemId !== null) + str += ' ' + enquoteDoctypeId(systemId); + + return str; +}; + + +/***/ }), +/* 36 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +module.exports = function mergeOptions(defaults, options) { + options = options || Object.create(null); + + return [defaults, options].reduce(function (merged, optObj) { + Object.keys(optObj).forEach(function (key) { + merged[key] = optObj[key]; + }); + + return merged; + }, Object.create(null)); +}; + + +/***/ }), +/* 37 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var Parser = __webpack_require__(59), + Serializer = __webpack_require__(62); + + +// Shorthands +exports.parse = function parse(html, options) { + var parser = new Parser(options); + + return parser.parse(html); +}; + +exports.parseFragment = function parseFragment(fragmentContext, html, options) { + if (typeof fragmentContext === 'string') { + options = html; + html = fragmentContext; + fragmentContext = null; } - var /** @type {?} */ strValue = (value); - var /** @type {?} */ isDynamic = strValue.split(/\s+/).some(function (v) { return v.charAt(0) == '{' && v.charAt(1) == '{'; }); - if (isDynamic) { - return new DynamicTimingAst(strValue); - } - timings = timings || resolveTiming(strValue, errors); - return new TimingAst(timings.duration, timings.delay, timings.easing); -} -/** - * @param {?} options - * @return {?} - */ -function normalizeAnimationOptions(options) { - if (options) { - options = copyObj(options); - if (options['params']) { - options['params'] = ((normalizeParams(options['params']))); + + var parser = new Parser(options); + + return parser.parseFragment(html, fragmentContext); +}; + +exports.serialize = function (node, options) { + var serializer = new Serializer(node, options); + + return serializer.serialize(); +}; + + +// Tree adapters +exports.treeAdapters = { + default: __webpack_require__(38), + htmlparser2: __webpack_require__(120) +}; + + +// Streaming +exports.ParserStream = __webpack_require__(61); +exports.PlainTextConversionStream = __webpack_require__(113); +exports.SerializerStream = __webpack_require__(117); +exports.SAXParser = __webpack_require__(115); + + +/***/ }), +/* 38 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var DOCUMENT_MODE = __webpack_require__(11).DOCUMENT_MODE; + +//Node construction +exports.createDocument = function () { + return { + nodeName: '#document', + mode: DOCUMENT_MODE.NO_QUIRKS, + childNodes: [] + }; +}; + +exports.createDocumentFragment = function () { + return { + nodeName: '#document-fragment', + childNodes: [] + }; +}; + +exports.createElement = function (tagName, namespaceURI, attrs) { + return { + nodeName: tagName, + tagName: tagName, + attrs: attrs, + namespaceURI: namespaceURI, + childNodes: [], + parentNode: null + }; +}; + +exports.createCommentNode = function (data) { + return { + nodeName: '#comment', + data: data, + parentNode: null + }; +}; + +var createTextNode = function (value) { + return { + nodeName: '#text', + value: value, + parentNode: null + }; +}; + + +//Tree mutation +var appendChild = exports.appendChild = function (parentNode, newNode) { + parentNode.childNodes.push(newNode); + newNode.parentNode = parentNode; +}; + +var insertBefore = exports.insertBefore = function (parentNode, newNode, referenceNode) { + var insertionIdx = parentNode.childNodes.indexOf(referenceNode); + + parentNode.childNodes.splice(insertionIdx, 0, newNode); + newNode.parentNode = parentNode; +}; + +exports.setTemplateContent = function (templateElement, contentElement) { + templateElement.content = contentElement; +}; + +exports.getTemplateContent = function (templateElement) { + return templateElement.content; +}; + +exports.setDocumentType = function (document, name, publicId, systemId) { + var doctypeNode = null; + + for (var i = 0; i < document.childNodes.length; i++) { + if (document.childNodes[i].nodeName === '#documentType') { + doctypeNode = document.childNodes[i]; + break; } } + + if (doctypeNode) { + doctypeNode.name = name; + doctypeNode.publicId = publicId; + doctypeNode.systemId = systemId; + } + else { - options = {}; + appendChild(document, { + nodeName: '#documentType', + name: name, + publicId: publicId, + systemId: systemId + }); } - return options; -} +}; + +exports.setDocumentMode = function (document, mode) { + document.mode = mode; +}; + +exports.getDocumentMode = function (document) { + return document.mode; +}; + +exports.detachNode = function (node) { + if (node.parentNode) { + var idx = node.parentNode.childNodes.indexOf(node); + + node.parentNode.childNodes.splice(idx, 1); + node.parentNode = null; + } +}; + +exports.insertText = function (parentNode, text) { + if (parentNode.childNodes.length) { + var prevNode = parentNode.childNodes[parentNode.childNodes.length - 1]; + + if (prevNode.nodeName === '#text') { + prevNode.value += text; + return; + } + } + + appendChild(parentNode, createTextNode(text)); +}; + +exports.insertTextBefore = function (parentNode, text, referenceNode) { + var prevNode = parentNode.childNodes[parentNode.childNodes.indexOf(referenceNode) - 1]; + + if (prevNode && prevNode.nodeName === '#text') + prevNode.value += text; + else + insertBefore(parentNode, createTextNode(text), referenceNode); +}; + +exports.adoptAttributes = function (recipient, attrs) { + var recipientAttrsMap = []; + + for (var i = 0; i < recipient.attrs.length; i++) + recipientAttrsMap.push(recipient.attrs[i].name); + + for (var j = 0; j < attrs.length; j++) { + if (recipientAttrsMap.indexOf(attrs[j].name) === -1) + recipient.attrs.push(attrs[j]); + } +}; + + +//Tree traversing +exports.getFirstChild = function (node) { + return node.childNodes[0]; +}; + +exports.getChildNodes = function (node) { + return node.childNodes; +}; + +exports.getParentNode = function (node) { + return node.parentNode; +}; + +exports.getAttrList = function (element) { + return element.attrs; +}; + +//Node data +exports.getTagName = function (element) { + return element.tagName; +}; + +exports.getNamespaceURI = function (element) { + return element.namespaceURI; +}; + +exports.getTextNodeContent = function (textNode) { + return textNode.value; +}; + +exports.getCommentNodeContent = function (commentNode) { + return commentNode.data; +}; + +exports.getDocumentTypeNodeName = function (doctypeNode) { + return doctypeNode.name; +}; + +exports.getDocumentTypeNodePublicId = function (doctypeNode) { + return doctypeNode.publicId; +}; + +exports.getDocumentTypeNodeSystemId = function (doctypeNode) { + return doctypeNode.systemId; +}; + +//Node types +exports.isTextNode = function (node) { + return node.nodeName === '#text'; +}; + +exports.isCommentNode = function (node) { + return node.nodeName === '#comment'; +}; + +exports.isDocumentTypeNode = function (node) { + return node.nodeName === '#documentType'; +}; + +exports.isElementNode = function (node) { + return !!node.tagName; +}; + + +/***/ }), +/* 39 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var __extends = (this && this.__extends) || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); +}; +var ArrayObservable_1 = __webpack_require__(16); +var isArray_1 = __webpack_require__(17); +var OuterSubscriber_1 = __webpack_require__(4); +var subscribeToResult_1 = __webpack_require__(3); +var none = {}; +/* tslint:enable:max-line-length */ /** - * @license - * Copyright Google Inc. All Rights Reserved. + * Combines multiple Observables to create an Observable whose values are + * calculated from the latest values of each of its input Observables. * - * 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 - */ -/** - * @param {?} element - * @param {?} keyframes - * @param {?} preStyleProps - * @param {?} postStyleProps - * @param {?} duration - * @param {?} delay - * @param {?=} easing - * @param {?=} subTimeline - * @return {?} + * Whenever any input Observable emits a value, it + * computes a formula using the latest values from all the inputs, then emits + * the output of that formula. + * + * + * + * `combineLatest` combines the values from this Observable with values from + * Observables passed as arguments. This is done by subscribing to each + * Observable, in order, and collecting an array of each of the most recent + * values any time any of the input Observables emits, then either taking that + * array and passing it as arguments to an optional `project` function and + * emitting the return value of that, or just emitting the array of recent + * values directly if there is no `project` function. + * + * @example Dynamically calculate the Body-Mass Index from an Observable of weight and one for height + * var weight = Rx.Observable.of(70, 72, 76, 79, 75); + * var height = Rx.Observable.of(1.76, 1.77, 1.78); + * var bmi = weight.combineLatest(height, (w, h) => w / (h * h)); + * bmi.subscribe(x => console.log('BMI is ' + x)); + * + * // With output to console: + * // BMI is 24.212293388429753 + * // BMI is 23.93948099205209 + * // BMI is 23.671253629592222 + * + * @see {@link combineAll} + * @see {@link merge} + * @see {@link withLatestFrom} + * + * @param {ObservableInput} other An input Observable to combine with the source + * Observable. More than one input Observables may be given as argument. + * @param {function} [project] An optional function to project the values from + * the combined latest values into a new value on the output Observable. + * @return {Observable} An Observable of projected values from the most recent + * values from each input Observable, or an array of the most recent values from + * each input Observable. + * @method combineLatest + * @owner Observable */ -function createTimelineInstruction(element, keyframes, preStyleProps, postStyleProps, duration, delay, easing, subTimeline) { - if (easing === void 0) { easing = null; } - if (subTimeline === void 0) { subTimeline = false; } - return { - type: 1 /* TimelineAnimation */, - element: element, - keyframes: keyframes, - preStyleProps: preStyleProps, - postStyleProps: postStyleProps, - duration: duration, - delay: delay, - totalTime: duration + delay, easing: easing, subTimeline: subTimeline - }; +function combineLatest() { + var observables = []; + for (var _i = 0; _i < arguments.length; _i++) { + observables[_i - 0] = arguments[_i]; + } + var project = null; + if (typeof observables[observables.length - 1] === 'function') { + project = observables.pop(); + } + // if the first and only other argument besides the resultSelector is an array + // assume it's been called with `combineLatest([obs1, obs2, obs3], project)` + if (observables.length === 1 && isArray_1.isArray(observables[0])) { + observables = observables[0].slice(); + } + observables.unshift(this); + return this.lift.call(new ArrayObservable_1.ArrayObservable(observables), new CombineLatestOperator(project)); } +exports.combineLatest = combineLatest; +var CombineLatestOperator = (function () { + function CombineLatestOperator(project) { + this.project = project; + } + CombineLatestOperator.prototype.call = function (subscriber, source) { + return source.subscribe(new CombineLatestSubscriber(subscriber, this.project)); + }; + return CombineLatestOperator; +}()); +exports.CombineLatestOperator = CombineLatestOperator; /** - * @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 + * We need this JSDoc comment for affecting ESDoc. + * @ignore + * @extends {Ignored} */ -var ElementInstructionMap = (function () { - function ElementInstructionMap() { - this._map = new Map(); +var CombineLatestSubscriber = (function (_super) { + __extends(CombineLatestSubscriber, _super); + function CombineLatestSubscriber(destination, project) { + _super.call(this, destination); + this.project = project; + this.active = 0; + this.values = []; + this.observables = []; } - /** - * @param {?} element - * @return {?} - */ - ElementInstructionMap.prototype.consume = function (element) { - var /** @type {?} */ instructions = this._map.get(element); - if (instructions) { - this._map.delete(element); + CombineLatestSubscriber.prototype._next = function (observable) { + this.values.push(none); + this.observables.push(observable); + }; + CombineLatestSubscriber.prototype._complete = function () { + var observables = this.observables; + var len = observables.length; + if (len === 0) { + this.destination.complete(); } else { - instructions = []; + this.active = len; + this.toRespond = len; + for (var i = 0; i < len; i++) { + var observable = observables[i]; + this.add(subscribeToResult_1.subscribeToResult(this, observable, observable, i)); + } } - return instructions; }; - /** - * @param {?} element - * @param {?} instructions - * @return {?} - */ - ElementInstructionMap.prototype.append = function (element, instructions) { - var /** @type {?} */ existingInstructions = this._map.get(element); - if (!existingInstructions) { - this._map.set(element, existingInstructions = []); + CombineLatestSubscriber.prototype.notifyComplete = function (unused) { + if ((this.active -= 1) === 0) { + this.destination.complete(); } - existingInstructions.push.apply(existingInstructions, instructions); }; - /** - * @param {?} element - * @return {?} - */ - ElementInstructionMap.prototype.has = function (element) { return this._map.has(element); }; - /** - * @return {?} - */ - ElementInstructionMap.prototype.clear = function () { this._map.clear(); }; - return ElementInstructionMap; -}()); -/** - * @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 ONE_FRAME_IN_MILLISECONDS = 1; -/** - * @param {?} driver - * @param {?} rootElement - * @param {?} ast - * @param {?=} startingStyles - * @param {?=} finalStyles - * @param {?=} options - * @param {?=} subInstructions - * @param {?=} errors - * @return {?} - */ -function buildAnimationTimelines(driver, rootElement, ast, startingStyles, finalStyles, options, subInstructions, errors) { - if (startingStyles === void 0) { startingStyles = {}; } - if (finalStyles === void 0) { finalStyles = {}; } - if (errors === void 0) { errors = []; } - return new AnimationTimelineBuilderVisitor().buildKeyframes(driver, rootElement, ast, startingStyles, finalStyles, options, subInstructions, errors); -} -var AnimationTimelineBuilderVisitor = (function () { - function AnimationTimelineBuilderVisitor() { - } - /** - * @param {?} driver - * @param {?} rootElement - * @param {?} ast - * @param {?} startingStyles - * @param {?} finalStyles - * @param {?} options - * @param {?=} subInstructions - * @param {?=} errors - * @return {?} - */ - AnimationTimelineBuilderVisitor.prototype.buildKeyframes = function (driver, rootElement, ast, startingStyles, finalStyles, options, subInstructions, errors) { - if (errors === void 0) { errors = []; } - subInstructions = subInstructions || new ElementInstructionMap(); - var /** @type {?} */ context = new AnimationTimelineContext(driver, rootElement, subInstructions, errors, []); - context.options = options; - context.currentTimeline.setStyles([startingStyles], null, context.errors, options); - ast.visit(this, context); - // this checks to see if an actual animation happened - var /** @type {?} */ timelines = context.timelines.filter(function (timeline) { return timeline.containsAnimation(); }); - if (timelines.length && Object.keys(finalStyles).length) { - var /** @type {?} */ tl = timelines[timelines.length - 1]; - if (!tl.allowOnlyTimelineStyles()) { - tl.setStyles([finalStyles], null, context.errors, options); + CombineLatestSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) { + var values = this.values; + var oldVal = values[outerIndex]; + var toRespond = !this.toRespond + ? 0 + : oldVal === none ? --this.toRespond : this.toRespond; + values[outerIndex] = innerValue; + if (toRespond === 0) { + if (this.project) { + this._tryProject(values); + } + else { + this.destination.next(values.slice()); } } - return timelines.length ? timelines.map(function (timeline) { return timeline.buildKeyframes(); }) : - [createTimelineInstruction(rootElement, [], [], [], 0, 0, '', false)]; - }; - /** - * @param {?} ast - * @param {?} context - * @return {?} - */ - AnimationTimelineBuilderVisitor.prototype.visitTrigger = function (ast, context) { - // these values are not visited in this AST }; - /** - * @param {?} ast - * @param {?} context - * @return {?} - */ - AnimationTimelineBuilderVisitor.prototype.visitState = function (ast, context) { - // these values are not visited in this AST + CombineLatestSubscriber.prototype._tryProject = function (values) { + var result; + try { + result = this.project.apply(this, values); + } + catch (err) { + this.destination.error(err); + return; + } + this.destination.next(result); }; - /** - * @param {?} ast - * @param {?} context - * @return {?} - */ - AnimationTimelineBuilderVisitor.prototype.visitTransition = function (ast, context) { - // these values are not visited in this AST + return CombineLatestSubscriber; +}(OuterSubscriber_1.OuterSubscriber)); +exports.CombineLatestSubscriber = CombineLatestSubscriber; +//# sourceMappingURL=combineLatest.js.map + +/***/ }), +/* 40 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var Observable_1 = __webpack_require__(0); +var isScheduler_1 = __webpack_require__(14); +var ArrayObservable_1 = __webpack_require__(16); +var mergeAll_1 = __webpack_require__(86); +/* tslint:enable:max-line-length */ +/** + * Creates an output Observable which sequentially emits all values from every + * given input Observable after the current Observable. + * + * Concatenates multiple Observables together by + * sequentially emitting their values, one Observable after the other. + * + * + * + * Joins this Observable with multiple other Observables by subscribing to them + * one at a time, starting with the source, and merging their results into the + * output Observable. Will wait for each Observable to complete before moving + * on to the next. + * + * @example Concatenate a timer counting from 0 to 3 with a synchronous sequence from 1 to 10 + * var timer = Rx.Observable.interval(1000).take(4); + * var sequence = Rx.Observable.range(1, 10); + * var result = timer.concat(sequence); + * result.subscribe(x => console.log(x)); + * + * // results in: + * // 1000ms-> 0 -1000ms-> 1 -1000ms-> 2 -1000ms-> 3 -immediate-> 1 ... 10 + * + * @example Concatenate 3 Observables + * var timer1 = Rx.Observable.interval(1000).take(10); + * var timer2 = Rx.Observable.interval(2000).take(6); + * var timer3 = Rx.Observable.interval(500).take(10); + * var result = timer1.concat(timer2, timer3); + * result.subscribe(x => console.log(x)); + * + * // results in the following: + * // (Prints to console sequentially) + * // -1000ms-> 0 -1000ms-> 1 -1000ms-> ... 9 + * // -2000ms-> 0 -2000ms-> 1 -2000ms-> ... 5 + * // -500ms-> 0 -500ms-> 1 -500ms-> ... 9 + * + * @see {@link concatAll} + * @see {@link concatMap} + * @see {@link concatMapTo} + * + * @param {ObservableInput} other An input Observable to concatenate after the source + * Observable. More than one input Observables may be given as argument. + * @param {Scheduler} [scheduler=null] An optional IScheduler to schedule each + * Observable subscription on. + * @return {Observable} All values of each passed Observable merged into a + * single Observable, in order, in serial fashion. + * @method concat + * @owner Observable + */ +function concat() { + var observables = []; + for (var _i = 0; _i < arguments.length; _i++) { + observables[_i - 0] = arguments[_i]; + } + return this.lift.call(concatStatic.apply(void 0, [this].concat(observables))); +} +exports.concat = concat; +/* tslint:enable:max-line-length */ +/** + * Creates an output Observable which sequentially emits all values from given + * Observable and then moves on to the next. + * + * Concatenates multiple Observables together by + * sequentially emitting their values, one Observable after the other. + * + * + * + * `concat` joins multiple Observables together, by subscribing to them one at a time and + * merging their results into the output Observable. You can pass either an array of + * Observables, or put them directly as arguments. Passing an empty array will result + * in Observable that completes immediately. + * + * `concat` will subscribe to first input Observable and emit all its values, without + * changing or affecting them in any way. When that Observable completes, it will + * subscribe to then next Observable passed and, again, emit its values. This will be + * repeated, until the operator runs out of Observables. When last input Observable completes, + * `concat` will complete as well. At any given moment only one Observable passed to operator + * emits values. If you would like to emit values from passed Observables concurrently, check out + * {@link merge} instead, especially with optional `concurrent` parameter. As a matter of fact, + * `concat` is an equivalent of `merge` operator with `concurrent` parameter set to `1`. + * + * Note that if some input Observable never completes, `concat` will also never complete + * and Observables following the one that did not complete will never be subscribed. On the other + * hand, if some Observable simply completes immediately after it is subscribed, it will be + * invisible for `concat`, which will just move on to the next Observable. + * + * If any Observable in chain errors, instead of passing control to the next Observable, + * `concat` will error immediately as well. Observables that would be subscribed after + * the one that emitted error, never will. + * + * If you pass to `concat` the same Observable many times, its stream of values + * will be "replayed" on every subscription, which means you can repeat given Observable + * as many times as you like. If passing the same Observable to `concat` 1000 times becomes tedious, + * you can always use {@link repeat}. + * + * @example Concatenate a timer counting from 0 to 3 with a synchronous sequence from 1 to 10 + * var timer = Rx.Observable.interval(1000).take(4); + * var sequence = Rx.Observable.range(1, 10); + * var result = Rx.Observable.concat(timer, sequence); + * result.subscribe(x => console.log(x)); + * + * // results in: + * // 0 -1000ms-> 1 -1000ms-> 2 -1000ms-> 3 -immediate-> 1 ... 10 + * + * + * @example Concatenate an array of 3 Observables + * var timer1 = Rx.Observable.interval(1000).take(10); + * var timer2 = Rx.Observable.interval(2000).take(6); + * var timer3 = Rx.Observable.interval(500).take(10); + * var result = Rx.Observable.concat([timer1, timer2, timer3]); // note that array is passed + * result.subscribe(x => console.log(x)); + * + * // results in the following: + * // (Prints to console sequentially) + * // -1000ms-> 0 -1000ms-> 1 -1000ms-> ... 9 + * // -2000ms-> 0 -2000ms-> 1 -2000ms-> ... 5 + * // -500ms-> 0 -500ms-> 1 -500ms-> ... 9 + * + * + * @example Concatenate the same Observable to repeat it + * const timer = Rx.Observable.interval(1000).take(2); + * + * Rx.Observable.concat(timer, timer) // concating the same Observable! + * .subscribe( + * value => console.log(value), + * err => {}, + * () => console.log('...and it is done!') + * ); + * + * // Logs: + * // 0 after 1s + * // 1 after 2s + * // 0 after 3s + * // 1 after 4s + * // "...and it is done!" also after 4s + * + * @see {@link concatAll} + * @see {@link concatMap} + * @see {@link concatMapTo} + * + * @param {ObservableInput} input1 An input Observable to concatenate with others. + * @param {ObservableInput} input2 An input Observable to concatenate with others. + * More than one input Observables may be given as argument. + * @param {Scheduler} [scheduler=null] An optional IScheduler to schedule each + * Observable subscription on. + * @return {Observable} All values of each passed Observable merged into a + * single Observable, in order, in serial fashion. + * @static true + * @name concat + * @owner Observable + */ +function concatStatic() { + var observables = []; + for (var _i = 0; _i < arguments.length; _i++) { + observables[_i - 0] = arguments[_i]; + } + var scheduler = null; + var args = observables; + if (isScheduler_1.isScheduler(args[observables.length - 1])) { + scheduler = args.pop(); + } + if (scheduler === null && observables.length === 1 && observables[0] instanceof Observable_1.Observable) { + return observables[0]; + } + return new ArrayObservable_1.ArrayObservable(observables, scheduler).lift(new mergeAll_1.MergeAllOperator(1)); +} +exports.concatStatic = concatStatic; +//# sourceMappingURL=concat.js.map + +/***/ }), +/* 41 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var __extends = (this && this.__extends) || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); +}; +var ArrayObservable_1 = __webpack_require__(16); +var isArray_1 = __webpack_require__(17); +var Subscriber_1 = __webpack_require__(2); +var OuterSubscriber_1 = __webpack_require__(4); +var subscribeToResult_1 = __webpack_require__(3); +var iterator_1 = __webpack_require__(87); +/* tslint:enable:max-line-length */ +/** + * @param observables + * @return {Observable} + * @method zip + * @owner Observable + */ +function zipProto() { + var observables = []; + for (var _i = 0; _i < arguments.length; _i++) { + observables[_i - 0] = arguments[_i]; + } + return this.lift.call(zipStatic.apply(void 0, [this].concat(observables))); +} +exports.zipProto = zipProto; +/* tslint:enable:max-line-length */ +/** + * Combines multiple Observables to create an Observable whose values are calculated from the values, in order, of each + * of its input Observables. + * + * If the latest parameter is a function, this function is used to compute the created value from the input values. + * Otherwise, an array of the input values is returned. + * + * @example Combine age and name from different sources + * + * let age$ = Observable.of(27, 25, 29); + * let name$ = Observable.of('Foo', 'Bar', 'Beer'); + * let isDev$ = Observable.of(true, true, false); + * + * Observable + * .zip(age$, + * name$, + * isDev$, + * (age: number, name: string, isDev: boolean) => ({ age, name, isDev })) + * .subscribe(x => console.log(x)); + * + * // outputs + * // { age: 27, name: 'Foo', isDev: true } + * // { age: 25, name: 'Bar', isDev: true } + * // { age: 29, name: 'Beer', isDev: false } + * + * @param observables + * @return {Observable} + * @static true + * @name zip + * @owner Observable + */ +function zipStatic() { + var observables = []; + for (var _i = 0; _i < arguments.length; _i++) { + observables[_i - 0] = arguments[_i]; + } + var project = observables[observables.length - 1]; + if (typeof project === 'function') { + observables.pop(); + } + return new ArrayObservable_1.ArrayObservable(observables).lift(new ZipOperator(project)); +} +exports.zipStatic = zipStatic; +var ZipOperator = (function () { + function ZipOperator(project) { + this.project = project; + } + ZipOperator.prototype.call = function (subscriber, source) { + return source.subscribe(new ZipSubscriber(subscriber, this.project)); }; - /** - * @param {?} ast - * @param {?} context - * @return {?} - */ - AnimationTimelineBuilderVisitor.prototype.visitAnimateChild = function (ast, context) { - var /** @type {?} */ elementInstructions = context.subInstructions.consume(context.element); - if (elementInstructions) { - var /** @type {?} */ innerContext = context.createSubContext(ast.options); - var /** @type {?} */ startTime = context.currentTimeline.currentTime; - var /** @type {?} */ endTime = this._visitSubInstructions(elementInstructions, innerContext, /** @type {?} */ (innerContext.options)); - if (startTime != endTime) { - // we do this on the upper context because we created a sub context for - // the sub child animations - context.transformIntoNewTimeline(endTime); - } + return ZipOperator; +}()); +exports.ZipOperator = ZipOperator; +/** + * We need this JSDoc comment for affecting ESDoc. + * @ignore + * @extends {Ignored} + */ +var ZipSubscriber = (function (_super) { + __extends(ZipSubscriber, _super); + function ZipSubscriber(destination, project, values) { + if (values === void 0) { values = Object.create(null); } + _super.call(this, destination); + this.iterators = []; + this.active = 0; + this.project = (typeof project === 'function') ? project : null; + this.values = values; + } + ZipSubscriber.prototype._next = function (value) { + var iterators = this.iterators; + if (isArray_1.isArray(value)) { + iterators.push(new StaticArrayIterator(value)); + } + else if (typeof value[iterator_1.iterator] === 'function') { + iterators.push(new StaticIterator(value[iterator_1.iterator]())); + } + else { + iterators.push(new ZipBufferIterator(this.destination, this, value)); } - context.previousNode = ast; - }; - /** - * @param {?} ast - * @param {?} context - * @return {?} - */ - AnimationTimelineBuilderVisitor.prototype.visitAnimateRef = function (ast, context) { - var /** @type {?} */ innerContext = context.createSubContext(ast.options); - innerContext.transformIntoNewTimeline(); - this.visitReference(ast.animation, innerContext); - context.transformIntoNewTimeline(innerContext.currentTimeline.currentTime); - context.previousNode = ast; }; - /** - * @param {?} instructions - * @param {?} context - * @param {?} options - * @return {?} - */ - AnimationTimelineBuilderVisitor.prototype._visitSubInstructions = function (instructions, context, options) { - var /** @type {?} */ startTime = context.currentTimeline.currentTime; - var /** @type {?} */ furthestTime = startTime; - // this is a special-case for when a user wants to skip a sub - // animation from being fired entirely. - var /** @type {?} */ duration = options.duration != null ? resolveTimingValue(options.duration) : null; - var /** @type {?} */ delay = options.delay != null ? resolveTimingValue(options.delay) : null; - if (duration !== 0) { - instructions.forEach(function (instruction) { - var /** @type {?} */ instructionTimings = context.appendInstructionToTimeline(instruction, duration, delay); - furthestTime = - Math.max(furthestTime, instructionTimings.duration + instructionTimings.delay); - }); + ZipSubscriber.prototype._complete = function () { + var iterators = this.iterators; + var len = iterators.length; + if (len === 0) { + this.destination.complete(); + return; + } + this.active = len; + for (var i = 0; i < len; i++) { + var iterator = iterators[i]; + if (iterator.stillUnsubscribed) { + this.add(iterator.subscribe(iterator, i)); + } + else { + this.active--; // not an observable + } } - return furthestTime; }; - /** - * @param {?} ast - * @param {?} context - * @return {?} - */ - AnimationTimelineBuilderVisitor.prototype.visitReference = function (ast, context) { - context.updateOptions(ast.options, true); - ast.animation.visit(this, context); - context.previousNode = ast; + ZipSubscriber.prototype.notifyInactive = function () { + this.active--; + if (this.active === 0) { + this.destination.complete(); + } }; - /** - * @param {?} ast - * @param {?} context - * @return {?} - */ - AnimationTimelineBuilderVisitor.prototype.visitSequence = function (ast, context) { - var _this = this; - var /** @type {?} */ subContextCount = context.subContextCount; - var /** @type {?} */ ctx = context; - var /** @type {?} */ options = ast.options; - if (options && (options.params || options.delay)) { - ctx = context.createSubContext(options); - ctx.transformIntoNewTimeline(); - if (options.delay != null) { - if (ctx.previousNode instanceof StyleAst) { - ctx.currentTimeline.snapshotCurrentStyles(); - ctx.previousNode = DEFAULT_NOOP_PREVIOUS_NODE; - } - var /** @type {?} */ delay = resolveTimingValue(options.delay); - ctx.delayNextStep(delay); + ZipSubscriber.prototype.checkIterators = function () { + var iterators = this.iterators; + var len = iterators.length; + var destination = this.destination; + // abort if not all of them have values + for (var i = 0; i < len; i++) { + var iterator = iterators[i]; + if (typeof iterator.hasValue === 'function' && !iterator.hasValue()) { + return; } } - if (ast.steps.length) { - ast.steps.forEach(function (s) { return s.visit(_this, ctx); }); - // this is here just incase the inner steps only contain or end with a style() call - ctx.currentTimeline.applyStylesToKeyframe(); - // this means that some animation function within the sequence - // ended up creating a sub timeline (which means the current - // timeline cannot overlap with the contents of the sequence) - if (ctx.subContextCount > subContextCount) { - ctx.transformIntoNewTimeline(); + var shouldComplete = false; + var args = []; + for (var i = 0; i < len; i++) { + var iterator = iterators[i]; + var result = iterator.next(); + // check to see if it's completed now that you've gotten + // the next value. + if (iterator.hasCompleted()) { + shouldComplete = true; } - } - context.previousNode = ast; - }; - /** - * @param {?} ast - * @param {?} context - * @return {?} - */ - AnimationTimelineBuilderVisitor.prototype.visitGroup = function (ast, context) { - var _this = this; - var /** @type {?} */ innerTimelines = []; - var /** @type {?} */ furthestTime = context.currentTimeline.currentTime; - var /** @type {?} */ delay = ast.options && ast.options.delay ? resolveTimingValue(ast.options.delay) : 0; - ast.steps.forEach(function (s) { - var /** @type {?} */ innerContext = context.createSubContext(ast.options); - if (delay) { - innerContext.delayNextStep(delay); + if (result.done) { + destination.complete(); + return; } - s.visit(_this, innerContext); - furthestTime = Math.max(furthestTime, innerContext.currentTimeline.currentTime); - innerTimelines.push(innerContext.currentTimeline); - }); - // this operation is run after the AST loop because otherwise - // if the parent timeline's collected styles were updated then - // it would pass in invalid data into the new-to-be forked items - innerTimelines.forEach(function (timeline) { return context.currentTimeline.mergeTimelineCollectedStyles(timeline); }); - context.transformIntoNewTimeline(furthestTime); - context.previousNode = ast; - }; - /** - * @param {?} ast - * @param {?} context - * @return {?} - */ - AnimationTimelineBuilderVisitor.prototype.visitTiming = function (ast, context) { - if (ast instanceof DynamicTimingAst) { - var /** @type {?} */ strValue = context.params ? - interpolateParams(ast.value, context.params, context.errors) : - ast.value.toString(); - return resolveTiming(strValue, context.errors); + args.push(result.value); + } + if (this.project) { + this._tryProject(args); } else { - return { duration: ast.duration, delay: ast.delay, easing: ast.easing }; + destination.next(args); + } + if (shouldComplete) { + destination.complete(); } }; - /** - * @param {?} ast - * @param {?} context - * @return {?} - */ - AnimationTimelineBuilderVisitor.prototype.visitAnimate = function (ast, context) { - var /** @type {?} */ timings = context.currentAnimateTimings = this.visitTiming(ast.timings, context); - var /** @type {?} */ timeline = context.currentTimeline; - if (timings.delay) { - context.incrementTime(timings.delay); - timeline.snapshotCurrentStyles(); + ZipSubscriber.prototype._tryProject = function (args) { + var result; + try { + result = this.project.apply(this, args); } - var /** @type {?} */ style$$1 = ast.style; - if (style$$1 instanceof KeyframesAst) { - this.visitKeyframes(style$$1, context); + catch (err) { + this.destination.error(err); + return; } - else { - context.incrementTime(timings.duration); - this.visitStyle(/** @type {?} */ (style$$1), context); - timeline.applyStylesToKeyframe(); - } - context.currentAnimateTimings = null; - context.previousNode = ast; + this.destination.next(result); }; - /** - * @param {?} ast - * @param {?} context - * @return {?} - */ - AnimationTimelineBuilderVisitor.prototype.visitStyle = function (ast, context) { - var /** @type {?} */ timeline = context.currentTimeline; - var /** @type {?} */ timings = ((context.currentAnimateTimings)); - // this is a special case for when a style() call - // directly follows an animate() call (but not inside of an animate() call) - if (!timings && timeline.getCurrentStyleProperties().length) { - timeline.forwardFrame(); + return ZipSubscriber; +}(Subscriber_1.Subscriber)); +exports.ZipSubscriber = ZipSubscriber; +var StaticIterator = (function () { + function StaticIterator(iterator) { + this.iterator = iterator; + this.nextResult = iterator.next(); + } + StaticIterator.prototype.hasValue = function () { + return true; + }; + StaticIterator.prototype.next = function () { + var result = this.nextResult; + this.nextResult = this.iterator.next(); + return result; + }; + StaticIterator.prototype.hasCompleted = function () { + var nextResult = this.nextResult; + return nextResult && nextResult.done; + }; + return StaticIterator; +}()); +var StaticArrayIterator = (function () { + function StaticArrayIterator(array) { + this.array = array; + this.index = 0; + this.length = 0; + this.length = array.length; + } + StaticArrayIterator.prototype[iterator_1.iterator] = function () { + return this; + }; + StaticArrayIterator.prototype.next = function (value) { + var i = this.index++; + var array = this.array; + return i < this.length ? { value: array[i], done: false } : { value: null, done: true }; + }; + StaticArrayIterator.prototype.hasValue = function () { + return this.array.length > this.index; + }; + StaticArrayIterator.prototype.hasCompleted = function () { + return this.array.length === this.index; + }; + return StaticArrayIterator; +}()); +/** + * We need this JSDoc comment for affecting ESDoc. + * @ignore + * @extends {Ignored} + */ +var ZipBufferIterator = (function (_super) { + __extends(ZipBufferIterator, _super); + function ZipBufferIterator(destination, parent, observable) { + _super.call(this, destination); + this.parent = parent; + this.observable = observable; + this.stillUnsubscribed = true; + this.buffer = []; + this.isComplete = false; + } + ZipBufferIterator.prototype[iterator_1.iterator] = function () { + return this; + }; + // NOTE: there is actually a name collision here with Subscriber.next and Iterator.next + // this is legit because `next()` will never be called by a subscription in this case. + ZipBufferIterator.prototype.next = function () { + var buffer = this.buffer; + if (buffer.length === 0 && this.isComplete) { + return { value: null, done: true }; } - var /** @type {?} */ easing = (timings && timings.easing) || ast.easing; - if (ast.isEmptyStep) { - timeline.applyEmptyStep(easing); + else { + return { value: buffer.shift(), done: false }; + } + }; + ZipBufferIterator.prototype.hasValue = function () { + return this.buffer.length > 0; + }; + ZipBufferIterator.prototype.hasCompleted = function () { + return this.buffer.length === 0 && this.isComplete; + }; + ZipBufferIterator.prototype.notifyComplete = function () { + if (this.buffer.length > 0) { + this.isComplete = true; + this.parent.notifyInactive(); } else { - timeline.setStyles(ast.styles, easing, context.errors, context.options); + this.destination.complete(); } - context.previousNode = ast; }; + ZipBufferIterator.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) { + this.buffer.push(innerValue); + this.parent.checkIterators(); + }; + ZipBufferIterator.prototype.subscribe = function (value, index) { + return subscribeToResult_1.subscribeToResult(this, this.observable, this, index); + }; + return ZipBufferIterator; +}(OuterSubscriber_1.OuterSubscriber)); +//# sourceMappingURL=zip.js.map + +/***/ }), +/* 42 */ +/***/ (function(module, exports, __webpack_require__) { + +module.exports = (__webpack_require__(1))(26); + +/***/ }), +/* 43 */ +/***/ (function(module, exports, __webpack_require__) { + +module.exports = (__webpack_require__(1))(36); + +/***/ }), +/* 44 */ +/***/ (function(module, exports, __webpack_require__) { + +module.exports = (__webpack_require__(1))(5); + +/***/ }), +/* 45 */ +/***/ (function(module, exports, __webpack_require__) { + +module.exports = (__webpack_require__(1))(65); + +/***/ }), +/* 46 */ +/***/ (function(module, exports, __webpack_require__) { + +module.exports = (__webpack_require__(1))(82); + +/***/ }), +/* 47 */ +/***/ (function(module, exports, __webpack_require__) { + +module.exports = (__webpack_require__(1))(88); + +/***/ }), +/* 48 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @license Angular v4.2.5 + * (c) 2010-2017 Google, Inc. https://angular.io/ + * License: MIT + */ +(function (global, factory) { + true ? factory(exports, __webpack_require__(10), __webpack_require__(44), __webpack_require__(34), __webpack_require__(13), __webpack_require__(378), __webpack_require__(30), __webpack_require__(50), __webpack_require__(0), __webpack_require__(6), __webpack_require__(93), __webpack_require__(46), __webpack_require__(91), __webpack_require__(77)) : + typeof define === 'function' && define.amd ? define(['exports', '@angular/core', '@angular/platform-browser', '@angular/animations/browser', '@angular/common', '@angular/compiler', '@angular/http', '@angular/platform-browser/animations', 'rxjs/Observable', 'rxjs/Subject', 'url', 'rxjs/operator/filter', 'rxjs/operator/first', 'rxjs/operator/toPromise'], factory) : + (factory((global.ng = global.ng || {}, global.ng.platformServer = global.ng.platformServer || {}),global.ng.core,global.ng.platformBrowser,global._angular_animations_browser,global.ng.common,global.ng.compiler,global._angular_http,global._angular_platformBrowser_animations,global.Rx,global.Rx,global.url,global.Rx.Observable.prototype,global.Rx.Observable.prototype,global.Rx.Observable.prototype)); +}(this, (function (exports,_angular_core,_angular_platformBrowser,_angular_animations_browser,_angular_common,_angular_compiler,_angular_http,_angular_platformBrowser_animations,rxjs_Observable,rxjs_Subject,url,rxjs_operator_filter,rxjs_operator_first,rxjs_operator_toPromise) { 'use strict'; + +/*! ***************************************************************************** +Copyright (c) Microsoft Corporation. All rights reserved. +Licensed under the Apache License, Version 2.0 (the "License"); you may not use +this file except in compliance with the License. You may obtain a copy of the +License at http://www.apache.org/licenses/LICENSE-2.0 + +THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED +WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, +MERCHANTABLITY OR NON-INFRINGEMENT. + +See the Apache Version 2.0 License for specific language governing permissions +and limitations under the License. +***************************************************************************** */ +/* global Reflect, Promise */ + +var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + +function __extends(d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); +} + +/** + * @license Angular v4.2.5 + * (c) 2010-2017 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 parse5 = __webpack_require__(37); +/** + * Representation of the current platform state. + * + * \@experimental + */ +var PlatformState = (function () { /** - * @param {?} ast - * @param {?} context + * @param {?} _doc + */ + function PlatformState(_doc) { + this._doc = _doc; + } + /** + * Renders the current state of the platform to string. * @return {?} */ - AnimationTimelineBuilderVisitor.prototype.visitKeyframes = function (ast, context) { - var /** @type {?} */ currentAnimateTimings = ((context.currentAnimateTimings)); - var /** @type {?} */ startTime = (((context.currentTimeline))).duration; - var /** @type {?} */ duration = currentAnimateTimings.duration; - var /** @type {?} */ innerContext = context.createSubContext(); - var /** @type {?} */ innerTimeline = innerContext.currentTimeline; - innerTimeline.easing = currentAnimateTimings.easing; - ast.styles.forEach(function (step) { - var /** @type {?} */ offset = step.offset || 0; - innerTimeline.forwardTime(offset * duration); - innerTimeline.setStyles(step.styles, step.easing, context.errors, context.options); - innerTimeline.applyStylesToKeyframe(); - }); - // this will ensure that the parent timeline gets all the styles from - // the child even if the new timeline below is not used - context.currentTimeline.mergeTimelineCollectedStyles(innerTimeline); - // we do this because the window between this timeline and the sub timeline - // should ensure that the styles within are exactly the same as they were before - context.transformIntoNewTimeline(startTime + duration); - context.previousNode = ast; - }; + PlatformState.prototype.renderToString = function () { return _angular_platformBrowser.ɵgetDOM().getInnerHTML(this._doc); }; /** - * @param {?} ast - * @param {?} context + * Returns the current DOM state. * @return {?} */ - AnimationTimelineBuilderVisitor.prototype.visitQuery = function (ast, context) { - var _this = this; - // in the event that the first step before this is a style step we need - // to ensure the styles are applied before the children are animated - var /** @type {?} */ startTime = context.currentTimeline.currentTime; - var /** @type {?} */ options = ((ast.options || {})); - var /** @type {?} */ delay = options.delay ? resolveTimingValue(options.delay) : 0; - if (delay && (context.previousNode instanceof StyleAst || - (startTime == 0 && context.currentTimeline.getCurrentStyleProperties().length))) { - context.currentTimeline.snapshotCurrentStyles(); - context.previousNode = DEFAULT_NOOP_PREVIOUS_NODE; - } - var /** @type {?} */ furthestTime = startTime; - var /** @type {?} */ elms = context.invokeQuery(ast.selector, ast.originalSelector, ast.limit, ast.includeSelf, options.optional ? true : false, context.errors); - context.currentQueryTotal = elms.length; - var /** @type {?} */ sameElementTimeline = null; - elms.forEach(function (element, i) { - context.currentQueryIndex = i; - var /** @type {?} */ innerContext = context.createSubContext(ast.options, element); - if (delay) { - innerContext.delayNextStep(delay); - } - if (element === context.element) { - sameElementTimeline = innerContext.currentTimeline; - } - ast.animation.visit(_this, innerContext); - // this is here just incase the inner steps only contain or end - // with a style() call (which is here to signal that this is a preparatory - // call to style an element before it is animated again) - innerContext.currentTimeline.applyStylesToKeyframe(); - var /** @type {?} */ endTime = innerContext.currentTimeline.currentTime; - furthestTime = Math.max(furthestTime, endTime); - }); - context.currentQueryIndex = 0; - context.currentQueryTotal = 0; - context.transformIntoNewTimeline(furthestTime); - if (sameElementTimeline) { - context.currentTimeline.mergeTimelineCollectedStyles(sameElementTimeline); - context.currentTimeline.snapshotCurrentStyles(); - } - context.previousNode = ast; - }; + PlatformState.prototype.getDocument = function () { return this._doc; }; + return PlatformState; +}()); +PlatformState.decorators = [ + { type: _angular_core.Injectable }, +]; +/** + * @nocollapse + */ +PlatformState.ctorParameters = function () { return [ + { type: undefined, decorators: [{ type: _angular_core.Inject, args: [_angular_platformBrowser.DOCUMENT,] },] }, +]; }; +/** + * @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 xhr2 = __webpack_require__(375); +var isAbsoluteUrl = /^[a-zA-Z\-\+.]+:\/\//; +/** + * @param {?} url + * @return {?} + */ +function validateRequestUrl(url$$1) { + if (!isAbsoluteUrl.test(url$$1)) { + throw new Error("URLs requested via Http on the server must be absolute. URL: " + url$$1); + } +} +var ServerXhr = (function () { + function ServerXhr() { + } /** - * @param {?} ast - * @param {?} context * @return {?} */ - AnimationTimelineBuilderVisitor.prototype.visitStagger = function (ast, context) { - var /** @type {?} */ parentContext = ((context.parentContext)); - var /** @type {?} */ tl = context.currentTimeline; - var /** @type {?} */ timings = ast.timings; - var /** @type {?} */ duration = Math.abs(timings.duration); - var /** @type {?} */ maxTime = duration * (context.currentQueryTotal - 1); - var /** @type {?} */ delay = duration * context.currentQueryIndex; - var /** @type {?} */ staggerTransformer = timings.duration < 0 ? 'reverse' : timings.easing; - switch (staggerTransformer) { - case 'reverse': - delay = maxTime - delay; - break; - case 'full': - delay = parentContext.currentStaggerTime; - break; - } - var /** @type {?} */ timeline = context.currentTimeline; - if (delay) { - timeline.delayNextStep(delay); - } - var /** @type {?} */ startingTime = timeline.currentTime; - ast.animation.visit(this, context); - context.previousNode = ast; - // time = duration + delay - // the reason why this computation is so complex is because - // the inner timeline may either have a delay value or a stretched - // keyframe depending on if a subtimeline is not used or is used. - parentContext.currentStaggerTime = - (tl.currentTime - startingTime) + (tl.startTime - parentContext.currentTimeline.startTime); - }; - return AnimationTimelineBuilderVisitor; + ServerXhr.prototype.build = function () { return new xhr2.XMLHttpRequest(); }; + return ServerXhr; }()); -var DEFAULT_NOOP_PREVIOUS_NODE = ({}); -var AnimationTimelineContext = (function () { +ServerXhr.decorators = [ + { type: _angular_core.Injectable }, +]; +/** + * @nocollapse + */ +ServerXhr.ctorParameters = function () { return []; }; +var ServerXsrfStrategy = (function () { + function ServerXsrfStrategy() { + } /** - * @param {?} _driver - * @param {?} element - * @param {?} subInstructions - * @param {?} errors - * @param {?} timelines - * @param {?=} initialTimeline + * @param {?} req + * @return {?} */ - function AnimationTimelineContext(_driver, element, subInstructions, errors, timelines, initialTimeline) { - this._driver = _driver; - this.element = element; - this.subInstructions = subInstructions; - this.errors = errors; - this.timelines = timelines; - this.parentContext = null; - this.currentAnimateTimings = null; - this.previousNode = DEFAULT_NOOP_PREVIOUS_NODE; - this.subContextCount = 0; - this.options = {}; - this.currentQueryIndex = 0; - this.currentQueryTotal = 0; - this.currentStaggerTime = 0; - this.currentTimeline = initialTimeline || new TimelineBuilder(element, 0); - timelines.push(this.currentTimeline); + ServerXsrfStrategy.prototype.configureRequest = function (req) { }; + return ServerXsrfStrategy; +}()); +ServerXsrfStrategy.decorators = [ + { type: _angular_core.Injectable }, +]; +/** + * @nocollapse + */ +ServerXsrfStrategy.ctorParameters = function () { return []; }; +var ZoneMacroTaskConnection = (function () { + /** + * @param {?} request + * @param {?} backend + */ + function ZoneMacroTaskConnection(request, backend) { + var _this = this; + this.request = request; + validateRequestUrl(request.url); + this.response = new rxjs_Observable.Observable(function (observer) { + var task = null; + var scheduled = false; + var sub = null; + var savedResult = null; + var savedError = null; + var scheduleTask = function (_task) { + task = _task; + scheduled = true; + _this.lastConnection = backend.createConnection(request); + sub = _this.lastConnection.response + .subscribe(function (res) { return savedResult = res; }, function (err) { + if (!scheduled) { + throw new Error('invoke twice'); + } + savedError = err; + scheduled = false; + task.invoke(); + }, function () { + if (!scheduled) { + throw new Error('invoke twice'); + } + scheduled = false; + task.invoke(); + }); + }; + var cancelTask = function (_task) { + if (!scheduled) { + return; + } + scheduled = false; + if (sub) { + sub.unsubscribe(); + sub = null; + } + }; + var onComplete = function () { + if (savedError !== null) { + observer.error(savedError); + } + else { + observer.next(savedResult); + observer.complete(); + } + }; + // MockBackend is currently synchronous, which means that if scheduleTask is by + // scheduleMacroTask, the request will hit MockBackend and the response will be + // sent, causing task.invoke() to be called. + var _task = Zone.current.scheduleMacroTask('ZoneMacroTaskConnection.subscribe', onComplete, {}, function () { return null; }, cancelTask); + scheduleTask(_task); + return function () { + if (scheduled && task) { + task.zone.cancelTask(task); + scheduled = false; + } + if (sub) { + sub.unsubscribe(); + sub = null; + } + }; + }); } - Object.defineProperty(AnimationTimelineContext.prototype, "params", { + Object.defineProperty(ZoneMacroTaskConnection.prototype, "readyState", { /** * @return {?} */ - get: function () { return this.options.params; }, + get: function () { + return !!this.lastConnection ? this.lastConnection.readyState : _angular_http.ReadyState.Unsent; + }, enumerable: true, configurable: true }); + return ZoneMacroTaskConnection; +}()); +var ZoneMacroTaskBackend = (function () { /** - * @param {?} options - * @param {?=} skipIfExists - * @return {?} + * @param {?} backend */ - AnimationTimelineContext.prototype.updateOptions = function (options, skipIfExists) { - var _this = this; - if (!options) - return; - var /** @type {?} */ newOptions = (options); - var /** @type {?} */ optionsToUpdate = this.options; - // NOTE: this will get patched up when other animation methods support duration overrides - if (newOptions.duration != null) { - ((optionsToUpdate)).duration = resolveTimingValue(newOptions.duration); - } - if (newOptions.delay != null) { - optionsToUpdate.delay = resolveTimingValue(newOptions.delay); - } - var /** @type {?} */ newParams = newOptions.params; - if (newParams) { - var /** @type {?} */ paramsToUpdate_1 = ((optionsToUpdate.params)); - if (!paramsToUpdate_1) { - paramsToUpdate_1 = this.options.params = {}; - } - Object.keys(newParams).forEach(function (name) { - if (!skipIfExists || !paramsToUpdate_1.hasOwnProperty(name)) { - paramsToUpdate_1[name] = interpolateParams(newParams[name], paramsToUpdate_1, _this.errors); - } - }); - } - }; + function ZoneMacroTaskBackend(backend) { + this.backend = backend; + } /** + * @param {?} request * @return {?} */ - AnimationTimelineContext.prototype._copyOptions = function () { - var /** @type {?} */ options = {}; - if (this.options) { - var /** @type {?} */ oldParams_1 = this.options.params; - if (oldParams_1) { - var /** @type {?} */ params_1 = options['params'] = {}; - Object.keys(this.options.params).forEach(function (name) { params_1[name] = oldParams_1[name]; }); - } - } - return options; + ZoneMacroTaskBackend.prototype.createConnection = function (request) { + return new ZoneMacroTaskConnection(request, this.backend); + }; + return ZoneMacroTaskBackend; +}()); +/** + * @param {?} xhrBackend + * @param {?} options + * @return {?} + */ +function httpFactory(xhrBackend, options) { + var /** @type {?} */ macroBackend = new ZoneMacroTaskBackend(xhrBackend); + return new _angular_http.Http(macroBackend, options); +} +var SERVER_HTTP_PROVIDERS = [ + { provide: _angular_http.Http, useFactory: httpFactory, deps: [_angular_http.XHRBackend, _angular_http.RequestOptions] }, + { provide: _angular_http.BrowserXhr, useClass: ServerXhr }, + { provide: _angular_http.XSRFStrategy, useClass: ServerXsrfStrategy }, +]; +/** + * @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 DI token for setting the initial config for the platform. + * + * \@experimental + */ +var INITIAL_CONFIG = new _angular_core.InjectionToken('Server.INITIAL_CONFIG'); +/** + * @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 + */ +/** + * @param {?} urlStr + * @return {?} + */ +function parseUrl(urlStr) { + var /** @type {?} */ parsedUrl = url.parse(urlStr); + return { + pathname: parsedUrl.pathname || '', + search: parsedUrl.search || '', + hash: parsedUrl.hash || '', }; +} +/** + * Server-side implementation of URL state. Implements `pathname`, `search`, and `hash` + * but not the state stack. + */ +var ServerPlatformLocation = (function () { + /** + * @param {?} _doc + * @param {?} _config + */ + function ServerPlatformLocation(_doc, _config) { + this._doc = _doc; + this._path = '/'; + this._search = ''; + this._hash = ''; + this._hashUpdate = new rxjs_Subject.Subject(); + var config = _config; + if (!!config && !!config.url) { + var parsedUrl = parseUrl(config.url); + this._path = parsedUrl.pathname; + this._search = parsedUrl.search; + this._hash = parsedUrl.hash; + } + } /** - * @param {?=} options - * @param {?=} element - * @param {?=} newTime * @return {?} */ - AnimationTimelineContext.prototype.createSubContext = function (options, element, newTime) { - if (options === void 0) { options = null; } - var /** @type {?} */ target = element || this.element; - var /** @type {?} */ context = new AnimationTimelineContext(this._driver, target, this.subInstructions, this.errors, this.timelines, this.currentTimeline.fork(target, newTime || 0)); - context.previousNode = this.previousNode; - context.currentAnimateTimings = this.currentAnimateTimings; - context.options = this._copyOptions(); - context.updateOptions(options); - context.currentQueryIndex = this.currentQueryIndex; - context.currentQueryTotal = this.currentQueryTotal; - context.parentContext = this; - this.subContextCount++; - return context; - }; + ServerPlatformLocation.prototype.getBaseHrefFromDOM = function () { return ((_angular_platformBrowser.ɵgetDOM().getBaseHref(this._doc))); }; /** - * @param {?=} newTime + * @param {?} fn * @return {?} */ - AnimationTimelineContext.prototype.transformIntoNewTimeline = function (newTime) { - this.previousNode = DEFAULT_NOOP_PREVIOUS_NODE; - this.currentTimeline = this.currentTimeline.fork(this.element, newTime); - this.timelines.push(this.currentTimeline); - return this.currentTimeline; + ServerPlatformLocation.prototype.onPopState = function (fn) { + // No-op: a state stack is not implemented, so + // no events will ever come. }; /** - * @param {?} instruction - * @param {?} duration - * @param {?} delay + * @param {?} fn * @return {?} */ - AnimationTimelineContext.prototype.appendInstructionToTimeline = function (instruction, duration, delay) { - var /** @type {?} */ updatedTimings = { - duration: duration != null ? duration : instruction.duration, - delay: this.currentTimeline.currentTime + (delay != null ? delay : 0) + instruction.delay, - easing: '' - }; - var /** @type {?} */ builder = new SubTimelineBuilder(instruction.element, instruction.keyframes, instruction.preStyleProps, instruction.postStyleProps, updatedTimings, instruction.stretchStartingKeyframe); - this.timelines.push(builder); - return updatedTimings; - }; + ServerPlatformLocation.prototype.onHashChange = function (fn) { this._hashUpdate.subscribe(fn); }; + Object.defineProperty(ServerPlatformLocation.prototype, "pathname", { + /** + * @return {?} + */ + get: function () { return this._path; }, + enumerable: true, + configurable: true + }); + Object.defineProperty(ServerPlatformLocation.prototype, "search", { + /** + * @return {?} + */ + get: function () { return this._search; }, + enumerable: true, + configurable: true + }); + Object.defineProperty(ServerPlatformLocation.prototype, "hash", { + /** + * @return {?} + */ + get: function () { return this._hash; }, + enumerable: true, + configurable: true + }); + Object.defineProperty(ServerPlatformLocation.prototype, "url", { + /** + * @return {?} + */ + get: function () { return "" + this.pathname + this.search + this.hash; }, + enumerable: true, + configurable: true + }); /** - * @param {?} time + * @param {?} value + * @param {?} oldUrl * @return {?} */ - AnimationTimelineContext.prototype.incrementTime = function (time) { - this.currentTimeline.forwardTime(this.currentTimeline.duration + time); + ServerPlatformLocation.prototype.setHash = function (value, oldUrl) { + var _this = this; + if (this._hash === value) { + // Don't fire events if the hash has not changed. + return; + } + this._hash = value; + var /** @type {?} */ newUrl = this.url; + scheduleMicroTask(function () { return _this._hashUpdate.next(/** @type {?} */ ({ type: 'hashchange', oldUrl: oldUrl, newUrl: newUrl })); }); }; /** - * @param {?} delay + * @param {?} state + * @param {?} title + * @param {?} newUrl * @return {?} */ - AnimationTimelineContext.prototype.delayNextStep = function (delay) { - // negative delays are not yet supported - if (delay > 0) { - this.currentTimeline.delayNextStep(delay); - } + ServerPlatformLocation.prototype.replaceState = function (state, title, newUrl) { + var /** @type {?} */ oldUrl = this.url; + var /** @type {?} */ parsedUrl = parseUrl(newUrl); + this._path = parsedUrl.pathname; + this._search = parsedUrl.search; + this.setHash(parsedUrl.hash, oldUrl); }; /** - * @param {?} selector - * @param {?} originalSelector - * @param {?} limit - * @param {?} includeSelf - * @param {?} optional - * @param {?} errors + * @param {?} state + * @param {?} title + * @param {?} newUrl * @return {?} */ - AnimationTimelineContext.prototype.invokeQuery = function (selector, originalSelector, limit, includeSelf, optional, errors) { - var /** @type {?} */ results = []; - if (includeSelf) { - results.push(this.element); - } - if (selector.length > 0) { - var /** @type {?} */ multi = limit != 1; - results.push.apply(results, this._driver.query(this.element, selector, multi)); - } - if (!optional && results.length == 0) { - errors.push("`query(\"" + originalSelector + "\")` returned zero elements. (Use `query(\"" + originalSelector + "\", { optional: true })` if you wish to allow this.)"); - } - return results; + ServerPlatformLocation.prototype.pushState = function (state, title, newUrl) { + this.replaceState(state, title, newUrl); }; - return AnimationTimelineContext; -}()); -var TimelineBuilder = (function () { /** - * @param {?} element - * @param {?} startTime - * @param {?=} _elementTimelineStylesLookup + * @return {?} */ - function TimelineBuilder(element, startTime, _elementTimelineStylesLookup) { - this.element = element; - this.startTime = startTime; - this._elementTimelineStylesLookup = _elementTimelineStylesLookup; - this.duration = 0; - this._previousKeyframe = {}; - this._currentKeyframe = {}; - this._keyframes = new Map(); - this._styleSummary = {}; - this._pendingStyles = {}; - this._backFill = {}; - this._currentEmptyStepKeyframe = null; - if (!this._elementTimelineStylesLookup) { - this._elementTimelineStylesLookup = new Map(); - } - this._localTimelineStyles = Object.create(this._backFill, {}); - this._globalTimelineStyles = this._elementTimelineStylesLookup.get(element); - if (!this._globalTimelineStyles) { - this._globalTimelineStyles = this._localTimelineStyles; - this._elementTimelineStylesLookup.set(element, this._localTimelineStyles); - } - this._loadKeyframe(); - } + ServerPlatformLocation.prototype.forward = function () { throw new Error('Not implemented'); }; /** * @return {?} */ - TimelineBuilder.prototype.containsAnimation = function () { - switch (this._keyframes.size) { - case 0: - return false; - case 1: - return this.getCurrentStyleProperties().length > 0; - default: - return true; + ServerPlatformLocation.prototype.back = function () { throw new Error('Not implemented'); }; + return ServerPlatformLocation; +}()); +ServerPlatformLocation.decorators = [ + { type: _angular_core.Injectable }, +]; +/** + * @nocollapse + */ +ServerPlatformLocation.ctorParameters = function () { return [ + { type: undefined, decorators: [{ type: _angular_core.Inject, args: [_angular_platformBrowser.DOCUMENT,] },] }, + { type: undefined, decorators: [{ type: _angular_core.Optional }, { type: _angular_core.Inject, args: [INITIAL_CONFIG,] },] }, +]; }; +/** + * @param {?} fn + * @return {?} + */ +function scheduleMicroTask(fn) { + Zone.current.scheduleMicroTask('scheduleMicrotask', fn); +} +/** + * @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 parse5$1 = __webpack_require__(37); +var treeAdapter; +var _attrToPropMap = { + 'class': 'className', + 'innerHtml': 'innerHTML', + 'readonly': 'readOnly', + 'tabindex': 'tabIndex', +}; +var mapProps = ['attribs', 'x-attribsNamespace', 'x-attribsPrefix']; +/** + * @param {?} methodName + * @return {?} + */ +function _notImplemented(methodName) { + return new Error('This method is not implemented in Parse5DomAdapter: ' + methodName); +} +/** + * @param {?} el + * @param {?} name + * @return {?} + */ +function _getElement(el, name) { + for (var /** @type {?} */ i = 0; i < el.childNodes.length; i++) { + var /** @type {?} */ node = el.childNodes[i]; + if (node.name === name) { + return node; } - }; + } + return null; +} +/** + * Parses a document string to a Document object. + * @param {?} html + * @return {?} + */ +function parseDocument(html) { + var /** @type {?} */ doc = parse5$1.parse(html, { treeAdapter: parse5$1.treeAdapters.htmlparser2 }); + var /** @type {?} */ docElement = _getElement(doc, 'html'); + doc['head'] = _getElement(docElement, 'head'); + doc['body'] = _getElement(docElement, 'body'); + doc['_window'] = {}; + return doc; +} +/** + * A `DomAdapter` powered by the `parse5` NodeJS module. + * + * \@security Tread carefully! Interacting with the DOM directly is dangerous and + * can introduce XSS risks. + */ +var Parse5DomAdapter = (function (_super) { + __extends(Parse5DomAdapter, _super); + function Parse5DomAdapter() { + return _super !== null && _super.apply(this, arguments) || this; + } /** * @return {?} */ - TimelineBuilder.prototype.getCurrentStyleProperties = function () { return Object.keys(this._currentKeyframe); }; - Object.defineProperty(TimelineBuilder.prototype, "currentTime", { - /** - * @return {?} - */ - get: function () { return this.startTime + this.duration; }, - enumerable: true, - configurable: true - }); + Parse5DomAdapter.makeCurrent = function () { + treeAdapter = parse5$1.treeAdapters.htmlparser2; + _angular_platformBrowser.ɵsetRootDomAdapter(new Parse5DomAdapter()); + }; /** - * @param {?} delay + * @param {?} nodeA + * @param {?} nodeB * @return {?} */ - TimelineBuilder.prototype.delayNextStep = function (delay) { - // in the event that a style() step is placed right before a stagger() - // and that style() step is the very first style() value in the animation - // then we need to make a copy of the keyframe [0, copy, 1] so that the delay - // properly applies the style() values to work with the stagger... - var /** @type {?} */ hasPreStyleStep = this._keyframes.size == 1 && Object.keys(this._pendingStyles).length; - if (this.duration || hasPreStyleStep) { - this.forwardTime(this.currentTime + delay); - if (hasPreStyleStep) { - this.snapshotCurrentStyles(); - } - } - else { - this.startTime += delay; + Parse5DomAdapter.prototype.contains = function (nodeA, nodeB) { + var /** @type {?} */ inner = nodeB; + while (inner) { + if (inner === nodeA) + return true; + inner = inner.parent; } + return false; }; /** * @param {?} element - * @param {?=} currentTime + * @param {?} name * @return {?} */ - TimelineBuilder.prototype.fork = function (element, currentTime) { - this.applyStylesToKeyframe(); - return new TimelineBuilder(element, currentTime || this.currentTime, this._elementTimelineStylesLookup); + Parse5DomAdapter.prototype.hasProperty = function (element, name) { + return _HTMLElementPropertyList.indexOf(name) > -1; }; /** + * @param {?} el + * @param {?} name + * @param {?} value * @return {?} */ - TimelineBuilder.prototype._loadKeyframe = function () { - if (this._currentKeyframe) { - this._previousKeyframe = this._currentKeyframe; + Parse5DomAdapter.prototype.setProperty = function (el, name, value) { + if (name === 'innerHTML') { + this.setInnerHTML(el, value); } - this._currentKeyframe = ((this._keyframes.get(this.duration))); - if (!this._currentKeyframe) { - this._currentKeyframe = Object.create(this._backFill, {}); - this._keyframes.set(this.duration, this._currentKeyframe); + else if (name === 'innerText') { + this.setText(el, value); + } + else if (name === 'className') { + el.attribs['class'] = el.className = value; + } + else { + el[name] = value; } }; /** + * @param {?} el + * @param {?} name * @return {?} */ - TimelineBuilder.prototype.forwardFrame = function () { - this.duration += ONE_FRAME_IN_MILLISECONDS; - this._loadKeyframe(); - }; + Parse5DomAdapter.prototype.getProperty = function (el, name) { return el[name]; }; /** - * @param {?} time + * @param {?} error * @return {?} */ - TimelineBuilder.prototype.forwardTime = function (time) { - this.applyStylesToKeyframe(); - this.duration = time; - this._loadKeyframe(); - }; + Parse5DomAdapter.prototype.logError = function (error) { console.error(error); }; /** - * @param {?} prop - * @param {?} value + * @param {?} error * @return {?} */ - TimelineBuilder.prototype._updateStyle = function (prop, value) { - this._localTimelineStyles[prop] = value; - this._globalTimelineStyles[prop] = value; - this._styleSummary[prop] = { time: this.currentTime, value: value }; - }; + Parse5DomAdapter.prototype.log = function (error) { console.log(error); }; /** + * @param {?} error * @return {?} */ - TimelineBuilder.prototype.allowOnlyTimelineStyles = function () { return this._currentEmptyStepKeyframe !== this._currentKeyframe; }; + Parse5DomAdapter.prototype.logGroup = function (error) { console.error(error); }; /** - * @param {?} easing * @return {?} */ - TimelineBuilder.prototype.applyEmptyStep = function (easing) { - var _this = this; - if (easing) { - this._previousKeyframe['easing'] = easing; - } - // special case for animate(duration): - // all missing styles are filled with a `*` value then - // if any destination styles are filled in later on the same - // keyframe then they will override the overridden styles - // We use `_globalTimelineStyles` here because there may be - // styles in previous keyframes that are not present in this timeline - Object.keys(this._globalTimelineStyles).forEach(function (prop) { - _this._backFill[prop] = _this._globalTimelineStyles[prop] || _angular_animations.AUTO_STYLE; - _this._currentKeyframe[prop] = _angular_animations.AUTO_STYLE; - }); - this._currentEmptyStepKeyframe = this._currentKeyframe; - }; + Parse5DomAdapter.prototype.logGroupEnd = function () { }; + Object.defineProperty(Parse5DomAdapter.prototype, "attrToPropMap", { + /** + * @return {?} + */ + get: function () { return _attrToPropMap; }, + enumerable: true, + configurable: true + }); /** - * @param {?} input - * @param {?} easing - * @param {?} errors - * @param {?=} options + * @param {?} el + * @param {?} selector * @return {?} */ - TimelineBuilder.prototype.setStyles = function (input, easing, errors, options) { - var _this = this; - if (easing) { - this._previousKeyframe['easing'] = easing; - } - var /** @type {?} */ params = (options && options.params) || {}; - var /** @type {?} */ styles = flattenStyles(input, this._globalTimelineStyles); - Object.keys(styles).forEach(function (prop) { - var /** @type {?} */ val = interpolateParams(styles[prop], params, errors); - _this._pendingStyles[prop] = val; - if (!_this._localTimelineStyles.hasOwnProperty(prop)) { - _this._backFill[prop] = _this._globalTimelineStyles.hasOwnProperty(prop) ? - _this._globalTimelineStyles[prop] : - _angular_animations.AUTO_STYLE; - } - _this._updateStyle(prop, val); - }); + Parse5DomAdapter.prototype.querySelector = function (el, selector) { + return this.querySelectorAll(el, selector)[0] || null; }; /** + * @param {?} el + * @param {?} selector * @return {?} */ - TimelineBuilder.prototype.applyStylesToKeyframe = function () { + Parse5DomAdapter.prototype.querySelectorAll = function (el, selector) { var _this = this; - var /** @type {?} */ styles = this._pendingStyles; - var /** @type {?} */ props = Object.keys(styles); - if (props.length == 0) - return; - this._pendingStyles = {}; - props.forEach(function (prop) { - var /** @type {?} */ val = styles[prop]; - _this._currentKeyframe[prop] = val; - }); - Object.keys(this._localTimelineStyles).forEach(function (prop) { - if (!_this._currentKeyframe.hasOwnProperty(prop)) { - _this._currentKeyframe[prop] = _this._localTimelineStyles[prop]; + var /** @type {?} */ res = []; + var /** @type {?} */ _recursive = function (result, node, selector, matcher) { + var /** @type {?} */ cNodes = node.childNodes; + if (cNodes && cNodes.length > 0) { + for (var /** @type {?} */ i = 0; i < cNodes.length; i++) { + var /** @type {?} */ childNode = cNodes[i]; + if (_this.elementMatches(childNode, selector, matcher)) { + result.push(childNode); + } + _recursive(result, childNode, selector, matcher); + } } - }); + }; + var /** @type {?} */ matcher = new _angular_compiler.SelectorMatcher(); + matcher.addSelectables(_angular_compiler.CssSelector.parse(selector)); + _recursive(res, el, selector, matcher); + return res; }; /** + * @param {?} node + * @param {?} selector + * @param {?=} matcher * @return {?} */ - TimelineBuilder.prototype.snapshotCurrentStyles = function () { - var _this = this; - Object.keys(this._localTimelineStyles).forEach(function (prop) { - var /** @type {?} */ val = _this._localTimelineStyles[prop]; - _this._pendingStyles[prop] = val; - _this._updateStyle(prop, val); - }); + Parse5DomAdapter.prototype.elementMatches = function (node, selector, matcher) { + if (matcher === void 0) { matcher = null; } + if (this.isElementNode(node) && selector === '*') { + return true; + } + var /** @type {?} */ result = false; + if (selector && selector.charAt(0) == '#') { + result = this.getAttribute(node, 'id') == selector.substring(1); + } + else if (selector) { + if (!matcher) { + matcher = new _angular_compiler.SelectorMatcher(); + matcher.addSelectables(_angular_compiler.CssSelector.parse(selector)); + } + var /** @type {?} */ cssSelector = new _angular_compiler.CssSelector(); + cssSelector.setElement(this.tagName(node)); + if (node.attribs) { + for (var /** @type {?} */ attrName in node.attribs) { + cssSelector.addAttribute(attrName, node.attribs[attrName]); + } + } + var /** @type {?} */ classList = this.classList(node); + for (var /** @type {?} */ i = 0; i < classList.length; i++) { + cssSelector.addClassName(classList[i]); + } + matcher.match(cssSelector, function (selector, cb) { result = true; }); + } + return result; }; /** + * @param {?} el + * @param {?} evt + * @param {?} listener * @return {?} */ - TimelineBuilder.prototype.getFinalKeyframe = function () { return this._keyframes.get(this.duration); }; - Object.defineProperty(TimelineBuilder.prototype, "properties", { - /** - * @return {?} - */ - get: function () { - var /** @type {?} */ properties = []; - for (var /** @type {?} */ prop in this._currentKeyframe) { - properties.push(prop); - } - return properties; - }, - enumerable: true, - configurable: true - }); + Parse5DomAdapter.prototype.on = function (el, evt, listener) { + var /** @type {?} */ listenersMap = el._eventListenersMap; + if (!listenersMap) { + listenersMap = {}; + el._eventListenersMap = listenersMap; + } + var /** @type {?} */ listeners = listenersMap[evt] || []; + listenersMap[evt] = listeners.concat([listener]); + }; /** - * @param {?} timeline + * @param {?} el + * @param {?} evt + * @param {?} listener * @return {?} */ - TimelineBuilder.prototype.mergeTimelineCollectedStyles = function (timeline) { - var _this = this; - Object.keys(timeline._styleSummary).forEach(function (prop) { - var /** @type {?} */ details0 = _this._styleSummary[prop]; - var /** @type {?} */ details1 = timeline._styleSummary[prop]; - if (!details0 || details1.time > details0.time) { - _this._updateStyle(prop, details1.value); - } - }); + Parse5DomAdapter.prototype.onAndCancel = function (el, evt, listener) { + this.on(el, evt, listener); + return function () { remove(/** @type {?} */ ((el._eventListenersMap[evt])), listener); }; }; /** + * @param {?} el + * @param {?} evt * @return {?} */ - TimelineBuilder.prototype.buildKeyframes = function () { - var _this = this; - this.applyStylesToKeyframe(); - var /** @type {?} */ preStyleProps = new Set(); - var /** @type {?} */ postStyleProps = new Set(); - var /** @type {?} */ isEmpty = this._keyframes.size === 1 && this.duration === 0; - var /** @type {?} */ finalKeyframes = []; - this._keyframes.forEach(function (keyframe, time) { - var /** @type {?} */ finalKeyframe = copyStyles(keyframe, true); - Object.keys(finalKeyframe).forEach(function (prop) { - var /** @type {?} */ value = finalKeyframe[prop]; - if (value == _angular_animations.ɵPRE_STYLE) { - preStyleProps.add(prop); - } - else if (value == _angular_animations.AUTO_STYLE) { - postStyleProps.add(prop); + Parse5DomAdapter.prototype.dispatchEvent = function (el, evt) { + if (!evt.target) { + evt.target = el; + } + if (el._eventListenersMap) { + var /** @type {?} */ listeners = el._eventListenersMap[evt.type]; + if (listeners) { + for (var /** @type {?} */ i = 0; i < listeners.length; i++) { + listeners[i](evt); } - }); - if (!isEmpty) { - finalKeyframe['offset'] = time / _this.duration; } - finalKeyframes.push(finalKeyframe); - }); - var /** @type {?} */ preProps = preStyleProps.size ? iteratorToArray(preStyleProps.values()) : []; - var /** @type {?} */ postProps = postStyleProps.size ? iteratorToArray(postStyleProps.values()) : []; - // special case for a 0-second animation (which is designed just to place styles onscreen) - if (isEmpty) { - var /** @type {?} */ kf0 = finalKeyframes[0]; - var /** @type {?} */ kf1 = copyObj(kf0); - kf0['offset'] = 0; - kf1['offset'] = 1; - finalKeyframes = [kf0, kf1]; } - return createTimelineInstruction(this.element, finalKeyframes, preProps, postProps, this.duration, this.startTime, this.easing, false); + if (el.parent) { + this.dispatchEvent(el.parent, evt); + } + if (el._window) { + this.dispatchEvent(el._window, evt); + } }; - return TimelineBuilder; -}()); -var SubTimelineBuilder = (function (_super) { - __extends(SubTimelineBuilder, _super); /** - * @param {?} element - * @param {?} keyframes - * @param {?} preStyleProps - * @param {?} postStyleProps - * @param {?} timings - * @param {?=} _stretchStartingKeyframe + * @param {?} eventType + * @return {?} */ - function SubTimelineBuilder(element, keyframes, preStyleProps, postStyleProps, timings, _stretchStartingKeyframe) { - if (_stretchStartingKeyframe === void 0) { _stretchStartingKeyframe = false; } - var _this = _super.call(this, element, timings.delay) || this; - _this.element = element; - _this.keyframes = keyframes; - _this.preStyleProps = preStyleProps; - _this.postStyleProps = postStyleProps; - _this._stretchStartingKeyframe = _stretchStartingKeyframe; - _this.timings = { duration: timings.duration, delay: timings.delay, easing: timings.easing }; - return _this; - } + Parse5DomAdapter.prototype.createMouseEvent = function (eventType) { return this.createEvent(eventType); }; /** + * @param {?} eventType * @return {?} */ - SubTimelineBuilder.prototype.containsAnimation = function () { return this.keyframes.length > 1; }; + Parse5DomAdapter.prototype.createEvent = function (eventType) { + var /** @type {?} */ event = ({ + type: eventType, + defaultPrevented: false, + preventDefault: function () { ((event)).defaultPrevented = true; } + }); + return event; + }; /** + * @param {?} event * @return {?} */ - SubTimelineBuilder.prototype.buildKeyframes = function () { - var /** @type {?} */ keyframes = this.keyframes; - var _a = this.timings, delay = _a.delay, duration = _a.duration, easing = _a.easing; - if (this._stretchStartingKeyframe && delay) { - var /** @type {?} */ newKeyframes = []; - var /** @type {?} */ totalTime = duration + delay; - var /** @type {?} */ startingGap = delay / totalTime; - // the original starting keyframe now starts once the delay is done - var /** @type {?} */ newFirstKeyframe = copyStyles(keyframes[0], false); - newFirstKeyframe['offset'] = 0; - newKeyframes.push(newFirstKeyframe); - var /** @type {?} */ oldFirstKeyframe = copyStyles(keyframes[0], false); - oldFirstKeyframe['offset'] = roundOffset(startingGap); - newKeyframes.push(oldFirstKeyframe); - /* - When the keyframe is stretched then it means that the delay before the animation - starts is gone. Instead the first keyframe is placed at the start of the animation - and it is then copied to where it starts when the original delay is over. This basically - means nothing animates during that delay, but the styles are still renderered. For this - to work the original offset values that exist in the original keyframes must be "warped" - so that they can take the new keyframe + delay into account. - - delay=1000, duration=1000, keyframes = 0 .5 1 - - turns into - - delay=0, duration=2000, keyframes = 0 .33 .66 1 - */ - // offsets between 1 ... n -1 are all warped by the keyframe stretch - var /** @type {?} */ limit = keyframes.length - 1; - for (var /** @type {?} */ i = 1; i <= limit; i++) { - var /** @type {?} */ kf = copyStyles(keyframes[i], false); - var /** @type {?} */ oldOffset = (kf['offset']); - var /** @type {?} */ timeAtKeyframe = delay + oldOffset * duration; - kf['offset'] = roundOffset(timeAtKeyframe / totalTime); - newKeyframes.push(kf); - } - // the new starting keyframe should be added at the start - duration = totalTime; - delay = 0; - easing = ''; - keyframes = newKeyframes; - } - return createTimelineInstruction(this.element, keyframes, this.preStyleProps, this.postStyleProps, duration, delay, easing, true); - }; - return SubTimelineBuilder; -}(TimelineBuilder)); -/** - * @param {?} offset - * @param {?=} decimalPoints - * @return {?} - */ -function roundOffset(offset, decimalPoints) { - if (decimalPoints === void 0) { decimalPoints = 3; } - var /** @type {?} */ mult = Math.pow(10, decimalPoints - 1); - return Math.round(offset * mult) / mult; -} -/** - * @param {?} input - * @param {?} allStyles - * @return {?} - */ -function flattenStyles(input, allStyles) { - var /** @type {?} */ styles = {}; - var /** @type {?} */ allProperties; - input.forEach(function (token) { - if (token === '*') { - allProperties = allProperties || Object.keys(allStyles); - allProperties.forEach(function (prop) { styles[prop] = _angular_animations.AUTO_STYLE; }); - } - else { - copyStyles(/** @type {?} */ (token), false, styles); - } - }); - return styles; -} -/** - * @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 Animation = (function () { + Parse5DomAdapter.prototype.preventDefault = function (event) { event.returnValue = false; }; /** - * @param {?} _driver - * @param {?} input + * @param {?} event + * @return {?} */ - function Animation(_driver, input) { - this._driver = _driver; - var errors = []; - var ast = buildAnimationAst(input, errors); - if (errors.length) { - var errorMessage = "animation validation failed:\n" + errors.join("\n"); - throw new Error(errorMessage); - } - this._animationAst = ast; - } + Parse5DomAdapter.prototype.isPrevented = function (event) { return event.returnValue != null && !event.returnValue; }; /** - * @param {?} element - * @param {?} startingStyles - * @param {?} destinationStyles - * @param {?} options - * @param {?=} subInstructions + * @param {?} el * @return {?} */ - Animation.prototype.buildTimelines = function (element, startingStyles, destinationStyles, options, subInstructions) { - var /** @type {?} */ start = Array.isArray(startingStyles) ? normalizeStyles(startingStyles) : (startingStyles); - var /** @type {?} */ dest = Array.isArray(destinationStyles) ? normalizeStyles(destinationStyles) : (destinationStyles); - var /** @type {?} */ errors = []; - subInstructions = subInstructions || new ElementInstructionMap(); - var /** @type {?} */ result = buildAnimationTimelines(this._driver, element, this._animationAst, start, dest, options, subInstructions, errors); - if (errors.length) { - var /** @type {?} */ errorMessage = "animation building failed:\n" + errors.join("\n"); - throw new Error(errorMessage); - } - return result; - }; - return Animation; -}()); -/** - * @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 - */ -/** - * @experimental Animation support is experimental. - */ -/** - * @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 AnimationStyleNormalizer = (function () { - function AnimationStyleNormalizer() { - } - return AnimationStyleNormalizer; -}()); -/** - * @experimental Animation support is experimental. - */ -var NoopAnimationStyleNormalizer = (function () { - function NoopAnimationStyleNormalizer() { - } - NoopAnimationStyleNormalizer.prototype.normalizePropertyName = function (propertyName, errors) { return propertyName; }; - NoopAnimationStyleNormalizer.prototype.normalizeStyleValue = function (userProvidedProperty, normalizedProperty, value, errors) { - return value; + Parse5DomAdapter.prototype.getInnerHTML = function (el) { + return parse5$1.serialize(this.templateAwareRoot(el), { treeAdapter: treeAdapter }); }; - return NoopAnimationStyleNormalizer; -}()); -/** - * @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 WebAnimationsStyleNormalizer = (function (_super) { - __extends(WebAnimationsStyleNormalizer, _super); - function WebAnimationsStyleNormalizer() { - return _super !== null && _super.apply(this, arguments) || this; - } /** - * @param {?} propertyName - * @param {?} errors + * @param {?} el * @return {?} */ - WebAnimationsStyleNormalizer.prototype.normalizePropertyName = function (propertyName, errors) { - return dashCaseToCamelCase(propertyName); + Parse5DomAdapter.prototype.getTemplateContent = function (el) { return null; }; + /** + * @param {?} el + * @return {?} + */ + Parse5DomAdapter.prototype.getOuterHTML = function (el) { + var /** @type {?} */ fragment = treeAdapter.createDocumentFragment(); + this.appendChild(fragment, el); + return parse5$1.serialize(fragment, { treeAdapter: treeAdapter }); }; /** - * @param {?} userProvidedProperty - * @param {?} normalizedProperty - * @param {?} value - * @param {?} errors + * @param {?} node * @return {?} */ - WebAnimationsStyleNormalizer.prototype.normalizeStyleValue = function (userProvidedProperty, normalizedProperty, value, errors) { - var /** @type {?} */ unit = ''; - var /** @type {?} */ strVal = value.toString().trim(); - if (DIMENSIONAL_PROP_MAP[normalizedProperty] && value !== 0 && value !== '0') { - if (typeof value === 'number') { - unit = 'px'; - } - else { - var /** @type {?} */ valAndSuffixMatch = value.match(/^[+-]?[\d\.]+([a-z]*)$/); - if (valAndSuffixMatch && valAndSuffixMatch[1].length == 0) { - errors.push("Please provide a CSS unit value for " + userProvidedProperty + ":" + value); - } - } + Parse5DomAdapter.prototype.nodeName = function (node) { return node.tagName; }; + /** + * @param {?} node + * @return {?} + */ + Parse5DomAdapter.prototype.nodeValue = function (node) { return node.nodeValue; }; + /** + * @param {?} node + * @return {?} + */ + Parse5DomAdapter.prototype.type = function (node) { throw _notImplemented('type'); }; + /** + * @param {?} node + * @return {?} + */ + Parse5DomAdapter.prototype.content = function (node) { return node.childNodes[0]; }; + /** + * @param {?} el + * @return {?} + */ + Parse5DomAdapter.prototype.firstChild = function (el) { return el.firstChild; }; + /** + * @param {?} el + * @return {?} + */ + Parse5DomAdapter.prototype.nextSibling = function (el) { return el.nextSibling; }; + /** + * @param {?} el + * @return {?} + */ + Parse5DomAdapter.prototype.parentElement = function (el) { return el.parent; }; + /** + * @param {?} el + * @return {?} + */ + Parse5DomAdapter.prototype.childNodes = function (el) { return el.childNodes; }; + /** + * @param {?} el + * @return {?} + */ + Parse5DomAdapter.prototype.childNodesAsList = function (el) { + var /** @type {?} */ childNodes = el.childNodes; + var /** @type {?} */ res = new Array(childNodes.length); + for (var /** @type {?} */ i = 0; i < childNodes.length; i++) { + res[i] = childNodes[i]; } - return strVal + unit; - }; - return WebAnimationsStyleNormalizer; -}(AnimationStyleNormalizer)); -var DIMENSIONAL_PROP_MAP = makeBooleanMap('width,height,minWidth,minHeight,maxWidth,maxHeight,left,top,bottom,right,fontSize,outlineWidth,outlineOffset,paddingTop,paddingLeft,paddingBottom,paddingRight,marginTop,marginLeft,marginBottom,marginRight,borderRadius,borderWidth,borderTopWidth,borderLeftWidth,borderRightWidth,borderBottomWidth,textIndent,perspective' - .split(',')); -/** - * @param {?} keys - * @return {?} - */ -function makeBooleanMap(keys) { - var /** @type {?} */ map = {}; - keys.forEach(function (key) { return map[key] = true; }); - return map; -} -/** - * @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 - */ -/** - * @param {?} element - * @param {?} triggerName - * @param {?} fromState - * @param {?} toState - * @param {?} isRemovalTransition - * @param {?} fromStyles - * @param {?} toStyles - * @param {?} timelines - * @param {?} queriedElements - * @param {?} preStyleProps - * @param {?} postStyleProps - * @return {?} - */ -function createTransitionInstruction(element, triggerName, fromState, toState, isRemovalTransition, fromStyles, toStyles, timelines, queriedElements, preStyleProps, postStyleProps) { - return { - type: 0 /* TransitionAnimation */, - element: element, - triggerName: triggerName, - isRemovalTransition: isRemovalTransition, - fromState: fromState, - fromStyles: fromStyles, - toState: toState, - toStyles: toStyles, - timelines: timelines, - queriedElements: queriedElements, - preStyleProps: preStyleProps, - postStyleProps: postStyleProps + 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 AnimationTransitionFactory = (function () { /** - * @param {?} _triggerName - * @param {?} ast - * @param {?} _stateStyles + * @param {?} el + * @return {?} */ - function AnimationTransitionFactory(_triggerName, ast, _stateStyles) { - this._triggerName = _triggerName; - this.ast = ast; - this._stateStyles = _stateStyles; - } + Parse5DomAdapter.prototype.clearNodes = function (el) { + while (el.childNodes.length > 0) { + this.remove(el.childNodes[0]); + } + }; /** - * @param {?} currentState - * @param {?} nextState + * @param {?} el + * @param {?} node * @return {?} */ - AnimationTransitionFactory.prototype.match = function (currentState, nextState) { - return oneOrMoreTransitionsMatch(this.ast.matchers, currentState, nextState); + Parse5DomAdapter.prototype.appendChild = function (el, node) { + this.remove(node); + treeAdapter.appendChild(this.templateAwareRoot(el), node); }; /** - * @param {?} driver - * @param {?} element - * @param {?} currentState - * @param {?} nextState - * @param {?=} options - * @param {?=} subInstructions + * @param {?} el + * @param {?} node * @return {?} */ - AnimationTransitionFactory.prototype.build = function (driver, element, currentState, nextState, options, subInstructions) { - var /** @type {?} */ animationOptions = mergeAnimationOptions(this.ast.options || {}, options || {}); - var /** @type {?} */ backupStateStyles = this._stateStyles['*'] || {}; - var /** @type {?} */ currentStateStyles = this._stateStyles[currentState] || backupStateStyles; - var /** @type {?} */ nextStateStyles = this._stateStyles[nextState] || backupStateStyles; - var /** @type {?} */ errors = []; - var /** @type {?} */ timelines = buildAnimationTimelines(driver, element, this.ast.animation, currentStateStyles, nextStateStyles, animationOptions, subInstructions, errors); - if (errors.length) { - var /** @type {?} */ errorMessage = "animation building failed:\n" + errors.join("\n"); - throw new Error(errorMessage); + Parse5DomAdapter.prototype.removeChild = function (el, node) { + if (el.childNodes.indexOf(node) > -1) { + this.remove(node); } - var /** @type {?} */ preStyleMap = new Map(); - var /** @type {?} */ postStyleMap = new Map(); - var /** @type {?} */ queriedElements = new Set(); - timelines.forEach(function (tl) { - var /** @type {?} */ elm = tl.element; - var /** @type {?} */ preProps = getOrSetAsInMap(preStyleMap, elm, {}); - tl.preStyleProps.forEach(function (prop) { return preProps[prop] = true; }); - var /** @type {?} */ postProps = getOrSetAsInMap(postStyleMap, elm, {}); - tl.postStyleProps.forEach(function (prop) { return postProps[prop] = true; }); - if (elm !== element) { - queriedElements.add(elm); - } - }); - var /** @type {?} */ queriedElementsList = iteratorToArray(queriedElements.values()); - return createTransitionInstruction(element, this._triggerName, currentState, nextState, nextState === 'void', currentStateStyles, nextStateStyles, timelines, queriedElementsList, preStyleMap, postStyleMap); }; - return AnimationTransitionFactory; -}()); -/** - * @param {?} matchFns - * @param {?} currentState - * @param {?} nextState - * @return {?} - */ -function oneOrMoreTransitionsMatch(matchFns, currentState, nextState) { - return matchFns.some(function (fn) { return fn(currentState, nextState); }); -} -/** - * @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 - */ -/** - * \@experimental Animation support is experimental. - * @param {?} name - * @param {?} ast - * @return {?} - */ -function buildTrigger(name, ast) { - return new AnimationTrigger(name, ast); -} -/** - * \@experimental Animation support is experimental. - */ -var AnimationTrigger = (function () { /** - * @param {?} name - * @param {?} ast + * @param {?} el + * @return {?} */ - function AnimationTrigger(name, ast) { - var _this = this; - this.name = name; - this.ast = ast; - this.transitionFactories = []; - this.states = {}; - ast.states.forEach(function (ast) { - var obj = _this.states[ast.name] = {}; - ast.style.styles.forEach(function (styleTuple) { - if (typeof styleTuple == 'object') { - copyStyles(styleTuple, false, obj); - } - }); - }); - balanceProperties(this.states, 'true', '1'); - balanceProperties(this.states, 'false', '0'); - ast.transitions.forEach(function (ast) { - _this.transitionFactories.push(new AnimationTransitionFactory(name, ast, _this.states)); - }); - this.fallbackTransition = createFallbackTransition(name, this.states); - } - Object.defineProperty(AnimationTrigger.prototype, "containsQueries", { - /** - * @return {?} - */ - get: function () { return this.ast.queryCount > 0; }, - enumerable: true, - configurable: true - }); + Parse5DomAdapter.prototype.remove = function (el) { + var /** @type {?} */ parent = el.parent; + if (parent) { + var /** @type {?} */ index = parent.childNodes.indexOf(el); + parent.childNodes.splice(index, 1); + } + var /** @type {?} */ prev = el.previousSibling; + var /** @type {?} */ next = el.nextSibling; + if (prev) { + prev.next = next; + } + if (next) { + next.prev = prev; + } + el.prev = null; + el.next = null; + el.parent = null; + return el; + }; /** - * @param {?} currentState - * @param {?} nextState + * @param {?} parent + * @param {?} ref + * @param {?} newNode * @return {?} */ - AnimationTrigger.prototype.matchTransition = function (currentState, nextState) { - var /** @type {?} */ entry = this.transitionFactories.find(function (f) { return f.match(currentState, nextState); }); - return entry || null; - }; - return AnimationTrigger; -}()); -/** - * @param {?} triggerName - * @param {?} states - * @return {?} - */ -function createFallbackTransition(triggerName, states) { - var /** @type {?} */ matchers = [function (fromState, toState) { return true; }]; - var /** @type {?} */ animation = new SequenceAst([]); - var /** @type {?} */ transition = new TransitionAst(matchers, animation); - return new AnimationTransitionFactory(triggerName, transition, states); -} -/** - * @param {?} obj - * @param {?} key1 - * @param {?} key2 - * @return {?} - */ -function balanceProperties(obj, key1, key2) { - if (obj.hasOwnProperty(key1)) { - if (!obj.hasOwnProperty(key2)) { - obj[key2] = obj[key1]; + Parse5DomAdapter.prototype.insertBefore = function (parent, ref, newNode) { + this.remove(newNode); + if (ref) { + treeAdapter.insertBefore(parent, newNode, ref); } - } - else if (obj.hasOwnProperty(key2)) { - obj[key1] = obj[key2]; - } -} -/** - * @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 EMPTY_INSTRUCTION_MAP = new ElementInstructionMap(); -var TimelineAnimationEngine = (function () { + else { + this.appendChild(parent, newNode); + } + }; /** - * @param {?} _driver - * @param {?} _normalizer + * @param {?} parent + * @param {?} ref + * @param {?} nodes + * @return {?} */ - function TimelineAnimationEngine(_driver, _normalizer) { - this._driver = _driver; - this._normalizer = _normalizer; - this._animations = {}; - this._playersById = {}; - this.players = []; - } + Parse5DomAdapter.prototype.insertAllBefore = function (parent, ref, nodes) { + var _this = this; + nodes.forEach(function (n) { return _this.insertBefore(parent, ref, n); }); + }; /** - * @param {?} id - * @param {?} metadata + * @param {?} parent + * @param {?} ref + * @param {?} node * @return {?} */ - TimelineAnimationEngine.prototype.register = function (id, metadata) { - var /** @type {?} */ errors = []; - var /** @type {?} */ ast = buildAnimationAst(metadata, errors); - if (errors.length) { - throw new Error("Unable to build the animation due to the following errors: " + errors.join("\n")); + Parse5DomAdapter.prototype.insertAfter = function (parent, ref, node) { + if (ref.nextSibling) { + this.insertBefore(parent, ref.nextSibling, node); } else { - this._animations[id] = ast; + this.appendChild(parent, node); } }; /** - * @param {?} i - * @param {?} preStyles - * @param {?=} postStyles + * @param {?} el + * @param {?} value * @return {?} */ - TimelineAnimationEngine.prototype._buildPlayer = function (i, preStyles, postStyles) { - var /** @type {?} */ element = i.element; - var /** @type {?} */ keyframes = normalizeKeyframes(this._driver, this._normalizer, element, i.keyframes, preStyles, postStyles); - return this._driver.animate(element, keyframes, i.duration, i.delay, i.easing, []); + Parse5DomAdapter.prototype.setInnerHTML = function (el, value) { + this.clearNodes(el); + var /** @type {?} */ content = parse5$1.parseFragment(value, { treeAdapter: treeAdapter }); + for (var /** @type {?} */ i = 0; i < content.childNodes.length; i++) { + treeAdapter.appendChild(el, content.childNodes[i]); + } }; /** - * @param {?} id - * @param {?} element - * @param {?=} options + * @param {?} el + * @param {?=} isRecursive * @return {?} */ - TimelineAnimationEngine.prototype.create = function (id, element, options) { - var _this = this; - if (options === void 0) { options = {}; } - var /** @type {?} */ errors = []; - var /** @type {?} */ ast = this._animations[id]; - var /** @type {?} */ instructions; - var /** @type {?} */ autoStylesMap = new Map(); - if (ast) { - instructions = buildAnimationTimelines(this._driver, element, ast, {}, {}, options, EMPTY_INSTRUCTION_MAP, errors); - instructions.forEach(function (inst) { - var /** @type {?} */ styles = getOrSetAsInMap(autoStylesMap, inst.element, {}); - inst.postStyleProps.forEach(function (prop) { return styles[prop] = null; }); - }); + Parse5DomAdapter.prototype.getText = function (el, isRecursive) { + if (this.isTextNode(el)) { + return el.data; } - else { - errors.push('The requested animation doesn\'t exist or has already been destroyed'); - instructions = []; + if (this.isCommentNode(el)) { + // In the DOM, comments within an element return an empty string for textContent + // However, comment node instances return the comment content for textContent getter + return isRecursive ? '' : el.data; } - if (errors.length) { - throw new Error("Unable to create the animation due to the following errors: " + errors.join("\n")); + if (!el.childNodes || el.childNodes.length == 0) { + return ''; } - autoStylesMap.forEach(function (styles, element) { - Object.keys(styles).forEach(function (prop) { styles[prop] = _this._driver.computeStyle(element, prop, _angular_animations.AUTO_STYLE); }); - }); - var /** @type {?} */ players = instructions.map(function (i) { - var /** @type {?} */ styles = autoStylesMap.get(i.element); - return _this._buildPlayer(i, {}, styles); - }); - var /** @type {?} */ player = optimizeGroupPlayer(players); - this._playersById[id] = player; - player.onDestroy(function () { return _this.destroy(id); }); - this.players.push(player); - return player; + var /** @type {?} */ textContent = ''; + for (var /** @type {?} */ i = 0; i < el.childNodes.length; i++) { + textContent += this.getText(el.childNodes[i], true); + } + return textContent; }; /** - * @param {?} id + * @param {?} el + * @param {?} value * @return {?} */ - TimelineAnimationEngine.prototype.destroy = function (id) { - var /** @type {?} */ player = this._getPlayer(id); - player.destroy(); - delete this._playersById[id]; - var /** @type {?} */ index = this.players.indexOf(player); - if (index >= 0) { - this.players.splice(index, 1); + Parse5DomAdapter.prototype.setText = function (el, value) { + if (this.isTextNode(el) || this.isCommentNode(el)) { + el.data = value; + } + else { + this.clearNodes(el); + if (value !== '') + treeAdapter.insertText(el, value); } }; /** - * @param {?} id + * @param {?} el * @return {?} */ - TimelineAnimationEngine.prototype._getPlayer = function (id) { - var /** @type {?} */ player = this._playersById[id]; - if (!player) { - throw new Error("Unable to find the timeline player referenced by " + id); - } - return player; - }; + Parse5DomAdapter.prototype.getValue = function (el) { return el.value; }; /** - * @param {?} id - * @param {?} element - * @param {?} eventName - * @param {?} callback + * @param {?} el + * @param {?} value * @return {?} */ - TimelineAnimationEngine.prototype.listen = function (id, element, eventName, callback) { - // triggerName, fromState, toState are all ignored for timeline animations - var /** @type {?} */ baseEvent = makeAnimationEvent(element, '', '', ''); - listenOnPlayer(this._getPlayer(id), eventName, baseEvent, callback); - return function () { }; - }; + Parse5DomAdapter.prototype.setValue = function (el, value) { el.value = value; }; /** - * @param {?} id - * @param {?} element - * @param {?} command - * @param {?} args + * @param {?} el * @return {?} */ - TimelineAnimationEngine.prototype.command = function (id, element, command, args) { - if (command == 'register') { - this.register(id, /** @type {?} */ (args[0])); - return; - } - if (command == 'create') { - var /** @type {?} */ options = ((args[0] || {})); - this.create(id, element, options); - return; - } - var /** @type {?} */ player = this._getPlayer(id); - switch (command) { - case 'play': - player.play(); - break; - case 'pause': - player.pause(); - break; - case 'reset': - player.reset(); - break; - case 'restart': - player.restart(); - break; - case 'finish': - player.finish(); - break; - case 'init': - player.init(); - break; - case 'setPosition': - player.setPosition(parseFloat(/** @type {?} */ (args[0]))); - break; - case 'destroy': - this.destroy(id); - break; - } + Parse5DomAdapter.prototype.getChecked = function (el) { return el.checked; }; + /** + * @param {?} el + * @param {?} value + * @return {?} + */ + Parse5DomAdapter.prototype.setChecked = function (el, value) { el.checked = value; }; + /** + * @param {?} text + * @return {?} + */ + Parse5DomAdapter.prototype.createComment = function (text) { return treeAdapter.createCommentNode(text); }; + /** + * @param {?} html + * @return {?} + */ + Parse5DomAdapter.prototype.createTemplate = function (html) { + var /** @type {?} */ template = treeAdapter.createElement('template', 'http://www.w3.org/1999/xhtml', []); + var /** @type {?} */ content = parse5$1.parseFragment(html, { treeAdapter: treeAdapter }); + treeAdapter.setTemplateContent(template, content); + return template; }; - return TimelineAnimationEngine; -}()); -/** - * @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 EMPTY_PLAYER_ARRAY = []; -var NULL_REMOVAL_STATE = { - namespaceId: '', - setForRemoval: null, - hasAnimation: false, - removedBeforeQueried: false -}; -var NULL_REMOVED_QUERIED_STATE = { - namespaceId: '', - setForRemoval: null, - hasAnimation: false, - removedBeforeQueried: true -}; -var REMOVAL_FLAG = '__ng_removed'; -var StateValue = (function () { /** - * @param {?} input + * @param {?} tagName + * @return {?} */ - function StateValue(input) { - var isObj = input && input.hasOwnProperty('value'); - var value = isObj ? input['value'] : input; - this.value = normalizeTriggerValue(value); - if (isObj) { - var options = copyObj(input); - delete options['value']; - this.options = options; - } - else { - this.options = {}; - } - if (!this.options.params) { - this.options.params = {}; - } - } + Parse5DomAdapter.prototype.createElement = function (tagName) { + return treeAdapter.createElement(tagName, 'http://www.w3.org/1999/xhtml', []); + }; /** - * @param {?} options + * @param {?} ns + * @param {?} tagName * @return {?} */ - StateValue.prototype.absorbOptions = function (options) { - var /** @type {?} */ newParams = options.params; - if (newParams) { - var /** @type {?} */ oldParams_2 = ((this.options.params)); - Object.keys(newParams).forEach(function (prop) { - if (oldParams_2[prop] == null) { - oldParams_2[prop] = newParams[prop]; - } - }); - } + Parse5DomAdapter.prototype.createElementNS = function (ns, tagName) { + return treeAdapter.createElement(tagName, ns, []); }; - return StateValue; -}()); -var VOID_VALUE = 'void'; -var DEFAULT_STATE_VALUE = new StateValue(VOID_VALUE); -var DELETED_STATE_VALUE = new StateValue('DELETED'); -var AnimationTransitionNamespace = (function () { /** - * @param {?} id - * @param {?} hostElement - * @param {?} _engine + * @param {?} text + * @return {?} */ - function AnimationTransitionNamespace(id, hostElement, _engine) { - this.id = id; - this.hostElement = hostElement; - this._engine = _engine; - this.players = []; - this._triggers = {}; - this._queue = []; - this._elementListeners = new Map(); - this._hostClassName = 'ng-tns-' + id; - addClass(hostElement, this._hostClassName); - } + Parse5DomAdapter.prototype.createTextNode = function (text) { + var /** @type {?} */ t = (this.createComment(text)); + t.type = 'text'; + return t; + }; /** - * @param {?} element - * @param {?} name - * @param {?} phase - * @param {?} callback + * @param {?} attrName + * @param {?} attrValue * @return {?} */ - AnimationTransitionNamespace.prototype.listen = function (element, name, phase, callback) { - var _this = this; - if (!this._triggers.hasOwnProperty(name)) { - throw new Error("Unable to listen on the animation trigger event \"" + phase + "\" because the animation trigger \"" + name + "\" doesn't exist!"); - } - if (phase == null || phase.length == 0) { - throw new Error("Unable to listen on the animation trigger \"" + name + "\" because the provided event is undefined!"); - } - if (!isTriggerEventValid(phase)) { - throw new Error("The provided animation trigger event \"" + phase + "\" for the animation trigger \"" + name + "\" is not supported!"); - } - var /** @type {?} */ listeners = getOrSetAsInMap(this._elementListeners, element, []); - var /** @type {?} */ data = { name: name, phase: phase, callback: callback }; - listeners.push(data); - var /** @type {?} */ triggersWithStates = getOrSetAsInMap(this._engine.statesByElement, element, {}); - if (!triggersWithStates.hasOwnProperty(name)) { - addClass(element, NG_TRIGGER_CLASSNAME); - addClass(element, NG_TRIGGER_CLASSNAME + '-' + name); - triggersWithStates[name] = null; - } - return function () { - // the event listener is removed AFTER the flush has occurred such - // that leave animations callbacks can fire (otherwise if the node - // is removed in between then the listeners would be deregistered) - _this._engine.afterFlush(function () { - var /** @type {?} */ index = listeners.indexOf(data); - if (index >= 0) { - listeners.splice(index, 1); - } - if (!_this._triggers[name]) { - delete triggersWithStates[name]; - } - }); - }; + Parse5DomAdapter.prototype.createScriptTag = function (attrName, attrValue) { + return treeAdapter.createElement('script', 'http://www.w3.org/1999/xhtml', [{ name: attrName, value: attrValue }]); }; /** - * @param {?} name - * @param {?} ast + * @param {?} css * @return {?} */ - AnimationTransitionNamespace.prototype.register = function (name, ast) { - if (this._triggers[name]) { - // throw - return false; - } - else { - this._triggers[name] = ast; - return true; - } + Parse5DomAdapter.prototype.createStyleElement = function (css) { + var /** @type {?} */ style = this.createElement('style'); + this.setText(style, css); + return (style); }; /** - * @param {?} name + * @param {?} el * @return {?} */ - AnimationTransitionNamespace.prototype._getTrigger = function (name) { - var /** @type {?} */ trigger = this._triggers[name]; - if (!trigger) { - throw new Error("The provided animation trigger \"" + name + "\" has not been registered!"); - } - return trigger; + Parse5DomAdapter.prototype.createShadowRoot = function (el) { + el.shadowRoot = treeAdapter.createDocumentFragment(); + el.shadowRoot.parent = el; + return el.shadowRoot; }; /** - * @param {?} element - * @param {?} triggerName - * @param {?} value - * @param {?=} defaultToFallback + * @param {?} el * @return {?} */ - AnimationTransitionNamespace.prototype.trigger = function (element, triggerName, value, defaultToFallback) { - var _this = this; - if (defaultToFallback === void 0) { defaultToFallback = true; } - var /** @type {?} */ trigger = this._getTrigger(triggerName); - var /** @type {?} */ player = new TransitionAnimationPlayer(this.id, triggerName, element); - var /** @type {?} */ triggersWithStates = this._engine.statesByElement.get(element); - if (!triggersWithStates) { - addClass(element, NG_TRIGGER_CLASSNAME); - addClass(element, NG_TRIGGER_CLASSNAME + '-' + triggerName); - this._engine.statesByElement.set(element, triggersWithStates = {}); - } - var /** @type {?} */ fromState = triggersWithStates[triggerName]; - var /** @type {?} */ toState = new StateValue(value); - var /** @type {?} */ isObj = value && value.hasOwnProperty('value'); - if (!isObj && fromState) { - toState.absorbOptions(fromState.options); - } - triggersWithStates[triggerName] = toState; - if (!fromState) { - fromState = DEFAULT_STATE_VALUE; - } - else if (fromState === DELETED_STATE_VALUE) { - return player; - } - var /** @type {?} */ playersOnElement = getOrSetAsInMap(this._engine.playersByElement, element, []); - playersOnElement.forEach(function (player) { - // only remove the player if it is queued on the EXACT same trigger/namespace - // we only also deal with queued players here because if the animation has - // started then we want to keep the player alive until the flush happens - // (which is where the previousPlayers are passed into the new palyer) - if (player.namespaceId == _this.id && player.triggerName == triggerName && player.queued) { - player.destroy(); - } - }); - var /** @type {?} */ transition = trigger.matchTransition(fromState.value, toState.value); - var /** @type {?} */ isFallbackTransition = false; - if (!transition) { - if (!defaultToFallback) - return; - transition = trigger.fallbackTransition; - isFallbackTransition = true; - } - this._engine.totalQueuedPlayers++; - this._queue.push({ element: element, triggerName: triggerName, transition: transition, fromState: fromState, toState: toState, player: player, isFallbackTransition: isFallbackTransition }); - if (!isFallbackTransition) { - addClass(element, NG_ANIMATING_CLASSNAME); - } - player.onDone(function () { - removeClass(element, NG_ANIMATING_CLASSNAME); - var /** @type {?} */ index = _this.players.indexOf(player); - if (index >= 0) { - _this.players.splice(index, 1); - } - var /** @type {?} */ players = _this._engine.playersByElement.get(element); - if (players) { - var /** @type {?} */ index_1 = players.indexOf(player); - if (index_1 >= 0) { - players.splice(index_1, 1); - } - } - }); - this.players.push(player); - playersOnElement.push(player); - return player; - }; + Parse5DomAdapter.prototype.getShadowRoot = function (el) { return el.shadowRoot; }; /** - * @param {?} name + * @param {?} el * @return {?} */ - AnimationTransitionNamespace.prototype.deregister = function (name) { - var _this = this; - delete this._triggers[name]; - this._engine.statesByElement.forEach(function (stateMap, element) { delete stateMap[name]; }); - this._elementListeners.forEach(function (listeners, element) { - _this._elementListeners.set(element, listeners.filter(function (entry) { return entry.name != name; })); - }); - }; + Parse5DomAdapter.prototype.getHost = function (el) { return el.host; }; /** - * @param {?} element + * @param {?} el * @return {?} */ - AnimationTransitionNamespace.prototype.clearElementCache = function (element) { - this._engine.statesByElement.delete(element); - this._elementListeners.delete(element); - var /** @type {?} */ elementPlayers = this._engine.playersByElement.get(element); - if (elementPlayers) { - elementPlayers.forEach(function (player) { return player.destroy(); }); - this._engine.playersByElement.delete(element); - } - }; + Parse5DomAdapter.prototype.getDistributedNodes = function (el) { throw _notImplemented('getDistributedNodes'); }; /** - * @param {?} rootElement - * @param {?} context - * @param {?=} animate + * @param {?} node * @return {?} */ - AnimationTransitionNamespace.prototype._destroyInnerNodes = function (rootElement, context, animate) { - var _this = this; - if (animate === void 0) { animate = false; } - this._engine.driver.query(rootElement, NG_TRIGGER_SELECTOR, true).forEach(function (elm) { - if (animate && containsClass(elm, _this._hostClassName)) { - var /** @type {?} */ innerNs = _this._engine.namespacesByHostElement.get(elm); - // special case for a host element with animations on the same element - if (innerNs) { - innerNs.removeNode(elm, context, true); + Parse5DomAdapter.prototype.clone = function (node) { + var /** @type {?} */ _recursive = function (node) { + var /** @type {?} */ nodeClone = Object.create(Object.getPrototypeOf(node)); + for (var /** @type {?} */ prop in node) { + var /** @type {?} */ desc = Object.getOwnPropertyDescriptor(node, prop); + if (desc && 'value' in desc && typeof desc.value !== 'object') { + nodeClone[prop] = node[prop]; } - _this.removeNode(elm, context, true); } - else { - _this.clearElementCache(elm); - } - }); - }; - /** - * @param {?} element - * @param {?} context - * @param {?=} doNotRecurse - * @return {?} - */ - AnimationTransitionNamespace.prototype.removeNode = function (element, context, doNotRecurse) { - var _this = this; - var /** @type {?} */ engine = this._engine; - if (!doNotRecurse && element.childElementCount) { - this._destroyInnerNodes(element, context, true); - } - var /** @type {?} */ triggerStates = engine.statesByElement.get(element); - if (triggerStates) { - var /** @type {?} */ players_1 = []; - Object.keys(triggerStates).forEach(function (triggerName) { - // this check is here in the event that an element is removed - // twice (both on the host level and the component level) - if (_this._triggers[triggerName]) { - var /** @type {?} */ player = _this.trigger(element, triggerName, VOID_VALUE, false); - if (player) { - players_1.push(player); + nodeClone.parent = null; + nodeClone.prev = null; + nodeClone.next = null; + nodeClone.children = null; + mapProps.forEach(function (mapName) { + if (node[mapName] != null) { + nodeClone[mapName] = {}; + for (var /** @type {?} */ prop in node[mapName]) { + nodeClone[mapName][prop] = node[mapName][prop]; } } }); - if (players_1.length) { - engine.markElementAsRemoved(this.id, element, true, context); - optimizeGroupPlayer(players_1).onDone(function () { return engine.processLeaveNode(element); }); - return; - } - } - // find the player that is animating and make sure that the - // removal is delayed until that player has completed - var /** @type {?} */ containsPotentialParentTransition = false; - if (engine.totalAnimations) { - var /** @type {?} */ currentPlayers = engine.players.length ? engine.playersByQueriedElement.get(element) : []; - // when this `if statement` does not continue forward it means that - // a previous animation query has selected the current element and - // is animating it. In this situation want to continue fowards and - // allow the element to be queued up for animation later. - if (currentPlayers && currentPlayers.length) { - containsPotentialParentTransition = true; - } - else { - var /** @type {?} */ parent = element; - while (parent = parent.parentNode) { - var /** @type {?} */ triggers = engine.statesByElement.get(parent); - if (triggers) { - containsPotentialParentTransition = true; - break; + var /** @type {?} */ cNodes = node.children; + if (cNodes) { + var /** @type {?} */ cNodesClone = new Array(cNodes.length); + for (var /** @type {?} */ i = 0; i < cNodes.length; i++) { + var /** @type {?} */ childNode = cNodes[i]; + var /** @type {?} */ childNodeClone = _recursive(childNode); + cNodesClone[i] = childNodeClone; + if (i > 0) { + childNodeClone.prev = cNodesClone[i - 1]; + cNodesClone[i - 1].next = childNodeClone; } + childNodeClone.parent = nodeClone; } + nodeClone.children = cNodesClone; } - } - // at this stage we know that the element will either get removed - // during flush or will be picked up by a parent query. Either way - // we need to fire the listeners for this element when it DOES get - // removed (once the query parent animation is done or after flush) - var /** @type {?} */ listeners = this._elementListeners.get(element); - if (listeners) { - var /** @type {?} */ visitedTriggers_1 = new Set(); - listeners.forEach(function (listener) { - var /** @type {?} */ triggerName = listener.name; - if (visitedTriggers_1.has(triggerName)) - return; - visitedTriggers_1.add(triggerName); - var /** @type {?} */ trigger = _this._triggers[triggerName]; - var /** @type {?} */ transition = trigger.fallbackTransition; - var /** @type {?} */ elementStates = ((engine.statesByElement.get(element))); - var /** @type {?} */ fromState = elementStates[triggerName] || DEFAULT_STATE_VALUE; - var /** @type {?} */ toState = new StateValue(VOID_VALUE); - var /** @type {?} */ player = new TransitionAnimationPlayer(_this.id, triggerName, element); - _this._engine.totalQueuedPlayers++; - _this._queue.push({ - element: element, - triggerName: triggerName, - transition: transition, - fromState: fromState, - toState: toState, - player: player, - isFallbackTransition: true - }); - }); - } - // whether or not a parent has an animation we need to delay the deferral of the leave - // operation until we have more information (which we do after flush() has been called) - if (containsPotentialParentTransition) { - engine.markElementAsRemoved(this.id, element, false, context); - } - else { - // we do this after the flush has occurred such - // that the callbacks can be fired - engine.afterFlush(function () { return _this.clearElementCache(element); }); - engine.destroyInnerAnimations(element); - engine._onRemovalComplete(element, context); - } + return nodeClone; + }; + return _recursive(node); }; /** * @param {?} element - * @param {?} parent + * @param {?} name * @return {?} */ - AnimationTransitionNamespace.prototype.insertNode = function (element, parent) { addClass(element, this._hostClassName); }; + Parse5DomAdapter.prototype.getElementsByClassName = function (element, name) { + return this.querySelectorAll(element, '.' + name); + }; /** - * @param {?} microtaskId + * @param {?} element + * @param {?} name * @return {?} */ - AnimationTransitionNamespace.prototype.drainQueuedTransitions = function (microtaskId) { - var _this = this; - var /** @type {?} */ instructions = []; - this._queue.forEach(function (entry) { - var /** @type {?} */ player = entry.player; - if (player.destroyed) - return; - var /** @type {?} */ element = entry.element; - var /** @type {?} */ listeners = _this._elementListeners.get(element); - if (listeners) { - listeners.forEach(function (listener) { - if (listener.name == entry.triggerName) { - var /** @type {?} */ baseEvent = makeAnimationEvent(element, entry.triggerName, entry.fromState.value, entry.toState.value); - ((baseEvent))['_data'] = microtaskId; - listenOnPlayer(entry.player, listener.phase, baseEvent, listener.callback); - } - }); - } - if (player.markedForDestroy) { - _this._engine.afterFlush(function () { - // now we can destroy the element properly since the event listeners have - // been bound to the player - player.destroy(); - }); - } - else { - instructions.push(entry); - } - }); - this._queue = []; - return instructions.sort(function (a, b) { - // if depCount == 0 them move to front - // otherwise if a contains b then move back - var /** @type {?} */ d0 = a.transition.ast.depCount; - var /** @type {?} */ d1 = b.transition.ast.depCount; - if (d0 == 0 || d1 == 0) { - return d0 - d1; - } - return _this._engine.driver.containsElement(a.element, b.element) ? 1 : -1; - }); + Parse5DomAdapter.prototype.getElementsByTagName = function (element, name) { + return this.querySelectorAll(element, name); }; /** - * @param {?} context + * @param {?} element * @return {?} */ - AnimationTransitionNamespace.prototype.destroy = function (context) { - this.players.forEach(function (p) { return p.destroy(); }); - this._destroyInnerNodes(this.hostElement, context); + Parse5DomAdapter.prototype.classList = function (element) { + var /** @type {?} */ classAttrValue = null; + var /** @type {?} */ attributes = element.attribs; + if (attributes && attributes['class'] != null) { + classAttrValue = attributes['class']; + } + return classAttrValue ? classAttrValue.trim().split(/\s+/g) : []; }; /** * @param {?} element + * @param {?} className * @return {?} */ - AnimationTransitionNamespace.prototype.elementContainsData = function (element) { - var /** @type {?} */ containsData = false; - if (this._elementListeners.has(element)) - containsData = true; - containsData = - (this._queue.find(function (entry) { return entry.element === element; }) ? true : false) || containsData; - return containsData; + Parse5DomAdapter.prototype.addClass = function (element, className) { + var /** @type {?} */ classList = this.classList(element); + var /** @type {?} */ index = classList.indexOf(className); + if (index == -1) { + classList.push(className); + element.attribs['class'] = element.className = classList.join(' '); + } }; - return AnimationTransitionNamespace; -}()); -var TransitionAnimationEngine = (function () { /** - * @param {?} driver - * @param {?} _normalizer + * @param {?} element + * @param {?} className + * @return {?} */ - function TransitionAnimationEngine(driver, _normalizer) { - this.driver = driver; - this._normalizer = _normalizer; - this.players = []; - this.newHostElements = new Map(); - this.playersByElement = new Map(); - this.playersByQueriedElement = new Map(); - this.statesByElement = new Map(); - this.totalAnimations = 0; - this.totalQueuedPlayers = 0; - this._namespaceLookup = {}; - this._namespaceList = []; - this._flushFns = []; - this._whenQuietFns = []; - this.namespacesByHostElement = new Map(); - this.collectedEnterElements = []; - this.collectedLeaveElements = []; - this.onRemovalComplete = function (element, context) { }; - } + Parse5DomAdapter.prototype.removeClass = function (element, className) { + var /** @type {?} */ classList = this.classList(element); + var /** @type {?} */ index = classList.indexOf(className); + if (index > -1) { + classList.splice(index, 1); + element.attribs['class'] = element.className = classList.join(' '); + } + }; /** * @param {?} element - * @param {?} context + * @param {?} className * @return {?} */ - TransitionAnimationEngine.prototype._onRemovalComplete = function (element, context) { this.onRemovalComplete(element, context); }; - Object.defineProperty(TransitionAnimationEngine.prototype, "queuedPlayers", { - /** - * @return {?} - */ - get: function () { - var /** @type {?} */ players = []; - this._namespaceList.forEach(function (ns) { - ns.players.forEach(function (player) { - if (player.queued) { - players.push(player); - } - }); - }); - return players; - }, - enumerable: true, - configurable: true - }); + Parse5DomAdapter.prototype.hasClass = function (element, className) { + return this.classList(element).indexOf(className) > -1; + }; /** - * @param {?} namespaceId - * @param {?} hostElement + * @param {?} element + * @param {?} styleName + * @param {?=} styleValue * @return {?} */ - TransitionAnimationEngine.prototype.createNamespace = function (namespaceId, hostElement) { - var /** @type {?} */ ns = new AnimationTransitionNamespace(namespaceId, hostElement, this); - if (hostElement.parentNode) { - this._balanceNamespaceList(ns, hostElement); - } - else { - // defer this later until flush during when the host element has - // been inserted so that we know exactly where to place it in - // the namespace list - this.newHostElements.set(hostElement, ns); - // given that this host element is apart of the animation code, it - // may or may not be inserted by a parent node that is an of an - // animation renderer type. If this happens then we can still have - // access to this item when we query for :enter nodes. If the parent - // is a renderer then the set data-structure will normalize the entry - this.collectEnterElement(hostElement); - } - return this._namespaceLookup[namespaceId] = ns; + Parse5DomAdapter.prototype.hasStyle = function (element, styleName, styleValue) { + var /** @type {?} */ value = this.getStyle(element, styleName) || ''; + return styleValue ? value == styleValue : value.length > 0; }; /** - * @param {?} ns - * @param {?} hostElement + * \@internal + * @param {?} element * @return {?} */ - TransitionAnimationEngine.prototype._balanceNamespaceList = function (ns, hostElement) { - var /** @type {?} */ limit = this._namespaceList.length - 1; - if (limit >= 0) { - var /** @type {?} */ found = false; - for (var /** @type {?} */ i = limit; i >= 0; i--) { - var /** @type {?} */ nextNamespace = this._namespaceList[i]; - if (this.driver.containsElement(nextNamespace.hostElement, hostElement)) { - this._namespaceList.splice(i + 1, 0, ns); - found = true; - break; + Parse5DomAdapter.prototype._readStyleAttribute = function (element) { + var /** @type {?} */ styleMap = {}; + var /** @type {?} */ attributes = element.attribs; + if (attributes && attributes['style'] != null) { + var /** @type {?} */ styleAttrValue = attributes['style']; + var /** @type {?} */ styleList = styleAttrValue.split(/;+/g); + for (var /** @type {?} */ i = 0; i < styleList.length; i++) { + if (styleList[i].length > 0) { + var /** @type {?} */ style = (styleList[i]); + var /** @type {?} */ colon = style.indexOf(':'); + if (colon === -1) { + throw new Error("Invalid CSS style: " + style); + } + ((styleMap))[style.substr(0, colon).trim()] = style.substr(colon + 1).trim(); } } - if (!found) { - this._namespaceList.splice(0, 0, ns); - } - } - else { - this._namespaceList.push(ns); } - this.namespacesByHostElement.set(hostElement, ns); - return ns; + return styleMap; }; /** - * @param {?} namespaceId - * @param {?} hostElement + * \@internal + * @param {?} element + * @param {?} styleMap * @return {?} */ - TransitionAnimationEngine.prototype.register = function (namespaceId, hostElement) { - var /** @type {?} */ ns = this._namespaceLookup[namespaceId]; - if (!ns) { - ns = this.createNamespace(namespaceId, hostElement); + Parse5DomAdapter.prototype._writeStyleAttribute = function (element, styleMap) { + var /** @type {?} */ styleAttrValue = ''; + for (var /** @type {?} */ key in styleMap) { + var /** @type {?} */ newValue = styleMap[key]; + if (newValue) { + styleAttrValue += key + ':' + styleMap[key] + ';'; + } } - return ns; + element.attribs['style'] = styleAttrValue; }; /** - * @param {?} namespaceId - * @param {?} name - * @param {?} trigger + * @param {?} element + * @param {?} styleName + * @param {?=} styleValue * @return {?} */ - TransitionAnimationEngine.prototype.registerTrigger = function (namespaceId, name, trigger) { - var /** @type {?} */ ns = this._namespaceLookup[namespaceId]; - if (ns && ns.register(name, trigger)) { - this.totalAnimations++; - } + Parse5DomAdapter.prototype.setStyle = function (element, styleName, styleValue) { + var /** @type {?} */ styleMap = this._readStyleAttribute(element); + ((styleMap))[styleName] = styleValue; + this._writeStyleAttribute(element, styleMap); }; /** - * @param {?} namespaceId - * @param {?} context + * @param {?} element + * @param {?} styleName * @return {?} */ - TransitionAnimationEngine.prototype.destroy = function (namespaceId, context) { - var _this = this; - if (!namespaceId) - return; - var /** @type {?} */ ns = this._fetchNamespace(namespaceId); - this.afterFlush(function () { - _this.namespacesByHostElement.delete(ns.hostElement); - delete _this._namespaceLookup[namespaceId]; - var /** @type {?} */ index = _this._namespaceList.indexOf(ns); - if (index >= 0) { - _this._namespaceList.splice(index, 1); - } - }); - this.afterFlushAnimationsDone(function () { return ns.destroy(context); }); + Parse5DomAdapter.prototype.removeStyle = function (element, styleName) { this.setStyle(element, styleName, null); }; + /** + * @param {?} element + * @param {?} styleName + * @return {?} + */ + Parse5DomAdapter.prototype.getStyle = function (element, styleName) { + var /** @type {?} */ styleMap = this._readStyleAttribute(element); + return styleMap.hasOwnProperty(styleName) ? ((styleMap))[styleName] : ''; }; /** - * @param {?} id + * @param {?} element * @return {?} */ - TransitionAnimationEngine.prototype._fetchNamespace = function (id) { return this._namespaceLookup[id]; }; + Parse5DomAdapter.prototype.tagName = function (element) { return element.tagName == 'style' ? 'STYLE' : element.tagName; }; /** - * @param {?} namespaceId * @param {?} element - * @param {?} name - * @param {?} value * @return {?} */ - TransitionAnimationEngine.prototype.trigger = function (namespaceId, element, name, value) { - if (isElementNode(element)) { - this._fetchNamespace(namespaceId).trigger(element, name, value); - return true; + Parse5DomAdapter.prototype.attributeMap = function (element) { + var /** @type {?} */ res = new Map(); + var /** @type {?} */ elAttrs = treeAdapter.getAttrList(element); + for (var /** @type {?} */ i = 0; i < elAttrs.length; i++) { + var /** @type {?} */ attrib = elAttrs[i]; + res.set(attrib.name, attrib.value); } - return false; + return res; }; /** - * @param {?} namespaceId * @param {?} element - * @param {?} parent - * @param {?} insertBefore + * @param {?} attribute * @return {?} */ - TransitionAnimationEngine.prototype.insertNode = function (namespaceId, element, parent, insertBefore) { - if (!isElementNode(element)) - return; - // special case for when an element is removed and reinserted (move operation) - // when this occurs we do not want to use the element for deletion later - var /** @type {?} */ details = (element[REMOVAL_FLAG]); - if (details && details.setForRemoval) { - details.setForRemoval = false; - } - // in the event that the namespaceId is blank then the caller - // code does not contain any animation code in it, but it is - // just being called so that the node is marked as being inserted - if (namespaceId) { - this._fetchNamespace(namespaceId).insertNode(element, parent); - } - // only *directives and host elements are inserted before - if (insertBefore) { - this.collectEnterElement(element); - } + Parse5DomAdapter.prototype.hasAttribute = function (element, attribute) { + return element.attribs && element.attribs[attribute] != null; }; /** * @param {?} element + * @param {?} ns + * @param {?} attribute * @return {?} */ - TransitionAnimationEngine.prototype.collectEnterElement = function (element) { this.collectedEnterElements.push(element); }; + Parse5DomAdapter.prototype.hasAttributeNS = function (element, ns, attribute) { + return this.hasAttribute(element, attribute); + }; /** - * @param {?} namespaceId * @param {?} element - * @param {?} context - * @param {?=} doNotRecurse + * @param {?} attribute * @return {?} */ - TransitionAnimationEngine.prototype.removeNode = function (namespaceId, element, context, doNotRecurse) { - if (!isElementNode(element)) { - this._onRemovalComplete(element, context); - return; - } - var /** @type {?} */ ns = namespaceId ? this._fetchNamespace(namespaceId) : null; - if (ns) { - ns.removeNode(element, context, doNotRecurse); - } - else { - this.markElementAsRemoved(namespaceId, element, false, context); - } + Parse5DomAdapter.prototype.getAttribute = function (element, attribute) { + return this.hasAttribute(element, attribute) ? element.attribs[attribute] : null; }; /** - * @param {?} namespaceId * @param {?} element - * @param {?=} hasAnimation - * @param {?=} context + * @param {?} ns + * @param {?} attribute * @return {?} */ - TransitionAnimationEngine.prototype.markElementAsRemoved = function (namespaceId, element, hasAnimation, context) { - this.collectedLeaveElements.push(element); - element[REMOVAL_FLAG] = { - namespaceId: namespaceId, - setForRemoval: context, hasAnimation: hasAnimation, - removedBeforeQueried: false - }; + Parse5DomAdapter.prototype.getAttributeNS = function (element, ns, attribute) { + return this.getAttribute(element, attribute); }; /** - * @param {?} namespaceId * @param {?} element - * @param {?} name - * @param {?} phase - * @param {?} callback + * @param {?} attribute + * @param {?} value * @return {?} */ - TransitionAnimationEngine.prototype.listen = function (namespaceId, element, name, phase, callback) { - if (isElementNode(element)) { - return this._fetchNamespace(namespaceId).listen(element, name, phase, callback); + Parse5DomAdapter.prototype.setAttribute = function (element, attribute, value) { + if (attribute) { + element.attribs[attribute] = value; + if (attribute === 'class') { + element.className = value; + } } - return function () { }; }; /** - * @param {?} entry - * @param {?} subTimelines + * @param {?} element + * @param {?} ns + * @param {?} attribute + * @param {?} value * @return {?} */ - TransitionAnimationEngine.prototype._buildInstruction = function (entry, subTimelines) { - return entry.transition.build(this.driver, entry.element, entry.fromState.value, entry.toState.value, entry.toState.options, subTimelines); + Parse5DomAdapter.prototype.setAttributeNS = function (element, ns, attribute, value) { + this.setAttribute(element, attribute, value); }; /** - * @param {?} containerElement + * @param {?} element + * @param {?} attribute * @return {?} */ - TransitionAnimationEngine.prototype.destroyInnerAnimations = function (containerElement) { - var _this = this; - var /** @type {?} */ elements = this.driver.query(containerElement, NG_TRIGGER_SELECTOR, true); - elements.forEach(function (element) { - var /** @type {?} */ players = _this.playersByElement.get(element); - if (players) { - players.forEach(function (player) { - // special case for when an element is set for destruction, but hasn't started. - // in this situation we want to delay the destruction until the flush occurs - // so that any event listeners attached to the player are triggered. - if (player.queued) { - player.markedForDestroy = true; - } - else { - player.destroy(); - } - }); - } - var /** @type {?} */ stateMap = _this.statesByElement.get(element); - if (stateMap) { - Object.keys(stateMap).forEach(function (triggerName) { return stateMap[triggerName] = DELETED_STATE_VALUE; }); - } - }); - if (this.playersByQueriedElement.size == 0) - return; - elements = this.driver.query(containerElement, NG_ANIMATING_SELECTOR, true); - if (elements.length) { - elements.forEach(function (element) { - var /** @type {?} */ players = _this.playersByQueriedElement.get(element); - if (players) { - players.forEach(function (player) { return player.finish(); }); - } - }); + Parse5DomAdapter.prototype.removeAttribute = function (element, attribute) { + if (attribute) { + delete element.attribs[attribute]; } }; /** + * @param {?} element + * @param {?} ns + * @param {?} name * @return {?} */ - TransitionAnimationEngine.prototype.whenRenderingDone = function () { - var _this = this; - return new Promise(function (resolve) { - if (_this.players.length) { - return optimizeGroupPlayer(_this.players).onDone(function () { return resolve(); }); - } - else { - resolve(); - } - }); - }; + Parse5DomAdapter.prototype.removeAttributeNS = function (element, ns, name) { throw 'not implemented'; }; /** - * @param {?} element + * @param {?} el * @return {?} */ - TransitionAnimationEngine.prototype.processLeaveNode = function (element) { - var /** @type {?} */ details = (element[REMOVAL_FLAG]); - if (details && details.setForRemoval) { - // this will prevent it from removing it twice - element[REMOVAL_FLAG] = NULL_REMOVAL_STATE; - if (details.namespaceId) { - this.destroyInnerAnimations(element); - var /** @type {?} */ ns = this._fetchNamespace(details.namespaceId); - if (ns) { - ns.clearElementCache(element); - } - } - this._onRemovalComplete(element, details.setForRemoval); - } + Parse5DomAdapter.prototype.templateAwareRoot = function (el) { + return this.isTemplateElement(el) ? treeAdapter.getTemplateContent(el) : el; }; /** - * @param {?=} microtaskId * @return {?} */ - TransitionAnimationEngine.prototype.flush = function (microtaskId) { - var _this = this; - if (microtaskId === void 0) { microtaskId = -1; } - var /** @type {?} */ players = []; - if (this.newHostElements.size) { - this.newHostElements.forEach(function (ns, element) { return _this._balanceNamespaceList(ns, element); }); - this.newHostElements.clear(); - } - if (this._namespaceList.length && - (this.totalQueuedPlayers || this.collectedLeaveElements.length)) { - players = this._flushAnimations(microtaskId); - } - else { - for (var /** @type {?} */ i = 0; i < this.collectedLeaveElements.length; i++) { - var /** @type {?} */ element = this.collectedLeaveElements[i]; - this.processLeaveNode(element); - } - } - this.totalQueuedPlayers = 0; - this.collectedEnterElements.length = 0; - this.collectedLeaveElements.length = 0; - this._flushFns.forEach(function (fn) { return fn(); }); - this._flushFns = []; - if (this._whenQuietFns.length) { - // we move these over to a variable so that - // if any new callbacks are registered in another - // flush they do not populate the existing set - var /** @type {?} */ quietFns_1 = this._whenQuietFns; - this._whenQuietFns = []; - if (players.length) { - optimizeGroupPlayer(players).onDone(function () { quietFns_1.forEach(function (fn) { return fn(); }); }); - } - else { - quietFns_1.forEach(function (fn) { return fn(); }); - } - } + Parse5DomAdapter.prototype.createHtmlDocument = function () { + var /** @type {?} */ newDoc = treeAdapter.createDocument(); + newDoc.title = 'fakeTitle'; + var /** @type {?} */ head = treeAdapter.createElement('head', null, []); + var /** @type {?} */ body = treeAdapter.createElement('body', 'http://www.w3.org/1999/xhtml', []); + this.appendChild(newDoc, head); + this.appendChild(newDoc, body); + newDoc['head'] = head; + newDoc['body'] = body; + newDoc['_window'] = {}; + return newDoc; }; /** - * @param {?} microtaskId + * @param {?} el * @return {?} */ - TransitionAnimationEngine.prototype._flushAnimations = function (microtaskId) { - var _this = this; - var /** @type {?} */ subTimelines = new ElementInstructionMap(); - var /** @type {?} */ skippedPlayers = []; - var /** @type {?} */ skippedPlayersMap = new Map(); - var /** @type {?} */ queuedInstructions = []; - var /** @type {?} */ queriedElements = new Map(); - var /** @type {?} */ allPreStyleElements = new Map(); - var /** @type {?} */ allPostStyleElements = new Map(); - var /** @type {?} */ bodyNode = getBodyNode(); - var /** @type {?} */ allEnterNodes = this.collectedEnterElements.length ? - this.collectedEnterElements.filter(createIsRootFilterFn(this.collectedEnterElements)) : - []; - // this must occur before the instructions are built below such that - // the :enter queries match the elements (since the timeline queries - // are fired during instruction building). - for (var /** @type {?} */ i = 0; i < allEnterNodes.length; i++) { - addClass(allEnterNodes[i], ENTER_CLASSNAME); - } - var /** @type {?} */ allLeaveNodes = []; - var /** @type {?} */ leaveNodesWithoutAnimations = []; - for (var /** @type {?} */ i = 0; i < this.collectedLeaveElements.length; i++) { - var /** @type {?} */ element = this.collectedLeaveElements[i]; - var /** @type {?} */ details = (element[REMOVAL_FLAG]); - if (details && details.setForRemoval) { - addClass(element, LEAVE_CLASSNAME); - allLeaveNodes.push(element); - if (!details.hasAnimation) { - leaveNodesWithoutAnimations.push(element); - } - } - } - for (var /** @type {?} */ i = this._namespaceList.length - 1; i >= 0; i--) { - var /** @type {?} */ ns = this._namespaceList[i]; - ns.drainQueuedTransitions(microtaskId).forEach(function (entry) { - var /** @type {?} */ player = entry.player; - var /** @type {?} */ element = entry.element; - if (!bodyNode || !_this.driver.containsElement(bodyNode, element)) { - player.destroy(); - return; - } - var /** @type {?} */ instruction = _this._buildInstruction(entry, subTimelines); - if (!instruction) - return; - // if a unmatched transition is queued to go then it SHOULD NOT render - // an animation and cancel the previously running animations. - if (entry.isFallbackTransition) { - player.onStart(function () { return eraseStyles(element, instruction.fromStyles); }); - player.onDestroy(function () { return setStyles(element, instruction.toStyles); }); - skippedPlayers.push(player); - return; - } - // this means that if a parent animation uses this animation as a sub trigger - // then it will instruct the timeline builder to not add a player delay, but - // instead stretch the first keyframe gap up until the animation starts. The - // reason this is important is to prevent extra initialization styles from being - // required by the user in the animation. - instruction.timelines.forEach(function (tl) { return tl.stretchStartingKeyframe = true; }); - subTimelines.append(element, instruction.timelines); - var /** @type {?} */ tuple = { instruction: instruction, player: player, element: element }; - queuedInstructions.push(tuple); - instruction.queriedElements.forEach(function (element) { return getOrSetAsInMap(queriedElements, element, []).push(player); }); - instruction.preStyleProps.forEach(function (stringMap, element) { - var /** @type {?} */ props = Object.keys(stringMap); - if (props.length) { - var /** @type {?} */ setVal_1 = ((allPreStyleElements.get(element))); - if (!setVal_1) { - allPreStyleElements.set(element, setVal_1 = new Set()); - } - props.forEach(function (prop) { return setVal_1.add(prop); }); - } - }); - instruction.postStyleProps.forEach(function (stringMap, element) { - var /** @type {?} */ props = Object.keys(stringMap); - var /** @type {?} */ setVal = ((allPostStyleElements.get(element))); - if (!setVal) { - allPostStyleElements.set(element, setVal = new Set()); - } - props.forEach(function (prop) { return setVal.add(prop); }); - }); - }); - } - // these can only be detected here since we have a map of all the elements - // that have animations attached to them... - var /** @type {?} */ enterNodesWithoutAnimations = []; - for (var /** @type {?} */ i = 0; i < allEnterNodes.length; i++) { - var /** @type {?} */ element = allEnterNodes[i]; - if (!subTimelines.has(element)) { - enterNodesWithoutAnimations.push(element); - } - } - var /** @type {?} */ allPreviousPlayersMap = new Map(); - var /** @type {?} */ sortedParentElements = []; - queuedInstructions.forEach(function (entry) { - var /** @type {?} */ element = entry.element; - if (subTimelines.has(element)) { - sortedParentElements.unshift(element); - _this._beforeAnimationBuild(entry.player.namespaceId, entry.instruction, allPreviousPlayersMap); - } - }); - skippedPlayers.forEach(function (player) { - var /** @type {?} */ element = player.element; - var /** @type {?} */ previousPlayers = _this._getPreviousPlayers(element, false, player.namespaceId, player.triggerName, null); - previousPlayers.forEach(function (prevPlayer) { getOrSetAsInMap(allPreviousPlayersMap, element, []).push(prevPlayer); }); - }); - allPreviousPlayersMap.forEach(function (players) { return players.forEach(function (player) { return player.destroy(); }); }); - // PRE STAGE: fill the ! styles - var /** @type {?} */ preStylesMap = allPreStyleElements.size ? - cloakAndComputeStyles(this.driver, enterNodesWithoutAnimations, allPreStyleElements, _angular_animations.ɵPRE_STYLE) : - new Map(); - // POST STAGE: fill the * styles - var /** @type {?} */ postStylesMap = cloakAndComputeStyles(this.driver, leaveNodesWithoutAnimations, allPostStyleElements, _angular_animations.AUTO_STYLE); - var /** @type {?} */ rootPlayers = []; - var /** @type {?} */ subPlayers = []; - queuedInstructions.forEach(function (entry) { - var element = entry.element, player = entry.player, instruction = entry.instruction; - // this means that it was never consumed by a parent animation which - // means that it is independent and therefore should be set for animation - if (subTimelines.has(element)) { - var /** @type {?} */ innerPlayer = _this._buildAnimation(player.namespaceId, instruction, allPreviousPlayersMap, skippedPlayersMap, preStylesMap, postStylesMap); - player.setRealPlayer(innerPlayer); - var /** @type {?} */ parentHasPriority = null; - for (var /** @type {?} */ i = 0; i < sortedParentElements.length; i++) { - var /** @type {?} */ parent = sortedParentElements[i]; - if (parent === element) - break; - if (_this.driver.containsElement(parent, element)) { - parentHasPriority = parent; - break; - } - } - if (parentHasPriority) { - var /** @type {?} */ parentPlayers = _this.playersByElement.get(parentHasPriority); - if (parentPlayers && parentPlayers.length) { - player.parentPlayer = optimizeGroupPlayer(parentPlayers); - } - skippedPlayers.push(player); - } - else { - rootPlayers.push(player); - } - } - else { - eraseStyles(element, instruction.fromStyles); - player.onDestroy(function () { return setStyles(element, instruction.toStyles); }); - subPlayers.push(player); - } - }); - subPlayers.forEach(function (player) { - var /** @type {?} */ playersForElement = skippedPlayersMap.get(player.element); - if (playersForElement && playersForElement.length) { - var /** @type {?} */ innerPlayer = optimizeGroupPlayer(playersForElement); - player.setRealPlayer(innerPlayer); - } - }); - // the reason why we don't actually play the animation is - // because all that a skipped player is designed to do is to - // fire the start/done transition callback events - skippedPlayers.forEach(function (player) { - if (player.parentPlayer) { - player.parentPlayer.onDestroy(function () { return player.destroy(); }); - } - else { - player.destroy(); - } - }); - // run through all of the queued removals and see if they - // were picked up by a query. If not then perform the removal - // operation right away unless a parent animation is ongoing. - for (var /** @type {?} */ i = 0; i < allLeaveNodes.length; i++) { - var /** @type {?} */ element = allLeaveNodes[i]; - var /** @type {?} */ details = (element[REMOVAL_FLAG]); - // this means the element has a removal animation that is being - // taken care of and therefore the inner elements will hang around - // until that animation is over (or the parent queried animation) - if (details && details.hasAnimation) - continue; - var /** @type {?} */ players = []; - // if this element is queried or if it contains queried children - // then we want for the element not to be removed from the page - // until the queried animations have finished - if (queriedElements.size) { - var /** @type {?} */ queriedPlayerResults = queriedElements.get(element); - if (queriedPlayerResults && queriedPlayerResults.length) { - players.push.apply(players, queriedPlayerResults); - } - var /** @type {?} */ queriedInnerElements = this.driver.query(element, NG_ANIMATING_SELECTOR, true); - for (var /** @type {?} */ j = 0; j < queriedInnerElements.length; j++) { - var /** @type {?} */ queriedPlayers = queriedElements.get(queriedInnerElements[j]); - if (queriedPlayers && queriedPlayers.length) { - players.push.apply(players, queriedPlayers); - } - } - } - if (players.length) { - removeNodesAfterAnimationDone(this, element, players); - } - else { - this.processLeaveNode(element); - } - } - rootPlayers.forEach(function (player) { - _this.players.push(player); - player.onDone(function () { - player.destroy(); - var /** @type {?} */ index = _this.players.indexOf(player); - _this.players.splice(index, 1); - }); - player.play(); - }); - allEnterNodes.forEach(function (element) { return removeClass(element, ENTER_CLASSNAME); }); - return rootPlayers; + Parse5DomAdapter.prototype.getBoundingClientRect = function (el) { return { left: 0, top: 0, width: 0, height: 0 }; }; + /** + * @param {?} doc + * @return {?} + */ + Parse5DomAdapter.prototype.getTitle = function (doc) { return this.getText(this.getTitleNode(doc)) || ''; }; + /** + * @param {?} doc + * @param {?} newTitle + * @return {?} + */ + Parse5DomAdapter.prototype.setTitle = function (doc, newTitle) { + this.setText(this.getTitleNode(doc), newTitle || ''); }; /** - * @param {?} namespaceId - * @param {?} element + * @param {?} el * @return {?} */ - TransitionAnimationEngine.prototype.elementContainsData = function (namespaceId, element) { - var /** @type {?} */ containsData = false; - var /** @type {?} */ details = (element[REMOVAL_FLAG]); - if (details && details.setForRemoval) - containsData = true; - if (this.playersByElement.has(element)) - containsData = true; - if (this.playersByQueriedElement.has(element)) - containsData = true; - if (this.statesByElement.has(element)) - containsData = true; - return this._fetchNamespace(namespaceId).elementContainsData(element) || containsData; + Parse5DomAdapter.prototype.isTemplateElement = function (el) { + return this.isElementNode(el) && this.tagName(el) === 'template'; }; /** - * @param {?} callback + * @param {?} node * @return {?} */ - TransitionAnimationEngine.prototype.afterFlush = function (callback) { this._flushFns.push(callback); }; + Parse5DomAdapter.prototype.isTextNode = function (node) { return treeAdapter.isTextNode(node); }; /** - * @param {?} callback + * @param {?} node * @return {?} */ - TransitionAnimationEngine.prototype.afterFlushAnimationsDone = function (callback) { this._whenQuietFns.push(callback); }; + Parse5DomAdapter.prototype.isCommentNode = function (node) { return treeAdapter.isCommentNode(node); }; /** - * @param {?} element - * @param {?} isQueriedElement - * @param {?=} namespaceId - * @param {?=} triggerName - * @param {?=} toStateValue + * @param {?} node * @return {?} */ - TransitionAnimationEngine.prototype._getPreviousPlayers = function (element, isQueriedElement, namespaceId, triggerName, toStateValue) { - var /** @type {?} */ players = []; - if (isQueriedElement) { - var /** @type {?} */ queriedElementPlayers = this.playersByQueriedElement.get(element); - if (queriedElementPlayers) { - players = queriedElementPlayers; - } - } - else { - var /** @type {?} */ elementPlayers = this.playersByElement.get(element); - if (elementPlayers) { - var /** @type {?} */ isRemovalAnimation_1 = !toStateValue || toStateValue == VOID_VALUE; - elementPlayers.forEach(function (player) { - if (player.queued) - return; - if (!isRemovalAnimation_1 && player.triggerName != triggerName) - return; - players.push(player); - }); - } - } - if (namespaceId || triggerName) { - players = players.filter(function (player) { - if (namespaceId && namespaceId != player.namespaceId) - return false; - if (triggerName && triggerName != player.triggerName) - return false; - return true; - }); - } - return players; - }; + Parse5DomAdapter.prototype.isElementNode = function (node) { return node ? treeAdapter.isElementNode(node) : false; }; /** - * @param {?} namespaceId - * @param {?} instruction - * @param {?} allPreviousPlayersMap + * @param {?} node * @return {?} */ - TransitionAnimationEngine.prototype._beforeAnimationBuild = function (namespaceId, instruction, allPreviousPlayersMap) { - var _this = this; - // it's important to do this step before destroying the players - // so that the onDone callback below won't fire before this - eraseStyles(instruction.element, instruction.fromStyles); - var /** @type {?} */ triggerName = instruction.triggerName; - var /** @type {?} */ rootElement = instruction.element; - // when a removal animation occurs, ALL previous players are collected - // and destroyed (even if they are outside of the current namespace) - var /** @type {?} */ targetNameSpaceId = instruction.isRemovalTransition ? undefined : namespaceId; - var /** @type {?} */ targetTriggerName = instruction.isRemovalTransition ? undefined : triggerName; - instruction.timelines.map(function (timelineInstruction) { - var /** @type {?} */ element = timelineInstruction.element; - var /** @type {?} */ isQueriedElement = element !== rootElement; - var /** @type {?} */ players = getOrSetAsInMap(allPreviousPlayersMap, element, []); - var /** @type {?} */ previousPlayers = _this._getPreviousPlayers(element, isQueriedElement, targetNameSpaceId, targetTriggerName, instruction.toState); - previousPlayers.forEach(function (player) { - var /** @type {?} */ realPlayer = (player.getRealPlayer()); - if (realPlayer.beforeDestroy) { - realPlayer.beforeDestroy(); - } - players.push(player); - }); - }); - }; + Parse5DomAdapter.prototype.hasShadowRoot = function (node) { return node.shadowRoot != null; }; /** - * @param {?} namespaceId - * @param {?} instruction - * @param {?} allPreviousPlayersMap - * @param {?} skippedPlayersMap - * @param {?} preStylesMap - * @param {?} postStylesMap + * @param {?} node * @return {?} */ - TransitionAnimationEngine.prototype._buildAnimation = function (namespaceId, instruction, allPreviousPlayersMap, skippedPlayersMap, preStylesMap, postStylesMap) { - var _this = this; - var /** @type {?} */ triggerName = instruction.triggerName; - var /** @type {?} */ rootElement = instruction.element; - // we first run this so that the previous animation player - // data can be passed into the successive animation players - var /** @type {?} */ allQueriedPlayers = []; - var /** @type {?} */ allConsumedElements = new Set(); - var /** @type {?} */ allSubElements = new Set(); - var /** @type {?} */ allNewPlayers = instruction.timelines.map(function (timelineInstruction) { - var /** @type {?} */ element = timelineInstruction.element; - // FIXME (matsko): make sure to-be-removed animations are removed properly - var /** @type {?} */ details = element[REMOVAL_FLAG]; - if (details && details.removedBeforeQueried) - return new _angular_animations.NoopAnimationPlayer(); - var /** @type {?} */ isQueriedElement = element !== rootElement; - var /** @type {?} */ previousPlayers = EMPTY_PLAYER_ARRAY; - if (!allConsumedElements.has(element)) { - allConsumedElements.add(element); - var /** @type {?} */ _previousPlayers = allPreviousPlayersMap.get(element); - if (_previousPlayers) { - previousPlayers = _previousPlayers.map(function (p) { return p.getRealPlayer(); }); - } - } - var /** @type {?} */ preStyles = preStylesMap.get(element); - var /** @type {?} */ postStyles = postStylesMap.get(element); - var /** @type {?} */ keyframes = normalizeKeyframes(_this.driver, _this._normalizer, element, timelineInstruction.keyframes, preStyles, postStyles); - var /** @type {?} */ player = _this._buildPlayer(timelineInstruction, keyframes, previousPlayers); - // this means that this particular player belongs to a sub trigger. It is - // important that we match this player up with the corresponding (@trigger.listener) - if (timelineInstruction.subTimeline && skippedPlayersMap) { - allSubElements.add(element); - } - if (isQueriedElement) { - var /** @type {?} */ wrappedPlayer = new TransitionAnimationPlayer(namespaceId, triggerName, element); - wrappedPlayer.setRealPlayer(player); - allQueriedPlayers.push(wrappedPlayer); - } - return player; - }); - allQueriedPlayers.forEach(function (player) { - getOrSetAsInMap(_this.playersByQueriedElement, player.element, []).push(player); - player.onDone(function () { return deleteOrUnsetInMap(_this.playersByQueriedElement, player.element, player); }); - }); - allConsumedElements.forEach(function (element) { return addClass(element, NG_ANIMATING_CLASSNAME); }); - var /** @type {?} */ player = optimizeGroupPlayer(allNewPlayers); - player.onDestroy(function () { - allConsumedElements.forEach(function (element) { return removeClass(element, NG_ANIMATING_CLASSNAME); }); - setStyles(rootElement, instruction.toStyles); - }); - // this basically makes all of the callbacks for sub element animations - // be dependent on the upper players for when they finish - allSubElements.forEach(function (element) { getOrSetAsInMap(skippedPlayersMap, element, []).push(player); }); - return player; - }; + Parse5DomAdapter.prototype.isShadowRoot = function (node) { return this.getShadowRoot(node) == node; }; /** - * @param {?} instruction - * @param {?} keyframes - * @param {?} previousPlayers + * @param {?} node * @return {?} */ - TransitionAnimationEngine.prototype._buildPlayer = function (instruction, keyframes, previousPlayers) { - if (keyframes.length > 0) { - return this.driver.animate(instruction.element, keyframes, instruction.duration, instruction.delay, instruction.easing, previousPlayers); - } - // special case for when an empty transition|definition is provided - // ... there is no point in rendering an empty animation - return new _angular_animations.NoopAnimationPlayer(); - }; - return TransitionAnimationEngine; -}()); -var TransitionAnimationPlayer = (function () { - /** - * @param {?} namespaceId - * @param {?} triggerName - * @param {?} element - */ - function TransitionAnimationPlayer(namespaceId, triggerName, element) { - this.namespaceId = namespaceId; - this.triggerName = triggerName; - this.element = element; - this._player = new _angular_animations.NoopAnimationPlayer(); - this._containsRealPlayer = false; - this._queuedCallbacks = {}; - this._destroyed = false; - this.markedForDestroy = false; - } - Object.defineProperty(TransitionAnimationPlayer.prototype, "queued", { - /** - * @return {?} - */ - get: function () { return this._containsRealPlayer == false; }, - enumerable: true, - configurable: true - }); - Object.defineProperty(TransitionAnimationPlayer.prototype, "destroyed", { - /** - * @return {?} - */ - get: function () { return this._destroyed; }, - enumerable: true, - configurable: true - }); + Parse5DomAdapter.prototype.importIntoDoc = function (node) { return this.clone(node); }; /** - * @param {?} player + * @param {?} node * @return {?} */ - TransitionAnimationPlayer.prototype.setRealPlayer = function (player) { - var _this = this; - if (this._containsRealPlayer) - return; - this._player = player; - Object.keys(this._queuedCallbacks).forEach(function (phase) { - _this._queuedCallbacks[phase].forEach(function (callback) { return listenOnPlayer(player, phase, undefined, callback); }); - }); - this._queuedCallbacks = {}; - this._containsRealPlayer = true; - }; + Parse5DomAdapter.prototype.adoptNode = function (node) { return node; }; /** + * @param {?} el * @return {?} */ - TransitionAnimationPlayer.prototype.getRealPlayer = function () { return this._player; }; + Parse5DomAdapter.prototype.getHref = function (el) { return this.getAttribute(el, 'href'); }; /** - * @param {?} name - * @param {?} callback + * @param {?} el + * @param {?} baseUrl + * @param {?} href * @return {?} */ - TransitionAnimationPlayer.prototype._queueEvent = function (name, callback) { - getOrSetAsInMap(this._queuedCallbacks, name, []).push(callback); + Parse5DomAdapter.prototype.resolveAndSetHref = function (el, baseUrl, href) { + if (href == null) { + el.href = baseUrl; + } + else { + el.href = baseUrl + '/../' + href; + } }; /** - * @param {?} fn + * \@internal + * @param {?} parsedRules + * @param {?=} css * @return {?} */ - TransitionAnimationPlayer.prototype.onDone = function (fn) { - if (this.queued) { - this._queueEvent('done', fn); + Parse5DomAdapter.prototype._buildRules = function (parsedRules, css) { + var /** @type {?} */ rules = []; + for (var /** @type {?} */ i = 0; i < parsedRules.length; i++) { + var /** @type {?} */ parsedRule = parsedRules[i]; + var /** @type {?} */ rule = {}; + rule['cssText'] = css; + rule['style'] = { content: '', cssText: '' }; + if (parsedRule.type == 'rule') { + rule['type'] = 1; + rule['selectorText'] = + parsedRule.selectors.join(', '.replace(/\s{2,}/g, ' ') + .replace(/\s*~\s*/g, ' ~ ') + .replace(/\s*\+\s*/g, ' + ') + .replace(/\s*>\s*/g, ' > ') + .replace(/\[(\w+)=(\w+)\]/g, '[$1="$2"]')); + if (parsedRule.declarations == null) { + continue; + } + for (var /** @type {?} */ j = 0; j < parsedRule.declarations.length; j++) { + var /** @type {?} */ declaration = parsedRule.declarations[j]; + rule['style'] = declaration.property[declaration.value]; + rule['style'].cssText += declaration.property + ': ' + declaration.value + ';'; + } + } + else if (parsedRule.type == 'media') { + rule['type'] = 4; + rule['media'] = { mediaText: parsedRule.media }; + if (parsedRule.rules) { + rule['cssRules'] = this._buildRules(parsedRule.rules); + } + } + rules.push(rule); } - this._player.onDone(fn); + return rules; }; /** - * @param {?} fn * @return {?} */ - TransitionAnimationPlayer.prototype.onStart = function (fn) { - if (this.queued) { - this._queueEvent('start', fn); + Parse5DomAdapter.prototype.supportsDOMEvents = function () { return false; }; + /** + * @return {?} + */ + Parse5DomAdapter.prototype.supportsNativeShadowDOM = function () { return false; }; + /** + * @param {?} doc + * @param {?} target + * @return {?} + */ + Parse5DomAdapter.prototype.getGlobalEventTarget = function (doc, target) { + if (target == 'window') { + return ((doc))._window; + } + else if (target == 'document') { + return doc; + } + else if (target == 'body') { + return doc.body; } - this._player.onStart(fn); }; /** - * @param {?} fn + * @param {?} doc * @return {?} */ - TransitionAnimationPlayer.prototype.onDestroy = function (fn) { - if (this.queued) { - this._queueEvent('destroy', fn); + Parse5DomAdapter.prototype.getBaseHref = function (doc) { + var /** @type {?} */ base = this.querySelector(doc, 'base'); + var /** @type {?} */ href = ''; + if (base) { + href = this.getHref(base); } - this._player.onDestroy(fn); + // TODO(alxhub): Need relative path logic from BrowserDomAdapter here? + return href == null ? null : href; }; /** * @return {?} */ - TransitionAnimationPlayer.prototype.init = function () { this._player.init(); }; + Parse5DomAdapter.prototype.resetBaseElement = function () { throw 'not implemented'; }; /** * @return {?} */ - TransitionAnimationPlayer.prototype.hasStarted = function () { return this.queued ? false : this._player.hasStarted(); }; + Parse5DomAdapter.prototype.getHistory = function () { throw 'not implemented'; }; /** * @return {?} */ - TransitionAnimationPlayer.prototype.play = function () { !this.queued && this._player.play(); }; + Parse5DomAdapter.prototype.getLocation = function () { throw 'not implemented'; }; /** * @return {?} */ - TransitionAnimationPlayer.prototype.pause = function () { !this.queued && this._player.pause(); }; + Parse5DomAdapter.prototype.getUserAgent = function () { return 'Fake user agent'; }; /** + * @param {?} el + * @param {?} name * @return {?} */ - TransitionAnimationPlayer.prototype.restart = function () { !this.queued && this._player.restart(); }; + Parse5DomAdapter.prototype.getData = function (el, name) { return this.getAttribute(el, 'data-' + name); }; /** + * @param {?} el * @return {?} */ - TransitionAnimationPlayer.prototype.finish = function () { this._player.finish(); }; + Parse5DomAdapter.prototype.getComputedStyle = function (el) { throw 'not implemented'; }; /** + * @param {?} el + * @param {?} name + * @param {?} value * @return {?} */ - TransitionAnimationPlayer.prototype.destroy = function () { - this._destroyed = true; - this._player.destroy(); - }; + Parse5DomAdapter.prototype.setData = function (el, name, value) { this.setAttribute(el, 'data-' + name, value); }; /** * @return {?} */ - TransitionAnimationPlayer.prototype.reset = function () { !this.queued && this._player.reset(); }; + Parse5DomAdapter.prototype.supportsWebAnimation = function () { return false; }; /** - * @param {?} p * @return {?} */ - TransitionAnimationPlayer.prototype.setPosition = function (p) { - if (!this.queued) { - this._player.setPosition(p); - } - }; + Parse5DomAdapter.prototype.performanceNow = function () { return Date.now(); }; /** * @return {?} */ - TransitionAnimationPlayer.prototype.getPosition = function () { return this.queued ? 0 : this._player.getPosition(); }; - Object.defineProperty(TransitionAnimationPlayer.prototype, "totalTime", { - /** - * @return {?} - */ - get: function () { return this._player.totalTime; }, - enumerable: true, - configurable: true - }); - return TransitionAnimationPlayer; -}()); -/** - * @param {?} map - * @param {?} key - * @param {?} value - * @return {?} - */ -function deleteOrUnsetInMap(map, key, value) { - var /** @type {?} */ currentValues; - if (map instanceof Map) { - currentValues = map.get(key); - if (currentValues) { - if (currentValues.length) { - var /** @type {?} */ index = currentValues.indexOf(value); - currentValues.splice(index, 1); - } - if (currentValues.length == 0) { - map.delete(key); - } - } - } - else { - currentValues = map[key]; - if (currentValues) { - if (currentValues.length) { - var /** @type {?} */ index = currentValues.indexOf(value); - currentValues.splice(index, 1); - } - if (currentValues.length == 0) { - delete map[key]; - } - } - } - return currentValues; -} -/** - * @param {?} value - * @return {?} - */ -function normalizeTriggerValue(value) { - switch (typeof value) { - case 'boolean': - return value ? '1' : '0'; - default: - return value != null ? value.toString() : null; - } -} -/** - * @param {?} node - * @return {?} - */ -function isElementNode(node) { - return node && node['nodeType'] === 1; -} -/** - * @param {?} eventName - * @return {?} - */ -function isTriggerEventValid(eventName) { - return eventName == 'start' || eventName == 'done'; -} -/** - * @param {?} element - * @param {?=} value - * @return {?} - */ -function cloakElement(element, value) { - var /** @type {?} */ oldValue = element.style.display; - element.style.display = value != null ? value : 'none'; - return oldValue; -} -/** - * @param {?} driver - * @param {?} elements - * @param {?} elementPropsMap - * @param {?} defaultStyle - * @return {?} - */ -function cloakAndComputeStyles(driver, elements, elementPropsMap, defaultStyle) { - var /** @type {?} */ cloakVals = elements.map(function (element) { return cloakElement(element); }); - var /** @type {?} */ valuesMap = new Map(); - elementPropsMap.forEach(function (props, element) { - var /** @type {?} */ styles = {}; - props.forEach(function (prop) { - var /** @type {?} */ value = styles[prop] = driver.computeStyle(element, prop, defaultStyle); - // there is no easy way to detect this because a sub element could be removed - // by a parent animation element being detached. - if (!value || value.length == 0) { - element[REMOVAL_FLAG] = NULL_REMOVED_QUERIED_STATE; - } - }); - valuesMap.set(element, styles); - }); - elements.forEach(function (element, i) { return cloakElement(element, cloakVals[i]); }); - return valuesMap; -} -/** - * @param {?} nodes - * @return {?} - */ -function createIsRootFilterFn(nodes) { - var /** @type {?} */ nodeSet = new Set(nodes); - var /** @type {?} */ knownRootContainer = new Set(); - var /** @type {?} */ isRoot; - isRoot = function (node) { - if (!node) - return true; - if (nodeSet.has(node.parentNode)) - return false; - if (knownRootContainer.has(node.parentNode)) - return true; - if (isRoot(node.parentNode)) { - knownRootContainer.add(node); - return true; - } - return false; - }; - return isRoot; -} -var CLASSES_CACHE_KEY = '$$classes'; -/** - * @param {?} element - * @param {?} className - * @return {?} - */ -function containsClass(element, className) { - if (element.classList) { - return element.classList.contains(className); - } - else { - var /** @type {?} */ classes = element[CLASSES_CACHE_KEY]; - return classes && classes[className]; - } -} -/** - * @param {?} element - * @param {?} className - * @return {?} - */ -function addClass(element, className) { - if (element.classList) { - element.classList.add(className); - } - else { - var /** @type {?} */ classes = element[CLASSES_CACHE_KEY]; - if (!classes) { - classes = element[CLASSES_CACHE_KEY] = {}; - } - classes[className] = true; - } -} -/** - * @param {?} element - * @param {?} className - * @return {?} - */ -function removeClass(element, className) { - if (element.classList) { - element.classList.remove(className); - } - else { - var /** @type {?} */ classes = element[CLASSES_CACHE_KEY]; - if (classes) { - delete classes[className]; - } - } -} -/** - * @return {?} - */ -function getBodyNode() { - if (typeof document != 'undefined') { - return document.body; - } - return null; -} -/** - * @param {?} engine - * @param {?} element - * @param {?} players - * @return {?} - */ -function removeNodesAfterAnimationDone(engine, element, players) { - optimizeGroupPlayer(players).onDone(function () { return engine.processLeaveNode(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 AnimationEngine = (function () { + Parse5DomAdapter.prototype.getAnimationPrefix = function () { return ''; }; /** - * @param {?} driver - * @param {?} normalizer + * @return {?} */ - function AnimationEngine(driver, normalizer) { - var _this = this; - this._triggerCache = {}; - this.onRemovalComplete = function (element, context) { }; - this._transitionEngine = new TransitionAnimationEngine(driver, normalizer); - this._timelineEngine = new TimelineAnimationEngine(driver, normalizer); - this._transitionEngine.onRemovalComplete = - function (element, context) { _this.onRemovalComplete(element, context); }; - } + Parse5DomAdapter.prototype.getTransitionEnd = function () { return 'transitionend'; }; /** - * @param {?} componentId - * @param {?} namespaceId - * @param {?} hostElement - * @param {?} name - * @param {?} metadata * @return {?} */ - AnimationEngine.prototype.registerTrigger = function (componentId, namespaceId, hostElement, name, metadata) { - var /** @type {?} */ cacheKey = componentId + '-' + name; - var /** @type {?} */ trigger = this._triggerCache[cacheKey]; - if (!trigger) { - var /** @type {?} */ errors = []; - var /** @type {?} */ ast = (buildAnimationAst(/** @type {?} */ (metadata), errors)); - if (errors.length) { - throw new Error("The animation trigger \"" + name + "\" has failed to build due to the following errors:\n - " + errors.join("\n - ")); - } - trigger = buildTrigger(name, ast); - this._triggerCache[cacheKey] = trigger; - } - this._transitionEngine.registerTrigger(namespaceId, name, trigger); - }; + Parse5DomAdapter.prototype.supportsAnimation = function () { return true; }; /** - * @param {?} namespaceId - * @param {?} hostElement + * @param {?} el + * @param {?} newNode + * @param {?} oldNode * @return {?} */ - AnimationEngine.prototype.register = function (namespaceId, hostElement) { - this._transitionEngine.register(namespaceId, hostElement); - }; + Parse5DomAdapter.prototype.replaceChild = function (el, newNode, oldNode) { throw new Error('not implemented'); }; /** - * @param {?} namespaceId - * @param {?} context + * @param {?} templateHtml * @return {?} */ - AnimationEngine.prototype.destroy = function (namespaceId, context) { - this._transitionEngine.destroy(namespaceId, context); - }; + Parse5DomAdapter.prototype.parse = function (templateHtml) { throw new Error('not implemented'); }; /** - * @param {?} namespaceId - * @param {?} element - * @param {?} parent - * @param {?} insertBefore + * @param {?} el + * @param {?} methodName + * @param {?} args * @return {?} */ - AnimationEngine.prototype.onInsert = function (namespaceId, element, parent, insertBefore) { - this._transitionEngine.insertNode(namespaceId, element, parent, insertBefore); - }; + Parse5DomAdapter.prototype.invoke = function (el, methodName, args) { throw new Error('not implemented'); }; /** - * @param {?} namespaceId - * @param {?} element - * @param {?} context + * @param {?} event * @return {?} */ - AnimationEngine.prototype.onRemove = function (namespaceId, element, context) { - this._transitionEngine.removeNode(namespaceId, element, context); - }; + Parse5DomAdapter.prototype.getEventKey = function (event) { throw new Error('not implemented'); }; /** - * @param {?} namespaceId - * @param {?} element - * @param {?} property - * @param {?} value * @return {?} */ - AnimationEngine.prototype.setProperty = function (namespaceId, element, property, value) { - // @@property - if (property.charAt(0) == '@') { - var _a = parseTimelineCommand(property), id = _a[0], action = _a[1]; - var /** @type {?} */ args = (value); - this._timelineEngine.command(id, element, action, args); - return false; - } - return this._transitionEngine.trigger(namespaceId, element, property, value); - }; + Parse5DomAdapter.prototype.supportsCookies = function () { return false; }; /** - * @param {?} namespaceId - * @param {?} element - * @param {?} eventName - * @param {?} eventPhase - * @param {?} callback + * @param {?} name * @return {?} */ - AnimationEngine.prototype.listen = function (namespaceId, element, eventName, eventPhase, callback) { - // @@listen - if (eventName.charAt(0) == '@') { - var _a = parseTimelineCommand(eventName), id = _a[0], action = _a[1]; - return this._timelineEngine.listen(id, element, action, callback); - } - return this._transitionEngine.listen(namespaceId, element, eventName, eventPhase, callback); - }; + Parse5DomAdapter.prototype.getCookie = function (name) { throw new Error('not implemented'); }; /** - * @param {?=} microtaskId + * @param {?} name + * @param {?} value * @return {?} */ - AnimationEngine.prototype.flush = function (microtaskId) { - if (microtaskId === void 0) { microtaskId = -1; } - this._transitionEngine.flush(microtaskId); - }; - Object.defineProperty(AnimationEngine.prototype, "players", { - /** - * @return {?} - */ - get: function () { - return ((this._transitionEngine.players)) - .concat(/** @type {?} */ (this._timelineEngine.players)); - }, - enumerable: true, - configurable: true - }); + Parse5DomAdapter.prototype.setCookie = function (name, value) { throw new Error('not implemented'); }; /** + * @param {?} element + * @param {?} keyframes + * @param {?} options * @return {?} */ - AnimationEngine.prototype.whenRenderingDone = function () { return this._transitionEngine.whenRenderingDone(); }; - return AnimationEngine; -}()); + Parse5DomAdapter.prototype.animate = function (element, keyframes, options) { throw new Error('not implemented'); }; + /** + * @param {?} doc + * @return {?} + */ + Parse5DomAdapter.prototype.getTitleNode = function (doc) { + var /** @type {?} */ title = this.querySelector(doc, 'title'); + if (!title) { + title = (this.createElement('title')); + this.appendChild(this.querySelector(doc, 'head'), title); + } + return title; + }; + return Parse5DomAdapter; +}(_angular_platformBrowser.ɵDomAdapter)); +// TODO: build a proper list, this one is all the keys of a HTMLInputElement +var _HTMLElementPropertyList = [ + 'webkitEntries', + 'incremental', + 'webkitdirectory', + 'selectionDirection', + 'selectionEnd', + 'selectionStart', + 'labels', + 'validationMessage', + 'validity', + 'willValidate', + 'width', + 'valueAsNumber', + 'valueAsDate', + 'value', + 'useMap', + 'defaultValue', + 'type', + 'step', + 'src', + 'size', + 'required', + 'readOnly', + 'placeholder', + 'pattern', + 'name', + 'multiple', + 'min', + 'minLength', + 'maxLength', + 'max', + 'list', + 'indeterminate', + 'height', + 'formTarget', + 'formNoValidate', + 'formMethod', + 'formEnctype', + 'formAction', + 'files', + 'form', + 'disabled', + 'dirName', + 'checked', + 'defaultChecked', + 'autofocus', + 'autocomplete', + 'alt', + 'align', + 'accept', + 'onautocompleteerror', + 'onautocomplete', + 'onwaiting', + 'onvolumechange', + 'ontoggle', + 'ontimeupdate', + 'onsuspend', + 'onsubmit', + 'onstalled', + 'onshow', + 'onselect', + 'onseeking', + 'onseeked', + 'onscroll', + 'onresize', + 'onreset', + 'onratechange', + 'onprogress', + 'onplaying', + 'onplay', + 'onpause', + 'onmousewheel', + 'onmouseup', + 'onmouseover', + 'onmouseout', + 'onmousemove', + 'onmouseleave', + 'onmouseenter', + 'onmousedown', + 'onloadstart', + 'onloadedmetadata', + 'onloadeddata', + 'onload', + 'onkeyup', + 'onkeypress', + 'onkeydown', + 'oninvalid', + 'oninput', + 'onfocus', + 'onerror', + 'onended', + 'onemptied', + 'ondurationchange', + 'ondrop', + 'ondragstart', + 'ondragover', + 'ondragleave', + 'ondragenter', + 'ondragend', + 'ondrag', + 'ondblclick', + 'oncuechange', + 'oncontextmenu', + 'onclose', + 'onclick', + 'onchange', + 'oncanplaythrough', + 'oncanplay', + 'oncancel', + 'onblur', + 'onabort', + 'spellcheck', + 'isContentEditable', + 'contentEditable', + 'outerText', + 'innerText', + 'accessKey', + 'hidden', + 'webkitdropzone', + 'draggable', + 'tabIndex', + 'dir', + 'translate', + 'lang', + 'title', + 'childElementCount', + 'lastElementChild', + 'firstElementChild', + 'children', + 'onwebkitfullscreenerror', + 'onwebkitfullscreenchange', + 'nextElementSibling', + 'previousElementSibling', + 'onwheel', + 'onselectstart', + 'onsearch', + 'onpaste', + 'oncut', + 'oncopy', + 'onbeforepaste', + 'onbeforecut', + 'onbeforecopy', + 'shadowRoot', + 'dataset', + 'classList', + 'className', + 'outerHTML', + 'innerHTML', + 'scrollHeight', + 'scrollWidth', + 'scrollTop', + 'scrollLeft', + 'clientHeight', + 'clientWidth', + 'clientTop', + 'clientLeft', + 'offsetParent', + 'offsetHeight', + 'offsetWidth', + 'offsetTop', + 'offsetLeft', + 'localName', + 'prefix', + 'namespaceURI', + 'id', + 'style', + 'attributes', + 'tagName', + 'parentElement', + 'textContent', + 'baseURI', + 'ownerDocument', + 'nextSibling', + 'previousSibling', + 'lastChild', + 'firstChild', + 'childNodes', + 'parentNode', + 'nodeType', + 'nodeValue', + 'nodeName', + 'closure_lm_714617', + '__jsaction', +]; +/** + * @template T + * @param {?} list + * @param {?} el + * @return {?} + */ +function remove(list, el) { + var /** @type {?} */ index = list.indexOf(el); + if (index > -1) { + list.splice(index, 1); + } +} /** * @license * Copyright Google Inc. All Rights Reserved. @@ -11411,9991 +11155,10728 @@ var AnimationEngine = (function () { * 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 WebAnimationsPlayer = (function () { +var EMPTY_ARRAY = []; +var ServerRendererFactory2 = (function () { /** - * @param {?} element - * @param {?} keyframes - * @param {?} options - * @param {?=} previousPlayers + * @param {?} ngZone + * @param {?} document + * @param {?} sharedStylesHost */ - function WebAnimationsPlayer(element, keyframes, options, previousPlayers) { - if (previousPlayers === void 0) { previousPlayers = []; } - var _this = this; - this.element = element; - this.keyframes = keyframes; - this.options = options; - this.previousPlayers = previousPlayers; - this._onDoneFns = []; - this._onStartFns = []; - this._onDestroyFns = []; - this._initialized = false; - this._finished = false; - this._started = false; - this._destroyed = false; - this.time = 0; - this.parentPlayer = null; - this.currentSnapshot = {}; - this._duration = options['duration']; - this._delay = options['delay'] || 0; - this.time = this._duration + this._delay; - this.previousStyles = {}; - previousPlayers.forEach(function (player) { - var styles = player.currentSnapshot; - Object.keys(styles).forEach(function (prop) { return _this.previousStyles[prop] = styles[prop]; }); - }); + function ServerRendererFactory2(ngZone, document, sharedStylesHost) { + this.ngZone = ngZone; + this.document = document; + this.sharedStylesHost = sharedStylesHost; + this.rendererByCompId = new Map(); + this.schema = new _angular_compiler.DomElementSchemaRegistry(); + this.defaultRenderer = new DefaultServerRenderer2(document, ngZone, this.schema); } + /** + * @param {?} element + * @param {?} type * @return {?} */ - WebAnimationsPlayer.prototype._onFinish = function () { - if (!this._finished) { - this._finished = true; - this._onDoneFns.forEach(function (fn) { return fn(); }); - this._onDoneFns = []; + ServerRendererFactory2.prototype.createRenderer = function (element, type) { + if (!element || !type) { + return this.defaultRenderer; } - }; - /** - * @return {?} - */ - WebAnimationsPlayer.prototype.init = function () { - this._buildPlayer(); - this._preparePlayerBeforeStart(); - }; - /** - * @return {?} - */ - WebAnimationsPlayer.prototype._buildPlayer = function () { - var _this = this; - if (this._initialized) - return; - this._initialized = true; - var /** @type {?} */ keyframes = this.keyframes.map(function (styles) { return copyStyles(styles, false); }); - var /** @type {?} */ previousStyleProps = Object.keys(this.previousStyles); - if (previousStyleProps.length) { - var /** @type {?} */ startingKeyframe_1 = keyframes[0]; - var /** @type {?} */ missingStyleProps_1 = []; - previousStyleProps.forEach(function (prop) { - if (!startingKeyframe_1.hasOwnProperty(prop)) { - missingStyleProps_1.push(prop); + switch (type.encapsulation) { + case _angular_core.ViewEncapsulation.Native: + case _angular_core.ViewEncapsulation.Emulated: { + var /** @type {?} */ renderer = this.rendererByCompId.get(type.id); + if (!renderer) { + renderer = new EmulatedEncapsulationServerRenderer2(this.document, this.ngZone, this.sharedStylesHost, this.schema, type); + this.rendererByCompId.set(type.id, renderer); } - startingKeyframe_1[prop] = _this.previousStyles[prop]; - }); - if (missingStyleProps_1.length) { - var /** @type {?} */ self_1 = this; - var _loop_1 = function () { - var /** @type {?} */ kf = keyframes[i]; - missingStyleProps_1.forEach(function (prop) { - kf[prop] = _computeStyle(self_1.element, prop); - }); - }; - // tslint:disable-next-line - for (var /** @type {?} */ i = 1; i < keyframes.length; i++) { - _loop_1(); + ((renderer)).applyToHost(element); + return renderer; + } + case _angular_core.ViewEncapsulation.Native: + throw new Error('Native encapsulation is not supported on the server!'); + default: { + if (!this.rendererByCompId.has(type.id)) { + var /** @type {?} */ styles = _angular_platformBrowser.ɵflattenStyles(type.id, type.styles, []); + this.sharedStylesHost.addStyles(styles); + this.rendererByCompId.set(type.id, this.defaultRenderer); } + return this.defaultRenderer; } } - this._player = this._triggerWebAnimation(this.element, keyframes, this.options); - this._finalKeyframe = keyframes.length ? keyframes[keyframes.length - 1] : {}; - this._player.addEventListener('finish', function () { return _this._onFinish(); }); - }; - /** - * @return {?} - */ - WebAnimationsPlayer.prototype._preparePlayerBeforeStart = function () { - // this is required so that the player doesn't start to animate right away - if (this._delay) { - this._resetDomPlayerState(); - } - else { - this._player.pause(); - } }; /** - * \@internal - * @param {?} element - * @param {?} keyframes - * @param {?} options * @return {?} */ - WebAnimationsPlayer.prototype._triggerWebAnimation = function (element, keyframes, options) { - // jscompiler doesn't seem to know animate is a native property because it's not fully - // supported yet across common browsers (we polyfill it for Edge/Safari) [CL #143630929] - return (element['animate'](keyframes, options)); - }; - Object.defineProperty(WebAnimationsPlayer.prototype, "domPlayer", { - /** - * @return {?} - */ - get: function () { return this._player; }, - enumerable: true, - configurable: true - }); + ServerRendererFactory2.prototype.begin = function () { }; /** - * @param {?} fn * @return {?} */ - WebAnimationsPlayer.prototype.onStart = function (fn) { this._onStartFns.push(fn); }; + ServerRendererFactory2.prototype.end = function () { }; + return ServerRendererFactory2; +}()); +ServerRendererFactory2.decorators = [ + { type: _angular_core.Injectable }, +]; +/** + * @nocollapse + */ +ServerRendererFactory2.ctorParameters = function () { return [ + { type: _angular_core.NgZone, }, + { type: undefined, decorators: [{ type: _angular_core.Inject, args: [_angular_platformBrowser.DOCUMENT,] },] }, + { type: _angular_platformBrowser.ɵSharedStylesHost, }, +]; }; +var DefaultServerRenderer2 = (function () { /** - * @param {?} fn - * @return {?} + * @param {?} document + * @param {?} ngZone + * @param {?} schema */ - WebAnimationsPlayer.prototype.onDone = function (fn) { this._onDoneFns.push(fn); }; + function DefaultServerRenderer2(document, ngZone, schema) { + this.document = document; + this.ngZone = ngZone; + this.schema = schema; + this.data = Object.create(null); + } /** - * @param {?} fn * @return {?} */ - WebAnimationsPlayer.prototype.onDestroy = function (fn) { this._onDestroyFns.push(fn); }; + DefaultServerRenderer2.prototype.destroy = function () { }; /** + * @param {?} name + * @param {?=} namespace + * @param {?=} debugInfo * @return {?} */ - WebAnimationsPlayer.prototype.play = function () { - this._buildPlayer(); - if (!this.hasStarted()) { - this._onStartFns.forEach(function (fn) { return fn(); }); - this._onStartFns = []; - this._started = true; + DefaultServerRenderer2.prototype.createElement = function (name, namespace, debugInfo) { + if (namespace) { + return _angular_platformBrowser.ɵgetDOM().createElementNS(_angular_platformBrowser.ɵNAMESPACE_URIS[namespace], name); } - this._player.play(); + return _angular_platformBrowser.ɵgetDOM().createElement(name); }; /** + * @param {?} value + * @param {?=} debugInfo * @return {?} */ - WebAnimationsPlayer.prototype.pause = function () { - this.init(); - this._player.pause(); - }; + DefaultServerRenderer2.prototype.createComment = function (value, debugInfo) { return _angular_platformBrowser.ɵgetDOM().createComment(value); }; /** + * @param {?} value + * @param {?=} debugInfo * @return {?} */ - WebAnimationsPlayer.prototype.finish = function () { - this.init(); - this._onFinish(); - this._player.finish(); - }; + DefaultServerRenderer2.prototype.createText = function (value, debugInfo) { return _angular_platformBrowser.ɵgetDOM().createTextNode(value); }; /** + * @param {?} parent + * @param {?} newChild * @return {?} */ - WebAnimationsPlayer.prototype.reset = function () { - this._resetDomPlayerState(); - this._destroyed = false; - this._finished = false; - this._started = false; - }; + DefaultServerRenderer2.prototype.appendChild = function (parent, newChild) { _angular_platformBrowser.ɵgetDOM().appendChild(parent, newChild); }; /** + * @param {?} parent + * @param {?} newChild + * @param {?} refChild * @return {?} */ - WebAnimationsPlayer.prototype._resetDomPlayerState = function () { - if (this._player) { - this._player.cancel(); + DefaultServerRenderer2.prototype.insertBefore = function (parent, newChild, refChild) { + if (parent) { + _angular_platformBrowser.ɵgetDOM().insertBefore(parent, refChild, newChild); } }; /** + * @param {?} parent + * @param {?} oldChild * @return {?} */ - WebAnimationsPlayer.prototype.restart = function () { - this.reset(); - this.play(); + DefaultServerRenderer2.prototype.removeChild = function (parent, oldChild) { + if (parent) { + _angular_platformBrowser.ɵgetDOM().removeChild(parent, oldChild); + } }; /** + * @param {?} selectorOrNode + * @param {?=} debugInfo * @return {?} */ - WebAnimationsPlayer.prototype.hasStarted = function () { return this._started; }; + DefaultServerRenderer2.prototype.selectRootElement = function (selectorOrNode, debugInfo) { + var /** @type {?} */ el; + if (typeof selectorOrNode === 'string') { + el = _angular_platformBrowser.ɵgetDOM().querySelector(this.document, selectorOrNode); + if (!el) { + throw new Error("The selector \"" + selectorOrNode + "\" did not match any elements"); + } + } + else { + el = selectorOrNode; + } + _angular_platformBrowser.ɵgetDOM().clearNodes(el); + return el; + }; /** + * @param {?} node * @return {?} */ - WebAnimationsPlayer.prototype.destroy = function () { - if (!this._destroyed) { - this._resetDomPlayerState(); - this._onFinish(); - this._destroyed = true; - this._onDestroyFns.forEach(function (fn) { return fn(); }); - this._onDestroyFns = []; + DefaultServerRenderer2.prototype.parentNode = function (node) { return _angular_platformBrowser.ɵgetDOM().parentElement(node); }; + /** + * @param {?} node + * @return {?} + */ + DefaultServerRenderer2.prototype.nextSibling = function (node) { return _angular_platformBrowser.ɵgetDOM().nextSibling(node); }; + /** + * @param {?} el + * @param {?} name + * @param {?} value + * @param {?=} namespace + * @return {?} + */ + DefaultServerRenderer2.prototype.setAttribute = function (el, name, value, namespace) { + if (namespace) { + _angular_platformBrowser.ɵgetDOM().setAttributeNS(el, _angular_platformBrowser.ɵNAMESPACE_URIS[namespace], namespace + ':' + name, value); + } + else { + _angular_platformBrowser.ɵgetDOM().setAttribute(el, name, value); } }; /** - * @param {?} p + * @param {?} el + * @param {?} name + * @param {?=} namespace * @return {?} */ - WebAnimationsPlayer.prototype.setPosition = function (p) { this._player.currentTime = p * this.time; }; + DefaultServerRenderer2.prototype.removeAttribute = function (el, name, namespace) { + if (namespace) { + _angular_platformBrowser.ɵgetDOM().removeAttributeNS(el, _angular_platformBrowser.ɵNAMESPACE_URIS[namespace], name); + } + else { + _angular_platformBrowser.ɵgetDOM().removeAttribute(el, name); + } + }; /** + * @param {?} el + * @param {?} name * @return {?} */ - WebAnimationsPlayer.prototype.getPosition = function () { return this._player.currentTime / this.time; }; - Object.defineProperty(WebAnimationsPlayer.prototype, "totalTime", { - /** - * @return {?} - */ - get: function () { return this._delay + this._duration; }, - enumerable: true, - configurable: true - }); + DefaultServerRenderer2.prototype.addClass = function (el, name) { _angular_platformBrowser.ɵgetDOM().addClass(el, name); }; /** + * @param {?} el + * @param {?} name * @return {?} */ - WebAnimationsPlayer.prototype.beforeDestroy = function () { - var _this = this; - var /** @type {?} */ styles = {}; - if (this.hasStarted()) { - Object.keys(this._finalKeyframe).forEach(function (prop) { - if (prop != 'offset') { - styles[prop] = - _this._finished ? _this._finalKeyframe[prop] : _computeStyle(_this.element, prop); - } - }); + DefaultServerRenderer2.prototype.removeClass = function (el, name) { _angular_platformBrowser.ɵgetDOM().removeClass(el, name); }; + /** + * @param {?} el + * @param {?} style + * @param {?} value + * @param {?} flags + * @return {?} + */ + DefaultServerRenderer2.prototype.setStyle = function (el, style, value, flags) { + _angular_platformBrowser.ɵgetDOM().setStyle(el, style, value); + }; + /** + * @param {?} el + * @param {?} style + * @param {?} flags + * @return {?} + */ + DefaultServerRenderer2.prototype.removeStyle = function (el, style, flags) { + _angular_platformBrowser.ɵgetDOM().removeStyle(el, style); + }; + /** + * @param {?} tagName + * @param {?} propertyName + * @return {?} + */ + DefaultServerRenderer2.prototype._isSafeToReflectProperty = function (tagName, propertyName) { + return this.schema.securityContext(tagName, propertyName, true) === + this.schema.securityContext(tagName, propertyName, false); + }; + /** + * @param {?} el + * @param {?} name + * @param {?} value + * @return {?} + */ + DefaultServerRenderer2.prototype.setProperty = function (el, name, value) { + checkNoSyntheticProp(name, 'property'); + _angular_platformBrowser.ɵgetDOM().setProperty(el, name, value); + // Mirror property values for known HTML element properties in the attributes. + var /** @type {?} */ tagName = ((el.tagName)).toLowerCase(); + if (value != null && (typeof value === 'number' || typeof value == 'string') && + this.schema.hasElement(tagName, EMPTY_ARRAY) && + this.schema.hasProperty(tagName, name, EMPTY_ARRAY) && + this._isSafeToReflectProperty(tagName, name)) { + this.setAttribute(el, name, value.toString()); } - this.currentSnapshot = styles; }; - return WebAnimationsPlayer; + /** + * @param {?} node + * @param {?} value + * @return {?} + */ + DefaultServerRenderer2.prototype.setValue = function (node, value) { _angular_platformBrowser.ɵgetDOM().setText(node, value); }; + /** + * @param {?} target + * @param {?} eventName + * @param {?} callback + * @return {?} + */ + DefaultServerRenderer2.prototype.listen = function (target, eventName, callback) { + var _this = this; + // Note: We are not using the EventsPlugin here as this is not needed + // to run our tests. + checkNoSyntheticProp(eventName, 'listener'); + var /** @type {?} */ el = typeof target === 'string' ? _angular_platformBrowser.ɵgetDOM().getGlobalEventTarget(this.document, target) : target; + var /** @type {?} */ outsideHandler = function (event) { return _this.ngZone.runGuarded(function () { return callback(event); }); }; + return this.ngZone.runOutsideAngular(function () { return _angular_platformBrowser.ɵgetDOM().onAndCancel(el, eventName, outsideHandler); }); + }; + return DefaultServerRenderer2; }()); +var AT_CHARCODE = '@'.charCodeAt(0); /** - * @param {?} element - * @param {?} prop + * @param {?} name + * @param {?} nameKind * @return {?} */ -function _computeStyle(element, prop) { - return ((window.getComputedStyle(element)))[prop]; +function checkNoSyntheticProp(name, nameKind) { + if (name.charCodeAt(0) === AT_CHARCODE) { + throw new Error("Found the synthetic " + nameKind + " " + name + ". Please include either \"BrowserAnimationsModule\" or \"NoopAnimationsModule\" in your application."); + } } -/** - * @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 WebAnimationsDriver = (function () { - function WebAnimationsDriver() { +var EmulatedEncapsulationServerRenderer2 = (function (_super) { + __extends(EmulatedEncapsulationServerRenderer2, _super); + /** + * @param {?} document + * @param {?} ngZone + * @param {?} sharedStylesHost + * @param {?} schema + * @param {?} component + */ + function EmulatedEncapsulationServerRenderer2(document, ngZone, sharedStylesHost, schema, component) { + var _this = _super.call(this, document, ngZone, schema) || this; + _this.component = component; + var styles = _angular_platformBrowser.ɵflattenStyles(component.id, component.styles, []); + sharedStylesHost.addStyles(styles); + _this.contentAttr = _angular_platformBrowser.ɵshimContentAttribute(component.id); + _this.hostAttr = _angular_platformBrowser.ɵshimHostAttribute(component.id); + return _this; } /** * @param {?} element - * @param {?} selector * @return {?} */ - WebAnimationsDriver.prototype.matchesElement = function (element, selector) { - return matchesElement(element, selector); - }; + EmulatedEncapsulationServerRenderer2.prototype.applyToHost = function (element) { _super.prototype.setAttribute.call(this, element, this.hostAttr, ''); }; /** - * @param {?} elm1 - * @param {?} elm2 + * @param {?} parent + * @param {?} name * @return {?} */ - WebAnimationsDriver.prototype.containsElement = function (elm1, elm2) { return containsElement(elm1, elm2); }; + EmulatedEncapsulationServerRenderer2.prototype.createElement = function (parent, name) { + var /** @type {?} */ el = _super.prototype.createElement.call(this, parent, name); + _super.prototype.setAttribute.call(this, el, this.contentAttr, ''); + return el; + }; + return EmulatedEncapsulationServerRenderer2; +}(DefaultServerRenderer2)); +/** + * @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 ServerStylesHost = (function (_super) { + __extends(ServerStylesHost, _super); /** - * @param {?} element - * @param {?} selector - * @param {?} multi - * @return {?} + * @param {?} doc + * @param {?} transitionId */ - WebAnimationsDriver.prototype.query = function (element, selector, multi) { - return invokeQuery(element, selector, multi); - }; + function ServerStylesHost(doc, transitionId) { + var _this = _super.call(this) || this; + _this.doc = doc; + _this.transitionId = transitionId; + _this.head = null; + _this.head = _angular_platformBrowser.ɵgetDOM().getElementsByTagName(doc, 'head')[0]; + return _this; + } /** - * @param {?} element - * @param {?} prop - * @param {?=} defaultValue + * @param {?} style * @return {?} */ - WebAnimationsDriver.prototype.computeStyle = function (element, prop, defaultValue) { - return (((window.getComputedStyle(element)))[prop]); + ServerStylesHost.prototype._addStyle = function (style) { + var /** @type {?} */ adapter = (_angular_platformBrowser.ɵgetDOM()); + var /** @type {?} */ el = adapter.createElement('style'); + adapter.setText(el, style); + if (!!this.transitionId) { + adapter.setAttribute(el, 'ng-transition', this.transitionId); + } + adapter.appendChild(this.head, el); }; /** - * @param {?} element - * @param {?} keyframes - * @param {?} duration - * @param {?} delay - * @param {?} easing - * @param {?=} previousPlayers + * @param {?} additions * @return {?} */ - WebAnimationsDriver.prototype.animate = function (element, keyframes, duration, delay, easing, previousPlayers) { - if (previousPlayers === void 0) { previousPlayers = []; } - var /** @type {?} */ fill = delay == 0 ? 'both' : 'forwards'; - var /** @type {?} */ playerOptions = { duration: duration, delay: delay, fill: fill }; - // we check for this to avoid having a null|undefined value be present - // for the easing (which results in an error for certain browsers #9752) - if (easing) { - playerOptions['easing'] = easing; - } - var /** @type {?} */ previousWebAnimationPlayers = (previousPlayers.filter(function (player) { return player instanceof WebAnimationsPlayer; })); - return new WebAnimationsPlayer(element, keyframes, playerOptions, previousWebAnimationPlayers); + ServerStylesHost.prototype.onStylesAdded = function (additions) { + var _this = this; + additions.forEach(function (style) { return _this._addStyle(style); }); }; - return WebAnimationsDriver; + return ServerStylesHost; +}(_angular_platformBrowser.ɵSharedStylesHost)); +ServerStylesHost.decorators = [ + { type: _angular_core.Injectable }, +]; +/** + * @nocollapse + */ +ServerStylesHost.ctorParameters = function () { return [ + { type: undefined, decorators: [{ type: _angular_core.Inject, args: [_angular_platformBrowser.DOCUMENT,] },] }, + { type: undefined, decorators: [{ type: _angular_core.Optional }, { type: _angular_core.Inject, args: [_angular_platformBrowser.ɵTRANSITION_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 + */ +var INTERNAL_SERVER_PLATFORM_PROVIDERS = [ + { provide: _angular_platformBrowser.DOCUMENT, useFactory: _document, deps: [_angular_core.Injector] }, + { provide: _angular_core.PLATFORM_ID, useValue: _angular_common.ɵPLATFORM_SERVER_ID }, + { provide: _angular_core.PLATFORM_INITIALIZER, useFactory: initParse5Adapter, multi: true, deps: [_angular_core.Injector] }, + { provide: _angular_common.PlatformLocation, useClass: ServerPlatformLocation }, PlatformState, + // Add special provider that allows multiple instances of platformServer* to be created. + { provide: _angular_core.ɵALLOW_MULTIPLE_PLATFORMS, useValue: true } +]; +/** + * @param {?} injector + * @return {?} + */ +function initParse5Adapter(injector) { + return function () { Parse5DomAdapter.makeCurrent(); }; +} +/** + * @param {?} renderer + * @param {?} engine + * @param {?} zone + * @return {?} + */ +function instantiateServerRendererFactory(renderer, engine, zone) { + return new _angular_platformBrowser_animations.ɵAnimationRendererFactory(renderer, engine, zone); +} +var SERVER_RENDER_PROVIDERS = [ + ServerRendererFactory2, + { + provide: _angular_core.RendererFactory2, + useFactory: instantiateServerRendererFactory, + deps: [ServerRendererFactory2, _angular_animations_browser.ɵAnimationEngine, _angular_core.NgZone] + }, + ServerStylesHost, + { provide: _angular_platformBrowser.ɵSharedStylesHost, useExisting: ServerStylesHost }, +]; +/** + * The ng module for the server. + * + * \@experimental + */ +var ServerModule = (function () { + function ServerModule() { + } + return ServerModule; }()); +ServerModule.decorators = [ + { type: _angular_core.NgModule, args: [{ + exports: [_angular_platformBrowser.BrowserModule], + imports: [_angular_http.HttpModule, _angular_platformBrowser_animations.NoopAnimationsModule], + providers: [ + SERVER_RENDER_PROVIDERS, + SERVER_HTTP_PROVIDERS, + { provide: _angular_core.Testability, useValue: null }, + ], + },] }, +]; +/** + * @nocollapse + */ +ServerModule.ctorParameters = function () { return []; }; /** + * @param {?} injector * @return {?} */ -function supportsWebAnimations() { - return typeof Element !== 'undefined' && typeof ((Element)).prototype['animate'] === 'function'; +function _document(injector) { + var /** @type {?} */ config = injector.get(INITIAL_CONFIG, null); + if (config && config.document) { + return parseDocument(config.document); + } + else { + return _angular_platformBrowser.ɵgetDOM().createHtmlDocument(); + } +} +/** + * \@experimental + */ +var platformServer = _angular_core.createPlatformFactory(_angular_core.platformCore, 'server', INTERNAL_SERVER_PLATFORM_PROVIDERS); +/** + * The server platform that supports the runtime compiler. + * + * \@experimental + */ +var platformDynamicServer = _angular_core.createPlatformFactory(_angular_compiler.platformCoreDynamic, 'serverDynamic', INTERNAL_SERVER_PLATFORM_PROVIDERS); +/** + * @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 parse5$2 = __webpack_require__(37); +/** + * @param {?} platformFactory + * @param {?} options + * @return {?} + */ +function _getPlatform(platformFactory, options) { + var /** @type {?} */ extraProviders = options.extraProviders ? options.extraProviders : []; + return platformFactory([ + { provide: INITIAL_CONFIG, useValue: { document: options.document, url: options.url } }, + extraProviders + ]); +} +/** + * @template T + * @param {?} platform + * @param {?} moduleRefPromise + * @return {?} + */ +function _render(platform, moduleRefPromise) { + return moduleRefPromise.then(function (moduleRef) { + var /** @type {?} */ transitionId = moduleRef.injector.get(_angular_platformBrowser.ɵTRANSITION_ID, null); + if (!transitionId) { + throw new Error("renderModule[Factory]() requires the use of BrowserModule.withServerTransition() to ensure\nthe server-rendered app can be properly bootstrapped into a client app."); + } + var /** @type {?} */ applicationRef = moduleRef.injector.get(_angular_core.ApplicationRef); + return rxjs_operator_toPromise.toPromise + .call(rxjs_operator_first.first.call(rxjs_operator_filter.filter.call(applicationRef.isStable, function (isStable) { return isStable; }))) + .then(function () { + var /** @type {?} */ output = platform.injector.get(PlatformState).renderToString(); + platform.destroy(); + return output; + }); + }); +} +/** + * Renders a Module to string. + * + * Do not use this in a production server environment. Use pre-compiled {\@link NgModuleFactory} with + * {link renderModuleFactory} instead. + * + * \@experimental + * @template T + * @param {?} module + * @param {?} options + * @return {?} + */ +function renderModule(module, options) { + var /** @type {?} */ platform = _getPlatform(platformDynamicServer, options); + return _render(platform, platform.bootstrapModule(module)); +} +/** + * Renders a {\@link NgModuleFactory} to string. + * + * \@experimental + * @template T + * @param {?} moduleFactory + * @param {?} options + * @return {?} + */ +function renderModuleFactory(moduleFactory, options) { + var /** @type {?} */ platform = _getPlatform(platformServer, options); + return _render(platform, platform.bootstrapModuleFactory(moduleFactory)); } +/** + * @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 + */ +/** + * @module + * @description + * Entry point for all public APIs of the common package. + */ +/** + * \@stable + */ +var VERSION = new _angular_core.Version('4.2.5'); -exports.AnimationDriver = AnimationDriver; -exports.ɵAnimation = Animation; -exports.ɵAnimationStyleNormalizer = AnimationStyleNormalizer; -exports.ɵNoopAnimationStyleNormalizer = NoopAnimationStyleNormalizer; -exports.ɵWebAnimationsStyleNormalizer = WebAnimationsStyleNormalizer; -exports.ɵNoopAnimationDriver = NoopAnimationDriver; -exports.ɵAnimationEngine = AnimationEngine; -exports.ɵWebAnimationsDriver = WebAnimationsDriver; -exports.ɵsupportsWebAnimations = supportsWebAnimations; -exports.ɵWebAnimationsPlayer = WebAnimationsPlayer; +exports.PlatformState = PlatformState; +exports.ServerModule = ServerModule; +exports.platformDynamicServer = platformDynamicServer; +exports.platformServer = platformServer; +exports.INITIAL_CONFIG = INITIAL_CONFIG; +exports.renderModule = renderModule; +exports.renderModuleFactory = renderModuleFactory; +exports.VERSION = VERSION; +exports.ɵINTERNAL_SERVER_PLATFORM_PROVIDERS = INTERNAL_SERVER_PLATFORM_PROVIDERS; +exports.ɵSERVER_RENDER_PROVIDERS = SERVER_RENDER_PROVIDERS; +exports.ɵServerRendererFactory2 = ServerRendererFactory2; +exports.ɵf = SERVER_HTTP_PROVIDERS; +exports.ɵc = ServerXhr; +exports.ɵd = ServerXsrfStrategy; +exports.ɵe = httpFactory; +exports.ɵa = instantiateServerRendererFactory; +exports.ɵb = ServerStylesHost; Object.defineProperty(exports, '__esModule', { value: true }); }))); -//# sourceMappingURL=animations-browser.umd.js.map +//# sourceMappingURL=platform-server.umd.js.map /***/ }), -/* 47 */ +/* 49 */ /***/ (function(module, exports, __webpack_require__) { -(function (global, factory) { - true ? factory(exports, __webpack_require__(10), __webpack_require__(17), __webpack_require__(29), __webpack_require__(58), __webpack_require__(57), __webpack_require__(121), __webpack_require__(41), __webpack_require__(83), __webpack_require__(109), __webpack_require__(0), __webpack_require__(55), __webpack_require__(54), __webpack_require__(56)) : - typeof define === 'function' && define.amd ? define(['exports', '@angular/core', '@angular/common', '@angular/http', 'rxjs/add/operator/map', 'rxjs/add/operator/catch', 'rxjs/Rx', 'rxjs/BehaviorSubject', '@angular/router', 'jsrsasign', 'rxjs/Observable', 'rxjs/add/observable/throw', 'rxjs/add/observable/interval', 'rxjs/add/observable/timer'], factory) : - (factory((global.ng = global.ng || {}, global.ng.angularAuthOidcClient = global.ng.angularAuthOidcClient || {}),global.ng.core,global.ng.common,global.ng.http,global.Rx,global.Rx,global.Rx,global.Rx,global.ng.router,global.jsrsasign,global.Rx)); -}(this, (function (exports,_angular_core,_angular_common,_angular_http,rxjs_add_operator_map,rxjs_add_operator_catch,rxjs_Rx,rxjs_BehaviorSubject,_angular_router,jsrsasign,rxjs_Observable) { 'use strict'; +"use strict"; -var DefaultConfiguration = (function () { - function DefaultConfiguration() { - this.stsServer = 'https://localhost:44318'; - this.redirect_url = 'https://localhost:44311'; - // The Client MUST validate that the aud (audience) Claim contains its client_id value registered at the Issuer identified by the iss (issuer) Claim as an audience. - // The ID Token MUST be rejected if the ID Token does not list the Client as a valid audience, or if it contains additional audiences not trusted by the Client. - this.client_id = 'angularclient'; - this.response_type = 'id_token token'; - // For some oidc, we require resource identifier to be provided along with the request. - this.resource = ''; - this.scope = 'openid email profile'; - this.post_logout_redirect_uri = 'https://localhost:44311/unauthorized'; - this.start_checksession = false; - this.silent_renew = true; - this.startup_route = '/dataeventrecords'; - // HTTP 403 - this.forbidden_route = '/forbidden'; - // HTTP 401 - this.unauthorized_route = '/unauthorized'; - this.auto_userinfo = true; - this.log_console_warning_active = true; - this.log_console_debug_active = false; - // id_token C8: The iat Claim can be used to reject tokens that were issued too far away from the current time, - // limiting the amount of time that nonces need to be stored to prevent attacks.The acceptable range is Client specific. - this.max_id_token_iat_offset_allowed_in_seconds = 3; - this.override_well_known_configuration = false; - this.override_well_known_configuration_url = 'https://localhost:44386/wellknownconfiguration.json'; - this.storage = typeof Storage !== 'undefined' ? sessionStorage : null; - } - return DefaultConfiguration; -}()); -var OpenIDImplicitFlowConfiguration = (function () { - function OpenIDImplicitFlowConfiguration() { - } - return OpenIDImplicitFlowConfiguration; -}()); -var AuthConfiguration = (function () { - /** - * @param {?} defaultConfig - */ - function AuthConfiguration(defaultConfig) { - this.defaultConfig = defaultConfig; - } - Object.defineProperty(AuthConfiguration.prototype, "stsServer", { - /** - * @return {?} - */ - get: function () { - return this.openIDImplicitFlowConfiguration.stsServer || this.defaultConfig.stsServer; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(AuthConfiguration.prototype, "redirect_url", { - /** - * @return {?} - */ - get: function () { - return this.openIDImplicitFlowConfiguration.redirect_url || this.defaultConfig.redirect_url; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(AuthConfiguration.prototype, "client_id", { - /** - * @return {?} - */ - get: function () { - return this.openIDImplicitFlowConfiguration.client_id || this.defaultConfig.client_id; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(AuthConfiguration.prototype, "response_type", { - /** - * @return {?} - */ - get: function () { - return this.openIDImplicitFlowConfiguration.response_type || this.defaultConfig.response_type; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(AuthConfiguration.prototype, "resource", { - /** - * @return {?} - */ - get: function () { - return this.openIDImplicitFlowConfiguration.resource || this.defaultConfig.resource; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(AuthConfiguration.prototype, "scope", { - /** - * @return {?} - */ - get: function () { - return this.openIDImplicitFlowConfiguration.scope || this.defaultConfig.scope; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(AuthConfiguration.prototype, "post_logout_redirect_uri", { - /** - * @return {?} - */ - get: function () { - return this.openIDImplicitFlowConfiguration.post_logout_redirect_uri || this.defaultConfig.post_logout_redirect_uri; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(AuthConfiguration.prototype, "start_checksession", { - /** - * @return {?} - */ - get: function () { - return this.openIDImplicitFlowConfiguration.start_checksession !== undefined ? this.openIDImplicitFlowConfiguration.start_checksession : this.defaultConfig.start_checksession; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(AuthConfiguration.prototype, "silent_renew", { - /** - * @return {?} - */ - get: function () { - return this.openIDImplicitFlowConfiguration.silent_renew !== undefined ? this.openIDImplicitFlowConfiguration.silent_renew : this.defaultConfig.silent_renew; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(AuthConfiguration.prototype, "startup_route", { - /** - * @return {?} - */ - get: function () { - return this.openIDImplicitFlowConfiguration.startup_route || this.defaultConfig.startup_route; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(AuthConfiguration.prototype, "forbidden_route", { - /** - * @return {?} - */ - get: function () { - return this.openIDImplicitFlowConfiguration.forbidden_route || this.defaultConfig.forbidden_route; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(AuthConfiguration.prototype, "unauthorized_route", { - /** - * @return {?} - */ - get: function () { - return this.openIDImplicitFlowConfiguration.unauthorized_route || this.defaultConfig.unauthorized_route; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(AuthConfiguration.prototype, "auto_userinfo", { - /** - * @return {?} - */ - get: function () { - return this.openIDImplicitFlowConfiguration.auto_userinfo !== undefined ? this.openIDImplicitFlowConfiguration.auto_userinfo : this.defaultConfig.auto_userinfo; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(AuthConfiguration.prototype, "auto_clean_state_after_authentication", { - /** - * @return {?} - */ - get: function () { - return this.openIDImplicitFlowConfiguration.auto_clean_state_after_authentication !== undefined ? this.openIDImplicitFlowConfiguration.auto_clean_state_after_authentication : this.defaultConfig.auto_clean_state_after_authentication; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(AuthConfiguration.prototype, "log_console_warning_active", { - /** - * @return {?} - */ - get: function () { - return this.openIDImplicitFlowConfiguration.log_console_warning_active !== undefined ? this.openIDImplicitFlowConfiguration.log_console_warning_active : this.defaultConfig.log_console_warning_active; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(AuthConfiguration.prototype, "log_console_debug_active", { - /** - * @return {?} - */ - get: function () { - return this.openIDImplicitFlowConfiguration.log_console_debug_active !== undefined ? this.openIDImplicitFlowConfiguration.log_console_debug_active : this.defaultConfig.log_console_debug_active; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(AuthConfiguration.prototype, "max_id_token_iat_offset_allowed_in_seconds", { - /** - * @return {?} - */ - get: function () { - return this.openIDImplicitFlowConfiguration.max_id_token_iat_offset_allowed_in_seconds || this.defaultConfig.max_id_token_iat_offset_allowed_in_seconds; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(AuthConfiguration.prototype, "override_well_known_configuration", { - /** - * @return {?} - */ - get: function () { - return this.openIDImplicitFlowConfiguration.override_well_known_configuration !== undefined ? this.openIDImplicitFlowConfiguration.override_well_known_configuration : this.defaultConfig.override_well_known_configuration; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(AuthConfiguration.prototype, "override_well_known_configuration_url", { - /** - * @return {?} - */ - get: function () { - return this.openIDImplicitFlowConfiguration.override_well_known_configuration_url || this.defaultConfig.override_well_known_configuration_url; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(AuthConfiguration.prototype, "storage", { - /** - * @return {?} - */ - get: function () { - return this.openIDImplicitFlowConfiguration.storage || this.defaultConfig.storage; - }, - enumerable: true, - configurable: true - }); - /** - * @param {?} openIDImplicitFlowConfiguration - * @return {?} - */ - AuthConfiguration.prototype.init = function (openIDImplicitFlowConfiguration) { - this.openIDImplicitFlowConfiguration = openIDImplicitFlowConfiguration; - }; - return AuthConfiguration; -}()); -AuthConfiguration.decorators = [ - { type: _angular_core.Injectable }, -]; -/** - * @nocollapse - */ -AuthConfiguration.ctorParameters = function () { return [ - { type: DefaultConfiguration, }, -]; }; -/** - * Implement this class-interface to create a custom storage. - * @abstract - */ -var OidcSecurityStorage = (function () { - function OidcSecurityStorage() { - } - /** - * This method must contain the logic to read the storage. - * @abstract - * @param {?} key - * @return {?} The value of the given key - */ - OidcSecurityStorage.prototype.read = function (key) { }; - /** - * This method must contain the logic to write the storage. - * @abstract - * @param {?} key - * @param {?} value The value for the given key - * @return {?} - */ - OidcSecurityStorage.prototype.write = function (key, value) { }; - return OidcSecurityStorage; -}()); -OidcSecurityStorage.decorators = [ - { type: _angular_core.Injectable }, -]; -/** - * @nocollapse - */ -OidcSecurityStorage.ctorParameters = function () { return []; }; -var BrowserStorage = (function () { - /** - * @param {?} authConfiguration - */ - function BrowserStorage(authConfiguration) { - this.authConfiguration = authConfiguration; - this.hasStorage = typeof Storage !== 'undefined'; - } - /** - * @param {?} key - * @return {?} - */ - BrowserStorage.prototype.read = function (key) { - if (this.hasStorage) { - return JSON.parse(this.authConfiguration.storage.getItem(key)); - } - return; - }; - /** - * @param {?} key - * @param {?} value - * @return {?} - */ - BrowserStorage.prototype.write = function (key, value) { - if (this.hasStorage) { - this.authConfiguration.storage.setItem(key, JSON.stringify(value)); - } - }; - return BrowserStorage; -}()); -BrowserStorage.decorators = [ - { type: _angular_core.Injectable }, -]; -/** - * @nocollapse - */ -BrowserStorage.ctorParameters = function () { return [ - { type: AuthConfiguration, }, -]; }; -var OidcSecurityCommon = (function () { - /** - * @param {?} authConfiguration - * @param {?} oidcSecurityStorage - */ - function OidcSecurityCommon(authConfiguration, oidcSecurityStorage) { - this.authConfiguration = authConfiguration; - this.oidcSecurityStorage = oidcSecurityStorage; - this.storage_auth_result = 'authorizationResult'; - this.storage_access_token = 'authorizationData'; - this.storage_id_token = 'authorizationDataIdToken'; - this.storage_is_authorized = '_isAuthorized'; - this.storage_user_data = 'userData'; - this.storage_auth_nonce = 'authNonce'; - this.storage_auth_state_control = 'authStateControl'; - this.storage_well_known_endpoints = 'wellknownendpoints'; - this.storage_session_state = 'session_state'; - this.storage_silent_renew_running = 'storage_silent_renew_running'; - this.storage_custom_request_params = 'storage_custom_request_params'; - } - /** - * @return {?} - */ - OidcSecurityCommon.prototype.setupModule = function () { }; - /** - * @param {?} key - * @return {?} - */ - OidcSecurityCommon.prototype.retrieve = function (key) { - return this.oidcSecurityStorage.read(key); - }; - /** - * @param {?} key - * @param {?} value - * @return {?} - */ - OidcSecurityCommon.prototype.store = function (key, value) { - this.oidcSecurityStorage.write(key, value); - }; - /** - * @param {?} isRenewProcess - * @return {?} - */ - OidcSecurityCommon.prototype.resetStorageData = function (isRenewProcess) { - if (!isRenewProcess) { - this.store(this.storage_auth_result, ''); - this.store(this.storage_session_state, ''); - this.store(this.storage_silent_renew_running, ''); - this.store(this.storage_is_authorized, false); - this.store(this.storage_access_token, ''); - this.store(this.storage_id_token, ''); - this.store(this.storage_user_data, ''); - } - }; - /** - * @return {?} - */ - OidcSecurityCommon.prototype.getAccessToken = function () { - return this.retrieve(this.storage_access_token); - }; - /** - * @return {?} - */ - OidcSecurityCommon.prototype.getIdToken = function () { - return this.retrieve(this.storage_id_token); - }; - /** - * @param {?} message - * @return {?} - */ - OidcSecurityCommon.prototype.logError = function (message) { - console.error(message); - }; - /** - * @param {?} message - * @return {?} - */ - OidcSecurityCommon.prototype.logWarning = function (message) { - if (this.authConfiguration.log_console_warning_active) { - console.warn(message); - } - }; - /** - * @param {?} message - * @return {?} - */ - OidcSecurityCommon.prototype.logDebug = function (message) { - if (this.authConfiguration.log_console_debug_active) { - console.log(message); - } - }; - return OidcSecurityCommon; -}()); -OidcSecurityCommon.decorators = [ - { type: _angular_core.Injectable }, -]; -/** - * @nocollapse - */ -OidcSecurityCommon.ctorParameters = function () { return [ - { type: AuthConfiguration, }, - { type: OidcSecurityStorage, }, -]; }; -var OidcSecurityValidation = (function () { - /** - * @param {?} oidcSecurityCommon - */ - function OidcSecurityValidation(oidcSecurityCommon) { - this.oidcSecurityCommon = oidcSecurityCommon; - } - /** - * @param {?} token - * @param {?=} offsetSeconds - * @return {?} - */ - OidcSecurityValidation.prototype.isTokenExpired = function (token, offsetSeconds) { - var /** @type {?} */ decoded; - decoded = this.getPayloadFromToken(token, false); - return !(this.validate_id_token_exp_not_expired(decoded, offsetSeconds)); - }; - /** - * @param {?} decoded_id_token - * @param {?=} offsetSeconds - * @return {?} - */ - OidcSecurityValidation.prototype.validate_id_token_exp_not_expired = function (decoded_id_token, offsetSeconds) { - var /** @type {?} */ tokenExpirationDate = this.getTokenExpirationDate(decoded_id_token); - offsetSeconds = offsetSeconds || 0; - if (tokenExpirationDate == null) { - return false; - } - // Token not expired? - return (tokenExpirationDate.valueOf() > (new Date().valueOf() + (offsetSeconds * 1000))); - }; - /** - * @param {?} dataIdToken - * @return {?} - */ - OidcSecurityValidation.prototype.validate_required_id_token = function (dataIdToken) { - var /** @type {?} */ validated = true; - if (!dataIdToken.hasOwnProperty('iss')) { - validated = false; - this.oidcSecurityCommon.logWarning('iss is missing, this is required in the id_token'); - } - if (!dataIdToken.hasOwnProperty('sub')) { - validated = false; - this.oidcSecurityCommon.logWarning('sub is missing, this is required in the id_token'); - } - if (!dataIdToken.hasOwnProperty('aud')) { - validated = false; - this.oidcSecurityCommon.logWarning('aud is missing, this is required in the id_token'); - } - if (!dataIdToken.hasOwnProperty('exp')) { - validated = false; - this.oidcSecurityCommon.logWarning('exp is missing, this is required in the id_token'); - } - if (!dataIdToken.hasOwnProperty('iat')) { - validated = false; - this.oidcSecurityCommon.logWarning('iat is missing, this is required in the id_token'); - } - return validated; - }; - /** - * @param {?} dataIdToken - * @param {?} max_offset_allowed_in_seconds - * @return {?} - */ - OidcSecurityValidation.prototype.validate_id_token_iat_max_offset = function (dataIdToken, max_offset_allowed_in_seconds) { - if (!dataIdToken.hasOwnProperty('iat')) { - return false; - } - var /** @type {?} */ dateTime_iat_id_token = new Date(0); // The 0 here is the key, which sets the date to the epoch - dateTime_iat_id_token.setUTCSeconds(dataIdToken.iat); - max_offset_allowed_in_seconds = max_offset_allowed_in_seconds || 0; - if (dateTime_iat_id_token == null) { - return false; - } - this.oidcSecurityCommon.logDebug('validate_id_token_iat_max_offset: ' + (new Date().valueOf() - dateTime_iat_id_token.valueOf()) + ' < ' + (max_offset_allowed_in_seconds * 1000)); - return ((new Date().valueOf() - dateTime_iat_id_token.valueOf()) < (max_offset_allowed_in_seconds * 1000)); - }; - /** - * @param {?} dataIdToken - * @param {?} local_nonce - * @return {?} - */ - OidcSecurityValidation.prototype.validate_id_token_nonce = function (dataIdToken, local_nonce) { - if (dataIdToken.nonce !== local_nonce) { - this.oidcSecurityCommon.logDebug('Validate_id_token_nonce failed, dataIdToken.nonce: ' + dataIdToken.nonce + ' local_nonce:' + local_nonce); - return false; - } - return true; - }; - /** - * @param {?} dataIdToken - * @param {?} authWellKnownEndpoints_issuer - * @return {?} - */ - OidcSecurityValidation.prototype.validate_id_token_iss = function (dataIdToken, authWellKnownEndpoints_issuer) { - if (dataIdToken.iss != authWellKnownEndpoints_issuer) { - this.oidcSecurityCommon.logDebug('Validate_id_token_iss failed, dataIdToken.iss: ' + dataIdToken.iss + ' authWellKnownEndpoints issuer:' + authWellKnownEndpoints_issuer); - return false; - } - return true; - }; - /** - * @param {?} dataIdToken - * @param {?} aud - * @return {?} - */ - OidcSecurityValidation.prototype.validate_id_token_aud = function (dataIdToken, aud) { - if (dataIdToken.aud != aud) { - this.oidcSecurityCommon.logDebug('Validate_id_token_aud failed, dataIdToken.aud: ' + dataIdToken.aud + ' client_id:' + aud); - return false; - } - return true; - }; - /** - * @param {?} state - * @param {?} local_state - * @return {?} - */ - OidcSecurityValidation.prototype.validateStateFromHashCallback = function (state, local_state) { - if (state != local_state) { - this.oidcSecurityCommon.logDebug('ValidateStateFromHashCallback failed, state: ' + state + ' local_state:' + local_state); - return false; - } - return true; - }; - /** - * @param {?} id_token_sub - * @param {?} userdata_sub - * @return {?} - */ - OidcSecurityValidation.prototype.validate_userdata_sub_id_token = function (id_token_sub, userdata_sub) { - if (id_token_sub != userdata_sub) { - this.oidcSecurityCommon.logDebug('validate_userdata_sub_id_token failed, id_token_sub: ' + id_token_sub + ' userdata_sub:' + userdata_sub); - return false; - } - return true; - }; - /** - * @param {?} token - * @param {?} encode - * @return {?} - */ - OidcSecurityValidation.prototype.getPayloadFromToken = function (token, encode) { - var /** @type {?} */ data = {}; - if (typeof token !== 'undefined') { - var /** @type {?} */ encoded = token.split('.')[1]; - if (encode) { - return encoded; - } - data = JSON.parse(this.urlBase64Decode(encoded)); - } - return data; - }; - /** - * @param {?} token - * @param {?} encode - * @return {?} - */ - OidcSecurityValidation.prototype.getHeaderFromToken = function (token, encode) { - var /** @type {?} */ data = {}; - if (typeof token !== 'undefined') { - var /** @type {?} */ encoded = token.split('.')[0]; - if (encode) { - return encoded; - } - data = JSON.parse(this.urlBase64Decode(encoded)); - } - return data; - }; - /** - * @param {?} token - * @param {?} encode - * @return {?} - */ - OidcSecurityValidation.prototype.getSignatureFromToken = function (token, encode) { - var /** @type {?} */ data = {}; - if (typeof token !== 'undefined') { - var /** @type {?} */ encoded = token.split('.')[2]; - if (encode) { - return encoded; - } - data = JSON.parse(this.urlBase64Decode(encoded)); - } - return data; - }; - /** - * @param {?} id_token - * @param {?} jwtkeys - * @return {?} - */ - OidcSecurityValidation.prototype.validate_signature_id_token = function (id_token, jwtkeys) { - if (!jwtkeys || !jwtkeys.keys) { - return false; - } - var /** @type {?} */ header_data = this.getHeaderFromToken(id_token, false); - var /** @type {?} */ kid = header_data.kid; - var /** @type {?} */ alg = header_data.alg; - if ('RS256' != alg) { - this.oidcSecurityCommon.logWarning('Only RS256 supported'); - return false; - } - var /** @type {?} */ isValid = false; - if (!header_data.hasOwnProperty('kid')) { - // exactly 1 key in the jwtkeys and no kid in the Jose header - // kty "RSA" use "sig" - var /** @type {?} */ amountOfMatchingKeys = 0; - for (var _i = 0, _a = jwtkeys.keys; _i < _a.length; _i++) { - var key = _a[_i]; - if (key.kty == 'RSA' && key.use == 'sig') { - amountOfMatchingKeys = amountOfMatchingKeys + 1; - } - } - if (amountOfMatchingKeys == 0) { - this.oidcSecurityCommon.logWarning('no keys found, incorrect Signature, validation failed for id_token'); - return false; - } - else if (amountOfMatchingKeys > 1) { - this.oidcSecurityCommon.logWarning('no ID Token kid claim in JOSE header and multiple supplied in jwks_uri'); - return false; - } - else { - for (var _b = 0, _c = jwtkeys.keys; _b < _c.length; _b++) { - var key = _c[_b]; - if (key.kty == 'RSA' && key.use == 'sig') { - var /** @type {?} */ publickey = jsrsasign.KEYUTIL.getKey(key); - isValid = jsrsasign.KJUR.jws.JWS.verify(id_token, publickey, ['RS256']); - if (!isValid) { - this.oidcSecurityCommon.logWarning('incorrect Signature, validation failed for id_token'); - } - return isValid; - } - } - } - } - else { - // kid in the Jose header of id_token - for (var _d = 0, _e = jwtkeys.keys; _d < _e.length; _d++) { - var key = _e[_d]; - if (key.kid == kid) { - var /** @type {?} */ publickey = jsrsasign.KEYUTIL.getKey(key); - isValid = jsrsasign.KJUR.jws.JWS.verify(id_token, publickey, ['RS256']); - if (!isValid) { - this.oidcSecurityCommon.logWarning('incorrect Signature, validation failed for id_token'); - } - return isValid; - } - } - } - return isValid; - }; - /** - * @param {?} response_type - * @return {?} - */ - OidcSecurityValidation.prototype.config_validate_response_type = function (response_type) { - if (response_type === 'id_token token' || response_type === 'id_token') { - return true; - } - this.oidcSecurityCommon.logWarning('module configure incorrect, invalid response_type:' + response_type); - return false; - }; - /** - * @param {?} access_token - * @param {?} at_hash - * @return {?} - */ - OidcSecurityValidation.prototype.validate_id_token_at_hash = function (access_token, at_hash) { - this.oidcSecurityCommon.logDebug('From the server:' + at_hash); - var /** @type {?} */ testdata = this.generate_at_hash('' + access_token); - this.oidcSecurityCommon.logDebug('client validation not decoded:' + testdata); - if (testdata == at_hash) { - return true; // isValid; - } - else { - var /** @type {?} */ testValue = this.generate_at_hash('' + decodeURIComponent(access_token)); - this.oidcSecurityCommon.logDebug('-gen access--' + testValue); - if (testValue == at_hash) { - return true; // isValid - } - } - return false; - }; - /** - * @param {?} access_token - * @return {?} - */ - OidcSecurityValidation.prototype.generate_at_hash = function (access_token) { - var /** @type {?} */ hash = jsrsasign.KJUR.crypto.Util.hashString(access_token, 'sha256'); - var /** @type {?} */ first128bits = hash.substr(0, hash.length / 2); - var /** @type {?} */ testdata = jsrsasign.hextob64u(first128bits); - return testdata; - }; - /** - * @param {?} dataIdToken - * @return {?} - */ - OidcSecurityValidation.prototype.getTokenExpirationDate = function (dataIdToken) { - if (!dataIdToken.hasOwnProperty('exp')) { - return new Date(); - } - var /** @type {?} */ date = new Date(0); // The 0 here is the key, which sets the date to the epoch - date.setUTCSeconds(dataIdToken.exp); - return date; - }; - /** - * @param {?} str - * @return {?} - */ - OidcSecurityValidation.prototype.urlBase64Decode = function (str) { - var /** @type {?} */ output = str.replace('-', '+').replace('_', '/'); - switch (output.length % 4) { - case 0: - break; - case 2: - output += '=='; - break; - case 3: - output += '='; - break; - default: - throw 'Illegal base64url string!'; - } - return window.atob(output); - }; - return OidcSecurityValidation; -}()); -OidcSecurityValidation.decorators = [ - { type: _angular_core.Injectable }, -]; -/** - * @nocollapse - */ -OidcSecurityValidation.ctorParameters = function () { return [ - { type: OidcSecurityCommon, }, -]; }; -var AuthWellKnownEndpoints = (function () { - /** - * @param {?} http - * @param {?} authConfiguration - * @param {?} oidcSecurityCommon - */ - function AuthWellKnownEndpoints(http, authConfiguration, oidcSecurityCommon) { - var _this = this; - this.http = http; - this.authConfiguration = authConfiguration; - this.oidcSecurityCommon = oidcSecurityCommon; - this.onWellKnownEndpointsLoaded = new _angular_core.EventEmitter(true); - this.getWellKnownEndpoints = function () { - var /** @type {?} */ headers = new _angular_http.Headers(); - headers.append('Accept', 'application/json'); - var /** @type {?} */ url = _this.authConfiguration.stsServer + '/.well-known/openid-configuration'; - if (_this.authConfiguration.override_well_known_configuration) { - url = _this.authConfiguration.override_well_known_configuration_url; - } - return _this.http.get(url, { - headers: headers, - }).map(function (res) { return res.json(); }); - }; - } - /** - * @return {?} - */ - AuthWellKnownEndpoints.prototype.setupModule = function () { - var _this = this; - var /** @type {?} */ data = this.oidcSecurityCommon.retrieve(this.oidcSecurityCommon.storage_well_known_endpoints); - this.oidcSecurityCommon.logDebug(data); - if (data && data !== '') { - this.oidcSecurityCommon.logDebug('AuthWellKnownEndpoints already defined'); - this.issuer = data.issuer; - this.jwks_uri = data.jwks_uri; - this.authorization_endpoint = data.authorization_endpoint; - this.token_endpoint = data.token_endpoint; - this.userinfo_endpoint = data.userinfo_endpoint; - if (data.end_session_endpoint) { - this.end_session_endpoint = data.end_session_endpoint; - } - if (data.check_session_iframe) { - this.check_session_iframe = data.check_session_iframe; - } - if (data.revocation_endpoint) { - this.revocation_endpoint = data.revocation_endpoint; - } - if (data.introspection_endpoint) { - this.introspection_endpoint = data.introspection_endpoint; - } - this.onWellKnownEndpointsLoaded.emit(); - } - else { - this.oidcSecurityCommon.logDebug('AuthWellKnownEndpoints first time, get from the server'); - this.getWellKnownEndpoints() - .subscribe(function (data) { - _this.issuer = data.issuer; - _this.jwks_uri = data.jwks_uri; - _this.authorization_endpoint = data.authorization_endpoint; - _this.token_endpoint = data.token_endpoint; - _this.userinfo_endpoint = data.userinfo_endpoint; - if (data.end_session_endpoint) { - _this.end_session_endpoint = data.end_session_endpoint; - } - if (data.check_session_iframe) { - _this.check_session_iframe = data.check_session_iframe; - } - if (data.revocation_endpoint) { - _this.revocation_endpoint = data.revocation_endpoint; - } - if (data.introspection_endpoint) { - _this.introspection_endpoint = data.introspection_endpoint; - } - _this.oidcSecurityCommon.store(_this.oidcSecurityCommon.storage_well_known_endpoints, data); - _this.oidcSecurityCommon.logDebug(data); - _this.onWellKnownEndpointsLoaded.emit(); - }); - } - }; - return AuthWellKnownEndpoints; -}()); -AuthWellKnownEndpoints.decorators = [ - { type: _angular_core.Injectable }, -]; -/** - * @nocollapse - */ -AuthWellKnownEndpoints.ctorParameters = function () { return [ - { type: _angular_http.Http, }, - { type: AuthConfiguration, }, - { type: OidcSecurityCommon, }, -]; }; -AuthWellKnownEndpoints.propDecorators = { - 'onWellKnownEndpointsLoaded': [{ type: _angular_core.Output },], -}; -var OidcSecurityCheckSession = (function () { - /** - * @param {?} authConfiguration - * @param {?} oidcSecurityCommon - * @param {?} authWellKnownEndpoints - */ - function OidcSecurityCheckSession(authConfiguration, oidcSecurityCommon, authWellKnownEndpoints) { - this.authConfiguration = authConfiguration; - this.oidcSecurityCommon = oidcSecurityCommon; - this.authWellKnownEndpoints = authWellKnownEndpoints; - this.onCheckSessionChanged = new _angular_core.EventEmitter(true); - } - /** - * @return {?} - */ - OidcSecurityCheckSession.prototype.init = function () { - var _this = this; - var /** @type {?} */ exists = window.parent.document.getElementById('myiFrameForCheckSession'); - if (!exists) { - this.sessionIframe = window.document.createElement('iframe'); - this.sessionIframe.id = 'myiFrameForCheckSession'; - this.oidcSecurityCommon.logDebug(this.sessionIframe); - this.sessionIframe.style.display = 'none'; - this.sessionIframe.src = this.authWellKnownEndpoints.check_session_iframe; - window.document.body.appendChild(this.sessionIframe); - this.iframeMessageEvent = this.messageHandler.bind(this); - window.addEventListener('message', this.iframeMessageEvent, false); - return rxjs_Observable.Observable.create(function (observer) { - _this.sessionIframe.onload = function () { - observer.next(_this); - observer.complete(); - }; - }); - } - return rxjs_Observable.Observable.empty(); - }; - /** - * @param {?} clientId - * @return {?} - */ - OidcSecurityCheckSession.prototype.pollServerSession = function (clientId) { - var _this = this; - var /** @type {?} */ source = rxjs_Observable.Observable.timer(3000, 3000) - .timeInterval() - .pluck('interval') - .take(10000); - var /** @type {?} */ subscription = source.subscribe(function () { - _this.oidcSecurityCommon.logDebug(_this.sessionIframe); - var /** @type {?} */ session_state = _this.oidcSecurityCommon.retrieve(_this.oidcSecurityCommon.storage_session_state); - if (session_state && session_state !== '') { - _this.sessionIframe.contentWindow.postMessage(clientId + ' ' + session_state, _this.authConfiguration.stsServer); - } - }, function (err) { - _this.oidcSecurityCommon.logError('pollServerSession error: ' + err); - }, function () { - _this.oidcSecurityCommon.logDebug('checksession pollServerSession completed'); - }); - }; - /** - * @param {?} e - * @return {?} - */ - OidcSecurityCheckSession.prototype.messageHandler = function (e) { - if (e.origin === this.authConfiguration.stsServer && - e.source === this.sessionIframe.contentWindow) { - if (e.data === 'error') { - this.oidcSecurityCommon.logWarning('error from checksession messageHandler'); - } - else if (e.data === 'changed') { - this.onCheckSessionChanged.emit(); - } - else { - this.oidcSecurityCommon.logDebug(e.data + ' from checksession messageHandler'); - } - } - }; - return OidcSecurityCheckSession; -}()); -OidcSecurityCheckSession.decorators = [ - { type: _angular_core.Injectable }, -]; -/** - * @nocollapse - */ -OidcSecurityCheckSession.ctorParameters = function () { return [ - { type: AuthConfiguration, }, - { type: OidcSecurityCommon, }, - { type: AuthWellKnownEndpoints, }, -]; }; -OidcSecurityCheckSession.propDecorators = { - 'onCheckSessionChanged': [{ type: _angular_core.Output },], -}; -var OidcSecuritySilentRenew = (function () { - /** - * @param {?} oidcSecurityCommon - */ - function OidcSecuritySilentRenew(oidcSecurityCommon) { - this.oidcSecurityCommon = oidcSecurityCommon; - } - /** - * @return {?} - */ - OidcSecuritySilentRenew.prototype.initRenew = function () { - var /** @type {?} */ existsparent = undefined; - try { - var /** @type {?} */ parentdoc = window.parent.document; - if (!parentdoc) { - throw new Error('Unaccessible'); - } - existsparent = parentdoc.getElementById('myiFrameForSilentRenew'); - } - catch (e) { - // not accessible - } - var /** @type {?} */ exists = window.document.getElementById('myiFrameForSilentRenew'); - if (existsparent) { - this.sessionIframe = existsparent; - } - else if (exists) { - this.sessionIframe = exists; - } - if (!exists && !existsparent) { - this.sessionIframe = window.document.createElement('iframe'); - this.sessionIframe.id = 'myiFrameForSilentRenew'; - this.oidcSecurityCommon.logDebug(this.sessionIframe); - this.sessionIframe.style.display = 'none'; - window.document.body.appendChild(this.sessionIframe); - } - }; - /** - * @param {?} url - * @return {?} - */ - OidcSecuritySilentRenew.prototype.startRenew = function (url) { - var _this = this; - var /** @type {?} */ existsparent = undefined; - try { - var /** @type {?} */ parentdoc = window.parent.document; - if (!parentdoc) { - throw new Error('Unaccessible'); - } - existsparent = parentdoc.getElementById('myiFrameForSilentRenew'); - } - catch (e) { - // not accessible - } - var /** @type {?} */ exists = window.document.getElementById('myiFrameForSilentRenew'); - if (existsparent) { - this.sessionIframe = existsparent; - } - else if (exists) { - this.sessionIframe = exists; - } - this.oidcSecurityCommon.logDebug('startRenew for URL:' + url); - this.sessionIframe.src = url; - return rxjs_Observable.Observable.create(function (observer) { - _this.sessionIframe.onload = function () { - observer.next(_this); - observer.complete(); - }; - }); - }; - return OidcSecuritySilentRenew; -}()); -OidcSecuritySilentRenew.decorators = [ - { type: _angular_core.Injectable }, -]; -/** - * @nocollapse - */ -OidcSecuritySilentRenew.ctorParameters = function () { return [ - { type: OidcSecurityCommon, }, -]; }; -var OidcSecurityUserService = (function () { - /** - * @param {?} http - * @param {?} authConfiguration - * @param {?} oidcSecurityCommon - * @param {?} authWellKnownEndpoints - */ - function OidcSecurityUserService(http, authConfiguration, oidcSecurityCommon, authWellKnownEndpoints) { - var _this = this; - this.http = http; - this.authConfiguration = authConfiguration; - this.oidcSecurityCommon = oidcSecurityCommon; - this.authWellKnownEndpoints = authWellKnownEndpoints; - this.userData = ''; - this.getIdentityUserData = function () { - var /** @type {?} */ headers = new _angular_http.Headers(); - headers.append('Accept', 'application/json'); - var /** @type {?} */ token = _this.oidcSecurityCommon.getAccessToken(); - if (token !== '') { - headers.append('Authorization', 'Bearer ' + decodeURIComponent(token)); - } - return _this.http.get(_this.authWellKnownEndpoints.userinfo_endpoint, { - headers: headers, - body: '' - }).map(function (res) { return res.json(); }); - }; - } - /** - * @return {?} - */ - OidcSecurityUserService.prototype.initUserData = function () { - var _this = this; - return this.getIdentityUserData() - .map(function (data) { return _this.userData = data; }); - }; - /** - * @param {?} error - * @return {?} - */ - OidcSecurityUserService.prototype.handleError = function (error) { - this.oidcSecurityCommon.logError(error); - }; - return OidcSecurityUserService; -}()); -OidcSecurityUserService.decorators = [ - { type: _angular_core.Injectable }, -]; -/** - * @nocollapse - */ -OidcSecurityUserService.ctorParameters = function () { return [ - { type: _angular_http.Http, }, - { type: AuthConfiguration, }, - { type: OidcSecurityCommon, }, - { type: AuthWellKnownEndpoints, }, -]; }; -var OidcSecurityService = (function () { - /** - * @param {?} platformId - * @param {?} http - * @param {?} authConfiguration - * @param {?} router - * @param {?} oidcSecurityCheckSession - * @param {?} oidcSecuritySilentRenew - * @param {?} oidcSecurityUserService - * @param {?} oidcSecurityCommon - * @param {?} authWellKnownEndpoints - */ - function OidcSecurityService(platformId, http, authConfiguration, router, oidcSecurityCheckSession, oidcSecuritySilentRenew, oidcSecurityUserService, oidcSecurityCommon, authWellKnownEndpoints) { - this.platformId = platformId; - this.http = http; - this.authConfiguration = authConfiguration; - this.router = router; - this.oidcSecurityCheckSession = oidcSecurityCheckSession; - this.oidcSecuritySilentRenew = oidcSecuritySilentRenew; - this.oidcSecurityUserService = oidcSecurityUserService; - this.oidcSecurityCommon = oidcSecurityCommon; - this.authWellKnownEndpoints = authWellKnownEndpoints; - this.onModuleSetup = new _angular_core.EventEmitter(true); - this.moduleSetup = false; - this._isAuthorized = new rxjs_BehaviorSubject.BehaviorSubject(false); - this._userData = new rxjs_BehaviorSubject.BehaviorSubject(''); - this.authWellKnownEndpointsLoaded = false; - } - /** - * @param {?} openIDImplicitFlowConfiguration - * @return {?} - */ - OidcSecurityService.prototype.setupModule = function (openIDImplicitFlowConfiguration) { - var _this = this; - this.authConfiguration.init(openIDImplicitFlowConfiguration); - this.oidcSecurityValidation = new OidcSecurityValidation(this.oidcSecurityCommon); - this.oidcSecurityCheckSession.onCheckSessionChanged.subscribe(function () { _this.onCheckSessionChanged(); }); - this.authWellKnownEndpoints.onWellKnownEndpointsLoaded.subscribe(function () { _this.onWellKnownEndpointsLoaded(); }); - this.oidcSecurityCommon.setupModule(); - if (this.oidcSecurityCommon.retrieve(this.oidcSecurityCommon.storage_user_data) !== '') { - this.setUserData(this.oidcSecurityCommon.retrieve(this.oidcSecurityCommon.storage_user_data)); - } - if (this.oidcSecurityCommon.retrieve(this.oidcSecurityCommon.storage_is_authorized) !== '') { - this.setIsAuthorized(this.oidcSecurityCommon.retrieve(this.oidcSecurityCommon.storage_is_authorized)); - } - this.oidcSecurityCommon.logDebug('STS server: ' + this.authConfiguration.stsServer); - if (_angular_common.isPlatformBrowser(this.platformId)) { - // Client only code. - this.authWellKnownEndpoints.setupModule(); - if (this.authConfiguration.silent_renew) { - this.oidcSecuritySilentRenew.initRenew(); - } - if (this.authConfiguration.start_checksession) { - this.oidcSecurityCheckSession.init().subscribe(function () { - _this.oidcSecurityCheckSession.pollServerSession(_this.authConfiguration.client_id); - }); - } - } - this.moduleSetup = true; - this.onModuleSetup.emit(); - }; - /** - * @return {?} - */ - OidcSecurityService.prototype.getUserData = function () { - return this._userData.asObservable(); - }; - /** - * @param {?} userData - * @return {?} - */ - OidcSecurityService.prototype.setUserData = function (userData) { - this.oidcSecurityCommon.store(this.oidcSecurityCommon.storage_user_data, userData); - this._userData.next(userData); - }; - /** - * @return {?} - */ - OidcSecurityService.prototype.getIsAuthorized = function () { - return this._isAuthorized.asObservable(); - }; - /** - * @param {?} isAuthorized - * @return {?} - */ - OidcSecurityService.prototype.setIsAuthorized = function (isAuthorized) { - this._isAuthorizedValue = isAuthorized; - this._isAuthorized.next(isAuthorized); - }; - /** - * @return {?} - */ - OidcSecurityService.prototype.getToken = function () { - if (!this._isAuthorizedValue) { - return ''; - } - var /** @type {?} */ token = this.oidcSecurityCommon.getAccessToken(); - return decodeURIComponent(token); - }; - /** - * @return {?} - */ - OidcSecurityService.prototype.getIdToken = function () { - if (!this._isAuthorizedValue) { - return ''; - } - var /** @type {?} */ token = this.oidcSecurityCommon.getIdToken(); - return decodeURIComponent(token); - }; - /** - * @param {?=} encode - * @return {?} - */ - OidcSecurityService.prototype.getPayloadFromIdToken = function (encode) { - if (encode === void 0) { encode = false; } - var /** @type {?} */ token = this.getIdToken(); - return this.oidcSecurityValidation.getPayloadFromToken(token, encode); - }; - /** - * @param {?} state - * @return {?} - */ - OidcSecurityService.prototype.setState = function (state) { - this.oidcSecurityCommon.store(this.oidcSecurityCommon.storage_auth_state_control, state); - }; - /** - * @return {?} - */ - OidcSecurityService.prototype.getState = function () { - return this.oidcSecurityCommon.retrieve(this.oidcSecurityCommon.storage_auth_state_control); - }; - /** - * @param {?} params - * @return {?} - */ - OidcSecurityService.prototype.setCustomRequestParameters = function (params) { - this.oidcSecurityCommon.store(this.oidcSecurityCommon.storage_custom_request_params, params); - }; - /** - * @return {?} - */ - OidcSecurityService.prototype.authorize = function () { - var /** @type {?} */ data = this.oidcSecurityCommon.retrieve(this.oidcSecurityCommon.storage_well_known_endpoints); - if (data && data !== '') { - this.authWellKnownEndpointsLoaded = true; - } - if (!this.authWellKnownEndpointsLoaded) { - this.oidcSecurityCommon.logError('Well known endpoints must be loaded before user can login!'); - return; - } - if (!this.oidcSecurityValidation.config_validate_response_type(this.authConfiguration.response_type)) { - // invalid response_type - return; - } - this.resetAuthorizationData(false); - this.oidcSecurityCommon.logDebug('BEGIN Authorize, no auth data'); - var /** @type {?} */ state = this.oidcSecurityCommon.retrieve(this.oidcSecurityCommon.storage_auth_state_control); - if (state === '') { - state = Date.now() + '' + Math.random(); - this.oidcSecurityCommon.store(this.oidcSecurityCommon.storage_auth_state_control, state); - } - var /** @type {?} */ nonce = 'N' + Math.random() + '' + Date.now(); - this.oidcSecurityCommon.store(this.oidcSecurityCommon.storage_auth_nonce, nonce); - this.oidcSecurityCommon.logDebug('AuthorizedController created. local state: ' + this.oidcSecurityCommon.retrieve(this.oidcSecurityCommon.storage_auth_state_control)); - var /** @type {?} */ url = this.createAuthorizeUrl(nonce, state, this.authWellKnownEndpoints.authorization_endpoint); - window.location.href = url; - }; - /** - * @param {?=} hash - * @return {?} - */ - OidcSecurityService.prototype.authorizedCallback = function (hash) { - var _this = this; - var /** @type {?} */ silentRenew = this.oidcSecurityCommon.retrieve(this.oidcSecurityCommon.storage_silent_renew_running); - var /** @type {?} */ isRenewProcess = (silentRenew === 'running'); - this.oidcSecurityCommon.logDebug('BEGIN authorizedCallback, no auth data'); - this.resetAuthorizationData(isRenewProcess); - hash = hash || window.location.hash.substr(1); - var /** @type {?} */ result = hash.split('&').reduce(function (result, item) { - var /** @type {?} */ parts = item.split('='); - result[parts[0]] = parts[1]; - return result; - }, {}); - this.oidcSecurityCommon.store(this.oidcSecurityCommon.storage_auth_result, result); - this.oidcSecurityCommon.logDebug(result); - this.oidcSecurityCommon.logDebug('authorizedCallback created, begin token validation'); - var /** @type {?} */ access_token = ''; - var /** @type {?} */ id_token = ''; - var /** @type {?} */ authResponseIsValid = false; - var /** @type {?} */ decoded_id_token; - this.getSigningKeys() - .subscribe(function (jwtKeys) { - _this.jwtKeys = jwtKeys; - if (!result.error) { - // validate state - if (_this.oidcSecurityValidation.validateStateFromHashCallback(result.state, _this.oidcSecurityCommon.retrieve(_this.oidcSecurityCommon.storage_auth_state_control))) { - if (_this.authConfiguration.response_type === 'id_token token') { - access_token = result.access_token; - } - id_token = result.id_token; - var /** @type {?} */ headerDecoded = void 0; - decoded_id_token = _this.oidcSecurityValidation.getPayloadFromToken(id_token, false); - headerDecoded = _this.oidcSecurityValidation.getHeaderFromToken(id_token, false); - // validate jwt signature - if (_this.oidcSecurityValidation.validate_signature_id_token(id_token, _this.jwtKeys)) { - // validate nonce - if (_this.oidcSecurityValidation.validate_id_token_nonce(decoded_id_token, _this.oidcSecurityCommon.retrieve(_this.oidcSecurityCommon.storage_auth_nonce))) { - // validate required fields id_token - if (_this.oidcSecurityValidation.validate_required_id_token(decoded_id_token)) { - // validate max offset from the id_token issue to now - if (_this.oidcSecurityValidation.validate_id_token_iat_max_offset(decoded_id_token, _this.authConfiguration.max_id_token_iat_offset_allowed_in_seconds)) { - // validate iss - if (_this.oidcSecurityValidation.validate_id_token_iss(decoded_id_token, _this.authWellKnownEndpoints.issuer)) { - // validate aud - if (_this.oidcSecurityValidation.validate_id_token_aud(decoded_id_token, _this.authConfiguration.client_id)) { - // validate_id_token_exp_not_expired - if (_this.oidcSecurityValidation.validate_id_token_exp_not_expired(decoded_id_token)) { - // flow id_token token - if (_this.authConfiguration.response_type === 'id_token token') { - // valiadate at_hash and access_token - if (_this.oidcSecurityValidation.validate_id_token_at_hash(access_token, decoded_id_token.at_hash) || !access_token) { - authResponseIsValid = true; - _this.successful_validation(); - } - else { - _this.oidcSecurityCommon.logWarning('authorizedCallback incorrect at_hash'); - } - } - else { - authResponseIsValid = true; - _this.successful_validation(); - } - } - else { - _this.oidcSecurityCommon.logWarning('authorizedCallback token expired'); - } - } - else { - _this.oidcSecurityCommon.logWarning('authorizedCallback incorrect aud'); - } - } - else { - _this.oidcSecurityCommon.logWarning('authorizedCallback incorrect iss does not match authWellKnownEndpoints issuer'); - } - } - else { - _this.oidcSecurityCommon.logWarning('authorizedCallback Validation, iat rejected id_token was issued too far away from the current time'); - } - } - else { - _this.oidcSecurityCommon.logDebug('authorizedCallback Validation, one of the REQUIRED properties missing from id_token'); - } - } - else { - _this.oidcSecurityCommon.logWarning('authorizedCallback incorrect nonce'); - } - } - else { - _this.oidcSecurityCommon.logDebug('authorizedCallback Signature validation failed id_token'); - } - } - else { - _this.oidcSecurityCommon.logWarning('authorizedCallback incorrect state'); - } - } - _this.oidcSecurityCommon.store(_this.oidcSecurityCommon.storage_silent_renew_running, ''); - if (authResponseIsValid) { - _this.setAuthorizationData(access_token, id_token); - if (_this.authConfiguration.auto_userinfo) { - _this.getUserinfo(isRenewProcess, result, id_token, decoded_id_token).subscribe(function (response) { - if (response) { - _this.router.navigate([_this.authConfiguration.startup_route]); - } - else { - _this.router.navigate([_this.authConfiguration.unauthorized_route]); - } - }); - } - else { - _this.router.navigate([_this.authConfiguration.startup_route]); - } - } - else { - _this.oidcSecurityCommon.logDebug('authorizedCallback, token(s) validation failed, resetting'); - _this.resetAuthorizationData(false); - _this.router.navigate([_this.authConfiguration.unauthorized_route]); - } - }); - }; - /** - * @param {?=} isRenewProcess - * @param {?=} result - * @param {?=} id_token - * @param {?=} decoded_id_token - * @return {?} - */ - OidcSecurityService.prototype.getUserinfo = function (isRenewProcess, result, id_token, decoded_id_token) { - var _this = this; - if (isRenewProcess === void 0) { isRenewProcess = false; } - result = result ? result : this.oidcSecurityCommon.retrieve(this.oidcSecurityCommon.storage_auth_result); - id_token = id_token ? id_token : this.oidcSecurityCommon.retrieve(this.oidcSecurityCommon.storage_id_token); - decoded_id_token = decoded_id_token ? decoded_id_token : this.oidcSecurityValidation.getPayloadFromToken(id_token, false); - return new rxjs_Rx.Observable(function (observer) { - // flow id_token token - if (_this.authConfiguration.response_type === 'id_token token') { - if (isRenewProcess) { - _this.oidcSecurityCommon.store(_this.oidcSecurityCommon.storage_session_state, result.session_state); - observer.next(true); - observer.complete(); - } - else { - _this.oidcSecurityUserService.initUserData() - .subscribe(function () { - _this.oidcSecurityCommon.logDebug('authorizedCallback id_token token flow'); - if (_this.oidcSecurityValidation.validate_userdata_sub_id_token(decoded_id_token.sub, _this.oidcSecurityUserService.userData.sub)) { - _this.setUserData(_this.oidcSecurityUserService.userData); - _this.oidcSecurityCommon.logDebug(_this.oidcSecurityCommon.retrieve(_this.oidcSecurityCommon.storage_access_token)); - _this.oidcSecurityCommon.logDebug(_this.oidcSecurityUserService.userData); - _this.oidcSecurityCommon.store(_this.oidcSecurityCommon.storage_session_state, result.session_state); - _this.runTokenValidatation(); - observer.next(true); - } - else { - _this.oidcSecurityCommon.logWarning('authorizedCallback, User data sub does not match sub in id_token'); - _this.oidcSecurityCommon.logDebug('authorizedCallback, token(s) validation failed, resetting'); - _this.resetAuthorizationData(false); - observer.next(false); - } - observer.complete(); - }); - } - } - else { - _this.oidcSecurityCommon.logDebug('authorizedCallback id_token flow'); - _this.oidcSecurityCommon.logDebug(_this.oidcSecurityCommon.retrieve(_this.oidcSecurityCommon.storage_access_token)); - // userData is set to the id_token decoded. No access_token. - _this.oidcSecurityUserService.userData = decoded_id_token; - _this.setUserData(_this.oidcSecurityUserService.userData); - _this.oidcSecurityCommon.store(_this.oidcSecurityCommon.storage_session_state, result.session_state); - if (!isRenewProcess) { - _this.runTokenValidatation(); - } - observer.next(true); - observer.complete(); - } - }); - }; - /** - * @return {?} - */ - OidcSecurityService.prototype.logoff = function () { - // /connect/endsession?id_token_hint=...&post_logout_redirect_uri=https://myapp.com - this.oidcSecurityCommon.logDebug('BEGIN Authorize, no auth data'); - if (this.authWellKnownEndpoints.end_session_endpoint) { - var /** @type {?} */ end_session_endpoint = this.authWellKnownEndpoints.end_session_endpoint; - var /** @type {?} */ id_token_hint = this.oidcSecurityCommon.retrieve(this.oidcSecurityCommon.storage_id_token); - var /** @type {?} */ url = this.createEndSessionUrl(end_session_endpoint, id_token_hint); - this.resetAuthorizationData(false); - if (this.authConfiguration.start_checksession && this.checkSessionChanged) { - this.oidcSecurityCommon.logDebug('only local login cleaned up, server session has changed'); - } - else { - window.location.href = url; - } - } - else { - this.resetAuthorizationData(false); - this.oidcSecurityCommon.logDebug('only local login cleaned up, no end_session_endpoint'); - } - }; - /** - * @return {?} - */ - OidcSecurityService.prototype.successful_validation = function () { - this.oidcSecurityCommon.store(this.oidcSecurityCommon.storage_auth_nonce, ''); - if (this.authConfiguration.auto_clean_state_after_authentication) { - this.oidcSecurityCommon.store(this.oidcSecurityCommon.storage_auth_state_control, ''); - } - this.oidcSecurityCommon.logDebug('AuthorizedCallback token(s) validated, continue'); - }; - /** - * @return {?} - */ - OidcSecurityService.prototype.refreshSession = function () { - this.oidcSecurityCommon.logDebug('BEGIN refresh session Authorize'); - var /** @type {?} */ state = this.oidcSecurityCommon.retrieve(this.oidcSecurityCommon.storage_auth_state_control); - if (state === '') { - state = Date.now() + '' + Math.random(); - this.oidcSecurityCommon.store(this.oidcSecurityCommon.storage_auth_state_control, state); - } - var /** @type {?} */ nonce = 'N' + Math.random() + '' + Date.now(); - this.oidcSecurityCommon.store(this.oidcSecurityCommon.storage_auth_nonce, nonce); - this.oidcSecurityCommon.logDebug('RefreshSession created. adding myautostate: ' + this.oidcSecurityCommon.retrieve(this.oidcSecurityCommon.storage_auth_state_control)); - var /** @type {?} */ url = this.createAuthorizeUrl(nonce, state, this.authWellKnownEndpoints.authorization_endpoint); - this.oidcSecurityCommon.store(this.oidcSecurityCommon.storage_silent_renew_running, 'running'); - this.oidcSecuritySilentRenew.startRenew(url); - }; - /** - * @param {?} access_token - * @param {?} id_token - * @return {?} - */ - OidcSecurityService.prototype.setAuthorizationData = function (access_token, id_token) { - if (this.oidcSecurityCommon.retrieve(this.oidcSecurityCommon.storage_access_token) !== '') { - this.oidcSecurityCommon.store(this.oidcSecurityCommon.storage_access_token, ''); - } - this.oidcSecurityCommon.logDebug(access_token); - this.oidcSecurityCommon.logDebug(id_token); - this.oidcSecurityCommon.logDebug('storing to storage, getting the roles'); - this.oidcSecurityCommon.store(this.oidcSecurityCommon.storage_access_token, access_token); - this.oidcSecurityCommon.store(this.oidcSecurityCommon.storage_id_token, id_token); - this.setIsAuthorized(true); - this.oidcSecurityCommon.store(this.oidcSecurityCommon.storage_is_authorized, true); - }; - /** - * @param {?} nonce - * @param {?} state - * @param {?} authorization_endpoint - * @return {?} - */ - OidcSecurityService.prototype.createAuthorizeUrl = function (nonce, state, authorization_endpoint) { - var /** @type {?} */ urlParts = authorization_endpoint.split('?'); - var /** @type {?} */ authorizationUrl = urlParts[0]; - var /** @type {?} */ params = new _angular_http.URLSearchParams(urlParts[1]); - params.set('client_id', this.authConfiguration.client_id); - params.set('redirect_uri', this.authConfiguration.redirect_url); - params.set('response_type', this.authConfiguration.response_type); - params.set('scope', this.authConfiguration.scope); - params.set('nonce', nonce); - params.set('state', state); - var /** @type {?} */ customParams = Object.assign({}, this.oidcSecurityCommon.retrieve(this.oidcSecurityCommon.storage_custom_request_params)); - Object.keys(customParams).forEach(function (key) { - params.set(key, customParams[key]); - }); - return authorizationUrl + "?" + params; - }; - /** - * @param {?} end_session_endpoint - * @param {?} id_token_hint - * @return {?} - */ - OidcSecurityService.prototype.createEndSessionUrl = function (end_session_endpoint, id_token_hint) { - var /** @type {?} */ urlParts = end_session_endpoint.split('?'); - var /** @type {?} */ authorizationEndsessionUrl = urlParts[0]; - var /** @type {?} */ params = new _angular_http.URLSearchParams(urlParts[1]); - params.set('id_token_hint', id_token_hint); - params.set('post_logout_redirect_uri', this.authConfiguration.post_logout_redirect_uri); - return authorizationEndsessionUrl + "?" + params; - }; - /** - * @param {?} isRenewProcess - * @return {?} - */ - OidcSecurityService.prototype.resetAuthorizationData = function (isRenewProcess) { - if (!isRenewProcess) { - this.setIsAuthorized(false); - this.oidcSecurityCommon.resetStorageData(isRenewProcess); - this.checkSessionChanged = false; - } - }; - /** - * @param {?} error - * @return {?} - */ - OidcSecurityService.prototype.handleError = function (error) { - this.oidcSecurityCommon.logError(error); - if (error.status == 403) { - this.router.navigate([this.authConfiguration.forbidden_route]); - } - else if (error.status == 401) { - var /** @type {?} */ silentRenew = this.oidcSecurityCommon.retrieve(this.oidcSecurityCommon.storage_silent_renew_running); - this.resetAuthorizationData(silentRenew); - this.router.navigate([this.authConfiguration.unauthorized_route]); - } - }; - /** - * @return {?} - */ - OidcSecurityService.prototype.onCheckSessionChanged = function () { - this.oidcSecurityCommon.logDebug('onCheckSessionChanged'); - this.checkSessionChanged = true; - }; - /** - * @return {?} - */ - OidcSecurityService.prototype.onWellKnownEndpointsLoaded = function () { - this.oidcSecurityCommon.logDebug('onWellKnownEndpointsLoaded'); - this.authWellKnownEndpointsLoaded = true; - }; - /** - * @return {?} - */ - OidcSecurityService.prototype.runGetSigningKeys = function () { - var _this = this; - this.getSigningKeys() - .subscribe(function (jwtKeys) { return _this.jwtKeys = jwtKeys; }, function (error) { return _this.errorMessage = (error); }); - }; - /** - * @return {?} - */ - OidcSecurityService.prototype.getSigningKeys = function () { - this.oidcSecurityCommon.logDebug('jwks_uri: ' + this.authWellKnownEndpoints.jwks_uri); - return this.http.get(this.authWellKnownEndpoints.jwks_uri) - .map(this.extractData) - .catch(this.handleErrorGetSigningKeys); - }; - /** - * @param {?} res - * @return {?} - */ - OidcSecurityService.prototype.extractData = function (res) { - var /** @type {?} */ body = res.json(); - return body; - }; - /** - * @param {?} error - * @return {?} - */ - OidcSecurityService.prototype.handleErrorGetSigningKeys = function (error) { - var /** @type {?} */ errMsg; - if (error instanceof _angular_http.Response) { - var /** @type {?} */ body = error.json() || {}; - var /** @type {?} */ err = body.error || JSON.stringify(body); - errMsg = error.status + " - " + (error.statusText || '') + " " + err; - } - else { - errMsg = error.message ? error.message : error.toString(); - } - console.error(errMsg); - return rxjs_Rx.Observable.throw(errMsg); - }; - /** - * @return {?} - */ - OidcSecurityService.prototype.runTokenValidatation = function () { - var _this = this; - var /** @type {?} */ source = rxjs_Rx.Observable.timer(3000, 3000) - .timeInterval() - .pluck('interval') - .take(10000); - var /** @type {?} */ subscription = source.subscribe(function () { - if (_this._isAuthorizedValue) { - if (_this.oidcSecurityValidation.isTokenExpired(_this.oidcSecurityCommon.retrieve(_this.oidcSecurityCommon.storage_id_token))) { - _this.oidcSecurityCommon.logDebug('IsAuthorized: id_token isTokenExpired, start silent renew if active'); - if (_this.authConfiguration.silent_renew) { - _this.refreshSession(); - } - else { - _this.resetAuthorizationData(false); - } - } - } - }, function (err) { - _this.oidcSecurityCommon.logError('Error: ' + err); - }, function () { - _this.oidcSecurityCommon.logDebug('Completed'); - }); - }; - return OidcSecurityService; -}()); -OidcSecurityService.decorators = [ - { type: _angular_core.Injectable }, -]; -/** - * @nocollapse - */ -OidcSecurityService.ctorParameters = function () { return [ - { type: Object, decorators: [{ type: _angular_core.Inject, args: [_angular_core.PLATFORM_ID,] },] }, - { type: _angular_http.Http, }, - { type: AuthConfiguration, }, - { type: _angular_router.Router, }, - { type: OidcSecurityCheckSession, }, - { type: OidcSecuritySilentRenew, }, - { type: OidcSecurityUserService, }, - { type: OidcSecurityCommon, }, - { type: AuthWellKnownEndpoints, }, -]; }; -OidcSecurityService.propDecorators = { - 'onModuleSetup': [{ type: _angular_core.Output },], -}; -var AuthModule = (function () { - function AuthModule() { - } - /** - * @param {?=} token - * @return {?} - */ - AuthModule.forRoot = function (token) { - if (token === void 0) { token = {}; } - return { - ngModule: AuthModule, - providers: [ - OidcSecurityService, - OidcSecurityValidation, - OidcSecurityCheckSession, - OidcSecuritySilentRenew, - OidcSecurityUserService, - OidcSecurityCommon, - AuthConfiguration, - DefaultConfiguration, - AuthWellKnownEndpoints, - { - provide: OidcSecurityStorage, - useClass: token.storage || BrowserStorage - } - ] - }; - }; - /** - * @param {?=} token - * @return {?} - */ - AuthModule.forChild = function (token) { - if (token === void 0) { token = {}; } - return { - ngModule: AuthModule, - providers: [ - OidcSecurityService, - OidcSecurityValidation, - OidcSecurityCheckSession, - OidcSecuritySilentRenew, - OidcSecurityUserService, - OidcSecurityCommon, - AuthConfiguration, - AuthWellKnownEndpoints, - { - provide: OidcSecurityStorage, - useClass: token.storage || BrowserStorage - } - ] - }; - }; - return AuthModule; -}()); -AuthModule.decorators = [ - { type: _angular_core.NgModule }, -]; -/** - * @nocollapse - */ -AuthModule.ctorParameters = function () { return []; }; - -exports.OidcSecurityService = OidcSecurityService; -exports.OidcSecurityValidation = OidcSecurityValidation; -exports.OidcSecurityCheckSession = OidcSecurityCheckSession; -exports.OidcSecuritySilentRenew = OidcSecuritySilentRenew; -exports.OidcSecurityUserService = OidcSecurityUserService; -exports.OidcSecurityCommon = OidcSecurityCommon; -exports.OidcSecurityStorage = OidcSecurityStorage; -exports.BrowserStorage = BrowserStorage; -exports.AuthWellKnownEndpoints = AuthWellKnownEndpoints; -exports.AuthConfiguration = AuthConfiguration; -exports.OpenIDImplicitFlowConfiguration = OpenIDImplicitFlowConfiguration; -exports.DefaultConfiguration = DefaultConfiguration; -exports.AuthModule = AuthModule; - -Object.defineProperty(exports, '__esModule', { value: true }); - -}))); -//# sourceMappingURL=angular-auth-oidc-client.umd.js.map - - -/***/ }), -/* 48 */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { - -"use strict"; -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return AppComponent; }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__angular_core__ = __webpack_require__(10); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__angular_core___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0__angular_core__); -var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { - var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); - else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; - return c > 3 && r && Object.defineProperty(target, key, r), r; -}; - -var AppComponent = (function () { - function AppComponent() { - } - AppComponent = __decorate([ - __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__angular_core__["Component"])({ - selector: 'app', - template: __webpack_require__(103), - styles: [__webpack_require__(375)] - }) - ], AppComponent); - return AppComponent; -}()); - - - -/***/ }), -/* 49 */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - - -var Tokenizer = __webpack_require__(19), - HTML = __webpack_require__(11); - -//Aliases -var $ = HTML.TAG_NAMES, - NS = HTML.NAMESPACES, - ATTRS = HTML.ATTRS; - - -//MIME types -var MIME_TYPES = { - TEXT_HTML: 'text/html', - APPLICATION_XML: 'application/xhtml+xml' -}; - -//Attributes -var DEFINITION_URL_ATTR = 'definitionurl', - ADJUSTED_DEFINITION_URL_ATTR = 'definitionURL', - SVG_ATTRS_ADJUSTMENT_MAP = { - 'attributename': 'attributeName', - 'attributetype': 'attributeType', - 'basefrequency': 'baseFrequency', - 'baseprofile': 'baseProfile', - 'calcmode': 'calcMode', - 'clippathunits': 'clipPathUnits', - 'diffuseconstant': 'diffuseConstant', - 'edgemode': 'edgeMode', - 'filterunits': 'filterUnits', - 'glyphref': 'glyphRef', - 'gradienttransform': 'gradientTransform', - 'gradientunits': 'gradientUnits', - 'kernelmatrix': 'kernelMatrix', - 'kernelunitlength': 'kernelUnitLength', - 'keypoints': 'keyPoints', - 'keysplines': 'keySplines', - 'keytimes': 'keyTimes', - 'lengthadjust': 'lengthAdjust', - 'limitingconeangle': 'limitingConeAngle', - 'markerheight': 'markerHeight', - 'markerunits': 'markerUnits', - 'markerwidth': 'markerWidth', - 'maskcontentunits': 'maskContentUnits', - 'maskunits': 'maskUnits', - 'numoctaves': 'numOctaves', - 'pathlength': 'pathLength', - 'patterncontentunits': 'patternContentUnits', - 'patterntransform': 'patternTransform', - 'patternunits': 'patternUnits', - 'pointsatx': 'pointsAtX', - 'pointsaty': 'pointsAtY', - 'pointsatz': 'pointsAtZ', - 'preservealpha': 'preserveAlpha', - 'preserveaspectratio': 'preserveAspectRatio', - 'primitiveunits': 'primitiveUnits', - 'refx': 'refX', - 'refy': 'refY', - 'repeatcount': 'repeatCount', - 'repeatdur': 'repeatDur', - 'requiredextensions': 'requiredExtensions', - 'requiredfeatures': 'requiredFeatures', - 'specularconstant': 'specularConstant', - 'specularexponent': 'specularExponent', - 'spreadmethod': 'spreadMethod', - 'startoffset': 'startOffset', - 'stddeviation': 'stdDeviation', - 'stitchtiles': 'stitchTiles', - 'surfacescale': 'surfaceScale', - 'systemlanguage': 'systemLanguage', - 'tablevalues': 'tableValues', - 'targetx': 'targetX', - 'targety': 'targetY', - 'textlength': 'textLength', - 'viewbox': 'viewBox', - 'viewtarget': 'viewTarget', - 'xchannelselector': 'xChannelSelector', - 'ychannelselector': 'yChannelSelector', - 'zoomandpan': 'zoomAndPan' - }, - XML_ATTRS_ADJUSTMENT_MAP = { - 'xlink:actuate': {prefix: 'xlink', name: 'actuate', namespace: NS.XLINK}, - 'xlink:arcrole': {prefix: 'xlink', name: 'arcrole', namespace: NS.XLINK}, - 'xlink:href': {prefix: 'xlink', name: 'href', namespace: NS.XLINK}, - 'xlink:role': {prefix: 'xlink', name: 'role', namespace: NS.XLINK}, - 'xlink:show': {prefix: 'xlink', name: 'show', namespace: NS.XLINK}, - 'xlink:title': {prefix: 'xlink', name: 'title', namespace: NS.XLINK}, - 'xlink:type': {prefix: 'xlink', name: 'type', namespace: NS.XLINK}, - 'xml:base': {prefix: 'xml', name: 'base', namespace: NS.XML}, - 'xml:lang': {prefix: 'xml', name: 'lang', namespace: NS.XML}, - 'xml:space': {prefix: 'xml', name: 'space', namespace: NS.XML}, - 'xmlns': {prefix: '', name: 'xmlns', namespace: NS.XMLNS}, - 'xmlns:xlink': {prefix: 'xmlns', name: 'xlink', namespace: NS.XMLNS} - - }; - -//SVG tag names adjustment map -var SVG_TAG_NAMES_ADJUSTMENT_MAP = exports.SVG_TAG_NAMES_ADJUSTMENT_MAP = { - 'altglyph': 'altGlyph', - 'altglyphdef': 'altGlyphDef', - 'altglyphitem': 'altGlyphItem', - 'animatecolor': 'animateColor', - 'animatemotion': 'animateMotion', - 'animatetransform': 'animateTransform', - 'clippath': 'clipPath', - 'feblend': 'feBlend', - 'fecolormatrix': 'feColorMatrix', - 'fecomponenttransfer': 'feComponentTransfer', - 'fecomposite': 'feComposite', - 'feconvolvematrix': 'feConvolveMatrix', - 'fediffuselighting': 'feDiffuseLighting', - 'fedisplacementmap': 'feDisplacementMap', - 'fedistantlight': 'feDistantLight', - 'feflood': 'feFlood', - 'fefunca': 'feFuncA', - 'fefuncb': 'feFuncB', - 'fefuncg': 'feFuncG', - 'fefuncr': 'feFuncR', - 'fegaussianblur': 'feGaussianBlur', - 'feimage': 'feImage', - 'femerge': 'feMerge', - 'femergenode': 'feMergeNode', - 'femorphology': 'feMorphology', - 'feoffset': 'feOffset', - 'fepointlight': 'fePointLight', - 'fespecularlighting': 'feSpecularLighting', - 'fespotlight': 'feSpotLight', - 'fetile': 'feTile', - 'feturbulence': 'feTurbulence', - 'foreignobject': 'foreignObject', - 'glyphref': 'glyphRef', - 'lineargradient': 'linearGradient', - 'radialgradient': 'radialGradient', - 'textpath': 'textPath' -}; - -//Tags that causes exit from foreign content -var EXITS_FOREIGN_CONTENT = Object.create(null); - -EXITS_FOREIGN_CONTENT[$.B] = true; -EXITS_FOREIGN_CONTENT[$.BIG] = true; -EXITS_FOREIGN_CONTENT[$.BLOCKQUOTE] = true; -EXITS_FOREIGN_CONTENT[$.BODY] = true; -EXITS_FOREIGN_CONTENT[$.BR] = true; -EXITS_FOREIGN_CONTENT[$.CENTER] = true; -EXITS_FOREIGN_CONTENT[$.CODE] = true; -EXITS_FOREIGN_CONTENT[$.DD] = true; -EXITS_FOREIGN_CONTENT[$.DIV] = true; -EXITS_FOREIGN_CONTENT[$.DL] = true; -EXITS_FOREIGN_CONTENT[$.DT] = true; -EXITS_FOREIGN_CONTENT[$.EM] = true; -EXITS_FOREIGN_CONTENT[$.EMBED] = true; -EXITS_FOREIGN_CONTENT[$.H1] = true; -EXITS_FOREIGN_CONTENT[$.H2] = true; -EXITS_FOREIGN_CONTENT[$.H3] = true; -EXITS_FOREIGN_CONTENT[$.H4] = true; -EXITS_FOREIGN_CONTENT[$.H5] = true; -EXITS_FOREIGN_CONTENT[$.H6] = true; -EXITS_FOREIGN_CONTENT[$.HEAD] = true; -EXITS_FOREIGN_CONTENT[$.HR] = true; -EXITS_FOREIGN_CONTENT[$.I] = true; -EXITS_FOREIGN_CONTENT[$.IMG] = true; -EXITS_FOREIGN_CONTENT[$.LI] = true; -EXITS_FOREIGN_CONTENT[$.LISTING] = true; -EXITS_FOREIGN_CONTENT[$.MENU] = true; -EXITS_FOREIGN_CONTENT[$.META] = true; -EXITS_FOREIGN_CONTENT[$.NOBR] = true; -EXITS_FOREIGN_CONTENT[$.OL] = true; -EXITS_FOREIGN_CONTENT[$.P] = true; -EXITS_FOREIGN_CONTENT[$.PRE] = true; -EXITS_FOREIGN_CONTENT[$.RUBY] = true; -EXITS_FOREIGN_CONTENT[$.S] = true; -EXITS_FOREIGN_CONTENT[$.SMALL] = true; -EXITS_FOREIGN_CONTENT[$.SPAN] = true; -EXITS_FOREIGN_CONTENT[$.STRONG] = true; -EXITS_FOREIGN_CONTENT[$.STRIKE] = true; -EXITS_FOREIGN_CONTENT[$.SUB] = true; -EXITS_FOREIGN_CONTENT[$.SUP] = true; -EXITS_FOREIGN_CONTENT[$.TABLE] = true; -EXITS_FOREIGN_CONTENT[$.TT] = true; -EXITS_FOREIGN_CONTENT[$.U] = true; -EXITS_FOREIGN_CONTENT[$.UL] = true; -EXITS_FOREIGN_CONTENT[$.VAR] = true; - -//Check exit from foreign content -exports.causesExit = function (startTagToken) { - var tn = startTagToken.tagName; - var isFontWithAttrs = tn === $.FONT && (Tokenizer.getTokenAttr(startTagToken, ATTRS.COLOR) !== null || - Tokenizer.getTokenAttr(startTagToken, ATTRS.SIZE) !== null || - Tokenizer.getTokenAttr(startTagToken, ATTRS.FACE) !== null); - - return isFontWithAttrs ? true : EXITS_FOREIGN_CONTENT[tn]; -}; - -//Token adjustments -exports.adjustTokenMathMLAttrs = function (token) { - for (var i = 0; i < token.attrs.length; i++) { - if (token.attrs[i].name === DEFINITION_URL_ATTR) { - token.attrs[i].name = ADJUSTED_DEFINITION_URL_ATTR; - break; - } - } -}; - -exports.adjustTokenSVGAttrs = function (token) { - for (var i = 0; i < token.attrs.length; i++) { - var adjustedAttrName = SVG_ATTRS_ADJUSTMENT_MAP[token.attrs[i].name]; - - if (adjustedAttrName) - token.attrs[i].name = adjustedAttrName; - } -}; - -exports.adjustTokenXMLAttrs = function (token) { - for (var i = 0; i < token.attrs.length; i++) { - var adjustedAttrEntry = XML_ATTRS_ADJUSTMENT_MAP[token.attrs[i].name]; - - if (adjustedAttrEntry) { - token.attrs[i].prefix = adjustedAttrEntry.prefix; - token.attrs[i].name = adjustedAttrEntry.name; - token.attrs[i].namespace = adjustedAttrEntry.namespace; - } - } -}; - -exports.adjustTokenSVGTagName = function (token) { - var adjustedTagName = SVG_TAG_NAMES_ADJUSTMENT_MAP[token.tagName]; - - if (adjustedTagName) - token.tagName = adjustedTagName; -}; - -//Integration points -function isMathMLTextIntegrationPoint(tn, ns) { - return ns === NS.MATHML && (tn === $.MI || tn === $.MO || tn === $.MN || tn === $.MS || tn === $.MTEXT); -} - -function isHtmlIntegrationPoint(tn, ns, attrs) { - if (ns === NS.MATHML && tn === $.ANNOTATION_XML) { - for (var i = 0; i < attrs.length; i++) { - if (attrs[i].name === ATTRS.ENCODING) { - var value = attrs[i].value.toLowerCase(); - - return value === MIME_TYPES.TEXT_HTML || value === MIME_TYPES.APPLICATION_XML; - } - } - } - - return ns === NS.SVG && (tn === $.FOREIGN_OBJECT || tn === $.DESC || tn === $.TITLE); -} - -exports.isIntegrationPoint = function (tn, ns, attrs, foreignNS) { - if ((!foreignNS || foreignNS === NS.HTML) && isHtmlIntegrationPoint(tn, ns, attrs)) - return true; - - if ((!foreignNS || foreignNS === NS.MATHML) && isMathMLTextIntegrationPoint(tn, ns)) - return true; - - return false; -}; - - -/***/ }), -/* 50 */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - - -var Tokenizer = __webpack_require__(19), - OpenElementStack = __webpack_require__(51), - FormattingElementList = __webpack_require__(112), - locationInfoMixin = __webpack_require__(110), - defaultTreeAdapter = __webpack_require__(36), - doctype = __webpack_require__(33), - foreignContent = __webpack_require__(49), - mergeOptions = __webpack_require__(34), - UNICODE = __webpack_require__(18), - HTML = __webpack_require__(11); - -//Aliases -var $ = HTML.TAG_NAMES, - NS = HTML.NAMESPACES, - ATTRS = HTML.ATTRS; - -var DEFAULT_OPTIONS = { - locationInfo: false, - treeAdapter: defaultTreeAdapter -}; - -//Misc constants -var HIDDEN_INPUT_TYPE = 'hidden'; - -//Adoption agency loops iteration count -var AA_OUTER_LOOP_ITER = 8, - AA_INNER_LOOP_ITER = 3; - -//Insertion modes -var INITIAL_MODE = 'INITIAL_MODE', - BEFORE_HTML_MODE = 'BEFORE_HTML_MODE', - BEFORE_HEAD_MODE = 'BEFORE_HEAD_MODE', - IN_HEAD_MODE = 'IN_HEAD_MODE', - AFTER_HEAD_MODE = 'AFTER_HEAD_MODE', - IN_BODY_MODE = 'IN_BODY_MODE', - TEXT_MODE = 'TEXT_MODE', - IN_TABLE_MODE = 'IN_TABLE_MODE', - IN_TABLE_TEXT_MODE = 'IN_TABLE_TEXT_MODE', - IN_CAPTION_MODE = 'IN_CAPTION_MODE', - IN_COLUMN_GROUP_MODE = 'IN_COLUMN_GROUP_MODE', - IN_TABLE_BODY_MODE = 'IN_TABLE_BODY_MODE', - IN_ROW_MODE = 'IN_ROW_MODE', - IN_CELL_MODE = 'IN_CELL_MODE', - IN_SELECT_MODE = 'IN_SELECT_MODE', - IN_SELECT_IN_TABLE_MODE = 'IN_SELECT_IN_TABLE_MODE', - IN_TEMPLATE_MODE = 'IN_TEMPLATE_MODE', - AFTER_BODY_MODE = 'AFTER_BODY_MODE', - IN_FRAMESET_MODE = 'IN_FRAMESET_MODE', - AFTER_FRAMESET_MODE = 'AFTER_FRAMESET_MODE', - AFTER_AFTER_BODY_MODE = 'AFTER_AFTER_BODY_MODE', - AFTER_AFTER_FRAMESET_MODE = 'AFTER_AFTER_FRAMESET_MODE'; - -//Insertion mode reset map -var INSERTION_MODE_RESET_MAP = Object.create(null); - -INSERTION_MODE_RESET_MAP[$.TR] = IN_ROW_MODE; -INSERTION_MODE_RESET_MAP[$.TBODY] = -INSERTION_MODE_RESET_MAP[$.THEAD] = -INSERTION_MODE_RESET_MAP[$.TFOOT] = IN_TABLE_BODY_MODE; -INSERTION_MODE_RESET_MAP[$.CAPTION] = IN_CAPTION_MODE; -INSERTION_MODE_RESET_MAP[$.COLGROUP] = IN_COLUMN_GROUP_MODE; -INSERTION_MODE_RESET_MAP[$.TABLE] = IN_TABLE_MODE; -INSERTION_MODE_RESET_MAP[$.BODY] = IN_BODY_MODE; -INSERTION_MODE_RESET_MAP[$.FRAMESET] = IN_FRAMESET_MODE; - -//Template insertion mode switch map -var TEMPLATE_INSERTION_MODE_SWITCH_MAP = Object.create(null); - -TEMPLATE_INSERTION_MODE_SWITCH_MAP[$.CAPTION] = -TEMPLATE_INSERTION_MODE_SWITCH_MAP[$.COLGROUP] = -TEMPLATE_INSERTION_MODE_SWITCH_MAP[$.TBODY] = -TEMPLATE_INSERTION_MODE_SWITCH_MAP[$.TFOOT] = -TEMPLATE_INSERTION_MODE_SWITCH_MAP[$.THEAD] = IN_TABLE_MODE; -TEMPLATE_INSERTION_MODE_SWITCH_MAP[$.COL] = IN_COLUMN_GROUP_MODE; -TEMPLATE_INSERTION_MODE_SWITCH_MAP[$.TR] = IN_TABLE_BODY_MODE; -TEMPLATE_INSERTION_MODE_SWITCH_MAP[$.TD] = -TEMPLATE_INSERTION_MODE_SWITCH_MAP[$.TH] = IN_ROW_MODE; - -//Token handlers map for insertion modes -var _ = Object.create(null); - -_[INITIAL_MODE] = Object.create(null); -_[INITIAL_MODE][Tokenizer.CHARACTER_TOKEN] = -_[INITIAL_MODE][Tokenizer.NULL_CHARACTER_TOKEN] = tokenInInitialMode; -_[INITIAL_MODE][Tokenizer.WHITESPACE_CHARACTER_TOKEN] = ignoreToken; -_[INITIAL_MODE][Tokenizer.COMMENT_TOKEN] = appendComment; -_[INITIAL_MODE][Tokenizer.DOCTYPE_TOKEN] = doctypeInInitialMode; -_[INITIAL_MODE][Tokenizer.START_TAG_TOKEN] = -_[INITIAL_MODE][Tokenizer.END_TAG_TOKEN] = -_[INITIAL_MODE][Tokenizer.EOF_TOKEN] = tokenInInitialMode; - -_[BEFORE_HTML_MODE] = Object.create(null); -_[BEFORE_HTML_MODE][Tokenizer.CHARACTER_TOKEN] = -_[BEFORE_HTML_MODE][Tokenizer.NULL_CHARACTER_TOKEN] = tokenBeforeHtml; -_[BEFORE_HTML_MODE][Tokenizer.WHITESPACE_CHARACTER_TOKEN] = ignoreToken; -_[BEFORE_HTML_MODE][Tokenizer.COMMENT_TOKEN] = appendComment; -_[BEFORE_HTML_MODE][Tokenizer.DOCTYPE_TOKEN] = ignoreToken; -_[BEFORE_HTML_MODE][Tokenizer.START_TAG_TOKEN] = startTagBeforeHtml; -_[BEFORE_HTML_MODE][Tokenizer.END_TAG_TOKEN] = endTagBeforeHtml; -_[BEFORE_HTML_MODE][Tokenizer.EOF_TOKEN] = tokenBeforeHtml; - -_[BEFORE_HEAD_MODE] = Object.create(null); -_[BEFORE_HEAD_MODE][Tokenizer.CHARACTER_TOKEN] = -_[BEFORE_HEAD_MODE][Tokenizer.NULL_CHARACTER_TOKEN] = tokenBeforeHead; -_[BEFORE_HEAD_MODE][Tokenizer.WHITESPACE_CHARACTER_TOKEN] = ignoreToken; -_[BEFORE_HEAD_MODE][Tokenizer.COMMENT_TOKEN] = appendComment; -_[BEFORE_HEAD_MODE][Tokenizer.DOCTYPE_TOKEN] = ignoreToken; -_[BEFORE_HEAD_MODE][Tokenizer.START_TAG_TOKEN] = startTagBeforeHead; -_[BEFORE_HEAD_MODE][Tokenizer.END_TAG_TOKEN] = endTagBeforeHead; -_[BEFORE_HEAD_MODE][Tokenizer.EOF_TOKEN] = tokenBeforeHead; - -_[IN_HEAD_MODE] = Object.create(null); -_[IN_HEAD_MODE][Tokenizer.CHARACTER_TOKEN] = -_[IN_HEAD_MODE][Tokenizer.NULL_CHARACTER_TOKEN] = tokenInHead; -_[IN_HEAD_MODE][Tokenizer.WHITESPACE_CHARACTER_TOKEN] = insertCharacters; -_[IN_HEAD_MODE][Tokenizer.COMMENT_TOKEN] = appendComment; -_[IN_HEAD_MODE][Tokenizer.DOCTYPE_TOKEN] = ignoreToken; -_[IN_HEAD_MODE][Tokenizer.START_TAG_TOKEN] = startTagInHead; -_[IN_HEAD_MODE][Tokenizer.END_TAG_TOKEN] = endTagInHead; -_[IN_HEAD_MODE][Tokenizer.EOF_TOKEN] = tokenInHead; - -_[AFTER_HEAD_MODE] = Object.create(null); -_[AFTER_HEAD_MODE][Tokenizer.CHARACTER_TOKEN] = -_[AFTER_HEAD_MODE][Tokenizer.NULL_CHARACTER_TOKEN] = tokenAfterHead; -_[AFTER_HEAD_MODE][Tokenizer.WHITESPACE_CHARACTER_TOKEN] = insertCharacters; -_[AFTER_HEAD_MODE][Tokenizer.COMMENT_TOKEN] = appendComment; -_[AFTER_HEAD_MODE][Tokenizer.DOCTYPE_TOKEN] = ignoreToken; -_[AFTER_HEAD_MODE][Tokenizer.START_TAG_TOKEN] = startTagAfterHead; -_[AFTER_HEAD_MODE][Tokenizer.END_TAG_TOKEN] = endTagAfterHead; -_[AFTER_HEAD_MODE][Tokenizer.EOF_TOKEN] = tokenAfterHead; - -_[IN_BODY_MODE] = Object.create(null); -_[IN_BODY_MODE][Tokenizer.CHARACTER_TOKEN] = characterInBody; -_[IN_BODY_MODE][Tokenizer.NULL_CHARACTER_TOKEN] = ignoreToken; -_[IN_BODY_MODE][Tokenizer.WHITESPACE_CHARACTER_TOKEN] = whitespaceCharacterInBody; -_[IN_BODY_MODE][Tokenizer.COMMENT_TOKEN] = appendComment; -_[IN_BODY_MODE][Tokenizer.DOCTYPE_TOKEN] = ignoreToken; -_[IN_BODY_MODE][Tokenizer.START_TAG_TOKEN] = startTagInBody; -_[IN_BODY_MODE][Tokenizer.END_TAG_TOKEN] = endTagInBody; -_[IN_BODY_MODE][Tokenizer.EOF_TOKEN] = eofInBody; - -_[TEXT_MODE] = Object.create(null); -_[TEXT_MODE][Tokenizer.CHARACTER_TOKEN] = -_[TEXT_MODE][Tokenizer.NULL_CHARACTER_TOKEN] = -_[TEXT_MODE][Tokenizer.WHITESPACE_CHARACTER_TOKEN] = insertCharacters; -_[TEXT_MODE][Tokenizer.COMMENT_TOKEN] = -_[TEXT_MODE][Tokenizer.DOCTYPE_TOKEN] = -_[TEXT_MODE][Tokenizer.START_TAG_TOKEN] = ignoreToken; -_[TEXT_MODE][Tokenizer.END_TAG_TOKEN] = endTagInText; -_[TEXT_MODE][Tokenizer.EOF_TOKEN] = eofInText; - -_[IN_TABLE_MODE] = Object.create(null); -_[IN_TABLE_MODE][Tokenizer.CHARACTER_TOKEN] = -_[IN_TABLE_MODE][Tokenizer.NULL_CHARACTER_TOKEN] = -_[IN_TABLE_MODE][Tokenizer.WHITESPACE_CHARACTER_TOKEN] = characterInTable; -_[IN_TABLE_MODE][Tokenizer.COMMENT_TOKEN] = appendComment; -_[IN_TABLE_MODE][Tokenizer.DOCTYPE_TOKEN] = ignoreToken; -_[IN_TABLE_MODE][Tokenizer.START_TAG_TOKEN] = startTagInTable; -_[IN_TABLE_MODE][Tokenizer.END_TAG_TOKEN] = endTagInTable; -_[IN_TABLE_MODE][Tokenizer.EOF_TOKEN] = eofInBody; - -_[IN_TABLE_TEXT_MODE] = Object.create(null); -_[IN_TABLE_TEXT_MODE][Tokenizer.CHARACTER_TOKEN] = characterInTableText; -_[IN_TABLE_TEXT_MODE][Tokenizer.NULL_CHARACTER_TOKEN] = ignoreToken; -_[IN_TABLE_TEXT_MODE][Tokenizer.WHITESPACE_CHARACTER_TOKEN] = whitespaceCharacterInTableText; -_[IN_TABLE_TEXT_MODE][Tokenizer.COMMENT_TOKEN] = -_[IN_TABLE_TEXT_MODE][Tokenizer.DOCTYPE_TOKEN] = -_[IN_TABLE_TEXT_MODE][Tokenizer.START_TAG_TOKEN] = -_[IN_TABLE_TEXT_MODE][Tokenizer.END_TAG_TOKEN] = -_[IN_TABLE_TEXT_MODE][Tokenizer.EOF_TOKEN] = tokenInTableText; - -_[IN_CAPTION_MODE] = Object.create(null); -_[IN_CAPTION_MODE][Tokenizer.CHARACTER_TOKEN] = characterInBody; -_[IN_CAPTION_MODE][Tokenizer.NULL_CHARACTER_TOKEN] = ignoreToken; -_[IN_CAPTION_MODE][Tokenizer.WHITESPACE_CHARACTER_TOKEN] = whitespaceCharacterInBody; -_[IN_CAPTION_MODE][Tokenizer.COMMENT_TOKEN] = appendComment; -_[IN_CAPTION_MODE][Tokenizer.DOCTYPE_TOKEN] = ignoreToken; -_[IN_CAPTION_MODE][Tokenizer.START_TAG_TOKEN] = startTagInCaption; -_[IN_CAPTION_MODE][Tokenizer.END_TAG_TOKEN] = endTagInCaption; -_[IN_CAPTION_MODE][Tokenizer.EOF_TOKEN] = eofInBody; - -_[IN_COLUMN_GROUP_MODE] = Object.create(null); -_[IN_COLUMN_GROUP_MODE][Tokenizer.CHARACTER_TOKEN] = -_[IN_COLUMN_GROUP_MODE][Tokenizer.NULL_CHARACTER_TOKEN] = tokenInColumnGroup; -_[IN_COLUMN_GROUP_MODE][Tokenizer.WHITESPACE_CHARACTER_TOKEN] = insertCharacters; -_[IN_COLUMN_GROUP_MODE][Tokenizer.COMMENT_TOKEN] = appendComment; -_[IN_COLUMN_GROUP_MODE][Tokenizer.DOCTYPE_TOKEN] = ignoreToken; -_[IN_COLUMN_GROUP_MODE][Tokenizer.START_TAG_TOKEN] = startTagInColumnGroup; -_[IN_COLUMN_GROUP_MODE][Tokenizer.END_TAG_TOKEN] = endTagInColumnGroup; -_[IN_COLUMN_GROUP_MODE][Tokenizer.EOF_TOKEN] = eofInBody; - -_[IN_TABLE_BODY_MODE] = Object.create(null); -_[IN_TABLE_BODY_MODE][Tokenizer.CHARACTER_TOKEN] = -_[IN_TABLE_BODY_MODE][Tokenizer.NULL_CHARACTER_TOKEN] = -_[IN_TABLE_BODY_MODE][Tokenizer.WHITESPACE_CHARACTER_TOKEN] = characterInTable; -_[IN_TABLE_BODY_MODE][Tokenizer.COMMENT_TOKEN] = appendComment; -_[IN_TABLE_BODY_MODE][Tokenizer.DOCTYPE_TOKEN] = ignoreToken; -_[IN_TABLE_BODY_MODE][Tokenizer.START_TAG_TOKEN] = startTagInTableBody; -_[IN_TABLE_BODY_MODE][Tokenizer.END_TAG_TOKEN] = endTagInTableBody; -_[IN_TABLE_BODY_MODE][Tokenizer.EOF_TOKEN] = eofInBody; - -_[IN_ROW_MODE] = Object.create(null); -_[IN_ROW_MODE][Tokenizer.CHARACTER_TOKEN] = -_[IN_ROW_MODE][Tokenizer.NULL_CHARACTER_TOKEN] = -_[IN_ROW_MODE][Tokenizer.WHITESPACE_CHARACTER_TOKEN] = characterInTable; -_[IN_ROW_MODE][Tokenizer.COMMENT_TOKEN] = appendComment; -_[IN_ROW_MODE][Tokenizer.DOCTYPE_TOKEN] = ignoreToken; -_[IN_ROW_MODE][Tokenizer.START_TAG_TOKEN] = startTagInRow; -_[IN_ROW_MODE][Tokenizer.END_TAG_TOKEN] = endTagInRow; -_[IN_ROW_MODE][Tokenizer.EOF_TOKEN] = eofInBody; - -_[IN_CELL_MODE] = Object.create(null); -_[IN_CELL_MODE][Tokenizer.CHARACTER_TOKEN] = characterInBody; -_[IN_CELL_MODE][Tokenizer.NULL_CHARACTER_TOKEN] = ignoreToken; -_[IN_CELL_MODE][Tokenizer.WHITESPACE_CHARACTER_TOKEN] = whitespaceCharacterInBody; -_[IN_CELL_MODE][Tokenizer.COMMENT_TOKEN] = appendComment; -_[IN_CELL_MODE][Tokenizer.DOCTYPE_TOKEN] = ignoreToken; -_[IN_CELL_MODE][Tokenizer.START_TAG_TOKEN] = startTagInCell; -_[IN_CELL_MODE][Tokenizer.END_TAG_TOKEN] = endTagInCell; -_[IN_CELL_MODE][Tokenizer.EOF_TOKEN] = eofInBody; - -_[IN_SELECT_MODE] = Object.create(null); -_[IN_SELECT_MODE][Tokenizer.CHARACTER_TOKEN] = insertCharacters; -_[IN_SELECT_MODE][Tokenizer.NULL_CHARACTER_TOKEN] = ignoreToken; -_[IN_SELECT_MODE][Tokenizer.WHITESPACE_CHARACTER_TOKEN] = insertCharacters; -_[IN_SELECT_MODE][Tokenizer.COMMENT_TOKEN] = appendComment; -_[IN_SELECT_MODE][Tokenizer.DOCTYPE_TOKEN] = ignoreToken; -_[IN_SELECT_MODE][Tokenizer.START_TAG_TOKEN] = startTagInSelect; -_[IN_SELECT_MODE][Tokenizer.END_TAG_TOKEN] = endTagInSelect; -_[IN_SELECT_MODE][Tokenizer.EOF_TOKEN] = eofInBody; - -_[IN_SELECT_IN_TABLE_MODE] = Object.create(null); -_[IN_SELECT_IN_TABLE_MODE][Tokenizer.CHARACTER_TOKEN] = insertCharacters; -_[IN_SELECT_IN_TABLE_MODE][Tokenizer.NULL_CHARACTER_TOKEN] = ignoreToken; -_[IN_SELECT_IN_TABLE_MODE][Tokenizer.WHITESPACE_CHARACTER_TOKEN] = insertCharacters; -_[IN_SELECT_IN_TABLE_MODE][Tokenizer.COMMENT_TOKEN] = appendComment; -_[IN_SELECT_IN_TABLE_MODE][Tokenizer.DOCTYPE_TOKEN] = ignoreToken; -_[IN_SELECT_IN_TABLE_MODE][Tokenizer.START_TAG_TOKEN] = startTagInSelectInTable; -_[IN_SELECT_IN_TABLE_MODE][Tokenizer.END_TAG_TOKEN] = endTagInSelectInTable; -_[IN_SELECT_IN_TABLE_MODE][Tokenizer.EOF_TOKEN] = eofInBody; - -_[IN_TEMPLATE_MODE] = Object.create(null); -_[IN_TEMPLATE_MODE][Tokenizer.CHARACTER_TOKEN] = characterInBody; -_[IN_TEMPLATE_MODE][Tokenizer.NULL_CHARACTER_TOKEN] = ignoreToken; -_[IN_TEMPLATE_MODE][Tokenizer.WHITESPACE_CHARACTER_TOKEN] = whitespaceCharacterInBody; -_[IN_TEMPLATE_MODE][Tokenizer.COMMENT_TOKEN] = appendComment; -_[IN_TEMPLATE_MODE][Tokenizer.DOCTYPE_TOKEN] = ignoreToken; -_[IN_TEMPLATE_MODE][Tokenizer.START_TAG_TOKEN] = startTagInTemplate; -_[IN_TEMPLATE_MODE][Tokenizer.END_TAG_TOKEN] = endTagInTemplate; -_[IN_TEMPLATE_MODE][Tokenizer.EOF_TOKEN] = eofInTemplate; - -_[AFTER_BODY_MODE] = Object.create(null); -_[AFTER_BODY_MODE][Tokenizer.CHARACTER_TOKEN] = -_[AFTER_BODY_MODE][Tokenizer.NULL_CHARACTER_TOKEN] = tokenAfterBody; -_[AFTER_BODY_MODE][Tokenizer.WHITESPACE_CHARACTER_TOKEN] = whitespaceCharacterInBody; -_[AFTER_BODY_MODE][Tokenizer.COMMENT_TOKEN] = appendCommentToRootHtmlElement; -_[AFTER_BODY_MODE][Tokenizer.DOCTYPE_TOKEN] = ignoreToken; -_[AFTER_BODY_MODE][Tokenizer.START_TAG_TOKEN] = startTagAfterBody; -_[AFTER_BODY_MODE][Tokenizer.END_TAG_TOKEN] = endTagAfterBody; -_[AFTER_BODY_MODE][Tokenizer.EOF_TOKEN] = stopParsing; - -_[IN_FRAMESET_MODE] = Object.create(null); -_[IN_FRAMESET_MODE][Tokenizer.CHARACTER_TOKEN] = -_[IN_FRAMESET_MODE][Tokenizer.NULL_CHARACTER_TOKEN] = ignoreToken; -_[IN_FRAMESET_MODE][Tokenizer.WHITESPACE_CHARACTER_TOKEN] = insertCharacters; -_[IN_FRAMESET_MODE][Tokenizer.COMMENT_TOKEN] = appendComment; -_[IN_FRAMESET_MODE][Tokenizer.DOCTYPE_TOKEN] = ignoreToken; -_[IN_FRAMESET_MODE][Tokenizer.START_TAG_TOKEN] = startTagInFrameset; -_[IN_FRAMESET_MODE][Tokenizer.END_TAG_TOKEN] = endTagInFrameset; -_[IN_FRAMESET_MODE][Tokenizer.EOF_TOKEN] = stopParsing; - -_[AFTER_FRAMESET_MODE] = Object.create(null); -_[AFTER_FRAMESET_MODE][Tokenizer.CHARACTER_TOKEN] = -_[AFTER_FRAMESET_MODE][Tokenizer.NULL_CHARACTER_TOKEN] = ignoreToken; -_[AFTER_FRAMESET_MODE][Tokenizer.WHITESPACE_CHARACTER_TOKEN] = insertCharacters; -_[AFTER_FRAMESET_MODE][Tokenizer.COMMENT_TOKEN] = appendComment; -_[AFTER_FRAMESET_MODE][Tokenizer.DOCTYPE_TOKEN] = ignoreToken; -_[AFTER_FRAMESET_MODE][Tokenizer.START_TAG_TOKEN] = startTagAfterFrameset; -_[AFTER_FRAMESET_MODE][Tokenizer.END_TAG_TOKEN] = endTagAfterFrameset; -_[AFTER_FRAMESET_MODE][Tokenizer.EOF_TOKEN] = stopParsing; - -_[AFTER_AFTER_BODY_MODE] = Object.create(null); -_[AFTER_AFTER_BODY_MODE][Tokenizer.CHARACTER_TOKEN] = tokenAfterAfterBody; -_[AFTER_AFTER_BODY_MODE][Tokenizer.NULL_CHARACTER_TOKEN] = tokenAfterAfterBody; -_[AFTER_AFTER_BODY_MODE][Tokenizer.WHITESPACE_CHARACTER_TOKEN] = whitespaceCharacterInBody; -_[AFTER_AFTER_BODY_MODE][Tokenizer.COMMENT_TOKEN] = appendCommentToDocument; -_[AFTER_AFTER_BODY_MODE][Tokenizer.DOCTYPE_TOKEN] = ignoreToken; -_[AFTER_AFTER_BODY_MODE][Tokenizer.START_TAG_TOKEN] = startTagAfterAfterBody; -_[AFTER_AFTER_BODY_MODE][Tokenizer.END_TAG_TOKEN] = tokenAfterAfterBody; -_[AFTER_AFTER_BODY_MODE][Tokenizer.EOF_TOKEN] = stopParsing; - -_[AFTER_AFTER_FRAMESET_MODE] = Object.create(null); -_[AFTER_AFTER_FRAMESET_MODE][Tokenizer.CHARACTER_TOKEN] = -_[AFTER_AFTER_FRAMESET_MODE][Tokenizer.NULL_CHARACTER_TOKEN] = ignoreToken; -_[AFTER_AFTER_FRAMESET_MODE][Tokenizer.WHITESPACE_CHARACTER_TOKEN] = whitespaceCharacterInBody; -_[AFTER_AFTER_FRAMESET_MODE][Tokenizer.COMMENT_TOKEN] = appendCommentToDocument; -_[AFTER_AFTER_FRAMESET_MODE][Tokenizer.DOCTYPE_TOKEN] = ignoreToken; -_[AFTER_AFTER_FRAMESET_MODE][Tokenizer.START_TAG_TOKEN] = startTagAfterAfterFrameset; -_[AFTER_AFTER_FRAMESET_MODE][Tokenizer.END_TAG_TOKEN] = ignoreToken; -_[AFTER_AFTER_FRAMESET_MODE][Tokenizer.EOF_TOKEN] = stopParsing; - - -//Parser -var Parser = module.exports = function (options) { - this.options = mergeOptions(DEFAULT_OPTIONS, options); - - this.treeAdapter = this.options.treeAdapter; - this.pendingScript = null; - - if (this.options.locationInfo) - locationInfoMixin.assign(this); -}; - -// API -Parser.prototype.parse = function (html) { - var document = this.treeAdapter.createDocument(); - - this._bootstrap(document, null); - this.tokenizer.write(html, true); - this._runParsingLoop(null); - - return document; -}; - -Parser.prototype.parseFragment = function (html, fragmentContext) { - //NOTE: use