@penn-libraries/web 0.0.4-dev.1 → 0.0.4-dev.3

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