@rindo/core 4.23.2 → 4.26.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/cli/index.cjs +2 -5
  2. package/cli/index.js +2 -5
  3. package/cli/package.json +1 -1
  4. package/compiler/package.json +1 -1
  5. package/compiler/rindo.js +2463 -839
  6. package/dev-server/client/index.js +1 -1
  7. package/dev-server/client/package.json +1 -1
  8. package/dev-server/connector.html +2 -2
  9. package/dev-server/index.js +1 -1
  10. package/dev-server/package.json +1 -1
  11. package/dev-server/server-process.js +10 -10
  12. package/internal/app-data/package.json +1 -1
  13. package/internal/client/index.js +2389 -1873
  14. package/internal/client/package.json +1 -1
  15. package/internal/client/patch-browser.js +1 -1
  16. package/internal/client/shadow-css.js +30 -6
  17. package/internal/hydrate/index.js +2450 -1854
  18. package/internal/hydrate/package.json +1 -1
  19. package/internal/hydrate/runner.d.ts +22 -5
  20. package/internal/hydrate/runner.js +139 -45
  21. package/internal/package.json +1 -1
  22. package/internal/rindo-private.d.ts +70 -2
  23. package/internal/rindo-public-compiler.d.ts +31 -16
  24. package/internal/testing/index.js +2192 -1693
  25. package/internal/testing/package.json +1 -1
  26. package/mock-doc/index.cjs +71 -7
  27. package/mock-doc/index.d.ts +14 -1
  28. package/mock-doc/index.js +71 -7
  29. package/mock-doc/package.json +1 -1
  30. package/package.json +3 -3
  31. package/screenshot/index.js +1 -1
  32. package/screenshot/package.json +1 -1
  33. package/screenshot/pixel-match.js +1 -1
  34. package/sys/node/autoprefixer.js +2 -2
  35. package/sys/node/glob.js +1 -1
  36. package/sys/node/index.js +1 -1
  37. package/sys/node/package.json +1 -1
  38. package/sys/node/worker.js +1 -1
  39. package/testing/index.js +28 -19
  40. package/testing/jest/jest-27-and-under/matchers/html.d.ts +2 -1
  41. package/testing/jest/jest-28/matchers/html.d.ts +2 -1
  42. package/testing/jest/jest-29/matchers/html.d.ts +2 -1
  43. package/testing/package.json +1 -1
@@ -1,9 +1,7 @@
1
1
  "use strict";
2
- var __create = Object.create;
3
2
  var __defProp = Object.defineProperty;
4
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
6
  var __export = (target, all) => {
9
7
  for (var name in all)
@@ -17,14 +15,6 @@ var __copyProps = (to, from, except, desc) => {
17
15
  }
18
16
  return to;
19
17
  };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
19
 
30
20
  // src/testing/platform/index.ts
@@ -411,6 +401,11 @@ function queryNonceMetaTagContent(doc2) {
411
401
  return (_c = (_b = (_a = doc2.head) == null ? void 0 : _a.querySelector('meta[name="csp-nonce"]')) == null ? void 0 : _b.getAttribute("content")) != null ? _c : void 0;
412
402
  }
413
403
 
404
+ // src/utils/regular-expression.ts
405
+ var escapeRegExpSpecialCharacters = (text) => {
406
+ return text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
407
+ };
408
+
414
409
  // src/utils/result.ts
415
410
  var result_exports = {};
