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