@everymatrix/general-input 1.10.0

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