@saasquatch/vanilla-components 1.2.4-23 → 1.2.4-24

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