UNPKG

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