@uoguelph/web-components 0.0.7

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