@opencxh/ui-kit 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/README.md +261 -0
  2. package/dist/index.d.ts +2 -0
  3. package/dist/index.js +3076 -0
  4. package/dist/index.js.map +1 -0
  5. package/dist/index.umd.cjs +2 -0
  6. package/dist/index.umd.cjs.map +1 -0
  7. package/dist/src/action/Button.d.ts +50 -0
  8. package/dist/src/action/ButtonGroup.d.ts +17 -0
  9. package/dist/src/action/Link.d.ts +21 -0
  10. package/dist/src/command-palette/CommandPalette.d.ts +22 -0
  11. package/dist/src/command-palette/index.d.ts +2 -0
  12. package/dist/src/content/Icon.d.ts +21 -0
  13. package/dist/src/content/Image.d.ts +29 -0
  14. package/dist/src/content/PageHeader.d.ts +43 -0
  15. package/dist/src/content/Table.d.ts +108 -0
  16. package/dist/src/feedback/Badge.d.ts +48 -0
  17. package/dist/src/feedback/ContentLoading.d.ts +21 -0
  18. package/dist/src/feedback/Spinner.d.ts +32 -0
  19. package/dist/src/forms/Form.d.ts +119 -0
  20. package/dist/src/index.d.ts +28 -0
  21. package/dist/src/input/Checkbox.d.ts +55 -0
  22. package/dist/src/input/DatePicker.d.ts +26 -0
  23. package/dist/src/input/Select.d.ts +89 -0
  24. package/dist/src/input/TextArea.d.ts +39 -0
  25. package/dist/src/input/TextField.d.ts +68 -0
  26. package/dist/src/navigation/Sidebar.d.ts +17 -0
  27. package/dist/src/navigation/Tabs.d.ts +59 -0
  28. package/dist/src/overlays/Dropdown.d.ts +41 -0
  29. package/dist/src/overlays/Modal.d.ts +82 -0
  30. package/dist/src/primitives/Box.d.ts +47 -0
  31. package/dist/src/primitives/Card.d.ts +6 -0
  32. package/dist/src/typography/Heading.d.ts +23 -0
  33. package/dist/src/typography/List.d.ts +31 -0
  34. package/dist/src/typography/Text.d.ts +31 -0
  35. package/dist/src/utils/cn.d.ts +14 -0
  36. package/dist/vite.config.d.ts +2 -0
  37. package/package.json +62 -0
