@rindo/core 4.23.2 → 4.25.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  /*
2
- Rindo Client Platform v4.23.2 | MIT Licensed | https://rindojs.web.app
2
+ Rindo Client Platform v4.25.3 | MIT Licensed | https://rindojs.web.app
3
3
  */
4
4
  var __defProp = Object.defineProperty;
5
5
  var __export = (target, all) => {
@@ -17,19 +17,46 @@ var Build = {
17
17
  };
18
18
 
19
19
  // src/client/client-host-ref.ts
20
+ import { BUILD as BUILD3 } from "@rindo/core/internal/app-data";
21
+
22
+ // src/utils/es2022-rewire-class-members.ts
20
23
  import { BUILD as BUILD2 } from "@rindo/core/internal/app-data";
21
24
 
22
25
  // src/utils/constants.ts
23
26
  var SVG_NS = "http://www.w3.org/2000/svg";
24
27
  var HTML_NS = "http://www.w3.org/1999/xhtml";
25
28
 
29
+ // src/utils/es2022-rewire-class-members.ts
30
+ var reWireGetterSetter = (instance, hostRef) => {
31
+ var _a;
32
+ const cmpMeta = hostRef.$cmpMeta$;
33
+ const members = Object.entries((_a = cmpMeta.$members$) != null ? _a : {});
34
+ members.map(([memberName, [memberFlags]]) => {
35
+ if ((BUILD2.state || BUILD2.prop) && (memberFlags & 31 /* Prop */ || memberFlags & 32 /* State */)) {
36
+ const ogValue = instance[memberName];
37
+ const ogDescriptor = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(instance), memberName);
38
+ Object.defineProperty(instance, memberName, {
39
+ get() {
40
+ return ogDescriptor.get.call(this);
41
+ },
42
+ set(newValue) {
43
+ ogDescriptor.set.call(this, newValue);
44
+ },
45
+ configurable: true,
46
+ enumerable: true
47
+ });
48
+ instance[memberName] = hostRef.$instanceValues$.has(memberName) ? hostRef.$instanceValues$.get(memberName) : ogValue;
49
+ }
50
+ });
51
+ };
52
+
26
53
  // src/client/client-host-ref.ts
27
- var hostRefs = BUILD2.hotModuleReplacement ? window.__RINDO_HOSTREFS__ || (window.__RINDO_HOSTREFS__ = /* @__PURE__ */ new WeakMap()) : /* @__PURE__ */ new WeakMap();
54
+ var hostRefs = BUILD3.hotModuleReplacement ? window.__RINDO_HOSTREFS__ || (window.__RINDO_HOSTREFS__ = /* @__PURE__ */ new WeakMap()) : /* @__PURE__ */ new WeakMap();
28
55
  var deleteHostRef = (ref) => hostRefs.delete(ref);
29
56
  var getHostRef = (ref) => hostRefs.get(ref);
