@penn-libraries/web 0.0.5 → 0.0.6

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