@penn-libraries/web 0.0.4-dev.2 → 0.0.5

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