@sustaina/shared-ui 1.1.5

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.js ADDED
@@ -0,0 +1,4897 @@
1
+ 'use strict';
2
+
3
+ var React3 = require('react');
4
+ var reactHookForm = require('react-hook-form');
5
+ var jsxRuntime = require('react/jsx-runtime');
6
+ var clsx3 = require('clsx');
7
+ var tailwindMerge = require('tailwind-merge');
8
+ var zustand = require('zustand');
9
+ var reactTable = require('@tanstack/react-table');
10
+ var lucideReact = require('lucide-react');
11
+ var reactSlot = require('@radix-ui/react-slot');
12
+ var classVarianceAuthority = require('class-variance-authority');
13
+ var LabelPrimitive2 = require('@radix-ui/react-label');
14
+ var DialogPrimitive = require('@radix-ui/react-dialog');
15
+ var sortable = require('@dnd-kit/sortable');
16
+ var utilities = require('@dnd-kit/utilities');
17
+ var SelectPrimitive = require('@radix-ui/react-select');
18
+ var TooltipPrimitive = require('@radix-ui/react-tooltip');
19
+ var core = require('@dnd-kit/core');
20
+ var zod = require('zod');
21
+ var reactDom = require('react-dom');
22
+ var PopoverPrimitive = require('@radix-ui/react-popover');
23
+
24
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
25
+
26
+ function _interopNamespace(e) {
27
+ if (e && e.__esModule) return e;
28
+ var n = Object.create(null);
29
+ if (e) {
30
+ Object.keys(e).forEach(function (k) {
31
+ if (k !== 'default') {
32
+ var d = Object.getOwnPropertyDescriptor(e, k);
33
+ Object.defineProperty(n, k, d.get ? d : {
34
+ enumerable: true,
35
+ get: function () { return e[k]; }
36
+ });
37
+ }
38
+ });
39
+ }
40
+ n.default = e;
41
+ return Object.freeze(n);
42
+ }
43
+
44
+ var React3__namespace = /*#__PURE__*/_interopNamespace(React3);
45
+ var clsx3__default = /*#__PURE__*/_interopDefault(clsx3);
46
+ var LabelPrimitive2__namespace = /*#__PURE__*/_interopNamespace(LabelPrimitive2);
47
+ var DialogPrimitive__namespace = /*#__PURE__*/_interopNamespace(DialogPrimitive);
48
+ var SelectPrimitive__namespace = /*#__PURE__*/_interopNamespace(SelectPrimitive);
49
+ var TooltipPrimitive__namespace = /*#__PURE__*/_interopNamespace(TooltipPrimitive);
50
+ var PopoverPrimitive__namespace = /*#__PURE__*/_interopNamespace(PopoverPrimitive);
51
+
52
+ // src/components/form/form-controls/use-form-field.ts
53
+ var FormFieldContext = React3.createContext({});
54
+ function FormField(props) {
55
+ return /* @__PURE__ */ jsxRuntime.jsx(FormFieldContext, { value: { name: props.name }, children: /* @__PURE__ */ jsxRuntime.jsx(reactHookForm.Controller, { ...props }) });
56
+ }
57
+ var FormItemContext = React3.createContext({});
58
+ function FormItem({ children, ...props }) {
59
+ const formItemId = React3.useId();
60
+ return /* @__PURE__ */ jsxRuntime.jsx(FormItemContext, { value: { id: formItemId }, children: /* @__PURE__ */ jsxRuntime.jsx("div", { ...props, children }) });
61
+ }
62
+
63
+ // src/components/form/form-controls/use-form-field.ts
64
+ function useFormField(options) {
65
+ const { name: formFieldName } = React3.useContext(FormFieldContext);
66
+ const { id: formItemId } = React3.useContext(FormItemContext);
67
+ const formContext = reactHookForm.useFormContext();
68
+ if ((!formFieldName || !formItemId || !formContext) && options?.skipValidationIfNoContext) {
69
+ return {
70
+ prefixId: void 0,
71
+ name: void 0,
72
+ formItemId: void 0,
73
+ formLabelId: void 0,
74
+ formErrorMessageId: void 0,
75
+ isDirty: false,
76
+ invalid: false,
77
+ isTouched: false,
78
+ isValidating: false,
79
+ error: void 0
80
+ };
81
+ }
82
+ if (!formFieldName) {
83
+ throw new Error(
84
+ "useFormField must be used inside a <FormField> component. Ensure that <FormField> wraps the component using useFormField."
85
+ );
86
+ }
87
+ if (!formItemId) {
88
+ throw new Error(
89
+ "useFormField must be used inside a <FormItem> component. Ensure that <FormItem> wraps the component using useFormField."
90
+ );
91
+ }
92
+ if (!formContext) {
93
+ throw new Error("useFormField must be used inside a <Form> component.");
94
+ }
95
+ const fieldState = formContext?.getFieldState?.(formFieldName, formContext?.formState);
96
+ const prefixId = formItemId?.concat(formFieldName);
97
+ return {
98
+ prefixId,
99
+ name: formFieldName,
100
+ formItemId: prefixId ? `${prefixId}-form-item` : void 0,
101
+ formLabelId: prefixId ? `${prefixId}-form-label` : void 0,
102
+ formErrorMessageId: prefixId ? `${prefixId}-form-error-message` : void 0,
103
+ ...fieldState
104
+ };
105
+ }
106
+ function cn(...args) {
107
+ return tailwindMerge.twMerge(clsx3.clsx(args));
108
+ }
109
+ function FormErrorMessage({ className, errorClassName, ...props }) {
110
+ const { formErrorMessageId, invalid, error } = useFormField();
111
+ if (!invalid) {
112
+ return null;
113
+ }
114
+ return /* @__PURE__ */ jsxRuntime.jsx(
115
+ "p",
116
+ {
117
+ id: formErrorMessageId,
118
+ className: cn(
119
+ "text-sm font-medium text-destructive text-red-600 flex items-center gap-1 mt-2 ml-1",
120
+ className,
121
+ {
122
+ "text-red-600": invalid,
123
+ [errorClassName ?? ""]: invalid
124
+ }
125
+ ),
126
+ "aria-invalid": invalid,
127
+ "aria-errormessage": error?.message,
128
+ ...props,
129
+ children: error?.message
130
+ }
131
+ );
132
+ }
133
+ function FormLabel({ children, className, errorClassName, required, ...props }) {
134
+ const { formItemId, formLabelId, invalid } = useFormField();
135
+ return /* @__PURE__ */ jsxRuntime.jsxs(
136
+ "label",
137
+ {
138
+ id: formLabelId,
139
+ htmlFor: formItemId,
140
+ className: cn("block mb-2", className, {
141
+ "text-destructive text-red-600": invalid,
142
+ [errorClassName ?? ""]: invalid
143
+ }),
144
+ "aria-label": formLabelId,
145
+ "aria-invalid": invalid,
146
+ ...props,
147
+ children: [
148
+ children,
149
+ required && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-red-600 ml-1", children: "*" })
150
+ ]
151
+ }
152
+ );
153
+ }
154
+
155
+ // src/utils/getColumnIdFromTable.ts
156
+ function getColumnIdFromTable(table) {
157
+ const allColumns = table.getAllColumns();
158
+ const availableColumns = allColumns.map((col) => ({ id: col.id }));
159
+ const currentColumns = allColumns.filter((col) => col.getIsVisible()).map((col) => ({ id: col.id }));
160
+ return { availableColumns, currentColumns };
161
+ }
162
+ var useGridSettingsStore = zustand.create(
163
+ (set) => ({
164
+ availableColumns: [],
165
+ currentColumns: [],
166
+ payload: {
167
+ ordering: [],
168
+ visibility: {},
169
+ pinning: { left: [] }
170
+ },
171
+ setAvailableColumns: (cols) => set({ availableColumns: cols }),
172
+ setCurrentColumns: (cols) => set({ currentColumns: cols }),
173
+ setPayload: (payload) => set({ payload }),
174
+ reset: () => set({
175
+ availableColumns: [],
176
+ currentColumns: [],
177
+ payload: { ordering: [], visibility: {}, pinning: { left: [] } }
178
+ }),
179
+ extractColumns: (table) => {
180
+ const availableColumns = table.getAllColumns().map((col) => ({ id: col.id }));
181
+ const currentColumns = table.getVisibleLeafColumns().map((col) => ({ id: col.id }));
182
+ return { availableColumns, currentColumns };
183
+ }
184
+ })
185
+ );
186
+ function TextInput({ className, ...props }) {
187
+ return /* @__PURE__ */ jsxRuntime.jsx("input", { type: "text", className: cn("input", className), ...props });
188
+ }
189
+ function NumberInput({ className, ...props }) {
190
+ return /* @__PURE__ */ jsxRuntime.jsx("input", { type: "number", className: cn("input", className), ...props });
191
+ }
192
+ function compareAlphanumeric(aStr, bStr) {
193
+ const a = aStr.split(reactTable.reSplitAlphaNumeric).filter(Boolean);
194
+ const b = bStr.split(reactTable.reSplitAlphaNumeric).filter(Boolean);
195
+ while (a.length && b.length) {
196
+ const aa = a.shift();
197
+ const bb = b.shift();
198
+ const an = parseInt(aa, 10);
199
+ const bn = parseInt(bb, 10);
200
+ const combo = [an, bn].sort();
201
+ if (isNaN(combo[0])) {
202
+ if (aa > bb) {
203
+ return 1;
204
+ }
205
+ if (bb > aa) {
206
+ return -1;
207
+ }
208
+ continue;
209
+ }
210
+ if (isNaN(combo[1])) {
211
+ return isNaN(an) ? -1 : 1;
212
+ }
213
+ if (an > bn) {
214
+ return 1;
215
+ }
216
+ if (bn > an) {
217
+ return -1;
218
+ }
219
+ }
220
+ return a.length - b.length;
221
+ }
222
+ function cn2(...inputs) {
223
+ return tailwindMerge.twMerge(clsx3.clsx(inputs));
224
+ }
225
+ function booleanToSelectValue(value, options) {
226
+ if (value === true) return "true";
227
+ if (value === false) return "false";
228
+ return options?.fallbackUndefinedValue ?? "";
229
+ }
230
+ function selectValueToBoolean(value) {
231
+ if (value === "true") return true;
232
+ if (value === "false") return false;
233
+ return void 0;
234
+ }
235
+ function renderContentSlot(slot, defaultWrapperProps) {
236
+ const { content, wrapperProps = {} } = slot;
237
+ const mergedProps = {
238
+ ...defaultWrapperProps,
239
+ ...wrapperProps,
240
+ className: cn2(defaultWrapperProps?.className, wrapperProps?.className)
241
+ };
242
+ if (!content) {
243
+ return null;
244
+ }
245
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { ...mergedProps, children: content });
246
+ }
247
+ var useHover = () => {
248
+ const [hovering, setHovering] = React3.useState(false);
249
+ const prevRef = React3.useRef(null);
250
+ const onMouseEnter = React3.useCallback(() => setHovering(true), []);
251
+ const onMouseLeave = React3.useCallback(() => setHovering(false), []);
252
+ const nodeRefCallback = React3.useCallback(
253
+ (node) => {
254
+ if (prevRef.current) {
255
+ prevRef.current.removeEventListener("mouseenter", onMouseEnter);
256
+ prevRef.current.removeEventListener("mouseleave", onMouseLeave);
257
+ }
258
+ if (node?.nodeType === Node.ELEMENT_NODE) {
259
+ node.addEventListener("mouseenter", onMouseEnter);
260
+ node.addEventListener("mouseleave", onMouseLeave);
261
+ }
262
+ prevRef.current = node;
263
+ },
264
+ [onMouseEnter, onMouseLeave]
265
+ );
266
+ return {
267
+ ref: nodeRefCallback,
268
+ hovering
269
+ };
270
+ };
271
+ var useHover_default = useHover;
272
+ var useIntersectionObserver = ({
273
+ threshold = 0,
274
+ root = null,
275
+ rootMargin = "0%",
276
+ freezeOnceVisible = false,
277
+ initialIsIntersecting = false,
278
+ onChange
279
+ } = {}) => {
280
+ const [ref, setRef] = React3.useState(null);
281
+ const [state, setState] = React3.useState(() => ({
282
+ isIntersecting: initialIsIntersecting,
283
+ entry: void 0
284
+ }));
285
+ const callbackRef = React3.useRef(null);
286
+ callbackRef.current = onChange;
287
+ const frozen = state.entry?.isIntersecting && freezeOnceVisible;
288
+ React3.useEffect(() => {
289
+ if (!ref) return;
290
+ if (!("IntersectionObserver" in window)) return;
291
+ if (frozen) return;
292
+ const observer = new IntersectionObserver(
293
+ (entries) => {
294
+ const thresholds = Array.isArray(observer.thresholds) ? observer.thresholds : [observer.thresholds];
295
+ entries.forEach((entry) => {
296
+ const isIntersecting = entry.isIntersecting && thresholds.some((threshold2) => entry.intersectionRatio >= threshold2);
297
+ setState({ isIntersecting, entry });
298
+ if (callbackRef.current) {
299
+ callbackRef.current(isIntersecting, entry);
300
+ }
301
+ });
302
+ },
303
+ { threshold, root, rootMargin }
304
+ );
305
+ observer.observe(ref);
306
+ return () => {
307
+ observer.disconnect();
308
+ };
309
+ }, [
310
+ ref,
311
+ // eslint-disable-next-line react-hooks/exhaustive-deps
312
+ JSON.stringify(threshold),
313
+ root,
314
+ rootMargin,
315
+ frozen,
316
+ freezeOnceVisible
317
+ ]);
318
+ const prevRef = React3.useRef(null);
319
+ React3.useEffect(() => {
320
+ if (!ref && state.entry?.target && !freezeOnceVisible && !frozen && prevRef.current !== state.entry.target) {
321
+ prevRef.current = state.entry.target;
322
+ setState({ isIntersecting: initialIsIntersecting, entry: void 0 });
323
+ }
324
+ }, [ref, state.entry, freezeOnceVisible, frozen, initialIsIntersecting]);
325
+ const result = [setRef, !!state.isIntersecting, state.entry];
326
+ result.ref = result[0];
327
+ result.isIntersecting = result[1];
328
+ result.entry = result[2];
329
+ return result;
330
+ };
331
+ var useIntersectionObserver_default = useIntersectionObserver;
332
+ var isValidMediaQueryString = (query) => {
333
+ return query !== "not all";
334
+ };
335
+ var useMediaQuery = ({ query }) => {
336
+ const [matches, setMatches] = React3.useState(false);
337
+ React3.useEffect(() => {
338
+ if (typeof window === "undefined") {
339
+ return;
340
+ }
341
+ const mql = window.matchMedia(query);
342
+ if (!isValidMediaQueryString(mql.media)) {
343
+ throw new Error(`${query}: invalid media query string.`);
344
+ }
345
+ const detectMediaChange = (event) => {
346
+ setMatches(event.matches);
347
+ };
348
+ setMatches(mql.matches);
349
+ mql.addEventListener("change", detectMediaChange);
350
+ return () => {
351
+ mql.removeEventListener("change", detectMediaChange);
352
+ };
353
+ }, [query]);
354
+ return matches;
355
+ };
356
+ var useMediaQuery_default = useMediaQuery;
357
+
358
+ // src/hooks/useScreenSize/useScreenSize.ts
359
+ var useScreenSize = (breakpoints) => {
360
+ const isMobile = useMediaQuery_default({ query: breakpoints?.mobile ?? "(max-width: 767px)" });
361
+ const isTablet = useMediaQuery_default({
362
+ query: breakpoints?.tablet ?? "(min-width: 768px) and (max-width: 1023px)"
363
+ });
364
+ const isDesktop = useMediaQuery_default({ query: breakpoints?.desktop ?? "(min-width: 1024px)" });
365
+ return { isMobile, isTablet, isDesktop };
366
+ };
367
+ var useScreenSize_default = useScreenSize;
368
+
369
+ // src/utils/common.ts
370
+ function isDefined(value) {
371
+ return value !== null && value !== void 0;
372
+ }
373
+
374
+ // src/utils/filters.ts
375
+ function stripNullishObject(value) {
376
+ if (!isDefined(value)) {
377
+ return {};
378
+ }
379
+ try {
380
+ return Object.fromEntries(Object.entries(value).filter(([, propValue]) => isDefined(propValue)));
381
+ } catch {
382
+ return {};
383
+ }
384
+ }
385
+ var HeaderCell = ({ rootClassName, labelClassName, context, label, sorterProps }) => {
386
+ const { ref, hovering } = useHover_default();
387
+ const showSorter = sorterProps?.show ?? context.column.getCanSort();
388
+ return /* @__PURE__ */ jsxRuntime.jsxs(
389
+ "div",
390
+ {
391
+ ref,
392
+ className: cn(
393
+ "flex items-center gap-2",
394
+ {
395
+ "cursor-pointer": context?.column?.getCanSort()
396
+ },
397
+ rootClassName
398
+ ),
399
+ ...stripNullishObject({
400
+ onClick: (event) => {
401
+ event.preventDefault();
402
+ if (context?.column?.getCanSort()) {
403
+ context?.column?.toggleSorting();
404
+ }
405
+ }
406
+ }),
407
+ children: [
408
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: cn("inline-block font-bold", labelClassName), children: label }),
409
+ showSorter && /* @__PURE__ */ jsxRuntime.jsxs(
410
+ "div",
411
+ {
412
+ className: "flex flex-col",
413
+ title: context.column.getCanSort() ? context.column.getNextSortingOrder() === "asc" ? "Sort ascending" : context.column.getNextSortingOrder() === "desc" ? "Sort descending" : "Clear sort" : void 0,
414
+ children: [
415
+ /* @__PURE__ */ jsxRuntime.jsx(
416
+ lucideReact.Triangle,
417
+ {
418
+ className: cn("fill-gray-300 stroke-0", {
419
+ "fill-[#41875c]": context?.column?.getIsSorted() === "asc",
420
+ "fill-[#41875c]/45": context?.column?.getNextSortingOrder() === "asc" && hovering
421
+ }),
422
+ size: 12
423
+ }
424
+ ),
425
+ /* @__PURE__ */ jsxRuntime.jsx(
426
+ lucideReact.Triangle,
427
+ {
428
+ className: cn("rotate-180 fill-gray-300 stroke-0", {
429
+ "fill-[#41875c]": context?.column?.getIsSorted() === "desc",
430
+ "fill-[#41875c]/45": context?.column?.getNextSortingOrder() === "desc" && hovering
431
+ }),
432
+ size: 12
433
+ }
434
+ )
435
+ ]
436
+ }
437
+ )
438
+ ]
439
+ }
440
+ );
441
+ };
442
+ var HeaderCell_default = HeaderCell;
443
+ function TableContainer({ className, children, ...props }) {
444
+ return /* @__PURE__ */ jsxRuntime.jsx(
445
+ "div",
446
+ {
447
+ "data-slot": "table-container",
448
+ className: cn("relative w-full overflow-x-auto", className),
449
+ ...props,
450
+ children
451
+ }
452
+ );
453
+ }
454
+ function Table({ className, ...props }) {
455
+ return /* @__PURE__ */ jsxRuntime.jsx(
456
+ "table",
457
+ {
458
+ "data-slot": "table",
459
+ className: cn("w-full caption-bottom text-sm border-separate border-spacing-0", className),
460
+ ...props
461
+ }
462
+ );
463
+ }
464
+ function TableHeader({ className, ...props }) {
465
+ return /* @__PURE__ */ jsxRuntime.jsx(
466
+ "thead",
467
+ {
468
+ "data-slot": "table-header",
469
+ className: cn("[&_tr]:border-b bg-[#f7f4f4]", className),
470
+ ...props
471
+ }
472
+ );
473
+ }
474
+ function TableBody({ className, ...props }) {
475
+ return /* @__PURE__ */ jsxRuntime.jsx("tbody", { "data-slot": "table-body", className: cn("[&_tr:last-child]:border-0", className), ...props });
476
+ }
477
+ function TableRow({ className, ...props }) {
478
+ return /* @__PURE__ */ jsxRuntime.jsx(
479
+ "tr",
480
+ {
481
+ "data-slot": "table-row",
482
+ className: cn("data-[state=selected]:bg-[#dfeae3]", className),
483
+ ...props
484
+ }
485
+ );
486
+ }
487
+ function TableHead({ className, ...props }) {
488
+ return /* @__PURE__ */ jsxRuntime.jsx(
489
+ "th",
490
+ {
491
+ "data-slot": "table-head",
492
+ className: cn(
493
+ "text-foreground h-9 px-2 text-left align-middle font-medium whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px] hover:bg-gray-200 bg-[#f7f4f4] truncate",
494
+ className
495
+ ),
496
+ ...props
497
+ }
498
+ );
499
+ }
500
+ function TableCell({ className, ...props }) {
501
+ return /* @__PURE__ */ jsxRuntime.jsx(
502
+ "td",
503
+ {
504
+ "data-slot": "table-cell",
505
+ className: cn(
506
+ "p-2 h-10 align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px] border-b truncate",
507
+ className
508
+ ),
509
+ ...props
510
+ }
511
+ );
512
+ }
513
+ var ColumnResizer = ({ header, className, style }) => {
514
+ if (!header.column.getCanResize()) {
515
+ return null;
516
+ }
517
+ const resizeHandler = header.getResizeHandler();
518
+ return /* @__PURE__ */ jsxRuntime.jsx(
519
+ "div",
520
+ {
521
+ className: cn(
522
+ "absolute top-0 right-0 h-full w-1 select-none touch-none cursor-col-resize hover:bg-[#41875c]/45 active:bg-[#41875c]",
523
+ className
524
+ ),
525
+ onDoubleClick: () => header.column.resetSize(),
526
+ onTouchStart: resizeHandler,
527
+ onMouseDown: resizeHandler,
528
+ style
529
+ }
530
+ );
531
+ };
532
+ var ColumnResizer_default = ColumnResizer;
533
+ var stateOptions = [
534
+ "columnFilters",
535
+ "globalFilter",
536
+ "sorting",
537
+ "pagination",
538
+ "columnVisibility",
539
+ "columnOrder",
540
+ "rowSelection",
541
+ "expanded",
542
+ "grouping",
543
+ "columnPinning",
544
+ "columnSizing",
545
+ "columnSizingInfo",
546
+ "rowPinning"
547
+ ];
548
+ var modelOptions = [
549
+ "getRowModel",
550
+ "getGroupedRowModel",
551
+ "getPaginationRowModel",
552
+ "getCoreRowModel",
553
+ "getFilteredRowModel",
554
+ "getFilteredSelectedRowModel",
555
+ "getSortedRowModel",
556
+ "getPreExpandedRowModel",
557
+ "getGroupedSelectedRowModel",
558
+ "getPrePaginationRowModel",
559
+ "getPreSelectedRowModel",
560
+ "getPreSortedRowModel",
561
+ "getSelectedRowModel",
562
+ "getExpandedRowModel",
563
+ "getIsAllColumnsVisible",
564
+ "getIsSomeColumnsPinned",
565
+ "getIsSomeColumnsVisible",
566
+ "getHeaderGroups",
567
+ "getFlatHeaders",
568
+ "getLeafHeaders",
569
+ "getLeftFlatHeaders",
570
+ "getCenterLeafHeaders",
571
+ "getRightFlatHeaders",
572
+ "getAllColumns",
573
+ "getAllFlatColumns",
574
+ "getAllLeafColumns",
575
+ "getLeftLeafColumns",
576
+ "getCenterLeafColumns",
577
+ "getRightLeafColumns",
578
+ "getVisibleFlatColumns",
579
+ "getVisibleLeafColumns",
580
+ "getLeftVisibleLeafColumns",
581
+ "getRightVisibleLeafColumns",
582
+ "getCenterVisibleLeafColumns"
583
+ ];
584
+ var DataTableDevTool = ({ table }) => {
585
+ const [open, setOpen] = React3.useState(false);
586
+ const [visibleStates, setVisibleStates] = React3.useState([]);
587
+ const [visibleModels, setVisibleModels] = React3.useState([]);
588
+ const tableState = table.getState();
589
+ const toggleValue = (arr, value) => arr.includes(value) ? arr.filter((v) => v !== value) : [...arr, value];
590
+ const getCircularReplacer = () => {
591
+ const seen = /* @__PURE__ */ new WeakSet();
592
+ return (_key, value) => {
593
+ if (typeof value === "object" && value !== null) {
594
+ if (seen.has(value)) return "[Circular]";
595
+ seen.add(value);
596
+ }
597
+ return value;
598
+ };
599
+ };
600
+ const renderStateValue = (key) => {
601
+ const value = tableState[key];
602
+ if (value == null) return null;
603
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mt-4", children: [
604
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "font-bold capitalize", children: key }),
605
+ /* @__PURE__ */ jsxRuntime.jsx("pre", { className: "bg-gray-100 text-xs p-2 rounded overflow-x-auto whitespace-pre-wrap", children: JSON.stringify(value, null, 2) })
606
+ ] }, key);
607
+ };
608
+ const renderModelValue = (key) => {
609
+ let value;
610
+ try {
611
+ value = table[key]();
612
+ } catch {
613
+ value = void 0;
614
+ }
615
+ if (value == null) return null;
616
+ let jsonString = "";
617
+ try {
618
+ jsonString = JSON.stringify(value, getCircularReplacer(), 2);
619
+ } catch {
620
+ jsonString = "[Cannot stringify]";
621
+ }
622
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mt-4", children: [
623
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "font-bold capitalize", children: key }),
624
+ /* @__PURE__ */ jsxRuntime.jsx("pre", { className: "bg-gray-100 text-xs p-2 rounded overflow-x-auto whitespace-pre-wrap", children: jsonString })
625
+ ] }, key);
626
+ };
627
+ if (process.env.NODE_ENV === "production") return null;
628
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
629
+ /* @__PURE__ */ jsxRuntime.jsx(
630
+ "button",
631
+ {
632
+ onClick: () => setOpen(true),
633
+ className: "fixed bottom-6 right-6 z-50 rounded-full bg-white border shadow p-3",
634
+ "aria-label": "Open debug panel",
635
+ children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Bug, { className: "w-5 h-5" })
636
+ }
637
+ ),
638
+ open && /* @__PURE__ */ jsxRuntime.jsxs("aside", { className: "fixed top-0 right-0 h-full w-[420px] bg-white shadow-lg border-l border-gray-200 z-50 flex flex-col", children: [
639
+ /* @__PURE__ */ jsxRuntime.jsxs("header", { className: "flex items-center justify-between p-4 border-b border-gray-200", children: [
640
+ /* @__PURE__ */ jsxRuntime.jsx("h2", { className: "text-lg font-semibold", children: "Debug Table State & Models" }),
641
+ /* @__PURE__ */ jsxRuntime.jsx("button", { onClick: () => setOpen(false), className: "text-xl font-bold", "aria-label": "Close", children: "\xD7" })
642
+ ] }),
643
+ /* @__PURE__ */ jsxRuntime.jsxs("main", { className: "overflow-auto p-4 flex-grow space-y-4", children: [
644
+ /* @__PURE__ */ jsxRuntime.jsxs("section", { className: "max-h-80 overflow-y-auto overflow-x-hidden", children: [
645
+ /* @__PURE__ */ jsxRuntime.jsxs("fieldset", { children: [
646
+ /* @__PURE__ */ jsxRuntime.jsx("legend", { className: "block text-sm font-medium mb-1", children: "Show Table State" }),
647
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "space-y-1", children: stateOptions.map((stateKey) => /* @__PURE__ */ jsxRuntime.jsxs(
648
+ "label",
649
+ {
650
+ className: "flex items-center gap-2 cursor-pointer hover:bg-gray-50 p-1 rounded",
651
+ children: [
652
+ /* @__PURE__ */ jsxRuntime.jsx(
653
+ "input",
654
+ {
655
+ type: "checkbox",
656
+ className: "accent-blue-500",
657
+ checked: visibleStates.includes(stateKey),
658
+ onChange: () => setVisibleStates(toggleValue(visibleStates, stateKey))
659
+ }
660
+ ),
661
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate", children: stateKey })
662
+ ]
663
+ },
664
+ stateKey
665
+ )) })
666
+ ] }),
667
+ /* @__PURE__ */ jsxRuntime.jsxs("fieldset", { children: [
668
+ /* @__PURE__ */ jsxRuntime.jsx("legend", { className: "block text-sm font-medium mb-1", children: "Show Table Models" }),
669
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "space-y-1", children: modelOptions.map((modelKey) => /* @__PURE__ */ jsxRuntime.jsxs(
670
+ "label",
671
+ {
672
+ className: "flex items-center gap-2 cursor-pointer hover:bg-gray-50 p-1 rounded",
673
+ children: [
674
+ /* @__PURE__ */ jsxRuntime.jsx(
675
+ "input",
676
+ {
677
+ type: "checkbox",
678
+ className: "accent-green-500",
679
+ checked: visibleModels.includes(modelKey),
680
+ onChange: () => setVisibleModels(toggleValue(visibleModels, modelKey))
681
+ }
682
+ ),
683
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate", children: modelKey })
684
+ ]
685
+ },
686
+ modelKey
687
+ )) })
688
+ ] })
689
+ ] }),
690
+ /* @__PURE__ */ jsxRuntime.jsx("hr", { className: "my-2 border-gray-300" }),
691
+ visibleStates.map(renderStateValue),
692
+ visibleModels.map(renderModelValue)
693
+ ] })
694
+ ] })
695
+ ] });
696
+ };
697
+ var DataTableDevTool_default = DataTableDevTool;
698
+
699
+ // src/components/data-table/helpers.ts
700
+ function getColumnPinningStyles(column) {
701
+ const isPinned = column.getIsPinned();
702
+ const isLastLeftPinnedColumn = isPinned === "left" && column.getIsLastColumn("left");
703
+ const isFirstRightPinnedColumn = isPinned === "right" && column.getIsFirstColumn("right");
704
+ const classes = cn(
705
+ isPinned ? "sticky" : "relative",
706
+ isPinned ? "z-[1]" : "z-0",
707
+ isLastLeftPinnedColumn && "shadow-[inset_-1px_0_0_0_black]",
708
+ isFirstRightPinnedColumn && "shadow-[inset_1px_0_0_0_black]"
709
+ );
710
+ const style = {
711
+ left: isPinned === "left" ? column.getStart("left") : void 0,
712
+ right: isPinned === "right" ? column.getAfter("right") : void 0
713
+ };
714
+ return { classes, style };
715
+ }
716
+ var fallbackData = [];
717
+ var DataTable = ({
718
+ tableRef,
719
+ isInitialLoading,
720
+ columns,
721
+ data,
722
+ filters,
723
+ sorting,
724
+ columnOrder,
725
+ columnVisibility,
726
+ columnPinning,
727
+ columnGrouping,
728
+ columnResizing,
729
+ rowSelection,
730
+ rowExpansion,
731
+ scrollFetch,
732
+ statusContent,
733
+ rowIdKey,
734
+ childrenKey,
735
+ onRowClick,
736
+ debug,
737
+ components
738
+ }) => {
739
+ const table = reactTable.useReactTable({
740
+ // required properties
741
+ columns,
742
+ data: data || fallbackData,
743
+ getCoreRowModel: reactTable.getCoreRowModel(),
744
+ // optional properties
745
+ ...stripNullishObject({
746
+ // state for filters, sorting, pinning, row selection, etc.
747
+ initialState: stripNullishObject({
748
+ columnFilters: filters?.enabled && (filters?.column?.enabled ?? true) ? filters?.column?.initialState : void 0,
749
+ globalFilter: filters?.enabled ? filters?.global?.initialState : void 0,
750
+ sorting: sorting?.enabled ? sorting?.initialState : void 0,
751
+ columnOrder: columnOrder?.enabled ? columnOrder?.initialState : void 0,
752
+ columnVisibility: columnVisibility?.enabled ? columnVisibility?.initialState : void 0,
753
+ columnPinning: columnPinning?.enabled ? columnPinning?.initialState : void 0,
754
+ rowSelection: rowSelection?.enabled ? rowSelection?.initialState : void 0,
755
+ expanded: rowExpansion?.enabled ? rowExpansion?.initialState : void 0,
756
+ grouping: columnGrouping?.enabled ? columnGrouping?.initialState : void 0
757
+ }),
758
+ state: stripNullishObject({
759
+ columnFilters: filters?.enabled && (filters?.column?.enabled ?? true) ? filters?.column?.state : void 0,
760
+ globalFilter: filters?.enabled ? filters?.global?.state : void 0,
761
+ sorting: sorting?.enabled ? sorting?.state : void 0,
762
+ columnOrder: columnOrder?.enabled ? columnOrder?.state : void 0,
763
+ columnVisibility: columnVisibility?.enabled ? columnVisibility?.state : void 0,
764
+ columnPinning: columnPinning?.enabled ? columnPinning?.state : void 0,
765
+ rowSelection: rowSelection?.enabled ? rowSelection?.state : void 0,
766
+ expanded: rowExpansion?.enabled ? rowExpansion?.state : void 0,
767
+ grouping: columnGrouping?.enabled ? columnGrouping?.state : void 0
768
+ }),
769
+ // common
770
+ getRowId: rowIdKey,
771
+ getSubRows: childrenKey,
772
+ // shared configs filters column and global
773
+ enableFilters: filters?.enabled ?? false,
774
+ filterFromLeafRows: filters?.enabled && (filters?.filterFromLeafRows ?? false),
775
+ manualFiltering: filters?.enabled && (filters?.manual ?? false),
776
+ maxLeafRowFilterDepth: filters?.enabled ? filters?.maxDepth : void 0,
777
+ // column filters
778
+ getFilteredRowModel: !filters?.manual && filters?.enabled ? reactTable.getFilteredRowModel() : void 0,
779
+ enableColumnFilters: filters?.enabled && (filters?.column?.enabled ?? true),
780
+ onColumnFiltersChange: filters?.enabled && (filters?.column?.enabled ?? true) ? filters?.column?.onFilterChange : void 0,
781
+ // global filters
782
+ enableGlobalFilter: filters?.enabled && (filters?.global?.enabled ?? true),
783
+ globalFilterFn: filters?.enabled && (filters?.global?.enabled ?? true) ? filters?.global?.filterFn : void 0,
784
+ onGlobalFilterChange: filters?.enabled && (filters?.global?.enabled ?? true) ? filters?.global?.onFilterChange : void 0,
785
+ getColumnCanGlobalFilter: filters?.enabled && (filters?.global?.enabled ?? true) ? filters?.global?.canColumnFilterable ?? (() => true) : void 0,
786
+ // sorting
787
+ getSortedRowModel: !sorting?.manual && sorting?.enabled ? reactTable.getSortedRowModel() : void 0,
788
+ manualSorting: sorting?.enabled && (sorting?.manual ?? false),
789
+ enableSorting: sorting?.enabled ?? false,
790
+ // default behavior: column with type number is sort by desc and string sort by asc first, we fix force always asc
791
+ sortDescFirst: sorting?.enabled ? sorting?.sortDescFirst ?? false : false,
792
+ onSortingChange: sorting?.enabled ? sorting?.onSortingChange : void 0,
793
+ // ordering
794
+ onColumnOrderChange: columnOrder?.enabled ? columnOrder?.onOrderChange : void 0,
795
+ // visibility
796
+ onColumnVisibilityChange: columnVisibility?.enabled ? columnVisibility?.onVisibilityChange : void 0,
797
+ // pinning
798
+ enableColumnPinning: columnPinning?.enabled ?? false,
799
+ onColumnPinningChange: columnPinning?.enabled ? columnPinning?.onPinningChange : void 0,
800
+ // row selection
801
+ enableRowSelection: rowSelection?.enabled ? rowSelection?.canRowSelectable : false,
802
+ enableMultiRowSelection: rowSelection?.enabled ? rowSelection?.multiSelect ?? true : true,
803
+ onRowSelectionChange: rowSelection?.enabled ? rowSelection?.onSelectionChange : void 0,
804
+ // row expanded
805
+ getExpandedRowModel: (
806
+ // when grouping is use then we should open this
807
+ !rowExpansion?.manual && rowExpansion?.enabled ? reactTable.getExpandedRowModel() : void 0
808
+ ),
809
+ manualExpanding: rowExpansion?.enabled && (rowExpansion?.manual ?? false),
810
+ enableExpanding: rowExpansion?.enabled ?? false,
811
+ getIsRowExpanded: rowExpansion?.enabled ? rowExpansion?.isRowExpanded : void 0,
812
+ getRowCanExpand: rowExpansion?.enabled ? rowExpansion?.canRowExpand : void 0,
813
+ onExpandedChange: rowExpansion?.enabled ? rowExpansion?.onExpandedChange : void 0,
814
+ // grouping
815
+ getGroupedRowModel: !columnGrouping?.manual && columnGrouping?.enabled ? reactTable.getGroupedRowModel() : void 0,
816
+ enableGrouping: columnGrouping?.enabled ?? false,
817
+ manualGrouping: columnGrouping?.enabled && (columnGrouping?.manual ?? false),
818
+ groupedColumnMode: columnGrouping?.enabled ? columnGrouping?.groupedMode ?? false : false,
819
+ aggregationFns: columnGrouping?.enabled ? columnGrouping?.customAggregationFns : void 0,
820
+ onGroupingChange: columnGrouping?.enabled ? columnGrouping?.onGroupingChange : void 0,
821
+ // column sizing
822
+ enableColumnResizing: columnResizing?.enabled ?? false,
823
+ columnResizeMode: columnResizing?.enabled ? columnResizing?.resizeMode ?? "onChange" : "onChange"
824
+ })
825
+ });
826
+ if (isDefined(tableRef) && !isDefined(tableRef?.current)) {
827
+ tableRef.current = table;
828
+ }
829
+ const tableContainerRef = React3.useRef(null);
830
+ const isTableEmpty = table.getCoreRowModel().rows.length === 0;
831
+ const isTableEmptyAfterFiltering = table.getRowModel().rows.length === 0;
832
+ const isFiltering = table.getState().columnFilters.length > 0 || !!table.getState().globalFilter;
833
+ const leftVisibleLeftColumns = table.getLeftVisibleLeafColumns();
834
+ const centerVisibleLeafColumns = table.getCenterVisibleLeafColumns();
835
+ const rightVisibleLeafColumns = table.getRightVisibleLeafColumns();
836
+ const { isSomeColumnsFilterable, filterableColumns } = React3.useMemo(() => {
837
+ const mergedColumns = [
838
+ ...leftVisibleLeftColumns,
839
+ ...centerVisibleLeafColumns,
840
+ ...rightVisibleLeafColumns
841
+ ];
842
+ const isSomeColumnsFilterable2 = mergedColumns.some(
843
+ (column) => column.getCanFilter() && column.columnDef.meta?.renderColumnFilter
844
+ );
845
+ return { isSomeColumnsFilterable: isSomeColumnsFilterable2, filterableColumns: mergedColumns };
846
+ }, [centerVisibleLeafColumns, leftVisibleLeftColumns, rightVisibleLeafColumns]);
847
+ const fetchMoreOnScrollReached = React3.useCallback(
848
+ (containerRefElement) => {
849
+ if (!scrollFetch?.enabled) {
850
+ return;
851
+ }
852
+ if (containerRefElement) {
853
+ const { scrollHeight, scrollTop, clientHeight } = containerRefElement;
854
+ const threshold = 1.5;
855
+ if (scrollHeight - scrollTop - clientHeight < clientHeight * threshold && !scrollFetch?.isFetchingMore && scrollFetch?.hasMore && scrollFetch?.fetchMore) {
856
+ scrollFetch.fetchMore();
857
+ }
858
+ }
859
+ },
860
+ // eslint-disable-next-line react-hooks/exhaustive-deps
861
+ [scrollFetch?.enabled, scrollFetch?.isFetchingMore, scrollFetch?.hasMore, scrollFetch?.fetchMore]
862
+ );
863
+ React3.useEffect(() => {
864
+ fetchMoreOnScrollReached(tableContainerRef.current);
865
+ }, [fetchMoreOnScrollReached]);
866
+ return /* @__PURE__ */ jsxRuntime.jsxs(
867
+ TableContainer,
868
+ {
869
+ ref: tableContainerRef,
870
+ ...components?.containerProps,
871
+ className: cn(
872
+ "relative w-full overflow-auto h-full max-h-dvh max-w-full bg-white",
873
+ components?.containerProps?.className
874
+ ),
875
+ onScroll: (e2) => fetchMoreOnScrollReached(e2.currentTarget),
876
+ children: [
877
+ isInitialLoading ? /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: renderContentSlot(statusContent?.initialLoading || { content: "Loading..." }, {
878
+ className: "flex flex-col h-full items-center justify-center text-sm py-4"
879
+ }) }) : isTableEmpty ? /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: renderContentSlot(statusContent?.emptyData || { content: "There's nothing here yet." }, {
880
+ className: "flex flex-col h-full items-center justify-center text-sm py-4"
881
+ }) }) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
882
+ /* @__PURE__ */ jsxRuntime.jsxs(Table, { ...components?.tableProps, children: [
883
+ /* @__PURE__ */ jsxRuntime.jsxs(
884
+ TableHeader,
885
+ {
886
+ className: cn("sticky top-0 z-10", components?.tableHeaderProps?.className),
887
+ ...components?.tableHeaderProps,
888
+ children: [
889
+ table.getHeaderGroups().map((headerGroup) => {
890
+ return /* @__PURE__ */ jsxRuntime.jsx(TableRow, { children: headerGroup.headers.map((header) => {
891
+ const { classes, style } = getColumnPinningStyles(header.column);
892
+ const useColumnSizing = header.column.columnDef?.meta?.useColumnSizing ?? columnResizing?.enabled ?? false;
893
+ return /* @__PURE__ */ jsxRuntime.jsxs(
894
+ TableHead,
895
+ {
896
+ colSpan: header.colSpan,
897
+ ...header.column.columnDef?.meta?.headerProps,
898
+ className: cn(classes, header.column.columnDef?.meta?.headerProps?.className),
899
+ style: {
900
+ ...style,
901
+ width: useColumnSizing ? header.column.getSize() : void 0,
902
+ minWidth: useColumnSizing ? header.column.columnDef.minSize : void 0,
903
+ maxWidth: useColumnSizing ? header.column.columnDef.maxSize : void 0,
904
+ ...header.column.columnDef?.meta?.headerProps?.style
905
+ },
906
+ children: [
907
+ header.isPlaceholder ? null : reactTable.flexRender(header.column.columnDef.header, header.getContext()),
908
+ /* @__PURE__ */ jsxRuntime.jsx(ColumnResizer_default, { header, ...components?.columnResizerProps })
909
+ ]
910
+ },
911
+ header.id
912
+ );
913
+ }) }, headerGroup.id);
914
+ }),
915
+ isSomeColumnsFilterable && /* @__PURE__ */ jsxRuntime.jsx(TableRow, { children: filterableColumns.map((column) => {
916
+ const { classes, style } = getColumnPinningStyles(column);
917
+ const useColumnSizing = column.columnDef.meta?.useColumnSizing ?? columnResizing?.enabled ?? false;
918
+ return /* @__PURE__ */ jsxRuntime.jsx(
919
+ TableCell,
920
+ {
921
+ ...column.columnDef?.meta?.cellProps,
922
+ className: cn(
923
+ "bg-white border-b",
924
+ classes,
925
+ column.columnDef?.meta?.cellProps?.className
926
+ ),
927
+ style: {
928
+ // TODO: should we separate styles for filter or use same columns styles
929
+ ...style,
930
+ width: useColumnSizing ? column.getSize() : void 0,
931
+ minWidth: useColumnSizing ? column.columnDef.minSize : void 0,
932
+ maxWidth: useColumnSizing ? column.columnDef.maxSize : void 0,
933
+ ...column.columnDef?.meta?.cellProps?.style
934
+ },
935
+ children: column.getCanFilter() && column.columnDef.meta?.renderColumnFilter?.({
936
+ column,
937
+ table
938
+ })
939
+ },
940
+ column.id
941
+ );
942
+ }) })
943
+ ]
944
+ }
945
+ ),
946
+ /* @__PURE__ */ jsxRuntime.jsx(TableBody, { ...components?.tableBodyProps, children: table.getRowModel().rows.map((row) => {
947
+ const tableDataRowProps = typeof components?.tableDataRowProps === "function" ? components.tableDataRowProps({ row, table }) || {} : components?.tableDataRowProps || {};
948
+ return /* @__PURE__ */ React3.createElement(
949
+ TableRow,
950
+ {
951
+ ...tableDataRowProps,
952
+ key: row.id,
953
+ className: cn("group", tableDataRowProps?.className),
954
+ "data-state": row.getIsSelected() ? "selected" : "non-selected",
955
+ onClick: (event) => {
956
+ if (typeof onRowClick === "function") {
957
+ onRowClick(row.original, { event, row, table });
958
+ }
959
+ }
960
+ },
961
+ row.getVisibleCells().map((cell) => {
962
+ const { classes, style } = getColumnPinningStyles(cell.column);
963
+ const useColumnSizing = cell.column.columnDef.meta?.useColumnSizing ?? columnResizing?.enabled ?? false;
964
+ return /* @__PURE__ */ jsxRuntime.jsx(
965
+ TableCell,
966
+ {
967
+ ...cell.column.columnDef?.meta?.cellProps,
968
+ className: cn(
969
+ {
970
+ "bg-[#dfeae3]": row.getIsSelected(),
971
+ "bg-white group-hover:bg-[#eff5f1]": !row.getIsSelected()
972
+ },
973
+ classes,
974
+ cell.column.columnDef?.meta?.cellProps?.className
975
+ ),
976
+ style: {
977
+ ...style,
978
+ width: useColumnSizing ? cell.column.getSize() : void 0,
979
+ minWidth: useColumnSizing ? cell.column.columnDef.minSize : void 0,
980
+ maxWidth: useColumnSizing ? cell.column.columnDef.maxSize : void 0,
981
+ ...cell.column.columnDef?.meta?.cellProps?.style
982
+ },
983
+ children: reactTable.flexRender(cell.column.columnDef.cell, cell.getContext())
984
+ },
985
+ cell.id
986
+ );
987
+ })
988
+ );
989
+ }) })
990
+ ] }),
991
+ isTableEmptyAfterFiltering && /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: renderContentSlot(
992
+ statusContent?.emptyFilteredData || {
993
+ content: "No records found. Please try a different search."
994
+ },
995
+ {
996
+ className: "flex flex-col h-[calc(100%-76px)] items-center justify-center text-sm py-4"
997
+ }
998
+ ) }),
999
+ scrollFetch?.enabled && !isFiltering && !isInitialLoading && scrollFetch?.isFetchingMore && /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: renderContentSlot(statusContent?.fetchingMore || { content: "Loading more..." }, {
1000
+ className: "flex items-center justify-center text-sm py-4"
1001
+ }) }),
1002
+ scrollFetch?.enabled && !isFiltering && !isInitialLoading && !scrollFetch?.hasMore && !scrollFetch?.isFetchingMore && /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: renderContentSlot(statusContent?.noMoreData || { content: null }, {
1003
+ className: "flex items-center justify-center text-sm py-4"
1004
+ }) })
1005
+ ] }),
1006
+ debug && /* @__PURE__ */ jsxRuntime.jsx(DataTableDevTool_default, { table })
1007
+ ]
1008
+ }
1009
+ );
1010
+ };
1011
+ var DataTable_default = DataTable;
1012
+ var buttonVariants = classVarianceAuthority.cva(
1013
+ "inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive cursor-pointer",
1014
+ {
1015
+ variants: {
1016
+ variant: {
1017
+ default: "bg-sus-primary-1 text-primary-foreground shadow-xs hover:bg-sus-primary/90",
1018
+ destructive: "bg-destructive text-white shadow-xs hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",
1019
+ outline: "border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50",
1020
+ secondary: "bg-secondary text-secondary-foreground shadow-xs hover:bg-secondary/80",
1021
+ ghost: "hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",
1022
+ link: "text-primary underline-offset-4 hover:underline",
1023
+ cancel: "border bg-[#8B8B8B] text-white shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50",
1024
+ defaultSelect: "bg-primary text-primary-foreground shadow-xs hover:bg-sus-primary/90 py-2",
1025
+ defaultOutline: "border bg-background py-2 shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50"
1026
+ },
1027
+ size: {
1028
+ default: "h-9 px-4 has-[>svg]:px-3",
1029
+ option: "py-5 h-9 px-4 has-[>svg]:px-3",
1030
+ sm: "h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",
1031
+ lg: "h-10 rounded-md px-6 has-[>svg]:px-4",
1032
+ icon: "size-9",
1033
+ "icon-xs": "size-5",
1034
+ "icon-sm": "size-[22px]",
1035
+ "icon-md": "size-7",
1036
+ "icon-lg": "size-10"
1037
+ },
1038
+ active: {
1039
+ true: "bg-sus-primary-1 text-white",
1040
+ false: ""
1041
+ }
1042
+ },
1043
+ defaultVariants: {
1044
+ variant: "default",
1045
+ size: "default"
1046
+ }
1047
+ }
1048
+ );
1049
+ function Button({
1050
+ className,
1051
+ variant,
1052
+ size,
1053
+ active,
1054
+ asChild = false,
1055
+ ...props
1056
+ }) {
1057
+ const Comp = asChild ? reactSlot.Slot : "button";
1058
+ return /* @__PURE__ */ jsxRuntime.jsx(
1059
+ Comp,
1060
+ {
1061
+ "data-slot": "button",
1062
+ className: cn(buttonVariants({ variant, size, className, active })),
1063
+ ...props
1064
+ }
1065
+ );
1066
+ }
1067
+ var s = (e2, s2, o3) => {
1068
+ if (e2 && "reportValidity" in e2) {
1069
+ const r2 = reactHookForm.get(o3, s2);
1070
+ e2.setCustomValidity(r2 && r2.message || ""), e2.reportValidity();
1071
+ }
1072
+ };
1073
+ var o = (t3, e2) => {
1074
+ for (const o3 in e2.fields) {
1075
+ const r2 = e2.fields[o3];
1076
+ r2 && r2.ref && "reportValidity" in r2.ref ? s(r2.ref, o3, t3) : r2.refs && r2.refs.forEach((e3) => s(e3, o3, t3));
1077
+ }
1078
+ };
1079
+ var r = (s2, r2) => {
1080
+ r2.shouldUseNativeValidation && o(s2, r2);
1081
+ const f = {};
1082
+ for (const o3 in s2) {
1083
+ const n2 = reactHookForm.get(r2.fields, o3), a = Object.assign(s2[o3] || {}, { ref: n2 && n2.ref });
1084
+ if (i(r2.names || Object.keys(s2), o3)) {
1085
+ const s3 = Object.assign({}, reactHookForm.get(f, o3));
1086
+ reactHookForm.set(s3, "root", a), reactHookForm.set(f, o3, s3);
1087
+ } else reactHookForm.set(f, o3, a);
1088
+ }
1089
+ return f;
1090
+ };
1091
+ var i = (t3, e2) => t3.some((t4) => t4.startsWith(e2 + "."));
1092
+ var n = function(r2, e2) {
1093
+ for (var n2 = {}; r2.length; ) {
1094
+ var t3 = r2[0], s2 = t3.code, i2 = t3.message, a = t3.path.join(".");
1095
+ if (!n2[a]) if ("unionErrors" in t3) {
1096
+ var u = t3.unionErrors[0].errors[0];
1097
+ n2[a] = { message: u.message, type: u.code };
1098
+ } else n2[a] = { message: i2, type: s2 };
1099
+ if ("unionErrors" in t3 && t3.unionErrors.forEach(function(e3) {
1100
+ return e3.errors.forEach(function(e4) {
1101
+ return r2.push(e4);
1102
+ });
1103
+ }), e2) {
1104
+ var c = n2[a].types, f = c && c[t3.code];
1105
+ n2[a] = reactHookForm.appendErrors(a, e2, n2, s2, f ? [].concat(f, t3.message) : t3.message);
1106
+ }
1107
+ r2.shift();
1108
+ }
1109
+ return n2;
1110
+ };
1111
+ var t2 = function(o3, t3, s2) {
1112
+ return void 0 === s2 && (s2 = {}), function(i2, a, u) {
1113
+ try {
1114
+ return Promise.resolve(function(e2, n2) {
1115
+ try {
1116
+ var a2 = Promise.resolve(o3["sync" === s2.mode ? "parse" : "parseAsync"](i2, t3)).then(function(e3) {
1117
+ return u.shouldUseNativeValidation && o({}, u), { errors: {}, values: s2.raw ? i2 : e3 };
1118
+ });
1119
+ } catch (r2) {
1120
+ return n2(r2);
1121
+ }
1122
+ return a2 && a2.then ? a2.then(void 0, n2) : a2;
1123
+ }(0, function(r2) {
1124
+ if (function(r3) {
1125
+ return Array.isArray(null == r3 ? void 0 : r3.errors);
1126
+ }(r2)) return { values: {}, errors: r(n(r2.errors, !u.shouldUseNativeValidation && "all" === u.criteriaMode), u) };
1127
+ throw r2;
1128
+ }));
1129
+ } catch (r2) {
1130
+ return Promise.reject(r2);
1131
+ }
1132
+ };
1133
+ };
1134
+ var Form = reactHookForm.FormProvider;
1135
+ var FormFieldContext2 = React3__namespace.createContext({});
1136
+ var FormField2 = ({
1137
+ ...props
1138
+ }) => {
1139
+ return /* @__PURE__ */ jsxRuntime.jsx(FormFieldContext2.Provider, { value: { name: props.name }, children: /* @__PURE__ */ jsxRuntime.jsx(reactHookForm.Controller, { ...props }) });
1140
+ };
1141
+ var useFormField2 = () => {
1142
+ const fieldContext = React3__namespace.useContext(FormFieldContext2);
1143
+ const itemContext = React3__namespace.useContext(FormItemContext2);
1144
+ const { getFieldState } = reactHookForm.useFormContext();
1145
+ const formState = reactHookForm.useFormState({ name: fieldContext.name });
1146
+ const fieldState = getFieldState(fieldContext.name, formState);
1147
+ if (!fieldContext) {
1148
+ throw new Error("useFormField should be used within <FormField>");
1149
+ }
1150
+ const { id } = itemContext;
1151
+ return {
1152
+ id,
1153
+ name: fieldContext.name,
1154
+ formItemId: `${id}-form-item`,
1155
+ formDescriptionId: `${id}-form-item-description`,
1156
+ formMessageId: `${id}-form-item-message`,
1157
+ ...fieldState
1158
+ };
1159
+ };
1160
+ var FormItemContext2 = React3__namespace.createContext({});
1161
+ function FormItem2({ className, ...props }) {
1162
+ const id = React3__namespace.useId();
1163
+ return /* @__PURE__ */ jsxRuntime.jsx(FormItemContext2.Provider, { value: { id }, children: /* @__PURE__ */ jsxRuntime.jsx("div", { "data-slot": "form-item", className: cn("grid gap-2", className), ...props }) });
1164
+ }
1165
+ function FormControl({ ...props }) {
1166
+ const { error, formItemId, formDescriptionId, formMessageId } = useFormField2();
1167
+ return /* @__PURE__ */ jsxRuntime.jsx(
1168
+ reactSlot.Slot,
1169
+ {
1170
+ "data-slot": "form-control",
1171
+ id: formItemId,
1172
+ "aria-describedby": !error ? `${formDescriptionId}` : `${formDescriptionId} ${formMessageId}`,
1173
+ "aria-invalid": !!error,
1174
+ ...props
1175
+ }
1176
+ );
1177
+ }
1178
+ function FormMessage({ className, ...props }) {
1179
+ const { error, formMessageId } = useFormField2();
1180
+ const body = error ? String(error?.message ?? "") : props.children;
1181
+ if (!body) {
1182
+ return null;
1183
+ }
1184
+ return /* @__PURE__ */ jsxRuntime.jsx(
1185
+ "p",
1186
+ {
1187
+ "data-slot": "form-message",
1188
+ id: formMessageId,
1189
+ className: cn("text-destructive text-xs", className),
1190
+ ...props,
1191
+ children: body
1192
+ }
1193
+ );
1194
+ }
1195
+ function Dialog({ ...props }) {
1196
+ return /* @__PURE__ */ jsxRuntime.jsx(DialogPrimitive__namespace.Root, { "data-slot": "dialog", ...props });
1197
+ }
1198
+ function DialogPortal({ ...props }) {
1199
+ return /* @__PURE__ */ jsxRuntime.jsx(DialogPrimitive__namespace.Portal, { "data-slot": "dialog-portal", ...props });
1200
+ }
1201
+ function DialogClose({ ...props }) {
1202
+ return /* @__PURE__ */ jsxRuntime.jsx(DialogPrimitive__namespace.Close, { "data-slot": "dialog-close", ...props });
1203
+ }
1204
+ function DialogOverlay({ className, ...props }) {
1205
+ return /* @__PURE__ */ jsxRuntime.jsx(
1206
+ DialogPrimitive__namespace.Overlay,
1207
+ {
1208
+ "data-slot": "dialog-overlay",
1209
+ className: cn(
1210
+ "data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",
1211
+ className
1212
+ ),
1213
+ ...props
1214
+ }
1215
+ );
1216
+ }
1217
+ function DialogContent({
1218
+ className,
1219
+ children,
1220
+ showCloseButton = true,
1221
+ ...props
1222
+ }) {
1223
+ return /* @__PURE__ */ jsxRuntime.jsxs(DialogPortal, { "data-slot": "dialog-portal", children: [
1224
+ /* @__PURE__ */ jsxRuntime.jsx(DialogOverlay, {}),
1225
+ /* @__PURE__ */ jsxRuntime.jsxs(
1226
+ DialogPrimitive__namespace.Content,
1227
+ {
1228
+ "data-slot": "dialog-content",
1229
+ className: cn(
1230
+ "bg-background 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 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 sm:max-w-lg",
1231
+ className
1232
+ ),
1233
+ ...props,
1234
+ children: [
1235
+ children,
1236
+ showCloseButton && /* @__PURE__ */ jsxRuntime.jsxs(
1237
+ DialogPrimitive__namespace.Close,
1238
+ {
1239
+ "data-slot": "dialog-close",
1240
+ className: "ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
1241
+ children: [
1242
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.XIcon, {}),
1243
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Close" })
1244
+ ]
1245
+ }
1246
+ )
1247
+ ]
1248
+ }
1249
+ )
1250
+ ] });
1251
+ }
1252
+ function DialogHeader({ className, ...props }) {
1253
+ return /* @__PURE__ */ jsxRuntime.jsx(
1254
+ "div",
1255
+ {
1256
+ "data-slot": "dialog-header",
1257
+ className: cn("flex flex-col gap-2 text-center sm:text-left", className),
1258
+ ...props
1259
+ }
1260
+ );
1261
+ }
1262
+ function DialogFooter({ className, ...props }) {
1263
+ return /* @__PURE__ */ jsxRuntime.jsx(
1264
+ "div",
1265
+ {
1266
+ "data-slot": "dialog-footer",
1267
+ className: cn("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end", className),
1268
+ ...props
1269
+ }
1270
+ );
1271
+ }
1272
+ function DialogTitle({ className, ...props }) {
1273
+ return /* @__PURE__ */ jsxRuntime.jsx(
1274
+ DialogPrimitive__namespace.Title,
1275
+ {
1276
+ "data-slot": "dialog-title",
1277
+ className: cn("text-lg leading-none font-semibold", className),
1278
+ ...props
1279
+ }
1280
+ );
1281
+ }
1282
+ function DialogDescription({
1283
+ className,
1284
+ ...props
1285
+ }) {
1286
+ return /* @__PURE__ */ jsxRuntime.jsx(
1287
+ DialogPrimitive__namespace.Description,
1288
+ {
1289
+ "data-slot": "dialog-description",
1290
+ className: cn("text-muted-foreground text-sm", className),
1291
+ ...props
1292
+ }
1293
+ );
1294
+ }
1295
+ function Select({ ...props }) {
1296
+ return /* @__PURE__ */ jsxRuntime.jsx(SelectPrimitive__namespace.Root, { "data-slot": "select", ...props });
1297
+ }
1298
+ function SelectValue({ ...props }) {
1299
+ return /* @__PURE__ */ jsxRuntime.jsx(SelectPrimitive__namespace.Value, { "data-slot": "select-value", ...props });
1300
+ }
1301
+ function SelectTrigger({
1302
+ className,
1303
+ size = "default",
1304
+ children,
1305
+ ...props
1306
+ }) {
1307
+ return /* @__PURE__ */ jsxRuntime.jsxs(
1308
+ SelectPrimitive__namespace.Trigger,
1309
+ {
1310
+ "data-slot": "select-trigger",
1311
+ "data-size": size,
1312
+ className: cn(
1313
+ "border-input data-[placeholder]:text-muted-foreground [&_svg:not([class*='text-'])]:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 dark:hover:bg-input/50 flex w-fit items-center justify-between gap-2 rounded-md border bg-transparent px-3 py-2 text-sm whitespace-nowrap shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 data-[size=default]:h-9 data-[size=sm]:h-8 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
1314
+ className
1315
+ ),
1316
+ ...props,
1317
+ children: [
1318
+ children,
1319
+ /* @__PURE__ */ jsxRuntime.jsx(SelectPrimitive__namespace.Icon, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronDownIcon, { className: "size-4 opacity-50" }) })
1320
+ ]
1321
+ }
1322
+ );
1323
+ }
1324
+ function SelectContent({
1325
+ className,
1326
+ children,
1327
+ position = "popper",
1328
+ ...props
1329
+ }) {
1330
+ return /* @__PURE__ */ jsxRuntime.jsx(SelectPrimitive__namespace.Portal, { children: /* @__PURE__ */ jsxRuntime.jsxs(
1331
+ SelectPrimitive__namespace.Content,
1332
+ {
1333
+ "data-slot": "select-content",
1334
+ className: cn(
1335
+ "bg-popover text-popover-foreground 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 relative z-50 max-h-(--radix-select-content-available-height) min-w-[8rem] origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border shadow-md",
1336
+ 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",
1337
+ className
1338
+ ),
1339
+ position,
1340
+ ...props,
1341
+ children: [
1342
+ /* @__PURE__ */ jsxRuntime.jsx(SelectScrollUpButton, {}),
1343
+ /* @__PURE__ */ jsxRuntime.jsx(
1344
+ SelectPrimitive__namespace.Viewport,
1345
+ {
1346
+ className: cn(
1347
+ "p-1",
1348
+ position === "popper" && "h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1"
1349
+ ),
1350
+ children
1351
+ }
1352
+ ),
1353
+ /* @__PURE__ */ jsxRuntime.jsx(SelectScrollDownButton, {})
1354
+ ]
1355
+ }
1356
+ ) });
1357
+ }
1358
+ function SelectItem({
1359
+ className,
1360
+ children,
1361
+ ...props
1362
+ }) {
1363
+ return /* @__PURE__ */ jsxRuntime.jsxs(
1364
+ SelectPrimitive__namespace.Item,
1365
+ {
1366
+ "data-slot": "select-item",
1367
+ className: cn(
1368
+ "focus:bg-accent focus:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex w-full cursor-default items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2",
1369
+ className
1370
+ ),
1371
+ ...props,
1372
+ children: [
1373
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "absolute right-2 flex size-3.5 items-center justify-center", children: /* @__PURE__ */ jsxRuntime.jsx(SelectPrimitive__namespace.ItemIndicator, { children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.CheckIcon, { className: "size-4" }) }) }),
1374
+ /* @__PURE__ */ jsxRuntime.jsx(SelectPrimitive__namespace.ItemText, { children })
1375
+ ]
1376
+ }
1377
+ );
1378
+ }
1379
+ function SelectScrollUpButton({
1380
+ className,
1381
+ ...props
1382
+ }) {
1383
+ return /* @__PURE__ */ jsxRuntime.jsx(
1384
+ SelectPrimitive__namespace.ScrollUpButton,
1385
+ {
1386
+ "data-slot": "select-scroll-up-button",
1387
+ className: cn("flex cursor-default items-center justify-center py-1", className),
1388
+ ...props,
1389
+ children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronUpIcon, { className: "size-4" })
1390
+ }
1391
+ );
1392
+ }
1393
+ function SelectScrollDownButton({
1394
+ className,
1395
+ ...props
1396
+ }) {
1397
+ return /* @__PURE__ */ jsxRuntime.jsx(
1398
+ SelectPrimitive__namespace.ScrollDownButton,
1399
+ {
1400
+ "data-slot": "select-scroll-down-button",
1401
+ className: cn("flex cursor-default items-center justify-center py-1", className),
1402
+ ...props,
1403
+ children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronDownIcon, { className: "size-4" })
1404
+ }
1405
+ );
1406
+ }
1407
+ function TooltipProvider({
1408
+ delayDuration = 0,
1409
+ ...props
1410
+ }) {
1411
+ return /* @__PURE__ */ jsxRuntime.jsx(TooltipPrimitive__namespace.Provider, { "data-slot": "tooltip-provider", delayDuration, ...props });
1412
+ }
1413
+ function Tooltip({ ...props }) {
1414
+ return /* @__PURE__ */ jsxRuntime.jsx(TooltipProvider, { children: /* @__PURE__ */ jsxRuntime.jsx(TooltipPrimitive__namespace.Root, { "data-slot": "tooltip", ...props }) });
1415
+ }
1416
+ function TooltipTrigger({ ...props }) {
1417
+ return /* @__PURE__ */ jsxRuntime.jsx(TooltipPrimitive__namespace.Trigger, { "data-slot": "tooltip-trigger", ...props });
1418
+ }
1419
+ function TooltipContent({
1420
+ className,
1421
+ arrowClassName,
1422
+ sideOffset = 0,
1423
+ children,
1424
+ ...props
1425
+ }) {
1426
+ return /* @__PURE__ */ jsxRuntime.jsx(TooltipPrimitive__namespace.Portal, { children: /* @__PURE__ */ jsxRuntime.jsxs(
1427
+ TooltipPrimitive__namespace.Content,
1428
+ {
1429
+ "data-slot": "tooltip-content",
1430
+ sideOffset,
1431
+ className: cn(
1432
+ "bg-primary text-primary-foreground animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-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 z-50 w-fit origin-(--radix-tooltip-content-transform-origin) rounded-md px-3 py-1.5 text-xs text-balance",
1433
+ className
1434
+ ),
1435
+ ...props,
1436
+ children: [
1437
+ children,
1438
+ /* @__PURE__ */ jsxRuntime.jsx(
1439
+ TooltipPrimitive__namespace.Arrow,
1440
+ {
1441
+ className: cn(
1442
+ "bg-primary fill-primary z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]",
1443
+ arrowClassName
1444
+ )
1445
+ }
1446
+ )
1447
+ ]
1448
+ }
1449
+ ) });
1450
+ }
1451
+ function SortableRow({
1452
+ itemId,
1453
+ index,
1454
+ control,
1455
+ availableColumns,
1456
+ currentColumns,
1457
+ disableDrag = false,
1458
+ disableEdit = false,
1459
+ hideFormMessage,
1460
+ removeColumn
1461
+ }) {
1462
+ const { attributes, listeners, setNodeRef, transform, transition } = sortable.useSortable({
1463
+ id: itemId,
1464
+ disabled: disableDrag
1465
+ });
1466
+ const style = {
1467
+ transform: utilities.CSS.Transform.toString(transform),
1468
+ transition
1469
+ };
1470
+ const capitalize = (str) => str.charAt(0).toUpperCase() + str.slice(1);
1471
+ const options = availableColumns.map((col) => ({
1472
+ id: col.id,
1473
+ label: capitalize(col.id)
1474
+ }));
1475
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { ref: setNodeRef, style, className: "flex items-center rounded-md bg-white", children: /* @__PURE__ */ jsxRuntime.jsx(
1476
+ FormField2,
1477
+ {
1478
+ control,
1479
+ name: `columns.${index}.id`,
1480
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(FormItem2, { className: "flex-1", children: [
1481
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
1482
+ /* @__PURE__ */ jsxRuntime.jsx(
1483
+ lucideReact.GripVertical,
1484
+ {
1485
+ className: cn(
1486
+ "h-5 w-5 text-[#B9B9B9] focus:outline-none cursor-grab",
1487
+ index == 0 && "opacity-0 pointer-events-none"
1488
+ ),
1489
+ ...attributes,
1490
+ ...listeners
1491
+ }
1492
+ ),
1493
+ /* @__PURE__ */ jsxRuntime.jsxs(
1494
+ Select,
1495
+ {
1496
+ value: field.value,
1497
+ onValueChange: (val) => {
1498
+ field.onChange(val);
1499
+ },
1500
+ disabled: disableEdit || index == 0,
1501
+ children: [
1502
+ /* @__PURE__ */ jsxRuntime.jsx(FormControl, { children: /* @__PURE__ */ jsxRuntime.jsx(
1503
+ SelectTrigger,
1504
+ {
1505
+ className: cn(
1506
+ "w-full border-[#DDDDDD] data-[disabled]:opacity-100 aria-invalid:border-[#BB0B0E]",
1507
+ index == 0 ? "text-[#8B8B8B] bg-[#EAEAEA] cursor-not-allowed" : ""
1508
+ ),
1509
+ children: /* @__PURE__ */ jsxRuntime.jsx(SelectValue, { placeholder: "Choose column..." })
1510
+ }
1511
+ ) }),
1512
+ /* @__PURE__ */ jsxRuntime.jsx(SelectContent, { children: options.filter((i2) => i2.id === field.value || !currentColumns?.some((c) => c.id === i2.id)).sort(
1513
+ (a, b) => a.id === field.value ? -1 : b.id === field.value ? 1 : 0
1514
+ ).map((opt) => /* @__PURE__ */ jsxRuntime.jsx(
1515
+ SelectItem,
1516
+ {
1517
+ value: opt.id,
1518
+ className: cn(
1519
+ "focus:bg-[#e8edea]",
1520
+ opt.id === field.value ? "font-bold bg-[#dae5de] focus:bg-[#dae5de]" : ""
1521
+ ),
1522
+ children: opt.label
1523
+ },
1524
+ opt.id
1525
+ )) })
1526
+ ]
1527
+ }
1528
+ ),
1529
+ index == 0 ? /* @__PURE__ */ jsxRuntime.jsx(TooltipProvider, { children: /* @__PURE__ */ jsxRuntime.jsxs(Tooltip, { children: [
1530
+ /* @__PURE__ */ jsxRuntime.jsx(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Info, { className: "h-5 w-5", stroke: "white", fill: "#8B8B8B" }) }),
1531
+ /* @__PURE__ */ jsxRuntime.jsx(
1532
+ TooltipContent,
1533
+ {
1534
+ align: "start",
1535
+ alignOffset: 10,
1536
+ className: "bg-[#8B8B8B] rounded-none",
1537
+ arrowClassName: "!hidden",
1538
+ children: /* @__PURE__ */ jsxRuntime.jsx("p", { children: "Column cannot be removed." })
1539
+ }
1540
+ )
1541
+ ] }) }) : /* @__PURE__ */ jsxRuntime.jsx(
1542
+ lucideReact.CircleMinus,
1543
+ {
1544
+ onClick: () => index > 0 && removeColumn(index),
1545
+ className: "h-5 w-5 cursor-pointer",
1546
+ stroke: "white",
1547
+ fill: "#C32A2C"
1548
+ }
1549
+ )
1550
+ ] }),
1551
+ /* @__PURE__ */ jsxRuntime.jsx(FormMessage, { className: cn("pl-6 text-[#BB0B0E]", hideFormMessage && "hidden") })
1552
+ ] })
1553
+ }
1554
+ ) });
1555
+ }
1556
+ var buttonVariants2 = classVarianceAuthority.cva(
1557
+ "inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive cursor-pointer",
1558
+ {
1559
+ variants: {
1560
+ variant: {
1561
+ default: "bg-primary text-primary-foreground shadow-xs hover:bg-sus-primary/90",
1562
+ destructive: "bg-destructive text-white shadow-xs hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",
1563
+ outline: "border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50",
1564
+ secondary: "bg-secondary text-secondary-foreground shadow-xs hover:bg-secondary/80",
1565
+ ghost: "hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",
1566
+ link: "text-primary underline-offset-4 hover:underline"
1567
+ },
1568
+ size: {
1569
+ default: "h-9 px-4 py-2 has-[>svg]:px-3",
1570
+ sm: "h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",
1571
+ lg: "h-10 rounded-md px-6 has-[>svg]:px-4",
1572
+ icon: "size-9",
1573
+ "icon-xs": "size-5",
1574
+ "icon-sm": "size-[22px]",
1575
+ "icon-md": "size-7",
1576
+ "icon-lg": "size-10"
1577
+ },
1578
+ active: {
1579
+ true: "bg-sus-primary-1 text-white",
1580
+ // <-- Active state style
1581
+ false: ""
1582
+ }
1583
+ },
1584
+ defaultVariants: {
1585
+ variant: "default",
1586
+ size: "default"
1587
+ }
1588
+ }
1589
+ );
1590
+ function Button2({
1591
+ className,
1592
+ variant,
1593
+ size,
1594
+ active,
1595
+ asChild = false,
1596
+ ...props
1597
+ }) {
1598
+ const Comp = asChild ? reactSlot.Slot : "button";
1599
+ return /* @__PURE__ */ jsxRuntime.jsx(
1600
+ Comp,
1601
+ {
1602
+ "data-slot": "button",
1603
+ className: cn(buttonVariants2({ variant, size, className, active })),
1604
+ ...props
1605
+ }
1606
+ );
1607
+ }
1608
+ var ColumnSchema = zod.z.object({
1609
+ id: zod.z.string().nonempty("This field is required")
1610
+ });
1611
+ var GridSettingsSchema = zod.z.object({
1612
+ columns: zod.z.array(ColumnSchema).min(1, "At least one column is required")
1613
+ });
1614
+ var GridSettingsModal = ({
1615
+ isOpen = false,
1616
+ headerClassname,
1617
+ descriptionClassname,
1618
+ addButtonClassname,
1619
+ saveButtonClassname,
1620
+ availableColumns,
1621
+ currentColumns,
1622
+ limit = availableColumns.length,
1623
+ onClose,
1624
+ onSaveColumns
1625
+ }) => {
1626
+ const [hideFormMessage, setHideFormMessage] = React3.useState(false);
1627
+ const form = reactHookForm.useForm({
1628
+ resolver: t2(GridSettingsSchema),
1629
+ defaultValues: { columns: currentColumns },
1630
+ mode: "onChange"
1631
+ });
1632
+ React3.useEffect(() => {
1633
+ if (isOpen) {
1634
+ form.reset({ columns: currentColumns });
1635
+ }
1636
+ }, [isOpen, currentColumns, form]);
1637
+ const columns = form.watch("columns");
1638
+ const onSubmit = (data) => {
1639
+ const ordering = data.columns.map((i2) => i2.id);
1640
+ const visibility = Object.fromEntries(
1641
+ availableColumns.map((col) => [col.id, data.columns.some((c) => c.id === col.id)])
1642
+ );
1643
+ const pinning = { left: [data.columns[0].id] };
1644
+ if (onSaveColumns) {
1645
+ onSaveColumns({ ordering, visibility, pinning });
1646
+ }
1647
+ };
1648
+ const addColumn = async () => {
1649
+ const isValid2 = await form.trigger("columns");
1650
+ if (!isValid2) {
1651
+ return;
1652
+ }
1653
+ form.setValue("columns", [...columns, { id: "" }], { shouldValidate: false });
1654
+ };
1655
+ const removeColumn = (index) => {
1656
+ const newCols = [...columns];
1657
+ newCols.splice(index, 1);
1658
+ form.setValue("columns", newCols);
1659
+ };
1660
+ const sensors = core.useSensors(core.useSensor(core.PointerSensor, { activationConstraint: { distance: 5 } }));
1661
+ const handleDragEnd = (event) => {
1662
+ const { active, over } = event;
1663
+ if (!over || active.id === over.id) return;
1664
+ const oldIndex = columns.findIndex((c) => c.id === active.id);
1665
+ const newIndex = columns.findIndex((c) => c.id === over.id);
1666
+ if (newIndex === 0) return;
1667
+ const reordered = sortable.arrayMove(columns, oldIndex, newIndex);
1668
+ form.setValue("columns", reordered, { shouldValidate: true });
1669
+ };
1670
+ return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: /* @__PURE__ */ jsxRuntime.jsx(Dialog, { open: isOpen, onOpenChange: (open) => !open && onClose(), children: /* @__PURE__ */ jsxRuntime.jsxs(DialogContent, { className: "sm:max-w-xl p-0 border-0", showCloseButton: false, children: [
1671
+ /* @__PURE__ */ jsxRuntime.jsx(DialogClose, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(
1672
+ "button",
1673
+ {
1674
+ type: "button",
1675
+ "aria-label": "Close",
1676
+ className: "absolute top-4 right-4",
1677
+ style: {
1678
+ background: "none",
1679
+ border: "none",
1680
+ padding: 0,
1681
+ cursor: "pointer"
1682
+ },
1683
+ children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.X, { className: "w-6 h-6 text-white" })
1684
+ }
1685
+ ) }),
1686
+ /* @__PURE__ */ jsxRuntime.jsxs(DialogHeader, { className: cn("bg-[#82B495] text-white h-25 rounded-t-lg", headerClassname), children: [
1687
+ /* @__PURE__ */ jsxRuntime.jsx(DialogTitle, { className: "text-2xl p-4", children: "Grid Settings" }),
1688
+ /* @__PURE__ */ jsxRuntime.jsx(
1689
+ DialogDescription,
1690
+ {
1691
+ className: cn("bg-[#8B8B8B] text-white px-4 py-2.5", descriptionClassname),
1692
+ children: "Add or remove columns. To change the column order, drag and drop a field."
1693
+ }
1694
+ )
1695
+ ] }),
1696
+ /* @__PURE__ */ jsxRuntime.jsx(Form, { ...form, children: /* @__PURE__ */ jsxRuntime.jsxs("form", { onSubmit: form.handleSubmit(onSubmit), className: "flex flex-col justify-between", children: [
1697
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "px-16 my-10", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-3 max-h-60 overflow-y-auto pr-4", children: [
1698
+ /* @__PURE__ */ jsxRuntime.jsx(
1699
+ SortableRow,
1700
+ {
1701
+ itemId: columns[0]?.id,
1702
+ index: 0,
1703
+ control: form.control,
1704
+ availableColumns,
1705
+ currentColumns: columns,
1706
+ disableDrag: true,
1707
+ disableEdit: true,
1708
+ removeColumn
1709
+ }
1710
+ ),
1711
+ /* @__PURE__ */ jsxRuntime.jsx(
1712
+ core.DndContext,
1713
+ {
1714
+ sensors,
1715
+ collisionDetection: core.closestCenter,
1716
+ onDragStart: () => setHideFormMessage(true),
1717
+ onDragEnd: (event) => {
1718
+ setHideFormMessage(false);
1719
+ handleDragEnd(event);
1720
+ },
1721
+ children: /* @__PURE__ */ jsxRuntime.jsx(
1722
+ sortable.SortableContext,
1723
+ {
1724
+ items: columns?.slice(1).map((c) => c.id),
1725
+ strategy: sortable.verticalListSortingStrategy,
1726
+ children: columns?.slice(1).map((item, index) => /* @__PURE__ */ jsxRuntime.jsx(
1727
+ SortableRow,
1728
+ {
1729
+ itemId: item.id,
1730
+ index: index + 1,
1731
+ control: form.control,
1732
+ availableColumns,
1733
+ currentColumns: columns,
1734
+ hideFormMessage,
1735
+ removeColumn
1736
+ },
1737
+ item.id + index
1738
+ ))
1739
+ }
1740
+ )
1741
+ }
1742
+ ),
1743
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "px-6", children: /* @__PURE__ */ jsxRuntime.jsxs(
1744
+ Button2,
1745
+ {
1746
+ type: "button",
1747
+ className: cn("bg-[#41875C99] text-white w-full rounded-t-lg", addButtonClassname),
1748
+ onClick: addColumn,
1749
+ disabled: columns.length >= limit,
1750
+ children: [
1751
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Plus, { className: "h-4 w-4 mr-1" }),
1752
+ " Add column"
1753
+ ]
1754
+ }
1755
+ ) })
1756
+ ] }) }),
1757
+ /* @__PURE__ */ jsxRuntime.jsx(DialogFooter, { className: "w-full px-6", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-between w-full py-4 border-t-1 border-[#B9B9B9]", children: [
1758
+ /* @__PURE__ */ jsxRuntime.jsx(
1759
+ Button2,
1760
+ {
1761
+ type: "button",
1762
+ variant: "outline",
1763
+ onClick: onClose,
1764
+ className: "w-18 text-[#8B8B8B] border-[#B9B9B9]",
1765
+ children: "Cancel"
1766
+ }
1767
+ ),
1768
+ /* @__PURE__ */ jsxRuntime.jsx(
1769
+ Button2,
1770
+ {
1771
+ type: "submit",
1772
+ className: cn("w-18 bg-[#379A2A] text-white", saveButtonClassname),
1773
+ children: "Save"
1774
+ }
1775
+ )
1776
+ ] }) })
1777
+ ] }) })
1778
+ ] }) }) });
1779
+ };
1780
+ var GridSettingsModal_default = GridSettingsModal;
1781
+ var InfoIcon = (props) => {
1782
+ return /* @__PURE__ */ jsxRuntime.jsxs(
1783
+ "svg",
1784
+ {
1785
+ width: "24",
1786
+ height: "26",
1787
+ viewBox: "0 0 14 13",
1788
+ fill: "none",
1789
+ xmlns: "http://www.w3.org/2000/svg",
1790
+ ...props,
1791
+ children: [
1792
+ /* @__PURE__ */ jsxRuntime.jsx("circle", { cx: "6.98438", cy: "6.63281", r: "6.25", fill: "white" }),
1793
+ /* @__PURE__ */ jsxRuntime.jsx(
1794
+ "path",
1795
+ {
1796
+ d: "M5.98811 3.39501C5.98811 4.01786 6.44715 4.40642 6.99953 4.40642C7.5519 4.40642 7.98047 4.04833 7.98047 3.39501C7.98047 2.74168 7.5519 2.41406 6.99953 2.41406C6.44715 2.41406 5.98811 2.76073 5.98811 3.39501ZM6.13096 10.8521H7.86809V5.02928H6.13096V10.8521Z",
1797
+ fill: "#231F20"
1798
+ }
1799
+ )
1800
+ ]
1801
+ }
1802
+ );
1803
+ };
1804
+ var InfoIcon_default = React3__namespace.default.memo(InfoIcon);
1805
+ function TooltipProvider2({
1806
+ delayDuration = 0,
1807
+ ...props
1808
+ }) {
1809
+ return /* @__PURE__ */ jsxRuntime.jsx(
1810
+ TooltipPrimitive__namespace.Provider,
1811
+ {
1812
+ "data-slot": "tooltip-provider",
1813
+ delayDuration,
1814
+ ...props
1815
+ }
1816
+ );
1817
+ }
1818
+ function Tooltip2({
1819
+ ...props
1820
+ }) {
1821
+ return /* @__PURE__ */ jsxRuntime.jsx(TooltipProvider2, { children: /* @__PURE__ */ jsxRuntime.jsx(TooltipPrimitive__namespace.Root, { "data-slot": "tooltip", ...props }) });
1822
+ }
1823
+ function TooltipTrigger2({
1824
+ ...props
1825
+ }) {
1826
+ return /* @__PURE__ */ jsxRuntime.jsx(TooltipPrimitive__namespace.Trigger, { "data-slot": "tooltip-trigger", ...props });
1827
+ }
1828
+ function TooltipArrow(props) {
1829
+ return /* @__PURE__ */ jsxRuntime.jsx(TooltipPrimitive__namespace.Arrow, { ...props });
1830
+ }
1831
+ function TooltipContent2({
1832
+ className,
1833
+ sideOffset = 0,
1834
+ children,
1835
+ ...props
1836
+ }) {
1837
+ return /* @__PURE__ */ jsxRuntime.jsx(TooltipPrimitive__namespace.Portal, { children: /* @__PURE__ */ jsxRuntime.jsx(
1838
+ TooltipPrimitive__namespace.Content,
1839
+ {
1840
+ "data-slot": "tooltip-content",
1841
+ sideOffset,
1842
+ className: cn(
1843
+ "relative bg-primary text-primary-foreground animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-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 z-50 w-fit origin-(--radix-tooltip-content-transform-origin) rounded-md rounded-tl-none px-3 py-1.5 text-xs text-balance",
1844
+ className
1845
+ ),
1846
+ ...props,
1847
+ children
1848
+ }
1849
+ ) });
1850
+ }
1851
+ var Navbar = ({
1852
+ className,
1853
+ title,
1854
+ subTitle,
1855
+ headImageURL = "",
1856
+ headImageURLClassName,
1857
+ tooltipTitle,
1858
+ tooltipIcon,
1859
+ tooltipdescription = [],
1860
+ mainButtonText,
1861
+ mainButtonClassName,
1862
+ mainButtonDisable = false,
1863
+ subButtonText,
1864
+ subButtonClassName,
1865
+ subButtonDisable = false,
1866
+ onMainButtonClick,
1867
+ onSubButtonClick,
1868
+ searchButton
1869
+ }) => {
1870
+ const { isMobile, isTablet, isDesktop } = useScreenSize_default();
1871
+ const Icon3 = lucideReact.CircleHelp;
1872
+ return /* @__PURE__ */ jsxRuntime.jsxs(
1873
+ "nav",
1874
+ {
1875
+ className: cn(
1876
+ "py-5 px-8 w-full h-[5.3rem] bg-sus-primary-1 flex items-center justify-between",
1877
+ className
1878
+ ),
1879
+ children: [
1880
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2.5", children: [
1881
+ headImageURL !== "" ? /* @__PURE__ */ jsxRuntime.jsx("img", { src: headImageURL, alt: "", className: cn("w-full h-full", headImageURLClassName) }) : /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-1", children: [
1882
+ React3.isValidElement(title) ? title : /* @__PURE__ */ jsxRuntime.jsx("h1", { className: "text-white text-4xl font-bold", children: title }),
1883
+ React3.isValidElement(subTitle) ? subTitle : /* @__PURE__ */ jsxRuntime.jsx("h1", { className: "text-white text-xl font-bold", children: subTitle })
1884
+ ] }),
1885
+ tooltipTitle && /* @__PURE__ */ jsxRuntime.jsxs(Tooltip2, { children: [
1886
+ /* @__PURE__ */ jsxRuntime.jsx(TooltipTrigger2, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("button", { className: "text-white hover:opacity-80 ", children: /* @__PURE__ */ jsxRuntime.jsx(InfoIcon_default, { className: "w-4" }) }) }),
1887
+ /* @__PURE__ */ jsxRuntime.jsxs(
1888
+ TooltipContent2,
1889
+ {
1890
+ forceMount: true,
1891
+ side: isDesktop ? "right" : "bottom",
1892
+ sideOffset: 8,
1893
+ align: "start",
1894
+ avoidCollisions: false,
1895
+ className: cn(
1896
+ "bg-background text-foreground border border-black md:w-[350px] lg:w-[420px]",
1897
+ "transition-all duration-150 ease-out origin-top",
1898
+ "data-[state=closed]:opacity-0 data-[state=open]:opacity-100",
1899
+ "data-[state=closed]:scale-95 data-[state=open]:scale-100",
1900
+ { "mt-5": isDesktop }
1901
+ ),
1902
+ children: [
1903
+ /* @__PURE__ */ jsxRuntime.jsxs(
1904
+ "div",
1905
+ {
1906
+ role: "tooltip",
1907
+ "aria-label": tooltipTitle,
1908
+ className: cn("flex flex-col gap-4 max-w-sm text-sm text-gray-700", className),
1909
+ children: [
1910
+ tooltipTitle && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-3", children: [
1911
+ React3.isValidElement(tooltipIcon) ? tooltipIcon : /* @__PURE__ */ jsxRuntime.jsx(Icon3, { size: 32, "aria-hidden": "true" }),
1912
+ /* @__PURE__ */ jsxRuntime.jsx("h3", { className: "text-xl font-bold", children: tooltipTitle })
1913
+ ] }),
1914
+ React3.isValidElement(tooltipdescription) ? tooltipdescription : ""
1915
+ ]
1916
+ }
1917
+ ),
1918
+ /* @__PURE__ */ jsxRuntime.jsx(TooltipArrow, { className: "-my-px border-none fill-white", asChild: true, children: /* @__PURE__ */ jsxRuntime.jsxs(
1919
+ "svg",
1920
+ {
1921
+ width: isDesktop ? 35 : 33,
1922
+ height: 35,
1923
+ viewBox: "0 0 40 35",
1924
+ xmlns: "http://www.w3.org/2000/svg",
1925
+ className: cn({
1926
+ "rotate-90 visible": isTablet || isMobile,
1927
+ "": isDesktop
1928
+ }),
1929
+ children: [
1930
+ /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M0 0 L40 0 L0 35 Z", fill: "white" }),
1931
+ isDesktop ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1932
+ /* @__PURE__ */ jsxRuntime.jsx("line", { x1: "0", y1: "40", x2: "0", y2: "0", stroke: "black", strokeWidth: "2.5" }),
1933
+ /* @__PURE__ */ jsxRuntime.jsx("line", { x1: "40", y1: "0", x2: "0", y2: "35", stroke: "black", strokeWidth: "1" })
1934
+ ] }) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1935
+ /* @__PURE__ */ jsxRuntime.jsx("line", { x1: "40", y1: "0", x2: "0", y2: "0", stroke: "black", strokeWidth: "2" }),
1936
+ /* @__PURE__ */ jsxRuntime.jsx("line", { x1: "40", y1: "0", x2: "0", y2: "35", stroke: "black", strokeWidth: "1" })
1937
+ ] })
1938
+ ]
1939
+ }
1940
+ ) })
1941
+ ]
1942
+ }
1943
+ )
1944
+ ] })
1945
+ ] }),
1946
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-3", children: [
1947
+ mainButtonText && /* @__PURE__ */ jsxRuntime.jsx(
1948
+ Button,
1949
+ {
1950
+ disabled: mainButtonDisable,
1951
+ className: cn("bg-sus-secondary-1 hover:bg-sus-secondary-hover", mainButtonClassName),
1952
+ size: "lg",
1953
+ onClick: onMainButtonClick,
1954
+ children: mainButtonText
1955
+ }
1956
+ ),
1957
+ subButtonText && /* @__PURE__ */ jsxRuntime.jsx(
1958
+ Button,
1959
+ {
1960
+ disabled: subButtonDisable,
1961
+ className: cn("bg-sus-primary-2 hover:bg-sus-primary-2-hover", subButtonClassName),
1962
+ size: "lg",
1963
+ onClick: onSubButtonClick,
1964
+ children: subButtonText
1965
+ }
1966
+ ),
1967
+ React3.isValidElement(searchButton) ? /* @__PURE__ */ jsxRuntime.jsx("div", { role: "separator", className: "ml-1 w-[1px] h-10 bg-white" }) : "",
1968
+ React3.isValidElement(searchButton) ? searchButton : ""
1969
+ ] })
1970
+ ]
1971
+ }
1972
+ );
1973
+ };
1974
+ var navbar_default = React3__namespace.default.memo(Navbar);
1975
+ var ExpandCollapse = ({ title, children, portalId }) => {
1976
+ const [isOpen, setIsOpen] = React3.useState(false);
1977
+ const Panel = /* @__PURE__ */ jsxRuntime.jsx(
1978
+ "div",
1979
+ {
1980
+ className: clsx3__default.default(
1981
+ "overflow-hidden transition-all duration-500 ease-in-out bg-white border-b shadow-md w-full",
1982
+ isOpen ? "max-h-[700px] opacity-100" : "max-h-0 opacity-0"
1983
+ ),
1984
+ children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "relative p-6", children: [
1985
+ /* @__PURE__ */ jsxRuntime.jsx(
1986
+ "button",
1987
+ {
1988
+ onClick: () => setIsOpen(false),
1989
+ className: "absolute top-2 right-2 text-gray-500 hover:text-gray-700",
1990
+ children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.X, { className: "w-5 h-5" })
1991
+ }
1992
+ ),
1993
+ children
1994
+ ] })
1995
+ }
1996
+ );
1997
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1998
+ /* @__PURE__ */ jsxRuntime.jsx(
1999
+ "button",
2000
+ {
2001
+ onClick: () => setIsOpen(!isOpen),
2002
+ className: "px-4 py-2 text-sm text-gray-700 hover:text-black",
2003
+ children: title
2004
+ }
2005
+ ),
2006
+ portalId && typeof document !== "undefined" ? document.getElementById(portalId) ? reactDom.createPortal(Panel, document.getElementById(portalId)) : null : Panel
2007
+ ] });
2008
+ };
2009
+ var ExpandCollapse_default = ExpandCollapse;
2010
+
2011
+ // src/components/advanceSearch/operatorMap.ts
2012
+ var OPERATOR_MAP = {
2013
+ text: [
2014
+ "contains",
2015
+ "equals",
2016
+ "beginsWith",
2017
+ "endsWith",
2018
+ "notEquals",
2019
+ "notBeginsWith",
2020
+ "notEndsWith",
2021
+ "notContains"
2022
+ ],
2023
+ number: ["equals", "notEquals", "gt", "gte", "lt", "lte"],
2024
+ date: ["on", "after", "before", "between"],
2025
+ datetime: ["on", "after", "before", "between"],
2026
+ checkbox: ["is", "isNot"],
2027
+ dropdown: ["is", "isNot"],
2028
+ lookup: ["containsAny", "containsOnly", "containsAll", "notContains"]
2029
+ };
2030
+
2031
+ // src/components/advanceSearch/hooks/useAdvanceSearch.ts
2032
+ function findField(fields, name) {
2033
+ return fields.find((f) => f.name === name);
2034
+ }
2035
+ function getFieldType(fields, name) {
2036
+ return findField(fields, name)?.type ?? "text";
2037
+ }
2038
+ function firstOperatorFor(fields, fieldName) {
2039
+ const t3 = getFieldType(fields, fieldName);
2040
+ return OPERATOR_MAP[t3][0];
2041
+ }
2042
+ function makeNewRow(fields) {
2043
+ const first = fields[0];
2044
+ const op = OPERATOR_MAP[first.type][0];
2045
+ if (op === "between") {
2046
+ return {
2047
+ id: crypto.randomUUID(),
2048
+ fieldName: first.name,
2049
+ operator: "between",
2050
+ value: "",
2051
+ value2: ""
2052
+ };
2053
+ }
2054
+ return { id: crypto.randomUUID(), fieldName: first.name, operator: op, value: "" };
2055
+ }
2056
+ function useAdvanceSearch({ fields, limitRows }) {
2057
+ const [rows, setRows] = React3.useState([makeNewRow(fields)]);
2058
+ const updateRows = React3.useCallback((next) => {
2059
+ setRows(next);
2060
+ }, []);
2061
+ const operatorsForField = React3.useCallback(
2062
+ (fieldName) => {
2063
+ const t3 = getFieldType(fields, fieldName);
2064
+ return OPERATOR_MAP[t3];
2065
+ },
2066
+ [fields]
2067
+ );
2068
+ const addRow = React3.useCallback(() => {
2069
+ if (!limitRows || rows.length < limitRows) {
2070
+ updateRows([...rows, makeNewRow(fields)]);
2071
+ }
2072
+ }, [rows, fields, updateRows, limitRows]);
2073
+ const removeRow = React3.useCallback(
2074
+ (id) => {
2075
+ if (rows.length === 1) return;
2076
+ updateRows(rows.filter((r2) => r2.id !== id));
2077
+ },
2078
+ [rows, updateRows]
2079
+ );
2080
+ const clearRow = React3.useCallback(
2081
+ (id) => {
2082
+ updateRows(
2083
+ rows.map((r2) => {
2084
+ if (r2.id !== id) return r2;
2085
+ const nextOp = firstOperatorFor(fields, r2.fieldName);
2086
+ return nextOp === "between" ? { id: r2.id, fieldName: r2.fieldName, operator: "between", value: "", value2: "" } : { id: r2.id, fieldName: r2.fieldName, operator: nextOp, value: "" };
2087
+ })
2088
+ );
2089
+ },
2090
+ [rows, fields, updateRows]
2091
+ );
2092
+ const clearAllRow = React3.useCallback(() => {
2093
+ updateRows([makeNewRow(fields)]);
2094
+ }, [fields, updateRows]);
2095
+ const changeField = React3.useCallback(
2096
+ (id, fieldName) => {
2097
+ const nextOp = firstOperatorFor(fields, fieldName);
2098
+ updateRows(
2099
+ rows.map((r2) => {
2100
+ if (r2.id !== id) return r2;
2101
+ return nextOp === "between" ? { id: r2.id, fieldName, operator: "between", value: "", value2: "" } : { id: r2.id, fieldName, operator: nextOp, value: "" };
2102
+ })
2103
+ );
2104
+ },
2105
+ [rows, fields, updateRows]
2106
+ );
2107
+ const changeOperator = React3.useCallback(
2108
+ (id, operator) => {
2109
+ updateRows(
2110
+ rows.map((r2) => {
2111
+ if (r2.id !== id) return r2;
2112
+ if (operator === "between") {
2113
+ return { id: r2.id, fieldName: r2.fieldName, operator, value: "", value2: "" };
2114
+ }
2115
+ return { id: r2.id, fieldName: r2.fieldName, operator, value: "" };
2116
+ })
2117
+ );
2118
+ },
2119
+ [rows, updateRows]
2120
+ );
2121
+ const changeValue = React3.useCallback(
2122
+ (id, which, val) => {
2123
+ updateRows(
2124
+ rows.map((r2) => {
2125
+ if (r2.id !== id) return r2;
2126
+ if (which === "value2" && r2.operator !== "between") return r2;
2127
+ return { ...r2, [which]: val };
2128
+ })
2129
+ );
2130
+ },
2131
+ [rows, updateRows]
2132
+ );
2133
+ const fieldOptions = React3.useMemo(
2134
+ () => fields.map((f) => ({
2135
+ value: f.name,
2136
+ label: f.label ?? f.name
2137
+ })),
2138
+ [fields]
2139
+ );
2140
+ const rowToFilter = (row) => {
2141
+ switch (row.operator) {
2142
+ case "between":
2143
+ return {
2144
+ [row.fieldName]: {
2145
+ gte: row.value,
2146
+ lte: row.value2
2147
+ }
2148
+ };
2149
+ case "contains":
2150
+ return { [row.fieldName]: { contains: row.value } };
2151
+ case "beginsWith":
2152
+ return { [row.fieldName]: { startsWith: row.value } };
2153
+ case "endsWith":
2154
+ return { [row.fieldName]: { endsWith: row.value } };
2155
+ case "notEquals":
2156
+ return { [row.fieldName]: { not: row.value } };
2157
+ case "gt":
2158
+ return { [row.fieldName]: { gt: row.value } };
2159
+ case "gte":
2160
+ return { [row.fieldName]: { gte: row.value } };
2161
+ case "lt":
2162
+ return { [row.fieldName]: { lt: row.value } };
2163
+ case "lte":
2164
+ return { [row.fieldName]: { lte: row.value } };
2165
+ case "is":
2166
+ return { [row.fieldName]: row.value };
2167
+ case "isNot":
2168
+ return { [row.fieldName]: { not: row.value } };
2169
+ case "notContains":
2170
+ return { [row.fieldName]: { not: { contains: row.value } } };
2171
+ case "notBeginsWith":
2172
+ return { [row.fieldName]: { not: { startsWith: row.value } } };
2173
+ case "notEndsWith":
2174
+ return { [row.fieldName]: { not: { endsWith: row.value } } };
2175
+ case "containsAny":
2176
+ return { [row.fieldName]: { hasSome: row.value.split(",") } };
2177
+ case "containsAll":
2178
+ return { [row.fieldName]: { hasEvery: row.value.split(",") } };
2179
+ case "containsOnly":
2180
+ return { [row.fieldName]: { equals: row.value.split(",") } };
2181
+ default:
2182
+ return { [row.fieldName]: row.value };
2183
+ }
2184
+ };
2185
+ const buildParam = React3.useMemo(() => {
2186
+ const andConditions = rows.map((r2) => r2.value ? rowToFilter(r2) : null).filter(Boolean);
2187
+ return { AND: andConditions };
2188
+ }, [rows]);
2189
+ return {
2190
+ rows,
2191
+ addRow,
2192
+ removeRow,
2193
+ clearRow,
2194
+ clearAllRow,
2195
+ changeField,
2196
+ changeOperator,
2197
+ changeValue,
2198
+ operatorsForField,
2199
+ fieldOptions,
2200
+ param: buildParam
2201
+ };
2202
+ }
2203
+
2204
+ // src/components/advanceSearch/types.ts
2205
+ var OPERATOR_LABEL = {
2206
+ contains: "Contains",
2207
+ equals: "Equals",
2208
+ beginsWith: "Begins with",
2209
+ endsWith: "Ends with",
2210
+ notEquals: "Not equals",
2211
+ notBeginsWith: "Not begins with",
2212
+ notEndsWith: "Not ends with",
2213
+ notContains: "Not contains",
2214
+ gt: "Greater than",
2215
+ gte: "Greater or equal",
2216
+ lt: "Less than",
2217
+ lte: "Less or equal",
2218
+ on: "On",
2219
+ after: "After",
2220
+ before: "Before",
2221
+ between: "Between",
2222
+ is: "Is",
2223
+ isNot: "Is not",
2224
+ containsAny: "Contains at least one of",
2225
+ containsOnly: "Contains only",
2226
+ containsAll: "Contains all of"
2227
+ };
2228
+ function Select2({ ...props }) {
2229
+ return /* @__PURE__ */ jsxRuntime.jsx(SelectPrimitive__namespace.Root, { "data-slot": "select", ...props });
2230
+ }
2231
+ function SelectValue2({ ...props }) {
2232
+ return /* @__PURE__ */ jsxRuntime.jsx(SelectPrimitive__namespace.Value, { "data-slot": "select-value", ...props });
2233
+ }
2234
+ function SelectTrigger2({
2235
+ className,
2236
+ size = "default",
2237
+ children,
2238
+ ...props
2239
+ }) {
2240
+ return /* @__PURE__ */ jsxRuntime.jsxs(
2241
+ SelectPrimitive__namespace.Trigger,
2242
+ {
2243
+ "data-slot": "select-trigger",
2244
+ "data-size": size,
2245
+ className: cn2(
2246
+ "border-input data-[placeholder]:text-gray-00 [&_svg:not([class*='text-'])]:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:hover:bg-input/50 flex w-fit items-center justify-between gap-2 rounded-md border bg-transparent px-3 py-2 text-sm whitespace-nowrap shadow-xs transition-[color,box-shadow] outline-none disabled:cursor-not-allowed disabled:opacity-50 data-[size=default]:h-9 data-[size=sm]:h-8 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
2247
+ className
2248
+ ),
2249
+ ...props,
2250
+ children: [
2251
+ children,
2252
+ /* @__PURE__ */ jsxRuntime.jsx(SelectPrimitive__namespace.Icon, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Triangle, { className: "size-2 opacity-60 fill-current", style: { transform: "rotate(180deg)" } }) })
2253
+ ]
2254
+ }
2255
+ );
2256
+ }
2257
+ function SelectContent2({
2258
+ className,
2259
+ children,
2260
+ position = "popper",
2261
+ ...props
2262
+ }) {
2263
+ return /* @__PURE__ */ jsxRuntime.jsx(SelectPrimitive__namespace.Portal, { children: /* @__PURE__ */ jsxRuntime.jsxs(
2264
+ SelectPrimitive__namespace.Content,
2265
+ {
2266
+ "data-slot": "select-content",
2267
+ className: cn2(
2268
+ "bg-popover text-popover-foreground 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 relative z-50 max-h-(--radix-select-content-available-height) min-w-[8rem] origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border shadow-md",
2269
+ 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",
2270
+ className
2271
+ ),
2272
+ position,
2273
+ ...props,
2274
+ children: [
2275
+ /* @__PURE__ */ jsxRuntime.jsx(SelectScrollUpButton2, {}),
2276
+ /* @__PURE__ */ jsxRuntime.jsx(
2277
+ SelectPrimitive__namespace.Viewport,
2278
+ {
2279
+ className: cn2(
2280
+ "p-1",
2281
+ position === "popper" && "h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1"
2282
+ ),
2283
+ children
2284
+ }
2285
+ ),
2286
+ /* @__PURE__ */ jsxRuntime.jsx(SelectScrollDownButton2, {})
2287
+ ]
2288
+ }
2289
+ ) });
2290
+ }
2291
+ function SelectItem2({
2292
+ className,
2293
+ children,
2294
+ ...props
2295
+ }) {
2296
+ return /* @__PURE__ */ jsxRuntime.jsxs(
2297
+ SelectPrimitive__namespace.Item,
2298
+ {
2299
+ "data-slot": "select-item",
2300
+ className: cn2(
2301
+ "focus:bg-accent focus:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex w-full cursor-default items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2",
2302
+ className
2303
+ ),
2304
+ ...props,
2305
+ children: [
2306
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "absolute right-2 flex size-3.5 items-center justify-center", children: /* @__PURE__ */ jsxRuntime.jsx(SelectPrimitive__namespace.ItemIndicator, { children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.CheckIcon, { className: "size-2" }) }) }),
2307
+ /* @__PURE__ */ jsxRuntime.jsx(SelectPrimitive__namespace.ItemText, { children })
2308
+ ]
2309
+ }
2310
+ );
2311
+ }
2312
+ function SelectScrollUpButton2({
2313
+ className,
2314
+ ...props
2315
+ }) {
2316
+ return /* @__PURE__ */ jsxRuntime.jsx(
2317
+ SelectPrimitive__namespace.ScrollUpButton,
2318
+ {
2319
+ "data-slot": "select-scroll-up-button",
2320
+ className: cn2("flex cursor-default items-center justify-center py-1", className),
2321
+ ...props,
2322
+ children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Triangle, { className: "size-2 fill-current", style: { transform: "rotate(0deg)" } })
2323
+ }
2324
+ );
2325
+ }
2326
+ function SelectScrollDownButton2({
2327
+ className,
2328
+ ...props
2329
+ }) {
2330
+ return /* @__PURE__ */ jsxRuntime.jsx(
2331
+ SelectPrimitive__namespace.ScrollDownButton,
2332
+ {
2333
+ "data-slot": "select-scroll-down-button",
2334
+ className: cn2("flex cursor-default items-center justify-center py-1", className),
2335
+ ...props,
2336
+ children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Triangle, { className: "size-2 fill-current", style: { transform: "rotate(180deg)" } })
2337
+ }
2338
+ );
2339
+ }
2340
+ function Input({ className, type, ...props }) {
2341
+ return /* @__PURE__ */ jsxRuntime.jsx(
2342
+ "input",
2343
+ {
2344
+ type,
2345
+ "data-slot": "input",
2346
+ className: cn2(
2347
+ "file:text-foreground placeholder:text-gray-400 selection:bg-primary selection:text-primary-foreground border-input flex h-9 w-full min-w-0 rounded-md border bg-white px-3 py-1 text-base shadow-xs transition-[color,box-shadow] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",
2348
+ "focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]",
2349
+ "aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",
2350
+ className
2351
+ ),
2352
+ ...props
2353
+ }
2354
+ );
2355
+ }
2356
+ function Popover({ ...props }) {
2357
+ return /* @__PURE__ */ jsxRuntime.jsx(PopoverPrimitive__namespace.Root, { "data-slot": "popover", ...props });
2358
+ }
2359
+ function PopoverTrigger({ ...props }) {
2360
+ return /* @__PURE__ */ jsxRuntime.jsx(PopoverPrimitive__namespace.Trigger, { "data-slot": "popover-trigger", ...props });
2361
+ }
2362
+ function PopoverContent({
2363
+ className,
2364
+ align = "center",
2365
+ sideOffset = 4,
2366
+ children,
2367
+ ...props
2368
+ }) {
2369
+ return /* @__PURE__ */ jsxRuntime.jsx(PopoverPrimitive__namespace.Portal, { children: /* @__PURE__ */ jsxRuntime.jsx(
2370
+ PopoverPrimitive__namespace.Content,
2371
+ {
2372
+ align,
2373
+ sideOffset,
2374
+ className: cn2(
2375
+ "bg-popover text-popover-foreground 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 z-50 w-72 origin-(--radix-popover-content-transform-origin) border p-4 shadow-md outline-hidden",
2376
+ className
2377
+ ),
2378
+ ...props,
2379
+ children
2380
+ }
2381
+ ) });
2382
+ }
2383
+ var buttonVariants3 = classVarianceAuthority.cva(
2384
+ "inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive cursor-pointer",
2385
+ {
2386
+ variants: {
2387
+ variant: {
2388
+ default: "bg-sus-primary-1 text-primary-foreground shadow-xs hover:bg-sus-primary/90",
2389
+ destructive: "bg-destructive text-white shadow-xs hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",
2390
+ outline: "border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:border-input dark:hover:bg-input/50",
2391
+ secondary: "bg-secondary text-secondary-foreground shadow-xs hover:bg-secondary/80",
2392
+ ghost: "hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",
2393
+ link: "text-primary underline-offset-4 hover:underline",
2394
+ cancel: "border bg-[#8B8B8B] text-white shadow-xs hover:bg-accent hover:text-accent-foreground dark:border-input dark:hover:bg-input/50",
2395
+ defaultSelect: "bg-primary text-primary-foreground shadow-xs hover:bg-sus-primary/90 py-2",
2396
+ defaultOutline: "border bg-background py-2 shadow-xs hover:bg-accent hover:text-accent-foreground dark:border-input dark:hover:bg-input/50"
2397
+ },
2398
+ size: {
2399
+ default: "h-9 px-4 has-[>svg]:px-3",
2400
+ option: "py-5 h-9 px-4 has-[>svg]:px-3",
2401
+ sm: "h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",
2402
+ lg: "h-10 rounded-md px-6 has-[>svg]:px-4",
2403
+ icon: "size-9",
2404
+ "icon-xs": "size-5",
2405
+ "icon-sm": "size-[22px]",
2406
+ "icon-md": "size-7",
2407
+ "icon-lg": "size-10"
2408
+ },
2409
+ active: {
2410
+ true: "bg-sus-primary-1 text-white",
2411
+ false: ""
2412
+ }
2413
+ },
2414
+ defaultVariants: {
2415
+ variant: "default",
2416
+ size: "default"
2417
+ }
2418
+ }
2419
+ );
2420
+ function Button3({
2421
+ className,
2422
+ variant,
2423
+ size,
2424
+ active,
2425
+ asChild = false,
2426
+ ...props
2427
+ }) {
2428
+ const Comp = asChild ? reactSlot.Slot : "button";
2429
+ return /* @__PURE__ */ jsxRuntime.jsx(
2430
+ Comp,
2431
+ {
2432
+ "data-slot": "button",
2433
+ className: cn2(buttonVariants3({ variant, size, className, active })),
2434
+ ...props
2435
+ }
2436
+ );
2437
+ }
2438
+ var ClearButton = ({
2439
+ onClick,
2440
+ title = "Clear",
2441
+ ariaLabel = "Clear row",
2442
+ className = ""
2443
+ }) => {
2444
+ return /* @__PURE__ */ jsxRuntime.jsx(
2445
+ "span",
2446
+ {
2447
+ role: "button",
2448
+ onClick,
2449
+ className: `clear-button ${className}`,
2450
+ "aria-label": ariaLabel,
2451
+ title,
2452
+ children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.X, { className: "icon" })
2453
+ }
2454
+ );
2455
+ };
2456
+ var isSameDay = (a, b) => a.getFullYear() === b.getFullYear() && a.getMonth() === b.getMonth() && a.getDate() === b.getDate();
2457
+ var startOfDay = (d) => {
2458
+ const x = new Date(d);
2459
+ x.setHours(0, 0, 0, 0);
2460
+ return x;
2461
+ };
2462
+ var clampToDay = (d) => d ? startOfDay(d) : void 0;
2463
+ var addMonths = (date, n2) => {
2464
+ const d = new Date(date);
2465
+ d.setMonth(d.getMonth() + n2);
2466
+ return d;
2467
+ };
2468
+ var daysInMonth = (year, monthIndex) => new Date(year, monthIndex + 1, 0).getDate();
2469
+ function buildCalendarGrid(displayed, weekStartsOnMonday = true) {
2470
+ const year = displayed.getFullYear();
2471
+ const month = displayed.getMonth();
2472
+ const firstOfMonth = new Date(year, month, 1);
2473
+ const firstWeekday = firstOfMonth.getDay();
2474
+ const offset = weekStartsOnMonday ? firstWeekday === 0 ? 6 : firstWeekday - 1 : firstWeekday;
2475
+ const totalDays = daysInMonth(year, month);
2476
+ const prevMonth = addMonths(firstOfMonth, -1);
2477
+ const prevMonthDays = daysInMonth(prevMonth.getFullYear(), prevMonth.getMonth());
2478
+ const grid = [];
2479
+ for (let i2 = offset - 1; i2 >= 0; i2--) {
2480
+ const d = new Date(prevMonth.getFullYear(), prevMonth.getMonth(), prevMonthDays - i2);
2481
+ grid.push({ date: d, inCurrentMonth: false });
2482
+ }
2483
+ for (let d = 1; d <= totalDays; d++) {
2484
+ grid.push({ date: new Date(year, month, d), inCurrentMonth: true });
2485
+ }
2486
+ while (grid.length < 42) {
2487
+ const last = grid[grid.length - 1].date;
2488
+ const next = new Date(last);
2489
+ next.setDate(last.getDate() + 1);
2490
+ grid.push({ date: next, inCurrentMonth: false });
2491
+ }
2492
+ const rows = [];
2493
+ for (let r2 = 0; r2 < 6; r2++) rows.push(grid.slice(r2 * 7, r2 * 7 + 7));
2494
+ return rows;
2495
+ }
2496
+ function DatePicker({
2497
+ selectedDate,
2498
+ onDateSelect,
2499
+ callbacks,
2500
+ onMonthBackward,
2501
+ onMonthForward,
2502
+ variant,
2503
+ minDate,
2504
+ maxDate,
2505
+ disabledDates,
2506
+ className,
2507
+ ...props
2508
+ }) {
2509
+ const today = React3__namespace.useMemo(() => startOfDay(/* @__PURE__ */ new Date()), []);
2510
+ const [displayed, setDisplayed] = React3__namespace.useState(
2511
+ selectedDate ? new Date(selectedDate) : /* @__PURE__ */ new Date()
2512
+ );
2513
+ minDate = clampToDay(minDate);
2514
+ maxDate = clampToDay(maxDate);
2515
+ const disabledSet = React3__namespace.useMemo(() => {
2516
+ const s2 = /* @__PURE__ */ new Set();
2517
+ disabledDates?.forEach((d) => s2.add(startOfDay(d).toISOString()));
2518
+ return s2;
2519
+ }, [disabledDates]);
2520
+ const displayYear = displayed.getFullYear();
2521
+ const displayMonth = displayed.getMonth();
2522
+ const monthLabel = callbacks?.monthLabel?.(displayYear, displayMonth) ?? new Intl.DateTimeFormat(void 0, { month: "short" }).format(displayed);
2523
+ const yearLabel = callbacks?.yearLabel?.(displayYear) ?? String(displayYear);
2524
+ const weekdays = React3__namespace.useMemo(() => {
2525
+ const labels = [];
2526
+ for (let i2 = 0; i2 < 7; i2++) {
2527
+ const idx = i2;
2528
+ const fallback = ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"][idx];
2529
+ labels.push(callbacks?.weekdayLabel?.(idx) ?? fallback);
2530
+ }
2531
+ return labels;
2532
+ }, [callbacks]);
2533
+ const grid = React3__namespace.useMemo(() => buildCalendarGrid(displayed, true), [displayed]);
2534
+ const isDateDisabled = (date) => {
2535
+ const d = startOfDay(date);
2536
+ if (minDate && d < minDate) return true;
2537
+ if (maxDate && d > maxDate) return true;
2538
+ if (disabledSet.has(d.toISOString())) return true;
2539
+ return false;
2540
+ };
2541
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn2("min-w-[260px] w-[300px] p-3", className), ...props, children: [
2542
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between mb-2", children: [
2543
+ /* @__PURE__ */ jsxRuntime.jsx(
2544
+ "button",
2545
+ {
2546
+ onClick: () => {
2547
+ setDisplayed(addMonths(displayed, -1));
2548
+ onMonthBackward?.();
2549
+ },
2550
+ className: cn2(
2551
+ buttonVariants3({ variant: variant?.chevrons ?? "outline" }),
2552
+ "inline-flex h-8 w-8 items-center justify-center p-0"
2553
+ ),
2554
+ "aria-label": "Previous month",
2555
+ children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronLeft, { className: "h-4 w-4 opacity-70" })
2556
+ }
2557
+ ),
2558
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-sm font-medium select-none", children: [
2559
+ monthLabel,
2560
+ " ",
2561
+ yearLabel
2562
+ ] }),
2563
+ /* @__PURE__ */ jsxRuntime.jsx(
2564
+ "button",
2565
+ {
2566
+ onClick: () => {
2567
+ setDisplayed(addMonths(displayed, 1));
2568
+ onMonthForward?.();
2569
+ },
2570
+ className: cn2(
2571
+ buttonVariants3({ variant: variant?.chevrons ?? "outline" }),
2572
+ "inline-flex h-8 w-8 items-center justify-center p-0"
2573
+ ),
2574
+ "aria-label": "Next month",
2575
+ children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronRight, { className: "h-4 w-4 opacity-70" })
2576
+ }
2577
+ )
2578
+ ] }),
2579
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "grid grid-cols-7 text-[11px] text-muted-foreground mb-1", children: weekdays.map((w, i2) => /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-center py-1", children: w }, i2)) }),
2580
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "grid grid-cols-7 gap-1", children: grid.map(
2581
+ (row, r2) => row.map(({ date, inCurrentMonth }, c) => {
2582
+ const selected = selectedDate && isSameDay(date, selectedDate);
2583
+ const isToday = isSameDay(date, today);
2584
+ const disabled = isDateDisabled(date);
2585
+ let variantName = variant?.day?.main ?? "ghost";
2586
+ if (!inCurrentMonth) variantName = variant?.day?.outside ?? "ghost";
2587
+ if (isToday && !selected) variantName = variant?.day?.today ?? variantName;
2588
+ if (selected) variantName = variant?.day?.selected ?? "default";
2589
+ const label = callbacks?.dayLabel?.(date) ?? date.getDate();
2590
+ return /* @__PURE__ */ jsxRuntime.jsx(
2591
+ "button",
2592
+ {
2593
+ onClick: () => !disabled && onDateSelect?.(date),
2594
+ disabled: disabled || !inCurrentMonth,
2595
+ className: cn2(
2596
+ buttonVariants3({ variant: variantName }),
2597
+ "h-9 w-full p-0 text-sm font-normal",
2598
+ !inCurrentMonth && "opacity-50",
2599
+ selected && "aria-selected:opacity-100"
2600
+ ),
2601
+ "aria-selected": selected,
2602
+ "aria-label": date.toDateString(),
2603
+ children: label
2604
+ },
2605
+ `${r2}-${c}`
2606
+ );
2607
+ })
2608
+ ) })
2609
+ ] });
2610
+ }
2611
+ var TagsInput = ({ value = [], onChange, onClear, error }) => {
2612
+ const [inputValue, setInputValue] = React3.useState("");
2613
+ const addTag = (val) => {
2614
+ const trimmed = val.trim();
2615
+ if (!trimmed) return;
2616
+ if (value.includes(trimmed)) return;
2617
+ onChange([...value, trimmed]);
2618
+ setInputValue("");
2619
+ };
2620
+ const removeTag = (index) => {
2621
+ const newTags = value.filter((_, i2) => i2 !== index);
2622
+ onChange(newTags);
2623
+ };
2624
+ const handleKeyDown = (e2) => {
2625
+ if (e2.key === "Enter" || e2.key === ",") {
2626
+ e2.preventDefault();
2627
+ addTag(inputValue);
2628
+ }
2629
+ if (e2.key === "Backspace" && !inputValue) {
2630
+ removeTag(value.length - 1);
2631
+ }
2632
+ };
2633
+ return /* @__PURE__ */ jsxRuntime.jsxs(
2634
+ "div",
2635
+ {
2636
+ className: `flex items-center border rounded-md px-2 py-1 w-full min-h-[36px] focus-within:ring-2
2637
+ ${error ? "border-red-500 focus-within:ring-red-500" : "border-gray-300 focus-within:ring-sus-green-1"}`,
2638
+ children: [
2639
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-wrap gap-2 flex-1 items-center", children: [
2640
+ value.map((tag, i2) => /* @__PURE__ */ jsxRuntime.jsxs(
2641
+ "span",
2642
+ {
2643
+ className: "flex items-center gap-1 border border-[#41875C] bg-[#f7fcf9] px-2 py-0.5 rounded-2xl text-sm text-black",
2644
+ children: [
2645
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Tag, { className: "w-3 h-3 transform scale-x-[-1]" }),
2646
+ tag,
2647
+ /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", onClick: () => removeTag(i2), className: "hover:text-red-500", children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.X, { className: "w-3 h-3" }) })
2648
+ ]
2649
+ },
2650
+ i2
2651
+ )),
2652
+ /* @__PURE__ */ jsxRuntime.jsx(
2653
+ "input",
2654
+ {
2655
+ type: "text",
2656
+ value: inputValue,
2657
+ onChange: (e2) => setInputValue(e2.target.value),
2658
+ onKeyDown: handleKeyDown,
2659
+ className: "flex-1 border-none outline-none text-sm text-gray-400 placeholder:text-gray-400 border-1"
2660
+ }
2661
+ )
2662
+ ] }),
2663
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Search, { className: "w-4 h-4 text-gray-400 mx-2" }),
2664
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "right-2", children: /* @__PURE__ */ jsxRuntime.jsx(ClearButton, { onClick: onClear }) })
2665
+ ]
2666
+ }
2667
+ );
2668
+ };
2669
+ var millisecondsInWeek = 6048e5;
2670
+ var millisecondsInDay = 864e5;
2671
+ var millisecondsInMinute = 6e4;
2672
+ var millisecondsInHour = 36e5;
2673
+ var constructFromSymbol = Symbol.for("constructDateFrom");
2674
+
2675
+ // node_modules/date-fns/constructFrom.js
2676
+ function constructFrom(date, value) {
2677
+ if (typeof date === "function") return date(value);
2678
+ if (date && typeof date === "object" && constructFromSymbol in date)
2679
+ return date[constructFromSymbol](value);
2680
+ if (date instanceof Date) return new date.constructor(value);
2681
+ return new Date(value);
2682
+ }
2683
+
2684
+ // node_modules/date-fns/toDate.js
2685
+ function toDate(argument, context) {
2686
+ return constructFrom(context || argument, argument);
2687
+ }
2688
+
2689
+ // node_modules/date-fns/_lib/defaultOptions.js
2690
+ var defaultOptions = {};
2691
+ function getDefaultOptions() {
2692
+ return defaultOptions;
2693
+ }
2694
+
2695
+ // node_modules/date-fns/startOfWeek.js
2696
+ function startOfWeek(date, options) {
2697
+ const defaultOptions2 = getDefaultOptions();
2698
+ const weekStartsOn = options?.weekStartsOn ?? options?.locale?.options?.weekStartsOn ?? defaultOptions2.weekStartsOn ?? defaultOptions2.locale?.options?.weekStartsOn ?? 0;
2699
+ const _date = toDate(date, options?.in);
2700
+ const day = _date.getDay();
2701
+ const diff = (day < weekStartsOn ? 7 : 0) + day - weekStartsOn;
2702
+ _date.setDate(_date.getDate() - diff);
2703
+ _date.setHours(0, 0, 0, 0);
2704
+ return _date;
2705
+ }
2706
+
2707
+ // node_modules/date-fns/startOfISOWeek.js
2708
+ function startOfISOWeek(date, options) {
2709
+ return startOfWeek(date, { ...options, weekStartsOn: 1 });
2710
+ }
2711
+
2712
+ // node_modules/date-fns/getISOWeekYear.js
2713
+ function getISOWeekYear(date, options) {
2714
+ const _date = toDate(date, options?.in);
2715
+ const year = _date.getFullYear();
2716
+ const fourthOfJanuaryOfNextYear = constructFrom(_date, 0);
2717
+ fourthOfJanuaryOfNextYear.setFullYear(year + 1, 0, 4);
2718
+ fourthOfJanuaryOfNextYear.setHours(0, 0, 0, 0);
2719
+ const startOfNextYear = startOfISOWeek(fourthOfJanuaryOfNextYear);
2720
+ const fourthOfJanuaryOfThisYear = constructFrom(_date, 0);
2721
+ fourthOfJanuaryOfThisYear.setFullYear(year, 0, 4);
2722
+ fourthOfJanuaryOfThisYear.setHours(0, 0, 0, 0);
2723
+ const startOfThisYear = startOfISOWeek(fourthOfJanuaryOfThisYear);
2724
+ if (_date.getTime() >= startOfNextYear.getTime()) {
2725
+ return year + 1;
2726
+ } else if (_date.getTime() >= startOfThisYear.getTime()) {
2727
+ return year;
2728
+ } else {
2729
+ return year - 1;
2730
+ }
2731
+ }
2732
+
2733
+ // node_modules/date-fns/_lib/getTimezoneOffsetInMilliseconds.js
2734
+ function getTimezoneOffsetInMilliseconds(date) {
2735
+ const _date = toDate(date);
2736
+ const utcDate = new Date(
2737
+ Date.UTC(
2738
+ _date.getFullYear(),
2739
+ _date.getMonth(),
2740
+ _date.getDate(),
2741
+ _date.getHours(),
2742
+ _date.getMinutes(),
2743
+ _date.getSeconds(),
2744
+ _date.getMilliseconds()
2745
+ )
2746
+ );
2747
+ utcDate.setUTCFullYear(_date.getFullYear());
2748
+ return +date - +utcDate;
2749
+ }
2750
+
2751
+ // node_modules/date-fns/_lib/normalizeDates.js
2752
+ function normalizeDates(context, ...dates) {
2753
+ const normalize = constructFrom.bind(
2754
+ null,
2755
+ dates.find((date) => typeof date === "object")
2756
+ );
2757
+ return dates.map(normalize);
2758
+ }
2759
+
2760
+ // node_modules/date-fns/startOfDay.js
2761
+ function startOfDay2(date, options) {
2762
+ const _date = toDate(date, options?.in);
2763
+ _date.setHours(0, 0, 0, 0);
2764
+ return _date;
2765
+ }
2766
+
2767
+ // node_modules/date-fns/differenceInCalendarDays.js
2768
+ function differenceInCalendarDays(laterDate, earlierDate, options) {
2769
+ const [laterDate_, earlierDate_] = normalizeDates(
2770
+ options?.in,
2771
+ laterDate,
2772
+ earlierDate
2773
+ );
2774
+ const laterStartOfDay = startOfDay2(laterDate_);
2775
+ const earlierStartOfDay = startOfDay2(earlierDate_);
2776
+ const laterTimestamp = +laterStartOfDay - getTimezoneOffsetInMilliseconds(laterStartOfDay);
2777
+ const earlierTimestamp = +earlierStartOfDay - getTimezoneOffsetInMilliseconds(earlierStartOfDay);
2778
+ return Math.round((laterTimestamp - earlierTimestamp) / millisecondsInDay);
2779
+ }
2780
+
2781
+ // node_modules/date-fns/startOfISOWeekYear.js
2782
+ function startOfISOWeekYear(date, options) {
2783
+ const year = getISOWeekYear(date, options);
2784
+ const fourthOfJanuary = constructFrom(date, 0);
2785
+ fourthOfJanuary.setFullYear(year, 0, 4);
2786
+ fourthOfJanuary.setHours(0, 0, 0, 0);
2787
+ return startOfISOWeek(fourthOfJanuary);
2788
+ }
2789
+
2790
+ // node_modules/date-fns/isDate.js
2791
+ function isDate(value) {
2792
+ return value instanceof Date || typeof value === "object" && Object.prototype.toString.call(value) === "[object Date]";
2793
+ }
2794
+
2795
+ // node_modules/date-fns/isValid.js
2796
+ function isValid(date) {
2797
+ return !(!isDate(date) && typeof date !== "number" || isNaN(+toDate(date)));
2798
+ }
2799
+
2800
+ // node_modules/date-fns/startOfYear.js
2801
+ function startOfYear(date, options) {
2802
+ const date_ = toDate(date, options?.in);
2803
+ date_.setFullYear(date_.getFullYear(), 0, 1);
2804
+ date_.setHours(0, 0, 0, 0);
2805
+ return date_;
2806
+ }
2807
+
2808
+ // node_modules/date-fns/locale/en-US/_lib/formatDistance.js
2809
+ var formatDistanceLocale = {
2810
+ lessThanXSeconds: {
2811
+ one: "less than a second",
2812
+ other: "less than {{count}} seconds"
2813
+ },
2814
+ xSeconds: {
2815
+ one: "1 second",
2816
+ other: "{{count}} seconds"
2817
+ },
2818
+ halfAMinute: "half a minute",
2819
+ lessThanXMinutes: {
2820
+ one: "less than a minute",
2821
+ other: "less than {{count}} minutes"
2822
+ },
2823
+ xMinutes: {
2824
+ one: "1 minute",
2825
+ other: "{{count}} minutes"
2826
+ },
2827
+ aboutXHours: {
2828
+ one: "about 1 hour",
2829
+ other: "about {{count}} hours"
2830
+ },
2831
+ xHours: {
2832
+ one: "1 hour",
2833
+ other: "{{count}} hours"
2834
+ },
2835
+ xDays: {
2836
+ one: "1 day",
2837
+ other: "{{count}} days"
2838
+ },
2839
+ aboutXWeeks: {
2840
+ one: "about 1 week",
2841
+ other: "about {{count}} weeks"
2842
+ },
2843
+ xWeeks: {
2844
+ one: "1 week",
2845
+ other: "{{count}} weeks"
2846
+ },
2847
+ aboutXMonths: {
2848
+ one: "about 1 month",
2849
+ other: "about {{count}} months"
2850
+ },
2851
+ xMonths: {
2852
+ one: "1 month",
2853
+ other: "{{count}} months"
2854
+ },
2855
+ aboutXYears: {
2856
+ one: "about 1 year",
2857
+ other: "about {{count}} years"
2858
+ },
2859
+ xYears: {
2860
+ one: "1 year",
2861
+ other: "{{count}} years"
2862
+ },
2863
+ overXYears: {
2864
+ one: "over 1 year",
2865
+ other: "over {{count}} years"
2866
+ },
2867
+ almostXYears: {
2868
+ one: "almost 1 year",
2869
+ other: "almost {{count}} years"
2870
+ }
2871
+ };
2872
+ var formatDistance = (token, count, options) => {
2873
+ let result;
2874
+ const tokenValue = formatDistanceLocale[token];
2875
+ if (typeof tokenValue === "string") {
2876
+ result = tokenValue;
2877
+ } else if (count === 1) {
2878
+ result = tokenValue.one;
2879
+ } else {
2880
+ result = tokenValue.other.replace("{{count}}", count.toString());
2881
+ }
2882
+ if (options?.addSuffix) {
2883
+ if (options.comparison && options.comparison > 0) {
2884
+ return "in " + result;
2885
+ } else {
2886
+ return result + " ago";
2887
+ }
2888
+ }
2889
+ return result;
2890
+ };
2891
+
2892
+ // node_modules/date-fns/locale/_lib/buildFormatLongFn.js
2893
+ function buildFormatLongFn(args) {
2894
+ return (options = {}) => {
2895
+ const width = options.width ? String(options.width) : args.defaultWidth;
2896
+ const format2 = args.formats[width] || args.formats[args.defaultWidth];
2897
+ return format2;
2898
+ };
2899
+ }
2900
+
2901
+ // node_modules/date-fns/locale/en-US/_lib/formatLong.js
2902
+ var dateFormats = {
2903
+ full: "EEEE, MMMM do, y",
2904
+ long: "MMMM do, y",
2905
+ medium: "MMM d, y",
2906
+ short: "MM/dd/yyyy"
2907
+ };
2908
+ var timeFormats = {
2909
+ full: "h:mm:ss a zzzz",
2910
+ long: "h:mm:ss a z",
2911
+ medium: "h:mm:ss a",
2912
+ short: "h:mm a"
2913
+ };
2914
+ var dateTimeFormats = {
2915
+ full: "{{date}} 'at' {{time}}",
2916
+ long: "{{date}} 'at' {{time}}",
2917
+ medium: "{{date}}, {{time}}",
2918
+ short: "{{date}}, {{time}}"
2919
+ };
2920
+ var formatLong = {
2921
+ date: buildFormatLongFn({
2922
+ formats: dateFormats,
2923
+ defaultWidth: "full"
2924
+ }),
2925
+ time: buildFormatLongFn({
2926
+ formats: timeFormats,
2927
+ defaultWidth: "full"
2928
+ }),
2929
+ dateTime: buildFormatLongFn({
2930
+ formats: dateTimeFormats,
2931
+ defaultWidth: "full"
2932
+ })
2933
+ };
2934
+
2935
+ // node_modules/date-fns/locale/en-US/_lib/formatRelative.js
2936
+ var formatRelativeLocale = {
2937
+ lastWeek: "'last' eeee 'at' p",
2938
+ yesterday: "'yesterday at' p",
2939
+ today: "'today at' p",
2940
+ tomorrow: "'tomorrow at' p",
2941
+ nextWeek: "eeee 'at' p",
2942
+ other: "P"
2943
+ };
2944
+ var formatRelative = (token, _date, _baseDate, _options) => formatRelativeLocale[token];
2945
+
2946
+ // node_modules/date-fns/locale/_lib/buildLocalizeFn.js
2947
+ function buildLocalizeFn(args) {
2948
+ return (value, options) => {
2949
+ const context = options?.context ? String(options.context) : "standalone";
2950
+ let valuesArray;
2951
+ if (context === "formatting" && args.formattingValues) {
2952
+ const defaultWidth = args.defaultFormattingWidth || args.defaultWidth;
2953
+ const width = options?.width ? String(options.width) : defaultWidth;
2954
+ valuesArray = args.formattingValues[width] || args.formattingValues[defaultWidth];
2955
+ } else {
2956
+ const defaultWidth = args.defaultWidth;
2957
+ const width = options?.width ? String(options.width) : args.defaultWidth;
2958
+ valuesArray = args.values[width] || args.values[defaultWidth];
2959
+ }
2960
+ const index = args.argumentCallback ? args.argumentCallback(value) : value;
2961
+ return valuesArray[index];
2962
+ };
2963
+ }
2964
+
2965
+ // node_modules/date-fns/locale/en-US/_lib/localize.js
2966
+ var eraValues = {
2967
+ narrow: ["B", "A"],
2968
+ abbreviated: ["BC", "AD"],
2969
+ wide: ["Before Christ", "Anno Domini"]
2970
+ };
2971
+ var quarterValues = {
2972
+ narrow: ["1", "2", "3", "4"],
2973
+ abbreviated: ["Q1", "Q2", "Q3", "Q4"],
2974
+ wide: ["1st quarter", "2nd quarter", "3rd quarter", "4th quarter"]
2975
+ };
2976
+ var monthValues = {
2977
+ narrow: ["J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"],
2978
+ abbreviated: [
2979
+ "Jan",
2980
+ "Feb",
2981
+ "Mar",
2982
+ "Apr",
2983
+ "May",
2984
+ "Jun",
2985
+ "Jul",
2986
+ "Aug",
2987
+ "Sep",
2988
+ "Oct",
2989
+ "Nov",
2990
+ "Dec"
2991
+ ],
2992
+ wide: [
2993
+ "January",
2994
+ "February",
2995
+ "March",
2996
+ "April",
2997
+ "May",
2998
+ "June",
2999
+ "July",
3000
+ "August",
3001
+ "September",
3002
+ "October",
3003
+ "November",
3004
+ "December"
3005
+ ]
3006
+ };
3007
+ var dayValues = {
3008
+ narrow: ["S", "M", "T", "W", "T", "F", "S"],
3009
+ short: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"],
3010
+ abbreviated: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
3011
+ wide: [
3012
+ "Sunday",
3013
+ "Monday",
3014
+ "Tuesday",
3015
+ "Wednesday",
3016
+ "Thursday",
3017
+ "Friday",
3018
+ "Saturday"
3019
+ ]
3020
+ };
3021
+ var dayPeriodValues = {
3022
+ narrow: {
3023
+ am: "a",
3024
+ pm: "p",
3025
+ midnight: "mi",
3026
+ noon: "n",
3027
+ morning: "morning",
3028
+ afternoon: "afternoon",
3029
+ evening: "evening",
3030
+ night: "night"
3031
+ },
3032
+ abbreviated: {
3033
+ am: "AM",
3034
+ pm: "PM",
3035
+ midnight: "midnight",
3036
+ noon: "noon",
3037
+ morning: "morning",
3038
+ afternoon: "afternoon",
3039
+ evening: "evening",
3040
+ night: "night"
3041
+ },
3042
+ wide: {
3043
+ am: "a.m.",
3044
+ pm: "p.m.",
3045
+ midnight: "midnight",
3046
+ noon: "noon",
3047
+ morning: "morning",
3048
+ afternoon: "afternoon",
3049
+ evening: "evening",
3050
+ night: "night"
3051
+ }
3052
+ };
3053
+ var formattingDayPeriodValues = {
3054
+ narrow: {
3055
+ am: "a",
3056
+ pm: "p",
3057
+ midnight: "mi",
3058
+ noon: "n",
3059
+ morning: "in the morning",
3060
+ afternoon: "in the afternoon",
3061
+ evening: "in the evening",
3062
+ night: "at night"
3063
+ },
3064
+ abbreviated: {
3065
+ am: "AM",
3066
+ pm: "PM",
3067
+ midnight: "midnight",
3068
+ noon: "noon",
3069
+ morning: "in the morning",
3070
+ afternoon: "in the afternoon",
3071
+ evening: "in the evening",
3072
+ night: "at night"
3073
+ },
3074
+ wide: {
3075
+ am: "a.m.",
3076
+ pm: "p.m.",
3077
+ midnight: "midnight",
3078
+ noon: "noon",
3079
+ morning: "in the morning",
3080
+ afternoon: "in the afternoon",
3081
+ evening: "in the evening",
3082
+ night: "at night"
3083
+ }
3084
+ };
3085
+ var ordinalNumber = (dirtyNumber, _options) => {
3086
+ const number = Number(dirtyNumber);
3087
+ const rem100 = number % 100;
3088
+ if (rem100 > 20 || rem100 < 10) {
3089
+ switch (rem100 % 10) {
3090
+ case 1:
3091
+ return number + "st";
3092
+ case 2:
3093
+ return number + "nd";
3094
+ case 3:
3095
+ return number + "rd";
3096
+ }
3097
+ }
3098
+ return number + "th";
3099
+ };
3100
+ var localize = {
3101
+ ordinalNumber,
3102
+ era: buildLocalizeFn({
3103
+ values: eraValues,
3104
+ defaultWidth: "wide"
3105
+ }),
3106
+ quarter: buildLocalizeFn({
3107
+ values: quarterValues,
3108
+ defaultWidth: "wide",
3109
+ argumentCallback: (quarter) => quarter - 1
3110
+ }),
3111
+ month: buildLocalizeFn({
3112
+ values: monthValues,
3113
+ defaultWidth: "wide"
3114
+ }),
3115
+ day: buildLocalizeFn({
3116
+ values: dayValues,
3117
+ defaultWidth: "wide"
3118
+ }),
3119
+ dayPeriod: buildLocalizeFn({
3120
+ values: dayPeriodValues,
3121
+ defaultWidth: "wide",
3122
+ formattingValues: formattingDayPeriodValues,
3123
+ defaultFormattingWidth: "wide"
3124
+ })
3125
+ };
3126
+
3127
+ // node_modules/date-fns/locale/_lib/buildMatchFn.js
3128
+ function buildMatchFn(args) {
3129
+ return (string, options = {}) => {
3130
+ const width = options.width;
3131
+ const matchPattern = width && args.matchPatterns[width] || args.matchPatterns[args.defaultMatchWidth];
3132
+ const matchResult = string.match(matchPattern);
3133
+ if (!matchResult) {
3134
+ return null;
3135
+ }
3136
+ const matchedString = matchResult[0];
3137
+ const parsePatterns = width && args.parsePatterns[width] || args.parsePatterns[args.defaultParseWidth];
3138
+ const key = Array.isArray(parsePatterns) ? findIndex(parsePatterns, (pattern) => pattern.test(matchedString)) : (
3139
+ // [TODO] -- I challenge you to fix the type
3140
+ findKey(parsePatterns, (pattern) => pattern.test(matchedString))
3141
+ );
3142
+ let value;
3143
+ value = args.valueCallback ? args.valueCallback(key) : key;
3144
+ value = options.valueCallback ? (
3145
+ // [TODO] -- I challenge you to fix the type
3146
+ options.valueCallback(value)
3147
+ ) : value;
3148
+ const rest = string.slice(matchedString.length);
3149
+ return { value, rest };
3150
+ };
3151
+ }
3152
+ function findKey(object, predicate) {
3153
+ for (const key in object) {
3154
+ if (Object.prototype.hasOwnProperty.call(object, key) && predicate(object[key])) {
3155
+ return key;
3156
+ }
3157
+ }
3158
+ return void 0;
3159
+ }
3160
+ function findIndex(array, predicate) {
3161
+ for (let key = 0; key < array.length; key++) {
3162
+ if (predicate(array[key])) {
3163
+ return key;
3164
+ }
3165
+ }
3166
+ return void 0;
3167
+ }
3168
+
3169
+ // node_modules/date-fns/locale/_lib/buildMatchPatternFn.js
3170
+ function buildMatchPatternFn(args) {
3171
+ return (string, options = {}) => {
3172
+ const matchResult = string.match(args.matchPattern);
3173
+ if (!matchResult) return null;
3174
+ const matchedString = matchResult[0];
3175
+ const parseResult = string.match(args.parsePattern);
3176
+ if (!parseResult) return null;
3177
+ let value = args.valueCallback ? args.valueCallback(parseResult[0]) : parseResult[0];
3178
+ value = options.valueCallback ? options.valueCallback(value) : value;
3179
+ const rest = string.slice(matchedString.length);
3180
+ return { value, rest };
3181
+ };
3182
+ }
3183
+
3184
+ // node_modules/date-fns/locale/en-US/_lib/match.js
3185
+ var matchOrdinalNumberPattern = /^(\d+)(th|st|nd|rd)?/i;
3186
+ var parseOrdinalNumberPattern = /\d+/i;
3187
+ var matchEraPatterns = {
3188
+ narrow: /^(b|a)/i,
3189
+ abbreviated: /^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,
3190
+ wide: /^(before christ|before common era|anno domini|common era)/i
3191
+ };
3192
+ var parseEraPatterns = {
3193
+ any: [/^b/i, /^(a|c)/i]
3194
+ };
3195
+ var matchQuarterPatterns = {
3196
+ narrow: /^[1234]/i,
3197
+ abbreviated: /^q[1234]/i,
3198
+ wide: /^[1234](th|st|nd|rd)? quarter/i
3199
+ };
3200
+ var parseQuarterPatterns = {
3201
+ any: [/1/i, /2/i, /3/i, /4/i]
3202
+ };
3203
+ var matchMonthPatterns = {
3204
+ narrow: /^[jfmasond]/i,
3205
+ abbreviated: /^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,
3206
+ wide: /^(january|february|march|april|may|june|july|august|september|october|november|december)/i
3207
+ };
3208
+ var parseMonthPatterns = {
3209
+ narrow: [
3210
+ /^j/i,
3211
+ /^f/i,
3212
+ /^m/i,
3213
+ /^a/i,
3214
+ /^m/i,
3215
+ /^j/i,
3216
+ /^j/i,
3217
+ /^a/i,
3218
+ /^s/i,
3219
+ /^o/i,
3220
+ /^n/i,
3221
+ /^d/i
3222
+ ],
3223
+ any: [
3224
+ /^ja/i,
3225
+ /^f/i,
3226
+ /^mar/i,
3227
+ /^ap/i,
3228
+ /^may/i,
3229
+ /^jun/i,
3230
+ /^jul/i,
3231
+ /^au/i,
3232
+ /^s/i,
3233
+ /^o/i,
3234
+ /^n/i,
3235
+ /^d/i
3236
+ ]
3237
+ };
3238
+ var matchDayPatterns = {
3239
+ narrow: /^[smtwf]/i,
3240
+ short: /^(su|mo|tu|we|th|fr|sa)/i,
3241
+ abbreviated: /^(sun|mon|tue|wed|thu|fri|sat)/i,
3242
+ wide: /^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i
3243
+ };
3244
+ var parseDayPatterns = {
3245
+ narrow: [/^s/i, /^m/i, /^t/i, /^w/i, /^t/i, /^f/i, /^s/i],
3246
+ any: [/^su/i, /^m/i, /^tu/i, /^w/i, /^th/i, /^f/i, /^sa/i]
3247
+ };
3248
+ var matchDayPeriodPatterns = {
3249
+ narrow: /^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,
3250
+ any: /^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i
3251
+ };
3252
+ var parseDayPeriodPatterns = {
3253
+ any: {
3254
+ am: /^a/i,
3255
+ pm: /^p/i,
3256
+ midnight: /^mi/i,
3257
+ noon: /^no/i,
3258
+ morning: /morning/i,
3259
+ afternoon: /afternoon/i,
3260
+ evening: /evening/i,
3261
+ night: /night/i
3262
+ }
3263
+ };
3264
+ var match = {
3265
+ ordinalNumber: buildMatchPatternFn({
3266
+ matchPattern: matchOrdinalNumberPattern,
3267
+ parsePattern: parseOrdinalNumberPattern,
3268
+ valueCallback: (value) => parseInt(value, 10)
3269
+ }),
3270
+ era: buildMatchFn({
3271
+ matchPatterns: matchEraPatterns,
3272
+ defaultMatchWidth: "wide",
3273
+ parsePatterns: parseEraPatterns,
3274
+ defaultParseWidth: "any"
3275
+ }),
3276
+ quarter: buildMatchFn({
3277
+ matchPatterns: matchQuarterPatterns,
3278
+ defaultMatchWidth: "wide",
3279
+ parsePatterns: parseQuarterPatterns,
3280
+ defaultParseWidth: "any",
3281
+ valueCallback: (index) => index + 1
3282
+ }),
3283
+ month: buildMatchFn({
3284
+ matchPatterns: matchMonthPatterns,
3285
+ defaultMatchWidth: "wide",
3286
+ parsePatterns: parseMonthPatterns,
3287
+ defaultParseWidth: "any"
3288
+ }),
3289
+ day: buildMatchFn({
3290
+ matchPatterns: matchDayPatterns,
3291
+ defaultMatchWidth: "wide",
3292
+ parsePatterns: parseDayPatterns,
3293
+ defaultParseWidth: "any"
3294
+ }),
3295
+ dayPeriod: buildMatchFn({
3296
+ matchPatterns: matchDayPeriodPatterns,
3297
+ defaultMatchWidth: "any",
3298
+ parsePatterns: parseDayPeriodPatterns,
3299
+ defaultParseWidth: "any"
3300
+ })
3301
+ };
3302
+
3303
+ // node_modules/date-fns/locale/en-US.js
3304
+ var enUS = {
3305
+ code: "en-US",
3306
+ formatDistance,
3307
+ formatLong,
3308
+ formatRelative,
3309
+ localize,
3310
+ match,
3311
+ options: {
3312
+ weekStartsOn: 0,
3313
+ firstWeekContainsDate: 1
3314
+ }
3315
+ };
3316
+
3317
+ // node_modules/date-fns/getDayOfYear.js
3318
+ function getDayOfYear(date, options) {
3319
+ const _date = toDate(date, options?.in);
3320
+ const diff = differenceInCalendarDays(_date, startOfYear(_date));
3321
+ const dayOfYear = diff + 1;
3322
+ return dayOfYear;
3323
+ }
3324
+
3325
+ // node_modules/date-fns/getISOWeek.js
3326
+ function getISOWeek(date, options) {
3327
+ const _date = toDate(date, options?.in);
3328
+ const diff = +startOfISOWeek(_date) - +startOfISOWeekYear(_date);
3329
+ return Math.round(diff / millisecondsInWeek) + 1;
3330
+ }
3331
+
3332
+ // node_modules/date-fns/getWeekYear.js
3333
+ function getWeekYear(date, options) {
3334
+ const _date = toDate(date, options?.in);
3335
+ const year = _date.getFullYear();
3336
+ const defaultOptions2 = getDefaultOptions();
3337
+ const firstWeekContainsDate = options?.firstWeekContainsDate ?? options?.locale?.options?.firstWeekContainsDate ?? defaultOptions2.firstWeekContainsDate ?? defaultOptions2.locale?.options?.firstWeekContainsDate ?? 1;
3338
+ const firstWeekOfNextYear = constructFrom(options?.in || date, 0);
3339
+ firstWeekOfNextYear.setFullYear(year + 1, 0, firstWeekContainsDate);
3340
+ firstWeekOfNextYear.setHours(0, 0, 0, 0);
3341
+ const startOfNextYear = startOfWeek(firstWeekOfNextYear, options);
3342
+ const firstWeekOfThisYear = constructFrom(options?.in || date, 0);
3343
+ firstWeekOfThisYear.setFullYear(year, 0, firstWeekContainsDate);
3344
+ firstWeekOfThisYear.setHours(0, 0, 0, 0);
3345
+ const startOfThisYear = startOfWeek(firstWeekOfThisYear, options);
3346
+ if (+_date >= +startOfNextYear) {
3347
+ return year + 1;
3348
+ } else if (+_date >= +startOfThisYear) {
3349
+ return year;
3350
+ } else {
3351
+ return year - 1;
3352
+ }
3353
+ }
3354
+
3355
+ // node_modules/date-fns/startOfWeekYear.js
3356
+ function startOfWeekYear(date, options) {
3357
+ const defaultOptions2 = getDefaultOptions();
3358
+ const firstWeekContainsDate = options?.firstWeekContainsDate ?? options?.locale?.options?.firstWeekContainsDate ?? defaultOptions2.firstWeekContainsDate ?? defaultOptions2.locale?.options?.firstWeekContainsDate ?? 1;
3359
+ const year = getWeekYear(date, options);
3360
+ const firstWeek = constructFrom(options?.in || date, 0);
3361
+ firstWeek.setFullYear(year, 0, firstWeekContainsDate);
3362
+ firstWeek.setHours(0, 0, 0, 0);
3363
+ const _date = startOfWeek(firstWeek, options);
3364
+ return _date;
3365
+ }
3366
+
3367
+ // node_modules/date-fns/getWeek.js
3368
+ function getWeek(date, options) {
3369
+ const _date = toDate(date, options?.in);
3370
+ const diff = +startOfWeek(_date, options) - +startOfWeekYear(_date, options);
3371
+ return Math.round(diff / millisecondsInWeek) + 1;
3372
+ }
3373
+
3374
+ // node_modules/date-fns/_lib/addLeadingZeros.js
3375
+ function addLeadingZeros(number, targetLength) {
3376
+ const sign = number < 0 ? "-" : "";
3377
+ const output = Math.abs(number).toString().padStart(targetLength, "0");
3378
+ return sign + output;
3379
+ }
3380
+
3381
+ // node_modules/date-fns/_lib/format/lightFormatters.js
3382
+ var lightFormatters = {
3383
+ // Year
3384
+ y(date, token) {
3385
+ const signedYear = date.getFullYear();
3386
+ const year = signedYear > 0 ? signedYear : 1 - signedYear;
3387
+ return addLeadingZeros(token === "yy" ? year % 100 : year, token.length);
3388
+ },
3389
+ // Month
3390
+ M(date, token) {
3391
+ const month = date.getMonth();
3392
+ return token === "M" ? String(month + 1) : addLeadingZeros(month + 1, 2);
3393
+ },
3394
+ // Day of the month
3395
+ d(date, token) {
3396
+ return addLeadingZeros(date.getDate(), token.length);
3397
+ },
3398
+ // AM or PM
3399
+ a(date, token) {
3400
+ const dayPeriodEnumValue = date.getHours() / 12 >= 1 ? "pm" : "am";
3401
+ switch (token) {
3402
+ case "a":
3403
+ case "aa":
3404
+ return dayPeriodEnumValue.toUpperCase();
3405
+ case "aaa":
3406
+ return dayPeriodEnumValue;
3407
+ case "aaaaa":
3408
+ return dayPeriodEnumValue[0];
3409
+ case "aaaa":
3410
+ default:
3411
+ return dayPeriodEnumValue === "am" ? "a.m." : "p.m.";
3412
+ }
3413
+ },
3414
+ // Hour [1-12]
3415
+ h(date, token) {
3416
+ return addLeadingZeros(date.getHours() % 12 || 12, token.length);
3417
+ },
3418
+ // Hour [0-23]
3419
+ H(date, token) {
3420
+ return addLeadingZeros(date.getHours(), token.length);
3421
+ },
3422
+ // Minute
3423
+ m(date, token) {
3424
+ return addLeadingZeros(date.getMinutes(), token.length);
3425
+ },
3426
+ // Second
3427
+ s(date, token) {
3428
+ return addLeadingZeros(date.getSeconds(), token.length);
3429
+ },
3430
+ // Fraction of second
3431
+ S(date, token) {
3432
+ const numberOfDigits = token.length;
3433
+ const milliseconds = date.getMilliseconds();
3434
+ const fractionalSeconds = Math.trunc(
3435
+ milliseconds * Math.pow(10, numberOfDigits - 3)
3436
+ );
3437
+ return addLeadingZeros(fractionalSeconds, token.length);
3438
+ }
3439
+ };
3440
+
3441
+ // node_modules/date-fns/_lib/format/formatters.js
3442
+ var dayPeriodEnum = {
3443
+ midnight: "midnight",
3444
+ noon: "noon",
3445
+ morning: "morning",
3446
+ afternoon: "afternoon",
3447
+ evening: "evening",
3448
+ night: "night"
3449
+ };
3450
+ var formatters = {
3451
+ // Era
3452
+ G: function(date, token, localize2) {
3453
+ const era = date.getFullYear() > 0 ? 1 : 0;
3454
+ switch (token) {
3455
+ // AD, BC
3456
+ case "G":
3457
+ case "GG":
3458
+ case "GGG":
3459
+ return localize2.era(era, { width: "abbreviated" });
3460
+ // A, B
3461
+ case "GGGGG":
3462
+ return localize2.era(era, { width: "narrow" });
3463
+ // Anno Domini, Before Christ
3464
+ case "GGGG":
3465
+ default:
3466
+ return localize2.era(era, { width: "wide" });
3467
+ }
3468
+ },
3469
+ // Year
3470
+ y: function(date, token, localize2) {
3471
+ if (token === "yo") {
3472
+ const signedYear = date.getFullYear();
3473
+ const year = signedYear > 0 ? signedYear : 1 - signedYear;
3474
+ return localize2.ordinalNumber(year, { unit: "year" });
3475
+ }
3476
+ return lightFormatters.y(date, token);
3477
+ },
3478
+ // Local week-numbering year
3479
+ Y: function(date, token, localize2, options) {
3480
+ const signedWeekYear = getWeekYear(date, options);
3481
+ const weekYear = signedWeekYear > 0 ? signedWeekYear : 1 - signedWeekYear;
3482
+ if (token === "YY") {
3483
+ const twoDigitYear = weekYear % 100;
3484
+ return addLeadingZeros(twoDigitYear, 2);
3485
+ }
3486
+ if (token === "Yo") {
3487
+ return localize2.ordinalNumber(weekYear, { unit: "year" });
3488
+ }
3489
+ return addLeadingZeros(weekYear, token.length);
3490
+ },
3491
+ // ISO week-numbering year
3492
+ R: function(date, token) {
3493
+ const isoWeekYear = getISOWeekYear(date);
3494
+ return addLeadingZeros(isoWeekYear, token.length);
3495
+ },
3496
+ // Extended year. This is a single number designating the year of this calendar system.
3497
+ // The main difference between `y` and `u` localizers are B.C. years:
3498
+ // | Year | `y` | `u` |
3499
+ // |------|-----|-----|
3500
+ // | AC 1 | 1 | 1 |
3501
+ // | BC 1 | 1 | 0 |
3502
+ // | BC 2 | 2 | -1 |
3503
+ // Also `yy` always returns the last two digits of a year,
3504
+ // while `uu` pads single digit years to 2 characters and returns other years unchanged.
3505
+ u: function(date, token) {
3506
+ const year = date.getFullYear();
3507
+ return addLeadingZeros(year, token.length);
3508
+ },
3509
+ // Quarter
3510
+ Q: function(date, token, localize2) {
3511
+ const quarter = Math.ceil((date.getMonth() + 1) / 3);
3512
+ switch (token) {
3513
+ // 1, 2, 3, 4
3514
+ case "Q":
3515
+ return String(quarter);
3516
+ // 01, 02, 03, 04
3517
+ case "QQ":
3518
+ return addLeadingZeros(quarter, 2);
3519
+ // 1st, 2nd, 3rd, 4th
3520
+ case "Qo":
3521
+ return localize2.ordinalNumber(quarter, { unit: "quarter" });
3522
+ // Q1, Q2, Q3, Q4
3523
+ case "QQQ":
3524
+ return localize2.quarter(quarter, {
3525
+ width: "abbreviated",
3526
+ context: "formatting"
3527
+ });
3528
+ // 1, 2, 3, 4 (narrow quarter; could be not numerical)
3529
+ case "QQQQQ":
3530
+ return localize2.quarter(quarter, {
3531
+ width: "narrow",
3532
+ context: "formatting"
3533
+ });
3534
+ // 1st quarter, 2nd quarter, ...
3535
+ case "QQQQ":
3536
+ default:
3537
+ return localize2.quarter(quarter, {
3538
+ width: "wide",
3539
+ context: "formatting"
3540
+ });
3541
+ }
3542
+ },
3543
+ // Stand-alone quarter
3544
+ q: function(date, token, localize2) {
3545
+ const quarter = Math.ceil((date.getMonth() + 1) / 3);
3546
+ switch (token) {
3547
+ // 1, 2, 3, 4
3548
+ case "q":
3549
+ return String(quarter);
3550
+ // 01, 02, 03, 04
3551
+ case "qq":
3552
+ return addLeadingZeros(quarter, 2);
3553
+ // 1st, 2nd, 3rd, 4th
3554
+ case "qo":
3555
+ return localize2.ordinalNumber(quarter, { unit: "quarter" });
3556
+ // Q1, Q2, Q3, Q4
3557
+ case "qqq":
3558
+ return localize2.quarter(quarter, {
3559
+ width: "abbreviated",
3560
+ context: "standalone"
3561
+ });
3562
+ // 1, 2, 3, 4 (narrow quarter; could be not numerical)
3563
+ case "qqqqq":
3564
+ return localize2.quarter(quarter, {
3565
+ width: "narrow",
3566
+ context: "standalone"
3567
+ });
3568
+ // 1st quarter, 2nd quarter, ...
3569
+ case "qqqq":
3570
+ default:
3571
+ return localize2.quarter(quarter, {
3572
+ width: "wide",
3573
+ context: "standalone"
3574
+ });
3575
+ }
3576
+ },
3577
+ // Month
3578
+ M: function(date, token, localize2) {
3579
+ const month = date.getMonth();
3580
+ switch (token) {
3581
+ case "M":
3582
+ case "MM":
3583
+ return lightFormatters.M(date, token);
3584
+ // 1st, 2nd, ..., 12th
3585
+ case "Mo":
3586
+ return localize2.ordinalNumber(month + 1, { unit: "month" });
3587
+ // Jan, Feb, ..., Dec
3588
+ case "MMM":
3589
+ return localize2.month(month, {
3590
+ width: "abbreviated",
3591
+ context: "formatting"
3592
+ });
3593
+ // J, F, ..., D
3594
+ case "MMMMM":
3595
+ return localize2.month(month, {
3596
+ width: "narrow",
3597
+ context: "formatting"
3598
+ });
3599
+ // January, February, ..., December
3600
+ case "MMMM":
3601
+ default:
3602
+ return localize2.month(month, { width: "wide", context: "formatting" });
3603
+ }
3604
+ },
3605
+ // Stand-alone month
3606
+ L: function(date, token, localize2) {
3607
+ const month = date.getMonth();
3608
+ switch (token) {
3609
+ // 1, 2, ..., 12
3610
+ case "L":
3611
+ return String(month + 1);
3612
+ // 01, 02, ..., 12
3613
+ case "LL":
3614
+ return addLeadingZeros(month + 1, 2);
3615
+ // 1st, 2nd, ..., 12th
3616
+ case "Lo":
3617
+ return localize2.ordinalNumber(month + 1, { unit: "month" });
3618
+ // Jan, Feb, ..., Dec
3619
+ case "LLL":
3620
+ return localize2.month(month, {
3621
+ width: "abbreviated",
3622
+ context: "standalone"
3623
+ });
3624
+ // J, F, ..., D
3625
+ case "LLLLL":
3626
+ return localize2.month(month, {
3627
+ width: "narrow",
3628
+ context: "standalone"
3629
+ });
3630
+ // January, February, ..., December
3631
+ case "LLLL":
3632
+ default:
3633
+ return localize2.month(month, { width: "wide", context: "standalone" });
3634
+ }
3635
+ },
3636
+ // Local week of year
3637
+ w: function(date, token, localize2, options) {
3638
+ const week = getWeek(date, options);
3639
+ if (token === "wo") {
3640
+ return localize2.ordinalNumber(week, { unit: "week" });
3641
+ }
3642
+ return addLeadingZeros(week, token.length);
3643
+ },
3644
+ // ISO week of year
3645
+ I: function(date, token, localize2) {
3646
+ const isoWeek = getISOWeek(date);
3647
+ if (token === "Io") {
3648
+ return localize2.ordinalNumber(isoWeek, { unit: "week" });
3649
+ }
3650
+ return addLeadingZeros(isoWeek, token.length);
3651
+ },
3652
+ // Day of the month
3653
+ d: function(date, token, localize2) {
3654
+ if (token === "do") {
3655
+ return localize2.ordinalNumber(date.getDate(), { unit: "date" });
3656
+ }
3657
+ return lightFormatters.d(date, token);
3658
+ },
3659
+ // Day of year
3660
+ D: function(date, token, localize2) {
3661
+ const dayOfYear = getDayOfYear(date);
3662
+ if (token === "Do") {
3663
+ return localize2.ordinalNumber(dayOfYear, { unit: "dayOfYear" });
3664
+ }
3665
+ return addLeadingZeros(dayOfYear, token.length);
3666
+ },
3667
+ // Day of week
3668
+ E: function(date, token, localize2) {
3669
+ const dayOfWeek = date.getDay();
3670
+ switch (token) {
3671
+ // Tue
3672
+ case "E":
3673
+ case "EE":
3674
+ case "EEE":
3675
+ return localize2.day(dayOfWeek, {
3676
+ width: "abbreviated",
3677
+ context: "formatting"
3678
+ });
3679
+ // T
3680
+ case "EEEEE":
3681
+ return localize2.day(dayOfWeek, {
3682
+ width: "narrow",
3683
+ context: "formatting"
3684
+ });
3685
+ // Tu
3686
+ case "EEEEEE":
3687
+ return localize2.day(dayOfWeek, {
3688
+ width: "short",
3689
+ context: "formatting"
3690
+ });
3691
+ // Tuesday
3692
+ case "EEEE":
3693
+ default:
3694
+ return localize2.day(dayOfWeek, {
3695
+ width: "wide",
3696
+ context: "formatting"
3697
+ });
3698
+ }
3699
+ },
3700
+ // Local day of week
3701
+ e: function(date, token, localize2, options) {
3702
+ const dayOfWeek = date.getDay();
3703
+ const localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7;
3704
+ switch (token) {
3705
+ // Numerical value (Nth day of week with current locale or weekStartsOn)
3706
+ case "e":
3707
+ return String(localDayOfWeek);
3708
+ // Padded numerical value
3709
+ case "ee":
3710
+ return addLeadingZeros(localDayOfWeek, 2);
3711
+ // 1st, 2nd, ..., 7th
3712
+ case "eo":
3713
+ return localize2.ordinalNumber(localDayOfWeek, { unit: "day" });
3714
+ case "eee":
3715
+ return localize2.day(dayOfWeek, {
3716
+ width: "abbreviated",
3717
+ context: "formatting"
3718
+ });
3719
+ // T
3720
+ case "eeeee":
3721
+ return localize2.day(dayOfWeek, {
3722
+ width: "narrow",
3723
+ context: "formatting"
3724
+ });
3725
+ // Tu
3726
+ case "eeeeee":
3727
+ return localize2.day(dayOfWeek, {
3728
+ width: "short",
3729
+ context: "formatting"
3730
+ });
3731
+ // Tuesday
3732
+ case "eeee":
3733
+ default:
3734
+ return localize2.day(dayOfWeek, {
3735
+ width: "wide",
3736
+ context: "formatting"
3737
+ });
3738
+ }
3739
+ },
3740
+ // Stand-alone local day of week
3741
+ c: function(date, token, localize2, options) {
3742
+ const dayOfWeek = date.getDay();
3743
+ const localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7;
3744
+ switch (token) {
3745
+ // Numerical value (same as in `e`)
3746
+ case "c":
3747
+ return String(localDayOfWeek);
3748
+ // Padded numerical value
3749
+ case "cc":
3750
+ return addLeadingZeros(localDayOfWeek, token.length);
3751
+ // 1st, 2nd, ..., 7th
3752
+ case "co":
3753
+ return localize2.ordinalNumber(localDayOfWeek, { unit: "day" });
3754
+ case "ccc":
3755
+ return localize2.day(dayOfWeek, {
3756
+ width: "abbreviated",
3757
+ context: "standalone"
3758
+ });
3759
+ // T
3760
+ case "ccccc":
3761
+ return localize2.day(dayOfWeek, {
3762
+ width: "narrow",
3763
+ context: "standalone"
3764
+ });
3765
+ // Tu
3766
+ case "cccccc":
3767
+ return localize2.day(dayOfWeek, {
3768
+ width: "short",
3769
+ context: "standalone"
3770
+ });
3771
+ // Tuesday
3772
+ case "cccc":
3773
+ default:
3774
+ return localize2.day(dayOfWeek, {
3775
+ width: "wide",
3776
+ context: "standalone"
3777
+ });
3778
+ }
3779
+ },
3780
+ // ISO day of week
3781
+ i: function(date, token, localize2) {
3782
+ const dayOfWeek = date.getDay();
3783
+ const isoDayOfWeek = dayOfWeek === 0 ? 7 : dayOfWeek;
3784
+ switch (token) {
3785
+ // 2
3786
+ case "i":
3787
+ return String(isoDayOfWeek);
3788
+ // 02
3789
+ case "ii":
3790
+ return addLeadingZeros(isoDayOfWeek, token.length);
3791
+ // 2nd
3792
+ case "io":
3793
+ return localize2.ordinalNumber(isoDayOfWeek, { unit: "day" });
3794
+ // Tue
3795
+ case "iii":
3796
+ return localize2.day(dayOfWeek, {
3797
+ width: "abbreviated",
3798
+ context: "formatting"
3799
+ });
3800
+ // T
3801
+ case "iiiii":
3802
+ return localize2.day(dayOfWeek, {
3803
+ width: "narrow",
3804
+ context: "formatting"
3805
+ });
3806
+ // Tu
3807
+ case "iiiiii":
3808
+ return localize2.day(dayOfWeek, {
3809
+ width: "short",
3810
+ context: "formatting"
3811
+ });
3812
+ // Tuesday
3813
+ case "iiii":
3814
+ default:
3815
+ return localize2.day(dayOfWeek, {
3816
+ width: "wide",
3817
+ context: "formatting"
3818
+ });
3819
+ }
3820
+ },
3821
+ // AM or PM
3822
+ a: function(date, token, localize2) {
3823
+ const hours = date.getHours();
3824
+ const dayPeriodEnumValue = hours / 12 >= 1 ? "pm" : "am";
3825
+ switch (token) {
3826
+ case "a":
3827
+ case "aa":
3828
+ return localize2.dayPeriod(dayPeriodEnumValue, {
3829
+ width: "abbreviated",
3830
+ context: "formatting"
3831
+ });
3832
+ case "aaa":
3833
+ return localize2.dayPeriod(dayPeriodEnumValue, {
3834
+ width: "abbreviated",
3835
+ context: "formatting"
3836
+ }).toLowerCase();
3837
+ case "aaaaa":
3838
+ return localize2.dayPeriod(dayPeriodEnumValue, {
3839
+ width: "narrow",
3840
+ context: "formatting"
3841
+ });
3842
+ case "aaaa":
3843
+ default:
3844
+ return localize2.dayPeriod(dayPeriodEnumValue, {
3845
+ width: "wide",
3846
+ context: "formatting"
3847
+ });
3848
+ }
3849
+ },
3850
+ // AM, PM, midnight, noon
3851
+ b: function(date, token, localize2) {
3852
+ const hours = date.getHours();
3853
+ let dayPeriodEnumValue;
3854
+ if (hours === 12) {
3855
+ dayPeriodEnumValue = dayPeriodEnum.noon;
3856
+ } else if (hours === 0) {
3857
+ dayPeriodEnumValue = dayPeriodEnum.midnight;
3858
+ } else {
3859
+ dayPeriodEnumValue = hours / 12 >= 1 ? "pm" : "am";
3860
+ }
3861
+ switch (token) {
3862
+ case "b":
3863
+ case "bb":
3864
+ return localize2.dayPeriod(dayPeriodEnumValue, {
3865
+ width: "abbreviated",
3866
+ context: "formatting"
3867
+ });
3868
+ case "bbb":
3869
+ return localize2.dayPeriod(dayPeriodEnumValue, {
3870
+ width: "abbreviated",
3871
+ context: "formatting"
3872
+ }).toLowerCase();
3873
+ case "bbbbb":
3874
+ return localize2.dayPeriod(dayPeriodEnumValue, {
3875
+ width: "narrow",
3876
+ context: "formatting"
3877
+ });
3878
+ case "bbbb":
3879
+ default:
3880
+ return localize2.dayPeriod(dayPeriodEnumValue, {
3881
+ width: "wide",
3882
+ context: "formatting"
3883
+ });
3884
+ }
3885
+ },
3886
+ // in the morning, in the afternoon, in the evening, at night
3887
+ B: function(date, token, localize2) {
3888
+ const hours = date.getHours();
3889
+ let dayPeriodEnumValue;
3890
+ if (hours >= 17) {
3891
+ dayPeriodEnumValue = dayPeriodEnum.evening;
3892
+ } else if (hours >= 12) {
3893
+ dayPeriodEnumValue = dayPeriodEnum.afternoon;
3894
+ } else if (hours >= 4) {
3895
+ dayPeriodEnumValue = dayPeriodEnum.morning;
3896
+ } else {
3897
+ dayPeriodEnumValue = dayPeriodEnum.night;
3898
+ }
3899
+ switch (token) {
3900
+ case "B":
3901
+ case "BB":
3902
+ case "BBB":
3903
+ return localize2.dayPeriod(dayPeriodEnumValue, {
3904
+ width: "abbreviated",
3905
+ context: "formatting"
3906
+ });
3907
+ case "BBBBB":
3908
+ return localize2.dayPeriod(dayPeriodEnumValue, {
3909
+ width: "narrow",
3910
+ context: "formatting"
3911
+ });
3912
+ case "BBBB":
3913
+ default:
3914
+ return localize2.dayPeriod(dayPeriodEnumValue, {
3915
+ width: "wide",
3916
+ context: "formatting"
3917
+ });
3918
+ }
3919
+ },
3920
+ // Hour [1-12]
3921
+ h: function(date, token, localize2) {
3922
+ if (token === "ho") {
3923
+ let hours = date.getHours() % 12;
3924
+ if (hours === 0) hours = 12;
3925
+ return localize2.ordinalNumber(hours, { unit: "hour" });
3926
+ }
3927
+ return lightFormatters.h(date, token);
3928
+ },
3929
+ // Hour [0-23]
3930
+ H: function(date, token, localize2) {
3931
+ if (token === "Ho") {
3932
+ return localize2.ordinalNumber(date.getHours(), { unit: "hour" });
3933
+ }
3934
+ return lightFormatters.H(date, token);
3935
+ },
3936
+ // Hour [0-11]
3937
+ K: function(date, token, localize2) {
3938
+ const hours = date.getHours() % 12;
3939
+ if (token === "Ko") {
3940
+ return localize2.ordinalNumber(hours, { unit: "hour" });
3941
+ }
3942
+ return addLeadingZeros(hours, token.length);
3943
+ },
3944
+ // Hour [1-24]
3945
+ k: function(date, token, localize2) {
3946
+ let hours = date.getHours();
3947
+ if (hours === 0) hours = 24;
3948
+ if (token === "ko") {
3949
+ return localize2.ordinalNumber(hours, { unit: "hour" });
3950
+ }
3951
+ return addLeadingZeros(hours, token.length);
3952
+ },
3953
+ // Minute
3954
+ m: function(date, token, localize2) {
3955
+ if (token === "mo") {
3956
+ return localize2.ordinalNumber(date.getMinutes(), { unit: "minute" });
3957
+ }
3958
+ return lightFormatters.m(date, token);
3959
+ },
3960
+ // Second
3961
+ s: function(date, token, localize2) {
3962
+ if (token === "so") {
3963
+ return localize2.ordinalNumber(date.getSeconds(), { unit: "second" });
3964
+ }
3965
+ return lightFormatters.s(date, token);
3966
+ },
3967
+ // Fraction of second
3968
+ S: function(date, token) {
3969
+ return lightFormatters.S(date, token);
3970
+ },
3971
+ // Timezone (ISO-8601. If offset is 0, output is always `'Z'`)
3972
+ X: function(date, token, _localize) {
3973
+ const timezoneOffset = date.getTimezoneOffset();
3974
+ if (timezoneOffset === 0) {
3975
+ return "Z";
3976
+ }
3977
+ switch (token) {
3978
+ // Hours and optional minutes
3979
+ case "X":
3980
+ return formatTimezoneWithOptionalMinutes(timezoneOffset);
3981
+ // Hours, minutes and optional seconds without `:` delimiter
3982
+ // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
3983
+ // so this token always has the same output as `XX`
3984
+ case "XXXX":
3985
+ case "XX":
3986
+ return formatTimezone(timezoneOffset);
3987
+ // Hours, minutes and optional seconds with `:` delimiter
3988
+ // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
3989
+ // so this token always has the same output as `XXX`
3990
+ case "XXXXX":
3991
+ case "XXX":
3992
+ // Hours and minutes with `:` delimiter
3993
+ default:
3994
+ return formatTimezone(timezoneOffset, ":");
3995
+ }
3996
+ },
3997
+ // Timezone (ISO-8601. If offset is 0, output is `'+00:00'` or equivalent)
3998
+ x: function(date, token, _localize) {
3999
+ const timezoneOffset = date.getTimezoneOffset();
4000
+ switch (token) {
4001
+ // Hours and optional minutes
4002
+ case "x":
4003
+ return formatTimezoneWithOptionalMinutes(timezoneOffset);
4004
+ // Hours, minutes and optional seconds without `:` delimiter
4005
+ // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
4006
+ // so this token always has the same output as `xx`
4007
+ case "xxxx":
4008
+ case "xx":
4009
+ return formatTimezone(timezoneOffset);
4010
+ // Hours, minutes and optional seconds with `:` delimiter
4011
+ // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
4012
+ // so this token always has the same output as `xxx`
4013
+ case "xxxxx":
4014
+ case "xxx":
4015
+ // Hours and minutes with `:` delimiter
4016
+ default:
4017
+ return formatTimezone(timezoneOffset, ":");
4018
+ }
4019
+ },
4020
+ // Timezone (GMT)
4021
+ O: function(date, token, _localize) {
4022
+ const timezoneOffset = date.getTimezoneOffset();
4023
+ switch (token) {
4024
+ // Short
4025
+ case "O":
4026
+ case "OO":
4027
+ case "OOO":
4028
+ return "GMT" + formatTimezoneShort(timezoneOffset, ":");
4029
+ // Long
4030
+ case "OOOO":
4031
+ default:
4032
+ return "GMT" + formatTimezone(timezoneOffset, ":");
4033
+ }
4034
+ },
4035
+ // Timezone (specific non-location)
4036
+ z: function(date, token, _localize) {
4037
+ const timezoneOffset = date.getTimezoneOffset();
4038
+ switch (token) {
4039
+ // Short
4040
+ case "z":
4041
+ case "zz":
4042
+ case "zzz":
4043
+ return "GMT" + formatTimezoneShort(timezoneOffset, ":");
4044
+ // Long
4045
+ case "zzzz":
4046
+ default:
4047
+ return "GMT" + formatTimezone(timezoneOffset, ":");
4048
+ }
4049
+ },
4050
+ // Seconds timestamp
4051
+ t: function(date, token, _localize) {
4052
+ const timestamp = Math.trunc(+date / 1e3);
4053
+ return addLeadingZeros(timestamp, token.length);
4054
+ },
4055
+ // Milliseconds timestamp
4056
+ T: function(date, token, _localize) {
4057
+ return addLeadingZeros(+date, token.length);
4058
+ }
4059
+ };
4060
+ function formatTimezoneShort(offset, delimiter = "") {
4061
+ const sign = offset > 0 ? "-" : "+";
4062
+ const absOffset = Math.abs(offset);
4063
+ const hours = Math.trunc(absOffset / 60);
4064
+ const minutes = absOffset % 60;
4065
+ if (minutes === 0) {
4066
+ return sign + String(hours);
4067
+ }
4068
+ return sign + String(hours) + delimiter + addLeadingZeros(minutes, 2);
4069
+ }
4070
+ function formatTimezoneWithOptionalMinutes(offset, delimiter) {
4071
+ if (offset % 60 === 0) {
4072
+ const sign = offset > 0 ? "-" : "+";
4073
+ return sign + addLeadingZeros(Math.abs(offset) / 60, 2);
4074
+ }
4075
+ return formatTimezone(offset, delimiter);
4076
+ }
4077
+ function formatTimezone(offset, delimiter = "") {
4078
+ const sign = offset > 0 ? "-" : "+";
4079
+ const absOffset = Math.abs(offset);
4080
+ const hours = addLeadingZeros(Math.trunc(absOffset / 60), 2);
4081
+ const minutes = addLeadingZeros(absOffset % 60, 2);
4082
+ return sign + hours + delimiter + minutes;
4083
+ }
4084
+
4085
+ // node_modules/date-fns/_lib/format/longFormatters.js
4086
+ var dateLongFormatter = (pattern, formatLong2) => {
4087
+ switch (pattern) {
4088
+ case "P":
4089
+ return formatLong2.date({ width: "short" });
4090
+ case "PP":
4091
+ return formatLong2.date({ width: "medium" });
4092
+ case "PPP":
4093
+ return formatLong2.date({ width: "long" });
4094
+ case "PPPP":
4095
+ default:
4096
+ return formatLong2.date({ width: "full" });
4097
+ }
4098
+ };
4099
+ var timeLongFormatter = (pattern, formatLong2) => {
4100
+ switch (pattern) {
4101
+ case "p":
4102
+ return formatLong2.time({ width: "short" });
4103
+ case "pp":
4104
+ return formatLong2.time({ width: "medium" });
4105
+ case "ppp":
4106
+ return formatLong2.time({ width: "long" });
4107
+ case "pppp":
4108
+ default:
4109
+ return formatLong2.time({ width: "full" });
4110
+ }
4111
+ };
4112
+ var dateTimeLongFormatter = (pattern, formatLong2) => {
4113
+ const matchResult = pattern.match(/(P+)(p+)?/) || [];
4114
+ const datePattern = matchResult[1];
4115
+ const timePattern = matchResult[2];
4116
+ if (!timePattern) {
4117
+ return dateLongFormatter(pattern, formatLong2);
4118
+ }
4119
+ let dateTimeFormat;
4120
+ switch (datePattern) {
4121
+ case "P":
4122
+ dateTimeFormat = formatLong2.dateTime({ width: "short" });
4123
+ break;
4124
+ case "PP":
4125
+ dateTimeFormat = formatLong2.dateTime({ width: "medium" });
4126
+ break;
4127
+ case "PPP":
4128
+ dateTimeFormat = formatLong2.dateTime({ width: "long" });
4129
+ break;
4130
+ case "PPPP":
4131
+ default:
4132
+ dateTimeFormat = formatLong2.dateTime({ width: "full" });
4133
+ break;
4134
+ }
4135
+ return dateTimeFormat.replace("{{date}}", dateLongFormatter(datePattern, formatLong2)).replace("{{time}}", timeLongFormatter(timePattern, formatLong2));
4136
+ };
4137
+ var longFormatters = {
4138
+ p: timeLongFormatter,
4139
+ P: dateTimeLongFormatter
4140
+ };
4141
+
4142
+ // node_modules/date-fns/_lib/protectedTokens.js
4143
+ var dayOfYearTokenRE = /^D+$/;
4144
+ var weekYearTokenRE = /^Y+$/;
4145
+ var throwTokens = ["D", "DD", "YY", "YYYY"];
4146
+ function isProtectedDayOfYearToken(token) {
4147
+ return dayOfYearTokenRE.test(token);
4148
+ }
4149
+ function isProtectedWeekYearToken(token) {
4150
+ return weekYearTokenRE.test(token);
4151
+ }
4152
+ function warnOrThrowProtectedError(token, format2, input) {
4153
+ const _message = message(token, format2, input);
4154
+ console.warn(_message);
4155
+ if (throwTokens.includes(token)) throw new RangeError(_message);
4156
+ }
4157
+ function message(token, format2, input) {
4158
+ const subject = token[0] === "Y" ? "years" : "days of the month";
4159
+ return `Use \`${token.toLowerCase()}\` instead of \`${token}\` (in \`${format2}\`) for formatting ${subject} to the input \`${input}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`;
4160
+ }
4161
+
4162
+ // node_modules/date-fns/format.js
4163
+ var formattingTokensRegExp = /[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g;
4164
+ var longFormattingTokensRegExp = /P+p+|P+|p+|''|'(''|[^'])+('|$)|./g;
4165
+ var escapedStringRegExp = /^'([^]*?)'?$/;
4166
+ var doubleQuoteRegExp = /''/g;
4167
+ var unescapedLatinCharacterRegExp = /[a-zA-Z]/;
4168
+ function format(date, formatStr, options) {
4169
+ const defaultOptions2 = getDefaultOptions();
4170
+ const locale = defaultOptions2.locale ?? enUS;
4171
+ const firstWeekContainsDate = defaultOptions2.firstWeekContainsDate ?? defaultOptions2.locale?.options?.firstWeekContainsDate ?? 1;
4172
+ const weekStartsOn = defaultOptions2.weekStartsOn ?? defaultOptions2.locale?.options?.weekStartsOn ?? 0;
4173
+ const originalDate = toDate(date, options?.in);
4174
+ if (!isValid(originalDate)) {
4175
+ throw new RangeError("Invalid time value");
4176
+ }
4177
+ let parts = formatStr.match(longFormattingTokensRegExp).map((substring) => {
4178
+ const firstCharacter = substring[0];
4179
+ if (firstCharacter === "p" || firstCharacter === "P") {
4180
+ const longFormatter = longFormatters[firstCharacter];
4181
+ return longFormatter(substring, locale.formatLong);
4182
+ }
4183
+ return substring;
4184
+ }).join("").match(formattingTokensRegExp).map((substring) => {
4185
+ if (substring === "''") {
4186
+ return { isToken: false, value: "'" };
4187
+ }
4188
+ const firstCharacter = substring[0];
4189
+ if (firstCharacter === "'") {
4190
+ return { isToken: false, value: cleanEscapedString(substring) };
4191
+ }
4192
+ if (formatters[firstCharacter]) {
4193
+ return { isToken: true, value: substring };
4194
+ }
4195
+ if (firstCharacter.match(unescapedLatinCharacterRegExp)) {
4196
+ throw new RangeError(
4197
+ "Format string contains an unescaped latin alphabet character `" + firstCharacter + "`"
4198
+ );
4199
+ }
4200
+ return { isToken: false, value: substring };
4201
+ });
4202
+ if (locale.localize.preprocessor) {
4203
+ parts = locale.localize.preprocessor(originalDate, parts);
4204
+ }
4205
+ const formatterOptions = {
4206
+ firstWeekContainsDate,
4207
+ weekStartsOn,
4208
+ locale
4209
+ };
4210
+ return parts.map((part) => {
4211
+ if (!part.isToken) return part.value;
4212
+ const token = part.value;
4213
+ if (isProtectedWeekYearToken(token) || isProtectedDayOfYearToken(token)) {
4214
+ warnOrThrowProtectedError(token, formatStr, String(date));
4215
+ }
4216
+ const formatter = formatters[token[0]];
4217
+ return formatter(originalDate, token, locale.localize, formatterOptions);
4218
+ }).join("");
4219
+ }
4220
+ function cleanEscapedString(input) {
4221
+ const matched = input.match(escapedStringRegExp);
4222
+ if (!matched) {
4223
+ return input;
4224
+ }
4225
+ return matched[1].replace(doubleQuoteRegExp, "'");
4226
+ }
4227
+
4228
+ // node_modules/date-fns/parseISO.js
4229
+ function parseISO(argument, options) {
4230
+ const invalidDate = () => constructFrom(options?.in, NaN);
4231
+ const additionalDigits = 2;
4232
+ const dateStrings = splitDateString(argument);
4233
+ let date;
4234
+ if (dateStrings.date) {
4235
+ const parseYearResult = parseYear(dateStrings.date, additionalDigits);
4236
+ date = parseDate(parseYearResult.restDateString, parseYearResult.year);
4237
+ }
4238
+ if (!date || isNaN(+date)) return invalidDate();
4239
+ const timestamp = +date;
4240
+ let time = 0;
4241
+ let offset;
4242
+ if (dateStrings.time) {
4243
+ time = parseTime(dateStrings.time);
4244
+ if (isNaN(time)) return invalidDate();
4245
+ }
4246
+ if (dateStrings.timezone) {
4247
+ offset = parseTimezone(dateStrings.timezone);
4248
+ if (isNaN(offset)) return invalidDate();
4249
+ } else {
4250
+ const tmpDate = new Date(timestamp + time);
4251
+ const result = toDate(0, options?.in);
4252
+ result.setFullYear(
4253
+ tmpDate.getUTCFullYear(),
4254
+ tmpDate.getUTCMonth(),
4255
+ tmpDate.getUTCDate()
4256
+ );
4257
+ result.setHours(
4258
+ tmpDate.getUTCHours(),
4259
+ tmpDate.getUTCMinutes(),
4260
+ tmpDate.getUTCSeconds(),
4261
+ tmpDate.getUTCMilliseconds()
4262
+ );
4263
+ return result;
4264
+ }
4265
+ return toDate(timestamp + time + offset, options?.in);
4266
+ }
4267
+ var patterns = {
4268
+ dateTimeDelimiter: /[T ]/,
4269
+ timeZoneDelimiter: /[Z ]/i,
4270
+ timezone: /([Z+-].*)$/
4271
+ };
4272
+ var dateRegex = /^-?(?:(\d{3})|(\d{2})(?:-?(\d{2}))?|W(\d{2})(?:-?(\d{1}))?|)$/;
4273
+ var timeRegex = /^(\d{2}(?:[.,]\d*)?)(?::?(\d{2}(?:[.,]\d*)?))?(?::?(\d{2}(?:[.,]\d*)?))?$/;
4274
+ var timezoneRegex = /^([+-])(\d{2})(?::?(\d{2}))?$/;
4275
+ function splitDateString(dateString) {
4276
+ const dateStrings = {};
4277
+ const array = dateString.split(patterns.dateTimeDelimiter);
4278
+ let timeString;
4279
+ if (array.length > 2) {
4280
+ return dateStrings;
4281
+ }
4282
+ if (/:/.test(array[0])) {
4283
+ timeString = array[0];
4284
+ } else {
4285
+ dateStrings.date = array[0];
4286
+ timeString = array[1];
4287
+ if (patterns.timeZoneDelimiter.test(dateStrings.date)) {
4288
+ dateStrings.date = dateString.split(patterns.timeZoneDelimiter)[0];
4289
+ timeString = dateString.substr(
4290
+ dateStrings.date.length,
4291
+ dateString.length
4292
+ );
4293
+ }
4294
+ }
4295
+ if (timeString) {
4296
+ const token = patterns.timezone.exec(timeString);
4297
+ if (token) {
4298
+ dateStrings.time = timeString.replace(token[1], "");
4299
+ dateStrings.timezone = token[1];
4300
+ } else {
4301
+ dateStrings.time = timeString;
4302
+ }
4303
+ }
4304
+ return dateStrings;
4305
+ }
4306
+ function parseYear(dateString, additionalDigits) {
4307
+ const regex = new RegExp(
4308
+ "^(?:(\\d{4}|[+-]\\d{" + (4 + additionalDigits) + "})|(\\d{2}|[+-]\\d{" + (2 + additionalDigits) + "})$)"
4309
+ );
4310
+ const captures = dateString.match(regex);
4311
+ if (!captures) return { year: NaN, restDateString: "" };
4312
+ const year = captures[1] ? parseInt(captures[1]) : null;
4313
+ const century = captures[2] ? parseInt(captures[2]) : null;
4314
+ return {
4315
+ year: century === null ? year : century * 100,
4316
+ restDateString: dateString.slice((captures[1] || captures[2]).length)
4317
+ };
4318
+ }
4319
+ function parseDate(dateString, year) {
4320
+ if (year === null) return /* @__PURE__ */ new Date(NaN);
4321
+ const captures = dateString.match(dateRegex);
4322
+ if (!captures) return /* @__PURE__ */ new Date(NaN);
4323
+ const isWeekDate = !!captures[4];
4324
+ const dayOfYear = parseDateUnit(captures[1]);
4325
+ const month = parseDateUnit(captures[2]) - 1;
4326
+ const day = parseDateUnit(captures[3]);
4327
+ const week = parseDateUnit(captures[4]);
4328
+ const dayOfWeek = parseDateUnit(captures[5]) - 1;
4329
+ if (isWeekDate) {
4330
+ if (!validateWeekDate(year, week, dayOfWeek)) {
4331
+ return /* @__PURE__ */ new Date(NaN);
4332
+ }
4333
+ return dayOfISOWeekYear(year, week, dayOfWeek);
4334
+ } else {
4335
+ const date = /* @__PURE__ */ new Date(0);
4336
+ if (!validateDate(year, month, day) || !validateDayOfYearDate(year, dayOfYear)) {
4337
+ return /* @__PURE__ */ new Date(NaN);
4338
+ }
4339
+ date.setUTCFullYear(year, month, Math.max(dayOfYear, day));
4340
+ return date;
4341
+ }
4342
+ }
4343
+ function parseDateUnit(value) {
4344
+ return value ? parseInt(value) : 1;
4345
+ }
4346
+ function parseTime(timeString) {
4347
+ const captures = timeString.match(timeRegex);
4348
+ if (!captures) return NaN;
4349
+ const hours = parseTimeUnit(captures[1]);
4350
+ const minutes = parseTimeUnit(captures[2]);
4351
+ const seconds = parseTimeUnit(captures[3]);
4352
+ if (!validateTime(hours, minutes, seconds)) {
4353
+ return NaN;
4354
+ }
4355
+ return hours * millisecondsInHour + minutes * millisecondsInMinute + seconds * 1e3;
4356
+ }
4357
+ function parseTimeUnit(value) {
4358
+ return value && parseFloat(value.replace(",", ".")) || 0;
4359
+ }
4360
+ function parseTimezone(timezoneString) {
4361
+ if (timezoneString === "Z") return 0;
4362
+ const captures = timezoneString.match(timezoneRegex);
4363
+ if (!captures) return 0;
4364
+ const sign = captures[1] === "+" ? -1 : 1;
4365
+ const hours = parseInt(captures[2]);
4366
+ const minutes = captures[3] && parseInt(captures[3]) || 0;
4367
+ if (!validateTimezone(hours, minutes)) {
4368
+ return NaN;
4369
+ }
4370
+ return sign * (hours * millisecondsInHour + minutes * millisecondsInMinute);
4371
+ }
4372
+ function dayOfISOWeekYear(isoWeekYear, week, day) {
4373
+ const date = /* @__PURE__ */ new Date(0);
4374
+ date.setUTCFullYear(isoWeekYear, 0, 4);
4375
+ const fourthOfJanuaryDay = date.getUTCDay() || 7;
4376
+ const diff = (week - 1) * 7 + day + 1 - fourthOfJanuaryDay;
4377
+ date.setUTCDate(date.getUTCDate() + diff);
4378
+ return date;
4379
+ }
4380
+ var daysInMonths = [31, null, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
4381
+ function isLeapYearIndex(year) {
4382
+ return year % 400 === 0 || year % 4 === 0 && year % 100 !== 0;
4383
+ }
4384
+ function validateDate(year, month, date) {
4385
+ return month >= 0 && month <= 11 && date >= 1 && date <= (daysInMonths[month] || (isLeapYearIndex(year) ? 29 : 28));
4386
+ }
4387
+ function validateDayOfYearDate(year, dayOfYear) {
4388
+ return dayOfYear >= 1 && dayOfYear <= (isLeapYearIndex(year) ? 366 : 365);
4389
+ }
4390
+ function validateWeekDate(_year, week, day) {
4391
+ return week >= 1 && week <= 53 && day >= 0 && day <= 6;
4392
+ }
4393
+ function validateTime(hours, minutes, seconds) {
4394
+ if (hours === 24) {
4395
+ return minutes === 0 && seconds === 0;
4396
+ }
4397
+ return seconds >= 0 && seconds < 60 && minutes >= 0 && minutes < 60 && hours >= 0 && hours < 25;
4398
+ }
4399
+ function validateTimezone(_hours, minutes) {
4400
+ return minutes >= 0 && minutes <= 59;
4401
+ }
4402
+ function Label4({ className, ...props }) {
4403
+ return /* @__PURE__ */ jsxRuntime.jsx(
4404
+ LabelPrimitive2__namespace.Root,
4405
+ {
4406
+ "data-slot": "label",
4407
+ className: cn2(
4408
+ "flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50",
4409
+ className
4410
+ ),
4411
+ ...props
4412
+ }
4413
+ );
4414
+ }
4415
+ var Form2 = reactHookForm.FormProvider;
4416
+ var FormFieldContext3 = React3__namespace.createContext({});
4417
+ var FormField3 = ({
4418
+ ...props
4419
+ }) => {
4420
+ return /* @__PURE__ */ jsxRuntime.jsx(FormFieldContext3.Provider, { value: { name: props.name }, children: /* @__PURE__ */ jsxRuntime.jsx(reactHookForm.Controller, { ...props }) });
4421
+ };
4422
+ var useFormField3 = () => {
4423
+ const fieldContext = React3__namespace.useContext(FormFieldContext3);
4424
+ const itemContext = React3__namespace.useContext(FormItemContext3);
4425
+ const { getFieldState } = reactHookForm.useFormContext();
4426
+ const formState = reactHookForm.useFormState({ name: fieldContext.name });
4427
+ const fieldState = getFieldState(fieldContext.name, formState);
4428
+ if (!fieldContext) {
4429
+ throw new Error("useFormField should be used within <FormField>");
4430
+ }
4431
+ const { id } = itemContext;
4432
+ return {
4433
+ id,
4434
+ name: fieldContext.name,
4435
+ formItemId: `${id}-form-item`,
4436
+ formDescriptionId: `${id}-form-item-description`,
4437
+ formMessageId: `${id}-form-item-message`,
4438
+ ...fieldState
4439
+ };
4440
+ };
4441
+ var FormItemContext3 = React3__namespace.createContext({});
4442
+ function FormItem3({ className, ...props }) {
4443
+ const id = React3__namespace.useId();
4444
+ return /* @__PURE__ */ jsxRuntime.jsx(FormItemContext3.Provider, { value: { id }, children: /* @__PURE__ */ jsxRuntime.jsx("div", { "data-slot": "form-item", className: cn2("grid gap-2", className), ...props }) });
4445
+ }
4446
+ function FormControl2({ ...props }) {
4447
+ const { error, formItemId, formDescriptionId, formMessageId } = useFormField3();
4448
+ return /* @__PURE__ */ jsxRuntime.jsx(
4449
+ reactSlot.Slot,
4450
+ {
4451
+ "data-slot": "form-control",
4452
+ id: formItemId,
4453
+ "aria-describedby": !error ? `${formDescriptionId}` : `${formDescriptionId} ${formMessageId}`,
4454
+ "aria-invalid": !!error,
4455
+ ...props
4456
+ }
4457
+ );
4458
+ }
4459
+ var AdvanceSearchRow = ({
4460
+ row,
4461
+ isFirst,
4462
+ fields,
4463
+ fieldOptions,
4464
+ operators,
4465
+ onChangeField,
4466
+ onChangeOperator,
4467
+ onAdd,
4468
+ onRemove,
4469
+ onClear
4470
+ }) => {
4471
+ const form = reactHookForm.useFormContext();
4472
+ const { control } = form;
4473
+ const fieldSchema = fields.find((f) => f.name === row.fieldName);
4474
+ const fieldType = fieldSchema?.type ?? "text";
4475
+ React3__namespace.default.useEffect(() => {
4476
+ if (operators && operators.length > 0 && !operators.includes(row.operator)) {
4477
+ onChangeOperator(operators[0]);
4478
+ }
4479
+ }, [operators, row.operator, onChangeOperator]);
4480
+ const isBetween = row.operator === "between";
4481
+ const isCheckbox = fieldType === "checkbox";
4482
+ const isDropdown = fieldType === "dropdown";
4483
+ const isLookup = fieldType === "lookup";
4484
+ const isNumber = fieldType === "number";
4485
+ const isDate2 = fieldType === "date" || fieldType === "datetime";
4486
+ const [openDateValue1, setOpenDateValue1] = React3__namespace.default.useState(false);
4487
+ const [openDateValue2, setOpenDateValue2] = React3__namespace.default.useState(false);
4488
+ const toDateFromISO = (v) => {
4489
+ if (!v) return void 0;
4490
+ try {
4491
+ const d = parseISO(v);
4492
+ return isValid(d) ? d : void 0;
4493
+ } catch {
4494
+ return void 0;
4495
+ }
4496
+ };
4497
+ const getOpeatorLabel = (operator) => {
4498
+ return OPERATOR_LABEL[operator] ?? operator;
4499
+ };
4500
+ const capitalizeFirst = (str) => {
4501
+ return str.charAt(0).toUpperCase() + str.slice(1);
4502
+ };
4503
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col space-y-3 md:flex-row md:items-center md:space-x-1 md:space-y-0 w-full mb-6", children: [
4504
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-full md:w-1/8", children: /* @__PURE__ */ jsxRuntime.jsxs(Select2, { value: row.fieldName, onValueChange: (value) => onChangeField(value), children: [
4505
+ /* @__PURE__ */ jsxRuntime.jsx(SelectTrigger2, { className: "w-full", children: /* @__PURE__ */ jsxRuntime.jsx(SelectValue2, { placeholder: row.fieldName }) }),
4506
+ /* @__PURE__ */ jsxRuntime.jsx(SelectContent2, { children: fieldOptions.map((f) => /* @__PURE__ */ jsxRuntime.jsx(SelectItem2, { value: f.value, children: capitalizeFirst(f.label) }, f.value)) })
4507
+ ] }) }),
4508
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-full md:w-1/8", children: /* @__PURE__ */ jsxRuntime.jsxs(Select2, { value: row.operator, onValueChange: (value) => onChangeOperator(value), children: [
4509
+ /* @__PURE__ */ jsxRuntime.jsx(SelectTrigger2, { className: "w-full", children: /* @__PURE__ */ jsxRuntime.jsx(SelectValue2, { placeholder: row.operator }) }),
4510
+ /* @__PURE__ */ jsxRuntime.jsx(SelectContent2, { children: operators.map((op) => /* @__PURE__ */ jsxRuntime.jsx(SelectItem2, { value: op, children: getOpeatorLabel(op) }, op)) })
4511
+ ] }) }),
4512
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-full md:flex-1", children: !isBetween ? /* @__PURE__ */ jsxRuntime.jsx(
4513
+ FormField3,
4514
+ {
4515
+ control,
4516
+ name: `value_${row.id}`,
4517
+ rules: { required: "This field is required." },
4518
+ render: ({ field, fieldState }) => /* @__PURE__ */ jsxRuntime.jsx(FormItem3, { children: isCheckbox ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "relative w-full", children: [
4519
+ /* @__PURE__ */ jsxRuntime.jsxs(Select2, { value: field.value ?? "", onValueChange: (value) => field.onChange(value), children: [
4520
+ /* @__PURE__ */ jsxRuntime.jsx(FormControl2, { children: /* @__PURE__ */ jsxRuntime.jsx(SelectTrigger2, { className: "w-full pr-8", children: /* @__PURE__ */ jsxRuntime.jsx(SelectValue2, { placeholder: "" }) }) }),
4521
+ /* @__PURE__ */ jsxRuntime.jsxs(SelectContent2, { children: [
4522
+ /* @__PURE__ */ jsxRuntime.jsx(SelectItem2, { value: "true", children: "true" }),
4523
+ /* @__PURE__ */ jsxRuntime.jsx(SelectItem2, { value: "false", children: "false" })
4524
+ ] })
4525
+ ] }),
4526
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "absolute right-3 top-2.5 flex justify-center items-center space-x-1", children: /* @__PURE__ */ jsxRuntime.jsx(ClearButton, { onClick: onClear }) }),
4527
+ fieldState.error && !field.value && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "absolute top-10 text-red-600 text-xs", children: "This field is required." })
4528
+ ] }) : isDropdown && fieldSchema && "options" in fieldSchema ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "relative w-full", children: [
4529
+ /* @__PURE__ */ jsxRuntime.jsxs(Select2, { value: field.value ?? "", onValueChange: (value) => field.onChange(value), children: [
4530
+ /* @__PURE__ */ jsxRuntime.jsx(FormControl2, { children: /* @__PURE__ */ jsxRuntime.jsx(SelectTrigger2, { className: "w-full pr-8", children: /* @__PURE__ */ jsxRuntime.jsx(SelectValue2, { placeholder: "" }) }) }),
4531
+ /* @__PURE__ */ jsxRuntime.jsx(SelectContent2, { children: fieldSchema.options.map((opt) => /* @__PURE__ */ jsxRuntime.jsx(SelectItem2, { value: opt.value, children: opt.label }, opt.value)) })
4532
+ ] }),
4533
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "absolute right-3 top-2.5 flex justify-center items-center space-x-1", children: /* @__PURE__ */ jsxRuntime.jsx(ClearButton, { onClick: onClear }) }),
4534
+ fieldState.error && !field.value && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "absolute top-10 text-red-600 text-xs", children: "This field is required." })
4535
+ ] }) : isDate2 ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "relative", children: [
4536
+ /* @__PURE__ */ jsxRuntime.jsxs(Popover, { open: openDateValue1, onOpenChange: setOpenDateValue1, children: [
4537
+ /* @__PURE__ */ jsxRuntime.jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(FormControl2, { children: /* @__PURE__ */ jsxRuntime.jsxs(
4538
+ Button3,
4539
+ {
4540
+ type: "button",
4541
+ variant: "outline",
4542
+ className: cn2(
4543
+ "w-full justify-start text-left font-normal",
4544
+ !field.value && "text-muted-foreground"
4545
+ ),
4546
+ onClick: () => setOpenDateValue1((v) => !v),
4547
+ children: [
4548
+ field.value ? format(toDateFromISO(field.value), "dd/MM/yyyy") : "DD/MM/YYYY",
4549
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "absolute right-3 top-2.5 flex justify-center items-center space-x-1", children: [
4550
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.CalendarIcon, { className: "w-4 h-4 text-[#c0c0c0]" }),
4551
+ /* @__PURE__ */ jsxRuntime.jsx(ClearButton, { onClick: onClear })
4552
+ ] })
4553
+ ]
4554
+ }
4555
+ ) }) }),
4556
+ /* @__PURE__ */ jsxRuntime.jsx(PopoverContent, { className: "w-auto p-0", align: "start", children: /* @__PURE__ */ jsxRuntime.jsx(
4557
+ DatePicker,
4558
+ {
4559
+ variant: { day: { selected: "outline" } },
4560
+ selectedDate: toDateFromISO(field.value),
4561
+ onDateSelect: (d) => {
4562
+ field.onChange(d ? format(d, "yyyy-MM-dd") : void 0);
4563
+ if (d) setOpenDateValue1(false);
4564
+ }
4565
+ }
4566
+ ) })
4567
+ ] }),
4568
+ fieldState.error && !field.value && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "absolute left-0 top-10 text-red-600 text-xs", children: "This field is required." })
4569
+ ] }) : isNumber ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "relative flex items-center", children: [
4570
+ /* @__PURE__ */ jsxRuntime.jsx(FormControl2, { children: /* @__PURE__ */ jsxRuntime.jsx(
4571
+ Input,
4572
+ {
4573
+ ...field,
4574
+ type: "number",
4575
+ value: field.value ?? "",
4576
+ autoComplete: "off",
4577
+ inputMode: "numeric",
4578
+ className: "focus-visible:ring-0 focus-visible:ring-offset-0 focus:outline-none focus:border-sus-green-1 pr-8"
4579
+ }
4580
+ ) }),
4581
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "absolute right-3 top-2.5 flex justify-center items-center space-x-1", children: /* @__PURE__ */ jsxRuntime.jsx(ClearButton, { onClick: onClear }) }),
4582
+ fieldState.error && !field.value && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "absolute top-10 text-red-600 text-xs", children: "This field is required." })
4583
+ ] }) : isLookup ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "relative", children: [
4584
+ /* @__PURE__ */ jsxRuntime.jsx(FormControl2, { children: /* @__PURE__ */ jsxRuntime.jsx(
4585
+ TagsInput,
4586
+ {
4587
+ value: Array.isArray(field.value) ? field.value : [],
4588
+ onChange: field.onChange,
4589
+ onClear,
4590
+ error: !!fieldState.error
4591
+ }
4592
+ ) }),
4593
+ fieldState.error && (!field.value || field.value.length === 0) && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "absolute top-10 text-red-600 text-xs", children: "This field is required." })
4594
+ ] }) : /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "relative flex items-center", children: [
4595
+ /* @__PURE__ */ jsxRuntime.jsx(FormControl2, { children: /* @__PURE__ */ jsxRuntime.jsx(
4596
+ Input,
4597
+ {
4598
+ ...field,
4599
+ value: field.value ?? "",
4600
+ autoComplete: "off",
4601
+ inputMode: "text",
4602
+ className: "focus-visible:ring-0 focus-visible:ring-offset-0 focus:outline-none focus:border-sus-green-1"
4603
+ }
4604
+ ) }),
4605
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "absolute right-3 top-2.5 flex justify-center items-center space-x-1", children: [
4606
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Search, { className: "w-4 h-4 text-[#c0c0c0]" }),
4607
+ /* @__PURE__ */ jsxRuntime.jsx(ClearButton, { onClick: onClear })
4608
+ ] }),
4609
+ fieldState.error && !field.value && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "absolute top-10 text-red-600 text-xs", children: "This field is required." })
4610
+ ] }) })
4611
+ }
4612
+ ) : /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col md:flex-row md:items-center md:space-x-2 md:space-y-0 space-y-3", children: [
4613
+ /* @__PURE__ */ jsxRuntime.jsx(
4614
+ FormField3,
4615
+ {
4616
+ control,
4617
+ name: `value_${row.id}`,
4618
+ rules: { required: "This field is required." },
4619
+ render: ({ field, fieldState }) => /* @__PURE__ */ jsxRuntime.jsx(FormItem3, { className: "relative w-full md:w-1/2", children: /* @__PURE__ */ jsxRuntime.jsxs(Popover, { open: openDateValue1, onOpenChange: setOpenDateValue1, children: [
4620
+ /* @__PURE__ */ jsxRuntime.jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(FormControl2, { children: /* @__PURE__ */ jsxRuntime.jsxs(
4621
+ Button3,
4622
+ {
4623
+ type: "button",
4624
+ variant: "outline",
4625
+ className: cn2(
4626
+ "w-full justify-start text-left font-normal",
4627
+ !field.value && "text-muted-foreground"
4628
+ ),
4629
+ onClick: () => setOpenDateValue1((v) => !v),
4630
+ children: [
4631
+ field.value ? format(toDateFromISO(field.value), "dd/MM/yyyy") : "DD/MM/YYYY",
4632
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "absolute right-3 top-2.5 flex justify-center items-center space-x-1", children: [
4633
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.CalendarIcon, { className: "w-4 h-4 text-[#c0c0c0]" }),
4634
+ /* @__PURE__ */ jsxRuntime.jsx(ClearButton, { onClick: onClear })
4635
+ ] }),
4636
+ fieldState.error && !field.value && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "absolute left-0 top-10 text-red-600 text-xs", children: "This field is required." })
4637
+ ]
4638
+ }
4639
+ ) }) }),
4640
+ /* @__PURE__ */ jsxRuntime.jsx(PopoverContent, { className: "w-auto p-0", align: "start", children: /* @__PURE__ */ jsxRuntime.jsx(
4641
+ DatePicker,
4642
+ {
4643
+ selectedDate: toDateFromISO(field.value),
4644
+ onDateSelect: (d) => {
4645
+ field.onChange(d ? format(d, "yyyy-MM-dd") : void 0);
4646
+ if (d) setOpenDateValue1(false);
4647
+ }
4648
+ }
4649
+ ) })
4650
+ ] }) })
4651
+ }
4652
+ ),
4653
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-black font-bold text-center", children: "To" }),
4654
+ /* @__PURE__ */ jsxRuntime.jsx(
4655
+ FormField3,
4656
+ {
4657
+ control,
4658
+ name: `value2_${row.id}`,
4659
+ rules: { required: "This field is required." },
4660
+ render: ({ field, fieldState }) => /* @__PURE__ */ jsxRuntime.jsx(FormItem3, { className: "relative w-full md:w-1/2", children: /* @__PURE__ */ jsxRuntime.jsxs(Popover, { open: openDateValue2, onOpenChange: setOpenDateValue2, children: [
4661
+ /* @__PURE__ */ jsxRuntime.jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(FormControl2, { children: /* @__PURE__ */ jsxRuntime.jsxs(
4662
+ Button3,
4663
+ {
4664
+ type: "button",
4665
+ variant: "outline",
4666
+ className: cn2(
4667
+ "w-full justify-start text-left font-normal",
4668
+ !field.value && "text-muted-foreground"
4669
+ ),
4670
+ onClick: () => setOpenDateValue2((v) => !v),
4671
+ children: [
4672
+ field.value ? format(toDateFromISO(field.value), "dd/MM/yyyy") : "DD/MM/YYYY",
4673
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "absolute right-3 top-2.5 flex justify-center items-center space-x-1", children: [
4674
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.CalendarIcon, { className: "w-4 h-4 text-[#c0c0c0]" }),
4675
+ /* @__PURE__ */ jsxRuntime.jsx(ClearButton, { onClick: onClear })
4676
+ ] }),
4677
+ fieldState.error && !field.value && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "absolute left-0 top-10 text-red-600 text-xs", children: "This field is required." })
4678
+ ]
4679
+ }
4680
+ ) }) }),
4681
+ /* @__PURE__ */ jsxRuntime.jsx(PopoverContent, { className: "w-auto p-0", align: "start", children: /* @__PURE__ */ jsxRuntime.jsx(
4682
+ DatePicker,
4683
+ {
4684
+ selectedDate: toDateFromISO(field.value),
4685
+ onDateSelect: (d) => {
4686
+ field.onChange(d ? format(d, "yyyy-MM-dd") : void 0);
4687
+ if (d) setOpenDateValue2(false);
4688
+ }
4689
+ }
4690
+ ) })
4691
+ ] }) })
4692
+ }
4693
+ )
4694
+ ] }) }),
4695
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center justify-center", children: isFirst ? /* @__PURE__ */ jsxRuntime.jsx(
4696
+ Button3,
4697
+ {
4698
+ type: "button",
4699
+ onClick: onAdd,
4700
+ className: "circle-btn bg-[#41875C] border border-[#41875C] text-white hover:bg-[#3a6f4e] transition duration-150",
4701
+ "aria-label": "Add row",
4702
+ title: "Add condition",
4703
+ children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Plus, { className: "w-3 h-3 stroke-[2]" })
4704
+ }
4705
+ ) : /* @__PURE__ */ jsxRuntime.jsx(
4706
+ Button3,
4707
+ {
4708
+ type: "button",
4709
+ onClick: onRemove,
4710
+ className: "circle-btn bg-white border-2 border-[#82b495] text-[#82b495] hover:bg-[#82b495] hover:text-white transition duration-150",
4711
+ "aria-label": "Remove row",
4712
+ title: "Remove condition",
4713
+ children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Minus, { className: "w-3 h-3 stroke-[2]" })
4714
+ }
4715
+ ) })
4716
+ ] });
4717
+ };
4718
+ var AdvanceSearch = ({
4719
+ fields,
4720
+ portalId,
4721
+ iconColor = "#ffffff",
4722
+ limitRows = 4,
4723
+ onSearch
4724
+ }) => {
4725
+ const fieldsData = React3.useMemo(() => fields || [], [fields]);
4726
+ const {
4727
+ rows,
4728
+ addRow,
4729
+ removeRow,
4730
+ clearRow,
4731
+ clearAllRow,
4732
+ changeField,
4733
+ changeOperator,
4734
+ operatorsForField,
4735
+ fieldOptions
4736
+ } = useAdvanceSearch({ fields: fieldsData, limitRows });
4737
+ const form = reactHookForm.useForm({
4738
+ mode: "onSubmit",
4739
+ reValidateMode: "onSubmit",
4740
+ defaultValues: {}
4741
+ });
4742
+ const { handleSubmit, unregister, resetField, getValues, setValue } = form;
4743
+ const onSubmit = React3.useCallback(() => {
4744
+ const currentValues = getValues();
4745
+ const param = {
4746
+ AND: rows.map((r2) => {
4747
+ const val1 = currentValues[`value_${r2.id}`];
4748
+ const val2 = currentValues[`value2_${r2.id}`];
4749
+ if (r2.operator === "between") {
4750
+ if (!val1 || !val2) return null;
4751
+ return {
4752
+ [r2.fieldName]: {
4753
+ gte: val1,
4754
+ lte: val2
4755
+ }
4756
+ };
4757
+ }
4758
+ if (!val1) return null;
4759
+ switch (r2.operator) {
4760
+ case "contains":
4761
+ return { [r2.fieldName]: { contains: val1 } };
4762
+ case "beginsWith":
4763
+ return { [r2.fieldName]: { startsWith: val1 } };
4764
+ case "endsWith":
4765
+ return { [r2.fieldName]: { endsWith: val1 } };
4766
+ case "notEquals":
4767
+ return { [r2.fieldName]: { not: val1 } };
4768
+ case "gt":
4769
+ return { [r2.fieldName]: { gt: val1 } };
4770
+ case "gte":
4771
+ return { [r2.fieldName]: { gte: val1 } };
4772
+ case "lt":
4773
+ return { [r2.fieldName]: { lt: val1 } };
4774
+ case "lte":
4775
+ return { [r2.fieldName]: { lte: val1 } };
4776
+ case "is":
4777
+ return { [r2.fieldName]: val1 };
4778
+ case "isNot":
4779
+ return { [r2.fieldName]: { not: val1 } };
4780
+ case "notContains":
4781
+ return { [r2.fieldName]: { not: { contains: val1 } } };
4782
+ case "notBeginsWith":
4783
+ return { [r2.fieldName]: { not: { startsWith: val1 } } };
4784
+ case "notEndsWith":
4785
+ return { [r2.fieldName]: { not: { endsWith: val1 } } };
4786
+ case "containsAny":
4787
+ return { [r2.fieldName]: { hasSome: String(val1).split(",") } };
4788
+ case "containsAll":
4789
+ return { [r2.fieldName]: { hasEvery: String(val1).split(",") } };
4790
+ case "containsOnly":
4791
+ return { [r2.fieldName]: { equals: String(val1).split(",") } };
4792
+ default:
4793
+ return { [r2.fieldName]: val1 };
4794
+ }
4795
+ }).filter(Boolean)
4796
+ };
4797
+ if (onSearch) {
4798
+ onSearch(param);
4799
+ }
4800
+ }, [getValues, rows, onSearch]);
4801
+ return /* @__PURE__ */ jsxRuntime.jsx(
4802
+ ExpandCollapse_default,
4803
+ {
4804
+ title: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Search, { className: "w-5 h-5", style: { color: iconColor } }),
4805
+ portalId,
4806
+ children: /* @__PURE__ */ jsxRuntime.jsx(Form2, { ...form, children: /* @__PURE__ */ jsxRuntime.jsx("form", { onSubmit: handleSubmit(onSubmit), className: "w-[70%] flex justify-center mx-auto", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded w-full md:w-3/4", children: [
4807
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex justify-between items-center mb-2", children: /* @__PURE__ */ jsxRuntime.jsx(Label4, { className: "font-bold text-black", children: "Select field" }) }),
4808
+ rows.map((row, idx) => /* @__PURE__ */ jsxRuntime.jsx(
4809
+ AdvanceSearchRow,
4810
+ {
4811
+ row,
4812
+ isFirst: idx === 0,
4813
+ fields: fieldsData,
4814
+ fieldOptions,
4815
+ operators: operatorsForField(row.fieldName),
4816
+ onChangeField: (f) => {
4817
+ changeField(row.id, f);
4818
+ setValue(`value_${row.id}`, void 0);
4819
+ setValue(`value2_${row.id}`, void 0);
4820
+ },
4821
+ onChangeOperator: (op) => {
4822
+ changeOperator(row.id, op);
4823
+ setValue(`value_${row.id}`, void 0);
4824
+ setValue(`value2_${row.id}`, void 0);
4825
+ },
4826
+ onAdd: addRow,
4827
+ onRemove: () => {
4828
+ removeRow(row.id);
4829
+ unregister(`value_${row.id}`);
4830
+ unregister(`value2_${row.id}`);
4831
+ },
4832
+ onClear: () => {
4833
+ clearRow(row.id);
4834
+ resetField(`value_${row.id}`);
4835
+ resetField(`value2_${row.id}`);
4836
+ }
4837
+ },
4838
+ row.id
4839
+ )),
4840
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col-reverse md:flex-row md:justify-end gap-2 mt-4 pr-7", children: [
4841
+ /* @__PURE__ */ jsxRuntime.jsx(
4842
+ Button3,
4843
+ {
4844
+ type: "button",
4845
+ className: "w-full md:w-auto md:min-w-[100px] bg-[#8b8b8b]",
4846
+ onClick: () => {
4847
+ clearAllRow();
4848
+ Object.keys(getValues()).forEach((k) => resetField(k));
4849
+ },
4850
+ children: "Clear Search"
4851
+ }
4852
+ ),
4853
+ /* @__PURE__ */ jsxRuntime.jsx(
4854
+ Button3,
4855
+ {
4856
+ type: "submit",
4857
+ className: "w-full md:w-auto md:min-w-[100px] bg-[#379a2a] hover:bg-[#3a6f4e]",
4858
+ onClick: onSubmit,
4859
+ children: "Search"
4860
+ }
4861
+ )
4862
+ ] })
4863
+ ] }) }) })
4864
+ }
4865
+ );
4866
+ };
4867
+ var AdvanceSearch_default = AdvanceSearch;
4868
+
4869
+ exports.AdvanceSearch = AdvanceSearch_default;
4870
+ exports.Button = Button;
4871
+ exports.DataTable = DataTable_default;
4872
+ exports.FormErrorMessage = FormErrorMessage;
4873
+ exports.FormField = FormField;
4874
+ exports.FormFieldContext = FormFieldContext;
4875
+ exports.FormItem = FormItem;
4876
+ exports.FormItemContext = FormItemContext;
4877
+ exports.FormLabel = FormLabel;
4878
+ exports.GridSettingsModal = GridSettingsModal_default;
4879
+ exports.HeaderCell = HeaderCell_default;
4880
+ exports.Navbar = navbar_default;
4881
+ exports.NumberInput = NumberInput;
4882
+ exports.TextInput = TextInput;
4883
+ exports.booleanToSelectValue = booleanToSelectValue;
4884
+ exports.buttonVariants = buttonVariants;
4885
+ exports.cn = cn;
4886
+ exports.compareAlphanumeric = compareAlphanumeric;
4887
+ exports.getColumnIdFromTable = getColumnIdFromTable;
4888
+ exports.renderContentSlot = renderContentSlot;
4889
+ exports.selectValueToBoolean = selectValueToBoolean;
4890
+ exports.useFormField = useFormField;
4891
+ exports.useGridSettingsStore = useGridSettingsStore;
4892
+ exports.useHover = useHover_default;
4893
+ exports.useIntersectionObserver = useIntersectionObserver_default;
4894
+ exports.useMediaQuery = useMediaQuery_default;
4895
+ exports.useScreenSize = useScreenSize_default;
4896
+ //# sourceMappingURL=index.js.map
4897
+ //# sourceMappingURL=index.js.map