416
411
  __export(result_exports, {
@@ -464,10 +459,13 @@ var unwrapErr = (result) => {
464
459
  var import_app_data17 = require("@rindo/core/internal/app-data");
465
460
 
466
461
  // src/runtime/client-hydrate.ts
467
- var import_app_data8 = require("@rindo/core/internal/app-data");
462
+ var import_app_data5 = require("@rindo/core/internal/app-data");
468
463
 
469
464
  // src/runtime/dom-extras.ts
470
- var import_app_data6 = require("@rindo/core/internal/app-data");
465
+ var import_app_data2 = require("@rindo/core/internal/app-data");
466
+
467
+ // src/runtime/slot-polyfill-utils.ts
468
+ var import_app_data = require("@rindo/core/internal/app-data");
471
469
 
472
470
  // src/runtime/runtime-constants.ts
473
471
  var CONTENT_REF_ID = "r";
@@ -495,7 +493,6 @@ var FORM_ASSOCIATED_CUSTOM_ELEMENT_CALLBACKS = [
495
493
  ];
496
494
 
497
495
  // src/runtime/slot-polyfill-utils.ts
498
- var import_app_data = require("@rindo/core/internal/app-data");
499
496
  var updateFallbackSlotVisibility = (elm) => {
500
497
  const childNodes = elm.__childNodes || elm.childNodes;
501
498
  if (elm.tagName && elm.tagName.includes("-") && elm["s-cr"] && elm.tagName !== "SLOT-FB") {
@@ -519,27 +516,27 @@ var updateFallbackSlotVisibility = (elm) => {
519
516
  var getSlottedChildNodes = (childNodes) => {
520
517
  const result = [];
521
518
  for (let i2 = 0; i2 < childNodes.length; i2++) {
522
- const slottedNode = childNodes[i2]["s-nr"];
519
+ const slottedNode = childNodes[i2]["s-nr"] || void 0;
523
520
  if (slottedNode && slottedNode.isConnected) {
524
521
  result.push(slottedNode);
525
522
  }
526
523
  }
527
524
  return result;
528
525
  };
529
- var getHostSlotNodes = (childNodes, hostName, slotName) => {
526
+ function getHostSlotNodes(childNodes, hostName, slotName) {
530
527
  let i2 = 0;
531
528
  let slottedNodes = [];
532
529
  let childNode;
533
530
  for (; i2 < childNodes.length; i2++) {
534
531
  childNode = childNodes[i2];
535
- if (childNode["s-sr"] && childNode["s-hn"] === hostName && (!slotName || childNode["s-sn"] === slotName)) {
532
+ if (childNode["s-sr"] && childNode["s-hn"] === hostName && (slotName === void 0 || childNode["s-sn"] === slotName)) {
536
533
  slottedNodes.push(childNode);
537
534
  if (typeof slotName !== "undefined") return slottedNodes;
538
535
  }
539
536
  slottedNodes = [...slottedNodes, ...getHostSlotNodes(childNode.childNodes, hostName, slotName)];
540
537
  }
541
538
  return slottedNodes;
542
- };
539
+ }
543
540
  var getHostSlotChildNodes = (node, slotName, includeSlot = true) => {
544
541
  const childNodes = [];
545
542
  if (includeSlot && node["s-sr"] || !node["s-sr"]) childNodes.push(node);
@@ -597,1801 +594,2276 @@ var addSlotRelocateNode = (newChild, slotNode, prepend, position) => {
597
594
  };
598
595
  var getSlotName = (node) => node["s-sn"] || node.nodeType === 1 && node.getAttribute("slot") || "";
599
596
 
600
- // src/runtime/vdom/vdom-render.ts
601
- var import_app_data5 = require("@rindo/core/internal/app-data");
602
-
603
- // src/runtime/vdom/h.ts
604
- var import_app_data2 = require("@rindo/core/internal/app-data");
605
- var h = (nodeName, vnodeData, ...children) => {
606
- let child = null;
607
- let key = null;
608
- let slotName = null;
609
- let simple = false;
610
- let lastSimple = false;
611
- const vNodeChildren = [];
612
- const walk = (c) => {
613
- for (let i2 = 0; i2 < c.length; i2++) {
614
- child = c[i2];
615
- if (Array.isArray(child)) {
616
- walk(child);
617
- } else if (child != null && typeof child !== "boolean") {
618
- if (simple = typeof nodeName !== "function" && !isComplexType(child)) {
619
- child = String(child);
620
- } else if (import_app_data2.BUILD.isDev && typeof nodeName !== "function" && child.$flags$ === void 0) {
621
- consoleDevError(`vNode passed as children has unexpected type.
622
- Make sure it's using the correct h() function.
623
- Empty objects can also be the cause, look for JSX comments that became objects.`);
597
+ // src/runtime/dom-extras.ts
598
+ var patchPseudoShadowDom = (hostElementPrototype) => {
599
+ patchCloneNode(hostElementPrototype);
600
+ patchSlotAppendChild(hostElementPrototype);
601
+ patchSlotAppend(hostElementPrototype);
602
+ patchSlotPrepend(hostElementPrototype);
603
+ patchSlotInsertAdjacentElement(hostElementPrototype);
604
+ patchSlotInsertAdjacentHTML(hostElementPrototype);
605
+ patchSlotInsertAdjacentText(hostElementPrototype);
606
+ patchInsertBefore(hostElementPrototype);
607
+ patchTextContent(hostElementPrototype);
608
+ patchChildSlotNodes(hostElementPrototype);
609
+ patchSlotRemoveChild(hostElementPrototype);
610
+ };
611
+ var patchCloneNode = (HostElementPrototype) => {
612
+ const orgCloneNode = HostElementPrototype.cloneNode;
613
+ HostElementPrototype.cloneNode = function(deep) {
614
+ const srcNode = this;
615
+ const isShadowDom = import_app_data2.BUILD.shadowDom ? srcNode.shadowRoot && supportsShadow : false;
616
+ const clonedNode = orgCloneNode.call(srcNode, isShadowDom ? deep : false);
617
+ if (import_app_data2.BUILD.slot && !isShadowDom && deep) {
618
+ let i2 = 0;
619
+ let slotted, nonRindoNode;
620
+ const rindoPrivates = [
621
+ "s-id",
622
+ "s-cr",
623
+ "s-lr",
624
+ "s-rc",
625
+ "s-sc",
626
+ "s-p",
627
+ "s-cn",
628
+ "s-sr",
629
+ "s-sn",
630
+ "s-hn",
631
+ "s-ol",
632
+ "s-nr",
633
+ "s-si",
634
+ "s-rf",
635
+ "s-scs"
636
+ ];
637
+ const childNodes = this.__childNodes || this.childNodes;
638
+ for (; i2 < childNodes.length; i2++) {
639
+ slotted = childNodes[i2]["s-nr"];
640
+ nonRindoNode = rindoPrivates.every((privateField) => !childNodes[i2][privateField]);
641
+ if (slotted) {
642
+ if (import_app_data2.BUILD.appendChildSlotFix && clonedNode.__appendChild) {
643
+ clonedNode.__appendChild(slotted.cloneNode(true));
644
+ } else {
645
+ clonedNode.appendChild(slotted.cloneNode(true));
646
+ }
624
647
  }
625
- if (simple && lastSimple) {
626
- vNodeChildren[vNodeChildren.length - 1].$text$ += child;
627
- } else {
628
- vNodeChildren.push(simple ? newVNode(null, child) : child);
648
+ if (nonRindoNode) {
649
+ clonedNode.appendChild(childNodes[i2].cloneNode(true));
629
650
  }
630
- lastSimple = simple;
631
651
  }
632
652
  }
653
+ return clonedNode;
633
654
  };
634
- walk(children);
635
- if (vnodeData) {
636
- if (import_app_data2.BUILD.isDev && nodeName === "input") {
637
- validateInputProperties(vnodeData);
638
- }
639
- if (import_app_data2.BUILD.vdomKey && vnodeData.key) {
640
- key = vnodeData.key;
641
- }
642
- if (import_app_data2.BUILD.slotRelocation && vnodeData.name) {
643
- slotName = vnodeData.name;
655
+ };
656
+ var patchSlotAppendChild = (HostElementPrototype) => {
657
+ HostElementPrototype.__appendChild = HostElementPrototype.appendChild;
658
+ HostElementPrototype.appendChild = function(newChild) {
659
+ const slotName = newChild["s-sn"] = getSlotName(newChild);
660
+ const slotNode = getHostSlotNodes(this.__childNodes || this.childNodes, this.tagName, slotName)[0];
661
+ if (slotNode) {
662
+ addSlotRelocateNode(newChild, slotNode);
663
+ const slotChildNodes = getHostSlotChildNodes(slotNode, slotName);
664
+ const appendAfter = slotChildNodes[slotChildNodes.length - 1];
665
+ const parent = intrnlCall(appendAfter, "parentNode");
666
+ let insertedNode;
667
+ if (parent.__insertBefore) {
668
+ insertedNode = parent.__insertBefore(newChild, appendAfter.nextSibling);
669
+ } else {
670
+ insertedNode = parent.insertBefore(newChild, appendAfter.nextSibling);
671
+ }
672
+ updateFallbackSlotVisibility(this);
673
+ return insertedNode;
644
674
  }
645
- if (import_app_data2.BUILD.vdomClass) {
646
- const classData = vnodeData.className || vnodeData.class;
647
- if (classData) {
648
- vnodeData.class = typeof classData !== "object" ? classData : Object.keys(classData).filter((k) => classData[k]).join(" ");
675
+ return this.__appendChild(newChild);
676
+ };
677
+ };
678
+ var patchSlotRemoveChild = (ElementPrototype) => {
679
+ ElementPrototype.__removeChild = ElementPrototype.removeChild;
680
+ ElementPrototype.removeChild = function(toRemove) {
681
+ if (toRemove && typeof toRemove["s-sn"] !== "undefined") {
682
+ const childNodes = this.__childNodes || this.childNodes;
683
+ const slotNode = getHostSlotNodes(childNodes, this.tagName, toRemove["s-sn"]);
684
+ if (slotNode && toRemove.isConnected) {
685
+ toRemove.remove();
686
+ updateFallbackSlotVisibility(this);
687
+ return;
649
688
  }
650
689
  }
651
- }
652
- if (import_app_data2.BUILD.isDev && vNodeChildren.some(isHost)) {
653
- consoleDevError(`The <Host> must be the single root component. Make sure:
654
- - You are NOT using hostData() and <Host> in the same component.
655
- - <Host> is used once, and it's the single root component of the render() function.`);
656
- }
657
- if (import_app_data2.BUILD.vdomFunctional && typeof nodeName === "function") {
658
- return nodeName(
659
- vnodeData === null ? {} : vnodeData,
660
- vNodeChildren,
661
- vdomFnUtils
662
- );
663
- }
664
- const vnode = newVNode(nodeName, null);
665
- vnode.$attrs$ = vnodeData;
666
- if (vNodeChildren.length > 0) {
667
- vnode.$children$ = vNodeChildren;
668
- }
669
- if (import_app_data2.BUILD.vdomKey) {
670
- vnode.$key$ = key;
671
- }
672
- if (import_app_data2.BUILD.slotRelocation) {
673
- vnode.$name$ = slotName;
674
- }
675
- return vnode;
690
+ return this.__removeChild(toRemove);
691
+ };
676
692
  };
677
- var newVNode = (tag, text) => {
678
- const vnode = {
679
- $flags$: 0,
680
- $tag$: tag,
681
- $text$: text,
682
- $elm$: null,
683
- $children$: null
693
+ var patchSlotPrepend = (HostElementPrototype) => {
694
+ HostElementPrototype.__prepend = HostElementPrototype.prepend;
695
+ HostElementPrototype.prepend = function(...newChildren) {
696
+ newChildren.forEach((newChild) => {
697
+ if (typeof newChild === "string") {
698
+ newChild = this.ownerDocument.createTextNode(newChild);
699
+ }
700
+ const slotName = newChild["s-sn"] = getSlotName(newChild);
701
+ const childNodes = this.__childNodes || this.childNodes;
702
+ const slotNode = getHostSlotNodes(childNodes, this.tagName, slotName)[0];
703
+ if (slotNode) {
704
+ addSlotRelocateNode(newChild, slotNode, true);
705
+ const slotChildNodes = getHostSlotChildNodes(slotNode, slotName);
706
+ const appendAfter = slotChildNodes[0];
707
+ const parent = intrnlCall(appendAfter, "parentNode");
708
+ if (parent.__insertBefore) {
709
+ return parent.__insertBefore(newChild, intrnlCall(appendAfter, "nextSibling"));
710
+ } else {
711
+ return parent.insertBefore(newChild, intrnlCall(appendAfter, "nextSibling"));
712
+ }
713
+ }
714
+ if (newChild.nodeType === 1 && !!newChild.getAttribute("slot")) {
715
+ newChild.hidden = true;
716
+ }
717
+ return HostElementPrototype.__prepend(newChild);
718
+ });
684
719
  };
685
- if (import_app_data2.BUILD.vdomAttribute) {
686
- vnode.$attrs$ = null;
687
- }
688
- if (import_app_data2.BUILD.vdomKey) {
689
- vnode.$key$ = null;
690
- }
691
- if (import_app_data2.BUILD.slotRelocation) {
692
- vnode.$name$ = null;
693
- }
694
- return vnode;
695
720
  };
696
- var Host = {};
697
- var isHost = (node) => node && node.$tag$ === Host;
698
- var vdomFnUtils = {
699
- forEach: (children, cb) => children.map(convertToPublic).forEach(cb),
700
- map: (children, cb) => children.map(convertToPublic).map(cb).map(convertToPrivate)
721
+ var patchSlotAppend = (HostElementPrototype) => {
722
+ HostElementPrototype.__append = HostElementPrototype.append;
723
+ HostElementPrototype.append = function(...newChildren) {
724
+ newChildren.forEach((newChild) => {
725
+ if (typeof newChild === "string") {
726
+ newChild = this.ownerDocument.createTextNode(newChild);
727
+ }
728
+ this.appendChild(newChild);
729
+ });
730
+ };
701
731
  };
702
- var convertToPublic = (node) => ({
703
- vattrs: node.$attrs$,
704
- vchildren: node.$children$,
705
- vkey: node.$key$,
706
- vname: node.$name$,
707
- vtag: node.$tag$,
708
- vtext: node.$text$
709
- });
710
- var convertToPrivate = (node) => {
711
- if (typeof node.vtag === "function") {
712
- const vnodeData = { ...node.vattrs };
713
- if (node.vkey) {
714
- vnodeData.key = node.vkey;
732
+ var patchSlotInsertAdjacentHTML = (HostElementPrototype) => {
733
+ const originalInsertAdjacentHtml = HostElementPrototype.insertAdjacentHTML;
734
+ HostElementPrototype.insertAdjacentHTML = function(position, text) {
735
+ if (position !== "afterbegin" && position !== "beforeend") {
736
+ return originalInsertAdjacentHtml.call(this, position, text);
715
737
  }
716
- if (node.vname) {
717
- vnodeData.name = node.vname;
738
+ const container = this.ownerDocument.createElement("_");
739
+ let node;
740
+ container.innerHTML = text;
741
+ if (position === "afterbegin") {
742
+ while (node = container.firstChild) {
743
+ this.prepend(node);
744
+ }
745
+ } else if (position === "beforeend") {
746
+ while (node = container.firstChild) {
747
+ this.append(node);
748
+ }
718
749
  }
719
- return h(node.vtag, vnodeData, ...node.vchildren || []);
720
- }
721
- const vnode = newVNode(node.vtag, node.vtext);
722
- vnode.$attrs$ = node.vattrs;
723
- vnode.$children$ = node.vchildren;
724
- vnode.$key$ = node.vkey;
725
- vnode.$name$ = node.vname;
726
- return vnode;
727
- };
728
- var validateInputProperties = (inputElm) => {
729
- const props = Object.keys(inputElm);
730
- const value = props.indexOf("value");
731
- if (value === -1) {
732
- return;
733
- }
734
- const typeIndex = props.indexOf("type");
735
- const minIndex = props.indexOf("min");
736
- const maxIndex = props.indexOf("max");
737
- const stepIndex = props.indexOf("step");
738
- if (value < typeIndex || value < minIndex || value < maxIndex || value < stepIndex) {
739
- consoleDevWarn(`The "value" prop of <input> should be set after "min", "max", "type" and "step"`);
740
- }
750
+ };
741
751
  };
742
-
743
- // src/runtime/vdom/update-element.ts
744
- var import_app_data4 = require("@rindo/core/internal/app-data");
745
-
746
- // src/runtime/vdom/set-accessor.ts
747
- var import_app_data3 = require("@rindo/core/internal/app-data");
748
- var setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
749
- if (oldValue !== newValue) {
750
- let isProp = isMemberInElement(elm, memberName);
751
- let ln = memberName.toLowerCase();
752
- if (import_app_data3.BUILD.vdomClass && memberName === "class") {
753
- const classList = elm.classList;
754
- const oldClasses = parseClassList(oldValue);
755
- let newClasses = parseClassList(newValue);
756
- if (elm["s-si"]) {
757
- newClasses.push(elm["s-si"]);
758
- oldClasses.forEach((c) => {
759
- if (c.startsWith(elm["s-si"])) newClasses.push(c);
760
- });
761
- newClasses = [...new Set(newClasses)];
762
- classList.add(...newClasses);
763
- delete elm["s-si"];
764
- } else {
765
- classList.remove(...oldClasses.filter((c) => c && !newClasses.includes(c)));
766
- classList.add(...newClasses.filter((c) => c && !oldClasses.includes(c)));
767
- }
768
- } else if (import_app_data3.BUILD.vdomStyle && memberName === "style") {
769
- if (import_app_data3.BUILD.updatable) {
770
- for (const prop in oldValue) {
771
- if (!newValue || newValue[prop] == null) {
772
- if (!import_app_data3.BUILD.hydrateServerSide && prop.includes("-")) {
773
- elm.style.removeProperty(prop);
774
- } else {
775
- elm.style[prop] = "";
776
- }
777
- }
778
- }
779
- }
780
- for (const prop in newValue) {
781
- if (!oldValue || newValue[prop] !== oldValue[prop]) {
782
- if (!import_app_data3.BUILD.hydrateServerSide && prop.includes("-")) {
783
- elm.style.setProperty(prop, newValue[prop]);
784
- } else {
785
- elm.style[prop] = newValue[prop];
752
+ var patchSlotInsertAdjacentText = (HostElementPrototype) => {
753
+ HostElementPrototype.insertAdjacentText = function(position, text) {
754
+ this.insertAdjacentHTML(position, text);
755
+ };
756
+ };
757
+ var patchInsertBefore = (HostElementPrototype) => {
758
+ const eleProto = HostElementPrototype;
759
+ if (eleProto.__insertBefore) return;
760
+ eleProto.__insertBefore = HostElementPrototype.insertBefore;
761
+ HostElementPrototype.insertBefore = function(newChild, currentChild) {
762
+ const slotName = newChild["s-sn"] = getSlotName(newChild);
763
+ const slotNode = getHostSlotNodes(this.__childNodes, this.tagName, slotName)[0];
764
+ const slottedNodes = this.__childNodes ? this.childNodes : getSlottedChildNodes(this.childNodes);
765
+ if (slotNode) {
766
+ let found = false;
767
+ slottedNodes.forEach((childNode) => {
768
+ if (childNode === currentChild || currentChild === null) {
769
+ found = true;
770
+ if (currentChild === null || slotName !== currentChild["s-sn"]) {
771
+ this.appendChild(newChild);
772
+ return;
786
773
  }
787
- }
788
- }
789
- } else if (import_app_data3.BUILD.vdomKey && memberName === "key") {
790
- } else if (import_app_data3.BUILD.vdomRef && memberName === "ref") {
791
- if (newValue) {
792
- newValue(elm);
793
- }
794
- } else if (import_app_data3.BUILD.vdomListener && (import_app_data3.BUILD.lazyLoad ? !isProp : !elm.__lookupSetter__(memberName)) && memberName[0] === "o" && memberName[1] === "n") {
795
- if (memberName[2] === "-") {
796
- memberName = memberName.slice(3);
797
- } else if (isMemberInElement(win, ln)) {
798
- memberName = ln.slice(2);
799
- } else {
800
- memberName = ln[2] + memberName.slice(3);
801
- }
802
- if (oldValue || newValue) {
803
- const capture = memberName.endsWith(CAPTURE_EVENT_SUFFIX);
804
- memberName = memberName.replace(CAPTURE_EVENT_REGEX, "");
805
- if (oldValue) {
806
- plt.rel(elm, memberName, oldValue, capture);
807
- }
808
- if (newValue) {
809
- plt.ael(elm, memberName, newValue, capture);
810
- }
811
- }
812
- } else if (import_app_data3.BUILD.vdomPropOrAttr) {
813
- const isComplex = isComplexType(newValue);
814
- if ((isProp || isComplex && newValue !== null) && !isSvg) {
815
- try {
816
- if (!elm.tagName.includes("-")) {
817
- const n = newValue == null ? "" : newValue;
818
- if (memberName === "list") {
819
- isProp = false;
820
- } else if (oldValue == null || elm[memberName] != n) {
821
- if (typeof elm.__lookupSetter__(memberName) === "function") {
822
- elm[memberName] = n;
823
- } else {
824
- elm.setAttribute(memberName, n);
825
- }
774
+ if (slotName === currentChild["s-sn"]) {
775
+ addSlotRelocateNode(newChild, slotNode);
776
+ const parent = intrnlCall(currentChild, "parentNode");
777
+ if (parent.__insertBefore) {
778
+ parent.__insertBefore(newChild, currentChild);
779
+ } else {
780
+ parent.insertBefore(newChild, currentChild);
826
781
  }
827
- } else {
828
- elm[memberName] = newValue;
829
- }
830
- } catch (e) {
831
- }
832
- }
833
- let xlink = false;
834
- if (import_app_data3.BUILD.vdomXlink) {
835
- if (ln !== (ln = ln.replace(/^xlink\:?/, ""))) {
836
- memberName = ln;
837
- xlink = true;
838
- }
839
- }
840
- if (newValue == null || newValue === false) {
841
- if (newValue !== false || elm.getAttribute(memberName) === "") {
842
- if (import_app_data3.BUILD.vdomXlink && xlink) {
843
- elm.removeAttributeNS(XLINK_NS, memberName);
844
- } else {
845
- elm.removeAttribute(memberName);
846
782
  }
783
+ return;
847
784
  }
848
- } else if ((!isProp || flags & 4 /* isHost */ || isSvg) && !isComplex) {
849
- newValue = newValue === true ? "" : newValue;
850
- if (import_app_data3.BUILD.vdomXlink && xlink) {
851
- elm.setAttributeNS(XLINK_NS, memberName, newValue);
852
- } else {
853
- elm.setAttribute(memberName, newValue);
854
- }
855
- }
785
+ });
786
+ if (found) return newChild;
856
787
  }
857
- }
788
+ return this.__insertBefore(newChild, currentChild);
789
+ };
858
790
  };
859
- var parseClassListRegex = /\s/;
860
- var parseClassList = (value) => {
861
- if (typeof value === "object" && "baseVal" in value) {
862
- value = value.baseVal;
863
- }
864
- if (!value) {
865
- return [];
866
- }
867
- return value.split(parseClassListRegex);
791
+ var patchSlotInsertAdjacentElement = (HostElementPrototype) => {
792
+ const originalInsertAdjacentElement = HostElementPrototype.insertAdjacentElement;
793
+ HostElementPrototype.insertAdjacentElement = function(position, element) {
794
+ if (position !== "afterbegin" && position !== "beforeend") {
795
+ return originalInsertAdjacentElement.call(this, position, element);
796
+ }
797
+ if (position === "afterbegin") {
798
+ this.prepend(element);
799
+ return element;
800
+ } else if (position === "beforeend") {
801
+ this.append(element);
802
+ return element;
803
+ }
804
+ return element;
805
+ };
868
806
  };
869
- var CAPTURE_EVENT_SUFFIX = "Capture";
870
- var CAPTURE_EVENT_REGEX = new RegExp(CAPTURE_EVENT_SUFFIX + "$");
871
-
872
- // src/runtime/vdom/update-element.ts
873
- var updateElement = (oldVnode, newVnode, isSvgMode2) => {
874
- const elm = newVnode.$elm$.nodeType === 11 /* DocumentFragment */ && newVnode.$elm$.host ? newVnode.$elm$.host : newVnode.$elm$;
875
- const oldVnodeAttrs = oldVnode && oldVnode.$attrs$ || {};
876
- const newVnodeAttrs = newVnode.$attrs$ || {};
877
- if (import_app_data4.BUILD.updatable) {
878
- for (const memberName of sortedAttrNames(Object.keys(oldVnodeAttrs))) {
879
- if (!(memberName in newVnodeAttrs)) {
880
- setAccessor(elm, memberName, oldVnodeAttrs[memberName], void 0, isSvgMode2, newVnode.$flags$);
881
- }
807
+ var patchTextContent = (hostElementPrototype) => {
808
+ patchHostOriginalAccessor("textContent", hostElementPrototype);
809
+ Object.defineProperty(hostElementPrototype, "textContent", {
810
+ get: function() {
811
+ let text = "";
812
+ const childNodes = this.__childNodes ? this.childNodes : getSlottedChildNodes(this.childNodes);
813
+ childNodes.forEach((node) => text += node.textContent || "");
814
+ return text;
815
+ },
816
+ set: function(value) {
817
+ const childNodes = this.__childNodes ? this.childNodes : getSlottedChildNodes(this.childNodes);
818
+ childNodes.forEach((node) => {
819
+ if (node["s-ol"]) node["s-ol"].remove();
820
+ node.remove();
821
+ });
822
+ this.insertAdjacentHTML("beforeend", value);
882
823
  }
883
- }
884
- for (const memberName of sortedAttrNames(Object.keys(newVnodeAttrs))) {
885
- setAccessor(elm, memberName, oldVnodeAttrs[memberName], newVnodeAttrs[memberName], isSvgMode2, newVnode.$flags$);
886
- }
824
+ });
887
825
  };
888
- function sortedAttrNames(attrNames) {
889
- return attrNames.includes("ref") ? (
890
- // we need to sort these to ensure that `'ref'` is the last attr
891
- [...attrNames.filter((attr) => attr !== "ref"), "ref"]
892
- ) : (
893
- // no need to sort, return the original array
894
- attrNames
895
- );
896
- }
897
-
898
- // src/runtime/vdom/vdom-render.ts
899
- var scopeId;
900
- var contentRef;
901
- var hostTagName;
902
- var useNativeShadowDom = false;
903
- var checkSlotFallbackVisibility = false;
904
- var checkSlotRelocate = false;
905
- var isSvgMode = false;
906
- var createElm = (oldParentVNode, newParentVNode, childIndex) => {
907
- var _a;
908
- const newVNode2 = newParentVNode.$children$[childIndex];
909
- let i2 = 0;
910
- let elm;
911
- let childNode;
912
- let oldVNode;
913
- if (import_app_data5.BUILD.slotRelocation && !useNativeShadowDom) {
914
- checkSlotRelocate = true;
915
- if (newVNode2.$tag$ === "slot") {
916
- newVNode2.$flags$ |= newVNode2.$children$ ? (
917
- // slot element has fallback content
918
- // still create an element that "mocks" the slot element
919
- 2 /* isSlotFallback */
920
- ) : (
921
- // slot element does not have fallback content
922
- // create an html comment we'll use to always reference
923
- // where actual slot content should sit next to
924
- 1 /* isSlotReference */
925
- );
826
+ var patchChildSlotNodes = (elm) => {
827
+ class FakeNodeList extends Array {
828
+ item(n) {
829
+ return this[n];
926
830
  }
927
831
  }
928
- if (import_app_data5.BUILD.isDev && newVNode2.$elm$) {
929
- consoleDevError(
930
- `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://rindojs.web.app/docs/templating-jsx#avoid-shared-jsx-nodes`
931
- );
932
- }
933
- if (import_app_data5.BUILD.vdomText && newVNode2.$text$ !== null) {
934
- elm = newVNode2.$elm$ = doc.createTextNode(newVNode2.$text$);
935
- } else if (import_app_data5.BUILD.slotRelocation && newVNode2.$flags$ & 1 /* isSlotReference */) {
936
- elm = newVNode2.$elm$ = import_app_data5.BUILD.isDebug || import_app_data5.BUILD.hydrateServerSide ? slotReferenceDebugNode(newVNode2) : doc.createTextNode("");
937
- } else {
938
- if (import_app_data5.BUILD.svg && !isSvgMode) {
939
- isSvgMode = newVNode2.$tag$ === "svg";
940
- }
941
- elm = newVNode2.$elm$ = import_app_data5.BUILD.svg ? doc.createElementNS(
942
- isSvgMode ? SVG_NS : HTML_NS,
943
- !useNativeShadowDom && import_app_data5.BUILD.slotRelocation && newVNode2.$flags$ & 2 /* isSlotFallback */ ? "slot-fb" : newVNode2.$tag$
944
- ) : doc.createElement(
945
- !useNativeShadowDom && import_app_data5.BUILD.slotRelocation && newVNode2.$flags$ & 2 /* isSlotFallback */ ? "slot-fb" : newVNode2.$tag$
946
- );
947
- if (import_app_data5.BUILD.svg && isSvgMode && newVNode2.$tag$ === "foreignObject") {
948
- isSvgMode = false;
832
+ patchHostOriginalAccessor("children", elm);
833
+ Object.defineProperty(elm, "children", {
834
+ get() {
835
+ return this.childNodes.filter((n) => n.nodeType === 1);
949
836
  }
950
- if (import_app_data5.BUILD.vdomAttribute) {
951
- updateElement(null, newVNode2, isSvgMode);
837
+ });
838
+ Object.defineProperty(elm, "childElementCount", {
839
+ get() {
840
+ return this.children.length;
952
841
  }
953
- if (import_app_data5.BUILD.scoped && isDef(scopeId) && elm["s-si"] !== scopeId) {
954
- elm.classList.add(elm["s-si"] = scopeId);
842
+ });
843
+ patchHostOriginalAccessor("firstChild", elm);
844
+ Object.defineProperty(elm, "firstChild", {
845
+ get() {
846
+ return this.childNodes[0];
955
847
  }
956
- if (newVNode2.$children$) {
957
- for (i2 = 0; i2 < newVNode2.$children$.length; ++i2) {
958
- childNode = createElm(oldParentVNode, newVNode2, i2);
959
- if (childNode) {
960
- elm.appendChild(childNode);
961
- }
962
- }
848
+ });
849
+ patchHostOriginalAccessor("lastChild", elm);
850
+ Object.defineProperty(elm, "lastChild", {
851
+ get() {
852
+ return this.childNodes[this.childNodes.length - 1];
963
853
  }
964
- if (import_app_data5.BUILD.svg) {
965
- if (newVNode2.$tag$ === "svg") {
966
- isSvgMode = false;
967
- } else if (elm.tagName === "foreignObject") {
968
- isSvgMode = true;
969
- }
970
- }
971
- }
972
- elm["s-hn"] = hostTagName;
973
- if (import_app_data5.BUILD.slotRelocation) {
974
- if (newVNode2.$flags$ & (2 /* isSlotFallback */ | 1 /* isSlotReference */)) {
975
- elm["s-sr"] = true;
976
- elm["s-cr"] = contentRef;
977
- elm["s-sn"] = newVNode2.$name$ || "";
978
- elm["s-rf"] = (_a = newVNode2.$attrs$) == null ? void 0 : _a.ref;
979
- oldVNode = oldParentVNode && oldParentVNode.$children$ && oldParentVNode.$children$[childIndex];
980
- if (oldVNode && oldVNode.$tag$ === newVNode2.$tag$ && oldParentVNode.$elm$) {
981
- if (import_app_data5.BUILD.experimentalSlotFixes) {
982
- relocateToHostRoot(oldParentVNode.$elm$);
983
- } else {
984
- putBackInOriginalLocation(oldParentVNode.$elm$, false);
985
- }
986
- }
987
- if (import_app_data5.BUILD.scoped) {
988
- addRemoveSlotScopedClass(contentRef, elm, newParentVNode.$elm$, oldParentVNode == null ? void 0 : oldParentVNode.$elm$);
989
- }
854
+ });
855
+ patchHostOriginalAccessor("childNodes", elm);
856
+ Object.defineProperty(elm, "childNodes", {
857
+ get() {
858
+ const result = new FakeNodeList();
859
+ result.push(...getSlottedChildNodes(this.__childNodes));
860
+ return result;
990
861
  }
862
+ });
863
+ };
864
+ var patchSlottedNode = (node) => {
865
+ if (!node || node.__nextSibling || !globalThis.Node) return;
866
+ patchNextSibling(node);
867
+ patchPreviousSibling(node);
868
+ patchParentNode(node);
869
+ if (node.nodeType === Node.ELEMENT_NODE) {
870
+ patchNextElementSibling(node);
871
+ patchPreviousElementSibling(node);
991
872
  }
992
- return elm;
993
873
  };
994
- var relocateToHostRoot = (parentElm) => {
995
- plt.$flags$ |= 1 /* isTmpDisconnected */;
996
- const host = parentElm.closest(hostTagName.toLowerCase());
997
- if (host != null) {
998
- const contentRefNode = Array.from(host.__childNodes || host.childNodes).find(
999
- (ref) => ref["s-cr"]
1000
- );
1001
- const childNodeArray = Array.from(
1002
- parentElm.__childNodes || parentElm.childNodes
1003
- );
1004
- for (const childNode of contentRefNode ? childNodeArray.reverse() : childNodeArray) {
1005
- if (childNode["s-sh"] != null) {
1006
- insertBefore(host, childNode, contentRefNode != null ? contentRefNode : null);
1007
- childNode["s-sh"] = void 0;
1008
- checkSlotRelocate = true;
874
+ var patchNextSibling = (node) => {
875
+ if (!node || node.__nextSibling) return;
876
+ patchHostOriginalAccessor("nextSibling", node);
877
+ Object.defineProperty(node, "nextSibling", {
878
+ get: function() {
879
+ var _a;
880
+ const parentNodes = (_a = this["s-ol"]) == null ? void 0 : _a.parentNode.childNodes;
881
+ const index = parentNodes == null ? void 0 : parentNodes.indexOf(this);
882
+ if (parentNodes && index > -1) {
883
+ return parentNodes[index + 1];
1009
884
  }
885
+ return this.__nextSibling;
1010
886
  }
1011
- }
1012
- plt.$flags$ &= ~1 /* isTmpDisconnected */;
887
+ });
1013
888
  };
1014
- var putBackInOriginalLocation = (parentElm, recursive) => {
1015
- plt.$flags$ |= 1 /* isTmpDisconnected */;
1016
- const oldSlotChildNodes = Array.from(parentElm.__childNodes || parentElm.childNodes);
1017
- if (parentElm["s-sr"] && import_app_data5.BUILD.experimentalSlotFixes) {
1018
- let node = parentElm;
1019
- while (node = node.nextSibling) {
1020
- if (node && node["s-sn"] === parentElm["s-sn"] && node["s-sh"] === hostTagName) {
1021
- oldSlotChildNodes.push(node);
889
+ var patchNextElementSibling = (element) => {
890
+ if (!element || element.__nextElementSibling) return;
891
+ patchHostOriginalAccessor("nextElementSibling", element);
892
+ Object.defineProperty(element, "nextElementSibling", {
893
+ get: function() {
894
+ var _a;
895
+ const parentEles = (_a = this["s-ol"]) == null ? void 0 : _a.parentNode.children;
896
+ const index = parentEles == null ? void 0 : parentEles.indexOf(this);
897
+ if (parentEles && index > -1) {
898
+ return parentEles[index + 1];
1022
899
  }
900
+ return this.__nextElementSibling;
1023
901
  }
1024
- }
1025
- for (let i2 = oldSlotChildNodes.length - 1; i2 >= 0; i2--) {
1026
- const childNode = oldSlotChildNodes[i2];
1027
- if (childNode["s-hn"] !== hostTagName && childNode["s-ol"]) {
1028
- insertBefore(referenceNode(childNode).parentNode, childNode, referenceNode(childNode));
1029
- childNode["s-ol"].remove();
1030
- childNode["s-ol"] = void 0;
1031
- childNode["s-sh"] = void 0;
1032
- checkSlotRelocate = true;
1033
- }
1034
- if (recursive) {
1035
- putBackInOriginalLocation(childNode, recursive);
1036
- }
1037
- }
1038
- plt.$flags$ &= ~1 /* isTmpDisconnected */;
902
+ });
1039
903
  };
1040
- var addVnodes = (parentElm, before, parentVNode, vnodes, startIdx, endIdx) => {
1041
- let containerElm = import_app_data5.BUILD.slotRelocation && parentElm["s-cr"] && parentElm["s-cr"].parentNode || parentElm;
1042
- let childNode;
1043
- if (import_app_data5.BUILD.shadowDom && containerElm.shadowRoot && containerElm.tagName === hostTagName) {
1044
- containerElm = containerElm.shadowRoot;
1045
- }
1046
- for (; startIdx <= endIdx; ++startIdx) {
1047
- if (vnodes[startIdx]) {
1048
- childNode = createElm(null, parentVNode, startIdx);
1049
- if (childNode) {
1050
- vnodes[startIdx].$elm$ = childNode;
1051
- insertBefore(containerElm, childNode, import_app_data5.BUILD.slotRelocation ? referenceNode(before) : before);
904
+ var patchPreviousSibling = (node) => {
905
+ if (!node || node.__previousSibling) return;
906
+ patchHostOriginalAccessor("previousSibling", node);
907
+ Object.defineProperty(node, "previousSibling", {
908
+ get: function() {
909
+ var _a;
910
+ const parentNodes = (_a = this["s-ol"]) == null ? void 0 : _a.parentNode.childNodes;
911
+ const index = parentNodes == null ? void 0 : parentNodes.indexOf(this);
912
+ if (parentNodes && index > -1) {
913
+ return parentNodes[index - 1];
1052
914
  }
915
+ return this.__previousSibling;
1053
916
  }
1054
- }
917
+ });
1055
918
  };
1056
- var removeVnodes = (vnodes, startIdx, endIdx) => {
1057
- for (let index = startIdx; index <= endIdx; ++index) {
1058
- const vnode = vnodes[index];
1059
- if (vnode) {
1060
- const elm = vnode.$elm$;
1061
- nullifyVNodeRefs(vnode);
1062
- if (elm) {
1063
- if (import_app_data5.BUILD.slotRelocation) {
1064
- checkSlotFallbackVisibility = true;
1065
- if (elm["s-ol"]) {
1066
- elm["s-ol"].remove();
1067
- } else {
1068
- putBackInOriginalLocation(elm, true);
1069
- }
1070
- }
1071
- elm.remove();
919
+ var patchPreviousElementSibling = (element) => {
920
+ if (!element || element.__previousElementSibling) return;
921
+ patchHostOriginalAccessor("previousElementSibling", element);
922
+ Object.defineProperty(element, "previousElementSibling", {
923
+ get: function() {
924
+ var _a;
925
+ const parentNodes = (_a = this["s-ol"]) == null ? void 0 : _a.parentNode.children;
926
+ const index = parentNodes == null ? void 0 : parentNodes.indexOf(this);
927
+ if (parentNodes && index > -1) {
928
+ return parentNodes[index - 1];
1072
929
  }
930
+ return this.__previousElementSibling;
1073
931
  }
1074
- }
932
+ });
1075
933
  };
1076
- var updateChildren = (parentElm, oldCh, newVNode2, newCh, isInitialRender = false) => {
1077
- let oldStartIdx = 0;
1078
- let newStartIdx = 0;
1079
- let idxInOld = 0;
1080
- let i2 = 0;
1081
- let oldEndIdx = oldCh.length - 1;
1082
- let oldStartVnode = oldCh[0];
1083
- let oldEndVnode = oldCh[oldEndIdx];
1084
- let newEndIdx = newCh.length - 1;
1085
- let newStartVnode = newCh[0];
1086
- let newEndVnode = newCh[newEndIdx];
1087
- let node;
1088
- let elmToMove;
1089
- while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
1090
- if (oldStartVnode == null) {
1091
- oldStartVnode = oldCh[++oldStartIdx];
1092
- } else if (oldEndVnode == null) {
1093
- oldEndVnode = oldCh[--oldEndIdx];
1094
- } else if (newStartVnode == null) {
1095
- newStartVnode = newCh[++newStartIdx];
1096
- } else if (newEndVnode == null) {
1097
- newEndVnode = newCh[--newEndIdx];
1098
- } else if (isSameVnode(oldStartVnode, newStartVnode, isInitialRender)) {
1099
- patch(oldStartVnode, newStartVnode, isInitialRender);
1100
- oldStartVnode = oldCh[++oldStartIdx];
1101
- newStartVnode = newCh[++newStartIdx];
1102
- } else if (isSameVnode(oldEndVnode, newEndVnode, isInitialRender)) {
1103
- patch(oldEndVnode, newEndVnode, isInitialRender);
1104
- oldEndVnode = oldCh[--oldEndIdx];
1105
- newEndVnode = newCh[--newEndIdx];
1106
- } else if (isSameVnode(oldStartVnode, newEndVnode, isInitialRender)) {
1107
- if (import_app_data5.BUILD.slotRelocation && (oldStartVnode.$tag$ === "slot" || newEndVnode.$tag$ === "slot")) {
1108
- putBackInOriginalLocation(oldStartVnode.$elm$.parentNode, false);
1109
- }
1110
- patch(oldStartVnode, newEndVnode, isInitialRender);
1111
- insertBefore(parentElm, oldStartVnode.$elm$, oldEndVnode.$elm$.nextSibling);
1112
- oldStartVnode = oldCh[++oldStartIdx];
1113
- newEndVnode = newCh[--newEndIdx];
1114
- } else if (isSameVnode(oldEndVnode, newStartVnode, isInitialRender)) {
1115
- if (import_app_data5.BUILD.slotRelocation && (oldStartVnode.$tag$ === "slot" || newEndVnode.$tag$ === "slot")) {
1116
- putBackInOriginalLocation(oldEndVnode.$elm$.parentNode, false);
1117
- }
1118
- patch(oldEndVnode, newStartVnode, isInitialRender);
1119
- insertBefore(parentElm, oldEndVnode.$elm$, oldStartVnode.$elm$);
1120
- oldEndVnode = oldCh[--oldEndIdx];
1121
- newStartVnode = newCh[++newStartIdx];
1122
- } else {
1123
- idxInOld = -1;
1124
- if (import_app_data5.BUILD.vdomKey) {
1125
- for (i2 = oldStartIdx; i2 <= oldEndIdx; ++i2) {
1126
- if (oldCh[i2] && oldCh[i2].$key$ !== null && oldCh[i2].$key$ === newStartVnode.$key$) {
1127
- idxInOld = i2;
1128
- break;
1129
- }
1130
- }
1131
- }
1132
- if (import_app_data5.BUILD.vdomKey && idxInOld >= 0) {
1133
- elmToMove = oldCh[idxInOld];
1134
- if (elmToMove.$tag$ !== newStartVnode.$tag$) {
1135
- node = createElm(oldCh && oldCh[newStartIdx], newVNode2, idxInOld);
1136
- } else {
1137
- patch(elmToMove, newStartVnode, isInitialRender);
1138
- oldCh[idxInOld] = void 0;
1139
- node = elmToMove.$elm$;
1140
- }
1141
- newStartVnode = newCh[++newStartIdx];
1142
- } else {
1143
- node = createElm(oldCh && oldCh[newStartIdx], newVNode2, newStartIdx);
1144
- newStartVnode = newCh[++newStartIdx];
1145
- }
1146
- if (node) {
1147
- if (import_app_data5.BUILD.slotRelocation) {
1148
- insertBefore(
1149
- referenceNode(oldStartVnode.$elm$).parentNode,
1150
- node,
1151
- referenceNode(oldStartVnode.$elm$)
1152
- );
1153
- } else {
1154
- insertBefore(oldStartVnode.$elm$.parentNode, node, oldStartVnode.$elm$);
1155
- }
1156
- }
934
+ var patchParentNode = (node) => {
935
+ if (!node || node.__parentNode) return;
936
+ patchHostOriginalAccessor("parentNode", node);
937
+ Object.defineProperty(node, "parentNode", {
938
+ get: function() {
939
+ var _a;
940
+ return ((_a = this["s-ol"]) == null ? void 0 : _a.parentNode) || this.__parentNode;
941
+ },
942
+ set: function(value) {
943
+ this.__parentNode = value;
1157
944
  }
945
+ });
946
+ };
947
+ var validElementPatches = ["children", "nextElementSibling", "previousElementSibling"];
948
+ var validNodesPatches = [
949
+ "childNodes",
950
+ "firstChild",
951
+ "lastChild",
952
+ "nextSibling",
953
+ "previousSibling",
954
+ "textContent",
955
+ "parentNode"
956
+ ];
957
+ function patchHostOriginalAccessor(accessorName, node) {
958
+ let accessor;
959
+ if (validElementPatches.includes(accessorName)) {
960
+ accessor = Object.getOwnPropertyDescriptor(Element.prototype, accessorName);
961
+ } else if (validNodesPatches.includes(accessorName)) {
962
+ accessor = Object.getOwnPropertyDescriptor(Node.prototype, accessorName);
1158
963
  }
1159
- if (oldStartIdx > oldEndIdx) {
1160
- addVnodes(
1161
- parentElm,
1162
- newCh[newEndIdx + 1] == null ? null : newCh[newEndIdx + 1].$elm$,
1163
- newVNode2,
1164
- newCh,
1165
- newStartIdx,
1166
- newEndIdx
1167
- );
1168
- } else if (import_app_data5.BUILD.updatable && newStartIdx > newEndIdx) {
1169
- removeVnodes(oldCh, oldStartIdx, oldEndIdx);
964
+ if (!accessor) {
965
+ accessor = Object.getOwnPropertyDescriptor(node, accessorName);
1170
966
  }
1171
- };
1172
- var isSameVnode = (leftVNode, rightVNode, isInitialRender = false) => {
1173
- if (leftVNode.$tag$ === rightVNode.$tag$) {
1174
- if (import_app_data5.BUILD.slotRelocation && leftVNode.$tag$ === "slot") {
1175
- return leftVNode.$name$ === rightVNode.$name$;
1176
- }
1177
- if (import_app_data5.BUILD.vdomKey && !isInitialRender) {
1178
- return leftVNode.$key$ === rightVNode.$key$;
1179
- }
1180
- if (isInitialRender && !leftVNode.$key$ && rightVNode.$key$) {
1181
- leftVNode.$key$ = rightVNode.$key$;
1182
- }
1183
- return true;
967
+ if (accessor) Object.defineProperty(node, "__" + accessorName, accessor);
968
+ }
969
+ function intrnlCall(node, method) {
970
+ if ("__" + method in node) {
971
+ return node["__" + method];
972
+ } else {
973
+ return node[method];
1184
974
  }
1185
- return false;
1186
- };
1187
- var referenceNode = (node) => node && node["s-ol"] || node;
1188
- var patch = (oldVNode, newVNode2, isInitialRender = false) => {
1189
- const elm = newVNode2.$elm$ = oldVNode.$elm$;
1190
- const oldChildren = oldVNode.$children$;
1191
- const newChildren = newVNode2.$children$;
1192
- const tag = newVNode2.$tag$;
1193
- const text = newVNode2.$text$;
1194
- let defaultHolder;
1195
- if (!import_app_data5.BUILD.vdomText || text === null) {
1196
- if (import_app_data5.BUILD.svg) {
1197
- isSvgMode = tag === "svg" ? true : tag === "foreignObject" ? false : isSvgMode;
1198
- }
1199
- if (import_app_data5.BUILD.vdomAttribute || import_app_data5.BUILD.reflect) {
1200
- if (import_app_data5.BUILD.slot && tag === "slot" && !useNativeShadowDom) {
1201
- if (import_app_data5.BUILD.experimentalSlotFixes && oldVNode.$name$ !== newVNode2.$name$) {
1202
- newVNode2.$elm$["s-sn"] = newVNode2.$name$ || "";
1203
- relocateToHostRoot(newVNode2.$elm$.parentElement);
1204
- }
1205
- } else {
1206
- updateElement(oldVNode, newVNode2, isSvgMode);
1207
- }
1208
- }
1209
- if (import_app_data5.BUILD.updatable && oldChildren !== null && newChildren !== null) {
1210
- updateChildren(elm, oldChildren, newVNode2, newChildren, isInitialRender);
1211
- } else if (newChildren !== null) {
1212
- if (import_app_data5.BUILD.updatable && import_app_data5.BUILD.vdomText && oldVNode.$text$ !== null) {
1213
- elm.textContent = "";
1214
- }
1215
- addVnodes(elm, null, newVNode2, newChildren, 0, newChildren.length - 1);
1216
- } else if (
1217
- // don't do this on initial render as it can cause non-hydrated content to be removed
1218
- !isInitialRender && import_app_data5.BUILD.updatable && oldChildren !== null
1219
- ) {
1220
- removeVnodes(oldChildren, 0, oldChildren.length - 1);
1221
- }
1222
- if (import_app_data5.BUILD.svg && isSvgMode && tag === "svg") {
1223
- isSvgMode = false;
1224
- }
1225
- } else if (import_app_data5.BUILD.vdomText && import_app_data5.BUILD.slotRelocation && (defaultHolder = elm["s-cr"])) {
1226
- defaultHolder.parentNode.textContent = text;
1227
- } else if (import_app_data5.BUILD.vdomText && oldVNode.$text$ !== text) {
1228
- elm.data = text;
975
+ }
976
+
977
+ // src/runtime/profile.ts
978
+ var import_app_data3 = require("@rindo/core/internal/app-data");
979
+ var i = 0;
980
+ var createTime = (fnName, tagName = "") => {
981
+ if (import_app_data3.BUILD.profile && performance.mark) {
982
+ const key = `st:${fnName}:${tagName}:${i++}`;
983
+ performance.mark(key);
984
+ return () => performance.measure(`[Rindo] ${fnName}() <${tagName}>`, key);
985
+ } else {
986
+ return () => {
987
+ return;
988
+ };
1229
989
  }
1230
990
  };
1231
- var relocateNodes = [];
1232
- var markSlotContentForRelocation = (elm) => {
1233
- let node;
1234
- let hostContentNodes;
1235
- let j;
1236
- const children = elm.__childNodes || elm.childNodes;
1237
- for (const childNode of children) {
1238
- if (childNode["s-sr"] && (node = childNode["s-cr"]) && node.parentNode) {
1239
- hostContentNodes = node.parentNode.__childNodes || node.parentNode.childNodes;
1240
- const slotName = childNode["s-sn"];
1241
- for (j = hostContentNodes.length - 1; j >= 0; j--) {
1242
- node = hostContentNodes[j];
1243
- if (!node["s-cn"] && !node["s-nr"] && node["s-hn"] !== childNode["s-hn"] && (!import_app_data5.BUILD.experimentalSlotFixes || !node["s-sh"] || node["s-sh"] !== childNode["s-hn"])) {
1244
- if (isNodeLocatedInSlot(node, slotName)) {
1245
- let relocateNodeData = relocateNodes.find((r) => r.$nodeToRelocate$ === node);
1246
- checkSlotFallbackVisibility = true;
1247
- node["s-sn"] = node["s-sn"] || slotName;
1248
- if (relocateNodeData) {
1249
- relocateNodeData.$nodeToRelocate$["s-sh"] = childNode["s-hn"];
1250
- relocateNodeData.$slotRefNode$ = childNode;
1251
- } else {
1252
- node["s-sh"] = childNode["s-hn"];
1253
- relocateNodes.push({
1254
- $slotRefNode$: childNode,
1255
- $nodeToRelocate$: node
1256
- });
1257
- }
1258
- if (node["s-sr"]) {
1259
- relocateNodes.map((relocateNode) => {
1260
- if (isNodeLocatedInSlot(relocateNode.$nodeToRelocate$, node["s-sn"])) {
1261
- relocateNodeData = relocateNodes.find((r) => r.$nodeToRelocate$ === node);
1262
- if (relocateNodeData && !relocateNode.$slotRefNode$) {
1263
- relocateNode.$slotRefNode$ = relocateNodeData.$slotRefNode$;
1264
- }
1265
- }
1266
- });
1267
- }
1268
- } else if (!relocateNodes.some((r) => r.$nodeToRelocate$ === node)) {
1269
- relocateNodes.push({
1270
- $nodeToRelocate$: node
1271
- });
1272
- }
1273
- }
1274
- }
1275
- }
1276
- if (childNode.nodeType === 1 /* ElementNode */) {
1277
- markSlotContentForRelocation(childNode);
991
+ var uniqueTime = (key, measureText) => {
992
+ if (import_app_data3.BUILD.profile && performance.mark) {
993
+ if (performance.getEntriesByName(key, "mark").length === 0) {
994
+ performance.mark(key);
1278
995
  }
996
+ return () => {
997
+ if (performance.getEntriesByName(measureText, "measure").length === 0) {
998
+ performance.measure(measureText, key);
999
+ }
1000
+ };
1001
+ } else {
1002
+ return () => {
1003
+ return;
1004
+ };
1279
1005
  }
1280
1006
  };
1281
- var nullifyVNodeRefs = (vNode) => {
1282
- if (import_app_data5.BUILD.vdomRef) {
1283
- vNode.$attrs$ && vNode.$attrs$.ref && vNode.$attrs$.ref(null);
1284
- vNode.$children$ && vNode.$children$.map(nullifyVNodeRefs);
1007
+ var inspect = (ref) => {
1008
+ const hostRef = getHostRef(ref);
1009
+ if (!hostRef) {
1010
+ return void 0;
1285
1011
  }
1012
+ const flags = hostRef.$flags$;
1013
+ const hostElement = hostRef.$hostElement$;
1014
+ return {
1015
+ renderCount: hostRef.$renderCount$,
1016
+ flags: {
1017
+ hasRendered: !!(flags & 2 /* hasRendered */),
1018
+ hasConnected: !!(flags & 1 /* hasConnected */),
1019
+ isWaitingForChildren: !!(flags & 4 /* isWaitingForChildren */),
1020
+ isConstructingInstance: !!(flags & 8 /* isConstructingInstance */),
1021
+ isQueuedForUpdate: !!(flags & 16 /* isQueuedForUpdate */),
1022
+ hasInitializedComponent: !!(flags & 32 /* hasInitializedComponent */),
1023
+ hasLoadedComponent: !!(flags & 64 /* hasLoadedComponent */),
1024
+ isWatchReady: !!(flags & 128 /* isWatchReady */),
1025
+ isListenReady: !!(flags & 256 /* isListenReady */),
1026
+ needsRerender: !!(flags & 512 /* needsRerender */)
1027
+ },
1028
+ instanceValues: hostRef.$instanceValues$,
1029
+ ancestorComponent: hostRef.$ancestorComponent$,
1030
+ hostElement,
1031
+ lazyInstance: hostRef.$lazyInstance$,
1032
+ vnode: hostRef.$vnode$,
1033
+ modeName: hostRef.$modeName$,
1034
+ onReadyPromise: hostRef.$onReadyPromise$,
1035
+ onReadyResolve: hostRef.$onReadyResolve$,
1036
+ onInstancePromise: hostRef.$onInstancePromise$,
1037
+ onInstanceResolve: hostRef.$onInstanceResolve$,
1038
+ onRenderResolve: hostRef.$onRenderResolve$,
1039
+ queuedListeners: hostRef.$queuedListeners$,
1040
+ rmListeners: hostRef.$rmListeners$,
1041
+ ["s-id"]: hostElement["s-id"],
1042
+ ["s-cr"]: hostElement["s-cr"],
1043
+ ["s-lr"]: hostElement["s-lr"],
1044
+ ["s-p"]: hostElement["s-p"],
1045
+ ["s-rc"]: hostElement["s-rc"],
1046
+ ["s-sc"]: hostElement["s-sc"]
1047
+ };
1286
1048
  };
1287
- var insertBefore = (parent, newNode, reference) => {
1288
- if (import_app_data5.BUILD.scoped && typeof newNode["s-sn"] === "string" && !!newNode["s-sr"] && !!newNode["s-cr"]) {
1289
- addRemoveSlotScopedClass(newNode["s-cr"], newNode, parent, newNode.parentElement);
1049
+ var installDevTools = () => {
1050
+ if (import_app_data3.BUILD.devTools) {
1051
+ const rindo = win.rindo = win.rindo || {};
1052
+ const originalInspect = rindo.inspect;
1053
+ rindo.inspect = (ref) => {
1054
+ let result = inspect(ref);
1055
+ if (!result && typeof originalInspect === "function") {
1056
+ result = originalInspect(ref);
1057
+ }
1058
+ return result;
1059
+ };
1290
1060
  }
1291
- const inserted = parent == null ? void 0 : parent.insertBefore(newNode, reference);
1292
- return inserted;
1293
1061
  };
1294
- function addRemoveSlotScopedClass(reference, slotNode, newParent, oldParent) {
1295
- var _a;
1296
- let scopeId2;
1297
- if (reference && typeof slotNode["s-sn"] === "string" && !!slotNode["s-sr"] && reference.parentNode && reference.parentNode["s-sc"] && (scopeId2 = slotNode["s-si"] || reference.parentNode["s-sc"])) {
1298
- const scopeName = slotNode["s-sn"];
1299
- const hostName = slotNode["s-hn"];
1300
- (_a = newParent.classList) == null ? void 0 : _a.add(scopeId2 + "-s");
1301
- if (oldParent && oldParent.classList.contains(scopeId2 + "-s")) {
1302
- let child = (oldParent.__childNodes || oldParent.childNodes)[0];
1303
- let found = false;
1304
- while (child) {
1305
- if (child["s-sn"] !== scopeName && child["s-hn"] === hostName && !!child["s-sr"]) {
1306
- found = true;
1307
- break;
1062
+
1063
+ // src/runtime/vdom/h.ts
1064
+ var import_app_data4 = require("@rindo/core/internal/app-data");
1065
+ var h = (nodeName, vnodeData, ...children) => {
1066
+ let child = null;
1067
+ let key = null;
1068
+ let slotName = null;
1069
+ let simple = false;
1070
+ let lastSimple = false;
1071
+ const vNodeChildren = [];
1072
+ const walk = (c) => {
1073
+ for (let i2 = 0; i2 < c.length; i2++) {
1074
+ child = c[i2];
1075
+ if (Array.isArray(child)) {
1076
+ walk(child);
1077
+ } else if (child != null && typeof child !== "boolean") {
1078
+ if (simple = typeof nodeName !== "function" && !isComplexType(child)) {
1079
+ child = String(child);
1080
+ } else if (import_app_data4.BUILD.isDev && typeof nodeName !== "function" && child.$flags$ === void 0) {
1081
+ consoleDevError(`vNode passed as children has unexpected type.
1082
+ Make sure it's using the correct h() function.
1083
+ Empty objects can also be the cause, look for JSX comments that became objects.`);
1308
1084
  }
1309
- child = child.nextSibling;
1085
+ if (simple && lastSimple) {
1086
+ vNodeChildren[vNodeChildren.length - 1].$text$ += child;
1087
+ } else {
1088
+ vNodeChildren.push(simple ? newVNode(null, child) : child);
1089
+ }
1090
+ lastSimple = simple;
1310
1091
  }
1311
- if (!found) oldParent.classList.remove(scopeId2 + "-s");
1312
1092
  }
1313
- }
1314
- }
1315
- var renderVdom = (hostRef, renderFnResults, isInitialLoad = false) => {
1316
- var _a, _b, _c, _d, _e;
1317
- const hostElm = hostRef.$hostElement$;
1318
- const cmpMeta = hostRef.$cmpMeta$;
1319
- const oldVNode = hostRef.$vnode$ || newVNode(null, null);
1320
- const rootVnode = isHost(renderFnResults) ? renderFnResults : h(null, null, renderFnResults);
1321
- hostTagName = hostElm.tagName;
1322
- if (import_app_data5.BUILD.isDev && Array.isArray(renderFnResults) && renderFnResults.some(isHost)) {
1323
- throw new Error(`The <Host> must be the single root component.
1324
- Looks like the render() function of "${hostTagName.toLowerCase()}" is returning an array that contains the <Host>.
1325
-
1326
- The render() function should look like this instead:
1327
-
1328
- render() {
1329
- // Do not return an array
1330
- return (
1331
- <Host>{content}</Host>
1332
- );
1333
- }
1334
- `);
1335
- }
1336
- if (import_app_data5.BUILD.reflect && cmpMeta.$attrsToReflect$) {
1337
- rootVnode.$attrs$ = rootVnode.$attrs$ || {};
1338
- cmpMeta.$attrsToReflect$.map(
1339
- ([propName, attribute]) => rootVnode.$attrs$[attribute] = hostElm[propName]
1340
- );
1341
- }
1342
- if (isInitialLoad && rootVnode.$attrs$) {
1343
- for (const key of Object.keys(rootVnode.$attrs$)) {
1344
- if (hostElm.hasAttribute(key) && !["key", "ref", "style", "class"].includes(key)) {
1345
- rootVnode.$attrs$[key] = hostElm[key];
1093
+ };
1094
+ walk(children);
1095
+ if (vnodeData) {
1096
+ if (import_app_data4.BUILD.isDev && nodeName === "input") {
1097
+ validateInputProperties(vnodeData);
1098
+ }
1099
+ if (import_app_data4.BUILD.vdomKey && vnodeData.key) {
1100
+ key = vnodeData.key;
1101
+ }
1102
+ if (import_app_data4.BUILD.slotRelocation && vnodeData.name) {
1103
+ slotName = vnodeData.name;
1104
+ }
1105
+ if (import_app_data4.BUILD.vdomClass) {
1106
+ const classData = vnodeData.className || vnodeData.class;
1107
+ if (classData) {
1108
+ vnodeData.class = typeof classData !== "object" ? classData : Object.keys(classData).filter((k) => classData[k]).join(" ");
1346
1109
  }
1347
1110
  }
1348
1111
  }
1349
- rootVnode.$tag$ = null;
1350
- rootVnode.$flags$ |= 4 /* isHost */;
1351
- hostRef.$vnode$ = rootVnode;
1352
- rootVnode.$elm$ = oldVNode.$elm$ = import_app_data5.BUILD.shadowDom ? hostElm.shadowRoot || hostElm : hostElm;
1353
- if (import_app_data5.BUILD.scoped || import_app_data5.BUILD.shadowDom) {
1354
- scopeId = hostElm["s-sc"];
1112
+ if (import_app_data4.BUILD.isDev && vNodeChildren.some(isHost)) {
1113
+ consoleDevError(`The <Host> must be the single root component. Make sure:
1114
+ - You are NOT using hostData() and <Host> in the same component.
1115
+ - <Host> is used once, and it's the single root component of the render() function.`);
1355
1116
  }
1356
- useNativeShadowDom = supportsShadow && (cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) !== 0;
1357
- if (import_app_data5.BUILD.slotRelocation) {
1358
- contentRef = hostElm["s-cr"];
1359
- checkSlotFallbackVisibility = false;
1117
+ if (import_app_data4.BUILD.vdomFunctional && typeof nodeName === "function") {
1118
+ return nodeName(
1119
+ vnodeData === null ? {} : vnodeData,
1120
+ vNodeChildren,
1121
+ vdomFnUtils
1122
+ );
1360
1123
  }
1361
- patch(oldVNode, rootVnode, isInitialLoad);
1362
- if (import_app_data5.BUILD.slotRelocation) {
1363
- plt.$flags$ |= 1 /* isTmpDisconnected */;
1364
- if (checkSlotRelocate) {
1365
- markSlotContentForRelocation(rootVnode.$elm$);
1366
- for (const relocateData of relocateNodes) {
1367
- const nodeToRelocate = relocateData.$nodeToRelocate$;
1368
- if (!nodeToRelocate["s-ol"]) {
1369
- const orgLocationNode = import_app_data5.BUILD.isDebug || import_app_data5.BUILD.hydrateServerSide ? originalLocationDebugNode(nodeToRelocate) : doc.createTextNode("");
1370
- orgLocationNode["s-nr"] = nodeToRelocate;
1371
- insertBefore(nodeToRelocate.parentNode, nodeToRelocate["s-ol"] = orgLocationNode, nodeToRelocate);
1124
+ const vnode = newVNode(nodeName, null);
1125
+ vnode.$attrs$ = vnodeData;
1126
+ if (vNodeChildren.length > 0) {
1127
+ vnode.$children$ = vNodeChildren;
1128
+ }
1129
+ if (import_app_data4.BUILD.vdomKey) {
1130
+ vnode.$key$ = key;
1131
+ }
1132
+ if (import_app_data4.BUILD.slotRelocation) {
1133
+ vnode.$name$ = slotName;
1134
+ }
1135
+ return vnode;
1136
+ };
1137
+ var newVNode = (tag, text) => {
1138
+ const vnode = {
1139
+ $flags$: 0,
1140
+ $tag$: tag,
1141
+ $text$: text,
1142
+ $elm$: null,
1143
+ $children$: null
1144
+ };
1145
+ if (import_app_data4.BUILD.vdomAttribute) {
1146
+ vnode.$attrs$ = null;
1147
+ }
1148
+ if (import_app_data4.BUILD.vdomKey) {
1149
+ vnode.$key$ = null;
1150
+ }
1151
+ if (import_app_data4.BUILD.slotRelocation) {
1152
+ vnode.$name$ = null;
1153
+ }
1154
+ return vnode;
1155
+ };
1156
+ var Host = {};
1157
+ var isHost = (node) => node && node.$tag$ === Host;
1158
+ var vdomFnUtils = {
1159
+ forEach: (children, cb) => children.map(convertToPublic).forEach(cb),
1160
+ map: (children, cb) => children.map(convertToPublic).map(cb).map(convertToPrivate)
1161
+ };
1162
+ var convertToPublic = (node) => ({
1163
+ vattrs: node.$attrs$,
1164
+ vchildren: node.$children$,
1165
+ vkey: node.$key$,
1166
+ vname: node.$name$,
1167
+ vtag: node.$tag$,
1168
+ vtext: node.$text$
1169
+ });
1170
+ var convertToPrivate = (node) => {
1171
+ if (typeof node.vtag === "function") {
1172
+ const vnodeData = { ...node.vattrs };
1173
+ if (node.vkey) {
1174
+ vnodeData.key = node.vkey;
1175
+ }
1176
+ if (node.vname) {
1177
+ vnodeData.name = node.vname;
1178
+ }
1179
+ return h(node.vtag, vnodeData, ...node.vchildren || []);
1180
+ }
1181
+ const vnode = newVNode(node.vtag, node.vtext);
1182
+ vnode.$attrs$ = node.vattrs;
1183
+ vnode.$children$ = node.vchildren;
1184
+ vnode.$key$ = node.vkey;
1185
+ vnode.$name$ = node.vname;
1186
+ return vnode;
1187
+ };
1188
+ var validateInputProperties = (inputElm) => {
1189
+ const props = Object.keys(inputElm);
1190
+ const value = props.indexOf("value");
1191
+ if (value === -1) {
1192
+ return;
1193
+ }
1194
+ const typeIndex = props.indexOf("type");
1195
+ const minIndex = props.indexOf("min");
1196
+ const maxIndex = props.indexOf("max");
1197
+ const stepIndex = props.indexOf("step");
1198
+ if (value < typeIndex || value < minIndex || value < maxIndex || value < stepIndex) {
1199
+ consoleDevWarn(`The "value" prop of <input> should be set after "min", "max", "type" and "step"`);
1200
+ }
1201
+ };
1202
+
1203
+ // src/runtime/client-hydrate.ts
1204
+ var initializeClientHydrate = (hostElm, tagName, hostId, hostRef) => {
1205
+ const endHydrate = createTime("hydrateClient", tagName);
1206
+ const shadowRoot = hostElm.shadowRoot;
1207
+ const childRenderNodes = [];
1208
+ const slotNodes = [];
1209
+ const slottedNodes = [];
1210
+ const shadowRootNodes = import_app_data5.BUILD.shadowDom && shadowRoot ? [] : null;
1211
+ const vnode = newVNode(tagName, null);
1212
+ vnode.$elm$ = hostElm;
1213
+ let scopeId2;
1214
+ if (import_app_data5.BUILD.scoped) {
1215
+ const cmpMeta = hostRef.$cmpMeta$;
1216
+ if (cmpMeta && cmpMeta.$flags$ & 10 /* needsScopedEncapsulation */ && hostElm["s-sc"]) {
1217
+ scopeId2 = hostElm["s-sc"];
1218
+ hostElm.classList.add(scopeId2 + "-h");
1219
+ } else if (hostElm["s-sc"]) {
1220
+ delete hostElm["s-sc"];
1221
+ }
1222
+ }
1223
+ if (!plt.$orgLocNodes$ || !plt.$orgLocNodes$.size) {
1224
+ initializeDocumentHydrate(doc.body, plt.$orgLocNodes$ = /* @__PURE__ */ new Map());
1225
+ }
1226
+ hostElm[HYDRATE_ID] = hostId;
1227
+ hostElm.removeAttribute(HYDRATE_ID);
1228
+ hostRef.$vnode$ = clientHydrate(
1229
+ vnode,
1230
+ childRenderNodes,
1231
+ slotNodes,
1232
+ shadowRootNodes,
1233
+ hostElm,
1234
+ hostElm,
1235
+ hostId,
1236
+ slottedNodes
1237
+ );
1238
+ let crIndex = 0;
1239
+ const crLength = childRenderNodes.length;
1240
+ let childRenderNode;
1241
+ for (crIndex; crIndex < crLength; crIndex++) {
1242
+ childRenderNode = childRenderNodes[crIndex];
1243
+ const orgLocationId = childRenderNode.$hostId$ + "." + childRenderNode.$nodeId$;
1244
+ const orgLocationNode = plt.$orgLocNodes$.get(orgLocationId);
1245
+ const node = childRenderNode.$elm$;
1246
+ if (!shadowRoot) {
1247
+ node["s-hn"] = tagName.toUpperCase();
1248
+ if (childRenderNode.$tag$ === "slot") {
1249
+ node["s-cr"] = hostElm["s-cr"];
1250
+ }
1251
+ }
1252
+ if (childRenderNode.$tag$ === "slot") {
1253
+ childRenderNode.$name$ = childRenderNode.$elm$["s-sn"] || childRenderNode.$elm$["name"] || null;
1254
+ if (childRenderNode.$children$) {
1255
+ childRenderNode.$flags$ |= 2 /* isSlotFallback */;
1256
+ if (!childRenderNode.$elm$.childNodes.length) {
1257
+ childRenderNode.$children$.forEach((c) => {
1258
+ childRenderNode.$elm$.appendChild(c.$elm$);
1259
+ });
1372
1260
  }
1261
+ } else {
1262
+ childRenderNode.$flags$ |= 1 /* isSlotReference */;
1373
1263
  }
1374
- for (const relocateData of relocateNodes) {
1375
- const nodeToRelocate = relocateData.$nodeToRelocate$;
1376
- const slotRefNode = relocateData.$slotRefNode$;
1377
- if (slotRefNode) {
1378
- const parentNodeRef = slotRefNode.parentNode;
1379
- let insertBeforeNode = slotRefNode.nextSibling;
1380
- if (!import_app_data5.BUILD.hydrateServerSide && (!import_app_data5.BUILD.experimentalSlotFixes || insertBeforeNode && insertBeforeNode.nodeType === 1 /* ElementNode */)) {
1381
- let orgLocationNode = (_a = nodeToRelocate["s-ol"]) == null ? void 0 : _a.previousSibling;
1382
- while (orgLocationNode) {
1383
- let refNode = (_b = orgLocationNode["s-nr"]) != null ? _b : null;
1384
- if (refNode && refNode["s-sn"] === nodeToRelocate["s-sn"] && parentNodeRef === refNode.parentNode) {
1385
- refNode = refNode.nextSibling;
1386
- while (refNode === nodeToRelocate || (refNode == null ? void 0 : refNode["s-sr"])) {
1387
- refNode = refNode == null ? void 0 : refNode.nextSibling;
1388
- }
1389
- if (!refNode || !refNode["s-nr"]) {
1390
- insertBeforeNode = refNode;
1391
- break;
1392
- }
1393
- }
1394
- orgLocationNode = orgLocationNode.previousSibling;
1395
- }
1264
+ }
1265
+ if (orgLocationNode && orgLocationNode.isConnected) {
1266
+ if (shadowRoot && orgLocationNode["s-en"] === "") {
1267
+ orgLocationNode.parentNode.insertBefore(node, orgLocationNode.nextSibling);
1268
+ }
1269
+ orgLocationNode.parentNode.removeChild(orgLocationNode);
1270
+ if (!shadowRoot) {
1271
+ node["s-oo"] = parseInt(childRenderNode.$nodeId$);
1272
+ }
1273
+ }
1274
+ plt.$orgLocNodes$.delete(orgLocationId);
1275
+ }
1276
+ const hosts = [];
1277
+ const snLen = slottedNodes.length;
1278
+ let snIndex = 0;
1279
+ let slotGroup;
1280
+ let snGroupIdx;
1281
+ let snGroupLen;
1282
+ let slottedItem;
1283
+ for (snIndex; snIndex < snLen; snIndex++) {
1284
+ slotGroup = slottedNodes[snIndex];
1285
+ if (!slotGroup || !slotGroup.length) continue;
1286
+ snGroupLen = slotGroup.length;
1287
+ snGroupIdx = 0;
1288
+ for (snGroupIdx; snGroupIdx < snGroupLen; snGroupIdx++) {
1289
+ slottedItem = slotGroup[snGroupIdx];
1290
+ if (!hosts[slottedItem.hostId]) {
1291
+ hosts[slottedItem.hostId] = plt.$orgLocNodes$.get(slottedItem.hostId);
1292
+ }
1293
+ if (!hosts[slottedItem.hostId]) continue;
1294
+ const hostEle = hosts[slottedItem.hostId];
1295
+ if (!hostEle.shadowRoot || !shadowRoot) {
1296
+ slottedItem.slot["s-cr"] = hostEle["s-cr"];
1297
+ if (!slottedItem.slot["s-cr"] && hostEle.shadowRoot) {
1298
+ slottedItem.slot["s-cr"] = hostEle;
1299
+ } else {
1300
+ slottedItem.slot["s-cr"] = (hostEle.__childNodes || hostEle.childNodes)[0];
1301
+ }
1302
+ addSlotRelocateNode(slottedItem.node, slottedItem.slot, false, slottedItem.node["s-oo"]);
1303
+ if (import_app_data5.BUILD.experimentalSlotFixes) {
1304
+ patchSlottedNode(slottedItem.node);
1305
+ }
1306
+ }
1307
+ if (hostEle.shadowRoot && slottedItem.node.parentElement !== hostEle) {
1308
+ hostEle.appendChild(slottedItem.node);
1309
+ }
1310
+ }
1311
+ }
1312
+ if (import_app_data5.BUILD.scoped && scopeId2 && slotNodes.length) {
1313
+ slotNodes.forEach((slot) => {
1314
+ slot.$elm$.parentElement.classList.add(scopeId2 + "-s");
1315
+ });
1316
+ }
1317
+ if (import_app_data5.BUILD.shadowDom && shadowRoot && !shadowRoot.childNodes.length) {
1318
+ let rnIdex = 0;
1319
+ const rnLen = shadowRootNodes.length;
1320
+ if (rnLen) {
1321
+ for (rnIdex; rnIdex < rnLen; rnIdex++) {
1322
+ shadowRoot.appendChild(shadowRootNodes[rnIdex]);
1323
+ }
1324
+ Array.from(hostElm.childNodes).forEach((node) => {
1325
+ if (typeof node["s-sn"] !== "string") {
1326
+ if (node.nodeType === 1 /* ElementNode */ && node.slot && node.hidden) {
1327
+ node.removeAttribute("hidden");
1328
+ } else if (node.nodeType === 8 /* CommentNode */ || node.nodeType === 3 /* TextNode */ && !node.wholeText.trim()) {
1329
+ node.parentNode.removeChild(node);
1396
1330
  }
1397
- if (!insertBeforeNode && parentNodeRef !== nodeToRelocate.parentNode || nodeToRelocate.nextSibling !== insertBeforeNode) {
1398
- if (nodeToRelocate !== insertBeforeNode) {
1399
- if (!import_app_data5.BUILD.experimentalSlotFixes && !nodeToRelocate["s-hn"] && nodeToRelocate["s-ol"]) {
1400
- nodeToRelocate["s-hn"] = nodeToRelocate["s-ol"].parentNode.nodeName;
1401
- }
1402
- insertBefore(parentNodeRef, nodeToRelocate, insertBeforeNode);
1403
- if (nodeToRelocate.nodeType === 1 /* ElementNode */ && nodeToRelocate.tagName !== "SLOT-FB") {
1404
- nodeToRelocate.hidden = (_c = nodeToRelocate["s-ih"]) != null ? _c : false;
1405
- }
1331
+ }
1332
+ });
1333
+ }
1334
+ }
1335
+ plt.$orgLocNodes$.delete(hostElm["s-id"]);
1336
+ hostRef.$hostElement$ = hostElm;
1337
+ endHydrate();
1338
+ };
1339
+ var clientHydrate = (parentVNode, childRenderNodes, slotNodes, shadowRootNodes, hostElm, node, hostId, slottedNodes = []) => {
1340
+ let childNodeType;
1341
+ let childIdSplt;
1342
+ let childVNode;
1343
+ let i2;
1344
+ const scopeId2 = hostElm["s-sc"];
1345
+ if (node.nodeType === 1 /* ElementNode */) {
1346
+ childNodeType = node.getAttribute(HYDRATE_CHILD_ID);
1347
+ if (childNodeType) {
1348
+ childIdSplt = childNodeType.split(".");
1349
+ if (childIdSplt[0] === hostId || childIdSplt[0] === "0") {
1350
+ childVNode = createSimpleVNode({
1351
+ $flags$: 0,
1352
+ $hostId$: childIdSplt[0],
1353
+ $nodeId$: childIdSplt[1],
1354
+ $depth$: childIdSplt[2],
1355
+ $index$: childIdSplt[3],
1356
+ $tag$: node.tagName.toLowerCase(),
1357
+ $elm$: node,
1358
+ // If we don't add the initial classes to the VNode, the first `vdom-render.ts` patch
1359
+ // won't try to reconcile them. Classes set on the node will be blown away.
1360
+ $attrs$: { class: node.className || "" }
1361
+ });
1362
+ childRenderNodes.push(childVNode);
1363
+ node.removeAttribute(HYDRATE_CHILD_ID);
1364
+ if (!parentVNode.$children$) {
1365
+ parentVNode.$children$ = [];
1366
+ }
1367
+ if (import_app_data5.BUILD.scoped && scopeId2) {
1368
+ node["s-si"] = scopeId2;
1369
+ childVNode.$attrs$.class += " " + scopeId2;
1370
+ }
1371
+ const slotName = childVNode.$elm$.getAttribute("s-sn");
1372
+ if (typeof slotName === "string") {
1373
+ if (childVNode.$tag$ === "slot-fb") {
1374
+ addSlot(
1375
+ slotName,
1376
+ childIdSplt[2],
1377
+ childVNode,
1378
+ node,
1379
+ parentVNode,
1380
+ childRenderNodes,
1381
+ slotNodes,
1382
+ shadowRootNodes,
1383
+ slottedNodes
1384
+ );
1385
+ if (import_app_data5.BUILD.scoped && scopeId2) {
1386
+ node.classList.add(scopeId2);
1406
1387
  }
1407
1388
  }
1408
- nodeToRelocate && typeof slotRefNode["s-rf"] === "function" && slotRefNode["s-rf"](nodeToRelocate);
1409
- } else {
1410
- if (nodeToRelocate.nodeType === 1 /* ElementNode */) {
1411
- if (isInitialLoad) {
1412
- nodeToRelocate["s-ih"] = (_d = nodeToRelocate.hidden) != null ? _d : false;
1389
+ childVNode.$elm$["s-sn"] = slotName;
1390
+ childVNode.$elm$.removeAttribute("s-sn");
1391
+ }
1392
+ if (childVNode.$index$ !== void 0) {
1393
+ parentVNode.$children$[childVNode.$index$] = childVNode;
1394
+ }
1395
+ parentVNode = childVNode;
1396
+ if (shadowRootNodes && childVNode.$depth$ === "0") {
1397
+ shadowRootNodes[childVNode.$index$] = childVNode.$elm$;
1398
+ }
1399
+ }
1400
+ }
1401
+ if (node.shadowRoot) {
1402
+ for (i2 = node.shadowRoot.childNodes.length - 1; i2 >= 0; i2--) {
1403
+ clientHydrate(
1404
+ parentVNode,
1405
+ childRenderNodes,
1406
+ slotNodes,
1407
+ shadowRootNodes,
1408
+ hostElm,
1409
+ node.shadowRoot.childNodes[i2],
1410
+ hostId,
1411
+ slottedNodes
1412
+ );
1413
+ }
1414
+ }
1415
+ const nonShadowNodes = node.__childNodes || node.childNodes;
1416
+ for (i2 = nonShadowNodes.length - 1; i2 >= 0; i2--) {
1417
+ clientHydrate(
1418
+ parentVNode,
1419
+ childRenderNodes,
1420
+ slotNodes,
1421
+ shadowRootNodes,
1422
+ hostElm,
1423
+ nonShadowNodes[i2],
1424
+ hostId,
1425
+ slottedNodes
1426
+ );
1427
+ }
1428
+ } else if (node.nodeType === 8 /* CommentNode */) {
1429
+ childIdSplt = node.nodeValue.split(".");
1430
+ if (childIdSplt[1] === hostId || childIdSplt[1] === "0") {
1431
+ childNodeType = childIdSplt[0];
1432
+ childVNode = createSimpleVNode({
1433
+ $hostId$: childIdSplt[1],
1434
+ $nodeId$: childIdSplt[2],
1435
+ $depth$: childIdSplt[3],
1436
+ $index$: childIdSplt[4] || "0",
1437
+ $elm$: node,
1438
+ $attrs$: null,
1439
+ $children$: null,
1440
+ $key$: null,
1441
+ $name$: null,
1442
+ $tag$: null,
1443
+ $text$: null
1444
+ });
1445
+ if (childNodeType === TEXT_NODE_ID) {
1446
+ childVNode.$elm$ = findCorrespondingNode(node, 3 /* TextNode */);
1447
+ if (childVNode.$elm$ && childVNode.$elm$.nodeType === 3 /* TextNode */) {
1448
+ childVNode.$text$ = childVNode.$elm$.textContent;
1449
+ childRenderNodes.push(childVNode);
1450
+ node.remove();
1451
+ if (hostId === childVNode.$hostId$) {
1452
+ if (!parentVNode.$children$) {
1453
+ parentVNode.$children$ = [];
1413
1454
  }
1414
- nodeToRelocate.hidden = true;
1455
+ parentVNode.$children$[childVNode.$index$] = childVNode;
1456
+ }
1457
+ if (shadowRootNodes && childVNode.$depth$ === "0") {
1458
+ shadowRootNodes[childVNode.$index$] = childVNode.$elm$;
1459
+ }
1460
+ }
1461
+ } else if (childNodeType === COMMENT_NODE_ID) {
1462
+ childVNode.$elm$ = findCorrespondingNode(node, 8 /* CommentNode */);
1463
+ if (childVNode.$elm$ && childVNode.$elm$.nodeType === 8 /* CommentNode */) {
1464
+ childRenderNodes.push(childVNode);
1465
+ node.remove();
1466
+ }
1467
+ } else if (childVNode.$hostId$ === hostId) {
1468
+ if (childNodeType === SLOT_NODE_ID) {
1469
+ const slotName = node["s-sn"] = childIdSplt[5] || "";
1470
+ addSlot(
1471
+ slotName,
1472
+ childIdSplt[2],
1473
+ childVNode,
1474
+ node,
1475
+ parentVNode,
1476
+ childRenderNodes,
1477
+ slotNodes,
1478
+ shadowRootNodes,
1479
+ slottedNodes
1480
+ );
1481
+ } else if (childNodeType === CONTENT_REF_ID) {
1482
+ if (import_app_data5.BUILD.shadowDom && shadowRootNodes) {
1483
+ node.remove();
1484
+ } else if (import_app_data5.BUILD.slotRelocation) {
1485
+ hostElm["s-cr"] = node;
1486
+ node["s-cn"] = true;
1415
1487
  }
1416
1488
  }
1417
1489
  }
1418
1490
  }
1419
- if (checkSlotFallbackVisibility) {
1420
- updateFallbackSlotVisibility(rootVnode.$elm$);
1491
+ } else if (parentVNode && parentVNode.$tag$ === "style") {
1492
+ const vnode = newVNode(null, node.textContent);
1493
+ vnode.$elm$ = node;
1494
+ vnode.$index$ = "0";
1495
+ parentVNode.$children$ = [vnode];
1496
+ } else {
1497
+ if (node.nodeType === 3 /* TextNode */ && !node.wholeText.trim()) {
1498
+ node.remove();
1421
1499
  }
1422
- plt.$flags$ &= ~1 /* isTmpDisconnected */;
1423
- relocateNodes.length = 0;
1424
1500
  }
1425
- if (import_app_data5.BUILD.experimentalScopedSlotChanges && cmpMeta.$flags$ & 2 /* scopedCssEncapsulation */) {
1426
- const children = rootVnode.$elm$.__childNodes || rootVnode.$elm$.childNodes;
1427
- for (const childNode of children) {
1428
- if (childNode["s-hn"] !== hostTagName && !childNode["s-sh"]) {
1429
- if (isInitialLoad && childNode["s-ih"] == null) {
1430
- childNode["s-ih"] = (_e = childNode.hidden) != null ? _e : false;
1431
- }
1432
- childNode.hidden = true;
1501
+ return parentVNode;
1502
+ };
1503
+ var initializeDocumentHydrate = (node, orgLocNodes) => {
1504
+ if (node.nodeType === 1 /* ElementNode */) {
1505
+ const componentId = node[HYDRATE_ID] || node.getAttribute(HYDRATE_ID);
1506
+ if (componentId) {
1507
+ orgLocNodes.set(componentId, node);
1508
+ }
1509
+ let i2 = 0;
1510
+ if (node.shadowRoot) {
1511
+ for (; i2 < node.shadowRoot.childNodes.length; i2++) {
1512
+ initializeDocumentHydrate(node.shadowRoot.childNodes[i2], orgLocNodes);
1433
1513
  }
1434
1514
  }
1515
+ const nonShadowNodes = node.__childNodes || node.childNodes;
1516
+ for (i2 = 0; i2 < nonShadowNodes.length; i2++) {
1517
+ initializeDocumentHydrate(nonShadowNodes[i2], orgLocNodes);
1518
+ }
1519
+ } else if (node.nodeType === 8 /* CommentNode */) {
1520
+ const childIdSplt = node.nodeValue.split(".");
1521
+ if (childIdSplt[0] === ORG_LOCATION_ID) {
1522
+ orgLocNodes.set(childIdSplt[1] + "." + childIdSplt[2], node);
1523
+ node.nodeValue = "";
1524
+ node["s-en"] = childIdSplt[3];
1525
+ }
1435
1526
  }
1436
- contentRef = void 0;
1437
1527
  };
1438
- var slotReferenceDebugNode = (slotVNode) => doc.createComment(
1439
- `<slot${slotVNode.$name$ ? ' name="' + slotVNode.$name$ + '"' : ""}> (host=${hostTagName.toLowerCase()})`
1440
- );
1441
- var originalLocationDebugNode = (nodeToRelocate) => doc.createComment(
1442
- `org-location for ` + (nodeToRelocate.localName ? `<${nodeToRelocate.localName}> (host=${nodeToRelocate["s-hn"]})` : `[${nodeToRelocate.textContent}]`)
1443
- );
1444
-
1445
- // src/runtime/dom-extras.ts
1446
- var patchPseudoShadowDom = (hostElementPrototype) => {
1447
- patchCloneNode(hostElementPrototype);
1448
- patchSlotAppendChild(hostElementPrototype);
1449
- patchSlotAppend(hostElementPrototype);
1450
- patchSlotPrepend(hostElementPrototype);
1451
- patchSlotInsertAdjacentElement(hostElementPrototype);
1452
- patchSlotInsertAdjacentHTML(hostElementPrototype);
1453
- patchSlotInsertAdjacentText(hostElementPrototype);
1454
- patchTextContent(hostElementPrototype);
1455
- patchChildSlotNodes(hostElementPrototype);
1456
- patchSlotRemoveChild(hostElementPrototype);
1528
+ var createSimpleVNode = (vnode) => {
1529
+ const defaultVNode = {
1530
+ $flags$: 0,
1531
+ $hostId$: null,
1532
+ $nodeId$: null,
1533
+ $depth$: null,
1534
+ $index$: "0",
1535
+ $elm$: null,
1536
+ $attrs$: null,
1537
+ $children$: null,
1538
+ $key$: null,
1539
+ $name$: null,
1540
+ $tag$: null,
1541
+ $text$: null
1542
+ };
1543
+ return { ...defaultVNode, ...vnode };
1457
1544
  };
1458
- var patchCloneNode = (HostElementPrototype) => {
1459
- const orgCloneNode = HostElementPrototype.cloneNode;
1460
- HostElementPrototype.cloneNode = function(deep) {
1461
- const srcNode = this;
1462
- const isShadowDom = import_app_data6.BUILD.shadowDom ? srcNode.shadowRoot && supportsShadow : false;
1463
- const clonedNode = orgCloneNode.call(srcNode, isShadowDom ? deep : false);
1464
- if (import_app_data6.BUILD.slot && !isShadowDom && deep) {
1465
- let i2 = 0;
1466
- let slotted, nonRindoNode;
1467
- const rindoPrivates = [
1468
- "s-id",
1469
- "s-cr",
1470
- "s-lr",
1471
- "s-rc",
1472
- "s-sc",
1473
- "s-p",
1474
- "s-cn",
1475
- "s-sr",
1476
- "s-sn",
1477
- "s-hn",
1478
- "s-ol",
1479
- "s-nr",
1480
- "s-si",
1481
- "s-rf",
1482
- "s-scs"
1483
- ];
1484
- const childNodes = this.__childNodes || this.childNodes;
1485
- for (; i2 < childNodes.length; i2++) {
1486
- slotted = childNodes[i2]["s-nr"];
1487
- nonRindoNode = rindoPrivates.every((privateField) => !childNodes[i2][privateField]);
1488
- if (slotted) {
1489
- if (import_app_data6.BUILD.appendChildSlotFix && clonedNode.__appendChild) {
1490
- clonedNode.__appendChild(slotted.cloneNode(true));
1491
- } else {
1492
- clonedNode.appendChild(slotted.cloneNode(true));
1493
- }
1494
- }
1495
- if (nonRindoNode) {
1496
- clonedNode.appendChild(childNodes[i2].cloneNode(true));
1497
- }
1498
- }
1545
+ function addSlot(slotName, slotId, childVNode, node, parentVNode, childRenderNodes, slotNodes, shadowRootNodes, slottedNodes) {
1546
+ node["s-sr"] = true;
1547
+ childVNode.$name$ = slotName || null;
1548
+ childVNode.$tag$ = "slot";
1549
+ const parentNodeId = (parentVNode == null ? void 0 : parentVNode.$elm$) ? parentVNode.$elm$["s-id"] || parentVNode.$elm$.getAttribute("s-id") : "";
1550
+ if (import_app_data5.BUILD.shadowDom && shadowRootNodes) {
1551
+ const slot = childVNode.$elm$ = doc.createElement(childVNode.$tag$);
1552
+ if (childVNode.$name$) {
1553
+ childVNode.$elm$.setAttribute("name", slotName);
1554
+ }
1555
+ if (parentNodeId && parentNodeId !== childVNode.$hostId$) {
1556
+ parentVNode.$elm$.insertBefore(slot, parentVNode.$elm$.children[0]);
1557
+ } else {
1558
+ node.parentNode.insertBefore(childVNode.$elm$, node);
1559
+ }
1560
+ addSlottedNodes(slottedNodes, slotId, slotName, node, childVNode.$hostId$);
1561
+ node.remove();
1562
+ if (childVNode.$depth$ === "0") {
1563
+ shadowRootNodes[childVNode.$index$] = childVNode.$elm$;
1499
1564
  }
1500
- return clonedNode;
1501
- };
1502
- };
1503
- var patchSlotAppendChild = (HostElementPrototype) => {
1504
- HostElementPrototype.__appendChild = HostElementPrototype.appendChild;
1505
- HostElementPrototype.appendChild = function(newChild) {
1506
- const slotName = newChild["s-sn"] = getSlotName(newChild);
1507
- const slotNode = getHostSlotNodes(this.__childNodes || this.childNodes, this.tagName, slotName)[0];
1508
- if (slotNode) {
1509
- addSlotRelocateNode(newChild, slotNode);
1510
- const slotChildNodes = getHostSlotChildNodes(slotNode, slotName);
1511
- const appendAfter = slotChildNodes[slotChildNodes.length - 1];
1512
- const insertedNode = insertBefore(appendAfter.parentNode, newChild, appendAfter.nextSibling);
1513
- updateFallbackSlotVisibility(this);
1514
- return insertedNode;
1565
+ } else {
1566
+ const slot = childVNode.$elm$;
1567
+ const shouldMove = parentNodeId && parentNodeId !== childVNode.$hostId$ && parentVNode.$elm$.shadowRoot;
1568
+ addSlottedNodes(slottedNodes, slotId, slotName, node, shouldMove ? parentNodeId : childVNode.$hostId$);
1569
+ if (shouldMove) {
1570
+ parentVNode.$elm$.insertBefore(slot, parentVNode.$elm$.children[0]);
1515
1571
  }
1516
- return this.__appendChild(newChild);
1572
+ childRenderNodes.push(childVNode);
1573
+ }
1574
+ slotNodes.push(childVNode);
1575
+ if (!parentVNode.$children$) {
1576
+ parentVNode.$children$ = [];
1577
+ }
1578
+ parentVNode.$children$[childVNode.$index$] = childVNode;
1579
+ }
1580
+ var addSlottedNodes = (slottedNodes, slotNodeId, slotName, slotNode, hostId) => {
1581
+ let slottedNode = slotNode.nextSibling;
1582
+ slottedNodes[slotNodeId] = slottedNodes[slotNodeId] || [];
1583
+ 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 */))) {
1584
+ slottedNode["s-sn"] = slotName;
1585
+ slottedNodes[slotNodeId].push({ slot: slotNode, node: slottedNode, hostId });
1586
+ slottedNode = slottedNode.nextSibling;
1587
+ }
1588
+ };
1589
+ var findCorrespondingNode = (node, type) => {
1590
+ let sibling = node;
1591
+ do {
1592
+ sibling = sibling.nextSibling;
1593
+ } while (sibling && (sibling.nodeType !== type || !sibling.nodeValue));
1594
+ return sibling;
1595
+ };
1596
+
1597
+ // src/runtime/initialize-component.ts
1598
+ var import_app_data16 = require("@rindo/core/internal/app-data");
1599
+
1600
+ // src/utils/shadow-css.ts
1601
+ /**
1602
+ * @license
1603
+ * Copyright Google Inc. All Rights Reserved.
1604
+ *
1605
+ * Use of this source code is governed by an MIT-style license that can be
1606
+ * found in the LICENSE file at https://angular.io/license
1607
+ *
1608
+ * This file is a port of shadowCSS from `webcomponents.js` to TypeScript.
1609
+ * https://github.com/webcomponents/webcomponentsjs/blob/4efecd7e0e/src/ShadowCSS/ShadowCSS.js
1610
+ * https://github.com/angular/angular/blob/master/packages/compiler/src/shadow_css.ts
1611
+ */
1612
+ var safeSelector = (selector) => {
1613
+ const placeholders = [];
1614
+ let index = 0;
1615
+ selector = selector.replace(/(\[[^\]]*\])/g, (_, keep) => {
1616
+ const replaceBy = `__ph-${index}__`;
1617
+ placeholders.push(keep);
1618
+ index++;
1619
+ return replaceBy;
1620
+ });
1621
+ const content = selector.replace(/(:nth-[-\w]+)(\([^)]+\))/g, (_, pseudo, exp) => {
1622
+ const replaceBy = `__ph-${index}__`;
1623
+ placeholders.push(exp);
1624
+ index++;
1625
+ return pseudo + replaceBy;
1626
+ });
1627
+ const ss = {
1628
+ content,
1629
+ placeholders
1517
1630
  };
1631
+ return ss;
1518
1632
  };
1519
- var patchSlotRemoveChild = (ElementPrototype) => {
1520
- ElementPrototype.__removeChild = ElementPrototype.removeChild;
1521
- ElementPrototype.removeChild = function(toRemove) {
1522
- if (toRemove && typeof toRemove["s-sn"] !== "undefined") {
1523
- const childNodes = this.__childNodes || this.childNodes;
1524
- const slotNode = getHostSlotNodes(childNodes, this.tagName, toRemove["s-sn"]);
1525
- if (slotNode && toRemove.isConnected) {
1526
- toRemove.remove();
1527
- updateFallbackSlotVisibility(this);
1528
- return;
1633
+ var restoreSafeSelector = (placeholders, content) => {
1634
+ return content.replace(/__ph-(\d+)__/g, (_, index) => placeholders[+index]);
1635
+ };
1636
+ var _polyfillHost = "-shadowcsshost";
1637
+ var _polyfillSlotted = "-shadowcssslotted";
1638
+ var _polyfillHostContext = "-shadowcsscontext";
1639
+ var _parenSuffix = ")(?:\\(((?:\\([^)(]*\\)|[^)(]*)+?)\\))?([^,{]*)";
1640
+ var _cssColonHostRe = new RegExp("(" + _polyfillHost + _parenSuffix, "gim");
1641
+ var _cssColonHostContextRe = new RegExp("(" + _polyfillHostContext + _parenSuffix, "gim");
1642
+ var _cssColonSlottedRe = new RegExp("(" + _polyfillSlotted + _parenSuffix, "gim");
1643
+ var _polyfillHostNoCombinator = _polyfillHost + "-no-combinator";
1644
+ var _polyfillHostNoCombinatorRe = /-shadowcsshost-no-combinator([^\s]*)/;
1645
+ var _shadowDOMSelectorsRe = [/::shadow/g, /::content/g];
1646
+ var _selectorReSuffix = "([>\\s~+[.,{:][\\s\\S]*)?$";
1647
+ var _polyfillHostRe = /-shadowcsshost/gim;
1648
+ var createSupportsRuleRe = (selector) => new RegExp(`((?<!(^@supports(.*)))|(?<={.*))(${selector}\\b)`, "gim");
1649
+ var _colonSlottedRe = createSupportsRuleRe("::slotted");
1650
+ var _colonHostRe = createSupportsRuleRe(":host");
1651
+ var _colonHostContextRe = createSupportsRuleRe(":host-context");
1652
+ var _commentRe = /\/\*\s*[\s\S]*?\*\//g;
1653
+ var stripComments = (input) => {
1654
+ return input.replace(_commentRe, "");
1655
+ };
1656
+ var _commentWithHashRe = /\/\*\s*#\s*source(Mapping)?URL=[\s\S]+?\*\//g;
1657
+ var extractCommentsWithHash = (input) => {
1658
+ return input.match(_commentWithHashRe) || [];
1659
+ };
1660
+ var _ruleRe = /(\s*)([^;\{\}]+?)(\s*)((?:{%BLOCK%}?\s*;?)|(?:\s*;))/g;
1661
+ var _curlyRe = /([{}])/g;
1662
+ var _selectorPartsRe = /(^.*?[^\\])??((:+)(.*)|$)/;
1663
+ var OPEN_CURLY = "{";
1664
+ var CLOSE_CURLY = "}";
1665
+ var BLOCK_PLACEHOLDER = "%BLOCK%";
1666
+ var processRules = (input, ruleCallback) => {
1667
+ const inputWithEscapedBlocks = escapeBlocks(input);
1668
+ let nextBlockIndex = 0;
1669
+ return inputWithEscapedBlocks.escapedString.replace(_ruleRe, (...m) => {
1670
+ const selector = m[2];
1671
+ let content = "";
1672
+ let suffix = m[4];
1673
+ let contentPrefix = "";
1674
+ if (suffix && suffix.startsWith("{" + BLOCK_PLACEHOLDER)) {
1675
+ content = inputWithEscapedBlocks.blocks[nextBlockIndex++];
1676
+ suffix = suffix.substring(BLOCK_PLACEHOLDER.length + 1);
1677
+ contentPrefix = "{";
1678
+ }
1679
+ const cssRule = {
1680
+ selector,
1681
+ content
1682
+ };
1683
+ const rule = ruleCallback(cssRule);
1684
+ return `${m[1]}${rule.selector}${m[3]}${contentPrefix}${rule.content}${suffix}`;
1685
+ });
1686
+ };
1687
+ var escapeBlocks = (input) => {
1688
+ const inputParts = input.split(_curlyRe);
1689
+ const resultParts = [];
1690
+ const escapedBlocks = [];
1691
+ let bracketCount = 0;
1692
+ let currentBlockParts = [];
1693
+ for (let partIndex = 0; partIndex < inputParts.length; partIndex++) {
1694
+ const part = inputParts[partIndex];
1695
+ if (part === CLOSE_CURLY) {
1696
+ bracketCount--;
1697
+ }
1698
+ if (bracketCount > 0) {
1699
+ currentBlockParts.push(part);
1700
+ } else {
1701
+ if (currentBlockParts.length > 0) {
1702
+ escapedBlocks.push(currentBlockParts.join(""));
1703
+ resultParts.push(BLOCK_PLACEHOLDER);
1704
+ currentBlockParts = [];
1529
1705
  }
1706
+ resultParts.push(part);
1530
1707
  }
1531
- return this.__removeChild(toRemove);
1708
+ if (part === OPEN_CURLY) {
1709
+ bracketCount++;
1710
+ }
1711
+ }
1712
+ if (currentBlockParts.length > 0) {
1713
+ escapedBlocks.push(currentBlockParts.join(""));
1714
+ resultParts.push(BLOCK_PLACEHOLDER);
1715
+ }
1716
+ const strEscapedBlocks = {
1717
+ escapedString: resultParts.join(""),
1718
+ blocks: escapedBlocks
1532
1719
  };
1720
+ return strEscapedBlocks;
1533
1721
  };
1534
- var patchSlotPrepend = (HostElementPrototype) => {
1535
- HostElementPrototype.__prepend = HostElementPrototype.prepend;
1536
- HostElementPrototype.prepend = function(...newChildren) {
1537
- newChildren.forEach((newChild) => {
1538
- if (typeof newChild === "string") {
1539
- newChild = this.ownerDocument.createTextNode(newChild);
1540
- }
1541
- const slotName = newChild["s-sn"] = getSlotName(newChild);
1542
- const childNodes = this.__childNodes || this.childNodes;
1543
- const slotNode = getHostSlotNodes(childNodes, this.tagName, slotName)[0];
1544
- if (slotNode) {
1545
- addSlotRelocateNode(newChild, slotNode, true);
1546
- const slotChildNodes = getHostSlotChildNodes(slotNode, slotName);
1547
- const appendAfter = slotChildNodes[0];
1548
- return insertBefore(appendAfter.parentNode, newChild, appendAfter.nextSibling);
1549
- }
1550
- if (newChild.nodeType === 1 && !!newChild.getAttribute("slot")) {
1551
- newChild.hidden = true;
1552
- }
1553
- return HostElementPrototype.__prepend(newChild);
1554
- });
1555
- };
1722
+ var insertPolyfillHostInCssText = (cssText) => {
1723
+ cssText = cssText.replace(_colonHostContextRe, `$1${_polyfillHostContext}`).replace(_colonHostRe, `$1${_polyfillHost}`).replace(_colonSlottedRe, `$1${_polyfillSlotted}`);
1724
+ return cssText;
1556
1725
  };
1557
- var patchSlotAppend = (HostElementPrototype) => {
1558
- HostElementPrototype.__append = HostElementPrototype.append;
1559
- HostElementPrototype.append = function(...newChildren) {
1560
- newChildren.forEach((newChild) => {
1561
- if (typeof newChild === "string") {
1562
- newChild = this.ownerDocument.createTextNode(newChild);
1726
+ var convertColonRule = (cssText, regExp, partReplacer) => {
1727
+ return cssText.replace(regExp, (...m) => {
1728
+ if (m[2]) {
1729
+ const parts = m[2].split(",");
1730
+ const r = [];
1731
+ for (let i2 = 0; i2 < parts.length; i2++) {
1732
+ const p = parts[i2].trim();
1733
+ if (!p) break;
1734
+ r.push(partReplacer(_polyfillHostNoCombinator, p, m[3]));
1563
1735
  }
1564
- this.appendChild(newChild);
1565
- });
1566
- };
1567
- };
1568
- var patchSlotInsertAdjacentHTML = (HostElementPrototype) => {
1569
- const originalInsertAdjacentHtml = HostElementPrototype.insertAdjacentHTML;
1570
- HostElementPrototype.insertAdjacentHTML = function(position, text) {
1571
- if (position !== "afterbegin" && position !== "beforeend") {
1572
- return originalInsertAdjacentHtml.call(this, position, text);
1736
+ return r.join(",");
1737
+ } else {
1738
+ return _polyfillHostNoCombinator + m[3];
1573
1739
  }
1574
- const container = this.ownerDocument.createElement("_");
1575
- let node;
1576
- container.innerHTML = text;
1577
- if (position === "afterbegin") {
1578
- while (node = container.firstChild) {
1579
- this.prepend(node);
1740
+ });
1741
+ };
1742
+ var colonHostPartReplacer = (host, part, suffix) => {
1743
+ return host + part.replace(_polyfillHost, "") + suffix;
1744
+ };
1745
+ var convertColonHost = (cssText) => {
1746
+ return convertColonRule(cssText, _cssColonHostRe, colonHostPartReplacer);
1747
+ };
1748
+ var colonHostContextPartReplacer = (host, part, suffix) => {
1749
+ if (part.indexOf(_polyfillHost) > -1) {
1750
+ return colonHostPartReplacer(host, part, suffix);
1751
+ } else {
1752
+ return host + part + suffix + ", " + part + " " + host + suffix;
1753
+ }
1754
+ };
1755
+ var convertColonSlotted = (cssText, slotScopeId) => {
1756
+ const slotClass = "." + slotScopeId + " > ";
1757
+ const selectors = [];
1758
+ cssText = cssText.replace(_cssColonSlottedRe, (...m) => {
1759
+ if (m[2]) {
1760
+ const compound = m[2].trim();
1761
+ const suffix = m[3];
1762
+ const slottedSelector = slotClass + compound + suffix;
1763
+ let prefixSelector = "";
1764
+ for (let i2 = m[4] - 1; i2 >= 0; i2--) {
1765
+ const char = m[5][i2];
1766
+ if (char === "}" || char === ",") {
1767
+ break;
1768
+ }
1769
+ prefixSelector = char + prefixSelector;
1580
1770
  }
1581
- } else if (position === "beforeend") {
1582
- while (node = container.firstChild) {
1583
- this.append(node);
1771
+ const orgSelector = (prefixSelector + slottedSelector).trim();
1772
+ const addedSelector = `${prefixSelector.trimEnd()}${slottedSelector.trim()}`.trim();
1773
+ if (orgSelector !== addedSelector) {
1774
+ const updatedSelector = `${addedSelector}, ${orgSelector}`;
1775
+ selectors.push({
1776
+ orgSelector,
1777
+ updatedSelector
1778
+ });
1584
1779
  }
1780
+ return slottedSelector;
1781
+ } else {
1782
+ return _polyfillHostNoCombinator + m[3];
1585
1783
  }
1784
+ });
1785
+ return {
1786
+ selectors,
1787
+ cssText
1586
1788
  };
1587
1789
  };
1588
- var patchSlotInsertAdjacentText = (HostElementPrototype) => {
1589
- HostElementPrototype.insertAdjacentText = function(position, text) {
1590
- this.insertAdjacentHTML(position, text);
1591
- };
1790
+ var convertColonHostContext = (cssText) => {
1791
+ return convertColonRule(cssText, _cssColonHostContextRe, colonHostContextPartReplacer);
1592
1792
  };
1593
- var patchSlotInsertAdjacentElement = (HostElementPrototype) => {
1594
- const originalInsertAdjacentElement = HostElementPrototype.insertAdjacentElement;
1595
- HostElementPrototype.insertAdjacentElement = function(position, element) {
1596
- if (position !== "afterbegin" && position !== "beforeend") {
1597
- return originalInsertAdjacentElement.call(this, position, element);
1598
- }
1599
- if (position === "afterbegin") {
1600
- this.prepend(element);
1601
- return element;
1602
- } else if (position === "beforeend") {
1603
- this.append(element);
1604
- return element;
1605
- }
1606
- return element;
1607
- };
1793
+ var convertShadowDOMSelectors = (cssText) => {
1794
+ return _shadowDOMSelectorsRe.reduce((result, pattern) => result.replace(pattern, " "), cssText);
1608
1795
  };
1609
- var patchTextContent = (hostElementPrototype) => {
1610
- patchHostOriginalAccessor("textContent", hostElementPrototype);
1611
- Object.defineProperty(hostElementPrototype, "textContent", {
1612
- get: function() {
1613
- let text = "";
1614
- const childNodes = this.__childNodes ? this.childNodes : getSlottedChildNodes(this.childNodes);
1615
- childNodes.forEach((node) => text += node.textContent || "");
1616
- return text;
1617
- },
1618
- set: function(value) {
1619
- const childNodes = this.__childNodes ? this.childNodes : getSlottedChildNodes(this.childNodes);
1620
- childNodes.forEach((node) => {
1621
- if (node["s-ol"]) node["s-ol"].remove();
1622
- node.remove();
1623
- });
1624
- this.insertAdjacentHTML("beforeend", value);
1625
- }
1796
+ var makeScopeMatcher = (scopeSelector2) => {
1797
+ const lre = /\[/g;
1798
+ const rre = /\]/g;
1799
+ scopeSelector2 = scopeSelector2.replace(lre, "\\[").replace(rre, "\\]");
1800
+ return new RegExp("^(" + scopeSelector2 + ")" + _selectorReSuffix, "m");
1801
+ };
1802
+ var selectorNeedsScoping = (selector, scopeSelector2) => {
1803
+ const re = makeScopeMatcher(scopeSelector2);
1804
+ return !re.test(selector);
1805
+ };
1806
+ var injectScopingSelector = (selector, scopingSelector) => {
1807
+ return selector.replace(_selectorPartsRe, (_, before = "", _colonGroup, colon = "", after = "") => {
1808
+ return before + scopingSelector + colon + after;
1626
1809
  });
1627
1810
  };
1628
- var patchChildSlotNodes = (elm) => {
1629
- class FakeNodeList extends Array {
1630
- item(n) {
1631
- return this[n];
1632
- }
1811
+ var applySimpleSelectorScope = (selector, scopeSelector2, hostSelector) => {
1812
+ _polyfillHostRe.lastIndex = 0;
1813
+ if (_polyfillHostRe.test(selector)) {
1814
+ const replaceBy = `.${hostSelector}`;
1815
+ return selector.replace(_polyfillHostNoCombinatorRe, (_, selector2) => injectScopingSelector(selector2, replaceBy)).replace(_polyfillHostRe, replaceBy + " ");
1633
1816
  }
1634
- patchHostOriginalAccessor("children", elm);
1635
- Object.defineProperty(elm, "children", {
1636
- get() {
1637
- return this.childNodes.filter((n) => n.nodeType === 1);
1638
- }
1639
- });
1640
- Object.defineProperty(elm, "childElementCount", {
1641
- get() {
1642
- return this.children.length;
1817
+ return scopeSelector2 + " " + selector;
1818
+ };
1819
+ var applyStrictSelectorScope = (selector, scopeSelector2, hostSelector) => {
1820
+ const isRe = /\[is=([^\]]*)\]/g;
1821
+ scopeSelector2 = scopeSelector2.replace(isRe, (_, ...parts) => parts[0]);
1822
+ const className = "." + scopeSelector2;
1823
+ const _scopeSelectorPart = (p) => {
1824
+ let scopedP = p.trim();
1825
+ if (!scopedP) {
1826
+ return "";
1827
+ }
1828
+ if (p.indexOf(_polyfillHostNoCombinator) > -1) {
1829
+ scopedP = applySimpleSelectorScope(p, scopeSelector2, hostSelector);
1830
+ } else {
1831
+ const t = p.replace(_polyfillHostRe, "");
1832
+ if (t.length > 0) {
1833
+ scopedP = injectScopingSelector(t, className);
1834
+ }
1643
1835
  }
1644
- });
1645
- patchHostOriginalAccessor("firstChild", elm);
1646
- Object.defineProperty(elm, "firstChild", {
1647
- get() {
1648
- return this.childNodes[0];
1836
+ return scopedP;
1837
+ };
1838
+ const safeContent = safeSelector(selector);
1839
+ selector = safeContent.content;
1840
+ let scopedSelector = "";
1841
+ let startIndex = 0;
1842
+ let res;
1843
+ const sep = /( |>|\+|~(?!=))\s*/g;
1844
+ const hasHost = selector.indexOf(_polyfillHostNoCombinator) > -1;
1845
+ let shouldScope = !hasHost;
1846
+ while ((res = sep.exec(selector)) !== null) {
1847
+ const separator = res[1];
1848
+ const part2 = selector.slice(startIndex, res.index).trim();
1849
+ shouldScope = shouldScope || part2.indexOf(_polyfillHostNoCombinator) > -1;
1850
+ const scopedPart = shouldScope ? _scopeSelectorPart(part2) : part2;
1851
+ scopedSelector += `${scopedPart} ${separator} `;
1852
+ startIndex = sep.lastIndex;
1853
+ }
1854
+ const part = selector.substring(startIndex);
1855
+ shouldScope = shouldScope || part.indexOf(_polyfillHostNoCombinator) > -1;
1856
+ scopedSelector += shouldScope ? _scopeSelectorPart(part) : part;
1857
+ return restoreSafeSelector(safeContent.placeholders, scopedSelector);
1858
+ };
1859
+ var scopeSelector = (selector, scopeSelectorText, hostSelector, slotSelector) => {
1860
+ return selector.split(",").map((shallowPart) => {
1861
+ if (slotSelector && shallowPart.indexOf("." + slotSelector) > -1) {
1862
+ return shallowPart.trim();
1649
1863
  }
1650
- });
1651
- patchHostOriginalAccessor("lastChild", elm);
1652
- Object.defineProperty(elm, "lastChild", {
1653
- get() {
1654
- return this.childNodes[this.childNodes.length - 1];
1864
+ if (selectorNeedsScoping(shallowPart, scopeSelectorText)) {
1865
+ return applyStrictSelectorScope(shallowPart, scopeSelectorText, hostSelector).trim();
1866
+ } else {
1867
+ return shallowPart.trim();
1655
1868
  }
1869
+ }).join(", ");
1870
+ };
1871
+ var scopeSelectors = (cssText, scopeSelectorText, hostSelector, slotSelector, commentOriginalSelector) => {
1872
+ return processRules(cssText, (rule) => {
1873
+ let selector = rule.selector;
1874
+ let content = rule.content;
1875
+ if (rule.selector[0] !== "@") {
1876
+ selector = scopeSelector(rule.selector, scopeSelectorText, hostSelector, slotSelector);
1877
+ } else if (rule.selector.startsWith("@media") || rule.selector.startsWith("@supports") || rule.selector.startsWith("@page") || rule.selector.startsWith("@document")) {
1878
+ content = scopeSelectors(rule.content, scopeSelectorText, hostSelector, slotSelector, commentOriginalSelector);
1879
+ }
1880
+ const cssRule = {
1881
+ selector: selector.replace(/\s{2,}/g, " ").trim(),
1882
+ content
1883
+ };
1884
+ return cssRule;
1656
1885
  });
1657
- patchHostOriginalAccessor("childNodes", elm);
1658
- Object.defineProperty(elm, "childNodes", {
1659
- get() {
1660
- var _a, _b;
1661
- 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 */) {
1662
- const result = new FakeNodeList();
1663
- const nodes = getSlottedChildNodes(this.__childNodes);
1664
- result.push(...nodes);
1665
- return result;
1886
+ };
1887
+ var scopeCssText = (cssText, scopeId2, hostScopeId, slotScopeId, commentOriginalSelector) => {
1888
+ cssText = insertPolyfillHostInCssText(cssText);
1889
+ cssText = convertColonHost(cssText);
1890
+ cssText = convertColonHostContext(cssText);
1891
+ const slotted = convertColonSlotted(cssText, slotScopeId);
1892
+ cssText = slotted.cssText;
1893
+ cssText = convertShadowDOMSelectors(cssText);
1894
+ if (scopeId2) {
1895
+ cssText = scopeSelectors(cssText, scopeId2, hostScopeId, slotScopeId, commentOriginalSelector);
1896
+ }
1897
+ cssText = replaceShadowCssHost(cssText, hostScopeId);
1898
+ cssText = cssText.replace(/>\s*\*\s+([^{, ]+)/gm, " $1 ");
1899
+ return {
1900
+ cssText: cssText.trim(),
1901
+ // We need to replace the shadow CSS host string in each of these selectors since we created
1902
+ // them prior to the replacement happening in the components CSS text.
1903
+ slottedSelectors: slotted.selectors.map((ref) => ({
1904
+ orgSelector: replaceShadowCssHost(ref.orgSelector, hostScopeId),
1905
+ updatedSelector: replaceShadowCssHost(ref.updatedSelector, hostScopeId)
1906
+ }))
1907
+ };
1908
+ };
1909
+ var replaceShadowCssHost = (cssText, hostScopeId) => {
1910
+ return cssText.replace(/-shadowcsshost-no-combinator/g, `.${hostScopeId}`);
1911
+ };
1912
+ var scopeCss = (cssText, scopeId2, commentOriginalSelector) => {
1913
+ const hostScopeId = scopeId2 + "-h";
1914
+ const slotScopeId = scopeId2 + "-s";
1915
+ const commentsWithHash = extractCommentsWithHash(cssText);
1916
+ cssText = stripComments(cssText);
1917
+ const orgSelectors = [];
1918
+ if (commentOriginalSelector) {
1919
+ const processCommentedSelector = (rule) => {
1920
+ const placeholder = `/*!@___${orgSelectors.length}___*/`;
1921
+ const comment = `/*!@${rule.selector}*/`;
1922
+ orgSelectors.push({ placeholder, comment });
1923
+ rule.selector = placeholder + rule.selector;
1924
+ return rule;
1925
+ };
1926
+ cssText = processRules(cssText, (rule) => {
1927
+ if (rule.selector[0] !== "@") {
1928
+ return processCommentedSelector(rule);
1929
+ } else if (rule.selector.startsWith("@media") || rule.selector.startsWith("@supports") || rule.selector.startsWith("@page") || rule.selector.startsWith("@document")) {
1930
+ rule.content = processRules(rule.content, processCommentedSelector);
1931
+ return rule;
1666
1932
  }
1667
- return FakeNodeList.from(this.__childNodes);
1668
- }
1933
+ return rule;
1934
+ });
1935
+ }
1936
+ const scoped = scopeCssText(cssText, scopeId2, hostScopeId, slotScopeId, commentOriginalSelector);
1937
+ cssText = [scoped.cssText, ...commentsWithHash].join("\n");
1938
+ if (commentOriginalSelector) {
1939
+ orgSelectors.forEach(({ placeholder, comment }) => {
1940
+ cssText = cssText.replace(placeholder, comment);
1941
+ });
1942
+ }
1943
+ scoped.slottedSelectors.forEach((slottedSelector) => {
1944
+ const regex = new RegExp(escapeRegExpSpecialCharacters(slottedSelector.orgSelector), "g");
1945
+ cssText = cssText.replace(regex, slottedSelector.updatedSelector);
1669
1946
  });
1947
+ return cssText;
1670
1948
  };
1671
- var patchNextPrev = (node) => {
1672
- if (!node || node.__nextSibling || !globalThis.Node) return;
1673
- patchNextSibling(node);
1674
- patchPreviousSibling(node);
1675
- if (node.nodeType === Node.ELEMENT_NODE) {
1676
- patchNextElementSibling(node);
1677
- patchPreviousElementSibling(node);
1949
+
1950
+ // src/runtime/mode.ts
1951
+ var computeMode = (elm) => modeResolutionChain.map((h2) => h2(elm)).find((m) => !!m);
1952
+ var setMode = (handler) => modeResolutionChain.push(handler);
1953
+ var getMode = (ref) => getHostRef(ref).$modeName$;
1954
+
1955
+ // src/runtime/proxy-component.ts
1956
+ var import_app_data15 = require("@rindo/core/internal/app-data");
1957
+
1958
+ // src/runtime/set-value.ts
1959
+ var import_app_data14 = require("@rindo/core/internal/app-data");
1960
+
1961
+ // src/runtime/parse-property-value.ts
1962
+ var import_app_data6 = require("@rindo/core/internal/app-data");
1963
+ var parsePropertyValue = (propValue, propType) => {
1964
+ if (propValue != null && !isComplexType(propValue)) {
1965
+ if (import_app_data6.BUILD.propBoolean && propType & 4 /* Boolean */) {
1966
+ return propValue === "false" ? false : propValue === "" || !!propValue;
1967
+ }
1968
+ if (import_app_data6.BUILD.propNumber && propType & 2 /* Number */) {
1969
+ return parseFloat(propValue);
1970
+ }
1971
+ if (import_app_data6.BUILD.propString && propType & 1 /* String */) {
1972
+ return String(propValue);
1973
+ }
1974
+ return propValue;
1678
1975
  }
1976
+ return propValue;
1679
1977
  };
1680
- var patchNextSibling = (node) => {
1681
- if (!node || node.__nextSibling) return;
1682
- patchHostOriginalAccessor("nextSibling", node);
1683
- Object.defineProperty(node, "nextSibling", {
1684
- get: function() {
1685
- var _a;
1686
- const parentNodes = (_a = this["s-ol"]) == null ? void 0 : _a.parentNode.childNodes;
1687
- const index = parentNodes == null ? void 0 : parentNodes.indexOf(this);
1688
- if (parentNodes && index > -1) {
1689
- return parentNodes[index + 1];
1978
+
1979
+ // src/runtime/update-component.ts
1980
+ var import_app_data13 = require("@rindo/core/internal/app-data");
1981
+
1982
+ // src/runtime/event-emitter.ts
1983
+ var import_app_data8 = require("@rindo/core/internal/app-data");
1984
+
1985
+ // src/runtime/element.ts
1986
+ var import_app_data7 = require("@rindo/core/internal/app-data");
1987
+ var getElement = (ref) => import_app_data7.BUILD.lazyLoad ? getHostRef(ref).$hostElement$ : ref;
1988
+
1989
+ // src/runtime/event-emitter.ts
1990
+ var createEvent = (ref, name, flags) => {
1991
+ const elm = getElement(ref);
1992
+ return {
1993
+ emit: (detail) => {
1994
+ if (import_app_data8.BUILD.isDev && !elm.isConnected) {
1995
+ consoleDevWarn(`The "${name}" event was emitted, but the dispatcher node is no longer connected to the dom.`);
1690
1996
  }
1691
- return this.__nextSibling;
1997
+ return emitEvent(elm, name, {
1998
+ bubbles: !!(flags & 4 /* Bubbles */),
1999
+ composed: !!(flags & 2 /* Composed */),
2000
+ cancelable: !!(flags & 1 /* Cancellable */),
2001
+ detail
2002
+ });
1692
2003
  }
1693
- });
2004
+ };
1694
2005
  };
1695
- var patchNextElementSibling = (element) => {
1696
- if (!element || element.__nextElementSibling) return;
1697
- patchHostOriginalAccessor("nextElementSibling", element);
1698
- Object.defineProperty(element, "nextElementSibling", {
1699
- get: function() {
1700
- var _a;
1701
- const parentEles = (_a = this["s-ol"]) == null ? void 0 : _a.parentNode.children;
1702
- const index = parentEles == null ? void 0 : parentEles.indexOf(this);
1703
- if (parentEles && index > -1) {
1704
- return parentEles[index + 1];
1705
- }
1706
- return this.__nextElementSibling;
1707
- }
1708
- });
2006
+ var emitEvent = (elm, name, opts) => {
2007
+ const ev = plt.ce(name, opts);
2008
+ elm.dispatchEvent(ev);
2009
+ return ev;
1709
2010
  };
1710
- var patchPreviousSibling = (node) => {
1711
- if (!node || node.__previousSibling) return;
1712
- patchHostOriginalAccessor("previousSibling", node);
1713
- Object.defineProperty(node, "previousSibling", {
1714
- get: function() {
1715
- var _a;
1716
- const parentNodes = (_a = this["s-ol"]) == null ? void 0 : _a.parentNode.childNodes;
1717
- const index = parentNodes == null ? void 0 : parentNodes.indexOf(this);
1718
- if (parentNodes && index > -1) {
1719
- return parentNodes[index - 1];
1720
- }
1721
- return this.__previousSibling;
2011
+
2012
+ // src/runtime/styles.ts
2013
+ var import_app_data9 = require("@rindo/core/internal/app-data");
2014
+ var rootAppliedStyles = /* @__PURE__ */ new WeakMap();
2015
+ var registerStyle = (scopeId2, cssText, allowCS) => {
2016
+ let style = styles.get(scopeId2);
2017
+ if (supportsConstructableStylesheets && allowCS) {
2018
+ style = style || new CSSStyleSheet();
2019
+ if (typeof style === "string") {
2020
+ style = cssText;
2021
+ } else {
2022
+ style.replaceSync(cssText);
1722
2023
  }
1723
- });
2024
+ } else {
2025
+ style = cssText;
2026
+ }
2027
+ styles.set(scopeId2, style);
1724
2028
  };
1725
- var patchPreviousElementSibling = (element) => {
1726
- if (!element || element.__previousElementSibling) return;
1727
- patchHostOriginalAccessor("previousElementSibling", element);
1728
- Object.defineProperty(element, "previousElementSibling", {
1729
- get: function() {
1730
- var _a;
1731
- const parentNodes = (_a = this["s-ol"]) == null ? void 0 : _a.parentNode.children;
1732
- const index = parentNodes == null ? void 0 : parentNodes.indexOf(this);
1733
- if (parentNodes && index > -1) {
1734
- return parentNodes[index - 1];
2029
+ var addStyle = (styleContainerNode, cmpMeta, mode) => {
2030
+ var _a;
2031
+ const scopeId2 = getScopeId(cmpMeta, mode);
2032
+ const style = styles.get(scopeId2);
2033
+ if (!import_app_data9.BUILD.attachStyles) {
2034
+ return scopeId2;
2035
+ }
2036
+ styleContainerNode = styleContainerNode.nodeType === 11 /* DocumentFragment */ ? styleContainerNode : doc;
2037
+ if (style) {
2038
+ if (typeof style === "string") {
2039
+ styleContainerNode = styleContainerNode.head || styleContainerNode;
2040
+ let appliedStyles = rootAppliedStyles.get(styleContainerNode);
2041
+ let styleElm;
2042
+ if (!appliedStyles) {
2043
+ rootAppliedStyles.set(styleContainerNode, appliedStyles = /* @__PURE__ */ new Set());
1735
2044
  }
1736
- return this.__previousElementSibling;
2045
+ if (!appliedStyles.has(scopeId2)) {
2046
+ if (import_app_data9.BUILD.hydrateClientSide && styleContainerNode.host && (styleElm = styleContainerNode.querySelector(`[${HYDRATED_STYLE_ID}="${scopeId2}"]`))) {
2047
+ styleElm.innerHTML = style;
2048
+ } else {
2049
+ styleElm = document.querySelector(`[${HYDRATED_STYLE_ID}="${scopeId2}"]`) || doc.createElement("style");
2050
+ styleElm.innerHTML = style;
2051
+ const nonce = (_a = plt.$nonce$) != null ? _a : queryNonceMetaTagContent(doc);
2052
+ if (nonce != null) {
2053
+ styleElm.setAttribute("nonce", nonce);
2054
+ }
2055
+ if ((import_app_data9.BUILD.hydrateServerSide || import_app_data9.BUILD.hotModuleReplacement) && (cmpMeta.$flags$ & 2 /* scopedCssEncapsulation */ || cmpMeta.$flags$ & 128 /* shadowNeedsScopedCss */)) {
2056
+ styleElm.setAttribute(HYDRATED_STYLE_ID, scopeId2);
2057
+ }
2058
+ if (!(cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */)) {
2059
+ if (styleContainerNode.nodeName === "HEAD") {
2060
+ const preconnectLinks = styleContainerNode.querySelectorAll("link[rel=preconnect]");
2061
+ const referenceNode2 = preconnectLinks.length > 0 ? preconnectLinks[preconnectLinks.length - 1].nextSibling : styleContainerNode.querySelector("style");
2062
+ styleContainerNode.insertBefore(
2063
+ styleElm,
2064
+ (referenceNode2 == null ? void 0 : referenceNode2.parentNode) === styleContainerNode ? referenceNode2 : null
2065
+ );
2066
+ } else if ("host" in styleContainerNode) {
2067
+ if (supportsConstructableStylesheets) {
2068
+ const stylesheet = new CSSStyleSheet();
2069
+ stylesheet.replaceSync(style);
2070
+ styleContainerNode.adoptedStyleSheets = [stylesheet, ...styleContainerNode.adoptedStyleSheets];
2071
+ } else {
2072
+ const existingStyleContainer = styleContainerNode.querySelector("style");
2073
+ if (existingStyleContainer) {
2074
+ existingStyleContainer.innerHTML = style + existingStyleContainer.innerHTML;
2075
+ } else {
2076
+ styleContainerNode.prepend(styleElm);
2077
+ }
2078
+ }
2079
+ } else {
2080
+ styleContainerNode.append(styleElm);
2081
+ }
2082
+ }
2083
+ if (cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) {
2084
+ styleContainerNode.insertBefore(styleElm, null);
2085
+ }
2086
+ }
2087
+ if (cmpMeta.$flags$ & 4 /* hasSlotRelocation */) {
2088
+ styleElm.innerHTML += SLOT_FB_CSS;
2089
+ }
2090
+ if (appliedStyles) {
2091
+ appliedStyles.add(scopeId2);
2092
+ }
2093
+ }
2094
+ } else if (import_app_data9.BUILD.constructableCSS && !styleContainerNode.adoptedStyleSheets.includes(style)) {
2095
+ styleContainerNode.adoptedStyleSheets = [...styleContainerNode.adoptedStyleSheets, style];
1737
2096
  }
1738
- });
1739
- };
1740
- var validElementPatches = ["children", "nextElementSibling", "previousElementSibling"];
1741
- var validNodesPatches = [
1742
- "childNodes",
1743
- "firstChild",
1744
- "lastChild",
1745
- "nextSibling",
1746
- "previousSibling",
1747
- "textContent"
1748
- ];
1749
- function patchHostOriginalAccessor(accessorName, node) {
1750
- let accessor;
1751
- if (validElementPatches.includes(accessorName)) {
1752
- accessor = Object.getOwnPropertyDescriptor(Element.prototype, accessorName);
1753
- } else if (validNodesPatches.includes(accessorName)) {
1754
- accessor = Object.getOwnPropertyDescriptor(Node.prototype, accessorName);
1755
2097
  }
1756
- if (!accessor) {
1757
- accessor = Object.getOwnPropertyDescriptor(node, accessorName);
2098
+ return scopeId2;
2099
+ };
2100
+ var attachStyles = (hostRef) => {
2101
+ const cmpMeta = hostRef.$cmpMeta$;
2102
+ const elm = hostRef.$hostElement$;
2103
+ const flags = cmpMeta.$flags$;
2104
+ const endAttachStyles = createTime("attachStyles", cmpMeta.$tagName$);
2105
+ const scopeId2 = addStyle(
2106
+ import_app_data9.BUILD.shadowDom && supportsShadow && elm.shadowRoot ? elm.shadowRoot : elm.getRootNode(),
2107
+ cmpMeta,
2108
+ hostRef.$modeName$
2109
+ );
2110
+ if ((import_app_data9.BUILD.shadowDom || import_app_data9.BUILD.scoped) && import_app_data9.BUILD.cssAnnotations && (flags & 10 /* needsScopedEncapsulation */ && flags & 2 /* scopedCssEncapsulation */ || flags & 128 /* shadowNeedsScopedCss */)) {
2111
+ elm["s-sc"] = scopeId2;
2112
+ elm.classList.add(scopeId2 + "-h");
1758
2113
  }
1759
- if (accessor) Object.defineProperty(node, "__" + accessorName, accessor);
1760
- }
1761
-
1762
- // src/runtime/profile.ts
1763
- var import_app_data7 = require("@rindo/core/internal/app-data");
1764
- var i = 0;
1765
- var createTime = (fnName, tagName = "") => {
1766
- if (import_app_data7.BUILD.profile && performance.mark) {
1767
- const key = `st:${fnName}:${tagName}:${i++}`;
1768
- performance.mark(key);
1769
- return () => performance.measure(`[Rindo] ${fnName}() <${tagName}>`, key);
1770
- } else {
1771
- return () => {
1772
- return;
1773
- };
2114
+ endAttachStyles();
2115
+ };
2116
+ var getScopeId = (cmp, mode) => "sc-" + (import_app_data9.BUILD.mode && mode && cmp.$flags$ & 32 /* hasMode */ ? cmp.$tagName$ + "-" + mode : cmp.$tagName$);
2117
+ var convertScopedToShadow = (css) => css.replace(/\/\*!@([^\/]+)\*\/[^\{]+\{/g, "$1{");
2118
+ var hydrateScopedToShadow = () => {
2119
+ const styles2 = doc.querySelectorAll(`[${HYDRATED_STYLE_ID}]`);
2120
+ let i2 = 0;
2121
+ for (; i2 < styles2.length; i2++) {
2122
+ registerStyle(styles2[i2].getAttribute(HYDRATED_STYLE_ID), convertScopedToShadow(styles2[i2].innerHTML), true);
1774
2123
  }
1775
2124
  };
1776
- var uniqueTime = (key, measureText) => {
1777
- if (import_app_data7.BUILD.profile && performance.mark) {
1778
- if (performance.getEntriesByName(key, "mark").length === 0) {
1779
- performance.mark(key);
1780
- }
1781
- return () => {
1782
- if (performance.getEntriesByName(measureText, "measure").length === 0) {
1783
- performance.measure(measureText, key);
2125
+
2126
+ // src/runtime/vdom/vdom-render.ts
2127
+ var import_app_data12 = require("@rindo/core/internal/app-data");
2128
+
2129
+ // src/runtime/vdom/update-element.ts
2130
+ var import_app_data11 = require("@rindo/core/internal/app-data");
2131
+
2132
+ // src/runtime/vdom/set-accessor.ts
2133
+ var import_app_data10 = require("@rindo/core/internal/app-data");
2134
+ var setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags, initialRender) => {
2135
+ if (oldValue !== newValue) {
2136
+ let isProp = isMemberInElement(elm, memberName);
2137
+ let ln = memberName.toLowerCase();
2138
+ if (import_app_data10.BUILD.vdomClass && memberName === "class") {
2139
+ const classList = elm.classList;
2140
+ const oldClasses = parseClassList(oldValue);
2141
+ let newClasses = parseClassList(newValue);
2142
+ if (import_app_data10.BUILD.hydrateClientSide && elm["s-si"] && initialRender) {
2143
+ newClasses.push(elm["s-si"]);
2144
+ oldClasses.forEach((c) => {
2145
+ if (c.startsWith(elm["s-si"])) newClasses.push(c);
2146
+ });
2147
+ newClasses = [...new Set(newClasses)];
2148
+ classList.add(...newClasses);
2149
+ } else {
2150
+ classList.remove(...oldClasses.filter((c) => c && !newClasses.includes(c)));
2151
+ classList.add(...newClasses.filter((c) => c && !oldClasses.includes(c)));
2152
+ }
2153
+ } else if (import_app_data10.BUILD.vdomStyle && memberName === "style") {
2154
+ if (import_app_data10.BUILD.updatable) {
2155
+ for (const prop in oldValue) {
2156
+ if (!newValue || newValue[prop] == null) {
2157
+ if (!import_app_data10.BUILD.hydrateServerSide && prop.includes("-")) {
2158
+ elm.style.removeProperty(prop);
2159
+ } else {
2160
+ elm.style[prop] = "";
2161
+ }
2162
+ }
2163
+ }
2164
+ }
2165
+ for (const prop in newValue) {
2166
+ if (!oldValue || newValue[prop] !== oldValue[prop]) {
2167
+ if (!import_app_data10.BUILD.hydrateServerSide && prop.includes("-")) {
2168
+ elm.style.setProperty(prop, newValue[prop]);
2169
+ } else {
2170
+ elm.style[prop] = newValue[prop];
2171
+ }
2172
+ }
2173
+ }
2174
+ } else if (import_app_data10.BUILD.vdomKey && memberName === "key") {
2175
+ } else if (import_app_data10.BUILD.vdomRef && memberName === "ref") {
2176
+ if (newValue) {
2177
+ newValue(elm);
2178
+ }
2179
+ } else if (import_app_data10.BUILD.vdomListener && (import_app_data10.BUILD.lazyLoad ? !isProp : !elm.__lookupSetter__(memberName)) && memberName[0] === "o" && memberName[1] === "n") {
2180
+ if (memberName[2] === "-") {
2181
+ memberName = memberName.slice(3);
2182
+ } else if (isMemberInElement(win, ln)) {
2183
+ memberName = ln.slice(2);
2184
+ } else {
2185
+ memberName = ln[2] + memberName.slice(3);
2186
+ }
2187
+ if (oldValue || newValue) {
2188
+ const capture = memberName.endsWith(CAPTURE_EVENT_SUFFIX);
2189
+ memberName = memberName.replace(CAPTURE_EVENT_REGEX, "");
2190
+ if (oldValue) {
2191
+ plt.rel(elm, memberName, oldValue, capture);
2192
+ }
2193
+ if (newValue) {
2194
+ plt.ael(elm, memberName, newValue, capture);
2195
+ }
2196
+ }
2197
+ } else if (import_app_data10.BUILD.vdomPropOrAttr) {
2198
+ const isComplex = isComplexType(newValue);
2199
+ if ((isProp || isComplex && newValue !== null) && !isSvg) {
2200
+ try {
2201
+ if (!elm.tagName.includes("-")) {
2202
+ const n = newValue == null ? "" : newValue;
2203
+ if (memberName === "list") {
2204
+ isProp = false;
2205
+ } else if (oldValue == null || elm[memberName] != n) {
2206
+ if (typeof elm.__lookupSetter__(memberName) === "function") {
2207
+ elm[memberName] = n;
2208
+ } else {
2209
+ elm.setAttribute(memberName, n);
2210
+ }
2211
+ }
2212
+ } else if (elm[memberName] !== newValue) {
2213
+ elm[memberName] = newValue;
2214
+ }
2215
+ } catch (e) {
2216
+ }
1784
2217
  }
1785
- };
1786
- } else {
1787
- return () => {
1788
- return;
1789
- };
2218
+ let xlink = false;
2219
+ if (import_app_data10.BUILD.vdomXlink) {
2220
+ if (ln !== (ln = ln.replace(/^xlink\:?/, ""))) {
2221
+ memberName = ln;
2222
+ xlink = true;
2223
+ }
2224
+ }
2225
+ if (newValue == null || newValue === false) {
2226
+ if (newValue !== false || elm.getAttribute(memberName) === "") {
2227
+ if (import_app_data10.BUILD.vdomXlink && xlink) {
2228
+ elm.removeAttributeNS(XLINK_NS, memberName);
2229
+ } else {
2230
+ elm.removeAttribute(memberName);
2231
+ }
2232
+ }
2233
+ } else if ((!isProp || flags & 4 /* isHost */ || isSvg) && !isComplex) {
2234
+ newValue = newValue === true ? "" : newValue;
2235
+ if (import_app_data10.BUILD.vdomXlink && xlink) {
2236
+ elm.setAttributeNS(XLINK_NS, memberName, newValue);
2237
+ } else {
2238
+ elm.setAttribute(memberName, newValue);
2239
+ }
2240
+ }
2241
+ }
1790
2242
  }
1791
2243
  };
1792
- var inspect = (ref) => {
1793
- const hostRef = getHostRef(ref);
1794
- if (!hostRef) {
1795
- return void 0;
2244
+ var parseClassListRegex = /\s/;
2245
+ var parseClassList = (value) => {
2246
+ if (typeof value === "object" && value && "baseVal" in value) {
2247
+ value = value.baseVal;
1796
2248
  }
1797
- const flags = hostRef.$flags$;
1798
- const hostElement = hostRef.$hostElement$;
1799
- return {
1800
- renderCount: hostRef.$renderCount$,
1801
- flags: {
1802
- hasRendered: !!(flags & 2 /* hasRendered */),
1803
- hasConnected: !!(flags & 1 /* hasConnected */),
1804
- isWaitingForChildren: !!(flags & 4 /* isWaitingForChildren */),
1805
- isConstructingInstance: !!(flags & 8 /* isConstructingInstance */),
1806
- isQueuedForUpdate: !!(flags & 16 /* isQueuedForUpdate */),
1807
- hasInitializedComponent: !!(flags & 32 /* hasInitializedComponent */),
1808
- hasLoadedComponent: !!(flags & 64 /* hasLoadedComponent */),
1809
- isWatchReady: !!(flags & 128 /* isWatchReady */),
1810
- isListenReady: !!(flags & 256 /* isListenReady */),
1811
- needsRerender: !!(flags & 512 /* needsRerender */)
1812
- },
1813
- instanceValues: hostRef.$instanceValues$,
1814
- ancestorComponent: hostRef.$ancestorComponent$,
1815
- hostElement,
1816
- lazyInstance: hostRef.$lazyInstance$,
1817
- vnode: hostRef.$vnode$,
1818
- modeName: hostRef.$modeName$,
1819
- onReadyPromise: hostRef.$onReadyPromise$,
1820
- onReadyResolve: hostRef.$onReadyResolve$,
1821
- onInstancePromise: hostRef.$onInstancePromise$,
1822
- onInstanceResolve: hostRef.$onInstanceResolve$,
1823
- onRenderResolve: hostRef.$onRenderResolve$,
1824
- queuedListeners: hostRef.$queuedListeners$,
1825
- rmListeners: hostRef.$rmListeners$,
1826
- ["s-id"]: hostElement["s-id"],
1827
- ["s-cr"]: hostElement["s-cr"],
1828
- ["s-lr"]: hostElement["s-lr"],
1829
- ["s-p"]: hostElement["s-p"],
1830
- ["s-rc"]: hostElement["s-rc"],
1831
- ["s-sc"]: hostElement["s-sc"]
1832
- };
2249
+ if (!value || typeof value !== "string") {
2250
+ return [];
2251
+ }
2252
+ return value.split(parseClassListRegex);
1833
2253
  };
1834
- var installDevTools = () => {
1835
- if (import_app_data7.BUILD.devTools) {
1836
- const rindo = win.rindo = win.rindo || {};
1837
- const originalInspect = rindo.inspect;
1838
- rindo.inspect = (ref) => {
1839
- let result = inspect(ref);
1840
- if (!result && typeof originalInspect === "function") {
1841
- result = originalInspect(ref);
2254
+ var CAPTURE_EVENT_SUFFIX = "Capture";
2255
+ var CAPTURE_EVENT_REGEX = new RegExp(CAPTURE_EVENT_SUFFIX + "$");
2256
+
2257
+ // src/runtime/vdom/update-element.ts
2258
+ var updateElement = (oldVnode, newVnode, isSvgMode2, isInitialRender) => {
2259
+ const elm = newVnode.$elm$.nodeType === 11 /* DocumentFragment */ && newVnode.$elm$.host ? newVnode.$elm$.host : newVnode.$elm$;
2260
+ const oldVnodeAttrs = oldVnode && oldVnode.$attrs$ || {};
2261
+ const newVnodeAttrs = newVnode.$attrs$ || {};
2262
+ if (import_app_data11.BUILD.updatable) {
2263
+ for (const memberName of sortedAttrNames(Object.keys(oldVnodeAttrs))) {
2264
+ if (!(memberName in newVnodeAttrs)) {
2265
+ setAccessor(
2266
+ elm,
2267
+ memberName,
2268
+ oldVnodeAttrs[memberName],
2269
+ void 0,
2270
+ isSvgMode2,
2271
+ newVnode.$flags$,
2272
+ isInitialRender
2273
+ );
1842
2274
  }
1843
- return result;
1844
- };
2275
+ }
2276
+ }
2277
+ for (const memberName of sortedAttrNames(Object.keys(newVnodeAttrs))) {
2278
+ setAccessor(
2279
+ elm,
2280
+ memberName,
2281
+ oldVnodeAttrs[memberName],
2282
+ newVnodeAttrs[memberName],
2283
+ isSvgMode2,
2284
+ newVnode.$flags$,
2285
+ isInitialRender
2286
+ );
1845
2287
  }
1846
2288
  };
2289
+ function sortedAttrNames(attrNames) {
2290
+ return attrNames.includes("ref") ? (
2291
+ // we need to sort these to ensure that `'ref'` is the last attr
2292
+ [...attrNames.filter((attr) => attr !== "ref"), "ref"]
2293
+ ) : (
2294
+ // no need to sort, return the original array
2295
+ attrNames
2296
+ );
2297
+ }
1847
2298
 
1848
- // src/runtime/client-hydrate.ts
1849
- var initializeClientHydrate = (hostElm, tagName, hostId, hostRef) => {
1850
- const endHydrate = createTime("hydrateClient", tagName);
1851
- const shadowRoot = hostElm.shadowRoot;
1852
- const childRenderNodes = [];
1853
- const slotNodes = [];
1854
- const slottedNodes = [];
1855
- const shadowRootNodes = import_app_data8.BUILD.shadowDom && shadowRoot ? [] : null;
1856
- const vnode = newVNode(tagName, null);
1857
- vnode.$elm$ = hostElm;
1858
- let scopeId2;
1859
- if (import_app_data8.BUILD.scoped) {
1860
- const cmpMeta = hostRef.$cmpMeta$;
1861
- if (cmpMeta && cmpMeta.$flags$ & 10 /* needsScopedEncapsulation */ && hostElm["s-sc"]) {
1862
- scopeId2 = hostElm["s-sc"];
1863
- hostElm.classList.add(scopeId2 + "-h");
1864
- } else if (hostElm["s-sc"]) {
1865
- delete hostElm["s-sc"];
2299
+ // src/runtime/vdom/vdom-render.ts
2300
+ var scopeId;
2301
+ var contentRef;
2302
+ var hostTagName;
2303
+ var useNativeShadowDom = false;
2304
+ var checkSlotFallbackVisibility = false;
2305
+ var checkSlotRelocate = false;
2306
+ var isSvgMode = false;
2307
+ var createElm = (oldParentVNode, newParentVNode, childIndex) => {
2308
+ var _a;
2309
+ const newVNode2 = newParentVNode.$children$[childIndex];
2310
+ let i2 = 0;
2311
+ let elm;
2312
+ let childNode;
2313
+ let oldVNode;
2314
+ if (import_app_data12.BUILD.slotRelocation && !useNativeShadowDom) {
2315
+ checkSlotRelocate = true;
2316
+ if (newVNode2.$tag$ === "slot") {
2317
+ newVNode2.$flags$ |= newVNode2.$children$ ? (
2318
+ // slot element has fallback content
2319
+ // still create an element that "mocks" the slot element
2320
+ 2 /* isSlotFallback */
2321
+ ) : (
2322
+ // slot element does not have fallback content
2323
+ // create an html comment we'll use to always reference
2324
+ // where actual slot content should sit next to
2325
+ 1 /* isSlotReference */
2326
+ );
1866
2327
  }
1867
2328
  }
1868
- if (!plt.$orgLocNodes$) {
1869
- initializeDocumentHydrate(doc.body, plt.$orgLocNodes$ = /* @__PURE__ */ new Map());
2329
+ if (import_app_data12.BUILD.isDev && newVNode2.$elm$) {
2330
+ consoleDevError(
2331
+ `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://rindojs.web.app/docs/templating-jsx#avoid-shared-jsx-nodes`
2332
+ );
1870
2333
  }
1871
- hostElm[HYDRATE_ID] = hostId;
1872
- hostElm.removeAttribute(HYDRATE_ID);
1873
- hostRef.$vnode$ = clientHydrate(
1874
- vnode,
1875
- childRenderNodes,
1876
- slotNodes,
1877
- shadowRootNodes,
1878
- hostElm,
1879
- hostElm,
1880
- hostId,
1881
- slottedNodes
1882
- );
1883
- let crIndex = 0;
1884
- const crLength = childRenderNodes.length;
1885
- let childRenderNode;
1886
- for (crIndex; crIndex < crLength; crIndex++) {
1887
- childRenderNode = childRenderNodes[crIndex];
1888
- const orgLocationId = childRenderNode.$hostId$ + "." + childRenderNode.$nodeId$;
1889
- const orgLocationNode = plt.$orgLocNodes$.get(orgLocationId);
1890
- const node = childRenderNode.$elm$;
1891
- if (!shadowRoot) {
1892
- node["s-hn"] = tagName.toUpperCase();
1893
- if (childRenderNode.$tag$ === "slot") {
1894
- node["s-cr"] = hostElm["s-cr"];
1895
- }
2334
+ if (import_app_data12.BUILD.vdomText && newVNode2.$text$ !== null) {
2335
+ elm = newVNode2.$elm$ = doc.createTextNode(newVNode2.$text$);
2336
+ } else if (import_app_data12.BUILD.slotRelocation && newVNode2.$flags$ & 1 /* isSlotReference */) {
2337
+ elm = newVNode2.$elm$ = import_app_data12.BUILD.isDebug || import_app_data12.BUILD.hydrateServerSide ? slotReferenceDebugNode(newVNode2) : doc.createTextNode("");
2338
+ } else {
2339
+ if (import_app_data12.BUILD.svg && !isSvgMode) {
2340
+ isSvgMode = newVNode2.$tag$ === "svg";
1896
2341
  }
1897
- if (childRenderNode.$tag$ === "slot") {
1898
- if (childRenderNode.$children$) {
1899
- childRenderNode.$flags$ |= 2 /* isSlotFallback */;
1900
- if (!childRenderNode.$elm$.childNodes.length) {
1901
- childRenderNode.$children$.forEach((c) => {
1902
- childRenderNode.$elm$.appendChild(c.$elm$);
1903
- });
2342
+ elm = newVNode2.$elm$ = import_app_data12.BUILD.svg ? doc.createElementNS(
2343
+ isSvgMode ? SVG_NS : HTML_NS,
2344
+ !useNativeShadowDom && import_app_data12.BUILD.slotRelocation && newVNode2.$flags$ & 2 /* isSlotFallback */ ? "slot-fb" : newVNode2.$tag$
2345
+ ) : doc.createElement(
2346
+ !useNativeShadowDom && import_app_data12.BUILD.slotRelocation && newVNode2.$flags$ & 2 /* isSlotFallback */ ? "slot-fb" : newVNode2.$tag$
2347
+ );
2348
+ if (import_app_data12.BUILD.svg && isSvgMode && newVNode2.$tag$ === "foreignObject") {
2349
+ isSvgMode = false;
2350
+ }
2351
+ if (import_app_data12.BUILD.vdomAttribute) {
2352
+ updateElement(null, newVNode2, isSvgMode);
2353
+ }
2354
+ if (import_app_data12.BUILD.scoped && isDef(scopeId) && elm["s-si"] !== scopeId) {
2355
+ elm.classList.add(elm["s-si"] = scopeId);
2356
+ }
2357
+ if (newVNode2.$children$) {
2358
+ for (i2 = 0; i2 < newVNode2.$children$.length; ++i2) {
2359
+ childNode = createElm(oldParentVNode, newVNode2, i2);
2360
+ if (childNode) {
2361
+ elm.appendChild(childNode);
1904
2362
  }
1905
- } else {
1906
- childRenderNode.$flags$ |= 1 /* isSlotReference */;
1907
2363
  }
1908
2364
  }
1909
- if (orgLocationNode && orgLocationNode.isConnected) {
1910
- if (shadowRoot && orgLocationNode["s-en"] === "") {
1911
- orgLocationNode.parentNode.insertBefore(node, orgLocationNode.nextSibling);
1912
- }
1913
- orgLocationNode.parentNode.removeChild(orgLocationNode);
1914
- if (!shadowRoot) {
1915
- node["s-oo"] = parseInt(childRenderNode.$nodeId$);
2365
+ if (import_app_data12.BUILD.svg) {
2366
+ if (newVNode2.$tag$ === "svg") {
2367
+ isSvgMode = false;
2368
+ } else if (elm.tagName === "foreignObject") {
2369
+ isSvgMode = true;
1916
2370
  }
1917
2371
  }
1918
- plt.$orgLocNodes$.delete(orgLocationId);
1919
2372
  }
1920
- const hosts = [];
1921
- const snLen = slottedNodes.length;
1922
- let snIndex = 0;
1923
- let slotGroup;
1924
- let snGroupIdx;
1925
- let snGroupLen;
1926
- let slottedItem;
1927
- for (snIndex; snIndex < snLen; snIndex++) {
1928
- slotGroup = slottedNodes[snIndex];
1929
- if (!slotGroup || !slotGroup.length) continue;
1930
- snGroupLen = slotGroup.length;
1931
- snGroupIdx = 0;
1932
- for (snGroupIdx; snGroupIdx < snGroupLen; snGroupIdx++) {
1933
- slottedItem = slotGroup[snGroupIdx];
1934
- if (!hosts[slottedItem.hostId]) {
1935
- hosts[slottedItem.hostId] = plt.$orgLocNodes$.get(slottedItem.hostId);
1936
- }
1937
- if (!hosts[slottedItem.hostId]) continue;
1938
- const hostEle = hosts[slottedItem.hostId];
1939
- if (!hostEle.shadowRoot || !shadowRoot) {
1940
- slottedItem.slot["s-cr"] = hostEle["s-cr"];
1941
- if (!slottedItem.slot["s-cr"] && hostEle.shadowRoot) {
1942
- slottedItem.slot["s-cr"] = hostEle;
2373
+ elm["s-hn"] = hostTagName;
2374
+ if (import_app_data12.BUILD.slotRelocation) {
2375
+ if (newVNode2.$flags$ & (2 /* isSlotFallback */ | 1 /* isSlotReference */)) {
2376
+ elm["s-sr"] = true;
2377
+ elm["s-cr"] = contentRef;
2378
+ elm["s-sn"] = newVNode2.$name$ || "";
2379
+ elm["s-rf"] = (_a = newVNode2.$attrs$) == null ? void 0 : _a.ref;
2380
+ oldVNode = oldParentVNode && oldParentVNode.$children$ && oldParentVNode.$children$[childIndex];
2381
+ if (oldVNode && oldVNode.$tag$ === newVNode2.$tag$ && oldParentVNode.$elm$) {
2382
+ if (import_app_data12.BUILD.experimentalSlotFixes) {
2383
+ relocateToHostRoot(oldParentVNode.$elm$);
1943
2384
  } else {
1944
- slottedItem.slot["s-cr"] = (hostEle.__childNodes || hostEle.childNodes)[0];
1945
- }
1946
- addSlotRelocateNode(slottedItem.node, slottedItem.slot, false, slottedItem.node["s-oo"]);
1947
- if (import_app_data8.BUILD.experimentalSlotFixes) {
1948
- patchNextPrev(slottedItem.node);
2385
+ putBackInOriginalLocation(oldParentVNode.$elm$, false);
1949
2386
  }
1950
2387
  }
1951
- if (hostEle.shadowRoot && slottedItem.node.parentElement !== hostEle) {
1952
- hostEle.appendChild(slottedItem.node);
2388
+ if (import_app_data12.BUILD.scoped) {
2389
+ addRemoveSlotScopedClass(contentRef, elm, newParentVNode.$elm$, oldParentVNode == null ? void 0 : oldParentVNode.$elm$);
1953
2390
  }
1954
2391
  }
1955
2392
  }
1956
- if (import_app_data8.BUILD.scoped && scopeId2 && slotNodes.length) {
1957
- slotNodes.forEach((slot) => {
1958
- slot.$elm$.parentElement.classList.add(scopeId2 + "-s");
1959
- });
2393
+ return elm;
2394
+ };
2395
+ var relocateToHostRoot = (parentElm) => {
2396
+ plt.$flags$ |= 1 /* isTmpDisconnected */;
2397
+ const host = parentElm.closest(hostTagName.toLowerCase());
2398
+ if (host != null) {
2399
+ const contentRefNode = Array.from(host.__childNodes || host.childNodes).find(
2400
+ (ref) => ref["s-cr"]
2401
+ );
2402
+ const childNodeArray = Array.from(
2403
+ parentElm.__childNodes || parentElm.childNodes
2404
+ );
2405
+ for (const childNode of contentRefNode ? childNodeArray.reverse() : childNodeArray) {
2406
+ if (childNode["s-sh"] != null) {
2407
+ insertBefore(host, childNode, contentRefNode != null ? contentRefNode : null);
2408
+ childNode["s-sh"] = void 0;
2409
+ checkSlotRelocate = true;
2410
+ }
2411
+ }
1960
2412
  }
1961
- if (import_app_data8.BUILD.shadowDom && shadowRoot) {
1962
- let rnIdex = 0;
1963
- const rnLen = shadowRootNodes.length;
1964
- for (rnIdex; rnIdex < rnLen; rnIdex++) {
1965
- shadowRoot.appendChild(shadowRootNodes[rnIdex]);
2413
+ plt.$flags$ &= ~1 /* isTmpDisconnected */;
2414
+ };
2415
+ var putBackInOriginalLocation = (parentElm, recursive) => {
2416
+ plt.$flags$ |= 1 /* isTmpDisconnected */;
2417
+ const oldSlotChildNodes = Array.from(parentElm.__childNodes || parentElm.childNodes);
2418
+ if (parentElm["s-sr"] && import_app_data12.BUILD.experimentalSlotFixes) {
2419
+ let node = parentElm;
2420
+ while (node = node.nextSibling) {
2421
+ if (node && node["s-sn"] === parentElm["s-sn"] && node["s-sh"] === hostTagName) {
2422
+ oldSlotChildNodes.push(node);
2423
+ }
2424
+ }
2425
+ }
2426
+ for (let i2 = oldSlotChildNodes.length - 1; i2 >= 0; i2--) {
2427
+ const childNode = oldSlotChildNodes[i2];
2428
+ if (childNode["s-hn"] !== hostTagName && childNode["s-ol"]) {
2429
+ insertBefore(referenceNode(childNode).parentNode, childNode, referenceNode(childNode));
2430
+ childNode["s-ol"].remove();
2431
+ childNode["s-ol"] = void 0;
2432
+ childNode["s-sh"] = void 0;
2433
+ checkSlotRelocate = true;
2434
+ }
2435
+ if (recursive) {
2436
+ putBackInOriginalLocation(childNode, recursive);
1966
2437
  }
1967
- Array.from(hostElm.childNodes).forEach((node) => {
1968
- if (node.nodeType === 8 /* CommentNode */ && typeof node["s-sn"] !== "string") {
1969
- node.parentNode.removeChild(node);
2438
+ }
2439
+ plt.$flags$ &= ~1 /* isTmpDisconnected */;
2440
+ };
2441
+ var addVnodes = (parentElm, before, parentVNode, vnodes, startIdx, endIdx) => {
2442
+ let containerElm = import_app_data12.BUILD.slotRelocation && parentElm["s-cr"] && parentElm["s-cr"].parentNode || parentElm;
2443
+ let childNode;
2444
+ if (import_app_data12.BUILD.shadowDom && containerElm.shadowRoot && containerElm.tagName === hostTagName) {
2445
+ containerElm = containerElm.shadowRoot;
2446
+ }
2447
+ for (; startIdx <= endIdx; ++startIdx) {
2448
+ if (vnodes[startIdx]) {
2449
+ childNode = createElm(null, parentVNode, startIdx);
2450
+ if (childNode) {
2451
+ vnodes[startIdx].$elm$ = childNode;
2452
+ insertBefore(containerElm, childNode, import_app_data12.BUILD.slotRelocation ? referenceNode(before) : before);
1970
2453
  }
1971
- });
2454
+ }
1972
2455
  }
1973
- hostRef.$hostElement$ = hostElm;
1974
- endHydrate();
1975
2456
  };
1976
- var clientHydrate = (parentVNode, childRenderNodes, slotNodes, shadowRootNodes, hostElm, node, hostId, slottedNodes = []) => {
1977
- let childNodeType;
1978
- let childIdSplt;
1979
- let childVNode;
1980
- let i2;
1981
- const scopeId2 = hostElm["s-sc"];
1982
- if (node.nodeType === 1 /* ElementNode */) {
1983
- childNodeType = node.getAttribute(HYDRATE_CHILD_ID);
1984
- if (childNodeType) {
1985
- childIdSplt = childNodeType.split(".");
1986
- if (childIdSplt[0] === hostId || childIdSplt[0] === "0") {
1987
- childVNode = createSimpleVNode({
1988
- $flags$: 0,
1989
- $hostId$: childIdSplt[0],
1990
- $nodeId$: childIdSplt[1],
1991
- $depth$: childIdSplt[2],
1992
- $index$: childIdSplt[3],
1993
- $tag$: node.tagName.toLowerCase(),
1994
- $elm$: node,
1995
- // If we don't add the initial classes to the VNode, the first `vdom-render.ts` patch
1996
- // won't try to reconcile them. Classes set on the node will be blown away.
1997
- $attrs$: { class: node.className || "" }
1998
- });
1999
- childRenderNodes.push(childVNode);
2000
- node.removeAttribute(HYDRATE_CHILD_ID);
2001
- if (!parentVNode.$children$) {
2002
- parentVNode.$children$ = [];
2003
- }
2004
- if (import_app_data8.BUILD.scoped && scopeId2) {
2005
- node["s-si"] = scopeId2;
2006
- childVNode.$attrs$.class += " " + scopeId2;
2007
- }
2008
- const slotName = childVNode.$elm$.getAttribute("s-sn");
2009
- if (typeof slotName === "string") {
2010
- if (childVNode.$tag$ === "slot-fb") {
2011
- addSlot(
2012
- slotName,
2013
- childIdSplt[2],
2014
- childVNode,
2015
- node,
2016
- parentVNode,
2017
- childRenderNodes,
2018
- slotNodes,
2019
- shadowRootNodes,
2020
- slottedNodes
2021
- );
2022
- if (import_app_data8.BUILD.scoped && scopeId2) {
2023
- node.classList.add(scopeId2);
2024
- }
2457
+ var removeVnodes = (vnodes, startIdx, endIdx) => {
2458
+ for (let index = startIdx; index <= endIdx; ++index) {
2459
+ const vnode = vnodes[index];
2460
+ if (vnode) {
2461
+ const elm = vnode.$elm$;
2462
+ nullifyVNodeRefs(vnode);
2463
+ if (elm) {
2464
+ if (import_app_data12.BUILD.slotRelocation) {
2465
+ checkSlotFallbackVisibility = true;
2466
+ if (elm["s-ol"]) {
2467
+ elm["s-ol"].remove();
2468
+ } else {
2469
+ putBackInOriginalLocation(elm, true);
2025
2470
  }
2026
- childVNode.$elm$["s-sn"] = slotName;
2027
- childVNode.$elm$.removeAttribute("s-sn");
2028
- }
2029
- if (childVNode.$index$ !== void 0) {
2030
- parentVNode.$children$[childVNode.$index$] = childVNode;
2031
- }
2032
- parentVNode = childVNode;
2033
- if (shadowRootNodes && childVNode.$depth$ === "0") {
2034
- shadowRootNodes[childVNode.$index$] = childVNode.$elm$;
2035
2471
  }
2472
+ elm.remove();
2036
2473
  }
2037
2474
  }
2038
- if (node.shadowRoot) {
2039
- for (i2 = node.shadowRoot.childNodes.length - 1; i2 >= 0; i2--) {
2040
- clientHydrate(
2041
- parentVNode,
2042
- childRenderNodes,
2043
- slotNodes,
2044
- shadowRootNodes,
2045
- hostElm,
2046
- node.shadowRoot.childNodes[i2],
2047
- hostId,
2048
- slottedNodes
2049
- );
2475
+ }
2476
+ };
2477
+ var updateChildren = (parentElm, oldCh, newVNode2, newCh, isInitialRender = false) => {
2478
+ let oldStartIdx = 0;
2479
+ let newStartIdx = 0;
2480
+ let idxInOld = 0;
2481
+ let i2 = 0;
2482
+ let oldEndIdx = oldCh.length - 1;
2483
+ let oldStartVnode = oldCh[0];
2484
+ let oldEndVnode = oldCh[oldEndIdx];
2485
+ let newEndIdx = newCh.length - 1;
2486
+ let newStartVnode = newCh[0];
2487
+ let newEndVnode = newCh[newEndIdx];
2488
+ let node;
2489
+ let elmToMove;
2490
+ while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
2491
+ if (oldStartVnode == null) {
2492
+ oldStartVnode = oldCh[++oldStartIdx];
2493
+ } else if (oldEndVnode == null) {
2494
+ oldEndVnode = oldCh[--oldEndIdx];
2495
+ } else if (newStartVnode == null) {
2496
+ newStartVnode = newCh[++newStartIdx];
2497
+ } else if (newEndVnode == null) {
2498
+ newEndVnode = newCh[--newEndIdx];
2499
+ } else if (isSameVnode(oldStartVnode, newStartVnode, isInitialRender)) {
2500
+ patch(oldStartVnode, newStartVnode, isInitialRender);
2501
+ oldStartVnode = oldCh[++oldStartIdx];
2502
+ newStartVnode = newCh[++newStartIdx];
2503
+ } else if (isSameVnode(oldEndVnode, newEndVnode, isInitialRender)) {
2504
+ patch(oldEndVnode, newEndVnode, isInitialRender);
2505
+ oldEndVnode = oldCh[--oldEndIdx];
2506
+ newEndVnode = newCh[--newEndIdx];
2507
+ } else if (isSameVnode(oldStartVnode, newEndVnode, isInitialRender)) {
2508
+ if (import_app_data12.BUILD.slotRelocation && (oldStartVnode.$tag$ === "slot" || newEndVnode.$tag$ === "slot")) {
2509
+ putBackInOriginalLocation(oldStartVnode.$elm$.parentNode, false);
2050
2510
  }
2051
- }
2052
- const nonShadowNodes = node.__childNodes || node.childNodes;
2053
- for (i2 = nonShadowNodes.length - 1; i2 >= 0; i2--) {
2054
- clientHydrate(
2055
- parentVNode,
2056
- childRenderNodes,
2057
- slotNodes,
2058
- shadowRootNodes,
2059
- hostElm,
2060
- nonShadowNodes[i2],
2061
- hostId,
2062
- slottedNodes
2063
- );
2064
- }
2065
- } else if (node.nodeType === 8 /* CommentNode */) {
2066
- childIdSplt = node.nodeValue.split(".");
2067
- if (childIdSplt[1] === hostId || childIdSplt[1] === "0") {
2068
- childNodeType = childIdSplt[0];
2069
- childVNode = createSimpleVNode({
2070
- $hostId$: childIdSplt[1],
2071
- $nodeId$: childIdSplt[2],
2072
- $depth$: childIdSplt[3],
2073
- $index$: childIdSplt[4] || "0",
2074
- $elm$: node,
2075
- $attrs$: null,
2076
- $children$: null,
2077
- $key$: null,
2078
- $name$: null,
2079
- $tag$: null,
2080
- $text$: null
2081
- });
2082
- if (childNodeType === TEXT_NODE_ID) {
2083
- childVNode.$elm$ = node.nextSibling;
2084
- if (childVNode.$elm$ && childVNode.$elm$.nodeType === 3 /* TextNode */) {
2085
- childVNode.$text$ = childVNode.$elm$.textContent;
2086
- childRenderNodes.push(childVNode);
2087
- node.remove();
2088
- if (hostId === childVNode.$hostId$) {
2089
- if (!parentVNode.$children$) {
2090
- parentVNode.$children$ = [];
2091
- }
2092
- parentVNode.$children$[childVNode.$index$] = childVNode;
2093
- }
2094
- if (shadowRootNodes && childVNode.$depth$ === "0") {
2095
- shadowRootNodes[childVNode.$index$] = childVNode.$elm$;
2511
+ patch(oldStartVnode, newEndVnode, isInitialRender);
2512
+ insertBefore(parentElm, oldStartVnode.$elm$, oldEndVnode.$elm$.nextSibling);
2513
+ oldStartVnode = oldCh[++oldStartIdx];
2514
+ newEndVnode = newCh[--newEndIdx];
2515
+ } else if (isSameVnode(oldEndVnode, newStartVnode, isInitialRender)) {
2516
+ if (import_app_data12.BUILD.slotRelocation && (oldStartVnode.$tag$ === "slot" || newEndVnode.$tag$ === "slot")) {
2517
+ putBackInOriginalLocation(oldEndVnode.$elm$.parentNode, false);
2518
+ }
2519
+ patch(oldEndVnode, newStartVnode, isInitialRender);
2520
+ insertBefore(parentElm, oldEndVnode.$elm$, oldStartVnode.$elm$);
2521
+ oldEndVnode = oldCh[--oldEndIdx];
2522
+ newStartVnode = newCh[++newStartIdx];
2523
+ } else {
2524
+ idxInOld = -1;
2525
+ if (import_app_data12.BUILD.vdomKey) {
2526
+ for (i2 = oldStartIdx; i2 <= oldEndIdx; ++i2) {
2527
+ if (oldCh[i2] && oldCh[i2].$key$ !== null && oldCh[i2].$key$ === newStartVnode.$key$) {
2528
+ idxInOld = i2;
2529
+ break;
2096
2530
  }
2097
2531
  }
2098
- } else if (childNodeType === COMMENT_NODE_ID) {
2099
- childVNode.$elm$ = node.nextSibling;
2100
- if (childVNode.$elm$ && childVNode.$elm$.nodeType === 8 /* CommentNode */) {
2101
- childRenderNodes.push(childVNode);
2102
- node.remove();
2532
+ }
2533
+ if (import_app_data12.BUILD.vdomKey && idxInOld >= 0) {
2534
+ elmToMove = oldCh[idxInOld];
2535
+ if (elmToMove.$tag$ !== newStartVnode.$tag$) {
2536
+ node = createElm(oldCh && oldCh[newStartIdx], newVNode2, idxInOld);
2537
+ } else {
2538
+ patch(elmToMove, newStartVnode, isInitialRender);
2539
+ oldCh[idxInOld] = void 0;
2540
+ node = elmToMove.$elm$;
2103
2541
  }
2104
- } else if (childVNode.$hostId$ === hostId) {
2105
- if (childNodeType === SLOT_NODE_ID) {
2106
- const slotName = node["s-sn"] = childIdSplt[5] || "";
2107
- addSlot(
2108
- slotName,
2109
- childIdSplt[2],
2110
- childVNode,
2542
+ newStartVnode = newCh[++newStartIdx];
2543
+ } else {
2544
+ node = createElm(oldCh && oldCh[newStartIdx], newVNode2, newStartIdx);
2545
+ newStartVnode = newCh[++newStartIdx];
2546
+ }
2547
+ if (node) {
2548
+ if (import_app_data12.BUILD.slotRelocation) {
2549
+ insertBefore(
2550
+ referenceNode(oldStartVnode.$elm$).parentNode,
2111
2551
  node,
2112
- parentVNode,
2113
- childRenderNodes,
2114
- slotNodes,
2115
- shadowRootNodes,
2116
- slottedNodes
2552
+ referenceNode(oldStartVnode.$elm$)
2117
2553
  );
2118
- } else if (childNodeType === CONTENT_REF_ID) {
2119
- if (import_app_data8.BUILD.shadowDom && shadowRootNodes) {
2120
- node.remove();
2121
- } else if (import_app_data8.BUILD.slotRelocation) {
2122
- hostElm["s-cr"] = node;
2123
- node["s-cn"] = true;
2124
- }
2554
+ } else {
2555
+ insertBefore(oldStartVnode.$elm$.parentNode, node, oldStartVnode.$elm$);
2125
2556
  }
2126
2557
  }
2127
2558
  }
2128
- } else if (parentVNode && parentVNode.$tag$ === "style") {
2129
- const vnode = newVNode(null, node.textContent);
2130
- vnode.$elm$ = node;
2131
- vnode.$index$ = "0";
2132
- parentVNode.$children$ = [vnode];
2133
2559
  }
2134
- return parentVNode;
2560
+ if (oldStartIdx > oldEndIdx) {
2561
+ addVnodes(
2562
+ parentElm,
2563
+ newCh[newEndIdx + 1] == null ? null : newCh[newEndIdx + 1].$elm$,
2564
+ newVNode2,
2565
+ newCh,
2566
+ newStartIdx,
2567
+ newEndIdx
2568
+ );
2569
+ } else if (import_app_data12.BUILD.updatable && newStartIdx > newEndIdx) {
2570
+ removeVnodes(oldCh, oldStartIdx, oldEndIdx);
2571
+ }
2135
2572
  };
2136
- var initializeDocumentHydrate = (node, orgLocNodes) => {
2137
- if (node.nodeType === 1 /* ElementNode */) {
2138
- const componentId = node[HYDRATE_ID] || node.getAttribute(HYDRATE_ID);
2139
- if (componentId) {
2140
- orgLocNodes.set(componentId, node);
2141
- }
2142
- let i2 = 0;
2143
- if (node.shadowRoot) {
2144
- for (; i2 < node.shadowRoot.childNodes.length; i2++) {
2145
- initializeDocumentHydrate(node.shadowRoot.childNodes[i2], orgLocNodes);
2146
- }
2573
+ var isSameVnode = (leftVNode, rightVNode, isInitialRender = false) => {
2574
+ if (leftVNode.$tag$ === rightVNode.$tag$) {
2575
+ if (import_app_data12.BUILD.slotRelocation && leftVNode.$tag$ === "slot") {
2576
+ return leftVNode.$name$ === rightVNode.$name$;
2147
2577
  }
2148
- const nonShadowNodes = node.__childNodes || node.childNodes;
2149
- for (i2 = 0; i2 < nonShadowNodes.length; i2++) {
2150
- initializeDocumentHydrate(nonShadowNodes[i2], orgLocNodes);
2578
+ if (import_app_data12.BUILD.vdomKey && !isInitialRender) {
2579
+ return leftVNode.$key$ === rightVNode.$key$;
2151
2580
  }
2152
- } else if (node.nodeType === 8 /* CommentNode */) {
2153
- const childIdSplt = node.nodeValue.split(".");
2154
- if (childIdSplt[0] === ORG_LOCATION_ID) {
2155
- orgLocNodes.set(childIdSplt[1] + "." + childIdSplt[2], node);
2156
- node.nodeValue = "";
2157
- node["s-en"] = childIdSplt[3];
2581
+ if (isInitialRender && !leftVNode.$key$ && rightVNode.$key$) {
2582
+ leftVNode.$key$ = rightVNode.$key$;
2158
2583
  }
2584
+ return true;
2159
2585
  }
2586
+ return false;
2160
2587
  };
2161
- var createSimpleVNode = (vnode) => {
2162
- const defaultVNode = {
2163
- $flags$: 0,
2164
- $hostId$: null,
2165
- $nodeId$: null,
2166
- $depth$: null,
2167
- $index$: "0",
2168
- $elm$: null,
2169
- $attrs$: null,
2170
- $children$: null,
2171
- $key$: null,
2172
- $name$: null,
2173
- $tag$: null,
2174
- $text$: null
2175
- };
2176
- return { ...defaultVNode, ...vnode };
2177
- };
2178
- function addSlot(slotName, slotId, childVNode, node, parentVNode, childRenderNodes, slotNodes, shadowRootNodes, slottedNodes) {
2179
- node["s-sr"] = true;
2180
- childVNode.$name$ = slotName || null;
2181
- childVNode.$tag$ = "slot";
2182
- const parentNodeId = (parentVNode == null ? void 0 : parentVNode.$elm$) ? parentVNode.$elm$["s-id"] || parentVNode.$elm$.getAttribute("s-id") : "";
2183
- if (import_app_data8.BUILD.shadowDom && shadowRootNodes) {
2184
- const slot = childVNode.$elm$ = doc.createElement(childVNode.$tag$);
2185
- if (childVNode.$name$) {
2186
- childVNode.$elm$.setAttribute("name", slotName);
2588
+ var referenceNode = (node) => node && node["s-ol"] || node;
2589
+ var patch = (oldVNode, newVNode2, isInitialRender = false) => {
2590
+ const elm = newVNode2.$elm$ = oldVNode.$elm$;
2591
+ const oldChildren = oldVNode.$children$;
2592
+ const newChildren = newVNode2.$children$;
2593
+ const tag = newVNode2.$tag$;
2594
+ const text = newVNode2.$text$;
2595
+ let defaultHolder;
2596
+ if (!import_app_data12.BUILD.vdomText || text === null) {
2597
+ if (import_app_data12.BUILD.svg) {
2598
+ isSvgMode = tag === "svg" ? true : tag === "foreignObject" ? false : isSvgMode;
2187
2599
  }
2188
- if (parentNodeId && parentNodeId !== childVNode.$hostId$) {
2189
- parentVNode.$elm$.insertBefore(slot, parentVNode.$elm$.children[0]);
2190
- } else {
2191
- node.parentNode.insertBefore(childVNode.$elm$, node);
2600
+ if (import_app_data12.BUILD.vdomAttribute || import_app_data12.BUILD.reflect) {
2601
+ if (import_app_data12.BUILD.slot && tag === "slot" && !useNativeShadowDom) {
2602
+ if (import_app_data12.BUILD.experimentalSlotFixes && oldVNode.$name$ !== newVNode2.$name$) {
2603
+ newVNode2.$elm$["s-sn"] = newVNode2.$name$ || "";
2604
+ relocateToHostRoot(newVNode2.$elm$.parentElement);
2605
+ }
2606
+ } else {
2607
+ updateElement(oldVNode, newVNode2, isSvgMode, isInitialRender);
2608
+ }
2192
2609
  }
2193
- addSlottedNodes(slottedNodes, slotId, slotName, node, childVNode.$hostId$);
2194
- node.remove();
2195
- if (childVNode.$depth$ === "0") {
2196
- shadowRootNodes[childVNode.$index$] = childVNode.$elm$;
2610
+ if (import_app_data12.BUILD.updatable && oldChildren !== null && newChildren !== null) {
2611
+ updateChildren(elm, oldChildren, newVNode2, newChildren, isInitialRender);
2612
+ } else if (newChildren !== null) {
2613
+ if (import_app_data12.BUILD.updatable && import_app_data12.BUILD.vdomText && oldVNode.$text$ !== null) {
2614
+ elm.textContent = "";
2615
+ }
2616
+ addVnodes(elm, null, newVNode2, newChildren, 0, newChildren.length - 1);
2617
+ } else if (
2618
+ // don't do this on initial render as it can cause non-hydrated content to be removed
2619
+ !isInitialRender && import_app_data12.BUILD.updatable && oldChildren !== null
2620
+ ) {
2621
+ removeVnodes(oldChildren, 0, oldChildren.length - 1);
2197
2622
  }
2198
- } else {
2199
- const slot = childVNode.$elm$;
2200
- const shouldMove = parentNodeId && parentNodeId !== childVNode.$hostId$ && parentVNode.$elm$.shadowRoot;
2201
- addSlottedNodes(slottedNodes, slotId, slotName, node, shouldMove ? parentNodeId : childVNode.$hostId$);
2202
- if (shouldMove) {
2203
- parentVNode.$elm$.insertBefore(slot, parentVNode.$elm$.children[0]);
2623
+ if (import_app_data12.BUILD.svg && isSvgMode && tag === "svg") {
2624
+ isSvgMode = false;
2204
2625
  }
2205
- childRenderNodes.push(childVNode);
2626
+ } else if (import_app_data12.BUILD.vdomText && import_app_data12.BUILD.slotRelocation && (defaultHolder = elm["s-cr"])) {
2627
+ defaultHolder.parentNode.textContent = text;
2628
+ } else if (import_app_data12.BUILD.vdomText && oldVNode.$text$ !== text) {
2629
+ elm.data = text;
2206
2630
  }
2207
- slotNodes.push(childVNode);
2208
- if (!parentVNode.$children$) {
2209
- parentVNode.$children$ = [];
2631
+ };
2632
+ var relocateNodes = [];
2633
+ var markSlotContentForRelocation = (elm) => {
2634
+ let node;
2635
+ let hostContentNodes;
2636
+ let j;
2637
+ const children = elm.__childNodes || elm.childNodes;
2638
+ for (const childNode of children) {
2639
+ if (childNode["s-sr"] && (node = childNode["s-cr"]) && node.parentNode) {
2640
+ hostContentNodes = node.parentNode.__childNodes || node.parentNode.childNodes;
2641
+ const slotName = childNode["s-sn"];
2642
+ for (j = hostContentNodes.length - 1; j >= 0; j--) {
2643
+ node = hostContentNodes[j];
2644
+ if (!node["s-cn"] && !node["s-nr"] && node["s-hn"] !== childNode["s-hn"] && (!import_app_data12.BUILD.experimentalSlotFixes || !node["s-sh"] || node["s-sh"] !== childNode["s-hn"])) {
2645
+ if (isNodeLocatedInSlot(node, slotName)) {
2646
+ let relocateNodeData = relocateNodes.find((r) => r.$nodeToRelocate$ === node);
2647
+ checkSlotFallbackVisibility = true;
2648
+ node["s-sn"] = node["s-sn"] || slotName;
2649
+ if (relocateNodeData) {
2650
+ relocateNodeData.$nodeToRelocate$["s-sh"] = childNode["s-hn"];
2651
+ relocateNodeData.$slotRefNode$ = childNode;
2652
+ } else {
2653
+ node["s-sh"] = childNode["s-hn"];
2654
+ relocateNodes.push({
2655
+ $slotRefNode$: childNode,
2656
+ $nodeToRelocate$: node
2657
+ });
2658
+ }
2659
+ if (node["s-sr"]) {
2660
+ relocateNodes.map((relocateNode) => {
2661
+ if (isNodeLocatedInSlot(relocateNode.$nodeToRelocate$, node["s-sn"])) {
2662
+ relocateNodeData = relocateNodes.find((r) => r.$nodeToRelocate$ === node);
2663
+ if (relocateNodeData && !relocateNode.$slotRefNode$) {
2664
+ relocateNode.$slotRefNode$ = relocateNodeData.$slotRefNode$;
2665
+ }
2666
+ }
2667
+ });
2668
+ }
2669
+ } else if (!relocateNodes.some((r) => r.$nodeToRelocate$ === node)) {
2670
+ relocateNodes.push({
2671
+ $nodeToRelocate$: node
2672
+ });
2673
+ }
2674
+ }
2675
+ }
2676
+ }
2677
+ if (childNode.nodeType === 1 /* ElementNode */) {
2678
+ markSlotContentForRelocation(childNode);
2679
+ }
2210
2680
  }
2211
- parentVNode.$children$[childVNode.$index$] = childVNode;
2212
- }
2213
- var addSlottedNodes = (slottedNodes, slotNodeId, slotName, slotNode, hostId) => {
2214
- let slottedNode = slotNode.nextSibling;
2215
- slottedNodes[slotNodeId] = slottedNodes[slotNodeId] || [];
2216
- 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 */))) {
2217
- slottedNode["s-sn"] = slotName;
2218
- slottedNodes[slotNodeId].push({ slot: slotNode, node: slottedNode, hostId });
2219
- slottedNode = slottedNode.nextSibling;
2681
+ };
2682
+ var nullifyVNodeRefs = (vNode) => {
2683
+ if (import_app_data12.BUILD.vdomRef) {
2684
+ vNode.$attrs$ && vNode.$attrs$.ref && vNode.$attrs$.ref(null);
2685
+ vNode.$children$ && vNode.$children$.map(nullifyVNodeRefs);
2220
2686
  }
2221
2687
  };
2222
-
2223
- // src/runtime/initialize-component.ts
2224
- var import_app_data16 = require("@rindo/core/internal/app-data");
2225
-
2226
- // src/runtime/mode.ts
2227
- var computeMode = (elm) => modeResolutionChain.map((h2) => h2(elm)).find((m) => !!m);
2228
- var setMode = (handler) => modeResolutionChain.push(handler);
2229
- var getMode = (ref) => getHostRef(ref).$modeName$;
2230
-
2231
- // src/runtime/proxy-component.ts
2232
- var import_app_data15 = require("@rindo/core/internal/app-data");
2233
-
2234
- // src/runtime/set-value.ts
2235
- var import_app_data14 = require("@rindo/core/internal/app-data");
2236
-
2237
- // src/runtime/parse-property-value.ts
2238
- var import_app_data9 = require("@rindo/core/internal/app-data");
2239
- var parsePropertyValue = (propValue, propType) => {
2240
- if (propValue != null && !isComplexType(propValue)) {
2241
- if (import_app_data9.BUILD.propBoolean && propType & 4 /* Boolean */) {
2242
- return propValue === "false" ? false : propValue === "" || !!propValue;
2243
- }
2244
- if (import_app_data9.BUILD.propNumber && propType & 2 /* Number */) {
2245
- return parseFloat(propValue);
2688
+ var insertBefore = (parent, newNode, reference) => {
2689
+ if (import_app_data12.BUILD.scoped && typeof newNode["s-sn"] === "string" && !!newNode["s-sr"] && !!newNode["s-cr"]) {
2690
+ addRemoveSlotScopedClass(newNode["s-cr"], newNode, parent, newNode.parentElement);
2691
+ } else if (import_app_data12.BUILD.experimentalSlotFixes && typeof newNode["s-sn"] === "string") {
2692
+ if (parent.getRootNode().nodeType !== 11 /* DOCUMENT_FRAGMENT_NODE */) {
2693
+ patchParentNode(newNode);
2246
2694
  }
2247
- if (import_app_data9.BUILD.propString && propType & 1 /* String */) {
2248
- return String(propValue);
2695
+ return parent.insertBefore(newNode, reference);
2696
+ }
2697
+ if (import_app_data12.BUILD.experimentalSlotFixes && parent.__insertBefore) {
2698
+ return parent.__insertBefore(newNode, reference);
2699
+ } else {
2700
+ return parent == null ? void 0 : parent.insertBefore(newNode, reference);
2701
+ }
2702
+ };
2703
+ function addRemoveSlotScopedClass(reference, slotNode, newParent, oldParent) {
2704
+ var _a, _b;
2705
+ let scopeId2;
2706
+ if (reference && typeof slotNode["s-sn"] === "string" && !!slotNode["s-sr"] && reference.parentNode && reference.parentNode["s-sc"] && (scopeId2 = slotNode["s-si"] || reference.parentNode["s-sc"])) {
2707
+ const scopeName = slotNode["s-sn"];
2708
+ const hostName = slotNode["s-hn"];
2709
+ (_a = newParent.classList) == null ? void 0 : _a.add(scopeId2 + "-s");
2710
+ if (oldParent && ((_b = oldParent.classList) == null ? void 0 : _b.contains(scopeId2 + "-s"))) {
2711
+ let child = (oldParent.__childNodes || oldParent.childNodes)[0];
2712
+ let found = false;
2713
+ while (child) {
2714
+ if (child["s-sn"] !== scopeName && child["s-hn"] === hostName && !!child["s-sr"]) {
2715
+ found = true;
2716
+ break;
2717
+ }
2718
+ child = child.nextSibling;
2719
+ }
2720
+ if (!found) oldParent.classList.remove(scopeId2 + "-s");
2249
2721
  }
2250
- return propValue;
2251
2722
  }
2252
- return propValue;
2253
- };
2254
-
2255
- // src/runtime/update-component.ts
2256
- var import_app_data13 = require("@rindo/core/internal/app-data");
2257
-
2258
- // src/runtime/event-emitter.ts
2259
- var import_app_data11 = require("@rindo/core/internal/app-data");
2723
+ }
2724
+ var renderVdom = (hostRef, renderFnResults, isInitialLoad = false) => {
2725
+ var _a, _b, _c, _d, _e;
2726
+ const hostElm = hostRef.$hostElement$;
2727
+ const cmpMeta = hostRef.$cmpMeta$;
2728
+ const oldVNode = hostRef.$vnode$ || newVNode(null, null);
2729
+ const rootVnode = isHost(renderFnResults) ? renderFnResults : h(null, null, renderFnResults);
2730
+ hostTagName = hostElm.tagName;
2731
+ if (import_app_data12.BUILD.isDev && Array.isArray(renderFnResults) && renderFnResults.some(isHost)) {
2732
+ throw new Error(`The <Host> must be the single root component.
2733
+ Looks like the render() function of "${hostTagName.toLowerCase()}" is returning an array that contains the <Host>.
2260
2734
 
2261
- // src/runtime/element.ts
2262
- var import_app_data10 = require("@rindo/core/internal/app-data");
2263
- var getElement = (ref) => import_app_data10.BUILD.lazyLoad ? getHostRef(ref).$hostElement$ : ref;
2735
+ The render() function should look like this instead:
2264
2736
 
2265
- // src/runtime/event-emitter.ts
2266
- var createEvent = (ref, name, flags) => {
2267
- const elm = getElement(ref);
2268
- return {
2269
- emit: (detail) => {
2270
- if (import_app_data11.BUILD.isDev && !elm.isConnected) {
2271
- consoleDevWarn(`The "${name}" event was emitted, but the dispatcher node is no longer connected to the dom.`);
2737
+ render() {
2738
+ // Do not return an array
2739
+ return (
2740
+ <Host>{content}</Host>
2741
+ );
2742
+ }
2743
+ `);
2744
+ }
2745
+ if (import_app_data12.BUILD.reflect && cmpMeta.$attrsToReflect$) {
2746
+ rootVnode.$attrs$ = rootVnode.$attrs$ || {};
2747
+ cmpMeta.$attrsToReflect$.map(
2748
+ ([propName, attribute]) => rootVnode.$attrs$[attribute] = hostElm[propName]
2749
+ );
2750
+ }
2751
+ if (isInitialLoad && rootVnode.$attrs$) {
2752
+ for (const key of Object.keys(rootVnode.$attrs$)) {
2753
+ if (hostElm.hasAttribute(key) && !["key", "ref", "style", "class"].includes(key)) {
2754
+ rootVnode.$attrs$[key] = hostElm[key];
2272
2755
  }
2273
- return emitEvent(elm, name, {
2274
- bubbles: !!(flags & 4 /* Bubbles */),
2275
- composed: !!(flags & 2 /* Composed */),
2276
- cancelable: !!(flags & 1 /* Cancellable */),
2277
- detail
2278
- });
2279
- }
2280
- };
2281
- };
2282
- var emitEvent = (elm, name, opts) => {
2283
- const ev = plt.ce(name, opts);
2284
- elm.dispatchEvent(ev);
2285
- return ev;
2286
- };
2287
-
2288
- // src/runtime/styles.ts
2289
- var import_app_data12 = require("@rindo/core/internal/app-data");
2290
- var rootAppliedStyles = /* @__PURE__ */ new WeakMap();
2291
- var registerStyle = (scopeId2, cssText, allowCS) => {
2292
- let style = styles.get(scopeId2);
2293
- if (supportsConstructableStylesheets && allowCS) {
2294
- style = style || new CSSStyleSheet();
2295
- if (typeof style === "string") {
2296
- style = cssText;
2297
- } else {
2298
- style.replaceSync(cssText);
2299
2756
  }
2300
- } else {
2301
- style = cssText;
2302
2757
  }
2303
- styles.set(scopeId2, style);
2304
- };
2305
- var addStyle = (styleContainerNode, cmpMeta, mode) => {
2306
- var _a;
2307
- const scopeId2 = getScopeId(cmpMeta, mode);
2308
- const style = styles.get(scopeId2);
2309
- if (!import_app_data12.BUILD.attachStyles) {
2310
- return scopeId2;
2758
+ rootVnode.$tag$ = null;
2759
+ rootVnode.$flags$ |= 4 /* isHost */;
2760
+ hostRef.$vnode$ = rootVnode;
2761
+ rootVnode.$elm$ = oldVNode.$elm$ = import_app_data12.BUILD.shadowDom ? hostElm.shadowRoot || hostElm : hostElm;
2762
+ if (import_app_data12.BUILD.scoped || import_app_data12.BUILD.shadowDom) {
2763
+ scopeId = hostElm["s-sc"];
2311
2764
  }
2312
- styleContainerNode = styleContainerNode.nodeType === 11 /* DocumentFragment */ ? styleContainerNode : doc;
2313
- if (style) {
2314
- if (typeof style === "string") {
2315
- styleContainerNode = styleContainerNode.head || styleContainerNode;
2316
- let appliedStyles = rootAppliedStyles.get(styleContainerNode);
2317
- let styleElm;
2318
- if (!appliedStyles) {
2319
- rootAppliedStyles.set(styleContainerNode, appliedStyles = /* @__PURE__ */ new Set());
2765
+ useNativeShadowDom = supportsShadow && !!(cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) && !(cmpMeta.$flags$ & 128 /* shadowNeedsScopedCss */);
2766
+ if (import_app_data12.BUILD.slotRelocation) {
2767
+ contentRef = hostElm["s-cr"];
2768
+ checkSlotFallbackVisibility = false;
2769
+ }
2770
+ patch(oldVNode, rootVnode, isInitialLoad);
2771
+ if (import_app_data12.BUILD.slotRelocation) {
2772
+ plt.$flags$ |= 1 /* isTmpDisconnected */;
2773
+ if (checkSlotRelocate) {
2774
+ markSlotContentForRelocation(rootVnode.$elm$);
2775
+ for (const relocateData of relocateNodes) {
2776
+ const nodeToRelocate = relocateData.$nodeToRelocate$;
2777
+ if (!nodeToRelocate["s-ol"]) {
2778
+ const orgLocationNode = import_app_data12.BUILD.isDebug || import_app_data12.BUILD.hydrateServerSide ? originalLocationDebugNode(nodeToRelocate) : doc.createTextNode("");
2779
+ orgLocationNode["s-nr"] = nodeToRelocate;
2780
+ insertBefore(nodeToRelocate.parentNode, nodeToRelocate["s-ol"] = orgLocationNode, nodeToRelocate);
2781
+ }
2320
2782
  }
2321
- if (!appliedStyles.has(scopeId2)) {
2322
- if (import_app_data12.BUILD.hydrateClientSide && styleContainerNode.host && (styleElm = styleContainerNode.querySelector(`[${HYDRATED_STYLE_ID}="${scopeId2}"]`))) {
2323
- styleElm.innerHTML = style;
2324
- } else {
2325
- styleElm = document.querySelector(`[${HYDRATED_STYLE_ID}="${scopeId2}"]`) || doc.createElement("style");
2326
- styleElm.innerHTML = style;
2327
- const nonce = (_a = plt.$nonce$) != null ? _a : queryNonceMetaTagContent(doc);
2328
- if (nonce != null) {
2329
- styleElm.setAttribute("nonce", nonce);
2330
- }
2331
- if ((import_app_data12.BUILD.hydrateServerSide || import_app_data12.BUILD.hotModuleReplacement) && cmpMeta.$flags$ & 2 /* scopedCssEncapsulation */) {
2332
- styleElm.setAttribute(HYDRATED_STYLE_ID, scopeId2);
2333
- }
2334
- if (!(cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */)) {
2335
- if (styleContainerNode.nodeName === "HEAD") {
2336
- const preconnectLinks = styleContainerNode.querySelectorAll("link[rel=preconnect]");
2337
- const referenceNode2 = preconnectLinks.length > 0 ? preconnectLinks[preconnectLinks.length - 1].nextSibling : styleContainerNode.querySelector("style");
2338
- styleContainerNode.insertBefore(styleElm, referenceNode2);
2339
- } else if ("host" in styleContainerNode) {
2340
- if (supportsConstructableStylesheets) {
2341
- const stylesheet = new CSSStyleSheet();
2342
- stylesheet.replaceSync(style);
2343
- styleContainerNode.adoptedStyleSheets = [stylesheet, ...styleContainerNode.adoptedStyleSheets];
2344
- } else {
2345
- const existingStyleContainer = styleContainerNode.querySelector("style");
2346
- if (existingStyleContainer) {
2347
- existingStyleContainer.innerHTML = style + existingStyleContainer.innerHTML;
2348
- } else {
2349
- styleContainerNode.prepend(styleElm);
2783
+ for (const relocateData of relocateNodes) {
2784
+ const nodeToRelocate = relocateData.$nodeToRelocate$;
2785
+ const slotRefNode = relocateData.$slotRefNode$;
2786
+ if (slotRefNode) {
2787
+ const parentNodeRef = slotRefNode.parentNode;
2788
+ let insertBeforeNode = slotRefNode.nextSibling;
2789
+ if (!import_app_data12.BUILD.hydrateServerSide && (!import_app_data12.BUILD.experimentalSlotFixes || insertBeforeNode && insertBeforeNode.nodeType === 1 /* ElementNode */)) {
2790
+ let orgLocationNode = (_a = nodeToRelocate["s-ol"]) == null ? void 0 : _a.previousSibling;
2791
+ while (orgLocationNode) {
2792
+ let refNode = (_b = orgLocationNode["s-nr"]) != null ? _b : null;
2793
+ if (refNode && refNode["s-sn"] === nodeToRelocate["s-sn"] && parentNodeRef === (refNode.__parentNode || refNode.parentNode)) {
2794
+ refNode = refNode.nextSibling;
2795
+ while (refNode === nodeToRelocate || (refNode == null ? void 0 : refNode["s-sr"])) {
2796
+ refNode = refNode == null ? void 0 : refNode.nextSibling;
2797
+ }
2798
+ if (!refNode || !refNode["s-nr"]) {
2799
+ insertBeforeNode = refNode;
2800
+ break;
2350
2801
  }
2351
2802
  }
2352
- } else {
2353
- styleContainerNode.append(styleElm);
2803
+ orgLocationNode = orgLocationNode.previousSibling;
2354
2804
  }
2355
2805
  }
2356
- if (cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */ && styleContainerNode.nodeName !== "HEAD") {
2357
- styleContainerNode.insertBefore(styleElm, null);
2806
+ const parent = nodeToRelocate.__parentNode || nodeToRelocate.parentNode;
2807
+ const nextSibling = nodeToRelocate.__nextSibling || nodeToRelocate.nextSibling;
2808
+ if (!insertBeforeNode && parentNodeRef !== parent || nextSibling !== insertBeforeNode) {
2809
+ if (nodeToRelocate !== insertBeforeNode) {
2810
+ if (!import_app_data12.BUILD.experimentalSlotFixes && !nodeToRelocate["s-hn"] && nodeToRelocate["s-ol"]) {
2811
+ nodeToRelocate["s-hn"] = nodeToRelocate["s-ol"].parentNode.nodeName;
2812
+ }
2813
+ insertBefore(parentNodeRef, nodeToRelocate, insertBeforeNode);
2814
+ if (nodeToRelocate.nodeType === 1 /* ElementNode */ && nodeToRelocate.tagName !== "SLOT-FB") {
2815
+ nodeToRelocate.hidden = (_c = nodeToRelocate["s-ih"]) != null ? _c : false;
2816
+ }
2817
+ }
2818
+ }
2819
+ nodeToRelocate && typeof slotRefNode["s-rf"] === "function" && slotRefNode["s-rf"](nodeToRelocate);
2820
+ } else {
2821
+ if (nodeToRelocate.nodeType === 1 /* ElementNode */) {
2822
+ if (isInitialLoad) {
2823
+ nodeToRelocate["s-ih"] = (_d = nodeToRelocate.hidden) != null ? _d : false;
2824
+ }
2825
+ nodeToRelocate.hidden = true;
2358
2826
  }
2359
- }
2360
- if (cmpMeta.$flags$ & 4 /* hasSlotRelocation */) {
2361
- styleElm.innerHTML += SLOT_FB_CSS;
2362
- }
2363
- if (appliedStyles) {
2364
- appliedStyles.add(scopeId2);
2365
2827
  }
2366
2828
  }
2367
- } else if (import_app_data12.BUILD.constructableCSS && !styleContainerNode.adoptedStyleSheets.includes(style)) {
2368
- styleContainerNode.adoptedStyleSheets = [...styleContainerNode.adoptedStyleSheets, style];
2369
2829
  }
2830
+ if (checkSlotFallbackVisibility) {
2831
+ updateFallbackSlotVisibility(rootVnode.$elm$);
2832
+ }
2833
+ plt.$flags$ &= ~1 /* isTmpDisconnected */;
2834
+ relocateNodes.length = 0;
2370
2835
  }
2371
- return scopeId2;
2372
- };
2373
- var attachStyles = (hostRef) => {
2374
- const cmpMeta = hostRef.$cmpMeta$;
2375
- const elm = hostRef.$hostElement$;
2376
- const flags = cmpMeta.$flags$;
2377
- const endAttachStyles = createTime("attachStyles", cmpMeta.$tagName$);
2378
- const scopeId2 = addStyle(
2379
- import_app_data12.BUILD.shadowDom && supportsShadow && elm.shadowRoot ? elm.shadowRoot : elm.getRootNode(),
2380
- cmpMeta,
2381
- hostRef.$modeName$
2382
- );
2383
- if ((import_app_data12.BUILD.shadowDom || import_app_data12.BUILD.scoped) && import_app_data12.BUILD.cssAnnotations && flags & 10 /* needsScopedEncapsulation */ && flags & 2 /* scopedCssEncapsulation */) {
2384
- elm["s-sc"] = scopeId2;
2385
- elm.classList.add(scopeId2 + "-h");
2836
+ if (import_app_data12.BUILD.experimentalScopedSlotChanges && cmpMeta.$flags$ & 2 /* scopedCssEncapsulation */) {
2837
+ const children = rootVnode.$elm$.__childNodes || rootVnode.$elm$.childNodes;
2838
+ for (const childNode of children) {
2839
+ if (childNode["s-hn"] !== hostTagName && !childNode["s-sh"]) {
2840
+ if (isInitialLoad && childNode["s-ih"] == null) {
2841
+ childNode["s-ih"] = (_e = childNode.hidden) != null ? _e : false;
2842
+ }
2843
+ childNode.hidden = true;
2844
+ }
2845
+ }
2386
2846
  }
2387
- endAttachStyles();
2847
+ contentRef = void 0;
2388
2848
  };
2389
- var getScopeId = (cmp, mode) => "sc-" + (import_app_data12.BUILD.mode && mode && cmp.$flags$ & 32 /* hasMode */ ? cmp.$tagName$ + "-" + mode : cmp.$tagName$);
2849
+ var slotReferenceDebugNode = (slotVNode) => doc.createComment(
2850
+ `<slot${slotVNode.$name$ ? ' name="' + slotVNode.$name$ + '"' : ""}> (host=${hostTagName.toLowerCase()})`
2851
+ );
2852
+ var originalLocationDebugNode = (nodeToRelocate) => doc.createComment(
2853
+ `org-location for ` + (nodeToRelocate.localName ? `<${nodeToRelocate.localName}> (host=${nodeToRelocate["s-hn"]})` : `[${nodeToRelocate.textContent}]`)
2854
+ );
2390
2855
 
2391
2856
  // src/runtime/update-component.ts
2392
2857
  var attachToAncestor = (hostRef, ancestorComponent) => {
2393
2858
  if (import_app_data13.BUILD.asyncLoading && ancestorComponent && !hostRef.$onRenderResolve$ && ancestorComponent["s-p"]) {
2394
- ancestorComponent["s-p"].push(new Promise((r) => hostRef.$onRenderResolve$ = r));
2859
+ const index = ancestorComponent["s-p"].push(
2860
+ new Promise(
2861
+ (r) => hostRef.$onRenderResolve$ = () => {
2862
+ ancestorComponent["s-p"].splice(index - 1, 1);
2863
+ r();
2864
+ }
2865
+ )
2866
+ );
2395
2867
  }
2396
2868
  };
2397
2869
  var scheduleUpdate = (hostRef, isInitialLoad) => {
@@ -2420,23 +2892,23 @@ var dispatchHooks = (hostRef, isInitialLoad) => {
2420
2892
  if (import_app_data13.BUILD.lazyLoad && import_app_data13.BUILD.hostListener) {
2421
2893
  hostRef.$flags$ |= 256 /* isListenReady */;
2422
2894
  if (hostRef.$queuedListeners$) {
2423
- hostRef.$queuedListeners$.map(([methodName, event]) => safeCall(instance, methodName, event));
2895
+ hostRef.$queuedListeners$.map(([methodName, event]) => safeCall(instance, methodName, event, elm));
2424
2896
  hostRef.$queuedListeners$ = void 0;
2425
2897
  }
2426
2898
  }
2427
2899
  emitLifecycleEvent(elm, "componentWillLoad");
2428
2900
  if (import_app_data13.BUILD.cmpWillLoad) {
2429
- maybePromise = safeCall(instance, "componentWillLoad");
2901
+ maybePromise = safeCall(instance, "componentWillLoad", void 0, elm);
2430
2902
  }
2431
2903
  } else {
2432
2904
  emitLifecycleEvent(elm, "componentWillUpdate");
2433
2905
  if (import_app_data13.BUILD.cmpWillUpdate) {
2434
- maybePromise = safeCall(instance, "componentWillUpdate");
2906
+ maybePromise = safeCall(instance, "componentWillUpdate", void 0, elm);
2435
2907
  }
2436
2908
  }
2437
2909
  emitLifecycleEvent(elm, "componentWillRender");
2438
2910
  if (import_app_data13.BUILD.cmpWillRender) {
2439
- maybePromise = enqueue(maybePromise, () => safeCall(instance, "componentWillRender"));
2911
+ maybePromise = enqueue(maybePromise, () => safeCall(instance, "componentWillRender", void 0, elm));
2440
2912
  }
2441
2913
  endSchedule();
2442
2914
  return enqueue(maybePromise, () => updateComponent(hostRef, instance, isInitialLoad));
@@ -2549,7 +3021,7 @@ var postUpdateComponent = (hostRef) => {
2549
3021
  if (import_app_data13.BUILD.isDev) {
2550
3022
  hostRef.$flags$ |= 1024 /* devOnRender */;
2551
3023
  }
2552
- safeCall(instance, "componentDidRender");
3024
+ safeCall(instance, "componentDidRender", void 0, elm);
2553
3025
  if (import_app_data13.BUILD.isDev) {
2554
3026
  hostRef.$flags$ &= ~1024 /* devOnRender */;
2555
3027
  }
@@ -2564,7 +3036,7 @@ var postUpdateComponent = (hostRef) => {
2564
3036
  if (import_app_data13.BUILD.isDev) {
2565
3037
  hostRef.$flags$ |= 2048 /* devOnDidLoad */;
2566
3038
  }
2567
- safeCall(instance, "componentDidLoad");
3039
+ safeCall(instance, "componentDidLoad", void 0, elm);
2568
3040
  if (import_app_data13.BUILD.isDev) {
2569
3041
  hostRef.$flags$ &= ~2048 /* devOnDidLoad */;
2570
3042
  }
@@ -2582,7 +3054,7 @@ var postUpdateComponent = (hostRef) => {
2582
3054
  if (import_app_data13.BUILD.isDev) {
2583
3055
  hostRef.$flags$ |= 1024 /* devOnRender */;
2584
3056
  }
2585
- safeCall(instance, "componentDidUpdate");
3057
+ safeCall(instance, "componentDidUpdate", void 0, elm);
2586
3058
  if (import_app_data13.BUILD.isDev) {
2587
3059
  hostRef.$flags$ &= ~1024 /* devOnRender */;
2588
3060
  }
@@ -2616,9 +3088,6 @@ var forceUpdate = (ref) => {
2616
3088
  return false;
2617
3089
  };
2618
3090
  var appDidLoad = (who) => {
2619
- if (import_app_data13.BUILD.cssAnnotations) {
2620
- addHydratedFlag(doc.documentElement);
2621
- }
2622
3091
  if (import_app_data13.BUILD.asyncQueue) {
2623
3092
  plt.$flags$ |= 2 /* appLoaded */;
2624
3093
  }
@@ -2627,12 +3096,12 @@ var appDidLoad = (who) => {
2627
3096
  performance.measure(`[Rindo] ${import_app_data13.NAMESPACE} initial load (by ${who})`, "st:app:start");
2628
3097
  }
2629
3098
  };
2630
- var safeCall = (instance, method, arg) => {
3099
+ var safeCall = (instance, method, arg, elm) => {
2631
3100
  if (instance && instance[method]) {
2632
3101
  try {
2633
3102
  return instance[method](arg);
2634
3103
  } catch (e) {
2635
- consoleError(e);
3104
+ consoleError(e, elm);
2636
3105
  }
2637
3106
  }
2638
3107
  return void 0;
@@ -2735,6 +3204,12 @@ var setValue = (ref, propName, newVal, cmpMeta) => {
2735
3204
  var proxyComponent = (Cstr, cmpMeta, flags) => {
2736
3205
  var _a, _b;
2737
3206
  const prototype = Cstr.prototype;
3207
+ if (import_app_data15.BUILD.isTesting) {
3208
+ if (prototype.__rindoAugmented) {
3209
+ return;
3210
+ }
3211
+ prototype.__rindoAugmented = true;
3212
+ }
2738
3213
  if (import_app_data15.BUILD.formAssociated && cmpMeta.$flags$ & 64 /* formAssociated */ && flags & 1 /* isElementConstructor */) {
2739
3214
  FORM_ASSOCIATED_CUSTOM_ELEMENT_CALLBACKS.forEach((cbName) => {
2740
3215
  const originalFormAssociatedCallback = prototype[cbName];
@@ -2762,77 +3237,91 @@ var proxyComponent = (Cstr, cmpMeta, flags) => {
2762
3237
  const members = Object.entries((_a = cmpMeta.$members$) != null ? _a : {});
2763
3238
  members.map(([memberName, [memberFlags]]) => {
2764
3239
  if ((import_app_data15.BUILD.prop || import_app_data15.BUILD.state) && (memberFlags & 31 /* Prop */ || (!import_app_data15.BUILD.lazyLoad || flags & 2 /* proxyState */) && memberFlags & 32 /* State */)) {
2765
- if ((memberFlags & 2048 /* Getter */) === 0) {
3240
+ const { get: origGetter, set: origSetter } = Object.getOwnPropertyDescriptor(prototype, memberName) || {};
3241
+ if (origGetter) cmpMeta.$members$[memberName][0] |= 2048 /* Getter */;
3242
+ if (origSetter) cmpMeta.$members$[memberName][0] |= 4096 /* Setter */;
3243
+ if (flags & 1 /* isElementConstructor */ || !origGetter) {
2766
3244
  Object.defineProperty(prototype, memberName, {
2767
3245
  get() {
2768
- return getValue(this, memberName);
2769
- },
2770
- set(newValue) {
2771
- if (import_app_data15.BUILD.isDev) {
2772
- const ref = getHostRef(this);
2773
- if (
2774
- // we are proxying the instance (not element)
2775
- (flags & 1 /* isElementConstructor */) === 0 && // the element is not constructing
2776
- (ref && ref.$flags$ & 8 /* isConstructingInstance */) === 0 && // the member is a prop
2777
- (memberFlags & 31 /* Prop */) !== 0 && // the member is not mutable
2778
- (memberFlags & 1024 /* Mutable */) === 0
2779
- ) {
2780
- consoleDevWarn(
2781
- `@Prop() "${memberName}" on <${cmpMeta.$tagName$}> is immutable but was modified from within the component.
2782
- More information: https://rindojs.web.app/docs/properties#prop-mutability`
2783
- );
3246
+ if (import_app_data15.BUILD.lazyLoad) {
3247
+ if ((cmpMeta.$members$[memberName][0] & 2048 /* Getter */) === 0) {
3248
+ return getValue(this, memberName);
2784
3249
  }
3250
+ const ref = getHostRef(this);
3251
+ const instance = ref ? ref.$lazyInstance$ : prototype;
3252
+ if (!instance) return;
3253
+ return instance[memberName];
3254
+ }
3255
+ if (!import_app_data15.BUILD.lazyLoad) {
3256
+ return origGetter ? origGetter.apply(this) : getValue(this, memberName);
2785
3257
  }
2786
- setValue(this, memberName, newValue, cmpMeta);
2787
3258
  },
2788
3259
  configurable: true,
2789
3260
  enumerable: true
2790
3261
  });
2791
- } else if (flags & 1 /* isElementConstructor */ && memberFlags & 2048 /* Getter */) {
2792
- if (import_app_data15.BUILD.lazyLoad) {
2793
- Object.defineProperty(prototype, memberName, {
2794
- get() {
2795
- const ref = getHostRef(this);
2796
- const instance = import_app_data15.BUILD.lazyLoad && ref ? ref.$lazyInstance$ : prototype;
2797
- if (!instance) return;
2798
- return instance[memberName];
2799
- },
2800
- configurable: true,
2801
- enumerable: true
2802
- });
2803
- }
2804
- if (memberFlags & 4096 /* Setter */) {
2805
- const origSetter = Object.getOwnPropertyDescriptor(prototype, memberName).set;
2806
- Object.defineProperty(prototype, memberName, {
2807
- set(newValue) {
2808
- const ref = getHostRef(this);
2809
- if (origSetter) {
2810
- const currentValue = ref.$hostElement$[memberName];
2811
- if (!ref.$instanceValues$.get(memberName) && currentValue) {
2812
- ref.$instanceValues$.set(memberName, currentValue);
2813
- }
2814
- origSetter.apply(this, [parsePropertyValue(newValue, cmpMeta.$members$[memberName][0])]);
2815
- setValue(this, memberName, ref.$hostElement$[memberName], cmpMeta);
2816
- return;
3262
+ }
3263
+ Object.defineProperty(prototype, memberName, {
3264
+ set(newValue) {
3265
+ const ref = getHostRef(this);
3266
+ if (import_app_data15.BUILD.isDev) {
3267
+ if (
3268
+ // we are proxying the instance (not element)
3269
+ (flags & 1 /* isElementConstructor */) === 0 && // if the class has a setter, then the Element can update instance values, so ignore
3270
+ (cmpMeta.$members$[memberName][0] & 4096 /* Setter */) === 0 && // the element is not constructing
3271
+ (ref && ref.$flags$ & 8 /* isConstructingInstance */) === 0 && // the member is a prop
3272
+ (memberFlags & 31 /* Prop */) !== 0 && // the member is not mutable
3273
+ (memberFlags & 1024 /* Mutable */) === 0
3274
+ ) {
3275
+ consoleDevWarn(
3276
+ `@Prop() "${memberName}" on <${cmpMeta.$tagName$}> is immutable but was modified from within the component.
3277
+ More information: https://rindojs.web.app/docs/properties#prop-mutability`
3278
+ );
3279
+ }
3280
+ }
3281
+ if (origSetter) {
3282
+ const currentValue = memberFlags & 32 /* State */ ? this[memberName] : ref.$hostElement$[memberName];
3283
+ if (typeof currentValue === "undefined" && ref.$instanceValues$.get(memberName)) {
3284
+ newValue = ref.$instanceValues$.get(memberName);
3285
+ } else if (!ref.$instanceValues$.get(memberName) && currentValue) {
3286
+ ref.$instanceValues$.set(memberName, currentValue);
3287
+ }
3288
+ origSetter.apply(this, [parsePropertyValue(newValue, memberFlags)]);
3289
+ newValue = memberFlags & 32 /* State */ ? this[memberName] : ref.$hostElement$[memberName];
3290
+ setValue(this, memberName, newValue, cmpMeta);
3291
+ return;
3292
+ }
3293
+ if (!import_app_data15.BUILD.lazyLoad) {
3294
+ setValue(this, memberName, newValue, cmpMeta);
3295
+ return;
3296
+ }
3297
+ if (import_app_data15.BUILD.lazyLoad) {
3298
+ if ((flags & 1 /* isElementConstructor */) === 0 || (cmpMeta.$members$[memberName][0] & 4096 /* Setter */) === 0) {
3299
+ setValue(this, memberName, newValue, cmpMeta);
3300
+ if (flags & 1 /* isElementConstructor */ && !ref.$lazyInstance$) {
3301
+ ref.$onReadyPromise$.then(() => {
3302
+ if (cmpMeta.$members$[memberName][0] & 4096 /* Setter */ && ref.$lazyInstance$[memberName] !== ref.$instanceValues$.get(memberName)) {
3303
+ ref.$lazyInstance$[memberName] = newValue;
3304
+ }
3305
+ });
2817
3306
  }
2818
- if (!ref) return;
2819
- const setterSetVal = () => {
2820
- const currentValue = ref.$lazyInstance$[memberName];
2821
- if (!ref.$instanceValues$.get(memberName) && currentValue) {
2822
- ref.$instanceValues$.set(memberName, currentValue);
2823
- }
2824
- ref.$lazyInstance$[memberName] = parsePropertyValue(newValue, cmpMeta.$members$[memberName][0]);
2825
- setValue(this, memberName, ref.$lazyInstance$[memberName], cmpMeta);
2826
- };
2827
- if (ref.$lazyInstance$) {
2828
- setterSetVal();
2829
- } else {
2830
- ref.$onReadyPromise$.then(() => setterSetVal());
3307
+ return;
3308
+ }
3309
+ const setterSetVal = () => {
3310
+ const currentValue = ref.$lazyInstance$[memberName];
3311
+ if (!ref.$instanceValues$.get(memberName) && currentValue) {
3312
+ ref.$instanceValues$.set(memberName, currentValue);
2831
3313
  }
3314
+ ref.$lazyInstance$[memberName] = parsePropertyValue(newValue, memberFlags);
3315
+ setValue(this, memberName, ref.$lazyInstance$[memberName], cmpMeta);
3316
+ };
3317
+ if (ref.$lazyInstance$) {
3318
+ setterSetVal();
3319
+ } else {
3320
+ ref.$onReadyPromise$.then(() => setterSetVal());
2832
3321
  }
2833
- });
3322
+ }
2834
3323
  }
2835
- }
3324
+ });
2836
3325
  } else if (import_app_data15.BUILD.lazyLoad && import_app_data15.BUILD.method && flags & 1 /* isElementConstructor */ && memberFlags & 64 /* Method */) {
2837
3326
  Object.defineProperty(prototype, memberName, {
2838
3327
  value(...args) {
@@ -2874,8 +3363,9 @@ More information: https://rindojs.web.app/docs/properties#prop-mutability`
2874
3363
  return;
2875
3364
  }
2876
3365
  const propDesc = Object.getOwnPropertyDescriptor(prototype, propName);
2877
- if (!propDesc.get || !!propDesc.set) {
2878
- this[propName] = newValue === null && typeof this[propName] === "boolean" ? false : newValue;
3366
+ newValue = newValue === null && typeof this[propName] === "boolean" ? false : newValue;
3367
+ if (newValue !== this[propName] && (!propDesc.get || !!propDesc.set)) {
3368
+ this[propName] = newValue;
2879
3369
  }
2880
3370
  });
2881
3371
  };
@@ -2904,7 +3394,7 @@ var initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId) => {
2904
3394
  if ((hostRef.$flags$ & 32 /* hasInitializedComponent */) === 0) {
2905
3395
  hostRef.$flags$ |= 32 /* hasInitializedComponent */;
2906
3396
  const bundleId = cmpMeta.$lazyBundleId$;
2907
- if ((import_app_data16.BUILD.lazyLoad || import_app_data16.BUILD.hydrateClientSide) && bundleId) {
3397
+ if (import_app_data16.BUILD.lazyLoad && bundleId) {
2908
3398
  const CstrImport = loadModule(cmpMeta, hostRef, hmrVersionId);
2909
3399
  if (CstrImport && "then" in CstrImport) {
2910
3400
  const endLoad = uniqueTime(
@@ -2933,7 +3423,7 @@ var initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId) => {
2933
3423
  try {
2934
3424
  new Cstr(hostRef);
2935
3425
  } catch (e) {
2936
- consoleError(e);
3426
+ consoleError(e, elm);
2937
3427
  }
2938
3428
  if (import_app_data16.BUILD.member) {
2939
3429
  hostRef.$flags$ &= ~8 /* isConstructingInstance */;
@@ -2942,7 +3432,7 @@ var initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId) => {
2942
3432
  hostRef.$flags$ |= 128 /* isWatchReady */;
2943
3433
  }
2944
3434
  endNewInstance();
2945
- fireConnectedCallback(hostRef.$lazyInstance$);
3435
+ fireConnectedCallback(hostRef.$lazyInstance$, elm);
2946
3436
  } else {
2947
3437
  Cstr = elm.constructor;
2948
3438
  const cmpTag = elm.localName;
@@ -2964,9 +3454,8 @@ var initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId) => {
2964
3454
  const scopeId2 = getScopeId(cmpMeta, hostRef.$modeName$);
2965
3455
  if (!styles.has(scopeId2)) {
2966
3456
  const endRegisterStyles = createTime("registerStyles", cmpMeta.$tagName$);
2967
- if (!import_app_data16.BUILD.hydrateServerSide && import_app_data16.BUILD.shadowDom && // TODO(RINDO-854): Remove code related to legacy shadowDomShim field
2968
- import_app_data16.BUILD.shadowDomShim && cmpMeta.$flags$ & 8 /* needsShadowDomShim */) {
2969
- style = await import("../client/shadow-css.js").then((m) => m.scopeCss(style, scopeId2));
3457
+ if (import_app_data16.BUILD.hydrateServerSide && import_app_data16.BUILD.shadowDom && cmpMeta.$flags$ & 128 /* shadowNeedsScopedCss */) {
3458
+ style = scopeCss(style, scopeId2, true);
2970
3459
  }
2971
3460
  registerStyle(scopeId2, style, !!(cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */));
2972
3461
  endRegisterStyles();
@@ -2981,9 +3470,9 @@ var initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId) => {
2981
3470
  schedule();
2982
3471
  }
2983
3472
  };
2984
- var fireConnectedCallback = (instance) => {
3473
+ var fireConnectedCallback = (instance, elm) => {
2985
3474
  if (import_app_data16.BUILD.lazyLoad && import_app_data16.BUILD.connectedCallback) {
2986
- safeCall(instance, "connectedCallback");
3475
+ safeCall(instance, "connectedCallback", void 0, elm);
2987
3476
  }
2988
3477
  };
2989
3478
 
@@ -3044,9 +3533,9 @@ var connectedCallback = (elm) => {
3044
3533
  } else {
3045
3534
  addHostEventListeners(elm, hostRef, cmpMeta.$listeners$, false);
3046
3535
  if (hostRef == null ? void 0 : hostRef.$lazyInstance$) {
3047
- fireConnectedCallback(hostRef.$lazyInstance$);
3536
+ fireConnectedCallback(hostRef.$lazyInstance$, elm);
3048
3537
  } else if (hostRef == null ? void 0 : hostRef.$onReadyPromise$) {
3049
- hostRef.$onReadyPromise$.then(() => fireConnectedCallback(hostRef.$lazyInstance$));
3538
+ hostRef.$onReadyPromise$.then(() => fireConnectedCallback(hostRef.$lazyInstance$, elm));
3050
3539
  }
3051
3540
  }
3052
3541
  endConnected();
@@ -3062,12 +3551,12 @@ var setContentReference = (elm) => {
3062
3551
 
3063
3552
  // src/runtime/disconnected-callback.ts
3064
3553
  var import_app_data18 = require("@rindo/core/internal/app-data");
3065
- var disconnectInstance = (instance) => {
3554
+ var disconnectInstance = (instance, elm) => {
3066
3555
  if (import_app_data18.BUILD.lazyLoad && import_app_data18.BUILD.disconnectedCallback) {
3067
- safeCall(instance, "disconnectedCallback");
3556
+ safeCall(instance, "disconnectedCallback", void 0, elm || instance);
3068
3557
  }
3069
3558
  if (import_app_data18.BUILD.cmpDidUnload) {
3070
- safeCall(instance, "componentDidUnload");
3559
+ safeCall(instance, "componentDidUnload", void 0, elm || instance);
3071
3560
  }
3072
3561
  };
3073
3562
  var disconnectedCallback = async (elm) => {
@@ -3082,9 +3571,9 @@ var disconnectedCallback = async (elm) => {
3082
3571
  if (!import_app_data18.BUILD.lazyLoad) {
3083
3572
  disconnectInstance(elm);
3084
3573
  } else if (hostRef == null ? void 0 : hostRef.$lazyInstance$) {
3085
- disconnectInstance(hostRef.$lazyInstance$);
3574
+ disconnectInstance(hostRef.$lazyInstance$, elm);
3086
3575
  } else if (hostRef == null ? void 0 : hostRef.$onReadyPromise$) {
3087
- hostRef.$onReadyPromise$.then(() => disconnectInstance(hostRef.$lazyInstance$));
3576
+ hostRef.$onReadyPromise$.then(() => disconnectInstance(hostRef.$lazyInstance$, elm));
3088
3577
  }
3089
3578
  }
3090
3579
  if (rootAppliedStyles.has(elm)) {
@@ -3137,6 +3626,9 @@ var proxyCustomElement = (Cstr, compactMeta) => {
3137
3626
  patchTextContent(Cstr.prototype);
3138
3627
  }
3139
3628
  }
3629
+ if (import_app_data19.BUILD.hydrateClientSide && import_app_data19.BUILD.shadowDom) {
3630
+ hydrateScopedToShadow();
3631
+ }
3140
3632
  const originalConnectedCallback = Cstr.prototype.connectedCallback;
3141
3633
  const originalDisconnectedCallback = Cstr.prototype.disconnectedCallback;
3142
3634
  Object.assign(Cstr.prototype, {
@@ -3257,6 +3749,9 @@ var bootstrapLazy = (lazyBundles, options = {}) => {
3257
3749
  if (import_app_data20.BUILD.hydrateClientSide) {
3258
3750
  plt.$flags$ |= 2 /* appLoaded */;
3259
3751
  }
3752
+ if (import_app_data20.BUILD.hydrateClientSide && import_app_data20.BUILD.shadowDom) {
3753
+ hydrateScopedToShadow();
3754
+ }
3260
3755
  let hasSlotRelocation = false;
3261
3756
  lazyBundles.map((lazyBundle) => {
3262
3757
  lazyBundle[1].map((compactMeta) => {
@@ -3337,6 +3832,10 @@ var bootstrapLazy = (lazyBundles, options = {}) => {
3337
3832
  plt.raf(() => {
3338
3833
  var _a3;
3339
3834
  const hostRef = getHostRef(this);
3835
+ const i2 = deferredConnectedCallbacks.findIndex((host) => host === this);
3836
+ if (i2 > -1) {
3837
+ deferredConnectedCallbacks.splice(i2, 1);
3838
+ }
3340
3839
  if (((_a3 = hostRef == null ? void 0 : hostRef.$vnode$) == null ? void 0 : _a3.$elm$) instanceof Node && !hostRef.$vnode$.$elm$.isConnected) {
3341
3840
  delete hostRef.$vnode$.$elm$;
3342
3841
  }
@@ -3447,7 +3946,7 @@ var hostListenerProxy = (hostRef, methodName) => (ev) => {
3447
3946
  hostRef.$hostElement$[methodName](ev);
3448
3947
  }
3449
3948
  } catch (e) {
3450
- consoleError(e);
3949
+ consoleError(e, hostRef.$hostElement$);
3451
3950
  }
3452
3951
  };
3453
3952
  var getHostListenerTarget = (elm, flags) => {