@ppg_pl/pallete 0.0.1

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