@salla.sa/twilight-components 1.0.21 → 1.0.22

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 (95) hide show
  1. package/dist/cjs/Helper-fcea994c.js +23 -0
  2. package/dist/cjs/index-714023c8.js +1653 -0
  3. package/dist/cjs/index.cjs.js +13 -0
  4. package/dist/cjs/loader.cjs.js +21 -0
  5. package/dist/cjs/salla-branches.cjs.entry.js +92 -0
  6. package/dist/cjs/salla-button_5.cjs.entry.js +1727 -0
  7. package/dist/cjs/salla-localization.cjs.entry.js +82 -0
  8. package/dist/cjs/salla-login-c438bb35.js +128 -0
  9. package/dist/cjs/salla-offer.cjs.entry.js +79 -0
  10. package/dist/cjs/salla-product-availability.cjs.entry.js +75 -0
  11. package/dist/cjs/salla-rating.cjs.entry.js +195 -0
  12. package/dist/cjs/salla-search-45173394.js +85 -0
  13. package/dist/cjs/salla-search.cjs.entry.js +11 -0
  14. package/dist/cjs/twilight-components.cjs.js +19 -0
  15. package/dist/collection/Helpers/Helper.js +19 -0
  16. package/dist/collection/collection-manifest.json +22 -0
  17. package/dist/collection/components/generate-summary.js +35 -0
  18. package/dist/collection/components/salla-branches/salla-branches.css +12 -0
  19. package/dist/collection/components/salla-branches/salla-branches.js +233 -0
  20. package/dist/collection/components/salla-button/salla-button.css +3 -0
  21. package/dist/collection/components/salla-button/salla-button.js +246 -0
  22. package/dist/collection/components/salla-localization/salla-localization.js +208 -0
  23. package/dist/collection/components/salla-login/salla-login.css +3 -0
  24. package/dist/collection/components/salla-login/salla-login.js +380 -0
  25. package/dist/collection/components/salla-modal/salla-modal.js +477 -0
  26. package/dist/collection/components/salla-offer/offer-schema.js +1 -0
  27. package/dist/collection/components/salla-offer/salla-offer.js +110 -0
  28. package/dist/collection/components/salla-product-availability/salla-product-availability.js +331 -0
  29. package/dist/collection/components/salla-rating/order-feedback-response.js +1 -0
  30. package/dist/collection/components/salla-rating/salla-rating.css +7 -0
  31. package/dist/collection/components/salla-rating/salla-rating.js +277 -0
  32. package/dist/collection/components/salla-search/salla-search.css +24 -0
  33. package/dist/collection/components/salla-search/salla-search.js +143 -0
  34. package/dist/collection/components/salla-tel-input/salla-tel-input.js +121 -0
  35. package/dist/collection/components/salla-verify/salla-verify.js +280 -0
  36. package/dist/collection/index.js +2 -0
  37. package/dist/collection/interfaces/colors.js +1 -0
  38. package/dist/collection/interfaces/index.js +2 -0
  39. package/dist/collection/interfaces/ratio.js +1 -0
  40. package/dist/collection/plugins/tailwind-theme/generator.js +62 -0
  41. package/dist/collection/plugins/tailwind-theme/index.js +26 -0
  42. package/dist/{twilight-components → esm}/Helper-d07ebbc7.js +0 -0
  43. package/dist/esm/index-a1bf769d.js +1625 -0
  44. package/dist/esm/index.js +4 -0
  45. package/dist/esm/loader.js +17 -0
  46. package/dist/esm/polyfills/core-js.js +11 -0
  47. package/dist/esm/polyfills/css-shim.js +1 -0
  48. package/dist/esm/polyfills/dom.js +79 -0
  49. package/dist/esm/polyfills/es5-html-element.js +1 -0
  50. package/dist/esm/polyfills/index.js +34 -0
  51. package/dist/esm/polyfills/system.js +6 -0
  52. package/dist/{twilight-components → esm}/salla-branches.entry.js +2 -2
  53. package/dist/{twilight-components/salla-tel-input.entry.js → esm/salla-button_5.entry.js} +337 -35
  54. package/dist/{twilight-components → esm}/salla-localization.entry.js +1 -1
  55. package/dist/{twilight-components/salla-login-57b18c2c.js → esm/salla-login-dd957742.js} +26 -23
  56. package/dist/{twilight-components → esm}/salla-offer.entry.js +1 -1
  57. package/dist/{twilight-components → esm}/salla-product-availability.entry.js +1 -1
  58. package/dist/{twilight-components → esm}/salla-rating.entry.js +71 -108
  59. package/dist/{twilight-components/salla-search-30fec1e8.js → esm/salla-search-5e691ebb.js} +15 -11
  60. package/dist/esm/salla-search.entry.js +3 -0
  61. package/dist/esm/twilight-components.js +17 -0
  62. package/dist/index.cjs.js +1 -0
  63. package/dist/index.js +1 -0
  64. package/dist/twilight-components/index.esm.js +1 -4
  65. package/dist/twilight-components/p-1a6d8171.entry.js +1 -0
  66. package/dist/twilight-components/p-1deb8111.entry.js +1 -0
  67. package/dist/twilight-components/p-3a4d963e.js +1 -0
  68. package/dist/twilight-components/p-47f17d3b.js +1 -0
  69. package/dist/twilight-components/p-5b2eb87d.entry.js +1 -0
  70. package/dist/twilight-components/p-6a5be894.js +1 -0
  71. package/dist/twilight-components/p-7fbdf746.entry.js +1 -0
  72. package/dist/twilight-components/p-7fe5d346.entry.js +1 -0
  73. package/dist/twilight-components/p-81a61f4e.js +1 -0
  74. package/dist/twilight-components/p-ce991664.entry.js +1 -0
  75. package/dist/twilight-components/p-da73fc9b.entry.js +1 -0
  76. package/dist/twilight-components/twilight-components.css +1 -3
  77. package/dist/twilight-components/twilight-components.esm.js +1 -125
  78. package/dist/types/components/salla-login/salla-login.d.ts +3 -3
  79. package/dist/types/components/salla-modal/salla-modal.d.ts +1 -0
  80. package/dist/types/components/salla-rating/salla-rating.d.ts +6 -23
  81. package/dist/types/components/salla-search/salla-search.d.ts +1 -1
  82. package/dist/types/components/salla-tel-input/salla-tel-input.d.ts +14 -0
  83. package/dist/types/components/salla-verify/salla-verify.d.ts +3 -1
  84. package/dist/types/components.d.ts +12 -35
  85. package/package.json +1 -1
  86. package/dist/twilight-components/app-globals-0f993ce5.js +0 -3
  87. package/dist/twilight-components/css-shim-a64b8820.js +0 -4
  88. package/dist/twilight-components/dom-d08ba8aa.js +0 -73
  89. package/dist/twilight-components/index-9c087700.js +0 -3010
  90. package/dist/twilight-components/salla-button.entry.js +0 -75
  91. package/dist/twilight-components/salla-login.entry.js +0 -3
  92. package/dist/twilight-components/salla-modal.entry.js +0 -113
  93. package/dist/twilight-components/salla-search.entry.js +0 -3
  94. package/dist/twilight-components/salla-verify.entry.js +0 -114
  95. package/dist/twilight-components/shadow-css-bc14d9fd.js +0 -389
