@globalpayments/vega 1.0.0

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