@reactive-web-components/rwc 2.63.0 → 2.63.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.
@@ -1,1134 +0,0 @@
1
- var dt = Object.defineProperty;
2
- var ht = (s, t, e) => t in s ? dt(s, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[t] = e;
3
- var f = (s, t, e) => ht(s, typeof t != "symbol" ? t + "" : t, e);
4
- const F = (s) => s && typeof s == "object" && ("classList" in s || "attributes" in s || "customAttributes" in s || "reactiveClassList" in s || "listeners" in s || "customListeners" in s || "children" in s || "effects" in s || "ref" in s || "style" in s || Object.keys(s).some(
5
- (t) => t.startsWith(".") || t.startsWith("@") || t.startsWith("$")
6
- )) && !("hostElement" in s), ft = (s) => s && typeof s == "object" && "hostElement" in s && "append" in s && "set" in s && "addStyle" in s && "setAttribute" in s && "addClass" in s && "addEffect" in s && "addReactiveContent" in s && "setReactiveContent" in s && "clear" in s, G = (s, t, ...e) => {
7
- t && t.apply(s, e);
8
- };
9
- let z = !0;
10
- const b = (...s) => {
11
- z && console.debug(
12
- ["[rwc]", ...s].join(" | "),
13
- ...Array.from(s.join("").matchAll(/%c/gm)).map((t, e) => e % 2 === 0 ? "color:red" : "color:inherit")
14
- );
15
- }, N = (s) => s.replace(/([A-Z])/gm, (t) => `-${t.toLowerCase()}`), ut = (s) => s.replace(/-(\w)/gm, (t, e) => e.toUpperCase()), V = (s, ...t) => {
16
- if (!z) return;
17
- const e = {
18
- r: "color: #ff0000",
19
- // red
20
- g: "color: #00ff00",
21
- // green
22
- b: "color: #0000ff",
23
- // blue
24
- y: "color: #ffff00",
25
- // yellow
26
- p: "color: #800080",
27
- // purple
28
- c: "color: #00ffff",
29
- // cyan
30
- o: "color: #ffa500",
31
- // orange
32
- w: "color: #808080"
33
- // gray (w for white/gray)
34
- }, n = s.match(/@[rgbpycow]/g) || [], o = n.map((i) => {
35
- const c = i.slice(1);
36
- return e[c] || "color: inherit";
37
- });
38
- let r = s;
39
- n.forEach((i) => {
40
- const c = new RegExp(`\\${i}([^\\s,]+)`, "g");
41
- r = r.replace(c, "%c$1");
42
- }), console.log(r, ...o, ...t);
43
- }, Vt = () => {
44
- z = !0;
45
- }, pt = () => {
46
- z = !1;
47
- };
48
- pt();
49
- const Nt = (s, t) => {
50
- s.every(Boolean) && t(s);
51
- }, k = /* @__PURE__ */ new Set();
52
- let U = !1, K = !1;
53
- const mt = () => {
54
- if (!K) {
55
- K = !0;
56
- try {
57
- if (U = !1, k.size === 0)
58
- return;
59
- const s = Array.from(k);
60
- k.clear(), s.forEach((t) => {
61
- if (t.status === "active") {
62
- Y(t), O.push(t);
63
- try {
64
- t();
65
- } catch (e) {
66
- console.error("Error in effect:", e);
67
- } finally {
68
- O.pop();
69
- }
70
- }
71
- }), k.size > 0 && nt();
72
- } finally {
73
- K = !1;
74
- }
75
- }
76
- };
77
- function Et() {
78
- queueMicrotask(mt);
79
- }
80
- const nt = () => {
81
- U || (U = !0, Et());
82
- }, Ct = (s) => {
83
- k.add(s), nt();
84
- }, O = [], Y = (s) => {
85
- var t, e, n, o;
86
- (t = s.children) == null || t.forEach((r) => {
87
- var i;
88
- return (i = r.destroy) == null ? void 0 : i.call(r);
89
- }), (e = s.children) == null || e.clear(), (n = s.cleanupSet) == null || n.forEach((r) => r()), (o = s.cleanupSet) == null || o.clear();
90
- };
91
- function j(s, t) {
92
- let e = (t == null ? void 0 : t.signalCompareFn) || (() => !0);
93
- const n = /* @__PURE__ */ new Set();
94
- function o() {
95
- var i;
96
- const r = O[O.length - 1];
97
- return r && !r.fake && !n.has(r) && r.status === "active" && (n.add(r), (i = r.cleanupSet) == null || i.add(() => n.delete(r))), !(t != null && t.name) && (r != null && r.effectId) && o.setName(r.effectId), s;
98
- }
99
- return o.signalId = `${(t == null ? void 0 : t.name) || ""}_${Math.random().toString(36).substring(2, 15)}`, o.setName = function(r) {
100
- return o.signalId = `${r}_${Math.random().toString(36).substring(2, 15)}`, o;
101
- }, o.setCompareFn = function(r) {
102
- return e = r, o;
103
- }, o.clearSubscribers = function() {
104
- n.clear();
105
- }, o.getSubscribers = function() {
106
- return n;
107
- }, o.peek = function() {
108
- return Object.freeze(s);
109
- }, o.initValue = Object.freeze(s), o.forceSet = function(r) {
110
- s = r, n.forEach((i) => {
111
- Ct(i);
112
- });
113
- }, o.set = function(r, i = e) {
114
- s !== r && i(s, r) && o.forceSet(r);
115
- }, o.update = function(r) {
116
- o.set(r(s));
117
- }, o.pipe = (r, i) => {
118
- i != null && i.name && o.setName(i.name);
119
- const c = j(null);
120
- return w(
121
- () => {
122
- const a = o();
123
- w(
124
- () => {
125
- const h = r(a);
126
- h instanceof Promise ? h.then((m) => c.set(m)) : g(h) ? w(() => c.set(h()), {
127
- name: "pipe_effect_inner"
128
- }) : c.set(h);
129
- },
130
- { name: "pipe_effect" }
131
- );
132
- },
133
- { name: (i == null ? void 0 : i.name) || `pipe_${o.signalId}` }
134
- ), c;
135
- }, o;
136
- }
137
- function w(s, t) {
138
- var r;
139
- const e = `${(t == null ? void 0 : t.name) || ""}_${Math.random().toString(36).substring(2, 15)}`;
140
- b("current effect", `%c${e}%c`);
141
- const n = s;
142
- n.status = "active", n.children = /* @__PURE__ */ new Set(), n.effectId = e;
143
- const o = O[O.length - 1];
144
- return o && ((r = o.children) == null || r.add(n), n.parent = new WeakRef(o), n.destroy = () => {
145
- var i;
146
- Y(n), (i = o.children) == null || i.delete(n), n.destroy = void 0, n.status = "inactive";
147
- }), n.cleanupSet = /* @__PURE__ */ new Set(), O.push(n), n(), O.pop(), n;
148
- }
149
- const g = (s) => !!s && ["object", "function"].includes(typeof s) && "set" in s && "update" in s && "forceSet" in s && "signalId" in s;
150
- function Jt(s, ...t) {
151
- const e = j("");
152
- return w(() => {
153
- const n = t.map(
154
- (r) => g(r) ? String(r()) : String(r)
155
- ), o = [s[0]];
156
- n.forEach((r, i) => {
157
- o.push(r, s[i + 1]);
158
- }), e.set(o.join(""));
159
- }), e;
160
- }
161
- function qt(s, t) {
162
- const e = j(t ?? null), n = (o) => e.set(o);
163
- return s instanceof Promise ? s.then(n) : typeof s == "function" && w(() => {
164
- const o = s();
165
- o instanceof Promise ? o.then(n) : g(o) ? w(() => n(o())) : n(o);
166
- }), e;
167
- }
168
- function zt(s, t) {
169
- let e = s(), n = t();
170
- w(() => {
171
- const o = s(), r = t();
172
- o !== r && (o !== e ? t.set(o) : r !== n && s.set(r)), e = o, n = r;
173
- });
174
- }
175
- function Dt(...s) {
176
- let t = s.map((n) => n());
177
- const e = j(t);
178
- return s.forEach((n, o) => {
179
- w(() => {
180
- const r = () => t.filter((i) => i !== void 0).length;
181
- r() === s.length && (t = Array.from(t).fill(void 0)), t[o] = n(), r() === s.length && e.set([...t]);
182
- });
183
- }), e;
184
- }
185
- const Gt = (...s) => {
186
- const t = j([]);
187
- return w(() => {
188
- t.set(
189
- s.map((e) => e())
190
- );
191
- }), t;
192
- }, Kt = (s, t) => {
193
- let e = !0;
194
- const n = w(() => {
195
- var o;
196
- e && (e = !1, t(s()), (o = n.destroy) == null || o.call(n));
197
- });
198
- }, J = "eventProps", q = "EVENT_CONFIG", P = "observedAttributes", Ut = () => (s, t) => {
199
- Reflect.get(s, P) || Reflect.defineProperty(s, P, {
200
- value: []
201
- }), Reflect.get(s, P).push(
202
- N(t)
203
- );
204
- }, Yt = (s) => (t, e) => {
205
- Reflect.get(t, J) || Reflect.defineProperty(t, J, {
206
- value: []
207
- }), Reflect.get(t, q) || Reflect.defineProperty(t, q, {
208
- value: {}
209
- }), Reflect.get(t, q)[e] = {
210
- bubbles: (s == null ? void 0 : s.bubbles) ?? !1,
211
- composed: (s == null ? void 0 : s.composed) ?? !1
212
- }, Reflect.get(t, J).push(e);
213
- }, ot = (s, t = !1) => (e) => {
214
- b(
215
- s,
216
- "start register static attr",
217
- e.prototype[P]
218
- );
219
- const n = [];
220
- if (e.styles) {
221
- const r = e.styles, i = [];
222
- Array.isArray(r) ? i.push(...r) : i.push(r), i.forEach((c) => {
223
- const a = new CSSStyleSheet();
224
- a.replaceSync(c), n.push(a);
225
- const C = new CSSStyleSheet();
226
- C.replaceSync(c.slice(c.indexOf("@property"))), document.adoptedStyleSheets.push(C);
227
- });
228
- }
229
- class o extends e {
230
- constructor(...i) {
231
- b("constructor", `%c${s}%c`), super(t, ...i), n.length > 0 && this.shadow.adoptedStyleSheets.push(...n);
232
- }
233
- render() {
234
- return b("rwc: render from new class"), e.prototype.render.call(this);
235
- }
236
- attributeChangedCallback(i, c, a) {
237
- b(
238
- "%cAttribute has changed.%c",
239
- `%c${i}%c`,
240
- `oldValue: ${c}, newValue: ${a}`,
241
- `%c${s}%c`
242
- );
243
- try {
244
- a = JSON.parse(a);
245
- } catch {
246
- }
247
- const C = ut(i);
248
- if (C in this && g(this[C])) {
249
- const h = this[C];
250
- h.setName(i), a === null ? (h.set(h.initValue), this.removeAttribute(i)) : h.set(a);
251
- }
252
- G(
253
- this,
254
- e.prototype.attributeChangedCallback,
255
- i,
256
- c,
257
- a
258
- );
259
- }
260
- connectedCallback() {
261
- const i = () => {
262
- var a, C;
263
- b("rwc: connectedCallback"), b("connectedCallback", `%c${s}%c`, this), (a = this.init) == null || a.call(this), this.providers && Object.keys(this.providers).length > 0 && (b("WRAPPER for providers", s), Object.entries(this.providers).forEach(
264
- ([h, d]) => {
265
- b("register provider", h, d()), this.addEventListener(h, (m) => {
266
- var u;
267
- b("send provider", h, d());
268
- const p = m;
269
- ((u = p.detail) == null ? void 0 : u.context) === h && (p.stopPropagation(), p.detail.callback(d));
270
- });
271
- }
272
- )), this.checkInjects(), (C = e.prototype[J]) == null || C.forEach(
273
- (h) => {
274
- this[h] = (d) => {
275
- const m = e.prototype[q][h], { bubbles: p, composed: u } = m;
276
- g(d) ? w(() => {
277
- V("@oemit reactive value", d()), this.dispatchEvent(
278
- new CustomEvent(h, {
279
- detail: d(),
280
- bubbles: p,
281
- composed: u
282
- })
283
- );
284
- }) : (V("@oemit value", d), this.dispatchEvent(
285
- new CustomEvent(h, {
286
- detail: d,
287
- bubbles: p,
288
- composed: u
289
- })
290
- ));
291
- };
292
- }
293
- ), b("start render", `%c${s}%c`, s);
294
- const c = () => {
295
- b("rwc: insertRenderTemplate");
296
- const d = this.render().hostElement;
297
- d && this.shadow.appendChild(d), G(this, e.prototype.connectedCallback), this.appendSlotContent();
298
- };
299
- if (this.rootStyle && !e.styles) {
300
- const h = (p) => p instanceof Promise || Array.isArray(p) && p.every((u) => u instanceof Promise), d = this.rootStyle, m = (p) => {
301
- const u = new CSSStyleSheet();
302
- u.replaceSync(p), this.shadow.adoptedStyleSheets.push(u);
303
- const y = new CSSStyleSheet();
304
- y.replaceSync(p.slice(p.indexOf("@property"))), document.adoptedStyleSheets.push(y);
305
- };
306
- if (h(d)) {
307
- const p = [];
308
- Array.isArray(d) ? p.push(...d) : p.push(d), Promise.all(p).then((u) => u.forEach((y) => m(y.default))).then(() => c());
309
- } else {
310
- const p = [];
311
- Array.isArray(d) ? p.push(...d) : p.push(d), p.forEach((u) => m(u)), c();
312
- }
313
- } else
314
- c();
315
- this.slotContext && Object.keys(this.slotContext).length > 0 && this.shadow.querySelectorAll("slot").forEach((h) => {
316
- b(
317
- this.slotContext,
318
- this.slotContext && this.slotContext[h.name]
319
- ), V(
320
- "@bslot element",
321
- h,
322
- `name:${h.name};`,
323
- h.assignedElements()
324
- ), h.assignedElements().forEach((d) => {
325
- const m = this.slotContext[h.name];
326
- this.slotContext && g(m) && (V(
327
- "@oslot element",
328
- h,
329
- `name:${h.name};`,
330
- h.assignedElements()
331
- ), w(() => {
332
- d.dispatchEvent(
333
- new CustomEvent("handleSlotContext", {
334
- detail: m()
335
- })
336
- );
337
- }));
338
- });
339
- });
340
- };
341
- i.fake = !0, i.component = new WeakRef(this), this.effectSet.add(new WeakRef(i)), w(i, { name: "FAKE_wrapperEffect" });
342
- }
343
- disconnectedCallback() {
344
- this.allSlotContent = [], this.slotContent = {}, this.htmlSlotContent = {}, this.effectSet.forEach((i) => {
345
- var c, a;
346
- return (a = (c = i.deref()) == null ? void 0 : c.destroy) == null ? void 0 : a.call(c);
347
- }), this.effectSet.clear(), this.shadow.replaceChildren(), this.replaceChildren(), G(this, e.prototype.disconnectedCallback);
348
- }
349
- }
350
- return f(o, "observedAttributes", e.prototype[P] ?? []), f(o, "renderTagName", s), o.toString = () => s, customElements.get(s) ? console.error(
351
- `название тега ${s} повторяется, компонент ${e.name} не зарегистрирован`
352
- ) : customElements.define(s, o), e.renderTagName = s, e;
353
- };
354
- class _ extends HTMLElement {
355
- constructor(e = !1) {
356
- super();
357
- f(this, "init");
358
- f(this, "isSlotLazyLoading", !1);
359
- f(this, "slotTemplate");
360
- f(this, "slotContext");
361
- f(this, "rootStyle");
362
- f(this, "modelValue");
363
- f(this, "providers");
364
- f(this, "effectSet", /* @__PURE__ */ new Set());
365
- f(this, "appendAllSlotContent");
366
- f(this, "allSlotContent", []);
367
- f(this, "slotContent", {});
368
- f(this, "htmlSlotContent", {});
369
- f(this, "shadow");
370
- f(this, "injects", {});
371
- this.shadow = this.attachShadow({ mode: e ? "closed" : "open" });
372
- }
373
- // @ts-expect-error - appendChild is not defined in the HTMLElement interface
374
- appendChild(e, n = !0) {
375
- var o;
376
- if (this.isSlotLazyLoading && n) {
377
- if (e instanceof HTMLElement) {
378
- const r = e.slot || "default";
379
- this.htmlSlotContent[r] || (this.htmlSlotContent[r] = []), (o = this.htmlSlotContent[r]) == null || o.push(e);
380
- }
381
- } else return super.appendChild(e);
382
- }
383
- appendSlotContent() {
384
- var e;
385
- (e = this.appendAllSlotContent) == null || e.call(this);
386
- }
387
- inject(e) {
388
- return b("%cinject%c", e), this.injects[e] || (this.injects[e] = j(null)), this.injects[e];
389
- }
390
- checkInjects() {
391
- Object.entries(this.injects).forEach(([e, n]) => {
392
- b(
393
- "%cinject%c",
394
- `%c${e}%c`,
395
- "from BaseElement (dispatch event)"
396
- ), this.shadow.dispatchEvent(
397
- new CustomEvent(e, {
398
- detail: {
399
- context: e,
400
- callback: (o) => w(() => {
401
- n.set(o());
402
- }, { name: e })
403
- },
404
- bubbles: !0,
405
- composed: !0
406
- })
407
- );
408
- });
409
- }
410
- setReactiveValue(e) {
411
- this.modelValue = e;
412
- }
413
- }
414
- f(_, "observedAttributes", []), f(_, "renderTagName", ""), f(_, "styles");
415
- const Zt = (s) => "render" in s && "setReactiveValue" in s, bt = "handleSlotContext", Q = "onConnected", rt = (s) => typeof s == "string" ? s : JSON.stringify(s), St = (s) => {
416
- const t = document.createElement("span");
417
- return t.textContent = rt(s), t;
418
- }, it = (s, t) => (s.appendChild(St(t)), s), yt = (s, t) => (s.replaceChildren(), it(s, t)), tt = (s) => {
419
- const t = document.createElement("span");
420
- return w(() => {
421
- const e = s();
422
- t.textContent = rt(e);
423
- }), t;
424
- };
425
- class ct {
426
- constructor(t) {
427
- f(this, "wrapper");
428
- f(this, "keyedEffects", /* @__PURE__ */ new Map());
429
- f(this, "append", (...t) => (t.forEach((e) => {
430
- var o;
431
- const n = e.hostElement;
432
- n && ((o = this.hostElement) == null || o.appendChild(n), Q in n && setTimeout(() => {
433
- var r;
434
- (r = n.onConnected) == null || r.call(
435
- n,
436
- e,
437
- n
438
- );
439
- }));
440
- }), this));
441
- f(this, "set", (...t) => {
442
- var n;
443
- this.clear();
444
- const e = document.createDocumentFragment();
445
- return t.forEach((o) => {
446
- const r = o.hostElement;
447
- r && e.appendChild(r);
448
- }), (n = this.hostElement) == null || n.appendChild(e), this;
449
- });
450
- f(this, "removeChild", (...t) => (t.forEach((e) => {
451
- var n, o;
452
- if (Array.from(((n = this.hostElement) == null ? void 0 : n.childNodes.values()) || []).some(
453
- (r) => r === e.hostElement
454
- )) {
455
- const r = e.hostElement;
456
- r && ((o = this.hostElement) == null || o.removeChild(r));
457
- }
458
- }), this));
459
- f(this, "addHtmlContent", (t) => {
460
- const e = this.hostElement;
461
- return e ? (it(e, t), this) : this;
462
- });
463
- f(this, "setHtmlContent", (t) => {
464
- const e = this.hostElement;
465
- return e ? (yt(e, t), this) : this;
466
- });
467
- f(this, "setAttribute", (t, e) => {
468
- var r;
469
- b("setAttribute", t, e);
470
- const n = this.hostElement;
471
- if (!n) return this;
472
- let o;
473
- if ((typeof e == "boolean" || e === null) && !(n instanceof _))
474
- if (e)
475
- o = "";
476
- else {
477
- this.removeAttribute(t);
478
- const i = t.toLowerCase();
479
- return i in n && (n[i] = null), this;
480
- }
481
- else typeof e != "string" ? o = JSON.stringify(e) : o = e;
482
- if ((r = this.hostElement) == null || r.setAttribute(N(t), o), !(n instanceof _)) {
483
- const i = t.toLowerCase();
484
- i in n && (n[i] = e);
485
- }
486
- return this;
487
- });
488
- f(this, "setCustomAttribute", (t, e) => {
489
- var o;
490
- let n;
491
- return typeof e != "string" ? n = JSON.stringify(e) : n = e, (o = this.hostElement) == null || o.setAttribute(N(t), n), this;
492
- });
493
- f(this, "setReactiveAttribute", (t, e) => (this.addEffect((n) => {
494
- b("setReactiveAttribute effect", t, e), n.setAttribute(t, e());
495
- }, t), this));
496
- f(this, "setReactiveCustomAttribute", (t, e) => (this.addEffect((n) => {
497
- n.setCustomAttribute(t, e());
498
- }), this));
499
- f(this, "removeAttribute", (t) => {
500
- var e;
501
- return (e = this.hostElement) == null || e.removeAttribute(N(t)), this;
502
- });
503
- f(this, "addStyle", (t) => {
504
- const e = this.hostElement;
505
- return e ? (Object.entries(t).forEach(([n, o]) => {
506
- const r = n.startsWith("--");
507
- typeof o == "function" ? this.addEffect(() => {
508
- if (r) {
509
- const i = String(o() || "");
510
- e.style.setProperty(n, i);
511
- } else
512
- e.style[n] = o();
513
- }) : typeof o == "string" && (r ? e.style.setProperty(n, o) : e.style[n] = o);
514
- }), this) : this;
515
- });
516
- f(this, "onConnected", (t) => this.hostElement ? (Reflect.defineProperty(this.hostElement, Q, {
517
- get() {
518
- return t;
519
- }
520
- }), this) : this);
521
- f(this, "addClass", (...t) => (t.forEach((e) => {
522
- var n;
523
- typeof e == "string" ? (n = this.hostElement) == null || n.classList.add(
524
- ...e.split(" ").flatMap((o) => o.split(`
525
- `)).map((o) => o.trim()).filter(Boolean)
526
- ) : (() => {
527
- let o = null;
528
- this.addEffect(() => {
529
- const r = e();
530
- r.length > 0 && (o ? this.replaceClass(o, r) : this.addClass(r), o = r);
531
- });
532
- })();
533
- }), this));
534
- f(this, "setClass", (...t) => {
535
- var e, n, o;
536
- return (n = this.hostElement) == null || n.classList.remove(...((e = this.hostElement) == null ? void 0 : e.classList) || []), (o = this.hostElement) == null || o.classList.add(...t), this;
537
- });
538
- f(this, "addReactiveClass", (t) => (Object.keys(t).forEach((e) => {
539
- this.addEffect((n) => {
540
- t[e]() ? n.addClass(e) : n.removeClass(e);
541
- });
542
- }), this));
543
- f(this, "removeClass", (...t) => {
544
- var e;
545
- return (e = this.hostElement) == null || e.classList.remove(...t), this;
546
- });
547
- f(this, "replaceClass", (t, e) => {
548
- var n;
549
- return (n = this.hostElement) == null || n.classList.replace(t, e), this;
550
- });
551
- f(this, "addEffect", (t, e) => {
552
- var r, i;
553
- const n = this.hostElement;
554
- if (!n) return this;
555
- const o = () => t(this, n);
556
- if (e) {
557
- const c = (r = this.keyedEffects.get(e)) == null ? void 0 : r.deref();
558
- c && Y(c);
559
- }
560
- return (i = n.effectSet) == null || i.add(new WeakRef(o)), o.component = this.wrapper, w(o, { name: (e == null ? void 0 : e.toString()) || n.tagName }), this;
561
- });
562
- f(this, "addReactiveContent", (t) => {
563
- var e;
564
- return (e = this.hostElement) == null || e.appendChild(tt(t)), this;
565
- });
566
- f(this, "setReactiveContent", (t) => {
567
- var e;
568
- return this.clear(), (e = this.hostElement) == null || e.appendChild(tt(t)), this;
569
- });
570
- f(this, "clear", () => {
571
- var t;
572
- return (t = this.hostElement) == null || t.replaceChildren(), this;
573
- });
574
- this.wrapper = t;
575
- const e = t.deref();
576
- e && (e.effectSet = /* @__PURE__ */ new Set());
577
- }
578
- get hostElement() {
579
- return this.wrapper.deref();
580
- }
581
- addEventlistener(t, e, n = !1) {
582
- var o;
583
- return (o = this.hostElement) == null || o.addEventListener(
584
- t,
585
- (r) => e(r, this, this.hostElement),
586
- n
587
- ), this;
588
- }
589
- }
590
- class wt extends ct {
591
- constructor() {
592
- super(...arguments);
593
- f(this, "setReactiveValue", (e) => (this.hostElement instanceof _ && this.hostElement.setReactiveValue(e), this));
594
- f(this, "setSlotTemplate", (e) => {
595
- var o;
596
- const n = (o = this.hostElement) == null ? void 0 : o.slotTemplate;
597
- return n && Object.entries(e).forEach(([r, i]) => {
598
- n[r] = i;
599
- }), this;
600
- });
601
- }
602
- }
603
- const Xt = () => () => {
604
- }, vt = (s) => new wt(new WeakRef(s)), At = (s) => new ct(new WeakRef(s)), Rt = (s, ...t) => ({
605
- classList: [...s.map((e) => e.trim()).filter(Boolean), ...t]
606
- }), Qt = (s, ...t) => Rt(s, ...t), lt = (s, t) => {
607
- var o;
608
- if (!t || !s.deref()) return;
609
- const e = Object.keys(t || {}).filter(
610
- (r) => r.startsWith(".") || r.startsWith("@") || r.startsWith("$")
611
- );
612
- e.filter((r) => r.startsWith(".")).forEach((r) => {
613
- t != null && t.attributes || (t.attributes = {}), t.attributes[r.slice(1)] = t[r];
614
- }), e.filter((r) => r.startsWith("@")).forEach((r) => {
615
- t != null && t.listeners || (t.listeners = {});
616
- const i = r.slice(1);
617
- t.listeners[i] = t[r];
618
- }), e.filter((r) => r.startsWith("$")).forEach((r) => {
619
- t != null && t.effects || (t.effects = []), t.effects.push(t[r]);
620
- });
621
- const n = s.deref();
622
- if (n)
623
- return Ot(n, t.classList), jt(n, t.style), Tt(n, t.attributes), Mt(n, t.reactiveClassList), It(n, t.customAttributes), Lt(n, t.children), gt(n, t.effects), et(n, t.listeners), et(n, t.customListeners), (o = t.ref) == null || o.set(n), n;
624
- }, et = (s, t) => {
625
- t && Object.entries(t).forEach(([e, n]) => {
626
- typeof n == "function" && s.addEventlistener(e, n);
627
- });
628
- }, gt = (s, t) => t == null ? void 0 : t.forEach((e) => s.addEffect(e)), Lt = (s, t) => D(new WeakRef(s), ...t || []) ?? s, It = (s, t) => {
629
- const e = t;
630
- e && Object.keys(e).forEach((n) => {
631
- g(e[n]) ? s.setReactiveCustomAttribute(n, e[n]) : typeof e[n] == "function" ? s.addEffect(() => {
632
- s.setCustomAttribute(n, e[n]());
633
- }) : s.setCustomAttribute(n, e[n]);
634
- });
635
- }, Ot = (s, t) => s.addClass(...t || []), Mt = (s, t) => s.addReactiveClass(t || {}), jt = (s, t) => s.addStyle(t || {}), Tt = (s, t) => {
636
- const e = t, n = (o, r) => {
637
- r !== void 0 && (b("addAttribute", o, r), g(r) ? s.setReactiveAttribute(o, r) : typeof r == "function" ? s.addEffect(() => {
638
- s.setAttribute(o, r());
639
- }) : s.setAttribute(o, r));
640
- };
641
- e && Object.keys(e).forEach((o) => {
642
- n(o, e[o]);
643
- });
644
- }, D = (s, ...t) => {
645
- const e = s.deref();
646
- if (e)
647
- return t.forEach((n) => {
648
- typeof n == "string" ? n.trim().length > 0 && e.addHtmlContent(n) : g(n) ? e.addReactiveContent(n) : e.append(n);
649
- }), e;
650
- }, W = (s, t) => {
651
- const e = document.createElement(s), n = At(e);
652
- return lt(new WeakRef(n), t) ?? n;
653
- }, Z = (s, t) => {
654
- const [e, ...n] = s.split(" ").map((r) => r.trim()), o = W(e, t);
655
- return n.length > 0 && o.addClass(...n), (...r) => D(
656
- new WeakRef(o),
657
- ...r.filter(Boolean).flat().flatMap(
658
- (i) => typeof i == "function" && !g(i) ? M(() => i(o)) : i
659
- )
660
- ) ?? o;
661
- }, M = (s) => {
662
- const t = `getSignalContent_${Math.random().toString(36).substring(2, 15)}`;
663
- return W("div").addStyle({ display: "contents" }).addEffect((e) => {
664
- e.clear(), D(new WeakRef(e), ...[s()].flat());
665
- }, t);
666
- }, te = (s, t, e) => {
667
- const n = W("div").addStyle({ display: "contents" }), o = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map(), c = /* @__PURE__ */ new Map();
668
- let a = [];
669
- const C = /* @__PURE__ */ new Set();
670
- let h = s.peek();
671
- const d = (u) => {
672
- C.delete(u), o.delete(u), r.delete(u), i.delete(u), c.delete(u);
673
- }, m = (u) => {
674
- if (!c.has(u)) {
675
- const y = a.indexOf(u);
676
- return c.set(u, y), y;
677
- }
678
- return c.get(u);
679
- }, p = (u, y, x) => Array.from(x.children).indexOf(u) !== y;
680
- return w(() => {
681
- const u = s(), y = u.map(t).map((E) => typeof E == "string" ? E : E.toString()), x = new Set(y);
682
- c.clear(), y.forEach((E, S) => {
683
- c.set(E, S);
684
- }), a = y;
685
- const L = n.hostElement;
686
- if (!L) return;
687
- b(
688
- "containerChildren",
689
- Array.from(L.children),
690
- a
691
- );
692
- const H = [];
693
- Array.from(L.children).forEach((E) => {
694
- const S = E.dataset.key;
695
- S && !x.has(S) && H.push(E);
696
- }), H.forEach((E) => {
697
- const S = E.dataset.key;
698
- b("remove element", S, E), E.remove(), d(S);
699
- }), y.forEach((E, S) => {
700
- var v;
701
- const A = u[S], $ = h[S];
702
- if (!o.has(E))
703
- b("create new element", E, A), o.set(
704
- E,
705
- j(Math.random().toString(36).substring(2, 15))
706
- ), r.set(
707
- E,
708
- () => e(A, S, u).setCustomAttribute("data-key", E)
709
- );
710
- else if ($ && JSON.stringify(A) !== JSON.stringify($)) {
711
- const R = i.get(E);
712
- (v = o.get(E)) == null || v.set(Math.random().toString(36).substring(2, 15)), r.set(
713
- E,
714
- () => e(A, S, u).setCustomAttribute("data-key", E)
715
- ), R && R.parentNode && b("mark element for update", E);
716
- }
717
- }), h = [...u.map((E) => ({ ...E }))];
718
- const B = () => {
719
- o.forEach((E, S) => {
720
- b("key from setTimeout foreach currItemSignalMap", S), C.has(S) || (C.add(S), w(() => {
721
- var X;
722
- E();
723
- const A = m(S), $ = (X = r.get(S)) == null ? void 0 : X();
724
- if (!$ || !$.hostElement) return;
725
- const v = n.hostElement, R = $.hostElement;
726
- if (!v) return;
727
- b("call effect from setTimeout", S, R);
728
- const I = i.get(S);
729
- if (I && I.parentNode === v) {
730
- if (p(I, A, v)) {
731
- const T = v.children[A];
732
- T && T !== I ? v.insertBefore(I, T) : T || v.appendChild(I);
733
- }
734
- R !== I && (I.replaceWith(R), i.set(S, R));
735
- } else if (i.set(S, R), A < v.children.length) {
736
- const T = v.children[A];
737
- T ? v.insertBefore(R, T) : v.appendChild(R);
738
- } else
739
- v.appendChild(R);
740
- }));
741
- });
742
- };
743
- Promise.resolve().then(() => B());
744
- }), n;
745
- }, ee = (s) => {
746
- let t = [W("div")], e = !1;
747
- return w(() => {
748
- var r, i;
749
- const n = s();
750
- e = Array.isArray(n);
751
- const o = [];
752
- o.push(...[n].flat()), o.length === 0 && o.push(
753
- W("div").addStyle({ display: "none" }).setAttribute("id", "empty_template")
754
- );
755
- try {
756
- b(
757
- "newReactiveComponent.map",
758
- o.map((c) => {
759
- var a;
760
- return b("newReactiveComponent hostElement", c.hostElement), (a = c.hostElement) == null ? void 0 : a.id;
761
- })
762
- ), b(
763
- "currComponent[0].hostElement?.id",
764
- (r = t[0].hostElement) == null ? void 0 : r.id,
765
- t
766
- ), (i = t[0].hostElement) == null || i.replaceWith(
767
- ...o.map((c) => c.hostElement).filter(Boolean)
768
- ), t.slice(1).forEach((c) => {
769
- var a;
770
- return (a = c.hostElement) == null ? void 0 : a.remove();
771
- }), t = o;
772
- } catch (c) {
773
- console.error(c);
774
- }
775
- }), e ? t : t[0];
776
- }, se = (s) => bt in s, ne = (s) => {
777
- const t = Z("div")().addStyle({ display: "contents" }), e = (n) => {
778
- const o = t.hostElement;
779
- return o && (o.innerHTML = n), t;
780
- };
781
- return typeof s == "string" ? e(s) : t.addEffect(() => {
782
- e(s());
783
- }), t;
784
- }, at = (s, t, e) => s ? M(t) : e ? M(e) : Z("div")().setAttribute("id", "empty_div_renderIf").addStyle({ display: "none" }), $t = (s, t, e) => M(() => at(!!s(), t, e)), oe = (s, t, e) => typeof s == "boolean" ? at(s, t, e) : $t(s, t, e), st = (s, t) => M(t).addEffect((e, n) => {
785
- if (typeof s == "boolean")
786
- n.style.display = s ? "block" : "none";
787
- else {
788
- const o = s() ? "block" : "none";
789
- n.style.display = o;
790
- }
791
- }), re = (s, t, e) => {
792
- const n = [
793
- st(s, t)
794
- ].flat();
795
- return e && n.push(
796
- ...[
797
- st(
798
- () => typeof s == "boolean" ? !s : !s(),
799
- e
800
- )
801
- ].flat()
802
- ), M(() => n);
803
- }, _t = (s, t) => {
804
- b("createCustomElement", s);
805
- const e = document.createElement(s), n = vt(e);
806
- return e.init = () => {
807
- lt(new WeakRef(n), t);
808
- }, n;
809
- }, Wt = (s, t) => {
810
- const e = s.split(" ").slice(1).map((o) => o.trim()), n = _t(s.split(" ")[0], t);
811
- return Array.isArray(e) && e.length > 0 && n.addClass(...e), (...o) => {
812
- const r = o.filter(Boolean).flat().flatMap(
813
- (c) => typeof c == "function" && !g(c) ? M(() => c(n)) : c
814
- ), i = n.hostElement;
815
- return i && (i.allSlotContent = r, i.slotContent = r.filter(ft).reduce(
816
- (c, a) => {
817
- var h;
818
- const C = ((h = a.hostElement) == null ? void 0 : h.getAttribute("slot")) || "default";
819
- return c[C] || (c[C] = []), c[C].push(a), c;
820
- },
821
- {}
822
- ), i.appendAllSlotContent = () => {
823
- D(new WeakRef(n), ...r);
824
- }), n;
825
- };
826
- }, xt = (s, t, e) => Wt(
827
- `${s.renderTagName}${t && typeof t == "string" ? " " + t : ""}`,
828
- F(t) ? t : t && typeof t == "string" ? e : void 0
829
- ), ie = () => {
830
- const s = () => {
831
- };
832
- return s.oldValue = null, s;
833
- }, ce = () => ({}), Ht = (s, t, e) => {
834
- const n = t ? ot(t, e)(s) : s;
835
- return (o, ...r) => {
836
- const i = [...r];
837
- return o && !F(o) && i.unshift(o), xt(n, F(o) ? o : {})(...i);
838
- };
839
- }, le = (s) => [
840
- Ht(s),
841
- (t, e) => {
842
- ot(t, e)(s);
843
- }
844
- ], l = {}, kt = [
845
- "div",
846
- "span",
847
- "section",
848
- "input",
849
- "button",
850
- "table",
851
- "tr",
852
- "td",
853
- "th",
854
- "ul",
855
- "li",
856
- "ol",
857
- "form",
858
- "label",
859
- "select",
860
- "option",
861
- "textarea",
862
- "img",
863
- "a",
864
- "p",
865
- "h1",
866
- "h2",
867
- "h3",
868
- "h4",
869
- "h5",
870
- "h6",
871
- "br",
872
- "hr",
873
- "pre",
874
- "code",
875
- "nav",
876
- "header",
877
- "footer",
878
- "main",
879
- "aside",
880
- "article",
881
- "figure",
882
- "figcaption",
883
- "blockquote",
884
- "cite",
885
- "small",
886
- "strong",
887
- "em",
888
- "b",
889
- "i",
890
- "u",
891
- "s",
892
- "sub",
893
- "sup",
894
- "mark",
895
- "del",
896
- "ins",
897
- "details",
898
- "summary",
899
- "progress",
900
- "meter",
901
- "audio",
902
- "video",
903
- "canvas",
904
- "slot"
905
- ];
906
- kt.forEach((s) => {
907
- l[s] = (t, ...e) => {
908
- let n = [...e];
909
- return t && !F(t) && (n = [t].concat(n)), Z(s, F(t) ? t : {})(...n);
910
- };
911
- });
912
- const Pt = l.div, ae = l.span, de = l.section, he = l.input, fe = l.button, ue = l.table, pe = l.tr, me = l.td, Ee = l.th, Ce = l.ul, be = l.li, Se = l.ol, ye = l.form, we = l.label, ve = l.select, Ae = l.option, Re = l.textarea, ge = l.img, Le = l.a, Ie = l.p, Oe = l.h1, Me = l.h2, je = l.h3, Te = l.h4, $e = l.h5, _e = l.h6, We = l.br, xe = l.hr, He = l.pre, ke = l.code, Pe = l.nav, Fe = l.header, Be = l.footer, Ve = l.main, Ne = l.aside, Je = l.article, qe = l.figure, ze = l.figcaption, De = l.blockquote, Ge = l.cite, Ke = l.small, Ue = l.strong, Ye = l.em, Ze = l.b, Xe = l.i, Qe = l.u, ts = l.s, es = l.sub, ss = l.sup, ns = l.mark, os = l.del, rs = l.ins, is = l.details, cs = l.summary, ls = l.progress, as = l.meter, ds = l.audio, hs = l.video, fs = l.canvas, us = l.slot, ps = (s) => (t) => s(t).addClass(...t.classList ?? []).addReactiveClass(t.reactiveClassList ?? {});
913
- function Ft(s, t) {
914
- let e = 0;
915
- return (...n) => {
916
- const o = Date.now();
917
- o - e >= t && (s(...n), e = o);
918
- };
919
- }
920
- const ms = (s, t) => M(() => {
921
- const e = s();
922
- let n = null;
923
- return e.map(
924
- (o, r) => Pt(
925
- {
926
- "@dragstart": (i, c, a) => {
927
- n = a;
928
- },
929
- "@dragend": (i, c, a) => {
930
- a.style.transform = "", a.removeAttribute("draggable");
931
- },
932
- "@mousedown": (i, c, a) => {
933
- a.style.transform = "translateZ(0)", a.setAttribute("draggable", "true");
934
- },
935
- "@dragover": (i) => {
936
- i.preventDefault();
937
- },
938
- "@dragenter": Ft((i, c, a) => {
939
- var C, h, d;
940
- if (i.preventDefault(), n) {
941
- let m = n, p = a;
942
- const u = ((C = n.getClientRects().item(0)) == null ? void 0 : C.y) ?? 0, y = ((h = a.getClientRects().item(0)) == null ? void 0 : h.y) ?? 0;
943
- u < y && ([m, p] = [a, n]), (d = a.parentElement) == null || d.insertBefore(m, p);
944
- }
945
- }, 200)
946
- },
947
- t(o, r, [...s.peek()])
948
- )
949
- );
950
- }), Es = (s, t, e) => {
951
- let n = [], o = [];
952
- const r = W("div").addStyle({ display: "contents" }), i = /* @__PURE__ */ new Map(), c = /* @__PURE__ */ new Map();
953
- return w(() => {
954
- const a = s(), C = a.map(t);
955
- o.filter((d) => !C.includes(d)).forEach((d) => {
956
- var m, p;
957
- i.delete(d), (p = (m = r.hostElement) == null ? void 0 : m.querySelector(`[data-key="${d}"]`)) == null || p.remove();
958
- }), C.forEach((d, m) => {
959
- o.includes(d) || i.set(
960
- d,
961
- () => e(a[m], m, a).setCustomAttribute(
962
- "data-key",
963
- d
964
- )
965
- );
966
- }), C.forEach((d, m) => {
967
- var p;
968
- if (o.includes(d)) {
969
- JSON.stringify(n[o.indexOf(d)]) !== JSON.stringify(a[m]) && ((p = c.get(d)) == null || p.set({
970
- templateFunc: () => e(a[m], m, a),
971
- items: a,
972
- itemsKey: C,
973
- index: m
974
- }));
975
- return;
976
- }
977
- c.set(
978
- d,
979
- j({
980
- templateFunc: () => e(a[m], m, a),
981
- items: a,
982
- itemsKey: C,
983
- index: m
984
- })
985
- ), queueMicrotask(() => {
986
- w(() => {
987
- var H, B, E;
988
- const { templateFunc: u, index: y } = ((H = c.get(d)) == null ? void 0 : H()) ?? {}, x = (B = r.hostElement) == null ? void 0 : B.querySelector(
989
- `[data-key="${d}"]`
990
- ), L = (u == null ? void 0 : u().setCustomAttribute("data-key", d).hostElement) ?? document.createElement("div");
991
- x ? (E = r.hostElement) == null || E.childNodes.forEach((S, A) => {
992
- S instanceof HTMLElement && S.getAttribute("data-key") === d && (y === A ? (h(
993
- y ?? 0,
994
- r.hostElement,
995
- L
996
- ), S.remove()) : h(
997
- y ?? 0,
998
- r.hostElement,
999
- L
1000
- ));
1001
- }) : h(y ?? 0, r.hostElement, L);
1002
- });
1003
- });
1004
- });
1005
- const h = (d, m, p) => {
1006
- p && m && (d < m.children.length ? m.insertBefore(p, m.children[d]) : m.appendChild(p));
1007
- };
1008
- o = C, n = [...a];
1009
- }), r;
1010
- };
1011
- export {
1012
- _ as BaseElement,
1013
- Le as a,
1014
- Tt as addAttributeList,
1015
- Ot as addClassList,
1016
- It as addCustomAttributes,
1017
- Mt as addReactiveClassList,
1018
- jt as addStyleList,
1019
- D as appendContentItem,
1020
- Je as article,
1021
- Ne as aside,
1022
- ds as audio,
1023
- Ze as b,
1024
- zt as bindReactiveSignals,
1025
- De as blockquote,
1026
- We as br,
1027
- fe as button,
1028
- N as camelToKebab,
1029
- fs as canvas,
1030
- G as checkCall,
1031
- Nt as checkRef,
1032
- Ge as cite,
1033
- Rt as classList,
1034
- Qt as cls,
1035
- ke as code,
1036
- V as colorLog,
1037
- Gt as combineLatest,
1038
- ot as component,
1039
- le as configCustomComponent,
1040
- ps as createComponent,
1041
- xt as createCustom,
1042
- Wt as createCustomEl,
1043
- _t as createCustomElement,
1044
- Z as createEl,
1045
- W as createElement,
1046
- qt as createSignal,
1047
- vt as customElementHelpers,
1048
- ms as ddList,
1049
- ce as defineSlotTemplate,
1050
- os as del,
1051
- is as details,
1052
- pt as disableLogs,
1053
- Pt as div,
1054
- w as effect,
1055
- At as elementHelpers,
1056
- Ye as em,
1057
- Vt as enableLogs,
1058
- Yt as event,
1059
- Xt as eventEmitter,
1060
- ze as figcaption,
1061
- qe as figure,
1062
- Kt as firstUpdate,
1063
- Be as footer,
1064
- Dt as forkJoin,
1065
- ye as form,
1066
- Es as getList,
1067
- M as getSignalContent,
1068
- Oe as h1,
1069
- Me as h2,
1070
- je as h3,
1071
- Te as h4,
1072
- $e as h5,
1073
- _e as h6,
1074
- Fe as header,
1075
- xe as hr,
1076
- Xe as i,
1077
- ge as img,
1078
- lt as initComponent,
1079
- he as input,
1080
- rs as ins,
1081
- Zt as isBaseElement,
1082
- ft as isComponentConfig,
1083
- F as isComponentInitConfig,
1084
- g as isReactiveSignal,
1085
- se as isSlotTemplate,
1086
- ut as kebabToCamel,
1087
- we as label,
1088
- be as li,
1089
- Ve as main,
1090
- ns as mark,
1091
- as as meter,
1092
- Pe as nav,
1093
- ie as newEventEmitter,
1094
- Se as ol,
1095
- te as oldGetList,
1096
- Ae as option,
1097
- Ie as p,
1098
- He as pre,
1099
- ls as progress,
1100
- b as projectLog,
1101
- Ut as property,
1102
- Y as removeEffect,
1103
- at as renderIf,
1104
- Jt as rs,
1105
- $t as rxRenderIf,
1106
- ts as s,
1107
- de as section,
1108
- ve as select,
1109
- Lt as setChildren,
1110
- gt as setEffects,
1111
- et as setListeners,
1112
- re as show,
1113
- st as showIf,
1114
- j as signal,
1115
- ee as signalComponent,
1116
- us as slot,
1117
- Ke as small,
1118
- ae as span,
1119
- Ue as strong,
1120
- es as sub,
1121
- cs as summary,
1122
- ss as sup,
1123
- ue as table,
1124
- me as td,
1125
- Re as textarea,
1126
- Ee as th,
1127
- pe as tr,
1128
- Qe as u,
1129
- Ce as ul,
1130
- ne as unsafeHtml,
1131
- Ht as useCustomComponent,
1132
- hs as video,
1133
- oe as when
1134
- };