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