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