@@ -0,0 +1,1653 @@
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 = 'twilight-components';
24
+
25
+ let contentRef;
26
+ let hostTagName;
27
+ let useNativeShadowDom = false;
28
+ let checkSlotFallbackVisibility = false;
29
+ let checkSlotRelocate = false;
30
+ let isSvgMode = false;
31
+ let queuePending = false;
32
+ const win = typeof window !== 'undefined' ? window : {};
33
+ const doc = win.document || { head: {} };
34
+ const plt = {
35
+ $flags$: 0,
36
+ $resourcesUrl$: '',
37
+ jmp: (h) => h(),
38
+ raf: (h) => requestAnimationFrame(h),
39
+ ael: (el, eventName, listener, opts) => el.addEventListener(eventName, listener, opts),
40
+ rel: (el, eventName, listener, opts) => el.removeEventListener(eventName, listener, opts),
41
+ ce: (eventName, opts) => new CustomEvent(eventName, opts),
42
+ };
43
+ const promiseResolve = (v) => Promise.resolve(v);
44
+ const supportsConstructibleStylesheets = /*@__PURE__*/ (() => {
45
+ try {
46
+ new CSSStyleSheet();
47
+ return typeof new CSSStyleSheet().replace === 'function';
48
+ }
49
+ catch (e) { }
50
+ return false;
51
+ })()
52
+ ;
53
+ const addHostEventListeners = (elm, hostRef, listeners, attachParentListeners) => {
54
+ if (listeners) {
55
+ listeners.map(([flags, name, method]) => {
56
+ const target = elm;
57
+ const handler = hostListenerProxy(hostRef, method);
58
+ const opts = hostListenerOpts(flags);
59
+ plt.ael(target, name, handler, opts);
60
+ (hostRef.$rmListeners$ = hostRef.$rmListeners$ || []).push(() => plt.rel(target, name, handler, opts));
61
+ });
62
+ }
63
+ };
64
+ const hostListenerProxy = (hostRef, methodName) => (ev) => {
65
+ try {
66
+ {
67
+ if (hostRef.$flags$ & 256 /* isListenReady */) {
68
+ // instance is ready, let's call it's member method for this event
69
+ hostRef.$lazyInstance$[methodName](ev);
70
+ }
71
+ else {
72
+ (hostRef.$queuedListeners$ = hostRef.$queuedListeners$ || []).push([methodName, ev]);
73
+ }
74
+ }
75
+ }
76
+ catch (e) {
77
+ consoleError(e);
78
+ }
79
+ };
80
+ // prettier-ignore
81
+ const hostListenerOpts = (flags) => (flags & 2 /* Capture */) !== 0;
82
+ const HYDRATED_CSS = '{visibility:hidden}.hydrated{visibility:inherit}';
83
+ const XLINK_NS = 'http://www.w3.org/1999/xlink';
84
+ const createTime = (fnName, tagName = '') => {
85
+ {
86
+ return () => {
87
+ return;
88
+ };
89
+ }
90
+ };
91
+ const uniqueTime = (key, measureText) => {
92
+ {
93
+ return () => {
94
+ return;
95
+ };
96
+ }
97
+ };
98
+ const rootAppliedStyles = new WeakMap();
99
+ const registerStyle = (scopeId, cssText, allowCS) => {
100
+ let style = styles.get(scopeId);
101
+ if (supportsConstructibleStylesheets && allowCS) {
102
+ style = (style || new CSSStyleSheet());
103
+ style.replace(cssText);
104
+ }
105
+ else {
106
+ style = cssText;
107
+ }
108
+ styles.set(scopeId, style);
109
+ };
110
+ const addStyle = (styleContainerNode, cmpMeta, mode, hostElm) => {
111
+ let scopeId = getScopeId(cmpMeta);
112
+ let style = styles.get(scopeId);
113
+ // if an element is NOT connected then getRootNode() will return the wrong root node
114
+ // so the fallback is to always use the document for the root node in those cases
115
+ styleContainerNode = styleContainerNode.nodeType === 11 /* DocumentFragment */ ? styleContainerNode : doc;
116
+ if (style) {
117
+ if (typeof style === 'string') {
118
+ styleContainerNode = styleContainerNode.head || styleContainerNode;
119
+ let appliedStyles = rootAppliedStyles.get(styleContainerNode);
120
+ let styleElm;
121
+ if (!appliedStyles) {
122
+ rootAppliedStyles.set(styleContainerNode, (appliedStyles = new Set()));
123
+ }
124
+ if (!appliedStyles.has(scopeId)) {
125
+ {
126
+ {
127
+ styleElm = doc.createElement('style');
128
+ styleElm.innerHTML = style;
129
+ }
130
+ styleContainerNode.insertBefore(styleElm, styleContainerNode.querySelector('link'));
131
+ }
132
+ if (appliedStyles) {
133
+ appliedStyles.add(scopeId);
134
+ }
135
+ }
136
+ }
137
+ else if (!styleContainerNode.adoptedStyleSheets.includes(style)) {
138
+ styleContainerNode.adoptedStyleSheets = [...styleContainerNode.adoptedStyleSheets, style];
139
+ }
140
+ }
141
+ return scopeId;
142
+ };
143
+ const attachStyles = (hostRef) => {
144
+ const cmpMeta = hostRef.$cmpMeta$;
145
+ const elm = hostRef.$hostElement$;
146
+ const endAttachStyles = createTime('attachStyles', cmpMeta.$tagName$);
147
+ addStyle(elm.getRootNode(), cmpMeta);
148
+ endAttachStyles();
149
+ };
150
+ const getScopeId = (cmp, mode) => 'sc-' + (cmp.$tagName$);
151
+ /**
152
+ * Default style mode id
153
+ */
154
+ /**
155
+ * Reusable empty obj/array
156
+ * Don't add values to these!!
157
+ */
158
+ const EMPTY_OBJ = {};
159
+ const isComplexType = (o) => {
160
+ // https://jsperf.com/typeof-fn-object/5
161
+ o = typeof o;
162
+ return o === 'object' || o === 'function';
163
+ };
164
+ /**
165
+ * Production h() function based on Preact by
166
+ * Jason Miller (@developit)
167
+ * Licensed under the MIT License
168
+ * https://github.com/developit/preact/blob/master/LICENSE
169
+ *
170
+ * Modified for Stencil's compiler and vdom
171
+ */
172
+ // const stack: any[] = [];
173
+ // export function h(nodeName: string | d.FunctionalComponent, vnodeData: d.PropsType, child?: d.ChildType): d.VNode;
174
+ // export function h(nodeName: string | d.FunctionalComponent, vnodeData: d.PropsType, ...children: d.ChildType[]): d.VNode;
175
+ const h = (nodeName, vnodeData, ...children) => {
176
+ let child = null;
177
+ let key = null;
178
+ let slotName = null;
179
+ let simple = false;
180
+ let lastSimple = false;
181
+ let vNodeChildren = [];
182
+ const walk = (c) => {
183
+ for (let i = 0; i < c.length; i++) {
184
+ child = c[i];
185
+ if (Array.isArray(child)) {
186
+ walk(child);
187
+ }
188
+ else if (child != null && typeof child !== 'boolean') {
189
+ if ((simple = typeof nodeName !== 'function' && !isComplexType(child))) {
190
+ child = String(child);
191
+ }
192
+ if (simple && lastSimple) {
193
+ // If the previous child was simple (string), we merge both
194
+ vNodeChildren[vNodeChildren.length - 1].$text$ += child;
195
+ }
196
+ else {
197
+ // Append a new vNode, if it's text, we create a text vNode
198
+ vNodeChildren.push(simple ? newVNode(null, child) : child);
199
+ }
200
+ lastSimple = simple;
201
+ }
202
+ }
203
+ };
204
+ walk(children);
205
+ if (vnodeData) {
206
+ // normalize class / classname attributes
207
+ if (vnodeData.key) {
208
+ key = vnodeData.key;
209
+ }
210
+ if (vnodeData.name) {
211
+ slotName = vnodeData.name;
212
+ }
213
+ {
214
+ const classData = vnodeData.className || vnodeData.class;
215
+ if (classData) {
216
+ vnodeData.class =
217
+ typeof classData !== 'object'
218
+ ? classData
219
+ : Object.keys(classData)
220
+ .filter((k) => classData[k])
221
+ .join(' ');
222
+ }
223
+ }
224
+ }
225
+ const vnode = newVNode(nodeName, null);
226
+ vnode.$attrs$ = vnodeData;
227
+ if (vNodeChildren.length > 0) {
228
+ vnode.$children$ = vNodeChildren;
229
+ }
230
+ {
231
+ vnode.$key$ = key;
232
+ }
233
+ {
234
+ vnode.$name$ = slotName;
235
+ }
236
+ return vnode;
237
+ };
238
+ const newVNode = (tag, text) => {
239
+ const vnode = {
240
+ $flags$: 0,
241
+ $tag$: tag,
242
+ $text$: text,
243
+ $elm$: null,
244
+ $children$: null,
245
+ };
246
+ {
247
+ vnode.$attrs$ = null;
248
+ }
249
+ {
250
+ vnode.$key$ = null;
251
+ }
252
+ {
253
+ vnode.$name$ = null;
254
+ }
255
+ return vnode;
256
+ };
257
+ const Host = {};
258
+ const isHost = (node) => node && node.$tag$ === Host;
259
+ /**
260
+ * Production setAccessor() function based on Preact by
261
+ * Jason Miller (@developit)
262
+ * Licensed under the MIT License
263
+ * https://github.com/developit/preact/blob/master/LICENSE
264
+ *
265
+ * Modified for Stencil's compiler and vdom
266
+ */
267
+ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
268
+ if (oldValue !== newValue) {
269
+ let isProp = isMemberInElement(elm, memberName);
270
+ let ln = memberName.toLowerCase();
271
+ if (memberName === 'class') {
272
+ const classList = elm.classList;
273
+ const oldClasses = parseClassList(oldValue);
274
+ const newClasses = parseClassList(newValue);
275
+ classList.remove(...oldClasses.filter((c) => c && !newClasses.includes(c)));
276
+ classList.add(...newClasses.filter((c) => c && !oldClasses.includes(c)));
277
+ }
278
+ else if (memberName === 'style') {
279
+ // update style attribute, css properties and values
280
+ {
281
+ for (const prop in oldValue) {
282
+ if (!newValue || newValue[prop] == null) {
283
+ if (prop.includes('-')) {
284
+ elm.style.removeProperty(prop);
285
+ }
286
+ else {
287
+ elm.style[prop] = '';
288
+ }
289
+ }
290
+ }
291
+ }
292
+ for (const prop in newValue) {
293
+ if (!oldValue || newValue[prop] !== oldValue[prop]) {
294
+ if (prop.includes('-')) {
295
+ elm.style.setProperty(prop, newValue[prop]);
296
+ }
297
+ else {
298
+ elm.style[prop] = newValue[prop];
299
+ }
300
+ }
301
+ }
302
+ }
303
+ else if (memberName === 'key')
304
+ ;
305
+ else if (memberName === 'ref') {
306
+ // minifier will clean this up
307
+ if (newValue) {
308
+ newValue(elm);
309
+ }
310
+ }
311
+ else if ((!isProp ) &&
312
+ memberName[0] === 'o' &&
313
+ memberName[1] === 'n') {
314
+ // Event Handlers
315
+ // so if the member name starts with "on" and the 3rd characters is
316
+ // a capital letter, and it's not already a member on the element,
317
+ // then we're assuming it's an event listener
318
+ if (memberName[2] === '-') {
319
+ // on- prefixed events
320
+ // allows to be explicit about the dom event to listen without any magic
321
+ // under the hood:
322
+ // <my-cmp on-click> // listens for "click"
323
+ // <my-cmp on-Click> // listens for "Click"
324
+ // <my-cmp on-ionChange> // listens for "ionChange"
325
+ // <my-cmp on-EVENTS> // listens for "EVENTS"
326
+ memberName = memberName.slice(3);
327
+ }
328
+ else if (isMemberInElement(win, ln)) {
329
+ // standard event
330
+ // the JSX attribute could have been "onMouseOver" and the
331
+ // member name "onmouseover" is on the window's prototype
332
+ // so let's add the listener "mouseover", which is all lowercased
333
+ memberName = ln.slice(2);
334
+ }
335
+ else {
336
+ // custom event
337
+ // the JSX attribute could have been "onMyCustomEvent"
338
+ // so let's trim off the "on" prefix and lowercase the first character
339
+ // and add the listener "myCustomEvent"
340
+ // except for the first character, we keep the event name case
341
+ memberName = ln[2] + memberName.slice(3);
342
+ }
343
+ if (oldValue) {
344
+ plt.rel(elm, memberName, oldValue, false);
345
+ }
346
+ if (newValue) {
347
+ plt.ael(elm, memberName, newValue, false);
348
+ }
349
+ }
350
+ else {
351
+ // Set property if it exists and it's not a SVG
352
+ const isComplex = isComplexType(newValue);
353
+ if ((isProp || (isComplex && newValue !== null)) && !isSvg) {
354
+ try {
355
+ if (!elm.tagName.includes('-')) {
356
+ let n = newValue == null ? '' : newValue;
357
+ // Workaround for Safari, moving the <input> caret when re-assigning the same valued
358
+ if (memberName === 'list') {
359
+ isProp = false;
360
+ // tslint:disable-next-line: triple-equals
361
+ }
362
+ else if (oldValue == null || elm[memberName] != n) {
363
+ elm[memberName] = n;
364
+ }
365
+ }
366
+ else {
367
+ elm[memberName] = newValue;
368
+ }
369
+ }
370
+ catch (e) { }
371
+ }
372
+ /**
373
+ * Need to manually update attribute if:
374
+ * - memberName is not an attribute
375
+ * - if we are rendering the host element in order to reflect attribute
376
+ * - if it's a SVG, since properties might not work in <svg>
377
+ * - if the newValue is null/undefined or 'false'.
378
+ */
379
+ let xlink = false;
380
+ {
381
+ if (ln !== (ln = ln.replace(/^xlink\:?/, ''))) {
382
+ memberName = ln;
383
+ xlink = true;
384
+ }
385
+ }
386
+ if (newValue == null || newValue === false) {
387
+ if (newValue !== false || elm.getAttribute(memberName) === '') {
388
+ if (xlink) {
389
+ elm.removeAttributeNS(XLINK_NS, memberName);
390
+ }
391
+ else {
392
+ elm.removeAttribute(memberName);
393
+ }
394
+ }
395
+ }
396
+ else if ((!isProp || flags & 4 /* isHost */ || isSvg) && !isComplex) {
397
+ newValue = newValue === true ? '' : newValue;
398
+ if (xlink) {
399
+ elm.setAttributeNS(XLINK_NS, memberName, newValue);
400
+ }
401
+ else {
402
+ elm.setAttribute(memberName, newValue);
403
+ }
404
+ }
405
+ }
406
+ }
407
+ };
408
+ const parseClassListRegex = /\s/;
409
+ const parseClassList = (value) => (!value ? [] : value.split(parseClassListRegex));
410
+ const updateElement = (oldVnode, newVnode, isSvgMode, memberName) => {
411
+ // if the element passed in is a shadow root, which is a document fragment
412
+ // then we want to be adding attrs/props to the shadow root's "host" element
413
+ // if it's not a shadow root, then we add attrs/props to the same element
414
+ const elm = newVnode.$elm$.nodeType === 11 /* DocumentFragment */ && newVnode.$elm$.host
415
+ ? newVnode.$elm$.host
416
+ : newVnode.$elm$;
417
+ const oldVnodeAttrs = (oldVnode && oldVnode.$attrs$) || EMPTY_OBJ;
418
+ const newVnodeAttrs = newVnode.$attrs$ || EMPTY_OBJ;
419
+ {
420
+ // remove attributes no longer present on the vnode by setting them to undefined
421
+ for (memberName in oldVnodeAttrs) {
422
+ if (!(memberName in newVnodeAttrs)) {
423
+ setAccessor(elm, memberName, oldVnodeAttrs[memberName], undefined, isSvgMode, newVnode.$flags$);
424
+ }
425
+ }
426
+ }
427
+ // add new & update changed attributes
428
+ for (memberName in newVnodeAttrs) {
429
+ setAccessor(elm, memberName, oldVnodeAttrs[memberName], newVnodeAttrs[memberName], isSvgMode, newVnode.$flags$);
430
+ }
431
+ };
432
+ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
433
+ // tslint:disable-next-line: prefer-const
434
+ let newVNode = newParentVNode.$children$[childIndex];
435
+ let i = 0;
436
+ let elm;
437
+ let childNode;
438
+ let oldVNode;
439
+ if (!useNativeShadowDom) {
440
+ // remember for later we need to check to relocate nodes
441
+ checkSlotRelocate = true;
442
+ if (newVNode.$tag$ === 'slot') {
443
+ newVNode.$flags$ |= newVNode.$children$
444
+ ? // slot element has fallback content
445
+ 2 /* isSlotFallback */
446
+ : // slot element does not have fallback content
447
+ 1 /* isSlotReference */;
448
+ }
449
+ }
450
+ if (newVNode.$text$ !== null) {
451
+ // create text node
452
+ elm = newVNode.$elm$ = doc.createTextNode(newVNode.$text$);
453
+ }
454
+ else if (newVNode.$flags$ & 1 /* isSlotReference */) {
455
+ // create a slot reference node
456
+ elm = newVNode.$elm$ =
457
+ doc.createTextNode('');
458
+ }
459
+ else {
460
+ // create element
461
+ elm = newVNode.$elm$ = (doc.createElement(newVNode.$flags$ & 2 /* isSlotFallback */
462
+ ? 'slot-fb'
463
+ : newVNode.$tag$));
464
+ // add css classes, attrs, props, listeners, etc.
465
+ {
466
+ updateElement(null, newVNode, isSvgMode);
467
+ }
468
+ if (newVNode.$children$) {
469
+ for (i = 0; i < newVNode.$children$.length; ++i) {
470
+ // create the node
471
+ childNode = createElm(oldParentVNode, newVNode, i);
472
+ // return node could have been null
473
+ if (childNode) {
474
+ // append our new node
475
+ elm.appendChild(childNode);
476
+ }
477
+ }
478
+ }
479
+ }
480
+ {
481
+ elm['s-hn'] = hostTagName;
482
+ if (newVNode.$flags$ & (2 /* isSlotFallback */ | 1 /* isSlotReference */)) {
483
+ // remember the content reference comment
484
+ elm['s-sr'] = true;
485
+ // remember the content reference comment
486
+ elm['s-cr'] = contentRef;
487
+ // remember the slot name, or empty string for default slot
488
+ elm['s-sn'] = newVNode.$name$ || '';
489
+ // check if we've got an old vnode for this slot
490
+ oldVNode = oldParentVNode && oldParentVNode.$children$ && oldParentVNode.$children$[childIndex];
491
+ if (oldVNode && oldVNode.$tag$ === newVNode.$tag$ && oldParentVNode.$elm$) {
492
+ // we've got an old slot vnode and the wrapper is being replaced
493
+ // so let's move the old slot content back to it's original location
494
+ putBackInOriginalLocation(oldParentVNode.$elm$, false);
495
+ }
496
+ }
497
+ }
498
+ return elm;
499
+ };
500
+ const putBackInOriginalLocation = (parentElm, recursive) => {
501
+ plt.$flags$ |= 1 /* isTmpDisconnected */;
502
+ const oldSlotChildNodes = parentElm.childNodes;
503
+ for (let i = oldSlotChildNodes.length - 1; i >= 0; i--) {
504
+ const childNode = oldSlotChildNodes[i];
505
+ if (childNode['s-hn'] !== hostTagName && childNode['s-ol']) {
506
+ // // this child node in the old element is from another component
507
+ // // remove this node from the old slot's parent
508
+ // childNode.remove();
509
+ // and relocate it back to it's original location
510
+ parentReferenceNode(childNode).insertBefore(childNode, referenceNode(childNode));
511
+ // remove the old original location comment entirely
512
+ // later on the patch function will know what to do
513
+ // and move this to the correct spot in need be
514
+ childNode['s-ol'].remove();
515
+ childNode['s-ol'] = undefined;
516
+ checkSlotRelocate = true;
517
+ }
518
+ if (recursive) {
519
+ putBackInOriginalLocation(childNode, recursive);
520
+ }
521
+ }
522
+ plt.$flags$ &= ~1 /* isTmpDisconnected */;
523
+ };
524
+ const addVnodes = (parentElm, before, parentVNode, vnodes, startIdx, endIdx) => {
525
+ let containerElm = ((parentElm['s-cr'] && parentElm['s-cr'].parentNode) || parentElm);
526
+ let childNode;
527
+ for (; startIdx <= endIdx; ++startIdx) {
528
+ if (vnodes[startIdx]) {
529
+ childNode = createElm(null, parentVNode, startIdx);
530
+ if (childNode) {
531
+ vnodes[startIdx].$elm$ = childNode;
532
+ containerElm.insertBefore(childNode, referenceNode(before) );
533
+ }
534
+ }
535
+ }
536
+ };
537
+ const removeVnodes = (vnodes, startIdx, endIdx, vnode, elm) => {
538
+ for (; startIdx <= endIdx; ++startIdx) {
539
+ if ((vnode = vnodes[startIdx])) {
540
+ elm = vnode.$elm$;
541
+ callNodeRefs(vnode);
542
+ {
543
+ // we're removing this element
544
+ // so it's possible we need to show slot fallback content now
545
+ checkSlotFallbackVisibility = true;
546
+ if (elm['s-ol']) {
547
+ // remove the original location comment
548
+ elm['s-ol'].remove();
549
+ }
550
+ else {
551
+ // it's possible that child nodes of the node
552
+ // that's being removed are slot nodes
553
+ putBackInOriginalLocation(elm, true);
554
+ }
555
+ }
556
+ // remove the vnode's element from the dom
557
+ elm.remove();
558
+ }
559
+ }
560
+ };
561
+ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
562
+ let oldStartIdx = 0;
563
+ let newStartIdx = 0;
564
+ let idxInOld = 0;
565
+ let i = 0;
566
+ let oldEndIdx = oldCh.length - 1;
567
+ let oldStartVnode = oldCh[0];
568
+ let oldEndVnode = oldCh[oldEndIdx];
569
+ let newEndIdx = newCh.length - 1;
570
+ let newStartVnode = newCh[0];
571
+ let newEndVnode = newCh[newEndIdx];
572
+ let node;
573
+ let elmToMove;
574
+ while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
575
+ if (oldStartVnode == null) {
576
+ // Vnode might have been moved left
577
+ oldStartVnode = oldCh[++oldStartIdx];
578
+ }
579
+ else if (oldEndVnode == null) {
580
+ oldEndVnode = oldCh[--oldEndIdx];
581
+ }
582
+ else if (newStartVnode == null) {
583
+ newStartVnode = newCh[++newStartIdx];
584
+ }
585
+ else if (newEndVnode == null) {
586
+ newEndVnode = newCh[--newEndIdx];
587
+ }
588
+ else if (isSameVnode(oldStartVnode, newStartVnode)) {
589
+ patch(oldStartVnode, newStartVnode);
590
+ oldStartVnode = oldCh[++oldStartIdx];
591
+ newStartVnode = newCh[++newStartIdx];
592
+ }
593
+ else if (isSameVnode(oldEndVnode, newEndVnode)) {
594
+ patch(oldEndVnode, newEndVnode);
595
+ oldEndVnode = oldCh[--oldEndIdx];
596
+ newEndVnode = newCh[--newEndIdx];
597
+ }
598
+ else if (isSameVnode(oldStartVnode, newEndVnode)) {
599
+ // Vnode moved right
600
+ if ((oldStartVnode.$tag$ === 'slot' || newEndVnode.$tag$ === 'slot')) {
601
+ putBackInOriginalLocation(oldStartVnode.$elm$.parentNode, false);
602
+ }
603
+ patch(oldStartVnode, newEndVnode);
604
+ parentElm.insertBefore(oldStartVnode.$elm$, oldEndVnode.$elm$.nextSibling);
605
+ oldStartVnode = oldCh[++oldStartIdx];
606
+ newEndVnode = newCh[--newEndIdx];
607
+ }
608
+ else if (isSameVnode(oldEndVnode, newStartVnode)) {
609
+ // Vnode moved left
610
+ if ((oldStartVnode.$tag$ === 'slot' || newEndVnode.$tag$ === 'slot')) {
611
+ putBackInOriginalLocation(oldEndVnode.$elm$.parentNode, false);
612
+ }
613
+ patch(oldEndVnode, newStartVnode);
614
+ parentElm.insertBefore(oldEndVnode.$elm$, oldStartVnode.$elm$);
615
+ oldEndVnode = oldCh[--oldEndIdx];
616
+ newStartVnode = newCh[++newStartIdx];
617
+ }
618
+ else {
619
+ // createKeyToOldIdx
620
+ idxInOld = -1;
621
+ {
622
+ for (i = oldStartIdx; i <= oldEndIdx; ++i) {
623
+ if (oldCh[i] && oldCh[i].$key$ !== null && oldCh[i].$key$ === newStartVnode.$key$) {
624
+ idxInOld = i;
625
+ break;
626
+ }
627
+ }
628
+ }
629
+ if (idxInOld >= 0) {
630
+ elmToMove = oldCh[idxInOld];
631
+ if (elmToMove.$tag$ !== newStartVnode.$tag$) {
632
+ node = createElm(oldCh && oldCh[newStartIdx], newVNode, idxInOld);
633
+ }
634
+ else {
635
+ patch(elmToMove, newStartVnode);
636
+ oldCh[idxInOld] = undefined;
637
+ node = elmToMove.$elm$;
638
+ }
639
+ newStartVnode = newCh[++newStartIdx];
640
+ }
641
+ else {
642
+ // new element
643
+ node = createElm(oldCh && oldCh[newStartIdx], newVNode, newStartIdx);
644
+ newStartVnode = newCh[++newStartIdx];
645
+ }
646
+ if (node) {
647
+ {
648
+ parentReferenceNode(oldStartVnode.$elm$).insertBefore(node, referenceNode(oldStartVnode.$elm$));
649
+ }
650
+ }
651
+ }
652
+ }
653
+ if (oldStartIdx > oldEndIdx) {
654
+ addVnodes(parentElm, newCh[newEndIdx + 1] == null ? null : newCh[newEndIdx + 1].$elm$, newVNode, newCh, newStartIdx, newEndIdx);
655
+ }
656
+ else if (newStartIdx > newEndIdx) {
657
+ removeVnodes(oldCh, oldStartIdx, oldEndIdx);
658
+ }
659
+ };
660
+ const isSameVnode = (vnode1, vnode2) => {
661
+ // compare if two vnode to see if they're "technically" the same
662
+ // need to have the same element tag, and same key to be the same
663
+ if (vnode1.$tag$ === vnode2.$tag$) {
664
+ if (vnode1.$tag$ === 'slot') {
665
+ return vnode1.$name$ === vnode2.$name$;
666
+ }
667
+ {
668
+ return vnode1.$key$ === vnode2.$key$;
669
+ }
670
+ }
671
+ return false;
672
+ };
673
+ const referenceNode = (node) => {
674
+ // this node was relocated to a new location in the dom
675
+ // because of some other component's slot
676
+ // but we still have an html comment in place of where
677
+ // it's original location was according to it's original vdom
678
+ return (node && node['s-ol']) || node;
679
+ };
680
+ const parentReferenceNode = (node) => (node['s-ol'] ? node['s-ol'] : node).parentNode;
681
+ const patch = (oldVNode, newVNode) => {
682
+ const elm = (newVNode.$elm$ = oldVNode.$elm$);
683
+ const oldChildren = oldVNode.$children$;
684
+ const newChildren = newVNode.$children$;
685
+ const tag = newVNode.$tag$;
686
+ const text = newVNode.$text$;
687
+ let defaultHolder;
688
+ if (text === null) {
689
+ // element node
690
+ {
691
+ if (tag === 'slot')
692
+ ;
693
+ else {
694
+ // either this is the first render of an element OR it's an update
695
+ // AND we already know it's possible it could have changed
696
+ // this updates the element's css classes, attrs, props, listeners, etc.
697
+ updateElement(oldVNode, newVNode, isSvgMode);
698
+ }
699
+ }
700
+ if (oldChildren !== null && newChildren !== null) {
701
+ // looks like there's child vnodes for both the old and new vnodes
702
+ updateChildren(elm, oldChildren, newVNode, newChildren);
703
+ }
704
+ else if (newChildren !== null) {
705
+ // no old child vnodes, but there are new child vnodes to add
706
+ if (oldVNode.$text$ !== null) {
707
+ // the old vnode was text, so be sure to clear it out
708
+ elm.textContent = '';
709
+ }
710
+ // add the new vnode children
711
+ addVnodes(elm, null, newVNode, newChildren, 0, newChildren.length - 1);
712
+ }
713
+ else if (oldChildren !== null) {
714
+ // no new child vnodes, but there are old child vnodes to remove
715
+ removeVnodes(oldChildren, 0, oldChildren.length - 1);
716
+ }
717
+ }
718
+ else if ((defaultHolder = elm['s-cr'])) {
719
+ // this element has slotted content
720
+ defaultHolder.parentNode.textContent = text;
721
+ }
722
+ else if (oldVNode.$text$ !== text) {
723
+ // update the text content for the text only vnode
724
+ // and also only if the text is different than before
725
+ elm.data = text;
726
+ }
727
+ };
728
+ const updateFallbackSlotVisibility = (elm) => {
729
+ // tslint:disable-next-line: prefer-const
730
+ let childNodes = elm.childNodes;
731
+ let childNode;
732
+ let i;
733
+ let ilen;
734
+ let j;
735
+ let slotNameAttr;
736
+ let nodeType;
737
+ for (i = 0, ilen = childNodes.length; i < ilen; i++) {
738
+ childNode = childNodes[i];
739
+ if (childNode.nodeType === 1 /* ElementNode */) {
740
+ if (childNode['s-sr']) {
741
+ // this is a slot fallback node
742
+ // get the slot name for this slot reference node
743
+ slotNameAttr = childNode['s-sn'];
744
+ // by default always show a fallback slot node
745
+ // then hide it if there are other slots in the light dom
746
+ childNode.hidden = false;
747
+ for (j = 0; j < ilen; j++) {
748
+ nodeType = childNodes[j].nodeType;
749
+ if (childNodes[j]['s-hn'] !== childNode['s-hn'] || slotNameAttr !== '') {
750
+ // this sibling node is from a different component OR is a named fallback slot node
751
+ if (nodeType === 1 /* ElementNode */ && slotNameAttr === childNodes[j].getAttribute('slot')) {
752
+ childNode.hidden = true;
753
+ break;
754
+ }
755
+ }
756
+ else {
757
+ // this is a default fallback slot node
758
+ // any element or text node (with content)
759
+ // should hide the default fallback slot node
760
+ if (nodeType === 1 /* ElementNode */ ||
761
+ (nodeType === 3 /* TextNode */ && childNodes[j].textContent.trim() !== '')) {
762
+ childNode.hidden = true;
763
+ break;
764
+ }
765
+ }
766
+ }
767
+ }
768
+ // keep drilling down
769
+ updateFallbackSlotVisibility(childNode);
770
+ }
771
+ }
772
+ };
773
+ const relocateNodes = [];
774
+ const relocateSlotContent = (elm) => {
775
+ // tslint:disable-next-line: prefer-const
776
+ let childNode;
777
+ let node;
778
+ let hostContentNodes;
779
+ let slotNameAttr;
780
+ let relocateNodeData;
781
+ let j;
782
+ let i = 0;
783
+ let childNodes = elm.childNodes;
784
+ let ilen = childNodes.length;
785
+ for (; i < ilen; i++) {
786
+ childNode = childNodes[i];
787
+ if (childNode['s-sr'] && (node = childNode['s-cr']) && node.parentNode) {
788
+ // first got the content reference comment node
789
+ // then we got it's parent, which is where all the host content is in now
790
+ hostContentNodes = node.parentNode.childNodes;
791
+ slotNameAttr = childNode['s-sn'];
792
+ for (j = hostContentNodes.length - 1; j >= 0; j--) {
793
+ node = hostContentNodes[j];
794
+ if (!node['s-cn'] && !node['s-nr'] && node['s-hn'] !== childNode['s-hn']) {
795
+ // let's do some relocating to its new home
796
+ // but never relocate a content reference node
797
+ // that is suppose to always represent the original content location
798
+ if (isNodeLocatedInSlot(node, slotNameAttr)) {
799
+ // it's possible we've already decided to relocate this node
800
+ relocateNodeData = relocateNodes.find((r) => r.$nodeToRelocate$ === node);
801
+ // made some changes to slots
802
+ // let's make sure we also double check
803
+ // fallbacks are correctly hidden or shown
804
+ checkSlotFallbackVisibility = true;
805
+ node['s-sn'] = node['s-sn'] || slotNameAttr;
806
+ if (relocateNodeData) {
807
+ // previously we never found a slot home for this node
808
+ // but turns out we did, so let's remember it now
809
+ relocateNodeData.$slotRefNode$ = childNode;
810
+ }
811
+ else {
812
+ // add to our list of nodes to relocate
813
+ relocateNodes.push({
814
+ $slotRefNode$: childNode,
815
+ $nodeToRelocate$: node,
816
+ });
817
+ }
818
+ if (node['s-sr']) {
819
+ relocateNodes.map((relocateNode) => {
820
+ if (isNodeLocatedInSlot(relocateNode.$nodeToRelocate$, node['s-sn'])) {
821
+ relocateNodeData = relocateNodes.find((r) => r.$nodeToRelocate$ === node);
822
+ if (relocateNodeData && !relocateNode.$slotRefNode$) {
823
+ relocateNode.$slotRefNode$ = relocateNodeData.$slotRefNode$;
824
+ }
825
+ }
826
+ });
827
+ }
828
+ }
829
+ else if (!relocateNodes.some((r) => r.$nodeToRelocate$ === node)) {
830
+ // so far this element does not have a slot home, not setting slotRefNode on purpose
831
+ // if we never find a home for this element then we'll need to hide it
832
+ relocateNodes.push({
833
+ $nodeToRelocate$: node,
834
+ });
835
+ }
836
+ }
837
+ }
838
+ }
839
+ if (childNode.nodeType === 1 /* ElementNode */) {
840
+ relocateSlotContent(childNode);
841
+ }
842
+ }
843
+ };
844
+ const isNodeLocatedInSlot = (nodeToRelocate, slotNameAttr) => {
845
+ if (nodeToRelocate.nodeType === 1 /* ElementNode */) {
846
+ if (nodeToRelocate.getAttribute('slot') === null && slotNameAttr === '') {
847
+ return true;
848
+ }
849
+ if (nodeToRelocate.getAttribute('slot') === slotNameAttr) {
850
+ return true;
851
+ }
852
+ return false;
853
+ }
854
+ if (nodeToRelocate['s-sn'] === slotNameAttr) {
855
+ return true;
856
+ }
857
+ return slotNameAttr === '';
858
+ };
859
+ const callNodeRefs = (vNode) => {
860
+ {
861
+ vNode.$attrs$ && vNode.$attrs$.ref && vNode.$attrs$.ref(null);
862
+ vNode.$children$ && vNode.$children$.map(callNodeRefs);
863
+ }
864
+ };
865
+ const renderVdom = (hostRef, renderFnResults) => {
866
+ const hostElm = hostRef.$hostElement$;
867
+ const cmpMeta = hostRef.$cmpMeta$;
868
+ const oldVNode = hostRef.$vnode$ || newVNode(null, null);
869
+ const rootVnode = isHost(renderFnResults) ? renderFnResults : h(null, null, renderFnResults);
870
+ hostTagName = hostElm.tagName;
871
+ if (cmpMeta.$attrsToReflect$) {
872
+ rootVnode.$attrs$ = rootVnode.$attrs$ || {};
873
+ cmpMeta.$attrsToReflect$.map(([propName, attribute]) => (rootVnode.$attrs$[attribute] = hostElm[propName]));
874
+ }
875
+ rootVnode.$tag$ = null;
876
+ rootVnode.$flags$ |= 4 /* isHost */;
877
+ hostRef.$vnode$ = rootVnode;
878
+ rootVnode.$elm$ = oldVNode.$elm$ = (hostElm);
879
+ {
880
+ contentRef = hostElm['s-cr'];
881
+ useNativeShadowDom = (cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) !== 0;
882
+ // always reset
883
+ checkSlotFallbackVisibility = false;
884
+ }
885
+ // synchronous patch
886
+ patch(oldVNode, rootVnode);
887
+ {
888
+ // while we're moving nodes around existing nodes, temporarily disable
889
+ // the disconnectCallback from working
890
+ plt.$flags$ |= 1 /* isTmpDisconnected */;
891
+ if (checkSlotRelocate) {
892
+ relocateSlotContent(rootVnode.$elm$);
893
+ let relocateData;
894
+ let nodeToRelocate;
895
+ let orgLocationNode;
896
+ let parentNodeRef;
897
+ let insertBeforeNode;
898
+ let refNode;
899
+ let i = 0;
900
+ for (; i < relocateNodes.length; i++) {
901
+ relocateData = relocateNodes[i];
902
+ nodeToRelocate = relocateData.$nodeToRelocate$;
903
+ if (!nodeToRelocate['s-ol']) {
904
+ // add a reference node marking this node's original location
905
+ // keep a reference to this node for later lookups
906
+ orgLocationNode =
907
+ doc.createTextNode('');
908
+ orgLocationNode['s-nr'] = nodeToRelocate;
909
+ nodeToRelocate.parentNode.insertBefore((nodeToRelocate['s-ol'] = orgLocationNode), nodeToRelocate);
910
+ }
911
+ }
912
+ for (i = 0; i < relocateNodes.length; i++) {
913
+ relocateData = relocateNodes[i];
914
+ nodeToRelocate = relocateData.$nodeToRelocate$;
915
+ if (relocateData.$slotRefNode$) {
916
+ // by default we're just going to insert it directly
917
+ // after the slot reference node
918
+ parentNodeRef = relocateData.$slotRefNode$.parentNode;
919
+ insertBeforeNode = relocateData.$slotRefNode$.nextSibling;
920
+ orgLocationNode = nodeToRelocate['s-ol'];
921
+ while ((orgLocationNode = orgLocationNode.previousSibling)) {
922
+ refNode = orgLocationNode['s-nr'];
923
+ if (refNode && refNode['s-sn'] === nodeToRelocate['s-sn'] && parentNodeRef === refNode.parentNode) {
924
+ refNode = refNode.nextSibling;
925
+ if (!refNode || !refNode['s-nr']) {
926
+ insertBeforeNode = refNode;
927
+ break;
928
+ }
929
+ }
930
+ }
931
+ if ((!insertBeforeNode && parentNodeRef !== nodeToRelocate.parentNode) ||
932
+ nodeToRelocate.nextSibling !== insertBeforeNode) {
933
+ // we've checked that it's worth while to relocate
934
+ // since that the node to relocate
935
+ // has a different next sibling or parent relocated
936
+ if (nodeToRelocate !== insertBeforeNode) {
937
+ if (!nodeToRelocate['s-hn'] && nodeToRelocate['s-ol']) {
938
+ // probably a component in the index.html that doesn't have it's hostname set
939
+ nodeToRelocate['s-hn'] = nodeToRelocate['s-ol'].parentNode.nodeName;
940
+ }
941
+ // add it back to the dom but in its new home
942
+ parentNodeRef.insertBefore(nodeToRelocate, insertBeforeNode);
943
+ }
944
+ }
945
+ }
946
+ else {
947
+ // this node doesn't have a slot home to go to, so let's hide it
948
+ if (nodeToRelocate.nodeType === 1 /* ElementNode */) {
949
+ nodeToRelocate.hidden = true;
950
+ }
951
+ }
952
+ }
953
+ }
954
+ if (checkSlotFallbackVisibility) {
955
+ updateFallbackSlotVisibility(rootVnode.$elm$);
956
+ }
957
+ // done moving nodes around
958
+ // allow the disconnect callback to work again
959
+ plt.$flags$ &= ~1 /* isTmpDisconnected */;
960
+ // always reset
961
+ relocateNodes.length = 0;
962
+ }
963
+ };
964
+ const getElement = (ref) => (getHostRef(ref).$hostElement$ );
965
+ const createEvent = (ref, name, flags) => {
966
+ const elm = getElement(ref);
967
+ return {
968
+ emit: (detail) => {
969
+ return emitEvent(elm, name, {
970
+ bubbles: !!(flags & 4 /* Bubbles */),
971
+ composed: !!(flags & 2 /* Composed */),
972
+ cancelable: !!(flags & 1 /* Cancellable */),
973
+ detail,
974
+ });
975
+ },
976
+ };
977
+ };
978
+ /**
979
+ * Helper function to create & dispatch a custom Event on a provided target
980
+ * @param elm the target of the Event
981
+ * @param name the name to give the custom Event
982
+ * @param opts options for configuring a custom Event
983
+ * @returns the custom Event
984
+ */
985
+ const emitEvent = (elm, name, opts) => {
986
+ const ev = plt.ce(name, opts);
987
+ elm.dispatchEvent(ev);
988
+ return ev;
989
+ };
990
+ const attachToAncestor = (hostRef, ancestorComponent) => {
991
+ if (ancestorComponent && !hostRef.$onRenderResolve$ && ancestorComponent['s-p']) {
992
+ ancestorComponent['s-p'].push(new Promise((r) => (hostRef.$onRenderResolve$ = r)));
993
+ }
994
+ };
995
+ const scheduleUpdate = (hostRef, isInitialLoad) => {
996
+ {
997
+ hostRef.$flags$ |= 16 /* isQueuedForUpdate */;
998
+ }
999
+ if (hostRef.$flags$ & 4 /* isWaitingForChildren */) {
1000
+ hostRef.$flags$ |= 512 /* needsRerender */;
1001
+ return;
1002
+ }
1003
+ attachToAncestor(hostRef, hostRef.$ancestorComponent$);
1004
+ // there is no ancestor component or the ancestor component
1005
+ // has already fired off its lifecycle update then
1006
+ // fire off the initial update
1007
+ const dispatch = () => dispatchHooks(hostRef, isInitialLoad);
1008
+ return writeTask(dispatch) ;
1009
+ };
1010
+ const dispatchHooks = (hostRef, isInitialLoad) => {
1011
+ const endSchedule = createTime('scheduleUpdate', hostRef.$cmpMeta$.$tagName$);
1012
+ const instance = hostRef.$lazyInstance$ ;
1013
+ let promise;
1014
+ if (isInitialLoad) {
1015
+ {
1016
+ hostRef.$flags$ |= 256 /* isListenReady */;
1017
+ if (hostRef.$queuedListeners$) {
1018
+ hostRef.$queuedListeners$.map(([methodName, event]) => safeCall(instance, methodName, event));
1019
+ hostRef.$queuedListeners$ = null;
1020
+ }
1021
+ }
1022
+ }
1023
+ endSchedule();
1024
+ return then(promise, () => updateComponent(hostRef, instance, isInitialLoad));
1025
+ };
1026
+ const updateComponent = async (hostRef, instance, isInitialLoad) => {
1027
+ // updateComponent
1028
+ const elm = hostRef.$hostElement$;
1029
+ const endUpdate = createTime('update', hostRef.$cmpMeta$.$tagName$);
1030
+ const rc = elm['s-rc'];
1031
+ if (isInitialLoad) {
1032
+ // DOM WRITE!
1033
+ attachStyles(hostRef);
1034
+ }
1035
+ const endRender = createTime('render', hostRef.$cmpMeta$.$tagName$);
1036
+ {
1037
+ callRender(hostRef, instance);
1038
+ }
1039
+ if (rc) {
1040
+ // ok, so turns out there are some child host elements
1041
+ // waiting on this parent element to load
1042
+ // let's fire off all update callbacks waiting
1043
+ rc.map((cb) => cb());
1044
+ elm['s-rc'] = undefined;
1045
+ }
1046
+ endRender();
1047
+ endUpdate();
1048
+ {
1049
+ const childrenPromises = elm['s-p'];
1050
+ const postUpdate = () => postUpdateComponent(hostRef);
1051
+ if (childrenPromises.length === 0) {
1052
+ postUpdate();
1053
+ }
1054
+ else {
1055
+ Promise.all(childrenPromises).then(postUpdate);
1056
+ hostRef.$flags$ |= 4 /* isWaitingForChildren */;
1057
+ childrenPromises.length = 0;
1058
+ }
1059
+ }
1060
+ };
1061
+ const callRender = (hostRef, instance, elm) => {
1062
+ try {
1063
+ instance = instance.render() ;
1064
+ {
1065
+ hostRef.$flags$ &= ~16 /* isQueuedForUpdate */;
1066
+ }
1067
+ {
1068
+ hostRef.$flags$ |= 2 /* hasRendered */;
1069
+ }
1070
+ {
1071
+ {
1072
+ // looks like we've got child nodes to render into this host element
1073
+ // or we need to update the css class/attrs on the host element
1074
+ // DOM WRITE!
1075
+ {
1076
+ renderVdom(hostRef, instance);
1077
+ }
1078
+ }
1079
+ }
1080
+ }
1081
+ catch (e) {
1082
+ consoleError(e, hostRef.$hostElement$);
1083
+ }
1084
+ return null;
1085
+ };
1086
+ const postUpdateComponent = (hostRef) => {
1087
+ const tagName = hostRef.$cmpMeta$.$tagName$;
1088
+ const elm = hostRef.$hostElement$;
1089
+ const endPostUpdate = createTime('postUpdate', tagName);
1090
+ const instance = hostRef.$lazyInstance$ ;
1091
+ const ancestorComponent = hostRef.$ancestorComponent$;
1092
+ {
1093
+ safeCall(instance, 'componentDidRender');
1094
+ }
1095
+ if (!(hostRef.$flags$ & 64 /* hasLoadedComponent */)) {
1096
+ hostRef.$flags$ |= 64 /* hasLoadedComponent */;
1097
+ {
1098
+ // DOM WRITE!
1099
+ addHydratedFlag(elm);
1100
+ }
1101
+ {
1102
+ safeCall(instance, 'componentDidLoad');
1103
+ }
1104
+ endPostUpdate();
1105
+ {
1106
+ hostRef.$onReadyResolve$(elm);
1107
+ if (!ancestorComponent) {
1108
+ appDidLoad();
1109
+ }
1110
+ }
1111
+ }
1112
+ else {
1113
+ endPostUpdate();
1114
+ }
1115
+ {
1116
+ hostRef.$onInstanceResolve$(elm);
1117
+ }
1118
+ // load events fire from bottom to top
1119
+ // the deepest elements load first then bubbles up
1120
+ {
1121
+ if (hostRef.$onRenderResolve$) {
1122
+ hostRef.$onRenderResolve$();
1123
+ hostRef.$onRenderResolve$ = undefined;
1124
+ }
1125
+ if (hostRef.$flags$ & 512 /* needsRerender */) {
1126
+ nextTick(() => scheduleUpdate(hostRef, false));
1127
+ }
1128
+ hostRef.$flags$ &= ~(4 /* isWaitingForChildren */ | 512 /* needsRerender */);
1129
+ }
1130
+ // ( •_•)
1131
+ // ( •_•)>⌐■-■
1132
+ // (⌐■_■)
1133
+ };
1134
+ const appDidLoad = (who) => {
1135
+ // on appload
1136
+ // we have finish the first big initial render
1137
+ {
1138
+ addHydratedFlag(doc.documentElement);
1139
+ }
1140
+ nextTick(() => emitEvent(win, 'appload', { detail: { namespace: NAMESPACE } }));
1141
+ };
1142
+ const safeCall = (instance, method, arg) => {
1143
+ if (instance && instance[method]) {
1144
+ try {
1145
+ return instance[method](arg);
1146
+ }
1147
+ catch (e) {
1148
+ consoleError(e);
1149
+ }
1150
+ }
1151
+ return undefined;
1152
+ };
1153
+ const then = (promise, thenFn) => {
1154
+ return promise && promise.then ? promise.then(thenFn) : thenFn();
1155
+ };
1156
+ const addHydratedFlag = (elm) => elm.classList.add('hydrated')
1157
+ ;
1158
+ const parsePropertyValue = (propValue, propType) => {
1159
+ // ensure this value is of the correct prop type
1160
+ if (propValue != null && !isComplexType(propValue)) {
1161
+ if (propType & 4 /* Boolean */) {
1162
+ // per the HTML spec, any string value means it is a boolean true value
1163
+ // but we'll cheat here and say that the string "false" is the boolean false
1164
+ return propValue === 'false' ? false : propValue === '' || !!propValue;
1165
+ }
1166
+ if (propType & 2 /* Number */) {
1167
+ // force it to be a number
1168
+ return parseFloat(propValue);
1169
+ }
1170
+ if (propType & 1 /* String */) {
1171
+ // could have been passed as a number or boolean
1172
+ // but we still want it as a string
1173
+ return String(propValue);
1174
+ }
1175
+ // redundant return here for better minification
1176
+ return propValue;
1177
+ }
1178
+ // not sure exactly what type we want
1179
+ // so no need to change to a different type
1180
+ return propValue;
1181
+ };
1182
+ const getValue = (ref, propName) => getHostRef(ref).$instanceValues$.get(propName);
1183
+ const setValue = (ref, propName, newVal, cmpMeta) => {
1184
+ // check our new property value against our internal value
1185
+ const hostRef = getHostRef(ref);
1186
+ const elm = hostRef.$hostElement$ ;
1187
+ const oldVal = hostRef.$instanceValues$.get(propName);
1188
+ const flags = hostRef.$flags$;
1189
+ const instance = hostRef.$lazyInstance$ ;
1190
+ newVal = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]);
1191
+ if ((!(flags & 8 /* isConstructingInstance */) || oldVal === undefined) && newVal !== oldVal) {
1192
+ // gadzooks! the property's value has changed!!
1193
+ // set our new value!
1194
+ hostRef.$instanceValues$.set(propName, newVal);
1195
+ if (instance) {
1196
+ // get an array of method names of watch functions to call
1197
+ if (cmpMeta.$watchers$ && flags & 128 /* isWatchReady */) {
1198
+ const watchMethods = cmpMeta.$watchers$[propName];
1199
+ if (watchMethods) {
1200
+ // this instance is watching for when this property changed
1201
+ watchMethods.map((watchMethodName) => {
1202
+ try {
1203
+ // fire off each of the watch methods that are watching this property
1204
+ instance[watchMethodName](newVal, oldVal, propName);
1205
+ }
1206
+ catch (e) {
1207
+ consoleError(e, elm);
1208
+ }
1209
+ });
1210
+ }
1211
+ }
1212
+ if ((flags & (2 /* hasRendered */ | 16 /* isQueuedForUpdate */)) === 2 /* hasRendered */) {
1213
+ // looks like this value actually changed, so we've got work to do!
1214
+ // but only if we've already rendered, otherwise just chill out
1215
+ // queue that we need to do an update, but don't worry about queuing
1216
+ // up millions cuz this function ensures it only runs once
1217
+ scheduleUpdate(hostRef, false);
1218
+ }
1219
+ }
1220
+ }
1221
+ };
1222
+ const proxyComponent = (Cstr, cmpMeta, flags) => {
1223
+ if (cmpMeta.$members$) {
1224
+ if (Cstr.watchers) {
1225
+ cmpMeta.$watchers$ = Cstr.watchers;
1226
+ }
1227
+ // It's better to have a const than two Object.entries()
1228
+ const members = Object.entries(cmpMeta.$members$);
1229
+ const prototype = Cstr.prototype;
1230
+ members.map(([memberName, [memberFlags]]) => {
1231
+ if ((memberFlags & 31 /* Prop */ ||
1232
+ ((flags & 2 /* proxyState */) && memberFlags & 32 /* State */))) {
1233
+ // proxyComponent - prop
1234
+ Object.defineProperty(prototype, memberName, {
1235
+ get() {
1236
+ // proxyComponent, get value
1237
+ return getValue(this, memberName);
1238
+ },
1239
+ set(newValue) {
1240
+ // proxyComponent, set value
1241
+ setValue(this, memberName, newValue, cmpMeta);
1242
+ },
1243
+ configurable: true,
1244
+ enumerable: true,
1245
+ });
1246
+ }
1247
+ else if (flags & 1 /* isElementConstructor */ &&
1248
+ memberFlags & 64 /* Method */) {
1249
+ // proxyComponent - method
1250
+ Object.defineProperty(prototype, memberName, {
1251
+ value(...args) {
1252
+ const ref = getHostRef(this);
1253
+ return ref.$onInstancePromise$.then(() => ref.$lazyInstance$[memberName](...args));
1254
+ },
1255
+ });
1256
+ }
1257
+ });
1258
+ if ((flags & 1 /* isElementConstructor */)) {
1259
+ const attrNameToPropName = new Map();
1260
+ prototype.attributeChangedCallback = function (attrName, _oldValue, newValue) {
1261
+ plt.jmp(() => {
1262
+ const propName = attrNameToPropName.get(attrName);
1263
+ // In a webcomponent lifecyle the attributeChangedCallback runs prior to connectedCallback
1264
+ // in the case where an attribute was set inline.
1265
+ // ```html
1266
+ // <my-component some-attribute="some-value"></my-component>
1267
+ // ```
1268
+ //
1269
+ // There is an edge case where a developer sets the attribute inline on a custom element and then programatically
1270
+ // changes it before it has been upgraded as shown below:
1271
+ //
1272
+ // ```html
1273
+ // <!-- this component has _not_ been upgraded yet -->
1274
+ // <my-component id="test" some-attribute="some-value"></my-component>
1275
+ // <script>
1276
+ // // grab non-upgraded component
1277
+ // el = document.querySelector("#test");
1278
+ // el.someAttribute = "another-value";
1279
+ // // upgrade component
1280
+ // cutsomElements.define('my-component', MyComponent);
1281
+ // </script>
1282
+ // ```
1283
+ // In this case if we do not unshadow here and use the value of the shadowing property, attributeChangedCallback
1284
+ // will be called with `newValue = "some-value"` and will set the shadowed property (this.someAttribute = "another-value")
1285
+ // to the value that was set inline i.e. "some-value" from above example. When
1286
+ // the connectedCallback attempts to unshadow it will use "some-value" as the intial value rather than "another-value"
1287
+ //
1288
+ // The case where the attribute was NOT set inline but was not set programmatically shall be handled/unshadowed
1289
+ // by connectedCallback as this attributeChangedCallback will not fire.
1290
+ //
1291
+ // https://developers.google.com/web/fundamentals/web-components/best-practices#lazy-properties
1292
+ //
1293
+ // TODO(STENCIL-16) we should think about whether or not we actually want to be reflecting the attributes to
1294
+ // properties here given that this goes against best practices outlined here
1295
+ // https://developers.google.com/web/fundamentals/web-components/best-practices#avoid-reentrancy
1296
+ if (this.hasOwnProperty(propName)) {
1297
+ newValue = this[propName];
1298
+ delete this[propName];
1299
+ }
1300
+ this[propName] = newValue === null && typeof this[propName] === 'boolean' ? false : newValue;
1301
+ });
1302
+ };
1303
+ // create an array of attributes to observe
1304
+ // and also create a map of html attribute name to js property name
1305
+ Cstr.observedAttributes = members
1306
+ .filter(([_, m]) => m[0] & 15 /* HasAttribute */) // filter to only keep props that should match attributes
1307
+ .map(([propName, m]) => {
1308
+ const attrName = m[1] || propName;
1309
+ attrNameToPropName.set(attrName, propName);
1310
+ if (m[0] & 512 /* ReflectAttr */) {
1311
+ cmpMeta.$attrsToReflect$.push([propName, attrName]);
1312
+ }
1313
+ return attrName;
1314
+ });
1315
+ }
1316
+ }
1317
+ return Cstr;
1318
+ };
1319
+ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) => {
1320
+ // initializeComponent
1321
+ if ((hostRef.$flags$ & 32 /* hasInitializedComponent */) === 0) {
1322
+ {
1323
+ // we haven't initialized this element yet
1324
+ hostRef.$flags$ |= 32 /* hasInitializedComponent */;
1325
+ // lazy loaded components
1326
+ // request the component's implementation to be
1327
+ // wired up with the host element
1328
+ Cstr = loadModule(cmpMeta);
1329
+ if (Cstr.then) {
1330
+ // Await creates a micro-task avoid if possible
1331
+ const endLoad = uniqueTime();
1332
+ Cstr = await Cstr;
1333
+ endLoad();
1334
+ }
1335
+ if (!Cstr.isProxied) {
1336
+ // we've never proxied this Constructor before
1337
+ // let's add the getters/setters to its prototype before
1338
+ // the first time we create an instance of the implementation
1339
+ {
1340
+ cmpMeta.$watchers$ = Cstr.watchers;
1341
+ }
1342
+ proxyComponent(Cstr, cmpMeta, 2 /* proxyState */);
1343
+ Cstr.isProxied = true;
1344
+ }
1345
+ const endNewInstance = createTime('createInstance', cmpMeta.$tagName$);
1346
+ // ok, time to construct the instance
1347
+ // but let's keep track of when we start and stop
1348
+ // so that the getters/setters don't incorrectly step on data
1349
+ {
1350
+ hostRef.$flags$ |= 8 /* isConstructingInstance */;
1351
+ }
1352
+ // construct the lazy-loaded component implementation
1353
+ // passing the hostRef is very important during
1354
+ // construction in order to directly wire together the
1355
+ // host element and the lazy-loaded instance
1356
+ try {
1357
+ new Cstr(hostRef);
1358
+ }
1359
+ catch (e) {
1360
+ consoleError(e);
1361
+ }
1362
+ {
1363
+ hostRef.$flags$ &= ~8 /* isConstructingInstance */;
1364
+ }
1365
+ {
1366
+ hostRef.$flags$ |= 128 /* isWatchReady */;
1367
+ }
1368
+ endNewInstance();
1369
+ }
1370
+ if (Cstr.style) {
1371
+ // this component has styles but we haven't registered them yet
1372
+ let style = Cstr.style;
1373
+ const scopeId = getScopeId(cmpMeta);
1374
+ if (!styles.has(scopeId)) {
1375
+ const endRegisterStyles = createTime('registerStyles', cmpMeta.$tagName$);
1376
+ registerStyle(scopeId, style, !!(cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */));
1377
+ endRegisterStyles();
1378
+ }
1379
+ }
1380
+ }
1381
+ // we've successfully created a lazy instance
1382
+ const ancestorComponent = hostRef.$ancestorComponent$;
1383
+ const schedule = () => scheduleUpdate(hostRef, true);
1384
+ if (ancestorComponent && ancestorComponent['s-rc']) {
1385
+ // this is the intial load and this component it has an ancestor component
1386
+ // but the ancestor component has NOT fired its will update lifecycle yet
1387
+ // so let's just cool our jets and wait for the ancestor to continue first
1388
+ // this will get fired off when the ancestor component
1389
+ // finally gets around to rendering its lazy self
1390
+ // fire off the initial update
1391
+ ancestorComponent['s-rc'].push(schedule);
1392
+ }
1393
+ else {
1394
+ schedule();
1395
+ }
1396
+ };
1397
+ const connectedCallback = (elm) => {
1398
+ if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0) {
1399
+ const hostRef = getHostRef(elm);
1400
+ const cmpMeta = hostRef.$cmpMeta$;
1401
+ const endConnected = createTime('connectedCallback', cmpMeta.$tagName$);
1402
+ if (!(hostRef.$flags$ & 1 /* hasConnected */)) {
1403
+ // first time this component has connected
1404
+ hostRef.$flags$ |= 1 /* hasConnected */;
1405
+ {
1406
+ // initUpdate
1407
+ // if the slot polyfill is required we'll need to put some nodes
1408
+ // in here to act as original content anchors as we move nodes around
1409
+ // host element has been connected to the DOM
1410
+ if ((cmpMeta.$flags$ & (4 /* hasSlotRelocation */ | 8 /* needsShadowDomShim */))) {
1411
+ setContentReference(elm);
1412
+ }
1413
+ }
1414
+ {
1415
+ // find the first ancestor component (if there is one) and register
1416
+ // this component as one of the actively loading child components for its ancestor
1417
+ let ancestorComponent = elm;
1418
+ while ((ancestorComponent = ancestorComponent.parentNode || ancestorComponent.host)) {
1419
+ // climb up the ancestors looking for the first
1420
+ // component that hasn't finished its lifecycle update yet
1421
+ if (ancestorComponent['s-p']) {
1422
+ // we found this components first ancestor component
1423
+ // keep a reference to this component's ancestor component
1424
+ attachToAncestor(hostRef, (hostRef.$ancestorComponent$ = ancestorComponent));
1425
+ break;
1426
+ }
1427
+ }
1428
+ }
1429
+ // Lazy properties
1430
+ // https://developers.google.com/web/fundamentals/web-components/best-practices#lazy-properties
1431
+ if (cmpMeta.$members$) {
1432
+ Object.entries(cmpMeta.$members$).map(([memberName, [memberFlags]]) => {
1433
+ if (memberFlags & 31 /* Prop */ && elm.hasOwnProperty(memberName)) {
1434
+ const value = elm[memberName];
1435
+ delete elm[memberName];
1436
+ elm[memberName] = value;
1437
+ }
1438
+ });
1439
+ }
1440
+ {
1441
+ initializeComponent(elm, hostRef, cmpMeta);
1442
+ }
1443
+ }
1444
+ else {
1445
+ // not the first time this has connected
1446
+ // reattach any event listeners to the host
1447
+ // since they would have been removed when disconnected
1448
+ addHostEventListeners(elm, hostRef, cmpMeta.$listeners$);
1449
+ }
1450
+ endConnected();
1451
+ }
1452
+ };
1453
+ const setContentReference = (elm) => {
1454
+ // only required when we're NOT using native shadow dom (slot)
1455
+ // or this browser doesn't support native shadow dom
1456
+ // and this host element was NOT created with SSR
1457
+ // let's pick out the inner content for slot projection
1458
+ // create a node to represent where the original
1459
+ // content was first placed, which is useful later on
1460
+ const contentRefElm = (elm['s-cr'] = doc.createComment(''));
1461
+ contentRefElm['s-cn'] = true;
1462
+ elm.insertBefore(contentRefElm, elm.firstChild);
1463
+ };
1464
+ const disconnectedCallback = (elm) => {
1465
+ if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0) {
1466
+ const hostRef = getHostRef(elm);
1467
+ {
1468
+ if (hostRef.$rmListeners$) {
1469
+ hostRef.$rmListeners$.map((rmListener) => rmListener());
1470
+ hostRef.$rmListeners$ = undefined;
1471
+ }
1472
+ }
1473
+ }
1474
+ };
1475
+ const bootstrapLazy = (lazyBundles, options = {}) => {
1476
+ const endBootstrap = createTime();
1477
+ const cmpTags = [];
1478
+ const exclude = options.exclude || [];
1479
+ const customElements = win.customElements;
1480
+ const head = doc.head;
1481
+ const metaCharset = /*@__PURE__*/ head.querySelector('meta[charset]');
1482
+ const visibilityStyle = /*@__PURE__*/ doc.createElement('style');
1483
+ const deferredConnectedCallbacks = [];
1484
+ let appLoadFallback;
1485
+ let isBootstrapping = true;
1486
+ Object.assign(plt, options);
1487
+ plt.$resourcesUrl$ = new URL(options.resourcesUrl || './', doc.baseURI).href;
1488
+ lazyBundles.map((lazyBundle) => lazyBundle[1].map((compactMeta) => {
1489
+ const cmpMeta = {
1490
+ $flags$: compactMeta[0],
1491
+ $tagName$: compactMeta[1],
1492
+ $members$: compactMeta[2],
1493
+ $listeners$: compactMeta[3],
1494
+ };
1495
+ {
1496
+ cmpMeta.$members$ = compactMeta[2];
1497
+ }
1498
+ {
1499
+ cmpMeta.$listeners$ = compactMeta[3];
1500
+ }
1501
+ {
1502
+ cmpMeta.$attrsToReflect$ = [];
1503
+ }
1504
+ {
1505
+ cmpMeta.$watchers$ = {};
1506
+ }
1507
+ const tagName = cmpMeta.$tagName$;
1508
+ const HostElement = class extends HTMLElement {
1509
+ // StencilLazyHost
1510
+ constructor(self) {
1511
+ // @ts-ignore
1512
+ super(self);
1513
+ self = this;
1514
+ registerHost(self, cmpMeta);
1515
+ }
1516
+ connectedCallback() {
1517
+ if (appLoadFallback) {
1518
+ clearTimeout(appLoadFallback);
1519
+ appLoadFallback = null;
1520
+ }
1521
+ if (isBootstrapping) {
1522
+ // connectedCallback will be processed once all components have been registered
1523
+ deferredConnectedCallbacks.push(this);
1524
+ }
1525
+ else {
1526
+ plt.jmp(() => connectedCallback(this));
1527
+ }
1528
+ }
1529
+ disconnectedCallback() {
1530
+ plt.jmp(() => disconnectedCallback(this));
1531
+ }
1532
+ componentOnReady() {
1533
+ return getHostRef(this).$onReadyPromise$;
1534
+ }
1535
+ };
1536
+ cmpMeta.$lazyBundleId$ = lazyBundle[0];
1537
+ if (!exclude.includes(tagName) && !customElements.get(tagName)) {
1538
+ cmpTags.push(tagName);
1539
+ customElements.define(tagName, proxyComponent(HostElement, cmpMeta, 1 /* isElementConstructor */));
1540
+ }
1541
+ }));
1542
+ {
1543
+ visibilityStyle.innerHTML = cmpTags + HYDRATED_CSS;
1544
+ visibilityStyle.setAttribute('data-styles', '');
1545
+ head.insertBefore(visibilityStyle, metaCharset ? metaCharset.nextSibling : head.firstChild);
1546
+ }
1547
+ // Process deferred connectedCallbacks now all components have been registered
1548
+ isBootstrapping = false;
1549
+ if (deferredConnectedCallbacks.length) {
1550
+ deferredConnectedCallbacks.map((host) => host.connectedCallback());
1551
+ }
1552
+ else {
1553
+ {
1554
+ plt.jmp(() => (appLoadFallback = setTimeout(appDidLoad, 30)));
1555
+ }
1556
+ }
1557
+ // Fallback appLoad event
1558
+ endBootstrap();
1559
+ };
1560
+ const hostRefs = new WeakMap();
1561
+ const getHostRef = (ref) => hostRefs.get(ref);
1562
+ const registerInstance = (lazyInstance, hostRef) => hostRefs.set((hostRef.$lazyInstance$ = lazyInstance), hostRef);
1563
+ const registerHost = (elm, cmpMeta) => {
1564
+ const hostRef = {
1565
+ $flags$: 0,
1566
+ $hostElement$: elm,
1567
+ $cmpMeta$: cmpMeta,
1568
+ $instanceValues$: new Map(),
1569
+ };
1570
+ {
1571
+ hostRef.$onInstancePromise$ = new Promise((r) => (hostRef.$onInstanceResolve$ = r));
1572
+ }
1573
+ {
1574
+ hostRef.$onReadyPromise$ = new Promise((r) => (hostRef.$onReadyResolve$ = r));
1575
+ elm['s-p'] = [];
1576
+ elm['s-rc'] = [];
1577
+ }
1578
+ addHostEventListeners(elm, hostRef, cmpMeta.$listeners$);
1579
+ return hostRefs.set(elm, hostRef);
1580
+ };
1581
+ const isMemberInElement = (elm, memberName) => memberName in elm;
1582
+ const consoleError = (e, el) => (0, console.error)(e, el);
1583
+ const cmpModules = /*@__PURE__*/ new Map();
1584
+ const loadModule = (cmpMeta, hostRef, hmrVersionId) => {
1585
+ // loadModuleImport
1586
+ const exportName = cmpMeta.$tagName$.replace(/-/g, '_');
1587
+ const bundleId = cmpMeta.$lazyBundleId$;
1588
+ const module = cmpModules.get(bundleId) ;
1589
+ if (module) {
1590
+ return module[exportName];
1591
+ }
1592
+ return Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require(
1593
+ /* webpackInclude: /\.entry\.js$/ */
1594
+ /* webpackExclude: /\.system\.entry\.js$/ */
1595
+ /* webpackMode: "lazy" */
1596
+ `./${bundleId}.entry.js${''}`)); }).then((importedModule) => {
1597
+ {
1598
+ cmpModules.set(bundleId, importedModule);
1599
+ }
1600
+ return importedModule[exportName];
1601
+ }, consoleError);
1602
+ };
1603
+ const styles = new Map();
1604
+ const queueDomReads = [];
1605
+ const queueDomWrites = [];
1606
+ const queueTask = (queue, write) => (cb) => {
1607
+ queue.push(cb);
1608
+ if (!queuePending) {
1609
+ queuePending = true;
1610
+ if (write && plt.$flags$ & 4 /* queueSync */) {
1611
+ nextTick(flush);
1612
+ }
1613
+ else {
1614
+ plt.raf(flush);
1615
+ }
1616
+ }
1617
+ };
1618
+ const consume = (queue) => {
1619
+ for (let i = 0; i < queue.length; i++) {
1620
+ try {
1621
+ queue[i](performance.now());
1622
+ }
1623
+ catch (e) {
1624
+ consoleError(e);
1625
+ }
1626
+ }
1627
+ queue.length = 0;
1628
+ };
1629
+ const flush = () => {
1630
+ // always force a bunch of medium callbacks to run, but still have
1631
+ // a throttle on how many can run in a certain time
1632
+ // DOM READS!!!
1633
+ consume(queueDomReads);
1634
+ // DOM WRITES!!!
1635
+ {
1636
+ consume(queueDomWrites);
1637
+ if ((queuePending = queueDomReads.length > 0)) {
1638
+ // still more to do yet, but we've run out of time
1639
+ // let's let this thing cool off and try again in the next tick
1640
+ plt.raf(flush);
1641
+ }
1642
+ }
1643
+ };
1644
+ const nextTick = /*@__PURE__*/ (cb) => promiseResolve().then(cb);
1645
+ const writeTask = /*@__PURE__*/ queueTask(queueDomWrites, true);
1646
+
1647
+ exports.Host = Host;
1648
+ exports.bootstrapLazy = bootstrapLazy;
1649
+ exports.createEvent = createEvent;
1650
+ exports.getElement = getElement;
1651
+ exports.h = h;
1652
+ exports.promiseResolve = promiseResolve;
1653
+ exports.registerInstance = registerInstance;