@easyvision/easyvision-ui 1.3.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs ADDED
@@ -0,0 +1,2968 @@
1
+ 'use strict';
2
+
3
+ require('./easyvision-DCTYH6PP.css');
4
+ require('./EasyVisionTable-643DMWO4.css');
5
+ var React8 = require('react');
6
+ var lucideReact = require('lucide-react');
7
+ var clsx = require('clsx');
8
+ var tailwindMerge = require('tailwind-merge');
9
+ var jsxRuntime = require('react/jsx-runtime');
10
+ var vanilla = require('zustand/vanilla');
11
+ var SelectPrimitive = require('@radix-ui/react-select');
12
+ var reactSlot = require('@radix-ui/react-slot');
13
+ var classVarianceAuthority = require('class-variance-authority');
14
+ var PopoverPrimitive = require('@radix-ui/react-popover');
15
+ var reactIcons = require('@radix-ui/react-icons');
16
+ var cmdk = require('cmdk');
17
+ var CheckboxPrimitive = require('@radix-ui/react-checkbox');
18
+ var dateFns = require('date-fns');
19
+ var locale = require('date-fns/locale');
20
+ var reactDayPicker = require('react-day-picker');
21
+ var reactTable = require('@tanstack/react-table');
22
+ var DropdownMenuPrimitive = require('@radix-ui/react-dropdown-menu');
23
+
24
+ function _interopNamespace(e) {
25
+ if (e && e.__esModule) return e;
26
+ var n = Object.create(null);
27
+ if (e) {
28
+ Object.keys(e).forEach(function (k) {
29
+ if (k !== 'default') {
30
+ var d = Object.getOwnPropertyDescriptor(e, k);
31
+ Object.defineProperty(n, k, d.get ? d : {
32
+ enumerable: true,
33
+ get: function () { return e[k]; }
34
+ });
35
+ }
36
+ });
37
+ }
38
+ n.default = e;
39
+ return Object.freeze(n);
40
+ }
41
+
42
+ var React8__namespace = /*#__PURE__*/_interopNamespace(React8);
43
+ var SelectPrimitive__namespace = /*#__PURE__*/_interopNamespace(SelectPrimitive);
44
+ var PopoverPrimitive__namespace = /*#__PURE__*/_interopNamespace(PopoverPrimitive);
45
+ var CheckboxPrimitive__namespace = /*#__PURE__*/_interopNamespace(CheckboxPrimitive);
46
+ var DropdownMenuPrimitive__namespace = /*#__PURE__*/_interopNamespace(DropdownMenuPrimitive);
47
+
48
+ // index.ts
49
+ function cn(...inputs) {
50
+ return tailwindMerge.twMerge(clsx.clsx(inputs));
51
+ }
52
+ var Input = React8__namespace.forwardRef(
53
+ ({ className, type, ...props }, ref) => {
54
+ return /* @__PURE__ */ jsxRuntime.jsx(
55
+ "input",
56
+ {
57
+ type,
58
+ className: cn(
59
+ "flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",
60
+ className
61
+ ),
62
+ ref,
63
+ ...props
64
+ }
65
+ );
66
+ }
67
+ );
68
+ Input.displayName = "Input";
69
+ var easyVisionRegistry = vanilla.createStore((set, get) => ({
70
+ slices: {},
71
+ ensure: (_kind, fullId, init) => {
72
+ const existing = get().slices[fullId];
73
+ if (existing) return existing;
74
+ const created = init();
75
+ set((s) => ({ slices: { ...s.slices, [fullId]: created } }));
76
+ return created;
77
+ },
78
+ patch: (fullId, partial) => {
79
+ set((s) => {
80
+ const current = s.slices[fullId];
81
+ if (!current) return s;
82
+ return {
83
+ slices: {
84
+ ...s.slices,
85
+ [fullId]: { ...current, ...partial }
86
+ }
87
+ };
88
+ });
89
+ },
90
+ drop: (fullId) => {
91
+ set((s) => {
92
+ const next = {};
93
+ const prefix = `${fullId}.`;
94
+ for (const key of Object.keys(s.slices)) {
95
+ if (key !== fullId && !key.startsWith(prefix)) {
96
+ next[key] = s.slices[key];
97
+ }
98
+ }
99
+ return { slices: next };
100
+ });
101
+ },
102
+ reset: () => set({ slices: {} })
103
+ }));
104
+ var getSlice = (fullId) => easyVisionRegistry.getState().slices[fullId];
105
+
106
+ // store/slice-types.ts
107
+ var KIND_SUFFIX = {
108
+ input: "-input",
109
+ selector: "-selector",
110
+ multifilter: "-multifilter",
111
+ table: "-table"
112
+ };
113
+
114
+ // store/namespace.ts
115
+ var fullIdOf = (id, kind) => `${id}${KIND_SUFFIX[kind]}`;
116
+ var childIdOf = (parentFullId, childLocalId) => `${parentFullId}.${childLocalId}`;
117
+ var childFullIdOf = (parentFullId, childLocalId, childKind) => parentFullId ? `${childIdOf(parentFullId, childLocalId)}${KIND_SUFFIX[childKind]}` : fullIdOf(childLocalId, childKind);
118
+ var NamespaceContext = React8.createContext(null);
119
+ function NamespaceProvider({
120
+ fullId,
121
+ children
122
+ }) {
123
+ return /* @__PURE__ */ jsxRuntime.jsx(NamespaceContext.Provider, { value: fullId, children });
124
+ }
125
+ var useParentFullId = () => React8.useContext(NamespaceContext);
126
+
127
+ // store/useEasyVisionSlice.ts
128
+ function useEasyVisionSlice(kind, localId, opts) {
129
+ const parentFullId = useParentFullId();
130
+ const fullId = React8.useMemo(
131
+ () => childFullIdOf(parentFullId, localId, kind),
132
+ [parentFullId, localId, kind]
133
+ );
134
+ if (!easyVisionRegistry.getState().slices[fullId]) {
135
+ easyVisionRegistry.getState().ensure(kind, fullId, opts.init);
136
+ }
137
+ const slice = React8.useSyncExternalStore(
138
+ easyVisionRegistry.subscribe,
139
+ () => {
140
+ const s = easyVisionRegistry.getState().slices[fullId];
141
+ if (s) return s;
142
+ return easyVisionRegistry.getState().ensure(kind, fullId, opts.init);
143
+ },
144
+ () => easyVisionRegistry.getState().ensure(kind, fullId, opts.init)
145
+ );
146
+ React8.useEffect(() => {
147
+ if (opts.clearWhen && opts.clearWhen(slice)) {
148
+ easyVisionRegistry.getState().drop(fullId);
149
+ easyVisionRegistry.getState().ensure(kind, fullId, opts.init);
150
+ }
151
+ }, [slice, fullId, kind, opts]);
152
+ React8.useEffect(() => {
153
+ opts.onStateChange?.(slice);
154
+ }, [slice]);
155
+ React8.useEffect(() => {
156
+ return () => {
157
+ if (!opts.persist) {
158
+ easyVisionRegistry.getState().drop(fullId);
159
+ }
160
+ };
161
+ }, [fullId]);
162
+ const patch = React8.useMemo(
163
+ () => (partial) => easyVisionRegistry.getState().patch(fullId, partial),
164
+ [fullId]
165
+ );
166
+ const reset = React8.useMemo(
167
+ () => () => {
168
+ easyVisionRegistry.getState().drop(fullId);
169
+ easyVisionRegistry.getState().ensure(kind, fullId, opts.init);
170
+ },
171
+ [fullId, kind, opts]
172
+ );
173
+ return { fullId, slice, patch, reset };
174
+ }
175
+ function useDebouncedValue(value, delayMs) {
176
+ const [debounced, setDebounced] = React8.useState(value);
177
+ React8.useEffect(() => {
178
+ if (delayMs <= 0) {
179
+ setDebounced(value);
180
+ return;
181
+ }
182
+ const timer = setTimeout(() => setDebounced(value), delayMs);
183
+ return () => clearTimeout(timer);
184
+ }, [value, delayMs]);
185
+ return debounced;
186
+ }
187
+ function EasyVisionInput({
188
+ id,
189
+ label,
190
+ placeholder,
191
+ debounceMs = 300,
192
+ mandatory = false,
193
+ defaultValue = "",
194
+ onChange,
195
+ onStateChange,
196
+ icon = "none",
197
+ showClearButton = false,
198
+ className,
199
+ disabled = false,
200
+ persist = false,
201
+ clearWhen
202
+ }) {
203
+ const { slice, patch } = useEasyVisionSlice("input", id, {
204
+ init: () => ({ kind: "input", value: defaultValue }),
205
+ persist,
206
+ clearWhen: clearWhen ? (s) => clearWhen(s.value) : void 0,
207
+ onStateChange: onStateChange ? (s) => onStateChange(s.value) : void 0
208
+ });
209
+ const debounced = useDebouncedValue(slice.value, debounceMs);
210
+ const lastEmittedRef = React8.useRef(slice.value);
211
+ React8.useEffect(() => {
212
+ if (debounced !== lastEmittedRef.current) {
213
+ lastEmittedRef.current = debounced;
214
+ onChange?.(debounced);
215
+ }
216
+ }, [debounced, onChange]);
217
+ const isInvalid = mandatory && slice.value.trim().length === 0;
218
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `flex flex-col gap-1 ${className ?? ""}`, children: [
219
+ label && /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-xs font-medium text-muted-foreground", children: [
220
+ label,
221
+ mandatory && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "ml-0.5 text-destructive", children: "*" })
222
+ ] }),
223
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "relative", children: [
224
+ icon === "search" && /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Search, { className: "absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground pointer-events-none" }),
225
+ /* @__PURE__ */ jsxRuntime.jsx(
226
+ Input,
227
+ {
228
+ className: `h-9 ${icon === "search" ? "pl-9" : ""} ${showClearButton && slice.value ? "pr-9" : ""} ${isInvalid ? "border-destructive focus-visible:ring-destructive/40" : ""}`,
229
+ placeholder,
230
+ value: slice.value,
231
+ onChange: (e) => patch({ value: e.target.value }),
232
+ disabled
233
+ }
234
+ ),
235
+ showClearButton && slice.value && !disabled && /* @__PURE__ */ jsxRuntime.jsx(
236
+ "button",
237
+ {
238
+ type: "button",
239
+ onClick: () => patch({ value: "" }),
240
+ className: "absolute right-2 top-1/2 -translate-y-1/2 p-0.5 hover:bg-muted rounded",
241
+ children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.X, { className: "w-3.5 h-3.5 text-muted-foreground" })
242
+ }
243
+ )
244
+ ] })
245
+ ] });
246
+ }
247
+ var Select = SelectPrimitive__namespace.Root;
248
+ var SelectValue = SelectPrimitive__namespace.Value;
249
+ var SelectTrigger = React8__namespace.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsxs(
250
+ SelectPrimitive__namespace.Trigger,
251
+ {
252
+ ref,
253
+ className: cn(
254
+ "flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background data-[placeholder]:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",
255
+ className
256
+ ),
257
+ ...props,
258
+ children: [
259
+ children,
260
+ /* @__PURE__ */ jsxRuntime.jsx(SelectPrimitive__namespace.Icon, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronDown, { className: "h-4 w-4 opacity-50" }) })
261
+ ]
262
+ }
263
+ ));
264
+ SelectTrigger.displayName = SelectPrimitive__namespace.Trigger.displayName;
265
+ var SelectScrollUpButton = React8__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
266
+ SelectPrimitive__namespace.ScrollUpButton,
267
+ {
268
+ ref,
269
+ className: cn(
270
+ "flex cursor-default items-center justify-center py-1",
271
+ className
272
+ ),
273
+ ...props,
274
+ children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronUp, { className: "h-4 w-4" })
275
+ }
276
+ ));
277
+ SelectScrollUpButton.displayName = SelectPrimitive__namespace.ScrollUpButton.displayName;
278
+ var SelectScrollDownButton = React8__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
279
+ SelectPrimitive__namespace.ScrollDownButton,
280
+ {
281
+ ref,
282
+ className: cn(
283
+ "flex cursor-default items-center justify-center py-1",
284
+ className
285
+ ),
286
+ ...props,
287
+ children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronDown, { className: "h-4 w-4" })
288
+ }
289
+ ));
290
+ SelectScrollDownButton.displayName = SelectPrimitive__namespace.ScrollDownButton.displayName;
291
+ var SelectContent = React8__namespace.forwardRef(({ className, children, position = "popper", ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(SelectPrimitive__namespace.Portal, { children: /* @__PURE__ */ jsxRuntime.jsxs(
292
+ SelectPrimitive__namespace.Content,
293
+ {
294
+ ref,
295
+ className: cn(
296
+ "relative z-50 max-h-[--radix-select-content-available-height] min-w-[8rem] overflow-y-auto overflow-x-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-select-content-transform-origin]",
297
+ position === "popper" && "data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",
298
+ className
299
+ ),
300
+ position,
301
+ ...props,
302
+ children: [
303
+ /* @__PURE__ */ jsxRuntime.jsx(SelectScrollUpButton, {}),
304
+ /* @__PURE__ */ jsxRuntime.jsx(
305
+ SelectPrimitive__namespace.Viewport,
306
+ {
307
+ className: cn(
308
+ "p-1",
309
+ position === "popper" && "h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"
310
+ ),
311
+ children
312
+ }
313
+ ),
314
+ /* @__PURE__ */ jsxRuntime.jsx(SelectScrollDownButton, {})
315
+ ]
316
+ }
317
+ ) }));
318
+ SelectContent.displayName = SelectPrimitive__namespace.Content.displayName;
319
+ var SelectLabel = React8__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
320
+ SelectPrimitive__namespace.Label,
321
+ {
322
+ ref,
323
+ className: cn("py-1.5 pl-8 pr-2 text-sm font-semibold", className),
324
+ ...props
325
+ }
326
+ ));
327
+ SelectLabel.displayName = SelectPrimitive__namespace.Label.displayName;
328
+ var SelectItem = React8__namespace.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsxs(
329
+ SelectPrimitive__namespace.Item,
330
+ {
331
+ ref,
332
+ className: cn(
333
+ "relative flex w-full cursor-default select-none items-center rounded-md py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
334
+ className
335
+ ),
336
+ ...props,
337
+ children: [
338
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "absolute left-2 flex h-3.5 w-3.5 items-center justify-center", children: /* @__PURE__ */ jsxRuntime.jsx(SelectPrimitive__namespace.ItemIndicator, { children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Check, { className: "h-4 w-4" }) }) }),
339
+ /* @__PURE__ */ jsxRuntime.jsx(SelectPrimitive__namespace.ItemText, { children })
340
+ ]
341
+ }
342
+ ));
343
+ SelectItem.displayName = SelectPrimitive__namespace.Item.displayName;
344
+ var SelectSeparator = React8__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
345
+ SelectPrimitive__namespace.Separator,
346
+ {
347
+ ref,
348
+ className: cn("-mx-1 my-1 h-px bg-muted", className),
349
+ ...props
350
+ }
351
+ ));
352
+ SelectSeparator.displayName = SelectPrimitive__namespace.Separator.displayName;
353
+ var buttonVariants = classVarianceAuthority.cva(
354
+ "inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",
355
+ {
356
+ variants: {
357
+ variant: {
358
+ default: "bg-primary text-primary-foreground hover:bg-primary/90",
359
+ destructive: "bg-destructive text-destructive-foreground hover:bg-destructive/90",
360
+ outline: "border border-input bg-background hover:bg-accent hover:text-accent-foreground",
361
+ secondary: "bg-secondary text-secondary-foreground hover:bg-secondary/80",
362
+ ghost: "hover:bg-accent hover:text-accent-foreground",
363
+ link: "text-primary underline-offset-4 hover:underline"
364
+ },
365
+ size: {
366
+ default: "h-10 px-4 py-2",
367
+ sm: "h-9 rounded-md px-3",
368
+ lg: "h-11 rounded-md px-8",
369
+ icon: "h-10 w-10"
370
+ }
371
+ },
372
+ defaultVariants: {
373
+ variant: "default",
374
+ size: "default"
375
+ }
376
+ }
377
+ );
378
+ var Button = React8__namespace.forwardRef(
379
+ ({ className, variant, size, asChild = false, ...props }, ref) => {
380
+ const Comp = asChild ? reactSlot.Slot : "button";
381
+ return /* @__PURE__ */ jsxRuntime.jsx(
382
+ Comp,
383
+ {
384
+ className: cn(buttonVariants({ variant, size, className })),
385
+ ref,
386
+ ...props
387
+ }
388
+ );
389
+ }
390
+ );
391
+ Button.displayName = "Button";
392
+ var Popover = PopoverPrimitive__namespace.Root;
393
+ var PopoverTrigger = PopoverPrimitive__namespace.Trigger;
394
+ var PopoverContent = React8__namespace.forwardRef(({ className, align = "center", sideOffset = 4, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(PopoverPrimitive__namespace.Portal, { children: /* @__PURE__ */ jsxRuntime.jsx(
395
+ PopoverPrimitive__namespace.Content,
396
+ {
397
+ ref,
398
+ align,
399
+ sideOffset,
400
+ className: cn(
401
+ "z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-popover-content-transform-origin]",
402
+ className
403
+ ),
404
+ ...props
405
+ }
406
+ ) }));
407
+ PopoverContent.displayName = PopoverPrimitive__namespace.Content.displayName;
408
+ var Command = React8__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
409
+ cmdk.Command,
410
+ {
411
+ ref,
412
+ className: cn(
413
+ "flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",
414
+ className
415
+ ),
416
+ ...props
417
+ }
418
+ ));
419
+ Command.displayName = cmdk.Command.displayName;
420
+ var CommandInput = React8__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center border-b px-3", "cmdk-input-wrapper": "", children: [
421
+ /* @__PURE__ */ jsxRuntime.jsx(reactIcons.MagnifyingGlassIcon, { className: "mr-2 h-4 w-4 shrink-0 opacity-50" }),
422
+ /* @__PURE__ */ jsxRuntime.jsx(
423
+ cmdk.Command.Input,
424
+ {
425
+ ref,
426
+ className: cn(
427
+ "flex h-10 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",
428
+ className
429
+ ),
430
+ ...props
431
+ }
432
+ )
433
+ ] }));
434
+ CommandInput.displayName = cmdk.Command.Input.displayName;
435
+ var CommandList = React8__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
436
+ cmdk.Command.List,
437
+ {
438
+ ref,
439
+ className: cn("max-h-[300px] overflow-y-auto overflow-x-hidden", className),
440
+ ...props
441
+ }
442
+ ));
443
+ CommandList.displayName = cmdk.Command.List.displayName;
444
+ var CommandEmpty = React8__namespace.forwardRef((props, ref) => /* @__PURE__ */ jsxRuntime.jsx(
445
+ cmdk.Command.Empty,
446
+ {
447
+ ref,
448
+ className: "py-6 text-center text-sm",
449
+ ...props
450
+ }
451
+ ));
452
+ CommandEmpty.displayName = cmdk.Command.Empty.displayName;
453
+ var CommandGroup = React8__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
454
+ cmdk.Command.Group,
455
+ {
456
+ ref,
457
+ className: cn(
458
+ "overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",
459
+ className
460
+ ),
461
+ ...props
462
+ }
463
+ ));
464
+ CommandGroup.displayName = cmdk.Command.Group.displayName;
465
+ var CommandSeparator = React8__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
466
+ cmdk.Command.Separator,
467
+ {
468
+ ref,
469
+ className: cn("-mx-1 h-px bg-border", className),
470
+ ...props
471
+ }
472
+ ));
473
+ CommandSeparator.displayName = cmdk.Command.Separator.displayName;
474
+ var CommandItem = React8__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
475
+ cmdk.Command.Item,
476
+ {
477
+ ref,
478
+ className: cn(
479
+ "relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[disabled=true]:pointer-events-none data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground data-[disabled=true]:opacity-50",
480
+ className
481
+ ),
482
+ ...props
483
+ }
484
+ ));
485
+ CommandItem.displayName = cmdk.Command.Item.displayName;
486
+ var SENTINEL_UNDEFINED = "__easyvision_undef__";
487
+ function EasyVisionSelector({
488
+ id,
489
+ label,
490
+ options,
491
+ placeholder = "Seleccionar...",
492
+ mandatory = false,
493
+ defaultValue,
494
+ confirmMode = false,
495
+ confirmLabel = "Confirmar",
496
+ searchable = false,
497
+ onChange,
498
+ onStateChange,
499
+ className,
500
+ disabled = false,
501
+ persist = false,
502
+ clearWhen
503
+ }) {
504
+ const { slice, patch } = useEasyVisionSlice("selector", id, {
505
+ init: () => ({ kind: "selector", value: defaultValue }),
506
+ persist,
507
+ clearWhen: clearWhen ? (s) => clearWhen(s.value) : void 0,
508
+ onStateChange: onStateChange ? (s) => onStateChange(s.value) : void 0
509
+ });
510
+ const value = slice.value;
511
+ const [resolved, setResolved] = React8.useState(
512
+ Array.isArray(options) ? options : null
513
+ );
514
+ React8.useEffect(() => {
515
+ if (typeof options === "function" && resolved === null) {
516
+ void options().then(setResolved).catch(() => setResolved([]));
517
+ } else if (Array.isArray(options)) {
518
+ setResolved(options);
519
+ }
520
+ }, [options, resolved]);
521
+ const opts = resolved ?? [];
522
+ const [pending, setPending] = React8.useState(value);
523
+ React8.useEffect(() => setPending(value), [value]);
524
+ const lastEmittedRef = React8.useRef(value);
525
+ React8.useEffect(() => {
526
+ if (value !== lastEmittedRef.current) {
527
+ lastEmittedRef.current = value;
528
+ onChange?.(value);
529
+ }
530
+ }, [value, onChange]);
531
+ const isInvalid = mandatory && (value === void 0 || value === "");
532
+ const commit = (v) => patch({ value: v });
533
+ const triggerClasses = `${isInvalid ? "border-destructive focus-visible:ring-destructive/40" : ""} ${className ?? ""}`;
534
+ if (searchable) {
535
+ const labelOf = (v) => opts.find((o) => o.value === v)?.label ?? "";
536
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-1", children: [
537
+ label && /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-xs font-medium text-muted-foreground", children: [
538
+ label,
539
+ mandatory && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "ml-0.5 text-destructive", children: "*" })
540
+ ] }),
541
+ /* @__PURE__ */ jsxRuntime.jsxs(Popover, { children: [
542
+ /* @__PURE__ */ jsxRuntime.jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsxs(
543
+ Button,
544
+ {
545
+ variant: "outline",
546
+ role: "combobox",
547
+ disabled,
548
+ className: `h-10 justify-between font-normal ${triggerClasses}`,
549
+ children: [
550
+ value !== void 0 && value !== "" ? labelOf(value) : /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground", children: placeholder }),
551
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronsUpDown, { className: "ml-2 h-4 w-4 shrink-0 opacity-50" })
552
+ ]
553
+ }
554
+ ) }),
555
+ /* @__PURE__ */ jsxRuntime.jsx(PopoverContent, { className: "w-[var(--radix-popover-trigger-width)] p-0", align: "start", children: /* @__PURE__ */ jsxRuntime.jsxs(Command, { children: [
556
+ /* @__PURE__ */ jsxRuntime.jsx(CommandInput, { placeholder: "Buscar..." }),
557
+ /* @__PURE__ */ jsxRuntime.jsxs(CommandList, { children: [
558
+ /* @__PURE__ */ jsxRuntime.jsx(CommandEmpty, { children: "Sin resultados" }),
559
+ /* @__PURE__ */ jsxRuntime.jsx(CommandGroup, { children: opts.map((o) => /* @__PURE__ */ jsxRuntime.jsxs(
560
+ CommandItem,
561
+ {
562
+ value: o.label,
563
+ onSelect: () => commit(o.value),
564
+ children: [
565
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Check, { className: `mr-2 h-4 w-4 ${value === o.value ? "opacity-100" : "opacity-0"}` }),
566
+ o.label
567
+ ]
568
+ },
569
+ String(o.value)
570
+ )) })
571
+ ] })
572
+ ] }) })
573
+ ] })
574
+ ] });
575
+ }
576
+ const selectValue = value === void 0 || value === "" ? SENTINEL_UNDEFINED : String(value);
577
+ const onValueChange = (raw) => {
578
+ if (raw === SENTINEL_UNDEFINED) {
579
+ if (confirmMode) setPending(void 0);
580
+ else commit(void 0);
581
+ return;
582
+ }
583
+ const matched = opts.find((o) => String(o.value) === raw);
584
+ const next = matched?.value;
585
+ if (confirmMode) setPending(next);
586
+ else commit(next);
587
+ };
588
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-1", children: [
589
+ label && /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-xs font-medium text-muted-foreground", children: [
590
+ label,
591
+ mandatory && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "ml-0.5 text-destructive", children: "*" })
592
+ ] }),
593
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
594
+ /* @__PURE__ */ jsxRuntime.jsxs(Select, { value: selectValue, onValueChange, disabled, children: [
595
+ /* @__PURE__ */ jsxRuntime.jsx(SelectTrigger, { className: triggerClasses, children: /* @__PURE__ */ jsxRuntime.jsx(SelectValue, { placeholder }) }),
596
+ /* @__PURE__ */ jsxRuntime.jsx(SelectContent, { children: opts.map((o) => /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: String(o.value), children: o.label }, String(o.value))) })
597
+ ] }),
598
+ !mandatory && value !== void 0 && value !== "" && !disabled && /* @__PURE__ */ jsxRuntime.jsx(
599
+ "button",
600
+ {
601
+ type: "button",
602
+ onClick: () => confirmMode ? setPending(void 0) : commit(void 0),
603
+ className: "p-1 hover:bg-muted rounded",
604
+ "aria-label": "Limpiar",
605
+ children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.X, { className: "h-3.5 w-3.5 text-muted-foreground" })
606
+ }
607
+ ),
608
+ confirmMode && pending !== value && /* @__PURE__ */ jsxRuntime.jsx(Button, { size: "sm", onClick: () => commit(pending), children: confirmLabel })
609
+ ] })
610
+ ] });
611
+ }
612
+ function TextWidget({ definition, value, onChange, onRemove }) {
613
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2 rounded-md border border-border bg-card px-3 py-1.5", children: [
614
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-xs font-medium text-muted-foreground whitespace-nowrap", children: [
615
+ definition.label,
616
+ definition.mandatory && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "ml-0.5 text-destructive", children: "*" }),
617
+ ":"
618
+ ] }),
619
+ /* @__PURE__ */ jsxRuntime.jsx(
620
+ Input,
621
+ {
622
+ className: "h-7 min-w-[112px] w-28 border-0 bg-transparent p-0 px-2 text-xs focus-visible:ring-0 focus-visible:ring-offset-0",
623
+ placeholder: definition.placeholder,
624
+ value: value ?? "",
625
+ onChange: (e) => onChange(e.target.value)
626
+ }
627
+ ),
628
+ onRemove && /* @__PURE__ */ jsxRuntime.jsx(
629
+ "button",
630
+ {
631
+ type: "button",
632
+ onClick: onRemove,
633
+ className: "ml-1 p-0.5 hover:bg-muted rounded transition-colors",
634
+ children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.X, { className: "w-3.5 h-3.5 text-muted-foreground" })
635
+ }
636
+ )
637
+ ] });
638
+ }
639
+ var SENTINEL = "__easyvision_undef__";
640
+ function SelectorWidget({ definition, value, onChange, onRemove }) {
641
+ const [resolved, setResolved] = React8.useState(
642
+ Array.isArray(definition.options) ? definition.options : null
643
+ );
644
+ React8.useEffect(() => {
645
+ if (typeof definition.options === "function" && resolved === null) {
646
+ void definition.options().then((o) => setResolved(o)).catch(() => setResolved([]));
647
+ } else if (Array.isArray(definition.options)) {
648
+ setResolved(definition.options);
649
+ }
650
+ }, [definition.options, resolved]);
651
+ const opts = resolved ?? [];
652
+ const selectValue = value === void 0 || value === "" ? SENTINEL : String(value);
653
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2 rounded-md border border-border bg-card px-3 py-1.5", children: [
654
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-xs font-medium text-muted-foreground whitespace-nowrap", children: [
655
+ definition.label,
656
+ definition.mandatory && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "ml-0.5 text-destructive", children: "*" }),
657
+ ":"
658
+ ] }),
659
+ /* @__PURE__ */ jsxRuntime.jsxs(
660
+ Select,
661
+ {
662
+ value: selectValue,
663
+ onValueChange: (raw) => {
664
+ if (raw === SENTINEL) onChange(void 0);
665
+ else {
666
+ const matched = opts.find((o) => String(o.value) === raw);
667
+ onChange(matched?.value);
668
+ }
669
+ },
670
+ children: [
671
+ /* @__PURE__ */ jsxRuntime.jsx(SelectTrigger, { className: "h-7 min-w-[120px] border-0 bg-transparent p-0 px-2 text-xs focus:ring-0 focus:ring-offset-0", children: /* @__PURE__ */ jsxRuntime.jsx(SelectValue, { placeholder: definition.placeholder ?? "Seleccionar" }) }),
672
+ /* @__PURE__ */ jsxRuntime.jsx(SelectContent, { children: opts.map((o) => /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: String(o.value), children: o.label }, String(o.value))) })
673
+ ]
674
+ }
675
+ ),
676
+ onRemove && /* @__PURE__ */ jsxRuntime.jsx(
677
+ "button",
678
+ {
679
+ type: "button",
680
+ onClick: onRemove,
681
+ className: "ml-1 p-0.5 hover:bg-muted rounded transition-colors",
682
+ children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.X, { className: "w-3.5 h-3.5 text-muted-foreground" })
683
+ }
684
+ )
685
+ ] });
686
+ }
687
+ var Checkbox = React8__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
688
+ CheckboxPrimitive__namespace.Root,
689
+ {
690
+ ref,
691
+ className: cn(
692
+ "peer h-4 w-4 shrink-0 rounded border border-primary ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground flex items-center justify-center",
693
+ className
694
+ ),
695
+ ...props,
696
+ children: /* @__PURE__ */ jsxRuntime.jsx(
697
+ CheckboxPrimitive__namespace.Indicator,
698
+ {
699
+ className: cn("flex items-center justify-center text-current w-full h-full"),
700
+ children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Check, { className: "h-3 w-3" })
701
+ }
702
+ )
703
+ }
704
+ ));
705
+ Checkbox.displayName = CheckboxPrimitive__namespace.Root.displayName;
706
+ function MultiSelectWidget({
707
+ definition,
708
+ value,
709
+ onChange,
710
+ onRemove
711
+ }) {
712
+ const [search, setSearch] = React8.useState("");
713
+ const [resolved, setResolved] = React8.useState(
714
+ Array.isArray(definition.options) ? definition.options : null
715
+ );
716
+ React8.useEffect(() => {
717
+ if (typeof definition.options === "function" && resolved === null) {
718
+ void definition.options().then(setResolved).catch(() => setResolved([]));
719
+ } else if (Array.isArray(definition.options)) {
720
+ setResolved(definition.options);
721
+ }
722
+ }, [definition.options, resolved]);
723
+ const selected = Array.isArray(value) ? value : [];
724
+ const opts = resolved ?? [];
725
+ const filtered = React8.useMemo(
726
+ () => opts.filter((o) => o.label.toLowerCase().includes(search.toLowerCase())),
727
+ [opts, search]
728
+ );
729
+ const toggle = (v) => {
730
+ onChange(selected.includes(v) ? selected.filter((x) => x !== v) : [...selected, v]);
731
+ };
732
+ const removeOne = (v) => onChange(selected.filter((x) => x !== v));
733
+ const labelOf = (v) => opts.find((o) => o.value === v)?.label ?? String(v);
734
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-1.5 rounded-md border border-border bg-card px-2 py-1 flex-wrap", children: [
735
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-xs font-medium text-muted-foreground whitespace-nowrap", children: [
736
+ definition.label,
737
+ definition.mandatory && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "ml-0.5 text-destructive", children: "*" }),
738
+ ":"
739
+ ] }),
740
+ selected.map((v) => /* @__PURE__ */ jsxRuntime.jsxs(
741
+ "span",
742
+ {
743
+ className: "inline-flex items-center gap-1 bg-primary/10 text-primary text-xs px-2 py-0.5 rounded-md",
744
+ children: [
745
+ labelOf(v),
746
+ /* @__PURE__ */ jsxRuntime.jsx(
747
+ "button",
748
+ {
749
+ type: "button",
750
+ onClick: () => removeOne(v),
751
+ className: "p-0.5 hover:bg-muted rounded",
752
+ children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.X, { className: "h-3 w-3" })
753
+ }
754
+ )
755
+ ]
756
+ },
757
+ String(v)
758
+ )),
759
+ /* @__PURE__ */ jsxRuntime.jsxs(Popover, { children: [
760
+ /* @__PURE__ */ jsxRuntime.jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(
761
+ "button",
762
+ {
763
+ type: "button",
764
+ className: "flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground",
765
+ children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronDown, { className: "h-3.5 w-3.5" })
766
+ }
767
+ ) }),
768
+ /* @__PURE__ */ jsxRuntime.jsxs(PopoverContent, { className: "w-56 p-2", align: "start", children: [
769
+ /* @__PURE__ */ jsxRuntime.jsx(
770
+ Input,
771
+ {
772
+ className: "mb-2 h-8 text-xs",
773
+ placeholder: "Buscar...",
774
+ value: search,
775
+ onChange: (e) => setSearch(e.target.value)
776
+ }
777
+ ),
778
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "max-h-48 overflow-y-auto", children: [
779
+ filtered.map((o) => /* @__PURE__ */ jsxRuntime.jsxs(
780
+ "label",
781
+ {
782
+ className: "flex cursor-pointer items-center gap-2 rounded-sm px-2 py-1.5 text-xs hover:bg-muted",
783
+ children: [
784
+ /* @__PURE__ */ jsxRuntime.jsx(
785
+ Checkbox,
786
+ {
787
+ checked: selected.includes(o.value),
788
+ onCheckedChange: () => toggle(o.value)
789
+ }
790
+ ),
791
+ o.label
792
+ ]
793
+ },
794
+ String(o.value)
795
+ )),
796
+ filtered.length === 0 && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "px-2 py-1 text-xs text-muted-foreground", children: "Sin opciones" })
797
+ ] })
798
+ ] })
799
+ ] }),
800
+ onRemove && /* @__PURE__ */ jsxRuntime.jsx(
801
+ "button",
802
+ {
803
+ type: "button",
804
+ onClick: onRemove,
805
+ className: "ml-1 p-0.5 hover:bg-muted rounded transition-colors",
806
+ children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.X, { className: "w-3.5 h-3.5 text-muted-foreground" })
807
+ }
808
+ )
809
+ ] });
810
+ }
811
+ function Calendar({
812
+ className,
813
+ classNames,
814
+ showOutsideDays = true,
815
+ ...props
816
+ }) {
817
+ return /* @__PURE__ */ jsxRuntime.jsx(
818
+ reactDayPicker.DayPicker,
819
+ {
820
+ showOutsideDays,
821
+ className: cn("p-3", className),
822
+ classNames: {
823
+ months: "flex flex-col sm:flex-row space-y-4 sm:space-x-4 sm:space-y-0",
824
+ month: "space-y-4",
825
+ caption: "flex justify-center pt-1 relative items-center",
826
+ caption_label: "text-sm font-medium",
827
+ nav: "space-x-1 flex items-center",
828
+ nav_button: cn(
829
+ buttonVariants({ variant: "outline" }),
830
+ "h-7 w-7 bg-transparent p-0 opacity-50 hover:opacity-100"
831
+ ),
832
+ nav_button_previous: "absolute left-1",
833
+ nav_button_next: "absolute right-1",
834
+ table: "w-full border-collapse space-y-1",
835
+ head_row: "flex",
836
+ head_cell: "text-muted-foreground rounded-md w-9 font-normal text-[0.8rem]",
837
+ row: "flex w-full mt-2",
838
+ cell: "h-9 w-9 text-center text-sm p-0 relative [&:has([aria-selected].day-range-end)]:rounded-r-md [&:has([aria-selected].day-outside)]:bg-accent/50 [&:has([aria-selected])]:bg-accent first:[&:has([aria-selected])]:rounded-l-md last:[&:has([aria-selected])]:rounded-r-md focus-within:relative focus-within:z-20",
839
+ day: cn(
840
+ buttonVariants({ variant: "ghost" }),
841
+ "h-9 w-9 p-0 font-normal aria-selected:opacity-100"
842
+ ),
843
+ day_range_end: "day-range-end",
844
+ day_selected: "bg-primary text-primary-foreground hover:bg-primary hover:text-primary-foreground focus:bg-primary focus:text-primary-foreground",
845
+ day_today: "bg-accent text-accent-foreground",
846
+ day_outside: "day-outside text-muted-foreground aria-selected:bg-accent/50 aria-selected:text-muted-foreground",
847
+ day_disabled: "text-muted-foreground opacity-50",
848
+ day_range_middle: "aria-selected:bg-accent aria-selected:text-accent-foreground",
849
+ day_hidden: "invisible",
850
+ ...classNames
851
+ },
852
+ components: {
853
+ IconLeft: ({ className: className2, ...props2 }) => /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronLeft, { className: cn("h-4 w-4", className2), ...props2 }),
854
+ IconRight: ({ className: className2, ...props2 }) => /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronRight, { className: cn("h-4 w-4", className2), ...props2 })
855
+ },
856
+ ...props
857
+ }
858
+ );
859
+ }
860
+ Calendar.displayName = "Calendar";
861
+ function DateRangeWidget({
862
+ definition,
863
+ value,
864
+ onChange,
865
+ onRemove
866
+ }) {
867
+ const range = value ?? {};
868
+ const label = (() => {
869
+ if (range.from && range.to) {
870
+ return `${dateFns.format(range.from, "dd/MM/yy", { locale: locale.es })} - ${dateFns.format(range.to, "dd/MM/yy", { locale: locale.es })}`;
871
+ }
872
+ if (range.from) return `Desde ${dateFns.format(range.from, "dd/MM/yy", { locale: locale.es })}`;
873
+ if (range.to) return `Hasta ${dateFns.format(range.to, "dd/MM/yy", { locale: locale.es })}`;
874
+ return definition.placeholder ?? "Seleccionar rango";
875
+ })();
876
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2 rounded-md border border-border bg-card px-3 py-1.5", children: [
877
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-xs font-medium text-muted-foreground whitespace-nowrap", children: [
878
+ definition.label,
879
+ definition.mandatory && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "ml-0.5 text-destructive", children: "*" }),
880
+ ":"
881
+ ] }),
882
+ /* @__PURE__ */ jsxRuntime.jsxs(Popover, { children: [
883
+ /* @__PURE__ */ jsxRuntime.jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsxs(
884
+ "button",
885
+ {
886
+ type: "button",
887
+ className: "flex items-center gap-1.5 text-xs hover:text-foreground",
888
+ children: [
889
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Calendar, { className: "h-3.5 w-3.5" }),
890
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: label })
891
+ ]
892
+ }
893
+ ) }),
894
+ /* @__PURE__ */ jsxRuntime.jsx(PopoverContent, { className: "w-auto p-0", align: "start", children: /* @__PURE__ */ jsxRuntime.jsx(
895
+ Calendar,
896
+ {
897
+ mode: "range",
898
+ selected: { from: range.from, to: range.to },
899
+ onSelect: (r) => onChange({ from: r?.from, to: r?.to }),
900
+ numberOfMonths: 2,
901
+ locale: locale.es
902
+ }
903
+ ) })
904
+ ] }),
905
+ onRemove && /* @__PURE__ */ jsxRuntime.jsx(
906
+ "button",
907
+ {
908
+ type: "button",
909
+ onClick: onRemove,
910
+ className: "ml-1 p-0.5 hover:bg-muted rounded transition-colors",
911
+ children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.X, { className: "w-3.5 h-3.5 text-muted-foreground" })
912
+ }
913
+ )
914
+ ] });
915
+ }
916
+ function NumberRangeWidget({
917
+ definition,
918
+ value,
919
+ onChange,
920
+ onRemove
921
+ }) {
922
+ const range = value ?? {};
923
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2 rounded-md border border-border bg-card px-3 py-1.5", children: [
924
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-xs font-medium text-muted-foreground whitespace-nowrap", children: [
925
+ definition.label,
926
+ definition.mandatory && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "ml-0.5 text-destructive", children: "*" }),
927
+ ":"
928
+ ] }),
929
+ /* @__PURE__ */ jsxRuntime.jsx(
930
+ Input,
931
+ {
932
+ type: "number",
933
+ className: "h-7 w-20 border-0 bg-transparent p-0 px-2 text-xs focus-visible:ring-0 focus-visible:ring-offset-0",
934
+ placeholder: "Min",
935
+ value: range.min ?? "",
936
+ onChange: (e) => onChange({ ...range, min: e.target.value ? Number(e.target.value) : void 0 })
937
+ }
938
+ ),
939
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-xs text-muted-foreground", children: "\u2014" }),
940
+ /* @__PURE__ */ jsxRuntime.jsx(
941
+ Input,
942
+ {
943
+ type: "number",
944
+ className: "h-7 w-20 border-0 bg-transparent p-0 px-2 text-xs focus-visible:ring-0 focus-visible:ring-offset-0",
945
+ placeholder: "Max",
946
+ value: range.max ?? "",
947
+ onChange: (e) => onChange({ ...range, max: e.target.value ? Number(e.target.value) : void 0 })
948
+ }
949
+ ),
950
+ onRemove && /* @__PURE__ */ jsxRuntime.jsx(
951
+ "button",
952
+ {
953
+ type: "button",
954
+ onClick: onRemove,
955
+ className: "ml-1 p-0.5 hover:bg-muted rounded transition-colors",
956
+ children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.X, { className: "w-3.5 h-3.5 text-muted-foreground" })
957
+ }
958
+ )
959
+ ] });
960
+ }
961
+ function MultifilterField({
962
+ definition,
963
+ value,
964
+ onChange,
965
+ onRemove
966
+ }) {
967
+ switch (definition.type) {
968
+ case "text":
969
+ return /* @__PURE__ */ jsxRuntime.jsx(
970
+ TextWidget,
971
+ {
972
+ definition,
973
+ value,
974
+ onChange: (v) => onChange(v),
975
+ onRemove
976
+ }
977
+ );
978
+ case "selector":
979
+ return /* @__PURE__ */ jsxRuntime.jsx(
980
+ SelectorWidget,
981
+ {
982
+ definition,
983
+ value,
984
+ onChange: (v) => onChange(v),
985
+ onRemove
986
+ }
987
+ );
988
+ case "multiselect":
989
+ return /* @__PURE__ */ jsxRuntime.jsx(
990
+ MultiSelectWidget,
991
+ {
992
+ definition,
993
+ value,
994
+ onChange: (v) => onChange(v),
995
+ onRemove
996
+ }
997
+ );
998
+ case "dateRange":
999
+ return /* @__PURE__ */ jsxRuntime.jsx(
1000
+ DateRangeWidget,
1001
+ {
1002
+ definition,
1003
+ value,
1004
+ onChange: (v) => onChange(v),
1005
+ onRemove
1006
+ }
1007
+ );
1008
+ case "numberRange":
1009
+ return /* @__PURE__ */ jsxRuntime.jsx(
1010
+ NumberRangeWidget,
1011
+ {
1012
+ definition,
1013
+ value,
1014
+ onChange: (v) => onChange(v),
1015
+ onRemove
1016
+ }
1017
+ );
1018
+ case "custom": {
1019
+ const Component = definition.component;
1020
+ return /* @__PURE__ */ jsxRuntime.jsx(
1021
+ Component,
1022
+ {
1023
+ definition,
1024
+ value,
1025
+ onChange,
1026
+ onRemove: onRemove ?? (() => {
1027
+ })
1028
+ }
1029
+ );
1030
+ }
1031
+ case "multifilter":
1032
+ return null;
1033
+ default:
1034
+ return null;
1035
+ }
1036
+ }
1037
+ function buildCondition(def, value) {
1038
+ if (value === void 0 || value === null || value === "") return void 0;
1039
+ const mapper = def.toCondition ?? def.transform;
1040
+ if (mapper) {
1041
+ const mapped = mapper(value);
1042
+ if (mapped === void 0 || mapped === null) return void 0;
1043
+ if (typeof mapped === "object" && !Array.isArray(mapped) && ("$or" in mapped || "$and" in mapped)) {
1044
+ return mapped;
1045
+ }
1046
+ if (def.field) return { [def.field]: mapped };
1047
+ return void 0;
1048
+ }
1049
+ if (!def.field) return void 0;
1050
+ switch (def.type) {
1051
+ case "text": {
1052
+ const str = String(value).trim();
1053
+ if (!str) return void 0;
1054
+ return { [def.field]: { $regex: `.*${str}.*`, $options: "i" } };
1055
+ }
1056
+ case "selector": {
1057
+ return { [def.field]: value };
1058
+ }
1059
+ case "multiselect": {
1060
+ const arr = value;
1061
+ if (!Array.isArray(arr) || arr.length === 0) return void 0;
1062
+ return { [def.field]: { $in: arr } };
1063
+ }
1064
+ case "dateRange": {
1065
+ const r = value;
1066
+ if (!r?.from && !r?.to) return void 0;
1067
+ const cond = {};
1068
+ if (r.from) cond.$gte = r.from.toISOString();
1069
+ if (r.to) cond.$lte = r.to.toISOString();
1070
+ return { [def.field]: cond };
1071
+ }
1072
+ case "numberRange": {
1073
+ const r = value;
1074
+ if (r?.min == null && r?.max == null) return void 0;
1075
+ const cond = {};
1076
+ if (r.min != null) cond.$gte = r.min;
1077
+ if (r.max != null) cond.$lte = r.max;
1078
+ return { [def.field]: cond };
1079
+ }
1080
+ default:
1081
+ return void 0;
1082
+ }
1083
+ }
1084
+ function useBuildQuery(config, values, childQueries) {
1085
+ return React8.useCallback(() => {
1086
+ const where = {};
1087
+ if (config.searchField) {
1088
+ const c = buildCondition(config.searchField, values[config.searchField.id]);
1089
+ if (c) Object.assign(where, c);
1090
+ }
1091
+ for (const def of config.fields) {
1092
+ if (def.type === "multifilter") {
1093
+ const childWhere = childQueries[def.id]?.where;
1094
+ if (childWhere) Object.assign(where, childWhere);
1095
+ continue;
1096
+ }
1097
+ const c = buildCondition(def, values[def.id]);
1098
+ if (c) Object.assign(where, c);
1099
+ }
1100
+ const out = {};
1101
+ if (Object.keys(where).length > 0) out.where = where;
1102
+ if (config.defaultOrder) out.order = config.defaultOrder;
1103
+ if (config.defaultLimit) out.limit = config.defaultLimit;
1104
+ return out;
1105
+ }, [config, values, childQueries]);
1106
+ }
1107
+
1108
+ // lib/stableStringify.ts
1109
+ function stableStringify(value) {
1110
+ return JSON.stringify(normalize(value));
1111
+ }
1112
+ function normalize(value) {
1113
+ if (value === void 0) return void 0;
1114
+ if (value === null) return null;
1115
+ if (value instanceof Date) return value.toISOString();
1116
+ if (Array.isArray(value)) return value.map(normalize);
1117
+ if (typeof value === "object") {
1118
+ const obj = value;
1119
+ const out = {};
1120
+ for (const key of Object.keys(obj).sort()) {
1121
+ const norm = normalize(obj[key]);
1122
+ if (norm !== void 0) out[key] = norm;
1123
+ }
1124
+ return out;
1125
+ }
1126
+ return value;
1127
+ }
1128
+
1129
+ // multifilter/hooks/useDirtyTracking.ts
1130
+ function isNonEmpty(value) {
1131
+ if (value === void 0 || value === null) return false;
1132
+ if (typeof value === "string") return value.trim().length > 0;
1133
+ if (Array.isArray(value)) return value.length > 0;
1134
+ if (typeof value === "object") {
1135
+ const obj = value;
1136
+ if ("from" in obj || "to" in obj) {
1137
+ return obj.from !== void 0 || obj.to !== void 0;
1138
+ }
1139
+ if ("min" in obj || "max" in obj) {
1140
+ return obj.min !== void 0 || obj.max !== void 0;
1141
+ }
1142
+ return Object.values(obj).some(isNonEmpty);
1143
+ }
1144
+ return true;
1145
+ }
1146
+ function buildSnapshotKey(input) {
1147
+ const filtered = {};
1148
+ for (const key of Object.keys(input.values)) {
1149
+ if (isNonEmpty(input.values[key])) {
1150
+ filtered[key] = input.values[key];
1151
+ }
1152
+ }
1153
+ return stableStringify({
1154
+ activeFields: [...input.activeFields].sort(),
1155
+ values: filtered
1156
+ });
1157
+ }
1158
+ function isDirty(input, lastConfirmed) {
1159
+ const current = buildSnapshotKey(input);
1160
+ if (lastConfirmed === null) {
1161
+ return Object.values(input.values).some(isNonEmpty);
1162
+ }
1163
+ return current !== lastConfirmed;
1164
+ }
1165
+ var DEFAULT_LABELS = {
1166
+ search: "Buscar",
1167
+ clear: "Limpiar",
1168
+ perform: "Buscar",
1169
+ addFilter: "A\xF1adir filtro",
1170
+ noOptions: "Sin opciones",
1171
+ searchPlaceholder: "Buscar..."
1172
+ };
1173
+ function isFieldVisible(def, values) {
1174
+ if (def.visible === void 0) return true;
1175
+ if (typeof def.visible === "boolean") return def.visible;
1176
+ return def.visible(values);
1177
+ }
1178
+ function isMandatorySatisfied(def, value) {
1179
+ if (!def.mandatory) return true;
1180
+ return isNonEmpty(value);
1181
+ }
1182
+ var EasyVisionMultifilter = React8.forwardRef(function EasyVisionMultifilter2(props, ref) {
1183
+ const {
1184
+ id,
1185
+ config,
1186
+ editable = true,
1187
+ performButton = false,
1188
+ performLabel,
1189
+ performIcon,
1190
+ performPosition = "inline",
1191
+ performTargetRef,
1192
+ performOnMount = false,
1193
+ onPerform,
1194
+ onChange,
1195
+ onStateChange,
1196
+ showClearAll,
1197
+ labels: labelOverrides,
1198
+ className,
1199
+ persist = false,
1200
+ clearWhen
1201
+ } = props;
1202
+ const labels = { ...DEFAULT_LABELS, ...labelOverrides };
1203
+ const showClear = showClearAll ?? editable;
1204
+ const initialActive = React8.useMemo(() => {
1205
+ const ids = [];
1206
+ if (config.searchField) ids.push(config.searchField.id);
1207
+ for (const f of config.fields) {
1208
+ if (f.pinned || f.initiallyActive) ids.push(f.id);
1209
+ }
1210
+ return ids;
1211
+ }, [config]);
1212
+ const initialValues = React8.useMemo(() => {
1213
+ const v = {};
1214
+ if (config.searchField?.defaultValue !== void 0) {
1215
+ v[config.searchField.id] = config.searchField.defaultValue;
1216
+ }
1217
+ for (const f of config.fields) {
1218
+ if (f.defaultValue !== void 0) v[f.id] = f.defaultValue;
1219
+ }
1220
+ return v;
1221
+ }, [config]);
1222
+ const { slice, fullId, patch } = useEasyVisionSlice("multifilter", id, {
1223
+ init: () => ({
1224
+ kind: "multifilter",
1225
+ activeFields: initialActive,
1226
+ values: initialValues,
1227
+ lastConfirmedSnapshotJSON: null
1228
+ }),
1229
+ persist,
1230
+ clearWhen: clearWhen ? (s) => clearWhen({
1231
+ values: s.values,
1232
+ activeFields: s.activeFields,
1233
+ isValid: false,
1234
+ isDirty: false,
1235
+ query: {}
1236
+ }) : void 0
1237
+ });
1238
+ const { activeFields, values, lastConfirmedSnapshotJSON } = slice;
1239
+ const [childTick, setChildTick] = React8.useState(0);
1240
+ React8.useEffect(() => {
1241
+ const unsub = easyVisionRegistry.subscribe(() => setChildTick((t) => t + 1));
1242
+ return unsub;
1243
+ }, []);
1244
+ const childSnapshots = React8.useMemo(() => {
1245
+ const out = {};
1246
+ for (const f of config.fields) {
1247
+ if (f.type !== "multifilter") continue;
1248
+ const childFullId = `${fullId}.${f.id}-multifilter`;
1249
+ const childSlice = easyVisionRegistry.getState().slices[childFullId];
1250
+ if (childSlice) {
1251
+ out[f.id] = {
1252
+ values: childSlice.values,
1253
+ activeFields: childSlice.activeFields
1254
+ };
1255
+ }
1256
+ }
1257
+ return out;
1258
+ }, [fullId, config.fields, childTick]);
1259
+ const childQueries = React8.useMemo(() => {
1260
+ const out = {};
1261
+ for (const f of config.fields) {
1262
+ if (f.type !== "multifilter") continue;
1263
+ const childSnap = childSnapshots[f.id];
1264
+ if (!childSnap) continue;
1265
+ out[f.id] = buildChildQueryDirect(f, childSnap.values);
1266
+ }
1267
+ return out;
1268
+ }, [config.fields, childSnapshots]);
1269
+ const buildQuery = useBuildQuery(config, values, childQueries);
1270
+ const composedValues = React8.useMemo(() => {
1271
+ const out = { ...values };
1272
+ for (const f of config.fields) {
1273
+ if (f.type === "multifilter") {
1274
+ out[f.id] = childSnapshots[f.id]?.values ?? {};
1275
+ }
1276
+ }
1277
+ return out;
1278
+ }, [values, config.fields, childSnapshots]);
1279
+ const isValid = React8.useMemo(() => {
1280
+ if (config.searchField && !isMandatorySatisfied(config.searchField, values[config.searchField.id])) {
1281
+ return false;
1282
+ }
1283
+ for (const f of config.fields) {
1284
+ if (f.type === "multifilter") {
1285
+ const childSnap = childSnapshots[f.id];
1286
+ if (!childSnap) {
1287
+ continue;
1288
+ }
1289
+ for (const cf of f.config.fields) {
1290
+ if (cf.mandatory && !isMandatorySatisfied(cf, childSnap.values[cf.id])) return false;
1291
+ }
1292
+ if (f.config.searchField?.mandatory && !isMandatorySatisfied(f.config.searchField, childSnap.values[f.config.searchField.id])) {
1293
+ return false;
1294
+ }
1295
+ } else if (!isMandatorySatisfied(f, values[f.id])) {
1296
+ return false;
1297
+ }
1298
+ }
1299
+ return true;
1300
+ }, [config, values, childSnapshots]);
1301
+ const snapshotKey = React8.useMemo(
1302
+ () => buildSnapshotKey({ activeFields, values: composedValues }),
1303
+ [activeFields, composedValues]
1304
+ );
1305
+ const dirty = React8.useMemo(
1306
+ () => isDirty({ activeFields, values: composedValues }, lastConfirmedSnapshotJSON),
1307
+ [activeFields, composedValues, lastConfirmedSnapshotJSON]
1308
+ );
1309
+ const snapshot = React8.useMemo(
1310
+ () => ({
1311
+ values: composedValues,
1312
+ activeFields,
1313
+ isValid,
1314
+ isDirty: dirty,
1315
+ query: buildQuery()
1316
+ }),
1317
+ [composedValues, activeFields, isValid, dirty, buildQuery]
1318
+ );
1319
+ const lastEmittedKeyRef = React8.useRef("");
1320
+ React8.useEffect(() => {
1321
+ const key = `${snapshotKey}|${dirty}|${isValid}`;
1322
+ if (key === lastEmittedKeyRef.current) return;
1323
+ lastEmittedKeyRef.current = key;
1324
+ onChange?.(snapshot);
1325
+ onStateChange?.(snapshot);
1326
+ }, [snapshotKey, dirty, isValid, snapshot, onChange, onStateChange]);
1327
+ const performAction = React8.useCallback(() => {
1328
+ const key = buildSnapshotKey({ activeFields, values: composedValues });
1329
+ patch({ lastConfirmedSnapshotJSON: key });
1330
+ onPerform?.({ ...snapshot, isDirty: false });
1331
+ }, [activeFields, composedValues, patch, onPerform, snapshot]);
1332
+ const didPerformOnMountRef = React8.useRef(false);
1333
+ React8.useEffect(() => {
1334
+ if (performOnMount && !didPerformOnMountRef.current && Object.values(composedValues).some(isNonEmpty)) {
1335
+ didPerformOnMountRef.current = true;
1336
+ performAction();
1337
+ }
1338
+ }, [performOnMount]);
1339
+ React8.useImperativeHandle(ref, () => ({
1340
+ perform: performAction,
1341
+ getSnapshot: () => snapshot
1342
+ }));
1343
+ const updateValue = React8.useCallback(
1344
+ (fieldId, value) => {
1345
+ patch({ values: { ...values, [fieldId]: value } });
1346
+ },
1347
+ [patch, values]
1348
+ );
1349
+ const addField = React8.useCallback(
1350
+ (fieldId) => {
1351
+ if (activeFields.includes(fieldId)) return;
1352
+ patch({ activeFields: [...activeFields, fieldId] });
1353
+ },
1354
+ [activeFields, patch]
1355
+ );
1356
+ const removeField = React8.useCallback(
1357
+ (fieldId) => {
1358
+ const nextValues = { ...values };
1359
+ delete nextValues[fieldId];
1360
+ patch({
1361
+ activeFields: activeFields.filter((f) => f !== fieldId),
1362
+ values: nextValues
1363
+ });
1364
+ },
1365
+ [activeFields, values, patch]
1366
+ );
1367
+ const clearAll = React8.useCallback(() => {
1368
+ const seed = {};
1369
+ if (config.searchField?.defaultValue !== void 0) {
1370
+ seed[config.searchField.id] = config.searchField.defaultValue;
1371
+ }
1372
+ patch({
1373
+ values: seed,
1374
+ activeFields: initialActive.filter((id2) => {
1375
+ const def = config.fields.find((f) => f.id === id2);
1376
+ return def?.pinned;
1377
+ }).concat(config.searchField ? [config.searchField.id] : []),
1378
+ lastConfirmedSnapshotJSON: null
1379
+ });
1380
+ }, [config, patch, initialActive]);
1381
+ const visibleConfigFields = React8.useMemo(
1382
+ () => config.fields.filter((f) => isFieldVisible(f, composedValues)),
1383
+ [config.fields, composedValues]
1384
+ );
1385
+ const isProminentTextField = (f) => f.type === "text" && f.prominent === true;
1386
+ const pinnedFields = React8.useMemo(
1387
+ () => visibleConfigFields.filter((f) => f.pinned && !isProminentTextField(f)),
1388
+ [visibleConfigFields]
1389
+ );
1390
+ const chipFields = React8.useMemo(
1391
+ () => visibleConfigFields.filter(
1392
+ (f) => !f.pinned && !isProminentTextField(f) && activeFields.includes(f.id)
1393
+ ),
1394
+ [visibleConfigFields, activeFields]
1395
+ );
1396
+ const prominentSlots = React8.useMemo(() => {
1397
+ const slots = [];
1398
+ if (config.searchField) {
1399
+ slots.push({
1400
+ def: config.searchField,
1401
+ removable: false,
1402
+ // legacy slot is implicitly always-present
1403
+ isLegacySearchField: true
1404
+ });
1405
+ }
1406
+ for (const f of visibleConfigFields) {
1407
+ if (!isProminentTextField(f)) continue;
1408
+ if (!activeFields.includes(f.id)) continue;
1409
+ slots.push({
1410
+ def: f,
1411
+ removable: editable !== false && !f.pinned && !f.locked,
1412
+ isLegacySearchField: false
1413
+ });
1414
+ }
1415
+ return slots;
1416
+ }, [config.searchField, visibleConfigFields, activeFields, editable]);
1417
+ const availableToAdd = React8.useMemo(
1418
+ () => visibleConfigFields.filter(
1419
+ (f) => !f.pinned && !activeFields.includes(f.id)
1420
+ ),
1421
+ [visibleConfigFields, activeFields]
1422
+ );
1423
+ const performEnabled = editable !== false && performButton && isValid && dirty;
1424
+ const performLabelText = performLabel ?? labels.perform;
1425
+ const renderField = (f) => {
1426
+ if (f.type === "multifilter") {
1427
+ const removable2 = editable && !f.pinned && !f.locked;
1428
+ return /* @__PURE__ */ jsxRuntime.jsxs(
1429
+ "div",
1430
+ {
1431
+ className: "rounded-md border border-dashed border-border bg-muted/30 p-2",
1432
+ children: [
1433
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2 mb-2", children: [
1434
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-xs font-medium text-muted-foreground", children: f.label }),
1435
+ removable2 && /* @__PURE__ */ jsxRuntime.jsx(
1436
+ "button",
1437
+ {
1438
+ type: "button",
1439
+ onClick: () => removeField(f.id),
1440
+ className: "ml-auto p-0.5 hover:bg-muted rounded",
1441
+ children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.X, { className: "w-3.5 h-3.5 text-muted-foreground" })
1442
+ }
1443
+ )
1444
+ ] }),
1445
+ /* @__PURE__ */ jsxRuntime.jsx(
1446
+ EasyVisionMultifilter2,
1447
+ {
1448
+ id: f.id,
1449
+ config: f.config,
1450
+ editable,
1451
+ performButton: false,
1452
+ labels: labelOverrides
1453
+ }
1454
+ )
1455
+ ]
1456
+ },
1457
+ f.id
1458
+ );
1459
+ }
1460
+ const removable = editable && !f.pinned && !f.locked;
1461
+ return /* @__PURE__ */ jsxRuntime.jsx(
1462
+ MultifilterField,
1463
+ {
1464
+ definition: f,
1465
+ value: values[f.id],
1466
+ onChange: (v) => updateValue(f.id, v),
1467
+ onRemove: removable ? () => removeField(f.id) : void 0
1468
+ },
1469
+ f.id
1470
+ );
1471
+ };
1472
+ return /* @__PURE__ */ jsxRuntime.jsx(NamespaceProvider, { fullId, children: /* @__PURE__ */ jsxRuntime.jsx("div", { className, children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "p-3 space-y-2 bg-card border border-border rounded-md", children: [
1473
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-wrap items-center gap-2", children: [
1474
+ prominentSlots.map(({ def, removable, isLegacySearchField }) => /* @__PURE__ */ jsxRuntime.jsxs(
1475
+ "div",
1476
+ {
1477
+ className: "relative flex-1 min-w-[200px]",
1478
+ children: [
1479
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Search, { className: "absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground pointer-events-none" }),
1480
+ /* @__PURE__ */ jsxRuntime.jsx(
1481
+ Input,
1482
+ {
1483
+ className: `w-full h-9 pl-9 ${removable ? "pr-9" : "pr-3"} bg-muted border-0 rounded-md text-sm focus:ring-1 focus:ring-ring focus:bg-card`,
1484
+ placeholder: def.placeholder ?? def.label ?? labels.searchPlaceholder,
1485
+ value: values[def.id] ?? "",
1486
+ onChange: (e) => updateValue(def.id, e.target.value),
1487
+ onKeyDown: (e) => {
1488
+ if (e.key === "Enter" && performButton && performEnabled) {
1489
+ performAction();
1490
+ }
1491
+ }
1492
+ }
1493
+ ),
1494
+ removable && /* @__PURE__ */ jsxRuntime.jsx(
1495
+ "button",
1496
+ {
1497
+ type: "button",
1498
+ onClick: () => removeField(def.id),
1499
+ "aria-label": labels.clear,
1500
+ className: "absolute right-2 top-1/2 -translate-y-1/2 p-1 rounded hover:bg-muted-foreground/10",
1501
+ children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.X, { className: "w-3.5 h-3.5 text-muted-foreground" })
1502
+ }
1503
+ )
1504
+ ]
1505
+ },
1506
+ isLegacySearchField ? `__searchField__${def.id}` : def.id
1507
+ )),
1508
+ editable && availableToAdd.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs(Popover, { children: [
1509
+ /* @__PURE__ */ jsxRuntime.jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(
1510
+ Button,
1511
+ {
1512
+ variant: "outline",
1513
+ size: "sm",
1514
+ className: "h-9 w-9 p-0 border border-dashed border-border hover:bg-muted rounded-md",
1515
+ "aria-label": labels.addFilter,
1516
+ children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Plus, { className: "w-4 h-4 text-muted-foreground" })
1517
+ }
1518
+ ) }),
1519
+ /* @__PURE__ */ jsxRuntime.jsx(PopoverContent, { className: "w-52 p-1", align: "start", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "space-y-0.5", children: availableToAdd.map((f) => /* @__PURE__ */ jsxRuntime.jsxs(
1520
+ "button",
1521
+ {
1522
+ type: "button",
1523
+ onClick: () => addField(f.id),
1524
+ className: "w-full text-left px-3 py-2 text-xs hover:bg-muted rounded-md flex items-center gap-2",
1525
+ children: [
1526
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Plus, { className: "w-3 h-3 text-muted-foreground" }),
1527
+ f.label
1528
+ ]
1529
+ },
1530
+ f.id
1531
+ )) }) })
1532
+ ] }),
1533
+ performButton && performPosition === "inline" && /* @__PURE__ */ jsxRuntime.jsxs(
1534
+ Button,
1535
+ {
1536
+ size: "sm",
1537
+ onClick: performAction,
1538
+ disabled: !performEnabled,
1539
+ className: "h-9 px-4 text-xs font-medium",
1540
+ children: [
1541
+ performIcon ?? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Search, { className: "w-3.5 h-3.5 mr-1.5" }),
1542
+ performLabelText
1543
+ ]
1544
+ }
1545
+ ),
1546
+ showClear && /* @__PURE__ */ jsxRuntime.jsxs(
1547
+ Button,
1548
+ {
1549
+ variant: "ghost",
1550
+ size: "sm",
1551
+ onClick: clearAll,
1552
+ className: "h-9 px-3 text-xs text-muted-foreground",
1553
+ children: [
1554
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.X, { className: "w-3.5 h-3.5 mr-1" }),
1555
+ labels.clear
1556
+ ]
1557
+ }
1558
+ )
1559
+ ] }),
1560
+ pinnedFields.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-wrap items-center gap-2", children: pinnedFields.map(renderField) }),
1561
+ chipFields.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-wrap items-center gap-2", children: chipFields.map(renderField) }),
1562
+ performButton && performPosition === "belowRow" && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex justify-end pt-1", children: /* @__PURE__ */ jsxRuntime.jsxs(
1563
+ Button,
1564
+ {
1565
+ size: "sm",
1566
+ onClick: performAction,
1567
+ disabled: !performEnabled,
1568
+ className: "h-9 px-4 text-xs font-medium",
1569
+ children: [
1570
+ performIcon ?? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Search, { className: "w-3.5 h-3.5 mr-1.5" }),
1571
+ performLabelText
1572
+ ]
1573
+ }
1574
+ ) })
1575
+ ] }) }) });
1576
+ });
1577
+ function buildChildQueryDirect(field, values) {
1578
+ const where = {};
1579
+ for (const def of field.config.fields) {
1580
+ if (def.type === "multifilter") continue;
1581
+ const v = values[def.id];
1582
+ if (v === void 0 || v === null || v === "") continue;
1583
+ if (!def.field) continue;
1584
+ switch (def.type) {
1585
+ case "text": {
1586
+ const str = String(v).trim();
1587
+ if (str) where[def.field] = { $regex: `.*${str}.*`, $options: "i" };
1588
+ break;
1589
+ }
1590
+ case "selector":
1591
+ where[def.field] = v;
1592
+ break;
1593
+ case "multiselect": {
1594
+ const arr = v;
1595
+ if (Array.isArray(arr) && arr.length > 0) where[def.field] = { $in: arr };
1596
+ break;
1597
+ }
1598
+ case "dateRange": {
1599
+ const r = v;
1600
+ if (r?.from || r?.to) {
1601
+ const cond = {};
1602
+ if (r.from) cond.$gte = r.from.toISOString();
1603
+ if (r.to) cond.$lte = r.to.toISOString();
1604
+ where[def.field] = cond;
1605
+ }
1606
+ break;
1607
+ }
1608
+ case "numberRange": {
1609
+ const r = v;
1610
+ if (r?.min != null || r?.max != null) {
1611
+ const cond = {};
1612
+ if (r.min != null) cond.$gte = r.min;
1613
+ if (r.max != null) cond.$lte = r.max;
1614
+ where[def.field] = cond;
1615
+ }
1616
+ break;
1617
+ }
1618
+ }
1619
+ }
1620
+ if (field.config.searchField) {
1621
+ const sv = values[field.config.searchField.id];
1622
+ if (typeof sv === "string" && sv.trim() && field.config.searchField.field) {
1623
+ where[field.config.searchField.field] = { $regex: `.*${sv.trim()}.*`, $options: "i" };
1624
+ }
1625
+ }
1626
+ return Object.keys(where).length > 0 ? { where } : {};
1627
+ }
1628
+ var join = (...parts) => parts.filter(Boolean).join(" ");
1629
+ var EasyVisionCard = React8__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
1630
+ "div",
1631
+ {
1632
+ ref,
1633
+ className: join(
1634
+ "rounded-md border border-border bg-card text-card-foreground shadow-sm",
1635
+ className
1636
+ ),
1637
+ ...props
1638
+ }
1639
+ ));
1640
+ EasyVisionCard.displayName = "EasyVisionCard";
1641
+ var EasyVisionCardHeader = React8__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
1642
+ "div",
1643
+ {
1644
+ ref,
1645
+ className: join("flex flex-col space-y-1.5 p-6", className),
1646
+ ...props
1647
+ }
1648
+ ));
1649
+ EasyVisionCardHeader.displayName = "EasyVisionCardHeader";
1650
+ var EasyVisionCardTitle = React8__namespace.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
1651
+ "h3",
1652
+ {
1653
+ ref,
1654
+ className: join(
1655
+ "text-2xl font-semibold leading-none tracking-tight",
1656
+ className
1657
+ ),
1658
+ ...props,
1659
+ children
1660
+ }
1661
+ ));
1662
+ EasyVisionCardTitle.displayName = "EasyVisionCardTitle";
1663
+ var EasyVisionCardDescription = React8__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
1664
+ "p",
1665
+ {
1666
+ ref,
1667
+ className: join("text-sm text-muted-foreground", className),
1668
+ ...props
1669
+ }
1670
+ ));
1671
+ EasyVisionCardDescription.displayName = "EasyVisionCardDescription";
1672
+ var EasyVisionCardContent = React8__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("div", { ref, className: join("p-6 pt-0", className), ...props }));
1673
+ EasyVisionCardContent.displayName = "EasyVisionCardContent";
1674
+ var EasyVisionCardFooter = React8__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
1675
+ "div",
1676
+ {
1677
+ ref,
1678
+ className: join("flex items-center p-6 pt-0", className),
1679
+ ...props
1680
+ }
1681
+ ));
1682
+ EasyVisionCardFooter.displayName = "EasyVisionCardFooter";
1683
+ var Table = React8__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("div", { className: "relative w-full overflow-auto", children: /* @__PURE__ */ jsxRuntime.jsx(
1684
+ "table",
1685
+ {
1686
+ ref,
1687
+ className: cn("w-full caption-bottom text-sm", className),
1688
+ ...props
1689
+ }
1690
+ ) }));
1691
+ Table.displayName = "Table";
1692
+ var TableHeader = React8__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("thead", { ref, className: cn("[&_tr]:border-b", className), ...props }));
1693
+ TableHeader.displayName = "TableHeader";
1694
+ var TableBody = React8__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
1695
+ "tbody",
1696
+ {
1697
+ ref,
1698
+ className: cn("[&_tr:last-child]:border-0", className),
1699
+ ...props
1700
+ }
1701
+ ));
1702
+ TableBody.displayName = "TableBody";
1703
+ var TableFooter = React8__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
1704
+ "tfoot",
1705
+ {
1706
+ ref,
1707
+ className: cn(
1708
+ "border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",
1709
+ className
1710
+ ),
1711
+ ...props
1712
+ }
1713
+ ));
1714
+ TableFooter.displayName = "TableFooter";
1715
+ var TableRow = React8__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
1716
+ "tr",
1717
+ {
1718
+ ref,
1719
+ className: cn(
1720
+ "border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted",
1721
+ className
1722
+ ),
1723
+ ...props
1724
+ }
1725
+ ));
1726
+ TableRow.displayName = "TableRow";
1727
+ var TableHead = React8__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
1728
+ "th",
1729
+ {
1730
+ ref,
1731
+ className: cn(
1732
+ "h-12 px-4 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0",
1733
+ className
1734
+ ),
1735
+ ...props
1736
+ }
1737
+ ));
1738
+ TableHead.displayName = "TableHead";
1739
+ var TableCell = React8__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
1740
+ "td",
1741
+ {
1742
+ ref,
1743
+ className: cn("p-4 align-middle [&:has([role=checkbox])]:pr-0", className),
1744
+ ...props
1745
+ }
1746
+ ));
1747
+ TableCell.displayName = "TableCell";
1748
+ var TableCaption = React8__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
1749
+ "caption",
1750
+ {
1751
+ ref,
1752
+ className: cn("mt-4 text-sm text-muted-foreground", className),
1753
+ ...props
1754
+ }
1755
+ ));
1756
+ TableCaption.displayName = "TableCaption";
1757
+ var isNestedField = (field) => field.includes(".");
1758
+ var resolvePath = (obj, path) => path.split(".").reduce(
1759
+ (acc, key) => acc != null && typeof acc === "object" ? acc[key] : void 0,
1760
+ obj
1761
+ );
1762
+ function shouldDisableSorting(col, orderingMode, defaultSorting = "nonNested") {
1763
+ if (col.type === "ui") return true;
1764
+ if (col.sortable === false) return true;
1765
+ if (col.sortable === true) return false;
1766
+ if (defaultSorting === "disabled") return true;
1767
+ if (defaultSorting === "all") return false;
1768
+ if (orderingMode === "api" && isNestedField(col.field)) return true;
1769
+ return false;
1770
+ }
1771
+ function adaptColumns(columns, orderingMode, defaultSorting = "nonNested") {
1772
+ return columns.map((c) => {
1773
+ const widthCss = typeof c.width === "number" ? `${c.width}px` : c.width;
1774
+ const numericWidth = typeof c.width === "number" ? c.width : typeof c.width === "string" && /^\d+px$/.test(c.width) ? parseInt(c.width, 10) : void 0;
1775
+ const meta = {
1776
+ initiallyHidden: !!c.initiallyHidden,
1777
+ largeScreensOnly: !!c.largeScreensOnly,
1778
+ width: widthCss,
1779
+ truncate: !!c.truncate,
1780
+ resizable: !!c.resizable
1781
+ };
1782
+ const isUi = c.type === "ui";
1783
+ const userCell = c.cell;
1784
+ const wrappedCell = userCell ? ({ row }) => userCell(row.original) : ({ getValue }) => React8.createElement(
1785
+ "span",
1786
+ { className: "text-sm text-foreground" },
1787
+ String(getValue() ?? "-")
1788
+ );
1789
+ const base = {
1790
+ id: c.field,
1791
+ header: c.header,
1792
+ cell: wrappedCell,
1793
+ enableSorting: !shouldDisableSorting(c, orderingMode, defaultSorting),
1794
+ enableHiding: true,
1795
+ enableResizing: !!c.resizable,
1796
+ meta
1797
+ };
1798
+ if (c.resizable) {
1799
+ base.size = numericWidth ?? 240;
1800
+ base.minSize = 60;
1801
+ } else if (numericWidth !== void 0) {
1802
+ base.size = numericWidth;
1803
+ }
1804
+ if (!isUi) {
1805
+ base.accessorFn = (row) => resolvePath(row, c.field);
1806
+ }
1807
+ return base;
1808
+ });
1809
+ }
1810
+
1811
+ // lib/isNestedAccessor.ts
1812
+ function getByPath(obj, path) {
1813
+ if (!obj || !path) return void 0;
1814
+ return path.split(".").reduce((acc, key) => {
1815
+ if (acc && typeof acc === "object") {
1816
+ return acc[key];
1817
+ }
1818
+ return void 0;
1819
+ }, obj);
1820
+ }
1821
+
1822
+ // lib/compareByPath.ts
1823
+ var numericRe = /-?\d+(?:[.,]\d+)?/;
1824
+ function extractFirstNumber(value) {
1825
+ if (typeof value === "number") return Number.isNaN(value) ? null : value;
1826
+ if (typeof value === "string") {
1827
+ const match = value.match(numericRe);
1828
+ if (match) {
1829
+ const parsed = parseFloat(match[0].replace(",", "."));
1830
+ return Number.isNaN(parsed) ? null : parsed;
1831
+ }
1832
+ }
1833
+ return null;
1834
+ }
1835
+ function compareByPath(a, b, path, descending) {
1836
+ const av = getByPath(a, path);
1837
+ const bv = getByPath(b, path);
1838
+ if (av == null && bv == null) return 0;
1839
+ if (av == null) return descending ? 1 : -1;
1840
+ if (bv == null) return descending ? -1 : 1;
1841
+ const an = extractFirstNumber(av);
1842
+ const bn = extractFirstNumber(bv);
1843
+ if (an !== null && bn !== null) {
1844
+ return descending ? bn - an : an - bn;
1845
+ }
1846
+ if (av instanceof Date && bv instanceof Date) {
1847
+ return descending ? bv.getTime() - av.getTime() : av.getTime() - bv.getTime();
1848
+ }
1849
+ const as = String(av);
1850
+ const bs = String(bv);
1851
+ return descending ? bs.localeCompare(as) : as.localeCompare(bs);
1852
+ }
1853
+
1854
+ // table/useTableData.ts
1855
+ function useTableData({
1856
+ data,
1857
+ columns,
1858
+ page,
1859
+ itemsPerPage,
1860
+ sort,
1861
+ paginationMode,
1862
+ orderingMode
1863
+ }) {
1864
+ return React8.useMemo(() => {
1865
+ let rows = data ?? [];
1866
+ if (orderingMode === "local" && sort) {
1867
+ const col = columns.find((c) => c.field === sort.column);
1868
+ if (col && col.type !== "ui") {
1869
+ const next = [...rows];
1870
+ next.sort((a, b) => compareByPath(a, b, col.field, sort.descending));
1871
+ rows = next;
1872
+ }
1873
+ }
1874
+ const totalCount = rows.length;
1875
+ if (paginationMode === "local") {
1876
+ const start = (page - 1) * itemsPerPage;
1877
+ rows = rows.slice(start, start + itemsPerPage);
1878
+ }
1879
+ return { rows, totalCount };
1880
+ }, [data, columns, page, itemsPerPage, sort, paginationMode, orderingMode]);
1881
+ }
1882
+ var DropdownMenu = DropdownMenuPrimitive__namespace.Root;
1883
+ var DropdownMenuTrigger = DropdownMenuPrimitive__namespace.Trigger;
1884
+ var DropdownMenuRadioGroup = DropdownMenuPrimitive__namespace.RadioGroup;
1885
+ var DropdownMenuSubTrigger = React8__namespace.forwardRef(({ className, inset, children, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsxs(
1886
+ DropdownMenuPrimitive__namespace.SubTrigger,
1887
+ {
1888
+ ref,
1889
+ className: cn(
1890
+ "flex cursor-default select-none items-center gap-2 rounded-md px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",
1891
+ inset && "pl-8",
1892
+ className
1893
+ ),
1894
+ ...props,
1895
+ children: [
1896
+ children,
1897
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronRight, { className: "ml-auto" })
1898
+ ]
1899
+ }
1900
+ ));
1901
+ DropdownMenuSubTrigger.displayName = DropdownMenuPrimitive__namespace.SubTrigger.displayName;
1902
+ var DropdownMenuSubContent = React8__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
1903
+ DropdownMenuPrimitive__namespace.SubContent,
1904
+ {
1905
+ ref,
1906
+ className: cn(
1907
+ "z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-dropdown-menu-content-transform-origin]",
1908
+ className
1909
+ ),
1910
+ ...props
1911
+ }
1912
+ ));
1913
+ DropdownMenuSubContent.displayName = DropdownMenuPrimitive__namespace.SubContent.displayName;
1914
+ var DropdownMenuContent = React8__namespace.forwardRef(({ className, sideOffset = 4, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(DropdownMenuPrimitive__namespace.Portal, { children: /* @__PURE__ */ jsxRuntime.jsx(
1915
+ DropdownMenuPrimitive__namespace.Content,
1916
+ {
1917
+ ref,
1918
+ sideOffset,
1919
+ className: cn(
1920
+ "z-50 max-h-[var(--radix-dropdown-menu-content-available-height)] min-w-[8rem] overflow-y-auto overflow-x-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-dropdown-menu-content-transform-origin]",
1921
+ className
1922
+ ),
1923
+ ...props
1924
+ }
1925
+ ) }));
1926
+ DropdownMenuContent.displayName = DropdownMenuPrimitive__namespace.Content.displayName;
1927
+ var DropdownMenuItem = React8__namespace.forwardRef(({ className, inset, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
1928
+ DropdownMenuPrimitive__namespace.Item,
1929
+ {
1930
+ ref,
1931
+ className: cn(
1932
+ "relative flex cursor-default select-none items-center gap-2 rounded-md px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",
1933
+ inset && "pl-8",
1934
+ className
1935
+ ),
1936
+ ...props
1937
+ }
1938
+ ));
1939
+ DropdownMenuItem.displayName = DropdownMenuPrimitive__namespace.Item.displayName;
1940
+ var DropdownMenuCheckboxItem = React8__namespace.forwardRef(({ className, children, checked, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsxs(
1941
+ DropdownMenuPrimitive__namespace.CheckboxItem,
1942
+ {
1943
+ ref,
1944
+ className: cn(
1945
+ "relative flex cursor-default select-none items-center rounded-md py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
1946
+ className
1947
+ ),
1948
+ checked,
1949
+ ...props,
1950
+ children: [
1951
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "absolute left-2 flex h-3.5 w-3.5 items-center justify-center", children: /* @__PURE__ */ jsxRuntime.jsx(DropdownMenuPrimitive__namespace.ItemIndicator, { children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Check, { className: "h-4 w-4" }) }) }),
1952
+ children
1953
+ ]
1954
+ }
1955
+ ));
1956
+ DropdownMenuCheckboxItem.displayName = DropdownMenuPrimitive__namespace.CheckboxItem.displayName;
1957
+ var DropdownMenuRadioItem = React8__namespace.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsxs(
1958
+ DropdownMenuPrimitive__namespace.RadioItem,
1959
+ {
1960
+ ref,
1961
+ className: cn(
1962
+ "relative flex cursor-default select-none items-center rounded-md py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
1963
+ className
1964
+ ),
1965
+ ...props,
1966
+ children: [
1967
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "absolute left-2 flex h-3.5 w-3.5 items-center justify-center", children: /* @__PURE__ */ jsxRuntime.jsx(DropdownMenuPrimitive__namespace.ItemIndicator, { children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Circle, { className: "h-2 w-2 fill-current" }) }) }),
1968
+ children
1969
+ ]
1970
+ }
1971
+ ));
1972
+ DropdownMenuRadioItem.displayName = DropdownMenuPrimitive__namespace.RadioItem.displayName;
1973
+ var DropdownMenuLabel = React8__namespace.forwardRef(({ className, inset, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
1974
+ DropdownMenuPrimitive__namespace.Label,
1975
+ {
1976
+ ref,
1977
+ className: cn(
1978
+ "px-2 py-1.5 text-sm font-semibold",
1979
+ inset && "pl-8",
1980
+ className
1981
+ ),
1982
+ ...props
1983
+ }
1984
+ ));
1985
+ DropdownMenuLabel.displayName = DropdownMenuPrimitive__namespace.Label.displayName;
1986
+ var DropdownMenuSeparator = React8__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
1987
+ DropdownMenuPrimitive__namespace.Separator,
1988
+ {
1989
+ ref,
1990
+ className: cn("-mx-1 my-1 h-px bg-muted", className),
1991
+ ...props
1992
+ }
1993
+ ));
1994
+ DropdownMenuSeparator.displayName = DropdownMenuPrimitive__namespace.Separator.displayName;
1995
+ function SelectAllControl({
1996
+ scope,
1997
+ toggleable,
1998
+ state,
1999
+ onToggle,
2000
+ onScopeChange,
2001
+ labels
2002
+ }) {
2003
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-1", children: [
2004
+ /* @__PURE__ */ jsxRuntime.jsx(
2005
+ Checkbox,
2006
+ {
2007
+ checked: state === "checked" ? true : state === "indeterminate" ? "indeterminate" : false,
2008
+ onCheckedChange: (c) => onToggle(!!c),
2009
+ "aria-label": "Select all"
2010
+ }
2011
+ ),
2012
+ toggleable && /* @__PURE__ */ jsxRuntime.jsxs(DropdownMenu, { children: [
2013
+ /* @__PURE__ */ jsxRuntime.jsx(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(
2014
+ "button",
2015
+ {
2016
+ type: "button",
2017
+ className: "flex h-5 w-5 items-center justify-center rounded border border-border bg-background hover:bg-muted",
2018
+ "aria-label": "Toggle select-all scope",
2019
+ children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronDown, { className: "h-3.5 w-3.5" })
2020
+ }
2021
+ ) }),
2022
+ /* @__PURE__ */ jsxRuntime.jsx(DropdownMenuContent, { align: "start", children: /* @__PURE__ */ jsxRuntime.jsxs(
2023
+ DropdownMenuRadioGroup,
2024
+ {
2025
+ value: scope,
2026
+ onValueChange: (v) => onScopeChange(v),
2027
+ children: [
2028
+ /* @__PURE__ */ jsxRuntime.jsx(DropdownMenuRadioItem, { value: "page", children: labels.selectAllPage }),
2029
+ /* @__PURE__ */ jsxRuntime.jsx(DropdownMenuRadioItem, { value: "all", children: labels.selectAllAll })
2030
+ ]
2031
+ }
2032
+ ) })
2033
+ ] })
2034
+ ] });
2035
+ }
2036
+ function PaginationFooter({
2037
+ currentPage,
2038
+ totalCount,
2039
+ itemsPerPage,
2040
+ itemsPerPageOptions,
2041
+ onPageChange,
2042
+ onItemsPerPageChange,
2043
+ labels
2044
+ }) {
2045
+ const totalPages = Math.max(1, Math.ceil(totalCount / itemsPerPage));
2046
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between p-4 border-t border-border text-sm text-muted-foreground", children: [
2047
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-3", children: [
2048
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: labels.rowsPerPage }),
2049
+ /* @__PURE__ */ jsxRuntime.jsxs(
2050
+ Select,
2051
+ {
2052
+ value: String(itemsPerPage),
2053
+ onValueChange: (v) => onItemsPerPageChange(Number(v)),
2054
+ children: [
2055
+ /* @__PURE__ */ jsxRuntime.jsx(SelectTrigger, { className: "h-9 w-[70px] border border-border", children: /* @__PURE__ */ jsxRuntime.jsx(SelectValue, {}) }),
2056
+ /* @__PURE__ */ jsxRuntime.jsx(SelectContent, { children: itemsPerPageOptions.map((opt) => /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: String(opt), children: opt }, opt)) })
2057
+ ]
2058
+ }
2059
+ ),
2060
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
2061
+ totalCount,
2062
+ " ",
2063
+ labels.results
2064
+ ] })
2065
+ ] }),
2066
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-3", children: [
2067
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: labels.page }),
2068
+ /* @__PURE__ */ jsxRuntime.jsxs(
2069
+ Select,
2070
+ {
2071
+ value: String(currentPage),
2072
+ onValueChange: (v) => onPageChange(Number(v)),
2073
+ children: [
2074
+ /* @__PURE__ */ jsxRuntime.jsx(SelectTrigger, { className: "h-9 w-16 border border-border", children: /* @__PURE__ */ jsxRuntime.jsx(SelectValue, {}) }),
2075
+ /* @__PURE__ */ jsxRuntime.jsx(SelectContent, { children: Array.from({ length: totalPages }, (_, i) => i + 1).map((p) => /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: String(p), children: p }, p)) })
2076
+ ]
2077
+ }
2078
+ ),
2079
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
2080
+ labels.of,
2081
+ " ",
2082
+ totalPages
2083
+ ] }),
2084
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-1 ml-1", children: [
2085
+ /* @__PURE__ */ jsxRuntime.jsx(
2086
+ Button,
2087
+ {
2088
+ variant: "ghost",
2089
+ size: "icon",
2090
+ className: "h-8 w-8",
2091
+ disabled: currentPage <= 1,
2092
+ onClick: () => onPageChange(currentPage - 1),
2093
+ children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronLeft, { className: "h-4 w-4" })
2094
+ }
2095
+ ),
2096
+ /* @__PURE__ */ jsxRuntime.jsx(
2097
+ Button,
2098
+ {
2099
+ variant: "ghost",
2100
+ size: "icon",
2101
+ className: "h-8 w-8",
2102
+ disabled: currentPage >= totalPages,
2103
+ onClick: () => onPageChange(currentPage + 1),
2104
+ children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronRight, { className: "h-4 w-4" })
2105
+ }
2106
+ )
2107
+ ] })
2108
+ ] })
2109
+ ] });
2110
+ }
2111
+ function ColumnVisibilityMenu({ table, label }) {
2112
+ return /* @__PURE__ */ jsxRuntime.jsxs(DropdownMenu, { children: [
2113
+ /* @__PURE__ */ jsxRuntime.jsx(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsxs(Button, { variant: "outline", size: "sm", children: [
2114
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Settings2, { className: "mr-2 h-4 w-4" }),
2115
+ label
2116
+ ] }) }),
2117
+ /* @__PURE__ */ jsxRuntime.jsx(DropdownMenuContent, { align: "end", className: "max-h-64 overflow-y-auto", children: table.getAllColumns().filter((col) => col.getCanHide() && col.id !== "_select").map((col) => {
2118
+ const rawHeader = col.columnDef.header;
2119
+ const headerLabel = typeof rawHeader === "string" && rawHeader.trim().length > 0 ? rawHeader : col.id;
2120
+ return /* @__PURE__ */ jsxRuntime.jsx(
2121
+ DropdownMenuCheckboxItem,
2122
+ {
2123
+ checked: col.getIsVisible(),
2124
+ onCheckedChange: (v) => col.toggleVisibility(!!v),
2125
+ className: "capitalize",
2126
+ children: headerLabel
2127
+ },
2128
+ col.id
2129
+ );
2130
+ }) })
2131
+ ] });
2132
+ }
2133
+
2134
+ // adapters/loopback.ts
2135
+ function createLoopbackTableFetcher(opts) {
2136
+ const { fetchPage, fetchCount, include, fields, defaultOrder } = opts;
2137
+ return async ({
2138
+ page,
2139
+ itemsPerPage,
2140
+ sort,
2141
+ filter
2142
+ }) => {
2143
+ const order = sort ? [`${sort.column} ${sort.descending ? "DESC" : "ASC"}`] : defaultOrder ?? [];
2144
+ const skip = (page - 1) * itemsPerPage;
2145
+ const where = filter?.where ?? {};
2146
+ const pageFilter = {
2147
+ where,
2148
+ skip,
2149
+ limit: itemsPerPage,
2150
+ order,
2151
+ ...include ? { include } : {},
2152
+ ...fields ? { fields } : {}
2153
+ };
2154
+ const [rows, count] = await Promise.all([
2155
+ fetchPage(pageFilter),
2156
+ fetchCount({ where })
2157
+ ]);
2158
+ return { rows, totalCount: count.count };
2159
+ };
2160
+ }
2161
+ function matchLoopbackWhere(row, where) {
2162
+ if (!where) return true;
2163
+ const w = where;
2164
+ const keys = Object.keys(w);
2165
+ if (keys.length === 0) return true;
2166
+ for (const key of keys) {
2167
+ const value = w[key];
2168
+ if (key === "$and") {
2169
+ if (!Array.isArray(value)) return false;
2170
+ if (!value.every((sub) => matchLoopbackWhere(row, sub))) {
2171
+ return false;
2172
+ }
2173
+ continue;
2174
+ }
2175
+ if (key === "$or") {
2176
+ if (!Array.isArray(value)) return false;
2177
+ if (!value.some((sub) => matchLoopbackWhere(row, sub))) {
2178
+ return false;
2179
+ }
2180
+ continue;
2181
+ }
2182
+ if (key === "$not") {
2183
+ if (matchLoopbackWhere(row, value)) return false;
2184
+ continue;
2185
+ }
2186
+ const values = resolvePath2(row, key.split("."));
2187
+ if (!values.some((v) => matchLeaf(v, value))) return false;
2188
+ }
2189
+ return true;
2190
+ }
2191
+ function resolvePath2(node, path) {
2192
+ if (path.length === 0) return [node];
2193
+ if (node == null) return [void 0];
2194
+ if (Array.isArray(node)) {
2195
+ return node.flatMap((item) => resolvePath2(item, path));
2196
+ }
2197
+ if (typeof node !== "object") return [void 0];
2198
+ const [head, ...rest] = path;
2199
+ return resolvePath2(node[head], rest);
2200
+ }
2201
+ function matchLeaf(value, condition) {
2202
+ if (condition === null || typeof condition !== "object") {
2203
+ if (Array.isArray(value)) return value.some((v) => v === condition);
2204
+ return value === condition;
2205
+ }
2206
+ const cond = condition;
2207
+ const keys = Object.keys(cond);
2208
+ if (keys.length === 0) return true;
2209
+ if (!keys.some((k) => k.startsWith("$"))) return false;
2210
+ for (const op of keys) {
2211
+ const arg = cond[op];
2212
+ switch (op) {
2213
+ case "$eq":
2214
+ if (Array.isArray(value) ? !value.includes(arg) : value !== arg) return false;
2215
+ break;
2216
+ case "$ne":
2217
+ case "$neq":
2218
+ if (Array.isArray(value) ? value.includes(arg) : value === arg) return false;
2219
+ break;
2220
+ case "$in":
2221
+ if (!Array.isArray(arg)) return false;
2222
+ if (Array.isArray(value)) {
2223
+ if (!value.some((v) => arg.includes(v))) return false;
2224
+ } else if (!arg.includes(value)) {
2225
+ return false;
2226
+ }
2227
+ break;
2228
+ case "$nin":
2229
+ if (!Array.isArray(arg)) return false;
2230
+ if (Array.isArray(value)) {
2231
+ if (value.some((v) => arg.includes(v))) return false;
2232
+ } else if (arg.includes(value)) {
2233
+ return false;
2234
+ }
2235
+ break;
2236
+ case "$gt":
2237
+ if (value == null || !(value > arg)) return false;
2238
+ break;
2239
+ case "$gte":
2240
+ if (value == null || !(value >= arg)) return false;
2241
+ break;
2242
+ case "$lt":
2243
+ if (value == null || !(value < arg)) return false;
2244
+ break;
2245
+ case "$lte":
2246
+ if (value == null || !(value <= arg)) return false;
2247
+ break;
2248
+ case "$exists": {
2249
+ const exists = value !== void 0 && value !== null;
2250
+ if (Boolean(arg) !== exists) return false;
2251
+ break;
2252
+ }
2253
+ case "$regex": {
2254
+ const opts = typeof cond.$options === "string" ? cond.$options : "";
2255
+ let re;
2256
+ try {
2257
+ re = arg instanceof RegExp ? arg : new RegExp(String(arg), opts);
2258
+ } catch {
2259
+ return false;
2260
+ }
2261
+ if (Array.isArray(value)) {
2262
+ if (!value.some((v) => typeof v === "string" && re.test(v))) return false;
2263
+ } else if (typeof value !== "string" || !re.test(value)) {
2264
+ return false;
2265
+ }
2266
+ break;
2267
+ }
2268
+ case "$options":
2269
+ break;
2270
+ default:
2271
+ return false;
2272
+ }
2273
+ }
2274
+ return true;
2275
+ }
2276
+ var DEFAULT_LABELS2 = {
2277
+ rowsPerPage: "Resultados por p\xE1gina:",
2278
+ results: "Resultados",
2279
+ page: "P\xE1gina:",
2280
+ of: "de",
2281
+ noData: "Sin datos",
2282
+ loading: "Cargando...",
2283
+ customizeColumns: "Columnas",
2284
+ selectAllPage: "Seleccionar p\xE1gina",
2285
+ selectAllAll: "Seleccionar todo",
2286
+ selectedAllBanner: (n) => `Todos los ${n} registros seleccionados`,
2287
+ selectedCountBanner: (n) => `${n} ${n === 1 ? "registro seleccionado" : "registros seleccionados"}`,
2288
+ clearSelection: "Limpiar selecci\xF3n"
2289
+ };
2290
+ function EasyVisionTable(props) {
2291
+ const {
2292
+ id,
2293
+ columns,
2294
+ paginationMode: paginationModeProp = "local",
2295
+ orderingMode: orderingModeProp = "local",
2296
+ defaultSorting = "nonNested",
2297
+ data,
2298
+ fetchData: fetchDataProp,
2299
+ loopback,
2300
+ onDataLoaded,
2301
+ multifilter,
2302
+ multifilterRef,
2303
+ refetchSignal,
2304
+ externalFilter,
2305
+ localMatch: localMatchProp,
2306
+ getRowId: getRowIdProp,
2307
+ itemsPerPage: itemsPerPageProp = 10,
2308
+ itemsPerPageOptions = [10, 15, 20],
2309
+ enableRowSelection = false,
2310
+ selectAllScope = "toggleable",
2311
+ selectAllResolution = "lazy",
2312
+ onSelectionChange,
2313
+ isLoading: isLoadingProp = false,
2314
+ emptyMessage,
2315
+ emptyAction,
2316
+ onRowClick,
2317
+ isRowHighlighted,
2318
+ toolbarLeft,
2319
+ toolbarRight,
2320
+ showColumnVisibility = true,
2321
+ maxBodyHeight,
2322
+ labels: labelOverrides,
2323
+ className,
2324
+ persist = false
2325
+ } = props;
2326
+ const labels = { ...DEFAULT_LABELS2, ...labelOverrides };
2327
+ const lbFetchPage = loopback?.fetchPage;
2328
+ const lbFetchCount = loopback?.fetchCount;
2329
+ const lbIncludeKey = JSON.stringify(loopback?.include ?? null);
2330
+ const lbFieldsKey = JSON.stringify(loopback?.fields ?? null);
2331
+ const lbOrderKey = JSON.stringify(loopback?.defaultOrder ?? null);
2332
+ const loopbackFetcher = React8.useMemo(
2333
+ () => loopback ? createLoopbackTableFetcher(loopback) : void 0,
2334
+ // eslint-disable-next-line react-hooks/exhaustive-deps
2335
+ [lbFetchPage, lbFetchCount, lbIncludeKey, lbFieldsKey, lbOrderKey]
2336
+ );
2337
+ const fetchData = fetchDataProp ?? loopbackFetcher;
2338
+ const paginationMode = loopback ? "api" : paginationModeProp;
2339
+ const orderingMode = loopback ? "api" : orderingModeProp;
2340
+ const getRowId = React8.useMemo(
2341
+ () => getRowIdProp ?? ((row) => String(row?.id ?? "")),
2342
+ [getRowIdProp]
2343
+ );
2344
+ const localMatch = localMatchProp ?? matchLoopbackWhere;
2345
+ const { slice, fullId, patch } = useEasyVisionSlice("table", id, {
2346
+ init: () => ({
2347
+ kind: "table",
2348
+ page: 1,
2349
+ itemsPerPage: itemsPerPageProp,
2350
+ sort: null,
2351
+ selection: {
2352
+ ids: {},
2353
+ scope: selectAllScope === "all" ? "all" : "page"
2354
+ }
2355
+ }),
2356
+ persist
2357
+ });
2358
+ const { page, itemsPerPage, sort, selection } = slice;
2359
+ const lastSnapshotRef = React8.useRef(null);
2360
+ const [localFilterTick, setLocalFilterTick] = React8.useState(0);
2361
+ const innerMultifilterRef = React8.useRef(null);
2362
+ const setMultifilterRef = React8.useCallback(
2363
+ (handle) => {
2364
+ innerMultifilterRef.current = handle;
2365
+ if (typeof multifilterRef === "function") {
2366
+ multifilterRef(handle);
2367
+ } else if (multifilterRef && "current" in multifilterRef) {
2368
+ multifilterRef.current = handle;
2369
+ }
2370
+ },
2371
+ [multifilterRef]
2372
+ );
2373
+ const [apiRows, setApiRows] = React8.useState([]);
2374
+ const [apiTotalCount, setApiTotalCount] = React8.useState(0);
2375
+ const [apiLoading, setApiLoading] = React8.useState(false);
2376
+ const fetchSeqRef = React8.useRef(0);
2377
+ const isApi = paginationMode === "api" || orderingMode === "api";
2378
+ const [eagerAllIds, setEagerAllIds] = React8.useState(null);
2379
+ const [eagerAllRows, setEagerAllRows] = React8.useState([]);
2380
+ const [isResolvingEager, setIsResolvingEager] = React8.useState(false);
2381
+ const eagerSeqRef = React8.useRef(0);
2382
+ const runFetch = React8.useCallback(async () => {
2383
+ if (!fetchData) return;
2384
+ const seq = ++fetchSeqRef.current;
2385
+ setApiLoading(true);
2386
+ try {
2387
+ const mfQuery = lastSnapshotRef.current?.query;
2388
+ const merged = externalFilter || mfQuery ? {
2389
+ ...mfQuery,
2390
+ where: {
2391
+ ...externalFilter?.where ?? {},
2392
+ ...mfQuery?.where ?? {}
2393
+ }
2394
+ } : void 0;
2395
+ const result = await fetchData({
2396
+ page,
2397
+ itemsPerPage,
2398
+ sort,
2399
+ filter: merged
2400
+ });
2401
+ if (seq !== fetchSeqRef.current) return;
2402
+ setApiRows(result.rows);
2403
+ setApiTotalCount(result.totalCount);
2404
+ onDataLoaded?.(result.rows, result.totalCount);
2405
+ } finally {
2406
+ if (seq === fetchSeqRef.current) setApiLoading(false);
2407
+ }
2408
+ }, [fetchData, page, itemsPerPage, sort, externalFilter, onDataLoaded]);
2409
+ React8.useEffect(() => {
2410
+ if (isApi && fetchData) void runFetch();
2411
+ }, [isApi, page, itemsPerPage, sort, refetchSignal]);
2412
+ const resolveEagerAll = React8.useCallback(async () => {
2413
+ if (!fetchData) return;
2414
+ const seq = ++eagerSeqRef.current;
2415
+ setIsResolvingEager(true);
2416
+ try {
2417
+ const mfQuery = lastSnapshotRef.current?.query;
2418
+ const merged = externalFilter || mfQuery ? {
2419
+ ...mfQuery,
2420
+ where: {
2421
+ ...externalFilter?.where ?? {},
2422
+ ...mfQuery?.where ?? {}
2423
+ }
2424
+ } : void 0;
2425
+ const PAGE_SIZE = 200;
2426
+ const ids = [];
2427
+ const rowsAcc = [];
2428
+ let knownTotal = Infinity;
2429
+ for (let p = 1; ids.length < knownTotal; p++) {
2430
+ const result = await fetchData({
2431
+ page: p,
2432
+ itemsPerPage: PAGE_SIZE,
2433
+ sort,
2434
+ filter: merged
2435
+ });
2436
+ if (seq !== eagerSeqRef.current) return;
2437
+ knownTotal = result.totalCount;
2438
+ for (const row of result.rows) {
2439
+ const rid = getRowId(row);
2440
+ if (rid) {
2441
+ ids.push(rid);
2442
+ rowsAcc.push(row);
2443
+ }
2444
+ }
2445
+ if (result.rows.length < PAGE_SIZE) break;
2446
+ }
2447
+ if (seq !== eagerSeqRef.current) return;
2448
+ setEagerAllIds(ids);
2449
+ setEagerAllRows(rowsAcc);
2450
+ } finally {
2451
+ if (seq === eagerSeqRef.current) setIsResolvingEager(false);
2452
+ }
2453
+ }, [fetchData, externalFilter, sort, getRowId]);
2454
+ const prevRefetchRef = React8.useRef(refetchSignal);
2455
+ React8.useEffect(() => {
2456
+ if (prevRefetchRef.current !== refetchSignal && page !== 1) {
2457
+ prevRefetchRef.current = refetchSignal;
2458
+ patch({ page: 1 });
2459
+ } else {
2460
+ prevRefetchRef.current = refetchSignal;
2461
+ }
2462
+ setEagerAllIds(null);
2463
+ setEagerAllRows([]);
2464
+ eagerSeqRef.current++;
2465
+ setIsResolvingEager(false);
2466
+ }, [refetchSignal]);
2467
+ const filteredData = React8.useMemo(() => {
2468
+ if (paginationMode !== "local") return data;
2469
+ if (!data || data.length === 0) return data;
2470
+ const mfWhere = lastSnapshotRef.current?.query?.where;
2471
+ const extWhere = externalFilter?.where;
2472
+ const merged = extWhere || mfWhere ? { ...extWhere ?? {}, ...mfWhere ?? {} } : void 0;
2473
+ if (!merged || Object.keys(merged).length === 0) return data;
2474
+ return data.filter((row) => localMatch(row, merged));
2475
+ }, [data, paginationMode, localMatch, localFilterTick, externalFilter]);
2476
+ const local = useTableData({
2477
+ data: filteredData,
2478
+ columns,
2479
+ page,
2480
+ itemsPerPage,
2481
+ sort,
2482
+ paginationMode,
2483
+ orderingMode
2484
+ });
2485
+ const rows = isApi ? apiRows : local.rows;
2486
+ const totalCount = isApi ? apiTotalCount : local.totalCount;
2487
+ const isLoading = isLoadingProp || apiLoading;
2488
+ const tanstackColumns = React8.useMemo(
2489
+ () => adaptColumns(columns, orderingMode, defaultSorting),
2490
+ [columns, orderingMode, defaultSorting]
2491
+ );
2492
+ const allColumns = React8.useMemo(() => {
2493
+ if (!enableRowSelection) return tanstackColumns;
2494
+ const checkboxCol = {
2495
+ id: "_select",
2496
+ header: () => null,
2497
+ // we render our own header in the header row below
2498
+ cell: ({ row }) => /* @__PURE__ */ jsxRuntime.jsx(
2499
+ Checkbox,
2500
+ {
2501
+ checked: row.getIsSelected(),
2502
+ onCheckedChange: (v) => row.toggleSelected(!!v),
2503
+ onClick: (e) => e.stopPropagation(),
2504
+ "aria-label": "Select row"
2505
+ }
2506
+ ),
2507
+ enableSorting: false,
2508
+ enableHiding: false
2509
+ };
2510
+ return [checkboxCol, ...tanstackColumns];
2511
+ }, [enableRowSelection, tanstackColumns]);
2512
+ const [columnVisibility, setColumnVisibility] = React8.useState(() => {
2513
+ const v = {};
2514
+ for (const c of columns) {
2515
+ if (c.initiallyHidden) v[c.field] = false;
2516
+ }
2517
+ return v;
2518
+ });
2519
+ const rowSelection = React8.useMemo(() => {
2520
+ if (selection.scope === "all") return {};
2521
+ const r = {};
2522
+ for (const id2 of Object.keys(selection.ids)) r[id2] = true;
2523
+ return r;
2524
+ }, [selection]);
2525
+ const sortingState = sort ? [{ id: sort.column, desc: sort.descending }] : [];
2526
+ const isEagerWildcard = selectAllResolution === "eager" && isApi && selection.scope === "all";
2527
+ const tableInstance = reactTable.useReactTable({
2528
+ data: rows,
2529
+ columns: allColumns,
2530
+ state: {
2531
+ columnVisibility,
2532
+ ...enableRowSelection ? { rowSelection } : {},
2533
+ sorting: sortingState
2534
+ },
2535
+ onColumnVisibilityChange: setColumnVisibility,
2536
+ enableRowSelection,
2537
+ onRowSelectionChange: enableRowSelection ? (updater) => {
2538
+ const next = typeof updater === "function" ? updater(rowSelection) : updater;
2539
+ const ids = {};
2540
+ for (const k of Object.keys(next)) {
2541
+ if (next[k]) ids[k] = true;
2542
+ }
2543
+ patch({ selection: { ...selection, ids } });
2544
+ } : void 0,
2545
+ onSortingChange: (updater) => {
2546
+ if (isEagerWildcard) return;
2547
+ const next = typeof updater === "function" ? updater(sortingState) : updater;
2548
+ const first = next[0];
2549
+ const newSort = first ? { column: first.id, descending: !!first.desc } : null;
2550
+ patch({ sort: newSort });
2551
+ },
2552
+ getCoreRowModel: reactTable.getCoreRowModel(),
2553
+ manualPagination: true,
2554
+ manualSorting: true,
2555
+ enableColumnResizing: true,
2556
+ columnResizeMode: "onChange",
2557
+ pageCount: Math.ceil(totalCount / itemsPerPage),
2558
+ getRowId
2559
+ });
2560
+ const lastSelectionEmittedRef = React8.useRef("");
2561
+ React8.useEffect(() => {
2562
+ if (!enableRowSelection) return;
2563
+ if (isEagerWildcard && (isResolvingEager || eagerAllIds === null)) return;
2564
+ let event;
2565
+ if (selection.scope === "all") {
2566
+ if (paginationMode === "local") {
2567
+ const allRows = filteredData ?? data ?? [];
2568
+ const ids = allRows.map(getRowId).filter(Boolean);
2569
+ event = { scope: "all", mode: "in-memory", ids, rows: allRows };
2570
+ } else if (selectAllResolution === "eager" && eagerAllIds) {
2571
+ const exceptSet = new Set(Object.keys(selection.exceptIds ?? {}));
2572
+ let ids;
2573
+ let outRows;
2574
+ if (exceptSet.size) {
2575
+ ids = [];
2576
+ outRows = [];
2577
+ for (let i = 0; i < eagerAllIds.length; i++) {
2578
+ const rid = eagerAllIds[i];
2579
+ if (exceptSet.has(rid)) continue;
2580
+ ids.push(rid);
2581
+ const r = eagerAllRows[i];
2582
+ if (r !== void 0) outRows.push(r);
2583
+ }
2584
+ } else {
2585
+ ids = eagerAllIds;
2586
+ outRows = eagerAllRows;
2587
+ }
2588
+ event = { scope: "all", mode: "in-memory", ids, rows: outRows };
2589
+ } else {
2590
+ const exceptIds = Object.keys(selection.exceptIds ?? {});
2591
+ const exceptSet = new Set(exceptIds);
2592
+ const pageRows = rows.filter((r) => !exceptSet.has(getRowId(r)));
2593
+ const ids = pageRows.map(getRowId).filter(Boolean);
2594
+ event = {
2595
+ scope: "all",
2596
+ mode: "wildcard",
2597
+ ids,
2598
+ exceptIds,
2599
+ rows: pageRows
2600
+ };
2601
+ }
2602
+ } else {
2603
+ const ids = Object.keys(selection.ids);
2604
+ const idSet = new Set(ids);
2605
+ const selectedRows = rows.filter((r) => idSet.has(getRowId(r)));
2606
+ event = { scope: "page", ids, rows: selectedRows };
2607
+ }
2608
+ const key = JSON.stringify({ ...event, rows: event.rows.length });
2609
+ if (key === lastSelectionEmittedRef.current) return;
2610
+ lastSelectionEmittedRef.current = key;
2611
+ onSelectionChange?.(event);
2612
+ }, [
2613
+ enableRowSelection,
2614
+ selection,
2615
+ paginationMode,
2616
+ data,
2617
+ filteredData,
2618
+ rows,
2619
+ getRowId,
2620
+ onSelectionChange,
2621
+ selectAllResolution,
2622
+ eagerAllIds,
2623
+ eagerAllRows,
2624
+ isResolvingEager,
2625
+ isEagerWildcard
2626
+ ]);
2627
+ const rowIdOf = React8.useCallback(
2628
+ (row) => getRowId(row),
2629
+ [getRowId]
2630
+ );
2631
+ const headerState = React8.useMemo(() => {
2632
+ if (selection.scope === "all") {
2633
+ const except = Object.keys(selection.exceptIds ?? {}).length;
2634
+ if (except === 0) return "checked";
2635
+ return "indeterminate";
2636
+ }
2637
+ const visibleIds = rows.map(rowIdOf).filter(Boolean);
2638
+ if (visibleIds.length === 0) return "unchecked";
2639
+ let selectedOnPage = 0;
2640
+ for (const id2 of visibleIds) {
2641
+ if (selection.ids[id2]) selectedOnPage++;
2642
+ }
2643
+ if (selectedOnPage === 0) return "unchecked";
2644
+ if (selectedOnPage === visibleIds.length) return "checked";
2645
+ return "indeterminate";
2646
+ }, [selection, rows, rowIdOf]);
2647
+ const onHeaderToggle = React8.useCallback(
2648
+ (checked) => {
2649
+ if (selection.scope === "all") {
2650
+ if (checked) {
2651
+ patch({ selection: { ids: {}, scope: "all", exceptIds: {} } });
2652
+ } else {
2653
+ const exceptIds = { ...selection.exceptIds ?? {} };
2654
+ for (const r of rows) {
2655
+ const rid = rowIdOf(r);
2656
+ if (rid) exceptIds[rid] = true;
2657
+ }
2658
+ patch({ selection: { ...selection, exceptIds } });
2659
+ }
2660
+ return;
2661
+ }
2662
+ const next = { ...selection.ids };
2663
+ const visibleIds = rows.map(rowIdOf).filter(Boolean);
2664
+ if (checked) {
2665
+ for (const rid of visibleIds) next[rid] = true;
2666
+ } else {
2667
+ for (const rid of visibleIds) delete next[rid];
2668
+ }
2669
+ patch({ selection: { ...selection, ids: next } });
2670
+ },
2671
+ [patch, selection, rows, rowIdOf]
2672
+ );
2673
+ const onScopeChange = React8.useCallback(
2674
+ (scope) => {
2675
+ if (scope === "all") {
2676
+ patch({ selection: { ids: {}, scope: "all", exceptIds: {} } });
2677
+ if (selectAllResolution === "eager" && isApi) {
2678
+ setEagerAllIds(null);
2679
+ setEagerAllRows([]);
2680
+ void resolveEagerAll();
2681
+ }
2682
+ } else {
2683
+ patch({ selection: { ids: {}, scope: "page" } });
2684
+ setEagerAllIds(null);
2685
+ setEagerAllRows([]);
2686
+ eagerSeqRef.current++;
2687
+ setIsResolvingEager(false);
2688
+ }
2689
+ },
2690
+ [patch, selectAllResolution, isApi, resolveEagerAll]
2691
+ );
2692
+ const firstPerformAfterMountRef = React8.useRef(true);
2693
+ const handlePerform = React8.useCallback(
2694
+ (snap) => {
2695
+ const isFirstAfterMount = firstPerformAfterMountRef.current;
2696
+ firstPerformAfterMountRef.current = false;
2697
+ lastSnapshotRef.current = snap;
2698
+ if (selection.scope === "all") {
2699
+ patch({ selection: { ids: {}, scope: "all", exceptIds: {} } });
2700
+ }
2701
+ setEagerAllIds(null);
2702
+ setEagerAllRows([]);
2703
+ eagerSeqRef.current++;
2704
+ setIsResolvingEager(false);
2705
+ if (!isFirstAfterMount) patch({ page: 1 });
2706
+ multifilter?.onPerform?.(snap);
2707
+ if (isApi) void runFetch();
2708
+ else setLocalFilterTick((n) => n + 1);
2709
+ },
2710
+ [isApi, multifilter, patch, runFetch, selection.scope]
2711
+ );
2712
+ const totalPages = Math.max(1, Math.ceil(totalCount / itemsPerPage));
2713
+ const hasResolvedDataRef = React8.useRef(false);
2714
+ React8.useEffect(() => {
2715
+ if (isApi) {
2716
+ if (apiLoading) return;
2717
+ if (!hasResolvedDataRef.current) {
2718
+ if (apiTotalCount > 0 || apiRows.length > 0) {
2719
+ hasResolvedDataRef.current = true;
2720
+ } else {
2721
+ return;
2722
+ }
2723
+ }
2724
+ }
2725
+ if (page > totalPages) patch({ page: totalPages });
2726
+ }, [page, totalPages, patch, isApi, apiLoading, apiTotalCount, apiRows.length]);
2727
+ React8.useEffect(() => {
2728
+ if (isApi) return;
2729
+ if (paginationMode === "page") return;
2730
+ if (page > 1 && page > Math.max(1, Math.ceil(totalCount / itemsPerPage))) {
2731
+ patch({ page: 1 });
2732
+ }
2733
+ }, [totalCount, itemsPerPage, page, paginationMode, patch, isApi]);
2734
+ return /* @__PURE__ */ jsxRuntime.jsx(NamespaceProvider, { fullId, children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className, children: [
2735
+ multifilter && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mb-2", children: /* @__PURE__ */ jsxRuntime.jsx(
2736
+ EasyVisionMultifilter,
2737
+ {
2738
+ ...multifilter,
2739
+ ref: setMultifilterRef,
2740
+ onPerform: handlePerform
2741
+ }
2742
+ ) }),
2743
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-md border border-border overflow-hidden bg-card", children: [
2744
+ (toolbarLeft || toolbarRight || enableRowSelection || showColumnVisibility) && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between gap-2 px-4 py-2 border-b border-border", children: [
2745
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center gap-2", children: toolbarLeft }),
2746
+ enableRowSelection && (() => {
2747
+ const isAllScope = selection.scope === "all";
2748
+ const pageCount = isAllScope ? 0 : Object.keys(selection.ids ?? {}).length;
2749
+ const eagerCount = isEagerWildcard && eagerAllIds ? Math.max(
2750
+ 0,
2751
+ eagerAllIds.length - Object.keys(selection.exceptIds ?? {}).length
2752
+ ) : null;
2753
+ const allCount = isAllScope ? eagerCount ?? Math.max(0, totalCount - Object.keys(selection.exceptIds ?? {}).length) : 0;
2754
+ if (!isAllScope && pageCount === 0) return null;
2755
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2 rounded-sm border border-primary/30 bg-primary/5 px-3 py-1 text-xs", children: [
2756
+ isEagerWildcard && isResolvingEager && /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Loader2, { className: "w-3 h-2 animate-spin text-primary" }),
2757
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-primary font-medium", children: isAllScope ? isEagerWildcard && isResolvingEager ? `${labels.loading}\u2026` : labels.selectedAllBanner(allCount) : labels.selectedCountBanner(pageCount) }),
2758
+ /* @__PURE__ */ jsxRuntime.jsxs(
2759
+ Button,
2760
+ {
2761
+ variant: "ghost",
2762
+ size: "sm",
2763
+ onClick: () => onScopeChange("page"),
2764
+ className: "ml-auto h-6 text-xs",
2765
+ children: [
2766
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.X, { className: "w-3 h-2 mr-1" }),
2767
+ labels.clearSelection
2768
+ ]
2769
+ }
2770
+ )
2771
+ ] });
2772
+ })(),
2773
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
2774
+ toolbarRight,
2775
+ showColumnVisibility && /* @__PURE__ */ jsxRuntime.jsx(ColumnVisibilityMenu, { table: tableInstance, label: labels.customizeColumns })
2776
+ ] })
2777
+ ] }),
2778
+ /* @__PURE__ */ jsxRuntime.jsx(
2779
+ "div",
2780
+ {
2781
+ className: "easyvision-table-scroll relative w-full overflow-auto",
2782
+ style: maxBodyHeight !== void 0 ? {
2783
+ maxHeight: typeof maxBodyHeight === "number" ? `${maxBodyHeight}px` : maxBodyHeight
2784
+ } : void 0,
2785
+ children: /* @__PURE__ */ jsxRuntime.jsxs("table", { className: "w-full caption-bottom text-sm min-w-max", children: [
2786
+ /* @__PURE__ */ jsxRuntime.jsx(
2787
+ TableHeader,
2788
+ {
2789
+ className: maxBodyHeight !== void 0 ? "sticky top-0 z-10 bg-card shadow-[inset_0_-1px_0_0_hsl(var(--border))]" : void 0,
2790
+ children: tableInstance.getHeaderGroups().map((hg) => /* @__PURE__ */ jsxRuntime.jsx(TableRow, { children: hg.headers.map((header) => {
2791
+ if (header.column.id === "_select" && enableRowSelection) {
2792
+ return /* @__PURE__ */ jsxRuntime.jsx(TableHead, { className: "w-[60px] whitespace-nowrap", children: /* @__PURE__ */ jsxRuntime.jsx(
2793
+ SelectAllControl,
2794
+ {
2795
+ scope: selection.scope,
2796
+ toggleable: selectAllScope === "toggleable",
2797
+ state: headerState,
2798
+ onToggle: onHeaderToggle,
2799
+ onScopeChange,
2800
+ labels: {
2801
+ selectAllPage: labels.selectAllPage,
2802
+ selectAllAll: labels.selectAllAll
2803
+ }
2804
+ }
2805
+ ) }, header.id);
2806
+ }
2807
+ const colDef = columns.find(
2808
+ (c) => c.field === header.column.id
2809
+ );
2810
+ const sortable = colDef && !shouldDisableSorting(colDef, orderingMode, defaultSorting) && !isEagerWildcard;
2811
+ const colMeta = header.column.columnDef.meta ?? {};
2812
+ const headerWidthStyle = colMeta.resizable ? { width: header.getSize(), minWidth: header.getSize() } : colMeta.width ? { width: colMeta.width, minWidth: colMeta.width } : void 0;
2813
+ return /* @__PURE__ */ jsxRuntime.jsxs(
2814
+ TableHead,
2815
+ {
2816
+ style: headerWidthStyle,
2817
+ className: [
2818
+ "relative",
2819
+ colMeta.largeScreensOnly ? "hidden lg:table-cell" : ""
2820
+ ].filter(Boolean).join(" "),
2821
+ children: [
2822
+ header.isPlaceholder ? null : sortable ? /* @__PURE__ */ jsxRuntime.jsxs(
2823
+ "button",
2824
+ {
2825
+ className: "flex items-center gap-1 select-none hover:opacity-70",
2826
+ onClick: header.column.getToggleSortingHandler(),
2827
+ children: [
2828
+ reactTable.flexRender(header.column.columnDef.header, header.getContext()),
2829
+ header.column.getIsSorted() === "asc" ? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ArrowUp, { className: "h-3 w-3" }) : header.column.getIsSorted() === "desc" ? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ArrowDown, { className: "h-3 w-3" }) : /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ArrowUpDown, { className: "h-3 w-3 text-muted-foreground opacity-50" })
2830
+ ]
2831
+ }
2832
+ ) : reactTable.flexRender(header.column.columnDef.header, header.getContext()),
2833
+ colMeta.resizable && header.column.getCanResize() && /* @__PURE__ */ jsxRuntime.jsx(
2834
+ "div",
2835
+ {
2836
+ onMouseDown: header.getResizeHandler(),
2837
+ onTouchStart: header.getResizeHandler(),
2838
+ onClick: (e) => e.stopPropagation(),
2839
+ role: "separator",
2840
+ "aria-orientation": "vertical",
2841
+ "aria-label": "Resize column",
2842
+ className: [
2843
+ "group absolute top-0 right-0 h-full w-3 -mr-1.5 cursor-col-resize select-none touch-none",
2844
+ "after:content-[''] after:absolute after:right-1.5 after:top-1/2 after:-translate-y-1/2",
2845
+ "after:h-1/2 after:w-px after:bg-border after:transition-all",
2846
+ "hover:after:w-1.5 hover:after:h-full hover:after:top-0 hover:after:translate-y-0 hover:after:bg-primary/30",
2847
+ header.column.getIsResizing() ? "after:!w-1.5 after:!h-full after:!top-0 after:!translate-y-0 after:!bg-primary/60" : ""
2848
+ ].filter(Boolean).join(" ")
2849
+ }
2850
+ )
2851
+ ]
2852
+ },
2853
+ header.id
2854
+ );
2855
+ }) }, hg.id))
2856
+ }
2857
+ ),
2858
+ /* @__PURE__ */ jsxRuntime.jsx(TableBody, { children: isLoading ? /* @__PURE__ */ jsxRuntime.jsx(TableRow, { children: /* @__PURE__ */ jsxRuntime.jsx(TableCell, { colSpan: allColumns.length, className: "h-48 text-center", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center justify-center", children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Loader2, { className: "h-6 w-6 animate-spin text-muted-foreground" }) }) }) }) : tableInstance.getRowModel().rows.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx(TableRow, { children: /* @__PURE__ */ jsxRuntime.jsx(TableCell, { colSpan: allColumns.length, className: "h-48 text-center", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col items-center gap-3", children: [
2859
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-muted-foreground", children: emptyMessage ?? labels.noData }),
2860
+ emptyAction
2861
+ ] }) }) }) : tableInstance.getRowModel().rows.map((row) => {
2862
+ const rid = rowIdOf(row.original);
2863
+ const isAllSelected = selection.scope === "all" && !selection.exceptIds?.[rid];
2864
+ const highlighted = isRowHighlighted?.(row.original) ?? false;
2865
+ return /* @__PURE__ */ jsxRuntime.jsx(
2866
+ TableRow,
2867
+ {
2868
+ "data-state": row.getIsSelected() || isAllSelected ? "selected" : void 0,
2869
+ "data-highlighted": highlighted ? "true" : void 0,
2870
+ className: [
2871
+ onRowClick ? "cursor-pointer" : "",
2872
+ highlighted ? "bg-muted/50" : ""
2873
+ ].filter(Boolean).join(" "),
2874
+ onClick: () => onRowClick?.(row.original),
2875
+ children: row.getVisibleCells().map((cell) => {
2876
+ if (cell.column.id === "_select" && selection.scope === "all") {
2877
+ return /* @__PURE__ */ jsxRuntime.jsx(TableCell, { children: /* @__PURE__ */ jsxRuntime.jsx(
2878
+ Checkbox,
2879
+ {
2880
+ checked: !selection.exceptIds?.[rid],
2881
+ onCheckedChange: (v) => {
2882
+ const exceptIds = { ...selection.exceptIds ?? {} };
2883
+ if (v) delete exceptIds[rid];
2884
+ else exceptIds[rid] = true;
2885
+ patch({ selection: { ...selection, exceptIds } });
2886
+ },
2887
+ onClick: (e) => e.stopPropagation()
2888
+ }
2889
+ ) }, cell.id);
2890
+ }
2891
+ const cellMeta = cell.column.columnDef.meta ?? {};
2892
+ const cellWidthStyle = cellMeta.resizable ? { width: cell.column.getSize(), minWidth: cell.column.getSize() } : cellMeta.width ? { width: cellMeta.width, minWidth: cellMeta.width } : void 0;
2893
+ const rendered = reactTable.flexRender(
2894
+ cell.column.columnDef.cell,
2895
+ cell.getContext()
2896
+ );
2897
+ let titleAttr;
2898
+ if (cellMeta.truncate) {
2899
+ try {
2900
+ const raw = cell.getValue();
2901
+ if (raw != null && (typeof raw === "string" || typeof raw === "number")) {
2902
+ const s = String(raw);
2903
+ if (s) titleAttr = s;
2904
+ }
2905
+ } catch {
2906
+ }
2907
+ }
2908
+ return /* @__PURE__ */ jsxRuntime.jsx(
2909
+ TableCell,
2910
+ {
2911
+ style: cellWidthStyle,
2912
+ className: [
2913
+ cellMeta.largeScreensOnly ? "hidden lg:table-cell" : "",
2914
+ cellMeta.truncate ? "max-w-0" : ""
2915
+ ].filter(Boolean).join(" "),
2916
+ children: cellMeta.truncate ? /* @__PURE__ */ jsxRuntime.jsx(
2917
+ "div",
2918
+ {
2919
+ className: "truncate",
2920
+ title: titleAttr,
2921
+ children: rendered
2922
+ }
2923
+ ) : rendered
2924
+ },
2925
+ cell.id
2926
+ );
2927
+ })
2928
+ },
2929
+ row.id
2930
+ );
2931
+ }) })
2932
+ ] })
2933
+ }
2934
+ ),
2935
+ /* @__PURE__ */ jsxRuntime.jsx(
2936
+ PaginationFooter,
2937
+ {
2938
+ currentPage: page,
2939
+ totalCount,
2940
+ itemsPerPage,
2941
+ itemsPerPageOptions,
2942
+ onPageChange: (p) => patch({ page: p }),
2943
+ onItemsPerPageChange: (n) => patch({ itemsPerPage: n, page: 1 }),
2944
+ labels
2945
+ }
2946
+ )
2947
+ ] })
2948
+ ] }) });
2949
+ }
2950
+ var defaultCell = (content, title) => /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm text-foreground", title, children: content });
2951
+
2952
+ exports.EasyVisionCard = EasyVisionCard;
2953
+ exports.EasyVisionCardContent = EasyVisionCardContent;
2954
+ exports.EasyVisionCardDescription = EasyVisionCardDescription;
2955
+ exports.EasyVisionCardFooter = EasyVisionCardFooter;
2956
+ exports.EasyVisionCardHeader = EasyVisionCardHeader;
2957
+ exports.EasyVisionCardTitle = EasyVisionCardTitle;
2958
+ exports.EasyVisionInput = EasyVisionInput;
2959
+ exports.EasyVisionMultifilter = EasyVisionMultifilter;
2960
+ exports.EasyVisionSelector = EasyVisionSelector;
2961
+ exports.EasyVisionTable = EasyVisionTable;
2962
+ exports.createLoopbackTableFetcher = createLoopbackTableFetcher;
2963
+ exports.defaultCell = defaultCell;
2964
+ exports.easyVisionRegistry = easyVisionRegistry;
2965
+ exports.getSlice = getSlice;
2966
+ exports.matchLoopbackWhere = matchLoopbackWhere;
2967
+ //# sourceMappingURL=index.cjs.map
2968
+ //# sourceMappingURL=index.cjs.map