@everymatrix/user-action-controller 0.0.1

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 (49) hide show
  1. package/dist/cjs/generic-user-consent_3.cjs.entry.js +182 -0
  2. package/dist/cjs/index-4a3038bd.js +1255 -0
  3. package/dist/cjs/index.cjs.js +2 -0
  4. package/dist/cjs/loader.cjs.js +21 -0
  5. package/dist/cjs/user-action-controller.cjs.js +19 -0
  6. package/dist/collection/collection-manifest.json +25 -0
  7. package/dist/collection/components/user-action-controller/user-action-controller.css +48 -0
  8. package/dist/collection/components/user-action-controller/user-action-controller.js +237 -0
  9. package/dist/collection/index.js +1 -0
  10. package/dist/collection/utils/utils.js +3 -0
  11. package/dist/components/generic-user-consent.js +6 -0
  12. package/dist/components/generic-user-consent2.js +93 -0
  13. package/dist/components/index.d.ts +26 -0
  14. package/dist/components/index.js +1 -0
  15. package/dist/components/legislation-wrapper.js +6 -0
  16. package/dist/components/legislation-wrapper2.js +33 -0
  17. package/dist/components/user-action-controller.d.ts +11 -0
  18. package/dist/components/user-action-controller.js +137 -0
  19. package/dist/esm/generic-user-consent_3.entry.js +176 -0
  20. package/dist/esm/index-9eef5ef8.js +1229 -0
  21. package/dist/esm/index.js +1 -0
  22. package/dist/esm/loader.js +17 -0
  23. package/dist/esm/polyfills/core-js.js +11 -0
  24. package/dist/esm/polyfills/css-shim.js +1 -0
  25. package/dist/esm/polyfills/dom.js +79 -0
  26. package/dist/esm/polyfills/es5-html-element.js +1 -0
  27. package/dist/esm/polyfills/index.js +34 -0
  28. package/dist/esm/polyfills/system.js +6 -0
  29. package/dist/esm/user-action-controller.js +17 -0
  30. package/dist/index.cjs.js +1 -0
  31. package/dist/index.js +1 -0
  32. package/dist/stencil.config.js +22 -0
  33. package/dist/types/Users/user/workspace/everymatrix/widgets-stencil/packages/user-action-controller/.stencil/packages/user-action-controller/stencil.config.d.ts +2 -0
  34. package/dist/types/components/user-action-controller/user-action-controller.d.ts +55 -0
  35. package/dist/types/components.d.ts +93 -0
  36. package/dist/types/index.d.ts +1 -0
  37. package/dist/types/stencil-public-runtime.d.ts +1565 -0
  38. package/dist/types/utils/utils.d.ts +1 -0
  39. package/dist/user-action-controller/index.esm.js +0 -0
  40. package/dist/user-action-controller/p-013051ff.entry.js +1 -0
  41. package/dist/user-action-controller/p-54386d36.js +1 -0
  42. package/dist/user-action-controller/user-action-controller.esm.js +1 -0
  43. package/loader/cdn.js +3 -0
  44. package/loader/index.cjs.js +3 -0
  45. package/loader/index.d.ts +12 -0
  46. package/loader/index.es2017.js +3 -0
  47. package/loader/index.js +4 -0
  48. package/loader/package.json +10 -0
  49. package/package.json +19 -0
