@everymatrix/general-styling-wrapper 1.15.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 (45) hide show
  1. package/dist/cjs/general-styling-wrapper.cjs.entry.js +87 -0
  2. package/dist/cjs/general-styling-wrapper.cjs.js +19 -0
  3. package/dist/cjs/index-38077f5d.js +1407 -0
  4. package/dist/cjs/index.cjs.js +2 -0
  5. package/dist/cjs/loader.cjs.js +21 -0
  6. package/dist/collection/collection-manifest.json +12 -0
  7. package/dist/collection/components/general-styling-wrapper/general-styling-wrapper.css +3 -0
  8. package/dist/collection/components/general-styling-wrapper/general-styling-wrapper.js +145 -0
  9. package/dist/collection/index.js +1 -0
  10. package/dist/collection/utils/locale.utils.js +15 -0
  11. package/dist/components/general-styling-wrapper.d.ts +11 -0
  12. package/dist/components/general-styling-wrapper.js +105 -0
  13. package/dist/components/index.d.ts +26 -0
  14. package/dist/components/index.js +1 -0
  15. package/dist/esm/general-styling-wrapper.entry.js +83 -0
  16. package/dist/esm/general-styling-wrapper.js +17 -0
  17. package/dist/esm/index-10c47fc0.js +1382 -0
  18. package/dist/esm/index.js +1 -0
  19. package/dist/esm/loader.js +17 -0
  20. package/dist/esm/polyfills/core-js.js +11 -0
  21. package/dist/esm/polyfills/css-shim.js +1 -0
  22. package/dist/esm/polyfills/dom.js +79 -0
  23. package/dist/esm/polyfills/es5-html-element.js +1 -0
  24. package/dist/esm/polyfills/index.js +34 -0
  25. package/dist/esm/polyfills/system.js +6 -0
  26. package/dist/general-styling-wrapper/general-styling-wrapper.esm.js +1 -0
  27. package/dist/general-styling-wrapper/index.esm.js +0 -0
  28. package/dist/general-styling-wrapper/p-05de0679.js +1 -0
  29. package/dist/general-styling-wrapper/p-69081248.entry.js +1 -0
  30. package/dist/index.cjs.js +1 -0
  31. package/dist/index.js +1 -0
  32. package/dist/stencil.config.js +22 -0
  33. package/dist/types/Users/adrian.pripon/Documents/Work/widgets-stencil/packages/general-styling-wrapper/.stencil/packages/general-styling-wrapper/stencil.config.d.ts +2 -0
  34. package/dist/types/components/general-styling-wrapper/general-styling-wrapper.d.ts +26 -0
  35. package/dist/types/components.d.ts +70 -0
  36. package/dist/types/index.d.ts +1 -0
  37. package/dist/types/stencil-public-runtime.d.ts +1565 -0
  38. package/dist/types/utils/locale.utils.d.ts +8 -0
  39. package/loader/cdn.js +3 -0
  40. package/loader/index.cjs.js +3 -0
  41. package/loader/index.d.ts +12 -0
  42. package/loader/index.es2017.js +3 -0
  43. package/loader/index.js +4 -0
  44. package/loader/package.json +10 -0
  45. package/package.json +19 -0
