UNPKG

98.9 kBJavaScriptView Raw
1/**
2 * @license Angular v9.1.9
3 * (c) 2010-2020 Google LLC. https://angular.io/
4 * License: MIT
5 */
6
7import { ɵDomAdapter, ɵsetRootDomAdapter, ɵparseCookieValue, ɵgetDOM, DOCUMENT, ɵPLATFORM_BROWSER_ID, CommonModule } from '@angular/common';
8export { ɵgetDOM } from '@angular/common';
9import { ɵglobal, InjectionToken, ApplicationInitStatus, APP_INITIALIZER, Injector, setTestabilityGetter, ApplicationRef, NgZone, ɵgetDebugNodeR2, NgProbeToken, Optional, Injectable, Inject, ViewEncapsulation, APP_ID, RendererStyleFlags2, ɵConsole, NgModule, forwardRef, ɵɵdefineInjectable, ɵɵinject, SecurityContext, ɵallowSanitizationBypassAndThrow, ɵunwrapSafeValue, ɵgetSanitizationBypassType, ɵ_sanitizeUrl, ɵ_sanitizeStyle, ɵ_sanitizeHtml, ɵbypassSanitizationTrustHtml, ɵbypassSanitizationTrustStyle, ɵbypassSanitizationTrustScript, ɵbypassSanitizationTrustUrl, ɵbypassSanitizationTrustResourceUrl, INJECTOR, ErrorHandler, ɵsetDocument, PLATFORM_ID, PLATFORM_INITIALIZER, Sanitizer, createPlatformFactory, platformCore, ɵINJECTOR_SCOPE, RendererFactory2, Testability, ApplicationModule, SkipSelf, Version } from '@angular/core';
10
11/**
12 * @fileoverview added by tsickle
13 * Generated from: packages/platform-browser/src/browser/generic_browser_adapter.ts
14 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
15 */
16/**
17 * Provides DOM operations in any browser environment.
18 *
19 * \@security Tread carefully! Interacting with the DOM directly is dangerous and
20 * can introduce XSS risks.
21 * @abstract
22 */
23class GenericBrowserDomAdapter extends ɵDomAdapter {
24 constructor() {
25 super();
26 }
27 /**
28 * @return {?}
29 */
30 supportsDOMEvents() {
31 return true;
32 }
33}
34
35/**
36 * @fileoverview added by tsickle
37 * Generated from: packages/platform-browser/src/browser/browser_adapter.ts
38 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
39 */
40const ɵ0 = /**
41 * @return {?}
42 */
43() => {
44 if (ɵglobal['Node']) {
45 return ɵglobal['Node'].prototype.contains || (/**
46 * @this {?}
47 * @param {?} node
48 * @return {?}
49 */
50 function (node) {
51 return !!(this.compareDocumentPosition(node) & 16);
52 });
53 }
54 return (/** @type {?} */ (undefined));
55};
56/** @type {?} */
57const nodeContains = ((ɵ0))();
58/**
59 * A `DomAdapter` powered by full browser DOM APIs.
60 *
61 * \@security Tread carefully! Interacting with the DOM directly is dangerous and
62 * can introduce XSS risks.
63 */
64/* tslint:disable:requireParameterType no-console */
65class BrowserDomAdapter extends GenericBrowserDomAdapter {
66 /**
67 * @return {?}
68 */
69 static makeCurrent() {
70 ɵsetRootDomAdapter(new BrowserDomAdapter());
71 }
72 /**
73 * @param {?} el
74 * @param {?} name
75 * @return {?}
76 */
77 getProperty(el, name) {
78 return ((/** @type {?} */ (el)))[name];
79 }
80 /**
81 * @param {?} error
82 * @return {?}
83 */
84 log(error) {
85 if (window.console) {
86 window.console.log && window.console.log(error);
87 }
88 }
89 /**
90 * @param {?} error
91 * @return {?}
92 */
93 logGroup(error) {
94 if (window.console) {
95 window.console.group && window.console.group(error);
96 }
97 }
98 /**
99 * @return {?}
100 */
101 logGroupEnd() {
102 if (window.console) {
103 window.console.groupEnd && window.console.groupEnd();
104 }
105 }
106 /**
107 * @param {?} el
108 * @param {?} evt
109 * @param {?} listener
110 * @return {?}
111 */
112 onAndCancel(el, evt, listener) {
113 el.addEventListener(evt, listener, false);
114 // Needed to follow Dart's subscription semantic, until fix of
115 // https://code.google.com/p/dart/issues/detail?id=17406
116 return (/**
117 * @return {?}
118 */
119 () => {
120 el.removeEventListener(evt, listener, false);
121 });
122 }
123 /**
124 * @param {?} el
125 * @param {?} evt
126 * @return {?}
127 */
128 dispatchEvent(el, evt) {
129 el.dispatchEvent(evt);
130 }
131 /**
132 * @param {?} node
133 * @return {?}
134 */
135 remove(node) {
136 if (node.parentNode) {
137 node.parentNode.removeChild(node);
138 }
139 return node;
140 }
141 /**
142 * @param {?} el
143 * @return {?}
144 */
145 getValue(el) {
146 return el.value;
147 }
148 /**
149 * @param {?} tagName
150 * @param {?=} doc
151 * @return {?}
152 */
153 createElement(tagName, doc) {
154 doc = doc || this.getDefaultDocument();
155 return doc.createElement(tagName);
156 }
157 /**
158 * @return {?}
159 */
160 createHtmlDocument() {
161 return document.implementation.createHTMLDocument('fakeTitle');
162 }
163 /**
164 * @return {?}
165 */
166 getDefaultDocument() {
167 return document;
168 }
169 /**
170 * @param {?} node
171 * @return {?}
172 */
173 isElementNode(node) {
174 return node.nodeType === Node.ELEMENT_NODE;
175 }
176 /**
177 * @param {?} node
178 * @return {?}
179 */
180 isShadowRoot(node) {
181 return node instanceof DocumentFragment;
182 }
183 /**
184 * @param {?} doc
185 * @param {?} target
186 * @return {?}
187 */
188 getGlobalEventTarget(doc, target) {
189 if (target === 'window') {
190 return window;
191 }
192 if (target === 'document') {
193 return doc;
194 }
195 if (target === 'body') {
196 return doc.body;
197 }
198 return null;
199 }
200 /**
201 * @return {?}
202 */
203 getHistory() {
204 return window.history;
205 }
206 /**
207 * @return {?}
208 */
209 getLocation() {
210 return window.location;
211 }
212 /**
213 * @param {?} doc
214 * @return {?}
215 */
216 getBaseHref(doc) {
217 /** @type {?} */
218 const href = getBaseElementHref();
219 return href == null ? null : relativePath(href);
220 }
221 /**
222 * @return {?}
223 */
224 resetBaseElement() {
225 baseElement = null;
226 }
227 /**
228 * @return {?}
229 */
230 getUserAgent() {
231 return window.navigator.userAgent;
232 }
233 /**
234 * @return {?}
235 */
236 performanceNow() {
237 // performance.now() is not available in all browsers, see
238 // http://caniuse.com/#search=performance.now
239 return window.performance && window.performance.now ? window.performance.now() :
240 new Date().getTime();
241 }
242 /**
243 * @return {?}
244 */
245 supportsCookies() {
246 return true;
247 }
248 /**
249 * @param {?} name
250 * @return {?}
251 */
252 getCookie(name) {
253 return ɵparseCookieValue(document.cookie, name);
254 }
255}
256/** @type {?} */
257let baseElement = null;
258/**
259 * @return {?}
260 */
261function getBaseElementHref() {
262 if (!baseElement) {
263 baseElement = (/** @type {?} */ (document.querySelector('base')));
264 if (!baseElement) {
265 return null;
266 }
267 }
268 return baseElement.getAttribute('href');
269}
270// based on urlUtils.js in AngularJS 1
271/** @type {?} */
272let urlParsingNode;
273/**
274 * @param {?} url
275 * @return {?}
276 */
277function relativePath(url) {
278 if (!urlParsingNode) {
279 urlParsingNode = document.createElement('a');
280 }
281 urlParsingNode.setAttribute('href', url);
282 return (urlParsingNode.pathname.charAt(0) === '/') ? urlParsingNode.pathname :
283 '/' + urlParsingNode.pathname;
284}
285
286/**
287 * @fileoverview added by tsickle
288 * Generated from: packages/platform-browser/src/browser/server-transition.ts
289 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
290 */
291/**
292 * An id that identifies a particular application being bootstrapped, that should
293 * match across the client/server boundary.
294 * @type {?}
295 */
296const TRANSITION_ID = new InjectionToken('TRANSITION_ID');
297/**
298 * @param {?} transitionId
299 * @param {?} document
300 * @param {?} injector
301 * @return {?}
302 */
303function appInitializerFactory(transitionId, document, injector) {
304 return (/**
305 * @return {?}
306 */
307 () => {
308 // Wait for all application initializers to be completed before removing the styles set by
309 // the server.
310 injector.get(ApplicationInitStatus).donePromise.then((/**
311 * @return {?}
312 */
313 () => {
314 /** @type {?} */
315 const dom = ɵgetDOM();
316 /** @type {?} */
317 const styles = Array.prototype.slice.apply(document.querySelectorAll(`style[ng-transition]`));
318 styles.filter((/**
319 * @param {?} el
320 * @return {?}
321 */
322 el => el.getAttribute('ng-transition') === transitionId))
323 .forEach((/**
324 * @param {?} el
325 * @return {?}
326 */
327 el => dom.remove(el)));
328 }));
329 });
330}
331/** @type {?} */
332const SERVER_TRANSITION_PROVIDERS = [
333 {
334 provide: APP_INITIALIZER,
335 useFactory: appInitializerFactory,
336 deps: [TRANSITION_ID, DOCUMENT, Injector],
337 multi: true
338 },
339];
340
341/**
342 * @fileoverview added by tsickle
343 * Generated from: packages/platform-browser/src/browser/testability.ts
344 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
345 */
346class BrowserGetTestability {
347 /**
348 * @return {?}
349 */
350 static init() {
351 setTestabilityGetter(new BrowserGetTestability());
352 }
353 /**
354 * @param {?} registry
355 * @return {?}
356 */
357 addToWindow(registry) {
358 ɵglobal['getAngularTestability'] = (/**
359 * @param {?} elem
360 * @param {?=} findInAncestors
361 * @return {?}
362 */
363 (elem, findInAncestors = true) => {
364 /** @type {?} */
365 const testability = registry.findTestabilityInTree(elem, findInAncestors);
366 if (testability == null) {
367 throw new Error('Could not find testability for element.');
368 }
369 return testability;
370 });
371 ɵglobal['getAllAngularTestabilities'] = (/**
372 * @return {?}
373 */
374 () => registry.getAllTestabilities());
375 ɵglobal['getAllAngularRootElements'] = (/**
376 * @return {?}
377 */
378 () => registry.getAllRootElements());
379 /** @type {?} */
380 const whenAllStable = (/**
381 * @param {?} callback
382 * @return {?}
383 */
384 (callback /** TODO #9100 */) => {
385 /** @type {?} */
386 const testabilities = ɵglobal['getAllAngularTestabilities']();
387 /** @type {?} */
388 let count = testabilities.length;
389 /** @type {?} */
390 let didWork = false;
391 /** @type {?} */
392 const decrement = (/**
393 * @param {?} didWork_
394 * @return {?}
395 */
396 function (didWork_ /** TODO #9100 */) {
397 didWork = didWork || didWork_;
398 count--;
399 if (count == 0) {
400 callback(didWork);
401 }
402 });
403 testabilities.forEach((/**
404 * @param {?} testability
405 * @return {?}
406 */
407 function (testability /** TODO #9100 */) {
408 testability.whenStable(decrement);
409 }));
410 });
411 if (!ɵglobal['frameworkStabilizers']) {
412 ɵglobal['frameworkStabilizers'] = [];
413 }
414 ɵglobal['frameworkStabilizers'].push(whenAllStable);
415 }
416 /**
417 * @param {?} registry
418 * @param {?} elem
419 * @param {?} findInAncestors
420 * @return {?}
421 */
422 findTestabilityInTree(registry, elem, findInAncestors) {
423 if (elem == null) {
424 return null;
425 }
426 /** @type {?} */
427 const t = registry.getTestability(elem);
428 if (t != null) {
429 return t;
430 }
431 else if (!findInAncestors) {
432 return null;
433 }
434 if (ɵgetDOM().isShadowRoot(elem)) {
435 return this.findTestabilityInTree(registry, ((/** @type {?} */ (elem))).host, true);
436 }
437 return this.findTestabilityInTree(registry, elem.parentElement, true);
438 }
439}
440
441/**
442 * @fileoverview added by tsickle
443 * Generated from: packages/platform-browser/src/dom/util.ts
444 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
445 */
446/** @type {?} */
447const CAMEL_CASE_REGEXP = /([A-Z])/g;
448/** @type {?} */
449const DASH_CASE_REGEXP = /-([a-z])/g;
450/**
451 * @param {?} input
452 * @return {?}
453 */
454function camelCaseToDashCase(input) {
455 return input.replace(CAMEL_CASE_REGEXP, (/**
456 * @param {...?} m
457 * @return {?}
458 */
459 (...m) => '-' + m[1].toLowerCase()));
460}
461/**
462 * @param {?} input
463 * @return {?}
464 */
465function dashCaseToCamelCase(input) {
466 return input.replace(DASH_CASE_REGEXP, (/**
467 * @param {...?} m
468 * @return {?}
469 */
470 (...m) => m[1].toUpperCase()));
471}
472/**
473 * Exports the value under a given `name` in the global property `ng`. For example `ng.probe` if
474 * `name` is `'probe'`.
475 * @param {?} name Name under which it will be exported. Keep in mind this will be a property of the
476 * global `ng` object.
477 * @param {?} value The value to export.
478 * @return {?}
479 */
480function exportNgVar(name, value) {
481 if (typeof COMPILED === 'undefined' || !COMPILED) {
482 // Note: we can't export `ng` when using closure enhanced optimization as:
483 // - closure declares globals itself for minified names, which sometimes clobber our `ng` global
484 // - we can't declare a closure extern as the namespace `ng` is already used within Google
485 // for typings for angularJS (via `goog.provide('ng....')`).
486 /** @type {?} */
487 const ng = ɵglobal['ng'] = ((/** @type {?} */ (ɵglobal['ng']))) || {};
488 ng[name] = value;
489 }
490}
491
492/**
493 * @fileoverview added by tsickle
494 * Generated from: packages/platform-browser/src/dom/debug/ng_probe.ts
495 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
496 */
497const ɵ0$1 = /**
498 * @return {?}
499 */
500() => ({
501 'ApplicationRef': ApplicationRef,
502 'NgZone': NgZone,
503});
504/** @type {?} */
505const CORE_TOKENS = ((ɵ0$1))();
506/** @type {?} */
507const INSPECT_GLOBAL_NAME = 'probe';
508/** @type {?} */
509const CORE_TOKENS_GLOBAL_NAME = 'coreTokens';
510/**
511 * Returns a {\@link DebugElement} for the given native DOM element, or
512 * null if the given native element does not have an Angular view associated
513 * with it.
514 * @param {?} element
515 * @return {?}
516 */
517function inspectNativeElementR2(element) {
518 return ɵgetDebugNodeR2(element);
519}
520/**
521 * @param {?} coreTokens
522 * @return {?}
523 */
524function _createNgProbeR2(coreTokens) {
525 exportNgVar(INSPECT_GLOBAL_NAME, inspectNativeElementR2);
526 exportNgVar(CORE_TOKENS_GLOBAL_NAME, Object.assign(Object.assign({}, CORE_TOKENS), _ngProbeTokensToMap(coreTokens || [])));
527 return (/**
528 * @return {?}
529 */
530 () => inspectNativeElementR2);
531}
532/**
533 * @param {?} tokens
534 * @return {?}
535 */
536function _ngProbeTokensToMap(tokens) {
537 return tokens.reduce((/**
538 * @param {?} prev
539 * @param {?} t
540 * @return {?}
541 */
542 (prev, t) => (prev[t.name] = t.token, prev)), {});
543}
544/**
545 * In Ivy, we don't support NgProbe because we have our own set of testing utilities
546 * with more robust functionality.
547 *
548 * We shouldn't bring in NgProbe because it prevents DebugNode and friends from
549 * tree-shaking properly.
550 * @type {?}
551 */
552const ELEMENT_PROBE_PROVIDERS__POST_R3__ = [];
553/**
554 * Providers which support debugging Angular applications (e.g. via `ng.probe`).
555 * @type {?}
556 */
557const ELEMENT_PROBE_PROVIDERS__PRE_R3__ = [
558 {
559 provide: APP_INITIALIZER,
560 useFactory: _createNgProbeR2,
561 deps: [
562 [NgProbeToken, new Optional()],
563 ],
564 multi: true,
565 },
566];
567/** @type {?} */
568const ELEMENT_PROBE_PROVIDERS = ELEMENT_PROBE_PROVIDERS__PRE_R3__;
569
570/**
571 * @fileoverview added by tsickle
572 * Generated from: packages/platform-browser/src/dom/events/event_manager.ts
573 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
574 */
575/**
576 * The injection token for the event-manager plug-in service.
577 *
578 * \@publicApi
579 * @type {?}
580 */
581const EVENT_MANAGER_PLUGINS = new InjectionToken('EventManagerPlugins');
582/**
583 * An injectable service that provides event management for Angular
584 * through a browser plug-in.
585 *
586 * \@publicApi
587 */
588class EventManager {
589 /**
590 * Initializes an instance of the event-manager service.
591 * @param {?} plugins
592 * @param {?} _zone
593 */
594 constructor(plugins, _zone) {
595 this._zone = _zone;
596 this._eventNameToPlugin = new Map();
597 plugins.forEach((/**
598 * @template THIS
599 * @this {THIS}
600 * @param {?} p
601 * @return {THIS}
602 */
603 p => p.manager = this));
604 this._plugins = plugins.slice().reverse();
605 }
606 /**
607 * Registers a handler for a specific element and event.
608 *
609 * @param {?} element The HTML element to receive event notifications.
610 * @param {?} eventName The name of the event to listen for.
611 * @param {?} handler A function to call when the notification occurs. Receives the
612 * event object as an argument.
613 * @return {?} A callback function that can be used to remove the handler.
614 */
615 addEventListener(element, eventName, handler) {
616 /** @type {?} */
617 const plugin = this._findPluginFor(eventName);
618 return plugin.addEventListener(element, eventName, handler);
619 }
620 /**
621 * Registers a global handler for an event in a target view.
622 *
623 * @param {?} target A target for global event notifications. One of "window", "document", or "body".
624 * @param {?} eventName The name of the event to listen for.
625 * @param {?} handler A function to call when the notification occurs. Receives the
626 * event object as an argument.
627 * @return {?} A callback function that can be used to remove the handler.
628 */
629 addGlobalEventListener(target, eventName, handler) {
630 /** @type {?} */
631 const plugin = this._findPluginFor(eventName);
632 return plugin.addGlobalEventListener(target, eventName, handler);
633 }
634 /**
635 * Retrieves the compilation zone in which event listeners are registered.
636 * @return {?}
637 */
638 getZone() {
639 return this._zone;
640 }
641 /**
642 * \@internal
643 * @param {?} eventName
644 * @return {?}
645 */
646 _findPluginFor(eventName) {
647 /** @type {?} */
648 const plugin = this._eventNameToPlugin.get(eventName);
649 if (plugin) {
650 return plugin;
651 }
652 /** @type {?} */
653 const plugins = this._plugins;
654 for (let i = 0; i < plugins.length; i++) {
655 /** @type {?} */
656 const plugin = plugins[i];
657 if (plugin.supports(eventName)) {
658 this._eventNameToPlugin.set(eventName, plugin);
659 return plugin;
660 }
661 }
662 throw new Error(`No event manager plugin found for event ${eventName}`);
663 }
664}
665EventManager.decorators = [
666 { type: Injectable }
667];
668/** @nocollapse */
669EventManager.ctorParameters = () => [
670 { type: Array, decorators: [{ type: Inject, args: [EVENT_MANAGER_PLUGINS,] }] },
671 { type: NgZone }
672];
673if (false) {
674 /**
675 * @type {?}
676 * @private
677 */
678 EventManager.prototype._plugins;
679 /**
680 * @type {?}
681 * @private
682 */
683 EventManager.prototype._eventNameToPlugin;
684 /**
685 * @type {?}
686 * @private
687 */
688 EventManager.prototype._zone;
689}
690/**
691 * @abstract
692 */
693class EventManagerPlugin {
694 /**
695 * @param {?} _doc
696 */
697 constructor(_doc) {
698 this._doc = _doc;
699 }
700 /**
701 * @param {?} element
702 * @param {?} eventName
703 * @param {?} handler
704 * @return {?}
705 */
706 addGlobalEventListener(element, eventName, handler) {
707 /** @type {?} */
708 const target = ɵgetDOM().getGlobalEventTarget(this._doc, element);
709 if (!target) {
710 throw new Error(`Unsupported event target ${target} for event ${eventName}`);
711 }
712 return this.addEventListener(target, eventName, handler);
713 }
714}
715if (false) {
716 /** @type {?} */
717 EventManagerPlugin.prototype.manager;
718 /**
719 * @type {?}
720 * @private
721 */
722 EventManagerPlugin.prototype._doc;
723 /**
724 * @abstract
725 * @param {?} eventName
726 * @return {?}
727 */
728 EventManagerPlugin.prototype.supports = function (eventName) { };
729 /**
730 * @abstract
731 * @param {?} element
732 * @param {?} eventName
733 * @param {?} handler
734 * @return {?}
735 */
736 EventManagerPlugin.prototype.addEventListener = function (element, eventName, handler) { };
737}
738
739/**
740 * @fileoverview added by tsickle
741 * Generated from: packages/platform-browser/src/dom/shared_styles_host.ts
742 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
743 */
744class SharedStylesHost {
745 constructor() {
746 /**
747 * \@internal
748 */
749 this._stylesSet = new Set();
750 }
751 /**
752 * @param {?} styles
753 * @return {?}
754 */
755 addStyles(styles) {
756 /** @type {?} */
757 const additions = new Set();
758 styles.forEach((/**
759 * @param {?} style
760 * @return {?}
761 */
762 style => {
763 if (!this._stylesSet.has(style)) {
764 this._stylesSet.add(style);
765 additions.add(style);
766 }
767 }));
768 this.onStylesAdded(additions);
769 }
770 /**
771 * @param {?} additions
772 * @return {?}
773 */
774 onStylesAdded(additions) { }
775 /**
776 * @return {?}
777 */
778 getAllStyles() {
779 return Array.from(this._stylesSet);
780 }
781}
782SharedStylesHost.decorators = [
783 { type: Injectable }
784];
785if (false) {
786 /**
787 * \@internal
788 * @type {?}
789 * @protected
790 */
791 SharedStylesHost.prototype._stylesSet;
792}
793class DomSharedStylesHost extends SharedStylesHost {
794 /**
795 * @param {?} _doc
796 */
797 constructor(_doc) {
798 super();
799 this._doc = _doc;
800 this._hostNodes = new Set();
801 this._styleNodes = new Set();
802 this._hostNodes.add(_doc.head);
803 }
804 /**
805 * @private
806 * @param {?} styles
807 * @param {?} host
808 * @return {?}
809 */
810 _addStylesToHost(styles, host) {
811 styles.forEach((/**
812 * @param {?} style
813 * @return {?}
814 */
815 (style) => {
816 /** @type {?} */
817 const styleEl = this._doc.createElement('style');
818 styleEl.textContent = style;
819 this._styleNodes.add(host.appendChild(styleEl));
820 }));
821 }
822 /**
823 * @param {?} hostNode
824 * @return {?}
825 */
826 addHost(hostNode) {
827 this._addStylesToHost(this._stylesSet, hostNode);
828 this._hostNodes.add(hostNode);
829 }
830 /**
831 * @param {?} hostNode
832 * @return {?}
833 */
834 removeHost(hostNode) {
835 this._hostNodes.delete(hostNode);
836 }
837 /**
838 * @param {?} additions
839 * @return {?}
840 */
841 onStylesAdded(additions) {
842 this._hostNodes.forEach((/**
843 * @param {?} hostNode
844 * @return {?}
845 */
846 hostNode => this._addStylesToHost(additions, hostNode)));
847 }
848 /**
849 * @return {?}
850 */
851 ngOnDestroy() {
852 this._styleNodes.forEach((/**
853 * @param {?} styleNode
854 * @return {?}
855 */
856 styleNode => ɵgetDOM().remove(styleNode)));
857 }
858}
859DomSharedStylesHost.decorators = [
860 { type: Injectable }
861];
862/** @nocollapse */
863DomSharedStylesHost.ctorParameters = () => [
864 { type: undefined, decorators: [{ type: Inject, args: [DOCUMENT,] }] }
865];
866if (false) {
867 /**
868 * @type {?}
869 * @private
870 */
871 DomSharedStylesHost.prototype._hostNodes;
872 /**
873 * @type {?}
874 * @private
875 */
876 DomSharedStylesHost.prototype._styleNodes;
877 /**
878 * @type {?}
879 * @private
880 */
881 DomSharedStylesHost.prototype._doc;
882}
883
884/**
885 * @fileoverview added by tsickle
886 * Generated from: packages/platform-browser/src/dom/dom_renderer.ts
887 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
888 */
889/** @type {?} */
890const NAMESPACE_URIS = {
891 'svg': 'http://www.w3.org/2000/svg',
892 'xhtml': 'http://www.w3.org/1999/xhtml',
893 'xlink': 'http://www.w3.org/1999/xlink',
894 'xml': 'http://www.w3.org/XML/1998/namespace',
895 'xmlns': 'http://www.w3.org/2000/xmlns/',
896};
897/** @type {?} */
898const COMPONENT_REGEX = /%COMP%/g;
899/** @type {?} */
900const NG_DEV_MODE = typeof ngDevMode === 'undefined' || !!ngDevMode;
901/** @type {?} */
902const COMPONENT_VARIABLE = '%COMP%';
903/** @type {?} */
904const HOST_ATTR = `_nghost-${COMPONENT_VARIABLE}`;
905/** @type {?} */
906const CONTENT_ATTR = `_ngcontent-${COMPONENT_VARIABLE}`;
907/**
908 * @param {?} componentShortId
909 * @return {?}
910 */
911function shimContentAttribute(componentShortId) {
912 return CONTENT_ATTR.replace(COMPONENT_REGEX, componentShortId);
913}
914/**
915 * @param {?} componentShortId
916 * @return {?}
917 */
918function shimHostAttribute(componentShortId) {
919 return HOST_ATTR.replace(COMPONENT_REGEX, componentShortId);
920}
921/**
922 * @param {?} compId
923 * @param {?} styles
924 * @param {?} target
925 * @return {?}
926 */
927function flattenStyles(compId, styles, target) {
928 for (let i = 0; i < styles.length; i++) {
929 /** @type {?} */
930 let style = styles[i];
931 if (Array.isArray(style)) {
932 flattenStyles(compId, style, target);
933 }
934 else {
935 style = style.replace(COMPONENT_REGEX, compId);
936 target.push(style);
937 }
938 }
939 return target;
940}
941/**
942 * @param {?} eventHandler
943 * @return {?}
944 */
945function decoratePreventDefault(eventHandler) {
946 // `DebugNode.triggerEventHandler` needs to know if the listener was created with
947 // decoratePreventDefault or is a listener added outside the Angular context so it can handle the
948 // two differently. In the first case, the special '__ngUnwrap__' token is passed to the unwrap
949 // the listener (see below).
950 return (/**
951 * @param {?} event
952 * @return {?}
953 */
954 (event) => {
955 // Ivy uses '__ngUnwrap__' as a special token that allows us to unwrap the function
956 // so that it can be invoked programmatically by `DebugNode.triggerEventHandler`. The debug_node
957 // can inspect the listener toString contents for the existence of this special token. Because
958 // the token is a string literal, it is ensured to not be modified by compiled code.
959 if (event === '__ngUnwrap__') {
960 return eventHandler;
961 }
962 /** @type {?} */
963 const allowDefaultBehavior = eventHandler(event);
964 if (allowDefaultBehavior === false) {
965 // TODO(tbosch): move preventDefault into event plugins...
966 event.preventDefault();
967 event.returnValue = false;
968 }
969 return undefined;
970 });
971}
972class DomRendererFactory2 {
973 /**
974 * @param {?} eventManager
975 * @param {?} sharedStylesHost
976 * @param {?} appId
977 */
978 constructor(eventManager, sharedStylesHost, appId) {
979 this.eventManager = eventManager;
980 this.sharedStylesHost = sharedStylesHost;
981 this.appId = appId;
982 this.rendererByCompId = new Map();
983 this.defaultRenderer = new DefaultDomRenderer2(eventManager);
984 }
985 /**
986 * @param {?} element
987 * @param {?} type
988 * @return {?}
989 */
990 createRenderer(element, type) {
991 if (!element || !type) {
992 return this.defaultRenderer;
993 }
994 switch (type.encapsulation) {
995 case ViewEncapsulation.Emulated: {
996 /** @type {?} */
997 let renderer = this.rendererByCompId.get(type.id);
998 if (!renderer) {
999 renderer = new EmulatedEncapsulationDomRenderer2(this.eventManager, this.sharedStylesHost, type, this.appId);
1000 this.rendererByCompId.set(type.id, renderer);
1001 }
1002 ((/** @type {?} */ (renderer))).applyToHost(element);
1003 return renderer;
1004 }
1005 case ViewEncapsulation.Native:
1006 case ViewEncapsulation.ShadowDom:
1007 return new ShadowDomRenderer(this.eventManager, this.sharedStylesHost, element, type);
1008 default: {
1009 if (!this.rendererByCompId.has(type.id)) {
1010 /** @type {?} */
1011 const styles = flattenStyles(type.id, type.styles, []);
1012 this.sharedStylesHost.addStyles(styles);
1013 this.rendererByCompId.set(type.id, this.defaultRenderer);
1014 }
1015 return this.defaultRenderer;
1016 }
1017 }
1018 }
1019 /**
1020 * @return {?}
1021 */
1022 begin() { }
1023 /**
1024 * @return {?}
1025 */
1026 end() { }
1027}
1028DomRendererFactory2.decorators = [
1029 { type: Injectable }
1030];
1031/** @nocollapse */
1032DomRendererFactory2.ctorParameters = () => [
1033 { type: EventManager },
1034 { type: DomSharedStylesHost },
1035 { type: String, decorators: [{ type: Inject, args: [APP_ID,] }] }
1036];
1037if (false) {
1038 /**
1039 * @type {?}
1040 * @private
1041 */
1042 DomRendererFactory2.prototype.rendererByCompId;
1043 /**
1044 * @type {?}
1045 * @private
1046 */
1047 DomRendererFactory2.prototype.defaultRenderer;
1048 /**
1049 * @type {?}
1050 * @private
1051 */
1052 DomRendererFactory2.prototype.eventManager;
1053 /**
1054 * @type {?}
1055 * @private
1056 */
1057 DomRendererFactory2.prototype.sharedStylesHost;
1058 /**
1059 * @type {?}
1060 * @private
1061 */
1062 DomRendererFactory2.prototype.appId;
1063}
1064class DefaultDomRenderer2 {
1065 /**
1066 * @param {?} eventManager
1067 */
1068 constructor(eventManager) {
1069 this.eventManager = eventManager;
1070 this.data = Object.create(null);
1071 }
1072 /**
1073 * @return {?}
1074 */
1075 destroy() { }
1076 /**
1077 * @param {?} name
1078 * @param {?=} namespace
1079 * @return {?}
1080 */
1081 createElement(name, namespace) {
1082 if (namespace) {
1083 // In cases where Ivy (not ViewEngine) is giving us the actual namespace, the look up by key
1084 // will result in undefined, so we just return the namespace here.
1085 return document.createElementNS(NAMESPACE_URIS[namespace] || namespace, name);
1086 }
1087 return document.createElement(name);
1088 }
1089 /**
1090 * @param {?} value
1091 * @return {?}
1092 */
1093 createComment(value) {
1094 return document.createComment(value);
1095 }
1096 /**
1097 * @param {?} value
1098 * @return {?}
1099 */
1100 createText(value) {
1101 return document.createTextNode(value);
1102 }
1103 /**
1104 * @param {?} parent
1105 * @param {?} newChild
1106 * @return {?}
1107 */
1108 appendChild(parent, newChild) {
1109 parent.appendChild(newChild);
1110 }
1111 /**
1112 * @param {?} parent
1113 * @param {?} newChild
1114 * @param {?} refChild
1115 * @return {?}
1116 */
1117 insertBefore(parent, newChild, refChild) {
1118 if (parent) {
1119 parent.insertBefore(newChild, refChild);
1120 }
1121 }
1122 /**
1123 * @param {?} parent
1124 * @param {?} oldChild
1125 * @return {?}
1126 */
1127 removeChild(parent, oldChild) {
1128 if (parent) {
1129 parent.removeChild(oldChild);
1130 }
1131 }
1132 /**
1133 * @param {?} selectorOrNode
1134 * @param {?=} preserveContent
1135 * @return {?}
1136 */
1137 selectRootElement(selectorOrNode, preserveContent) {
1138 /** @type {?} */
1139 let el = typeof selectorOrNode === 'string' ? document.querySelector(selectorOrNode) :
1140 selectorOrNode;
1141 if (!el) {
1142 throw new Error(`The selector "${selectorOrNode}" did not match any elements`);
1143 }
1144 if (!preserveContent) {
1145 el.textContent = '';
1146 }
1147 return el;
1148 }
1149 /**
1150 * @param {?} node
1151 * @return {?}
1152 */
1153 parentNode(node) {
1154 return node.parentNode;
1155 }
1156 /**
1157 * @param {?} node
1158 * @return {?}
1159 */
1160 nextSibling(node) {
1161 return node.nextSibling;
1162 }
1163 /**
1164 * @param {?} el
1165 * @param {?} name
1166 * @param {?} value
1167 * @param {?=} namespace
1168 * @return {?}
1169 */
1170 setAttribute(el, name, value, namespace) {
1171 if (namespace) {
1172 name = namespace + ':' + name;
1173 // TODO(FW-811): Ivy may cause issues here because it's passing around
1174 // full URIs for namespaces, therefore this lookup will fail.
1175 /** @type {?} */
1176 const namespaceUri = NAMESPACE_URIS[namespace];
1177 if (namespaceUri) {
1178 el.setAttributeNS(namespaceUri, name, value);
1179 }
1180 else {
1181 el.setAttribute(name, value);
1182 }
1183 }
1184 else {
1185 el.setAttribute(name, value);
1186 }
1187 }
1188 /**
1189 * @param {?} el
1190 * @param {?} name
1191 * @param {?=} namespace
1192 * @return {?}
1193 */
1194 removeAttribute(el, name, namespace) {
1195 if (namespace) {
1196 // TODO(FW-811): Ivy may cause issues here because it's passing around
1197 // full URIs for namespaces, therefore this lookup will fail.
1198 /** @type {?} */
1199 const namespaceUri = NAMESPACE_URIS[namespace];
1200 if (namespaceUri) {
1201 el.removeAttributeNS(namespaceUri, name);
1202 }
1203 else {
1204 // TODO(FW-811): Since ivy is passing around full URIs for namespaces
1205 // this could result in properties like `http://www.w3.org/2000/svg:cx="123"`,
1206 // which is wrong.
1207 el.removeAttribute(`${namespace}:${name}`);
1208 }
1209 }
1210 else {
1211 el.removeAttribute(name);
1212 }
1213 }
1214 /**
1215 * @param {?} el
1216 * @param {?} name
1217 * @return {?}
1218 */
1219 addClass(el, name) {
1220 el.classList.add(name);
1221 }
1222 /**
1223 * @param {?} el
1224 * @param {?} name
1225 * @return {?}
1226 */
1227 removeClass(el, name) {
1228 el.classList.remove(name);
1229 }
1230 /**
1231 * @param {?} el
1232 * @param {?} style
1233 * @param {?} value
1234 * @param {?} flags
1235 * @return {?}
1236 */
1237 setStyle(el, style, value, flags) {
1238 if (flags & RendererStyleFlags2.DashCase) {
1239 el.style.setProperty(style, value, !!(flags & RendererStyleFlags2.Important) ? 'important' : '');
1240 }
1241 else {
1242 el.style[style] = value;
1243 }
1244 }
1245 /**
1246 * @param {?} el
1247 * @param {?} style
1248 * @param {?} flags
1249 * @return {?}
1250 */
1251 removeStyle(el, style, flags) {
1252 if (flags & RendererStyleFlags2.DashCase) {
1253 el.style.removeProperty(style);
1254 }
1255 else {
1256 // IE requires '' instead of null
1257 // see https://github.com/angular/angular/issues/7916
1258 el.style[style] = '';
1259 }
1260 }
1261 /**
1262 * @param {?} el
1263 * @param {?} name
1264 * @param {?} value
1265 * @return {?}
1266 */
1267 setProperty(el, name, value) {
1268 NG_DEV_MODE && checkNoSyntheticProp(name, 'property');
1269 el[name] = value;
1270 }
1271 /**
1272 * @param {?} node
1273 * @param {?} value
1274 * @return {?}
1275 */
1276 setValue(node, value) {
1277 node.nodeValue = value;
1278 }
1279 /**
1280 * @param {?} target
1281 * @param {?} event
1282 * @param {?} callback
1283 * @return {?}
1284 */
1285 listen(target, event, callback) {
1286 NG_DEV_MODE && checkNoSyntheticProp(event, 'listener');
1287 if (typeof target === 'string') {
1288 return (/** @type {?} */ (this.eventManager.addGlobalEventListener(target, event, decoratePreventDefault(callback))));
1289 }
1290 return (/** @type {?} */ ((/** @type {?} */ (this.eventManager.addEventListener(target, event, decoratePreventDefault(callback))))));
1291 }
1292}
1293if (false) {
1294 /** @type {?} */
1295 DefaultDomRenderer2.prototype.data;
1296 /** @type {?} */
1297 DefaultDomRenderer2.prototype.destroyNode;
1298 /**
1299 * @type {?}
1300 * @private
1301 */
1302 DefaultDomRenderer2.prototype.eventManager;
1303}
1304const ɵ0$2 = /**
1305 * @return {?}
1306 */
1307() => '@'.charCodeAt(0);
1308/** @type {?} */
1309const AT_CHARCODE = ((ɵ0$2))();
1310/**
1311 * @param {?} name
1312 * @param {?} nameKind
1313 * @return {?}
1314 */
1315function checkNoSyntheticProp(name, nameKind) {
1316 if (name.charCodeAt(0) === AT_CHARCODE) {
1317 throw new Error(`Found the synthetic ${nameKind} ${name}. Please include either "BrowserAnimationsModule" or "NoopAnimationsModule" in your application.`);
1318 }
1319}
1320class EmulatedEncapsulationDomRenderer2 extends DefaultDomRenderer2 {
1321 /**
1322 * @param {?} eventManager
1323 * @param {?} sharedStylesHost
1324 * @param {?} component
1325 * @param {?} appId
1326 */
1327 constructor(eventManager, sharedStylesHost, component, appId) {
1328 super(eventManager);
1329 this.component = component;
1330 /** @type {?} */
1331 const styles = flattenStyles(appId + '-' + component.id, component.styles, []);
1332 sharedStylesHost.addStyles(styles);
1333 this.contentAttr = shimContentAttribute(appId + '-' + component.id);
1334 this.hostAttr = shimHostAttribute(appId + '-' + component.id);
1335 }
1336 /**
1337 * @param {?} element
1338 * @return {?}
1339 */
1340 applyToHost(element) {
1341 super.setAttribute(element, this.hostAttr, '');
1342 }
1343 /**
1344 * @param {?} parent
1345 * @param {?} name
1346 * @return {?}
1347 */
1348 createElement(parent, name) {
1349 /** @type {?} */
1350 const el = super.createElement(parent, name);
1351 super.setAttribute(el, this.contentAttr, '');
1352 return el;
1353 }
1354}
1355if (false) {
1356 /**
1357 * @type {?}
1358 * @private
1359 */
1360 EmulatedEncapsulationDomRenderer2.prototype.contentAttr;
1361 /**
1362 * @type {?}
1363 * @private
1364 */
1365 EmulatedEncapsulationDomRenderer2.prototype.hostAttr;
1366 /**
1367 * @type {?}
1368 * @private
1369 */
1370 EmulatedEncapsulationDomRenderer2.prototype.component;
1371}
1372class ShadowDomRenderer extends DefaultDomRenderer2 {
1373 /**
1374 * @param {?} eventManager
1375 * @param {?} sharedStylesHost
1376 * @param {?} hostEl
1377 * @param {?} component
1378 */
1379 constructor(eventManager, sharedStylesHost, hostEl, component) {
1380 super(eventManager);
1381 this.sharedStylesHost = sharedStylesHost;
1382 this.hostEl = hostEl;
1383 this.component = component;
1384 if (component.encapsulation === ViewEncapsulation.ShadowDom) {
1385 this.shadowRoot = ((/** @type {?} */ (hostEl))).attachShadow({ mode: 'open' });
1386 }
1387 else {
1388 this.shadowRoot = ((/** @type {?} */ (hostEl))).createShadowRoot();
1389 }
1390 this.sharedStylesHost.addHost(this.shadowRoot);
1391 /** @type {?} */
1392 const styles = flattenStyles(component.id, component.styles, []);
1393 for (let i = 0; i < styles.length; i++) {
1394 /** @type {?} */
1395 const styleEl = document.createElement('style');
1396 styleEl.textContent = styles[i];
1397 this.shadowRoot.appendChild(styleEl);
1398 }
1399 }
1400 /**
1401 * @private
1402 * @param {?} node
1403 * @return {?}
1404 */
1405 nodeOrShadowRoot(node) {
1406 return node === this.hostEl ? this.shadowRoot : node;
1407 }
1408 /**
1409 * @return {?}
1410 */
1411 destroy() {
1412 this.sharedStylesHost.removeHost(this.shadowRoot);
1413 }
1414 /**
1415 * @param {?} parent
1416 * @param {?} newChild
1417 * @return {?}
1418 */
1419 appendChild(parent, newChild) {
1420 return super.appendChild(this.nodeOrShadowRoot(parent), newChild);
1421 }
1422 /**
1423 * @param {?} parent
1424 * @param {?} newChild
1425 * @param {?} refChild
1426 * @return {?}
1427 */
1428 insertBefore(parent, newChild, refChild) {
1429 return super.insertBefore(this.nodeOrShadowRoot(parent), newChild, refChild);
1430 }
1431 /**
1432 * @param {?} parent
1433 * @param {?} oldChild
1434 * @return {?}
1435 */
1436 removeChild(parent, oldChild) {
1437 return super.removeChild(this.nodeOrShadowRoot(parent), oldChild);
1438 }
1439 /**
1440 * @param {?} node
1441 * @return {?}
1442 */
1443 parentNode(node) {
1444 return this.nodeOrShadowRoot(super.parentNode(this.nodeOrShadowRoot(node)));
1445 }
1446}
1447if (false) {
1448 /**
1449 * @type {?}
1450 * @private
1451 */
1452 ShadowDomRenderer.prototype.shadowRoot;
1453 /**
1454 * @type {?}
1455 * @private
1456 */
1457 ShadowDomRenderer.prototype.sharedStylesHost;
1458 /**
1459 * @type {?}
1460 * @private
1461 */
1462 ShadowDomRenderer.prototype.hostEl;
1463 /**
1464 * @type {?}
1465 * @private
1466 */
1467 ShadowDomRenderer.prototype.component;
1468}
1469
1470/**
1471 * @fileoverview added by tsickle
1472 * Generated from: packages/platform-browser/src/dom/events/dom_events.ts
1473 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
1474 */
1475class DomEventsPlugin extends EventManagerPlugin {
1476 /**
1477 * @param {?} doc
1478 */
1479 constructor(doc) {
1480 super(doc);
1481 }
1482 // This plugin should come last in the list of plugins, because it accepts all
1483 // events.
1484 /**
1485 * @param {?} eventName
1486 * @return {?}
1487 */
1488 supports(eventName) {
1489 return true;
1490 }
1491 /**
1492 * @param {?} element
1493 * @param {?} eventName
1494 * @param {?} handler
1495 * @return {?}
1496 */
1497 addEventListener(element, eventName, handler) {
1498 element.addEventListener(eventName, (/** @type {?} */ (handler)), false);
1499 return (/**
1500 * @return {?}
1501 */
1502 () => this.removeEventListener(element, eventName, (/** @type {?} */ (handler))));
1503 }
1504 /**
1505 * @param {?} target
1506 * @param {?} eventName
1507 * @param {?} callback
1508 * @return {?}
1509 */
1510 removeEventListener(target, eventName, callback) {
1511 return target.removeEventListener(eventName, (/** @type {?} */ (callback)));
1512 }
1513}
1514DomEventsPlugin.decorators = [
1515 { type: Injectable }
1516];
1517/** @nocollapse */
1518DomEventsPlugin.ctorParameters = () => [
1519 { type: undefined, decorators: [{ type: Inject, args: [DOCUMENT,] }] }
1520];
1521
1522/**
1523 * @fileoverview added by tsickle
1524 * Generated from: packages/platform-browser/src/dom/events/hammer_gestures.ts
1525 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
1526 */
1527/**
1528 * Supported HammerJS recognizer event names.
1529 * @type {?}
1530 */
1531const EVENT_NAMES = {
1532 // pan
1533 'pan': true,
1534 'panstart': true,
1535 'panmove': true,
1536 'panend': true,
1537 'pancancel': true,
1538 'panleft': true,
1539 'panright': true,
1540 'panup': true,
1541 'pandown': true,
1542 // pinch
1543 'pinch': true,
1544 'pinchstart': true,
1545 'pinchmove': true,
1546 'pinchend': true,
1547 'pinchcancel': true,
1548 'pinchin': true,
1549 'pinchout': true,
1550 // press
1551 'press': true,
1552 'pressup': true,
1553 // rotate
1554 'rotate': true,
1555 'rotatestart': true,
1556 'rotatemove': true,
1557 'rotateend': true,
1558 'rotatecancel': true,
1559 // swipe
1560 'swipe': true,
1561 'swipeleft': true,
1562 'swiperight': true,
1563 'swipeup': true,
1564 'swipedown': true,
1565 // tap
1566 'tap': true,
1567};
1568/**
1569 * DI token for providing [HammerJS](http://hammerjs.github.io/) support to Angular.
1570 * @see `HammerGestureConfig`
1571 *
1572 * \@ngModule HammerModule
1573 * \@publicApi
1574 * @type {?}
1575 */
1576const HAMMER_GESTURE_CONFIG = new InjectionToken('HammerGestureConfig');
1577/**
1578 * Injection token used to provide a {\@link HammerLoader} to Angular.
1579 *
1580 * \@publicApi
1581 * @type {?}
1582 */
1583const HAMMER_LOADER = new InjectionToken('HammerLoader');
1584/**
1585 * @record
1586 */
1587function HammerInstance() { }
1588if (false) {
1589 /**
1590 * @param {?} eventName
1591 * @param {?=} callback
1592 * @return {?}
1593 */
1594 HammerInstance.prototype.on = function (eventName, callback) { };
1595 /**
1596 * @param {?} eventName
1597 * @param {?=} callback
1598 * @return {?}
1599 */
1600 HammerInstance.prototype.off = function (eventName, callback) { };
1601 /**
1602 * @return {?}
1603 */
1604 HammerInstance.prototype.destroy = function () { };
1605}
1606/**
1607 * An injectable [HammerJS Manager](http://hammerjs.github.io/api/#hammer.manager)
1608 * for gesture recognition. Configures specific event recognition.
1609 * \@publicApi
1610 */
1611class HammerGestureConfig {
1612 constructor() {
1613 /**
1614 * A set of supported event names for gestures to be used in Angular.
1615 * Angular supports all built-in recognizers, as listed in
1616 * [HammerJS documentation](http://hammerjs.github.io/).
1617 */
1618 this.events = [];
1619 /**
1620 * Maps gesture event names to a set of configuration options
1621 * that specify overrides to the default values for specific properties.
1622 *
1623 * The key is a supported event name to be configured,
1624 * and the options object contains a set of properties, with override values
1625 * to be applied to the named recognizer event.
1626 * For example, to disable recognition of the rotate event, specify
1627 * `{"rotate": {"enable": false}}`.
1628 *
1629 * Properties that are not present take the HammerJS default values.
1630 * For information about which properties are supported for which events,
1631 * and their allowed and default values, see
1632 * [HammerJS documentation](http://hammerjs.github.io/).
1633 *
1634 */
1635 this.overrides = {};
1636 }
1637 /**
1638 * Creates a [HammerJS Manager](http://hammerjs.github.io/api/#hammer.manager)
1639 * and attaches it to a given HTML element.
1640 * @param {?} element The element that will recognize gestures.
1641 * @return {?} A HammerJS event-manager object.
1642 */
1643 buildHammer(element) {
1644 /** @type {?} */
1645 const mc = new (/** @type {?} */ (Hammer))(element, this.options);
1646 mc.get('pinch').set({ enable: true });
1647 mc.get('rotate').set({ enable: true });
1648 for (const eventName in this.overrides) {
1649 mc.get(eventName).set(this.overrides[eventName]);
1650 }
1651 return mc;
1652 }
1653}
1654HammerGestureConfig.decorators = [
1655 { type: Injectable }
1656];
1657if (false) {
1658 /**
1659 * A set of supported event names for gestures to be used in Angular.
1660 * Angular supports all built-in recognizers, as listed in
1661 * [HammerJS documentation](http://hammerjs.github.io/).
1662 * @type {?}
1663 */
1664 HammerGestureConfig.prototype.events;
1665 /**
1666 * Maps gesture event names to a set of configuration options
1667 * that specify overrides to the default values for specific properties.
1668 *
1669 * The key is a supported event name to be configured,
1670 * and the options object contains a set of properties, with override values
1671 * to be applied to the named recognizer event.
1672 * For example, to disable recognition of the rotate event, specify
1673 * `{"rotate": {"enable": false}}`.
1674 *
1675 * Properties that are not present take the HammerJS default values.
1676 * For information about which properties are supported for which events,
1677 * and their allowed and default values, see
1678 * [HammerJS documentation](http://hammerjs.github.io/).
1679 *
1680 * @type {?}
1681 */
1682 HammerGestureConfig.prototype.overrides;
1683 /**
1684 * Properties whose default values can be overridden for a given event.
1685 * Different sets of properties apply to different events.
1686 * For information about which properties are supported for which events,
1687 * and their allowed and default values, see
1688 * [HammerJS documentation](http://hammerjs.github.io/).
1689 * @type {?}
1690 */
1691 HammerGestureConfig.prototype.options;
1692}
1693/**
1694 * Event plugin that adds Hammer support to an application.
1695 *
1696 * \@ngModule HammerModule
1697 */
1698class HammerGesturesPlugin extends EventManagerPlugin {
1699 /**
1700 * @param {?} doc
1701 * @param {?} _config
1702 * @param {?} console
1703 * @param {?=} loader
1704 */
1705 constructor(doc, _config, console, loader) {
1706 super(doc);
1707 this._config = _config;
1708 this.console = console;
1709 this.loader = loader;
1710 }
1711 /**
1712 * @param {?} eventName
1713 * @return {?}
1714 */
1715 supports(eventName) {
1716 if (!EVENT_NAMES.hasOwnProperty(eventName.toLowerCase()) && !this.isCustomEvent(eventName)) {
1717 return false;
1718 }
1719 if (!((/** @type {?} */ (window))).Hammer && !this.loader) {
1720 this.console.warn(`The "${eventName}" event cannot be bound because Hammer.JS is not ` +
1721 `loaded and no custom loader has been specified.`);
1722 return false;
1723 }
1724 return true;
1725 }
1726 /**
1727 * @param {?} element
1728 * @param {?} eventName
1729 * @param {?} handler
1730 * @return {?}
1731 */
1732 addEventListener(element, eventName, handler) {
1733 /** @type {?} */
1734 const zone = this.manager.getZone();
1735 eventName = eventName.toLowerCase();
1736 // If Hammer is not present but a loader is specified, we defer adding the event listener
1737 // until Hammer is loaded.
1738 if (!((/** @type {?} */ (window))).Hammer && this.loader) {
1739 // This `addEventListener` method returns a function to remove the added listener.
1740 // Until Hammer is loaded, the returned function needs to *cancel* the registration rather
1741 // than remove anything.
1742 /** @type {?} */
1743 let cancelRegistration = false;
1744 /** @type {?} */
1745 let deregister = (/**
1746 * @return {?}
1747 */
1748 () => {
1749 cancelRegistration = true;
1750 });
1751 this.loader()
1752 .then((/**
1753 * @return {?}
1754 */
1755 () => {
1756 // If Hammer isn't actually loaded when the custom loader resolves, give up.
1757 if (!((/** @type {?} */ (window))).Hammer) {
1758 this.console.warn(`The custom HAMMER_LOADER completed, but Hammer.JS is not present.`);
1759 deregister = (/**
1760 * @return {?}
1761 */
1762 () => { });
1763 return;
1764 }
1765 if (!cancelRegistration) {
1766 // Now that Hammer is loaded and the listener is being loaded for real,
1767 // the deregistration function changes from canceling registration to removal.
1768 deregister = this.addEventListener(element, eventName, handler);
1769 }
1770 }))
1771 .catch((/**
1772 * @return {?}
1773 */
1774 () => {
1775 this.console.warn(`The "${eventName}" event cannot be bound because the custom ` +
1776 `Hammer.JS loader failed.`);
1777 deregister = (/**
1778 * @return {?}
1779 */
1780 () => { });
1781 }));
1782 // Return a function that *executes* `deregister` (and not `deregister` itself) so that we
1783 // can change the behavior of `deregister` once the listener is added. Using a closure in
1784 // this way allows us to avoid any additional data structures to track listener removal.
1785 return (/**
1786 * @return {?}
1787 */
1788 () => {
1789 deregister();
1790 });
1791 }
1792 return zone.runOutsideAngular((/**
1793 * @return {?}
1794 */
1795 () => {
1796 // Creating the manager bind events, must be done outside of angular
1797 /** @type {?} */
1798 const mc = this._config.buildHammer(element);
1799 /** @type {?} */
1800 const callback = (/**
1801 * @param {?} eventObj
1802 * @return {?}
1803 */
1804 function (eventObj) {
1805 zone.runGuarded((/**
1806 * @return {?}
1807 */
1808 function () {
1809 handler(eventObj);
1810 }));
1811 });
1812 mc.on(eventName, callback);
1813 return (/**
1814 * @return {?}
1815 */
1816 () => {
1817 mc.off(eventName, callback);
1818 // destroy mc to prevent memory leak
1819 if (typeof mc.destroy === 'function') {
1820 mc.destroy();
1821 }
1822 });
1823 }));
1824 }
1825 /**
1826 * @param {?} eventName
1827 * @return {?}
1828 */
1829 isCustomEvent(eventName) {
1830 return this._config.events.indexOf(eventName) > -1;
1831 }
1832}
1833HammerGesturesPlugin.decorators = [
1834 { type: Injectable }
1835];
1836/** @nocollapse */
1837HammerGesturesPlugin.ctorParameters = () => [
1838 { type: undefined, decorators: [{ type: Inject, args: [DOCUMENT,] }] },
1839 { type: HammerGestureConfig, decorators: [{ type: Inject, args: [HAMMER_GESTURE_CONFIG,] }] },
1840 { type: ɵConsole },
1841 { type: undefined, decorators: [{ type: Optional }, { type: Inject, args: [HAMMER_LOADER,] }] }
1842];
1843if (false) {
1844 /**
1845 * @type {?}
1846 * @private
1847 */
1848 HammerGesturesPlugin.prototype._config;
1849 /**
1850 * @type {?}
1851 * @private
1852 */
1853 HammerGesturesPlugin.prototype.console;
1854 /**
1855 * @type {?}
1856 * @private
1857 */
1858 HammerGesturesPlugin.prototype.loader;
1859}
1860/**
1861 * In Ivy, support for Hammer gestures is optional, so applications must
1862 * import the `HammerModule` at root to turn on support. This means that
1863 * Hammer-specific code can be tree-shaken away if not needed.
1864 * @type {?}
1865 */
1866const HAMMER_PROVIDERS__POST_R3__ = [];
1867/**
1868 * In View Engine, support for Hammer gestures is built-in by default.
1869 * @type {?}
1870 */
1871const HAMMER_PROVIDERS__PRE_R3__ = [
1872 {
1873 provide: EVENT_MANAGER_PLUGINS,
1874 useClass: HammerGesturesPlugin,
1875 multi: true,
1876 deps: [DOCUMENT, HAMMER_GESTURE_CONFIG, ɵConsole, [new Optional(), HAMMER_LOADER]]
1877 },
1878 { provide: HAMMER_GESTURE_CONFIG, useClass: HammerGestureConfig, deps: [] },
1879];
1880/** @type {?} */
1881const HAMMER_PROVIDERS = HAMMER_PROVIDERS__PRE_R3__;
1882/**
1883 * Adds support for HammerJS.
1884 *
1885 * Import this module at the root of your application so that Angular can work with
1886 * HammerJS to detect gesture events.
1887 *
1888 * Note that applications still need to include the HammerJS script itself. This module
1889 * simply sets up the coordination layer between HammerJS and Angular's EventManager.
1890 *
1891 * \@publicApi
1892 */
1893class HammerModule {
1894}
1895HammerModule.decorators = [
1896 { type: NgModule, args: [{ providers: HAMMER_PROVIDERS__PRE_R3__ },] }
1897];
1898
1899/**
1900 * @fileoverview added by tsickle
1901 * Generated from: packages/platform-browser/src/dom/events/key_events.ts
1902 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
1903 */
1904/**
1905 * Defines supported modifiers for key events.
1906 * @type {?}
1907 */
1908const MODIFIER_KEYS = ['alt', 'control', 'meta', 'shift'];
1909/** @type {?} */
1910const DOM_KEY_LOCATION_NUMPAD = 3;
1911// Map to convert some key or keyIdentifier values to what will be returned by getEventKey
1912/** @type {?} */
1913const _keyMap = {
1914 // The following values are here for cross-browser compatibility and to match the W3C standard
1915 // cf http://www.w3.org/TR/DOM-Level-3-Events-key/
1916 '\b': 'Backspace',
1917 '\t': 'Tab',
1918 '\x7F': 'Delete',
1919 '\x1B': 'Escape',
1920 'Del': 'Delete',
1921 'Esc': 'Escape',
1922 'Left': 'ArrowLeft',
1923 'Right': 'ArrowRight',
1924 'Up': 'ArrowUp',
1925 'Down': 'ArrowDown',
1926 'Menu': 'ContextMenu',
1927 'Scroll': 'ScrollLock',
1928 'Win': 'OS'
1929};
1930// There is a bug in Chrome for numeric keypad keys:
1931// https://code.google.com/p/chromium/issues/detail?id=155654
1932// 1, 2, 3 ... are reported as A, B, C ...
1933/** @type {?} */
1934const _chromeNumKeyPadMap = {
1935 'A': '1',
1936 'B': '2',
1937 'C': '3',
1938 'D': '4',
1939 'E': '5',
1940 'F': '6',
1941 'G': '7',
1942 'H': '8',
1943 'I': '9',
1944 'J': '*',
1945 'K': '+',
1946 'M': '-',
1947 'N': '.',
1948 'O': '/',
1949 '\x60': '0',
1950 '\x90': 'NumLock'
1951};
1952const ɵ0$3 = /**
1953 * @param {?} event
1954 * @return {?}
1955 */
1956(event) => event.altKey, ɵ1 = /**
1957 * @param {?} event
1958 * @return {?}
1959 */
1960(event) => event.ctrlKey, ɵ2 = /**
1961 * @param {?} event
1962 * @return {?}
1963 */
1964(event) => event.metaKey, ɵ3 = /**
1965 * @param {?} event
1966 * @return {?}
1967 */
1968(event) => event.shiftKey;
1969/**
1970 * Retrieves modifiers from key-event objects.
1971 * @type {?}
1972 */
1973const MODIFIER_KEY_GETTERS = {
1974 'alt': (ɵ0$3),
1975 'control': (ɵ1),
1976 'meta': (ɵ2),
1977 'shift': (ɵ3)
1978};
1979/**
1980 * \@publicApi
1981 * A browser plug-in that provides support for handling of key events in Angular.
1982 */
1983class KeyEventsPlugin extends EventManagerPlugin {
1984 /**
1985 * Initializes an instance of the browser plug-in.
1986 * @param {?} doc The document in which key events will be detected.
1987 */
1988 constructor(doc) {
1989 super(doc);
1990 }
1991 /**
1992 * Reports whether a named key event is supported.
1993 * @param {?} eventName The event name to query.
1994 * @return {?} True if the named key event is supported.
1995 */
1996 supports(eventName) {
1997 return KeyEventsPlugin.parseEventName(eventName) != null;
1998 }
1999 /**
2000 * Registers a handler for a specific element and key event.
2001 * @param {?} element The HTML element to receive event notifications.
2002 * @param {?} eventName The name of the key event to listen for.
2003 * @param {?} handler A function to call when the notification occurs. Receives the
2004 * event object as an argument.
2005 * @return {?} The key event that was registered.
2006 */
2007 addEventListener(element, eventName, handler) {
2008 /** @type {?} */
2009 const parsedEvent = (/** @type {?} */ (KeyEventsPlugin.parseEventName(eventName)));
2010 /** @type {?} */
2011 const outsideHandler = KeyEventsPlugin.eventCallback(parsedEvent['fullKey'], handler, this.manager.getZone());
2012 return this.manager.getZone().runOutsideAngular((/**
2013 * @return {?}
2014 */
2015 () => {
2016 return ɵgetDOM().onAndCancel(element, parsedEvent['domEventName'], outsideHandler);
2017 }));
2018 }
2019 /**
2020 * @param {?} eventName
2021 * @return {?}
2022 */
2023 static parseEventName(eventName) {
2024 /** @type {?} */
2025 const parts = eventName.toLowerCase().split('.');
2026 /** @type {?} */
2027 const domEventName = parts.shift();
2028 if ((parts.length === 0) || !(domEventName === 'keydown' || domEventName === 'keyup')) {
2029 return null;
2030 }
2031 /** @type {?} */
2032 const key = KeyEventsPlugin._normalizeKey((/** @type {?} */ (parts.pop())));
2033 /** @type {?} */
2034 let fullKey = '';
2035 MODIFIER_KEYS.forEach((/**
2036 * @param {?} modifierName
2037 * @return {?}
2038 */
2039 modifierName => {
2040 /** @type {?} */
2041 const index = parts.indexOf(modifierName);
2042 if (index > -1) {
2043 parts.splice(index, 1);
2044 fullKey += modifierName + '.';
2045 }
2046 }));
2047 fullKey += key;
2048 if (parts.length != 0 || key.length === 0) {
2049 // returning null instead of throwing to let another plugin process the event
2050 return null;
2051 }
2052 /** @type {?} */
2053 const result = {};
2054 result['domEventName'] = domEventName;
2055 result['fullKey'] = fullKey;
2056 return result;
2057 }
2058 /**
2059 * @param {?} event
2060 * @return {?}
2061 */
2062 static getEventFullKey(event) {
2063 /** @type {?} */
2064 let fullKey = '';
2065 /** @type {?} */
2066 let key = getEventKey(event);
2067 key = key.toLowerCase();
2068 if (key === ' ') {
2069 key = 'space'; // for readability
2070 }
2071 else if (key === '.') {
2072 key = 'dot'; // because '.' is used as a separator in event names
2073 }
2074 MODIFIER_KEYS.forEach((/**
2075 * @param {?} modifierName
2076 * @return {?}
2077 */
2078 modifierName => {
2079 if (modifierName != key) {
2080 /** @type {?} */
2081 const modifierGetter = MODIFIER_KEY_GETTERS[modifierName];
2082 if (modifierGetter(event)) {
2083 fullKey += modifierName + '.';
2084 }
2085 }
2086 }));
2087 fullKey += key;
2088 return fullKey;
2089 }
2090 /**
2091 * Configures a handler callback for a key event.
2092 * @param {?} fullKey The event name that combines all simultaneous keystrokes.
2093 * @param {?} handler The function that responds to the key event.
2094 * @param {?} zone The zone in which the event occurred.
2095 * @return {?} A callback function.
2096 */
2097 static eventCallback(fullKey, handler, zone) {
2098 return (/**
2099 * @param {?} event
2100 * @return {?}
2101 */
2102 (event /** TODO #9100 */) => {
2103 if (KeyEventsPlugin.getEventFullKey(event) === fullKey) {
2104 zone.runGuarded((/**
2105 * @return {?}
2106 */
2107 () => handler(event)));
2108 }
2109 });
2110 }
2111 /**
2112 * \@internal
2113 * @param {?} keyName
2114 * @return {?}
2115 */
2116 static _normalizeKey(keyName) {
2117 // TODO: switch to a Map if the mapping grows too much
2118 switch (keyName) {
2119 case 'esc':
2120 return 'escape';
2121 default:
2122 return keyName;
2123 }
2124 }
2125}
2126KeyEventsPlugin.decorators = [
2127 { type: Injectable }
2128];
2129/** @nocollapse */
2130KeyEventsPlugin.ctorParameters = () => [
2131 { type: undefined, decorators: [{ type: Inject, args: [DOCUMENT,] }] }
2132];
2133/**
2134 * @param {?} event
2135 * @return {?}
2136 */
2137function getEventKey(event) {
2138 /** @type {?} */
2139 let key = event.key;
2140 if (key == null) {
2141 key = event.keyIdentifier;
2142 // keyIdentifier is defined in the old draft of DOM Level 3 Events implemented by Chrome and
2143 // Safari cf
2144 // http://www.w3.org/TR/2007/WD-DOM-Level-3-Events-20071221/events.html#Events-KeyboardEvents-Interfaces
2145 if (key == null) {
2146 return 'Unidentified';
2147 }
2148 if (key.startsWith('U+')) {
2149 key = String.fromCharCode(parseInt(key.substring(2), 16));
2150 if (event.location === DOM_KEY_LOCATION_NUMPAD && _chromeNumKeyPadMap.hasOwnProperty(key)) {
2151 // There is a bug in Chrome for numeric keypad keys:
2152 // https://code.google.com/p/chromium/issues/detail?id=155654
2153 // 1, 2, 3 ... are reported as A, B, C ...
2154 key = ((/** @type {?} */ (_chromeNumKeyPadMap)))[key];
2155 }
2156 }
2157 }
2158 return _keyMap[key] || key;
2159}
2160
2161/**
2162 * @fileoverview added by tsickle
2163 * Generated from: packages/platform-browser/src/security/dom_sanitization_service.ts
2164 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
2165 */
2166/**
2167 * Marker interface for a value that's safe to use in a particular context.
2168 *
2169 * \@publicApi
2170 * @record
2171 */
2172function SafeValue() { }
2173/**
2174 * Marker interface for a value that's safe to use as HTML.
2175 *
2176 * \@publicApi
2177 * @record
2178 */
2179function SafeHtml() { }
2180/**
2181 * Marker interface for a value that's safe to use as style (CSS).
2182 *
2183 * \@publicApi
2184 * @record
2185 */
2186function SafeStyle() { }
2187/**
2188 * Marker interface for a value that's safe to use as JavaScript.
2189 *
2190 * \@publicApi
2191 * @record
2192 */
2193function SafeScript() { }
2194/**
2195 * Marker interface for a value that's safe to use as a URL linking to a document.
2196 *
2197 * \@publicApi
2198 * @record
2199 */
2200function SafeUrl() { }
2201/**
2202 * Marker interface for a value that's safe to use as a URL to load executable code from.
2203 *
2204 * \@publicApi
2205 * @record
2206 */
2207function SafeResourceUrl() { }
2208/**
2209 * DomSanitizer helps preventing Cross Site Scripting Security bugs (XSS) by sanitizing
2210 * values to be safe to use in the different DOM contexts.
2211 *
2212 * For example, when binding a URL in an `<a [href]="someValue">` hyperlink, `someValue` will be
2213 * sanitized so that an attacker cannot inject e.g. a `javascript:` URL that would execute code on
2214 * the website.
2215 *
2216 * In specific situations, it might be necessary to disable sanitization, for example if the
2217 * application genuinely needs to produce a `javascript:` style link with a dynamic value in it.
2218 * Users can bypass security by constructing a value with one of the `bypassSecurityTrust...`
2219 * methods, and then binding to that value from the template.
2220 *
2221 * These situations should be very rare, and extraordinary care must be taken to avoid creating a
2222 * Cross Site Scripting (XSS) security bug!
2223 *
2224 * When using `bypassSecurityTrust...`, make sure to call the method as early as possible and as
2225 * close as possible to the source of the value, to make it easy to verify no security bug is
2226 * created by its use.
2227 *
2228 * It is not required (and not recommended) to bypass security if the value is safe, e.g. a URL that
2229 * does not start with a suspicious protocol, or an HTML snippet that does not contain dangerous
2230 * code. The sanitizer leaves safe values intact.
2231 *
2232 * \@security Calling any of the `bypassSecurityTrust...` APIs disables Angular's built-in
2233 * sanitization for the value passed in. Carefully check and audit all values and code paths going
2234 * into this call. Make sure any user data is appropriately escaped for this security context.
2235 * For more detail, see the [Security Guide](http://g.co/ng/security).
2236 *
2237 * \@publicApi
2238 * @abstract
2239 */
2240class DomSanitizer {
2241}
2242DomSanitizer.decorators = [
2243 { type: Injectable, args: [{ providedIn: 'root', useExisting: forwardRef((/**
2244 * @return {?}
2245 */
2246 () => DomSanitizerImpl)) },] }
2247];
2248/** @nocollapse */ DomSanitizer.ɵprov = ɵɵdefineInjectable({ factory: function DomSanitizer_Factory() { return ɵɵinject(DomSanitizerImpl); }, token: DomSanitizer, providedIn: "root" });
2249if (false) {
2250 /**
2251 * Sanitizes a value for use in the given SecurityContext.
2252 *
2253 * If value is trusted for the context, this method will unwrap the contained safe value and use
2254 * it directly. Otherwise, value will be sanitized to be safe in the given context, for example
2255 * by replacing URLs that have an unsafe protocol part (such as `javascript:`). The implementation
2256 * is responsible to make sure that the value can definitely be safely used in the given context.
2257 * @abstract
2258 * @param {?} context
2259 * @param {?} value
2260 * @return {?}
2261 */
2262 DomSanitizer.prototype.sanitize = function (context, value) { };
2263 /**
2264 * Bypass security and trust the given value to be safe HTML. Only use this when the bound HTML
2265 * is unsafe (e.g. contains `<script>` tags) and the code should be executed. The sanitizer will
2266 * leave safe HTML intact, so in most situations this method should not be used.
2267 *
2268 * **WARNING:** calling this method with untrusted user data exposes your application to XSS
2269 * security risks!
2270 * @abstract
2271 * @param {?} value
2272 * @return {?}
2273 */
2274 DomSanitizer.prototype.bypassSecurityTrustHtml = function (value) { };
2275 /**
2276 * Bypass security and trust the given value to be safe style value (CSS).
2277 *
2278 * **WARNING:** calling this method with untrusted user data exposes your application to XSS
2279 * security risks!
2280 * @abstract
2281 * @param {?} value
2282 * @return {?}
2283 */
2284 DomSanitizer.prototype.bypassSecurityTrustStyle = function (value) { };
2285 /**
2286 * Bypass security and trust the given value to be safe JavaScript.
2287 *
2288 * **WARNING:** calling this method with untrusted user data exposes your application to XSS
2289 * security risks!
2290 * @abstract
2291 * @param {?} value
2292 * @return {?}
2293 */
2294 DomSanitizer.prototype.bypassSecurityTrustScript = function (value) { };
2295 /**
2296 * Bypass security and trust the given value to be a safe style URL, i.e. a value that can be used
2297 * in hyperlinks or `<img src>`.
2298 *
2299 * **WARNING:** calling this method with untrusted user data exposes your application to XSS
2300 * security risks!
2301 * @abstract
2302 * @param {?} value
2303 * @return {?}
2304 */
2305 DomSanitizer.prototype.bypassSecurityTrustUrl = function (value) { };
2306 /**
2307 * Bypass security and trust the given value to be a safe resource URL, i.e. a location that may
2308 * be used to load executable code from, like `<script src>`, or `<iframe src>`.
2309 *
2310 * **WARNING:** calling this method with untrusted user data exposes your application to XSS
2311 * security risks!
2312 * @abstract
2313 * @param {?} value
2314 * @return {?}
2315 */
2316 DomSanitizer.prototype.bypassSecurityTrustResourceUrl = function (value) { };
2317}
2318/**
2319 * @param {?} injector
2320 * @return {?}
2321 */
2322function domSanitizerImplFactory(injector) {
2323 return new DomSanitizerImpl(injector.get(DOCUMENT));
2324}
2325class DomSanitizerImpl extends DomSanitizer {
2326 /**
2327 * @param {?} _doc
2328 */
2329 constructor(_doc) {
2330 super();
2331 this._doc = _doc;
2332 }
2333 /**
2334 * @param {?} ctx
2335 * @param {?} value
2336 * @return {?}
2337 */
2338 sanitize(ctx, value) {
2339 if (value == null)
2340 return null;
2341 switch (ctx) {
2342 case SecurityContext.NONE:
2343 return (/** @type {?} */ (value));
2344 case SecurityContext.HTML:
2345 if (ɵallowSanitizationBypassAndThrow(value, "HTML" /* Html */)) {
2346 return ɵunwrapSafeValue(value);
2347 }
2348 return ɵ_sanitizeHtml(this._doc, String(value));
2349 case SecurityContext.STYLE:
2350 if (ɵallowSanitizationBypassAndThrow(value, "Style" /* Style */)) {
2351 return ɵunwrapSafeValue(value);
2352 }
2353 return ɵ_sanitizeStyle((/** @type {?} */ (value)));
2354 case SecurityContext.SCRIPT:
2355 if (ɵallowSanitizationBypassAndThrow(value, "Script" /* Script */)) {
2356 return ɵunwrapSafeValue(value);
2357 }
2358 throw new Error('unsafe value used in a script context');
2359 case SecurityContext.URL:
2360 /** @type {?} */
2361 const type = ɵgetSanitizationBypassType(value);
2362 if (ɵallowSanitizationBypassAndThrow(value, "URL" /* Url */)) {
2363 return ɵunwrapSafeValue(value);
2364 }
2365 return ɵ_sanitizeUrl(String(value));
2366 case SecurityContext.RESOURCE_URL:
2367 if (ɵallowSanitizationBypassAndThrow(value, "ResourceURL" /* ResourceUrl */)) {
2368 return ɵunwrapSafeValue(value);
2369 }
2370 throw new Error('unsafe value used in a resource URL context (see http://g.co/ng/security#xss)');
2371 default:
2372 throw new Error(`Unexpected SecurityContext ${ctx} (see http://g.co/ng/security#xss)`);
2373 }
2374 }
2375 /**
2376 * @param {?} value
2377 * @return {?}
2378 */
2379 bypassSecurityTrustHtml(value) {
2380 return ɵbypassSanitizationTrustHtml(value);
2381 }
2382 /**
2383 * @param {?} value
2384 * @return {?}
2385 */
2386 bypassSecurityTrustStyle(value) {
2387 return ɵbypassSanitizationTrustStyle(value);
2388 }
2389 /**
2390 * @param {?} value
2391 * @return {?}
2392 */
2393 bypassSecurityTrustScript(value) {
2394 return ɵbypassSanitizationTrustScript(value);
2395 }
2396 /**
2397 * @param {?} value
2398 * @return {?}
2399 */
2400 bypassSecurityTrustUrl(value) {
2401 return ɵbypassSanitizationTrustUrl(value);
2402 }
2403 /**
2404 * @param {?} value
2405 * @return {?}
2406 */
2407 bypassSecurityTrustResourceUrl(value) {
2408 return ɵbypassSanitizationTrustResourceUrl(value);
2409 }
2410}
2411DomSanitizerImpl.decorators = [
2412 { type: Injectable, args: [{ providedIn: 'root', useFactory: domSanitizerImplFactory, deps: [Injector] },] }
2413];
2414/** @nocollapse */
2415DomSanitizerImpl.ctorParameters = () => [
2416 { type: undefined, decorators: [{ type: Inject, args: [DOCUMENT,] }] }
2417];
2418/** @nocollapse */ DomSanitizerImpl.ɵprov = ɵɵdefineInjectable({ factory: function DomSanitizerImpl_Factory() { return domSanitizerImplFactory(ɵɵinject(INJECTOR)); }, token: DomSanitizerImpl, providedIn: "root" });
2419if (false) {
2420 /**
2421 * @type {?}
2422 * @private
2423 */
2424 DomSanitizerImpl.prototype._doc;
2425}
2426
2427/**
2428 * @fileoverview added by tsickle
2429 * Generated from: packages/platform-browser/src/browser.ts
2430 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
2431 */
2432/**
2433 * @return {?}
2434 */
2435function initDomAdapter() {
2436 BrowserDomAdapter.makeCurrent();
2437 BrowserGetTestability.init();
2438}
2439/**
2440 * @return {?}
2441 */
2442function errorHandler() {
2443 return new ErrorHandler();
2444}
2445/**
2446 * @return {?}
2447 */
2448function _document() {
2449 // Tell ivy about the global document
2450 ɵsetDocument(document);
2451 return document;
2452}
2453const ɵ0$4 = ɵPLATFORM_BROWSER_ID;
2454/** @type {?} */
2455const INTERNAL_BROWSER_PLATFORM_PROVIDERS = [
2456 { provide: PLATFORM_ID, useValue: ɵ0$4 },
2457 { provide: PLATFORM_INITIALIZER, useValue: initDomAdapter, multi: true },
2458 { provide: DOCUMENT, useFactory: _document, deps: [] },
2459];
2460/** @type {?} */
2461const BROWSER_SANITIZATION_PROVIDERS__PRE_R3__ = [
2462 { provide: Sanitizer, useExisting: DomSanitizer },
2463 { provide: DomSanitizer, useClass: DomSanitizerImpl, deps: [DOCUMENT] },
2464];
2465/** @type {?} */
2466const BROWSER_SANITIZATION_PROVIDERS__POST_R3__ = [];
2467/**
2468 * \@security Replacing built-in sanitization providers exposes the application to XSS risks.
2469 * Attacker-controlled data introduced by an unsanitized provider could expose your
2470 * application to XSS risks. For more detail, see the [Security Guide](http://g.co/ng/security).
2471 * \@publicApi
2472 * @type {?}
2473 */
2474const BROWSER_SANITIZATION_PROVIDERS = BROWSER_SANITIZATION_PROVIDERS__PRE_R3__;
2475/**
2476 * \@publicApi
2477 * @type {?}
2478 */
2479const platformBrowser = createPlatformFactory(platformCore, 'browser', INTERNAL_BROWSER_PLATFORM_PROVIDERS);
2480/** @type {?} */
2481const BROWSER_MODULE_PROVIDERS = [
2482 BROWSER_SANITIZATION_PROVIDERS,
2483 { provide: ɵINJECTOR_SCOPE, useValue: 'root' },
2484 { provide: ErrorHandler, useFactory: errorHandler, deps: [] },
2485 {
2486 provide: EVENT_MANAGER_PLUGINS,
2487 useClass: DomEventsPlugin,
2488 multi: true,
2489 deps: [DOCUMENT, NgZone, PLATFORM_ID]
2490 },
2491 { provide: EVENT_MANAGER_PLUGINS, useClass: KeyEventsPlugin, multi: true, deps: [DOCUMENT] },
2492 HAMMER_PROVIDERS,
2493 {
2494 provide: DomRendererFactory2,
2495 useClass: DomRendererFactory2,
2496 deps: [EventManager, DomSharedStylesHost, APP_ID]
2497 },
2498 { provide: RendererFactory2, useExisting: DomRendererFactory2 },
2499 { provide: SharedStylesHost, useExisting: DomSharedStylesHost },
2500 { provide: DomSharedStylesHost, useClass: DomSharedStylesHost, deps: [DOCUMENT] },
2501 { provide: Testability, useClass: Testability, deps: [NgZone] },
2502 { provide: EventManager, useClass: EventManager, deps: [EVENT_MANAGER_PLUGINS, NgZone] },
2503 ELEMENT_PROBE_PROVIDERS,
2504];
2505/**
2506 * Exports required infrastructure for all Angular apps.
2507 * Included by default in all Angular apps created with the CLI
2508 * `new` command.
2509 * Re-exports `CommonModule` and `ApplicationModule`, making their
2510 * exports and providers available to all apps.
2511 *
2512 * \@publicApi
2513 */
2514class BrowserModule {
2515 /**
2516 * @param {?} parentModule
2517 */
2518 constructor(parentModule) {
2519 if (parentModule) {
2520 throw new Error(`BrowserModule has already been loaded. If you need access to common directives such as NgIf and NgFor from a lazy loaded module, import CommonModule instead.`);
2521 }
2522 }
2523 /**
2524 * Configures a browser-based app to transition from a server-rendered app, if
2525 * one is present on the page.
2526 *
2527 * @param {?} params An object containing an identifier for the app to transition.
2528 * The ID must match between the client and server versions of the app.
2529 * @return {?} The reconfigured `BrowserModule` to import into the app's root `AppModule`.
2530 */
2531 static withServerTransition(params) {
2532 return {
2533 ngModule: BrowserModule,
2534 providers: [
2535 { provide: APP_ID, useValue: params.appId },
2536 { provide: TRANSITION_ID, useExisting: APP_ID },
2537 SERVER_TRANSITION_PROVIDERS,
2538 ],
2539 };
2540 }
2541}
2542BrowserModule.decorators = [
2543 { type: NgModule, args: [{ providers: BROWSER_MODULE_PROVIDERS, exports: [CommonModule, ApplicationModule] },] }
2544];
2545/** @nocollapse */
2546BrowserModule.ctorParameters = () => [
2547 { type: undefined, decorators: [{ type: Optional }, { type: SkipSelf }, { type: Inject, args: [BrowserModule,] }] }
2548];
2549
2550/**
2551 * @fileoverview added by tsickle
2552 * Generated from: packages/platform-browser/src/browser/meta.ts
2553 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
2554 */
2555/**
2556 * Factory to create Meta service.
2557 * @return {?}
2558 */
2559function createMeta() {
2560 return new Meta(ɵɵinject(DOCUMENT));
2561}
2562/**
2563 * A service that can be used to get and add meta tags.
2564 *
2565 * \@publicApi
2566 */
2567class Meta {
2568 /**
2569 * @param {?} _doc
2570 */
2571 constructor(_doc) {
2572 this._doc = _doc;
2573 this._dom = ɵgetDOM();
2574 }
2575 /**
2576 * @param {?} tag
2577 * @param {?=} forceCreation
2578 * @return {?}
2579 */
2580 addTag(tag, forceCreation = false) {
2581 if (!tag)
2582 return null;
2583 return this._getOrCreateElement(tag, forceCreation);
2584 }
2585 /**
2586 * @param {?} tags
2587 * @param {?=} forceCreation
2588 * @return {?}
2589 */
2590 addTags(tags, forceCreation = false) {
2591 if (!tags)
2592 return [];
2593 return tags.reduce((/**
2594 * @param {?} result
2595 * @param {?} tag
2596 * @return {?}
2597 */
2598 (result, tag) => {
2599 if (tag) {
2600 result.push(this._getOrCreateElement(tag, forceCreation));
2601 }
2602 return result;
2603 }), []);
2604 }
2605 /**
2606 * @param {?} attrSelector
2607 * @return {?}
2608 */
2609 getTag(attrSelector) {
2610 if (!attrSelector)
2611 return null;
2612 return this._doc.querySelector(`meta[${attrSelector}]`) || null;
2613 }
2614 /**
2615 * @param {?} attrSelector
2616 * @return {?}
2617 */
2618 getTags(attrSelector) {
2619 if (!attrSelector)
2620 return [];
2621 /** @type {?} */
2622 const list /*NodeList*/ = this._doc.querySelectorAll(`meta[${attrSelector}]`);
2623 return list ? [].slice.call(list) : [];
2624 }
2625 /**
2626 * @param {?} tag
2627 * @param {?=} selector
2628 * @return {?}
2629 */
2630 updateTag(tag, selector) {
2631 if (!tag)
2632 return null;
2633 selector = selector || this._parseSelector(tag);
2634 /** @type {?} */
2635 const meta = (/** @type {?} */ (this.getTag(selector)));
2636 if (meta) {
2637 return this._setMetaElementAttributes(tag, meta);
2638 }
2639 return this._getOrCreateElement(tag, true);
2640 }
2641 /**
2642 * @param {?} attrSelector
2643 * @return {?}
2644 */
2645 removeTag(attrSelector) {
2646 this.removeTagElement((/** @type {?} */ (this.getTag(attrSelector))));
2647 }
2648 /**
2649 * @param {?} meta
2650 * @return {?}
2651 */
2652 removeTagElement(meta) {
2653 if (meta) {
2654 this._dom.remove(meta);
2655 }
2656 }
2657 /**
2658 * @private
2659 * @param {?} meta
2660 * @param {?=} forceCreation
2661 * @return {?}
2662 */
2663 _getOrCreateElement(meta, forceCreation = false) {
2664 if (!forceCreation) {
2665 /** @type {?} */
2666 const selector = this._parseSelector(meta);
2667 /** @type {?} */
2668 const elem = (/** @type {?} */ (this.getTag(selector)));
2669 // It's allowed to have multiple elements with the same name so it's not enough to
2670 // just check that element with the same name already present on the page. We also need to
2671 // check if element has tag attributes
2672 if (elem && this._containsAttributes(meta, elem))
2673 return elem;
2674 }
2675 /** @type {?} */
2676 const element = (/** @type {?} */ (this._dom.createElement('meta')));
2677 this._setMetaElementAttributes(meta, element);
2678 /** @type {?} */
2679 const head = this._doc.getElementsByTagName('head')[0];
2680 head.appendChild(element);
2681 return element;
2682 }
2683 /**
2684 * @private
2685 * @param {?} tag
2686 * @param {?} el
2687 * @return {?}
2688 */
2689 _setMetaElementAttributes(tag, el) {
2690 Object.keys(tag).forEach((/**
2691 * @param {?} prop
2692 * @return {?}
2693 */
2694 (prop) => el.setAttribute(prop, tag[prop])));
2695 return el;
2696 }
2697 /**
2698 * @private
2699 * @param {?} tag
2700 * @return {?}
2701 */
2702 _parseSelector(tag) {
2703 /** @type {?} */
2704 const attr = tag.name ? 'name' : 'property';
2705 return `${attr}="${tag[attr]}"`;
2706 }
2707 /**
2708 * @private
2709 * @param {?} tag
2710 * @param {?} elem
2711 * @return {?}
2712 */
2713 _containsAttributes(tag, elem) {
2714 return Object.keys(tag).every((/**
2715 * @param {?} key
2716 * @return {?}
2717 */
2718 (key) => elem.getAttribute(key) === tag[key]));
2719 }
2720}
2721Meta.decorators = [
2722 { type: Injectable, args: [{ providedIn: 'root', useFactory: createMeta, deps: [] },] }
2723];
2724/** @nocollapse */
2725Meta.ctorParameters = () => [
2726 { type: undefined, decorators: [{ type: Inject, args: [DOCUMENT,] }] }
2727];
2728/** @nocollapse */ Meta.ɵprov = ɵɵdefineInjectable({ factory: createMeta, token: Meta, providedIn: "root" });
2729if (false) {
2730 /**
2731 * @type {?}
2732 * @private
2733 */
2734 Meta.prototype._dom;
2735 /**
2736 * @type {?}
2737 * @private
2738 */
2739 Meta.prototype._doc;
2740}
2741
2742/**
2743 * @fileoverview added by tsickle
2744 * Generated from: packages/platform-browser/src/browser/title.ts
2745 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
2746 */
2747/**
2748 * Factory to create Title service.
2749 * @return {?}
2750 */
2751function createTitle() {
2752 return new Title(ɵɵinject(DOCUMENT));
2753}
2754/**
2755 * A service that can be used to get and set the title of a current HTML document.
2756 *
2757 * Since an Angular application can't be bootstrapped on the entire HTML document (`<html>` tag)
2758 * it is not possible to bind to the `text` property of the `HTMLTitleElement` elements
2759 * (representing the `<title>` tag). Instead, this service can be used to set and get the current
2760 * title value.
2761 *
2762 * \@publicApi
2763 */
2764class Title {
2765 /**
2766 * @param {?} _doc
2767 */
2768 constructor(_doc) {
2769 this._doc = _doc;
2770 }
2771 /**
2772 * Get the title of the current HTML document.
2773 * @return {?}
2774 */
2775 getTitle() {
2776 return this._doc.title;
2777 }
2778 /**
2779 * Set the title of the current HTML document.
2780 * @param {?} newTitle
2781 * @return {?}
2782 */
2783 setTitle(newTitle) {
2784 this._doc.title = newTitle || '';
2785 }
2786}
2787Title.decorators = [
2788 { type: Injectable, args: [{ providedIn: 'root', useFactory: createTitle, deps: [] },] }
2789];
2790/** @nocollapse */
2791Title.ctorParameters = () => [
2792 { type: undefined, decorators: [{ type: Inject, args: [DOCUMENT,] }] }
2793];
2794/** @nocollapse */ Title.ɵprov = ɵɵdefineInjectable({ factory: createTitle, token: Title, providedIn: "root" });
2795if (false) {
2796 /**
2797 * @type {?}
2798 * @private
2799 */
2800 Title.prototype._doc;
2801}
2802
2803/**
2804 * @fileoverview added by tsickle
2805 * Generated from: packages/platform-browser/src/browser/tools/browser.ts
2806 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
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/** @type {?} */
2816const win = typeof window !== 'undefined' && window || (/** @type {?} */ ({}));
2817
2818/**
2819 * @fileoverview added by tsickle
2820 * Generated from: packages/platform-browser/src/browser/tools/common_tools.ts
2821 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
2822 */
2823class ChangeDetectionPerfRecord {
2824 /**
2825 * @param {?} msPerTick
2826 * @param {?} numTicks
2827 */
2828 constructor(msPerTick, numTicks) {
2829 this.msPerTick = msPerTick;
2830 this.numTicks = numTicks;
2831 }
2832}
2833if (false) {
2834 /** @type {?} */
2835 ChangeDetectionPerfRecord.prototype.msPerTick;
2836 /** @type {?} */
2837 ChangeDetectionPerfRecord.prototype.numTicks;
2838}
2839/**
2840 * Entry point for all Angular profiling-related debug tools. This object
2841 * corresponds to the `ng.profiler` in the dev console.
2842 */
2843class AngularProfiler {
2844 /**
2845 * @param {?} ref
2846 */
2847 constructor(ref) {
2848 this.appRef = ref.injector.get(ApplicationRef);
2849 }
2850 // tslint:disable:no-console
2851 /**
2852 * Exercises change detection in a loop and then prints the average amount of
2853 * time in milliseconds how long a single round of change detection takes for
2854 * the current state of the UI. It runs a minimum of 5 rounds for a minimum
2855 * of 500 milliseconds.
2856 *
2857 * Optionally, a user may pass a `config` parameter containing a map of
2858 * options. Supported options are:
2859 *
2860 * `record` (boolean) - causes the profiler to record a CPU profile while
2861 * it exercises the change detector. Example:
2862 *
2863 * ```
2864 * ng.profiler.timeChangeDetection({record: true})
2865 * ```
2866 * @param {?} config
2867 * @return {?}
2868 */
2869 timeChangeDetection(config) {
2870 /** @type {?} */
2871 const record = config && config['record'];
2872 /** @type {?} */
2873 const profileName = 'Change Detection';
2874 // Profiler is not available in Android browsers, nor in IE 9 without dev tools opened
2875 /** @type {?} */
2876 const isProfilerAvailable = win.console.profile != null;
2877 if (record && isProfilerAvailable) {
2878 win.console.profile(profileName);
2879 }
2880 /** @type {?} */
2881 const start = ɵgetDOM().performanceNow();
2882 /** @type {?} */
2883 let numTicks = 0;
2884 while (numTicks < 5 || (ɵgetDOM().performanceNow() - start) < 500) {
2885 this.appRef.tick();
2886 numTicks++;
2887 }
2888 /** @type {?} */
2889 const end = ɵgetDOM().performanceNow();
2890 if (record && isProfilerAvailable) {
2891 win.console.profileEnd(profileName);
2892 }
2893 /** @type {?} */
2894 const msPerTick = (end - start) / numTicks;
2895 win.console.log(`ran ${numTicks} change detection cycles`);
2896 win.console.log(`${msPerTick.toFixed(2)} ms per check`);
2897 return new ChangeDetectionPerfRecord(msPerTick, numTicks);
2898 }
2899}
2900if (false) {
2901 /** @type {?} */
2902 AngularProfiler.prototype.appRef;
2903}
2904
2905/**
2906 * @fileoverview added by tsickle
2907 * Generated from: packages/platform-browser/src/browser/tools/tools.ts
2908 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
2909 */
2910/** @type {?} */
2911const PROFILER_GLOBAL_NAME = 'profiler';
2912/**
2913 * Enabled Angular debug tools that are accessible via your browser's
2914 * developer console.
2915 *
2916 * Usage:
2917 *
2918 * 1. Open developer console (e.g. in Chrome Ctrl + Shift + j)
2919 * 1. Type `ng.` (usually the console will show auto-complete suggestion)
2920 * 1. Try the change detection profiler `ng.profiler.timeChangeDetection()`
2921 * then hit Enter.
2922 *
2923 * \@publicApi
2924 * @template T
2925 * @param {?} ref
2926 * @return {?}
2927 */
2928function enableDebugTools(ref) {
2929 exportNgVar(PROFILER_GLOBAL_NAME, new AngularProfiler(ref));
2930 return ref;
2931}
2932/**
2933 * Disables Angular tools.
2934 *
2935 * \@publicApi
2936 * @return {?}
2937 */
2938function disableDebugTools() {
2939 exportNgVar(PROFILER_GLOBAL_NAME, null);
2940}
2941
2942/**
2943 * @fileoverview added by tsickle
2944 * Generated from: packages/platform-browser/src/browser/transfer_state.ts
2945 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
2946 */
2947/**
2948 * @param {?} text
2949 * @return {?}
2950 */
2951function escapeHtml(text) {
2952 /** @type {?} */
2953 const escapedText = {
2954 '&': '&a;',
2955 '"': '&q;',
2956 '\'': '&s;',
2957 '<': '&l;',
2958 '>': '&g;',
2959 };
2960 return text.replace(/[&"'<>]/g, (/**
2961 * @param {?} s
2962 * @return {?}
2963 */
2964 s => escapedText[s]));
2965}
2966/**
2967 * @param {?} text
2968 * @return {?}
2969 */
2970function unescapeHtml(text) {
2971 /** @type {?} */
2972 const unescapedText = {
2973 '&a;': '&',
2974 '&q;': '"',
2975 '&s;': '\'',
2976 '&l;': '<',
2977 '&g;': '>',
2978 };
2979 return text.replace(/&[^;]+;/g, (/**
2980 * @param {?} s
2981 * @return {?}
2982 */
2983 s => unescapedText[s]));
2984}
2985/**
2986 * Create a `StateKey<T>` that can be used to store value of type T with `TransferState`.
2987 *
2988 * Example:
2989 *
2990 * ```
2991 * const COUNTER_KEY = makeStateKey<number>('counter');
2992 * let value = 10;
2993 *
2994 * transferState.set(COUNTER_KEY, value);
2995 * ```
2996 *
2997 * \@publicApi
2998 * @template T
2999 * @param {?} key
3000 * @return {?}
3001 */
3002function makeStateKey(key) {
3003 return (/** @type {?} */ (key));
3004}
3005/**
3006 * A key value store that is transferred from the application on the server side to the application
3007 * on the client side.
3008 *
3009 * `TransferState` will be available as an injectable token. To use it import
3010 * `ServerTransferStateModule` on the server and `BrowserTransferStateModule` on the client.
3011 *
3012 * The values in the store are serialized/deserialized using JSON.stringify/JSON.parse. So only
3013 * boolean, number, string, null and non-class objects will be serialized and deserialzied in a
3014 * non-lossy manner.
3015 *
3016 * \@publicApi
3017 */
3018class TransferState {
3019 constructor() {
3020 this.store = {};
3021 this.onSerializeCallbacks = {};
3022 }
3023 /**
3024 * \@internal
3025 * @param {?} initState
3026 * @return {?}
3027 */
3028 static init(initState) {
3029 /** @type {?} */
3030 const transferState = new TransferState();
3031 transferState.store = initState;
3032 return transferState;
3033 }
3034 /**
3035 * Get the value corresponding to a key. Return `defaultValue` if key is not found.
3036 * @template T
3037 * @param {?} key
3038 * @param {?} defaultValue
3039 * @return {?}
3040 */
3041 get(key, defaultValue) {
3042 return this.store[key] !== undefined ? (/** @type {?} */ (this.store[key])) : defaultValue;
3043 }
3044 /**
3045 * Set the value corresponding to a key.
3046 * @template T
3047 * @param {?} key
3048 * @param {?} value
3049 * @return {?}
3050 */
3051 set(key, value) {
3052 this.store[key] = value;
3053 }
3054 /**
3055 * Remove a key from the store.
3056 * @template T
3057 * @param {?} key
3058 * @return {?}
3059 */
3060 remove(key) {
3061 delete this.store[key];
3062 }
3063 /**
3064 * Test whether a key exists in the store.
3065 * @template T
3066 * @param {?} key
3067 * @return {?}
3068 */
3069 hasKey(key) {
3070 return this.store.hasOwnProperty(key);
3071 }
3072 /**
3073 * Register a callback to provide the value for a key when `toJson` is called.
3074 * @template T
3075 * @param {?} key
3076 * @param {?} callback
3077 * @return {?}
3078 */
3079 onSerialize(key, callback) {
3080 this.onSerializeCallbacks[key] = callback;
3081 }
3082 /**
3083 * Serialize the current state of the store to JSON.
3084 * @return {?}
3085 */
3086 toJson() {
3087 // Call the onSerialize callbacks and put those values into the store.
3088 for (const key in this.onSerializeCallbacks) {
3089 if (this.onSerializeCallbacks.hasOwnProperty(key)) {
3090 try {
3091 this.store[key] = this.onSerializeCallbacks[key]();
3092 }
3093 catch (e) {
3094 console.warn('Exception in onSerialize callback: ', e);
3095 }
3096 }
3097 }
3098 return JSON.stringify(this.store);
3099 }
3100}
3101TransferState.decorators = [
3102 { type: Injectable }
3103];
3104if (false) {
3105 /**
3106 * @type {?}
3107 * @private
3108 */
3109 TransferState.prototype.store;
3110 /**
3111 * @type {?}
3112 * @private
3113 */
3114 TransferState.prototype.onSerializeCallbacks;
3115}
3116/**
3117 * @param {?} doc
3118 * @param {?} appId
3119 * @return {?}
3120 */
3121function initTransferState(doc, appId) {
3122 // Locate the script tag with the JSON data transferred from the server.
3123 // The id of the script tag is set to the Angular appId + 'state'.
3124 /** @type {?} */
3125 const script = doc.getElementById(appId + '-state');
3126 /** @type {?} */
3127 let initialState = {};
3128 if (script && script.textContent) {
3129 try {
3130 initialState = JSON.parse(unescapeHtml(script.textContent));
3131 }
3132 catch (e) {
3133 console.warn('Exception while restoring TransferState for app ' + appId, e);
3134 }
3135 }
3136 return TransferState.init(initialState);
3137}
3138/**
3139 * NgModule to install on the client side while using the `TransferState` to transfer state from
3140 * server to client.
3141 *
3142 * \@publicApi
3143 */
3144class BrowserTransferStateModule {
3145}
3146BrowserTransferStateModule.decorators = [
3147 { type: NgModule, args: [{
3148 providers: [{ provide: TransferState, useFactory: initTransferState, deps: [DOCUMENT, APP_ID] }],
3149 },] }
3150];
3151
3152/**
3153 * @fileoverview added by tsickle
3154 * Generated from: packages/platform-browser/src/dom/debug/by.ts
3155 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
3156 */
3157/**
3158 * Predicates for use with {\@link DebugElement}'s query functions.
3159 *
3160 * \@publicApi
3161 */
3162class By {
3163 /**
3164 * Match all nodes.
3165 *
3166 * \@usageNotes
3167 * ### Example
3168 *
3169 * {\@example platform-browser/dom/debug/ts/by/by.ts region='by_all'}
3170 * @return {?}
3171 */
3172 static all() {
3173 return (/**
3174 * @return {?}
3175 */
3176 () => true);
3177 }
3178 /**
3179 * Match elements by the given CSS selector.
3180 *
3181 * \@usageNotes
3182 * ### Example
3183 *
3184 * {\@example platform-browser/dom/debug/ts/by/by.ts region='by_css'}
3185 * @param {?} selector
3186 * @return {?}
3187 */
3188 static css(selector) {
3189 return (/**
3190 * @param {?} debugElement
3191 * @return {?}
3192 */
3193 (debugElement) => {
3194 return debugElement.nativeElement != null ?
3195 elementMatches(debugElement.nativeElement, selector) :
3196 false;
3197 });
3198 }
3199 /**
3200 * Match nodes that have the given directive present.
3201 *
3202 * \@usageNotes
3203 * ### Example
3204 *
3205 * {\@example platform-browser/dom/debug/ts/by/by.ts region='by_directive'}
3206 * @param {?} type
3207 * @return {?}
3208 */
3209 static directive(type) {
3210 return (/**
3211 * @param {?} debugNode
3212 * @return {?}
3213 */
3214 (debugNode) => (/** @type {?} */ (debugNode.providerTokens)).indexOf(type) !== -1);
3215 }
3216}
3217/**
3218 * @param {?} n
3219 * @param {?} selector
3220 * @return {?}
3221 */
3222function elementMatches(n, selector) {
3223 if (ɵgetDOM().isElementNode(n)) {
3224 return n.matches && n.matches(selector) ||
3225 n.msMatchesSelector && n.msMatchesSelector(selector) ||
3226 n.webkitMatchesSelector && n.webkitMatchesSelector(selector);
3227 }
3228 return false;
3229}
3230
3231/**
3232 * @fileoverview added by tsickle
3233 * Generated from: packages/platform-browser/src/private_export.ts
3234 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
3235 */
3236
3237/**
3238 * @fileoverview added by tsickle
3239 * Generated from: packages/platform-browser/src/version.ts
3240 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
3241 */
3242/**
3243 * \@publicApi
3244 * @type {?}
3245 */
3246const VERSION = new Version('9.1.9');
3247
3248/**
3249 * @fileoverview added by tsickle
3250 * Generated from: packages/platform-browser/src/platform-browser.ts
3251 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
3252 */
3253
3254/**
3255 * @fileoverview added by tsickle
3256 * Generated from: packages/platform-browser/public_api.ts
3257 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
3258 */
3259
3260/**
3261 * @fileoverview added by tsickle
3262 * Generated from: packages/platform-browser/index.ts
3263 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
3264 */
3265
3266/**
3267 * Generated bundle index. Do not edit.
3268 */
3269
3270export { BrowserModule, BrowserTransferStateModule, By, DomSanitizer, EVENT_MANAGER_PLUGINS, EventManager, HAMMER_GESTURE_CONFIG, HAMMER_LOADER, HammerGestureConfig, HammerModule, Meta, Title, TransferState, VERSION, disableDebugTools, enableDebugTools, makeStateKey, platformBrowser, BROWSER_SANITIZATION_PROVIDERS as ɵBROWSER_SANITIZATION_PROVIDERS, BROWSER_SANITIZATION_PROVIDERS__POST_R3__ as ɵBROWSER_SANITIZATION_PROVIDERS__POST_R3__, BrowserDomAdapter as ɵBrowserDomAdapter, BrowserGetTestability as ɵBrowserGetTestability, DomEventsPlugin as ɵDomEventsPlugin, DomRendererFactory2 as ɵDomRendererFactory2, DomSanitizerImpl as ɵDomSanitizerImpl, DomSharedStylesHost as ɵDomSharedStylesHost, ELEMENT_PROBE_PROVIDERS as ɵELEMENT_PROBE_PROVIDERS, ELEMENT_PROBE_PROVIDERS__POST_R3__ as ɵELEMENT_PROBE_PROVIDERS__POST_R3__, HAMMER_PROVIDERS__POST_R3__ as ɵHAMMER_PROVIDERS__POST_R3__, HammerGesturesPlugin as ɵHammerGesturesPlugin, INTERNAL_BROWSER_PLATFORM_PROVIDERS as ɵINTERNAL_BROWSER_PLATFORM_PROVIDERS, KeyEventsPlugin as ɵKeyEventsPlugin, NAMESPACE_URIS as ɵNAMESPACE_URIS, SharedStylesHost as ɵSharedStylesHost, TRANSITION_ID as ɵTRANSITION_ID, errorHandler as ɵangular_packages_platform_browser_platform_browser_a, _document as ɵangular_packages_platform_browser_platform_browser_b, BROWSER_MODULE_PROVIDERS as ɵangular_packages_platform_browser_platform_browser_c, createMeta as ɵangular_packages_platform_browser_platform_browser_d, createTitle as ɵangular_packages_platform_browser_platform_browser_e, initTransferState as ɵangular_packages_platform_browser_platform_browser_f, EventManagerPlugin as ɵangular_packages_platform_browser_platform_browser_g, HAMMER_PROVIDERS__PRE_R3__ as ɵangular_packages_platform_browser_platform_browser_h, HAMMER_PROVIDERS as ɵangular_packages_platform_browser_platform_browser_i, domSanitizerImplFactory as ɵangular_packages_platform_browser_platform_browser_j, appInitializerFactory as ɵangular_packages_platform_browser_platform_browser_k, SERVER_TRANSITION_PROVIDERS as ɵangular_packages_platform_browser_platform_browser_l, _createNgProbeR2 as ɵangular_packages_platform_browser_platform_browser_m, ELEMENT_PROBE_PROVIDERS__PRE_R3__ as ɵangular_packages_platform_browser_platform_browser_n, GenericBrowserDomAdapter as ɵangular_packages_platform_browser_platform_browser_o, escapeHtml as ɵescapeHtml, flattenStyles as ɵflattenStyles, initDomAdapter as ɵinitDomAdapter, shimContentAttribute as ɵshimContentAttribute, shimHostAttribute as ɵshimHostAttribute };
3271//# sourceMappingURL=platform-browser.js.map