UNPKG

72.3 kBJavaScriptView Raw
1var __extends = (this && this.__extends) || (function () {
2 var extendStatics = function (d, b) {
3 extendStatics = Object.setPrototypeOf ||
4 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
5 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
6 return extendStatics(d, b);
7 };
8 return function (d, b) {
9 extendStatics(d, b);
10 function __() { this.constructor = d; }
11 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
12 };
13})();
14var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
15 function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
16 return new (P || (P = Promise))(function (resolve, reject) {
17 function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
18 function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
19 function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
20 step((generator = generator.apply(thisArg, _arguments || [])).next());
21 });
22};
23var __generator = (this && this.__generator) || function (thisArg, body) {
24 var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
25 return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
26 function verb(n) { return function (v) { return step([n, v]); }; }
27 function step(op) {
28 if (f) throw new TypeError("Generator is already executing.");
29 while (_) try {
30 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;
31 if (y = 0, t) op = [op[0] & 2, t.value];
32 switch (op[0]) {
33 case 0: case 1: t = op; break;
34 case 4: _.label++; return { value: op[1], done: false };
35 case 5: _.label++; y = op[1]; op = [0]; continue;
36 case 7: op = _.ops.pop(); _.trys.pop(); continue;
37 default:
38 if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
39 if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
40 if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
41 if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
42 if (t[2]) _.ops.pop();
43 _.trys.pop(); continue;
44 }
45 op = body.call(thisArg, _);
46 } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
47 if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
48 }
49};
50var __spreadArrays = (this && this.__spreadArrays) || function () {
51 for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
52 for (var r = Array(s), k = 0, i = 0; i < il; i++)
53 for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
54 r[k] = a[j];
55 return r;
56};
57var BUILD = { "allRenderFn": false, "cmpDidLoad": false, "cmpShouldUpdate": false, "cmpDidUnload": false, "cmpDidUpdate": false, "cmpDidRender": true, "cmpWillLoad": false, "cmpWillUpdate": false, "cmpWillRender": false, "connectedCallback": true, "disconnectedCallback": false, "element": false, "event": false, "hasRenderFn": true, "lifecycle": true, "asyncLoading": true, "hostListener": true, "hostListenerTargetWindow": true, "hostListenerTargetDocument": false, "hostListenerTargetBody": false, "hostListenerTargetParent": false, "hostListenerTarget": true, "member": true, "method": false, "mode": false, "noVdomRender": false, "observeAttribute": true, "prop": true, "propBoolean": true, "propNumber": false, "propString": true, "propMutable": false, "reflect": true, "scoped": true, "shadowDom": false, "slot": true, "slotRelocation": true, "state": true, "style": true, "svg": true, "updatable": true, "vdomAttribute": true, "vdomXlink": false, "vdomClass": true, "vdomFunctional": false, "vdomKey": false, "vdomListener": true, "vdomRef": false, "vdomRender": true, "vdomStyle": true, "vdomText": true, "watchCallback": true, "taskQueue": true, "lazyLoad": true, "hydrateServerSide": false, "cssVarShim": true, "initializeNextTick": true, "hydrateClientSide": false, "isDebug": false, "isDev": false, "devTools": false, "lifecycleDOMEvents": false, "profile": false, "hotModuleReplacement": false, "constructableCSS": true, "cssAnnotations": true };
58var NAMESPACE = 'anjuna-docs';
59var queueCongestion = 0;
60var queuePending = false;
61var scopeId;
62var contentRef;
63var hostTagName;
64var useNativeShadowDom = false;
65var checkSlotFallbackVisibility = false;
66var checkSlotRelocate = false;
67var isSvgMode = false;
68var win = window;
69var doc = document;
70var plt = {
71 $flags$: 0,
72 $resourcesUrl$: '',
73 jmp: function (h) { return h(); },
74 raf: function (h) { return requestAnimationFrame(h); },
75 ael: function (el, eventName, listener, opts) { return el.addEventListener(eventName, listener, opts); },
76 rel: function (el, eventName, listener, opts) { return el.removeEventListener(eventName, listener, opts); },
77};
78var supportsShadowDom = false;
79var supportsListenerOptions = /*@__PURE__*/ (function () {
80 var supportsListenerOptions = false;
81 try {
82 doc.addEventListener('e', null, Object.defineProperty({}, 'passive', {
83 get: function () { supportsListenerOptions = true; }
84 }));
85 }
86 catch (e) { }
87 return supportsListenerOptions;
88})();
89var supportsConstructibleStylesheets = /*@__PURE__*/ (function () {
90 try {
91 new CSSStyleSheet();
92 return true;
93 }
94 catch (e) { }
95 return false;
96})();
97var hostRefs = new WeakMap();
98var getHostRef = function (ref) { return hostRefs.get(ref); };
99var registerInstance = function (lazyInstance, hostRef) { return hostRefs.set(hostRef.$lazyInstance$ = lazyInstance, hostRef); };
100var registerHost = function (elm) {
101 var hostRef = {
102 $flags$: 0,
103 $hostElement$: elm,
104 $instanceValues$: new Map()
105 };
106 {
107 hostRef.$onReadyPromise$ = new Promise(function (r) { return hostRef.$onReadyResolve$ = r; });
108 elm['s-p'] = [];
109 elm['s-rc'] = [];
110 }
111 return hostRefs.set(elm, hostRef);
112};
113var isMemberInElement = function (elm, memberName) { return memberName in elm; };
114var consoleError = function (e) { return console.error(e); };
115var moduleCache = /*@__PURE__*/ new Map();
116var loadModule = function (cmpMeta, hostRef, hmrVersionId) {
117 // loadModuleImport
118 var exportName = cmpMeta.$tagName$.replace(/-/g, '_');
119 var bundleId = (cmpMeta.$lazyBundleIds$);
120 var module = moduleCache.get(bundleId);
121 if (module) {
122 return module[exportName];
123 }
124 return import(
125 /* webpackInclude: /\.entry\.js$/ */
126 /* webpackExclude: /\.system\.entry\.js$/ */
127 /* webpackMode: "lazy" */
128 "./" + bundleId + ".entry.js" + '').then(function (importedModule) {
129 {
130 moduleCache.set(bundleId, importedModule);
131 }
132 return importedModule[exportName];
133 }, consoleError);
134};
135var styles = new Map();
136var queueDomReads = [];
137var queueDomWrites = [];
138var queueDomWritesLow = [];
139var queueTask = function (queue, write) { return function (cb) {
140 queue.push(cb);
141 if (!queuePending) {
142 queuePending = true;
143 if (write && plt.$flags$ & 4 /* queueSync */) {
144 nextTick(flush);
145 }
146 else {
147 plt.raf(flush);
148 }
149 }
150}; };
151var consume = function (queue) {
152 for (var i = 0; i < queue.length; i++) {
153 try {
154 queue[i](performance.now());
155 }
156 catch (e) {
157 consoleError(e);
158 }
159 }
160 queue.length = 0;
161};
162var consumeTimeout = function (queue, timeout) {
163 var i = 0;
164 var ts = 0;
165 while (i < queue.length && (ts = performance.now()) < timeout) {
166 try {
167 queue[i++](ts);
168 }
169 catch (e) {
170 consoleError(e);
171 }
172 }
173 if (i === queue.length) {
174 queue.length = 0;
175 }
176 else if (i !== 0) {
177 queue.splice(0, i);
178 }
179};
180var flush = function () {
181 queueCongestion++;
182 // always force a bunch of medium callbacks to run, but still have
183 // a throttle on how many can run in a certain time
184 // DOM READS!!!
185 consume(queueDomReads);
186 var timeout = (plt.$flags$ & 6 /* queueMask */) === 2 /* appLoaded */
187 ? performance.now() + (10 * Math.ceil(queueCongestion * (1.0 / 22.0)))
188 : Infinity;
189 // DOM WRITES!!!
190 consumeTimeout(queueDomWrites, timeout);
191 consumeTimeout(queueDomWritesLow, timeout);
192 if (queueDomWrites.length > 0) {
193 queueDomWritesLow.push.apply(queueDomWritesLow, queueDomWrites);
194 queueDomWrites.length = 0;
195 }
196 if (queuePending = ((queueDomReads.length + queueDomWrites.length + queueDomWritesLow.length) > 0)) {
197 // still more to do yet, but we've run out of time
198 // let's let this thing cool off and try again in the next tick
199 plt.raf(flush);
200 }
201 else {
202 queueCongestion = 0;
203 }
204};
205var nextTick = /*@__PURE__*/ function (cb) { return Promise.resolve().then(cb); };
206var writeTask = /*@__PURE__*/ queueTask(queueDomWrites, true);
207/**
208 * Default style mode id
209 */
210/**
211 * Reusable empty obj/array
212 * Don't add values to these!!
213 */
214var EMPTY_OBJ = {};
215/**
216 * Namespaces
217 */
218var SVG_NS = 'http://www.w3.org/2000/svg';
219var HTML_NS = 'http://www.w3.org/1999/xhtml';
220var isDef = function (v) { return v != null; };
221var isComplexType = function (o) {
222 // https://jsperf.com/typeof-fn-object/5
223 o = typeof o;
224 return o === 'object' || o === 'function';
225};
226var getDynamicImportFunction = function (namespace) {
227 return "__sc_import_" + namespace.replace(/\s|-/g, '_');
228};
229var patchEsm = function () {
230 // @ts-ignore
231 if (!(win.CSS && win.CSS.supports && win.CSS.supports('color', 'var(--c)'))) {
232 // @ts-ignore
233 return import('./css-shim-978387b1-1e75855f.js').then(function () {
234 plt.$cssShim$ = win.__stencil_cssshim;
235 if (plt.$cssShim$) {
236 return plt.$cssShim$.initShim();
237 }
238 });
239 }
240 return Promise.resolve();
241};
242var patchBrowser = function () { return __awaiter(void 0, void 0, void 0, function () {
243 var importMeta, regex, scriptElm, opts, resourcesUrl;
244 return __generator(this, function (_a) {
245 switch (_a.label) {
246 case 0:
247 {
248 plt.$cssShim$ = win.__stencil_cssshim;
249 }
250 importMeta = "";
251 regex = new RegExp("/" + NAMESPACE + "(\\.esm)?\\.js($|\\?|#)");
252 scriptElm = Array.from(doc.querySelectorAll('script')).find(function (s) { return (regex.test(s.src) ||
253 s.getAttribute('data-stencil-namespace') === NAMESPACE); });
254 opts = scriptElm['data-opts'];
255 if (!(importMeta !== '')) return [3 /*break*/, 1];
256 return [2 /*return*/, Object.assign(Object.assign({}, opts), { resourcesUrl: new URL('.', importMeta).href })];
257 case 1:
258 resourcesUrl = new URL('.', new URL(scriptElm.getAttribute('data-resources-url') || scriptElm.src, win.location.href));
259 patchDynamicImport(resourcesUrl.href);
260 if (!!window.customElements) return [3 /*break*/, 3];
261 // @ts-ignore
262 return [4 /*yield*/, import('./dom-96781eef-a2fb04dd.js')];
263 case 2:
264 // @ts-ignore
265 _a.sent();
266 _a.label = 3;
267 case 3: return [2 /*return*/, Object.assign(Object.assign({}, opts), { resourcesUrl: resourcesUrl.href })];
268 }
269 });
270}); };
271var patchDynamicImport = function (base) {
272 var importFunctionName = getDynamicImportFunction(NAMESPACE);
273 try {
274 // There is a caching issue in V8, that breaks using import() in Function
275 // By generating a random string, we can workaround it
276 // Check https://bugs.chromium.org/p/v8/issues/detail?id=9558 for more info
277 win[importFunctionName] = new Function('w', "return import(w);//" + Math.random());
278 }
279 catch (e) {
280 var moduleMap_1 = new Map();
281 win[importFunctionName] = function (src) {
282 var url = new URL(src, base).href;
283 var mod = moduleMap_1.get(url);
284 if (!mod) {
285 var script_1 = doc.createElement('script');
286 script_1.type = 'module';
287 script_1.src = URL.createObjectURL(new Blob(["import * as m from '" + url + "'; window." + importFunctionName + ".m = m;"], { type: 'application/javascript' }));
288 mod = new Promise(function (resolve) {
289 script_1.onload = function () {
290 resolve(win[importFunctionName].m);
291 script_1.remove();
292 };
293 });
294 moduleMap_1.set(url, mod);
295 doc.head.appendChild(script_1);
296 }
297 return mod;
298 };
299 }
300};
301var parsePropertyValue = function (propValue, propType) {
302 // ensure this value is of the correct prop type
303 if (propValue != null && !isComplexType(propValue)) {
304 if (propType & 4 /* Boolean */) {
305 // per the HTML spec, any string value means it is a boolean true value
306 // but we'll cheat here and say that the string "false" is the boolean false
307 return (propValue === 'false' ? false : propValue === '' || !!propValue);
308 }
309 if (propType & 1 /* String */) {
310 // could have been passed as a number or boolean
311 // but we still want it as a string
312 return String(propValue);
313 }
314 // redundant return here for better minification
315 return propValue;
316 }
317 // not sure exactly what type we want
318 // so no need to change to a different type
319 return propValue;
320};
321var HYDRATED_CLASS = 'hydrated';
322var createTime = function (fnName, tagName) {
323 if (tagName === void 0) { tagName = ''; }
324 {
325 return function () { return; };
326 }
327};
328var uniqueTime = function (key, measureText) {
329 {
330 return function () { return; };
331 }
332};
333var rootAppliedStyles = new WeakMap();
334var registerStyle = function (scopeId, cssText, allowCS) {
335 var style = styles.get(scopeId);
336 if (supportsConstructibleStylesheets && allowCS) {
337 style = (style || new CSSStyleSheet());
338 style.replace(cssText);
339 }
340 else {
341 style = cssText;
342 }
343 styles.set(scopeId, style);
344};
345var addStyle = function (styleContainerNode, cmpMeta, mode, hostElm) {
346 var scopeId = getScopeId(cmpMeta.$tagName$);
347 var style = styles.get(scopeId);
348 // if an element is NOT connected then getRootNode() will return the wrong root node
349 // so the fallback is to always use the document for the root node in those cases
350 styleContainerNode = (styleContainerNode.nodeType === 11 /* DocumentFragment */ ? styleContainerNode : doc);
351 if (style) {
352 if (typeof style === 'string') {
353 styleContainerNode = styleContainerNode.head || styleContainerNode;
354 var appliedStyles = rootAppliedStyles.get(styleContainerNode);
355 var styleElm = void 0;
356 if (!appliedStyles) {
357 rootAppliedStyles.set(styleContainerNode, appliedStyles = new Set());
358 }
359 if (!appliedStyles.has(scopeId)) {
360 {
361 if (plt.$cssShim$) {
362 styleElm = plt.$cssShim$.createHostStyle(hostElm, scopeId, style, !!(cmpMeta.$flags$ & 10 /* needsScopedEncapsulation */));
363 var newScopeId = styleElm['s-sc'];
364 if (newScopeId) {
365 scopeId = newScopeId;
366 // we don't want to add this styleID to the appliedStyles Set
367 // since the cssVarShim might need to apply several different
368 // stylesheets for the same component
369 appliedStyles = null;
370 }
371 }
372 else {
373 styleElm = doc.createElement('style');
374 styleElm.innerHTML = style;
375 }
376 styleContainerNode.insertBefore(styleElm, styleContainerNode.querySelector('link'));
377 }
378 if (appliedStyles) {
379 appliedStyles.add(scopeId);
380 }
381 }
382 }
383 else if (!styleContainerNode.adoptedStyleSheets.includes(style)) {
384 styleContainerNode.adoptedStyleSheets = __spreadArrays(styleContainerNode.adoptedStyleSheets, [
385 style
386 ]);
387 }
388 }
389 return scopeId;
390};
391var attachStyles = function (elm, cmpMeta, mode) {
392 var endAttachStyles = createTime('attachStyles', cmpMeta.$tagName$);
393 var scopeId = addStyle(elm.getRootNode(), cmpMeta, mode, elm);
394 if (cmpMeta.$flags$ & 10 /* needsScopedEncapsulation */) {
395 // only required when we're NOT using native shadow dom (slot)
396 // or this browser doesn't support native shadow dom
397 // and this host element was NOT created with SSR
398 // let's pick out the inner content for slot projection
399 // create a node to represent where the original
400 // content was first placed, which is useful later on
401 // DOM WRITE!!
402 elm['s-sc'] = scopeId;
403 elm.classList.add(scopeId + '-h');
404 if (cmpMeta.$flags$ & 2 /* scopedCssEncapsulation */) {
405 elm.classList.add(scopeId + '-s');
406 }
407 }
408 endAttachStyles();
409};
410var getScopeId = function (tagName, mode) { return 'sc-' + (tagName); };
411/**
412 * Production h() function based on Preact by
413 * Jason Miller (@developit)
414 * Licensed under the MIT License
415 * https://github.com/developit/preact/blob/master/LICENSE
416 *
417 * Modified for Stencil's compiler and vdom
418 */
419// const stack: any[] = [];
420// export function h(nodeName: string | d.FunctionalComponent, vnodeData: d.PropsType, child?: d.ChildType): d.VNode;
421// export function h(nodeName: string | d.FunctionalComponent, vnodeData: d.PropsType, ...children: d.ChildType[]): d.VNode;
422var h = function (nodeName, vnodeData) {
423 var children = [];
424 for (var _i = 2; _i < arguments.length; _i++) {
425 children[_i - 2] = arguments[_i];
426 }
427 var child = null;
428 var slotName = null;
429 var simple = false;
430 var lastSimple = false;
431 var vNodeChildren = [];
432 var walk = function (c) {
433 for (var i = 0; i < c.length; i++) {
434 child = c[i];
435 if (Array.isArray(child)) {
436 walk(child);
437 }
438 else if (child != null && typeof child !== 'boolean') {
439 if (simple = typeof nodeName !== 'function' && !isComplexType(child)) {
440 child = String(child);
441 }
442 if (simple && lastSimple) {
443 // If the previous child was simple (string), we merge both
444 vNodeChildren[vNodeChildren.length - 1].$text$ += child;
445 }
446 else {
447 // Append a new vNode, if it's text, we create a text vNode
448 vNodeChildren.push(simple ? newVNode(null, child) : child);
449 }
450 lastSimple = simple;
451 }
452 }
453 };
454 walk(children);
455 if (vnodeData) {
456 if (vnodeData.name) {
457 slotName = vnodeData.name;
458 }
459 {
460 var classData_1 = vnodeData.className || vnodeData.class;
461 if (classData_1) {
462 vnodeData.class = typeof classData_1 !== 'object'
463 ? classData_1
464 : Object.keys(classData_1)
465 .filter(function (k) { return classData_1[k]; })
466 .join(' ');
467 }
468 }
469 }
470 var vnode = newVNode(nodeName, null);
471 vnode.$attrs$ = vnodeData;
472 if (vNodeChildren.length > 0) {
473 vnode.$children$ = vNodeChildren;
474 }
475 {
476 vnode.$name$ = slotName;
477 }
478 return vnode;
479};
480var newVNode = function (tag, text) {
481 var vnode = {
482 $flags$: 0,
483 $tag$: tag,
484 $text$: text,
485 $elm$: null,
486 $children$: null
487 };
488 {
489 vnode.$attrs$ = null;
490 }
491 {
492 vnode.$name$ = null;
493 }
494 return vnode;
495};
496var Host = {};
497var isHost = function (node) { return node && node.$tag$ === Host; };
498/**
499 * Production setAccessor() function based on Preact by
500 * Jason Miller (@developit)
501 * Licensed under the MIT License
502 * https://github.com/developit/preact/blob/master/LICENSE
503 *
504 * Modified for Stencil's compiler and vdom
505 */
506var setAccessor = function (elm, memberName, oldValue, newValue, isSvg, flags) {
507 if (oldValue === newValue) {
508 return;
509 }
510 var isProp = isMemberInElement(elm, memberName);
511 var ln = memberName.toLowerCase();
512 if (memberName === 'class') {
513 var classList = elm.classList;
514 var oldClasses_1 = parseClassList(oldValue);
515 var newClasses_1 = parseClassList(newValue);
516 classList.remove.apply(classList, oldClasses_1.filter(function (c) { return c && !newClasses_1.includes(c); }));
517 classList.add.apply(classList, newClasses_1.filter(function (c) { return c && !oldClasses_1.includes(c); }));
518 }
519 else if (memberName === 'style') {
520 // update style attribute, css properties and values
521 {
522 for (var prop in oldValue) {
523 if (!newValue || newValue[prop] == null) {
524 if (prop.includes('-')) {
525 elm.style.removeProperty(prop);
526 }
527 else {
528 elm.style[prop] = '';
529 }
530 }
531 }
532 }
533 for (var prop in newValue) {
534 if (!oldValue || newValue[prop] !== oldValue[prop]) {
535 if (prop.includes('-')) {
536 elm.style.setProperty(prop, newValue[prop]);
537 }
538 else {
539 elm.style[prop] = newValue[prop];
540 }
541 }
542 }
543 }
544 else if (!isProp && memberName[0] === 'o' && memberName[1] === 'n') {
545 // Event Handlers
546 // so if the member name starts with "on" and the 3rd characters is
547 // a capital letter, and it's not already a member on the element,
548 // then we're assuming it's an event listener
549 if (memberName[2] === '-') {
550 // on- prefixed events
551 // allows to be explicit about the dom event to listen without any magic
552 // under the hood:
553 // <my-cmp on-click> // listens for "click"
554 // <my-cmp on-Click> // listens for "Click"
555 // <my-cmp on-ionChange> // listens for "ionChange"
556 // <my-cmp on-EVENTS> // listens for "EVENTS"
557 memberName = memberName.slice(3);
558 }
559 else if (isMemberInElement(win, ln)) {
560 // standard event
561 // the JSX attribute could have been "onMouseOver" and the
562 // member name "onmouseover" is on the window's prototype
563 // so let's add the listener "mouseover", which is all lowercased
564 memberName = ln.slice(2);
565 }
566 else {
567 // custom event
568 // the JSX attribute could have been "onMyCustomEvent"
569 // so let's trim off the "on" prefix and lowercase the first character
570 // and add the listener "myCustomEvent"
571 // except for the first character, we keep the event name case
572 memberName = ln[2] + memberName.slice(3);
573 }
574 if (oldValue) {
575 plt.rel(elm, memberName, oldValue, false);
576 }
577 if (newValue) {
578 plt.ael(elm, memberName, newValue, false);
579 }
580 }
581 else {
582 // Set property if it exists and it's not a SVG
583 var isComplex = isComplexType(newValue);
584 if ((isProp || (isComplex && newValue !== null)) && !isSvg) {
585 try {
586 if (!elm.tagName.includes('-')) {
587 var n = newValue == null ? '' : newValue;
588 // Workaround for Safari, moving the <input> caret when re-assigning the same valued
589 if (memberName === 'list') {
590 isProp = false;
591 // tslint:disable-next-line: triple-equals
592 }
593 else if (oldValue == null || elm[memberName] != n) {
594 elm[memberName] = n;
595 }
596 }
597 else {
598 elm[memberName] = newValue;
599 }
600 }
601 catch (e) { }
602 }
603 if (newValue == null || newValue === false) {
604 {
605 elm.removeAttribute(memberName);
606 }
607 }
608 else if ((!isProp || (flags & 4 /* isHost */) || isSvg) && !isComplex) {
609 newValue = newValue === true ? '' : newValue;
610 {
611 elm.setAttribute(memberName, newValue);
612 }
613 }
614 }
615};
616var parseClassListRegex = /\s/;
617var parseClassList = function (value) { return (!value) ? [] : value.split(parseClassListRegex); };
618var updateElement = function (oldVnode, newVnode, isSvgMode, memberName) {
619 // if the element passed in is a shadow root, which is a document fragment
620 // then we want to be adding attrs/props to the shadow root's "host" element
621 // if it's not a shadow root, then we add attrs/props to the same element
622 var elm = (newVnode.$elm$.nodeType === 11 /* DocumentFragment */ && newVnode.$elm$.host) ? newVnode.$elm$.host : newVnode.$elm$;
623 var oldVnodeAttrs = (oldVnode && oldVnode.$attrs$) || EMPTY_OBJ;
624 var newVnodeAttrs = newVnode.$attrs$ || EMPTY_OBJ;
625 {
626 // remove attributes no longer present on the vnode by setting them to undefined
627 for (memberName in oldVnodeAttrs) {
628 if (!(memberName in newVnodeAttrs)) {
629 setAccessor(elm, memberName, oldVnodeAttrs[memberName], undefined, isSvgMode, newVnode.$flags$);
630 }
631 }
632 }
633 // add new & update changed attributes
634 for (memberName in newVnodeAttrs) {
635 setAccessor(elm, memberName, oldVnodeAttrs[memberName], newVnodeAttrs[memberName], isSvgMode, newVnode.$flags$);
636 }
637};
638var createElm = function (oldParentVNode, newParentVNode, childIndex, parentElm) {
639 // tslint:disable-next-line: prefer-const
640 var newVNode = newParentVNode.$children$[childIndex];
641 var i = 0;
642 var elm;
643 var childNode;
644 var oldVNode;
645 if (!useNativeShadowDom) {
646 // remember for later we need to check to relocate nodes
647 checkSlotRelocate = true;
648 if (newVNode.$tag$ === 'slot') {
649 if (scopeId) {
650 // scoped css needs to add its scoped id to the parent element
651 parentElm.classList.add(scopeId + '-s');
652 }
653 newVNode.$flags$ |= (newVNode.$children$)
654 // slot element has fallback content
655 // still create an element that "mocks" the slot element
656 ? 2 /* isSlotFallback */
657 // slot element does not have fallback content
658 // create an html comment we'll use to always reference
659 // where actual slot content should sit next to
660 : 1 /* isSlotReference */;
661 }
662 }
663 if (newVNode.$text$ !== null) {
664 // create text node
665 elm = newVNode.$elm$ = doc.createTextNode(newVNode.$text$);
666 }
667 else if (newVNode.$flags$ & 1 /* isSlotReference */) {
668 // create a slot reference node
669 elm = newVNode.$elm$ = doc.createTextNode('');
670 }
671 else {
672 if (!isSvgMode) {
673 isSvgMode = newVNode.$tag$ === 'svg';
674 }
675 // create element
676 elm = newVNode.$elm$ = (doc.createElementNS(isSvgMode ? SVG_NS : HTML_NS, (newVNode.$flags$ & 2 /* isSlotFallback */) ? 'slot-fb' : newVNode.$tag$));
677 if (isSvgMode && newVNode.$tag$ === 'foreignObject') {
678 isSvgMode = false;
679 }
680 // add css classes, attrs, props, listeners, etc.
681 {
682 updateElement(null, newVNode, isSvgMode);
683 }
684 if (isDef(scopeId) && elm['s-si'] !== scopeId) {
685 // if there is a scopeId and this is the initial render
686 // then let's add the scopeId as a css class
687 elm.classList.add((elm['s-si'] = scopeId));
688 }
689 if (newVNode.$children$) {
690 for (i = 0; i < newVNode.$children$.length; ++i) {
691 // create the node
692 childNode = createElm(oldParentVNode, newVNode, i, elm);
693 // return node could have been null
694 if (childNode) {
695 // append our new node
696 elm.appendChild(childNode);
697 }
698 }
699 }
700 {
701 if (newVNode.$tag$ === 'svg') {
702 // Only reset the SVG context when we're exiting <svg> element
703 isSvgMode = false;
704 }
705 else if (elm.tagName === 'foreignObject') {
706 // Reenter SVG context when we're exiting <foreignObject> element
707 isSvgMode = true;
708 }
709 }
710 }
711 {
712 elm['s-hn'] = hostTagName;
713 if (newVNode.$flags$ & (2 /* isSlotFallback */ | 1 /* isSlotReference */)) {
714 // remember the content reference comment
715 elm['s-sr'] = true;
716 // remember the content reference comment
717 elm['s-cr'] = contentRef;
718 // remember the slot name, or empty string for default slot
719 elm['s-sn'] = newVNode.$name$ || '';
720 // check if we've got an old vnode for this slot
721 oldVNode = oldParentVNode && oldParentVNode.$children$ && oldParentVNode.$children$[childIndex];
722 if (oldVNode && oldVNode.$tag$ === newVNode.$tag$ && oldParentVNode.$elm$) {
723 // we've got an old slot vnode and the wrapper is being replaced
724 // so let's move the old slot content back to it's original location
725 putBackInOriginalLocation(oldParentVNode.$elm$, false);
726 }
727 }
728 }
729 return elm;
730};
731var putBackInOriginalLocation = function (parentElm, recursive) {
732 plt.$flags$ |= 1 /* isTmpDisconnected */;
733 var oldSlotChildNodes = parentElm.childNodes;
734 for (var i = oldSlotChildNodes.length - 1; i >= 0; i--) {
735 var childNode = oldSlotChildNodes[i];
736 if (childNode['s-hn'] !== hostTagName && childNode['s-ol']) {
737 // // this child node in the old element is from another component
738 // // remove this node from the old slot's parent
739 // childNode.remove();
740 // and relocate it back to it's original location
741 parentReferenceNode(childNode).insertBefore(childNode, referenceNode(childNode));
742 // remove the old original location comment entirely
743 // later on the patch function will know what to do
744 // and move this to the correct spot in need be
745 childNode['s-ol'].remove();
746 childNode['s-ol'] = undefined;
747 checkSlotRelocate = true;
748 }
749 if (recursive) {
750 putBackInOriginalLocation(childNode, recursive);
751 }
752 }
753 plt.$flags$ &= ~1 /* isTmpDisconnected */;
754};
755var addVnodes = function (parentElm, before, parentVNode, vnodes, startIdx, endIdx) {
756 var containerElm = ((parentElm['s-cr'] && parentElm['s-cr'].parentNode) || parentElm);
757 var childNode;
758 for (; startIdx <= endIdx; ++startIdx) {
759 if (vnodes[startIdx]) {
760 childNode = createElm(null, parentVNode, startIdx, parentElm);
761 if (childNode) {
762 vnodes[startIdx].$elm$ = childNode;
763 containerElm.insertBefore(childNode, referenceNode(before));
764 }
765 }
766 }
767};
768var removeVnodes = function (vnodes, startIdx, endIdx, vnode, elm) {
769 for (; startIdx <= endIdx; ++startIdx) {
770 if (vnode = vnodes[startIdx]) {
771 elm = vnode.$elm$;
772 {
773 // we're removing this element
774 // so it's possible we need to show slot fallback content now
775 checkSlotFallbackVisibility = true;
776 if (elm['s-ol']) {
777 // remove the original location comment
778 elm['s-ol'].remove();
779 }
780 else {
781 // it's possible that child nodes of the node
782 // that's being removed are slot nodes
783 putBackInOriginalLocation(elm, true);
784 }
785 }
786 // remove the vnode's element from the dom
787 elm.remove();
788 }
789 }
790};
791var updateChildren = function (parentElm, oldCh, newVNode, newCh) {
792 var oldStartIdx = 0;
793 var newStartIdx = 0;
794 var oldEndIdx = oldCh.length - 1;
795 var oldStartVnode = oldCh[0];
796 var oldEndVnode = oldCh[oldEndIdx];
797 var newEndIdx = newCh.length - 1;
798 var newStartVnode = newCh[0];
799 var newEndVnode = newCh[newEndIdx];
800 var node;
801 while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
802 if (oldStartVnode == null) {
803 // Vnode might have been moved left
804 oldStartVnode = oldCh[++oldStartIdx];
805 }
806 else if (oldEndVnode == null) {
807 oldEndVnode = oldCh[--oldEndIdx];
808 }
809 else if (newStartVnode == null) {
810 newStartVnode = newCh[++newStartIdx];
811 }
812 else if (newEndVnode == null) {
813 newEndVnode = newCh[--newEndIdx];
814 }
815 else if (isSameVnode(oldStartVnode, newStartVnode)) {
816 patch(oldStartVnode, newStartVnode);
817 oldStartVnode = oldCh[++oldStartIdx];
818 newStartVnode = newCh[++newStartIdx];
819 }
820 else if (isSameVnode(oldEndVnode, newEndVnode)) {
821 patch(oldEndVnode, newEndVnode);
822 oldEndVnode = oldCh[--oldEndIdx];
823 newEndVnode = newCh[--newEndIdx];
824 }
825 else if (isSameVnode(oldStartVnode, newEndVnode)) {
826 // Vnode moved right
827 if ((oldStartVnode.$tag$ === 'slot' || newEndVnode.$tag$ === 'slot')) {
828 putBackInOriginalLocation(oldStartVnode.$elm$.parentNode, false);
829 }
830 patch(oldStartVnode, newEndVnode);
831 parentElm.insertBefore(oldStartVnode.$elm$, oldEndVnode.$elm$.nextSibling);
832 oldStartVnode = oldCh[++oldStartIdx];
833 newEndVnode = newCh[--newEndIdx];
834 }
835 else if (isSameVnode(oldEndVnode, newStartVnode)) {
836 // Vnode moved left
837 if ((oldStartVnode.$tag$ === 'slot' || newEndVnode.$tag$ === 'slot')) {
838 putBackInOriginalLocation(oldEndVnode.$elm$.parentNode, false);
839 }
840 patch(oldEndVnode, newStartVnode);
841 parentElm.insertBefore(oldEndVnode.$elm$, oldStartVnode.$elm$);
842 oldEndVnode = oldCh[--oldEndIdx];
843 newStartVnode = newCh[++newStartIdx];
844 }
845 else {
846 {
847 // new element
848 node = createElm(oldCh && oldCh[newStartIdx], newVNode, newStartIdx, parentElm);
849 newStartVnode = newCh[++newStartIdx];
850 }
851 if (node) {
852 {
853 parentReferenceNode(oldStartVnode.$elm$).insertBefore(node, referenceNode(oldStartVnode.$elm$));
854 }
855 }
856 }
857 }
858 if (oldStartIdx > oldEndIdx) {
859 addVnodes(parentElm, (newCh[newEndIdx + 1] == null ? null : newCh[newEndIdx + 1].$elm$), newVNode, newCh, newStartIdx, newEndIdx);
860 }
861 else if (newStartIdx > newEndIdx) {
862 removeVnodes(oldCh, oldStartIdx, oldEndIdx);
863 }
864};
865var isSameVnode = function (vnode1, vnode2) {
866 // compare if two vnode to see if they're "technically" the same
867 // need to have the same element tag, and same key to be the same
868 if (vnode1.$tag$ === vnode2.$tag$) {
869 if (vnode1.$tag$ === 'slot') {
870 return vnode1.$name$ === vnode2.$name$;
871 }
872 return true;
873 }
874 return false;
875};
876var referenceNode = function (node) {
877 // this node was relocated to a new location in the dom
878 // because of some other component's slot
879 // but we still have an html comment in place of where
880 // it's original location was according to it's original vdom
881 return (node && node['s-ol']) || node;
882};
883var parentReferenceNode = function (node) { return (node['s-ol'] ? node['s-ol'] : node).parentNode; };
884var patch = function (oldVNode, newVNode) {
885 var elm = newVNode.$elm$ = oldVNode.$elm$;
886 var oldChildren = oldVNode.$children$;
887 var newChildren = newVNode.$children$;
888 var defaultHolder;
889 {
890 // test if we're rendering an svg element, or still rendering nodes inside of one
891 // only add this to the when the compiler sees we're using an svg somewhere
892 isSvgMode = elm && elm.parentNode &&
893 elm.ownerSVGElement !== undefined;
894 isSvgMode = newVNode.$tag$ === 'svg' ? true : (newVNode.$tag$ === 'foreignObject' ? false : isSvgMode);
895 }
896 if (newVNode.$text$ === null) {
897 // element node
898 {
899 if (newVNode.$tag$ === 'slot')
900 ;
901 else {
902 // either this is the first render of an element OR it's an update
903 // AND we already know it's possible it could have changed
904 // this updates the element's css classes, attrs, props, listeners, etc.
905 updateElement(oldVNode, newVNode, isSvgMode);
906 }
907 }
908 if (oldChildren !== null && newChildren !== null) {
909 // looks like there's child vnodes for both the old and new vnodes
910 updateChildren(elm, oldChildren, newVNode, newChildren);
911 }
912 else if (newChildren !== null) {
913 // no old child vnodes, but there are new child vnodes to add
914 if (oldVNode.$text$ !== null) {
915 // the old vnode was text, so be sure to clear it out
916 elm.textContent = '';
917 }
918 // add the new vnode children
919 addVnodes(elm, null, newVNode, newChildren, 0, newChildren.length - 1);
920 }
921 else if (oldChildren !== null) {
922 // no new child vnodes, but there are old child vnodes to remove
923 removeVnodes(oldChildren, 0, oldChildren.length - 1);
924 }
925 }
926 else if ((defaultHolder = elm['s-cr'])) {
927 // this element has slotted content
928 defaultHolder.parentNode.textContent = newVNode.$text$;
929 }
930 else if (oldVNode.$text$ !== newVNode.$text$) {
931 // update the text content for the text only vnode
932 // and also only if the text is different than before
933 elm.data = newVNode.$text$;
934 }
935 if (isSvgMode && newVNode.$tag$ === 'svg') {
936 isSvgMode = false;
937 }
938};
939var updateFallbackSlotVisibility = function (elm) {
940 // tslint:disable-next-line: prefer-const
941 var childNodes = elm.childNodes;
942 var childNode;
943 var i;
944 var ilen;
945 var j;
946 var slotNameAttr;
947 var nodeType;
948 for (i = 0, ilen = childNodes.length; i < ilen; i++) {
949 childNode = childNodes[i];
950 if (childNode.nodeType === 1 /* ElementNode */) {
951 if (childNode['s-sr']) {
952 // this is a slot fallback node
953 // get the slot name for this slot reference node
954 slotNameAttr = childNode['s-sn'];
955 // by default always show a fallback slot node
956 // then hide it if there are other slots in the light dom
957 childNode.hidden = false;
958 for (j = 0; j < ilen; j++) {
959 if (childNodes[j]['s-hn'] !== childNode['s-hn']) {
960 // this sibling node is from a different component
961 nodeType = childNodes[j].nodeType;
962 if (slotNameAttr !== '') {
963 // this is a named fallback slot node
964 if (nodeType === 1 /* ElementNode */ && slotNameAttr === childNodes[j].getAttribute('slot')) {
965 childNode.hidden = true;
966 break;
967 }
968 }
969 else {
970 // this is a default fallback slot node
971 // any element or text node (with content)
972 // should hide the default fallback slot node
973 if (nodeType === 1 /* ElementNode */ || (nodeType === 3 /* TextNode */ && childNodes[j].textContent.trim() !== '')) {
974 childNode.hidden = true;
975 break;
976 }
977 }
978 }
979 }
980 }
981 // keep drilling down
982 updateFallbackSlotVisibility(childNode);
983 }
984 }
985};
986var relocateNodes = [];
987var relocateSlotContent = function (elm) {
988 // tslint:disable-next-line: prefer-const
989 var childNodes = elm.childNodes;
990 var ilen = childNodes.length;
991 var i = 0;
992 var j = 0;
993 var nodeType = 0;
994 var childNode;
995 var node;
996 var hostContentNodes;
997 var slotNameAttr;
998 for (ilen = childNodes.length; i < ilen; i++) {
999 childNode = childNodes[i];
1000 if (childNode['s-sr'] && (node = childNode['s-cr'])) {
1001 // first got the content reference comment node
1002 // then we got it's parent, which is where all the host content is in now
1003 hostContentNodes = node.parentNode.childNodes;
1004 slotNameAttr = childNode['s-sn'];
1005 for (j = hostContentNodes.length - 1; j >= 0; j--) {
1006 node = hostContentNodes[j];
1007 if (!node['s-cn'] && !node['s-nr'] && node['s-hn'] !== childNode['s-hn']) {
1008 // let's do some relocating to its new home
1009 // but never relocate a content reference node
1010 // that is suppose to always represent the original content location
1011 nodeType = node.nodeType;
1012 if (((nodeType === 3 /* TextNode */ || nodeType === 8 /* CommentNode */) && slotNameAttr === '') ||
1013 (nodeType === 1 /* ElementNode */ && node.getAttribute('slot') === null && slotNameAttr === '') ||
1014 (nodeType === 1 /* ElementNode */ && node.getAttribute('slot') === slotNameAttr)) {
1015 // it's possible we've already decided to relocate this node
1016 if (!relocateNodes.some(function (r) { return r.$nodeToRelocate$ === node; })) {
1017 // made some changes to slots
1018 // let's make sure we also double check
1019 // fallbacks are correctly hidden or shown
1020 checkSlotFallbackVisibility = true;
1021 node['s-sn'] = slotNameAttr;
1022 // add to our list of nodes to relocate
1023 relocateNodes.push({
1024 $slotRefNode$: childNode,
1025 $nodeToRelocate$: node
1026 });
1027 }
1028 }
1029 }
1030 }
1031 }
1032 if (childNode.nodeType === 1 /* ElementNode */) {
1033 relocateSlotContent(childNode);
1034 }
1035 }
1036};
1037var renderVdom = function (hostElm, hostRef, cmpMeta, renderFnResults) {
1038 hostTagName = hostElm.tagName;
1039 var oldVNode = hostRef.$vnode$ || newVNode(null, null);
1040 var rootVnode = isHost(renderFnResults)
1041 ? renderFnResults
1042 : h(null, null, renderFnResults);
1043 if (cmpMeta.$attrsToReflect$) {
1044 rootVnode.$attrs$ = rootVnode.$attrs$ || {};
1045 cmpMeta.$attrsToReflect$.forEach(function (_a) {
1046 var propName = _a[0], attribute = _a[1];
1047 return rootVnode.$attrs$[attribute] = hostElm[propName];
1048 });
1049 }
1050 rootVnode.$tag$ = null;
1051 rootVnode.$flags$ |= 4 /* isHost */;
1052 hostRef.$vnode$ = rootVnode;
1053 rootVnode.$elm$ = oldVNode.$elm$ = (hostElm);
1054 {
1055 scopeId = hostElm['s-sc'];
1056 }
1057 {
1058 contentRef = hostElm['s-cr'];
1059 useNativeShadowDom = supportsShadowDom;
1060 // always reset
1061 checkSlotFallbackVisibility = false;
1062 }
1063 // synchronous patch
1064 patch(oldVNode, rootVnode);
1065 {
1066 if (checkSlotRelocate) {
1067 relocateSlotContent(rootVnode.$elm$);
1068 for (var i = 0; i < relocateNodes.length; i++) {
1069 var relocateNode = relocateNodes[i];
1070 if (!relocateNode.$nodeToRelocate$['s-ol']) {
1071 // add a reference node marking this node's original location
1072 // keep a reference to this node for later lookups
1073 var orgLocationNode = doc.createTextNode('');
1074 orgLocationNode['s-nr'] = relocateNode.$nodeToRelocate$;
1075 relocateNode.$nodeToRelocate$.parentNode.insertBefore((relocateNode.$nodeToRelocate$['s-ol'] = orgLocationNode), relocateNode.$nodeToRelocate$);
1076 }
1077 }
1078 // while we're moving nodes around existing nodes, temporarily disable
1079 // the disconnectCallback from working
1080 plt.$flags$ |= 1 /* isTmpDisconnected */;
1081 for (var i = 0; i < relocateNodes.length; i++) {
1082 var relocateNode = relocateNodes[i];
1083 // by default we're just going to insert it directly
1084 // after the slot reference node
1085 var parentNodeRef = relocateNode.$slotRefNode$.parentNode;
1086 var insertBeforeNode = relocateNode.$slotRefNode$.nextSibling;
1087 var orgLocationNode = relocateNode.$nodeToRelocate$['s-ol'];
1088 while (orgLocationNode = orgLocationNode.previousSibling) {
1089 var refNode = orgLocationNode['s-nr'];
1090 if (refNode &&
1091 refNode['s-sn'] === relocateNode.$nodeToRelocate$['s-sn'] &&
1092 parentNodeRef === refNode.parentNode) {
1093 refNode = refNode.nextSibling;
1094 if (!refNode || !refNode['s-nr']) {
1095 insertBeforeNode = refNode;
1096 break;
1097 }
1098 }
1099 }
1100 if ((!insertBeforeNode && parentNodeRef !== relocateNode.$nodeToRelocate$.parentNode) ||
1101 (relocateNode.$nodeToRelocate$.nextSibling !== insertBeforeNode)) {
1102 // we've checked that it's worth while to relocate
1103 // since that the node to relocate
1104 // has a different next sibling or parent relocated
1105 if (relocateNode.$nodeToRelocate$ !== insertBeforeNode) {
1106 // add it back to the dom but in its new home
1107 parentNodeRef.insertBefore(relocateNode.$nodeToRelocate$, insertBeforeNode);
1108 }
1109 }
1110 }
1111 // done moving nodes around
1112 // allow the disconnect callback to work again
1113 plt.$flags$ &= ~1 /* isTmpDisconnected */;
1114 }
1115 if (checkSlotFallbackVisibility) {
1116 updateFallbackSlotVisibility(rootVnode.$elm$);
1117 }
1118 // always reset
1119 relocateNodes.length = 0;
1120 }
1121};
1122var attachToAncestor = function (hostRef, ancestorComponent) {
1123 if (ancestorComponent && !hostRef.$onRenderResolve$) {
1124 ancestorComponent['s-p'].push(new Promise(function (r) { return hostRef.$onRenderResolve$ = r; }));
1125 }
1126};
1127var scheduleUpdate = function (elm, hostRef, cmpMeta, isInitialLoad) {
1128 {
1129 hostRef.$flags$ |= 16 /* isQueuedForUpdate */;
1130 }
1131 if (hostRef.$flags$ & 4 /* isWaitingForChildren */) {
1132 hostRef.$flags$ |= 512 /* needsRerender */;
1133 return;
1134 }
1135 var endSchedule = createTime('scheduleUpdate', cmpMeta.$tagName$);
1136 var ancestorComponent = hostRef.$ancestorComponent$;
1137 var instance = hostRef.$lazyInstance$;
1138 var update = function () { return updateComponent(elm, hostRef, cmpMeta, instance, isInitialLoad); };
1139 attachToAncestor(hostRef, ancestorComponent);
1140 var promise;
1141 if (isInitialLoad) {
1142 {
1143 hostRef.$flags$ |= 256 /* isListenReady */;
1144 if (hostRef.$queuedListeners$) {
1145 hostRef.$queuedListeners$.forEach(function (_a) {
1146 var methodName = _a[0], event = _a[1];
1147 return safeCall(instance, methodName, event);
1148 });
1149 hostRef.$queuedListeners$ = null;
1150 }
1151 }
1152 }
1153 endSchedule();
1154 // there is no ancestorc omponent or the ancestor component
1155 // has already fired off its lifecycle update then
1156 // fire off the initial update
1157 return then(promise, function () { return writeTask(update); });
1158};
1159var updateComponent = function (elm, hostRef, cmpMeta, instance, isInitialLoad) {
1160 // updateComponent
1161 var endUpdate = createTime('update', cmpMeta.$tagName$);
1162 var rc = elm['s-rc'];
1163 if (isInitialLoad) {
1164 // DOM WRITE!
1165 attachStyles(elm, cmpMeta, hostRef.$modeName$);
1166 }
1167 var endRender = createTime('render', cmpMeta.$tagName$);
1168 {
1169 {
1170 try {
1171 // looks like we've got child nodes to render into this host element
1172 // or we need to update the css class/attrs on the host element
1173 // DOM WRITE!
1174 renderVdom(elm, hostRef, cmpMeta, (instance.render && instance.render()));
1175 }
1176 catch (e) {
1177 consoleError(e);
1178 }
1179 }
1180 }
1181 if (plt.$cssShim$) {
1182 plt.$cssShim$.updateHost(elm);
1183 }
1184 {
1185 hostRef.$flags$ &= ~16 /* isQueuedForUpdate */;
1186 }
1187 {
1188 hostRef.$flags$ |= 2 /* hasRendered */;
1189 }
1190 if (rc) {
1191 // ok, so turns out there are some child host elements
1192 // waiting on this parent element to load
1193 // let's fire off all update callbacks waiting
1194 rc.forEach(function (cb) { return cb(); });
1195 elm['s-rc'] = undefined;
1196 }
1197 endRender();
1198 endUpdate();
1199 {
1200 var childrenPromises = elm['s-p'];
1201 var postUpdate = function () { return postUpdateComponent(elm, hostRef, cmpMeta); };
1202 if (childrenPromises.length === 0) {
1203 postUpdate();
1204 }
1205 else {
1206 Promise.all(childrenPromises).then(postUpdate);
1207 hostRef.$flags$ |= 4 /* isWaitingForChildren */;
1208 childrenPromises.length = 0;
1209 }
1210 }
1211};
1212var postUpdateComponent = function (elm, hostRef, cmpMeta) {
1213 var endPostUpdate = createTime('postUpdate', cmpMeta.$tagName$);
1214 var instance = hostRef.$lazyInstance$;
1215 var ancestorComponent = hostRef.$ancestorComponent$;
1216 {
1217 safeCall(instance, 'componentDidRender');
1218 }
1219 if (!(hostRef.$flags$ & 64 /* hasLoadedComponent */)) {
1220 hostRef.$flags$ |= 64 /* hasLoadedComponent */;
1221 {
1222 // DOM WRITE!
1223 // add the css class that this element has officially hydrated
1224 elm.classList.add(HYDRATED_CLASS);
1225 }
1226 endPostUpdate();
1227 {
1228 hostRef.$onReadyResolve$(elm);
1229 if (!ancestorComponent) {
1230 appDidLoad();
1231 }
1232 }
1233 }
1234 else {
1235 endPostUpdate();
1236 }
1237 // load events fire from bottom to top
1238 // the deepest elements load first then bubbles up
1239 {
1240 if (hostRef.$onRenderResolve$) {
1241 hostRef.$onRenderResolve$();
1242 hostRef.$onRenderResolve$ = undefined;
1243 }
1244 if (hostRef.$flags$ & 512 /* needsRerender */) {
1245 nextTick(function () { return scheduleUpdate(elm, hostRef, cmpMeta, false); });
1246 }
1247 hostRef.$flags$ &= ~(4 /* isWaitingForChildren */ | 512 /* needsRerender */);
1248 }
1249 // ( •_•)
1250 // ( •_•)>⌐■-■
1251 // (⌐■_■)
1252};
1253var forceUpdate = function (elm, cmpMeta) {
1254 {
1255 var hostRef = getHostRef(elm);
1256 if ((hostRef.$flags$ & (2 /* hasRendered */ | 16 /* isQueuedForUpdate */)) === 2 /* hasRendered */) {
1257 scheduleUpdate(elm, hostRef, cmpMeta, false);
1258 }
1259 }
1260};
1261var appDidLoad = function (who) {
1262 // on appload
1263 // we have finish the first big initial render
1264 {
1265 doc.documentElement.classList.add(HYDRATED_CLASS);
1266 }
1267 {
1268 plt.$flags$ |= 2 /* appLoaded */;
1269 }
1270};
1271var safeCall = function (instance, method, arg) {
1272 if (instance && instance[method]) {
1273 try {
1274 return instance[method](arg);
1275 }
1276 catch (e) {
1277 consoleError(e);
1278 }
1279 }
1280 return undefined;
1281};
1282var then = function (promise, thenFn) {
1283 return promise && promise.then ? promise.then(thenFn) : thenFn();
1284};
1285var getValue = function (ref, propName) { return getHostRef(ref).$instanceValues$.get(propName); };
1286var setValue = function (ref, propName, newVal, cmpMeta) {
1287 // check our new property value against our internal value
1288 var hostRef = getHostRef(ref);
1289 var elm = hostRef.$hostElement$;
1290 var oldVal = hostRef.$instanceValues$.get(propName);
1291 var flags = hostRef.$flags$;
1292 var instance = hostRef.$lazyInstance$;
1293 newVal = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]);
1294 if (newVal !== oldVal && (!(flags & 8 /* isConstructingInstance */) || oldVal === undefined)) {
1295 // gadzooks! the property's value has changed!!
1296 // set our new value!
1297 hostRef.$instanceValues$.set(propName, newVal);
1298 if (instance) {
1299 // get an array of method names of watch functions to call
1300 if (cmpMeta.$watchers$ && flags & 128 /* isWatchReady */) {
1301 var watchMethods = cmpMeta.$watchers$[propName];
1302 if (watchMethods) {
1303 // this instance is watching for when this property changed
1304 watchMethods.forEach(function (watchMethodName) {
1305 try {
1306 // fire off each of the watch methods that are watching this property
1307 instance[watchMethodName](newVal, oldVal, propName);
1308 }
1309 catch (e) {
1310 consoleError(e);
1311 }
1312 });
1313 }
1314 }
1315 if ((flags & (2 /* hasRendered */ | 16 /* isQueuedForUpdate */)) === 2 /* hasRendered */) {
1316 // looks like this value actually changed, so we've got work to do!
1317 // but only if we've already rendered, otherwise just chill out
1318 // queue that we need to do an update, but don't worry about queuing
1319 // up millions cuz this function ensures it only runs once
1320 scheduleUpdate(elm, hostRef, cmpMeta, false);
1321 }
1322 }
1323 }
1324};
1325var proxyComponent = function (Cstr, cmpMeta, flags) {
1326 if (cmpMeta.$members$) {
1327 if (Cstr.watchers) {
1328 cmpMeta.$watchers$ = Cstr.watchers;
1329 }
1330 // It's better to have a const than two Object.entries()
1331 var members = Object.entries(cmpMeta.$members$);
1332 var prototype_1 = Cstr.prototype;
1333 members.forEach(function (_a) {
1334 var memberName = _a[0], memberFlags = _a[1][0];
1335 if (((memberFlags & 31 /* Prop */) ||
1336 ((flags & 2 /* proxyState */) &&
1337 (memberFlags & 32 /* State */)))) {
1338 // proxyComponent - prop
1339 Object.defineProperty(prototype_1, memberName, {
1340 get: function () {
1341 // proxyComponent, get value
1342 return getValue(this, memberName);
1343 },
1344 set: function (newValue) {
1345 // proxyComponent, set value
1346 setValue(this, memberName, newValue, cmpMeta);
1347 },
1348 configurable: true,
1349 enumerable: true
1350 });
1351 }
1352 });
1353 if ((flags & 1 /* isElementConstructor */)) {
1354 var attrNameToPropName_1 = new Map();
1355 prototype_1.attributeChangedCallback = function (attrName, _oldValue, newValue) {
1356 var _this = this;
1357 plt.jmp(function () {
1358 var propName = attrNameToPropName_1.get(attrName);
1359 _this[propName] = newValue === null && typeof _this[propName] === 'boolean'
1360 ? false
1361 : newValue;
1362 });
1363 };
1364 // create an array of attributes to observe
1365 // and also create a map of html attribute name to js property name
1366 Cstr.observedAttributes = members
1367 .filter(function (_a) {
1368 var _ = _a[0], m = _a[1];
1369 return m[0] & 15;
1370 } /* HasAttribute */) // filter to only keep props that should match attributes
1371 .map(function (_a) {
1372 var propName = _a[0], m = _a[1];
1373 var attrName = m[1] || propName;
1374 attrNameToPropName_1.set(attrName, propName);
1375 if (m[0] & 512 /* ReflectAttr */) {
1376 cmpMeta.$attrsToReflect$.push([propName, attrName]);
1377 }
1378 return attrName;
1379 });
1380 }
1381 }
1382 return Cstr;
1383};
1384var addEventListeners = function (elm, hostRef, listeners) {
1385 hostRef.$queuedListeners$ = hostRef.$queuedListeners$ || [];
1386 var removeFns = listeners.map(function (_a) {
1387 var flags = _a[0], name = _a[1], method = _a[2];
1388 var target = (getHostListenerTarget(elm, flags));
1389 var handler = hostListenerProxy(hostRef, method);
1390 var opts = hostListenerOpts(flags);
1391 plt.ael(target, name, handler, opts);
1392 return function () { return plt.rel(target, name, handler, opts); };
1393 });
1394 return function () { return removeFns.forEach(function (fn) { return fn(); }); };
1395};
1396var hostListenerProxy = function (hostRef, methodName) {
1397 return function (ev) {
1398 {
1399 if (hostRef.$flags$ & 256 /* isListenReady */) {
1400 // instance is ready, let's call it's member method for this event
1401 hostRef.$lazyInstance$[methodName](ev);
1402 }
1403 else {
1404 hostRef.$queuedListeners$.push([methodName, ev]);
1405 }
1406 }
1407 };
1408};
1409var getHostListenerTarget = function (elm, flags) {
1410 if (flags & 8 /* TargetWindow */)
1411 return win;
1412 return elm;
1413};
1414var hostListenerOpts = function (flags) { return supportsListenerOptions ?
1415 {
1416 'passive': (flags & 1 /* Passive */) !== 0,
1417 'capture': (flags & 2 /* Capture */) !== 0,
1418 }
1419 : (flags & 2 /* Capture */) !== 0; };
1420var initializeComponent = function (elm, hostRef, cmpMeta, hmrVersionId, Cstr) { return __awaiter(void 0, void 0, void 0, function () {
1421 var endLoad, endNewInstance, scopeId_1, endRegisterStyles, style, ancestorComponent, schedule;
1422 return __generator(this, function (_a) {
1423 switch (_a.label) {
1424 case 0:
1425 if (!((hostRef.$flags$ & 32 /* hasInitializedComponent */) === 0)) return [3 /*break*/, 3];
1426 // we haven't initialized this element yet
1427 hostRef.$flags$ |= 32 /* hasInitializedComponent */;
1428 // lazy loaded components
1429 // request the component's implementation to be
1430 // wired up with the host element
1431 Cstr = loadModule(cmpMeta);
1432 if (!Cstr.then) return [3 /*break*/, 2];
1433 endLoad = uniqueTime();
1434 return [4 /*yield*/, Cstr];
1435 case 1:
1436 Cstr = _a.sent();
1437 endLoad();
1438 _a.label = 2;
1439 case 2:
1440 if (!Cstr.isProxied) {
1441 // we'eve never proxied this Constructor before
1442 // let's add the getters/setters to its prototype before
1443 // the first time we create an instance of the implementation
1444 {
1445 cmpMeta.$watchers$ = Cstr.watchers;
1446 }
1447 proxyComponent(Cstr, cmpMeta, 2 /* proxyState */);
1448 Cstr.isProxied = true;
1449 }
1450 endNewInstance = createTime('createInstance', cmpMeta.$tagName$);
1451 // ok, time to construct the instance
1452 // but let's keep track of when we start and stop
1453 // so that the getters/setters don't incorrectly step on data
1454 {
1455 hostRef.$flags$ |= 8 /* isConstructingInstance */;
1456 }
1457 // construct the lazy-loaded component implementation
1458 // passing the hostRef is very important during
1459 // construction in order to directly wire together the
1460 // host element and the lazy-loaded instance
1461 try {
1462 new Cstr(hostRef);
1463 }
1464 catch (e) {
1465 consoleError(e);
1466 }
1467 {
1468 hostRef.$flags$ &= ~8 /* isConstructingInstance */;
1469 }
1470 {
1471 hostRef.$flags$ |= 128 /* isWatchReady */;
1472 }
1473 endNewInstance();
1474 fireConnectedCallback(hostRef.$lazyInstance$);
1475 scopeId_1 = getScopeId(cmpMeta.$tagName$);
1476 if (!styles.has(scopeId_1) && Cstr.style) {
1477 endRegisterStyles = createTime('registerStyles', cmpMeta.$tagName$);
1478 style = Cstr.style;
1479 registerStyle(scopeId_1, style, !!(cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */));
1480 endRegisterStyles();
1481 }
1482 _a.label = 3;
1483 case 3:
1484 ancestorComponent = hostRef.$ancestorComponent$;
1485 schedule = function () { return scheduleUpdate(elm, hostRef, cmpMeta, true); };
1486 if (ancestorComponent && ancestorComponent['s-rc']) {
1487 // this is the intial load and this component it has an ancestor component
1488 // but the ancestor component has NOT fired its will update lifecycle yet
1489 // so let's just cool our jets and wait for the ancestor to continue first
1490 // this will get fired off when the ancestor component
1491 // finally gets around to rendering its lazy self
1492 // fire off the initial update
1493 ancestorComponent['s-rc'].push(schedule);
1494 }
1495 else {
1496 schedule();
1497 }
1498 return [2 /*return*/];
1499 }
1500 });
1501}); };
1502var fireConnectedCallback = function (instance) {
1503 {
1504 safeCall(instance, 'connectedCallback');
1505 }
1506};
1507var connectedCallback = function (elm, cmpMeta) {
1508 if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0) {
1509 var endConnected = createTime('connectedCallback', cmpMeta.$tagName$);
1510 // connectedCallback
1511 var hostRef_1 = getHostRef(elm);
1512 if (cmpMeta.$listeners$) {
1513 // initialize our event listeners on the host element
1514 // we do this now so that we can listening to events that may
1515 // have fired even before the instance is ready
1516 hostRef_1.$rmListeners$ = addEventListeners(elm, hostRef_1, cmpMeta.$listeners$);
1517 }
1518 if (!(hostRef_1.$flags$ & 1 /* hasConnected */)) {
1519 // first time this component has connected
1520 hostRef_1.$flags$ |= 1 /* hasConnected */;
1521 var hostId = void 0;
1522 if (!hostId) {
1523 // initUpdate
1524 // if the slot polyfill is required we'll need to put some nodes
1525 // in here to act as original content anchors as we move nodes around
1526 // host element has been connected to the DOM
1527 if ((cmpMeta.$flags$ & 4 /* hasSlotRelocation */) ||
1528 (BUILD.shadowDom /* needsShadowDomShim */)) {
1529 setContentReference(elm);
1530 }
1531 }
1532 {
1533 // find the first ancestor component (if there is one) and register
1534 // this component as one of the actively loading child components for its ancestor
1535 var ancestorComponent = elm;
1536 while ((ancestorComponent = (ancestorComponent.parentNode || ancestorComponent.host))) {
1537 // climb up the ancestors looking for the first
1538 // component that hasn't finished its lifecycle update yet
1539 if ((ancestorComponent['s-p'])) {
1540 // we found this components first ancestor component
1541 // keep a reference to this component's ancestor component
1542 attachToAncestor(hostRef_1, (hostRef_1.$ancestorComponent$ = ancestorComponent));
1543 break;
1544 }
1545 }
1546 }
1547 // Lazy properties
1548 // https://developers.google.com/web/fundamentals/web-components/best-practices#lazy-properties
1549 if (cmpMeta.$members$) {
1550 Object.entries(cmpMeta.$members$).forEach(function (_a) {
1551 var memberName = _a[0], memberFlags = _a[1][0];
1552 if (memberFlags & 31 /* Prop */ && elm.hasOwnProperty(memberName)) {
1553 var value = elm[memberName];
1554 delete elm[memberName];
1555 elm[memberName] = value;
1556 }
1557 });
1558 }
1559 {
1560 // connectedCallback, taskQueue, initialLoad
1561 // angular sets attribute AFTER connectCallback
1562 // https://github.com/angular/angular/issues/18909
1563 // https://github.com/angular/angular/issues/19940
1564 nextTick(function () { return initializeComponent(elm, hostRef_1, cmpMeta); });
1565 }
1566 }
1567 fireConnectedCallback(hostRef_1.$lazyInstance$);
1568 endConnected();
1569 }
1570};
1571var setContentReference = function (elm) {
1572 // only required when we're NOT using native shadow dom (slot)
1573 // or this browser doesn't support native shadow dom
1574 // and this host element was NOT created with SSR
1575 // let's pick out the inner content for slot projection
1576 // create a node to represent where the original
1577 // content was first placed, which is useful later on
1578 var crName = '';
1579 var contentRefElm = elm['s-cr'] = doc.createComment(crName);
1580 contentRefElm['s-cn'] = true;
1581 elm.insertBefore(contentRefElm, elm.firstChild);
1582};
1583var disconnectedCallback = function (elm) {
1584 if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0) {
1585 var hostRef = getHostRef(elm);
1586 {
1587 if (hostRef.$rmListeners$) {
1588 hostRef.$rmListeners$();
1589 hostRef.$rmListeners$ = undefined;
1590 }
1591 }
1592 // clear CSS var-shim tracking
1593 if (plt.$cssShim$) {
1594 plt.$cssShim$.removeHost(elm);
1595 }
1596 }
1597};
1598var bootstrapLazy = function (lazyBundles, options) {
1599 if (options === void 0) { options = {}; }
1600 var endBootstrap = createTime();
1601 var cmpTags = [];
1602 var exclude = options.exclude || [];
1603 var head = doc.head;
1604 var customElements = win.customElements;
1605 var y = /*@__PURE__*/ head.querySelector('meta[charset]');
1606 var visibilityStyle = /*@__PURE__*/ doc.createElement('style');
1607 var deferredConnectedCallbacks = [];
1608 var appLoadFallback;
1609 var isBootstrapping = true;
1610 Object.assign(plt, options);
1611 plt.$resourcesUrl$ = new URL(options.resourcesUrl || './', doc.baseURI).href;
1612 if (options.syncQueue) {
1613 plt.$flags$ |= 4 /* queueSync */;
1614 }
1615 lazyBundles.forEach(function (lazyBundle) { return lazyBundle[1].forEach(function (compactMeta) {
1616 var cmpMeta = {
1617 $flags$: compactMeta[0],
1618 $tagName$: compactMeta[1],
1619 $members$: compactMeta[2],
1620 $listeners$: compactMeta[3],
1621 };
1622 {
1623 cmpMeta.$members$ = compactMeta[2];
1624 }
1625 {
1626 cmpMeta.$listeners$ = compactMeta[3];
1627 }
1628 {
1629 cmpMeta.$attrsToReflect$ = [];
1630 }
1631 {
1632 cmpMeta.$watchers$ = {};
1633 }
1634 var tagName = cmpMeta.$tagName$;
1635 var HostElement = /** @class */ (function (_super) {
1636 __extends(HostElement, _super);
1637 // StencilLazyHost
1638 function HostElement(self) {
1639 var _this =
1640 // @ts-ignore
1641 _super.call(this, self) || this;
1642 self = _this;
1643 registerHost(self);
1644 return _this;
1645 }
1646 HostElement.prototype.connectedCallback = function () {
1647 var _this = this;
1648 if (appLoadFallback) {
1649 clearTimeout(appLoadFallback);
1650 appLoadFallback = null;
1651 }
1652 if (isBootstrapping) {
1653 // connectedCallback will be processed once all components have been registered
1654 deferredConnectedCallbacks.push(this);
1655 }
1656 else {
1657 plt.jmp(function () { return connectedCallback(_this, cmpMeta); });
1658 }
1659 };
1660 HostElement.prototype.disconnectedCallback = function () {
1661 var _this = this;
1662 plt.jmp(function () { return disconnectedCallback(_this); });
1663 };
1664 HostElement.prototype['s-hmr'] = function (hmrVersionId) {
1665 };
1666 HostElement.prototype.forceUpdate = function () {
1667 forceUpdate(this, cmpMeta);
1668 };
1669 HostElement.prototype.componentOnReady = function () {
1670 return getHostRef(this).$onReadyPromise$;
1671 };
1672 return HostElement;
1673 }(HTMLElement));
1674 cmpMeta.$lazyBundleIds$ = lazyBundle[0];
1675 if (!exclude.includes(tagName) && !customElements.get(tagName)) {
1676 cmpTags.push(tagName);
1677 customElements.define(tagName, proxyComponent(HostElement, cmpMeta, 1 /* isElementConstructor */));
1678 }
1679 }); });
1680 // visibilityStyle.innerHTML = cmpTags.map(t => `${t}:not(.hydrated)`) + '{display:none}';
1681 visibilityStyle.innerHTML = cmpTags + '{visibility:hidden}.hydrated{visibility:inherit}';
1682 visibilityStyle.setAttribute('data-styles', '');
1683 head.insertBefore(visibilityStyle, y ? y.nextSibling : head.firstChild);
1684 // Process deferred connectedCallbacks now all components have been registered
1685 isBootstrapping = false;
1686 if (deferredConnectedCallbacks.length > 0) {
1687 deferredConnectedCallbacks.forEach(function (host) { return host.connectedCallback(); });
1688 }
1689 else {
1690 plt.jmp(function () { return appLoadFallback = setTimeout(appDidLoad, 30, 'timeout'); });
1691 }
1692 // Fallback appLoad event
1693 endBootstrap();
1694};
1695var getElement = function (ref) { return getHostRef(ref).$hostElement$; };
1696export { patchEsm as a, bootstrapLazy as b, getElement as g, h, patchBrowser as p, registerInstance as r };