@@ -0,0 +1,1255 @@
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 = 'user-action-controller';
24
+
25
+ let scopeId;
26
+ let hostTagName;
27
+ let isSvgMode = false;
28
+ let queuePending = false;
29
+ const win = typeof window !== 'undefined' ? window : {};
30
+ const doc = win.document || { head: {} };
31
+ const plt = {
32
+ $flags$: 0,
33
+ $resourcesUrl$: '',
34
+ jmp: (h) => h(),
35
+ raf: (h) => requestAnimationFrame(h),
36
+ ael: (el, eventName, listener, opts) => el.addEventListener(eventName, listener, opts),
37
+ rel: (el, eventName, listener, opts) => el.removeEventListener(eventName, listener, opts),
38
+ ce: (eventName, opts) => new CustomEvent(eventName, opts),
39
+ };
40
+ const promiseResolve = (v) => Promise.resolve(v);
41
+ const supportsConstructibleStylesheets = /*@__PURE__*/ (() => {
42
+ try {
43
+ new CSSStyleSheet();
44
+ return typeof new CSSStyleSheet().replace === 'function';
45
+ }
46
+ catch (e) { }
47
+ return false;
48
+ })()
49
+ ;
50
+ const addHostEventListeners = (elm, hostRef, listeners, attachParentListeners) => {
51
+ if (listeners) {
52
+ listeners.map(([flags, name, method]) => {
53
+ const target = elm;
54
+ const handler = hostListenerProxy(hostRef, method);
55
+ const opts = hostListenerOpts(flags);
56
+ plt.ael(target, name, handler, opts);
57
+ (hostRef.$rmListeners$ = hostRef.$rmListeners$ || []).push(() => plt.rel(target, name, handler, opts));
58
+ });
59
+ }
60
+ };
61
+ const hostListenerProxy = (hostRef, methodName) => (ev) => {
62
+ try {
63
+ {
64
+ if (hostRef.$flags$ & 256 /* isListenReady */) {
65
+ // instance is ready, let's call it's member method for this event
66
+ hostRef.$lazyInstance$[methodName](ev);
67
+ }
68
+ else {
69
+ (hostRef.$queuedListeners$ = hostRef.$queuedListeners$ || []).push([methodName, ev]);
70
+ }
71
+ }
72
+ }
73
+ catch (e) {
74
+ consoleError(e);
75
+ }
76
+ };
77
+ // prettier-ignore
78
+ const hostListenerOpts = (flags) => (flags & 2 /* Capture */) !== 0;
79
+ const HYDRATED_CSS = '{visibility:hidden}.hydrated{visibility:inherit}';
80
+ const createTime = (fnName, tagName = '') => {
81
+ {
82
+ return () => {
83
+ return;
84
+ };
85
+ }
86
+ };
87
+ const uniqueTime = (key, measureText) => {
88
+ {
89
+ return () => {
90
+ return;
91
+ };
92
+ }
93
+ };
94
+ const rootAppliedStyles = new WeakMap();
95
+ const registerStyle = (scopeId, cssText, allowCS) => {
96
+ let style = styles.get(scopeId);
97
+ if (supportsConstructibleStylesheets && allowCS) {
98
+ style = (style || new CSSStyleSheet());
99
+ style.replace(cssText);
100
+ }
101
+ else {
102
+ style = cssText;
103
+ }
104
+ styles.set(scopeId, style);
105
+ };
106
+ const addStyle = (styleContainerNode, cmpMeta, mode, hostElm) => {
107
+ let scopeId = getScopeId(cmpMeta);
108
+ let style = styles.get(scopeId);
109
+ // if an element is NOT connected then getRootNode() will return the wrong root node
110
+ // so the fallback is to always use the document for the root node in those cases
111
+ styleContainerNode = styleContainerNode.nodeType === 11 /* DocumentFragment */ ? styleContainerNode : doc;
112
+ if (style) {
113
+ if (typeof style === 'string') {
114
+ styleContainerNode = styleContainerNode.head || styleContainerNode;
115
+ let appliedStyles = rootAppliedStyles.get(styleContainerNode);
116
+ let styleElm;
117
+ if (!appliedStyles) {
118
+ rootAppliedStyles.set(styleContainerNode, (appliedStyles = new Set()));
119
+ }
120
+ if (!appliedStyles.has(scopeId)) {
121
+ {
122
+ {
123
+ styleElm = doc.createElement('style');
124
+ styleElm.innerHTML = style;
125
+ }
126
+ styleContainerNode.insertBefore(styleElm, styleContainerNode.querySelector('link'));
127
+ }
128
+ if (appliedStyles) {
129
+ appliedStyles.add(scopeId);
130
+ }
131
+ }
132
+ }
133
+ else if (!styleContainerNode.adoptedStyleSheets.includes(style)) {
134
+ styleContainerNode.adoptedStyleSheets = [...styleContainerNode.adoptedStyleSheets, style];
135
+ }
136
+ }
137
+ return scopeId;
138
+ };
139
+ const attachStyles = (hostRef) => {
140
+ const cmpMeta = hostRef.$cmpMeta$;
141
+ const elm = hostRef.$hostElement$;
142
+ const flags = cmpMeta.$flags$;
143
+ const endAttachStyles = createTime('attachStyles', cmpMeta.$tagName$);
144
+ const scopeId = addStyle(elm.shadowRoot ? elm.shadowRoot : elm.getRootNode(), cmpMeta);
145
+ if (flags & 10 /* needsScopedEncapsulation */) {
146
+ // only required when we're NOT using native shadow dom (slot)
147
+ // or this browser doesn't support native shadow dom
148
+ // and this host element was NOT created with SSR
149
+ // let's pick out the inner content for slot projection
150
+ // create a node to represent where the original
151
+ // content was first placed, which is useful later on
152
+ // DOM WRITE!!
153
+ elm['s-sc'] = scopeId;
154
+ elm.classList.add(scopeId + '-h');
155
+ }
156
+ endAttachStyles();
157
+ };
158
+ const getScopeId = (cmp, mode) => 'sc-' + (cmp.$tagName$);
159
+ /**
160
+ * Default style mode id
161
+ */
162
+ /**
163
+ * Reusable empty obj/array
164
+ * Don't add values to these!!
165
+ */
166
+ const EMPTY_OBJ = {};
167
+ const isDef = (v) => v != null;
168
+ const isComplexType = (o) => {
169
+ // https://jsperf.com/typeof-fn-object/5
170
+ o = typeof o;
171
+ return o === 'object' || o === 'function';
172
+ };
173
+ /**
174
+ * Production h() function based on Preact by
175
+ * Jason Miller (@developit)
176
+ * Licensed under the MIT License
177
+ * https://github.com/developit/preact/blob/master/LICENSE
178
+ *
179
+ * Modified for Stencil's compiler and vdom
180
+ */
181
+ // const stack: any[] = [];
182
+ // export function h(nodeName: string | d.FunctionalComponent, vnodeData: d.PropsType, child?: d.ChildType): d.VNode;
183
+ // export function h(nodeName: string | d.FunctionalComponent, vnodeData: d.PropsType, ...children: d.ChildType[]): d.VNode;
184
+ const h = (nodeName, vnodeData, ...children) => {
185
+ let child = null;
186
+ let simple = false;
187
+ let lastSimple = false;
188
+ let vNodeChildren = [];
189
+ const walk = (c) => {
190
+ for (let i = 0; i < c.length; i++) {
191
+ child = c[i];
192
+ if (Array.isArray(child)) {
193
+ walk(child);
194
+ }
195
+ else if (child != null && typeof child !== 'boolean') {
196
+ if ((simple = typeof nodeName !== 'function' && !isComplexType(child))) {
197
+ child = String(child);
198
+ }
199
+ if (simple && lastSimple) {
200
+ // If the previous child was simple (string), we merge both
201
+ vNodeChildren[vNodeChildren.length - 1].$text$ += child;
202
+ }
203
+ else {
204
+ // Append a new vNode, if it's text, we create a text vNode
205
+ vNodeChildren.push(simple ? newVNode(null, child) : child);
206
+ }
207
+ lastSimple = simple;
208
+ }
209
+ }
210
+ };
211
+ walk(children);
212
+ if (vnodeData) {
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
+ return vnode;
231
+ };
232
+ const newVNode = (tag, text) => {
233
+ const vnode = {
234
+ $flags$: 0,
235
+ $tag$: tag,
236
+ $text$: text,
237
+ $elm$: null,
238
+ $children$: null,
239
+ };
240
+ {
241
+ vnode.$attrs$ = null;
242
+ }
243
+ return vnode;
244
+ };
245
+ const Host = {};
246
+ const isHost = (node) => node && node.$tag$ === Host;
247
+ /**
248
+ * Production setAccessor() function based on Preact by
249
+ * Jason Miller (@developit)
250
+ * Licensed under the MIT License
251
+ * https://github.com/developit/preact/blob/master/LICENSE
252
+ *
253
+ * Modified for Stencil's compiler and vdom
254
+ */
255
+ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
256
+ if (oldValue !== newValue) {
257
+ let isProp = isMemberInElement(elm, memberName);
258
+ let ln = memberName.toLowerCase();
259
+ if (memberName === 'class') {
260
+ const classList = elm.classList;
261
+ const oldClasses = parseClassList(oldValue);
262
+ const newClasses = parseClassList(newValue);
263
+ classList.remove(...oldClasses.filter((c) => c && !newClasses.includes(c)));
264
+ classList.add(...newClasses.filter((c) => c && !oldClasses.includes(c)));
265
+ }
266
+ else if (memberName === 'ref') {
267
+ // minifier will clean this up
268
+ if (newValue) {
269
+ newValue(elm);
270
+ }
271
+ }
272
+ else if ((!isProp ) &&
273
+ memberName[0] === 'o' &&
274
+ memberName[1] === 'n') {
275
+ // Event Handlers
276
+ // so if the member name starts with "on" and the 3rd characters is
277
+ // a capital letter, and it's not already a member on the element,
278
+ // then we're assuming it's an event listener
279
+ if (memberName[2] === '-') {
280
+ // on- prefixed events
281
+ // allows to be explicit about the dom event to listen without any magic
282
+ // under the hood:
283
+ // <my-cmp on-click> // listens for "click"
284
+ // <my-cmp on-Click> // listens for "Click"
285
+ // <my-cmp on-ionChange> // listens for "ionChange"
286
+ // <my-cmp on-EVENTS> // listens for "EVENTS"
287
+ memberName = memberName.slice(3);
288
+ }
289
+ else if (isMemberInElement(win, ln)) {
290
+ // standard event
291
+ // the JSX attribute could have been "onMouseOver" and the
292
+ // member name "onmouseover" is on the window's prototype
293
+ // so let's add the listener "mouseover", which is all lowercased
294
+ memberName = ln.slice(2);
295
+ }
296
+ else {
297
+ // custom event
298
+ // the JSX attribute could have been "onMyCustomEvent"
299
+ // so let's trim off the "on" prefix and lowercase the first character
300
+ // and add the listener "myCustomEvent"
301
+ // except for the first character, we keep the event name case
302
+ memberName = ln[2] + memberName.slice(3);
303
+ }
304
+ if (oldValue) {
305
+ plt.rel(elm, memberName, oldValue, false);
306
+ }
307
+ if (newValue) {
308
+ plt.ael(elm, memberName, newValue, false);
309
+ }
310
+ }
311
+ else {
312
+ // Set property if it exists and it's not a SVG
313
+ const isComplex = isComplexType(newValue);
314
+ if ((isProp || (isComplex && newValue !== null)) && !isSvg) {
315
+ try {
316
+ if (!elm.tagName.includes('-')) {
317
+ let n = newValue == null ? '' : newValue;
318
+ // Workaround for Safari, moving the <input> caret when re-assigning the same valued
319
+ if (memberName === 'list') {
320
+ isProp = false;
321
+ }
322
+ else if (oldValue == null || elm[memberName] != n) {
323
+ elm[memberName] = n;
324
+ }
325
+ }
326
+ else {
327
+ elm[memberName] = newValue;
328
+ }
329
+ }
330
+ catch (e) { }
331
+ }
332
+ if (newValue == null || newValue === false) {
333
+ if (newValue !== false || elm.getAttribute(memberName) === '') {
334
+ {
335
+ elm.removeAttribute(memberName);
336
+ }
337
+ }
338
+ }
339
+ else if ((!isProp || flags & 4 /* isHost */ || isSvg) && !isComplex) {
340
+ newValue = newValue === true ? '' : newValue;
341
+ {
342
+ elm.setAttribute(memberName, newValue);
343
+ }
344
+ }
345
+ }
346
+ }
347
+ };
348
+ const parseClassListRegex = /\s/;
349
+ const parseClassList = (value) => (!value ? [] : value.split(parseClassListRegex));
350
+ const updateElement = (oldVnode, newVnode, isSvgMode, memberName) => {
351
+ // if the element passed in is a shadow root, which is a document fragment
352
+ // then we want to be adding attrs/props to the shadow root's "host" element
353
+ // if it's not a shadow root, then we add attrs/props to the same element
354
+ const elm = newVnode.$elm$.nodeType === 11 /* DocumentFragment */ && newVnode.$elm$.host
355
+ ? newVnode.$elm$.host
356
+ : newVnode.$elm$;
357
+ const oldVnodeAttrs = (oldVnode && oldVnode.$attrs$) || EMPTY_OBJ;
358
+ const newVnodeAttrs = newVnode.$attrs$ || EMPTY_OBJ;
359
+ {
360
+ // remove attributes no longer present on the vnode by setting them to undefined
361
+ for (memberName in oldVnodeAttrs) {
362
+ if (!(memberName in newVnodeAttrs)) {
363
+ setAccessor(elm, memberName, oldVnodeAttrs[memberName], undefined, isSvgMode, newVnode.$flags$);
364
+ }
365
+ }
366
+ }
367
+ // add new & update changed attributes
368
+ for (memberName in newVnodeAttrs) {
369
+ setAccessor(elm, memberName, oldVnodeAttrs[memberName], newVnodeAttrs[memberName], isSvgMode, newVnode.$flags$);
370
+ }
371
+ };
372
+ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
373
+ // tslint:disable-next-line: prefer-const
374
+ let newVNode = newParentVNode.$children$[childIndex];
375
+ let i = 0;
376
+ let elm;
377
+ let childNode;
378
+ if (newVNode.$text$ !== null) {
379
+ // create text node
380
+ elm = newVNode.$elm$ = doc.createTextNode(newVNode.$text$);
381
+ }
382
+ else {
383
+ // create element
384
+ elm = newVNode.$elm$ = (doc.createElement(newVNode.$tag$));
385
+ // add css classes, attrs, props, listeners, etc.
386
+ {
387
+ updateElement(null, newVNode, isSvgMode);
388
+ }
389
+ if (isDef(scopeId) && elm['s-si'] !== scopeId) {
390
+ // if there is a scopeId and this is the initial render
391
+ // then let's add the scopeId as a css class
392
+ elm.classList.add((elm['s-si'] = scopeId));
393
+ }
394
+ if (newVNode.$children$) {
395
+ for (i = 0; i < newVNode.$children$.length; ++i) {
396
+ // create the node
397
+ childNode = createElm(oldParentVNode, newVNode, i);
398
+ // return node could have been null
399
+ if (childNode) {
400
+ // append our new node
401
+ elm.appendChild(childNode);
402
+ }
403
+ }
404
+ }
405
+ }
406
+ return elm;
407
+ };
408
+ const addVnodes = (parentElm, before, parentVNode, vnodes, startIdx, endIdx) => {
409
+ let containerElm = (parentElm);
410
+ let childNode;
411
+ if (containerElm.shadowRoot && containerElm.tagName === hostTagName) {
412
+ containerElm = containerElm.shadowRoot;
413
+ }
414
+ for (; startIdx <= endIdx; ++startIdx) {
415
+ if (vnodes[startIdx]) {
416
+ childNode = createElm(null, parentVNode, startIdx);
417
+ if (childNode) {
418
+ vnodes[startIdx].$elm$ = childNode;
419
+ containerElm.insertBefore(childNode, before);
420
+ }
421
+ }
422
+ }
423
+ };
424
+ const removeVnodes = (vnodes, startIdx, endIdx, vnode, elm) => {
425
+ for (; startIdx <= endIdx; ++startIdx) {
426
+ if ((vnode = vnodes[startIdx])) {
427
+ elm = vnode.$elm$;
428
+ callNodeRefs(vnode);
429
+ // remove the vnode's element from the dom
430
+ elm.remove();
431
+ }
432
+ }
433
+ };
434
+ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
435
+ let oldStartIdx = 0;
436
+ let newStartIdx = 0;
437
+ let oldEndIdx = oldCh.length - 1;
438
+ let oldStartVnode = oldCh[0];
439
+ let oldEndVnode = oldCh[oldEndIdx];
440
+ let newEndIdx = newCh.length - 1;
441
+ let newStartVnode = newCh[0];
442
+ let newEndVnode = newCh[newEndIdx];
443
+ let node;
444
+ while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
445
+ if (oldStartVnode == null) {
446
+ // Vnode might have been moved left
447
+ oldStartVnode = oldCh[++oldStartIdx];
448
+ }
449
+ else if (oldEndVnode == null) {
450
+ oldEndVnode = oldCh[--oldEndIdx];
451
+ }
452
+ else if (newStartVnode == null) {
453
+ newStartVnode = newCh[++newStartIdx];
454
+ }
455
+ else if (newEndVnode == null) {
456
+ newEndVnode = newCh[--newEndIdx];
457
+ }
458
+ else if (isSameVnode(oldStartVnode, newStartVnode)) {
459
+ patch(oldStartVnode, newStartVnode);
460
+ oldStartVnode = oldCh[++oldStartIdx];
461
+ newStartVnode = newCh[++newStartIdx];
462
+ }
463
+ else if (isSameVnode(oldEndVnode, newEndVnode)) {
464
+ patch(oldEndVnode, newEndVnode);
465
+ oldEndVnode = oldCh[--oldEndIdx];
466
+ newEndVnode = newCh[--newEndIdx];
467
+ }
468
+ else if (isSameVnode(oldStartVnode, newEndVnode)) {
469
+ patch(oldStartVnode, newEndVnode);
470
+ parentElm.insertBefore(oldStartVnode.$elm$, oldEndVnode.$elm$.nextSibling);
471
+ oldStartVnode = oldCh[++oldStartIdx];
472
+ newEndVnode = newCh[--newEndIdx];
473
+ }
474
+ else if (isSameVnode(oldEndVnode, newStartVnode)) {
475
+ patch(oldEndVnode, newStartVnode);
476
+ parentElm.insertBefore(oldEndVnode.$elm$, oldStartVnode.$elm$);
477
+ oldEndVnode = oldCh[--oldEndIdx];
478
+ newStartVnode = newCh[++newStartIdx];
479
+ }
480
+ else {
481
+ {
482
+ // new element
483
+ node = createElm(oldCh && oldCh[newStartIdx], newVNode, newStartIdx);
484
+ newStartVnode = newCh[++newStartIdx];
485
+ }
486
+ if (node) {
487
+ {
488
+ oldStartVnode.$elm$.parentNode.insertBefore(node, oldStartVnode.$elm$);
489
+ }
490
+ }
491
+ }
492
+ }
493
+ if (oldStartIdx > oldEndIdx) {
494
+ addVnodes(parentElm, newCh[newEndIdx + 1] == null ? null : newCh[newEndIdx + 1].$elm$, newVNode, newCh, newStartIdx, newEndIdx);
495
+ }
496
+ else if (newStartIdx > newEndIdx) {
497
+ removeVnodes(oldCh, oldStartIdx, oldEndIdx);
498
+ }
499
+ };
500
+ const isSameVnode = (vnode1, vnode2) => {
501
+ // compare if two vnode to see if they're "technically" the same
502
+ // need to have the same element tag, and same key to be the same
503
+ if (vnode1.$tag$ === vnode2.$tag$) {
504
+ return true;
505
+ }
506
+ return false;
507
+ };
508
+ const patch = (oldVNode, newVNode) => {
509
+ const elm = (newVNode.$elm$ = oldVNode.$elm$);
510
+ const oldChildren = oldVNode.$children$;
511
+ const newChildren = newVNode.$children$;
512
+ const tag = newVNode.$tag$;
513
+ const text = newVNode.$text$;
514
+ if (text === null) {
515
+ // element node
516
+ {
517
+ if (tag === 'slot')
518
+ ;
519
+ else {
520
+ // either this is the first render of an element OR it's an update
521
+ // AND we already know it's possible it could have changed
522
+ // this updates the element's css classes, attrs, props, listeners, etc.
523
+ updateElement(oldVNode, newVNode, isSvgMode);
524
+ }
525
+ }
526
+ if (oldChildren !== null && newChildren !== null) {
527
+ // looks like there's child vnodes for both the old and new vnodes
528
+ updateChildren(elm, oldChildren, newVNode, newChildren);
529
+ }
530
+ else if (newChildren !== null) {
531
+ // no old child vnodes, but there are new child vnodes to add
532
+ if (oldVNode.$text$ !== null) {
533
+ // the old vnode was text, so be sure to clear it out
534
+ elm.textContent = '';
535
+ }
536
+ // add the new vnode children
537
+ addVnodes(elm, null, newVNode, newChildren, 0, newChildren.length - 1);
538
+ }
539
+ else if (oldChildren !== null) {
540
+ // no new child vnodes, but there are old child vnodes to remove
541
+ removeVnodes(oldChildren, 0, oldChildren.length - 1);
542
+ }
543
+ }
544
+ else if (oldVNode.$text$ !== text) {
545
+ // update the text content for the text only vnode
546
+ // and also only if the text is different than before
547
+ elm.data = text;
548
+ }
549
+ };
550
+ const callNodeRefs = (vNode) => {
551
+ {
552
+ vNode.$attrs$ && vNode.$attrs$.ref && vNode.$attrs$.ref(null);
553
+ vNode.$children$ && vNode.$children$.map(callNodeRefs);
554
+ }
555
+ };
556
+ const renderVdom = (hostRef, renderFnResults) => {
557
+ const hostElm = hostRef.$hostElement$;
558
+ const oldVNode = hostRef.$vnode$ || newVNode(null, null);
559
+ const rootVnode = isHost(renderFnResults) ? renderFnResults : h(null, null, renderFnResults);
560
+ hostTagName = hostElm.tagName;
561
+ rootVnode.$tag$ = null;
562
+ rootVnode.$flags$ |= 4 /* isHost */;
563
+ hostRef.$vnode$ = rootVnode;
564
+ rootVnode.$elm$ = oldVNode.$elm$ = (hostElm.shadowRoot || hostElm );
565
+ {
566
+ scopeId = hostElm['s-sc'];
567
+ }
568
+ // synchronous patch
569
+ patch(oldVNode, rootVnode);
570
+ };
571
+ const getElement = (ref) => (getHostRef(ref).$hostElement$ );
572
+ const createEvent = (ref, name, flags) => {
573
+ const elm = getElement(ref);
574
+ return {
575
+ emit: (detail) => {
576
+ return emitEvent(elm, name, {
577
+ bubbles: !!(flags & 4 /* Bubbles */),
578
+ composed: !!(flags & 2 /* Composed */),
579
+ cancelable: !!(flags & 1 /* Cancellable */),
580
+ detail,
581
+ });
582
+ },
583
+ };
584
+ };
585
+ /**
586
+ * Helper function to create & dispatch a custom Event on a provided target
587
+ * @param elm the target of the Event
588
+ * @param name the name to give the custom Event
589
+ * @param opts options for configuring a custom Event
590
+ * @returns the custom Event
591
+ */
592
+ const emitEvent = (elm, name, opts) => {
593
+ const ev = plt.ce(name, opts);
594
+ elm.dispatchEvent(ev);
595
+ return ev;
596
+ };
597
+ const attachToAncestor = (hostRef, ancestorComponent) => {
598
+ if (ancestorComponent && !hostRef.$onRenderResolve$ && ancestorComponent['s-p']) {
599
+ ancestorComponent['s-p'].push(new Promise((r) => (hostRef.$onRenderResolve$ = r)));
600
+ }
601
+ };
602
+ const scheduleUpdate = (hostRef, isInitialLoad) => {
603
+ {
604
+ hostRef.$flags$ |= 16 /* isQueuedForUpdate */;
605
+ }
606
+ if (hostRef.$flags$ & 4 /* isWaitingForChildren */) {
607
+ hostRef.$flags$ |= 512 /* needsRerender */;
608
+ return;
609
+ }
610
+ attachToAncestor(hostRef, hostRef.$ancestorComponent$);
611
+ // there is no ancestor component or the ancestor component
612
+ // has already fired off its lifecycle update then
613
+ // fire off the initial update
614
+ const dispatch = () => dispatchHooks(hostRef, isInitialLoad);
615
+ return writeTask(dispatch) ;
616
+ };
617
+ const dispatchHooks = (hostRef, isInitialLoad) => {
618
+ const endSchedule = createTime('scheduleUpdate', hostRef.$cmpMeta$.$tagName$);
619
+ const instance = hostRef.$lazyInstance$ ;
620
+ let promise;
621
+ if (isInitialLoad) {
622
+ {
623
+ hostRef.$flags$ |= 256 /* isListenReady */;
624
+ if (hostRef.$queuedListeners$) {
625
+ hostRef.$queuedListeners$.map(([methodName, event]) => safeCall(instance, methodName, event));
626
+ hostRef.$queuedListeners$ = null;
627
+ }
628
+ }
629
+ {
630
+ promise = safeCall(instance, 'componentWillLoad');
631
+ }
632
+ }
633
+ endSchedule();
634
+ return then(promise, () => updateComponent(hostRef, instance, isInitialLoad));
635
+ };
636
+ const updateComponent = async (hostRef, instance, isInitialLoad) => {
637
+ // updateComponent
638
+ const elm = hostRef.$hostElement$;
639
+ const endUpdate = createTime('update', hostRef.$cmpMeta$.$tagName$);
640
+ const rc = elm['s-rc'];
641
+ if (isInitialLoad) {
642
+ // DOM WRITE!
643
+ attachStyles(hostRef);
644
+ }
645
+ const endRender = createTime('render', hostRef.$cmpMeta$.$tagName$);
646
+ {
647
+ callRender(hostRef, instance);
648
+ }
649
+ if (rc) {
650
+ // ok, so turns out there are some child host elements
651
+ // waiting on this parent element to load
652
+ // let's fire off all update callbacks waiting
653
+ rc.map((cb) => cb());
654
+ elm['s-rc'] = undefined;
655
+ }
656
+ endRender();
657
+ endUpdate();
658
+ {
659
+ const childrenPromises = elm['s-p'];
660
+ const postUpdate = () => postUpdateComponent(hostRef);
661
+ if (childrenPromises.length === 0) {
662
+ postUpdate();
663
+ }
664
+ else {
665
+ Promise.all(childrenPromises).then(postUpdate);
666
+ hostRef.$flags$ |= 4 /* isWaitingForChildren */;
667
+ childrenPromises.length = 0;
668
+ }
669
+ }
670
+ };
671
+ const callRender = (hostRef, instance, elm) => {
672
+ try {
673
+ instance = instance.render() ;
674
+ {
675
+ hostRef.$flags$ &= ~16 /* isQueuedForUpdate */;
676
+ }
677
+ {
678
+ hostRef.$flags$ |= 2 /* hasRendered */;
679
+ }
680
+ {
681
+ {
682
+ // looks like we've got child nodes to render into this host element
683
+ // or we need to update the css class/attrs on the host element
684
+ // DOM WRITE!
685
+ {
686
+ renderVdom(hostRef, instance);
687
+ }
688
+ }
689
+ }
690
+ }
691
+ catch (e) {
692
+ consoleError(e, hostRef.$hostElement$);
693
+ }
694
+ return null;
695
+ };
696
+ const postUpdateComponent = (hostRef) => {
697
+ const tagName = hostRef.$cmpMeta$.$tagName$;
698
+ const elm = hostRef.$hostElement$;
699
+ const endPostUpdate = createTime('postUpdate', tagName);
700
+ const ancestorComponent = hostRef.$ancestorComponent$;
701
+ if (!(hostRef.$flags$ & 64 /* hasLoadedComponent */)) {
702
+ hostRef.$flags$ |= 64 /* hasLoadedComponent */;
703
+ {
704
+ // DOM WRITE!
705
+ addHydratedFlag(elm);
706
+ }
707
+ endPostUpdate();
708
+ {
709
+ hostRef.$onReadyResolve$(elm);
710
+ if (!ancestorComponent) {
711
+ appDidLoad();
712
+ }
713
+ }
714
+ }
715
+ else {
716
+ endPostUpdate();
717
+ }
718
+ // load events fire from bottom to top
719
+ // the deepest elements load first then bubbles up
720
+ {
721
+ if (hostRef.$onRenderResolve$) {
722
+ hostRef.$onRenderResolve$();
723
+ hostRef.$onRenderResolve$ = undefined;
724
+ }
725
+ if (hostRef.$flags$ & 512 /* needsRerender */) {
726
+ nextTick(() => scheduleUpdate(hostRef, false));
727
+ }
728
+ hostRef.$flags$ &= ~(4 /* isWaitingForChildren */ | 512 /* needsRerender */);
729
+ }
730
+ // ( •_•)
731
+ // ( •_•)>⌐■-■
732
+ // (⌐■_■)
733
+ };
734
+ const appDidLoad = (who) => {
735
+ // on appload
736
+ // we have finish the first big initial render
737
+ {
738
+ addHydratedFlag(doc.documentElement);
739
+ }
740
+ nextTick(() => emitEvent(win, 'appload', { detail: { namespace: NAMESPACE } }));
741
+ };
742
+ const safeCall = (instance, method, arg) => {
743
+ if (instance && instance[method]) {
744
+ try {
745
+ return instance[method](arg);
746
+ }
747
+ catch (e) {
748
+ consoleError(e);
749
+ }
750
+ }
751
+ return undefined;
752
+ };
753
+ const then = (promise, thenFn) => {
754
+ return promise && promise.then ? promise.then(thenFn) : thenFn();
755
+ };
756
+ const addHydratedFlag = (elm) => elm.classList.add('hydrated')
757
+ ;
758
+ /**
759
+ * Parse a new property value for a given property type.
760
+ *
761
+ * While the prop value can reasonably be expected to be of `any` type as far as TypeScript's type checker is concerned,
762
+ * it is not safe to assume that the string returned by evaluating `typeof propValue` matches:
763
+ * 1. `any`, the type given to `propValue` in the function signature
764
+ * 2. the type stored from `propType`.
765
+ *
766
+ * This function provides the capability to parse/coerce a property's value to potentially any other JavaScript type.
767
+ *
768
+ * Property values represented in TSX preserve their type information. In the example below, the number 0 is passed to
769
+ * a component. This `propValue` will preserve its type information (`typeof propValue === 'number'`). Note that is
770
+ * based on the type of the value being passed in, not the type declared of the class member decorated with `@Prop`.
771
+ * ```tsx
772
+ * <my-cmp prop-val={0}></my-cmp>
773
+ * ```
774
+ *
775
+ * HTML prop values on the other hand, will always a string
776
+ *
777
+ * @param propValue the new value to coerce to some type
778
+ * @param propType the type of the prop, expressed as a binary number
779
+ * @returns the parsed/coerced value
780
+ */
781
+ const parsePropertyValue = (propValue, propType) => {
782
+ // ensure this value is of the correct prop type
783
+ if (propValue != null && !isComplexType(propValue)) {
784
+ if (propType & 4 /* Boolean */) {
785
+ // per the HTML spec, any string value means it is a boolean true value
786
+ // but we'll cheat here and say that the string "false" is the boolean false
787
+ return propValue === 'false' ? false : propValue === '' || !!propValue;
788
+ }
789
+ if (propType & 1 /* String */) {
790
+ // could have been passed as a number or boolean
791
+ // but we still want it as a string
792
+ return String(propValue);
793
+ }
794
+ // redundant return here for better minification
795
+ return propValue;
796
+ }
797
+ // not sure exactly what type we want
798
+ // so no need to change to a different type
799
+ return propValue;
800
+ };
801
+ const getValue = (ref, propName) => getHostRef(ref).$instanceValues$.get(propName);
802
+ const setValue = (ref, propName, newVal, cmpMeta) => {
803
+ // check our new property value against our internal value
804
+ const hostRef = getHostRef(ref);
805
+ const elm = hostRef.$hostElement$ ;
806
+ const oldVal = hostRef.$instanceValues$.get(propName);
807
+ const flags = hostRef.$flags$;
808
+ const instance = hostRef.$lazyInstance$ ;
809
+ newVal = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]);
810
+ // explicitly check for NaN on both sides, as `NaN === NaN` is always false
811
+ const areBothNaN = Number.isNaN(oldVal) && Number.isNaN(newVal);
812
+ const didValueChange = newVal !== oldVal && !areBothNaN;
813
+ if ((!(flags & 8 /* isConstructingInstance */) || oldVal === undefined) && didValueChange) {
814
+ // gadzooks! the property's value has changed!!
815
+ // set our new value!
816
+ hostRef.$instanceValues$.set(propName, newVal);
817
+ if (instance) {
818
+ // get an array of method names of watch functions to call
819
+ if (cmpMeta.$watchers$ && flags & 128 /* isWatchReady */) {
820
+ const watchMethods = cmpMeta.$watchers$[propName];
821
+ if (watchMethods) {
822
+ // this instance is watching for when this property changed
823
+ watchMethods.map((watchMethodName) => {
824
+ try {
825
+ // fire off each of the watch methods that are watching this property
826
+ instance[watchMethodName](newVal, oldVal, propName);
827
+ }
828
+ catch (e) {
829
+ consoleError(e, elm);
830
+ }
831
+ });
832
+ }
833
+ }
834
+ if ((flags & (2 /* hasRendered */ | 16 /* isQueuedForUpdate */)) === 2 /* hasRendered */) {
835
+ // looks like this value actually changed, so we've got work to do!
836
+ // but only if we've already rendered, otherwise just chill out
837
+ // queue that we need to do an update, but don't worry about queuing
838
+ // up millions cuz this function ensures it only runs once
839
+ scheduleUpdate(hostRef, false);
840
+ }
841
+ }
842
+ }
843
+ };
844
+ const proxyComponent = (Cstr, cmpMeta, flags) => {
845
+ if (cmpMeta.$members$) {
846
+ if (Cstr.watchers) {
847
+ cmpMeta.$watchers$ = Cstr.watchers;
848
+ }
849
+ // It's better to have a const than two Object.entries()
850
+ const members = Object.entries(cmpMeta.$members$);
851
+ const prototype = Cstr.prototype;
852
+ members.map(([memberName, [memberFlags]]) => {
853
+ if ((memberFlags & 31 /* Prop */ ||
854
+ ((flags & 2 /* proxyState */) && memberFlags & 32 /* State */))) {
855
+ // proxyComponent - prop
856
+ Object.defineProperty(prototype, memberName, {
857
+ get() {
858
+ // proxyComponent, get value
859
+ return getValue(this, memberName);
860
+ },
861
+ set(newValue) {
862
+ // proxyComponent, set value
863
+ setValue(this, memberName, newValue, cmpMeta);
864
+ },
865
+ configurable: true,
866
+ enumerable: true,
867
+ });
868
+ }
869
+ });
870
+ if ((flags & 1 /* isElementConstructor */)) {
871
+ const attrNameToPropName = new Map();
872
+ prototype.attributeChangedCallback = function (attrName, _oldValue, newValue) {
873
+ plt.jmp(() => {
874
+ const propName = attrNameToPropName.get(attrName);
875
+ // In a web component lifecycle the attributeChangedCallback runs prior to connectedCallback
876
+ // in the case where an attribute was set inline.
877
+ // ```html
878
+ // <my-component some-attribute="some-value"></my-component>
879
+ // ```
880
+ //
881
+ // There is an edge case where a developer sets the attribute inline on a custom element and then
882
+ // programmatically changes it before it has been upgraded as shown below:
883
+ //
884
+ // ```html
885
+ // <!-- this component has _not_ been upgraded yet -->
886
+ // <my-component id="test" some-attribute="some-value"></my-component>
887
+ // <script>
888
+ // // grab non-upgraded component
889
+ // el = document.querySelector("#test");
890
+ // el.someAttribute = "another-value";
891
+ // // upgrade component
892
+ // customElements.define('my-component', MyComponent);
893
+ // </script>
894
+ // ```
895
+ // In this case if we do not unshadow here and use the value of the shadowing property, attributeChangedCallback
896
+ // will be called with `newValue = "some-value"` and will set the shadowed property (this.someAttribute = "another-value")
897
+ // to the value that was set inline i.e. "some-value" from above example. When
898
+ // the connectedCallback attempts to unshadow it will use "some-value" as the initial value rather than "another-value"
899
+ //
900
+ // The case where the attribute was NOT set inline but was not set programmatically shall be handled/unshadowed
901
+ // by connectedCallback as this attributeChangedCallback will not fire.
902
+ //
903
+ // https://developers.google.com/web/fundamentals/web-components/best-practices#lazy-properties
904
+ //
905
+ // TODO(STENCIL-16) we should think about whether or not we actually want to be reflecting the attributes to
906
+ // properties here given that this goes against best practices outlined here
907
+ // https://developers.google.com/web/fundamentals/web-components/best-practices#avoid-reentrancy
908
+ if (this.hasOwnProperty(propName)) {
909
+ newValue = this[propName];
910
+ delete this[propName];
911
+ }
912
+ else if (prototype.hasOwnProperty(propName) &&
913
+ typeof this[propName] === 'number' &&
914
+ this[propName] == newValue) {
915
+ // if the propName exists on the prototype of `Cstr`, this update may be a result of Stencil using native
916
+ // APIs to reflect props as attributes. Calls to `setAttribute(someElement, propName)` will result in
917
+ // `propName` to be converted to a `DOMString`, which may not be what we want for other primitive props.
918
+ return;
919
+ }
920
+ this[propName] = newValue === null && typeof this[propName] === 'boolean' ? false : newValue;
921
+ });
922
+ };
923
+ // create an array of attributes to observe
924
+ // and also create a map of html attribute name to js property name
925
+ Cstr.observedAttributes = members
926
+ .filter(([_, m]) => m[0] & 15 /* HasAttribute */) // filter to only keep props that should match attributes
927
+ .map(([propName, m]) => {
928
+ const attrName = m[1] || propName;
929
+ attrNameToPropName.set(attrName, propName);
930
+ return attrName;
931
+ });
932
+ }
933
+ }
934
+ return Cstr;
935
+ };
936
+ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) => {
937
+ // initializeComponent
938
+ if ((hostRef.$flags$ & 32 /* hasInitializedComponent */) === 0) {
939
+ {
940
+ // we haven't initialized this element yet
941
+ hostRef.$flags$ |= 32 /* hasInitializedComponent */;
942
+ // lazy loaded components
943
+ // request the component's implementation to be
944
+ // wired up with the host element
945
+ Cstr = loadModule(cmpMeta);
946
+ if (Cstr.then) {
947
+ // Await creates a micro-task avoid if possible
948
+ const endLoad = uniqueTime();
949
+ Cstr = await Cstr;
950
+ endLoad();
951
+ }
952
+ if (!Cstr.isProxied) {
953
+ // we've never proxied this Constructor before
954
+ // let's add the getters/setters to its prototype before
955
+ // the first time we create an instance of the implementation
956
+ {
957
+ cmpMeta.$watchers$ = Cstr.watchers;
958
+ }
959
+ proxyComponent(Cstr, cmpMeta, 2 /* proxyState */);
960
+ Cstr.isProxied = true;
961
+ }
962
+ const endNewInstance = createTime('createInstance', cmpMeta.$tagName$);
963
+ // ok, time to construct the instance
964
+ // but let's keep track of when we start and stop
965
+ // so that the getters/setters don't incorrectly step on data
966
+ {
967
+ hostRef.$flags$ |= 8 /* isConstructingInstance */;
968
+ }
969
+ // construct the lazy-loaded component implementation
970
+ // passing the hostRef is very important during
971
+ // construction in order to directly wire together the
972
+ // host element and the lazy-loaded instance
973
+ try {
974
+ new Cstr(hostRef);
975
+ }
976
+ catch (e) {
977
+ consoleError(e);
978
+ }
979
+ {
980
+ hostRef.$flags$ &= ~8 /* isConstructingInstance */;
981
+ }
982
+ {
983
+ hostRef.$flags$ |= 128 /* isWatchReady */;
984
+ }
985
+ endNewInstance();
986
+ }
987
+ if (Cstr.style) {
988
+ // this component has styles but we haven't registered them yet
989
+ let style = Cstr.style;
990
+ const scopeId = getScopeId(cmpMeta);
991
+ if (!styles.has(scopeId)) {
992
+ const endRegisterStyles = createTime('registerStyles', cmpMeta.$tagName$);
993
+ registerStyle(scopeId, style, !!(cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */));
994
+ endRegisterStyles();
995
+ }
996
+ }
997
+ }
998
+ // we've successfully created a lazy instance
999
+ const ancestorComponent = hostRef.$ancestorComponent$;
1000
+ const schedule = () => scheduleUpdate(hostRef, true);
1001
+ if (ancestorComponent && ancestorComponent['s-rc']) {
1002
+ // this is the initial load and this component it has an ancestor component
1003
+ // but the ancestor component has NOT fired its will update lifecycle yet
1004
+ // so let's just cool our jets and wait for the ancestor to continue first
1005
+ // this will get fired off when the ancestor component
1006
+ // finally gets around to rendering its lazy self
1007
+ // fire off the initial update
1008
+ ancestorComponent['s-rc'].push(schedule);
1009
+ }
1010
+ else {
1011
+ schedule();
1012
+ }
1013
+ };
1014
+ const connectedCallback = (elm) => {
1015
+ if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0) {
1016
+ const hostRef = getHostRef(elm);
1017
+ const cmpMeta = hostRef.$cmpMeta$;
1018
+ const endConnected = createTime('connectedCallback', cmpMeta.$tagName$);
1019
+ if (!(hostRef.$flags$ & 1 /* hasConnected */)) {
1020
+ // first time this component has connected
1021
+ hostRef.$flags$ |= 1 /* hasConnected */;
1022
+ {
1023
+ // find the first ancestor component (if there is one) and register
1024
+ // this component as one of the actively loading child components for its ancestor
1025
+ let ancestorComponent = elm;
1026
+ while ((ancestorComponent = ancestorComponent.parentNode || ancestorComponent.host)) {
1027
+ // climb up the ancestors looking for the first
1028
+ // component that hasn't finished its lifecycle update yet
1029
+ if (ancestorComponent['s-p']) {
1030
+ // we found this components first ancestor component
1031
+ // keep a reference to this component's ancestor component
1032
+ attachToAncestor(hostRef, (hostRef.$ancestorComponent$ = ancestorComponent));
1033
+ break;
1034
+ }
1035
+ }
1036
+ }
1037
+ // Lazy properties
1038
+ // https://developers.google.com/web/fundamentals/web-components/best-practices#lazy-properties
1039
+ if (cmpMeta.$members$) {
1040
+ Object.entries(cmpMeta.$members$).map(([memberName, [memberFlags]]) => {
1041
+ if (memberFlags & 31 /* Prop */ && elm.hasOwnProperty(memberName)) {
1042
+ const value = elm[memberName];
1043
+ delete elm[memberName];
1044
+ elm[memberName] = value;
1045
+ }
1046
+ });
1047
+ }
1048
+ {
1049
+ initializeComponent(elm, hostRef, cmpMeta);
1050
+ }
1051
+ }
1052
+ else {
1053
+ // not the first time this has connected
1054
+ // reattach any event listeners to the host
1055
+ // since they would have been removed when disconnected
1056
+ addHostEventListeners(elm, hostRef, cmpMeta.$listeners$);
1057
+ }
1058
+ endConnected();
1059
+ }
1060
+ };
1061
+ const disconnectedCallback = (elm) => {
1062
+ if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0) {
1063
+ const hostRef = getHostRef(elm);
1064
+ {
1065
+ if (hostRef.$rmListeners$) {
1066
+ hostRef.$rmListeners$.map((rmListener) => rmListener());
1067
+ hostRef.$rmListeners$ = undefined;
1068
+ }
1069
+ }
1070
+ }
1071
+ };
1072
+ const bootstrapLazy = (lazyBundles, options = {}) => {
1073
+ const endBootstrap = createTime();
1074
+ const cmpTags = [];
1075
+ const exclude = options.exclude || [];
1076
+ const customElements = win.customElements;
1077
+ const head = doc.head;
1078
+ const metaCharset = /*@__PURE__*/ head.querySelector('meta[charset]');
1079
+ const visibilityStyle = /*@__PURE__*/ doc.createElement('style');
1080
+ const deferredConnectedCallbacks = [];
1081
+ let appLoadFallback;
1082
+ let isBootstrapping = true;
1083
+ Object.assign(plt, options);
1084
+ plt.$resourcesUrl$ = new URL(options.resourcesUrl || './', doc.baseURI).href;
1085
+ lazyBundles.map((lazyBundle) => {
1086
+ lazyBundle[1].map((compactMeta) => {
1087
+ const cmpMeta = {
1088
+ $flags$: compactMeta[0],
1089
+ $tagName$: compactMeta[1],
1090
+ $members$: compactMeta[2],
1091
+ $listeners$: compactMeta[3],
1092
+ };
1093
+ {
1094
+ cmpMeta.$members$ = compactMeta[2];
1095
+ }
1096
+ {
1097
+ cmpMeta.$listeners$ = compactMeta[3];
1098
+ }
1099
+ {
1100
+ cmpMeta.$watchers$ = {};
1101
+ }
1102
+ const tagName = cmpMeta.$tagName$;
1103
+ const HostElement = class extends HTMLElement {
1104
+ // StencilLazyHost
1105
+ constructor(self) {
1106
+ // @ts-ignore
1107
+ super(self);
1108
+ self = this;
1109
+ registerHost(self, cmpMeta);
1110
+ if (cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) {
1111
+ // this component is using shadow dom
1112
+ // and this browser supports shadow dom
1113
+ // add the read-only property "shadowRoot" to the host element
1114
+ // adding the shadow root build conditionals to minimize runtime
1115
+ {
1116
+ {
1117
+ self.attachShadow({ mode: 'open' });
1118
+ }
1119
+ }
1120
+ }
1121
+ }
1122
+ connectedCallback() {
1123
+ if (appLoadFallback) {
1124
+ clearTimeout(appLoadFallback);
1125
+ appLoadFallback = null;
1126
+ }
1127
+ if (isBootstrapping) {
1128
+ // connectedCallback will be processed once all components have been registered
1129
+ deferredConnectedCallbacks.push(this);
1130
+ }
1131
+ else {
1132
+ plt.jmp(() => connectedCallback(this));
1133
+ }
1134
+ }
1135
+ disconnectedCallback() {
1136
+ plt.jmp(() => disconnectedCallback(this));
1137
+ }
1138
+ componentOnReady() {
1139
+ return getHostRef(this).$onReadyPromise$;
1140
+ }
1141
+ };
1142
+ cmpMeta.$lazyBundleId$ = lazyBundle[0];
1143
+ if (!exclude.includes(tagName) && !customElements.get(tagName)) {
1144
+ cmpTags.push(tagName);
1145
+ customElements.define(tagName, proxyComponent(HostElement, cmpMeta, 1 /* isElementConstructor */));
1146
+ }
1147
+ });
1148
+ });
1149
+ {
1150
+ visibilityStyle.innerHTML = cmpTags + HYDRATED_CSS;
1151
+ visibilityStyle.setAttribute('data-styles', '');
1152
+ head.insertBefore(visibilityStyle, metaCharset ? metaCharset.nextSibling : head.firstChild);
1153
+ }
1154
+ // Process deferred connectedCallbacks now all components have been registered
1155
+ isBootstrapping = false;
1156
+ if (deferredConnectedCallbacks.length) {
1157
+ deferredConnectedCallbacks.map((host) => host.connectedCallback());
1158
+ }
1159
+ else {
1160
+ {
1161
+ plt.jmp(() => (appLoadFallback = setTimeout(appDidLoad, 30)));
1162
+ }
1163
+ }
1164
+ // Fallback appLoad event
1165
+ endBootstrap();
1166
+ };
1167
+ const hostRefs = new WeakMap();
1168
+ const getHostRef = (ref) => hostRefs.get(ref);
1169
+ const registerInstance = (lazyInstance, hostRef) => hostRefs.set((hostRef.$lazyInstance$ = lazyInstance), hostRef);
1170
+ const registerHost = (elm, cmpMeta) => {
1171
+ const hostRef = {
1172
+ $flags$: 0,
1173
+ $hostElement$: elm,
1174
+ $cmpMeta$: cmpMeta,
1175
+ $instanceValues$: new Map(),
1176
+ };
1177
+ {
1178
+ hostRef.$onReadyPromise$ = new Promise((r) => (hostRef.$onReadyResolve$ = r));
1179
+ elm['s-p'] = [];
1180
+ elm['s-rc'] = [];
1181
+ }
1182
+ addHostEventListeners(elm, hostRef, cmpMeta.$listeners$);
1183
+ return hostRefs.set(elm, hostRef);
1184
+ };
1185
+ const isMemberInElement = (elm, memberName) => memberName in elm;
1186
+ const consoleError = (e, el) => (0, console.error)(e, el);
1187
+ const cmpModules = /*@__PURE__*/ new Map();
1188
+ const loadModule = (cmpMeta, hostRef, hmrVersionId) => {
1189
+ // loadModuleImport
1190
+ const exportName = cmpMeta.$tagName$.replace(/-/g, '_');
1191
+ const bundleId = cmpMeta.$lazyBundleId$;
1192
+ const module = cmpModules.get(bundleId) ;
1193
+ if (module) {
1194
+ return module[exportName];
1195
+ }
1196
+ return Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require(
1197
+ /* webpackInclude: /\.entry\.js$/ */
1198
+ /* webpackExclude: /\.system\.entry\.js$/ */
1199
+ /* webpackMode: "lazy" */
1200
+ `./${bundleId}.entry.js${''}`)); }).then((importedModule) => {
1201
+ {
1202
+ cmpModules.set(bundleId, importedModule);
1203
+ }
1204
+ return importedModule[exportName];
1205
+ }, consoleError);
1206
+ };
1207
+ const styles = new Map();
1208
+ const queueDomReads = [];
1209
+ const queueDomWrites = [];
1210
+ const queueTask = (queue, write) => (cb) => {
1211
+ queue.push(cb);
1212
+ if (!queuePending) {
1213
+ queuePending = true;
1214
+ if (write && plt.$flags$ & 4 /* queueSync */) {
1215
+ nextTick(flush);
1216
+ }
1217
+ else {
1218
+ plt.raf(flush);
1219
+ }
1220
+ }
1221
+ };
1222
+ const consume = (queue) => {
1223
+ for (let i = 0; i < queue.length; i++) {
1224
+ try {
1225
+ queue[i](performance.now());
1226
+ }
1227
+ catch (e) {
1228
+ consoleError(e);
1229
+ }
1230
+ }
1231
+ queue.length = 0;
1232
+ };
1233
+ const flush = () => {
1234
+ // always force a bunch of medium callbacks to run, but still have
1235
+ // a throttle on how many can run in a certain time
1236
+ // DOM READS!!!
1237
+ consume(queueDomReads);
1238
+ // DOM WRITES!!!
1239
+ {
1240
+ consume(queueDomWrites);
1241
+ if ((queuePending = queueDomReads.length > 0)) {
1242
+ // still more to do yet, but we've run out of time
1243
+ // let's let this thing cool off and try again in the next tick
1244
+ plt.raf(flush);
1245
+ }
1246
+ }
1247
+ };
1248
+ const nextTick = /*@__PURE__*/ (cb) => promiseResolve().then(cb);
1249
+ const writeTask = /*@__PURE__*/ queueTask(queueDomWrites, true);
1250
+
1251
+ exports.bootstrapLazy = bootstrapLazy;
1252
+ exports.createEvent = createEvent;
1253
+ exports.h = h;
1254
+ exports.promiseResolve = promiseResolve;
1255
+ exports.registerInstance = registerInstance;