UNPKG

422 kBJavaScriptView Raw
1/**
2 * @license Angular v4.1.1
3 * (c) 2010-2017 Google, Inc. https://angular.io/
4 * License: MIT
5 */
6import { Observable } from 'rxjs/Observable';
7import { merge } from 'rxjs/observable/merge';
8import { share } from 'rxjs/operator/share';
9import { Subject } from 'rxjs/Subject';
10
11/**
12 * Creates a token that can be used in a DI Provider.
13 *
14 * ### Example ([live demo](http://plnkr.co/edit/Ys9ezXpj2Mnoy3Uc8KBp?p=preview))
15 *
16 * ```typescript
17 * var t = new OpaqueToken("value");
18 *
19 * var injector = Injector.resolveAndCreate([
20 * {provide: t, useValue: "bindingValue"}
21 * ]);
22 *
23 * expect(injector.get(t)).toEqual("bindingValue");
24 * ```
25 *
26 * Using an `OpaqueToken` is preferable to using strings as tokens because of possible collisions
27 * caused by multiple providers using the same string as two different tokens.
28 *
29 * Using an `OpaqueToken` is preferable to using an `Object` as tokens because it provides better
30 * error messages.
31 * @deprecated since v4.0.0 because it does not support type information, use `InjectionToken<?>`
32 * instead.
33 */
34class OpaqueToken {
35 /**
36 * @param {?} _desc
37 */
38 constructor(_desc) {
39 this._desc = _desc;
40 }
41 /**
42 * @return {?}
43 */
44 toString() { return `Token ${this._desc}`; }
45}
46/**
47 * Creates a token that can be used in a DI Provider.
48 *
49 * Use an `InjectionToken` whenever the type you are injecting is not reified (does not have a
50 * runtime representation) such as when injecting an interface, callable type, array or
51 * parametrized type.
52 *
53 * `InjectionToken` is parameterized on `T` which is the type of object which will be returned by
54 * the `Injector`. This provides additional level of type safety.
55 *
56 * ```
57 * interface MyInterface {...}
58 * var myInterface = injector.get(new InjectionToken<MyInterface>('SomeToken'));
59 * // myInterface is inferred to be MyInterface.
60 * ```
61 *
62 * ### Example
63 *
64 * {\@example core/di/ts/injector_spec.ts region='InjectionToken'}
65 *
66 * \@stable
67 */
68class InjectionToken extends OpaqueToken {
69 /**
70 * @param {?} desc
71 */
72 constructor(desc) { super(desc); }
73 /**
74 * @return {?}
75 */
76 toString() { return `InjectionToken ${this._desc}`; }
77}
78
79/**
80 * @license
81 * Copyright Google Inc. All Rights Reserved.
82 *
83 * Use of this source code is governed by an MIT-style license that can be
84 * found in the LICENSE file at https://angular.io/license
85 */
86const __window = typeof window !== 'undefined' && window;
87const __self = typeof self !== 'undefined' && typeof WorkerGlobalScope !== 'undefined' &&
88 self instanceof WorkerGlobalScope && self;
89const __global = typeof global !== 'undefined' && global;
90const _global = __window || __global || __self;
91let _symbolIterator = null;
92/**
93 * @return {?}
94 */
95function getSymbolIterator() {
96 if (!_symbolIterator) {
97 const /** @type {?} */ Symbol = _global['Symbol'];
98 if (Symbol && Symbol.iterator) {
99 _symbolIterator = Symbol.iterator;
100 }
101 else {
102 // es6-shim specific logic
103 const /** @type {?} */ keys = Object.getOwnPropertyNames(Map.prototype);
104 for (let /** @type {?} */ i = 0; i < keys.length; ++i) {
105 const /** @type {?} */ key = keys[i];
106 if (key !== 'entries' && key !== 'size' &&
107 ((Map)).prototype[key] === Map.prototype['entries']) {
108 _symbolIterator = key;
109 }
110 }
111 }
112 }
113 return _symbolIterator;
114}
115/**
116 * @param {?} fn
117 * @return {?}
118 */
119function scheduleMicroTask(fn) {
120 Zone.current.scheduleMicroTask('scheduleMicrotask', fn);
121}
122/**
123 * @param {?} a
124 * @param {?} b
125 * @return {?}
126 */
127function looseIdentical(a, b) {
128 return a === b || typeof a === 'number' && typeof b === 'number' && isNaN(a) && isNaN(b);
129}
130/**
131 * @param {?} token
132 * @return {?}
133 */
134function stringify(token) {
135 if (typeof token === 'string') {
136 return token;
137 }
138 if (token == null) {
139 return '' + token;
140 }
141 if (token.overriddenName) {
142 return `${token.overriddenName}`;
143 }
144 if (token.name) {
145 return `${token.name}`;
146 }
147 const /** @type {?} */ res = token.toString();
148 if (res == null) {
149 return '' + res;
150 }
151 const /** @type {?} */ newLineIndex = res.indexOf('\n');
152 return newLineIndex === -1 ? res : res.substring(0, newLineIndex);
153}
154
155/**
156 * @license
157 * Copyright Google Inc. All Rights Reserved.
158 *
159 * Use of this source code is governed by an MIT-style license that can be
160 * found in the LICENSE file at https://angular.io/license
161 */
162let _nextClassId = 0;
163const Reflect = _global['Reflect'];
164/**
165 * @param {?} annotation
166 * @return {?}
167 */
168function extractAnnotation(annotation) {
169 if (typeof annotation === 'function' && annotation.hasOwnProperty('annotation')) {
170 // it is a decorator, extract annotation
171 annotation = annotation.annotation;
172 }
173 return annotation;
174}
175/**
176 * @param {?} fnOrArray
177 * @param {?} key
178 * @return {?}
179 */
180function applyParams(fnOrArray, key) {
181 if (fnOrArray === Object || fnOrArray === String || fnOrArray === Function ||
182 fnOrArray === Number || fnOrArray === Array) {
183 throw new Error(`Can not use native ${stringify(fnOrArray)} as constructor`);
184 }
185 if (typeof fnOrArray === 'function') {
186 return fnOrArray;
187 }
188 if (Array.isArray(fnOrArray)) {
189 const /** @type {?} */ annotations = (fnOrArray);
190 const /** @type {?} */ annoLength = annotations.length - 1;
191 const /** @type {?} */ fn = fnOrArray[annoLength];
192 if (typeof fn !== 'function') {
193 throw new Error(`Last position of Class method array must be Function in key ${key} was '${stringify(fn)}'`);
194 }
195 if (annoLength != fn.length) {
196 throw new Error(`Number of annotations (${annoLength}) does not match number of arguments (${fn.length}) in the function: ${stringify(fn)}`);
197 }
198 const /** @type {?} */ paramsAnnotations = [];
199 for (let /** @type {?} */ i = 0, /** @type {?} */ ii = annotations.length - 1; i < ii; i++) {
200 const /** @type {?} */ paramAnnotations = [];
201 paramsAnnotations.push(paramAnnotations);
202 const /** @type {?} */ annotation = annotations[i];
203 if (Array.isArray(annotation)) {
204 for (let /** @type {?} */ j = 0; j < annotation.length; j++) {
205 paramAnnotations.push(extractAnnotation(annotation[j]));
206 }
207 }
208 else if (typeof annotation === 'function') {
209 paramAnnotations.push(extractAnnotation(annotation));
210 }
211 else {
212 paramAnnotations.push(annotation);
213 }
214 }
215 Reflect.defineMetadata('parameters', paramsAnnotations, fn);
216 return fn;
217 }
218 throw new Error(`Only Function or Array is supported in Class definition for key '${key}' is '${stringify(fnOrArray)}'`);
219}
220/**
221 * Provides a way for expressing ES6 classes with parameter annotations in ES5.
222 *
223 * ## Basic Example
224 *
225 * ```
226 * var Greeter = ng.Class({
227 * constructor: function(name) {
228 * this.name = name;
229 * },
230 *
231 * greet: function() {
232 * alert('Hello ' + this.name + '!');
233 * }
234 * });
235 * ```
236 *
237 * is equivalent to ES6:
238 *
239 * ```
240 * class Greeter {
241 * constructor(name) {
242 * this.name = name;
243 * }
244 *
245 * greet() {
246 * alert('Hello ' + this.name + '!');
247 * }
248 * }
249 * ```
250 *
251 * or equivalent to ES5:
252 *
253 * ```
254 * var Greeter = function (name) {
255 * this.name = name;
256 * }
257 *
258 * Greeter.prototype.greet = function () {
259 * alert('Hello ' + this.name + '!');
260 * }
261 * ```
262 *
263 * ### Example with parameter annotations
264 *
265 * ```
266 * var MyService = ng.Class({
267 * constructor: [String, [new Optional(), Service], function(name, myService) {
268 * ...
269 * }]
270 * });
271 * ```
272 *
273 * is equivalent to ES6:
274 *
275 * ```
276 * class MyService {
277 * constructor(name: string, \@Optional() myService: Service) {
278 * ...
279 * }
280 * }
281 * ```
282 *
283 * ### Example with inheritance
284 *
285 * ```
286 * var Shape = ng.Class({
287 * constructor: (color) {
288 * this.color = color;
289 * }
290 * });
291 *
292 * var Square = ng.Class({
293 * extends: Shape,
294 * constructor: function(color, size) {
295 * Shape.call(this, color);
296 * this.size = size;
297 * }
298 * });
299 * ```
300 * @suppress {globalThis}
301 * \@stable
302 * @param {?} clsDef
303 * @return {?}
304 */
305function Class(clsDef) {
306 const /** @type {?} */ constructor = applyParams(clsDef.hasOwnProperty('constructor') ? clsDef.constructor : undefined, 'constructor');
307 let /** @type {?} */ proto = constructor.prototype;
308 if (clsDef.hasOwnProperty('extends')) {
309 if (typeof clsDef.extends === 'function') {
310 ((constructor)).prototype = proto =
311 Object.create(((clsDef.extends)).prototype);
312 }
313 else {
314 throw new Error(`Class definition 'extends' property must be a constructor function was: ${stringify(clsDef.extends)}`);
315 }
316 }
317 for (const /** @type {?} */ key in clsDef) {
318 if (key !== 'extends' && key !== 'prototype' && clsDef.hasOwnProperty(key)) {
319 proto[key] = applyParams(clsDef[key], key);
320 }
321 }
322 if (this && this.annotations instanceof Array) {
323 Reflect.defineMetadata('annotations', this.annotations, constructor);
324 }
325 const /** @type {?} */ constructorName = constructor['name'];
326 if (!constructorName || constructorName === 'constructor') {
327 ((constructor))['overriddenName'] = `class${_nextClassId++}`;
328 }
329 return (constructor);
330}
331/**
332 * @suppress {globalThis}
333 * @param {?} name
334 * @param {?} props
335 * @param {?=} parentClass
336 * @param {?=} chainFn
337 * @return {?}
338 */
339function makeDecorator(name, props, parentClass, chainFn) {
340 const /** @type {?} */ metaCtor = makeMetadataCtor([props]);
341 /**
342 * @param {?} objOrType
343 * @return {?}
344 */
345 function DecoratorFactory(objOrType) {
346 if (!(Reflect && Reflect.getOwnMetadata)) {
347 throw 'reflect-metadata shim is required when using class decorators';
348 }
349 if (this instanceof DecoratorFactory) {
350 metaCtor.call(this, objOrType);
351 return this;
352 }
353 const /** @type {?} */ annotationInstance = new ((DecoratorFactory))(objOrType);
354 const /** @type {?} */ chainAnnotation = typeof this === 'function' && Array.isArray(this.annotations) ? this.annotations : [];
355 chainAnnotation.push(annotationInstance);
356 const /** @type {?} */ TypeDecorator = (function TypeDecorator(cls) {
357 const /** @type {?} */ annotations = Reflect.getOwnMetadata('annotations', cls) || [];
358 annotations.push(annotationInstance);
359 Reflect.defineMetadata('annotations', annotations, cls);
360 return cls;
361 });
362 TypeDecorator.annotations = chainAnnotation;
363 TypeDecorator.Class = Class;
364 if (chainFn)
365 chainFn(TypeDecorator);
366 return TypeDecorator;
367 }
368 if (parentClass) {
369 DecoratorFactory.prototype = Object.create(parentClass.prototype);
370 }
371 DecoratorFactory.prototype.toString = () => `@${name}`;
372 ((DecoratorFactory)).annotationCls = DecoratorFactory;
373 return DecoratorFactory;
374}
375/**
376 * @param {?} props
377 * @return {?}
378 */
379function makeMetadataCtor(props) {
380 return function ctor(...args) {
381 props.forEach((prop, i) => {
382 const /** @type {?} */ argVal = args[i];
383 if (Array.isArray(prop)) {
384 // plain parameter
385 this[prop[0]] = argVal === undefined ? prop[1] : argVal;
386 }
387 else {
388 for (const /** @type {?} */ propName in prop) {
389 this[propName] =
390 argVal && argVal.hasOwnProperty(propName) ? argVal[propName] : prop[propName];
391 }
392 }
393 });
394 };
395}
396/**
397 * @param {?} name
398 * @param {?} props
399 * @param {?=} parentClass
400 * @return {?}
401 */
402function makeParamDecorator(name, props, parentClass) {
403 const /** @type {?} */ metaCtor = makeMetadataCtor(props);
404 /**
405 * @param {...?} args
406 * @return {?}
407 */
408 function ParamDecoratorFactory(...args) {
409 if (this instanceof ParamDecoratorFactory) {
410 metaCtor.apply(this, args);
411 return this;
412 }
413 const /** @type {?} */ annotationInstance = new ((ParamDecoratorFactory))(...args);
414 ((ParamDecorator)).annotation = annotationInstance;
415 return ParamDecorator;
416 /**
417 * @param {?} cls
418 * @param {?} unusedKey
419 * @param {?} index
420 * @return {?}
421 */
422 function ParamDecorator(cls, unusedKey, index) {
423 const /** @type {?} */ parameters = Reflect.getOwnMetadata('parameters', cls) || [];
424 // there might be gaps if some in between parameters do not have annotations.
425 // we pad with nulls.
426 while (parameters.length <= index) {
427 parameters.push(null);
428 }
429 parameters[index] = parameters[index] || []; /** @type {?} */
430 ((parameters[index])).push(annotationInstance);
431 Reflect.defineMetadata('parameters', parameters, cls);
432 return cls;
433 }
434 }
435 if (parentClass) {
436 ParamDecoratorFactory.prototype = Object.create(parentClass.prototype);
437 }
438 ParamDecoratorFactory.prototype.toString = () => `@${name}`;
439 ((ParamDecoratorFactory)).annotationCls = ParamDecoratorFactory;
440 return ParamDecoratorFactory;
441}
442/**
443 * @param {?} name
444 * @param {?} props
445 * @param {?=} parentClass
446 * @return {?}
447 */
448function makePropDecorator(name, props, parentClass) {
449 const /** @type {?} */ metaCtor = makeMetadataCtor(props);
450 /**
451 * @param {...?} args
452 * @return {?}
453 */
454 function PropDecoratorFactory(...args) {
455 if (this instanceof PropDecoratorFactory) {
456 metaCtor.apply(this, args);
457 return this;
458 }
459 const /** @type {?} */ decoratorInstance = new ((PropDecoratorFactory))(...args);
460 return function PropDecorator(target, name) {
461 const /** @type {?} */ meta = Reflect.getOwnMetadata('propMetadata', target.constructor) || {};
462 meta[name] = meta.hasOwnProperty(name) && meta[name] || [];
463 meta[name].unshift(decoratorInstance);
464 Reflect.defineMetadata('propMetadata', meta, target.constructor);
465 };
466 }
467 if (parentClass) {
468 PropDecoratorFactory.prototype = Object.create(parentClass.prototype);
469 }
470 PropDecoratorFactory.prototype.toString = () => `@${name}`;
471 ((PropDecoratorFactory)).annotationCls = PropDecoratorFactory;
472 return PropDecoratorFactory;
473}
474
475/**
476 * @license
477 * Copyright Google Inc. All Rights Reserved.
478 *
479 * Use of this source code is governed by an MIT-style license that can be
480 * found in the LICENSE file at https://angular.io/license
481 */
482/**
483 * This token can be used to create a virtual provider that will populate the
484 * `entryComponents` fields of components and ng modules based on its `useValue`.
485 * All components that are referenced in the `useValue` value (either directly
486 * or in a nested array or map) will be added to the `entryComponents` property.
487 *
488 * ### Example
489 * The following example shows how the router can populate the `entryComponents`
490 * field of an NgModule based on the router configuration which refers
491 * to components.
492 *
493 * ```typescript
494 * // helper function inside the router
495 * function provideRoutes(routes) {
496 * return [
497 * {provide: ROUTES, useValue: routes},
498 * {provide: ANALYZE_FOR_ENTRY_COMPONENTS, useValue: routes, multi: true}
499 * ];
500 * }
501 *
502 * // user code
503 * let routes = [
504 * {path: '/root', component: RootComp},
505 * {path: '/teams', component: TeamsComp}
506 * ];
507 *
508 * \@NgModule({
509 * providers: [provideRoutes(routes)]
510 * })
511 * class ModuleWithRoutes {}
512 * ```
513 *
514 * \@experimental
515 */
516const ANALYZE_FOR_ENTRY_COMPONENTS = new InjectionToken('AnalyzeForEntryComponents');
517/**
518 * Attribute decorator and metadata.
519 *
520 * \@stable
521 * \@Annotation
522 */
523const Attribute = makeParamDecorator('Attribute', [['attributeName', undefined]]);
524/**
525 * Base class for query metadata.
526 *
527 * See {\@link ContentChildren}, {\@link ContentChild}, {\@link ViewChildren}, {\@link ViewChild} for
528 * more information.
529 *
530 * \@stable
531 * @abstract
532 */
533class Query {
534}
535/**
536 * ContentChildren decorator and metadata.
537 *
538 * \@stable
539 * \@Annotation
540 */
541const ContentChildren = makePropDecorator('ContentChildren', [
542 ['selector', undefined], {
543 first: false,
544 isViewQuery: false,
545 descendants: false,
546 read: undefined,
547 }
548], Query);
549/**
550 * ContentChild decorator and metadata.
551 *
552 * \@stable
553 * \@Annotation
554 */
555const ContentChild = makePropDecorator('ContentChild', [
556 ['selector', undefined], {
557 first: true,
558 isViewQuery: false,
559 descendants: true,
560 read: undefined,
561 }
562], Query);
563/**
564 * ViewChildren decorator and metadata.
565 *
566 * \@stable
567 * \@Annotation
568 */
569const ViewChildren = makePropDecorator('ViewChildren', [
570 ['selector', undefined], {
571 first: false,
572 isViewQuery: true,
573 descendants: true,
574 read: undefined,
575 }
576], Query);
577/**
578 * ViewChild decorator and metadata.
579 *
580 * \@stable
581 * \@Annotation
582 */
583const ViewChild = makePropDecorator('ViewChild', [
584 ['selector', undefined], {
585 first: true,
586 isViewQuery: true,
587 descendants: true,
588 read: undefined,
589 }
590], Query);
591
592let ChangeDetectionStrategy = {};
593ChangeDetectionStrategy.OnPush = 0;
594ChangeDetectionStrategy.Default = 1;
595ChangeDetectionStrategy[ChangeDetectionStrategy.OnPush] = "OnPush";
596ChangeDetectionStrategy[ChangeDetectionStrategy.Default] = "Default";
597let ChangeDetectorStatus = {};
598ChangeDetectorStatus.CheckOnce = 0;
599ChangeDetectorStatus.Checked = 1;
600ChangeDetectorStatus.CheckAlways = 2;
601ChangeDetectorStatus.Detached = 3;
602ChangeDetectorStatus.Errored = 4;
603ChangeDetectorStatus.Destroyed = 5;
604ChangeDetectorStatus[ChangeDetectorStatus.CheckOnce] = "CheckOnce";
605ChangeDetectorStatus[ChangeDetectorStatus.Checked] = "Checked";
606ChangeDetectorStatus[ChangeDetectorStatus.CheckAlways] = "CheckAlways";
607ChangeDetectorStatus[ChangeDetectorStatus.Detached] = "Detached";
608ChangeDetectorStatus[ChangeDetectorStatus.Errored] = "Errored";
609ChangeDetectorStatus[ChangeDetectorStatus.Destroyed] = "Destroyed";
610/**
611 * @param {?} changeDetectionStrategy
612 * @return {?}
613 */
614function isDefaultChangeDetectionStrategy(changeDetectionStrategy) {
615 return changeDetectionStrategy == null ||
616 changeDetectionStrategy === ChangeDetectionStrategy.Default;
617}
618
619/**
620 * @license
621 * Copyright Google Inc. All Rights Reserved.
622 *
623 * Use of this source code is governed by an MIT-style license that can be
624 * found in the LICENSE file at https://angular.io/license
625 */
626/**
627 * Directive decorator and metadata.
628 *
629 * \@stable
630 * \@Annotation
631 */
632const Directive = makeDecorator('Directive', {
633 selector: undefined,
634 inputs: undefined,
635 outputs: undefined,
636 host: undefined,
637 providers: undefined,
638 exportAs: undefined,
639 queries: undefined
640});
641/**
642 * Component decorator and metadata.
643 *
644 * \@stable
645 * \@Annotation
646 */
647const Component = makeDecorator('Component', {
648 selector: undefined,
649 inputs: undefined,
650 outputs: undefined,
651 host: undefined,
652 exportAs: undefined,
653 moduleId: undefined,
654 providers: undefined,
655 viewProviders: undefined,
656 changeDetection: ChangeDetectionStrategy.Default,
657 queries: undefined,
658 templateUrl: undefined,
659 template: undefined,
660 styleUrls: undefined,
661 styles: undefined,
662 animations: undefined,
663 encapsulation: undefined,
664 interpolation: undefined,
665 entryComponents: undefined
666}, Directive);
667/**
668 * Pipe decorator and metadata.
669 *
670 * \@stable
671 * \@Annotation
672 */
673const Pipe = makeDecorator('Pipe', {
674 name: undefined,
675 pure: true,
676});
677/**
678 * Input decorator and metadata.
679 *
680 * \@stable
681 * \@Annotation
682 */
683const Input = makePropDecorator('Input', [['bindingPropertyName', undefined]]);
684/**
685 * Output decorator and metadata.
686 *
687 * \@stable
688 * \@Annotation
689 */
690const Output = makePropDecorator('Output', [['bindingPropertyName', undefined]]);
691/**
692 * HostBinding decorator and metadata.
693 *
694 * \@stable
695 * \@Annotation
696 */
697const HostBinding = makePropDecorator('HostBinding', [['hostPropertyName', undefined]]);
698/**
699 * HostListener decorator and metadata.
700 *
701 * \@stable
702 * \@Annotation
703 */
704const HostListener = makePropDecorator('HostListener', [['eventName', undefined], ['args', []]]);
705
706/**
707 * @license
708 * Copyright Google Inc. All Rights Reserved.
709 *
710 * Use of this source code is governed by an MIT-style license that can be
711 * found in the LICENSE file at https://angular.io/license
712 */
713/**
714 * Defines a schema that will allow:
715 * - any non-Angular elements with a `-` in their name,
716 * - any properties on elements with a `-` in their name which is the common rule for custom
717 * elements.
718 *
719 * \@stable
720 */
721const CUSTOM_ELEMENTS_SCHEMA = {
722 name: 'custom-elements'
723};
724/**
725 * Defines a schema that will allow any property on any element.
726 *
727 * \@experimental
728 */
729const NO_ERRORS_SCHEMA = {
730 name: 'no-errors-schema'
731};
732/**
733 * NgModule decorator and metadata.
734 *
735 * \@stable
736 * \@Annotation
737 */
738const NgModule = makeDecorator('NgModule', {
739 providers: undefined,
740 declarations: undefined,
741 imports: undefined,
742 exports: undefined,
743 entryComponents: undefined,
744 bootstrap: undefined,
745 schemas: undefined,
746 id: undefined,
747});
748
749let ViewEncapsulation = {};
750ViewEncapsulation.Emulated = 0;
751ViewEncapsulation.Native = 1;
752ViewEncapsulation.None = 2;
753ViewEncapsulation[ViewEncapsulation.Emulated] = "Emulated";
754ViewEncapsulation[ViewEncapsulation.Native] = "Native";
755ViewEncapsulation[ViewEncapsulation.None] = "None";
756/**
757 * Metadata properties available for configuring Views.
758 *
759 * For details on the `\@Component` annotation, see {\@link Component}.
760 *
761 * ### Example
762 *
763 * ```
764 * \@Component({
765 * selector: 'greet',
766 * template: 'Hello {{name}}!',
767 * })
768 * class Greet {
769 * name: string;
770 *
771 * constructor() {
772 * this.name = 'World';
773 * }
774 * }
775 * ```
776 *
777 * @deprecated Use Component instead.
778 *
779 * {\@link Component}
780 */
781class ViewMetadata {
782 /**
783 * @param {?=} __0
784 */
785 constructor({ templateUrl, template, encapsulation, styles, styleUrls, animations, interpolation } = {}) {
786 this.templateUrl = templateUrl;
787 this.template = template;
788 this.styleUrls = styleUrls;
789 this.styles = styles;
790 this.encapsulation = encapsulation;
791 this.animations = animations;
792 this.interpolation = interpolation;
793 }
794}
795
796/**
797 * @license
798 * Copyright Google Inc. All Rights Reserved.
799 *
800 * Use of this source code is governed by an MIT-style license that can be
801 * found in the LICENSE file at https://angular.io/license
802 */
803
804/**
805 * \@whatItDoes Represents the version of Angular
806 *
807 * \@stable
808 */
809class Version {
810 /**
811 * @param {?} full
812 */
813 constructor(full) {
814 this.full = full;
815 }
816 /**
817 * @return {?}
818 */
819 get major() { return this.full.split('.')[0]; }
820 /**
821 * @return {?}
822 */
823 get minor() { return this.full.split('.')[1]; }
824 /**
825 * @return {?}
826 */
827 get patch() { return this.full.split('.').slice(2).join('.'); }
828}
829/**
830 * \@stable
831 */
832const VERSION = new Version('4.1.1');
833
834/**
835 * @license
836 * Copyright Google Inc. All Rights Reserved.
837 *
838 * Use of this source code is governed by an MIT-style license that can be
839 * found in the LICENSE file at https://angular.io/license
840 */
841/**
842 * Inject decorator and metadata.
843 *
844 * \@stable
845 * \@Annotation
846 */
847const Inject = makeParamDecorator('Inject', [['token', undefined]]);
848/**
849 * Optional decorator and metadata.
850 *
851 * \@stable
852 * \@Annotation
853 */
854const Optional = makeParamDecorator('Optional', []);
855/**
856 * Injectable decorator and metadata.
857 *
858 * \@stable
859 * \@Annotation
860 */
861const Injectable = makeDecorator('Injectable', []);
862/**
863 * Self decorator and metadata.
864 *
865 * \@stable
866 * \@Annotation
867 */
868const Self = makeParamDecorator('Self', []);
869/**
870 * SkipSelf decorator and metadata.
871 *
872 * \@stable
873 * \@Annotation
874 */
875const SkipSelf = makeParamDecorator('SkipSelf', []);
876/**
877 * Host decorator and metadata.
878 *
879 * \@stable
880 * \@Annotation
881 */
882const Host = makeParamDecorator('Host', []);
883
884/**
885 * @license
886 * Copyright Google Inc. All Rights Reserved.
887 *
888 * Use of this source code is governed by an MIT-style license that can be
889 * found in the LICENSE file at https://angular.io/license
890 */
891/**
892 * Allows to refer to references which are not yet defined.
893 *
894 * For instance, `forwardRef` is used when the `token` which we need to refer to for the purposes of
895 * DI is declared,
896 * but not yet defined. It is also used when the `token` which we use when creating a query is not
897 * yet defined.
898 *
899 * ### Example
900 * {\@example core/di/ts/forward_ref/forward_ref_spec.ts region='forward_ref'}
901 * \@experimental
902 * @param {?} forwardRefFn
903 * @return {?}
904 */
905function forwardRef(forwardRefFn) {
906 ((forwardRefFn)).__forward_ref__ = forwardRef;
907 ((forwardRefFn)).toString = function () { return stringify(this()); };
908 return (((forwardRefFn)));
909}
910/**
911 * Lazily retrieves the reference value from a forwardRef.
912 *
913 * Acts as the identity function when given a non-forward-ref value.
914 *
915 * ### Example ([live demo](http://plnkr.co/edit/GU72mJrk1fiodChcmiDR?p=preview))
916 *
917 * {\@example core/di/ts/forward_ref/forward_ref_spec.ts region='resolve_forward_ref'}
918 *
919 * See: {\@link forwardRef}
920 * \@experimental
921 * @param {?} type
922 * @return {?}
923 */
924function resolveForwardRef(type) {
925 if (typeof type === 'function' && type.hasOwnProperty('__forward_ref__') &&
926 type.__forward_ref__ === forwardRef) {
927 return ((type))();
928 }
929 else {
930 return type;
931 }
932}
933
934/**
935 * @license
936 * Copyright Google Inc. All Rights Reserved.
937 *
938 * Use of this source code is governed by an MIT-style license that can be
939 * found in the LICENSE file at https://angular.io/license
940 */
941const _THROW_IF_NOT_FOUND = new Object();
942const THROW_IF_NOT_FOUND = _THROW_IF_NOT_FOUND;
943class _NullInjector {
944 /**
945 * @param {?} token
946 * @param {?=} notFoundValue
947 * @return {?}
948 */
949 get(token, notFoundValue = _THROW_IF_NOT_FOUND) {
950 if (notFoundValue === _THROW_IF_NOT_FOUND) {
951 throw new Error(`No provider for ${stringify(token)}!`);
952 }
953 return notFoundValue;
954 }
955}
956/**
957 * \@whatItDoes Injector interface
958 * \@howToUse
959 * ```
960 * const injector: Injector = ...;
961 * injector.get(...);
962 * ```
963 *
964 * \@description
965 * For more details, see the {\@linkDocs guide/dependency-injection "Dependency Injection Guide"}.
966 *
967 * ### Example
968 *
969 * {\@example core/di/ts/injector_spec.ts region='Injector'}
970 *
971 * `Injector` returns itself when given `Injector` as a token:
972 * {\@example core/di/ts/injector_spec.ts region='injectInjector'}
973 *
974 * \@stable
975 * @abstract
976 */
977class Injector {
978 /**
979 * Retrieves an instance from the injector based on the provided token.
980 * If not found:
981 * - Throws an error if no `notFoundValue` that is not equal to
982 * Injector.THROW_IF_NOT_FOUND is given
983 * - Returns the `notFoundValue` otherwise
984 * @abstract
985 * @template T
986 * @param {?} token
987 * @param {?=} notFoundValue
988 * @return {?}
989 */
990 get(token, notFoundValue) { }
991 /**
992 * @deprecated from v4.0.0 use Type<T> or InjectionToken<T>
993 * @suppress {duplicate}
994 * @abstract
995 * @param {?} token
996 * @param {?=} notFoundValue
997 * @return {?}
998 */
999 get(token, notFoundValue) { }
1000}
1001Injector.THROW_IF_NOT_FOUND = _THROW_IF_NOT_FOUND;
1002Injector.NULL = new _NullInjector();
1003
1004/**
1005 * @license
1006 * Copyright Google Inc. All Rights Reserved.
1007 *
1008 * Use of this source code is governed by an MIT-style license that can be
1009 * found in the LICENSE file at https://angular.io/license
1010 */
1011
1012const ERROR_COMPONENT_TYPE = 'ngComponentType';
1013const ERROR_DEBUG_CONTEXT = 'ngDebugContext';
1014const ERROR_ORIGINAL_ERROR = 'ngOriginalError';
1015const ERROR_LOGGER = 'ngErrorLogger';
1016/**
1017 * @param {?} error
1018 * @return {?}
1019 */
1020
1021/**
1022 * @param {?} error
1023 * @return {?}
1024 */
1025function getDebugContext(error) {
1026 return ((error))[ERROR_DEBUG_CONTEXT];
1027}
1028/**
1029 * @param {?} error
1030 * @return {?}
1031 */
1032function getOriginalError(error) {
1033 return ((error))[ERROR_ORIGINAL_ERROR];
1034}
1035/**
1036 * @param {?} error
1037 * @return {?}
1038 */
1039function getErrorLogger(error) {
1040 return ((error))[ERROR_LOGGER] || defaultErrorLogger;
1041}
1042/**
1043 * @param {?} console
1044 * @param {...?} values
1045 * @return {?}
1046 */
1047function defaultErrorLogger(console, ...values) {
1048 ((console.error))(...values);
1049}
1050
1051/**
1052 * @license
1053 * Copyright Google Inc. All Rights Reserved.
1054 *
1055 * Use of this source code is governed by an MIT-style license that can be
1056 * found in the LICENSE file at https://angular.io/license
1057 */
1058/**
1059 * \@whatItDoes Provides a hook for centralized exception handling.
1060 *
1061 * \@description
1062 *
1063 * The default implementation of `ErrorHandler` prints error messages to the `console`. To
1064 * intercept error handling, write a custom exception handler that replaces this default as
1065 * appropriate for your app.
1066 *
1067 * ### Example
1068 *
1069 * ```
1070 * class MyErrorHandler implements ErrorHandler {
1071 * handleError(error) {
1072 * // do something with the exception
1073 * }
1074 * }
1075 *
1076 * \@NgModule({
1077 * providers: [{provide: ErrorHandler, useClass: MyErrorHandler}]
1078 * })
1079 * class MyModule {}
1080 * ```
1081 *
1082 * \@stable
1083 */
1084class ErrorHandler {
1085 /**
1086 * @param {?=} deprecatedParameter
1087 */
1088 constructor(
1089 /**
1090 * @deprecated since v4.0 parameter no longer has an effect, as ErrorHandler will never
1091 * rethrow.
1092 */
1093 deprecatedParameter) {
1094 /**
1095 * \@internal
1096 */
1097 this._console = console;
1098 }
1099 /**
1100 * @param {?} error
1101 * @return {?}
1102 */
1103 handleError(error) {
1104 const /** @type {?} */ originalError = this._findOriginalError(error);
1105 const /** @type {?} */ context = this._findContext(error);
1106 // Note: Browser consoles show the place from where console.error was called.
1107 // We can use this to give users additional information about the error.
1108 const /** @type {?} */ errorLogger = getErrorLogger(error);
1109 errorLogger(this._console, `ERROR`, error);
1110 if (originalError) {
1111 errorLogger(this._console, `ORIGINAL ERROR`, originalError);
1112 }
1113 if (context) {
1114 errorLogger(this._console, 'ERROR CONTEXT', context);
1115 }
1116 }
1117 /**
1118 * \@internal
1119 * @param {?} error
1120 * @return {?}
1121 */
1122 _findContext(error) {
1123 if (error) {
1124 return getDebugContext(error) ? getDebugContext(error) :
1125 this._findContext(getOriginalError(error));
1126 }
1127 return null;
1128 }
1129 /**
1130 * \@internal
1131 * @param {?} error
1132 * @return {?}
1133 */
1134 _findOriginalError(error) {
1135 let /** @type {?} */ e = getOriginalError(error);
1136 while (e && getOriginalError(e)) {
1137 e = getOriginalError(e);
1138 }
1139 return e;
1140 }
1141}
1142/**
1143 * @param {?} message
1144 * @param {?} originalError
1145 * @return {?}
1146 */
1147function wrappedError(message, originalError) {
1148 const /** @type {?} */ msg = `${message} caused by: ${originalError instanceof Error ? originalError.message : originalError}`;
1149 const /** @type {?} */ error = Error(msg);
1150 ((error))[ERROR_ORIGINAL_ERROR] = originalError;
1151 return error;
1152}
1153
1154/**
1155 * @license
1156 * Copyright Google Inc. All Rights Reserved.
1157 *
1158 * Use of this source code is governed by an MIT-style license that can be
1159 * found in the LICENSE file at https://angular.io/license
1160 */
1161/**
1162 * @param {?} keys
1163 * @return {?}
1164 */
1165function findFirstClosedCycle(keys) {
1166 const /** @type {?} */ res = [];
1167 for (let /** @type {?} */ i = 0; i < keys.length; ++i) {
1168 if (res.indexOf(keys[i]) > -1) {
1169 res.push(keys[i]);
1170 return res;
1171 }
1172 res.push(keys[i]);
1173 }
1174 return res;
1175}
1176/**
1177 * @param {?} keys
1178 * @return {?}
1179 */
1180function constructResolvingPath(keys) {
1181 if (keys.length > 1) {
1182 const /** @type {?} */ reversed = findFirstClosedCycle(keys.slice().reverse());
1183 const /** @type {?} */ tokenStrs = reversed.map(k => stringify(k.token));
1184 return ' (' + tokenStrs.join(' -> ') + ')';
1185 }
1186 return '';
1187}
1188/**
1189 * @param {?} injector
1190 * @param {?} key
1191 * @param {?} constructResolvingMessage
1192 * @param {?=} originalError
1193 * @return {?}
1194 */
1195function injectionError(injector, key, constructResolvingMessage, originalError) {
1196 const /** @type {?} */ error = ((originalError ? wrappedError('', originalError) : Error()));
1197 error.addKey = addKey;
1198 error.keys = [key];
1199 error.injectors = [injector];
1200 error.constructResolvingMessage = constructResolvingMessage;
1201 error.message = error.constructResolvingMessage();
1202 ((error))[ERROR_ORIGINAL_ERROR] = originalError;
1203 return error;
1204}
1205/**
1206 * @this {?}
1207 * @param {?} injector
1208 * @param {?} key
1209 * @return {?}
1210 */
1211function addKey(injector, key) {
1212 this.injectors.push(injector);
1213 this.keys.push(key);
1214 this.message = this.constructResolvingMessage();
1215}
1216/**
1217 * Thrown when trying to retrieve a dependency by key from {\@link Injector}, but the
1218 * {\@link Injector} does not have a {\@link Provider} for the given key.
1219 *
1220 * ### Example ([live demo](http://plnkr.co/edit/vq8D3FRB9aGbnWJqtEPE?p=preview))
1221 *
1222 * ```typescript
1223 * class A {
1224 * constructor(b:B) {}
1225 * }
1226 *
1227 * expect(() => Injector.resolveAndCreate([A])).toThrowError();
1228 * ```
1229 * @param {?} injector
1230 * @param {?} key
1231 * @return {?}
1232 */
1233function noProviderError(injector, key) {
1234 return injectionError(injector, key, function () {
1235 const /** @type {?} */ first = stringify(this.keys[0].token);
1236 return `No provider for ${first}!${constructResolvingPath(this.keys)}`;
1237 });
1238}
1239/**
1240 * Thrown when dependencies form a cycle.
1241 *
1242 * ### Example ([live demo](http://plnkr.co/edit/wYQdNos0Tzql3ei1EV9j?p=info))
1243 *
1244 * ```typescript
1245 * var injector = Injector.resolveAndCreate([
1246 * {provide: "one", useFactory: (two) => "two", deps: [[new Inject("two")]]},
1247 * {provide: "two", useFactory: (one) => "one", deps: [[new Inject("one")]]}
1248 * ]);
1249 *
1250 * expect(() => injector.get("one")).toThrowError();
1251 * ```
1252 *
1253 * Retrieving `A` or `B` throws a `CyclicDependencyError` as the graph above cannot be constructed.
1254 * @param {?} injector
1255 * @param {?} key
1256 * @return {?}
1257 */
1258function cyclicDependencyError(injector, key) {
1259 return injectionError(injector, key, function () {
1260 return `Cannot instantiate cyclic dependency!${constructResolvingPath(this.keys)}`;
1261 });
1262}
1263/**
1264 * Thrown when a constructing type returns with an Error.
1265 *
1266 * The `InstantiationError` class contains the original error plus the dependency graph which caused
1267 * this object to be instantiated.
1268 *
1269 * ### Example ([live demo](http://plnkr.co/edit/7aWYdcqTQsP0eNqEdUAf?p=preview))
1270 *
1271 * ```typescript
1272 * class A {
1273 * constructor() {
1274 * throw new Error('message');
1275 * }
1276 * }
1277 *
1278 * var injector = Injector.resolveAndCreate([A]);
1279 * try {
1280 * injector.get(A);
1281 * } catch (e) {
1282 * expect(e instanceof InstantiationError).toBe(true);
1283 * expect(e.originalException.message).toEqual("message");
1284 * expect(e.originalStack).toBeDefined();
1285 * }
1286 * ```
1287 * @param {?} injector
1288 * @param {?} originalException
1289 * @param {?} originalStack
1290 * @param {?} key
1291 * @return {?}
1292 */
1293function instantiationError(injector, originalException, originalStack, key) {
1294 return injectionError(injector, key, function () {
1295 const /** @type {?} */ first = stringify(this.keys[0].token);
1296 return `${getOriginalError(this).message}: Error during instantiation of ${first}!${constructResolvingPath(this.keys)}.`;
1297 }, originalException);
1298}
1299/**
1300 * Thrown when an object other then {\@link Provider} (or `Type`) is passed to {\@link Injector}
1301 * creation.
1302 *
1303 * ### Example ([live demo](http://plnkr.co/edit/YatCFbPAMCL0JSSQ4mvH?p=preview))
1304 *
1305 * ```typescript
1306 * expect(() => Injector.resolveAndCreate(["not a type"])).toThrowError();
1307 * ```
1308 * @param {?} provider
1309 * @return {?}
1310 */
1311function invalidProviderError(provider) {
1312 return Error(`Invalid provider - only instances of Provider and Type are allowed, got: ${provider}`);
1313}
1314/**
1315 * Thrown when the class has no annotation information.
1316 *
1317 * Lack of annotation information prevents the {\@link Injector} from determining which dependencies
1318 * need to be injected into the constructor.
1319 *
1320 * ### Example ([live demo](http://plnkr.co/edit/rHnZtlNS7vJOPQ6pcVkm?p=preview))
1321 *
1322 * ```typescript
1323 * class A {
1324 * constructor(b) {}
1325 * }
1326 *
1327 * expect(() => Injector.resolveAndCreate([A])).toThrowError();
1328 * ```
1329 *
1330 * This error is also thrown when the class not marked with {\@link Injectable} has parameter types.
1331 *
1332 * ```typescript
1333 * class B {}
1334 *
1335 * class A {
1336 * constructor(b:B) {} // no information about the parameter types of A is available at runtime.
1337 * }
1338 *
1339 * expect(() => Injector.resolveAndCreate([A,B])).toThrowError();
1340 * ```
1341 * \@stable
1342 * @param {?} typeOrFunc
1343 * @param {?} params
1344 * @return {?}
1345 */
1346function noAnnotationError(typeOrFunc, params) {
1347 const /** @type {?} */ signature = [];
1348 for (let /** @type {?} */ i = 0, /** @type {?} */ ii = params.length; i < ii; i++) {
1349 const /** @type {?} */ parameter = params[i];
1350 if (!parameter || parameter.length == 0) {
1351 signature.push('?');
1352 }
1353 else {
1354 signature.push(parameter.map(stringify).join(' '));
1355 }
1356 }
1357 return Error('Cannot resolve all parameters for \'' + stringify(typeOrFunc) + '\'(' +
1358 signature.join(', ') + '). ' +
1359 'Make sure that all the parameters are decorated with Inject or have valid type annotations and that \'' +
1360 stringify(typeOrFunc) + '\' is decorated with Injectable.');
1361}
1362/**
1363 * Thrown when getting an object by index.
1364 *
1365 * ### Example ([live demo](http://plnkr.co/edit/bRs0SX2OTQiJzqvjgl8P?p=preview))
1366 *
1367 * ```typescript
1368 * class A {}
1369 *
1370 * var injector = Injector.resolveAndCreate([A]);
1371 *
1372 * expect(() => injector.getAt(100)).toThrowError();
1373 * ```
1374 * \@stable
1375 * @param {?} index
1376 * @return {?}
1377 */
1378function outOfBoundsError(index) {
1379 return Error(`Index ${index} is out-of-bounds.`);
1380}
1381/**
1382 * Thrown when a multi provider and a regular provider are bound to the same token.
1383 *
1384 * ### Example
1385 *
1386 * ```typescript
1387 * expect(() => Injector.resolveAndCreate([
1388 * { provide: "Strings", useValue: "string1", multi: true},
1389 * { provide: "Strings", useValue: "string2", multi: false}
1390 * ])).toThrowError();
1391 * ```
1392 * @param {?} provider1
1393 * @param {?} provider2
1394 * @return {?}
1395 */
1396function mixingMultiProvidersWithRegularProvidersError(provider1, provider2) {
1397 return Error(`Cannot mix multi providers and regular providers, got: ${provider1} ${provider2}`);
1398}
1399
1400/**
1401 * @license
1402 * Copyright Google Inc. All Rights Reserved.
1403 *
1404 * Use of this source code is governed by an MIT-style license that can be
1405 * found in the LICENSE file at https://angular.io/license
1406 */
1407/**
1408 * A unique object used for retrieving items from the {\@link ReflectiveInjector}.
1409 *
1410 * Keys have:
1411 * - a system-wide unique `id`.
1412 * - a `token`.
1413 *
1414 * `Key` is used internally by {\@link ReflectiveInjector} because its system-wide unique `id` allows
1415 * the
1416 * injector to store created objects in a more efficient way.
1417 *
1418 * `Key` should not be created directly. {\@link ReflectiveInjector} creates keys automatically when
1419 * resolving
1420 * providers.
1421 * \@experimental
1422 */
1423class ReflectiveKey {
1424 /**
1425 * Private
1426 * @param {?} token
1427 * @param {?} id
1428 */
1429 constructor(token, id) {
1430 this.token = token;
1431 this.id = id;
1432 if (!token) {
1433 throw new Error('Token must be defined!');
1434 }
1435 }
1436 /**
1437 * Returns a stringified token.
1438 * @return {?}
1439 */
1440 get displayName() { return stringify(this.token); }
1441 /**
1442 * Retrieves a `Key` for a token.
1443 * @param {?} token
1444 * @return {?}
1445 */
1446 static get(token) {
1447 return _globalKeyRegistry.get(resolveForwardRef(token));
1448 }
1449 /**
1450 * @return {?} the number of keys registered in the system.
1451 */
1452 static get numberOfKeys() { return _globalKeyRegistry.numberOfKeys; }
1453}
1454/**
1455 * \@internal
1456 */
1457class KeyRegistry {
1458 constructor() {
1459 this._allKeys = new Map();
1460 }
1461 /**
1462 * @param {?} token
1463 * @return {?}
1464 */
1465 get(token) {
1466 if (token instanceof ReflectiveKey)
1467 return token;
1468 if (this._allKeys.has(token)) {
1469 return ((this._allKeys.get(token)));
1470 }
1471 const /** @type {?} */ newKey = new ReflectiveKey(token, ReflectiveKey.numberOfKeys);
1472 this._allKeys.set(token, newKey);
1473 return newKey;
1474 }
1475 /**
1476 * @return {?}
1477 */
1478 get numberOfKeys() { return this._allKeys.size; }
1479}
1480const _globalKeyRegistry = new KeyRegistry();
1481
1482/**
1483 * \@whatItDoes Represents a type that a Component or other object is instances of.
1484 *
1485 * \@description
1486 *
1487 * An example of a `Type` is `MyCustomComponent` class, which in JavaScript is be represented by
1488 * the `MyCustomComponent` constructor function.
1489 *
1490 * \@stable
1491 */
1492const Type = Function;
1493/**
1494 * @param {?} v
1495 * @return {?}
1496 */
1497function isType(v) {
1498 return typeof v === 'function';
1499}
1500
1501/**
1502 * @license
1503 * Copyright Google Inc. All Rights Reserved.
1504 *
1505 * Use of this source code is governed by an MIT-style license that can be
1506 * found in the LICENSE file at https://angular.io/license
1507 */
1508/**
1509 * Attention: This regex has to hold even if the code is minified!
1510 */
1511const DELEGATE_CTOR = /^function\s+\S+\(\)\s*{[\s\S]+\.apply\(this,\s*arguments\)/;
1512class ReflectionCapabilities {
1513 /**
1514 * @param {?=} reflect
1515 */
1516 constructor(reflect) { this._reflect = reflect || _global['Reflect']; }
1517 /**
1518 * @return {?}
1519 */
1520 isReflectionEnabled() { return true; }
1521 /**
1522 * @template T
1523 * @param {?} t
1524 * @return {?}
1525 */
1526 factory(t) { return (...args) => new t(...args); }
1527 /**
1528 * \@internal
1529 * @param {?} paramTypes
1530 * @param {?} paramAnnotations
1531 * @return {?}
1532 */
1533 _zipTypesAndAnnotations(paramTypes, paramAnnotations) {
1534 let /** @type {?} */ result;
1535 if (typeof paramTypes === 'undefined') {
1536 result = new Array(paramAnnotations.length);
1537 }
1538 else {
1539 result = new Array(paramTypes.length);
1540 }
1541 for (let /** @type {?} */ i = 0; i < result.length; i++) {
1542 // TS outputs Object for parameters without types, while Traceur omits
1543 // the annotations. For now we preserve the Traceur behavior to aid
1544 // migration, but this can be revisited.
1545 if (typeof paramTypes === 'undefined') {
1546 result[i] = [];
1547 }
1548 else if (paramTypes[i] != Object) {
1549 result[i] = [paramTypes[i]];
1550 }
1551 else {
1552 result[i] = [];
1553 }
1554 if (paramAnnotations && paramAnnotations[i] != null) {
1555 result[i] = result[i].concat(paramAnnotations[i]);
1556 }
1557 }
1558 return result;
1559 }
1560 /**
1561 * @param {?} type
1562 * @param {?} parentCtor
1563 * @return {?}
1564 */
1565 _ownParameters(type, parentCtor) {
1566 // If we have no decorators, we only have function.length as metadata.
1567 // In that case, to detect whether a child class declared an own constructor or not,
1568 // we need to look inside of that constructor to check whether it is
1569 // just calling the parent.
1570 // This also helps to work around for https://github.com/Microsoft/TypeScript/issues/12439
1571 // that sets 'design:paramtypes' to []
1572 // if a class inherits from another class but has no ctor declared itself.
1573 if (DELEGATE_CTOR.exec(type.toString())) {
1574 return null;
1575 }
1576 // Prefer the direct API.
1577 if (((type)).parameters && ((type)).parameters !== parentCtor.parameters) {
1578 return ((type)).parameters;
1579 }
1580 // API of tsickle for lowering decorators to properties on the class.
1581 const /** @type {?} */ tsickleCtorParams = ((type)).ctorParameters;
1582 if (tsickleCtorParams && tsickleCtorParams !== parentCtor.ctorParameters) {
1583 // Newer tsickle uses a function closure
1584 // Retain the non-function case for compatibility with older tsickle
1585 const /** @type {?} */ ctorParameters = typeof tsickleCtorParams === 'function' ? tsickleCtorParams() : tsickleCtorParams;
1586 const /** @type {?} */ paramTypes = ctorParameters.map((ctorParam) => ctorParam && ctorParam.type);
1587 const /** @type {?} */ paramAnnotations = ctorParameters.map((ctorParam) => ctorParam && convertTsickleDecoratorIntoMetadata(ctorParam.decorators));
1588 return this._zipTypesAndAnnotations(paramTypes, paramAnnotations);
1589 }
1590 // API for metadata created by invoking the decorators.
1591 if (this._reflect != null && this._reflect.getOwnMetadata != null) {
1592 const /** @type {?} */ paramAnnotations = this._reflect.getOwnMetadata('parameters', type);
1593 const /** @type {?} */ paramTypes = this._reflect.getOwnMetadata('design:paramtypes', type);
1594 if (paramTypes || paramAnnotations) {
1595 return this._zipTypesAndAnnotations(paramTypes, paramAnnotations);
1596 }
1597 }
1598 // If a class has no decorators, at least create metadata
1599 // based on function.length.
1600 // Note: We know that this is a real constructor as we checked
1601 // the content of the constructor above.
1602 return new Array(((type.length))).fill(undefined);
1603 }
1604 /**
1605 * @param {?} type
1606 * @return {?}
1607 */
1608 parameters(type) {
1609 // Note: only report metadata if we have at least one class decorator
1610 // to stay in sync with the static reflector.
1611 if (!isType(type)) {
1612 return [];
1613 }
1614 const /** @type {?} */ parentCtor = getParentCtor(type);
1615 let /** @type {?} */ parameters = this._ownParameters(type, parentCtor);
1616 if (!parameters && parentCtor !== Object) {
1617 parameters = this.parameters(parentCtor);
1618 }
1619 return parameters || [];
1620 }
1621 /**
1622 * @param {?} typeOrFunc
1623 * @param {?} parentCtor
1624 * @return {?}
1625 */
1626 _ownAnnotations(typeOrFunc, parentCtor) {
1627 // Prefer the direct API.
1628 if (((typeOrFunc)).annotations && ((typeOrFunc)).annotations !== parentCtor.annotations) {
1629 let /** @type {?} */ annotations = ((typeOrFunc)).annotations;
1630 if (typeof annotations === 'function' && annotations.annotations) {
1631 annotations = annotations.annotations;
1632 }
1633 return annotations;
1634 }
1635 // API of tsickle for lowering decorators to properties on the class.
1636 if (((typeOrFunc)).decorators && ((typeOrFunc)).decorators !== parentCtor.decorators) {
1637 return convertTsickleDecoratorIntoMetadata(((typeOrFunc)).decorators);
1638 }
1639 // API for metadata created by invoking the decorators.
1640 if (this._reflect && this._reflect.getOwnMetadata) {
1641 return this._reflect.getOwnMetadata('annotations', typeOrFunc);
1642 }
1643 return null;
1644 }
1645 /**
1646 * @param {?} typeOrFunc
1647 * @return {?}
1648 */
1649 annotations(typeOrFunc) {
1650 if (!isType(typeOrFunc)) {
1651 return [];
1652 }
1653 const /** @type {?} */ parentCtor = getParentCtor(typeOrFunc);
1654 const /** @type {?} */ ownAnnotations = this._ownAnnotations(typeOrFunc, parentCtor) || [];
1655 const /** @type {?} */ parentAnnotations = parentCtor !== Object ? this.annotations(parentCtor) : [];
1656 return parentAnnotations.concat(ownAnnotations);
1657 }
1658 /**
1659 * @param {?} typeOrFunc
1660 * @param {?} parentCtor
1661 * @return {?}
1662 */
1663 _ownPropMetadata(typeOrFunc, parentCtor) {
1664 // Prefer the direct API.
1665 if (((typeOrFunc)).propMetadata &&
1666 ((typeOrFunc)).propMetadata !== parentCtor.propMetadata) {
1667 let /** @type {?} */ propMetadata = ((typeOrFunc)).propMetadata;
1668 if (typeof propMetadata === 'function' && propMetadata.propMetadata) {
1669 propMetadata = propMetadata.propMetadata;
1670 }
1671 return propMetadata;
1672 }
1673 // API of tsickle for lowering decorators to properties on the class.
1674 if (((typeOrFunc)).propDecorators &&
1675 ((typeOrFunc)).propDecorators !== parentCtor.propDecorators) {
1676 const /** @type {?} */ propDecorators = ((typeOrFunc)).propDecorators;
1677 const /** @type {?} */ propMetadata = ({});
1678 Object.keys(propDecorators).forEach(prop => {
1679 propMetadata[prop] = convertTsickleDecoratorIntoMetadata(propDecorators[prop]);
1680 });
1681 return propMetadata;
1682 }
1683 // API for metadata created by invoking the decorators.
1684 if (this._reflect && this._reflect.getOwnMetadata) {
1685 return this._reflect.getOwnMetadata('propMetadata', typeOrFunc);
1686 }
1687 return null;
1688 }
1689 /**
1690 * @param {?} typeOrFunc
1691 * @return {?}
1692 */
1693 propMetadata(typeOrFunc) {
1694 if (!isType(typeOrFunc)) {
1695 return {};
1696 }
1697 const /** @type {?} */ parentCtor = getParentCtor(typeOrFunc);
1698 const /** @type {?} */ propMetadata = {};
1699 if (parentCtor !== Object) {
1700 const /** @type {?} */ parentPropMetadata = this.propMetadata(parentCtor);
1701 Object.keys(parentPropMetadata).forEach((propName) => {
1702 propMetadata[propName] = parentPropMetadata[propName];
1703 });
1704 }
1705 const /** @type {?} */ ownPropMetadata = this._ownPropMetadata(typeOrFunc, parentCtor);
1706 if (ownPropMetadata) {
1707 Object.keys(ownPropMetadata).forEach((propName) => {
1708 const /** @type {?} */ decorators = [];
1709 if (propMetadata.hasOwnProperty(propName)) {
1710 decorators.push(...propMetadata[propName]);
1711 }
1712 decorators.push(...ownPropMetadata[propName]);
1713 propMetadata[propName] = decorators;
1714 });
1715 }
1716 return propMetadata;
1717 }
1718 /**
1719 * @param {?} type
1720 * @param {?} lcProperty
1721 * @return {?}
1722 */
1723 hasLifecycleHook(type, lcProperty) {
1724 return type instanceof Type && lcProperty in type.prototype;
1725 }
1726 /**
1727 * @param {?} name
1728 * @return {?}
1729 */
1730 getter(name) { return (new Function('o', 'return o.' + name + ';')); }
1731 /**
1732 * @param {?} name
1733 * @return {?}
1734 */
1735 setter(name) {
1736 return (new Function('o', 'v', 'return o.' + name + ' = v;'));
1737 }
1738 /**
1739 * @param {?} name
1740 * @return {?}
1741 */
1742 method(name) {
1743 const /** @type {?} */ functionBody = `if (!o.${name}) throw new Error('"${name}" is undefined');
1744 return o.${name}.apply(o, args);`;
1745 return (new Function('o', 'args', functionBody));
1746 }
1747 /**
1748 * @param {?} type
1749 * @return {?}
1750 */
1751 importUri(type) {
1752 // StaticSymbol
1753 if (typeof type === 'object' && type['filePath']) {
1754 return type['filePath'];
1755 }
1756 // Runtime type
1757 return `./${stringify(type)}`;
1758 }
1759 /**
1760 * @param {?} type
1761 * @return {?}
1762 */
1763 resourceUri(type) { return `./${stringify(type)}`; }
1764 /**
1765 * @param {?} name
1766 * @param {?} moduleUrl
1767 * @param {?} members
1768 * @param {?} runtime
1769 * @return {?}
1770 */
1771 resolveIdentifier(name, moduleUrl, members, runtime) {
1772 return runtime;
1773 }
1774 /**
1775 * @param {?} enumIdentifier
1776 * @param {?} name
1777 * @return {?}
1778 */
1779 resolveEnum(enumIdentifier, name) { return enumIdentifier[name]; }
1780}
1781/**
1782 * @param {?} decoratorInvocations
1783 * @return {?}
1784 */
1785function convertTsickleDecoratorIntoMetadata(decoratorInvocations) {
1786 if (!decoratorInvocations) {
1787 return [];
1788 }
1789 return decoratorInvocations.map(decoratorInvocation => {
1790 const /** @type {?} */ decoratorType = decoratorInvocation.type;
1791 const /** @type {?} */ annotationCls = decoratorType.annotationCls;
1792 const /** @type {?} */ annotationArgs = decoratorInvocation.args ? decoratorInvocation.args : [];
1793 return new annotationCls(...annotationArgs);
1794 });
1795}
1796/**
1797 * @param {?} ctor
1798 * @return {?}
1799 */
1800function getParentCtor(ctor) {
1801 const /** @type {?} */ parentProto = Object.getPrototypeOf(ctor.prototype);
1802 const /** @type {?} */ parentCtor = parentProto ? parentProto.constructor : null;
1803 // Note: We always use `Object` as the null value
1804 // to simplify checking later on.
1805 return parentCtor || Object;
1806}
1807
1808/**
1809 * Provides read-only access to reflection data about symbols. Used internally by Angular
1810 * to power dependency injection and compilation.
1811 * @abstract
1812 */
1813class ReflectorReader {
1814 /**
1815 * @abstract
1816 * @param {?} typeOrFunc
1817 * @return {?}
1818 */
1819 parameters(typeOrFunc) { }
1820 /**
1821 * @abstract
1822 * @param {?} typeOrFunc
1823 * @return {?}
1824 */
1825 annotations(typeOrFunc) { }
1826 /**
1827 * @abstract
1828 * @param {?} typeOrFunc
1829 * @return {?}
1830 */
1831 propMetadata(typeOrFunc) { }
1832 /**
1833 * @abstract
1834 * @param {?} typeOrFunc
1835 * @return {?}
1836 */
1837 importUri(typeOrFunc) { }
1838 /**
1839 * @abstract
1840 * @param {?} typeOrFunc
1841 * @return {?}
1842 */
1843 resourceUri(typeOrFunc) { }
1844 /**
1845 * @abstract
1846 * @param {?} name
1847 * @param {?} moduleUrl
1848 * @param {?} members
1849 * @param {?} runtime
1850 * @return {?}
1851 */
1852 resolveIdentifier(name, moduleUrl, members, runtime) { }
1853 /**
1854 * @abstract
1855 * @param {?} identifier
1856 * @param {?} name
1857 * @return {?}
1858 */
1859 resolveEnum(identifier, name) { }
1860}
1861
1862/**
1863 * @license
1864 * Copyright Google Inc. All Rights Reserved.
1865 *
1866 * Use of this source code is governed by an MIT-style license that can be
1867 * found in the LICENSE file at https://angular.io/license
1868 */
1869/**
1870 * Provides access to reflection data about symbols. Used internally by Angular
1871 * to power dependency injection and compilation.
1872 */
1873class Reflector extends ReflectorReader {
1874 /**
1875 * @param {?} reflectionCapabilities
1876 */
1877 constructor(reflectionCapabilities) {
1878 super();
1879 this.reflectionCapabilities = reflectionCapabilities;
1880 }
1881 /**
1882 * @param {?} caps
1883 * @return {?}
1884 */
1885 updateCapabilities(caps) { this.reflectionCapabilities = caps; }
1886 /**
1887 * @param {?} type
1888 * @return {?}
1889 */
1890 factory(type) { return this.reflectionCapabilities.factory(type); }
1891 /**
1892 * @param {?} typeOrFunc
1893 * @return {?}
1894 */
1895 parameters(typeOrFunc) {
1896 return this.reflectionCapabilities.parameters(typeOrFunc);
1897 }
1898 /**
1899 * @param {?} typeOrFunc
1900 * @return {?}
1901 */
1902 annotations(typeOrFunc) {
1903 return this.reflectionCapabilities.annotations(typeOrFunc);
1904 }
1905 /**
1906 * @param {?} typeOrFunc
1907 * @return {?}
1908 */
1909 propMetadata(typeOrFunc) {
1910 return this.reflectionCapabilities.propMetadata(typeOrFunc);
1911 }
1912 /**
1913 * @param {?} type
1914 * @param {?} lcProperty
1915 * @return {?}
1916 */
1917 hasLifecycleHook(type, lcProperty) {
1918 return this.reflectionCapabilities.hasLifecycleHook(type, lcProperty);
1919 }
1920 /**
1921 * @param {?} name
1922 * @return {?}
1923 */
1924 getter(name) { return this.reflectionCapabilities.getter(name); }
1925 /**
1926 * @param {?} name
1927 * @return {?}
1928 */
1929 setter(name) { return this.reflectionCapabilities.setter(name); }
1930 /**
1931 * @param {?} name
1932 * @return {?}
1933 */
1934 method(name) { return this.reflectionCapabilities.method(name); }
1935 /**
1936 * @param {?} type
1937 * @return {?}
1938 */
1939 importUri(type) { return this.reflectionCapabilities.importUri(type); }
1940 /**
1941 * @param {?} type
1942 * @return {?}
1943 */
1944 resourceUri(type) { return this.reflectionCapabilities.resourceUri(type); }
1945 /**
1946 * @param {?} name
1947 * @param {?} moduleUrl
1948 * @param {?} members
1949 * @param {?} runtime
1950 * @return {?}
1951 */
1952 resolveIdentifier(name, moduleUrl, members, runtime) {
1953 return this.reflectionCapabilities.resolveIdentifier(name, moduleUrl, members, runtime);
1954 }
1955 /**
1956 * @param {?} identifier
1957 * @param {?} name
1958 * @return {?}
1959 */
1960 resolveEnum(identifier, name) {
1961 return this.reflectionCapabilities.resolveEnum(identifier, name);
1962 }
1963}
1964
1965/**
1966 * @license
1967 * Copyright Google Inc. All Rights Reserved.
1968 *
1969 * Use of this source code is governed by an MIT-style license that can be
1970 * found in the LICENSE file at https://angular.io/license
1971 */
1972/**
1973 * The {@link Reflector} used internally in Angular to access metadata
1974 * about symbols.
1975 */
1976const reflector = new Reflector(new ReflectionCapabilities());
1977
1978/**
1979 * @license
1980 * Copyright Google Inc. All Rights Reserved.
1981 *
1982 * Use of this source code is governed by an MIT-style license that can be
1983 * found in the LICENSE file at https://angular.io/license
1984 */
1985/**
1986 * `Dependency` is used by the framework to extend DI.
1987 * This is internal to Angular and should not be used directly.
1988 */
1989class ReflectiveDependency {
1990 /**
1991 * @param {?} key
1992 * @param {?} optional
1993 * @param {?} visibility
1994 */
1995 constructor(key, optional, visibility) {
1996 this.key = key;
1997 this.optional = optional;
1998 this.visibility = visibility;
1999 }
2000 /**
2001 * @param {?} key
2002 * @return {?}
2003 */
2004 static fromKey(key) {
2005 return new ReflectiveDependency(key, false, null);
2006 }
2007}
2008const _EMPTY_LIST = [];
2009class ResolvedReflectiveProvider_ {
2010 /**
2011 * @param {?} key
2012 * @param {?} resolvedFactories
2013 * @param {?} multiProvider
2014 */
2015 constructor(key, resolvedFactories, multiProvider) {
2016 this.key = key;
2017 this.resolvedFactories = resolvedFactories;
2018 this.multiProvider = multiProvider;
2019 }
2020 /**
2021 * @return {?}
2022 */
2023 get resolvedFactory() { return this.resolvedFactories[0]; }
2024}
2025/**
2026 * An internal resolved representation of a factory function created by resolving {\@link
2027 * Provider}.
2028 * \@experimental
2029 */
2030class ResolvedReflectiveFactory {
2031 /**
2032 * @param {?} factory
2033 * @param {?} dependencies
2034 */
2035 constructor(factory, dependencies) {
2036 this.factory = factory;
2037 this.dependencies = dependencies;
2038 }
2039}
2040/**
2041 * Resolve a single provider.
2042 * @param {?} provider
2043 * @return {?}
2044 */
2045function resolveReflectiveFactory(provider) {
2046 let /** @type {?} */ factoryFn;
2047 let /** @type {?} */ resolvedDeps;
2048 if (provider.useClass) {
2049 const /** @type {?} */ useClass = resolveForwardRef(provider.useClass);
2050 factoryFn = reflector.factory(useClass);
2051 resolvedDeps = _dependenciesFor(useClass);
2052 }
2053 else if (provider.useExisting) {
2054 factoryFn = (aliasInstance) => aliasInstance;
2055 resolvedDeps = [ReflectiveDependency.fromKey(ReflectiveKey.get(provider.useExisting))];
2056 }
2057 else if (provider.useFactory) {
2058 factoryFn = provider.useFactory;
2059 resolvedDeps = constructDependencies(provider.useFactory, provider.deps);
2060 }
2061 else {
2062 factoryFn = () => provider.useValue;
2063 resolvedDeps = _EMPTY_LIST;
2064 }
2065 return new ResolvedReflectiveFactory(factoryFn, resolvedDeps);
2066}
2067/**
2068 * Converts the {\@link Provider} into {\@link ResolvedProvider}.
2069 *
2070 * {\@link Injector} internally only uses {\@link ResolvedProvider}, {\@link Provider} contains
2071 * convenience provider syntax.
2072 * @param {?} provider
2073 * @return {?}
2074 */
2075function resolveReflectiveProvider(provider) {
2076 return new ResolvedReflectiveProvider_(ReflectiveKey.get(provider.provide), [resolveReflectiveFactory(provider)], provider.multi || false);
2077}
2078/**
2079 * Resolve a list of Providers.
2080 * @param {?} providers
2081 * @return {?}
2082 */
2083function resolveReflectiveProviders(providers) {
2084 const /** @type {?} */ normalized = _normalizeProviders(providers, []);
2085 const /** @type {?} */ resolved = normalized.map(resolveReflectiveProvider);
2086 const /** @type {?} */ resolvedProviderMap = mergeResolvedReflectiveProviders(resolved, new Map());
2087 return Array.from(resolvedProviderMap.values());
2088}
2089/**
2090 * Merges a list of ResolvedProviders into a list where
2091 * each key is contained exactly once and multi providers
2092 * have been merged.
2093 * @param {?} providers
2094 * @param {?} normalizedProvidersMap
2095 * @return {?}
2096 */
2097function mergeResolvedReflectiveProviders(providers, normalizedProvidersMap) {
2098 for (let /** @type {?} */ i = 0; i < providers.length; i++) {
2099 const /** @type {?} */ provider = providers[i];
2100 const /** @type {?} */ existing = normalizedProvidersMap.get(provider.key.id);
2101 if (existing) {
2102 if (provider.multiProvider !== existing.multiProvider) {
2103 throw mixingMultiProvidersWithRegularProvidersError(existing, provider);
2104 }
2105 if (provider.multiProvider) {
2106 for (let /** @type {?} */ j = 0; j < provider.resolvedFactories.length; j++) {
2107 existing.resolvedFactories.push(provider.resolvedFactories[j]);
2108 }
2109 }
2110 else {
2111 normalizedProvidersMap.set(provider.key.id, provider);
2112 }
2113 }
2114 else {
2115 let /** @type {?} */ resolvedProvider;
2116 if (provider.multiProvider) {
2117 resolvedProvider = new ResolvedReflectiveProvider_(provider.key, provider.resolvedFactories.slice(), provider.multiProvider);
2118 }
2119 else {
2120 resolvedProvider = provider;
2121 }
2122 normalizedProvidersMap.set(provider.key.id, resolvedProvider);
2123 }
2124 }
2125 return normalizedProvidersMap;
2126}
2127/**
2128 * @param {?} providers
2129 * @param {?} res
2130 * @return {?}
2131 */
2132function _normalizeProviders(providers, res) {
2133 providers.forEach(b => {
2134 if (b instanceof Type) {
2135 res.push({ provide: b, useClass: b });
2136 }
2137 else if (b && typeof b == 'object' && ((b)).provide !== undefined) {
2138 res.push(/** @type {?} */ (b));
2139 }
2140 else if (b instanceof Array) {
2141 _normalizeProviders(b, res);
2142 }
2143 else {
2144 throw invalidProviderError(b);
2145 }
2146 });
2147 return res;
2148}
2149/**
2150 * @param {?} typeOrFunc
2151 * @param {?=} dependencies
2152 * @return {?}
2153 */
2154function constructDependencies(typeOrFunc, dependencies) {
2155 if (!dependencies) {
2156 return _dependenciesFor(typeOrFunc);
2157 }
2158 else {
2159 const /** @type {?} */ params = dependencies.map(t => [t]);
2160 return dependencies.map(t => _extractToken(typeOrFunc, t, params));
2161 }
2162}
2163/**
2164 * @param {?} typeOrFunc
2165 * @return {?}
2166 */
2167function _dependenciesFor(typeOrFunc) {
2168 const /** @type {?} */ params = reflector.parameters(typeOrFunc);
2169 if (!params)
2170 return [];
2171 if (params.some(p => p == null)) {
2172 throw noAnnotationError(typeOrFunc, params);
2173 }
2174 return params.map(p => _extractToken(typeOrFunc, p, params));
2175}
2176/**
2177 * @param {?} typeOrFunc
2178 * @param {?} metadata
2179 * @param {?} params
2180 * @return {?}
2181 */
2182function _extractToken(typeOrFunc, metadata, params) {
2183 let /** @type {?} */ token = null;
2184 let /** @type {?} */ optional = false;
2185 if (!Array.isArray(metadata)) {
2186 if (metadata instanceof Inject) {
2187 return _createDependency(metadata['token'], optional, null);
2188 }
2189 else {
2190 return _createDependency(metadata, optional, null);
2191 }
2192 }
2193 let /** @type {?} */ visibility = null;
2194 for (let /** @type {?} */ i = 0; i < metadata.length; ++i) {
2195 const /** @type {?} */ paramMetadata = metadata[i];
2196 if (paramMetadata instanceof Type) {
2197 token = paramMetadata;
2198 }
2199 else if (paramMetadata instanceof Inject) {
2200 token = paramMetadata['token'];
2201 }
2202 else if (paramMetadata instanceof Optional) {
2203 optional = true;
2204 }
2205 else if (paramMetadata instanceof Self || paramMetadata instanceof SkipSelf) {
2206 visibility = paramMetadata;
2207 }
2208 else if (paramMetadata instanceof InjectionToken) {
2209 token = paramMetadata;
2210 }
2211 }
2212 token = resolveForwardRef(token);
2213 if (token != null) {
2214 return _createDependency(token, optional, visibility);
2215 }
2216 else {
2217 throw noAnnotationError(typeOrFunc, params);
2218 }
2219}
2220/**
2221 * @param {?} token
2222 * @param {?} optional
2223 * @param {?} visibility
2224 * @return {?}
2225 */
2226function _createDependency(token, optional, visibility) {
2227 return new ReflectiveDependency(ReflectiveKey.get(token), optional, visibility);
2228}
2229
2230/**
2231 * @license
2232 * Copyright Google Inc. All Rights Reserved.
2233 *
2234 * Use of this source code is governed by an MIT-style license that can be
2235 * found in the LICENSE file at https://angular.io/license
2236 */
2237// Threshold for the dynamic version
2238const UNDEFINED = new Object();
2239/**
2240 * A ReflectiveDependency injection container used for instantiating objects and resolving
2241 * dependencies.
2242 *
2243 * An `Injector` is a replacement for a `new` operator, which can automatically resolve the
2244 * constructor dependencies.
2245 *
2246 * In typical use, application code asks for the dependencies in the constructor and they are
2247 * resolved by the `Injector`.
2248 *
2249 * ### Example ([live demo](http://plnkr.co/edit/jzjec0?p=preview))
2250 *
2251 * The following example creates an `Injector` configured to create `Engine` and `Car`.
2252 *
2253 * ```typescript
2254 * \@Injectable()
2255 * class Engine {
2256 * }
2257 *
2258 * \@Injectable()
2259 * class Car {
2260 * constructor(public engine:Engine) {}
2261 * }
2262 *
2263 * var injector = ReflectiveInjector.resolveAndCreate([Car, Engine]);
2264 * var car = injector.get(Car);
2265 * expect(car instanceof Car).toBe(true);
2266 * expect(car.engine instanceof Engine).toBe(true);
2267 * ```
2268 *
2269 * Notice, we don't use the `new` operator because we explicitly want to have the `Injector`
2270 * resolve all of the object's dependencies automatically.
2271 *
2272 * \@stable
2273 * @abstract
2274 */
2275class ReflectiveInjector {
2276 /**
2277 * Turns an array of provider definitions into an array of resolved providers.
2278 *
2279 * A resolution is a process of flattening multiple nested arrays and converting individual
2280 * providers into an array of {\@link ResolvedReflectiveProvider}s.
2281 *
2282 * ### Example ([live demo](http://plnkr.co/edit/AiXTHi?p=preview))
2283 *
2284 * ```typescript
2285 * \@Injectable()
2286 * class Engine {
2287 * }
2288 *
2289 * \@Injectable()
2290 * class Car {
2291 * constructor(public engine:Engine) {}
2292 * }
2293 *
2294 * var providers = ReflectiveInjector.resolve([Car, [[Engine]]]);
2295 *
2296 * expect(providers.length).toEqual(2);
2297 *
2298 * expect(providers[0] instanceof ResolvedReflectiveProvider).toBe(true);
2299 * expect(providers[0].key.displayName).toBe("Car");
2300 * expect(providers[0].dependencies.length).toEqual(1);
2301 * expect(providers[0].factory).toBeDefined();
2302 *
2303 * expect(providers[1].key.displayName).toBe("Engine");
2304 * });
2305 * ```
2306 *
2307 * See {\@link ReflectiveInjector#fromResolvedProviders} for more info.
2308 * @param {?} providers
2309 * @return {?}
2310 */
2311 static resolve(providers) {
2312 return resolveReflectiveProviders(providers);
2313 }
2314 /**
2315 * Resolves an array of providers and creates an injector from those providers.
2316 *
2317 * The passed-in providers can be an array of `Type`, {\@link Provider},
2318 * or a recursive array of more providers.
2319 *
2320 * ### Example ([live demo](http://plnkr.co/edit/ePOccA?p=preview))
2321 *
2322 * ```typescript
2323 * \@Injectable()
2324 * class Engine {
2325 * }
2326 *
2327 * \@Injectable()
2328 * class Car {
2329 * constructor(public engine:Engine) {}
2330 * }
2331 *
2332 * var injector = ReflectiveInjector.resolveAndCreate([Car, Engine]);
2333 * expect(injector.get(Car) instanceof Car).toBe(true);
2334 * ```
2335 *
2336 * This function is slower than the corresponding `fromResolvedProviders`
2337 * because it needs to resolve the passed-in providers first.
2338 * See {\@link Injector#resolve} and {\@link Injector#fromResolvedProviders}.
2339 * @param {?} providers
2340 * @param {?=} parent
2341 * @return {?}
2342 */
2343 static resolveAndCreate(providers, parent) {
2344 const /** @type {?} */ ResolvedReflectiveProviders = ReflectiveInjector.resolve(providers);
2345 return ReflectiveInjector.fromResolvedProviders(ResolvedReflectiveProviders, parent);
2346 }
2347 /**
2348 * Creates an injector from previously resolved providers.
2349 *
2350 * This API is the recommended way to construct injectors in performance-sensitive parts.
2351 *
2352 * ### Example ([live demo](http://plnkr.co/edit/KrSMci?p=preview))
2353 *
2354 * ```typescript
2355 * \@Injectable()
2356 * class Engine {
2357 * }
2358 *
2359 * \@Injectable()
2360 * class Car {
2361 * constructor(public engine:Engine) {}
2362 * }
2363 *
2364 * var providers = ReflectiveInjector.resolve([Car, Engine]);
2365 * var injector = ReflectiveInjector.fromResolvedProviders(providers);
2366 * expect(injector.get(Car) instanceof Car).toBe(true);
2367 * ```
2368 * \@experimental
2369 * @param {?} providers
2370 * @param {?=} parent
2371 * @return {?}
2372 */
2373 static fromResolvedProviders(providers, parent) {
2374 return new ReflectiveInjector_(providers, parent);
2375 }
2376 /**
2377 * Parent of this injector.
2378 *
2379 * <!-- TODO: Add a link to the section of the user guide talking about hierarchical injection.
2380 * -->
2381 *
2382 * ### Example ([live demo](http://plnkr.co/edit/eosMGo?p=preview))
2383 *
2384 * ```typescript
2385 * var parent = ReflectiveInjector.resolveAndCreate([]);
2386 * var child = parent.resolveAndCreateChild([]);
2387 * expect(child.parent).toBe(parent);
2388 * ```
2389 * @abstract
2390 * @return {?}
2391 */
2392 parent() { }
2393 /**
2394 * Resolves an array of providers and creates a child injector from those providers.
2395 *
2396 * <!-- TODO: Add a link to the section of the user guide talking about hierarchical injection.
2397 * -->
2398 *
2399 * The passed-in providers can be an array of `Type`, {\@link Provider},
2400 * or a recursive array of more providers.
2401 *
2402 * ### Example ([live demo](http://plnkr.co/edit/opB3T4?p=preview))
2403 *
2404 * ```typescript
2405 * class ParentProvider {}
2406 * class ChildProvider {}
2407 *
2408 * var parent = ReflectiveInjector.resolveAndCreate([ParentProvider]);
2409 * var child = parent.resolveAndCreateChild([ChildProvider]);
2410 *
2411 * expect(child.get(ParentProvider) instanceof ParentProvider).toBe(true);
2412 * expect(child.get(ChildProvider) instanceof ChildProvider).toBe(true);
2413 * expect(child.get(ParentProvider)).toBe(parent.get(ParentProvider));
2414 * ```
2415 *
2416 * This function is slower than the corresponding `createChildFromResolved`
2417 * because it needs to resolve the passed-in providers first.
2418 * See {\@link Injector#resolve} and {\@link Injector#createChildFromResolved}.
2419 * @abstract
2420 * @param {?} providers
2421 * @return {?}
2422 */
2423 resolveAndCreateChild(providers) { }
2424 /**
2425 * Creates a child injector from previously resolved providers.
2426 *
2427 * <!-- TODO: Add a link to the section of the user guide talking about hierarchical injection.
2428 * -->
2429 *
2430 * This API is the recommended way to construct injectors in performance-sensitive parts.
2431 *
2432 * ### Example ([live demo](http://plnkr.co/edit/VhyfjN?p=preview))
2433 *
2434 * ```typescript
2435 * class ParentProvider {}
2436 * class ChildProvider {}
2437 *
2438 * var parentProviders = ReflectiveInjector.resolve([ParentProvider]);
2439 * var childProviders = ReflectiveInjector.resolve([ChildProvider]);
2440 *
2441 * var parent = ReflectiveInjector.fromResolvedProviders(parentProviders);
2442 * var child = parent.createChildFromResolved(childProviders);
2443 *
2444 * expect(child.get(ParentProvider) instanceof ParentProvider).toBe(true);
2445 * expect(child.get(ChildProvider) instanceof ChildProvider).toBe(true);
2446 * expect(child.get(ParentProvider)).toBe(parent.get(ParentProvider));
2447 * ```
2448 * @abstract
2449 * @param {?} providers
2450 * @return {?}
2451 */
2452 createChildFromResolved(providers) { }
2453 /**
2454 * Resolves a provider and instantiates an object in the context of the injector.
2455 *
2456 * The created object does not get cached by the injector.
2457 *
2458 * ### Example ([live demo](http://plnkr.co/edit/yvVXoB?p=preview))
2459 *
2460 * ```typescript
2461 * \@Injectable()
2462 * class Engine {
2463 * }
2464 *
2465 * \@Injectable()
2466 * class Car {
2467 * constructor(public engine:Engine) {}
2468 * }
2469 *
2470 * var injector = ReflectiveInjector.resolveAndCreate([Engine]);
2471 *
2472 * var car = injector.resolveAndInstantiate(Car);
2473 * expect(car.engine).toBe(injector.get(Engine));
2474 * expect(car).not.toBe(injector.resolveAndInstantiate(Car));
2475 * ```
2476 * @abstract
2477 * @param {?} provider
2478 * @return {?}
2479 */
2480 resolveAndInstantiate(provider) { }
2481 /**
2482 * Instantiates an object using a resolved provider in the context of the injector.
2483 *
2484 * The created object does not get cached by the injector.
2485 *
2486 * ### Example ([live demo](http://plnkr.co/edit/ptCImQ?p=preview))
2487 *
2488 * ```typescript
2489 * \@Injectable()
2490 * class Engine {
2491 * }
2492 *
2493 * \@Injectable()
2494 * class Car {
2495 * constructor(public engine:Engine) {}
2496 * }
2497 *
2498 * var injector = ReflectiveInjector.resolveAndCreate([Engine]);
2499 * var carProvider = ReflectiveInjector.resolve([Car])[0];
2500 * var car = injector.instantiateResolved(carProvider);
2501 * expect(car.engine).toBe(injector.get(Engine));
2502 * expect(car).not.toBe(injector.instantiateResolved(carProvider));
2503 * ```
2504 * @abstract
2505 * @param {?} provider
2506 * @return {?}
2507 */
2508 instantiateResolved(provider) { }
2509 /**
2510 * @abstract
2511 * @param {?} token
2512 * @param {?=} notFoundValue
2513 * @return {?}
2514 */
2515 get(token, notFoundValue) { }
2516}
2517class ReflectiveInjector_ {
2518 /**
2519 * Private
2520 * @param {?} _providers
2521 * @param {?=} _parent
2522 */
2523 constructor(_providers, _parent) {
2524 /**
2525 * \@internal
2526 */
2527 this._constructionCounter = 0;
2528 this._providers = _providers;
2529 this._parent = _parent || null;
2530 const len = _providers.length;
2531 this.keyIds = new Array(len);
2532 this.objs = new Array(len);
2533 for (let i = 0; i < len; i++) {
2534 this.keyIds[i] = _providers[i].key.id;
2535 this.objs[i] = UNDEFINED;
2536 }
2537 }
2538 /**
2539 * @param {?} token
2540 * @param {?=} notFoundValue
2541 * @return {?}
2542 */
2543 get(token, notFoundValue = THROW_IF_NOT_FOUND) {
2544 return this._getByKey(ReflectiveKey.get(token), null, notFoundValue);
2545 }
2546 /**
2547 * @return {?}
2548 */
2549 get parent() { return this._parent; }
2550 /**
2551 * @param {?} providers
2552 * @return {?}
2553 */
2554 resolveAndCreateChild(providers) {
2555 const /** @type {?} */ ResolvedReflectiveProviders = ReflectiveInjector.resolve(providers);
2556 return this.createChildFromResolved(ResolvedReflectiveProviders);
2557 }
2558 /**
2559 * @param {?} providers
2560 * @return {?}
2561 */
2562 createChildFromResolved(providers) {
2563 const /** @type {?} */ inj = new ReflectiveInjector_(providers);
2564 inj._parent = this;
2565 return inj;
2566 }
2567 /**
2568 * @param {?} provider
2569 * @return {?}
2570 */
2571 resolveAndInstantiate(provider) {
2572 return this.instantiateResolved(ReflectiveInjector.resolve([provider])[0]);
2573 }
2574 /**
2575 * @param {?} provider
2576 * @return {?}
2577 */
2578 instantiateResolved(provider) {
2579 return this._instantiateProvider(provider);
2580 }
2581 /**
2582 * @param {?} index
2583 * @return {?}
2584 */
2585 getProviderAtIndex(index) {
2586 if (index < 0 || index >= this._providers.length) {
2587 throw outOfBoundsError(index);
2588 }
2589 return this._providers[index];
2590 }
2591 /**
2592 * \@internal
2593 * @param {?} provider
2594 * @return {?}
2595 */
2596 _new(provider) {
2597 if (this._constructionCounter++ > this._getMaxNumberOfObjects()) {
2598 throw cyclicDependencyError(this, provider.key);
2599 }
2600 return this._instantiateProvider(provider);
2601 }
2602 /**
2603 * @return {?}
2604 */
2605 _getMaxNumberOfObjects() { return this.objs.length; }
2606 /**
2607 * @param {?} provider
2608 * @return {?}
2609 */
2610 _instantiateProvider(provider) {
2611 if (provider.multiProvider) {
2612 const /** @type {?} */ res = new Array(provider.resolvedFactories.length);
2613 for (let /** @type {?} */ i = 0; i < provider.resolvedFactories.length; ++i) {
2614 res[i] = this._instantiate(provider, provider.resolvedFactories[i]);
2615 }
2616 return res;
2617 }
2618 else {
2619 return this._instantiate(provider, provider.resolvedFactories[0]);
2620 }
2621 }
2622 /**
2623 * @param {?} provider
2624 * @param {?} ResolvedReflectiveFactory
2625 * @return {?}
2626 */
2627 _instantiate(provider, ResolvedReflectiveFactory$$1) {
2628 const /** @type {?} */ factory = ResolvedReflectiveFactory$$1.factory;
2629 let /** @type {?} */ deps;
2630 try {
2631 deps =
2632 ResolvedReflectiveFactory$$1.dependencies.map(dep => this._getByReflectiveDependency(dep));
2633 }
2634 catch (e) {
2635 if (e.addKey) {
2636 e.addKey(this, provider.key);
2637 }
2638 throw e;
2639 }
2640 let /** @type {?} */ obj;
2641 try {
2642 obj = factory(...deps);
2643 }
2644 catch (e) {
2645 throw instantiationError(this, e, e.stack, provider.key);
2646 }
2647 return obj;
2648 }
2649 /**
2650 * @param {?} dep
2651 * @return {?}
2652 */
2653 _getByReflectiveDependency(dep) {
2654 return this._getByKey(dep.key, dep.visibility, dep.optional ? null : THROW_IF_NOT_FOUND);
2655 }
2656 /**
2657 * @param {?} key
2658 * @param {?} visibility
2659 * @param {?} notFoundValue
2660 * @return {?}
2661 */
2662 _getByKey(key, visibility, notFoundValue) {
2663 if (key === INJECTOR_KEY) {
2664 return this;
2665 }
2666 if (visibility instanceof Self) {
2667 return this._getByKeySelf(key, notFoundValue);
2668 }
2669 else {
2670 return this._getByKeyDefault(key, notFoundValue, visibility);
2671 }
2672 }
2673 /**
2674 * @param {?} keyId
2675 * @return {?}
2676 */
2677 _getObjByKeyId(keyId) {
2678 for (let /** @type {?} */ i = 0; i < this.keyIds.length; i++) {
2679 if (this.keyIds[i] === keyId) {
2680 if (this.objs[i] === UNDEFINED) {
2681 this.objs[i] = this._new(this._providers[i]);
2682 }
2683 return this.objs[i];
2684 }
2685 }
2686 return UNDEFINED;
2687 }
2688 /**
2689 * \@internal
2690 * @param {?} key
2691 * @param {?} notFoundValue
2692 * @return {?}
2693 */
2694 _throwOrNull(key, notFoundValue) {
2695 if (notFoundValue !== THROW_IF_NOT_FOUND) {
2696 return notFoundValue;
2697 }
2698 else {
2699 throw noProviderError(this, key);
2700 }
2701 }
2702 /**
2703 * \@internal
2704 * @param {?} key
2705 * @param {?} notFoundValue
2706 * @return {?}
2707 */
2708 _getByKeySelf(key, notFoundValue) {
2709 const /** @type {?} */ obj = this._getObjByKeyId(key.id);
2710 return (obj !== UNDEFINED) ? obj : this._throwOrNull(key, notFoundValue);
2711 }
2712 /**
2713 * \@internal
2714 * @param {?} key
2715 * @param {?} notFoundValue
2716 * @param {?} visibility
2717 * @return {?}
2718 */
2719 _getByKeyDefault(key, notFoundValue, visibility) {
2720 let /** @type {?} */ inj;
2721 if (visibility instanceof SkipSelf) {
2722 inj = this._parent;
2723 }
2724 else {
2725 inj = this;
2726 }
2727 while (inj instanceof ReflectiveInjector_) {
2728 const /** @type {?} */ inj_ = (inj);
2729 const /** @type {?} */ obj = inj_._getObjByKeyId(key.id);
2730 if (obj !== UNDEFINED)
2731 return obj;
2732 inj = inj_._parent;
2733 }
2734 if (inj !== null) {
2735 return inj.get(key.token, notFoundValue);
2736 }
2737 else {
2738 return this._throwOrNull(key, notFoundValue);
2739 }
2740 }
2741 /**
2742 * @return {?}
2743 */
2744 get displayName() {
2745 const /** @type {?} */ providers = _mapProviders(this, (b) => ' "' + b.key.displayName + '" ')
2746 .join(', ');
2747 return `ReflectiveInjector(providers: [${providers}])`;
2748 }
2749 /**
2750 * @return {?}
2751 */
2752 toString() { return this.displayName; }
2753}
2754const INJECTOR_KEY = ReflectiveKey.get(Injector);
2755/**
2756 * @param {?} injector
2757 * @param {?} fn
2758 * @return {?}
2759 */
2760function _mapProviders(injector, fn) {
2761 const /** @type {?} */ res = new Array(injector._providers.length);
2762 for (let /** @type {?} */ i = 0; i < injector._providers.length; ++i) {
2763 res[i] = fn(injector.getProviderAtIndex(i));
2764 }
2765 return res;
2766}
2767
2768/**
2769 * @license
2770 * Copyright Google Inc. All Rights Reserved.
2771 *
2772 * Use of this source code is governed by an MIT-style license that can be
2773 * found in the LICENSE file at https://angular.io/license
2774 */
2775/**
2776 * @module
2777 * @description
2778 * The `di` module provides dependency injection container services.
2779 */
2780
2781/**
2782 * @license
2783 * Copyright Google Inc. All Rights Reserved.
2784 *
2785 * Use of this source code is governed by an MIT-style license that can be
2786 * found in the LICENSE file at https://angular.io/license
2787 */
2788/**
2789 * Determine if the argument is shaped like a Promise
2790 * @param {?} obj
2791 * @return {?}
2792 */
2793function isPromise(obj) {
2794 // allow any Promise/A+ compliant thenable.
2795 // It's up to the caller to ensure that obj.then conforms to the spec
2796 return !!obj && typeof obj.then === 'function';
2797}
2798/**
2799 * Determine if the argument is an Observable
2800 * @param {?} obj
2801 * @return {?}
2802 */
2803function isObservable(obj) {
2804 // TODO use Symbol.observable when https://github.com/ReactiveX/rxjs/issues/2415 will be resolved
2805 return !!obj && typeof obj.subscribe === 'function';
2806}
2807
2808/**
2809 * @license
2810 * Copyright Google Inc. All Rights Reserved.
2811 *
2812 * Use of this source code is governed by an MIT-style license that can be
2813 * found in the LICENSE file at https://angular.io/license
2814 */
2815/**
2816 * A function that will be executed when an application is initialized.
2817 * \@experimental
2818 */
2819const APP_INITIALIZER = new InjectionToken('Application Initializer');
2820/**
2821 * A class that reflects the state of running {\@link APP_INITIALIZER}s.
2822 *
2823 * \@experimental
2824 */
2825class ApplicationInitStatus {
2826 /**
2827 * @param {?} appInits
2828 */
2829 constructor(appInits) {
2830 this._done = false;
2831 const asyncInitPromises = [];
2832 if (appInits) {
2833 for (let i = 0; i < appInits.length; i++) {
2834 const initResult = appInits[i]();
2835 if (isPromise(initResult)) {
2836 asyncInitPromises.push(initResult);
2837 }
2838 }
2839 }
2840 this._donePromise = Promise.all(asyncInitPromises).then(() => { this._done = true; });
2841 if (asyncInitPromises.length === 0) {
2842 this._done = true;
2843 }
2844 }
2845 /**
2846 * @return {?}
2847 */
2848 get done() { return this._done; }
2849 /**
2850 * @return {?}
2851 */
2852 get donePromise() { return this._donePromise; }
2853}
2854ApplicationInitStatus.decorators = [
2855 { type: Injectable },
2856];
2857/**
2858 * @nocollapse
2859 */
2860ApplicationInitStatus.ctorParameters = () => [
2861 { type: Array, decorators: [{ type: Inject, args: [APP_INITIALIZER,] }, { type: Optional },] },
2862];
2863
2864/**
2865 * @license
2866 * Copyright Google Inc. All Rights Reserved.
2867 *
2868 * Use of this source code is governed by an MIT-style license that can be
2869 * found in the LICENSE file at https://angular.io/license
2870 */
2871/**
2872 * A DI Token representing a unique string id assigned to the application by Angular and used
2873 * primarily for prefixing application attributes and CSS styles when
2874 * {\@link ViewEncapsulation#Emulated} is being used.
2875 *
2876 * If you need to avoid randomly generated value to be used as an application id, you can provide
2877 * a custom value via a DI provider <!-- TODO: provider --> configuring the root {\@link Injector}
2878 * using this token.
2879 * \@experimental
2880 */
2881const APP_ID = new InjectionToken('AppId');
2882/**
2883 * @return {?}
2884 */
2885function _appIdRandomProviderFactory() {
2886 return `${_randomChar()}${_randomChar()}${_randomChar()}`;
2887}
2888/**
2889 * Providers that will generate a random APP_ID_TOKEN.
2890 * \@experimental
2891 */
2892const APP_ID_RANDOM_PROVIDER = {
2893 provide: APP_ID,
2894 useFactory: _appIdRandomProviderFactory,
2895 deps: [],
2896};
2897/**
2898 * @return {?}
2899 */
2900function _randomChar() {
2901 return String.fromCharCode(97 + Math.floor(Math.random() * 25));
2902}
2903/**
2904 * A function that will be executed when a platform is initialized.
2905 * \@experimental
2906 */
2907const PLATFORM_INITIALIZER = new InjectionToken('Platform Initializer');
2908/**
2909 * A token that indicates an opaque platform id.
2910 * \@experimental
2911 */
2912const PLATFORM_ID = new InjectionToken('Platform ID');
2913/**
2914 * All callbacks provided via this token will be called for every component that is bootstrapped.
2915 * Signature of the callback:
2916 *
2917 * `(componentRef: ComponentRef) => void`.
2918 *
2919 * \@experimental
2920 */
2921const APP_BOOTSTRAP_LISTENER = new InjectionToken('appBootstrapListener');
2922/**
2923 * A token which indicates the root directory of the application
2924 * \@experimental
2925 */
2926const PACKAGE_ROOT_URL = new InjectionToken('Application Packages Root URL');
2927
2928/**
2929 * @license
2930 * Copyright Google Inc. All Rights Reserved.
2931 *
2932 * Use of this source code is governed by an MIT-style license that can be
2933 * found in the LICENSE file at https://angular.io/license
2934 */
2935class Console {
2936 /**
2937 * @param {?} message
2938 * @return {?}
2939 */
2940 log(message) {
2941 // tslint:disable-next-line:no-console
2942 console.log(message);
2943 }
2944 /**
2945 * @param {?} message
2946 * @return {?}
2947 */
2948 warn(message) {
2949 // tslint:disable-next-line:no-console
2950 console.warn(message);
2951 }
2952}
2953Console.decorators = [
2954 { type: Injectable },
2955];
2956/**
2957 * @nocollapse
2958 */
2959Console.ctorParameters = () => [];
2960
2961/**
2962 * @license
2963 * Copyright Google Inc. All Rights Reserved.
2964 *
2965 * Use of this source code is governed by an MIT-style license that can be
2966 * found in the LICENSE file at https://angular.io/license
2967 */
2968/**
2969 * Combination of NgModuleFactory and ComponentFactorys.
2970 *
2971 * \@experimental
2972 */
2973class ModuleWithComponentFactories {
2974 /**
2975 * @param {?} ngModuleFactory
2976 * @param {?} componentFactories
2977 */
2978 constructor(ngModuleFactory, componentFactories) {
2979 this.ngModuleFactory = ngModuleFactory;
2980 this.componentFactories = componentFactories;
2981 }
2982}
2983/**
2984 * @return {?}
2985 */
2986function _throwError() {
2987 throw new Error(`Runtime compiler is not loaded`);
2988}
2989/**
2990 * Low-level service for running the angular compiler during runtime
2991 * to create {\@link ComponentFactory}s, which
2992 * can later be used to create and render a Component instance.
2993 *
2994 * Each `\@NgModule` provides an own `Compiler` to its injector,
2995 * that will use the directives/pipes of the ng module for compilation
2996 * of components.
2997 * \@stable
2998 */
2999class Compiler {
3000 /**
3001 * Compiles the given NgModule and all of its components. All templates of the components listed
3002 * in `entryComponents` have to be inlined.
3003 * @template T
3004 * @param {?} moduleType
3005 * @return {?}
3006 */
3007 compileModuleSync(moduleType) { throw _throwError(); }
3008 /**
3009 * Compiles the given NgModule and all of its components
3010 * @template T
3011 * @param {?} moduleType
3012 * @return {?}
3013 */
3014 compileModuleAsync(moduleType) { throw _throwError(); }
3015 /**
3016 * Same as {\@link #compileModuleSync} but also creates ComponentFactories for all components.
3017 * @template T
3018 * @param {?} moduleType
3019 * @return {?}
3020 */
3021 compileModuleAndAllComponentsSync(moduleType) {
3022 throw _throwError();
3023 }
3024 /**
3025 * Same as {\@link #compileModuleAsync} but also creates ComponentFactories for all components.
3026 * @template T
3027 * @param {?} moduleType
3028 * @return {?}
3029 */
3030 compileModuleAndAllComponentsAsync(moduleType) {
3031 throw _throwError();
3032 }
3033 /**
3034 * Exposes the CSS-style selectors that have been used in `ngContent` directives within
3035 * the template of the given component.
3036 * This is used by the `upgrade` library to compile the appropriate transclude content
3037 * in the AngularJS wrapper component.
3038 *
3039 * @deprecated since v4. Use ComponentFactory.ngContentSelectors instead.
3040 * @param {?} component
3041 * @return {?}
3042 */
3043 getNgContentSelectors(component) { throw _throwError(); }
3044 /**
3045 * Clears all caches.
3046 * @return {?}
3047 */
3048 clearCache() { }
3049 /**
3050 * Clears the cache for the given component/ngModule.
3051 * @param {?} type
3052 * @return {?}
3053 */
3054 clearCacheFor(type) { }
3055}
3056Compiler.decorators = [
3057 { type: Injectable },
3058];
3059/**
3060 * @nocollapse
3061 */
3062Compiler.ctorParameters = () => [];
3063/**
3064 * Token to provide CompilerOptions in the platform injector.
3065 *
3066 * \@experimental
3067 */
3068const COMPILER_OPTIONS = new InjectionToken('compilerOptions');
3069/**
3070 * A factory for creating a Compiler
3071 *
3072 * \@experimental
3073 * @abstract
3074 */
3075class CompilerFactory {
3076 /**
3077 * @abstract
3078 * @param {?=} options
3079 * @return {?}
3080 */
3081 createCompiler(options) { }
3082}
3083
3084/**
3085 * @license
3086 * Copyright Google Inc. All Rights Reserved.
3087 *
3088 * Use of this source code is governed by an MIT-style license that can be
3089 * found in the LICENSE file at https://angular.io/license
3090 */
3091/**
3092 * Represents an instance of a Component created via a {\@link ComponentFactory}.
3093 *
3094 * `ComponentRef` provides access to the Component Instance as well other objects related to this
3095 * Component Instance and allows you to destroy the Component Instance via the {\@link #destroy}
3096 * method.
3097 * \@stable
3098 * @abstract
3099 */
3100class ComponentRef {
3101 /**
3102 * Location of the Host Element of this Component Instance.
3103 * @abstract
3104 * @return {?}
3105 */
3106 location() { }
3107 /**
3108 * The injector on which the component instance exists.
3109 * @abstract
3110 * @return {?}
3111 */
3112 injector() { }
3113 /**
3114 * The instance of the Component.
3115 * @abstract
3116 * @return {?}
3117 */
3118 instance() { }
3119 /**
3120 * The {\@link ViewRef} of the Host View of this Component instance.
3121 * @abstract
3122 * @return {?}
3123 */
3124 hostView() { }
3125 /**
3126 * The {\@link ChangeDetectorRef} of the Component instance.
3127 * @abstract
3128 * @return {?}
3129 */
3130 changeDetectorRef() { }
3131 /**
3132 * The component type.
3133 * @abstract
3134 * @return {?}
3135 */
3136 componentType() { }
3137 /**
3138 * Destroys the component instance and all of the data structures associated with it.
3139 * @abstract
3140 * @return {?}
3141 */
3142 destroy() { }
3143 /**
3144 * Allows to register a callback that will be called when the component is destroyed.
3145 * @abstract
3146 * @param {?} callback
3147 * @return {?}
3148 */
3149 onDestroy(callback) { }
3150}
3151/**
3152 * \@stable
3153 * @abstract
3154 */
3155class ComponentFactory {
3156 /**
3157 * @abstract
3158 * @return {?}
3159 */
3160 selector() { }
3161 /**
3162 * @abstract
3163 * @return {?}
3164 */
3165 componentType() { }
3166 /**
3167 * selector for all <ng-content> elements in the component.
3168 * @abstract
3169 * @return {?}
3170 */
3171 ngContentSelectors() { }
3172 /**
3173 * the inputs of the component.
3174 * @abstract
3175 * @return {?}
3176 */
3177 inputs() { }
3178 /**
3179 * the outputs of the component.
3180 * @abstract
3181 * @return {?}
3182 */
3183 outputs() { }
3184 /**
3185 * Creates a new component.
3186 * @abstract
3187 * @param {?} injector
3188 * @param {?=} projectableNodes
3189 * @param {?=} rootSelectorOrNode
3190 * @param {?=} ngModule
3191 * @return {?}
3192 */
3193 create(injector, projectableNodes, rootSelectorOrNode, ngModule) { }
3194}
3195
3196/**
3197 * @license
3198 * Copyright Google Inc. All Rights Reserved.
3199 *
3200 * Use of this source code is governed by an MIT-style license that can be
3201 * found in the LICENSE file at https://angular.io/license
3202 */
3203/**
3204 * @param {?} component
3205 * @return {?}
3206 */
3207function noComponentFactoryError(component) {
3208 const /** @type {?} */ error = Error(`No component factory found for ${stringify(component)}. Did you add it to @NgModule.entryComponents?`);
3209 ((error))[ERROR_COMPONENT] = component;
3210 return error;
3211}
3212const ERROR_COMPONENT = 'ngComponent';
3213/**
3214 * @param {?} error
3215 * @return {?}
3216 */
3217
3218class _NullComponentFactoryResolver {
3219 /**
3220 * @template T
3221 * @param {?} component
3222 * @return {?}
3223 */
3224 resolveComponentFactory(component) {
3225 throw noComponentFactoryError(component);
3226 }
3227}
3228/**
3229 * \@stable
3230 * @abstract
3231 */
3232class ComponentFactoryResolver {
3233 /**
3234 * @abstract
3235 * @template T
3236 * @param {?} component
3237 * @return {?}
3238 */
3239 resolveComponentFactory(component) { }
3240}
3241ComponentFactoryResolver.NULL = new _NullComponentFactoryResolver();
3242class CodegenComponentFactoryResolver {
3243 /**
3244 * @param {?} factories
3245 * @param {?} _parent
3246 * @param {?} _ngModule
3247 */
3248 constructor(factories, _parent, _ngModule) {
3249 this._parent = _parent;
3250 this._ngModule = _ngModule;
3251 this._factories = new Map();
3252 for (let i = 0; i < factories.length; i++) {
3253 const factory = factories[i];
3254 this._factories.set(factory.componentType, factory);
3255 }
3256 }
3257 /**
3258 * @template T
3259 * @param {?} component
3260 * @return {?}
3261 */
3262 resolveComponentFactory(component) {
3263 let /** @type {?} */ factory = this._factories.get(component) || this._parent.resolveComponentFactory(component);
3264 return new ComponentFactoryBoundToModule(factory, this._ngModule);
3265 }
3266}
3267class ComponentFactoryBoundToModule extends ComponentFactory {
3268 /**
3269 * @param {?} factory
3270 * @param {?} ngModule
3271 */
3272 constructor(factory, ngModule) {
3273 super();
3274 this.factory = factory;
3275 this.ngModule = ngModule;
3276 }
3277 /**
3278 * @return {?}
3279 */
3280 get selector() { return this.factory.selector; }
3281 /**
3282 * @return {?}
3283 */
3284 get componentType() { return this.factory.componentType; }
3285 /**
3286 * @return {?}
3287 */
3288 get ngContentSelectors() { return this.factory.ngContentSelectors; }
3289 /**
3290 * @return {?}
3291 */
3292 get inputs() { return this.factory.inputs; }
3293 /**
3294 * @return {?}
3295 */
3296 get outputs() { return this.factory.outputs; }
3297 /**
3298 * @param {?} injector
3299 * @param {?=} projectableNodes
3300 * @param {?=} rootSelectorOrNode
3301 * @param {?=} ngModule
3302 * @return {?}
3303 */
3304 create(injector, projectableNodes, rootSelectorOrNode, ngModule) {
3305 return this.factory.create(injector, projectableNodes, rootSelectorOrNode, ngModule || this.ngModule);
3306 }
3307}
3308
3309/**
3310 * @license
3311 * Copyright Google Inc. All Rights Reserved.
3312 *
3313 * Use of this source code is governed by an MIT-style license that can be
3314 * found in the LICENSE file at https://angular.io/license
3315 */
3316/**
3317 * Represents an instance of an NgModule created via a {\@link NgModuleFactory}.
3318 *
3319 * `NgModuleRef` provides access to the NgModule Instance as well other objects related to this
3320 * NgModule Instance.
3321 *
3322 * \@stable
3323 * @abstract
3324 */
3325class NgModuleRef {
3326 /**
3327 * The injector that contains all of the providers of the NgModule.
3328 * @abstract
3329 * @return {?}
3330 */
3331 injector() { }
3332 /**
3333 * The ComponentFactoryResolver to get hold of the ComponentFactories
3334 * declared in the `entryComponents` property of the module.
3335 * @abstract
3336 * @return {?}
3337 */
3338 componentFactoryResolver() { }
3339 /**
3340 * The NgModule instance.
3341 * @abstract
3342 * @return {?}
3343 */
3344 instance() { }
3345 /**
3346 * Destroys the module instance and all of the data structures associated with it.
3347 * @abstract
3348 * @return {?}
3349 */
3350 destroy() { }
3351 /**
3352 * Allows to register a callback that will be called when the module is destroyed.
3353 * @abstract
3354 * @param {?} callback
3355 * @return {?}
3356 */
3357 onDestroy(callback) { }
3358}
3359/**
3360 * \@experimental
3361 */
3362class NgModuleFactory {
3363 /**
3364 * @param {?} _injectorClass
3365 * @param {?} _moduleType
3366 */
3367 constructor(_injectorClass, _moduleType) {
3368 this._injectorClass = _injectorClass;
3369 this._moduleType = _moduleType;
3370 }
3371 /**
3372 * @return {?}
3373 */
3374 get moduleType() { return this._moduleType; }
3375 /**
3376 * @param {?} parentInjector
3377 * @return {?}
3378 */
3379 create(parentInjector) {
3380 const /** @type {?} */ instance = new this._injectorClass(parentInjector || Injector.NULL);
3381 instance.create();
3382 return instance;
3383 }
3384}
3385const _UNDEFINED = new Object();
3386/**
3387 * @abstract
3388 */
3389class NgModuleInjector {
3390 /**
3391 * @param {?} parent
3392 * @param {?} factories
3393 * @param {?} bootstrapFactories
3394 */
3395 constructor(parent, factories, bootstrapFactories) {
3396 this.parent = parent;
3397 this._destroyListeners = [];
3398 this._destroyed = false;
3399 this.bootstrapFactories =
3400 bootstrapFactories.map(f => new ComponentFactoryBoundToModule(f, this));
3401 this._cmpFactoryResolver = new CodegenComponentFactoryResolver(factories, parent.get(ComponentFactoryResolver, ComponentFactoryResolver.NULL), this);
3402 }
3403 /**
3404 * @return {?}
3405 */
3406 create() { this.instance = this.createInternal(); }
3407 /**
3408 * @abstract
3409 * @return {?}
3410 */
3411 createInternal() { }
3412 /**
3413 * @param {?} token
3414 * @param {?=} notFoundValue
3415 * @return {?}
3416 */
3417 get(token, notFoundValue = THROW_IF_NOT_FOUND) {
3418 if (token === Injector || token === NgModuleRef) {
3419 return this;
3420 }
3421 if (token === ComponentFactoryResolver) {
3422 return this._cmpFactoryResolver;
3423 }
3424 const /** @type {?} */ result = this.getInternal(token, _UNDEFINED);
3425 return result === _UNDEFINED ? this.parent.get(token, notFoundValue) : result;
3426 }
3427 /**
3428 * @abstract
3429 * @param {?} token
3430 * @param {?} notFoundValue
3431 * @return {?}
3432 */
3433 getInternal(token, notFoundValue) { }
3434 /**
3435 * @return {?}
3436 */
3437 get injector() { return this; }
3438 /**
3439 * @return {?}
3440 */
3441 get componentFactoryResolver() { return this._cmpFactoryResolver; }
3442 /**
3443 * @return {?}
3444 */
3445 destroy() {
3446 if (this._destroyed) {
3447 throw new Error(`The ng module ${stringify(this.instance.constructor)} has already been destroyed.`);
3448 }
3449 this._destroyed = true;
3450 this.destroyInternal();
3451 this._destroyListeners.forEach((listener) => listener());
3452 }
3453 /**
3454 * @param {?} callback
3455 * @return {?}
3456 */
3457 onDestroy(callback) { this._destroyListeners.push(callback); }
3458 /**
3459 * @abstract
3460 * @return {?}
3461 */
3462 destroyInternal() { }
3463}
3464
3465/**
3466 * @license
3467 * Copyright Google Inc. All Rights Reserved.
3468 *
3469 * Use of this source code is governed by an MIT-style license that can be
3470 * found in the LICENSE file at https://angular.io/license
3471 */
3472let trace;
3473let events;
3474/**
3475 * @return {?}
3476 */
3477function detectWTF() {
3478 const /** @type {?} */ wtf = ((_global) /** TODO #9100 */)['wtf'];
3479 if (wtf) {
3480 trace = wtf['trace'];
3481 if (trace) {
3482 events = trace['events'];
3483 return true;
3484 }
3485 }
3486 return false;
3487}
3488/**
3489 * @param {?} signature
3490 * @param {?=} flags
3491 * @return {?}
3492 */
3493function createScope$1(signature, flags = null) {
3494 return events.createScope(signature, flags);
3495}
3496/**
3497 * @template T
3498 * @param {?} scope
3499 * @param {?=} returnValue
3500 * @return {?}
3501 */
3502function leave(scope, returnValue) {
3503 trace.leaveScope(scope, returnValue);
3504 return returnValue;
3505}
3506/**
3507 * @param {?} rangeType
3508 * @param {?} action
3509 * @return {?}
3510 */
3511function startTimeRange(rangeType, action) {
3512 return trace.beginTimeRange(rangeType, action);
3513}
3514/**
3515 * @param {?} range
3516 * @return {?}
3517 */
3518function endTimeRange(range) {
3519 trace.endTimeRange(range);
3520}
3521
3522/**
3523 * @license
3524 * Copyright Google Inc. All Rights Reserved.
3525 *
3526 * Use of this source code is governed by an MIT-style license that can be
3527 * found in the LICENSE file at https://angular.io/license
3528 */
3529/**
3530 * True if WTF is enabled.
3531 */
3532const wtfEnabled = detectWTF();
3533/**
3534 * @param {?=} arg0
3535 * @param {?=} arg1
3536 * @return {?}
3537 */
3538function noopScope(arg0, arg1) {
3539 return null;
3540}
3541/**
3542 * Create trace scope.
3543 *
3544 * Scopes must be strictly nested and are analogous to stack frames, but
3545 * do not have to follow the stack frames. Instead it is recommended that they follow logical
3546 * nesting. You may want to use
3547 * [Event
3548 * Signatures](http://google.github.io/tracing-framework/instrumenting-code.html#custom-events)
3549 * as they are defined in WTF.
3550 *
3551 * Used to mark scope entry. The return value is used to leave the scope.
3552 *
3553 * var myScope = wtfCreateScope('MyClass#myMethod(ascii someVal)');
3554 *
3555 * someMethod() {
3556 * var s = myScope('Foo'); // 'Foo' gets stored in tracing UI
3557 * // DO SOME WORK HERE
3558 * return wtfLeave(s, 123); // Return value 123
3559 * }
3560 *
3561 * Note, adding try-finally block around the work to ensure that `wtfLeave` gets called can
3562 * negatively impact the performance of your application. For this reason we recommend that
3563 * you don't add them to ensure that `wtfLeave` gets called. In production `wtfLeave` is a noop and
3564 * so try-finally block has no value. When debugging perf issues, skipping `wtfLeave`, do to
3565 * exception, will produce incorrect trace, but presence of exception signifies logic error which
3566 * needs to be fixed before the app should be profiled. Add try-finally only when you expect that
3567 * an exception is expected during normal execution while profiling.
3568 *
3569 * \@experimental
3570 */
3571const wtfCreateScope = wtfEnabled ? createScope$1 : (signature, flags) => noopScope;
3572/**
3573 * Used to mark end of Scope.
3574 *
3575 * - `scope` to end.
3576 * - `returnValue` (optional) to be passed to the WTF.
3577 *
3578 * Returns the `returnValue for easy chaining.
3579 * \@experimental
3580 */
3581const wtfLeave = wtfEnabled ? leave : (s, r) => r;
3582/**
3583 * Used to mark Async start. Async are similar to scope but they don't have to be strictly nested.
3584 * The return value is used in the call to [endAsync]. Async ranges only work if WTF has been
3585 * enabled.
3586 *
3587 * someMethod() {
3588 * var s = wtfStartTimeRange('HTTP:GET', 'some.url');
3589 * var future = new Future.delay(5).then((_) {
3590 * wtfEndTimeRange(s);
3591 * });
3592 * }
3593 * \@experimental
3594 */
3595const wtfStartTimeRange = wtfEnabled ? startTimeRange : (rangeType, action) => null;
3596/**
3597 * Ends a async time range operation.
3598 * [range] is the return value from [wtfStartTimeRange] Async ranges only work if WTF has been
3599 * enabled.
3600 * \@experimental
3601 */
3602const wtfEndTimeRange = wtfEnabled ? endTimeRange : (r) => null;
3603
3604/**
3605 * @license
3606 * Copyright Google Inc. All Rights Reserved.
3607 *
3608 * Use of this source code is governed by an MIT-style license that can be
3609 * found in the LICENSE file at https://angular.io/license
3610 */
3611/**
3612 * Use by directives and components to emit custom Events.
3613 *
3614 * ### Examples
3615 *
3616 * In the following example, `Zippy` alternatively emits `open` and `close` events when its
3617 * title gets clicked:
3618 *
3619 * ```
3620 * \@Component({
3621 * selector: 'zippy',
3622 * template: `
3623 * <div class="zippy">
3624 * <div (click)="toggle()">Toggle</div>
3625 * <div [hidden]="!visible">
3626 * <ng-content></ng-content>
3627 * </div>
3628 * </div>`})
3629 * export class Zippy {
3630 * visible: boolean = true;
3631 * \@Output() open: EventEmitter<any> = new EventEmitter();
3632 * \@Output() close: EventEmitter<any> = new EventEmitter();
3633 *
3634 * toggle() {
3635 * this.visible = !this.visible;
3636 * if (this.visible) {
3637 * this.open.emit(null);
3638 * } else {
3639 * this.close.emit(null);
3640 * }
3641 * }
3642 * }
3643 * ```
3644 *
3645 * The events payload can be accessed by the parameter `$event` on the components output event
3646 * handler:
3647 *
3648 * ```
3649 * <zippy (open)="onOpen($event)" (close)="onClose($event)"></zippy>
3650 * ```
3651 *
3652 * Uses Rx.Observable but provides an adapter to make it work as specified here:
3653 * https://github.com/jhusain/observable-spec
3654 *
3655 * Once a reference implementation of the spec is available, switch to it.
3656 * \@stable
3657 */
3658class EventEmitter extends Subject {
3659 /**
3660 * Creates an instance of [EventEmitter], which depending on [isAsync],
3661 * delivers events synchronously or asynchronously.
3662 * @param {?=} isAsync
3663 */
3664 constructor(isAsync = false) {
3665 super();
3666 this.__isAsync = isAsync;
3667 }
3668 /**
3669 * @param {?=} value
3670 * @return {?}
3671 */
3672 emit(value) { super.next(value); }
3673 /**
3674 * @param {?=} generatorOrNext
3675 * @param {?=} error
3676 * @param {?=} complete
3677 * @return {?}
3678 */
3679 subscribe(generatorOrNext, error, complete) {
3680 let /** @type {?} */ schedulerFn;
3681 let /** @type {?} */ errorFn = (err) => null;
3682 let /** @type {?} */ completeFn = () => null;
3683 if (generatorOrNext && typeof generatorOrNext === 'object') {
3684 schedulerFn = this.__isAsync ? (value) => {
3685 setTimeout(() => generatorOrNext.next(value));
3686 } : (value) => { generatorOrNext.next(value); };
3687 if (generatorOrNext.error) {
3688 errorFn = this.__isAsync ? (err) => { setTimeout(() => generatorOrNext.error(err)); } :
3689 (err) => { generatorOrNext.error(err); };
3690 }
3691 if (generatorOrNext.complete) {
3692 completeFn = this.__isAsync ? () => { setTimeout(() => generatorOrNext.complete()); } :
3693 () => { generatorOrNext.complete(); };
3694 }
3695 }
3696 else {
3697 schedulerFn = this.__isAsync ? (value) => { setTimeout(() => generatorOrNext(value)); } :
3698 (value) => { generatorOrNext(value); };
3699 if (error) {
3700 errorFn =
3701 this.__isAsync ? (err) => { setTimeout(() => error(err)); } : (err) => { error(err); };
3702 }
3703 if (complete) {
3704 completeFn =
3705 this.__isAsync ? () => { setTimeout(() => complete()); } : () => { complete(); };
3706 }
3707 }
3708 return super.subscribe(schedulerFn, errorFn, completeFn);
3709 }
3710}
3711
3712/**
3713 * @license
3714 * Copyright Google Inc. All Rights Reserved.
3715 *
3716 * Use of this source code is governed by an MIT-style license that can be
3717 * found in the LICENSE file at https://angular.io/license
3718 */
3719/**
3720 * An injectable service for executing work inside or outside of the Angular zone.
3721 *
3722 * The most common use of this service is to optimize performance when starting a work consisting of
3723 * one or more asynchronous tasks that don't require UI updates or error handling to be handled by
3724 * Angular. Such tasks can be kicked off via {\@link #runOutsideAngular} and if needed, these tasks
3725 * can reenter the Angular zone via {\@link #run}.
3726 *
3727 * <!-- TODO: add/fix links to:
3728 * - docs explaining zones and the use of zones in Angular and change-detection
3729 * - link to runOutsideAngular/run (throughout this file!)
3730 * -->
3731 *
3732 * ### Example
3733 *
3734 * ```
3735 * import {Component, NgZone} from '\@angular/core';
3736 * import {NgIf} from '\@angular/common';
3737 *
3738 * \@Component({
3739 * selector: 'ng-zone-demo'.
3740 * template: `
3741 * <h2>Demo: NgZone</h2>
3742 *
3743 * <p>Progress: {{progress}}%</p>
3744 * <p *ngIf="progress >= 100">Done processing {{label}} of Angular zone!</p>
3745 *
3746 * <button (click)="processWithinAngularZone()">Process within Angular zone</button>
3747 * <button (click)="processOutsideOfAngularZone()">Process outside of Angular zone</button>
3748 * `,
3749 * })
3750 * export class NgZoneDemo {
3751 * progress: number = 0;
3752 * label: string;
3753 *
3754 * constructor(private _ngZone: NgZone) {}
3755 *
3756 * // Loop inside the Angular zone
3757 * // so the UI DOES refresh after each setTimeout cycle
3758 * processWithinAngularZone() {
3759 * this.label = 'inside';
3760 * this.progress = 0;
3761 * this._increaseProgress(() => console.log('Inside Done!'));
3762 * }
3763 *
3764 * // Loop outside of the Angular zone
3765 * // so the UI DOES NOT refresh after each setTimeout cycle
3766 * processOutsideOfAngularZone() {
3767 * this.label = 'outside';
3768 * this.progress = 0;
3769 * this._ngZone.runOutsideAngular(() => {
3770 * this._increaseProgress(() => {
3771 * // reenter the Angular zone and display done
3772 * this._ngZone.run(() => {console.log('Outside Done!') });
3773 * }}));
3774 * }
3775 *
3776 * _increaseProgress(doneCallback: () => void) {
3777 * this.progress += 1;
3778 * console.log(`Current progress: ${this.progress}%`);
3779 *
3780 * if (this.progress < 100) {
3781 * window.setTimeout(() => this._increaseProgress(doneCallback)), 10)
3782 * } else {
3783 * doneCallback();
3784 * }
3785 * }
3786 * }
3787 * ```
3788 *
3789 * \@experimental
3790 */
3791class NgZone {
3792 /**
3793 * @param {?} __0
3794 */
3795 constructor({ enableLongStackTrace = false }) {
3796 this._hasPendingMicrotasks = false;
3797 this._hasPendingMacrotasks = false;
3798 this._isStable = true;
3799 this._nesting = 0;
3800 this._onUnstable = new EventEmitter(false);
3801 this._onMicrotaskEmpty = new EventEmitter(false);
3802 this._onStable = new EventEmitter(false);
3803 this._onErrorEvents = new EventEmitter(false);
3804 if (typeof Zone == 'undefined') {
3805 throw new Error('Angular requires Zone.js prolyfill.');
3806 }
3807 Zone.assertZonePatched();
3808 this.outer = this.inner = Zone.current;
3809 if (Zone['wtfZoneSpec']) {
3810 this.inner = this.inner.fork(Zone['wtfZoneSpec']);
3811 }
3812 if (enableLongStackTrace && Zone['longStackTraceZoneSpec']) {
3813 this.inner = this.inner.fork(Zone['longStackTraceZoneSpec']);
3814 }
3815 this.forkInnerZoneWithAngularBehavior();
3816 }
3817 /**
3818 * @return {?}
3819 */
3820 static isInAngularZone() { return Zone.current.get('isAngularZone') === true; }
3821 /**
3822 * @return {?}
3823 */
3824 static assertInAngularZone() {
3825 if (!NgZone.isInAngularZone()) {
3826 throw new Error('Expected to be in Angular Zone, but it is not!');
3827 }
3828 }
3829 /**
3830 * @return {?}
3831 */
3832 static assertNotInAngularZone() {
3833 if (NgZone.isInAngularZone()) {
3834 throw new Error('Expected to not be in Angular Zone, but it is!');
3835 }
3836 }
3837 /**
3838 * Executes the `fn` function synchronously within the Angular zone and returns value returned by
3839 * the function.
3840 *
3841 * Running functions via `run` allows you to reenter Angular zone from a task that was executed
3842 * outside of the Angular zone (typically started via {\@link #runOutsideAngular}).
3843 *
3844 * Any future tasks or microtasks scheduled from within this function will continue executing from
3845 * within the Angular zone.
3846 *
3847 * If a synchronous error happens it will be rethrown and not reported via `onError`.
3848 * @param {?} fn
3849 * @return {?}
3850 */
3851 run(fn) { return this.inner.run(fn); }
3852 /**
3853 * Same as `run`, except that synchronous errors are caught and forwarded via `onError` and not
3854 * rethrown.
3855 * @param {?} fn
3856 * @return {?}
3857 */
3858 runGuarded(fn) { return this.inner.runGuarded(fn); }
3859 /**
3860 * Executes the `fn` function synchronously in Angular's parent zone and returns value returned by
3861 * the function.
3862 *
3863 * Running functions via {\@link #runOutsideAngular} allows you to escape Angular's zone and do
3864 * work that
3865 * doesn't trigger Angular change-detection or is subject to Angular's error handling.
3866 *
3867 * Any future tasks or microtasks scheduled from within this function will continue executing from
3868 * outside of the Angular zone.
3869 *
3870 * Use {\@link #run} to reenter the Angular zone and do work that updates the application model.
3871 * @param {?} fn
3872 * @return {?}
3873 */
3874 runOutsideAngular(fn) { return this.outer.run(fn); }
3875 /**
3876 * Notifies when code enters Angular Zone. This gets fired first on VM Turn.
3877 * @return {?}
3878 */
3879 get onUnstable() { return this._onUnstable; }
3880 /**
3881 * Notifies when there is no more microtasks enqueue in the current VM Turn.
3882 * This is a hint for Angular to do change detection, which may enqueue more microtasks.
3883 * For this reason this event can fire multiple times per VM Turn.
3884 * @return {?}
3885 */
3886 get onMicrotaskEmpty() { return this._onMicrotaskEmpty; }
3887 /**
3888 * Notifies when the last `onMicrotaskEmpty` has run and there are no more microtasks, which
3889 * implies we are about to relinquish VM turn.
3890 * This event gets called just once.
3891 * @return {?}
3892 */
3893 get onStable() { return this._onStable; }
3894 /**
3895 * Notify that an error has been delivered.
3896 * @return {?}
3897 */
3898 get onError() { return this._onErrorEvents; }
3899 /**
3900 * Whether there are no outstanding microtasks or macrotasks.
3901 * @return {?}
3902 */
3903 get isStable() { return this._isStable; }
3904 /**
3905 * @return {?}
3906 */
3907 get hasPendingMicrotasks() { return this._hasPendingMicrotasks; }
3908 /**
3909 * @return {?}
3910 */
3911 get hasPendingMacrotasks() { return this._hasPendingMacrotasks; }
3912 /**
3913 * @return {?}
3914 */
3915 checkStable() {
3916 if (this._nesting == 0 && !this._hasPendingMicrotasks && !this._isStable) {
3917 try {
3918 this._nesting++;
3919 this._onMicrotaskEmpty.emit(null);
3920 }
3921 finally {
3922 this._nesting--;
3923 if (!this._hasPendingMicrotasks) {
3924 try {
3925 this.runOutsideAngular(() => this._onStable.emit(null));
3926 }
3927 finally {
3928 this._isStable = true;
3929 }
3930 }
3931 }
3932 }
3933 }
3934 /**
3935 * @return {?}
3936 */
3937 forkInnerZoneWithAngularBehavior() {
3938 this.inner = this.inner.fork({
3939 name: 'angular',
3940 properties: /** @type {?} */ ({ 'isAngularZone': true }),
3941 onInvokeTask: (delegate, current, target, task, applyThis, applyArgs) => {
3942 try {
3943 this.onEnter();
3944 return delegate.invokeTask(target, task, applyThis, applyArgs);
3945 }
3946 finally {
3947 this.onLeave();
3948 }
3949 },
3950 onInvoke: (delegate, current, target, callback, applyThis, applyArgs, source) => {
3951 try {
3952 this.onEnter();
3953 return delegate.invoke(target, callback, applyThis, applyArgs, source);
3954 }
3955 finally {
3956 this.onLeave();
3957 }
3958 },
3959 onHasTask: (delegate, current, target, hasTaskState) => {
3960 delegate.hasTask(target, hasTaskState);
3961 if (current === target) {
3962 // We are only interested in hasTask events which originate from our zone
3963 // (A child hasTask event is not interesting to us)
3964 if (hasTaskState.change == 'microTask') {
3965 this.setHasMicrotask(hasTaskState.microTask);
3966 }
3967 else if (hasTaskState.change == 'macroTask') {
3968 this.setHasMacrotask(hasTaskState.macroTask);
3969 }
3970 }
3971 },
3972 onHandleError: (delegate, current, target, error) => {
3973 delegate.handleError(target, error);
3974 this.triggerError(error);
3975 return false;
3976 }
3977 });
3978 }
3979 /**
3980 * @return {?}
3981 */
3982 onEnter() {
3983 this._nesting++;
3984 if (this._isStable) {
3985 this._isStable = false;
3986 this._onUnstable.emit(null);
3987 }
3988 }
3989 /**
3990 * @return {?}
3991 */
3992 onLeave() {
3993 this._nesting--;
3994 this.checkStable();
3995 }
3996 /**
3997 * @param {?} hasMicrotasks
3998 * @return {?}
3999 */
4000 setHasMicrotask(hasMicrotasks) {
4001 this._hasPendingMicrotasks = hasMicrotasks;
4002 this.checkStable();
4003 }
4004 /**
4005 * @param {?} hasMacrotasks
4006 * @return {?}
4007 */
4008 setHasMacrotask(hasMacrotasks) { this._hasPendingMacrotasks = hasMacrotasks; }
4009 /**
4010 * @param {?} error
4011 * @return {?}
4012 */
4013 triggerError(error) { this._onErrorEvents.emit(error); }
4014}
4015
4016/**
4017 * @license
4018 * Copyright Google Inc. All Rights Reserved.
4019 *
4020 * Use of this source code is governed by an MIT-style license that can be
4021 * found in the LICENSE file at https://angular.io/license
4022 */
4023/**
4024 * The Testability service provides testing hooks that can be accessed from
4025 * the browser and by services such as Protractor. Each bootstrapped Angular
4026 * application on the page will have an instance of Testability.
4027 * \@experimental
4028 */
4029class Testability {
4030 /**
4031 * @param {?} _ngZone
4032 */
4033 constructor(_ngZone) {
4034 this._ngZone = _ngZone;
4035 /**
4036 * \@internal
4037 */
4038 this._pendingCount = 0;
4039 /**
4040 * \@internal
4041 */
4042 this._isZoneStable = true;
4043 /**
4044 * Whether any work was done since the last 'whenStable' callback. This is
4045 * useful to detect if this could have potentially destabilized another
4046 * component while it is stabilizing.
4047 * \@internal
4048 */
4049 this._didWork = false;
4050 /**
4051 * \@internal
4052 */
4053 this._callbacks = [];
4054 this._watchAngularEvents();
4055 }
4056 /**
4057 * \@internal
4058 * @return {?}
4059 */
4060 _watchAngularEvents() {
4061 this._ngZone.onUnstable.subscribe({
4062 next: () => {
4063 this._didWork = true;
4064 this._isZoneStable = false;
4065 }
4066 });
4067 this._ngZone.runOutsideAngular(() => {
4068 this._ngZone.onStable.subscribe({
4069 next: () => {
4070 NgZone.assertNotInAngularZone();
4071 scheduleMicroTask(() => {
4072 this._isZoneStable = true;
4073 this._runCallbacksIfReady();
4074 });
4075 }
4076 });
4077 });
4078 }
4079 /**
4080 * @return {?}
4081 */
4082 increasePendingRequestCount() {
4083 this._pendingCount += 1;
4084 this._didWork = true;
4085 return this._pendingCount;
4086 }
4087 /**
4088 * @return {?}
4089 */
4090 decreasePendingRequestCount() {
4091 this._pendingCount -= 1;
4092 if (this._pendingCount < 0) {
4093 throw new Error('pending async requests below zero');
4094 }
4095 this._runCallbacksIfReady();
4096 return this._pendingCount;
4097 }
4098 /**
4099 * @return {?}
4100 */
4101 isStable() {
4102 return this._isZoneStable && this._pendingCount == 0 && !this._ngZone.hasPendingMacrotasks;
4103 }
4104 /**
4105 * \@internal
4106 * @return {?}
4107 */
4108 _runCallbacksIfReady() {
4109 if (this.isStable()) {
4110 // Schedules the call backs in a new frame so that it is always async.
4111 scheduleMicroTask(() => {
4112 while (this._callbacks.length !== 0) {
4113 (((this._callbacks.pop())))(this._didWork);
4114 }
4115 this._didWork = false;
4116 });
4117 }
4118 else {
4119 // Not Ready
4120 this._didWork = true;
4121 }
4122 }
4123 /**
4124 * @param {?} callback
4125 * @return {?}
4126 */
4127 whenStable(callback) {
4128 this._callbacks.push(callback);
4129 this._runCallbacksIfReady();
4130 }
4131 /**
4132 * @return {?}
4133 */
4134 getPendingRequestCount() { return this._pendingCount; }
4135 /**
4136 * @deprecated use findProviders
4137 * @param {?} using
4138 * @param {?} provider
4139 * @param {?} exactMatch
4140 * @return {?}
4141 */
4142 findBindings(using, provider, exactMatch) {
4143 // TODO(juliemr): implement.
4144 return [];
4145 }
4146 /**
4147 * @param {?} using
4148 * @param {?} provider
4149 * @param {?} exactMatch
4150 * @return {?}
4151 */
4152 findProviders(using, provider, exactMatch) {
4153 // TODO(juliemr): implement.
4154 return [];
4155 }
4156}
4157Testability.decorators = [
4158 { type: Injectable },
4159];
4160/**
4161 * @nocollapse
4162 */
4163Testability.ctorParameters = () => [
4164 { type: NgZone, },
4165];
4166/**
4167 * A global registry of {\@link Testability} instances for specific elements.
4168 * \@experimental
4169 */
4170class TestabilityRegistry {
4171 constructor() {
4172 /**
4173 * \@internal
4174 */
4175 this._applications = new Map();
4176 _testabilityGetter.addToWindow(this);
4177 }
4178 /**
4179 * @param {?} token
4180 * @param {?} testability
4181 * @return {?}
4182 */
4183 registerApplication(token, testability) {
4184 this._applications.set(token, testability);
4185 }
4186 /**
4187 * @param {?} elem
4188 * @return {?}
4189 */
4190 getTestability(elem) { return this._applications.get(elem) || null; }
4191 /**
4192 * @return {?}
4193 */
4194 getAllTestabilities() { return Array.from(this._applications.values()); }
4195 /**
4196 * @return {?}
4197 */
4198 getAllRootElements() { return Array.from(this._applications.keys()); }
4199 /**
4200 * @param {?} elem
4201 * @param {?=} findInAncestors
4202 * @return {?}
4203 */
4204 findTestabilityInTree(elem, findInAncestors = true) {
4205 return _testabilityGetter.findTestabilityInTree(this, elem, findInAncestors);
4206 }
4207}
4208TestabilityRegistry.decorators = [
4209 { type: Injectable },
4210];
4211/**
4212 * @nocollapse
4213 */
4214TestabilityRegistry.ctorParameters = () => [];
4215class _NoopGetTestability {
4216 /**
4217 * @param {?} registry
4218 * @return {?}
4219 */
4220 addToWindow(registry) { }
4221 /**
4222 * @param {?} registry
4223 * @param {?} elem
4224 * @param {?} findInAncestors
4225 * @return {?}
4226 */
4227 findTestabilityInTree(registry, elem, findInAncestors) {
4228 return null;
4229 }
4230}
4231/**
4232 * Set the {\@link GetTestability} implementation used by the Angular testing framework.
4233 * \@experimental
4234 * @param {?} getter
4235 * @return {?}
4236 */
4237function setTestabilityGetter(getter) {
4238 _testabilityGetter = getter;
4239}
4240let _testabilityGetter = new _NoopGetTestability();
4241
4242/**
4243 * @license
4244 * Copyright Google Inc. All Rights Reserved.
4245 *
4246 * Use of this source code is governed by an MIT-style license that can be
4247 * found in the LICENSE file at https://angular.io/license
4248 */
4249let _devMode = true;
4250let _runModeLocked = false;
4251let _platform;
4252const ALLOW_MULTIPLE_PLATFORMS = new InjectionToken('AllowMultipleToken');
4253/**
4254 * Disable Angular's development mode, which turns off assertions and other
4255 * checks within the framework.
4256 *
4257 * One important assertion this disables verifies that a change detection pass
4258 * does not result in additional changes to any bindings (also known as
4259 * unidirectional data flow).
4260 *
4261 * \@stable
4262 * @return {?}
4263 */
4264function enableProdMode() {
4265 if (_runModeLocked) {
4266 throw new Error('Cannot enable prod mode after platform setup.');
4267 }
4268 _devMode = false;
4269}
4270/**
4271 * Returns whether Angular is in development mode. After called once,
4272 * the value is locked and won't change any more.
4273 *
4274 * By default, this is true, unless a user calls `enableProdMode` before calling this.
4275 *
4276 * \@experimental APIs related to application bootstrap are currently under review.
4277 * @return {?}
4278 */
4279function isDevMode() {
4280 _runModeLocked = true;
4281 return _devMode;
4282}
4283/**
4284 * A token for third-party components that can register themselves with NgProbe.
4285 *
4286 * \@experimental
4287 */
4288class NgProbeToken {
4289 /**
4290 * @param {?} name
4291 * @param {?} token
4292 */
4293 constructor(name, token) {
4294 this.name = name;
4295 this.token = token;
4296 }
4297}
4298/**
4299 * Creates a platform.
4300 * Platforms have to be eagerly created via this function.
4301 *
4302 * \@experimental APIs related to application bootstrap are currently under review.
4303 * @param {?} injector
4304 * @return {?}
4305 */
4306function createPlatform(injector) {
4307 if (_platform && !_platform.destroyed &&
4308 !_platform.injector.get(ALLOW_MULTIPLE_PLATFORMS, false)) {
4309 throw new Error('There can be only one platform. Destroy the previous one to create a new one.');
4310 }
4311 _platform = injector.get(PlatformRef);
4312 const /** @type {?} */ inits = injector.get(PLATFORM_INITIALIZER, null);
4313 if (inits)
4314 inits.forEach((init) => init());
4315 return _platform;
4316}
4317/**
4318 * Creates a factory for a platform
4319 *
4320 * \@experimental APIs related to application bootstrap are currently under review.
4321 * @param {?} parentPlatformFactory
4322 * @param {?} name
4323 * @param {?=} providers
4324 * @return {?}
4325 */
4326function createPlatformFactory(parentPlatformFactory, name, providers = []) {
4327 const /** @type {?} */ marker = new InjectionToken(`Platform: ${name}`);
4328 return (extraProviders = []) => {
4329 let /** @type {?} */ platform = getPlatform();
4330 if (!platform || platform.injector.get(ALLOW_MULTIPLE_PLATFORMS, false)) {
4331 if (parentPlatformFactory) {
4332 parentPlatformFactory(providers.concat(extraProviders).concat({ provide: marker, useValue: true }));
4333 }
4334 else {
4335 createPlatform(ReflectiveInjector.resolveAndCreate(providers.concat(extraProviders).concat({ provide: marker, useValue: true })));
4336 }
4337 }
4338 return assertPlatform(marker);
4339 };
4340}
4341/**
4342 * Checks that there currently is a platform which contains the given token as a provider.
4343 *
4344 * \@experimental APIs related to application bootstrap are currently under review.
4345 * @param {?} requiredToken
4346 * @return {?}
4347 */
4348function assertPlatform(requiredToken) {
4349 const /** @type {?} */ platform = getPlatform();
4350 if (!platform) {
4351 throw new Error('No platform exists!');
4352 }
4353 if (!platform.injector.get(requiredToken, null)) {
4354 throw new Error('A platform with a different configuration has been created. Please destroy it first.');
4355 }
4356 return platform;
4357}
4358/**
4359 * Destroy the existing platform.
4360 *
4361 * \@experimental APIs related to application bootstrap are currently under review.
4362 * @return {?}
4363 */
4364function destroyPlatform() {
4365 if (_platform && !_platform.destroyed) {
4366 _platform.destroy();
4367 }
4368}
4369/**
4370 * Returns the current platform.
4371 *
4372 * \@experimental APIs related to application bootstrap are currently under review.
4373 * @return {?}
4374 */
4375function getPlatform() {
4376 return _platform && !_platform.destroyed ? _platform : null;
4377}
4378/**
4379 * The Angular platform is the entry point for Angular on a web page. Each page
4380 * has exactly one platform, and services (such as reflection) which are common
4381 * to every Angular application running on the page are bound in its scope.
4382 *
4383 * A page's platform is initialized implicitly when a platform is created via a platform factory
4384 * (e.g. {\@link platformBrowser}), or explicitly by calling the {\@link createPlatform} function.
4385 *
4386 * \@stable
4387 * @abstract
4388 */
4389class PlatformRef {
4390 /**
4391 * Creates an instance of an `\@NgModule` for the given platform
4392 * for offline compilation.
4393 *
4394 * ## Simple Example
4395 *
4396 * ```typescript
4397 * my_module.ts:
4398 *
4399 * \@NgModule({
4400 * imports: [BrowserModule]
4401 * })
4402 * class MyModule {}
4403 *
4404 * main.ts:
4405 * import {MyModuleNgFactory} from './my_module.ngfactory';
4406 * import {platformBrowser} from '\@angular/platform-browser';
4407 *
4408 * let moduleRef = platformBrowser().bootstrapModuleFactory(MyModuleNgFactory);
4409 * ```
4410 *
4411 * \@experimental APIs related to application bootstrap are currently under review.
4412 * @abstract
4413 * @template M
4414 * @param {?} moduleFactory
4415 * @return {?}
4416 */
4417 bootstrapModuleFactory(moduleFactory) { }
4418 /**
4419 * Creates an instance of an `\@NgModule` for a given platform using the given runtime compiler.
4420 *
4421 * ## Simple Example
4422 *
4423 * ```typescript
4424 * \@NgModule({
4425 * imports: [BrowserModule]
4426 * })
4427 * class MyModule {}
4428 *
4429 * let moduleRef = platformBrowser().bootstrapModule(MyModule);
4430 * ```
4431 * \@stable
4432 * @abstract
4433 * @template M
4434 * @param {?} moduleType
4435 * @param {?=} compilerOptions
4436 * @return {?}
4437 */
4438 bootstrapModule(moduleType, compilerOptions) { }
4439 /**
4440 * Register a listener to be called when the platform is disposed.
4441 * @abstract
4442 * @param {?} callback
4443 * @return {?}
4444 */
4445 onDestroy(callback) { }
4446 /**
4447 * Retrieve the platform {\@link Injector}, which is the parent injector for
4448 * every Angular application on the page and provides singleton providers.
4449 * @abstract
4450 * @return {?}
4451 */
4452 injector() { }
4453 /**
4454 * Destroy the Angular platform and all Angular applications on the page.
4455 * @abstract
4456 * @return {?}
4457 */
4458 destroy() { }
4459 /**
4460 * @abstract
4461 * @return {?}
4462 */
4463 destroyed() { }
4464}
4465/**
4466 * @param {?} errorHandler
4467 * @param {?} callback
4468 * @return {?}
4469 */
4470function _callAndReportToErrorHandler(errorHandler, callback) {
4471 try {
4472 const /** @type {?} */ result = callback();
4473 if (isPromise(result)) {
4474 return result.catch((e) => {
4475 errorHandler.handleError(e);
4476 // rethrow as the exception handler might not do it
4477 throw e;
4478 });
4479 }
4480 return result;
4481 }
4482 catch (e) {
4483 errorHandler.handleError(e);
4484 // rethrow as the exception handler might not do it
4485 throw e;
4486 }
4487}
4488/**
4489 * workaround https://github.com/angular/tsickle/issues/350
4490 * @suppress {checkTypes}
4491 */
4492class PlatformRef_ extends PlatformRef {
4493 /**
4494 * @param {?} _injector
4495 */
4496 constructor(_injector) {
4497 super();
4498 this._injector = _injector;
4499 this._modules = [];
4500 this._destroyListeners = [];
4501 this._destroyed = false;
4502 }
4503 /**
4504 * @param {?} callback
4505 * @return {?}
4506 */
4507 onDestroy(callback) { this._destroyListeners.push(callback); }
4508 /**
4509 * @return {?}
4510 */
4511 get injector() { return this._injector; }
4512 /**
4513 * @return {?}
4514 */
4515 get destroyed() { return this._destroyed; }
4516 /**
4517 * @return {?}
4518 */
4519 destroy() {
4520 if (this._destroyed) {
4521 throw new Error('The platform has already been destroyed!');
4522 }
4523 this._modules.slice().forEach(module => module.destroy());
4524 this._destroyListeners.forEach(listener => listener());
4525 this._destroyed = true;
4526 }
4527 /**
4528 * @template M
4529 * @param {?} moduleFactory
4530 * @return {?}
4531 */
4532 bootstrapModuleFactory(moduleFactory) {
4533 return this._bootstrapModuleFactoryWithZone(moduleFactory);
4534 }
4535 /**
4536 * @template M
4537 * @param {?} moduleFactory
4538 * @param {?=} ngZone
4539 * @return {?}
4540 */
4541 _bootstrapModuleFactoryWithZone(moduleFactory, ngZone) {
4542 // Note: We need to create the NgZone _before_ we instantiate the module,
4543 // as instantiating the module creates some providers eagerly.
4544 // So we create a mini parent injector that just contains the new NgZone and
4545 // pass that as parent to the NgModuleFactory.
4546 if (!ngZone)
4547 ngZone = new NgZone({ enableLongStackTrace: isDevMode() });
4548 // Attention: Don't use ApplicationRef.run here,
4549 // as we want to be sure that all possible constructor calls are inside `ngZone.run`!
4550 return ngZone.run(() => {
4551 const /** @type {?} */ ngZoneInjector = ReflectiveInjector.resolveAndCreate([{ provide: NgZone, useValue: ngZone }], this.injector);
4552 const /** @type {?} */ moduleRef = (moduleFactory.create(ngZoneInjector));
4553 const /** @type {?} */ exceptionHandler = moduleRef.injector.get(ErrorHandler, null);
4554 if (!exceptionHandler) {
4555 throw new Error('No ErrorHandler. Is platform module (BrowserModule) included?');
4556 }
4557 moduleRef.onDestroy(() => remove(this._modules, moduleRef)); /** @type {?} */
4558 ((ngZone)).onError.subscribe({ next: (error) => { exceptionHandler.handleError(error); } });
4559 return _callAndReportToErrorHandler(exceptionHandler, () => {
4560 const /** @type {?} */ initStatus = moduleRef.injector.get(ApplicationInitStatus);
4561 return initStatus.donePromise.then(() => {
4562 this._moduleDoBootstrap(moduleRef);
4563 return moduleRef;
4564 });
4565 });
4566 });
4567 }
4568 /**
4569 * @template M
4570 * @param {?} moduleType
4571 * @param {?=} compilerOptions
4572 * @return {?}
4573 */
4574 bootstrapModule(moduleType, compilerOptions = []) {
4575 return this._bootstrapModuleWithZone(moduleType, compilerOptions);
4576 }
4577 /**
4578 * @template M
4579 * @param {?} moduleType
4580 * @param {?=} compilerOptions
4581 * @param {?=} ngZone
4582 * @return {?}
4583 */
4584 _bootstrapModuleWithZone(moduleType, compilerOptions = [], ngZone) {
4585 const /** @type {?} */ compilerFactory = this.injector.get(CompilerFactory);
4586 const /** @type {?} */ compiler = compilerFactory.createCompiler(Array.isArray(compilerOptions) ? compilerOptions : [compilerOptions]);
4587 return compiler.compileModuleAsync(moduleType)
4588 .then((moduleFactory) => this._bootstrapModuleFactoryWithZone(moduleFactory, ngZone));
4589 }
4590 /**
4591 * @param {?} moduleRef
4592 * @return {?}
4593 */
4594 _moduleDoBootstrap(moduleRef) {
4595 const /** @type {?} */ appRef = moduleRef.injector.get(ApplicationRef);
4596 if (moduleRef.bootstrapFactories.length > 0) {
4597 moduleRef.bootstrapFactories.forEach(f => appRef.bootstrap(f));
4598 }
4599 else if (moduleRef.instance.ngDoBootstrap) {
4600 moduleRef.instance.ngDoBootstrap(appRef);
4601 }
4602 else {
4603 throw new Error(`The module ${stringify(moduleRef.instance.constructor)} was bootstrapped, but it does not declare "@NgModule.bootstrap" components nor a "ngDoBootstrap" method. ` +
4604 `Please define one of these.`);
4605 }
4606 this._modules.push(moduleRef);
4607 }
4608}
4609PlatformRef_.decorators = [
4610 { type: Injectable },
4611];
4612/**
4613 * @nocollapse
4614 */
4615PlatformRef_.ctorParameters = () => [
4616 { type: Injector, },
4617];
4618/**
4619 * A reference to an Angular application running on a page.
4620 *
4621 * \@stable
4622 * @abstract
4623 */
4624class ApplicationRef {
4625 /**
4626 * Bootstrap a new component at the root level of the application.
4627 *
4628 * ### Bootstrap process
4629 *
4630 * When bootstrapping a new root component into an application, Angular mounts the
4631 * specified application component onto DOM elements identified by the [componentType]'s
4632 * selector and kicks off automatic change detection to finish initializing the component.
4633 *
4634 * ### Example
4635 * {\@example core/ts/platform/platform.ts region='longform'}
4636 * @abstract
4637 * @template C
4638 * @param {?} componentFactory
4639 * @return {?}
4640 */
4641 bootstrap(componentFactory) { }
4642 /**
4643 * Invoke this method to explicitly process change detection and its side-effects.
4644 *
4645 * In development mode, `tick()` also performs a second change detection cycle to ensure that no
4646 * further changes are detected. If additional changes are picked up during this second cycle,
4647 * bindings in the app have side-effects that cannot be resolved in a single change detection
4648 * pass.
4649 * In this case, Angular throws an error, since an Angular application can only have one change
4650 * detection pass during which all change detection must complete.
4651 * @abstract
4652 * @return {?}
4653 */
4654 tick() { }
4655 /**
4656 * Get a list of component types registered to this application.
4657 * This list is populated even before the component is created.
4658 * @abstract
4659 * @return {?}
4660 */
4661 componentTypes() { }
4662 /**
4663 * Get a list of components registered to this application.
4664 * @abstract
4665 * @return {?}
4666 */
4667 components() { }
4668 /**
4669 * Attaches a view so that it will be dirty checked.
4670 * The view will be automatically detached when it is destroyed.
4671 * This will throw if the view is already attached to a ViewContainer.
4672 * @abstract
4673 * @param {?} view
4674 * @return {?}
4675 */
4676 attachView(view) { }
4677 /**
4678 * Detaches a view from dirty checking again.
4679 * @abstract
4680 * @param {?} view
4681 * @return {?}
4682 */
4683 detachView(view) { }
4684 /**
4685 * Returns the number of attached views.
4686 * @abstract
4687 * @return {?}
4688 */
4689 viewCount() { }
4690 /**
4691 * Returns an Observable that indicates when the application is stable or unstable.
4692 * @abstract
4693 * @return {?}
4694 */
4695 isStable() { }
4696}
4697/**
4698 * workaround https://github.com/angular/tsickle/issues/350
4699 * @suppress {checkTypes}
4700 */
4701class ApplicationRef_ extends ApplicationRef {
4702 /**
4703 * @param {?} _zone
4704 * @param {?} _console
4705 * @param {?} _injector
4706 * @param {?} _exceptionHandler
4707 * @param {?} _componentFactoryResolver
4708 * @param {?} _initStatus
4709 */
4710 constructor(_zone, _console, _injector, _exceptionHandler, _componentFactoryResolver, _initStatus) {
4711 super();
4712 this._zone = _zone;
4713 this._console = _console;
4714 this._injector = _injector;
4715 this._exceptionHandler = _exceptionHandler;
4716 this._componentFactoryResolver = _componentFactoryResolver;
4717 this._initStatus = _initStatus;
4718 this._bootstrapListeners = [];
4719 this._rootComponents = [];
4720 this._rootComponentTypes = [];
4721 this._views = [];
4722 this._runningTick = false;
4723 this._enforceNoNewChanges = false;
4724 this._stable = true;
4725 this._enforceNoNewChanges = isDevMode();
4726 this._zone.onMicrotaskEmpty.subscribe({ next: () => { this._zone.run(() => { this.tick(); }); } });
4727 const isCurrentlyStable = new Observable((observer) => {
4728 this._stable = this._zone.isStable && !this._zone.hasPendingMacrotasks &&
4729 !this._zone.hasPendingMicrotasks;
4730 this._zone.runOutsideAngular(() => {
4731 observer.next(this._stable);
4732 observer.complete();
4733 });
4734 });
4735 const isStable = new Observable((observer) => {
4736 const stableSub = this._zone.onStable.subscribe(() => {
4737 NgZone.assertNotInAngularZone();
4738 // Check whether there are no pending macro/micro tasks in the next tick
4739 // to allow for NgZone to update the state.
4740 scheduleMicroTask(() => {
4741 if (!this._stable && !this._zone.hasPendingMacrotasks &&
4742 !this._zone.hasPendingMicrotasks) {
4743 this._stable = true;
4744 observer.next(true);
4745 }
4746 });
4747 });
4748 const unstableSub = this._zone.onUnstable.subscribe(() => {
4749 NgZone.assertInAngularZone();
4750 if (this._stable) {
4751 this._stable = false;
4752 this._zone.runOutsideAngular(() => { observer.next(false); });
4753 }
4754 });
4755 return () => {
4756 stableSub.unsubscribe();
4757 unstableSub.unsubscribe();
4758 };
4759 });
4760 this._isStable = merge(isCurrentlyStable, share.call(isStable));
4761 }
4762 /**
4763 * @param {?} viewRef
4764 * @return {?}
4765 */
4766 attachView(viewRef) {
4767 const /** @type {?} */ view = ((viewRef));
4768 this._views.push(view);
4769 view.attachToAppRef(this);
4770 }
4771 /**
4772 * @param {?} viewRef
4773 * @return {?}
4774 */
4775 detachView(viewRef) {
4776 const /** @type {?} */ view = ((viewRef));
4777 remove(this._views, view);
4778 view.detachFromAppRef();
4779 }
4780 /**
4781 * @template C
4782 * @param {?} componentOrFactory
4783 * @return {?}
4784 */
4785 bootstrap(componentOrFactory) {
4786 if (!this._initStatus.done) {
4787 throw new Error('Cannot bootstrap as there are still asynchronous initializers running. Bootstrap components in the `ngDoBootstrap` method of the root module.');
4788 }
4789 let /** @type {?} */ componentFactory;
4790 if (componentOrFactory instanceof ComponentFactory) {
4791 componentFactory = componentOrFactory;
4792 }
4793 else {
4794 componentFactory = ((this._componentFactoryResolver.resolveComponentFactory(componentOrFactory)));
4795 }
4796 this._rootComponentTypes.push(componentFactory.componentType);
4797 // Create a factory associated with the current module if it's not bound to some other
4798 const /** @type {?} */ ngModule = componentFactory instanceof ComponentFactoryBoundToModule ?
4799 null :
4800 this._injector.get(NgModuleRef);
4801 const /** @type {?} */ compRef = componentFactory.create(Injector.NULL, [], componentFactory.selector, ngModule);
4802 compRef.onDestroy(() => { this._unloadComponent(compRef); });
4803 const /** @type {?} */ testability = compRef.injector.get(Testability, null);
4804 if (testability) {
4805 compRef.injector.get(TestabilityRegistry)
4806 .registerApplication(compRef.location.nativeElement, testability);
4807 }
4808 this._loadComponent(compRef);
4809 if (isDevMode()) {
4810 this._console.log(`Angular is running in the development mode. Call enableProdMode() to enable the production mode.`);
4811 }
4812 return compRef;
4813 }
4814 /**
4815 * @param {?} componentRef
4816 * @return {?}
4817 */
4818 _loadComponent(componentRef) {
4819 this.attachView(componentRef.hostView);
4820 this.tick();
4821 this._rootComponents.push(componentRef);
4822 // Get the listeners lazily to prevent DI cycles.
4823 const /** @type {?} */ listeners = this._injector.get(APP_BOOTSTRAP_LISTENER, []).concat(this._bootstrapListeners);
4824 listeners.forEach((listener) => listener(componentRef));
4825 }
4826 /**
4827 * @param {?} componentRef
4828 * @return {?}
4829 */
4830 _unloadComponent(componentRef) {
4831 this.detachView(componentRef.hostView);
4832 remove(this._rootComponents, componentRef);
4833 }
4834 /**
4835 * @return {?}
4836 */
4837 tick() {
4838 if (this._runningTick) {
4839 throw new Error('ApplicationRef.tick is called recursively');
4840 }
4841 const /** @type {?} */ scope = ApplicationRef_._tickScope();
4842 try {
4843 this._runningTick = true;
4844 this._views.forEach((view) => view.detectChanges());
4845 if (this._enforceNoNewChanges) {
4846 this._views.forEach((view) => view.checkNoChanges());
4847 }
4848 }
4849 catch (e) {
4850 // Attention: Don't rethrow as it could cancel subscriptions to Observables!
4851 this._exceptionHandler.handleError(e);
4852 }
4853 finally {
4854 this._runningTick = false;
4855 wtfLeave(scope);
4856 }
4857 }
4858 /**
4859 * @return {?}
4860 */
4861 ngOnDestroy() {
4862 // TODO(alxhub): Dispose of the NgZone.
4863 this._views.slice().forEach((view) => view.destroy());
4864 }
4865 /**
4866 * @return {?}
4867 */
4868 get viewCount() { return this._views.length; }
4869 /**
4870 * @return {?}
4871 */
4872 get componentTypes() { return this._rootComponentTypes; }
4873 /**
4874 * @return {?}
4875 */
4876 get components() { return this._rootComponents; }
4877 /**
4878 * @return {?}
4879 */
4880 get isStable() { return this._isStable; }
4881}
4882/**
4883 * \@internal
4884 */
4885ApplicationRef_._tickScope = wtfCreateScope('ApplicationRef#tick()');
4886ApplicationRef_.decorators = [
4887 { type: Injectable },
4888];
4889/**
4890 * @nocollapse
4891 */
4892ApplicationRef_.ctorParameters = () => [
4893 { type: NgZone, },
4894 { type: Console, },
4895 { type: Injector, },
4896 { type: ErrorHandler, },
4897 { type: ComponentFactoryResolver, },
4898 { type: ApplicationInitStatus, },
4899];
4900/**
4901 * @template T
4902 * @param {?} list
4903 * @param {?} el
4904 * @return {?}
4905 */
4906function remove(list, el) {
4907 const /** @type {?} */ index = list.indexOf(el);
4908 if (index > -1) {
4909 list.splice(index, 1);
4910 }
4911}
4912
4913/**
4914 * @license
4915 * Copyright Google Inc. All Rights Reserved.
4916 *
4917 * Use of this source code is governed by an MIT-style license that can be
4918 * found in the LICENSE file at https://angular.io/license
4919 */
4920// Public API for Zone
4921
4922/**
4923 * @license
4924 * Copyright Google Inc. All Rights Reserved.
4925 *
4926 * Use of this source code is governed by an MIT-style license that can be
4927 * found in the LICENSE file at https://angular.io/license
4928 */
4929/**
4930 * @deprecated Use `RendererType2` (and `Renderer2`) instead.
4931 */
4932class RenderComponentType {
4933 /**
4934 * @param {?} id
4935 * @param {?} templateUrl
4936 * @param {?} slotCount
4937 * @param {?} encapsulation
4938 * @param {?} styles
4939 * @param {?} animations
4940 */
4941 constructor(id, templateUrl, slotCount, encapsulation, styles, animations) {
4942 this.id = id;
4943 this.templateUrl = templateUrl;
4944 this.slotCount = slotCount;
4945 this.encapsulation = encapsulation;
4946 this.styles = styles;
4947 this.animations = animations;
4948 }
4949}
4950/**
4951 * @deprecated Debug info is handeled internally in the view engine now.
4952 * @abstract
4953 */
4954class RenderDebugInfo {
4955 /**
4956 * @abstract
4957 * @return {?}
4958 */
4959 injector() { }
4960 /**
4961 * @abstract
4962 * @return {?}
4963 */
4964 component() { }
4965 /**
4966 * @abstract
4967 * @return {?}
4968 */
4969 providerTokens() { }
4970 /**
4971 * @abstract
4972 * @return {?}
4973 */
4974 references() { }
4975 /**
4976 * @abstract
4977 * @return {?}
4978 */
4979 context() { }
4980 /**
4981 * @abstract
4982 * @return {?}
4983 */
4984 source() { }
4985}
4986/**
4987 * @deprecated Use the `Renderer2` instead.
4988 * @abstract
4989 */
4990class Renderer {
4991 /**
4992 * @abstract
4993 * @param {?} selectorOrNode
4994 * @param {?=} debugInfo
4995 * @return {?}
4996 */
4997 selectRootElement(selectorOrNode, debugInfo) { }
4998 /**
4999 * @abstract
5000 * @param {?} parentElement
5001 * @param {?} name
5002 * @param {?=} debugInfo
5003 * @return {?}
5004 */
5005 createElement(parentElement, name, debugInfo) { }
5006 /**
5007 * @abstract
5008 * @param {?} hostElement
5009 * @return {?}
5010 */
5011 createViewRoot(hostElement) { }
5012 /**
5013 * @abstract
5014 * @param {?} parentElement
5015 * @param {?=} debugInfo
5016 * @return {?}
5017 */
5018 createTemplateAnchor(parentElement, debugInfo) { }
5019 /**
5020 * @abstract
5021 * @param {?} parentElement
5022 * @param {?} value
5023 * @param {?=} debugInfo
5024 * @return {?}
5025 */
5026 createText(parentElement, value, debugInfo) { }
5027 /**
5028 * @abstract
5029 * @param {?} parentElement
5030 * @param {?} nodes
5031 * @return {?}
5032 */
5033 projectNodes(parentElement, nodes) { }
5034 /**
5035 * @abstract
5036 * @param {?} node
5037 * @param {?} viewRootNodes
5038 * @return {?}
5039 */
5040 attachViewAfter(node, viewRootNodes) { }
5041 /**
5042 * @abstract
5043 * @param {?} viewRootNodes
5044 * @return {?}
5045 */
5046 detachView(viewRootNodes) { }
5047 /**
5048 * @abstract
5049 * @param {?} hostElement
5050 * @param {?} viewAllNodes
5051 * @return {?}
5052 */
5053 destroyView(hostElement, viewAllNodes) { }
5054 /**
5055 * @abstract
5056 * @param {?} renderElement
5057 * @param {?} name
5058 * @param {?} callback
5059 * @return {?}
5060 */
5061 listen(renderElement, name, callback) { }
5062 /**
5063 * @abstract
5064 * @param {?} target
5065 * @param {?} name
5066 * @param {?} callback
5067 * @return {?}
5068 */
5069 listenGlobal(target, name, callback) { }
5070 /**
5071 * @abstract
5072 * @param {?} renderElement
5073 * @param {?} propertyName
5074 * @param {?} propertyValue
5075 * @return {?}
5076 */
5077 setElementProperty(renderElement, propertyName, propertyValue) { }
5078 /**
5079 * @abstract
5080 * @param {?} renderElement
5081 * @param {?} attributeName
5082 * @param {?} attributeValue
5083 * @return {?}
5084 */
5085 setElementAttribute(renderElement, attributeName, attributeValue) { }
5086 /**
5087 * Used only in debug mode to serialize property changes to dom nodes as attributes.
5088 * @abstract
5089 * @param {?} renderElement
5090 * @param {?} propertyName
5091 * @param {?} propertyValue
5092 * @return {?}
5093 */
5094 setBindingDebugInfo(renderElement, propertyName, propertyValue) { }
5095 /**
5096 * @abstract
5097 * @param {?} renderElement
5098 * @param {?} className
5099 * @param {?} isAdd
5100 * @return {?}
5101 */
5102 setElementClass(renderElement, className, isAdd) { }
5103 /**
5104 * @abstract
5105 * @param {?} renderElement
5106 * @param {?} styleName
5107 * @param {?} styleValue
5108 * @return {?}
5109 */
5110 setElementStyle(renderElement, styleName, styleValue) { }
5111 /**
5112 * @abstract
5113 * @param {?} renderElement
5114 * @param {?} methodName
5115 * @param {?=} args
5116 * @return {?}
5117 */
5118 invokeElementMethod(renderElement, methodName, args) { }
5119 /**
5120 * @abstract
5121 * @param {?} renderNode
5122 * @param {?} text
5123 * @return {?}
5124 */
5125 setText(renderNode, text) { }
5126 /**
5127 * @abstract
5128 * @param {?} element
5129 * @param {?} startingStyles
5130 * @param {?} keyframes
5131 * @param {?} duration
5132 * @param {?} delay
5133 * @param {?} easing
5134 * @param {?=} previousPlayers
5135 * @return {?}
5136 */
5137 animate(element, startingStyles, keyframes, duration, delay, easing, previousPlayers) { }
5138}
5139const Renderer2Interceptor = new InjectionToken('Renderer2Interceptor');
5140/**
5141 * Injectable service that provides a low-level interface for modifying the UI.
5142 *
5143 * Use this service to bypass Angular's templating and make custom UI changes that can't be
5144 * expressed declaratively. For example if you need to set a property or an attribute whose name is
5145 * not statically known, use {\@link #setElementProperty} or {\@link #setElementAttribute}
5146 * respectively.
5147 *
5148 * If you are implementing a custom renderer, you must implement this interface.
5149 *
5150 * The default Renderer implementation is `DomRenderer`. Also available is `WebWorkerRenderer`.
5151 *
5152 * @deprecated Use `RendererFactory2` instead.
5153 * @abstract
5154 */
5155class RootRenderer {
5156 /**
5157 * @abstract
5158 * @param {?} componentType
5159 * @return {?}
5160 */
5161 renderComponent(componentType) { }
5162}
5163/**
5164 * \@experimental
5165 * @abstract
5166 */
5167class RendererFactory2 {
5168 /**
5169 * @abstract
5170 * @param {?} hostElement
5171 * @param {?} type
5172 * @return {?}
5173 */
5174 createRenderer(hostElement, type) { }
5175}
5176let RendererStyleFlags2 = {};
5177RendererStyleFlags2.Important = 1;
5178RendererStyleFlags2.DashCase = 2;
5179RendererStyleFlags2[RendererStyleFlags2.Important] = "Important";
5180RendererStyleFlags2[RendererStyleFlags2.DashCase] = "DashCase";
5181/**
5182 * \@experimental
5183 * @abstract
5184 */
5185class Renderer2 {
5186 /**
5187 * This field can be used to store arbitrary data on this renderer instance.
5188 * This is useful for renderers that delegate to other renderers.
5189 * @abstract
5190 * @return {?}
5191 */
5192 data() { }
5193 /**
5194 * @abstract
5195 * @return {?}
5196 */
5197 destroy() { }
5198 /**
5199 * @abstract
5200 * @param {?} name
5201 * @param {?=} namespace
5202 * @return {?}
5203 */
5204 createElement(name, namespace) { }
5205 /**
5206 * @abstract
5207 * @param {?} value
5208 * @return {?}
5209 */
5210 createComment(value) { }
5211 /**
5212 * @abstract
5213 * @param {?} value
5214 * @return {?}
5215 */
5216 createText(value) { }
5217 /**
5218 * @abstract
5219 * @param {?} parent
5220 * @param {?} newChild
5221 * @return {?}
5222 */
5223 appendChild(parent, newChild) { }
5224 /**
5225 * @abstract
5226 * @param {?} parent
5227 * @param {?} newChild
5228 * @param {?} refChild
5229 * @return {?}
5230 */
5231 insertBefore(parent, newChild, refChild) { }
5232 /**
5233 * @abstract
5234 * @param {?} parent
5235 * @param {?} oldChild
5236 * @return {?}
5237 */
5238 removeChild(parent, oldChild) { }
5239 /**
5240 * @abstract
5241 * @param {?} selectorOrNode
5242 * @return {?}
5243 */
5244 selectRootElement(selectorOrNode) { }
5245 /**
5246 * Attention: On WebWorkers, this will always return a value,
5247 * as we are asking for a result synchronously. I.e.
5248 * the caller can't rely on checking whether this is null or not.
5249 * @abstract
5250 * @param {?} node
5251 * @return {?}
5252 */
5253 parentNode(node) { }
5254 /**
5255 * Attention: On WebWorkers, this will always return a value,
5256 * as we are asking for a result synchronously. I.e.
5257 * the caller can't rely on checking whether this is null or not.
5258 * @abstract
5259 * @param {?} node
5260 * @return {?}
5261 */
5262 nextSibling(node) { }
5263 /**
5264 * @abstract
5265 * @param {?} el
5266 * @param {?} name
5267 * @param {?} value
5268 * @param {?=} namespace
5269 * @return {?}
5270 */
5271 setAttribute(el, name, value, namespace) { }
5272 /**
5273 * @abstract
5274 * @param {?} el
5275 * @param {?} name
5276 * @param {?=} namespace
5277 * @return {?}
5278 */
5279 removeAttribute(el, name, namespace) { }
5280 /**
5281 * @abstract
5282 * @param {?} el
5283 * @param {?} name
5284 * @return {?}
5285 */
5286 addClass(el, name) { }
5287 /**
5288 * @abstract
5289 * @param {?} el
5290 * @param {?} name
5291 * @return {?}
5292 */
5293 removeClass(el, name) { }
5294 /**
5295 * @abstract
5296 * @param {?} el
5297 * @param {?} style
5298 * @param {?} value
5299 * @param {?=} flags
5300 * @return {?}
5301 */
5302 setStyle(el, style, value, flags) { }
5303 /**
5304 * @abstract
5305 * @param {?} el
5306 * @param {?} style
5307 * @param {?=} flags
5308 * @return {?}
5309 */
5310 removeStyle(el, style, flags) { }
5311 /**
5312 * @abstract
5313 * @param {?} el
5314 * @param {?} name
5315 * @param {?} value
5316 * @return {?}
5317 */
5318 setProperty(el, name, value) { }
5319 /**
5320 * @abstract
5321 * @param {?} node
5322 * @param {?} value
5323 * @return {?}
5324 */
5325 setValue(node, value) { }
5326 /**
5327 * @abstract
5328 * @param {?} target
5329 * @param {?} eventName
5330 * @param {?} callback
5331 * @return {?}
5332 */
5333 listen(target, eventName, callback) { }
5334}
5335
5336/**
5337 * @license
5338 * Copyright Google Inc. All Rights Reserved.
5339 *
5340 * Use of this source code is governed by an MIT-style license that can be
5341 * found in the LICENSE file at https://angular.io/license
5342 */
5343// Public API for render
5344
5345class ElementRef {
5346 /**
5347 * @param {?} nativeElement
5348 */
5349 constructor(nativeElement) { this.nativeElement = nativeElement; }
5350}
5351
5352/**
5353 * @license
5354 * Copyright Google Inc. All Rights Reserved.
5355 *
5356 * Use of this source code is governed by an MIT-style license that can be
5357 * found in the LICENSE file at https://angular.io/license
5358 */
5359/**
5360 * Used to load ng module factories.
5361 * \@stable
5362 * @abstract
5363 */
5364class NgModuleFactoryLoader {
5365 /**
5366 * @abstract
5367 * @param {?} path
5368 * @return {?}
5369 */
5370 load(path) { }
5371}
5372let moduleFactories = new Map();
5373/**
5374 * Registers a loaded module. Should only be called from generated NgModuleFactory code.
5375 * \@experimental
5376 * @param {?} id
5377 * @param {?} factory
5378 * @return {?}
5379 */
5380function registerModuleFactory(id, factory) {
5381 const /** @type {?} */ existing = moduleFactories.get(id);
5382 if (existing) {
5383 throw new Error(`Duplicate module registered for ${id} - ${existing.moduleType.name} vs ${factory.moduleType.name}`);
5384 }
5385 moduleFactories.set(id, factory);
5386}
5387/**
5388 * @return {?}
5389 */
5390
5391/**
5392 * Returns the NgModuleFactory with the given id, if it exists and has been loaded.
5393 * Factories for modules that do not specify an `id` cannot be retrieved. Throws if the module
5394 * cannot be found.
5395 * \@experimental
5396 * @param {?} id
5397 * @return {?}
5398 */
5399function getModuleFactory(id) {
5400 const /** @type {?} */ factory = moduleFactories.get(id);
5401 if (!factory)
5402 throw new Error(`No module with ID ${id} loaded`);
5403 return factory;
5404}
5405
5406/**
5407 * @license
5408 * Copyright Google Inc. All Rights Reserved.
5409 *
5410 * Use of this source code is governed by an MIT-style license that can be
5411 * found in the LICENSE file at https://angular.io/license
5412 */
5413/**
5414 * An unmodifiable list of items that Angular keeps up to date when the state
5415 * of the application changes.
5416 *
5417 * The type of object that {\@link ViewChildren}, {\@link ContentChildren}, and {\@link QueryList}
5418 * provide.
5419 *
5420 * Implements an iterable interface, therefore it can be used in both ES6
5421 * javascript `for (var i of items)` loops as well as in Angular templates with
5422 * `*ngFor="let i of myList"`.
5423 *
5424 * Changes can be observed by subscribing to the changes `Observable`.
5425 *
5426 * NOTE: In the future this class will implement an `Observable` interface.
5427 *
5428 * ### Example ([live demo](http://plnkr.co/edit/RX8sJnQYl9FWuSCWme5z?p=preview))
5429 * ```typescript
5430 * \@Component({...})
5431 * class Container {
5432 * \@ViewChildren(Item) items:QueryList<Item>;
5433 * }
5434 * ```
5435 * \@stable
5436 */
5437class QueryList {
5438 constructor() {
5439 this._dirty = true;
5440 this._results = [];
5441 this._emitter = new EventEmitter();
5442 }
5443 /**
5444 * @return {?}
5445 */
5446 get changes() { return this._emitter; }
5447 /**
5448 * @return {?}
5449 */
5450 get length() { return this._results.length; }
5451 /**
5452 * @return {?}
5453 */
5454 get first() { return this._results[0]; }
5455 /**
5456 * @return {?}
5457 */
5458 get last() { return this._results[this.length - 1]; }
5459 /**
5460 * See
5461 * [Array.map](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map)
5462 * @template U
5463 * @param {?} fn
5464 * @return {?}
5465 */
5466 map(fn) { return this._results.map(fn); }
5467 /**
5468 * See
5469 * [Array.filter](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter)
5470 * @param {?} fn
5471 * @return {?}
5472 */
5473 filter(fn) {
5474 return this._results.filter(fn);
5475 }
5476 /**
5477 * See
5478 * [Array.find](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find)
5479 * @param {?} fn
5480 * @return {?}
5481 */
5482 find(fn) {
5483 return this._results.find(fn);
5484 }
5485 /**
5486 * See
5487 * [Array.reduce](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduce)
5488 * @template U
5489 * @param {?} fn
5490 * @param {?} init
5491 * @return {?}
5492 */
5493 reduce(fn, init) {
5494 return this._results.reduce(fn, init);
5495 }
5496 /**
5497 * See
5498 * [Array.forEach](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach)
5499 * @param {?} fn
5500 * @return {?}
5501 */
5502 forEach(fn) { this._results.forEach(fn); }
5503 /**
5504 * See
5505 * [Array.some](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/some)
5506 * @param {?} fn
5507 * @return {?}
5508 */
5509 some(fn) {
5510 return this._results.some(fn);
5511 }
5512 /**
5513 * @return {?}
5514 */
5515 toArray() { return this._results.slice(); }
5516 /**
5517 * @return {?}
5518 */
5519 [getSymbolIterator()]() { return ((this._results))[getSymbolIterator()](); }
5520 /**
5521 * @return {?}
5522 */
5523 toString() { return this._results.toString(); }
5524 /**
5525 * @param {?} res
5526 * @return {?}
5527 */
5528 reset(res) {
5529 this._results = flatten(res);
5530 this._dirty = false;
5531 }
5532 /**
5533 * @return {?}
5534 */
5535 notifyOnChanges() { this._emitter.emit(this); }
5536 /**
5537 * internal
5538 * @return {?}
5539 */
5540 setDirty() { this._dirty = true; }
5541 /**
5542 * internal
5543 * @return {?}
5544 */
5545 get dirty() { return this._dirty; }
5546}
5547/**
5548 * @template T
5549 * @param {?} list
5550 * @return {?}
5551 */
5552function flatten(list) {
5553 return list.reduce((flat, item) => {
5554 const /** @type {?} */ flatItem = Array.isArray(item) ? flatten(item) : item;
5555 return ((flat)).concat(flatItem);
5556 }, []);
5557}
5558
5559/**
5560 * @license
5561 * Copyright Google Inc. All Rights Reserved.
5562 *
5563 * Use of this source code is governed by an MIT-style license that can be
5564 * found in the LICENSE file at https://angular.io/license
5565 */
5566const _SEPARATOR = '#';
5567const FACTORY_CLASS_SUFFIX = 'NgFactory';
5568/**
5569 * Configuration for SystemJsNgModuleLoader.
5570 * token.
5571 *
5572 * \@experimental
5573 * @abstract
5574 */
5575class SystemJsNgModuleLoaderConfig {
5576}
5577const DEFAULT_CONFIG = {
5578 factoryPathPrefix: '',
5579 factoryPathSuffix: '.ngfactory',
5580};
5581/**
5582 * NgModuleFactoryLoader that uses SystemJS to load NgModuleFactory
5583 * \@experimental
5584 */
5585class SystemJsNgModuleLoader {
5586 /**
5587 * @param {?} _compiler
5588 * @param {?=} config
5589 */
5590 constructor(_compiler, config) {
5591 this._compiler = _compiler;
5592 this._config = config || DEFAULT_CONFIG;
5593 }
5594 /**
5595 * @param {?} path
5596 * @return {?}
5597 */
5598 load(path) {
5599 const /** @type {?} */ offlineMode = this._compiler instanceof Compiler;
5600 return offlineMode ? this.loadFactory(path) : this.loadAndCompile(path);
5601 }
5602 /**
5603 * @param {?} path
5604 * @return {?}
5605 */
5606 loadAndCompile(path) {
5607 let [module, exportName] = path.split(_SEPARATOR);
5608 if (exportName === undefined) {
5609 exportName = 'default';
5610 }
5611 return System.import(module)
5612 .then((module) => module[exportName])
5613 .then((type) => checkNotEmpty(type, module, exportName))
5614 .then((type) => this._compiler.compileModuleAsync(type));
5615 }
5616 /**
5617 * @param {?} path
5618 * @return {?}
5619 */
5620 loadFactory(path) {
5621 let [module, exportName] = path.split(_SEPARATOR);
5622 let /** @type {?} */ factoryClassSuffix = FACTORY_CLASS_SUFFIX;
5623 if (exportName === undefined) {
5624 exportName = 'default';
5625 factoryClassSuffix = '';
5626 }
5627 return System.import(this._config.factoryPathPrefix + module + this._config.factoryPathSuffix)
5628 .then((module) => module[exportName + factoryClassSuffix])
5629 .then((factory) => checkNotEmpty(factory, module, exportName));
5630 }
5631}
5632SystemJsNgModuleLoader.decorators = [
5633 { type: Injectable },
5634];
5635/**
5636 * @nocollapse
5637 */
5638SystemJsNgModuleLoader.ctorParameters = () => [
5639 { type: Compiler, },
5640 { type: SystemJsNgModuleLoaderConfig, decorators: [{ type: Optional },] },
5641];
5642/**
5643 * @param {?} value
5644 * @param {?} modulePath
5645 * @param {?} exportName
5646 * @return {?}
5647 */
5648function checkNotEmpty(value, modulePath, exportName) {
5649 if (!value) {
5650 throw new Error(`Cannot find '${exportName}' in '${modulePath}'`);
5651 }
5652 return value;
5653}
5654
5655/**
5656 * @license
5657 * Copyright Google Inc. All Rights Reserved.
5658 *
5659 * Use of this source code is governed by an MIT-style license that can be
5660 * found in the LICENSE file at https://angular.io/license
5661 */
5662/**
5663 * Represents an Embedded Template that can be used to instantiate Embedded Views.
5664 *
5665 * You can access a `TemplateRef`, in two ways. Via a directive placed on a `<ng-template>` element
5666 * (or directive prefixed with `*`) and have the `TemplateRef` for this Embedded View injected into
5667 * the constructor of the directive using the `TemplateRef` Token. Alternatively you can query for
5668 * the `TemplateRef` from a Component or a Directive via {\@link Query}.
5669 *
5670 * To instantiate Embedded Views based on a Template, use
5671 * {\@link ViewContainerRef#createEmbeddedView}, which will create the View and attach it to the
5672 * View Container.
5673 * \@stable
5674 * @abstract
5675 */
5676class TemplateRef {
5677 /**
5678 * @abstract
5679 * @return {?}
5680 */
5681 elementRef() { }
5682 /**
5683 * @abstract
5684 * @param {?} context
5685 * @return {?}
5686 */
5687 createEmbeddedView(context) { }
5688}
5689
5690/**
5691 * @license
5692 * Copyright Google Inc. All Rights Reserved.
5693 *
5694 * Use of this source code is governed by an MIT-style license that can be
5695 * found in the LICENSE file at https://angular.io/license
5696 */
5697/**
5698 * Represents a container where one or more Views can be attached.
5699 *
5700 * The container can contain two kinds of Views. Host Views, created by instantiating a
5701 * {\@link Component} via {\@link #createComponent}, and Embedded Views, created by instantiating an
5702 * {\@link TemplateRef Embedded Template} via {\@link #createEmbeddedView}.
5703 *
5704 * The location of the View Container within the containing View is specified by the Anchor
5705 * `element`. Each View Container can have only one Anchor Element and each Anchor Element can only
5706 * have a single View Container.
5707 *
5708 * Root elements of Views attached to this container become siblings of the Anchor Element in
5709 * the Rendered View.
5710 *
5711 * To access a `ViewContainerRef` of an Element, you can either place a {\@link Directive} injected
5712 * with `ViewContainerRef` on the Element, or you obtain it via a {\@link ViewChild} query.
5713 * \@stable
5714 * @abstract
5715 */
5716class ViewContainerRef {
5717 /**
5718 * Anchor element that specifies the location of this container in the containing View.
5719 * <!-- TODO: rename to anchorElement -->
5720 * @abstract
5721 * @return {?}
5722 */
5723 element() { }
5724 /**
5725 * @abstract
5726 * @return {?}
5727 */
5728 injector() { }
5729 /**
5730 * @abstract
5731 * @return {?}
5732 */
5733 parentInjector() { }
5734 /**
5735 * Destroys all Views in this container.
5736 * @abstract
5737 * @return {?}
5738 */
5739 clear() { }
5740 /**
5741 * Returns the {\@link ViewRef} for the View located in this container at the specified index.
5742 * @abstract
5743 * @param {?} index
5744 * @return {?}
5745 */
5746 get(index) { }
5747 /**
5748 * Returns the number of Views currently attached to this container.
5749 * @abstract
5750 * @return {?}
5751 */
5752 length() { }
5753 /**
5754 * Instantiates an Embedded View based on the {\@link TemplateRef `templateRef`} and inserts it
5755 * into this container at the specified `index`.
5756 *
5757 * If `index` is not specified, the new View will be inserted as the last View in the container.
5758 *
5759 * Returns the {\@link ViewRef} for the newly created View.
5760 * @abstract
5761 * @template C
5762 * @param {?} templateRef
5763 * @param {?=} context
5764 * @param {?=} index
5765 * @return {?}
5766 */
5767 createEmbeddedView(templateRef, context, index) { }
5768 /**
5769 * Instantiates a single {\@link Component} and inserts its Host View into this container at the
5770 * specified `index`.
5771 *
5772 * The component is instantiated using its {\@link ComponentFactory} which can be
5773 * obtained via {\@link ComponentFactoryResolver#resolveComponentFactory}.
5774 *
5775 * If `index` is not specified, the new View will be inserted as the last View in the container.
5776 *
5777 * You can optionally specify the {\@link Injector} that will be used as parent for the Component.
5778 *
5779 * Returns the {\@link ComponentRef} of the Host View created for the newly instantiated Component.
5780 * @abstract
5781 * @template C
5782 * @param {?} componentFactory
5783 * @param {?=} index
5784 * @param {?=} injector
5785 * @param {?=} projectableNodes
5786 * @param {?=} ngModule
5787 * @return {?}
5788 */
5789 createComponent(componentFactory, index, injector, projectableNodes, ngModule) { }
5790 /**
5791 * Inserts a View identified by a {\@link ViewRef} into the container at the specified `index`.
5792 *
5793 * If `index` is not specified, the new View will be inserted as the last View in the container.
5794 *
5795 * Returns the inserted {\@link ViewRef}.
5796 * @abstract
5797 * @param {?} viewRef
5798 * @param {?=} index
5799 * @return {?}
5800 */
5801 insert(viewRef, index) { }
5802 /**
5803 * Moves a View identified by a {\@link ViewRef} into the container at the specified `index`.
5804 *
5805 * Returns the inserted {\@link ViewRef}.
5806 * @abstract
5807 * @param {?} viewRef
5808 * @param {?} currentIndex
5809 * @return {?}
5810 */
5811 move(viewRef, currentIndex) { }
5812 /**
5813 * Returns the index of the View, specified via {\@link ViewRef}, within the current container or
5814 * `-1` if this container doesn't contain the View.
5815 * @abstract
5816 * @param {?} viewRef
5817 * @return {?}
5818 */
5819 indexOf(viewRef) { }
5820 /**
5821 * Destroys a View attached to this container at the specified `index`.
5822 *
5823 * If `index` is not specified, the last View in the container will be removed.
5824 * @abstract
5825 * @param {?=} index
5826 * @return {?}
5827 */
5828 remove(index) { }
5829 /**
5830 * Use along with {\@link #insert} to move a View within the current container.
5831 *
5832 * If the `index` param is omitted, the last {\@link ViewRef} is detached.
5833 * @abstract
5834 * @param {?=} index
5835 * @return {?}
5836 */
5837 detach(index) { }
5838}
5839
5840/**
5841 * \@stable
5842 * @abstract
5843 */
5844class ChangeDetectorRef {
5845 /**
5846 * Marks all {\@link ChangeDetectionStrategy#OnPush} ancestors as to be checked.
5847 *
5848 * <!-- TODO: Add a link to a chapter on OnPush components -->
5849 *
5850 * ### Example ([live demo](http://plnkr.co/edit/GC512b?p=preview))
5851 *
5852 * ```typescript
5853 * \@Component({
5854 * selector: 'cmp',
5855 * changeDetection: ChangeDetectionStrategy.OnPush,
5856 * template: `Number of ticks: {{numberOfTicks}}`
5857 * })
5858 * class Cmp {
5859 * numberOfTicks = 0;
5860 *
5861 * constructor(ref: ChangeDetectorRef) {
5862 * setInterval(() => {
5863 * this.numberOfTicks ++
5864 * // the following is required, otherwise the view will not be updated
5865 * this.ref.markForCheck();
5866 * }, 1000);
5867 * }
5868 * }
5869 *
5870 * \@Component({
5871 * selector: 'app',
5872 * changeDetection: ChangeDetectionStrategy.OnPush,
5873 * template: `
5874 * <cmp><cmp>
5875 * `,
5876 * })
5877 * class App {
5878 * }
5879 * ```
5880 * @abstract
5881 * @return {?}
5882 */
5883 markForCheck() { }
5884 /**
5885 * Detaches the change detector from the change detector tree.
5886 *
5887 * The detached change detector will not be checked until it is reattached.
5888 *
5889 * This can also be used in combination with {\@link ChangeDetectorRef#detectChanges} to implement
5890 * local change
5891 * detection checks.
5892 *
5893 * <!-- TODO: Add a link to a chapter on detach/reattach/local digest -->
5894 * <!-- TODO: Add a live demo once ref.detectChanges is merged into master -->
5895 *
5896 * ### Example
5897 *
5898 * The following example defines a component with a large list of readonly data.
5899 * Imagine the data changes constantly, many times per second. For performance reasons,
5900 * we want to check and update the list every five seconds. We can do that by detaching
5901 * the component's change detector and doing a local check every five seconds.
5902 *
5903 * ```typescript
5904 * class DataProvider {
5905 * // in a real application the returned data will be different every time
5906 * get data() {
5907 * return [1,2,3,4,5];
5908 * }
5909 * }
5910 *
5911 * \@Component({
5912 * selector: 'giant-list',
5913 * template: `
5914 * <li *ngFor="let d of dataProvider.data">Data {{d}}</lig>
5915 * `,
5916 * })
5917 * class GiantList {
5918 * constructor(private ref: ChangeDetectorRef, private dataProvider:DataProvider) {
5919 * ref.detach();
5920 * setInterval(() => {
5921 * this.ref.detectChanges();
5922 * }, 5000);
5923 * }
5924 * }
5925 *
5926 * \@Component({
5927 * selector: 'app',
5928 * providers: [DataProvider],
5929 * template: `
5930 * <giant-list><giant-list>
5931 * `,
5932 * })
5933 * class App {
5934 * }
5935 * ```
5936 * @abstract
5937 * @return {?}
5938 */
5939 detach() { }
5940 /**
5941 * Checks the change detector and its children.
5942 *
5943 * This can also be used in combination with {\@link ChangeDetectorRef#detach} to implement local
5944 * change detection
5945 * checks.
5946 *
5947 * <!-- TODO: Add a link to a chapter on detach/reattach/local digest -->
5948 * <!-- TODO: Add a live demo once ref.detectChanges is merged into master -->
5949 *
5950 * ### Example
5951 *
5952 * The following example defines a component with a large list of readonly data.
5953 * Imagine, the data changes constantly, many times per second. For performance reasons,
5954 * we want to check and update the list every five seconds.
5955 *
5956 * We can do that by detaching the component's change detector and doing a local change detection
5957 * check
5958 * every five seconds.
5959 *
5960 * See {\@link ChangeDetectorRef#detach} for more information.
5961 * @abstract
5962 * @return {?}
5963 */
5964 detectChanges() { }
5965 /**
5966 * Checks the change detector and its children, and throws if any changes are detected.
5967 *
5968 * This is used in development mode to verify that running change detection doesn't introduce
5969 * other changes.
5970 * @abstract
5971 * @return {?}
5972 */
5973 checkNoChanges() { }
5974 /**
5975 * Reattach the change detector to the change detector tree.
5976 *
5977 * This also marks OnPush ancestors as to be checked. This reattached change detector will be
5978 * checked during the next change detection run.
5979 *
5980 * <!-- TODO: Add a link to a chapter on detach/reattach/local digest -->
5981 *
5982 * ### Example ([live demo](http://plnkr.co/edit/aUhZha?p=preview))
5983 *
5984 * The following example creates a component displaying `live` data. The component will detach
5985 * its change detector from the main change detector tree when the component's live property
5986 * is set to false.
5987 *
5988 * ```typescript
5989 * class DataProvider {
5990 * data = 1;
5991 *
5992 * constructor() {
5993 * setInterval(() => {
5994 * this.data = this.data * 2;
5995 * }, 500);
5996 * }
5997 * }
5998 *
5999 * \@Component({
6000 * selector: 'live-data',
6001 * inputs: ['live'],
6002 * template: 'Data: {{dataProvider.data}}'
6003 * })
6004 * class LiveData {
6005 * constructor(private ref: ChangeDetectorRef, private dataProvider:DataProvider) {}
6006 *
6007 * set live(value) {
6008 * if (value)
6009 * this.ref.reattach();
6010 * else
6011 * this.ref.detach();
6012 * }
6013 * }
6014 *
6015 * \@Component({
6016 * selector: 'app',
6017 * providers: [DataProvider],
6018 * template: `
6019 * Live Update: <input type="checkbox" [(ngModel)]="live">
6020 * <live-data [live]="live"><live-data>
6021 * `,
6022 * })
6023 * class App {
6024 * live = true;
6025 * }
6026 * ```
6027 * @abstract
6028 * @return {?}
6029 */
6030 reattach() { }
6031}
6032
6033/**
6034 * @license
6035 * Copyright Google Inc. All Rights Reserved.
6036 *
6037 * Use of this source code is governed by an MIT-style license that can be
6038 * found in the LICENSE file at https://angular.io/license
6039 */
6040/**
6041 * \@stable
6042 * @abstract
6043 */
6044class ViewRef extends ChangeDetectorRef {
6045 /**
6046 * Destroys the view and all of the data structures associated with it.
6047 * @abstract
6048 * @return {?}
6049 */
6050 destroy() { }
6051 /**
6052 * @abstract
6053 * @return {?}
6054 */
6055 destroyed() { }
6056 /**
6057 * @abstract
6058 * @param {?} callback
6059 * @return {?}
6060 */
6061 onDestroy(callback) { }
6062}
6063/**
6064 * Represents an Angular View.
6065 *
6066 * <!-- TODO: move the next two paragraphs to the dev guide -->
6067 * A View is a fundamental building block of the application UI. It is the smallest grouping of
6068 * Elements which are created and destroyed together.
6069 *
6070 * Properties of elements in a View can change, but the structure (number and order) of elements in
6071 * a View cannot. Changing the structure of Elements can only be done by inserting, moving or
6072 * removing nested Views via a {\@link ViewContainerRef}. Each View can contain many View Containers.
6073 * <!-- /TODO -->
6074 *
6075 * ### Example
6076 *
6077 * Given this template...
6078 *
6079 * ```
6080 * Count: {{items.length}}
6081 * <ul>
6082 * <li *ngFor="let item of items">{{item}}</li>
6083 * </ul>
6084 * ```
6085 *
6086 * We have two {\@link TemplateRef}s:
6087 *
6088 * Outer {\@link TemplateRef}:
6089 * ```
6090 * Count: {{items.length}}
6091 * <ul>
6092 * <ng-template ngFor let-item [ngForOf]="items"></ng-template>
6093 * </ul>
6094 * ```
6095 *
6096 * Inner {\@link TemplateRef}:
6097 * ```
6098 * <li>{{item}}</li>
6099 * ```
6100 *
6101 * Notice that the original template is broken down into two separate {\@link TemplateRef}s.
6102 *
6103 * The outer/inner {\@link TemplateRef}s are then assembled into views like so:
6104 *
6105 * ```
6106 * <!-- ViewRef: outer-0 -->
6107 * Count: 2
6108 * <ul>
6109 * <ng-template view-container-ref></ng-template>
6110 * <!-- ViewRef: inner-1 --><li>first</li><!-- /ViewRef: inner-1 -->
6111 * <!-- ViewRef: inner-2 --><li>second</li><!-- /ViewRef: inner-2 -->
6112 * </ul>
6113 * <!-- /ViewRef: outer-0 -->
6114 * ```
6115 * \@experimental
6116 * @abstract
6117 */
6118class EmbeddedViewRef extends ViewRef {
6119 /**
6120 * @abstract
6121 * @return {?}
6122 */
6123 context() { }
6124 /**
6125 * @abstract
6126 * @return {?}
6127 */
6128 rootNodes() { }
6129}
6130
6131/**
6132 * @license
6133 * Copyright Google Inc. All Rights Reserved.
6134 *
6135 * Use of this source code is governed by an MIT-style license that can be
6136 * found in the LICENSE file at https://angular.io/license
6137 */
6138// Public API for compiler
6139
6140/**
6141 * @license
6142 * Copyright Google Inc. All Rights Reserved.
6143 *
6144 * Use of this source code is governed by an MIT-style license that can be
6145 * found in the LICENSE file at https://angular.io/license
6146 */
6147class EventListener {
6148 /**
6149 * @param {?} name
6150 * @param {?} callback
6151 */
6152 constructor(name, callback) {
6153 this.name = name;
6154 this.callback = callback;
6155 }
6156 ;
6157}
6158/**
6159 * \@experimental All debugging apis are currently experimental.
6160 */
6161class DebugNode {
6162 /**
6163 * @param {?} nativeNode
6164 * @param {?} parent
6165 * @param {?} _debugContext
6166 */
6167 constructor(nativeNode, parent, _debugContext) {
6168 this._debugContext = _debugContext;
6169 this.nativeNode = nativeNode;
6170 if (parent && parent instanceof DebugElement) {
6171 parent.addChild(this);
6172 }
6173 else {
6174 this.parent = null;
6175 }
6176 this.listeners = [];
6177 }
6178 /**
6179 * @return {?}
6180 */
6181 get injector() { return this._debugContext.injector; }
6182 /**
6183 * @return {?}
6184 */
6185 get componentInstance() { return this._debugContext.component; }
6186 /**
6187 * @return {?}
6188 */
6189 get context() { return this._debugContext.context; }
6190 /**
6191 * @return {?}
6192 */
6193 get references() { return this._debugContext.references; }
6194 /**
6195 * @return {?}
6196 */
6197 get providerTokens() { return this._debugContext.providerTokens; }
6198 /**
6199 * @deprecated since v4
6200 * @return {?}
6201 */
6202 get source() { return 'Deprecated since v4'; }
6203}
6204/**
6205 * \@experimental All debugging apis are currently experimental.
6206 */
6207class DebugElement extends DebugNode {
6208 /**
6209 * @param {?} nativeNode
6210 * @param {?} parent
6211 * @param {?} _debugContext
6212 */
6213 constructor(nativeNode, parent, _debugContext) {
6214 super(nativeNode, parent, _debugContext);
6215 this.properties = {};
6216 this.attributes = {};
6217 this.classes = {};
6218 this.styles = {};
6219 this.childNodes = [];
6220 this.nativeElement = nativeNode;
6221 }
6222 /**
6223 * @param {?} child
6224 * @return {?}
6225 */
6226 addChild(child) {
6227 if (child) {
6228 this.childNodes.push(child);
6229 child.parent = this;
6230 }
6231 }
6232 /**
6233 * @param {?} child
6234 * @return {?}
6235 */
6236 removeChild(child) {
6237 const /** @type {?} */ childIndex = this.childNodes.indexOf(child);
6238 if (childIndex !== -1) {
6239 child.parent = null;
6240 this.childNodes.splice(childIndex, 1);
6241 }
6242 }
6243 /**
6244 * @param {?} child
6245 * @param {?} newChildren
6246 * @return {?}
6247 */
6248 insertChildrenAfter(child, newChildren) {
6249 const /** @type {?} */ siblingIndex = this.childNodes.indexOf(child);
6250 if (siblingIndex !== -1) {
6251 this.childNodes.splice(siblingIndex + 1, 0, ...newChildren);
6252 newChildren.forEach(c => {
6253 if (c.parent) {
6254 c.parent.removeChild(c);
6255 }
6256 c.parent = this;
6257 });
6258 }
6259 }
6260 /**
6261 * @param {?} refChild
6262 * @param {?} newChild
6263 * @return {?}
6264 */
6265 insertBefore(refChild, newChild) {
6266 const /** @type {?} */ refIndex = this.childNodes.indexOf(refChild);
6267 if (refIndex === -1) {
6268 this.addChild(newChild);
6269 }
6270 else {
6271 if (newChild.parent) {
6272 newChild.parent.removeChild(newChild);
6273 }
6274 newChild.parent = this;
6275 this.childNodes.splice(refIndex, 0, newChild);
6276 }
6277 }
6278 /**
6279 * @param {?} predicate
6280 * @return {?}
6281 */
6282 query(predicate) {
6283 const /** @type {?} */ results = this.queryAll(predicate);
6284 return results[0] || null;
6285 }
6286 /**
6287 * @param {?} predicate
6288 * @return {?}
6289 */
6290 queryAll(predicate) {
6291 const /** @type {?} */ matches = [];
6292 _queryElementChildren(this, predicate, matches);
6293 return matches;
6294 }
6295 /**
6296 * @param {?} predicate
6297 * @return {?}
6298 */
6299 queryAllNodes(predicate) {
6300 const /** @type {?} */ matches = [];
6301 _queryNodeChildren(this, predicate, matches);
6302 return matches;
6303 }
6304 /**
6305 * @return {?}
6306 */
6307 get children() {
6308 return (this.childNodes.filter((node) => node instanceof DebugElement));
6309 }
6310 /**
6311 * @param {?} eventName
6312 * @param {?} eventObj
6313 * @return {?}
6314 */
6315 triggerEventHandler(eventName, eventObj) {
6316 this.listeners.forEach((listener) => {
6317 if (listener.name == eventName) {
6318 listener.callback(eventObj);
6319 }
6320 });
6321 }
6322}
6323/**
6324 * \@experimental
6325 * @param {?} debugEls
6326 * @return {?}
6327 */
6328function asNativeElements(debugEls) {
6329 return debugEls.map((el) => el.nativeElement);
6330}
6331/**
6332 * @param {?} element
6333 * @param {?} predicate
6334 * @param {?} matches
6335 * @return {?}
6336 */
6337function _queryElementChildren(element, predicate, matches) {
6338 element.childNodes.forEach(node => {
6339 if (node instanceof DebugElement) {
6340 if (predicate(node)) {
6341 matches.push(node);
6342 }
6343 _queryElementChildren(node, predicate, matches);
6344 }
6345 });
6346}
6347/**
6348 * @param {?} parentNode
6349 * @param {?} predicate
6350 * @param {?} matches
6351 * @return {?}
6352 */
6353function _queryNodeChildren(parentNode, predicate, matches) {
6354 if (parentNode instanceof DebugElement) {
6355 parentNode.childNodes.forEach(node => {
6356 if (predicate(node)) {
6357 matches.push(node);
6358 }
6359 if (node instanceof DebugElement) {
6360 _queryNodeChildren(node, predicate, matches);
6361 }
6362 });
6363 }
6364}
6365// Need to keep the nodes in a global Map so that multiple angular apps are supported.
6366const _nativeNodeToDebugNode = new Map();
6367/**
6368 * \@experimental
6369 * @param {?} nativeNode
6370 * @return {?}
6371 */
6372function getDebugNode(nativeNode) {
6373 return _nativeNodeToDebugNode.get(nativeNode) || null;
6374}
6375/**
6376 * @return {?}
6377 */
6378
6379/**
6380 * @param {?} node
6381 * @return {?}
6382 */
6383function indexDebugNode(node) {
6384 _nativeNodeToDebugNode.set(node.nativeNode, node);
6385}
6386/**
6387 * @param {?} node
6388 * @return {?}
6389 */
6390function removeDebugNodeFromIndex(node) {
6391 _nativeNodeToDebugNode.delete(node.nativeNode);
6392}
6393
6394/**
6395 * @license
6396 * Copyright Google Inc. All Rights Reserved.
6397 *
6398 * Use of this source code is governed by an MIT-style license that can be
6399 * found in the LICENSE file at https://angular.io/license
6400 */
6401/**
6402 * @param {?} a
6403 * @param {?} b
6404 * @return {?}
6405 */
6406function devModeEqual(a, b) {
6407 const /** @type {?} */ isListLikeIterableA = isListLikeIterable(a);
6408 const /** @type {?} */ isListLikeIterableB = isListLikeIterable(b);
6409 if (isListLikeIterableA && isListLikeIterableB) {
6410 return areIterablesEqual(a, b, devModeEqual);
6411 }
6412 else {
6413 const /** @type {?} */ isAObject = a && (typeof a === 'object' || typeof a === 'function');
6414 const /** @type {?} */ isBObject = b && (typeof b === 'object' || typeof b === 'function');
6415 if (!isListLikeIterableA && isAObject && !isListLikeIterableB && isBObject) {
6416 return true;
6417 }
6418 else {
6419 return looseIdentical(a, b);
6420 }
6421 }
6422}
6423/**
6424 * Indicates that the result of a {\@link Pipe} transformation has changed even though the
6425 * reference
6426 * has not changed.
6427 *
6428 * The wrapped value will be unwrapped by change detection, and the unwrapped value will be stored.
6429 *
6430 * Example:
6431 *
6432 * ```
6433 * if (this._latestValue === this._latestReturnedValue) {
6434 * return this._latestReturnedValue;
6435 * } else {
6436 * this._latestReturnedValue = this._latestValue;
6437 * return WrappedValue.wrap(this._latestValue); // this will force update
6438 * }
6439 * ```
6440 * \@stable
6441 */
6442class WrappedValue {
6443 /**
6444 * @param {?} wrapped
6445 */
6446 constructor(wrapped) {
6447 this.wrapped = wrapped;
6448 }
6449 /**
6450 * @param {?} value
6451 * @return {?}
6452 */
6453 static wrap(value) { return new WrappedValue(value); }
6454}
6455/**
6456 * Helper class for unwrapping WrappedValue s
6457 */
6458class ValueUnwrapper {
6459 constructor() {
6460 this.hasWrappedValue = false;
6461 }
6462 /**
6463 * @param {?} value
6464 * @return {?}
6465 */
6466 unwrap(value) {
6467 if (value instanceof WrappedValue) {
6468 this.hasWrappedValue = true;
6469 return value.wrapped;
6470 }
6471 return value;
6472 }
6473 /**
6474 * @return {?}
6475 */
6476 reset() { this.hasWrappedValue = false; }
6477}
6478/**
6479 * Represents a basic change from a previous to a new value.
6480 * \@stable
6481 */
6482class SimpleChange {
6483 /**
6484 * @param {?} previousValue
6485 * @param {?} currentValue
6486 * @param {?} firstChange
6487 */
6488 constructor(previousValue, currentValue, firstChange) {
6489 this.previousValue = previousValue;
6490 this.currentValue = currentValue;
6491 this.firstChange = firstChange;
6492 }
6493 /**
6494 * Check whether the new value is the first value assigned.
6495 * @return {?}
6496 */
6497 isFirstChange() { return this.firstChange; }
6498}
6499/**
6500 * @param {?} obj
6501 * @return {?}
6502 */
6503function isListLikeIterable(obj) {
6504 if (!isJsObject(obj))
6505 return false;
6506 return Array.isArray(obj) ||
6507 (!(obj instanceof Map) &&
6508 getSymbolIterator() in obj); // JS Iterable have a Symbol.iterator prop
6509}
6510/**
6511 * @param {?} a
6512 * @param {?} b
6513 * @param {?} comparator
6514 * @return {?}
6515 */
6516function areIterablesEqual(a, b, comparator) {
6517 const /** @type {?} */ iterator1 = a[getSymbolIterator()]();
6518 const /** @type {?} */ iterator2 = b[getSymbolIterator()]();
6519 while (true) {
6520 const /** @type {?} */ item1 = iterator1.next();
6521 const /** @type {?} */ item2 = iterator2.next();
6522 if (item1.done && item2.done)
6523 return true;
6524 if (item1.done || item2.done)
6525 return false;
6526 if (!comparator(item1.value, item2.value))
6527 return false;
6528 }
6529}
6530/**
6531 * @param {?} obj
6532 * @param {?} fn
6533 * @return {?}
6534 */
6535function iterateListLike(obj, fn) {
6536 if (Array.isArray(obj)) {
6537 for (let /** @type {?} */ i = 0; i < obj.length; i++) {
6538 fn(obj[i]);
6539 }
6540 }
6541 else {
6542 const /** @type {?} */ iterator = obj[getSymbolIterator()]();
6543 let /** @type {?} */ item;
6544 while (!((item = iterator.next()).done)) {
6545 fn(item.value);
6546 }
6547 }
6548}
6549/**
6550 * @param {?} o
6551 * @return {?}
6552 */
6553function isJsObject(o) {
6554 return o !== null && (typeof o === 'function' || typeof o === 'object');
6555}
6556
6557/**
6558 * @license
6559 * Copyright Google Inc. All Rights Reserved.
6560 *
6561 * Use of this source code is governed by an MIT-style license that can be
6562 * found in the LICENSE file at https://angular.io/license
6563 */
6564class DefaultIterableDifferFactory {
6565 constructor() { }
6566 /**
6567 * @param {?} obj
6568 * @return {?}
6569 */
6570 supports(obj) { return isListLikeIterable(obj); }
6571 /**
6572 * @deprecated v4.0.0 - ChangeDetectorRef is not used and is no longer a parameter
6573 * @template V
6574 * @param {?=} cdRefOrTrackBy
6575 * @param {?=} trackByFn
6576 * @return {?}
6577 */
6578 create(cdRefOrTrackBy, trackByFn) {
6579 return new DefaultIterableDiffer(trackByFn || (cdRefOrTrackBy));
6580 }
6581}
6582const trackByIdentity = (index, item) => item;
6583/**
6584 * @deprecated v4.0.0 - Should not be part of public API.
6585 */
6586class DefaultIterableDiffer {
6587 /**
6588 * @param {?=} trackByFn
6589 */
6590 constructor(trackByFn) {
6591 this._length = 0;
6592 this._collection = null;
6593 this._linkedRecords = null;
6594 this._unlinkedRecords = null;
6595 this._previousItHead = null;
6596 this._itHead = null;
6597 this._itTail = null;
6598 this._additionsHead = null;
6599 this._additionsTail = null;
6600 this._movesHead = null;
6601 this._movesTail = null;
6602 this._removalsHead = null;
6603 this._removalsTail = null;
6604 this._identityChangesHead = null;
6605 this._identityChangesTail = null;
6606 this._trackByFn = trackByFn || trackByIdentity;
6607 }
6608 /**
6609 * @return {?}
6610 */
6611 get collection() { return this._collection; }
6612 /**
6613 * @return {?}
6614 */
6615 get length() { return this._length; }
6616 /**
6617 * @param {?} fn
6618 * @return {?}
6619 */
6620 forEachItem(fn) {
6621 let /** @type {?} */ record;
6622 for (record = this._itHead; record !== null; record = record._next) {
6623 fn(record);
6624 }
6625 }
6626 /**
6627 * @param {?} fn
6628 * @return {?}
6629 */
6630 forEachOperation(fn) {
6631 let /** @type {?} */ nextIt = this._itHead;
6632 let /** @type {?} */ nextRemove = this._removalsHead;
6633 let /** @type {?} */ addRemoveOffset = 0;
6634 let /** @type {?} */ moveOffsets = null;
6635 while (nextIt || nextRemove) {
6636 // Figure out which is the next record to process
6637 // Order: remove, add, move
6638 const /** @type {?} */ record = !nextRemove ||
6639 nextIt && ((nextIt.currentIndex)) <
6640 getPreviousIndex(nextRemove, addRemoveOffset, moveOffsets) ? ((nextIt)) :
6641 nextRemove;
6642 const /** @type {?} */ adjPreviousIndex = getPreviousIndex(record, addRemoveOffset, moveOffsets);
6643 const /** @type {?} */ currentIndex = record.currentIndex;
6644 // consume the item, and adjust the addRemoveOffset and update moveDistance if necessary
6645 if (record === nextRemove) {
6646 addRemoveOffset--;
6647 nextRemove = nextRemove._nextRemoved;
6648 }
6649 else {
6650 nextIt = ((nextIt))._next;
6651 if (record.previousIndex == null) {
6652 addRemoveOffset++;
6653 }
6654 else {
6655 // INVARIANT: currentIndex < previousIndex
6656 if (!moveOffsets)
6657 moveOffsets = [];
6658 const /** @type {?} */ localMovePreviousIndex = adjPreviousIndex - addRemoveOffset;
6659 const /** @type {?} */ localCurrentIndex = ((currentIndex)) - addRemoveOffset;
6660 if (localMovePreviousIndex != localCurrentIndex) {
6661 for (let /** @type {?} */ i = 0; i < localMovePreviousIndex; i++) {
6662 const /** @type {?} */ offset = i < moveOffsets.length ? moveOffsets[i] : (moveOffsets[i] = 0);
6663 const /** @type {?} */ index = offset + i;
6664 if (localCurrentIndex <= index && index < localMovePreviousIndex) {
6665 moveOffsets[i] = offset + 1;
6666 }
6667 }
6668 const /** @type {?} */ previousIndex = record.previousIndex;
6669 moveOffsets[previousIndex] = localCurrentIndex - localMovePreviousIndex;
6670 }
6671 }
6672 }
6673 if (adjPreviousIndex !== currentIndex) {
6674 fn(record, adjPreviousIndex, currentIndex);
6675 }
6676 }
6677 }
6678 /**
6679 * @param {?} fn
6680 * @return {?}
6681 */
6682 forEachPreviousItem(fn) {
6683 let /** @type {?} */ record;
6684 for (record = this._previousItHead; record !== null; record = record._nextPrevious) {
6685 fn(record);
6686 }
6687 }
6688 /**
6689 * @param {?} fn
6690 * @return {?}
6691 */
6692 forEachAddedItem(fn) {
6693 let /** @type {?} */ record;
6694 for (record = this._additionsHead; record !== null; record = record._nextAdded) {
6695 fn(record);
6696 }
6697 }
6698 /**
6699 * @param {?} fn
6700 * @return {?}
6701 */
6702 forEachMovedItem(fn) {
6703 let /** @type {?} */ record;
6704 for (record = this._movesHead; record !== null; record = record._nextMoved) {
6705 fn(record);
6706 }
6707 }
6708 /**
6709 * @param {?} fn
6710 * @return {?}
6711 */
6712 forEachRemovedItem(fn) {
6713 let /** @type {?} */ record;
6714 for (record = this._removalsHead; record !== null; record = record._nextRemoved) {
6715 fn(record);
6716 }
6717 }
6718 /**
6719 * @param {?} fn
6720 * @return {?}
6721 */
6722 forEachIdentityChange(fn) {
6723 let /** @type {?} */ record;
6724 for (record = this._identityChangesHead; record !== null; record = record._nextIdentityChange) {
6725 fn(record);
6726 }
6727 }
6728 /**
6729 * @param {?} collection
6730 * @return {?}
6731 */
6732 diff(collection) {
6733 if (collection == null)
6734 collection = [];
6735 if (!isListLikeIterable(collection)) {
6736 throw new Error(`Error trying to diff '${stringify(collection)}'. Only arrays and iterables are allowed`);
6737 }
6738 if (this.check(collection)) {
6739 return this;
6740 }
6741 else {
6742 return null;
6743 }
6744 }
6745 /**
6746 * @return {?}
6747 */
6748 onDestroy() { }
6749 /**
6750 * @param {?} collection
6751 * @return {?}
6752 */
6753 check(collection) {
6754 this._reset();
6755 let /** @type {?} */ record = this._itHead;
6756 let /** @type {?} */ mayBeDirty = false;
6757 let /** @type {?} */ index;
6758 let /** @type {?} */ item;
6759 let /** @type {?} */ itemTrackBy;
6760 if (Array.isArray(collection)) {
6761 this._length = collection.length;
6762 for (let /** @type {?} */ index = 0; index < this._length; index++) {
6763 item = collection[index];
6764 itemTrackBy = this._trackByFn(index, item);
6765 if (record === null || !looseIdentical(record.trackById, itemTrackBy)) {
6766 record = this._mismatch(record, item, itemTrackBy, index);
6767 mayBeDirty = true;
6768 }
6769 else {
6770 if (mayBeDirty) {
6771 // TODO(misko): can we limit this to duplicates only?
6772 record = this._verifyReinsertion(record, item, itemTrackBy, index);
6773 }
6774 if (!looseIdentical(record.item, item))
6775 this._addIdentityChange(record, item);
6776 }
6777 record = record._next;
6778 }
6779 }
6780 else {
6781 index = 0;
6782 iterateListLike(collection, (item) => {
6783 itemTrackBy = this._trackByFn(index, item);
6784 if (record === null || !looseIdentical(record.trackById, itemTrackBy)) {
6785 record = this._mismatch(record, item, itemTrackBy, index);
6786 mayBeDirty = true;
6787 }
6788 else {
6789 if (mayBeDirty) {
6790 // TODO(misko): can we limit this to duplicates only?
6791 record = this._verifyReinsertion(record, item, itemTrackBy, index);
6792 }
6793 if (!looseIdentical(record.item, item))
6794 this._addIdentityChange(record, item);
6795 }
6796 record = record._next;
6797 index++;
6798 });
6799 this._length = index;
6800 }
6801 this._truncate(record);
6802 this._collection = collection;
6803 return this.isDirty;
6804 }
6805 /**
6806 * @return {?}
6807 */
6808 get isDirty() {
6809 return this._additionsHead !== null || this._movesHead !== null ||
6810 this._removalsHead !== null || this._identityChangesHead !== null;
6811 }
6812 /**
6813 * Reset the state of the change objects to show no changes. This means set previousKey to
6814 * currentKey, and clear all of the queues (additions, moves, removals).
6815 * Set the previousIndexes of moved and added items to their currentIndexes
6816 * Reset the list of additions, moves and removals
6817 *
6818 * \@internal
6819 * @return {?}
6820 */
6821 _reset() {
6822 if (this.isDirty) {
6823 let /** @type {?} */ record;
6824 let /** @type {?} */ nextRecord;
6825 for (record = this._previousItHead = this._itHead; record !== null; record = record._next) {
6826 record._nextPrevious = record._next;
6827 }
6828 for (record = this._additionsHead; record !== null; record = record._nextAdded) {
6829 record.previousIndex = record.currentIndex;
6830 }
6831 this._additionsHead = this._additionsTail = null;
6832 for (record = this._movesHead; record !== null; record = nextRecord) {
6833 record.previousIndex = record.currentIndex;
6834 nextRecord = record._nextMoved;
6835 }
6836 this._movesHead = this._movesTail = null;
6837 this._removalsHead = this._removalsTail = null;
6838 this._identityChangesHead = this._identityChangesTail = null;
6839 }
6840 }
6841 /**
6842 * This is the core function which handles differences between collections.
6843 *
6844 * - `record` is the record which we saw at this position last time. If null then it is a new
6845 * item.
6846 * - `item` is the current item in the collection
6847 * - `index` is the position of the item in the collection
6848 *
6849 * \@internal
6850 * @param {?} record
6851 * @param {?} item
6852 * @param {?} itemTrackBy
6853 * @param {?} index
6854 * @return {?}
6855 */
6856 _mismatch(record, item, itemTrackBy, index) {
6857 // The previous record after which we will append the current one.
6858 let /** @type {?} */ previousRecord;
6859 if (record === null) {
6860 previousRecord = ((this._itTail));
6861 }
6862 else {
6863 previousRecord = ((record._prev));
6864 // Remove the record from the collection since we know it does not match the item.
6865 this._remove(record);
6866 }
6867 // Attempt to see if we have seen the item before.
6868 record = this._linkedRecords === null ? null : this._linkedRecords.get(itemTrackBy, index);
6869 if (record !== null) {
6870 // We have seen this before, we need to move it forward in the collection.
6871 // But first we need to check if identity changed, so we can update in view if necessary
6872 if (!looseIdentical(record.item, item))
6873 this._addIdentityChange(record, item);
6874 this._moveAfter(record, previousRecord, index);
6875 }
6876 else {
6877 // Never seen it, check evicted list.
6878 record = this._unlinkedRecords === null ? null : this._unlinkedRecords.get(itemTrackBy, null);
6879 if (record !== null) {
6880 // It is an item which we have evicted earlier: reinsert it back into the list.
6881 // But first we need to check if identity changed, so we can update in view if necessary
6882 if (!looseIdentical(record.item, item))
6883 this._addIdentityChange(record, item);
6884 this._reinsertAfter(record, previousRecord, index);
6885 }
6886 else {
6887 // It is a new item: add it.
6888 record =
6889 this._addAfter(new IterableChangeRecord_(item, itemTrackBy), previousRecord, index);
6890 }
6891 }
6892 return record;
6893 }
6894 /**
6895 * This check is only needed if an array contains duplicates. (Short circuit of nothing dirty)
6896 *
6897 * Use case: `[a, a]` => `[b, a, a]`
6898 *
6899 * If we did not have this check then the insertion of `b` would:
6900 * 1) evict first `a`
6901 * 2) insert `b` at `0` index.
6902 * 3) leave `a` at index `1` as is. <-- this is wrong!
6903 * 3) reinsert `a` at index 2. <-- this is wrong!
6904 *
6905 * The correct behavior is:
6906 * 1) evict first `a`
6907 * 2) insert `b` at `0` index.
6908 * 3) reinsert `a` at index 1.
6909 * 3) move `a` at from `1` to `2`.
6910 *
6911 *
6912 * Double check that we have not evicted a duplicate item. We need to check if the item type may
6913 * have already been removed:
6914 * The insertion of b will evict the first 'a'. If we don't reinsert it now it will be reinserted
6915 * at the end. Which will show up as the two 'a's switching position. This is incorrect, since a
6916 * better way to think of it is as insert of 'b' rather then switch 'a' with 'b' and then add 'a'
6917 * at the end.
6918 *
6919 * \@internal
6920 * @param {?} record
6921 * @param {?} item
6922 * @param {?} itemTrackBy
6923 * @param {?} index
6924 * @return {?}
6925 */
6926 _verifyReinsertion(record, item, itemTrackBy, index) {
6927 let /** @type {?} */ reinsertRecord = this._unlinkedRecords === null ? null : this._unlinkedRecords.get(itemTrackBy, null);
6928 if (reinsertRecord !== null) {
6929 record = this._reinsertAfter(reinsertRecord, /** @type {?} */ ((record._prev)), index);
6930 }
6931 else if (record.currentIndex != index) {
6932 record.currentIndex = index;
6933 this._addToMoves(record, index);
6934 }
6935 return record;
6936 }
6937 /**
6938 * Get rid of any excess {\@link IterableChangeRecord_}s from the previous collection
6939 *
6940 * - `record` The first excess {\@link IterableChangeRecord_}.
6941 *
6942 * \@internal
6943 * @param {?} record
6944 * @return {?}
6945 */
6946 _truncate(record) {
6947 // Anything after that needs to be removed;
6948 while (record !== null) {
6949 const /** @type {?} */ nextRecord = record._next;
6950 this._addToRemovals(this._unlink(record));
6951 record = nextRecord;
6952 }
6953 if (this._unlinkedRecords !== null) {
6954 this._unlinkedRecords.clear();
6955 }
6956 if (this._additionsTail !== null) {
6957 this._additionsTail._nextAdded = null;
6958 }
6959 if (this._movesTail !== null) {
6960 this._movesTail._nextMoved = null;
6961 }
6962 if (this._itTail !== null) {
6963 this._itTail._next = null;
6964 }
6965 if (this._removalsTail !== null) {
6966 this._removalsTail._nextRemoved = null;
6967 }
6968 if (this._identityChangesTail !== null) {
6969 this._identityChangesTail._nextIdentityChange = null;
6970 }
6971 }
6972 /**
6973 * \@internal
6974 * @param {?} record
6975 * @param {?} prevRecord
6976 * @param {?} index
6977 * @return {?}
6978 */
6979 _reinsertAfter(record, prevRecord, index) {
6980 if (this._unlinkedRecords !== null) {
6981 this._unlinkedRecords.remove(record);
6982 }
6983 const /** @type {?} */ prev = record._prevRemoved;
6984 const /** @type {?} */ next = record._nextRemoved;
6985 if (prev === null) {
6986 this._removalsHead = next;
6987 }
6988 else {
6989 prev._nextRemoved = next;
6990 }
6991 if (next === null) {
6992 this._removalsTail = prev;
6993 }
6994 else {
6995 next._prevRemoved = prev;
6996 }
6997 this._insertAfter(record, prevRecord, index);
6998 this._addToMoves(record, index);
6999 return record;
7000 }
7001 /**
7002 * \@internal
7003 * @param {?} record
7004 * @param {?} prevRecord
7005 * @param {?} index
7006 * @return {?}
7007 */
7008 _moveAfter(record, prevRecord, index) {
7009 this._unlink(record);
7010 this._insertAfter(record, prevRecord, index);
7011 this._addToMoves(record, index);
7012 return record;
7013 }
7014 /**
7015 * \@internal
7016 * @param {?} record
7017 * @param {?} prevRecord
7018 * @param {?} index
7019 * @return {?}
7020 */
7021 _addAfter(record, prevRecord, index) {
7022 this._insertAfter(record, prevRecord, index);
7023 if (this._additionsTail === null) {
7024 // todo(vicb)
7025 // assert(this._additionsHead === null);
7026 this._additionsTail = this._additionsHead = record;
7027 }
7028 else {
7029 // todo(vicb)
7030 // assert(_additionsTail._nextAdded === null);
7031 // assert(record._nextAdded === null);
7032 this._additionsTail = this._additionsTail._nextAdded = record;
7033 }
7034 return record;
7035 }
7036 /**
7037 * \@internal
7038 * @param {?} record
7039 * @param {?} prevRecord
7040 * @param {?} index
7041 * @return {?}
7042 */
7043 _insertAfter(record, prevRecord, index) {
7044 // todo(vicb)
7045 // assert(record != prevRecord);
7046 // assert(record._next === null);
7047 // assert(record._prev === null);
7048 const /** @type {?} */ next = prevRecord === null ? this._itHead : prevRecord._next;
7049 // todo(vicb)
7050 // assert(next != record);
7051 // assert(prevRecord != record);
7052 record._next = next;
7053 record._prev = prevRecord;
7054 if (next === null) {
7055 this._itTail = record;
7056 }
7057 else {
7058 next._prev = record;
7059 }
7060 if (prevRecord === null) {
7061 this._itHead = record;
7062 }
7063 else {
7064 prevRecord._next = record;
7065 }
7066 if (this._linkedRecords === null) {
7067 this._linkedRecords = new _DuplicateMap();
7068 }
7069 this._linkedRecords.put(record);
7070 record.currentIndex = index;
7071 return record;
7072 }
7073 /**
7074 * \@internal
7075 * @param {?} record
7076 * @return {?}
7077 */
7078 _remove(record) {
7079 return this._addToRemovals(this._unlink(record));
7080 }
7081 /**
7082 * \@internal
7083 * @param {?} record
7084 * @return {?}
7085 */
7086 _unlink(record) {
7087 if (this._linkedRecords !== null) {
7088 this._linkedRecords.remove(record);
7089 }
7090 const /** @type {?} */ prev = record._prev;
7091 const /** @type {?} */ next = record._next;
7092 // todo(vicb)
7093 // assert((record._prev = null) === null);
7094 // assert((record._next = null) === null);
7095 if (prev === null) {
7096 this._itHead = next;
7097 }
7098 else {
7099 prev._next = next;
7100 }
7101 if (next === null) {
7102 this._itTail = prev;
7103 }
7104 else {
7105 next._prev = prev;
7106 }
7107 return record;
7108 }
7109 /**
7110 * \@internal
7111 * @param {?} record
7112 * @param {?} toIndex
7113 * @return {?}
7114 */
7115 _addToMoves(record, toIndex) {
7116 // todo(vicb)
7117 // assert(record._nextMoved === null);
7118 if (record.previousIndex === toIndex) {
7119 return record;
7120 }
7121 if (this._movesTail === null) {
7122 // todo(vicb)
7123 // assert(_movesHead === null);
7124 this._movesTail = this._movesHead = record;
7125 }
7126 else {
7127 // todo(vicb)
7128 // assert(_movesTail._nextMoved === null);
7129 this._movesTail = this._movesTail._nextMoved = record;
7130 }
7131 return record;
7132 }
7133 /**
7134 * @param {?} record
7135 * @return {?}
7136 */
7137 _addToRemovals(record) {
7138 if (this._unlinkedRecords === null) {
7139 this._unlinkedRecords = new _DuplicateMap();
7140 }
7141 this._unlinkedRecords.put(record);
7142 record.currentIndex = null;
7143 record._nextRemoved = null;
7144 if (this._removalsTail === null) {
7145 // todo(vicb)
7146 // assert(_removalsHead === null);
7147 this._removalsTail = this._removalsHead = record;
7148 record._prevRemoved = null;
7149 }
7150 else {
7151 // todo(vicb)
7152 // assert(_removalsTail._nextRemoved === null);
7153 // assert(record._nextRemoved === null);
7154 record._prevRemoved = this._removalsTail;
7155 this._removalsTail = this._removalsTail._nextRemoved = record;
7156 }
7157 return record;
7158 }
7159 /**
7160 * \@internal
7161 * @param {?} record
7162 * @param {?} item
7163 * @return {?}
7164 */
7165 _addIdentityChange(record, item) {
7166 record.item = item;
7167 if (this._identityChangesTail === null) {
7168 this._identityChangesTail = this._identityChangesHead = record;
7169 }
7170 else {
7171 this._identityChangesTail = this._identityChangesTail._nextIdentityChange = record;
7172 }
7173 return record;
7174 }
7175 /**
7176 * @return {?}
7177 */
7178 toString() {
7179 const /** @type {?} */ list = [];
7180 this.forEachItem((record) => list.push(record));
7181 const /** @type {?} */ previous = [];
7182 this.forEachPreviousItem((record) => previous.push(record));
7183 const /** @type {?} */ additions = [];
7184 this.forEachAddedItem((record) => additions.push(record));
7185 const /** @type {?} */ moves = [];
7186 this.forEachMovedItem((record) => moves.push(record));
7187 const /** @type {?} */ removals = [];
7188 this.forEachRemovedItem((record) => removals.push(record));
7189 const /** @type {?} */ identityChanges = [];
7190 this.forEachIdentityChange((record) => identityChanges.push(record));
7191 return 'collection: ' + list.join(', ') + '\n' +
7192 'previous: ' + previous.join(', ') + '\n' +
7193 'additions: ' + additions.join(', ') + '\n' +
7194 'moves: ' + moves.join(', ') + '\n' +
7195 'removals: ' + removals.join(', ') + '\n' +
7196 'identityChanges: ' + identityChanges.join(', ') + '\n';
7197 }
7198}
7199/**
7200 * \@stable
7201 */
7202class IterableChangeRecord_ {
7203 /**
7204 * @param {?} item
7205 * @param {?} trackById
7206 */
7207 constructor(item, trackById) {
7208 this.item = item;
7209 this.trackById = trackById;
7210 this.currentIndex = null;
7211 this.previousIndex = null;
7212 /**
7213 * \@internal
7214 */
7215 this._nextPrevious = null;
7216 /**
7217 * \@internal
7218 */
7219 this._prev = null;
7220 /**
7221 * \@internal
7222 */
7223 this._next = null;
7224 /**
7225 * \@internal
7226 */
7227 this._prevDup = null;
7228 /**
7229 * \@internal
7230 */
7231 this._nextDup = null;
7232 /**
7233 * \@internal
7234 */
7235 this._prevRemoved = null;
7236 /**
7237 * \@internal
7238 */
7239 this._nextRemoved = null;
7240 /**
7241 * \@internal
7242 */
7243 this._nextAdded = null;
7244 /**
7245 * \@internal
7246 */
7247 this._nextMoved = null;
7248 /**
7249 * \@internal
7250 */
7251 this._nextIdentityChange = null;
7252 }
7253 /**
7254 * @return {?}
7255 */
7256 toString() {
7257 return this.previousIndex === this.currentIndex ? stringify(this.item) :
7258 stringify(this.item) + '[' +
7259 stringify(this.previousIndex) + '->' + stringify(this.currentIndex) + ']';
7260 }
7261}
7262class _DuplicateItemRecordList {
7263 constructor() {
7264 /**
7265 * \@internal
7266 */
7267 this._head = null;
7268 /**
7269 * \@internal
7270 */
7271 this._tail = null;
7272 }
7273 /**
7274 * Append the record to the list of duplicates.
7275 *
7276 * Note: by design all records in the list of duplicates hold the same value in record.item.
7277 * @param {?} record
7278 * @return {?}
7279 */
7280 add(record) {
7281 if (this._head === null) {
7282 this._head = this._tail = record;
7283 record._nextDup = null;
7284 record._prevDup = null;
7285 }
7286 else {
7287 ((
7288 // todo(vicb)
7289 // assert(record.item == _head.item ||
7290 // record.item is num && record.item.isNaN && _head.item is num && _head.item.isNaN);
7291 this._tail))._nextDup = record;
7292 record._prevDup = this._tail;
7293 record._nextDup = null;
7294 this._tail = record;
7295 }
7296 }
7297 /**
7298 * @param {?} trackById
7299 * @param {?} afterIndex
7300 * @return {?}
7301 */
7302 get(trackById, afterIndex) {
7303 let /** @type {?} */ record;
7304 for (record = this._head; record !== null; record = record._nextDup) {
7305 if ((afterIndex === null || afterIndex < record.currentIndex) &&
7306 looseIdentical(record.trackById, trackById)) {
7307 return record;
7308 }
7309 }
7310 return null;
7311 }
7312 /**
7313 * Remove one {\@link IterableChangeRecord_} from the list of duplicates.
7314 *
7315 * Returns whether the list of duplicates is empty.
7316 * @param {?} record
7317 * @return {?}
7318 */
7319 remove(record) {
7320 // todo(vicb)
7321 // assert(() {
7322 // // verify that the record being removed is in the list.
7323 // for (IterableChangeRecord_ cursor = _head; cursor != null; cursor = cursor._nextDup) {
7324 // if (identical(cursor, record)) return true;
7325 // }
7326 // return false;
7327 //});
7328 const /** @type {?} */ prev = record._prevDup;
7329 const /** @type {?} */ next = record._nextDup;
7330 if (prev === null) {
7331 this._head = next;
7332 }
7333 else {
7334 prev._nextDup = next;
7335 }
7336 if (next === null) {
7337 this._tail = prev;
7338 }
7339 else {
7340 next._prevDup = prev;
7341 }
7342 return this._head === null;
7343 }
7344}
7345class _DuplicateMap {
7346 constructor() {
7347 this.map = new Map();
7348 }
7349 /**
7350 * @param {?} record
7351 * @return {?}
7352 */
7353 put(record) {
7354 const /** @type {?} */ key = record.trackById;
7355 let /** @type {?} */ duplicates = this.map.get(key);
7356 if (!duplicates) {
7357 duplicates = new _DuplicateItemRecordList();
7358 this.map.set(key, duplicates);
7359 }
7360 duplicates.add(record);
7361 }
7362 /**
7363 * Retrieve the `value` using key. Because the IterableChangeRecord_ value may be one which we
7364 * have already iterated over, we use the afterIndex to pretend it is not there.
7365 *
7366 * Use case: `[a, b, c, a, a]` if we are at index `3` which is the second `a` then asking if we
7367 * have any more `a`s needs to return the last `a` not the first or second.
7368 * @param {?} trackById
7369 * @param {?} afterIndex
7370 * @return {?}
7371 */
7372 get(trackById, afterIndex) {
7373 const /** @type {?} */ key = trackById;
7374 const /** @type {?} */ recordList = this.map.get(key);
7375 return recordList ? recordList.get(trackById, afterIndex) : null;
7376 }
7377 /**
7378 * Removes a {\@link IterableChangeRecord_} from the list of duplicates.
7379 *
7380 * The list of duplicates also is removed from the map if it gets empty.
7381 * @param {?} record
7382 * @return {?}
7383 */
7384 remove(record) {
7385 const /** @type {?} */ key = record.trackById;
7386 const /** @type {?} */ recordList = ((this.map.get(key)));
7387 // Remove the list of duplicates when it gets empty
7388 if (recordList.remove(record)) {
7389 this.map.delete(key);
7390 }
7391 return record;
7392 }
7393 /**
7394 * @return {?}
7395 */
7396 get isEmpty() { return this.map.size === 0; }
7397 /**
7398 * @return {?}
7399 */
7400 clear() { this.map.clear(); }
7401 /**
7402 * @return {?}
7403 */
7404 toString() { return '_DuplicateMap(' + stringify(this.map) + ')'; }
7405}
7406/**
7407 * @param {?} item
7408 * @param {?} addRemoveOffset
7409 * @param {?} moveOffsets
7410 * @return {?}
7411 */
7412function getPreviousIndex(item, addRemoveOffset, moveOffsets) {
7413 const /** @type {?} */ previousIndex = item.previousIndex;
7414 if (previousIndex === null)
7415 return previousIndex;
7416 let /** @type {?} */ moveOffset = 0;
7417 if (moveOffsets && previousIndex < moveOffsets.length) {
7418 moveOffset = moveOffsets[previousIndex];
7419 }
7420 return previousIndex + addRemoveOffset + moveOffset;
7421}
7422
7423/**
7424 * @license
7425 * Copyright Google Inc. All Rights Reserved.
7426 *
7427 * Use of this source code is governed by an MIT-style license that can be
7428 * found in the LICENSE file at https://angular.io/license
7429 */
7430class DefaultKeyValueDifferFactory {
7431 constructor() { }
7432 /**
7433 * @param {?} obj
7434 * @return {?}
7435 */
7436 supports(obj) { return obj instanceof Map || isJsObject(obj); }
7437 /**
7438 * @deprecated v4.0.0 - ChangeDetectorRef is not used and is no longer a parameter
7439 * @template K, V
7440 * @param {?=} cd
7441 * @return {?}
7442 */
7443 create(cd) {
7444 return new DefaultKeyValueDiffer();
7445 }
7446}
7447class DefaultKeyValueDiffer {
7448 constructor() {
7449 this._records = new Map();
7450 this._mapHead = null;
7451 this._appendAfter = null;
7452 this._previousMapHead = null;
7453 this._changesHead = null;
7454 this._changesTail = null;
7455 this._additionsHead = null;
7456 this._additionsTail = null;
7457 this._removalsHead = null;
7458 this._removalsTail = null;
7459 }
7460 /**
7461 * @return {?}
7462 */
7463 get isDirty() {
7464 return this._additionsHead !== null || this._changesHead !== null ||
7465 this._removalsHead !== null;
7466 }
7467 /**
7468 * @param {?} fn
7469 * @return {?}
7470 */
7471 forEachItem(fn) {
7472 let /** @type {?} */ record;
7473 for (record = this._mapHead; record !== null; record = record._next) {
7474 fn(record);
7475 }
7476 }
7477 /**
7478 * @param {?} fn
7479 * @return {?}
7480 */
7481 forEachPreviousItem(fn) {
7482 let /** @type {?} */ record;
7483 for (record = this._previousMapHead; record !== null; record = record._nextPrevious) {
7484 fn(record);
7485 }
7486 }
7487 /**
7488 * @param {?} fn
7489 * @return {?}
7490 */
7491 forEachChangedItem(fn) {
7492 let /** @type {?} */ record;
7493 for (record = this._changesHead; record !== null; record = record._nextChanged) {
7494 fn(record);
7495 }
7496 }
7497 /**
7498 * @param {?} fn
7499 * @return {?}
7500 */
7501 forEachAddedItem(fn) {
7502 let /** @type {?} */ record;
7503 for (record = this._additionsHead; record !== null; record = record._nextAdded) {
7504 fn(record);
7505 }
7506 }
7507 /**
7508 * @param {?} fn
7509 * @return {?}
7510 */
7511 forEachRemovedItem(fn) {
7512 let /** @type {?} */ record;
7513 for (record = this._removalsHead; record !== null; record = record._nextRemoved) {
7514 fn(record);
7515 }
7516 }
7517 /**
7518 * @param {?=} map
7519 * @return {?}
7520 */
7521 diff(map) {
7522 if (!map) {
7523 map = new Map();
7524 }
7525 else if (!(map instanceof Map || isJsObject(map))) {
7526 throw new Error(`Error trying to diff '${stringify(map)}'. Only maps and objects are allowed`);
7527 }
7528 return this.check(map) ? this : null;
7529 }
7530 /**
7531 * @return {?}
7532 */
7533 onDestroy() { }
7534 /**
7535 * Check the current state of the map vs the previous.
7536 * The algorithm is optimised for when the keys do no change.
7537 * @param {?} map
7538 * @return {?}
7539 */
7540 check(map) {
7541 this._reset();
7542 let /** @type {?} */ insertBefore = this._mapHead;
7543 this._appendAfter = null;
7544 this._forEach(map, (value, key) => {
7545 if (insertBefore && insertBefore.key === key) {
7546 this._maybeAddToChanges(insertBefore, value);
7547 this._appendAfter = insertBefore;
7548 insertBefore = insertBefore._next;
7549 }
7550 else {
7551 const /** @type {?} */ record = this._getOrCreateRecordForKey(key, value);
7552 insertBefore = this._insertBeforeOrAppend(insertBefore, record);
7553 }
7554 });
7555 // Items remaining at the end of the list have been deleted
7556 if (insertBefore) {
7557 if (insertBefore._prev) {
7558 insertBefore._prev._next = null;
7559 }
7560 this._removalsHead = insertBefore;
7561 for (let /** @type {?} */ record = insertBefore; record !== null; record = record._nextRemoved) {
7562 if (record === this._mapHead) {
7563 this._mapHead = null;
7564 }
7565 this._records.delete(record.key);
7566 record._nextRemoved = record._next;
7567 record.previousValue = record.currentValue;
7568 record.currentValue = null;
7569 record._prev = null;
7570 record._next = null;
7571 }
7572 }
7573 // Make sure tails have no next records from previous runs
7574 if (this._changesTail)
7575 this._changesTail._nextChanged = null;
7576 if (this._additionsTail)
7577 this._additionsTail._nextAdded = null;
7578 return this.isDirty;
7579 }
7580 /**
7581 * Inserts a record before `before` or append at the end of the list when `before` is null.
7582 *
7583 * Notes:
7584 * - This method appends at `this._appendAfter`,
7585 * - This method updates `this._appendAfter`,
7586 * - The return value is the new value for the insertion pointer.
7587 * @param {?} before
7588 * @param {?} record
7589 * @return {?}
7590 */
7591 _insertBeforeOrAppend(before, record) {
7592 if (before) {
7593 const /** @type {?} */ prev = before._prev;
7594 record._next = before;
7595 record._prev = prev;
7596 before._prev = record;
7597 if (prev) {
7598 prev._next = record;
7599 }
7600 if (before === this._mapHead) {
7601 this._mapHead = record;
7602 }
7603 this._appendAfter = before;
7604 return before;
7605 }
7606 if (this._appendAfter) {
7607 this._appendAfter._next = record;
7608 record._prev = this._appendAfter;
7609 }
7610 else {
7611 this._mapHead = record;
7612 }
7613 this._appendAfter = record;
7614 return null;
7615 }
7616 /**
7617 * @param {?} key
7618 * @param {?} value
7619 * @return {?}
7620 */
7621 _getOrCreateRecordForKey(key, value) {
7622 if (this._records.has(key)) {
7623 const /** @type {?} */ record = ((this._records.get(key)));
7624 this._maybeAddToChanges(record, value);
7625 const /** @type {?} */ prev = record._prev;
7626 const /** @type {?} */ next = record._next;
7627 if (prev) {
7628 prev._next = next;
7629 }
7630 if (next) {
7631 next._prev = prev;
7632 }
7633 record._next = null;
7634 record._prev = null;
7635 return record;
7636 }
7637 const /** @type {?} */ record = new KeyValueChangeRecord_(key);
7638 this._records.set(key, record);
7639 record.currentValue = value;
7640 this._addToAdditions(record);
7641 return record;
7642 }
7643 /**
7644 * \@internal
7645 * @return {?}
7646 */
7647 _reset() {
7648 if (this.isDirty) {
7649 let /** @type {?} */ record;
7650 // let `_previousMapHead` contain the state of the map before the changes
7651 this._previousMapHead = this._mapHead;
7652 for (record = this._previousMapHead; record !== null; record = record._next) {
7653 record._nextPrevious = record._next;
7654 }
7655 // Update `record.previousValue` with the value of the item before the changes
7656 // We need to update all changed items (that's those which have been added and changed)
7657 for (record = this._changesHead; record !== null; record = record._nextChanged) {
7658 record.previousValue = record.currentValue;
7659 }
7660 for (record = this._additionsHead; record != null; record = record._nextAdded) {
7661 record.previousValue = record.currentValue;
7662 }
7663 this._changesHead = this._changesTail = null;
7664 this._additionsHead = this._additionsTail = null;
7665 this._removalsHead = null;
7666 }
7667 }
7668 /**
7669 * @param {?} record
7670 * @param {?} newValue
7671 * @return {?}
7672 */
7673 _maybeAddToChanges(record, newValue) {
7674 if (!looseIdentical(newValue, record.currentValue)) {
7675 record.previousValue = record.currentValue;
7676 record.currentValue = newValue;
7677 this._addToChanges(record);
7678 }
7679 }
7680 /**
7681 * @param {?} record
7682 * @return {?}
7683 */
7684 _addToAdditions(record) {
7685 if (this._additionsHead === null) {
7686 this._additionsHead = this._additionsTail = record;
7687 }
7688 else {
7689 ((this._additionsTail))._nextAdded = record;
7690 this._additionsTail = record;
7691 }
7692 }
7693 /**
7694 * @param {?} record
7695 * @return {?}
7696 */
7697 _addToChanges(record) {
7698 if (this._changesHead === null) {
7699 this._changesHead = this._changesTail = record;
7700 }
7701 else {
7702 ((this._changesTail))._nextChanged = record;
7703 this._changesTail = record;
7704 }
7705 }
7706 /**
7707 * @return {?}
7708 */
7709 toString() {
7710 const /** @type {?} */ items = [];
7711 const /** @type {?} */ previous = [];
7712 const /** @type {?} */ changes = [];
7713 const /** @type {?} */ additions = [];
7714 const /** @type {?} */ removals = [];
7715 this.forEachItem(r => items.push(stringify(r)));
7716 this.forEachPreviousItem(r => previous.push(stringify(r)));
7717 this.forEachChangedItem(r => changes.push(stringify(r)));
7718 this.forEachAddedItem(r => additions.push(stringify(r)));
7719 this.forEachRemovedItem(r => removals.push(stringify(r)));
7720 return 'map: ' + items.join(', ') + '\n' +
7721 'previous: ' + previous.join(', ') + '\n' +
7722 'additions: ' + additions.join(', ') + '\n' +
7723 'changes: ' + changes.join(', ') + '\n' +
7724 'removals: ' + removals.join(', ') + '\n';
7725 }
7726 /**
7727 * \@internal
7728 * @template K, V
7729 * @param {?} obj
7730 * @param {?} fn
7731 * @return {?}
7732 */
7733 _forEach(obj, fn) {
7734 if (obj instanceof Map) {
7735 obj.forEach(fn);
7736 }
7737 else {
7738 Object.keys(obj).forEach(k => fn(obj[k], k));
7739 }
7740 }
7741}
7742/**
7743 * \@stable
7744 */
7745class KeyValueChangeRecord_ {
7746 /**
7747 * @param {?} key
7748 */
7749 constructor(key) {
7750 this.key = key;
7751 this.previousValue = null;
7752 this.currentValue = null;
7753 /**
7754 * \@internal
7755 */
7756 this._nextPrevious = null;
7757 /**
7758 * \@internal
7759 */
7760 this._next = null;
7761 /**
7762 * \@internal
7763 */
7764 this._prev = null;
7765 /**
7766 * \@internal
7767 */
7768 this._nextAdded = null;
7769 /**
7770 * \@internal
7771 */
7772 this._nextRemoved = null;
7773 /**
7774 * \@internal
7775 */
7776 this._nextChanged = null;
7777 }
7778 /**
7779 * @return {?}
7780 */
7781 toString() {
7782 return looseIdentical(this.previousValue, this.currentValue) ?
7783 stringify(this.key) :
7784 (stringify(this.key) + '[' + stringify(this.previousValue) + '->' +
7785 stringify(this.currentValue) + ']');
7786 }
7787}
7788
7789/**
7790 * @license
7791 * Copyright Google Inc. All Rights Reserved.
7792 *
7793 * Use of this source code is governed by an MIT-style license that can be
7794 * found in the LICENSE file at https://angular.io/license
7795 */
7796/**
7797 * A repository of different iterable diffing strategies used by NgFor, NgClass, and others.
7798 * \@stable
7799 */
7800class IterableDiffers {
7801 /**
7802 * @param {?} factories
7803 */
7804 constructor(factories) { this.factories = factories; }
7805 /**
7806 * @param {?} factories
7807 * @param {?=} parent
7808 * @return {?}
7809 */
7810 static create(factories, parent) {
7811 if (parent != null) {
7812 const /** @type {?} */ copied = parent.factories.slice();
7813 factories = factories.concat(copied);
7814 return new IterableDiffers(factories);
7815 }
7816 else {
7817 return new IterableDiffers(factories);
7818 }
7819 }
7820 /**
7821 * Takes an array of {\@link IterableDifferFactory} and returns a provider used to extend the
7822 * inherited {\@link IterableDiffers} instance with the provided factories and return a new
7823 * {\@link IterableDiffers} instance.
7824 *
7825 * The following example shows how to extend an existing list of factories,
7826 * which will only be applied to the injector for this component and its children.
7827 * This step is all that's required to make a new {\@link IterableDiffer} available.
7828 *
7829 * ### Example
7830 *
7831 * ```
7832 * \@Component({
7833 * viewProviders: [
7834 * IterableDiffers.extend([new ImmutableListDiffer()])
7835 * ]
7836 * })
7837 * ```
7838 * @param {?} factories
7839 * @return {?}
7840 */
7841 static extend(factories) {
7842 return {
7843 provide: IterableDiffers,
7844 useFactory: (parent) => {
7845 if (!parent) {
7846 // Typically would occur when calling IterableDiffers.extend inside of dependencies passed
7847 // to
7848 // bootstrap(), which would override default pipes instead of extending them.
7849 throw new Error('Cannot extend IterableDiffers without a parent injector');
7850 }
7851 return IterableDiffers.create(factories, parent);
7852 },
7853 // Dependency technically isn't optional, but we can provide a better error message this way.
7854 deps: [[IterableDiffers, new SkipSelf(), new Optional()]]
7855 };
7856 }
7857 /**
7858 * @param {?} iterable
7859 * @return {?}
7860 */
7861 find(iterable) {
7862 const /** @type {?} */ factory = this.factories.find(f => f.supports(iterable));
7863 if (factory != null) {
7864 return factory;
7865 }
7866 else {
7867 throw new Error(`Cannot find a differ supporting object '${iterable}' of type '${getTypeNameForDebugging(iterable)}'`);
7868 }
7869 }
7870}
7871/**
7872 * @param {?} type
7873 * @return {?}
7874 */
7875function getTypeNameForDebugging(type) {
7876 return type['name'] || typeof type;
7877}
7878
7879/**
7880 * @license
7881 * Copyright Google Inc. All Rights Reserved.
7882 *
7883 * Use of this source code is governed by an MIT-style license that can be
7884 * found in the LICENSE file at https://angular.io/license
7885 */
7886/**
7887 * A repository of different Map diffing strategies used by NgClass, NgStyle, and others.
7888 * \@stable
7889 */
7890class KeyValueDiffers {
7891 /**
7892 * @param {?} factories
7893 */
7894 constructor(factories) { this.factories = factories; }
7895 /**
7896 * @template S
7897 * @param {?} factories
7898 * @param {?=} parent
7899 * @return {?}
7900 */
7901 static create(factories, parent) {
7902 if (parent) {
7903 const /** @type {?} */ copied = parent.factories.slice();
7904 factories = factories.concat(copied);
7905 }
7906 return new KeyValueDiffers(factories);
7907 }
7908 /**
7909 * Takes an array of {\@link KeyValueDifferFactory} and returns a provider used to extend the
7910 * inherited {\@link KeyValueDiffers} instance with the provided factories and return a new
7911 * {\@link KeyValueDiffers} instance.
7912 *
7913 * The following example shows how to extend an existing list of factories,
7914 * which will only be applied to the injector for this component and its children.
7915 * This step is all that's required to make a new {\@link KeyValueDiffer} available.
7916 *
7917 * ### Example
7918 *
7919 * ```
7920 * \@Component({
7921 * viewProviders: [
7922 * KeyValueDiffers.extend([new ImmutableMapDiffer()])
7923 * ]
7924 * })
7925 * ```
7926 * @template S
7927 * @param {?} factories
7928 * @return {?}
7929 */
7930 static extend(factories) {
7931 return {
7932 provide: KeyValueDiffers,
7933 useFactory: (parent) => {
7934 if (!parent) {
7935 // Typically would occur when calling KeyValueDiffers.extend inside of dependencies passed
7936 // to bootstrap(), which would override default pipes instead of extending them.
7937 throw new Error('Cannot extend KeyValueDiffers without a parent injector');
7938 }
7939 return KeyValueDiffers.create(factories, parent);
7940 },
7941 // Dependency technically isn't optional, but we can provide a better error message this way.
7942 deps: [[KeyValueDiffers, new SkipSelf(), new Optional()]]
7943 };
7944 }
7945 /**
7946 * @param {?} kv
7947 * @return {?}
7948 */
7949 find(kv) {
7950 const /** @type {?} */ factory = this.factories.find(f => f.supports(kv));
7951 if (factory) {
7952 return factory;
7953 }
7954 throw new Error(`Cannot find a differ supporting object '${kv}'`);
7955 }
7956}
7957
7958/**
7959 * @license
7960 * Copyright Google Inc. All Rights Reserved.
7961 *
7962 * Use of this source code is governed by an MIT-style license that can be
7963 * found in the LICENSE file at https://angular.io/license
7964 */
7965/**
7966 * Structural diffing for `Object`s and `Map`s.
7967 */
7968const keyValDiff = [new DefaultKeyValueDifferFactory()];
7969/**
7970 * Structural diffing for `Iterable` types such as `Array`s.
7971 */
7972const iterableDiff = [new DefaultIterableDifferFactory()];
7973const defaultIterableDiffers = new IterableDiffers(iterableDiff);
7974const defaultKeyValueDiffers = new KeyValueDiffers(keyValDiff);
7975
7976/**
7977 * @license
7978 * Copyright Google Inc. All Rights Reserved.
7979 *
7980 * Use of this source code is governed by an MIT-style license that can be
7981 * found in the LICENSE file at https://angular.io/license
7982 */
7983/**
7984 * @module
7985 * @description
7986 * Change detection enables data binding in Angular.
7987 */
7988
7989/**
7990 * @license
7991 * Copyright Google Inc. All Rights Reserved.
7992 *
7993 * Use of this source code is governed by an MIT-style license that can be
7994 * found in the LICENSE file at https://angular.io/license
7995 */
7996/**
7997 * @return {?}
7998 */
7999function _reflector() {
8000 return reflector;
8001}
8002const _CORE_PLATFORM_PROVIDERS = [
8003 // Set a default platform name for platforms that don't set it explicitly.
8004 { provide: PLATFORM_ID, useValue: 'unknown' },
8005 PlatformRef_,
8006 { provide: PlatformRef, useExisting: PlatformRef_ },
8007 { provide: Reflector, useFactory: _reflector, deps: [] },
8008 { provide: ReflectorReader, useExisting: Reflector },
8009 TestabilityRegistry,
8010 Console,
8011];
8012/**
8013 * This platform has to be included in any other platform
8014 *
8015 * \@experimental
8016 */
8017const platformCore = createPlatformFactory(null, 'core', _CORE_PLATFORM_PROVIDERS);
8018
8019/**
8020 * @license
8021 * Copyright Google Inc. All Rights Reserved.
8022 *
8023 * Use of this source code is governed by an MIT-style license that can be
8024 * found in the LICENSE file at https://angular.io/license
8025 */
8026/**
8027 * \@experimental i18n support is experimental.
8028 */
8029const LOCALE_ID = new InjectionToken('LocaleId');
8030/**
8031 * \@experimental i18n support is experimental.
8032 */
8033const TRANSLATIONS = new InjectionToken('Translations');
8034/**
8035 * \@experimental i18n support is experimental.
8036 */
8037const TRANSLATIONS_FORMAT = new InjectionToken('TranslationsFormat');
8038let MissingTranslationStrategy = {};
8039MissingTranslationStrategy.Error = 0;
8040MissingTranslationStrategy.Warning = 1;
8041MissingTranslationStrategy.Ignore = 2;
8042MissingTranslationStrategy[MissingTranslationStrategy.Error] = "Error";
8043MissingTranslationStrategy[MissingTranslationStrategy.Warning] = "Warning";
8044MissingTranslationStrategy[MissingTranslationStrategy.Ignore] = "Ignore";
8045
8046let SecurityContext = {};
8047SecurityContext.NONE = 0;
8048SecurityContext.HTML = 1;
8049SecurityContext.STYLE = 2;
8050SecurityContext.SCRIPT = 3;
8051SecurityContext.URL = 4;
8052SecurityContext.RESOURCE_URL = 5;
8053SecurityContext[SecurityContext.NONE] = "NONE";
8054SecurityContext[SecurityContext.HTML] = "HTML";
8055SecurityContext[SecurityContext.STYLE] = "STYLE";
8056SecurityContext[SecurityContext.SCRIPT] = "SCRIPT";
8057SecurityContext[SecurityContext.URL] = "URL";
8058SecurityContext[SecurityContext.RESOURCE_URL] = "RESOURCE_URL";
8059/**
8060 * Sanitizer is used by the views to sanitize potentially dangerous values.
8061 *
8062 * \@stable
8063 * @abstract
8064 */
8065class Sanitizer {
8066 /**
8067 * @abstract
8068 * @param {?} context
8069 * @param {?} value
8070 * @return {?}
8071 */
8072 sanitize(context, value) { }
8073}
8074
8075/**
8076 * @license
8077 * Copyright Google Inc. All Rights Reserved.
8078 *
8079 * Use of this source code is governed by an MIT-style license that can be
8080 * found in the LICENSE file at https://angular.io/license
8081 */
8082/**
8083 * Node instance data.
8084 *
8085 * We have a separate type per NodeType to save memory
8086 * (TextData | ElementData | ProviderData | PureExpressionData | QueryList<any>)
8087 *
8088 * To keep our code monomorphic,
8089 * we prohibit using `NodeData` directly but enforce the use of accessors (`asElementData`, ...).
8090 * This way, no usage site can get a `NodeData` from view.nodes and then use it for different
8091 * purposes.
8092 */
8093
8094/**
8095 * Accessor for view.nodes, enforcing that every usage site stays monomorphic.
8096 * @param {?} view
8097 * @param {?} index
8098 * @return {?}
8099 */
8100function asTextData(view, index) {
8101 return (view.nodes[index]);
8102}
8103/**
8104 * Accessor for view.nodes, enforcing that every usage site stays monomorphic.
8105 * @param {?} view
8106 * @param {?} index
8107 * @return {?}
8108 */
8109function asElementData(view, index) {
8110 return (view.nodes[index]);
8111}
8112/**
8113 * Accessor for view.nodes, enforcing that every usage site stays monomorphic.
8114 * @param {?} view
8115 * @param {?} index
8116 * @return {?}
8117 */
8118function asProviderData(view, index) {
8119 return (view.nodes[index]);
8120}
8121/**
8122 * Accessor for view.nodes, enforcing that every usage site stays monomorphic.
8123 * @param {?} view
8124 * @param {?} index
8125 * @return {?}
8126 */
8127function asPureExpressionData(view, index) {
8128 return (view.nodes[index]);
8129}
8130/**
8131 * Accessor for view.nodes, enforcing that every usage site stays monomorphic.
8132 * @param {?} view
8133 * @param {?} index
8134 * @return {?}
8135 */
8136function asQueryList(view, index) {
8137 return (view.nodes[index]);
8138}
8139/**
8140 * @abstract
8141 */
8142class DebugContext {
8143 /**
8144 * @abstract
8145 * @return {?}
8146 */
8147 view() { }
8148 /**
8149 * @abstract
8150 * @return {?}
8151 */
8152 nodeIndex() { }
8153 /**
8154 * @abstract
8155 * @return {?}
8156 */
8157 injector() { }
8158 /**
8159 * @abstract
8160 * @return {?}
8161 */
8162 component() { }
8163 /**
8164 * @abstract
8165 * @return {?}
8166 */
8167 providerTokens() { }
8168 /**
8169 * @abstract
8170 * @return {?}
8171 */
8172 references() { }
8173 /**
8174 * @abstract
8175 * @return {?}
8176 */
8177 context() { }
8178 /**
8179 * @abstract
8180 * @return {?}
8181 */
8182 componentRenderElement() { }
8183 /**
8184 * @abstract
8185 * @return {?}
8186 */
8187 renderNode() { }
8188 /**
8189 * @abstract
8190 * @param {?} console
8191 * @param {...?} values
8192 * @return {?}
8193 */
8194 logError(console, ...values) { }
8195}
8196/**
8197 * This object is used to prevent cycles in the source files and to have a place where
8198 * debug mode can hook it. It is lazily filled when `isDevMode` is known.
8199 */
8200const Services = {
8201 setCurrentNode: /** @type {?} */ ((undefined)),
8202 createRootView: /** @type {?} */ ((undefined)),
8203 createEmbeddedView: /** @type {?} */ ((undefined)),
8204 checkAndUpdateView: /** @type {?} */ ((undefined)),
8205 checkNoChangesView: /** @type {?} */ ((undefined)),
8206 destroyView: /** @type {?} */ ((undefined)),
8207 resolveDep: /** @type {?} */ ((undefined)),
8208 createDebugContext: /** @type {?} */ ((undefined)),
8209 handleEvent: /** @type {?} */ ((undefined)),
8210 updateDirectives: /** @type {?} */ ((undefined)),
8211 updateRenderer: /** @type {?} */ ((undefined)),
8212 dirtyParentQueries: /** @type {?} */ ((undefined)),
8213};
8214
8215/**
8216 * @license
8217 * Copyright Google Inc. All Rights Reserved.
8218 *
8219 * Use of this source code is governed by an MIT-style license that can be
8220 * found in the LICENSE file at https://angular.io/license
8221 */
8222/**
8223 * @param {?} context
8224 * @param {?} oldValue
8225 * @param {?} currValue
8226 * @param {?} isFirstCheck
8227 * @return {?}
8228 */
8229function expressionChangedAfterItHasBeenCheckedError(context, oldValue, currValue, isFirstCheck) {
8230 let /** @type {?} */ msg = `ExpressionChangedAfterItHasBeenCheckedError: Expression has changed after it was checked. Previous value: '${oldValue}'. Current value: '${currValue}'.`;
8231 if (isFirstCheck) {
8232 msg +=
8233 ` It seems like the view has been created after its parent and its children have been dirty checked.` +
8234 ` Has it been created in a change detection hook ?`;
8235 }
8236 return viewDebugError(msg, context);
8237}
8238/**
8239 * @param {?} err
8240 * @param {?} context
8241 * @return {?}
8242 */
8243function viewWrappedDebugError(err, context) {
8244 if (!(err instanceof Error)) {
8245 // errors that are not Error instances don't have a stack,
8246 // so it is ok to wrap them into a new Error object...
8247 err = new Error(err.toString());
8248 }
8249 _addDebugContext(err, context);
8250 return err;
8251}
8252/**
8253 * @param {?} msg
8254 * @param {?} context
8255 * @return {?}
8256 */
8257function viewDebugError(msg, context) {
8258 const /** @type {?} */ err = new Error(msg);
8259 _addDebugContext(err, context);
8260 return err;
8261}
8262/**
8263 * @param {?} err
8264 * @param {?} context
8265 * @return {?}
8266 */
8267function _addDebugContext(err, context) {
8268 ((err))[ERROR_DEBUG_CONTEXT] = context;
8269 ((err))[ERROR_LOGGER] = context.logError.bind(context);
8270}
8271/**
8272 * @param {?} err
8273 * @return {?}
8274 */
8275function isViewDebugError(err) {
8276 return !!getDebugContext(err);
8277}
8278/**
8279 * @param {?} action
8280 * @return {?}
8281 */
8282function viewDestroyedError(action) {
8283 return new Error(`ViewDestroyedError: Attempt to use a destroyed view: ${action}`);
8284}
8285
8286/**
8287 * @license
8288 * Copyright Google Inc. All Rights Reserved.
8289 *
8290 * Use of this source code is governed by an MIT-style license that can be
8291 * found in the LICENSE file at https://angular.io/license
8292 */
8293const NOOP = () => { };
8294const _tokenKeyCache = new Map();
8295/**
8296 * @param {?} token
8297 * @return {?}
8298 */
8299function tokenKey(token) {
8300 let /** @type {?} */ key = _tokenKeyCache.get(token);
8301 if (!key) {
8302 key = stringify(token) + '_' + _tokenKeyCache.size;
8303 _tokenKeyCache.set(token, key);
8304 }
8305 return key;
8306}
8307/**
8308 * @param {?} view
8309 * @param {?} nodeIdx
8310 * @param {?} bindingIdx
8311 * @param {?} value
8312 * @return {?}
8313 */
8314function unwrapValue(view, nodeIdx, bindingIdx, value) {
8315 if (value instanceof WrappedValue) {
8316 value = value.wrapped;
8317 let /** @type {?} */ globalBindingIdx = view.def.nodes[nodeIdx].bindingIndex + bindingIdx;
8318 let /** @type {?} */ oldValue = view.oldValues[globalBindingIdx];
8319 if (oldValue instanceof WrappedValue) {
8320 oldValue = oldValue.wrapped;
8321 }
8322 view.oldValues[globalBindingIdx] = new WrappedValue(oldValue);
8323 }
8324 return value;
8325}
8326const UNDEFINED_RENDERER_TYPE_ID = '$$undefined';
8327const EMPTY_RENDERER_TYPE_ID = '$$empty';
8328/**
8329 * @param {?} values
8330 * @return {?}
8331 */
8332function createRendererType2(values) {
8333 return {
8334 id: UNDEFINED_RENDERER_TYPE_ID,
8335 styles: values.styles,
8336 encapsulation: values.encapsulation,
8337 data: values.data
8338 };
8339}
8340let _renderCompCount = 0;
8341/**
8342 * @param {?=} type
8343 * @return {?}
8344 */
8345function resolveRendererType2(type) {
8346 if (type && type.id === UNDEFINED_RENDERER_TYPE_ID) {
8347 // first time we see this RendererType2. Initialize it...
8348 const /** @type {?} */ isFilled = ((type.encapsulation != null && type.encapsulation !== ViewEncapsulation.None) ||
8349 type.styles.length || Object.keys(type.data).length);
8350 if (isFilled) {
8351 type.id = `c${_renderCompCount++}`;
8352 }
8353 else {
8354 type.id = EMPTY_RENDERER_TYPE_ID;
8355 }
8356 }
8357 if (type && type.id === EMPTY_RENDERER_TYPE_ID) {
8358 type = null;
8359 }
8360 return type || null;
8361}
8362/**
8363 * @param {?} view
8364 * @param {?} def
8365 * @param {?} bindingIdx
8366 * @param {?} value
8367 * @return {?}
8368 */
8369function checkBinding(view, def, bindingIdx, value) {
8370 const /** @type {?} */ oldValues = view.oldValues;
8371 if ((view.state & 2 /* FirstCheck */) ||
8372 !looseIdentical(oldValues[def.bindingIndex + bindingIdx], value)) {
8373 return true;
8374 }
8375 return false;
8376}
8377/**
8378 * @param {?} view
8379 * @param {?} def
8380 * @param {?} bindingIdx
8381 * @param {?} value
8382 * @return {?}
8383 */
8384function checkAndUpdateBinding(view, def, bindingIdx, value) {
8385 if (checkBinding(view, def, bindingIdx, value)) {
8386 view.oldValues[def.bindingIndex + bindingIdx] = value;
8387 return true;
8388 }
8389 return false;
8390}
8391/**
8392 * @param {?} view
8393 * @param {?} def
8394 * @param {?} bindingIdx
8395 * @param {?} value
8396 * @return {?}
8397 */
8398function checkBindingNoChanges(view, def, bindingIdx, value) {
8399 const /** @type {?} */ oldValue = view.oldValues[def.bindingIndex + bindingIdx];
8400 if ((view.state & 1 /* BeforeFirstCheck */) || !devModeEqual(oldValue, value)) {
8401 throw expressionChangedAfterItHasBeenCheckedError(Services.createDebugContext(view, def.index), oldValue, value, (view.state & 1 /* BeforeFirstCheck */) !== 0);
8402 }
8403}
8404/**
8405 * @param {?} view
8406 * @return {?}
8407 */
8408function markParentViewsForCheck(view) {
8409 let /** @type {?} */ currView = view;
8410 while (currView) {
8411 if (currView.def.flags & 2 /* OnPush */) {
8412 currView.state |= 8 /* ChecksEnabled */;
8413 }
8414 currView = currView.viewContainerParent || currView.parent;
8415 }
8416}
8417/**
8418 * @param {?} view
8419 * @param {?} nodeIndex
8420 * @param {?} eventName
8421 * @param {?} event
8422 * @return {?}
8423 */
8424function dispatchEvent(view, nodeIndex, eventName, event) {
8425 const /** @type {?} */ nodeDef = view.def.nodes[nodeIndex];
8426 const /** @type {?} */ startView = nodeDef.flags & 16777216 /* ComponentView */ ? asElementData(view, nodeIndex).componentView : view;
8427 markParentViewsForCheck(startView);
8428 return Services.handleEvent(view, nodeIndex, eventName, event);
8429}
8430/**
8431 * @param {?} view
8432 * @return {?}
8433 */
8434function declaredViewContainer(view) {
8435 if (view.parent) {
8436 const /** @type {?} */ parentView = view.parent;
8437 return asElementData(parentView, /** @type {?} */ ((view.parentNodeDef)).index);
8438 }
8439 return null;
8440}
8441/**
8442 * for component views, this is the host element.
8443 * for embedded views, this is the index of the parent node
8444 * that contains the view container.
8445 * @param {?} view
8446 * @return {?}
8447 */
8448function viewParentEl(view) {
8449 const /** @type {?} */ parentView = view.parent;
8450 if (parentView) {
8451 return ((view.parentNodeDef)).parent;
8452 }
8453 else {
8454 return null;
8455 }
8456}
8457/**
8458 * @param {?} view
8459 * @param {?} def
8460 * @return {?}
8461 */
8462function renderNode(view, def) {
8463 switch (def.flags & 100673535 /* Types */) {
8464 case 1 /* TypeElement */:
8465 return asElementData(view, def.index).renderElement;
8466 case 2 /* TypeText */:
8467 return asTextData(view, def.index).renderText;
8468 }
8469}
8470/**
8471 * @param {?} target
8472 * @param {?} name
8473 * @return {?}
8474 */
8475function elementEventFullName(target, name) {
8476 return target ? `${target}:${name}` : name;
8477}
8478/**
8479 * @param {?} view
8480 * @return {?}
8481 */
8482function isComponentView(view) {
8483 return !!view.parent && !!(((view.parentNodeDef)).flags & 16384 /* Component */);
8484}
8485/**
8486 * @param {?} view
8487 * @return {?}
8488 */
8489function isEmbeddedView(view) {
8490 return !!view.parent && !(((view.parentNodeDef)).flags & 16384 /* Component */);
8491}
8492/**
8493 * @param {?} queryId
8494 * @return {?}
8495 */
8496function filterQueryId(queryId) {
8497 return 1 << (queryId % 32);
8498}
8499/**
8500 * @param {?} matchedQueriesDsl
8501 * @return {?}
8502 */
8503function splitMatchedQueriesDsl(matchedQueriesDsl) {
8504 const /** @type {?} */ matchedQueries = {};
8505 let /** @type {?} */ matchedQueryIds = 0;
8506 const /** @type {?} */ references = {};
8507 if (matchedQueriesDsl) {
8508 matchedQueriesDsl.forEach(([queryId, valueType]) => {
8509 if (typeof queryId === 'number') {
8510 matchedQueries[queryId] = valueType;
8511 matchedQueryIds |= filterQueryId(queryId);
8512 }
8513 else {
8514 references[queryId] = valueType;
8515 }
8516 });
8517 }
8518 return { matchedQueries, references, matchedQueryIds };
8519}
8520/**
8521 * @param {?} view
8522 * @param {?} renderHost
8523 * @param {?} def
8524 * @return {?}
8525 */
8526function getParentRenderElement(view, renderHost, def) {
8527 let /** @type {?} */ renderParent = def.renderParent;
8528 if (renderParent) {
8529 if ((renderParent.flags & 1 /* TypeElement */) === 0 ||
8530 (renderParent.flags & 16777216 /* ComponentView */) === 0 ||
8531 (((renderParent.element)).componentRendererType && ((((renderParent.element)).componentRendererType)).encapsulation ===
8532 ViewEncapsulation.Native)) {
8533 // only children of non components, or children of components with native encapsulation should
8534 // be attached.
8535 return asElementData(view, /** @type {?} */ ((def.renderParent)).index).renderElement;
8536 }
8537 }
8538 else {
8539 return renderHost;
8540 }
8541}
8542const VIEW_DEFINITION_CACHE = new WeakMap();
8543/**
8544 * @param {?} factory
8545 * @return {?}
8546 */
8547function resolveViewDefinition(factory) {
8548 let /** @type {?} */ value = ((VIEW_DEFINITION_CACHE.get(factory)));
8549 if (!value) {
8550 value = factory(() => NOOP);
8551 value.factory = factory;
8552 VIEW_DEFINITION_CACHE.set(factory, value);
8553 }
8554 return value;
8555}
8556/**
8557 * @param {?} view
8558 * @return {?}
8559 */
8560function rootRenderNodes(view) {
8561 const /** @type {?} */ renderNodes = [];
8562 visitRootRenderNodes(view, 0 /* Collect */, undefined, undefined, renderNodes);
8563 return renderNodes;
8564}
8565/**
8566 * @param {?} view
8567 * @param {?} action
8568 * @param {?} parentNode
8569 * @param {?} nextSibling
8570 * @param {?=} target
8571 * @return {?}
8572 */
8573function visitRootRenderNodes(view, action, parentNode, nextSibling, target) {
8574 // We need to re-compute the parent node in case the nodes have been moved around manually
8575 if (action === 3 /* RemoveChild */) {
8576 parentNode = view.renderer.parentNode(renderNode(view, /** @type {?} */ ((view.def.lastRenderRootNode))));
8577 }
8578 visitSiblingRenderNodes(view, action, 0, view.def.nodes.length - 1, parentNode, nextSibling, target);
8579}
8580/**
8581 * @param {?} view
8582 * @param {?} action
8583 * @param {?} startIndex
8584 * @param {?} endIndex
8585 * @param {?} parentNode
8586 * @param {?} nextSibling
8587 * @param {?=} target
8588 * @return {?}
8589 */
8590function visitSiblingRenderNodes(view, action, startIndex, endIndex, parentNode, nextSibling, target) {
8591 for (let /** @type {?} */ i = startIndex; i <= endIndex; i++) {
8592 const /** @type {?} */ nodeDef = view.def.nodes[i];
8593 if (nodeDef.flags & (1 /* TypeElement */ | 2 /* TypeText */ | 4 /* TypeNgContent */)) {
8594 visitRenderNode(view, nodeDef, action, parentNode, nextSibling, target);
8595 }
8596 // jump to next sibling
8597 i += nodeDef.childCount;
8598 }
8599}
8600/**
8601 * @param {?} view
8602 * @param {?} ngContentIndex
8603 * @param {?} action
8604 * @param {?} parentNode
8605 * @param {?} nextSibling
8606 * @param {?=} target
8607 * @return {?}
8608 */
8609function visitProjectedRenderNodes(view, ngContentIndex, action, parentNode, nextSibling, target) {
8610 let /** @type {?} */ compView = view;
8611 while (compView && !isComponentView(compView)) {
8612 compView = compView.parent;
8613 }
8614 const /** @type {?} */ hostView = ((compView)).parent;
8615 const /** @type {?} */ hostElDef = viewParentEl(/** @type {?} */ ((compView)));
8616 const /** @type {?} */ startIndex = ((hostElDef)).index + 1;
8617 const /** @type {?} */ endIndex = ((hostElDef)).index + ((hostElDef)).childCount;
8618 for (let /** @type {?} */ i = startIndex; i <= endIndex; i++) {
8619 const /** @type {?} */ nodeDef = ((hostView)).def.nodes[i];
8620 if (nodeDef.ngContentIndex === ngContentIndex) {
8621 visitRenderNode(/** @type {?} */ ((hostView)), nodeDef, action, parentNode, nextSibling, target);
8622 }
8623 // jump to next sibling
8624 i += nodeDef.childCount;
8625 }
8626 if (!((hostView)).parent) {
8627 // a root view
8628 const /** @type {?} */ projectedNodes = view.root.projectableNodes[ngContentIndex];
8629 if (projectedNodes) {
8630 for (let /** @type {?} */ i = 0; i < projectedNodes.length; i++) {
8631 execRenderNodeAction(view, projectedNodes[i], action, parentNode, nextSibling, target);
8632 }
8633 }
8634 }
8635}
8636/**
8637 * @param {?} view
8638 * @param {?} nodeDef
8639 * @param {?} action
8640 * @param {?} parentNode
8641 * @param {?} nextSibling
8642 * @param {?=} target
8643 * @return {?}
8644 */
8645function visitRenderNode(view, nodeDef, action, parentNode, nextSibling, target) {
8646 if (nodeDef.flags & 4 /* TypeNgContent */) {
8647 visitProjectedRenderNodes(view, /** @type {?} */ ((nodeDef.ngContent)).index, action, parentNode, nextSibling, target);
8648 }
8649 else {
8650 const /** @type {?} */ rn = renderNode(view, nodeDef);
8651 if (action === 3 /* RemoveChild */ && (nodeDef.flags & 16777216 /* ComponentView */) &&
8652 (nodeDef.bindingFlags & 48 /* CatSyntheticProperty */)) {
8653 // Note: we might need to do both actions.
8654 if (nodeDef.bindingFlags & (16 /* SyntheticProperty */)) {
8655 execRenderNodeAction(view, rn, action, parentNode, nextSibling, target);
8656 }
8657 if (nodeDef.bindingFlags & (32 /* SyntheticHostProperty */)) {
8658 const /** @type {?} */ compView = asElementData(view, nodeDef.index).componentView;
8659 execRenderNodeAction(compView, rn, action, parentNode, nextSibling, target);
8660 }
8661 }
8662 else {
8663 execRenderNodeAction(view, rn, action, parentNode, nextSibling, target);
8664 }
8665 if (nodeDef.flags & 8388608 /* EmbeddedViews */) {
8666 const /** @type {?} */ embeddedViews = ((asElementData(view, nodeDef.index).viewContainer))._embeddedViews;
8667 for (let /** @type {?} */ k = 0; k < embeddedViews.length; k++) {
8668 visitRootRenderNodes(embeddedViews[k], action, parentNode, nextSibling, target);
8669 }
8670 }
8671 if (nodeDef.flags & 1 /* TypeElement */ && !((nodeDef.element)).name) {
8672 visitSiblingRenderNodes(view, action, nodeDef.index + 1, nodeDef.index + nodeDef.childCount, parentNode, nextSibling, target);
8673 }
8674 }
8675}
8676/**
8677 * @param {?} view
8678 * @param {?} renderNode
8679 * @param {?} action
8680 * @param {?} parentNode
8681 * @param {?} nextSibling
8682 * @param {?=} target
8683 * @return {?}
8684 */
8685function execRenderNodeAction(view, renderNode, action, parentNode, nextSibling, target) {
8686 const /** @type {?} */ renderer = view.renderer;
8687 switch (action) {
8688 case 1 /* AppendChild */:
8689 renderer.appendChild(parentNode, renderNode);
8690 break;
8691 case 2 /* InsertBefore */:
8692 renderer.insertBefore(parentNode, renderNode, nextSibling);
8693 break;
8694 case 3 /* RemoveChild */:
8695 renderer.removeChild(parentNode, renderNode);
8696 break;
8697 case 0 /* Collect */:
8698 ((target)).push(renderNode);
8699 break;
8700 }
8701}
8702const NS_PREFIX_RE = /^:([^:]+):(.+)$/;
8703/**
8704 * @param {?} name
8705 * @return {?}
8706 */
8707function splitNamespace(name) {
8708 if (name[0] === ':') {
8709 const /** @type {?} */ match = ((name.match(NS_PREFIX_RE)));
8710 return [match[1], match[2]];
8711 }
8712 return ['', name];
8713}
8714/**
8715 * @param {?} bindings
8716 * @return {?}
8717 */
8718function calcBindingFlags(bindings) {
8719 let /** @type {?} */ flags = 0;
8720 for (let /** @type {?} */ i = 0; i < bindings.length; i++) {
8721 flags |= bindings[i].flags;
8722 }
8723 return flags;
8724}
8725/**
8726 * @param {?} valueCount
8727 * @param {?} constAndInterp
8728 * @return {?}
8729 */
8730function interpolate(valueCount, constAndInterp) {
8731 let /** @type {?} */ result = '';
8732 for (let /** @type {?} */ i = 0; i < valueCount * 2; i = i + 2) {
8733 result = result + constAndInterp[i] + _toStringWithNull(constAndInterp[i + 1]);
8734 }
8735 return result + constAndInterp[valueCount * 2];
8736}
8737/**
8738 * @param {?} valueCount
8739 * @param {?} c0
8740 * @param {?} a1
8741 * @param {?} c1
8742 * @param {?=} a2
8743 * @param {?=} c2
8744 * @param {?=} a3
8745 * @param {?=} c3
8746 * @param {?=} a4
8747 * @param {?=} c4
8748 * @param {?=} a5
8749 * @param {?=} c5
8750 * @param {?=} a6
8751 * @param {?=} c6
8752 * @param {?=} a7
8753 * @param {?=} c7
8754 * @param {?=} a8
8755 * @param {?=} c8
8756 * @param {?=} a9
8757 * @param {?=} c9
8758 * @return {?}
8759 */
8760function inlineInterpolate(valueCount, c0, a1, c1, a2, c2, a3, c3, a4, c4, a5, c5, a6, c6, a7, c7, a8, c8, a9, c9) {
8761 switch (valueCount) {
8762 case 1:
8763 return c0 + _toStringWithNull(a1) + c1;
8764 case 2:
8765 return c0 + _toStringWithNull(a1) + c1 + _toStringWithNull(a2) + c2;
8766 case 3:
8767 return c0 + _toStringWithNull(a1) + c1 + _toStringWithNull(a2) + c2 + _toStringWithNull(a3) +
8768 c3;
8769 case 4:
8770 return c0 + _toStringWithNull(a1) + c1 + _toStringWithNull(a2) + c2 + _toStringWithNull(a3) +
8771 c3 + _toStringWithNull(a4) + c4;
8772 case 5:
8773 return c0 + _toStringWithNull(a1) + c1 + _toStringWithNull(a2) + c2 + _toStringWithNull(a3) +
8774 c3 + _toStringWithNull(a4) + c4 + _toStringWithNull(a5) + c5;
8775 case 6:
8776 return c0 + _toStringWithNull(a1) + c1 + _toStringWithNull(a2) + c2 + _toStringWithNull(a3) +
8777 c3 + _toStringWithNull(a4) + c4 + _toStringWithNull(a5) + c5 + _toStringWithNull(a6) + c6;
8778 case 7:
8779 return c0 + _toStringWithNull(a1) + c1 + _toStringWithNull(a2) + c2 + _toStringWithNull(a3) +
8780 c3 + _toStringWithNull(a4) + c4 + _toStringWithNull(a5) + c5 + _toStringWithNull(a6) +
8781 c6 + _toStringWithNull(a7) + c7;
8782 case 8:
8783 return c0 + _toStringWithNull(a1) + c1 + _toStringWithNull(a2) + c2 + _toStringWithNull(a3) +
8784 c3 + _toStringWithNull(a4) + c4 + _toStringWithNull(a5) + c5 + _toStringWithNull(a6) +
8785 c6 + _toStringWithNull(a7) + c7 + _toStringWithNull(a8) + c8;
8786 case 9:
8787 return c0 + _toStringWithNull(a1) + c1 + _toStringWithNull(a2) + c2 + _toStringWithNull(a3) +
8788 c3 + _toStringWithNull(a4) + c4 + _toStringWithNull(a5) + c5 + _toStringWithNull(a6) +
8789 c6 + _toStringWithNull(a7) + c7 + _toStringWithNull(a8) + c8 + _toStringWithNull(a9) + c9;
8790 default:
8791 throw new Error(`Does not support more than 9 expressions`);
8792 }
8793}
8794/**
8795 * @param {?} v
8796 * @return {?}
8797 */
8798function _toStringWithNull(v) {
8799 return v != null ? v.toString() : '';
8800}
8801const EMPTY_ARRAY = [];
8802const EMPTY_MAP = {};
8803
8804/**
8805 * @license
8806 * Copyright Google Inc. All Rights Reserved.
8807 *
8808 * Use of this source code is governed by an MIT-style license that can be
8809 * found in the LICENSE file at https://angular.io/license
8810 */
8811/**
8812 * @param {?} flags
8813 * @param {?} matchedQueriesDsl
8814 * @param {?} ngContentIndex
8815 * @param {?} childCount
8816 * @param {?=} handleEvent
8817 * @param {?=} templateFactory
8818 * @return {?}
8819 */
8820function anchorDef(flags, matchedQueriesDsl, ngContentIndex, childCount, handleEvent, templateFactory) {
8821 flags |= 1 /* TypeElement */;
8822 const { matchedQueries, references, matchedQueryIds } = splitMatchedQueriesDsl(matchedQueriesDsl);
8823 const /** @type {?} */ template = templateFactory ? resolveViewDefinition(templateFactory) : null;
8824 return {
8825 // will bet set by the view definition
8826 index: -1,
8827 parent: null,
8828 renderParent: null,
8829 bindingIndex: -1,
8830 outputIndex: -1,
8831 // regular values
8832 flags,
8833 childFlags: 0,
8834 directChildFlags: 0,
8835 childMatchedQueries: 0, matchedQueries, matchedQueryIds, references, ngContentIndex, childCount,
8836 bindings: [],
8837 bindingFlags: 0,
8838 outputs: [],
8839 element: {
8840 ns: null,
8841 name: null,
8842 attrs: null, template,
8843 componentProvider: null,
8844 componentView: null,
8845 componentRendererType: null,
8846 publicProviders: null,
8847 allProviders: null,
8848 handleEvent: handleEvent || NOOP
8849 },
8850 provider: null,
8851 text: null,
8852 query: null,
8853 ngContent: null
8854 };
8855}
8856/**
8857 * @param {?} flags
8858 * @param {?} matchedQueriesDsl
8859 * @param {?} ngContentIndex
8860 * @param {?} childCount
8861 * @param {?} namespaceAndName
8862 * @param {?=} fixedAttrs
8863 * @param {?=} bindings
8864 * @param {?=} outputs
8865 * @param {?=} handleEvent
8866 * @param {?=} componentView
8867 * @param {?=} componentRendererType
8868 * @return {?}
8869 */
8870function elementDef(flags, matchedQueriesDsl, ngContentIndex, childCount, namespaceAndName, fixedAttrs = [], bindings, outputs, handleEvent, componentView, componentRendererType) {
8871 if (!handleEvent) {
8872 handleEvent = NOOP;
8873 }
8874 const { matchedQueries, references, matchedQueryIds } = splitMatchedQueriesDsl(matchedQueriesDsl);
8875 let /** @type {?} */ ns = ((null));
8876 let /** @type {?} */ name = ((null));
8877 if (namespaceAndName) {
8878 [ns, name] = splitNamespace(namespaceAndName);
8879 }
8880 bindings = bindings || [];
8881 const /** @type {?} */ bindingDefs = new Array(bindings.length);
8882 for (let /** @type {?} */ i = 0; i < bindings.length; i++) {
8883 const [bindingFlags, namespaceAndName, suffixOrSecurityContext] = bindings[i];
8884 const [ns, name] = splitNamespace(namespaceAndName);
8885 let /** @type {?} */ securityContext = ((undefined));
8886 let /** @type {?} */ suffix = ((undefined));
8887 switch (bindingFlags & 15 /* Types */) {
8888 case 4 /* TypeElementStyle */:
8889 suffix = (suffixOrSecurityContext);
8890 break;
8891 case 1 /* TypeElementAttribute */:
8892 case 8 /* TypeProperty */:
8893 securityContext = (suffixOrSecurityContext);
8894 break;
8895 }
8896 bindingDefs[i] =
8897 { flags: bindingFlags, ns, name, nonMinifiedName: name, securityContext, suffix };
8898 }
8899 outputs = outputs || [];
8900 const /** @type {?} */ outputDefs = new Array(outputs.length);
8901 for (let /** @type {?} */ i = 0; i < outputs.length; i++) {
8902 const [target, eventName] = outputs[i];
8903 outputDefs[i] = {
8904 type: 0 /* ElementOutput */,
8905 target: /** @type {?} */ (target), eventName,
8906 propName: null
8907 };
8908 }
8909 fixedAttrs = fixedAttrs || [];
8910 const /** @type {?} */ attrs = (fixedAttrs.map(([namespaceAndName, value]) => {
8911 const [ns, name] = splitNamespace(namespaceAndName);
8912 return [ns, name, value];
8913 }));
8914 componentRendererType = resolveRendererType2(componentRendererType);
8915 if (componentView) {
8916 flags |= 16777216 /* ComponentView */;
8917 }
8918 flags |= 1 /* TypeElement */;
8919 return {
8920 // will bet set by the view definition
8921 index: -1,
8922 parent: null,
8923 renderParent: null,
8924 bindingIndex: -1,
8925 outputIndex: -1,
8926 // regular values
8927 flags,
8928 childFlags: 0,
8929 directChildFlags: 0,
8930 childMatchedQueries: 0, matchedQueries, matchedQueryIds, references, ngContentIndex, childCount,
8931 bindings: bindingDefs,
8932 bindingFlags: calcBindingFlags(bindingDefs),
8933 outputs: outputDefs,
8934 element: {
8935 ns,
8936 name,
8937 attrs,
8938 template: null,
8939 // will bet set by the view definition
8940 componentProvider: null,
8941 componentView: componentView || null,
8942 componentRendererType: componentRendererType,
8943 publicProviders: null,
8944 allProviders: null,
8945 handleEvent: handleEvent || NOOP,
8946 },
8947 provider: null,
8948 text: null,
8949 query: null,
8950 ngContent: null
8951 };
8952}
8953/**
8954 * @param {?} view
8955 * @param {?} renderHost
8956 * @param {?} def
8957 * @return {?}
8958 */
8959function createElement(view, renderHost, def) {
8960 const /** @type {?} */ elDef = ((def.element));
8961 const /** @type {?} */ rootSelectorOrNode = view.root.selectorOrNode;
8962 const /** @type {?} */ renderer = view.renderer;
8963 let /** @type {?} */ el;
8964 if (view.parent || !rootSelectorOrNode) {
8965 if (elDef.name) {
8966 el = renderer.createElement(elDef.name, elDef.ns);
8967 }
8968 else {
8969 el = renderer.createComment('');
8970 }
8971 const /** @type {?} */ parentEl = getParentRenderElement(view, renderHost, def);
8972 if (parentEl) {
8973 renderer.appendChild(parentEl, el);
8974 }
8975 }
8976 else {
8977 el = renderer.selectRootElement(rootSelectorOrNode);
8978 }
8979 if (elDef.attrs) {
8980 for (let /** @type {?} */ i = 0; i < elDef.attrs.length; i++) {
8981 const [ns, name, value] = elDef.attrs[i];
8982 renderer.setAttribute(el, name, value, ns);
8983 }
8984 }
8985 return el;
8986}
8987/**
8988 * @param {?} view
8989 * @param {?} compView
8990 * @param {?} def
8991 * @param {?} el
8992 * @return {?}
8993 */
8994function listenToElementOutputs(view, compView, def, el) {
8995 for (let /** @type {?} */ i = 0; i < def.outputs.length; i++) {
8996 const /** @type {?} */ output = def.outputs[i];
8997 const /** @type {?} */ handleEventClosure = renderEventHandlerClosure(view, def.index, elementEventFullName(output.target, output.eventName));
8998 let /** @type {?} */ listenTarget = output.target;
8999 let /** @type {?} */ listenerView = view;
9000 if (output.target === 'component') {
9001 listenTarget = null;
9002 listenerView = compView;
9003 }
9004 const /** @type {?} */ disposable = (listenerView.renderer.listen(listenTarget || el, output.eventName, handleEventClosure)); /** @type {?} */
9005 ((view.disposables))[def.outputIndex + i] = disposable;
9006 }
9007}
9008/**
9009 * @param {?} view
9010 * @param {?} index
9011 * @param {?} eventName
9012 * @return {?}
9013 */
9014function renderEventHandlerClosure(view, index, eventName) {
9015 return (event) => {
9016 try {
9017 return dispatchEvent(view, index, eventName, event);
9018 }
9019 catch (e) {
9020 // Attention: Don't rethrow, to keep in sync with directive events.
9021 view.root.errorHandler.handleError(e);
9022 }
9023 };
9024}
9025/**
9026 * @param {?} view
9027 * @param {?} def
9028 * @param {?} v0
9029 * @param {?} v1
9030 * @param {?} v2
9031 * @param {?} v3
9032 * @param {?} v4
9033 * @param {?} v5
9034 * @param {?} v6
9035 * @param {?} v7
9036 * @param {?} v8
9037 * @param {?} v9
9038 * @return {?}
9039 */
9040function checkAndUpdateElementInline(view, def, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9) {
9041 const /** @type {?} */ bindLen = def.bindings.length;
9042 let /** @type {?} */ changed = false;
9043 if (bindLen > 0 && checkAndUpdateElementValue(view, def, 0, v0))
9044 changed = true;
9045 if (bindLen > 1 && checkAndUpdateElementValue(view, def, 1, v1))
9046 changed = true;
9047 if (bindLen > 2 && checkAndUpdateElementValue(view, def, 2, v2))
9048 changed = true;
9049 if (bindLen > 3 && checkAndUpdateElementValue(view, def, 3, v3))
9050 changed = true;
9051 if (bindLen > 4 && checkAndUpdateElementValue(view, def, 4, v4))
9052 changed = true;
9053 if (bindLen > 5 && checkAndUpdateElementValue(view, def, 5, v5))
9054 changed = true;
9055 if (bindLen > 6 && checkAndUpdateElementValue(view, def, 6, v6))
9056 changed = true;
9057 if (bindLen > 7 && checkAndUpdateElementValue(view, def, 7, v7))
9058 changed = true;
9059 if (bindLen > 8 && checkAndUpdateElementValue(view, def, 8, v8))
9060 changed = true;
9061 if (bindLen > 9 && checkAndUpdateElementValue(view, def, 9, v9))
9062 changed = true;
9063 return changed;
9064}
9065/**
9066 * @param {?} view
9067 * @param {?} def
9068 * @param {?} values
9069 * @return {?}
9070 */
9071function checkAndUpdateElementDynamic(view, def, values) {
9072 let /** @type {?} */ changed = false;
9073 for (let /** @type {?} */ i = 0; i < values.length; i++) {
9074 if (checkAndUpdateElementValue(view, def, i, values[i]))
9075 changed = true;
9076 }
9077 return changed;
9078}
9079/**
9080 * @param {?} view
9081 * @param {?} def
9082 * @param {?} bindingIdx
9083 * @param {?} value
9084 * @return {?}
9085 */
9086function checkAndUpdateElementValue(view, def, bindingIdx, value) {
9087 if (!checkAndUpdateBinding(view, def, bindingIdx, value)) {
9088 return false;
9089 }
9090 const /** @type {?} */ binding = def.bindings[bindingIdx];
9091 const /** @type {?} */ elData = asElementData(view, def.index);
9092 const /** @type {?} */ renderNode$$1 = elData.renderElement;
9093 const /** @type {?} */ name = ((binding.name));
9094 switch (binding.flags & 15 /* Types */) {
9095 case 1 /* TypeElementAttribute */:
9096 setElementAttribute(view, binding, renderNode$$1, binding.ns, name, value);
9097 break;
9098 case 2 /* TypeElementClass */:
9099 setElementClass(view, renderNode$$1, name, value);
9100 break;
9101 case 4 /* TypeElementStyle */:
9102 setElementStyle(view, binding, renderNode$$1, name, value);
9103 break;
9104 case 8 /* TypeProperty */:
9105 const /** @type {?} */ bindView = (def.flags & 16777216 /* ComponentView */ &&
9106 binding.flags & 32 /* SyntheticHostProperty */) ?
9107 elData.componentView :
9108 view;
9109 setElementProperty(bindView, binding, renderNode$$1, name, value);
9110 break;
9111 }
9112 return true;
9113}
9114/**
9115 * @param {?} view
9116 * @param {?} binding
9117 * @param {?} renderNode
9118 * @param {?} ns
9119 * @param {?} name
9120 * @param {?} value
9121 * @return {?}
9122 */
9123function setElementAttribute(view, binding, renderNode$$1, ns, name, value) {
9124 const /** @type {?} */ securityContext = binding.securityContext;
9125 let /** @type {?} */ renderValue = securityContext ? view.root.sanitizer.sanitize(securityContext, value) : value;
9126 renderValue = renderValue != null ? renderValue.toString() : null;
9127 const /** @type {?} */ renderer = view.renderer;
9128 if (value != null) {
9129 renderer.setAttribute(renderNode$$1, name, renderValue, ns);
9130 }
9131 else {
9132 renderer.removeAttribute(renderNode$$1, name, ns);
9133 }
9134}
9135/**
9136 * @param {?} view
9137 * @param {?} renderNode
9138 * @param {?} name
9139 * @param {?} value
9140 * @return {?}
9141 */
9142function setElementClass(view, renderNode$$1, name, value) {
9143 const /** @type {?} */ renderer = view.renderer;
9144 if (value) {
9145 renderer.addClass(renderNode$$1, name);
9146 }
9147 else {
9148 renderer.removeClass(renderNode$$1, name);
9149 }
9150}
9151/**
9152 * @param {?} view
9153 * @param {?} binding
9154 * @param {?} renderNode
9155 * @param {?} name
9156 * @param {?} value
9157 * @return {?}
9158 */
9159function setElementStyle(view, binding, renderNode$$1, name, value) {
9160 let /** @type {?} */ renderValue = view.root.sanitizer.sanitize(SecurityContext.STYLE, /** @type {?} */ (value));
9161 if (renderValue != null) {
9162 renderValue = renderValue.toString();
9163 const /** @type {?} */ unit = binding.suffix;
9164 if (unit != null) {
9165 renderValue = renderValue + unit;
9166 }
9167 }
9168 else {
9169 renderValue = null;
9170 }
9171 const /** @type {?} */ renderer = view.renderer;
9172 if (renderValue != null) {
9173 renderer.setStyle(renderNode$$1, name, renderValue);
9174 }
9175 else {
9176 renderer.removeStyle(renderNode$$1, name);
9177 }
9178}
9179/**
9180 * @param {?} view
9181 * @param {?} binding
9182 * @param {?} renderNode
9183 * @param {?} name
9184 * @param {?} value
9185 * @return {?}
9186 */
9187function setElementProperty(view, binding, renderNode$$1, name, value) {
9188 const /** @type {?} */ securityContext = binding.securityContext;
9189 let /** @type {?} */ renderValue = securityContext ? view.root.sanitizer.sanitize(securityContext, value) : value;
9190 view.renderer.setProperty(renderNode$$1, name, renderValue);
9191}
9192
9193/**
9194 * @license
9195 * Copyright Google Inc. All Rights Reserved.
9196 *
9197 * Use of this source code is governed by an MIT-style license that can be
9198 * found in the LICENSE file at https://angular.io/license
9199 */
9200/**
9201 * @param {?} ngContentIndex
9202 * @param {?} index
9203 * @return {?}
9204 */
9205function ngContentDef(ngContentIndex, index) {
9206 return {
9207 // will bet set by the view definition
9208 index: -1,
9209 parent: null,
9210 renderParent: null,
9211 bindingIndex: -1,
9212 outputIndex: -1,
9213 // regular values
9214 flags: 4 /* TypeNgContent */,
9215 childFlags: 0,
9216 directChildFlags: 0,
9217 childMatchedQueries: 0,
9218 matchedQueries: {},
9219 matchedQueryIds: 0,
9220 references: {}, ngContentIndex,
9221 childCount: 0,
9222 bindings: [],
9223 bindingFlags: 0,
9224 outputs: [],
9225 element: null,
9226 provider: null,
9227 text: null,
9228 query: null,
9229 ngContent: { index }
9230 };
9231}
9232/**
9233 * @param {?} view
9234 * @param {?} renderHost
9235 * @param {?} def
9236 * @return {?}
9237 */
9238function appendNgContent(view, renderHost, def) {
9239 const /** @type {?} */ parentEl = getParentRenderElement(view, renderHost, def);
9240 if (!parentEl) {
9241 // Nothing to do if there is no parent element.
9242 return;
9243 }
9244 const /** @type {?} */ ngContentIndex = ((def.ngContent)).index;
9245 visitProjectedRenderNodes(view, ngContentIndex, 1 /* AppendChild */, parentEl, null, undefined);
9246}
9247
9248/**
9249 * @license
9250 * Copyright Google Inc. All Rights Reserved.
9251 *
9252 * Use of this source code is governed by an MIT-style license that can be
9253 * found in the LICENSE file at https://angular.io/license
9254 */
9255/**
9256 * @param {?} parentView
9257 * @param {?} elementData
9258 * @param {?} viewIndex
9259 * @param {?} view
9260 * @return {?}
9261 */
9262function attachEmbeddedView(parentView, elementData, viewIndex, view) {
9263 let /** @type {?} */ embeddedViews = ((elementData.viewContainer))._embeddedViews;
9264 if (viewIndex === null || viewIndex === undefined) {
9265 viewIndex = embeddedViews.length;
9266 }
9267 view.viewContainerParent = parentView;
9268 addToArray(embeddedViews, /** @type {?} */ ((viewIndex)), view);
9269 const /** @type {?} */ dvcElementData = declaredViewContainer(view);
9270 if (dvcElementData && dvcElementData !== elementData) {
9271 let /** @type {?} */ projectedViews = dvcElementData.template._projectedViews;
9272 if (!projectedViews) {
9273 projectedViews = dvcElementData.template._projectedViews = [];
9274 }
9275 projectedViews.push(view);
9276 }
9277 Services.dirtyParentQueries(view);
9278 const /** @type {?} */ prevView = ((viewIndex)) > 0 ? embeddedViews[((viewIndex)) - 1] : null;
9279 renderAttachEmbeddedView(elementData, prevView, view);
9280}
9281/**
9282 * @param {?} elementData
9283 * @param {?=} viewIndex
9284 * @return {?}
9285 */
9286function detachEmbeddedView(elementData, viewIndex) {
9287 const /** @type {?} */ embeddedViews = ((elementData.viewContainer))._embeddedViews;
9288 if (viewIndex == null || viewIndex >= embeddedViews.length) {
9289 viewIndex = embeddedViews.length - 1;
9290 }
9291 if (viewIndex < 0) {
9292 return null;
9293 }
9294 const /** @type {?} */ view = embeddedViews[viewIndex];
9295 view.viewContainerParent = null;
9296 removeFromArray(embeddedViews, viewIndex);
9297 const /** @type {?} */ dvcElementData = declaredViewContainer(view);
9298 if (dvcElementData && dvcElementData !== elementData) {
9299 const /** @type {?} */ projectedViews = dvcElementData.template._projectedViews;
9300 removeFromArray(projectedViews, projectedViews.indexOf(view));
9301 }
9302 Services.dirtyParentQueries(view);
9303 renderDetachView(view);
9304 return view;
9305}
9306/**
9307 * @param {?} elementData
9308 * @param {?} oldViewIndex
9309 * @param {?} newViewIndex
9310 * @return {?}
9311 */
9312function moveEmbeddedView(elementData, oldViewIndex, newViewIndex) {
9313 const /** @type {?} */ embeddedViews = ((elementData.viewContainer))._embeddedViews;
9314 const /** @type {?} */ view = embeddedViews[oldViewIndex];
9315 removeFromArray(embeddedViews, oldViewIndex);
9316 if (newViewIndex == null) {
9317 newViewIndex = embeddedViews.length;
9318 }
9319 addToArray(embeddedViews, newViewIndex, view);
9320 // Note: Don't need to change projectedViews as the order in there
9321 // as always invalid...
9322 Services.dirtyParentQueries(view);
9323 renderDetachView(view);
9324 const /** @type {?} */ prevView = newViewIndex > 0 ? embeddedViews[newViewIndex - 1] : null;
9325 renderAttachEmbeddedView(elementData, prevView, view);
9326 return view;
9327}
9328/**
9329 * @param {?} elementData
9330 * @param {?} prevView
9331 * @param {?} view
9332 * @return {?}
9333 */
9334function renderAttachEmbeddedView(elementData, prevView, view) {
9335 const /** @type {?} */ prevRenderNode = prevView ? renderNode(prevView, /** @type {?} */ ((prevView.def.lastRenderRootNode))) :
9336 elementData.renderElement;
9337 const /** @type {?} */ parentNode = view.renderer.parentNode(prevRenderNode);
9338 const /** @type {?} */ nextSibling = view.renderer.nextSibling(prevRenderNode);
9339 // Note: We can't check if `nextSibling` is present, as on WebWorkers it will always be!
9340 // However, browsers automatically do `appendChild` when there is no `nextSibling`.
9341 visitRootRenderNodes(view, 2 /* InsertBefore */, parentNode, nextSibling, undefined);
9342}
9343/**
9344 * @param {?} view
9345 * @return {?}
9346 */
9347function renderDetachView(view) {
9348 visitRootRenderNodes(view, 3 /* RemoveChild */, null, null, undefined);
9349}
9350/**
9351 * @param {?} arr
9352 * @param {?} index
9353 * @param {?} value
9354 * @return {?}
9355 */
9356function addToArray(arr, index, value) {
9357 // perf: array.push is faster than array.splice!
9358 if (index >= arr.length) {
9359 arr.push(value);
9360 }
9361 else {
9362 arr.splice(index, 0, value);
9363 }
9364}
9365/**
9366 * @param {?} arr
9367 * @param {?} index
9368 * @return {?}
9369 */
9370function removeFromArray(arr, index) {
9371 // perf: array.pop is faster than array.splice!
9372 if (index >= arr.length - 1) {
9373 arr.pop();
9374 }
9375 else {
9376 arr.splice(index, 1);
9377 }
9378}
9379
9380/**
9381 * @license
9382 * Copyright Google Inc. All Rights Reserved.
9383 *
9384 * Use of this source code is governed by an MIT-style license that can be
9385 * found in the LICENSE file at https://angular.io/license
9386 */
9387const EMPTY_CONTEXT = new Object();
9388/**
9389 * @param {?} selector
9390 * @param {?} componentType
9391 * @param {?} viewDefFactory
9392 * @param {?} inputs
9393 * @param {?} outputs
9394 * @param {?} ngContentSelectors
9395 * @return {?}
9396 */
9397function createComponentFactory(selector, componentType, viewDefFactory, inputs, outputs, ngContentSelectors) {
9398 return new ComponentFactory_(selector, componentType, viewDefFactory, inputs, outputs, ngContentSelectors);
9399}
9400/**
9401 * @param {?} componentFactory
9402 * @return {?}
9403 */
9404function getComponentViewDefinitionFactory(componentFactory) {
9405 return ((componentFactory)).viewDefFactory;
9406}
9407class ComponentFactory_ extends ComponentFactory {
9408 /**
9409 * @param {?} selector
9410 * @param {?} componentType
9411 * @param {?} viewDefFactory
9412 * @param {?} _inputs
9413 * @param {?} _outputs
9414 * @param {?} ngContentSelectors
9415 */
9416 constructor(selector, componentType, viewDefFactory, _inputs, _outputs, ngContentSelectors) {
9417 // Attention: this ctor is called as top level function.
9418 // Putting any logic in here will destroy closure tree shaking!
9419 super();
9420 this.selector = selector;
9421 this.componentType = componentType;
9422 this._inputs = _inputs;
9423 this._outputs = _outputs;
9424 this.ngContentSelectors = ngContentSelectors;
9425 this.viewDefFactory = viewDefFactory;
9426 }
9427 /**
9428 * @return {?}
9429 */
9430 get inputs() {
9431 const /** @type {?} */ inputsArr = [];
9432 const /** @type {?} */ inputs = ((this._inputs));
9433 for (let /** @type {?} */ propName in inputs) {
9434 const /** @type {?} */ templateName = inputs[propName];
9435 inputsArr.push({ propName, templateName });
9436 }
9437 return inputsArr;
9438 }
9439 /**
9440 * @return {?}
9441 */
9442 get outputs() {
9443 const /** @type {?} */ outputsArr = [];
9444 for (let /** @type {?} */ propName in this._outputs) {
9445 const /** @type {?} */ templateName = this._outputs[propName];
9446 outputsArr.push({ propName, templateName });
9447 }
9448 return outputsArr;
9449 }
9450 /**
9451 * Creates a new component.
9452 * @param {?} injector
9453 * @param {?=} projectableNodes
9454 * @param {?=} rootSelectorOrNode
9455 * @param {?=} ngModule
9456 * @return {?}
9457 */
9458 create(injector, projectableNodes, rootSelectorOrNode, ngModule) {
9459 if (!ngModule) {
9460 throw new Error('ngModule should be provided');
9461 }
9462 const /** @type {?} */ viewDef = resolveViewDefinition(this.viewDefFactory);
9463 const /** @type {?} */ componentNodeIndex = ((((viewDef.nodes[0].element)).componentProvider)).index;
9464 const /** @type {?} */ view = Services.createRootView(injector, projectableNodes || [], rootSelectorOrNode, viewDef, ngModule, EMPTY_CONTEXT);
9465 const /** @type {?} */ component = asProviderData(view, componentNodeIndex).instance;
9466 if (rootSelectorOrNode) {
9467 view.renderer.setAttribute(asElementData(view, 0).renderElement, 'ng-version', VERSION.full);
9468 }
9469 return new ComponentRef_(view, new ViewRef_(view), component);
9470 }
9471}
9472class ComponentRef_ extends ComponentRef {
9473 /**
9474 * @param {?} _view
9475 * @param {?} _viewRef
9476 * @param {?} _component
9477 */
9478 constructor(_view, _viewRef, _component) {
9479 super();
9480 this._view = _view;
9481 this._viewRef = _viewRef;
9482 this._component = _component;
9483 this._elDef = this._view.def.nodes[0];
9484 }
9485 /**
9486 * @return {?}
9487 */
9488 get location() {
9489 return new ElementRef(asElementData(this._view, this._elDef.index).renderElement);
9490 }
9491 /**
9492 * @return {?}
9493 */
9494 get injector() { return new Injector_(this._view, this._elDef); }
9495 /**
9496 * @return {?}
9497 */
9498 get instance() { return this._component; }
9499 ;
9500 /**
9501 * @return {?}
9502 */
9503 get hostView() { return this._viewRef; }
9504 ;
9505 /**
9506 * @return {?}
9507 */
9508 get changeDetectorRef() { return this._viewRef; }
9509 ;
9510 /**
9511 * @return {?}
9512 */
9513 get componentType() { return (this._component.constructor); }
9514 /**
9515 * @return {?}
9516 */
9517 destroy() { this._viewRef.destroy(); }
9518 /**
9519 * @param {?} callback
9520 * @return {?}
9521 */
9522 onDestroy(callback) { this._viewRef.onDestroy(callback); }
9523}
9524/**
9525 * @param {?} view
9526 * @param {?} elDef
9527 * @param {?} elData
9528 * @return {?}
9529 */
9530function createViewContainerData(view, elDef, elData) {
9531 return new ViewContainerRef_(view, elDef, elData);
9532}
9533class ViewContainerRef_ {
9534 /**
9535 * @param {?} _view
9536 * @param {?} _elDef
9537 * @param {?} _data
9538 */
9539 constructor(_view, _elDef, _data) {
9540 this._view = _view;
9541 this._elDef = _elDef;
9542 this._data = _data;
9543 /**
9544 * \@internal
9545 */
9546 this._embeddedViews = [];
9547 }
9548 /**
9549 * @return {?}
9550 */
9551 get element() { return new ElementRef(this._data.renderElement); }
9552 /**
9553 * @return {?}
9554 */
9555 get injector() { return new Injector_(this._view, this._elDef); }
9556 /**
9557 * @return {?}
9558 */
9559 get parentInjector() {
9560 let /** @type {?} */ view = this._view;
9561 let /** @type {?} */ elDef = this._elDef.parent;
9562 while (!elDef && view) {
9563 elDef = viewParentEl(view);
9564 view = ((view.parent));
9565 }
9566 return view ? new Injector_(view, elDef) : new Injector_(this._view, null);
9567 }
9568 /**
9569 * @return {?}
9570 */
9571 clear() {
9572 const /** @type {?} */ len = this._embeddedViews.length;
9573 for (let /** @type {?} */ i = len - 1; i >= 0; i--) {
9574 const /** @type {?} */ view = ((detachEmbeddedView(this._data, i)));
9575 Services.destroyView(view);
9576 }
9577 }
9578 /**
9579 * @param {?} index
9580 * @return {?}
9581 */
9582 get(index) {
9583 const /** @type {?} */ view = this._embeddedViews[index];
9584 if (view) {
9585 const /** @type {?} */ ref = new ViewRef_(view);
9586 ref.attachToViewContainerRef(this);
9587 return ref;
9588 }
9589 return null;
9590 }
9591 /**
9592 * @return {?}
9593 */
9594 get length() { return this._embeddedViews.length; }
9595 ;
9596 /**
9597 * @template C
9598 * @param {?} templateRef
9599 * @param {?=} context
9600 * @param {?=} index
9601 * @return {?}
9602 */
9603 createEmbeddedView(templateRef, context, index) {
9604 const /** @type {?} */ viewRef = templateRef.createEmbeddedView(context || ({}));
9605 this.insert(viewRef, index);
9606 return viewRef;
9607 }
9608 /**
9609 * @template C
9610 * @param {?} componentFactory
9611 * @param {?=} index
9612 * @param {?=} injector
9613 * @param {?=} projectableNodes
9614 * @param {?=} ngModuleRef
9615 * @return {?}
9616 */
9617 createComponent(componentFactory, index, injector, projectableNodes, ngModuleRef) {
9618 const /** @type {?} */ contextInjector = injector || this.parentInjector;
9619 if (!ngModuleRef && !(componentFactory instanceof ComponentFactoryBoundToModule)) {
9620 ngModuleRef = contextInjector.get(NgModuleRef);
9621 }
9622 const /** @type {?} */ componentRef = componentFactory.create(contextInjector, projectableNodes, undefined, ngModuleRef);
9623 this.insert(componentRef.hostView, index);
9624 return componentRef;
9625 }
9626 /**
9627 * @param {?} viewRef
9628 * @param {?=} index
9629 * @return {?}
9630 */
9631 insert(viewRef, index) {
9632 const /** @type {?} */ viewRef_ = (viewRef);
9633 const /** @type {?} */ viewData = viewRef_._view;
9634 attachEmbeddedView(this._view, this._data, index, viewData);
9635 viewRef_.attachToViewContainerRef(this);
9636 return viewRef;
9637 }
9638 /**
9639 * @param {?} viewRef
9640 * @param {?} currentIndex
9641 * @return {?}
9642 */
9643 move(viewRef, currentIndex) {
9644 const /** @type {?} */ previousIndex = this._embeddedViews.indexOf(viewRef._view);
9645 moveEmbeddedView(this._data, previousIndex, currentIndex);
9646 return viewRef;
9647 }
9648 /**
9649 * @param {?} viewRef
9650 * @return {?}
9651 */
9652 indexOf(viewRef) {
9653 return this._embeddedViews.indexOf(((viewRef))._view);
9654 }
9655 /**
9656 * @param {?=} index
9657 * @return {?}
9658 */
9659 remove(index) {
9660 const /** @type {?} */ viewData = detachEmbeddedView(this._data, index);
9661 if (viewData) {
9662 Services.destroyView(viewData);
9663 }
9664 }
9665 /**
9666 * @param {?=} index
9667 * @return {?}
9668 */
9669 detach(index) {
9670 const /** @type {?} */ view = detachEmbeddedView(this._data, index);
9671 return view ? new ViewRef_(view) : null;
9672 }
9673}
9674/**
9675 * @param {?} view
9676 * @return {?}
9677 */
9678function createChangeDetectorRef(view) {
9679 return new ViewRef_(view);
9680}
9681class ViewRef_ {
9682 /**
9683 * @param {?} _view
9684 */
9685 constructor(_view) {
9686 this._view = _view;
9687 this._viewContainerRef = null;
9688 this._appRef = null;
9689 }
9690 /**
9691 * @return {?}
9692 */
9693 get rootNodes() { return rootRenderNodes(this._view); }
9694 /**
9695 * @return {?}
9696 */
9697 get context() { return this._view.context; }
9698 /**
9699 * @return {?}
9700 */
9701 get destroyed() { return (this._view.state & 16 /* Destroyed */) !== 0; }
9702 /**
9703 * @return {?}
9704 */
9705 markForCheck() { markParentViewsForCheck(this._view); }
9706 /**
9707 * @return {?}
9708 */
9709 detach() { this._view.state &= ~4 /* Attached */; }
9710 /**
9711 * @return {?}
9712 */
9713 detectChanges() { Services.checkAndUpdateView(this._view); }
9714 /**
9715 * @return {?}
9716 */
9717 checkNoChanges() { Services.checkNoChangesView(this._view); }
9718 /**
9719 * @return {?}
9720 */
9721 reattach() { this._view.state |= 4 /* Attached */; }
9722 /**
9723 * @param {?} callback
9724 * @return {?}
9725 */
9726 onDestroy(callback) {
9727 if (!this._view.disposables) {
9728 this._view.disposables = [];
9729 }
9730 this._view.disposables.push(/** @type {?} */ (callback));
9731 }
9732 /**
9733 * @return {?}
9734 */
9735 destroy() {
9736 if (this._appRef) {
9737 this._appRef.detachView(this);
9738 }
9739 else if (this._viewContainerRef) {
9740 this._viewContainerRef.detach(this._viewContainerRef.indexOf(this));
9741 }
9742 Services.destroyView(this._view);
9743 }
9744 /**
9745 * @return {?}
9746 */
9747 detachFromAppRef() {
9748 this._appRef = null;
9749 renderDetachView(this._view);
9750 Services.dirtyParentQueries(this._view);
9751 }
9752 /**
9753 * @param {?} appRef
9754 * @return {?}
9755 */
9756 attachToAppRef(appRef) {
9757 if (this._viewContainerRef) {
9758 throw new Error('This view is already attached to a ViewContainer!');
9759 }
9760 this._appRef = appRef;
9761 }
9762 /**
9763 * @param {?} vcRef
9764 * @return {?}
9765 */
9766 attachToViewContainerRef(vcRef) {
9767 if (this._appRef) {
9768 throw new Error('This view is already attached directly to the ApplicationRef!');
9769 }
9770 this._viewContainerRef = vcRef;
9771 }
9772}
9773/**
9774 * @param {?} view
9775 * @param {?} def
9776 * @return {?}
9777 */
9778function createTemplateData(view, def) {
9779 return new TemplateRef_(view, def);
9780}
9781class TemplateRef_ extends TemplateRef {
9782 /**
9783 * @param {?} _parentView
9784 * @param {?} _def
9785 */
9786 constructor(_parentView, _def) {
9787 super();
9788 this._parentView = _parentView;
9789 this._def = _def;
9790 }
9791 /**
9792 * @param {?} context
9793 * @return {?}
9794 */
9795 createEmbeddedView(context) {
9796 return new ViewRef_(Services.createEmbeddedView(this._parentView, this._def, context));
9797 }
9798 /**
9799 * @return {?}
9800 */
9801 get elementRef() {
9802 return new ElementRef(asElementData(this._parentView, this._def.index).renderElement);
9803 }
9804}
9805/**
9806 * @param {?} view
9807 * @param {?} elDef
9808 * @return {?}
9809 */
9810function createInjector(view, elDef) {
9811 return new Injector_(view, elDef);
9812}
9813class Injector_ {
9814 /**
9815 * @param {?} view
9816 * @param {?} elDef
9817 */
9818 constructor(view, elDef) {
9819 this.view = view;
9820 this.elDef = elDef;
9821 }
9822 /**
9823 * @param {?} token
9824 * @param {?=} notFoundValue
9825 * @return {?}
9826 */
9827 get(token, notFoundValue = Injector.THROW_IF_NOT_FOUND) {
9828 const /** @type {?} */ allowPrivateServices = this.elDef ? (this.elDef.flags & 16777216 /* ComponentView */) !== 0 : false;
9829 return Services.resolveDep(this.view, this.elDef, allowPrivateServices, { flags: 0 /* None */, token, tokenKey: tokenKey(token) }, notFoundValue);
9830 }
9831}
9832/**
9833 * @param {?} view
9834 * @param {?} index
9835 * @return {?}
9836 */
9837function nodeValue(view, index) {
9838 const /** @type {?} */ def = view.def.nodes[index];
9839 if (def.flags & 1 /* TypeElement */) {
9840 const /** @type {?} */ elData = asElementData(view, def.index);
9841 return ((def.element)).template ? elData.template : elData.renderElement;
9842 }
9843 else if (def.flags & 2 /* TypeText */) {
9844 return asTextData(view, def.index).renderText;
9845 }
9846 else if (def.flags & (10112 /* CatProvider */ | 8 /* TypePipe */)) {
9847 return asProviderData(view, def.index).instance;
9848 }
9849 throw new Error(`Illegal state: read nodeValue for node index ${index}`);
9850}
9851/**
9852 * @param {?} view
9853 * @return {?}
9854 */
9855function createRendererV1(view) {
9856 return new RendererAdapter(view.renderer);
9857}
9858class RendererAdapter {
9859 /**
9860 * @param {?} delegate
9861 */
9862 constructor(delegate) {
9863 this.delegate = delegate;
9864 }
9865 /**
9866 * @param {?} selectorOrNode
9867 * @return {?}
9868 */
9869 selectRootElement(selectorOrNode) {
9870 return this.delegate.selectRootElement(selectorOrNode);
9871 }
9872 /**
9873 * @param {?} parent
9874 * @param {?} namespaceAndName
9875 * @return {?}
9876 */
9877 createElement(parent, namespaceAndName) {
9878 const [ns, name] = splitNamespace(namespaceAndName);
9879 const /** @type {?} */ el = this.delegate.createElement(name, ns);
9880 if (parent) {
9881 this.delegate.appendChild(parent, el);
9882 }
9883 return el;
9884 }
9885 /**
9886 * @param {?} hostElement
9887 * @return {?}
9888 */
9889 createViewRoot(hostElement) { return hostElement; }
9890 /**
9891 * @param {?} parentElement
9892 * @return {?}
9893 */
9894 createTemplateAnchor(parentElement) {
9895 const /** @type {?} */ comment = this.delegate.createComment('');
9896 if (parentElement) {
9897 this.delegate.appendChild(parentElement, comment);
9898 }
9899 return comment;
9900 }
9901 /**
9902 * @param {?} parentElement
9903 * @param {?} value
9904 * @return {?}
9905 */
9906 createText(parentElement, value) {
9907 const /** @type {?} */ node = this.delegate.createText(value);
9908 if (parentElement) {
9909 this.delegate.appendChild(parentElement, node);
9910 }
9911 return node;
9912 }
9913 /**
9914 * @param {?} parentElement
9915 * @param {?} nodes
9916 * @return {?}
9917 */
9918 projectNodes(parentElement, nodes) {
9919 for (let /** @type {?} */ i = 0; i < nodes.length; i++) {
9920 this.delegate.appendChild(parentElement, nodes[i]);
9921 }
9922 }
9923 /**
9924 * @param {?} node
9925 * @param {?} viewRootNodes
9926 * @return {?}
9927 */
9928 attachViewAfter(node, viewRootNodes) {
9929 const /** @type {?} */ parentElement = this.delegate.parentNode(node);
9930 const /** @type {?} */ nextSibling = this.delegate.nextSibling(node);
9931 for (let /** @type {?} */ i = 0; i < viewRootNodes.length; i++) {
9932 this.delegate.insertBefore(parentElement, viewRootNodes[i], nextSibling);
9933 }
9934 }
9935 /**
9936 * @param {?} viewRootNodes
9937 * @return {?}
9938 */
9939 detachView(viewRootNodes) {
9940 for (let /** @type {?} */ i = 0; i < viewRootNodes.length; i++) {
9941 const /** @type {?} */ node = viewRootNodes[i];
9942 const /** @type {?} */ parentElement = this.delegate.parentNode(node);
9943 this.delegate.removeChild(parentElement, node);
9944 }
9945 }
9946 /**
9947 * @param {?} hostElement
9948 * @param {?} viewAllNodes
9949 * @return {?}
9950 */
9951 destroyView(hostElement, viewAllNodes) {
9952 for (let /** @type {?} */ i = 0; i < viewAllNodes.length; i++) {
9953 ((this.delegate.destroyNode))(viewAllNodes[i]);
9954 }
9955 }
9956 /**
9957 * @param {?} renderElement
9958 * @param {?} name
9959 * @param {?} callback
9960 * @return {?}
9961 */
9962 listen(renderElement, name, callback) {
9963 return this.delegate.listen(renderElement, name, /** @type {?} */ (callback));
9964 }
9965 /**
9966 * @param {?} target
9967 * @param {?} name
9968 * @param {?} callback
9969 * @return {?}
9970 */
9971 listenGlobal(target, name, callback) {
9972 return this.delegate.listen(target, name, /** @type {?} */ (callback));
9973 }
9974 /**
9975 * @param {?} renderElement
9976 * @param {?} propertyName
9977 * @param {?} propertyValue
9978 * @return {?}
9979 */
9980 setElementProperty(renderElement, propertyName, propertyValue) {
9981 this.delegate.setProperty(renderElement, propertyName, propertyValue);
9982 }
9983 /**
9984 * @param {?} renderElement
9985 * @param {?} namespaceAndName
9986 * @param {?} attributeValue
9987 * @return {?}
9988 */
9989 setElementAttribute(renderElement, namespaceAndName, attributeValue) {
9990 const [ns, name] = splitNamespace(namespaceAndName);
9991 if (attributeValue != null) {
9992 this.delegate.setAttribute(renderElement, name, attributeValue, ns);
9993 }
9994 else {
9995 this.delegate.removeAttribute(renderElement, name, ns);
9996 }
9997 }
9998 /**
9999 * @param {?} renderElement
10000 * @param {?} propertyName
10001 * @param {?} propertyValue
10002 * @return {?}
10003 */
10004 setBindingDebugInfo(renderElement, propertyName, propertyValue) { }
10005 /**
10006 * @param {?} renderElement
10007 * @param {?} className
10008 * @param {?} isAdd
10009 * @return {?}
10010 */
10011 setElementClass(renderElement, className, isAdd) {
10012 if (isAdd) {
10013 this.delegate.addClass(renderElement, className);
10014 }
10015 else {
10016 this.delegate.removeClass(renderElement, className);
10017 }
10018 }
10019 /**
10020 * @param {?} renderElement
10021 * @param {?} styleName
10022 * @param {?} styleValue
10023 * @return {?}
10024 */
10025 setElementStyle(renderElement, styleName, styleValue) {
10026 if (styleValue != null) {
10027 this.delegate.setStyle(renderElement, styleName, styleValue);
10028 }
10029 else {
10030 this.delegate.removeStyle(renderElement, styleName);
10031 }
10032 }
10033 /**
10034 * @param {?} renderElement
10035 * @param {?} methodName
10036 * @param {?} args
10037 * @return {?}
10038 */
10039 invokeElementMethod(renderElement, methodName, args) {
10040 ((renderElement))[methodName].apply(renderElement, args);
10041 }
10042 /**
10043 * @param {?} renderNode
10044 * @param {?} text
10045 * @return {?}
10046 */
10047 setText(renderNode$$1, text) { this.delegate.setValue(renderNode$$1, text); }
10048 /**
10049 * @return {?}
10050 */
10051 animate() { throw new Error('Renderer.animate is no longer supported!'); }
10052}
10053
10054/**
10055 * @license
10056 * Copyright Google Inc. All Rights Reserved.
10057 *
10058 * Use of this source code is governed by an MIT-style license that can be
10059 * found in the LICENSE file at https://angular.io/license
10060 */
10061const RendererV1TokenKey = tokenKey(Renderer);
10062const Renderer2TokenKey = tokenKey(Renderer2);
10063const ElementRefTokenKey = tokenKey(ElementRef);
10064const ViewContainerRefTokenKey = tokenKey(ViewContainerRef);
10065const TemplateRefTokenKey = tokenKey(TemplateRef);
10066const ChangeDetectorRefTokenKey = tokenKey(ChangeDetectorRef);
10067const InjectorRefTokenKey = tokenKey(Injector);
10068const NOT_CREATED = new Object();
10069/**
10070 * @param {?} flags
10071 * @param {?} matchedQueries
10072 * @param {?} childCount
10073 * @param {?} ctor
10074 * @param {?} deps
10075 * @param {?=} props
10076 * @param {?=} outputs
10077 * @return {?}
10078 */
10079function directiveDef(flags, matchedQueries, childCount, ctor, deps, props, outputs) {
10080 const /** @type {?} */ bindings = [];
10081 if (props) {
10082 for (let /** @type {?} */ prop in props) {
10083 const [bindingIndex, nonMinifiedName] = props[prop];
10084 bindings[bindingIndex] = {
10085 flags: 8 /* TypeProperty */,
10086 name: prop, nonMinifiedName,
10087 ns: null,
10088 securityContext: null,
10089 suffix: null
10090 };
10091 }
10092 }
10093 const /** @type {?} */ outputDefs = [];
10094 if (outputs) {
10095 for (let /** @type {?} */ propName in outputs) {
10096 outputDefs.push({ type: 1 /* DirectiveOutput */, propName, target: null, eventName: outputs[propName] });
10097 }
10098 }
10099 flags |= 8192 /* TypeDirective */;
10100 return _def(flags, matchedQueries, childCount, ctor, ctor, deps, bindings, outputDefs);
10101}
10102/**
10103 * @param {?} flags
10104 * @param {?} ctor
10105 * @param {?} deps
10106 * @return {?}
10107 */
10108function pipeDef(flags, ctor, deps) {
10109 flags |= 8 /* TypePipe */;
10110 return _def(flags, null, 0, ctor, ctor, deps);
10111}
10112/**
10113 * @param {?} flags
10114 * @param {?} matchedQueries
10115 * @param {?} token
10116 * @param {?} value
10117 * @param {?} deps
10118 * @return {?}
10119 */
10120function providerDef(flags, matchedQueries, token, value, deps) {
10121 return _def(flags, matchedQueries, 0, token, value, deps);
10122}
10123/**
10124 * @param {?} flags
10125 * @param {?} matchedQueriesDsl
10126 * @param {?} childCount
10127 * @param {?} token
10128 * @param {?} value
10129 * @param {?} deps
10130 * @param {?=} bindings
10131 * @param {?=} outputs
10132 * @return {?}
10133 */
10134function _def(flags, matchedQueriesDsl, childCount, token, value, deps, bindings, outputs) {
10135 const { matchedQueries, references, matchedQueryIds } = splitMatchedQueriesDsl(matchedQueriesDsl);
10136 if (!outputs) {
10137 outputs = [];
10138 }
10139 if (!bindings) {
10140 bindings = [];
10141 }
10142 const /** @type {?} */ depDefs = deps.map(value => {
10143 let /** @type {?} */ token;
10144 let /** @type {?} */ flags;
10145 if (Array.isArray(value)) {
10146 [flags, token] = value;
10147 }
10148 else {
10149 flags = 0 /* None */;
10150 token = value;
10151 }
10152 return { flags, token, tokenKey: tokenKey(token) };
10153 });
10154 return {
10155 // will bet set by the view definition
10156 index: -1,
10157 parent: null,
10158 renderParent: null,
10159 bindingIndex: -1,
10160 outputIndex: -1,
10161 // regular values
10162 flags,
10163 childFlags: 0,
10164 directChildFlags: 0,
10165 childMatchedQueries: 0, matchedQueries, matchedQueryIds, references,
10166 ngContentIndex: -1, childCount, bindings,
10167 bindingFlags: calcBindingFlags(bindings), outputs,
10168 element: null,
10169 provider: { token, tokenKey: tokenKey(token), value, deps: depDefs },
10170 text: null,
10171 query: null,
10172 ngContent: null
10173 };
10174}
10175/**
10176 * @param {?} view
10177 * @param {?} def
10178 * @return {?}
10179 */
10180function createProviderInstance(view, def) {
10181 return def.flags & 2048 /* LazyProvider */ ? NOT_CREATED : _createProviderInstance(view, def);
10182}
10183/**
10184 * @param {?} view
10185 * @param {?} def
10186 * @return {?}
10187 */
10188function createPipeInstance(view, def) {
10189 // deps are looked up from component.
10190 let /** @type {?} */ compView = view;
10191 while (compView.parent && !isComponentView(compView)) {
10192 compView = compView.parent;
10193 }
10194 // pipes can see the private services of the component
10195 const /** @type {?} */ allowPrivateServices = true;
10196 // pipes are always eager and classes!
10197 return createClass(/** @type {?} */ ((compView.parent)), /** @type {?} */ ((viewParentEl(compView))), allowPrivateServices, /** @type {?} */ ((def.provider)).value, /** @type {?} */ ((def.provider)).deps);
10198}
10199/**
10200 * @param {?} view
10201 * @param {?} def
10202 * @return {?}
10203 */
10204function createDirectiveInstance(view, def) {
10205 // components can see other private services, other directives can't.
10206 const /** @type {?} */ allowPrivateServices = (def.flags & 16384 /* Component */) > 0;
10207 // directives are always eager and classes!
10208 const /** @type {?} */ instance = createClass(view, /** @type {?} */ ((def.parent)), allowPrivateServices, /** @type {?} */ ((def.provider)).value, /** @type {?} */ ((def.provider)).deps);
10209 if (def.outputs.length) {
10210 for (let /** @type {?} */ i = 0; i < def.outputs.length; i++) {
10211 const /** @type {?} */ output = def.outputs[i];
10212 const /** @type {?} */ subscription = instance[((output.propName))].subscribe(eventHandlerClosure(view, /** @type {?} */ ((def.parent)).index, output.eventName)); /** @type {?} */
10213 ((view.disposables))[def.outputIndex + i] = subscription.unsubscribe.bind(subscription);
10214 }
10215 }
10216 return instance;
10217}
10218/**
10219 * @param {?} view
10220 * @param {?} index
10221 * @param {?} eventName
10222 * @return {?}
10223 */
10224function eventHandlerClosure(view, index, eventName) {
10225 return (event) => {
10226 try {
10227 return dispatchEvent(view, index, eventName, event);
10228 }
10229 catch (e) {
10230 // Attention: Don't rethrow, as it would cancel Observable subscriptions!
10231 view.root.errorHandler.handleError(e);
10232 }
10233 };
10234}
10235/**
10236 * @param {?} view
10237 * @param {?} def
10238 * @param {?} v0
10239 * @param {?} v1
10240 * @param {?} v2
10241 * @param {?} v3
10242 * @param {?} v4
10243 * @param {?} v5
10244 * @param {?} v6
10245 * @param {?} v7
10246 * @param {?} v8
10247 * @param {?} v9
10248 * @return {?}
10249 */
10250function checkAndUpdateDirectiveInline(view, def, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9) {
10251 const /** @type {?} */ providerData = asProviderData(view, def.index);
10252 const /** @type {?} */ directive = providerData.instance;
10253 let /** @type {?} */ changed = false;
10254 let /** @type {?} */ changes = ((undefined));
10255 const /** @type {?} */ bindLen = def.bindings.length;
10256 if (bindLen > 0 && checkBinding(view, def, 0, v0)) {
10257 changed = true;
10258 changes = updateProp(view, providerData, def, 0, v0, changes);
10259 }
10260 if (bindLen > 1 && checkBinding(view, def, 1, v1)) {
10261 changed = true;
10262 changes = updateProp(view, providerData, def, 1, v1, changes);
10263 }
10264 if (bindLen > 2 && checkBinding(view, def, 2, v2)) {
10265 changed = true;
10266 changes = updateProp(view, providerData, def, 2, v2, changes);
10267 }
10268 if (bindLen > 3 && checkBinding(view, def, 3, v3)) {
10269 changed = true;
10270 changes = updateProp(view, providerData, def, 3, v3, changes);
10271 }
10272 if (bindLen > 4 && checkBinding(view, def, 4, v4)) {
10273 changed = true;
10274 changes = updateProp(view, providerData, def, 4, v4, changes);
10275 }
10276 if (bindLen > 5 && checkBinding(view, def, 5, v5)) {
10277 changed = true;
10278 changes = updateProp(view, providerData, def, 5, v5, changes);
10279 }
10280 if (bindLen > 6 && checkBinding(view, def, 6, v6)) {
10281 changed = true;
10282 changes = updateProp(view, providerData, def, 6, v6, changes);
10283 }
10284 if (bindLen > 7 && checkBinding(view, def, 7, v7)) {
10285 changed = true;
10286 changes = updateProp(view, providerData, def, 7, v7, changes);
10287 }
10288 if (bindLen > 8 && checkBinding(view, def, 8, v8)) {
10289 changed = true;
10290 changes = updateProp(view, providerData, def, 8, v8, changes);
10291 }
10292 if (bindLen > 9 && checkBinding(view, def, 9, v9)) {
10293 changed = true;
10294 changes = updateProp(view, providerData, def, 9, v9, changes);
10295 }
10296 if (changes) {
10297 directive.ngOnChanges(changes);
10298 }
10299 if ((view.state & 2 /* FirstCheck */) && (def.flags & 32768 /* OnInit */)) {
10300 directive.ngOnInit();
10301 }
10302 if (def.flags & 131072 /* DoCheck */) {
10303 directive.ngDoCheck();
10304 }
10305 return changed;
10306}
10307/**
10308 * @param {?} view
10309 * @param {?} def
10310 * @param {?} values
10311 * @return {?}
10312 */
10313function checkAndUpdateDirectiveDynamic(view, def, values) {
10314 const /** @type {?} */ providerData = asProviderData(view, def.index);
10315 const /** @type {?} */ directive = providerData.instance;
10316 let /** @type {?} */ changed = false;
10317 let /** @type {?} */ changes = ((undefined));
10318 for (let /** @type {?} */ i = 0; i < values.length; i++) {
10319 if (checkBinding(view, def, i, values[i])) {
10320 changed = true;
10321 changes = updateProp(view, providerData, def, i, values[i], changes);
10322 }
10323 }
10324 if (changes) {
10325 directive.ngOnChanges(changes);
10326 }
10327 if ((view.state & 2 /* FirstCheck */) && (def.flags & 32768 /* OnInit */)) {
10328 directive.ngOnInit();
10329 }
10330 if (def.flags & 131072 /* DoCheck */) {
10331 directive.ngDoCheck();
10332 }
10333 return changed;
10334}
10335/**
10336 * @param {?} view
10337 * @param {?} def
10338 * @return {?}
10339 */
10340function _createProviderInstance(view, def) {
10341 // private services can see other private services
10342 const /** @type {?} */ allowPrivateServices = (def.flags & 4096 /* PrivateProvider */) > 0;
10343 const /** @type {?} */ providerDef = def.provider;
10344 let /** @type {?} */ injectable;
10345 switch (def.flags & 100673535 /* Types */) {
10346 case 256 /* TypeClassProvider */:
10347 injectable = createClass(view, /** @type {?} */ ((def.parent)), allowPrivateServices, /** @type {?} */ ((providerDef)).value, /** @type {?} */ ((providerDef)).deps);
10348 break;
10349 case 512 /* TypeFactoryProvider */:
10350 injectable = callFactory(view, /** @type {?} */ ((def.parent)), allowPrivateServices, /** @type {?} */ ((providerDef)).value, /** @type {?} */ ((providerDef)).deps);
10351 break;
10352 case 1024 /* TypeUseExistingProvider */:
10353 injectable = resolveDep(view, /** @type {?} */ ((def.parent)), allowPrivateServices, /** @type {?} */ ((providerDef)).deps[0]);
10354 break;
10355 case 128 /* TypeValueProvider */:
10356 injectable = ((providerDef)).value;
10357 break;
10358 }
10359 return injectable;
10360}
10361/**
10362 * @param {?} view
10363 * @param {?} elDef
10364 * @param {?} allowPrivateServices
10365 * @param {?} ctor
10366 * @param {?} deps
10367 * @return {?}
10368 */
10369function createClass(view, elDef, allowPrivateServices, ctor, deps) {
10370 const /** @type {?} */ len = deps.length;
10371 let /** @type {?} */ injectable;
10372 switch (len) {
10373 case 0:
10374 injectable = new ctor();
10375 break;
10376 case 1:
10377 injectable = new ctor(resolveDep(view, elDef, allowPrivateServices, deps[0]));
10378 break;
10379 case 2:
10380 injectable = new ctor(resolveDep(view, elDef, allowPrivateServices, deps[0]), resolveDep(view, elDef, allowPrivateServices, deps[1]));
10381 break;
10382 case 3:
10383 injectable = new ctor(resolveDep(view, elDef, allowPrivateServices, deps[0]), resolveDep(view, elDef, allowPrivateServices, deps[1]), resolveDep(view, elDef, allowPrivateServices, deps[2]));
10384 break;
10385 default:
10386 const /** @type {?} */ depValues = new Array(len);
10387 for (let /** @type {?} */ i = 0; i < len; i++) {
10388 depValues[i] = resolveDep(view, elDef, allowPrivateServices, deps[i]);
10389 }
10390 injectable = new ctor(...depValues);
10391 }
10392 return injectable;
10393}
10394/**
10395 * @param {?} view
10396 * @param {?} elDef
10397 * @param {?} allowPrivateServices
10398 * @param {?} factory
10399 * @param {?} deps
10400 * @return {?}
10401 */
10402function callFactory(view, elDef, allowPrivateServices, factory, deps) {
10403 const /** @type {?} */ len = deps.length;
10404 let /** @type {?} */ injectable;
10405 switch (len) {
10406 case 0:
10407 injectable = factory();
10408 break;
10409 case 1:
10410 injectable = factory(resolveDep(view, elDef, allowPrivateServices, deps[0]));
10411 break;
10412 case 2:
10413 injectable = factory(resolveDep(view, elDef, allowPrivateServices, deps[0]), resolveDep(view, elDef, allowPrivateServices, deps[1]));
10414 break;
10415 case 3:
10416 injectable = factory(resolveDep(view, elDef, allowPrivateServices, deps[0]), resolveDep(view, elDef, allowPrivateServices, deps[1]), resolveDep(view, elDef, allowPrivateServices, deps[2]));
10417 break;
10418 default:
10419 const /** @type {?} */ depValues = Array(len);
10420 for (let /** @type {?} */ i = 0; i < len; i++) {
10421 depValues[i] = resolveDep(view, elDef, allowPrivateServices, deps[i]);
10422 }
10423 injectable = factory(...depValues);
10424 }
10425 return injectable;
10426}
10427// This default value is when checking the hierarchy for a token.
10428//
10429// It means both:
10430// - the token is not provided by the current injector,
10431// - only the element injectors should be checked (ie do not check module injectors
10432//
10433// mod1
10434// /
10435// el1 mod2
10436// \ /
10437// el2
10438//
10439// When requesting el2.injector.get(token), we should check in the following order and return the
10440// first found value:
10441// - el2.injector.get(token, default)
10442// - el1.injector.get(token, NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR) -> do not check the module
10443// - mod2.injector.get(token, default)
10444const NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR = {};
10445/**
10446 * @param {?} view
10447 * @param {?} elDef
10448 * @param {?} allowPrivateServices
10449 * @param {?} depDef
10450 * @param {?=} notFoundValue
10451 * @return {?}
10452 */
10453function resolveDep(view, elDef, allowPrivateServices, depDef, notFoundValue = Injector.THROW_IF_NOT_FOUND) {
10454 if (depDef.flags & 8 /* Value */) {
10455 return depDef.token;
10456 }
10457 const /** @type {?} */ startView = view;
10458 if (depDef.flags & 2 /* Optional */) {
10459 notFoundValue = null;
10460 }
10461 const /** @type {?} */ tokenKey$$1 = depDef.tokenKey;
10462 if (tokenKey$$1 === ChangeDetectorRefTokenKey) {
10463 // directives on the same element as a component should be able to control the change detector
10464 // of that component as well.
10465 allowPrivateServices = !!(elDef && ((elDef.element)).componentView);
10466 }
10467 if (elDef && (depDef.flags & 1 /* SkipSelf */)) {
10468 allowPrivateServices = false;
10469 elDef = ((elDef.parent));
10470 }
10471 while (view) {
10472 if (elDef) {
10473 switch (tokenKey$$1) {
10474 case RendererV1TokenKey: {
10475 const /** @type {?} */ compView = findCompView(view, elDef, allowPrivateServices);
10476 return createRendererV1(compView);
10477 }
10478 case Renderer2TokenKey: {
10479 const /** @type {?} */ compView = findCompView(view, elDef, allowPrivateServices);
10480 return compView.renderer;
10481 }
10482 case ElementRefTokenKey:
10483 return new ElementRef(asElementData(view, elDef.index).renderElement);
10484 case ViewContainerRefTokenKey:
10485 return asElementData(view, elDef.index).viewContainer;
10486 case TemplateRefTokenKey: {
10487 if (((elDef.element)).template) {
10488 return asElementData(view, elDef.index).template;
10489 }
10490 break;
10491 }
10492 case ChangeDetectorRefTokenKey: {
10493 let /** @type {?} */ cdView = findCompView(view, elDef, allowPrivateServices);
10494 return createChangeDetectorRef(cdView);
10495 }
10496 case InjectorRefTokenKey:
10497 return createInjector(view, elDef);
10498 default:
10499 const /** @type {?} */ providerDef = (((allowPrivateServices ? ((elDef.element)).allProviders : ((elDef.element)).publicProviders)))[tokenKey$$1];
10500 if (providerDef) {
10501 const /** @type {?} */ providerData = asProviderData(view, providerDef.index);
10502 if (providerData.instance === NOT_CREATED) {
10503 providerData.instance = _createProviderInstance(view, providerDef);
10504 }
10505 return providerData.instance;
10506 }
10507 }
10508 }
10509 allowPrivateServices = isComponentView(view);
10510 elDef = ((viewParentEl(view)));
10511 view = ((view.parent));
10512 }
10513 const /** @type {?} */ value = startView.root.injector.get(depDef.token, NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR);
10514 if (value !== NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR ||
10515 notFoundValue === NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR) {
10516 // Return the value from the root element injector when
10517 // - it provides it
10518 // (value !== NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR)
10519 // - the module injector should not be checked
10520 // (notFoundValue === NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR)
10521 return value;
10522 }
10523 return startView.root.ngModule.injector.get(depDef.token, notFoundValue);
10524}
10525/**
10526 * @param {?} view
10527 * @param {?} elDef
10528 * @param {?} allowPrivateServices
10529 * @return {?}
10530 */
10531function findCompView(view, elDef, allowPrivateServices) {
10532 let /** @type {?} */ compView;
10533 if (allowPrivateServices) {
10534 compView = asElementData(view, elDef.index).componentView;
10535 }
10536 else {
10537 compView = view;
10538 while (compView.parent && !isComponentView(compView)) {
10539 compView = compView.parent;
10540 }
10541 }
10542 return compView;
10543}
10544/**
10545 * @param {?} view
10546 * @param {?} providerData
10547 * @param {?} def
10548 * @param {?} bindingIdx
10549 * @param {?} value
10550 * @param {?} changes
10551 * @return {?}
10552 */
10553function updateProp(view, providerData, def, bindingIdx, value, changes) {
10554 if (def.flags & 16384 /* Component */) {
10555 const /** @type {?} */ compView = asElementData(view, /** @type {?} */ ((def.parent)).index).componentView;
10556 if (compView.def.flags & 2 /* OnPush */) {
10557 compView.state |= 8 /* ChecksEnabled */;
10558 }
10559 }
10560 const /** @type {?} */ binding = def.bindings[bindingIdx];
10561 const /** @type {?} */ propName = ((binding.name));
10562 // Note: This is still safe with Closure Compiler as
10563 // the user passed in the property name as an object has to `providerDef`,
10564 // so Closure Compiler will have renamed the property correctly already.
10565 providerData.instance[propName] = value;
10566 if (def.flags & 262144 /* OnChanges */) {
10567 changes = changes || {};
10568 let /** @type {?} */ oldValue = view.oldValues[def.bindingIndex + bindingIdx];
10569 if (oldValue instanceof WrappedValue) {
10570 oldValue = oldValue.wrapped;
10571 }
10572 const /** @type {?} */ binding = def.bindings[bindingIdx];
10573 changes[((binding.nonMinifiedName))] =
10574 new SimpleChange(oldValue, value, (view.state & 2 /* FirstCheck */) !== 0);
10575 }
10576 view.oldValues[def.bindingIndex + bindingIdx] = value;
10577 return changes;
10578}
10579/**
10580 * @param {?} view
10581 * @param {?} lifecycles
10582 * @return {?}
10583 */
10584function callLifecycleHooksChildrenFirst(view, lifecycles) {
10585 if (!(view.def.nodeFlags & lifecycles)) {
10586 return;
10587 }
10588 const /** @type {?} */ nodes = view.def.nodes;
10589 for (let /** @type {?} */ i = 0; i < nodes.length; i++) {
10590 const /** @type {?} */ nodeDef = nodes[i];
10591 let /** @type {?} */ parent = nodeDef.parent;
10592 if (!parent && nodeDef.flags & lifecycles) {
10593 // matching root node (e.g. a pipe)
10594 callProviderLifecycles(view, i, nodeDef.flags & lifecycles);
10595 }
10596 if ((nodeDef.childFlags & lifecycles) === 0) {
10597 // no child matches one of the lifecycles
10598 i += nodeDef.childCount;
10599 }
10600 while (parent && (parent.flags & 1 /* TypeElement */) &&
10601 i === parent.index + parent.childCount) {
10602 // last child of an element
10603 if (parent.directChildFlags & lifecycles) {
10604 callElementProvidersLifecycles(view, parent, lifecycles);
10605 }
10606 parent = parent.parent;
10607 }
10608 }
10609}
10610/**
10611 * @param {?} view
10612 * @param {?} elDef
10613 * @param {?} lifecycles
10614 * @return {?}
10615 */
10616function callElementProvidersLifecycles(view, elDef, lifecycles) {
10617 for (let /** @type {?} */ i = elDef.index + 1; i <= elDef.index + elDef.childCount; i++) {
10618 const /** @type {?} */ nodeDef = view.def.nodes[i];
10619 if (nodeDef.flags & lifecycles) {
10620 callProviderLifecycles(view, i, nodeDef.flags & lifecycles);
10621 }
10622 // only visit direct children
10623 i += nodeDef.childCount;
10624 }
10625}
10626/**
10627 * @param {?} view
10628 * @param {?} index
10629 * @param {?} lifecycles
10630 * @return {?}
10631 */
10632function callProviderLifecycles(view, index, lifecycles) {
10633 const /** @type {?} */ provider = asProviderData(view, index).instance;
10634 if (provider === NOT_CREATED) {
10635 return;
10636 }
10637 Services.setCurrentNode(view, index);
10638 if (lifecycles & 524288 /* AfterContentInit */) {
10639 provider.ngAfterContentInit();
10640 }
10641 if (lifecycles & 1048576 /* AfterContentChecked */) {
10642 provider.ngAfterContentChecked();
10643 }
10644 if (lifecycles & 2097152 /* AfterViewInit */) {
10645 provider.ngAfterViewInit();
10646 }
10647 if (lifecycles & 4194304 /* AfterViewChecked */) {
10648 provider.ngAfterViewChecked();
10649 }
10650 if (lifecycles & 65536 /* OnDestroy */) {
10651 provider.ngOnDestroy();
10652 }
10653}
10654
10655/**
10656 * @license
10657 * Copyright Google Inc. All Rights Reserved.
10658 *
10659 * Use of this source code is governed by an MIT-style license that can be
10660 * found in the LICENSE file at https://angular.io/license
10661 */
10662/**
10663 * @param {?} argCount
10664 * @return {?}
10665 */
10666function purePipeDef(argCount) {
10667 // argCount + 1 to include the pipe as first arg
10668 return _pureExpressionDef(64 /* TypePurePipe */, new Array(argCount + 1));
10669}
10670/**
10671 * @param {?} argCount
10672 * @return {?}
10673 */
10674function pureArrayDef(argCount) {
10675 return _pureExpressionDef(16 /* TypePureArray */, new Array(argCount));
10676}
10677/**
10678 * @param {?} propertyNames
10679 * @return {?}
10680 */
10681function pureObjectDef(propertyNames) {
10682 return _pureExpressionDef(32 /* TypePureObject */, propertyNames);
10683}
10684/**
10685 * @param {?} flags
10686 * @param {?} propertyNames
10687 * @return {?}
10688 */
10689function _pureExpressionDef(flags, propertyNames) {
10690 const /** @type {?} */ bindings = new Array(propertyNames.length);
10691 for (let /** @type {?} */ i = 0; i < propertyNames.length; i++) {
10692 const /** @type {?} */ prop = propertyNames[i];
10693 bindings[i] = {
10694 flags: 8 /* TypeProperty */,
10695 name: prop,
10696 ns: null,
10697 nonMinifiedName: prop,
10698 securityContext: null,
10699 suffix: null
10700 };
10701 }
10702 return {
10703 // will bet set by the view definition
10704 index: -1,
10705 parent: null,
10706 renderParent: null,
10707 bindingIndex: -1,
10708 outputIndex: -1,
10709 // regular values
10710 flags,
10711 childFlags: 0,
10712 directChildFlags: 0,
10713 childMatchedQueries: 0,
10714 matchedQueries: {},
10715 matchedQueryIds: 0,
10716 references: {},
10717 ngContentIndex: -1,
10718 childCount: 0, bindings,
10719 bindingFlags: calcBindingFlags(bindings),
10720 outputs: [],
10721 element: null,
10722 provider: null,
10723 text: null,
10724 query: null,
10725 ngContent: null
10726 };
10727}
10728/**
10729 * @param {?} view
10730 * @param {?} def
10731 * @return {?}
10732 */
10733function createPureExpression(view, def) {
10734 return { value: undefined };
10735}
10736/**
10737 * @param {?} view
10738 * @param {?} def
10739 * @param {?} v0
10740 * @param {?} v1
10741 * @param {?} v2
10742 * @param {?} v3
10743 * @param {?} v4
10744 * @param {?} v5
10745 * @param {?} v6
10746 * @param {?} v7
10747 * @param {?} v8
10748 * @param {?} v9
10749 * @return {?}
10750 */
10751function checkAndUpdatePureExpressionInline(view, def, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9) {
10752 const /** @type {?} */ bindings = def.bindings;
10753 let /** @type {?} */ changed = false;
10754 const /** @type {?} */ bindLen = bindings.length;
10755 if (bindLen > 0 && checkAndUpdateBinding(view, def, 0, v0))
10756 changed = true;
10757 if (bindLen > 1 && checkAndUpdateBinding(view, def, 1, v1))
10758 changed = true;
10759 if (bindLen > 2 && checkAndUpdateBinding(view, def, 2, v2))
10760 changed = true;
10761 if (bindLen > 3 && checkAndUpdateBinding(view, def, 3, v3))
10762 changed = true;
10763 if (bindLen > 4 && checkAndUpdateBinding(view, def, 4, v4))
10764 changed = true;
10765 if (bindLen > 5 && checkAndUpdateBinding(view, def, 5, v5))
10766 changed = true;
10767 if (bindLen > 6 && checkAndUpdateBinding(view, def, 6, v6))
10768 changed = true;
10769 if (bindLen > 7 && checkAndUpdateBinding(view, def, 7, v7))
10770 changed = true;
10771 if (bindLen > 8 && checkAndUpdateBinding(view, def, 8, v8))
10772 changed = true;
10773 if (bindLen > 9 && checkAndUpdateBinding(view, def, 9, v9))
10774 changed = true;
10775 if (changed) {
10776 const /** @type {?} */ data = asPureExpressionData(view, def.index);
10777 let /** @type {?} */ value;
10778 switch (def.flags & 100673535 /* Types */) {
10779 case 16 /* TypePureArray */:
10780 value = new Array(bindings.length);
10781 if (bindLen > 0)
10782 value[0] = v0;
10783 if (bindLen > 1)
10784 value[1] = v1;
10785 if (bindLen > 2)
10786 value[2] = v2;
10787 if (bindLen > 3)
10788 value[3] = v3;
10789 if (bindLen > 4)
10790 value[4] = v4;
10791 if (bindLen > 5)
10792 value[5] = v5;
10793 if (bindLen > 6)
10794 value[6] = v6;
10795 if (bindLen > 7)
10796 value[7] = v7;
10797 if (bindLen > 8)
10798 value[8] = v8;
10799 if (bindLen > 9)
10800 value[9] = v9;
10801 break;
10802 case 32 /* TypePureObject */:
10803 value = {};
10804 if (bindLen > 0)
10805 value[((bindings[0].name))] = v0;
10806 if (bindLen > 1)
10807 value[((bindings[1].name))] = v1;
10808 if (bindLen > 2)
10809 value[((bindings[2].name))] = v2;
10810 if (bindLen > 3)
10811 value[((bindings[3].name))] = v3;
10812 if (bindLen > 4)
10813 value[((bindings[4].name))] = v4;
10814 if (bindLen > 5)
10815 value[((bindings[5].name))] = v5;
10816 if (bindLen > 6)
10817 value[((bindings[6].name))] = v6;
10818 if (bindLen > 7)
10819 value[((bindings[7].name))] = v7;
10820 if (bindLen > 8)
10821 value[((bindings[8].name))] = v8;
10822 if (bindLen > 9)
10823 value[((bindings[9].name))] = v9;
10824 break;
10825 case 64 /* TypePurePipe */:
10826 const /** @type {?} */ pipe = v0;
10827 switch (bindLen) {
10828 case 1:
10829 value = pipe.transform(v0);
10830 break;
10831 case 2:
10832 value = pipe.transform(v1);
10833 break;
10834 case 3:
10835 value = pipe.transform(v1, v2);
10836 break;
10837 case 4:
10838 value = pipe.transform(v1, v2, v3);
10839 break;
10840 case 5:
10841 value = pipe.transform(v1, v2, v3, v4);
10842 break;
10843 case 6:
10844 value = pipe.transform(v1, v2, v3, v4, v5);
10845 break;
10846 case 7:
10847 value = pipe.transform(v1, v2, v3, v4, v5, v6);
10848 break;
10849 case 8:
10850 value = pipe.transform(v1, v2, v3, v4, v5, v6, v7);
10851 break;
10852 case 9:
10853 value = pipe.transform(v1, v2, v3, v4, v5, v6, v7, v8);
10854 break;
10855 case 10:
10856 value = pipe.transform(v1, v2, v3, v4, v5, v6, v7, v8, v9);
10857 break;
10858 }
10859 break;
10860 }
10861 data.value = value;
10862 }
10863 return changed;
10864}
10865/**
10866 * @param {?} view
10867 * @param {?} def
10868 * @param {?} values
10869 * @return {?}
10870 */
10871function checkAndUpdatePureExpressionDynamic(view, def, values) {
10872 const /** @type {?} */ bindings = def.bindings;
10873 let /** @type {?} */ changed = false;
10874 for (let /** @type {?} */ i = 0; i < values.length; i++) {
10875 // Note: We need to loop over all values, so that
10876 // the old values are updates as well!
10877 if (checkAndUpdateBinding(view, def, i, values[i])) {
10878 changed = true;
10879 }
10880 }
10881 if (changed) {
10882 const /** @type {?} */ data = asPureExpressionData(view, def.index);
10883 let /** @type {?} */ value;
10884 switch (def.flags & 100673535 /* Types */) {
10885 case 16 /* TypePureArray */:
10886 value = values;
10887 break;
10888 case 32 /* TypePureObject */:
10889 value = {};
10890 for (let /** @type {?} */ i = 0; i < values.length; i++) {
10891 value[((bindings[i].name))] = values[i];
10892 }
10893 break;
10894 case 64 /* TypePurePipe */:
10895 const /** @type {?} */ pipe = values[0];
10896 const /** @type {?} */ params = values.slice(1);
10897 value = ((pipe.transform))(...params);
10898 break;
10899 }
10900 data.value = value;
10901 }
10902 return changed;
10903}
10904
10905/**
10906 * @license
10907 * Copyright Google Inc. All Rights Reserved.
10908 *
10909 * Use of this source code is governed by an MIT-style license that can be
10910 * found in the LICENSE file at https://angular.io/license
10911 */
10912/**
10913 * @param {?} flags
10914 * @param {?} id
10915 * @param {?} bindings
10916 * @return {?}
10917 */
10918function queryDef(flags, id, bindings) {
10919 let /** @type {?} */ bindingDefs = [];
10920 for (let /** @type {?} */ propName in bindings) {
10921 const /** @type {?} */ bindingType = bindings[propName];
10922 bindingDefs.push({ propName, bindingType });
10923 }
10924 return {
10925 // will bet set by the view definition
10926 index: -1,
10927 parent: null,
10928 renderParent: null,
10929 bindingIndex: -1,
10930 outputIndex: -1,
10931 // regular values
10932 flags,
10933 childFlags: 0,
10934 directChildFlags: 0,
10935 childMatchedQueries: 0,
10936 ngContentIndex: -1,
10937 matchedQueries: {},
10938 matchedQueryIds: 0,
10939 references: {},
10940 childCount: 0,
10941 bindings: [],
10942 bindingFlags: 0,
10943 outputs: [],
10944 element: null,
10945 provider: null,
10946 text: null,
10947 query: { id, filterId: filterQueryId(id), bindings: bindingDefs },
10948 ngContent: null
10949 };
10950}
10951/**
10952 * @return {?}
10953 */
10954function createQuery() {
10955 return new QueryList();
10956}
10957/**
10958 * @param {?} view
10959 * @return {?}
10960 */
10961function dirtyParentQueries(view) {
10962 const /** @type {?} */ queryIds = view.def.nodeMatchedQueries;
10963 while (view.parent && isEmbeddedView(view)) {
10964 let /** @type {?} */ tplDef = ((view.parentNodeDef));
10965 view = view.parent;
10966 // content queries
10967 const /** @type {?} */ end = tplDef.index + tplDef.childCount;
10968 for (let /** @type {?} */ i = 0; i <= end; i++) {
10969 const /** @type {?} */ nodeDef = view.def.nodes[i];
10970 if ((nodeDef.flags & 33554432 /* TypeContentQuery */) &&
10971 (nodeDef.flags & 268435456 /* DynamicQuery */) &&
10972 (((nodeDef.query)).filterId & queryIds) === ((nodeDef.query)).filterId) {
10973 asQueryList(view, i).setDirty();
10974 }
10975 if ((nodeDef.flags & 1 /* TypeElement */ && i + nodeDef.childCount < tplDef.index) ||
10976 !(nodeDef.childFlags & 33554432 /* TypeContentQuery */) ||
10977 !(nodeDef.childFlags & 268435456 /* DynamicQuery */)) {
10978 // skip elements that don't contain the template element or no query.
10979 i += nodeDef.childCount;
10980 }
10981 }
10982 }
10983 // view queries
10984 if (view.def.nodeFlags & 67108864 /* TypeViewQuery */) {
10985 for (let /** @type {?} */ i = 0; i < view.def.nodes.length; i++) {
10986 const /** @type {?} */ nodeDef = view.def.nodes[i];
10987 if ((nodeDef.flags & 67108864 /* TypeViewQuery */) && (nodeDef.flags & 268435456 /* DynamicQuery */)) {
10988 asQueryList(view, i).setDirty();
10989 }
10990 // only visit the root nodes
10991 i += nodeDef.childCount;
10992 }
10993 }
10994}
10995/**
10996 * @param {?} view
10997 * @param {?} nodeDef
10998 * @return {?}
10999 */
11000function checkAndUpdateQuery(view, nodeDef) {
11001 const /** @type {?} */ queryList = asQueryList(view, nodeDef.index);
11002 if (!queryList.dirty) {
11003 return;
11004 }
11005 let /** @type {?} */ directiveInstance;
11006 let /** @type {?} */ newValues = ((undefined));
11007 if (nodeDef.flags & 33554432 /* TypeContentQuery */) {
11008 const /** @type {?} */ elementDef = ((((nodeDef.parent)).parent));
11009 newValues = calcQueryValues(view, elementDef.index, elementDef.index + elementDef.childCount, /** @type {?} */ ((nodeDef.query)), []);
11010 directiveInstance = asProviderData(view, /** @type {?} */ ((nodeDef.parent)).index).instance;
11011 }
11012 else if (nodeDef.flags & 67108864 /* TypeViewQuery */) {
11013 newValues = calcQueryValues(view, 0, view.def.nodes.length - 1, /** @type {?} */ ((nodeDef.query)), []);
11014 directiveInstance = view.component;
11015 }
11016 queryList.reset(newValues);
11017 const /** @type {?} */ bindings = ((nodeDef.query)).bindings;
11018 let /** @type {?} */ notify = false;
11019 for (let /** @type {?} */ i = 0; i < bindings.length; i++) {
11020 const /** @type {?} */ binding = bindings[i];
11021 let /** @type {?} */ boundValue;
11022 switch (binding.bindingType) {
11023 case 0 /* First */:
11024 boundValue = queryList.first;
11025 break;
11026 case 1 /* All */:
11027 boundValue = queryList;
11028 notify = true;
11029 break;
11030 }
11031 directiveInstance[binding.propName] = boundValue;
11032 }
11033 if (notify) {
11034 queryList.notifyOnChanges();
11035 }
11036}
11037/**
11038 * @param {?} view
11039 * @param {?} startIndex
11040 * @param {?} endIndex
11041 * @param {?} queryDef
11042 * @param {?} values
11043 * @return {?}
11044 */
11045function calcQueryValues(view, startIndex, endIndex, queryDef, values) {
11046 for (let /** @type {?} */ i = startIndex; i <= endIndex; i++) {
11047 const /** @type {?} */ nodeDef = view.def.nodes[i];
11048 const /** @type {?} */ valueType = nodeDef.matchedQueries[queryDef.id];
11049 if (valueType != null) {
11050 values.push(getQueryValue(view, nodeDef, valueType));
11051 }
11052 if (nodeDef.flags & 1 /* TypeElement */ && ((nodeDef.element)).template &&
11053 (((((nodeDef.element)).template)).nodeMatchedQueries & queryDef.filterId) ===
11054 queryDef.filterId) {
11055 // check embedded views that were attached at the place of their template.
11056 const /** @type {?} */ elementData = asElementData(view, i);
11057 if (nodeDef.flags & 8388608 /* EmbeddedViews */) {
11058 const /** @type {?} */ embeddedViews = ((elementData.viewContainer))._embeddedViews;
11059 for (let /** @type {?} */ k = 0; k < embeddedViews.length; k++) {
11060 const /** @type {?} */ embeddedView = embeddedViews[k];
11061 const /** @type {?} */ dvc = declaredViewContainer(embeddedView);
11062 if (dvc && dvc === elementData) {
11063 calcQueryValues(embeddedView, 0, embeddedView.def.nodes.length - 1, queryDef, values);
11064 }
11065 }
11066 }
11067 const /** @type {?} */ projectedViews = elementData.template._projectedViews;
11068 if (projectedViews) {
11069 for (let /** @type {?} */ k = 0; k < projectedViews.length; k++) {
11070 const /** @type {?} */ projectedView = projectedViews[k];
11071 calcQueryValues(projectedView, 0, projectedView.def.nodes.length - 1, queryDef, values);
11072 }
11073 }
11074 }
11075 if ((nodeDef.childMatchedQueries & queryDef.filterId) !== queryDef.filterId) {
11076 // if no child matches the query, skip the children.
11077 i += nodeDef.childCount;
11078 }
11079 }
11080 return values;
11081}
11082/**
11083 * @param {?} view
11084 * @param {?} nodeDef
11085 * @param {?} queryValueType
11086 * @return {?}
11087 */
11088function getQueryValue(view, nodeDef, queryValueType) {
11089 if (queryValueType != null) {
11090 // a match
11091 let /** @type {?} */ value;
11092 switch (queryValueType) {
11093 case 1 /* RenderElement */:
11094 value = asElementData(view, nodeDef.index).renderElement;
11095 break;
11096 case 0 /* ElementRef */:
11097 value = new ElementRef(asElementData(view, nodeDef.index).renderElement);
11098 break;
11099 case 2 /* TemplateRef */:
11100 value = asElementData(view, nodeDef.index).template;
11101 break;
11102 case 3 /* ViewContainerRef */:
11103 value = asElementData(view, nodeDef.index).viewContainer;
11104 break;
11105 case 4 /* Provider */:
11106 value = asProviderData(view, nodeDef.index).instance;
11107 break;
11108 }
11109 return value;
11110 }
11111}
11112
11113/**
11114 * @license
11115 * Copyright Google Inc. All Rights Reserved.
11116 *
11117 * Use of this source code is governed by an MIT-style license that can be
11118 * found in the LICENSE file at https://angular.io/license
11119 */
11120/**
11121 * @param {?} ngContentIndex
11122 * @param {?} constants
11123 * @return {?}
11124 */
11125function textDef(ngContentIndex, constants) {
11126 const /** @type {?} */ bindings = new Array(constants.length - 1);
11127 for (let /** @type {?} */ i = 1; i < constants.length; i++) {
11128 bindings[i - 1] = {
11129 flags: 8 /* TypeProperty */,
11130 name: null,
11131 ns: null,
11132 nonMinifiedName: null,
11133 securityContext: null,
11134 suffix: constants[i]
11135 };
11136 }
11137 const /** @type {?} */ flags = 2;
11138 return {
11139 // will bet set by the view definition
11140 index: -1,
11141 parent: null,
11142 renderParent: null,
11143 bindingIndex: -1,
11144 outputIndex: -1,
11145 // regular values
11146 flags,
11147 childFlags: 0,
11148 directChildFlags: 0,
11149 childMatchedQueries: 0,
11150 matchedQueries: {},
11151 matchedQueryIds: 0,
11152 references: {}, ngContentIndex,
11153 childCount: 0, bindings,
11154 bindingFlags: calcBindingFlags(bindings),
11155 outputs: [],
11156 element: null,
11157 provider: null,
11158 text: { prefix: constants[0] },
11159 query: null,
11160 ngContent: null
11161 };
11162}
11163/**
11164 * @param {?} view
11165 * @param {?} renderHost
11166 * @param {?} def
11167 * @return {?}
11168 */
11169function createText(view, renderHost, def) {
11170 let /** @type {?} */ renderNode$$1;
11171 const /** @type {?} */ renderer = view.renderer;
11172 renderNode$$1 = renderer.createText(/** @type {?} */ ((def.text)).prefix);
11173 const /** @type {?} */ parentEl = getParentRenderElement(view, renderHost, def);
11174 if (parentEl) {
11175 renderer.appendChild(parentEl, renderNode$$1);
11176 }
11177 return { renderText: renderNode$$1 };
11178}
11179/**
11180 * @param {?} view
11181 * @param {?} def
11182 * @param {?} v0
11183 * @param {?} v1
11184 * @param {?} v2
11185 * @param {?} v3
11186 * @param {?} v4
11187 * @param {?} v5
11188 * @param {?} v6
11189 * @param {?} v7
11190 * @param {?} v8
11191 * @param {?} v9
11192 * @return {?}
11193 */
11194function checkAndUpdateTextInline(view, def, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9) {
11195 let /** @type {?} */ changed = false;
11196 const /** @type {?} */ bindings = def.bindings;
11197 const /** @type {?} */ bindLen = bindings.length;
11198 if (bindLen > 0 && checkAndUpdateBinding(view, def, 0, v0))
11199 changed = true;
11200 if (bindLen > 1 && checkAndUpdateBinding(view, def, 1, v1))
11201 changed = true;
11202 if (bindLen > 2 && checkAndUpdateBinding(view, def, 2, v2))
11203 changed = true;
11204 if (bindLen > 3 && checkAndUpdateBinding(view, def, 3, v3))
11205 changed = true;
11206 if (bindLen > 4 && checkAndUpdateBinding(view, def, 4, v4))
11207 changed = true;
11208 if (bindLen > 5 && checkAndUpdateBinding(view, def, 5, v5))
11209 changed = true;
11210 if (bindLen > 6 && checkAndUpdateBinding(view, def, 6, v6))
11211 changed = true;
11212 if (bindLen > 7 && checkAndUpdateBinding(view, def, 7, v7))
11213 changed = true;
11214 if (bindLen > 8 && checkAndUpdateBinding(view, def, 8, v8))
11215 changed = true;
11216 if (bindLen > 9 && checkAndUpdateBinding(view, def, 9, v9))
11217 changed = true;
11218 if (changed) {
11219 let /** @type {?} */ value = ((def.text)).prefix;
11220 if (bindLen > 0)
11221 value += _addInterpolationPart(v0, bindings[0]);
11222 if (bindLen > 1)
11223 value += _addInterpolationPart(v1, bindings[1]);
11224 if (bindLen > 2)
11225 value += _addInterpolationPart(v2, bindings[2]);
11226 if (bindLen > 3)
11227 value += _addInterpolationPart(v3, bindings[3]);
11228 if (bindLen > 4)
11229 value += _addInterpolationPart(v4, bindings[4]);
11230 if (bindLen > 5)
11231 value += _addInterpolationPart(v5, bindings[5]);
11232 if (bindLen > 6)
11233 value += _addInterpolationPart(v6, bindings[6]);
11234 if (bindLen > 7)
11235 value += _addInterpolationPart(v7, bindings[7]);
11236 if (bindLen > 8)
11237 value += _addInterpolationPart(v8, bindings[8]);
11238 if (bindLen > 9)
11239 value += _addInterpolationPart(v9, bindings[9]);
11240 const /** @type {?} */ renderNode$$1 = asTextData(view, def.index).renderText;
11241 view.renderer.setValue(renderNode$$1, value);
11242 }
11243 return changed;
11244}
11245/**
11246 * @param {?} view
11247 * @param {?} def
11248 * @param {?} values
11249 * @return {?}
11250 */
11251function checkAndUpdateTextDynamic(view, def, values) {
11252 const /** @type {?} */ bindings = def.bindings;
11253 let /** @type {?} */ changed = false;
11254 for (let /** @type {?} */ i = 0; i < values.length; i++) {
11255 // Note: We need to loop over all values, so that
11256 // the old values are updates as well!
11257 if (checkAndUpdateBinding(view, def, i, values[i])) {
11258 changed = true;
11259 }
11260 }
11261 if (changed) {
11262 let /** @type {?} */ value = '';
11263 for (let /** @type {?} */ i = 0; i < values.length; i++) {
11264 value = value + _addInterpolationPart(values[i], bindings[i]);
11265 }
11266 value = ((def.text)).prefix + value;
11267 const /** @type {?} */ renderNode$$1 = asTextData(view, def.index).renderText;
11268 view.renderer.setValue(renderNode$$1, value);
11269 }
11270 return changed;
11271}
11272/**
11273 * @param {?} value
11274 * @param {?} binding
11275 * @return {?}
11276 */
11277function _addInterpolationPart(value, binding) {
11278 const /** @type {?} */ valueStr = value != null ? value.toString() : '';
11279 return valueStr + binding.suffix;
11280}
11281
11282/**
11283 * @license
11284 * Copyright Google Inc. All Rights Reserved.
11285 *
11286 * Use of this source code is governed by an MIT-style license that can be
11287 * found in the LICENSE file at https://angular.io/license
11288 */
11289/**
11290 * @param {?} flags
11291 * @param {?} nodes
11292 * @param {?=} updateDirectives
11293 * @param {?=} updateRenderer
11294 * @return {?}
11295 */
11296function viewDef(flags, nodes, updateDirectives, updateRenderer) {
11297 // clone nodes and set auto calculated values
11298 let /** @type {?} */ viewBindingCount = 0;
11299 let /** @type {?} */ viewDisposableCount = 0;
11300 let /** @type {?} */ viewNodeFlags = 0;
11301 let /** @type {?} */ viewRootNodeFlags = 0;
11302 let /** @type {?} */ viewMatchedQueries = 0;
11303 let /** @type {?} */ currentParent = null;
11304 let /** @type {?} */ currentElementHasPublicProviders = false;
11305 let /** @type {?} */ currentElementHasPrivateProviders = false;
11306 let /** @type {?} */ lastRenderRootNode = null;
11307 for (let /** @type {?} */ i = 0; i < nodes.length; i++) {
11308 while (currentParent && i > currentParent.index + currentParent.childCount) {
11309 const /** @type {?} */ newParent = currentParent.parent;
11310 if (newParent) {
11311 newParent.childFlags |= ((currentParent.childFlags));
11312 newParent.childMatchedQueries |= currentParent.childMatchedQueries;
11313 }
11314 currentParent = newParent;
11315 }
11316 const /** @type {?} */ node = nodes[i];
11317 node.index = i;
11318 node.parent = currentParent;
11319 node.bindingIndex = viewBindingCount;
11320 node.outputIndex = viewDisposableCount;
11321 // renderParent needs to account for ng-container!
11322 let /** @type {?} */ currentRenderParent;
11323 if (currentParent && currentParent.flags & 1 /* TypeElement */ &&
11324 !((currentParent.element)).name) {
11325 currentRenderParent = currentParent.renderParent;
11326 }
11327 else {
11328 currentRenderParent = currentParent;
11329 }
11330 node.renderParent = currentRenderParent;
11331 if (node.element) {
11332 const /** @type {?} */ elDef = node.element;
11333 elDef.publicProviders =
11334 currentParent ? ((currentParent.element)).publicProviders : Object.create(null);
11335 elDef.allProviders = elDef.publicProviders;
11336 // Note: We assume that all providers of an element are before any child element!
11337 currentElementHasPublicProviders = false;
11338 currentElementHasPrivateProviders = false;
11339 }
11340 validateNode(currentParent, node, nodes.length);
11341 viewNodeFlags |= node.flags;
11342 viewMatchedQueries |= node.matchedQueryIds;
11343 if (node.element && node.element.template) {
11344 viewMatchedQueries |= node.element.template.nodeMatchedQueries;
11345 }
11346 if (currentParent) {
11347 currentParent.childFlags |= node.flags;
11348 currentParent.directChildFlags |= node.flags;
11349 currentParent.childMatchedQueries |= node.matchedQueryIds;
11350 if (node.element && node.element.template) {
11351 currentParent.childMatchedQueries |= node.element.template.nodeMatchedQueries;
11352 }
11353 }
11354 else {
11355 viewRootNodeFlags |= node.flags;
11356 }
11357 viewBindingCount += node.bindings.length;
11358 viewDisposableCount += node.outputs.length;
11359 if (!currentRenderParent && (node.flags & 3 /* CatRenderNode */)) {
11360 lastRenderRootNode = node;
11361 }
11362 if (node.flags & 10112 /* CatProvider */) {
11363 if (!currentElementHasPublicProviders) {
11364 currentElementHasPublicProviders = true; /** @type {?} */
11365 ((((
11366 // Use prototypical inheritance to not get O(n^2) complexity...
11367 currentParent)).element)).publicProviders =
11368 Object.create(/** @type {?} */ ((((currentParent)).element)).publicProviders); /** @type {?} */
11369 ((((currentParent)).element)).allProviders = ((((currentParent)).element)).publicProviders;
11370 }
11371 const /** @type {?} */ isPrivateService = (node.flags & 4096 /* PrivateProvider */) !== 0;
11372 const /** @type {?} */ isComponent = (node.flags & 16384 /* Component */) !== 0;
11373 if (!isPrivateService || isComponent) {
11374 ((((((currentParent)).element)).publicProviders))[((node.provider)).tokenKey] = node;
11375 }
11376 else {
11377 if (!currentElementHasPrivateProviders) {
11378 currentElementHasPrivateProviders = true; /** @type {?} */
11379 ((((
11380 // Use protoyypical inheritance to not get O(n^2) complexity...
11381 currentParent)).element)).allProviders =
11382 Object.create(/** @type {?} */ ((((currentParent)).element)).publicProviders);
11383 } /** @type {?} */
11384 ((((((currentParent)).element)).allProviders))[((node.provider)).tokenKey] = node;
11385 }
11386 if (isComponent) {
11387 ((((currentParent)).element)).componentProvider = node;
11388 }
11389 }
11390 if (node.childCount) {
11391 currentParent = node;
11392 }
11393 }
11394 while (currentParent) {
11395 const /** @type {?} */ newParent = currentParent.parent;
11396 if (newParent) {
11397 newParent.childFlags |= currentParent.childFlags;
11398 newParent.childMatchedQueries |= currentParent.childMatchedQueries;
11399 }
11400 currentParent = newParent;
11401 }
11402 const /** @type {?} */ handleEvent = (view, nodeIndex, eventName, event) => ((((nodes[nodeIndex].element)).handleEvent))(view, eventName, event);
11403 return {
11404 // Will be filled later...
11405 factory: null,
11406 nodeFlags: viewNodeFlags,
11407 rootNodeFlags: viewRootNodeFlags,
11408 nodeMatchedQueries: viewMatchedQueries, flags,
11409 nodes: nodes,
11410 updateDirectives: updateDirectives || NOOP,
11411 updateRenderer: updateRenderer || NOOP,
11412 handleEvent: handleEvent || NOOP,
11413 bindingCount: viewBindingCount,
11414 outputCount: viewDisposableCount, lastRenderRootNode
11415 };
11416}
11417/**
11418 * @param {?} parent
11419 * @param {?} node
11420 * @param {?} nodeCount
11421 * @return {?}
11422 */
11423function validateNode(parent, node, nodeCount) {
11424 const /** @type {?} */ template = node.element && node.element.template;
11425 if (template) {
11426 if (!template.lastRenderRootNode) {
11427 throw new Error(`Illegal State: Embedded templates without nodes are not allowed!`);
11428 }
11429 if (template.lastRenderRootNode &&
11430 template.lastRenderRootNode.flags & 8388608 /* EmbeddedViews */) {
11431 throw new Error(`Illegal State: Last root node of a template can't have embedded views, at index ${node.index}!`);
11432 }
11433 }
11434 if (node.flags & 10112 /* CatProvider */) {
11435 const /** @type {?} */ parentFlags = parent ? parent.flags : 0;
11436 if ((parentFlags & 1 /* TypeElement */) === 0) {
11437 throw new Error(`Illegal State: Provider/Directive nodes need to be children of elements or anchors, at index ${node.index}!`);
11438 }
11439 }
11440 if (node.query) {
11441 if (node.flags & 33554432 /* TypeContentQuery */ &&
11442 (!parent || (parent.flags & 8192 /* TypeDirective */) === 0)) {
11443 throw new Error(`Illegal State: Content Query nodes need to be children of directives, at index ${node.index}!`);
11444 }
11445 if (node.flags & 67108864 /* TypeViewQuery */ && parent) {
11446 throw new Error(`Illegal State: View Query nodes have to be top level nodes, at index ${node.index}!`);
11447 }
11448 }
11449 if (node.childCount) {
11450 const /** @type {?} */ parentEnd = parent ? parent.index + parent.childCount : nodeCount - 1;
11451 if (node.index <= parentEnd && node.index + node.childCount > parentEnd) {
11452 throw new Error(`Illegal State: childCount of node leads outside of parent, at index ${node.index}!`);
11453 }
11454 }
11455}
11456/**
11457 * @param {?} parent
11458 * @param {?} anchorDef
11459 * @param {?=} context
11460 * @return {?}
11461 */
11462function createEmbeddedView(parent, anchorDef$$1, context) {
11463 // embedded views are seen as siblings to the anchor, so we need
11464 // to get the parent of the anchor and use it as parentIndex.
11465 const /** @type {?} */ view = createView(parent.root, parent.renderer, parent, anchorDef$$1, /** @type {?} */ ((((anchorDef$$1.element)).template)));
11466 initView(view, parent.component, context);
11467 createViewNodes(view);
11468 return view;
11469}
11470/**
11471 * @param {?} root
11472 * @param {?} def
11473 * @param {?=} context
11474 * @return {?}
11475 */
11476function createRootView(root, def, context) {
11477 const /** @type {?} */ view = createView(root, root.renderer, null, null, def);
11478 initView(view, context, context);
11479 createViewNodes(view);
11480 return view;
11481}
11482/**
11483 * @param {?} root
11484 * @param {?} renderer
11485 * @param {?} parent
11486 * @param {?} parentNodeDef
11487 * @param {?} def
11488 * @return {?}
11489 */
11490function createView(root, renderer, parent, parentNodeDef, def) {
11491 const /** @type {?} */ nodes = new Array(def.nodes.length);
11492 const /** @type {?} */ disposables = def.outputCount ? new Array(def.outputCount) : null;
11493 const /** @type {?} */ view = {
11494 def,
11495 parent,
11496 viewContainerParent: null, parentNodeDef,
11497 context: null,
11498 component: null, nodes,
11499 state: 13 /* CatInit */, root, renderer,
11500 oldValues: new Array(def.bindingCount), disposables
11501 };
11502 return view;
11503}
11504/**
11505 * @param {?} view
11506 * @param {?} component
11507 * @param {?} context
11508 * @return {?}
11509 */
11510function initView(view, component, context) {
11511 view.component = component;
11512 view.context = context;
11513}
11514/**
11515 * @param {?} view
11516 * @return {?}
11517 */
11518function createViewNodes(view) {
11519 let /** @type {?} */ renderHost;
11520 if (isComponentView(view)) {
11521 const /** @type {?} */ hostDef = view.parentNodeDef;
11522 renderHost = asElementData(/** @type {?} */ ((view.parent)), /** @type {?} */ ((((hostDef)).parent)).index).renderElement;
11523 }
11524 const /** @type {?} */ def = view.def;
11525 const /** @type {?} */ nodes = view.nodes;
11526 for (let /** @type {?} */ i = 0; i < def.nodes.length; i++) {
11527 const /** @type {?} */ nodeDef = def.nodes[i];
11528 Services.setCurrentNode(view, i);
11529 let /** @type {?} */ nodeData;
11530 switch (nodeDef.flags & 100673535 /* Types */) {
11531 case 1 /* TypeElement */:
11532 const /** @type {?} */ el = (createElement(view, renderHost, nodeDef));
11533 let /** @type {?} */ componentView = ((undefined));
11534 if (nodeDef.flags & 16777216 /* ComponentView */) {
11535 const /** @type {?} */ compViewDef = resolveViewDefinition(/** @type {?} */ ((((nodeDef.element)).componentView)));
11536 const /** @type {?} */ rendererType = ((nodeDef.element)).componentRendererType;
11537 let /** @type {?} */ compRenderer;
11538 if (!rendererType) {
11539 compRenderer = view.root.renderer;
11540 }
11541 else {
11542 compRenderer = view.root.rendererFactory.createRenderer(el, rendererType);
11543 }
11544 componentView = createView(view.root, compRenderer, view, /** @type {?} */ ((nodeDef.element)).componentProvider, compViewDef);
11545 }
11546 listenToElementOutputs(view, componentView, nodeDef, el);
11547 nodeData = ({
11548 renderElement: el,
11549 componentView,
11550 viewContainer: null,
11551 template: /** @type {?} */ ((nodeDef.element)).template ? createTemplateData(view, nodeDef) : undefined
11552 });
11553 if (nodeDef.flags & 8388608 /* EmbeddedViews */) {
11554 nodeData.viewContainer = createViewContainerData(view, nodeDef, nodeData);
11555 }
11556 break;
11557 case 2 /* TypeText */:
11558 nodeData = (createText(view, renderHost, nodeDef));
11559 break;
11560 case 256 /* TypeClassProvider */:
11561 case 512 /* TypeFactoryProvider */:
11562 case 1024 /* TypeUseExistingProvider */:
11563 case 128 /* TypeValueProvider */: {
11564 const /** @type {?} */ instance = createProviderInstance(view, nodeDef);
11565 nodeData = ({ instance });
11566 break;
11567 }
11568 case 8 /* TypePipe */: {
11569 const /** @type {?} */ instance = createPipeInstance(view, nodeDef);
11570 nodeData = ({ instance });
11571 break;
11572 }
11573 case 8192 /* TypeDirective */: {
11574 const /** @type {?} */ instance = createDirectiveInstance(view, nodeDef);
11575 nodeData = ({ instance });
11576 if (nodeDef.flags & 16384 /* Component */) {
11577 const /** @type {?} */ compView = asElementData(view, /** @type {?} */ ((nodeDef.parent)).index).componentView;
11578 initView(compView, instance, instance);
11579 }
11580 break;
11581 }
11582 case 16 /* TypePureArray */:
11583 case 32 /* TypePureObject */:
11584 case 64 /* TypePurePipe */:
11585 nodeData = (createPureExpression(view, nodeDef));
11586 break;
11587 case 33554432 /* TypeContentQuery */:
11588 case 67108864 /* TypeViewQuery */:
11589 nodeData = (createQuery());
11590 break;
11591 case 4 /* TypeNgContent */:
11592 appendNgContent(view, renderHost, nodeDef);
11593 // no runtime data needed for NgContent...
11594 nodeData = undefined;
11595 break;
11596 }
11597 nodes[i] = nodeData;
11598 }
11599 // Create the ViewData.nodes of component views after we created everything else,
11600 // so that e.g. ng-content works
11601 execComponentViewsAction(view, ViewAction.CreateViewNodes);
11602 // fill static content and view queries
11603 execQueriesAction(view, 33554432 /* TypeContentQuery */ | 67108864 /* TypeViewQuery */, 134217728 /* StaticQuery */, 0 /* CheckAndUpdate */);
11604}
11605/**
11606 * @param {?} view
11607 * @return {?}
11608 */
11609function checkNoChangesView(view) {
11610 Services.updateDirectives(view, 1 /* CheckNoChanges */);
11611 execEmbeddedViewsAction(view, ViewAction.CheckNoChanges);
11612 Services.updateRenderer(view, 1 /* CheckNoChanges */);
11613 execComponentViewsAction(view, ViewAction.CheckNoChanges);
11614 // Note: We don't check queries for changes as we didn't do this in v2.x.
11615 // TODO(tbosch): investigate if we can enable the check again in v5.x with a nicer error message.
11616}
11617/**
11618 * @param {?} view
11619 * @return {?}
11620 */
11621function checkAndUpdateView(view) {
11622 if (view.state & 1 /* BeforeFirstCheck */) {
11623 view.state &= ~1 /* BeforeFirstCheck */;
11624 view.state |= 2 /* FirstCheck */;
11625 }
11626 else {
11627 view.state &= ~2 /* FirstCheck */;
11628 }
11629 Services.updateDirectives(view, 0 /* CheckAndUpdate */);
11630 execEmbeddedViewsAction(view, ViewAction.CheckAndUpdate);
11631 execQueriesAction(view, 33554432 /* TypeContentQuery */, 268435456 /* DynamicQuery */, 0 /* CheckAndUpdate */);
11632 callLifecycleHooksChildrenFirst(view, 1048576 /* AfterContentChecked */ |
11633 (view.state & 2 /* FirstCheck */ ? 524288 /* AfterContentInit */ : 0));
11634 Services.updateRenderer(view, 0 /* CheckAndUpdate */);
11635 execComponentViewsAction(view, ViewAction.CheckAndUpdate);
11636 execQueriesAction(view, 67108864 /* TypeViewQuery */, 268435456 /* DynamicQuery */, 0 /* CheckAndUpdate */);
11637 callLifecycleHooksChildrenFirst(view, 4194304 /* AfterViewChecked */ |
11638 (view.state & 2 /* FirstCheck */ ? 2097152 /* AfterViewInit */ : 0));
11639 if (view.def.flags & 2 /* OnPush */) {
11640 view.state &= ~8 /* ChecksEnabled */;
11641 }
11642}
11643/**
11644 * @param {?} view
11645 * @param {?} nodeDef
11646 * @param {?} argStyle
11647 * @param {?=} v0
11648 * @param {?=} v1
11649 * @param {?=} v2
11650 * @param {?=} v3
11651 * @param {?=} v4
11652 * @param {?=} v5
11653 * @param {?=} v6
11654 * @param {?=} v7
11655 * @param {?=} v8
11656 * @param {?=} v9
11657 * @return {?}
11658 */
11659function checkAndUpdateNode(view, nodeDef, argStyle, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9) {
11660 if (argStyle === 0 /* Inline */) {
11661 return checkAndUpdateNodeInline(view, nodeDef, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9);
11662 }
11663 else {
11664 return checkAndUpdateNodeDynamic(view, nodeDef, v0);
11665 }
11666}
11667/**
11668 * @param {?} view
11669 * @param {?} nodeDef
11670 * @param {?=} v0
11671 * @param {?=} v1
11672 * @param {?=} v2
11673 * @param {?=} v3
11674 * @param {?=} v4
11675 * @param {?=} v5
11676 * @param {?=} v6
11677 * @param {?=} v7
11678 * @param {?=} v8
11679 * @param {?=} v9
11680 * @return {?}
11681 */
11682function checkAndUpdateNodeInline(view, nodeDef, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9) {
11683 let /** @type {?} */ changed = false;
11684 switch (nodeDef.flags & 100673535 /* Types */) {
11685 case 1 /* TypeElement */:
11686 changed = checkAndUpdateElementInline(view, nodeDef, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9);
11687 break;
11688 case 2 /* TypeText */:
11689 changed = checkAndUpdateTextInline(view, nodeDef, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9);
11690 break;
11691 case 8192 /* TypeDirective */:
11692 changed =
11693 checkAndUpdateDirectiveInline(view, nodeDef, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9);
11694 break;
11695 case 16 /* TypePureArray */:
11696 case 32 /* TypePureObject */:
11697 case 64 /* TypePurePipe */:
11698 changed =
11699 checkAndUpdatePureExpressionInline(view, nodeDef, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9);
11700 break;
11701 }
11702 return changed;
11703}
11704/**
11705 * @param {?} view
11706 * @param {?} nodeDef
11707 * @param {?} values
11708 * @return {?}
11709 */
11710function checkAndUpdateNodeDynamic(view, nodeDef, values) {
11711 let /** @type {?} */ changed = false;
11712 switch (nodeDef.flags & 100673535 /* Types */) {
11713 case 1 /* TypeElement */:
11714 changed = checkAndUpdateElementDynamic(view, nodeDef, values);
11715 break;
11716 case 2 /* TypeText */:
11717 changed = checkAndUpdateTextDynamic(view, nodeDef, values);
11718 break;
11719 case 8192 /* TypeDirective */:
11720 changed = checkAndUpdateDirectiveDynamic(view, nodeDef, values);
11721 break;
11722 case 16 /* TypePureArray */:
11723 case 32 /* TypePureObject */:
11724 case 64 /* TypePurePipe */:
11725 changed = checkAndUpdatePureExpressionDynamic(view, nodeDef, values);
11726 break;
11727 }
11728 if (changed) {
11729 // Update oldValues after all bindings have been updated,
11730 // as a setter for a property might update other properties.
11731 const /** @type {?} */ bindLen = nodeDef.bindings.length;
11732 const /** @type {?} */ bindingStart = nodeDef.bindingIndex;
11733 const /** @type {?} */ oldValues = view.oldValues;
11734 for (let /** @type {?} */ i = 0; i < bindLen; i++) {
11735 oldValues[bindingStart + i] = values[i];
11736 }
11737 }
11738 return changed;
11739}
11740/**
11741 * @param {?} view
11742 * @param {?} nodeDef
11743 * @param {?} argStyle
11744 * @param {?=} v0
11745 * @param {?=} v1
11746 * @param {?=} v2
11747 * @param {?=} v3
11748 * @param {?=} v4
11749 * @param {?=} v5
11750 * @param {?=} v6
11751 * @param {?=} v7
11752 * @param {?=} v8
11753 * @param {?=} v9
11754 * @return {?}
11755 */
11756function checkNoChangesNode(view, nodeDef, argStyle, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9) {
11757 if (argStyle === 0 /* Inline */) {
11758 checkNoChangesNodeInline(view, nodeDef, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9);
11759 }
11760 else {
11761 checkNoChangesNodeDynamic(view, nodeDef, v0);
11762 }
11763 // Returning false is ok here as we would have thrown in case of a change.
11764 return false;
11765}
11766/**
11767 * @param {?} view
11768 * @param {?} nodeDef
11769 * @param {?} v0
11770 * @param {?} v1
11771 * @param {?} v2
11772 * @param {?} v3
11773 * @param {?} v4
11774 * @param {?} v5
11775 * @param {?} v6
11776 * @param {?} v7
11777 * @param {?} v8
11778 * @param {?} v9
11779 * @return {?}
11780 */
11781function checkNoChangesNodeInline(view, nodeDef, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9) {
11782 const /** @type {?} */ bindLen = nodeDef.bindings.length;
11783 if (bindLen > 0)
11784 checkBindingNoChanges(view, nodeDef, 0, v0);
11785 if (bindLen > 1)
11786 checkBindingNoChanges(view, nodeDef, 1, v1);
11787 if (bindLen > 2)
11788 checkBindingNoChanges(view, nodeDef, 2, v2);
11789 if (bindLen > 3)
11790 checkBindingNoChanges(view, nodeDef, 3, v3);
11791 if (bindLen > 4)
11792 checkBindingNoChanges(view, nodeDef, 4, v4);
11793 if (bindLen > 5)
11794 checkBindingNoChanges(view, nodeDef, 5, v5);
11795 if (bindLen > 6)
11796 checkBindingNoChanges(view, nodeDef, 6, v6);
11797 if (bindLen > 7)
11798 checkBindingNoChanges(view, nodeDef, 7, v7);
11799 if (bindLen > 8)
11800 checkBindingNoChanges(view, nodeDef, 8, v8);
11801 if (bindLen > 9)
11802 checkBindingNoChanges(view, nodeDef, 9, v9);
11803}
11804/**
11805 * @param {?} view
11806 * @param {?} nodeDef
11807 * @param {?} values
11808 * @return {?}
11809 */
11810function checkNoChangesNodeDynamic(view, nodeDef, values) {
11811 for (let /** @type {?} */ i = 0; i < values.length; i++) {
11812 checkBindingNoChanges(view, nodeDef, i, values[i]);
11813 }
11814}
11815/**
11816 * @param {?} view
11817 * @param {?} nodeDef
11818 * @return {?}
11819 */
11820function checkNoChangesQuery(view, nodeDef) {
11821 const /** @type {?} */ queryList = asQueryList(view, nodeDef.index);
11822 if (queryList.dirty) {
11823 throw expressionChangedAfterItHasBeenCheckedError(Services.createDebugContext(view, nodeDef.index), `Query ${ /** @type {?} */((nodeDef.query)).id} not dirty`, `Query ${ /** @type {?} */((nodeDef.query)).id} dirty`, (view.state & 1 /* BeforeFirstCheck */) !== 0);
11824 }
11825}
11826/**
11827 * @param {?} view
11828 * @return {?}
11829 */
11830function destroyView(view) {
11831 if (view.state & 16 /* Destroyed */) {
11832 return;
11833 }
11834 execEmbeddedViewsAction(view, ViewAction.Destroy);
11835 execComponentViewsAction(view, ViewAction.Destroy);
11836 callLifecycleHooksChildrenFirst(view, 65536 /* OnDestroy */);
11837 if (view.disposables) {
11838 for (let /** @type {?} */ i = 0; i < view.disposables.length; i++) {
11839 view.disposables[i]();
11840 }
11841 }
11842 if (view.renderer.destroyNode) {
11843 destroyViewNodes(view);
11844 }
11845 if (isComponentView(view)) {
11846 view.renderer.destroy();
11847 }
11848 view.state |= 16 /* Destroyed */;
11849}
11850/**
11851 * @param {?} view
11852 * @return {?}
11853 */
11854function destroyViewNodes(view) {
11855 const /** @type {?} */ len = view.def.nodes.length;
11856 for (let /** @type {?} */ i = 0; i < len; i++) {
11857 const /** @type {?} */ def = view.def.nodes[i];
11858 if (def.flags & 1 /* TypeElement */) {
11859 ((view.renderer.destroyNode))(asElementData(view, i).renderElement);
11860 }
11861 else if (def.flags & 2 /* TypeText */) {
11862 ((view.renderer.destroyNode))(asTextData(view, i).renderText);
11863 }
11864 }
11865}
11866let ViewAction = {};
11867ViewAction.CreateViewNodes = 0;
11868ViewAction.CheckNoChanges = 1;
11869ViewAction.CheckAndUpdate = 2;
11870ViewAction.Destroy = 3;
11871ViewAction[ViewAction.CreateViewNodes] = "CreateViewNodes";
11872ViewAction[ViewAction.CheckNoChanges] = "CheckNoChanges";
11873ViewAction[ViewAction.CheckAndUpdate] = "CheckAndUpdate";
11874ViewAction[ViewAction.Destroy] = "Destroy";
11875/**
11876 * @param {?} view
11877 * @param {?} action
11878 * @return {?}
11879 */
11880function execComponentViewsAction(view, action) {
11881 const /** @type {?} */ def = view.def;
11882 if (!(def.nodeFlags & 16777216 /* ComponentView */)) {
11883 return;
11884 }
11885 for (let /** @type {?} */ i = 0; i < def.nodes.length; i++) {
11886 const /** @type {?} */ nodeDef = def.nodes[i];
11887 if (nodeDef.flags & 16777216 /* ComponentView */) {
11888 // a leaf
11889 callViewAction(asElementData(view, i).componentView, action);
11890 }
11891 else if ((nodeDef.childFlags & 16777216 /* ComponentView */) === 0) {
11892 // a parent with leafs
11893 // no child is a component,
11894 // then skip the children
11895 i += nodeDef.childCount;
11896 }
11897 }
11898}
11899/**
11900 * @param {?} view
11901 * @param {?} action
11902 * @return {?}
11903 */
11904function execEmbeddedViewsAction(view, action) {
11905 const /** @type {?} */ def = view.def;
11906 if (!(def.nodeFlags & 8388608 /* EmbeddedViews */)) {
11907 return;
11908 }
11909 for (let /** @type {?} */ i = 0; i < def.nodes.length; i++) {
11910 const /** @type {?} */ nodeDef = def.nodes[i];
11911 if (nodeDef.flags & 8388608 /* EmbeddedViews */) {
11912 // a leaf
11913 const /** @type {?} */ embeddedViews = ((asElementData(view, i).viewContainer))._embeddedViews;
11914 for (let /** @type {?} */ k = 0; k < embeddedViews.length; k++) {
11915 callViewAction(embeddedViews[k], action);
11916 }
11917 }
11918 else if ((nodeDef.childFlags & 8388608 /* EmbeddedViews */) === 0) {
11919 // a parent with leafs
11920 // no child is a component,
11921 // then skip the children
11922 i += nodeDef.childCount;
11923 }
11924 }
11925}
11926/**
11927 * @param {?} view
11928 * @param {?} action
11929 * @return {?}
11930 */
11931function callViewAction(view, action) {
11932 const /** @type {?} */ viewState = view.state;
11933 switch (action) {
11934 case ViewAction.CheckNoChanges:
11935 if ((viewState & 12 /* CatDetectChanges */) === 12 /* CatDetectChanges */ &&
11936 (viewState & 16 /* Destroyed */) === 0) {
11937 checkNoChangesView(view);
11938 }
11939 break;
11940 case ViewAction.CheckAndUpdate:
11941 if ((viewState & 12 /* CatDetectChanges */) === 12 /* CatDetectChanges */ &&
11942 (viewState & 16 /* Destroyed */) === 0) {
11943 checkAndUpdateView(view);
11944 }
11945 break;
11946 case ViewAction.Destroy:
11947 destroyView(view);
11948 break;
11949 case ViewAction.CreateViewNodes:
11950 createViewNodes(view);
11951 break;
11952 }
11953}
11954/**
11955 * @param {?} view
11956 * @param {?} queryFlags
11957 * @param {?} staticDynamicQueryFlag
11958 * @param {?} checkType
11959 * @return {?}
11960 */
11961function execQueriesAction(view, queryFlags, staticDynamicQueryFlag, checkType) {
11962 if (!(view.def.nodeFlags & queryFlags) || !(view.def.nodeFlags & staticDynamicQueryFlag)) {
11963 return;
11964 }
11965 const /** @type {?} */ nodeCount = view.def.nodes.length;
11966 for (let /** @type {?} */ i = 0; i < nodeCount; i++) {
11967 const /** @type {?} */ nodeDef = view.def.nodes[i];
11968 if ((nodeDef.flags & queryFlags) && (nodeDef.flags & staticDynamicQueryFlag)) {
11969 Services.setCurrentNode(view, nodeDef.index);
11970 switch (checkType) {
11971 case 0 /* CheckAndUpdate */:
11972 checkAndUpdateQuery(view, nodeDef);
11973 break;
11974 case 1 /* CheckNoChanges */:
11975 checkNoChangesQuery(view, nodeDef);
11976 break;
11977 }
11978 }
11979 if (!(nodeDef.childFlags & queryFlags) || !(nodeDef.childFlags & staticDynamicQueryFlag)) {
11980 // no child has a matching query
11981 // then skip the children
11982 i += nodeDef.childCount;
11983 }
11984 }
11985}
11986
11987/**
11988 * @license
11989 * Copyright Google Inc. All Rights Reserved.
11990 *
11991 * Use of this source code is governed by an MIT-style license that can be
11992 * found in the LICENSE file at https://angular.io/license
11993 */
11994let initialized = false;
11995/**
11996 * @return {?}
11997 */
11998function initServicesIfNeeded() {
11999 if (initialized) {
12000 return;
12001 }
12002 initialized = true;
12003 const /** @type {?} */ services = isDevMode() ? createDebugServices() : createProdServices();
12004 Services.setCurrentNode = services.setCurrentNode;
12005 Services.createRootView = services.createRootView;
12006 Services.createEmbeddedView = services.createEmbeddedView;
12007 Services.checkAndUpdateView = services.checkAndUpdateView;
12008 Services.checkNoChangesView = services.checkNoChangesView;
12009 Services.destroyView = services.destroyView;
12010 Services.resolveDep = resolveDep;
12011 Services.createDebugContext = services.createDebugContext;
12012 Services.handleEvent = services.handleEvent;
12013 Services.updateDirectives = services.updateDirectives;
12014 Services.updateRenderer = services.updateRenderer;
12015 Services.dirtyParentQueries = dirtyParentQueries;
12016}
12017/**
12018 * @return {?}
12019 */
12020function createProdServices() {
12021 return {
12022 setCurrentNode: () => { },
12023 createRootView: createProdRootView,
12024 createEmbeddedView: createEmbeddedView,
12025 checkAndUpdateView: checkAndUpdateView,
12026 checkNoChangesView: checkNoChangesView,
12027 destroyView: destroyView,
12028 createDebugContext: (view, nodeIndex) => new DebugContext_(view, nodeIndex),
12029 handleEvent: (view, nodeIndex, eventName, event) => view.def.handleEvent(view, nodeIndex, eventName, event),
12030 updateDirectives: (view, checkType) => view.def.updateDirectives(checkType === 0 /* CheckAndUpdate */ ? prodCheckAndUpdateNode :
12031 prodCheckNoChangesNode, view),
12032 updateRenderer: (view, checkType) => view.def.updateRenderer(checkType === 0 /* CheckAndUpdate */ ? prodCheckAndUpdateNode :
12033 prodCheckNoChangesNode, view),
12034 };
12035}
12036/**
12037 * @return {?}
12038 */
12039function createDebugServices() {
12040 return {
12041 setCurrentNode: debugSetCurrentNode,
12042 createRootView: debugCreateRootView,
12043 createEmbeddedView: debugCreateEmbeddedView,
12044 checkAndUpdateView: debugCheckAndUpdateView,
12045 checkNoChangesView: debugCheckNoChangesView,
12046 destroyView: debugDestroyView,
12047 createDebugContext: (view, nodeIndex) => new DebugContext_(view, nodeIndex),
12048 handleEvent: debugHandleEvent,
12049 updateDirectives: debugUpdateDirectives,
12050 updateRenderer: debugUpdateRenderer
12051 };
12052}
12053/**
12054 * @param {?} elInjector
12055 * @param {?} projectableNodes
12056 * @param {?} rootSelectorOrNode
12057 * @param {?} def
12058 * @param {?} ngModule
12059 * @param {?=} context
12060 * @return {?}
12061 */
12062function createProdRootView(elInjector, projectableNodes, rootSelectorOrNode, def, ngModule, context) {
12063 const /** @type {?} */ rendererFactory = ngModule.injector.get(RendererFactory2);
12064 return createRootView(createRootData(elInjector, ngModule, rendererFactory, projectableNodes, rootSelectorOrNode), def, context);
12065}
12066/**
12067 * @param {?} elInjector
12068 * @param {?} projectableNodes
12069 * @param {?} rootSelectorOrNode
12070 * @param {?} def
12071 * @param {?} ngModule
12072 * @param {?=} context
12073 * @return {?}
12074 */
12075function debugCreateRootView(elInjector, projectableNodes, rootSelectorOrNode, def, ngModule, context) {
12076 const /** @type {?} */ rendererFactory = ngModule.injector.get(RendererFactory2);
12077 const /** @type {?} */ root = createRootData(elInjector, ngModule, new DebugRendererFactory2(rendererFactory), projectableNodes, rootSelectorOrNode);
12078 return callWithDebugContext(DebugAction.create, createRootView, null, [root, def, context]);
12079}
12080/**
12081 * @param {?} elInjector
12082 * @param {?} ngModule
12083 * @param {?} rendererFactory
12084 * @param {?} projectableNodes
12085 * @param {?} rootSelectorOrNode
12086 * @return {?}
12087 */
12088function createRootData(elInjector, ngModule, rendererFactory, projectableNodes, rootSelectorOrNode) {
12089 const /** @type {?} */ sanitizer = ngModule.injector.get(Sanitizer);
12090 const /** @type {?} */ errorHandler = ngModule.injector.get(ErrorHandler);
12091 const /** @type {?} */ renderer = rendererFactory.createRenderer(null, null);
12092 return {
12093 ngModule,
12094 injector: elInjector, projectableNodes,
12095 selectorOrNode: rootSelectorOrNode, sanitizer, rendererFactory, renderer, errorHandler
12096 };
12097}
12098/**
12099 * @param {?} view
12100 * @param {?} nodeIndex
12101 * @param {?} argStyle
12102 * @param {?=} v0
12103 * @param {?=} v1
12104 * @param {?=} v2
12105 * @param {?=} v3
12106 * @param {?=} v4
12107 * @param {?=} v5
12108 * @param {?=} v6
12109 * @param {?=} v7
12110 * @param {?=} v8
12111 * @param {?=} v9
12112 * @return {?}
12113 */
12114function prodCheckAndUpdateNode(view, nodeIndex, argStyle, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9) {
12115 const /** @type {?} */ nodeDef = view.def.nodes[nodeIndex];
12116 checkAndUpdateNode(view, nodeDef, argStyle, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9);
12117 return (nodeDef.flags & 112 /* CatPureExpression */) ?
12118 asPureExpressionData(view, nodeIndex).value :
12119 undefined;
12120}
12121/**
12122 * @param {?} view
12123 * @param {?} nodeIndex
12124 * @param {?} argStyle
12125 * @param {?=} v0
12126 * @param {?=} v1
12127 * @param {?=} v2
12128 * @param {?=} v3
12129 * @param {?=} v4
12130 * @param {?=} v5
12131 * @param {?=} v6
12132 * @param {?=} v7
12133 * @param {?=} v8
12134 * @param {?=} v9
12135 * @return {?}
12136 */
12137function prodCheckNoChangesNode(view, nodeIndex, argStyle, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9) {
12138 const /** @type {?} */ nodeDef = view.def.nodes[nodeIndex];
12139 checkNoChangesNode(view, nodeDef, argStyle, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9);
12140 return (nodeDef.flags & 112 /* CatPureExpression */) ?
12141 asPureExpressionData(view, nodeIndex).value :
12142 undefined;
12143}
12144/**
12145 * @param {?} parent
12146 * @param {?} anchorDef
12147 * @param {?=} context
12148 * @return {?}
12149 */
12150function debugCreateEmbeddedView(parent, anchorDef, context) {
12151 return callWithDebugContext(DebugAction.create, createEmbeddedView, null, [parent, anchorDef, context]);
12152}
12153/**
12154 * @param {?} view
12155 * @return {?}
12156 */
12157function debugCheckAndUpdateView(view) {
12158 return callWithDebugContext(DebugAction.detectChanges, checkAndUpdateView, null, [view]);
12159}
12160/**
12161 * @param {?} view
12162 * @return {?}
12163 */
12164function debugCheckNoChangesView(view) {
12165 return callWithDebugContext(DebugAction.checkNoChanges, checkNoChangesView, null, [view]);
12166}
12167/**
12168 * @param {?} view
12169 * @return {?}
12170 */
12171function debugDestroyView(view) {
12172 return callWithDebugContext(DebugAction.destroy, destroyView, null, [view]);
12173}
12174let DebugAction = {};
12175DebugAction.create = 0;
12176DebugAction.detectChanges = 1;
12177DebugAction.checkNoChanges = 2;
12178DebugAction.destroy = 3;
12179DebugAction.handleEvent = 4;
12180DebugAction[DebugAction.create] = "create";
12181DebugAction[DebugAction.detectChanges] = "detectChanges";
12182DebugAction[DebugAction.checkNoChanges] = "checkNoChanges";
12183DebugAction[DebugAction.destroy] = "destroy";
12184DebugAction[DebugAction.handleEvent] = "handleEvent";
12185let _currentAction;
12186let _currentView;
12187let _currentNodeIndex;
12188/**
12189 * @param {?} view
12190 * @param {?} nodeIndex
12191 * @return {?}
12192 */
12193function debugSetCurrentNode(view, nodeIndex) {
12194 _currentView = view;
12195 _currentNodeIndex = nodeIndex;
12196}
12197/**
12198 * @param {?} view
12199 * @param {?} nodeIndex
12200 * @param {?} eventName
12201 * @param {?} event
12202 * @return {?}
12203 */
12204function debugHandleEvent(view, nodeIndex, eventName, event) {
12205 debugSetCurrentNode(view, nodeIndex);
12206 return callWithDebugContext(DebugAction.handleEvent, view.def.handleEvent, null, [view, nodeIndex, eventName, event]);
12207}
12208/**
12209 * @param {?} view
12210 * @param {?} checkType
12211 * @return {?}
12212 */
12213function debugUpdateDirectives(view, checkType) {
12214 if (view.state & 16 /* Destroyed */) {
12215 throw viewDestroyedError(DebugAction[_currentAction]);
12216 }
12217 debugSetCurrentNode(view, nextDirectiveWithBinding(view, 0));
12218 return view.def.updateDirectives(debugCheckDirectivesFn, view);
12219 /**
12220 * @param {?} view
12221 * @param {?} nodeIndex
12222 * @param {?} argStyle
12223 * @param {...?} values
12224 * @return {?}
12225 */
12226 function debugCheckDirectivesFn(view, nodeIndex, argStyle, ...values) {
12227 const /** @type {?} */ nodeDef = view.def.nodes[nodeIndex];
12228 if (checkType === 0 /* CheckAndUpdate */) {
12229 debugCheckAndUpdateNode(view, nodeDef, argStyle, values);
12230 }
12231 else {
12232 debugCheckNoChangesNode(view, nodeDef, argStyle, values);
12233 }
12234 if (nodeDef.flags & 8192 /* TypeDirective */) {
12235 debugSetCurrentNode(view, nextDirectiveWithBinding(view, nodeIndex));
12236 }
12237 return (nodeDef.flags & 112 /* CatPureExpression */) ?
12238 asPureExpressionData(view, nodeDef.index).value :
12239 undefined;
12240 }
12241}
12242/**
12243 * @param {?} view
12244 * @param {?} checkType
12245 * @return {?}
12246 */
12247function debugUpdateRenderer(view, checkType) {
12248 if (view.state & 16 /* Destroyed */) {
12249 throw viewDestroyedError(DebugAction[_currentAction]);
12250 }
12251 debugSetCurrentNode(view, nextRenderNodeWithBinding(view, 0));
12252 return view.def.updateRenderer(debugCheckRenderNodeFn, view);
12253 /**
12254 * @param {?} view
12255 * @param {?} nodeIndex
12256 * @param {?} argStyle
12257 * @param {...?} values
12258 * @return {?}
12259 */
12260 function debugCheckRenderNodeFn(view, nodeIndex, argStyle, ...values) {
12261 const /** @type {?} */ nodeDef = view.def.nodes[nodeIndex];
12262 if (checkType === 0 /* CheckAndUpdate */) {
12263 debugCheckAndUpdateNode(view, nodeDef, argStyle, values);
12264 }
12265 else {
12266 debugCheckNoChangesNode(view, nodeDef, argStyle, values);
12267 }
12268 if (nodeDef.flags & 3 /* CatRenderNode */) {
12269 debugSetCurrentNode(view, nextRenderNodeWithBinding(view, nodeIndex));
12270 }
12271 return (nodeDef.flags & 112 /* CatPureExpression */) ?
12272 asPureExpressionData(view, nodeDef.index).value :
12273 undefined;
12274 }
12275}
12276/**
12277 * @param {?} view
12278 * @param {?} nodeDef
12279 * @param {?} argStyle
12280 * @param {?} givenValues
12281 * @return {?}
12282 */
12283function debugCheckAndUpdateNode(view, nodeDef, argStyle, givenValues) {
12284 const /** @type {?} */ changed = ((checkAndUpdateNode))(view, nodeDef, argStyle, ...givenValues);
12285 if (changed) {
12286 const /** @type {?} */ values = argStyle === 1 /* Dynamic */ ? givenValues[0] : givenValues;
12287 if (nodeDef.flags & 8192 /* TypeDirective */) {
12288 const /** @type {?} */ bindingValues = {};
12289 for (let /** @type {?} */ i = 0; i < nodeDef.bindings.length; i++) {
12290 const /** @type {?} */ binding = nodeDef.bindings[i];
12291 const /** @type {?} */ value = values[i];
12292 if (binding.flags & 8 /* TypeProperty */) {
12293 bindingValues[normalizeDebugBindingName(/** @type {?} */ ((binding.nonMinifiedName)))] =
12294 normalizeDebugBindingValue(value);
12295 }
12296 }
12297 const /** @type {?} */ elDef = ((nodeDef.parent));
12298 const /** @type {?} */ el = asElementData(view, elDef.index).renderElement;
12299 if (!((elDef.element)).name) {
12300 // a comment.
12301 view.renderer.setValue(el, `bindings=${JSON.stringify(bindingValues, null, 2)}`);
12302 }
12303 else {
12304 // a regular element.
12305 for (let /** @type {?} */ attr in bindingValues) {
12306 const /** @type {?} */ value = bindingValues[attr];
12307 if (value != null) {
12308 view.renderer.setAttribute(el, attr, value);
12309 }
12310 else {
12311 view.renderer.removeAttribute(el, attr);
12312 }
12313 }
12314 }
12315 }
12316 }
12317}
12318/**
12319 * @param {?} view
12320 * @param {?} nodeDef
12321 * @param {?} argStyle
12322 * @param {?} values
12323 * @return {?}
12324 */
12325function debugCheckNoChangesNode(view, nodeDef, argStyle, values) {
12326 ((checkNoChangesNode))(view, nodeDef, argStyle, ...values);
12327}
12328/**
12329 * @param {?} name
12330 * @return {?}
12331 */
12332function normalizeDebugBindingName(name) {
12333 // Attribute names with `$` (eg `x-y$`) are valid per spec, but unsupported by some browsers
12334 name = camelCaseToDashCase(name.replace(/[$@]/g, '_'));
12335 return `ng-reflect-${name}`;
12336}
12337const CAMEL_CASE_REGEXP = /([A-Z])/g;
12338/**
12339 * @param {?} input
12340 * @return {?}
12341 */
12342function camelCaseToDashCase(input) {
12343 return input.replace(CAMEL_CASE_REGEXP, (...m) => '-' + m[1].toLowerCase());
12344}
12345/**
12346 * @param {?} value
12347 * @return {?}
12348 */
12349function normalizeDebugBindingValue(value) {
12350 try {
12351 // Limit the size of the value as otherwise the DOM just gets polluted.
12352 return value != null ? value.toString().slice(0, 30) : value;
12353 }
12354 catch (e) {
12355 return '[ERROR] Exception while trying to serialize the value';
12356 }
12357}
12358/**
12359 * @param {?} view
12360 * @param {?} nodeIndex
12361 * @return {?}
12362 */
12363function nextDirectiveWithBinding(view, nodeIndex) {
12364 for (let /** @type {?} */ i = nodeIndex; i < view.def.nodes.length; i++) {
12365 const /** @type {?} */ nodeDef = view.def.nodes[i];
12366 if (nodeDef.flags & 8192 /* TypeDirective */ && nodeDef.bindings && nodeDef.bindings.length) {
12367 return i;
12368 }
12369 }
12370 return null;
12371}
12372/**
12373 * @param {?} view
12374 * @param {?} nodeIndex
12375 * @return {?}
12376 */
12377function nextRenderNodeWithBinding(view, nodeIndex) {
12378 for (let /** @type {?} */ i = nodeIndex; i < view.def.nodes.length; i++) {
12379 const /** @type {?} */ nodeDef = view.def.nodes[i];
12380 if ((nodeDef.flags & 3 /* CatRenderNode */) && nodeDef.bindings && nodeDef.bindings.length) {
12381 return i;
12382 }
12383 }
12384 return null;
12385}
12386class DebugContext_ {
12387 /**
12388 * @param {?} view
12389 * @param {?} nodeIndex
12390 */
12391 constructor(view, nodeIndex) {
12392 this.view = view;
12393 this.nodeIndex = nodeIndex;
12394 if (nodeIndex == null) {
12395 this.nodeIndex = nodeIndex = 0;
12396 }
12397 this.nodeDef = view.def.nodes[nodeIndex];
12398 let elDef = this.nodeDef;
12399 let elView = view;
12400 while (elDef && (elDef.flags & 1 /* TypeElement */) === 0) {
12401 elDef = elDef.parent;
12402 }
12403 if (!elDef) {
12404 while (!elDef && elView) {
12405 elDef = viewParentEl(elView);
12406 elView = elView.parent;
12407 }
12408 }
12409 this.elDef = elDef;
12410 this.elView = elView;
12411 }
12412 /**
12413 * @return {?}
12414 */
12415 get elOrCompView() {
12416 // Has to be done lazily as we use the DebugContext also during creation of elements...
12417 return asElementData(this.elView, this.elDef.index).componentView || this.view;
12418 }
12419 /**
12420 * @return {?}
12421 */
12422 get injector() { return createInjector(this.elView, this.elDef); }
12423 /**
12424 * @return {?}
12425 */
12426 get component() { return this.elOrCompView.component; }
12427 /**
12428 * @return {?}
12429 */
12430 get context() { return this.elOrCompView.context; }
12431 /**
12432 * @return {?}
12433 */
12434 get providerTokens() {
12435 const /** @type {?} */ tokens = [];
12436 if (this.elDef) {
12437 for (let /** @type {?} */ i = this.elDef.index + 1; i <= this.elDef.index + this.elDef.childCount; i++) {
12438 const /** @type {?} */ childDef = this.elView.def.nodes[i];
12439 if (childDef.flags & 10112 /* CatProvider */) {
12440 tokens.push(/** @type {?} */ ((childDef.provider)).token);
12441 }
12442 i += childDef.childCount;
12443 }
12444 }
12445 return tokens;
12446 }
12447 /**
12448 * @return {?}
12449 */
12450 get references() {
12451 const /** @type {?} */ references = {};
12452 if (this.elDef) {
12453 collectReferences(this.elView, this.elDef, references);
12454 for (let /** @type {?} */ i = this.elDef.index + 1; i <= this.elDef.index + this.elDef.childCount; i++) {
12455 const /** @type {?} */ childDef = this.elView.def.nodes[i];
12456 if (childDef.flags & 10112 /* CatProvider */) {
12457 collectReferences(this.elView, childDef, references);
12458 }
12459 i += childDef.childCount;
12460 }
12461 }
12462 return references;
12463 }
12464 /**
12465 * @return {?}
12466 */
12467 get componentRenderElement() {
12468 const /** @type {?} */ elData = findHostElement(this.elOrCompView);
12469 return elData ? elData.renderElement : undefined;
12470 }
12471 /**
12472 * @return {?}
12473 */
12474 get renderNode() {
12475 return this.nodeDef.flags & 2 /* TypeText */ ? renderNode(this.view, this.nodeDef) :
12476 renderNode(this.elView, this.elDef);
12477 }
12478 /**
12479 * @param {?} console
12480 * @param {...?} values
12481 * @return {?}
12482 */
12483 logError(console, ...values) {
12484 let /** @type {?} */ logViewDef;
12485 let /** @type {?} */ logNodeIndex;
12486 if (this.nodeDef.flags & 2 /* TypeText */) {
12487 logViewDef = this.view.def;
12488 logNodeIndex = this.nodeDef.index;
12489 }
12490 else {
12491 logViewDef = this.elView.def;
12492 logNodeIndex = this.elDef.index;
12493 }
12494 // Note: we only generate a log function for text and element nodes
12495 // to make the generated code as small as possible.
12496 const /** @type {?} */ renderNodeIndex = getRenderNodeIndex(logViewDef, logNodeIndex);
12497 let /** @type {?} */ currRenderNodeIndex = -1;
12498 let /** @type {?} */ nodeLogger = () => {
12499 currRenderNodeIndex++;
12500 if (currRenderNodeIndex === renderNodeIndex) {
12501 return console.error.bind(console, ...values);
12502 }
12503 else {
12504 return NOOP;
12505 }
12506 }; /** @type {?} */
12507 ((logViewDef.factory))(nodeLogger);
12508 if (currRenderNodeIndex < renderNodeIndex) {
12509 console.error('Illegal state: the ViewDefinitionFactory did not call the logger!');
12510 ((console.error))(...values);
12511 }
12512 }
12513}
12514/**
12515 * @param {?} viewDef
12516 * @param {?} nodeIndex
12517 * @return {?}
12518 */
12519function getRenderNodeIndex(viewDef$$1, nodeIndex) {
12520 let /** @type {?} */ renderNodeIndex = -1;
12521 for (let /** @type {?} */ i = 0; i <= nodeIndex; i++) {
12522 const /** @type {?} */ nodeDef = viewDef$$1.nodes[i];
12523 if (nodeDef.flags & 3 /* CatRenderNode */) {
12524 renderNodeIndex++;
12525 }
12526 }
12527 return renderNodeIndex;
12528}
12529/**
12530 * @param {?} view
12531 * @return {?}
12532 */
12533function findHostElement(view) {
12534 while (view && !isComponentView(view)) {
12535 view = ((view.parent));
12536 }
12537 if (view.parent) {
12538 return asElementData(view.parent, /** @type {?} */ ((viewParentEl(view))).index);
12539 }
12540 return null;
12541}
12542/**
12543 * @param {?} view
12544 * @param {?} nodeDef
12545 * @param {?} references
12546 * @return {?}
12547 */
12548function collectReferences(view, nodeDef, references) {
12549 for (let /** @type {?} */ refName in nodeDef.references) {
12550 references[refName] = getQueryValue(view, nodeDef, nodeDef.references[refName]);
12551 }
12552}
12553/**
12554 * @param {?} action
12555 * @param {?} fn
12556 * @param {?} self
12557 * @param {?} args
12558 * @return {?}
12559 */
12560function callWithDebugContext(action, fn, self, args) {
12561 const /** @type {?} */ oldAction = _currentAction;
12562 const /** @type {?} */ oldView = _currentView;
12563 const /** @type {?} */ oldNodeIndex = _currentNodeIndex;
12564 try {
12565 _currentAction = action;
12566 const /** @type {?} */ result = fn.apply(self, args);
12567 _currentView = oldView;
12568 _currentNodeIndex = oldNodeIndex;
12569 _currentAction = oldAction;
12570 return result;
12571 }
12572 catch (e) {
12573 if (isViewDebugError(e) || !_currentView) {
12574 throw e;
12575 }
12576 throw viewWrappedDebugError(e, /** @type {?} */ ((getCurrentDebugContext())));
12577 }
12578}
12579/**
12580 * @return {?}
12581 */
12582function getCurrentDebugContext() {
12583 return _currentView ? new DebugContext_(_currentView, _currentNodeIndex) : null;
12584}
12585class DebugRendererFactory2 {
12586 /**
12587 * @param {?} delegate
12588 */
12589 constructor(delegate) {
12590 this.delegate = delegate;
12591 }
12592 /**
12593 * @param {?} element
12594 * @param {?} renderData
12595 * @return {?}
12596 */
12597 createRenderer(element, renderData) {
12598 return new DebugRenderer2(this.delegate.createRenderer(element, renderData));
12599 }
12600}
12601class DebugRenderer2 {
12602 /**
12603 * @param {?} delegate
12604 */
12605 constructor(delegate) {
12606 this.delegate = delegate;
12607 }
12608 /**
12609 * @return {?}
12610 */
12611 get data() { return this.delegate.data; }
12612 /**
12613 * @param {?} node
12614 * @return {?}
12615 */
12616 destroyNode(node) {
12617 removeDebugNodeFromIndex(/** @type {?} */ ((getDebugNode(node))));
12618 if (this.delegate.destroyNode) {
12619 this.delegate.destroyNode(node);
12620 }
12621 }
12622 /**
12623 * @return {?}
12624 */
12625 destroy() { this.delegate.destroy(); }
12626 /**
12627 * @param {?} name
12628 * @param {?=} namespace
12629 * @return {?}
12630 */
12631 createElement(name, namespace) {
12632 const /** @type {?} */ el = this.delegate.createElement(name, namespace);
12633 const /** @type {?} */ debugCtx = getCurrentDebugContext();
12634 if (debugCtx) {
12635 const /** @type {?} */ debugEl = new DebugElement(el, null, debugCtx);
12636 debugEl.name = name;
12637 indexDebugNode(debugEl);
12638 }
12639 return el;
12640 }
12641 /**
12642 * @param {?} value
12643 * @return {?}
12644 */
12645 createComment(value) {
12646 const /** @type {?} */ comment = this.delegate.createComment(value);
12647 const /** @type {?} */ debugCtx = getCurrentDebugContext();
12648 if (debugCtx) {
12649 indexDebugNode(new DebugNode(comment, null, debugCtx));
12650 }
12651 return comment;
12652 }
12653 /**
12654 * @param {?} value
12655 * @return {?}
12656 */
12657 createText(value) {
12658 const /** @type {?} */ text = this.delegate.createText(value);
12659 const /** @type {?} */ debugCtx = getCurrentDebugContext();
12660 if (debugCtx) {
12661 indexDebugNode(new DebugNode(text, null, debugCtx));
12662 }
12663 return text;
12664 }
12665 /**
12666 * @param {?} parent
12667 * @param {?} newChild
12668 * @return {?}
12669 */
12670 appendChild(parent, newChild) {
12671 const /** @type {?} */ debugEl = getDebugNode(parent);
12672 const /** @type {?} */ debugChildEl = getDebugNode(newChild);
12673 if (debugEl && debugChildEl && debugEl instanceof DebugElement) {
12674 debugEl.addChild(debugChildEl);
12675 }
12676 this.delegate.appendChild(parent, newChild);
12677 }
12678 /**
12679 * @param {?} parent
12680 * @param {?} newChild
12681 * @param {?} refChild
12682 * @return {?}
12683 */
12684 insertBefore(parent, newChild, refChild) {
12685 const /** @type {?} */ debugEl = getDebugNode(parent);
12686 const /** @type {?} */ debugChildEl = getDebugNode(newChild);
12687 const /** @type {?} */ debugRefEl = ((getDebugNode(refChild)));
12688 if (debugEl && debugChildEl && debugEl instanceof DebugElement) {
12689 debugEl.insertBefore(debugRefEl, debugChildEl);
12690 }
12691 this.delegate.insertBefore(parent, newChild, refChild);
12692 }
12693 /**
12694 * @param {?} parent
12695 * @param {?} oldChild
12696 * @return {?}
12697 */
12698 removeChild(parent, oldChild) {
12699 const /** @type {?} */ debugEl = getDebugNode(parent);
12700 const /** @type {?} */ debugChildEl = getDebugNode(oldChild);
12701 if (debugEl && debugChildEl && debugEl instanceof DebugElement) {
12702 debugEl.removeChild(debugChildEl);
12703 }
12704 this.delegate.removeChild(parent, oldChild);
12705 }
12706 /**
12707 * @param {?} selectorOrNode
12708 * @return {?}
12709 */
12710 selectRootElement(selectorOrNode) {
12711 const /** @type {?} */ el = this.delegate.selectRootElement(selectorOrNode);
12712 const /** @type {?} */ debugCtx = getCurrentDebugContext();
12713 if (debugCtx) {
12714 indexDebugNode(new DebugElement(el, null, debugCtx));
12715 }
12716 return el;
12717 }
12718 /**
12719 * @param {?} el
12720 * @param {?} name
12721 * @param {?} value
12722 * @param {?=} namespace
12723 * @return {?}
12724 */
12725 setAttribute(el, name, value, namespace) {
12726 const /** @type {?} */ debugEl = getDebugNode(el);
12727 if (debugEl && debugEl instanceof DebugElement) {
12728 const /** @type {?} */ fullName = namespace ? namespace + ':' + name : name;
12729 debugEl.attributes[fullName] = value;
12730 }
12731 this.delegate.setAttribute(el, name, value, namespace);
12732 }
12733 /**
12734 * @param {?} el
12735 * @param {?} name
12736 * @param {?=} namespace
12737 * @return {?}
12738 */
12739 removeAttribute(el, name, namespace) {
12740 const /** @type {?} */ debugEl = getDebugNode(el);
12741 if (debugEl && debugEl instanceof DebugElement) {
12742 const /** @type {?} */ fullName = namespace ? namespace + ':' + name : name;
12743 debugEl.attributes[fullName] = null;
12744 }
12745 this.delegate.removeAttribute(el, name, namespace);
12746 }
12747 /**
12748 * @param {?} el
12749 * @param {?} name
12750 * @return {?}
12751 */
12752 addClass(el, name) {
12753 const /** @type {?} */ debugEl = getDebugNode(el);
12754 if (debugEl && debugEl instanceof DebugElement) {
12755 debugEl.classes[name] = true;
12756 }
12757 this.delegate.addClass(el, name);
12758 }
12759 /**
12760 * @param {?} el
12761 * @param {?} name
12762 * @return {?}
12763 */
12764 removeClass(el, name) {
12765 const /** @type {?} */ debugEl = getDebugNode(el);
12766 if (debugEl && debugEl instanceof DebugElement) {
12767 debugEl.classes[name] = false;
12768 }
12769 this.delegate.removeClass(el, name);
12770 }
12771 /**
12772 * @param {?} el
12773 * @param {?} style
12774 * @param {?} value
12775 * @param {?} flags
12776 * @return {?}
12777 */
12778 setStyle(el, style, value, flags) {
12779 const /** @type {?} */ debugEl = getDebugNode(el);
12780 if (debugEl && debugEl instanceof DebugElement) {
12781 debugEl.styles[style] = value;
12782 }
12783 this.delegate.setStyle(el, style, value, flags);
12784 }
12785 /**
12786 * @param {?} el
12787 * @param {?} style
12788 * @param {?} flags
12789 * @return {?}
12790 */
12791 removeStyle(el, style, flags) {
12792 const /** @type {?} */ debugEl = getDebugNode(el);
12793 if (debugEl && debugEl instanceof DebugElement) {
12794 debugEl.styles[style] = null;
12795 }
12796 this.delegate.removeStyle(el, style, flags);
12797 }
12798 /**
12799 * @param {?} el
12800 * @param {?} name
12801 * @param {?} value
12802 * @return {?}
12803 */
12804 setProperty(el, name, value) {
12805 const /** @type {?} */ debugEl = getDebugNode(el);
12806 if (debugEl && debugEl instanceof DebugElement) {
12807 debugEl.properties[name] = value;
12808 }
12809 this.delegate.setProperty(el, name, value);
12810 }
12811 /**
12812 * @param {?} target
12813 * @param {?} eventName
12814 * @param {?} callback
12815 * @return {?}
12816 */
12817 listen(target, eventName, callback) {
12818 if (typeof target !== 'string') {
12819 const /** @type {?} */ debugEl = getDebugNode(target);
12820 if (debugEl) {
12821 debugEl.listeners.push(new EventListener(eventName, callback));
12822 }
12823 }
12824 return this.delegate.listen(target, eventName, callback);
12825 }
12826 /**
12827 * @param {?} node
12828 * @return {?}
12829 */
12830 parentNode(node) { return this.delegate.parentNode(node); }
12831 /**
12832 * @param {?} node
12833 * @return {?}
12834 */
12835 nextSibling(node) { return this.delegate.nextSibling(node); }
12836 /**
12837 * @param {?} node
12838 * @param {?} value
12839 * @return {?}
12840 */
12841 setValue(node, value) { return this.delegate.setValue(node, value); }
12842}
12843
12844/**
12845 * @license
12846 * Copyright Google Inc. All Rights Reserved.
12847 *
12848 * Use of this source code is governed by an MIT-style license that can be
12849 * found in the LICENSE file at https://angular.io/license
12850 */
12851
12852/**
12853 * @license
12854 * Copyright Google Inc. All Rights Reserved.
12855 *
12856 * Use of this source code is governed by an MIT-style license that can be
12857 * found in the LICENSE file at https://angular.io/license
12858 */
12859/**
12860 * @return {?}
12861 */
12862function _iterableDiffersFactory() {
12863 return defaultIterableDiffers;
12864}
12865/**
12866 * @return {?}
12867 */
12868function _keyValueDiffersFactory() {
12869 return defaultKeyValueDiffers;
12870}
12871/**
12872 * @param {?=} locale
12873 * @return {?}
12874 */
12875function _localeFactory(locale) {
12876 return locale || 'en-US';
12877}
12878/**
12879 * @return {?}
12880 */
12881function _initViewEngine() {
12882 initServicesIfNeeded();
12883}
12884/**
12885 * This module includes the providers of \@angular/core that are needed
12886 * to bootstrap components via `ApplicationRef`.
12887 *
12888 * \@experimental
12889 */
12890class ApplicationModule {
12891 /**
12892 * @param {?} appRef
12893 */
12894 constructor(appRef) { }
12895}
12896ApplicationModule.decorators = [
12897 { type: NgModule, args: [{
12898 providers: [
12899 ApplicationRef_,
12900 { provide: ApplicationRef, useExisting: ApplicationRef_ },
12901 ApplicationInitStatus,
12902 Compiler,
12903 APP_ID_RANDOM_PROVIDER,
12904 { provide: IterableDiffers, useFactory: _iterableDiffersFactory },
12905 { provide: KeyValueDiffers, useFactory: _keyValueDiffersFactory },
12906 {
12907 provide: LOCALE_ID,
12908 useFactory: _localeFactory,
12909 deps: [[new Inject(LOCALE_ID), new Optional(), new SkipSelf()]]
12910 },
12911 { provide: APP_INITIALIZER, useValue: _initViewEngine, multi: true },
12912 ]
12913 },] },
12914];
12915/**
12916 * @nocollapse
12917 */
12918ApplicationModule.ctorParameters = () => [
12919 { type: ApplicationRef, },
12920];
12921
12922/**
12923 * @license
12924 * Copyright Google Inc. All Rights Reserved.
12925 *
12926 * Use of this source code is governed by an MIT-style license that can be
12927 * found in the LICENSE file at https://angular.io/license
12928 */
12929let LifecycleHooks = {};
12930LifecycleHooks.OnInit = 0;
12931LifecycleHooks.OnDestroy = 1;
12932LifecycleHooks.DoCheck = 2;
12933LifecycleHooks.OnChanges = 3;
12934LifecycleHooks.AfterContentInit = 4;
12935LifecycleHooks.AfterContentChecked = 5;
12936LifecycleHooks.AfterViewInit = 6;
12937LifecycleHooks.AfterViewChecked = 7;
12938LifecycleHooks[LifecycleHooks.OnInit] = "OnInit";
12939LifecycleHooks[LifecycleHooks.OnDestroy] = "OnDestroy";
12940LifecycleHooks[LifecycleHooks.DoCheck] = "DoCheck";
12941LifecycleHooks[LifecycleHooks.OnChanges] = "OnChanges";
12942LifecycleHooks[LifecycleHooks.AfterContentInit] = "AfterContentInit";
12943LifecycleHooks[LifecycleHooks.AfterContentChecked] = "AfterContentChecked";
12944LifecycleHooks[LifecycleHooks.AfterViewInit] = "AfterViewInit";
12945LifecycleHooks[LifecycleHooks.AfterViewChecked] = "AfterViewChecked";
12946const LIFECYCLE_HOOKS_VALUES = [
12947 LifecycleHooks.OnInit, LifecycleHooks.OnDestroy, LifecycleHooks.DoCheck, LifecycleHooks.OnChanges,
12948 LifecycleHooks.AfterContentInit, LifecycleHooks.AfterContentChecked, LifecycleHooks.AfterViewInit,
12949 LifecycleHooks.AfterViewChecked
12950];
12951
12952/**
12953 * @license
12954 * Copyright Google Inc. All Rights Reserved.
12955 *
12956 * Use of this source code is governed by an MIT-style license that can be
12957 * found in the LICENSE file at https://angular.io/license
12958 */
12959
12960/**
12961 * @license
12962 * Copyright Google Inc. All Rights Reserved.
12963 *
12964 * Use of this source code is governed by an MIT-style license that can be
12965 * found in the LICENSE file at https://angular.io/license
12966 */
12967
12968/**
12969 * \@experimental Animation support is experimental.
12970 */
12971
12972/**
12973 * `trigger` is an animation-specific function that is designed to be used inside of Angular's
12974 * animation DSL language. If this information is new, please navigate to the {\@link
12975 * Component#animations-anchor component animations metadata page} to gain a better understanding of
12976 * how animations in Angular are used.
12977 *
12978 * `trigger` Creates an animation trigger which will a list of {\@link state state} and {\@link
12979 * transition transition} entries that will be evaluated when the expression bound to the trigger
12980 * changes.
12981 *
12982 * Triggers are registered within the component annotation data under the {\@link
12983 * Component#animations-anchor animations section}. An animation trigger can be placed on an element
12984 * within a template by referencing the name of the trigger followed by the expression value that the
12985 * trigger is bound to (in the form of `[\@triggerName]="expression"`.
12986 *
12987 * ### Usage
12988 *
12989 * `trigger` will create an animation trigger reference based on the provided `name` value. The
12990 * provided `animation` value is expected to be an array consisting of {\@link state state} and {\@link
12991 * transition transition} declarations.
12992 *
12993 * ```typescript
12994 * \@Component({
12995 * selector: 'my-component',
12996 * templateUrl: 'my-component-tpl.html',
12997 * animations: [
12998 * trigger("myAnimationTrigger", [
12999 * state(...),
13000 * state(...),
13001 * transition(...),
13002 * transition(...)
13003 * ])
13004 * ]
13005 * })
13006 * class MyComponent {
13007 * myStatusExp = "something";
13008 * }
13009 * ```
13010 *
13011 * The template associated with this component will make use of the `myAnimationTrigger` animation
13012 * trigger by binding to an element within its template code.
13013 *
13014 * ```html
13015 * <!-- somewhere inside of my-component-tpl.html -->
13016 * <div [\@myAnimationTrigger]="myStatusExp">...</div>
13017 * tools/gulp-tasks/validate-commit-message.js ```
13018 *
13019 * {\@example core/animation/ts/dsl/animation_example.ts region='Component'}
13020 *
13021 * \@experimental Animation support is experimental.
13022 * @param {?} name
13023 * @param {?} definitions
13024 * @return {?}
13025 */
13026function trigger$1(name, definitions) {
13027 return { name, definitions };
13028}
13029/**
13030 * `animate` is an animation-specific function that is designed to be used inside of Angular's
13031 * animation DSL language. If this information is new, please navigate to the {\@link
13032 * Component#animations-anchor component animations metadata page} to gain a better understanding of
13033 * how animations in Angular are used.
13034 *
13035 * `animate` specifies an animation step that will apply the provided `styles` data for a given
13036 * amount of time based on the provided `timing` expression value. Calls to `animate` are expected
13037 * to be used within {\@link sequence an animation sequence}, {\@link group group}, or {\@link
13038 * transition transition}.
13039 *
13040 * ### Usage
13041 *
13042 * The `animate` function accepts two input parameters: `timing` and `styles`:
13043 *
13044 * - `timing` is a string based value that can be a combination of a duration with optional delay
13045 * and easing values. The format for the expression breaks down to `duration delay easing`
13046 * (therefore a value such as `1s 100ms ease-out` will be parse itself into `duration=1000,
13047 * delay=100, easing=ease-out`. If a numeric value is provided then that will be used as the
13048 * `duration` value in millisecond form.
13049 * - `styles` is the style input data which can either be a call to {\@link style style} or {\@link
13050 * keyframes keyframes}. If left empty then the styles from the destination state will be collected
13051 * and used (this is useful when describing an animation step that will complete an animation by
13052 * {\@link transition#the-final-animate-call animating to the final state}).
13053 *
13054 * ```typescript
13055 * // various functions for specifying timing data
13056 * animate(500, style(...))
13057 * animate("1s", style(...))
13058 * animate("100ms 0.5s", style(...))
13059 * animate("5s ease", style(...))
13060 * animate("5s 10ms cubic-bezier(.17,.67,.88,.1)", style(...))
13061 *
13062 * // either style() of keyframes() can be used
13063 * animate(500, style({ background: "red" }))
13064 * animate(500, keyframes([
13065 * style({ background: "blue" })),
13066 * style({ background: "red" }))
13067 * ])
13068 * ```
13069 *
13070 * {\@example core/animation/ts/dsl/animation_example.ts region='Component'}
13071 *
13072 * \@experimental Animation support is experimental.
13073 * @param {?} timings
13074 * @param {?=} styles
13075 * @return {?}
13076 */
13077function animate$1(timings, styles = null) {
13078 return { type: 4 /* Animate */, styles: styles, timings: timings };
13079}
13080/**
13081 * `group` is an animation-specific function that is designed to be used inside of Angular's
13082 * animation DSL language. If this information is new, please navigate to the {\@link
13083 * Component#animations-anchor component animations metadata page} to gain a better understanding of
13084 * how animations in Angular are used.
13085 *
13086 * `group` specifies a list of animation steps that are all run in parallel. Grouped animations are
13087 * useful when a series of styles must be animated/closed off at different statrting/ending times.
13088 *
13089 * The `group` function can either be used within a {\@link sequence sequence} or a {\@link transition
13090 * transition} and it will only continue to the next instruction once all of the inner animation
13091 * steps have completed.
13092 *
13093 * ### Usage
13094 *
13095 * The `steps` data that is passed into the `group` animation function can either consist of {\@link
13096 * style style} or {\@link animate animate} function calls. Each call to `style()` or `animate()`
13097 * within a group will be executed instantly (use {\@link keyframes keyframes} or a {\@link
13098 * animate#usage animate() with a delay value} to offset styles to be applied at a later time).
13099 *
13100 * ```typescript
13101 * group([
13102 * animate("1s", { background: "black" }))
13103 * animate("2s", { color: "white" }))
13104 * ])
13105 * ```
13106 *
13107 * {\@example core/animation/ts/dsl/animation_example.ts region='Component'}
13108 *
13109 * \@experimental Animation support is experimental.
13110 * @param {?} steps
13111 * @return {?}
13112 */
13113function group$1(steps) {
13114 return { type: 3 /* Group */, steps: steps };
13115}
13116/**
13117 * `sequence` is an animation-specific function that is designed to be used inside of Angular's
13118 * animation DSL language. If this information is new, please navigate to the {\@link
13119 * Component#animations-anchor component animations metadata page} to gain a better understanding of
13120 * how animations in Angular are used.
13121 *
13122 * `sequence` Specifies a list of animation steps that are run one by one. (`sequence` is used by
13123 * default when an array is passed as animation data into {\@link transition transition}.)
13124 *
13125 * The `sequence` function can either be used within a {\@link group group} or a {\@link transition
13126 * transition} and it will only continue to the next instruction once each of the inner animation
13127 * steps have completed.
13128 *
13129 * To perform animation styling in parallel with other animation steps then have a look at the
13130 * {\@link group group} animation function.
13131 *
13132 * ### Usage
13133 *
13134 * The `steps` data that is passed into the `sequence` animation function can either consist of
13135 * {\@link style style} or {\@link animate animate} function calls. A call to `style()` will apply the
13136 * provided styling data immediately while a call to `animate()` will apply its styling data over a
13137 * given time depending on its timing data.
13138 *
13139 * ```typescript
13140 * sequence([
13141 * style({ opacity: 0 })),
13142 * animate("1s", { opacity: 1 }))
13143 * ])
13144 * ```
13145 *
13146 * {\@example core/animation/ts/dsl/animation_example.ts region='Component'}
13147 *
13148 * \@experimental Animation support is experimental.
13149 * @param {?} steps
13150 * @return {?}
13151 */
13152function sequence$1(steps) {
13153 return { type: 2 /* Sequence */, steps: steps };
13154}
13155/**
13156 * `style` is an animation-specific function that is designed to be used inside of Angular's
13157 * animation DSL language. If this information is new, please navigate to the {\@link
13158 * Component#animations-anchor component animations metadata page} to gain a better understanding of
13159 * how animations in Angular are used.
13160 *
13161 * `style` declares a key/value object containing CSS properties/styles that can then be used for
13162 * {\@link state animation states}, within an {\@link sequence animation sequence}, or as styling data
13163 * for both {\@link animate animate} and {\@link keyframes keyframes}.
13164 *
13165 * ### Usage
13166 *
13167 * `style` takes in a key/value string map as data and expects one or more CSS property/value pairs
13168 * to be defined.
13169 *
13170 * ```typescript
13171 * // string values are used for css properties
13172 * style({ background: "red", color: "blue" })
13173 *
13174 * // numerical (pixel) values are also supported
13175 * style({ width: 100, height: 0 })
13176 * ```
13177 *
13178 * #### Auto-styles (using `*`)
13179 *
13180 * When an asterix (`*`) character is used as a value then it will be detected from the element
13181 * being animated and applied as animation data when the animation starts.
13182 *
13183 * This feature proves useful for a state depending on layout and/or environment factors; in such
13184 * cases the styles are calculated just before the animation starts.
13185 *
13186 * ```typescript
13187 * // the steps below will animate from 0 to the
13188 * // actual height of the element
13189 * style({ height: 0 }),
13190 * animate("1s", style({ height: "*" }))
13191 * ```
13192 *
13193 * {\@example core/animation/ts/dsl/animation_example.ts region='Component'}
13194 *
13195 * \@experimental Animation support is experimental.
13196 * @param {?} tokens
13197 * @return {?}
13198 */
13199function style$1(tokens) {
13200 return { type: 6 /* Style */, styles: tokens };
13201}
13202/**
13203 * `state` is an animation-specific function that is designed to be used inside of Angular's
13204 * animation DSL language. If this information is new, please navigate to the {\@link
13205 * Component#animations-anchor component animations metadata page} to gain a better understanding of
13206 * how animations in Angular are used.
13207 *
13208 * `state` declares an animation state within the given trigger. When a state is active within a
13209 * component then its associated styles will persist on the element that the trigger is attached to
13210 * (even when the animation ends).
13211 *
13212 * To animate between states, have a look at the animation {\@link transition transition} DSL
13213 * function. To register states to an animation trigger please have a look at the {\@link trigger
13214 * trigger} function.
13215 *
13216 * #### The `void` state
13217 *
13218 * The `void` state value is a reserved word that angular uses to determine when the element is not
13219 * apart of the application anymore (e.g. when an `ngIf` evaluates to false then the state of the
13220 * associated element is void).
13221 *
13222 * #### The `*` (default) state
13223 *
13224 * The `*` state (when styled) is a fallback state that will be used if the state that is being
13225 * animated is not declared within the trigger.
13226 *
13227 * ### Usage
13228 *
13229 * `state` will declare an animation state with its associated styles
13230 * within the given trigger.
13231 *
13232 * - `stateNameExpr` can be one or more state names separated by commas.
13233 * - `styles` refers to the {\@link style styling data} that will be persisted on the element once
13234 * the state has been reached.
13235 *
13236 * ```typescript
13237 * // "void" is a reserved name for a state and is used to represent
13238 * // the state in which an element is detached from from the application.
13239 * state("void", style({ height: 0 }))
13240 *
13241 * // user-defined states
13242 * state("closed", style({ height: 0 }))
13243 * state("open, visible", style({ height: "*" }))
13244 * ```
13245 *
13246 * {\@example core/animation/ts/dsl/animation_example.ts region='Component'}
13247 *
13248 * \@experimental Animation support is experimental.
13249 * @param {?} name
13250 * @param {?} styles
13251 * @return {?}
13252 */
13253function state$1(name, styles) {
13254 return { type: 0 /* State */, name: name, styles: styles };
13255}
13256/**
13257 * `keyframes` is an animation-specific function that is designed to be used inside of Angular's
13258 * animation DSL language. If this information is new, please navigate to the {\@link
13259 * Component#animations-anchor component animations metadata page} to gain a better understanding of
13260 * how animations in Angular are used.
13261 *
13262 * `keyframes` specifies a collection of {\@link style style} entries each optionally characterized
13263 * by an `offset` value.
13264 *
13265 * ### Usage
13266 *
13267 * The `keyframes` animation function is designed to be used alongside the {\@link animate animate}
13268 * animation function. Instead of applying animations from where they are currently to their
13269 * destination, keyframes can describe how each style entry is applied and at what point within the
13270 * animation arc (much like CSS Keyframe Animations do).
13271 *
13272 * For each `style()` entry an `offset` value can be set. Doing so allows to specifiy at what
13273 * percentage of the animate time the styles will be applied.
13274 *
13275 * ```typescript
13276 * // the provided offset values describe when each backgroundColor value is applied.
13277 * animate("5s", keyframes([
13278 * style({ backgroundColor: "red", offset: 0 }),
13279 * style({ backgroundColor: "blue", offset: 0.2 }),
13280 * style({ backgroundColor: "orange", offset: 0.3 }),
13281 * style({ backgroundColor: "black", offset: 1 })
13282 * ]))
13283 * ```
13284 *
13285 * Alternatively, if there are no `offset` values used within the style entries then the offsets
13286 * will be calculated automatically.
13287 *
13288 * ```typescript
13289 * animate("5s", keyframes([
13290 * style({ backgroundColor: "red" }) // offset = 0
13291 * style({ backgroundColor: "blue" }) // offset = 0.33
13292 * style({ backgroundColor: "orange" }) // offset = 0.66
13293 * style({ backgroundColor: "black" }) // offset = 1
13294 * ]))
13295 * ```
13296 *
13297 * {\@example core/animation/ts/dsl/animation_example.ts region='Component'}
13298 *
13299 * \@experimental Animation support is experimental.
13300 * @param {?} steps
13301 * @return {?}
13302 */
13303function keyframes$1(steps) {
13304 return { type: 5 /* KeyframeSequence */, steps: steps };
13305}
13306/**
13307 * `transition` is an animation-specific function that is designed to be used inside of Angular's
13308 * animation DSL language. If this information is new, please navigate to the {\@link
13309 * Component#animations-anchor component animations metadata page} to gain a better understanding of
13310 * how animations in Angular are used.
13311 *
13312 * `transition` declares the {\@link sequence sequence of animation steps} that will be run when the
13313 * provided `stateChangeExpr` value is satisfied. The `stateChangeExpr` consists of a `state1 =>
13314 * state2` which consists of two known states (use an asterix (`*`) to refer to a dynamic starting
13315 * and/or ending state).
13316 *
13317 * A function can also be provided as the `stateChangeExpr` argument for a transition and this
13318 * function will be executed each time a state change occurs. If the value returned within the
13319 * function is true then the associated animation will be run.
13320 *
13321 * Animation transitions are placed within an {\@link trigger animation trigger}. For an transition
13322 * to animate to a state value and persist its styles then one or more {\@link state animation
13323 * states} is expected to be defined.
13324 *
13325 * ### Usage
13326 *
13327 * An animation transition is kicked off the `stateChangeExpr` predicate evaluates to true based on
13328 * what the previous state is and what the current state has become. In other words, if a transition
13329 * is defined that matches the old/current state criteria then the associated animation will be
13330 * triggered.
13331 *
13332 * ```typescript
13333 * // all transition/state changes are defined within an animation trigger
13334 * trigger("myAnimationTrigger", [
13335 * // if a state is defined then its styles will be persisted when the
13336 * // animation has fully completed itself
13337 * state("on", style({ background: "green" })),
13338 * state("off", style({ background: "grey" })),
13339 *
13340 * // a transition animation that will be kicked off when the state value
13341 * // bound to "myAnimationTrigger" changes from "on" to "off"
13342 * transition("on => off", animate(500)),
13343 *
13344 * // it is also possible to do run the same animation for both directions
13345 * transition("on <=> off", animate(500)),
13346 *
13347 * // or to define multiple states pairs separated by commas
13348 * transition("on => off, off => void", animate(500)),
13349 *
13350 * // this is a catch-all state change for when an element is inserted into
13351 * // the page and the destination state is unknown
13352 * transition("void => *", [
13353 * style({ opacity: 0 }),
13354 * animate(500)
13355 * ]),
13356 *
13357 * // this will capture a state change between any states
13358 * transition("* => *", animate("1s 0s")),
13359 *
13360 * // you can also go full out and include a function
13361 * transition((fromState, toState) => {
13362 * // when `true` then it will allow the animation below to be invoked
13363 * return fromState == "off" && toState == "on";
13364 * }, animate("1s 0s"))
13365 * ])
13366 * ```
13367 *
13368 * The template associated with this component will make use of the `myAnimationTrigger` animation
13369 * trigger by binding to an element within its template code.
13370 *
13371 * ```html
13372 * <!-- somewhere inside of my-component-tpl.html -->
13373 * <div [\@myAnimationTrigger]="myStatusExp">...</div>
13374 * ```
13375 *
13376 * #### The final `animate` call
13377 *
13378 * If the final step within the transition steps is a call to `animate()` that **only** uses a
13379 * timing value with **no style data** then it will be automatically used as the final animation arc
13380 * for the element to animate itself to the final state. This involves an automatic mix of
13381 * adding/removing CSS styles so that the element will be in the exact state it should be for the
13382 * applied state to be presented correctly.
13383 *
13384 * ```
13385 * // start off by hiding the element, but make sure that it animates properly to whatever state
13386 * // is currently active for "myAnimationTrigger"
13387 * transition("void => *", [
13388 * style({ opacity: 0 }),
13389 * animate(500)
13390 * ])
13391 * ```
13392 *
13393 * ### Transition Aliases (`:enter` and `:leave`)
13394 *
13395 * Given that enter (insertion) and leave (removal) animations are so common, the `transition`
13396 * function accepts both `:enter` and `:leave` values which are aliases for the `void => *` and `*
13397 * => void` state changes.
13398 *
13399 * ```
13400 * transition(":enter", [
13401 * style({ opacity: 0 }),
13402 * animate(500, style({ opacity: 1 }))
13403 * ])
13404 * transition(":leave", [
13405 * animate(500, style({ opacity: 0 }))
13406 * ])
13407 * ```
13408 *
13409 * {\@example core/animation/ts/dsl/animation_example.ts region='Component'}
13410 *
13411 * \@experimental Animation support is experimental.
13412 * @param {?} stateChangeExpr
13413 * @param {?} steps
13414 * @return {?}
13415 */
13416function transition$1(stateChangeExpr, steps) {
13417 return { type: 1 /* Transition */, expr: stateChangeExpr, animation: steps };
13418}
13419
13420/**
13421 * @license
13422 * Copyright Google Inc. All Rights Reserved.
13423 *
13424 * Use of this source code is governed by an MIT-style license that can be
13425 * found in the LICENSE file at https://angular.io/license
13426 */
13427/**
13428 * @deprecated This symbol has moved. Please Import from \@angular/animations instead!
13429 */
13430const AUTO_STYLE$$1 = '*';
13431/**
13432 * @deprecated This symbol has moved. Please Import from \@angular/animations instead!
13433 * @param {?} name
13434 * @param {?} definitions
13435 * @return {?}
13436 */
13437function trigger$$1(name, definitions) {
13438 return trigger$1(name, definitions);
13439}
13440/**
13441 * @deprecated This symbol has moved. Please Import from \@angular/animations instead!
13442 * @param {?} timings
13443 * @param {?=} styles
13444 * @return {?}
13445 */
13446function animate$$1(timings, styles) {
13447 return animate$1(timings, styles);
13448}
13449/**
13450 * @deprecated This symbol has moved. Please Import from \@angular/animations instead!
13451 * @param {?} steps
13452 * @return {?}
13453 */
13454function group$$1(steps) {
13455 return group$1(steps);
13456}
13457/**
13458 * @deprecated This symbol has moved. Please Import from \@angular/animations instead!
13459 * @param {?} steps
13460 * @return {?}
13461 */
13462function sequence$$1(steps) {
13463 return sequence$1(steps);
13464}
13465/**
13466 * @deprecated This symbol has moved. Please Import from \@angular/animations instead!
13467 * @param {?} tokens
13468 * @return {?}
13469 */
13470function style$$1(tokens) {
13471 return style$1(tokens);
13472}
13473/**
13474 * @deprecated This symbol has moved. Please Import from \@angular/animations instead!
13475 * @param {?} name
13476 * @param {?} styles
13477 * @return {?}
13478 */
13479function state$$1(name, styles) {
13480 return state$1(name, styles);
13481}
13482/**
13483 * @deprecated This symbol has moved. Please Import from \@angular/animations instead!
13484 * @param {?} steps
13485 * @return {?}
13486 */
13487function keyframes$$1(steps) {
13488 return keyframes$1(steps);
13489}
13490/**
13491 * @deprecated This symbol has moved. Please Import from \@angular/animations instead!
13492 * @param {?} stateChangeExpr
13493 * @param {?} steps
13494 * @return {?}
13495 */
13496function transition$$1(stateChangeExpr, steps) {
13497 return transition$1(stateChangeExpr, steps);
13498}
13499
13500/**
13501 * @license
13502 * Copyright Google Inc. All Rights Reserved.
13503 *
13504 * Use of this source code is governed by an MIT-style license that can be
13505 * found in the LICENSE file at https://angular.io/license
13506 */
13507/**
13508 * @module
13509 * @description
13510 * Entry point from which you should import all public core APIs.
13511 */
13512
13513/**
13514 * @license
13515 * Copyright Google Inc. All Rights Reserved.
13516 *
13517 * Use of this source code is governed by an MIT-style license that can be
13518 * found in the LICENSE file at https://angular.io/license
13519 */
13520/**
13521 * @module
13522 * @description
13523 * Entry point for all public APIs of the core package.
13524 */
13525
13526// This file only reexports content of the `src` folder. Keep it that way.
13527
13528/**
13529 * Generated bundle index. Do not edit.
13530 */
13531
13532export { Class, createPlatform, assertPlatform, destroyPlatform, getPlatform, PlatformRef, ApplicationRef, enableProdMode, isDevMode, createPlatformFactory, NgProbeToken, APP_ID, PACKAGE_ROOT_URL, PLATFORM_INITIALIZER, PLATFORM_ID, APP_BOOTSTRAP_LISTENER, APP_INITIALIZER, ApplicationInitStatus, DebugElement, DebugNode, asNativeElements, getDebugNode, Testability, TestabilityRegistry, setTestabilityGetter, TRANSLATIONS, TRANSLATIONS_FORMAT, LOCALE_ID, MissingTranslationStrategy, ApplicationModule, wtfCreateScope, wtfLeave, wtfStartTimeRange, wtfEndTimeRange, Type, EventEmitter, ErrorHandler, Sanitizer, SecurityContext, ANALYZE_FOR_ENTRY_COMPONENTS, Attribute, ContentChild, ContentChildren, Query, ViewChild, ViewChildren, Component, Directive, HostBinding, HostListener, Input, Output, Pipe, CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA, NgModule, ViewEncapsulation, Version, VERSION, forwardRef, resolveForwardRef, Injector, ReflectiveInjector, ResolvedReflectiveFactory, ReflectiveKey, InjectionToken, OpaqueToken, Inject, Optional, Injectable, Self, SkipSelf, Host, NgZone, RenderComponentType, Renderer, Renderer2, RendererFactory2, RendererStyleFlags2, RootRenderer, COMPILER_OPTIONS, Compiler, CompilerFactory, ModuleWithComponentFactories, ComponentFactory, ComponentRef, ComponentFactoryResolver, ElementRef, NgModuleFactory, NgModuleRef, NgModuleFactoryLoader, getModuleFactory, QueryList, SystemJsNgModuleLoader, SystemJsNgModuleLoaderConfig, TemplateRef, ViewContainerRef, EmbeddedViewRef, ViewRef, ChangeDetectionStrategy, ChangeDetectorRef, DefaultIterableDiffer, IterableDiffers, KeyValueDiffers, SimpleChange, WrappedValue, platformCore, ALLOW_MULTIPLE_PLATFORMS as ɵALLOW_MULTIPLE_PLATFORMS, APP_ID_RANDOM_PROVIDER as ɵAPP_ID_RANDOM_PROVIDER, ValueUnwrapper as ɵValueUnwrapper, devModeEqual as ɵdevModeEqual, isListLikeIterable as ɵisListLikeIterable, ChangeDetectorStatus as ɵChangeDetectorStatus, isDefaultChangeDetectionStrategy as ɵisDefaultChangeDetectionStrategy, Console as ɵConsole, ERROR_COMPONENT_TYPE as ɵERROR_COMPONENT_TYPE, ComponentFactory as ɵComponentFactory, CodegenComponentFactoryResolver as ɵCodegenComponentFactoryResolver, LIFECYCLE_HOOKS_VALUES as ɵLIFECYCLE_HOOKS_VALUES, LifecycleHooks as ɵLifecycleHooks, ViewMetadata as ɵViewMetadata, Reflector as ɵReflector, reflector as ɵreflector, ReflectionCapabilities as ɵReflectionCapabilities, ReflectorReader as ɵReflectorReader, RenderDebugInfo as ɵRenderDebugInfo, _global as ɵglobal, looseIdentical as ɵlooseIdentical, stringify as ɵstringify, makeDecorator as ɵmakeDecorator, isObservable as ɵisObservable, isPromise as ɵisPromise, NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR as ɵNOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR, NgModuleInjector as ɵNgModuleInjector, registerModuleFactory as ɵregisterModuleFactory, EMPTY_ARRAY as ɵEMPTY_ARRAY, EMPTY_MAP as ɵEMPTY_MAP, anchorDef as ɵand, createComponentFactory as ɵccf, createRendererType2 as ɵcrt, directiveDef as ɵdid, elementDef as ɵeld, elementEventFullName as ɵelementEventFullName, getComponentViewDefinitionFactory as ɵgetComponentViewDefinitionFactory, inlineInterpolate as ɵinlineInterpolate, interpolate as ɵinterpolate, ngContentDef as ɵncd, nodeValue as ɵnov, pipeDef as ɵpid, providerDef as ɵprd, pureArrayDef as ɵpad, pureObjectDef as ɵpod, purePipeDef as ɵppd, queryDef as ɵqud, textDef as ɵted, unwrapValue as ɵunv, viewDef as ɵvid, AUTO_STYLE$$1 as AUTO_STYLE, trigger$$1 as trigger, animate$$1 as animate, group$$1 as group, sequence$$1 as sequence, style$$1 as style, state$$1 as state, keyframes$$1 as keyframes, transition$$1 as transition, animate$1 as ɵba, group$1 as ɵbb, keyframes$1 as ɵbf, sequence$1 as ɵbc, state$1 as ɵbe, style$1 as ɵbd, transition$1 as ɵbg, trigger$1 as ɵz, _initViewEngine as ɵo, _iterableDiffersFactory as ɵl, _keyValueDiffersFactory as ɵm, _localeFactory as ɵn, ApplicationRef_ as ɵf, _appIdRandomProviderFactory as ɵg, defaultIterableDiffers as ɵh, defaultKeyValueDiffers as ɵi, DefaultIterableDifferFactory as ɵj, DefaultKeyValueDifferFactory as ɵk, ReflectiveInjector_ as ɵc, ReflectiveDependency as ɵd, resolveReflectiveProviders as ɵe, wtfEnabled as ɵp, createScope$1 as ɵr, detectWTF as ɵq, endTimeRange as ɵu, leave as ɵs, startTimeRange as ɵt, makeParamDecorator as ɵa, makePropDecorator as ɵb, _def as ɵw, DebugContext as ɵx };
13533//# sourceMappingURL=core.js.map