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