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