package/dist/index.js ADDED
@@ -0,0 +1,3076 @@
1
+ import { clsx as ve } from "clsx";
2
+ import { jsxs as c, jsx as e, Fragment as ke } from "react/jsx-runtime";
3
+ import ce, { forwardRef as de, useState as q, useRef as re, useEffect as K, useCallback as ee, useMemo as ie, createContext as Ne } from "react";
4
+ import { ArrowLeft as we, ChevronDownIcon as Ce, ChevronRight as Se } from "lucide-react";
5
+ function p(...r) {
6
+ return ve(r);
7
+ }
8
+ function fr(r) {
9
+ return (n, a) => {
10
+ var t;
11
+ return ((t = r[n]) == null ? void 0 : t[a]) || "";
12
+ };
13
+ }
14
+ function pr(r) {
15
+ return (n) => r[n] || "";
16
+ }
17
+ const Me = {
18
+ primary: "btn o__primary",
19
+ secondary: "btn o__secondary",
20
+ outline: "btn o__secondary",
21
+ ghost: "btn text-gray-700",
22
+ destructive: "btn o__destructive"
23
+ }, Le = {
24
+ xs: "px-2 py-1 text-xs",
25
+ sm: "px-3 py-1.5 text-sm",
26
+ md: "px-4 py-2 text-sm",
27
+ lg: "px-6 py-3 text-base",
28
+ xl: "px-8 py-4 text-lg",
29
+ full: "px-4 py-3 text-base"
30
+ }, De = {
31
+ xs: "p-1",
32
+ sm: "p-1.5",
33
+ md: "p-2",
34
+ lg: "p-3",
35
+ xl: "p-4",
36
+ full: "p-4"
37
+ }, te = de(
38
+ ({
39
+ variant: r = "primary",
40
+ size: n = "md",
41
+ fullWidth: a = !1,
42
+ loading: t = !1,
43
+ leftIcon: s,
44
+ rightIcon: o,
45
+ iconOnly: g = !1,
46
+ className: x,
47
+ children: f,
48
+ disabled: i,
49
+ ...w
50
+ }, d) => {
51
+ const u = i || t;
52
+ return /* @__PURE__ */ c(
53
+ "button",
54
+ {
55
+ ref: d,
56
+ className: p(
57
+ // Base styles
58
+ "inline-flex items-center justify-center font-medium rounded-lg transition-colors duration-200",
59
+ "focus:outline-none focus:ring-1 focus:ring-offset-1",
60
+ "disabled:opacity-50 disabled:cursor-not-allowed",
61
+ // Variant styles
62
+ Me[r],
63
+ // Size styles
64
+ g ? De[n] : Le[n],
65
+ // Full width
66
+ a && "w-full",
67
+ // Loading state
68
+ t && "cursor-wait",
69
+ x
70
+ ),
71
+ disabled: u,
72
+ ...w,
73
+ children: [
74
+ t && /* @__PURE__ */ c(
75
+ "svg",
76
+ {
77
+ className: p(
78
+ "animate-spin",
79
+ g ? "h-4 w-4" : "h-4 w-4 mr-2"
80
+ ),
81
+ fill: "none",
82
+ viewBox: "0 0 24 24",
83
+ children: [
84
+ /* @__PURE__ */ e(
85
+ "circle",
86
+ {
87
+ className: "opacity-25",
88
+ cx: "12",
89
+ cy: "12",
90
+ r: "10",
91
+ stroke: "currentColor",
92
+ strokeWidth: "4"
93
+ }
94
+ ),
95
+ /* @__PURE__ */ e(
96
+ "path",
97
+ {
98
+ className: "opacity-75",
99
+ fill: "currentColor",
100
+ d: "M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"
101
+ }
102
+ )
103
+ ]
104
+ }
105
+ ),
106
+ !t && s && /* @__PURE__ */ e("span", { className: p("flex-shrink-0", !g && "mr-2"), children: s }),
107
+ !g && f,
108
+ !t && o && /* @__PURE__ */ e("span", { className: p("flex-shrink-0", !g && "ml-2"), children: o }),
109
+ g && !t && !s && !o && f
110
+ ]
111
+ }
112
+ );
113
+ }
114
+ );
115
+ te.displayName = "Button";
116
+ const gr = ({
117
+ children: r,
118
+ size: n = "md",
119
+ orientation: a = "horizontal",
120
+ attached: t = !0,
121
+ className: s
122
+ }) => {
123
+ const o = p(
124
+ "inline-flex",
125
+ {
126
+ // Orientation
127
+ "flex-row": a === "horizontal",
128
+ "flex-col": a === "vertical",
129
+ // Attached styling
130
+ "[&>*:not(:first-child):not(:last-child)]:rounded-none": t,
131
+ "[&>*:first-child]:rounded-r-none": t && a === "horizontal",
132
+ "[&>*:last-child]:rounded-l-none": t && a === "horizontal",
133
+ "[&>*:first-child]:rounded-b-none": t && a === "vertical",
134
+ "[&>*:last-child]:rounded-t-none": t && a === "vertical",
135
+ // Borders for attached buttons
136
+ "[&>*:not(:first-child)]:-ml-px": t && a === "horizontal",
137
+ "[&>*:not(:first-child)]:-mt-px": t && a === "vertical",
138
+ // Spacing for non-attached buttons
139
+ "gap-1": !t && n === "xs",
140
+ "gap-2": !t && (n === "sm" || n === "md"),
141
+ "gap-3": !t && (n === "lg" || n === "xl")
142
+ },
143
+ s
144
+ );
145
+ return /* @__PURE__ */ e("div", { className: o, role: "group", children: r });
146
+ }, br = ({
147
+ variant: r = "default",
148
+ size: n = "md",
149
+ color: a = "primary",
150
+ disabled: t = !1,
151
+ external: s = !1,
152
+ className: o,
153
+ children: g,
154
+ href: x,
155
+ target: f,
156
+ rel: i,
157
+ ...w
158
+ }) => {
159
+ const d = s || x && (x.startsWith("http") || x.startsWith("mailto:")), u = p(
160
+ // Base styles
161
+ "inline-flex items-center gap-1 transition-colors duration-200 focus:outline-none focus:ring-2 focus:ring-offset-2",
162
+ // Size variants
163
+ {
164
+ "text-xs": n === "xs",
165
+ "text-sm": n === "sm",
166
+ "text-base": n === "md",
167
+ "text-lg": n === "lg",
168
+ "text-xl": n === "xl"
169
+ },
170
+ // Color variants
171
+ {
172
+ // Primary
173
+ "text-primary hover:text-primary/80 focus:ring-primary/20": a === "primary" && !t,
174
+ // Secondary
175
+ "text-secondary hover:text-secondary/80 focus:ring-secondary/20": a === "secondary" && !t,
176
+ // Accent
177
+ "text-accent hover:text-accent/80 focus:ring-accent/20": a === "accent" && !t,
178
+ // Success
179
+ "text-success hover:text-success/80 focus:ring-success/20": a === "success" && !t,
180
+ // Warning
181
+ "text-warning hover:text-warning/80 focus:ring-warning/20": a === "warning" && !t,
182
+ // Error
183
+ "text-error hover:text-error/80 focus:ring-error/20": a === "error" && !t,
184
+ // Info
185
+ "text-info hover:text-info/80 focus:ring-info/20": a === "info" && !t,
186
+ // Neutral
187
+ "text-neutral hover:text-neutral/80 focus:ring-neutral/20": a === "neutral" && !t
188
+ },
189
+ // Variant styles
190
+ {
191
+ // Default - just colored text
192
+ "": r === "default",
193
+ // Subtle - muted colors
194
+ "text-opacity-70 hover:text-opacity-100": r === "subtle",
195
+ // Underline - always underlined
196
+ "underline underline-offset-2 decoration-1 hover:decoration-2": r === "underline",
197
+ // Button - looks like a button
198
+ "px-3 py-1.5 rounded-md bg-opacity-10 hover:bg-opacity-20": r === "button",
199
+ "bg-primary": r === "button" && a === "primary",
200
+ "bg-secondary": r === "button" && a === "secondary",
201
+ "bg-accent": r === "button" && a === "accent",
202
+ "bg-success": r === "button" && a === "success",
203
+ "bg-warning": r === "button" && a === "warning",
204
+ "bg-error": r === "button" && a === "error",
205
+ "bg-info": r === "button" && a === "info",
206
+ "bg-neutral": r === "button" && a === "neutral"
207
+ },
208
+ // Disabled state
209
+ {
210
+ "opacity-50 cursor-not-allowed pointer-events-none": t
211
+ },
212
+ o
213
+ ), k = {
214
+ ...w,
215
+ href: t ? void 0 : x,
216
+ target: d ? "_blank" : f,
217
+ rel: d ? "noopener noreferrer" : i
218
+ };
219
+ return /* @__PURE__ */ c("a", { className: u, ...k, children: [
220
+ g,
221
+ d && /* @__PURE__ */ e(
222
+ "svg",
223
+ {
224
+ className: "w-3 h-3 ml-1",
225
+ fill: "none",
226
+ stroke: "currentColor",
227
+ viewBox: "0 0 24 24",
228
+ "aria-hidden": "true",
229
+ children: /* @__PURE__ */ e(
230
+ "path",
231
+ {
232
+ strokeLinecap: "round",
233
+ strokeLinejoin: "round",
234
+ strokeWidth: 2,
235
+ d: "M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"
236
+ }
237
+ )
238
+ }
239
+ )
240
+ ] });
241
+ }, Ee = {
242
+ sm: "h-4 w-4",
243
+ md: "h-5 w-5",
244
+ lg: "h-6 w-6",
245
+ full: "h-6 w-6"
246
+ }, Ae = {
247
+ sm: "text-sm",
248
+ md: "text-sm",
249
+ lg: "text-base",
250
+ full: "text-base"
251
+ }, me = de(
252
+ ({
253
+ label: r,
254
+ helperText: n,
255
+ error: a,
256
+ size: t = "md",
257
+ indeterminate: s = !1,
258
+ containerClassName: o,
259
+ labelClassName: g,
260
+ className: x,
261
+ id: f,
262
+ ...i
263
+ }, w) => {
264
+ const d = f || `checkbox-${Math.random().toString(36).substr(2, 9)}`, u = !!a;
265
+ return ce.useEffect(() => {
266
+ w && typeof w == "object" && w.current && (w.current.indeterminate = s);
267
+ }, [s, w]), /* @__PURE__ */ c("div", { className: p("flex flex-col", o), children: [
268
+ /* @__PURE__ */ c("div", { className: "flex items-start", children: [
269
+ /* @__PURE__ */ e("div", { className: "flex items-center h-5", children: /* @__PURE__ */ e(
270
+ "input",
271
+ {
272
+ ref: w,
273
+ id: d,
274
+ type: "checkbox",
275
+ className: p(
276
+ // Base styles
277
+ "rounded border transition-colors duration-200",
278
+ "focus:ring-2 focus:ring-offset-2 focus:outline-none",
279
+ "disabled:opacity-50 disabled:cursor-not-allowed",
280
+ // Size styles
281
+ Ee[t],
282
+ // State styles
283
+ u ? "border-error text-error focus:border-error focus:ring-error" : "border-gray-100 text-primary focus:border-primary focus:ring-primary dark:border-gray-600 dark:bg-secondary-800",
284
+ x
285
+ ),
286
+ ...i
287
+ }
288
+ ) }),
289
+ r && /* @__PURE__ */ c("div", { className: "ml-3 flex-1", children: [
290
+ /* @__PURE__ */ e(
291
+ "label",
292
+ {
293
+ htmlFor: d,
294
+ className: p(
295
+ "font-medium cursor-pointer",
296
+ u ? "text-error" : "text-secondary-900 dark:text-secondary-100",
297
+ Ae[t],
298
+ g
299
+ ),
300
+ children: r
301
+ }
302
+ ),
303
+ n && !a && /* @__PURE__ */ e("p", { className: "mt-1 text-xs text-secondary-500 dark:text-secondary-400", children: n })
304
+ ] })
305
+ ] }),
306
+ a && /* @__PURE__ */ e("p", { className: "mt-1 text-xs text-error", children: a })
307
+ ] });
308
+ }
309
+ );
310
+ me.displayName = "Checkbox";
311
+ const $e = () => /* @__PURE__ */ e("svg", { className: "h-4 w-4", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ e("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z" }) }), je = () => /* @__PURE__ */ e("svg", { className: "h-4 w-4", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ e("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "m15 18-6-6 6-6" }) }), Te = () => /* @__PURE__ */ e("svg", { className: "h-4 w-4", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ e("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "m9 18 6-6-6-6" }) }), he = de(({
312
+ value: r,
313
+ onChange: n,
314
+ placeholder: a = "Select date",
315
+ disabled: t = !1,
316
+ required: s = !1,
317
+ size: o = "md",
318
+ className: g,
319
+ minDate: x,
320
+ maxDate: f,
321
+ format: i = "MM/dd/yyyy"
322
+ }, w) => {
323
+ const [d, u] = q(!1), [k, b] = q(() => r || /* @__PURE__ */ new Date()), C = re(null);
324
+ K(() => {
325
+ const S = (y) => {
326
+ C.current && !C.current.contains(y.target) && u(!1);
327
+ };
328
+ return d && document.addEventListener("mousedown", S), () => {
329
+ document.removeEventListener("mousedown", S);
330
+ };
331
+ }, [d]);
332
+ const M = (S) => {
333
+ if (!S) return "";
334
+ const y = S.getDate().toString().padStart(2, "0"), l = (S.getMonth() + 1).toString().padStart(2, "0"), v = S.getFullYear();
335
+ switch (i) {
336
+ case "dd/MM/yyyy":
337
+ return `${y}/${l}/${v}`;
338
+ case "yyyy-MM-dd":
339
+ return `${v}-${l}-${y}`;
340
+ case "MM/dd/yyyy":
341
+ default:
342
+ return `${l}/${y}/${v}`;
343
+ }
344
+ }, V = () => {
345
+ const S = k.getFullYear(), y = k.getMonth(), l = new Date(S, y, 1), v = new Date(l);
346
+ v.setDate(v.getDate() - l.getDay());
347
+ const N = [], h = new Date(v);
348
+ for (let A = 0; A < 42; A++)
349
+ N.push(new Date(h)), h.setDate(h.getDate() + 1);
350
+ return N;
351
+ }, $ = (S) => {
352
+ S.getMonth() === k.getMonth() && (x && S < x || f && S > f || (n == null || n(S), u(!1)));
353
+ }, J = () => {
354
+ b(new Date(k.getFullYear(), k.getMonth() - 1, 1));
355
+ }, H = () => {
356
+ b(new Date(k.getFullYear(), k.getMonth() + 1, 1));
357
+ }, z = () => {
358
+ n == null || n(null), u(!1);
359
+ }, I = p(
360
+ "w-full border border-neutral-100 dark:border-neutral-600 rounded-md transition-colors duration-200",
361
+ "bg-white dark:bg-neutral-800 text-gray-700 dark:text-gray-300",
362
+ "placeholder:text-gray-800 dark:placeholder:text-gray-500",
363
+ "focus:outline-none focus:ring-2 focus:ring-primary/20 focus:border-primary",
364
+ "disabled:opacity-50 disabled:cursor-not-allowed disabled:bg-neutral-50 dark:disabled:bg-neutral-900",
365
+ {
366
+ "px-3 py-2 text-sm": o === "sm",
367
+ "px-3 py-2 text-base": o === "md",
368
+ "px-4 py-3 text-lg": o === "lg",
369
+ "px-4 py-3 text-base": o === "full"
370
+ },
371
+ g
372
+ ), P = V(), G = [
373
+ "January",
374
+ "February",
375
+ "March",
376
+ "April",
377
+ "May",
378
+ "June",
379
+ "July",
380
+ "August",
381
+ "September",
382
+ "October",
383
+ "November",
384
+ "December"
385
+ ];
386
+ return /* @__PURE__ */ c("div", { ref: C, className: "relative", children: [
387
+ /* @__PURE__ */ c("div", { className: "relative", children: [
388
+ /* @__PURE__ */ e(
389
+ "input",
390
+ {
391
+ ref: w,
392
+ type: "text",
393
+ value: M(r ?? null),
394
+ placeholder: a,
395
+ disabled: t,
396
+ required: s,
397
+ readOnly: !0,
398
+ onClick: () => !t && u(!d),
399
+ className: p(I, "pr-10 cursor-pointer")
400
+ }
401
+ ),
402
+ /* @__PURE__ */ e(
403
+ "button",
404
+ {
405
+ type: "button",
406
+ onClick: () => !t && u(!d),
407
+ disabled: t,
408
+ className: "absolute inset-y-0 right-0 flex items-center pr-3 text-neutral-400 hover:text-neutral-600 dark:hover:text-neutral-300",
409
+ children: /* @__PURE__ */ e($e, {})
410
+ }
411
+ )
412
+ ] }),
413
+ d && /* @__PURE__ */ c("div", { className: "absolute z-50 mt-1 bg-white dark:bg-neutral-800 border border-neutral-100 dark:border-neutral-600 rounded-md shadow-lg p-4 min-w-[280px]", children: [
414
+ /* @__PURE__ */ c("div", { className: "flex items-center justify-between mb-4", children: [
415
+ /* @__PURE__ */ e(
416
+ "button",
417
+ {
418
+ onClick: J,
419
+ className: "p-1 hover:bg-neutral-100 dark:hover:bg-neutral-700 rounded",
420
+ children: /* @__PURE__ */ e(je, {})
421
+ }
422
+ ),
423
+ /* @__PURE__ */ c("h3", { className: "text-sm font-medium text-neutral-900 dark:text-neutral-100", children: [
424
+ G[k.getMonth()],
425
+ " ",
426
+ k.getFullYear()
427
+ ] }),
428
+ /* @__PURE__ */ e(
429
+ "button",
430
+ {
431
+ onClick: H,
432
+ className: "p-1 hover:bg-neutral-100 dark:hover:bg-neutral-700 rounded",
433
+ children: /* @__PURE__ */ e(Te, {})
434
+ }
435
+ )
436
+ ] }),
437
+ /* @__PURE__ */ e("div", { className: "grid grid-cols-7 gap-1 mb-2", children: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"].map((S) => /* @__PURE__ */ e("div", { className: "text-xs font-medium text-neutral-500 dark:text-neutral-400 text-center py-1", children: S }, S)) }),
438
+ /* @__PURE__ */ e("div", { className: "grid grid-cols-7 gap-1", children: P.map((S, y) => {
439
+ const l = S.getMonth() === k.getMonth(), v = r && S.toDateString() === r.toDateString(), N = S.toDateString() === (/* @__PURE__ */ new Date()).toDateString(), h = !l || x && S < x || f && S > f;
440
+ return /* @__PURE__ */ e(
441
+ "button",
442
+ {
443
+ onClick: () => !h && $(S),
444
+ disabled: h,
445
+ className: p(
446
+ "w-8 h-8 text-sm rounded transition-colors duration-200",
447
+ {
448
+ "text-neutral-900 dark:text-neutral-100 hover:bg-neutral-100 dark:hover:bg-neutral-700": l && !v && !h,
449
+ "bg-primary text-white": v,
450
+ "bg-neutral-100 dark:bg-neutral-700 text-neutral-900 dark:text-neutral-100": N && !v,
451
+ "text-neutral-300 dark:text-neutral-600 cursor-not-allowed": h
452
+ }
453
+ ),
454
+ children: S.getDate()
455
+ },
456
+ y
457
+ );
458
+ }) }),
459
+ /* @__PURE__ */ c("div", { className: "flex justify-between items-center mt-4 pt-3 border-t border-neutral-200 dark:border-neutral-700", children: [
460
+ /* @__PURE__ */ e(
461
+ "button",
462
+ {
463
+ onClick: z,
464
+ className: "text-sm text-neutral-500 hover:text-neutral-700 dark:text-neutral-400 dark:hover:text-neutral-300",
465
+ children: "Clear"
466
+ }
467
+ ),
468
+ /* @__PURE__ */ e(
469
+ "button",
470
+ {
471
+ onClick: () => u(!1),
472
+ className: "text-sm text-primary hover:text-primary/80",
473
+ children: "Close"
474
+ }
475
+ )
476
+ ] })
477
+ ] })
478
+ ] });
479
+ }), Ie = {
480
+ sm: "px-3 py-1.5 text-sm",
481
+ md: "px-3 py-2 text-sm",
482
+ lg: "px-3 py-2 text-sm",
483
+ full: "px-3 py-2 text-sm"
484
+ }, xe = de(
485
+ ({
486
+ label: r,
487
+ helperText: n,
488
+ error: a,
489
+ size: t = "md",
490
+ fullWidth: s = !1,
491
+ options: o,
492
+ placeholder: g,
493
+ containerClassName: x,
494
+ labelClassName: f,
495
+ className: i,
496
+ id: w,
497
+ searchable: d,
498
+ multiple: u,
499
+ value: k,
500
+ onChange: b,
501
+ ...C
502
+ }, M) => {
503
+ const V = w || `select-${Math.random().toString(36).substr(2, 9)}`, $ = !!a, [J, H] = ce.useState(!1), [z, I] = ce.useState(""), P = ce.useRef(null);
504
+ ce.useImperativeHandle(M, () => P.current), ce.useEffect(() => {
505
+ const N = (h) => {
506
+ P.current && !P.current.contains(h.target) && H(!1);
507
+ };
508
+ return document.addEventListener("mousedown", N), () => {
509
+ document.removeEventListener("mousedown", N);
510
+ };
511
+ }, []);
512
+ const G = (N) => {
513
+ if (u) {
514
+ const h = Array.isArray(k) ? k : [], A = h.includes(N) ? h.filter((_) => _ !== N) : [...h, N];
515
+ b == null || b(A);
516
+ } else
517
+ b == null || b(N), H(!1), I("");
518
+ }, S = u ? null : o.find((N) => N.value === k), y = u ? o.filter((N) => Array.isArray(k) && k.includes(N.value)) : [], l = d && z ? o.filter(
519
+ (N) => N.label.toLowerCase().includes(z.toLowerCase())
520
+ ) : o, v = () => u ? y.length > 0 ? y.map((N) => N.label).join(", ") : g || "Select options" : (S == null ? void 0 : S.label) || g || "Select an option";
521
+ return /* @__PURE__ */ c(
522
+ "div",
523
+ {
524
+ ref: P,
525
+ className: p(
526
+ "relative flex flex-col",
527
+ s && "w-full",
528
+ x
529
+ ),
530
+ ...C,
531
+ children: [
532
+ r && /* @__PURE__ */ e(
533
+ "label",
534
+ {
535
+ htmlFor: V,
536
+ onClick: () => H(!J),
537
+ className: p(
538
+ "block text-sm font-medium mb-1",
539
+ $ ? "text-error" : "text-secondary-700 dark:text-secondary-300",
540
+ f
541
+ ),
542
+ children: r
543
+ }
544
+ ),
545
+ /* @__PURE__ */ c("div", { className: "relative", children: [
546
+ /* @__PURE__ */ e(
547
+ "button",
548
+ {
549
+ type: "button",
550
+ id: V,
551
+ onClick: () => H(!J),
552
+ className: p(
553
+ // Base styles
554
+ "block w-full rounded-lg border transition-colors duration-200 text-left",
555
+ "focus:outline-none focus:ring-0 focus:ring-offset-0",
556
+ "disabled:opacity-50 disabled:cursor-not-allowed",
557
+ "bg-white dark:bg-secondary-800",
558
+ // Size styles
559
+ Ie[t],
560
+ // State styles
561
+ $ ? "border-error text-error focus:border-error focus:ring-error" : "border-gray-100 text-secondary-900 focus:border-primary focus:ring-primary dark:border-gray-600 dark:bg-secondary-800 dark:text-secondary-100",
562
+ i
563
+ ),
564
+ children: /* @__PURE__ */ e("span", { className: "block truncate", children: v() })
565
+ }
566
+ ),
567
+ J && /* @__PURE__ */ c("div", { className: "absolute z-10 mt-1 w-full rounded-md bg-white dark:bg-secondary-800 shadow-lg border dark:border-gray-600", children: [
568
+ d && /* @__PURE__ */ e("div", { className: "p-2", children: /* @__PURE__ */ e(
569
+ "input",
570
+ {
571
+ type: "text",
572
+ placeholder: "Search...",
573
+ value: z,
574
+ onChange: (N) => I(N.target.value),
575
+ className: p(
576
+ "w-full px-3 py-2 text-sm rounded-md border",
577
+ "text-secondary-900 border-gray-100 dark:border-gray-600 focus:outline-none focus:ring-0"
578
+ )
579
+ }
580
+ ) }),
581
+ /* @__PURE__ */ c("ul", { className: "max-h-60 overflow-auto py-1", children: [
582
+ g && !u && /* @__PURE__ */ e(
583
+ "li",
584
+ {
585
+ className: "px-4 py-2 text-sm text-secondary-500",
586
+ onClick: () => {
587
+ b == null || b(""), H(!1);
588
+ },
589
+ children: g
590
+ }
591
+ ),
592
+ l.map((N) => {
593
+ const h = u ? Array.isArray(k) && k.includes(N.value) : k === N.value;
594
+ return /* @__PURE__ */ e(
595
+ "li",
596
+ {
597
+ onClick: () => !N.disabled && G(N.value),
598
+ className: p(
599
+ "px-4 py-2 text-sm cursor-pointer",
600
+ "text-secondary-900 dark:text-secondary-100",
601
+ N.disabled ? "opacity-50 cursor-not-allowed" : "hover:bg-gray-100 dark:hover:bg-secondary-700",
602
+ h && "font-semibold"
603
+ ),
604
+ children: /* @__PURE__ */ c("div", { className: "flex items-center", children: [
605
+ u && /* @__PURE__ */ e(
606
+ "input",
607
+ {
608
+ type: "checkbox",
609
+ checked: h,
610
+ readOnly: !0,
611
+ className: "mr-3 h-4 w-4 rounded border-gray-300 text-primary focus:ring-primary"
612
+ }
613
+ ),
614
+ /* @__PURE__ */ e("span", { children: N.label })
615
+ ] })
616
+ },
617
+ N.value
618
+ );
619
+ })
620
+ ] })
621
+ ] })
622
+ ] }),
623
+ (a || n) && /* @__PURE__ */ e(
624
+ "p",
625
+ {
626
+ className: p(
627
+ "mt-1 text-xs",
628
+ $ ? "text-error" : "text-secondary-500"
629
+ ),
630
+ children: a || n
631
+ }
632
+ )
633
+ ]
634
+ }
635
+ );
636
+ }
637
+ );
638
+ xe.displayName = "Select";
639
+ const Pe = {
640
+ sm: "px-3 py-1.5 text-sm",
641
+ md: "px-3 py-2 text-sm",
642
+ lg: "px-4 py-3 text-base",
643
+ full: "px-4 py-3 text-base"
644
+ }, fe = de(
645
+ ({
646
+ label: r,
647
+ helperText: n,
648
+ error: a,
649
+ size: t = "md",
650
+ fullWidth: s = !1,
651
+ loading: o = !1,
652
+ containerClassName: g,
653
+ labelClassName: x,
654
+ className: f,
655
+ id: i,
656
+ rows: w = 4,
657
+ ...d
658
+ }, u) => {
659
+ const k = i || `textarea-${Math.random().toString(36).substr(2, 9)}`, b = !!a;
660
+ return /* @__PURE__ */ c("div", { className: p("flex flex-col", s && "w-full", g), children: [
661
+ r && /* @__PURE__ */ e(
662
+ "label",
663
+ {
664
+ htmlFor: k,
665
+ className: p(
666
+ "block text-sm font-medium mb-1",
667
+ b ? "text-error" : "text-secondary-700 dark:text-secondary-300",
668
+ x
669
+ ),
670
+ children: r
671
+ }
672
+ ),
673
+ /* @__PURE__ */ c("div", { className: "relative", children: [
674
+ /* @__PURE__ */ e(
675
+ "textarea",
676
+ {
677
+ ref: u,
678
+ id: k,
679
+ rows: w,
680
+ className: p(
681
+ // Base styles
682
+ "block w-full rounded-lg border transition-colors duration-200 resize-vertical",
683
+ "placeholder-secondary-400 focus:outline-none focus:ring-0",
684
+ "disabled:opacity-50 disabled:cursor-not-allowed",
685
+ // Size styles
686
+ Pe[t],
687
+ // State styles
688
+ b ? "border-error text-error focus:border-error focus:ring-error" : "border-gray-100 text-secondary-900 dark:border-gray-600 dark:bg-secondary-800 dark:text-secondary-100",
689
+ f
690
+ ),
691
+ ...d
692
+ }
693
+ ),
694
+ o && /* @__PURE__ */ e("div", { className: "absolute top-3 right-3", children: /* @__PURE__ */ c(
695
+ "svg",
696
+ {
697
+ className: "animate-spin h-4 w-4 text-secondary-400",
698
+ fill: "none",
699
+ viewBox: "0 0 24 24",
700
+ children: [
701
+ /* @__PURE__ */ e(
702
+ "circle",
703
+ {
704
+ className: "opacity-25",
705
+ cx: "12",
706
+ cy: "12",
707
+ r: "10",
708
+ stroke: "currentColor",
709
+ strokeWidth: "4"
710
+ }
711
+ ),
712
+ /* @__PURE__ */ e(
713
+ "path",
714
+ {
715
+ className: "opacity-75",
716
+ fill: "currentColor",
717
+ d: "M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"
718
+ }
719
+ )
720
+ ]
721
+ }
722
+ ) })
723
+ ] }),
724
+ (a || n) && /* @__PURE__ */ e(
725
+ "p",
726
+ {
727
+ className: p(
728
+ "mt-1 text-xs",
729
+ b ? "text-error" : "text-secondary-500"
730
+ ),
731
+ children: a || n
732
+ }
733
+ )
734
+ ] });
735
+ }
736
+ );
737
+ fe.displayName = "TextArea";
738
+ const _e = {
739
+ sm: "px-3 py-1.5 text-sm",
740
+ md: "px-3 py-2 text-sm",
741
+ lg: "px-3 py-2 text-sm",
742
+ full: "px-3 py-2 text-sm"
743
+ }, ue = {
744
+ sm: "h-4 w-4",
745
+ md: "h-5 w-5",
746
+ lg: "h-6 w-6",
747
+ full: "h-6 w-6"
748
+ }, oe = de(
749
+ ({
750
+ label: r,
751
+ helperText: n,
752
+ error: a,
753
+ size: t = "md",
754
+ fullWidth: s = !1,
755
+ startIcon: o,
756
+ endIcon: g,
757
+ loading: x = !1,
758
+ containerClassName: f,
759
+ labelClassName: i,
760
+ className: w,
761
+ id: d,
762
+ ...u
763
+ }, k) => {
764
+ const b = d || `textfield-${Math.random().toString(36).substr(2, 9)}`, C = !!a;
765
+ return /* @__PURE__ */ c("div", { className: p("flex flex-col", s && "w-full", f), children: [
766
+ r && /* @__PURE__ */ e(
767
+ "label",
768
+ {
769
+ htmlFor: b,
770
+ className: p(
771
+ "block text-sm font-medium mb-1",
772
+ C ? "text-error" : "text-secondary-700 dark:text-secondary-300",
773
+ i
774
+ ),
775
+ children: r
776
+ }
777
+ ),
778
+ /* @__PURE__ */ c("div", { className: "relative", children: [
779
+ o && // Todo fix inset not showing correctly on different sizes
780
+ /* @__PURE__ */ e("div", { className: "absolute left-0 pl-3 flex items-center pointer-events-none h-full", children: /* @__PURE__ */ e("span", { className: p("text-secondary-400", ue[t]), children: o }) }),
781
+ /* @__PURE__ */ e(
782
+ "input",
783
+ {
784
+ ref: k,
785
+ id: b,
786
+ className: p(
787
+ // Base styles
788
+ "block w-full rounded-lg border dark:border-gray-600 transition-colors duration-200",
789
+ "placeholder-gray-500 dark:placeholder-gray-500 focus:outline-none focus:ring-1 focus:ring-offset-0",
790
+ "disabled:opacity-50 disabled:cursor-not-allowed",
791
+ // Size styles
792
+ _e[t],
793
+ // Icon padding
794
+ o && "pl-10",
795
+ g && "pr-10",
796
+ // State styles
797
+ C ? "border-error text-error focus:border-error focus:ring-error" : "border-gray-100 text-secondary-900 focus:border-primary focus:ring-primary dark:border-gray-600 dark:bg-secondary-800 dark:text-secondary-100",
798
+ w
799
+ ),
800
+ ...u
801
+ }
802
+ ),
803
+ (g || x) && /* @__PURE__ */ e("div", { className: "absolute inset-y-0 right-0 pr-3 flex items-center", children: x ? /* @__PURE__ */ c(
804
+ "svg",
805
+ {
806
+ className: p("animate-spin text-secondary-400", ue[t]),
807
+ fill: "none",
808
+ viewBox: "0 0 24 24",
809
+ children: [
810
+ /* @__PURE__ */ e(
811
+ "circle",
812
+ {
813
+ className: "opacity-25",
814
+ cx: "12",
815
+ cy: "12",
816
+ r: "10",
817
+ stroke: "currentColor",
818
+ strokeWidth: "4"
819
+ }
820
+ ),
821
+ /* @__PURE__ */ e(
822
+ "path",
823
+ {
824
+ className: "opacity-75",
825
+ fill: "currentColor",
826
+ d: "M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"
827
+ }
828
+ )
829
+ ]
830
+ }
831
+ ) : g && /* @__PURE__ */ e("span", { className: p("text-secondary-400", ue[t]), children: g }) })
832
+ ] }),
833
+ (a || n) && /* @__PURE__ */ e(
834
+ "p",
835
+ {
836
+ className: p(
837
+ "mt-1 text-xs",
838
+ C ? "text-error" : "text-secondary-500"
839
+ ),
840
+ children: a || n
841
+ }
842
+ )
843
+ ] });
844
+ }
845
+ );
846
+ oe.displayName = "TextField";
847
+ const le = ({
848
+ variant: r = "body",
849
+ size: n = "md",
850
+ weight: a = "normal",
851
+ color: t = "current",
852
+ align: s = "left",
853
+ truncate: o = !1,
854
+ italic: g = !1,
855
+ underline: x = !1,
856
+ lineHeight: f = "normal",
857
+ as: i,
858
+ className: w,
859
+ children: d,
860
+ ...u
861
+ }) => {
862
+ const k = i || Be(r), b = p(
863
+ // Base styles
864
+ "font-primary",
865
+ // Variant styles
866
+ {
867
+ "leading-relaxed": r === "body",
868
+ "text-sm leading-tight": r === "caption",
869
+ "text-sm font-medium leading-none": r === "label",
870
+ "font-mono text-sm bg-neutral-100 dark:bg-neutral-800 px-1 py-0.5 rounded": r === "code"
871
+ },
872
+ // Size variants (override variant sizes)
873
+ r !== "code" && {
874
+ "text-xs": n === "xs",
875
+ "text-sm": n === "sm",
876
+ "text-base": n === "md",
877
+ "text-lg": n === "lg",
878
+ "text-xl": n === "xl"
879
+ },
880
+ // Weight variants
881
+ r !== "label" && {
882
+ "font-light": a === "light",
883
+ "font-normal": a === "normal",
884
+ "font-medium": a === "medium",
885
+ "font-semibold": a === "semibold",
886
+ "font-bold": a === "bold"
887
+ },
888
+ // Color variants
889
+ {
890
+ "text-primary": t === "primary",
891
+ "text-secondary": t === "secondary",
892
+ "text-accent": t === "accent",
893
+ "text-success": t === "success",
894
+ "text-warning": t === "warning",
895
+ "text-error": t === "error",
896
+ "text-info": t === "info",
897
+ "text-neutral": t === "neutral",
898
+ "text-current": t === "current",
899
+ "text-neutral-400 dark:text-neutral-500": t === "muted"
900
+ },
901
+ // Alignment
902
+ {
903
+ "text-left": s === "left",
904
+ "text-center": s === "center",
905
+ "text-right": s === "right",
906
+ "text-justify": s === "justify"
907
+ },
908
+ // Line height (override variant line heights)
909
+ r === "body" && {
910
+ "leading-tight": f === "tight",
911
+ "leading-normal": f === "normal",
912
+ "leading-relaxed": f === "relaxed"
913
+ },
914
+ // Text decorations
915
+ {
916
+ italic: g,
917
+ underline: x,
918
+ truncate: o
919
+ },
920
+ w
921
+ );
922
+ return /* @__PURE__ */ e(k, { className: b, ...u, children: d });
923
+ };
924
+ function Be(r) {
925
+ return {
926
+ body: "p",
927
+ caption: "span",
928
+ label: "span",
929
+ code: "code"
930
+ }[r] || "p";
931
+ }
932
+ const yr = ({
933
+ groups: r,
934
+ data: n,
935
+ onSubmit: a,
936
+ onCancel: t,
937
+ onChange: s,
938
+ transform: o,
939
+ validate: g,
940
+ submitButton: x = { label: "Submit", variant: "primary" },
941
+ cancelButton: f = { label: "Cancel", variant: "outline" },
942
+ showButtons: i = !0,
943
+ layout: w = "vertical",
944
+ size: d = "md",
945
+ loading: u = !1,
946
+ className: k,
947
+ ref: b
948
+ }) => {
949
+ const [C, M] = q(n || {}), [V, $] = q({}), [J, H] = q({});
950
+ K(() => {
951
+ n && M(n);
952
+ }, [n]);
953
+ const z = ee(
954
+ (l, v, N) => {
955
+ const h = r.flatMap((A) => A.items).find((A) => A.name === l);
956
+ if (!h) return null;
957
+ if (h.required && (v == null || v === ""))
958
+ return `${h.label} is required`;
959
+ if (h.type === "array") {
960
+ if (h.required && (!v || v.length === 0))
961
+ return `${h.label} cannot be empty.`;
962
+ if (v && !Array.isArray(v))
963
+ return `${h.label} must be an array.`;
964
+ if (Array.isArray(v) && h.arrayFields) {
965
+ const A = [];
966
+ let _ = !1;
967
+ if (v.forEach((Q, T) => {
968
+ const Z = {};
969
+ for (const U of h.arrayFields) {
970
+ const X = Q == null ? void 0 : Q[U.name];
971
+ if (U.required && (X == null || X === ""))
972
+ Z[U.name] = `${U.label} is required`, _ = !0;
973
+ else if (U.validator) {
974
+ const R = U.validator(X, Q);
975
+ R && (Z[U.name] = R, _ = !0);
976
+ }
977
+ }
978
+ A[T] = Z;
979
+ }), _)
980
+ return JSON.stringify(A);
981
+ }
982
+ }
983
+ return h.validator ? h.validator(v, N) : null;
984
+ },
985
+ [r]
986
+ ), I = ee(
987
+ (l, v) => {
988
+ const N = { ...C, [l]: v }, h = r.flatMap((_) => _.items).find((_) => _.name === l);
989
+ h != null && h.removeIfEmpty && (v == null || v === "") && delete N[l], M(N), H((_) => ({ ..._, [l]: !0 }));
990
+ const A = z(l, v, N);
991
+ $((_) => ({
992
+ ..._,
993
+ [l]: A || ""
994
+ })), s == null || s(N, l);
995
+ },
996
+ [C, r, z, s]
997
+ ), P = ee(
998
+ async (l) => {
999
+ if (l.preventDefault(), u) return;
1000
+ const v = {}, N = r.flatMap((A) => A.items);
1001
+ for (const A of N) {
1002
+ if (A.hidden || A.conditional && !A.conditional(C))
1003
+ continue;
1004
+ const _ = z(A.name, C[A.name], C);
1005
+ _ && (v[A.name] = _);
1006
+ }
1007
+ if (g) {
1008
+ const A = g(C);
1009
+ A && Object.assign(v, A);
1010
+ }
1011
+ if ($(v), Object.keys(v).some((A) => v[A]))
1012
+ return;
1013
+ const h = o ? o(C) : C;
1014
+ await (a == null ? void 0 : a(C, h));
1015
+ },
1016
+ [C, r, z, g, o, a, u]
1017
+ ), G = ee(
1018
+ (l) => {
1019
+ var _, Q;
1020
+ const v = C[l.name], N = J[l.name] ? V[l.name] : void 0, h = l.disabled || u, A = {
1021
+ value: v || "",
1022
+ disabled: h,
1023
+ required: l.required,
1024
+ placeholder: l.placeholder,
1025
+ ...l.fieldProps
1026
+ };
1027
+ switch (l.type) {
1028
+ case "text":
1029
+ case "email":
1030
+ case "password":
1031
+ case "number":
1032
+ case "tel":
1033
+ case "url":
1034
+ return /* @__PURE__ */ e(
1035
+ oe,
1036
+ {
1037
+ ...A,
1038
+ onChange: (T) => I(l.name, T.target.value),
1039
+ type: l.textType || l.type,
1040
+ autoComplete: l.autocomplete,
1041
+ error: N,
1042
+ size: d
1043
+ }
1044
+ );
1045
+ case "textarea":
1046
+ return /* @__PURE__ */ e(
1047
+ fe,
1048
+ {
1049
+ ...A,
1050
+ onChange: (T) => I(l.name, T.target.value),
1051
+ rows: 4,
1052
+ error: N,
1053
+ size: d
1054
+ }
1055
+ );
1056
+ case "select":
1057
+ return /* @__PURE__ */ e(
1058
+ xe,
1059
+ {
1060
+ ...A,
1061
+ onChange: (T) => I(l.name, T),
1062
+ options: (l.options || []).map((T) => ({
1063
+ ...T,
1064
+ value: String(T.value)
1065
+ })),
1066
+ searchable: l.searchable,
1067
+ multiple: l.multiple,
1068
+ error: N,
1069
+ size: d
1070
+ }
1071
+ );
1072
+ case "checkbox":
1073
+ return /* @__PURE__ */ e(
1074
+ me,
1075
+ {
1076
+ ...A,
1077
+ checked: !!v,
1078
+ onChange: (T) => I(l.name, T.target.checked),
1079
+ size: d
1080
+ }
1081
+ );
1082
+ case "radio":
1083
+ return /* @__PURE__ */ e("div", { className: "space-y-1", children: (_ = l.options) == null ? void 0 : _.map((T) => /* @__PURE__ */ c("label", { className: "flex items-center gap-2", children: [
1084
+ /* @__PURE__ */ e(
1085
+ "input",
1086
+ {
1087
+ type: "radio",
1088
+ name: l.name,
1089
+ value: T.value,
1090
+ checked: v === T.value,
1091
+ onChange: () => I(l.name, T.value),
1092
+ disabled: h || T.disabled,
1093
+ className: "rounded-full border-neutral-100 dark:border-neutral-600"
1094
+ }
1095
+ ),
1096
+ /* @__PURE__ */ e(le, { variant: "label", size: "sm", children: T.label })
1097
+ ] }, T.value)) });
1098
+ case "date":
1099
+ return /* @__PURE__ */ e(
1100
+ he,
1101
+ {
1102
+ ...A,
1103
+ value: v ? new Date(v) : null,
1104
+ onChange: (T) => I(l.name, T),
1105
+ size: d
1106
+ }
1107
+ );
1108
+ case "custom":
1109
+ return (Q = l.customComponent) == null ? void 0 : Q.call(l, {
1110
+ value: v,
1111
+ onChange: (T) => I(l.name, T),
1112
+ error: N,
1113
+ disabled: h
1114
+ });
1115
+ case "array": {
1116
+ const T = v || [];
1117
+ let Z = [];
1118
+ if (typeof N == "string" && N.startsWith("["))
1119
+ try {
1120
+ Z = JSON.parse(N);
1121
+ } catch {
1122
+ }
1123
+ const U = () => {
1124
+ I(l.name, [...T, {}]);
1125
+ }, X = (W) => {
1126
+ I(
1127
+ l.name,
1128
+ T.filter((Y, ae) => ae !== W)
1129
+ );
1130
+ }, R = (W, Y, ae) => {
1131
+ const E = [...T];
1132
+ E[W] = {
1133
+ ...E[W],
1134
+ [Y]: ae
1135
+ }, I(l.name, E);
1136
+ };
1137
+ return /* @__PURE__ */ c("div", { className: "space-y-2", children: [
1138
+ T.map((W, Y) => {
1139
+ var ae;
1140
+ return /* @__PURE__ */ c(
1141
+ "div",
1142
+ {
1143
+ className: "p-4 border rounded-md dark:border-neutral-700 space-y-2 relative",
1144
+ children: [
1145
+ /* @__PURE__ */ e("div", { className: "absolute top-2 right-2", children: /* @__PURE__ */ e(
1146
+ te,
1147
+ {
1148
+ type: "button",
1149
+ variant: "ghost",
1150
+ size: "sm",
1151
+ onClick: () => X(Y),
1152
+ disabled: h,
1153
+ children: "Remove"
1154
+ }
1155
+ ) }),
1156
+ /* @__PURE__ */ e("div", { className: "grid grid-cols-1 md:grid-cols-2 gap-4", children: (ae = l.arrayFields) == null ? void 0 : ae.map((E) => {
1157
+ var F;
1158
+ const ne = (F = Z == null ? void 0 : Z[Y]) == null ? void 0 : F[E.name];
1159
+ return /* @__PURE__ */ c(
1160
+ "div",
1161
+ {
1162
+ className: "space-y-1",
1163
+ children: [
1164
+ /* @__PURE__ */ e("label", { className: "block", children: /* @__PURE__ */ c(
1165
+ le,
1166
+ {
1167
+ variant: "label",
1168
+ size: "sm",
1169
+ className: "font-semibold text-neutral-700 dark:text-neutral-300",
1170
+ children: [
1171
+ E.label,
1172
+ E.required && /* @__PURE__ */ e("span", { className: "text-red-500 ml-1", children: "*" })
1173
+ ]
1174
+ }
1175
+ ) }),
1176
+ (() => {
1177
+ var m, j;
1178
+ const se = {
1179
+ value: (W == null ? void 0 : W[E.name]) || "",
1180
+ disabled: h,
1181
+ required: E.required,
1182
+ placeholder: E.placeholder,
1183
+ ...E.fieldProps
1184
+ };
1185
+ switch (E.type) {
1186
+ case "text":
1187
+ case "email":
1188
+ case "password":
1189
+ case "number":
1190
+ case "tel":
1191
+ case "url":
1192
+ return /* @__PURE__ */ e(
1193
+ oe,
1194
+ {
1195
+ ...se,
1196
+ onChange: (L) => R(
1197
+ Y,
1198
+ E.name,
1199
+ L.target.value
1200
+ ),
1201
+ type: E.textType || E.type,
1202
+ autoComplete: E.autocomplete,
1203
+ error: ne,
1204
+ size: d
1205
+ }
1206
+ );
1207
+ case "textarea":
1208
+ return /* @__PURE__ */ e(
1209
+ fe,
1210
+ {
1211
+ ...se,
1212
+ onChange: (L) => R(
1213
+ Y,
1214
+ E.name,
1215
+ L.target.value
1216
+ ),
1217
+ rows: 4,
1218
+ error: ne,
1219
+ size: d
1220
+ }
1221
+ );
1222
+ case "select":
1223
+ return /* @__PURE__ */ e(
1224
+ xe,
1225
+ {
1226
+ ...se,
1227
+ onChange: (L) => R(
1228
+ Y,
1229
+ E.name,
1230
+ L
1231
+ ),
1232
+ options: (E.options || []).map(
1233
+ (L) => ({
1234
+ ...L,
1235
+ value: String(L.value)
1236
+ })
1237
+ ),
1238
+ searchable: E.searchable,
1239
+ multiple: E.multiple,
1240
+ error: ne,
1241
+ size: d
1242
+ }
1243
+ );
1244
+ case "checkbox":
1245
+ return /* @__PURE__ */ e(
1246
+ me,
1247
+ {
1248
+ ...se,
1249
+ checked: !!(W != null && W[E.name]),
1250
+ onChange: (L) => R(
1251
+ Y,
1252
+ E.name,
1253
+ L.target.checked
1254
+ ),
1255
+ size: d
1256
+ }
1257
+ );
1258
+ case "radio":
1259
+ return /* @__PURE__ */ e("div", { className: "space-y-1", children: (m = E.options) == null ? void 0 : m.map((L) => /* @__PURE__ */ c(
1260
+ "label",
1261
+ {
1262
+ className: "flex items-center gap-2",
1263
+ children: [
1264
+ /* @__PURE__ */ e(
1265
+ "input",
1266
+ {
1267
+ type: "radio",
1268
+ name: `${l.name}.${Y}.${E.name}`,
1269
+ value: L.value,
1270
+ checked: (W == null ? void 0 : W[E.name]) === L.value,
1271
+ onChange: () => R(
1272
+ Y,
1273
+ E.name,
1274
+ L.value
1275
+ ),
1276
+ disabled: h || L.disabled,
1277
+ className: "rounded-full border-neutral-100 dark:border-neutral-600"
1278
+ }
1279
+ ),
1280
+ /* @__PURE__ */ e(le, { variant: "label", size: "sm", children: L.label })
1281
+ ]
1282
+ },
1283
+ L.value
1284
+ )) });
1285
+ case "date": {
1286
+ const L = W == null ? void 0 : W[E.name];
1287
+ return /* @__PURE__ */ e(
1288
+ he,
1289
+ {
1290
+ ...se,
1291
+ value: L ? new Date(L) : null,
1292
+ onChange: (B) => R(
1293
+ Y,
1294
+ E.name,
1295
+ B
1296
+ ),
1297
+ size: d
1298
+ }
1299
+ );
1300
+ }
1301
+ case "custom":
1302
+ return (j = E.customComponent) == null ? void 0 : j.call(E, {
1303
+ value: W == null ? void 0 : W[E.name],
1304
+ onChange: (L) => R(
1305
+ Y,
1306
+ E.name,
1307
+ L
1308
+ ),
1309
+ error: ne,
1310
+ disabled: h
1311
+ });
1312
+ // Add other field types here as needed
1313
+ default:
1314
+ return /* @__PURE__ */ c("p", { children: [
1315
+ "Unsupported field type in array:",
1316
+ " ",
1317
+ E.type
1318
+ ] });
1319
+ }
1320
+ })(),
1321
+ ne && /* @__PURE__ */ e(
1322
+ le,
1323
+ {
1324
+ variant: "body",
1325
+ size: "sm",
1326
+ className: "text-red-600 dark:text-red-400",
1327
+ children: ne
1328
+ }
1329
+ )
1330
+ ]
1331
+ },
1332
+ E.name
1333
+ );
1334
+ }) })
1335
+ ]
1336
+ },
1337
+ Y
1338
+ );
1339
+ }),
1340
+ /* @__PURE__ */ c(
1341
+ te,
1342
+ {
1343
+ type: "button",
1344
+ variant: "outline",
1345
+ size: "sm",
1346
+ onClick: U,
1347
+ disabled: h,
1348
+ children: [
1349
+ "Add ",
1350
+ l.label
1351
+ ]
1352
+ }
1353
+ )
1354
+ ] });
1355
+ }
1356
+ default:
1357
+ return null;
1358
+ }
1359
+ },
1360
+ [C, J, V, u, d, I]
1361
+ ), S = ee(
1362
+ (l) => {
1363
+ if (l.conditional && !l.conditional(C))
1364
+ return null;
1365
+ const v = l.items.filter((h) => !(h.hidden || h.conditional && !h.conditional(C)));
1366
+ if (v.length === 0) return null;
1367
+ const N = p(
1368
+ "space-y-2",
1369
+ {
1370
+ "grid gap-2": l.layout === "grid",
1371
+ "flex flex-wrap gap-2": l.layout === "flex"
1372
+ },
1373
+ l.layout === "grid" && {
1374
+ "grid-cols-1": !l.columns || l.columns === 1,
1375
+ "grid-cols-2": l.columns === 2,
1376
+ "grid-cols-3": l.columns === 3,
1377
+ "grid-cols-4": l.columns === 4
1378
+ },
1379
+ l.className
1380
+ );
1381
+ return /* @__PURE__ */ c(
1382
+ "div",
1383
+ {
1384
+ className: "grid grid-cols-1 md:grid-cols-3 gap-8 p-6 border border-neutral dark:border-neutral-700 rounded-xl",
1385
+ children: [
1386
+ /* @__PURE__ */ c("div", { className: "md:col-span-1", children: [
1387
+ /* @__PURE__ */ e(
1388
+ le,
1389
+ {
1390
+ variant: "label",
1391
+ size: "lg",
1392
+ weight: "semibold",
1393
+ className: "text-neutral-900 dark:text-neutral-100",
1394
+ children: l.title
1395
+ }
1396
+ ),
1397
+ l.description && /* @__PURE__ */ e(
1398
+ le,
1399
+ {
1400
+ variant: "body",
1401
+ size: "sm",
1402
+ className: "text-neutral-600 dark:text-neutral-400 mt-1",
1403
+ children: l.description
1404
+ }
1405
+ )
1406
+ ] }),
1407
+ /* @__PURE__ */ e("div", { className: "md:col-span-2", children: /* @__PURE__ */ e("div", { className: N, children: v.map((h) => (J[h.name] && V[h.name], /* @__PURE__ */ c(
1408
+ "div",
1409
+ {
1410
+ className: p(
1411
+ "space-y-1",
1412
+ h.width && typeof h.width == "string" && `w-[${h.width}]`,
1413
+ h.width && typeof h.width == "number" && `col-span-${h.width}`
1414
+ ),
1415
+ children: [
1416
+ h.type !== "custom" && /* @__PURE__ */ e("label", { className: "block", children: /* @__PURE__ */ c(
1417
+ le,
1418
+ {
1419
+ variant: "label",
1420
+ size: "sm",
1421
+ className: "font-medium text-neutral-700 dark:text-neutral-300",
1422
+ children: [
1423
+ h.label,
1424
+ h.required && /* @__PURE__ */ e("span", { className: "text-red-500 ml-1", children: "*" })
1425
+ ]
1426
+ }
1427
+ ) }),
1428
+ G(h)
1429
+ ]
1430
+ },
1431
+ h.name
1432
+ ))) }) })
1433
+ ]
1434
+ },
1435
+ l.id
1436
+ );
1437
+ },
1438
+ [C, J, V, G]
1439
+ ), y = p(
1440
+ "space-y-6",
1441
+ {
1442
+ "max-w-md": d === "sm",
1443
+ "max-w-2xl": d === "md",
1444
+ "max-w-4xl": d === "lg",
1445
+ "max-w-full": d === "full"
1446
+ },
1447
+ k
1448
+ );
1449
+ return /* @__PURE__ */ c("form", { ref: b, onSubmit: P, className: y, children: [
1450
+ /* @__PURE__ */ e("div", { className: "space-y-8", children: r.map(S) }),
1451
+ i && /* @__PURE__ */ c("div", { className: p("flex gap-3 justify-end pt-8"), children: [
1452
+ t && /* @__PURE__ */ e(
1453
+ te,
1454
+ {
1455
+ type: "button",
1456
+ variant: f.variant,
1457
+ size: f.size || d,
1458
+ disabled: f.disabled || u,
1459
+ onClick: t,
1460
+ className: f.className,
1461
+ children: f.label
1462
+ }
1463
+ ),
1464
+ /* @__PURE__ */ e(
1465
+ te,
1466
+ {
1467
+ type: "submit",
1468
+ variant: x.variant,
1469
+ size: x.size || d,
1470
+ disabled: x.disabled || u,
1471
+ loading: u,
1472
+ className: x.className,
1473
+ children: x.label
1474
+ }
1475
+ )
1476
+ ] })
1477
+ ] });
1478
+ }, ze = ({
1479
+ trigger: r,
1480
+ options: n,
1481
+ value: a,
1482
+ onSelect: t,
1483
+ placement: s = "bottom-start",
1484
+ disabled: o = !1,
1485
+ className: g,
1486
+ showCheck: x = !0,
1487
+ header: f
1488
+ }) => {
1489
+ const [i, w] = q(!1), [d, u] = q(null), [k, b] = q({ top: 0, left: 0 }), C = re(null), M = re(null), V = re(null), $ = re(null);
1490
+ K(() => {
1491
+ const y = (l) => {
1492
+ C.current && !C.current.contains(l.target) && V.current && !V.current.contains(l.target) && (w(!1), u(null), $.current && (clearTimeout($.current), $.current = null));
1493
+ };
1494
+ return i && document.addEventListener("mousedown", y), () => {
1495
+ document.removeEventListener("mousedown", y);
1496
+ };
1497
+ }, [i]), K(() => {
1498
+ const y = (l) => {
1499
+ l.key === "Escape" && (w(!1), u(null), $.current && (clearTimeout($.current), $.current = null));
1500
+ };
1501
+ return i && document.addEventListener("keydown", y), () => {
1502
+ document.removeEventListener("keydown", y);
1503
+ };
1504
+ }, [i]), K(() => {
1505
+ if (d && C.current) {
1506
+ const y = C.current.querySelector(
1507
+ `[data-option-value="${d}"]`
1508
+ );
1509
+ if (y) {
1510
+ const l = y.getBoundingClientRect();
1511
+ b({
1512
+ top: l.top,
1513
+ left: l.right + 8
1514
+ });
1515
+ }
1516
+ }
1517
+ }, [d]), K(() => () => {
1518
+ $.current && clearTimeout($.current);
1519
+ }, []);
1520
+ const J = (y) => {
1521
+ y.stopPropagation(), o || (w(!i), u(null), $.current && (clearTimeout($.current), $.current = null));
1522
+ }, H = (y, l, v) => {
1523
+ y.stopPropagation(), !l.disabled && !l.divider && (!l.children || l.children.length === 0) && (t == null || t(l.value, v), w(!1), u(null));
1524
+ }, z = (y) => {
1525
+ $.current && (clearTimeout($.current), $.current = null), y.children && y.children.length > 0 ? u(y.value) : u(null);
1526
+ }, I = (y) => {
1527
+ y.children && y.children.length > 0 ? $.current = setTimeout(() => {
1528
+ u(null);
1529
+ }, 150) : u(null);
1530
+ }, P = (y, l, v) => {
1531
+ y.stopPropagation(), !l.disabled && !l.divider && (t == null || t(l.value, v), w(!1), u(null));
1532
+ }, G = p(
1533
+ "absolute z-50 min-w-[200px] bg-white dark:bg-gray-800 rounded-md shadow-xs border border-gray-100 dark:border-gray-600",
1534
+ "max-h-60 overflow-auto",
1535
+ {
1536
+ "top-full left-0 mt-2": s === "bottom-start",
1537
+ "top-full right-0 mt-2": s === "bottom-end",
1538
+ "bottom-full left-0 mb-2": s === "top-start",
1539
+ "bottom-full right-0 mb-2": s === "top-end"
1540
+ }
1541
+ ), S = p(
1542
+ "fixed z-[60] min-w-[200px] bg-white dark:bg-gray-800 rounded-md shadow-lg border border-gray-100 dark:border-gray-600",
1543
+ "max-h-60 overflow-auto"
1544
+ );
1545
+ return /* @__PURE__ */ c(
1546
+ "div",
1547
+ {
1548
+ ref: C,
1549
+ className: p(
1550
+ "relative flex flex-row items-center justify-center rounded-lg hover:bg-gray-100 dark:hover:bg-gray-700",
1551
+ g
1552
+ ),
1553
+ children: [
1554
+ /* @__PURE__ */ e(
1555
+ "button",
1556
+ {
1557
+ ref: M,
1558
+ onClick: J,
1559
+ disabled: o,
1560
+ className: p("inline-flex items-center justify-center", {
1561
+ "opacity-50 cursor-not-allowed": o
1562
+ }),
1563
+ children: r
1564
+ }
1565
+ ),
1566
+ i && /* @__PURE__ */ e("div", { className: G, children: /* @__PURE__ */ c("div", { className: "p-2", children: [
1567
+ f && /* @__PURE__ */ e("div", { className: "text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider px-3 py-2", children: f }),
1568
+ n.map((y, l) => {
1569
+ if (y.divider)
1570
+ return /* @__PURE__ */ e(
1571
+ "div",
1572
+ {
1573
+ className: "border-t border-gray-200 dark:border-gray-700 my-2"
1574
+ },
1575
+ `divider-${l}`
1576
+ );
1577
+ const v = y.children && y.children.length > 0, N = d === y.value;
1578
+ return /* @__PURE__ */ c("div", { className: "relative group", children: [
1579
+ /* @__PURE__ */ c(
1580
+ "button",
1581
+ {
1582
+ "data-option-value": y.value,
1583
+ onClick: (h) => H(h, y),
1584
+ onMouseEnter: () => z(y),
1585
+ onMouseLeave: () => I(y),
1586
+ disabled: y.disabled,
1587
+ className: p(
1588
+ "w-full flex items-center justify-between px-3 py-2 text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-md transition-colors",
1589
+ {
1590
+ "opacity-50 cursor-not-allowed": y.disabled,
1591
+ "bg-gray-100 dark:bg-gray-700": N && v
1592
+ }
1593
+ ),
1594
+ children: [
1595
+ /* @__PURE__ */ c("div", { className: "flex items-center space-x-2 min-w-0", children: [
1596
+ y.icon && /* @__PURE__ */ e("span", { className: "flex-shrink-0", children: y.icon }),
1597
+ /* @__PURE__ */ c("div", { className: "flex flex-col items-start min-w-0", children: [
1598
+ /* @__PURE__ */ e("span", { className: "font-base truncate", children: y.label }),
1599
+ y.description && /* @__PURE__ */ e("span", { className: "text-xs text-gray-500 dark:text-gray-400", children: y.description })
1600
+ ] })
1601
+ ] }),
1602
+ /* @__PURE__ */ c("div", { className: "flex items-center space-x-2", children: [
1603
+ x && a === y.value && /* @__PURE__ */ e("span", { className: "h-4 w-4 text-green-600 flex-shrink-0 text-sm font-bold", children: "✓" }),
1604
+ v && /* @__PURE__ */ e("span", { className: "text-gray-400 dark:text-gray-500 text-xs", children: "▶" })
1605
+ ] })
1606
+ ]
1607
+ }
1608
+ ),
1609
+ v && N && /* @__PURE__ */ e(
1610
+ "div",
1611
+ {
1612
+ ref: V,
1613
+ className: S,
1614
+ style: {
1615
+ top: `${k.top}px`,
1616
+ left: `${k.left}px`
1617
+ },
1618
+ onMouseEnter: () => {
1619
+ $.current && (clearTimeout($.current), $.current = null), u(y.value);
1620
+ },
1621
+ onMouseLeave: () => {
1622
+ $.current = setTimeout(() => {
1623
+ u(null);
1624
+ }, 150);
1625
+ },
1626
+ children: /* @__PURE__ */ e("div", { className: "p-2", children: y.children.map((h, A) => {
1627
+ if (h.divider)
1628
+ return /* @__PURE__ */ e(
1629
+ "div",
1630
+ {
1631
+ className: "border-t border-gray-200 dark:border-gray-700 my-2"
1632
+ },
1633
+ `divider-${A}`
1634
+ );
1635
+ const _ = typeof a == "object" && a[y.value] && a[y.value].includes(
1636
+ h.value
1637
+ ) || a === h.value;
1638
+ return /* @__PURE__ */ c(
1639
+ "button",
1640
+ {
1641
+ onClick: (Q) => P(
1642
+ Q,
1643
+ h,
1644
+ y.value
1645
+ ),
1646
+ disabled: h.disabled,
1647
+ className: p(
1648
+ "w-full flex items-center justify-between px-3 py-2 text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-md transition-colors",
1649
+ {
1650
+ "opacity-50 cursor-not-allowed": h.disabled
1651
+ }
1652
+ ),
1653
+ children: [
1654
+ /* @__PURE__ */ c("div", { className: "flex items-center space-x-2 min-w-0", children: [
1655
+ h.icon && /* @__PURE__ */ e("span", { className: "flex-shrink-0", children: h.icon }),
1656
+ /* @__PURE__ */ c("div", { className: "flex flex-col items-start min-w-0", children: [
1657
+ /* @__PURE__ */ e("span", { className: "font-base truncate", children: h.label }),
1658
+ h.description && /* @__PURE__ */ e("span", { className: "text-xs text-gray-500 dark:text-gray-400", children: h.description })
1659
+ ] })
1660
+ ] }),
1661
+ x && _ && /* @__PURE__ */ e("span", { className: "h-4 w-4 text-green-600 flex-shrink-0 text-sm font-bold", children: "✓" })
1662
+ ]
1663
+ },
1664
+ h.value
1665
+ );
1666
+ }) })
1667
+ }
1668
+ )
1669
+ ] }, y.value);
1670
+ }),
1671
+ (() => {
1672
+ const y = n.reduce((l, v) => {
1673
+ if (v.divider) return l;
1674
+ const N = v.children ? v.children.filter((h) => !h.divider).length : 0;
1675
+ return l + 1 + N;
1676
+ }, 0);
1677
+ return y > 1 && /* @__PURE__ */ e("div", { className: "border-t border-gray-200 dark:border-gray-600 mt-2 pt-2", children: /* @__PURE__ */ c("div", { className: "text-xs text-gray-500 dark:text-gray-400 px-3 py-1", children: [
1678
+ y,
1679
+ " options available"
1680
+ ] }) });
1681
+ })()
1682
+ ] }) })
1683
+ ]
1684
+ }
1685
+ );
1686
+ }, We = {
1687
+ sm: "max-w-md",
1688
+ md: "max-w-lg",
1689
+ lg: "max-w-2xl",
1690
+ xl: "max-w-4xl",
1691
+ full: "max-w-full mx-4"
1692
+ };
1693
+ function vr({
1694
+ open: r,
1695
+ onClose: n,
1696
+ title: a,
1697
+ size: t = "md",
1698
+ closeOnBackdropClick: s = !0,
1699
+ closeOnEscape: o = !0,
1700
+ className: g,
1701
+ backdropClassName: x,
1702
+ children: f,
1703
+ footer: i,
1704
+ showCloseButton: w = !0
1705
+ }) {
1706
+ const d = re(null), u = re(null);
1707
+ K(() => {
1708
+ if (!r || !o) return;
1709
+ const b = (C) => {
1710
+ C.key === "Escape" && n();
1711
+ };
1712
+ return document.addEventListener("keydown", b), () => document.removeEventListener("keydown", b);
1713
+ }, [r, o, n]), K(() => (r ? (u.current = document.activeElement, d.current && d.current.focus(), document.body.style.overflow = "hidden") : (u.current && u.current.focus(), document.body.style.overflow = ""), () => {
1714
+ document.body.style.overflow = "";
1715
+ }), [r]);
1716
+ const k = (b) => {
1717
+ s && b.target === b.currentTarget && n();
1718
+ };
1719
+ return r ? /* @__PURE__ */ e(
1720
+ "div",
1721
+ {
1722
+ className: p(
1723
+ "fixed inset-0 z-50 flex items-center justify-center p-4",
1724
+ "bg-black/20",
1725
+ // 'animate-fade-in',
1726
+ x
1727
+ ),
1728
+ onClick: k,
1729
+ children: /* @__PURE__ */ c(
1730
+ "div",
1731
+ {
1732
+ ref: d,
1733
+ className: p(
1734
+ "relative w-full bg-white dark:bg-secondary-800 rounded-modal shadow-modal rounded-md",
1735
+ // 'animate-scale-in',
1736
+ "focus:outline-none",
1737
+ We[t],
1738
+ g
1739
+ ),
1740
+ role: "dialog",
1741
+ "aria-modal": "true",
1742
+ "aria-labelledby": a ? "modal-title" : void 0,
1743
+ tabIndex: -1,
1744
+ children: [
1745
+ (a || w) && /* @__PURE__ */ c("div", { className: "flex items-center justify-between p-6 pb-0", children: [
1746
+ a && /* @__PURE__ */ e(
1747
+ "span",
1748
+ {
1749
+ id: "modal-title",
1750
+ className: "text-lg font-semibold text-secondary-800 dark:text-secondary-200",
1751
+ children: a
1752
+ }
1753
+ ),
1754
+ w && /* @__PURE__ */ e(
1755
+ "button",
1756
+ {
1757
+ onClick: n,
1758
+ className: "p-1 text-secondary-400 hover:text-secondary-600 dark:hover:text-secondary-300 transition-colors",
1759
+ "aria-label": "Close modal",
1760
+ children: /* @__PURE__ */ e("svg", { className: "h-6 w-6", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: /* @__PURE__ */ e("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M6 18L18 6M6 6l12 12" }) })
1761
+ }
1762
+ )
1763
+ ] }),
1764
+ /* @__PURE__ */ e("div", { className: "p-6", children: f }),
1765
+ i && /* @__PURE__ */ e("div", { className: "px-6 py-4", children: i })
1766
+ ]
1767
+ }
1768
+ )
1769
+ }
1770
+ ) : null;
1771
+ }
1772
+ const Ve = {
1773
+ default: "bg-secondary-100 text-secondary-800 dark:bg-secondary-800 dark:text-secondary-200",
1774
+ primary: "bg-primary-100 text-primary-800 dark:bg-primary-900 dark:text-primary-200",
1775
+ secondary: "bg-secondary-100 text-secondary-800 dark:bg-secondary-800 dark:text-secondary-200",
1776
+ success: "bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-200",
1777
+ warning: "bg-yellow-100 text-yellow-800 dark:bg-yellow-900 dark:text-yellow-200",
1778
+ error: "bg-red-100 text-red-800 dark:bg-red-900 dark:text-red-200",
1779
+ info: "bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-200"
1780
+ }, qe = {
1781
+ sm: "px-2 py-0.5 text-xs",
1782
+ md: "px-2.5 py-1 text-sm",
1783
+ lg: "px-3 py-1.5 text-base"
1784
+ }, He = {
1785
+ default: "bg-secondary-400",
1786
+ primary: "bg-primary-500",
1787
+ secondary: "bg-secondary-400",
1788
+ success: "bg-green-500",
1789
+ warning: "bg-yellow-500",
1790
+ error: "bg-red-500",
1791
+ info: "bg-blue-500"
1792
+ };
1793
+ function kr({
1794
+ variant: r = "default",
1795
+ size: n = "md",
1796
+ dot: a = !1,
1797
+ icon: t,
1798
+ dismissible: s = !1,
1799
+ onDismiss: o,
1800
+ className: g,
1801
+ children: x,
1802
+ ...f
1803
+ }) {
1804
+ return /* @__PURE__ */ c(
1805
+ "span",
1806
+ {
1807
+ className: p(
1808
+ // Base styles
1809
+ "inline-flex items-center font-medium rounded-full",
1810
+ // Variant styles
1811
+ Ve[r],
1812
+ // Size styles
1813
+ qe[n],
1814
+ g
1815
+ ),
1816
+ ...f,
1817
+ children: [
1818
+ a && /* @__PURE__ */ e(
1819
+ "span",
1820
+ {
1821
+ className: p(
1822
+ "w-2 h-2 rounded-full mr-1.5",
1823
+ He[r]
1824
+ )
1825
+ }
1826
+ ),
1827
+ t && /* @__PURE__ */ e("span", { className: p("flex-shrink-0", x && "mr-1"), children: t }),
1828
+ x,
1829
+ s && o && /* @__PURE__ */ e(
1830
+ "button",
1831
+ {
1832
+ onClick: o,
1833
+ className: "ml-1.5 flex-shrink-0 hover:opacity-70 transition-opacity",
1834
+ "aria-label": "Remove badge",
1835
+ children: /* @__PURE__ */ e("svg", { className: "h-3 w-3", fill: "currentColor", viewBox: "0 0 20 20", children: /* @__PURE__ */ e(
1836
+ "path",
1837
+ {
1838
+ fillRule: "evenodd",
1839
+ d: "M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z",
1840
+ clipRule: "evenodd"
1841
+ }
1842
+ ) })
1843
+ }
1844
+ )
1845
+ ]
1846
+ }
1847
+ );
1848
+ }
1849
+ function Oe({
1850
+ children: r,
1851
+ showTableSkeleton: n = !1,
1852
+ tableColumns: a = 6,
1853
+ tableRows: t = 8
1854
+ }) {
1855
+ return r ? /* @__PURE__ */ e("main", { className: "flex-1 bg-gray-50 dark:bg-gray-950 p-6", children: /* @__PURE__ */ e("div", { className: "w-full max-w-6xl mx-auto animate-pulse", children: r }) }) : /* @__PURE__ */ e("main", { className: "flex-1 bg-gray-50 dark:bg-gray-950 p-6", children: /* @__PURE__ */ c("div", { className: "w-full mx-auto space-y-6 animate-pulse", children: [
1856
+ !n && /* @__PURE__ */ c(ke, { children: [
1857
+ /* @__PURE__ */ e("div", { className: "h-6 bg-gray-200 dark:bg-gray-700 rounded w-1/4" }),
1858
+ /* @__PURE__ */ c("div", { className: "space-y-2", children: [
1859
+ /* @__PURE__ */ e("div", { className: "h-4 bg-gray-200 dark:bg-gray-700 rounded w-3/4" }),
1860
+ /* @__PURE__ */ e("div", { className: "h-4 bg-gray-200 dark:bg-gray-700 rounded w-1/2" })
1861
+ ] })
1862
+ ] }),
1863
+ n && /* @__PURE__ */ c("div", { className: "rounded-lg overflow-hidden", children: [
1864
+ /* @__PURE__ */ e("div", { className: `grid grid-cols-${a} gap-2 bg-gray-100 dark:bg-gray-800 p-3`, children: Array.from({ length: a }).map((s, o) => /* @__PURE__ */ e(
1865
+ "div",
1866
+ {
1867
+ className: "h-4 bg-gray-300 dark:bg-gray-600 rounded w-2/3"
1868
+ },
1869
+ `header-${o}`
1870
+ )) }),
1871
+ Array.from({ length: t }).map((s, o) => /* @__PURE__ */ e(
1872
+ "div",
1873
+ {
1874
+ className: `grid grid-cols-${a} gap-2 p-3 border-t border-gray-100 dark:border-gray-800`,
1875
+ children: Array.from({ length: a }).map((g, x) => /* @__PURE__ */ e(
1876
+ "div",
1877
+ {
1878
+ className: "h-4 bg-gray-200 dark:bg-gray-700 rounded w-full"
1879
+ },
1880
+ `cell-${o}-${x}`
1881
+ ))
1882
+ },
1883
+ `row-${o}`
1884
+ ))
1885
+ ] })
1886
+ ] }) });
1887
+ }
1888
+ const Je = {
1889
+ xs: "h-3 w-3",
1890
+ sm: "h-4 w-4",
1891
+ md: "h-6 w-6",
1892
+ lg: "h-8 w-8",
1893
+ xl: "h-12 w-12"
1894
+ }, Ye = {
1895
+ primary: "text-primary",
1896
+ secondary: "text-secondary-600",
1897
+ white: "text-white",
1898
+ current: "text-current"
1899
+ }, Ue = {
1900
+ xs: "text-xs",
1901
+ sm: "text-sm",
1902
+ md: "text-sm",
1903
+ lg: "text-base",
1904
+ xl: "text-lg"
1905
+ };
1906
+ function Nr({
1907
+ size: r = "md",
1908
+ variant: n = "primary",
1909
+ label: a = "Loading...",
1910
+ showLabel: t = !1,
1911
+ className: s,
1912
+ ...o
1913
+ }) {
1914
+ return /* @__PURE__ */ c(
1915
+ "div",
1916
+ {
1917
+ className: p(
1918
+ "inline-flex items-center",
1919
+ t ? "flex-col space-y-2" : "",
1920
+ s
1921
+ ),
1922
+ ...o,
1923
+ children: [
1924
+ /* @__PURE__ */ c(
1925
+ "svg",
1926
+ {
1927
+ className: p(
1928
+ "animate-spin",
1929
+ Je[r],
1930
+ Ye[n]
1931
+ ),
1932
+ fill: "none",
1933
+ viewBox: "0 0 24 24",
1934
+ "aria-hidden": !t,
1935
+ role: t ? "status" : void 0,
1936
+ children: [
1937
+ /* @__PURE__ */ e(
1938
+ "circle",
1939
+ {
1940
+ className: "opacity-25",
1941
+ cx: "12",
1942
+ cy: "12",
1943
+ r: "10",
1944
+ stroke: "currentColor",
1945
+ strokeWidth: "4"
1946
+ }
1947
+ ),
1948
+ /* @__PURE__ */ e(
1949
+ "path",
1950
+ {
1951
+ className: "opacity-75",
1952
+ fill: "currentColor",
1953
+ d: "M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"
1954
+ }
1955
+ )
1956
+ ]
1957
+ }
1958
+ ),
1959
+ t && /* @__PURE__ */ e(
1960
+ "span",
1961
+ {
1962
+ className: p(
1963
+ "text-secondary-600 dark:text-secondary-400",
1964
+ Ue[r]
1965
+ ),
1966
+ children: a
1967
+ }
1968
+ ),
1969
+ !t && /* @__PURE__ */ e("span", { className: "sr-only", children: a })
1970
+ ]
1971
+ }
1972
+ );
1973
+ }
1974
+ const wr = ({
1975
+ icon: r,
1976
+ size: n = "md",
1977
+ color: a = "current",
1978
+ clickable: t = !1,
1979
+ onClick: s,
1980
+ className: o,
1981
+ "aria-label": g,
1982
+ ...x
1983
+ }) => {
1984
+ const f = typeof n == "number" ? n : Ge(n), i = p(
1985
+ "inline-block",
1986
+ // Color variants
1987
+ {
1988
+ "text-primary": a === "primary",
1989
+ "text-secondary": a === "secondary",
1990
+ "text-accent": a === "accent",
1991
+ "text-success": a === "success",
1992
+ "text-warning": a === "warning",
1993
+ "text-error": a === "error",
1994
+ "text-info": a === "info",
1995
+ "text-neutral": a === "neutral",
1996
+ "text-current": a === "current"
1997
+ },
1998
+ // Clickable styles
1999
+ {
2000
+ "cursor-pointer hover:opacity-80 transition-opacity duration-200": t,
2001
+ "focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-primary/20 rounded": t
2002
+ },
2003
+ o
2004
+ ), w = {
2005
+ size: f,
2006
+ className: i,
2007
+ onClick: t ? s : void 0,
2008
+ "aria-label": g,
2009
+ role: t ? "button" : void 0,
2010
+ tabIndex: t ? 0 : void 0,
2011
+ onKeyDown: t ? (d) => {
2012
+ (d.key === "Enter" || d.key === " ") && (d.preventDefault(), s == null || s());
2013
+ } : void 0,
2014
+ ...x
2015
+ };
2016
+ return /* @__PURE__ */ e(r, { ...w });
2017
+ };
2018
+ function Ge(r) {
2019
+ return {
2020
+ xs: 12,
2021
+ sm: 16,
2022
+ md: 20,
2023
+ lg: 24,
2024
+ xl: 32
2025
+ }[r];
2026
+ }
2027
+ const Cr = ({
2028
+ src: r,
2029
+ alt: n,
2030
+ size: a = "md",
2031
+ aspectRatio: t = "auto",
2032
+ radius: s = "md",
2033
+ showLoading: o = !0,
2034
+ showError: g = !0,
2035
+ fallback: x,
2036
+ loadingContent: f,
2037
+ errorContent: i,
2038
+ className: w,
2039
+ onLoad: d,
2040
+ onError: u,
2041
+ ...k
2042
+ }) => {
2043
+ const [b, C] = q(!0), [M, V] = q(!1), [$, J] = q(r), H = (l) => {
2044
+ C(!1), V(!1), d == null || d(l);
2045
+ }, z = (l) => {
2046
+ if (C(!1), V(!0), x && $ !== x) {
2047
+ J(x), V(!1), C(!0);
2048
+ return;
2049
+ }
2050
+ u == null || u(l);
2051
+ }, I = p(
2052
+ "relative overflow-hidden bg-neutral-100 dark:bg-neutral-800",
2053
+ // Size variants
2054
+ {
2055
+ "w-8 h-8": a === "xs",
2056
+ "w-12 h-12": a === "sm",
2057
+ "w-16 h-16": a === "md",
2058
+ "w-24 h-24": a === "lg",
2059
+ "w-32 h-32": a === "xl",
2060
+ "w-full h-full": a === "full"
2061
+ },
2062
+ // Aspect ratio variants
2063
+ {
2064
+ "aspect-square": t === "square",
2065
+ "aspect-video": t === "video",
2066
+ "aspect-[3/4]": t === "portrait",
2067
+ "aspect-[4/3]": t === "landscape"
2068
+ },
2069
+ // Border radius variants
2070
+ {
2071
+ "rounded-none": s === "none",
2072
+ "rounded-sm": s === "sm",
2073
+ "rounded-md": s === "md",
2074
+ "rounded-lg": s === "lg",
2075
+ "rounded-xl": s === "xl",
2076
+ "rounded-full": s === "full"
2077
+ },
2078
+ w
2079
+ ), P = p(
2080
+ "w-full h-full object-cover transition-opacity duration-200",
2081
+ {
2082
+ "opacity-0": b || M,
2083
+ "opacity-100": !b && !M
2084
+ }
2085
+ ), G = p(
2086
+ "absolute inset-0 flex items-center justify-center",
2087
+ "text-neutral-400 dark:text-neutral-500"
2088
+ ), S = /* @__PURE__ */ e("div", { className: "animate-pulse", children: /* @__PURE__ */ e("div", { className: "w-6 h-6 bg-neutral-300 dark:bg-neutral-600 rounded" }) }), y = /* @__PURE__ */ c("div", { className: "text-center", children: [
2089
+ /* @__PURE__ */ e(
2090
+ "svg",
2091
+ {
2092
+ className: "w-6 h-6 mx-auto mb-1",
2093
+ fill: "none",
2094
+ stroke: "currentColor",
2095
+ viewBox: "0 0 24 24",
2096
+ children: /* @__PURE__ */ e(
2097
+ "path",
2098
+ {
2099
+ strokeLinecap: "round",
2100
+ strokeLinejoin: "round",
2101
+ strokeWidth: 2,
2102
+ d: "M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z"
2103
+ }
2104
+ )
2105
+ }
2106
+ ),
2107
+ /* @__PURE__ */ e("span", { className: "text-xs", children: "Failed to load" })
2108
+ ] });
2109
+ return /* @__PURE__ */ c("div", { className: I, children: [
2110
+ /* @__PURE__ */ e(
2111
+ "img",
2112
+ {
2113
+ ...k,
2114
+ src: $,
2115
+ alt: n,
2116
+ className: P,
2117
+ onLoad: H,
2118
+ onError: z
2119
+ }
2120
+ ),
2121
+ b && o && /* @__PURE__ */ e("div", { className: G, children: f || S }),
2122
+ M && g && /* @__PURE__ */ e("div", { className: G, children: i || y })
2123
+ ] });
2124
+ }, Sr = ({
2125
+ title: r,
2126
+ subtitle: n,
2127
+ actions: a = [],
2128
+ children: t,
2129
+ className: s,
2130
+ backLabel: o = "Back",
2131
+ backClassName: g,
2132
+ onBack: x
2133
+ }) => /* @__PURE__ */ c(
2134
+ "div",
2135
+ {
2136
+ className: p(
2137
+ "p-5 pb-3 border-b border-gray-100 dark:border-gray-700",
2138
+ s
2139
+ ),
2140
+ children: [
2141
+ /* @__PURE__ */ c("div", { className: "flex flex-col sm:flex-row sm:items-start sm:justify-between gap-4", children: [
2142
+ /* @__PURE__ */ e("div", { className: "min-w-0 flex-1", children: /* @__PURE__ */ c("div", { className: "flex items-center gap-2 text-neutral-900 dark:text-neutral-100 pb-2", children: [
2143
+ x && /* @__PURE__ */ e(
2144
+ "button",
2145
+ {
2146
+ onClick: x,
2147
+ className: p(
2148
+ "flex items-center text-sm dark:hover:text-neutral-300 cursor-pointer transition",
2149
+ g
2150
+ ),
2151
+ children: /* @__PURE__ */ e(we, { size: 16, color: "currentColor" })
2152
+ }
2153
+ ),
2154
+ /* @__PURE__ */ e("h2", { className: "text-2xl font-semibold truncate", children: r })
2155
+ ] }) }),
2156
+ a.length > 0 && /* @__PURE__ */ e("div", { className: "flex flex-wrap sm:flex-nowrap gap-2 sm:gap-3", children: a.map((f) => /* @__PURE__ */ c(
2157
+ "button",
2158
+ {
2159
+ onClick: (i) => {
2160
+ i.stopPropagation(), i.target.blur(), f.onClick();
2161
+ },
2162
+ disabled: f.disabled,
2163
+ className: p("btn", {
2164
+ o__primary: f.variant === "primary",
2165
+ o__secondary: f.variant === "secondary" || f.variant === "outline",
2166
+ o__ghost: f.variant === "ghost",
2167
+ o__destructive: f.variant === "destructive"
2168
+ }),
2169
+ children: [
2170
+ f.icon && /* @__PURE__ */ e("span", { className: "mr-2", children: f.icon }),
2171
+ f.label
2172
+ ]
2173
+ },
2174
+ f.id
2175
+ )) })
2176
+ ] }),
2177
+ t && /* @__PURE__ */ e("div", { className: "mt-4", children: t })
2178
+ ]
2179
+ }
2180
+ ), Re = () => /* @__PURE__ */ e("svg", { className: "h-4 w-4", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ e("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "m21 21-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z" }) }), Ke = ({ active: r }) => /* @__PURE__ */ e("svg", { className: p("h-3 w-3", r ? "text-neutral-900 dark:text-neutral-100" : "text-neutral-400"), fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ e("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "m18 15-6-6-6 6" }) }), Qe = ({ active: r }) => /* @__PURE__ */ e("svg", { className: p("h-3 w-3", r ? "text-neutral-900 dark:text-neutral-100" : "text-neutral-400"), fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ e("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "m6 9 6 6 6-6" }) }), Xe = () => /* @__PURE__ */ e("svg", { className: "h-4 w-4", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ e("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "m15 18-6-6 6-6" }) }), Ze = () => /* @__PURE__ */ e("svg", { className: "h-4 w-4", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ e("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "m9 18 6-6-6-6" }) }), Fe = () => /* @__PURE__ */ e("svg", { className: "h-4 w-4", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ e("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "m11 17-5-5 5-5m6 10-5-5 5-5" }) }), er = () => /* @__PURE__ */ e("svg", { className: "h-4 w-4", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ e("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "m7 17 5-5-5-5m6 10 5-5-5-5" }) }), pe = () => /* @__PURE__ */ e("svg", { className: "h-4 w-4", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ e("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "m6 9 6 6 6-6" }) }), rr = (r) => {
2181
+ var t, s, o, g;
2182
+ const n = (x) => {
2183
+ var f;
2184
+ return r.multiSelect && Array.isArray(r.value) ? (f = r.value) == null ? void 0 : f.includes(x) : r.value === x;
2185
+ }, a = (x) => {
2186
+ r.multiSelect && Array.isArray(r.value) ? r.onChange(r.value.filter((f) => f !== x)) : r.onChange(x);
2187
+ };
2188
+ return r.type === "date" ? /* @__PURE__ */ e("div", { className: "flex items-center space-x-1 max-w-[140px]", children: /* @__PURE__ */ e(
2189
+ he,
2190
+ {
2191
+ size: "sm",
2192
+ value: r.value,
2193
+ onChange: (x) => r.onChange(x),
2194
+ placeholder: r.placeholder || `Select ${r.label.toLowerCase()}`,
2195
+ className: "min-w-[160px] btn btn o__secondary"
2196
+ }
2197
+ ) }) : /* @__PURE__ */ e("div", { className: "flex items-center space-x-1 max-w-[240px]", children: /* @__PURE__ */ e("div", { className: "relative", children: /* @__PURE__ */ c("details", { className: "group", children: [
2198
+ /* @__PURE__ */ c("summary", { className: "flex items-center space-x-2 cursor-pointer hover:bg-white rounded-full px-3 py-2 text-sm btn btn o__secondary", children: [
2199
+ /* @__PURE__ */ e("span", { children: r.label }),
2200
+ /* @__PURE__ */ e("span", { className: "text-gray-800", children: r.multiSelect && Array.isArray(r.value) ? (t = r.value) == null ? void 0 : t.map((x) => {
2201
+ var f, i;
2202
+ return (i = (f = r.options) == null ? void 0 : f.find((w) => w.value === x)) == null ? void 0 : i.label;
2203
+ }).join(", ") : (o = (s = r.options) == null ? void 0 : s.find((x) => x.value === r.value)) == null ? void 0 : o.label }),
2204
+ /* @__PURE__ */ e("span", { className: "text-gray-500 text-sm group-open:rotate-180 transition-transform", children: /* @__PURE__ */ e(pe, {}) })
2205
+ ] }),
2206
+ /* @__PURE__ */ c("div", { className: "absolute z-10 left-0 mt-1 bg-white border border-gray-100 rounded-lg shadow-sm p-2 w-48", children: [
2207
+ (g = r.options) == null ? void 0 : g.map((x) => /* @__PURE__ */ e("button", { className: "w-full text-left px-3 py-2 rounded-md hover:bg-gray-50 text-sm text-gray-700 flex items-center space-x-2", onClick: () => a(x.value), children: /* @__PURE__ */ e("span", { className: p(n(x.value) && "text-primary-500"), children: x.label }) }, x.value)),
2208
+ r.value && /* @__PURE__ */ e("button", { className: "w-full text-left px-3 py-2 rounded-md hover:bg-gray-50 text-sm text-gray-700 flex items-center space-x-2 mt-2", onClick: () => a(null), children: /* @__PURE__ */ e("span", { className: "text-gray-400 dark:text-gray-600", children: "Clear filter" }) })
2209
+ ] })
2210
+ ] }) }) });
2211
+ }, Mr = ({
2212
+ data: r,
2213
+ columns: n,
2214
+ loading: a = !1,
2215
+ searchable: t = !1,
2216
+ searchPlaceholder: s = "Search...",
2217
+ filters: o = [],
2218
+ paginated: g = !1,
2219
+ pageSizeOptions: x = [10, 25, 50, 100],
2220
+ defaultPageSize: f = 10,
2221
+ actions: i = [],
2222
+ onRowClick: w,
2223
+ selectable: d = !1,
2224
+ selectedRows: u = [],
2225
+ onSelectionChange: k,
2226
+ getRowKey: b = (z, I) => I,
2227
+ emptyContent: C,
2228
+ hoverable: M = !0,
2229
+ bordered: V = !1,
2230
+ striped: $ = !1,
2231
+ className: J,
2232
+ rowClassName: H
2233
+ }) => {
2234
+ const [z, I] = q(""), [P, G] = q({ column: null, direction: null }), [S, y] = q({
2235
+ page: 0,
2236
+ pageSize: f
2237
+ }), l = re(null), v = ie(() => {
2238
+ let m = r;
2239
+ if (t && z.trim()) {
2240
+ const j = n.filter((B) => B.searchable !== !1), L = z.toLowerCase();
2241
+ m = m.filter((B) => j.some((D) => {
2242
+ const O = typeof D.accessor == "function" ? D.accessor(B) : B[D.accessor];
2243
+ return String(O || "").toLowerCase().includes(L);
2244
+ }));
2245
+ }
2246
+ return o.forEach((j) => {
2247
+ j.value && j.value !== "all" && (m = m.filter((L) => {
2248
+ const B = n.find((O) => O.id === j.id);
2249
+ if (!B) return !0;
2250
+ const D = typeof B.accessor == "function" ? B.accessor(L) : L[B.accessor];
2251
+ return String(D || "") === j.value;
2252
+ }));
2253
+ }), m;
2254
+ }, [r, z, n, t, o]), N = ie(() => {
2255
+ if (!P.column || !P.direction) return v;
2256
+ const m = n.find((j) => j.id === P.column);
2257
+ return m ? [...v].sort((j, L) => {
2258
+ const B = typeof m.accessor == "function" ? m.accessor(j) : j[m.accessor], D = typeof m.accessor == "function" ? m.accessor(L) : L[m.accessor];
2259
+ let O = 0;
2260
+ return B < D ? O = -1 : B > D && (O = 1), P.direction === "desc" ? -O : O;
2261
+ }) : v;
2262
+ }, [v, P, n]), h = ie(() => {
2263
+ if (!g) return N;
2264
+ const m = S.page * S.pageSize, j = m + S.pageSize;
2265
+ return N.slice(m, j);
2266
+ }, [N, S, g]), A = ee((m) => {
2267
+ const j = n.find((L) => L.id === m);
2268
+ j != null && j.sortable && G((L) => L.column !== m ? { column: m, direction: "asc" } : L.direction === "asc" ? { column: m, direction: "desc" } : { column: null, direction: null });
2269
+ }, [n]), _ = ee((m) => {
2270
+ y((j) => ({ ...j, page: m }));
2271
+ }, []), Q = ee((m) => {
2272
+ y({ page: 0, pageSize: m });
2273
+ }, []), T = ee((m, j) => {
2274
+ if (!k) return;
2275
+ const L = b(m, 0);
2276
+ u.map((B, D) => b(B, D)), k(j ? [...u, m] : u.filter((B, D) => b(u[D], D) !== L));
2277
+ }, [u, k, b]), Z = ee((m) => {
2278
+ k && k(m ? [...h] : []);
2279
+ }, [h, k]);
2280
+ K(() => {
2281
+ y((m) => ({ ...m, page: 0 }));
2282
+ }, [z, P]), K(() => {
2283
+ y((m) => ({ ...m, page: 0 }));
2284
+ }, [o.map((m) => m.value).join(",")]);
2285
+ const U = N.length, X = Math.ceil(U / S.pageSize), R = S.page * S.pageSize + 1, W = Math.min(R + S.pageSize - 1, U), Y = h.length > 0 && h.every((m) => {
2286
+ const j = b(m, 0);
2287
+ return u.some((L, B) => b(L, B) === j);
2288
+ }), ae = h.some((m) => {
2289
+ const j = b(m, 0);
2290
+ return u.some((L, B) => b(L, B) === j);
2291
+ }), E = p(
2292
+ "w-full text-sm leading-5 text-[var(--text-default)] border-collapse",
2293
+ J
2294
+ ), ne = p(
2295
+ "bg-[var(--base-module)]"
2296
+ ), F = p(
2297
+ "text-[var(--text-default)] dark:text-[var(--text-on-neutral)] truncate p-3 border-b border-[var(--neutral-border)]"
2298
+ ), se = p(
2299
+ "h-12",
2300
+ {
2301
+ "hover:bg-[var(--neutral-container)] dark:hover:bg-[var(--neutral-container-emphasis)]": M,
2302
+ "cursor-pointer": w
2303
+ }
2304
+ );
2305
+ return /* @__PURE__ */ c("div", { className: "space-y-4", children: [
2306
+ (t || o.length > 0) && /* @__PURE__ */ e("div", { className: "pt-4 pb-2", children: /* @__PURE__ */ c("div", { className: "flex flex-wrap gap-4 items-start", children: [
2307
+ o.map((m) => /* @__PURE__ */ e(rr, { ...m }, m.id)),
2308
+ /* @__PURE__ */ e("div", { className: "w-full sm:w-auto sm:ml-auto min-w-[200px]", children: /* @__PURE__ */ e(
2309
+ oe,
2310
+ {
2311
+ placeholder: s,
2312
+ value: z,
2313
+ onChange: (m) => I(m.target.value),
2314
+ startIcon: /* @__PURE__ */ e(Re, {}),
2315
+ className: "max-w-sm"
2316
+ }
2317
+ ) })
2318
+ ] }) }),
2319
+ /* @__PURE__ */ c("div", { className: "relative w-full overflow-x-auto min-h-[400px]", children: [
2320
+ a && /* @__PURE__ */ e("div", { className: "flex items-center justify-center z-10", children: /* @__PURE__ */ e(Oe, { showTableSkeleton: !0, tableRows: 10, tableColumns: n.length }) }),
2321
+ /* @__PURE__ */ c("table", { ref: l, className: p(E, "min-w-full"), children: [
2322
+ /* @__PURE__ */ e("thead", { className: ne, children: /* @__PURE__ */ c("tr", { children: [
2323
+ d && /* @__PURE__ */ e("th", { className: p(F, "w-12"), children: /* @__PURE__ */ e(
2324
+ "input",
2325
+ {
2326
+ type: "checkbox",
2327
+ checked: Y,
2328
+ ref: (m) => {
2329
+ m && (m.indeterminate = ae && !Y);
2330
+ },
2331
+ onChange: (m) => Z(m.target.checked),
2332
+ className: "rounded border-neutral-300 dark:border-neutral-600"
2333
+ }
2334
+ ) }),
2335
+ !a && n.map((m) => /* @__PURE__ */ e(
2336
+ "th",
2337
+ {
2338
+ className: p(
2339
+ F,
2340
+ "font-semibold text-xs text-[var(--text-muted)] dark:text-[var(--text-muted)] uppercase tracking-wider",
2341
+ "group",
2342
+ {
2343
+ "text-left": m.align === "left" || !m.align,
2344
+ "text-center": m.align === "center",
2345
+ "text-right": m.align === "right",
2346
+ "cursor-pointer select-none": m.sortable,
2347
+ "sticky left-0 bg-white dark:bg-neutral-900": m.sticky === "left",
2348
+ "sticky right-0 bg-white dark:bg-neutral-900": m.sticky === "right"
2349
+ }
2350
+ ),
2351
+ style: { width: m.width },
2352
+ onClick: () => m.sortable && A(m.id),
2353
+ children: /* @__PURE__ */ c("div", { className: "flex items-center gap-2", children: [
2354
+ m.headerCell ? m.headerCell() : m.header,
2355
+ m.sortable && /* @__PURE__ */ c("div", { className: p(
2356
+ "flex flex-col opacity-0 group-hover:opacity-100 transition-opacity",
2357
+ P.column === m.id && "opacity-100"
2358
+ ), children: [
2359
+ /* @__PURE__ */ e(Ke, { active: P.column === m.id && P.direction === "asc" }),
2360
+ /* @__PURE__ */ e(Qe, { active: P.column === m.id && P.direction === "desc" })
2361
+ ] })
2362
+ ] })
2363
+ },
2364
+ m.id
2365
+ )),
2366
+ i.length > 0 && /* @__PURE__ */ e("th", { className: p(F, "w-20"), children: /* @__PURE__ */ e("span", { className: "sr-only", children: "Actions" }) })
2367
+ ] }) }),
2368
+ /* @__PURE__ */ e("tbody", { children: h.length === 0 || a ? !a && /* @__PURE__ */ e("tr", { children: /* @__PURE__ */ e(
2369
+ "td",
2370
+ {
2371
+ colSpan: n.length + (d ? 1 : 0) + (i.length > 0 ? 1 : 0),
2372
+ className: p(F, "text-center py-8 text-neutral-500 dark:text-neutral-400"),
2373
+ children: C || "No data available"
2374
+ }
2375
+ ) }) : h.map((m, j) => {
2376
+ const L = b(m, j), B = u.some(
2377
+ (D, O) => b(D, O) === L
2378
+ );
2379
+ return /* @__PURE__ */ c(
2380
+ "tr",
2381
+ {
2382
+ className: p(
2383
+ se,
2384
+ { "bg-blue-50 dark:bg-blue-900/20": B },
2385
+ H == null ? void 0 : H(m, j)
2386
+ ),
2387
+ onClick: (D) => {
2388
+ D.stopPropagation(), w == null || w(m, j);
2389
+ },
2390
+ children: [
2391
+ d && /* @__PURE__ */ e("td", { className: F, children: /* @__PURE__ */ e(
2392
+ "input",
2393
+ {
2394
+ type: "checkbox",
2395
+ checked: B,
2396
+ onChange: (D) => {
2397
+ D.stopPropagation(), T(m, D.target.checked);
2398
+ },
2399
+ className: "rounded border-neutral-300 dark:border-neutral-600"
2400
+ }
2401
+ ) }),
2402
+ n.map((D) => {
2403
+ const O = typeof D.accessor == "function" ? D.accessor(m) : m[D.accessor];
2404
+ return /* @__PURE__ */ e(
2405
+ "td",
2406
+ {
2407
+ className: p(
2408
+ F,
2409
+ {
2410
+ "text-left": D.align === "left" || !D.align,
2411
+ "text-center": D.align === "center",
2412
+ "text-right": D.align === "right",
2413
+ "sticky left-0 bg-white dark:bg-neutral-900": D.sticky === "left",
2414
+ "sticky right-0 bg-white dark:bg-neutral-900": D.sticky === "right"
2415
+ }
2416
+ ),
2417
+ children: D.cell ? D.cell(O, m, j) : String(O || "")
2418
+ },
2419
+ D.id
2420
+ );
2421
+ }),
2422
+ i.length > 0 && /* @__PURE__ */ e("td", { className: F, children: /* @__PURE__ */ e(
2423
+ ze,
2424
+ {
2425
+ trigger: /* @__PURE__ */ c("div", { className: "inline-flex items-center gap-1 px-2 py-1 text-sm text-neutral-600 dark:text-neutral-400 hover:text-neutral-900 dark:hover:text-neutral-100", children: [
2426
+ /* @__PURE__ */ e("span", { children: "Options" }),
2427
+ /* @__PURE__ */ e(pe, {})
2428
+ ] }),
2429
+ options: i.map((D) => {
2430
+ var O;
2431
+ return {
2432
+ value: D.id,
2433
+ label: D.label,
2434
+ icon: D.icon,
2435
+ disabled: (O = D.disabled) == null ? void 0 : O.call(D, m)
2436
+ };
2437
+ }),
2438
+ onSelect: (D) => {
2439
+ const O = i.find((ye) => ye.id === D);
2440
+ O && O.onClick(m, j);
2441
+ },
2442
+ placement: "bottom-end"
2443
+ }
2444
+ ) })
2445
+ ]
2446
+ },
2447
+ L
2448
+ );
2449
+ }) })
2450
+ ] })
2451
+ ] }),
2452
+ g && U > 0 && /* @__PURE__ */ c("div", { className: "flex items-center justify-between px-6", children: [
2453
+ /* @__PURE__ */ c("div", { className: "flex items-center gap-4", children: [
2454
+ /* @__PURE__ */ c("span", { className: "text-sm text-neutral-600 dark:text-neutral-400", children: [
2455
+ "Showing ",
2456
+ R,
2457
+ " to ",
2458
+ W,
2459
+ " of ",
2460
+ U,
2461
+ " results"
2462
+ ] }),
2463
+ /* @__PURE__ */ c("div", { className: "flex items-center gap-2", children: [
2464
+ /* @__PURE__ */ e("span", { className: "text-sm text-neutral-600 dark:text-neutral-400", children: "Rows per page:" }),
2465
+ /* @__PURE__ */ e(
2466
+ "select",
2467
+ {
2468
+ value: S.pageSize,
2469
+ onChange: (m) => Q(Number(m.target.value)),
2470
+ className: "border border-[var(--neutral-border)] text-[var(--text-default)] dark:text-[var(--text-on-neutral)] rounded-md px-2 py-1 text-sm bg-[var(--base-input)] dark:bg-[var(--base-input)] w-16",
2471
+ children: x.map((m) => /* @__PURE__ */ e("option", { value: m, children: m }, m))
2472
+ }
2473
+ )
2474
+ ] })
2475
+ ] }),
2476
+ /* @__PURE__ */ c("div", { className: "flex items-center gap-1", children: [
2477
+ /* @__PURE__ */ e(
2478
+ te,
2479
+ {
2480
+ size: "sm",
2481
+ variant: "ghost",
2482
+ onClick: () => _(0),
2483
+ disabled: S.page === 0,
2484
+ iconOnly: !0,
2485
+ children: /* @__PURE__ */ e(Fe, {})
2486
+ }
2487
+ ),
2488
+ /* @__PURE__ */ e(
2489
+ te,
2490
+ {
2491
+ size: "sm",
2492
+ variant: "ghost",
2493
+ onClick: () => _(S.page - 1),
2494
+ disabled: S.page === 0,
2495
+ iconOnly: !0,
2496
+ children: /* @__PURE__ */ e(Xe, {})
2497
+ }
2498
+ ),
2499
+ /* @__PURE__ */ c("span", { className: "px-3 py-1 text-sm text-gray-500 dark:text-gray-400", children: [
2500
+ "Page ",
2501
+ S.page + 1,
2502
+ " of ",
2503
+ X
2504
+ ] }),
2505
+ /* @__PURE__ */ e(
2506
+ te,
2507
+ {
2508
+ size: "sm",
2509
+ variant: "ghost",
2510
+ onClick: () => _(S.page + 1),
2511
+ disabled: S.page >= X - 1,
2512
+ iconOnly: !0,
2513
+ children: /* @__PURE__ */ e(Ze, {})
2514
+ }
2515
+ ),
2516
+ /* @__PURE__ */ e(
2517
+ te,
2518
+ {
2519
+ size: "sm",
2520
+ variant: "ghost",
2521
+ onClick: () => _(X - 1),
2522
+ disabled: S.page >= X - 1,
2523
+ iconOnly: !0,
2524
+ children: /* @__PURE__ */ e(er, {})
2525
+ }
2526
+ )
2527
+ ] })
2528
+ ] })
2529
+ ] });
2530
+ }, ge = ({ item: r, isSelectedHandler: n, onClick: a }) => {
2531
+ var f;
2532
+ const [t, s] = q(!1), o = r.children && r.children.length > 0, g = () => {
2533
+ o && s(!t);
2534
+ }, x = n ? n(r.path) : !1;
2535
+ return /* @__PURE__ */ c("li", { children: [
2536
+ /* @__PURE__ */ c(
2537
+ "div",
2538
+ {
2539
+ className: p(
2540
+ "flex flex-row w-full py-1 rounded-lg items-center h-8 transition-colors cursor-pointer px-3 pr-1 no-underline text-sm",
2541
+ {
2542
+ "active-nav-item": x,
2543
+ "shadow-lvl-0": x,
2544
+ "font-semibold": x || o || r.children !== void 0
2545
+ }
2546
+ ),
2547
+ onClick: () => {
2548
+ o ? g() : r.path && (a == null || a(r.path));
2549
+ },
2550
+ children: [
2551
+ r.icon && /* @__PURE__ */ e("span", { className: "mr-2", children: r.icon }),
2552
+ /* @__PURE__ */ e("span", { className: "flex-1", children: r.label }),
2553
+ r.count !== void 0 && r.count > 0 && /* @__PURE__ */ e("span", { className: "ml-2 mr-1.5", children: r.count }),
2554
+ o && /* @__PURE__ */ e("span", { className: `${t ? "collapsed" : ""}`, children: /* @__PURE__ */ e(Ce, { className: "w-4 h-4 text-gray-300" }) })
2555
+ ]
2556
+ }
2557
+ ),
2558
+ o && !t && /* @__PURE__ */ e("ul", { className: "sidebar-menu-nested-items", children: (f = r.children) == null ? void 0 : f.map((i, w) => /* @__PURE__ */ e(
2559
+ ge,
2560
+ {
2561
+ item: i,
2562
+ isSelectedHandler: n,
2563
+ onClick: a
2564
+ },
2565
+ w
2566
+ )) })
2567
+ ] });
2568
+ }, Lr = ({
2569
+ title: r,
2570
+ actionIcons: n,
2571
+ items: a,
2572
+ isSelectedHandler: t,
2573
+ onClick: s
2574
+ }) => /* @__PURE__ */ c("div", { className: "flex flex-col h-screen mb-6", children: [
2575
+ /* @__PURE__ */ c("div", { className: "sidebar-menu-header", children: [
2576
+ /* @__PURE__ */ e("span", { className: "text-xl font-semibold text-gray-800 mb-2", children: r }),
2577
+ /* @__PURE__ */ e("div", { className: "sidebar-menu-actions", children: n == null ? void 0 : n.map((o, g) => /* @__PURE__ */ e("span", { className: "sidebar-menu-action-icon", children: o }, g)) })
2578
+ ] }),
2579
+ /* @__PURE__ */ e("ul", { children: a.map(
2580
+ (o, g) => !o.path && !o.label && !o.children ? /* @__PURE__ */ e("span", { className: "flex w-full h-4" }, g) : /* @__PURE__ */ e(
2581
+ ge,
2582
+ {
2583
+ item: o,
2584
+ isSelectedHandler: t,
2585
+ onClick: s
2586
+ },
2587
+ g
2588
+ )
2589
+ ) })
2590
+ ] }), tr = Ne(null), Dr = ({
2591
+ items: r,
2592
+ activeTab: n,
2593
+ onTabChange: a,
2594
+ className: t
2595
+ }) => {
2596
+ var f;
2597
+ const [s, o] = q(((f = r[0]) == null ? void 0 : f.id) || ""), g = n || s, x = (i) => {
2598
+ a ? a(i) : o(i);
2599
+ };
2600
+ return /* @__PURE__ */ e("div", { className: p("border-b border-neutral-200 dark:border-neutral-700", t), children: /* @__PURE__ */ e("nav", { className: "-mb-px flex space-x-8", children: r.map((i) => /* @__PURE__ */ e(
2601
+ "button",
2602
+ {
2603
+ onClick: () => !i.disabled && x(i.id),
2604
+ disabled: i.disabled,
2605
+ className: p(
2606
+ "border-b-2 py-2 px-1 text-sm font-medium transition-colors duration-200",
2607
+ {
2608
+ "border-primary text-primary": g === i.id,
2609
+ "border-transparent text-neutral-500 hover:text-neutral-700 dark:text-neutral-400 dark:hover:text-neutral-300": g !== i.id && !i.disabled,
2610
+ "border-transparent text-neutral-300 cursor-not-allowed dark:text-neutral-600": i.disabled
2611
+ }
2612
+ ),
2613
+ children: /* @__PURE__ */ c("span", { className: "flex items-center gap-2", children: [
2614
+ i.label,
2615
+ i.badge && /* @__PURE__ */ e("span", { className: p(
2616
+ "inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium",
2617
+ g === i.id ? "bg-primary/10 text-primary" : "bg-neutral-100 text-neutral-600 dark:bg-neutral-800 dark:text-neutral-400"
2618
+ ), children: i.badge })
2619
+ ] })
2620
+ },
2621
+ i.id
2622
+ )) }) });
2623
+ }, Er = ({
2624
+ items: r,
2625
+ defaultTab: n,
2626
+ activeTab: a,
2627
+ onTabChange: t,
2628
+ variant: s = "default",
2629
+ size: o = "md",
2630
+ className: g
2631
+ }) => {
2632
+ var C;
2633
+ const [x, f] = q(
2634
+ n || a || ((C = r[0]) == null ? void 0 : C.id) || ""
2635
+ ), i = a || x, w = (M) => {
2636
+ t ? t(M) : f(M);
2637
+ }, d = {
2638
+ activeTab: i,
2639
+ setActiveTab: w
2640
+ }, u = r.find((M) => M.id === i), k = p(
2641
+ "flex",
2642
+ {
2643
+ "border-b border-neutral-200 dark:border-neutral-700": s === "default" || s === "underline",
2644
+ "bg-neutral-100 dark:bg-neutral-800 p-1 rounded-lg": s === "pills",
2645
+ "space-x-1": s === "pills",
2646
+ "space-x-8": s === "default" || s === "underline"
2647
+ },
2648
+ g
2649
+ ), b = (M, V) => {
2650
+ const $ = "transition-colors duration-200 font-medium", J = {
2651
+ "text-xs px-2 py-1": o === "sm",
2652
+ "text-sm px-3 py-2": o === "md",
2653
+ "text-base px-4 py-3": o === "lg"
2654
+ }, H = {
2655
+ // Default variant
2656
+ "border-b-2 -mb-px": s === "default",
2657
+ // Pills variant
2658
+ "rounded-md": s === "pills",
2659
+ // Underline variant
2660
+ "border-b-2 pb-2": s === "underline"
2661
+ }, z = {
2662
+ "opacity-50 cursor-not-allowed": M.disabled,
2663
+ "cursor-pointer": !M.disabled
2664
+ }, I = V ? {
2665
+ "border-primary text-primary": s === "default" || s === "underline",
2666
+ "bg-white dark:bg-neutral-700 text-neutral-900 dark:text-neutral-100 shadow-sm": s === "pills"
2667
+ } : {}, P = !V && !M.disabled ? {
2668
+ "border-transparent text-neutral-600 hover:text-neutral-900 dark:text-neutral-400 dark:hover:text-neutral-100": s === "default",
2669
+ "text-neutral-600 hover:text-neutral-900 dark:text-neutral-400 dark:hover:text-neutral-100": s === "pills",
2670
+ "border-transparent text-neutral-600 hover:text-neutral-900 hover:border-neutral-300 dark:text-neutral-400 dark:hover:text-neutral-100": s === "underline"
2671
+ } : {};
2672
+ return p($, J, H, z, I, P);
2673
+ };
2674
+ return /* @__PURE__ */ e(tr.Provider, { value: d, children: /* @__PURE__ */ c("div", { children: [
2675
+ /* @__PURE__ */ e("div", { className: k, role: "tablist", children: r.map((M) => /* @__PURE__ */ e(
2676
+ "button",
2677
+ {
2678
+ role: "tab",
2679
+ "aria-selected": i === M.id,
2680
+ "aria-controls": `tabpanel-${M.id}`,
2681
+ disabled: M.disabled,
2682
+ onClick: () => !M.disabled && w(M.id),
2683
+ className: b(M, i === M.id),
2684
+ children: /* @__PURE__ */ c("span", { className: "flex items-center gap-2", children: [
2685
+ M.label,
2686
+ M.badge && /* @__PURE__ */ e("span", { className: "inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium bg-neutral-200 text-neutral-700 dark:bg-neutral-700 dark:text-neutral-300", children: M.badge })
2687
+ ] })
2688
+ },
2689
+ M.id
2690
+ )) }),
2691
+ (u == null ? void 0 : u.content) && /* @__PURE__ */ e(
2692
+ "div",
2693
+ {
2694
+ role: "tabpanel",
2695
+ id: `tabpanel-${i}`,
2696
+ "aria-labelledby": `tab-${i}`,
2697
+ className: "mt-4",
2698
+ children: u.content
2699
+ }
2700
+ )
2701
+ ] }) });
2702
+ }, Ar = ({
2703
+ level: r = 1,
2704
+ size: n,
2705
+ weight: a = "bold",
2706
+ color: t = "current",
2707
+ align: s = "left",
2708
+ truncate: o = !1,
2709
+ className: g,
2710
+ children: x,
2711
+ ...f
2712
+ }) => {
2713
+ const i = n || ar(r), w = p(
2714
+ "font-primary",
2715
+ // Size variants
2716
+ {
2717
+ "text-xs": i === "xs",
2718
+ "text-sm": i === "sm",
2719
+ "text-base": i === "md",
2720
+ "text-lg": i === "lg",
2721
+ "text-xl": i === "xl",
2722
+ "text-2xl": i === "2xl",
2723
+ "text-3xl": i === "3xl",
2724
+ "text-4xl": i === "4xl"
2725
+ },
2726
+ // Weight variants
2727
+ {
2728
+ "font-light": a === "light",
2729
+ "font-normal": a === "normal",
2730
+ "font-medium": a === "medium",
2731
+ "font-semibold": a === "semibold",
2732
+ "font-bold": a === "bold"
2733
+ },
2734
+ // Color variants
2735
+ {
2736
+ "text-primary": t === "primary",
2737
+ "text-secondary": t === "secondary",
2738
+ "text-accent": t === "accent",
2739
+ "text-success": t === "success",
2740
+ "text-warning": t === "warning",
2741
+ "text-error": t === "error",
2742
+ "text-info": t === "info",
2743
+ "text-neutral": t === "neutral",
2744
+ "text-current": t === "current"
2745
+ },
2746
+ // Alignment
2747
+ {
2748
+ "text-left": s === "left",
2749
+ "text-center": s === "center",
2750
+ "text-right": s === "right"
2751
+ },
2752
+ // Truncation
2753
+ {
2754
+ truncate: o
2755
+ },
2756
+ g
2757
+ ), d = `h${r}`;
2758
+ return /* @__PURE__ */ e(d, { className: w, ...f, children: x });
2759
+ };
2760
+ function ar(r) {
2761
+ return {
2762
+ 1: "4xl",
2763
+ 2: "3xl",
2764
+ 3: "2xl",
2765
+ 4: "xl",
2766
+ 5: "lg",
2767
+ 6: "md"
2768
+ }[r] || "md";
2769
+ }
2770
+ const $r = ({
2771
+ items: r,
2772
+ type: n = "unordered",
2773
+ variant: a = "default",
2774
+ size: t = "md",
2775
+ interactive: s = !1,
2776
+ className: o,
2777
+ itemClassName: g
2778
+ }) => {
2779
+ const x = p(
2780
+ // Base styles
2781
+ "space-y-1",
2782
+ // Variant styles
2783
+ {
2784
+ // Default - basic spacing
2785
+ "": a === "default",
2786
+ // Flush - no padding
2787
+ "space-y-0": a === "flush",
2788
+ // Bordered - border around entire list
2789
+ "border border-neutral-200 dark:border-neutral-700 rounded-lg overflow-hidden": a === "bordered",
2790
+ // Divided - borders between items
2791
+ "divide-y divide-neutral-200 dark:divide-neutral-700": a === "divided"
2792
+ },
2793
+ // Size variants
2794
+ {
2795
+ "text-sm": t === "sm",
2796
+ "text-base": t === "md",
2797
+ "text-lg": t === "lg"
2798
+ },
2799
+ o
2800
+ ), f = (d, u) => p(
2801
+ // Base item styles
2802
+ "transition-colors duration-200",
2803
+ // Size-based padding
2804
+ {
2805
+ "py-1 px-2": t === "sm" && (a === "bordered" || a === "divided"),
2806
+ "py-2 px-3": t === "md" && (a === "bordered" || a === "divided"),
2807
+ "py-3 px-4": t === "lg" && (a === "bordered" || a === "divided")
2808
+ },
2809
+ // Interactive styles
2810
+ s && !d.disabled && {
2811
+ "cursor-pointer hover:bg-neutral-50 dark:hover:bg-neutral-800": !0,
2812
+ "focus:outline-none focus:bg-neutral-100 dark:focus:bg-neutral-700": !0
2813
+ },
2814
+ // Disabled styles
2815
+ d.disabled && {
2816
+ "opacity-50 cursor-not-allowed": !0
2817
+ },
2818
+ g
2819
+ ), i = (d) => {
2820
+ s && !d.disabled && d.onClick && d.onClick();
2821
+ }, w = (d, u) => {
2822
+ var k;
2823
+ s && !u.disabled && (d.key === "Enter" || d.key === " ") && (d.preventDefault(), (k = u.onClick) == null || k.call(u));
2824
+ };
2825
+ return n === "ordered" ? /* @__PURE__ */ e("ol", { className: x, children: r.map((d, u) => /* @__PURE__ */ e(
2826
+ "li",
2827
+ {
2828
+ className: f(d),
2829
+ onClick: () => i(d),
2830
+ onKeyDown: (k) => w(k, d),
2831
+ tabIndex: s && !d.disabled ? 0 : void 0,
2832
+ role: s ? "button" : void 0,
2833
+ children: d.content
2834
+ },
2835
+ d.id || u
2836
+ )) }) : n === "description" ? /* @__PURE__ */ e("dl", { className: x, children: r.map((d, u) => /* @__PURE__ */ e(
2837
+ "div",
2838
+ {
2839
+ className: f(d),
2840
+ onClick: () => i(d),
2841
+ onKeyDown: (k) => w(k, d),
2842
+ tabIndex: s && !d.disabled ? 0 : void 0,
2843
+ role: s ? "button" : void 0,
2844
+ children: d.content
2845
+ },
2846
+ d.id || u
2847
+ )) }) : /* @__PURE__ */ e("ul", { className: x, children: r.map((d, u) => /* @__PURE__ */ e(
2848
+ "li",
2849
+ {
2850
+ className: f(d),
2851
+ onClick: () => i(d),
2852
+ onKeyDown: (k) => w(k, d),
2853
+ tabIndex: s && !d.disabled ? 0 : void 0,
2854
+ role: s ? "button" : void 0,
2855
+ children: d.content
2856
+ },
2857
+ d.id || u
2858
+ )) });
2859
+ }, jr = ({
2860
+ commands: r,
2861
+ isOpen: n,
2862
+ onClose: a,
2863
+ labels: t
2864
+ }) => {
2865
+ var k;
2866
+ const [s, o] = q(""), [g, x] = q([]), [f, i] = q(0), w = re(null), u = (g.length ? ((k = r.find((b) => b.id === g[0])) == null ? void 0 : k.subCommands) || [] : r).filter(
2867
+ (b) => b.label.toLowerCase().includes(s.toLowerCase())
2868
+ );
2869
+ return K(() => {
2870
+ n || (o(""), x([]), i(0));
2871
+ }, [n]), K(() => {
2872
+ const b = (C) => {
2873
+ if (n) {
2874
+ if (C.key === "Escape")
2875
+ a();
2876
+ else if (C.key === "ArrowUp")
2877
+ i(
2878
+ (M) => M > 0 ? M - 1 : u.length - 1
2879
+ );
2880
+ else if (C.key === "ArrowDown")
2881
+ i(
2882
+ (M) => M < u.length - 1 ? M + 1 : 0
2883
+ );
2884
+ else if (C.key === "Enter") {
2885
+ const M = u[f];
2886
+ M && (M.subCommands ? (x([...g, M.id]), i(0)) : M.action && (M.action(), a()));
2887
+ }
2888
+ }
2889
+ };
2890
+ return document.addEventListener("keydown", b), () => document.removeEventListener("keydown", b);
2891
+ }, [n, a, u, f, g]), K(() => {
2892
+ const b = (C) => {
2893
+ w.current && !w.current.contains(C.target) && a();
2894
+ };
2895
+ return n && document.addEventListener("mousedown", b), () => document.removeEventListener("mousedown", b);
2896
+ }, [n, a]), n ? /* @__PURE__ */ e("div", { className: "fixed inset-0 z-50 flex items-center justify-center shadow-lvl-0", children: /* @__PURE__ */ c(
2897
+ "div",
2898
+ {
2899
+ className: "flex flex-col w-full max-w-lg p-2 mx-auto rounded-lg shadow-lg bg-white",
2900
+ ref: w,
2901
+ children: [
2902
+ /* @__PURE__ */ e(
2903
+ "input",
2904
+ {
2905
+ type: "text",
2906
+ placeholder: (t == null ? void 0 : t.searchPlaceholder) || "Search commands...",
2907
+ value: s,
2908
+ onChange: (b) => o(b.target.value),
2909
+ className: "w-full px-4 py-2 text-gray-800 border-none border-b border-gray-200 focus:outline-none focus:ring-0 rounded-lg bg-transparent"
2910
+ }
2911
+ ),
2912
+ /* @__PURE__ */ c("div", { className: "mt-2 pt-2 text-sm border-t border-gray-200", children: [
2913
+ u.length === 0 && /* @__PURE__ */ e("div", { className: "text-gray-500 text-center text-sm", children: (t == null ? void 0 : t.noCommandsFound) || "No commands found" }),
2914
+ u.map((b, C) => /* @__PURE__ */ c(
2915
+ "div",
2916
+ {
2917
+ className: `flex items-center p-2 cursor-pointer rounded-md text-secondary-800 ${C === f ? "bg-gray-100" : ""}`,
2918
+ onClick: () => {
2919
+ b.subCommands ? (x([...g, b.id]), i(0)) : b.action && (b.action(), a());
2920
+ },
2921
+ onMouseEnter: () => i(C),
2922
+ children: [
2923
+ b.icon && /* @__PURE__ */ e("span", { className: "mr-3", children: b.icon }),
2924
+ /* @__PURE__ */ e("span", { className: "flex-grow", children: b.label }),
2925
+ b.subCommands && /* @__PURE__ */ e("span", { className: "text-gray-400", children: /* @__PURE__ */ e(Se, { className: "w-4 h-4" }) })
2926
+ ]
2927
+ },
2928
+ b.id
2929
+ ))
2930
+ ] }),
2931
+ /* @__PURE__ */ c("div", { className: "flex items-center justify-between pt-2 mt-2 text-xs text-gray-500 border-t border-gray-200", children: [
2932
+ /* @__PURE__ */ c("span", { children: [
2933
+ /* @__PURE__ */ e("span", { className: "font-bold", children: "↑↓" }),
2934
+ " ",
2935
+ (t == null ? void 0 : t.navigate) || "to navigate"
2936
+ ] }),
2937
+ /* @__PURE__ */ c("span", { children: [
2938
+ /* @__PURE__ */ e("span", { className: "font-bold", children: "↵" }),
2939
+ " ",
2940
+ (t == null ? void 0 : t.select) || "to select"
2941
+ ] }),
2942
+ /* @__PURE__ */ c("span", { children: [
2943
+ /* @__PURE__ */ e("span", { className: "font-bold", children: "Esc" }),
2944
+ " ",
2945
+ (t == null ? void 0 : t.close) || "to close"
2946
+ ] })
2947
+ ] })
2948
+ ]
2949
+ }
2950
+ ) }) : null;
2951
+ }, nr = {
2952
+ none: "p-0",
2953
+ xs: "p-1",
2954
+ sm: "p-2",
2955
+ md: "p-4",
2956
+ lg: "p-6",
2957
+ xl: "p-8",
2958
+ "2xl": "p-12"
2959
+ }, sr = {
2960
+ none: "m-0",
2961
+ xs: "m-1",
2962
+ sm: "m-2",
2963
+ md: "m-4",
2964
+ lg: "m-6",
2965
+ xl: "m-8",
2966
+ "2xl": "m-12"
2967
+ }, lr = {
2968
+ none: "",
2969
+ primary: "bg-primary",
2970
+ secondary: "bg-secondary",
2971
+ accent: "bg-accent",
2972
+ success: "bg-success",
2973
+ warning: "bg-warning",
2974
+ error: "bg-error",
2975
+ info: "bg-info",
2976
+ neutral: "bg-neutral",
2977
+ white: "bg-white",
2978
+ module: "bg-module"
2979
+ }, dr = {
2980
+ none: "rounded-none",
2981
+ sm: "rounded-sm",
2982
+ md: "rounded-md",
2983
+ lg: "rounded-lg",
2984
+ xl: "rounded-xl",
2985
+ full: "rounded-full"
2986
+ }, cr = {
2987
+ none: "shadow-none",
2988
+ sm: "shadow-sm shadow-lvl-0",
2989
+ md: "shadow-md shadow-lvl-0",
2990
+ lg: "shadow-lg shadow-lvl-0",
2991
+ xl: "shadow-xl shadow-lvl-0",
2992
+ "2xl": "shadow-2xl shadow-lvl-0"
2993
+ }, or = {
2994
+ none: "border-0",
2995
+ sm: "border",
2996
+ md: "border-2",
2997
+ lg: "border-4"
2998
+ }, ir = {
2999
+ primary: "border-primary",
3000
+ secondary: "border-secondary",
3001
+ accent: "border-accent",
3002
+ success: "border-success",
3003
+ warning: "border-warning",
3004
+ error: "border-error",
3005
+ info: "border-info",
3006
+ neutral: "border-neutral",
3007
+ white: "border-white"
3008
+ }, be = de(
3009
+ ({
3010
+ padding: r,
3011
+ margin: n,
3012
+ background: a,
3013
+ radius: t,
3014
+ shadow: s,
3015
+ border: o,
3016
+ borderColor: g,
3017
+ className: x,
3018
+ children: f,
3019
+ ...i
3020
+ }, w) => /* @__PURE__ */ e(
3021
+ "div",
3022
+ {
3023
+ ref: w,
3024
+ className: p(
3025
+ r && nr[r],
3026
+ n && sr[n],
3027
+ a && lr[a],
3028
+ t && dr[t],
3029
+ s && cr[s],
3030
+ o && or[o],
3031
+ g && ir[g],
3032
+ x
3033
+ ),
3034
+ ...i,
3035
+ children: f
3036
+ }
3037
+ )
3038
+ );
3039
+ be.displayName = "Box";
3040
+ const Tr = ({ children: r, title: n, ...a }) => /* @__PURE__ */ c(be, { background: "module", radius: "xl", shadow: "sm", ...a, children: [
3041
+ n && /* @__PURE__ */ e("span", { className: "text-base font-medium text-gray-800 mb-2", children: n }),
3042
+ r
3043
+ ] });
3044
+ export {
3045
+ kr as Badge,
3046
+ be as Box,
3047
+ te as Button,
3048
+ gr as ButtonGroup,
3049
+ Tr as Card,
3050
+ me as Checkbox,
3051
+ jr as CommandPalette,
3052
+ Oe as ContentLoading,
3053
+ he as DatePicker,
3054
+ ze as Dropdown,
3055
+ yr as Form,
3056
+ Ar as Heading,
3057
+ wr as Icon,
3058
+ Cr as Image,
3059
+ br as Link,
3060
+ $r as List,
3061
+ vr as Modal,
3062
+ Sr as PageHeader,
3063
+ xe as Select,
3064
+ Lr as SidebarMenu,
3065
+ Nr as Spinner,
3066
+ Dr as TabBar,
3067
+ Mr as Table,
3068
+ Er as Tabs,
3069
+ le as Text,
3070
+ fe as TextArea,
3071
+ oe as TextField,
3072
+ p as cn,
3073
+ pr as createSizes,
3074
+ fr as createVariants
3075
+ };
3076
+ //# sourceMappingURL=index.js.map