30
57
  var registerInstance = (lazyInstance, hostRef) => {
31
58
  hostRefs.set(hostRef.$lazyInstance$ = lazyInstance, hostRef);
32
- if (BUILD2.modernPropertyDecls && (BUILD2.state || BUILD2.prop)) {
59
+ if (BUILD3.modernPropertyDecls && (BUILD3.state || BUILD3.prop)) {
33
60
  reWireGetterSetter(lazyInstance, hostRef);
34
61
  }
35
62
  };
@@ -40,55 +67,33 @@ var registerHost = (hostElement, cmpMeta) => {
40
67
  $cmpMeta$: cmpMeta,
41
68
  $instanceValues$: /* @__PURE__ */ new Map()
42
69
  };
43
- if (BUILD2.isDev) {
70
+ if (BUILD3.isDev) {
44
71
  hostRef.$renderCount$ = 0;
45
72
  }
46
- if (BUILD2.method && BUILD2.lazyLoad) {
73
+ if (BUILD3.method && BUILD3.lazyLoad) {
47
74
  hostRef.$onInstancePromise$ = new Promise((r) => hostRef.$onInstanceResolve$ = r);
48
75
  }
49
- if (BUILD2.asyncLoading) {
76
+ if (BUILD3.asyncLoading) {
50
77
  hostRef.$onReadyPromise$ = new Promise((r) => hostRef.$onReadyResolve$ = r);
51
78
  hostElement["s-p"] = [];
52
79
  hostElement["s-rc"] = [];
53
80
  }
54
81
  const ref = hostRefs.set(hostElement, hostRef);
55
- if (!BUILD2.lazyLoad && BUILD2.modernPropertyDecls && (BUILD2.state || BUILD2.prop)) {
82
+ if (!BUILD3.lazyLoad && BUILD3.modernPropertyDecls && (BUILD3.state || BUILD3.prop)) {
56
83
  reWireGetterSetter(hostElement, hostRef);
57
84
  }
58
85
  return ref;
59
86
  };
60
87
  var isMemberInElement = (elm, memberName) => memberName in elm;
61
- var reWireGetterSetter = (instance, hostRef) => {
62
- var _a;
63
- const cmpMeta = hostRef.$cmpMeta$;
64
- const members = Object.entries((_a = cmpMeta.$members$) != null ? _a : {});
65
- members.map(([memberName, [memberFlags]]) => {
66
- if (BUILD2.state && BUILD2.prop && (memberFlags & 2048 /* Getter */) === 0 && (memberFlags & 31 /* Prop */ || memberFlags & 32 /* State */)) {
67
- const ogValue = instance[memberName];
68
- const lazyDescriptor = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(instance), memberName);
69
- Object.defineProperty(instance, memberName, {
70
- get() {
71
- return lazyDescriptor.get.call(this);
72
- },
73
- set(newValue) {
74
- lazyDescriptor.set.call(this, newValue);
75
- },
76
- configurable: true,
77
- enumerable: true
78
- });
79
- instance[memberName] = hostRef.$instanceValues$.has(memberName) ? hostRef.$instanceValues$.get(memberName) : ogValue;
80
- }
81
- });
82
- };
83
88
 
84
89
  // src/client/client-load-module.ts
85
- import { BUILD as BUILD4 } from "@rindo/core/internal/app-data";
90
+ import { BUILD as BUILD5 } from "@rindo/core/internal/app-data";
86
91
 
87
92
  // src/client/client-log.ts
88
- import { BUILD as BUILD3 } from "@rindo/core/internal/app-data";
93
+ import { BUILD as BUILD4 } from "@rindo/core/internal/app-data";
89
94
  var customError;
90
95
  var consoleError = (e, el) => (customError || console.error)(e, el);
91
- var RINDO_DEV_MODE = BUILD3.isTesting ? ["RINDO:"] : [
96
+ var RINDO_DEV_MODE = BUILD4.isTesting ? ["RINDO:"] : [
92
97
  "%crindo",
93
98
  "color: white;background:#4c47ff;font-weight: bold; font-size:10px; padding:2px 6px; border-radius: 5px"
94
99
  ];
@@ -103,7 +108,7 @@ var MODULE_IMPORT_PREFIX = "./";
103
108
  var loadModule = (cmpMeta, hostRef, hmrVersionId) => {
104
109
  const exportName = cmpMeta.$tagName$.replace(/-/g, "_");
105
110
  const bundleId = cmpMeta.$lazyBundleId$;
106
- if (BUILD4.isDev && typeof bundleId !== "string") {
111
+ if (BUILD5.isDev && typeof bundleId !== "string") {
107
112
  consoleDevError(
108
113
  `Trying to lazily load component <${cmpMeta.$tagName$}> with style mode "${hostRef.$modeName$}", but it does not exist.`
109
114
  );
@@ -111,24 +116,28 @@ var loadModule = (cmpMeta, hostRef, hmrVersionId) => {
111
116
  } else if (!bundleId) {
112
117
  return void 0;
113
118
  }
114
- const module = !BUILD4.hotModuleReplacement ? cmpModules.get(bundleId) : false;
119
+ const module = !BUILD5.hotModuleReplacement ? cmpModules.get(bundleId) : false;
115
120
  if (module) {
116
121
  return module[exportName];
117
122
  }
118
123
  /*!__RINDO_STATIC_IMPORT_SWITCH__*/
119
124
  return import(
120
- /* @wite-ignore */
121
125
  /* @lahm-ignore */
122
126
  /* webpackInclude: /\.entry\.js$/ */
123
127
  /* webpackExclude: /\.system\.entry\.js$/ */
124
128
  /* webpackMode: "lazy" */
125
- `./${bundleId}.entry.js${BUILD4.hotModuleReplacement && hmrVersionId ? "?s-hmr=" + hmrVersionId : ""}`
126
- ).then((importedModule) => {
127
- if (!BUILD4.hotModuleReplacement) {
128
- cmpModules.set(bundleId, importedModule);
129
+ `./${bundleId}.entry.js${BUILD5.hotModuleReplacement && hmrVersionId ? "?s-hmr=" + hmrVersionId : ""}`
130
+ ).then(
131
+ (importedModule) => {
132
+ if (!BUILD5.hotModuleReplacement) {
133
+ cmpModules.set(bundleId, importedModule);
134
+ }
135
+ return importedModule[exportName];
136
+ },
137
+ (e) => {
138
+ consoleError(e, hostRef.$hostElement$);
129
139
  }
130
- return importedModule[exportName];
131
- }, consoleError);
140
+ );
132
141
  };
133
142
 
134
143
  // src/client/client-style.ts
@@ -136,7 +145,7 @@ var styles = /* @__PURE__ */ new Map();
136
145
  var modeResolutionChain = [];
137
146
 
138
147
  // src/client/client-task-queue.ts
139
- import { BUILD as BUILD6 } from "@rindo/core/internal/app-data";
148
+ import { BUILD as BUILD7 } from "@rindo/core/internal/app-data";
140
149
 
141
150
  // src/runtime/runtime-constants.ts
142
151
  var CONTENT_REF_ID = "r";
@@ -164,7 +173,7 @@ var FORM_ASSOCIATED_CUSTOM_ELEMENT_CALLBACKS = [
164
173
  ];
165
174
 
166
175
  // src/client/client-window.ts
167
- import { BUILD as BUILD5 } from "@rindo/core/internal/app-data";
176
+ import { BUILD as BUILD6 } from "@rindo/core/internal/app-data";
168
177
  var win = typeof window !== "undefined" ? window : {};
169
178
  var doc = win.document || { head: {} };
170
179
  var H = win.HTMLElement || class {
@@ -181,7 +190,7 @@ var plt = {
181
190
  var setPlatformHelpers = (helpers) => {
182
191
  Object.assign(plt, helpers);
183
192
  };
184
- var supportsShadow = BUILD5.shadowDom;
193
+ var supportsShadow = BUILD6.shadowDom;
185
194
  var supportsListenerOptions = /* @__PURE__ */ (() => {
186
195
  let supportsListenerOptions2 = false;
187
196
  try {
@@ -199,7 +208,7 @@ var supportsListenerOptions = /* @__PURE__ */ (() => {
199
208
  return supportsListenerOptions2;
200
209
  })();
201
210
  var promiseResolve = (v) => Promise.resolve(v);
202
- var supportsConstructableStylesheets = BUILD5.constructableCSS ? /* @__PURE__ */ (() => {
211
+ var supportsConstructableStylesheets = BUILD6.constructableCSS ? /* @__PURE__ */ (() => {
203
212
  try {
204
213
  new CSSStyleSheet();
205
214
  return typeof new CSSStyleSheet().replaceSync === "function";
@@ -252,11 +261,11 @@ var consumeTimeout = (queue, timeout) => {
252
261
  }
253
262
  };
254
263
  var flush = () => {
255
- if (BUILD6.asyncQueue) {
264
+ if (BUILD7.asyncQueue) {
256
265
  queueCongestion++;
257
266
  }
258
267
  consume(queueDomReads);
259
- if (BUILD6.asyncQueue) {
268
+ if (BUILD7.asyncQueue) {
260
269
  const timeout = (plt.$flags$ & 6 /* queueMask */) === 2 /* appLoaded */ ? performance.now() + 14 * Math.ceil(queueCongestion * (1 / 10)) : Infinity;
261
270
  consumeTimeout(queueDomWrites, timeout);
262
271
  consumeTimeout(queueDomWritesLow, timeout);
@@ -281,7 +290,7 @@ var readTask = /* @__PURE__ */ queueTask(queueDomReads, false);
281
290
  var writeTask = /* @__PURE__ */ queueTask(queueDomWrites, true);
282
291
 
283
292
  // src/client/index.ts
284
- import { BUILD as BUILD28, Env, NAMESPACE as NAMESPACE2 } from "@rindo/core/internal/app-data";
293
+ import { BUILD as BUILD29, Env, NAMESPACE as NAMESPACE2 } from "@rindo/core/internal/app-data";
285
294
 
286
295
  // src/runtime/asset-path.ts
287
296
  var getAssetPath = (path) => {
@@ -291,7 +300,7 @@ var getAssetPath = (path) => {
291
300
  var setAssetPath = (path) => plt.$resourcesUrl$ = path;
292
301
 
293
302
  // src/runtime/bootstrap-custom-element.ts
294
- import { BUILD as BUILD25 } from "@rindo/core/internal/app-data";
303
+ import { BUILD as BUILD26 } from "@rindo/core/internal/app-data";
295
304
 
296
305
  // src/utils/helpers.ts
297
306
  var isDef = (v) => v != null && v !== void 0;
@@ -356,16 +365,16 @@ var unwrapErr = (result) => {
356
365
  };
357
366
 
358
367
  // src/runtime/connected-callback.ts
359
- import { BUILD as BUILD23 } from "@rindo/core/internal/app-data";
368
+ import { BUILD as BUILD24 } from "@rindo/core/internal/app-data";
360
369
 
361
370
  // src/runtime/client-hydrate.ts
362
- import { BUILD as BUILD14 } from "@rindo/core/internal/app-data";
371
+ import { BUILD as BUILD12 } from "@rindo/core/internal/app-data";
363
372
 
364
373
  // src/runtime/dom-extras.ts
365
- import { BUILD as BUILD12 } from "@rindo/core/internal/app-data";
374
+ import { BUILD as BUILD9 } from "@rindo/core/internal/app-data";
366
375
 
367
376
  // src/runtime/slot-polyfill-utils.ts
368
- import { BUILD as BUILD7 } from "@rindo/core/internal/app-data";
377
+ import { BUILD as BUILD8 } from "@rindo/core/internal/app-data";
369
378
  var updateFallbackSlotVisibility = (elm) => {
370
379
  const childNodes = elm.__childNodes || elm.childNodes;
371
380
  if (elm.tagName && elm.tagName.includes("-") && elm["s-cr"] && elm.tagName !== "SLOT-FB") {
@@ -389,27 +398,27 @@ var updateFallbackSlotVisibility = (elm) => {
389
398
  var getSlottedChildNodes = (childNodes) => {
390
399
  const result = [];
391
400
  for (let i2 = 0; i2 < childNodes.length; i2++) {
392
- const slottedNode = childNodes[i2]["s-nr"];
401
+ const slottedNode = childNodes[i2]["s-nr"] || void 0;
393
402
  if (slottedNode && slottedNode.isConnected) {
394
403
  result.push(slottedNode);
395
404
  }
396
405
  }
397
406
  return result;
398
407
  };
399
- var getHostSlotNodes = (childNodes, hostName, slotName) => {
408
+ function getHostSlotNodes(childNodes, hostName, slotName) {
400
409
  let i2 = 0;
401
410
  let slottedNodes = [];
402
411
  let childNode;
403
412
  for (; i2 < childNodes.length; i2++) {
404
413
  childNode = childNodes[i2];
405
- if (childNode["s-sr"] && childNode["s-hn"] === hostName && (!slotName || childNode["s-sn"] === slotName)) {
414
+ if (childNode["s-sr"] && childNode["s-hn"] === hostName && (slotName === void 0 || childNode["s-sn"] === slotName)) {
406
415
  slottedNodes.push(childNode);
407
416
  if (typeof slotName !== "undefined") return slottedNodes;
408
417
  }
409
418
  slottedNodes = [...slottedNodes, ...getHostSlotNodes(childNode.childNodes, hostName, slotName)];
410
419
  }
411
420
  return slottedNodes;
412
- };
421
+ }
413
422
  var getHostSlotChildNodes = (node, slotName, includeSlot = true) => {
414
423
  const childNodes = [];
415
424
  if (includeSlot && node["s-sr"] || !node["s-sr"]) childNodes.push(node);
@@ -445,7 +454,7 @@ var addSlotRelocateNode = (newChild, slotNode, prepend, position) => {
445
454
  const parent = slotNode["s-cr"].parentNode;
446
455
  const appendMethod = prepend ? parent.__prepend || parent.prepend : parent.__appendChild || parent.appendChild;
447
456
  if (typeof position !== "undefined") {
448
- if (BUILD7.hydrateClientSide) {
457
+ if (BUILD8.hydrateClientSide) {
449
458
  slottedNodeLocation["s-oo"] = position;
450
459
  const childNodes = parent.__childNodes || parent.childNodes;
451
460
  const slotRelocateNodes = [slottedNodeLocation];
@@ -467,1819 +476,1913 @@ var addSlotRelocateNode = (newChild, slotNode, prepend, position) => {
467
476
  };
468
477
  var getSlotName = (node) => node["s-sn"] || node.nodeType === 1 && node.getAttribute("slot") || "";
469
478
 
470
- // src/runtime/vdom/vdom-render.ts
471
- import { BUILD as BUILD11 } from "@rindo/core/internal/app-data";
472
-
473
- // src/runtime/vdom/h.ts
474
- import { BUILD as BUILD8 } from "@rindo/core/internal/app-data";
475
- var h = (nodeName, vnodeData, ...children) => {
476
- let child = null;
477
- let key = null;
478
- let slotName = null;
479
- let simple = false;
480
- let lastSimple = false;
481
- const vNodeChildren = [];
482
- const walk = (c) => {
483
- for (let i2 = 0; i2 < c.length; i2++) {
484
- child = c[i2];
485
- if (Array.isArray(child)) {
486
- walk(child);
487
- } else if (child != null && typeof child !== "boolean") {
488
- if (simple = typeof nodeName !== "function" && !isComplexType(child)) {
489
- child = String(child);
490
- } else if (BUILD8.isDev && typeof nodeName !== "function" && child.$flags$ === void 0) {
491
- consoleDevError(`vNode passed as children has unexpected type.
492
- Make sure it's using the correct h() function.
493
- Empty objects can also be the cause, look for JSX comments that became objects.`);
479
+ // src/runtime/dom-extras.ts
480
+ var patchPseudoShadowDom = (hostElementPrototype) => {
481
+ patchCloneNode(hostElementPrototype);
482
+ patchSlotAppendChild(hostElementPrototype);
483
+ patchSlotAppend(hostElementPrototype);
484
+ patchSlotPrepend(hostElementPrototype);
485
+ patchSlotInsertAdjacentElement(hostElementPrototype);
486
+ patchSlotInsertAdjacentHTML(hostElementPrototype);
487
+ patchSlotInsertAdjacentText(hostElementPrototype);
488
+ patchInsertBefore(hostElementPrototype);
489
+ patchTextContent(hostElementPrototype);
490
+ patchChildSlotNodes(hostElementPrototype);
491
+ patchSlotRemoveChild(hostElementPrototype);
492
+ };
493
+ var patchCloneNode = (HostElementPrototype) => {
494
+ const orgCloneNode = HostElementPrototype.cloneNode;
495
+ HostElementPrototype.cloneNode = function(deep) {
496
+ const srcNode = this;
497
+ const isShadowDom = BUILD9.shadowDom ? srcNode.shadowRoot && supportsShadow : false;
498
+ const clonedNode = orgCloneNode.call(srcNode, isShadowDom ? deep : false);
499
+ if (BUILD9.slot && !isShadowDom && deep) {
500
+ let i2 = 0;
501
+ let slotted, nonRindoNode;
502
+ const rindoPrivates = [
503
+ "s-id",
504
+ "s-cr",
505
+ "s-lr",
506
+ "s-rc",
507
+ "s-sc",
508
+ "s-p",
509
+ "s-cn",
510
+ "s-sr",
511
+ "s-sn",
512
+ "s-hn",
513
+ "s-ol",
514
+ "s-nr",
515
+ "s-si",
516
+ "s-rf",
517
+ "s-scs"
518
+ ];
519
+ const childNodes = this.__childNodes || this.childNodes;
520
+ for (; i2 < childNodes.length; i2++) {
521
+ slotted = childNodes[i2]["s-nr"];
522
+ nonRindoNode = rindoPrivates.every((privateField) => !childNodes[i2][privateField]);
523
+ if (slotted) {
524
+ if (BUILD9.appendChildSlotFix && clonedNode.__appendChild) {
525
+ clonedNode.__appendChild(slotted.cloneNode(true));
526
+ } else {
527
+ clonedNode.appendChild(slotted.cloneNode(true));
528
+ }
494
529
  }
495
- if (simple && lastSimple) {
496
- vNodeChildren[vNodeChildren.length - 1].$text$ += child;
497
- } else {
498
- vNodeChildren.push(simple ? newVNode(null, child) : child);
530
+ if (nonRindoNode) {
531
+ clonedNode.appendChild(childNodes[i2].cloneNode(true));
499
532
  }
500
- lastSimple = simple;
501
533
  }
502
534
  }
535
+ return clonedNode;
503
536
  };
504
- walk(children);
505
- if (vnodeData) {
506
- if (BUILD8.isDev && nodeName === "input") {
507
- validateInputProperties(vnodeData);
508
- }
509
- if (BUILD8.vdomKey && vnodeData.key) {
510
- key = vnodeData.key;
511
- }
512
- if (BUILD8.slotRelocation && vnodeData.name) {
513
- slotName = vnodeData.name;
537
+ };
538
+ var patchSlotAppendChild = (HostElementPrototype) => {
539
+ HostElementPrototype.__appendChild = HostElementPrototype.appendChild;
540
+ HostElementPrototype.appendChild = function(newChild) {
541
+ const slotName = newChild["s-sn"] = getSlotName(newChild);
542
+ const slotNode = getHostSlotNodes(this.__childNodes || this.childNodes, this.tagName, slotName)[0];
543
+ if (slotNode) {
544
+ addSlotRelocateNode(newChild, slotNode);
545
+ const slotChildNodes = getHostSlotChildNodes(slotNode, slotName);
546
+ const appendAfter = slotChildNodes[slotChildNodes.length - 1];
547
+ const parent = intrnlCall(appendAfter, "parentNode");
548
+ let insertedNode;
549
+ if (parent.__insertBefore) {
550
+ insertedNode = parent.__insertBefore(newChild, appendAfter.nextSibling);
551
+ } else {
552
+ insertedNode = parent.insertBefore(newChild, appendAfter.nextSibling);
553
+ }
554
+ updateFallbackSlotVisibility(this);
555
+ return insertedNode;
514
556
  }
515
- if (BUILD8.vdomClass) {
516
- const classData = vnodeData.className || vnodeData.class;
517
- if (classData) {
518
- vnodeData.class = typeof classData !== "object" ? classData : Object.keys(classData).filter((k) => classData[k]).join(" ");
557
+ return this.__appendChild(newChild);
558
+ };
559
+ };
560
+ var patchSlotRemoveChild = (ElementPrototype) => {
561
+ ElementPrototype.__removeChild = ElementPrototype.removeChild;
562
+ ElementPrototype.removeChild = function(toRemove) {
563
+ if (toRemove && typeof toRemove["s-sn"] !== "undefined") {
564
+ const childNodes = this.__childNodes || this.childNodes;
565
+ const slotNode = getHostSlotNodes(childNodes, this.tagName, toRemove["s-sn"]);
566
+ if (slotNode && toRemove.isConnected) {
567
+ toRemove.remove();
568
+ updateFallbackSlotVisibility(this);
569
+ return;
519
570
  }
520
571
  }
521
- }
522
- if (BUILD8.isDev && vNodeChildren.some(isHost)) {
523
- consoleDevError(`The <Host> must be the single root component. Make sure:
524
- - You are NOT using hostData() and <Host> in the same component.
525
- - <Host> is used once, and it's the single root component of the render() function.`);
526
- }
527
- if (BUILD8.vdomFunctional && typeof nodeName === "function") {
528
- return nodeName(
529
- vnodeData === null ? {} : vnodeData,
530
- vNodeChildren,
531
- vdomFnUtils
532
- );
533
- }
534
- const vnode = newVNode(nodeName, null);
535
- vnode.$attrs$ = vnodeData;
536
- if (vNodeChildren.length > 0) {
537
- vnode.$children$ = vNodeChildren;
538
- }
539
- if (BUILD8.vdomKey) {
540
- vnode.$key$ = key;
541
- }
542
- if (BUILD8.slotRelocation) {
543
- vnode.$name$ = slotName;
544
- }
545
- return vnode;
572
+ return this.__removeChild(toRemove);
573
+ };
546
574
  };
547
- var newVNode = (tag, text) => {
548
- const vnode = {
549
- $flags$: 0,
550
- $tag$: tag,
551
- $text$: text,
552
- $elm$: null,
553
- $children$: null
575
+ var patchSlotPrepend = (HostElementPrototype) => {
576
+ HostElementPrototype.__prepend = HostElementPrototype.prepend;
577
+ HostElementPrototype.prepend = function(...newChildren) {
578
+ newChildren.forEach((newChild) => {
579
+ if (typeof newChild === "string") {
580
+ newChild = this.ownerDocument.createTextNode(newChild);
581
+ }
582
+ const slotName = newChild["s-sn"] = getSlotName(newChild);
583
+ const childNodes = this.__childNodes || this.childNodes;
584
+ const slotNode = getHostSlotNodes(childNodes, this.tagName, slotName)[0];
585
+ if (slotNode) {
586
+ addSlotRelocateNode(newChild, slotNode, true);
587
+ const slotChildNodes = getHostSlotChildNodes(slotNode, slotName);
588
+ const appendAfter = slotChildNodes[0];
589
+ const parent = intrnlCall(appendAfter, "parentNode");
590
+ if (parent.__insertBefore) {
591
+ return parent.__insertBefore(newChild, intrnlCall(appendAfter, "nextSibling"));
592
+ } else {
593
+ return parent.insertBefore(newChild, intrnlCall(appendAfter, "nextSibling"));
594
+ }
595
+ }
596
+ if (newChild.nodeType === 1 && !!newChild.getAttribute("slot")) {
597
+ newChild.hidden = true;
598
+ }
599
+ return HostElementPrototype.__prepend(newChild);
600
+ });
554
601
  };
555
- if (BUILD8.vdomAttribute) {
556
- vnode.$attrs$ = null;
557
- }
558
- if (BUILD8.vdomKey) {
559
- vnode.$key$ = null;
560
- }
561
- if (BUILD8.slotRelocation) {
562
- vnode.$name$ = null;
563
- }
564
- return vnode;
565
602
  };
566
- var Host = {};
567
- var isHost = (node) => node && node.$tag$ === Host;
568
- var vdomFnUtils = {
569
- forEach: (children, cb) => children.map(convertToPublic).forEach(cb),
570
- map: (children, cb) => children.map(convertToPublic).map(cb).map(convertToPrivate)
603
+ var patchSlotAppend = (HostElementPrototype) => {
604
+ HostElementPrototype.__append = HostElementPrototype.append;
605
+ HostElementPrototype.append = function(...newChildren) {
606
+ newChildren.forEach((newChild) => {
607
+ if (typeof newChild === "string") {
608
+ newChild = this.ownerDocument.createTextNode(newChild);
609
+ }
610
+ this.appendChild(newChild);
611
+ });
612
+ };
571
613
  };
572
- var convertToPublic = (node) => ({
573
- vattrs: node.$attrs$,
574
- vchildren: node.$children$,
575
- vkey: node.$key$,
576
- vname: node.$name$,
577
- vtag: node.$tag$,
578
- vtext: node.$text$
579
- });
580
- var convertToPrivate = (node) => {
581
- if (typeof node.vtag === "function") {
582
- const vnodeData = { ...node.vattrs };
583
- if (node.vkey) {
584
- vnodeData.key = node.vkey;
614
+ var patchSlotInsertAdjacentHTML = (HostElementPrototype) => {
615
+ const originalInsertAdjacentHtml = HostElementPrototype.insertAdjacentHTML;
616
+ HostElementPrototype.insertAdjacentHTML = function(position, text) {
617
+ if (position !== "afterbegin" && position !== "beforeend") {
618
+ return originalInsertAdjacentHtml.call(this, position, text);
585
619
  }
586
- if (node.vname) {
587
- vnodeData.name = node.vname;
620
+ const container = this.ownerDocument.createElement("_");
621
+ let node;
622
+ container.innerHTML = text;
623
+ if (position === "afterbegin") {
624
+ while (node = container.firstChild) {
625
+ this.prepend(node);
626
+ }
627
+ } else if (position === "beforeend") {
628
+ while (node = container.firstChild) {
629
+ this.append(node);
630
+ }
588
631
  }
589
- return h(node.vtag, vnodeData, ...node.vchildren || []);
590
- }
591
- const vnode = newVNode(node.vtag, node.vtext);
592
- vnode.$attrs$ = node.vattrs;
593
- vnode.$children$ = node.vchildren;
594
- vnode.$key$ = node.vkey;
595
- vnode.$name$ = node.vname;
596
- return vnode;
632
+ };
597
633
  };
598
- var validateInputProperties = (inputElm) => {
599
- const props = Object.keys(inputElm);
600
- const value = props.indexOf("value");
601
- if (value === -1) {
602
- return;
603
- }
604
- const typeIndex = props.indexOf("type");
605
- const minIndex = props.indexOf("min");
606
- const maxIndex = props.indexOf("max");
607
- const stepIndex = props.indexOf("step");
608
- if (value < typeIndex || value < minIndex || value < maxIndex || value < stepIndex) {
609
- consoleDevWarn(`The "value" prop of <input> should be set after "min", "max", "type" and "step"`);
610
- }
634
+ var patchSlotInsertAdjacentText = (HostElementPrototype) => {
635
+ HostElementPrototype.insertAdjacentText = function(position, text) {
636
+ this.insertAdjacentHTML(position, text);
637
+ };
611
638
  };
612
-
613
- // src/runtime/vdom/update-element.ts
614
- import { BUILD as BUILD10 } from "@rindo/core/internal/app-data";
615
-
616
- // src/runtime/vdom/set-accessor.ts
617
- import { BUILD as BUILD9 } from "@rindo/core/internal/app-data";
618
- var setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
619
- if (oldValue !== newValue) {
620
- let isProp = isMemberInElement(elm, memberName);
621
- let ln = memberName.toLowerCase();
622
- if (BUILD9.vdomClass && memberName === "class") {
623
- const classList = elm.classList;
624
- const oldClasses = parseClassList(oldValue);
625
- let newClasses = parseClassList(newValue);
626
- if (elm["s-si"]) {
627
- newClasses.push(elm["s-si"]);
628
- oldClasses.forEach((c) => {
629
- if (c.startsWith(elm["s-si"])) newClasses.push(c);
630
- });
631
- newClasses = [...new Set(newClasses)];
632
- classList.add(...newClasses);
633
- delete elm["s-si"];
634
- } else {
635
- classList.remove(...oldClasses.filter((c) => c && !newClasses.includes(c)));
636
- classList.add(...newClasses.filter((c) => c && !oldClasses.includes(c)));
637
- }
638
- } else if (BUILD9.vdomStyle && memberName === "style") {
639
- if (BUILD9.updatable) {
640
- for (const prop in oldValue) {
641
- if (!newValue || newValue[prop] == null) {
642
- if (!BUILD9.hydrateServerSide && prop.includes("-")) {
643
- elm.style.removeProperty(prop);
644
- } else {
645
- elm.style[prop] = "";
646
- }
647
- }
648
- }
649
- }
650
- for (const prop in newValue) {
651
- if (!oldValue || newValue[prop] !== oldValue[prop]) {
652
- if (!BUILD9.hydrateServerSide && prop.includes("-")) {
653
- elm.style.setProperty(prop, newValue[prop]);
654
- } else {
655
- elm.style[prop] = newValue[prop];
639
+ var patchInsertBefore = (HostElementPrototype) => {
640
+ const eleProto = HostElementPrototype;
641
+ if (eleProto.__insertBefore) return;
642
+ eleProto.__insertBefore = HostElementPrototype.insertBefore;
643
+ HostElementPrototype.insertBefore = function(newChild, currentChild) {
644
+ const slotName = newChild["s-sn"] = getSlotName(newChild);
645
+ const slotNode = getHostSlotNodes(this.__childNodes, this.tagName, slotName)[0];
646
+ const slottedNodes = this.__childNodes ? this.childNodes : getSlottedChildNodes(this.childNodes);
647
+ if (slotNode) {
648
+ let found = false;
649
+ slottedNodes.forEach((childNode) => {
650
+ if (childNode === currentChild || currentChild === null) {
651
+ found = true;
652
+ if (currentChild === null || slotName !== currentChild["s-sn"]) {
653
+ this.appendChild(newChild);
654
+ return;
656
655
  }
657
- }
658
- }
659
- } else if (BUILD9.vdomKey && memberName === "key") {
660
- } else if (BUILD9.vdomRef && memberName === "ref") {
661
- if (newValue) {
662
- newValue(elm);
663
- }
664
- } else if (BUILD9.vdomListener && (BUILD9.lazyLoad ? !isProp : !elm.__lookupSetter__(memberName)) && memberName[0] === "o" && memberName[1] === "n") {
665
- if (memberName[2] === "-") {
666
- memberName = memberName.slice(3);
667
- } else if (isMemberInElement(win, ln)) {
668
- memberName = ln.slice(2);
669
- } else {
670
- memberName = ln[2] + memberName.slice(3);
671
- }
672
- if (oldValue || newValue) {
673
- const capture = memberName.endsWith(CAPTURE_EVENT_SUFFIX);
674
- memberName = memberName.replace(CAPTURE_EVENT_REGEX, "");
675
- if (oldValue) {
676
- plt.rel(elm, memberName, oldValue, capture);
677
- }
678
- if (newValue) {
679
- plt.ael(elm, memberName, newValue, capture);
680
- }
681
- }
682
- } else if (BUILD9.vdomPropOrAttr) {
683
- const isComplex = isComplexType(newValue);
684
- if ((isProp || isComplex && newValue !== null) && !isSvg) {
685
- try {
686
- if (!elm.tagName.includes("-")) {
687
- const n = newValue == null ? "" : newValue;
688
- if (memberName === "list") {
689
- isProp = false;
690
- } else if (oldValue == null || elm[memberName] != n) {
691
- if (typeof elm.__lookupSetter__(memberName) === "function") {
692
- elm[memberName] = n;
693
- } else {
694
- elm.setAttribute(memberName, n);
695
- }
656
+ if (slotName === currentChild["s-sn"]) {
657
+ addSlotRelocateNode(newChild, slotNode);
658
+ const parent = intrnlCall(currentChild, "parentNode");
659
+ if (parent.__insertBefore) {
660
+ parent.__insertBefore(newChild, currentChild);
661
+ } else {
662
+ parent.insertBefore(newChild, currentChild);
696
663
  }
697
- } else {
698
- elm[memberName] = newValue;
699
- }
700
- } catch (e) {
701
- }
702
- }
703
- let xlink = false;
704
- if (BUILD9.vdomXlink) {
705
- if (ln !== (ln = ln.replace(/^xlink\:?/, ""))) {
706
- memberName = ln;
707
- xlink = true;
708
- }
709
- }
710
- if (newValue == null || newValue === false) {
711
- if (newValue !== false || elm.getAttribute(memberName) === "") {
712
- if (BUILD9.vdomXlink && xlink) {
713
- elm.removeAttributeNS(XLINK_NS, memberName);
714
- } else {
715
- elm.removeAttribute(memberName);
716
664
  }
665
+ return;
717
666
  }
718
- } else if ((!isProp || flags & 4 /* isHost */ || isSvg) && !isComplex) {
719
- newValue = newValue === true ? "" : newValue;
720
- if (BUILD9.vdomXlink && xlink) {
721
- elm.setAttributeNS(XLINK_NS, memberName, newValue);
722
- } else {
723
- elm.setAttribute(memberName, newValue);
724
- }
725
- }
667
+ });
668
+ if (found) return newChild;
726
669
  }
727
- }
670
+ return this.__insertBefore(newChild, currentChild);
671
+ };
728
672
  };
729
- var parseClassListRegex = /\s/;
730
- var parseClassList = (value) => {
731
- if (typeof value === "object" && "baseVal" in value) {
732
- value = value.baseVal;
733
- }
734
- if (!value) {
735
- return [];
736
- }
737
- return value.split(parseClassListRegex);
673
+ var patchSlotInsertAdjacentElement = (HostElementPrototype) => {
674
+ const originalInsertAdjacentElement = HostElementPrototype.insertAdjacentElement;
675
+ HostElementPrototype.insertAdjacentElement = function(position, element) {
676
+ if (position !== "afterbegin" && position !== "beforeend") {
677
+ return originalInsertAdjacentElement.call(this, position, element);
678
+ }
679
+ if (position === "afterbegin") {
680
+ this.prepend(element);
681
+ return element;
682
+ } else if (position === "beforeend") {
683
+ this.append(element);
684
+ return element;
685
+ }
686
+ return element;
687
+ };
738
688
  };
739
- var CAPTURE_EVENT_SUFFIX = "Capture";
740
- var CAPTURE_EVENT_REGEX = new RegExp(CAPTURE_EVENT_SUFFIX + "$");
741
-
742
- // src/runtime/vdom/update-element.ts
743
- var updateElement = (oldVnode, newVnode, isSvgMode2) => {
744
- const elm = newVnode.$elm$.nodeType === 11 /* DocumentFragment */ && newVnode.$elm$.host ? newVnode.$elm$.host : newVnode.$elm$;
745
- const oldVnodeAttrs = oldVnode && oldVnode.$attrs$ || {};
746
- const newVnodeAttrs = newVnode.$attrs$ || {};
747
- if (BUILD10.updatable) {
748
- for (const memberName of sortedAttrNames(Object.keys(oldVnodeAttrs))) {
749
- if (!(memberName in newVnodeAttrs)) {
750
- setAccessor(elm, memberName, oldVnodeAttrs[memberName], void 0, isSvgMode2, newVnode.$flags$);
751
- }
689
+ var patchTextContent = (hostElementPrototype) => {
690
+ patchHostOriginalAccessor("textContent", hostElementPrototype);
691
+ Object.defineProperty(hostElementPrototype, "textContent", {
692
+ get: function() {
693
+ let text = "";
694
+ const childNodes = this.__childNodes ? this.childNodes : getSlottedChildNodes(this.childNodes);
695
+ childNodes.forEach((node) => text += node.textContent || "");
696
+ return text;
697
+ },
698
+ set: function(value) {
699
+ const childNodes = this.__childNodes ? this.childNodes : getSlottedChildNodes(this.childNodes);
700
+ childNodes.forEach((node) => {
701
+ if (node["s-ol"]) node["s-ol"].remove();
702
+ node.remove();
703
+ });
704
+ this.insertAdjacentHTML("beforeend", value);
752
705
  }
753
- }
754
- for (const memberName of sortedAttrNames(Object.keys(newVnodeAttrs))) {
755
- setAccessor(elm, memberName, oldVnodeAttrs[memberName], newVnodeAttrs[memberName], isSvgMode2, newVnode.$flags$);
756
- }
706
+ });
757
707
  };
758
- function sortedAttrNames(attrNames) {
759
- return attrNames.includes("ref") ? (
760
- // we need to sort these to ensure that `'ref'` is the last attr
761
- [...attrNames.filter((attr) => attr !== "ref"), "ref"]
762
- ) : (
763
- // no need to sort, return the original array
764
- attrNames
765
- );
766
- }
767
-
768
- // src/runtime/vdom/vdom-render.ts
769
- var scopeId;
770
- var contentRef;
771
- var hostTagName;
772
- var useNativeShadowDom = false;
773
- var checkSlotFallbackVisibility = false;
774
- var checkSlotRelocate = false;
775
- var isSvgMode = false;
776
- var createElm = (oldParentVNode, newParentVNode, childIndex) => {
777
- var _a;
778
- const newVNode2 = newParentVNode.$children$[childIndex];
779
- let i2 = 0;
780
- let elm;
781
- let childNode;
782
- let oldVNode;
783
- if (BUILD11.slotRelocation && !useNativeShadowDom) {
784
- checkSlotRelocate = true;
785
- if (newVNode2.$tag$ === "slot") {
786
- newVNode2.$flags$ |= newVNode2.$children$ ? (
787
- // slot element has fallback content
788
- // still create an element that "mocks" the slot element
789
- 2 /* isSlotFallback */
790
- ) : (
791
- // slot element does not have fallback content
792
- // create an html comment we'll use to always reference
793
- // where actual slot content should sit next to
794
- 1 /* isSlotReference */
795
- );
708
+ var patchChildSlotNodes = (elm) => {
709
+ class FakeNodeList extends Array {
710
+ item(n) {
711
+ return this[n];
796
712
  }
797
713
  }
798
- if (BUILD11.isDev && newVNode2.$elm$) {
799
- consoleDevError(
800
- `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`
801
- );
802
- }
803
- if (BUILD11.vdomText && newVNode2.$text$ !== null) {
804
- elm = newVNode2.$elm$ = doc.createTextNode(newVNode2.$text$);
805
- } else if (BUILD11.slotRelocation && newVNode2.$flags$ & 1 /* isSlotReference */) {
806
- elm = newVNode2.$elm$ = BUILD11.isDebug || BUILD11.hydrateServerSide ? slotReferenceDebugNode(newVNode2) : doc.createTextNode("");
807
- } else {
808
- if (BUILD11.svg && !isSvgMode) {
809
- isSvgMode = newVNode2.$tag$ === "svg";
810
- }
811
- elm = newVNode2.$elm$ = BUILD11.svg ? doc.createElementNS(
812
- isSvgMode ? SVG_NS : HTML_NS,
813
- !useNativeShadowDom && BUILD11.slotRelocation && newVNode2.$flags$ & 2 /* isSlotFallback */ ? "slot-fb" : newVNode2.$tag$
814
- ) : doc.createElement(
815
- !useNativeShadowDom && BUILD11.slotRelocation && newVNode2.$flags$ & 2 /* isSlotFallback */ ? "slot-fb" : newVNode2.$tag$
816
- );
817
- if (BUILD11.svg && isSvgMode && newVNode2.$tag$ === "foreignObject") {
818
- isSvgMode = false;
714
+ patchHostOriginalAccessor("children", elm);
715
+ Object.defineProperty(elm, "children", {
716
+ get() {
717
+ return this.childNodes.filter((n) => n.nodeType === 1);
819
718
  }
820
- if (BUILD11.vdomAttribute) {
821
- updateElement(null, newVNode2, isSvgMode);
719
+ });
720
+ Object.defineProperty(elm, "childElementCount", {
721
+ get() {
722
+ return this.children.length;
822
723
  }
823
- if (BUILD11.scoped && isDef(scopeId) && elm["s-si"] !== scopeId) {
824
- elm.classList.add(elm["s-si"] = scopeId);
724
+ });
725
+ patchHostOriginalAccessor("firstChild", elm);
726
+ Object.defineProperty(elm, "firstChild", {
727
+ get() {
728
+ return this.childNodes[0];
825
729
  }
826
- if (newVNode2.$children$) {
827
- for (i2 = 0; i2 < newVNode2.$children$.length; ++i2) {
828
- childNode = createElm(oldParentVNode, newVNode2, i2);
829
- if (childNode) {
830
- elm.appendChild(childNode);
831
- }
832
- }
730
+ });
731
+ patchHostOriginalAccessor("lastChild", elm);
732
+ Object.defineProperty(elm, "lastChild", {
733
+ get() {
734
+ return this.childNodes[this.childNodes.length - 1];
833
735
  }
834
- if (BUILD11.svg) {
835
- if (newVNode2.$tag$ === "svg") {
836
- isSvgMode = false;
837
- } else if (elm.tagName === "foreignObject") {
838
- isSvgMode = true;
839
- }
736
+ });
737
+ patchHostOriginalAccessor("childNodes", elm);
738
+ Object.defineProperty(elm, "childNodes", {
739
+ get() {
740
+ const result = new FakeNodeList();
741
+ result.push(...getSlottedChildNodes(this.__childNodes));
742
+ return result;
840
743
  }
744
+ });
745
+ };
746
+ var patchSlottedNode = (node) => {
747
+ if (!node || node.__nextSibling || !globalThis.Node) return;
748
+ patchNextSibling(node);
749
+ patchPreviousSibling(node);
750
+ patchParentNode(node);
751
+ if (node.nodeType === Node.ELEMENT_NODE) {
752
+ patchNextElementSibling(node);
753
+ patchPreviousElementSibling(node);
841
754
  }
842
- elm["s-hn"] = hostTagName;
843
- if (BUILD11.slotRelocation) {
844
- if (newVNode2.$flags$ & (2 /* isSlotFallback */ | 1 /* isSlotReference */)) {
845
- elm["s-sr"] = true;
846
- elm["s-cr"] = contentRef;
847
- elm["s-sn"] = newVNode2.$name$ || "";
848
- elm["s-rf"] = (_a = newVNode2.$attrs$) == null ? void 0 : _a.ref;
849
- oldVNode = oldParentVNode && oldParentVNode.$children$ && oldParentVNode.$children$[childIndex];
850
- if (oldVNode && oldVNode.$tag$ === newVNode2.$tag$ && oldParentVNode.$elm$) {
851
- if (BUILD11.experimentalSlotFixes) {
852
- relocateToHostRoot(oldParentVNode.$elm$);
853
- } else {
854
- putBackInOriginalLocation(oldParentVNode.$elm$, false);
855
- }
856
- }
857
- if (BUILD11.scoped) {
858
- addRemoveSlotScopedClass(contentRef, elm, newParentVNode.$elm$, oldParentVNode == null ? void 0 : oldParentVNode.$elm$);
755
+ };
756
+ var patchNextSibling = (node) => {
757
+ if (!node || node.__nextSibling) return;
758
+ patchHostOriginalAccessor("nextSibling", node);
759
+ Object.defineProperty(node, "nextSibling", {
760
+ get: function() {
761
+ var _a;
762
+ const parentNodes = (_a = this["s-ol"]) == null ? void 0 : _a.parentNode.childNodes;
763
+ const index = parentNodes == null ? void 0 : parentNodes.indexOf(this);
764
+ if (parentNodes && index > -1) {
765
+ return parentNodes[index + 1];
859
766
  }
767
+ return this.__nextSibling;
860
768
  }
861
- }
862
- return elm;
769
+ });
863
770
  };
864
- var relocateToHostRoot = (parentElm) => {
865
- plt.$flags$ |= 1 /* isTmpDisconnected */;
866
- const host = parentElm.closest(hostTagName.toLowerCase());
867
- if (host != null) {
868
- const contentRefNode = Array.from(host.__childNodes || host.childNodes).find(
869
- (ref) => ref["s-cr"]
870
- );
871
- const childNodeArray = Array.from(
872
- parentElm.__childNodes || parentElm.childNodes
873
- );
874
- for (const childNode of contentRefNode ? childNodeArray.reverse() : childNodeArray) {
875
- if (childNode["s-sh"] != null) {
876
- insertBefore(host, childNode, contentRefNode != null ? contentRefNode : null);
877
- childNode["s-sh"] = void 0;
878
- checkSlotRelocate = true;
771
+ var patchNextElementSibling = (element) => {
772
+ if (!element || element.__nextElementSibling) return;
773
+ patchHostOriginalAccessor("nextElementSibling", element);
774
+ Object.defineProperty(element, "nextElementSibling", {
775
+ get: function() {
776
+ var _a;
777
+ const parentEles = (_a = this["s-ol"]) == null ? void 0 : _a.parentNode.children;
778
+ const index = parentEles == null ? void 0 : parentEles.indexOf(this);
779
+ if (parentEles && index > -1) {
780
+ return parentEles[index + 1];
879
781
  }
782
+ return this.__nextElementSibling;
880
783
  }
881
- }
882
- plt.$flags$ &= ~1 /* isTmpDisconnected */;
784
+ });
883
785
  };
884
- var putBackInOriginalLocation = (parentElm, recursive) => {
885
- plt.$flags$ |= 1 /* isTmpDisconnected */;
886
- const oldSlotChildNodes = Array.from(parentElm.__childNodes || parentElm.childNodes);
887
- if (parentElm["s-sr"] && BUILD11.experimentalSlotFixes) {
888
- let node = parentElm;
889
- while (node = node.nextSibling) {
890
- if (node && node["s-sn"] === parentElm["s-sn"] && node["s-sh"] === hostTagName) {
891
- oldSlotChildNodes.push(node);
786
+ var patchPreviousSibling = (node) => {
787
+ if (!node || node.__previousSibling) return;
788
+ patchHostOriginalAccessor("previousSibling", node);
789
+ Object.defineProperty(node, "previousSibling", {
790
+ get: function() {
791
+ var _a;
792
+ const parentNodes = (_a = this["s-ol"]) == null ? void 0 : _a.parentNode.childNodes;
793
+ const index = parentNodes == null ? void 0 : parentNodes.indexOf(this);
794
+ if (parentNodes && index > -1) {
795
+ return parentNodes[index - 1];
892
796
  }
797
+ return this.__previousSibling;
893
798
  }
894
- }
895
- for (let i2 = oldSlotChildNodes.length - 1; i2 >= 0; i2--) {
896
- const childNode = oldSlotChildNodes[i2];
897
- if (childNode["s-hn"] !== hostTagName && childNode["s-ol"]) {
898
- insertBefore(referenceNode(childNode).parentNode, childNode, referenceNode(childNode));
899
- childNode["s-ol"].remove();
900
- childNode["s-ol"] = void 0;
901
- childNode["s-sh"] = void 0;
902
- checkSlotRelocate = true;
799
+ });
800
+ };
801
+ var patchPreviousElementSibling = (element) => {
802
+ if (!element || element.__previousElementSibling) return;
803
+ patchHostOriginalAccessor("previousElementSibling", element);
804
+ Object.defineProperty(element, "previousElementSibling", {
805
+ get: function() {
806
+ var _a;
807
+ const parentNodes = (_a = this["s-ol"]) == null ? void 0 : _a.parentNode.children;
808
+ const index = parentNodes == null ? void 0 : parentNodes.indexOf(this);
809
+ if (parentNodes && index > -1) {
810
+ return parentNodes[index - 1];
811
+ }
812
+ return this.__previousElementSibling;
903
813
  }
904
- if (recursive) {
905
- putBackInOriginalLocation(childNode, recursive);
814
+ });
815
+ };
816
+ var patchParentNode = (node) => {
817
+ if (!node || node.__parentNode) return;
818
+ patchHostOriginalAccessor("parentNode", node);
819
+ Object.defineProperty(node, "parentNode", {
820
+ get: function() {
821
+ var _a;
822
+ return ((_a = this["s-ol"]) == null ? void 0 : _a.parentNode) || this.__parentNode;
823
+ },
824
+ set: function(value) {
825
+ this.__parentNode = value;
906
826
  }
907
- }
908
- plt.$flags$ &= ~1 /* isTmpDisconnected */;
827
+ });
909
828
  };
910
- var addVnodes = (parentElm, before, parentVNode, vnodes, startIdx, endIdx) => {
911
- let containerElm = BUILD11.slotRelocation && parentElm["s-cr"] && parentElm["s-cr"].parentNode || parentElm;
912
- let childNode;
913
- if (BUILD11.shadowDom && containerElm.shadowRoot && containerElm.tagName === hostTagName) {
914
- containerElm = containerElm.shadowRoot;
829
+ var validElementPatches = ["children", "nextElementSibling", "previousElementSibling"];
830
+ var validNodesPatches = [
831
+ "childNodes",
832
+ "firstChild",
833
+ "lastChild",
834
+ "nextSibling",
835
+ "previousSibling",
836
+ "textContent",
837
+ "parentNode"
838
+ ];
839
+ function patchHostOriginalAccessor(accessorName, node) {
840
+ let accessor;
841
+ if (validElementPatches.includes(accessorName)) {
842
+ accessor = Object.getOwnPropertyDescriptor(Element.prototype, accessorName);
843
+ } else if (validNodesPatches.includes(accessorName)) {
844
+ accessor = Object.getOwnPropertyDescriptor(Node.prototype, accessorName);
915
845
  }
916
- for (; startIdx <= endIdx; ++startIdx) {
917
- if (vnodes[startIdx]) {
918
- childNode = createElm(null, parentVNode, startIdx);
919
- if (childNode) {
920
- vnodes[startIdx].$elm$ = childNode;
921
- insertBefore(containerElm, childNode, BUILD11.slotRelocation ? referenceNode(before) : before);
922
- }
923
- }
846
+ if (!accessor) {
847
+ accessor = Object.getOwnPropertyDescriptor(node, accessorName);
848
+ }
849
+ if (accessor) Object.defineProperty(node, "__" + accessorName, accessor);
850
+ }
851
+ function intrnlCall(node, method) {
852
+ if ("__" + method in node) {
853
+ return node["__" + method];
854
+ } else {
855
+ return node[method];
856
+ }
857
+ }
858
+
859
+ // src/runtime/profile.ts
860
+ import { BUILD as BUILD10 } from "@rindo/core/internal/app-data";
861
+ var i = 0;
862
+ var createTime = (fnName, tagName = "") => {
863
+ if (BUILD10.profile && performance.mark) {
864
+ const key = `st:${fnName}:${tagName}:${i++}`;
865
+ performance.mark(key);
866
+ return () => performance.measure(`[Rindo] ${fnName}() <${tagName}>`, key);
867
+ } else {
868
+ return () => {
869
+ return;
870
+ };
924
871
  }
925
872
  };
926
- var removeVnodes = (vnodes, startIdx, endIdx) => {
927
- for (let index = startIdx; index <= endIdx; ++index) {
928
- const vnode = vnodes[index];
929
- if (vnode) {
930
- const elm = vnode.$elm$;
931
- nullifyVNodeRefs(vnode);
932
- if (elm) {
933
- if (BUILD11.slotRelocation) {
934
- checkSlotFallbackVisibility = true;
935
- if (elm["s-ol"]) {
936
- elm["s-ol"].remove();
937
- } else {
938
- putBackInOriginalLocation(elm, true);
939
- }
940
- }
941
- elm.remove();
942
- }
873
+ var uniqueTime = (key, measureText) => {
874
+ if (BUILD10.profile && performance.mark) {
875
+ if (performance.getEntriesByName(key, "mark").length === 0) {
876
+ performance.mark(key);
943
877
  }
878
+ return () => {
879
+ if (performance.getEntriesByName(measureText, "measure").length === 0) {
880
+ performance.measure(measureText, key);
881
+ }
882
+ };
883
+ } else {
884
+ return () => {
885
+ return;
886
+ };
944
887
  }
945
888
  };
946
- var updateChildren = (parentElm, oldCh, newVNode2, newCh, isInitialRender = false) => {
947
- let oldStartIdx = 0;
948
- let newStartIdx = 0;
949
- let idxInOld = 0;
950
- let i2 = 0;
951
- let oldEndIdx = oldCh.length - 1;
952
- let oldStartVnode = oldCh[0];
953
- let oldEndVnode = oldCh[oldEndIdx];
954
- let newEndIdx = newCh.length - 1;
955
- let newStartVnode = newCh[0];
956
- let newEndVnode = newCh[newEndIdx];
957
- let node;
958
- let elmToMove;
959
- while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
960
- if (oldStartVnode == null) {
961
- oldStartVnode = oldCh[++oldStartIdx];
962
- } else if (oldEndVnode == null) {
963
- oldEndVnode = oldCh[--oldEndIdx];
964
- } else if (newStartVnode == null) {
965
- newStartVnode = newCh[++newStartIdx];
966
- } else if (newEndVnode == null) {
967
- newEndVnode = newCh[--newEndIdx];
968
- } else if (isSameVnode(oldStartVnode, newStartVnode, isInitialRender)) {
969
- patch(oldStartVnode, newStartVnode, isInitialRender);
970
- oldStartVnode = oldCh[++oldStartIdx];
971
- newStartVnode = newCh[++newStartIdx];
972
- } else if (isSameVnode(oldEndVnode, newEndVnode, isInitialRender)) {
973
- patch(oldEndVnode, newEndVnode, isInitialRender);
974
- oldEndVnode = oldCh[--oldEndIdx];
975
- newEndVnode = newCh[--newEndIdx];
976
- } else if (isSameVnode(oldStartVnode, newEndVnode, isInitialRender)) {
977
- if (BUILD11.slotRelocation && (oldStartVnode.$tag$ === "slot" || newEndVnode.$tag$ === "slot")) {
978
- putBackInOriginalLocation(oldStartVnode.$elm$.parentNode, false);
979
- }
980
- patch(oldStartVnode, newEndVnode, isInitialRender);
981
- insertBefore(parentElm, oldStartVnode.$elm$, oldEndVnode.$elm$.nextSibling);
982
- oldStartVnode = oldCh[++oldStartIdx];
983
- newEndVnode = newCh[--newEndIdx];
984
- } else if (isSameVnode(oldEndVnode, newStartVnode, isInitialRender)) {
985
- if (BUILD11.slotRelocation && (oldStartVnode.$tag$ === "slot" || newEndVnode.$tag$ === "slot")) {
986
- putBackInOriginalLocation(oldEndVnode.$elm$.parentNode, false);
889
+ var inspect = (ref) => {
890
+ const hostRef = getHostRef(ref);
891
+ if (!hostRef) {
892
+ return void 0;
893
+ }
894
+ const flags = hostRef.$flags$;
895
+ const hostElement = hostRef.$hostElement$;
896
+ return {
897
+ renderCount: hostRef.$renderCount$,
898
+ flags: {
899
+ hasRendered: !!(flags & 2 /* hasRendered */),
900
+ hasConnected: !!(flags & 1 /* hasConnected */),
901
+ isWaitingForChildren: !!(flags & 4 /* isWaitingForChildren */),
902
+ isConstructingInstance: !!(flags & 8 /* isConstructingInstance */),
903
+ isQueuedForUpdate: !!(flags & 16 /* isQueuedForUpdate */),
904
+ hasInitializedComponent: !!(flags & 32 /* hasInitializedComponent */),
905
+ hasLoadedComponent: !!(flags & 64 /* hasLoadedComponent */),
906
+ isWatchReady: !!(flags & 128 /* isWatchReady */),
907
+ isListenReady: !!(flags & 256 /* isListenReady */),
908
+ needsRerender: !!(flags & 512 /* needsRerender */)
909
+ },
910
+ instanceValues: hostRef.$instanceValues$,
911
+ ancestorComponent: hostRef.$ancestorComponent$,
912
+ hostElement,
913
+ lazyInstance: hostRef.$lazyInstance$,
914
+ vnode: hostRef.$vnode$,
915
+ modeName: hostRef.$modeName$,
916
+ onReadyPromise: hostRef.$onReadyPromise$,
917
+ onReadyResolve: hostRef.$onReadyResolve$,
918
+ onInstancePromise: hostRef.$onInstancePromise$,
919
+ onInstanceResolve: hostRef.$onInstanceResolve$,
920
+ onRenderResolve: hostRef.$onRenderResolve$,
921
+ queuedListeners: hostRef.$queuedListeners$,
922
+ rmListeners: hostRef.$rmListeners$,
923
+ ["s-id"]: hostElement["s-id"],
924
+ ["s-cr"]: hostElement["s-cr"],
925
+ ["s-lr"]: hostElement["s-lr"],
926
+ ["s-p"]: hostElement["s-p"],
927
+ ["s-rc"]: hostElement["s-rc"],
928
+ ["s-sc"]: hostElement["s-sc"]
929
+ };
930
+ };
931
+ var installDevTools = () => {
932
+ if (BUILD10.devTools) {
933
+ const rindo = win.rindo = win.rindo || {};
934
+ const originalInspect = rindo.inspect;
935
+ rindo.inspect = (ref) => {
936
+ let result = inspect(ref);
937
+ if (!result && typeof originalInspect === "function") {
938
+ result = originalInspect(ref);
987
939
  }
988
- patch(oldEndVnode, newStartVnode, isInitialRender);
989
- insertBefore(parentElm, oldEndVnode.$elm$, oldStartVnode.$elm$);
990
- oldEndVnode = oldCh[--oldEndIdx];
991
- newStartVnode = newCh[++newStartIdx];
992
- } else {
993
- idxInOld = -1;
994
- if (BUILD11.vdomKey) {
995
- for (i2 = oldStartIdx; i2 <= oldEndIdx; ++i2) {
996
- if (oldCh[i2] && oldCh[i2].$key$ !== null && oldCh[i2].$key$ === newStartVnode.$key$) {
997
- idxInOld = i2;
998
- break;
999
- }
940
+ return result;
941
+ };
942
+ }
943
+ };
944
+
945
+ // src/runtime/vdom/h.ts
946
+ import { BUILD as BUILD11 } from "@rindo/core/internal/app-data";
947
+ var h = (nodeName, vnodeData, ...children) => {
948
+ let child = null;
949
+ let key = null;
950
+ let slotName = null;
951
+ let simple = false;
952
+ let lastSimple = false;
953
+ const vNodeChildren = [];
954
+ const walk = (c) => {
955
+ for (let i2 = 0; i2 < c.length; i2++) {
956
+ child = c[i2];
957
+ if (Array.isArray(child)) {
958
+ walk(child);
959
+ } else if (child != null && typeof child !== "boolean") {
960
+ if (simple = typeof nodeName !== "function" && !isComplexType(child)) {
961
+ child = String(child);
962
+ } else if (BUILD11.isDev && typeof nodeName !== "function" && child.$flags$ === void 0) {
963
+ consoleDevError(`vNode passed as children has unexpected type.
964
+ Make sure it's using the correct h() function.
965
+ Empty objects can also be the cause, look for JSX comments that became objects.`);
1000
966
  }
1001
- }
1002
- if (BUILD11.vdomKey && idxInOld >= 0) {
1003
- elmToMove = oldCh[idxInOld];
1004
- if (elmToMove.$tag$ !== newStartVnode.$tag$) {
1005
- node = createElm(oldCh && oldCh[newStartIdx], newVNode2, idxInOld);
967
+ if (simple && lastSimple) {
968
+ vNodeChildren[vNodeChildren.length - 1].$text$ += child;
1006
969
  } else {
1007
- patch(elmToMove, newStartVnode, isInitialRender);
1008
- oldCh[idxInOld] = void 0;
1009
- node = elmToMove.$elm$;
970
+ vNodeChildren.push(simple ? newVNode(null, child) : child);
1010
971
  }
1011
- newStartVnode = newCh[++newStartIdx];
1012
- } else {
1013
- node = createElm(oldCh && oldCh[newStartIdx], newVNode2, newStartIdx);
1014
- newStartVnode = newCh[++newStartIdx];
972
+ lastSimple = simple;
1015
973
  }
1016
- if (node) {
1017
- if (BUILD11.slotRelocation) {
1018
- insertBefore(
1019
- referenceNode(oldStartVnode.$elm$).parentNode,
1020
- node,
1021
- referenceNode(oldStartVnode.$elm$)
1022
- );
1023
- } else {
1024
- insertBefore(oldStartVnode.$elm$.parentNode, node, oldStartVnode.$elm$);
1025
- }
974
+ }
975
+ };
976
+ walk(children);
977
+ if (vnodeData) {
978
+ if (BUILD11.isDev && nodeName === "input") {
979
+ validateInputProperties(vnodeData);
980
+ }
981
+ if (BUILD11.vdomKey && vnodeData.key) {
982
+ key = vnodeData.key;
983
+ }
984
+ if (BUILD11.slotRelocation && vnodeData.name) {
985
+ slotName = vnodeData.name;
986
+ }
987
+ if (BUILD11.vdomClass) {
988
+ const classData = vnodeData.className || vnodeData.class;
989
+ if (classData) {
990
+ vnodeData.class = typeof classData !== "object" ? classData : Object.keys(classData).filter((k) => classData[k]).join(" ");
1026
991
  }
1027
992
  }
1028
993
  }
1029
- if (oldStartIdx > oldEndIdx) {
1030
- addVnodes(
1031
- parentElm,
1032
- newCh[newEndIdx + 1] == null ? null : newCh[newEndIdx + 1].$elm$,
1033
- newVNode2,
1034
- newCh,
1035
- newStartIdx,
1036
- newEndIdx
994
+ if (BUILD11.isDev && vNodeChildren.some(isHost)) {
995
+ consoleDevError(`The <Host> must be the single root component. Make sure:
996
+ - You are NOT using hostData() and <Host> in the same component.
997
+ - <Host> is used once, and it's the single root component of the render() function.`);
998
+ }
999
+ if (BUILD11.vdomFunctional && typeof nodeName === "function") {
1000
+ return nodeName(
1001
+ vnodeData === null ? {} : vnodeData,
1002
+ vNodeChildren,
1003
+ vdomFnUtils
1037
1004
  );
1038
- } else if (BUILD11.updatable && newStartIdx > newEndIdx) {
1039
- removeVnodes(oldCh, oldStartIdx, oldEndIdx);
1040
1005
  }
1006
+ const vnode = newVNode(nodeName, null);
1007
+ vnode.$attrs$ = vnodeData;
1008
+ if (vNodeChildren.length > 0) {
1009
+ vnode.$children$ = vNodeChildren;
1010
+ }
1011
+ if (BUILD11.vdomKey) {
1012
+ vnode.$key$ = key;
1013
+ }
1014
+ if (BUILD11.slotRelocation) {
1015
+ vnode.$name$ = slotName;
1016
+ }
1017
+ return vnode;
1041
1018
  };
1042
- var isSameVnode = (leftVNode, rightVNode, isInitialRender = false) => {
1043
- if (leftVNode.$tag$ === rightVNode.$tag$) {
1044
- if (BUILD11.slotRelocation && leftVNode.$tag$ === "slot") {
1045
- return leftVNode.$name$ === rightVNode.$name$;
1046
- }
1047
- if (BUILD11.vdomKey && !isInitialRender) {
1048
- return leftVNode.$key$ === rightVNode.$key$;
1049
- }
1050
- if (isInitialRender && !leftVNode.$key$ && rightVNode.$key$) {
1051
- leftVNode.$key$ = rightVNode.$key$;
1052
- }
1053
- return true;
1019
+ var newVNode = (tag, text) => {
1020
+ const vnode = {
1021
+ $flags$: 0,
1022
+ $tag$: tag,
1023
+ $text$: text,
1024
+ $elm$: null,
1025
+ $children$: null
1026
+ };
1027
+ if (BUILD11.vdomAttribute) {
1028
+ vnode.$attrs$ = null;
1054
1029
  }
1055
- return false;
1030
+ if (BUILD11.vdomKey) {
1031
+ vnode.$key$ = null;
1032
+ }
1033
+ if (BUILD11.slotRelocation) {
1034
+ vnode.$name$ = null;
1035
+ }
1036
+ return vnode;
1056
1037
  };
1057
- var referenceNode = (node) => node && node["s-ol"] || node;
1058
- var patch = (oldVNode, newVNode2, isInitialRender = false) => {
1059
- const elm = newVNode2.$elm$ = oldVNode.$elm$;
1060
- const oldChildren = oldVNode.$children$;
1061
- const newChildren = newVNode2.$children$;
1062
- const tag = newVNode2.$tag$;
1063
- const text = newVNode2.$text$;
1064
- let defaultHolder;
1065
- if (!BUILD11.vdomText || text === null) {
1066
- if (BUILD11.svg) {
1067
- isSvgMode = tag === "svg" ? true : tag === "foreignObject" ? false : isSvgMode;
1068
- }
1069
- if (BUILD11.vdomAttribute || BUILD11.reflect) {
1070
- if (BUILD11.slot && tag === "slot" && !useNativeShadowDom) {
1071
- if (BUILD11.experimentalSlotFixes && oldVNode.$name$ !== newVNode2.$name$) {
1072
- newVNode2.$elm$["s-sn"] = newVNode2.$name$ || "";
1073
- relocateToHostRoot(newVNode2.$elm$.parentElement);
1074
- }
1075
- } else {
1076
- updateElement(oldVNode, newVNode2, isSvgMode);
1077
- }
1078
- }
1079
- if (BUILD11.updatable && oldChildren !== null && newChildren !== null) {
1080
- updateChildren(elm, oldChildren, newVNode2, newChildren, isInitialRender);
1081
- } else if (newChildren !== null) {
1082
- if (BUILD11.updatable && BUILD11.vdomText && oldVNode.$text$ !== null) {
1083
- elm.textContent = "";
1084
- }
1085
- addVnodes(elm, null, newVNode2, newChildren, 0, newChildren.length - 1);
1086
- } else if (
1087
- // don't do this on initial render as it can cause non-hydrated content to be removed
1088
- !isInitialRender && BUILD11.updatable && oldChildren !== null
1089
- ) {
1090
- removeVnodes(oldChildren, 0, oldChildren.length - 1);
1038
+ var Host = {};
1039
+ var isHost = (node) => node && node.$tag$ === Host;
1040
+ var vdomFnUtils = {
1041
+ forEach: (children, cb) => children.map(convertToPublic).forEach(cb),
1042
+ map: (children, cb) => children.map(convertToPublic).map(cb).map(convertToPrivate)
1043
+ };
1044
+ var convertToPublic = (node) => ({
1045
+ vattrs: node.$attrs$,
1046
+ vchildren: node.$children$,
1047
+ vkey: node.$key$,
1048
+ vname: node.$name$,
1049
+ vtag: node.$tag$,
1050
+ vtext: node.$text$
1051
+ });
1052
+ var convertToPrivate = (node) => {
1053
+ if (typeof node.vtag === "function") {
1054
+ const vnodeData = { ...node.vattrs };
1055
+ if (node.vkey) {
1056
+ vnodeData.key = node.vkey;
1091
1057
  }
1092
- if (BUILD11.svg && isSvgMode && tag === "svg") {
1093
- isSvgMode = false;
1058
+ if (node.vname) {
1059
+ vnodeData.name = node.vname;
1094
1060
  }
1095
- } else if (BUILD11.vdomText && BUILD11.slotRelocation && (defaultHolder = elm["s-cr"])) {
1096
- defaultHolder.parentNode.textContent = text;
1097
- } else if (BUILD11.vdomText && oldVNode.$text$ !== text) {
1098
- elm.data = text;
1061
+ return h(node.vtag, vnodeData, ...node.vchildren || []);
1099
1062
  }
1063
+ const vnode = newVNode(node.vtag, node.vtext);
1064
+ vnode.$attrs$ = node.vattrs;
1065
+ vnode.$children$ = node.vchildren;
1066
+ vnode.$key$ = node.vkey;
1067
+ vnode.$name$ = node.vname;
1068
+ return vnode;
1100
1069
  };
1101
- var relocateNodes = [];
1102
- var markSlotContentForRelocation = (elm) => {
1103
- let node;
1104
- let hostContentNodes;
1105
- let j;
1106
- const children = elm.__childNodes || elm.childNodes;
1107
- for (const childNode of children) {
1108
- if (childNode["s-sr"] && (node = childNode["s-cr"]) && node.parentNode) {
1109
- hostContentNodes = node.parentNode.__childNodes || node.parentNode.childNodes;
1110
- const slotName = childNode["s-sn"];
1111
- for (j = hostContentNodes.length - 1; j >= 0; j--) {
1112
- node = hostContentNodes[j];
1113
- if (!node["s-cn"] && !node["s-nr"] && node["s-hn"] !== childNode["s-hn"] && (!BUILD11.experimentalSlotFixes || !node["s-sh"] || node["s-sh"] !== childNode["s-hn"])) {
1114
- if (isNodeLocatedInSlot(node, slotName)) {
1115
- let relocateNodeData = relocateNodes.find((r) => r.$nodeToRelocate$ === node);
1116
- checkSlotFallbackVisibility = true;
1117
- node["s-sn"] = node["s-sn"] || slotName;
1118
- if (relocateNodeData) {
1119
- relocateNodeData.$nodeToRelocate$["s-sh"] = childNode["s-hn"];
1120
- relocateNodeData.$slotRefNode$ = childNode;
1121
- } else {
1122
- node["s-sh"] = childNode["s-hn"];
1123
- relocateNodes.push({
1124
- $slotRefNode$: childNode,
1125
- $nodeToRelocate$: node
1126
- });
1127
- }
1128
- if (node["s-sr"]) {
1129
- relocateNodes.map((relocateNode) => {
1130
- if (isNodeLocatedInSlot(relocateNode.$nodeToRelocate$, node["s-sn"])) {
1131
- relocateNodeData = relocateNodes.find((r) => r.$nodeToRelocate$ === node);
1132
- if (relocateNodeData && !relocateNode.$slotRefNode$) {
1133
- relocateNode.$slotRefNode$ = relocateNodeData.$slotRefNode$;
1134
- }
1135
- }
1136
- });
1137
- }
1138
- } else if (!relocateNodes.some((r) => r.$nodeToRelocate$ === node)) {
1139
- relocateNodes.push({
1140
- $nodeToRelocate$: node
1141
- });
1142
- }
1143
- }
1144
- }
1145
- }
1146
- if (childNode.nodeType === 1 /* ElementNode */) {
1147
- markSlotContentForRelocation(childNode);
1148
- }
1149
- }
1150
- };
1151
- var nullifyVNodeRefs = (vNode) => {
1152
- if (BUILD11.vdomRef) {
1153
- vNode.$attrs$ && vNode.$attrs$.ref && vNode.$attrs$.ref(null);
1154
- vNode.$children$ && vNode.$children$.map(nullifyVNodeRefs);
1070
+ var validateInputProperties = (inputElm) => {
1071
+ const props = Object.keys(inputElm);
1072
+ const value = props.indexOf("value");
1073
+ if (value === -1) {
1074
+ return;
1155
1075
  }
1156
- };
1157
- var insertBefore = (parent, newNode, reference) => {
1158
- if (BUILD11.scoped && typeof newNode["s-sn"] === "string" && !!newNode["s-sr"] && !!newNode["s-cr"]) {
1159
- addRemoveSlotScopedClass(newNode["s-cr"], newNode, parent, newNode.parentElement);
1076
+ const typeIndex = props.indexOf("type");
1077
+ const minIndex = props.indexOf("min");
1078
+ const maxIndex = props.indexOf("max");
1079
+ const stepIndex = props.indexOf("step");
1080
+ if (value < typeIndex || value < minIndex || value < maxIndex || value < stepIndex) {
1081
+ consoleDevWarn(`The "value" prop of <input> should be set after "min", "max", "type" and "step"`);
1160
1082
  }
1161
- const inserted = parent == null ? void 0 : parent.insertBefore(newNode, reference);
1162
- return inserted;
1163
1083
  };
1164
- function addRemoveSlotScopedClass(reference, slotNode, newParent, oldParent) {
1165
- var _a;
1084
+
1085
+ // src/runtime/client-hydrate.ts
1086
+ var initializeClientHydrate = (hostElm, tagName, hostId, hostRef) => {
1087
+ const endHydrate = createTime("hydrateClient", tagName);
1088
+ const shadowRoot = hostElm.shadowRoot;
1089
+ const childRenderNodes = [];
1090
+ const slotNodes = [];
1091
+ const slottedNodes = [];
1092
+ const shadowRootNodes = BUILD12.shadowDom && shadowRoot ? [] : null;
1093
+ const vnode = newVNode(tagName, null);
1094
+ vnode.$elm$ = hostElm;
1166
1095
  let scopeId2;
1167
- if (reference && typeof slotNode["s-sn"] === "string" && !!slotNode["s-sr"] && reference.parentNode && reference.parentNode["s-sc"] && (scopeId2 = slotNode["s-si"] || reference.parentNode["s-sc"])) {
1168
- const scopeName = slotNode["s-sn"];
1169
- const hostName = slotNode["s-hn"];
1170
- (_a = newParent.classList) == null ? void 0 : _a.add(scopeId2 + "-s");
1171
- if (oldParent && oldParent.classList.contains(scopeId2 + "-s")) {
1172
- let child = (oldParent.__childNodes || oldParent.childNodes)[0];
1173
- let found = false;
1174
- while (child) {
1175
- if (child["s-sn"] !== scopeName && child["s-hn"] === hostName && !!child["s-sr"]) {
1176
- found = true;
1177
- break;
1178
- }
1179
- child = child.nextSibling;
1180
- }
1181
- if (!found) oldParent.classList.remove(scopeId2 + "-s");
1096
+ if (BUILD12.scoped) {
1097
+ const cmpMeta = hostRef.$cmpMeta$;
1098
+ if (cmpMeta && cmpMeta.$flags$ & 10 /* needsScopedEncapsulation */ && hostElm["s-sc"]) {
1099
+ scopeId2 = hostElm["s-sc"];
1100
+ hostElm.classList.add(scopeId2 + "-h");
1101
+ } else if (hostElm["s-sc"]) {
1102
+ delete hostElm["s-sc"];
1182
1103
  }
1183
1104
  }
1184
- }
1185
- var renderVdom = (hostRef, renderFnResults, isInitialLoad = false) => {
1186
- var _a, _b, _c, _d, _e;
1187
- const hostElm = hostRef.$hostElement$;
1188
- const cmpMeta = hostRef.$cmpMeta$;
1189
- const oldVNode = hostRef.$vnode$ || newVNode(null, null);
1190
- const rootVnode = isHost(renderFnResults) ? renderFnResults : h(null, null, renderFnResults);
1191
- hostTagName = hostElm.tagName;
1192
- if (BUILD11.isDev && Array.isArray(renderFnResults) && renderFnResults.some(isHost)) {
1193
- throw new Error(`The <Host> must be the single root component.
1194
- Looks like the render() function of "${hostTagName.toLowerCase()}" is returning an array that contains the <Host>.
1195
-
1196
- The render() function should look like this instead:
1197
-
1198
- render() {
1199
- // Do not return an array
1200
- return (
1201
- <Host>{content}</Host>
1202
- );
1203
- }
1204
- `);
1205
- }
1206
- if (BUILD11.reflect && cmpMeta.$attrsToReflect$) {
1207
- rootVnode.$attrs$ = rootVnode.$attrs$ || {};
1208
- cmpMeta.$attrsToReflect$.map(
1209
- ([propName, attribute]) => rootVnode.$attrs$[attribute] = hostElm[propName]
1210
- );
1105
+ if (!plt.$orgLocNodes$) {
1106
+ initializeDocumentHydrate(doc.body, plt.$orgLocNodes$ = /* @__PURE__ */ new Map());
1211
1107
  }
1212
- if (isInitialLoad && rootVnode.$attrs$) {
1213
- for (const key of Object.keys(rootVnode.$attrs$)) {
1214
- if (hostElm.hasAttribute(key) && !["key", "ref", "style", "class"].includes(key)) {
1215
- rootVnode.$attrs$[key] = hostElm[key];
1108
+ hostElm[HYDRATE_ID] = hostId;
1109
+ hostElm.removeAttribute(HYDRATE_ID);
1110
+ hostRef.$vnode$ = clientHydrate(
1111
+ vnode,
1112
+ childRenderNodes,
1113
+ slotNodes,
1114
+ shadowRootNodes,
1115
+ hostElm,
1116
+ hostElm,
1117
+ hostId,
1118
+ slottedNodes
1119
+ );
1120
+ let crIndex = 0;
1121
+ const crLength = childRenderNodes.length;
1122
+ let childRenderNode;
1123
+ for (crIndex; crIndex < crLength; crIndex++) {
1124
+ childRenderNode = childRenderNodes[crIndex];
1125
+ const orgLocationId = childRenderNode.$hostId$ + "." + childRenderNode.$nodeId$;
1126
+ const orgLocationNode = plt.$orgLocNodes$.get(orgLocationId);
1127
+ const node = childRenderNode.$elm$;
1128
+ if (!shadowRoot) {
1129
+ node["s-hn"] = tagName.toUpperCase();
1130
+ if (childRenderNode.$tag$ === "slot") {
1131
+ node["s-cr"] = hostElm["s-cr"];
1216
1132
  }
1217
1133
  }
1218
- }
1219
- rootVnode.$tag$ = null;
1220
- rootVnode.$flags$ |= 4 /* isHost */;
1221
- hostRef.$vnode$ = rootVnode;
1222
- rootVnode.$elm$ = oldVNode.$elm$ = BUILD11.shadowDom ? hostElm.shadowRoot || hostElm : hostElm;
1223
- if (BUILD11.scoped || BUILD11.shadowDom) {
1224
- scopeId = hostElm["s-sc"];
1225
- }
1226
- useNativeShadowDom = supportsShadow && (cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) !== 0;
1227
- if (BUILD11.slotRelocation) {
1228
- contentRef = hostElm["s-cr"];
1229
- checkSlotFallbackVisibility = false;
1230
- }
1231
- patch(oldVNode, rootVnode, isInitialLoad);
1232
- if (BUILD11.slotRelocation) {
1233
- plt.$flags$ |= 1 /* isTmpDisconnected */;
1234
- if (checkSlotRelocate) {
1235
- markSlotContentForRelocation(rootVnode.$elm$);
1236
- for (const relocateData of relocateNodes) {
1237
- const nodeToRelocate = relocateData.$nodeToRelocate$;
1238
- if (!nodeToRelocate["s-ol"]) {
1239
- const orgLocationNode = BUILD11.isDebug || BUILD11.hydrateServerSide ? originalLocationDebugNode(nodeToRelocate) : doc.createTextNode("");
1240
- orgLocationNode["s-nr"] = nodeToRelocate;
1241
- insertBefore(nodeToRelocate.parentNode, nodeToRelocate["s-ol"] = orgLocationNode, nodeToRelocate);
1242
- }
1243
- }
1244
- for (const relocateData of relocateNodes) {
1245
- const nodeToRelocate = relocateData.$nodeToRelocate$;
1246
- const slotRefNode = relocateData.$slotRefNode$;
1247
- if (slotRefNode) {
1248
- const parentNodeRef = slotRefNode.parentNode;
1249
- let insertBeforeNode = slotRefNode.nextSibling;
1250
- if (!BUILD11.hydrateServerSide && (!BUILD11.experimentalSlotFixes || insertBeforeNode && insertBeforeNode.nodeType === 1 /* ElementNode */)) {
1251
- let orgLocationNode = (_a = nodeToRelocate["s-ol"]) == null ? void 0 : _a.previousSibling;
1252
- while (orgLocationNode) {
1253
- let refNode = (_b = orgLocationNode["s-nr"]) != null ? _b : null;
1254
- if (refNode && refNode["s-sn"] === nodeToRelocate["s-sn"] && parentNodeRef === refNode.parentNode) {
1255
- refNode = refNode.nextSibling;
1256
- while (refNode === nodeToRelocate || (refNode == null ? void 0 : refNode["s-sr"])) {
1257
- refNode = refNode == null ? void 0 : refNode.nextSibling;
1258
- }
1259
- if (!refNode || !refNode["s-nr"]) {
1260
- insertBeforeNode = refNode;
1261
- break;
1262
- }
1263
- }
1264
- orgLocationNode = orgLocationNode.previousSibling;
1265
- }
1266
- }
1267
- if (!insertBeforeNode && parentNodeRef !== nodeToRelocate.parentNode || nodeToRelocate.nextSibling !== insertBeforeNode) {
1268
- if (nodeToRelocate !== insertBeforeNode) {
1269
- if (!BUILD11.experimentalSlotFixes && !nodeToRelocate["s-hn"] && nodeToRelocate["s-ol"]) {
1270
- nodeToRelocate["s-hn"] = nodeToRelocate["s-ol"].parentNode.nodeName;
1271
- }
1272
- insertBefore(parentNodeRef, nodeToRelocate, insertBeforeNode);
1273
- if (nodeToRelocate.nodeType === 1 /* ElementNode */ && nodeToRelocate.tagName !== "SLOT-FB") {
1274
- nodeToRelocate.hidden = (_c = nodeToRelocate["s-ih"]) != null ? _c : false;
1275
- }
1276
- }
1277
- }
1278
- nodeToRelocate && typeof slotRefNode["s-rf"] === "function" && slotRefNode["s-rf"](nodeToRelocate);
1279
- } else {
1280
- if (nodeToRelocate.nodeType === 1 /* ElementNode */) {
1281
- if (isInitialLoad) {
1282
- nodeToRelocate["s-ih"] = (_d = nodeToRelocate.hidden) != null ? _d : false;
1283
- }
1284
- nodeToRelocate.hidden = true;
1285
- }
1134
+ if (childRenderNode.$tag$ === "slot") {
1135
+ childRenderNode.$name$ = childRenderNode.$elm$["s-sn"] || childRenderNode.$elm$["name"] || null;
1136
+ if (childRenderNode.$children$) {
1137
+ childRenderNode.$flags$ |= 2 /* isSlotFallback */;
1138
+ if (!childRenderNode.$elm$.childNodes.length) {
1139
+ childRenderNode.$children$.forEach((c) => {
1140
+ childRenderNode.$elm$.appendChild(c.$elm$);
1141
+ });
1286
1142
  }
1143
+ } else {
1144
+ childRenderNode.$flags$ |= 1 /* isSlotReference */;
1287
1145
  }
1288
1146
  }
1289
- if (checkSlotFallbackVisibility) {
1290
- updateFallbackSlotVisibility(rootVnode.$elm$);
1291
- }
1292
- plt.$flags$ &= ~1 /* isTmpDisconnected */;
1293
- relocateNodes.length = 0;
1294
- }
1295
- if (BUILD11.experimentalScopedSlotChanges && cmpMeta.$flags$ & 2 /* scopedCssEncapsulation */) {
1296
- const children = rootVnode.$elm$.__childNodes || rootVnode.$elm$.childNodes;
1297
- for (const childNode of children) {
1298
- if (childNode["s-hn"] !== hostTagName && !childNode["s-sh"]) {
1299
- if (isInitialLoad && childNode["s-ih"] == null) {
1300
- childNode["s-ih"] = (_e = childNode.hidden) != null ? _e : false;
1301
- }
1302
- childNode.hidden = true;
1147
+ if (orgLocationNode && orgLocationNode.isConnected) {
1148
+ if (shadowRoot && orgLocationNode["s-en"] === "") {
1149
+ orgLocationNode.parentNode.insertBefore(node, orgLocationNode.nextSibling);
1150
+ }
1151
+ orgLocationNode.parentNode.removeChild(orgLocationNode);
1152
+ if (!shadowRoot) {
1153
+ node["s-oo"] = parseInt(childRenderNode.$nodeId$);
1303
1154
  }
1304
1155
  }
1156
+ plt.$orgLocNodes$.delete(orgLocationId);
1305
1157
  }
1306
- contentRef = void 0;
1307
- };
1308
- var slotReferenceDebugNode = (slotVNode) => doc.createComment(
1309
- `<slot${slotVNode.$name$ ? ' name="' + slotVNode.$name$ + '"' : ""}> (host=${hostTagName.toLowerCase()})`
1310
- );
1311
- var originalLocationDebugNode = (nodeToRelocate) => doc.createComment(
1312
- `org-location for ` + (nodeToRelocate.localName ? `<${nodeToRelocate.localName}> (host=${nodeToRelocate["s-hn"]})` : `[${nodeToRelocate.textContent}]`)
1313
- );
1314
-
1315
- // src/runtime/dom-extras.ts
1316
- var patchPseudoShadowDom = (hostElementPrototype) => {
1317
- patchCloneNode(hostElementPrototype);
1318
- patchSlotAppendChild(hostElementPrototype);
1319
- patchSlotAppend(hostElementPrototype);
1320
- patchSlotPrepend(hostElementPrototype);
1321
- patchSlotInsertAdjacentElement(hostElementPrototype);
1322
- patchSlotInsertAdjacentHTML(hostElementPrototype);
1323
- patchSlotInsertAdjacentText(hostElementPrototype);
1324
- patchTextContent(hostElementPrototype);
1325
- patchChildSlotNodes(hostElementPrototype);
1326
- patchSlotRemoveChild(hostElementPrototype);
1327
- };
1328
- var patchCloneNode = (HostElementPrototype) => {
1329
- const orgCloneNode = HostElementPrototype.cloneNode;
1330
- HostElementPrototype.cloneNode = function(deep) {
1331
- const srcNode = this;
1332
- const isShadowDom = BUILD12.shadowDom ? srcNode.shadowRoot && supportsShadow : false;
1333
- const clonedNode = orgCloneNode.call(srcNode, isShadowDom ? deep : false);
1334
- if (BUILD12.slot && !isShadowDom && deep) {
1335
- let i2 = 0;
1336
- let slotted, nonRindoNode;
1337
- const rindoPrivates = [
1338
- "s-id",
1339
- "s-cr",
1340
- "s-lr",
1341
- "s-rc",
1342
- "s-sc",
1343
- "s-p",
1344
- "s-cn",
1345
- "s-sr",
1346
- "s-sn",
1347
- "s-hn",
1348
- "s-ol",
1349
- "s-nr",
1350
- "s-si",
1351
- "s-rf",
1352
- "s-scs"
1353
- ];
1354
- const childNodes = this.__childNodes || this.childNodes;
1355
- for (; i2 < childNodes.length; i2++) {
1356
- slotted = childNodes[i2]["s-nr"];
1357
- nonRindoNode = rindoPrivates.every((privateField) => !childNodes[i2][privateField]);
1358
- if (slotted) {
1359
- if (BUILD12.appendChildSlotFix && clonedNode.__appendChild) {
1360
- clonedNode.__appendChild(slotted.cloneNode(true));
1361
- } else {
1362
- clonedNode.appendChild(slotted.cloneNode(true));
1363
- }
1158
+ const hosts = [];
1159
+ const snLen = slottedNodes.length;
1160
+ let snIndex = 0;
1161
+ let slotGroup;
1162
+ let snGroupIdx;
1163
+ let snGroupLen;
1164
+ let slottedItem;
1165
+ for (snIndex; snIndex < snLen; snIndex++) {
1166
+ slotGroup = slottedNodes[snIndex];
1167
+ if (!slotGroup || !slotGroup.length) continue;
1168
+ snGroupLen = slotGroup.length;
1169
+ snGroupIdx = 0;
1170
+ for (snGroupIdx; snGroupIdx < snGroupLen; snGroupIdx++) {
1171
+ slottedItem = slotGroup[snGroupIdx];
1172
+ if (!hosts[slottedItem.hostId]) {
1173
+ hosts[slottedItem.hostId] = plt.$orgLocNodes$.get(slottedItem.hostId);
1174
+ }
1175
+ if (!hosts[slottedItem.hostId]) continue;
1176
+ const hostEle = hosts[slottedItem.hostId];
1177
+ if (!hostEle.shadowRoot || !shadowRoot) {
1178
+ slottedItem.slot["s-cr"] = hostEle["s-cr"];
1179
+ if (!slottedItem.slot["s-cr"] && hostEle.shadowRoot) {
1180
+ slottedItem.slot["s-cr"] = hostEle;
1181
+ } else {
1182
+ slottedItem.slot["s-cr"] = (hostEle.__childNodes || hostEle.childNodes)[0];
1364
1183
  }
1365
- if (nonRindoNode) {
1366
- clonedNode.appendChild(childNodes[i2].cloneNode(true));
1184
+ addSlotRelocateNode(slottedItem.node, slottedItem.slot, false, slottedItem.node["s-oo"]);
1185
+ if (BUILD12.experimentalSlotFixes) {
1186
+ patchSlottedNode(slottedItem.node);
1367
1187
  }
1368
1188
  }
1369
- }
1370
- return clonedNode;
1371
- };
1372
- };
1373
- var patchSlotAppendChild = (HostElementPrototype) => {
1374
- HostElementPrototype.__appendChild = HostElementPrototype.appendChild;
1375
- HostElementPrototype.appendChild = function(newChild) {
1376
- const slotName = newChild["s-sn"] = getSlotName(newChild);
1377
- const slotNode = getHostSlotNodes(this.__childNodes || this.childNodes, this.tagName, slotName)[0];
1378
- if (slotNode) {
1379
- addSlotRelocateNode(newChild, slotNode);
1380
- const slotChildNodes = getHostSlotChildNodes(slotNode, slotName);
1381
- const appendAfter = slotChildNodes[slotChildNodes.length - 1];
1382
- const insertedNode = insertBefore(appendAfter.parentNode, newChild, appendAfter.nextSibling);
1383
- updateFallbackSlotVisibility(this);
1384
- return insertedNode;
1385
- }
1386
- return this.__appendChild(newChild);
1387
- };
1388
- };
1389
- var patchSlotRemoveChild = (ElementPrototype) => {
1390
- ElementPrototype.__removeChild = ElementPrototype.removeChild;
1391
- ElementPrototype.removeChild = function(toRemove) {
1392
- if (toRemove && typeof toRemove["s-sn"] !== "undefined") {
1393
- const childNodes = this.__childNodes || this.childNodes;
1394
- const slotNode = getHostSlotNodes(childNodes, this.tagName, toRemove["s-sn"]);
1395
- if (slotNode && toRemove.isConnected) {
1396
- toRemove.remove();
1397
- updateFallbackSlotVisibility(this);
1398
- return;
1189
+ if (hostEle.shadowRoot && slottedItem.node.parentElement !== hostEle) {
1190
+ hostEle.appendChild(slottedItem.node);
1399
1191
  }
1400
1192
  }
1401
- return this.__removeChild(toRemove);
1402
- };
1403
- };
1404
- var patchSlotPrepend = (HostElementPrototype) => {
1405
- HostElementPrototype.__prepend = HostElementPrototype.prepend;
1406
- HostElementPrototype.prepend = function(...newChildren) {
1407
- newChildren.forEach((newChild) => {
1408
- if (typeof newChild === "string") {
1409
- newChild = this.ownerDocument.createTextNode(newChild);
1410
- }
1411
- const slotName = newChild["s-sn"] = getSlotName(newChild);
1412
- const childNodes = this.__childNodes || this.childNodes;
1413
- const slotNode = getHostSlotNodes(childNodes, this.tagName, slotName)[0];
1414
- if (slotNode) {
1415
- addSlotRelocateNode(newChild, slotNode, true);
1416
- const slotChildNodes = getHostSlotChildNodes(slotNode, slotName);
1417
- const appendAfter = slotChildNodes[0];
1418
- return insertBefore(appendAfter.parentNode, newChild, appendAfter.nextSibling);
1419
- }
1420
- if (newChild.nodeType === 1 && !!newChild.getAttribute("slot")) {
1421
- newChild.hidden = true;
1422
- }
1423
- return HostElementPrototype.__prepend(newChild);
1193
+ }
1194
+ if (BUILD12.scoped && scopeId2 && slotNodes.length) {
1195
+ slotNodes.forEach((slot) => {
1196
+ slot.$elm$.parentElement.classList.add(scopeId2 + "-s");
1424
1197
  });
1425
- };
1198
+ }
1199
+ if (BUILD12.shadowDom && shadowRoot) {
1200
+ let rnIdex = 0;
1201
+ const rnLen = shadowRootNodes.length;
1202
+ for (rnIdex; rnIdex < rnLen; rnIdex++) {
1203
+ shadowRoot.appendChild(shadowRootNodes[rnIdex]);
1204
+ }
1205
+ }
1206
+ hostRef.$hostElement$ = hostElm;
1207
+ endHydrate();
1426
1208
  };
1427
- var patchSlotAppend = (HostElementPrototype) => {
1428
- HostElementPrototype.__append = HostElementPrototype.append;
1429
- HostElementPrototype.append = function(...newChildren) {
1430
- newChildren.forEach((newChild) => {
1431
- if (typeof newChild === "string") {
1432
- newChild = this.ownerDocument.createTextNode(newChild);
1209
+ var clientHydrate = (parentVNode, childRenderNodes, slotNodes, shadowRootNodes, hostElm, node, hostId, slottedNodes = []) => {
1210
+ let childNodeType;
1211
+ let childIdSplt;
1212
+ let childVNode;
1213
+ let i2;
1214
+ const scopeId2 = hostElm["s-sc"];
1215
+ if (node.nodeType === 1 /* ElementNode */) {
1216
+ childNodeType = node.getAttribute(HYDRATE_CHILD_ID);
1217
+ if (childNodeType) {
1218
+ childIdSplt = childNodeType.split(".");
1219
+ if (childIdSplt[0] === hostId || childIdSplt[0] === "0") {
1220
+ childVNode = createSimpleVNode({
1221
+ $flags$: 0,
1222
+ $hostId$: childIdSplt[0],
1223
+ $nodeId$: childIdSplt[1],
1224
+ $depth$: childIdSplt[2],
1225
+ $index$: childIdSplt[3],
1226
+ $tag$: node.tagName.toLowerCase(),
1227
+ $elm$: node,
1228
+ // If we don't add the initial classes to the VNode, the first `vdom-render.ts` patch
1229
+ // won't try to reconcile them. Classes set on the node will be blown away.
1230
+ $attrs$: { class: node.className || "" }
1231
+ });
1232
+ childRenderNodes.push(childVNode);
1233
+ node.removeAttribute(HYDRATE_CHILD_ID);
1234
+ if (!parentVNode.$children$) {
1235
+ parentVNode.$children$ = [];
1236
+ }
1237
+ if (BUILD12.scoped && scopeId2) {
1238
+ node["s-si"] = scopeId2;
1239
+ childVNode.$attrs$.class += " " + scopeId2;
1240
+ }
1241
+ const slotName = childVNode.$elm$.getAttribute("s-sn");
1242
+ if (typeof slotName === "string") {
1243
+ if (childVNode.$tag$ === "slot-fb") {
1244
+ addSlot(
1245
+ slotName,
1246
+ childIdSplt[2],
1247
+ childVNode,
1248
+ node,
1249
+ parentVNode,
1250
+ childRenderNodes,
1251
+ slotNodes,
1252
+ shadowRootNodes,
1253
+ slottedNodes
1254
+ );
1255
+ if (BUILD12.scoped && scopeId2) {
1256
+ node.classList.add(scopeId2);
1257
+ }
1258
+ }
1259
+ childVNode.$elm$["s-sn"] = slotName;
1260
+ childVNode.$elm$.removeAttribute("s-sn");
1261
+ }
1262
+ if (childVNode.$index$ !== void 0) {
1263
+ parentVNode.$children$[childVNode.$index$] = childVNode;
1264
+ }
1265
+ parentVNode = childVNode;
1266
+ if (shadowRootNodes && childVNode.$depth$ === "0") {
1267
+ shadowRootNodes[childVNode.$index$] = childVNode.$elm$;
1268
+ }
1433
1269
  }
1434
- this.appendChild(newChild);
1435
- });
1436
- };
1437
- };
1438
- var patchSlotInsertAdjacentHTML = (HostElementPrototype) => {
1439
- const originalInsertAdjacentHtml = HostElementPrototype.insertAdjacentHTML;
1440
- HostElementPrototype.insertAdjacentHTML = function(position, text) {
1441
- if (position !== "afterbegin" && position !== "beforeend") {
1442
- return originalInsertAdjacentHtml.call(this, position, text);
1443
1270
  }
1444
- const container = this.ownerDocument.createElement("_");
1445
- let node;
1446
- container.innerHTML = text;
1447
- if (position === "afterbegin") {
1448
- while (node = container.firstChild) {
1449
- this.prepend(node);
1450
- }
1451
- } else if (position === "beforeend") {
1452
- while (node = container.firstChild) {
1453
- this.append(node);
1271
+ if (node.shadowRoot) {
1272
+ for (i2 = node.shadowRoot.childNodes.length - 1; i2 >= 0; i2--) {
1273
+ clientHydrate(
1274
+ parentVNode,
1275
+ childRenderNodes,
1276
+ slotNodes,
1277
+ shadowRootNodes,
1278
+ hostElm,
1279
+ node.shadowRoot.childNodes[i2],
1280
+ hostId,
1281
+ slottedNodes
1282
+ );
1454
1283
  }
1455
1284
  }
1456
- };
1457
- };
1458
- var patchSlotInsertAdjacentText = (HostElementPrototype) => {
1459
- HostElementPrototype.insertAdjacentText = function(position, text) {
1460
- this.insertAdjacentHTML(position, text);
1461
- };
1462
- };
1463
- var patchSlotInsertAdjacentElement = (HostElementPrototype) => {
1464
- const originalInsertAdjacentElement = HostElementPrototype.insertAdjacentElement;
1465
- HostElementPrototype.insertAdjacentElement = function(position, element) {
1466
- if (position !== "afterbegin" && position !== "beforeend") {
1467
- return originalInsertAdjacentElement.call(this, position, element);
1468
- }
1469
- if (position === "afterbegin") {
1470
- this.prepend(element);
1471
- return element;
1472
- } else if (position === "beforeend") {
1473
- this.append(element);
1474
- return element;
1285
+ const nonShadowNodes = node.__childNodes || node.childNodes;
1286
+ for (i2 = nonShadowNodes.length - 1; i2 >= 0; i2--) {
1287
+ clientHydrate(
1288
+ parentVNode,
1289
+ childRenderNodes,
1290
+ slotNodes,
1291
+ shadowRootNodes,
1292
+ hostElm,
1293
+ nonShadowNodes[i2],
1294
+ hostId,
1295
+ slottedNodes
1296
+ );
1475
1297
  }
1476
- return element;
1477
- };
1478
- };
1479
- var patchTextContent = (hostElementPrototype) => {
1480
- patchHostOriginalAccessor("textContent", hostElementPrototype);
1481
- Object.defineProperty(hostElementPrototype, "textContent", {
1482
- get: function() {
1483
- let text = "";
1484
- const childNodes = this.__childNodes ? this.childNodes : getSlottedChildNodes(this.childNodes);
1485
- childNodes.forEach((node) => text += node.textContent || "");
1486
- return text;
1487
- },
1488
- set: function(value) {
1489
- const childNodes = this.__childNodes ? this.childNodes : getSlottedChildNodes(this.childNodes);
1490
- childNodes.forEach((node) => {
1491
- if (node["s-ol"]) node["s-ol"].remove();
1492
- node.remove();
1298
+ } else if (node.nodeType === 8 /* CommentNode */) {
1299
+ childIdSplt = node.nodeValue.split(".");
1300
+ if (childIdSplt[1] === hostId || childIdSplt[1] === "0") {
1301
+ childNodeType = childIdSplt[0];
1302
+ childVNode = createSimpleVNode({
1303
+ $hostId$: childIdSplt[1],
1304
+ $nodeId$: childIdSplt[2],
1305
+ $depth$: childIdSplt[3],
1306
+ $index$: childIdSplt[4] || "0",
1307
+ $elm$: node,
1308
+ $attrs$: null,
1309
+ $children$: null,
1310
+ $key$: null,
1311
+ $name$: null,
1312
+ $tag$: null,
1313
+ $text$: null
1493
1314
  });
1494
- this.insertAdjacentHTML("beforeend", value);
1315
+ if (childNodeType === TEXT_NODE_ID) {
1316
+ childVNode.$elm$ = node.nextSibling;
1317
+ if (childVNode.$elm$ && childVNode.$elm$.nodeType === 3 /* TextNode */) {
1318
+ childVNode.$text$ = childVNode.$elm$.textContent;
1319
+ childRenderNodes.push(childVNode);
1320
+ node.remove();
1321
+ if (hostId === childVNode.$hostId$) {
1322
+ if (!parentVNode.$children$) {
1323
+ parentVNode.$children$ = [];
1324
+ }
1325
+ parentVNode.$children$[childVNode.$index$] = childVNode;
1326
+ }
1327
+ if (shadowRootNodes && childVNode.$depth$ === "0") {
1328
+ shadowRootNodes[childVNode.$index$] = childVNode.$elm$;
1329
+ }
1330
+ }
1331
+ } else if (childNodeType === COMMENT_NODE_ID) {
1332
+ childVNode.$elm$ = node.nextSibling;
1333
+ if (childVNode.$elm$ && childVNode.$elm$.nodeType === 8 /* CommentNode */) {
1334
+ childRenderNodes.push(childVNode);
1335
+ node.remove();
1336
+ }
1337
+ } else if (childVNode.$hostId$ === hostId) {
1338
+ if (childNodeType === SLOT_NODE_ID) {
1339
+ const slotName = node["s-sn"] = childIdSplt[5] || "";
1340
+ addSlot(
1341
+ slotName,
1342
+ childIdSplt[2],
1343
+ childVNode,
1344
+ node,
1345
+ parentVNode,
1346
+ childRenderNodes,
1347
+ slotNodes,
1348
+ shadowRootNodes,
1349
+ slottedNodes
1350
+ );
1351
+ } else if (childNodeType === CONTENT_REF_ID) {
1352
+ if (BUILD12.shadowDom && shadowRootNodes) {
1353
+ node.remove();
1354
+ } else if (BUILD12.slotRelocation) {
1355
+ hostElm["s-cr"] = node;
1356
+ node["s-cn"] = true;
1357
+ }
1358
+ }
1359
+ }
1495
1360
  }
1496
- });
1361
+ } else if (parentVNode && parentVNode.$tag$ === "style") {
1362
+ const vnode = newVNode(null, node.textContent);
1363
+ vnode.$elm$ = node;
1364
+ vnode.$index$ = "0";
1365
+ parentVNode.$children$ = [vnode];
1366
+ }
1367
+ return parentVNode;
1497
1368
  };
1498
- var patchChildSlotNodes = (elm) => {
1499
- class FakeNodeList extends Array {
1500
- item(n) {
1501
- return this[n];
1369
+ var initializeDocumentHydrate = (node, orgLocNodes) => {
1370
+ if (node.nodeType === 1 /* ElementNode */) {
1371
+ const componentId = node[HYDRATE_ID] || node.getAttribute(HYDRATE_ID);
1372
+ if (componentId) {
1373
+ orgLocNodes.set(componentId, node);
1502
1374
  }
1503
- }
1504
- patchHostOriginalAccessor("children", elm);
1505
- Object.defineProperty(elm, "children", {
1506
- get() {
1507
- return this.childNodes.filter((n) => n.nodeType === 1);
1375
+ let i2 = 0;
1376
+ if (node.shadowRoot) {
1377
+ for (; i2 < node.shadowRoot.childNodes.length; i2++) {
1378
+ initializeDocumentHydrate(node.shadowRoot.childNodes[i2], orgLocNodes);
1379
+ }
1508
1380
  }
1509
- });
1510
- Object.defineProperty(elm, "childElementCount", {
1511
- get() {
1512
- return this.children.length;
1381
+ const nonShadowNodes = node.__childNodes || node.childNodes;
1382
+ for (i2 = 0; i2 < nonShadowNodes.length; i2++) {
1383
+ initializeDocumentHydrate(nonShadowNodes[i2], orgLocNodes);
1513
1384
  }
1514
- });
1515
- patchHostOriginalAccessor("firstChild", elm);
1516
- Object.defineProperty(elm, "firstChild", {
1517
- get() {
1518
- return this.childNodes[0];
1385
+ } else if (node.nodeType === 8 /* CommentNode */) {
1386
+ const childIdSplt = node.nodeValue.split(".");
1387
+ if (childIdSplt[0] === ORG_LOCATION_ID) {
1388
+ orgLocNodes.set(childIdSplt[1] + "." + childIdSplt[2], node);
1389
+ node.nodeValue = "";
1390
+ node["s-en"] = childIdSplt[3];
1519
1391
  }
1520
- });
1521
- patchHostOriginalAccessor("lastChild", elm);
1522
- Object.defineProperty(elm, "lastChild", {
1523
- get() {
1524
- return this.childNodes[this.childNodes.length - 1];
1392
+ }
1393
+ };
1394
+ var createSimpleVNode = (vnode) => {
1395
+ const defaultVNode = {
1396
+ $flags$: 0,
1397
+ $hostId$: null,
1398
+ $nodeId$: null,
1399
+ $depth$: null,
1400
+ $index$: "0",
1401
+ $elm$: null,
1402
+ $attrs$: null,
1403
+ $children$: null,
1404
+ $key$: null,
1405
+ $name$: null,
1406
+ $tag$: null,
1407
+ $text$: null
1408
+ };
1409
+ return { ...defaultVNode, ...vnode };
1410
+ };
1411
+ function addSlot(slotName, slotId, childVNode, node, parentVNode, childRenderNodes, slotNodes, shadowRootNodes, slottedNodes) {
1412
+ node["s-sr"] = true;
1413
+ childVNode.$name$ = slotName || null;
1414
+ childVNode.$tag$ = "slot";
1415
+ const parentNodeId = (parentVNode == null ? void 0 : parentVNode.$elm$) ? parentVNode.$elm$["s-id"] || parentVNode.$elm$.getAttribute("s-id") : "";
1416
+ if (BUILD12.shadowDom && shadowRootNodes) {
1417
+ const slot = childVNode.$elm$ = doc.createElement(childVNode.$tag$);
1418
+ if (childVNode.$name$) {
1419
+ childVNode.$elm$.setAttribute("name", slotName);
1525
1420
  }
1526
- });
1527
- patchHostOriginalAccessor("childNodes", elm);
1528
- Object.defineProperty(elm, "childNodes", {
1529
- get() {
1530
- var _a, _b;
1531
- 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 */) {
1532
- const result = new FakeNodeList();
1533
- const nodes = getSlottedChildNodes(this.__childNodes);
1534
- result.push(...nodes);
1535
- return result;
1536
- }
1537
- return FakeNodeList.from(this.__childNodes);
1421
+ if (parentNodeId && parentNodeId !== childVNode.$hostId$) {
1422
+ parentVNode.$elm$.insertBefore(slot, parentVNode.$elm$.children[0]);
1423
+ } else {
1424
+ node.parentNode.insertBefore(childVNode.$elm$, node);
1538
1425
  }
1539
- });
1540
- };
1541
- var patchNextPrev = (node) => {
1542
- if (!node || node.__nextSibling || !globalThis.Node) return;
1543
- patchNextSibling(node);
1544
- patchPreviousSibling(node);
1545
- if (node.nodeType === Node.ELEMENT_NODE) {
1546
- patchNextElementSibling(node);
1547
- patchPreviousElementSibling(node);
1426
+ addSlottedNodes(slottedNodes, slotId, slotName, node, childVNode.$hostId$);
1427
+ node.remove();
1428
+ if (childVNode.$depth$ === "0") {
1429
+ shadowRootNodes[childVNode.$index$] = childVNode.$elm$;
1430
+ }
1431
+ } else {
1432
+ const slot = childVNode.$elm$;
1433
+ const shouldMove = parentNodeId && parentNodeId !== childVNode.$hostId$ && parentVNode.$elm$.shadowRoot;
1434
+ addSlottedNodes(slottedNodes, slotId, slotName, node, shouldMove ? parentNodeId : childVNode.$hostId$);
1435
+ if (shouldMove) {
1436
+ parentVNode.$elm$.insertBefore(slot, parentVNode.$elm$.children[0]);
1437
+ }
1438
+ childRenderNodes.push(childVNode);
1439
+ }
1440
+ slotNodes.push(childVNode);
1441
+ if (!parentVNode.$children$) {
1442
+ parentVNode.$children$ = [];
1443
+ }
1444
+ parentVNode.$children$[childVNode.$index$] = childVNode;
1445
+ }
1446
+ var addSlottedNodes = (slottedNodes, slotNodeId, slotName, slotNode, hostId) => {
1447
+ let slottedNode = slotNode.nextSibling;
1448
+ slottedNodes[slotNodeId] = slottedNodes[slotNodeId] || [];
1449
+ 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 */))) {
1450
+ slottedNode["s-sn"] = slotName;
1451
+ slottedNodes[slotNodeId].push({ slot: slotNode, node: slottedNode, hostId });
1452
+ slottedNode = slottedNode.nextSibling;
1548
1453
  }
1549
1454
  };
1550
- var patchNextSibling = (node) => {
1551
- if (!node || node.__nextSibling) return;
1552
- patchHostOriginalAccessor("nextSibling", node);
1553
- Object.defineProperty(node, "nextSibling", {
1554
- get: function() {
1555
- var _a;
1556
- const parentNodes = (_a = this["s-ol"]) == null ? void 0 : _a.parentNode.childNodes;
1557
- const index = parentNodes == null ? void 0 : parentNodes.indexOf(this);
1558
- if (parentNodes && index > -1) {
1559
- return parentNodes[index + 1];
1560
- }
1561
- return this.__nextSibling;
1455
+
1456
+ // src/runtime/initialize-component.ts
1457
+ import { BUILD as BUILD23 } from "@rindo/core/internal/app-data";
1458
+
1459
+ // src/runtime/mode.ts
1460
+ var computeMode = (elm) => modeResolutionChain.map((h2) => h2(elm)).find((m) => !!m);
1461
+ var setMode = (handler) => modeResolutionChain.push(handler);
1462
+ var getMode = (ref) => getHostRef(ref).$modeName$;
1463
+
1464
+ // src/runtime/proxy-component.ts
1465
+ import { BUILD as BUILD22 } from "@rindo/core/internal/app-data";
1466
+
1467
+ // src/runtime/set-value.ts
1468
+ import { BUILD as BUILD21 } from "@rindo/core/internal/app-data";
1469
+
1470
+ // src/runtime/parse-property-value.ts
1471
+ import { BUILD as BUILD13 } from "@rindo/core/internal/app-data";
1472
+ var parsePropertyValue = (propValue, propType) => {
1473
+ if (propValue != null && !isComplexType(propValue)) {
1474
+ if (BUILD13.propBoolean && propType & 4 /* Boolean */) {
1475
+ return propValue === "false" ? false : propValue === "" || !!propValue;
1562
1476
  }
1563
- });
1564
- };
1565
- var patchNextElementSibling = (element) => {
1566
- if (!element || element.__nextElementSibling) return;
1567
- patchHostOriginalAccessor("nextElementSibling", element);
1568
- Object.defineProperty(element, "nextElementSibling", {
1569
- get: function() {
1570
- var _a;
1571
- const parentEles = (_a = this["s-ol"]) == null ? void 0 : _a.parentNode.children;
1572
- const index = parentEles == null ? void 0 : parentEles.indexOf(this);
1573
- if (parentEles && index > -1) {
1574
- return parentEles[index + 1];
1575
- }
1576
- return this.__nextElementSibling;
1477
+ if (BUILD13.propNumber && propType & 2 /* Number */) {
1478
+ return parseFloat(propValue);
1577
1479
  }
1578
- });
1579
- };
1580
- var patchPreviousSibling = (node) => {
1581
- if (!node || node.__previousSibling) return;
1582
- patchHostOriginalAccessor("previousSibling", node);
1583
- Object.defineProperty(node, "previousSibling", {
1584
- get: function() {
1585
- var _a;
1586
- const parentNodes = (_a = this["s-ol"]) == null ? void 0 : _a.parentNode.childNodes;
1587
- const index = parentNodes == null ? void 0 : parentNodes.indexOf(this);
1588
- if (parentNodes && index > -1) {
1589
- return parentNodes[index - 1];
1590
- }
1591
- return this.__previousSibling;
1480
+ if (BUILD13.propString && propType & 1 /* String */) {
1481
+ return String(propValue);
1592
1482
  }
1593
- });
1483
+ return propValue;
1484
+ }
1485
+ return propValue;
1594
1486
  };
1595
- var patchPreviousElementSibling = (element) => {
1596
- if (!element || element.__previousElementSibling) return;
1597
- patchHostOriginalAccessor("previousElementSibling", element);
1598
- Object.defineProperty(element, "previousElementSibling", {
1599
- get: function() {
1600
- var _a;
1601
- const parentNodes = (_a = this["s-ol"]) == null ? void 0 : _a.parentNode.children;
1602
- const index = parentNodes == null ? void 0 : parentNodes.indexOf(this);
1603
- if (parentNodes && index > -1) {
1604
- return parentNodes[index - 1];
1487
+
1488
+ // src/runtime/update-component.ts
1489
+ import { BUILD as BUILD20, NAMESPACE } from "@rindo/core/internal/app-data";
1490
+
1491
+ // src/runtime/event-emitter.ts
1492
+ import { BUILD as BUILD15 } from "@rindo/core/internal/app-data";
1493
+
1494
+ // src/runtime/element.ts
1495
+ import { BUILD as BUILD14 } from "@rindo/core/internal/app-data";
1496
+ var getElement = (ref) => BUILD14.lazyLoad ? getHostRef(ref).$hostElement$ : ref;
1497
+
1498
+ // src/runtime/event-emitter.ts
1499
+ var createEvent = (ref, name, flags) => {
1500
+ const elm = getElement(ref);
1501
+ return {
1502
+ emit: (detail) => {
1503
+ if (BUILD15.isDev && !elm.isConnected) {
1504
+ consoleDevWarn(`The "${name}" event was emitted, but the dispatcher node is no longer connected to the dom.`);
1605
1505
  }
1606
- return this.__previousElementSibling;
1506
+ return emitEvent(elm, name, {
1507
+ bubbles: !!(flags & 4 /* Bubbles */),
1508
+ composed: !!(flags & 2 /* Composed */),
1509
+ cancelable: !!(flags & 1 /* Cancellable */),
1510
+ detail
1511
+ });
1607
1512
  }
1608
- });
1513
+ };
1514
+ };
1515
+ var emitEvent = (elm, name, opts) => {
1516
+ const ev = plt.ce(name, opts);
1517
+ elm.dispatchEvent(ev);
1518
+ return ev;
1609
1519
  };
1610
- var validElementPatches = ["children", "nextElementSibling", "previousElementSibling"];
1611
- var validNodesPatches = [
1612
- "childNodes",
1613
- "firstChild",
1614
- "lastChild",
1615
- "nextSibling",
1616
- "previousSibling",
1617
- "textContent"
1618
- ];
1619
- function patchHostOriginalAccessor(accessorName, node) {
1620
- let accessor;
1621
- if (validElementPatches.includes(accessorName)) {
1622
- accessor = Object.getOwnPropertyDescriptor(Element.prototype, accessorName);
1623
- } else if (validNodesPatches.includes(accessorName)) {
1624
- accessor = Object.getOwnPropertyDescriptor(Node.prototype, accessorName);
1625
- }
1626
- if (!accessor) {
1627
- accessor = Object.getOwnPropertyDescriptor(node, accessorName);
1628
- }
1629
- if (accessor) Object.defineProperty(node, "__" + accessorName, accessor);
1630
- }
1631
1520
 
1632
- // src/runtime/profile.ts
1633
- import { BUILD as BUILD13 } from "@rindo/core/internal/app-data";
1634
- var i = 0;
1635
- var createTime = (fnName, tagName = "") => {
1636
- if (BUILD13.profile && performance.mark) {
1637
- const key = `st:${fnName}:${tagName}:${i++}`;
1638
- performance.mark(key);
1639
- return () => performance.measure(`[Rindo] ${fnName}() <${tagName}>`, key);
1521
+ // src/runtime/styles.ts
1522
+ import { BUILD as BUILD16 } from "@rindo/core/internal/app-data";
1523
+ var rootAppliedStyles = /* @__PURE__ */ new WeakMap();
1524
+ var registerStyle = (scopeId2, cssText, allowCS) => {
1525
+ let style = styles.get(scopeId2);
1526
+ if (supportsConstructableStylesheets && allowCS) {
1527
+ style = style || new CSSStyleSheet();
1528
+ if (typeof style === "string") {
1529
+ style = cssText;
1530
+ } else {
1531
+ style.replaceSync(cssText);
1532
+ }
1640
1533
  } else {
1641
- return () => {
1642
- return;
1643
- };
1534
+ style = cssText;
1644
1535
  }
1536
+ styles.set(scopeId2, style);
1645
1537
  };
1646
- var uniqueTime = (key, measureText) => {
1647
- if (BUILD13.profile && performance.mark) {
1648
- if (performance.getEntriesByName(key, "mark").length === 0) {
1649
- performance.mark(key);
1538
+ var addStyle = (styleContainerNode, cmpMeta, mode) => {
1539
+ var _a;
1540
+ const scopeId2 = getScopeId(cmpMeta, mode);
1541
+ const style = styles.get(scopeId2);
1542
+ if (!BUILD16.attachStyles) {
1543
+ return scopeId2;
1544
+ }
1545
+ styleContainerNode = styleContainerNode.nodeType === 11 /* DocumentFragment */ ? styleContainerNode : doc;
1546
+ if (style) {
1547
+ if (typeof style === "string") {
1548
+ styleContainerNode = styleContainerNode.head || styleContainerNode;
1549
+ let appliedStyles = rootAppliedStyles.get(styleContainerNode);
1550
+ let styleElm;
1551
+ if (!appliedStyles) {
1552
+ rootAppliedStyles.set(styleContainerNode, appliedStyles = /* @__PURE__ */ new Set());
1553
+ }
1554
+ if (!appliedStyles.has(scopeId2)) {
1555
+ if (BUILD16.hydrateClientSide && styleContainerNode.host && (styleElm = styleContainerNode.querySelector(`[${HYDRATED_STYLE_ID}="${scopeId2}"]`))) {
1556
+ styleElm.innerHTML = style;
1557
+ } else {
1558
+ styleElm = document.querySelector(`[${HYDRATED_STYLE_ID}="${scopeId2}"]`) || doc.createElement("style");
1559
+ styleElm.innerHTML = style;
1560
+ const nonce = (_a = plt.$nonce$) != null ? _a : queryNonceMetaTagContent(doc);
1561
+ if (nonce != null) {
1562
+ styleElm.setAttribute("nonce", nonce);
1563
+ }
1564
+ if ((BUILD16.hydrateServerSide || BUILD16.hotModuleReplacement) && cmpMeta.$flags$ & 2 /* scopedCssEncapsulation */) {
1565
+ styleElm.setAttribute(HYDRATED_STYLE_ID, scopeId2);
1566
+ }
1567
+ if (!(cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */)) {
1568
+ if (styleContainerNode.nodeName === "HEAD") {
1569
+ const preconnectLinks = styleContainerNode.querySelectorAll("link[rel=preconnect]");
1570
+ const referenceNode2 = preconnectLinks.length > 0 ? preconnectLinks[preconnectLinks.length - 1].nextSibling : styleContainerNode.querySelector("style");
1571
+ styleContainerNode.insertBefore(
1572
+ styleElm,
1573
+ (referenceNode2 == null ? void 0 : referenceNode2.parentNode) === styleContainerNode ? referenceNode2 : null
1574
+ );
1575
+ } else if ("host" in styleContainerNode) {
1576
+ if (supportsConstructableStylesheets) {
1577
+ const stylesheet = new CSSStyleSheet();
1578
+ stylesheet.replaceSync(style);
1579
+ styleContainerNode.adoptedStyleSheets = [stylesheet, ...styleContainerNode.adoptedStyleSheets];
1580
+ } else {
1581
+ const existingStyleContainer = styleContainerNode.querySelector("style");
1582
+ if (existingStyleContainer) {
1583
+ existingStyleContainer.innerHTML = style + existingStyleContainer.innerHTML;
1584
+ } else {
1585
+ styleContainerNode.prepend(styleElm);
1586
+ }
1587
+ }
1588
+ } else {
1589
+ styleContainerNode.append(styleElm);
1590
+ }
1591
+ }
1592
+ if (cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */ && styleContainerNode.nodeName !== "HEAD") {
1593
+ styleContainerNode.insertBefore(styleElm, null);
1594
+ }
1595
+ }
1596
+ if (cmpMeta.$flags$ & 4 /* hasSlotRelocation */) {
1597
+ styleElm.innerHTML += SLOT_FB_CSS;
1598
+ }
1599
+ if (appliedStyles) {
1600
+ appliedStyles.add(scopeId2);
1601
+ }
1602
+ }
1603
+ } else if (BUILD16.constructableCSS && !styleContainerNode.adoptedStyleSheets.includes(style)) {
1604
+ styleContainerNode.adoptedStyleSheets = [...styleContainerNode.adoptedStyleSheets, style];
1650
1605
  }
1651
- return () => {
1652
- if (performance.getEntriesByName(measureText, "measure").length === 0) {
1653
- performance.measure(measureText, key);
1606
+ }
1607
+ return scopeId2;
1608
+ };
1609
+ var attachStyles = (hostRef) => {
1610
+ const cmpMeta = hostRef.$cmpMeta$;
1611
+ const elm = hostRef.$hostElement$;
1612
+ const flags = cmpMeta.$flags$;
1613
+ const endAttachStyles = createTime("attachStyles", cmpMeta.$tagName$);
1614
+ const scopeId2 = addStyle(
1615
+ BUILD16.shadowDom && supportsShadow && elm.shadowRoot ? elm.shadowRoot : elm.getRootNode(),
1616
+ cmpMeta,
1617
+ hostRef.$modeName$
1618
+ );
1619
+ if ((BUILD16.shadowDom || BUILD16.scoped) && BUILD16.cssAnnotations && flags & 10 /* needsScopedEncapsulation */ && flags & 2 /* scopedCssEncapsulation */) {
1620
+ elm["s-sc"] = scopeId2;
1621
+ elm.classList.add(scopeId2 + "-h");
1622
+ }
1623
+ endAttachStyles();
1624
+ };
1625
+ var getScopeId = (cmp, mode) => "sc-" + (BUILD16.mode && mode && cmp.$flags$ & 32 /* hasMode */ ? cmp.$tagName$ + "-" + mode : cmp.$tagName$);
1626
+
1627
+ // src/runtime/vdom/vdom-render.ts
1628
+ import { BUILD as BUILD19 } from "@rindo/core/internal/app-data";
1629
+
1630
+ // src/runtime/vdom/update-element.ts
1631
+ import { BUILD as BUILD18 } from "@rindo/core/internal/app-data";
1632
+
1633
+ // src/runtime/vdom/set-accessor.ts
1634
+ import { BUILD as BUILD17 } from "@rindo/core/internal/app-data";
1635
+ var setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags, initialRender) => {
1636
+ if (oldValue !== newValue) {
1637
+ let isProp = isMemberInElement(elm, memberName);
1638
+ let ln = memberName.toLowerCase();
1639
+ if (BUILD17.vdomClass && memberName === "class") {
1640
+ const classList = elm.classList;
1641
+ const oldClasses = parseClassList(oldValue);
1642
+ let newClasses = parseClassList(newValue);
1643
+ if (BUILD17.hydrateClientSide && elm["s-si"] && initialRender) {
1644
+ newClasses.push(elm["s-si"]);
1645
+ oldClasses.forEach((c) => {
1646
+ if (c.startsWith(elm["s-si"])) newClasses.push(c);
1647
+ });
1648
+ newClasses = [...new Set(newClasses)];
1649
+ classList.add(...newClasses);
1650
+ } else {
1651
+ classList.remove(...oldClasses.filter((c) => c && !newClasses.includes(c)));
1652
+ classList.add(...newClasses.filter((c) => c && !oldClasses.includes(c)));
1653
+ }
1654
+ } else if (BUILD17.vdomStyle && memberName === "style") {
1655
+ if (BUILD17.updatable) {
1656
+ for (const prop in oldValue) {
1657
+ if (!newValue || newValue[prop] == null) {
1658
+ if (!BUILD17.hydrateServerSide && prop.includes("-")) {
1659
+ elm.style.removeProperty(prop);
1660
+ } else {
1661
+ elm.style[prop] = "";
1662
+ }
1663
+ }
1664
+ }
1665
+ }
1666
+ for (const prop in newValue) {
1667
+ if (!oldValue || newValue[prop] !== oldValue[prop]) {
1668
+ if (!BUILD17.hydrateServerSide && prop.includes("-")) {
1669
+ elm.style.setProperty(prop, newValue[prop]);
1670
+ } else {
1671
+ elm.style[prop] = newValue[prop];
1672
+ }
1673
+ }
1674
+ }
1675
+ } else if (BUILD17.vdomKey && memberName === "key") {
1676
+ } else if (BUILD17.vdomRef && memberName === "ref") {
1677
+ if (newValue) {
1678
+ newValue(elm);
1679
+ }
1680
+ } else if (BUILD17.vdomListener && (BUILD17.lazyLoad ? !isProp : !elm.__lookupSetter__(memberName)) && memberName[0] === "o" && memberName[1] === "n") {
1681
+ if (memberName[2] === "-") {
1682
+ memberName = memberName.slice(3);
1683
+ } else if (isMemberInElement(win, ln)) {
1684
+ memberName = ln.slice(2);
1685
+ } else {
1686
+ memberName = ln[2] + memberName.slice(3);
1687
+ }
1688
+ if (oldValue || newValue) {
1689
+ const capture = memberName.endsWith(CAPTURE_EVENT_SUFFIX);
1690
+ memberName = memberName.replace(CAPTURE_EVENT_REGEX, "");
1691
+ if (oldValue) {
1692
+ plt.rel(elm, memberName, oldValue, capture);
1693
+ }
1694
+ if (newValue) {
1695
+ plt.ael(elm, memberName, newValue, capture);
1696
+ }
1697
+ }
1698
+ } else if (BUILD17.vdomPropOrAttr) {
1699
+ const isComplex = isComplexType(newValue);
1700
+ if ((isProp || isComplex && newValue !== null) && !isSvg) {
1701
+ try {
1702
+ if (!elm.tagName.includes("-")) {
1703
+ const n = newValue == null ? "" : newValue;
1704
+ if (memberName === "list") {
1705
+ isProp = false;
1706
+ } else if (oldValue == null || elm[memberName] != n) {
1707
+ if (typeof elm.__lookupSetter__(memberName) === "function") {
1708
+ elm[memberName] = n;
1709
+ } else {
1710
+ elm.setAttribute(memberName, n);
1711
+ }
1712
+ }
1713
+ } else if (elm[memberName] !== newValue) {
1714
+ elm[memberName] = newValue;
1715
+ }
1716
+ } catch (e) {
1717
+ }
1718
+ }
1719
+ let xlink = false;
1720
+ if (BUILD17.vdomXlink) {
1721
+ if (ln !== (ln = ln.replace(/^xlink\:?/, ""))) {
1722
+ memberName = ln;
1723
+ xlink = true;
1724
+ }
1654
1725
  }
1655
- };
1656
- } else {
1657
- return () => {
1658
- return;
1659
- };
1726
+ if (newValue == null || newValue === false) {
1727
+ if (newValue !== false || elm.getAttribute(memberName) === "") {
1728
+ if (BUILD17.vdomXlink && xlink) {
1729
+ elm.removeAttributeNS(XLINK_NS, memberName);
1730
+ } else {
1731
+ elm.removeAttribute(memberName);
1732
+ }
1733
+ }
1734
+ } else if ((!isProp || flags & 4 /* isHost */ || isSvg) && !isComplex) {
1735
+ newValue = newValue === true ? "" : newValue;
1736
+ if (BUILD17.vdomXlink && xlink) {
1737
+ elm.setAttributeNS(XLINK_NS, memberName, newValue);
1738
+ } else {
1739
+ elm.setAttribute(memberName, newValue);
1740
+ }
1741
+ }
1742
+ }
1660
1743
  }
1661
1744
  };
1662
- var inspect = (ref) => {
1663
- const hostRef = getHostRef(ref);
1664
- if (!hostRef) {
1665
- return void 0;
1745
+ var parseClassListRegex = /\s/;
1746
+ var parseClassList = (value) => {
1747
+ if (typeof value === "object" && value && "baseVal" in value) {
1748
+ value = value.baseVal;
1666
1749
  }
1667
- const flags = hostRef.$flags$;
1668
- const hostElement = hostRef.$hostElement$;
1669
- return {
1670
- renderCount: hostRef.$renderCount$,
1671
- flags: {
1672
- hasRendered: !!(flags & 2 /* hasRendered */),
1673
- hasConnected: !!(flags & 1 /* hasConnected */),
1674
- isWaitingForChildren: !!(flags & 4 /* isWaitingForChildren */),
1675
- isConstructingInstance: !!(flags & 8 /* isConstructingInstance */),
1676
- isQueuedForUpdate: !!(flags & 16 /* isQueuedForUpdate */),
1677
- hasInitializedComponent: !!(flags & 32 /* hasInitializedComponent */),
1678
- hasLoadedComponent: !!(flags & 64 /* hasLoadedComponent */),
1679
- isWatchReady: !!(flags & 128 /* isWatchReady */),
1680
- isListenReady: !!(flags & 256 /* isListenReady */),
1681
- needsRerender: !!(flags & 512 /* needsRerender */)
1682
- },
1683
- instanceValues: hostRef.$instanceValues$,
1684
- ancestorComponent: hostRef.$ancestorComponent$,
1685
- hostElement,
1686
- lazyInstance: hostRef.$lazyInstance$,
1687
- vnode: hostRef.$vnode$,
1688
- modeName: hostRef.$modeName$,
1689
- onReadyPromise: hostRef.$onReadyPromise$,
1690
- onReadyResolve: hostRef.$onReadyResolve$,
1691
- onInstancePromise: hostRef.$onInstancePromise$,
1692
- onInstanceResolve: hostRef.$onInstanceResolve$,
1693
- onRenderResolve: hostRef.$onRenderResolve$,
1694
- queuedListeners: hostRef.$queuedListeners$,
1695
- rmListeners: hostRef.$rmListeners$,
1696
- ["s-id"]: hostElement["s-id"],
1697
- ["s-cr"]: hostElement["s-cr"],
1698
- ["s-lr"]: hostElement["s-lr"],
1699
- ["s-p"]: hostElement["s-p"],
1700
- ["s-rc"]: hostElement["s-rc"],
1701
- ["s-sc"]: hostElement["s-sc"]
1702
- };
1750
+ if (!value || typeof value !== "string") {
1751
+ return [];
1752
+ }
1753
+ return value.split(parseClassListRegex);
1703
1754
  };
1704
- var installDevTools = () => {
1705
- if (BUILD13.devTools) {
1706
- const rindo = win.rindo = win.rindo || {};
1707
- const originalInspect = rindo.inspect;
1708
- rindo.inspect = (ref) => {
1709
- let result = inspect(ref);
1710
- if (!result && typeof originalInspect === "function") {
1711
- result = originalInspect(ref);
1755
+ var CAPTURE_EVENT_SUFFIX = "Capture";
1756
+ var CAPTURE_EVENT_REGEX = new RegExp(CAPTURE_EVENT_SUFFIX + "$");
1757
+
1758
+ // src/runtime/vdom/update-element.ts
1759
+ var updateElement = (oldVnode, newVnode, isSvgMode2, isInitialRender) => {
1760
+ const elm = newVnode.$elm$.nodeType === 11 /* DocumentFragment */ && newVnode.$elm$.host ? newVnode.$elm$.host : newVnode.$elm$;
1761
+ const oldVnodeAttrs = oldVnode && oldVnode.$attrs$ || {};
1762
+ const newVnodeAttrs = newVnode.$attrs$ || {};
1763
+ if (BUILD18.updatable) {
1764
+ for (const memberName of sortedAttrNames(Object.keys(oldVnodeAttrs))) {
1765
+ if (!(memberName in newVnodeAttrs)) {
1766
+ setAccessor(
1767
+ elm,
1768
+ memberName,
1769
+ oldVnodeAttrs[memberName],
1770
+ void 0,
1771
+ isSvgMode2,
1772
+ newVnode.$flags$,
1773
+ isInitialRender
1774
+ );
1712
1775
  }
1713
- return result;
1714
- };
1776
+ }
1777
+ }
1778
+ for (const memberName of sortedAttrNames(Object.keys(newVnodeAttrs))) {
1779
+ setAccessor(
1780
+ elm,
1781
+ memberName,
1782
+ oldVnodeAttrs[memberName],
1783
+ newVnodeAttrs[memberName],
1784
+ isSvgMode2,
1785
+ newVnode.$flags$,
1786
+ isInitialRender
1787
+ );
1715
1788
  }
1716
1789
  };
1790
+ function sortedAttrNames(attrNames) {
1791
+ return attrNames.includes("ref") ? (
1792
+ // we need to sort these to ensure that `'ref'` is the last attr
1793
+ [...attrNames.filter((attr) => attr !== "ref"), "ref"]
1794
+ ) : (
1795
+ // no need to sort, return the original array
1796
+ attrNames
1797
+ );
1798
+ }
1717
1799
 
1718
- // src/runtime/client-hydrate.ts
1719
- var initializeClientHydrate = (hostElm, tagName, hostId, hostRef) => {
1720
- const endHydrate = createTime("hydrateClient", tagName);
1721
- const shadowRoot = hostElm.shadowRoot;
1722
- const childRenderNodes = [];
1723
- const slotNodes = [];
1724
- const slottedNodes = [];
1725
- const shadowRootNodes = BUILD14.shadowDom && shadowRoot ? [] : null;
1726
- const vnode = newVNode(tagName, null);
1727
- vnode.$elm$ = hostElm;
1728
- let scopeId2;
1729
- if (BUILD14.scoped) {
1730
- const cmpMeta = hostRef.$cmpMeta$;
1731
- if (cmpMeta && cmpMeta.$flags$ & 10 /* needsScopedEncapsulation */ && hostElm["s-sc"]) {
1732
- scopeId2 = hostElm["s-sc"];
1733
- hostElm.classList.add(scopeId2 + "-h");
1734
- } else if (hostElm["s-sc"]) {
1735
- delete hostElm["s-sc"];
1800
+ // src/runtime/vdom/vdom-render.ts
1801
+ var scopeId;
1802
+ var contentRef;
1803
+ var hostTagName;
1804
+ var useNativeShadowDom = false;
1805
+ var checkSlotFallbackVisibility = false;
1806
+ var checkSlotRelocate = false;
1807
+ var isSvgMode = false;
1808
+ var createElm = (oldParentVNode, newParentVNode, childIndex) => {
1809
+ var _a;
1810
+ const newVNode2 = newParentVNode.$children$[childIndex];
1811
+ let i2 = 0;
1812
+ let elm;
1813
+ let childNode;
1814
+ let oldVNode;
1815
+ if (BUILD19.slotRelocation && !useNativeShadowDom) {
1816
+ checkSlotRelocate = true;
1817
+ if (newVNode2.$tag$ === "slot") {
1818
+ newVNode2.$flags$ |= newVNode2.$children$ ? (
1819
+ // slot element has fallback content
1820
+ // still create an element that "mocks" the slot element
1821
+ 2 /* isSlotFallback */
1822
+ ) : (
1823
+ // slot element does not have fallback content
1824
+ // create an html comment we'll use to always reference
1825
+ // where actual slot content should sit next to
1826
+ 1 /* isSlotReference */
1827
+ );
1736
1828
  }
1737
1829
  }
1738
- if (!plt.$orgLocNodes$) {
1739
- initializeDocumentHydrate(doc.body, plt.$orgLocNodes$ = /* @__PURE__ */ new Map());
1830
+ if (BUILD19.isDev && newVNode2.$elm$) {
1831
+ consoleDevError(
1832
+ `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`
1833
+ );
1740
1834
  }
1741
- hostElm[HYDRATE_ID] = hostId;
1742
- hostElm.removeAttribute(HYDRATE_ID);
1743
- hostRef.$vnode$ = clientHydrate(
1744
- vnode,
1745
- childRenderNodes,
1746
- slotNodes,
1747
- shadowRootNodes,
1748
- hostElm,
1749
- hostElm,
1750
- hostId,
1751
- slottedNodes
1752
- );
1753
- let crIndex = 0;
1754
- const crLength = childRenderNodes.length;
1755
- let childRenderNode;
1756
- for (crIndex; crIndex < crLength; crIndex++) {
1757
- childRenderNode = childRenderNodes[crIndex];
1758
- const orgLocationId = childRenderNode.$hostId$ + "." + childRenderNode.$nodeId$;
1759
- const orgLocationNode = plt.$orgLocNodes$.get(orgLocationId);
1760
- const node = childRenderNode.$elm$;
1761
- if (!shadowRoot) {
1762
- node["s-hn"] = tagName.toUpperCase();
1763
- if (childRenderNode.$tag$ === "slot") {
1764
- node["s-cr"] = hostElm["s-cr"];
1765
- }
1835
+ if (BUILD19.vdomText && newVNode2.$text$ !== null) {
1836
+ elm = newVNode2.$elm$ = doc.createTextNode(newVNode2.$text$);
1837
+ } else if (BUILD19.slotRelocation && newVNode2.$flags$ & 1 /* isSlotReference */) {
1838
+ elm = newVNode2.$elm$ = BUILD19.isDebug || BUILD19.hydrateServerSide ? slotReferenceDebugNode(newVNode2) : doc.createTextNode("");
1839
+ } else {
1840
+ if (BUILD19.svg && !isSvgMode) {
1841
+ isSvgMode = newVNode2.$tag$ === "svg";
1766
1842
  }
1767
- if (childRenderNode.$tag$ === "slot") {
1768
- if (childRenderNode.$children$) {
1769
- childRenderNode.$flags$ |= 2 /* isSlotFallback */;
1770
- if (!childRenderNode.$elm$.childNodes.length) {
1771
- childRenderNode.$children$.forEach((c) => {
1772
- childRenderNode.$elm$.appendChild(c.$elm$);
1773
- });
1843
+ elm = newVNode2.$elm$ = BUILD19.svg ? doc.createElementNS(
1844
+ isSvgMode ? SVG_NS : HTML_NS,
1845
+ !useNativeShadowDom && BUILD19.slotRelocation && newVNode2.$flags$ & 2 /* isSlotFallback */ ? "slot-fb" : newVNode2.$tag$
1846
+ ) : doc.createElement(
1847
+ !useNativeShadowDom && BUILD19.slotRelocation && newVNode2.$flags$ & 2 /* isSlotFallback */ ? "slot-fb" : newVNode2.$tag$
1848
+ );
1849
+ if (BUILD19.svg && isSvgMode && newVNode2.$tag$ === "foreignObject") {
1850
+ isSvgMode = false;
1851
+ }
1852
+ if (BUILD19.vdomAttribute) {
1853
+ updateElement(null, newVNode2, isSvgMode);
1854
+ }
1855
+ if (BUILD19.scoped && isDef(scopeId) && elm["s-si"] !== scopeId) {
1856
+ elm.classList.add(elm["s-si"] = scopeId);
1857
+ }
1858
+ if (newVNode2.$children$) {
1859
+ for (i2 = 0; i2 < newVNode2.$children$.length; ++i2) {
1860
+ childNode = createElm(oldParentVNode, newVNode2, i2);
1861
+ if (childNode) {
1862
+ elm.appendChild(childNode);
1774
1863
  }
1775
- } else {
1776
- childRenderNode.$flags$ |= 1 /* isSlotReference */;
1777
1864
  }
1778
1865
  }
1779
- if (orgLocationNode && orgLocationNode.isConnected) {
1780
- if (shadowRoot && orgLocationNode["s-en"] === "") {
1781
- orgLocationNode.parentNode.insertBefore(node, orgLocationNode.nextSibling);
1782
- }
1783
- orgLocationNode.parentNode.removeChild(orgLocationNode);
1784
- if (!shadowRoot) {
1785
- node["s-oo"] = parseInt(childRenderNode.$nodeId$);
1866
+ if (BUILD19.svg) {
1867
+ if (newVNode2.$tag$ === "svg") {
1868
+ isSvgMode = false;
1869
+ } else if (elm.tagName === "foreignObject") {
1870
+ isSvgMode = true;
1786
1871
  }
1787
1872
  }
1788
- plt.$orgLocNodes$.delete(orgLocationId);
1789
1873
  }
1790
- const hosts = [];
1791
- const snLen = slottedNodes.length;
1792
- let snIndex = 0;
1793
- let slotGroup;
1794
- let snGroupIdx;
1795
- let snGroupLen;
1796
- let slottedItem;
1797
- for (snIndex; snIndex < snLen; snIndex++) {
1798
- slotGroup = slottedNodes[snIndex];
1799
- if (!slotGroup || !slotGroup.length) continue;
1800
- snGroupLen = slotGroup.length;
1801
- snGroupIdx = 0;
1802
- for (snGroupIdx; snGroupIdx < snGroupLen; snGroupIdx++) {
1803
- slottedItem = slotGroup[snGroupIdx];
1804
- if (!hosts[slottedItem.hostId]) {
1805
- hosts[slottedItem.hostId] = plt.$orgLocNodes$.get(slottedItem.hostId);
1806
- }
1807
- if (!hosts[slottedItem.hostId]) continue;
1808
- const hostEle = hosts[slottedItem.hostId];
1809
- if (!hostEle.shadowRoot || !shadowRoot) {
1810
- slottedItem.slot["s-cr"] = hostEle["s-cr"];
1811
- if (!slottedItem.slot["s-cr"] && hostEle.shadowRoot) {
1812
- slottedItem.slot["s-cr"] = hostEle;
1874
+ elm["s-hn"] = hostTagName;
1875
+ if (BUILD19.slotRelocation) {
1876
+ if (newVNode2.$flags$ & (2 /* isSlotFallback */ | 1 /* isSlotReference */)) {
1877
+ elm["s-sr"] = true;
1878
+ elm["s-cr"] = contentRef;
1879
+ elm["s-sn"] = newVNode2.$name$ || "";
1880
+ elm["s-rf"] = (_a = newVNode2.$attrs$) == null ? void 0 : _a.ref;
1881
+ oldVNode = oldParentVNode && oldParentVNode.$children$ && oldParentVNode.$children$[childIndex];
1882
+ if (oldVNode && oldVNode.$tag$ === newVNode2.$tag$ && oldParentVNode.$elm$) {
1883
+ if (BUILD19.experimentalSlotFixes) {
1884
+ relocateToHostRoot(oldParentVNode.$elm$);
1813
1885
  } else {
1814
- slottedItem.slot["s-cr"] = (hostEle.__childNodes || hostEle.childNodes)[0];
1815
- }
1816
- addSlotRelocateNode(slottedItem.node, slottedItem.slot, false, slottedItem.node["s-oo"]);
1817
- if (BUILD14.experimentalSlotFixes) {
1818
- patchNextPrev(slottedItem.node);
1886
+ putBackInOriginalLocation(oldParentVNode.$elm$, false);
1819
1887
  }
1820
1888
  }
1821
- if (hostEle.shadowRoot && slottedItem.node.parentElement !== hostEle) {
1822
- hostEle.appendChild(slottedItem.node);
1889
+ if (BUILD19.scoped) {
1890
+ addRemoveSlotScopedClass(contentRef, elm, newParentVNode.$elm$, oldParentVNode == null ? void 0 : oldParentVNode.$elm$);
1891
+ }
1892
+ }
1893
+ }
1894
+ return elm;
1895
+ };
1896
+ var relocateToHostRoot = (parentElm) => {
1897
+ plt.$flags$ |= 1 /* isTmpDisconnected */;
1898
+ const host = parentElm.closest(hostTagName.toLowerCase());
1899
+ if (host != null) {
1900
+ const contentRefNode = Array.from(host.__childNodes || host.childNodes).find(
1901
+ (ref) => ref["s-cr"]
1902
+ );
1903
+ const childNodeArray = Array.from(
1904
+ parentElm.__childNodes || parentElm.childNodes
1905
+ );
1906
+ for (const childNode of contentRefNode ? childNodeArray.reverse() : childNodeArray) {
1907
+ if (childNode["s-sh"] != null) {
1908
+ insertBefore(host, childNode, contentRefNode != null ? contentRefNode : null);
1909
+ childNode["s-sh"] = void 0;
1910
+ checkSlotRelocate = true;
1823
1911
  }
1824
1912
  }
1825
1913
  }
1826
- if (BUILD14.scoped && scopeId2 && slotNodes.length) {
1827
- slotNodes.forEach((slot) => {
1828
- slot.$elm$.parentElement.classList.add(scopeId2 + "-s");
1829
- });
1914
+ plt.$flags$ &= ~1 /* isTmpDisconnected */;
1915
+ };
1916
+ var putBackInOriginalLocation = (parentElm, recursive) => {
1917
+ plt.$flags$ |= 1 /* isTmpDisconnected */;
1918
+ const oldSlotChildNodes = Array.from(parentElm.__childNodes || parentElm.childNodes);
1919
+ if (parentElm["s-sr"] && BUILD19.experimentalSlotFixes) {
1920
+ let node = parentElm;
1921
+ while (node = node.nextSibling) {
1922
+ if (node && node["s-sn"] === parentElm["s-sn"] && node["s-sh"] === hostTagName) {
1923
+ oldSlotChildNodes.push(node);
1924
+ }
1925
+ }
1830
1926
  }
1831
- if (BUILD14.shadowDom && shadowRoot) {
1832
- let rnIdex = 0;
1833
- const rnLen = shadowRootNodes.length;
1834
- for (rnIdex; rnIdex < rnLen; rnIdex++) {
1835
- shadowRoot.appendChild(shadowRootNodes[rnIdex]);
1927
+ for (let i2 = oldSlotChildNodes.length - 1; i2 >= 0; i2--) {
1928
+ const childNode = oldSlotChildNodes[i2];
1929
+ if (childNode["s-hn"] !== hostTagName && childNode["s-ol"]) {
1930
+ insertBefore(referenceNode(childNode).parentNode, childNode, referenceNode(childNode));
1931
+ childNode["s-ol"].remove();
1932
+ childNode["s-ol"] = void 0;
1933
+ childNode["s-sh"] = void 0;
1934
+ checkSlotRelocate = true;
1935
+ }
1936
+ if (recursive) {
1937
+ putBackInOriginalLocation(childNode, recursive);
1836
1938
  }
1837
- Array.from(hostElm.childNodes).forEach((node) => {
1838
- if (node.nodeType === 8 /* CommentNode */ && typeof node["s-sn"] !== "string") {
1839
- node.parentNode.removeChild(node);
1939
+ }
1940
+ plt.$flags$ &= ~1 /* isTmpDisconnected */;
1941
+ };
1942
+ var addVnodes = (parentElm, before, parentVNode, vnodes, startIdx, endIdx) => {
1943
+ let containerElm = BUILD19.slotRelocation && parentElm["s-cr"] && parentElm["s-cr"].parentNode || parentElm;
1944
+ let childNode;
1945
+ if (BUILD19.shadowDom && containerElm.shadowRoot && containerElm.tagName === hostTagName) {
1946
+ containerElm = containerElm.shadowRoot;
1947
+ }
1948
+ for (; startIdx <= endIdx; ++startIdx) {
1949
+ if (vnodes[startIdx]) {
1950
+ childNode = createElm(null, parentVNode, startIdx);
1951
+ if (childNode) {
1952
+ vnodes[startIdx].$elm$ = childNode;
1953
+ insertBefore(containerElm, childNode, BUILD19.slotRelocation ? referenceNode(before) : before);
1840
1954
  }
1841
- });
1955
+ }
1842
1956
  }
1843
- hostRef.$hostElement$ = hostElm;
1844
- endHydrate();
1845
1957
  };
1846
- var clientHydrate = (parentVNode, childRenderNodes, slotNodes, shadowRootNodes, hostElm, node, hostId, slottedNodes = []) => {
1847
- let childNodeType;
1848
- let childIdSplt;
1849
- let childVNode;
1850
- let i2;
1851
- const scopeId2 = hostElm["s-sc"];
1852
- if (node.nodeType === 1 /* ElementNode */) {
1853
- childNodeType = node.getAttribute(HYDRATE_CHILD_ID);
1854
- if (childNodeType) {
1855
- childIdSplt = childNodeType.split(".");
1856
- if (childIdSplt[0] === hostId || childIdSplt[0] === "0") {
1857
- childVNode = createSimpleVNode({
1858
- $flags$: 0,
1859
- $hostId$: childIdSplt[0],
1860
- $nodeId$: childIdSplt[1],
1861
- $depth$: childIdSplt[2],
1862
- $index$: childIdSplt[3],
1863
- $tag$: node.tagName.toLowerCase(),
1864
- $elm$: node,
1865
- // If we don't add the initial classes to the VNode, the first `vdom-render.ts` patch
1866
- // won't try to reconcile them. Classes set on the node will be blown away.
1867
- $attrs$: { class: node.className || "" }
1868
- });
1869
- childRenderNodes.push(childVNode);
1870
- node.removeAttribute(HYDRATE_CHILD_ID);
1871
- if (!parentVNode.$children$) {
1872
- parentVNode.$children$ = [];
1873
- }
1874
- if (BUILD14.scoped && scopeId2) {
1875
- node["s-si"] = scopeId2;
1876
- childVNode.$attrs$.class += " " + scopeId2;
1877
- }
1878
- const slotName = childVNode.$elm$.getAttribute("s-sn");
1879
- if (typeof slotName === "string") {
1880
- if (childVNode.$tag$ === "slot-fb") {
1881
- addSlot(
1882
- slotName,
1883
- childIdSplt[2],
1884
- childVNode,
1885
- node,
1886
- parentVNode,
1887
- childRenderNodes,
1888
- slotNodes,
1889
- shadowRootNodes,
1890
- slottedNodes
1891
- );
1892
- if (BUILD14.scoped && scopeId2) {
1893
- node.classList.add(scopeId2);
1894
- }
1958
+ var removeVnodes = (vnodes, startIdx, endIdx) => {
1959
+ for (let index = startIdx; index <= endIdx; ++index) {
1960
+ const vnode = vnodes[index];
1961
+ if (vnode) {
1962
+ const elm = vnode.$elm$;
1963
+ nullifyVNodeRefs(vnode);
1964
+ if (elm) {
1965
+ if (BUILD19.slotRelocation) {
1966
+ checkSlotFallbackVisibility = true;
1967
+ if (elm["s-ol"]) {
1968
+ elm["s-ol"].remove();
1969
+ } else {
1970
+ putBackInOriginalLocation(elm, true);
1895
1971
  }
1896
- childVNode.$elm$["s-sn"] = slotName;
1897
- childVNode.$elm$.removeAttribute("s-sn");
1898
- }
1899
- if (childVNode.$index$ !== void 0) {
1900
- parentVNode.$children$[childVNode.$index$] = childVNode;
1901
- }
1902
- parentVNode = childVNode;
1903
- if (shadowRootNodes && childVNode.$depth$ === "0") {
1904
- shadowRootNodes[childVNode.$index$] = childVNode.$elm$;
1905
1972
  }
1973
+ elm.remove();
1906
1974
  }
1907
1975
  }
1908
- if (node.shadowRoot) {
1909
- for (i2 = node.shadowRoot.childNodes.length - 1; i2 >= 0; i2--) {
1910
- clientHydrate(
1911
- parentVNode,
1912
- childRenderNodes,
1913
- slotNodes,
1914
- shadowRootNodes,
1915
- hostElm,
1916
- node.shadowRoot.childNodes[i2],
1917
- hostId,
1918
- slottedNodes
1919
- );
1976
+ }
1977
+ };
1978
+ var updateChildren = (parentElm, oldCh, newVNode2, newCh, isInitialRender = false) => {
1979
+ let oldStartIdx = 0;
1980
+ let newStartIdx = 0;
1981
+ let idxInOld = 0;
1982
+ let i2 = 0;
1983
+ let oldEndIdx = oldCh.length - 1;
1984
+ let oldStartVnode = oldCh[0];
1985
+ let oldEndVnode = oldCh[oldEndIdx];
1986
+ let newEndIdx = newCh.length - 1;
1987
+ let newStartVnode = newCh[0];
1988
+ let newEndVnode = newCh[newEndIdx];
1989
+ let node;
1990
+ let elmToMove;
1991
+ while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
1992
+ if (oldStartVnode == null) {
1993
+ oldStartVnode = oldCh[++oldStartIdx];
1994
+ } else if (oldEndVnode == null) {
1995
+ oldEndVnode = oldCh[--oldEndIdx];
1996
+ } else if (newStartVnode == null) {
1997
+ newStartVnode = newCh[++newStartIdx];
1998
+ } else if (newEndVnode == null) {
1999
+ newEndVnode = newCh[--newEndIdx];
2000
+ } else if (isSameVnode(oldStartVnode, newStartVnode, isInitialRender)) {
2001
+ patch(oldStartVnode, newStartVnode, isInitialRender);
2002
+ oldStartVnode = oldCh[++oldStartIdx];
2003
+ newStartVnode = newCh[++newStartIdx];
2004
+ } else if (isSameVnode(oldEndVnode, newEndVnode, isInitialRender)) {
2005
+ patch(oldEndVnode, newEndVnode, isInitialRender);
2006
+ oldEndVnode = oldCh[--oldEndIdx];
2007
+ newEndVnode = newCh[--newEndIdx];
2008
+ } else if (isSameVnode(oldStartVnode, newEndVnode, isInitialRender)) {
2009
+ if (BUILD19.slotRelocation && (oldStartVnode.$tag$ === "slot" || newEndVnode.$tag$ === "slot")) {
2010
+ putBackInOriginalLocation(oldStartVnode.$elm$.parentNode, false);
1920
2011
  }
1921
- }
1922
- const nonShadowNodes = node.__childNodes || node.childNodes;
1923
- for (i2 = nonShadowNodes.length - 1; i2 >= 0; i2--) {
1924
- clientHydrate(
1925
- parentVNode,
1926
- childRenderNodes,
1927
- slotNodes,
1928
- shadowRootNodes,
1929
- hostElm,
1930
- nonShadowNodes[i2],
1931
- hostId,
1932
- slottedNodes
1933
- );
1934
- }
1935
- } else if (node.nodeType === 8 /* CommentNode */) {
1936
- childIdSplt = node.nodeValue.split(".");
1937
- if (childIdSplt[1] === hostId || childIdSplt[1] === "0") {
1938
- childNodeType = childIdSplt[0];
1939
- childVNode = createSimpleVNode({
1940
- $hostId$: childIdSplt[1],
1941
- $nodeId$: childIdSplt[2],
1942
- $depth$: childIdSplt[3],
1943
- $index$: childIdSplt[4] || "0",
1944
- $elm$: node,
1945
- $attrs$: null,
1946
- $children$: null,
1947
- $key$: null,
1948
- $name$: null,
1949
- $tag$: null,
1950
- $text$: null
1951
- });
1952
- if (childNodeType === TEXT_NODE_ID) {
1953
- childVNode.$elm$ = node.nextSibling;
1954
- if (childVNode.$elm$ && childVNode.$elm$.nodeType === 3 /* TextNode */) {
1955
- childVNode.$text$ = childVNode.$elm$.textContent;
1956
- childRenderNodes.push(childVNode);
1957
- node.remove();
1958
- if (hostId === childVNode.$hostId$) {
1959
- if (!parentVNode.$children$) {
1960
- parentVNode.$children$ = [];
1961
- }
1962
- parentVNode.$children$[childVNode.$index$] = childVNode;
1963
- }
1964
- if (shadowRootNodes && childVNode.$depth$ === "0") {
1965
- shadowRootNodes[childVNode.$index$] = childVNode.$elm$;
2012
+ patch(oldStartVnode, newEndVnode, isInitialRender);
2013
+ insertBefore(parentElm, oldStartVnode.$elm$, oldEndVnode.$elm$.nextSibling);
2014
+ oldStartVnode = oldCh[++oldStartIdx];
2015
+ newEndVnode = newCh[--newEndIdx];
2016
+ } else if (isSameVnode(oldEndVnode, newStartVnode, isInitialRender)) {
2017
+ if (BUILD19.slotRelocation && (oldStartVnode.$tag$ === "slot" || newEndVnode.$tag$ === "slot")) {
2018
+ putBackInOriginalLocation(oldEndVnode.$elm$.parentNode, false);
2019
+ }
2020
+ patch(oldEndVnode, newStartVnode, isInitialRender);
2021
+ insertBefore(parentElm, oldEndVnode.$elm$, oldStartVnode.$elm$);
2022
+ oldEndVnode = oldCh[--oldEndIdx];
2023
+ newStartVnode = newCh[++newStartIdx];
2024
+ } else {
2025
+ idxInOld = -1;
2026
+ if (BUILD19.vdomKey) {
2027
+ for (i2 = oldStartIdx; i2 <= oldEndIdx; ++i2) {
2028
+ if (oldCh[i2] && oldCh[i2].$key$ !== null && oldCh[i2].$key$ === newStartVnode.$key$) {
2029
+ idxInOld = i2;
2030
+ break;
1966
2031
  }
1967
2032
  }
1968
- } else if (childNodeType === COMMENT_NODE_ID) {
1969
- childVNode.$elm$ = node.nextSibling;
1970
- if (childVNode.$elm$ && childVNode.$elm$.nodeType === 8 /* CommentNode */) {
1971
- childRenderNodes.push(childVNode);
1972
- node.remove();
1973
- }
1974
- } else if (childVNode.$hostId$ === hostId) {
1975
- if (childNodeType === SLOT_NODE_ID) {
1976
- const slotName = node["s-sn"] = childIdSplt[5] || "";
1977
- addSlot(
1978
- slotName,
1979
- childIdSplt[2],
1980
- childVNode,
2033
+ }
2034
+ if (BUILD19.vdomKey && idxInOld >= 0) {
2035
+ elmToMove = oldCh[idxInOld];
2036
+ if (elmToMove.$tag$ !== newStartVnode.$tag$) {
2037
+ node = createElm(oldCh && oldCh[newStartIdx], newVNode2, idxInOld);
2038
+ } else {
2039
+ patch(elmToMove, newStartVnode, isInitialRender);
2040
+ oldCh[idxInOld] = void 0;
2041
+ node = elmToMove.$elm$;
2042
+ }
2043
+ newStartVnode = newCh[++newStartIdx];
2044
+ } else {
2045
+ node = createElm(oldCh && oldCh[newStartIdx], newVNode2, newStartIdx);
2046
+ newStartVnode = newCh[++newStartIdx];
2047
+ }
2048
+ if (node) {
2049
+ if (BUILD19.slotRelocation) {
2050
+ insertBefore(
2051
+ referenceNode(oldStartVnode.$elm$).parentNode,
1981
2052
  node,
1982
- parentVNode,
1983
- childRenderNodes,
1984
- slotNodes,
1985
- shadowRootNodes,
1986
- slottedNodes
2053
+ referenceNode(oldStartVnode.$elm$)
1987
2054
  );
1988
- } else if (childNodeType === CONTENT_REF_ID) {
1989
- if (BUILD14.shadowDom && shadowRootNodes) {
1990
- node.remove();
1991
- } else if (BUILD14.slotRelocation) {
1992
- hostElm["s-cr"] = node;
1993
- node["s-cn"] = true;
1994
- }
2055
+ } else {
2056
+ insertBefore(oldStartVnode.$elm$.parentNode, node, oldStartVnode.$elm$);
1995
2057
  }
1996
2058
  }
1997
2059
  }
1998
- } else if (parentVNode && parentVNode.$tag$ === "style") {
1999
- const vnode = newVNode(null, node.textContent);
2000
- vnode.$elm$ = node;
2001
- vnode.$index$ = "0";
2002
- parentVNode.$children$ = [vnode];
2003
2060
  }
2004
- return parentVNode;
2061
+ if (oldStartIdx > oldEndIdx) {
2062
+ addVnodes(
2063
+ parentElm,
2064
+ newCh[newEndIdx + 1] == null ? null : newCh[newEndIdx + 1].$elm$,
2065
+ newVNode2,
2066
+ newCh,
2067
+ newStartIdx,
2068
+ newEndIdx
2069
+ );
2070
+ } else if (BUILD19.updatable && newStartIdx > newEndIdx) {
2071
+ removeVnodes(oldCh, oldStartIdx, oldEndIdx);
2072
+ }
2005
2073
  };
2006
- var initializeDocumentHydrate = (node, orgLocNodes) => {
2007
- if (node.nodeType === 1 /* ElementNode */) {
2008
- const componentId = node[HYDRATE_ID] || node.getAttribute(HYDRATE_ID);
2009
- if (componentId) {
2010
- orgLocNodes.set(componentId, node);
2011
- }
2012
- let i2 = 0;
2013
- if (node.shadowRoot) {
2014
- for (; i2 < node.shadowRoot.childNodes.length; i2++) {
2015
- initializeDocumentHydrate(node.shadowRoot.childNodes[i2], orgLocNodes);
2016
- }
2074
+ var isSameVnode = (leftVNode, rightVNode, isInitialRender = false) => {
2075
+ if (leftVNode.$tag$ === rightVNode.$tag$) {
2076
+ if (BUILD19.slotRelocation && leftVNode.$tag$ === "slot") {
2077
+ return leftVNode.$name$ === rightVNode.$name$;
2017
2078
  }
2018
- const nonShadowNodes = node.__childNodes || node.childNodes;
2019
- for (i2 = 0; i2 < nonShadowNodes.length; i2++) {
2020
- initializeDocumentHydrate(nonShadowNodes[i2], orgLocNodes);
2079
+ if (BUILD19.vdomKey && !isInitialRender) {
2080
+ return leftVNode.$key$ === rightVNode.$key$;
2021
2081
  }
2022
- } else if (node.nodeType === 8 /* CommentNode */) {
2023
- const childIdSplt = node.nodeValue.split(".");
2024
- if (childIdSplt[0] === ORG_LOCATION_ID) {
2025
- orgLocNodes.set(childIdSplt[1] + "." + childIdSplt[2], node);
2026
- node.nodeValue = "";
2027
- node["s-en"] = childIdSplt[3];
2082
+ if (isInitialRender && !leftVNode.$key$ && rightVNode.$key$) {
2083
+ leftVNode.$key$ = rightVNode.$key$;
2028
2084
  }
2085
+ return true;
2029
2086
  }
2087
+ return false;
2030
2088
  };
2031
- var createSimpleVNode = (vnode) => {
2032
- const defaultVNode = {
2033
- $flags$: 0,
2034
- $hostId$: null,
2035
- $nodeId$: null,
2036
- $depth$: null,
2037
- $index$: "0",
2038
- $elm$: null,
2039
- $attrs$: null,
2040
- $children$: null,
2041
- $key$: null,
2042
- $name$: null,
2043
- $tag$: null,
2044
- $text$: null
2045
- };
2046
- return { ...defaultVNode, ...vnode };
2047
- };
2048
- function addSlot(slotName, slotId, childVNode, node, parentVNode, childRenderNodes, slotNodes, shadowRootNodes, slottedNodes) {
2049
- node["s-sr"] = true;
2050
- childVNode.$name$ = slotName || null;
2051
- childVNode.$tag$ = "slot";
2052
- const parentNodeId = (parentVNode == null ? void 0 : parentVNode.$elm$) ? parentVNode.$elm$["s-id"] || parentVNode.$elm$.getAttribute("s-id") : "";
2053
- if (BUILD14.shadowDom && shadowRootNodes) {
2054
- const slot = childVNode.$elm$ = doc.createElement(childVNode.$tag$);
2055
- if (childVNode.$name$) {
2056
- childVNode.$elm$.setAttribute("name", slotName);
2089
+ var referenceNode = (node) => node && node["s-ol"] || node;
2090
+ var patch = (oldVNode, newVNode2, isInitialRender = false) => {
2091
+ const elm = newVNode2.$elm$ = oldVNode.$elm$;
2092
+ const oldChildren = oldVNode.$children$;
2093
+ const newChildren = newVNode2.$children$;
2094
+ const tag = newVNode2.$tag$;
2095
+ const text = newVNode2.$text$;
2096
+ let defaultHolder;
2097
+ if (!BUILD19.vdomText || text === null) {
2098
+ if (BUILD19.svg) {
2099
+ isSvgMode = tag === "svg" ? true : tag === "foreignObject" ? false : isSvgMode;
2057
2100
  }
2058
- if (parentNodeId && parentNodeId !== childVNode.$hostId$) {
2059
- parentVNode.$elm$.insertBefore(slot, parentVNode.$elm$.children[0]);
2060
- } else {
2061
- node.parentNode.insertBefore(childVNode.$elm$, node);
2101
+ if (BUILD19.vdomAttribute || BUILD19.reflect) {
2102
+ if (BUILD19.slot && tag === "slot" && !useNativeShadowDom) {
2103
+ if (BUILD19.experimentalSlotFixes && oldVNode.$name$ !== newVNode2.$name$) {
2104
+ newVNode2.$elm$["s-sn"] = newVNode2.$name$ || "";
2105
+ relocateToHostRoot(newVNode2.$elm$.parentElement);
2106
+ }
2107
+ } else {
2108
+ updateElement(oldVNode, newVNode2, isSvgMode, isInitialRender);
2109
+ }
2062
2110
  }
2063
- addSlottedNodes(slottedNodes, slotId, slotName, node, childVNode.$hostId$);
2064
- node.remove();
2065
- if (childVNode.$depth$ === "0") {
2066
- shadowRootNodes[childVNode.$index$] = childVNode.$elm$;
2111
+ if (BUILD19.updatable && oldChildren !== null && newChildren !== null) {
2112
+ updateChildren(elm, oldChildren, newVNode2, newChildren, isInitialRender);
2113
+ } else if (newChildren !== null) {
2114
+ if (BUILD19.updatable && BUILD19.vdomText && oldVNode.$text$ !== null) {
2115
+ elm.textContent = "";
2116
+ }
2117
+ addVnodes(elm, null, newVNode2, newChildren, 0, newChildren.length - 1);
2118
+ } else if (
2119
+ // don't do this on initial render as it can cause non-hydrated content to be removed
2120
+ !isInitialRender && BUILD19.updatable && oldChildren !== null
2121
+ ) {
2122
+ removeVnodes(oldChildren, 0, oldChildren.length - 1);
2067
2123
  }
2068
- } else {
2069
- const slot = childVNode.$elm$;
2070
- const shouldMove = parentNodeId && parentNodeId !== childVNode.$hostId$ && parentVNode.$elm$.shadowRoot;
2071
- addSlottedNodes(slottedNodes, slotId, slotName, node, shouldMove ? parentNodeId : childVNode.$hostId$);
2072
- if (shouldMove) {
2073
- parentVNode.$elm$.insertBefore(slot, parentVNode.$elm$.children[0]);
2124
+ if (BUILD19.svg && isSvgMode && tag === "svg") {
2125
+ isSvgMode = false;
2074
2126
  }
2075
- childRenderNodes.push(childVNode);
2076
- }
2077
- slotNodes.push(childVNode);
2078
- if (!parentVNode.$children$) {
2079
- parentVNode.$children$ = [];
2080
- }
2081
- parentVNode.$children$[childVNode.$index$] = childVNode;
2082
- }
2083
- var addSlottedNodes = (slottedNodes, slotNodeId, slotName, slotNode, hostId) => {
2084
- let slottedNode = slotNode.nextSibling;
2085
- slottedNodes[slotNodeId] = slottedNodes[slotNodeId] || [];
2086
- 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 */))) {
2087
- slottedNode["s-sn"] = slotName;
2088
- slottedNodes[slotNodeId].push({ slot: slotNode, node: slottedNode, hostId });
2089
- slottedNode = slottedNode.nextSibling;
2127
+ } else if (BUILD19.vdomText && BUILD19.slotRelocation && (defaultHolder = elm["s-cr"])) {
2128
+ defaultHolder.parentNode.textContent = text;
2129
+ } else if (BUILD19.vdomText && oldVNode.$text$ !== text) {
2130
+ elm.data = text;
2090
2131
  }
2091
2132
  };
2092
-
2093
- // src/runtime/initialize-component.ts
2094
- import { BUILD as BUILD22 } from "@rindo/core/internal/app-data";
2095
-
2096
- // src/runtime/mode.ts
2097
- var computeMode = (elm) => modeResolutionChain.map((h2) => h2(elm)).find((m) => !!m);
2098
- var setMode = (handler) => modeResolutionChain.push(handler);
2099
- var getMode = (ref) => getHostRef(ref).$modeName$;
2100
-
2101
- // src/runtime/proxy-component.ts
2102
- import { BUILD as BUILD21 } from "@rindo/core/internal/app-data";
2103
-
2104
- // src/runtime/set-value.ts
2105
- import { BUILD as BUILD20 } from "@rindo/core/internal/app-data";
2106
-
2107
- // src/runtime/parse-property-value.ts
2108
- import { BUILD as BUILD15 } from "@rindo/core/internal/app-data";
2109
- var parsePropertyValue = (propValue, propType) => {
2110
- if (propValue != null && !isComplexType(propValue)) {
2111
- if (BUILD15.propBoolean && propType & 4 /* Boolean */) {
2112
- return propValue === "false" ? false : propValue === "" || !!propValue;
2133
+ var relocateNodes = [];
2134
+ var markSlotContentForRelocation = (elm) => {
2135
+ let node;
2136
+ let hostContentNodes;
2137
+ let j;
2138
+ const children = elm.__childNodes || elm.childNodes;
2139
+ for (const childNode of children) {
2140
+ if (childNode["s-sr"] && (node = childNode["s-cr"]) && node.parentNode) {
2141
+ hostContentNodes = node.parentNode.__childNodes || node.parentNode.childNodes;
2142
+ const slotName = childNode["s-sn"];
2143
+ for (j = hostContentNodes.length - 1; j >= 0; j--) {
2144
+ node = hostContentNodes[j];
2145
+ if (!node["s-cn"] && !node["s-nr"] && node["s-hn"] !== childNode["s-hn"] && (!BUILD19.experimentalSlotFixes || !node["s-sh"] || node["s-sh"] !== childNode["s-hn"])) {
2146
+ if (isNodeLocatedInSlot(node, slotName)) {
2147
+ let relocateNodeData = relocateNodes.find((r) => r.$nodeToRelocate$ === node);
2148
+ checkSlotFallbackVisibility = true;
2149
+ node["s-sn"] = node["s-sn"] || slotName;
2150
+ if (relocateNodeData) {
2151
+ relocateNodeData.$nodeToRelocate$["s-sh"] = childNode["s-hn"];
2152
+ relocateNodeData.$slotRefNode$ = childNode;
2153
+ } else {
2154
+ node["s-sh"] = childNode["s-hn"];
2155
+ relocateNodes.push({
2156
+ $slotRefNode$: childNode,
2157
+ $nodeToRelocate$: node
2158
+ });
2159
+ }
2160
+ if (node["s-sr"]) {
2161
+ relocateNodes.map((relocateNode) => {
2162
+ if (isNodeLocatedInSlot(relocateNode.$nodeToRelocate$, node["s-sn"])) {
2163
+ relocateNodeData = relocateNodes.find((r) => r.$nodeToRelocate$ === node);
2164
+ if (relocateNodeData && !relocateNode.$slotRefNode$) {
2165
+ relocateNode.$slotRefNode$ = relocateNodeData.$slotRefNode$;
2166
+ }
2167
+ }
2168
+ });
2169
+ }
2170
+ } else if (!relocateNodes.some((r) => r.$nodeToRelocate$ === node)) {
2171
+ relocateNodes.push({
2172
+ $nodeToRelocate$: node
2173
+ });
2174
+ }
2175
+ }
2176
+ }
2113
2177
  }
2114
- if (BUILD15.propNumber && propType & 2 /* Number */) {
2115
- return parseFloat(propValue);
2178
+ if (childNode.nodeType === 1 /* ElementNode */) {
2179
+ markSlotContentForRelocation(childNode);
2116
2180
  }
2117
- if (BUILD15.propString && propType & 1 /* String */) {
2118
- return String(propValue);
2181
+ }
2182
+ };
2183
+ var nullifyVNodeRefs = (vNode) => {
2184
+ if (BUILD19.vdomRef) {
2185
+ vNode.$attrs$ && vNode.$attrs$.ref && vNode.$attrs$.ref(null);
2186
+ vNode.$children$ && vNode.$children$.map(nullifyVNodeRefs);
2187
+ }
2188
+ };
2189
+ var insertBefore = (parent, newNode, reference) => {
2190
+ if (BUILD19.scoped && typeof newNode["s-sn"] === "string" && !!newNode["s-sr"] && !!newNode["s-cr"]) {
2191
+ addRemoveSlotScopedClass(newNode["s-cr"], newNode, parent, newNode.parentElement);
2192
+ } else if (BUILD19.experimentalSlotFixes && typeof newNode["s-sn"] === "string") {
2193
+ if (parent.getRootNode().nodeType !== 11 /* DOCUMENT_FRAGMENT_NODE */) {
2194
+ patchParentNode(newNode);
2119
2195
  }
2120
- return propValue;
2196
+ return parent.insertBefore(newNode, reference);
2197
+ }
2198
+ if (BUILD19.experimentalSlotFixes && parent.__insertBefore) {
2199
+ return parent.__insertBefore(newNode, reference);
2200
+ } else {
2201
+ return parent == null ? void 0 : parent.insertBefore(newNode, reference);
2121
2202
  }
2122
- return propValue;
2123
2203
  };
2124
-
2125
- // src/runtime/update-component.ts
2126
- import { BUILD as BUILD19, NAMESPACE } from "@rindo/core/internal/app-data";
2127
-
2128
- // src/runtime/event-emitter.ts
2129
- import { BUILD as BUILD17 } from "@rindo/core/internal/app-data";
2130
-
2131
- // src/runtime/element.ts
2132
- import { BUILD as BUILD16 } from "@rindo/core/internal/app-data";
2133
- var getElement = (ref) => BUILD16.lazyLoad ? getHostRef(ref).$hostElement$ : ref;
2134
-
2135
- // src/runtime/event-emitter.ts
2136
- var createEvent = (ref, name, flags) => {
2137
- const elm = getElement(ref);
2138
- return {
2139
- emit: (detail) => {
2140
- if (BUILD17.isDev && !elm.isConnected) {
2141
- consoleDevWarn(`The "${name}" event was emitted, but the dispatcher node is no longer connected to the dom.`);
2204
+ function addRemoveSlotScopedClass(reference, slotNode, newParent, oldParent) {
2205
+ var _a, _b;
2206
+ let scopeId2;
2207
+ if (reference && typeof slotNode["s-sn"] === "string" && !!slotNode["s-sr"] && reference.parentNode && reference.parentNode["s-sc"] && (scopeId2 = slotNode["s-si"] || reference.parentNode["s-sc"])) {
2208
+ const scopeName = slotNode["s-sn"];
2209
+ const hostName = slotNode["s-hn"];
2210
+ (_a = newParent.classList) == null ? void 0 : _a.add(scopeId2 + "-s");
2211
+ if (oldParent && ((_b = oldParent.classList) == null ? void 0 : _b.contains(scopeId2 + "-s"))) {
2212
+ let child = (oldParent.__childNodes || oldParent.childNodes)[0];
2213
+ let found = false;
2214
+ while (child) {
2215
+ if (child["s-sn"] !== scopeName && child["s-hn"] === hostName && !!child["s-sr"]) {
2216
+ found = true;
2217
+ break;
2218
+ }
2219
+ child = child.nextSibling;
2142
2220
  }
2143
- return emitEvent(elm, name, {
2144
- bubbles: !!(flags & 4 /* Bubbles */),
2145
- composed: !!(flags & 2 /* Composed */),
2146
- cancelable: !!(flags & 1 /* Cancellable */),
2147
- detail
2148
- });
2221
+ if (!found) oldParent.classList.remove(scopeId2 + "-s");
2149
2222
  }
2150
- };
2151
- };
2152
- var emitEvent = (elm, name, opts) => {
2153
- const ev = plt.ce(name, opts);
2154
- elm.dispatchEvent(ev);
2155
- return ev;
2156
- };
2223
+ }
2224
+ }
2225
+ var renderVdom = (hostRef, renderFnResults, isInitialLoad = false) => {
2226
+ var _a, _b, _c, _d, _e;
2227
+ const hostElm = hostRef.$hostElement$;
2228
+ const cmpMeta = hostRef.$cmpMeta$;
2229
+ const oldVNode = hostRef.$vnode$ || newVNode(null, null);
2230
+ const rootVnode = isHost(renderFnResults) ? renderFnResults : h(null, null, renderFnResults);
2231
+ hostTagName = hostElm.tagName;
2232
+ if (BUILD19.isDev && Array.isArray(renderFnResults) && renderFnResults.some(isHost)) {
2233
+ throw new Error(`The <Host> must be the single root component.
2234
+ Looks like the render() function of "${hostTagName.toLowerCase()}" is returning an array that contains the <Host>.
2157
2235
 
2158
- // src/runtime/styles.ts
2159
- import { BUILD as BUILD18 } from "@rindo/core/internal/app-data";
2160
- var rootAppliedStyles = /* @__PURE__ */ new WeakMap();
2161
- var registerStyle = (scopeId2, cssText, allowCS) => {
2162
- let style = styles.get(scopeId2);
2163
- if (supportsConstructableStylesheets && allowCS) {
2164
- style = style || new CSSStyleSheet();
2165
- if (typeof style === "string") {
2166
- style = cssText;
2167
- } else {
2168
- style.replaceSync(cssText);
2236
+ The render() function should look like this instead:
2237
+
2238
+ render() {
2239
+ // Do not return an array
2240
+ return (
2241
+ <Host>{content}</Host>
2242
+ );
2243
+ }
2244
+ `);
2245
+ }
2246
+ if (BUILD19.reflect && cmpMeta.$attrsToReflect$) {
2247
+ rootVnode.$attrs$ = rootVnode.$attrs$ || {};
2248
+ cmpMeta.$attrsToReflect$.map(
2249
+ ([propName, attribute]) => rootVnode.$attrs$[attribute] = hostElm[propName]
2250
+ );
2251
+ }
2252
+ if (isInitialLoad && rootVnode.$attrs$) {
2253
+ for (const key of Object.keys(rootVnode.$attrs$)) {
2254
+ if (hostElm.hasAttribute(key) && !["key", "ref", "style", "class"].includes(key)) {
2255
+ rootVnode.$attrs$[key] = hostElm[key];
2256
+ }
2169
2257
  }
2170
- } else {
2171
- style = cssText;
2172
2258
  }
2173
- styles.set(scopeId2, style);
2174
- };
2175
- var addStyle = (styleContainerNode, cmpMeta, mode) => {
2176
- var _a;
2177
- const scopeId2 = getScopeId(cmpMeta, mode);
2178
- const style = styles.get(scopeId2);
2179
- if (!BUILD18.attachStyles) {
2180
- return scopeId2;
2259
+ rootVnode.$tag$ = null;
2260
+ rootVnode.$flags$ |= 4 /* isHost */;
2261
+ hostRef.$vnode$ = rootVnode;
2262
+ rootVnode.$elm$ = oldVNode.$elm$ = BUILD19.shadowDom ? hostElm.shadowRoot || hostElm : hostElm;
2263
+ if (BUILD19.scoped || BUILD19.shadowDom) {
2264
+ scopeId = hostElm["s-sc"];
2181
2265
  }
2182
- styleContainerNode = styleContainerNode.nodeType === 11 /* DocumentFragment */ ? styleContainerNode : doc;
2183
- if (style) {
2184
- if (typeof style === "string") {
2185
- styleContainerNode = styleContainerNode.head || styleContainerNode;
2186
- let appliedStyles = rootAppliedStyles.get(styleContainerNode);
2187
- let styleElm;
2188
- if (!appliedStyles) {
2189
- rootAppliedStyles.set(styleContainerNode, appliedStyles = /* @__PURE__ */ new Set());
2266
+ useNativeShadowDom = supportsShadow && (cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) !== 0;
2267
+ if (BUILD19.slotRelocation) {
2268
+ contentRef = hostElm["s-cr"];
2269
+ checkSlotFallbackVisibility = false;
2270
+ }
2271
+ patch(oldVNode, rootVnode, isInitialLoad);
2272
+ if (BUILD19.slotRelocation) {
2273
+ plt.$flags$ |= 1 /* isTmpDisconnected */;
2274
+ if (checkSlotRelocate) {
2275
+ markSlotContentForRelocation(rootVnode.$elm$);
2276
+ for (const relocateData of relocateNodes) {
2277
+ const nodeToRelocate = relocateData.$nodeToRelocate$;
2278
+ if (!nodeToRelocate["s-ol"]) {
2279
+ const orgLocationNode = BUILD19.isDebug || BUILD19.hydrateServerSide ? originalLocationDebugNode(nodeToRelocate) : doc.createTextNode("");
2280
+ orgLocationNode["s-nr"] = nodeToRelocate;
2281
+ insertBefore(nodeToRelocate.parentNode, nodeToRelocate["s-ol"] = orgLocationNode, nodeToRelocate);
2282
+ }
2190
2283
  }
2191
- if (!appliedStyles.has(scopeId2)) {
2192
- if (BUILD18.hydrateClientSide && styleContainerNode.host && (styleElm = styleContainerNode.querySelector(`[${HYDRATED_STYLE_ID}="${scopeId2}"]`))) {
2193
- styleElm.innerHTML = style;
2194
- } else {
2195
- styleElm = document.querySelector(`[${HYDRATED_STYLE_ID}="${scopeId2}"]`) || doc.createElement("style");
2196
- styleElm.innerHTML = style;
2197
- const nonce = (_a = plt.$nonce$) != null ? _a : queryNonceMetaTagContent(doc);
2198
- if (nonce != null) {
2199
- styleElm.setAttribute("nonce", nonce);
2200
- }
2201
- if ((BUILD18.hydrateServerSide || BUILD18.hotModuleReplacement) && cmpMeta.$flags$ & 2 /* scopedCssEncapsulation */) {
2202
- styleElm.setAttribute(HYDRATED_STYLE_ID, scopeId2);
2203
- }
2204
- if (!(cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */)) {
2205
- if (styleContainerNode.nodeName === "HEAD") {
2206
- const preconnectLinks = styleContainerNode.querySelectorAll("link[rel=preconnect]");
2207
- const referenceNode2 = preconnectLinks.length > 0 ? preconnectLinks[preconnectLinks.length - 1].nextSibling : styleContainerNode.querySelector("style");
2208
- styleContainerNode.insertBefore(styleElm, referenceNode2);
2209
- } else if ("host" in styleContainerNode) {
2210
- if (supportsConstructableStylesheets) {
2211
- const stylesheet = new CSSStyleSheet();
2212
- stylesheet.replaceSync(style);
2213
- styleContainerNode.adoptedStyleSheets = [stylesheet, ...styleContainerNode.adoptedStyleSheets];
2214
- } else {
2215
- const existingStyleContainer = styleContainerNode.querySelector("style");
2216
- if (existingStyleContainer) {
2217
- existingStyleContainer.innerHTML = style + existingStyleContainer.innerHTML;
2218
- } else {
2219
- styleContainerNode.prepend(styleElm);
2284
+ for (const relocateData of relocateNodes) {
2285
+ const nodeToRelocate = relocateData.$nodeToRelocate$;
2286
+ const slotRefNode = relocateData.$slotRefNode$;
2287
+ if (slotRefNode) {
2288
+ const parentNodeRef = slotRefNode.parentNode;
2289
+ let insertBeforeNode = slotRefNode.nextSibling;
2290
+ if (!BUILD19.hydrateServerSide && (!BUILD19.experimentalSlotFixes || insertBeforeNode && insertBeforeNode.nodeType === 1 /* ElementNode */)) {
2291
+ let orgLocationNode = (_a = nodeToRelocate["s-ol"]) == null ? void 0 : _a.previousSibling;
2292
+ while (orgLocationNode) {
2293
+ let refNode = (_b = orgLocationNode["s-nr"]) != null ? _b : null;
2294
+ if (refNode && refNode["s-sn"] === nodeToRelocate["s-sn"] && parentNodeRef === (refNode.__parentNode || refNode.parentNode)) {
2295
+ refNode = refNode.nextSibling;
2296
+ while (refNode === nodeToRelocate || (refNode == null ? void 0 : refNode["s-sr"])) {
2297
+ refNode = refNode == null ? void 0 : refNode.nextSibling;
2298
+ }
2299
+ if (!refNode || !refNode["s-nr"]) {
2300
+ insertBeforeNode = refNode;
2301
+ break;
2220
2302
  }
2221
2303
  }
2222
- } else {
2223
- styleContainerNode.append(styleElm);
2304
+ orgLocationNode = orgLocationNode.previousSibling;
2224
2305
  }
2225
2306
  }
2226
- if (cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */ && styleContainerNode.nodeName !== "HEAD") {
2227
- styleContainerNode.insertBefore(styleElm, null);
2307
+ const parent = nodeToRelocate.__parentNode || nodeToRelocate.parentNode;
2308
+ const nextSibling = nodeToRelocate.__nextSibling || nodeToRelocate.nextSibling;
2309
+ if (!insertBeforeNode && parentNodeRef !== parent || nextSibling !== insertBeforeNode) {
2310
+ if (nodeToRelocate !== insertBeforeNode) {
2311
+ if (!BUILD19.experimentalSlotFixes && !nodeToRelocate["s-hn"] && nodeToRelocate["s-ol"]) {
2312
+ nodeToRelocate["s-hn"] = nodeToRelocate["s-ol"].parentNode.nodeName;
2313
+ }
2314
+ insertBefore(parentNodeRef, nodeToRelocate, insertBeforeNode);
2315
+ if (nodeToRelocate.nodeType === 1 /* ElementNode */ && nodeToRelocate.tagName !== "SLOT-FB") {
2316
+ nodeToRelocate.hidden = (_c = nodeToRelocate["s-ih"]) != null ? _c : false;
2317
+ }
2318
+ }
2319
+ }
2320
+ nodeToRelocate && typeof slotRefNode["s-rf"] === "function" && slotRefNode["s-rf"](nodeToRelocate);
2321
+ } else {
2322
+ if (nodeToRelocate.nodeType === 1 /* ElementNode */) {
2323
+ if (isInitialLoad) {
2324
+ nodeToRelocate["s-ih"] = (_d = nodeToRelocate.hidden) != null ? _d : false;
2325
+ }
2326
+ nodeToRelocate.hidden = true;
2228
2327
  }
2229
- }
2230
- if (cmpMeta.$flags$ & 4 /* hasSlotRelocation */) {
2231
- styleElm.innerHTML += SLOT_FB_CSS;
2232
- }
2233
- if (appliedStyles) {
2234
- appliedStyles.add(scopeId2);
2235
2328
  }
2236
2329
  }
2237
- } else if (BUILD18.constructableCSS && !styleContainerNode.adoptedStyleSheets.includes(style)) {
2238
- styleContainerNode.adoptedStyleSheets = [...styleContainerNode.adoptedStyleSheets, style];
2239
2330
  }
2331
+ if (checkSlotFallbackVisibility) {
2332
+ updateFallbackSlotVisibility(rootVnode.$elm$);
2333
+ }
2334
+ plt.$flags$ &= ~1 /* isTmpDisconnected */;
2335
+ relocateNodes.length = 0;
2240
2336
  }
2241
- return scopeId2;
2242
- };
2243
- var attachStyles = (hostRef) => {
2244
- const cmpMeta = hostRef.$cmpMeta$;
2245
- const elm = hostRef.$hostElement$;
2246
- const flags = cmpMeta.$flags$;
2247
- const endAttachStyles = createTime("attachStyles", cmpMeta.$tagName$);
2248
- const scopeId2 = addStyle(
2249
- BUILD18.shadowDom && supportsShadow && elm.shadowRoot ? elm.shadowRoot : elm.getRootNode(),
2250
- cmpMeta,
2251
- hostRef.$modeName$
2252
- );
2253
- if ((BUILD18.shadowDom || BUILD18.scoped) && BUILD18.cssAnnotations && flags & 10 /* needsScopedEncapsulation */ && flags & 2 /* scopedCssEncapsulation */) {
2254
- elm["s-sc"] = scopeId2;
2255
- elm.classList.add(scopeId2 + "-h");
2337
+ if (BUILD19.experimentalScopedSlotChanges && cmpMeta.$flags$ & 2 /* scopedCssEncapsulation */) {
2338
+ const children = rootVnode.$elm$.__childNodes || rootVnode.$elm$.childNodes;
2339
+ for (const childNode of children) {
2340
+ if (childNode["s-hn"] !== hostTagName && !childNode["s-sh"]) {
2341
+ if (isInitialLoad && childNode["s-ih"] == null) {
2342
+ childNode["s-ih"] = (_e = childNode.hidden) != null ? _e : false;
2343
+ }
2344
+ childNode.hidden = true;
2345
+ }
2346
+ }
2256
2347
  }
2257
- endAttachStyles();
2348
+ contentRef = void 0;
2258
2349
  };
2259
- var getScopeId = (cmp, mode) => "sc-" + (BUILD18.mode && mode && cmp.$flags$ & 32 /* hasMode */ ? cmp.$tagName$ + "-" + mode : cmp.$tagName$);
2350
+ var slotReferenceDebugNode = (slotVNode) => doc.createComment(
2351
+ `<slot${slotVNode.$name$ ? ' name="' + slotVNode.$name$ + '"' : ""}> (host=${hostTagName.toLowerCase()})`
2352
+ );
2353
+ var originalLocationDebugNode = (nodeToRelocate) => doc.createComment(
2354
+ `org-location for ` + (nodeToRelocate.localName ? `<${nodeToRelocate.localName}> (host=${nodeToRelocate["s-hn"]})` : `[${nodeToRelocate.textContent}]`)
2355
+ );
2260
2356
 
2261
2357
  // src/runtime/update-component.ts
2262
2358
  var attachToAncestor = (hostRef, ancestorComponent) => {
2263
- if (BUILD19.asyncLoading && ancestorComponent && !hostRef.$onRenderResolve$ && ancestorComponent["s-p"]) {
2264
- ancestorComponent["s-p"].push(new Promise((r) => hostRef.$onRenderResolve$ = r));
2359
+ if (BUILD20.asyncLoading && ancestorComponent && !hostRef.$onRenderResolve$ && ancestorComponent["s-p"]) {
2360
+ const index = ancestorComponent["s-p"].push(
2361
+ new Promise(
2362
+ (r) => hostRef.$onRenderResolve$ = () => {
2363
+ ancestorComponent["s-p"].splice(index - 1, 1);
2364
+ r();
2365
+ }
2366
+ )
2367
+ );
2265
2368
  }
2266
2369
  };
2267
2370
  var scheduleUpdate = (hostRef, isInitialLoad) => {
2268
- if (BUILD19.taskQueue && BUILD19.updatable) {
2371
+ if (BUILD20.taskQueue && BUILD20.updatable) {
2269
2372
  hostRef.$flags$ |= 16 /* isQueuedForUpdate */;
2270
2373
  }
2271
- if (BUILD19.asyncLoading && hostRef.$flags$ & 4 /* isWaitingForChildren */) {
2374
+ if (BUILD20.asyncLoading && hostRef.$flags$ & 4 /* isWaitingForChildren */) {
2272
2375
  hostRef.$flags$ |= 512 /* needsRerender */;
2273
2376
  return;
2274
2377
  }
2275
2378
  attachToAncestor(hostRef, hostRef.$ancestorComponent$);
2276
2379
  const dispatch = () => dispatchHooks(hostRef, isInitialLoad);
2277
- return BUILD19.taskQueue ? writeTask(dispatch) : dispatch();
2380
+ return BUILD20.taskQueue ? writeTask(dispatch) : dispatch();
2278
2381
  };
2279
2382
  var dispatchHooks = (hostRef, isInitialLoad) => {
2280
2383
  const elm = hostRef.$hostElement$;
2281
2384
  const endSchedule = createTime("scheduleUpdate", hostRef.$cmpMeta$.$tagName$);
2282
- const instance = BUILD19.lazyLoad ? hostRef.$lazyInstance$ : elm;
2385
+ const instance = BUILD20.lazyLoad ? hostRef.$lazyInstance$ : elm;
2283
2386
  if (!instance) {
2284
2387
  throw new Error(
2285
2388
  `Can't render component <${elm.tagName.toLowerCase()} /> with invalid Rindo runtime! Make sure this imported component is compiled with a \`externalRuntime: true\` flag. For more information, please refer to https://rindojs.web.app/docs/custom-elements#externalruntime`
@@ -2287,26 +2390,26 @@ var dispatchHooks = (hostRef, isInitialLoad) => {
2287
2390
  }
2288
2391
  let maybePromise;
2289
2392
  if (isInitialLoad) {
2290
- if (BUILD19.lazyLoad && BUILD19.hostListener) {
2393
+ if (BUILD20.lazyLoad && BUILD20.hostListener) {
2291
2394
  hostRef.$flags$ |= 256 /* isListenReady */;
2292
2395
  if (hostRef.$queuedListeners$) {
2293
- hostRef.$queuedListeners$.map(([methodName, event]) => safeCall(instance, methodName, event));
2396
+ hostRef.$queuedListeners$.map(([methodName, event]) => safeCall(instance, methodName, event, elm));
2294
2397
  hostRef.$queuedListeners$ = void 0;
2295
2398
  }
2296
2399
  }
2297
2400
  emitLifecycleEvent(elm, "componentWillLoad");
2298
- if (BUILD19.cmpWillLoad) {
2299
- maybePromise = safeCall(instance, "componentWillLoad");
2401
+ if (BUILD20.cmpWillLoad) {
2402
+ maybePromise = safeCall(instance, "componentWillLoad", void 0, elm);
2300
2403
  }
2301
2404
  } else {
2302
2405
  emitLifecycleEvent(elm, "componentWillUpdate");
2303
- if (BUILD19.cmpWillUpdate) {
2304
- maybePromise = safeCall(instance, "componentWillUpdate");
2406
+ if (BUILD20.cmpWillUpdate) {
2407
+ maybePromise = safeCall(instance, "componentWillUpdate", void 0, elm);
2305
2408
  }
2306
2409
  }
2307
2410
  emitLifecycleEvent(elm, "componentWillRender");
2308
- if (BUILD19.cmpWillRender) {
2309
- maybePromise = enqueue(maybePromise, () => safeCall(instance, "componentWillRender"));
2411
+ if (BUILD20.cmpWillRender) {
2412
+ maybePromise = enqueue(maybePromise, () => safeCall(instance, "componentWillRender", void 0, elm));
2310
2413
  }
2311
2414
  endSchedule();
2312
2415
  return enqueue(maybePromise, () => updateComponent(hostRef, instance, isInitialLoad));
@@ -2321,23 +2424,23 @@ var updateComponent = async (hostRef, instance, isInitialLoad) => {
2321
2424
  const elm = hostRef.$hostElement$;
2322
2425
  const endUpdate = createTime("update", hostRef.$cmpMeta$.$tagName$);
2323
2426
  const rc = elm["s-rc"];
2324
- if (BUILD19.style && isInitialLoad) {
2427
+ if (BUILD20.style && isInitialLoad) {
2325
2428
  attachStyles(hostRef);
2326
2429
  }
2327
2430
  const endRender = createTime("render", hostRef.$cmpMeta$.$tagName$);
2328
- if (BUILD19.isDev) {
2431
+ if (BUILD20.isDev) {
2329
2432
  hostRef.$flags$ |= 1024 /* devOnRender */;
2330
2433
  }
2331
- if (BUILD19.hydrateServerSide) {
2434
+ if (BUILD20.hydrateServerSide) {
2332
2435
  await callRender(hostRef, instance, elm, isInitialLoad);
2333
2436
  } else {
2334
2437
  callRender(hostRef, instance, elm, isInitialLoad);
2335
2438
  }
2336
- if (BUILD19.isDev) {
2439
+ if (BUILD20.isDev) {
2337
2440
  hostRef.$renderCount$ = hostRef.$renderCount$ === void 0 ? 1 : hostRef.$renderCount$ + 1;
2338
2441
  hostRef.$flags$ &= ~1024 /* devOnRender */;
2339
2442
  }
2340
- if (BUILD19.hydrateServerSide) {
2443
+ if (BUILD20.hydrateServerSide) {
2341
2444
  try {
2342
2445
  serverSideConnected(elm);
2343
2446
  if (isInitialLoad) {
@@ -2351,13 +2454,13 @@ var updateComponent = async (hostRef, instance, isInitialLoad) => {
2351
2454
  consoleError(e, elm);
2352
2455
  }
2353
2456
  }
2354
- if (BUILD19.asyncLoading && rc) {
2457
+ if (BUILD20.asyncLoading && rc) {
2355
2458
  rc.map((cb) => cb());
2356
2459
  elm["s-rc"] = void 0;
2357
2460
  }
2358
2461
  endRender();
2359
2462
  endUpdate();
2360
- if (BUILD19.asyncLoading) {
2463
+ if (BUILD20.asyncLoading) {
2361
2464
  const childrenPromises = (_a = elm["s-p"]) != null ? _a : [];
2362
2465
  const postUpdate = () => postUpdateComponent(hostRef);
2363
2466
  if (childrenPromises.length === 0) {
@@ -2373,10 +2476,10 @@ var updateComponent = async (hostRef, instance, isInitialLoad) => {
2373
2476
  };
2374
2477
  var renderingRef = null;
2375
2478
  var callRender = (hostRef, instance, elm, isInitialLoad) => {
2376
- const allRenderFn = BUILD19.allRenderFn ? true : false;
2377
- const lazyLoad = BUILD19.lazyLoad ? true : false;
2378
- const taskQueue = BUILD19.taskQueue ? true : false;
2379
- const updatable = BUILD19.updatable ? true : false;
2479
+ const allRenderFn = BUILD20.allRenderFn ? true : false;
2480
+ const lazyLoad = BUILD20.lazyLoad ? true : false;
2481
+ const taskQueue = BUILD20.taskQueue ? true : false;
2482
+ const updatable = BUILD20.updatable ? true : false;
2380
2483
  try {
2381
2484
  renderingRef = instance;
2382
2485
  instance = allRenderFn ? instance.render() : instance.render && instance.render();
@@ -2386,9 +2489,9 @@ var callRender = (hostRef, instance, elm, isInitialLoad) => {
2386
2489
  if (updatable || lazyLoad) {
2387
2490
  hostRef.$flags$ |= 2 /* hasRendered */;
2388
2491
  }
2389
- if (BUILD19.hasRenderFn || BUILD19.reflect) {
2390
- if (BUILD19.vdomRender || BUILD19.reflect) {
2391
- if (BUILD19.hydrateServerSide) {
2492
+ if (BUILD20.hasRenderFn || BUILD20.reflect) {
2493
+ if (BUILD20.vdomRender || BUILD20.reflect) {
2494
+ if (BUILD20.hydrateServerSide) {
2392
2495
  return Promise.resolve(instance).then((value) => renderVdom(hostRef, value, isInitialLoad));
2393
2496
  } else {
2394
2497
  renderVdom(hostRef, instance, isInitialLoad);
@@ -2413,57 +2516,57 @@ var postUpdateComponent = (hostRef) => {
2413
2516
  const tagName = hostRef.$cmpMeta$.$tagName$;
2414
2517
  const elm = hostRef.$hostElement$;
2415
2518
  const endPostUpdate = createTime("postUpdate", tagName);
2416
- const instance = BUILD19.lazyLoad ? hostRef.$lazyInstance$ : elm;
2519
+ const instance = BUILD20.lazyLoad ? hostRef.$lazyInstance$ : elm;
2417
2520
  const ancestorComponent = hostRef.$ancestorComponent$;
2418
- if (BUILD19.cmpDidRender) {
2419
- if (BUILD19.isDev) {
2521
+ if (BUILD20.cmpDidRender) {
2522
+ if (BUILD20.isDev) {
2420
2523
  hostRef.$flags$ |= 1024 /* devOnRender */;
2421
2524
  }
2422
- safeCall(instance, "componentDidRender");
2423
- if (BUILD19.isDev) {
2525
+ safeCall(instance, "componentDidRender", void 0, elm);
2526
+ if (BUILD20.isDev) {
2424
2527
  hostRef.$flags$ &= ~1024 /* devOnRender */;
2425
2528
  }
2426
2529
  }
2427
2530
  emitLifecycleEvent(elm, "componentDidRender");
2428
2531
  if (!(hostRef.$flags$ & 64 /* hasLoadedComponent */)) {
2429
2532
  hostRef.$flags$ |= 64 /* hasLoadedComponent */;
2430
- if (BUILD19.asyncLoading && BUILD19.cssAnnotations) {
2533
+ if (BUILD20.asyncLoading && BUILD20.cssAnnotations) {
2431
2534
  addHydratedFlag(elm);
2432
2535
  }
2433
- if (BUILD19.cmpDidLoad) {
2434
- if (BUILD19.isDev) {
2536
+ if (BUILD20.cmpDidLoad) {
2537
+ if (BUILD20.isDev) {
2435
2538
  hostRef.$flags$ |= 2048 /* devOnDidLoad */;
2436
2539
  }
2437
- safeCall(instance, "componentDidLoad");
2438
- if (BUILD19.isDev) {
2540
+ safeCall(instance, "componentDidLoad", void 0, elm);
2541
+ if (BUILD20.isDev) {
2439
2542
  hostRef.$flags$ &= ~2048 /* devOnDidLoad */;
2440
2543
  }
2441
2544
  }
2442
2545
  emitLifecycleEvent(elm, "componentDidLoad");
2443
2546
  endPostUpdate();
2444
- if (BUILD19.asyncLoading) {
2547
+ if (BUILD20.asyncLoading) {
2445
2548
  hostRef.$onReadyResolve$(elm);
2446
2549
  if (!ancestorComponent) {
2447
2550
  appDidLoad(tagName);
2448
2551
  }
2449
2552
  }
2450
2553
  } else {
2451
- if (BUILD19.cmpDidUpdate) {
2452
- if (BUILD19.isDev) {
2554
+ if (BUILD20.cmpDidUpdate) {
2555
+ if (BUILD20.isDev) {
2453
2556
  hostRef.$flags$ |= 1024 /* devOnRender */;
2454
2557
  }
2455
- safeCall(instance, "componentDidUpdate");
2456
- if (BUILD19.isDev) {
2558
+ safeCall(instance, "componentDidUpdate", void 0, elm);
2559
+ if (BUILD20.isDev) {
2457
2560
  hostRef.$flags$ &= ~1024 /* devOnRender */;
2458
2561
  }
2459
2562
  }
2460
2563
  emitLifecycleEvent(elm, "componentDidUpdate");
2461
2564
  endPostUpdate();
2462
2565
  }
2463
- if (BUILD19.method && BUILD19.lazyLoad) {
2566
+ if (BUILD20.method && BUILD20.lazyLoad) {
2464
2567
  hostRef.$onInstanceResolve$(elm);
2465
2568
  }
2466
- if (BUILD19.asyncLoading) {
2569
+ if (BUILD20.asyncLoading) {
2467
2570
  if (hostRef.$onRenderResolve$) {
2468
2571
  hostRef.$onRenderResolve$();
2469
2572
  hostRef.$onRenderResolve$ = void 0;
@@ -2475,7 +2578,7 @@ var postUpdateComponent = (hostRef) => {
2475
2578
  }
2476
2579
  };
2477
2580
  var forceUpdate = (ref) => {
2478
- if (BUILD19.updatable && (Build.isBrowser || Build.isTesting)) {
2581
+ if (BUILD20.updatable && (Build.isBrowser || Build.isTesting)) {
2479
2582
  const hostRef = getHostRef(ref);
2480
2583
  const isConnected = hostRef.$hostElement$.isConnected;
2481
2584
  if (isConnected && (hostRef.$flags$ & (2 /* hasRendered */ | 16 /* isQueuedForUpdate */)) === 2 /* hasRendered */) {
@@ -2486,29 +2589,26 @@ var forceUpdate = (ref) => {
2486
2589
  return false;
2487
2590
  };
2488
2591
  var appDidLoad = (who) => {
2489
- if (BUILD19.cssAnnotations) {
2490
- addHydratedFlag(doc.documentElement);
2491
- }
2492
- if (BUILD19.asyncQueue) {
2592
+ if (BUILD20.asyncQueue) {
2493
2593
  plt.$flags$ |= 2 /* appLoaded */;
2494
2594
  }
2495
2595
  nextTick(() => emitEvent(win, "appload", { detail: { namespace: NAMESPACE } }));
2496
- if (BUILD19.profile && performance.measure) {
2596
+ if (BUILD20.profile && performance.measure) {
2497
2597
  performance.measure(`[Rindo] ${NAMESPACE} initial load (by ${who})`, "st:app:start");
2498
2598
  }
2499
2599
  };
2500
- var safeCall = (instance, method, arg) => {
2600
+ var safeCall = (instance, method, arg, elm) => {
2501
2601
  if (instance && instance[method]) {
2502
2602
  try {
2503
2603
  return instance[method](arg);
2504
2604
  } catch (e) {
2505
- consoleError(e);
2605
+ consoleError(e, elm);
2506
2606
  }
2507
2607
  }
2508
2608
  return void 0;
2509
2609
  };
2510
2610
  var emitLifecycleEvent = (elm, lifecycleName) => {
2511
- if (BUILD19.lifecycleDOMEvents) {
2611
+ if (BUILD20.lifecycleDOMEvents) {
2512
2612
  emitEvent(elm, "rindo_" + lifecycleName, {
2513
2613
  bubbles: true,
2514
2614
  composed: true,
@@ -2520,7 +2620,7 @@ var emitLifecycleEvent = (elm, lifecycleName) => {
2520
2620
  };
2521
2621
  var addHydratedFlag = (elm) => {
2522
2622
  var _a, _b;
2523
- return BUILD19.hydratedClass ? elm.classList.add((_a = BUILD19.hydratedSelectorName) != null ? _a : "hydrated") : BUILD19.hydratedAttribute ? elm.setAttribute((_b = BUILD19.hydratedSelectorName) != null ? _b : "hydrated", "") : void 0;
2623
+ return BUILD20.hydratedClass ? elm.classList.add((_a = BUILD20.hydratedSelectorName) != null ? _a : "hydrated") : BUILD20.hydratedAttribute ? elm.setAttribute((_b = BUILD20.hydratedSelectorName) != null ? _b : "hydrated", "") : void 0;
2524
2624
  };
2525
2625
  var serverSideConnected = (elm) => {
2526
2626
  const children = elm.children;
@@ -2539,21 +2639,21 @@ var serverSideConnected = (elm) => {
2539
2639
  var getValue = (ref, propName) => getHostRef(ref).$instanceValues$.get(propName);
2540
2640
  var setValue = (ref, propName, newVal, cmpMeta) => {
2541
2641
  const hostRef = getHostRef(ref);
2542
- if (BUILD20.lazyLoad && !hostRef) {
2642
+ if (BUILD21.lazyLoad && !hostRef) {
2543
2643
  throw new Error(
2544
2644
  `Couldn't find host element for "${cmpMeta.$tagName$}" as it is unknown to this Rindo runtime. This usually happens when integrating a 3rd party Rindo component with another Rindo component or application.`
2545
2645
  );
2546
2646
  }
2547
- const elm = BUILD20.lazyLoad ? hostRef.$hostElement$ : ref;
2647
+ const elm = BUILD21.lazyLoad ? hostRef.$hostElement$ : ref;
2548
2648
  const oldVal = hostRef.$instanceValues$.get(propName);
2549
2649
  const flags = hostRef.$flags$;
2550
- const instance = BUILD20.lazyLoad ? hostRef.$lazyInstance$ : elm;
2650
+ const instance = BUILD21.lazyLoad ? hostRef.$lazyInstance$ : elm;
2551
2651
  newVal = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]);
2552
2652
  const areBothNaN = Number.isNaN(oldVal) && Number.isNaN(newVal);
2553
2653
  const didValueChange = newVal !== oldVal && !areBothNaN;
2554
- if ((!BUILD20.lazyLoad || !(flags & 8 /* isConstructingInstance */) || oldVal === void 0) && didValueChange) {
2654
+ if ((!BUILD21.lazyLoad || !(flags & 8 /* isConstructingInstance */) || oldVal === void 0) && didValueChange) {
2555
2655
  hostRef.$instanceValues$.set(propName, newVal);
2556
- if (BUILD20.isDev) {
2656
+ if (BUILD21.isDev) {
2557
2657
  if (hostRef.$flags$ & 1024 /* devOnRender */) {
2558
2658
  consoleDevWarn(
2559
2659
  `The state/prop "${propName}" changed during rendering. This can potentially lead to infinite-loops and other bugs.`,
@@ -2576,8 +2676,8 @@ var setValue = (ref, propName, newVal, cmpMeta) => {
2576
2676
  );
2577
2677
  }
2578
2678
  }
2579
- if (!BUILD20.lazyLoad || instance) {
2580
- if (BUILD20.watchCallback && cmpMeta.$watchers$ && flags & 128 /* isWatchReady */) {
2679
+ if (!BUILD21.lazyLoad || instance) {
2680
+ if (BUILD21.watchCallback && cmpMeta.$watchers$ && flags & 128 /* isWatchReady */) {
2581
2681
  const watchMethods = cmpMeta.$watchers$[propName];
2582
2682
  if (watchMethods) {
2583
2683
  watchMethods.map((watchMethodName) => {
@@ -2589,8 +2689,8 @@ var setValue = (ref, propName, newVal, cmpMeta) => {
2589
2689
  });
2590
2690
  }
2591
2691
  }
2592
- if (BUILD20.updatable && (flags & (2 /* hasRendered */ | 16 /* isQueuedForUpdate */)) === 2 /* hasRendered */) {
2593
- if (BUILD20.cmpShouldUpdate && instance.componentShouldUpdate) {
2692
+ if (BUILD21.updatable && (flags & (2 /* hasRendered */ | 16 /* isQueuedForUpdate */)) === 2 /* hasRendered */) {
2693
+ if (BUILD21.cmpShouldUpdate && instance.componentShouldUpdate) {
2594
2694
  if (instance.componentShouldUpdate(newVal, oldVal, propName) === false) {
2595
2695
  return;
2596
2696
  }
@@ -2605,105 +2705,125 @@ var setValue = (ref, propName, newVal, cmpMeta) => {
2605
2705
  var proxyComponent = (Cstr, cmpMeta, flags) => {
2606
2706
  var _a, _b;
2607
2707
  const prototype = Cstr.prototype;
2608
- if (BUILD21.formAssociated && cmpMeta.$flags$ & 64 /* formAssociated */ && flags & 1 /* isElementConstructor */) {
2708
+ if (BUILD22.isTesting) {
2709
+ if (prototype.__rindoAugmented) {
2710
+ return;
2711
+ }
2712
+ prototype.__rindoAugmented = true;
2713
+ }
2714
+ if (BUILD22.formAssociated && cmpMeta.$flags$ & 64 /* formAssociated */ && flags & 1 /* isElementConstructor */) {
2609
2715
  FORM_ASSOCIATED_CUSTOM_ELEMENT_CALLBACKS.forEach((cbName) => {
2610
2716
  const originalFormAssociatedCallback = prototype[cbName];
2611
2717
  Object.defineProperty(prototype, cbName, {
2612
2718
  value(...args) {
2613
2719
  const hostRef = getHostRef(this);
2614
- const instance = BUILD21.lazyLoad ? hostRef.$lazyInstance$ : this;
2720
+ const instance = BUILD22.lazyLoad ? hostRef.$lazyInstance$ : this;
2615
2721
  if (!instance) {
2616
2722
  hostRef.$onReadyPromise$.then((asyncInstance) => {
2617
2723
  const cb = asyncInstance[cbName];
2618
2724
  typeof cb === "function" && cb.call(asyncInstance, ...args);
2619
2725
  });
2620
2726
  } else {
2621
- const cb = BUILD21.lazyLoad ? instance[cbName] : originalFormAssociatedCallback;
2727
+ const cb = BUILD22.lazyLoad ? instance[cbName] : originalFormAssociatedCallback;
2622
2728
  typeof cb === "function" && cb.call(instance, ...args);
2623
2729
  }
2624
2730
  }
2625
2731
  });
2626
2732
  });
2627
2733
  }
2628
- if (BUILD21.member && cmpMeta.$members$ || BUILD21.watchCallback && (cmpMeta.$watchers$ || Cstr.watchers)) {
2629
- if (BUILD21.watchCallback && Cstr.watchers && !cmpMeta.$watchers$) {
2734
+ if (BUILD22.member && cmpMeta.$members$ || BUILD22.watchCallback && (cmpMeta.$watchers$ || Cstr.watchers)) {
2735
+ if (BUILD22.watchCallback && Cstr.watchers && !cmpMeta.$watchers$) {
2630
2736
  cmpMeta.$watchers$ = Cstr.watchers;
2631
2737
  }
2632
2738
  const members = Object.entries((_a = cmpMeta.$members$) != null ? _a : {});
2633
2739
  members.map(([memberName, [memberFlags]]) => {
2634
- if ((BUILD21.prop || BUILD21.state) && (memberFlags & 31 /* Prop */ || (!BUILD21.lazyLoad || flags & 2 /* proxyState */) && memberFlags & 32 /* State */)) {
2635
- if ((memberFlags & 2048 /* Getter */) === 0) {
2740
+ if ((BUILD22.prop || BUILD22.state) && (memberFlags & 31 /* Prop */ || (!BUILD22.lazyLoad || flags & 2 /* proxyState */) && memberFlags & 32 /* State */)) {
2741
+ const { get: origGetter, set: origSetter } = Object.getOwnPropertyDescriptor(prototype, memberName) || {};
2742
+ if (origGetter) cmpMeta.$members$[memberName][0] |= 2048 /* Getter */;
2743
+ if (origSetter) cmpMeta.$members$[memberName][0] |= 4096 /* Setter */;
2744
+ if (flags & 1 /* isElementConstructor */ || !origGetter) {
2636
2745
  Object.defineProperty(prototype, memberName, {
2637
2746
  get() {
2638
- return getValue(this, memberName);
2639
- },
2640
- set(newValue) {
2641
- if (BUILD21.isDev) {
2642
- const ref = getHostRef(this);
2643
- if (
2644
- // we are proxying the instance (not element)
2645
- (flags & 1 /* isElementConstructor */) === 0 && // the element is not constructing
2646
- (ref && ref.$flags$ & 8 /* isConstructingInstance */) === 0 && // the member is a prop
2647
- (memberFlags & 31 /* Prop */) !== 0 && // the member is not mutable
2648
- (memberFlags & 1024 /* Mutable */) === 0
2649
- ) {
2650
- consoleDevWarn(
2651
- `@Prop() "${memberName}" on <${cmpMeta.$tagName$}> is immutable but was modified from within the component.
2652
- More information: https://rindojs.web.app/docs/properties#prop-mutability`
2653
- );
2747
+ if (BUILD22.lazyLoad) {
2748
+ if ((cmpMeta.$members$[memberName][0] & 2048 /* Getter */) === 0) {
2749
+ return getValue(this, memberName);
2654
2750
  }
2751
+ const ref = getHostRef(this);
2752
+ const instance = ref ? ref.$lazyInstance$ : prototype;
2753
+ if (!instance) return;
2754
+ return instance[memberName];
2755
+ }
2756
+ if (!BUILD22.lazyLoad) {
2757
+ return origGetter ? origGetter.apply(this) : getValue(this, memberName);
2655
2758
  }
2656
- setValue(this, memberName, newValue, cmpMeta);
2657
2759
  },
2658
2760
  configurable: true,
2659
2761
  enumerable: true
2660
2762
  });
2661
- } else if (flags & 1 /* isElementConstructor */ && memberFlags & 2048 /* Getter */) {
2662
- if (BUILD21.lazyLoad) {
2663
- Object.defineProperty(prototype, memberName, {
2664
- get() {
2665
- const ref = getHostRef(this);
2666
- const instance = BUILD21.lazyLoad && ref ? ref.$lazyInstance$ : prototype;
2667
- if (!instance) return;
2668
- return instance[memberName];
2669
- },
2670
- configurable: true,
2671
- enumerable: true
2672
- });
2673
- }
2674
- if (memberFlags & 4096 /* Setter */) {
2675
- const origSetter = Object.getOwnPropertyDescriptor(prototype, memberName).set;
2676
- Object.defineProperty(prototype, memberName, {
2677
- set(newValue) {
2678
- const ref = getHostRef(this);
2679
- if (origSetter) {
2680
- const currentValue = ref.$hostElement$[memberName];
2681
- if (!ref.$instanceValues$.get(memberName) && currentValue) {
2682
- ref.$instanceValues$.set(memberName, currentValue);
2683
- }
2684
- origSetter.apply(this, [parsePropertyValue(newValue, cmpMeta.$members$[memberName][0])]);
2685
- setValue(this, memberName, ref.$hostElement$[memberName], cmpMeta);
2686
- return;
2763
+ }
2764
+ Object.defineProperty(prototype, memberName, {
2765
+ set(newValue) {
2766
+ const ref = getHostRef(this);
2767
+ if (BUILD22.isDev) {
2768
+ if (
2769
+ // we are proxying the instance (not element)
2770
+ (flags & 1 /* isElementConstructor */) === 0 && // if the class has a setter, then the Element can update instance values, so ignore
2771
+ (cmpMeta.$members$[memberName][0] & 4096 /* Setter */) === 0 && // the element is not constructing
2772
+ (ref && ref.$flags$ & 8 /* isConstructingInstance */) === 0 && // the member is a prop
2773
+ (memberFlags & 31 /* Prop */) !== 0 && // the member is not mutable
2774
+ (memberFlags & 1024 /* Mutable */) === 0
2775
+ ) {
2776
+ consoleDevWarn(
2777
+ `@Prop() "${memberName}" on <${cmpMeta.$tagName$}> is immutable but was modified from within the component.
2778
+ More information: https://rindojs.web.app/docs/properties#prop-mutability`
2779
+ );
2780
+ }
2781
+ }
2782
+ if (origSetter) {
2783
+ const currentValue = memberFlags & 32 /* State */ ? this[memberName] : ref.$hostElement$[memberName];
2784
+ if (typeof currentValue === "undefined" && ref.$instanceValues$.get(memberName)) {
2785
+ newValue = ref.$instanceValues$.get(memberName);
2786
+ } else if (!ref.$instanceValues$.get(memberName) && currentValue) {
2787
+ ref.$instanceValues$.set(memberName, currentValue);
2788
+ }
2789
+ origSetter.apply(this, [parsePropertyValue(newValue, memberFlags)]);
2790
+ newValue = memberFlags & 32 /* State */ ? this[memberName] : ref.$hostElement$[memberName];
2791
+ setValue(this, memberName, newValue, cmpMeta);
2792
+ return;
2793
+ }
2794
+ if (!BUILD22.lazyLoad) {
2795
+ setValue(this, memberName, newValue, cmpMeta);
2796
+ return;
2797
+ }
2798
+ if (BUILD22.lazyLoad) {
2799
+ if ((flags & 1 /* isElementConstructor */) === 0 || (cmpMeta.$members$[memberName][0] & 4096 /* Setter */) === 0) {
2800
+ setValue(this, memberName, newValue, cmpMeta);
2801
+ if (flags & 1 /* isElementConstructor */ && !ref.$lazyInstance$) {
2802
+ ref.$onReadyPromise$.then(() => {
2803
+ if (cmpMeta.$members$[memberName][0] & 4096 /* Setter */ && ref.$lazyInstance$[memberName] !== ref.$instanceValues$.get(memberName)) {
2804
+ ref.$lazyInstance$[memberName] = newValue;
2805
+ }
2806
+ });
2687
2807
  }
2688
- if (!ref) return;
2689
- const setterSetVal = () => {
2690
- const currentValue = ref.$lazyInstance$[memberName];
2691
- if (!ref.$instanceValues$.get(memberName) && currentValue) {
2692
- ref.$instanceValues$.set(memberName, currentValue);
2693
- }
2694
- ref.$lazyInstance$[memberName] = parsePropertyValue(newValue, cmpMeta.$members$[memberName][0]);
2695
- setValue(this, memberName, ref.$lazyInstance$[memberName], cmpMeta);
2696
- };
2697
- if (ref.$lazyInstance$) {
2698
- setterSetVal();
2699
- } else {
2700
- ref.$onReadyPromise$.then(() => setterSetVal());
2808
+ return;
2809
+ }
2810
+ const setterSetVal = () => {
2811
+ const currentValue = ref.$lazyInstance$[memberName];
2812
+ if (!ref.$instanceValues$.get(memberName) && currentValue) {
2813
+ ref.$instanceValues$.set(memberName, currentValue);
2701
2814
  }
2815
+ ref.$lazyInstance$[memberName] = parsePropertyValue(newValue, memberFlags);
2816
+ setValue(this, memberName, ref.$lazyInstance$[memberName], cmpMeta);
2817
+ };
2818
+ if (ref.$lazyInstance$) {
2819
+ setterSetVal();
2820
+ } else {
2821
+ ref.$onReadyPromise$.then(() => setterSetVal());
2702
2822
  }
2703
- });
2823
+ }
2704
2824
  }
2705
- }
2706
- } else if (BUILD21.lazyLoad && BUILD21.method && flags & 1 /* isElementConstructor */ && memberFlags & 64 /* Method */) {
2825
+ });
2826
+ } else if (BUILD22.lazyLoad && BUILD22.method && flags & 1 /* isElementConstructor */ && memberFlags & 64 /* Method */) {
2707
2827
  Object.defineProperty(prototype, memberName, {
2708
2828
  value(...args) {
2709
2829
  var _a2;
@@ -2716,13 +2836,13 @@ More information: https://rindojs.web.app/docs/properties#prop-mutability`
2716
2836
  });
2717
2837
  }
2718
2838
  });
2719
- if (BUILD21.observeAttribute && (!BUILD21.lazyLoad || flags & 1 /* isElementConstructor */)) {
2839
+ if (BUILD22.observeAttribute && (!BUILD22.lazyLoad || flags & 1 /* isElementConstructor */)) {
2720
2840
  const attrNameToPropName = /* @__PURE__ */ new Map();
2721
2841
  prototype.attributeChangedCallback = function(attrName, oldValue, newValue) {
2722
2842
  plt.jmp(() => {
2723
2843
  var _a2;
2724
2844
  const propName = attrNameToPropName.get(attrName);
2725
- if (this.hasOwnProperty(propName) && BUILD21.lazyLoad) {
2845
+ if (this.hasOwnProperty(propName) && BUILD22.lazyLoad) {
2726
2846
  newValue = this[propName];
2727
2847
  delete this[propName];
2728
2848
  } else if (prototype.hasOwnProperty(propName) && typeof this[propName] === "number" && // cast type to number to avoid TS compiler issues
@@ -2732,8 +2852,8 @@ More information: https://rindojs.web.app/docs/properties#prop-mutability`
2732
2852
  const hostRef = getHostRef(this);
2733
2853
  const flags2 = hostRef == null ? void 0 : hostRef.$flags$;
2734
2854
  if (flags2 && !(flags2 & 8 /* isConstructingInstance */) && flags2 & 128 /* isWatchReady */ && newValue !== oldValue) {
2735
- const elm = BUILD21.lazyLoad ? hostRef.$hostElement$ : this;
2736
- const instance = BUILD21.lazyLoad ? hostRef.$lazyInstance$ : elm;
2855
+ const elm = BUILD22.lazyLoad ? hostRef.$hostElement$ : this;
2856
+ const instance = BUILD22.lazyLoad ? hostRef.$lazyInstance$ : elm;
2737
2857
  const entry = (_a2 = cmpMeta.$watchers$) == null ? void 0 : _a2[attrName];
2738
2858
  entry == null ? void 0 : entry.forEach((callbackName) => {
2739
2859
  if (instance[callbackName] != null) {
@@ -2744,8 +2864,9 @@ More information: https://rindojs.web.app/docs/properties#prop-mutability`
2744
2864
  return;
2745
2865
  }
2746
2866
  const propDesc = Object.getOwnPropertyDescriptor(prototype, propName);
2747
- if (!propDesc.get || !!propDesc.set) {
2748
- this[propName] = newValue === null && typeof this[propName] === "boolean" ? false : newValue;
2867
+ newValue = newValue === null && typeof this[propName] === "boolean" ? false : newValue;
2868
+ if (newValue !== this[propName] && (!propDesc.get || !!propDesc.set)) {
2869
+ this[propName] = newValue;
2749
2870
  }
2750
2871
  });
2751
2872
  };
@@ -2756,7 +2877,7 @@ More information: https://rindojs.web.app/docs/properties#prop-mutability`
2756
2877
  var _a2;
2757
2878
  const attrName = m[1] || propName;
2758
2879
  attrNameToPropName.set(attrName, propName);
2759
- if (BUILD21.reflect && m[0] & 512 /* ReflectAttr */) {
2880
+ if (BUILD22.reflect && m[0] & 512 /* ReflectAttr */) {
2760
2881
  (_a2 = cmpMeta.$attrsToReflect$) == null ? void 0 : _a2.push([propName, attrName]);
2761
2882
  }
2762
2883
  return attrName;
@@ -2774,7 +2895,7 @@ var initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId) => {
2774
2895
  if ((hostRef.$flags$ & 32 /* hasInitializedComponent */) === 0) {
2775
2896
  hostRef.$flags$ |= 32 /* hasInitializedComponent */;
2776
2897
  const bundleId = cmpMeta.$lazyBundleId$;
2777
- if ((BUILD22.lazyLoad || BUILD22.hydrateClientSide) && bundleId) {
2898
+ if (BUILD23.lazyLoad && bundleId) {
2778
2899
  const CstrImport = loadModule(cmpMeta, hostRef, hmrVersionId);
2779
2900
  if (CstrImport && "then" in CstrImport) {
2780
2901
  const endLoad = uniqueTime(
@@ -2789,53 +2910,53 @@ var initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId) => {
2789
2910
  if (!Cstr) {
2790
2911
  throw new Error(`Constructor for "${cmpMeta.$tagName$}#${hostRef.$modeName$}" was not found`);
2791
2912
  }
2792
- if (BUILD22.member && !Cstr.isProxied) {
2793
- if (BUILD22.watchCallback) {
2913
+ if (BUILD23.member && !Cstr.isProxied) {
2914
+ if (BUILD23.watchCallback) {
2794
2915
  cmpMeta.$watchers$ = Cstr.watchers;
2795
2916
  }
2796
2917
  proxyComponent(Cstr, cmpMeta, 2 /* proxyState */);
2797
2918
  Cstr.isProxied = true;
2798
2919
  }
2799
2920
  const endNewInstance = createTime("createInstance", cmpMeta.$tagName$);
2800
- if (BUILD22.member) {
2921
+ if (BUILD23.member) {
2801
2922
  hostRef.$flags$ |= 8 /* isConstructingInstance */;
2802
2923
  }
2803
2924
  try {
2804
2925
  new Cstr(hostRef);
2805
2926
  } catch (e) {
2806
- consoleError(e);
2927
+ consoleError(e, elm);
2807
2928
  }
2808
- if (BUILD22.member) {
2929
+ if (BUILD23.member) {
2809
2930
  hostRef.$flags$ &= ~8 /* isConstructingInstance */;
2810
2931
  }
2811
- if (BUILD22.watchCallback) {
2932
+ if (BUILD23.watchCallback) {
2812
2933
  hostRef.$flags$ |= 128 /* isWatchReady */;
2813
2934
  }
2814
2935
  endNewInstance();
2815
- fireConnectedCallback(hostRef.$lazyInstance$);
2936
+ fireConnectedCallback(hostRef.$lazyInstance$, elm);
2816
2937
  } else {
2817
2938
  Cstr = elm.constructor;
2818
2939
  const cmpTag = elm.localName;
2819
2940
  customElements.whenDefined(cmpTag).then(() => hostRef.$flags$ |= 128 /* isWatchReady */);
2820
2941
  }
2821
- if (BUILD22.style && Cstr && Cstr.style) {
2942
+ if (BUILD23.style && Cstr && Cstr.style) {
2822
2943
  let style;
2823
2944
  if (typeof Cstr.style === "string") {
2824
2945
  style = Cstr.style;
2825
- } else if (BUILD22.mode && typeof Cstr.style !== "string") {
2946
+ } else if (BUILD23.mode && typeof Cstr.style !== "string") {
2826
2947
  hostRef.$modeName$ = computeMode(elm);
2827
2948
  if (hostRef.$modeName$) {
2828
2949
  style = Cstr.style[hostRef.$modeName$];
2829
2950
  }
2830
- if (BUILD22.hydrateServerSide && hostRef.$modeName$) {
2951
+ if (BUILD23.hydrateServerSide && hostRef.$modeName$) {
2831
2952
  elm.setAttribute("s-mode", hostRef.$modeName$);
2832
2953
  }
2833
2954
  }
2834
2955
  const scopeId2 = getScopeId(cmpMeta, hostRef.$modeName$);
2835
2956
  if (!styles.has(scopeId2)) {
2836
2957
  const endRegisterStyles = createTime("registerStyles", cmpMeta.$tagName$);
2837
- if (!BUILD22.hydrateServerSide && BUILD22.shadowDom && // TODO(RINDO-854): Remove code related to legacy shadowDomShim field
2838
- BUILD22.shadowDomShim && cmpMeta.$flags$ & 8 /* needsShadowDomShim */) {
2958
+ if (!BUILD23.hydrateServerSide && BUILD23.shadowDom && // TODO(RINDO-854): Remove code related to legacy shadowDomShim field
2959
+ BUILD23.shadowDomShim && cmpMeta.$flags$ & 8 /* needsShadowDomShim */) {
2839
2960
  style = await import("./shadow-css.js").then((m) => m.scopeCss(style, scopeId2));
2840
2961
  }
2841
2962
  registerStyle(scopeId2, style, !!(cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */));
@@ -2845,15 +2966,15 @@ var initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId) => {
2845
2966
  }
2846
2967
  const ancestorComponent = hostRef.$ancestorComponent$;
2847
2968
  const schedule = () => scheduleUpdate(hostRef, true);
2848
- if (BUILD22.asyncLoading && ancestorComponent && ancestorComponent["s-rc"]) {
2969
+ if (BUILD23.asyncLoading && ancestorComponent && ancestorComponent["s-rc"]) {
2849
2970
  ancestorComponent["s-rc"].push(schedule);
2850
2971
  } else {
2851
2972
  schedule();
2852
2973
  }
2853
2974
  };
2854
- var fireConnectedCallback = (instance) => {
2855
- if (BUILD22.lazyLoad && BUILD22.connectedCallback) {
2856
- safeCall(instance, "connectedCallback");
2975
+ var fireConnectedCallback = (instance, elm) => {
2976
+ if (BUILD23.lazyLoad && BUILD23.connectedCallback) {
2977
+ safeCall(instance, "connectedCallback", void 0, elm);
2857
2978
  }
2858
2979
  };
2859
2980
 
@@ -2863,41 +2984,41 @@ var connectedCallback = (elm) => {
2863
2984
  const hostRef = getHostRef(elm);
2864
2985
  const cmpMeta = hostRef.$cmpMeta$;
2865
2986
  const endConnected = createTime("connectedCallback", cmpMeta.$tagName$);
2866
- if (BUILD23.hostListenerTargetParent) {
2987
+ if (BUILD24.hostListenerTargetParent) {
2867
2988
  addHostEventListeners(elm, hostRef, cmpMeta.$listeners$, true);
2868
2989
  }
2869
2990
  if (!(hostRef.$flags$ & 1 /* hasConnected */)) {
2870
2991
  hostRef.$flags$ |= 1 /* hasConnected */;
2871
2992
  let hostId;
2872
- if (BUILD23.hydrateClientSide) {
2993
+ if (BUILD24.hydrateClientSide) {
2873
2994
  hostId = elm.getAttribute(HYDRATE_ID);
2874
2995
  if (hostId) {
2875
- if (BUILD23.shadowDom && supportsShadow && cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) {
2876
- const scopeId2 = BUILD23.mode ? addStyle(elm.shadowRoot, cmpMeta, elm.getAttribute("s-mode")) : addStyle(elm.shadowRoot, cmpMeta);
2996
+ if (BUILD24.shadowDom && supportsShadow && cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) {
2997
+ const scopeId2 = BUILD24.mode ? addStyle(elm.shadowRoot, cmpMeta, elm.getAttribute("s-mode")) : addStyle(elm.shadowRoot, cmpMeta);
2877
2998
  elm.classList.remove(scopeId2 + "-h", scopeId2 + "-s");
2878
- } else if (BUILD23.scoped && cmpMeta.$flags$ & 2 /* scopedCssEncapsulation */) {
2879
- const scopeId2 = getScopeId(cmpMeta, BUILD23.mode ? elm.getAttribute("s-mode") : void 0);
2999
+ } else if (BUILD24.scoped && cmpMeta.$flags$ & 2 /* scopedCssEncapsulation */) {
3000
+ const scopeId2 = getScopeId(cmpMeta, BUILD24.mode ? elm.getAttribute("s-mode") : void 0);
2880
3001
  elm["s-sc"] = scopeId2;
2881
3002
  }
2882
3003
  initializeClientHydrate(elm, cmpMeta.$tagName$, hostId, hostRef);
2883
3004
  }
2884
3005
  }
2885
- if (BUILD23.slotRelocation && !hostId) {
2886
- if (BUILD23.hydrateServerSide || (BUILD23.slot || BUILD23.shadowDom) && // TODO(RINDO-854): Remove code related to legacy shadowDomShim field
3006
+ if (BUILD24.slotRelocation && !hostId) {
3007
+ if (BUILD24.hydrateServerSide || (BUILD24.slot || BUILD24.shadowDom) && // TODO(RINDO-854): Remove code related to legacy shadowDomShim field
2887
3008
  cmpMeta.$flags$ & (4 /* hasSlotRelocation */ | 8 /* needsShadowDomShim */)) {
2888
3009
  setContentReference(elm);
2889
3010
  }
2890
3011
  }
2891
- if (BUILD23.asyncLoading) {
3012
+ if (BUILD24.asyncLoading) {
2892
3013
  let ancestorComponent = elm;
2893
3014
  while (ancestorComponent = ancestorComponent.parentNode || ancestorComponent.host) {
2894
- if (BUILD23.hydrateClientSide && ancestorComponent.nodeType === 1 /* ElementNode */ && ancestorComponent.hasAttribute("s-id") && ancestorComponent["s-p"] || ancestorComponent["s-p"]) {
3015
+ if (BUILD24.hydrateClientSide && ancestorComponent.nodeType === 1 /* ElementNode */ && ancestorComponent.hasAttribute("s-id") && ancestorComponent["s-p"] || ancestorComponent["s-p"]) {
2895
3016
  attachToAncestor(hostRef, hostRef.$ancestorComponent$ = ancestorComponent);
2896
3017
  break;
2897
3018
  }
2898
3019
  }
2899
3020
  }
2900
- if (BUILD23.prop && !BUILD23.hydrateServerSide && cmpMeta.$members$) {
3021
+ if (BUILD24.prop && !BUILD24.hydrateServerSide && cmpMeta.$members$) {
2901
3022
  Object.entries(cmpMeta.$members$).map(([memberName, [memberFlags]]) => {
2902
3023
  if (memberFlags & 31 /* Prop */ && elm.hasOwnProperty(memberName)) {
2903
3024
  const value = elm[memberName];
@@ -2906,7 +3027,7 @@ var connectedCallback = (elm) => {
2906
3027
  }
2907
3028
  });
2908
3029
  }
2909
- if (BUILD23.initializeNextTick) {
3030
+ if (BUILD24.initializeNextTick) {
2910
3031
  nextTick(() => initializeComponent(elm, hostRef, cmpMeta));
2911
3032
  } else {
2912
3033
  initializeComponent(elm, hostRef, cmpMeta);
@@ -2914,9 +3035,9 @@ var connectedCallback = (elm) => {
2914
3035
  } else {
2915
3036
  addHostEventListeners(elm, hostRef, cmpMeta.$listeners$, false);
2916
3037
  if (hostRef == null ? void 0 : hostRef.$lazyInstance$) {
2917
- fireConnectedCallback(hostRef.$lazyInstance$);
3038
+ fireConnectedCallback(hostRef.$lazyInstance$, elm);
2918
3039
  } else if (hostRef == null ? void 0 : hostRef.$onReadyPromise$) {
2919
- hostRef.$onReadyPromise$.then(() => fireConnectedCallback(hostRef.$lazyInstance$));
3040
+ hostRef.$onReadyPromise$.then(() => fireConnectedCallback(hostRef.$lazyInstance$, elm));
2920
3041
  }
2921
3042
  }
2922
3043
  endConnected();
@@ -2924,37 +3045,37 @@ var connectedCallback = (elm) => {
2924
3045
  };
2925
3046
  var setContentReference = (elm) => {
2926
3047
  const contentRefElm = elm["s-cr"] = doc.createComment(
2927
- BUILD23.isDebug ? `content-ref (host=${elm.localName})` : ""
3048
+ BUILD24.isDebug ? `content-ref (host=${elm.localName})` : ""
2928
3049
  );
2929
3050
  contentRefElm["s-cn"] = true;
2930
3051
  insertBefore(elm, contentRefElm, elm.firstChild);
2931
3052
  };
2932
3053
 
2933
3054
  // src/runtime/disconnected-callback.ts
2934
- import { BUILD as BUILD24 } from "@rindo/core/internal/app-data";
2935
- var disconnectInstance = (instance) => {
2936
- if (BUILD24.lazyLoad && BUILD24.disconnectedCallback) {
2937
- safeCall(instance, "disconnectedCallback");
3055
+ import { BUILD as BUILD25 } from "@rindo/core/internal/app-data";
3056
+ var disconnectInstance = (instance, elm) => {
3057
+ if (BUILD25.lazyLoad && BUILD25.disconnectedCallback) {
3058
+ safeCall(instance, "disconnectedCallback", void 0, elm || instance);
2938
3059
  }
2939
- if (BUILD24.cmpDidUnload) {
2940
- safeCall(instance, "componentDidUnload");
3060
+ if (BUILD25.cmpDidUnload) {
3061
+ safeCall(instance, "componentDidUnload", void 0, elm || instance);
2941
3062
  }
2942
3063
  };
2943
3064
  var disconnectedCallback = async (elm) => {
2944
3065
  if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0) {
2945
3066
  const hostRef = getHostRef(elm);
2946
- if (BUILD24.hostListener) {
3067
+ if (BUILD25.hostListener) {
2947
3068
  if (hostRef.$rmListeners$) {
2948
3069
  hostRef.$rmListeners$.map((rmListener) => rmListener());
2949
3070
  hostRef.$rmListeners$ = void 0;
2950
3071
  }
2951
3072
  }
2952
- if (!BUILD24.lazyLoad) {
3073
+ if (!BUILD25.lazyLoad) {
2953
3074
  disconnectInstance(elm);
2954
3075
  } else if (hostRef == null ? void 0 : hostRef.$lazyInstance$) {
2955
- disconnectInstance(hostRef.$lazyInstance$);
3076
+ disconnectInstance(hostRef.$lazyInstance$, elm);
2956
3077
  } else if (hostRef == null ? void 0 : hostRef.$onReadyPromise$) {
2957
- hostRef.$onReadyPromise$.then(() => disconnectInstance(hostRef.$lazyInstance$));
3078
+ hostRef.$onReadyPromise$.then(() => disconnectInstance(hostRef.$lazyInstance$, elm));
2958
3079
  }
2959
3080
  }
2960
3081
  if (rootAppliedStyles.has(elm)) {
@@ -2974,36 +3095,36 @@ var proxyCustomElement = (Cstr, compactMeta) => {
2974
3095
  $flags$: compactMeta[0],
2975
3096
  $tagName$: compactMeta[1]
2976
3097
  };
2977
- if (BUILD25.member) {
3098
+ if (BUILD26.member) {
2978
3099
  cmpMeta.$members$ = compactMeta[2];
2979
3100
  }
2980
- if (BUILD25.hostListener) {
3101
+ if (BUILD26.hostListener) {
2981
3102
  cmpMeta.$listeners$ = compactMeta[3];
2982
3103
  }
2983
- if (BUILD25.watchCallback) {
3104
+ if (BUILD26.watchCallback) {
2984
3105
  cmpMeta.$watchers$ = Cstr.$watchers$;
2985
3106
  }
2986
- if (BUILD25.reflect) {
3107
+ if (BUILD26.reflect) {
2987
3108
  cmpMeta.$attrsToReflect$ = [];
2988
3109
  }
2989
- if (BUILD25.shadowDom && !supportsShadow && cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) {
3110
+ if (BUILD26.shadowDom && !supportsShadow && cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) {
2990
3111
  cmpMeta.$flags$ |= 8 /* needsShadowDomShim */;
2991
3112
  }
2992
- if (BUILD25.experimentalSlotFixes) {
2993
- if (BUILD25.scoped && cmpMeta.$flags$ & 2 /* scopedCssEncapsulation */) {
3113
+ if (BUILD26.experimentalSlotFixes) {
3114
+ if (BUILD26.scoped && cmpMeta.$flags$ & 2 /* scopedCssEncapsulation */) {
2994
3115
  patchPseudoShadowDom(Cstr.prototype);
2995
3116
  }
2996
3117
  } else {
2997
- if (BUILD25.slotChildNodesFix) {
3118
+ if (BUILD26.slotChildNodesFix) {
2998
3119
  patchChildSlotNodes(Cstr.prototype);
2999
3120
  }
3000
- if (BUILD25.cloneNodeFix) {
3121
+ if (BUILD26.cloneNodeFix) {
3001
3122
  patchCloneNode(Cstr.prototype);
3002
3123
  }
3003
- if (BUILD25.appendChildSlotFix) {
3124
+ if (BUILD26.appendChildSlotFix) {
3004
3125
  patchSlotAppendChild(Cstr.prototype);
3005
3126
  }
3006
- if (BUILD25.scopedSlotTextContentFix && cmpMeta.$flags$ & 2 /* scopedCssEncapsulation */) {
3127
+ if (BUILD26.scopedSlotTextContentFix && cmpMeta.$flags$ & 2 /* scopedCssEncapsulation */) {
3007
3128
  patchTextContent(Cstr.prototype);
3008
3129
  }
3009
3130
  }
@@ -3021,13 +3142,13 @@ var proxyCustomElement = (Cstr, compactMeta) => {
3021
3142
  this.__hasHostListenerAttached = true;
3022
3143
  }
3023
3144
  connectedCallback(this);
3024
- if (BUILD25.connectedCallback && originalConnectedCallback) {
3145
+ if (BUILD26.connectedCallback && originalConnectedCallback) {
3025
3146
  originalConnectedCallback.call(this);
3026
3147
  }
3027
3148
  },
3028
3149
  disconnectedCallback() {
3029
3150
  disconnectedCallback(this);
3030
- if (BUILD25.disconnectedCallback && originalDisconnectedCallback) {
3151
+ if (BUILD26.disconnectedCallback && originalDisconnectedCallback) {
3031
3152
  originalDisconnectedCallback.call(this);
3032
3153
  }
3033
3154
  plt.raf(() => {
@@ -3044,7 +3165,7 @@ var proxyCustomElement = (Cstr, compactMeta) => {
3044
3165
  __attachShadow() {
3045
3166
  if (supportsShadow) {
3046
3167
  if (!this.shadowRoot) {
3047
- if (BUILD25.shadowDelegatesFocus) {
3168
+ if (BUILD26.shadowDelegatesFocus) {
3048
3169
  this.attachShadow({
3049
3170
  mode: "open",
3050
3171
  delegatesFocus: !!(cmpMeta.$flags$ & 16 /* shadowDelegatesFocus */)
@@ -3068,7 +3189,7 @@ var proxyCustomElement = (Cstr, compactMeta) => {
3068
3189
  return proxyComponent(Cstr, cmpMeta, 1 /* isElementConstructor */ | 2 /* proxyState */);
3069
3190
  };
3070
3191
  var forceModeUpdate = (elm) => {
3071
- if (BUILD25.style && BUILD25.mode && !BUILD25.lazyLoad) {
3192
+ if (BUILD26.style && BUILD26.mode && !BUILD26.lazyLoad) {
3072
3193
  const mode = computeMode(elm);
3073
3194
  const hostRef = getHostRef(elm);
3074
3195
  if (hostRef.$modeName$ !== mode) {
@@ -3091,7 +3212,7 @@ var forceModeUpdate = (elm) => {
3091
3212
  };
3092
3213
 
3093
3214
  // src/runtime/bootstrap-lazy.ts
3094
- import { BUILD as BUILD26 } from "@rindo/core/internal/app-data";
3215
+ import { BUILD as BUILD27 } from "@rindo/core/internal/app-data";
3095
3216
 
3096
3217
  // src/runtime/hmr-component.ts
3097
3218
  var hmrStart = (hostElement, cmpMeta, hmrVersionId) => {
@@ -3103,7 +3224,7 @@ var hmrStart = (hostElement, cmpMeta, hmrVersionId) => {
3103
3224
  // src/runtime/bootstrap-lazy.ts
3104
3225
  var bootstrapLazy = (lazyBundles, options = {}) => {
3105
3226
  var _a;
3106
- if (BUILD26.profile && performance.mark) {
3227
+ if (BUILD27.profile && performance.mark) {
3107
3228
  performance.mark("st:app:start");
3108
3229
  }
3109
3230
  installDevTools();
@@ -3119,12 +3240,12 @@ var bootstrapLazy = (lazyBundles, options = {}) => {
3119
3240
  let isBootstrapping = true;
3120
3241
  Object.assign(plt, options);
3121
3242
  plt.$resourcesUrl$ = new URL(options.resourcesUrl || "./", doc.baseURI).href;
3122
- if (BUILD26.asyncQueue) {
3243
+ if (BUILD27.asyncQueue) {
3123
3244
  if (options.syncQueue) {
3124
3245
  plt.$flags$ |= 4 /* queueSync */;
3125
3246
  }
3126
3247
  }
3127
- if (BUILD26.hydrateClientSide) {
3248
+ if (BUILD27.hydrateClientSide) {
3128
3249
  plt.$flags$ |= 2 /* appLoaded */;
3129
3250
  }
3130
3251
  let hasSlotRelocation = false;
@@ -3140,22 +3261,22 @@ var bootstrapLazy = (lazyBundles, options = {}) => {
3140
3261
  if (cmpMeta.$flags$ & 4 /* hasSlotRelocation */) {
3141
3262
  hasSlotRelocation = true;
3142
3263
  }
3143
- if (BUILD26.member) {
3264
+ if (BUILD27.member) {
3144
3265
  cmpMeta.$members$ = compactMeta[2];
3145
3266
  }
3146
- if (BUILD26.hostListener) {
3267
+ if (BUILD27.hostListener) {
3147
3268
  cmpMeta.$listeners$ = compactMeta[3];
3148
3269
  }
3149
- if (BUILD26.reflect) {
3270
+ if (BUILD27.reflect) {
3150
3271
  cmpMeta.$attrsToReflect$ = [];
3151
3272
  }
3152
- if (BUILD26.watchCallback) {
3273
+ if (BUILD27.watchCallback) {
3153
3274
  cmpMeta.$watchers$ = (_a2 = compactMeta[4]) != null ? _a2 : {};
3154
3275
  }
3155
- if (BUILD26.shadowDom && !supportsShadow && cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) {
3276
+ if (BUILD27.shadowDom && !supportsShadow && cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) {
3156
3277
  cmpMeta.$flags$ |= 8 /* needsShadowDomShim */;
3157
3278
  }
3158
- const tagName = BUILD26.transformTagName && options.transformTagName ? options.transformTagName(cmpMeta.$tagName$) : cmpMeta.$tagName$;
3279
+ const tagName = BUILD27.transformTagName && options.transformTagName ? options.transformTagName(cmpMeta.$tagName$) : cmpMeta.$tagName$;
3159
3280
  const HostElement = class extends HTMLElement {
3160
3281
  // RindoLazyHost
3161
3282
  constructor(self) {
@@ -3163,10 +3284,10 @@ var bootstrapLazy = (lazyBundles, options = {}) => {
3163
3284
  this.hasRegisteredEventListeners = false;
3164
3285
  self = this;
3165
3286
  registerHost(self, cmpMeta);
3166
- if (BUILD26.shadowDom && cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) {
3287
+ if (BUILD27.shadowDom && cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) {
3167
3288
  if (supportsShadow) {
3168
3289
  if (!self.shadowRoot) {
3169
- if (BUILD26.shadowDelegatesFocus) {
3290
+ if (BUILD27.shadowDelegatesFocus) {
3170
3291
  self.attachShadow({
3171
3292
  mode: "open",
3172
3293
  delegatesFocus: !!(cmpMeta.$flags$ & 16 /* shadowDelegatesFocus */)
@@ -3181,7 +3302,7 @@ var bootstrapLazy = (lazyBundles, options = {}) => {
3181
3302
  );
3182
3303
  }
3183
3304
  }
3184
- } else if (!BUILD26.hydrateServerSide && !("shadowRoot" in self)) {
3305
+ } else if (!BUILD27.hydrateServerSide && !("shadowRoot" in self)) {
3185
3306
  self.shadowRoot = self;
3186
3307
  }
3187
3308
  }
@@ -3207,6 +3328,10 @@ var bootstrapLazy = (lazyBundles, options = {}) => {
3207
3328
  plt.raf(() => {
3208
3329
  var _a3;
3209
3330
  const hostRef = getHostRef(this);
3331
+ const i2 = deferredConnectedCallbacks.findIndex((host) => host === this);
3332
+ if (i2 > -1) {
3333
+ deferredConnectedCallbacks.splice(i2, 1);
3334
+ }
3210
3335
  if (((_a3 = hostRef == null ? void 0 : hostRef.$vnode$) == null ? void 0 : _a3.$elm$) instanceof Node && !hostRef.$vnode$.$elm$.isConnected) {
3211
3336
  delete hostRef.$vnode$.$elm$;
3212
3337
  }
@@ -3216,28 +3341,28 @@ var bootstrapLazy = (lazyBundles, options = {}) => {
3216
3341
  return getHostRef(this).$onReadyPromise$;
3217
3342
  }
3218
3343
  };
3219
- if (BUILD26.experimentalSlotFixes) {
3220
- if (BUILD26.scoped && cmpMeta.$flags$ & 2 /* scopedCssEncapsulation */) {
3344
+ if (BUILD27.experimentalSlotFixes) {
3345
+ if (BUILD27.scoped && cmpMeta.$flags$ & 2 /* scopedCssEncapsulation */) {
3221
3346
  patchPseudoShadowDom(HostElement.prototype);
3222
3347
  }
3223
3348
  } else {
3224
- if (BUILD26.slotChildNodesFix) {
3349
+ if (BUILD27.slotChildNodesFix) {
3225
3350
  patchChildSlotNodes(HostElement.prototype);
3226
3351
  }
3227
- if (BUILD26.cloneNodeFix) {
3352
+ if (BUILD27.cloneNodeFix) {
3228
3353
  patchCloneNode(HostElement.prototype);
3229
3354
  }
3230
- if (BUILD26.appendChildSlotFix) {
3355
+ if (BUILD27.appendChildSlotFix) {
3231
3356
  patchSlotAppendChild(HostElement.prototype);
3232
3357
  }
3233
- if (BUILD26.scopedSlotTextContentFix && cmpMeta.$flags$ & 2 /* scopedCssEncapsulation */) {
3358
+ if (BUILD27.scopedSlotTextContentFix && cmpMeta.$flags$ & 2 /* scopedCssEncapsulation */) {
3234
3359
  patchTextContent(HostElement.prototype);
3235
3360
  }
3236
3361
  }
3237
- if (BUILD26.formAssociated && cmpMeta.$flags$ & 64 /* formAssociated */) {
3362
+ if (BUILD27.formAssociated && cmpMeta.$flags$ & 64 /* formAssociated */) {
3238
3363
  HostElement.formAssociated = true;
3239
3364
  }
3240
- if (BUILD26.hotModuleReplacement) {
3365
+ if (BUILD27.hotModuleReplacement) {
3241
3366
  HostElement.prototype["s-hmr"] = function(hmrVersionId) {
3242
3367
  hmrStart(this, cmpMeta, hmrVersionId);
3243
3368
  };
@@ -3256,7 +3381,7 @@ var bootstrapLazy = (lazyBundles, options = {}) => {
3256
3381
  if (hasSlotRelocation) {
3257
3382
  dataStyles.textContent += SLOT_FB_CSS;
3258
3383
  }
3259
- if (BUILD26.invisiblePrehydration && (BUILD26.hydratedClass || BUILD26.hydratedAttribute)) {
3384
+ if (BUILD27.invisiblePrehydration && (BUILD27.hydratedClass || BUILD27.hydratedAttribute)) {
3260
3385
  dataStyles.textContent += cmpTags.sort() + HYDRATED_CSS;
3261
3386
  }
3262
3387
  if (dataStyles.innerHTML.length) {
@@ -3272,7 +3397,7 @@ var bootstrapLazy = (lazyBundles, options = {}) => {
3272
3397
  if (deferredConnectedCallbacks.length) {
3273
3398
  deferredConnectedCallbacks.map((host) => host.connectedCallback());
3274
3399
  } else {
3275
- if (BUILD26.profile) {
3400
+ if (BUILD27.profile) {
3276
3401
  plt.jmp(() => appLoadFallback = setTimeout(appDidLoad, 30, "timeout"));
3277
3402
  } else {
3278
3403
  plt.jmp(() => appLoadFallback = setTimeout(appDidLoad, 30));
@@ -3285,10 +3410,10 @@ var bootstrapLazy = (lazyBundles, options = {}) => {
3285
3410
  var Fragment = (_, children) => children;
3286
3411
 
3287
3412
  // src/runtime/host-listener.ts
3288
- import { BUILD as BUILD27 } from "@rindo/core/internal/app-data";
3413
+ import { BUILD as BUILD28 } from "@rindo/core/internal/app-data";
3289
3414
  var addHostEventListeners = (elm, hostRef, listeners, attachParentListeners) => {
3290
- if (BUILD27.hostListener && listeners) {
3291
- if (BUILD27.hostListenerTargetParent) {
3415
+ if (BUILD28.hostListener && listeners) {
3416
+ if (BUILD28.hostListenerTargetParent) {
3292
3417
  if (attachParentListeners) {
3293
3418
  listeners = listeners.filter(([flags]) => flags & 32 /* TargetParent */);
3294
3419
  } else {
@@ -3296,7 +3421,7 @@ var addHostEventListeners = (elm, hostRef, listeners, attachParentListeners) =>
3296
3421
  }
3297
3422
  }
3298
3423
  listeners.map(([flags, name, method]) => {
3299
- const target = BUILD27.hostListenerTarget ? getHostListenerTarget(elm, flags) : elm;
3424
+ const target = BUILD28.hostListenerTarget ? getHostListenerTarget(elm, flags) : elm;
3300
3425
  const handler = hostListenerProxy(hostRef, method);
3301
3426
  const opts = hostListenerOpts(flags);
3302
3427
  plt.ael(target, name, handler, opts);
@@ -3307,7 +3432,7 @@ var addHostEventListeners = (elm, hostRef, listeners, attachParentListeners) =>
3307
3432
  var hostListenerProxy = (hostRef, methodName) => (ev) => {
3308
3433
  var _a;
3309
3434
  try {
3310
- if (BUILD27.lazyLoad) {
3435
+ if (BUILD28.lazyLoad) {
3311
3436
  if (hostRef.$flags$ & 256 /* isListenReady */) {
3312
3437
  (_a = hostRef.$lazyInstance$) == null ? void 0 : _a[methodName](ev);
3313
3438
  } else {
@@ -3317,14 +3442,14 @@ var hostListenerProxy = (hostRef, methodName) => (ev) => {
3317
3442
  hostRef.$hostElement$[methodName](ev);
3318
3443
  }
3319
3444
  } catch (e) {
3320
- consoleError(e);
3445
+ consoleError(e, hostRef.$hostElement$);
3321
3446
  }
3322
3447
  };
3323
3448
  var getHostListenerTarget = (elm, flags) => {
3324
- if (BUILD27.hostListenerTargetDocument && flags & 4 /* TargetDocument */) return doc;
3325
- if (BUILD27.hostListenerTargetWindow && flags & 8 /* TargetWindow */) return win;
3326
- if (BUILD27.hostListenerTargetBody && flags & 16 /* TargetBody */) return doc.body;
3327
- if (BUILD27.hostListenerTargetParent && flags & 32 /* TargetParent */ && elm.parentElement)
3449
+ if (BUILD28.hostListenerTargetDocument && flags & 4 /* TargetDocument */) return doc;
3450
+ if (BUILD28.hostListenerTargetWindow && flags & 8 /* TargetWindow */) return win;
3451
+ if (BUILD28.hostListenerTargetBody && flags & 16 /* TargetBody */) return doc.body;
3452
+ if (BUILD28.hostListenerTargetParent && flags & 32 /* TargetParent */ && elm.parentElement)
3328
3453
  return elm.parentElement;
3329
3454
  return elm;
3330
3455
  };
@@ -3484,7 +3609,7 @@ var insertChildVNodeAnnotations = (doc2, vnodeChild, cmpData, hostId, depth, ind
3484
3609
  }
3485
3610
  };
3486
3611
  export {
3487
- BUILD28 as BUILD,
3612
+ BUILD29 as BUILD,
3488
3613
  Build,
3489
3614
  Env,
3490
3615
  Fragment,