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