@tempots/beatui 0.80.0 → 0.82.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 (112) hide show
  1. package/dist/{ar-DwHLVgKj.cjs → ar-D7CXDmVZ.cjs} +1 -1
  2. package/dist/{ar-Bo_FZZi7.js → ar-nOSKXpIW.js} +1 -1
  3. package/dist/auth/index.cjs.js +1 -1
  4. package/dist/auth/index.es.js +101 -99
  5. package/dist/beatui.css +393 -0
  6. package/dist/beatui.tailwind.css +393 -0
  7. package/dist/{de-zI5mdV4M.cjs → de-WzsOu9Gn.cjs} +1 -1
  8. package/dist/{de-CCqwOkqN.js → de-f2xcEb34.js} +1 -1
  9. package/dist/{deep-merge-1uN6CG6K.js → deep-merge-CiOwVWn8.js} +269 -284
  10. package/dist/deep-merge-DxZqCkE5.cjs +1 -0
  11. package/dist/{duration-input-C9kpsw-t.js → duration-input-B3vnnwBZ.js} +30 -29
  12. package/dist/duration-input-Dg5SX3lM.cjs +1 -0
  13. package/dist/{es-BF02UrPL.js → es-CDqqzpCw.js} +1 -1
  14. package/dist/{es-Cw90CAbu.cjs → es-Ds2Xf3wV.cjs} +1 -1
  15. package/dist/{fa-DPQV4YB8.js → fa-C7tE_hR3.js} +1 -1
  16. package/dist/{fa-B4lssnzR.cjs → fa-Ct1UtDB7.cjs} +1 -1
  17. package/dist/{fr-1Kd6z1F-.cjs → fr-CzAkRFed.cjs} +1 -1
  18. package/dist/{fr-dmxPhwkD.js → fr-yOW_68YY.js} +1 -1
  19. package/dist/{he-BtQbrVt3.js → he-D2oUloCJ.js} +1 -1
  20. package/dist/{he-CJ3XnuPm.cjs → he-DlXALrK7.cjs} +1 -1
  21. package/dist/{hi-BpfnFKHp.cjs → hi-3dBhLwDs.cjs} +1 -1
  22. package/dist/{hi-D_Le4Yka.js → hi-D5ZlZoQq.js} +1 -1
  23. package/dist/{index-CfaWytS2.cjs → index-C5YCCgnn.cjs} +1 -1
  24. package/dist/{index-K6u33-GC.cjs → index-ChsRjiIp.cjs} +17 -17
  25. package/dist/{index-CGEzILlC.js → index-CiAVfKIZ.js} +1 -1
  26. package/dist/{index-YtW7SCWB.js → index-DT6-HMMz.js} +8 -7
  27. package/dist/index.cjs.js +4 -4
  28. package/dist/index.es.js +296 -291
  29. package/dist/{it-DyHjSuHN.js → it-6e6X-4BB.js} +1 -1
  30. package/dist/{it-COCZ9NyB.cjs → it-DohtcWi9.cjs} +1 -1
  31. package/dist/{ja-X43lABza.js → ja-BxNuNo2H.js} +1 -1
  32. package/dist/{ja--NdggLU9.cjs → ja-eyTArrgS.cjs} +1 -1
  33. package/dist/json-schema/index.cjs.js +1 -8
  34. package/dist/json-schema/index.es.js +1391 -7471
  35. package/dist/json-schema-display/index.cjs.js +1 -0
  36. package/dist/json-schema-display/index.es.js +846 -0
  37. package/dist/json-structure/index.cjs.js +1 -1
  38. package/dist/json-structure/index.es.js +89 -87
  39. package/dist/{ko-BUvb0ggK.cjs → ko-BFLCDMMs.cjs} +1 -1
  40. package/dist/{ko-B9g9iw99.js → ko-Ch0jFsBV.js} +1 -1
  41. package/dist/modal-D2xE47kr.cjs +1 -0
  42. package/dist/{modal-CSHIhHvI.js → modal-hkQD1bqZ.js} +22 -21
  43. package/dist/{nl-0S25Gsld.cjs → nl-Bx2ACvr4.cjs} +1 -1
  44. package/dist/{nl-Ew5jnSsT.js → nl-NuTdZO1s.js} +1 -1
  45. package/dist/notice-C0SmlheE.cjs +1 -0
  46. package/dist/{notice-C-964yaY.js → notice-CZHWWwOQ.js} +52 -51
  47. package/dist/oneof-branch-detection-BVNoKU9d.js +6281 -0
  48. package/dist/oneof-branch-detection-C8g3eWnx.cjs +8 -0
  49. package/dist/{pl-C9f6UBSe.js → pl-Bs4nLJ__.js} +1 -1
  50. package/dist/{pl-B3k-K3S4.cjs → pl-QHl6sl8f.cjs} +1 -1
  51. package/dist/prosemirror/index.cjs.js +1 -1
  52. package/dist/prosemirror/index.es.js +1 -1
  53. package/dist/{pt-DYtAvbrw.js → pt-BETjHZrL.js} +1 -1
  54. package/dist/{pt-CKoikRO5.cjs → pt-DZGw2Z-1.cjs} +1 -1
  55. package/dist/{ru-ZexN-b8V.js → ru-Bi1_DEKM.js} +1 -1
  56. package/dist/{ru-COb7RSDt.cjs → ru-D03IuLqh.cjs} +1 -1
  57. package/dist/stack-BJgsPJ9A.js +873 -0
  58. package/dist/stack-DcZ_u50f.cjs +1 -0
  59. package/dist/string-B9vVyfq3.cjs +1 -0
  60. package/dist/string-DYyMxBl-.js +19 -0
  61. package/dist/text-input-CByq5OIo.cjs +1 -0
  62. package/dist/text-input-CFJntP7G.js +287 -0
  63. package/dist/{toolbar-DNpBIoJo.js → toolbar-DR2Zd4Oo.js} +1 -1
  64. package/dist/toolbar-TPWYzoiF.cjs +1 -0
  65. package/dist/{tr-tO_EH-Y2.cjs → tr-B_-_1wua.cjs} +1 -1
  66. package/dist/{tr-BDvn05-H.js → tr-DiYB-FwX.js} +1 -1
  67. package/dist/translations-B4-Zd2LM.cjs +1 -0
  68. package/dist/translations-Cq8bUKJP.js +584 -0
  69. package/dist/{translations-DwGC_94w.cjs → translations-D62qqNV9.cjs} +1 -1
  70. package/dist/{translations-CfWR4loD.js → translations-DPr6c05Z.js} +1 -1
  71. package/dist/types/components/json-schema/schema-conditionals.d.ts +11 -0
  72. package/dist/types/components/json-schema/schema-context.d.ts +1 -1
  73. package/dist/types/components/json-schema-display/display-widget-customization.d.ts +61 -0
  74. package/dist/types/components/json-schema-display/display-wrapper.d.ts +14 -0
  75. package/dist/types/components/json-schema-display/displays/any-display.d.ts +14 -0
  76. package/dist/types/components/json-schema-display/displays/array-display.d.ts +13 -0
  77. package/dist/types/components/json-schema-display/displays/boolean-display.d.ts +13 -0
  78. package/dist/types/components/json-schema-display/displays/composition-display.d.ts +14 -0
  79. package/dist/types/components/json-schema-display/displays/enum-const-display.d.ts +13 -0
  80. package/dist/types/components/json-schema-display/displays/generic-display.d.ts +18 -0
  81. package/dist/types/components/json-schema-display/displays/null-display.d.ts +13 -0
  82. package/dist/types/components/json-schema-display/displays/number-display.d.ts +13 -0
  83. package/dist/types/components/json-schema-display/displays/object-display.d.ts +13 -0
  84. package/dist/types/components/json-schema-display/displays/string-display.d.ts +14 -0
  85. package/dist/types/components/json-schema-display/index.d.ts +14 -0
  86. package/dist/types/components/json-schema-display/json-schema-display.d.ts +25 -0
  87. package/dist/types/components/json-schema-display/mismatch.d.ts +14 -0
  88. package/dist/types/json-schema-display/index.d.ts +1 -0
  89. package/dist/{ur-DbEqQgS6.js → ur-B69X-xNs.js} +1 -1
  90. package/dist/{ur-BbnYJ3HS.cjs → ur-DyUSmIbo.cjs} +1 -1
  91. package/dist/use-form-CgZyrACX.js +864 -0
  92. package/dist/use-form-JjeKCINk.cjs +2 -0
  93. package/dist/utils-DEbsp9Q9.js +129 -0
  94. package/dist/utils-DIUEhA-Z.cjs +1 -0
  95. package/dist/{vi-CpZUeuSj.js → vi-BdzxA60L.js} +1 -1
  96. package/dist/{vi-ByBwvGQY.cjs → vi-CBmPaHxg.cjs} +1 -1
  97. package/dist/widget-customization-DRA7E9Zf.js +1072 -0
  98. package/dist/widget-customization-G-QLB1rw.cjs +1 -0
  99. package/dist/{zh-DnxK0ieB.cjs → zh-Cb1b8uik.cjs} +1 -1
  100. package/dist/{zh-DJyhKO0I.js → zh-Dn1UJiZa.js} +1 -1
  101. package/package.json +13 -7
  102. package/dist/deep-merge-CBIkQM4E.cjs +0 -1
  103. package/dist/duration-input-DHWhQJnn.cjs +0 -1
  104. package/dist/modal-cc8Ehngz.cjs +0 -1
  105. package/dist/notice-C_BWqu2K.cjs +0 -1
  106. package/dist/toolbar-D5FcnRju.cjs +0 -1
  107. package/dist/translations-0tLX4x7M.js +0 -866
  108. package/dist/translations-WPN3ibDg.cjs +0 -1
  109. package/dist/use-form-D4JFOcjo.cjs +0 -2
  110. package/dist/use-form-D4rqJkvG.js +0 -1731
  111. package/dist/widget-customization-BSjJz3_Y.js +0 -1195
  112. package/dist/widget-customization-CrFVrt4V.cjs +0 -1
