pushfeedback 0.1.69 → 0.1.70

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 (47) hide show
  1. package/dist/components/canvas-editor.d.ts +11 -0
  2. package/dist/components/index.d.ts +1 -0
  3. package/dist/pushfeedback/app-globals-0f993ce5.js +3 -0
  4. package/dist/pushfeedback/canvas-editor.entry.js +860 -0
  5. package/dist/pushfeedback/css-shim-b7d3d95f.js +4 -0
  6. package/dist/pushfeedback/dom-64053c71.js +73 -0
  7. package/dist/{components/feedback-button.js → pushfeedback/feedback-button.entry.js} +30 -73
  8. package/dist/pushfeedback/feedback-modal.entry.js +295 -0
  9. package/dist/pushfeedback/index-36434da0.js +3371 -0
  10. package/dist/pushfeedback/index.esm.js +1 -0
  11. package/dist/pushfeedback/pushfeedback.css +146 -1
  12. package/dist/pushfeedback/pushfeedback.esm.js +148 -1
  13. package/dist/pushfeedback/shadow-css-98135883.js +387 -0
  14. package/dist/types/components/canvas-editor/canvas-editor.d.ts +108 -0
  15. package/dist/types/components/feedback-button/feedback-button.d.ts +11 -0
  16. package/dist/types/components/feedback-modal/feedback-modal.d.ts +22 -79
  17. package/dist/types/components.d.ts +102 -0
  18. package/package.json +3 -4
  19. package/dist/cjs/feedback-button_2.cjs.entry.js +0 -1202
  20. package/dist/cjs/index-9a8f4784.js +0 -1584
  21. package/dist/cjs/index.cjs.js +0 -2
  22. package/dist/cjs/loader.cjs.js +0 -22
  23. package/dist/cjs/pushfeedback.cjs.js +0 -23
  24. package/dist/collection/collection-manifest.json +0 -13
  25. package/dist/collection/components/feedback-button/feedback-button.css +0 -81
  26. package/dist/collection/components/feedback-button/feedback-button.js +0 -949
  27. package/dist/collection/components/feedback-modal/feedback-modal.css +0 -1003
  28. package/dist/collection/components/feedback-modal/feedback-modal.js +0 -1792
  29. package/dist/collection/index.js +0 -1
  30. package/dist/components/feedback-modal.js +0 -6
  31. package/dist/components/feedback-modal2.js +0 -1101
  32. package/dist/components/index.js +0 -3
  33. package/dist/esm/feedback-button_2.entry.js +0 -1197
  34. package/dist/esm/index-f65e9124.js +0 -1555
  35. package/dist/esm/index.js +0 -1
  36. package/dist/esm/loader.js +0 -18
  37. package/dist/esm/polyfills/core-js.js +0 -11
  38. package/dist/esm/polyfills/css-shim.js +0 -1
  39. package/dist/esm/polyfills/dom.js +0 -79
  40. package/dist/esm/polyfills/es5-html-element.js +0 -1
  41. package/dist/esm/polyfills/index.js +0 -34
  42. package/dist/esm/polyfills/system.js +0 -6
  43. package/dist/esm/pushfeedback.js +0 -18
  44. package/dist/index.cjs.js +0 -1
  45. package/dist/index.js +0 -1
  46. package/dist/pushfeedback/p-af2a1f7f.js +0 -2
  47. package/dist/pushfeedback/p-e7f48090.entry.js +0 -1
