@stencil/core 4.23.2 → 4.24.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  /*
2
- Stencil Hydrate Platform v4.23.2 | MIT Licensed | https://stenciljs.com
2
+ Stencil Hydrate Platform v4.24.0 | MIT Licensed | https://stenciljs.com
3
3
  */
4
4
  var __defProp = Object.defineProperty;
5
5
  var __export = (target, all) => {
@@ -90,10 +90,13 @@ var unwrapErr = (result) => {
90
90
  import { BUILD as BUILD17 } from "@stencil/core/internal/app-data";
91
91
 
92
92
  // src/runtime/client-hydrate.ts
93
- import { BUILD as BUILD8 } from "@stencil/core/internal/app-data";
93
+ import { BUILD as BUILD5 } from "@stencil/core/internal/app-data";
94
94
 
95
95
  // src/runtime/dom-extras.ts
96
- import { BUILD as BUILD6 } from "@stencil/core/internal/app-data";
96
+ import { BUILD as BUILD2 } from "@stencil/core/internal/app-data";
97
+
98
+ // src/runtime/slot-polyfill-utils.ts
99
+ import { BUILD } from "@stencil/core/internal/app-data";
97
100
 
98
101
  // src/runtime/runtime-constants.ts
99
102
  var CONTENT_REF_ID = "r";
@@ -121,7 +124,6 @@ var FORM_ASSOCIATED_CUSTOM_ELEMENT_CALLBACKS = [
121
124
  ];
122
125
 
123
126
  // src/runtime/slot-polyfill-utils.ts
124
- import { BUILD } from "@stencil/core/internal/app-data";
125
127
  var updateFallbackSlotVisibility = (elm) => {
126
128
  const childNodes = elm.__childNodes || elm.childNodes;
127
129
  if (elm.tagName && elm.tagName.includes("-") && elm["s-cr"] && elm.tagName !== "SLOT-FB") {
@@ -145,27 +147,27 @@ var updateFallbackSlotVisibility = (elm) => {
145
147
  var getSlottedChildNodes = (childNodes) => {
146
148
  const result = [];
147
149
  for (let i2 = 0; i2 < childNodes.length; i2++) {
148
- const slottedNode = childNodes[i2]["s-nr"];
150
+ const slottedNode = childNodes[i2]["s-nr"] || void 0;
149
151
  if (slottedNode && slottedNode.isConnected) {
150
152
  result.push(slottedNode);
151
153
  }
152
154
  }
153
155
  return result;
154
156
  };
155
- var getHostSlotNodes = (childNodes, hostName, slotName) => {
157
+ function getHostSlotNodes(childNodes, hostName, slotName) {
156
158
  let i2 = 0;
157
159
  let slottedNodes = [];
158
160
  let childNode;
159
161
  for (; i2 < childNodes.length; i2++) {
160
162
  childNode = childNodes[i2];
161
- if (childNode["s-sr"] && childNode["s-hn"] === hostName && (!slotName || childNode["s-sn"] === slotName)) {
163
+ if (childNode["s-sr"] && childNode["s-hn"] === hostName && (slotName === void 0 || childNode["s-sn"] === slotName)) {
162
164
  slottedNodes.push(childNode);
163
165
  if (typeof slotName !== "undefined") return slottedNodes;
164
166
  }
165
167
  slottedNodes = [...slottedNodes, ...getHostSlotNodes(childNode.childNodes, hostName, slotName)];
166
168
  }
167
169
  return slottedNodes;
168
- };
170
+ }
169
171
  var getHostSlotChildNodes = (node, slotName, includeSlot = true) => {
170
172
  const childNodes = [];
171
173
  if (includeSlot && node["s-sr"] || !node["s-sr"]) childNodes.push(node);
@@ -223,1801 +225,1881 @@ var addSlotRelocateNode = (newChild, slotNode, prepend, position) => {
223
225
  };
224
226
  var getSlotName = (node) => node["s-sn"] || node.nodeType === 1 && node.getAttribute("slot") || "";
225
227
 
226
- // src/runtime/vdom/vdom-render.ts
227
- import { BUILD as BUILD5 } from "@stencil/core/internal/app-data";
228
-
229
- // src/runtime/vdom/h.ts
230
- import { BUILD as BUILD2 } from "@stencil/core/internal/app-data";
231
- var h = (nodeName, vnodeData, ...children) => {
232
- let child = null;
233
- let key = null;
234
- let slotName = null;
235
- let simple = false;
236
- let lastSimple = false;
237
- const vNodeChildren = [];
238
- const walk = (c) => {
239
- for (let i2 = 0; i2 < c.length; i2++) {
240
- child = c[i2];
241
- if (Array.isArray(child)) {
242
- walk(child);
243
- } else if (child != null && typeof child !== "boolean") {
244
- if (simple = typeof nodeName !== "function" && !isComplexType(child)) {
245
- child = String(child);
246
- } else if (BUILD2.isDev && typeof nodeName !== "function" && child.$flags$ === void 0) {
247
- consoleDevError(`vNode passed as children has unexpected type.
248
- Make sure it's using the correct h() function.
249
- Empty objects can also be the cause, look for JSX comments that became objects.`);
228
+ // src/runtime/dom-extras.ts
229
+ var patchPseudoShadowDom = (hostElementPrototype) => {
230
+ patchCloneNode(hostElementPrototype);
231
+ patchSlotAppendChild(hostElementPrototype);
232
+ patchSlotAppend(hostElementPrototype);
233
+ patchSlotPrepend(hostElementPrototype);
234
+ patchSlotInsertAdjacentElement(hostElementPrototype);
235
+ patchSlotInsertAdjacentHTML(hostElementPrototype);
236
+ patchSlotInsertAdjacentText(hostElementPrototype);
237
+ patchInsertBefore(hostElementPrototype);
238
+ patchTextContent(hostElementPrototype);
239
+ patchChildSlotNodes(hostElementPrototype);
240
+ patchSlotRemoveChild(hostElementPrototype);
241
+ };
242
+ var patchCloneNode = (HostElementPrototype) => {
243
+ const orgCloneNode = HostElementPrototype.cloneNode;
244
+ HostElementPrototype.cloneNode = function(deep) {
245
+ const srcNode = this;
246
+ const isShadowDom = BUILD2.shadowDom ? srcNode.shadowRoot && supportsShadow : false;
247
+ const clonedNode = orgCloneNode.call(srcNode, isShadowDom ? deep : false);
248
+ if (BUILD2.slot && !isShadowDom && deep) {
249
+ let i2 = 0;
250
+ let slotted, nonStencilNode;
251
+ const stencilPrivates = [
252
+ "s-id",
253
+ "s-cr",
254
+ "s-lr",
255
+ "s-rc",
256
+ "s-sc",
257
+ "s-p",
258
+ "s-cn",
259
+ "s-sr",
260
+ "s-sn",
261
+ "s-hn",
262
+ "s-ol",
263
+ "s-nr",
264
+ "s-si",
265
+ "s-rf",
266
+ "s-scs"
267
+ ];
268
+ const childNodes = this.__childNodes || this.childNodes;
269
+ for (; i2 < childNodes.length; i2++) {
270
+ slotted = childNodes[i2]["s-nr"];
271
+ nonStencilNode = stencilPrivates.every((privateField) => !childNodes[i2][privateField]);
272
+ if (slotted) {
273
+ if (BUILD2.appendChildSlotFix && clonedNode.__appendChild) {
274
+ clonedNode.__appendChild(slotted.cloneNode(true));
275
+ } else {
276
+ clonedNode.appendChild(slotted.cloneNode(true));
277
+ }
250
278
  }
251
- if (simple && lastSimple) {
252
- vNodeChildren[vNodeChildren.length - 1].$text$ += child;
253
- } else {
254
- vNodeChildren.push(simple ? newVNode(null, child) : child);
279
+ if (nonStencilNode) {
280
+ clonedNode.appendChild(childNodes[i2].cloneNode(true));
255
281
  }
256
- lastSimple = simple;
257
282
  }
258
283
  }
284
+ return clonedNode;
259
285
  };
260
- walk(children);
261
- if (vnodeData) {
262
- if (BUILD2.isDev && nodeName === "input") {
263
- validateInputProperties(vnodeData);
264
- }
265
- if (BUILD2.vdomKey && vnodeData.key) {
266
- key = vnodeData.key;
267
- }
268
- if (BUILD2.slotRelocation && vnodeData.name) {
269
- slotName = vnodeData.name;
286
+ };
287
+ var patchSlotAppendChild = (HostElementPrototype) => {
288
+ HostElementPrototype.__appendChild = HostElementPrototype.appendChild;
289
+ HostElementPrototype.appendChild = function(newChild) {
290
+ const slotName = newChild["s-sn"] = getSlotName(newChild);
291
+ const slotNode = getHostSlotNodes(this.__childNodes || this.childNodes, this.tagName, slotName)[0];
292
+ if (slotNode) {
293
+ addSlotRelocateNode(newChild, slotNode);
294
+ const slotChildNodes = getHostSlotChildNodes(slotNode, slotName);
295
+ const appendAfter = slotChildNodes[slotChildNodes.length - 1];
296
+ const parent = intrnlCall(appendAfter, "parentNode");
297
+ let insertedNode;
298
+ if (parent.__insertBefore) {
299
+ insertedNode = parent.__insertBefore(newChild, appendAfter.nextSibling);
300
+ } else {
301
+ insertedNode = parent.insertBefore(newChild, appendAfter.nextSibling);
302
+ }
303
+ updateFallbackSlotVisibility(this);
304
+ return insertedNode;
270
305
  }
271
- if (BUILD2.vdomClass) {
272
- const classData = vnodeData.className || vnodeData.class;
273
- if (classData) {
274
- vnodeData.class = typeof classData !== "object" ? classData : Object.keys(classData).filter((k) => classData[k]).join(" ");
306
+ return this.__appendChild(newChild);
307
+ };
308
+ };
309
+ var patchSlotRemoveChild = (ElementPrototype) => {
310
+ ElementPrototype.__removeChild = ElementPrototype.removeChild;
311
+ ElementPrototype.removeChild = function(toRemove) {
312
+ if (toRemove && typeof toRemove["s-sn"] !== "undefined") {
313
+ const childNodes = this.__childNodes || this.childNodes;
314
+ const slotNode = getHostSlotNodes(childNodes, this.tagName, toRemove["s-sn"]);
315
+ if (slotNode && toRemove.isConnected) {
316
+ toRemove.remove();
317
+ updateFallbackSlotVisibility(this);
318
+ return;
275
319
  }
276
320
  }
277
- }
278
- if (BUILD2.isDev && vNodeChildren.some(isHost)) {
279
- consoleDevError(`The <Host> must be the single root component. Make sure:
280
- - You are NOT using hostData() and <Host> in the same component.
281
- - <Host> is used once, and it's the single root component of the render() function.`);
282
- }
283
- if (BUILD2.vdomFunctional && typeof nodeName === "function") {
284
- return nodeName(
285
- vnodeData === null ? {} : vnodeData,
286
- vNodeChildren,
287
- vdomFnUtils
288
- );
289
- }
290
- const vnode = newVNode(nodeName, null);
291
- vnode.$attrs$ = vnodeData;
292
- if (vNodeChildren.length > 0) {
293
- vnode.$children$ = vNodeChildren;
294
- }
295
- if (BUILD2.vdomKey) {
296
- vnode.$key$ = key;
297
- }
298
- if (BUILD2.slotRelocation) {
299
- vnode.$name$ = slotName;
300
- }
301
- return vnode;
321
+ return this.__removeChild(toRemove);
322
+ };
302
323
  };
303
- var newVNode = (tag, text) => {
304
- const vnode = {
305
- $flags$: 0,
306
- $tag$: tag,
307
- $text$: text,
308
- $elm$: null,
309
- $children$: null
324
+ var patchSlotPrepend = (HostElementPrototype) => {
325
+ HostElementPrototype.__prepend = HostElementPrototype.prepend;
326
+ HostElementPrototype.prepend = function(...newChildren) {
327
+ newChildren.forEach((newChild) => {
328
+ if (typeof newChild === "string") {
329
+ newChild = this.ownerDocument.createTextNode(newChild);
330
+ }
331
+ const slotName = newChild["s-sn"] = getSlotName(newChild);
332
+ const childNodes = this.__childNodes || this.childNodes;
333
+ const slotNode = getHostSlotNodes(childNodes, this.tagName, slotName)[0];
334
+ if (slotNode) {
335
+ addSlotRelocateNode(newChild, slotNode, true);
336
+ const slotChildNodes = getHostSlotChildNodes(slotNode, slotName);
337
+ const appendAfter = slotChildNodes[0];
338
+ const parent = intrnlCall(appendAfter, "parentNode");
339
+ if (parent.__insertBefore) {
340
+ return parent.__insertBefore(newChild, intrnlCall(appendAfter, "nextSibling"));
341
+ } else {
342
+ return parent.insertBefore(newChild, intrnlCall(appendAfter, "nextSibling"));
343
+ }
344
+ }
345
+ if (newChild.nodeType === 1 && !!newChild.getAttribute("slot")) {
346
+ newChild.hidden = true;
347
+ }
348
+ return HostElementPrototype.__prepend(newChild);
349
+ });
310
350
  };
311
- if (BUILD2.vdomAttribute) {
312
- vnode.$attrs$ = null;
313
- }
314
- if (BUILD2.vdomKey) {
315
- vnode.$key$ = null;
316
- }
317
- if (BUILD2.slotRelocation) {
318
- vnode.$name$ = null;
319
- }
320
- return vnode;
321
351
  };
322
- var Host = {};
323
- var isHost = (node) => node && node.$tag$ === Host;
324
- var vdomFnUtils = {
325
- forEach: (children, cb) => children.map(convertToPublic).forEach(cb),
326
- map: (children, cb) => children.map(convertToPublic).map(cb).map(convertToPrivate)
352
+ var patchSlotAppend = (HostElementPrototype) => {
353
+ HostElementPrototype.__append = HostElementPrototype.append;
354
+ HostElementPrototype.append = function(...newChildren) {
355
+ newChildren.forEach((newChild) => {
356
+ if (typeof newChild === "string") {
357
+ newChild = this.ownerDocument.createTextNode(newChild);
358
+ }
359
+ this.appendChild(newChild);
360
+ });
361
+ };
327
362
  };
328
- var convertToPublic = (node) => ({
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 = (node) => {
337
- if (typeof node.vtag === "function") {
338
- const vnodeData = { ...node.vattrs };
339
- if (node.vkey) {
340
- vnodeData.key = node.vkey;
363
+ var patchSlotInsertAdjacentHTML = (HostElementPrototype) => {
364
+ const originalInsertAdjacentHtml = HostElementPrototype.insertAdjacentHTML;
365
+ HostElementPrototype.insertAdjacentHTML = function(position, text) {
366
+ if (position !== "afterbegin" && position !== "beforeend") {
367
+ return originalInsertAdjacentHtml.call(this, position, text);
341
368
  }
342
- if (node.vname) {
343
- vnodeData.name = node.vname;
369
+ const container = this.ownerDocument.createElement("_");
370
+ let node;
371
+ container.innerHTML = text;
372
+ if (position === "afterbegin") {
373
+ while (node = container.firstChild) {
374
+ this.prepend(node);
375
+ }
376
+ } else if (position === "beforeend") {
377
+ while (node = container.firstChild) {
378
+ this.append(node);
379
+ }
344
380
  }
345
- return h(node.vtag, vnodeData, ...node.vchildren || []);
346
- }
347
- const 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;
381
+ };
353
382
  };
354
- var validateInputProperties = (inputElm) => {
355
- const props = Object.keys(inputElm);
356
- const value = props.indexOf("value");
357
- if (value === -1) {
358
- return;
359
- }
360
- const typeIndex = props.indexOf("type");
361
- const minIndex = props.indexOf("min");
362
- const maxIndex = props.indexOf("max");
363
- const stepIndex = props.indexOf("step");
364
- if (value < typeIndex || value < minIndex || value < maxIndex || value < stepIndex) {
365
- consoleDevWarn(`The "value" prop of <input> should be set after "min", "max", "type" and "step"`);
366
- }
383
+ var patchSlotInsertAdjacentText = (HostElementPrototype) => {
384
+ HostElementPrototype.insertAdjacentText = function(position, text) {
385
+ this.insertAdjacentHTML(position, text);
386
+ };
367
387
  };
368
-
369
- // src/runtime/vdom/update-element.ts
370
- import { BUILD as BUILD4 } from "@stencil/core/internal/app-data";
371
-
372
- // src/runtime/vdom/set-accessor.ts
373
- import { BUILD as BUILD3 } from "@stencil/core/internal/app-data";
374
- var setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
375
- if (oldValue !== newValue) {
376
- let isProp = isMemberInElement(elm, memberName);
377
- let ln = memberName.toLowerCase();
378
- if (BUILD3.vdomClass && memberName === "class") {
379
- const classList = elm.classList;
380
- const oldClasses = parseClassList(oldValue);
381
- let newClasses = parseClassList(newValue);
382
- if (elm["s-si"]) {
383
- newClasses.push(elm["s-si"]);
384
- oldClasses.forEach((c) => {
385
- if (c.startsWith(elm["s-si"])) newClasses.push(c);
386
- });
387
- newClasses = [...new Set(newClasses)];
388
- classList.add(...newClasses);
389
- delete elm["s-si"];
390
- } else {
391
- classList.remove(...oldClasses.filter((c) => c && !newClasses.includes(c)));
392
- classList.add(...newClasses.filter((c) => c && !oldClasses.includes(c)));
393
- }
394
- } else if (BUILD3.vdomStyle && memberName === "style") {
395
- if (BUILD3.updatable) {
396
- for (const prop in oldValue) {
397
- if (!newValue || newValue[prop] == null) {
398
- if (!BUILD3.hydrateServerSide && prop.includes("-")) {
399
- elm.style.removeProperty(prop);
400
- } else {
401
- elm.style[prop] = "";
402
- }
403
- }
404
- }
405
- }
406
- for (const prop in newValue) {
407
- if (!oldValue || newValue[prop] !== oldValue[prop]) {
408
- if (!BUILD3.hydrateServerSide && prop.includes("-")) {
409
- elm.style.setProperty(prop, newValue[prop]);
410
- } else {
411
- elm.style[prop] = newValue[prop];
388
+ var patchInsertBefore = (HostElementPrototype) => {
389
+ const eleProto = HostElementPrototype;
390
+ if (eleProto.__insertBefore) return;
391
+ eleProto.__insertBefore = HostElementPrototype.insertBefore;
392
+ HostElementPrototype.insertBefore = function(newChild, currentChild) {
393
+ const slotName = newChild["s-sn"] = getSlotName(newChild);
394
+ const slotNode = getHostSlotNodes(this.__childNodes, this.tagName, slotName)[0];
395
+ const slottedNodes = this.__childNodes ? this.childNodes : getSlottedChildNodes(this.childNodes);
396
+ if (slotNode) {
397
+ let found = false;
398
+ slottedNodes.forEach((childNode) => {
399
+ if (childNode === currentChild || currentChild === null) {
400
+ found = true;
401
+ if (currentChild === null || slotName !== currentChild["s-sn"]) {
402
+ this.appendChild(newChild);
403
+ return;
412
404
  }
413
- }
414
- }
415
- } else if (BUILD3.vdomKey && memberName === "key") {
416
- } else if (BUILD3.vdomRef && memberName === "ref") {
417
- if (newValue) {
418
- newValue(elm);
419
- }
420
- } else if (BUILD3.vdomListener && (BUILD3.lazyLoad ? !isProp : !elm.__lookupSetter__(memberName)) && memberName[0] === "o" && memberName[1] === "n") {
421
- if (memberName[2] === "-") {
422
- memberName = memberName.slice(3);
423
- } else if (isMemberInElement(win, ln)) {
424
- memberName = ln.slice(2);
425
- } else {
426
- memberName = ln[2] + memberName.slice(3);
427
- }
428
- if (oldValue || newValue) {
429
- const capture = memberName.endsWith(CAPTURE_EVENT_SUFFIX);
430
- memberName = memberName.replace(CAPTURE_EVENT_REGEX, "");
431
- if (oldValue) {
432
- plt.rel(elm, memberName, oldValue, capture);
433
- }
434
- if (newValue) {
435
- plt.ael(elm, memberName, newValue, capture);
436
- }
437
- }
438
- } else if (BUILD3.vdomPropOrAttr) {
439
- const isComplex = isComplexType(newValue);
440
- if ((isProp || isComplex && newValue !== null) && !isSvg) {
441
- try {
442
- if (!elm.tagName.includes("-")) {
443
- const n = newValue == null ? "" : newValue;
444
- if (memberName === "list") {
445
- isProp = false;
446
- } else if (oldValue == null || elm[memberName] != n) {
447
- if (typeof elm.__lookupSetter__(memberName) === "function") {
448
- elm[memberName] = n;
449
- } else {
450
- elm.setAttribute(memberName, n);
451
- }
405
+ if (slotName === currentChild["s-sn"]) {
406
+ addSlotRelocateNode(newChild, slotNode);
407
+ const parent = intrnlCall(currentChild, "parentNode");
408
+ if (parent.__insertBefore) {
409
+ parent.__insertBefore(newChild, currentChild);
410
+ } else {
411
+ parent.insertBefore(newChild, currentChild);
452
412
  }
453
- } else {
454
- elm[memberName] = newValue;
455
- }
456
- } catch (e) {
457
- }
458
- }
459
- let xlink = false;
460
- if (BUILD3.vdomXlink) {
461
- if (ln !== (ln = ln.replace(/^xlink\:?/, ""))) {
462
- memberName = ln;
463
- xlink = true;
464
- }
465
- }
466
- if (newValue == null || newValue === false) {
467
- if (newValue !== false || elm.getAttribute(memberName) === "") {
468
- if (BUILD3.vdomXlink && xlink) {
469
- elm.removeAttributeNS(XLINK_NS, memberName);
470
- } else {
471
- elm.removeAttribute(memberName);
472
413
  }
414
+ return;
473
415
  }
474
- } else if ((!isProp || flags & 4 /* isHost */ || isSvg) && !isComplex) {
475
- newValue = newValue === true ? "" : newValue;
476
- if (BUILD3.vdomXlink && xlink) {
477
- elm.setAttributeNS(XLINK_NS, memberName, newValue);
478
- } else {
479
- elm.setAttribute(memberName, newValue);
480
- }
481
- }
416
+ });
417
+ if (found) return newChild;
482
418
  }
483
- }
419
+ return this.__insertBefore(newChild, currentChild);
420
+ };
484
421
  };
485
- var parseClassListRegex = /\s/;
486
- var parseClassList = (value) => {
487
- if (typeof value === "object" && "baseVal" in value) {
488
- value = value.baseVal;
489
- }
490
- if (!value) {
491
- return [];
492
- }
493
- return value.split(parseClassListRegex);
422
+ var patchSlotInsertAdjacentElement = (HostElementPrototype) => {
423
+ const originalInsertAdjacentElement = HostElementPrototype.insertAdjacentElement;
424
+ HostElementPrototype.insertAdjacentElement = function(position, element) {
425
+ if (position !== "afterbegin" && position !== "beforeend") {
426
+ return originalInsertAdjacentElement.call(this, position, element);
427
+ }
428
+ if (position === "afterbegin") {
429
+ this.prepend(element);
430
+ return element;
431
+ } else if (position === "beforeend") {
432
+ this.append(element);
433
+ return element;
434
+ }
435
+ return element;
436
+ };
494
437
  };
495
- var CAPTURE_EVENT_SUFFIX = "Capture";
496
- var CAPTURE_EVENT_REGEX = new RegExp(CAPTURE_EVENT_SUFFIX + "$");
497
-
498
- // src/runtime/vdom/update-element.ts
499
- var updateElement = (oldVnode, newVnode, isSvgMode2) => {
500
- const elm = newVnode.$elm$.nodeType === 11 /* DocumentFragment */ && newVnode.$elm$.host ? newVnode.$elm$.host : newVnode.$elm$;
501
- const oldVnodeAttrs = oldVnode && oldVnode.$attrs$ || {};
502
- const newVnodeAttrs = newVnode.$attrs$ || {};
503
- if (BUILD4.updatable) {
504
- for (const memberName of sortedAttrNames(Object.keys(oldVnodeAttrs))) {
505
- if (!(memberName in newVnodeAttrs)) {
506
- setAccessor(elm, memberName, oldVnodeAttrs[memberName], void 0, isSvgMode2, newVnode.$flags$);
507
- }
438
+ var patchTextContent = (hostElementPrototype) => {
439
+ patchHostOriginalAccessor("textContent", hostElementPrototype);
440
+ Object.defineProperty(hostElementPrototype, "textContent", {
441
+ get: function() {
442
+ let text = "";
443
+ const childNodes = this.__childNodes ? this.childNodes : getSlottedChildNodes(this.childNodes);
444
+ childNodes.forEach((node) => text += node.textContent || "");
445
+ return text;
446
+ },
447
+ set: function(value) {
448
+ const childNodes = this.__childNodes ? this.childNodes : getSlottedChildNodes(this.childNodes);
449
+ childNodes.forEach((node) => {
450
+ if (node["s-ol"]) node["s-ol"].remove();
451
+ node.remove();
452
+ });
453
+ this.insertAdjacentHTML("beforeend", value);
508
454
  }
509
- }
510
- for (const memberName of sortedAttrNames(Object.keys(newVnodeAttrs))) {
511
- setAccessor(elm, memberName, oldVnodeAttrs[memberName], newVnodeAttrs[memberName], isSvgMode2, newVnode.$flags$);
512
- }
455
+ });
513
456
  };
514
- function sortedAttrNames(attrNames) {
515
- return attrNames.includes("ref") ? (
516
- // we need to sort these to ensure that `'ref'` is the last attr
517
- [...attrNames.filter((attr) => attr !== "ref"), "ref"]
518
- ) : (
519
- // no need to sort, return the original array
520
- attrNames
521
- );
522
- }
523
-
524
- // src/runtime/vdom/vdom-render.ts
525
- var scopeId;
526
- var contentRef;
527
- var hostTagName;
528
- var useNativeShadowDom = false;
529
- var checkSlotFallbackVisibility = false;
530
- var checkSlotRelocate = false;
531
- var isSvgMode = false;
532
- var createElm = (oldParentVNode, newParentVNode, childIndex) => {
533
- var _a;
534
- const newVNode2 = newParentVNode.$children$[childIndex];
535
- let i2 = 0;
536
- let elm;
537
- let childNode;
538
- let oldVNode;
539
- if (BUILD5.slotRelocation && !useNativeShadowDom) {
540
- checkSlotRelocate = true;
541
- if (newVNode2.$tag$ === "slot") {
542
- newVNode2.$flags$ |= newVNode2.$children$ ? (
543
- // slot element has fallback content
544
- // still create an element that "mocks" the slot element
545
- 2 /* isSlotFallback */
546
- ) : (
547
- // slot element does not have fallback content
548
- // create an html comment we'll use to always reference
549
- // where actual slot content should sit next to
550
- 1 /* isSlotReference */
551
- );
457
+ var patchChildSlotNodes = (elm) => {
458
+ class FakeNodeList extends Array {
459
+ item(n) {
460
+ return this[n];
552
461
  }
553
462
  }
554
- if (BUILD5.isDev && newVNode2.$elm$) {
555
- consoleDevError(
556
- `The JSX ${newVNode2.$text$ !== null ? `"${newVNode2.$text$}" text` : `"${newVNode2.$tag$}" element`} node should not be shared within the same renderer. The renderer caches element lookups in order to improve performance. However, a side effect from this is that the exact same JSX node should not be reused. For more information please see https://stenciljs.com/docs/templating-jsx#avoid-shared-jsx-nodes`
557
- );
558
- }
559
- if (BUILD5.vdomText && newVNode2.$text$ !== null) {
560
- elm = newVNode2.$elm$ = doc.createTextNode(newVNode2.$text$);
561
- } else if (BUILD5.slotRelocation && newVNode2.$flags$ & 1 /* isSlotReference */) {
562
- elm = newVNode2.$elm$ = BUILD5.isDebug || BUILD5.hydrateServerSide ? slotReferenceDebugNode(newVNode2) : doc.createTextNode("");
563
- } else {
564
- if (BUILD5.svg && !isSvgMode) {
565
- isSvgMode = newVNode2.$tag$ === "svg";
566
- }
567
- elm = newVNode2.$elm$ = BUILD5.svg ? doc.createElementNS(
568
- isSvgMode ? SVG_NS : HTML_NS,
569
- !useNativeShadowDom && BUILD5.slotRelocation && newVNode2.$flags$ & 2 /* isSlotFallback */ ? "slot-fb" : newVNode2.$tag$
570
- ) : doc.createElement(
571
- !useNativeShadowDom && BUILD5.slotRelocation && newVNode2.$flags$ & 2 /* isSlotFallback */ ? "slot-fb" : newVNode2.$tag$
572
- );
573
- if (BUILD5.svg && isSvgMode && newVNode2.$tag$ === "foreignObject") {
574
- isSvgMode = false;
463
+ patchHostOriginalAccessor("children", elm);
464
+ Object.defineProperty(elm, "children", {
465
+ get() {
466
+ return this.childNodes.filter((n) => n.nodeType === 1);
575
467
  }
576
- if (BUILD5.vdomAttribute) {
577
- updateElement(null, newVNode2, isSvgMode);
468
+ });
469
+ Object.defineProperty(elm, "childElementCount", {
470
+ get() {
471
+ return this.children.length;
578
472
  }
579
- if (BUILD5.scoped && isDef(scopeId) && elm["s-si"] !== scopeId) {
580
- elm.classList.add(elm["s-si"] = scopeId);
473
+ });
474
+ patchHostOriginalAccessor("firstChild", elm);
475
+ Object.defineProperty(elm, "firstChild", {
476
+ get() {
477
+ return this.childNodes[0];
581
478
  }
582
- if (newVNode2.$children$) {
583
- for (i2 = 0; i2 < newVNode2.$children$.length; ++i2) {
584
- childNode = createElm(oldParentVNode, newVNode2, i2);
585
- if (childNode) {
586
- elm.appendChild(childNode);
587
- }
588
- }
479
+ });
480
+ patchHostOriginalAccessor("lastChild", elm);
481
+ Object.defineProperty(elm, "lastChild", {
482
+ get() {
483
+ return this.childNodes[this.childNodes.length - 1];
589
484
  }
590
- if (BUILD5.svg) {
591
- if (newVNode2.$tag$ === "svg") {
592
- isSvgMode = false;
593
- } else if (elm.tagName === "foreignObject") {
594
- isSvgMode = true;
595
- }
485
+ });
486
+ patchHostOriginalAccessor("childNodes", elm);
487
+ Object.defineProperty(elm, "childNodes", {
488
+ get() {
489
+ const result = new FakeNodeList();
490
+ result.push(...getSlottedChildNodes(this.__childNodes));
491
+ return result;
596
492
  }
597
- }
598
- elm["s-hn"] = hostTagName;
599
- if (BUILD5.slotRelocation) {
600
- if (newVNode2.$flags$ & (2 /* isSlotFallback */ | 1 /* isSlotReference */)) {
601
- elm["s-sr"] = true;
602
- elm["s-cr"] = contentRef;
603
- elm["s-sn"] = newVNode2.$name$ || "";
604
- elm["s-rf"] = (_a = newVNode2.$attrs$) == null ? void 0 : _a.ref;
605
- oldVNode = oldParentVNode && oldParentVNode.$children$ && oldParentVNode.$children$[childIndex];
606
- if (oldVNode && oldVNode.$tag$ === newVNode2.$tag$ && oldParentVNode.$elm$) {
607
- if (BUILD5.experimentalSlotFixes) {
608
- relocateToHostRoot(oldParentVNode.$elm$);
609
- } else {
610
- putBackInOriginalLocation(oldParentVNode.$elm$, false);
611
- }
612
- }
613
- if (BUILD5.scoped) {
614
- addRemoveSlotScopedClass(contentRef, elm, newParentVNode.$elm$, oldParentVNode == null ? void 0 : oldParentVNode.$elm$);
493
+ });
494
+ };
495
+ var patchSlottedNode = (node) => {
496
+ if (!node || node.__nextSibling || !globalThis.Node) return;
497
+ patchNextSibling(node);
498
+ patchPreviousSibling(node);
499
+ patchParentNode(node);
500
+ if (node.nodeType === Node.ELEMENT_NODE) {
501
+ patchNextElementSibling(node);
502
+ patchPreviousElementSibling(node);
503
+ }
504
+ };
505
+ var patchNextSibling = (node) => {
506
+ if (!node || node.__nextSibling) return;
507
+ patchHostOriginalAccessor("nextSibling", node);
508
+ Object.defineProperty(node, "nextSibling", {
509
+ get: function() {
510
+ var _a;
511
+ const parentNodes = (_a = this["s-ol"]) == null ? void 0 : _a.parentNode.childNodes;
512
+ const index = parentNodes == null ? void 0 : parentNodes.indexOf(this);
513
+ if (parentNodes && index > -1) {
514
+ return parentNodes[index + 1];
615
515
  }
516
+ return this.__nextSibling;
616
517
  }
617
- }
618
- return elm;
518
+ });
619
519
  };
620
- var relocateToHostRoot = (parentElm) => {
621
- plt.$flags$ |= 1 /* isTmpDisconnected */;
622
- const host = parentElm.closest(hostTagName.toLowerCase());
623
- if (host != null) {
624
- const contentRefNode = Array.from(host.__childNodes || host.childNodes).find(
625
- (ref) => ref["s-cr"]
626
- );
627
- const childNodeArray = Array.from(
628
- parentElm.__childNodes || parentElm.childNodes
629
- );
630
- for (const childNode of contentRefNode ? childNodeArray.reverse() : childNodeArray) {
631
- if (childNode["s-sh"] != null) {
632
- insertBefore(host, childNode, contentRefNode != null ? contentRefNode : null);
633
- childNode["s-sh"] = void 0;
634
- checkSlotRelocate = true;
520
+ var patchNextElementSibling = (element) => {
521
+ if (!element || element.__nextElementSibling) return;
522
+ patchHostOriginalAccessor("nextElementSibling", element);
523
+ Object.defineProperty(element, "nextElementSibling", {
524
+ get: function() {
525
+ var _a;
526
+ const parentEles = (_a = this["s-ol"]) == null ? void 0 : _a.parentNode.children;
527
+ const index = parentEles == null ? void 0 : parentEles.indexOf(this);
528
+ if (parentEles && index > -1) {
529
+ return parentEles[index + 1];
635
530
  }
531
+ return this.__nextElementSibling;
636
532
  }
637
- }
638
- plt.$flags$ &= ~1 /* isTmpDisconnected */;
533
+ });
639
534
  };
640
- var putBackInOriginalLocation = (parentElm, recursive) => {
641
- plt.$flags$ |= 1 /* isTmpDisconnected */;
642
- const oldSlotChildNodes = Array.from(parentElm.__childNodes || parentElm.childNodes);
643
- if (parentElm["s-sr"] && BUILD5.experimentalSlotFixes) {
644
- let node = parentElm;
645
- while (node = node.nextSibling) {
646
- if (node && node["s-sn"] === parentElm["s-sn"] && node["s-sh"] === hostTagName) {
647
- oldSlotChildNodes.push(node);
535
+ var patchPreviousSibling = (node) => {
536
+ if (!node || node.__previousSibling) return;
537
+ patchHostOriginalAccessor("previousSibling", node);
538
+ Object.defineProperty(node, "previousSibling", {
539
+ get: function() {
540
+ var _a;
541
+ const parentNodes = (_a = this["s-ol"]) == null ? void 0 : _a.parentNode.childNodes;
542
+ const index = parentNodes == null ? void 0 : parentNodes.indexOf(this);
543
+ if (parentNodes && index > -1) {
544
+ return parentNodes[index - 1];
648
545
  }
546
+ return this.__previousSibling;
649
547
  }
650
- }
651
- for (let i2 = oldSlotChildNodes.length - 1; i2 >= 0; i2--) {
652
- const childNode = oldSlotChildNodes[i2];
653
- if (childNode["s-hn"] !== hostTagName && childNode["s-ol"]) {
654
- insertBefore(referenceNode(childNode).parentNode, childNode, referenceNode(childNode));
655
- childNode["s-ol"].remove();
656
- childNode["s-ol"] = void 0;
657
- childNode["s-sh"] = void 0;
658
- checkSlotRelocate = true;
548
+ });
549
+ };
550
+ var patchPreviousElementSibling = (element) => {
551
+ if (!element || element.__previousElementSibling) return;
552
+ patchHostOriginalAccessor("previousElementSibling", element);
553
+ Object.defineProperty(element, "previousElementSibling", {
554
+ get: function() {
555
+ var _a;
556
+ const parentNodes = (_a = this["s-ol"]) == null ? void 0 : _a.parentNode.children;
557
+ const index = parentNodes == null ? void 0 : parentNodes.indexOf(this);
558
+ if (parentNodes && index > -1) {
559
+ return parentNodes[index - 1];
560
+ }
561
+ return this.__previousElementSibling;
659
562
  }
660
- if (recursive) {
661
- putBackInOriginalLocation(childNode, recursive);
563
+ });
564
+ };
565
+ var patchParentNode = (node) => {
566
+ if (!node || node.__parentNode) return;
567
+ patchHostOriginalAccessor("parentNode", node);
568
+ Object.defineProperty(node, "parentNode", {
569
+ get: function() {
570
+ var _a;
571
+ return ((_a = this["s-ol"]) == null ? void 0 : _a.parentNode) || this.__parentNode;
572
+ },
573
+ set: function(value) {
574
+ this.__parentNode = value;
662
575
  }
663
- }
664
- plt.$flags$ &= ~1 /* isTmpDisconnected */;
576
+ });
665
577
  };
666
- var addVnodes = (parentElm, before, parentVNode, vnodes, startIdx, endIdx) => {
667
- let containerElm = BUILD5.slotRelocation && parentElm["s-cr"] && parentElm["s-cr"].parentNode || parentElm;
668
- let childNode;
669
- if (BUILD5.shadowDom && containerElm.shadowRoot && containerElm.tagName === hostTagName) {
670
- containerElm = containerElm.shadowRoot;
578
+ var validElementPatches = ["children", "nextElementSibling", "previousElementSibling"];
579
+ var validNodesPatches = [
580
+ "childNodes",
581
+ "firstChild",
582
+ "lastChild",
583
+ "nextSibling",
584
+ "previousSibling",
585
+ "textContent",
586
+ "parentNode"
587
+ ];
588
+ function patchHostOriginalAccessor(accessorName, node) {
589
+ let accessor;
590
+ if (validElementPatches.includes(accessorName)) {
591
+ accessor = Object.getOwnPropertyDescriptor(Element.prototype, accessorName);
592
+ } else if (validNodesPatches.includes(accessorName)) {
593
+ accessor = Object.getOwnPropertyDescriptor(Node.prototype, accessorName);
671
594
  }
672
- for (; startIdx <= endIdx; ++startIdx) {
673
- if (vnodes[startIdx]) {
674
- childNode = createElm(null, parentVNode, startIdx);
675
- if (childNode) {
676
- vnodes[startIdx].$elm$ = childNode;
677
- insertBefore(containerElm, childNode, BUILD5.slotRelocation ? referenceNode(before) : before);
678
- }
595
+ if (!accessor) {
596
+ accessor = Object.getOwnPropertyDescriptor(node, accessorName);
597
+ }
598
+ if (accessor) Object.defineProperty(node, "__" + accessorName, accessor);
599
+ }
600
+ function intrnlCall(node, method) {
601
+ if ("__" + method in node) {
602
+ return node["__" + method];
603
+ } else {
604
+ return node[method];
605
+ }
606
+ }
607
+
608
+ // src/runtime/profile.ts
609
+ import { BUILD as BUILD3 } from "@stencil/core/internal/app-data";
610
+ var i = 0;
611
+ var createTime = (fnName, tagName = "") => {
612
+ if (BUILD3.profile && performance.mark) {
613
+ const key = `st:${fnName}:${tagName}:${i++}`;
614
+ performance.mark(key);
615
+ return () => performance.measure(`[Stencil] ${fnName}() <${tagName}>`, key);
616
+ } else {
617
+ return () => {
618
+ return;
619
+ };
620
+ }
621
+ };
622
+ var uniqueTime = (key, measureText) => {
623
+ if (BUILD3.profile && performance.mark) {
624
+ if (performance.getEntriesByName(key, "mark").length === 0) {
625
+ performance.mark(key);
679
626
  }
627
+ return () => {
628
+ if (performance.getEntriesByName(measureText, "measure").length === 0) {
629
+ performance.measure(measureText, key);
630
+ }
631
+ };
632
+ } else {
633
+ return () => {
634
+ return;
635
+ };
680
636
  }
681
637
  };
682
- var removeVnodes = (vnodes, startIdx, endIdx) => {
683
- for (let index = startIdx; index <= endIdx; ++index) {
684
- const vnode = vnodes[index];
685
- if (vnode) {
686
- const elm = vnode.$elm$;
687
- nullifyVNodeRefs(vnode);
688
- if (elm) {
689
- if (BUILD5.slotRelocation) {
690
- checkSlotFallbackVisibility = true;
691
- if (elm["s-ol"]) {
692
- elm["s-ol"].remove();
693
- } else {
694
- putBackInOriginalLocation(elm, true);
695
- }
696
- }
697
- elm.remove();
638
+ var inspect = (ref) => {
639
+ const hostRef = getHostRef(ref);
640
+ if (!hostRef) {
641
+ return void 0;
642
+ }
643
+ const flags = hostRef.$flags$;
644
+ const hostElement = hostRef.$hostElement$;
645
+ return {
646
+ renderCount: hostRef.$renderCount$,
647
+ flags: {
648
+ hasRendered: !!(flags & 2 /* hasRendered */),
649
+ hasConnected: !!(flags & 1 /* hasConnected */),
650
+ isWaitingForChildren: !!(flags & 4 /* isWaitingForChildren */),
651
+ isConstructingInstance: !!(flags & 8 /* isConstructingInstance */),
652
+ isQueuedForUpdate: !!(flags & 16 /* isQueuedForUpdate */),
653
+ hasInitializedComponent: !!(flags & 32 /* hasInitializedComponent */),
654
+ hasLoadedComponent: !!(flags & 64 /* hasLoadedComponent */),
655
+ isWatchReady: !!(flags & 128 /* isWatchReady */),
656
+ isListenReady: !!(flags & 256 /* isListenReady */),
657
+ needsRerender: !!(flags & 512 /* needsRerender */)
658
+ },
659
+ instanceValues: hostRef.$instanceValues$,
660
+ ancestorComponent: hostRef.$ancestorComponent$,
661
+ hostElement,
662
+ lazyInstance: hostRef.$lazyInstance$,
663
+ vnode: hostRef.$vnode$,
664
+ modeName: hostRef.$modeName$,
665
+ onReadyPromise: hostRef.$onReadyPromise$,
666
+ onReadyResolve: hostRef.$onReadyResolve$,
667
+ onInstancePromise: hostRef.$onInstancePromise$,
668
+ onInstanceResolve: hostRef.$onInstanceResolve$,
669
+ onRenderResolve: hostRef.$onRenderResolve$,
670
+ queuedListeners: hostRef.$queuedListeners$,
671
+ rmListeners: hostRef.$rmListeners$,
672
+ ["s-id"]: hostElement["s-id"],
673
+ ["s-cr"]: hostElement["s-cr"],
674
+ ["s-lr"]: hostElement["s-lr"],
675
+ ["s-p"]: hostElement["s-p"],
676
+ ["s-rc"]: hostElement["s-rc"],
677
+ ["s-sc"]: hostElement["s-sc"]
678
+ };
679
+ };
680
+ var installDevTools = () => {
681
+ if (BUILD3.devTools) {
682
+ const stencil = win.stencil = win.stencil || {};
683
+ const originalInspect = stencil.inspect;
684
+ stencil.inspect = (ref) => {
685
+ let result = inspect(ref);
686
+ if (!result && typeof originalInspect === "function") {
687
+ result = originalInspect(ref);
698
688
  }
699
- }
689
+ return result;
690
+ };
700
691
  }
701
692
  };
702
- var updateChildren = (parentElm, oldCh, newVNode2, newCh, isInitialRender = false) => {
703
- let oldStartIdx = 0;
704
- let newStartIdx = 0;
705
- let idxInOld = 0;
706
- let i2 = 0;
707
- let oldEndIdx = oldCh.length - 1;
708
- let oldStartVnode = oldCh[0];
709
- let oldEndVnode = oldCh[oldEndIdx];
710
- let newEndIdx = newCh.length - 1;
711
- let newStartVnode = newCh[0];
712
- let newEndVnode = newCh[newEndIdx];
713
- let node;
714
- let elmToMove;
715
- while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
716
- if (oldStartVnode == null) {
717
- oldStartVnode = oldCh[++oldStartIdx];
718
- } else if (oldEndVnode == null) {
719
- oldEndVnode = oldCh[--oldEndIdx];
720
- } else if (newStartVnode == null) {
721
- newStartVnode = newCh[++newStartIdx];
722
- } else if (newEndVnode == null) {
723
- newEndVnode = newCh[--newEndIdx];
724
- } else if (isSameVnode(oldStartVnode, newStartVnode, isInitialRender)) {
725
- patch(oldStartVnode, newStartVnode, isInitialRender);
726
- oldStartVnode = oldCh[++oldStartIdx];
727
- newStartVnode = newCh[++newStartIdx];
728
- } else if (isSameVnode(oldEndVnode, newEndVnode, isInitialRender)) {
729
- patch(oldEndVnode, newEndVnode, isInitialRender);
730
- oldEndVnode = oldCh[--oldEndIdx];
731
- newEndVnode = newCh[--newEndIdx];
732
- } else if (isSameVnode(oldStartVnode, newEndVnode, isInitialRender)) {
733
- if (BUILD5.slotRelocation && (oldStartVnode.$tag$ === "slot" || newEndVnode.$tag$ === "slot")) {
734
- putBackInOriginalLocation(oldStartVnode.$elm$.parentNode, false);
735
- }
736
- patch(oldStartVnode, newEndVnode, isInitialRender);
737
- insertBefore(parentElm, oldStartVnode.$elm$, oldEndVnode.$elm$.nextSibling);
738
- oldStartVnode = oldCh[++oldStartIdx];
739
- newEndVnode = newCh[--newEndIdx];
740
- } else if (isSameVnode(oldEndVnode, newStartVnode, isInitialRender)) {
741
- if (BUILD5.slotRelocation && (oldStartVnode.$tag$ === "slot" || newEndVnode.$tag$ === "slot")) {
742
- putBackInOriginalLocation(oldEndVnode.$elm$.parentNode, false);
743
- }
744
- patch(oldEndVnode, newStartVnode, isInitialRender);
745
- insertBefore(parentElm, oldEndVnode.$elm$, oldStartVnode.$elm$);
746
- oldEndVnode = oldCh[--oldEndIdx];
747
- newStartVnode = newCh[++newStartIdx];
748
- } else {
749
- idxInOld = -1;
750
- if (BUILD5.vdomKey) {
751
- for (i2 = oldStartIdx; i2 <= oldEndIdx; ++i2) {
752
- if (oldCh[i2] && oldCh[i2].$key$ !== null && oldCh[i2].$key$ === newStartVnode.$key$) {
753
- idxInOld = i2;
754
- break;
755
- }
693
+
694
+ // src/runtime/vdom/h.ts
695
+ import { BUILD as BUILD4 } from "@stencil/core/internal/app-data";
696
+ var h = (nodeName, vnodeData, ...children) => {
697
+ let child = null;
698
+ let key = null;
699
+ let slotName = null;
700
+ let simple = false;
701
+ let lastSimple = false;
702
+ const vNodeChildren = [];
703
+ const walk = (c) => {
704
+ for (let i2 = 0; i2 < c.length; i2++) {
705
+ child = c[i2];
706
+ if (Array.isArray(child)) {
707
+ walk(child);
708
+ } else if (child != null && typeof child !== "boolean") {
709
+ if (simple = typeof nodeName !== "function" && !isComplexType(child)) {
710
+ child = String(child);
711
+ } else if (BUILD4.isDev && typeof nodeName !== "function" && child.$flags$ === void 0) {
712
+ consoleDevError(`vNode passed as children has unexpected type.
713
+ Make sure it's using the correct h() function.
714
+ Empty objects can also be the cause, look for JSX comments that became objects.`);
756
715
  }
757
- }
758
- if (BUILD5.vdomKey && idxInOld >= 0) {
759
- elmToMove = oldCh[idxInOld];
760
- if (elmToMove.$tag$ !== newStartVnode.$tag$) {
761
- node = createElm(oldCh && oldCh[newStartIdx], newVNode2, idxInOld);
716
+ if (simple && lastSimple) {
717
+ vNodeChildren[vNodeChildren.length - 1].$text$ += child;
762
718
  } else {
763
- patch(elmToMove, newStartVnode, isInitialRender);
764
- oldCh[idxInOld] = void 0;
765
- node = elmToMove.$elm$;
719
+ vNodeChildren.push(simple ? newVNode(null, child) : child);
766
720
  }
767
- newStartVnode = newCh[++newStartIdx];
768
- } else {
769
- node = createElm(oldCh && oldCh[newStartIdx], newVNode2, newStartIdx);
770
- newStartVnode = newCh[++newStartIdx];
721
+ lastSimple = simple;
771
722
  }
772
- if (node) {
773
- if (BUILD5.slotRelocation) {
774
- insertBefore(
775
- referenceNode(oldStartVnode.$elm$).parentNode,
776
- node,
777
- referenceNode(oldStartVnode.$elm$)
778
- );
779
- } else {
780
- insertBefore(oldStartVnode.$elm$.parentNode, node, oldStartVnode.$elm$);
781
- }
723
+ }
724
+ };
725
+ walk(children);
726
+ if (vnodeData) {
727
+ if (BUILD4.isDev && nodeName === "input") {
728
+ validateInputProperties(vnodeData);
729
+ }
730
+ if (BUILD4.vdomKey && vnodeData.key) {
731
+ key = vnodeData.key;
732
+ }
733
+ if (BUILD4.slotRelocation && vnodeData.name) {
734
+ slotName = vnodeData.name;
735
+ }
736
+ if (BUILD4.vdomClass) {
737
+ const classData = vnodeData.className || vnodeData.class;
738
+ if (classData) {
739
+ vnodeData.class = typeof classData !== "object" ? classData : Object.keys(classData).filter((k) => classData[k]).join(" ");
782
740
  }
783
741
  }
784
742
  }
785
- if (oldStartIdx > oldEndIdx) {
786
- addVnodes(
787
- parentElm,
788
- newCh[newEndIdx + 1] == null ? null : newCh[newEndIdx + 1].$elm$,
789
- newVNode2,
790
- newCh,
791
- newStartIdx,
792
- newEndIdx
743
+ if (BUILD4.isDev && vNodeChildren.some(isHost)) {
744
+ consoleDevError(`The <Host> must be the single root component. Make sure:
745
+ - You are NOT using hostData() and <Host> in the same component.
746
+ - <Host> is used once, and it's the single root component of the render() function.`);
747
+ }
748
+ if (BUILD4.vdomFunctional && typeof nodeName === "function") {
749
+ return nodeName(
750
+ vnodeData === null ? {} : vnodeData,
751
+ vNodeChildren,
752
+ vdomFnUtils
793
753
  );
794
- } else if (BUILD5.updatable && newStartIdx > newEndIdx) {
795
- removeVnodes(oldCh, oldStartIdx, oldEndIdx);
796
754
  }
755
+ const vnode = newVNode(nodeName, null);
756
+ vnode.$attrs$ = vnodeData;
757
+ if (vNodeChildren.length > 0) {
758
+ vnode.$children$ = vNodeChildren;
759
+ }
760
+ if (BUILD4.vdomKey) {
761
+ vnode.$key$ = key;
762
+ }
763
+ if (BUILD4.slotRelocation) {
764
+ vnode.$name$ = slotName;
765
+ }
766
+ return vnode;
797
767
  };
798
- var isSameVnode = (leftVNode, rightVNode, isInitialRender = false) => {
799
- if (leftVNode.$tag$ === rightVNode.$tag$) {
800
- if (BUILD5.slotRelocation && leftVNode.$tag$ === "slot") {
801
- return leftVNode.$name$ === rightVNode.$name$;
802
- }
803
- if (BUILD5.vdomKey && !isInitialRender) {
804
- return leftVNode.$key$ === rightVNode.$key$;
768
+ var newVNode = (tag, text) => {
769
+ const vnode = {
770
+ $flags$: 0,
771
+ $tag$: tag,
772
+ $text$: text,
773
+ $elm$: null,
774
+ $children$: null
775
+ };
776
+ if (BUILD4.vdomAttribute) {
777
+ vnode.$attrs$ = null;
778
+ }
779
+ if (BUILD4.vdomKey) {
780
+ vnode.$key$ = null;
781
+ }
782
+ if (BUILD4.slotRelocation) {
783
+ vnode.$name$ = null;
784
+ }
785
+ return vnode;
786
+ };
787
+ var Host = {};
788
+ var isHost = (node) => node && node.$tag$ === Host;
789
+ var vdomFnUtils = {
790
+ forEach: (children, cb) => children.map(convertToPublic).forEach(cb),
791
+ map: (children, cb) => children.map(convertToPublic).map(cb).map(convertToPrivate)
792
+ };
793
+ var convertToPublic = (node) => ({
794
+ vattrs: node.$attrs$,
795
+ vchildren: node.$children$,
796
+ vkey: node.$key$,
797
+ vname: node.$name$,
798
+ vtag: node.$tag$,
799
+ vtext: node.$text$
800
+ });
801
+ var convertToPrivate = (node) => {
802
+ if (typeof node.vtag === "function") {
803
+ const vnodeData = { ...node.vattrs };
804
+ if (node.vkey) {
805
+ vnodeData.key = node.vkey;
805
806
  }
806
- if (isInitialRender && !leftVNode.$key$ && rightVNode.$key$) {
807
- leftVNode.$key$ = rightVNode.$key$;
807
+ if (node.vname) {
808
+ vnodeData.name = node.vname;
808
809
  }
809
- return true;
810
+ return h(node.vtag, vnodeData, ...node.vchildren || []);
810
811
  }
811
- return false;
812
+ const vnode = newVNode(node.vtag, node.vtext);
813
+ vnode.$attrs$ = node.vattrs;
814
+ vnode.$children$ = node.vchildren;
815
+ vnode.$key$ = node.vkey;
816
+ vnode.$name$ = node.vname;
817
+ return vnode;
812
818
  };
813
- var referenceNode = (node) => node && node["s-ol"] || node;
814
- var patch = (oldVNode, newVNode2, isInitialRender = false) => {
815
- const elm = newVNode2.$elm$ = oldVNode.$elm$;
816
- const oldChildren = oldVNode.$children$;
817
- const newChildren = newVNode2.$children$;
818
- const tag = newVNode2.$tag$;
819
- const text = newVNode2.$text$;
820
- let defaultHolder;
821
- if (!BUILD5.vdomText || text === null) {
822
- if (BUILD5.svg) {
823
- isSvgMode = tag === "svg" ? true : tag === "foreignObject" ? false : isSvgMode;
819
+ var validateInputProperties = (inputElm) => {
820
+ const props = Object.keys(inputElm);
821
+ const value = props.indexOf("value");
822
+ if (value === -1) {
823
+ return;
824
+ }
825
+ const typeIndex = props.indexOf("type");
826
+ const minIndex = props.indexOf("min");
827
+ const maxIndex = props.indexOf("max");
828
+ const stepIndex = props.indexOf("step");
829
+ if (value < typeIndex || value < minIndex || value < maxIndex || value < stepIndex) {
830
+ consoleDevWarn(`The "value" prop of <input> should be set after "min", "max", "type" and "step"`);
831
+ }
832
+ };
833
+
834
+ // src/runtime/client-hydrate.ts
835
+ var initializeClientHydrate = (hostElm, tagName, hostId, hostRef) => {
836
+ const endHydrate = createTime("hydrateClient", tagName);
837
+ const shadowRoot = hostElm.shadowRoot;
838
+ const childRenderNodes = [];
839
+ const slotNodes = [];
840
+ const slottedNodes = [];
841
+ const shadowRootNodes = BUILD5.shadowDom && shadowRoot ? [] : null;
842
+ const vnode = newVNode(tagName, null);
843
+ vnode.$elm$ = hostElm;
844
+ let scopeId2;
845
+ if (BUILD5.scoped) {
846
+ const cmpMeta = hostRef.$cmpMeta$;
847
+ if (cmpMeta && cmpMeta.$flags$ & 10 /* needsScopedEncapsulation */ && hostElm["s-sc"]) {
848
+ scopeId2 = hostElm["s-sc"];
849
+ hostElm.classList.add(scopeId2 + "-h");
850
+ } else if (hostElm["s-sc"]) {
851
+ delete hostElm["s-sc"];
824
852
  }
825
- if (BUILD5.vdomAttribute || BUILD5.reflect) {
826
- if (BUILD5.slot && tag === "slot" && !useNativeShadowDom) {
827
- if (BUILD5.experimentalSlotFixes && oldVNode.$name$ !== newVNode2.$name$) {
828
- newVNode2.$elm$["s-sn"] = newVNode2.$name$ || "";
829
- relocateToHostRoot(newVNode2.$elm$.parentElement);
853
+ }
854
+ if (!plt.$orgLocNodes$) {
855
+ initializeDocumentHydrate(doc.body, plt.$orgLocNodes$ = /* @__PURE__ */ new Map());
856
+ }
857
+ hostElm[HYDRATE_ID] = hostId;
858
+ hostElm.removeAttribute(HYDRATE_ID);
859
+ hostRef.$vnode$ = clientHydrate(
860
+ vnode,
861
+ childRenderNodes,
862
+ slotNodes,
863
+ shadowRootNodes,
864
+ hostElm,
865
+ hostElm,
866
+ hostId,
867
+ slottedNodes
868
+ );
869
+ let crIndex = 0;
870
+ const crLength = childRenderNodes.length;
871
+ let childRenderNode;
872
+ for (crIndex; crIndex < crLength; crIndex++) {
873
+ childRenderNode = childRenderNodes[crIndex];
874
+ const orgLocationId = childRenderNode.$hostId$ + "." + childRenderNode.$nodeId$;
875
+ const orgLocationNode = plt.$orgLocNodes$.get(orgLocationId);
876
+ const node = childRenderNode.$elm$;
877
+ if (!shadowRoot) {
878
+ node["s-hn"] = tagName.toUpperCase();
879
+ if (childRenderNode.$tag$ === "slot") {
880
+ node["s-cr"] = hostElm["s-cr"];
881
+ }
882
+ }
883
+ if (childRenderNode.$tag$ === "slot") {
884
+ if (childRenderNode.$children$) {
885
+ childRenderNode.$flags$ |= 2 /* isSlotFallback */;
886
+ if (!childRenderNode.$elm$.childNodes.length) {
887
+ childRenderNode.$children$.forEach((c) => {
888
+ childRenderNode.$elm$.appendChild(c.$elm$);
889
+ });
830
890
  }
831
891
  } else {
832
- updateElement(oldVNode, newVNode2, isSvgMode);
892
+ childRenderNode.$flags$ |= 1 /* isSlotReference */;
833
893
  }
834
894
  }
835
- if (BUILD5.updatable && oldChildren !== null && newChildren !== null) {
836
- updateChildren(elm, oldChildren, newVNode2, newChildren, isInitialRender);
837
- } else if (newChildren !== null) {
838
- if (BUILD5.updatable && BUILD5.vdomText && oldVNode.$text$ !== null) {
839
- elm.textContent = "";
895
+ if (orgLocationNode && orgLocationNode.isConnected) {
896
+ if (shadowRoot && orgLocationNode["s-en"] === "") {
897
+ orgLocationNode.parentNode.insertBefore(node, orgLocationNode.nextSibling);
898
+ }
899
+ orgLocationNode.parentNode.removeChild(orgLocationNode);
900
+ if (!shadowRoot) {
901
+ node["s-oo"] = parseInt(childRenderNode.$nodeId$);
840
902
  }
841
- addVnodes(elm, null, newVNode2, newChildren, 0, newChildren.length - 1);
842
- } else if (
843
- // don't do this on initial render as it can cause non-hydrated content to be removed
844
- !isInitialRender && BUILD5.updatable && oldChildren !== null
845
- ) {
846
- removeVnodes(oldChildren, 0, oldChildren.length - 1);
847
- }
848
- if (BUILD5.svg && isSvgMode && tag === "svg") {
849
- isSvgMode = false;
850
903
  }
851
- } else if (BUILD5.vdomText && BUILD5.slotRelocation && (defaultHolder = elm["s-cr"])) {
852
- defaultHolder.parentNode.textContent = text;
853
- } else if (BUILD5.vdomText && oldVNode.$text$ !== text) {
854
- elm.data = text;
904
+ plt.$orgLocNodes$.delete(orgLocationId);
855
905
  }
856
- };
857
- var relocateNodes = [];
858
- var markSlotContentForRelocation = (elm) => {
859
- let node;
860
- let hostContentNodes;
861
- let j;
862
- const children = elm.__childNodes || elm.childNodes;
863
- for (const childNode of children) {
864
- if (childNode["s-sr"] && (node = childNode["s-cr"]) && node.parentNode) {
865
- hostContentNodes = node.parentNode.__childNodes || node.parentNode.childNodes;
866
- const slotName = childNode["s-sn"];
867
- for (j = hostContentNodes.length - 1; j >= 0; j--) {
868
- node = hostContentNodes[j];
869
- if (!node["s-cn"] && !node["s-nr"] && node["s-hn"] !== childNode["s-hn"] && (!BUILD5.experimentalSlotFixes || !node["s-sh"] || node["s-sh"] !== childNode["s-hn"])) {
870
- if (isNodeLocatedInSlot(node, slotName)) {
871
- let relocateNodeData = relocateNodes.find((r) => r.$nodeToRelocate$ === node);
872
- checkSlotFallbackVisibility = true;
873
- node["s-sn"] = node["s-sn"] || slotName;
874
- if (relocateNodeData) {
875
- relocateNodeData.$nodeToRelocate$["s-sh"] = childNode["s-hn"];
876
- relocateNodeData.$slotRefNode$ = childNode;
877
- } else {
878
- node["s-sh"] = childNode["s-hn"];
879
- relocateNodes.push({
880
- $slotRefNode$: childNode,
881
- $nodeToRelocate$: node
882
- });
883
- }
884
- if (node["s-sr"]) {
885
- relocateNodes.map((relocateNode) => {
886
- if (isNodeLocatedInSlot(relocateNode.$nodeToRelocate$, node["s-sn"])) {
887
- relocateNodeData = relocateNodes.find((r) => r.$nodeToRelocate$ === node);
888
- if (relocateNodeData && !relocateNode.$slotRefNode$) {
889
- relocateNode.$slotRefNode$ = relocateNodeData.$slotRefNode$;
890
- }
891
- }
892
- });
893
- }
894
- } else if (!relocateNodes.some((r) => r.$nodeToRelocate$ === node)) {
895
- relocateNodes.push({
896
- $nodeToRelocate$: node
897
- });
898
- }
906
+ const hosts = [];
907
+ const snLen = slottedNodes.length;
908
+ let snIndex = 0;
909
+ let slotGroup;
910
+ let snGroupIdx;
911
+ let snGroupLen;
912
+ let slottedItem;
913
+ for (snIndex; snIndex < snLen; snIndex++) {
914
+ slotGroup = slottedNodes[snIndex];
915
+ if (!slotGroup || !slotGroup.length) continue;
916
+ snGroupLen = slotGroup.length;
917
+ snGroupIdx = 0;
918
+ for (snGroupIdx; snGroupIdx < snGroupLen; snGroupIdx++) {
919
+ slottedItem = slotGroup[snGroupIdx];
920
+ if (!hosts[slottedItem.hostId]) {
921
+ hosts[slottedItem.hostId] = plt.$orgLocNodes$.get(slottedItem.hostId);
922
+ }
923
+ if (!hosts[slottedItem.hostId]) continue;
924
+ const hostEle = hosts[slottedItem.hostId];
925
+ if (!hostEle.shadowRoot || !shadowRoot) {
926
+ slottedItem.slot["s-cr"] = hostEle["s-cr"];
927
+ if (!slottedItem.slot["s-cr"] && hostEle.shadowRoot) {
928
+ slottedItem.slot["s-cr"] = hostEle;
929
+ } else {
930
+ slottedItem.slot["s-cr"] = (hostEle.__childNodes || hostEle.childNodes)[0];
931
+ }
932
+ addSlotRelocateNode(slottedItem.node, slottedItem.slot, false, slottedItem.node["s-oo"]);
933
+ if (BUILD5.experimentalSlotFixes) {
934
+ patchSlottedNode(slottedItem.node);
899
935
  }
900
936
  }
901
- }
902
- if (childNode.nodeType === 1 /* ElementNode */) {
903
- markSlotContentForRelocation(childNode);
937
+ if (hostEle.shadowRoot && slottedItem.node.parentElement !== hostEle) {
938
+ hostEle.appendChild(slottedItem.node);
939
+ }
904
940
  }
905
941
  }
906
- };
907
- var nullifyVNodeRefs = (vNode) => {
908
- if (BUILD5.vdomRef) {
909
- vNode.$attrs$ && vNode.$attrs$.ref && vNode.$attrs$.ref(null);
910
- vNode.$children$ && vNode.$children$.map(nullifyVNodeRefs);
942
+ if (BUILD5.scoped && scopeId2 && slotNodes.length) {
943
+ slotNodes.forEach((slot) => {
944
+ slot.$elm$.parentElement.classList.add(scopeId2 + "-s");
945
+ });
911
946
  }
912
- };
913
- var insertBefore = (parent, newNode, reference) => {
914
- if (BUILD5.scoped && typeof newNode["s-sn"] === "string" && !!newNode["s-sr"] && !!newNode["s-cr"]) {
915
- addRemoveSlotScopedClass(newNode["s-cr"], newNode, parent, newNode.parentElement);
947
+ if (BUILD5.shadowDom && shadowRoot) {
948
+ let rnIdex = 0;
949
+ const rnLen = shadowRootNodes.length;
950
+ for (rnIdex; rnIdex < rnLen; rnIdex++) {
951
+ shadowRoot.appendChild(shadowRootNodes[rnIdex]);
952
+ }
953
+ Array.from(hostElm.childNodes).forEach((node) => {
954
+ if (node.nodeType === 8 /* CommentNode */ && typeof node["s-sn"] !== "string") {
955
+ node.parentNode.removeChild(node);
956
+ }
957
+ });
916
958
  }
917
- const inserted = parent == null ? void 0 : parent.insertBefore(newNode, reference);
918
- return inserted;
959
+ hostRef.$hostElement$ = hostElm;
960
+ endHydrate();
919
961
  };
920
- function addRemoveSlotScopedClass(reference, slotNode, newParent, oldParent) {
921
- var _a;
922
- let scopeId2;
923
- if (reference && typeof slotNode["s-sn"] === "string" && !!slotNode["s-sr"] && reference.parentNode && reference.parentNode["s-sc"] && (scopeId2 = slotNode["s-si"] || reference.parentNode["s-sc"])) {
924
- const scopeName = slotNode["s-sn"];
925
- const hostName = slotNode["s-hn"];
926
- (_a = newParent.classList) == null ? void 0 : _a.add(scopeId2 + "-s");
927
- if (oldParent && oldParent.classList.contains(scopeId2 + "-s")) {
928
- let child = (oldParent.__childNodes || oldParent.childNodes)[0];
929
- let found = false;
930
- while (child) {
931
- if (child["s-sn"] !== scopeName && child["s-hn"] === hostName && !!child["s-sr"]) {
932
- found = true;
933
- break;
962
+ var clientHydrate = (parentVNode, childRenderNodes, slotNodes, shadowRootNodes, hostElm, node, hostId, slottedNodes = []) => {
963
+ let childNodeType;
964
+ let childIdSplt;
965
+ let childVNode;
966
+ let i2;
967
+ const scopeId2 = hostElm["s-sc"];
968
+ if (node.nodeType === 1 /* ElementNode */) {
969
+ childNodeType = node.getAttribute(HYDRATE_CHILD_ID);
970
+ if (childNodeType) {
971
+ childIdSplt = childNodeType.split(".");
972
+ if (childIdSplt[0] === hostId || childIdSplt[0] === "0") {
973
+ childVNode = createSimpleVNode({
974
+ $flags$: 0,
975
+ $hostId$: childIdSplt[0],
976
+ $nodeId$: childIdSplt[1],
977
+ $depth$: childIdSplt[2],
978
+ $index$: childIdSplt[3],
979
+ $tag$: node.tagName.toLowerCase(),
980
+ $elm$: node,
981
+ // If we don't add the initial classes to the VNode, the first `vdom-render.ts` patch
982
+ // won't try to reconcile them. Classes set on the node will be blown away.
983
+ $attrs$: { class: node.className || "" }
984
+ });
985
+ childRenderNodes.push(childVNode);
986
+ node.removeAttribute(HYDRATE_CHILD_ID);
987
+ if (!parentVNode.$children$) {
988
+ parentVNode.$children$ = [];
989
+ }
990
+ if (BUILD5.scoped && scopeId2) {
991
+ node["s-si"] = scopeId2;
992
+ childVNode.$attrs$.class += " " + scopeId2;
993
+ }
994
+ const slotName = childVNode.$elm$.getAttribute("s-sn");
995
+ if (typeof slotName === "string") {
996
+ if (childVNode.$tag$ === "slot-fb") {
997
+ addSlot(
998
+ slotName,
999
+ childIdSplt[2],
1000
+ childVNode,
1001
+ node,
1002
+ parentVNode,
1003
+ childRenderNodes,
1004
+ slotNodes,
1005
+ shadowRootNodes,
1006
+ slottedNodes
1007
+ );
1008
+ if (BUILD5.scoped && scopeId2) {
1009
+ node.classList.add(scopeId2);
1010
+ }
1011
+ }
1012
+ childVNode.$elm$["s-sn"] = slotName;
1013
+ childVNode.$elm$.removeAttribute("s-sn");
1014
+ }
1015
+ if (childVNode.$index$ !== void 0) {
1016
+ parentVNode.$children$[childVNode.$index$] = childVNode;
1017
+ }
1018
+ parentVNode = childVNode;
1019
+ if (shadowRootNodes && childVNode.$depth$ === "0") {
1020
+ shadowRootNodes[childVNode.$index$] = childVNode.$elm$;
934
1021
  }
935
- child = child.nextSibling;
936
1022
  }
937
- if (!found) oldParent.classList.remove(scopeId2 + "-s");
938
1023
  }
939
- }
940
- }
941
- var renderVdom = (hostRef, renderFnResults, isInitialLoad = false) => {
942
- var _a, _b, _c, _d, _e;
943
- const hostElm = hostRef.$hostElement$;
944
- const cmpMeta = hostRef.$cmpMeta$;
945
- const oldVNode = hostRef.$vnode$ || newVNode(null, null);
946
- const rootVnode = isHost(renderFnResults) ? renderFnResults : h(null, null, renderFnResults);
947
- hostTagName = hostElm.tagName;
948
- if (BUILD5.isDev && Array.isArray(renderFnResults) && renderFnResults.some(isHost)) {
949
- throw new Error(`The <Host> must be the single root component.
950
- Looks like the render() function of "${hostTagName.toLowerCase()}" is returning an array that contains the <Host>.
951
-
952
- The render() function should look like this instead:
953
-
954
- render() {
955
- // Do not return an array
956
- return (
957
- <Host>{content}</Host>
958
- );
959
- }
960
- `);
961
- }
962
- if (BUILD5.reflect && cmpMeta.$attrsToReflect$) {
963
- rootVnode.$attrs$ = rootVnode.$attrs$ || {};
964
- cmpMeta.$attrsToReflect$.map(
965
- ([propName, attribute]) => rootVnode.$attrs$[attribute] = hostElm[propName]
966
- );
967
- }
968
- if (isInitialLoad && rootVnode.$attrs$) {
969
- for (const key of Object.keys(rootVnode.$attrs$)) {
970
- if (hostElm.hasAttribute(key) && !["key", "ref", "style", "class"].includes(key)) {
971
- rootVnode.$attrs$[key] = hostElm[key];
1024
+ if (node.shadowRoot) {
1025
+ for (i2 = node.shadowRoot.childNodes.length - 1; i2 >= 0; i2--) {
1026
+ clientHydrate(
1027
+ parentVNode,
1028
+ childRenderNodes,
1029
+ slotNodes,
1030
+ shadowRootNodes,
1031
+ hostElm,
1032
+ node.shadowRoot.childNodes[i2],
1033
+ hostId,
1034
+ slottedNodes
1035
+ );
972
1036
  }
973
1037
  }
974
- }
975
- rootVnode.$tag$ = null;
976
- rootVnode.$flags$ |= 4 /* isHost */;
977
- hostRef.$vnode$ = rootVnode;
978
- rootVnode.$elm$ = oldVNode.$elm$ = BUILD5.shadowDom ? hostElm.shadowRoot || hostElm : hostElm;
979
- if (BUILD5.scoped || BUILD5.shadowDom) {
980
- scopeId = hostElm["s-sc"];
981
- }
982
- useNativeShadowDom = supportsShadow && (cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) !== 0;
983
- if (BUILD5.slotRelocation) {
984
- contentRef = hostElm["s-cr"];
985
- checkSlotFallbackVisibility = false;
986
- }
987
- patch(oldVNode, rootVnode, isInitialLoad);
988
- if (BUILD5.slotRelocation) {
989
- plt.$flags$ |= 1 /* isTmpDisconnected */;
990
- if (checkSlotRelocate) {
991
- markSlotContentForRelocation(rootVnode.$elm$);
992
- for (const relocateData of relocateNodes) {
993
- const nodeToRelocate = relocateData.$nodeToRelocate$;
994
- if (!nodeToRelocate["s-ol"]) {
995
- const orgLocationNode = BUILD5.isDebug || BUILD5.hydrateServerSide ? originalLocationDebugNode(nodeToRelocate) : doc.createTextNode("");
996
- orgLocationNode["s-nr"] = nodeToRelocate;
997
- insertBefore(nodeToRelocate.parentNode, nodeToRelocate["s-ol"] = orgLocationNode, nodeToRelocate);
998
- }
999
- }
1000
- for (const relocateData of relocateNodes) {
1001
- const nodeToRelocate = relocateData.$nodeToRelocate$;
1002
- const slotRefNode = relocateData.$slotRefNode$;
1003
- if (slotRefNode) {
1004
- const parentNodeRef = slotRefNode.parentNode;
1005
- let insertBeforeNode = slotRefNode.nextSibling;
1006
- if (!BUILD5.hydrateServerSide && (!BUILD5.experimentalSlotFixes || insertBeforeNode && insertBeforeNode.nodeType === 1 /* ElementNode */)) {
1007
- let orgLocationNode = (_a = nodeToRelocate["s-ol"]) == null ? void 0 : _a.previousSibling;
1008
- while (orgLocationNode) {
1009
- let refNode = (_b = orgLocationNode["s-nr"]) != null ? _b : null;
1010
- if (refNode && refNode["s-sn"] === nodeToRelocate["s-sn"] && parentNodeRef === refNode.parentNode) {
1011
- refNode = refNode.nextSibling;
1012
- while (refNode === nodeToRelocate || (refNode == null ? void 0 : refNode["s-sr"])) {
1013
- refNode = refNode == null ? void 0 : refNode.nextSibling;
1014
- }
1015
- if (!refNode || !refNode["s-nr"]) {
1016
- insertBeforeNode = refNode;
1017
- break;
1018
- }
1019
- }
1020
- orgLocationNode = orgLocationNode.previousSibling;
1038
+ const nonShadowNodes = node.__childNodes || node.childNodes;
1039
+ for (i2 = nonShadowNodes.length - 1; i2 >= 0; i2--) {
1040
+ clientHydrate(
1041
+ parentVNode,
1042
+ childRenderNodes,
1043
+ slotNodes,
1044
+ shadowRootNodes,
1045
+ hostElm,
1046
+ nonShadowNodes[i2],
1047
+ hostId,
1048
+ slottedNodes
1049
+ );
1050
+ }
1051
+ } else if (node.nodeType === 8 /* CommentNode */) {
1052
+ childIdSplt = node.nodeValue.split(".");
1053
+ if (childIdSplt[1] === hostId || childIdSplt[1] === "0") {
1054
+ childNodeType = childIdSplt[0];
1055
+ childVNode = createSimpleVNode({
1056
+ $hostId$: childIdSplt[1],
1057
+ $nodeId$: childIdSplt[2],
1058
+ $depth$: childIdSplt[3],
1059
+ $index$: childIdSplt[4] || "0",
1060
+ $elm$: node,
1061
+ $attrs$: null,
1062
+ $children$: null,
1063
+ $key$: null,
1064
+ $name$: null,
1065
+ $tag$: null,
1066
+ $text$: null
1067
+ });
1068
+ if (childNodeType === TEXT_NODE_ID) {
1069
+ childVNode.$elm$ = node.nextSibling;
1070
+ if (childVNode.$elm$ && childVNode.$elm$.nodeType === 3 /* TextNode */) {
1071
+ childVNode.$text$ = childVNode.$elm$.textContent;
1072
+ childRenderNodes.push(childVNode);
1073
+ node.remove();
1074
+ if (hostId === childVNode.$hostId$) {
1075
+ if (!parentVNode.$children$) {
1076
+ parentVNode.$children$ = [];
1021
1077
  }
1078
+ parentVNode.$children$[childVNode.$index$] = childVNode;
1022
1079
  }
1023
- if (!insertBeforeNode && parentNodeRef !== nodeToRelocate.parentNode || nodeToRelocate.nextSibling !== insertBeforeNode) {
1024
- if (nodeToRelocate !== insertBeforeNode) {
1025
- if (!BUILD5.experimentalSlotFixes && !nodeToRelocate["s-hn"] && nodeToRelocate["s-ol"]) {
1026
- nodeToRelocate["s-hn"] = nodeToRelocate["s-ol"].parentNode.nodeName;
1027
- }
1028
- insertBefore(parentNodeRef, nodeToRelocate, insertBeforeNode);
1029
- if (nodeToRelocate.nodeType === 1 /* ElementNode */ && nodeToRelocate.tagName !== "SLOT-FB") {
1030
- nodeToRelocate.hidden = (_c = nodeToRelocate["s-ih"]) != null ? _c : false;
1031
- }
1032
- }
1080
+ if (shadowRootNodes && childVNode.$depth$ === "0") {
1081
+ shadowRootNodes[childVNode.$index$] = childVNode.$elm$;
1033
1082
  }
1034
- nodeToRelocate && typeof slotRefNode["s-rf"] === "function" && slotRefNode["s-rf"](nodeToRelocate);
1035
- } else {
1036
- if (nodeToRelocate.nodeType === 1 /* ElementNode */) {
1037
- if (isInitialLoad) {
1038
- nodeToRelocate["s-ih"] = (_d = nodeToRelocate.hidden) != null ? _d : false;
1039
- }
1040
- nodeToRelocate.hidden = true;
1083
+ }
1084
+ } else if (childNodeType === COMMENT_NODE_ID) {
1085
+ childVNode.$elm$ = node.nextSibling;
1086
+ if (childVNode.$elm$ && childVNode.$elm$.nodeType === 8 /* CommentNode */) {
1087
+ childRenderNodes.push(childVNode);
1088
+ node.remove();
1089
+ }
1090
+ } else if (childVNode.$hostId$ === hostId) {
1091
+ if (childNodeType === SLOT_NODE_ID) {
1092
+ const slotName = node["s-sn"] = childIdSplt[5] || "";
1093
+ addSlot(
1094
+ slotName,
1095
+ childIdSplt[2],
1096
+ childVNode,
1097
+ node,
1098
+ parentVNode,
1099
+ childRenderNodes,
1100
+ slotNodes,
1101
+ shadowRootNodes,
1102
+ slottedNodes
1103
+ );
1104
+ } else if (childNodeType === CONTENT_REF_ID) {
1105
+ if (BUILD5.shadowDom && shadowRootNodes) {
1106
+ node.remove();
1107
+ } else if (BUILD5.slotRelocation) {
1108
+ hostElm["s-cr"] = node;
1109
+ node["s-cn"] = true;
1041
1110
  }
1042
1111
  }
1043
1112
  }
1044
1113
  }
1045
- if (checkSlotFallbackVisibility) {
1046
- updateFallbackSlotVisibility(rootVnode.$elm$);
1047
- }
1048
- plt.$flags$ &= ~1 /* isTmpDisconnected */;
1049
- relocateNodes.length = 0;
1114
+ } else if (parentVNode && parentVNode.$tag$ === "style") {
1115
+ const vnode = newVNode(null, node.textContent);
1116
+ vnode.$elm$ = node;
1117
+ vnode.$index$ = "0";
1118
+ parentVNode.$children$ = [vnode];
1050
1119
  }
1051
- if (BUILD5.experimentalScopedSlotChanges && cmpMeta.$flags$ & 2 /* scopedCssEncapsulation */) {
1052
- const children = rootVnode.$elm$.__childNodes || rootVnode.$elm$.childNodes;
1053
- for (const childNode of children) {
1054
- if (childNode["s-hn"] !== hostTagName && !childNode["s-sh"]) {
1055
- if (isInitialLoad && childNode["s-ih"] == null) {
1056
- childNode["s-ih"] = (_e = childNode.hidden) != null ? _e : false;
1057
- }
1058
- childNode.hidden = true;
1120
+ return parentVNode;
1121
+ };
1122
+ var initializeDocumentHydrate = (node, orgLocNodes) => {
1123
+ if (node.nodeType === 1 /* ElementNode */) {
1124
+ const componentId = node[HYDRATE_ID] || node.getAttribute(HYDRATE_ID);
1125
+ if (componentId) {
1126
+ orgLocNodes.set(componentId, node);
1127
+ }
1128
+ let i2 = 0;
1129
+ if (node.shadowRoot) {
1130
+ for (; i2 < node.shadowRoot.childNodes.length; i2++) {
1131
+ initializeDocumentHydrate(node.shadowRoot.childNodes[i2], orgLocNodes);
1059
1132
  }
1060
1133
  }
1134
+ const nonShadowNodes = node.__childNodes || node.childNodes;
1135
+ for (i2 = 0; i2 < nonShadowNodes.length; i2++) {
1136
+ initializeDocumentHydrate(nonShadowNodes[i2], orgLocNodes);
1137
+ }
1138
+ } else if (node.nodeType === 8 /* CommentNode */) {
1139
+ const childIdSplt = node.nodeValue.split(".");
1140
+ if (childIdSplt[0] === ORG_LOCATION_ID) {
1141
+ orgLocNodes.set(childIdSplt[1] + "." + childIdSplt[2], node);
1142
+ node.nodeValue = "";
1143
+ node["s-en"] = childIdSplt[3];
1144
+ }
1061
1145
  }
1062
- contentRef = void 0;
1063
- };
1064
- var slotReferenceDebugNode = (slotVNode) => doc.createComment(
1065
- `<slot${slotVNode.$name$ ? ' name="' + slotVNode.$name$ + '"' : ""}> (host=${hostTagName.toLowerCase()})`
1066
- );
1067
- var originalLocationDebugNode = (nodeToRelocate) => doc.createComment(
1068
- `org-location for ` + (nodeToRelocate.localName ? `<${nodeToRelocate.localName}> (host=${nodeToRelocate["s-hn"]})` : `[${nodeToRelocate.textContent}]`)
1069
- );
1070
-
1071
- // src/runtime/dom-extras.ts
1072
- var patchPseudoShadowDom = (hostElementPrototype) => {
1073
- patchCloneNode(hostElementPrototype);
1074
- patchSlotAppendChild(hostElementPrototype);
1075
- patchSlotAppend(hostElementPrototype);
1076
- patchSlotPrepend(hostElementPrototype);
1077
- patchSlotInsertAdjacentElement(hostElementPrototype);
1078
- patchSlotInsertAdjacentHTML(hostElementPrototype);
1079
- patchSlotInsertAdjacentText(hostElementPrototype);
1080
- patchTextContent(hostElementPrototype);
1081
- patchChildSlotNodes(hostElementPrototype);
1082
- patchSlotRemoveChild(hostElementPrototype);
1083
1146
  };
1084
- var patchCloneNode = (HostElementPrototype) => {
1085
- const orgCloneNode = HostElementPrototype.cloneNode;
1086
- HostElementPrototype.cloneNode = function(deep) {
1087
- const srcNode = this;
1088
- const isShadowDom = BUILD6.shadowDom ? srcNode.shadowRoot && supportsShadow : false;
1089
- const clonedNode = orgCloneNode.call(srcNode, isShadowDom ? deep : false);
1090
- if (BUILD6.slot && !isShadowDom && deep) {
1091
- let i2 = 0;
1092
- let slotted, nonStencilNode;
1093
- const stencilPrivates = [
1094
- "s-id",
1095
- "s-cr",
1096
- "s-lr",
1097
- "s-rc",
1098
- "s-sc",
1099
- "s-p",
1100
- "s-cn",
1101
- "s-sr",
1102
- "s-sn",
1103
- "s-hn",
1104
- "s-ol",
1105
- "s-nr",
1106
- "s-si",
1107
- "s-rf",
1108
- "s-scs"
1109
- ];
1110
- const childNodes = this.__childNodes || this.childNodes;
1111
- for (; i2 < childNodes.length; i2++) {
1112
- slotted = childNodes[i2]["s-nr"];
1113
- nonStencilNode = stencilPrivates.every((privateField) => !childNodes[i2][privateField]);
1114
- if (slotted) {
1115
- if (BUILD6.appendChildSlotFix && clonedNode.__appendChild) {
1116
- clonedNode.__appendChild(slotted.cloneNode(true));
1117
- } else {
1118
- clonedNode.appendChild(slotted.cloneNode(true));
1119
- }
1120
- }
1121
- if (nonStencilNode) {
1122
- clonedNode.appendChild(childNodes[i2].cloneNode(true));
1123
- }
1124
- }
1125
- }
1126
- return clonedNode;
1147
+ var createSimpleVNode = (vnode) => {
1148
+ const defaultVNode = {
1149
+ $flags$: 0,
1150
+ $hostId$: null,
1151
+ $nodeId$: null,
1152
+ $depth$: null,
1153
+ $index$: "0",
1154
+ $elm$: null,
1155
+ $attrs$: null,
1156
+ $children$: null,
1157
+ $key$: null,
1158
+ $name$: null,
1159
+ $tag$: null,
1160
+ $text$: null
1127
1161
  };
1162
+ return { ...defaultVNode, ...vnode };
1128
1163
  };
1129
- var patchSlotAppendChild = (HostElementPrototype) => {
1130
- HostElementPrototype.__appendChild = HostElementPrototype.appendChild;
1131
- HostElementPrototype.appendChild = function(newChild) {
1132
- const slotName = newChild["s-sn"] = getSlotName(newChild);
1133
- const slotNode = getHostSlotNodes(this.__childNodes || this.childNodes, this.tagName, slotName)[0];
1134
- if (slotNode) {
1135
- addSlotRelocateNode(newChild, slotNode);
1136
- const slotChildNodes = getHostSlotChildNodes(slotNode, slotName);
1137
- const appendAfter = slotChildNodes[slotChildNodes.length - 1];
1138
- const insertedNode = insertBefore(appendAfter.parentNode, newChild, appendAfter.nextSibling);
1139
- updateFallbackSlotVisibility(this);
1140
- return insertedNode;
1164
+ function addSlot(slotName, slotId, childVNode, node, parentVNode, childRenderNodes, slotNodes, shadowRootNodes, slottedNodes) {
1165
+ node["s-sr"] = true;
1166
+ childVNode.$name$ = slotName || null;
1167
+ childVNode.$tag$ = "slot";
1168
+ const parentNodeId = (parentVNode == null ? void 0 : parentVNode.$elm$) ? parentVNode.$elm$["s-id"] || parentVNode.$elm$.getAttribute("s-id") : "";
1169
+ if (BUILD5.shadowDom && shadowRootNodes) {
1170
+ const slot = childVNode.$elm$ = doc.createElement(childVNode.$tag$);
1171
+ if (childVNode.$name$) {
1172
+ childVNode.$elm$.setAttribute("name", slotName);
1141
1173
  }
1142
- return this.__appendChild(newChild);
1143
- };
1144
- };
1145
- var patchSlotRemoveChild = (ElementPrototype) => {
1146
- ElementPrototype.__removeChild = ElementPrototype.removeChild;
1147
- ElementPrototype.removeChild = function(toRemove) {
1148
- if (toRemove && typeof toRemove["s-sn"] !== "undefined") {
1149
- const childNodes = this.__childNodes || this.childNodes;
1150
- const slotNode = getHostSlotNodes(childNodes, this.tagName, toRemove["s-sn"]);
1151
- if (slotNode && toRemove.isConnected) {
1152
- toRemove.remove();
1153
- updateFallbackSlotVisibility(this);
1154
- return;
1155
- }
1174
+ if (parentNodeId && parentNodeId !== childVNode.$hostId$) {
1175
+ parentVNode.$elm$.insertBefore(slot, parentVNode.$elm$.children[0]);
1176
+ } else {
1177
+ node.parentNode.insertBefore(childVNode.$elm$, node);
1156
1178
  }
1157
- return this.__removeChild(toRemove);
1158
- };
1159
- };
1160
- var patchSlotPrepend = (HostElementPrototype) => {
1161
- HostElementPrototype.__prepend = HostElementPrototype.prepend;
1162
- HostElementPrototype.prepend = function(...newChildren) {
1163
- newChildren.forEach((newChild) => {
1164
- if (typeof newChild === "string") {
1165
- newChild = this.ownerDocument.createTextNode(newChild);
1166
- }
1167
- const slotName = newChild["s-sn"] = getSlotName(newChild);
1168
- const childNodes = this.__childNodes || this.childNodes;
1169
- const slotNode = getHostSlotNodes(childNodes, this.tagName, slotName)[0];
1170
- if (slotNode) {
1171
- addSlotRelocateNode(newChild, slotNode, true);
1172
- const slotChildNodes = getHostSlotChildNodes(slotNode, slotName);
1173
- const appendAfter = slotChildNodes[0];
1174
- return insertBefore(appendAfter.parentNode, newChild, appendAfter.nextSibling);
1175
- }
1176
- if (newChild.nodeType === 1 && !!newChild.getAttribute("slot")) {
1177
- newChild.hidden = true;
1178
- }
1179
- return HostElementPrototype.__prepend(newChild);
1180
- });
1181
- };
1182
- };
1183
- var patchSlotAppend = (HostElementPrototype) => {
1184
- HostElementPrototype.__append = HostElementPrototype.append;
1185
- HostElementPrototype.append = function(...newChildren) {
1186
- newChildren.forEach((newChild) => {
1187
- if (typeof newChild === "string") {
1188
- newChild = this.ownerDocument.createTextNode(newChild);
1189
- }
1190
- this.appendChild(newChild);
1191
- });
1192
- };
1193
- };
1194
- var patchSlotInsertAdjacentHTML = (HostElementPrototype) => {
1195
- const originalInsertAdjacentHtml = HostElementPrototype.insertAdjacentHTML;
1196
- HostElementPrototype.insertAdjacentHTML = function(position, text) {
1197
- if (position !== "afterbegin" && position !== "beforeend") {
1198
- return originalInsertAdjacentHtml.call(this, position, text);
1179
+ addSlottedNodes(slottedNodes, slotId, slotName, node, childVNode.$hostId$);
1180
+ node.remove();
1181
+ if (childVNode.$depth$ === "0") {
1182
+ shadowRootNodes[childVNode.$index$] = childVNode.$elm$;
1199
1183
  }
1200
- const container = this.ownerDocument.createElement("_");
1201
- let node;
1202
- container.innerHTML = text;
1203
- if (position === "afterbegin") {
1204
- while (node = container.firstChild) {
1205
- this.prepend(node);
1206
- }
1207
- } else if (position === "beforeend") {
1208
- while (node = container.firstChild) {
1209
- this.append(node);
1210
- }
1184
+ } else {
1185
+ const slot = childVNode.$elm$;
1186
+ const shouldMove = parentNodeId && parentNodeId !== childVNode.$hostId$ && parentVNode.$elm$.shadowRoot;
1187
+ addSlottedNodes(slottedNodes, slotId, slotName, node, shouldMove ? parentNodeId : childVNode.$hostId$);
1188
+ if (shouldMove) {
1189
+ parentVNode.$elm$.insertBefore(slot, parentVNode.$elm$.children[0]);
1211
1190
  }
1212
- };
1213
- };
1214
- var patchSlotInsertAdjacentText = (HostElementPrototype) => {
1215
- HostElementPrototype.insertAdjacentText = function(position, text) {
1216
- this.insertAdjacentHTML(position, text);
1217
- };
1191
+ childRenderNodes.push(childVNode);
1192
+ }
1193
+ slotNodes.push(childVNode);
1194
+ if (!parentVNode.$children$) {
1195
+ parentVNode.$children$ = [];
1196
+ }
1197
+ parentVNode.$children$[childVNode.$index$] = childVNode;
1198
+ }
1199
+ var addSlottedNodes = (slottedNodes, slotNodeId, slotName, slotNode, hostId) => {
1200
+ let slottedNode = slotNode.nextSibling;
1201
+ slottedNodes[slotNodeId] = slottedNodes[slotNodeId] || [];
1202
+ while (slottedNode && ((slottedNode["getAttribute"] && slottedNode.getAttribute("slot") || slottedNode["s-sn"]) === slotName || slotName === "" && !slottedNode["s-sn"] && (slottedNode.nodeType === 8 /* CommentNode */ && slottedNode.nodeValue.indexOf(".") !== 1 || slottedNode.nodeType === 3 /* TextNode */))) {
1203
+ slottedNode["s-sn"] = slotName;
1204
+ slottedNodes[slotNodeId].push({ slot: slotNode, node: slottedNode, hostId });
1205
+ slottedNode = slottedNode.nextSibling;
1206
+ }
1218
1207
  };
1219
- var patchSlotInsertAdjacentElement = (HostElementPrototype) => {
1220
- const originalInsertAdjacentElement = HostElementPrototype.insertAdjacentElement;
1221
- HostElementPrototype.insertAdjacentElement = function(position, element) {
1222
- if (position !== "afterbegin" && position !== "beforeend") {
1223
- return originalInsertAdjacentElement.call(this, position, element);
1208
+
1209
+ // src/runtime/initialize-component.ts
1210
+ import { BUILD as BUILD16 } from "@stencil/core/internal/app-data";
1211
+
1212
+ // src/runtime/mode.ts
1213
+ var computeMode = (elm) => modeResolutionChain.map((h2) => h2(elm)).find((m) => !!m);
1214
+ var setMode = (handler) => modeResolutionChain.push(handler);
1215
+ var getMode = (ref) => getHostRef(ref).$modeName$;
1216
+
1217
+ // src/runtime/proxy-component.ts
1218
+ import { BUILD as BUILD15 } from "@stencil/core/internal/app-data";
1219
+
1220
+ // src/runtime/set-value.ts
1221
+ import { BUILD as BUILD14 } from "@stencil/core/internal/app-data";
1222
+
1223
+ // src/runtime/parse-property-value.ts
1224
+ import { BUILD as BUILD6 } from "@stencil/core/internal/app-data";
1225
+ var parsePropertyValue = (propValue, propType) => {
1226
+ if (propValue != null && !isComplexType(propValue)) {
1227
+ if (BUILD6.propBoolean && propType & 4 /* Boolean */) {
1228
+ return propValue === "false" ? false : propValue === "" || !!propValue;
1224
1229
  }
1225
- if (position === "afterbegin") {
1226
- this.prepend(element);
1227
- return element;
1228
- } else if (position === "beforeend") {
1229
- this.append(element);
1230
- return element;
1230
+ if (BUILD6.propNumber && propType & 2 /* Number */) {
1231
+ return parseFloat(propValue);
1231
1232
  }
1232
- return element;
1233
- };
1233
+ if (BUILD6.propString && propType & 1 /* String */) {
1234
+ return String(propValue);
1235
+ }
1236
+ return propValue;
1237
+ }
1238
+ return propValue;
1234
1239
  };
1235
- var patchTextContent = (hostElementPrototype) => {
1236
- patchHostOriginalAccessor("textContent", hostElementPrototype);
1237
- Object.defineProperty(hostElementPrototype, "textContent", {
1238
- get: function() {
1239
- let text = "";
1240
- const childNodes = this.__childNodes ? this.childNodes : getSlottedChildNodes(this.childNodes);
1241
- childNodes.forEach((node) => text += node.textContent || "");
1242
- return text;
1243
- },
1244
- set: function(value) {
1245
- const childNodes = this.__childNodes ? this.childNodes : getSlottedChildNodes(this.childNodes);
1246
- childNodes.forEach((node) => {
1247
- if (node["s-ol"]) node["s-ol"].remove();
1248
- node.remove();
1240
+
1241
+ // src/runtime/update-component.ts
1242
+ import { BUILD as BUILD13, NAMESPACE } from "@stencil/core/internal/app-data";
1243
+
1244
+ // src/runtime/event-emitter.ts
1245
+ import { BUILD as BUILD8 } from "@stencil/core/internal/app-data";
1246
+
1247
+ // src/runtime/element.ts
1248
+ import { BUILD as BUILD7 } from "@stencil/core/internal/app-data";
1249
+ var getElement = (ref) => BUILD7.lazyLoad ? getHostRef(ref).$hostElement$ : ref;
1250
+
1251
+ // src/runtime/event-emitter.ts
1252
+ var createEvent = (ref, name, flags) => {
1253
+ const elm = getElement(ref);
1254
+ return {
1255
+ emit: (detail) => {
1256
+ if (BUILD8.isDev && !elm.isConnected) {
1257
+ consoleDevWarn(`The "${name}" event was emitted, but the dispatcher node is no longer connected to the dom.`);
1258
+ }
1259
+ return emitEvent(elm, name, {
1260
+ bubbles: !!(flags & 4 /* Bubbles */),
1261
+ composed: !!(flags & 2 /* Composed */),
1262
+ cancelable: !!(flags & 1 /* Cancellable */),
1263
+ detail
1249
1264
  });
1250
- this.insertAdjacentHTML("beforeend", value);
1251
1265
  }
1252
- });
1266
+ };
1253
1267
  };
1254
- var patchChildSlotNodes = (elm) => {
1255
- class FakeNodeList extends Array {
1256
- item(n) {
1257
- return this[n];
1268
+ var emitEvent = (elm, name, opts) => {
1269
+ const ev = plt.ce(name, opts);
1270
+ elm.dispatchEvent(ev);
1271
+ return ev;
1272
+ };
1273
+
1274
+ // src/runtime/styles.ts
1275
+ import { BUILD as BUILD9 } from "@stencil/core/internal/app-data";
1276
+ var rootAppliedStyles = /* @__PURE__ */ new WeakMap();
1277
+ var registerStyle = (scopeId2, cssText, allowCS) => {
1278
+ let style = styles.get(scopeId2);
1279
+ if (supportsConstructableStylesheets && allowCS) {
1280
+ style = style || new CSSStyleSheet();
1281
+ if (typeof style === "string") {
1282
+ style = cssText;
1283
+ } else {
1284
+ style.replaceSync(cssText);
1258
1285
  }
1286
+ } else {
1287
+ style = cssText;
1259
1288
  }
1260
- patchHostOriginalAccessor("children", elm);
1261
- Object.defineProperty(elm, "children", {
1262
- get() {
1263
- return this.childNodes.filter((n) => n.nodeType === 1);
1264
- }
1265
- });
1266
- Object.defineProperty(elm, "childElementCount", {
1267
- get() {
1268
- return this.children.length;
1269
- }
1270
- });
1271
- patchHostOriginalAccessor("firstChild", elm);
1272
- Object.defineProperty(elm, "firstChild", {
1273
- get() {
1274
- return this.childNodes[0];
1275
- }
1276
- });
1277
- patchHostOriginalAccessor("lastChild", elm);
1278
- Object.defineProperty(elm, "lastChild", {
1279
- get() {
1280
- return this.childNodes[this.childNodes.length - 1];
1281
- }
1282
- });
1283
- patchHostOriginalAccessor("childNodes", elm);
1284
- Object.defineProperty(elm, "childNodes", {
1285
- get() {
1286
- var _a, _b;
1287
- if (!plt.$flags$ || !((_a = getHostRef(this)) == null ? void 0 : _a.$flags$) || (plt.$flags$ & 1 /* isTmpDisconnected */) === 0 && ((_b = getHostRef(this)) == null ? void 0 : _b.$flags$) & 2 /* hasRendered */) {
1288
- const result = new FakeNodeList();
1289
- const nodes = getSlottedChildNodes(this.__childNodes);
1290
- result.push(...nodes);
1291
- return result;
1289
+ styles.set(scopeId2, style);
1290
+ };
1291
+ var addStyle = (styleContainerNode, cmpMeta, mode) => {
1292
+ var _a;
1293
+ const scopeId2 = getScopeId(cmpMeta, mode);
1294
+ const style = styles.get(scopeId2);
1295
+ if (!BUILD9.attachStyles) {
1296
+ return scopeId2;
1297
+ }
1298
+ styleContainerNode = styleContainerNode.nodeType === 11 /* DocumentFragment */ ? styleContainerNode : doc;
1299
+ if (style) {
1300
+ if (typeof style === "string") {
1301
+ styleContainerNode = styleContainerNode.head || styleContainerNode;
1302
+ let appliedStyles = rootAppliedStyles.get(styleContainerNode);
1303
+ let styleElm;
1304
+ if (!appliedStyles) {
1305
+ rootAppliedStyles.set(styleContainerNode, appliedStyles = /* @__PURE__ */ new Set());
1292
1306
  }
1293
- return FakeNodeList.from(this.__childNodes);
1307
+ if (!appliedStyles.has(scopeId2)) {
1308
+ if (BUILD9.hydrateClientSide && styleContainerNode.host && (styleElm = styleContainerNode.querySelector(`[${HYDRATED_STYLE_ID}="${scopeId2}"]`))) {
1309
+ styleElm.innerHTML = style;
1310
+ } else {
1311
+ styleElm = document.querySelector(`[${HYDRATED_STYLE_ID}="${scopeId2}"]`) || doc.createElement("style");
1312
+ styleElm.innerHTML = style;
1313
+ const nonce = (_a = plt.$nonce$) != null ? _a : queryNonceMetaTagContent(doc);
1314
+ if (nonce != null) {
1315
+ styleElm.setAttribute("nonce", nonce);
1316
+ }
1317
+ if ((BUILD9.hydrateServerSide || BUILD9.hotModuleReplacement) && cmpMeta.$flags$ & 2 /* scopedCssEncapsulation */) {
1318
+ styleElm.setAttribute(HYDRATED_STYLE_ID, scopeId2);
1319
+ }
1320
+ if (!(cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */)) {
1321
+ if (styleContainerNode.nodeName === "HEAD") {
1322
+ const preconnectLinks = styleContainerNode.querySelectorAll("link[rel=preconnect]");
1323
+ const referenceNode2 = preconnectLinks.length > 0 ? preconnectLinks[preconnectLinks.length - 1].nextSibling : styleContainerNode.querySelector("style");
1324
+ styleContainerNode.insertBefore(styleElm, referenceNode2);
1325
+ } else if ("host" in styleContainerNode) {
1326
+ if (supportsConstructableStylesheets) {
1327
+ const stylesheet = new CSSStyleSheet();
1328
+ stylesheet.replaceSync(style);
1329
+ styleContainerNode.adoptedStyleSheets = [stylesheet, ...styleContainerNode.adoptedStyleSheets];
1330
+ } else {
1331
+ const existingStyleContainer = styleContainerNode.querySelector("style");
1332
+ if (existingStyleContainer) {
1333
+ existingStyleContainer.innerHTML = style + existingStyleContainer.innerHTML;
1334
+ } else {
1335
+ styleContainerNode.prepend(styleElm);
1336
+ }
1337
+ }
1338
+ } else {
1339
+ styleContainerNode.append(styleElm);
1340
+ }
1341
+ }
1342
+ if (cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */ && styleContainerNode.nodeName !== "HEAD") {
1343
+ styleContainerNode.insertBefore(styleElm, null);
1344
+ }
1345
+ }
1346
+ if (cmpMeta.$flags$ & 4 /* hasSlotRelocation */) {
1347
+ styleElm.innerHTML += SLOT_FB_CSS;
1348
+ }
1349
+ if (appliedStyles) {
1350
+ appliedStyles.add(scopeId2);
1351
+ }
1352
+ }
1353
+ } else if (BUILD9.constructableCSS && !styleContainerNode.adoptedStyleSheets.includes(style)) {
1354
+ styleContainerNode.adoptedStyleSheets = [...styleContainerNode.adoptedStyleSheets, style];
1294
1355
  }
1295
- });
1356
+ }
1357
+ return scopeId2;
1296
1358
  };
1297
- var patchNextPrev = (node) => {
1298
- if (!node || node.__nextSibling || !globalThis.Node) return;
1299
- patchNextSibling(node);
1300
- patchPreviousSibling(node);
1301
- if (node.nodeType === Node.ELEMENT_NODE) {
1302
- patchNextElementSibling(node);
1303
- patchPreviousElementSibling(node);
1359
+ var attachStyles = (hostRef) => {
1360
+ const cmpMeta = hostRef.$cmpMeta$;
1361
+ const elm = hostRef.$hostElement$;
1362
+ const flags = cmpMeta.$flags$;
1363
+ const endAttachStyles = createTime("attachStyles", cmpMeta.$tagName$);
1364
+ const scopeId2 = addStyle(
1365
+ BUILD9.shadowDom && supportsShadow && elm.shadowRoot ? elm.shadowRoot : elm.getRootNode(),
1366
+ cmpMeta,
1367
+ hostRef.$modeName$
1368
+ );
1369
+ if ((BUILD9.shadowDom || BUILD9.scoped) && BUILD9.cssAnnotations && flags & 10 /* needsScopedEncapsulation */ && flags & 2 /* scopedCssEncapsulation */) {
1370
+ elm["s-sc"] = scopeId2;
1371
+ elm.classList.add(scopeId2 + "-h");
1304
1372
  }
1373
+ endAttachStyles();
1305
1374
  };
1306
- var patchNextSibling = (node) => {
1307
- if (!node || node.__nextSibling) return;
1308
- patchHostOriginalAccessor("nextSibling", node);
1309
- Object.defineProperty(node, "nextSibling", {
1310
- get: function() {
1311
- var _a;
1312
- const parentNodes = (_a = this["s-ol"]) == null ? void 0 : _a.parentNode.childNodes;
1313
- const index = parentNodes == null ? void 0 : parentNodes.indexOf(this);
1314
- if (parentNodes && index > -1) {
1315
- return parentNodes[index + 1];
1375
+ var getScopeId = (cmp, mode) => "sc-" + (BUILD9.mode && mode && cmp.$flags$ & 32 /* hasMode */ ? cmp.$tagName$ + "-" + mode : cmp.$tagName$);
1376
+
1377
+ // src/runtime/vdom/vdom-render.ts
1378
+ import { BUILD as BUILD12 } from "@stencil/core/internal/app-data";
1379
+
1380
+ // src/runtime/vdom/update-element.ts
1381
+ import { BUILD as BUILD11 } from "@stencil/core/internal/app-data";
1382
+
1383
+ // src/runtime/vdom/set-accessor.ts
1384
+ import { BUILD as BUILD10 } from "@stencil/core/internal/app-data";
1385
+ var setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
1386
+ if (oldValue !== newValue) {
1387
+ let isProp = isMemberInElement(elm, memberName);
1388
+ let ln = memberName.toLowerCase();
1389
+ if (BUILD10.vdomClass && memberName === "class") {
1390
+ const classList = elm.classList;
1391
+ const oldClasses = parseClassList(oldValue);
1392
+ let newClasses = parseClassList(newValue);
1393
+ if (elm["s-si"]) {
1394
+ newClasses.push(elm["s-si"]);
1395
+ oldClasses.forEach((c) => {
1396
+ if (c.startsWith(elm["s-si"])) newClasses.push(c);
1397
+ });
1398
+ newClasses = [...new Set(newClasses)];
1399
+ classList.add(...newClasses);
1400
+ delete elm["s-si"];
1401
+ } else {
1402
+ classList.remove(...oldClasses.filter((c) => c && !newClasses.includes(c)));
1403
+ classList.add(...newClasses.filter((c) => c && !oldClasses.includes(c)));
1316
1404
  }
1317
- return this.__nextSibling;
1318
- }
1319
- });
1320
- };
1321
- var patchNextElementSibling = (element) => {
1322
- if (!element || element.__nextElementSibling) return;
1323
- patchHostOriginalAccessor("nextElementSibling", element);
1324
- Object.defineProperty(element, "nextElementSibling", {
1325
- get: function() {
1326
- var _a;
1327
- const parentEles = (_a = this["s-ol"]) == null ? void 0 : _a.parentNode.children;
1328
- const index = parentEles == null ? void 0 : parentEles.indexOf(this);
1329
- if (parentEles && index > -1) {
1330
- return parentEles[index + 1];
1405
+ } else if (BUILD10.vdomStyle && memberName === "style") {
1406
+ if (BUILD10.updatable) {
1407
+ for (const prop in oldValue) {
1408
+ if (!newValue || newValue[prop] == null) {
1409
+ if (!BUILD10.hydrateServerSide && prop.includes("-")) {
1410
+ elm.style.removeProperty(prop);
1411
+ } else {
1412
+ elm.style[prop] = "";
1413
+ }
1414
+ }
1415
+ }
1331
1416
  }
1332
- return this.__nextElementSibling;
1333
- }
1334
- });
1335
- };
1336
- var patchPreviousSibling = (node) => {
1337
- if (!node || node.__previousSibling) return;
1338
- patchHostOriginalAccessor("previousSibling", node);
1339
- Object.defineProperty(node, "previousSibling", {
1340
- get: function() {
1341
- var _a;
1342
- const parentNodes = (_a = this["s-ol"]) == null ? void 0 : _a.parentNode.childNodes;
1343
- const index = parentNodes == null ? void 0 : parentNodes.indexOf(this);
1344
- if (parentNodes && index > -1) {
1345
- return parentNodes[index - 1];
1417
+ for (const prop in newValue) {
1418
+ if (!oldValue || newValue[prop] !== oldValue[prop]) {
1419
+ if (!BUILD10.hydrateServerSide && prop.includes("-")) {
1420
+ elm.style.setProperty(prop, newValue[prop]);
1421
+ } else {
1422
+ elm.style[prop] = newValue[prop];
1423
+ }
1424
+ }
1346
1425
  }
1347
- return this.__previousSibling;
1348
- }
1349
- });
1350
- };
1351
- var patchPreviousElementSibling = (element) => {
1352
- if (!element || element.__previousElementSibling) return;
1353
- patchHostOriginalAccessor("previousElementSibling", element);
1354
- Object.defineProperty(element, "previousElementSibling", {
1355
- get: function() {
1356
- var _a;
1357
- const parentNodes = (_a = this["s-ol"]) == null ? void 0 : _a.parentNode.children;
1358
- const index = parentNodes == null ? void 0 : parentNodes.indexOf(this);
1359
- if (parentNodes && index > -1) {
1360
- return parentNodes[index - 1];
1426
+ } else if (BUILD10.vdomKey && memberName === "key") {
1427
+ } else if (BUILD10.vdomRef && memberName === "ref") {
1428
+ if (newValue) {
1429
+ newValue(elm);
1361
1430
  }
1362
- return this.__previousElementSibling;
1363
- }
1364
- });
1365
- };
1366
- var validElementPatches = ["children", "nextElementSibling", "previousElementSibling"];
1367
- var validNodesPatches = [
1368
- "childNodes",
1369
- "firstChild",
1370
- "lastChild",
1371
- "nextSibling",
1372
- "previousSibling",
1373
- "textContent"
1374
- ];
1375
- function patchHostOriginalAccessor(accessorName, node) {
1376
- let accessor;
1377
- if (validElementPatches.includes(accessorName)) {
1378
- accessor = Object.getOwnPropertyDescriptor(Element.prototype, accessorName);
1379
- } else if (validNodesPatches.includes(accessorName)) {
1380
- accessor = Object.getOwnPropertyDescriptor(Node.prototype, accessorName);
1381
- }
1382
- if (!accessor) {
1383
- accessor = Object.getOwnPropertyDescriptor(node, accessorName);
1384
- }
1385
- if (accessor) Object.defineProperty(node, "__" + accessorName, accessor);
1386
- }
1387
-
1388
- // src/runtime/profile.ts
1389
- import { BUILD as BUILD7 } from "@stencil/core/internal/app-data";
1390
- var i = 0;
1391
- var createTime = (fnName, tagName = "") => {
1392
- if (BUILD7.profile && performance.mark) {
1393
- const key = `st:${fnName}:${tagName}:${i++}`;
1394
- performance.mark(key);
1395
- return () => performance.measure(`[Stencil] ${fnName}() <${tagName}>`, key);
1396
- } else {
1397
- return () => {
1398
- return;
1399
- };
1400
- }
1401
- };
1402
- var uniqueTime = (key, measureText) => {
1403
- if (BUILD7.profile && performance.mark) {
1404
- if (performance.getEntriesByName(key, "mark").length === 0) {
1405
- performance.mark(key);
1406
- }
1407
- return () => {
1408
- if (performance.getEntriesByName(measureText, "measure").length === 0) {
1409
- performance.measure(measureText, key);
1431
+ } else if (BUILD10.vdomListener && (BUILD10.lazyLoad ? !isProp : !elm.__lookupSetter__(memberName)) && memberName[0] === "o" && memberName[1] === "n") {
1432
+ if (memberName[2] === "-") {
1433
+ memberName = memberName.slice(3);
1434
+ } else if (isMemberInElement(win, ln)) {
1435
+ memberName = ln.slice(2);
1436
+ } else {
1437
+ memberName = ln[2] + memberName.slice(3);
1438
+ }
1439
+ if (oldValue || newValue) {
1440
+ const capture = memberName.endsWith(CAPTURE_EVENT_SUFFIX);
1441
+ memberName = memberName.replace(CAPTURE_EVENT_REGEX, "");
1442
+ if (oldValue) {
1443
+ plt.rel(elm, memberName, oldValue, capture);
1444
+ }
1445
+ if (newValue) {
1446
+ plt.ael(elm, memberName, newValue, capture);
1447
+ }
1448
+ }
1449
+ } else if (BUILD10.vdomPropOrAttr) {
1450
+ const isComplex = isComplexType(newValue);
1451
+ if ((isProp || isComplex && newValue !== null) && !isSvg) {
1452
+ try {
1453
+ if (!elm.tagName.includes("-")) {
1454
+ const n = newValue == null ? "" : newValue;
1455
+ if (memberName === "list") {
1456
+ isProp = false;
1457
+ } else if (oldValue == null || elm[memberName] != n) {
1458
+ if (typeof elm.__lookupSetter__(memberName) === "function") {
1459
+ elm[memberName] = n;
1460
+ } else {
1461
+ elm.setAttribute(memberName, n);
1462
+ }
1463
+ }
1464
+ } else if (elm[memberName] !== newValue) {
1465
+ elm[memberName] = newValue;
1466
+ }
1467
+ } catch (e) {
1468
+ }
1469
+ }
1470
+ let xlink = false;
1471
+ if (BUILD10.vdomXlink) {
1472
+ if (ln !== (ln = ln.replace(/^xlink\:?/, ""))) {
1473
+ memberName = ln;
1474
+ xlink = true;
1475
+ }
1410
1476
  }
1411
- };
1412
- } else {
1413
- return () => {
1414
- return;
1415
- };
1477
+ if (newValue == null || newValue === false) {
1478
+ if (newValue !== false || elm.getAttribute(memberName) === "") {
1479
+ if (BUILD10.vdomXlink && xlink) {
1480
+ elm.removeAttributeNS(XLINK_NS, memberName);
1481
+ } else {
1482
+ elm.removeAttribute(memberName);
1483
+ }
1484
+ }
1485
+ } else if ((!isProp || flags & 4 /* isHost */ || isSvg) && !isComplex) {
1486
+ newValue = newValue === true ? "" : newValue;
1487
+ if (BUILD10.vdomXlink && xlink) {
1488
+ elm.setAttributeNS(XLINK_NS, memberName, newValue);
1489
+ } else {
1490
+ elm.setAttribute(memberName, newValue);
1491
+ }
1492
+ }
1493
+ }
1416
1494
  }
1417
1495
  };
1418
- var inspect = (ref) => {
1419
- const hostRef = getHostRef(ref);
1420
- if (!hostRef) {
1421
- return void 0;
1496
+ var parseClassListRegex = /\s/;
1497
+ var parseClassList = (value) => {
1498
+ if (typeof value === "object" && "baseVal" in value) {
1499
+ value = value.baseVal;
1422
1500
  }
1423
- const flags = hostRef.$flags$;
1424
- const hostElement = hostRef.$hostElement$;
1425
- return {
1426
- renderCount: hostRef.$renderCount$,
1427
- flags: {
1428
- hasRendered: !!(flags & 2 /* hasRendered */),
1429
- hasConnected: !!(flags & 1 /* hasConnected */),
1430
- isWaitingForChildren: !!(flags & 4 /* isWaitingForChildren */),
1431
- isConstructingInstance: !!(flags & 8 /* isConstructingInstance */),
1432
- isQueuedForUpdate: !!(flags & 16 /* isQueuedForUpdate */),
1433
- hasInitializedComponent: !!(flags & 32 /* hasInitializedComponent */),
1434
- hasLoadedComponent: !!(flags & 64 /* hasLoadedComponent */),
1435
- isWatchReady: !!(flags & 128 /* isWatchReady */),
1436
- isListenReady: !!(flags & 256 /* isListenReady */),
1437
- needsRerender: !!(flags & 512 /* needsRerender */)
1438
- },
1439
- instanceValues: hostRef.$instanceValues$,
1440
- ancestorComponent: hostRef.$ancestorComponent$,
1441
- hostElement,
1442
- lazyInstance: hostRef.$lazyInstance$,
1443
- vnode: hostRef.$vnode$,
1444
- modeName: hostRef.$modeName$,
1445
- onReadyPromise: hostRef.$onReadyPromise$,
1446
- onReadyResolve: hostRef.$onReadyResolve$,
1447
- onInstancePromise: hostRef.$onInstancePromise$,
1448
- onInstanceResolve: hostRef.$onInstanceResolve$,
1449
- onRenderResolve: hostRef.$onRenderResolve$,
1450
- queuedListeners: hostRef.$queuedListeners$,
1451
- rmListeners: hostRef.$rmListeners$,
1452
- ["s-id"]: hostElement["s-id"],
1453
- ["s-cr"]: hostElement["s-cr"],
1454
- ["s-lr"]: hostElement["s-lr"],
1455
- ["s-p"]: hostElement["s-p"],
1456
- ["s-rc"]: hostElement["s-rc"],
1457
- ["s-sc"]: hostElement["s-sc"]
1458
- };
1501
+ if (!value) {
1502
+ return [];
1503
+ }
1504
+ return value.split(parseClassListRegex);
1459
1505
  };
1460
- var installDevTools = () => {
1461
- if (BUILD7.devTools) {
1462
- const stencil = win.stencil = win.stencil || {};
1463
- const originalInspect = stencil.inspect;
1464
- stencil.inspect = (ref) => {
1465
- let result = inspect(ref);
1466
- if (!result && typeof originalInspect === "function") {
1467
- result = originalInspect(ref);
1506
+ var CAPTURE_EVENT_SUFFIX = "Capture";
1507
+ var CAPTURE_EVENT_REGEX = new RegExp(CAPTURE_EVENT_SUFFIX + "$");
1508
+
1509
+ // src/runtime/vdom/update-element.ts
1510
+ var updateElement = (oldVnode, newVnode, isSvgMode2) => {
1511
+ const elm = newVnode.$elm$.nodeType === 11 /* DocumentFragment */ && newVnode.$elm$.host ? newVnode.$elm$.host : newVnode.$elm$;
1512
+ const oldVnodeAttrs = oldVnode && oldVnode.$attrs$ || {};
1513
+ const newVnodeAttrs = newVnode.$attrs$ || {};
1514
+ if (BUILD11.updatable) {
1515
+ for (const memberName of sortedAttrNames(Object.keys(oldVnodeAttrs))) {
1516
+ if (!(memberName in newVnodeAttrs)) {
1517
+ setAccessor(elm, memberName, oldVnodeAttrs[memberName], void 0, isSvgMode2, newVnode.$flags$);
1468
1518
  }
1469
- return result;
1470
- };
1519
+ }
1520
+ }
1521
+ for (const memberName of sortedAttrNames(Object.keys(newVnodeAttrs))) {
1522
+ setAccessor(elm, memberName, oldVnodeAttrs[memberName], newVnodeAttrs[memberName], isSvgMode2, newVnode.$flags$);
1471
1523
  }
1472
1524
  };
1525
+ function sortedAttrNames(attrNames) {
1526
+ return attrNames.includes("ref") ? (
1527
+ // we need to sort these to ensure that `'ref'` is the last attr
1528
+ [...attrNames.filter((attr) => attr !== "ref"), "ref"]
1529
+ ) : (
1530
+ // no need to sort, return the original array
1531
+ attrNames
1532
+ );
1533
+ }
1473
1534
 
1474
- // src/runtime/client-hydrate.ts
1475
- var initializeClientHydrate = (hostElm, tagName, hostId, hostRef) => {
1476
- const endHydrate = createTime("hydrateClient", tagName);
1477
- const shadowRoot = hostElm.shadowRoot;
1478
- const childRenderNodes = [];
1479
- const slotNodes = [];
1480
- const slottedNodes = [];
1481
- const shadowRootNodes = BUILD8.shadowDom && shadowRoot ? [] : null;
1482
- const vnode = newVNode(tagName, null);
1483
- vnode.$elm$ = hostElm;
1484
- let scopeId2;
1485
- if (BUILD8.scoped) {
1486
- const cmpMeta = hostRef.$cmpMeta$;
1487
- if (cmpMeta && cmpMeta.$flags$ & 10 /* needsScopedEncapsulation */ && hostElm["s-sc"]) {
1488
- scopeId2 = hostElm["s-sc"];
1489
- hostElm.classList.add(scopeId2 + "-h");
1490
- } else if (hostElm["s-sc"]) {
1491
- delete hostElm["s-sc"];
1535
+ // src/runtime/vdom/vdom-render.ts
1536
+ var scopeId;
1537
+ var contentRef;
1538
+ var hostTagName;
1539
+ var useNativeShadowDom = false;
1540
+ var checkSlotFallbackVisibility = false;
1541
+ var checkSlotRelocate = false;
1542
+ var isSvgMode = false;
1543
+ var createElm = (oldParentVNode, newParentVNode, childIndex) => {
1544
+ var _a;
1545
+ const newVNode2 = newParentVNode.$children$[childIndex];
1546
+ let i2 = 0;
1547
+ let elm;
1548
+ let childNode;
1549
+ let oldVNode;
1550
+ if (BUILD12.slotRelocation && !useNativeShadowDom) {
1551
+ checkSlotRelocate = true;
1552
+ if (newVNode2.$tag$ === "slot") {
1553
+ newVNode2.$flags$ |= newVNode2.$children$ ? (
1554
+ // slot element has fallback content
1555
+ // still create an element that "mocks" the slot element
1556
+ 2 /* isSlotFallback */
1557
+ ) : (
1558
+ // slot element does not have fallback content
1559
+ // create an html comment we'll use to always reference
1560
+ // where actual slot content should sit next to
1561
+ 1 /* isSlotReference */
1562
+ );
1492
1563
  }
1493
1564
  }
1494
- if (!plt.$orgLocNodes$) {
1495
- initializeDocumentHydrate(doc.body, plt.$orgLocNodes$ = /* @__PURE__ */ new Map());
1565
+ if (BUILD12.isDev && newVNode2.$elm$) {
1566
+ consoleDevError(
1567
+ `The JSX ${newVNode2.$text$ !== null ? `"${newVNode2.$text$}" text` : `"${newVNode2.$tag$}" element`} node should not be shared within the same renderer. The renderer caches element lookups in order to improve performance. However, a side effect from this is that the exact same JSX node should not be reused. For more information please see https://stenciljs.com/docs/templating-jsx#avoid-shared-jsx-nodes`
1568
+ );
1496
1569
  }
1497
- hostElm[HYDRATE_ID] = hostId;
1498
- hostElm.removeAttribute(HYDRATE_ID);
1499
- hostRef.$vnode$ = clientHydrate(
1500
- vnode,
1501
- childRenderNodes,
1502
- slotNodes,
1503
- shadowRootNodes,
1504
- hostElm,
1505
- hostElm,
1506
- hostId,
1507
- slottedNodes
1508
- );
1509
- let crIndex = 0;
1510
- const crLength = childRenderNodes.length;
1511
- let childRenderNode;
1512
- for (crIndex; crIndex < crLength; crIndex++) {
1513
- childRenderNode = childRenderNodes[crIndex];
1514
- const orgLocationId = childRenderNode.$hostId$ + "." + childRenderNode.$nodeId$;
1515
- const orgLocationNode = plt.$orgLocNodes$.get(orgLocationId);
1516
- const node = childRenderNode.$elm$;
1517
- if (!shadowRoot) {
1518
- node["s-hn"] = tagName.toUpperCase();
1519
- if (childRenderNode.$tag$ === "slot") {
1520
- node["s-cr"] = hostElm["s-cr"];
1521
- }
1570
+ if (BUILD12.vdomText && newVNode2.$text$ !== null) {
1571
+ elm = newVNode2.$elm$ = doc.createTextNode(newVNode2.$text$);
1572
+ } else if (BUILD12.slotRelocation && newVNode2.$flags$ & 1 /* isSlotReference */) {
1573
+ elm = newVNode2.$elm$ = BUILD12.isDebug || BUILD12.hydrateServerSide ? slotReferenceDebugNode(newVNode2) : doc.createTextNode("");
1574
+ } else {
1575
+ if (BUILD12.svg && !isSvgMode) {
1576
+ isSvgMode = newVNode2.$tag$ === "svg";
1522
1577
  }
1523
- if (childRenderNode.$tag$ === "slot") {
1524
- if (childRenderNode.$children$) {
1525
- childRenderNode.$flags$ |= 2 /* isSlotFallback */;
1526
- if (!childRenderNode.$elm$.childNodes.length) {
1527
- childRenderNode.$children$.forEach((c) => {
1528
- childRenderNode.$elm$.appendChild(c.$elm$);
1529
- });
1578
+ elm = newVNode2.$elm$ = BUILD12.svg ? doc.createElementNS(
1579
+ isSvgMode ? SVG_NS : HTML_NS,
1580
+ !useNativeShadowDom && BUILD12.slotRelocation && newVNode2.$flags$ & 2 /* isSlotFallback */ ? "slot-fb" : newVNode2.$tag$
1581
+ ) : doc.createElement(
1582
+ !useNativeShadowDom && BUILD12.slotRelocation && newVNode2.$flags$ & 2 /* isSlotFallback */ ? "slot-fb" : newVNode2.$tag$
1583
+ );
1584
+ if (BUILD12.svg && isSvgMode && newVNode2.$tag$ === "foreignObject") {
1585
+ isSvgMode = false;
1586
+ }
1587
+ if (BUILD12.vdomAttribute) {
1588
+ updateElement(null, newVNode2, isSvgMode);
1589
+ }
1590
+ if (BUILD12.scoped && isDef(scopeId) && elm["s-si"] !== scopeId) {
1591
+ elm.classList.add(elm["s-si"] = scopeId);
1592
+ }
1593
+ if (newVNode2.$children$) {
1594
+ for (i2 = 0; i2 < newVNode2.$children$.length; ++i2) {
1595
+ childNode = createElm(oldParentVNode, newVNode2, i2);
1596
+ if (childNode) {
1597
+ elm.appendChild(childNode);
1530
1598
  }
1531
- } else {
1532
- childRenderNode.$flags$ |= 1 /* isSlotReference */;
1533
1599
  }
1534
1600
  }
1535
- if (orgLocationNode && orgLocationNode.isConnected) {
1536
- if (shadowRoot && orgLocationNode["s-en"] === "") {
1537
- orgLocationNode.parentNode.insertBefore(node, orgLocationNode.nextSibling);
1538
- }
1539
- orgLocationNode.parentNode.removeChild(orgLocationNode);
1540
- if (!shadowRoot) {
1541
- node["s-oo"] = parseInt(childRenderNode.$nodeId$);
1601
+ if (BUILD12.svg) {
1602
+ if (newVNode2.$tag$ === "svg") {
1603
+ isSvgMode = false;
1604
+ } else if (elm.tagName === "foreignObject") {
1605
+ isSvgMode = true;
1542
1606
  }
1543
1607
  }
1544
- plt.$orgLocNodes$.delete(orgLocationId);
1545
1608
  }
1546
- const hosts = [];
1547
- const snLen = slottedNodes.length;
1548
- let snIndex = 0;
1549
- let slotGroup;
1550
- let snGroupIdx;
1551
- let snGroupLen;
1552
- let slottedItem;
1553
- for (snIndex; snIndex < snLen; snIndex++) {
1554
- slotGroup = slottedNodes[snIndex];
1555
- if (!slotGroup || !slotGroup.length) continue;
1556
- snGroupLen = slotGroup.length;
1557
- snGroupIdx = 0;
1558
- for (snGroupIdx; snGroupIdx < snGroupLen; snGroupIdx++) {
1559
- slottedItem = slotGroup[snGroupIdx];
1560
- if (!hosts[slottedItem.hostId]) {
1561
- hosts[slottedItem.hostId] = plt.$orgLocNodes$.get(slottedItem.hostId);
1562
- }
1563
- if (!hosts[slottedItem.hostId]) continue;
1564
- const hostEle = hosts[slottedItem.hostId];
1565
- if (!hostEle.shadowRoot || !shadowRoot) {
1566
- slottedItem.slot["s-cr"] = hostEle["s-cr"];
1567
- if (!slottedItem.slot["s-cr"] && hostEle.shadowRoot) {
1568
- slottedItem.slot["s-cr"] = hostEle;
1609
+ elm["s-hn"] = hostTagName;
1610
+ if (BUILD12.slotRelocation) {
1611
+ if (newVNode2.$flags$ & (2 /* isSlotFallback */ | 1 /* isSlotReference */)) {
1612
+ elm["s-sr"] = true;
1613
+ elm["s-cr"] = contentRef;
1614
+ elm["s-sn"] = newVNode2.$name$ || "";
1615
+ elm["s-rf"] = (_a = newVNode2.$attrs$) == null ? void 0 : _a.ref;
1616
+ oldVNode = oldParentVNode && oldParentVNode.$children$ && oldParentVNode.$children$[childIndex];
1617
+ if (oldVNode && oldVNode.$tag$ === newVNode2.$tag$ && oldParentVNode.$elm$) {
1618
+ if (BUILD12.experimentalSlotFixes) {
1619
+ relocateToHostRoot(oldParentVNode.$elm$);
1569
1620
  } else {
1570
- slottedItem.slot["s-cr"] = (hostEle.__childNodes || hostEle.childNodes)[0];
1571
- }
1572
- addSlotRelocateNode(slottedItem.node, slottedItem.slot, false, slottedItem.node["s-oo"]);
1573
- if (BUILD8.experimentalSlotFixes) {
1574
- patchNextPrev(slottedItem.node);
1621
+ putBackInOriginalLocation(oldParentVNode.$elm$, false);
1575
1622
  }
1576
1623
  }
1577
- if (hostEle.shadowRoot && slottedItem.node.parentElement !== hostEle) {
1578
- hostEle.appendChild(slottedItem.node);
1624
+ if (BUILD12.scoped) {
1625
+ addRemoveSlotScopedClass(contentRef, elm, newParentVNode.$elm$, oldParentVNode == null ? void 0 : oldParentVNode.$elm$);
1626
+ }
1627
+ }
1628
+ }
1629
+ return elm;
1630
+ };
1631
+ var relocateToHostRoot = (parentElm) => {
1632
+ plt.$flags$ |= 1 /* isTmpDisconnected */;
1633
+ const host = parentElm.closest(hostTagName.toLowerCase());
1634
+ if (host != null) {
1635
+ const contentRefNode = Array.from(host.__childNodes || host.childNodes).find(
1636
+ (ref) => ref["s-cr"]
1637
+ );
1638
+ const childNodeArray = Array.from(
1639
+ parentElm.__childNodes || parentElm.childNodes
1640
+ );
1641
+ for (const childNode of contentRefNode ? childNodeArray.reverse() : childNodeArray) {
1642
+ if (childNode["s-sh"] != null) {
1643
+ insertBefore(host, childNode, contentRefNode != null ? contentRefNode : null);
1644
+ childNode["s-sh"] = void 0;
1645
+ checkSlotRelocate = true;
1579
1646
  }
1580
1647
  }
1581
1648
  }
1582
- if (BUILD8.scoped && scopeId2 && slotNodes.length) {
1583
- slotNodes.forEach((slot) => {
1584
- slot.$elm$.parentElement.classList.add(scopeId2 + "-s");
1585
- });
1649
+ plt.$flags$ &= ~1 /* isTmpDisconnected */;
1650
+ };
1651
+ var putBackInOriginalLocation = (parentElm, recursive) => {
1652
+ plt.$flags$ |= 1 /* isTmpDisconnected */;
1653
+ const oldSlotChildNodes = Array.from(parentElm.__childNodes || parentElm.childNodes);
1654
+ if (parentElm["s-sr"] && BUILD12.experimentalSlotFixes) {
1655
+ let node = parentElm;
1656
+ while (node = node.nextSibling) {
1657
+ if (node && node["s-sn"] === parentElm["s-sn"] && node["s-sh"] === hostTagName) {
1658
+ oldSlotChildNodes.push(node);
1659
+ }
1660
+ }
1586
1661
  }
1587
- if (BUILD8.shadowDom && shadowRoot) {
1588
- let rnIdex = 0;
1589
- const rnLen = shadowRootNodes.length;
1590
- for (rnIdex; rnIdex < rnLen; rnIdex++) {
1591
- shadowRoot.appendChild(shadowRootNodes[rnIdex]);
1662
+ for (let i2 = oldSlotChildNodes.length - 1; i2 >= 0; i2--) {
1663
+ const childNode = oldSlotChildNodes[i2];
1664
+ if (childNode["s-hn"] !== hostTagName && childNode["s-ol"]) {
1665
+ insertBefore(referenceNode(childNode).parentNode, childNode, referenceNode(childNode));
1666
+ childNode["s-ol"].remove();
1667
+ childNode["s-ol"] = void 0;
1668
+ childNode["s-sh"] = void 0;
1669
+ checkSlotRelocate = true;
1592
1670
  }
1593
- Array.from(hostElm.childNodes).forEach((node) => {
1594
- if (node.nodeType === 8 /* CommentNode */ && typeof node["s-sn"] !== "string") {
1595
- node.parentNode.removeChild(node);
1671
+ if (recursive) {
1672
+ putBackInOriginalLocation(childNode, recursive);
1673
+ }
1674
+ }
1675
+ plt.$flags$ &= ~1 /* isTmpDisconnected */;
1676
+ };
1677
+ var addVnodes = (parentElm, before, parentVNode, vnodes, startIdx, endIdx) => {
1678
+ let containerElm = BUILD12.slotRelocation && parentElm["s-cr"] && parentElm["s-cr"].parentNode || parentElm;
1679
+ let childNode;
1680
+ if (BUILD12.shadowDom && containerElm.shadowRoot && containerElm.tagName === hostTagName) {
1681
+ containerElm = containerElm.shadowRoot;
1682
+ }
1683
+ for (; startIdx <= endIdx; ++startIdx) {
1684
+ if (vnodes[startIdx]) {
1685
+ childNode = createElm(null, parentVNode, startIdx);
1686
+ if (childNode) {
1687
+ vnodes[startIdx].$elm$ = childNode;
1688
+ insertBefore(containerElm, childNode, BUILD12.slotRelocation ? referenceNode(before) : before);
1596
1689
  }
1597
- });
1690
+ }
1598
1691
  }
1599
- hostRef.$hostElement$ = hostElm;
1600
- endHydrate();
1601
1692
  };
1602
- var clientHydrate = (parentVNode, childRenderNodes, slotNodes, shadowRootNodes, hostElm, node, hostId, slottedNodes = []) => {
1603
- let childNodeType;
1604
- let childIdSplt;
1605
- let childVNode;
1606
- let i2;
1607
- const scopeId2 = hostElm["s-sc"];
1608
- if (node.nodeType === 1 /* ElementNode */) {
1609
- childNodeType = node.getAttribute(HYDRATE_CHILD_ID);
1610
- if (childNodeType) {
1611
- childIdSplt = childNodeType.split(".");
1612
- if (childIdSplt[0] === hostId || childIdSplt[0] === "0") {
1613
- childVNode = createSimpleVNode({
1614
- $flags$: 0,
1615
- $hostId$: childIdSplt[0],
1616
- $nodeId$: childIdSplt[1],
1617
- $depth$: childIdSplt[2],
1618
- $index$: childIdSplt[3],
1619
- $tag$: node.tagName.toLowerCase(),
1620
- $elm$: node,
1621
- // If we don't add the initial classes to the VNode, the first `vdom-render.ts` patch
1622
- // won't try to reconcile them. Classes set on the node will be blown away.
1623
- $attrs$: { class: node.className || "" }
1624
- });
1625
- childRenderNodes.push(childVNode);
1626
- node.removeAttribute(HYDRATE_CHILD_ID);
1627
- if (!parentVNode.$children$) {
1628
- parentVNode.$children$ = [];
1629
- }
1630
- if (BUILD8.scoped && scopeId2) {
1631
- node["s-si"] = scopeId2;
1632
- childVNode.$attrs$.class += " " + scopeId2;
1633
- }
1634
- const slotName = childVNode.$elm$.getAttribute("s-sn");
1635
- if (typeof slotName === "string") {
1636
- if (childVNode.$tag$ === "slot-fb") {
1637
- addSlot(
1638
- slotName,
1639
- childIdSplt[2],
1640
- childVNode,
1641
- node,
1642
- parentVNode,
1643
- childRenderNodes,
1644
- slotNodes,
1645
- shadowRootNodes,
1646
- slottedNodes
1647
- );
1648
- if (BUILD8.scoped && scopeId2) {
1649
- node.classList.add(scopeId2);
1650
- }
1693
+ var removeVnodes = (vnodes, startIdx, endIdx) => {
1694
+ for (let index = startIdx; index <= endIdx; ++index) {
1695
+ const vnode = vnodes[index];
1696
+ if (vnode) {
1697
+ const elm = vnode.$elm$;
1698
+ nullifyVNodeRefs(vnode);
1699
+ if (elm) {
1700
+ if (BUILD12.slotRelocation) {
1701
+ checkSlotFallbackVisibility = true;
1702
+ if (elm["s-ol"]) {
1703
+ elm["s-ol"].remove();
1704
+ } else {
1705
+ putBackInOriginalLocation(elm, true);
1651
1706
  }
1652
- childVNode.$elm$["s-sn"] = slotName;
1653
- childVNode.$elm$.removeAttribute("s-sn");
1654
- }
1655
- if (childVNode.$index$ !== void 0) {
1656
- parentVNode.$children$[childVNode.$index$] = childVNode;
1657
- }
1658
- parentVNode = childVNode;
1659
- if (shadowRootNodes && childVNode.$depth$ === "0") {
1660
- shadowRootNodes[childVNode.$index$] = childVNode.$elm$;
1661
1707
  }
1708
+ elm.remove();
1662
1709
  }
1663
1710
  }
1664
- if (node.shadowRoot) {
1665
- for (i2 = node.shadowRoot.childNodes.length - 1; i2 >= 0; i2--) {
1666
- clientHydrate(
1667
- parentVNode,
1668
- childRenderNodes,
1669
- slotNodes,
1670
- shadowRootNodes,
1671
- hostElm,
1672
- node.shadowRoot.childNodes[i2],
1673
- hostId,
1674
- slottedNodes
1675
- );
1711
+ }
1712
+ };
1713
+ var updateChildren = (parentElm, oldCh, newVNode2, newCh, isInitialRender = false) => {
1714
+ let oldStartIdx = 0;
1715
+ let newStartIdx = 0;
1716
+ let idxInOld = 0;
1717
+ let i2 = 0;
1718
+ let oldEndIdx = oldCh.length - 1;
1719
+ let oldStartVnode = oldCh[0];
1720
+ let oldEndVnode = oldCh[oldEndIdx];
1721
+ let newEndIdx = newCh.length - 1;
1722
+ let newStartVnode = newCh[0];
1723
+ let newEndVnode = newCh[newEndIdx];
1724
+ let node;
1725
+ let elmToMove;
1726
+ while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
1727
+ if (oldStartVnode == null) {
1728
+ oldStartVnode = oldCh[++oldStartIdx];
1729
+ } else if (oldEndVnode == null) {
1730
+ oldEndVnode = oldCh[--oldEndIdx];
1731
+ } else if (newStartVnode == null) {
1732
+ newStartVnode = newCh[++newStartIdx];
1733
+ } else if (newEndVnode == null) {
1734
+ newEndVnode = newCh[--newEndIdx];
1735
+ } else if (isSameVnode(oldStartVnode, newStartVnode, isInitialRender)) {
1736
+ patch(oldStartVnode, newStartVnode, isInitialRender);
1737
+ oldStartVnode = oldCh[++oldStartIdx];
1738
+ newStartVnode = newCh[++newStartIdx];
1739
+ } else if (isSameVnode(oldEndVnode, newEndVnode, isInitialRender)) {
1740
+ patch(oldEndVnode, newEndVnode, isInitialRender);
1741
+ oldEndVnode = oldCh[--oldEndIdx];
1742
+ newEndVnode = newCh[--newEndIdx];
1743
+ } else if (isSameVnode(oldStartVnode, newEndVnode, isInitialRender)) {
1744
+ if (BUILD12.slotRelocation && (oldStartVnode.$tag$ === "slot" || newEndVnode.$tag$ === "slot")) {
1745
+ putBackInOriginalLocation(oldStartVnode.$elm$.parentNode, false);
1676
1746
  }
1677
- }
1678
- const nonShadowNodes = node.__childNodes || node.childNodes;
1679
- for (i2 = nonShadowNodes.length - 1; i2 >= 0; i2--) {
1680
- clientHydrate(
1681
- parentVNode,
1682
- childRenderNodes,
1683
- slotNodes,
1684
- shadowRootNodes,
1685
- hostElm,
1686
- nonShadowNodes[i2],
1687
- hostId,
1688
- slottedNodes
1689
- );
1690
- }
1691
- } else if (node.nodeType === 8 /* CommentNode */) {
1692
- childIdSplt = node.nodeValue.split(".");
1693
- if (childIdSplt[1] === hostId || childIdSplt[1] === "0") {
1694
- childNodeType = childIdSplt[0];
1695
- childVNode = createSimpleVNode({
1696
- $hostId$: childIdSplt[1],
1697
- $nodeId$: childIdSplt[2],
1698
- $depth$: childIdSplt[3],
1699
- $index$: childIdSplt[4] || "0",
1700
- $elm$: node,
1701
- $attrs$: null,
1702
- $children$: null,
1703
- $key$: null,
1704
- $name$: null,
1705
- $tag$: null,
1706
- $text$: null
1707
- });
1708
- if (childNodeType === TEXT_NODE_ID) {
1709
- childVNode.$elm$ = node.nextSibling;
1710
- if (childVNode.$elm$ && childVNode.$elm$.nodeType === 3 /* TextNode */) {
1711
- childVNode.$text$ = childVNode.$elm$.textContent;
1712
- childRenderNodes.push(childVNode);
1713
- node.remove();
1714
- if (hostId === childVNode.$hostId$) {
1715
- if (!parentVNode.$children$) {
1716
- parentVNode.$children$ = [];
1717
- }
1718
- parentVNode.$children$[childVNode.$index$] = childVNode;
1719
- }
1720
- if (shadowRootNodes && childVNode.$depth$ === "0") {
1721
- shadowRootNodes[childVNode.$index$] = childVNode.$elm$;
1747
+ patch(oldStartVnode, newEndVnode, isInitialRender);
1748
+ insertBefore(parentElm, oldStartVnode.$elm$, oldEndVnode.$elm$.nextSibling);
1749
+ oldStartVnode = oldCh[++oldStartIdx];
1750
+ newEndVnode = newCh[--newEndIdx];
1751
+ } else if (isSameVnode(oldEndVnode, newStartVnode, isInitialRender)) {
1752
+ if (BUILD12.slotRelocation && (oldStartVnode.$tag$ === "slot" || newEndVnode.$tag$ === "slot")) {
1753
+ putBackInOriginalLocation(oldEndVnode.$elm$.parentNode, false);
1754
+ }
1755
+ patch(oldEndVnode, newStartVnode, isInitialRender);
1756
+ insertBefore(parentElm, oldEndVnode.$elm$, oldStartVnode.$elm$);
1757
+ oldEndVnode = oldCh[--oldEndIdx];
1758
+ newStartVnode = newCh[++newStartIdx];
1759
+ } else {
1760
+ idxInOld = -1;
1761
+ if (BUILD12.vdomKey) {
1762
+ for (i2 = oldStartIdx; i2 <= oldEndIdx; ++i2) {
1763
+ if (oldCh[i2] && oldCh[i2].$key$ !== null && oldCh[i2].$key$ === newStartVnode.$key$) {
1764
+ idxInOld = i2;
1765
+ break;
1722
1766
  }
1723
1767
  }
1724
- } else if (childNodeType === COMMENT_NODE_ID) {
1725
- childVNode.$elm$ = node.nextSibling;
1726
- if (childVNode.$elm$ && childVNode.$elm$.nodeType === 8 /* CommentNode */) {
1727
- childRenderNodes.push(childVNode);
1728
- node.remove();
1768
+ }
1769
+ if (BUILD12.vdomKey && idxInOld >= 0) {
1770
+ elmToMove = oldCh[idxInOld];
1771
+ if (elmToMove.$tag$ !== newStartVnode.$tag$) {
1772
+ node = createElm(oldCh && oldCh[newStartIdx], newVNode2, idxInOld);
1773
+ } else {
1774
+ patch(elmToMove, newStartVnode, isInitialRender);
1775
+ oldCh[idxInOld] = void 0;
1776
+ node = elmToMove.$elm$;
1729
1777
  }
1730
- } else if (childVNode.$hostId$ === hostId) {
1731
- if (childNodeType === SLOT_NODE_ID) {
1732
- const slotName = node["s-sn"] = childIdSplt[5] || "";
1733
- addSlot(
1734
- slotName,
1735
- childIdSplt[2],
1736
- childVNode,
1778
+ newStartVnode = newCh[++newStartIdx];
1779
+ } else {
1780
+ node = createElm(oldCh && oldCh[newStartIdx], newVNode2, newStartIdx);
1781
+ newStartVnode = newCh[++newStartIdx];
1782
+ }
1783
+ if (node) {
1784
+ if (BUILD12.slotRelocation) {
1785
+ insertBefore(
1786
+ referenceNode(oldStartVnode.$elm$).parentNode,
1737
1787
  node,
1738
- parentVNode,
1739
- childRenderNodes,
1740
- slotNodes,
1741
- shadowRootNodes,
1742
- slottedNodes
1788
+ referenceNode(oldStartVnode.$elm$)
1743
1789
  );
1744
- } else if (childNodeType === CONTENT_REF_ID) {
1745
- if (BUILD8.shadowDom && shadowRootNodes) {
1746
- node.remove();
1747
- } else if (BUILD8.slotRelocation) {
1748
- hostElm["s-cr"] = node;
1749
- node["s-cn"] = true;
1750
- }
1790
+ } else {
1791
+ insertBefore(oldStartVnode.$elm$.parentNode, node, oldStartVnode.$elm$);
1751
1792
  }
1752
1793
  }
1753
1794
  }
1754
- } else if (parentVNode && parentVNode.$tag$ === "style") {
1755
- const vnode = newVNode(null, node.textContent);
1756
- vnode.$elm$ = node;
1757
- vnode.$index$ = "0";
1758
- parentVNode.$children$ = [vnode];
1759
1795
  }
1760
- return parentVNode;
1796
+ if (oldStartIdx > oldEndIdx) {
1797
+ addVnodes(
1798
+ parentElm,
1799
+ newCh[newEndIdx + 1] == null ? null : newCh[newEndIdx + 1].$elm$,
1800
+ newVNode2,
1801
+ newCh,
1802
+ newStartIdx,
1803
+ newEndIdx
1804
+ );
1805
+ } else if (BUILD12.updatable && newStartIdx > newEndIdx) {
1806
+ removeVnodes(oldCh, oldStartIdx, oldEndIdx);
1807
+ }
1761
1808
  };
1762
- var initializeDocumentHydrate = (node, orgLocNodes) => {
1763
- if (node.nodeType === 1 /* ElementNode */) {
1764
- const componentId = node[HYDRATE_ID] || node.getAttribute(HYDRATE_ID);
1765
- if (componentId) {
1766
- orgLocNodes.set(componentId, node);
1767
- }
1768
- let i2 = 0;
1769
- if (node.shadowRoot) {
1770
- for (; i2 < node.shadowRoot.childNodes.length; i2++) {
1771
- initializeDocumentHydrate(node.shadowRoot.childNodes[i2], orgLocNodes);
1772
- }
1809
+ var isSameVnode = (leftVNode, rightVNode, isInitialRender = false) => {
1810
+ if (leftVNode.$tag$ === rightVNode.$tag$) {
1811
+ if (BUILD12.slotRelocation && leftVNode.$tag$ === "slot") {
1812
+ return leftVNode.$name$ === rightVNode.$name$;
1773
1813
  }
1774
- const nonShadowNodes = node.__childNodes || node.childNodes;
1775
- for (i2 = 0; i2 < nonShadowNodes.length; i2++) {
1776
- initializeDocumentHydrate(nonShadowNodes[i2], orgLocNodes);
1814
+ if (BUILD12.vdomKey && !isInitialRender) {
1815
+ return leftVNode.$key$ === rightVNode.$key$;
1777
1816
  }
1778
- } else if (node.nodeType === 8 /* CommentNode */) {
1779
- const childIdSplt = node.nodeValue.split(".");
1780
- if (childIdSplt[0] === ORG_LOCATION_ID) {
1781
- orgLocNodes.set(childIdSplt[1] + "." + childIdSplt[2], node);
1782
- node.nodeValue = "";
1783
- node["s-en"] = childIdSplt[3];
1817
+ if (isInitialRender && !leftVNode.$key$ && rightVNode.$key$) {
1818
+ leftVNode.$key$ = rightVNode.$key$;
1784
1819
  }
1820
+ return true;
1785
1821
  }
1822
+ return false;
1786
1823
  };
1787
- var createSimpleVNode = (vnode) => {
1788
- const defaultVNode = {
1789
- $flags$: 0,
1790
- $hostId$: null,
1791
- $nodeId$: null,
1792
- $depth$: null,
1793
- $index$: "0",
1794
- $elm$: null,
1795
- $attrs$: null,
1796
- $children$: null,
1797
- $key$: null,
1798
- $name$: null,
1799
- $tag$: null,
1800
- $text$: null
1801
- };
1802
- return { ...defaultVNode, ...vnode };
1803
- };
1804
- function addSlot(slotName, slotId, childVNode, node, parentVNode, childRenderNodes, slotNodes, shadowRootNodes, slottedNodes) {
1805
- node["s-sr"] = true;
1806
- childVNode.$name$ = slotName || null;
1807
- childVNode.$tag$ = "slot";
1808
- const parentNodeId = (parentVNode == null ? void 0 : parentVNode.$elm$) ? parentVNode.$elm$["s-id"] || parentVNode.$elm$.getAttribute("s-id") : "";
1809
- if (BUILD8.shadowDom && shadowRootNodes) {
1810
- const slot = childVNode.$elm$ = doc.createElement(childVNode.$tag$);
1811
- if (childVNode.$name$) {
1812
- childVNode.$elm$.setAttribute("name", slotName);
1824
+ var referenceNode = (node) => node && node["s-ol"] || node;
1825
+ var patch = (oldVNode, newVNode2, isInitialRender = false) => {
1826
+ const elm = newVNode2.$elm$ = oldVNode.$elm$;
1827
+ const oldChildren = oldVNode.$children$;
1828
+ const newChildren = newVNode2.$children$;
1829
+ const tag = newVNode2.$tag$;
1830
+ const text = newVNode2.$text$;
1831
+ let defaultHolder;
1832
+ if (!BUILD12.vdomText || text === null) {
1833
+ if (BUILD12.svg) {
1834
+ isSvgMode = tag === "svg" ? true : tag === "foreignObject" ? false : isSvgMode;
1813
1835
  }
1814
- if (parentNodeId && parentNodeId !== childVNode.$hostId$) {
1815
- parentVNode.$elm$.insertBefore(slot, parentVNode.$elm$.children[0]);
1816
- } else {
1817
- node.parentNode.insertBefore(childVNode.$elm$, node);
1836
+ if (BUILD12.vdomAttribute || BUILD12.reflect) {
1837
+ if (BUILD12.slot && tag === "slot" && !useNativeShadowDom) {
1838
+ if (BUILD12.experimentalSlotFixes && oldVNode.$name$ !== newVNode2.$name$) {
1839
+ newVNode2.$elm$["s-sn"] = newVNode2.$name$ || "";
1840
+ relocateToHostRoot(newVNode2.$elm$.parentElement);
1841
+ }
1842
+ } else {
1843
+ updateElement(oldVNode, newVNode2, isSvgMode);
1844
+ }
1818
1845
  }
1819
- addSlottedNodes(slottedNodes, slotId, slotName, node, childVNode.$hostId$);
1820
- node.remove();
1821
- if (childVNode.$depth$ === "0") {
1822
- shadowRootNodes[childVNode.$index$] = childVNode.$elm$;
1846
+ if (BUILD12.updatable && oldChildren !== null && newChildren !== null) {
1847
+ updateChildren(elm, oldChildren, newVNode2, newChildren, isInitialRender);
1848
+ } else if (newChildren !== null) {
1849
+ if (BUILD12.updatable && BUILD12.vdomText && oldVNode.$text$ !== null) {
1850
+ elm.textContent = "";
1851
+ }
1852
+ addVnodes(elm, null, newVNode2, newChildren, 0, newChildren.length - 1);
1853
+ } else if (
1854
+ // don't do this on initial render as it can cause non-hydrated content to be removed
1855
+ !isInitialRender && BUILD12.updatable && oldChildren !== null
1856
+ ) {
1857
+ removeVnodes(oldChildren, 0, oldChildren.length - 1);
1823
1858
  }
1824
- } else {
1825
- const slot = childVNode.$elm$;
1826
- const shouldMove = parentNodeId && parentNodeId !== childVNode.$hostId$ && parentVNode.$elm$.shadowRoot;
1827
- addSlottedNodes(slottedNodes, slotId, slotName, node, shouldMove ? parentNodeId : childVNode.$hostId$);
1828
- if (shouldMove) {
1829
- parentVNode.$elm$.insertBefore(slot, parentVNode.$elm$.children[0]);
1859
+ if (BUILD12.svg && isSvgMode && tag === "svg") {
1860
+ isSvgMode = false;
1830
1861
  }
1831
- childRenderNodes.push(childVNode);
1832
- }
1833
- slotNodes.push(childVNode);
1834
- if (!parentVNode.$children$) {
1835
- parentVNode.$children$ = [];
1836
- }
1837
- parentVNode.$children$[childVNode.$index$] = childVNode;
1838
- }
1839
- var addSlottedNodes = (slottedNodes, slotNodeId, slotName, slotNode, hostId) => {
1840
- let slottedNode = slotNode.nextSibling;
1841
- slottedNodes[slotNodeId] = slottedNodes[slotNodeId] || [];
1842
- while (slottedNode && ((slottedNode["getAttribute"] && slottedNode.getAttribute("slot") || slottedNode["s-sn"]) === slotName || slotName === "" && !slottedNode["s-sn"] && (slottedNode.nodeType === 8 /* CommentNode */ && slottedNode.nodeValue.indexOf(".") !== 1 || slottedNode.nodeType === 3 /* TextNode */))) {
1843
- slottedNode["s-sn"] = slotName;
1844
- slottedNodes[slotNodeId].push({ slot: slotNode, node: slottedNode, hostId });
1845
- slottedNode = slottedNode.nextSibling;
1862
+ } else if (BUILD12.vdomText && BUILD12.slotRelocation && (defaultHolder = elm["s-cr"])) {
1863
+ defaultHolder.parentNode.textContent = text;
1864
+ } else if (BUILD12.vdomText && oldVNode.$text$ !== text) {
1865
+ elm.data = text;
1846
1866
  }
1847
1867
  };
1848
-
1849
- // src/runtime/initialize-component.ts
1850
- import { BUILD as BUILD16 } from "@stencil/core/internal/app-data";
1851
-
1852
- // src/runtime/mode.ts
1853
- var computeMode = (elm) => modeResolutionChain.map((h2) => h2(elm)).find((m) => !!m);
1854
- var setMode = (handler) => modeResolutionChain.push(handler);
1855
- var getMode = (ref) => getHostRef(ref).$modeName$;
1856
-
1857
- // src/runtime/proxy-component.ts
1858
- import { BUILD as BUILD15 } from "@stencil/core/internal/app-data";
1859
-
1860
- // src/runtime/set-value.ts
1861
- import { BUILD as BUILD14 } from "@stencil/core/internal/app-data";
1862
-
1863
- // src/runtime/parse-property-value.ts
1864
- import { BUILD as BUILD9 } from "@stencil/core/internal/app-data";
1865
- var parsePropertyValue = (propValue, propType) => {
1866
- if (propValue != null && !isComplexType(propValue)) {
1867
- if (BUILD9.propBoolean && propType & 4 /* Boolean */) {
1868
- return propValue === "false" ? false : propValue === "" || !!propValue;
1869
- }
1870
- if (BUILD9.propNumber && propType & 2 /* Number */) {
1871
- return parseFloat(propValue);
1868
+ var relocateNodes = [];
1869
+ var markSlotContentForRelocation = (elm) => {
1870
+ let node;
1871
+ let hostContentNodes;
1872
+ let j;
1873
+ const children = elm.__childNodes || elm.childNodes;
1874
+ for (const childNode of children) {
1875
+ if (childNode["s-sr"] && (node = childNode["s-cr"]) && node.parentNode) {
1876
+ hostContentNodes = node.parentNode.__childNodes || node.parentNode.childNodes;
1877
+ const slotName = childNode["s-sn"];
1878
+ for (j = hostContentNodes.length - 1; j >= 0; j--) {
1879
+ node = hostContentNodes[j];
1880
+ if (!node["s-cn"] && !node["s-nr"] && node["s-hn"] !== childNode["s-hn"] && (!BUILD12.experimentalSlotFixes || !node["s-sh"] || node["s-sh"] !== childNode["s-hn"])) {
1881
+ if (isNodeLocatedInSlot(node, slotName)) {
1882
+ let relocateNodeData = relocateNodes.find((r) => r.$nodeToRelocate$ === node);
1883
+ checkSlotFallbackVisibility = true;
1884
+ node["s-sn"] = node["s-sn"] || slotName;
1885
+ if (relocateNodeData) {
1886
+ relocateNodeData.$nodeToRelocate$["s-sh"] = childNode["s-hn"];
1887
+ relocateNodeData.$slotRefNode$ = childNode;
1888
+ } else {
1889
+ node["s-sh"] = childNode["s-hn"];
1890
+ relocateNodes.push({
1891
+ $slotRefNode$: childNode,
1892
+ $nodeToRelocate$: node
1893
+ });
1894
+ }
1895
+ if (node["s-sr"]) {
1896
+ relocateNodes.map((relocateNode) => {
1897
+ if (isNodeLocatedInSlot(relocateNode.$nodeToRelocate$, node["s-sn"])) {
1898
+ relocateNodeData = relocateNodes.find((r) => r.$nodeToRelocate$ === node);
1899
+ if (relocateNodeData && !relocateNode.$slotRefNode$) {
1900
+ relocateNode.$slotRefNode$ = relocateNodeData.$slotRefNode$;
1901
+ }
1902
+ }
1903
+ });
1904
+ }
1905
+ } else if (!relocateNodes.some((r) => r.$nodeToRelocate$ === node)) {
1906
+ relocateNodes.push({
1907
+ $nodeToRelocate$: node
1908
+ });
1909
+ }
1910
+ }
1911
+ }
1872
1912
  }
1873
- if (BUILD9.propString && propType & 1 /* String */) {
1874
- return String(propValue);
1913
+ if (childNode.nodeType === 1 /* ElementNode */) {
1914
+ markSlotContentForRelocation(childNode);
1875
1915
  }
1876
- return propValue;
1877
1916
  }
1878
- return propValue;
1879
- };
1880
-
1881
- // src/runtime/update-component.ts
1882
- import { BUILD as BUILD13, NAMESPACE } from "@stencil/core/internal/app-data";
1883
-
1884
- // src/runtime/event-emitter.ts
1885
- import { BUILD as BUILD11 } from "@stencil/core/internal/app-data";
1886
-
1887
- // src/runtime/element.ts
1888
- import { BUILD as BUILD10 } from "@stencil/core/internal/app-data";
1889
- var getElement = (ref) => BUILD10.lazyLoad ? getHostRef(ref).$hostElement$ : ref;
1890
-
1891
- // src/runtime/event-emitter.ts
1892
- var createEvent = (ref, name, flags) => {
1893
- const elm = getElement(ref);
1894
- return {
1895
- emit: (detail) => {
1896
- if (BUILD11.isDev && !elm.isConnected) {
1897
- consoleDevWarn(`The "${name}" event was emitted, but the dispatcher node is no longer connected to the dom.`);
1898
- }
1899
- return emitEvent(elm, name, {
1900
- bubbles: !!(flags & 4 /* Bubbles */),
1901
- composed: !!(flags & 2 /* Composed */),
1902
- cancelable: !!(flags & 1 /* Cancellable */),
1903
- detail
1904
- });
1905
- }
1906
- };
1907
- };
1908
- var emitEvent = (elm, name, opts) => {
1909
- const ev = plt.ce(name, opts);
1910
- elm.dispatchEvent(ev);
1911
- return ev;
1912
1917
  };
1913
-
1914
- // src/runtime/styles.ts
1915
- import { BUILD as BUILD12 } from "@stencil/core/internal/app-data";
1916
- var rootAppliedStyles = /* @__PURE__ */ new WeakMap();
1917
- var registerStyle = (scopeId2, cssText, allowCS) => {
1918
- let style = styles.get(scopeId2);
1919
- if (supportsConstructableStylesheets && allowCS) {
1920
- style = style || new CSSStyleSheet();
1921
- if (typeof style === "string") {
1922
- style = cssText;
1923
- } else {
1924
- style.replaceSync(cssText);
1918
+ var nullifyVNodeRefs = (vNode) => {
1919
+ if (BUILD12.vdomRef) {
1920
+ vNode.$attrs$ && vNode.$attrs$.ref && vNode.$attrs$.ref(null);
1921
+ vNode.$children$ && vNode.$children$.map(nullifyVNodeRefs);
1922
+ }
1923
+ };
1924
+ var insertBefore = (parent, newNode, reference) => {
1925
+ if (BUILD12.scoped && typeof newNode["s-sn"] === "string" && !!newNode["s-sr"] && !!newNode["s-cr"]) {
1926
+ addRemoveSlotScopedClass(newNode["s-cr"], newNode, parent, newNode.parentElement);
1927
+ } else if (BUILD12.experimentalSlotFixes && typeof newNode["s-sn"] === "string") {
1928
+ if (parent.getRootNode().nodeType !== 11 /* DOCUMENT_FRAGMENT_NODE */) {
1929
+ patchParentNode(newNode);
1925
1930
  }
1931
+ return parent.insertBefore(newNode, reference);
1932
+ }
1933
+ if (BUILD12.experimentalSlotFixes && parent.__insertBefore) {
1934
+ return parent.__insertBefore(newNode, reference);
1926
1935
  } else {
1927
- style = cssText;
1936
+ return parent == null ? void 0 : parent.insertBefore(newNode, reference);
1928
1937
  }
1929
- styles.set(scopeId2, style);
1930
1938
  };
1931
- var addStyle = (styleContainerNode, cmpMeta, mode) => {
1939
+ function addRemoveSlotScopedClass(reference, slotNode, newParent, oldParent) {
1932
1940
  var _a;
1933
- const scopeId2 = getScopeId(cmpMeta, mode);
1934
- const style = styles.get(scopeId2);
1935
- if (!BUILD12.attachStyles) {
1936
- return scopeId2;
1941
+ let scopeId2;
1942
+ if (reference && typeof slotNode["s-sn"] === "string" && !!slotNode["s-sr"] && reference.parentNode && reference.parentNode["s-sc"] && (scopeId2 = slotNode["s-si"] || reference.parentNode["s-sc"])) {
1943
+ const scopeName = slotNode["s-sn"];
1944
+ const hostName = slotNode["s-hn"];
1945
+ (_a = newParent.classList) == null ? void 0 : _a.add(scopeId2 + "-s");
1946
+ if (oldParent && oldParent.classList.contains(scopeId2 + "-s")) {
1947
+ let child = (oldParent.__childNodes || oldParent.childNodes)[0];
1948
+ let found = false;
1949
+ while (child) {
1950
+ if (child["s-sn"] !== scopeName && child["s-hn"] === hostName && !!child["s-sr"]) {
1951
+ found = true;
1952
+ break;
1953
+ }
1954
+ child = child.nextSibling;
1955
+ }
1956
+ if (!found) oldParent.classList.remove(scopeId2 + "-s");
1957
+ }
1937
1958
  }
1938
- styleContainerNode = styleContainerNode.nodeType === 11 /* DocumentFragment */ ? styleContainerNode : doc;
1939
- if (style) {
1940
- if (typeof style === "string") {
1941
- styleContainerNode = styleContainerNode.head || styleContainerNode;
1942
- let appliedStyles = rootAppliedStyles.get(styleContainerNode);
1943
- let styleElm;
1944
- if (!appliedStyles) {
1945
- rootAppliedStyles.set(styleContainerNode, appliedStyles = /* @__PURE__ */ new Set());
1959
+ }
1960
+ var renderVdom = (hostRef, renderFnResults, isInitialLoad = false) => {
1961
+ var _a, _b, _c, _d, _e;
1962
+ const hostElm = hostRef.$hostElement$;
1963
+ const cmpMeta = hostRef.$cmpMeta$;
1964
+ const oldVNode = hostRef.$vnode$ || newVNode(null, null);
1965
+ const rootVnode = isHost(renderFnResults) ? renderFnResults : h(null, null, renderFnResults);
1966
+ hostTagName = hostElm.tagName;
1967
+ if (BUILD12.isDev && Array.isArray(renderFnResults) && renderFnResults.some(isHost)) {
1968
+ throw new Error(`The <Host> must be the single root component.
1969
+ Looks like the render() function of "${hostTagName.toLowerCase()}" is returning an array that contains the <Host>.
1970
+
1971
+ The render() function should look like this instead:
1972
+
1973
+ render() {
1974
+ // Do not return an array
1975
+ return (
1976
+ <Host>{content}</Host>
1977
+ );
1978
+ }
1979
+ `);
1980
+ }
1981
+ if (BUILD12.reflect && cmpMeta.$attrsToReflect$) {
1982
+ rootVnode.$attrs$ = rootVnode.$attrs$ || {};
1983
+ cmpMeta.$attrsToReflect$.map(
1984
+ ([propName, attribute]) => rootVnode.$attrs$[attribute] = hostElm[propName]
1985
+ );
1986
+ }
1987
+ if (isInitialLoad && rootVnode.$attrs$) {
1988
+ for (const key of Object.keys(rootVnode.$attrs$)) {
1989
+ if (hostElm.hasAttribute(key) && !["key", "ref", "style", "class"].includes(key)) {
1990
+ rootVnode.$attrs$[key] = hostElm[key];
1946
1991
  }
1947
- if (!appliedStyles.has(scopeId2)) {
1948
- if (BUILD12.hydrateClientSide && styleContainerNode.host && (styleElm = styleContainerNode.querySelector(`[${HYDRATED_STYLE_ID}="${scopeId2}"]`))) {
1949
- styleElm.innerHTML = style;
1950
- } else {
1951
- styleElm = document.querySelector(`[${HYDRATED_STYLE_ID}="${scopeId2}"]`) || doc.createElement("style");
1952
- styleElm.innerHTML = style;
1953
- const nonce = (_a = plt.$nonce$) != null ? _a : queryNonceMetaTagContent(doc);
1954
- if (nonce != null) {
1955
- styleElm.setAttribute("nonce", nonce);
1956
- }
1957
- if ((BUILD12.hydrateServerSide || BUILD12.hotModuleReplacement) && cmpMeta.$flags$ & 2 /* scopedCssEncapsulation */) {
1958
- styleElm.setAttribute(HYDRATED_STYLE_ID, scopeId2);
1959
- }
1960
- if (!(cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */)) {
1961
- if (styleContainerNode.nodeName === "HEAD") {
1962
- const preconnectLinks = styleContainerNode.querySelectorAll("link[rel=preconnect]");
1963
- const referenceNode2 = preconnectLinks.length > 0 ? preconnectLinks[preconnectLinks.length - 1].nextSibling : styleContainerNode.querySelector("style");
1964
- styleContainerNode.insertBefore(styleElm, referenceNode2);
1965
- } else if ("host" in styleContainerNode) {
1966
- if (supportsConstructableStylesheets) {
1967
- const stylesheet = new CSSStyleSheet();
1968
- stylesheet.replaceSync(style);
1969
- styleContainerNode.adoptedStyleSheets = [stylesheet, ...styleContainerNode.adoptedStyleSheets];
1970
- } else {
1971
- const existingStyleContainer = styleContainerNode.querySelector("style");
1972
- if (existingStyleContainer) {
1973
- existingStyleContainer.innerHTML = style + existingStyleContainer.innerHTML;
1974
- } else {
1975
- styleContainerNode.prepend(styleElm);
1992
+ }
1993
+ }
1994
+ rootVnode.$tag$ = null;
1995
+ rootVnode.$flags$ |= 4 /* isHost */;
1996
+ hostRef.$vnode$ = rootVnode;
1997
+ rootVnode.$elm$ = oldVNode.$elm$ = BUILD12.shadowDom ? hostElm.shadowRoot || hostElm : hostElm;
1998
+ if (BUILD12.scoped || BUILD12.shadowDom) {
1999
+ scopeId = hostElm["s-sc"];
2000
+ }
2001
+ useNativeShadowDom = supportsShadow && (cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) !== 0;
2002
+ if (BUILD12.slotRelocation) {
2003
+ contentRef = hostElm["s-cr"];
2004
+ checkSlotFallbackVisibility = false;
2005
+ }
2006
+ patch(oldVNode, rootVnode, isInitialLoad);
2007
+ if (BUILD12.slotRelocation) {
2008
+ plt.$flags$ |= 1 /* isTmpDisconnected */;
2009
+ if (checkSlotRelocate) {
2010
+ markSlotContentForRelocation(rootVnode.$elm$);
2011
+ for (const relocateData of relocateNodes) {
2012
+ const nodeToRelocate = relocateData.$nodeToRelocate$;
2013
+ if (!nodeToRelocate["s-ol"]) {
2014
+ const orgLocationNode = BUILD12.isDebug || BUILD12.hydrateServerSide ? originalLocationDebugNode(nodeToRelocate) : doc.createTextNode("");
2015
+ orgLocationNode["s-nr"] = nodeToRelocate;
2016
+ insertBefore(nodeToRelocate.parentNode, nodeToRelocate["s-ol"] = orgLocationNode, nodeToRelocate);
2017
+ }
2018
+ }
2019
+ for (const relocateData of relocateNodes) {
2020
+ const nodeToRelocate = relocateData.$nodeToRelocate$;
2021
+ const slotRefNode = relocateData.$slotRefNode$;
2022
+ if (slotRefNode) {
2023
+ const parentNodeRef = slotRefNode.parentNode;
2024
+ let insertBeforeNode = slotRefNode.nextSibling;
2025
+ if (!BUILD12.hydrateServerSide && (!BUILD12.experimentalSlotFixes || insertBeforeNode && insertBeforeNode.nodeType === 1 /* ElementNode */)) {
2026
+ let orgLocationNode = (_a = nodeToRelocate["s-ol"]) == null ? void 0 : _a.previousSibling;
2027
+ while (orgLocationNode) {
2028
+ let refNode = (_b = orgLocationNode["s-nr"]) != null ? _b : null;
2029
+ if (refNode && refNode["s-sn"] === nodeToRelocate["s-sn"] && parentNodeRef === (refNode.__parentNode || refNode.parentNode)) {
2030
+ refNode = refNode.nextSibling;
2031
+ while (refNode === nodeToRelocate || (refNode == null ? void 0 : refNode["s-sr"])) {
2032
+ refNode = refNode == null ? void 0 : refNode.nextSibling;
2033
+ }
2034
+ if (!refNode || !refNode["s-nr"]) {
2035
+ insertBeforeNode = refNode;
2036
+ break;
1976
2037
  }
1977
2038
  }
1978
- } else {
1979
- styleContainerNode.append(styleElm);
2039
+ orgLocationNode = orgLocationNode.previousSibling;
1980
2040
  }
1981
2041
  }
1982
- if (cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */ && styleContainerNode.nodeName !== "HEAD") {
1983
- styleContainerNode.insertBefore(styleElm, null);
2042
+ const parent = nodeToRelocate.__parentNode || nodeToRelocate.parentNode;
2043
+ const nextSibling = nodeToRelocate.__nextSibling || nodeToRelocate.nextSibling;
2044
+ if (!insertBeforeNode && parentNodeRef !== parent || nextSibling !== insertBeforeNode) {
2045
+ if (nodeToRelocate !== insertBeforeNode) {
2046
+ if (!BUILD12.experimentalSlotFixes && !nodeToRelocate["s-hn"] && nodeToRelocate["s-ol"]) {
2047
+ nodeToRelocate["s-hn"] = nodeToRelocate["s-ol"].parentNode.nodeName;
2048
+ }
2049
+ insertBefore(parentNodeRef, nodeToRelocate, insertBeforeNode);
2050
+ if (nodeToRelocate.nodeType === 1 /* ElementNode */ && nodeToRelocate.tagName !== "SLOT-FB") {
2051
+ nodeToRelocate.hidden = (_c = nodeToRelocate["s-ih"]) != null ? _c : false;
2052
+ }
2053
+ }
2054
+ }
2055
+ nodeToRelocate && typeof slotRefNode["s-rf"] === "function" && slotRefNode["s-rf"](nodeToRelocate);
2056
+ } else {
2057
+ if (nodeToRelocate.nodeType === 1 /* ElementNode */) {
2058
+ if (isInitialLoad) {
2059
+ nodeToRelocate["s-ih"] = (_d = nodeToRelocate.hidden) != null ? _d : false;
2060
+ }
2061
+ nodeToRelocate.hidden = true;
1984
2062
  }
1985
- }
1986
- if (cmpMeta.$flags$ & 4 /* hasSlotRelocation */) {
1987
- styleElm.innerHTML += SLOT_FB_CSS;
1988
- }
1989
- if (appliedStyles) {
1990
- appliedStyles.add(scopeId2);
1991
2063
  }
1992
2064
  }
1993
- } else if (BUILD12.constructableCSS && !styleContainerNode.adoptedStyleSheets.includes(style)) {
1994
- styleContainerNode.adoptedStyleSheets = [...styleContainerNode.adoptedStyleSheets, style];
1995
2065
  }
2066
+ if (checkSlotFallbackVisibility) {
2067
+ updateFallbackSlotVisibility(rootVnode.$elm$);
2068
+ }
2069
+ plt.$flags$ &= ~1 /* isTmpDisconnected */;
2070
+ relocateNodes.length = 0;
1996
2071
  }
1997
- return scopeId2;
1998
- };
1999
- var attachStyles = (hostRef) => {
2000
- const cmpMeta = hostRef.$cmpMeta$;
2001
- const elm = hostRef.$hostElement$;
2002
- const flags = cmpMeta.$flags$;
2003
- const endAttachStyles = createTime("attachStyles", cmpMeta.$tagName$);
2004
- const scopeId2 = addStyle(
2005
- BUILD12.shadowDom && supportsShadow && elm.shadowRoot ? elm.shadowRoot : elm.getRootNode(),
2006
- cmpMeta,
2007
- hostRef.$modeName$
2008
- );
2009
- if ((BUILD12.shadowDom || BUILD12.scoped) && BUILD12.cssAnnotations && flags & 10 /* needsScopedEncapsulation */ && flags & 2 /* scopedCssEncapsulation */) {
2010
- elm["s-sc"] = scopeId2;
2011
- elm.classList.add(scopeId2 + "-h");
2072
+ if (BUILD12.experimentalScopedSlotChanges && cmpMeta.$flags$ & 2 /* scopedCssEncapsulation */) {
2073
+ const children = rootVnode.$elm$.__childNodes || rootVnode.$elm$.childNodes;
2074
+ for (const childNode of children) {
2075
+ if (childNode["s-hn"] !== hostTagName && !childNode["s-sh"]) {
2076
+ if (isInitialLoad && childNode["s-ih"] == null) {
2077
+ childNode["s-ih"] = (_e = childNode.hidden) != null ? _e : false;
2078
+ }
2079
+ childNode.hidden = true;
2080
+ }
2081
+ }
2012
2082
  }
2013
- endAttachStyles();
2083
+ contentRef = void 0;
2014
2084
  };
2015
- var getScopeId = (cmp, mode) => "sc-" + (BUILD12.mode && mode && cmp.$flags$ & 32 /* hasMode */ ? cmp.$tagName$ + "-" + mode : cmp.$tagName$);
2085
+ var slotReferenceDebugNode = (slotVNode) => doc.createComment(
2086
+ `<slot${slotVNode.$name$ ? ' name="' + slotVNode.$name$ + '"' : ""}> (host=${hostTagName.toLowerCase()})`
2087
+ );
2088
+ var originalLocationDebugNode = (nodeToRelocate) => doc.createComment(
2089
+ `org-location for ` + (nodeToRelocate.localName ? `<${nodeToRelocate.localName}> (host=${nodeToRelocate["s-hn"]})` : `[${nodeToRelocate.textContent}]`)
2090
+ );
2016
2091
 
2017
2092
  // src/runtime/update-component.ts
2018
2093
  var attachToAncestor = (hostRef, ancestorComponent) => {
2019
2094
  if (BUILD13.asyncLoading && ancestorComponent && !hostRef.$onRenderResolve$ && ancestorComponent["s-p"]) {
2020
- ancestorComponent["s-p"].push(new Promise((r) => hostRef.$onRenderResolve$ = r));
2095
+ const index = ancestorComponent["s-p"].push(
2096
+ new Promise(
2097
+ (r) => hostRef.$onRenderResolve$ = () => {
2098
+ ancestorComponent["s-p"].splice(index - 1, 1);
2099
+ r();
2100
+ }
2101
+ )
2102
+ );
2021
2103
  }
2022
2104
  };
2023
2105
  var scheduleUpdate = (hostRef, isInitialLoad) => {
@@ -2388,77 +2470,91 @@ var proxyComponent = (Cstr, cmpMeta, flags) => {
2388
2470
  const members = Object.entries((_a = cmpMeta.$members$) != null ? _a : {});
2389
2471
  members.map(([memberName, [memberFlags]]) => {
2390
2472
  if ((BUILD15.prop || BUILD15.state) && (memberFlags & 31 /* Prop */ || (!BUILD15.lazyLoad || flags & 2 /* proxyState */) && memberFlags & 32 /* State */)) {
2391
- if ((memberFlags & 2048 /* Getter */) === 0) {
2473
+ const { get: origGetter, set: origSetter } = Object.getOwnPropertyDescriptor(prototype, memberName) || {};
2474
+ if (origGetter) cmpMeta.$members$[memberName][0] |= 2048 /* Getter */;
2475
+ if (origSetter) cmpMeta.$members$[memberName][0] |= 4096 /* Setter */;
2476
+ if (flags & 1 /* isElementConstructor */ || !origGetter) {
2392
2477
  Object.defineProperty(prototype, memberName, {
2393
2478
  get() {
2394
- return getValue(this, memberName);
2395
- },
2396
- set(newValue) {
2397
- if (BUILD15.isDev) {
2398
- const ref = getHostRef(this);
2399
- if (
2400
- // we are proxying the instance (not element)
2401
- (flags & 1 /* isElementConstructor */) === 0 && // the element is not constructing
2402
- (ref && ref.$flags$ & 8 /* isConstructingInstance */) === 0 && // the member is a prop
2403
- (memberFlags & 31 /* Prop */) !== 0 && // the member is not mutable
2404
- (memberFlags & 1024 /* Mutable */) === 0
2405
- ) {
2406
- consoleDevWarn(
2407
- `@Prop() "${memberName}" on <${cmpMeta.$tagName$}> is immutable but was modified from within the component.
2408
- More information: https://stenciljs.com/docs/properties#prop-mutability`
2409
- );
2479
+ if (BUILD15.lazyLoad) {
2480
+ if ((cmpMeta.$members$[memberName][0] & 2048 /* Getter */) === 0) {
2481
+ return getValue(this, memberName);
2410
2482
  }
2483
+ const ref = getHostRef(this);
2484
+ const instance = ref ? ref.$lazyInstance$ : prototype;
2485
+ if (!instance) return;
2486
+ return instance[memberName];
2487
+ }
2488
+ if (!BUILD15.lazyLoad) {
2489
+ return origGetter ? origGetter.apply(this) : getValue(this, memberName);
2411
2490
  }
2412
- setValue(this, memberName, newValue, cmpMeta);
2413
2491
  },
2414
2492
  configurable: true,
2415
2493
  enumerable: true
2416
2494
  });
2417
- } else if (flags & 1 /* isElementConstructor */ && memberFlags & 2048 /* Getter */) {
2418
- if (BUILD15.lazyLoad) {
2419
- Object.defineProperty(prototype, memberName, {
2420
- get() {
2421
- const ref = getHostRef(this);
2422
- const instance = BUILD15.lazyLoad && ref ? ref.$lazyInstance$ : prototype;
2423
- if (!instance) return;
2424
- return instance[memberName];
2425
- },
2426
- configurable: true,
2427
- enumerable: true
2428
- });
2429
- }
2430
- if (memberFlags & 4096 /* Setter */) {
2431
- const origSetter = Object.getOwnPropertyDescriptor(prototype, memberName).set;
2432
- Object.defineProperty(prototype, memberName, {
2433
- set(newValue) {
2434
- const ref = getHostRef(this);
2435
- if (origSetter) {
2436
- const currentValue = ref.$hostElement$[memberName];
2437
- if (!ref.$instanceValues$.get(memberName) && currentValue) {
2438
- ref.$instanceValues$.set(memberName, currentValue);
2439
- }
2440
- origSetter.apply(this, [parsePropertyValue(newValue, cmpMeta.$members$[memberName][0])]);
2441
- setValue(this, memberName, ref.$hostElement$[memberName], cmpMeta);
2442
- return;
2495
+ }
2496
+ Object.defineProperty(prototype, memberName, {
2497
+ set(newValue) {
2498
+ const ref = getHostRef(this);
2499
+ if (BUILD15.isDev) {
2500
+ if (
2501
+ // we are proxying the instance (not element)
2502
+ (flags & 1 /* isElementConstructor */) === 0 && // if the class has a setter, then the Element can update instance values, so ignore
2503
+ (cmpMeta.$members$[memberName][0] & 4096 /* Setter */) === 0 && // the element is not constructing
2504
+ (ref && ref.$flags$ & 8 /* isConstructingInstance */) === 0 && // the member is a prop
2505
+ (cmpMeta.$members$[memberName][0] & 31 /* Prop */) !== 0 && // the member is not mutable
2506
+ (cmpMeta.$members$[memberName][0] & 1024 /* Mutable */) === 0
2507
+ ) {
2508
+ consoleDevWarn(
2509
+ `@Prop() "${memberName}" on <${cmpMeta.$tagName$}> is immutable but was modified from within the component.
2510
+ More information: https://stenciljs.com/docs/properties#prop-mutability`
2511
+ );
2512
+ }
2513
+ }
2514
+ if (origSetter) {
2515
+ const currentValue = memberFlags & 32 /* State */ ? this[memberName] : ref.$hostElement$[memberName];
2516
+ if (typeof currentValue === "undefined" && ref.$instanceValues$.get(memberName)) {
2517
+ newValue = ref.$instanceValues$.get(memberName);
2518
+ } else if (!ref.$instanceValues$.get(memberName) && currentValue) {
2519
+ ref.$instanceValues$.set(memberName, currentValue);
2520
+ }
2521
+ origSetter.apply(this, [parsePropertyValue(newValue, memberFlags)]);
2522
+ newValue = memberFlags & 32 /* State */ ? this[memberName] : ref.$hostElement$[memberName];
2523
+ setValue(this, memberName, newValue, cmpMeta);
2524
+ return;
2525
+ }
2526
+ if (!BUILD15.lazyLoad) {
2527
+ setValue(this, memberName, newValue, cmpMeta);
2528
+ return;
2529
+ }
2530
+ if (BUILD15.lazyLoad) {
2531
+ if ((flags & 1 /* isElementConstructor */) === 0 || (cmpMeta.$members$[memberName][0] & 4096 /* Setter */) === 0) {
2532
+ setValue(this, memberName, newValue, cmpMeta);
2533
+ if (flags & 1 /* isElementConstructor */ && !ref.$lazyInstance$) {
2534
+ ref.$onReadyPromise$.then(() => {
2535
+ if (cmpMeta.$members$[memberName][0] & 4096 /* Setter */ && ref.$lazyInstance$[memberName] !== ref.$instanceValues$.get(memberName)) {
2536
+ ref.$lazyInstance$[memberName] = newValue;
2537
+ }
2538
+ });
2443
2539
  }
2444
- if (!ref) return;
2445
- const setterSetVal = () => {
2446
- const currentValue = ref.$lazyInstance$[memberName];
2447
- if (!ref.$instanceValues$.get(memberName) && currentValue) {
2448
- ref.$instanceValues$.set(memberName, currentValue);
2449
- }
2450
- ref.$lazyInstance$[memberName] = parsePropertyValue(newValue, cmpMeta.$members$[memberName][0]);
2451
- setValue(this, memberName, ref.$lazyInstance$[memberName], cmpMeta);
2452
- };
2453
- if (ref.$lazyInstance$) {
2454
- setterSetVal();
2455
- } else {
2456
- ref.$onReadyPromise$.then(() => setterSetVal());
2540
+ return;
2541
+ }
2542
+ const setterSetVal = () => {
2543
+ const currentValue = ref.$lazyInstance$[memberName];
2544
+ if (!ref.$instanceValues$.get(memberName) && currentValue) {
2545
+ ref.$instanceValues$.set(memberName, currentValue);
2457
2546
  }
2547
+ ref.$lazyInstance$[memberName] = parsePropertyValue(newValue, memberFlags);
2548
+ setValue(this, memberName, ref.$lazyInstance$[memberName], cmpMeta);
2549
+ };
2550
+ if (ref.$lazyInstance$) {
2551
+ setterSetVal();
2552
+ } else {
2553
+ ref.$onReadyPromise$.then(() => setterSetVal());
2458
2554
  }
2459
- });
2555
+ }
2460
2556
  }
2461
- }
2557
+ });
2462
2558
  } else if (BUILD15.lazyLoad && BUILD15.method && flags & 1 /* isElementConstructor */ && memberFlags & 64 /* Method */) {
2463
2559
  Object.defineProperty(prototype, memberName, {
2464
2560
  value(...args) {
@@ -2500,8 +2596,9 @@ More information: https://stenciljs.com/docs/properties#prop-mutability`
2500
2596
  return;
2501
2597
  }
2502
2598
  const propDesc = Object.getOwnPropertyDescriptor(prototype, propName);
2503
- if (!propDesc.get || !!propDesc.set) {
2504
- this[propName] = newValue === null && typeof this[propName] === "boolean" ? false : newValue;
2599
+ newValue = newValue === null && typeof this[propName] === "boolean" ? false : newValue;
2600
+ if (newValue !== this[propName] && (!propDesc.get || !!propDesc.set)) {
2601
+ this[propName] = newValue;
2505
2602
  }
2506
2603
  });
2507
2604
  };
@@ -3259,7 +3356,8 @@ import { globalScripts } from "@stencil/core/internal/app-globals";
3259
3356
 
3260
3357
  // src/hydrate/platform/proxy-host-element.ts
3261
3358
  import { BUILD as BUILD22 } from "@stencil/core/internal/app-data";
3262
- function proxyHostElement(elm, cmpMeta) {
3359
+ function proxyHostElement(elm, cstr) {
3360
+ const cmpMeta = cstr.cmpMeta;
3263
3361
  if (typeof elm.componentOnReady !== "function") {
3264
3362
  elm.componentOnReady = componentOnReady;
3265
3363
  }
@@ -3279,11 +3377,14 @@ function proxyHostElement(elm, cmpMeta) {
3279
3377
  if (cmpMeta.$members$ != null) {
3280
3378
  const hostRef = getHostRef(elm);
3281
3379
  const members = Object.entries(cmpMeta.$members$);
3282
- members.forEach(([memberName, m]) => {
3380
+ members.forEach(([memberName, [memberFlags, metaAttributeName]]) => {
3283
3381
  var _a, _b;
3284
- const memberFlags = m[0];
3285
3382
  if (memberFlags & 31 /* Prop */) {
3286
- const attributeName = m[1] || memberName;
3383
+ let getter2 = function() {
3384
+ return ![void 0, null].includes(parsedAttrValue) ? parsedAttrValue : origGetter ? origGetter.apply(this) : getValue(this, memberName);
3385
+ };
3386
+ var getter = getter2;
3387
+ const attributeName = metaAttributeName || memberName;
3287
3388
  let attrValue = elm.getAttribute(attributeName);
3288
3389
  if ((attrValue == null ? void 0 : attrValue.startsWith("{")) && attrValue.endsWith("}") || (attrValue == null ? void 0 : attrValue.startsWith("[")) && attrValue.endsWith("]")) {
3289
3390
  try {
@@ -3291,8 +3392,14 @@ function proxyHostElement(elm, cmpMeta) {
3291
3392
  } catch (e) {
3292
3393
  }
3293
3394
  }
3395
+ const { get: origGetter, set: origSetter } = Object.getOwnPropertyDescriptor(cstr.prototype, memberName) || {};
3396
+ let parsedAttrValue;
3294
3397
  if (attrValue != null) {
3295
- const parsedAttrValue = parsePropertyValue(attrValue, memberFlags);
3398
+ parsedAttrValue = parsePropertyValue(attrValue, memberFlags);
3399
+ if (origSetter) {
3400
+ origSetter.apply(elm, [parsedAttrValue]);
3401
+ parsedAttrValue = origGetter ? origGetter.apply(elm) : parsedAttrValue;
3402
+ }
3296
3403
  (_a = hostRef == null ? void 0 : hostRef.$instanceValues$) == null ? void 0 : _a.set(memberName, parsedAttrValue);
3297
3404
  }
3298
3405
  const ownValue = elm[memberName];
@@ -3301,15 +3408,18 @@ function proxyHostElement(elm, cmpMeta) {
3301
3408
  delete elm[memberName];
3302
3409
  }
3303
3410
  Object.defineProperty(elm, memberName, {
3304
- get() {
3305
- return getValue(this, memberName);
3306
- },
3411
+ get: getter2,
3307
3412
  set(newValue) {
3308
3413
  setValue(this, memberName, newValue, cmpMeta);
3309
3414
  },
3310
3415
  configurable: true,
3311
3416
  enumerable: true
3312
3417
  });
3418
+ Object.defineProperty(cstr.prototype, memberName, {
3419
+ get: getter2,
3420
+ configurable: true,
3421
+ enumerable: true
3422
+ });
3313
3423
  } else if (memberFlags & 64 /* Method */) {
3314
3424
  Object.defineProperty(elm, memberName, {
3315
3425
  value(...args) {
@@ -3386,7 +3496,7 @@ function hydrateApp(win2, opts, results, afterHydrate, resolve) {
3386
3496
  createdElements.add(elm);
3387
3497
  elm.connectedCallback = patchedConnectedCallback2;
3388
3498
  registerHost(elm, Cstr.cmpMeta);
3389
- proxyHostElement(elm, Cstr.cmpMeta);
3499
+ proxyHostElement(elm, Cstr);
3390
3500
  }
3391
3501
  }
3392
3502
  }