@everymatrix/nuts-inbox-widget 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/dist/cjs/index-305bcf58.js +1349 -0
  2. package/dist/cjs/index.cjs.js +2 -0
  3. package/dist/cjs/loader.cjs.js +21 -0
  4. package/dist/cjs/nuts-inbox-widget.cjs.js +19 -0
  5. package/dist/cjs/nuts-inbox-widget_3.cjs.entry.js +39985 -0
  6. package/dist/collection/collection-manifest.json +14 -0
  7. package/dist/collection/components/nuts-inbox-widget/nuts-inbox-widget.css +15 -0
  8. package/dist/collection/components/nuts-inbox-widget/nuts-inbox-widget.js +450 -0
  9. package/dist/collection/components/nuts-notification/nuts-notification.css +147 -0
  10. package/dist/collection/components/nuts-notification/nuts-notification.js +426 -0
  11. package/dist/collection/components/nuts-popover/nuts-popover.css +75 -0
  12. package/dist/collection/components/nuts-popover/nuts-popover.js +265 -0
  13. package/dist/collection/index.js +1 -0
  14. package/dist/collection/types/nuts-inbox-widget.types.js +47 -0
  15. package/dist/collection/utils/utils.js +0 -0
  16. package/dist/components/index.d.ts +26 -0
  17. package/dist/components/index.js +1 -0
  18. package/dist/components/nuts-inbox-widget.d.ts +11 -0
  19. package/dist/components/nuts-inbox-widget.js +4216 -0
  20. package/dist/components/nuts-notification.d.ts +11 -0
  21. package/dist/components/nuts-notification.js +6 -0
  22. package/dist/components/nuts-notification2.js +35762 -0
  23. package/dist/components/nuts-popover.d.ts +11 -0
  24. package/dist/components/nuts-popover.js +6 -0
  25. package/dist/components/nuts-popover2.js +119 -0
  26. package/dist/esm/index-4e49d940.js +1322 -0
  27. package/dist/esm/index.js +1 -0
  28. package/dist/esm/loader.js +17 -0
  29. package/dist/esm/nuts-inbox-widget.js +17 -0
  30. package/dist/esm/nuts-inbox-widget_3.entry.js +39979 -0
  31. package/dist/esm/polyfills/core-js.js +11 -0
  32. package/dist/esm/polyfills/css-shim.js +1 -0
  33. package/dist/esm/polyfills/dom.js +79 -0
  34. package/dist/esm/polyfills/es5-html-element.js +1 -0
  35. package/dist/esm/polyfills/index.js +34 -0
  36. package/dist/esm/polyfills/system.js +6 -0
  37. package/dist/index.cjs.js +1 -0
  38. package/dist/index.js +1 -0
  39. package/dist/nuts-inbox-widget/index.esm.js +0 -0
  40. package/dist/nuts-inbox-widget/nuts-inbox-widget.esm.js +1 -0
  41. package/dist/nuts-inbox-widget/p-2f19681b.entry.js +1 -0
  42. package/dist/nuts-inbox-widget/p-d5a07a94.js +1 -0
  43. package/dist/stencil.config.js +22 -0
  44. package/dist/types/Users/raul.vasile/workspace/everymatrix/widgets-stencil/packages/nuts-inbox-widget/.stencil/packages/nuts-inbox-widget/stencil.config.d.ts +2 -0
  45. package/dist/types/components/nuts-inbox-widget/nuts-inbox-widget.d.ts +70 -0
  46. package/dist/types/components/nuts-notification/nuts-notification.d.ts +38 -0
  47. package/dist/types/components/nuts-popover/nuts-popover.d.ts +29 -0
  48. package/dist/types/components.d.ts +225 -0
  49. package/dist/types/index.d.ts +1 -0
  50. package/dist/types/stencil-public-runtime.d.ts +1565 -0
  51. package/dist/types/types/nuts-inbox-widget.types.d.ts +98 -0
  52. package/dist/types/utils/utils.d.ts +0 -0
  53. package/loader/cdn.js +3 -0
  54. package/loader/index.cjs.js +3 -0
  55. package/loader/index.d.ts +12 -0
  56. package/loader/index.es2017.js +3 -0
  57. package/loader/index.js +4 -0
  58. package/loader/package.json +10 -0
  59. package/package.json +19 -0