@@ -0,0 +1,3371 @@
1
+ const NAMESPACE = 'pushfeedback';
2
+ const BUILD = /* pushfeedback */ { allRenderFn: true, appendChildSlotFix: false, asyncLoading: true, asyncQueue: false, attachStyles: true, cloneNodeFix: false, cmpDidLoad: true, cmpDidRender: true, cmpDidUnload: false, cmpDidUpdate: false, cmpShouldUpdate: false, cmpWillLoad: true, cmpWillRender: false, cmpWillUpdate: false, connectedCallback: true, constructableCSS: false, cssAnnotations: true, cssVarShim: false, devTools: true, disconnectedCallback: true, dynamicImportShim: false, element: false, event: true, hasRenderFn: true, hostListener: false, hostListenerTarget: false, hostListenerTargetBody: false, hostListenerTargetDocument: false, hostListenerTargetParent: false, hostListenerTargetWindow: false, hotModuleReplacement: true, hydrateClientSide: false, hydrateServerSide: false, hydratedAttribute: false, hydratedClass: true, initializeNextTick: false, invisiblePrehydration: true, isDebug: false, isDev: true, isTesting: false, lazyLoad: true, lifecycle: true, lifecycleDOMEvents: false, member: true, method: true, mode: false, observeAttribute: true, profile: true, prop: true, propBoolean: true, propMutable: true, propNumber: true, propString: true, reflect: true, safari10: false, scoped: false, scopedSlotTextContentFix: false, scriptDataOpts: false, shadowDelegatesFocus: false, shadowDom: true, shadowDomShim: false, slot: true, slotChildNodesFix: false, slotRelocation: false, state: true, style: true, svg: true, taskQueue: true, transformTagName: false, updatable: true, vdomAttribute: true, vdomClass: true, vdomFunctional: false, vdomKey: true, vdomListener: true, vdomPropOrAttr: true, vdomRef: true, vdomRender: true, vdomStyle: true, vdomText: true, vdomXlink: false, watchCallback: false };
3
+ const Env = /* pushfeedback */ {};
4
+
5
+ /**
6
+ * Virtual DOM patching algorithm based on Snabbdom by
7
+ * Simon Friis Vindum (@paldepind)
8
+ * Licensed under the MIT License
9
+ * https://github.com/snabbdom/snabbdom/blob/master/LICENSE
10
+ *
11
+ * Modified for Stencil's renderer and slot projection
12
+ */
13
+ let scopeId;
14
+ let contentRef;
15
+ let hostTagName;
16
+ let customError;
17
+ let i = 0;
18
+ let useNativeShadowDom = false;
19
+ let checkSlotFallbackVisibility = false;
20
+ let checkSlotRelocate = false;
21
+ let isSvgMode = false;
22
+ let renderingRef = null;
23
+ let queueCongestion = 0;
24
+ let queuePending = false;
25
+ const Build = {
26
+ isDev: BUILD.isDev ? true : false,
27
+ isBrowser: true,
28
+ isServer: false,
29
+ isTesting: BUILD.isTesting ? true : false,
30
+ };
31
+ const Context = {};
32
+ const getAssetPath = (path) => {
33
+ const assetUrl = new URL(path, plt.$resourcesUrl$);
34
+ return assetUrl.origin !== win.location.origin ? assetUrl.href : assetUrl.pathname;
35
+ };
36
+ const setAssetPath = (path) => (plt.$resourcesUrl$ = path);
37
+ const createTime = (fnName, tagName = '') => {
38
+ if (BUILD.profile && performance.mark) {
39
+ const key = `st:${fnName}:${tagName}:${i++}`;
40
+ // Start
41
+ performance.mark(key);
42
+ // End
43
+ return () => performance.measure(`[Stencil] ${fnName}() <${tagName}>`, key);
44
+ }
45
+ else {
46
+ return () => {
47
+ return;
48
+ };
49
+ }
50
+ };
51
+ const uniqueTime = (key, measureText) => {
52
+ if (BUILD.profile && performance.mark) {
53
+ if (performance.getEntriesByName(key, 'mark').length === 0) {
54
+ performance.mark(key);
55
+ }
56
+ return () => {
57
+ if (performance.getEntriesByName(measureText, 'measure').length === 0) {
58
+ performance.measure(measureText, key);
59
+ }
60
+ };
61
+ }
62
+ else {
63
+ return () => {
64
+ return;
65
+ };
66
+ }
67
+ };
68
+ const inspect = (ref) => {
69
+ const hostRef = getHostRef(ref);
70
+ if (!hostRef) {
71
+ return undefined;
72
+ }
73
+ const flags = hostRef.$flags$;
74
+ const hostElement = hostRef.$hostElement$;
75
+ return {
76
+ renderCount: hostRef.$renderCount$,
77
+ flags: {
78
+ hasRendered: !!(flags & 2 /* HOST_FLAGS.hasRendered */),
79
+ hasConnected: !!(flags & 1 /* HOST_FLAGS.hasConnected */),
80
+ isWaitingForChildren: !!(flags & 4 /* HOST_FLAGS.isWaitingForChildren */),
81
+ isConstructingInstance: !!(flags & 8 /* HOST_FLAGS.isConstructingInstance */),
82
+ isQueuedForUpdate: !!(flags & 16 /* HOST_FLAGS.isQueuedForUpdate */),
83
+ hasInitializedComponent: !!(flags & 32 /* HOST_FLAGS.hasInitializedComponent */),
84
+ hasLoadedComponent: !!(flags & 64 /* HOST_FLAGS.hasLoadedComponent */),
85
+ isWatchReady: !!(flags & 128 /* HOST_FLAGS.isWatchReady */),
86
+ isListenReady: !!(flags & 256 /* HOST_FLAGS.isListenReady */),
87
+ needsRerender: !!(flags & 512 /* HOST_FLAGS.needsRerender */),
88
+ },
89
+ instanceValues: hostRef.$instanceValues$,
90
+ ancestorComponent: hostRef.$ancestorComponent$,
91
+ hostElement,
92
+ lazyInstance: hostRef.$lazyInstance$,
93
+ vnode: hostRef.$vnode$,
94
+ modeName: hostRef.$modeName$,
95
+ onReadyPromise: hostRef.$onReadyPromise$,
96
+ onReadyResolve: hostRef.$onReadyResolve$,
97
+ onInstancePromise: hostRef.$onInstancePromise$,
98
+ onInstanceResolve: hostRef.$onInstanceResolve$,
99
+ onRenderResolve: hostRef.$onRenderResolve$,
100
+ queuedListeners: hostRef.$queuedListeners$,
101
+ rmListeners: hostRef.$rmListeners$,
102
+ ['s-id']: hostElement['s-id'],
103
+ ['s-cr']: hostElement['s-cr'],
104
+ ['s-lr']: hostElement['s-lr'],
105
+ ['s-p']: hostElement['s-p'],
106
+ ['s-rc']: hostElement['s-rc'],
107
+ ['s-sc']: hostElement['s-sc'],
108
+ };
109
+ };
110
+ const installDevTools = () => {
111
+ if (BUILD.devTools) {
112
+ const stencil = (win.stencil = win.stencil || {});
113
+ const originalInspect = stencil.inspect;
114
+ stencil.inspect = (ref) => {
115
+ let result = inspect(ref);
116
+ if (!result && typeof originalInspect === 'function') {
117
+ result = originalInspect(ref);
118
+ }
119
+ return result;
120
+ };
121
+ }
122
+ };
123
+ const CONTENT_REF_ID = 'r';
124
+ const ORG_LOCATION_ID = 'o';
125
+ const SLOT_NODE_ID = 's';
126
+ const TEXT_NODE_ID = 't';
127
+ const HYDRATE_ID = 's-id';
128
+ const HYDRATED_STYLE_ID = 'sty-id';
129
+ const HYDRATE_CHILD_ID = 'c-id';
130
+ const HYDRATED_CSS = '{visibility:hidden}.hydrated{visibility:inherit}';
131
+ const XLINK_NS = 'http://www.w3.org/1999/xlink';
132
+ /**
133
+ * Default style mode id
134
+ */
135
+ /**
136
+ * Reusable empty obj/array
137
+ * Don't add values to these!!
138
+ */
139
+ const EMPTY_OBJ = {};
140
+ /**
141
+ * Namespaces
142
+ */
143
+ const SVG_NS = 'http://www.w3.org/2000/svg';
144
+ const HTML_NS = 'http://www.w3.org/1999/xhtml';
145
+ const isDef = (v) => v != null;
146
+ const isComplexType = (o) => {
147
+ // https://jsperf.com/typeof-fn-object/5
148
+ o = typeof o;
149
+ return o === 'object' || o === 'function';
150
+ };
151
+ /**
152
+ * Helper method for querying a `meta` tag that contains a nonce value
153
+ * out of a DOM's head.
154
+ *
155
+ * @param doc The DOM containing the `head` to query against
156
+ * @returns The content of the meta tag representing the nonce value, or `undefined` if no tag
157
+ * exists or the tag has no content.
158
+ */
159
+ function queryNonceMetaTagContent(doc) {
160
+ var _a, _b, _c;
161
+ 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;
162
+ }
163
+ /**
164
+ * Production h() function based on Preact by
165
+ * Jason Miller (@developit)
166
+ * Licensed under the MIT License
167
+ * https://github.com/developit/preact/blob/master/LICENSE
168
+ *
169
+ * Modified for Stencil's compiler and vdom
170
+ */
171
+ // export function h(nodeName: string | d.FunctionalComponent, vnodeData: d.PropsType, child?: d.ChildType): d.VNode;
172
+ // export function h(nodeName: string | d.FunctionalComponent, vnodeData: d.PropsType, ...children: d.ChildType[]): d.VNode;
173
+ const h = (nodeName, vnodeData, ...children) => {
174
+ let child = null;
175
+ let key = null;
176
+ let slotName = null;
177
+ let simple = false;
178
+ let lastSimple = false;
179
+ const vNodeChildren = [];
180
+ const walk = (c) => {
181
+ for (let i = 0; i < c.length; i++) {
182
+ child = c[i];
183
+ if (Array.isArray(child)) {
184
+ walk(child);
185
+ }
186
+ else if (child != null && typeof child !== 'boolean') {
187
+ if ((simple = typeof nodeName !== 'function' && !isComplexType(child))) {
188
+ child = String(child);
189
+ }
190
+ else if (BUILD.isDev && typeof nodeName !== 'function' && child.$flags$ === undefined) {
191
+ consoleDevError(`vNode passed as children has unexpected type.
192
+ Make sure it's using the correct h() function.
193
+ Empty objects can also be the cause, look for JSX comments that became objects.`);
194
+ }
195
+ if (simple && lastSimple) {
196
+ // If the previous child was simple (string), we merge both
197
+ vNodeChildren[vNodeChildren.length - 1].$text$ += child;
198
+ }
199
+ else {
200
+ // Append a new vNode, if it's text, we create a text vNode
201
+ vNodeChildren.push(simple ? newVNode(null, child) : child);
202
+ }
203
+ lastSimple = simple;
204
+ }
205
+ }
206
+ };
207
+ walk(children);
208
+ if (vnodeData) {
209
+ if (BUILD.isDev && nodeName === 'input') {
210
+ validateInputProperties(vnodeData);
211
+ }
212
+ // normalize class / classname attributes
213
+ if (BUILD.vdomKey && vnodeData.key) {
214
+ key = vnodeData.key;
215
+ }
216
+ if (BUILD.slotRelocation && vnodeData.name) {
217
+ slotName = vnodeData.name;
218
+ }
219
+ if (BUILD.vdomClass) {
220
+ const classData = vnodeData.className || vnodeData.class;
221
+ if (classData) {
222
+ vnodeData.class =
223
+ typeof classData !== 'object'
224
+ ? classData
225
+ : Object.keys(classData)
226
+ .filter((k) => classData[k])
227
+ .join(' ');
228
+ }
229
+ }
230
+ }
231
+ if (BUILD.isDev && vNodeChildren.some(isHost)) {
232
+ consoleDevError(`The <Host> must be the single root component. Make sure:
233
+ - You are NOT using hostData() and <Host> in the same component.
234
+ - <Host> is used once, and it's the single root component of the render() function.`);
235
+ }
236
+ if (BUILD.vdomFunctional && typeof nodeName === 'function') {
237
+ // nodeName is a functional component
238
+ return nodeName(vnodeData === null ? {} : vnodeData, vNodeChildren, vdomFnUtils);
239
+ }
240
+ const vnode = newVNode(nodeName, null);
241
+ vnode.$attrs$ = vnodeData;
242
+ if (vNodeChildren.length > 0) {
243
+ vnode.$children$ = vNodeChildren;
244
+ }
245
+ if (BUILD.vdomKey) {
246
+ vnode.$key$ = key;
247
+ }
248
+ if (BUILD.slotRelocation) {
249
+ vnode.$name$ = slotName;
250
+ }
251
+ return vnode;
252
+ };
253
+ /**
254
+ * A utility function for creating a virtual DOM node from a tag and some
255
+ * possible text content.
256
+ *
257
+ * @param tag the tag for this element
258
+ * @param text possible text content for the node
259
+ * @returns a newly-minted virtual DOM node
260
+ */
261
+ const newVNode = (tag, text) => {
262
+ const vnode = {
263
+ $flags$: 0,
264
+ $tag$: tag,
265
+ $text$: text,
266
+ $elm$: null,
267
+ $children$: null,
268
+ };
269
+ if (BUILD.vdomAttribute) {
270
+ vnode.$attrs$ = null;
271
+ }
272
+ if (BUILD.vdomKey) {
273
+ vnode.$key$ = null;
274
+ }
275
+ if (BUILD.slotRelocation) {
276
+ vnode.$name$ = null;
277
+ }
278
+ return vnode;
279
+ };
280
+ const Host = {};
281
+ /**
282
+ * Check whether a given node is a Host node or not
283
+ *
284
+ * @param node the virtual DOM node to check
285
+ * @returns whether it's a Host node or not
286
+ */
287
+ const isHost = (node) => node && node.$tag$ === Host;
288
+ /**
289
+ * Implementation of {@link d.FunctionalUtilities} for Stencil's VDom.
290
+ *
291
+ * Note that these functions convert from {@link d.VNode} to
292
+ * {@link d.ChildNode} to give functional component developers a friendly
293
+ * interface.
294
+ */
295
+ const vdomFnUtils = {
296
+ forEach: (children, cb) => children.map(convertToPublic).forEach(cb),
297
+ map: (children, cb) => children.map(convertToPublic).map(cb).map(convertToPrivate),
298
+ };
299
+ /**
300
+ * Convert a {@link d.VNode} to a {@link d.ChildNode} in order to present a
301
+ * friendlier public interface (hence, 'convertToPublic').
302
+ *
303
+ * @param node the virtual DOM node to convert
304
+ * @returns a converted child node
305
+ */
306
+ const convertToPublic = (node) => ({
307
+ vattrs: node.$attrs$,
308
+ vchildren: node.$children$,
309
+ vkey: node.$key$,
310
+ vname: node.$name$,
311
+ vtag: node.$tag$,
312
+ vtext: node.$text$,
313
+ });
314
+ /**
315
+ * Convert a {@link d.ChildNode} back to an equivalent {@link d.VNode} in
316
+ * order to use the resulting object in the virtual DOM. The initial object was
317
+ * likely created as part of presenting a public API, so converting it back
318
+ * involved making it 'private' again (hence, `convertToPrivate`).
319
+ *
320
+ * @param node the child node to convert
321
+ * @returns a converted virtual DOM node
322
+ */
323
+ const convertToPrivate = (node) => {
324
+ if (typeof node.vtag === 'function') {
325
+ const vnodeData = Object.assign({}, node.vattrs);
326
+ if (node.vkey) {
327
+ vnodeData.key = node.vkey;
328
+ }
329
+ if (node.vname) {
330
+ vnodeData.name = node.vname;
331
+ }
332
+ return h(node.vtag, vnodeData, ...(node.vchildren || []));
333
+ }
334
+ const vnode = newVNode(node.vtag, node.vtext);
335
+ vnode.$attrs$ = node.vattrs;
336
+ vnode.$children$ = node.vchildren;
337
+ vnode.$key$ = node.vkey;
338
+ vnode.$name$ = node.vname;
339
+ return vnode;
340
+ };
341
+ /**
342
+ * Validates the ordering of attributes on an input element
343
+ *
344
+ * @param inputElm the element to validate
345
+ */
346
+ const validateInputProperties = (inputElm) => {
347
+ const props = Object.keys(inputElm);
348
+ const value = props.indexOf('value');
349
+ if (value === -1) {
350
+ return;
351
+ }
352
+ const typeIndex = props.indexOf('type');
353
+ const minIndex = props.indexOf('min');
354
+ const maxIndex = props.indexOf('max');
355
+ const stepIndex = props.indexOf('step');
356
+ if (value < typeIndex || value < minIndex || value < maxIndex || value < stepIndex) {
357
+ consoleDevWarn(`The "value" prop of <input> should be set after "min", "max", "type" and "step"`);
358
+ }
359
+ };
360
+ const initializeClientHydrate = (hostElm, tagName, hostId, hostRef) => {
361
+ const endHydrate = createTime('hydrateClient', tagName);
362
+ const shadowRoot = hostElm.shadowRoot;
363
+ const childRenderNodes = [];
364
+ const slotNodes = [];
365
+ const shadowRootNodes = BUILD.shadowDom && shadowRoot ? [] : null;
366
+ const vnode = (hostRef.$vnode$ = newVNode(tagName, null));
367
+ if (!plt.$orgLocNodes$) {
368
+ initializeDocumentHydrate(doc.body, (plt.$orgLocNodes$ = new Map()));
369
+ }
370
+ hostElm[HYDRATE_ID] = hostId;
371
+ hostElm.removeAttribute(HYDRATE_ID);
372
+ clientHydrate(vnode, childRenderNodes, slotNodes, shadowRootNodes, hostElm, hostElm, hostId);
373
+ childRenderNodes.map((c) => {
374
+ const orgLocationId = c.$hostId$ + '.' + c.$nodeId$;
375
+ const orgLocationNode = plt.$orgLocNodes$.get(orgLocationId);
376
+ const node = c.$elm$;
377
+ if (orgLocationNode && supportsShadow && orgLocationNode['s-en'] === '') {
378
+ orgLocationNode.parentNode.insertBefore(node, orgLocationNode.nextSibling);
379
+ }
380
+ if (!shadowRoot) {
381
+ node['s-hn'] = tagName;
382
+ if (orgLocationNode) {
383
+ node['s-ol'] = orgLocationNode;
384
+ node['s-ol']['s-nr'] = node;
385
+ }
386
+ }
387
+ plt.$orgLocNodes$.delete(orgLocationId);
388
+ });
389
+ if (BUILD.shadowDom && shadowRoot) {
390
+ shadowRootNodes.map((shadowRootNode) => {
391
+ if (shadowRootNode) {
392
+ shadowRoot.appendChild(shadowRootNode);
393
+ }
394
+ });
395
+ }
396
+ endHydrate();
397
+ };
398
+ const clientHydrate = (parentVNode, childRenderNodes, slotNodes, shadowRootNodes, hostElm, node, hostId) => {
399
+ let childNodeType;
400
+ let childIdSplt;
401
+ let childVNode;
402
+ let i;
403
+ if (node.nodeType === 1 /* NODE_TYPE.ElementNode */) {
404
+ childNodeType = node.getAttribute(HYDRATE_CHILD_ID);
405
+ if (childNodeType) {
406
+ // got the node data from the element's attribute
407
+ // `${hostId}.${nodeId}.${depth}.${index}`
408
+ childIdSplt = childNodeType.split('.');
409
+ if (childIdSplt[0] === hostId || childIdSplt[0] === '0') {
410
+ childVNode = {
411
+ $flags$: 0,
412
+ $hostId$: childIdSplt[0],
413
+ $nodeId$: childIdSplt[1],
414
+ $depth$: childIdSplt[2],
415
+ $index$: childIdSplt[3],
416
+ $tag$: node.tagName.toLowerCase(),
417
+ $elm$: node,
418
+ $attrs$: null,
419
+ $children$: null,
420
+ $key$: null,
421
+ $name$: null,
422
+ $text$: null,
423
+ };
424
+ childRenderNodes.push(childVNode);
425
+ node.removeAttribute(HYDRATE_CHILD_ID);
426
+ // this is a new child vnode
427
+ // so ensure its parent vnode has the vchildren array
428
+ if (!parentVNode.$children$) {
429
+ parentVNode.$children$ = [];
430
+ }
431
+ // add our child vnode to a specific index of the vnode's children
432
+ parentVNode.$children$[childVNode.$index$] = childVNode;
433
+ // this is now the new parent vnode for all the next child checks
434
+ parentVNode = childVNode;
435
+ if (shadowRootNodes && childVNode.$depth$ === '0') {
436
+ shadowRootNodes[childVNode.$index$] = childVNode.$elm$;
437
+ }
438
+ }
439
+ }
440
+ // recursively drill down, end to start so we can remove nodes
441
+ for (i = node.childNodes.length - 1; i >= 0; i--) {
442
+ clientHydrate(parentVNode, childRenderNodes, slotNodes, shadowRootNodes, hostElm, node.childNodes[i], hostId);
443
+ }
444
+ if (node.shadowRoot) {
445
+ // keep drilling down through the shadow root nodes
446
+ for (i = node.shadowRoot.childNodes.length - 1; i >= 0; i--) {
447
+ clientHydrate(parentVNode, childRenderNodes, slotNodes, shadowRootNodes, hostElm, node.shadowRoot.childNodes[i], hostId);
448
+ }
449
+ }
450
+ }
451
+ else if (node.nodeType === 8 /* NODE_TYPE.CommentNode */) {
452
+ // `${COMMENT_TYPE}.${hostId}.${nodeId}.${depth}.${index}`
453
+ childIdSplt = node.nodeValue.split('.');
454
+ if (childIdSplt[1] === hostId || childIdSplt[1] === '0') {
455
+ // comment node for either the host id or a 0 host id
456
+ childNodeType = childIdSplt[0];
457
+ childVNode = {
458
+ $flags$: 0,
459
+ $hostId$: childIdSplt[1],
460
+ $nodeId$: childIdSplt[2],
461
+ $depth$: childIdSplt[3],
462
+ $index$: childIdSplt[4],
463
+ $elm$: node,
464
+ $attrs$: null,
465
+ $children$: null,
466
+ $key$: null,
467
+ $name$: null,
468
+ $tag$: null,
469
+ $text$: null,
470
+ };
471
+ if (childNodeType === TEXT_NODE_ID) {
472
+ childVNode.$elm$ = node.nextSibling;
473
+ if (childVNode.$elm$ && childVNode.$elm$.nodeType === 3 /* NODE_TYPE.TextNode */) {
474
+ childVNode.$text$ = childVNode.$elm$.textContent;
475
+ childRenderNodes.push(childVNode);
476
+ // remove the text comment since it's no longer needed
477
+ node.remove();
478
+ if (!parentVNode.$children$) {
479
+ parentVNode.$children$ = [];
480
+ }
481
+ parentVNode.$children$[childVNode.$index$] = childVNode;
482
+ if (shadowRootNodes && childVNode.$depth$ === '0') {
483
+ shadowRootNodes[childVNode.$index$] = childVNode.$elm$;
484
+ }
485
+ }
486
+ }
487
+ else if (childVNode.$hostId$ === hostId) {
488
+ // this comment node is specifcally for this host id
489
+ if (childNodeType === SLOT_NODE_ID) {
490
+ // `${SLOT_NODE_ID}.${hostId}.${nodeId}.${depth}.${index}.${slotName}`;
491
+ childVNode.$tag$ = 'slot';
492
+ if (childIdSplt[5]) {
493
+ node['s-sn'] = childVNode.$name$ = childIdSplt[5];
494
+ }
495
+ else {
496
+ node['s-sn'] = '';
497
+ }
498
+ node['s-sr'] = true;
499
+ if (BUILD.shadowDom && shadowRootNodes) {
500
+ // browser support shadowRoot and this is a shadow dom component
501
+ // create an actual slot element
502
+ childVNode.$elm$ = doc.createElement(childVNode.$tag$);
503
+ if (childVNode.$name$) {
504
+ // add the slot name attribute
505
+ childVNode.$elm$.setAttribute('name', childVNode.$name$);
506
+ }
507
+ // insert the new slot element before the slot comment
508
+ node.parentNode.insertBefore(childVNode.$elm$, node);
509
+ // remove the slot comment since it's not needed for shadow
510
+ node.remove();
511
+ if (childVNode.$depth$ === '0') {
512
+ shadowRootNodes[childVNode.$index$] = childVNode.$elm$;
513
+ }
514
+ }
515
+ slotNodes.push(childVNode);
516
+ if (!parentVNode.$children$) {
517
+ parentVNode.$children$ = [];
518
+ }
519
+ parentVNode.$children$[childVNode.$index$] = childVNode;
520
+ }
521
+ else if (childNodeType === CONTENT_REF_ID) {
522
+ // `${CONTENT_REF_ID}.${hostId}`;
523
+ if (BUILD.shadowDom && shadowRootNodes) {
524
+ // remove the content ref comment since it's not needed for shadow
525
+ node.remove();
526
+ }
527
+ else if (BUILD.slotRelocation) {
528
+ hostElm['s-cr'] = node;
529
+ node['s-cn'] = true;
530
+ }
531
+ }
532
+ }
533
+ }
534
+ }
535
+ else if (parentVNode && parentVNode.$tag$ === 'style') {
536
+ const vnode = newVNode(null, node.textContent);
537
+ vnode.$elm$ = node;
538
+ vnode.$index$ = '0';
539
+ parentVNode.$children$ = [vnode];
540
+ }
541
+ };
542
+ const initializeDocumentHydrate = (node, orgLocNodes) => {
543
+ if (node.nodeType === 1 /* NODE_TYPE.ElementNode */) {
544
+ let i = 0;
545
+ for (; i < node.childNodes.length; i++) {
546
+ initializeDocumentHydrate(node.childNodes[i], orgLocNodes);
547
+ }
548
+ if (node.shadowRoot) {
549
+ for (i = 0; i < node.shadowRoot.childNodes.length; i++) {
550
+ initializeDocumentHydrate(node.shadowRoot.childNodes[i], orgLocNodes);
551
+ }
552
+ }
553
+ }
554
+ else if (node.nodeType === 8 /* NODE_TYPE.CommentNode */) {
555
+ const childIdSplt = node.nodeValue.split('.');
556
+ if (childIdSplt[0] === ORG_LOCATION_ID) {
557
+ orgLocNodes.set(childIdSplt[1] + '.' + childIdSplt[2], node);
558
+ node.nodeValue = '';
559
+ // useful to know if the original location is
560
+ // the root light-dom of a shadow dom component
561
+ node['s-en'] = childIdSplt[3];
562
+ }
563
+ }
564
+ };
565
+ // Private
566
+ const computeMode = (elm) => modeResolutionChain.map((h) => h(elm)).find((m) => !!m);
567
+ // Public
568
+ const setMode = (handler) => modeResolutionChain.push(handler);
569
+ const getMode = (ref) => getHostRef(ref).$modeName$;
570
+ /**
571
+ * Parse a new property value for a given property type.
572
+ *
573
+ * While the prop value can reasonably be expected to be of `any` type as far as TypeScript's type checker is concerned,
574
+ * it is not safe to assume that the string returned by evaluating `typeof propValue` matches:
575
+ * 1. `any`, the type given to `propValue` in the function signature
576
+ * 2. the type stored from `propType`.
577
+ *
578
+ * This function provides the capability to parse/coerce a property's value to potentially any other JavaScript type.
579
+ *
580
+ * Property values represented in TSX preserve their type information. In the example below, the number 0 is passed to
581
+ * a component. This `propValue` will preserve its type information (`typeof propValue === 'number'`). Note that is
582
+ * based on the type of the value being passed in, not the type declared of the class member decorated with `@Prop`.
583
+ * ```tsx
584
+ * <my-cmp prop-val={0}></my-cmp>
585
+ * ```
586
+ *
587
+ * HTML prop values on the other hand, will always a string
588
+ *
589
+ * @param propValue the new value to coerce to some type
590
+ * @param propType the type of the prop, expressed as a binary number
591
+ * @returns the parsed/coerced value
592
+ */
593
+ const parsePropertyValue = (propValue, propType) => {
594
+ // ensure this value is of the correct prop type
595
+ if (propValue != null && !isComplexType(propValue)) {
596
+ if (BUILD.propBoolean && propType & 4 /* MEMBER_FLAGS.Boolean */) {
597
+ // per the HTML spec, any string value means it is a boolean true value
598
+ // but we'll cheat here and say that the string "false" is the boolean false
599
+ return propValue === 'false' ? false : propValue === '' || !!propValue;
600
+ }
601
+ if (BUILD.propNumber && propType & 2 /* MEMBER_FLAGS.Number */) {
602
+ // force it to be a number
603
+ return parseFloat(propValue);
604
+ }
605
+ if (BUILD.propString && propType & 1 /* MEMBER_FLAGS.String */) {
606
+ // could have been passed as a number or boolean
607
+ // but we still want it as a string
608
+ return String(propValue);
609
+ }
610
+ // redundant return here for better minification
611
+ return propValue;
612
+ }
613
+ // not sure exactly what type we want
614
+ // so no need to change to a different type
615
+ return propValue;
616
+ };
617
+ const getElement = (ref) => (BUILD.lazyLoad ? getHostRef(ref).$hostElement$ : ref);
618
+ const createEvent = (ref, name, flags) => {
619
+ const elm = getElement(ref);
620
+ return {
621
+ emit: (detail) => {
622
+ if (BUILD.isDev && !elm.isConnected) {
623
+ consoleDevWarn(`The "${name}" event was emitted, but the dispatcher node is no longer connected to the dom.`);
624
+ }
625
+ return emitEvent(elm, name, {
626
+ bubbles: !!(flags & 4 /* EVENT_FLAGS.Bubbles */),
627
+ composed: !!(flags & 2 /* EVENT_FLAGS.Composed */),
628
+ cancelable: !!(flags & 1 /* EVENT_FLAGS.Cancellable */),
629
+ detail,
630
+ });
631
+ },
632
+ };
633
+ };
634
+ /**
635
+ * Helper function to create & dispatch a custom Event on a provided target
636
+ * @param elm the target of the Event
637
+ * @param name the name to give the custom Event
638
+ * @param opts options for configuring a custom Event
639
+ * @returns the custom Event
640
+ */
641
+ const emitEvent = (elm, name, opts) => {
642
+ const ev = plt.ce(name, opts);
643
+ elm.dispatchEvent(ev);
644
+ return ev;
645
+ };
646
+ const rootAppliedStyles = /*@__PURE__*/ new WeakMap();
647
+ const registerStyle = (scopeId, cssText, allowCS) => {
648
+ let style = styles.get(scopeId);
649
+ if (supportsConstructableStylesheets && allowCS) {
650
+ style = (style || new CSSStyleSheet());
651
+ if (typeof style === 'string') {
652
+ style = cssText;
653
+ }
654
+ else {
655
+ style.replaceSync(cssText);
656
+ }
657
+ }
658
+ else {
659
+ style = cssText;
660
+ }
661
+ styles.set(scopeId, style);
662
+ };
663
+ const addStyle = (styleContainerNode, cmpMeta, mode, hostElm) => {
664
+ var _a;
665
+ let scopeId = getScopeId(cmpMeta, mode);
666
+ const style = styles.get(scopeId);
667
+ if (!BUILD.attachStyles) {
668
+ return scopeId;
669
+ }
670
+ // if an element is NOT connected then getRootNode() will return the wrong root node
671
+ // so the fallback is to always use the document for the root node in those cases
672
+ styleContainerNode = styleContainerNode.nodeType === 11 /* NODE_TYPE.DocumentFragment */ ? styleContainerNode : doc;
673
+ if (style) {
674
+ if (typeof style === 'string') {
675
+ styleContainerNode = styleContainerNode.head || styleContainerNode;
676
+ let appliedStyles = rootAppliedStyles.get(styleContainerNode);
677
+ let styleElm;
678
+ if (!appliedStyles) {
679
+ rootAppliedStyles.set(styleContainerNode, (appliedStyles = new Set()));
680
+ }
681
+ if (!appliedStyles.has(scopeId)) {
682
+ if (BUILD.hydrateClientSide &&
683
+ styleContainerNode.host &&
684
+ (styleElm = styleContainerNode.querySelector(`[${HYDRATED_STYLE_ID}="${scopeId}"]`))) {
685
+ // This is only happening on native shadow-dom, do not needs CSS var shim
686
+ styleElm.innerHTML = style;
687
+ }
688
+ else {
689
+ if (BUILD.cssVarShim && plt.$cssShim$) {
690
+ styleElm = plt.$cssShim$.createHostStyle(hostElm, scopeId, style, !!(cmpMeta.$flags$ & 10 /* CMP_FLAGS.needsScopedEncapsulation */));
691
+ const newScopeId = styleElm['s-sc'];
692
+ if (newScopeId) {
693
+ scopeId = newScopeId;
694
+ // we don't want to add this styleID to the appliedStyles Set
695
+ // since the cssVarShim might need to apply several different
696
+ // stylesheets for the same component
697
+ appliedStyles = null;
698
+ }
699
+ }
700
+ else {
701
+ styleElm = doc.createElement('style');
702
+ styleElm.innerHTML = style;
703
+ }
704
+ // Apply CSP nonce to the style tag if it exists
705
+ const nonce = (_a = plt.$nonce$) !== null && _a !== void 0 ? _a : queryNonceMetaTagContent(doc);
706
+ if (nonce != null) {
707
+ styleElm.setAttribute('nonce', nonce);
708
+ }
709
+ if (BUILD.hydrateServerSide || BUILD.hotModuleReplacement) {
710
+ styleElm.setAttribute(HYDRATED_STYLE_ID, scopeId);
711
+ }
712
+ styleContainerNode.insertBefore(styleElm, styleContainerNode.querySelector('link'));
713
+ }
714
+ if (appliedStyles) {
715
+ appliedStyles.add(scopeId);
716
+ }
717
+ }
718
+ }
719
+ else if (BUILD.constructableCSS && !styleContainerNode.adoptedStyleSheets.includes(style)) {
720
+ styleContainerNode.adoptedStyleSheets = [...styleContainerNode.adoptedStyleSheets, style];
721
+ }
722
+ }
723
+ return scopeId;
724
+ };
725
+ const attachStyles = (hostRef) => {
726
+ const cmpMeta = hostRef.$cmpMeta$;
727
+ const elm = hostRef.$hostElement$;
728
+ const flags = cmpMeta.$flags$;
729
+ const endAttachStyles = createTime('attachStyles', cmpMeta.$tagName$);
730
+ const scopeId = addStyle(BUILD.shadowDom && supportsShadow && elm.shadowRoot ? elm.shadowRoot : elm.getRootNode(), cmpMeta, hostRef.$modeName$, elm);
731
+ if ((BUILD.shadowDom || BUILD.scoped) && BUILD.cssAnnotations && flags & 10 /* CMP_FLAGS.needsScopedEncapsulation */) {
732
+ // only required when we're NOT using native shadow dom (slot)
733
+ // or this browser doesn't support native shadow dom
734
+ // and this host element was NOT created with SSR
735
+ // let's pick out the inner content for slot projection
736
+ // create a node to represent where the original
737
+ // content was first placed, which is useful later on
738
+ // DOM WRITE!!
739
+ elm['s-sc'] = scopeId;
740
+ elm.classList.add(scopeId + '-h');
741
+ if (BUILD.scoped && flags & 2 /* CMP_FLAGS.scopedCssEncapsulation */) {
742
+ elm.classList.add(scopeId + '-s');
743
+ }
744
+ }
745
+ endAttachStyles();
746
+ };
747
+ const getScopeId = (cmp, mode) => 'sc-' + (BUILD.mode && mode && cmp.$flags$ & 32 /* CMP_FLAGS.hasMode */ ? cmp.$tagName$ + '-' + mode : cmp.$tagName$);
748
+ const convertScopedToShadow = (css) => css.replace(/\/\*!@([^\/]+)\*\/[^\{]+\{/g, '$1{');
749
+ /**
750
+ * Production setAccessor() function based on Preact by
751
+ * Jason Miller (@developit)
752
+ * Licensed under the MIT License
753
+ * https://github.com/developit/preact/blob/master/LICENSE
754
+ *
755
+ * Modified for Stencil's compiler and vdom
756
+ */
757
+ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
758
+ if (oldValue !== newValue) {
759
+ let isProp = isMemberInElement(elm, memberName);
760
+ let ln = memberName.toLowerCase();
761
+ if (BUILD.vdomClass && memberName === 'class') {
762
+ const classList = elm.classList;
763
+ const oldClasses = parseClassList(oldValue);
764
+ const newClasses = parseClassList(newValue);
765
+ classList.remove(...oldClasses.filter((c) => c && !newClasses.includes(c)));
766
+ classList.add(...newClasses.filter((c) => c && !oldClasses.includes(c)));
767
+ }
768
+ else if (BUILD.vdomStyle && memberName === 'style') {
769
+ // update style attribute, css properties and values
770
+ if (BUILD.updatable) {
771
+ for (const prop in oldValue) {
772
+ if (!newValue || newValue[prop] == null) {
773
+ if (!BUILD.hydrateServerSide && prop.includes('-')) {
774
+ elm.style.removeProperty(prop);
775
+ }
776
+ else {
777
+ elm.style[prop] = '';
778
+ }
779
+ }
780
+ }
781
+ }
782
+ for (const prop in newValue) {
783
+ if (!oldValue || newValue[prop] !== oldValue[prop]) {
784
+ if (!BUILD.hydrateServerSide && prop.includes('-')) {
785
+ elm.style.setProperty(prop, newValue[prop]);
786
+ }
787
+ else {
788
+ elm.style[prop] = newValue[prop];
789
+ }
790
+ }
791
+ }
792
+ }
793
+ else if (BUILD.vdomKey && memberName === 'key')
794
+ ;
795
+ else if (BUILD.vdomRef && memberName === 'ref') {
796
+ // minifier will clean this up
797
+ if (newValue) {
798
+ newValue(elm);
799
+ }
800
+ }
801
+ else if (BUILD.vdomListener &&
802
+ (BUILD.lazyLoad ? !isProp : !elm.__lookupSetter__(memberName)) &&
803
+ memberName[0] === 'o' &&
804
+ memberName[1] === 'n') {
805
+ // Event Handlers
806
+ // so if the member name starts with "on" and the 3rd characters is
807
+ // a capital letter, and it's not already a member on the element,
808
+ // then we're assuming it's an event listener
809
+ if (memberName[2] === '-') {
810
+ // on- prefixed events
811
+ // allows to be explicit about the dom event to listen without any magic
812
+ // under the hood:
813
+ // <my-cmp on-click> // listens for "click"
814
+ // <my-cmp on-Click> // listens for "Click"
815
+ // <my-cmp on-ionChange> // listens for "ionChange"
816
+ // <my-cmp on-EVENTS> // listens for "EVENTS"
817
+ memberName = memberName.slice(3);
818
+ }
819
+ else if (isMemberInElement(win, ln)) {
820
+ // standard event
821
+ // the JSX attribute could have been "onMouseOver" and the
822
+ // member name "onmouseover" is on the window's prototype
823
+ // so let's add the listener "mouseover", which is all lowercased
824
+ memberName = ln.slice(2);
825
+ }
826
+ else {
827
+ // custom event
828
+ // the JSX attribute could have been "onMyCustomEvent"
829
+ // so let's trim off the "on" prefix and lowercase the first character
830
+ // and add the listener "myCustomEvent"
831
+ // except for the first character, we keep the event name case
832
+ memberName = ln[2] + memberName.slice(3);
833
+ }
834
+ if (oldValue) {
835
+ plt.rel(elm, memberName, oldValue, false);
836
+ }
837
+ if (newValue) {
838
+ plt.ael(elm, memberName, newValue, false);
839
+ }
840
+ }
841
+ else if (BUILD.vdomPropOrAttr) {
842
+ // Set property if it exists and it's not a SVG
843
+ const isComplex = isComplexType(newValue);
844
+ if ((isProp || (isComplex && newValue !== null)) && !isSvg) {
845
+ try {
846
+ if (!elm.tagName.includes('-')) {
847
+ const n = newValue == null ? '' : newValue;
848
+ // Workaround for Safari, moving the <input> caret when re-assigning the same valued
849
+ if (memberName === 'list') {
850
+ isProp = false;
851
+ }
852
+ else if (oldValue == null || elm[memberName] != n) {
853
+ elm[memberName] = n;
854
+ }
855
+ }
856
+ else {
857
+ elm[memberName] = newValue;
858
+ }
859
+ }
860
+ catch (e) { }
861
+ }
862
+ /**
863
+ * Need to manually update attribute if:
864
+ * - memberName is not an attribute
865
+ * - if we are rendering the host element in order to reflect attribute
866
+ * - if it's a SVG, since properties might not work in <svg>
867
+ * - if the newValue is null/undefined or 'false'.
868
+ */
869
+ let xlink = false;
870
+ if (BUILD.vdomXlink) {
871
+ if (ln !== (ln = ln.replace(/^xlink\:?/, ''))) {
872
+ memberName = ln;
873
+ xlink = true;
874
+ }
875
+ }
876
+ if (newValue == null || newValue === false) {
877
+ if (newValue !== false || elm.getAttribute(memberName) === '') {
878
+ if (BUILD.vdomXlink && xlink) {
879
+ elm.removeAttributeNS(XLINK_NS, memberName);
880
+ }
881
+ else {
882
+ elm.removeAttribute(memberName);
883
+ }
884
+ }
885
+ }
886
+ else if ((!isProp || flags & 4 /* VNODE_FLAGS.isHost */ || isSvg) && !isComplex) {
887
+ newValue = newValue === true ? '' : newValue;
888
+ if (BUILD.vdomXlink && xlink) {
889
+ elm.setAttributeNS(XLINK_NS, memberName, newValue);
890
+ }
891
+ else {
892
+ elm.setAttribute(memberName, newValue);
893
+ }
894
+ }
895
+ }
896
+ }
897
+ };
898
+ const parseClassListRegex = /\s/;
899
+ const parseClassList = (value) => (!value ? [] : value.split(parseClassListRegex));
900
+ const updateElement = (oldVnode, newVnode, isSvgMode, memberName) => {
901
+ // if the element passed in is a shadow root, which is a document fragment
902
+ // then we want to be adding attrs/props to the shadow root's "host" element
903
+ // if it's not a shadow root, then we add attrs/props to the same element
904
+ const elm = newVnode.$elm$.nodeType === 11 /* NODE_TYPE.DocumentFragment */ && newVnode.$elm$.host
905
+ ? newVnode.$elm$.host
906
+ : newVnode.$elm$;
907
+ const oldVnodeAttrs = (oldVnode && oldVnode.$attrs$) || EMPTY_OBJ;
908
+ const newVnodeAttrs = newVnode.$attrs$ || EMPTY_OBJ;
909
+ if (BUILD.updatable) {
910
+ // remove attributes no longer present on the vnode by setting them to undefined
911
+ for (memberName in oldVnodeAttrs) {
912
+ if (!(memberName in newVnodeAttrs)) {
913
+ setAccessor(elm, memberName, oldVnodeAttrs[memberName], undefined, isSvgMode, newVnode.$flags$);
914
+ }
915
+ }
916
+ }
917
+ // add new & update changed attributes
918
+ for (memberName in newVnodeAttrs) {
919
+ setAccessor(elm, memberName, oldVnodeAttrs[memberName], newVnodeAttrs[memberName], isSvgMode, newVnode.$flags$);
920
+ }
921
+ };
922
+ /**
923
+ * Create a DOM Node corresponding to one of the children of a given VNode.
924
+ *
925
+ * @param oldParentVNode the parent VNode from the previous render
926
+ * @param newParentVNode the parent VNode from the current render
927
+ * @param childIndex the index of the VNode, in the _new_ parent node's
928
+ * children, for which we will create a new DOM node
929
+ * @param parentElm the parent DOM node which our new node will be a child of
930
+ * @returns the newly created node
931
+ */
932
+ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
933
+ // tslint:disable-next-line: prefer-const
934
+ const newVNode = newParentVNode.$children$[childIndex];
935
+ let i = 0;
936
+ let elm;
937
+ let childNode;
938
+ let oldVNode;
939
+ if (BUILD.slotRelocation && !useNativeShadowDom) {
940
+ // remember for later we need to check to relocate nodes
941
+ checkSlotRelocate = true;
942
+ if (newVNode.$tag$ === 'slot') {
943
+ if (scopeId) {
944
+ // scoped css needs to add its scoped id to the parent element
945
+ parentElm.classList.add(scopeId + '-s');
946
+ }
947
+ newVNode.$flags$ |= newVNode.$children$
948
+ ? // slot element has fallback content
949
+ 2 /* VNODE_FLAGS.isSlotFallback */
950
+ : // slot element does not have fallback content
951
+ 1 /* VNODE_FLAGS.isSlotReference */;
952
+ }
953
+ }
954
+ if (BUILD.isDev && newVNode.$elm$) {
955
+ consoleDevError(`The JSX ${newVNode.$text$ !== null ? `"${newVNode.$text$}" text` : `"${newVNode.$tag$}" element`} node should not be shared within the same renderer. The renderer caches element lookups in order to improve performance. However, a side effect from this is that the exact same JSX node should not be reused. For more information please see https://stenciljs.com/docs/templating-jsx#avoid-shared-jsx-nodes`);
956
+ }
957
+ if (BUILD.vdomText && newVNode.$text$ !== null) {
958
+ // create text node
959
+ elm = newVNode.$elm$ = doc.createTextNode(newVNode.$text$);
960
+ }
961
+ else if (BUILD.slotRelocation && newVNode.$flags$ & 1 /* VNODE_FLAGS.isSlotReference */) {
962
+ // create a slot reference node
963
+ elm = newVNode.$elm$ =
964
+ BUILD.isDebug || BUILD.hydrateServerSide ? slotReferenceDebugNode(newVNode) : doc.createTextNode('');
965
+ }
966
+ else {
967
+ if (BUILD.svg && !isSvgMode) {
968
+ isSvgMode = newVNode.$tag$ === 'svg';
969
+ }
970
+ // create element
971
+ elm = newVNode.$elm$ = (BUILD.svg
972
+ ? doc.createElementNS(isSvgMode ? SVG_NS : HTML_NS, BUILD.slotRelocation && newVNode.$flags$ & 2 /* VNODE_FLAGS.isSlotFallback */
973
+ ? 'slot-fb'
974
+ : newVNode.$tag$)
975
+ : doc.createElement(BUILD.slotRelocation && newVNode.$flags$ & 2 /* VNODE_FLAGS.isSlotFallback */
976
+ ? 'slot-fb'
977
+ : newVNode.$tag$));
978
+ if (BUILD.svg && isSvgMode && newVNode.$tag$ === 'foreignObject') {
979
+ isSvgMode = false;
980
+ }
981
+ // add css classes, attrs, props, listeners, etc.
982
+ if (BUILD.vdomAttribute) {
983
+ updateElement(null, newVNode, isSvgMode);
984
+ }
985
+ if ((BUILD.shadowDom || BUILD.scoped) && isDef(scopeId) && elm['s-si'] !== scopeId) {
986
+ // if there is a scopeId and this is the initial render
987
+ // then let's add the scopeId as a css class
988
+ elm.classList.add((elm['s-si'] = scopeId));
989
+ }
990
+ if (newVNode.$children$) {
991
+ for (i = 0; i < newVNode.$children$.length; ++i) {
992
+ // create the node
993
+ childNode = createElm(oldParentVNode, newVNode, i, elm);
994
+ // return node could have been null
995
+ if (childNode) {
996
+ // append our new node
997
+ elm.appendChild(childNode);
998
+ }
999
+ }
1000
+ }
1001
+ if (BUILD.svg) {
1002
+ if (newVNode.$tag$ === 'svg') {
1003
+ // Only reset the SVG context when we're exiting <svg> element
1004
+ isSvgMode = false;
1005
+ }
1006
+ else if (elm.tagName === 'foreignObject') {
1007
+ // Reenter SVG context when we're exiting <foreignObject> element
1008
+ isSvgMode = true;
1009
+ }
1010
+ }
1011
+ }
1012
+ if (BUILD.slotRelocation) {
1013
+ elm['s-hn'] = hostTagName;
1014
+ if (newVNode.$flags$ & (2 /* VNODE_FLAGS.isSlotFallback */ | 1 /* VNODE_FLAGS.isSlotReference */)) {
1015
+ // remember the content reference comment
1016
+ elm['s-sr'] = true;
1017
+ // remember the content reference comment
1018
+ elm['s-cr'] = contentRef;
1019
+ // remember the slot name, or empty string for default slot
1020
+ elm['s-sn'] = newVNode.$name$ || '';
1021
+ // check if we've got an old vnode for this slot
1022
+ oldVNode = oldParentVNode && oldParentVNode.$children$ && oldParentVNode.$children$[childIndex];
1023
+ if (oldVNode && oldVNode.$tag$ === newVNode.$tag$ && oldParentVNode.$elm$) {
1024
+ // we've got an old slot vnode and the wrapper is being replaced
1025
+ // so let's move the old slot content back to it's original location
1026
+ putBackInOriginalLocation(oldParentVNode.$elm$, false);
1027
+ }
1028
+ }
1029
+ }
1030
+ return elm;
1031
+ };
1032
+ const putBackInOriginalLocation = (parentElm, recursive) => {
1033
+ plt.$flags$ |= 1 /* PLATFORM_FLAGS.isTmpDisconnected */;
1034
+ const oldSlotChildNodes = parentElm.childNodes;
1035
+ for (let i = oldSlotChildNodes.length - 1; i >= 0; i--) {
1036
+ const childNode = oldSlotChildNodes[i];
1037
+ if (childNode['s-hn'] !== hostTagName && childNode['s-ol']) {
1038
+ // // this child node in the old element is from another component
1039
+ // // remove this node from the old slot's parent
1040
+ // childNode.remove();
1041
+ // and relocate it back to it's original location
1042
+ parentReferenceNode(childNode).insertBefore(childNode, referenceNode(childNode));
1043
+ // remove the old original location comment entirely
1044
+ // later on the patch function will know what to do
1045
+ // and move this to the correct spot in need be
1046
+ childNode['s-ol'].remove();
1047
+ childNode['s-ol'] = undefined;
1048
+ checkSlotRelocate = true;
1049
+ }
1050
+ if (recursive) {
1051
+ putBackInOriginalLocation(childNode, recursive);
1052
+ }
1053
+ }
1054
+ plt.$flags$ &= ~1 /* PLATFORM_FLAGS.isTmpDisconnected */;
1055
+ };
1056
+ /**
1057
+ * Create DOM nodes corresponding to a list of {@link d.Vnode} objects and
1058
+ * add them to the DOM in the appropriate place.
1059
+ *
1060
+ * @param parentElm the DOM node which should be used as a parent for the new
1061
+ * DOM nodes
1062
+ * @param before a child of the `parentElm` which the new children should be
1063
+ * inserted before (optional)
1064
+ * @param parentVNode the parent virtual DOM node
1065
+ * @param vnodes the new child virtual DOM nodes to produce DOM nodes for
1066
+ * @param startIdx the index in the child virtual DOM nodes at which to start
1067
+ * creating DOM nodes (inclusive)
1068
+ * @param endIdx the index in the child virtual DOM nodes at which to stop
1069
+ * creating DOM nodes (inclusive)
1070
+ */
1071
+ const addVnodes = (parentElm, before, parentVNode, vnodes, startIdx, endIdx) => {
1072
+ let containerElm = ((BUILD.slotRelocation && parentElm['s-cr'] && parentElm['s-cr'].parentNode) || parentElm);
1073
+ let childNode;
1074
+ if (BUILD.shadowDom && containerElm.shadowRoot && containerElm.tagName === hostTagName) {
1075
+ containerElm = containerElm.shadowRoot;
1076
+ }
1077
+ for (; startIdx <= endIdx; ++startIdx) {
1078
+ if (vnodes[startIdx]) {
1079
+ childNode = createElm(null, parentVNode, startIdx, parentElm);
1080
+ if (childNode) {
1081
+ vnodes[startIdx].$elm$ = childNode;
1082
+ containerElm.insertBefore(childNode, BUILD.slotRelocation ? referenceNode(before) : before);
1083
+ }
1084
+ }
1085
+ }
1086
+ };
1087
+ /**
1088
+ * Remove the DOM elements corresponding to a list of {@link d.VNode} objects.
1089
+ * This can be used to, for instance, clean up after a list of children which
1090
+ * should no longer be shown.
1091
+ *
1092
+ * This function also handles some of Stencil's slot relocation logic.
1093
+ *
1094
+ * @param vnodes a list of virtual DOM nodes to remove
1095
+ * @param startIdx the index at which to start removing nodes (inclusive)
1096
+ * @param endIdx the index at which to stop removing nodes (inclusive)
1097
+ * @param vnode a VNode
1098
+ * @param elm an element
1099
+ */
1100
+ const removeVnodes = (vnodes, startIdx, endIdx, vnode, elm) => {
1101
+ for (; startIdx <= endIdx; ++startIdx) {
1102
+ if ((vnode = vnodes[startIdx])) {
1103
+ elm = vnode.$elm$;
1104
+ callNodeRefs(vnode);
1105
+ if (BUILD.slotRelocation) {
1106
+ // we're removing this element
1107
+ // so it's possible we need to show slot fallback content now
1108
+ checkSlotFallbackVisibility = true;
1109
+ if (elm['s-ol']) {
1110
+ // remove the original location comment
1111
+ elm['s-ol'].remove();
1112
+ }
1113
+ else {
1114
+ // it's possible that child nodes of the node
1115
+ // that's being removed are slot nodes
1116
+ putBackInOriginalLocation(elm, true);
1117
+ }
1118
+ }
1119
+ // remove the vnode's element from the dom
1120
+ elm.remove();
1121
+ }
1122
+ }
1123
+ };
1124
+ /**
1125
+ * Reconcile the children of a new VNode with the children of an old VNode by
1126
+ * traversing the two collections of children, identifying nodes that are
1127
+ * conserved or changed, calling out to `patch` to make any necessary
1128
+ * updates to the DOM, and rearranging DOM nodes as needed.
1129
+ *
1130
+ * The algorithm for reconciling children works by analyzing two 'windows' onto
1131
+ * the two arrays of children (`oldCh` and `newCh`). We keep track of the
1132
+ * 'windows' by storing start and end indices and references to the
1133
+ * corresponding array entries. Initially the two 'windows' are basically equal
1134
+ * to the entire array, but we progressively narrow the windows until there are
1135
+ * no children left to update by doing the following:
1136
+ *
1137
+ * 1. Skip any `null` entries at the beginning or end of the two arrays, so
1138
+ * that if we have an initial array like the following we'll end up dealing
1139
+ * only with a window bounded by the highlighted elements:
1140
+ *
1141
+ * [null, null, VNode1 , ... , VNode2, null, null]
1142
+ * ^^^^^^ ^^^^^^
1143
+ *
1144
+ * 2. Check to see if the elements at the head and tail positions are equal
1145
+ * across the windows. This will basically detect elements which haven't
1146
+ * been added, removed, or changed position, i.e. if you had the following
1147
+ * VNode elements (represented as HTML):
1148
+ *
1149
+ * oldVNode: `<div><p><span>HEY</span></p></div>`
1150
+ * newVNode: `<div><p><span>THERE</span></p></div>`
1151
+ *
1152
+ * Then when comparing the children of the `<div>` tag we check the equality
1153
+ * of the VNodes corresponding to the `<p>` tags and, since they are the
1154
+ * same tag in the same position, we'd be able to avoid completely
1155
+ * re-rendering the subtree under them with a new DOM element and would just
1156
+ * call out to `patch` to handle reconciling their children and so on.
1157
+ *
1158
+ * 3. Check, for both windows, to see if the element at the beginning of the
1159
+ * window corresponds to the element at the end of the other window. This is
1160
+ * a heuristic which will let us identify _some_ situations in which
1161
+ * elements have changed position, for instance it _should_ detect that the
1162
+ * children nodes themselves have not changed but merely moved in the
1163
+ * following example:
1164
+ *
1165
+ * oldVNode: `<div><element-one /><element-two /></div>`
1166
+ * newVNode: `<div><element-two /><element-one /></div>`
1167
+ *
1168
+ * If we find cases like this then we also need to move the concrete DOM
1169
+ * elements corresponding to the moved children to write the re-order to the
1170
+ * DOM.
1171
+ *
1172
+ * 4. Finally, if VNodes have the `key` attribute set on them we check for any
1173
+ * nodes in the old children which have the same key as the first element in
1174
+ * our window on the new children. If we find such a node we handle calling
1175
+ * out to `patch`, moving relevant DOM nodes, and so on, in accordance with
1176
+ * what we find.
1177
+ *
1178
+ * Finally, once we've narrowed our 'windows' to the point that either of them
1179
+ * collapse (i.e. they have length 0) we then handle any remaining VNode
1180
+ * insertion or deletion that needs to happen to get a DOM state that correctly
1181
+ * reflects the new child VNodes. If, for instance, after our window on the old
1182
+ * children has collapsed we still have more nodes on the new children that
1183
+ * we haven't dealt with yet then we need to add them, or if the new children
1184
+ * collapse but we still have unhandled _old_ children then we need to make
1185
+ * sure the corresponding DOM nodes are removed.
1186
+ *
1187
+ * @param parentElm the node into which the parent VNode is rendered
1188
+ * @param oldCh the old children of the parent node
1189
+ * @param newVNode the new VNode which will replace the parent
1190
+ * @param newCh the new children of the parent node
1191
+ */
1192
+ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
1193
+ let oldStartIdx = 0;
1194
+ let newStartIdx = 0;
1195
+ let idxInOld = 0;
1196
+ let i = 0;
1197
+ let oldEndIdx = oldCh.length - 1;
1198
+ let oldStartVnode = oldCh[0];
1199
+ let oldEndVnode = oldCh[oldEndIdx];
1200
+ let newEndIdx = newCh.length - 1;
1201
+ let newStartVnode = newCh[0];
1202
+ let newEndVnode = newCh[newEndIdx];
1203
+ let node;
1204
+ let elmToMove;
1205
+ while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
1206
+ if (oldStartVnode == null) {
1207
+ // VNode might have been moved left
1208
+ oldStartVnode = oldCh[++oldStartIdx];
1209
+ }
1210
+ else if (oldEndVnode == null) {
1211
+ oldEndVnode = oldCh[--oldEndIdx];
1212
+ }
1213
+ else if (newStartVnode == null) {
1214
+ newStartVnode = newCh[++newStartIdx];
1215
+ }
1216
+ else if (newEndVnode == null) {
1217
+ newEndVnode = newCh[--newEndIdx];
1218
+ }
1219
+ else if (isSameVnode(oldStartVnode, newStartVnode)) {
1220
+ // if the start nodes are the same then we should patch the new VNode
1221
+ // onto the old one, and increment our `newStartIdx` and `oldStartIdx`
1222
+ // indices to reflect that. We don't need to move any DOM Nodes around
1223
+ // since things are matched up in order.
1224
+ patch(oldStartVnode, newStartVnode);
1225
+ oldStartVnode = oldCh[++oldStartIdx];
1226
+ newStartVnode = newCh[++newStartIdx];
1227
+ }
1228
+ else if (isSameVnode(oldEndVnode, newEndVnode)) {
1229
+ // likewise, if the end nodes are the same we patch new onto old and
1230
+ // decrement our end indices, and also likewise in this case we don't
1231
+ // need to move any DOM Nodes.
1232
+ patch(oldEndVnode, newEndVnode);
1233
+ oldEndVnode = oldCh[--oldEndIdx];
1234
+ newEndVnode = newCh[--newEndIdx];
1235
+ }
1236
+ else if (isSameVnode(oldStartVnode, newEndVnode)) {
1237
+ // case: "Vnode moved right"
1238
+ //
1239
+ // We've found that the last node in our window on the new children is
1240
+ // the same VNode as the _first_ node in our window on the old children
1241
+ // we're dealing with now. Visually, this is the layout of these two
1242
+ // nodes:
1243
+ //
1244
+ // newCh: [..., newStartVnode , ... , newEndVnode , ...]
1245
+ // ^^^^^^^^^^^
1246
+ // oldCh: [..., oldStartVnode , ... , oldEndVnode , ...]
1247
+ // ^^^^^^^^^^^^^
1248
+ //
1249
+ // In this situation we need to patch `newEndVnode` onto `oldStartVnode`
1250
+ // and move the DOM element for `oldStartVnode`.
1251
+ if (BUILD.slotRelocation && (oldStartVnode.$tag$ === 'slot' || newEndVnode.$tag$ === 'slot')) {
1252
+ putBackInOriginalLocation(oldStartVnode.$elm$.parentNode, false);
1253
+ }
1254
+ patch(oldStartVnode, newEndVnode);
1255
+ // We need to move the element for `oldStartVnode` into a position which
1256
+ // will be appropriate for `newEndVnode`. For this we can use
1257
+ // `.insertBefore` and `oldEndVnode.$elm$.nextSibling`. If there is a
1258
+ // sibling for `oldEndVnode.$elm$` then we want to move the DOM node for
1259
+ // `oldStartVnode` between `oldEndVnode` and it's sibling, like so:
1260
+ //
1261
+ // <old-start-node />
1262
+ // <some-intervening-node />
1263
+ // <old-end-node />
1264
+ // <!-- -> <-- `oldStartVnode.$elm$` should be inserted here
1265
+ // <next-sibling />
1266
+ //
1267
+ // If instead `oldEndVnode.$elm$` has no sibling then we just want to put
1268
+ // the node for `oldStartVnode` at the end of the children of
1269
+ // `parentElm`. Luckily, `Node.nextSibling` will return `null` if there
1270
+ // aren't any siblings, and passing `null` to `Node.insertBefore` will
1271
+ // append it to the children of the parent element.
1272
+ parentElm.insertBefore(oldStartVnode.$elm$, oldEndVnode.$elm$.nextSibling);
1273
+ oldStartVnode = oldCh[++oldStartIdx];
1274
+ newEndVnode = newCh[--newEndIdx];
1275
+ }
1276
+ else if (isSameVnode(oldEndVnode, newStartVnode)) {
1277
+ // case: "Vnode moved left"
1278
+ //
1279
+ // We've found that the first node in our window on the new children is
1280
+ // the same VNode as the _last_ node in our window on the old children.
1281
+ // Visually, this is the layout of these two nodes:
1282
+ //
1283
+ // newCh: [..., newStartVnode , ... , newEndVnode , ...]
1284
+ // ^^^^^^^^^^^^^
1285
+ // oldCh: [..., oldStartVnode , ... , oldEndVnode , ...]
1286
+ // ^^^^^^^^^^^
1287
+ //
1288
+ // In this situation we need to patch `newStartVnode` onto `oldEndVnode`
1289
+ // (which will handle updating any changed attributes, reconciling their
1290
+ // children etc) but we also need to move the DOM node to which
1291
+ // `oldEndVnode` corresponds.
1292
+ if (BUILD.slotRelocation && (oldStartVnode.$tag$ === 'slot' || newEndVnode.$tag$ === 'slot')) {
1293
+ putBackInOriginalLocation(oldEndVnode.$elm$.parentNode, false);
1294
+ }
1295
+ patch(oldEndVnode, newStartVnode);
1296
+ // We've already checked above if `oldStartVnode` and `newStartVnode` are
1297
+ // the same node, so since we're here we know that they are not. Thus we
1298
+ // can move the element for `oldEndVnode` _before_ the element for
1299
+ // `oldStartVnode`, leaving `oldStartVnode` to be reconciled in the
1300
+ // future.
1301
+ parentElm.insertBefore(oldEndVnode.$elm$, oldStartVnode.$elm$);
1302
+ oldEndVnode = oldCh[--oldEndIdx];
1303
+ newStartVnode = newCh[++newStartIdx];
1304
+ }
1305
+ else {
1306
+ // Here we do some checks to match up old and new nodes based on the
1307
+ // `$key$` attribute, which is set by putting a `key="my-key"` attribute
1308
+ // in the JSX for a DOM element in the implementation of a Stencil
1309
+ // component.
1310
+ //
1311
+ // First we check to see if there are any nodes in the array of old
1312
+ // children which have the same key as the first node in the new
1313
+ // children.
1314
+ idxInOld = -1;
1315
+ if (BUILD.vdomKey) {
1316
+ for (i = oldStartIdx; i <= oldEndIdx; ++i) {
1317
+ if (oldCh[i] && oldCh[i].$key$ !== null && oldCh[i].$key$ === newStartVnode.$key$) {
1318
+ idxInOld = i;
1319
+ break;
1320
+ }
1321
+ }
1322
+ }
1323
+ if (BUILD.vdomKey && idxInOld >= 0) {
1324
+ // We found a node in the old children which matches up with the first
1325
+ // node in the new children! So let's deal with that
1326
+ elmToMove = oldCh[idxInOld];
1327
+ if (elmToMove.$tag$ !== newStartVnode.$tag$) {
1328
+ // the tag doesn't match so we'll need a new DOM element
1329
+ node = createElm(oldCh && oldCh[newStartIdx], newVNode, idxInOld, parentElm);
1330
+ }
1331
+ else {
1332
+ patch(elmToMove, newStartVnode);
1333
+ // invalidate the matching old node so that we won't try to update it
1334
+ // again later on
1335
+ oldCh[idxInOld] = undefined;
1336
+ node = elmToMove.$elm$;
1337
+ }
1338
+ newStartVnode = newCh[++newStartIdx];
1339
+ }
1340
+ else {
1341
+ // We either didn't find an element in the old children that matches
1342
+ // the key of the first new child OR the build is not using `key`
1343
+ // attributes at all. In either case we need to create a new element
1344
+ // for the new node.
1345
+ node = createElm(oldCh && oldCh[newStartIdx], newVNode, newStartIdx, parentElm);
1346
+ newStartVnode = newCh[++newStartIdx];
1347
+ }
1348
+ if (node) {
1349
+ // if we created a new node then handle inserting it to the DOM
1350
+ if (BUILD.slotRelocation) {
1351
+ parentReferenceNode(oldStartVnode.$elm$).insertBefore(node, referenceNode(oldStartVnode.$elm$));
1352
+ }
1353
+ else {
1354
+ oldStartVnode.$elm$.parentNode.insertBefore(node, oldStartVnode.$elm$);
1355
+ }
1356
+ }
1357
+ }
1358
+ }
1359
+ if (oldStartIdx > oldEndIdx) {
1360
+ // we have some more new nodes to add which don't match up with old nodes
1361
+ addVnodes(parentElm, newCh[newEndIdx + 1] == null ? null : newCh[newEndIdx + 1].$elm$, newVNode, newCh, newStartIdx, newEndIdx);
1362
+ }
1363
+ else if (BUILD.updatable && newStartIdx > newEndIdx) {
1364
+ // there are nodes in the `oldCh` array which no longer correspond to nodes
1365
+ // in the new array, so lets remove them (which entails cleaning up the
1366
+ // relevant DOM nodes)
1367
+ removeVnodes(oldCh, oldStartIdx, oldEndIdx);
1368
+ }
1369
+ };
1370
+ /**
1371
+ * Compare two VNodes to determine if they are the same
1372
+ *
1373
+ * **NB**: This function is an equality _heuristic_ based on the available
1374
+ * information set on the two VNodes and can be misleading under certain
1375
+ * circumstances. In particular, if the two nodes do not have `key` attrs
1376
+ * (available under `$key$` on VNodes) then the function falls back on merely
1377
+ * checking that they have the same tag.
1378
+ *
1379
+ * So, in other words, if `key` attrs are not set on VNodes which may be
1380
+ * changing order within a `children` array or something along those lines then
1381
+ * we could obtain a false negative and then have to do needless re-rendering
1382
+ * (i.e. we'd say two VNodes aren't equal when in fact they should be).
1383
+ *
1384
+ * @param leftVNode the first VNode to check
1385
+ * @param rightVNode the second VNode to check
1386
+ * @returns whether they're equal or not
1387
+ */
1388
+ const isSameVnode = (leftVNode, rightVNode) => {
1389
+ // compare if two vnode to see if they're "technically" the same
1390
+ // need to have the same element tag, and same key to be the same
1391
+ if (leftVNode.$tag$ === rightVNode.$tag$) {
1392
+ if (BUILD.slotRelocation && leftVNode.$tag$ === 'slot') {
1393
+ return leftVNode.$name$ === rightVNode.$name$;
1394
+ }
1395
+ // this will be set if components in the build have `key` attrs set on them
1396
+ if (BUILD.vdomKey) {
1397
+ return leftVNode.$key$ === rightVNode.$key$;
1398
+ }
1399
+ return true;
1400
+ }
1401
+ return false;
1402
+ };
1403
+ const referenceNode = (node) => {
1404
+ // this node was relocated to a new location in the dom
1405
+ // because of some other component's slot
1406
+ // but we still have an html comment in place of where
1407
+ // it's original location was according to it's original vdom
1408
+ return (node && node['s-ol']) || node;
1409
+ };
1410
+ const parentReferenceNode = (node) => (node['s-ol'] ? node['s-ol'] : node).parentNode;
1411
+ /**
1412
+ * Handle reconciling an outdated VNode with a new one which corresponds to
1413
+ * it. This function handles flushing updates to the DOM and reconciling the
1414
+ * children of the two nodes (if any).
1415
+ *
1416
+ * @param oldVNode an old VNode whose DOM element and children we want to update
1417
+ * @param newVNode a new VNode representing an updated version of the old one
1418
+ */
1419
+ const patch = (oldVNode, newVNode) => {
1420
+ const elm = (newVNode.$elm$ = oldVNode.$elm$);
1421
+ const oldChildren = oldVNode.$children$;
1422
+ const newChildren = newVNode.$children$;
1423
+ const tag = newVNode.$tag$;
1424
+ const text = newVNode.$text$;
1425
+ let defaultHolder;
1426
+ if (!BUILD.vdomText || text === null) {
1427
+ if (BUILD.svg) {
1428
+ // test if we're rendering an svg element, or still rendering nodes inside of one
1429
+ // only add this to the when the compiler sees we're using an svg somewhere
1430
+ isSvgMode = tag === 'svg' ? true : tag === 'foreignObject' ? false : isSvgMode;
1431
+ }
1432
+ if (BUILD.vdomAttribute || BUILD.reflect) {
1433
+ if (BUILD.slot && tag === 'slot')
1434
+ ;
1435
+ else {
1436
+ // either this is the first render of an element OR it's an update
1437
+ // AND we already know it's possible it could have changed
1438
+ // this updates the element's css classes, attrs, props, listeners, etc.
1439
+ updateElement(oldVNode, newVNode, isSvgMode);
1440
+ }
1441
+ }
1442
+ if (BUILD.updatable && oldChildren !== null && newChildren !== null) {
1443
+ // looks like there's child vnodes for both the old and new vnodes
1444
+ // so we need to call `updateChildren` to reconcile them
1445
+ updateChildren(elm, oldChildren, newVNode, newChildren);
1446
+ }
1447
+ else if (newChildren !== null) {
1448
+ // no old child vnodes, but there are new child vnodes to add
1449
+ if (BUILD.updatable && BUILD.vdomText && oldVNode.$text$ !== null) {
1450
+ // the old vnode was text, so be sure to clear it out
1451
+ elm.textContent = '';
1452
+ }
1453
+ // add the new vnode children
1454
+ addVnodes(elm, null, newVNode, newChildren, 0, newChildren.length - 1);
1455
+ }
1456
+ else if (BUILD.updatable && oldChildren !== null) {
1457
+ // no new child vnodes, but there are old child vnodes to remove
1458
+ removeVnodes(oldChildren, 0, oldChildren.length - 1);
1459
+ }
1460
+ if (BUILD.svg && isSvgMode && tag === 'svg') {
1461
+ isSvgMode = false;
1462
+ }
1463
+ }
1464
+ else if (BUILD.vdomText && BUILD.slotRelocation && (defaultHolder = elm['s-cr'])) {
1465
+ // this element has slotted content
1466
+ defaultHolder.parentNode.textContent = text;
1467
+ }
1468
+ else if (BUILD.vdomText && oldVNode.$text$ !== text) {
1469
+ // update the text content for the text only vnode
1470
+ // and also only if the text is different than before
1471
+ elm.data = text;
1472
+ }
1473
+ };
1474
+ const updateFallbackSlotVisibility = (elm) => {
1475
+ // tslint:disable-next-line: prefer-const
1476
+ const childNodes = elm.childNodes;
1477
+ let childNode;
1478
+ let i;
1479
+ let ilen;
1480
+ let j;
1481
+ let slotNameAttr;
1482
+ let nodeType;
1483
+ for (i = 0, ilen = childNodes.length; i < ilen; i++) {
1484
+ childNode = childNodes[i];
1485
+ if (childNode.nodeType === 1 /* NODE_TYPE.ElementNode */) {
1486
+ if (childNode['s-sr']) {
1487
+ // this is a slot fallback node
1488
+ // get the slot name for this slot reference node
1489
+ slotNameAttr = childNode['s-sn'];
1490
+ // by default always show a fallback slot node
1491
+ // then hide it if there are other slots in the light dom
1492
+ childNode.hidden = false;
1493
+ for (j = 0; j < ilen; j++) {
1494
+ nodeType = childNodes[j].nodeType;
1495
+ if (childNodes[j]['s-hn'] !== childNode['s-hn'] || slotNameAttr !== '') {
1496
+ // this sibling node is from a different component OR is a named fallback slot node
1497
+ if (nodeType === 1 /* NODE_TYPE.ElementNode */ && slotNameAttr === childNodes[j].getAttribute('slot')) {
1498
+ childNode.hidden = true;
1499
+ break;
1500
+ }
1501
+ }
1502
+ else {
1503
+ // this is a default fallback slot node
1504
+ // any element or text node (with content)
1505
+ // should hide the default fallback slot node
1506
+ if (nodeType === 1 /* NODE_TYPE.ElementNode */ ||
1507
+ (nodeType === 3 /* NODE_TYPE.TextNode */ && childNodes[j].textContent.trim() !== '')) {
1508
+ childNode.hidden = true;
1509
+ break;
1510
+ }
1511
+ }
1512
+ }
1513
+ }
1514
+ // keep drilling down
1515
+ updateFallbackSlotVisibility(childNode);
1516
+ }
1517
+ }
1518
+ };
1519
+ const relocateNodes = [];
1520
+ const relocateSlotContent = (elm) => {
1521
+ // tslint:disable-next-line: prefer-const
1522
+ let childNode;
1523
+ let node;
1524
+ let hostContentNodes;
1525
+ let slotNameAttr;
1526
+ let relocateNodeData;
1527
+ let j;
1528
+ let i = 0;
1529
+ const childNodes = elm.childNodes;
1530
+ const ilen = childNodes.length;
1531
+ for (; i < ilen; i++) {
1532
+ childNode = childNodes[i];
1533
+ if (childNode['s-sr'] && (node = childNode['s-cr']) && node.parentNode) {
1534
+ // first got the content reference comment node
1535
+ // then we got it's parent, which is where all the host content is in now
1536
+ hostContentNodes = node.parentNode.childNodes;
1537
+ slotNameAttr = childNode['s-sn'];
1538
+ for (j = hostContentNodes.length - 1; j >= 0; j--) {
1539
+ node = hostContentNodes[j];
1540
+ if (!node['s-cn'] && !node['s-nr'] && node['s-hn'] !== childNode['s-hn']) {
1541
+ // let's do some relocating to its new home
1542
+ // but never relocate a content reference node
1543
+ // that is suppose to always represent the original content location
1544
+ if (isNodeLocatedInSlot(node, slotNameAttr)) {
1545
+ // it's possible we've already decided to relocate this node
1546
+ relocateNodeData = relocateNodes.find((r) => r.$nodeToRelocate$ === node);
1547
+ // made some changes to slots
1548
+ // let's make sure we also double check
1549
+ // fallbacks are correctly hidden or shown
1550
+ checkSlotFallbackVisibility = true;
1551
+ node['s-sn'] = node['s-sn'] || slotNameAttr;
1552
+ if (relocateNodeData) {
1553
+ // previously we never found a slot home for this node
1554
+ // but turns out we did, so let's remember it now
1555
+ relocateNodeData.$slotRefNode$ = childNode;
1556
+ }
1557
+ else {
1558
+ // add to our list of nodes to relocate
1559
+ relocateNodes.push({
1560
+ $slotRefNode$: childNode,
1561
+ $nodeToRelocate$: node,
1562
+ });
1563
+ }
1564
+ if (node['s-sr']) {
1565
+ relocateNodes.map((relocateNode) => {
1566
+ if (isNodeLocatedInSlot(relocateNode.$nodeToRelocate$, node['s-sn'])) {
1567
+ relocateNodeData = relocateNodes.find((r) => r.$nodeToRelocate$ === node);
1568
+ if (relocateNodeData && !relocateNode.$slotRefNode$) {
1569
+ relocateNode.$slotRefNode$ = relocateNodeData.$slotRefNode$;
1570
+ }
1571
+ }
1572
+ });
1573
+ }
1574
+ }
1575
+ else if (!relocateNodes.some((r) => r.$nodeToRelocate$ === node)) {
1576
+ // so far this element does not have a slot home, not setting slotRefNode on purpose
1577
+ // if we never find a home for this element then we'll need to hide it
1578
+ relocateNodes.push({
1579
+ $nodeToRelocate$: node,
1580
+ });
1581
+ }
1582
+ }
1583
+ }
1584
+ }
1585
+ if (childNode.nodeType === 1 /* NODE_TYPE.ElementNode */) {
1586
+ relocateSlotContent(childNode);
1587
+ }
1588
+ }
1589
+ };
1590
+ const isNodeLocatedInSlot = (nodeToRelocate, slotNameAttr) => {
1591
+ if (nodeToRelocate.nodeType === 1 /* NODE_TYPE.ElementNode */) {
1592
+ if (nodeToRelocate.getAttribute('slot') === null && slotNameAttr === '') {
1593
+ return true;
1594
+ }
1595
+ if (nodeToRelocate.getAttribute('slot') === slotNameAttr) {
1596
+ return true;
1597
+ }
1598
+ return false;
1599
+ }
1600
+ if (nodeToRelocate['s-sn'] === slotNameAttr) {
1601
+ return true;
1602
+ }
1603
+ return slotNameAttr === '';
1604
+ };
1605
+ const callNodeRefs = (vNode) => {
1606
+ if (BUILD.vdomRef) {
1607
+ vNode.$attrs$ && vNode.$attrs$.ref && vNode.$attrs$.ref(null);
1608
+ vNode.$children$ && vNode.$children$.map(callNodeRefs);
1609
+ }
1610
+ };
1611
+ /**
1612
+ * The main entry point for Stencil's virtual DOM-based rendering engine
1613
+ *
1614
+ * Given a {@link d.HostRef} container and some virtual DOM nodes, this
1615
+ * function will handle creating a virtual DOM tree with a single root, patching
1616
+ * the current virtual DOM tree onto an old one (if any), dealing with slot
1617
+ * relocation, and reflecting attributes.
1618
+ *
1619
+ * @param hostRef data needed to root and render the virtual DOM tree, such as
1620
+ * the DOM node into which it should be rendered.
1621
+ * @param renderFnResults the virtual DOM nodes to be rendered
1622
+ */
1623
+ const renderVdom = (hostRef, renderFnResults) => {
1624
+ const hostElm = hostRef.$hostElement$;
1625
+ const cmpMeta = hostRef.$cmpMeta$;
1626
+ const oldVNode = hostRef.$vnode$ || newVNode(null, null);
1627
+ const rootVnode = isHost(renderFnResults) ? renderFnResults : h(null, null, renderFnResults);
1628
+ hostTagName = hostElm.tagName;
1629
+ // <Host> runtime check
1630
+ if (BUILD.isDev && Array.isArray(renderFnResults) && renderFnResults.some(isHost)) {
1631
+ throw new Error(`The <Host> must be the single root component.
1632
+ Looks like the render() function of "${hostTagName.toLowerCase()}" is returning an array that contains the <Host>.
1633
+
1634
+ The render() function should look like this instead:
1635
+
1636
+ render() {
1637
+ // Do not return an array
1638
+ return (
1639
+ <Host>{content}</Host>
1640
+ );
1641
+ }
1642
+ `);
1643
+ }
1644
+ if (BUILD.reflect && cmpMeta.$attrsToReflect$) {
1645
+ rootVnode.$attrs$ = rootVnode.$attrs$ || {};
1646
+ cmpMeta.$attrsToReflect$.map(([propName, attribute]) => (rootVnode.$attrs$[attribute] = hostElm[propName]));
1647
+ }
1648
+ rootVnode.$tag$ = null;
1649
+ rootVnode.$flags$ |= 4 /* VNODE_FLAGS.isHost */;
1650
+ hostRef.$vnode$ = rootVnode;
1651
+ rootVnode.$elm$ = oldVNode.$elm$ = (BUILD.shadowDom ? hostElm.shadowRoot || hostElm : hostElm);
1652
+ if (BUILD.scoped || BUILD.shadowDom) {
1653
+ scopeId = hostElm['s-sc'];
1654
+ }
1655
+ if (BUILD.slotRelocation) {
1656
+ contentRef = hostElm['s-cr'];
1657
+ useNativeShadowDom = supportsShadow && (cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) !== 0;
1658
+ // always reset
1659
+ checkSlotFallbackVisibility = false;
1660
+ }
1661
+ // synchronous patch
1662
+ patch(oldVNode, rootVnode);
1663
+ if (BUILD.slotRelocation) {
1664
+ // while we're moving nodes around existing nodes, temporarily disable
1665
+ // the disconnectCallback from working
1666
+ plt.$flags$ |= 1 /* PLATFORM_FLAGS.isTmpDisconnected */;
1667
+ if (checkSlotRelocate) {
1668
+ relocateSlotContent(rootVnode.$elm$);
1669
+ let relocateData;
1670
+ let nodeToRelocate;
1671
+ let orgLocationNode;
1672
+ let parentNodeRef;
1673
+ let insertBeforeNode;
1674
+ let refNode;
1675
+ let i = 0;
1676
+ for (; i < relocateNodes.length; i++) {
1677
+ relocateData = relocateNodes[i];
1678
+ nodeToRelocate = relocateData.$nodeToRelocate$;
1679
+ if (!nodeToRelocate['s-ol']) {
1680
+ // add a reference node marking this node's original location
1681
+ // keep a reference to this node for later lookups
1682
+ orgLocationNode =
1683
+ BUILD.isDebug || BUILD.hydrateServerSide
1684
+ ? originalLocationDebugNode(nodeToRelocate)
1685
+ : doc.createTextNode('');
1686
+ orgLocationNode['s-nr'] = nodeToRelocate;
1687
+ nodeToRelocate.parentNode.insertBefore((nodeToRelocate['s-ol'] = orgLocationNode), nodeToRelocate);
1688
+ }
1689
+ }
1690
+ for (i = 0; i < relocateNodes.length; i++) {
1691
+ relocateData = relocateNodes[i];
1692
+ nodeToRelocate = relocateData.$nodeToRelocate$;
1693
+ if (relocateData.$slotRefNode$) {
1694
+ // by default we're just going to insert it directly
1695
+ // after the slot reference node
1696
+ parentNodeRef = relocateData.$slotRefNode$.parentNode;
1697
+ insertBeforeNode = relocateData.$slotRefNode$.nextSibling;
1698
+ orgLocationNode = nodeToRelocate['s-ol'];
1699
+ while ((orgLocationNode = orgLocationNode.previousSibling)) {
1700
+ refNode = orgLocationNode['s-nr'];
1701
+ if (refNode && refNode['s-sn'] === nodeToRelocate['s-sn'] && parentNodeRef === refNode.parentNode) {
1702
+ refNode = refNode.nextSibling;
1703
+ if (!refNode || !refNode['s-nr']) {
1704
+ insertBeforeNode = refNode;
1705
+ break;
1706
+ }
1707
+ }
1708
+ }
1709
+ if ((!insertBeforeNode && parentNodeRef !== nodeToRelocate.parentNode) ||
1710
+ nodeToRelocate.nextSibling !== insertBeforeNode) {
1711
+ // we've checked that it's worth while to relocate
1712
+ // since that the node to relocate
1713
+ // has a different next sibling or parent relocated
1714
+ if (nodeToRelocate !== insertBeforeNode) {
1715
+ if (!nodeToRelocate['s-hn'] && nodeToRelocate['s-ol']) {
1716
+ // probably a component in the index.html that doesn't have it's hostname set
1717
+ nodeToRelocate['s-hn'] = nodeToRelocate['s-ol'].parentNode.nodeName;
1718
+ }
1719
+ // add it back to the dom but in its new home
1720
+ parentNodeRef.insertBefore(nodeToRelocate, insertBeforeNode);
1721
+ }
1722
+ }
1723
+ }
1724
+ else {
1725
+ // this node doesn't have a slot home to go to, so let's hide it
1726
+ if (nodeToRelocate.nodeType === 1 /* NODE_TYPE.ElementNode */) {
1727
+ nodeToRelocate.hidden = true;
1728
+ }
1729
+ }
1730
+ }
1731
+ }
1732
+ if (checkSlotFallbackVisibility) {
1733
+ updateFallbackSlotVisibility(rootVnode.$elm$);
1734
+ }
1735
+ // done moving nodes around
1736
+ // allow the disconnect callback to work again
1737
+ plt.$flags$ &= ~1 /* PLATFORM_FLAGS.isTmpDisconnected */;
1738
+ // always reset
1739
+ relocateNodes.length = 0;
1740
+ }
1741
+ };
1742
+ // slot comment debug nodes only created with the `--debug` flag
1743
+ // otherwise these nodes are text nodes w/out content
1744
+ const slotReferenceDebugNode = (slotVNode) => doc.createComment(`<slot${slotVNode.$name$ ? ' name="' + slotVNode.$name$ + '"' : ''}> (host=${hostTagName.toLowerCase()})`);
1745
+ const originalLocationDebugNode = (nodeToRelocate) => doc.createComment(`org-location for ` +
1746
+ (nodeToRelocate.localName
1747
+ ? `<${nodeToRelocate.localName}> (host=${nodeToRelocate['s-hn']})`
1748
+ : `[${nodeToRelocate.textContent}]`));
1749
+ const attachToAncestor = (hostRef, ancestorComponent) => {
1750
+ if (BUILD.asyncLoading && ancestorComponent && !hostRef.$onRenderResolve$ && ancestorComponent['s-p']) {
1751
+ ancestorComponent['s-p'].push(new Promise((r) => (hostRef.$onRenderResolve$ = r)));
1752
+ }
1753
+ };
1754
+ const scheduleUpdate = (hostRef, isInitialLoad) => {
1755
+ if (BUILD.taskQueue && BUILD.updatable) {
1756
+ hostRef.$flags$ |= 16 /* HOST_FLAGS.isQueuedForUpdate */;
1757
+ }
1758
+ if (BUILD.asyncLoading && hostRef.$flags$ & 4 /* HOST_FLAGS.isWaitingForChildren */) {
1759
+ hostRef.$flags$ |= 512 /* HOST_FLAGS.needsRerender */;
1760
+ return;
1761
+ }
1762
+ attachToAncestor(hostRef, hostRef.$ancestorComponent$);
1763
+ // there is no ancestor component or the ancestor component
1764
+ // has already fired off its lifecycle update then
1765
+ // fire off the initial update
1766
+ const dispatch = () => dispatchHooks(hostRef, isInitialLoad);
1767
+ return BUILD.taskQueue ? writeTask(dispatch) : dispatch();
1768
+ };
1769
+ const dispatchHooks = (hostRef, isInitialLoad) => {
1770
+ const elm = hostRef.$hostElement$;
1771
+ const endSchedule = createTime('scheduleUpdate', hostRef.$cmpMeta$.$tagName$);
1772
+ const instance = BUILD.lazyLoad ? hostRef.$lazyInstance$ : elm;
1773
+ let promise;
1774
+ if (isInitialLoad) {
1775
+ if (BUILD.lazyLoad && BUILD.hostListener) {
1776
+ hostRef.$flags$ |= 256 /* HOST_FLAGS.isListenReady */;
1777
+ if (hostRef.$queuedListeners$) {
1778
+ hostRef.$queuedListeners$.map(([methodName, event]) => safeCall(instance, methodName, event));
1779
+ hostRef.$queuedListeners$ = null;
1780
+ }
1781
+ }
1782
+ emitLifecycleEvent(elm, 'componentWillLoad');
1783
+ if (BUILD.cmpWillLoad) {
1784
+ promise = safeCall(instance, 'componentWillLoad');
1785
+ }
1786
+ }
1787
+ else {
1788
+ emitLifecycleEvent(elm, 'componentWillUpdate');
1789
+ if (BUILD.cmpWillUpdate) {
1790
+ promise = safeCall(instance, 'componentWillUpdate');
1791
+ }
1792
+ }
1793
+ emitLifecycleEvent(elm, 'componentWillRender');
1794
+ if (BUILD.cmpWillRender) {
1795
+ promise = then(promise, () => safeCall(instance, 'componentWillRender'));
1796
+ }
1797
+ endSchedule();
1798
+ return then(promise, () => updateComponent(hostRef, instance, isInitialLoad));
1799
+ };
1800
+ const updateComponent = async (hostRef, instance, isInitialLoad) => {
1801
+ // updateComponent
1802
+ const elm = hostRef.$hostElement$;
1803
+ const endUpdate = createTime('update', hostRef.$cmpMeta$.$tagName$);
1804
+ const rc = elm['s-rc'];
1805
+ if (BUILD.style && isInitialLoad) {
1806
+ // DOM WRITE!
1807
+ attachStyles(hostRef);
1808
+ }
1809
+ const endRender = createTime('render', hostRef.$cmpMeta$.$tagName$);
1810
+ if (BUILD.isDev) {
1811
+ hostRef.$flags$ |= 1024 /* HOST_FLAGS.devOnRender */;
1812
+ }
1813
+ if (BUILD.hydrateServerSide) {
1814
+ await callRender(hostRef, instance, elm);
1815
+ }
1816
+ else {
1817
+ callRender(hostRef, instance, elm);
1818
+ }
1819
+ if (BUILD.cssVarShim && plt.$cssShim$) {
1820
+ plt.$cssShim$.updateHost(elm);
1821
+ }
1822
+ if (BUILD.isDev) {
1823
+ hostRef.$renderCount$++;
1824
+ hostRef.$flags$ &= ~1024 /* HOST_FLAGS.devOnRender */;
1825
+ }
1826
+ if (BUILD.hydrateServerSide) {
1827
+ try {
1828
+ // manually connected child components during server-side hydrate
1829
+ serverSideConnected(elm);
1830
+ if (isInitialLoad) {
1831
+ // using only during server-side hydrate
1832
+ if (hostRef.$cmpMeta$.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) {
1833
+ elm['s-en'] = '';
1834
+ }
1835
+ else if (hostRef.$cmpMeta$.$flags$ & 2 /* CMP_FLAGS.scopedCssEncapsulation */) {
1836
+ elm['s-en'] = 'c';
1837
+ }
1838
+ }
1839
+ }
1840
+ catch (e) {
1841
+ consoleError(e, elm);
1842
+ }
1843
+ }
1844
+ if (BUILD.asyncLoading && rc) {
1845
+ // ok, so turns out there are some child host elements
1846
+ // waiting on this parent element to load
1847
+ // let's fire off all update callbacks waiting
1848
+ rc.map((cb) => cb());
1849
+ elm['s-rc'] = undefined;
1850
+ }
1851
+ endRender();
1852
+ endUpdate();
1853
+ if (BUILD.asyncLoading) {
1854
+ const childrenPromises = elm['s-p'];
1855
+ const postUpdate = () => postUpdateComponent(hostRef);
1856
+ if (childrenPromises.length === 0) {
1857
+ postUpdate();
1858
+ }
1859
+ else {
1860
+ Promise.all(childrenPromises).then(postUpdate);
1861
+ hostRef.$flags$ |= 4 /* HOST_FLAGS.isWaitingForChildren */;
1862
+ childrenPromises.length = 0;
1863
+ }
1864
+ }
1865
+ else {
1866
+ postUpdateComponent(hostRef);
1867
+ }
1868
+ };
1869
+ const callRender = (hostRef, instance, elm) => {
1870
+ // in order for bundlers to correctly treeshake the BUILD object
1871
+ // we need to ensure BUILD is not deoptimized within a try/catch
1872
+ // https://rollupjs.org/guide/en/#treeshake tryCatchDeoptimization
1873
+ const allRenderFn = BUILD.allRenderFn ? true : false;
1874
+ const lazyLoad = BUILD.lazyLoad ? true : false;
1875
+ const taskQueue = BUILD.taskQueue ? true : false;
1876
+ const updatable = BUILD.updatable ? true : false;
1877
+ try {
1878
+ renderingRef = instance;
1879
+ instance = allRenderFn ? instance.render() : instance.render && instance.render();
1880
+ if (updatable && taskQueue) {
1881
+ hostRef.$flags$ &= ~16 /* HOST_FLAGS.isQueuedForUpdate */;
1882
+ }
1883
+ if (updatable || lazyLoad) {
1884
+ hostRef.$flags$ |= 2 /* HOST_FLAGS.hasRendered */;
1885
+ }
1886
+ if (BUILD.hasRenderFn || BUILD.reflect) {
1887
+ if (BUILD.vdomRender || BUILD.reflect) {
1888
+ // looks like we've got child nodes to render into this host element
1889
+ // or we need to update the css class/attrs on the host element
1890
+ // DOM WRITE!
1891
+ if (BUILD.hydrateServerSide) {
1892
+ return Promise.resolve(instance).then((value) => renderVdom(hostRef, value));
1893
+ }
1894
+ else {
1895
+ renderVdom(hostRef, instance);
1896
+ }
1897
+ }
1898
+ else {
1899
+ elm.textContent = instance;
1900
+ }
1901
+ }
1902
+ }
1903
+ catch (e) {
1904
+ consoleError(e, hostRef.$hostElement$);
1905
+ }
1906
+ renderingRef = null;
1907
+ return null;
1908
+ };
1909
+ const getRenderingRef = () => renderingRef;
1910
+ const postUpdateComponent = (hostRef) => {
1911
+ const tagName = hostRef.$cmpMeta$.$tagName$;
1912
+ const elm = hostRef.$hostElement$;
1913
+ const endPostUpdate = createTime('postUpdate', tagName);
1914
+ const instance = BUILD.lazyLoad ? hostRef.$lazyInstance$ : elm;
1915
+ const ancestorComponent = hostRef.$ancestorComponent$;
1916
+ if (BUILD.cmpDidRender) {
1917
+ if (BUILD.isDev) {
1918
+ hostRef.$flags$ |= 1024 /* HOST_FLAGS.devOnRender */;
1919
+ }
1920
+ safeCall(instance, 'componentDidRender');
1921
+ if (BUILD.isDev) {
1922
+ hostRef.$flags$ &= ~1024 /* HOST_FLAGS.devOnRender */;
1923
+ }
1924
+ }
1925
+ emitLifecycleEvent(elm, 'componentDidRender');
1926
+ if (!(hostRef.$flags$ & 64 /* HOST_FLAGS.hasLoadedComponent */)) {
1927
+ hostRef.$flags$ |= 64 /* HOST_FLAGS.hasLoadedComponent */;
1928
+ if (BUILD.asyncLoading && BUILD.cssAnnotations) {
1929
+ // DOM WRITE!
1930
+ addHydratedFlag(elm);
1931
+ }
1932
+ if (BUILD.cmpDidLoad) {
1933
+ if (BUILD.isDev) {
1934
+ hostRef.$flags$ |= 2048 /* HOST_FLAGS.devOnDidLoad */;
1935
+ }
1936
+ safeCall(instance, 'componentDidLoad');
1937
+ if (BUILD.isDev) {
1938
+ hostRef.$flags$ &= ~2048 /* HOST_FLAGS.devOnDidLoad */;
1939
+ }
1940
+ }
1941
+ emitLifecycleEvent(elm, 'componentDidLoad');
1942
+ endPostUpdate();
1943
+ if (BUILD.asyncLoading) {
1944
+ hostRef.$onReadyResolve$(elm);
1945
+ if (!ancestorComponent) {
1946
+ appDidLoad(tagName);
1947
+ }
1948
+ }
1949
+ }
1950
+ else {
1951
+ if (BUILD.cmpDidUpdate) {
1952
+ // we've already loaded this component
1953
+ // fire off the user's componentDidUpdate method (if one was provided)
1954
+ // componentDidUpdate runs AFTER render() has been called
1955
+ // and all child components have finished updating
1956
+ if (BUILD.isDev) {
1957
+ hostRef.$flags$ |= 1024 /* HOST_FLAGS.devOnRender */;
1958
+ }
1959
+ safeCall(instance, 'componentDidUpdate');
1960
+ if (BUILD.isDev) {
1961
+ hostRef.$flags$ &= ~1024 /* HOST_FLAGS.devOnRender */;
1962
+ }
1963
+ }
1964
+ emitLifecycleEvent(elm, 'componentDidUpdate');
1965
+ endPostUpdate();
1966
+ }
1967
+ if (BUILD.hotModuleReplacement) {
1968
+ elm['s-hmr-load'] && elm['s-hmr-load']();
1969
+ }
1970
+ if (BUILD.method && BUILD.lazyLoad) {
1971
+ hostRef.$onInstanceResolve$(elm);
1972
+ }
1973
+ // load events fire from bottom to top
1974
+ // the deepest elements load first then bubbles up
1975
+ if (BUILD.asyncLoading) {
1976
+ if (hostRef.$onRenderResolve$) {
1977
+ hostRef.$onRenderResolve$();
1978
+ hostRef.$onRenderResolve$ = undefined;
1979
+ }
1980
+ if (hostRef.$flags$ & 512 /* HOST_FLAGS.needsRerender */) {
1981
+ nextTick(() => scheduleUpdate(hostRef, false));
1982
+ }
1983
+ hostRef.$flags$ &= ~(4 /* HOST_FLAGS.isWaitingForChildren */ | 512 /* HOST_FLAGS.needsRerender */);
1984
+ }
1985
+ // ( •_•)
1986
+ // ( •_•)>⌐■-■
1987
+ // (⌐■_■)
1988
+ };
1989
+ const forceUpdate = (ref) => {
1990
+ if (BUILD.updatable) {
1991
+ const hostRef = getHostRef(ref);
1992
+ const isConnected = hostRef.$hostElement$.isConnected;
1993
+ if (isConnected &&
1994
+ (hostRef.$flags$ & (2 /* HOST_FLAGS.hasRendered */ | 16 /* HOST_FLAGS.isQueuedForUpdate */)) === 2 /* HOST_FLAGS.hasRendered */) {
1995
+ scheduleUpdate(hostRef, false);
1996
+ }
1997
+ // Returns "true" when the forced update was successfully scheduled
1998
+ return isConnected;
1999
+ }
2000
+ return false;
2001
+ };
2002
+ const appDidLoad = (who) => {
2003
+ // on appload
2004
+ // we have finish the first big initial render
2005
+ if (BUILD.cssAnnotations) {
2006
+ addHydratedFlag(doc.documentElement);
2007
+ }
2008
+ if (BUILD.asyncQueue) {
2009
+ plt.$flags$ |= 2 /* PLATFORM_FLAGS.appLoaded */;
2010
+ }
2011
+ nextTick(() => emitEvent(win, 'appload', { detail: { namespace: NAMESPACE } }));
2012
+ if (BUILD.profile && performance.measure) {
2013
+ performance.measure(`[Stencil] ${NAMESPACE} initial load (by ${who})`, 'st:app:start');
2014
+ }
2015
+ };
2016
+ const safeCall = (instance, method, arg) => {
2017
+ if (instance && instance[method]) {
2018
+ try {
2019
+ return instance[method](arg);
2020
+ }
2021
+ catch (e) {
2022
+ consoleError(e);
2023
+ }
2024
+ }
2025
+ return undefined;
2026
+ };
2027
+ const then = (promise, thenFn) => {
2028
+ return promise && promise.then ? promise.then(thenFn) : thenFn();
2029
+ };
2030
+ const emitLifecycleEvent = (elm, lifecycleName) => {
2031
+ if (BUILD.lifecycleDOMEvents) {
2032
+ emitEvent(elm, 'stencil_' + lifecycleName, {
2033
+ bubbles: true,
2034
+ composed: true,
2035
+ detail: {
2036
+ namespace: NAMESPACE,
2037
+ },
2038
+ });
2039
+ }
2040
+ };
2041
+ const addHydratedFlag = (elm) => BUILD.hydratedClass
2042
+ ? elm.classList.add('hydrated')
2043
+ : BUILD.hydratedAttribute
2044
+ ? elm.setAttribute('hydrated', '')
2045
+ : undefined;
2046
+ const serverSideConnected = (elm) => {
2047
+ const children = elm.children;
2048
+ if (children != null) {
2049
+ for (let i = 0, ii = children.length; i < ii; i++) {
2050
+ const childElm = children[i];
2051
+ if (typeof childElm.connectedCallback === 'function') {
2052
+ childElm.connectedCallback();
2053
+ }
2054
+ serverSideConnected(childElm);
2055
+ }
2056
+ }
2057
+ };
2058
+ const getValue = (ref, propName) => getHostRef(ref).$instanceValues$.get(propName);
2059
+ const setValue = (ref, propName, newVal, cmpMeta) => {
2060
+ // check our new property value against our internal value
2061
+ const hostRef = getHostRef(ref);
2062
+ const elm = BUILD.lazyLoad ? hostRef.$hostElement$ : ref;
2063
+ const oldVal = hostRef.$instanceValues$.get(propName);
2064
+ const flags = hostRef.$flags$;
2065
+ const instance = BUILD.lazyLoad ? hostRef.$lazyInstance$ : elm;
2066
+ newVal = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]);
2067
+ // explicitly check for NaN on both sides, as `NaN === NaN` is always false
2068
+ const areBothNaN = Number.isNaN(oldVal) && Number.isNaN(newVal);
2069
+ const didValueChange = newVal !== oldVal && !areBothNaN;
2070
+ if ((!BUILD.lazyLoad || !(flags & 8 /* HOST_FLAGS.isConstructingInstance */) || oldVal === undefined) && didValueChange) {
2071
+ // gadzooks! the property's value has changed!!
2072
+ // set our new value!
2073
+ hostRef.$instanceValues$.set(propName, newVal);
2074
+ if (BUILD.isDev) {
2075
+ if (hostRef.$flags$ & 1024 /* HOST_FLAGS.devOnRender */) {
2076
+ consoleDevWarn(`The state/prop "${propName}" changed during rendering. This can potentially lead to infinite-loops and other bugs.`, '\nElement', elm, '\nNew value', newVal, '\nOld value', oldVal);
2077
+ }
2078
+ else if (hostRef.$flags$ & 2048 /* HOST_FLAGS.devOnDidLoad */) {
2079
+ consoleDevWarn(`The state/prop "${propName}" changed during "componentDidLoad()", this triggers extra re-renders, try to setup on "componentWillLoad()"`, '\nElement', elm, '\nNew value', newVal, '\nOld value', oldVal);
2080
+ }
2081
+ }
2082
+ if (!BUILD.lazyLoad || instance) {
2083
+ // get an array of method names of watch functions to call
2084
+ if (BUILD.watchCallback && cmpMeta.$watchers$ && flags & 128 /* HOST_FLAGS.isWatchReady */) {
2085
+ const watchMethods = cmpMeta.$watchers$[propName];
2086
+ if (watchMethods) {
2087
+ // this instance is watching for when this property changed
2088
+ watchMethods.map((watchMethodName) => {
2089
+ try {
2090
+ // fire off each of the watch methods that are watching this property
2091
+ instance[watchMethodName](newVal, oldVal, propName);
2092
+ }
2093
+ catch (e) {
2094
+ consoleError(e, elm);
2095
+ }
2096
+ });
2097
+ }
2098
+ }
2099
+ if (BUILD.updatable &&
2100
+ (flags & (2 /* HOST_FLAGS.hasRendered */ | 16 /* HOST_FLAGS.isQueuedForUpdate */)) === 2 /* HOST_FLAGS.hasRendered */) {
2101
+ if (BUILD.cmpShouldUpdate && instance.componentShouldUpdate) {
2102
+ if (instance.componentShouldUpdate(newVal, oldVal, propName) === false) {
2103
+ return;
2104
+ }
2105
+ }
2106
+ // looks like this value actually changed, so we've got work to do!
2107
+ // but only if we've already rendered, otherwise just chill out
2108
+ // queue that we need to do an update, but don't worry about queuing
2109
+ // up millions cuz this function ensures it only runs once
2110
+ scheduleUpdate(hostRef, false);
2111
+ }
2112
+ }
2113
+ }
2114
+ };
2115
+ /**
2116
+ * Attach a series of runtime constructs to a compiled Stencil component
2117
+ * constructor, including getters and setters for the `@Prop` and `@State`
2118
+ * decorators, callbacks for when attributes change, and so on.
2119
+ *
2120
+ * @param Cstr the constructor for a component that we need to process
2121
+ * @param cmpMeta metadata collected previously about the component
2122
+ * @param flags a number used to store a series of bit flags
2123
+ * @returns a reference to the same constructor passed in (but now mutated)
2124
+ */
2125
+ const proxyComponent = (Cstr, cmpMeta, flags) => {
2126
+ if (BUILD.member && cmpMeta.$members$) {
2127
+ if (BUILD.watchCallback && Cstr.watchers) {
2128
+ cmpMeta.$watchers$ = Cstr.watchers;
2129
+ }
2130
+ // It's better to have a const than two Object.entries()
2131
+ const members = Object.entries(cmpMeta.$members$);
2132
+ const prototype = Cstr.prototype;
2133
+ members.map(([memberName, [memberFlags]]) => {
2134
+ if ((BUILD.prop || BUILD.state) &&
2135
+ (memberFlags & 31 /* MEMBER_FLAGS.Prop */ ||
2136
+ ((!BUILD.lazyLoad || flags & 2 /* PROXY_FLAGS.proxyState */) && memberFlags & 32 /* MEMBER_FLAGS.State */))) {
2137
+ // proxyComponent - prop
2138
+ Object.defineProperty(prototype, memberName, {
2139
+ get() {
2140
+ // proxyComponent, get value
2141
+ return getValue(this, memberName);
2142
+ },
2143
+ set(newValue) {
2144
+ // only during dev time
2145
+ if (BUILD.isDev) {
2146
+ const ref = getHostRef(this);
2147
+ if (
2148
+ // we are proxying the instance (not element)
2149
+ (flags & 1 /* PROXY_FLAGS.isElementConstructor */) === 0 &&
2150
+ // the element is not constructing
2151
+ (ref.$flags$ & 8 /* HOST_FLAGS.isConstructingInstance */) === 0 &&
2152
+ // the member is a prop
2153
+ (memberFlags & 31 /* MEMBER_FLAGS.Prop */) !== 0 &&
2154
+ // the member is not mutable
2155
+ (memberFlags & 1024 /* MEMBER_FLAGS.Mutable */) === 0) {
2156
+ consoleDevWarn(`@Prop() "${memberName}" on <${cmpMeta.$tagName$}> is immutable but was modified from within the component.\nMore information: https://stenciljs.com/docs/properties#prop-mutability`);
2157
+ }
2158
+ }
2159
+ // proxyComponent, set value
2160
+ setValue(this, memberName, newValue, cmpMeta);
2161
+ },
2162
+ configurable: true,
2163
+ enumerable: true,
2164
+ });
2165
+ }
2166
+ else if (BUILD.lazyLoad &&
2167
+ BUILD.method &&
2168
+ flags & 1 /* PROXY_FLAGS.isElementConstructor */ &&
2169
+ memberFlags & 64 /* MEMBER_FLAGS.Method */) {
2170
+ // proxyComponent - method
2171
+ Object.defineProperty(prototype, memberName, {
2172
+ value(...args) {
2173
+ const ref = getHostRef(this);
2174
+ return ref.$onInstancePromise$.then(() => ref.$lazyInstance$[memberName](...args));
2175
+ },
2176
+ });
2177
+ }
2178
+ });
2179
+ if (BUILD.observeAttribute && (!BUILD.lazyLoad || flags & 1 /* PROXY_FLAGS.isElementConstructor */)) {
2180
+ const attrNameToPropName = new Map();
2181
+ prototype.attributeChangedCallback = function (attrName, _oldValue, newValue) {
2182
+ plt.jmp(() => {
2183
+ const propName = attrNameToPropName.get(attrName);
2184
+ // In a web component lifecycle the attributeChangedCallback runs prior to connectedCallback
2185
+ // in the case where an attribute was set inline.
2186
+ // ```html
2187
+ // <my-component some-attribute="some-value"></my-component>
2188
+ // ```
2189
+ //
2190
+ // There is an edge case where a developer sets the attribute inline on a custom element and then
2191
+ // programmatically changes it before it has been upgraded as shown below:
2192
+ //
2193
+ // ```html
2194
+ // <!-- this component has _not_ been upgraded yet -->
2195
+ // <my-component id="test" some-attribute="some-value"></my-component>
2196
+ // <script>
2197
+ // // grab non-upgraded component
2198
+ // el = document.querySelector("#test");
2199
+ // el.someAttribute = "another-value";
2200
+ // // upgrade component
2201
+ // customElements.define('my-component', MyComponent);
2202
+ // </script>
2203
+ // ```
2204
+ // In this case if we do not unshadow here and use the value of the shadowing property, attributeChangedCallback
2205
+ // will be called with `newValue = "some-value"` and will set the shadowed property (this.someAttribute = "another-value")
2206
+ // to the value that was set inline i.e. "some-value" from above example. When
2207
+ // the connectedCallback attempts to unshadow it will use "some-value" as the initial value rather than "another-value"
2208
+ //
2209
+ // The case where the attribute was NOT set inline but was not set programmatically shall be handled/unshadowed
2210
+ // by connectedCallback as this attributeChangedCallback will not fire.
2211
+ //
2212
+ // https://developers.google.com/web/fundamentals/web-components/best-practices#lazy-properties
2213
+ //
2214
+ // TODO(STENCIL-16) we should think about whether or not we actually want to be reflecting the attributes to
2215
+ // properties here given that this goes against best practices outlined here
2216
+ // https://developers.google.com/web/fundamentals/web-components/best-practices#avoid-reentrancy
2217
+ if (this.hasOwnProperty(propName)) {
2218
+ newValue = this[propName];
2219
+ delete this[propName];
2220
+ }
2221
+ else if (prototype.hasOwnProperty(propName) &&
2222
+ typeof this[propName] === 'number' &&
2223
+ this[propName] == newValue) {
2224
+ // if the propName exists on the prototype of `Cstr`, this update may be a result of Stencil using native
2225
+ // APIs to reflect props as attributes. Calls to `setAttribute(someElement, propName)` will result in
2226
+ // `propName` to be converted to a `DOMString`, which may not be what we want for other primitive props.
2227
+ return;
2228
+ }
2229
+ this[propName] = newValue === null && typeof this[propName] === 'boolean' ? false : newValue;
2230
+ });
2231
+ };
2232
+ // create an array of attributes to observe
2233
+ // and also create a map of html attribute name to js property name
2234
+ Cstr.observedAttributes = members
2235
+ .filter(([_, m]) => m[0] & 15 /* MEMBER_FLAGS.HasAttribute */) // filter to only keep props that should match attributes
2236
+ .map(([propName, m]) => {
2237
+ const attrName = m[1] || propName;
2238
+ attrNameToPropName.set(attrName, propName);
2239
+ if (BUILD.reflect && m[0] & 512 /* MEMBER_FLAGS.ReflectAttr */) {
2240
+ cmpMeta.$attrsToReflect$.push([propName, attrName]);
2241
+ }
2242
+ return attrName;
2243
+ });
2244
+ }
2245
+ }
2246
+ return Cstr;
2247
+ };
2248
+ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) => {
2249
+ // initializeComponent
2250
+ if ((BUILD.lazyLoad || BUILD.hydrateServerSide || BUILD.style) &&
2251
+ (hostRef.$flags$ & 32 /* HOST_FLAGS.hasInitializedComponent */) === 0) {
2252
+ if (BUILD.lazyLoad || BUILD.hydrateClientSide) {
2253
+ // we haven't initialized this element yet
2254
+ hostRef.$flags$ |= 32 /* HOST_FLAGS.hasInitializedComponent */;
2255
+ // lazy loaded components
2256
+ // request the component's implementation to be
2257
+ // wired up with the host element
2258
+ Cstr = loadModule(cmpMeta, hostRef, hmrVersionId);
2259
+ if (Cstr.then) {
2260
+ // Await creates a micro-task avoid if possible
2261
+ const endLoad = uniqueTime(`st:load:${cmpMeta.$tagName$}:${hostRef.$modeName$}`, `[Stencil] Load module for <${cmpMeta.$tagName$}>`);
2262
+ Cstr = await Cstr;
2263
+ endLoad();
2264
+ }
2265
+ if ((BUILD.isDev || BUILD.isDebug) && !Cstr) {
2266
+ throw new Error(`Constructor for "${cmpMeta.$tagName$}#${hostRef.$modeName$}" was not found`);
2267
+ }
2268
+ if (BUILD.member && !Cstr.isProxied) {
2269
+ // we've never proxied this Constructor before
2270
+ // let's add the getters/setters to its prototype before
2271
+ // the first time we create an instance of the implementation
2272
+ if (BUILD.watchCallback) {
2273
+ cmpMeta.$watchers$ = Cstr.watchers;
2274
+ }
2275
+ proxyComponent(Cstr, cmpMeta, 2 /* PROXY_FLAGS.proxyState */);
2276
+ Cstr.isProxied = true;
2277
+ }
2278
+ const endNewInstance = createTime('createInstance', cmpMeta.$tagName$);
2279
+ // ok, time to construct the instance
2280
+ // but let's keep track of when we start and stop
2281
+ // so that the getters/setters don't incorrectly step on data
2282
+ if (BUILD.member) {
2283
+ hostRef.$flags$ |= 8 /* HOST_FLAGS.isConstructingInstance */;
2284
+ }
2285
+ // construct the lazy-loaded component implementation
2286
+ // passing the hostRef is very important during
2287
+ // construction in order to directly wire together the
2288
+ // host element and the lazy-loaded instance
2289
+ try {
2290
+ new Cstr(hostRef);
2291
+ }
2292
+ catch (e) {
2293
+ consoleError(e);
2294
+ }
2295
+ if (BUILD.member) {
2296
+ hostRef.$flags$ &= ~8 /* HOST_FLAGS.isConstructingInstance */;
2297
+ }
2298
+ if (BUILD.watchCallback) {
2299
+ hostRef.$flags$ |= 128 /* HOST_FLAGS.isWatchReady */;
2300
+ }
2301
+ endNewInstance();
2302
+ fireConnectedCallback(hostRef.$lazyInstance$);
2303
+ }
2304
+ else {
2305
+ // sync constructor component
2306
+ Cstr = elm.constructor;
2307
+ hostRef.$flags$ |= 32 /* HOST_FLAGS.hasInitializedComponent */;
2308
+ // wait for the CustomElementRegistry to mark the component as ready before setting `isWatchReady`. Otherwise,
2309
+ // watchers may fire prematurely if `customElements.get()`/`customElements.whenDefined()` resolves _before_
2310
+ // Stencil has completed instantiating the component.
2311
+ customElements.whenDefined(cmpMeta.$tagName$).then(() => (hostRef.$flags$ |= 128 /* HOST_FLAGS.isWatchReady */));
2312
+ }
2313
+ if (BUILD.style && Cstr.style) {
2314
+ // this component has styles but we haven't registered them yet
2315
+ let style = Cstr.style;
2316
+ if (BUILD.mode && typeof style !== 'string') {
2317
+ style = style[(hostRef.$modeName$ = computeMode(elm))];
2318
+ if (BUILD.hydrateServerSide && hostRef.$modeName$) {
2319
+ elm.setAttribute('s-mode', hostRef.$modeName$);
2320
+ }
2321
+ }
2322
+ const scopeId = getScopeId(cmpMeta, hostRef.$modeName$);
2323
+ if (!styles.has(scopeId)) {
2324
+ const endRegisterStyles = createTime('registerStyles', cmpMeta.$tagName$);
2325
+ if (!BUILD.hydrateServerSide &&
2326
+ BUILD.shadowDom &&
2327
+ BUILD.shadowDomShim &&
2328
+ cmpMeta.$flags$ & 8 /* CMP_FLAGS.needsShadowDomShim */) {
2329
+ style = await import('./shadow-css-98135883.js').then((m) => m.scopeCss(style, scopeId, false));
2330
+ }
2331
+ registerStyle(scopeId, style, !!(cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */));
2332
+ endRegisterStyles();
2333
+ }
2334
+ }
2335
+ }
2336
+ // we've successfully created a lazy instance
2337
+ const ancestorComponent = hostRef.$ancestorComponent$;
2338
+ const schedule = () => scheduleUpdate(hostRef, true);
2339
+ if (BUILD.asyncLoading && ancestorComponent && ancestorComponent['s-rc']) {
2340
+ // this is the initial load and this component it has an ancestor component
2341
+ // but the ancestor component has NOT fired its will update lifecycle yet
2342
+ // so let's just cool our jets and wait for the ancestor to continue first
2343
+ // this will get fired off when the ancestor component
2344
+ // finally gets around to rendering its lazy self
2345
+ // fire off the initial update
2346
+ ancestorComponent['s-rc'].push(schedule);
2347
+ }
2348
+ else {
2349
+ schedule();
2350
+ }
2351
+ };
2352
+ const fireConnectedCallback = (instance) => {
2353
+ if (BUILD.lazyLoad && BUILD.connectedCallback) {
2354
+ safeCall(instance, 'connectedCallback');
2355
+ }
2356
+ };
2357
+ const connectedCallback = (elm) => {
2358
+ if ((plt.$flags$ & 1 /* PLATFORM_FLAGS.isTmpDisconnected */) === 0) {
2359
+ const hostRef = getHostRef(elm);
2360
+ const cmpMeta = hostRef.$cmpMeta$;
2361
+ const endConnected = createTime('connectedCallback', cmpMeta.$tagName$);
2362
+ if (BUILD.hostListenerTargetParent) {
2363
+ // only run if we have listeners being attached to a parent
2364
+ addHostEventListeners(elm, hostRef, cmpMeta.$listeners$, true);
2365
+ }
2366
+ if (!(hostRef.$flags$ & 1 /* HOST_FLAGS.hasConnected */)) {
2367
+ // first time this component has connected
2368
+ hostRef.$flags$ |= 1 /* HOST_FLAGS.hasConnected */;
2369
+ let hostId;
2370
+ if (BUILD.hydrateClientSide) {
2371
+ hostId = elm.getAttribute(HYDRATE_ID);
2372
+ if (hostId) {
2373
+ if (BUILD.shadowDom && supportsShadow && cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) {
2374
+ const scopeId = BUILD.mode
2375
+ ? addStyle(elm.shadowRoot, cmpMeta, elm.getAttribute('s-mode'))
2376
+ : addStyle(elm.shadowRoot, cmpMeta);
2377
+ elm.classList.remove(scopeId + '-h', scopeId + '-s');
2378
+ }
2379
+ initializeClientHydrate(elm, cmpMeta.$tagName$, hostId, hostRef);
2380
+ }
2381
+ }
2382
+ if (BUILD.slotRelocation && !hostId) {
2383
+ // initUpdate
2384
+ // if the slot polyfill is required we'll need to put some nodes
2385
+ // in here to act as original content anchors as we move nodes around
2386
+ // host element has been connected to the DOM
2387
+ if (BUILD.hydrateServerSide ||
2388
+ ((BUILD.slot || BUILD.shadowDom) &&
2389
+ cmpMeta.$flags$ & (4 /* CMP_FLAGS.hasSlotRelocation */ | 8 /* CMP_FLAGS.needsShadowDomShim */))) {
2390
+ setContentReference(elm);
2391
+ }
2392
+ }
2393
+ if (BUILD.asyncLoading) {
2394
+ // find the first ancestor component (if there is one) and register
2395
+ // this component as one of the actively loading child components for its ancestor
2396
+ let ancestorComponent = elm;
2397
+ while ((ancestorComponent = ancestorComponent.parentNode || ancestorComponent.host)) {
2398
+ // climb up the ancestors looking for the first
2399
+ // component that hasn't finished its lifecycle update yet
2400
+ if ((BUILD.hydrateClientSide &&
2401
+ ancestorComponent.nodeType === 1 /* NODE_TYPE.ElementNode */ &&
2402
+ ancestorComponent.hasAttribute('s-id') &&
2403
+ ancestorComponent['s-p']) ||
2404
+ ancestorComponent['s-p']) {
2405
+ // we found this components first ancestor component
2406
+ // keep a reference to this component's ancestor component
2407
+ attachToAncestor(hostRef, (hostRef.$ancestorComponent$ = ancestorComponent));
2408
+ break;
2409
+ }
2410
+ }
2411
+ }
2412
+ // Lazy properties
2413
+ // https://developers.google.com/web/fundamentals/web-components/best-practices#lazy-properties
2414
+ if (BUILD.prop && !BUILD.hydrateServerSide && cmpMeta.$members$) {
2415
+ Object.entries(cmpMeta.$members$).map(([memberName, [memberFlags]]) => {
2416
+ if (memberFlags & 31 /* MEMBER_FLAGS.Prop */ && elm.hasOwnProperty(memberName)) {
2417
+ const value = elm[memberName];
2418
+ delete elm[memberName];
2419
+ elm[memberName] = value;
2420
+ }
2421
+ });
2422
+ }
2423
+ if (BUILD.initializeNextTick) {
2424
+ // connectedCallback, taskQueue, initialLoad
2425
+ // angular sets attribute AFTER connectCallback
2426
+ // https://github.com/angular/angular/issues/18909
2427
+ // https://github.com/angular/angular/issues/19940
2428
+ nextTick(() => initializeComponent(elm, hostRef, cmpMeta));
2429
+ }
2430
+ else {
2431
+ initializeComponent(elm, hostRef, cmpMeta);
2432
+ }
2433
+ }
2434
+ else {
2435
+ // not the first time this has connected
2436
+ // reattach any event listeners to the host
2437
+ // since they would have been removed when disconnected
2438
+ addHostEventListeners(elm, hostRef, cmpMeta.$listeners$, false);
2439
+ // fire off connectedCallback() on component instance
2440
+ fireConnectedCallback(hostRef.$lazyInstance$);
2441
+ }
2442
+ endConnected();
2443
+ }
2444
+ };
2445
+ const setContentReference = (elm) => {
2446
+ // only required when we're NOT using native shadow dom (slot)
2447
+ // or this browser doesn't support native shadow dom
2448
+ // and this host element was NOT created with SSR
2449
+ // let's pick out the inner content for slot projection
2450
+ // create a node to represent where the original
2451
+ // content was first placed, which is useful later on
2452
+ const contentRefElm = (elm['s-cr'] = doc.createComment(BUILD.isDebug ? `content-ref (host=${elm.localName})` : ''));
2453
+ contentRefElm['s-cn'] = true;
2454
+ elm.insertBefore(contentRefElm, elm.firstChild);
2455
+ };
2456
+ const disconnectedCallback = (elm) => {
2457
+ if ((plt.$flags$ & 1 /* PLATFORM_FLAGS.isTmpDisconnected */) === 0) {
2458
+ const hostRef = getHostRef(elm);
2459
+ const instance = BUILD.lazyLoad ? hostRef.$lazyInstance$ : elm;
2460
+ if (BUILD.hostListener) {
2461
+ if (hostRef.$rmListeners$) {
2462
+ hostRef.$rmListeners$.map((rmListener) => rmListener());
2463
+ hostRef.$rmListeners$ = undefined;
2464
+ }
2465
+ }
2466
+ // clear CSS var-shim tracking
2467
+ if (BUILD.cssVarShim && plt.$cssShim$) {
2468
+ plt.$cssShim$.removeHost(elm);
2469
+ }
2470
+ if (BUILD.lazyLoad && BUILD.disconnectedCallback) {
2471
+ safeCall(instance, 'disconnectedCallback');
2472
+ }
2473
+ if (BUILD.cmpDidUnload) {
2474
+ safeCall(instance, 'componentDidUnload');
2475
+ }
2476
+ }
2477
+ };
2478
+ const defineCustomElement = (Cstr, compactMeta) => {
2479
+ customElements.define(compactMeta[1], proxyCustomElement(Cstr, compactMeta));
2480
+ };
2481
+ const proxyCustomElement = (Cstr, compactMeta) => {
2482
+ const cmpMeta = {
2483
+ $flags$: compactMeta[0],
2484
+ $tagName$: compactMeta[1],
2485
+ };
2486
+ if (BUILD.member) {
2487
+ cmpMeta.$members$ = compactMeta[2];
2488
+ }
2489
+ if (BUILD.hostListener) {
2490
+ cmpMeta.$listeners$ = compactMeta[3];
2491
+ }
2492
+ if (BUILD.watchCallback) {
2493
+ cmpMeta.$watchers$ = Cstr.$watchers$;
2494
+ }
2495
+ if (BUILD.reflect) {
2496
+ cmpMeta.$attrsToReflect$ = [];
2497
+ }
2498
+ if (BUILD.shadowDom && !supportsShadow && cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) {
2499
+ cmpMeta.$flags$ |= 8 /* CMP_FLAGS.needsShadowDomShim */;
2500
+ }
2501
+ const originalConnectedCallback = Cstr.prototype.connectedCallback;
2502
+ const originalDisconnectedCallback = Cstr.prototype.disconnectedCallback;
2503
+ Object.assign(Cstr.prototype, {
2504
+ __registerHost() {
2505
+ registerHost(this, cmpMeta);
2506
+ },
2507
+ connectedCallback() {
2508
+ connectedCallback(this);
2509
+ if (BUILD.connectedCallback && originalConnectedCallback) {
2510
+ originalConnectedCallback.call(this);
2511
+ }
2512
+ },
2513
+ disconnectedCallback() {
2514
+ disconnectedCallback(this);
2515
+ if (BUILD.disconnectedCallback && originalDisconnectedCallback) {
2516
+ originalDisconnectedCallback.call(this);
2517
+ }
2518
+ },
2519
+ __attachShadow() {
2520
+ if (supportsShadow) {
2521
+ if (BUILD.shadowDelegatesFocus) {
2522
+ this.attachShadow({
2523
+ mode: 'open',
2524
+ delegatesFocus: !!(cmpMeta.$flags$ & 16 /* CMP_FLAGS.shadowDelegatesFocus */),
2525
+ });
2526
+ }
2527
+ else {
2528
+ this.attachShadow({ mode: 'open' });
2529
+ }
2530
+ }
2531
+ else {
2532
+ this.shadowRoot = this;
2533
+ }
2534
+ },
2535
+ });
2536
+ Cstr.is = cmpMeta.$tagName$;
2537
+ return proxyComponent(Cstr, cmpMeta, 1 /* PROXY_FLAGS.isElementConstructor */ | 2 /* PROXY_FLAGS.proxyState */);
2538
+ };
2539
+ const forceModeUpdate = (elm) => {
2540
+ if (BUILD.style && BUILD.mode && !BUILD.lazyLoad) {
2541
+ const mode = computeMode(elm);
2542
+ const hostRef = getHostRef(elm);
2543
+ if (hostRef.$modeName$ !== mode) {
2544
+ const cmpMeta = hostRef.$cmpMeta$;
2545
+ const oldScopeId = elm['s-sc'];
2546
+ const scopeId = getScopeId(cmpMeta, mode);
2547
+ const style = elm.constructor.style[mode];
2548
+ const flags = cmpMeta.$flags$;
2549
+ if (style) {
2550
+ if (!styles.has(scopeId)) {
2551
+ registerStyle(scopeId, style, !!(flags & 1 /* CMP_FLAGS.shadowDomEncapsulation */));
2552
+ }
2553
+ hostRef.$modeName$ = mode;
2554
+ elm.classList.remove(oldScopeId + '-h', oldScopeId + '-s');
2555
+ attachStyles(hostRef);
2556
+ forceUpdate(elm);
2557
+ }
2558
+ }
2559
+ }
2560
+ };
2561
+ const patchCloneNode = (HostElementPrototype) => {
2562
+ const orgCloneNode = HostElementPrototype.cloneNode;
2563
+ HostElementPrototype.cloneNode = function (deep) {
2564
+ const srcNode = this;
2565
+ const isShadowDom = BUILD.shadowDom ? srcNode.shadowRoot && supportsShadow : false;
2566
+ const clonedNode = orgCloneNode.call(srcNode, isShadowDom ? deep : false);
2567
+ if (BUILD.slot && !isShadowDom && deep) {
2568
+ let i = 0;
2569
+ let slotted, nonStencilNode;
2570
+ const stencilPrivates = [
2571
+ 's-id',
2572
+ 's-cr',
2573
+ 's-lr',
2574
+ 's-rc',
2575
+ 's-sc',
2576
+ 's-p',
2577
+ 's-cn',
2578
+ 's-sr',
2579
+ 's-sn',
2580
+ 's-hn',
2581
+ 's-ol',
2582
+ 's-nr',
2583
+ 's-si',
2584
+ ];
2585
+ for (; i < srcNode.childNodes.length; i++) {
2586
+ slotted = srcNode.childNodes[i]['s-nr'];
2587
+ nonStencilNode = stencilPrivates.every((privateField) => !srcNode.childNodes[i][privateField]);
2588
+ if (slotted) {
2589
+ if (BUILD.appendChildSlotFix && clonedNode.__appendChild) {
2590
+ clonedNode.__appendChild(slotted.cloneNode(true));
2591
+ }
2592
+ else {
2593
+ clonedNode.appendChild(slotted.cloneNode(true));
2594
+ }
2595
+ }
2596
+ if (nonStencilNode) {
2597
+ clonedNode.appendChild(srcNode.childNodes[i].cloneNode(true));
2598
+ }
2599
+ }
2600
+ }
2601
+ return clonedNode;
2602
+ };
2603
+ };
2604
+ const patchSlotAppendChild = (HostElementPrototype) => {
2605
+ HostElementPrototype.__appendChild = HostElementPrototype.appendChild;
2606
+ HostElementPrototype.appendChild = function (newChild) {
2607
+ const slotName = (newChild['s-sn'] = getSlotName(newChild));
2608
+ const slotNode = getHostSlotNode(this.childNodes, slotName);
2609
+ if (slotNode) {
2610
+ const slotChildNodes = getHostSlotChildNodes(slotNode, slotName);
2611
+ const appendAfter = slotChildNodes[slotChildNodes.length - 1];
2612
+ return appendAfter.parentNode.insertBefore(newChild, appendAfter.nextSibling);
2613
+ }
2614
+ return this.__appendChild(newChild);
2615
+ };
2616
+ };
2617
+ /**
2618
+ * Patches the text content of an unnamed slotted node inside a scoped component
2619
+ * @param hostElementPrototype the `Element` to be patched
2620
+ * @param cmpMeta component runtime metadata used to determine if the component should be patched or not
2621
+ */
2622
+ const patchTextContent = (hostElementPrototype, cmpMeta) => {
2623
+ if (BUILD.scoped && cmpMeta.$flags$ & 2 /* CMP_FLAGS.scopedCssEncapsulation */) {
2624
+ const descriptor = Object.getOwnPropertyDescriptor(Node.prototype, 'textContent');
2625
+ Object.defineProperty(hostElementPrototype, '__textContent', descriptor);
2626
+ Object.defineProperty(hostElementPrototype, 'textContent', {
2627
+ get() {
2628
+ var _a;
2629
+ // get the 'default slot', which would be the first slot in a shadow tree (if we were using one), whose name is
2630
+ // the empty string
2631
+ const slotNode = getHostSlotNode(this.childNodes, '');
2632
+ // when a slot node is found, the textContent _may_ be found in the next sibling (text) node, depending on how
2633
+ // nodes were reordered during the vdom render. first try to get the text content from the sibling.
2634
+ if (((_a = slotNode === null || slotNode === void 0 ? void 0 : slotNode.nextSibling) === null || _a === void 0 ? void 0 : _a.nodeType) === 3 /* NODE_TYPES.TEXT_NODE */) {
2635
+ return slotNode.nextSibling.textContent;
2636
+ }
2637
+ else if (slotNode) {
2638
+ return slotNode.textContent;
2639
+ }
2640
+ else {
2641
+ // fallback to the original implementation
2642
+ return this.__textContent;
2643
+ }
2644
+ },
2645
+ set(value) {
2646
+ var _a;
2647
+ // get the 'default slot', which would be the first slot in a shadow tree (if we were using one), whose name is
2648
+ // the empty string
2649
+ const slotNode = getHostSlotNode(this.childNodes, '');
2650
+ // when a slot node is found, the textContent _may_ need to be placed in the next sibling (text) node,
2651
+ // depending on how nodes were reordered during the vdom render. first try to set the text content on the
2652
+ // sibling.
2653
+ if (((_a = slotNode === null || slotNode === void 0 ? void 0 : slotNode.nextSibling) === null || _a === void 0 ? void 0 : _a.nodeType) === 3 /* NODE_TYPES.TEXT_NODE */) {
2654
+ slotNode.nextSibling.textContent = value;
2655
+ }
2656
+ else if (slotNode) {
2657
+ slotNode.textContent = value;
2658
+ }
2659
+ else {
2660
+ // we couldn't find a slot, but that doesn't mean that there isn't one. if this check ran before the DOM
2661
+ // loaded, we could have missed it. check for a content reference element on the scoped component and insert
2662
+ // it there
2663
+ this.__textContent = value;
2664
+ const contentRefElm = this['s-cr'];
2665
+ if (contentRefElm) {
2666
+ this.insertBefore(contentRefElm, this.firstChild);
2667
+ }
2668
+ }
2669
+ },
2670
+ });
2671
+ }
2672
+ };
2673
+ const patchChildSlotNodes = (elm, cmpMeta) => {
2674
+ class FakeNodeList extends Array {
2675
+ item(n) {
2676
+ return this[n];
2677
+ }
2678
+ }
2679
+ if (cmpMeta.$flags$ & 8 /* CMP_FLAGS.needsShadowDomShim */) {
2680
+ const childNodesFn = elm.__lookupGetter__('childNodes');
2681
+ Object.defineProperty(elm, 'children', {
2682
+ get() {
2683
+ return this.childNodes.map((n) => n.nodeType === 1);
2684
+ },
2685
+ });
2686
+ Object.defineProperty(elm, 'childElementCount', {
2687
+ get() {
2688
+ return elm.children.length;
2689
+ },
2690
+ });
2691
+ Object.defineProperty(elm, 'childNodes', {
2692
+ get() {
2693
+ const childNodes = childNodesFn.call(this);
2694
+ if ((plt.$flags$ & 1 /* PLATFORM_FLAGS.isTmpDisconnected */) === 0 &&
2695
+ getHostRef(this).$flags$ & 2 /* HOST_FLAGS.hasRendered */) {
2696
+ const result = new FakeNodeList();
2697
+ for (let i = 0; i < childNodes.length; i++) {
2698
+ const slot = childNodes[i]['s-nr'];
2699
+ if (slot) {
2700
+ result.push(slot);
2701
+ }
2702
+ }
2703
+ return result;
2704
+ }
2705
+ return FakeNodeList.from(childNodes);
2706
+ },
2707
+ });
2708
+ }
2709
+ };
2710
+ const getSlotName = (node) => node['s-sn'] || (node.nodeType === 1 && node.getAttribute('slot')) || '';
2711
+ /**
2712
+ * Recursively searches a series of child nodes for a slot with the provided name.
2713
+ * @param childNodes the nodes to search for a slot with a specific name.
2714
+ * @param slotName the name of the slot to match on.
2715
+ * @returns a reference to the slot node that matches the provided name, `null` otherwise
2716
+ */
2717
+ const getHostSlotNode = (childNodes, slotName) => {
2718
+ let i = 0;
2719
+ let childNode;
2720
+ for (; i < childNodes.length; i++) {
2721
+ childNode = childNodes[i];
2722
+ if (childNode['s-sr'] && childNode['s-sn'] === slotName) {
2723
+ return childNode;
2724
+ }
2725
+ childNode = getHostSlotNode(childNode.childNodes, slotName);
2726
+ if (childNode) {
2727
+ return childNode;
2728
+ }
2729
+ }
2730
+ return null;
2731
+ };
2732
+ const getHostSlotChildNodes = (n, slotName) => {
2733
+ const childNodes = [n];
2734
+ while ((n = n.nextSibling) && n['s-sn'] === slotName) {
2735
+ childNodes.push(n);
2736
+ }
2737
+ return childNodes;
2738
+ };
2739
+ const hmrStart = (elm, cmpMeta, hmrVersionId) => {
2740
+ // ¯\_(ツ)_/¯
2741
+ const hostRef = getHostRef(elm);
2742
+ // reset state flags to only have been connected
2743
+ hostRef.$flags$ = 1 /* HOST_FLAGS.hasConnected */;
2744
+ // TODO
2745
+ // detatch any event listeners that may have been added
2746
+ // because we're not passing an exact event name it'll
2747
+ // remove all of this element's event, which is good
2748
+ // create a callback for when this component finishes hmr
2749
+ elm['s-hmr-load'] = () => {
2750
+ // finished hmr for this element
2751
+ delete elm['s-hmr-load'];
2752
+ };
2753
+ // re-initialize the component
2754
+ initializeComponent(elm, hostRef, cmpMeta, hmrVersionId);
2755
+ };
2756
+ const bootstrapLazy = (lazyBundles, options = {}) => {
2757
+ var _a;
2758
+ if (BUILD.profile && performance.mark) {
2759
+ performance.mark('st:app:start');
2760
+ }
2761
+ installDevTools();
2762
+ const endBootstrap = createTime('bootstrapLazy');
2763
+ const cmpTags = [];
2764
+ const exclude = options.exclude || [];
2765
+ const customElements = win.customElements;
2766
+ const head = doc.head;
2767
+ const metaCharset = /*@__PURE__*/ head.querySelector('meta[charset]');
2768
+ const visibilityStyle = /*@__PURE__*/ doc.createElement('style');
2769
+ const deferredConnectedCallbacks = [];
2770
+ const styles = /*@__PURE__*/ doc.querySelectorAll(`[${HYDRATED_STYLE_ID}]`);
2771
+ let appLoadFallback;
2772
+ let isBootstrapping = true;
2773
+ let i = 0;
2774
+ Object.assign(plt, options);
2775
+ plt.$resourcesUrl$ = new URL(options.resourcesUrl || './', doc.baseURI).href;
2776
+ if (BUILD.asyncQueue) {
2777
+ if (options.syncQueue) {
2778
+ plt.$flags$ |= 4 /* PLATFORM_FLAGS.queueSync */;
2779
+ }
2780
+ }
2781
+ if (BUILD.hydrateClientSide) {
2782
+ // If the app is already hydrated there is not point to disable the
2783
+ // async queue. This will improve the first input delay
2784
+ plt.$flags$ |= 2 /* PLATFORM_FLAGS.appLoaded */;
2785
+ }
2786
+ if (BUILD.hydrateClientSide && BUILD.shadowDom) {
2787
+ for (; i < styles.length; i++) {
2788
+ registerStyle(styles[i].getAttribute(HYDRATED_STYLE_ID), convertScopedToShadow(styles[i].innerHTML), true);
2789
+ }
2790
+ }
2791
+ lazyBundles.map((lazyBundle) => {
2792
+ lazyBundle[1].map((compactMeta) => {
2793
+ const cmpMeta = {
2794
+ $flags$: compactMeta[0],
2795
+ $tagName$: compactMeta[1],
2796
+ $members$: compactMeta[2],
2797
+ $listeners$: compactMeta[3],
2798
+ };
2799
+ if (BUILD.member) {
2800
+ cmpMeta.$members$ = compactMeta[2];
2801
+ }
2802
+ if (BUILD.hostListener) {
2803
+ cmpMeta.$listeners$ = compactMeta[3];
2804
+ }
2805
+ if (BUILD.reflect) {
2806
+ cmpMeta.$attrsToReflect$ = [];
2807
+ }
2808
+ if (BUILD.watchCallback) {
2809
+ cmpMeta.$watchers$ = {};
2810
+ }
2811
+ if (BUILD.shadowDom && !supportsShadow && cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) {
2812
+ cmpMeta.$flags$ |= 8 /* CMP_FLAGS.needsShadowDomShim */;
2813
+ }
2814
+ const tagName = BUILD.transformTagName && options.transformTagName
2815
+ ? options.transformTagName(cmpMeta.$tagName$)
2816
+ : cmpMeta.$tagName$;
2817
+ const HostElement = class extends HTMLElement {
2818
+ // StencilLazyHost
2819
+ constructor(self) {
2820
+ // @ts-ignore
2821
+ super(self);
2822
+ self = this;
2823
+ registerHost(self, cmpMeta);
2824
+ if (BUILD.shadowDom && cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) {
2825
+ // this component is using shadow dom
2826
+ // and this browser supports shadow dom
2827
+ // add the read-only property "shadowRoot" to the host element
2828
+ // adding the shadow root build conditionals to minimize runtime
2829
+ if (supportsShadow) {
2830
+ if (BUILD.shadowDelegatesFocus) {
2831
+ self.attachShadow({
2832
+ mode: 'open',
2833
+ delegatesFocus: !!(cmpMeta.$flags$ & 16 /* CMP_FLAGS.shadowDelegatesFocus */),
2834
+ });
2835
+ }
2836
+ else {
2837
+ self.attachShadow({ mode: 'open' });
2838
+ }
2839
+ }
2840
+ else if (!BUILD.hydrateServerSide && !('shadowRoot' in self)) {
2841
+ self.shadowRoot = self;
2842
+ }
2843
+ }
2844
+ if (BUILD.slotChildNodesFix) {
2845
+ patchChildSlotNodes(self, cmpMeta);
2846
+ }
2847
+ }
2848
+ connectedCallback() {
2849
+ if (appLoadFallback) {
2850
+ clearTimeout(appLoadFallback);
2851
+ appLoadFallback = null;
2852
+ }
2853
+ if (isBootstrapping) {
2854
+ // connectedCallback will be processed once all components have been registered
2855
+ deferredConnectedCallbacks.push(this);
2856
+ }
2857
+ else {
2858
+ plt.jmp(() => connectedCallback(this));
2859
+ }
2860
+ }
2861
+ disconnectedCallback() {
2862
+ plt.jmp(() => disconnectedCallback(this));
2863
+ }
2864
+ componentOnReady() {
2865
+ return getHostRef(this).$onReadyPromise$;
2866
+ }
2867
+ };
2868
+ if (BUILD.cloneNodeFix) {
2869
+ patchCloneNode(HostElement.prototype);
2870
+ }
2871
+ if (BUILD.appendChildSlotFix) {
2872
+ patchSlotAppendChild(HostElement.prototype);
2873
+ }
2874
+ if (BUILD.hotModuleReplacement) {
2875
+ HostElement.prototype['s-hmr'] = function (hmrVersionId) {
2876
+ hmrStart(this, cmpMeta, hmrVersionId);
2877
+ };
2878
+ }
2879
+ if (BUILD.scopedSlotTextContentFix) {
2880
+ patchTextContent(HostElement.prototype, cmpMeta);
2881
+ }
2882
+ cmpMeta.$lazyBundleId$ = lazyBundle[0];
2883
+ if (!exclude.includes(tagName) && !customElements.get(tagName)) {
2884
+ cmpTags.push(tagName);
2885
+ customElements.define(tagName, proxyComponent(HostElement, cmpMeta, 1 /* PROXY_FLAGS.isElementConstructor */));
2886
+ }
2887
+ });
2888
+ });
2889
+ if (BUILD.invisiblePrehydration && (BUILD.hydratedClass || BUILD.hydratedAttribute)) {
2890
+ visibilityStyle.innerHTML = cmpTags + HYDRATED_CSS;
2891
+ visibilityStyle.setAttribute('data-styles', '');
2892
+ // Apply CSP nonce to the style tag if it exists
2893
+ const nonce = (_a = plt.$nonce$) !== null && _a !== void 0 ? _a : queryNonceMetaTagContent(doc);
2894
+ if (nonce != null) {
2895
+ visibilityStyle.setAttribute('nonce', nonce);
2896
+ }
2897
+ head.insertBefore(visibilityStyle, metaCharset ? metaCharset.nextSibling : head.firstChild);
2898
+ }
2899
+ // Process deferred connectedCallbacks now all components have been registered
2900
+ isBootstrapping = false;
2901
+ if (deferredConnectedCallbacks.length) {
2902
+ deferredConnectedCallbacks.map((host) => host.connectedCallback());
2903
+ }
2904
+ else {
2905
+ if (BUILD.profile) {
2906
+ plt.jmp(() => (appLoadFallback = setTimeout(appDidLoad, 30, 'timeout')));
2907
+ }
2908
+ else {
2909
+ plt.jmp(() => (appLoadFallback = setTimeout(appDidLoad, 30)));
2910
+ }
2911
+ }
2912
+ // Fallback appLoad event
2913
+ endBootstrap();
2914
+ };
2915
+ const getConnect = (_ref, tagName) => {
2916
+ const componentOnReady = () => {
2917
+ let elm = doc.querySelector(tagName);
2918
+ if (!elm) {
2919
+ elm = doc.createElement(tagName);
2920
+ doc.body.appendChild(elm);
2921
+ }
2922
+ return typeof elm.componentOnReady === 'function' ? elm.componentOnReady() : Promise.resolve(elm);
2923
+ };
2924
+ const create = (...args) => {
2925
+ return componentOnReady().then((el) => el.create(...args));
2926
+ };
2927
+ return {
2928
+ create,
2929
+ componentOnReady,
2930
+ };
2931
+ };
2932
+ const getContext = (_elm, context) => {
2933
+ if (context in Context) {
2934
+ return Context[context];
2935
+ }
2936
+ else if (context === 'window') {
2937
+ return win;
2938
+ }
2939
+ else if (context === 'document') {
2940
+ return doc;
2941
+ }
2942
+ else if (context === 'isServer' || context === 'isPrerender') {
2943
+ return BUILD.hydrateServerSide ? true : false;
2944
+ }
2945
+ else if (context === 'isClient') {
2946
+ return BUILD.hydrateServerSide ? false : true;
2947
+ }
2948
+ else if (context === 'resourcesUrl' || context === 'publicPath') {
2949
+ return getAssetPath('.');
2950
+ }
2951
+ else if (context === 'queue') {
2952
+ return {
2953
+ write: writeTask,
2954
+ read: readTask,
2955
+ tick: {
2956
+ then(cb) {
2957
+ return nextTick(cb);
2958
+ },
2959
+ },
2960
+ };
2961
+ }
2962
+ return undefined;
2963
+ };
2964
+ const Fragment = (_, children) => children;
2965
+ const addHostEventListeners = (elm, hostRef, listeners, attachParentListeners) => {
2966
+ if (BUILD.hostListener && listeners) {
2967
+ // this is called immediately within the element's constructor
2968
+ // initialize our event listeners on the host element
2969
+ // we do this now so that we can listen to events that may
2970
+ // have fired even before the instance is ready
2971
+ if (BUILD.hostListenerTargetParent) {
2972
+ // this component may have event listeners that should be attached to the parent
2973
+ if (attachParentListeners) {
2974
+ // this is being ran from within the connectedCallback
2975
+ // which is important so that we know the host element actually has a parent element
2976
+ // filter out the listeners to only have the ones that ARE being attached to the parent
2977
+ listeners = listeners.filter(([flags]) => flags & 32 /* LISTENER_FLAGS.TargetParent */);
2978
+ }
2979
+ else {
2980
+ // this is being ran from within the component constructor
2981
+ // everything BUT the parent element listeners should be attached at this time
2982
+ // filter out the listeners that are NOT being attached to the parent
2983
+ listeners = listeners.filter(([flags]) => !(flags & 32 /* LISTENER_FLAGS.TargetParent */));
2984
+ }
2985
+ }
2986
+ listeners.map(([flags, name, method]) => {
2987
+ const target = BUILD.hostListenerTarget ? getHostListenerTarget(elm, flags) : elm;
2988
+ const handler = hostListenerProxy(hostRef, method);
2989
+ const opts = hostListenerOpts(flags);
2990
+ plt.ael(target, name, handler, opts);
2991
+ (hostRef.$rmListeners$ = hostRef.$rmListeners$ || []).push(() => plt.rel(target, name, handler, opts));
2992
+ });
2993
+ }
2994
+ };
2995
+ const hostListenerProxy = (hostRef, methodName) => (ev) => {
2996
+ try {
2997
+ if (BUILD.lazyLoad) {
2998
+ if (hostRef.$flags$ & 256 /* HOST_FLAGS.isListenReady */) {
2999
+ // instance is ready, let's call it's member method for this event
3000
+ hostRef.$lazyInstance$[methodName](ev);
3001
+ }
3002
+ else {
3003
+ (hostRef.$queuedListeners$ = hostRef.$queuedListeners$ || []).push([methodName, ev]);
3004
+ }
3005
+ }
3006
+ else {
3007
+ hostRef.$hostElement$[methodName](ev);
3008
+ }
3009
+ }
3010
+ catch (e) {
3011
+ consoleError(e);
3012
+ }
3013
+ };
3014
+ const getHostListenerTarget = (elm, flags) => {
3015
+ if (BUILD.hostListenerTargetDocument && flags & 4 /* LISTENER_FLAGS.TargetDocument */)
3016
+ return doc;
3017
+ if (BUILD.hostListenerTargetWindow && flags & 8 /* LISTENER_FLAGS.TargetWindow */)
3018
+ return win;
3019
+ if (BUILD.hostListenerTargetBody && flags & 16 /* LISTENER_FLAGS.TargetBody */)
3020
+ return doc.body;
3021
+ if (BUILD.hostListenerTargetParent && flags & 32 /* LISTENER_FLAGS.TargetParent */)
3022
+ return elm.parentElement;
3023
+ return elm;
3024
+ };
3025
+ // prettier-ignore
3026
+ const hostListenerOpts = (flags) => supportsListenerOptions
3027
+ ? ({
3028
+ passive: (flags & 1 /* LISTENER_FLAGS.Passive */) !== 0,
3029
+ capture: (flags & 2 /* LISTENER_FLAGS.Capture */) !== 0,
3030
+ })
3031
+ : (flags & 2 /* LISTENER_FLAGS.Capture */) !== 0;
3032
+ /**
3033
+ * Assigns the given value to the nonce property on the runtime platform object.
3034
+ * During runtime, this value is used to set the nonce attribute on all dynamically created script and style tags.
3035
+ * @param nonce The value to be assigned to the platform nonce property.
3036
+ * @returns void
3037
+ */
3038
+ const setNonce = (nonce) => (plt.$nonce$ = nonce);
3039
+ const setPlatformOptions = (opts) => Object.assign(plt, opts);
3040
+ const insertVdomAnnotations = (doc, staticComponents) => {
3041
+ if (doc != null) {
3042
+ const docData = {
3043
+ hostIds: 0,
3044
+ rootLevelIds: 0,
3045
+ staticComponents: new Set(staticComponents),
3046
+ };
3047
+ const orgLocationNodes = [];
3048
+ parseVNodeAnnotations(doc, doc.body, docData, orgLocationNodes);
3049
+ orgLocationNodes.forEach((orgLocationNode) => {
3050
+ if (orgLocationNode != null) {
3051
+ const nodeRef = orgLocationNode['s-nr'];
3052
+ let hostId = nodeRef['s-host-id'];
3053
+ let nodeId = nodeRef['s-node-id'];
3054
+ let childId = `${hostId}.${nodeId}`;
3055
+ if (hostId == null) {
3056
+ hostId = 0;
3057
+ docData.rootLevelIds++;
3058
+ nodeId = docData.rootLevelIds;
3059
+ childId = `${hostId}.${nodeId}`;
3060
+ if (nodeRef.nodeType === 1 /* NODE_TYPE.ElementNode */) {
3061
+ nodeRef.setAttribute(HYDRATE_CHILD_ID, childId);
3062
+ }
3063
+ else if (nodeRef.nodeType === 3 /* NODE_TYPE.TextNode */) {
3064
+ if (hostId === 0) {
3065
+ const textContent = nodeRef.nodeValue.trim();
3066
+ if (textContent === '') {
3067
+ // useless whitespace node at the document root
3068
+ orgLocationNode.remove();
3069
+ return;
3070
+ }
3071
+ }
3072
+ const commentBeforeTextNode = doc.createComment(childId);
3073
+ commentBeforeTextNode.nodeValue = `${TEXT_NODE_ID}.${childId}`;
3074
+ nodeRef.parentNode.insertBefore(commentBeforeTextNode, nodeRef);
3075
+ }
3076
+ }
3077
+ let orgLocationNodeId = `${ORG_LOCATION_ID}.${childId}`;
3078
+ const orgLocationParentNode = orgLocationNode.parentElement;
3079
+ if (orgLocationParentNode) {
3080
+ if (orgLocationParentNode['s-en'] === '') {
3081
+ // ending with a "." means that the parent element
3082
+ // of this node's original location is a SHADOW dom element
3083
+ // and this node is apart of the root level light dom
3084
+ orgLocationNodeId += `.`;
3085
+ }
3086
+ else if (orgLocationParentNode['s-en'] === 'c') {
3087
+ // ending with a ".c" means that the parent element
3088
+ // of this node's original location is a SCOPED element
3089
+ // and this node is apart of the root level light dom
3090
+ orgLocationNodeId += `.c`;
3091
+ }
3092
+ }
3093
+ orgLocationNode.nodeValue = orgLocationNodeId;
3094
+ }
3095
+ });
3096
+ }
3097
+ };
3098
+ const parseVNodeAnnotations = (doc, node, docData, orgLocationNodes) => {
3099
+ if (node == null) {
3100
+ return;
3101
+ }
3102
+ if (node['s-nr'] != null) {
3103
+ orgLocationNodes.push(node);
3104
+ }
3105
+ if (node.nodeType === 1 /* NODE_TYPE.ElementNode */) {
3106
+ node.childNodes.forEach((childNode) => {
3107
+ const hostRef = getHostRef(childNode);
3108
+ if (hostRef != null && !docData.staticComponents.has(childNode.nodeName.toLowerCase())) {
3109
+ const cmpData = {
3110
+ nodeIds: 0,
3111
+ };
3112
+ insertVNodeAnnotations(doc, childNode, hostRef.$vnode$, docData, cmpData);
3113
+ }
3114
+ parseVNodeAnnotations(doc, childNode, docData, orgLocationNodes);
3115
+ });
3116
+ }
3117
+ };
3118
+ const insertVNodeAnnotations = (doc, hostElm, vnode, docData, cmpData) => {
3119
+ if (vnode != null) {
3120
+ const hostId = ++docData.hostIds;
3121
+ hostElm.setAttribute(HYDRATE_ID, hostId);
3122
+ if (hostElm['s-cr'] != null) {
3123
+ hostElm['s-cr'].nodeValue = `${CONTENT_REF_ID}.${hostId}`;
3124
+ }
3125
+ if (vnode.$children$ != null) {
3126
+ const depth = 0;
3127
+ vnode.$children$.forEach((vnodeChild, index) => {
3128
+ insertChildVNodeAnnotations(doc, vnodeChild, cmpData, hostId, depth, index);
3129
+ });
3130
+ }
3131
+ if (hostElm && vnode && vnode.$elm$ && !hostElm.hasAttribute('c-id')) {
3132
+ const parent = hostElm.parentElement;
3133
+ if (parent && parent.childNodes) {
3134
+ const parentChildNodes = Array.from(parent.childNodes);
3135
+ const comment = parentChildNodes.find((node) => node.nodeType === 8 /* NODE_TYPE.CommentNode */ && node['s-sr']);
3136
+ if (comment) {
3137
+ const index = parentChildNodes.indexOf(hostElm) - 1;
3138
+ vnode.$elm$.setAttribute(HYDRATE_CHILD_ID, `${comment['s-host-id']}.${comment['s-node-id']}.0.${index}`);
3139
+ }
3140
+ }
3141
+ }
3142
+ }
3143
+ };
3144
+ const insertChildVNodeAnnotations = (doc, vnodeChild, cmpData, hostId, depth, index) => {
3145
+ const childElm = vnodeChild.$elm$;
3146
+ if (childElm == null) {
3147
+ return;
3148
+ }
3149
+ const nodeId = cmpData.nodeIds++;
3150
+ const childId = `${hostId}.${nodeId}.${depth}.${index}`;
3151
+ childElm['s-host-id'] = hostId;
3152
+ childElm['s-node-id'] = nodeId;
3153
+ if (childElm.nodeType === 1 /* NODE_TYPE.ElementNode */) {
3154
+ childElm.setAttribute(HYDRATE_CHILD_ID, childId);
3155
+ }
3156
+ else if (childElm.nodeType === 3 /* NODE_TYPE.TextNode */) {
3157
+ const parentNode = childElm.parentNode;
3158
+ const nodeName = parentNode.nodeName;
3159
+ if (nodeName !== 'STYLE' && nodeName !== 'SCRIPT') {
3160
+ const textNodeId = `${TEXT_NODE_ID}.${childId}`;
3161
+ const commentBeforeTextNode = doc.createComment(textNodeId);
3162
+ parentNode.insertBefore(commentBeforeTextNode, childElm);
3163
+ }
3164
+ }
3165
+ else if (childElm.nodeType === 8 /* NODE_TYPE.CommentNode */) {
3166
+ if (childElm['s-sr']) {
3167
+ const slotName = childElm['s-sn'] || '';
3168
+ const slotNodeId = `${SLOT_NODE_ID}.${childId}.${slotName}`;
3169
+ childElm.nodeValue = slotNodeId;
3170
+ }
3171
+ }
3172
+ if (vnodeChild.$children$ != null) {
3173
+ const childDepth = depth + 1;
3174
+ vnodeChild.$children$.forEach((vnode, index) => {
3175
+ insertChildVNodeAnnotations(doc, vnode, cmpData, hostId, childDepth, index);
3176
+ });
3177
+ }
3178
+ };
3179
+ const hostRefs = /*@__PURE__*/ new WeakMap();
3180
+ const getHostRef = (ref) => hostRefs.get(ref);
3181
+ const registerInstance = (lazyInstance, hostRef) => hostRefs.set((hostRef.$lazyInstance$ = lazyInstance), hostRef);
3182
+ const registerHost = (elm, cmpMeta) => {
3183
+ const hostRef = {
3184
+ $flags$: 0,
3185
+ $hostElement$: elm,
3186
+ $cmpMeta$: cmpMeta,
3187
+ $instanceValues$: new Map(),
3188
+ };
3189
+ if (BUILD.isDev) {
3190
+ hostRef.$renderCount$ = 0;
3191
+ }
3192
+ if (BUILD.method && BUILD.lazyLoad) {
3193
+ hostRef.$onInstancePromise$ = new Promise((r) => (hostRef.$onInstanceResolve$ = r));
3194
+ }
3195
+ if (BUILD.asyncLoading) {
3196
+ hostRef.$onReadyPromise$ = new Promise((r) => (hostRef.$onReadyResolve$ = r));
3197
+ elm['s-p'] = [];
3198
+ elm['s-rc'] = [];
3199
+ }
3200
+ addHostEventListeners(elm, hostRef, cmpMeta.$listeners$, false);
3201
+ return hostRefs.set(elm, hostRef);
3202
+ };
3203
+ const isMemberInElement = (elm, memberName) => memberName in elm;
3204
+ const consoleError = (e, el) => (customError || console.error)(e, el);
3205
+ const STENCIL_DEV_MODE = BUILD.isTesting
3206
+ ? ['STENCIL:'] // E2E testing
3207
+ : [
3208
+ '%cstencil',
3209
+ 'color: white;background:#4c47ff;font-weight: bold; font-size:10px; padding:2px 6px; border-radius: 5px',
3210
+ ];
3211
+ const consoleDevError = (...m) => console.error(...STENCIL_DEV_MODE, ...m);
3212
+ const consoleDevWarn = (...m) => console.warn(...STENCIL_DEV_MODE, ...m);
3213
+ const consoleDevInfo = (...m) => console.info(...STENCIL_DEV_MODE, ...m);
3214
+ const setErrorHandler = (handler) => (customError = handler);
3215
+ const cmpModules = /*@__PURE__*/ new Map();
3216
+ const loadModule = (cmpMeta, hostRef, hmrVersionId) => {
3217
+ // loadModuleImport
3218
+ const exportName = cmpMeta.$tagName$.replace(/-/g, '_');
3219
+ const bundleId = cmpMeta.$lazyBundleId$;
3220
+ if (BUILD.isDev && typeof bundleId !== 'string') {
3221
+ consoleDevError(`Trying to lazily load component <${cmpMeta.$tagName$}> with style mode "${hostRef.$modeName$}", but it does not exist.`);
3222
+ return undefined;
3223
+ }
3224
+ const module = !BUILD.hotModuleReplacement ? cmpModules.get(bundleId) : false;
3225
+ if (module) {
3226
+ return module[exportName];
3227
+ }
3228
+ /*!__STENCIL_STATIC_IMPORT_SWITCH__*/
3229
+ return import(
3230
+ /* @vite-ignore */
3231
+ /* webpackInclude: /\.entry\.js$/ */
3232
+ /* webpackExclude: /\.system\.entry\.js$/ */
3233
+ /* webpackMode: "lazy" */
3234
+ `./${bundleId}.entry.js${BUILD.hotModuleReplacement && hmrVersionId ? '?s-hmr=' + hmrVersionId : ''}`).then((importedModule) => {
3235
+ if (!BUILD.hotModuleReplacement) {
3236
+ cmpModules.set(bundleId, importedModule);
3237
+ }
3238
+ return importedModule[exportName];
3239
+ }, consoleError);
3240
+ };
3241
+ const styles = /*@__PURE__*/ new Map();
3242
+ const modeResolutionChain = [];
3243
+ const win = typeof window !== 'undefined' ? window : {};
3244
+ const CSS = BUILD.cssVarShim ? win.CSS : null;
3245
+ const doc = win.document || { head: {} };
3246
+ const H = (win.HTMLElement || class {
3247
+ });
3248
+ const plt = {
3249
+ $flags$: 0,
3250
+ $resourcesUrl$: '',
3251
+ jmp: (h) => h(),
3252
+ raf: (h) => requestAnimationFrame(h),
3253
+ ael: (el, eventName, listener, opts) => el.addEventListener(eventName, listener, opts),
3254
+ rel: (el, eventName, listener, opts) => el.removeEventListener(eventName, listener, opts),
3255
+ ce: (eventName, opts) => new CustomEvent(eventName, opts),
3256
+ };
3257
+ const setPlatformHelpers = (helpers) => {
3258
+ Object.assign(plt, helpers);
3259
+ };
3260
+ const supportsShadow = BUILD.shadowDomShim && BUILD.shadowDom
3261
+ ? /*@__PURE__*/ (() => (doc.head.attachShadow + '').indexOf('[native') > -1)()
3262
+ : true;
3263
+ const supportsListenerOptions = /*@__PURE__*/ (() => {
3264
+ let supportsListenerOptions = false;
3265
+ try {
3266
+ doc.addEventListener('e', null, Object.defineProperty({}, 'passive', {
3267
+ get() {
3268
+ supportsListenerOptions = true;
3269
+ },
3270
+ }));
3271
+ }
3272
+ catch (e) { }
3273
+ return supportsListenerOptions;
3274
+ })();
3275
+ const promiseResolve = (v) => Promise.resolve(v);
3276
+ const supportsConstructableStylesheets = BUILD.constructableCSS
3277
+ ? /*@__PURE__*/ (() => {
3278
+ try {
3279
+ new CSSStyleSheet();
3280
+ return typeof new CSSStyleSheet().replaceSync === 'function';
3281
+ }
3282
+ catch (e) { }
3283
+ return false;
3284
+ })()
3285
+ : false;
3286
+ const queueDomReads = [];
3287
+ const queueDomWrites = [];
3288
+ const queueDomWritesLow = [];
3289
+ const queueTask = (queue, write) => (cb) => {
3290
+ queue.push(cb);
3291
+ if (!queuePending) {
3292
+ queuePending = true;
3293
+ if (write && plt.$flags$ & 4 /* PLATFORM_FLAGS.queueSync */) {
3294
+ nextTick(flush);
3295
+ }
3296
+ else {
3297
+ plt.raf(flush);
3298
+ }
3299
+ }
3300
+ };
3301
+ const consume = (queue) => {
3302
+ for (let i = 0; i < queue.length; i++) {
3303
+ try {
3304
+ queue[i](performance.now());
3305
+ }
3306
+ catch (e) {
3307
+ consoleError(e);
3308
+ }
3309
+ }
3310
+ queue.length = 0;
3311
+ };
3312
+ const consumeTimeout = (queue, timeout) => {
3313
+ let i = 0;
3314
+ let ts = 0;
3315
+ while (i < queue.length && (ts = performance.now()) < timeout) {
3316
+ try {
3317
+ queue[i++](ts);
3318
+ }
3319
+ catch (e) {
3320
+ consoleError(e);
3321
+ }
3322
+ }
3323
+ if (i === queue.length) {
3324
+ queue.length = 0;
3325
+ }
3326
+ else if (i !== 0) {
3327
+ queue.splice(0, i);
3328
+ }
3329
+ };
3330
+ const flush = () => {
3331
+ if (BUILD.asyncQueue) {
3332
+ queueCongestion++;
3333
+ }
3334
+ // always force a bunch of medium callbacks to run, but still have
3335
+ // a throttle on how many can run in a certain time
3336
+ // DOM READS!!!
3337
+ consume(queueDomReads);
3338
+ // DOM WRITES!!!
3339
+ if (BUILD.asyncQueue) {
3340
+ const timeout = (plt.$flags$ & 6 /* PLATFORM_FLAGS.queueMask */) === 2 /* PLATFORM_FLAGS.appLoaded */
3341
+ ? performance.now() + 14 * Math.ceil(queueCongestion * (1.0 / 10.0))
3342
+ : Infinity;
3343
+ consumeTimeout(queueDomWrites, timeout);
3344
+ consumeTimeout(queueDomWritesLow, timeout);
3345
+ if (queueDomWrites.length > 0) {
3346
+ queueDomWritesLow.push(...queueDomWrites);
3347
+ queueDomWrites.length = 0;
3348
+ }
3349
+ if ((queuePending = queueDomReads.length + queueDomWrites.length + queueDomWritesLow.length > 0)) {
3350
+ // still more to do yet, but we've run out of time
3351
+ // let's let this thing cool off and try again in the next tick
3352
+ plt.raf(flush);
3353
+ }
3354
+ else {
3355
+ queueCongestion = 0;
3356
+ }
3357
+ }
3358
+ else {
3359
+ consume(queueDomWrites);
3360
+ if ((queuePending = queueDomReads.length > 0)) {
3361
+ // still more to do yet, but we've run out of time
3362
+ // let's let this thing cool off and try again in the next tick
3363
+ plt.raf(flush);
3364
+ }
3365
+ }
3366
+ };
3367
+ const nextTick = /*@__PURE__*/ (cb) => promiseResolve().then(cb);
3368
+ const readTask = /*@__PURE__*/ queueTask(queueDomReads, false);
3369
+ const writeTask = /*@__PURE__*/ queueTask(queueDomWrites, true);
3370
+
3371
+ export { BUILD as B, CSS as C, H, NAMESPACE as N, promiseResolve as a, bootstrapLazy as b, consoleDevInfo as c, doc as d, createEvent as e, Host as f, getElement as g, h, plt as p, registerInstance as r, setNonce as s, win as w };