@oila/0account 3.4.3 → 3.4.5

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 (94) hide show
  1. package/LICENSE +1 -1
  2. package/dist/cjs/index-1e526aba.js +1645 -0
  3. package/dist/cjs/index-1e526aba.js.map +1 -0
  4. package/dist/cjs/index.cjs.js +4 -0
  5. package/dist/cjs/index.cjs.js.map +1 -0
  6. package/dist/cjs/loader.cjs.js +15 -0
  7. package/dist/cjs/loader.cjs.js.map +1 -0
  8. package/dist/cjs/qr-code_2.cjs.entry.js +2472 -0
  9. package/dist/cjs/qr-code_2.cjs.entry.js.map +1 -0
  10. package/dist/cjs/zero-account.cjs.js +25 -0
  11. package/dist/cjs/zero-account.cjs.js.map +1 -0
  12. package/dist/collection/collection-manifest.json +13 -0
  13. package/dist/collection/components/zero-account/enums.js +18 -0
  14. package/dist/collection/components/zero-account/enums.js.map +1 -0
  15. package/dist/collection/components/zero-account/logo.js +6 -0
  16. package/dist/collection/components/zero-account/logo.js.map +1 -0
  17. package/dist/collection/components/zero-account/qrcode.js +111 -0
  18. package/dist/collection/components/zero-account/qrcode.js.map +1 -0
  19. package/dist/collection/components/zero-account/websocket.js +174 -0
  20. package/dist/collection/components/zero-account/websocket.js.map +1 -0
  21. package/dist/collection/components/zero-account/zero-account.css +287 -0
  22. package/dist/collection/components/zero-account/zero-account.e2e.js +26 -0
  23. package/dist/collection/components/zero-account/zero-account.e2e.js.map +1 -0
  24. package/dist/collection/components/zero-account/zero-account.js +457 -0
  25. package/dist/collection/components/zero-account/zero-account.js.map +1 -0
  26. package/dist/collection/components/zero-account/zero-account.spec.js +35 -0
  27. package/dist/collection/components/zero-account/zero-account.spec.js.map +1 -0
  28. package/dist/collection/index.js +2 -0
  29. package/dist/collection/index.js.map +1 -0
  30. package/dist/collection/utils/qrcode/qrcode.js +1007 -0
  31. package/dist/collection/utils/request.js +38 -0
  32. package/dist/collection/utils/request.js.map +1 -0
  33. package/dist/collection/utils/url.js +43 -0
  34. package/dist/collection/utils/utils.js +16 -0
  35. package/dist/collection/utils/utils.js.map +1 -0
  36. package/dist/collection/utils/utils.spec.js +10 -0
  37. package/dist/collection/utils/utils.spec.js.map +1 -0
  38. package/dist/components/index.d.ts +27 -0
  39. package/dist/components/index.js +3 -0
  40. package/dist/components/index.js.map +1 -0
  41. package/dist/components/qr-code.d.ts +11 -0
  42. package/dist/components/qr-code.js +8 -0
  43. package/dist/components/qr-code.js.map +1 -0
  44. package/dist/components/qrcode.js +1073 -0
  45. package/dist/components/qrcode.js.map +1 -0
  46. package/dist/components/zero-account.d.ts +11 -0
  47. package/dist/components/zero-account.js +1460 -0
  48. package/dist/components/zero-account.js.map +1 -0
  49. package/dist/esm/index-09024c20.js +1616 -0
  50. package/dist/esm/index-09024c20.js.map +1 -0
  51. package/dist/esm/index.js +3 -0
  52. package/dist/esm/index.js.map +1 -0
  53. package/dist/esm/loader.js +11 -0
  54. package/dist/esm/loader.js.map +1 -0
  55. package/dist/esm/polyfills/core-js.js +11 -0
  56. package/dist/esm/polyfills/dom.js +79 -0
  57. package/dist/esm/polyfills/es5-html-element.js +1 -0
  58. package/dist/esm/polyfills/index.js +34 -0
  59. package/dist/esm/polyfills/system.js +6 -0
  60. package/dist/esm/qr-code_2.entry.js +2467 -0
  61. package/dist/esm/qr-code_2.entry.js.map +1 -0
  62. package/dist/esm/zero-account.js +20 -0
  63. package/dist/esm/zero-account.js.map +1 -0
  64. package/dist/index.cjs.js +1 -0
  65. package/dist/index.js +1 -0
  66. package/dist/types/components/zero-account/enums.d.ts +14 -0
  67. package/dist/types/components/zero-account/logo.d.ts +5 -0
  68. package/dist/types/components/zero-account/qrcode.d.ts +8 -0
  69. package/dist/types/components/zero-account/websocket.d.ts +31 -0
  70. package/dist/types/components/zero-account/zero-account.d.ts +45 -0
  71. package/dist/types/components.d.ts +88 -0
  72. package/dist/types/index.d.ts +1 -0
  73. package/dist/types/stencil-public-runtime.d.ts +1640 -0
  74. package/dist/types/utils/request.d.ts +10 -0
  75. package/dist/types/utils/utils.d.ts +7 -0
  76. package/dist/zero-account/index.esm.js +2 -0
  77. package/dist/zero-account/index.esm.js.map +1 -0
  78. package/dist/zero-account/p-21f4994d.js +3 -0
  79. package/dist/zero-account/p-21f4994d.js.map +1 -0
  80. package/dist/zero-account/p-9a90a04d.entry.js +2 -0
  81. package/dist/zero-account/p-9a90a04d.entry.js.map +1 -0
  82. package/dist/zero-account/zero-account.esm.js +2 -0
  83. package/dist/zero-account/zero-account.esm.js.map +1 -0
  84. package/loader/cdn.js +3 -0
  85. package/loader/index.cjs.js +3 -0
  86. package/loader/index.d.ts +21 -0
  87. package/loader/index.es2017.js +3 -0
  88. package/loader/index.js +4 -0
  89. package/loader/package.json +11 -0
  90. package/package.json +33 -40
  91. package/readme.md +75 -0
  92. package/0account.d.ts +0 -24
  93. package/README.md +0 -3
  94. package/dist/0account.js +0 -1