@@ -1,1195 +0,0 @@
1
- import { Value as p, prop as ot, computedOf as D, html as _, attr as u, svg as et, svgAttr as Y, on as $, Empty as A, When as W, Fragment as E, aria as N, emitValue as tt, Use as ct, input as it, emitValueAsNullableDate as nt, emitValueAsNullableDateTime as st, style as lt, Repeat as gt, emit as dt, emitValueAsNumber as B } from "@tempots/dom";
2
- import { F as ht, $ as mt, N as X, T as ft, U as bt, a as yt } from "./deep-merge-1uN6CG6K.js";
3
- import { C as V, b as U, a as wt, c as Q, T as xt, L as $t, d as rt, e as Mt } from "./translations-0tLX4x7M.js";
4
- import { AutoSelect as It, ElementRect as _t } from "@tempots/ui";
5
- import { E as kt, P as Tt } from "./notice-C-964yaY.js";
6
- import { s as Ct } from "./use-form-D4rqJkvG.js";
7
- function ut(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 Ft(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, s = t.match(e);
15
- if (!s) return !1;
16
- const [, n, a, r] = s, o = parseInt(n, 10), c = parseInt(a, 10), i = parseInt(r, 10);
17
- return o >= 0 && o <= 255 && c >= 0 && c <= 255 && i >= 0 && i <= 255;
18
- }
19
- function At(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, s = t.match(e);
22
- if (!s) return !1;
23
- const [, n, a, r, o] = s, c = parseInt(n, 10), i = parseInt(a, 10), l = parseInt(r, 10), g = parseFloat(o);
24
- return c >= 0 && c <= 255 && i >= 0 && i <= 255 && l >= 0 && l <= 255 && g >= 0 && g <= 1;
25
- }
26
- function vt(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, s = t.match(e);
29
- if (!s) return !1;
30
- const [, n, a, r] = s, o = parseInt(n, 10), c = parseInt(a, 10), i = parseInt(r, 10);
31
- return o >= 0 && o <= 360 && c >= 0 && c <= 100 && i >= 0 && i <= 100;
32
- }
33
- function ce(t) {
34
- return ut(t) || Ft(t) || At(t) || vt(t);
35
- }
36
- function St(t) {
37
- if (!ut(t)) return null;
38
- let e = t.startsWith("#") ? t.slice(1) : t;
39
- return e.length === 3 && (e = e.split("").map((s) => s + s).join("")), `#${e.toLowerCase()}`;
40
- }
41
- function J(t, e, s) {
42
- const n = (a) => {
43
- const r = Math.round(Math.max(0, Math.min(255, a))).toString(16);
44
- return r.length === 1 ? "0" + r : r;
45
- };
46
- return `#${n(t)}${n(e)}${n(s)}`;
47
- }
48
- function H(t) {
49
- const e = St(t);
50
- if (!e) return null;
51
- const s = /^#([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);
52
- return s ? {
53
- r: parseInt(s[1], 16),
54
- g: parseInt(s[2], 16),
55
- b: parseInt(s[3], 16)
56
- } : null;
57
- }
58
- function ie(t, e) {
59
- const s = H(t), n = H(e);
60
- if (!s || !n) return null;
61
- const a = (l, g, m) => {
62
- const [b, d, w] = [l, g, m].map((x) => (x = x / 255, x <= 0.03928 ? x / 12.92 : Math.pow((x + 0.055) / 1.055, 2.4)));
63
- return 0.2126 * b + 0.7152 * d + 0.0722 * w;
64
- }, r = a(s.r, s.g, s.b), o = a(n.r, n.g, n.b), c = Math.max(r, o), i = Math.min(r, o);
65
- return (c + 0.05) / (i + 0.05);
66
- }
67
- function Rt(t) {
68
- if (!t) return [0, 0, 0, 1];
69
- const s = t.trim().match(
70
- /^#?([a-fA-F0-9]{3,4}|[a-fA-F0-9]{6}|[a-fA-F0-9]{8})$/
71
- );
72
- if (s) {
73
- const l = s[1];
74
- if (l.length === 8) {
75
- const g = parseInt(l.slice(0, 2), 16), m = parseInt(l.slice(2, 4), 16), b = parseInt(l.slice(4, 6), 16), d = parseInt(l.slice(6, 8), 16) / 255;
76
- return [g, m, b, d];
77
- }
78
- if (l.length === 6)
79
- return [
80
- parseInt(l.slice(0, 2), 16),
81
- parseInt(l.slice(2, 4), 16),
82
- parseInt(l.slice(4, 6), 16),
83
- 1
84
- ];
85
- if (l.length === 4) {
86
- const g = parseInt(l[0] + l[0], 16), m = parseInt(l[1] + l[1], 16), b = parseInt(l[2] + l[2], 16), d = parseInt(l[3] + l[3], 16) / 255;
87
- return [g, m, b, d];
88
- }
89
- if (l.length === 3) {
90
- const g = parseInt(l[0] + l[0], 16), m = parseInt(l[1] + l[1], 16), b = parseInt(l[2] + l[2], 16);
91
- return [g, m, b, 1];
92
- }
93
- }
94
- const n = 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 (n)
98
- return [
99
- parseInt(n[1], 10),
100
- parseInt(n[2], 10),
101
- parseInt(n[3], 10),
102
- parseFloat(n[4])
103
- ];
104
- const a = t.match(
105
- /^rgb\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*\)$/i
106
- );
107
- if (a)
108
- return [parseInt(a[1], 10), parseInt(a[2], 10), parseInt(a[3], 10), 1];
109
- const r = t.match(
110
- /^hsla?\(\s*([+-]?[\d.]+)(?:deg)?\s*[ ,]?\s*([\d.]+)%\s*[ ,]?\s*([\d.]+)%\s*(?:[/,]\s*(\d?(?:\.\d+)?))?\s*\)$/i
111
- );
112
- if (r) {
113
- const l = parseFloat(r[1]), g = parseFloat(r[2]), m = parseFloat(r[3]), b = r[4] != null ? parseFloat(r[4]) : 1, [d, w, x] = pt(l, g / 100, m / 100);
114
- return [d, w, x, b];
115
- }
116
- const o = t.match(
117
- /^hwb\(\s*([+-]?[\d.]+)(?:deg)?\s*[, ]\s*([\d.]+)%\s*[, ]\s*([\d.]+)%\s*(?:[/]\s*(\d?(?:\.\d+)?))?\s*\)$/i
118
- );
119
- if (o) {
120
- const l = parseFloat(o[1]), g = parseFloat(o[2]) / 100, m = parseFloat(o[3]) / 100, b = o[4] != null ? parseFloat(o[4]) : 1, [d, w, x] = Lt(l, g, m);
121
- return [d, w, x, 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 l = c[1], g = parseFloat(c[2]), m = parseFloat(c[3]), b = c[4] != null ? parseFloat(c[4]) : 1, d = l.endsWith("%") ? Math.max(0, Math.min(1, parseFloat(l) / 100)) : Math.max(0, Math.min(1, parseFloat(l))), [w, x, y] = Et(d, g, m);
128
- return [w, x, y, b];
129
- }
130
- const i = H(t);
131
- return i ? [i.r, i.g, i.b, 1] : [0, 0, 0, 1];
132
- }
133
- function Nt(t, e, s, n) {
134
- return `rgba(${Math.round(t)}, ${Math.round(e)}, ${Math.round(s)}, ${Math.max(
135
- 0,
136
- Math.min(1, Math.round(n * 100) / 100)
137
- )})`;
138
- }
139
- function Dt(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 pt(t, e, s) {
146
- t = (t % 360 + 360) % 360;
147
- const n = (1 - Math.abs(2 * s - 1)) * e, a = n * (1 - Math.abs(t / 60 % 2 - 1)), r = s - n / 2;
148
- let o = 0, c = 0, i = 0;
149
- return 0 <= t && t < 60 ? [o, c, i] = [n, a, 0] : 60 <= t && t < 120 ? [o, c, i] = [a, n, 0] : 120 <= t && t < 180 ? [o, c, i] = [0, n, a] : 180 <= t && t < 240 ? [o, c, i] = [0, a, n] : 240 <= t && t < 300 ? [o, c, i] = [a, 0, n] : [o, c, i] = [n, 0, a], [
150
- Math.round((o + r) * 255),
151
- Math.round((c + r) * 255),
152
- Math.round((i + r) * 255)
153
- ];
154
- }
155
- function Lt(t, e, s) {
156
- t = (t % 360 + 360) % 360;
157
- const n = e + s;
158
- n > 1 && (e /= n, s /= n);
159
- const [a, r, o] = pt(t, 1, 0.5).map((m) => m / 255), c = 1 - e - s, i = a * c + e, l = r * c + e, g = o * c + e;
160
- return [Math.round(i * 255), Math.round(l * 255), Math.round(g * 255)];
161
- }
162
- function Z(t, e, s) {
163
- t /= 255, e /= 255, s /= 255;
164
- const n = Math.max(t, e, s), a = Math.min(t, e, s);
165
- let r = 0, o = 0;
166
- const c = (n + a) / 2, i = n - a;
167
- if (i !== 0) {
168
- switch (o = c > 0.5 ? i / (2 - n - a) : i / (n + a), n) {
169
- case t:
170
- r = (e - s) / i + (e < s ? 6 : 0);
171
- break;
172
- case e:
173
- r = (s - t) / i + 2;
174
- break;
175
- default:
176
- r = (t - e) / i + 4;
177
- }
178
- r *= 60;
179
- }
180
- return [Math.round(r), Math.round(o * 100), Math.round(c * 100)];
181
- }
182
- function Bt(t, e, s) {
183
- const [n] = Z(t, e, s), a = t / 255, r = e / 255, o = s / 255, c = Math.min(a, r, o), i = 1 - Math.max(a, r, o);
184
- return [n, Math.round(c * 100), Math.round(i * 100)];
185
- }
186
- function G(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 K(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 Et(t, e, s) {
195
- const n = s * Math.PI / 180, a = Math.cos(n) * e, r = Math.sin(n) * e, o = t + 0.3963377774 * a + 0.2158037573 * r, c = t - 0.1055613458 * a - 0.0638541728 * r, i = t - 0.0894841775 * a - 1.291485548 * r, l = o * o * o, g = c * c * c, m = i * i * i, b = 4.0767416621 * l - 3.3077115913 * g + 0.2309699292 * m, d = -1.2684380046 * l + 2.6097574011 * g - 0.3413193965 * m, w = -0.0041960863 * l - 0.7034186147 * g + 1.707614701 * m;
196
- return [K(b), K(d), K(w)];
197
- }
198
- function Vt(t, e, s) {
199
- const n = G(t), a = G(e), r = G(s), o = 0.4122214708 * n + 0.5363325363 * a + 0.0514459929 * r, c = 0.2119034982 * n + 0.6806995451 * a + 0.1073969566 * r, i = 0.0883024619 * n + 0.2817188376 * a + 0.6299787005 * r, l = Math.cbrt(o), g = Math.cbrt(c), m = Math.cbrt(i), b = 0.2104542553 * l + 0.793617785 * g - 0.0040720468 * m, d = 1.9779984951 * l - 2.428592205 * g + 0.4505937099 * m, w = 0.0259040371 * l + 0.7827717662 * g - 0.808675766 * m, x = Math.sqrt(d * d + w * w);
200
- let y = Math.atan2(w, d) * 180 / Math.PI;
201
- return y < 0 && (y += 360), [b, x, y];
202
- }
203
- function P(t, e, s, n, a, r) {
204
- switch (a) {
205
- case "hex":
206
- if (r) {
207
- const o = (i) => i.toString(16).padStart(2, "0"), c = Math.max(0, Math.min(255, Math.round(n * 255)));
208
- return `#${o(t)}${o(e)}${o(s)}${o(c)}`;
209
- }
210
- return J(t, e, s);
211
- case "rgb":
212
- return `rgb(${t}, ${e}, ${s})`;
213
- case "rgba":
214
- return `rgba(${t}, ${e}, ${s}, ${Math.round(n * 100) / 100})`;
215
- case "hsl": {
216
- const [o, c, i] = Z(t, e, s);
217
- return `hsl(${o}, ${c}%, ${i}%)`;
218
- }
219
- case "hsla": {
220
- const [o, c, i] = Z(t, e, s);
221
- return `hsla(${o}, ${c}%, ${i}%, ${Math.round(n * 100) / 100})`;
222
- }
223
- case "hwb": {
224
- const [o, c, i] = Bt(t, e, s);
225
- return n < 1 ? `hwb(${o} ${c}% ${i}% / ${Math.round(n * 100) / 100})` : `hwb(${o} ${c}% ${i}%)`;
226
- }
227
- case "oklch": {
228
- const [o, c, i] = Vt(t, e, s), l = (Math.round(o * 1e3) / 1e3).toFixed(3), g = (Math.round(c * 1e3) / 1e3).toFixed(3), m = (Math.round(i * 10) / 10).toFixed(1), b = Math.round(n * 100) / 100;
229
- return r || n < 1 ? `oklch(${l} ${g} ${m} / ${b})` : `oklch(${l} ${g} ${m})`;
230
- }
231
- }
232
- }
233
- function j(t, e) {
234
- return e ? t === "rgb" ? "rgba" : t === "hsl" ? "hsla" : t : t === "rgba" ? "rgb" : t === "hsla" ? "hsl" : t;
235
- }
236
- async function Ut(t) {
237
- return new Promise((e, s) => {
238
- const n = new FileReader();
239
- n.readAsDataURL(t), n.onload = () => {
240
- const a = n.result;
241
- e(a.split(",")[1]);
242
- }, n.onerror = (a) => s(a);
243
- });
244
- }
245
- function Ot(t) {
246
- return Promise.all(t.map(Ut));
247
- }
248
- function Pt(t) {
249
- if (t.length >= 4) {
250
- if (t[0] === 137 && t[1] === 80 && t[2] === 78 && t[3] === 71)
251
- return "image/png";
252
- if (t[0] === 255 && t[1] === 216) return "image/jpeg";
253
- if (t[0] === 71 && t[1] === 73 && t[2] === 70)
254
- return "image/gif";
255
- 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)
256
- return "image/webp";
257
- }
258
- try {
259
- if (new TextDecoder("utf-8").decode(t.slice(0, 256)).includes("<svg")) return "image/svg+xml";
260
- } catch {
261
- }
262
- return "application/octet-stream";
263
- }
264
- function jt(t) {
265
- const e = mt(t ?? ""), s = e.length, n = new Uint8Array(s);
266
- for (let a = 0; a < s; a++) n[a] = e.charCodeAt(a);
267
- return n;
268
- }
269
- function Wt(t) {
270
- const {
271
- value: e,
272
- onChange: s,
273
- onInput: n,
274
- ...a
275
- } = t, r = /* @__PURE__ */ new Map(), o = p.toSignal(e).map((g) => g.map((m, b) => {
276
- const d = r.get(m), w = jt(m ?? ""), x = d?.type || Pt(w), y = d?.name ?? `file-${b}`, I = w.buffer.slice(
277
- w.byteOffset,
278
- w.byteOffset + w.byteLength
279
- ), f = new Blob([I], { type: x });
280
- return new File([f], y, { type: x });
281
- })), c = (g) => (m) => {
282
- g && Ot(m).then((b) => {
283
- for (const [d, w] of b.entries())
284
- r.set(w, { name: m[d].name, type: m[d].type });
285
- g(b);
286
- });
287
- }, i = c(s), l = c(n);
288
- return ht({
289
- ...a,
290
- value: o,
291
- onChange: i,
292
- onInput: l
293
- });
294
- }
295
- function le(t) {
296
- const {
297
- value: e,
298
- onInput: s,
299
- onChange: n,
300
- ...a
301
- } = t;
302
- return Wt({
303
- ...a,
304
- maxFiles: 1,
305
- value: p.map(e, (r) => r == null ? [] : [r]),
306
- onChange: (r) => {
307
- n?.(r[0]);
308
- },
309
- onInput: (r) => {
310
- s?.(r[0]);
311
- }
312
- });
313
- }
314
- function Ht(t, e) {
315
- const [s, n, a] = t, r = s << 16 ^ n << 8 ^ a, o = Dt(r), c = 6 + Math.floor(o() * 5), i = 0.18 + o() * 0.06, l = [];
316
- for (let d = 0; d < c; d++) {
317
- const w = d / c * Math.PI * 2, x = e * (1 + (o() * 2 - 1) * i), y = Math.cos(w) * x, I = Math.sin(w) * x;
318
- l.push({ x: y, y: I });
319
- }
320
- const g = (l[0].x + l[c - 1].x) / 2, m = (l[0].y + l[c - 1].y) / 2;
321
- let b = `M ${g.toFixed(3)} ${m.toFixed(3)}`;
322
- for (let d = 0; d < c; d++) {
323
- const w = l[d], x = l[(d + 1) % c], y = (w.x + x.x) / 2, I = (w.y + x.y) / 2;
324
- b += ` Q ${w.x.toFixed(3)} ${w.y.toFixed(3)} ${y.toFixed(3)} ${I.toFixed(3)}`;
325
- }
326
- return b += " Z", b;
327
- }
328
- const ue = (t) => {
329
- const { value: e, onBlur: s, onChange: n, onInput: a, displayValue: r, size: o, withAlpha: c } = t, i = p.map(o ?? 32, (h) => h), l = p.map(e, (h) => Rt(h ?? "#000000")), g = p.map(
330
- l,
331
- ([h, M, T]) => [h, M, T]
332
- ), m = p.map(l, ([, , , h]) => h), b = ot(p.get(m) ?? 1), d = p.map(c ?? !1, (h) => h), w = p.map(
333
- t.colorTextFormat ?? "rgb",
334
- (h) => h
335
- ), x = D(
336
- g,
337
- b,
338
- w,
339
- d
340
- )(
341
- ([h, M, T], v, S, R) => P(h, M, T, v ?? 1, j(S, R), R)
342
- ), y = p.map(
343
- t.colorTextFormat ?? "hex",
344
- (h) => h
345
- ), I = p.map(i, (h) => `${-h / 2} ${-h / 2} ${h} ${h}`), f = D(
346
- g,
347
- i
348
- )((h, M) => Ht(h, M / 2)), F = D(
349
- g,
350
- b,
351
- d
352
- )(
353
- ([h, M, T], v, S) => S || v < 1 ? Nt(h, M, T, v) : J(h, M, T)
354
- ), C = _.div(
355
- u.class("bc-color-swatch-input__control"),
356
- u.class(
357
- p.map(
358
- d,
359
- (h) => h ? "bc-color-swatch-input__control--alpha" : ""
360
- )
361
- ),
362
- u.style(
363
- D(i)((h) => `min-width:${h + 2}px;height:${h + 2}px`)
364
- ),
365
- // The SVG blob preview
366
- et.svg(
367
- u.class("bc-color-swatch-input__svg"),
368
- Y.viewBox(I),
369
- et.path(Y.d(f), Y.fill(F))
370
- ),
371
- // Invisible native input overlays the blob for picker and accessibility
372
- _.input(
373
- u.type("color"),
374
- V(t),
375
- // Native color input needs hex without alpha
376
- u.value(p.map(g, ([h, M, T]) => J(h, M, T))),
377
- u.class(
378
- "bc-input bc-color-swatch-input bc-color-swatch-input__native"
379
- ),
380
- s != null ? $.blur(s) : A,
381
- n != null ? $.change((h) => {
382
- const M = h.target.value;
383
- if (!n) return;
384
- const { r: T, g: v, b: S } = H(M) ?? { r: 0, g: 0, b: 0 }, R = p.get(b) ?? 1, L = j(
385
- p.get(y),
386
- p.get(d)
387
- ), z = P(T, v, S, R, L, p.get(d));
388
- n(z);
389
- }) : A,
390
- a != null ? $.input((h) => {
391
- const M = h.target.value;
392
- if (!a) return;
393
- const { r: T, g: v, b: S } = H(M) ?? { r: 0, g: 0, b: 0 }, R = p.get(b) ?? 1, L = j(
394
- p.get(y),
395
- p.get(d)
396
- ), z = P(T, v, S, R, L, p.get(d));
397
- a(z);
398
- }) : A
399
- )
400
- ), k = W(
401
- d,
402
- () => _.input(
403
- u.type("range"),
404
- u.class("bc-color-swatch-input__alpha"),
405
- u.min(0),
406
- u.max(1),
407
- u.step(0.01),
408
- u.value(p.map(b, (h) => String(h ?? 1))),
409
- u.disabled(t.disabled),
410
- $.input((h) => {
411
- const M = parseFloat(h.target.value);
412
- b.set(M);
413
- const [T, v, S] = p.get(g), R = j(
414
- p.get(y),
415
- p.get(d)
416
- ), L = P(T, v, S, M, R, p.get(d));
417
- a?.(L);
418
- }),
419
- $.change((h) => {
420
- const M = parseFloat(h.target.value);
421
- b.set(M);
422
- const [T, v, S] = p.get(g), R = j(
423
- p.get(y),
424
- p.get(d)
425
- ), L = P(T, v, S, M, R, p.get(d));
426
- n?.(L);
427
- })
428
- )
429
- );
430
- return U({
431
- baseContainer: !0,
432
- ...t,
433
- // ensure our control does not try to grow
434
- growInput: !1,
435
- input: C,
436
- // If caller provided an `after`, append RGB before it
437
- after: E(
438
- W(
439
- r ?? !1,
440
- () => _.span(u.class("bc-color-swatch-input__rgb"), x)
441
- ),
442
- k,
443
- t.after
444
- )
445
- });
446
- };
447
- function Xt(t, e, s) {
448
- const n = ["bc-card"];
449
- return t !== "default" && n.push(`bc-card--${t}`), e !== "md" && n.push(`bc-card--padding-${e}`), s !== "lg" && n.push(`bc-card--rounded-${s}`), n.join(" ");
450
- }
451
- function pe({ variant: t = "default", size: e = "md", roundedness: s = "lg" } = {}, ...n) {
452
- return _.div(
453
- u.class(
454
- D(
455
- t,
456
- e,
457
- s
458
- )(
459
- (a, r, o) => Xt(
460
- a ?? "default",
461
- r ?? "md",
462
- o ?? "lg"
463
- )
464
- )
465
- ),
466
- ...n
467
- );
468
- }
469
- const ge = ({
470
- startEditing: t,
471
- value: e,
472
- onChange: s,
473
- placeholder: n,
474
- disabled: a
475
- }) => {
476
- const r = p.deriveProp(t ?? !1), o = ot(!1), c = p.map(a ?? !1, (i) => i);
477
- return _.div(
478
- u.class("bc-editable-text"),
479
- u.class(
480
- p.map(
481
- c,
482
- (i) => i ? "bc-editable-text--disabled" : ""
483
- )
484
- ),
485
- N.disabled(c),
486
- W(
487
- r,
488
- () => _.input(
489
- u.placeholder(n),
490
- u.value(e),
491
- u.class("bc-editable-text__input"),
492
- It(),
493
- $.keydown((i) => {
494
- i.key === "Enter" ? r.set(!1) : i.key === "Escape" && (o.set(!0), r.set(!1));
495
- }),
496
- $.blur(
497
- tt((i) => {
498
- if (r.set(!1), o.value) {
499
- o.set(!1);
500
- return;
501
- }
502
- s(i);
503
- })
504
- )
505
- ),
506
- () => _.span(
507
- $.click(() => {
508
- p.get(c) || r.set(!0);
509
- }),
510
- u.class("bc-editable-text__display"),
511
- W(
512
- p.map(e, (i) => i != null && i.trim() !== ""),
513
- () => _.span(u.class("bc-editable-text__text"), e),
514
- () => _.span(
515
- u.class("bc-editable-text__placeholder"),
516
- n
517
- )
518
- ),
519
- W(
520
- p.map(c, (i) => !i),
521
- () => _.button(
522
- u.type("button"),
523
- u.class("bc-editable-text__edit-button"),
524
- ct(wt, (i) => N.label(i.$.editLabel)),
525
- $.click(() => r.set(!0)),
526
- Q({ icon: "line-md/pencil", color: "neutral" })
527
- )
528
- )
529
- )
530
- )
531
- );
532
- }, de = (t) => {
533
- const { value: e, onBlur: s, onChange: n, onInput: a, after: r, disabled: o } = t, c = X(e, o, n ?? a);
534
- return U({
535
- ...t,
536
- input: it.date(
537
- V(t),
538
- u.valueAsDate(e),
539
- u.class("bc-input"),
540
- s != null ? $.blur(tt(s)) : A,
541
- n != null ? $.change(nt(n)) : A,
542
- a != null ? $.input(nt(a)) : A
543
- ),
544
- after: r != null ? E(c, r) : c
545
- });
546
- }, zt = (t) => {
547
- const e = t.getFullYear(), s = t.getMonth() + 1, n = t.getDate(), a = t.getHours(), r = t.getMinutes(), o = t.getSeconds();
548
- return `${e}-${s.toString().padStart(2, "0")}-${n.toString().padStart(2, "0")}T${a.toString().padStart(2, "0")}:${r.toString().padStart(2, "0")}:${o.toString().padStart(2, "0")}`;
549
- }, he = (t) => {
550
- const { value: e, onBlur: s, onChange: n, onInput: a, after: r, disabled: o } = t, c = p.map(e, (l) => l != null ? zt(l) : null), i = X(e, o, n ?? a);
551
- return U({
552
- ...t,
553
- input: it["datetime-local"](
554
- V(t),
555
- u.value(p.map(c, (l) => l ?? null)),
556
- u.class("bc-input"),
557
- s != null ? $.blur(tt(s)) : A,
558
- n != null ? $.change(st(n)) : A,
559
- a != null ? $.input(st(a)) : A
560
- ),
561
- after: r != null ? E(i, r) : i
562
- });
563
- }, at = (t) => typeof t == "string" && t.trim() === "" ? null : t, Yt = (t) => t ?? "";
564
- function O(t) {
565
- return (e) => {
566
- const { value: s, onBlur: n, onChange: a, onInput: r, after: o, disabled: c, ...i } = e, l = X(s, c, a ?? r);
567
- return t({
568
- ...i,
569
- disabled: c,
570
- value: p.map(s, Yt),
571
- onChange: a != null ? (g) => a(at(g)) : void 0,
572
- onInput: r != null ? (g) => r(at(g)) : void 0,
573
- onBlur: n,
574
- after: o != null ? E(l, o) : l
575
- });
576
- };
577
- }
578
- const me = O(kt), fe = O(xt), be = O(Tt), ye = O(
579
- ft
580
- ), we = ({
581
- value: t,
582
- onChange: e,
583
- onInput: s,
584
- onBlur: n,
585
- offLabel: a,
586
- onLabel: r,
587
- disabled: o = !1,
588
- size: c = "md",
589
- id: i,
590
- color: l = "primary",
591
- tabIndex: g = 0
592
- }) => {
593
- const m = i ?? Ct("switch");
594
- function b(y, I) {
595
- const f = [
596
- "bc-switch",
597
- `bc-switch--size-${I}`,
598
- `bc-switch--${I}`
599
- ];
600
- return y && f.push("bc-switch--disabled"), f.join(" ");
601
- }
602
- function d(y) {
603
- const I = y ?? "primary", f = /* @__PURE__ */ new Map(), F = rt(I, "solid", "light"), C = rt(I, "solid", "dark");
604
- return f.set("--switch-track-on-bg", F.backgroundColor), f.set("--switch-track-on-label", F.textColor), f.set("--switch-track-on-bg-dark", C.backgroundColor), f.set("--switch-track-on-label-dark", C.textColor), f.set(
605
- "--switch-track-on-border-dark",
606
- Mt(I, "dark")
607
- ), Array.from(f.entries()).map(([k, h]) => `${k}: ${h}`).join("; ");
608
- }
609
- const w = () => {
610
- p.get(o) || (e?.(!p.get(t)), s?.(!p.get(t)));
611
- }, x = (y) => {
612
- p.get(o) || (y.key === " " || y.key === "Enter") && (y.preventDefault(), w());
613
- };
614
- return _.div(
615
- u.class(
616
- D(
617
- o ?? !1,
618
- c
619
- )(
620
- (y, I) => b(y ?? !1, I ?? "md")
621
- )
622
- ),
623
- u.style(
624
- D(l)(
625
- (y) => d(y)
626
- )
627
- ),
628
- u.id(m),
629
- u.role("switch"),
630
- u.tabindex(
631
- D(
632
- o ?? !1,
633
- g
634
- )((y, I) => y ? -1 : I ?? 0)
635
- ),
636
- N.checked(t),
637
- N.disabled(o),
638
- $.click(w),
639
- $.keydown(x),
640
- n != null ? $.blur(n) : null,
641
- _.div(
642
- u.class("bc-switch__track"),
643
- u.class(
644
- p.map(
645
- t,
646
- (y) => y ? "bc-switch__track--on" : "bc-switch__track--off"
647
- )
648
- ),
649
- a != null ? _.div(
650
- N.hidden(!0),
651
- u.class("bc-switch__track-label bc-switch__track-label--off"),
652
- u.class(
653
- p.map(
654
- t,
655
- (y) => y ? "bc-switch__track-label--hidden" : "bc-switch__track-label--visible"
656
- )
657
- ),
658
- a
659
- ) : null,
660
- r != null ? _.div(
661
- u.class("bc-switch__track-label bc-switch__track-label--on"),
662
- u.class(
663
- p.map(
664
- t,
665
- (y) => y ? "bc-switch__track-label--visible" : "bc-switch__track-label--hidden"
666
- )
667
- ),
668
- r
669
- ) : null,
670
- _t(
671
- (y) => ct(
672
- $t,
673
- ({ direction: I }) => _.div(
674
- u.class("bc-switch__thumb"),
675
- u.class(
676
- p.map(
677
- t,
678
- (f) => f ? "bc-switch__thumb--on" : "bc-switch__thumb--off"
679
- )
680
- ),
681
- lt.transform(
682
- D(
683
- t,
684
- y,
685
- c,
686
- I
687
- )((f, { width: F }, C, k) => {
688
- const h = (() => {
689
- switch (C) {
690
- case "xs":
691
- return 5;
692
- case "sm":
693
- return 5.5;
694
- case "md":
695
- return 6;
696
- case "lg":
697
- return 7;
698
- case "xl":
699
- return 8;
700
- }
701
- })(), M = k === "rtl" ? `calc((var(--spacing-base) * ${h}) - ${F}px)` : `calc(${F}px - (var(--spacing-base) * ${h}))`;
702
- return f ? `translateX(${M})` : "translateX(0)";
703
- })
704
- )
705
- )
706
- )
707
- )
708
- )
709
- );
710
- }, xe = O(bt), Gt = "line-md:star-alt-filled", Kt = "line-md:star-alt", qt = (t) => {
711
- const {
712
- value: e,
713
- onChange: s,
714
- disabled: n,
715
- max: a = 5,
716
- fullColor: r = "yellow",
717
- emptyColor: o = "neutral",
718
- fullIcon: c = Gt,
719
- emptyIcon: i = Kt,
720
- size: l = "md",
721
- onBlur: g,
722
- rounding: m = 1
723
- } = t, b = () => {
724
- const f = p.get(m);
725
- return f > 0 ? f : 1;
726
- }, d = (f) => Math.min(Math.max(f, 0), p.get(a)), w = (f, F) => {
727
- if (p.get(n ?? !1)) return;
728
- const k = f.currentTarget.getBoundingClientRect(), h = (f.clientX - k.left) / k.width, M = F - 1 + h, T = b(), v = Math.ceil(M / T) * T, S = d(v);
729
- s?.(S);
730
- }, x = (f) => {
731
- if (p.get(n ?? !1)) return;
732
- const F = b(), C = p.get(e) ?? 0;
733
- let k;
734
- switch (f.key) {
735
- case "ArrowRight":
736
- case "ArrowUp":
737
- k = d(C + F);
738
- break;
739
- case "ArrowLeft":
740
- case "ArrowDown":
741
- k = d(C - F);
742
- break;
743
- case "Home":
744
- k = 0;
745
- break;
746
- case "End":
747
- k = p.get(a);
748
- break;
749
- default:
750
- return;
751
- }
752
- f.preventDefault(), s?.(k);
753
- }, y = p.map(l, (f) => `bc-icon--${f}`), I = ({ index: f, counter: F }) => _.span(
754
- u.class("bc-rating-input__icon-container"),
755
- u.class(y),
756
- Q(
757
- {
758
- icon: i,
759
- size: l,
760
- color: o,
761
- tone: "soft"
762
- },
763
- u.class("bc-rating-input__icon-empty")
764
- ),
765
- _.span(
766
- u.class("bc-rating-input__icon-clipper"),
767
- u.class(y),
768
- lt.width(
769
- p.map(e, (C) => {
770
- const k = Math.floor(C);
771
- return k > f ? "100%" : k < f ? "0%" : `${(C - f) * 100}%`;
772
- })
773
- ),
774
- Q(
775
- {
776
- icon: c,
777
- size: l,
778
- color: r,
779
- tone: "soft"
780
- },
781
- u.class("bc-rating-input__icon-full")
782
- )
783
- ),
784
- $.click(
785
- dt((C) => w(C, F), {
786
- preventDefault: !0,
787
- stopPropagation: !0
788
- })
789
- )
790
- );
791
- return U({
792
- baseContainer: !0,
793
- growInput: !1,
794
- focusableSelector: '[role="slider"]',
795
- ...t,
796
- input: _.div(
797
- // Common input attributes (id, required, invalid, custom classes, etc.)
798
- V(t),
799
- u.class("bc-rating-input"),
800
- // ARIA slider semantics
801
- u.role("slider"),
802
- u.tabindex(p.map(n ?? !1, (f) => f ? -1 : 0)),
803
- N.disabled(n ?? !1),
804
- N.valuemin(0),
805
- N.valuemax(p.map(a, (f) => f ?? 0)),
806
- N.valuenow(p.map(e, (f) => f ?? 0)),
807
- N.valuetext(
808
- D(
809
- e,
810
- a
811
- )((f, F) => {
812
- const C = f ?? 0, k = F ?? 0;
813
- return `${String(C)} / ${String(k)}`;
814
- })
815
- ),
816
- // Keyboard & focus handlers
817
- $.keydown(x),
818
- g != null ? $.blur(g) : null,
819
- gt(a, I)
820
- )
821
- });
822
- }, $e = (t) => {
823
- const { value: e, onChange: s, onInput: n, onBlur: a, after: r, disabled: o, ...c } = t, i = X(e, o, s ?? n);
824
- return qt({
825
- ...c,
826
- // Map null -> 0 for display so the control shows as empty when null
827
- value: p.map(e, (l) => l ?? 0),
828
- // Pass through numeric changes; clear button will call onChange(null)
829
- onChange: s,
830
- onInput: n,
831
- onBlur: a,
832
- after: r != null ? E(i, r) : i
833
- });
834
- }, Me = (t) => {
835
- const { value: e, step: s, min: n, max: a, onBlur: r, onChange: o, onInput: c } = t;
836
- return U({
837
- ...t,
838
- // Make sure clicks anywhere focus the range input
839
- focusableSelector: 'input[type="range"]',
840
- input: _.input(
841
- u.type("range"),
842
- V(t),
843
- u.min(n),
844
- u.max(a),
845
- u.step(s),
846
- // Using value as number to keep it in sync
847
- u.valueAsNumber(e),
848
- u.class("bc-input bc-slider-input"),
849
- r != null ? $.blur(B(r)) : A,
850
- o != null ? $.change(B(o)) : A,
851
- c != null ? $.input(B(c)) : A
852
- )
853
- });
854
- }, Ie = (t) => {
855
- const { value: e, step: s, min: n, max: a, onBlur: r, onChange: o, onInput: c } = t, i = p.map(e, (g) => {
856
- if (g != null) return g;
857
- const m = n != null ? p.get(n) : void 0;
858
- return typeof m == "number" ? m : 0;
859
- }), l = X(
860
- e,
861
- t.disabled,
862
- o ?? c
863
- );
864
- return U(
865
- {
866
- ...t,
867
- focusableSelector: 'input[type="range"]',
868
- after: l,
869
- input: _.input(
870
- u.type("range"),
871
- V(t),
872
- u.min(n),
873
- u.max(a),
874
- u.step(s),
875
- u.valueAsNumber(i),
876
- u.class("bc-input bc-slider-input"),
877
- r != null ? $.blur(B(r)) : A,
878
- o != null ? $.change(
879
- B((g) => {
880
- o(g);
881
- })
882
- ) : A,
883
- c != null ? $.input(
884
- B((g) => {
885
- c(g);
886
- })
887
- ) : A
888
- )
889
- },
890
- // Ensure container grows input naturally
891
- E()
892
- );
893
- }, _e = O(yt), q = ["description", "comment", "notes", "text"];
894
- function Qt(t) {
895
- if (typeof t == "boolean") return q;
896
- const e = t["x:ui"];
897
- return e && Array.isArray(e.textAreaTriggers) ? [...q, ...e.textAreaTriggers] : q;
898
- }
899
- function Jt(t) {
900
- if (typeof t == "boolean") return;
901
- const e = t["x:ui"];
902
- if (e != null && (typeof e == "string" || typeof e == "object" && e !== null))
903
- return e;
904
- }
905
- function Zt(t, e) {
906
- if (typeof t == "boolean") return;
907
- const s = Jt(t);
908
- if (typeof s == "object" && typeof s.widget == "string")
909
- return {
910
- widget: s.widget,
911
- source: "explicit-widget",
912
- options: s
913
- };
914
- const n = typeof s == "string" ? s : typeof s == "object" && typeof s.format == "string" ? s.format : void 0;
915
- if (n)
916
- return {
917
- widget: n,
918
- source: "explicit-format",
919
- options: typeof s == "object" ? s : void 0
920
- };
921
- if (typeof t.format == "string")
922
- return {
923
- widget: {
924
- datetime: "date-time",
925
- base64: "binary",
926
- bytes: "binary",
927
- iri: "uri",
928
- "iri-reference": "uri-reference",
929
- "idn-hostname": "hostname"
930
- }[t.format] || t.format,
931
- source: "schema-format"
932
- };
933
- if (t.contentMediaType === "text/markdown")
934
- return {
935
- widget: "markdown",
936
- source: "schema-media"
937
- };
938
- if (t.contentMediaType != null || t.contentEncoding === "base64")
939
- return {
940
- widget: "binary",
941
- source: "schema-media",
942
- options: {
943
- mediaType: t.contentMediaType,
944
- encoding: t.contentEncoding
945
- }
946
- };
947
- if (t.enum != null)
948
- return {
949
- widget: "enum",
950
- source: "constraints"
951
- };
952
- if (t.const != null)
953
- return {
954
- widget: "const",
955
- source: "constraints"
956
- };
957
- if ((t.type === "number" || t.type === "integer" || Array.isArray(t.type) && t.type.some((r) => r === "number" || r === "integer")) && t.minimum != null && t.maximum != null)
958
- return t.maximum - t.minimum <= 5 && t.minimum >= 0 && t.minimum <= 1 && (t.multipleOf == null || t.multipleOf >= 1) ? {
959
- widget: "rating",
960
- source: "constraints",
961
- options: { max: t.maximum }
962
- } : {
963
- widget: "slider",
964
- source: "constraints",
965
- options: {
966
- min: t.minimum,
967
- max: t.maximum,
968
- step: t.multipleOf
969
- }
970
- };
971
- if (t.type === "string") {
972
- if (t.minLength != null && t.minLength > 20 || t.maxLength != null && t.maxLength > 100)
973
- return {
974
- widget: "textarea",
975
- source: "heuristics"
976
- };
977
- if (e) {
978
- const r = e.toLowerCase();
979
- if (r.includes("password") || r.includes("secret"))
980
- return { widget: "password", source: "heuristics" };
981
- if (r.includes("email"))
982
- return { widget: "email", source: "heuristics" };
983
- if (r.includes("url") || r.includes("link"))
984
- return { widget: "url", source: "heuristics" };
985
- if (r.includes("color"))
986
- return { widget: "color", source: "heuristics" };
987
- if (Qt(t).some(
988
- (c) => r.includes(c.toLowerCase())
989
- ))
990
- return { widget: "textarea", source: "heuristics" };
991
- }
992
- }
993
- }
994
- class te {
995
- widgets = /* @__PURE__ */ new Map();
996
- typeMapping = /* @__PURE__ */ new Map();
997
- // JSON Schema type -> widget names
998
- /**
999
- * Register a custom widget
1000
- */
1001
- register(e, s) {
1002
- if (this.widgets.set(e, s), s.supportedTypes)
1003
- for (const n of s.supportedTypes)
1004
- this.typeMapping.has(n) || this.typeMapping.set(n, []), this.typeMapping.get(n).push(e), this.typeMapping.get(n).sort((a, r) => {
1005
- const o = this.widgets.get(a)?.priority || 0;
1006
- return (this.widgets.get(r)?.priority || 0) - o;
1007
- });
1008
- }
1009
- /**
1010
- * Unregister a widget
1011
- */
1012
- unregister(e) {
1013
- const s = this.widgets.get(e);
1014
- if (s && (this.widgets.delete(e), s.supportedTypes))
1015
- for (const n of s.supportedTypes) {
1016
- const a = this.typeMapping.get(n);
1017
- if (a) {
1018
- const r = a.indexOf(e);
1019
- r >= 0 && a.splice(r, 1), a.length === 0 && this.typeMapping.delete(n);
1020
- }
1021
- }
1022
- }
1023
- /**
1024
- * Get a registered widget
1025
- */
1026
- get(e) {
1027
- return this.widgets.get(e);
1028
- }
1029
- /**
1030
- * Get all registered widgets
1031
- */
1032
- getAll() {
1033
- return new Map(this.widgets);
1034
- }
1035
- /**
1036
- * Get widgets that support a specific JSON Schema type
1037
- */
1038
- getForType(e) {
1039
- return (this.typeMapping.get(e) || []).map((n) => this.widgets.get(n)).filter(Boolean);
1040
- }
1041
- /**
1042
- * Find the best widget for a schema context
1043
- */
1044
- findBestWidget(e) {
1045
- const s = Zt(e.definition, e.name);
1046
- if (s?.widget) {
1047
- const a = this.widgets.get(s.widget);
1048
- if (a)
1049
- return { name: s.widget, registration: a, resolved: s };
1050
- }
1051
- const n = [];
1052
- for (const [a, r] of this.widgets.entries())
1053
- if (r.matcher)
1054
- try {
1055
- r.matcher(e) && n.push({
1056
- name: a,
1057
- registration: r,
1058
- priority: r.priority ?? 0
1059
- });
1060
- } catch (o) {
1061
- console.warn(`Error in matcher for widget "${a}":`, o);
1062
- }
1063
- if (n.length > 0) {
1064
- n.sort((r, o) => o.priority - r.priority);
1065
- const a = n[0];
1066
- return {
1067
- name: a.name,
1068
- registration: a.registration,
1069
- resolved: { widget: a.name, source: "heuristics" }
1070
- };
1071
- }
1072
- if (typeof e.definition == "object" && e.definition.type) {
1073
- const a = Array.isArray(e.definition.type) ? e.definition.type[0] : e.definition.type, r = this.getForType(a);
1074
- if (r.length > 0) {
1075
- const o = this.typeMapping.get(a)[0];
1076
- return {
1077
- name: o,
1078
- registration: r[0],
1079
- resolved: { widget: o, source: "type-fallback" }
1080
- };
1081
- }
1082
- }
1083
- return null;
1084
- }
1085
- }
1086
- const ke = new te();
1087
- function Te(t, e, s) {
1088
- return {
1089
- factory: e,
1090
- matcher: (n) => {
1091
- const r = n.definition["x:ui"];
1092
- return r === t || typeof r == "object" && r !== null && r.widget === t;
1093
- },
1094
- displayName: s?.displayName ?? t,
1095
- priority: s?.priority ?? 100,
1096
- // High priority for explicit matches
1097
- ...s
1098
- };
1099
- }
1100
- function Ce(t, e, s) {
1101
- return {
1102
- factory: e,
1103
- matcher: (n) => n.definition.format === t,
1104
- displayName: s?.displayName ?? `${t} widget`,
1105
- priority: s?.priority ?? 75,
1106
- ...s
1107
- };
1108
- }
1109
- function Fe(t, e, s, n) {
1110
- return {
1111
- factory: s,
1112
- matcher: (a) => {
1113
- const r = a.definition;
1114
- return r.type === t && r.format === e;
1115
- },
1116
- displayName: n?.displayName ?? `${t}:${e} widget`,
1117
- priority: n?.priority ?? 80,
1118
- ...n
1119
- };
1120
- }
1121
- function Ae(t) {
1122
- const e = t?.logPrefix ?? "WIDGET_DIAG", s = t?.filterFn ?? (() => !0);
1123
- return {
1124
- factory: () => null,
1125
- displayName: "Diagnostic Widget (never matches)",
1126
- priority: -1e3,
1127
- // Very low priority, should never actually match
1128
- matcher: (n) => {
1129
- if (!s(n)) return !1;
1130
- const a = n.definition, r = {
1131
- name: n.name,
1132
- path: n.path.map(String),
1133
- type: a?.type,
1134
- hasRegistry: n.widgetRegistry !== void 0,
1135
- definition: a
1136
- };
1137
- return console.log(
1138
- `[${e}] name="${r.name ?? "ROOT"}" path=[${r.path.join(", ")}] type="${r.type ?? "unknown"}" hasRegistry=${r.hasRegistry}`
1139
- ), t?.onProcess?.(r), !1;
1140
- }
1141
- };
1142
- }
1143
- export {
1144
- ie as A,
1145
- le as B,
1146
- ue as C,
1147
- Rt as D,
1148
- ge as E,
1149
- Nt as F,
1150
- Dt as G,
1151
- pt as H,
1152
- Lt as I,
1153
- Z as J,
1154
- Bt as K,
1155
- G as L,
1156
- K as M,
1157
- de as N,
1158
- Et as O,
1159
- Vt as P,
1160
- P as Q,
1161
- qt as R,
1162
- we as S,
1163
- j as T,
1164
- ke as U,
1165
- Zt as V,
1166
- Jt as W,
1167
- te as X,
1168
- Ae as Y,
1169
- ut as a,
1170
- St as b,
1171
- Ce as c,
1172
- Fe as d,
1173
- at as e,
1174
- Te as f,
1175
- Ut as g,
1176
- Wt as h,
1177
- ce as i,
1178
- he as j,
1179
- me as k,
1180
- be as l,
1181
- ye as m,
1182
- Yt as n,
1183
- fe as o,
1184
- xe as p,
1185
- $e as q,
1186
- Me as r,
1187
- Ie as s,
1188
- _e as t,
1189
- pe as u,
1190
- Ft as v,
1191
- At as w,
1192
- vt as x,
1193
- J as y,
1194
- H as z
1195
- };