var __extends = (this && this.__extends) || (function () { var extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; var __generator = (this && this.__generator) || function (thisArg, body) { var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; function verb(n) { return function (v) { return step([n, v]); }; } function step(op) { if (f) throw new TypeError("Generator is already executing."); while (_) try { 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; if (y = 0, t) op = [op[0] & 2, t.value]; switch (op[0]) { case 0: case 1: t = op; break; case 4: _.label++; return { value: op[1], done: false }; case 5: _.label++; y = op[1]; op = [0]; continue; case 7: op = _.ops.pop(); _.trys.pop(); continue; default: if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } if (t[2]) _.ops.pop(); _.trys.pop(); continue; } op = body.call(thisArg, _); } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; } }; var appGlobal = function () { }; export function applyPolyfills(window, cb) { /*! es6-promise - a tiny implementation of Promises/A+. Copyright (c) 2014 Yehuda Katz, Tom Dale, Stefan Penner and contributors (Conversion to ES6 API by Jake Archibald) Licensed under MIT license See https://raw.githubusercontent.com/stefanpenner/es6-promise/master/LICENSE v4.2.4+314e4831 */ (window.ES6Promise = function () { function t() { var t = setTimeout; return function () { return t(r, 1); }; } function r() { for (var t = 0; t < y; t += 2) (0, C[t])(C[t + 1]), C[t] = void 0, C[t + 1] = void 0; y = 0; } function e(t, r) { var e = this, n = new this.constructor(o); void 0 === n[O] && _(n); var i = e._state; if (i) { var s = arguments[i - 1]; g(function () { return v(i, n, s, e._result); }); } else l(e, n, t, r); return n; } function n(t) { if (t && "object" == typeof t && t.constructor === this) return t; var r = new this(o); return u(r, t), r; } function o() { } function i(t) { try { return t.then; } catch (t) { return q.error = t, q; } } function s(t, r, o) { r.constructor === t.constructor && o === e && r.constructor.resolve === n ? function (t, r) { r._state === x ? a(t, r._result) : r._state === F ? f(t, r._result) : l(r, void 0, function (r) { return u(t, r); }, function (r) { return f(t, r); }); }(t, r) : o === q ? (f(t, q.error), q.error = null) : void 0 === o ? a(t, r) : "function" == typeof o ? function (t, r, e) { g(function (t) { var n = !1, o = function (t, r, e, n) { try { t.call(r, e, n); } catch (t) { return t; } }(e, r, function (e) { n || (n = !0, r !== e ? u(t, e) : a(t, e)); }, function (r) { n || (n = !0, f(t, r)); }, t._label); !n && o && (n = !0, f(t, o)); }, t); }(t, r, o) : a(t, r); } function u(t, r) { if (t === r) f(t, new TypeError("cannot resolve promise w/ itself")); else { var e = typeof r; null === r || "object" !== e && "function" !== e ? a(t, r) : s(t, r, i(r)); } } function c(t) { t._onerror && t._onerror(t._result), h(t); } function a(t, r) { t._state === P && (t._result = r, t._state = x, 0 !== t._subscribers.length && g(h, t)); } function f(t, r) { t._state === P && (t._state = F, t._result = r, g(c, t)); } function l(t, r, e, n) { var o = t._subscribers, i = o.length; t._onerror = null, o[i] = r, o[i + x] = e, o[i + F] = n, 0 === i && t._state && g(h, t); } function h(t) { var r = t._subscribers, e = t._state; if (0 !== r.length) { for (var n, o, i = t._result, s = 0; s < r.length; s += 3) n = r[s], o = r[s + e], n ? v(e, n, o, i) : o(i); t._subscribers.length = 0; } } function v(t, r, e, n) { var o = "function" == typeof e, i = void 0, s = void 0, c = void 0, l = void 0; if (o) { try { i = e(n); } catch (t) { q.error = t, i = q; } if (i === q ? (l = !0, s = i.error, i.error = null) : c = !0, r === i) return void f(r, new TypeError("Cannot return same promise")); } else i = n, c = !0; r._state === P && (o && c ? u(r, i) : l ? f(r, s) : t === x ? a(r, i) : t === F && f(r, i)); } function _(t) { t[O] = U++, t._state = void 0, t._result = void 0, t._subscribers = []; } var p, d = Array.isArray ? Array.isArray : function (t) { return "[object Array]" === Object.prototype.toString.call(t); }, y = 0, w = void 0, m = void 0, g = function (t, e) { C[y] = t, C[y + 1] = e, 2 === (y += 2) && (m ? m(r) : T()); }, b = (p = "undefined" != typeof window ? window : void 0) || {}, A = b.MutationObserver || b.WebKitMutationObserver; b = "undefined" == typeof self; var E, S, M, j = "undefined" != typeof Uint8ClampedArray && "undefined" != typeof importScripts && "undefined" != typeof MessageChannel, C = Array(1e3), T = void 0; T = A ? (E = 0, S = new A(r), M = document.createTextNode(""), S.observe(M, { characterData: !0 }), function () { M.data = E = ++E % 2; }) : j ? function () { var t = new MessageChannel; return t.port1.onmessage = r, function () { return t.port2.postMessage(0); }; }() : void 0 === p && "function" == typeof require ? function () { try { var e = Function("return this")().require("vertx"); return void 0 !== (w = e.runOnLoop || e.runOnContext) ? function () { w(r); } : t(); } catch (r) { return t(); } }() : t(); var O = Math.random().toString(36).substring(2), P = void 0, x = 1, F = 2, q = { error: null }, U = 0, D = function () { function t(t, r) { this._instanceConstructor = t, this.promise = new t(o), this.promise[O] || _(this.promise), d(r) ? (this._remaining = this.length = r.length, this._result = Array(this.length), 0 === this.length ? a(this.promise, this._result) : (this.length = this.length || 0, this._enumerate(r), 0 === this._remaining && a(this.promise, this._result))) : f(this.promise, Error("Array Methods must be provided an Array")); } return t.prototype._enumerate = function (t) { for (var r = 0; this._state === P && r < t.length; r++) this._eachEntry(t[r], r); }, t.prototype._eachEntry = function (t, r) { var u = this._instanceConstructor, c = u.resolve; c === n ? (c = i(t)) === e && t._state !== P ? this._settledAt(t._state, r, t._result) : "function" != typeof c ? (this._remaining--, this._result[r] = t) : u === K ? (s(u = new u(o), t, c), this._willSettleAt(u, r)) : this._willSettleAt(new u(function (r) { return r(t); }), r) : this._willSettleAt(c(t), r); }, t.prototype._settledAt = function (t, r, e) { var n = this.promise; n._state === P && (this._remaining--, t === F ? f(n, e) : this._result[r] = e), 0 === this._remaining && a(n, this._result); }, t.prototype._willSettleAt = function (t, r) { var e = this; l(t, void 0, function (t) { return e._settledAt(x, r, t); }, function (t) { return e._settledAt(F, r, t); }); }, t; }(), K = function () { function t(r) { if (this[O] = U++, this._result = this._state = void 0, this._subscribers = [], o !== r) { if ("function" != typeof r) throw new TypeError("Must pass a resolver fn as 1st arg"); if (!(this instanceof t)) throw new TypeError("Failed to construct 'Promise': Use the 'new' operator."); !function (t, r) { try { r(function (r) { u(t, r); }, function (r) { f(t, r); }); } catch (r) { f(t, r); } }(this, r); } } return t.prototype.catch = function (t) { return this.then(null, t); }, t.prototype.finally = function (t) { var r = this.constructor; return this.then(function (e) { return r.resolve(t()).then(function () { return e; }); }, function (e) { return r.resolve(t()).then(function () { throw e; }); }); }, t; }(); return K.prototype.then = e, K.all = function (t) { return new D(this, t).promise; }, K.race = function (t) { var r = this; return d(t) ? new r(function (e, n) { for (var o = t.length, i = 0; i < o; i++) r.resolve(t[i]).then(e, n); }) : new r(function (t, r) { return r(new TypeError("Must pass array to race")); }); }, K.resolve = n, K.reject = function (t) { var r = new this(o); return f(r, t), r; }, K._setScheduler = function (t) { m = t; }, K._setAsap = function (t) { g = t; }, K._asap = g, K.polyfill = function () { var t = void 0; if ("undefined" != typeof global) t = global; else if ("undefined" != typeof self) t = self; else try { t = Function("return this")(); } catch (t) { throw Error("polyfill failed"); } var r = t.Promise; if (r) { var e = null; try { e = Object.prototype.toString.call(r.resolve()); } catch (t) { } if ("[object Promise]" === e && !r.cast) return; } t.Promise = K; }, K.Promise = K, K.polyfill(), K; }()); var promises = []; if (!window.customElements || (window.Element && (!window.Element.prototype.closest || !window.Element.prototype.matches || !window.Element.prototype.remove))) { promises.push(import('./polyfills/dom.js')); } if ('function' !== typeof Object.assign || !Object.entries) { promises.push(import('./polyfills/object.js')); } if (!Array.prototype.find || !Array.prototype.includes) { promises.push(import('./polyfills/array.js')); } if (!String.prototype.startsWith || !String.prototype.endsWith) { promises.push(import('./polyfills/string.js')); } if (!window.fetch) { promises.push(import('./polyfills/fetch.js')); } function checkIfURLIsSupported() { try { var u = new URL('b', 'http://a'); u.pathname = 'c%20d'; return (u.href === 'http://a/c%20d') && u.searchParams; } catch (e) { return false; } } if (!checkIfURLIsSupported) { promises.push(import('./polyfills/url.js')); } Promise.all(promises).then(function (results) { results.forEach(function (polyfillModule) { polyfillModule.applyPolyfill(window, window.document); }); cb(); }); } function createComponentOnReadyPrototype(win, namespace, HTMLElementPrototype) { (win['s-apps'] = win['s-apps'] || []).push(namespace); if (!HTMLElementPrototype.componentOnReady) { HTMLElementPrototype.componentOnReady = function componentOnReady() { /*tslint:disable*/ var elm = this; function executor(resolve) { if (elm.nodeName.indexOf('-') > 0) { // window hasn't loaded yet and there's a // good chance this is a custom element var apps = win['s-apps']; var appsReady = 0; // loop through all the app namespaces for (var i = 0; i < apps.length; i++) { // see if this app has "componentOnReady" setup if (win[apps[i]].componentOnReady) { // this app's core has loaded call its "componentOnReady" if (win[apps[i]].componentOnReady(elm, resolve)) { // this component does belong to this app and would // have fired off the resolve fn // let's stop here, we're good return; } appsReady++; } } if (appsReady < apps.length) { // not all apps are ready yet // add it to the queue to be figured out when they are (win['s-cr'] = win['s-cr'] || []).push([elm, resolve]); return; } } // not a recognized app component resolve(null); } // callback wasn't provided, let's return a promise if (win.Promise) { // use native/polyfilled promise return new win.Promise(executor); } // promise may not have been polyfilled yet return { then: executor }; }; } } /** * SSR Attribute Names */ var SSR_VNODE_ID = 'ssrv'; var SSR_CHILD_ID = 'ssrc'; /** * Default style mode id */ var DEFAULT_STYLE_MODE = '$'; /** * Reusable empty obj/array * Don't add values to these!! */ var EMPTY_OBJ = {}; /** * Key Name to Key Code Map */ var KEY_CODE_MAP = { 'enter': 13, 'escape': 27, 'space': 32, 'tab': 9, 'left': 37, 'up': 38, 'right': 39, 'down': 40 }; function getScopeId(cmpMeta, mode) { return ('sc-' + cmpMeta.tagNameMeta) + ((mode && mode !== DEFAULT_STYLE_MODE) ? '-' + mode : ''); } function getElementScopeId(scopeId, isHostElement) { return scopeId + (isHostElement ? '-h' : '-s'); } function initStyleTemplate(domApi, cmpMeta, encapsulation, style, styleMode, perf) { if (style) { if (false) { perf.mark("init_style_template_start:" + cmpMeta.tagNameMeta); } // we got a style mode for this component, let's create an id for this style var styleModeId = cmpMeta.tagNameMeta + (styleMode || DEFAULT_STYLE_MODE); if (!cmpMeta[styleModeId]) { // we don't have this style mode id initialized yet if (true) { // ie11's template polyfill doesn't fully do the trick and there's still issues // so instead of trying to clone templates with styles in them, we'll just // keep a map of the style text as a string to create "); templateElm.innerHTML = styleContent.join(''); } else { // prod mode, no style id data attributes templateElm.innerHTML = ""; } // add our new template element to the head // so it can be cloned later domApi.$appendChild(domApi.$doc.head, templateElm); } } if (false) { perf.mark("init_style_template_end:" + cmpMeta.tagNameMeta); perf.measure("init_style_template:" + cmpMeta.tagNameMeta, "init_style_template_start:" + cmpMeta.tagNameMeta, "init_style_template_end:" + cmpMeta.tagNameMeta); } } } function attachStyles(plt, domApi, cmpMeta, hostElm) { // first see if we've got a style for a specific mode // either this host element should use scoped css // or it wants to use shadow dom but the browser doesn't support it // create a scope id which is useful for scoped css // and add the scope attribute to the host // create the style id w/ the host element's mode var styleId = cmpMeta.tagNameMeta + hostElm.mode; var styleTemplate = cmpMeta[styleId]; var shouldScopeCss = (cmpMeta.encapsulationMeta === 2 /* ScopedCss */ || (cmpMeta.encapsulationMeta === 1 /* ShadowDom */ && !plt.domApi.$supportsShadowDom)); if (shouldScopeCss) { hostElm['s-sc'] = styleTemplate ? getScopeId(cmpMeta, hostElm.mode) : getScopeId(cmpMeta); } if (!styleTemplate) { // doesn't look like there's a style template with the mode // create the style id using the default style mode and try again styleId = cmpMeta.tagNameMeta + DEFAULT_STYLE_MODE; styleTemplate = cmpMeta[styleId]; } if (styleTemplate) { // cool, we found a style template element for this component var styleContainerNode = domApi.$doc.head; // if this browser supports shadow dom, then let's climb up // the dom and see if we're within a shadow dom if (true && domApi.$supportsShadowDom) { if (cmpMeta.encapsulationMeta === 1 /* ShadowDom */) { // we already know we're in a shadow dom // so shadow root is the container for these styles styleContainerNode = hostElm.shadowRoot; } else { // climb up the dom and see if we're in a shadow dom var root = hostElm; while (root = domApi.$parentNode(root)) { if (root.host && root.host.shadowRoot) { // looks like we are in shadow dom, let's use // this shadow root as the container for these styles styleContainerNode = (root.host.shadowRoot); break; } } } } // if this container element already has these styles // then there's no need to apply them again // create an object to keep track if we'ready applied this component style var appliedStyles = plt.componentAppliedStyles.get(styleContainerNode); if (!appliedStyles) { plt.componentAppliedStyles.set(styleContainerNode, appliedStyles = {}); } // check if we haven't applied these styles to this container yet if (!appliedStyles[styleId]) { var styleElm = void 0; if (true) { // es5 builds are not usig