UNPKG

82.9 kBJavaScriptView Raw
1'use strict';
2
3function _interopNamespace(e) {
4 if (e && e.__esModule) return e;
5 var n = Object.create(null);
6 if (e) {
7 Object.keys(e).forEach(function (k) {
8 if (k !== 'default') {
9 var d = Object.getOwnPropertyDescriptor(e, k);
10 Object.defineProperty(n, k, d.get ? d : {
11 enumerable: true,
12 get: function () {
13 return e[k];
14 }
15 });
16 }
17 });
18 }
19 n['default'] = e;
20 return Object.freeze(n);
21}
22
23const NAMESPACE = 'ionic';
24
25let scopeId;
26let contentRef;
27let hostTagName;
28let useNativeShadowDom = false;
29let checkSlotFallbackVisibility = false;
30let checkSlotRelocate = false;
31let isSvgMode = false;
32let queuePending = false;
33const win = typeof window !== 'undefined' ? window : {};
34const CSS = win.CSS ;
35const doc = win.document || { head: {} };
36const plt = {
37 $flags$: 0,
38 $resourcesUrl$: '',
39 jmp: h => h(),
40 raf: h => requestAnimationFrame(h),
41 ael: (el, eventName, listener, opts) => el.addEventListener(eventName, listener, opts),
42 rel: (el, eventName, listener, opts) => el.removeEventListener(eventName, listener, opts),
43 ce: (eventName, opts) => new CustomEvent(eventName, opts),
44};
45const supportsShadow = /*@__PURE__*/ (() => (doc.head.attachShadow + '').indexOf('[native') > -1)() ;
46const promiseResolve = (v) => Promise.resolve(v);
47const supportsConstructibleStylesheets = /*@__PURE__*/ (() => {
48 try {
49 new CSSStyleSheet();
50 return typeof (new CSSStyleSheet()).replace === 'function';
51 }
52 catch (e) { }
53 return false;
54 })()
55 ;
56const addHostEventListeners = (elm, hostRef, listeners, attachParentListeners) => {
57 if (listeners) {
58 listeners.map(([flags, name, method]) => {
59 const target = getHostListenerTarget(elm, flags) ;
60 const handler = hostListenerProxy(hostRef, method);
61 const opts = hostListenerOpts(flags);
62 plt.ael(target, name, handler, opts);
63 (hostRef.$rmListeners$ = hostRef.$rmListeners$ || []).push(() => plt.rel(target, name, handler, opts));
64 });
65 }
66};
67const hostListenerProxy = (hostRef, methodName) => (ev) => {
68 try {
69 {
70 if (hostRef.$flags$ & 256 /* isListenReady */) {
71 // instance is ready, let's call it's member method for this event
72 hostRef.$lazyInstance$[methodName](ev);
73 }
74 else {
75 (hostRef.$queuedListeners$ = hostRef.$queuedListeners$ || []).push([methodName, ev]);
76 }
77 }
78 }
79 catch (e) {
80 consoleError(e);
81 }
82};
83const getHostListenerTarget = (elm, flags) => {
84 if (flags & 4 /* TargetDocument */)
85 return doc;
86 if (flags & 8 /* TargetWindow */)
87 return win;
88 if (flags & 16 /* TargetBody */)
89 return doc.body;
90 return elm;
91};
92// prettier-ignore
93const hostListenerOpts = (flags) => (flags & 2 /* Capture */) !== 0;
94const CONTENT_REF_ID = 'r';
95const ORG_LOCATION_ID = 'o';
96const SLOT_NODE_ID = 's';
97const TEXT_NODE_ID = 't';
98const HYDRATE_ID = 's-id';
99const HYDRATED_STYLE_ID = 'sty-id';
100const HYDRATE_CHILD_ID = 'c-id';
101const HYDRATED_CSS = '{visibility:hidden}.hydrated{visibility:inherit}';
102const XLINK_NS = 'http://www.w3.org/1999/xlink';
103const createTime = (fnName, tagName = '') => {
104 {
105 return () => {
106 return;
107 };
108 }
109};
110const uniqueTime = (key, measureText) => {
111 {
112 return () => {
113 return;
114 };
115 }
116};
117const rootAppliedStyles = new WeakMap();
118const registerStyle = (scopeId, cssText, allowCS) => {
119 let style = styles.get(scopeId);
120 if (supportsConstructibleStylesheets && allowCS) {
121 style = (style || new CSSStyleSheet());
122 style.replace(cssText);
123 }
124 else {
125 style = cssText;
126 }
127 styles.set(scopeId, style);
128};
129const addStyle = (styleContainerNode, cmpMeta, mode, hostElm) => {
130 let scopeId = getScopeId(cmpMeta, mode);
131 let style = styles.get(scopeId);
132 // if an element is NOT connected then getRootNode() will return the wrong root node
133 // so the fallback is to always use the document for the root node in those cases
134 styleContainerNode = styleContainerNode.nodeType === 11 /* DocumentFragment */ ? styleContainerNode : doc;
135 if (style) {
136 if (typeof style === 'string') {
137 styleContainerNode = styleContainerNode.head || styleContainerNode;
138 let appliedStyles = rootAppliedStyles.get(styleContainerNode);
139 let styleElm;
140 if (!appliedStyles) {
141 rootAppliedStyles.set(styleContainerNode, (appliedStyles = new Set()));
142 }
143 if (!appliedStyles.has(scopeId)) {
144 if (styleContainerNode.host && (styleElm = styleContainerNode.querySelector(`[${HYDRATED_STYLE_ID}="${scopeId}"]`))) {
145 // This is only happening on native shadow-dom, do not needs CSS var shim
146 styleElm.innerHTML = style;
147 }
148 else {
149 if (plt.$cssShim$) {
150 styleElm = plt.$cssShim$.createHostStyle(hostElm, scopeId, style, !!(cmpMeta.$flags$ & 10 /* needsScopedEncapsulation */));
151 const newScopeId = styleElm['s-sc'];
152 if (newScopeId) {
153 scopeId = newScopeId;
154 // we don't want to add this styleID to the appliedStyles Set
155 // since the cssVarShim might need to apply several different
156 // stylesheets for the same component
157 appliedStyles = null;
158 }
159 }
160 else {
161 styleElm = doc.createElement('style');
162 styleElm.innerHTML = style;
163 }
164 styleContainerNode.insertBefore(styleElm, styleContainerNode.querySelector('link'));
165 }
166 if (appliedStyles) {
167 appliedStyles.add(scopeId);
168 }
169 }
170 }
171 else if (!styleContainerNode.adoptedStyleSheets.includes(style)) {
172 styleContainerNode.adoptedStyleSheets = [...styleContainerNode.adoptedStyleSheets, style];
173 }
174 }
175 return scopeId;
176};
177const attachStyles = (hostRef) => {
178 const cmpMeta = hostRef.$cmpMeta$;
179 const elm = hostRef.$hostElement$;
180 const flags = cmpMeta.$flags$;
181 const endAttachStyles = createTime('attachStyles', cmpMeta.$tagName$);
182 const scopeId = addStyle(supportsShadow && elm.shadowRoot ? elm.shadowRoot : elm.getRootNode(), cmpMeta, hostRef.$modeName$, elm);
183 if (flags & 10 /* needsScopedEncapsulation */) {
184 // only required when we're NOT using native shadow dom (slot)
185 // or this browser doesn't support native shadow dom
186 // and this host element was NOT created with SSR
187 // let's pick out the inner content for slot projection
188 // create a node to represent where the original
189 // content was first placed, which is useful later on
190 // DOM WRITE!!
191 elm['s-sc'] = scopeId;
192 elm.classList.add(scopeId + '-h');
193 if (flags & 2 /* scopedCssEncapsulation */) {
194 elm.classList.add(scopeId + '-s');
195 }
196 }
197 endAttachStyles();
198};
199const getScopeId = (cmp, mode) => 'sc-' + (mode && cmp.$flags$ & 32 /* hasMode */ ? cmp.$tagName$ + '-' + mode : cmp.$tagName$);
200const convertScopedToShadow = (css) => css.replace(/\/\*!@([^\/]+)\*\/[^\{]+\{/g, '$1{');
201// Private
202const computeMode = (elm) => modeResolutionChain.map(h => h(elm)).find(m => !!m);
203// Public
204const setMode = (handler) => modeResolutionChain.push(handler);
205const getMode = (ref) => getHostRef(ref).$modeName$;
206/**
207 * Default style mode id
208 */
209/**
210 * Reusable empty obj/array
211 * Don't add values to these!!
212 */
213const EMPTY_OBJ = {};
214/**
215 * Namespaces
216 */
217const SVG_NS = 'http://www.w3.org/2000/svg';
218const HTML_NS = 'http://www.w3.org/1999/xhtml';
219const isDef = (v) => v != null;
220const isComplexType = (o) => {
221 // https://jsperf.com/typeof-fn-object/5
222 o = typeof o;
223 return o === 'object' || o === 'function';
224};
225/**
226 * Production h() function based on Preact by
227 * Jason Miller (@developit)
228 * Licensed under the MIT License
229 * https://github.com/developit/preact/blob/master/LICENSE
230 *
231 * Modified for Stencil's compiler and vdom
232 */
233// const stack: any[] = [];
234// export function h(nodeName: string | d.FunctionalComponent, vnodeData: d.PropsType, child?: d.ChildType): d.VNode;
235// export function h(nodeName: string | d.FunctionalComponent, vnodeData: d.PropsType, ...children: d.ChildType[]): d.VNode;
236const h = (nodeName, vnodeData, ...children) => {
237 let child = null;
238 let key = null;
239 let slotName = null;
240 let simple = false;
241 let lastSimple = false;
242 let vNodeChildren = [];
243 const walk = (c) => {
244 for (let i = 0; i < c.length; i++) {
245 child = c[i];
246 if (Array.isArray(child)) {
247 walk(child);
248 }
249 else if (child != null && typeof child !== 'boolean') {
250 if ((simple = typeof nodeName !== 'function' && !isComplexType(child))) {
251 child = String(child);
252 }
253 if (simple && lastSimple) {
254 // If the previous child was simple (string), we merge both
255 vNodeChildren[vNodeChildren.length - 1].$text$ += child;
256 }
257 else {
258 // Append a new vNode, if it's text, we create a text vNode
259 vNodeChildren.push(simple ? newVNode(null, child) : child);
260 }
261 lastSimple = simple;
262 }
263 }
264 };
265 walk(children);
266 if (vnodeData) {
267 // normalize class / classname attributes
268 if (vnodeData.key) {
269 key = vnodeData.key;
270 }
271 if (vnodeData.name) {
272 slotName = vnodeData.name;
273 }
274 {
275 const classData = vnodeData.className || vnodeData.class;
276 if (classData) {
277 vnodeData.class =
278 typeof classData !== 'object'
279 ? classData
280 : Object.keys(classData)
281 .filter(k => classData[k])
282 .join(' ');
283 }
284 }
285 }
286 if (typeof nodeName === 'function') {
287 // nodeName is a functional component
288 return nodeName(vnodeData === null ? {} : vnodeData, vNodeChildren, vdomFnUtils);
289 }
290 const vnode = newVNode(nodeName, null);
291 vnode.$attrs$ = vnodeData;
292 if (vNodeChildren.length > 0) {
293 vnode.$children$ = vNodeChildren;
294 }
295 {
296 vnode.$key$ = key;
297 }
298 {
299 vnode.$name$ = slotName;
300 }
301 return vnode;
302};
303const newVNode = (tag, text) => {
304 const vnode = {
305 $flags$: 0,
306 $tag$: tag,
307 $text$: text,
308 $elm$: null,
309 $children$: null,
310 };
311 {
312 vnode.$attrs$ = null;
313 }
314 {
315 vnode.$key$ = null;
316 }
317 {
318 vnode.$name$ = null;
319 }
320 return vnode;
321};
322const Host = {};
323const isHost = (node) => node && node.$tag$ === Host;
324const vdomFnUtils = {
325 forEach: (children, cb) => children.map(convertToPublic).forEach(cb),
326 map: (children, cb) => children.map(convertToPublic).map(cb).map(convertToPrivate),
327};
328const convertToPublic = (node) => ({
329 vattrs: node.$attrs$,
330 vchildren: node.$children$,
331 vkey: node.$key$,
332 vname: node.$name$,
333 vtag: node.$tag$,
334 vtext: node.$text$,
335});
336const convertToPrivate = (node) => {
337 if (typeof node.vtag === 'function') {
338 const vnodeData = Object.assign({}, node.vattrs);
339 if (node.vkey) {
340 vnodeData.key = node.vkey;
341 }
342 if (node.vname) {
343 vnodeData.name = node.vname;
344 }
345 return h(node.vtag, vnodeData, ...(node.vchildren || []));
346 }
347 const vnode = newVNode(node.vtag, node.vtext);
348 vnode.$attrs$ = node.vattrs;
349 vnode.$children$ = node.vchildren;
350 vnode.$key$ = node.vkey;
351 vnode.$name$ = node.vname;
352 return vnode;
353};
354/**
355 * Production setAccessor() function based on Preact by
356 * Jason Miller (@developit)
357 * Licensed under the MIT License
358 * https://github.com/developit/preact/blob/master/LICENSE
359 *
360 * Modified for Stencil's compiler and vdom
361 */
362const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
363 if (oldValue !== newValue) {
364 let isProp = isMemberInElement(elm, memberName);
365 let ln = memberName.toLowerCase();
366 if (memberName === 'class') {
367 const classList = elm.classList;
368 const oldClasses = parseClassList(oldValue);
369 const newClasses = parseClassList(newValue);
370 classList.remove(...oldClasses.filter(c => c && !newClasses.includes(c)));
371 classList.add(...newClasses.filter(c => c && !oldClasses.includes(c)));
372 }
373 else if (memberName === 'style') {
374 // update style attribute, css properties and values
375 {
376 for (const prop in oldValue) {
377 if (!newValue || newValue[prop] == null) {
378 if (prop.includes('-')) {
379 elm.style.removeProperty(prop);
380 }
381 else {
382 elm.style[prop] = '';
383 }
384 }
385 }
386 }
387 for (const prop in newValue) {
388 if (!oldValue || newValue[prop] !== oldValue[prop]) {
389 if (prop.includes('-')) {
390 elm.style.setProperty(prop, newValue[prop]);
391 }
392 else {
393 elm.style[prop] = newValue[prop];
394 }
395 }
396 }
397 }
398 else if (memberName === 'key')
399 ;
400 else if (memberName === 'ref') {
401 // minifier will clean this up
402 if (newValue) {
403 newValue(elm);
404 }
405 }
406 else if ((!isProp ) && memberName[0] === 'o' && memberName[1] === 'n') {
407 // Event Handlers
408 // so if the member name starts with "on" and the 3rd characters is
409 // a capital letter, and it's not already a member on the element,
410 // then we're assuming it's an event listener
411 if (memberName[2] === '-') {
412 // on- prefixed events
413 // allows to be explicit about the dom event to listen without any magic
414 // under the hood:
415 // <my-cmp on-click> // listens for "click"
416 // <my-cmp on-Click> // listens for "Click"
417 // <my-cmp on-ionChange> // listens for "ionChange"
418 // <my-cmp on-EVENTS> // listens for "EVENTS"
419 memberName = memberName.slice(3);
420 }
421 else if (isMemberInElement(win, ln)) {
422 // standard event
423 // the JSX attribute could have been "onMouseOver" and the
424 // member name "onmouseover" is on the window's prototype
425 // so let's add the listener "mouseover", which is all lowercased
426 memberName = ln.slice(2);
427 }
428 else {
429 // custom event
430 // the JSX attribute could have been "onMyCustomEvent"
431 // so let's trim off the "on" prefix and lowercase the first character
432 // and add the listener "myCustomEvent"
433 // except for the first character, we keep the event name case
434 memberName = ln[2] + memberName.slice(3);
435 }
436 if (oldValue) {
437 plt.rel(elm, memberName, oldValue, false);
438 }
439 if (newValue) {
440 plt.ael(elm, memberName, newValue, false);
441 }
442 }
443 else {
444 // Set property if it exists and it's not a SVG
445 const isComplex = isComplexType(newValue);
446 if ((isProp || (isComplex && newValue !== null)) && !isSvg) {
447 try {
448 if (!elm.tagName.includes('-')) {
449 let n = newValue == null ? '' : newValue;
450 // Workaround for Safari, moving the <input> caret when re-assigning the same valued
451 if (memberName === 'list') {
452 isProp = false;
453 // tslint:disable-next-line: triple-equals
454 }
455 else if (oldValue == null || elm[memberName] != n) {
456 elm[memberName] = n;
457 }
458 }
459 else {
460 elm[memberName] = newValue;
461 }
462 }
463 catch (e) { }
464 }
465 /**
466 * Need to manually update attribute if:
467 * - memberName is not an attribute
468 * - if we are rendering the host element in order to reflect attribute
469 * - if it's a SVG, since properties might not work in <svg>
470 * - if the newValue is null/undefined or 'false'.
471 */
472 let xlink = false;
473 {
474 if (ln !== (ln = ln.replace(/^xlink\:?/, ''))) {
475 memberName = ln;
476 xlink = true;
477 }
478 }
479 if (newValue == null || newValue === false) {
480 if (newValue !== false || elm.getAttribute(memberName) === '') {
481 if (xlink) {
482 elm.removeAttributeNS(XLINK_NS, memberName);
483 }
484 else {
485 elm.removeAttribute(memberName);
486 }
487 }
488 }
489 else if ((!isProp || flags & 4 /* isHost */ || isSvg) && !isComplex) {
490 newValue = newValue === true ? '' : newValue;
491 if (xlink) {
492 elm.setAttributeNS(XLINK_NS, memberName, newValue);
493 }
494 else {
495 elm.setAttribute(memberName, newValue);
496 }
497 }
498 }
499 }
500};
501const parseClassListRegex = /\s/;
502const parseClassList = (value) => (!value ? [] : value.split(parseClassListRegex));
503const updateElement = (oldVnode, newVnode, isSvgMode, memberName) => {
504 // if the element passed in is a shadow root, which is a document fragment
505 // then we want to be adding attrs/props to the shadow root's "host" element
506 // if it's not a shadow root, then we add attrs/props to the same element
507 const elm = newVnode.$elm$.nodeType === 11 /* DocumentFragment */ && newVnode.$elm$.host ? newVnode.$elm$.host : newVnode.$elm$;
508 const oldVnodeAttrs = (oldVnode && oldVnode.$attrs$) || EMPTY_OBJ;
509 const newVnodeAttrs = newVnode.$attrs$ || EMPTY_OBJ;
510 {
511 // remove attributes no longer present on the vnode by setting them to undefined
512 for (memberName in oldVnodeAttrs) {
513 if (!(memberName in newVnodeAttrs)) {
514 setAccessor(elm, memberName, oldVnodeAttrs[memberName], undefined, isSvgMode, newVnode.$flags$);
515 }
516 }
517 }
518 // add new & update changed attributes
519 for (memberName in newVnodeAttrs) {
520 setAccessor(elm, memberName, oldVnodeAttrs[memberName], newVnodeAttrs[memberName], isSvgMode, newVnode.$flags$);
521 }
522};
523const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
524 // tslint:disable-next-line: prefer-const
525 let newVNode = newParentVNode.$children$[childIndex];
526 let i = 0;
527 let elm;
528 let childNode;
529 let oldVNode;
530 if (!useNativeShadowDom) {
531 // remember for later we need to check to relocate nodes
532 checkSlotRelocate = true;
533 if (newVNode.$tag$ === 'slot') {
534 if (scopeId) {
535 // scoped css needs to add its scoped id to the parent element
536 parentElm.classList.add(scopeId + '-s');
537 }
538 newVNode.$flags$ |= newVNode.$children$
539 ? // slot element has fallback content
540 2 /* isSlotFallback */
541 : // slot element does not have fallback content
542 1 /* isSlotReference */;
543 }
544 }
545 if (newVNode.$text$ !== null) {
546 // create text node
547 elm = newVNode.$elm$ = doc.createTextNode(newVNode.$text$);
548 }
549 else if (newVNode.$flags$ & 1 /* isSlotReference */) {
550 // create a slot reference node
551 elm = newVNode.$elm$ = doc.createTextNode('');
552 }
553 else {
554 if (!isSvgMode) {
555 isSvgMode = newVNode.$tag$ === 'svg';
556 }
557 // create element
558 elm = newVNode.$elm$ = (doc.createElementNS(isSvgMode ? SVG_NS : HTML_NS, newVNode.$flags$ & 2 /* isSlotFallback */ ? 'slot-fb' : newVNode.$tag$)
559 );
560 if (isSvgMode && newVNode.$tag$ === 'foreignObject') {
561 isSvgMode = false;
562 }
563 // add css classes, attrs, props, listeners, etc.
564 {
565 updateElement(null, newVNode, isSvgMode);
566 }
567 if (isDef(scopeId) && elm['s-si'] !== scopeId) {
568 // if there is a scopeId and this is the initial render
569 // then let's add the scopeId as a css class
570 elm.classList.add((elm['s-si'] = scopeId));
571 }
572 if (newVNode.$children$) {
573 for (i = 0; i < newVNode.$children$.length; ++i) {
574 // create the node
575 childNode = createElm(oldParentVNode, newVNode, i, elm);
576 // return node could have been null
577 if (childNode) {
578 // append our new node
579 elm.appendChild(childNode);
580 }
581 }
582 }
583 {
584 if (newVNode.$tag$ === 'svg') {
585 // Only reset the SVG context when we're exiting <svg> element
586 isSvgMode = false;
587 }
588 else if (elm.tagName === 'foreignObject') {
589 // Reenter SVG context when we're exiting <foreignObject> element
590 isSvgMode = true;
591 }
592 }
593 }
594 {
595 elm['s-hn'] = hostTagName;
596 if (newVNode.$flags$ & (2 /* isSlotFallback */ | 1 /* isSlotReference */)) {
597 // remember the content reference comment
598 elm['s-sr'] = true;
599 // remember the content reference comment
600 elm['s-cr'] = contentRef;
601 // remember the slot name, or empty string for default slot
602 elm['s-sn'] = newVNode.$name$ || '';
603 // check if we've got an old vnode for this slot
604 oldVNode = oldParentVNode && oldParentVNode.$children$ && oldParentVNode.$children$[childIndex];
605 if (oldVNode && oldVNode.$tag$ === newVNode.$tag$ && oldParentVNode.$elm$) {
606 // we've got an old slot vnode and the wrapper is being replaced
607 // so let's move the old slot content back to it's original location
608 putBackInOriginalLocation(oldParentVNode.$elm$, false);
609 }
610 }
611 }
612 return elm;
613};
614const putBackInOriginalLocation = (parentElm, recursive) => {
615 plt.$flags$ |= 1 /* isTmpDisconnected */;
616 const oldSlotChildNodes = parentElm.childNodes;
617 for (let i = oldSlotChildNodes.length - 1; i >= 0; i--) {
618 const childNode = oldSlotChildNodes[i];
619 if (childNode['s-hn'] !== hostTagName && childNode['s-ol']) {
620 // // this child node in the old element is from another component
621 // // remove this node from the old slot's parent
622 // childNode.remove();
623 // and relocate it back to it's original location
624 parentReferenceNode(childNode).insertBefore(childNode, referenceNode(childNode));
625 // remove the old original location comment entirely
626 // later on the patch function will know what to do
627 // and move this to the correct spot in need be
628 childNode['s-ol'].remove();
629 childNode['s-ol'] = undefined;
630 checkSlotRelocate = true;
631 }
632 if (recursive) {
633 putBackInOriginalLocation(childNode, recursive);
634 }
635 }
636 plt.$flags$ &= ~1 /* isTmpDisconnected */;
637};
638const addVnodes = (parentElm, before, parentVNode, vnodes, startIdx, endIdx) => {
639 let containerElm = ((parentElm['s-cr'] && parentElm['s-cr'].parentNode) || parentElm);
640 let childNode;
641 if (containerElm.shadowRoot && containerElm.tagName === hostTagName) {
642 containerElm = containerElm.shadowRoot;
643 }
644 for (; startIdx <= endIdx; ++startIdx) {
645 if (vnodes[startIdx]) {
646 childNode = createElm(null, parentVNode, startIdx, parentElm);
647 if (childNode) {
648 vnodes[startIdx].$elm$ = childNode;
649 containerElm.insertBefore(childNode, referenceNode(before) );
650 }
651 }
652 }
653};
654const removeVnodes = (vnodes, startIdx, endIdx, vnode, elm) => {
655 for (; startIdx <= endIdx; ++startIdx) {
656 if ((vnode = vnodes[startIdx])) {
657 elm = vnode.$elm$;
658 callNodeRefs(vnode);
659 {
660 // we're removing this element
661 // so it's possible we need to show slot fallback content now
662 checkSlotFallbackVisibility = true;
663 if (elm['s-ol']) {
664 // remove the original location comment
665 elm['s-ol'].remove();
666 }
667 else {
668 // it's possible that child nodes of the node
669 // that's being removed are slot nodes
670 putBackInOriginalLocation(elm, true);
671 }
672 }
673 // remove the vnode's element from the dom
674 elm.remove();
675 }
676 }
677};
678const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
679 let oldStartIdx = 0;
680 let newStartIdx = 0;
681 let idxInOld = 0;
682 let i = 0;
683 let oldEndIdx = oldCh.length - 1;
684 let oldStartVnode = oldCh[0];
685 let oldEndVnode = oldCh[oldEndIdx];
686 let newEndIdx = newCh.length - 1;
687 let newStartVnode = newCh[0];
688 let newEndVnode = newCh[newEndIdx];
689 let node;
690 let elmToMove;
691 while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
692 if (oldStartVnode == null) {
693 // Vnode might have been moved left
694 oldStartVnode = oldCh[++oldStartIdx];
695 }
696 else if (oldEndVnode == null) {
697 oldEndVnode = oldCh[--oldEndIdx];
698 }
699 else if (newStartVnode == null) {
700 newStartVnode = newCh[++newStartIdx];
701 }
702 else if (newEndVnode == null) {
703 newEndVnode = newCh[--newEndIdx];
704 }
705 else if (isSameVnode(oldStartVnode, newStartVnode)) {
706 patch(oldStartVnode, newStartVnode);
707 oldStartVnode = oldCh[++oldStartIdx];
708 newStartVnode = newCh[++newStartIdx];
709 }
710 else if (isSameVnode(oldEndVnode, newEndVnode)) {
711 patch(oldEndVnode, newEndVnode);
712 oldEndVnode = oldCh[--oldEndIdx];
713 newEndVnode = newCh[--newEndIdx];
714 }
715 else if (isSameVnode(oldStartVnode, newEndVnode)) {
716 // Vnode moved right
717 if ((oldStartVnode.$tag$ === 'slot' || newEndVnode.$tag$ === 'slot')) {
718 putBackInOriginalLocation(oldStartVnode.$elm$.parentNode, false);
719 }
720 patch(oldStartVnode, newEndVnode);
721 parentElm.insertBefore(oldStartVnode.$elm$, oldEndVnode.$elm$.nextSibling);
722 oldStartVnode = oldCh[++oldStartIdx];
723 newEndVnode = newCh[--newEndIdx];
724 }
725 else if (isSameVnode(oldEndVnode, newStartVnode)) {
726 // Vnode moved left
727 if ((oldStartVnode.$tag$ === 'slot' || newEndVnode.$tag$ === 'slot')) {
728 putBackInOriginalLocation(oldEndVnode.$elm$.parentNode, false);
729 }
730 patch(oldEndVnode, newStartVnode);
731 parentElm.insertBefore(oldEndVnode.$elm$, oldStartVnode.$elm$);
732 oldEndVnode = oldCh[--oldEndIdx];
733 newStartVnode = newCh[++newStartIdx];
734 }
735 else {
736 // createKeyToOldIdx
737 idxInOld = -1;
738 {
739 for (i = oldStartIdx; i <= oldEndIdx; ++i) {
740 if (oldCh[i] && oldCh[i].$key$ !== null && oldCh[i].$key$ === newStartVnode.$key$) {
741 idxInOld = i;
742 break;
743 }
744 }
745 }
746 if (idxInOld >= 0) {
747 elmToMove = oldCh[idxInOld];
748 if (elmToMove.$tag$ !== newStartVnode.$tag$) {
749 node = createElm(oldCh && oldCh[newStartIdx], newVNode, idxInOld, parentElm);
750 }
751 else {
752 patch(elmToMove, newStartVnode);
753 oldCh[idxInOld] = undefined;
754 node = elmToMove.$elm$;
755 }
756 newStartVnode = newCh[++newStartIdx];
757 }
758 else {
759 // new element
760 node = createElm(oldCh && oldCh[newStartIdx], newVNode, newStartIdx, parentElm);
761 newStartVnode = newCh[++newStartIdx];
762 }
763 if (node) {
764 {
765 parentReferenceNode(oldStartVnode.$elm$).insertBefore(node, referenceNode(oldStartVnode.$elm$));
766 }
767 }
768 }
769 }
770 if (oldStartIdx > oldEndIdx) {
771 addVnodes(parentElm, newCh[newEndIdx + 1] == null ? null : newCh[newEndIdx + 1].$elm$, newVNode, newCh, newStartIdx, newEndIdx);
772 }
773 else if (newStartIdx > newEndIdx) {
774 removeVnodes(oldCh, oldStartIdx, oldEndIdx);
775 }
776};
777const isSameVnode = (vnode1, vnode2) => {
778 // compare if two vnode to see if they're "technically" the same
779 // need to have the same element tag, and same key to be the same
780 if (vnode1.$tag$ === vnode2.$tag$) {
781 if (vnode1.$tag$ === 'slot') {
782 return vnode1.$name$ === vnode2.$name$;
783 }
784 {
785 return vnode1.$key$ === vnode2.$key$;
786 }
787 }
788 return false;
789};
790const referenceNode = (node) => {
791 // this node was relocated to a new location in the dom
792 // because of some other component's slot
793 // but we still have an html comment in place of where
794 // it's original location was according to it's original vdom
795 return (node && node['s-ol']) || node;
796};
797const parentReferenceNode = (node) => (node['s-ol'] ? node['s-ol'] : node).parentNode;
798const patch = (oldVNode, newVNode) => {
799 const elm = (newVNode.$elm$ = oldVNode.$elm$);
800 const oldChildren = oldVNode.$children$;
801 const newChildren = newVNode.$children$;
802 const tag = newVNode.$tag$;
803 const text = newVNode.$text$;
804 let defaultHolder;
805 if (text === null) {
806 {
807 // test if we're rendering an svg element, or still rendering nodes inside of one
808 // only add this to the when the compiler sees we're using an svg somewhere
809 isSvgMode = tag === 'svg' ? true : tag === 'foreignObject' ? false : isSvgMode;
810 }
811 // element node
812 {
813 if (tag === 'slot')
814 ;
815 else {
816 // either this is the first render of an element OR it's an update
817 // AND we already know it's possible it could have changed
818 // this updates the element's css classes, attrs, props, listeners, etc.
819 updateElement(oldVNode, newVNode, isSvgMode);
820 }
821 }
822 if (oldChildren !== null && newChildren !== null) {
823 // looks like there's child vnodes for both the old and new vnodes
824 updateChildren(elm, oldChildren, newVNode, newChildren);
825 }
826 else if (newChildren !== null) {
827 // no old child vnodes, but there are new child vnodes to add
828 if (oldVNode.$text$ !== null) {
829 // the old vnode was text, so be sure to clear it out
830 elm.textContent = '';
831 }
832 // add the new vnode children
833 addVnodes(elm, null, newVNode, newChildren, 0, newChildren.length - 1);
834 }
835 else if (oldChildren !== null) {
836 // no new child vnodes, but there are old child vnodes to remove
837 removeVnodes(oldChildren, 0, oldChildren.length - 1);
838 }
839 if (isSvgMode && tag === 'svg') {
840 isSvgMode = false;
841 }
842 }
843 else if ((defaultHolder = elm['s-cr'])) {
844 // this element has slotted content
845 defaultHolder.parentNode.textContent = text;
846 }
847 else if (oldVNode.$text$ !== text) {
848 // update the text content for the text only vnode
849 // and also only if the text is different than before
850 elm.data = text;
851 }
852};
853const updateFallbackSlotVisibility = (elm) => {
854 // tslint:disable-next-line: prefer-const
855 let childNodes = elm.childNodes;
856 let childNode;
857 let i;
858 let ilen;
859 let j;
860 let slotNameAttr;
861 let nodeType;
862 for (i = 0, ilen = childNodes.length; i < ilen; i++) {
863 childNode = childNodes[i];
864 if (childNode.nodeType === 1 /* ElementNode */) {
865 if (childNode['s-sr']) {
866 // this is a slot fallback node
867 // get the slot name for this slot reference node
868 slotNameAttr = childNode['s-sn'];
869 // by default always show a fallback slot node
870 // then hide it if there are other slots in the light dom
871 childNode.hidden = false;
872 for (j = 0; j < ilen; j++) {
873 nodeType = childNodes[j].nodeType;
874 if (childNodes[j]['s-hn'] !== childNode['s-hn'] || slotNameAttr !== '') {
875 // this sibling node is from a different component OR is a named fallback slot node
876 if (nodeType === 1 /* ElementNode */ && slotNameAttr === childNodes[j].getAttribute('slot')) {
877 childNode.hidden = true;
878 break;
879 }
880 }
881 else {
882 // this is a default fallback slot node
883 // any element or text node (with content)
884 // should hide the default fallback slot node
885 if (nodeType === 1 /* ElementNode */ ||
886 (nodeType === 3 /* TextNode */ && childNodes[j].textContent.trim() !== '')) {
887 childNode.hidden = true;
888 break;
889 }
890 }
891 }
892 }
893 // keep drilling down
894 updateFallbackSlotVisibility(childNode);
895 }
896 }
897};
898const relocateNodes = [];
899const relocateSlotContent = (elm) => {
900 // tslint:disable-next-line: prefer-const
901 let childNode;
902 let node;
903 let hostContentNodes;
904 let slotNameAttr;
905 let relocateNodeData;
906 let j;
907 let i = 0;
908 let childNodes = elm.childNodes;
909 let ilen = childNodes.length;
910 for (; i < ilen; i++) {
911 childNode = childNodes[i];
912 if (childNode['s-sr'] && (node = childNode['s-cr']) && node.parentNode) {
913 // first got the content reference comment node
914 // then we got it's parent, which is where all the host content is in now
915 hostContentNodes = node.parentNode.childNodes;
916 slotNameAttr = childNode['s-sn'];
917 for (j = hostContentNodes.length - 1; j >= 0; j--) {
918 node = hostContentNodes[j];
919 if (!node['s-cn'] && !node['s-nr'] && node['s-hn'] !== childNode['s-hn']) {
920 // let's do some relocating to its new home
921 // but never relocate a content reference node
922 // that is suppose to always represent the original content location
923 if (isNodeLocatedInSlot(node, slotNameAttr)) {
924 // it's possible we've already decided to relocate this node
925 relocateNodeData = relocateNodes.find(r => r.$nodeToRelocate$ === node);
926 // made some changes to slots
927 // let's make sure we also double check
928 // fallbacks are correctly hidden or shown
929 checkSlotFallbackVisibility = true;
930 node['s-sn'] = node['s-sn'] || slotNameAttr;
931 if (relocateNodeData) {
932 // previously we never found a slot home for this node
933 // but turns out we did, so let's remember it now
934 relocateNodeData.$slotRefNode$ = childNode;
935 }
936 else {
937 // add to our list of nodes to relocate
938 relocateNodes.push({
939 $slotRefNode$: childNode,
940 $nodeToRelocate$: node,
941 });
942 }
943 if (node['s-sr']) {
944 relocateNodes.map(relocateNode => {
945 if (isNodeLocatedInSlot(relocateNode.$nodeToRelocate$, node['s-sn'])) {
946 relocateNodeData = relocateNodes.find(r => r.$nodeToRelocate$ === node);
947 if (relocateNodeData && !relocateNode.$slotRefNode$) {
948 relocateNode.$slotRefNode$ = relocateNodeData.$slotRefNode$;
949 }
950 }
951 });
952 }
953 }
954 else if (!relocateNodes.some(r => r.$nodeToRelocate$ === node)) {
955 // so far this element does not have a slot home, not setting slotRefNode on purpose
956 // if we never find a home for this element then we'll need to hide it
957 relocateNodes.push({
958 $nodeToRelocate$: node,
959 });
960 }
961 }
962 }
963 }
964 if (childNode.nodeType === 1 /* ElementNode */) {
965 relocateSlotContent(childNode);
966 }
967 }
968};
969const isNodeLocatedInSlot = (nodeToRelocate, slotNameAttr) => {
970 if (nodeToRelocate.nodeType === 1 /* ElementNode */) {
971 if (nodeToRelocate.getAttribute('slot') === null && slotNameAttr === '') {
972 return true;
973 }
974 if (nodeToRelocate.getAttribute('slot') === slotNameAttr) {
975 return true;
976 }
977 return false;
978 }
979 if (nodeToRelocate['s-sn'] === slotNameAttr) {
980 return true;
981 }
982 return slotNameAttr === '';
983};
984const callNodeRefs = (vNode) => {
985 {
986 vNode.$attrs$ && vNode.$attrs$.ref && vNode.$attrs$.ref(null);
987 vNode.$children$ && vNode.$children$.map(callNodeRefs);
988 }
989};
990const renderVdom = (hostRef, renderFnResults) => {
991 const hostElm = hostRef.$hostElement$;
992 const cmpMeta = hostRef.$cmpMeta$;
993 const oldVNode = hostRef.$vnode$ || newVNode(null, null);
994 const rootVnode = isHost(renderFnResults) ? renderFnResults : h(null, null, renderFnResults);
995 hostTagName = hostElm.tagName;
996 if (cmpMeta.$attrsToReflect$) {
997 rootVnode.$attrs$ = rootVnode.$attrs$ || {};
998 cmpMeta.$attrsToReflect$.map(([propName, attribute]) => (rootVnode.$attrs$[attribute] = hostElm[propName]));
999 }
1000 rootVnode.$tag$ = null;
1001 rootVnode.$flags$ |= 4 /* isHost */;
1002 hostRef.$vnode$ = rootVnode;
1003 rootVnode.$elm$ = oldVNode.$elm$ = (hostElm.shadowRoot || hostElm );
1004 {
1005 scopeId = hostElm['s-sc'];
1006 }
1007 {
1008 contentRef = hostElm['s-cr'];
1009 useNativeShadowDom = supportsShadow && (cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) !== 0;
1010 // always reset
1011 checkSlotFallbackVisibility = false;
1012 }
1013 // synchronous patch
1014 patch(oldVNode, rootVnode);
1015 {
1016 // while we're moving nodes around existing nodes, temporarily disable
1017 // the disconnectCallback from working
1018 plt.$flags$ |= 1 /* isTmpDisconnected */;
1019 if (checkSlotRelocate) {
1020 relocateSlotContent(rootVnode.$elm$);
1021 let relocateData;
1022 let nodeToRelocate;
1023 let orgLocationNode;
1024 let parentNodeRef;
1025 let insertBeforeNode;
1026 let refNode;
1027 let i = 0;
1028 for (; i < relocateNodes.length; i++) {
1029 relocateData = relocateNodes[i];
1030 nodeToRelocate = relocateData.$nodeToRelocate$;
1031 if (!nodeToRelocate['s-ol']) {
1032 // add a reference node marking this node's original location
1033 // keep a reference to this node for later lookups
1034 orgLocationNode = doc.createTextNode('');
1035 orgLocationNode['s-nr'] = nodeToRelocate;
1036 nodeToRelocate.parentNode.insertBefore((nodeToRelocate['s-ol'] = orgLocationNode), nodeToRelocate);
1037 }
1038 }
1039 for (i = 0; i < relocateNodes.length; i++) {
1040 relocateData = relocateNodes[i];
1041 nodeToRelocate = relocateData.$nodeToRelocate$;
1042 if (relocateData.$slotRefNode$) {
1043 // by default we're just going to insert it directly
1044 // after the slot reference node
1045 parentNodeRef = relocateData.$slotRefNode$.parentNode;
1046 insertBeforeNode = relocateData.$slotRefNode$.nextSibling;
1047 orgLocationNode = nodeToRelocate['s-ol'];
1048 while ((orgLocationNode = orgLocationNode.previousSibling)) {
1049 refNode = orgLocationNode['s-nr'];
1050 if (refNode && refNode['s-sn'] === nodeToRelocate['s-sn'] && parentNodeRef === refNode.parentNode) {
1051 refNode = refNode.nextSibling;
1052 if (!refNode || !refNode['s-nr']) {
1053 insertBeforeNode = refNode;
1054 break;
1055 }
1056 }
1057 }
1058 if ((!insertBeforeNode && parentNodeRef !== nodeToRelocate.parentNode) || nodeToRelocate.nextSibling !== insertBeforeNode) {
1059 // we've checked that it's worth while to relocate
1060 // since that the node to relocate
1061 // has a different next sibling or parent relocated
1062 if (nodeToRelocate !== insertBeforeNode) {
1063 if (!nodeToRelocate['s-hn'] && nodeToRelocate['s-ol']) {
1064 // probably a component in the index.html that doesn't have it's hostname set
1065 nodeToRelocate['s-hn'] = nodeToRelocate['s-ol'].parentNode.nodeName;
1066 }
1067 // add it back to the dom but in its new home
1068 parentNodeRef.insertBefore(nodeToRelocate, insertBeforeNode);
1069 }
1070 }
1071 }
1072 else {
1073 // this node doesn't have a slot home to go to, so let's hide it
1074 if (nodeToRelocate.nodeType === 1 /* ElementNode */) {
1075 nodeToRelocate.hidden = true;
1076 }
1077 }
1078 }
1079 }
1080 if (checkSlotFallbackVisibility) {
1081 updateFallbackSlotVisibility(rootVnode.$elm$);
1082 }
1083 // done moving nodes around
1084 // allow the disconnect callback to work again
1085 plt.$flags$ &= ~1 /* isTmpDisconnected */;
1086 // always reset
1087 relocateNodes.length = 0;
1088 }
1089};
1090const getElement = (ref) => (getHostRef(ref).$hostElement$ );
1091const createEvent = (ref, name, flags) => {
1092 const elm = getElement(ref);
1093 return {
1094 emit: (detail) => {
1095 return emitEvent(elm, name, {
1096 bubbles: !!(flags & 4 /* Bubbles */),
1097 composed: !!(flags & 2 /* Composed */),
1098 cancelable: !!(flags & 1 /* Cancellable */),
1099 detail,
1100 });
1101 },
1102 };
1103};
1104const emitEvent = (elm, name, opts) => {
1105 const ev = plt.ce(name, opts);
1106 elm.dispatchEvent(ev);
1107 return ev;
1108};
1109const attachToAncestor = (hostRef, ancestorComponent) => {
1110 if (ancestorComponent && !hostRef.$onRenderResolve$ && ancestorComponent['s-p']) {
1111 ancestorComponent['s-p'].push(new Promise(r => (hostRef.$onRenderResolve$ = r)));
1112 }
1113};
1114const scheduleUpdate = (hostRef, isInitialLoad) => {
1115 {
1116 hostRef.$flags$ |= 16 /* isQueuedForUpdate */;
1117 }
1118 if (hostRef.$flags$ & 4 /* isWaitingForChildren */) {
1119 hostRef.$flags$ |= 512 /* needsRerender */;
1120 return;
1121 }
1122 attachToAncestor(hostRef, hostRef.$ancestorComponent$);
1123 // there is no ancestor component or the ancestor component
1124 // has already fired off its lifecycle update then
1125 // fire off the initial update
1126 const dispatch = () => dispatchHooks(hostRef, isInitialLoad);
1127 return writeTask(dispatch) ;
1128};
1129const dispatchHooks = (hostRef, isInitialLoad) => {
1130 const endSchedule = createTime('scheduleUpdate', hostRef.$cmpMeta$.$tagName$);
1131 const instance = hostRef.$lazyInstance$ ;
1132 let promise;
1133 if (isInitialLoad) {
1134 {
1135 hostRef.$flags$ |= 256 /* isListenReady */;
1136 if (hostRef.$queuedListeners$) {
1137 hostRef.$queuedListeners$.map(([methodName, event]) => safeCall(instance, methodName, event));
1138 hostRef.$queuedListeners$ = null;
1139 }
1140 }
1141 {
1142 promise = safeCall(instance, 'componentWillLoad');
1143 }
1144 }
1145 {
1146 promise = then(promise, () => safeCall(instance, 'componentWillRender'));
1147 }
1148 endSchedule();
1149 return then(promise, () => updateComponent(hostRef, instance, isInitialLoad));
1150};
1151const updateComponent = async (hostRef, instance, isInitialLoad) => {
1152 // updateComponent
1153 const elm = hostRef.$hostElement$;
1154 const endUpdate = createTime('update', hostRef.$cmpMeta$.$tagName$);
1155 const rc = elm['s-rc'];
1156 if (isInitialLoad) {
1157 // DOM WRITE!
1158 attachStyles(hostRef);
1159 }
1160 const endRender = createTime('render', hostRef.$cmpMeta$.$tagName$);
1161 {
1162 callRender(hostRef, instance);
1163 }
1164 if (plt.$cssShim$) {
1165 plt.$cssShim$.updateHost(elm);
1166 }
1167 if (rc) {
1168 // ok, so turns out there are some child host elements
1169 // waiting on this parent element to load
1170 // let's fire off all update callbacks waiting
1171 rc.map(cb => cb());
1172 elm['s-rc'] = undefined;
1173 }
1174 endRender();
1175 endUpdate();
1176 {
1177 const childrenPromises = elm['s-p'];
1178 const postUpdate = () => postUpdateComponent(hostRef);
1179 if (childrenPromises.length === 0) {
1180 postUpdate();
1181 }
1182 else {
1183 Promise.all(childrenPromises).then(postUpdate);
1184 hostRef.$flags$ |= 4 /* isWaitingForChildren */;
1185 childrenPromises.length = 0;
1186 }
1187 }
1188};
1189const callRender = (hostRef, instance, elm) => {
1190 try {
1191 instance = instance.render && instance.render();
1192 {
1193 hostRef.$flags$ &= ~16 /* isQueuedForUpdate */;
1194 }
1195 {
1196 hostRef.$flags$ |= 2 /* hasRendered */;
1197 }
1198 {
1199 {
1200 // looks like we've got child nodes to render into this host element
1201 // or we need to update the css class/attrs on the host element
1202 // DOM WRITE!
1203 {
1204 renderVdom(hostRef, instance);
1205 }
1206 }
1207 }
1208 }
1209 catch (e) {
1210 consoleError(e, hostRef.$hostElement$);
1211 }
1212 return null;
1213};
1214const postUpdateComponent = (hostRef) => {
1215 const tagName = hostRef.$cmpMeta$.$tagName$;
1216 const elm = hostRef.$hostElement$;
1217 const endPostUpdate = createTime('postUpdate', tagName);
1218 const instance = hostRef.$lazyInstance$ ;
1219 const ancestorComponent = hostRef.$ancestorComponent$;
1220 if (!(hostRef.$flags$ & 64 /* hasLoadedComponent */)) {
1221 hostRef.$flags$ |= 64 /* hasLoadedComponent */;
1222 {
1223 // DOM WRITE!
1224 addHydratedFlag(elm);
1225 }
1226 {
1227 safeCall(instance, 'componentDidLoad');
1228 }
1229 endPostUpdate();
1230 {
1231 hostRef.$onReadyResolve$(elm);
1232 if (!ancestorComponent) {
1233 appDidLoad();
1234 }
1235 }
1236 }
1237 else {
1238 {
1239 safeCall(instance, 'componentDidUpdate');
1240 }
1241 endPostUpdate();
1242 }
1243 {
1244 hostRef.$onInstanceResolve$(elm);
1245 }
1246 // load events fire from bottom to top
1247 // the deepest elements load first then bubbles up
1248 {
1249 if (hostRef.$onRenderResolve$) {
1250 hostRef.$onRenderResolve$();
1251 hostRef.$onRenderResolve$ = undefined;
1252 }
1253 if (hostRef.$flags$ & 512 /* needsRerender */) {
1254 nextTick(() => scheduleUpdate(hostRef, false));
1255 }
1256 hostRef.$flags$ &= ~(4 /* isWaitingForChildren */ | 512 /* needsRerender */);
1257 }
1258 // ( •_•)
1259 // ( •_•)>⌐■-■
1260 // (⌐■_■)
1261};
1262const forceUpdate = (ref) => {
1263 {
1264 const hostRef = getHostRef(ref);
1265 const isConnected = hostRef.$hostElement$.isConnected;
1266 if (isConnected && (hostRef.$flags$ & (2 /* hasRendered */ | 16 /* isQueuedForUpdate */)) === 2 /* hasRendered */) {
1267 scheduleUpdate(hostRef, false);
1268 }
1269 // Returns "true" when the forced update was successfully scheduled
1270 return isConnected;
1271 }
1272};
1273const appDidLoad = (who) => {
1274 // on appload
1275 // we have finish the first big initial render
1276 {
1277 addHydratedFlag(doc.documentElement);
1278 }
1279 nextTick(() => emitEvent(win, 'appload', { detail: { namespace: NAMESPACE } }));
1280};
1281const safeCall = (instance, method, arg) => {
1282 if (instance && instance[method]) {
1283 try {
1284 return instance[method](arg);
1285 }
1286 catch (e) {
1287 consoleError(e);
1288 }
1289 }
1290 return undefined;
1291};
1292const then = (promise, thenFn) => {
1293 return promise && promise.then ? promise.then(thenFn) : thenFn();
1294};
1295const addHydratedFlag = (elm) => (elm.classList.add('hydrated') );
1296const initializeClientHydrate = (hostElm, tagName, hostId, hostRef) => {
1297 const endHydrate = createTime('hydrateClient', tagName);
1298 const shadowRoot = hostElm.shadowRoot;
1299 const childRenderNodes = [];
1300 const slotNodes = [];
1301 const shadowRootNodes = shadowRoot ? [] : null;
1302 const vnode = (hostRef.$vnode$ = newVNode(tagName, null));
1303 if (!plt.$orgLocNodes$) {
1304 initializeDocumentHydrate(doc.body, (plt.$orgLocNodes$ = new Map()));
1305 }
1306 hostElm[HYDRATE_ID] = hostId;
1307 hostElm.removeAttribute(HYDRATE_ID);
1308 clientHydrate(vnode, childRenderNodes, slotNodes, shadowRootNodes, hostElm, hostElm, hostId);
1309 childRenderNodes.map(c => {
1310 const orgLocationId = c.$hostId$ + '.' + c.$nodeId$;
1311 const orgLocationNode = plt.$orgLocNodes$.get(orgLocationId);
1312 const node = c.$elm$;
1313 if (orgLocationNode && supportsShadow && orgLocationNode['s-en'] === '') {
1314 orgLocationNode.parentNode.insertBefore(node, orgLocationNode.nextSibling);
1315 }
1316 if (!shadowRoot) {
1317 node['s-hn'] = tagName;
1318 if (orgLocationNode) {
1319 node['s-ol'] = orgLocationNode;
1320 node['s-ol']['s-nr'] = node;
1321 }
1322 }
1323 plt.$orgLocNodes$.delete(orgLocationId);
1324 });
1325 if (shadowRoot) {
1326 shadowRootNodes.map(shadowRootNode => {
1327 if (shadowRootNode) {
1328 shadowRoot.appendChild(shadowRootNode);
1329 }
1330 });
1331 }
1332 endHydrate();
1333};
1334const clientHydrate = (parentVNode, childRenderNodes, slotNodes, shadowRootNodes, hostElm, node, hostId) => {
1335 let childNodeType;
1336 let childIdSplt;
1337 let childVNode;
1338 let i;
1339 if (node.nodeType === 1 /* ElementNode */) {
1340 childNodeType = node.getAttribute(HYDRATE_CHILD_ID);
1341 if (childNodeType) {
1342 // got the node data from the element's attribute
1343 // `${hostId}.${nodeId}.${depth}.${index}`
1344 childIdSplt = childNodeType.split('.');
1345 if (childIdSplt[0] === hostId || childIdSplt[0] === '0') {
1346 childVNode = {
1347 $flags$: 0,
1348 $hostId$: childIdSplt[0],
1349 $nodeId$: childIdSplt[1],
1350 $depth$: childIdSplt[2],
1351 $index$: childIdSplt[3],
1352 $tag$: node.tagName.toLowerCase(),
1353 $elm$: node,
1354 $attrs$: null,
1355 $children$: null,
1356 $key$: null,
1357 $name$: null,
1358 $text$: null,
1359 };
1360 childRenderNodes.push(childVNode);
1361 node.removeAttribute(HYDRATE_CHILD_ID);
1362 // this is a new child vnode
1363 // so ensure its parent vnode has the vchildren array
1364 if (!parentVNode.$children$) {
1365 parentVNode.$children$ = [];
1366 }
1367 // add our child vnode to a specific index of the vnode's children
1368 parentVNode.$children$[childVNode.$index$] = childVNode;
1369 // this is now the new parent vnode for all the next child checks
1370 parentVNode = childVNode;
1371 if (shadowRootNodes && childVNode.$depth$ === '0') {
1372 shadowRootNodes[childVNode.$index$] = childVNode.$elm$;
1373 }
1374 }
1375 }
1376 // recursively drill down, end to start so we can remove nodes
1377 for (i = node.childNodes.length - 1; i >= 0; i--) {
1378 clientHydrate(parentVNode, childRenderNodes, slotNodes, shadowRootNodes, hostElm, node.childNodes[i], hostId);
1379 }
1380 if (node.shadowRoot) {
1381 // keep drilling down through the shadow root nodes
1382 for (i = node.shadowRoot.childNodes.length - 1; i >= 0; i--) {
1383 clientHydrate(parentVNode, childRenderNodes, slotNodes, shadowRootNodes, hostElm, node.shadowRoot.childNodes[i], hostId);
1384 }
1385 }
1386 }
1387 else if (node.nodeType === 8 /* CommentNode */) {
1388 // `${COMMENT_TYPE}.${hostId}.${nodeId}.${depth}.${index}`
1389 childIdSplt = node.nodeValue.split('.');
1390 if (childIdSplt[1] === hostId || childIdSplt[1] === '0') {
1391 // comment node for either the host id or a 0 host id
1392 childNodeType = childIdSplt[0];
1393 childVNode = {
1394 $flags$: 0,
1395 $hostId$: childIdSplt[1],
1396 $nodeId$: childIdSplt[2],
1397 $depth$: childIdSplt[3],
1398 $index$: childIdSplt[4],
1399 $elm$: node,
1400 $attrs$: null,
1401 $children$: null,
1402 $key$: null,
1403 $name$: null,
1404 $tag$: null,
1405 $text$: null,
1406 };
1407 if (childNodeType === TEXT_NODE_ID) {
1408 childVNode.$elm$ = node.nextSibling;
1409 if (childVNode.$elm$ && childVNode.$elm$.nodeType === 3 /* TextNode */) {
1410 childVNode.$text$ = childVNode.$elm$.textContent;
1411 childRenderNodes.push(childVNode);
1412 // remove the text comment since it's no longer needed
1413 node.remove();
1414 if (!parentVNode.$children$) {
1415 parentVNode.$children$ = [];
1416 }
1417 parentVNode.$children$[childVNode.$index$] = childVNode;
1418 if (shadowRootNodes && childVNode.$depth$ === '0') {
1419 shadowRootNodes[childVNode.$index$] = childVNode.$elm$;
1420 }
1421 }
1422 }
1423 else if (childVNode.$hostId$ === hostId) {
1424 // this comment node is specifcally for this host id
1425 if (childNodeType === SLOT_NODE_ID) {
1426 // `${SLOT_NODE_ID}.${hostId}.${nodeId}.${depth}.${index}.${slotName}`;
1427 childVNode.$tag$ = 'slot';
1428 if (childIdSplt[5]) {
1429 node['s-sn'] = childVNode.$name$ = childIdSplt[5];
1430 }
1431 else {
1432 node['s-sn'] = '';
1433 }
1434 node['s-sr'] = true;
1435 if (shadowRootNodes) {
1436 // browser support shadowRoot and this is a shadow dom component
1437 // create an actual slot element
1438 childVNode.$elm$ = doc.createElement(childVNode.$tag$);
1439 if (childVNode.$name$) {
1440 // add the slot name attribute
1441 childVNode.$elm$.setAttribute('name', childVNode.$name$);
1442 }
1443 // insert the new slot element before the slot comment
1444 node.parentNode.insertBefore(childVNode.$elm$, node);
1445 // remove the slot comment since it's not needed for shadow
1446 node.remove();
1447 if (childVNode.$depth$ === '0') {
1448 shadowRootNodes[childVNode.$index$] = childVNode.$elm$;
1449 }
1450 }
1451 slotNodes.push(childVNode);
1452 if (!parentVNode.$children$) {
1453 parentVNode.$children$ = [];
1454 }
1455 parentVNode.$children$[childVNode.$index$] = childVNode;
1456 }
1457 else if (childNodeType === CONTENT_REF_ID) {
1458 // `${CONTENT_REF_ID}.${hostId}`;
1459 if (shadowRootNodes) {
1460 // remove the content ref comment since it's not needed for shadow
1461 node.remove();
1462 }
1463 else {
1464 hostElm['s-cr'] = node;
1465 node['s-cn'] = true;
1466 }
1467 }
1468 }
1469 }
1470 }
1471 else if (parentVNode && parentVNode.$tag$ === 'style') {
1472 const vnode = newVNode(null, node.textContent);
1473 vnode.$elm$ = node;
1474 vnode.$index$ = '0';
1475 parentVNode.$children$ = [vnode];
1476 }
1477};
1478const initializeDocumentHydrate = (node, orgLocNodes) => {
1479 if (node.nodeType === 1 /* ElementNode */) {
1480 let i = 0;
1481 for (; i < node.childNodes.length; i++) {
1482 initializeDocumentHydrate(node.childNodes[i], orgLocNodes);
1483 }
1484 if (node.shadowRoot) {
1485 for (i = 0; i < node.shadowRoot.childNodes.length; i++) {
1486 initializeDocumentHydrate(node.shadowRoot.childNodes[i], orgLocNodes);
1487 }
1488 }
1489 }
1490 else if (node.nodeType === 8 /* CommentNode */) {
1491 const childIdSplt = node.nodeValue.split('.');
1492 if (childIdSplt[0] === ORG_LOCATION_ID) {
1493 orgLocNodes.set(childIdSplt[1] + '.' + childIdSplt[2], node);
1494 node.nodeValue = '';
1495 // useful to know if the original location is
1496 // the root light-dom of a shadow dom component
1497 node['s-en'] = childIdSplt[3];
1498 }
1499 }
1500};
1501const parsePropertyValue = (propValue, propType) => {
1502 // ensure this value is of the correct prop type
1503 if (propValue != null && !isComplexType(propValue)) {
1504 if (propType & 4 /* Boolean */) {
1505 // per the HTML spec, any string value means it is a boolean true value
1506 // but we'll cheat here and say that the string "false" is the boolean false
1507 return propValue === 'false' ? false : propValue === '' || !!propValue;
1508 }
1509 if (propType & 2 /* Number */) {
1510 // force it to be a number
1511 return parseFloat(propValue);
1512 }
1513 if (propType & 1 /* String */) {
1514 // could have been passed as a number or boolean
1515 // but we still want it as a string
1516 return String(propValue);
1517 }
1518 // redundant return here for better minification
1519 return propValue;
1520 }
1521 // not sure exactly what type we want
1522 // so no need to change to a different type
1523 return propValue;
1524};
1525const getValue = (ref, propName) => getHostRef(ref).$instanceValues$.get(propName);
1526const setValue = (ref, propName, newVal, cmpMeta) => {
1527 // check our new property value against our internal value
1528 const hostRef = getHostRef(ref);
1529 const elm = hostRef.$hostElement$ ;
1530 const oldVal = hostRef.$instanceValues$.get(propName);
1531 const flags = hostRef.$flags$;
1532 const instance = hostRef.$lazyInstance$ ;
1533 newVal = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]);
1534 if ((!(flags & 8 /* isConstructingInstance */) || oldVal === undefined) && newVal !== oldVal) {
1535 // gadzooks! the property's value has changed!!
1536 // set our new value!
1537 hostRef.$instanceValues$.set(propName, newVal);
1538 if (instance) {
1539 // get an array of method names of watch functions to call
1540 if (cmpMeta.$watchers$ && flags & 128 /* isWatchReady */) {
1541 const watchMethods = cmpMeta.$watchers$[propName];
1542 if (watchMethods) {
1543 // this instance is watching for when this property changed
1544 watchMethods.map(watchMethodName => {
1545 try {
1546 // fire off each of the watch methods that are watching this property
1547 instance[watchMethodName](newVal, oldVal, propName);
1548 }
1549 catch (e) {
1550 consoleError(e, elm);
1551 }
1552 });
1553 }
1554 }
1555 if ((flags & (2 /* hasRendered */ | 16 /* isQueuedForUpdate */)) === 2 /* hasRendered */) {
1556 // looks like this value actually changed, so we've got work to do!
1557 // but only if we've already rendered, otherwise just chill out
1558 // queue that we need to do an update, but don't worry about queuing
1559 // up millions cuz this function ensures it only runs once
1560 scheduleUpdate(hostRef, false);
1561 }
1562 }
1563 }
1564};
1565const proxyComponent = (Cstr, cmpMeta, flags) => {
1566 if (cmpMeta.$members$) {
1567 if (Cstr.watchers) {
1568 cmpMeta.$watchers$ = Cstr.watchers;
1569 }
1570 // It's better to have a const than two Object.entries()
1571 const members = Object.entries(cmpMeta.$members$);
1572 const prototype = Cstr.prototype;
1573 members.map(([memberName, [memberFlags]]) => {
1574 if ((memberFlags & 31 /* Prop */ || ((flags & 2 /* proxyState */) && memberFlags & 32 /* State */))) {
1575 // proxyComponent - prop
1576 Object.defineProperty(prototype, memberName, {
1577 get() {
1578 // proxyComponent, get value
1579 return getValue(this, memberName);
1580 },
1581 set(newValue) {
1582 // proxyComponent, set value
1583 setValue(this, memberName, newValue, cmpMeta);
1584 },
1585 configurable: true,
1586 enumerable: true,
1587 });
1588 }
1589 else if (flags & 1 /* isElementConstructor */ && memberFlags & 64 /* Method */) {
1590 // proxyComponent - method
1591 Object.defineProperty(prototype, memberName, {
1592 value(...args) {
1593 const ref = getHostRef(this);
1594 return ref.$onInstancePromise$.then(() => ref.$lazyInstance$[memberName](...args));
1595 },
1596 });
1597 }
1598 });
1599 if ((flags & 1 /* isElementConstructor */)) {
1600 const attrNameToPropName = new Map();
1601 prototype.attributeChangedCallback = function (attrName, _oldValue, newValue) {
1602 plt.jmp(() => {
1603 const propName = attrNameToPropName.get(attrName);
1604 this[propName] = newValue === null && typeof this[propName] === 'boolean' ? false : newValue;
1605 });
1606 };
1607 // create an array of attributes to observe
1608 // and also create a map of html attribute name to js property name
1609 Cstr.observedAttributes = members
1610 .filter(([_, m]) => m[0] & 15 /* HasAttribute */) // filter to only keep props that should match attributes
1611 .map(([propName, m]) => {
1612 const attrName = m[1] || propName;
1613 attrNameToPropName.set(attrName, propName);
1614 if (m[0] & 512 /* ReflectAttr */) {
1615 cmpMeta.$attrsToReflect$.push([propName, attrName]);
1616 }
1617 return attrName;
1618 });
1619 }
1620 }
1621 return Cstr;
1622};
1623const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) => {
1624 // initializeComponent
1625 if ((hostRef.$flags$ & 32 /* hasInitializedComponent */) === 0) {
1626 {
1627 // we haven't initialized this element yet
1628 hostRef.$flags$ |= 32 /* hasInitializedComponent */;
1629 // lazy loaded components
1630 // request the component's implementation to be
1631 // wired up with the host element
1632 Cstr = loadModule(cmpMeta);
1633 if (Cstr.then) {
1634 // Await creates a micro-task avoid if possible
1635 const endLoad = uniqueTime();
1636 Cstr = await Cstr;
1637 endLoad();
1638 }
1639 if (!Cstr.isProxied) {
1640 // we'eve never proxied this Constructor before
1641 // let's add the getters/setters to its prototype before
1642 // the first time we create an instance of the implementation
1643 {
1644 cmpMeta.$watchers$ = Cstr.watchers;
1645 }
1646 proxyComponent(Cstr, cmpMeta, 2 /* proxyState */);
1647 Cstr.isProxied = true;
1648 }
1649 const endNewInstance = createTime('createInstance', cmpMeta.$tagName$);
1650 // ok, time to construct the instance
1651 // but let's keep track of when we start and stop
1652 // so that the getters/setters don't incorrectly step on data
1653 {
1654 hostRef.$flags$ |= 8 /* isConstructingInstance */;
1655 }
1656 // construct the lazy-loaded component implementation
1657 // passing the hostRef is very important during
1658 // construction in order to directly wire together the
1659 // host element and the lazy-loaded instance
1660 try {
1661 new Cstr(hostRef);
1662 }
1663 catch (e) {
1664 consoleError(e);
1665 }
1666 {
1667 hostRef.$flags$ &= ~8 /* isConstructingInstance */;
1668 }
1669 {
1670 hostRef.$flags$ |= 128 /* isWatchReady */;
1671 }
1672 endNewInstance();
1673 fireConnectedCallback(hostRef.$lazyInstance$);
1674 }
1675 if (Cstr.style) {
1676 // this component has styles but we haven't registered them yet
1677 let style = Cstr.style;
1678 if (typeof style !== 'string') {
1679 style = style[(hostRef.$modeName$ = computeMode(elm))];
1680 }
1681 const scopeId = getScopeId(cmpMeta, hostRef.$modeName$);
1682 if (!styles.has(scopeId)) {
1683 const endRegisterStyles = createTime('registerStyles', cmpMeta.$tagName$);
1684 if (cmpMeta.$flags$ & 8 /* needsShadowDomShim */) {
1685 style = await Promise.resolve().then(function () { return require('./shadow-css-c4152736.js'); }).then(m => m.scopeCss(style, scopeId, false));
1686 }
1687 registerStyle(scopeId, style, !!(cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */));
1688 endRegisterStyles();
1689 }
1690 }
1691 }
1692 // we've successfully created a lazy instance
1693 const ancestorComponent = hostRef.$ancestorComponent$;
1694 const schedule = () => scheduleUpdate(hostRef, true);
1695 if (ancestorComponent && ancestorComponent['s-rc']) {
1696 // this is the intial load and this component it has an ancestor component
1697 // but the ancestor component has NOT fired its will update lifecycle yet
1698 // so let's just cool our jets and wait for the ancestor to continue first
1699 // this will get fired off when the ancestor component
1700 // finally gets around to rendering its lazy self
1701 // fire off the initial update
1702 ancestorComponent['s-rc'].push(schedule);
1703 }
1704 else {
1705 schedule();
1706 }
1707};
1708const fireConnectedCallback = (instance) => {
1709 {
1710 safeCall(instance, 'connectedCallback');
1711 }
1712};
1713const connectedCallback = (elm) => {
1714 if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0) {
1715 const hostRef = getHostRef(elm);
1716 const cmpMeta = hostRef.$cmpMeta$;
1717 const endConnected = createTime('connectedCallback', cmpMeta.$tagName$);
1718 if (!(hostRef.$flags$ & 1 /* hasConnected */)) {
1719 // first time this component has connected
1720 hostRef.$flags$ |= 1 /* hasConnected */;
1721 let hostId;
1722 {
1723 hostId = elm.getAttribute(HYDRATE_ID);
1724 if (hostId) {
1725 if (supportsShadow && cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) {
1726 const scopeId = addStyle(elm.shadowRoot, cmpMeta, elm.getAttribute('s-mode')) ;
1727 elm.classList.remove(scopeId + '-h', scopeId + '-s');
1728 }
1729 initializeClientHydrate(elm, cmpMeta.$tagName$, hostId, hostRef);
1730 }
1731 }
1732 if (!hostId) {
1733 // initUpdate
1734 // if the slot polyfill is required we'll need to put some nodes
1735 // in here to act as original content anchors as we move nodes around
1736 // host element has been connected to the DOM
1737 if ((cmpMeta.$flags$ & (4 /* hasSlotRelocation */ | 8 /* needsShadowDomShim */))) {
1738 setContentReference(elm);
1739 }
1740 }
1741 {
1742 // find the first ancestor component (if there is one) and register
1743 // this component as one of the actively loading child components for its ancestor
1744 let ancestorComponent = elm;
1745 while ((ancestorComponent = ancestorComponent.parentNode || ancestorComponent.host)) {
1746 // climb up the ancestors looking for the first
1747 // component that hasn't finished its lifecycle update yet
1748 if ((ancestorComponent.nodeType === 1 /* ElementNode */ && ancestorComponent.hasAttribute('s-id') && ancestorComponent['s-p']) ||
1749 ancestorComponent['s-p']) {
1750 // we found this components first ancestor component
1751 // keep a reference to this component's ancestor component
1752 attachToAncestor(hostRef, (hostRef.$ancestorComponent$ = ancestorComponent));
1753 break;
1754 }
1755 }
1756 }
1757 // Lazy properties
1758 // https://developers.google.com/web/fundamentals/web-components/best-practices#lazy-properties
1759 if (cmpMeta.$members$) {
1760 Object.entries(cmpMeta.$members$).map(([memberName, [memberFlags]]) => {
1761 if (memberFlags & 31 /* Prop */ && elm.hasOwnProperty(memberName)) {
1762 const value = elm[memberName];
1763 delete elm[memberName];
1764 elm[memberName] = value;
1765 }
1766 });
1767 }
1768 {
1769 // connectedCallback, taskQueue, initialLoad
1770 // angular sets attribute AFTER connectCallback
1771 // https://github.com/angular/angular/issues/18909
1772 // https://github.com/angular/angular/issues/19940
1773 nextTick(() => initializeComponent(elm, hostRef, cmpMeta));
1774 }
1775 }
1776 else {
1777 // not the first time this has connected
1778 // reattach any event listeners to the host
1779 // since they would have been removed when disconnected
1780 addHostEventListeners(elm, hostRef, cmpMeta.$listeners$);
1781 // fire off connectedCallback() on component instance
1782 fireConnectedCallback(hostRef.$lazyInstance$);
1783 }
1784 endConnected();
1785 }
1786};
1787const setContentReference = (elm) => {
1788 // only required when we're NOT using native shadow dom (slot)
1789 // or this browser doesn't support native shadow dom
1790 // and this host element was NOT created with SSR
1791 // let's pick out the inner content for slot projection
1792 // create a node to represent where the original
1793 // content was first placed, which is useful later on
1794 const contentRefElm = (elm['s-cr'] = doc.createComment(''));
1795 contentRefElm['s-cn'] = true;
1796 elm.insertBefore(contentRefElm, elm.firstChild);
1797};
1798const disconnectedCallback = (elm) => {
1799 if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0) {
1800 const hostRef = getHostRef(elm);
1801 const instance = hostRef.$lazyInstance$ ;
1802 {
1803 if (hostRef.$rmListeners$) {
1804 hostRef.$rmListeners$.map(rmListener => rmListener());
1805 hostRef.$rmListeners$ = undefined;
1806 }
1807 }
1808 // clear CSS var-shim tracking
1809 if (plt.$cssShim$) {
1810 plt.$cssShim$.removeHost(elm);
1811 }
1812 {
1813 safeCall(instance, 'disconnectedCallback');
1814 }
1815 }
1816};
1817const bootstrapLazy = (lazyBundles, options = {}) => {
1818 const endBootstrap = createTime();
1819 const cmpTags = [];
1820 const exclude = options.exclude || [];
1821 const customElements = win.customElements;
1822 const head = doc.head;
1823 const metaCharset = /*@__PURE__*/ head.querySelector('meta[charset]');
1824 const visibilityStyle = /*@__PURE__*/ doc.createElement('style');
1825 const deferredConnectedCallbacks = [];
1826 const styles = /*@__PURE__*/ doc.querySelectorAll(`[${HYDRATED_STYLE_ID}]`);
1827 let appLoadFallback;
1828 let isBootstrapping = true;
1829 let i = 0;
1830 Object.assign(plt, options);
1831 plt.$resourcesUrl$ = new URL(options.resourcesUrl || './', doc.baseURI).href;
1832 {
1833 // If the app is already hydrated there is not point to disable the
1834 // async queue. This will improve the first input delay
1835 plt.$flags$ |= 2 /* appLoaded */;
1836 }
1837 {
1838 for (; i < styles.length; i++) {
1839 registerStyle(styles[i].getAttribute(HYDRATED_STYLE_ID), convertScopedToShadow(styles[i].innerHTML), true);
1840 }
1841 }
1842 lazyBundles.map(lazyBundle => lazyBundle[1].map(compactMeta => {
1843 const cmpMeta = {
1844 $flags$: compactMeta[0],
1845 $tagName$: compactMeta[1],
1846 $members$: compactMeta[2],
1847 $listeners$: compactMeta[3],
1848 };
1849 {
1850 cmpMeta.$members$ = compactMeta[2];
1851 }
1852 {
1853 cmpMeta.$listeners$ = compactMeta[3];
1854 }
1855 {
1856 cmpMeta.$attrsToReflect$ = [];
1857 }
1858 {
1859 cmpMeta.$watchers$ = {};
1860 }
1861 if (!supportsShadow && cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) {
1862 cmpMeta.$flags$ |= 8 /* needsShadowDomShim */;
1863 }
1864 const tagName = cmpMeta.$tagName$;
1865 const HostElement = class extends HTMLElement {
1866 // StencilLazyHost
1867 constructor(self) {
1868 // @ts-ignore
1869 super(self);
1870 self = this;
1871 registerHost(self, cmpMeta);
1872 if (cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) {
1873 // this component is using shadow dom
1874 // and this browser supports shadow dom
1875 // add the read-only property "shadowRoot" to the host element
1876 // adding the shadow root build conditionals to minimize runtime
1877 if (supportsShadow) {
1878 {
1879 self.attachShadow({
1880 mode: 'open',
1881 delegatesFocus: !!(cmpMeta.$flags$ & 16 /* shadowDelegatesFocus */),
1882 });
1883 }
1884 }
1885 else if (!('shadowRoot' in self)) {
1886 self.shadowRoot = self;
1887 }
1888 }
1889 }
1890 connectedCallback() {
1891 if (appLoadFallback) {
1892 clearTimeout(appLoadFallback);
1893 appLoadFallback = null;
1894 }
1895 if (isBootstrapping) {
1896 // connectedCallback will be processed once all components have been registered
1897 deferredConnectedCallbacks.push(this);
1898 }
1899 else {
1900 plt.jmp(() => connectedCallback(this));
1901 }
1902 }
1903 disconnectedCallback() {
1904 plt.jmp(() => disconnectedCallback(this));
1905 }
1906 componentOnReady() {
1907 return getHostRef(this).$onReadyPromise$;
1908 }
1909 };
1910 cmpMeta.$lazyBundleId$ = lazyBundle[0];
1911 if (!exclude.includes(tagName) && !customElements.get(tagName)) {
1912 cmpTags.push(tagName);
1913 customElements.define(tagName, proxyComponent(HostElement, cmpMeta, 1 /* isElementConstructor */));
1914 }
1915 }));
1916 {
1917 visibilityStyle.innerHTML = cmpTags + HYDRATED_CSS;
1918 visibilityStyle.setAttribute('data-styles', '');
1919 head.insertBefore(visibilityStyle, metaCharset ? metaCharset.nextSibling : head.firstChild);
1920 }
1921 // Process deferred connectedCallbacks now all components have been registered
1922 isBootstrapping = false;
1923 if (deferredConnectedCallbacks.length) {
1924 deferredConnectedCallbacks.map(host => host.connectedCallback());
1925 }
1926 else {
1927 {
1928 plt.jmp(() => (appLoadFallback = setTimeout(appDidLoad, 30)));
1929 }
1930 }
1931 // Fallback appLoad event
1932 endBootstrap();
1933};
1934const getAssetPath = (path) => {
1935 const assetUrl = new URL(path, plt.$resourcesUrl$);
1936 return assetUrl.origin !== win.location.origin ? assetUrl.href : assetUrl.pathname;
1937};
1938const hostRefs = new WeakMap();
1939const getHostRef = (ref) => hostRefs.get(ref);
1940const registerInstance = (lazyInstance, hostRef) => hostRefs.set((hostRef.$lazyInstance$ = lazyInstance), hostRef);
1941const registerHost = (elm, cmpMeta) => {
1942 const hostRef = {
1943 $flags$: 0,
1944 $hostElement$: elm,
1945 $cmpMeta$: cmpMeta,
1946 $instanceValues$: new Map(),
1947 };
1948 {
1949 hostRef.$onInstancePromise$ = new Promise(r => (hostRef.$onInstanceResolve$ = r));
1950 }
1951 {
1952 hostRef.$onReadyPromise$ = new Promise(r => (hostRef.$onReadyResolve$ = r));
1953 elm['s-p'] = [];
1954 elm['s-rc'] = [];
1955 }
1956 addHostEventListeners(elm, hostRef, cmpMeta.$listeners$);
1957 return hostRefs.set(elm, hostRef);
1958};
1959const isMemberInElement = (elm, memberName) => memberName in elm;
1960const consoleError = (e, el) => (0, console.error)(e, el);
1961const cmpModules = /*@__PURE__*/ new Map();
1962const loadModule = (cmpMeta, hostRef, hmrVersionId) => {
1963 // loadModuleImport
1964 const exportName = cmpMeta.$tagName$.replace(/-/g, '_');
1965 const bundleId = cmpMeta.$lazyBundleId$;
1966 const module = cmpModules.get(bundleId) ;
1967 if (module) {
1968 return module[exportName];
1969 }
1970 return Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require(
1971 /* webpackInclude: /\.entry\.js$/ */
1972 /* webpackExclude: /\.system\.entry\.js$/ */
1973 /* webpackMode: "lazy" */
1974 `./${bundleId}.entry.js${''}`)); }).then(importedModule => {
1975 {
1976 cmpModules.set(bundleId, importedModule);
1977 }
1978 return importedModule[exportName];
1979 }, consoleError);
1980};
1981const styles = new Map();
1982const modeResolutionChain = [];
1983const queueDomReads = [];
1984const queueDomWrites = [];
1985const queueTask = (queue, write) => (cb) => {
1986 queue.push(cb);
1987 if (!queuePending) {
1988 queuePending = true;
1989 if (write && plt.$flags$ & 4 /* queueSync */) {
1990 nextTick(flush);
1991 }
1992 else {
1993 plt.raf(flush);
1994 }
1995 }
1996};
1997const consume = (queue) => {
1998 for (let i = 0; i < queue.length; i++) {
1999 try {
2000 queue[i](performance.now());
2001 }
2002 catch (e) {
2003 consoleError(e);
2004 }
2005 }
2006 queue.length = 0;
2007};
2008const flush = () => {
2009 // always force a bunch of medium callbacks to run, but still have
2010 // a throttle on how many can run in a certain time
2011 // DOM READS!!!
2012 consume(queueDomReads);
2013 // DOM WRITES!!!
2014 {
2015 consume(queueDomWrites);
2016 if ((queuePending = queueDomReads.length > 0)) {
2017 // still more to do yet, but we've run out of time
2018 // let's let this thing cool off and try again in the next tick
2019 plt.raf(flush);
2020 }
2021 }
2022};
2023const nextTick = /*@__PURE__*/ (cb) => promiseResolve().then(cb);
2024const readTask = /*@__PURE__*/ queueTask(queueDomReads, false);
2025const writeTask = /*@__PURE__*/ queueTask(queueDomWrites, true);
2026const Build = {
2027 isDev: false,
2028 isBrowser: true,
2029 isServer: false,
2030 isTesting: false,
2031};
2032
2033exports.Build = Build;
2034exports.CSS = CSS;
2035exports.Host = Host;
2036exports.NAMESPACE = NAMESPACE;
2037exports.bootstrapLazy = bootstrapLazy;
2038exports.createEvent = createEvent;
2039exports.doc = doc;
2040exports.forceUpdate = forceUpdate;
2041exports.getAssetPath = getAssetPath;
2042exports.getElement = getElement;
2043exports.getMode = getMode;
2044exports.h = h;
2045exports.plt = plt;
2046exports.promiseResolve = promiseResolve;
2047exports.readTask = readTask;
2048exports.registerInstance = registerInstance;
2049exports.setMode = setMode;
2050exports.win = win;
2051exports.writeTask = writeTask;