@koppajs/koppajs-core 3.0.7 → 3.0.8

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.
package/dist/index.es.js CHANGED
@@ -1,11 +1,11 @@
1
- var Re = /* @__PURE__ */ ((e) => (e[e.DEBUG = 0] = "DEBUG", e[e.INFO = 1] = "INFO", e[e.WARN = 2] = "WARN", e[e.ERROR = 3] = "ERROR", e[e.NONE = 4] = "NONE", e))(Re || {});
2
- const B = {
1
+ var Ie = /* @__PURE__ */ ((e) => (e[e.DEBUG = 0] = "DEBUG", e[e.INFO = 1] = "INFO", e[e.WARN = 2] = "WARN", e[e.ERROR = 3] = "ERROR", e[e.NONE = 4] = "NONE", e))(Ie || {});
2
+ const q = {
3
3
  ERROR: "❌",
4
4
  WARN: "⚠️",
5
5
  INFO: "ℹ️",
6
6
  DEBUG: "🔍"
7
7
  };
8
- class Pe {
8
+ class Le {
9
9
  level = 3;
10
10
  isDevelopment = !1;
11
11
  /**
@@ -34,57 +34,57 @@ class Pe {
34
34
  shouldLog(t) {
35
35
  return t >= this.level;
36
36
  }
37
- formatMessage(t, n, o) {
38
- const r = [t, n];
39
- if (o) {
40
- const a = Object.entries(o).map(([i, s]) => `${i}: ${s}`).join(", ");
41
- a && r.push(`[${a}]`);
37
+ formatMessage(t, o, n) {
38
+ const i = [t, o];
39
+ if (n) {
40
+ const l = Object.entries(n).map(([r, s]) => `${r}: ${s}`).join(", ");
41
+ l && i.push(`[${l}]`);
42
42
  }
43
- return r.join(" ");
43
+ return i.join(" ");
44
44
  }
45
45
  /**
46
46
  * Log an error message.
47
47
  * @param message - Error message
48
48
  * @param args - Additional arguments to log
49
49
  */
50
- error(t, ...n) {
50
+ error(t, ...o) {
51
51
  this.shouldLog(
52
52
  3
53
53
  /* ERROR */
54
- ) && console.error(this.formatMessage(B.ERROR, t), ...n);
54
+ ) && console.error(this.formatMessage(q.ERROR, t), ...o);
55
55
  }
56
56
  /**
57
57
  * Log a warning message.
58
58
  * @param message - Warning message
59
59
  * @param args - Additional arguments to log
60
60
  */
61
- warn(t, ...n) {
61
+ warn(t, ...o) {
62
62
  this.shouldLog(
63
63
  2
64
64
  /* WARN */
65
- ) && console.warn(this.formatMessage(B.WARN, t), ...n);
65
+ ) && console.warn(this.formatMessage(q.WARN, t), ...o);
66
66
  }
67
67
  /**
68
68
  * Log an info message.
69
69
  * @param message - Info message
70
70
  * @param args - Additional arguments to log
71
71
  */
72
- info(t, ...n) {
72
+ info(t, ...o) {
73
73
  this.shouldLog(
74
74
  1
75
75
  /* INFO */
76
- ) && console.info(this.formatMessage(B.INFO, t), ...n);
76
+ ) && console.info(this.formatMessage(q.INFO, t), ...o);
77
77
  }
78
78
  /**
79
79
  * Log a debug message.
80
80
  * @param message - Debug message
81
81
  * @param args - Additional arguments to log
82
82
  */
83
- debug(t, ...n) {
83
+ debug(t, ...o) {
84
84
  this.shouldLog(
85
85
  0
86
86
  /* DEBUG */
87
- ) && console.debug(this.formatMessage(B.DEBUG, t), ...n);
87
+ ) && console.debug(this.formatMessage(q.DEBUG, t), ...o);
88
88
  }
89
89
  /**
90
90
  * Log an error with context information.
@@ -92,29 +92,29 @@ class Pe {
92
92
  * @param context - Context object with additional information
93
93
  * @param error - Optional error object
94
94
  */
95
- errorWithContext(t, n, o) {
95
+ errorWithContext(t, o, n) {
96
96
  if (!this.shouldLog(
97
97
  3
98
98
  /* ERROR */
99
99
  )) return;
100
- const r = this.formatMessage(B.ERROR, t, n);
101
- o ? console.error(r, o) : console.error(r);
100
+ const i = this.formatMessage(q.ERROR, t, o);
101
+ n ? console.error(i, n) : console.error(i);
102
102
  }
103
103
  /**
104
104
  * Log a warning with context information.
105
105
  * @param message - Warning message
106
106
  * @param context - Context object with additional information
107
107
  */
108
- warnWithContext(t, n) {
108
+ warnWithContext(t, o) {
109
109
  this.shouldLog(
110
110
  2
111
111
  /* WARN */
112
- ) && console.warn(this.formatMessage(B.WARN, t, n));
112
+ ) && console.warn(this.formatMessage(q.WARN, t, o));
113
113
  }
114
114
  }
115
- const _ = new Pe();
116
- _.init();
117
- const ce = /* @__PURE__ */ Symbol("isBounded"), pe = /* @__PURE__ */ Symbol("isProxy"), Ie = [
115
+ const S = new Le();
116
+ S.init();
117
+ const fe = /* @__PURE__ */ Symbol("isBounded"), ge = /* @__PURE__ */ Symbol("isProxy"), De = [
118
118
  "created",
119
119
  "beforeMount",
120
120
  "mounted",
@@ -124,22 +124,22 @@ const ce = /* @__PURE__ */ Symbol("isBounded"), pe = /* @__PURE__ */ Symbol("isP
124
124
  "destroyed",
125
125
  "processed"
126
126
  ];
127
- function K(e, t) {
128
- if (typeof e != "function" || e[ce]) return e;
129
- const o = e.bind(t);
130
- return o[ce] = !0, o;
127
+ function Y(e, t) {
128
+ if (typeof e != "function" || e[fe]) return e;
129
+ const n = e.bind(t);
130
+ return n[fe] = !0, n;
131
131
  }
132
- function Le(e, t) {
133
- for (const n in e) {
134
- const o = e[n];
135
- if (Object.prototype.hasOwnProperty.call(e, n) && typeof o == "function")
132
+ function We(e, t) {
133
+ for (const o in e) {
134
+ const n = e[o];
135
+ if (Object.prototype.hasOwnProperty.call(e, o) && typeof n == "function")
136
136
  try {
137
- e[n] = K(o, t);
138
- } catch (r) {
139
- _.errorWithContext(
140
- `Failed to bind method "${n}"`,
141
- { methodName: n },
142
- r
137
+ e[o] = Y(n, t);
138
+ } catch (i) {
139
+ S.errorWithContext(
140
+ `Failed to bind method "${o}"`,
141
+ { methodName: o },
142
+ i
143
143
  );
144
144
  }
145
145
  }
@@ -147,69 +147,69 @@ function Le(e, t) {
147
147
  function Fe(e) {
148
148
  return /<\/?[a-z][^>]*>/i.test(e);
149
149
  }
150
- function ne(e, t) {
150
+ function re(e, t) {
151
151
  if (e == null || typeof t != "string") return;
152
- const n = t.trim().replace(/\[(\w+)\]/g, ".$1").split(".").filter(Boolean);
152
+ const o = t.trim().replace(/\[(\w+)\]/g, ".$1").split(".").filter(Boolean);
153
153
  try {
154
- return n.reduce((o, r) => {
155
- if (o != null)
156
- return o[r];
154
+ return o.reduce((n, i) => {
155
+ if (n != null)
156
+ return n[i];
157
157
  }, e);
158
158
  } catch {
159
159
  return;
160
160
  }
161
161
  }
162
- function We(e) {
162
+ function Ve(e) {
163
163
  return typeof e == "string" ? e.toLowerCase() : typeof e == "function" && typeof e.name == "string" ? e.name.toLowerCase() : "unknown";
164
164
  }
165
- function me(e) {
165
+ function be(e) {
166
166
  const t = e.trim();
167
167
  return /^[a-zA-Z_$][0-9a-zA-Z_$]*(?:\[(?:\d+|\w+)\]|\.[a-zA-Z_$][0-9a-zA-Z_$]*)*$/.test(
168
168
  t
169
169
  );
170
170
  }
171
- function De(e, t, n) {
171
+ function je(e, t, o) {
172
172
  if (e == null || typeof e != "object" && typeof e != "function")
173
173
  throw new Error("❌ setValueByPath: target must be an object.");
174
174
  if (typeof t != "string" || !t.trim())
175
175
  throw new Error("❌ setValueByPath: path must be a non-empty string.");
176
- const o = t.trim().replace(/\[(\w+)\]/g, ".$1").split(".").filter(Boolean);
177
- if (o.length === 0)
176
+ const n = t.trim().replace(/\[(\w+)\]/g, ".$1").split(".").filter(Boolean);
177
+ if (n.length === 0)
178
178
  throw new Error(`❌ setValueByPath: invalid path "${t}".`);
179
- const r = (c, l) => Object.prototype.hasOwnProperty.call(c, l), a = o.pop();
180
- let i = e;
181
- for (const c of o) {
182
- if (i == null || typeof i != "object" && typeof i != "function")
179
+ const i = (c, a) => Object.prototype.hasOwnProperty.call(c, a), l = n.pop();
180
+ let r = e;
181
+ for (const c of n) {
182
+ if (r == null || typeof r != "object" && typeof r != "function")
183
183
  throw new Error(
184
184
  `❌ setValueByPath: invalid path "${t}". Segment "${c}" is not an object.`
185
185
  );
186
- if (!r(i, c))
186
+ if (!i(r, c))
187
187
  throw new Error(
188
188
  `❌ setValueByPath: invalid path "${t}". Missing segment "${c}".`
189
189
  );
190
- const l = i[c];
191
- if (l == null || typeof l != "object" && typeof l != "function")
190
+ const a = r[c];
191
+ if (a == null || typeof a != "object" && typeof a != "function")
192
192
  throw new Error(
193
193
  `❌ setValueByPath: invalid path "${t}". Segment "${c}" is not an object.`
194
194
  );
195
- i = l;
195
+ r = a;
196
196
  }
197
- if (i == null || typeof i != "object" && typeof i != "function")
197
+ if (r == null || typeof r != "object" && typeof r != "function")
198
198
  throw new Error(
199
199
  `❌ setValueByPath: invalid path "${t}". Final target is not an object.`
200
200
  );
201
- if (!r(i, a))
201
+ if (!i(r, l))
202
202
  throw new Error(
203
- `❌ setValueByPath: invalid path "${t}". Final key "${a}" does not exist.`
203
+ `❌ setValueByPath: invalid path "${t}". Final key "${l}" does not exist.`
204
204
  );
205
- const s = Object.getOwnPropertyDescriptor(i, a);
205
+ const s = Object.getOwnPropertyDescriptor(r, l);
206
206
  if (s && s.writable === !1 && !s.set)
207
207
  throw new Error(
208
- `❌ setValueByPath: cannot write "${t}". Property "${a}" is read-only.`
208
+ `❌ setValueByPath: cannot write "${t}". Property "${l}" is read-only.`
209
209
  );
210
- i[a] = n;
210
+ r[l] = o;
211
211
  }
212
- const je = {
212
+ const He = {
213
213
  select: {
214
214
  get() {
215
215
  return (e) => this instanceof HTMLInputElement || this instanceof HTMLTextAreaElement ? (this.select(), null) : this.querySelector(e);
@@ -252,9 +252,9 @@ const je = {
252
252
  return (e) => {
253
253
  if (!this.parentNode) return [];
254
254
  const t = [];
255
- let n = this.parentNode.firstChild;
256
- for (; n; )
257
- n.nodeType === Node.ELEMENT_NODE && n !== this && n instanceof HTMLElement && (e?.(n), t.push(n)), n = n.nextSibling;
255
+ let o = this.parentNode.firstChild;
256
+ for (; o; )
257
+ o.nodeType === Node.ELEMENT_NODE && o !== this && o instanceof HTMLElement && (e?.(o), t.push(o)), o = o.nextSibling;
258
258
  return t;
259
259
  };
260
260
  }
@@ -278,51 +278,51 @@ const je = {
278
278
  return (e, t) => (t !== void 0 && this.setAttribute(e, t || "true"), this.getAttribute(e));
279
279
  }
280
280
  }
281
- }, Ve = {};
282
- function He(e) {
281
+ }, Be = {};
282
+ function qe(e) {
283
283
  return e.replace(/-./g, (t) => t[1].toUpperCase());
284
284
  }
285
- const Be = /(?:\bwindow\b|\bdocument\b|\bglobalThis\b|\bFunction\b|\beval\b|\bsetTimeout\b|\bsetInterval\b|\bfetch\b|\bXMLHttpRequest\b|\bimport\b|\brequire\b|\bthis\b)/, q = /* @__PURE__ */ new Map(), qe = 1e3, ae = /* @__PURE__ */ new WeakMap();
286
- function ze(e) {
287
- const t = Object.keys(e), n = t.join("\0"), o = ae.get(e);
288
- if (o && o.fingerprint === n)
289
- return o.keys;
290
- const r = t.sort();
291
- return ae.set(e, { keys: r, fingerprint: n }), r;
285
+ const ze = /(?:\bwindow\b|\bdocument\b|\bglobalThis\b|\bFunction\b|\beval\b|\bsetTimeout\b|\bsetInterval\b|\bfetch\b|\bXMLHttpRequest\b|\bimport\b|\brequire\b|\bthis\b)/, z = /* @__PURE__ */ new Map(), Ue = 1e3, ue = /* @__PURE__ */ new WeakMap();
286
+ function Xe(e) {
287
+ const t = Object.keys(e), o = t.join("\0"), n = ue.get(e);
288
+ if (n && n.fingerprint === o)
289
+ return n.keys;
290
+ const i = t.sort();
291
+ return ue.set(e, { keys: i, fingerprint: o }), i;
292
292
  }
293
- function H(e, t = {}) {
294
- const n = (e ?? "").trim();
295
- if (n)
293
+ function B(e, t = {}) {
294
+ const o = (e ?? "").trim();
295
+ if (o)
296
296
  try {
297
- if (Be.test(n))
297
+ if (ze.test(o))
298
298
  return;
299
- if (me(n)) {
300
- const i = ne(t, n);
301
- return typeof i == "function" ? i.call(t) : i;
299
+ if (be(o)) {
300
+ const r = re(t, o);
301
+ return typeof r == "function" ? r.call(t) : r;
302
302
  }
303
- const o = ze(t), r = `${n}|${o.join(",")}`;
304
- let a = q.get(r);
305
- if (!a) {
306
- const i = `"use strict"; return (${n});`;
307
- if (a = new Function(...o, i), q.size >= qe) {
308
- const s = q.keys().next().value;
309
- s && q.delete(s);
303
+ const n = Xe(t), i = `${o}|${n.join(",")}`;
304
+ let l = z.get(i);
305
+ if (!l) {
306
+ const r = `"use strict"; return (${o});`;
307
+ if (l = new Function(...n, r), z.size >= Ue) {
308
+ const s = z.keys().next().value;
309
+ s && z.delete(s);
310
310
  }
311
- q.set(r, a);
311
+ z.set(i, l);
312
312
  }
313
- return a(...o.map((i) => t[i]));
314
- } catch (o) {
315
- _.debug(`Expression evaluation failed: ${n}`, o);
313
+ return l(...n.map((r) => t[r]));
314
+ } catch (n) {
315
+ S.debug(`Expression evaluation failed: ${o}`, n);
316
316
  return;
317
317
  }
318
318
  }
319
- function Ue(e) {
319
+ function Ge(e) {
320
320
  return e.length === 0 ? "" : e.map((t) => `var ${t} = __deps.${t};`).join(`
321
321
  `) + `
322
322
  `;
323
323
  }
324
- function Xe(e, t) {
325
- const n = e.replace(/\$-\{/g, "${"), o = t ? Object.keys(t) : [], a = `
324
+ function Ke(e, t) {
325
+ const o = e.replace(/\$-\{/g, "${"), n = t ? Object.keys(t) : [], l = `
326
326
  const { $refs, $parent, $emit, $take, $handleEventFromChild, ...rest } = context;
327
327
 
328
328
  // Expose all $*-prefixed context entries (e.g. $router, $store) as local variables
@@ -335,356 +335,356 @@ function Xe(e, t) {
335
335
  }
336
336
 
337
337
  // Inject resolved dependencies as local variables
338
- ${Ue(o)}
338
+ ${Ge(n)}
339
339
 
340
- return (${n});
340
+ return (${o});
341
341
  `;
342
342
  try {
343
- const i = t ? new Function("context", "__deps", a) : new Function("context", a);
344
- return ((c) => t ? i(c, t) : i(c));
345
- } catch (i) {
346
- throw _.errorWithContext("Failed to compile dynamic code", { functionBody: a }, i), i;
343
+ const r = t ? new Function("context", "__deps", l) : new Function("context", l);
344
+ return ((c) => t ? r(c, t) : r(c));
345
+ } catch (r) {
346
+ throw S.errorWithContext("Failed to compile dynamic code", { functionBody: l }, r), r;
347
347
  }
348
348
  }
349
- function ye() {
349
+ function Ee() {
350
350
  return /* @__PURE__ */ new Map();
351
351
  }
352
- const ge = ye();
353
- function be(e, t, n) {
354
- e === "global" && (e = ge), e.has(t) || e.set(t, /* @__PURE__ */ new Set()), e.get(t).add(n);
352
+ const ve = Ee();
353
+ function we(e, t, o) {
354
+ e === "global" && (e = ve), e.has(t) || e.set(t, /* @__PURE__ */ new Set()), e.get(t).add(o);
355
355
  }
356
- async function R(e, t, n) {
357
- e === "global" && (e = ge);
358
- const o = Array.from(e.get(t) ?? []);
359
- for (const r of o)
356
+ async function P(e, t, o) {
357
+ e === "global" && (e = ve);
358
+ const n = Array.from(e.get(t) ?? []);
359
+ for (const i of n)
360
360
  try {
361
- await r(n);
362
- } catch (a) {
363
- _.errorWithContext(`Hook "${t}" callback failed`, { hook: t }, a);
361
+ await i(o);
362
+ } catch (l) {
363
+ S.errorWithContext(`Hook "${t}" callback failed`, { hook: t }, l);
364
364
  }
365
365
  }
366
- const G = {
366
+ const Z = {
367
367
  modules: {},
368
368
  plugins: {}
369
369
  };
370
- function Ge(e) {
370
+ function Ze(e) {
371
371
  if (e == null || typeof e != "object") return !1;
372
372
  const t = e;
373
373
  return typeof t.template == "string" && typeof t.script == "string" && typeof t.style == "string";
374
374
  }
375
- function Z(e) {
375
+ function J(e) {
376
376
  if (e == null || typeof e != "object") return !1;
377
377
  const t = e;
378
378
  return typeof t.setup == "function" && t.attach === void 0;
379
379
  }
380
- function Ke(e) {
380
+ function Ye(e) {
381
381
  if (e == null || typeof e != "object") return !1;
382
382
  const t = e;
383
383
  return typeof t.attach == "function" && t.setup === void 0;
384
384
  }
385
- function Ze(e) {
385
+ function Je(e) {
386
386
  return e instanceof HTMLElement && "instance" in e && e.instance !== void 0;
387
387
  }
388
- const Ye = () => {
389
- Object.defineProperties(Object.prototype, Ve), typeof HTMLElement < "u" && Object.defineProperties(HTMLElement.prototype, je);
388
+ const Qe = () => {
389
+ Object.defineProperties(Object.prototype, Be), typeof HTMLElement < "u" && Object.defineProperties(HTMLElement.prototype, He);
390
390
  };
391
- function z(e) {
391
+ function U(e) {
392
392
  return e.nodeType === Node.ELEMENT_NODE && e.tagName.includes("-");
393
393
  }
394
- function Je(e, t) {
395
- const n = document.createTreeWalker(e, NodeFilter.SHOW_ELEMENT, {
396
- acceptNode: (r) => z(r) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP
394
+ function et(e, t) {
395
+ const o = document.createTreeWalker(e, NodeFilter.SHOW_ELEMENT, {
396
+ acceptNode: (i) => U(i) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP
397
397
  });
398
- let o = n.nextNode();
399
- for (; o; ) {
400
- const r = o.getAttribute(t);
401
- r !== null && (Ne(o) === void 0 && we(o, r), o.removeAttribute(t)), o = n.nextNode();
398
+ let n = o.nextNode();
399
+ for (; n; ) {
400
+ const i = n.getAttribute(t);
401
+ i !== null && (Ae(n) === void 0 && Ce(n, i), n.removeAttribute(t)), n = o.nextNode();
402
402
  }
403
403
  }
404
- function le(e, t) {
405
- if (!z(e)) return null;
406
- const n = e.tagName;
407
- let o = Ne(e);
408
- const r = nt(e);
409
- if (o === void 0 && t) {
410
- const a = e.getAttribute(t);
411
- a !== null && (we(e, a), o = a, e.removeAttribute(t));
404
+ function de(e, t) {
405
+ if (!U(e)) return null;
406
+ const o = e.tagName;
407
+ let n = Ae(e);
408
+ const i = rt(e);
409
+ if (n === void 0 && t) {
410
+ const l = e.getAttribute(t);
411
+ l !== null && (Ce(e, l), n = l, e.removeAttribute(t));
412
412
  }
413
- return o === void 0 ? null : r !== void 0 ? `${n}:${String(o)}:${String(r)}` : `${n}:${String(o)}`;
413
+ return n === void 0 ? null : i !== void 0 ? `${o}:${String(n)}:${String(i)}` : `${o}:${String(n)}`;
414
414
  }
415
- function Qe(e, t) {
415
+ function tt(e, t) {
416
416
  return e.nodeType !== t.nodeType ? !1 : e.nodeType === Node.TEXT_NODE || e.nodeType === Node.COMMENT_NODE ? !0 : e.nodeType === Node.ELEMENT_NODE ? e.tagName === t.tagName : !1;
417
417
  }
418
- function Y(e, t) {
419
- const n = new Set(e.getAttributeNames()), o = new Set(t.getAttributeNames());
420
- for (const r of n)
421
- !o.has(r) && !r.startsWith("@") && e.removeAttribute(r);
422
- for (const r of o) {
423
- const a = t.getAttribute(r), i = e.getAttribute(r);
424
- a !== i && (a === null ? e.removeAttribute(r) : e.setAttribute(r, a));
418
+ function Q(e, t) {
419
+ const o = new Set(e.getAttributeNames()), n = new Set(t.getAttributeNames());
420
+ for (const i of o)
421
+ !n.has(i) && !i.startsWith("@") && e.removeAttribute(i);
422
+ for (const i of n) {
423
+ const l = t.getAttribute(i), r = e.getAttribute(i);
424
+ l !== r && (l === null ? e.removeAttribute(i) : e.setAttribute(i, l));
425
425
  }
426
426
  }
427
- function Ee(e, t, n) {
428
- const o = Array.from(e.childNodes), r = Array.from(t.childNodes), a = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Set();
429
- for (const s of o) {
430
- const c = le(s, n);
431
- c !== null && !a.has(c) && a.set(c, s);
427
+ function Ne(e, t, o) {
428
+ const n = Array.from(e.childNodes), i = Array.from(t.childNodes), l = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Set();
429
+ for (const s of n) {
430
+ const c = de(s, o);
431
+ c !== null && !l.has(c) && l.set(c, s);
432
432
  }
433
- for (let s = 0; s < r.length; s++) {
434
- const c = r[s], l = o[s], m = le(c, n);
435
- let p = null;
436
- if (m !== null && a.has(m) && (p = a.get(m), i.add(p)), p && z(p)) {
437
- l !== p && (s < e.childNodes.length ? e.insertBefore(p, e.childNodes[s]) : e.appendChild(p)), Y(p, c);
433
+ for (let s = 0; s < i.length; s++) {
434
+ const c = i[s], a = n[s], u = de(c, o);
435
+ let d = null;
436
+ if (u !== null && l.has(u) && (d = l.get(u), r.add(d)), d && U(d)) {
437
+ a !== d && (s < e.childNodes.length ? e.insertBefore(d, e.childNodes[s]) : e.appendChild(d)), Q(d, c);
438
438
  continue;
439
439
  }
440
- if (z(c) && m !== null) {
441
- l ? e.replaceChild(c, l) : e.appendChild(c);
440
+ if (U(c) && u !== null) {
441
+ a ? e.replaceChild(c, a) : e.appendChild(c);
442
442
  continue;
443
443
  }
444
- if (!l) {
444
+ if (!a) {
445
445
  e.appendChild(c);
446
446
  continue;
447
447
  }
448
- if (!Qe(l, c)) {
449
- e.replaceChild(c, l);
448
+ if (!tt(a, c)) {
449
+ e.replaceChild(c, a);
450
450
  continue;
451
451
  }
452
- if (l.nodeType === Node.TEXT_NODE) {
453
- l.textContent !== c.textContent && (l.textContent = c.textContent);
452
+ if (a.nodeType === Node.TEXT_NODE) {
453
+ a.textContent !== c.textContent && (a.textContent = c.textContent);
454
454
  continue;
455
455
  }
456
- if (l.nodeType === Node.COMMENT_NODE) {
457
- l.textContent !== c.textContent && (l.textContent = c.textContent);
456
+ if (a.nodeType === Node.COMMENT_NODE) {
457
+ a.textContent !== c.textContent && (a.textContent = c.textContent);
458
458
  continue;
459
459
  }
460
- if (l.nodeType === Node.ELEMENT_NODE) {
461
- const N = l, x = c;
462
- if (z(N)) {
463
- Y(N, x);
460
+ if (a.nodeType === Node.ELEMENT_NODE) {
461
+ const v = a, x = c;
462
+ if (U(v)) {
463
+ Q(v, x);
464
464
  continue;
465
465
  }
466
- Y(N, x), Ee(N, x, n);
466
+ Q(v, x), Ne(v, x, o);
467
467
  }
468
468
  }
469
- for (; e.childNodes.length > r.length; ) {
469
+ for (; e.childNodes.length > i.length; ) {
470
470
  const s = e.lastChild;
471
471
  s && e.removeChild(s);
472
472
  }
473
473
  }
474
- function et(e, t, n, o) {
475
- if (n || e.childNodes.length === 0) {
476
- o && Je(t, o), e.replaceChildren(t);
474
+ function nt(e, t, o, n) {
475
+ if (o || e.childNodes.length === 0) {
476
+ n && et(t, n), e.replaceChildren(t);
477
477
  return;
478
478
  }
479
- const r = document.createElement("div");
480
- r.appendChild(t), Ee(e, r, o);
479
+ const i = document.createElement("div");
480
+ i.appendChild(t), Ne(e, i, n);
481
481
  }
482
- const oe = /* @__PURE__ */ Symbol("STRUCT_ID"), re = /* @__PURE__ */ Symbol("SLOT_ID");
483
- function ve(e, t, n) {
482
+ const ie = /* @__PURE__ */ Symbol("STRUCT_ID"), se = /* @__PURE__ */ Symbol("SLOT_ID");
483
+ function _e(e, t, o) {
484
484
  Object.defineProperty(e, t, {
485
- value: n,
485
+ value: o,
486
486
  writable: !0,
487
487
  configurable: !0,
488
488
  enumerable: !1
489
489
  });
490
490
  }
491
- function we(e, t) {
492
- ve(e, oe, t);
491
+ function Ce(e, t) {
492
+ _e(e, ie, t);
493
493
  }
494
- function Ne(e) {
495
- return Object.prototype.hasOwnProperty.call(e, oe) ? e[oe] : void 0;
494
+ function Ae(e) {
495
+ return Object.prototype.hasOwnProperty.call(e, ie) ? e[ie] : void 0;
496
496
  }
497
- function tt(e, t) {
498
- ve(e, re, t);
497
+ function ot(e, t) {
498
+ _e(e, se, t);
499
499
  }
500
- function nt(e) {
501
- return Object.prototype.hasOwnProperty.call(e, re) ? e[re] : void 0;
500
+ function rt(e) {
501
+ return Object.prototype.hasOwnProperty.call(e, se) ? e[se] : void 0;
502
502
  }
503
- function ot(e, t, n, o) {
503
+ function it(e, t, o, n) {
504
504
  if (!Array.isArray(t)) return () => {
505
505
  };
506
- const r = [];
507
- return t.forEach(([a, i, s]) => {
508
- if (typeof a != "string" || typeof s != "function") {
509
- _.error("Provided handler is not a function", s);
506
+ const i = [];
507
+ return t.forEach(([l, r, s]) => {
508
+ if (typeof l != "string" || typeof s != "function") {
509
+ S.error("Provided handler is not a function", s);
510
510
  return;
511
511
  }
512
512
  let c = [];
513
- if (i === "window")
513
+ if (r === "window")
514
514
  c = [window];
515
- else if (typeof i == "string")
516
- if (i.startsWith("$refs.")) {
517
- const [l, ...m] = i.slice(6).split(" "), p = o[l];
518
- p && (c = m.length ? Array.from(p.querySelectorAll(m.join(" "))) : [p]);
515
+ else if (typeof r == "string")
516
+ if (r.startsWith("$refs.")) {
517
+ const [a, ...u] = r.slice(6).split(" "), d = n[a];
518
+ d && (c = u.length ? Array.from(d.querySelectorAll(u.join(" "))) : [d]);
519
519
  } else
520
- c = Array.from(n.querySelectorAll(i));
521
- else if (i instanceof Element || i instanceof Window)
522
- c = [i];
523
- else if (typeof i == "object" && i && "ref" in i) {
524
- const { ref: l, selector: m } = i, p = o[l];
525
- p && (c = m ? Array.from(p.querySelectorAll(m)) : [p]);
520
+ c = Array.from(o.querySelectorAll(r));
521
+ else if (r instanceof Element || r instanceof Window)
522
+ c = [r];
523
+ else if (typeof r == "object" && r && "ref" in r) {
524
+ const { ref: a, selector: u } = r, d = n[a];
525
+ d && (c = u ? Array.from(d.querySelectorAll(u)) : [d]);
526
526
  }
527
- for (const l of c) {
528
- const m = K(s, e);
529
- l.addEventListener(a, m), r.push({ target: l, type: a, handler: m });
527
+ for (const a of c) {
528
+ const u = Y(s, e);
529
+ a.addEventListener(l, u), i.push({ target: a, type: l, handler: u });
530
530
  }
531
531
  }), () => {
532
- for (const { target: a, type: i, handler: s } of r)
533
- a.removeEventListener(i, s);
534
- r.length = 0;
532
+ for (const { target: l, type: r, handler: s } of i)
533
+ l.removeEventListener(r, s);
534
+ i.length = 0;
535
535
  };
536
536
  }
537
- const Ce = /^on([a-z]+)$/i;
538
- function rt(e, t) {
539
- const n = document.createTreeWalker(t, NodeFilter.SHOW_ELEMENT);
540
- let o = n.nextNode();
541
- for (; o; ) {
542
- for (const r of Array.from(o.attributes)) {
543
- const a = r.name.match(Ce);
544
- if (a) {
545
- const i = a[1].toLowerCase(), s = r.value;
537
+ const Te = /^on([a-z]+)$/i;
538
+ function st(e, t) {
539
+ const o = document.createTreeWalker(t, NodeFilter.SHOW_ELEMENT);
540
+ let n = o.nextNode();
541
+ for (; n; ) {
542
+ for (const i of Array.from(n.attributes)) {
543
+ const l = i.name.match(Te);
544
+ if (l) {
545
+ const r = l[1].toLowerCase(), s = i.value;
546
546
  if (s) {
547
547
  const c = e[s];
548
- typeof c == "function" && (o.removeAttribute(r.name), o.addEventListener(i, c));
548
+ typeof c == "function" && (n.removeAttribute(i.name), n.addEventListener(r, c));
549
549
  }
550
550
  }
551
551
  }
552
- o = n.nextNode();
552
+ n = o.nextNode();
553
553
  }
554
554
  }
555
- function it(e, t) {
556
- const n = document.createTreeWalker(t, NodeFilter.SHOW_ELEMENT);
557
- let o = n.nextNode();
558
- for (; o; ) {
559
- for (const r of Array.from(o.attributes)) {
560
- const a = r.name.match(Ce);
561
- if (a) {
562
- const i = a[1].toLowerCase(), s = r.value;
555
+ function ct(e, t) {
556
+ const o = document.createTreeWalker(t, NodeFilter.SHOW_ELEMENT);
557
+ let n = o.nextNode();
558
+ for (; n; ) {
559
+ for (const i of Array.from(n.attributes)) {
560
+ const l = i.name.match(Te);
561
+ if (l) {
562
+ const r = l[1].toLowerCase(), s = i.value;
563
563
  if (s) {
564
564
  const c = e[s];
565
- typeof c == "function" && (o.removeAttribute(r.name), o.addEventListener(i, c));
565
+ typeof c == "function" && (n.removeAttribute(i.name), n.addEventListener(r, c));
566
566
  }
567
567
  }
568
568
  }
569
- o = n.nextNode();
569
+ n = o.nextNode();
570
570
  }
571
571
  }
572
- function st(e, t, n, o, r) {
573
- if (!Array.isArray(n)) return () => {
572
+ function at(e, t, o, n, i) {
573
+ if (!Array.isArray(o)) return () => {
574
574
  };
575
- const a = [];
576
- return n.forEach(([i, s, c]) => {
577
- if (typeof i != "string" || typeof c != "function") {
578
- _.error("Provided handler is not a function", c);
575
+ const l = [];
576
+ return o.forEach(([r, s, c]) => {
577
+ if (typeof r != "string" || typeof c != "function") {
578
+ S.error("Provided handler is not a function", c);
579
579
  return;
580
580
  }
581
- let l = [];
581
+ let a = [];
582
582
  if (s === "window")
583
- l = [window];
583
+ a = [window];
584
584
  else if (typeof s == "string")
585
585
  if (s.startsWith("$refs.")) {
586
- const [m, ...p] = s.slice(6).split(" "), N = r[m];
587
- N && (l = p.length ? Array.from(N.querySelectorAll(p.join(" "))) : [N]);
586
+ const [u, ...d] = s.slice(6).split(" "), v = i[u];
587
+ v && (a = d.length ? Array.from(v.querySelectorAll(d.join(" "))) : [v]);
588
588
  } else
589
- l = Array.from(o.querySelectorAll(s));
589
+ a = Array.from(n.querySelectorAll(s));
590
590
  else if (s instanceof Element || s instanceof Window)
591
- l = [s];
591
+ a = [s];
592
592
  else if (typeof s == "object" && s && "ref" in s) {
593
- const { ref: m, selector: p } = s, N = r[m];
594
- N && (l = p ? Array.from(N.querySelectorAll(p)) : [N]);
593
+ const { ref: u, selector: d } = s, v = i[u];
594
+ v && (a = d ? Array.from(v.querySelectorAll(d)) : [v]);
595
595
  }
596
- for (const m of l) {
597
- const p = K(c, t);
598
- m.addEventListener(i, p), a.push({ target: m, type: i, handler: p });
596
+ for (const u of a) {
597
+ const d = Y(c, t);
598
+ u.addEventListener(r, d), l.push({ target: u, type: r, handler: d });
599
599
  }
600
600
  }), () => {
601
- for (const { target: i, type: s, handler: c } of a)
602
- i.removeEventListener(s, c);
603
- a.length = 0;
601
+ for (const { target: r, type: s, handler: c } of l)
602
+ r.removeEventListener(s, c);
603
+ l.length = 0;
604
604
  };
605
605
  }
606
- const j = /* @__PURE__ */ new WeakMap();
607
- let J;
608
- function ct() {
606
+ const V = /* @__PURE__ */ new WeakMap();
607
+ let ee;
608
+ function lt() {
609
609
  if (typeof EventTarget > "u") return;
610
610
  const e = globalThis;
611
611
  if (e.__koppajsEventTrackingPatched) return;
612
612
  e.__koppajsEventTrackingPatched = !0;
613
- const t = EventTarget.prototype.addEventListener, n = EventTarget.prototype.removeEventListener;
614
- EventTarget.prototype.addEventListener = function(o, r, a) {
615
- return j.has(this) || j.set(this, /* @__PURE__ */ new Set()), j.get(this).add({ type: o, listener: r, options: a }), t.call(this, o, r, a);
616
- }, EventTarget.prototype.removeEventListener = function(o, r, a) {
617
- const i = j.get(this);
618
- if (i) {
619
- for (const s of i)
620
- if (s.type === o && s.listener === r) {
621
- i.delete(s);
613
+ const t = EventTarget.prototype.addEventListener, o = EventTarget.prototype.removeEventListener;
614
+ EventTarget.prototype.addEventListener = function(n, i, l) {
615
+ return V.has(this) || V.set(this, /* @__PURE__ */ new Set()), V.get(this).add({ type: n, listener: i, options: l }), t.call(this, n, i, l);
616
+ }, EventTarget.prototype.removeEventListener = function(n, i, l) {
617
+ const r = V.get(this);
618
+ if (r) {
619
+ for (const s of r)
620
+ if (s.type === n && s.listener === i) {
621
+ r.delete(s);
622
622
  break;
623
623
  }
624
- i.size === 0 && j.delete(this);
624
+ r.size === 0 && V.delete(this);
625
625
  }
626
- return n.call(this, o, r, a);
626
+ return o.call(this, n, i, l);
627
627
  };
628
628
  }
629
- function at(e) {
630
- const t = j.get(e);
629
+ function ft(e) {
630
+ const t = V.get(e);
631
631
  if (t) {
632
- for (const { type: n, listener: o, options: r } of t)
633
- e.removeEventListener(n, o, r);
634
- j.delete(e);
632
+ for (const { type: o, listener: n, options: i } of t)
633
+ e.removeEventListener(o, n, i);
634
+ V.delete(e);
635
635
  }
636
636
  }
637
- function Ae(e) {
637
+ function Se(e) {
638
638
  if (typeof document > "u" || typeof NodeFilter > "u" || typeof Element > "u")
639
639
  return;
640
640
  const t = document.createTreeWalker(e, NodeFilter.SHOW_ELEMENT);
641
- let n = e instanceof Element ? e : null;
642
- for (; n; )
643
- j.has(n) && at(n), n = t.nextNode();
641
+ let o = e instanceof Element ? e : null;
642
+ for (; o; )
643
+ V.has(o) && ft(o), o = t.nextNode();
644
644
  }
645
- function lt() {
646
- J || typeof MutationObserver > "u" || typeof document > "u" || document.body && (J = new MutationObserver((e) => {
645
+ function ut() {
646
+ ee || typeof MutationObserver > "u" || typeof document > "u" || document.body && (ee = new MutationObserver((e) => {
647
647
  for (const t of e)
648
- t.removedNodes.forEach((n) => {
649
- n.nodeType === Node.ELEMENT_NODE && Ae(n);
648
+ t.removedNodes.forEach((o) => {
649
+ o.nodeType === Node.ELEMENT_NODE && Se(o);
650
650
  });
651
- }), J.observe(document.body, { childList: !0, subtree: !0 }));
651
+ }), ee.observe(document.body, { childList: !0, subtree: !0 }));
652
652
  }
653
- const _e = /* @__PURE__ */ new WeakMap(), Te = /* @__PURE__ */ new WeakMap(), U = /* @__PURE__ */ new WeakMap();
654
- let ft = 0;
655
- const V = () => `slot-${++ft}`, W = (e) => typeof e == "object" && e !== null, Q = (e) => typeof e == "symbol" ? e.toString() : String(e), ut = (e) => {
656
- const t = _e.get(e);
653
+ const xe = /* @__PURE__ */ new WeakMap(), Me = /* @__PURE__ */ new WeakMap(), X = /* @__PURE__ */ new WeakMap();
654
+ let dt = 0;
655
+ const H = () => `slot-${++dt}`, W = (e) => typeof e == "object" && e !== null, te = (e) => typeof e == "symbol" ? e.toString() : String(e), ht = (e) => {
656
+ const t = xe.get(e);
657
657
  return t && W(t) ? t : void 0;
658
658
  };
659
- function Se(e) {
660
- const t = Te.get(e);
659
+ function Oe(e) {
660
+ const t = Me.get(e);
661
661
  return t || e;
662
662
  }
663
- const D = (e) => W(e) ? Reflect.get(e, pe) === !0 : !1;
664
- function dt(e) {
665
- const t = D(e) ? Se(e) : e;
666
- return U.get(t);
663
+ const F = (e) => W(e) ? Reflect.get(e, ge) === !0 : !1;
664
+ function pt(e) {
665
+ const t = F(e) ? Oe(e) : e;
666
+ return X.get(t);
667
667
  }
668
- const ht = (e) => e !== null && (typeof e == "string" || typeof e == "number" || typeof e == "boolean" || typeof e == "function" || typeof e > "u"), X = (e) => {
669
- let t = U.get(e);
670
- return t || (t = e.map(() => V()), U.set(e, t)), t;
671
- }, fe = (e) => {
672
- const t = U.get(e);
668
+ const mt = (e) => e !== null && (typeof e == "string" || typeof e == "number" || typeof e == "boolean" || typeof e == "function" || typeof e > "u"), K = (e) => {
669
+ let t = X.get(e);
670
+ return t || (t = e.map(() => H()), X.set(e, t)), t;
671
+ }, he = (e) => {
672
+ const t = X.get(e);
673
673
  if (t && t.length !== e.length)
674
674
  throw new Error(
675
675
  `Slot sidecar invariant violation: slotIds length (${t.length}) does not match array length (${e.length})`
676
676
  );
677
677
  };
678
- function pt(e) {
679
- const t = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new WeakMap();
680
- let o = 0, r = /* @__PURE__ */ new Set();
681
- const a = /* @__PURE__ */ new Map(), i = (f, y) => !!(f === y || f.startsWith(y + ".")), s = (f, y) => {
682
- const b = n.get(f) ?? "";
678
+ function yt(e) {
679
+ const t = /* @__PURE__ */ new Set(), o = /* @__PURE__ */ new WeakMap();
680
+ let n = 0, i = /* @__PURE__ */ new Set();
681
+ const l = /* @__PURE__ */ new Map(), r = (f, y) => !!(f === y || f.startsWith(y + ".")), s = (f, y) => {
682
+ const b = o.get(f) ?? "";
683
683
  return b ? `${b}.${y}` : y;
684
684
  };
685
685
  let c = !1;
686
- const l = (f) => {
687
- r.add(f), o++, c || (c = !0, queueMicrotask(() => {
686
+ const a = (f) => {
687
+ i.add(f), n++, c || (c = !0, queueMicrotask(() => {
688
688
  c = !1, t.forEach((y) => {
689
689
  try {
690
690
  y();
@@ -693,55 +693,55 @@ function pt(e) {
693
693
  }
694
694
  });
695
695
  }));
696
- }, m = (f, y, b) => {
696
+ }, u = (f, y, b) => {
697
697
  if (f === y) return;
698
698
  let w = f.length !== y.length;
699
699
  if (!w) {
700
- for (let u = 0; u < f.length; u++)
701
- if (f[u] !== y[u]) {
700
+ for (let h = 0; h < f.length; h++)
701
+ if (f[h] !== y[h]) {
702
702
  w = !0;
703
703
  break;
704
704
  }
705
705
  }
706
- f.splice(0, f.length, ...y), w && l(b);
707
- }, p = (f, y, b) => {
708
- const w = new Set(f), u = new Set(y);
709
- let d = !1;
710
- for (const g of w)
711
- if (!u.has(g)) {
712
- d = !0;
706
+ f.splice(0, f.length, ...y), w && a(b);
707
+ }, d = (f, y, b) => {
708
+ const w = new Set(f), h = new Set(y);
709
+ let m = !1;
710
+ for (const E of w)
711
+ if (!h.has(E)) {
712
+ m = !0;
713
713
  break;
714
714
  }
715
- if (!d) {
716
- for (const g of u)
717
- if (!w.has(g)) {
718
- d = !0;
715
+ if (!m) {
716
+ for (const E of h)
717
+ if (!w.has(E)) {
718
+ m = !0;
719
719
  break;
720
720
  }
721
721
  }
722
- d && (f.splice(0, f.length, ...y), l(b));
723
- }, N = (f, y, b) => {
724
- const w = new Set(f), u = new Set(y);
725
- f.length !== y.length || [...w].some((g) => !u.has(g)) || [...u].some((g) => !w.has(g)) ? p(f, y, b) : m(f, y, b);
722
+ m && (f.splice(0, f.length, ...y), a(b));
723
+ }, v = (f, y, b) => {
724
+ const w = new Set(f), h = new Set(y);
725
+ f.length !== y.length || [...w].some((E) => !h.has(E)) || [...h].some((E) => !w.has(E)) ? d(f, y, b) : u(f, y, b);
726
726
  }, x = (f, y, b) => {
727
727
  if (f === y) return !1;
728
728
  let w = !1;
729
- for (const u of Object.keys(f))
730
- u in y || (w = !0, Reflect.deleteProperty(f, u));
731
- for (const u of Object.keys(y)) {
732
- const d = f[u], g = y[u];
733
- d !== g && (W(d) && D(d) && W(g) && !D(g) ? (x(
734
- d,
735
- g
736
- ) && (w = !0), d !== g && (w = !0, Reflect.set(f, u, g))) : (w = !0, Reflect.set(f, u, g)));
729
+ for (const h of Object.keys(f))
730
+ h in y || (w = !0, Reflect.deleteProperty(f, h));
731
+ for (const h of Object.keys(y)) {
732
+ const m = f[h], E = y[h];
733
+ m !== E && (W(m) && F(m) && W(E) && !F(E) ? (x(
734
+ m,
735
+ E
736
+ ) && (w = !0), m !== E && (w = !0, Reflect.set(f, h, E))) : (w = !0, Reflect.set(f, h, E)));
737
737
  }
738
738
  return w;
739
- }, S = (f, y, b) => {
740
- const w = X(f);
739
+ }, M = (f, y, b) => {
740
+ const w = K(f);
741
741
  switch (y) {
742
742
  case "push": {
743
- const u = Array.from({ length: b.length }, () => V());
744
- w.push(...u);
743
+ const h = Array.from({ length: b.length }, () => H());
744
+ w.push(...h);
745
745
  break;
746
746
  }
747
747
  case "pop": {
@@ -753,16 +753,16 @@ function pt(e) {
753
753
  break;
754
754
  }
755
755
  case "unshift": {
756
- const u = Array.from({ length: b.length }, () => V());
757
- w.unshift(...u);
756
+ const h = Array.from({ length: b.length }, () => H());
757
+ w.unshift(...h);
758
758
  break;
759
759
  }
760
760
  case "splice": {
761
- const u = b[0] ?? 0, d = b[1] !== void 0 ? b[1] : f.length - u, g = b.slice(2), T = Array.from(
762
- { length: g.length },
763
- () => V()
761
+ const h = b[0] ?? 0, m = b[1] !== void 0 ? b[1] : f.length - h, E = b.slice(2), T = Array.from(
762
+ { length: E.length },
763
+ () => H()
764
764
  );
765
- w.splice(u, d, ...T);
765
+ w.splice(h, m, ...T);
766
766
  break;
767
767
  }
768
768
  case "reverse": {
@@ -770,21 +770,21 @@ function pt(e) {
770
770
  break;
771
771
  }
772
772
  }
773
- fe(f);
774
- }, v = (f, y = "") => {
773
+ he(f);
774
+ }, N = (f, y = "") => {
775
775
  if (f instanceof Node || f instanceof Window || f instanceof Document)
776
776
  return f;
777
- const b = ut(f);
777
+ const b = ht(f);
778
778
  if (b) return b;
779
- y && n.set(f, y), Array.isArray(f) && X(f);
779
+ y && o.set(f, y), Array.isArray(f) && K(f);
780
780
  const w = new Proxy(f, {
781
- get: (u, d, g) => {
782
- if (d === pe) return !0;
783
- if (d === "toJSON")
781
+ get: (h, m, E) => {
782
+ if (m === ge) return !0;
783
+ if (m === "toJSON")
784
784
  return function() {
785
- return Se(u);
785
+ return Oe(h);
786
786
  };
787
- if (Array.isArray(u) && typeof d == "string" && [
787
+ if (Array.isArray(h) && typeof m == "string" && [
788
788
  "push",
789
789
  "pop",
790
790
  "shift",
@@ -792,86 +792,86 @@ function pt(e) {
792
792
  "splice",
793
793
  "reverse",
794
794
  "sort"
795
- ].includes(d)) {
796
- const O = u[d];
797
- if (typeof O == "function")
798
- return function(...I) {
799
- if (d === "sort") {
800
- const k = X(u), h = u.map((C, F) => ({
801
- el: C,
802
- slotId: k[F] || V()
803
- })), E = O.apply(this, I), A = /* @__PURE__ */ new Map();
804
- for (let C = 0; C < h.length; C++) {
805
- const F = h[C].el;
806
- let $ = A.get(F);
807
- $ || ($ = [], A.set(F, $)), $.push(C);
795
+ ].includes(m)) {
796
+ const R = h[m];
797
+ if (typeof R == "function")
798
+ return function(...D) {
799
+ if (m === "sort") {
800
+ const k = K(h), $ = h.map((p, _) => ({
801
+ el: p,
802
+ slotId: k[_] || H()
803
+ })), G = R.apply(this, D), g = /* @__PURE__ */ new Map();
804
+ for (let p = 0; p < $.length; p++) {
805
+ const _ = $[p].el;
806
+ let O = g.get(_);
807
+ O || (O = [], g.set(_, O)), O.push(p);
808
808
  }
809
- for (let C = 0; C < u.length; C++) {
810
- const F = u[C], $ = A.get(F);
811
- if ($ && $.length > 0) {
812
- const Me = $.shift();
813
- k[C] = h[Me].slotId;
809
+ for (let p = 0; p < h.length; p++) {
810
+ const _ = h[p], O = g.get(_);
811
+ if (O && O.length > 0) {
812
+ const L = O.shift();
813
+ k[p] = $[L].slotId;
814
814
  } else
815
- k[C] = V();
815
+ k[p] = H();
816
816
  }
817
- return fe(u), E;
817
+ return he(h), G;
818
818
  } else {
819
- const k = O.apply(this, I);
820
- return S(u, d, I), k;
819
+ const k = R.apply(this, D);
820
+ return M(h, m, D), k;
821
821
  }
822
822
  };
823
823
  }
824
- const T = Reflect.get(u, d, g), M = Array.isArray(u) && typeof d == "string" && /^\d+$/.test(d);
825
- if (W(T) && !D(T) && !M && (Array.isArray(T) || !Array.isArray(u))) {
826
- const L = Q(d), O = s(u, L);
827
- return v(T, O);
824
+ const T = Reflect.get(h, m, E), A = Array.isArray(h) && typeof m == "string" && /^\d+$/.test(m);
825
+ if (W(T) && !F(T) && !A && (Array.isArray(T) || !Array.isArray(h))) {
826
+ const I = te(m), R = s(h, I);
827
+ return N(T, R);
828
828
  }
829
829
  return T;
830
830
  },
831
- set: (u, d, g, T) => {
832
- const M = Reflect.get(u, d, T);
833
- if (M === g) return !0;
834
- const L = Q(d), O = s(u, L);
835
- if (Array.isArray(u) && typeof d == "string" && /^\d+$/.test(d)) {
836
- const k = parseInt(d, 10);
837
- if (k >= 0 && k < u.length) {
838
- const h = Reflect.set(u, d, g, T);
839
- return l(O), h;
831
+ set: (h, m, E, T) => {
832
+ const A = Reflect.get(h, m, T);
833
+ if (A === E) return !0;
834
+ const I = te(m), R = s(h, I);
835
+ if (Array.isArray(h) && typeof m == "string" && /^\d+$/.test(m)) {
836
+ const k = parseInt(m, 10);
837
+ if (k >= 0 && k < h.length) {
838
+ const $ = Reflect.set(h, m, E, T);
839
+ return a(R), $;
840
840
  }
841
841
  }
842
- if (Array.isArray(M) && !ht(g) && Array.isArray(g)) {
843
- N(M, g, O);
844
- const k = M.map(() => V());
845
- return U.set(M, k), !0;
842
+ if (Array.isArray(A) && !mt(E) && Array.isArray(E)) {
843
+ v(A, E, R);
844
+ const k = A.map(() => H());
845
+ return X.set(A, k), !0;
846
846
  }
847
- if (W(M) && D(M) && W(g) && !D(g)) {
847
+ if (W(A) && F(A) && W(E) && !F(E)) {
848
848
  if (x(
849
- M,
850
- g
849
+ A,
850
+ E
851
851
  )) {
852
- let h = g;
853
- W(h) && !D(h) && (h = v(h, O)), Reflect.set(u, d, h, T), l(O);
852
+ let $ = E;
853
+ W($) && !F($) && ($ = N($, R)), Reflect.set(h, m, $, T), a(R);
854
854
  }
855
855
  return !0;
856
856
  }
857
- const I = Reflect.set(u, d, g, T);
858
- if (W(g) && !D(g)) {
859
- const k = v(g, O);
860
- Reflect.set(u, d, k, T), Array.isArray(g) && X(g);
857
+ const D = Reflect.set(h, m, E, T);
858
+ if (W(E) && !F(E)) {
859
+ const k = N(E, R);
860
+ Reflect.set(h, m, k, T), Array.isArray(E) && K(E);
861
861
  }
862
- return l(O), I;
862
+ return a(R), D;
863
863
  },
864
- deleteProperty: (u, d) => {
865
- if (d === "changedPaths")
866
- return Reflect.deleteProperty(u, d);
867
- const g = Q(d), T = s(u, g), M = Reflect.get(u, d), L = Reflect.deleteProperty(u, d);
868
- return L && M !== void 0 && l(T), L;
864
+ deleteProperty: (h, m) => {
865
+ if (m === "changedPaths")
866
+ return Reflect.deleteProperty(h, m);
867
+ const E = te(m), T = s(h, E), A = Reflect.get(h, m), I = Reflect.deleteProperty(h, m);
868
+ return I && A !== void 0 && a(T), I;
869
869
  }
870
870
  });
871
- return _e.set(f, w), Te.set(w, f), w;
871
+ return xe.set(f, w), Me.set(w, f), w;
872
872
  };
873
873
  return {
874
- state: v(e),
874
+ state: N(e),
875
875
  /**
876
876
  * Registers a watcher for a path prefix.
877
877
  * The callback is called at most once per flush cycle with the subset of
@@ -885,14 +885,14 @@ function pt(e) {
885
885
  * @returns A cleanup function stop() that unregisters this watcher (idempotent)
886
886
  */
887
887
  watch(f, y) {
888
- let b = a.get(f);
889
- b || (b = /* @__PURE__ */ new Set(), a.set(f, b)), b.add(y);
888
+ let b = l.get(f);
889
+ b || (b = /* @__PURE__ */ new Set(), l.set(f, b)), b.add(y);
890
890
  let w = !1;
891
891
  return () => {
892
892
  if (w) return;
893
893
  w = !0;
894
- const u = a.get(f);
895
- u && (u.delete(y), u.size === 0 && a.delete(f));
894
+ const h = l.get(f);
895
+ h && (h.delete(y), h.size === 0 && l.delete(f));
896
896
  };
897
897
  },
898
898
  addObserver(f) {
@@ -902,7 +902,7 @@ function pt(e) {
902
902
  t.delete(f);
903
903
  },
904
904
  getStateVersion() {
905
- return o;
905
+ return n;
906
906
  },
907
907
  /**
908
908
  * Checks if any pending changed path matches one of the given prefixes.
@@ -911,7 +911,7 @@ function pt(e) {
911
911
  * @returns True if at least one pending change matches a prefix
912
912
  */
913
913
  hasPendingChangesFor(f) {
914
- for (const y of r)
914
+ for (const y of i)
915
915
  for (const b of f)
916
916
  if (y === b || y.startsWith(b + ".")) return !0;
917
917
  return !1;
@@ -924,50 +924,50 @@ function pt(e) {
924
924
  * @returns A copy of all changed paths since the last flush
925
925
  */
926
926
  flushChanges() {
927
- const f = new Set(r);
928
- if (f.size > 0 && a.size > 0) {
927
+ const f = new Set(i);
928
+ if (f.size > 0 && l.size > 0) {
929
929
  const y = /* @__PURE__ */ new Map();
930
- for (const [b, w] of a) {
931
- const u = /* @__PURE__ */ new Set();
932
- for (const d of f)
933
- i(d, b) && u.add(d);
934
- if (u.size > 0)
935
- for (const d of w) {
936
- const g = y.get(d);
937
- if (g)
938
- for (const T of u)
939
- g.add(T);
930
+ for (const [b, w] of l) {
931
+ const h = /* @__PURE__ */ new Set();
932
+ for (const m of f)
933
+ r(m, b) && h.add(m);
934
+ if (h.size > 0)
935
+ for (const m of w) {
936
+ const E = y.get(m);
937
+ if (E)
938
+ for (const T of h)
939
+ E.add(T);
940
940
  else
941
- y.set(d, new Set(u));
941
+ y.set(m, new Set(h));
942
942
  }
943
943
  }
944
944
  for (const [b, w] of y)
945
945
  b({ changedPaths: w });
946
946
  }
947
- return r = /* @__PURE__ */ new Set(), f;
947
+ return i = /* @__PURE__ */ new Set(), f;
948
948
  }
949
949
  };
950
950
  }
951
- const ee = /^[A-Za-z_$][A-Za-z0-9_$]*$/;
952
- function mt(e) {
951
+ const ne = /^[A-Za-z_$][A-Za-z0-9_$]*$/;
952
+ function gt(e) {
953
953
  const t = e.trim();
954
954
  if (t.startsWith("[") && t.endsWith("]")) {
955
- const o = t.slice(1, -1).split(",").map((i) => i.trim());
956
- if (o.length !== 2)
955
+ const n = t.slice(1, -1).split(",").map((r) => r.trim());
956
+ if (n.length !== 2)
957
957
  throw new Error("Invalid loop binding: expected <id> or [<id>, <id>]");
958
- const [r, a] = o;
959
- if (!ee.test(r) || !ee.test(a))
958
+ const [i, l] = n;
959
+ if (!ne.test(i) || !ne.test(l))
960
960
  throw new Error("Invalid loop binding: expected <id> or [<id>, <id>]");
961
- return { type: "tuple", keyVar: r, itemVar: a };
961
+ return { type: "tuple", keyVar: i, itemVar: l };
962
962
  }
963
- if (!ee.test(t))
963
+ if (!ne.test(t))
964
964
  throw new Error("Invalid loop binding: expected <id> or [<id>, <id>]");
965
965
  return { type: "single", itemVar: t };
966
966
  }
967
- function yt(e) {
967
+ function bt(e) {
968
968
  const t = {
969
- acceptNode(n) {
970
- return n.nodeType === Node.ELEMENT_NODE || n.nodeType === Node.TEXT_NODE && /\{\{(.+?)\}\}/g.test(n.nodeValue || "") ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;
969
+ acceptNode(o) {
970
+ return o.nodeType === Node.ELEMENT_NODE || o.nodeType === Node.TEXT_NODE && /\{\{(.+?)\}\}/g.test(o.nodeValue || "") ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;
971
971
  }
972
972
  };
973
973
  return document.createTreeWalker(
@@ -976,186 +976,186 @@ function yt(e) {
976
976
  t
977
977
  );
978
978
  }
979
- function gt(e) {
979
+ function Et(e) {
980
980
  const t = e.currentNode;
981
981
  return t?.nextSibling ? e.currentNode = t.nextSibling : e.nextNode();
982
982
  }
983
- function bt(e, t) {
984
- let n = t.nextSibling;
985
- if (!n) {
986
- let o = t.parentNode;
987
- for (; o && o !== e.root; ) {
988
- if (o.nextSibling) {
989
- n = o.nextSibling;
983
+ function vt(e, t) {
984
+ let o = t.nextSibling;
985
+ if (!o) {
986
+ let n = t.parentNode;
987
+ for (; n && n !== e.root; ) {
988
+ if (n.nextSibling) {
989
+ o = n.nextSibling;
990
990
  break;
991
991
  }
992
- o = o.parentNode;
992
+ n = n.parentNode;
993
993
  }
994
994
  }
995
- return n ? (e.currentNode = n, n) : null;
995
+ return o ? (e.currentNode = o, o) : null;
996
996
  }
997
- function Et(e) {
997
+ function wt(e) {
998
998
  return e == null || e === !0 || e === !1 ? "" : String(e);
999
999
  }
1000
- function xe(e, t) {
1001
- return e.replace(/\{\{(.+?)\}\}/g, (n, o) => {
1002
- const r = H(o.trim(), t);
1003
- return Et(r);
1000
+ function ke(e, t) {
1001
+ return e.replace(/\{\{(.+?)\}\}/g, (o, n) => {
1002
+ const i = B(n.trim(), t);
1003
+ return wt(i);
1004
1004
  });
1005
1005
  }
1006
- async function vt(e, t, n) {
1007
- const o = e.getAttribute("loop");
1008
- if (!o) return;
1006
+ async function Nt(e, t, o) {
1007
+ const n = e.getAttribute("loop");
1008
+ if (!n) return;
1009
1009
  e.removeAttribute("loop");
1010
- const r = e.getAttribute("if");
1011
- r && e.removeAttribute("if");
1012
- const a = o.match(/^(.+?)\s+in\s+(.+)$/);
1013
- if (!a)
1010
+ const i = e.getAttribute("if");
1011
+ i && e.removeAttribute("if");
1012
+ const l = n.match(/^(.+?)\s+in\s+(.+)$/);
1013
+ if (!l)
1014
1014
  throw new Error("Invalid loop binding: expected <id> or [<id>, <id>]");
1015
- const [, i, s] = a, c = mt(i), l = H(s.trim(), t);
1016
- if (l == null) {
1015
+ const [, r, s] = l, c = gt(r), a = B(s.trim(), t);
1016
+ if (a == null) {
1017
1017
  e.remove();
1018
1018
  return;
1019
1019
  }
1020
- if (typeof l != "object") {
1021
- _.error("State source is not iterable", { collectionExp: s, raw: l });
1020
+ if (typeof a != "object") {
1021
+ S.error("State source is not iterable", { collectionExp: s, raw: a });
1022
1022
  return;
1023
1023
  }
1024
- const m = Array.isArray(l), p = m ? l.map((f, y) => [String(y), f]) : Object.entries(l), N = p.length, x = document.createDocumentFragment(), S = m ? dt(l) : void 0, v = { ...t };
1025
- let P = 0;
1026
- for (const [f, y] of p) {
1027
- if (v.index = P, v.key = f, v.isFirst = P === 0, v.isLast = P === N - 1, v.isEven = P % 2 === 0, v.isOdd = P % 2 !== 0, c.type === "single" || (v[c.keyVar] = f), v[c.itemVar] = y, r && !H(r, v)) {
1028
- P++;
1024
+ const u = Array.isArray(a), d = u ? a.map((f, y) => [String(y), f]) : Object.entries(a), v = d.length, x = document.createDocumentFragment(), M = u ? pt(a) : void 0, N = { ...t };
1025
+ let C = 0;
1026
+ for (const [f, y] of d) {
1027
+ if (N.index = C, N.key = f, N.isFirst = C === 0, N.isLast = C === v - 1, N.isEven = C % 2 === 0, N.isOdd = C % 2 !== 0, c.type === "single" || (N[c.keyVar] = f), N[c.itemVar] = y, i && !B(i, N)) {
1028
+ C++;
1029
1029
  continue;
1030
1030
  }
1031
1031
  const b = e.cloneNode(!0);
1032
- m && b instanceof HTMLElement && S && S[P] !== void 0 && tt(b, S[P]), b instanceof HTMLElement && (await Oe(b, v, n), x.appendChild(b)), P++;
1032
+ u && b instanceof HTMLElement && M && M[C] !== void 0 && ot(b, M[C]), b instanceof HTMLElement && (await $e(b, N, o), x.appendChild(b)), C++;
1033
1033
  }
1034
1034
  x.childNodes.length > 0 && e.parentNode ? e.parentNode.replaceChild(x, e) : e.remove();
1035
1035
  }
1036
- function wt(e, t, n) {
1037
- const o = e.parentNode, r = () => {
1038
- if (o)
1039
- return n.get(o);
1040
- }, a = (l) => {
1041
- o && n.set(o, l);
1042
- }, i = () => {
1043
- o && n.delete(o);
1036
+ function _t(e, t, o) {
1037
+ const n = e.parentNode, i = () => {
1038
+ if (n)
1039
+ return o.get(n);
1040
+ }, l = (a) => {
1041
+ n && o.set(n, a);
1042
+ }, r = () => {
1043
+ n && o.delete(n);
1044
1044
  }, s = e.getAttribute("if");
1045
1045
  if (s !== null) {
1046
- const l = !!H(s, t);
1047
- a({ hasHead: !0, resolved: l }), l ? e.removeAttribute("if") : e.remove();
1046
+ const a = !!B(s, t);
1047
+ l({ hasHead: !0, resolved: a }), a ? e.removeAttribute("if") : e.remove();
1048
1048
  return;
1049
1049
  }
1050
1050
  const c = e.getAttribute("else-if");
1051
1051
  if (c !== null) {
1052
- const l = r();
1053
- if (!l?.hasHead) {
1052
+ const a = i();
1053
+ if (!a?.hasHead) {
1054
1054
  e.remove();
1055
1055
  return;
1056
1056
  }
1057
- if (l.resolved) {
1057
+ if (a.resolved) {
1058
1058
  e.remove();
1059
1059
  return;
1060
1060
  }
1061
- const m = !!H(c, t);
1062
- a({ hasHead: !0, resolved: m }), m ? e.removeAttribute("else-if") : e.remove();
1061
+ const u = !!B(c, t);
1062
+ l({ hasHead: !0, resolved: u }), u ? e.removeAttribute("else-if") : e.remove();
1063
1063
  return;
1064
1064
  }
1065
1065
  if (e.hasAttribute("else")) {
1066
- const l = r();
1067
- if (!l?.hasHead) {
1066
+ const a = i();
1067
+ if (!a?.hasHead) {
1068
1068
  e.remove();
1069
1069
  return;
1070
1070
  }
1071
- l.resolved ? e.remove() : e.removeAttribute("else"), i();
1071
+ a.resolved ? e.remove() : e.removeAttribute("else"), r();
1072
1072
  return;
1073
1073
  }
1074
1074
  }
1075
- async function Nt(e, t, n = 50) {
1076
- const o = /* @__PURE__ */ new WeakMap();
1077
- for (let r = 0; r < e.length; r += n) {
1078
- const a = e.slice(r, r + n);
1079
- for (const { node: i, state: s } of a) {
1080
- if (i instanceof HTMLElement) {
1081
- if (i.hasAttribute("loop")) {
1082
- await vt(i, s, t);
1075
+ async function Ct(e, t, o = 50) {
1076
+ const n = /* @__PURE__ */ new WeakMap();
1077
+ for (let i = 0; i < e.length; i += o) {
1078
+ const l = e.slice(i, i + o);
1079
+ for (const { node: r, state: s } of l) {
1080
+ if (r instanceof HTMLElement) {
1081
+ if (r.hasAttribute("loop")) {
1082
+ await Nt(r, s, t);
1083
1083
  continue;
1084
1084
  }
1085
- if (i.hasAttribute("if") || i.hasAttribute("else") || i.hasAttribute("else-if")) {
1086
- wt(i, s, o);
1085
+ if (r.hasAttribute("if") || r.hasAttribute("else") || r.hasAttribute("else-if")) {
1086
+ _t(r, s, n);
1087
1087
  continue;
1088
1088
  }
1089
1089
  continue;
1090
1090
  }
1091
- const c = xe(i.nodeValue, s);
1091
+ const c = ke(r.nodeValue, s);
1092
1092
  if (Fe(c)) {
1093
- const l = document.createRange().createContextualFragment(c);
1094
- i.replaceWith(l);
1093
+ const a = document.createRange().createContextualFragment(c);
1094
+ r.replaceWith(a);
1095
1095
  } else
1096
- i.nodeValue = c;
1096
+ r.nodeValue = c;
1097
1097
  }
1098
- r + n < e.length && await new Promise(requestAnimationFrame);
1098
+ i + o < e.length && await new Promise(requestAnimationFrame);
1099
1099
  }
1100
1100
  }
1101
- async function Oe(e, t, n) {
1101
+ async function $e(e, t, o) {
1102
1102
  try {
1103
- const o = yt(e), r = /* @__PURE__ */ new Set(), a = [];
1104
- let i = o.currentNode;
1105
- for (; i; ) {
1106
- if (r.has(i)) {
1107
- i = o.nextNode();
1103
+ const n = bt(e), i = /* @__PURE__ */ new Set(), l = [];
1104
+ let r = n.currentNode;
1105
+ for (; r; ) {
1106
+ if (i.has(r)) {
1107
+ r = n.nextNode();
1108
1108
  continue;
1109
1109
  }
1110
- if (r.add(i), i.nodeType === Node.ELEMENT_NODE && i instanceof HTMLElement) {
1111
- const s = i;
1110
+ if (i.add(r), r.nodeType === Node.ELEMENT_NODE && r instanceof HTMLElement) {
1111
+ const s = r;
1112
1112
  if (s.hasAttribute("loop")) {
1113
- a.push({ node: s, state: t }), i = bt(o, s);
1113
+ l.push({ node: s, state: t }), r = vt(n, s);
1114
1114
  continue;
1115
1115
  }
1116
- (s.hasAttribute("if") || s.hasAttribute("else") || s.hasAttribute("else-if")) && a.push({ node: s, state: t });
1116
+ (s.hasAttribute("if") || s.hasAttribute("else") || s.hasAttribute("else-if")) && l.push({ node: s, state: t });
1117
1117
  for (const c of Array.from(s.attributes)) {
1118
- if (c.name === "ref" && (n[c.value] = s), c.name.startsWith(":")) {
1119
- const l = c.name.slice(1), m = c.value.trim();
1118
+ if (c.name === "ref" && (o[c.value] = s), c.name.startsWith(":")) {
1119
+ const a = c.name.slice(1), u = c.value.trim();
1120
1120
  try {
1121
- const p = H(m, t);
1122
- if (l === "class" && typeof p == "object" && p !== null) {
1123
- const N = [];
1124
- for (const [x, S] of Object.entries(p))
1125
- S && N.push(x);
1126
- if (N.length > 0) {
1127
- const x = s.getAttribute("class") || "", S = x ? `${x} ${N.join(" ")}` : N.join(" ");
1128
- s.setAttribute("class", S);
1121
+ const d = B(u, t);
1122
+ if (a === "class" && typeof d == "object" && d !== null) {
1123
+ const v = [];
1124
+ for (const [x, M] of Object.entries(d))
1125
+ M && v.push(x);
1126
+ if (v.length > 0) {
1127
+ const x = s.getAttribute("class") || "", M = x ? `${x} ${v.join(" ")}` : v.join(" ");
1128
+ s.setAttribute("class", M);
1129
1129
  }
1130
- } else p != null && p !== !1 && (p === !0 ? s.setAttribute(l, "") : s.setAttribute(l, String(p)));
1130
+ } else d != null && d !== !1 && (d === !0 ? s.setAttribute(a, "") : s.setAttribute(a, String(d)));
1131
1131
  s.removeAttribute(c.name);
1132
- } catch (p) {
1133
- _.errorWithContext(
1132
+ } catch (d) {
1133
+ S.errorWithContext(
1134
1134
  `Error evaluating dynamic attribute "${c.name}"`,
1135
- { attributeName: c.name, expression: m },
1136
- p
1135
+ { attributeName: c.name, expression: u },
1136
+ d
1137
1137
  );
1138
1138
  }
1139
1139
  continue;
1140
1140
  }
1141
1141
  if (c.value.includes("{{"))
1142
1142
  try {
1143
- let l = xe(c.value, t);
1144
- c.name === "class" && (l = l.replace(/\s+/g, " ").trim()), l !== c.value && s.setAttribute(c.name, l);
1145
- } catch (l) {
1146
- _.errorWithContext(
1143
+ let a = ke(c.value, t);
1144
+ c.name === "class" && (a = a.replace(/\s+/g, " ").trim()), a !== c.value && s.setAttribute(c.name, a);
1145
+ } catch (a) {
1146
+ S.errorWithContext(
1147
1147
  `Error replacing attribute "${c.name}"`,
1148
1148
  { attributeName: c.name },
1149
- l
1149
+ a
1150
1150
  );
1151
1151
  }
1152
1152
  }
1153
1153
  if (s.tagName.includes("-")) {
1154
- i = gt(o) || o.nextNode();
1154
+ r = Et(n) || n.nextNode();
1155
1155
  continue;
1156
1156
  }
1157
- } else if (i.nodeType === Node.TEXT_NODE && i instanceof Text) {
1158
- let s = i.parentElement, c = !1;
1157
+ } else if (r.nodeType === Node.TEXT_NODE && r instanceof Text) {
1158
+ let s = r.parentElement, c = !1;
1159
1159
  for (; s; ) {
1160
1160
  if (s.tagName.includes("-")) {
1161
1161
  c = !0;
@@ -1163,154 +1163,200 @@ async function Oe(e, t, n) {
1163
1163
  }
1164
1164
  s = s.parentElement;
1165
1165
  }
1166
- c || a.push({ node: i, state: t });
1166
+ c || l.push({ node: r, state: t });
1167
1167
  }
1168
- i = o.nextNode();
1168
+ r = n.nextNode();
1169
1169
  }
1170
- await Nt(a, n);
1171
- } catch (o) {
1172
- throw _.errorWithContext("Error processing template", {}, o), o;
1170
+ await Ct(l, o);
1171
+ } catch (n) {
1172
+ throw S.errorWithContext("Error processing template", {}, n), n;
1173
1173
  }
1174
1174
  }
1175
- function Ct(e, t = {}) {
1175
+ function At(e, t = {}) {
1176
1176
  if (!Array.isArray(e) || e.length === 0)
1177
1177
  throw new Error("composeBySource: layers must be a non-empty array");
1178
1178
  if (e.some((s) => s == null || typeof s != "object"))
1179
1179
  throw new Error("composeBySource: all layers must be objects");
1180
- const { defaultWriteIndex: n = e.length - 1, includePrototype: o = !1 } = t, r = n >= 0 && n < e.length && Number.isInteger(n) ? n : e.length - 1;
1181
- n !== r && _.warnWithContext(
1182
- `Invalid defaultWriteIndex ${n}, using ${r}`,
1183
- { defaultWriteIndex: n, validWriteIndex: r, layersLength: e.length }
1180
+ const { defaultWriteIndex: o = e.length - 1, includePrototype: n = !1 } = t, i = o >= 0 && o < e.length && Number.isInteger(o) ? o : e.length - 1;
1181
+ o !== i && S.warnWithContext(
1182
+ `Invalid defaultWriteIndex ${o}, using ${i}`,
1183
+ { defaultWriteIndex: o, validWriteIndex: i, layersLength: e.length }
1184
1184
  );
1185
- const a = (s, c) => o ? c in s : Object.prototype.hasOwnProperty.call(s, c), i = (s) => {
1185
+ const l = (s, c) => n ? c in s : Object.prototype.hasOwnProperty.call(s, c), r = (s) => {
1186
1186
  for (let c = 0; c < e.length; c++)
1187
- if (a(e[c], s)) return c;
1187
+ if (l(e[c], s)) return c;
1188
1188
  return -1;
1189
1189
  };
1190
- return new Proxy(e[r], {
1190
+ return new Proxy(e[i], {
1191
1191
  get(s, c) {
1192
- const l = i(c);
1193
- if (l !== -1) return e[l][c];
1192
+ const a = r(c);
1193
+ if (a !== -1) return e[a][c];
1194
1194
  },
1195
- set(s, c, l) {
1196
- const m = i(c), p = m !== -1 ? m : r;
1197
- return e[p][c] = l, !0;
1195
+ set(s, c, a) {
1196
+ const u = r(c), d = u !== -1 ? u : i;
1197
+ return e[d][c] = a, !0;
1198
1198
  },
1199
1199
  deleteProperty(s, c) {
1200
- const l = i(c);
1201
- return l === -1 ? !0 : delete e[l][c];
1200
+ const a = r(c);
1201
+ return a === -1 ? !0 : delete e[a][c];
1202
1202
  },
1203
1203
  has(s, c) {
1204
- return i(c) !== -1;
1204
+ return r(c) !== -1;
1205
1205
  },
1206
1206
  ownKeys() {
1207
1207
  const s = /* @__PURE__ */ new Set();
1208
1208
  for (const c of e)
1209
- Reflect.ownKeys(c).forEach((l) => {
1210
- typeof l != "number" && s.add(l);
1209
+ Reflect.ownKeys(c).forEach((a) => {
1210
+ typeof a != "number" && s.add(a);
1211
1211
  });
1212
1212
  return Array.from(s);
1213
1213
  },
1214
1214
  getOwnPropertyDescriptor(s, c) {
1215
- for (const l of e) {
1216
- const m = Object.getOwnPropertyDescriptor(l, c);
1217
- if (m) return m;
1215
+ for (const a of e) {
1216
+ const u = Object.getOwnPropertyDescriptor(a, c);
1217
+ if (u) return u;
1218
1218
  }
1219
1219
  }
1220
1220
  });
1221
1221
  }
1222
- function ue(e) {
1223
- const t = e.getRootNode(), n = e.parentElement ?? (t instanceof ShadowRoot ? t.host : void 0);
1224
- if (Ze(n))
1225
- return n.instance;
1222
+ function pe(e) {
1223
+ const t = e.getRootNode(), o = e.parentElement ?? (t instanceof ShadowRoot ? t.host : void 0);
1224
+ if (Je(o))
1225
+ return o.instance;
1226
1226
  }
1227
- function At({
1227
+ function Tt({
1228
1228
  container: e,
1229
1229
  host: t
1230
1230
  }) {
1231
- const n = Array.from(t.childNodes).filter(
1232
- (r) => r.nodeType === Node.ELEMENT_NODE || r.nodeType === Node.TEXT_NODE
1233
- ), o = {};
1234
- for (const r of n) {
1235
- const a = r instanceof HTMLElement && r.hasAttribute("slot") ? r.getAttribute("slot") : "default";
1236
- o[a] || (o[a] = []), o[a].push(r);
1231
+ const o = Array.from(t.childNodes).filter(
1232
+ (i) => i.nodeType === Node.ELEMENT_NODE || i.nodeType === Node.TEXT_NODE
1233
+ ), n = {};
1234
+ for (const i of o) {
1235
+ const l = i instanceof HTMLElement && i.hasAttribute("slot") ? i.getAttribute("slot") : "default";
1236
+ n[l] || (n[l] = []), n[l].push(i);
1237
1237
  }
1238
- e.querySelectorAll("slot").forEach((r) => {
1239
- const a = r.getAttribute("name") || "default", i = o[a];
1240
- i && i.length > 0 && i.forEach((s) => {
1241
- r.parentNode.insertBefore(s, r);
1242
- }), r.remove();
1238
+ e.querySelectorAll("slot").forEach((i) => {
1239
+ const l = i.getAttribute("name") || "default", r = n[l];
1240
+ r && r.length > 0 && r.forEach((s) => {
1241
+ i.parentNode.insertBefore(s, i);
1242
+ }), i.remove();
1243
1243
  });
1244
1244
  }
1245
- function te({
1245
+ function St(e, t, o) {
1246
+ const n = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map(), l = () => {
1247
+ for (const a of Object.keys(o)) {
1248
+ const u = n.get(o[a]);
1249
+ u instanceof HTMLElement && (o[a] = u);
1250
+ }
1251
+ };
1252
+ if (!e.querySelector("slot")) return { commit: () => {
1253
+ }, remapRefs: l };
1254
+ const r = document.createElement("div"), s = (a) => {
1255
+ const u = a.cloneNode(!1);
1256
+ if (n.set(u, a), !(a instanceof HTMLElement && a.tagName.includes("-")))
1257
+ for (const d of a.childNodes) u.appendChild(s(d));
1258
+ return i.set(u, {
1259
+ attributes: new Map(
1260
+ a instanceof HTMLElement ? Array.from(a.attributes, (d) => [d.name, d.value]) : []
1261
+ ),
1262
+ children: Array.from(u.childNodes),
1263
+ value: u.nodeValue
1264
+ }), u;
1265
+ };
1266
+ for (const a of t.childNodes) r.appendChild(s(a));
1267
+ return Tt({ container: e, host: r }), { commit: () => {
1268
+ const a = (u) => {
1269
+ const d = n.get(u), v = i.get(u), x = Array.from(u.childNodes), M = x.map(a);
1270
+ if (!d || !v)
1271
+ return x.forEach((N, C) => {
1272
+ M[C] !== N && N.replaceWith(M[C]);
1273
+ }), u;
1274
+ if (d instanceof HTMLElement && u instanceof HTMLElement) {
1275
+ for (const N of v.attributes.keys())
1276
+ u.hasAttribute(N) || d.removeAttribute(N);
1277
+ for (const N of Array.from(u.attributes))
1278
+ v.attributes.get(N.name) !== N.value && d.setAttribute(N.name, N.value);
1279
+ !d.tagName.includes("-") && (x.length !== v.children.length || x.some((N, C) => N !== v.children[C])) && d.replaceChildren(...M);
1280
+ } else u.nodeValue !== v.value && (d.nodeValue = u.nodeValue);
1281
+ return d;
1282
+ };
1283
+ for (const u of Array.from(e.childNodes)) {
1284
+ const d = a(u);
1285
+ d !== u && u.replaceWith(d);
1286
+ }
1287
+ l();
1288
+ }, remapRefs: l };
1289
+ }
1290
+ function oe({
1246
1291
  propName: e,
1247
1292
  propValue: t,
1248
- props: n
1293
+ props: o
1249
1294
  }) {
1250
- const o = n[e], r = t ?? o?.default;
1251
- if (!o) return !0;
1252
- const a = We(o.type), i = Array.isArray(r) ? "array" : typeof r, s = {
1253
- string: i === "string",
1254
- number: i === "number",
1255
- boolean: i === "boolean",
1256
- array: Array.isArray(r),
1257
- object: i === "object" && r !== null && !Array.isArray(r),
1258
- function: i === "function"
1295
+ const n = o[e], i = t ?? n?.default;
1296
+ if (!n) return !0;
1297
+ const l = Ve(n.type), r = Array.isArray(i) ? "array" : typeof i, s = {
1298
+ string: r === "string",
1299
+ number: r === "number",
1300
+ boolean: r === "boolean",
1301
+ array: Array.isArray(i),
1302
+ object: r === "object" && i !== null && !Array.isArray(i),
1303
+ function: r === "function"
1259
1304
  };
1260
- return (a === "unknown" ? !0 : s[a] ?? !1) ? o.regex && typeof r == "string" && !new RegExp(o.regex).test(r) ? (_.error(`Prop "${e}" does not match regex "${o.regex}".`), !1) : !0 : (_.error(
1261
- `Prop "${e}" should be of type "${a}", but got "${i}".`,
1262
- r
1305
+ return (l === "unknown" ? !0 : s[l] ?? !1) ? n.regex && typeof i == "string" && !new RegExp(n.regex).test(i) ? (S.error(`Prop "${e}" does not match regex "${n.regex}".`), !1) : !0 : (S.error(
1306
+ `Prop "${e}" should be of type "${l}", but got "${r}".`,
1307
+ i
1263
1308
  ), !1);
1264
1309
  }
1265
- function de({
1310
+ function me({
1266
1311
  ele: e,
1267
1312
  parent: t,
1268
- props: n,
1269
- state: o
1313
+ props: o,
1314
+ state: n
1270
1315
  }) {
1271
- const r = Object.keys(n).length > 0, a = (i, s) => {
1272
- Object.defineProperty(o, i, {
1316
+ const i = Object.keys(o).length > 0, l = (r, s) => {
1317
+ Object.defineProperty(n, r, {
1273
1318
  enumerable: !0,
1274
1319
  configurable: !0,
1275
1320
  get() {
1276
1321
  if (t)
1277
- return ne(t.state, s);
1322
+ return re(t.state, s);
1278
1323
  },
1279
1324
  set(c) {
1280
1325
  if (!(!t || !t.state))
1281
1326
  try {
1282
- De(t.state, s, c);
1283
- } catch (l) {
1284
- _.errorWithContext(
1285
- `Failed to set bound prop "${i}" → "${s}"`,
1286
- { propName: i, parentPath: s },
1287
- l
1327
+ je(t.state, s, c);
1328
+ } catch (a) {
1329
+ S.errorWithContext(
1330
+ `Failed to set bound prop "${r}" → "${s}"`,
1331
+ { propName: r, parentPath: s },
1332
+ a
1288
1333
  );
1289
1334
  }
1290
1335
  }
1291
1336
  });
1292
1337
  };
1293
- for (const i of e.attributes) {
1294
- const s = i.name.startsWith(":"), c = He(i.name.substring(s ? 1 : 0));
1295
- if (s && !t || !(!r || n[c] && n[c] !== void 0)) continue;
1338
+ for (const r of e.attributes) {
1339
+ const s = r.name.startsWith(":"), c = qe(r.name.substring(s ? 1 : 0));
1340
+ if (s && !t || !(!i || o[c] && o[c] !== void 0)) continue;
1296
1341
  if (!s) {
1297
- const N = i.value !== "" ? i.value : !0;
1298
- (!r || te({ propName: c, propValue: N, props: n })) && (o[c] = N);
1342
+ const v = r.value !== "" ? r.value : !0;
1343
+ (!i || oe({ propName: c, propValue: v, props: o })) && (n[c] = v);
1299
1344
  continue;
1300
1345
  }
1301
- const m = i.value?.trim() ?? "";
1302
- if (m && me(m)) {
1303
- const N = ne(t.state, m);
1304
- (!r || te({ propName: c, propValue: N, props: n })) && a(c, m);
1346
+ const u = r.value?.trim() ?? "";
1347
+ if (u && be(u)) {
1348
+ const v = re(t.state, u);
1349
+ (!i || oe({ propName: c, propValue: v, props: o })) && l(c, u);
1305
1350
  continue;
1306
1351
  }
1307
- const p = m ? H(m, t.state) : void 0;
1308
- (!r || te({ propName: c, propValue: p, props: n })) && (o[c] = p);
1352
+ const d = u ? B(u, t.state) : void 0;
1353
+ (!i || oe({ propName: c, propValue: d, props: o })) && (n[c] = d);
1309
1354
  }
1310
- for (const [i, s] of Object.entries(n))
1311
- i in o || (s.default !== void 0 ? o[i] = s.default : s.required && _.error(`Required prop "${i}" is missing.`));
1355
+ for (const [r, s] of Object.entries(o))
1356
+ r in n || (s.default !== void 0 ? n[r] = s.default : s.required && S.error(`Required prop "${r}" is missing.`));
1312
1357
  }
1313
- function _t(e, t) {
1358
+ function xt(e, t) {
1359
+ const o = /* @__PURE__ */ new Set();
1314
1360
  customElements.define(
1315
1361
  e,
1316
1362
  class extends HTMLElement {
@@ -1320,6 +1366,7 @@ function _t(e, t) {
1320
1366
  */
1321
1367
  instance;
1322
1368
  // Cleanup state for deterministic teardown
1369
+ _connectionVersion = 0;
1323
1370
  _isDisconnected = !1;
1324
1371
  _isMounted = !1;
1325
1372
  // Track if component has been mounted (persists across connectedCallback calls)
@@ -1333,176 +1380,176 @@ function _t(e, t) {
1333
1380
  super(), this.template = document.createElement("template"), this.template.innerHTML = t.template;
1334
1381
  }
1335
1382
  async connectedCallback() {
1336
- const n = this;
1383
+ const n = this, i = ++this._connectionVersion;
1384
+ if (this._isDisconnected = !1, this._renderAborted = !1, this._pendingRender = null, o.add(this), !document.head.querySelector(`style#style-${e}`)) {
1385
+ const g = document.createElement("style");
1386
+ g.id = `style-${e}`, g.textContent = t.style, document.head.appendChild(g);
1387
+ }
1337
1388
  if (n.instance && this._model && this._observerFn) {
1338
- const h = n.instance, E = ue(n);
1339
- h.$parent = E, this._isDisconnected = !1, this._renderAborted = !1, this._pendingRender = null, this._model.addObserver(this._observerFn), this._isMounted = !0, h.props && h.state && de({
1389
+ const g = n.instance, p = pe(n);
1390
+ g.$parent = p, this._isDisconnected = !1, this._renderAborted = !1, this._pendingRender = null, this._model.addObserver(this._observerFn), g.props && g.state && me({
1340
1391
  ele: n,
1341
- parent: E,
1342
- props: h.props,
1343
- state: h.state
1392
+ parent: p,
1393
+ props: g.props,
1394
+ state: g.state
1344
1395
  });
1345
1396
  return;
1346
1397
  }
1347
- const r = (t.type || "options") === "options", a = ue(n), i = this.template.cloneNode(!0);
1348
- let s;
1398
+ const r = (t.type || "options") === "options", s = pe(n), c = this.template.cloneNode(!0);
1399
+ let a;
1349
1400
  if (t.deps) {
1350
- s = {};
1351
- const h = Object.entries(t.deps), E = await Promise.all(
1352
- h.map(([, A]) => A())
1401
+ a = {};
1402
+ const g = Object.entries(t.deps), p = await Promise.all(
1403
+ g.map(([, _]) => _())
1353
1404
  );
1354
- for (let A = 0; A < h.length; A++)
1355
- s[h[A][0]] = E[A];
1405
+ for (let _ = 0; _ < g.length; _++)
1406
+ a[g[_][0]] = p[_];
1356
1407
  }
1357
- const c = Xe(t.script, s), l = {};
1358
- let m = !1, p = -1;
1408
+ if (i !== this._connectionVersion || this._isDisconnected) return;
1409
+ const u = Ke(t.script, a), d = {};
1410
+ let v = !1, x = -1;
1359
1411
  this._isDisconnected = !1, this._renderAborted = !1, this._pendingRender = null;
1360
- const N = ye(), x = (() => {
1361
- let h;
1362
- return { promise: new Promise((A) => {
1363
- h = A;
1364
- }), resolve: h };
1412
+ const M = Ee(), N = (() => {
1413
+ let g;
1414
+ return { promise: new Promise((_) => {
1415
+ g = _;
1416
+ }), resolve: g };
1365
1417
  })();
1366
- if (!document.head.querySelector(`style#style-${e}`)) {
1367
- const h = document.createElement("style");
1368
- h.id = `style-${e}`, h.textContent = t.style, document.head.appendChild(h);
1369
- }
1370
- let S, v;
1371
- const P = (h) => {
1372
- const E = G.plugins[h];
1373
- if (!E || typeof E.setup != "function") {
1374
- _.warnWithContext(
1375
- `Plugin "${h}" not found or has no setup method`,
1376
- { pluginName: h }
1418
+ let C, f;
1419
+ const y = (g) => {
1420
+ const p = Z.plugins[g];
1421
+ if (!p || typeof p.setup != "function") {
1422
+ S.warnWithContext(
1423
+ `Plugin "${g}" not found or has no setup method`,
1424
+ { pluginName: g }
1377
1425
  );
1378
1426
  return;
1379
1427
  }
1380
1428
  try {
1381
- const A = r && v ? v : S;
1382
- return E.setup.call(A);
1383
- } catch (A) {
1384
- _.errorWithContext(
1385
- `Plugin "${h}" setup failed`,
1386
- { pluginName: h },
1387
- A
1429
+ const _ = r && f ? f : C;
1430
+ return p.setup.call(_);
1431
+ } catch (_) {
1432
+ S.errorWithContext(
1433
+ `Plugin "${g}" setup failed`,
1434
+ { pluginName: g },
1435
+ _
1388
1436
  );
1389
1437
  return;
1390
1438
  }
1391
- }, f = {};
1392
- for (const [h, E] of Object.entries(G.modules))
1393
- if (typeof E.attach == "function") {
1394
- const A = E.attach.call({
1439
+ }, b = {};
1440
+ for (const [g, p] of Object.entries(Z.modules))
1441
+ if (typeof p.attach == "function") {
1442
+ const _ = p.attach.call({
1395
1443
  element: n,
1396
- parent: a,
1397
- core: { take: ke.take }
1444
+ parent: s,
1445
+ core: { take: Pe.take }
1398
1446
  });
1399
- A && (f[`$${h}`] = A);
1447
+ _ && (b[`$${g}`] = _);
1400
1448
  }
1401
- const y = /* @__PURE__ */ new Map(), b = (h) => {
1402
- let E = y.get(h);
1403
- return E || (E = `on${h.charAt(0).toUpperCase()}${h.slice(1)}`, y.set(h, E)), E;
1404
- }, w = (h, ...E) => {
1405
- const A = b(h);
1406
- let C = a;
1407
- for (; C; ) {
1408
- const F = C.userContext;
1409
- if (F) {
1410
- const $ = F[A];
1411
- typeof $ == "function" && $(...E);
1412
- } else if (C.methods) {
1413
- const $ = C.methods[A];
1414
- typeof $ == "function" && $(...E);
1449
+ const w = /* @__PURE__ */ new Map(), h = (g) => {
1450
+ let p = w.get(g);
1451
+ return p || (p = `on${g.charAt(0).toUpperCase()}${g.slice(1)}`, w.set(g, p)), p;
1452
+ }, m = (g, ...p) => {
1453
+ const _ = h(g);
1454
+ let O = s;
1455
+ for (; O; ) {
1456
+ const L = O.userContext;
1457
+ if (L) {
1458
+ const j = L[_];
1459
+ typeof j == "function" && j(...p);
1460
+ } else if (O.methods) {
1461
+ const j = O.methods[_];
1462
+ typeof j == "function" && j(...p);
1415
1463
  }
1416
- C = C.$parent;
1464
+ O = O.$parent;
1417
1465
  }
1418
- }, u = {
1419
- $refs: l,
1420
- $parent: a,
1421
- $emit: w,
1422
- $take: P,
1423
- ...f
1424
- }, d = c(u), g = pt(d.state ?? {});
1425
- S = g.state;
1426
- const T = d.methods || {}, M = d.props || {}, L = d.events || [];
1427
- let O = d.watchList || [];
1428
- r && (v = Ct([T, S])), de({
1466
+ }, E = {
1467
+ $refs: d,
1468
+ $parent: s,
1469
+ $emit: m,
1470
+ $take: y,
1471
+ ...b
1472
+ }, T = u(E), A = yt(T.state ?? {});
1473
+ C = A.state;
1474
+ const I = T.methods || {}, R = T.props || {}, D = T.events || [];
1475
+ let k = T.watchList || [];
1476
+ r && (f = At([I, C])), me({
1429
1477
  ele: n,
1430
- parent: a,
1431
- props: M,
1432
- state: S
1433
- }), r && v && Le(T, v);
1434
- for (const h of Ie) {
1435
- const E = d[h];
1436
- if (typeof E == "function") {
1437
- const A = r && v ? K(E, v) : E;
1438
- be(N, h, async () => {
1439
- const C = A();
1440
- C instanceof Promise && await C;
1478
+ parent: s,
1479
+ props: R,
1480
+ state: C
1481
+ }), r && f && We(I, f);
1482
+ for (const g of De) {
1483
+ const p = T[g];
1484
+ if (typeof p == "function") {
1485
+ const _ = r && f ? Y(p, f) : p;
1486
+ we(M, g, async () => {
1487
+ const O = _();
1488
+ O instanceof Promise && await O;
1441
1489
  });
1442
1490
  }
1443
1491
  }
1444
- this._model = g;
1445
- const I = async () => {
1492
+ this._model = A;
1493
+ const $ = async () => {
1446
1494
  if (this._isDisconnected)
1447
1495
  return;
1448
- if (m) {
1449
- this._renderAborted = !0, this._pendingRender = I;
1496
+ if (v) {
1497
+ this._renderAborted = !0, this._pendingRender = $;
1450
1498
  return;
1451
1499
  }
1452
- const h = g.getStateVersion();
1453
- if (p !== h) {
1454
- m = !0, this._renderAborted = !1, n.instance && (n.instance.isRendering = !0);
1500
+ const g = A.getStateVersion();
1501
+ if (x !== g) {
1502
+ v = !0, this._renderAborted = !1, n.instance && (n.instance.isRendering = !0);
1455
1503
  try {
1456
- const E = i.content.cloneNode(!0);
1457
- if (At({ container: E, host: n }), await Oe(E, r && v ? v : S, l), this._renderAborted) {
1458
- this._pendingRender = I;
1504
+ const p = c.content.cloneNode(!0), _ = St(p, n, d);
1505
+ if (await $e(p, r && f ? f : C, d), _.remapRefs(), this._renderAborted || this._model !== A) {
1506
+ this._pendingRender = $;
1459
1507
  return;
1460
1508
  }
1461
- const C = r && v ? v : S;
1462
- if (await R("global", "processed", C), await R(N, "processed"), this._renderAborted) {
1463
- this._pendingRender = I;
1509
+ const L = r && f ? f : C;
1510
+ if (await P("global", "processed", L), await P(M, "processed"), this._renderAborted || this._model !== A) {
1511
+ this._pendingRender = $;
1464
1512
  return;
1465
1513
  }
1466
- r && v ? (rt(v, E), this._eventCleanup && this._eventCleanup(), this._eventCleanup = ot(v, L, E, l)) : (it(T, E), this._eventCleanup && this._eventCleanup(), this._eventCleanup = st(
1467
- T,
1468
- S,
1469
- L,
1470
- E,
1471
- l
1472
- ));
1473
- const F = g.flushChanges();
1474
- Object.defineProperty(C, "changedPaths", {
1475
- value: F,
1514
+ const j = A.flushChanges();
1515
+ Object.defineProperty(L, "changedPaths", {
1516
+ value: j,
1476
1517
  writable: !0,
1477
1518
  configurable: !0,
1478
1519
  enumerable: !1
1479
1520
  });
1480
- const $ = !this._isMounted;
1481
- if (await R(
1521
+ const le = !this._isMounted;
1522
+ if (await P(
1482
1523
  "global",
1483
- $ ? "beforeMount" : "beforeUpdate",
1484
- C
1485
- ), await R(
1486
- N,
1487
- $ ? "beforeMount" : "beforeUpdate",
1488
- C
1489
- ), this._renderAborted) {
1490
- delete C.changedPaths, this._pendingRender = I;
1524
+ le ? "beforeMount" : "beforeUpdate",
1525
+ L
1526
+ ), await P(
1527
+ M,
1528
+ le ? "beforeMount" : "beforeUpdate",
1529
+ L
1530
+ ), this._renderAborted || this._model !== A) {
1531
+ delete L.changedPaths, this._pendingRender = $;
1491
1532
  return;
1492
1533
  }
1493
- et(n, E, !this._isMounted, t.structAttr), this._isMounted && (await R("global", "updated", C), await R(N, "updated", C)), delete C.changedPaths, p = h, n.instance && (n.instance._lastRenderedStateVersion = p);
1494
- } catch (E) {
1495
- _.errorWithContext("Error during render", { componentName: e }, E);
1534
+ _.commit(), r && f ? (st(f, p), this._eventCleanup && this._eventCleanup(), this._eventCleanup = it(f, D, p, d)) : (ct(I, p), this._eventCleanup && this._eventCleanup(), this._eventCleanup = at(
1535
+ I,
1536
+ C,
1537
+ D,
1538
+ p,
1539
+ d
1540
+ )), nt(n, p, !this._isMounted, t.structAttr), this._isMounted && (await P("global", "updated", L), await P(M, "updated", L)), delete L.changedPaths, x = g, n.instance && (n.instance._lastRenderedStateVersion = x);
1541
+ } catch (p) {
1542
+ S.errorWithContext("Error during render", { componentName: e }, p);
1496
1543
  } finally {
1497
- const E = r && v ? v : S;
1498
- if (delete E.changedPaths, m = !1, n.instance && (n.instance.isRendering = !1), this._pendingRender && !this._isDisconnected) {
1499
- const A = this._pendingRender;
1544
+ const p = r && f ? f : C;
1545
+ if (delete p.changedPaths, v = !1, n.instance && (n.instance.isRendering = !1), this._pendingRender && !this._isDisconnected) {
1546
+ const _ = this._pendingRender;
1500
1547
  this._pendingRender = null, requestAnimationFrame(() => {
1501
- this._isDisconnected || A().catch((C) => {
1502
- _.errorWithContext(
1548
+ this._isDisconnected || _().catch((O) => {
1549
+ S.errorWithContext(
1503
1550
  "Error during pending render",
1504
1551
  { componentName: e },
1505
- C
1552
+ O
1506
1553
  );
1507
1554
  });
1508
1555
  });
@@ -1512,104 +1559,109 @@ function _t(e, t) {
1512
1559
  };
1513
1560
  n.instance = {
1514
1561
  element: n,
1515
- template: i,
1516
- state: S,
1517
- userContext: r ? v : void 0,
1518
- props: M,
1519
- methods: T,
1520
- events: L,
1521
- watchList: O,
1522
- $refs: l,
1523
- $parent: a,
1524
- $emit: w,
1525
- $take: P,
1526
- readyPromise: x.promise,
1527
- lifecycleRegistry: N,
1528
- ...f,
1562
+ template: c,
1563
+ state: C,
1564
+ userContext: r ? f : void 0,
1565
+ props: R,
1566
+ methods: I,
1567
+ events: D,
1568
+ watchList: k,
1569
+ $refs: d,
1570
+ $parent: s,
1571
+ $emit: m,
1572
+ $take: y,
1573
+ readyPromise: N.promise,
1574
+ lifecycleRegistry: M,
1575
+ ...b,
1529
1576
  isRendering: !1
1530
1577
  }, this._observerFn = () => {
1531
- if (this._isDisconnected || O && O.length > 0 && !g.hasPendingChangesFor(O))
1578
+ if (this._isDisconnected || k && k.length > 0 && !A.hasPendingChangesFor(k))
1532
1579
  return;
1533
- let h = a;
1534
- for (; h; ) {
1535
- if (h.isRendering)
1580
+ let g = s;
1581
+ for (; g; ) {
1582
+ if (g.isRendering)
1536
1583
  return;
1537
- h = h.$parent;
1584
+ g = g.$parent;
1538
1585
  }
1539
1586
  requestAnimationFrame(() => {
1540
- this._isDisconnected || I().catch((E) => {
1541
- _.errorWithContext(
1587
+ this._isDisconnected || $().catch((p) => {
1588
+ S.errorWithContext(
1542
1589
  "Error during render (observer)",
1543
1590
  { componentName: e },
1544
- E
1591
+ p
1545
1592
  );
1546
1593
  });
1547
1594
  });
1548
- }, g.addObserver(this._observerFn);
1549
- const k = r && v ? v : S;
1550
- await R("global", "created", k), await R(N, "created"), await I(), this._isMounted || (await R("global", "mounted", k), await R(N, "mounted"), this._isMounted = !0), x.resolve();
1595
+ }, A.addObserver(this._observerFn);
1596
+ const G = r && f ? f : C;
1597
+ if (await P("global", "created", G), await P(M, "created"), !(this._isDisconnected || this._model !== A) && (await $(), !(this._isDisconnected || this._model !== A))) {
1598
+ if (!this._isMounted) {
1599
+ if (await P("global", "mounted", G), this._isDisconnected || this._model !== A || (await P(M, "mounted"), this._isDisconnected || this._model !== A)) return;
1600
+ this._isMounted = !0;
1601
+ }
1602
+ N.resolve();
1603
+ }
1551
1604
  }
1552
1605
  async disconnectedCallback() {
1553
- const n = this;
1554
- if (!n.instance) return;
1555
- this._isMounted = !1;
1556
- const o = n.instance;
1606
+ const n = this, i = ++this._connectionVersion;
1607
+ if (this._isDisconnected = !0, this._renderAborted = !0, this._pendingRender = null, o.delete(this), o.size === 0 && document.head.querySelector(`style#style-${e}`)?.remove(), !n.instance) return;
1608
+ const l = n.instance;
1557
1609
  this._isDisconnected = !0, this._renderAborted = !0, this._pendingRender = null, this._model && this._observerFn && this._model.removeObserver(this._observerFn);
1558
- const r = o.userContext || o.state;
1559
- await R("global", "beforeDestroy", r), await R(o.lifecycleRegistry, "beforeDestroy"), this._isDisconnected && (Ae(this), this._eventCleanup && (this._eventCleanup(), this._eventCleanup = null), document.body.querySelector(this.tagName.toLowerCase()) || document.head.querySelector(`style#style-${this.tagName.toLowerCase()}`)?.remove(), await R("global", "destroyed", r), await R(o.lifecycleRegistry, "destroyed"), this._isDisconnected && (this._model = void 0, this._observerFn = void 0, this._eventCleanup = null, n.instance = void 0));
1610
+ const r = l.userContext || l.state;
1611
+ await P("global", "beforeDestroy", r), await P(l.lifecycleRegistry, "beforeDestroy"), !(!this._isDisconnected || i !== this._connectionVersion) && (Se(this), this._eventCleanup && (this._eventCleanup(), this._eventCleanup = null), await P("global", "destroyed", r), await P(l.lifecycleRegistry, "destroyed"), !(!this._isDisconnected || i !== this._connectionVersion) && (this._isMounted = !1, this._model = void 0, this._observerFn = void 0, this._eventCleanup = null, n.instance = void 0));
1560
1612
  }
1561
1613
  }
1562
1614
  );
1563
1615
  }
1564
- let ie = !1, he = !1, se = [];
1565
- function Tt() {
1566
- he || (he = !0, !(typeof document > "u" || typeof HTMLElement > "u") && (ct(), Ye(), lt()));
1616
+ let ce = !1, ye = !1, ae = [];
1617
+ function Mt() {
1618
+ ye || (ye = !0, !(typeof document > "u" || typeof HTMLElement > "u") && (lt(), Qe(), ut()));
1567
1619
  }
1568
- function $e(...e) {
1569
- const t = e[0], n = e[1];
1570
- if (Ge(t)) {
1571
- if (!n) {
1572
- _.error("ComponentSource requires a component name when calling take()");
1620
+ function Re(...e) {
1621
+ const t = e[0], o = e[1];
1622
+ if (Ze(t)) {
1623
+ if (!o) {
1624
+ S.error("ComponentSource requires a component name when calling take()");
1573
1625
  return;
1574
1626
  }
1575
- _t(n, t);
1627
+ xt(o, t);
1576
1628
  return;
1577
1629
  }
1578
- if (Z(t) || Ke(t)) {
1579
- const o = {
1580
- registerHook: (r, a) => {
1581
- be("global", r, a);
1630
+ if (J(t) || Ye(t)) {
1631
+ const n = {
1632
+ registerHook: (i, l) => {
1633
+ we("global", i, l);
1582
1634
  },
1583
- take: ke.take
1635
+ take: Pe.take
1584
1636
  };
1585
1637
  try {
1586
- t.install(o), Z(t) ? G.plugins[t.name] = t : G.modules[t.name] = t;
1587
- } catch (r) {
1588
- _.errorWithContext(
1638
+ t.install(n), J(t) ? Z.plugins[t.name] = t : Z.modules[t.name] = t;
1639
+ } catch (i) {
1640
+ S.errorWithContext(
1589
1641
  "Failed to install extension",
1590
- { name: t.name, type: Z(t) ? "plugin" : "module" },
1591
- r
1642
+ { name: t.name, type: J(t) ? "plugin" : "module" },
1643
+ i
1592
1644
  );
1593
1645
  }
1594
1646
  return;
1595
1647
  }
1596
- _.error("Unknown extension type", t);
1648
+ S.error("Unknown extension type", t);
1597
1649
  }
1598
- function St() {
1599
- ie || (ie = !0, se.forEach((e) => $e(...e)), se = [], _.info("Core initialized"));
1650
+ function Ot() {
1651
+ ce || (ce = !0, ae.forEach((e) => Re(...e)), ae = [], S.info("Core initialized"));
1600
1652
  }
1601
- const ke = Object.assign(
1653
+ const Pe = Object.assign(
1602
1654
  () => {
1603
- Tt(), St();
1655
+ Mt(), Ot();
1604
1656
  },
1605
1657
  {
1606
1658
  take: (...t) => {
1607
- ie ? $e(...t) : se.push(t);
1659
+ ce ? Re(...t) : ae.push(t);
1608
1660
  }
1609
1661
  }
1610
1662
  );
1611
1663
  export {
1612
- ke as Core,
1613
- Re as LogLevel,
1614
- _ as logger
1664
+ Pe as Core,
1665
+ Ie as LogLevel,
1666
+ S as logger
1615
1667
  };