@@ -0,0 +1,1322 @@
1
+ const NAMESPACE = 'nuts-inbox-widget';
2
+
3
+ let scopeId;
4
+ let hostTagName;
5
+ let isSvgMode = false;
6
+ let queuePending = false;
7
+ const win = typeof window !== 'undefined' ? window : {};
8
+ const doc = win.document || { head: {} };
9
+ const plt = {
10
+ $flags$: 0,
11
+ $resourcesUrl$: '',
12
+ jmp: (h) => h(),
13
+ raf: (h) => requestAnimationFrame(h),
14
+ ael: (el, eventName, listener, opts) => el.addEventListener(eventName, listener, opts),
15
+ rel: (el, eventName, listener, opts) => el.removeEventListener(eventName, listener, opts),
16
+ ce: (eventName, opts) => new CustomEvent(eventName, opts),
17
+ };
18
+ const promiseResolve = (v) => Promise.resolve(v);
19
+ const supportsConstructibleStylesheets = /*@__PURE__*/ (() => {
20
+ try {
21
+ new CSSStyleSheet();
22
+ return typeof new CSSStyleSheet().replace === 'function';
23
+ }
24
+ catch (e) { }
25
+ return false;
26
+ })()
27
+ ;
28
+ const addHostEventListeners = (elm, hostRef, listeners, attachParentListeners) => {
29
+ if (listeners) {
30
+ listeners.map(([flags, name, method]) => {
31
+ const target = getHostListenerTarget(elm, flags) ;
32
+ const handler = hostListenerProxy(hostRef, method);
33
+ const opts = hostListenerOpts(flags);
34
+ plt.ael(target, name, handler, opts);
35
+ (hostRef.$rmListeners$ = hostRef.$rmListeners$ || []).push(() => plt.rel(target, name, handler, opts));
36
+ });
37
+ }
38
+ };
39
+ const hostListenerProxy = (hostRef, methodName) => (ev) => {
40
+ try {
41
+ {
42
+ if (hostRef.$flags$ & 256 /* isListenReady */) {
43
+ // instance is ready, let's call it's member method for this event
44
+ hostRef.$lazyInstance$[methodName](ev);
45
+ }
46
+ else {
47
+ (hostRef.$queuedListeners$ = hostRef.$queuedListeners$ || []).push([methodName, ev]);
48
+ }
49
+ }
50
+ }
51
+ catch (e) {
52
+ consoleError(e);
53
+ }
54
+ };
55
+ const getHostListenerTarget = (elm, flags) => {
56
+ if (flags & 8 /* TargetWindow */)
57
+ return win;
58
+ return elm;
59
+ };
60
+ // prettier-ignore
61
+ const hostListenerOpts = (flags) => (flags & 2 /* Capture */) !== 0;
62
+ const HYDRATED_CSS = '{visibility:hidden}.hydrated{visibility:inherit}';
63
+ const createTime = (fnName, tagName = '') => {
64
+ {
65
+ return () => {
66
+ return;
67
+ };
68
+ }
69
+ };
70
+ const uniqueTime = (key, measureText) => {
71
+ {
72
+ return () => {
73
+ return;
74
+ };
75
+ }
76
+ };
77
+ const rootAppliedStyles = new WeakMap();
78
+ const registerStyle = (scopeId, cssText, allowCS) => {
79
+ let style = styles.get(scopeId);
80
+ if (supportsConstructibleStylesheets && allowCS) {
81
+ style = (style || new CSSStyleSheet());
82
+ style.replace(cssText);
83
+ }
84
+ else {
85
+ style = cssText;
86
+ }
87
+ styles.set(scopeId, style);
88
+ };
89
+ const addStyle = (styleContainerNode, cmpMeta, mode, hostElm) => {
90
+ let scopeId = getScopeId(cmpMeta);
91
+ let style = styles.get(scopeId);
92
+ // if an element is NOT connected then getRootNode() will return the wrong root node
93
+ // so the fallback is to always use the document for the root node in those cases
94
+ styleContainerNode = styleContainerNode.nodeType === 11 /* DocumentFragment */ ? styleContainerNode : doc;
95
+ if (style) {
96
+ if (typeof style === 'string') {
97
+ styleContainerNode = styleContainerNode.head || styleContainerNode;
98
+ let appliedStyles = rootAppliedStyles.get(styleContainerNode);
99
+ let styleElm;
100
+ if (!appliedStyles) {
101
+ rootAppliedStyles.set(styleContainerNode, (appliedStyles = new Set()));
102
+ }
103
+ if (!appliedStyles.has(scopeId)) {
104
+ {
105
+ {
106
+ styleElm = doc.createElement('style');
107
+ styleElm.innerHTML = style;
108
+ }
109
+ styleContainerNode.insertBefore(styleElm, styleContainerNode.querySelector('link'));
110
+ }
111
+ if (appliedStyles) {
112
+ appliedStyles.add(scopeId);
113
+ }
114
+ }
115
+ }
116
+ else if (!styleContainerNode.adoptedStyleSheets.includes(style)) {
117
+ styleContainerNode.adoptedStyleSheets = [...styleContainerNode.adoptedStyleSheets, style];
118
+ }
119
+ }
120
+ return scopeId;
121
+ };
122
+ const attachStyles = (hostRef) => {
123
+ const cmpMeta = hostRef.$cmpMeta$;
124
+ const elm = hostRef.$hostElement$;
125
+ const flags = cmpMeta.$flags$;
126
+ const endAttachStyles = createTime('attachStyles', cmpMeta.$tagName$);
127
+ const scopeId = addStyle(elm.shadowRoot ? elm.shadowRoot : elm.getRootNode(), cmpMeta);
128
+ if (flags & 10 /* needsScopedEncapsulation */) {
129
+ // only required when we're NOT using native shadow dom (slot)
130
+ // or this browser doesn't support native shadow dom
131
+ // and this host element was NOT created with SSR
132
+ // let's pick out the inner content for slot projection
133
+ // create a node to represent where the original
134
+ // content was first placed, which is useful later on
135
+ // DOM WRITE!!
136
+ elm['s-sc'] = scopeId;
137
+ elm.classList.add(scopeId + '-h');
138
+ }
139
+ endAttachStyles();
140
+ };
141
+ const getScopeId = (cmp, mode) => 'sc-' + (cmp.$tagName$);
142
+ /**
143
+ * Default style mode id
144
+ */
145
+ /**
146
+ * Reusable empty obj/array
147
+ * Don't add values to these!!
148
+ */
149
+ const EMPTY_OBJ = {};
150
+ /**
151
+ * Namespaces
152
+ */
153
+ const SVG_NS = 'http://www.w3.org/2000/svg';
154
+ const HTML_NS = 'http://www.w3.org/1999/xhtml';
155
+ const isDef = (v) => v != null;
156
+ const isComplexType = (o) => {
157
+ // https://jsperf.com/typeof-fn-object/5
158
+ o = typeof o;
159
+ return o === 'object' || o === 'function';
160
+ };
161
+ /**
162
+ * Production h() function based on Preact by
163
+ * Jason Miller (@developit)
164
+ * Licensed under the MIT License
165
+ * https://github.com/developit/preact/blob/master/LICENSE
166
+ *
167
+ * Modified for Stencil's compiler and vdom
168
+ */
169
+ // const stack: any[] = [];
170
+ // export function h(nodeName: string | d.FunctionalComponent, vnodeData: d.PropsType, child?: d.ChildType): d.VNode;
171
+ // export function h(nodeName: string | d.FunctionalComponent, vnodeData: d.PropsType, ...children: d.ChildType[]): d.VNode;
172
+ const h = (nodeName, vnodeData, ...children) => {
173
+ let child = null;
174
+ let key = null;
175
+ let simple = false;
176
+ let lastSimple = false;
177
+ let vNodeChildren = [];
178
+ const walk = (c) => {
179
+ for (let i = 0; i < c.length; i++) {
180
+ child = c[i];
181
+ if (Array.isArray(child)) {
182
+ walk(child);
183
+ }
184
+ else if (child != null && typeof child !== 'boolean') {
185
+ if ((simple = typeof nodeName !== 'function' && !isComplexType(child))) {
186
+ child = String(child);
187
+ }
188
+ if (simple && lastSimple) {
189
+ // If the previous child was simple (string), we merge both
190
+ vNodeChildren[vNodeChildren.length - 1].$text$ += child;
191
+ }
192
+ else {
193
+ // Append a new vNode, if it's text, we create a text vNode
194
+ vNodeChildren.push(simple ? newVNode(null, child) : child);
195
+ }
196
+ lastSimple = simple;
197
+ }
198
+ }
199
+ };
200
+ walk(children);
201
+ if (vnodeData) {
202
+ // normalize class / classname attributes
203
+ if (vnodeData.key) {
204
+ key = vnodeData.key;
205
+ }
206
+ {
207
+ const classData = vnodeData.className || vnodeData.class;
208
+ if (classData) {
209
+ vnodeData.class =
210
+ typeof classData !== 'object'
211
+ ? classData
212
+ : Object.keys(classData)
213
+ .filter((k) => classData[k])
214
+ .join(' ');
215
+ }
216
+ }
217
+ }
218
+ const vnode = newVNode(nodeName, null);
219
+ vnode.$attrs$ = vnodeData;
220
+ if (vNodeChildren.length > 0) {
221
+ vnode.$children$ = vNodeChildren;
222
+ }
223
+ {
224
+ vnode.$key$ = key;
225
+ }
226
+ return vnode;
227
+ };
228
+ const newVNode = (tag, text) => {
229
+ const vnode = {
230
+ $flags$: 0,
231
+ $tag$: tag,
232
+ $text$: text,
233
+ $elm$: null,
234
+ $children$: null,
235
+ };
236
+ {
237
+ vnode.$attrs$ = null;
238
+ }
239
+ {
240
+ vnode.$key$ = null;
241
+ }
242
+ return vnode;
243
+ };
244
+ const Host = {};
245
+ const isHost = (node) => node && node.$tag$ === Host;
246
+ /**
247
+ * Production setAccessor() function based on Preact by
248
+ * Jason Miller (@developit)
249
+ * Licensed under the MIT License
250
+ * https://github.com/developit/preact/blob/master/LICENSE
251
+ *
252
+ * Modified for Stencil's compiler and vdom
253
+ */
254
+ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
255
+ if (oldValue !== newValue) {
256
+ let isProp = isMemberInElement(elm, memberName);
257
+ let ln = memberName.toLowerCase();
258
+ if (memberName === 'class') {
259
+ const classList = elm.classList;
260
+ const oldClasses = parseClassList(oldValue);
261
+ const newClasses = parseClassList(newValue);
262
+ classList.remove(...oldClasses.filter((c) => c && !newClasses.includes(c)));
263
+ classList.add(...newClasses.filter((c) => c && !oldClasses.includes(c)));
264
+ }
265
+ else if (memberName === 'key')
266
+ ;
267
+ else if (memberName === 'ref') {
268
+ // minifier will clean this up
269
+ if (newValue) {
270
+ newValue(elm);
271
+ }
272
+ }
273
+ else if ((!isProp ) &&
274
+ memberName[0] === 'o' &&
275
+ memberName[1] === 'n') {
276
+ // Event Handlers
277
+ // so if the member name starts with "on" and the 3rd characters is
278
+ // a capital letter, and it's not already a member on the element,
279
+ // then we're assuming it's an event listener
280
+ if (memberName[2] === '-') {
281
+ // on- prefixed events
282
+ // allows to be explicit about the dom event to listen without any magic
283
+ // under the hood:
284
+ // <my-cmp on-click> // listens for "click"
285
+ // <my-cmp on-Click> // listens for "Click"
286
+ // <my-cmp on-ionChange> // listens for "ionChange"
287
+ // <my-cmp on-EVENTS> // listens for "EVENTS"
288
+ memberName = memberName.slice(3);
289
+ }
290
+ else if (isMemberInElement(win, ln)) {
291
+ // standard event
292
+ // the JSX attribute could have been "onMouseOver" and the
293
+ // member name "onmouseover" is on the window's prototype
294
+ // so let's add the listener "mouseover", which is all lowercased
295
+ memberName = ln.slice(2);
296
+ }
297
+ else {
298
+ // custom event
299
+ // the JSX attribute could have been "onMyCustomEvent"
300
+ // so let's trim off the "on" prefix and lowercase the first character
301
+ // and add the listener "myCustomEvent"
302
+ // except for the first character, we keep the event name case
303
+ memberName = ln[2] + memberName.slice(3);
304
+ }
305
+ if (oldValue) {
306
+ plt.rel(elm, memberName, oldValue, false);
307
+ }
308
+ if (newValue) {
309
+ plt.ael(elm, memberName, newValue, false);
310
+ }
311
+ }
312
+ else {
313
+ // Set property if it exists and it's not a SVG
314
+ const isComplex = isComplexType(newValue);
315
+ if ((isProp || (isComplex && newValue !== null)) && !isSvg) {
316
+ try {
317
+ if (!elm.tagName.includes('-')) {
318
+ let n = newValue == null ? '' : newValue;
319
+ // Workaround for Safari, moving the <input> caret when re-assigning the same valued
320
+ if (memberName === 'list') {
321
+ isProp = false;
322
+ }
323
+ else if (oldValue == null || elm[memberName] != n) {
324
+ elm[memberName] = n;
325
+ }
326
+ }
327
+ else {
328
+ elm[memberName] = newValue;
329
+ }
330
+ }
331
+ catch (e) { }
332
+ }
333
+ if (newValue == null || newValue === false) {
334
+ if (newValue !== false || elm.getAttribute(memberName) === '') {
335
+ {
336
+ elm.removeAttribute(memberName);
337
+ }
338
+ }
339
+ }
340
+ else if ((!isProp || flags & 4 /* isHost */ || isSvg) && !isComplex) {
341
+ newValue = newValue === true ? '' : newValue;
342
+ {
343
+ elm.setAttribute(memberName, newValue);
344
+ }
345
+ }
346
+ }
347
+ }
348
+ };
349
+ const parseClassListRegex = /\s/;
350
+ const parseClassList = (value) => (!value ? [] : value.split(parseClassListRegex));
351
+ const updateElement = (oldVnode, newVnode, isSvgMode, memberName) => {
352
+ // if the element passed in is a shadow root, which is a document fragment
353
+ // then we want to be adding attrs/props to the shadow root's "host" element
354
+ // if it's not a shadow root, then we add attrs/props to the same element
355
+ const elm = newVnode.$elm$.nodeType === 11 /* DocumentFragment */ && newVnode.$elm$.host
356
+ ? newVnode.$elm$.host
357
+ : newVnode.$elm$;
358
+ const oldVnodeAttrs = (oldVnode && oldVnode.$attrs$) || EMPTY_OBJ;
359
+ const newVnodeAttrs = newVnode.$attrs$ || EMPTY_OBJ;
360
+ {
361
+ // remove attributes no longer present on the vnode by setting them to undefined
362
+ for (memberName in oldVnodeAttrs) {
363
+ if (!(memberName in newVnodeAttrs)) {
364
+ setAccessor(elm, memberName, oldVnodeAttrs[memberName], undefined, isSvgMode, newVnode.$flags$);
365
+ }
366
+ }
367
+ }
368
+ // add new & update changed attributes
369
+ for (memberName in newVnodeAttrs) {
370
+ setAccessor(elm, memberName, oldVnodeAttrs[memberName], newVnodeAttrs[memberName], isSvgMode, newVnode.$flags$);
371
+ }
372
+ };
373
+ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
374
+ // tslint:disable-next-line: prefer-const
375
+ let newVNode = newParentVNode.$children$[childIndex];
376
+ let i = 0;
377
+ let elm;
378
+ let childNode;
379
+ if (newVNode.$text$ !== null) {
380
+ // create text node
381
+ elm = newVNode.$elm$ = doc.createTextNode(newVNode.$text$);
382
+ }
383
+ else {
384
+ if (!isSvgMode) {
385
+ isSvgMode = newVNode.$tag$ === 'svg';
386
+ }
387
+ // create element
388
+ elm = newVNode.$elm$ = (doc.createElementNS(isSvgMode ? SVG_NS : HTML_NS, newVNode.$tag$)
389
+ );
390
+ if (isSvgMode && newVNode.$tag$ === 'foreignObject') {
391
+ isSvgMode = false;
392
+ }
393
+ // add css classes, attrs, props, listeners, etc.
394
+ {
395
+ updateElement(null, newVNode, isSvgMode);
396
+ }
397
+ if (isDef(scopeId) && elm['s-si'] !== scopeId) {
398
+ // if there is a scopeId and this is the initial render
399
+ // then let's add the scopeId as a css class
400
+ elm.classList.add((elm['s-si'] = scopeId));
401
+ }
402
+ if (newVNode.$children$) {
403
+ for (i = 0; i < newVNode.$children$.length; ++i) {
404
+ // create the node
405
+ childNode = createElm(oldParentVNode, newVNode, i);
406
+ // return node could have been null
407
+ if (childNode) {
408
+ // append our new node
409
+ elm.appendChild(childNode);
410
+ }
411
+ }
412
+ }
413
+ {
414
+ if (newVNode.$tag$ === 'svg') {
415
+ // Only reset the SVG context when we're exiting <svg> element
416
+ isSvgMode = false;
417
+ }
418
+ else if (elm.tagName === 'foreignObject') {
419
+ // Reenter SVG context when we're exiting <foreignObject> element
420
+ isSvgMode = true;
421
+ }
422
+ }
423
+ }
424
+ return elm;
425
+ };
426
+ const addVnodes = (parentElm, before, parentVNode, vnodes, startIdx, endIdx) => {
427
+ let containerElm = (parentElm);
428
+ let childNode;
429
+ if (containerElm.shadowRoot && containerElm.tagName === hostTagName) {
430
+ containerElm = containerElm.shadowRoot;
431
+ }
432
+ for (; startIdx <= endIdx; ++startIdx) {
433
+ if (vnodes[startIdx]) {
434
+ childNode = createElm(null, parentVNode, startIdx);
435
+ if (childNode) {
436
+ vnodes[startIdx].$elm$ = childNode;
437
+ containerElm.insertBefore(childNode, before);
438
+ }
439
+ }
440
+ }
441
+ };
442
+ const removeVnodes = (vnodes, startIdx, endIdx, vnode, elm) => {
443
+ for (; startIdx <= endIdx; ++startIdx) {
444
+ if ((vnode = vnodes[startIdx])) {
445
+ elm = vnode.$elm$;
446
+ callNodeRefs(vnode);
447
+ // remove the vnode's element from the dom
448
+ elm.remove();
449
+ }
450
+ }
451
+ };
452
+ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
453
+ let oldStartIdx = 0;
454
+ let newStartIdx = 0;
455
+ let idxInOld = 0;
456
+ let i = 0;
457
+ let oldEndIdx = oldCh.length - 1;
458
+ let oldStartVnode = oldCh[0];
459
+ let oldEndVnode = oldCh[oldEndIdx];
460
+ let newEndIdx = newCh.length - 1;
461
+ let newStartVnode = newCh[0];
462
+ let newEndVnode = newCh[newEndIdx];
463
+ let node;
464
+ let elmToMove;
465
+ while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
466
+ if (oldStartVnode == null) {
467
+ // Vnode might have been moved left
468
+ oldStartVnode = oldCh[++oldStartIdx];
469
+ }
470
+ else if (oldEndVnode == null) {
471
+ oldEndVnode = oldCh[--oldEndIdx];
472
+ }
473
+ else if (newStartVnode == null) {
474
+ newStartVnode = newCh[++newStartIdx];
475
+ }
476
+ else if (newEndVnode == null) {
477
+ newEndVnode = newCh[--newEndIdx];
478
+ }
479
+ else if (isSameVnode(oldStartVnode, newStartVnode)) {
480
+ patch(oldStartVnode, newStartVnode);
481
+ oldStartVnode = oldCh[++oldStartIdx];
482
+ newStartVnode = newCh[++newStartIdx];
483
+ }
484
+ else if (isSameVnode(oldEndVnode, newEndVnode)) {
485
+ patch(oldEndVnode, newEndVnode);
486
+ oldEndVnode = oldCh[--oldEndIdx];
487
+ newEndVnode = newCh[--newEndIdx];
488
+ }
489
+ else if (isSameVnode(oldStartVnode, newEndVnode)) {
490
+ patch(oldStartVnode, newEndVnode);
491
+ parentElm.insertBefore(oldStartVnode.$elm$, oldEndVnode.$elm$.nextSibling);
492
+ oldStartVnode = oldCh[++oldStartIdx];
493
+ newEndVnode = newCh[--newEndIdx];
494
+ }
495
+ else if (isSameVnode(oldEndVnode, newStartVnode)) {
496
+ patch(oldEndVnode, newStartVnode);
497
+ parentElm.insertBefore(oldEndVnode.$elm$, oldStartVnode.$elm$);
498
+ oldEndVnode = oldCh[--oldEndIdx];
499
+ newStartVnode = newCh[++newStartIdx];
500
+ }
501
+ else {
502
+ // createKeyToOldIdx
503
+ idxInOld = -1;
504
+ {
505
+ for (i = oldStartIdx; i <= oldEndIdx; ++i) {
506
+ if (oldCh[i] && oldCh[i].$key$ !== null && oldCh[i].$key$ === newStartVnode.$key$) {
507
+ idxInOld = i;
508
+ break;
509
+ }
510
+ }
511
+ }
512
+ if (idxInOld >= 0) {
513
+ elmToMove = oldCh[idxInOld];
514
+ if (elmToMove.$tag$ !== newStartVnode.$tag$) {
515
+ node = createElm(oldCh && oldCh[newStartIdx], newVNode, idxInOld);
516
+ }
517
+ else {
518
+ patch(elmToMove, newStartVnode);
519
+ oldCh[idxInOld] = undefined;
520
+ node = elmToMove.$elm$;
521
+ }
522
+ newStartVnode = newCh[++newStartIdx];
523
+ }
524
+ else {
525
+ // new element
526
+ node = createElm(oldCh && oldCh[newStartIdx], newVNode, newStartIdx);
527
+ newStartVnode = newCh[++newStartIdx];
528
+ }
529
+ if (node) {
530
+ {
531
+ oldStartVnode.$elm$.parentNode.insertBefore(node, oldStartVnode.$elm$);
532
+ }
533
+ }
534
+ }
535
+ }
536
+ if (oldStartIdx > oldEndIdx) {
537
+ addVnodes(parentElm, newCh[newEndIdx + 1] == null ? null : newCh[newEndIdx + 1].$elm$, newVNode, newCh, newStartIdx, newEndIdx);
538
+ }
539
+ else if (newStartIdx > newEndIdx) {
540
+ removeVnodes(oldCh, oldStartIdx, oldEndIdx);
541
+ }
542
+ };
543
+ const isSameVnode = (vnode1, vnode2) => {
544
+ // compare if two vnode to see if they're "technically" the same
545
+ // need to have the same element tag, and same key to be the same
546
+ if (vnode1.$tag$ === vnode2.$tag$) {
547
+ {
548
+ return vnode1.$key$ === vnode2.$key$;
549
+ }
550
+ }
551
+ return false;
552
+ };
553
+ const patch = (oldVNode, newVNode) => {
554
+ const elm = (newVNode.$elm$ = oldVNode.$elm$);
555
+ const oldChildren = oldVNode.$children$;
556
+ const newChildren = newVNode.$children$;
557
+ const tag = newVNode.$tag$;
558
+ const text = newVNode.$text$;
559
+ if (text === null) {
560
+ {
561
+ // test if we're rendering an svg element, or still rendering nodes inside of one
562
+ // only add this to the when the compiler sees we're using an svg somewhere
563
+ isSvgMode = tag === 'svg' ? true : tag === 'foreignObject' ? false : isSvgMode;
564
+ }
565
+ // element node
566
+ {
567
+ {
568
+ // either this is the first render of an element OR it's an update
569
+ // AND we already know it's possible it could have changed
570
+ // this updates the element's css classes, attrs, props, listeners, etc.
571
+ updateElement(oldVNode, newVNode, isSvgMode);
572
+ }
573
+ }
574
+ if (oldChildren !== null && newChildren !== null) {
575
+ // looks like there's child vnodes for both the old and new vnodes
576
+ updateChildren(elm, oldChildren, newVNode, newChildren);
577
+ }
578
+ else if (newChildren !== null) {
579
+ // no old child vnodes, but there are new child vnodes to add
580
+ if (oldVNode.$text$ !== null) {
581
+ // the old vnode was text, so be sure to clear it out
582
+ elm.textContent = '';
583
+ }
584
+ // add the new vnode children
585
+ addVnodes(elm, null, newVNode, newChildren, 0, newChildren.length - 1);
586
+ }
587
+ else if (oldChildren !== null) {
588
+ // no new child vnodes, but there are old child vnodes to remove
589
+ removeVnodes(oldChildren, 0, oldChildren.length - 1);
590
+ }
591
+ if (isSvgMode && tag === 'svg') {
592
+ isSvgMode = false;
593
+ }
594
+ }
595
+ else if (oldVNode.$text$ !== text) {
596
+ // update the text content for the text only vnode
597
+ // and also only if the text is different than before
598
+ elm.data = text;
599
+ }
600
+ };
601
+ const callNodeRefs = (vNode) => {
602
+ {
603
+ vNode.$attrs$ && vNode.$attrs$.ref && vNode.$attrs$.ref(null);
604
+ vNode.$children$ && vNode.$children$.map(callNodeRefs);
605
+ }
606
+ };
607
+ const renderVdom = (hostRef, renderFnResults) => {
608
+ const hostElm = hostRef.$hostElement$;
609
+ const cmpMeta = hostRef.$cmpMeta$;
610
+ const oldVNode = hostRef.$vnode$ || newVNode(null, null);
611
+ const rootVnode = isHost(renderFnResults) ? renderFnResults : h(null, null, renderFnResults);
612
+ hostTagName = hostElm.tagName;
613
+ if (cmpMeta.$attrsToReflect$) {
614
+ rootVnode.$attrs$ = rootVnode.$attrs$ || {};
615
+ cmpMeta.$attrsToReflect$.map(([propName, attribute]) => (rootVnode.$attrs$[attribute] = hostElm[propName]));
616
+ }
617
+ rootVnode.$tag$ = null;
618
+ rootVnode.$flags$ |= 4 /* isHost */;
619
+ hostRef.$vnode$ = rootVnode;
620
+ rootVnode.$elm$ = oldVNode.$elm$ = (hostElm.shadowRoot || hostElm );
621
+ {
622
+ scopeId = hostElm['s-sc'];
623
+ }
624
+ // synchronous patch
625
+ patch(oldVNode, rootVnode);
626
+ };
627
+ const getElement = (ref) => (getHostRef(ref).$hostElement$ );
628
+ const createEvent = (ref, name, flags) => {
629
+ const elm = getElement(ref);
630
+ return {
631
+ emit: (detail) => {
632
+ return emitEvent(elm, name, {
633
+ bubbles: !!(flags & 4 /* Bubbles */),
634
+ composed: !!(flags & 2 /* Composed */),
635
+ cancelable: !!(flags & 1 /* Cancellable */),
636
+ detail,
637
+ });
638
+ },
639
+ };
640
+ };
641
+ /**
642
+ * Helper function to create & dispatch a custom Event on a provided target
643
+ * @param elm the target of the Event
644
+ * @param name the name to give the custom Event
645
+ * @param opts options for configuring a custom Event
646
+ * @returns the custom Event
647
+ */
648
+ const emitEvent = (elm, name, opts) => {
649
+ const ev = plt.ce(name, opts);
650
+ elm.dispatchEvent(ev);
651
+ return ev;
652
+ };
653
+ const attachToAncestor = (hostRef, ancestorComponent) => {
654
+ if (ancestorComponent && !hostRef.$onRenderResolve$ && ancestorComponent['s-p']) {
655
+ ancestorComponent['s-p'].push(new Promise((r) => (hostRef.$onRenderResolve$ = r)));
656
+ }
657
+ };
658
+ const scheduleUpdate = (hostRef, isInitialLoad) => {
659
+ {
660
+ hostRef.$flags$ |= 16 /* isQueuedForUpdate */;
661
+ }
662
+ if (hostRef.$flags$ & 4 /* isWaitingForChildren */) {
663
+ hostRef.$flags$ |= 512 /* needsRerender */;
664
+ return;
665
+ }
666
+ attachToAncestor(hostRef, hostRef.$ancestorComponent$);
667
+ // there is no ancestor component or the ancestor component
668
+ // has already fired off its lifecycle update then
669
+ // fire off the initial update
670
+ const dispatch = () => dispatchHooks(hostRef, isInitialLoad);
671
+ return writeTask(dispatch) ;
672
+ };
673
+ const dispatchHooks = (hostRef, isInitialLoad) => {
674
+ const endSchedule = createTime('scheduleUpdate', hostRef.$cmpMeta$.$tagName$);
675
+ const instance = hostRef.$lazyInstance$ ;
676
+ let promise;
677
+ if (isInitialLoad) {
678
+ {
679
+ hostRef.$flags$ |= 256 /* isListenReady */;
680
+ if (hostRef.$queuedListeners$) {
681
+ hostRef.$queuedListeners$.map(([methodName, event]) => safeCall(instance, methodName, event));
682
+ hostRef.$queuedListeners$ = null;
683
+ }
684
+ }
685
+ }
686
+ endSchedule();
687
+ return then(promise, () => updateComponent(hostRef, instance, isInitialLoad));
688
+ };
689
+ const updateComponent = async (hostRef, instance, isInitialLoad) => {
690
+ // updateComponent
691
+ const elm = hostRef.$hostElement$;
692
+ const endUpdate = createTime('update', hostRef.$cmpMeta$.$tagName$);
693
+ const rc = elm['s-rc'];
694
+ if (isInitialLoad) {
695
+ // DOM WRITE!
696
+ attachStyles(hostRef);
697
+ }
698
+ const endRender = createTime('render', hostRef.$cmpMeta$.$tagName$);
699
+ {
700
+ callRender(hostRef, instance);
701
+ }
702
+ if (rc) {
703
+ // ok, so turns out there are some child host elements
704
+ // waiting on this parent element to load
705
+ // let's fire off all update callbacks waiting
706
+ rc.map((cb) => cb());
707
+ elm['s-rc'] = undefined;
708
+ }
709
+ endRender();
710
+ endUpdate();
711
+ {
712
+ const childrenPromises = elm['s-p'];
713
+ const postUpdate = () => postUpdateComponent(hostRef);
714
+ if (childrenPromises.length === 0) {
715
+ postUpdate();
716
+ }
717
+ else {
718
+ Promise.all(childrenPromises).then(postUpdate);
719
+ hostRef.$flags$ |= 4 /* isWaitingForChildren */;
720
+ childrenPromises.length = 0;
721
+ }
722
+ }
723
+ };
724
+ const callRender = (hostRef, instance, elm) => {
725
+ try {
726
+ instance = instance.render() ;
727
+ {
728
+ hostRef.$flags$ &= ~16 /* isQueuedForUpdate */;
729
+ }
730
+ {
731
+ hostRef.$flags$ |= 2 /* hasRendered */;
732
+ }
733
+ {
734
+ {
735
+ // looks like we've got child nodes to render into this host element
736
+ // or we need to update the css class/attrs on the host element
737
+ // DOM WRITE!
738
+ {
739
+ renderVdom(hostRef, instance);
740
+ }
741
+ }
742
+ }
743
+ }
744
+ catch (e) {
745
+ consoleError(e, hostRef.$hostElement$);
746
+ }
747
+ return null;
748
+ };
749
+ const postUpdateComponent = (hostRef) => {
750
+ const tagName = hostRef.$cmpMeta$.$tagName$;
751
+ const elm = hostRef.$hostElement$;
752
+ const endPostUpdate = createTime('postUpdate', tagName);
753
+ const ancestorComponent = hostRef.$ancestorComponent$;
754
+ if (!(hostRef.$flags$ & 64 /* hasLoadedComponent */)) {
755
+ hostRef.$flags$ |= 64 /* hasLoadedComponent */;
756
+ {
757
+ // DOM WRITE!
758
+ addHydratedFlag(elm);
759
+ }
760
+ endPostUpdate();
761
+ {
762
+ hostRef.$onReadyResolve$(elm);
763
+ if (!ancestorComponent) {
764
+ appDidLoad();
765
+ }
766
+ }
767
+ }
768
+ else {
769
+ endPostUpdate();
770
+ }
771
+ // load events fire from bottom to top
772
+ // the deepest elements load first then bubbles up
773
+ {
774
+ if (hostRef.$onRenderResolve$) {
775
+ hostRef.$onRenderResolve$();
776
+ hostRef.$onRenderResolve$ = undefined;
777
+ }
778
+ if (hostRef.$flags$ & 512 /* needsRerender */) {
779
+ nextTick(() => scheduleUpdate(hostRef, false));
780
+ }
781
+ hostRef.$flags$ &= ~(4 /* isWaitingForChildren */ | 512 /* needsRerender */);
782
+ }
783
+ // ( •_•)
784
+ // ( •_•)>⌐■-■
785
+ // (⌐■_■)
786
+ };
787
+ const appDidLoad = (who) => {
788
+ // on appload
789
+ // we have finish the first big initial render
790
+ {
791
+ addHydratedFlag(doc.documentElement);
792
+ }
793
+ nextTick(() => emitEvent(win, 'appload', { detail: { namespace: NAMESPACE } }));
794
+ };
795
+ const safeCall = (instance, method, arg) => {
796
+ if (instance && instance[method]) {
797
+ try {
798
+ return instance[method](arg);
799
+ }
800
+ catch (e) {
801
+ consoleError(e);
802
+ }
803
+ }
804
+ return undefined;
805
+ };
806
+ const then = (promise, thenFn) => {
807
+ return promise && promise.then ? promise.then(thenFn) : thenFn();
808
+ };
809
+ const addHydratedFlag = (elm) => elm.classList.add('hydrated')
810
+ ;
811
+ /**
812
+ * Parse a new property value for a given property type.
813
+ *
814
+ * While the prop value can reasonably be expected to be of `any` type as far as TypeScript's type checker is concerned,
815
+ * it is not safe to assume that the string returned by evaluating `typeof propValue` matches:
816
+ * 1. `any`, the type given to `propValue` in the function signature
817
+ * 2. the type stored from `propType`.
818
+ *
819
+ * This function provides the capability to parse/coerce a property's value to potentially any other JavaScript type.
820
+ *
821
+ * Property values represented in TSX preserve their type information. In the example below, the number 0 is passed to
822
+ * a component. This `propValue` will preserve its type information (`typeof propValue === 'number'`). Note that is
823
+ * based on the type of the value being passed in, not the type declared of the class member decorated with `@Prop`.
824
+ * ```tsx
825
+ * <my-cmp prop-val={0}></my-cmp>
826
+ * ```
827
+ *
828
+ * HTML prop values on the other hand, will always a string
829
+ *
830
+ * @param propValue the new value to coerce to some type
831
+ * @param propType the type of the prop, expressed as a binary number
832
+ * @returns the parsed/coerced value
833
+ */
834
+ const parsePropertyValue = (propValue, propType) => {
835
+ // ensure this value is of the correct prop type
836
+ if (propValue != null && !isComplexType(propValue)) {
837
+ if (propType & 4 /* Boolean */) {
838
+ // per the HTML spec, any string value means it is a boolean true value
839
+ // but we'll cheat here and say that the string "false" is the boolean false
840
+ return propValue === 'false' ? false : propValue === '' || !!propValue;
841
+ }
842
+ if (propType & 2 /* Number */) {
843
+ // force it to be a number
844
+ return parseFloat(propValue);
845
+ }
846
+ if (propType & 1 /* String */) {
847
+ // could have been passed as a number or boolean
848
+ // but we still want it as a string
849
+ return String(propValue);
850
+ }
851
+ // redundant return here for better minification
852
+ return propValue;
853
+ }
854
+ // not sure exactly what type we want
855
+ // so no need to change to a different type
856
+ return propValue;
857
+ };
858
+ const getValue = (ref, propName) => getHostRef(ref).$instanceValues$.get(propName);
859
+ const setValue = (ref, propName, newVal, cmpMeta) => {
860
+ // check our new property value against our internal value
861
+ const hostRef = getHostRef(ref);
862
+ const elm = hostRef.$hostElement$ ;
863
+ const oldVal = hostRef.$instanceValues$.get(propName);
864
+ const flags = hostRef.$flags$;
865
+ const instance = hostRef.$lazyInstance$ ;
866
+ newVal = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]);
867
+ // explicitly check for NaN on both sides, as `NaN === NaN` is always false
868
+ const areBothNaN = Number.isNaN(oldVal) && Number.isNaN(newVal);
869
+ const didValueChange = newVal !== oldVal && !areBothNaN;
870
+ if ((!(flags & 8 /* isConstructingInstance */) || oldVal === undefined) && didValueChange) {
871
+ // gadzooks! the property's value has changed!!
872
+ // set our new value!
873
+ hostRef.$instanceValues$.set(propName, newVal);
874
+ if (instance) {
875
+ // get an array of method names of watch functions to call
876
+ if (cmpMeta.$watchers$ && flags & 128 /* isWatchReady */) {
877
+ const watchMethods = cmpMeta.$watchers$[propName];
878
+ if (watchMethods) {
879
+ // this instance is watching for when this property changed
880
+ watchMethods.map((watchMethodName) => {
881
+ try {
882
+ // fire off each of the watch methods that are watching this property
883
+ instance[watchMethodName](newVal, oldVal, propName);
884
+ }
885
+ catch (e) {
886
+ consoleError(e, elm);
887
+ }
888
+ });
889
+ }
890
+ }
891
+ if ((flags & (2 /* hasRendered */ | 16 /* isQueuedForUpdate */)) === 2 /* hasRendered */) {
892
+ // looks like this value actually changed, so we've got work to do!
893
+ // but only if we've already rendered, otherwise just chill out
894
+ // queue that we need to do an update, but don't worry about queuing
895
+ // up millions cuz this function ensures it only runs once
896
+ scheduleUpdate(hostRef, false);
897
+ }
898
+ }
899
+ }
900
+ };
901
+ const proxyComponent = (Cstr, cmpMeta, flags) => {
902
+ if (cmpMeta.$members$) {
903
+ if (Cstr.watchers) {
904
+ cmpMeta.$watchers$ = Cstr.watchers;
905
+ }
906
+ // It's better to have a const than two Object.entries()
907
+ const members = Object.entries(cmpMeta.$members$);
908
+ const prototype = Cstr.prototype;
909
+ members.map(([memberName, [memberFlags]]) => {
910
+ if ((memberFlags & 31 /* Prop */ ||
911
+ ((flags & 2 /* proxyState */) && memberFlags & 32 /* State */))) {
912
+ // proxyComponent - prop
913
+ Object.defineProperty(prototype, memberName, {
914
+ get() {
915
+ // proxyComponent, get value
916
+ return getValue(this, memberName);
917
+ },
918
+ set(newValue) {
919
+ // proxyComponent, set value
920
+ setValue(this, memberName, newValue, cmpMeta);
921
+ },
922
+ configurable: true,
923
+ enumerable: true,
924
+ });
925
+ }
926
+ });
927
+ if ((flags & 1 /* isElementConstructor */)) {
928
+ const attrNameToPropName = new Map();
929
+ prototype.attributeChangedCallback = function (attrName, _oldValue, newValue) {
930
+ plt.jmp(() => {
931
+ const propName = attrNameToPropName.get(attrName);
932
+ // In a web component lifecycle the attributeChangedCallback runs prior to connectedCallback
933
+ // in the case where an attribute was set inline.
934
+ // ```html
935
+ // <my-component some-attribute="some-value"></my-component>
936
+ // ```
937
+ //
938
+ // There is an edge case where a developer sets the attribute inline on a custom element and then
939
+ // programmatically changes it before it has been upgraded as shown below:
940
+ //
941
+ // ```html
942
+ // <!-- this component has _not_ been upgraded yet -->
943
+ // <my-component id="test" some-attribute="some-value"></my-component>
944
+ // <script>
945
+ // // grab non-upgraded component
946
+ // el = document.querySelector("#test");
947
+ // el.someAttribute = "another-value";
948
+ // // upgrade component
949
+ // customElements.define('my-component', MyComponent);
950
+ // </script>
951
+ // ```
952
+ // In this case if we do not unshadow here and use the value of the shadowing property, attributeChangedCallback
953
+ // will be called with `newValue = "some-value"` and will set the shadowed property (this.someAttribute = "another-value")
954
+ // to the value that was set inline i.e. "some-value" from above example. When
955
+ // the connectedCallback attempts to unshadow it will use "some-value" as the initial value rather than "another-value"
956
+ //
957
+ // The case where the attribute was NOT set inline but was not set programmatically shall be handled/unshadowed
958
+ // by connectedCallback as this attributeChangedCallback will not fire.
959
+ //
960
+ // https://developers.google.com/web/fundamentals/web-components/best-practices#lazy-properties
961
+ //
962
+ // TODO(STENCIL-16) we should think about whether or not we actually want to be reflecting the attributes to
963
+ // properties here given that this goes against best practices outlined here
964
+ // https://developers.google.com/web/fundamentals/web-components/best-practices#avoid-reentrancy
965
+ if (this.hasOwnProperty(propName)) {
966
+ newValue = this[propName];
967
+ delete this[propName];
968
+ }
969
+ else if (prototype.hasOwnProperty(propName) &&
970
+ typeof this[propName] === 'number' &&
971
+ this[propName] == newValue) {
972
+ // if the propName exists on the prototype of `Cstr`, this update may be a result of Stencil using native
973
+ // APIs to reflect props as attributes. Calls to `setAttribute(someElement, propName)` will result in
974
+ // `propName` to be converted to a `DOMString`, which may not be what we want for other primitive props.
975
+ return;
976
+ }
977
+ this[propName] = newValue === null && typeof this[propName] === 'boolean' ? false : newValue;
978
+ });
979
+ };
980
+ // create an array of attributes to observe
981
+ // and also create a map of html attribute name to js property name
982
+ Cstr.observedAttributes = members
983
+ .filter(([_, m]) => m[0] & 15 /* HasAttribute */) // filter to only keep props that should match attributes
984
+ .map(([propName, m]) => {
985
+ const attrName = m[1] || propName;
986
+ attrNameToPropName.set(attrName, propName);
987
+ if (m[0] & 512 /* ReflectAttr */) {
988
+ cmpMeta.$attrsToReflect$.push([propName, attrName]);
989
+ }
990
+ return attrName;
991
+ });
992
+ }
993
+ }
994
+ return Cstr;
995
+ };
996
+ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) => {
997
+ // initializeComponent
998
+ if ((hostRef.$flags$ & 32 /* hasInitializedComponent */) === 0) {
999
+ {
1000
+ // we haven't initialized this element yet
1001
+ hostRef.$flags$ |= 32 /* hasInitializedComponent */;
1002
+ // lazy loaded components
1003
+ // request the component's implementation to be
1004
+ // wired up with the host element
1005
+ Cstr = loadModule(cmpMeta);
1006
+ if (Cstr.then) {
1007
+ // Await creates a micro-task avoid if possible
1008
+ const endLoad = uniqueTime();
1009
+ Cstr = await Cstr;
1010
+ endLoad();
1011
+ }
1012
+ if (!Cstr.isProxied) {
1013
+ // we've never proxied this Constructor before
1014
+ // let's add the getters/setters to its prototype before
1015
+ // the first time we create an instance of the implementation
1016
+ {
1017
+ cmpMeta.$watchers$ = Cstr.watchers;
1018
+ }
1019
+ proxyComponent(Cstr, cmpMeta, 2 /* proxyState */);
1020
+ Cstr.isProxied = true;
1021
+ }
1022
+ const endNewInstance = createTime('createInstance', cmpMeta.$tagName$);
1023
+ // ok, time to construct the instance
1024
+ // but let's keep track of when we start and stop
1025
+ // so that the getters/setters don't incorrectly step on data
1026
+ {
1027
+ hostRef.$flags$ |= 8 /* isConstructingInstance */;
1028
+ }
1029
+ // construct the lazy-loaded component implementation
1030
+ // passing the hostRef is very important during
1031
+ // construction in order to directly wire together the
1032
+ // host element and the lazy-loaded instance
1033
+ try {
1034
+ new Cstr(hostRef);
1035
+ }
1036
+ catch (e) {
1037
+ consoleError(e);
1038
+ }
1039
+ {
1040
+ hostRef.$flags$ &= ~8 /* isConstructingInstance */;
1041
+ }
1042
+ {
1043
+ hostRef.$flags$ |= 128 /* isWatchReady */;
1044
+ }
1045
+ endNewInstance();
1046
+ fireConnectedCallback(hostRef.$lazyInstance$);
1047
+ }
1048
+ if (Cstr.style) {
1049
+ // this component has styles but we haven't registered them yet
1050
+ let style = Cstr.style;
1051
+ const scopeId = getScopeId(cmpMeta);
1052
+ if (!styles.has(scopeId)) {
1053
+ const endRegisterStyles = createTime('registerStyles', cmpMeta.$tagName$);
1054
+ registerStyle(scopeId, style, !!(cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */));
1055
+ endRegisterStyles();
1056
+ }
1057
+ }
1058
+ }
1059
+ // we've successfully created a lazy instance
1060
+ const ancestorComponent = hostRef.$ancestorComponent$;
1061
+ const schedule = () => scheduleUpdate(hostRef, true);
1062
+ if (ancestorComponent && ancestorComponent['s-rc']) {
1063
+ // this is the initial load and this component it has an ancestor component
1064
+ // but the ancestor component has NOT fired its will update lifecycle yet
1065
+ // so let's just cool our jets and wait for the ancestor to continue first
1066
+ // this will get fired off when the ancestor component
1067
+ // finally gets around to rendering its lazy self
1068
+ // fire off the initial update
1069
+ ancestorComponent['s-rc'].push(schedule);
1070
+ }
1071
+ else {
1072
+ schedule();
1073
+ }
1074
+ };
1075
+ const fireConnectedCallback = (instance) => {
1076
+ {
1077
+ safeCall(instance, 'connectedCallback');
1078
+ }
1079
+ };
1080
+ const connectedCallback = (elm) => {
1081
+ if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0) {
1082
+ const hostRef = getHostRef(elm);
1083
+ const cmpMeta = hostRef.$cmpMeta$;
1084
+ const endConnected = createTime('connectedCallback', cmpMeta.$tagName$);
1085
+ if (!(hostRef.$flags$ & 1 /* hasConnected */)) {
1086
+ // first time this component has connected
1087
+ hostRef.$flags$ |= 1 /* hasConnected */;
1088
+ {
1089
+ // find the first ancestor component (if there is one) and register
1090
+ // this component as one of the actively loading child components for its ancestor
1091
+ let ancestorComponent = elm;
1092
+ while ((ancestorComponent = ancestorComponent.parentNode || ancestorComponent.host)) {
1093
+ // climb up the ancestors looking for the first
1094
+ // component that hasn't finished its lifecycle update yet
1095
+ if (ancestorComponent['s-p']) {
1096
+ // we found this components first ancestor component
1097
+ // keep a reference to this component's ancestor component
1098
+ attachToAncestor(hostRef, (hostRef.$ancestorComponent$ = ancestorComponent));
1099
+ break;
1100
+ }
1101
+ }
1102
+ }
1103
+ // Lazy properties
1104
+ // https://developers.google.com/web/fundamentals/web-components/best-practices#lazy-properties
1105
+ if (cmpMeta.$members$) {
1106
+ Object.entries(cmpMeta.$members$).map(([memberName, [memberFlags]]) => {
1107
+ if (memberFlags & 31 /* Prop */ && elm.hasOwnProperty(memberName)) {
1108
+ const value = elm[memberName];
1109
+ delete elm[memberName];
1110
+ elm[memberName] = value;
1111
+ }
1112
+ });
1113
+ }
1114
+ {
1115
+ initializeComponent(elm, hostRef, cmpMeta);
1116
+ }
1117
+ }
1118
+ else {
1119
+ // not the first time this has connected
1120
+ // reattach any event listeners to the host
1121
+ // since they would have been removed when disconnected
1122
+ addHostEventListeners(elm, hostRef, cmpMeta.$listeners$);
1123
+ // fire off connectedCallback() on component instance
1124
+ fireConnectedCallback(hostRef.$lazyInstance$);
1125
+ }
1126
+ endConnected();
1127
+ }
1128
+ };
1129
+ const disconnectedCallback = (elm) => {
1130
+ if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0) {
1131
+ const hostRef = getHostRef(elm);
1132
+ {
1133
+ if (hostRef.$rmListeners$) {
1134
+ hostRef.$rmListeners$.map((rmListener) => rmListener());
1135
+ hostRef.$rmListeners$ = undefined;
1136
+ }
1137
+ }
1138
+ }
1139
+ };
1140
+ const bootstrapLazy = (lazyBundles, options = {}) => {
1141
+ const endBootstrap = createTime();
1142
+ const cmpTags = [];
1143
+ const exclude = options.exclude || [];
1144
+ const customElements = win.customElements;
1145
+ const head = doc.head;
1146
+ const metaCharset = /*@__PURE__*/ head.querySelector('meta[charset]');
1147
+ const visibilityStyle = /*@__PURE__*/ doc.createElement('style');
1148
+ const deferredConnectedCallbacks = [];
1149
+ let appLoadFallback;
1150
+ let isBootstrapping = true;
1151
+ Object.assign(plt, options);
1152
+ plt.$resourcesUrl$ = new URL(options.resourcesUrl || './', doc.baseURI).href;
1153
+ lazyBundles.map((lazyBundle) => {
1154
+ lazyBundle[1].map((compactMeta) => {
1155
+ const cmpMeta = {
1156
+ $flags$: compactMeta[0],
1157
+ $tagName$: compactMeta[1],
1158
+ $members$: compactMeta[2],
1159
+ $listeners$: compactMeta[3],
1160
+ };
1161
+ {
1162
+ cmpMeta.$members$ = compactMeta[2];
1163
+ }
1164
+ {
1165
+ cmpMeta.$listeners$ = compactMeta[3];
1166
+ }
1167
+ {
1168
+ cmpMeta.$attrsToReflect$ = [];
1169
+ }
1170
+ {
1171
+ cmpMeta.$watchers$ = {};
1172
+ }
1173
+ const tagName = cmpMeta.$tagName$;
1174
+ const HostElement = class extends HTMLElement {
1175
+ // StencilLazyHost
1176
+ constructor(self) {
1177
+ // @ts-ignore
1178
+ super(self);
1179
+ self = this;
1180
+ registerHost(self, cmpMeta);
1181
+ if (cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) {
1182
+ // this component is using shadow dom
1183
+ // and this browser supports shadow dom
1184
+ // add the read-only property "shadowRoot" to the host element
1185
+ // adding the shadow root build conditionals to minimize runtime
1186
+ {
1187
+ {
1188
+ self.attachShadow({ mode: 'open' });
1189
+ }
1190
+ }
1191
+ }
1192
+ }
1193
+ connectedCallback() {
1194
+ if (appLoadFallback) {
1195
+ clearTimeout(appLoadFallback);
1196
+ appLoadFallback = null;
1197
+ }
1198
+ if (isBootstrapping) {
1199
+ // connectedCallback will be processed once all components have been registered
1200
+ deferredConnectedCallbacks.push(this);
1201
+ }
1202
+ else {
1203
+ plt.jmp(() => connectedCallback(this));
1204
+ }
1205
+ }
1206
+ disconnectedCallback() {
1207
+ plt.jmp(() => disconnectedCallback(this));
1208
+ }
1209
+ componentOnReady() {
1210
+ return getHostRef(this).$onReadyPromise$;
1211
+ }
1212
+ };
1213
+ cmpMeta.$lazyBundleId$ = lazyBundle[0];
1214
+ if (!exclude.includes(tagName) && !customElements.get(tagName)) {
1215
+ cmpTags.push(tagName);
1216
+ customElements.define(tagName, proxyComponent(HostElement, cmpMeta, 1 /* isElementConstructor */));
1217
+ }
1218
+ });
1219
+ });
1220
+ {
1221
+ visibilityStyle.innerHTML = cmpTags + HYDRATED_CSS;
1222
+ visibilityStyle.setAttribute('data-styles', '');
1223
+ head.insertBefore(visibilityStyle, metaCharset ? metaCharset.nextSibling : head.firstChild);
1224
+ }
1225
+ // Process deferred connectedCallbacks now all components have been registered
1226
+ isBootstrapping = false;
1227
+ if (deferredConnectedCallbacks.length) {
1228
+ deferredConnectedCallbacks.map((host) => host.connectedCallback());
1229
+ }
1230
+ else {
1231
+ {
1232
+ plt.jmp(() => (appLoadFallback = setTimeout(appDidLoad, 30)));
1233
+ }
1234
+ }
1235
+ // Fallback appLoad event
1236
+ endBootstrap();
1237
+ };
1238
+ const hostRefs = new WeakMap();
1239
+ const getHostRef = (ref) => hostRefs.get(ref);
1240
+ const registerInstance = (lazyInstance, hostRef) => hostRefs.set((hostRef.$lazyInstance$ = lazyInstance), hostRef);
1241
+ const registerHost = (elm, cmpMeta) => {
1242
+ const hostRef = {
1243
+ $flags$: 0,
1244
+ $hostElement$: elm,
1245
+ $cmpMeta$: cmpMeta,
1246
+ $instanceValues$: new Map(),
1247
+ };
1248
+ {
1249
+ hostRef.$onReadyPromise$ = new Promise((r) => (hostRef.$onReadyResolve$ = r));
1250
+ elm['s-p'] = [];
1251
+ elm['s-rc'] = [];
1252
+ }
1253
+ addHostEventListeners(elm, hostRef, cmpMeta.$listeners$);
1254
+ return hostRefs.set(elm, hostRef);
1255
+ };
1256
+ const isMemberInElement = (elm, memberName) => memberName in elm;
1257
+ const consoleError = (e, el) => (0, console.error)(e, el);
1258
+ const cmpModules = /*@__PURE__*/ new Map();
1259
+ const loadModule = (cmpMeta, hostRef, hmrVersionId) => {
1260
+ // loadModuleImport
1261
+ const exportName = cmpMeta.$tagName$.replace(/-/g, '_');
1262
+ const bundleId = cmpMeta.$lazyBundleId$;
1263
+ const module = cmpModules.get(bundleId) ;
1264
+ if (module) {
1265
+ return module[exportName];
1266
+ }
1267
+ return import(
1268
+ /* webpackInclude: /\.entry\.js$/ */
1269
+ /* webpackExclude: /\.system\.entry\.js$/ */
1270
+ /* webpackMode: "lazy" */
1271
+ `./${bundleId}.entry.js${''}`).then((importedModule) => {
1272
+ {
1273
+ cmpModules.set(bundleId, importedModule);
1274
+ }
1275
+ return importedModule[exportName];
1276
+ }, consoleError);
1277
+ };
1278
+ const styles = new Map();
1279
+ const queueDomReads = [];
1280
+ const queueDomWrites = [];
1281
+ const queueTask = (queue, write) => (cb) => {
1282
+ queue.push(cb);
1283
+ if (!queuePending) {
1284
+ queuePending = true;
1285
+ if (write && plt.$flags$ & 4 /* queueSync */) {
1286
+ nextTick(flush);
1287
+ }
1288
+ else {
1289
+ plt.raf(flush);
1290
+ }
1291
+ }
1292
+ };
1293
+ const consume = (queue) => {
1294
+ for (let i = 0; i < queue.length; i++) {
1295
+ try {
1296
+ queue[i](performance.now());
1297
+ }
1298
+ catch (e) {
1299
+ consoleError(e);
1300
+ }
1301
+ }
1302
+ queue.length = 0;
1303
+ };
1304
+ const flush = () => {
1305
+ // always force a bunch of medium callbacks to run, but still have
1306
+ // a throttle on how many can run in a certain time
1307
+ // DOM READS!!!
1308
+ consume(queueDomReads);
1309
+ // DOM WRITES!!!
1310
+ {
1311
+ consume(queueDomWrites);
1312
+ if ((queuePending = queueDomReads.length > 0)) {
1313
+ // still more to do yet, but we've run out of time
1314
+ // let's let this thing cool off and try again in the next tick
1315
+ plt.raf(flush);
1316
+ }
1317
+ }
1318
+ };
1319
+ const nextTick = /*@__PURE__*/ (cb) => promiseResolve().then(cb);
1320
+ const writeTask = /*@__PURE__*/ queueTask(queueDomWrites, true);
1321
+
1322
+ export { bootstrapLazy as b, createEvent as c, getElement as g, h, promiseResolve as p, registerInstance as r };