@everymatrix/user-transaction-history 1.13.11

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