@siemens/ix-aggrid 1.1.0-beta.2 → 1.1.0-beta.4

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