@@ -0,0 +1,1382 @@
1
+ const NAMESPACE = 'general-styling-wrapper';
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
+ 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 (memberName === 'ref') {
216
+ // minifier will clean this up
217
+ if (newValue) {
218
+ newValue(elm);
219
+ }
220
+ }
221
+ else {
222
+ // Set property if it exists and it's not a SVG
223
+ const isComplex = isComplexType(newValue);
224
+ if ((isProp || (isComplex && newValue !== null)) && !isSvg) {
225
+ try {
226
+ if (!elm.tagName.includes('-')) {
227
+ let n = newValue == null ? '' : newValue;
228
+ // Workaround for Safari, moving the <input> caret when re-assigning the same valued
229
+ if (memberName === 'list') {
230
+ isProp = false;
231
+ }
232
+ else if (oldValue == null || elm[memberName] != n) {
233
+ elm[memberName] = n;
234
+ }
235
+ }
236
+ else {
237
+ elm[memberName] = newValue;
238
+ }
239
+ }
240
+ catch (e) { }
241
+ }
242
+ if (newValue == null || newValue === false) {
243
+ if (newValue !== false || elm.getAttribute(memberName) === '') {
244
+ {
245
+ elm.removeAttribute(memberName);
246
+ }
247
+ }
248
+ }
249
+ else if ((!isProp || flags & 4 /* isHost */ || isSvg) && !isComplex) {
250
+ newValue = newValue === true ? '' : newValue;
251
+ {
252
+ elm.setAttribute(memberName, newValue);
253
+ }
254
+ }
255
+ }
256
+ }
257
+ };
258
+ const parseClassListRegex = /\s/;
259
+ const parseClassList = (value) => (!value ? [] : value.split(parseClassListRegex));
260
+ const updateElement = (oldVnode, newVnode, isSvgMode, memberName) => {
261
+ // if the element passed in is a shadow root, which is a document fragment
262
+ // then we want to be adding attrs/props to the shadow root's "host" element
263
+ // if it's not a shadow root, then we add attrs/props to the same element
264
+ const elm = newVnode.$elm$.nodeType === 11 /* DocumentFragment */ && newVnode.$elm$.host
265
+ ? newVnode.$elm$.host
266
+ : newVnode.$elm$;
267
+ const oldVnodeAttrs = (oldVnode && oldVnode.$attrs$) || EMPTY_OBJ;
268
+ const newVnodeAttrs = newVnode.$attrs$ || EMPTY_OBJ;
269
+ {
270
+ // remove attributes no longer present on the vnode by setting them to undefined
271
+ for (memberName in oldVnodeAttrs) {
272
+ if (!(memberName in newVnodeAttrs)) {
273
+ setAccessor(elm, memberName, oldVnodeAttrs[memberName], undefined, isSvgMode, newVnode.$flags$);
274
+ }
275
+ }
276
+ }
277
+ // add new & update changed attributes
278
+ for (memberName in newVnodeAttrs) {
279
+ setAccessor(elm, memberName, oldVnodeAttrs[memberName], newVnodeAttrs[memberName], isSvgMode, newVnode.$flags$);
280
+ }
281
+ };
282
+ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
283
+ // tslint:disable-next-line: prefer-const
284
+ let newVNode = newParentVNode.$children$[childIndex];
285
+ let i = 0;
286
+ let elm;
287
+ let childNode;
288
+ let oldVNode;
289
+ if (!useNativeShadowDom) {
290
+ // remember for later we need to check to relocate nodes
291
+ checkSlotRelocate = true;
292
+ if (newVNode.$tag$ === 'slot') {
293
+ newVNode.$flags$ |= newVNode.$children$
294
+ ? // slot element has fallback content
295
+ 2 /* isSlotFallback */
296
+ : // slot element does not have fallback content
297
+ 1 /* isSlotReference */;
298
+ }
299
+ }
300
+ if (newVNode.$flags$ & 1 /* isSlotReference */) {
301
+ // create a slot reference node
302
+ elm = newVNode.$elm$ =
303
+ doc.createTextNode('');
304
+ }
305
+ else {
306
+ // create element
307
+ elm = newVNode.$elm$ = (doc.createElement(newVNode.$flags$ & 2 /* isSlotFallback */
308
+ ? 'slot-fb'
309
+ : newVNode.$tag$));
310
+ // add css classes, attrs, props, listeners, etc.
311
+ {
312
+ updateElement(null, newVNode, isSvgMode);
313
+ }
314
+ if (newVNode.$children$) {
315
+ for (i = 0; i < newVNode.$children$.length; ++i) {
316
+ // create the node
317
+ childNode = createElm(oldParentVNode, newVNode, i);
318
+ // return node could have been null
319
+ if (childNode) {
320
+ // append our new node
321
+ elm.appendChild(childNode);
322
+ }
323
+ }
324
+ }
325
+ }
326
+ {
327
+ elm['s-hn'] = hostTagName;
328
+ if (newVNode.$flags$ & (2 /* isSlotFallback */ | 1 /* isSlotReference */)) {
329
+ // remember the content reference comment
330
+ elm['s-sr'] = true;
331
+ // remember the content reference comment
332
+ elm['s-cr'] = contentRef;
333
+ // remember the slot name, or empty string for default slot
334
+ elm['s-sn'] = newVNode.$name$ || '';
335
+ // check if we've got an old vnode for this slot
336
+ oldVNode = oldParentVNode && oldParentVNode.$children$ && oldParentVNode.$children$[childIndex];
337
+ if (oldVNode && oldVNode.$tag$ === newVNode.$tag$ && oldParentVNode.$elm$) {
338
+ // we've got an old slot vnode and the wrapper is being replaced
339
+ // so let's move the old slot content back to it's original location
340
+ putBackInOriginalLocation(oldParentVNode.$elm$, false);
341
+ }
342
+ }
343
+ }
344
+ return elm;
345
+ };
346
+ const putBackInOriginalLocation = (parentElm, recursive) => {
347
+ plt.$flags$ |= 1 /* isTmpDisconnected */;
348
+ const oldSlotChildNodes = parentElm.childNodes;
349
+ for (let i = oldSlotChildNodes.length - 1; i >= 0; i--) {
350
+ const childNode = oldSlotChildNodes[i];
351
+ if (childNode['s-hn'] !== hostTagName && childNode['s-ol']) {
352
+ // // this child node in the old element is from another component
353
+ // // remove this node from the old slot's parent
354
+ // childNode.remove();
355
+ // and relocate it back to it's original location
356
+ parentReferenceNode(childNode).insertBefore(childNode, referenceNode(childNode));
357
+ // remove the old original location comment entirely
358
+ // later on the patch function will know what to do
359
+ // and move this to the correct spot in need be
360
+ childNode['s-ol'].remove();
361
+ childNode['s-ol'] = undefined;
362
+ checkSlotRelocate = true;
363
+ }
364
+ if (recursive) {
365
+ putBackInOriginalLocation(childNode, recursive);
366
+ }
367
+ }
368
+ plt.$flags$ &= ~1 /* isTmpDisconnected */;
369
+ };
370
+ const addVnodes = (parentElm, before, parentVNode, vnodes, startIdx, endIdx) => {
371
+ let containerElm = ((parentElm['s-cr'] && parentElm['s-cr'].parentNode) || parentElm);
372
+ let childNode;
373
+ for (; startIdx <= endIdx; ++startIdx) {
374
+ if (vnodes[startIdx]) {
375
+ childNode = createElm(null, parentVNode, startIdx);
376
+ if (childNode) {
377
+ vnodes[startIdx].$elm$ = childNode;
378
+ containerElm.insertBefore(childNode, referenceNode(before) );
379
+ }
380
+ }
381
+ }
382
+ };
383
+ const removeVnodes = (vnodes, startIdx, endIdx, vnode, elm) => {
384
+ for (; startIdx <= endIdx; ++startIdx) {
385
+ if ((vnode = vnodes[startIdx])) {
386
+ elm = vnode.$elm$;
387
+ callNodeRefs(vnode);
388
+ {
389
+ // we're removing this element
390
+ // so it's possible we need to show slot fallback content now
391
+ checkSlotFallbackVisibility = true;
392
+ if (elm['s-ol']) {
393
+ // remove the original location comment
394
+ elm['s-ol'].remove();
395
+ }
396
+ else {
397
+ // it's possible that child nodes of the node
398
+ // that's being removed are slot nodes
399
+ putBackInOriginalLocation(elm, true);
400
+ }
401
+ }
402
+ // remove the vnode's element from the dom
403
+ elm.remove();
404
+ }
405
+ }
406
+ };
407
+ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
408
+ let oldStartIdx = 0;
409
+ let newStartIdx = 0;
410
+ let oldEndIdx = oldCh.length - 1;
411
+ let oldStartVnode = oldCh[0];
412
+ let oldEndVnode = oldCh[oldEndIdx];
413
+ let newEndIdx = newCh.length - 1;
414
+ let newStartVnode = newCh[0];
415
+ let newEndVnode = newCh[newEndIdx];
416
+ let node;
417
+ while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
418
+ if (oldStartVnode == null) {
419
+ // Vnode might have been moved left
420
+ oldStartVnode = oldCh[++oldStartIdx];
421
+ }
422
+ else if (oldEndVnode == null) {
423
+ oldEndVnode = oldCh[--oldEndIdx];
424
+ }
425
+ else if (newStartVnode == null) {
426
+ newStartVnode = newCh[++newStartIdx];
427
+ }
428
+ else if (newEndVnode == null) {
429
+ newEndVnode = newCh[--newEndIdx];
430
+ }
431
+ else if (isSameVnode(oldStartVnode, newStartVnode)) {
432
+ patch(oldStartVnode, newStartVnode);
433
+ oldStartVnode = oldCh[++oldStartIdx];
434
+ newStartVnode = newCh[++newStartIdx];
435
+ }
436
+ else if (isSameVnode(oldEndVnode, newEndVnode)) {
437
+ patch(oldEndVnode, newEndVnode);
438
+ oldEndVnode = oldCh[--oldEndIdx];
439
+ newEndVnode = newCh[--newEndIdx];
440
+ }
441
+ else if (isSameVnode(oldStartVnode, newEndVnode)) {
442
+ // Vnode moved right
443
+ if ((oldStartVnode.$tag$ === 'slot' || newEndVnode.$tag$ === 'slot')) {
444
+ putBackInOriginalLocation(oldStartVnode.$elm$.parentNode, false);
445
+ }
446
+ patch(oldStartVnode, newEndVnode);
447
+ parentElm.insertBefore(oldStartVnode.$elm$, oldEndVnode.$elm$.nextSibling);
448
+ oldStartVnode = oldCh[++oldStartIdx];
449
+ newEndVnode = newCh[--newEndIdx];
450
+ }
451
+ else if (isSameVnode(oldEndVnode, newStartVnode)) {
452
+ // Vnode moved left
453
+ if ((oldStartVnode.$tag$ === 'slot' || newEndVnode.$tag$ === 'slot')) {
454
+ putBackInOriginalLocation(oldEndVnode.$elm$.parentNode, false);
455
+ }
456
+ patch(oldEndVnode, newStartVnode);
457
+ parentElm.insertBefore(oldEndVnode.$elm$, oldStartVnode.$elm$);
458
+ oldEndVnode = oldCh[--oldEndIdx];
459
+ newStartVnode = newCh[++newStartIdx];
460
+ }
461
+ else {
462
+ {
463
+ // new element
464
+ node = createElm(oldCh && oldCh[newStartIdx], newVNode, newStartIdx);
465
+ newStartVnode = newCh[++newStartIdx];
466
+ }
467
+ if (node) {
468
+ {
469
+ parentReferenceNode(oldStartVnode.$elm$).insertBefore(node, referenceNode(oldStartVnode.$elm$));
470
+ }
471
+ }
472
+ }
473
+ }
474
+ if (oldStartIdx > oldEndIdx) {
475
+ addVnodes(parentElm, newCh[newEndIdx + 1] == null ? null : newCh[newEndIdx + 1].$elm$, newVNode, newCh, newStartIdx, newEndIdx);
476
+ }
477
+ else if (newStartIdx > newEndIdx) {
478
+ removeVnodes(oldCh, oldStartIdx, oldEndIdx);
479
+ }
480
+ };
481
+ const isSameVnode = (vnode1, vnode2) => {
482
+ // compare if two vnode to see if they're "technically" the same
483
+ // need to have the same element tag, and same key to be the same
484
+ if (vnode1.$tag$ === vnode2.$tag$) {
485
+ if (vnode1.$tag$ === 'slot') {
486
+ return vnode1.$name$ === vnode2.$name$;
487
+ }
488
+ return true;
489
+ }
490
+ return false;
491
+ };
492
+ const referenceNode = (node) => {
493
+ // this node was relocated to a new location in the dom
494
+ // because of some other component's slot
495
+ // but we still have an html comment in place of where
496
+ // it's original location was according to it's original vdom
497
+ return (node && node['s-ol']) || node;
498
+ };
499
+ const parentReferenceNode = (node) => (node['s-ol'] ? node['s-ol'] : node).parentNode;
500
+ const patch = (oldVNode, newVNode) => {
501
+ const elm = (newVNode.$elm$ = oldVNode.$elm$);
502
+ const oldChildren = oldVNode.$children$;
503
+ const newChildren = newVNode.$children$;
504
+ const tag = newVNode.$tag$;
505
+ {
506
+ // element node
507
+ {
508
+ if (tag === 'slot')
509
+ ;
510
+ else {
511
+ // either this is the first render of an element OR it's an update
512
+ // AND we already know it's possible it could have changed
513
+ // this updates the element's css classes, attrs, props, listeners, etc.
514
+ updateElement(oldVNode, newVNode, isSvgMode);
515
+ }
516
+ }
517
+ if (oldChildren !== null && newChildren !== null) {
518
+ // looks like there's child vnodes for both the old and new vnodes
519
+ updateChildren(elm, oldChildren, newVNode, newChildren);
520
+ }
521
+ else if (newChildren !== null) {
522
+ // add the new vnode children
523
+ addVnodes(elm, null, newVNode, newChildren, 0, newChildren.length - 1);
524
+ }
525
+ else if (oldChildren !== null) {
526
+ // no new child vnodes, but there are old child vnodes to remove
527
+ removeVnodes(oldChildren, 0, oldChildren.length - 1);
528
+ }
529
+ }
530
+ };
531
+ const updateFallbackSlotVisibility = (elm) => {
532
+ // tslint:disable-next-line: prefer-const
533
+ let childNodes = elm.childNodes;
534
+ let childNode;
535
+ let i;
536
+ let ilen;
537
+ let j;
538
+ let slotNameAttr;
539
+ let nodeType;
540
+ for (i = 0, ilen = childNodes.length; i < ilen; i++) {
541
+ childNode = childNodes[i];
542
+ if (childNode.nodeType === 1 /* ElementNode */) {
543
+ if (childNode['s-sr']) {
544
+ // this is a slot fallback node
545
+ // get the slot name for this slot reference node
546
+ slotNameAttr = childNode['s-sn'];
547
+ // by default always show a fallback slot node
548
+ // then hide it if there are other slots in the light dom
549
+ childNode.hidden = false;
550
+ for (j = 0; j < ilen; j++) {
551
+ nodeType = childNodes[j].nodeType;
552
+ if (childNodes[j]['s-hn'] !== childNode['s-hn'] || slotNameAttr !== '') {
553
+ // this sibling node is from a different component OR is a named fallback slot node
554
+ if (nodeType === 1 /* ElementNode */ && slotNameAttr === childNodes[j].getAttribute('slot')) {
555
+ childNode.hidden = true;
556
+ break;
557
+ }
558
+ }
559
+ else {
560
+ // this is a default fallback slot node
561
+ // any element or text node (with content)
562
+ // should hide the default fallback slot node
563
+ if (nodeType === 1 /* ElementNode */ ||
564
+ (nodeType === 3 /* TextNode */ && childNodes[j].textContent.trim() !== '')) {
565
+ childNode.hidden = true;
566
+ break;
567
+ }
568
+ }
569
+ }
570
+ }
571
+ // keep drilling down
572
+ updateFallbackSlotVisibility(childNode);
573
+ }
574
+ }
575
+ };
576
+ const relocateNodes = [];
577
+ const relocateSlotContent = (elm) => {
578
+ // tslint:disable-next-line: prefer-const
579
+ let childNode;
580
+ let node;
581
+ let hostContentNodes;
582
+ let slotNameAttr;
583
+ let relocateNodeData;
584
+ let j;
585
+ let i = 0;
586
+ let childNodes = elm.childNodes;
587
+ let ilen = childNodes.length;
588
+ for (; i < ilen; i++) {
589
+ childNode = childNodes[i];
590
+ if (childNode['s-sr'] && (node = childNode['s-cr']) && node.parentNode) {
591
+ // first got the content reference comment node
592
+ // then we got it's parent, which is where all the host content is in now
593
+ hostContentNodes = node.parentNode.childNodes;
594
+ slotNameAttr = childNode['s-sn'];
595
+ for (j = hostContentNodes.length - 1; j >= 0; j--) {
596
+ node = hostContentNodes[j];
597
+ if (!node['s-cn'] && !node['s-nr'] && node['s-hn'] !== childNode['s-hn']) {
598
+ // let's do some relocating to its new home
599
+ // but never relocate a content reference node
600
+ // that is suppose to always represent the original content location
601
+ if (isNodeLocatedInSlot(node, slotNameAttr)) {
602
+ // it's possible we've already decided to relocate this node
603
+ relocateNodeData = relocateNodes.find((r) => r.$nodeToRelocate$ === node);
604
+ // made some changes to slots
605
+ // let's make sure we also double check
606
+ // fallbacks are correctly hidden or shown
607
+ checkSlotFallbackVisibility = true;
608
+ node['s-sn'] = node['s-sn'] || slotNameAttr;
609
+ if (relocateNodeData) {
610
+ // previously we never found a slot home for this node
611
+ // but turns out we did, so let's remember it now
612
+ relocateNodeData.$slotRefNode$ = childNode;
613
+ }
614
+ else {
615
+ // add to our list of nodes to relocate
616
+ relocateNodes.push({
617
+ $slotRefNode$: childNode,
618
+ $nodeToRelocate$: node,
619
+ });
620
+ }
621
+ if (node['s-sr']) {
622
+ relocateNodes.map((relocateNode) => {
623
+ if (isNodeLocatedInSlot(relocateNode.$nodeToRelocate$, node['s-sn'])) {
624
+ relocateNodeData = relocateNodes.find((r) => r.$nodeToRelocate$ === node);
625
+ if (relocateNodeData && !relocateNode.$slotRefNode$) {
626
+ relocateNode.$slotRefNode$ = relocateNodeData.$slotRefNode$;
627
+ }
628
+ }
629
+ });
630
+ }
631
+ }
632
+ else if (!relocateNodes.some((r) => r.$nodeToRelocate$ === node)) {
633
+ // so far this element does not have a slot home, not setting slotRefNode on purpose
634
+ // if we never find a home for this element then we'll need to hide it
635
+ relocateNodes.push({
636
+ $nodeToRelocate$: node,
637
+ });
638
+ }
639
+ }
640
+ }
641
+ }
642
+ if (childNode.nodeType === 1 /* ElementNode */) {
643
+ relocateSlotContent(childNode);
644
+ }
645
+ }
646
+ };
647
+ const isNodeLocatedInSlot = (nodeToRelocate, slotNameAttr) => {
648
+ if (nodeToRelocate.nodeType === 1 /* ElementNode */) {
649
+ if (nodeToRelocate.getAttribute('slot') === null && slotNameAttr === '') {
650
+ return true;
651
+ }
652
+ if (nodeToRelocate.getAttribute('slot') === slotNameAttr) {
653
+ return true;
654
+ }
655
+ return false;
656
+ }
657
+ if (nodeToRelocate['s-sn'] === slotNameAttr) {
658
+ return true;
659
+ }
660
+ return slotNameAttr === '';
661
+ };
662
+ const callNodeRefs = (vNode) => {
663
+ {
664
+ vNode.$attrs$ && vNode.$attrs$.ref && vNode.$attrs$.ref(null);
665
+ vNode.$children$ && vNode.$children$.map(callNodeRefs);
666
+ }
667
+ };
668
+ const renderVdom = (hostRef, renderFnResults) => {
669
+ const hostElm = hostRef.$hostElement$;
670
+ const cmpMeta = hostRef.$cmpMeta$;
671
+ const oldVNode = hostRef.$vnode$ || newVNode(null, null);
672
+ const rootVnode = isHost(renderFnResults) ? renderFnResults : h(null, null, renderFnResults);
673
+ hostTagName = hostElm.tagName;
674
+ rootVnode.$tag$ = null;
675
+ rootVnode.$flags$ |= 4 /* isHost */;
676
+ hostRef.$vnode$ = rootVnode;
677
+ rootVnode.$elm$ = oldVNode.$elm$ = (hostElm);
678
+ {
679
+ contentRef = hostElm['s-cr'];
680
+ useNativeShadowDom = (cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) !== 0;
681
+ // always reset
682
+ checkSlotFallbackVisibility = false;
683
+ }
684
+ // synchronous patch
685
+ patch(oldVNode, rootVnode);
686
+ {
687
+ // while we're moving nodes around existing nodes, temporarily disable
688
+ // the disconnectCallback from working
689
+ plt.$flags$ |= 1 /* isTmpDisconnected */;
690
+ if (checkSlotRelocate) {
691
+ relocateSlotContent(rootVnode.$elm$);
692
+ let relocateData;
693
+ let nodeToRelocate;
694
+ let orgLocationNode;
695
+ let parentNodeRef;
696
+ let insertBeforeNode;
697
+ let refNode;
698
+ let i = 0;
699
+ for (; i < relocateNodes.length; i++) {
700
+ relocateData = relocateNodes[i];
701
+ nodeToRelocate = relocateData.$nodeToRelocate$;
702
+ if (!nodeToRelocate['s-ol']) {
703
+ // add a reference node marking this node's original location
704
+ // keep a reference to this node for later lookups
705
+ orgLocationNode =
706
+ doc.createTextNode('');
707
+ orgLocationNode['s-nr'] = nodeToRelocate;
708
+ nodeToRelocate.parentNode.insertBefore((nodeToRelocate['s-ol'] = orgLocationNode), nodeToRelocate);
709
+ }
710
+ }
711
+ for (i = 0; i < relocateNodes.length; i++) {
712
+ relocateData = relocateNodes[i];
713
+ nodeToRelocate = relocateData.$nodeToRelocate$;
714
+ if (relocateData.$slotRefNode$) {
715
+ // by default we're just going to insert it directly
716
+ // after the slot reference node
717
+ parentNodeRef = relocateData.$slotRefNode$.parentNode;
718
+ insertBeforeNode = relocateData.$slotRefNode$.nextSibling;
719
+ orgLocationNode = nodeToRelocate['s-ol'];
720
+ while ((orgLocationNode = orgLocationNode.previousSibling)) {
721
+ refNode = orgLocationNode['s-nr'];
722
+ if (refNode && refNode['s-sn'] === nodeToRelocate['s-sn'] && parentNodeRef === refNode.parentNode) {
723
+ refNode = refNode.nextSibling;
724
+ if (!refNode || !refNode['s-nr']) {
725
+ insertBeforeNode = refNode;
726
+ break;
727
+ }
728
+ }
729
+ }
730
+ if ((!insertBeforeNode && parentNodeRef !== nodeToRelocate.parentNode) ||
731
+ nodeToRelocate.nextSibling !== insertBeforeNode) {
732
+ // we've checked that it's worth while to relocate
733
+ // since that the node to relocate
734
+ // has a different next sibling or parent relocated
735
+ if (nodeToRelocate !== insertBeforeNode) {
736
+ if (!nodeToRelocate['s-hn'] && nodeToRelocate['s-ol']) {
737
+ // probably a component in the index.html that doesn't have it's hostname set
738
+ nodeToRelocate['s-hn'] = nodeToRelocate['s-ol'].parentNode.nodeName;
739
+ }
740
+ // add it back to the dom but in its new home
741
+ parentNodeRef.insertBefore(nodeToRelocate, insertBeforeNode);
742
+ }
743
+ }
744
+ }
745
+ else {
746
+ // this node doesn't have a slot home to go to, so let's hide it
747
+ if (nodeToRelocate.nodeType === 1 /* ElementNode */) {
748
+ nodeToRelocate.hidden = true;
749
+ }
750
+ }
751
+ }
752
+ }
753
+ if (checkSlotFallbackVisibility) {
754
+ updateFallbackSlotVisibility(rootVnode.$elm$);
755
+ }
756
+ // done moving nodes around
757
+ // allow the disconnect callback to work again
758
+ plt.$flags$ &= ~1 /* isTmpDisconnected */;
759
+ // always reset
760
+ relocateNodes.length = 0;
761
+ }
762
+ };
763
+ /**
764
+ * Helper function to create & dispatch a custom Event on a provided target
765
+ * @param elm the target of the Event
766
+ * @param name the name to give the custom Event
767
+ * @param opts options for configuring a custom Event
768
+ * @returns the custom Event
769
+ */
770
+ const emitEvent = (elm, name, opts) => {
771
+ const ev = plt.ce(name, opts);
772
+ elm.dispatchEvent(ev);
773
+ return ev;
774
+ };
775
+ const attachToAncestor = (hostRef, ancestorComponent) => {
776
+ if (ancestorComponent && !hostRef.$onRenderResolve$ && ancestorComponent['s-p']) {
777
+ ancestorComponent['s-p'].push(new Promise((r) => (hostRef.$onRenderResolve$ = r)));
778
+ }
779
+ };
780
+ const scheduleUpdate = (hostRef, isInitialLoad) => {
781
+ {
782
+ hostRef.$flags$ |= 16 /* isQueuedForUpdate */;
783
+ }
784
+ if (hostRef.$flags$ & 4 /* isWaitingForChildren */) {
785
+ hostRef.$flags$ |= 512 /* needsRerender */;
786
+ return;
787
+ }
788
+ attachToAncestor(hostRef, hostRef.$ancestorComponent$);
789
+ // there is no ancestor component or the ancestor component
790
+ // has already fired off its lifecycle update then
791
+ // fire off the initial update
792
+ const dispatch = () => dispatchHooks(hostRef, isInitialLoad);
793
+ return writeTask(dispatch) ;
794
+ };
795
+ const dispatchHooks = (hostRef, isInitialLoad) => {
796
+ const endSchedule = createTime('scheduleUpdate', hostRef.$cmpMeta$.$tagName$);
797
+ const instance = hostRef.$lazyInstance$ ;
798
+ let promise;
799
+ if (isInitialLoad) {
800
+ {
801
+ promise = safeCall(instance, 'componentWillLoad');
802
+ }
803
+ }
804
+ endSchedule();
805
+ return then(promise, () => updateComponent(hostRef, instance, isInitialLoad));
806
+ };
807
+ const updateComponent = async (hostRef, instance, isInitialLoad) => {
808
+ // updateComponent
809
+ const elm = hostRef.$hostElement$;
810
+ const endUpdate = createTime('update', hostRef.$cmpMeta$.$tagName$);
811
+ const rc = elm['s-rc'];
812
+ if (isInitialLoad) {
813
+ // DOM WRITE!
814
+ attachStyles(hostRef);
815
+ }
816
+ const endRender = createTime('render', hostRef.$cmpMeta$.$tagName$);
817
+ {
818
+ callRender(hostRef, instance);
819
+ }
820
+ if (rc) {
821
+ // ok, so turns out there are some child host elements
822
+ // waiting on this parent element to load
823
+ // let's fire off all update callbacks waiting
824
+ rc.map((cb) => cb());
825
+ elm['s-rc'] = undefined;
826
+ }
827
+ endRender();
828
+ endUpdate();
829
+ {
830
+ const childrenPromises = elm['s-p'];
831
+ const postUpdate = () => postUpdateComponent(hostRef);
832
+ if (childrenPromises.length === 0) {
833
+ postUpdate();
834
+ }
835
+ else {
836
+ Promise.all(childrenPromises).then(postUpdate);
837
+ hostRef.$flags$ |= 4 /* isWaitingForChildren */;
838
+ childrenPromises.length = 0;
839
+ }
840
+ }
841
+ };
842
+ const callRender = (hostRef, instance, elm) => {
843
+ try {
844
+ instance = instance.render() ;
845
+ {
846
+ hostRef.$flags$ &= ~16 /* isQueuedForUpdate */;
847
+ }
848
+ {
849
+ hostRef.$flags$ |= 2 /* hasRendered */;
850
+ }
851
+ {
852
+ {
853
+ // looks like we've got child nodes to render into this host element
854
+ // or we need to update the css class/attrs on the host element
855
+ // DOM WRITE!
856
+ {
857
+ renderVdom(hostRef, instance);
858
+ }
859
+ }
860
+ }
861
+ }
862
+ catch (e) {
863
+ consoleError(e, hostRef.$hostElement$);
864
+ }
865
+ return null;
866
+ };
867
+ const postUpdateComponent = (hostRef) => {
868
+ const tagName = hostRef.$cmpMeta$.$tagName$;
869
+ const elm = hostRef.$hostElement$;
870
+ const endPostUpdate = createTime('postUpdate', tagName);
871
+ const instance = hostRef.$lazyInstance$ ;
872
+ const ancestorComponent = hostRef.$ancestorComponent$;
873
+ {
874
+ safeCall(instance, 'componentDidRender');
875
+ }
876
+ if (!(hostRef.$flags$ & 64 /* hasLoadedComponent */)) {
877
+ hostRef.$flags$ |= 64 /* hasLoadedComponent */;
878
+ {
879
+ // DOM WRITE!
880
+ addHydratedFlag(elm);
881
+ }
882
+ endPostUpdate();
883
+ {
884
+ hostRef.$onReadyResolve$(elm);
885
+ if (!ancestorComponent) {
886
+ appDidLoad();
887
+ }
888
+ }
889
+ }
890
+ else {
891
+ endPostUpdate();
892
+ }
893
+ // load events fire from bottom to top
894
+ // the deepest elements load first then bubbles up
895
+ {
896
+ if (hostRef.$onRenderResolve$) {
897
+ hostRef.$onRenderResolve$();
898
+ hostRef.$onRenderResolve$ = undefined;
899
+ }
900
+ if (hostRef.$flags$ & 512 /* needsRerender */) {
901
+ nextTick(() => scheduleUpdate(hostRef, false));
902
+ }
903
+ hostRef.$flags$ &= ~(4 /* isWaitingForChildren */ | 512 /* needsRerender */);
904
+ }
905
+ // ( •_•)
906
+ // ( •_•)>⌐■-■
907
+ // (⌐■_■)
908
+ };
909
+ const appDidLoad = (who) => {
910
+ // on appload
911
+ // we have finish the first big initial render
912
+ {
913
+ addHydratedFlag(doc.documentElement);
914
+ }
915
+ nextTick(() => emitEvent(win, 'appload', { detail: { namespace: NAMESPACE } }));
916
+ };
917
+ const safeCall = (instance, method, arg) => {
918
+ if (instance && instance[method]) {
919
+ try {
920
+ return instance[method](arg);
921
+ }
922
+ catch (e) {
923
+ consoleError(e);
924
+ }
925
+ }
926
+ return undefined;
927
+ };
928
+ const then = (promise, thenFn) => {
929
+ return promise && promise.then ? promise.then(thenFn) : thenFn();
930
+ };
931
+ const addHydratedFlag = (elm) => elm.classList.add('hydrated')
932
+ ;
933
+ /**
934
+ * Parse a new property value for a given property type.
935
+ *
936
+ * While the prop value can reasonably be expected to be of `any` type as far as TypeScript's type checker is concerned,
937
+ * it is not safe to assume that the string returned by evaluating `typeof propValue` matches:
938
+ * 1. `any`, the type given to `propValue` in the function signature
939
+ * 2. the type stored from `propType`.
940
+ *
941
+ * This function provides the capability to parse/coerce a property's value to potentially any other JavaScript type.
942
+ *
943
+ * Property values represented in TSX preserve their type information. In the example below, the number 0 is passed to
944
+ * a component. This `propValue` will preserve its type information (`typeof propValue === 'number'`). Note that is
945
+ * based on the type of the value being passed in, not the type declared of the class member decorated with `@Prop`.
946
+ * ```tsx
947
+ * <my-cmp prop-val={0}></my-cmp>
948
+ * ```
949
+ *
950
+ * HTML prop values on the other hand, will always a string
951
+ *
952
+ * @param propValue the new value to coerce to some type
953
+ * @param propType the type of the prop, expressed as a binary number
954
+ * @returns the parsed/coerced value
955
+ */
956
+ const parsePropertyValue = (propValue, propType) => {
957
+ // ensure this value is of the correct prop type
958
+ if (propValue != null && !isComplexType(propValue)) {
959
+ if (propType & 1 /* String */) {
960
+ // could have been passed as a number or boolean
961
+ // but we still want it as a string
962
+ return String(propValue);
963
+ }
964
+ // redundant return here for better minification
965
+ return propValue;
966
+ }
967
+ // not sure exactly what type we want
968
+ // so no need to change to a different type
969
+ return propValue;
970
+ };
971
+ const getValue = (ref, propName) => getHostRef(ref).$instanceValues$.get(propName);
972
+ const setValue = (ref, propName, newVal, cmpMeta) => {
973
+ // check our new property value against our internal value
974
+ const hostRef = getHostRef(ref);
975
+ const oldVal = hostRef.$instanceValues$.get(propName);
976
+ const flags = hostRef.$flags$;
977
+ const instance = hostRef.$lazyInstance$ ;
978
+ newVal = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]);
979
+ // explicitly check for NaN on both sides, as `NaN === NaN` is always false
980
+ const areBothNaN = Number.isNaN(oldVal) && Number.isNaN(newVal);
981
+ const didValueChange = newVal !== oldVal && !areBothNaN;
982
+ if ((!(flags & 8 /* isConstructingInstance */) || oldVal === undefined) && didValueChange) {
983
+ // gadzooks! the property's value has changed!!
984
+ // set our new value!
985
+ hostRef.$instanceValues$.set(propName, newVal);
986
+ if (instance) {
987
+ if ((flags & (2 /* hasRendered */ | 16 /* isQueuedForUpdate */)) === 2 /* hasRendered */) {
988
+ // looks like this value actually changed, so we've got work to do!
989
+ // but only if we've already rendered, otherwise just chill out
990
+ // queue that we need to do an update, but don't worry about queuing
991
+ // up millions cuz this function ensures it only runs once
992
+ scheduleUpdate(hostRef, false);
993
+ }
994
+ }
995
+ }
996
+ };
997
+ const proxyComponent = (Cstr, cmpMeta, flags) => {
998
+ if (cmpMeta.$members$) {
999
+ // It's better to have a const than two Object.entries()
1000
+ const members = Object.entries(cmpMeta.$members$);
1001
+ const prototype = Cstr.prototype;
1002
+ members.map(([memberName, [memberFlags]]) => {
1003
+ if ((memberFlags & 31 /* Prop */ ||
1004
+ ((flags & 2 /* proxyState */) && memberFlags & 32 /* State */))) {
1005
+ // proxyComponent - prop
1006
+ Object.defineProperty(prototype, memberName, {
1007
+ get() {
1008
+ // proxyComponent, get value
1009
+ return getValue(this, memberName);
1010
+ },
1011
+ set(newValue) {
1012
+ // proxyComponent, set value
1013
+ setValue(this, memberName, newValue, cmpMeta);
1014
+ },
1015
+ configurable: true,
1016
+ enumerable: true,
1017
+ });
1018
+ }
1019
+ });
1020
+ if ((flags & 1 /* isElementConstructor */)) {
1021
+ const attrNameToPropName = new Map();
1022
+ prototype.attributeChangedCallback = function (attrName, _oldValue, newValue) {
1023
+ plt.jmp(() => {
1024
+ const propName = attrNameToPropName.get(attrName);
1025
+ // In a web component lifecycle the attributeChangedCallback runs prior to connectedCallback
1026
+ // in the case where an attribute was set inline.
1027
+ // ```html
1028
+ // <my-component some-attribute="some-value"></my-component>
1029
+ // ```
1030
+ //
1031
+ // There is an edge case where a developer sets the attribute inline on a custom element and then
1032
+ // programmatically changes it before it has been upgraded as shown below:
1033
+ //
1034
+ // ```html
1035
+ // <!-- this component has _not_ been upgraded yet -->
1036
+ // <my-component id="test" some-attribute="some-value"></my-component>
1037
+ // <script>
1038
+ // // grab non-upgraded component
1039
+ // el = document.querySelector("#test");
1040
+ // el.someAttribute = "another-value";
1041
+ // // upgrade component
1042
+ // customElements.define('my-component', MyComponent);
1043
+ // </script>
1044
+ // ```
1045
+ // In this case if we do not unshadow here and use the value of the shadowing property, attributeChangedCallback
1046
+ // will be called with `newValue = "some-value"` and will set the shadowed property (this.someAttribute = "another-value")
1047
+ // to the value that was set inline i.e. "some-value" from above example. When
1048
+ // the connectedCallback attempts to unshadow it will use "some-value" as the initial value rather than "another-value"
1049
+ //
1050
+ // The case where the attribute was NOT set inline but was not set programmatically shall be handled/unshadowed
1051
+ // by connectedCallback as this attributeChangedCallback will not fire.
1052
+ //
1053
+ // https://developers.google.com/web/fundamentals/web-components/best-practices#lazy-properties
1054
+ //
1055
+ // TODO(STENCIL-16) we should think about whether or not we actually want to be reflecting the attributes to
1056
+ // properties here given that this goes against best practices outlined here
1057
+ // https://developers.google.com/web/fundamentals/web-components/best-practices#avoid-reentrancy
1058
+ if (this.hasOwnProperty(propName)) {
1059
+ newValue = this[propName];
1060
+ delete this[propName];
1061
+ }
1062
+ else if (prototype.hasOwnProperty(propName) &&
1063
+ typeof this[propName] === 'number' &&
1064
+ this[propName] == newValue) {
1065
+ // if the propName exists on the prototype of `Cstr`, this update may be a result of Stencil using native
1066
+ // APIs to reflect props as attributes. Calls to `setAttribute(someElement, propName)` will result in
1067
+ // `propName` to be converted to a `DOMString`, which may not be what we want for other primitive props.
1068
+ return;
1069
+ }
1070
+ this[propName] = newValue === null && typeof this[propName] === 'boolean' ? false : newValue;
1071
+ });
1072
+ };
1073
+ // create an array of attributes to observe
1074
+ // and also create a map of html attribute name to js property name
1075
+ Cstr.observedAttributes = members
1076
+ .filter(([_, m]) => m[0] & 15 /* HasAttribute */) // filter to only keep props that should match attributes
1077
+ .map(([propName, m]) => {
1078
+ const attrName = m[1] || propName;
1079
+ attrNameToPropName.set(attrName, propName);
1080
+ return attrName;
1081
+ });
1082
+ }
1083
+ }
1084
+ return Cstr;
1085
+ };
1086
+ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) => {
1087
+ // initializeComponent
1088
+ if ((hostRef.$flags$ & 32 /* hasInitializedComponent */) === 0) {
1089
+ {
1090
+ // we haven't initialized this element yet
1091
+ hostRef.$flags$ |= 32 /* hasInitializedComponent */;
1092
+ // lazy loaded components
1093
+ // request the component's implementation to be
1094
+ // wired up with the host element
1095
+ Cstr = loadModule(cmpMeta);
1096
+ if (Cstr.then) {
1097
+ // Await creates a micro-task avoid if possible
1098
+ const endLoad = uniqueTime();
1099
+ Cstr = await Cstr;
1100
+ endLoad();
1101
+ }
1102
+ if (!Cstr.isProxied) {
1103
+ proxyComponent(Cstr, cmpMeta, 2 /* proxyState */);
1104
+ Cstr.isProxied = true;
1105
+ }
1106
+ const endNewInstance = createTime('createInstance', cmpMeta.$tagName$);
1107
+ // ok, time to construct the instance
1108
+ // but let's keep track of when we start and stop
1109
+ // so that the getters/setters don't incorrectly step on data
1110
+ {
1111
+ hostRef.$flags$ |= 8 /* isConstructingInstance */;
1112
+ }
1113
+ // construct the lazy-loaded component implementation
1114
+ // passing the hostRef is very important during
1115
+ // construction in order to directly wire together the
1116
+ // host element and the lazy-loaded instance
1117
+ try {
1118
+ new Cstr(hostRef);
1119
+ }
1120
+ catch (e) {
1121
+ consoleError(e);
1122
+ }
1123
+ {
1124
+ hostRef.$flags$ &= ~8 /* isConstructingInstance */;
1125
+ }
1126
+ endNewInstance();
1127
+ }
1128
+ if (Cstr.style) {
1129
+ // this component has styles but we haven't registered them yet
1130
+ let style = Cstr.style;
1131
+ const scopeId = getScopeId(cmpMeta);
1132
+ if (!styles.has(scopeId)) {
1133
+ const endRegisterStyles = createTime('registerStyles', cmpMeta.$tagName$);
1134
+ registerStyle(scopeId, style, !!(cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */));
1135
+ endRegisterStyles();
1136
+ }
1137
+ }
1138
+ }
1139
+ // we've successfully created a lazy instance
1140
+ const ancestorComponent = hostRef.$ancestorComponent$;
1141
+ const schedule = () => scheduleUpdate(hostRef, true);
1142
+ if (ancestorComponent && ancestorComponent['s-rc']) {
1143
+ // this is the initial load and this component it has an ancestor component
1144
+ // but the ancestor component has NOT fired its will update lifecycle yet
1145
+ // so let's just cool our jets and wait for the ancestor to continue first
1146
+ // this will get fired off when the ancestor component
1147
+ // finally gets around to rendering its lazy self
1148
+ // fire off the initial update
1149
+ ancestorComponent['s-rc'].push(schedule);
1150
+ }
1151
+ else {
1152
+ schedule();
1153
+ }
1154
+ };
1155
+ const connectedCallback = (elm) => {
1156
+ if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0) {
1157
+ const hostRef = getHostRef(elm);
1158
+ const cmpMeta = hostRef.$cmpMeta$;
1159
+ const endConnected = createTime('connectedCallback', cmpMeta.$tagName$);
1160
+ if (!(hostRef.$flags$ & 1 /* hasConnected */)) {
1161
+ // first time this component has connected
1162
+ hostRef.$flags$ |= 1 /* hasConnected */;
1163
+ {
1164
+ // initUpdate
1165
+ // if the slot polyfill is required we'll need to put some nodes
1166
+ // in here to act as original content anchors as we move nodes around
1167
+ // host element has been connected to the DOM
1168
+ if ((cmpMeta.$flags$ & (4 /* hasSlotRelocation */ | 8 /* needsShadowDomShim */))) {
1169
+ setContentReference(elm);
1170
+ }
1171
+ }
1172
+ {
1173
+ // find the first ancestor component (if there is one) and register
1174
+ // this component as one of the actively loading child components for its ancestor
1175
+ let ancestorComponent = elm;
1176
+ while ((ancestorComponent = ancestorComponent.parentNode || ancestorComponent.host)) {
1177
+ // climb up the ancestors looking for the first
1178
+ // component that hasn't finished its lifecycle update yet
1179
+ if (ancestorComponent['s-p']) {
1180
+ // we found this components first ancestor component
1181
+ // keep a reference to this component's ancestor component
1182
+ attachToAncestor(hostRef, (hostRef.$ancestorComponent$ = ancestorComponent));
1183
+ break;
1184
+ }
1185
+ }
1186
+ }
1187
+ // Lazy properties
1188
+ // https://developers.google.com/web/fundamentals/web-components/best-practices#lazy-properties
1189
+ if (cmpMeta.$members$) {
1190
+ Object.entries(cmpMeta.$members$).map(([memberName, [memberFlags]]) => {
1191
+ if (memberFlags & 31 /* Prop */ && elm.hasOwnProperty(memberName)) {
1192
+ const value = elm[memberName];
1193
+ delete elm[memberName];
1194
+ elm[memberName] = value;
1195
+ }
1196
+ });
1197
+ }
1198
+ {
1199
+ initializeComponent(elm, hostRef, cmpMeta);
1200
+ }
1201
+ }
1202
+ endConnected();
1203
+ }
1204
+ };
1205
+ const setContentReference = (elm) => {
1206
+ // only required when we're NOT using native shadow dom (slot)
1207
+ // or this browser doesn't support native shadow dom
1208
+ // and this host element was NOT created with SSR
1209
+ // let's pick out the inner content for slot projection
1210
+ // create a node to represent where the original
1211
+ // content was first placed, which is useful later on
1212
+ const contentRefElm = (elm['s-cr'] = doc.createComment(''));
1213
+ contentRefElm['s-cn'] = true;
1214
+ elm.insertBefore(contentRefElm, elm.firstChild);
1215
+ };
1216
+ const disconnectedCallback = (elm) => {
1217
+ if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0) {
1218
+ getHostRef(elm);
1219
+ }
1220
+ };
1221
+ const bootstrapLazy = (lazyBundles, options = {}) => {
1222
+ const endBootstrap = createTime();
1223
+ const cmpTags = [];
1224
+ const exclude = options.exclude || [];
1225
+ const customElements = win.customElements;
1226
+ const head = doc.head;
1227
+ const metaCharset = /*@__PURE__*/ head.querySelector('meta[charset]');
1228
+ const visibilityStyle = /*@__PURE__*/ doc.createElement('style');
1229
+ const deferredConnectedCallbacks = [];
1230
+ let appLoadFallback;
1231
+ let isBootstrapping = true;
1232
+ Object.assign(plt, options);
1233
+ plt.$resourcesUrl$ = new URL(options.resourcesUrl || './', doc.baseURI).href;
1234
+ lazyBundles.map((lazyBundle) => {
1235
+ lazyBundle[1].map((compactMeta) => {
1236
+ const cmpMeta = {
1237
+ $flags$: compactMeta[0],
1238
+ $tagName$: compactMeta[1],
1239
+ $members$: compactMeta[2],
1240
+ $listeners$: compactMeta[3],
1241
+ };
1242
+ {
1243
+ cmpMeta.$members$ = compactMeta[2];
1244
+ }
1245
+ const tagName = cmpMeta.$tagName$;
1246
+ const HostElement = class extends HTMLElement {
1247
+ // StencilLazyHost
1248
+ constructor(self) {
1249
+ // @ts-ignore
1250
+ super(self);
1251
+ self = this;
1252
+ registerHost(self, cmpMeta);
1253
+ }
1254
+ connectedCallback() {
1255
+ if (appLoadFallback) {
1256
+ clearTimeout(appLoadFallback);
1257
+ appLoadFallback = null;
1258
+ }
1259
+ if (isBootstrapping) {
1260
+ // connectedCallback will be processed once all components have been registered
1261
+ deferredConnectedCallbacks.push(this);
1262
+ }
1263
+ else {
1264
+ plt.jmp(() => connectedCallback(this));
1265
+ }
1266
+ }
1267
+ disconnectedCallback() {
1268
+ plt.jmp(() => disconnectedCallback(this));
1269
+ }
1270
+ componentOnReady() {
1271
+ return getHostRef(this).$onReadyPromise$;
1272
+ }
1273
+ };
1274
+ cmpMeta.$lazyBundleId$ = lazyBundle[0];
1275
+ if (!exclude.includes(tagName) && !customElements.get(tagName)) {
1276
+ cmpTags.push(tagName);
1277
+ customElements.define(tagName, proxyComponent(HostElement, cmpMeta, 1 /* isElementConstructor */));
1278
+ }
1279
+ });
1280
+ });
1281
+ {
1282
+ visibilityStyle.innerHTML = cmpTags + HYDRATED_CSS;
1283
+ visibilityStyle.setAttribute('data-styles', '');
1284
+ head.insertBefore(visibilityStyle, metaCharset ? metaCharset.nextSibling : head.firstChild);
1285
+ }
1286
+ // Process deferred connectedCallbacks now all components have been registered
1287
+ isBootstrapping = false;
1288
+ if (deferredConnectedCallbacks.length) {
1289
+ deferredConnectedCallbacks.map((host) => host.connectedCallback());
1290
+ }
1291
+ else {
1292
+ {
1293
+ plt.jmp(() => (appLoadFallback = setTimeout(appDidLoad, 30)));
1294
+ }
1295
+ }
1296
+ // Fallback appLoad event
1297
+ endBootstrap();
1298
+ };
1299
+ const hostRefs = new WeakMap();
1300
+ const getHostRef = (ref) => hostRefs.get(ref);
1301
+ const registerInstance = (lazyInstance, hostRef) => hostRefs.set((hostRef.$lazyInstance$ = lazyInstance), hostRef);
1302
+ const registerHost = (elm, cmpMeta) => {
1303
+ const hostRef = {
1304
+ $flags$: 0,
1305
+ $hostElement$: elm,
1306
+ $cmpMeta$: cmpMeta,
1307
+ $instanceValues$: new Map(),
1308
+ };
1309
+ {
1310
+ hostRef.$onReadyPromise$ = new Promise((r) => (hostRef.$onReadyResolve$ = r));
1311
+ elm['s-p'] = [];
1312
+ elm['s-rc'] = [];
1313
+ }
1314
+ return hostRefs.set(elm, hostRef);
1315
+ };
1316
+ const isMemberInElement = (elm, memberName) => memberName in elm;
1317
+ const consoleError = (e, el) => (0, console.error)(e, el);
1318
+ const cmpModules = /*@__PURE__*/ new Map();
1319
+ const loadModule = (cmpMeta, hostRef, hmrVersionId) => {
1320
+ // loadModuleImport
1321
+ const exportName = cmpMeta.$tagName$.replace(/-/g, '_');
1322
+ const bundleId = cmpMeta.$lazyBundleId$;
1323
+ const module = cmpModules.get(bundleId) ;
1324
+ if (module) {
1325
+ return module[exportName];
1326
+ }
1327
+ return import(
1328
+ /* webpackInclude: /\.entry\.js$/ */
1329
+ /* webpackExclude: /\.system\.entry\.js$/ */
1330
+ /* webpackMode: "lazy" */
1331
+ `./${bundleId}.entry.js${''}`).then((importedModule) => {
1332
+ {
1333
+ cmpModules.set(bundleId, importedModule);
1334
+ }
1335
+ return importedModule[exportName];
1336
+ }, consoleError);
1337
+ };
1338
+ const styles = new Map();
1339
+ const queueDomReads = [];
1340
+ const queueDomWrites = [];
1341
+ const queueTask = (queue, write) => (cb) => {
1342
+ queue.push(cb);
1343
+ if (!queuePending) {
1344
+ queuePending = true;
1345
+ if (write && plt.$flags$ & 4 /* queueSync */) {
1346
+ nextTick(flush);
1347
+ }
1348
+ else {
1349
+ plt.raf(flush);
1350
+ }
1351
+ }
1352
+ };
1353
+ const consume = (queue) => {
1354
+ for (let i = 0; i < queue.length; i++) {
1355
+ try {
1356
+ queue[i](performance.now());
1357
+ }
1358
+ catch (e) {
1359
+ consoleError(e);
1360
+ }
1361
+ }
1362
+ queue.length = 0;
1363
+ };
1364
+ const flush = () => {
1365
+ // always force a bunch of medium callbacks to run, but still have
1366
+ // a throttle on how many can run in a certain time
1367
+ // DOM READS!!!
1368
+ consume(queueDomReads);
1369
+ // DOM WRITES!!!
1370
+ {
1371
+ consume(queueDomWrites);
1372
+ if ((queuePending = queueDomReads.length > 0)) {
1373
+ // still more to do yet, but we've run out of time
1374
+ // let's let this thing cool off and try again in the next tick
1375
+ plt.raf(flush);
1376
+ }
1377
+ }
1378
+ };
1379
+ const nextTick = /*@__PURE__*/ (cb) => promiseResolve().then(cb);
1380
+ const writeTask = /*@__PURE__*/ queueTask(queueDomWrites, true);
1381
+
1382
+ export { bootstrapLazy as b, h, promiseResolve as p, registerInstance as r };