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 = 'calcite';
|
58 | var scopeId;
|
59 | var contentRef;
|
60 | var hostTagName;
|
61 | var useNativeShadowDom = false;
|
62 | var checkSlotFallbackVisibility = false;
|
63 | var checkSlotRelocate = false;
|
64 | var isSvgMode = false;
|
65 | var queueCongestion = 0;
|
66 | var queuePending = false;
|
67 | var win = typeof window !== 'undefined' ? window : {};
|
68 | var CSS = win.CSS;
|
69 | var doc = win.document || { head: {} };
|
70 | var plt = {
|
71 | $flags$: 0,
|
72 | $resourcesUrl$: '',
|
73 | jmp: function (h) { return h(); },
|
74 | raf: function (h) { return requestAnimationFrame(h); },
|
75 | ael: function (el, eventName, listener, opts) { return el.addEventListener(eventName, listener, opts); },
|
76 | rel: function (el, eventName, listener, opts) { return el.removeEventListener(eventName, listener, opts); },
|
77 | };
|
78 | var supportsShadow = (function () { return (doc.head.attachShadow + '').indexOf('[native') > -1; })();
|
79 | var promiseResolve = function (v) { return Promise.resolve(v); };
|
80 | var supportsConstructibleStylesheets = (function () {
|
81 | try {
|
82 | new CSSStyleSheet();
|
83 | return true;
|
84 | }
|
85 | catch (e) { }
|
86 | return false;
|
87 | })();
|
88 | var addHostEventListeners = function (elm, hostRef, listeners, attachParentListeners) {
|
89 | if (listeners) {
|
90 |
|
91 |
|
92 |
|
93 |
|
94 | {
|
95 |
|
96 | if (attachParentListeners) {
|
97 |
|
98 |
|
99 |
|
100 | listeners = listeners.filter(function (_a) {
|
101 | var flags = _a[0];
|
102 | return flags & 16;
|
103 | } );
|
104 | }
|
105 | else {
|
106 |
|
107 |
|
108 |
|
109 | listeners = listeners.filter(function (_a) {
|
110 | var flags = _a[0];
|
111 | return !(flags & 16 );
|
112 | });
|
113 | }
|
114 | }
|
115 | listeners.map(function (_a) {
|
116 | var flags = _a[0], name = _a[1], method = _a[2];
|
117 | var target = getHostListenerTarget(elm, flags);
|
118 | var handler = hostListenerProxy(hostRef, method);
|
119 | var opts = hostListenerOpts(flags);
|
120 | plt.ael(target, name, handler, opts);
|
121 | (hostRef.$rmListeners$ = hostRef.$rmListeners$ || []).push(function () { return plt.rel(target, name, handler, opts); });
|
122 | });
|
123 | }
|
124 | };
|
125 | var hostListenerProxy = function (hostRef, methodName) { return function (ev) {
|
126 | {
|
127 | if (hostRef.$flags$ & 256 ) {
|
128 |
|
129 | hostRef.$lazyInstance$[methodName](ev);
|
130 | }
|
131 | else {
|
132 | (hostRef.$queuedListeners$ = hostRef.$queuedListeners$ || []).push([methodName, ev]);
|
133 | }
|
134 | }
|
135 | }; };
|
136 | var getHostListenerTarget = function (elm, flags) {
|
137 | if (flags & 8 )
|
138 | return win;
|
139 | if (flags & 32 )
|
140 | return doc.body;
|
141 | if (flags & 16 )
|
142 | return elm.parentElement;
|
143 | return elm;
|
144 | };
|
145 |
|
146 | var hostListenerOpts = function (flags) { return (flags & 2 ) !== 0; };
|
147 | var CONTENT_REF_ID = 'r';
|
148 | var ORG_LOCATION_ID = 'o';
|
149 | var SLOT_NODE_ID = 's';
|
150 | var TEXT_NODE_ID = 't';
|
151 | var HYDRATE_ID = 's-id';
|
152 | var HYDRATED_STYLE_ID = 'sty-id';
|
153 | var HYDRATE_CHILD_ID = 'c-id';
|
154 | var HYDRATED_CSS = '{visibility:hidden}.hydrated{visibility:inherit}';
|
155 | var XLINK_NS = 'http://www.w3.org/1999/xlink';
|
156 | var createTime = function (fnName, tagName) {
|
157 | if (tagName === void 0) { tagName = ''; }
|
158 | {
|
159 | return function () {
|
160 | return;
|
161 | };
|
162 | }
|
163 | };
|
164 | var uniqueTime = function (key, measureText) {
|
165 | {
|
166 | return function () {
|
167 | return;
|
168 | };
|
169 | }
|
170 | };
|
171 | var rootAppliedStyles = new WeakMap();
|
172 | var registerStyle = function (scopeId, cssText, allowCS) {
|
173 | var style = styles.get(scopeId);
|
174 | if (supportsConstructibleStylesheets && allowCS) {
|
175 | style = (style || new CSSStyleSheet());
|
176 | style.replace(cssText);
|
177 | }
|
178 | else {
|
179 | style = cssText;
|
180 | }
|
181 | styles.set(scopeId, style);
|
182 | };
|
183 | var addStyle = function (styleContainerNode, cmpMeta, mode, hostElm) {
|
184 | var scopeId = getScopeId(cmpMeta.$tagName$);
|
185 | var style = styles.get(scopeId);
|
186 |
|
187 |
|
188 | styleContainerNode = styleContainerNode.nodeType === 11 ? styleContainerNode : doc;
|
189 | if (style) {
|
190 | if (typeof style === 'string') {
|
191 | styleContainerNode = styleContainerNode.head || styleContainerNode;
|
192 | var appliedStyles = rootAppliedStyles.get(styleContainerNode);
|
193 | var styleElm = void 0;
|
194 | if (!appliedStyles) {
|
195 | rootAppliedStyles.set(styleContainerNode, (appliedStyles = new Set()));
|
196 | }
|
197 | if (!appliedStyles.has(scopeId)) {
|
198 | if (styleContainerNode.host && (styleElm = styleContainerNode.querySelector("[" + HYDRATED_STYLE_ID + "=\"" + scopeId + "\"]"))) {
|
199 |
|
200 | styleElm.innerHTML = style;
|
201 | }
|
202 | else {
|
203 | if (plt.$cssShim$) {
|
204 | styleElm = plt.$cssShim$.createHostStyle(hostElm, scopeId, style, !!(cmpMeta.$flags$ & 10 ));
|
205 | var newScopeId = styleElm['s-sc'];
|
206 | if (newScopeId) {
|
207 | scopeId = newScopeId;
|
208 |
|
209 |
|
210 |
|
211 | appliedStyles = null;
|
212 | }
|
213 | }
|
214 | else {
|
215 | styleElm = doc.createElement('style');
|
216 | styleElm.innerHTML = style;
|
217 | }
|
218 | styleContainerNode.insertBefore(styleElm, styleContainerNode.querySelector('link'));
|
219 | }
|
220 | if (appliedStyles) {
|
221 | appliedStyles.add(scopeId);
|
222 | }
|
223 | }
|
224 | }
|
225 | else if (!styleContainerNode.adoptedStyleSheets.includes(style)) {
|
226 | styleContainerNode.adoptedStyleSheets = __spreadArrays(styleContainerNode.adoptedStyleSheets, [style]);
|
227 | }
|
228 | }
|
229 | return scopeId;
|
230 | };
|
231 | var attachStyles = function (hostRef) {
|
232 | var cmpMeta = hostRef.$cmpMeta$;
|
233 | var elm = hostRef.$hostElement$;
|
234 | var flags = cmpMeta.$flags$;
|
235 | var endAttachStyles = createTime('attachStyles', cmpMeta.$tagName$);
|
236 | var scopeId = addStyle(supportsShadow && elm.shadowRoot ? elm.shadowRoot : elm.getRootNode(), cmpMeta, hostRef.$modeName$, elm);
|
237 | if (flags & 10 ) {
|
238 |
|
239 |
|
240 |
|
241 |
|
242 |
|
243 |
|
244 |
|
245 | elm['s-sc'] = scopeId;
|
246 | elm.classList.add(scopeId + '-h');
|
247 | }
|
248 | endAttachStyles();
|
249 | };
|
250 | var getScopeId = function (tagName, mode) { return 'sc-' + (tagName); };
|
251 | var convertScopedToShadow = function (css) { return css.replace(/\/\*!@([^\/]+)\*\/[^\{]+\{/g, '$1{'); };
|
252 |
|
253 |
|
254 |
|
255 |
|
256 |
|
257 |
|
258 |
|
259 | var EMPTY_OBJ = {};
|
260 |
|
261 |
|
262 |
|
263 | var SVG_NS = 'http://www.w3.org/2000/svg';
|
264 | var HTML_NS = 'http://www.w3.org/1999/xhtml';
|
265 | var isDef = function (v) { return v != null; };
|
266 | var isComplexType = function (o) {
|
267 |
|
268 | o = typeof o;
|
269 | return o === 'object' || o === 'function';
|
270 | };
|
271 | var getDynamicImportFunction = function (namespace) { return "__sc_import_" + namespace.replace(/\s|-/g, '_'); };
|
272 |
|
273 |
|
274 |
|
275 |
|
276 |
|
277 |
|
278 |
|
279 |
|
280 |
|
281 |
|
282 |
|
283 | var h = function (nodeName, vnodeData) {
|
284 | var children = [];
|
285 | for (var _i = 2; _i < arguments.length; _i++) {
|
286 | children[_i - 2] = arguments[_i];
|
287 | }
|
288 | var child = null;
|
289 | var key = null;
|
290 | var slotName = null;
|
291 | var simple = false;
|
292 | var lastSimple = false;
|
293 | var vNodeChildren = [];
|
294 | var walk = function (c) {
|
295 | for (var i = 0; i < c.length; i++) {
|
296 | child = c[i];
|
297 | if (Array.isArray(child)) {
|
298 | walk(child);
|
299 | }
|
300 | else if (child != null && typeof child !== 'boolean') {
|
301 | if ((simple = typeof nodeName !== 'function' && !isComplexType(child))) {
|
302 | child = String(child);
|
303 | }
|
304 | if (simple && lastSimple) {
|
305 |
|
306 | vNodeChildren[vNodeChildren.length - 1].$text$ += child;
|
307 | }
|
308 | else {
|
309 |
|
310 | vNodeChildren.push(simple ? newVNode(null, child) : child);
|
311 | }
|
312 | lastSimple = simple;
|
313 | }
|
314 | }
|
315 | };
|
316 | walk(children);
|
317 | if (vnodeData) {
|
318 |
|
319 | if (vnodeData.key) {
|
320 | key = vnodeData.key;
|
321 | }
|
322 | if (vnodeData.name) {
|
323 | slotName = vnodeData.name;
|
324 | }
|
325 | {
|
326 | var classData_1 = vnodeData.className || vnodeData.class;
|
327 | if (classData_1) {
|
328 | vnodeData.class =
|
329 | typeof classData_1 !== 'object'
|
330 | ? classData_1
|
331 | : Object.keys(classData_1)
|
332 | .filter(function (k) { return classData_1[k]; })
|
333 | .join(' ');
|
334 | }
|
335 | }
|
336 | }
|
337 | if (typeof nodeName === 'function') {
|
338 |
|
339 | return nodeName(vnodeData === null ? {} : vnodeData, vNodeChildren, vdomFnUtils);
|
340 | }
|
341 | var vnode = newVNode(nodeName, null);
|
342 | vnode.$attrs$ = vnodeData;
|
343 | if (vNodeChildren.length > 0) {
|
344 | vnode.$children$ = vNodeChildren;
|
345 | }
|
346 | {
|
347 | vnode.$key$ = key;
|
348 | }
|
349 | {
|
350 | vnode.$name$ = slotName;
|
351 | }
|
352 | return vnode;
|
353 | };
|
354 | var newVNode = function (tag, text) {
|
355 | var vnode = {
|
356 | $flags$: 0,
|
357 | $tag$: tag,
|
358 | $text$: text,
|
359 | $elm$: null,
|
360 | $children$: null,
|
361 | };
|
362 | {
|
363 | vnode.$attrs$ = null;
|
364 | }
|
365 | {
|
366 | vnode.$key$ = null;
|
367 | }
|
368 | {
|
369 | vnode.$name$ = null;
|
370 | }
|
371 | return vnode;
|
372 | };
|
373 | var Host = {};
|
374 | var isHost = function (node) { return node && node.$tag$ === Host; };
|
375 | var vdomFnUtils = {
|
376 | forEach: function (children, cb) { return children.map(convertToPublic).forEach(cb); },
|
377 | map: function (children, cb) { return children
|
378 | .map(convertToPublic)
|
379 | .map(cb)
|
380 | .map(convertToPrivate); },
|
381 | };
|
382 | var convertToPublic = function (node) { return ({
|
383 | vattrs: node.$attrs$,
|
384 | vchildren: node.$children$,
|
385 | vkey: node.$key$,
|
386 | vname: node.$name$,
|
387 | vtag: node.$tag$,
|
388 | vtext: node.$text$,
|
389 | }); };
|
390 | var convertToPrivate = function (node) {
|
391 | var vnode = newVNode(node.vtag, node.vtext);
|
392 | vnode.$attrs$ = node.vattrs;
|
393 | vnode.$children$ = node.vchildren;
|
394 | vnode.$key$ = node.vkey;
|
395 | vnode.$name$ = node.vname;
|
396 | return vnode;
|
397 | };
|
398 |
|
399 |
|
400 |
|
401 |
|
402 |
|
403 |
|
404 |
|
405 |
|
406 | var setAccessor = function (elm, memberName, oldValue, newValue, isSvg, flags) {
|
407 | if (oldValue !== newValue) {
|
408 | var isProp = isMemberInElement(elm, memberName);
|
409 | var ln = memberName.toLowerCase();
|
410 | if (memberName === 'class') {
|
411 | var classList = elm.classList;
|
412 | var oldClasses_1 = parseClassList(oldValue);
|
413 | var newClasses_1 = parseClassList(newValue);
|
414 | classList.remove.apply(classList, oldClasses_1.filter(function (c) { return c && !newClasses_1.includes(c); }));
|
415 | classList.add.apply(classList, newClasses_1.filter(function (c) { return c && !oldClasses_1.includes(c); }));
|
416 | }
|
417 | else if (memberName === 'style') {
|
418 |
|
419 | {
|
420 | for (var prop in oldValue) {
|
421 | if (!newValue || newValue[prop] == null) {
|
422 | if (prop.includes('-')) {
|
423 | elm.style.removeProperty(prop);
|
424 | }
|
425 | else {
|
426 | elm.style[prop] = '';
|
427 | }
|
428 | }
|
429 | }
|
430 | }
|
431 | for (var prop in newValue) {
|
432 | if (!oldValue || newValue[prop] !== oldValue[prop]) {
|
433 | if (prop.includes('-')) {
|
434 | elm.style.setProperty(prop, newValue[prop]);
|
435 | }
|
436 | else {
|
437 | elm.style[prop] = newValue[prop];
|
438 | }
|
439 | }
|
440 | }
|
441 | }
|
442 | else if (memberName === 'key')
|
443 | ;
|
444 | else if (memberName === 'ref') {
|
445 |
|
446 | if (newValue) {
|
447 | newValue(elm);
|
448 | }
|
449 | }
|
450 | else if ((!isProp) && memberName[0] === 'o' && memberName[1] === 'n') {
|
451 |
|
452 |
|
453 |
|
454 |
|
455 | if (memberName[2] === '-') {
|
456 |
|
457 |
|
458 |
|
459 |
|
460 |
|
461 |
|
462 |
|
463 | memberName = memberName.slice(3);
|
464 | }
|
465 | else if (isMemberInElement(win, ln)) {
|
466 |
|
467 |
|
468 |
|
469 |
|
470 | memberName = ln.slice(2);
|
471 | }
|
472 | else {
|
473 |
|
474 |
|
475 |
|
476 |
|
477 |
|
478 | memberName = ln[2] + memberName.slice(3);
|
479 | }
|
480 | if (oldValue) {
|
481 | plt.rel(elm, memberName, oldValue, false);
|
482 | }
|
483 | if (newValue) {
|
484 | plt.ael(elm, memberName, newValue, false);
|
485 | }
|
486 | }
|
487 | else {
|
488 |
|
489 | var isComplex = isComplexType(newValue);
|
490 | if ((isProp || (isComplex && newValue !== null)) && !isSvg) {
|
491 | try {
|
492 | if (!elm.tagName.includes('-')) {
|
493 | var n = newValue == null ? '' : newValue;
|
494 |
|
495 | if (memberName === 'list') {
|
496 | isProp = false;
|
497 |
|
498 | }
|
499 | else if (oldValue == null || elm[memberName] != n) {
|
500 | elm[memberName] = n;
|
501 | }
|
502 | }
|
503 | else {
|
504 | elm[memberName] = newValue;
|
505 | }
|
506 | }
|
507 | catch (e) { }
|
508 | }
|
509 | |
510 |
|
511 |
|
512 |
|
513 |
|
514 |
|
515 |
|
516 | var xlink = false;
|
517 | {
|
518 | if (ln !== (ln = ln.replace(/^xlink\:?/, ''))) {
|
519 | memberName = ln;
|
520 | xlink = true;
|
521 | }
|
522 | }
|
523 | if (newValue == null || newValue === false) {
|
524 | if (xlink) {
|
525 | elm.removeAttributeNS(XLINK_NS, memberName);
|
526 | }
|
527 | else {
|
528 | elm.removeAttribute(memberName);
|
529 | }
|
530 | }
|
531 | else if ((!isProp || flags & 4 || isSvg) && !isComplex) {
|
532 | newValue = newValue === true ? '' : newValue;
|
533 | if (xlink) {
|
534 | elm.setAttributeNS(XLINK_NS, memberName, newValue);
|
535 | }
|
536 | else {
|
537 | elm.setAttribute(memberName, newValue);
|
538 | }
|
539 | }
|
540 | }
|
541 | }
|
542 | };
|
543 | var parseClassListRegex = /\s/;
|
544 | var parseClassList = function (value) { return (!value ? [] : value.split(parseClassListRegex)); };
|
545 | var updateElement = function (oldVnode, newVnode, isSvgMode, memberName) {
|
546 |
|
547 |
|
548 |
|
549 | var elm = newVnode.$elm$.nodeType === 11 && newVnode.$elm$.host ? newVnode.$elm$.host : newVnode.$elm$;
|
550 | var oldVnodeAttrs = (oldVnode && oldVnode.$attrs$) || EMPTY_OBJ;
|
551 | var newVnodeAttrs = newVnode.$attrs$ || EMPTY_OBJ;
|
552 | {
|
553 |
|
554 | for (memberName in oldVnodeAttrs) {
|
555 | if (!(memberName in newVnodeAttrs)) {
|
556 | setAccessor(elm, memberName, oldVnodeAttrs[memberName], undefined, isSvgMode, newVnode.$flags$);
|
557 | }
|
558 | }
|
559 | }
|
560 |
|
561 | for (memberName in newVnodeAttrs) {
|
562 | setAccessor(elm, memberName, oldVnodeAttrs[memberName], newVnodeAttrs[memberName], isSvgMode, newVnode.$flags$);
|
563 | }
|
564 | };
|
565 | var createElm = function (oldParentVNode, newParentVNode, childIndex, parentElm) {
|
566 |
|
567 | var newVNode = newParentVNode.$children$[childIndex];
|
568 | var i = 0;
|
569 | var elm;
|
570 | var childNode;
|
571 | var oldVNode;
|
572 | if (!useNativeShadowDom) {
|
573 |
|
574 | checkSlotRelocate = true;
|
575 | if (newVNode.$tag$ === 'slot') {
|
576 | if (scopeId) {
|
577 |
|
578 | parentElm.classList.add(scopeId + '-s');
|
579 | }
|
580 | newVNode.$flags$ |= newVNode.$children$
|
581 | ?
|
582 | 2
|
583 | :
|
584 | 1 ;
|
585 | }
|
586 | }
|
587 | if (newVNode.$text$ !== null) {
|
588 |
|
589 | elm = newVNode.$elm$ = doc.createTextNode(newVNode.$text$);
|
590 | }
|
591 | else if (newVNode.$flags$ & 1 ) {
|
592 |
|
593 | elm = newVNode.$elm$ = doc.createTextNode('');
|
594 | }
|
595 | else {
|
596 | if (!isSvgMode) {
|
597 | isSvgMode = newVNode.$tag$ === 'svg';
|
598 | }
|
599 |
|
600 | elm = newVNode.$elm$ = (doc.createElementNS(isSvgMode ? SVG_NS : HTML_NS, newVNode.$flags$ & 2 ? 'slot-fb' : newVNode.$tag$));
|
601 | if (isSvgMode && newVNode.$tag$ === 'foreignObject') {
|
602 | isSvgMode = false;
|
603 | }
|
604 |
|
605 | {
|
606 | updateElement(null, newVNode, isSvgMode);
|
607 | }
|
608 | if (isDef(scopeId) && elm['s-si'] !== scopeId) {
|
609 |
|
610 |
|
611 | elm.classList.add((elm['s-si'] = scopeId));
|
612 | }
|
613 | if (newVNode.$children$) {
|
614 | for (i = 0; i < newVNode.$children$.length; ++i) {
|
615 |
|
616 | childNode = createElm(oldParentVNode, newVNode, i, elm);
|
617 |
|
618 | if (childNode) {
|
619 |
|
620 | elm.appendChild(childNode);
|
621 | }
|
622 | }
|
623 | }
|
624 | {
|
625 | if (newVNode.$tag$ === 'svg') {
|
626 |
|
627 | isSvgMode = false;
|
628 | }
|
629 | else if (elm.tagName === 'foreignObject') {
|
630 |
|
631 | isSvgMode = true;
|
632 | }
|
633 | }
|
634 | }
|
635 | {
|
636 | elm['s-hn'] = hostTagName;
|
637 | if (newVNode.$flags$ & (2 | 1 )) {
|
638 |
|
639 | elm['s-sr'] = true;
|
640 |
|
641 | elm['s-cr'] = contentRef;
|
642 |
|
643 | elm['s-sn'] = newVNode.$name$ || '';
|
644 |
|
645 | oldVNode = oldParentVNode && oldParentVNode.$children$ && oldParentVNode.$children$[childIndex];
|
646 | if (oldVNode && oldVNode.$tag$ === newVNode.$tag$ && oldParentVNode.$elm$) {
|
647 |
|
648 |
|
649 | putBackInOriginalLocation(oldParentVNode.$elm$, false);
|
650 | }
|
651 | }
|
652 | }
|
653 | return elm;
|
654 | };
|
655 | var putBackInOriginalLocation = function (parentElm, recursive) {
|
656 | plt.$flags$ |= 1 ;
|
657 | var oldSlotChildNodes = parentElm.childNodes;
|
658 | for (var i = oldSlotChildNodes.length - 1; i >= 0; i--) {
|
659 | var childNode = oldSlotChildNodes[i];
|
660 | if (childNode['s-hn'] !== hostTagName && childNode['s-ol']) {
|
661 |
|
662 |
|
663 |
|
664 |
|
665 | parentReferenceNode(childNode).insertBefore(childNode, referenceNode(childNode));
|
666 |
|
667 |
|
668 |
|
669 | childNode['s-ol'].remove();
|
670 | childNode['s-ol'] = undefined;
|
671 | checkSlotRelocate = true;
|
672 | }
|
673 | if (recursive) {
|
674 | putBackInOriginalLocation(childNode, recursive);
|
675 | }
|
676 | }
|
677 | plt.$flags$ &= ~1 ;
|
678 | };
|
679 | var addVnodes = function (parentElm, before, parentVNode, vnodes, startIdx, endIdx) {
|
680 | var containerElm = ((parentElm['s-cr'] && parentElm['s-cr'].parentNode) || parentElm);
|
681 | var childNode;
|
682 | if (containerElm.shadowRoot && containerElm.tagName === hostTagName) {
|
683 | containerElm = containerElm.shadowRoot;
|
684 | }
|
685 | for (; startIdx <= endIdx; ++startIdx) {
|
686 | if (vnodes[startIdx]) {
|
687 | childNode = createElm(null, parentVNode, startIdx, parentElm);
|
688 | if (childNode) {
|
689 | vnodes[startIdx].$elm$ = childNode;
|
690 | containerElm.insertBefore(childNode, referenceNode(before));
|
691 | }
|
692 | }
|
693 | }
|
694 | };
|
695 | var removeVnodes = function (vnodes, startIdx, endIdx, vnode, elm) {
|
696 | for (; startIdx <= endIdx; ++startIdx) {
|
697 | if ((vnode = vnodes[startIdx])) {
|
698 | elm = vnode.$elm$;
|
699 | callNodeRefs(vnode);
|
700 | {
|
701 |
|
702 |
|
703 | checkSlotFallbackVisibility = true;
|
704 | if (elm['s-ol']) {
|
705 |
|
706 | elm['s-ol'].remove();
|
707 | }
|
708 | else {
|
709 |
|
710 |
|
711 | putBackInOriginalLocation(elm, true);
|
712 | }
|
713 | }
|
714 |
|
715 | elm.remove();
|
716 | }
|
717 | }
|
718 | };
|
719 | var updateChildren = function (parentElm, oldCh, newVNode, newCh) {
|
720 | var oldStartIdx = 0;
|
721 | var newStartIdx = 0;
|
722 | var idxInOld = 0;
|
723 | var i = 0;
|
724 | var oldEndIdx = oldCh.length - 1;
|
725 | var oldStartVnode = oldCh[0];
|
726 | var oldEndVnode = oldCh[oldEndIdx];
|
727 | var newEndIdx = newCh.length - 1;
|
728 | var newStartVnode = newCh[0];
|
729 | var newEndVnode = newCh[newEndIdx];
|
730 | var node;
|
731 | var elmToMove;
|
732 | while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
|
733 | if (oldStartVnode == null) {
|
734 |
|
735 | oldStartVnode = oldCh[++oldStartIdx];
|
736 | }
|
737 | else if (oldEndVnode == null) {
|
738 | oldEndVnode = oldCh[--oldEndIdx];
|
739 | }
|
740 | else if (newStartVnode == null) {
|
741 | newStartVnode = newCh[++newStartIdx];
|
742 | }
|
743 | else if (newEndVnode == null) {
|
744 | newEndVnode = newCh[--newEndIdx];
|
745 | }
|
746 | else if (isSameVnode(oldStartVnode, newStartVnode)) {
|
747 | patch(oldStartVnode, newStartVnode);
|
748 | oldStartVnode = oldCh[++oldStartIdx];
|
749 | newStartVnode = newCh[++newStartIdx];
|
750 | }
|
751 | else if (isSameVnode(oldEndVnode, newEndVnode)) {
|
752 | patch(oldEndVnode, newEndVnode);
|
753 | oldEndVnode = oldCh[--oldEndIdx];
|
754 | newEndVnode = newCh[--newEndIdx];
|
755 | }
|
756 | else if (isSameVnode(oldStartVnode, newEndVnode)) {
|
757 |
|
758 | if ((oldStartVnode.$tag$ === 'slot' || newEndVnode.$tag$ === 'slot')) {
|
759 | putBackInOriginalLocation(oldStartVnode.$elm$.parentNode, false);
|
760 | }
|
761 | patch(oldStartVnode, newEndVnode);
|
762 | parentElm.insertBefore(oldStartVnode.$elm$, oldEndVnode.$elm$.nextSibling);
|
763 | oldStartVnode = oldCh[++oldStartIdx];
|
764 | newEndVnode = newCh[--newEndIdx];
|
765 | }
|
766 | else if (isSameVnode(oldEndVnode, newStartVnode)) {
|
767 |
|
768 | if ((oldStartVnode.$tag$ === 'slot' || newEndVnode.$tag$ === 'slot')) {
|
769 | putBackInOriginalLocation(oldEndVnode.$elm$.parentNode, false);
|
770 | }
|
771 | patch(oldEndVnode, newStartVnode);
|
772 | parentElm.insertBefore(oldEndVnode.$elm$, oldStartVnode.$elm$);
|
773 | oldEndVnode = oldCh[--oldEndIdx];
|
774 | newStartVnode = newCh[++newStartIdx];
|
775 | }
|
776 | else {
|
777 |
|
778 | idxInOld = -1;
|
779 | {
|
780 | for (i = oldStartIdx; i <= oldEndIdx; ++i) {
|
781 | if (oldCh[i] && oldCh[i].$key$ !== null && oldCh[i].$key$ === newStartVnode.$key$) {
|
782 | idxInOld = i;
|
783 | break;
|
784 | }
|
785 | }
|
786 | }
|
787 | if (idxInOld >= 0) {
|
788 | elmToMove = oldCh[idxInOld];
|
789 | if (elmToMove.$tag$ !== newStartVnode.$tag$) {
|
790 | node = createElm(oldCh && oldCh[newStartIdx], newVNode, idxInOld, parentElm);
|
791 | }
|
792 | else {
|
793 | patch(elmToMove, newStartVnode);
|
794 | oldCh[idxInOld] = undefined;
|
795 | node = elmToMove.$elm$;
|
796 | }
|
797 | newStartVnode = newCh[++newStartIdx];
|
798 | }
|
799 | else {
|
800 |
|
801 | node = createElm(oldCh && oldCh[newStartIdx], newVNode, newStartIdx, parentElm);
|
802 | newStartVnode = newCh[++newStartIdx];
|
803 | }
|
804 | if (node) {
|
805 | {
|
806 | parentReferenceNode(oldStartVnode.$elm$).insertBefore(node, referenceNode(oldStartVnode.$elm$));
|
807 | }
|
808 | }
|
809 | }
|
810 | }
|
811 | if (oldStartIdx > oldEndIdx) {
|
812 | addVnodes(parentElm, newCh[newEndIdx + 1] == null ? null : newCh[newEndIdx + 1].$elm$, newVNode, newCh, newStartIdx, newEndIdx);
|
813 | }
|
814 | else if (newStartIdx > newEndIdx) {
|
815 | removeVnodes(oldCh, oldStartIdx, oldEndIdx);
|
816 | }
|
817 | };
|
818 | var isSameVnode = function (vnode1, vnode2) {
|
819 |
|
820 |
|
821 | if (vnode1.$tag$ === vnode2.$tag$) {
|
822 | if (vnode1.$tag$ === 'slot') {
|
823 | return vnode1.$name$ === vnode2.$name$;
|
824 | }
|
825 | {
|
826 | return vnode1.$key$ === vnode2.$key$;
|
827 | }
|
828 | }
|
829 | return false;
|
830 | };
|
831 | var referenceNode = function (node) {
|
832 |
|
833 |
|
834 |
|
835 |
|
836 | return (node && node['s-ol']) || node;
|
837 | };
|
838 | var parentReferenceNode = function (node) { return (node['s-ol'] ? node['s-ol'] : node).parentNode; };
|
839 | var patch = function (oldVNode, newVNode) {
|
840 | var elm = (newVNode.$elm$ = oldVNode.$elm$);
|
841 | var oldChildren = oldVNode.$children$;
|
842 | var newChildren = newVNode.$children$;
|
843 | var tag = newVNode.$tag$;
|
844 | var text = newVNode.$text$;
|
845 | var defaultHolder;
|
846 | if (text === null) {
|
847 | {
|
848 |
|
849 |
|
850 | isSvgMode = tag === 'svg' ? true : tag === 'foreignObject' ? false : isSvgMode;
|
851 | }
|
852 |
|
853 | {
|
854 | if (tag === 'slot')
|
855 | ;
|
856 | else {
|
857 |
|
858 |
|
859 |
|
860 | updateElement(oldVNode, newVNode, isSvgMode);
|
861 | }
|
862 | }
|
863 | if (oldChildren !== null && newChildren !== null) {
|
864 |
|
865 | updateChildren(elm, oldChildren, newVNode, newChildren);
|
866 | }
|
867 | else if (newChildren !== null) {
|
868 |
|
869 | if (oldVNode.$text$ !== null) {
|
870 |
|
871 | elm.textContent = '';
|
872 | }
|
873 |
|
874 | addVnodes(elm, null, newVNode, newChildren, 0, newChildren.length - 1);
|
875 | }
|
876 | else if (oldChildren !== null) {
|
877 |
|
878 | removeVnodes(oldChildren, 0, oldChildren.length - 1);
|
879 | }
|
880 | if (isSvgMode && tag === 'svg') {
|
881 | isSvgMode = false;
|
882 | }
|
883 | }
|
884 | else if ((defaultHolder = elm['s-cr'])) {
|
885 |
|
886 | defaultHolder.parentNode.textContent = text;
|
887 | }
|
888 | else if (oldVNode.$text$ !== text) {
|
889 |
|
890 |
|
891 | elm.data = text;
|
892 | }
|
893 | };
|
894 | var updateFallbackSlotVisibility = function (elm) {
|
895 |
|
896 | var childNodes = elm.childNodes;
|
897 | var childNode;
|
898 | var i;
|
899 | var ilen;
|
900 | var j;
|
901 | var slotNameAttr;
|
902 | var nodeType;
|
903 | for (i = 0, ilen = childNodes.length; i < ilen; i++) {
|
904 | childNode = childNodes[i];
|
905 | if (childNode.nodeType === 1 ) {
|
906 | if (childNode['s-sr']) {
|
907 |
|
908 |
|
909 | slotNameAttr = childNode['s-sn'];
|
910 |
|
911 |
|
912 | childNode.hidden = false;
|
913 | for (j = 0; j < ilen; j++) {
|
914 | if (childNodes[j]['s-hn'] !== childNode['s-hn']) {
|
915 |
|
916 | nodeType = childNodes[j].nodeType;
|
917 | if (slotNameAttr !== '') {
|
918 |
|
919 | if (nodeType === 1 && slotNameAttr === childNodes[j].getAttribute('slot')) {
|
920 | childNode.hidden = true;
|
921 | break;
|
922 | }
|
923 | }
|
924 | else {
|
925 |
|
926 |
|
927 |
|
928 | if (nodeType === 1 || (nodeType === 3 && childNodes[j].textContent.trim() !== '')) {
|
929 | childNode.hidden = true;
|
930 | break;
|
931 | }
|
932 | }
|
933 | }
|
934 | }
|
935 | }
|
936 |
|
937 | updateFallbackSlotVisibility(childNode);
|
938 | }
|
939 | }
|
940 | };
|
941 | var relocateNodes = [];
|
942 | var relocateSlotContent = function (elm) {
|
943 |
|
944 | var childNode;
|
945 | var node;
|
946 | var hostContentNodes;
|
947 | var slotNameAttr;
|
948 | var relocateNodeData;
|
949 | var j;
|
950 | var i = 0;
|
951 | var childNodes = elm.childNodes;
|
952 | var ilen = childNodes.length;
|
953 | for (; i < ilen; i++) {
|
954 | childNode = childNodes[i];
|
955 | if (childNode['s-sr'] && (node = childNode['s-cr'])) {
|
956 |
|
957 |
|
958 | hostContentNodes = node.parentNode.childNodes;
|
959 | slotNameAttr = childNode['s-sn'];
|
960 | for (j = hostContentNodes.length - 1; j >= 0; j--) {
|
961 | node = hostContentNodes[j];
|
962 | if (!node['s-cn'] && !node['s-nr'] && node['s-hn'] !== childNode['s-hn']) {
|
963 |
|
964 |
|
965 |
|
966 | if (isNodeLocatedInSlot(node, slotNameAttr)) {
|
967 |
|
968 | relocateNodeData = relocateNodes.find(function (r) { return r.$nodeToRelocate$ === node; });
|
969 |
|
970 |
|
971 |
|
972 | checkSlotFallbackVisibility = true;
|
973 | node['s-sn'] = node['s-sn'] || slotNameAttr;
|
974 | if (relocateNodeData) {
|
975 |
|
976 |
|
977 | relocateNodeData.$slotRefNode$ = childNode;
|
978 | }
|
979 | else {
|
980 |
|
981 | relocateNodes.push({
|
982 | $slotRefNode$: childNode,
|
983 | $nodeToRelocate$: node,
|
984 | });
|
985 | }
|
986 | if (node['s-sr']) {
|
987 | relocateNodes.map(function (relocateNode) {
|
988 | if (isNodeLocatedInSlot(relocateNode.$nodeToRelocate$, node['s-sn'])) {
|
989 | relocateNodeData = relocateNodes.find(function (r) { return r.$nodeToRelocate$ === node; });
|
990 | if (relocateNodeData && !relocateNode.$slotRefNode$) {
|
991 | relocateNode.$slotRefNode$ = relocateNodeData.$slotRefNode$;
|
992 | }
|
993 | }
|
994 | });
|
995 | }
|
996 | }
|
997 | else if (!relocateNodes.some(function (r) { return r.$nodeToRelocate$ === node; })) {
|
998 |
|
999 |
|
1000 | relocateNodes.push({
|
1001 | $nodeToRelocate$: node,
|
1002 | });
|
1003 | }
|
1004 | }
|
1005 | }
|
1006 | }
|
1007 | if (childNode.nodeType === 1 ) {
|
1008 | relocateSlotContent(childNode);
|
1009 | }
|
1010 | }
|
1011 | };
|
1012 | var isNodeLocatedInSlot = function (nodeToRelocate, slotNameAttr) {
|
1013 | if (nodeToRelocate.nodeType === 1 ) {
|
1014 | if (nodeToRelocate.getAttribute('slot') === null && slotNameAttr === '') {
|
1015 | return true;
|
1016 | }
|
1017 | if (nodeToRelocate.getAttribute('slot') === slotNameAttr) {
|
1018 | return true;
|
1019 | }
|
1020 | return false;
|
1021 | }
|
1022 | if (nodeToRelocate['s-sn'] === slotNameAttr) {
|
1023 | return true;
|
1024 | }
|
1025 | return slotNameAttr === '';
|
1026 | };
|
1027 | var callNodeRefs = function (vNode) {
|
1028 | {
|
1029 | vNode.$attrs$ && vNode.$attrs$.ref && vNode.$attrs$.ref(null);
|
1030 | vNode.$children$ && vNode.$children$.map(callNodeRefs);
|
1031 | }
|
1032 | };
|
1033 | var renderVdom = function (hostRef, renderFnResults) {
|
1034 | var hostElm = hostRef.$hostElement$;
|
1035 | var cmpMeta = hostRef.$cmpMeta$;
|
1036 | var oldVNode = hostRef.$vnode$ || newVNode(null, null);
|
1037 | var rootVnode = isHost(renderFnResults) ? renderFnResults : h(null, null, renderFnResults);
|
1038 | hostTagName = hostElm.tagName;
|
1039 | if (cmpMeta.$attrsToReflect$) {
|
1040 | rootVnode.$attrs$ = rootVnode.$attrs$ || {};
|
1041 | cmpMeta.$attrsToReflect$.map(function (_a) {
|
1042 | var propName = _a[0], attribute = _a[1];
|
1043 | return (rootVnode.$attrs$[attribute] = hostElm[propName]);
|
1044 | });
|
1045 | }
|
1046 | rootVnode.$tag$ = null;
|
1047 | rootVnode.$flags$ |= 4 ;
|
1048 | hostRef.$vnode$ = rootVnode;
|
1049 | rootVnode.$elm$ = oldVNode.$elm$ = (hostElm.shadowRoot || hostElm);
|
1050 | {
|
1051 | scopeId = hostElm['s-sc'];
|
1052 | }
|
1053 | {
|
1054 | contentRef = hostElm['s-cr'];
|
1055 | useNativeShadowDom = supportsShadow && (cmpMeta.$flags$ & 1 ) !== 0;
|
1056 |
|
1057 | checkSlotFallbackVisibility = false;
|
1058 | }
|
1059 |
|
1060 | patch(oldVNode, rootVnode);
|
1061 | {
|
1062 |
|
1063 |
|
1064 | plt.$flags$ |= 1 ;
|
1065 | if (checkSlotRelocate) {
|
1066 | relocateSlotContent(rootVnode.$elm$);
|
1067 | var relocateData = void 0;
|
1068 | var nodeToRelocate = void 0;
|
1069 | var orgLocationNode = void 0;
|
1070 | var parentNodeRef = void 0;
|
1071 | var insertBeforeNode = void 0;
|
1072 | var refNode = void 0;
|
1073 | var i = 0;
|
1074 | for (; i < relocateNodes.length; i++) {
|
1075 | relocateData = relocateNodes[i];
|
1076 | nodeToRelocate = relocateData.$nodeToRelocate$;
|
1077 | if (!nodeToRelocate['s-ol']) {
|
1078 |
|
1079 |
|
1080 | orgLocationNode = doc.createTextNode('');
|
1081 | orgLocationNode['s-nr'] = nodeToRelocate;
|
1082 | nodeToRelocate.parentNode.insertBefore((nodeToRelocate['s-ol'] = orgLocationNode), nodeToRelocate);
|
1083 | }
|
1084 | }
|
1085 | for (i = 0; i < relocateNodes.length; i++) {
|
1086 | relocateData = relocateNodes[i];
|
1087 | nodeToRelocate = relocateData.$nodeToRelocate$;
|
1088 | if (relocateData.$slotRefNode$) {
|
1089 |
|
1090 |
|
1091 | parentNodeRef = relocateData.$slotRefNode$.parentNode;
|
1092 | insertBeforeNode = relocateData.$slotRefNode$.nextSibling;
|
1093 | orgLocationNode = nodeToRelocate['s-ol'];
|
1094 | while ((orgLocationNode = orgLocationNode.previousSibling)) {
|
1095 | refNode = orgLocationNode['s-nr'];
|
1096 | if (refNode && refNode['s-sn'] === nodeToRelocate['s-sn'] && parentNodeRef === refNode.parentNode) {
|
1097 | refNode = refNode.nextSibling;
|
1098 | if (!refNode || !refNode['s-nr']) {
|
1099 | insertBeforeNode = refNode;
|
1100 | break;
|
1101 | }
|
1102 | }
|
1103 | }
|
1104 | if ((!insertBeforeNode && parentNodeRef !== nodeToRelocate.parentNode) || nodeToRelocate.nextSibling !== insertBeforeNode) {
|
1105 |
|
1106 |
|
1107 |
|
1108 | if (nodeToRelocate !== insertBeforeNode) {
|
1109 | if (!nodeToRelocate['s-hn'] && nodeToRelocate['s-ol']) {
|
1110 |
|
1111 | nodeToRelocate['s-hn'] = nodeToRelocate['s-ol'].parentNode.nodeName;
|
1112 | }
|
1113 |
|
1114 | parentNodeRef.insertBefore(nodeToRelocate, insertBeforeNode);
|
1115 | }
|
1116 | }
|
1117 | }
|
1118 | else {
|
1119 |
|
1120 | if (nodeToRelocate.nodeType === 1 ) {
|
1121 | nodeToRelocate.hidden = true;
|
1122 | }
|
1123 | }
|
1124 | }
|
1125 | }
|
1126 | if (checkSlotFallbackVisibility) {
|
1127 | updateFallbackSlotVisibility(rootVnode.$elm$);
|
1128 | }
|
1129 |
|
1130 |
|
1131 | plt.$flags$ &= ~1 ;
|
1132 |
|
1133 | relocateNodes.length = 0;
|
1134 | }
|
1135 | };
|
1136 | var getElement = function (ref) { return (getHostRef(ref).$hostElement$); };
|
1137 | var createEvent = function (ref, name, flags) {
|
1138 | var elm = getElement(ref);
|
1139 | return {
|
1140 | emit: function (detail) {
|
1141 | return emitEvent(elm, name, {
|
1142 | bubbles: !!(flags & 4 ),
|
1143 | composed: !!(flags & 2 ),
|
1144 | cancelable: !!(flags & 1 ),
|
1145 | detail: detail,
|
1146 | });
|
1147 | },
|
1148 | };
|
1149 | };
|
1150 | var emitEvent = function (elm, name, opts) {
|
1151 | var ev = new (CustomEvent)(name, opts);
|
1152 | elm.dispatchEvent(ev);
|
1153 | return ev;
|
1154 | };
|
1155 | var attachToAncestor = function (hostRef, ancestorComponent) {
|
1156 | if (ancestorComponent && !hostRef.$onRenderResolve$) {
|
1157 | ancestorComponent['s-p'].push(new Promise(function (r) { return (hostRef.$onRenderResolve$ = r); }));
|
1158 | }
|
1159 | };
|
1160 | var scheduleUpdate = function (hostRef, isInitialLoad) {
|
1161 | {
|
1162 | hostRef.$flags$ |= 16 ;
|
1163 | }
|
1164 | if (hostRef.$flags$ & 4 ) {
|
1165 | hostRef.$flags$ |= 512 ;
|
1166 | return;
|
1167 | }
|
1168 | var endSchedule = createTime('scheduleUpdate', hostRef.$cmpMeta$.$tagName$);
|
1169 | var ancestorComponent = hostRef.$ancestorComponent$;
|
1170 | var instance = hostRef.$lazyInstance$;
|
1171 | var update = function () { return updateComponent(hostRef, instance, isInitialLoad); };
|
1172 | attachToAncestor(hostRef, ancestorComponent);
|
1173 | var promise;
|
1174 | if (isInitialLoad) {
|
1175 | {
|
1176 | hostRef.$flags$ |= 256 ;
|
1177 | if (hostRef.$queuedListeners$) {
|
1178 | hostRef.$queuedListeners$.map(function (_a) {
|
1179 | var methodName = _a[0], event = _a[1];
|
1180 | return safeCall(instance, methodName, event);
|
1181 | });
|
1182 | hostRef.$queuedListeners$ = null;
|
1183 | }
|
1184 | }
|
1185 | {
|
1186 | promise = safeCall(instance, 'componentWillLoad');
|
1187 | }
|
1188 | }
|
1189 | else {
|
1190 | {
|
1191 | promise = safeCall(instance, 'componentWillUpdate');
|
1192 | }
|
1193 | }
|
1194 | {
|
1195 | promise = then(promise, function () { return safeCall(instance, 'componentWillRender'); });
|
1196 | }
|
1197 | endSchedule();
|
1198 |
|
1199 |
|
1200 |
|
1201 | return then(promise, function () { return writeTask(update); });
|
1202 | };
|
1203 | var updateComponent = function (hostRef, instance, isInitialLoad) {
|
1204 |
|
1205 | var elm = hostRef.$hostElement$;
|
1206 | var endUpdate = createTime('update', hostRef.$cmpMeta$.$tagName$);
|
1207 | var rc = elm['s-rc'];
|
1208 | if (isInitialLoad) {
|
1209 |
|
1210 | attachStyles(hostRef);
|
1211 | }
|
1212 | var endRender = createTime('render', hostRef.$cmpMeta$.$tagName$);
|
1213 | {
|
1214 | {
|
1215 |
|
1216 |
|
1217 |
|
1218 | renderVdom(hostRef, callRender(instance));
|
1219 | }
|
1220 | }
|
1221 | if (plt.$cssShim$) {
|
1222 | plt.$cssShim$.updateHost(elm);
|
1223 | }
|
1224 | {
|
1225 | hostRef.$flags$ &= ~16 ;
|
1226 | }
|
1227 | {
|
1228 | hostRef.$flags$ |= 2 ;
|
1229 | }
|
1230 | if (rc) {
|
1231 |
|
1232 |
|
1233 |
|
1234 | rc.map(function (cb) { return cb(); });
|
1235 | elm['s-rc'] = undefined;
|
1236 | }
|
1237 | endRender();
|
1238 | endUpdate();
|
1239 | {
|
1240 | var childrenPromises = elm['s-p'];
|
1241 | var postUpdate = function () { return postUpdateComponent(hostRef); };
|
1242 | if (childrenPromises.length === 0) {
|
1243 | postUpdate();
|
1244 | }
|
1245 | else {
|
1246 | Promise.all(childrenPromises).then(postUpdate);
|
1247 | hostRef.$flags$ |= 4 ;
|
1248 | childrenPromises.length = 0;
|
1249 | }
|
1250 | }
|
1251 | };
|
1252 | var callRender = function (instance) {
|
1253 | try {
|
1254 | instance = instance.render();
|
1255 | }
|
1256 | catch (e) {
|
1257 | consoleError(e);
|
1258 | }
|
1259 | return instance;
|
1260 | };
|
1261 | var postUpdateComponent = function (hostRef) {
|
1262 | var tagName = hostRef.$cmpMeta$.$tagName$;
|
1263 | var elm = hostRef.$hostElement$;
|
1264 | var endPostUpdate = createTime('postUpdate', tagName);
|
1265 | var instance = hostRef.$lazyInstance$;
|
1266 | var ancestorComponent = hostRef.$ancestorComponent$;
|
1267 | {
|
1268 | safeCall(instance, 'componentDidRender');
|
1269 | }
|
1270 | if (!(hostRef.$flags$ & 64 )) {
|
1271 | hostRef.$flags$ |= 64 ;
|
1272 | {
|
1273 |
|
1274 | addHydratedFlag(elm);
|
1275 | }
|
1276 | {
|
1277 | safeCall(instance, 'componentDidLoad');
|
1278 | }
|
1279 | endPostUpdate();
|
1280 | {
|
1281 | hostRef.$onReadyResolve$(elm);
|
1282 | if (!ancestorComponent) {
|
1283 | appDidLoad();
|
1284 | }
|
1285 | }
|
1286 | }
|
1287 | else {
|
1288 | {
|
1289 | safeCall(instance, 'componentDidUpdate');
|
1290 | }
|
1291 | endPostUpdate();
|
1292 | }
|
1293 | {
|
1294 | hostRef.$onInstanceResolve$(elm);
|
1295 | }
|
1296 |
|
1297 |
|
1298 | {
|
1299 | if (hostRef.$onRenderResolve$) {
|
1300 | hostRef.$onRenderResolve$();
|
1301 | hostRef.$onRenderResolve$ = undefined;
|
1302 | }
|
1303 | if (hostRef.$flags$ & 512 ) {
|
1304 | nextTick(function () { return scheduleUpdate(hostRef, false); });
|
1305 | }
|
1306 | hostRef.$flags$ &= ~(4 | 512 );
|
1307 | }
|
1308 |
|
1309 |
|
1310 |
|
1311 | };
|
1312 | var forceUpdate = function (ref) {
|
1313 | {
|
1314 | var hostRef = getHostRef(ref);
|
1315 | var isConnected = hostRef.$hostElement$.isConnected;
|
1316 | if (isConnected && (hostRef.$flags$ & (2 | 16 )) === 2 ) {
|
1317 | scheduleUpdate(hostRef, false);
|
1318 | }
|
1319 |
|
1320 | return isConnected;
|
1321 | }
|
1322 | };
|
1323 | var appDidLoad = function (who) {
|
1324 |
|
1325 |
|
1326 | {
|
1327 | addHydratedFlag(doc.documentElement);
|
1328 | }
|
1329 | {
|
1330 | plt.$flags$ |= 2 ;
|
1331 | }
|
1332 | nextTick(function () { return emitEvent(win, 'appload', { detail: { namespace: NAMESPACE } }); });
|
1333 | };
|
1334 | var safeCall = function (instance, method, arg) {
|
1335 | if (instance && instance[method]) {
|
1336 | try {
|
1337 | return instance[method](arg);
|
1338 | }
|
1339 | catch (e) {
|
1340 | consoleError(e);
|
1341 | }
|
1342 | }
|
1343 | return undefined;
|
1344 | };
|
1345 | var then = function (promise, thenFn) {
|
1346 | return promise && promise.then ? promise.then(thenFn) : thenFn();
|
1347 | };
|
1348 | var addHydratedFlag = function (elm) { return (elm.classList.add('hydrated')); };
|
1349 | var initializeClientHydrate = function (hostElm, tagName, hostId, hostRef) {
|
1350 | var endHydrate = createTime('hydrateClient', tagName);
|
1351 | var shadowRoot = hostElm.shadowRoot;
|
1352 | var childRenderNodes = [];
|
1353 | var slotNodes = [];
|
1354 | var shadowRootNodes = shadowRoot ? [] : null;
|
1355 | var vnode = (hostRef.$vnode$ = newVNode(tagName, null));
|
1356 | if (!plt.$orgLocNodes$) {
|
1357 | initializeDocumentHydrate(doc.body, (plt.$orgLocNodes$ = new Map()));
|
1358 | }
|
1359 | hostElm[HYDRATE_ID] = hostId;
|
1360 | hostElm.removeAttribute(HYDRATE_ID);
|
1361 | clientHydrate(vnode, childRenderNodes, slotNodes, shadowRootNodes, hostElm, hostElm, hostId);
|
1362 | childRenderNodes.map(function (c) {
|
1363 | var orgLocationId = c.$hostId$ + '.' + c.$nodeId$;
|
1364 | var orgLocationNode = plt.$orgLocNodes$.get(orgLocationId);
|
1365 | var node = c.$elm$;
|
1366 | if (orgLocationNode && supportsShadow && orgLocationNode['s-en'] === '') {
|
1367 | orgLocationNode.parentNode.insertBefore(node, orgLocationNode.nextSibling);
|
1368 | }
|
1369 | if (!shadowRoot) {
|
1370 | node['s-hn'] = tagName;
|
1371 | if (orgLocationNode) {
|
1372 | node['s-ol'] = orgLocationNode;
|
1373 | node['s-ol']['s-nr'] = node;
|
1374 | }
|
1375 | }
|
1376 | plt.$orgLocNodes$.delete(orgLocationId);
|
1377 | });
|
1378 | if (shadowRoot) {
|
1379 | shadowRootNodes.map(function (shadowRootNode) {
|
1380 | if (shadowRootNode) {
|
1381 | shadowRoot.appendChild(shadowRootNode);
|
1382 | }
|
1383 | });
|
1384 | }
|
1385 | endHydrate();
|
1386 | };
|
1387 | var clientHydrate = function (parentVNode, childRenderNodes, slotNodes, shadowRootNodes, hostElm, node, hostId) {
|
1388 | var childNodeType;
|
1389 | var childIdSplt;
|
1390 | var childVNode;
|
1391 | var i;
|
1392 | if (node.nodeType === 1 ) {
|
1393 | childNodeType = node.getAttribute(HYDRATE_CHILD_ID);
|
1394 | if (childNodeType) {
|
1395 |
|
1396 |
|
1397 | childIdSplt = childNodeType.split('.');
|
1398 | if (childIdSplt[0] === hostId || childIdSplt[0] === '0') {
|
1399 | childVNode = {
|
1400 | $flags$: 0,
|
1401 | $hostId$: childIdSplt[0],
|
1402 | $nodeId$: childIdSplt[1],
|
1403 | $depth$: childIdSplt[2],
|
1404 | $index$: childIdSplt[3],
|
1405 | $tag$: node.tagName.toLowerCase(),
|
1406 | $elm$: node,
|
1407 | $attrs$: null,
|
1408 | $children$: null,
|
1409 | $key$: null,
|
1410 | $name$: null,
|
1411 | $text$: null,
|
1412 | };
|
1413 | childRenderNodes.push(childVNode);
|
1414 | node.removeAttribute(HYDRATE_CHILD_ID);
|
1415 |
|
1416 |
|
1417 | if (!parentVNode.$children$) {
|
1418 | parentVNode.$children$ = [];
|
1419 | }
|
1420 |
|
1421 | parentVNode.$children$[childVNode.$index$] = childVNode;
|
1422 |
|
1423 | parentVNode = childVNode;
|
1424 | if (shadowRootNodes && childVNode.$depth$ === '0') {
|
1425 | shadowRootNodes[childVNode.$index$] = childVNode.$elm$;
|
1426 | }
|
1427 | }
|
1428 | }
|
1429 |
|
1430 | for (i = node.childNodes.length - 1; i >= 0; i--) {
|
1431 | clientHydrate(parentVNode, childRenderNodes, slotNodes, shadowRootNodes, hostElm, node.childNodes[i], hostId);
|
1432 | }
|
1433 | if (node.shadowRoot) {
|
1434 |
|
1435 | for (i = node.shadowRoot.childNodes.length - 1; i >= 0; i--) {
|
1436 | clientHydrate(parentVNode, childRenderNodes, slotNodes, shadowRootNodes, hostElm, node.shadowRoot.childNodes[i], hostId);
|
1437 | }
|
1438 | }
|
1439 | }
|
1440 | else if (node.nodeType === 8 ) {
|
1441 |
|
1442 | childIdSplt = node.nodeValue.split('.');
|
1443 | if (childIdSplt[1] === hostId || childIdSplt[1] === '0') {
|
1444 |
|
1445 | childNodeType = childIdSplt[0];
|
1446 | childVNode = {
|
1447 | $flags$: 0,
|
1448 | $hostId$: childIdSplt[1],
|
1449 | $nodeId$: childIdSplt[2],
|
1450 | $depth$: childIdSplt[3],
|
1451 | $index$: childIdSplt[4],
|
1452 | $elm$: node,
|
1453 | $attrs$: null,
|
1454 | $children$: null,
|
1455 | $key$: null,
|
1456 | $name$: null,
|
1457 | $tag$: null,
|
1458 | $text$: null,
|
1459 | };
|
1460 | if (childNodeType === TEXT_NODE_ID) {
|
1461 | childVNode.$elm$ = node.nextSibling;
|
1462 | if (childVNode.$elm$ && childVNode.$elm$.nodeType === 3 ) {
|
1463 | childVNode.$text$ = childVNode.$elm$.textContent;
|
1464 | childRenderNodes.push(childVNode);
|
1465 |
|
1466 | node.remove();
|
1467 | if (!parentVNode.$children$) {
|
1468 | parentVNode.$children$ = [];
|
1469 | }
|
1470 | parentVNode.$children$[childVNode.$index$] = childVNode;
|
1471 | if (shadowRootNodes && childVNode.$depth$ === '0') {
|
1472 | shadowRootNodes[childVNode.$index$] = childVNode.$elm$;
|
1473 | }
|
1474 | }
|
1475 | }
|
1476 | else if (childVNode.$hostId$ === hostId) {
|
1477 |
|
1478 | if (childNodeType === SLOT_NODE_ID) {
|
1479 |
|
1480 | childVNode.$tag$ = 'slot';
|
1481 | if (childIdSplt[5]) {
|
1482 | node['s-sn'] = childVNode.$name$ = childIdSplt[5];
|
1483 | }
|
1484 | else {
|
1485 | node['s-sn'] = '';
|
1486 | }
|
1487 | node['s-sr'] = true;
|
1488 | if (shadowRootNodes) {
|
1489 |
|
1490 |
|
1491 | childVNode.$elm$ = doc.createElement(childVNode.$tag$);
|
1492 | if (childVNode.$name$) {
|
1493 |
|
1494 | childVNode.$elm$.setAttribute('name', childVNode.$name$);
|
1495 | }
|
1496 |
|
1497 | node.parentNode.insertBefore(childVNode.$elm$, node);
|
1498 |
|
1499 | node.remove();
|
1500 | if (childVNode.$depth$ === '0') {
|
1501 | shadowRootNodes[childVNode.$index$] = childVNode.$elm$;
|
1502 | }
|
1503 | }
|
1504 | slotNodes.push(childVNode);
|
1505 | if (!parentVNode.$children$) {
|
1506 | parentVNode.$children$ = [];
|
1507 | }
|
1508 | parentVNode.$children$[childVNode.$index$] = childVNode;
|
1509 | }
|
1510 | else if (childNodeType === CONTENT_REF_ID) {
|
1511 |
|
1512 | if (shadowRootNodes) {
|
1513 |
|
1514 | node.remove();
|
1515 | }
|
1516 | else {
|
1517 | hostElm['s-cr'] = node;
|
1518 | node['s-cn'] = true;
|
1519 | }
|
1520 | }
|
1521 | }
|
1522 | }
|
1523 | }
|
1524 | else if (parentVNode && parentVNode.$tag$ === 'style') {
|
1525 | var vnode = newVNode(null, node.textContent);
|
1526 | vnode.$elm$ = node;
|
1527 | vnode.$index$ = '0';
|
1528 | parentVNode.$children$ = [vnode];
|
1529 | }
|
1530 | };
|
1531 | var initializeDocumentHydrate = function (node, orgLocNodes) {
|
1532 | if (node.nodeType === 1 ) {
|
1533 | var i = 0;
|
1534 | for (; i < node.childNodes.length; i++) {
|
1535 | initializeDocumentHydrate(node.childNodes[i], orgLocNodes);
|
1536 | }
|
1537 | if (node.shadowRoot) {
|
1538 | for (i = 0; i < node.shadowRoot.childNodes.length; i++) {
|
1539 | initializeDocumentHydrate(node.shadowRoot.childNodes[i], orgLocNodes);
|
1540 | }
|
1541 | }
|
1542 | }
|
1543 | else if (node.nodeType === 8 ) {
|
1544 | var childIdSplt = node.nodeValue.split('.');
|
1545 | if (childIdSplt[0] === ORG_LOCATION_ID) {
|
1546 | orgLocNodes.set(childIdSplt[1] + '.' + childIdSplt[2], node);
|
1547 | node.nodeValue = '';
|
1548 |
|
1549 |
|
1550 | node['s-en'] = childIdSplt[3];
|
1551 | }
|
1552 | }
|
1553 | };
|
1554 | var parsePropertyValue = function (propValue, propType) {
|
1555 |
|
1556 | if (propValue != null && !isComplexType(propValue)) {
|
1557 | if (propType & 4 ) {
|
1558 |
|
1559 |
|
1560 | return propValue === 'false' ? false : propValue === '' || !!propValue;
|
1561 | }
|
1562 | if (propType & 2 ) {
|
1563 |
|
1564 | return parseFloat(propValue);
|
1565 | }
|
1566 | if (propType & 1 ) {
|
1567 |
|
1568 |
|
1569 | return String(propValue);
|
1570 | }
|
1571 |
|
1572 | return propValue;
|
1573 | }
|
1574 |
|
1575 |
|
1576 | return propValue;
|
1577 | };
|
1578 | var getValue = function (ref, propName) { return getHostRef(ref).$instanceValues$.get(propName); };
|
1579 | var setValue = function (ref, propName, newVal, cmpMeta) {
|
1580 |
|
1581 | var hostRef = getHostRef(ref);
|
1582 | var oldVal = hostRef.$instanceValues$.get(propName);
|
1583 | var flags = hostRef.$flags$;
|
1584 | var instance = hostRef.$lazyInstance$;
|
1585 | newVal = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]);
|
1586 | if ((!(flags & 8 /* isConstructingInstance */) || oldVal === undefined) && newVal !== oldVal) {
|
1587 |
|
1588 |
|
1589 | hostRef.$instanceValues$.set(propName, newVal);
|
1590 | if (instance) {
|
1591 |
|
1592 | if (cmpMeta.$watchers$ && flags & 128 ) {
|
1593 | var watchMethods = cmpMeta.$watchers$[propName];
|
1594 | if (watchMethods) {
|
1595 |
|
1596 | watchMethods.map(function (watchMethodName) {
|
1597 | try {
|
1598 |
|
1599 | instance[watchMethodName](newVal, oldVal, propName);
|
1600 | }
|
1601 | catch (e) {
|
1602 | consoleError(e);
|
1603 | }
|
1604 | });
|
1605 | }
|
1606 | }
|
1607 | if ((flags & (2 | 16 )) === 2 ) {
|
1608 |
|
1609 |
|
1610 |
|
1611 |
|
1612 | scheduleUpdate(hostRef, false);
|
1613 | }
|
1614 | }
|
1615 | }
|
1616 | };
|
1617 | var proxyComponent = function (Cstr, cmpMeta, flags) {
|
1618 | if (cmpMeta.$members$) {
|
1619 | if (Cstr.watchers) {
|
1620 | cmpMeta.$watchers$ = Cstr.watchers;
|
1621 | }
|
1622 |
|
1623 | var members = Object.entries(cmpMeta.$members$);
|
1624 | var prototype_1 = Cstr.prototype;
|
1625 | members.map(function (_a) {
|
1626 | var memberName = _a[0], memberFlags = _a[1][0];
|
1627 | if ((memberFlags & 31 || ((flags & 2 ) && memberFlags & 32 ))) {
|
1628 |
|
1629 | Object.defineProperty(prototype_1, memberName, {
|
1630 | get: function () {
|
1631 |
|
1632 | return getValue(this, memberName);
|
1633 | },
|
1634 | set: function (newValue) {
|
1635 |
|
1636 | setValue(this, memberName, newValue, cmpMeta);
|
1637 | },
|
1638 | configurable: true,
|
1639 | enumerable: true,
|
1640 | });
|
1641 | }
|
1642 | else if (flags & 1 && memberFlags & 64 ) {
|
1643 |
|
1644 | Object.defineProperty(prototype_1, memberName, {
|
1645 | value: function () {
|
1646 | var args = [];
|
1647 | for (var _i = 0; _i < arguments.length; _i++) {
|
1648 | args[_i] = arguments[_i];
|
1649 | }
|
1650 | var ref = getHostRef(this);
|
1651 | return ref.$onInstancePromise$.then(function () {
|
1652 | var _a;
|
1653 | return (_a = ref.$lazyInstance$)[memberName].apply(_a, args);
|
1654 | });
|
1655 | },
|
1656 | });
|
1657 | }
|
1658 | });
|
1659 | if ((flags & 1 )) {
|
1660 | var attrNameToPropName_1 = new Map();
|
1661 | prototype_1.attributeChangedCallback = function (attrName, _oldValue, newValue) {
|
1662 | var _this = this;
|
1663 | plt.jmp(function () {
|
1664 | var propName = attrNameToPropName_1.get(attrName);
|
1665 | _this[propName] = newValue === null && typeof _this[propName] === 'boolean' ? false : newValue;
|
1666 | });
|
1667 | };
|
1668 |
|
1669 |
|
1670 | Cstr.observedAttributes = members
|
1671 | .filter(function (_a) {
|
1672 | var _ = _a[0], m = _a[1];
|
1673 | return m[0] & 15;
|
1674 | } )
|
1675 | .map(function (_a) {
|
1676 | var propName = _a[0], m = _a[1];
|
1677 | var attrName = m[1] || propName;
|
1678 | attrNameToPropName_1.set(attrName, propName);
|
1679 | if (m[0] & 512 ) {
|
1680 | cmpMeta.$attrsToReflect$.push([propName, attrName]);
|
1681 | }
|
1682 | return attrName;
|
1683 | });
|
1684 | }
|
1685 | }
|
1686 | return Cstr;
|
1687 | };
|
1688 | var initializeComponent = function (elm, hostRef, cmpMeta, hmrVersionId, Cstr) { return __awaiter(void 0, void 0, void 0, function () {
|
1689 | var endLoad, endNewInstance, scopeId_1, endRegisterStyles, style_1, ancestorComponent, schedule;
|
1690 | return __generator(this, function (_a) {
|
1691 | switch (_a.label) {
|
1692 | case 0:
|
1693 | if (!((hostRef.$flags$ & 32 ) === 0)) return [3 , 5];
|
1694 |
|
1695 | hostRef.$flags$ |= 32 ;
|
1696 |
|
1697 |
|
1698 |
|
1699 | Cstr = loadModule(cmpMeta);
|
1700 | if (!Cstr.then) return [3 , 2];
|
1701 | endLoad = uniqueTime();
|
1702 | return [4 , Cstr];
|
1703 | case 1:
|
1704 | Cstr = _a.sent();
|
1705 | endLoad();
|
1706 | _a.label = 2;
|
1707 | case 2:
|
1708 | if (!Cstr.isProxied) {
|
1709 |
|
1710 |
|
1711 |
|
1712 | {
|
1713 | cmpMeta.$watchers$ = Cstr.watchers;
|
1714 | }
|
1715 | proxyComponent(Cstr, cmpMeta, 2 );
|
1716 | Cstr.isProxied = true;
|
1717 | }
|
1718 | endNewInstance = createTime('createInstance', cmpMeta.$tagName$);
|
1719 |
|
1720 |
|
1721 |
|
1722 | {
|
1723 | hostRef.$flags$ |= 8 ;
|
1724 | }
|
1725 |
|
1726 |
|
1727 |
|
1728 |
|
1729 | try {
|
1730 | new Cstr(hostRef);
|
1731 | }
|
1732 | catch (e) {
|
1733 | consoleError(e);
|
1734 | }
|
1735 | {
|
1736 | hostRef.$flags$ &= ~8 ;
|
1737 | }
|
1738 | {
|
1739 | hostRef.$flags$ |= 128 ;
|
1740 | }
|
1741 | endNewInstance();
|
1742 | fireConnectedCallback(hostRef.$lazyInstance$);
|
1743 | scopeId_1 = getScopeId(cmpMeta.$tagName$);
|
1744 | if (!(!styles.has(scopeId_1) && Cstr.style)) return [3 , 5];
|
1745 | endRegisterStyles = createTime('registerStyles', cmpMeta.$tagName$);
|
1746 | style_1 = Cstr.style;
|
1747 | if (!(cmpMeta.$flags$ & 8) ) return [3 , 4];
|
1748 | return [4 , import('./shadow-css-76400429.js').then(function (m) { return m.scopeCss(style_1, scopeId_1, false); })];
|
1749 | case 3:
|
1750 | style_1 = _a.sent();
|
1751 | _a.label = 4;
|
1752 | case 4:
|
1753 | registerStyle(scopeId_1, style_1, !!(cmpMeta.$flags$ & 1 ));
|
1754 | endRegisterStyles();
|
1755 | _a.label = 5;
|
1756 | case 5:
|
1757 | ancestorComponent = hostRef.$ancestorComponent$;
|
1758 | schedule = function () { return scheduleUpdate(hostRef, true); };
|
1759 | if (ancestorComponent && ancestorComponent['s-rc']) {
|
1760 |
|
1761 |
|
1762 |
|
1763 |
|
1764 |
|
1765 |
|
1766 | ancestorComponent['s-rc'].push(schedule);
|
1767 | }
|
1768 | else {
|
1769 | schedule();
|
1770 | }
|
1771 | return [2 ];
|
1772 | }
|
1773 | });
|
1774 | }); };
|
1775 | var fireConnectedCallback = function (instance) {
|
1776 | {
|
1777 | safeCall(instance, 'connectedCallback');
|
1778 | }
|
1779 | };
|
1780 | var connectedCallback = function (elm) {
|
1781 | if ((plt.$flags$ & 1 ) === 0) {
|
1782 | var hostRef = getHostRef(elm);
|
1783 | var cmpMeta = hostRef.$cmpMeta$;
|
1784 | var endConnected = createTime('connectedCallback', cmpMeta.$tagName$);
|
1785 | {
|
1786 |
|
1787 | addHostEventListeners(elm, hostRef, cmpMeta.$listeners$, true);
|
1788 | }
|
1789 | if (!(hostRef.$flags$ & 1 )) {
|
1790 |
|
1791 | hostRef.$flags$ |= 1 ;
|
1792 | var hostId = void 0;
|
1793 | {
|
1794 | hostId = elm.getAttribute(HYDRATE_ID);
|
1795 | if (hostId) {
|
1796 | if (supportsShadow && cmpMeta.$flags$ & 1 ) {
|
1797 | var scopeId_2 = addStyle(elm.shadowRoot, cmpMeta);
|
1798 | elm.classList.remove(scopeId_2 + '-h', scopeId_2 + '-s');
|
1799 | }
|
1800 | initializeClientHydrate(elm, cmpMeta.$tagName$, hostId, hostRef);
|
1801 | }
|
1802 | }
|
1803 | if (!hostId) {
|
1804 |
|
1805 |
|
1806 |
|
1807 |
|
1808 | if ((cmpMeta.$flags$ & (4 | 8 ))) {
|
1809 | setContentReference(elm);
|
1810 | }
|
1811 | }
|
1812 | {
|
1813 |
|
1814 |
|
1815 | var ancestorComponent = elm;
|
1816 | while ((ancestorComponent = ancestorComponent.parentNode || ancestorComponent.host)) {
|
1817 |
|
1818 |
|
1819 | if ((ancestorComponent.nodeType === 1 && ancestorComponent.hasAttribute('s-id')) || ancestorComponent['s-p']) {
|
1820 |
|
1821 |
|
1822 | attachToAncestor(hostRef, (hostRef.$ancestorComponent$ = ancestorComponent));
|
1823 | break;
|
1824 | }
|
1825 | }
|
1826 | }
|
1827 |
|
1828 |
|
1829 | if (cmpMeta.$members$) {
|
1830 | Object.entries(cmpMeta.$members$).map(function (_a) {
|
1831 | var memberName = _a[0], memberFlags = _a[1][0];
|
1832 | if (memberFlags & 31 && elm.hasOwnProperty(memberName)) {
|
1833 | var value = elm[memberName];
|
1834 | delete elm[memberName];
|
1835 | elm[memberName] = value;
|
1836 | }
|
1837 | });
|
1838 | }
|
1839 | {
|
1840 | initializeComponent(elm, hostRef, cmpMeta);
|
1841 | }
|
1842 | }
|
1843 | else {
|
1844 |
|
1845 |
|
1846 |
|
1847 | addHostEventListeners(elm, hostRef, cmpMeta.$listeners$, false);
|
1848 |
|
1849 | fireConnectedCallback(hostRef.$lazyInstance$);
|
1850 | }
|
1851 | endConnected();
|
1852 | }
|
1853 | };
|
1854 | var setContentReference = function (elm) {
|
1855 |
|
1856 |
|
1857 |
|
1858 |
|
1859 |
|
1860 |
|
1861 | var contentRefElm = (elm['s-cr'] = doc.createComment(''));
|
1862 | contentRefElm['s-cn'] = true;
|
1863 | elm.insertBefore(contentRefElm, elm.firstChild);
|
1864 | };
|
1865 | var disconnectedCallback = function (elm) {
|
1866 | if ((plt.$flags$ & 1 ) === 0) {
|
1867 | var hostRef = getHostRef(elm);
|
1868 | var instance = hostRef.$lazyInstance$;
|
1869 | {
|
1870 | if (hostRef.$rmListeners$) {
|
1871 | hostRef.$rmListeners$.map(function (rmListener) { return rmListener(); });
|
1872 | hostRef.$rmListeners$ = undefined;
|
1873 | }
|
1874 | }
|
1875 |
|
1876 | if (plt.$cssShim$) {
|
1877 | plt.$cssShim$.removeHost(elm);
|
1878 | }
|
1879 | {
|
1880 | safeCall(instance, 'disconnectedCallback');
|
1881 | }
|
1882 | {
|
1883 | safeCall(instance, 'componentDidUnload');
|
1884 | }
|
1885 | }
|
1886 | };
|
1887 | var patchSlotAppendChild = function (HostElementPrototype) {
|
1888 | HostElementPrototype.__appendChild = HostElementPrototype.appendChild;
|
1889 | HostElementPrototype.appendChild = function (newChild) {
|
1890 | var slotName = (newChild['s-sn'] = getSlotName(newChild));
|
1891 | var slotNode = getHostSlotNode(this.childNodes, slotName);
|
1892 | if (slotNode) {
|
1893 | var slotChildNodes = getHostSlotChildNodes(slotNode, slotName);
|
1894 | var appendAfter = slotChildNodes[slotChildNodes.length - 1];
|
1895 | return appendAfter.parentNode.insertBefore(newChild, appendAfter.nextSibling);
|
1896 | }
|
1897 | return this.__appendChild(newChild);
|
1898 | };
|
1899 | };
|
1900 | var patchChildSlotNodes = function (elm, cmpMeta) {
|
1901 | if (cmpMeta.$flags$ & 8 ) {
|
1902 | var childrenFn_1 = elm.__lookupGetter__('children');
|
1903 | var childNodesFn_1 = elm.__lookupGetter__('childNodes');
|
1904 | Object.defineProperty(elm, 'children', {
|
1905 | get: function () {
|
1906 | var children = childrenFn_1.call(this);
|
1907 | if ((plt.$flags$ & 1 ) === 0) {
|
1908 | var slotNode = getHostSlotNode(children, '');
|
1909 | if (slotNode && slotNode.parentNode) {
|
1910 | return slotNode.parentNode.children;
|
1911 | }
|
1912 | }
|
1913 | return children;
|
1914 | },
|
1915 | });
|
1916 | Object.defineProperty(elm, 'childElementCount', {
|
1917 | get: function () {
|
1918 | return elm.children.length;
|
1919 | },
|
1920 | });
|
1921 | Object.defineProperty(elm, 'childNodes', {
|
1922 | get: function () {
|
1923 | var childNodes = childNodesFn_1.call(this);
|
1924 | if ((plt.$flags$ & 1 ) === 0) {
|
1925 | var slotNode = getHostSlotNode(childNodes, '');
|
1926 | if (slotNode && slotNode.parentNode) {
|
1927 | return slotNode.parentNode.childNodes;
|
1928 | }
|
1929 | }
|
1930 | return childNodes;
|
1931 | },
|
1932 | });
|
1933 | }
|
1934 | };
|
1935 | var getSlotName = function (node) { return node['s-sn'] || (node.nodeType === 1 && node.getAttribute('slot')) || ''; };
|
1936 | var getHostSlotNode = function (childNodes, slotName) {
|
1937 | var i = 0;
|
1938 | var childNode;
|
1939 | for (; i < childNodes.length; i++) {
|
1940 | childNode = childNodes[i];
|
1941 | if (childNode['s-sr'] && childNode['s-sn'] === slotName) {
|
1942 | return childNode;
|
1943 | }
|
1944 | childNode = getHostSlotNode(childNode.childNodes, slotName);
|
1945 | if (childNode) {
|
1946 | return childNode;
|
1947 | }
|
1948 | }
|
1949 | return null;
|
1950 | };
|
1951 | var getHostSlotChildNodes = function (n, slotName) {
|
1952 | var childNodes = [n];
|
1953 | while ((n = n.nextSibling) && n['s-sn'] === slotName) {
|
1954 | childNodes.push(n);
|
1955 | }
|
1956 | return childNodes;
|
1957 | };
|
1958 | var bootstrapLazy = function (lazyBundles, options) {
|
1959 | if (options === void 0) { options = {}; }
|
1960 | var endBootstrap = createTime();
|
1961 | var cmpTags = [];
|
1962 | var exclude = options.exclude || [];
|
1963 | var customElements = win.customElements;
|
1964 | var head = doc.head;
|
1965 | var metaCharset = head.querySelector('meta[charset]');
|
1966 | var visibilityStyle = doc.createElement('style');
|
1967 | var deferredConnectedCallbacks = [];
|
1968 | var styles = doc.querySelectorAll("[" + HYDRATED_STYLE_ID + "]");
|
1969 | var appLoadFallback;
|
1970 | var isBootstrapping = true;
|
1971 | var i = 0;
|
1972 | Object.assign(plt, options);
|
1973 | plt.$resourcesUrl$ = new URL(options.resourcesUrl || './', doc.baseURI).href;
|
1974 | if (options.syncQueue) {
|
1975 | plt.$flags$ |= 4 ;
|
1976 | }
|
1977 | {
|
1978 |
|
1979 |
|
1980 | plt.$flags$ |= 2 ;
|
1981 | }
|
1982 | {
|
1983 | for (; i < styles.length; i++) {
|
1984 | registerStyle(styles[i].getAttribute(HYDRATED_STYLE_ID), convertScopedToShadow(styles[i].innerHTML), true);
|
1985 | }
|
1986 | }
|
1987 | lazyBundles.map(function (lazyBundle) { return lazyBundle[1].map(function (compactMeta) {
|
1988 | var cmpMeta = {
|
1989 | $flags$: compactMeta[0],
|
1990 | $tagName$: compactMeta[1],
|
1991 | $members$: compactMeta[2],
|
1992 | $listeners$: compactMeta[3],
|
1993 | };
|
1994 | {
|
1995 | cmpMeta.$members$ = compactMeta[2];
|
1996 | }
|
1997 | {
|
1998 | cmpMeta.$listeners$ = compactMeta[3];
|
1999 | }
|
2000 | {
|
2001 | cmpMeta.$attrsToReflect$ = [];
|
2002 | }
|
2003 | {
|
2004 | cmpMeta.$watchers$ = {};
|
2005 | }
|
2006 | if (!supportsShadow && cmpMeta.$flags$ & 1 ) {
|
2007 | cmpMeta.$flags$ |= 8 ;
|
2008 | }
|
2009 | var tagName = cmpMeta.$tagName$;
|
2010 | var HostElement = (function (_super) {
|
2011 | __extends(HostElement, _super);
|
2012 |
|
2013 | function HostElement(self) {
|
2014 | var _this =
|
2015 |
|
2016 | _super.call(this, self) || this;
|
2017 | self = _this;
|
2018 | registerHost(self, cmpMeta);
|
2019 | if (cmpMeta.$flags$ & 1 ) {
|
2020 |
|
2021 |
|
2022 |
|
2023 |
|
2024 | if (supportsShadow) {
|
2025 | {
|
2026 | self.attachShadow({ mode: 'open' });
|
2027 | }
|
2028 | }
|
2029 | else if (!('shadowRoot' in self)) {
|
2030 | self.shadowRoot = self;
|
2031 | }
|
2032 | }
|
2033 | {
|
2034 | patchChildSlotNodes(self, cmpMeta);
|
2035 | }
|
2036 | return _this;
|
2037 | }
|
2038 | HostElement.prototype.connectedCallback = function () {
|
2039 | var _this = this;
|
2040 | if (appLoadFallback) {
|
2041 | clearTimeout(appLoadFallback);
|
2042 | appLoadFallback = null;
|
2043 | }
|
2044 | if (isBootstrapping) {
|
2045 |
|
2046 | deferredConnectedCallbacks.push(this);
|
2047 | }
|
2048 | else {
|
2049 | plt.jmp(function () { return connectedCallback(_this); });
|
2050 | }
|
2051 | };
|
2052 | HostElement.prototype.disconnectedCallback = function () {
|
2053 | var _this = this;
|
2054 | plt.jmp(function () { return disconnectedCallback(_this); });
|
2055 | };
|
2056 | HostElement.prototype.forceUpdate = function () {
|
2057 | forceUpdate(this);
|
2058 | };
|
2059 | HostElement.prototype.componentOnReady = function () {
|
2060 | return getHostRef(this).$onReadyPromise$;
|
2061 | };
|
2062 | return HostElement;
|
2063 | }(HTMLElement));
|
2064 | {
|
2065 | patchSlotAppendChild(HostElement.prototype);
|
2066 | }
|
2067 | cmpMeta.$lazyBundleIds$ = lazyBundle[0];
|
2068 | if (!exclude.includes(tagName) && !customElements.get(tagName)) {
|
2069 | cmpTags.push(tagName);
|
2070 | customElements.define(tagName, proxyComponent(HostElement, cmpMeta, 1 ));
|
2071 | }
|
2072 | }); });
|
2073 | {
|
2074 | visibilityStyle.innerHTML = cmpTags + HYDRATED_CSS;
|
2075 | visibilityStyle.setAttribute('data-styles', '');
|
2076 | head.insertBefore(visibilityStyle, metaCharset ? metaCharset.nextSibling : head.firstChild);
|
2077 | }
|
2078 |
|
2079 | isBootstrapping = false;
|
2080 | if (deferredConnectedCallbacks.length) {
|
2081 | deferredConnectedCallbacks.map(function (host) { return host.connectedCallback(); });
|
2082 | }
|
2083 | else {
|
2084 | {
|
2085 | plt.jmp(function () { return (appLoadFallback = setTimeout(appDidLoad, 30)); });
|
2086 | }
|
2087 | }
|
2088 |
|
2089 | endBootstrap();
|
2090 | };
|
2091 | var getAssetPath = function (path) {
|
2092 | var assetUrl = new URL(path, plt.$resourcesUrl$);
|
2093 | return assetUrl.origin !== win.location.origin ? assetUrl.href : assetUrl.pathname;
|
2094 | };
|
2095 | var hostRefs = new WeakMap();
|
2096 | var getHostRef = function (ref) { return hostRefs.get(ref); };
|
2097 | var registerInstance = function (lazyInstance, hostRef) { return hostRefs.set((hostRef.$lazyInstance$ = lazyInstance), hostRef); };
|
2098 | var registerHost = function (elm, cmpMeta) {
|
2099 | var hostRef = {
|
2100 | $flags$: 0,
|
2101 | $hostElement$: elm,
|
2102 | $cmpMeta$: cmpMeta,
|
2103 | $instanceValues$: new Map(),
|
2104 | };
|
2105 | {
|
2106 | hostRef.$onInstancePromise$ = new Promise(function (r) { return (hostRef.$onInstanceResolve$ = r); });
|
2107 | }
|
2108 | {
|
2109 | hostRef.$onReadyPromise$ = new Promise(function (r) { return (hostRef.$onReadyResolve$ = r); });
|
2110 | elm['s-p'] = [];
|
2111 | elm['s-rc'] = [];
|
2112 | }
|
2113 | addHostEventListeners(elm, hostRef, cmpMeta.$listeners$, false);
|
2114 | return hostRefs.set(elm, hostRef);
|
2115 | };
|
2116 | var isMemberInElement = function (elm, memberName) { return memberName in elm; };
|
2117 | var consoleError = function (e) { return console.error(e); };
|
2118 | var cmpModules = new Map();
|
2119 | var loadModule = function (cmpMeta, hostRef, hmrVersionId) {
|
2120 |
|
2121 | var exportName = cmpMeta.$tagName$.replace(/-/g, '_');
|
2122 | var bundleId = (cmpMeta.$lazyBundleIds$);
|
2123 | var module = cmpModules.get(bundleId);
|
2124 | if (module) {
|
2125 | return module[exportName];
|
2126 | }
|
2127 | return import(
|
2128 |
|
2129 |
|
2130 |
|
2131 |
|
2132 | "./" + bundleId + ".entry.js" + '').then(function (importedModule) {
|
2133 | {
|
2134 | cmpModules.set(bundleId, importedModule);
|
2135 | }
|
2136 | return importedModule[exportName];
|
2137 | }, consoleError);
|
2138 | };
|
2139 | var styles = new Map();
|
2140 | var queueDomReads = [];
|
2141 | var queueDomWrites = [];
|
2142 | var queueDomWritesLow = [];
|
2143 | var queueTask = function (queue, write) { return function (cb) {
|
2144 | queue.push(cb);
|
2145 | if (!queuePending) {
|
2146 | queuePending = true;
|
2147 | if (write && plt.$flags$ & 4 ) {
|
2148 | nextTick(flush);
|
2149 | }
|
2150 | else {
|
2151 | plt.raf(flush);
|
2152 | }
|
2153 | }
|
2154 | }; };
|
2155 | var consume = function (queue) {
|
2156 | for (var i = 0; i < queue.length; i++) {
|
2157 | try {
|
2158 | queue[i](performance.now());
|
2159 | }
|
2160 | catch (e) {
|
2161 | consoleError(e);
|
2162 | }
|
2163 | }
|
2164 | queue.length = 0;
|
2165 | };
|
2166 | var consumeTimeout = function (queue, timeout) {
|
2167 | var i = 0;
|
2168 | var ts = 0;
|
2169 | while (i < queue.length && (ts = performance.now()) < timeout) {
|
2170 | try {
|
2171 | queue[i++](ts);
|
2172 | }
|
2173 | catch (e) {
|
2174 | consoleError(e);
|
2175 | }
|
2176 | }
|
2177 | if (i === queue.length) {
|
2178 | queue.length = 0;
|
2179 | }
|
2180 | else if (i !== 0) {
|
2181 | queue.splice(0, i);
|
2182 | }
|
2183 | };
|
2184 | var flush = function () {
|
2185 | queueCongestion++;
|
2186 |
|
2187 |
|
2188 |
|
2189 | consume(queueDomReads);
|
2190 | var timeout = (plt.$flags$ & 6 ) === 2 ? performance.now() + 10 * Math.ceil(queueCongestion * (1.0 / 22.0)) : Infinity;
|
2191 |
|
2192 | consumeTimeout(queueDomWrites, timeout);
|
2193 | consumeTimeout(queueDomWritesLow, timeout);
|
2194 | if (queueDomWrites.length > 0) {
|
2195 | queueDomWritesLow.push.apply(queueDomWritesLow, queueDomWrites);
|
2196 | queueDomWrites.length = 0;
|
2197 | }
|
2198 | if ((queuePending = queueDomReads.length + queueDomWrites.length + queueDomWritesLow.length > 0)) {
|
2199 |
|
2200 |
|
2201 | plt.raf(flush);
|
2202 | }
|
2203 | else {
|
2204 | queueCongestion = 0;
|
2205 | }
|
2206 | };
|
2207 | var nextTick = function (cb) { return promiseResolve().then(cb); };
|
2208 | var writeTask = queueTask(queueDomWrites, true);
|
2209 | var patchEsm = function () {
|
2210 |
|
2211 | if (!(CSS && CSS.supports && CSS.supports('color', 'var(--c)'))) {
|
2212 |
|
2213 | return import( './css-shim-f8adc4ba.js').then(function () {
|
2214 | if ((plt.$cssShim$ = win.__cssshim)) {
|
2215 | return plt.$cssShim$.i();
|
2216 | }
|
2217 | else {
|
2218 |
|
2219 | return 0;
|
2220 | }
|
2221 | });
|
2222 | }
|
2223 | return promiseResolve();
|
2224 | };
|
2225 | var patchBrowser = function () {
|
2226 | {
|
2227 |
|
2228 | plt.$cssShim$ = win.__cssshim;
|
2229 | }
|
2230 |
|
2231 | var scriptElm = Array.from(doc.querySelectorAll('script')).find(function (s) { return new RegExp("/" + NAMESPACE + "(\\.esm)?\\.js($|\\?|#)").test(s.src) || s.getAttribute('data-stencil-namespace') === NAMESPACE; });
|
2232 | var opts = scriptElm['data-opts'] || {};
|
2233 | if ('onbeforeload' in scriptElm && !history.scrollRestoration ) {
|
2234 |
|
2235 |
|
2236 |
|
2237 |
|
2238 |
|
2239 |
|
2240 |
|
2241 | return {
|
2242 | then: function () {
|
2243 |
|
2244 | },
|
2245 | };
|
2246 | }
|
2247 | {
|
2248 | opts.resourcesUrl = new URL('.', new URL(scriptElm.getAttribute('data-resources-url') || scriptElm.src, win.location.href)).href;
|
2249 | {
|
2250 | patchDynamicImport(opts.resourcesUrl, scriptElm);
|
2251 | }
|
2252 | if (!win.customElements) {
|
2253 |
|
2254 |
|
2255 | return import( './dom-4001f04a.js').then(function () { return opts; });
|
2256 | }
|
2257 | }
|
2258 | return promiseResolve(opts);
|
2259 | };
|
2260 | var patchDynamicImport = function (base, orgScriptElm) {
|
2261 | var importFunctionName = getDynamicImportFunction(NAMESPACE);
|
2262 | try {
|
2263 |
|
2264 |
|
2265 |
|
2266 |
|
2267 | win[importFunctionName] = new Function('w', "return import(w);//" + Math.random());
|
2268 | }
|
2269 | catch (e) {
|
2270 |
|
2271 |
|
2272 |
|
2273 | var moduleMap_1 = new Map();
|
2274 | win[importFunctionName] = function (src) {
|
2275 | var url = new URL(src, base).href;
|
2276 | var mod = moduleMap_1.get(url);
|
2277 | if (!mod) {
|
2278 | var script_1 = doc.createElement('script');
|
2279 | script_1.type = 'module';
|
2280 | script_1.crossOrigin = orgScriptElm.crossOrigin;
|
2281 | script_1.src = URL.createObjectURL(new Blob(["import * as m from '" + url + "'; window." + importFunctionName + ".m = m;"], { type: 'application/javascript' }));
|
2282 | mod = new Promise(function (resolve) {
|
2283 | script_1.onload = function () {
|
2284 | resolve(win[importFunctionName].m);
|
2285 | script_1.remove();
|
2286 | };
|
2287 | });
|
2288 | moduleMap_1.set(url, mod);
|
2289 | doc.head.appendChild(script_1);
|
2290 | }
|
2291 | return mod;
|
2292 | };
|
2293 | }
|
2294 | };
|
2295 | export { Host as H, patchEsm as a, bootstrapLazy as b, createEvent as c, getAssetPath as d, getElement as g, h, patchBrowser as p, registerInstance as r };
|