hemfixarna-web-components 0.0.1

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