@@ -0,0 +1,1645 @@
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 = 'zero-account';
24
+
25
+ /**
26
+ * Virtual DOM patching algorithm based on Snabbdom by
27
+ * Simon Friis Vindum (@paldepind)
28
+ * Licensed under the MIT License
29
+ * https://github.com/snabbdom/snabbdom/blob/master/LICENSE
30
+ *
31
+ * Modified for Stencil's renderer and slot projection
32
+ */
33
+ let scopeId;
34
+ let hostTagName;
35
+ let isSvgMode = false;
36
+ let queuePending = false;
37
+ const Build = {
38
+ isDev: false,
39
+ isBrowser: true,
40
+ isServer: false,
41
+ isTesting: false,
42
+ };
43
+ const createTime = (fnName, tagName = '') => {
44
+ {
45
+ return () => {
46
+ return;
47
+ };
48
+ }
49
+ };
50
+ const uniqueTime = (key, measureText) => {
51
+ {
52
+ return () => {
53
+ return;
54
+ };
55
+ }
56
+ };
57
+ const HYDRATED_CSS = '{visibility:hidden}.hydrated{visibility:inherit}';
58
+ /**
59
+ * Default style mode id
60
+ */
61
+ /**
62
+ * Reusable empty obj/array
63
+ * Don't add values to these!!
64
+ */
65
+ const EMPTY_OBJ = {};
66
+ /**
67
+ * Namespaces
68
+ */
69
+ const SVG_NS = 'http://www.w3.org/2000/svg';
70
+ const HTML_NS = 'http://www.w3.org/1999/xhtml';
71
+ const isDef = (v) => v != null;
72
+ /**
73
+ * Check whether a value is a 'complex type', defined here as an object or a
74
+ * function.
75
+ *
76
+ * @param o the value to check
77
+ * @returns whether it's a complex type or not
78
+ */
79
+ const isComplexType = (o) => {
80
+ // https://jsperf.com/typeof-fn-object/5
81
+ o = typeof o;
82
+ return o === 'object' || o === 'function';
83
+ };
84
+ /**
85
+ * Helper method for querying a `meta` tag that contains a nonce value
86
+ * out of a DOM's head.
87
+ *
88
+ * @param doc The DOM containing the `head` to query against
89
+ * @returns The content of the meta tag representing the nonce value, or `undefined` if no tag
90
+ * exists or the tag has no content.
91
+ */
92
+ function queryNonceMetaTagContent(doc) {
93
+ var _a, _b, _c;
94
+ return (_c = (_b = (_a = doc.head) === null || _a === void 0 ? void 0 : _a.querySelector('meta[name="csp-nonce"]')) === null || _b === void 0 ? void 0 : _b.getAttribute('content')) !== null && _c !== void 0 ? _c : undefined;
95
+ }
96
+ /**
97
+ * Production h() function based on Preact by
98
+ * Jason Miller (@developit)
99
+ * Licensed under the MIT License
100
+ * https://github.com/developit/preact/blob/master/LICENSE
101
+ *
102
+ * Modified for Stencil's compiler and vdom
103
+ */
104
+ // export function h(nodeName: string | d.FunctionalComponent, vnodeData: d.PropsType, child?: d.ChildType): d.VNode;
105
+ // export function h(nodeName: string | d.FunctionalComponent, vnodeData: d.PropsType, ...children: d.ChildType[]): d.VNode;
106
+ const h = (nodeName, vnodeData, ...children) => {
107
+ let child = null;
108
+ let simple = false;
109
+ let lastSimple = false;
110
+ const vNodeChildren = [];
111
+ const walk = (c) => {
112
+ for (let i = 0; i < c.length; i++) {
113
+ child = c[i];
114
+ if (Array.isArray(child)) {
115
+ walk(child);
116
+ }
117
+ else if (child != null && typeof child !== 'boolean') {
118
+ if ((simple = typeof nodeName !== 'function' && !isComplexType(child))) {
119
+ child = String(child);
120
+ }
121
+ if (simple && lastSimple) {
122
+ // If the previous child was simple (string), we merge both
123
+ vNodeChildren[vNodeChildren.length - 1].$text$ += child;
124
+ }
125
+ else {
126
+ // Append a new vNode, if it's text, we create a text vNode
127
+ vNodeChildren.push(simple ? newVNode(null, child) : child);
128
+ }
129
+ lastSimple = simple;
130
+ }
131
+ }
132
+ };
133
+ walk(children);
134
+ if (vnodeData) {
135
+ {
136
+ const classData = vnodeData.className || vnodeData.class;
137
+ if (classData) {
138
+ vnodeData.class =
139
+ typeof classData !== 'object'
140
+ ? classData
141
+ : Object.keys(classData)
142
+ .filter((k) => classData[k])
143
+ .join(' ');
144
+ }
145
+ }
146
+ }
147
+ if (typeof nodeName === 'function') {
148
+ // nodeName is a functional component
149
+ return nodeName(vnodeData === null ? {} : vnodeData, vNodeChildren, vdomFnUtils);
150
+ }
151
+ const vnode = newVNode(nodeName, null);
152
+ vnode.$attrs$ = vnodeData;
153
+ if (vNodeChildren.length > 0) {
154
+ vnode.$children$ = vNodeChildren;
155
+ }
156
+ return vnode;
157
+ };
158
+ /**
159
+ * A utility function for creating a virtual DOM node from a tag and some
160
+ * possible text content.
161
+ *
162
+ * @param tag the tag for this element
163
+ * @param text possible text content for the node
164
+ * @returns a newly-minted virtual DOM node
165
+ */
166
+ const newVNode = (tag, text) => {
167
+ const vnode = {
168
+ $flags$: 0,
169
+ $tag$: tag,
170
+ $text$: text,
171
+ $elm$: null,
172
+ $children$: null,
173
+ };
174
+ {
175
+ vnode.$attrs$ = null;
176
+ }
177
+ return vnode;
178
+ };
179
+ const Host = {};
180
+ /**
181
+ * Check whether a given node is a Host node or not
182
+ *
183
+ * @param node the virtual DOM node to check
184
+ * @returns whether it's a Host node or not
185
+ */
186
+ const isHost = (node) => node && node.$tag$ === Host;
187
+ /**
188
+ * Implementation of {@link d.FunctionalUtilities} for Stencil's VDom.
189
+ *
190
+ * Note that these functions convert from {@link d.VNode} to
191
+ * {@link d.ChildNode} to give functional component developers a friendly
192
+ * interface.
193
+ */
194
+ const vdomFnUtils = {
195
+ forEach: (children, cb) => children.map(convertToPublic).forEach(cb),
196
+ map: (children, cb) => children.map(convertToPublic).map(cb).map(convertToPrivate),
197
+ };
198
+ /**
199
+ * Convert a {@link d.VNode} to a {@link d.ChildNode} in order to present a
200
+ * friendlier public interface (hence, 'convertToPublic').
201
+ *
202
+ * @param node the virtual DOM node to convert
203
+ * @returns a converted child node
204
+ */
205
+ const convertToPublic = (node) => ({
206
+ vattrs: node.$attrs$,
207
+ vchildren: node.$children$,
208
+ vkey: node.$key$,
209
+ vname: node.$name$,
210
+ vtag: node.$tag$,
211
+ vtext: node.$text$,
212
+ });
213
+ /**
214
+ * Convert a {@link d.ChildNode} back to an equivalent {@link d.VNode} in
215
+ * order to use the resulting object in the virtual DOM. The initial object was
216
+ * likely created as part of presenting a public API, so converting it back
217
+ * involved making it 'private' again (hence, `convertToPrivate`).
218
+ *
219
+ * @param node the child node to convert
220
+ * @returns a converted virtual DOM node
221
+ */
222
+ const convertToPrivate = (node) => {
223
+ if (typeof node.vtag === 'function') {
224
+ const vnodeData = Object.assign({}, node.vattrs);
225
+ if (node.vkey) {
226
+ vnodeData.key = node.vkey;
227
+ }
228
+ if (node.vname) {
229
+ vnodeData.name = node.vname;
230
+ }
231
+ return h(node.vtag, vnodeData, ...(node.vchildren || []));
232
+ }
233
+ const vnode = newVNode(node.vtag, node.vtext);
234
+ vnode.$attrs$ = node.vattrs;
235
+ vnode.$children$ = node.vchildren;
236
+ vnode.$key$ = node.vkey;
237
+ vnode.$name$ = node.vname;
238
+ return vnode;
239
+ };
240
+ /**
241
+ * Parse a new property value for a given property type.
242
+ *
243
+ * While the prop value can reasonably be expected to be of `any` type as far as TypeScript's type checker is concerned,
244
+ * it is not safe to assume that the string returned by evaluating `typeof propValue` matches:
245
+ * 1. `any`, the type given to `propValue` in the function signature
246
+ * 2. the type stored from `propType`.
247
+ *
248
+ * This function provides the capability to parse/coerce a property's value to potentially any other JavaScript type.
249
+ *
250
+ * Property values represented in TSX preserve their type information. In the example below, the number 0 is passed to
251
+ * a component. This `propValue` will preserve its type information (`typeof propValue === 'number'`). Note that is
252
+ * based on the type of the value being passed in, not the type declared of the class member decorated with `@Prop`.
253
+ * ```tsx
254
+ * <my-cmp prop-val={0}></my-cmp>
255
+ * ```
256
+ *
257
+ * HTML prop values on the other hand, will always a string
258
+ *
259
+ * @param propValue the new value to coerce to some type
260
+ * @param propType the type of the prop, expressed as a binary number
261
+ * @returns the parsed/coerced value
262
+ */
263
+ const parsePropertyValue = (propValue, propType) => {
264
+ // ensure this value is of the correct prop type
265
+ if (propValue != null && !isComplexType(propValue)) {
266
+ if (propType & 4 /* MEMBER_FLAGS.Boolean */) {
267
+ // per the HTML spec, any string value means it is a boolean true value
268
+ // but we'll cheat here and say that the string "false" is the boolean false
269
+ return propValue === 'false' ? false : propValue === '' || !!propValue;
270
+ }
271
+ if (propType & 2 /* MEMBER_FLAGS.Number */) {
272
+ // force it to be a number
273
+ return parseFloat(propValue);
274
+ }
275
+ if (propType & 1 /* MEMBER_FLAGS.String */) {
276
+ // could have been passed as a number or boolean
277
+ // but we still want it as a string
278
+ return String(propValue);
279
+ }
280
+ // redundant return here for better minification
281
+ return propValue;
282
+ }
283
+ // not sure exactly what type we want
284
+ // so no need to change to a different type
285
+ return propValue;
286
+ };
287
+ const getElement = (ref) => (getHostRef(ref).$hostElement$ );
288
+ /**
289
+ * Helper function to create & dispatch a custom Event on a provided target
290
+ * @param elm the target of the Event
291
+ * @param name the name to give the custom Event
292
+ * @param opts options for configuring a custom Event
293
+ * @returns the custom Event
294
+ */
295
+ const emitEvent = (elm, name, opts) => {
296
+ const ev = plt.ce(name, opts);
297
+ elm.dispatchEvent(ev);
298
+ return ev;
299
+ };
300
+ const rootAppliedStyles = /*@__PURE__*/ new WeakMap();
301
+ const registerStyle = (scopeId, cssText, allowCS) => {
302
+ let style = styles.get(scopeId);
303
+ if (supportsConstructableStylesheets && allowCS) {
304
+ style = (style || new CSSStyleSheet());
305
+ if (typeof style === 'string') {
306
+ style = cssText;
307
+ }
308
+ else {
309
+ style.replaceSync(cssText);
310
+ }
311
+ }
312
+ else {
313
+ style = cssText;
314
+ }
315
+ styles.set(scopeId, style);
316
+ };
317
+ const addStyle = (styleContainerNode, cmpMeta, mode) => {
318
+ var _a;
319
+ const scopeId = getScopeId(cmpMeta);
320
+ const style = styles.get(scopeId);
321
+ // if an element is NOT connected then getRootNode() will return the wrong root node
322
+ // so the fallback is to always use the document for the root node in those cases
323
+ styleContainerNode = styleContainerNode.nodeType === 11 /* NODE_TYPE.DocumentFragment */ ? styleContainerNode : doc;
324
+ if (style) {
325
+ if (typeof style === 'string') {
326
+ styleContainerNode = styleContainerNode.head || styleContainerNode;
327
+ let appliedStyles = rootAppliedStyles.get(styleContainerNode);
328
+ let styleElm;
329
+ if (!appliedStyles) {
330
+ rootAppliedStyles.set(styleContainerNode, (appliedStyles = new Set()));
331
+ }
332
+ if (!appliedStyles.has(scopeId)) {
333
+ {
334
+ styleElm = doc.createElement('style');
335
+ styleElm.innerHTML = style;
336
+ // Apply CSP nonce to the style tag if it exists
337
+ const nonce = (_a = plt.$nonce$) !== null && _a !== void 0 ? _a : queryNonceMetaTagContent(doc);
338
+ if (nonce != null) {
339
+ styleElm.setAttribute('nonce', nonce);
340
+ }
341
+ styleContainerNode.insertBefore(styleElm, styleContainerNode.querySelector('link'));
342
+ }
343
+ if (appliedStyles) {
344
+ appliedStyles.add(scopeId);
345
+ }
346
+ }
347
+ }
348
+ else if (!styleContainerNode.adoptedStyleSheets.includes(style)) {
349
+ styleContainerNode.adoptedStyleSheets = [...styleContainerNode.adoptedStyleSheets, style];
350
+ }
351
+ }
352
+ return scopeId;
353
+ };
354
+ const attachStyles = (hostRef) => {
355
+ const cmpMeta = hostRef.$cmpMeta$;
356
+ const elm = hostRef.$hostElement$;
357
+ const flags = cmpMeta.$flags$;
358
+ const endAttachStyles = createTime('attachStyles', cmpMeta.$tagName$);
359
+ const scopeId = addStyle(elm.shadowRoot ? elm.shadowRoot : elm.getRootNode(), cmpMeta);
360
+ if (flags & 10 /* CMP_FLAGS.needsScopedEncapsulation */) {
361
+ // only required when we're NOT using native shadow dom (slot)
362
+ // or this browser doesn't support native shadow dom
363
+ // and this host element was NOT created with SSR
364
+ // let's pick out the inner content for slot projection
365
+ // create a node to represent where the original
366
+ // content was first placed, which is useful later on
367
+ // DOM WRITE!!
368
+ elm['s-sc'] = scopeId;
369
+ elm.classList.add(scopeId + '-h');
370
+ }
371
+ endAttachStyles();
372
+ };
373
+ const getScopeId = (cmp, mode) => 'sc-' + (cmp.$tagName$);
374
+ /**
375
+ * Production setAccessor() function based on Preact by
376
+ * Jason Miller (@developit)
377
+ * Licensed under the MIT License
378
+ * https://github.com/developit/preact/blob/master/LICENSE
379
+ *
380
+ * Modified for Stencil's compiler and vdom
381
+ */
382
+ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
383
+ if (oldValue !== newValue) {
384
+ let isProp = isMemberInElement(elm, memberName);
385
+ let ln = memberName.toLowerCase();
386
+ if (memberName === 'class') {
387
+ const classList = elm.classList;
388
+ const oldClasses = parseClassList(oldValue);
389
+ const newClasses = parseClassList(newValue);
390
+ classList.remove(...oldClasses.filter((c) => c && !newClasses.includes(c)));
391
+ classList.add(...newClasses.filter((c) => c && !oldClasses.includes(c)));
392
+ }
393
+ else if (memberName === 'ref') {
394
+ // minifier will clean this up
395
+ if (newValue) {
396
+ newValue(elm);
397
+ }
398
+ }
399
+ else if ((!isProp ) &&
400
+ memberName[0] === 'o' &&
401
+ memberName[1] === 'n') {
402
+ // Event Handlers
403
+ // so if the member name starts with "on" and the 3rd characters is
404
+ // a capital letter, and it's not already a member on the element,
405
+ // then we're assuming it's an event listener
406
+ if (memberName[2] === '-') {
407
+ // on- prefixed events
408
+ // allows to be explicit about the dom event to listen without any magic
409
+ // under the hood:
410
+ // <my-cmp on-click> // listens for "click"
411
+ // <my-cmp on-Click> // listens for "Click"
412
+ // <my-cmp on-ionChange> // listens for "ionChange"
413
+ // <my-cmp on-EVENTS> // listens for "EVENTS"
414
+ memberName = memberName.slice(3);
415
+ }
416
+ else if (isMemberInElement(win, ln)) {
417
+ // standard event
418
+ // the JSX attribute could have been "onMouseOver" and the
419
+ // member name "onmouseover" is on the window's prototype
420
+ // so let's add the listener "mouseover", which is all lowercased
421
+ memberName = ln.slice(2);
422
+ }
423
+ else {
424
+ // custom event
425
+ // the JSX attribute could have been "onMyCustomEvent"
426
+ // so let's trim off the "on" prefix and lowercase the first character
427
+ // and add the listener "myCustomEvent"
428
+ // except for the first character, we keep the event name case
429
+ memberName = ln[2] + memberName.slice(3);
430
+ }
431
+ if (oldValue) {
432
+ plt.rel(elm, memberName, oldValue, false);
433
+ }
434
+ if (newValue) {
435
+ plt.ael(elm, memberName, newValue, false);
436
+ }
437
+ }
438
+ else {
439
+ // Set property if it exists and it's not a SVG
440
+ const isComplex = isComplexType(newValue);
441
+ if ((isProp || (isComplex && newValue !== null)) && !isSvg) {
442
+ try {
443
+ if (!elm.tagName.includes('-')) {
444
+ const n = newValue == null ? '' : newValue;
445
+ // Workaround for Safari, moving the <input> caret when re-assigning the same valued
446
+ if (memberName === 'list') {
447
+ isProp = false;
448
+ }
449
+ else if (oldValue == null || elm[memberName] != n) {
450
+ elm[memberName] = n;
451
+ }
452
+ }
453
+ else {
454
+ elm[memberName] = newValue;
455
+ }
456
+ }
457
+ catch (e) { }
458
+ }
459
+ if (newValue == null || newValue === false) {
460
+ if (newValue !== false || elm.getAttribute(memberName) === '') {
461
+ {
462
+ elm.removeAttribute(memberName);
463
+ }
464
+ }
465
+ }
466
+ else if ((!isProp || flags & 4 /* VNODE_FLAGS.isHost */ || isSvg) && !isComplex) {
467
+ newValue = newValue === true ? '' : newValue;
468
+ {
469
+ elm.setAttribute(memberName, newValue);
470
+ }
471
+ }
472
+ }
473
+ }
474
+ };
475
+ const parseClassListRegex = /\s/;
476
+ const parseClassList = (value) => (!value ? [] : value.split(parseClassListRegex));
477
+ const updateElement = (oldVnode, newVnode, isSvgMode, memberName) => {
478
+ // if the element passed in is a shadow root, which is a document fragment
479
+ // then we want to be adding attrs/props to the shadow root's "host" element
480
+ // if it's not a shadow root, then we add attrs/props to the same element
481
+ const elm = newVnode.$elm$.nodeType === 11 /* NODE_TYPE.DocumentFragment */ && newVnode.$elm$.host
482
+ ? newVnode.$elm$.host
483
+ : newVnode.$elm$;
484
+ const oldVnodeAttrs = (oldVnode && oldVnode.$attrs$) || EMPTY_OBJ;
485
+ const newVnodeAttrs = newVnode.$attrs$ || EMPTY_OBJ;
486
+ {
487
+ // remove attributes no longer present on the vnode by setting them to undefined
488
+ for (memberName in oldVnodeAttrs) {
489
+ if (!(memberName in newVnodeAttrs)) {
490
+ setAccessor(elm, memberName, oldVnodeAttrs[memberName], undefined, isSvgMode, newVnode.$flags$);
491
+ }
492
+ }
493
+ }
494
+ // add new & update changed attributes
495
+ for (memberName in newVnodeAttrs) {
496
+ setAccessor(elm, memberName, oldVnodeAttrs[memberName], newVnodeAttrs[memberName], isSvgMode, newVnode.$flags$);
497
+ }
498
+ };
499
+ /**
500
+ * Create a DOM Node corresponding to one of the children of a given VNode.
501
+ *
502
+ * @param oldParentVNode the parent VNode from the previous render
503
+ * @param newParentVNode the parent VNode from the current render
504
+ * @param childIndex the index of the VNode, in the _new_ parent node's
505
+ * children, for which we will create a new DOM node
506
+ * @param parentElm the parent DOM node which our new node will be a child of
507
+ * @returns the newly created node
508
+ */
509
+ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
510
+ // tslint:disable-next-line: prefer-const
511
+ const newVNode = newParentVNode.$children$[childIndex];
512
+ let i = 0;
513
+ let elm;
514
+ let childNode;
515
+ if (newVNode.$text$ !== null) {
516
+ // create text node
517
+ elm = newVNode.$elm$ = doc.createTextNode(newVNode.$text$);
518
+ }
519
+ else {
520
+ if (!isSvgMode) {
521
+ isSvgMode = newVNode.$tag$ === 'svg';
522
+ }
523
+ // create element
524
+ elm = newVNode.$elm$ = (doc.createElementNS(isSvgMode ? SVG_NS : HTML_NS, newVNode.$tag$)
525
+ );
526
+ if (isSvgMode && newVNode.$tag$ === 'foreignObject') {
527
+ isSvgMode = false;
528
+ }
529
+ // add css classes, attrs, props, listeners, etc.
530
+ {
531
+ updateElement(null, newVNode, isSvgMode);
532
+ }
533
+ if (isDef(scopeId) && elm['s-si'] !== scopeId) {
534
+ // if there is a scopeId and this is the initial render
535
+ // then let's add the scopeId as a css class
536
+ elm.classList.add((elm['s-si'] = scopeId));
537
+ }
538
+ if (newVNode.$children$) {
539
+ for (i = 0; i < newVNode.$children$.length; ++i) {
540
+ // create the node
541
+ childNode = createElm(oldParentVNode, newVNode, i);
542
+ // return node could have been null
543
+ if (childNode) {
544
+ // append our new node
545
+ elm.appendChild(childNode);
546
+ }
547
+ }
548
+ }
549
+ {
550
+ if (newVNode.$tag$ === 'svg') {
551
+ // Only reset the SVG context when we're exiting <svg> element
552
+ isSvgMode = false;
553
+ }
554
+ else if (elm.tagName === 'foreignObject') {
555
+ // Reenter SVG context when we're exiting <foreignObject> element
556
+ isSvgMode = true;
557
+ }
558
+ }
559
+ }
560
+ return elm;
561
+ };
562
+ /**
563
+ * Create DOM nodes corresponding to a list of {@link d.Vnode} objects and
564
+ * add them to the DOM in the appropriate place.
565
+ *
566
+ * @param parentElm the DOM node which should be used as a parent for the new
567
+ * DOM nodes
568
+ * @param before a child of the `parentElm` which the new children should be
569
+ * inserted before (optional)
570
+ * @param parentVNode the parent virtual DOM node
571
+ * @param vnodes the new child virtual DOM nodes to produce DOM nodes for
572
+ * @param startIdx the index in the child virtual DOM nodes at which to start
573
+ * creating DOM nodes (inclusive)
574
+ * @param endIdx the index in the child virtual DOM nodes at which to stop
575
+ * creating DOM nodes (inclusive)
576
+ */
577
+ const addVnodes = (parentElm, before, parentVNode, vnodes, startIdx, endIdx) => {
578
+ let containerElm = (parentElm);
579
+ let childNode;
580
+ if (containerElm.shadowRoot && containerElm.tagName === hostTagName) {
581
+ containerElm = containerElm.shadowRoot;
582
+ }
583
+ for (; startIdx <= endIdx; ++startIdx) {
584
+ if (vnodes[startIdx]) {
585
+ childNode = createElm(null, parentVNode, startIdx);
586
+ if (childNode) {
587
+ vnodes[startIdx].$elm$ = childNode;
588
+ containerElm.insertBefore(childNode, before);
589
+ }
590
+ }
591
+ }
592
+ };
593
+ /**
594
+ * Remove the DOM elements corresponding to a list of {@link d.VNode} objects.
595
+ * This can be used to, for instance, clean up after a list of children which
596
+ * should no longer be shown.
597
+ *
598
+ * This function also handles some of Stencil's slot relocation logic.
599
+ *
600
+ * @param vnodes a list of virtual DOM nodes to remove
601
+ * @param startIdx the index at which to start removing nodes (inclusive)
602
+ * @param endIdx the index at which to stop removing nodes (inclusive)
603
+ */
604
+ const removeVnodes = (vnodes, startIdx, endIdx) => {
605
+ for (let index = startIdx; index <= endIdx; ++index) {
606
+ const vnode = vnodes[index];
607
+ if (vnode) {
608
+ const elm = vnode.$elm$;
609
+ nullifyVNodeRefs(vnode);
610
+ if (elm) {
611
+ // remove the vnode's element from the dom
612
+ elm.remove();
613
+ }
614
+ }
615
+ }
616
+ };
617
+ /**
618
+ * Reconcile the children of a new VNode with the children of an old VNode by
619
+ * traversing the two collections of children, identifying nodes that are
620
+ * conserved or changed, calling out to `patch` to make any necessary
621
+ * updates to the DOM, and rearranging DOM nodes as needed.
622
+ *
623
+ * The algorithm for reconciling children works by analyzing two 'windows' onto
624
+ * the two arrays of children (`oldCh` and `newCh`). We keep track of the
625
+ * 'windows' by storing start and end indices and references to the
626
+ * corresponding array entries. Initially the two 'windows' are basically equal
627
+ * to the entire array, but we progressively narrow the windows until there are
628
+ * no children left to update by doing the following:
629
+ *
630
+ * 1. Skip any `null` entries at the beginning or end of the two arrays, so
631
+ * that if we have an initial array like the following we'll end up dealing
632
+ * only with a window bounded by the highlighted elements:
633
+ *
634
+ * [null, null, VNode1 , ... , VNode2, null, null]
635
+ * ^^^^^^ ^^^^^^
636
+ *
637
+ * 2. Check to see if the elements at the head and tail positions are equal
638
+ * across the windows. This will basically detect elements which haven't
639
+ * been added, removed, or changed position, i.e. if you had the following
640
+ * VNode elements (represented as HTML):
641
+ *
642
+ * oldVNode: `<div><p><span>HEY</span></p></div>`
643
+ * newVNode: `<div><p><span>THERE</span></p></div>`
644
+ *
645
+ * Then when comparing the children of the `<div>` tag we check the equality
646
+ * of the VNodes corresponding to the `<p>` tags and, since they are the
647
+ * same tag in the same position, we'd be able to avoid completely
648
+ * re-rendering the subtree under them with a new DOM element and would just
649
+ * call out to `patch` to handle reconciling their children and so on.
650
+ *
651
+ * 3. Check, for both windows, to see if the element at the beginning of the
652
+ * window corresponds to the element at the end of the other window. This is
653
+ * a heuristic which will let us identify _some_ situations in which
654
+ * elements have changed position, for instance it _should_ detect that the
655
+ * children nodes themselves have not changed but merely moved in the
656
+ * following example:
657
+ *
658
+ * oldVNode: `<div><element-one /><element-two /></div>`
659
+ * newVNode: `<div><element-two /><element-one /></div>`
660
+ *
661
+ * If we find cases like this then we also need to move the concrete DOM
662
+ * elements corresponding to the moved children to write the re-order to the
663
+ * DOM.
664
+ *
665
+ * 4. Finally, if VNodes have the `key` attribute set on them we check for any
666
+ * nodes in the old children which have the same key as the first element in
667
+ * our window on the new children. If we find such a node we handle calling
668
+ * out to `patch`, moving relevant DOM nodes, and so on, in accordance with
669
+ * what we find.
670
+ *
671
+ * Finally, once we've narrowed our 'windows' to the point that either of them
672
+ * collapse (i.e. they have length 0) we then handle any remaining VNode
673
+ * insertion or deletion that needs to happen to get a DOM state that correctly
674
+ * reflects the new child VNodes. If, for instance, after our window on the old
675
+ * children has collapsed we still have more nodes on the new children that
676
+ * we haven't dealt with yet then we need to add them, or if the new children
677
+ * collapse but we still have unhandled _old_ children then we need to make
678
+ * sure the corresponding DOM nodes are removed.
679
+ *
680
+ * @param parentElm the node into which the parent VNode is rendered
681
+ * @param oldCh the old children of the parent node
682
+ * @param newVNode the new VNode which will replace the parent
683
+ * @param newCh the new children of the parent node
684
+ */
685
+ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
686
+ let oldStartIdx = 0;
687
+ let newStartIdx = 0;
688
+ let oldEndIdx = oldCh.length - 1;
689
+ let oldStartVnode = oldCh[0];
690
+ let oldEndVnode = oldCh[oldEndIdx];
691
+ let newEndIdx = newCh.length - 1;
692
+ let newStartVnode = newCh[0];
693
+ let newEndVnode = newCh[newEndIdx];
694
+ let node;
695
+ while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
696
+ if (oldStartVnode == null) {
697
+ // VNode might have been moved left
698
+ oldStartVnode = oldCh[++oldStartIdx];
699
+ }
700
+ else if (oldEndVnode == null) {
701
+ oldEndVnode = oldCh[--oldEndIdx];
702
+ }
703
+ else if (newStartVnode == null) {
704
+ newStartVnode = newCh[++newStartIdx];
705
+ }
706
+ else if (newEndVnode == null) {
707
+ newEndVnode = newCh[--newEndIdx];
708
+ }
709
+ else if (isSameVnode(oldStartVnode, newStartVnode)) {
710
+ // if the start nodes are the same then we should patch the new VNode
711
+ // onto the old one, and increment our `newStartIdx` and `oldStartIdx`
712
+ // indices to reflect that. We don't need to move any DOM Nodes around
713
+ // since things are matched up in order.
714
+ patch(oldStartVnode, newStartVnode);
715
+ oldStartVnode = oldCh[++oldStartIdx];
716
+ newStartVnode = newCh[++newStartIdx];
717
+ }
718
+ else if (isSameVnode(oldEndVnode, newEndVnode)) {
719
+ // likewise, if the end nodes are the same we patch new onto old and
720
+ // decrement our end indices, and also likewise in this case we don't
721
+ // need to move any DOM Nodes.
722
+ patch(oldEndVnode, newEndVnode);
723
+ oldEndVnode = oldCh[--oldEndIdx];
724
+ newEndVnode = newCh[--newEndIdx];
725
+ }
726
+ else if (isSameVnode(oldStartVnode, newEndVnode)) {
727
+ patch(oldStartVnode, newEndVnode);
728
+ // We need to move the element for `oldStartVnode` into a position which
729
+ // will be appropriate for `newEndVnode`. For this we can use
730
+ // `.insertBefore` and `oldEndVnode.$elm$.nextSibling`. If there is a
731
+ // sibling for `oldEndVnode.$elm$` then we want to move the DOM node for
732
+ // `oldStartVnode` between `oldEndVnode` and it's sibling, like so:
733
+ //
734
+ // <old-start-node />
735
+ // <some-intervening-node />
736
+ // <old-end-node />
737
+ // <!-- -> <-- `oldStartVnode.$elm$` should be inserted here
738
+ // <next-sibling />
739
+ //
740
+ // If instead `oldEndVnode.$elm$` has no sibling then we just want to put
741
+ // the node for `oldStartVnode` at the end of the children of
742
+ // `parentElm`. Luckily, `Node.nextSibling` will return `null` if there
743
+ // aren't any siblings, and passing `null` to `Node.insertBefore` will
744
+ // append it to the children of the parent element.
745
+ parentElm.insertBefore(oldStartVnode.$elm$, oldEndVnode.$elm$.nextSibling);
746
+ oldStartVnode = oldCh[++oldStartIdx];
747
+ newEndVnode = newCh[--newEndIdx];
748
+ }
749
+ else if (isSameVnode(oldEndVnode, newStartVnode)) {
750
+ patch(oldEndVnode, newStartVnode);
751
+ // We've already checked above if `oldStartVnode` and `newStartVnode` are
752
+ // the same node, so since we're here we know that they are not. Thus we
753
+ // can move the element for `oldEndVnode` _before_ the element for
754
+ // `oldStartVnode`, leaving `oldStartVnode` to be reconciled in the
755
+ // future.
756
+ parentElm.insertBefore(oldEndVnode.$elm$, oldStartVnode.$elm$);
757
+ oldEndVnode = oldCh[--oldEndIdx];
758
+ newStartVnode = newCh[++newStartIdx];
759
+ }
760
+ else {
761
+ {
762
+ // We either didn't find an element in the old children that matches
763
+ // the key of the first new child OR the build is not using `key`
764
+ // attributes at all. In either case we need to create a new element
765
+ // for the new node.
766
+ node = createElm(oldCh && oldCh[newStartIdx], newVNode, newStartIdx);
767
+ newStartVnode = newCh[++newStartIdx];
768
+ }
769
+ if (node) {
770
+ // if we created a new node then handle inserting it to the DOM
771
+ {
772
+ oldStartVnode.$elm$.parentNode.insertBefore(node, oldStartVnode.$elm$);
773
+ }
774
+ }
775
+ }
776
+ }
777
+ if (oldStartIdx > oldEndIdx) {
778
+ // we have some more new nodes to add which don't match up with old nodes
779
+ addVnodes(parentElm, newCh[newEndIdx + 1] == null ? null : newCh[newEndIdx + 1].$elm$, newVNode, newCh, newStartIdx, newEndIdx);
780
+ }
781
+ else if (newStartIdx > newEndIdx) {
782
+ // there are nodes in the `oldCh` array which no longer correspond to nodes
783
+ // in the new array, so lets remove them (which entails cleaning up the
784
+ // relevant DOM nodes)
785
+ removeVnodes(oldCh, oldStartIdx, oldEndIdx);
786
+ }
787
+ };
788
+ /**
789
+ * Compare two VNodes to determine if they are the same
790
+ *
791
+ * **NB**: This function is an equality _heuristic_ based on the available
792
+ * information set on the two VNodes and can be misleading under certain
793
+ * circumstances. In particular, if the two nodes do not have `key` attrs
794
+ * (available under `$key$` on VNodes) then the function falls back on merely
795
+ * checking that they have the same tag.
796
+ *
797
+ * So, in other words, if `key` attrs are not set on VNodes which may be
798
+ * changing order within a `children` array or something along those lines then
799
+ * we could obtain a false negative and then have to do needless re-rendering
800
+ * (i.e. we'd say two VNodes aren't equal when in fact they should be).
801
+ *
802
+ * @param leftVNode the first VNode to check
803
+ * @param rightVNode the second VNode to check
804
+ * @returns whether they're equal or not
805
+ */
806
+ const isSameVnode = (leftVNode, rightVNode) => {
807
+ // compare if two vnode to see if they're "technically" the same
808
+ // need to have the same element tag, and same key to be the same
809
+ if (leftVNode.$tag$ === rightVNode.$tag$) {
810
+ return true;
811
+ }
812
+ return false;
813
+ };
814
+ /**
815
+ * Handle reconciling an outdated VNode with a new one which corresponds to
816
+ * it. This function handles flushing updates to the DOM and reconciling the
817
+ * children of the two nodes (if any).
818
+ *
819
+ * @param oldVNode an old VNode whose DOM element and children we want to update
820
+ * @param newVNode a new VNode representing an updated version of the old one
821
+ */
822
+ const patch = (oldVNode, newVNode) => {
823
+ const elm = (newVNode.$elm$ = oldVNode.$elm$);
824
+ const oldChildren = oldVNode.$children$;
825
+ const newChildren = newVNode.$children$;
826
+ const tag = newVNode.$tag$;
827
+ const text = newVNode.$text$;
828
+ if (text === null) {
829
+ {
830
+ // test if we're rendering an svg element, or still rendering nodes inside of one
831
+ // only add this to the when the compiler sees we're using an svg somewhere
832
+ isSvgMode = tag === 'svg' ? true : tag === 'foreignObject' ? false : isSvgMode;
833
+ }
834
+ {
835
+ if (tag === 'slot')
836
+ ;
837
+ else {
838
+ // either this is the first render of an element OR it's an update
839
+ // AND we already know it's possible it could have changed
840
+ // this updates the element's css classes, attrs, props, listeners, etc.
841
+ updateElement(oldVNode, newVNode, isSvgMode);
842
+ }
843
+ }
844
+ if (oldChildren !== null && newChildren !== null) {
845
+ // looks like there's child vnodes for both the old and new vnodes
846
+ // so we need to call `updateChildren` to reconcile them
847
+ updateChildren(elm, oldChildren, newVNode, newChildren);
848
+ }
849
+ else if (newChildren !== null) {
850
+ // no old child vnodes, but there are new child vnodes to add
851
+ if (oldVNode.$text$ !== null) {
852
+ // the old vnode was text, so be sure to clear it out
853
+ elm.textContent = '';
854
+ }
855
+ // add the new vnode children
856
+ addVnodes(elm, null, newVNode, newChildren, 0, newChildren.length - 1);
857
+ }
858
+ else if (oldChildren !== null) {
859
+ // no new child vnodes, but there are old child vnodes to remove
860
+ removeVnodes(oldChildren, 0, oldChildren.length - 1);
861
+ }
862
+ if (isSvgMode && tag === 'svg') {
863
+ isSvgMode = false;
864
+ }
865
+ }
866
+ else if (oldVNode.$text$ !== text) {
867
+ // update the text content for the text only vnode
868
+ // and also only if the text is different than before
869
+ elm.data = text;
870
+ }
871
+ };
872
+ /**
873
+ * 'Nullify' any VDom `ref` callbacks on a VDom node or its children by
874
+ * calling them with `null`. This signals that the DOM element corresponding to
875
+ * the VDom node has been removed from the DOM.
876
+ *
877
+ * @param vNode a virtual DOM node
878
+ */
879
+ const nullifyVNodeRefs = (vNode) => {
880
+ {
881
+ vNode.$attrs$ && vNode.$attrs$.ref && vNode.$attrs$.ref(null);
882
+ vNode.$children$ && vNode.$children$.map(nullifyVNodeRefs);
883
+ }
884
+ };
885
+ /**
886
+ * The main entry point for Stencil's virtual DOM-based rendering engine
887
+ *
888
+ * Given a {@link d.HostRef} container and some virtual DOM nodes, this
889
+ * function will handle creating a virtual DOM tree with a single root, patching
890
+ * the current virtual DOM tree onto an old one (if any), dealing with slot
891
+ * relocation, and reflecting attributes.
892
+ *
893
+ * @param hostRef data needed to root and render the virtual DOM tree, such as
894
+ * the DOM node into which it should be rendered.
895
+ * @param renderFnResults the virtual DOM nodes to be rendered
896
+ */
897
+ const renderVdom = (hostRef, renderFnResults) => {
898
+ const hostElm = hostRef.$hostElement$;
899
+ const oldVNode = hostRef.$vnode$ || newVNode(null, null);
900
+ const rootVnode = isHost(renderFnResults) ? renderFnResults : h(null, null, renderFnResults);
901
+ hostTagName = hostElm.tagName;
902
+ rootVnode.$tag$ = null;
903
+ rootVnode.$flags$ |= 4 /* VNODE_FLAGS.isHost */;
904
+ hostRef.$vnode$ = rootVnode;
905
+ rootVnode.$elm$ = oldVNode.$elm$ = (hostElm.shadowRoot || hostElm );
906
+ {
907
+ scopeId = hostElm['s-sc'];
908
+ }
909
+ // synchronous patch
910
+ patch(oldVNode, rootVnode);
911
+ };
912
+ const attachToAncestor = (hostRef, ancestorComponent) => {
913
+ if (ancestorComponent && !hostRef.$onRenderResolve$ && ancestorComponent['s-p']) {
914
+ ancestorComponent['s-p'].push(new Promise((r) => (hostRef.$onRenderResolve$ = r)));
915
+ }
916
+ };
917
+ const scheduleUpdate = (hostRef, isInitialLoad) => {
918
+ {
919
+ hostRef.$flags$ |= 16 /* HOST_FLAGS.isQueuedForUpdate */;
920
+ }
921
+ if (hostRef.$flags$ & 4 /* HOST_FLAGS.isWaitingForChildren */) {
922
+ hostRef.$flags$ |= 512 /* HOST_FLAGS.needsRerender */;
923
+ return;
924
+ }
925
+ attachToAncestor(hostRef, hostRef.$ancestorComponent$);
926
+ // there is no ancestor component or the ancestor component
927
+ // has already fired off its lifecycle update then
928
+ // fire off the initial update
929
+ const dispatch = () => dispatchHooks(hostRef, isInitialLoad);
930
+ return writeTask(dispatch) ;
931
+ };
932
+ /**
933
+ * Dispatch initial-render and update lifecycle hooks, enqueuing calls to
934
+ * component lifecycle methods like `componentWillLoad` as well as
935
+ * {@link updateComponent}, which will kick off the virtual DOM re-render.
936
+ *
937
+ * @param hostRef a reference to a host DOM node
938
+ * @param isInitialLoad whether we're on the initial load or not
939
+ * @returns an empty Promise which is used to enqueue a series of operations for
940
+ * the component
941
+ */
942
+ const dispatchHooks = (hostRef, isInitialLoad) => {
943
+ const endSchedule = createTime('scheduleUpdate', hostRef.$cmpMeta$.$tagName$);
944
+ const instance = hostRef.$lazyInstance$ ;
945
+ // We're going to use this variable together with `enqueue` to implement a
946
+ // little promise-based queue. We start out with it `undefined`. When we add
947
+ // the first function to the queue we'll set this variable to be that
948
+ // function's return value. When we attempt to add subsequent values to the
949
+ // queue we'll check that value and, if it was a `Promise`, we'll then chain
950
+ // the new function off of that `Promise` using `.then()`. This will give our
951
+ // queue two nice properties:
952
+ //
953
+ // 1. If all functions added to the queue are synchronous they'll be called
954
+ // synchronously right away.
955
+ // 2. If all functions added to the queue are asynchronous they'll all be
956
+ // called in order after `dispatchHooks` exits.
957
+ let maybePromise;
958
+ if (isInitialLoad) {
959
+ {
960
+ hostRef.$flags$ |= 256 /* HOST_FLAGS.isListenReady */;
961
+ if (hostRef.$queuedListeners$) {
962
+ hostRef.$queuedListeners$.map(([methodName, event]) => safeCall(instance, methodName, event));
963
+ hostRef.$queuedListeners$ = undefined;
964
+ }
965
+ }
966
+ {
967
+ // If `componentWillLoad` returns a `Promise` then we want to wait on
968
+ // whatever's going on in that `Promise` before we launch into
969
+ // rendering the component, doing other lifecycle stuff, etc. So
970
+ // in that case we assign the returned promise to the variable we
971
+ // declared above to hold a possible 'queueing' Promise
972
+ maybePromise = safeCall(instance, 'componentWillLoad');
973
+ }
974
+ }
975
+ endSchedule();
976
+ return enqueue(maybePromise, () => updateComponent(hostRef, instance, isInitialLoad));
977
+ };
978
+ /**
979
+ * This function uses a Promise to implement a simple first-in, first-out queue
980
+ * of functions to be called.
981
+ *
982
+ * The queue is ordered on the basis of the first argument. If it's
983
+ * `undefined`, then nothing is on the queue yet, so the provided function can
984
+ * be called synchronously (although note that this function may return a
985
+ * `Promise`). The idea is that then the return value of that enqueueing
986
+ * operation is kept around, so that if it was a `Promise` then subsequent
987
+ * functions can be enqueued by calling this function again with that `Promise`
988
+ * as the first argument.
989
+ *
990
+ * @param maybePromise either a `Promise` which should resolve before the next function is called or an 'empty' sentinel
991
+ * @param fn a function to enqueue
992
+ * @returns either a `Promise` or the return value of the provided function
993
+ */
994
+ const enqueue = (maybePromise, fn) => isPromisey(maybePromise) ? maybePromise.then(fn) : fn();
995
+ /**
996
+ * Check that a value is a `Promise`. To check, we first see if the value is an
997
+ * instance of the `Promise` global. In a few circumstances, in particular if
998
+ * the global has been overwritten, this is could be misleading, so we also do
999
+ * a little 'duck typing' check to see if the `.then` property of the value is
1000
+ * defined and a function.
1001
+ *
1002
+ * @param maybePromise it might be a promise!
1003
+ * @returns whether it is or not
1004
+ */
1005
+ const isPromisey = (maybePromise) => maybePromise instanceof Promise ||
1006
+ (maybePromise && maybePromise.then && typeof maybePromise.then === 'function');
1007
+ const updateComponent = async (hostRef, instance, isInitialLoad) => {
1008
+ var _a;
1009
+ const elm = hostRef.$hostElement$;
1010
+ const endUpdate = createTime('update', hostRef.$cmpMeta$.$tagName$);
1011
+ const rc = elm['s-rc'];
1012
+ if (isInitialLoad) {
1013
+ // DOM WRITE!
1014
+ attachStyles(hostRef);
1015
+ }
1016
+ const endRender = createTime('render', hostRef.$cmpMeta$.$tagName$);
1017
+ {
1018
+ callRender(hostRef, instance);
1019
+ }
1020
+ if (rc) {
1021
+ // ok, so turns out there are some child host elements
1022
+ // waiting on this parent element to load
1023
+ // let's fire off all update callbacks waiting
1024
+ rc.map((cb) => cb());
1025
+ elm['s-rc'] = undefined;
1026
+ }
1027
+ endRender();
1028
+ endUpdate();
1029
+ {
1030
+ const childrenPromises = (_a = elm['s-p']) !== null && _a !== void 0 ? _a : [];
1031
+ const postUpdate = () => postUpdateComponent(hostRef);
1032
+ if (childrenPromises.length === 0) {
1033
+ postUpdate();
1034
+ }
1035
+ else {
1036
+ Promise.all(childrenPromises).then(postUpdate);
1037
+ hostRef.$flags$ |= 4 /* HOST_FLAGS.isWaitingForChildren */;
1038
+ childrenPromises.length = 0;
1039
+ }
1040
+ }
1041
+ };
1042
+ const callRender = (hostRef, instance, elm) => {
1043
+ try {
1044
+ instance = instance.render() ;
1045
+ {
1046
+ hostRef.$flags$ &= ~16 /* HOST_FLAGS.isQueuedForUpdate */;
1047
+ }
1048
+ {
1049
+ hostRef.$flags$ |= 2 /* HOST_FLAGS.hasRendered */;
1050
+ }
1051
+ {
1052
+ {
1053
+ // looks like we've got child nodes to render into this host element
1054
+ // or we need to update the css class/attrs on the host element
1055
+ // DOM WRITE!
1056
+ {
1057
+ renderVdom(hostRef, instance);
1058
+ }
1059
+ }
1060
+ }
1061
+ }
1062
+ catch (e) {
1063
+ consoleError(e, hostRef.$hostElement$);
1064
+ }
1065
+ return null;
1066
+ };
1067
+ const postUpdateComponent = (hostRef) => {
1068
+ const tagName = hostRef.$cmpMeta$.$tagName$;
1069
+ const elm = hostRef.$hostElement$;
1070
+ const endPostUpdate = createTime('postUpdate', tagName);
1071
+ const ancestorComponent = hostRef.$ancestorComponent$;
1072
+ if (!(hostRef.$flags$ & 64 /* HOST_FLAGS.hasLoadedComponent */)) {
1073
+ hostRef.$flags$ |= 64 /* HOST_FLAGS.hasLoadedComponent */;
1074
+ {
1075
+ // DOM WRITE!
1076
+ addHydratedFlag(elm);
1077
+ }
1078
+ endPostUpdate();
1079
+ {
1080
+ hostRef.$onReadyResolve$(elm);
1081
+ if (!ancestorComponent) {
1082
+ appDidLoad();
1083
+ }
1084
+ }
1085
+ }
1086
+ else {
1087
+ endPostUpdate();
1088
+ }
1089
+ // load events fire from bottom to top
1090
+ // the deepest elements load first then bubbles up
1091
+ {
1092
+ if (hostRef.$onRenderResolve$) {
1093
+ hostRef.$onRenderResolve$();
1094
+ hostRef.$onRenderResolve$ = undefined;
1095
+ }
1096
+ if (hostRef.$flags$ & 512 /* HOST_FLAGS.needsRerender */) {
1097
+ nextTick(() => scheduleUpdate(hostRef, false));
1098
+ }
1099
+ hostRef.$flags$ &= ~(4 /* HOST_FLAGS.isWaitingForChildren */ | 512 /* HOST_FLAGS.needsRerender */);
1100
+ }
1101
+ // ( •_•)
1102
+ // ( •_•)>⌐■-■
1103
+ // (⌐■_■)
1104
+ };
1105
+ const appDidLoad = (who) => {
1106
+ // on appload
1107
+ // we have finish the first big initial render
1108
+ {
1109
+ addHydratedFlag(doc.documentElement);
1110
+ }
1111
+ nextTick(() => emitEvent(win, 'appload', { detail: { namespace: NAMESPACE } }));
1112
+ };
1113
+ const safeCall = (instance, method, arg) => {
1114
+ if (instance && instance[method]) {
1115
+ try {
1116
+ return instance[method](arg);
1117
+ }
1118
+ catch (e) {
1119
+ consoleError(e);
1120
+ }
1121
+ }
1122
+ return undefined;
1123
+ };
1124
+ const addHydratedFlag = (elm) => elm.classList.add('hydrated')
1125
+ ;
1126
+ const getValue = (ref, propName) => getHostRef(ref).$instanceValues$.get(propName);
1127
+ const setValue = (ref, propName, newVal, cmpMeta) => {
1128
+ // check our new property value against our internal value
1129
+ const hostRef = getHostRef(ref);
1130
+ const oldVal = hostRef.$instanceValues$.get(propName);
1131
+ const flags = hostRef.$flags$;
1132
+ const instance = hostRef.$lazyInstance$ ;
1133
+ newVal = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]);
1134
+ // explicitly check for NaN on both sides, as `NaN === NaN` is always false
1135
+ const areBothNaN = Number.isNaN(oldVal) && Number.isNaN(newVal);
1136
+ const didValueChange = newVal !== oldVal && !areBothNaN;
1137
+ if ((!(flags & 8 /* HOST_FLAGS.isConstructingInstance */) || oldVal === undefined) && didValueChange) {
1138
+ // gadzooks! the property's value has changed!!
1139
+ // set our new value!
1140
+ hostRef.$instanceValues$.set(propName, newVal);
1141
+ if (instance) {
1142
+ if ((flags & (2 /* HOST_FLAGS.hasRendered */ | 16 /* HOST_FLAGS.isQueuedForUpdate */)) === 2 /* HOST_FLAGS.hasRendered */) {
1143
+ // looks like this value actually changed, so we've got work to do!
1144
+ // but only if we've already rendered, otherwise just chill out
1145
+ // queue that we need to do an update, but don't worry about queuing
1146
+ // up millions cuz this function ensures it only runs once
1147
+ scheduleUpdate(hostRef, false);
1148
+ }
1149
+ }
1150
+ }
1151
+ };
1152
+ /**
1153
+ * Attach a series of runtime constructs to a compiled Stencil component
1154
+ * constructor, including getters and setters for the `@Prop` and `@State`
1155
+ * decorators, callbacks for when attributes change, and so on.
1156
+ *
1157
+ * @param Cstr the constructor for a component that we need to process
1158
+ * @param cmpMeta metadata collected previously about the component
1159
+ * @param flags a number used to store a series of bit flags
1160
+ * @returns a reference to the same constructor passed in (but now mutated)
1161
+ */
1162
+ const proxyComponent = (Cstr, cmpMeta, flags) => {
1163
+ if (cmpMeta.$members$) {
1164
+ // It's better to have a const than two Object.entries()
1165
+ const members = Object.entries(cmpMeta.$members$);
1166
+ const prototype = Cstr.prototype;
1167
+ members.map(([memberName, [memberFlags]]) => {
1168
+ if ((memberFlags & 31 /* MEMBER_FLAGS.Prop */ ||
1169
+ ((flags & 2 /* PROXY_FLAGS.proxyState */) && memberFlags & 32 /* MEMBER_FLAGS.State */))) {
1170
+ // proxyComponent - prop
1171
+ Object.defineProperty(prototype, memberName, {
1172
+ get() {
1173
+ // proxyComponent, get value
1174
+ return getValue(this, memberName);
1175
+ },
1176
+ set(newValue) {
1177
+ // proxyComponent, set value
1178
+ setValue(this, memberName, newValue, cmpMeta);
1179
+ },
1180
+ configurable: true,
1181
+ enumerable: true,
1182
+ });
1183
+ }
1184
+ });
1185
+ if ((flags & 1 /* PROXY_FLAGS.isElementConstructor */)) {
1186
+ const attrNameToPropName = new Map();
1187
+ prototype.attributeChangedCallback = function (attrName, _oldValue, newValue) {
1188
+ plt.jmp(() => {
1189
+ const propName = attrNameToPropName.get(attrName);
1190
+ // In a web component lifecycle the attributeChangedCallback runs prior to connectedCallback
1191
+ // in the case where an attribute was set inline.
1192
+ // ```html
1193
+ // <my-component some-attribute="some-value"></my-component>
1194
+ // ```
1195
+ //
1196
+ // There is an edge case where a developer sets the attribute inline on a custom element and then
1197
+ // programmatically changes it before it has been upgraded as shown below:
1198
+ //
1199
+ // ```html
1200
+ // <!-- this component has _not_ been upgraded yet -->
1201
+ // <my-component id="test" some-attribute="some-value"></my-component>
1202
+ // <script>
1203
+ // // grab non-upgraded component
1204
+ // el = document.querySelector("#test");
1205
+ // el.someAttribute = "another-value";
1206
+ // // upgrade component
1207
+ // customElements.define('my-component', MyComponent);
1208
+ // </script>
1209
+ // ```
1210
+ // In this case if we do not unshadow here and use the value of the shadowing property, attributeChangedCallback
1211
+ // will be called with `newValue = "some-value"` and will set the shadowed property (this.someAttribute = "another-value")
1212
+ // to the value that was set inline i.e. "some-value" from above example. When
1213
+ // the connectedCallback attempts to unshadow it will use "some-value" as the initial value rather than "another-value"
1214
+ //
1215
+ // The case where the attribute was NOT set inline but was not set programmatically shall be handled/unshadowed
1216
+ // by connectedCallback as this attributeChangedCallback will not fire.
1217
+ //
1218
+ // https://developers.google.com/web/fundamentals/web-components/best-practices#lazy-properties
1219
+ //
1220
+ // TODO(STENCIL-16) we should think about whether or not we actually want to be reflecting the attributes to
1221
+ // properties here given that this goes against best practices outlined here
1222
+ // https://developers.google.com/web/fundamentals/web-components/best-practices#avoid-reentrancy
1223
+ if (this.hasOwnProperty(propName)) {
1224
+ newValue = this[propName];
1225
+ delete this[propName];
1226
+ }
1227
+ else if (prototype.hasOwnProperty(propName) &&
1228
+ typeof this[propName] === 'number' &&
1229
+ this[propName] == newValue) {
1230
+ // if the propName exists on the prototype of `Cstr`, this update may be a result of Stencil using native
1231
+ // APIs to reflect props as attributes. Calls to `setAttribute(someElement, propName)` will result in
1232
+ // `propName` to be converted to a `DOMString`, which may not be what we want for other primitive props.
1233
+ return;
1234
+ }
1235
+ this[propName] = newValue === null && typeof this[propName] === 'boolean' ? false : newValue;
1236
+ });
1237
+ };
1238
+ // create an array of attributes to observe
1239
+ // and also create a map of html attribute name to js property name
1240
+ Cstr.observedAttributes = members
1241
+ .filter(([_, m]) => m[0] & 15 /* MEMBER_FLAGS.HasAttribute */) // filter to only keep props that should match attributes
1242
+ .map(([propName, m]) => {
1243
+ const attrName = m[1] || propName;
1244
+ attrNameToPropName.set(attrName, propName);
1245
+ return attrName;
1246
+ });
1247
+ }
1248
+ }
1249
+ return Cstr;
1250
+ };
1251
+ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) => {
1252
+ // initializeComponent
1253
+ if ((hostRef.$flags$ & 32 /* HOST_FLAGS.hasInitializedComponent */) === 0) {
1254
+ // Let the runtime know that the component has been initialized
1255
+ hostRef.$flags$ |= 32 /* HOST_FLAGS.hasInitializedComponent */;
1256
+ {
1257
+ // lazy loaded components
1258
+ // request the component's implementation to be
1259
+ // wired up with the host element
1260
+ Cstr = loadModule(cmpMeta);
1261
+ if (Cstr.then) {
1262
+ // Await creates a micro-task avoid if possible
1263
+ const endLoad = uniqueTime();
1264
+ Cstr = await Cstr;
1265
+ endLoad();
1266
+ }
1267
+ if (!Cstr.isProxied) {
1268
+ proxyComponent(Cstr, cmpMeta, 2 /* PROXY_FLAGS.proxyState */);
1269
+ Cstr.isProxied = true;
1270
+ }
1271
+ const endNewInstance = createTime('createInstance', cmpMeta.$tagName$);
1272
+ // ok, time to construct the instance
1273
+ // but let's keep track of when we start and stop
1274
+ // so that the getters/setters don't incorrectly step on data
1275
+ {
1276
+ hostRef.$flags$ |= 8 /* HOST_FLAGS.isConstructingInstance */;
1277
+ }
1278
+ // construct the lazy-loaded component implementation
1279
+ // passing the hostRef is very important during
1280
+ // construction in order to directly wire together the
1281
+ // host element and the lazy-loaded instance
1282
+ try {
1283
+ new Cstr(hostRef);
1284
+ }
1285
+ catch (e) {
1286
+ consoleError(e);
1287
+ }
1288
+ {
1289
+ hostRef.$flags$ &= ~8 /* HOST_FLAGS.isConstructingInstance */;
1290
+ }
1291
+ endNewInstance();
1292
+ fireConnectedCallback(hostRef.$lazyInstance$);
1293
+ }
1294
+ if (Cstr.style) {
1295
+ // this component has styles but we haven't registered them yet
1296
+ let style = Cstr.style;
1297
+ const scopeId = getScopeId(cmpMeta);
1298
+ if (!styles.has(scopeId)) {
1299
+ const endRegisterStyles = createTime('registerStyles', cmpMeta.$tagName$);
1300
+ registerStyle(scopeId, style, !!(cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */));
1301
+ endRegisterStyles();
1302
+ }
1303
+ }
1304
+ }
1305
+ // we've successfully created a lazy instance
1306
+ const ancestorComponent = hostRef.$ancestorComponent$;
1307
+ const schedule = () => scheduleUpdate(hostRef, true);
1308
+ if (ancestorComponent && ancestorComponent['s-rc']) {
1309
+ // this is the initial load and this component it has an ancestor component
1310
+ // but the ancestor component has NOT fired its will update lifecycle yet
1311
+ // so let's just cool our jets and wait for the ancestor to continue first
1312
+ // this will get fired off when the ancestor component
1313
+ // finally gets around to rendering its lazy self
1314
+ // fire off the initial update
1315
+ ancestorComponent['s-rc'].push(schedule);
1316
+ }
1317
+ else {
1318
+ schedule();
1319
+ }
1320
+ };
1321
+ const fireConnectedCallback = (instance) => {
1322
+ {
1323
+ safeCall(instance, 'connectedCallback');
1324
+ }
1325
+ };
1326
+ const connectedCallback = (elm) => {
1327
+ if ((plt.$flags$ & 1 /* PLATFORM_FLAGS.isTmpDisconnected */) === 0) {
1328
+ const hostRef = getHostRef(elm);
1329
+ const cmpMeta = hostRef.$cmpMeta$;
1330
+ const endConnected = createTime('connectedCallback', cmpMeta.$tagName$);
1331
+ if (!(hostRef.$flags$ & 1 /* HOST_FLAGS.hasConnected */)) {
1332
+ // first time this component has connected
1333
+ hostRef.$flags$ |= 1 /* HOST_FLAGS.hasConnected */;
1334
+ {
1335
+ // find the first ancestor component (if there is one) and register
1336
+ // this component as one of the actively loading child components for its ancestor
1337
+ let ancestorComponent = elm;
1338
+ while ((ancestorComponent = ancestorComponent.parentNode || ancestorComponent.host)) {
1339
+ // climb up the ancestors looking for the first
1340
+ // component that hasn't finished its lifecycle update yet
1341
+ if (ancestorComponent['s-p']) {
1342
+ // we found this components first ancestor component
1343
+ // keep a reference to this component's ancestor component
1344
+ attachToAncestor(hostRef, (hostRef.$ancestorComponent$ = ancestorComponent));
1345
+ break;
1346
+ }
1347
+ }
1348
+ }
1349
+ // Lazy properties
1350
+ // https://developers.google.com/web/fundamentals/web-components/best-practices#lazy-properties
1351
+ if (cmpMeta.$members$) {
1352
+ Object.entries(cmpMeta.$members$).map(([memberName, [memberFlags]]) => {
1353
+ if (memberFlags & 31 /* MEMBER_FLAGS.Prop */ && elm.hasOwnProperty(memberName)) {
1354
+ const value = elm[memberName];
1355
+ delete elm[memberName];
1356
+ elm[memberName] = value;
1357
+ }
1358
+ });
1359
+ }
1360
+ {
1361
+ initializeComponent(elm, hostRef, cmpMeta);
1362
+ }
1363
+ }
1364
+ else {
1365
+ // not the first time this has connected
1366
+ // reattach any event listeners to the host
1367
+ // since they would have been removed when disconnected
1368
+ addHostEventListeners(elm, hostRef, cmpMeta.$listeners$);
1369
+ // fire off connectedCallback() on component instance
1370
+ fireConnectedCallback(hostRef.$lazyInstance$);
1371
+ }
1372
+ endConnected();
1373
+ }
1374
+ };
1375
+ const disconnectedCallback = (elm) => {
1376
+ if ((plt.$flags$ & 1 /* PLATFORM_FLAGS.isTmpDisconnected */) === 0) {
1377
+ const hostRef = getHostRef(elm);
1378
+ const instance = hostRef.$lazyInstance$ ;
1379
+ {
1380
+ if (hostRef.$rmListeners$) {
1381
+ hostRef.$rmListeners$.map((rmListener) => rmListener());
1382
+ hostRef.$rmListeners$ = undefined;
1383
+ }
1384
+ }
1385
+ {
1386
+ safeCall(instance, 'disconnectedCallback');
1387
+ }
1388
+ }
1389
+ };
1390
+ const bootstrapLazy = (lazyBundles, options = {}) => {
1391
+ var _a;
1392
+ const endBootstrap = createTime();
1393
+ const cmpTags = [];
1394
+ const exclude = options.exclude || [];
1395
+ const customElements = win.customElements;
1396
+ const head = doc.head;
1397
+ const metaCharset = /*@__PURE__*/ head.querySelector('meta[charset]');
1398
+ const visibilityStyle = /*@__PURE__*/ doc.createElement('style');
1399
+ const deferredConnectedCallbacks = [];
1400
+ let appLoadFallback;
1401
+ let isBootstrapping = true;
1402
+ Object.assign(plt, options);
1403
+ plt.$resourcesUrl$ = new URL(options.resourcesUrl || './', doc.baseURI).href;
1404
+ lazyBundles.map((lazyBundle) => {
1405
+ lazyBundle[1].map((compactMeta) => {
1406
+ const cmpMeta = {
1407
+ $flags$: compactMeta[0],
1408
+ $tagName$: compactMeta[1],
1409
+ $members$: compactMeta[2],
1410
+ $listeners$: compactMeta[3],
1411
+ };
1412
+ {
1413
+ cmpMeta.$members$ = compactMeta[2];
1414
+ }
1415
+ {
1416
+ cmpMeta.$listeners$ = compactMeta[3];
1417
+ }
1418
+ const tagName = cmpMeta.$tagName$;
1419
+ const HostElement = class extends HTMLElement {
1420
+ // StencilLazyHost
1421
+ constructor(self) {
1422
+ // @ts-ignore
1423
+ super(self);
1424
+ self = this;
1425
+ registerHost(self, cmpMeta);
1426
+ if (cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) {
1427
+ // this component is using shadow dom
1428
+ // and this browser supports shadow dom
1429
+ // add the read-only property "shadowRoot" to the host element
1430
+ // adding the shadow root build conditionals to minimize runtime
1431
+ {
1432
+ {
1433
+ self.attachShadow({ mode: 'open' });
1434
+ }
1435
+ }
1436
+ }
1437
+ }
1438
+ connectedCallback() {
1439
+ if (appLoadFallback) {
1440
+ clearTimeout(appLoadFallback);
1441
+ appLoadFallback = null;
1442
+ }
1443
+ if (isBootstrapping) {
1444
+ // connectedCallback will be processed once all components have been registered
1445
+ deferredConnectedCallbacks.push(this);
1446
+ }
1447
+ else {
1448
+ plt.jmp(() => connectedCallback(this));
1449
+ }
1450
+ }
1451
+ disconnectedCallback() {
1452
+ plt.jmp(() => disconnectedCallback(this));
1453
+ }
1454
+ componentOnReady() {
1455
+ return getHostRef(this).$onReadyPromise$;
1456
+ }
1457
+ };
1458
+ cmpMeta.$lazyBundleId$ = lazyBundle[0];
1459
+ if (!exclude.includes(tagName) && !customElements.get(tagName)) {
1460
+ cmpTags.push(tagName);
1461
+ customElements.define(tagName, proxyComponent(HostElement, cmpMeta, 1 /* PROXY_FLAGS.isElementConstructor */));
1462
+ }
1463
+ });
1464
+ });
1465
+ {
1466
+ visibilityStyle.innerHTML = cmpTags + HYDRATED_CSS;
1467
+ visibilityStyle.setAttribute('data-styles', '');
1468
+ // Apply CSP nonce to the style tag if it exists
1469
+ const nonce = (_a = plt.$nonce$) !== null && _a !== void 0 ? _a : queryNonceMetaTagContent(doc);
1470
+ if (nonce != null) {
1471
+ visibilityStyle.setAttribute('nonce', nonce);
1472
+ }
1473
+ head.insertBefore(visibilityStyle, metaCharset ? metaCharset.nextSibling : head.firstChild);
1474
+ }
1475
+ // Process deferred connectedCallbacks now all components have been registered
1476
+ isBootstrapping = false;
1477
+ if (deferredConnectedCallbacks.length) {
1478
+ deferredConnectedCallbacks.map((host) => host.connectedCallback());
1479
+ }
1480
+ else {
1481
+ {
1482
+ plt.jmp(() => (appLoadFallback = setTimeout(appDidLoad, 30)));
1483
+ }
1484
+ }
1485
+ // Fallback appLoad event
1486
+ endBootstrap();
1487
+ };
1488
+ const addHostEventListeners = (elm, hostRef, listeners, attachParentListeners) => {
1489
+ if (listeners) {
1490
+ listeners.map(([flags, name, method]) => {
1491
+ const target = getHostListenerTarget(elm, flags) ;
1492
+ const handler = hostListenerProxy(hostRef, method);
1493
+ const opts = hostListenerOpts(flags);
1494
+ plt.ael(target, name, handler, opts);
1495
+ (hostRef.$rmListeners$ = hostRef.$rmListeners$ || []).push(() => plt.rel(target, name, handler, opts));
1496
+ });
1497
+ }
1498
+ };
1499
+ const hostListenerProxy = (hostRef, methodName) => (ev) => {
1500
+ try {
1501
+ {
1502
+ if (hostRef.$flags$ & 256 /* HOST_FLAGS.isListenReady */) {
1503
+ // instance is ready, let's call it's member method for this event
1504
+ hostRef.$lazyInstance$[methodName](ev);
1505
+ }
1506
+ else {
1507
+ (hostRef.$queuedListeners$ = hostRef.$queuedListeners$ || []).push([methodName, ev]);
1508
+ }
1509
+ }
1510
+ }
1511
+ catch (e) {
1512
+ consoleError(e);
1513
+ }
1514
+ };
1515
+ const getHostListenerTarget = (elm, flags) => {
1516
+ if (flags & 4 /* LISTENER_FLAGS.TargetDocument */)
1517
+ return doc;
1518
+ return elm;
1519
+ };
1520
+ // prettier-ignore
1521
+ const hostListenerOpts = (flags) => (flags & 2 /* LISTENER_FLAGS.Capture */) !== 0;
1522
+ /**
1523
+ * Assigns the given value to the nonce property on the runtime platform object.
1524
+ * During runtime, this value is used to set the nonce attribute on all dynamically created script and style tags.
1525
+ * @param nonce The value to be assigned to the platform nonce property.
1526
+ * @returns void
1527
+ */
1528
+ const setNonce = (nonce) => (plt.$nonce$ = nonce);
1529
+ const hostRefs = /*@__PURE__*/ new WeakMap();
1530
+ const getHostRef = (ref) => hostRefs.get(ref);
1531
+ const registerInstance = (lazyInstance, hostRef) => hostRefs.set((hostRef.$lazyInstance$ = lazyInstance), hostRef);
1532
+ const registerHost = (elm, cmpMeta) => {
1533
+ const hostRef = {
1534
+ $flags$: 0,
1535
+ $hostElement$: elm,
1536
+ $cmpMeta$: cmpMeta,
1537
+ $instanceValues$: new Map(),
1538
+ };
1539
+ {
1540
+ hostRef.$onReadyPromise$ = new Promise((r) => (hostRef.$onReadyResolve$ = r));
1541
+ elm['s-p'] = [];
1542
+ elm['s-rc'] = [];
1543
+ }
1544
+ addHostEventListeners(elm, hostRef, cmpMeta.$listeners$);
1545
+ return hostRefs.set(elm, hostRef);
1546
+ };
1547
+ const isMemberInElement = (elm, memberName) => memberName in elm;
1548
+ const consoleError = (e, el) => (0, console.error)(e, el);
1549
+ const cmpModules = /*@__PURE__*/ new Map();
1550
+ const loadModule = (cmpMeta, hostRef, hmrVersionId) => {
1551
+ // loadModuleImport
1552
+ const exportName = cmpMeta.$tagName$.replace(/-/g, '_');
1553
+ const bundleId = cmpMeta.$lazyBundleId$;
1554
+ const module = cmpModules.get(bundleId) ;
1555
+ if (module) {
1556
+ return module[exportName];
1557
+ }
1558
+ /*!__STENCIL_STATIC_IMPORT_SWITCH__*/
1559
+ return Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require(
1560
+ /* @vite-ignore */
1561
+ /* webpackInclude: /\.entry\.js$/ */
1562
+ /* webpackExclude: /\.system\.entry\.js$/ */
1563
+ /* webpackMode: "lazy" */
1564
+ `./${bundleId}.entry.js${''}`)); }).then((importedModule) => {
1565
+ {
1566
+ cmpModules.set(bundleId, importedModule);
1567
+ }
1568
+ return importedModule[exportName];
1569
+ }, consoleError);
1570
+ };
1571
+ const styles = /*@__PURE__*/ new Map();
1572
+ const win = typeof window !== 'undefined' ? window : {};
1573
+ const doc = win.document || { head: {} };
1574
+ const plt = {
1575
+ $flags$: 0,
1576
+ $resourcesUrl$: '',
1577
+ jmp: (h) => h(),
1578
+ raf: (h) => requestAnimationFrame(h),
1579
+ ael: (el, eventName, listener, opts) => el.addEventListener(eventName, listener, opts),
1580
+ rel: (el, eventName, listener, opts) => el.removeEventListener(eventName, listener, opts),
1581
+ ce: (eventName, opts) => new CustomEvent(eventName, opts),
1582
+ };
1583
+ const promiseResolve = (v) => Promise.resolve(v);
1584
+ const supportsConstructableStylesheets = /*@__PURE__*/ (() => {
1585
+ try {
1586
+ new CSSStyleSheet();
1587
+ return typeof new CSSStyleSheet().replaceSync === 'function';
1588
+ }
1589
+ catch (e) { }
1590
+ return false;
1591
+ })()
1592
+ ;
1593
+ const queueDomReads = [];
1594
+ const queueDomWrites = [];
1595
+ const queueTask = (queue, write) => (cb) => {
1596
+ queue.push(cb);
1597
+ if (!queuePending) {
1598
+ queuePending = true;
1599
+ if (write && plt.$flags$ & 4 /* PLATFORM_FLAGS.queueSync */) {
1600
+ nextTick(flush);
1601
+ }
1602
+ else {
1603
+ plt.raf(flush);
1604
+ }
1605
+ }
1606
+ };
1607
+ const consume = (queue) => {
1608
+ for (let i = 0; i < queue.length; i++) {
1609
+ try {
1610
+ queue[i](performance.now());
1611
+ }
1612
+ catch (e) {
1613
+ consoleError(e);
1614
+ }
1615
+ }
1616
+ queue.length = 0;
1617
+ };
1618
+ const flush = () => {
1619
+ // always force a bunch of medium callbacks to run, but still have
1620
+ // a throttle on how many can run in a certain time
1621
+ // DOM READS!!!
1622
+ consume(queueDomReads);
1623
+ // DOM WRITES!!!
1624
+ {
1625
+ consume(queueDomWrites);
1626
+ if ((queuePending = queueDomReads.length > 0)) {
1627
+ // still more to do yet, but we've run out of time
1628
+ // let's let this thing cool off and try again in the next tick
1629
+ plt.raf(flush);
1630
+ }
1631
+ }
1632
+ };
1633
+ const nextTick = /*@__PURE__*/ (cb) => promiseResolve().then(cb);
1634
+ const writeTask = /*@__PURE__*/ queueTask(queueDomWrites, true);
1635
+
1636
+ exports.Build = Build;
1637
+ exports.Host = Host;
1638
+ exports.bootstrapLazy = bootstrapLazy;
1639
+ exports.getElement = getElement;
1640
+ exports.h = h;
1641
+ exports.promiseResolve = promiseResolve;
1642
+ exports.registerInstance = registerInstance;
1643
+ exports.setNonce = setNonce;
1644
+
1645
+ //# sourceMappingURL=index-1e526aba.js.map