jett.admin.npmpackage 2.0.15 → 2.0.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. package/dist/index.css +213 -0
  2. package/dist/index.js +1854 -1580
  3. package/dist/index.mjs +1820 -1546
  4. package/package.json +2 -1
package/dist/index.js CHANGED
@@ -1,1580 +1,1854 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __export = (target, all) => {
8
- for (var name in all)
9
- __defProp(target, name, { get: all[name], enumerable: true });
10
- };
11
- var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from))
14
- if (!__hasOwnProp.call(to, key) && key !== except)
15
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
- }
17
- return to;
18
- };
19
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
- // If the importer is in node compatibility mode or this is not an ESM
21
- // file that has been converted to a CommonJS file using a Babel-
22
- // compatible transform (i.e. "__esModule" has not been set), then set
23
- // "default" to the CommonJS "module.exports" for node compatibility.
24
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
- mod
26
- ));
27
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
-
29
- // src/index.js
30
- var index_exports = {};
31
- __export(index_exports, {
32
- AppSideBar: () => AppSideBar,
33
- Chip: () => Chip,
34
- CustomAutocomplete: () => CustomAutocomplete,
35
- CustomButton: () => CustomButton,
36
- CustomCheckbox: () => CustomCheckbox,
37
- CustomInput: () => CustomInput,
38
- CustomSearch: () => CustomSearch,
39
- CustomSelect: () => CustomSelect,
40
- CustomSwitch: () => CustomSwitch,
41
- CustomTable: () => CustomTable,
42
- CustomTextarea: () => CustomTextarea,
43
- CustomUpload: () => CustomUpload,
44
- Pagination: () => Pagination,
45
- ProgressBar: () => ProgressBar,
46
- RightSheet: () => RightSheet
47
- });
48
- module.exports = __toCommonJS(index_exports);
49
-
50
- // src/utils/cn.ts
51
- var import_clsx = require("clsx");
52
- var import_tailwind_merge = require("tailwind-merge");
53
- function cn(...inputs) {
54
- return (0, import_tailwind_merge.twMerge)((0, import_clsx.clsx)(inputs));
55
- }
56
-
57
- // src/Button.jsx
58
- var import_react = __toESM(require("react"));
59
- var variantStyles = {
60
- PRIMARY: "bg-white dark:bg-[#18181b] dark:text-white",
61
- SECONDARY: "bg-primary text-white dark:text-white",
62
- DEFAULT: "bg-white text-black dark:text-white",
63
- DANGER: "bg-[#ef4444] text-white dark:text-white"
64
- };
65
- var CustomButton = ({
66
- id = "button",
67
- variant = "DEFAULT",
68
- children,
69
- className,
70
- onClick,
71
- disabled = false,
72
- icon
73
- }) => {
74
- return /* @__PURE__ */ import_react.default.createElement(
75
- "div",
76
- {
77
- className: cn(
78
- `cursor-pointer flex items-center py-2 px-3 min-h-10 justify-center border rounded-[6px] border-[#e5e5e5] dark:border-[#303036] ${variant == "DANGER" ? "bg-[#ef4444]" : "dark:bg-[#1d1d20]"} gap-2`,
79
- variantStyles[variant],
80
- className
81
- ),
82
- onClick,
83
- id: `${id}-div-1`
84
- },
85
- icon && /* @__PURE__ */ import_react.default.createElement("div", { id: `${id}-div-2` }, icon),
86
- children
87
- );
88
- };
89
-
90
- // src/inputs/Autocomplete.jsx
91
- var import_react2 = __toESM(require("react"));
92
- var import_lucide_react = require("lucide-react");
93
- var CustomAutocomplete = ({
94
- id = "autocomplete",
95
- label,
96
- value,
97
- onChange,
98
- options,
99
- placeholder = "Search & select...",
100
- isRequired = false,
101
- error,
102
- heading,
103
- disabled = false
104
- }) => {
105
- const [open, setOpen] = (0, import_react2.useState)(false);
106
- const [search, setSearch] = (0, import_react2.useState)("");
107
- const wrapperRef = (0, import_react2.useRef)(null);
108
- const selectedOptions = options.filter((opt) => value.includes(opt.value));
109
- const handleBlur = (e) => {
110
- var _a;
111
- if (!((_a = wrapperRef.current) == null ? void 0 : _a.contains(e.relatedTarget))) {
112
- setOpen(false);
113
- }
114
- };
115
- const filteredOptions = options.filter(
116
- (opt) => opt.label.toLowerCase().includes(search.toLowerCase())
117
- );
118
- const toggleValue = (val) => {
119
- if (value.includes(val)) {
120
- onChange(value.filter((v) => v !== val));
121
- } else {
122
- onChange([...value, val]);
123
- }
124
- };
125
- return /* @__PURE__ */ import_react2.default.createElement(
126
- "div",
127
- {
128
- className: "flex flex-col w-full relative dark:bg-[#18181b] dark:text-white",
129
- ref: wrapperRef,
130
- tabIndex: disabled ? -1 : 0,
131
- onBlur: handleBlur,
132
- id: `${id}-div-1`
133
- },
134
- heading && /* @__PURE__ */ import_react2.default.createElement("h3", { className: "text-lg font-semibold leading-6 mb-1", id: `${id}-h3-1` }, heading),
135
- label && /* @__PURE__ */ import_react2.default.createElement(
136
- "label",
137
- {
138
- className: `font-[500] text-sm leading-5 mb-1 ${heading ? "text-[#737373]" : "text-black dark:text-white"}`,
139
- id: `${id}-label-1`
140
- },
141
- label,
142
- " ",
143
- isRequired && /* @__PURE__ */ import_react2.default.createElement("span", { className: "text-red-500", id: `${id}-span-1` }, "*")
144
- ),
145
- /* @__PURE__ */ import_react2.default.createElement(
146
- "div",
147
- {
148
- onClick: () => {
149
- if (!disabled) setOpen((prev) => !prev);
150
- },
151
- className: `flex justify-between items-center flex-wrap gap-1 rounded-md px-3 py-2 text-sm transition border dark:border-[#303036] h-auto min-h-10 dark:bg-[#18181b] dark:text-white
152
- ${disabled ? "bg-gray-100 cursor-not-allowed text-gray-400" : "cursor-text"}
153
- ${error ? "border-red-500 bg-red-50" : "bg-white border-[hsl(0_0%_89.8%)] hover:border-gray-400 dark:bg-[#18181b] dark:text-white"}
154
- `,
155
- id: `${id}-div-2`
156
- },
157
- /* @__PURE__ */ import_react2.default.createElement("div", { className: "flex flex-wrap gap-1 flex-1", id: `${id}-div-3` }, selectedOptions.length > 0 ? selectedOptions.map((opt) => /* @__PURE__ */ import_react2.default.createElement(
158
- "span",
159
- {
160
- key: opt.value,
161
- className: "bg-[#F7FAFC] dark:bg-[#303036] border border-gray-300 px-2 dark:text-white py-0.5 rounded text-xs flex items-center gap-1",
162
- id: `${id}-span-2`
163
- },
164
- opt.label,
165
- /* @__PURE__ */ import_react2.default.createElement(
166
- "button",
167
- {
168
- onClick: (e) => {
169
- e.stopPropagation();
170
- toggleValue(opt.value);
171
- },
172
- className: "text-gray-500 hover:text-gray-700 dark:text-white cursor-pointer dark:hover:text-white",
173
- id: `${id}-button-1`
174
- },
175
- "\u2715"
176
- )
177
- )) : /* @__PURE__ */ import_react2.default.createElement("span", { className: "text-gray-400", id: `${id}-span-3` }, placeholder)),
178
- /* @__PURE__ */ import_react2.default.createElement(
179
- import_lucide_react.ChevronDown,
180
- {
181
- className: `w-4 h-4 text-gray-500 transition-transform ${open ? "rotate-180" : ""}`
182
- }
183
- )
184
- ),
185
- !disabled && open && /* @__PURE__ */ import_react2.default.createElement("div", { className: "absolute top-full mt-1 w-full bg-white border border-gray-200 rounded-lg shadow-lg z-10 max-h-60 overflow-y-auto dark:bg-[#18181b] dark:text-white", id: `${id}-div-4` }, /* @__PURE__ */ import_react2.default.createElement("div", { className: "flex items-center gap-2 p-2 border-b border-gray-200", id: `${id}-div-5` }, /* @__PURE__ */ import_react2.default.createElement(import_lucide_react.Search, { size: 16, className: "text-gray-400" }), /* @__PURE__ */ import_react2.default.createElement(
186
- "input",
187
- {
188
- type: "text",
189
- value: search,
190
- onChange: (e) => setSearch(e.target.value),
191
- placeholder: "Search...",
192
- className: "flex-1 text-sm focus:outline-none",
193
- id: `${id}-input-1`
194
- }
195
- )), /* @__PURE__ */ import_react2.default.createElement("ul", { id: `${id}-ul-1` }, filteredOptions.length > 0 ? filteredOptions.map((opt) => {
196
- const selected = value.includes(opt.value);
197
- return /* @__PURE__ */ import_react2.default.createElement(
198
- "li",
199
- {
200
- key: opt.value,
201
- onClick: () => toggleValue(opt.value),
202
- className: `flex items-center gap-2 px-3 py-2 text-sm cursor-pointer hover:bg-[#F7FAFC] dark:hover:bg-[#303036] ${selected ? "bg-[#F7FAFC] dark:bg-[#303036] font-medium" : ""}`,
203
- id: `${id}-li-1`
204
- },
205
- /* @__PURE__ */ import_react2.default.createElement(
206
- "span",
207
- {
208
- className: `w-4 h-4 flex items-center justify-center border rounded-sm ${selected ? "bg-blue-600 border-blue-600 text-white" : "border-gray-300"}`,
209
- id: `${id}-span-4`
210
- },
211
- selected && /* @__PURE__ */ import_react2.default.createElement(import_lucide_react.Check, { size: 14 })
212
- ),
213
- opt.label
214
- );
215
- }) : /* @__PURE__ */ import_react2.default.createElement("li", { className: "px-3 py-2 text-sm text-gray-400", id: `${id}-li-2` }, "No results found")))
216
- );
217
- };
218
-
219
- // src/inputs/Checkbox.jsx
220
- var import_react3 = __toESM(require("react"));
221
- var CustomCheckbox = ({ id = "checkbox", onChange, checked }) => {
222
- const handleChange = (e) => {
223
- onChange(e.target.checked);
224
- };
225
- return /* @__PURE__ */ import_react3.default.createElement("label", { className: "inline-flex items-center cursor-pointer select-none", id: `${id}-label-1` }, /* @__PURE__ */ import_react3.default.createElement(
226
- "input",
227
- {
228
- type: "checkbox",
229
- checked,
230
- onChange: handleChange,
231
- className: "peer hidden",
232
- id: `${id}-input-1`
233
- }
234
- ), /* @__PURE__ */ import_react3.default.createElement(
235
- "span",
236
- {
237
- className: "\r\n w-4 h-4 flex items-center justify-center border-2 border-gray-400 rounded \r\n peer-checked:bg-primary peer-checked:border-primary\r\n transition-colors\r\n ",
238
- id: `${id}-span-1`
239
- },
240
- checked && /* @__PURE__ */ import_react3.default.createElement(
241
- "svg",
242
- {
243
- className: "w-4 h-4 text-white",
244
- fill: "none",
245
- stroke: "currentColor",
246
- strokeWidth: "3",
247
- viewBox: "0 0 24 24",
248
- id: `${id}-svg-1`
249
- },
250
- /* @__PURE__ */ import_react3.default.createElement("path", { d: "M5 13l4 4L19 7", id: `${id}-path-1` })
251
- )
252
- ));
253
- };
254
-
255
- // src/inputs/Chip.jsx
256
- var import_react4 = __toESM(require("react"));
257
- var VARIANTS = {
258
- PRIMARY: "bg-gray-100 text-black dark:bg-gray-800 dark:text-white",
259
- GREEN: "bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-100",
260
- RED: "bg-red-100 text-red-800 dark:bg-red-900 dark:text-red-100",
261
- YELLOW: "bg-yellow-100 text-yellow-800 dark:bg-yellow-900 dark:text-yellow-100"
262
- };
263
- var Chip = ({ id = "chip", label, variant }) => {
264
- return /* @__PURE__ */ import_react4.default.createElement(
265
- "div",
266
- {
267
- className: `inline-flex text-[12px] items-center px-3 py-1 rounded-full ${VARIANTS[variant] || VARIANTS.PRIMARY} text-sm font-[600]`,
268
- id: `${id}-div-1`
269
- },
270
- label
271
- );
272
- };
273
-
274
- // src/inputs/CustomSwitch.jsx
275
- var import_react5 = __toESM(require("react"));
276
- var CustomSwitch = ({ id = "custom-switch", checked, onChange, label, description }) => {
277
- return /* @__PURE__ */ import_react5.default.createElement("div", { id: `${id}-div-1` }, /* @__PURE__ */ import_react5.default.createElement(
278
- "button",
279
- {
280
- type: "button",
281
- role: "switch",
282
- "aria-checked": checked,
283
- onClick: () => onChange(!checked),
284
- className: `relative inline-flex h-6 w-11 shrink-0 items-center rounded-full transition-colors ${checked ? "bg-black" : "bg-gray-300"}`,
285
- id: `${id}-button-1`
286
- },
287
- /* @__PURE__ */ import_react5.default.createElement(
288
- "span",
289
- {
290
- className: `inline-block h-4 w-4 transform rounded-full bg-white shadow transition ${checked ? "translate-x-6" : "translate-x-1"}`,
291
- id: `${id}-span-1`
292
- }
293
- )
294
- ), /* @__PURE__ */ import_react5.default.createElement("div", { className: "flex flex-col", id: `${id}-div-2` }, label && /* @__PURE__ */ import_react5.default.createElement("h3", { className: "font-[500] text-sm text-black mb-2", id: `${id}-h3-1` }, label), description && /* @__PURE__ */ import_react5.default.createElement("p", { className: "font-[500] text-sm text-[#737373]", id: `${id}-p-1` }, description)));
295
- };
296
-
297
- // src/inputs/Input.jsx
298
- var import_react6 = __toESM(require("react"));
299
- var CustomInput = ({
300
- id = "input",
301
- label,
302
- isRequired,
303
- value,
304
- onChange,
305
- placeholder,
306
- disabled = false,
307
- error,
308
- heading
309
- }) => {
310
- return /* @__PURE__ */ import_react6.default.createElement("div", { className: "flex flex-col gap-1 w-full", id: `${id}-div-1` }, heading && /* @__PURE__ */ import_react6.default.createElement("h3", { className: "text-lg font-semibold", id: `${id}-h3-1` }, heading), /* @__PURE__ */ import_react6.default.createElement(
311
- "label",
312
- {
313
- className: `font-[500] text-sm ${heading ? "text-[#737373]" : "text-black"} dark:text-white`,
314
- id: `${id}-label-1`
315
- },
316
- label,
317
- " ",
318
- isRequired && /* @__PURE__ */ import_react6.default.createElement("span", { className: "text-red-500", id: `${id}-span-1` }, "*")
319
- ), /* @__PURE__ */ import_react6.default.createElement(
320
- "input",
321
- {
322
- className: `border border-gray-200 rounded-md h-10 px-4 py-2 w-full text-[14px]
323
- focus:outline-2 outline-black dark:outline-white outline-offset-2
324
- dark:bg-transparent dark:text-white dark:border-[#303036]
325
- ${disabled ? "bg-gray-100 cursor-not-allowed text-gray-500 border-gray-300" : error ? "border-red-500 bg-red-50" : "bg-white border-[hsl(0_0%_89.8%)]"}
326
- `,
327
- value,
328
- onChange: (e) => onChange == null ? void 0 : onChange(e.target.value),
329
- placeholder,
330
- disabled,
331
- readOnly: disabled,
332
- id: `${id}-input-1`
333
- }
334
- ));
335
- };
336
-
337
- // src/inputs/ProgressBar.jsx
338
- var import_react7 = __toESM(require("react"));
339
- var ProgressBar = ({ id = "progress-bar", step, totalSteps }) => {
340
- const progress = step / totalSteps * 100;
341
- return /* @__PURE__ */ import_react7.default.createElement("div", { className: "mb-6", id: `${id}-div-1` }, /* @__PURE__ */ import_react7.default.createElement("p", { className: "text-gray-600 text-sm mb-2", id: `${id}-p-1` }, "Step ", step, " of ", totalSteps), /* @__PURE__ */ import_react7.default.createElement("div", { className: "w-full bg-gray-200 rounded-full h-2", id: `${id}-div-2` }, /* @__PURE__ */ import_react7.default.createElement(
342
- "div",
343
- {
344
- className: "bg-black h-2 rounded-full transition-all duration-300",
345
- style: { width: `${progress}%` },
346
- id: `${id}-div-3`
347
- }
348
- )));
349
- };
350
-
351
- // src/inputs/Search.jsx
352
- var import_react8 = __toESM(require("react"));
353
- var import_lucide_react2 = require("lucide-react");
354
- var CustomSearch = ({
355
- id = "search",
356
- value,
357
- onChange,
358
- placeholder = "Search Markets..."
359
- }) => {
360
- return /* @__PURE__ */ import_react8.default.createElement("div", { className: "flex items-center border bg-transparent text-[14px] border-[hsl(0_0%_89.8%)] dark:border-[#303036] \r\n rounded-md h-10 px-2 w-full focus-within:outline-2 focus-within:outline-black focus-within:outline-offset-2 dark:text-white", id: `${id}-div-1` }, /* @__PURE__ */ import_react8.default.createElement(import_lucide_react2.Search, { width: 16, height: 16, color: "gray", className: "mr-2" }), /* @__PURE__ */ import_react8.default.createElement(
361
- "input",
362
- {
363
- type: "text",
364
- value,
365
- onChange,
366
- placeholder,
367
- className: "bg-transparent w-full h-full focus:outline-none",
368
- id: `${id}-input-1`
369
- }
370
- ));
371
- };
372
-
373
- // src/inputs/TextArea.jsx
374
- var import_react9 = __toESM(require("react"));
375
- var CustomTextarea = ({
376
- id = "text-area",
377
- label,
378
- isRequired,
379
- value,
380
- onChange,
381
- placeholder,
382
- disabled = false,
383
- error,
384
- heading,
385
- rows = 4
386
- }) => {
387
- return /* @__PURE__ */ import_react9.default.createElement("div", { className: "flex flex-col gap-1 w-full", id: `${id}-div-1` }, heading && /* @__PURE__ */ import_react9.default.createElement("h3", { className: "text-lg font-semibold", id: `${id}-h3-1` }, heading), /* @__PURE__ */ import_react9.default.createElement(
388
- "label",
389
- {
390
- className: `font-[500] text-sm ${heading ? "text-[#737373]" : "text-black"}`,
391
- id: `${id}-label-1`
392
- },
393
- label,
394
- " ",
395
- isRequired && /* @__PURE__ */ import_react9.default.createElement("span", { className: "text-red-500", id: `${id}-span-1` }, "*")
396
- ), /* @__PURE__ */ import_react9.default.createElement(
397
- "textarea",
398
- {
399
- rows,
400
- className: `border rounded-md px-4 py-2 w-full text-[14px]
401
- focus:outline-2 focus:outline-black focus:outline-offset-2
402
- focus:ring-0 focus:shadow-none focus:border-black
403
- ${disabled ? "bg-gray-100 text-gray-500 border-gray-300" : error ? "border-red-500 bg-red-50" : "bg-white border-[hsl(0_0%_89.8%)]"}
404
- `,
405
- value,
406
- onChange: (e) => onChange == null ? void 0 : onChange(e.target.value),
407
- placeholder,
408
- disabled,
409
- readOnly: disabled,
410
- id: `${id}-textarea-1`
411
- }
412
- ));
413
- };
414
-
415
- // src/inputs/Upload.jsx
416
- var import_react10 = __toESM(require("react"));
417
- var import_lucide_react3 = require("lucide-react");
418
- var CustomUpload = ({
419
- id = "upload",
420
- label = "Supporting documents",
421
- description = "Drop items here or Browse Files",
422
- accept = ".pdf,.jpg,.jpeg,.png",
423
- maxSizeMB = 5,
424
- onChange,
425
- error,
426
- value
427
- }) => {
428
- const inputRef = (0, import_react10.useRef)(null);
429
- const handleFileSelect = (files) => {
430
- if (!files || files.length === 0) return;
431
- const selectedFile = files[0];
432
- if (selectedFile.size > maxSizeMB * 1024 * 1024) {
433
- alert(`File size must be less than ${maxSizeMB} MB`);
434
- return;
435
- }
436
- onChange == null ? void 0 : onChange(selectedFile);
437
- };
438
- return /* @__PURE__ */ import_react10.default.createElement("div", { className: "flex flex-col gap-2 w-full", id: `${id}-div-1` }, label && /* @__PURE__ */ import_react10.default.createElement("label", { className: "text-sm font-medium", id: `${id}-label-1` }, label), /* @__PURE__ */ import_react10.default.createElement(
439
- "div",
440
- {
441
- className: `border-2 border-dashed rounded-lg p-6 flex flex-col items-center justify-center text-center cursor-pointer transition
442
- ${error ? "border-red-500 bg-red-50" : "border-gray-300 hover:border-gray-400 bg-gray-50"}`,
443
- onClick: () => {
444
- var _a;
445
- return (_a = inputRef.current) == null ? void 0 : _a.click();
446
- },
447
- onDragOver: (e) => e.preventDefault(),
448
- onDrop: (e) => {
449
- e.preventDefault();
450
- handleFileSelect(e.dataTransfer.files);
451
- },
452
- id: `${id}-div-2`
453
- },
454
- /* @__PURE__ */ import_react10.default.createElement(import_lucide_react3.Upload, { className: "w-6 h-6 text-gray-500 mb-2" }),
455
- /* @__PURE__ */ import_react10.default.createElement("p", { className: "text-sm text-gray-700", id: `${id}-p-1` }, description),
456
- /* @__PURE__ */ import_react10.default.createElement("p", { className: "text-xs text-gray-500 mt-1", id: `${id}-p-2` }, "File Supported: PDF/JPG/PNG, up to ", maxSizeMB, " MB"),
457
- /* @__PURE__ */ import_react10.default.createElement(
458
- "input",
459
- {
460
- ref: inputRef,
461
- type: "file",
462
- accept,
463
- className: "hidden",
464
- onChange: (e) => handleFileSelect(e.target.files),
465
- id: `${id}-input-1`
466
- }
467
- )
468
- ), value && /* @__PURE__ */ import_react10.default.createElement("span", { className: "text-sm truncate text-gray-500", id: `${id}-span-1` }, "Selected: ", value.name), error && /* @__PURE__ */ import_react10.default.createElement("p", { className: "text-xs text-red-500", id: `${id}-p-3` }, error));
469
- };
470
-
471
- // src/sideBar/SideBar.jsx
472
- var import_lucide_react6 = require("lucide-react");
473
- var import_react12 = __toESM(require("react"));
474
-
475
- // ConstantUI.js
476
- var import_lucide_react4 = require("lucide-react");
477
- var encodedAuthData = localStorage.getItem("encodedAuthData");
478
- var navItemsConstant = [
479
- {
480
- Icon: import_lucide_react4.Home,
481
- label: "Home",
482
- onClick: () => {
483
- window.location.href = "/";
484
- },
485
- isDropDown: false
486
- },
487
- {
488
- Icon: import_lucide_react4.Building,
489
- label: "Consumer Ecosystem",
490
- onClick: () => {
491
- },
492
- options: [
493
- {
494
- label: "Corporate",
495
- onClick: () => {
496
- window.location.href = "/corporate/";
497
- }
498
- },
499
- {
500
- label: "Trips",
501
- onClick: () => {
502
- window.location.href = "/corporate/trips/";
503
- }
504
- },
505
- {
506
- label: "Users",
507
- onClick: () => {
508
- window.location.href = "/users/users";
509
- }
510
- },
511
- {
512
- label: "Tags (Custom Variables)",
513
- onClick: () => {
514
- window.location.href = "/orgselector/?path=tag";
515
- }
516
- },
517
- {
518
- label: "Special Request",
519
- onClick: () => {
520
- window.location.href = "/orgselector/?path=special-requests";
521
- }
522
- },
523
- {
524
- label: "Support Tickets (Coming Soon)",
525
- isDisabled: true
526
- // onClick: () => {},
527
- }
528
- ],
529
- isDropDown: true
530
- },
531
- {
532
- Icon: import_lucide_react4.Banknote,
533
- label: "Finance",
534
- onClick: () => {
535
- },
536
- isDropDown: true,
537
- options: [
538
- {
539
- label: "Credit Management",
540
- onClick: () => {
541
- window.location.href = "/finance/paymentsLedger/";
542
- }
543
- },
544
- {
545
- label: "Booking & Invoices",
546
- onClick: () => {
547
- window.location.href = "/finance/bookingHistory/";
548
- }
549
- }
550
- ]
551
- },
552
- {
553
- Icon: import_lucide_react4.DollarSign,
554
- label: "Revenue Management",
555
- onClick: () => {
556
- },
557
- isDropDown: true,
558
- options: [
559
- {
560
- label: "Pricing Engine",
561
- onClick: () => {
562
- window.location.href = "/orgselector/?path=pricing-policy";
563
- }
564
- },
565
- {
566
- label: "Offers",
567
- onClick: () => {
568
- window.location.href = "/orgselector/?path=offer";
569
- }
570
- },
571
- {
572
- label: "Vouchers",
573
- onClick: () => {
574
- window.location.href = "/orgselector/?path=voucher";
575
- }
576
- }
577
- ]
578
- },
579
- {
580
- Icon: import_lucide_react4.Handshake,
581
- label: "Supplier Ecosystem",
582
- onClick: () => {
583
- },
584
- isDropDown: true,
585
- options: [
586
- {
587
- label: "Suppliers List",
588
- onClick: () => {
589
- window.location.href = "/orgselector/?path=supplier-list";
590
- }
591
- },
592
- {
593
- label: "Supplier Deals",
594
- onClick: () => {
595
- window.location.href = "/supplierdeals/";
596
- }
597
- }
598
- ]
599
- },
600
- {
601
- Icon: import_lucide_react4.BarChart3,
602
- label: "Reports",
603
- onClick: () => {
604
- },
605
- isDropDown: true,
606
- options: [
607
- {
608
- label: "Reports (Coming Soon)",
609
- isDisabled: true
610
- // onClick: () => {
611
- // window.open("https://viz.jett.travel", "_blank");
612
- // },
613
- }
614
- ]
615
- },
616
- {
617
- Icon: import_lucide_react4.Cog,
618
- label: "Settings",
619
- onClick: () => {
620
- },
621
- isDropDown: true,
622
- options: [
623
- {
624
- label: "Whitelabel",
625
- onClick: () => {
626
- window.location.href = "/whitelabel/";
627
- }
628
- },
629
- {
630
- label: "Markets",
631
- onClick: () => {
632
- window.location.href = "/market/";
633
- }
634
- },
635
- {
636
- label: "Users",
637
- onClick: () => {
638
- window.location.href = `/users/users?role=admin&auth=${encodedAuthData}`;
639
- }
640
- },
641
- {
642
- label: "Reports Configurations (Coming Soon)",
643
- isDisabled: true
644
- // onClick: () => {},
645
- }
646
- ]
647
- }
648
- ];
649
- var additionalItemsConstant = [
650
- {
651
- Icon: import_lucide_react4.LifeBuoy,
652
- label: "Help",
653
- onClick: () => {
654
- window.location.href = "/help";
655
- }
656
- }
657
- ];
658
-
659
- // src/sideBar/SideBar.jsx
660
- var import_js_cookie = __toESM(require("js-cookie"));
661
-
662
- // src/inputs/CustomSelect.jsx
663
- var import_react11 = __toESM(require("react"));
664
- var import_lucide_react5 = require("lucide-react");
665
- var CustomSelect = ({
666
- id = "custom-select",
667
- label,
668
- value,
669
- onChange,
670
- options,
671
- placeholder = "Select...",
672
- isRequired = false,
673
- error,
674
- heading,
675
- disabled = false
676
- }) => {
677
- const [open, setOpen] = (0, import_react11.useState)(false);
678
- const [search, setSearch] = (0, import_react11.useState)("");
679
- const wrapperRef = (0, import_react11.useRef)(null);
680
- const handleBlur = (e) => {
681
- var _a;
682
- if (!((_a = wrapperRef.current) == null ? void 0 : _a.contains(e.relatedTarget))) {
683
- setOpen(false);
684
- }
685
- };
686
- const filteredOptions = options.filter(
687
- (opt) => opt.label.toLowerCase().includes(search.toLowerCase())
688
- );
689
- const handleSelect = (val) => {
690
- onChange(val);
691
- setOpen(false);
692
- };
693
- const selectedOption = options.find((opt) => opt.value === value);
694
- return /* @__PURE__ */ import_react11.default.createElement(
695
- "div",
696
- {
697
- className: "flex flex-col w-full relative",
698
- ref: wrapperRef,
699
- tabIndex: disabled ? -1 : 0,
700
- onBlur: handleBlur,
701
- id: `${id}-div-1`
702
- },
703
- heading && /* @__PURE__ */ import_react11.default.createElement("h3", { className: "text-lg font-semibold mb-1", id: `${id}-h3-1` }, heading),
704
- label && /* @__PURE__ */ import_react11.default.createElement(
705
- "label",
706
- {
707
- className: `font-medium text-sm mb-1 ${heading ? "text-[#737373] dark:text-white" : "text-black dark:text-white"}`,
708
- id: `${id}-label-1`
709
- },
710
- label,
711
- " ",
712
- isRequired && /* @__PURE__ */ import_react11.default.createElement("span", { className: "text-red-500", id: `${id}-span-1` }, "*")
713
- ),
714
- /* @__PURE__ */ import_react11.default.createElement(
715
- "div",
716
- {
717
- onClick: () => !disabled && setOpen((prev) => !prev),
718
- className: `flex justify-between items-center rounded-md px-3 py-2 text-sm border h-10 cursor-pointer dark:border-[#303036] dark:bg-[#18181b] dark:text-white
719
- ${disabled ? "bg-gray-100 text-gray-400" : "bg-white dark:bg-[#18181b] dark:text-white"}
720
- ${error ? "border-red-500" : "border-gray-300"}
721
- `,
722
- id: `${id}-div-2`
723
- },
724
- /* @__PURE__ */ import_react11.default.createElement("span", { className: `${selectedOption ? "text-black dark:text-white" : "text-gray-400 dark:text-white"}`, id: `${id}-span-2` }, selectedOption ? selectedOption.label : placeholder),
725
- /* @__PURE__ */ import_react11.default.createElement(
726
- import_lucide_react5.ChevronDown,
727
- {
728
- className: `w-4 h-4 text-gray-500 transition-transform dark:text-white ${open ? "rotate-180" : ""}`
729
- }
730
- )
731
- ),
732
- open && !disabled && /* @__PURE__ */ import_react11.default.createElement("div", { className: "absolute top-full mt-1 w-full bg-white border border-gray-200 rounded-lg shadow-lg z-10 max-h-60 overflow-y-auto dark:bg-[#18181b] dark:text-white", id: `${id}-div-3` }, /* @__PURE__ */ import_react11.default.createElement("div", { className: "flex items-center gap-2 p-2 border-b border-gray-200", id: `${id}-div-4` }, /* @__PURE__ */ import_react11.default.createElement(import_lucide_react5.Search, { size: 16, className: "text-gray-400" }), /* @__PURE__ */ import_react11.default.createElement(
733
- "input",
734
- {
735
- type: "text",
736
- value: search,
737
- onChange: (e) => setSearch(e.target.value),
738
- placeholder: "Search...",
739
- className: "flex-1 text-sm focus:outline-none",
740
- id: `${id}-input-1`
741
- }
742
- )), /* @__PURE__ */ import_react11.default.createElement("ul", { id: `${id}-ul-1` }, filteredOptions.length > 0 ? filteredOptions.map((opt) => /* @__PURE__ */ import_react11.default.createElement(
743
- "li",
744
- {
745
- key: opt.value,
746
- onClick: () => handleSelect(opt.value),
747
- className: `px-3 py-2 text-sm cursor-pointer hover:bg-gray-100 dark:hover:bg-[#27272a] ${value === opt.value ? "bg-gray-100 font-medium dark:bg-[#27272a] dark:text-white" : ""}`,
748
- id: `${id}-li-1`
749
- },
750
- opt.label
751
- )) : /* @__PURE__ */ import_react11.default.createElement("li", { className: "px-3 py-2 text-sm text-gray-400 dark:text-white", id: `${id}-li-2` }, "No results found")))
752
- );
753
- };
754
-
755
- // src/utils/cookieHelpers.js
756
- var JETT_ID_COOKIE_NAME = "jett-id";
757
- function getCookie(name) {
758
- if (typeof document === "undefined" || !document.cookie) return null;
759
- const match = document.cookie.match(
760
- new RegExp("(^|\\s)" + name + "=([^;]+)")
761
- );
762
- return match ? decodeURIComponent(match[2].trim()) : null;
763
- }
764
- function decodeBase64(value) {
765
- try {
766
- let base64 = value.replace(/-/g, "+").replace(/_/g, "/");
767
- const pad = base64.length % 4;
768
- if (pad) base64 += "=".repeat(4 - pad);
769
- return atob(base64);
770
- } catch {
771
- return "";
772
- }
773
- }
774
- function getJettIdCookieData() {
775
- const raw = getCookie(JETT_ID_COOKIE_NAME);
776
- if (!raw) return null;
777
- try {
778
- const decoded = decodeBase64(raw);
779
- if (!decoded) return null;
780
- const data = JSON.parse(decoded);
781
- return data && typeof data === "object" ? data : null;
782
- } catch {
783
- return null;
784
- }
785
- }
786
- function getLogoFromJettIdCookie() {
787
- const data = getJettIdCookieData();
788
- if (!(data == null ? void 0 : data.CDNBasePath)) return null;
789
- const logoPath = (data.OrgLogo || data.TmcLogo || "").trim();
790
- if (!logoPath) return null;
791
- return {
792
- logoPath,
793
- CDNBasePath: data.CDNBasePath
794
- };
795
- }
796
- function getScopeFromJettIdCookie() {
797
- const data = getJettIdCookieData();
798
- return (data == null ? void 0 : data.Scope) ?? null;
799
- }
800
- function buildLogoUrl(CDNBasePath, logoPath) {
801
- const base = (CDNBasePath || "").replace(/\/$/, "");
802
- const path = (logoPath || "").replace(/^\//, "");
803
- if (!base || !path) return "";
804
- return `${base}/${path}`;
805
- }
806
-
807
- // src/sideBar/SideBar.jsx
808
- var SCOPE_LABELS = {
809
- TMC: "TMC Manager",
810
- TMC_ENTITY: "TMC Entity Manager"
811
- };
812
- var AppSideBar = ({
813
- id = "side-bar",
814
- username,
815
- navItems,
816
- additionalItems,
817
- sideBarLogo
818
- }) => {
819
- var _a, _b;
820
- const [authData, setAuthData] = (0, import_react12.useState)(null);
821
- const [cookieUserName, setCookieUserName] = (0, import_react12.useState)(null);
822
- const [scope, setScope] = (0, import_react12.useState)(null);
823
- const [selectedCountry, setSelectedCountry] = (0, import_react12.useState)("dubai");
824
- const [isMobileMenuOpen, setIsMobileMenuOpen] = (0, import_react12.useState)(false);
825
- const [openMenus, setOpenMenus] = (0, import_react12.useState)(/* @__PURE__ */ new Set());
826
- const [activeMenuPath, setActiveMenuPath] = (0, import_react12.useState)(null);
827
- const [currAppearance, setCurrAppearance] = (0, import_react12.useState)("light");
828
- (0, import_react12.useEffect)(() => {
829
- setCurrAppearance("light");
830
- }, []);
831
- const countryOptions = [
832
- { label: "India", value: "india" },
833
- { label: "Dubai", value: "dubai" },
834
- { label: "Singapore", value: "singapore" },
835
- { label: "Qatar", value: "qatar" }
836
- ];
837
- const toggleMenu = (menuKey) => {
838
- setOpenMenus((prev) => {
839
- const newSet = new Set(prev);
840
- if (newSet.has(menuKey)) {
841
- newSet.delete(menuKey);
842
- } else {
843
- newSet.add(menuKey);
844
- }
845
- return newSet;
846
- });
847
- };
848
- const isMenuOpen = (menuKey) => {
849
- return openMenus.has(menuKey);
850
- };
851
- const handleMenuClick = (item, index, e) => {
852
- if (item.isDropDown) {
853
- e.preventDefault();
854
- const menuKey = `menu-${index}`;
855
- toggleMenu(menuKey);
856
- setActiveMenuPath(`menu-${index}`);
857
- } else {
858
- setActiveMenuPath(`menu-${index}`);
859
- if (item.onClick) {
860
- item.onClick(e);
861
- }
862
- closeMobileMenu();
863
- }
864
- };
865
- const handleSubMenuClick = (option, optionsIndex, parentIndex, e) => {
866
- const parentMenuKey = `menu-${parentIndex}`;
867
- setOpenMenus((prev) => {
868
- const newSet = new Set(prev);
869
- newSet.add(parentMenuKey);
870
- return newSet;
871
- });
872
- if (option.isDropDown) {
873
- e.preventDefault();
874
- const menuKey = `menu-${parentIndex}-option-${optionsIndex}`;
875
- toggleMenu(menuKey);
876
- setActiveMenuPath(`menu-${parentIndex}-option-${optionsIndex}`);
877
- } else {
878
- setActiveMenuPath(`menu-${parentIndex}-option-${optionsIndex}`);
879
- if (option.onClick) {
880
- option.onClick();
881
- }
882
- closeMobileMenu();
883
- }
884
- };
885
- const handleSubSubMenuClick = (subOption, parentIndex, optionsIndex, e) => {
886
- const parentMenuKey = `menu-${parentIndex}`;
887
- const subMenuKey = `menu-${parentIndex}-option-${optionsIndex}`;
888
- setOpenMenus((prev) => {
889
- const newSet = new Set(prev);
890
- newSet.add(parentMenuKey);
891
- newSet.add(subMenuKey);
892
- return newSet;
893
- });
894
- setActiveMenuPath(`menu-${parentIndex}-option-${optionsIndex}-sub-${subOption.label}`);
895
- if (subOption.onClick) {
896
- subOption.onClick();
897
- }
898
- closeMobileMenu();
899
- };
900
- (0, import_react12.useEffect)(() => {
901
- const storedAuthData = localStorage.getItem("authData");
902
- if (storedAuthData) {
903
- let parseData = JSON.parse(storedAuthData);
904
- setAuthData(parseData);
905
- }
906
- }, [localStorage.getItem("authData")]);
907
- (0, import_react12.useEffect)(() => {
908
- const jettIdData = getJettIdCookieData();
909
- if (jettIdData == null ? void 0 : jettIdData.UserName) {
910
- setCookieUserName(jettIdData.UserName);
911
- }
912
- const cookieScope = getScopeFromJettIdCookie();
913
- if (cookieScope) {
914
- setScope(cookieScope);
915
- }
916
- }, []);
917
- const extractUrlFromOnClick = (onClick) => {
918
- if (!onClick || typeof onClick !== "function") return null;
919
- const funcString = onClick.toString();
920
- let match = funcString.match(/window\.location\.href\s*=\s*`([^`]+)`/);
921
- if (!match) {
922
- match = funcString.match(/window\.location\.href\s*=\s*["']([^"']+)["']/);
923
- }
924
- if (match && match[1]) {
925
- try {
926
- if (match[1].startsWith("http://") || match[1].startsWith("https://")) {
927
- const url = new URL(match[1]);
928
- return {
929
- pathname: url.pathname,
930
- search: url.search,
931
- fullPath: url.pathname + url.search
932
- };
933
- }
934
- if (match[1].startsWith("/")) {
935
- const url = new URL(match[1], window.location.origin);
936
- return {
937
- pathname: url.pathname,
938
- search: url.search,
939
- fullPath: url.pathname + url.search
940
- };
941
- }
942
- return null;
943
- } catch {
944
- const pathMatch = match[1].match(/^([^?]+)(\?.*)?$/);
945
- if (pathMatch) {
946
- return {
947
- pathname: pathMatch[1],
948
- search: pathMatch[2] || "",
949
- fullPath: match[1]
950
- };
951
- }
952
- return null;
953
- }
954
- }
955
- return null;
956
- };
957
- const currentUrlMatches = (menuUrlData, currentPath, currentSearch) => {
958
- if (!menuUrlData || !currentPath) return false;
959
- const normalizedMenuPath = menuUrlData.pathname.replace(/\/$/, "") || "/";
960
- const normalizedCurrentPath = currentPath.replace(/\/$/, "") || "/";
961
- if (normalizedMenuPath === "/users/users" && normalizedCurrentPath === "/users/users") {
962
- const menuParams = new URLSearchParams(menuUrlData.search);
963
- const currentParams = new URLSearchParams(currentSearch);
964
- const menuRole = menuParams.get("role");
965
- const currentRole = currentParams.get("role");
966
- if (menuRole && currentRole) {
967
- return menuRole === currentRole;
968
- }
969
- if (menuRole && !currentRole || !menuRole && currentRole) {
970
- return false;
971
- }
972
- return true;
973
- }
974
- if (normalizedMenuPath === "/corporate" && normalizedCurrentPath.startsWith("/org/organizations")) {
975
- return true;
976
- }
977
- if (normalizedMenuPath === "/supplier" && normalizedCurrentPath === "/orgselector") {
978
- const currentPathParam = new URLSearchParams(currentSearch).get("path");
979
- if (currentPathParam === "supplier-list") {
980
- return true;
981
- }
982
- }
983
- if (normalizedMenuPath === "/supplierdeals" && normalizedCurrentPath === "/orgselector") {
984
- const currentPathParam = new URLSearchParams(currentSearch).get("path");
985
- if (currentPathParam === "supplier-deals") {
986
- return true;
987
- }
988
- }
989
- if (normalizedMenuPath === "/trips") {
990
- if (normalizedCurrentPath.startsWith("/tripdetails") || normalizedCurrentPath.startsWith("/offline")) {
991
- return true;
992
- }
993
- }
994
- if (normalizedMenuPath === "/orgselector" && menuUrlData.search) {
995
- const menuPathParam = new URLSearchParams(menuUrlData.search).get("path");
996
- if (menuPathParam) {
997
- const pathRouteMap = {
998
- "offer": "/offer/offer",
999
- "voucher": "/voucher/voucher",
1000
- "tag": "/tags/tags",
1001
- "special-requests": "/corporate/special-requests",
1002
- "pricing-policy": "/policies/pricing-policy",
1003
- "supplier-list": "/supplier",
1004
- "users": "/users/users"
1005
- // Consumer Ecosystem Users (no role param)
1006
- };
1007
- const expectedRoute = pathRouteMap[menuPathParam];
1008
- if (expectedRoute) {
1009
- if (normalizedCurrentPath === expectedRoute || normalizedCurrentPath.startsWith(expectedRoute + "/")) {
1010
- if (menuPathParam === "users") {
1011
- const currentParams = new URLSearchParams(currentSearch);
1012
- const currentRole = currentParams.get("role");
1013
- return currentRole !== "admin";
1014
- }
1015
- return true;
1016
- }
1017
- }
1018
- }
1019
- if (normalizedCurrentPath === "/orgselector") {
1020
- const menuPathParam2 = new URLSearchParams(menuUrlData.search).get("path");
1021
- const currentPathParam = new URLSearchParams(currentSearch).get("path");
1022
- if (menuPathParam2 && currentPathParam) {
1023
- return menuPathParam2 === currentPathParam;
1024
- }
1025
- }
1026
- }
1027
- if (normalizedMenuPath === normalizedCurrentPath) {
1028
- if (menuUrlData.search) {
1029
- const menuParams = new URLSearchParams(menuUrlData.search);
1030
- const currentParams = new URLSearchParams(currentSearch);
1031
- for (const [key, value] of menuParams.entries()) {
1032
- if (key === "auth") {
1033
- continue;
1034
- }
1035
- if (currentParams.get(key) !== value) {
1036
- return false;
1037
- }
1038
- }
1039
- return true;
1040
- }
1041
- return true;
1042
- }
1043
- if (normalizedCurrentPath.startsWith(normalizedMenuPath + "/")) {
1044
- return true;
1045
- }
1046
- return false;
1047
- };
1048
- const navItemsLocal = navItems ?? navItemsConstant;
1049
- const additionalItemsLocal = additionalItems ?? additionalItemsConstant;
1050
- const logoFromCookie = getLogoFromJettIdCookie();
1051
- const logoUrlFromCookie = logoFromCookie ? buildLogoUrl(logoFromCookie.CDNBasePath, logoFromCookie.logoPath) : null;
1052
- const logoUrlFromUserInfo = ((_a = authData == null ? void 0 : authData.userInfo) == null ? void 0 : _a.CDNBasePath) && ((_b = authData == null ? void 0 : authData.userInfo) == null ? void 0 : _b.OrgLogo) ? buildLogoUrl(
1053
- authData.userInfo.CDNBasePath,
1054
- authData.userInfo.OrgLogo
1055
- ) : null;
1056
- const sideBarLogoLocal = sideBarLogo ?? logoUrlFromCookie ?? logoUrlFromUserInfo ?? null;
1057
- const detectAndSetActiveMenu = (0, import_react12.useCallback)(() => {
1058
- const currentPath = window.location.pathname;
1059
- const currentSearch = window.location.search;
1060
- const newOpenMenus = /* @__PURE__ */ new Set();
1061
- let foundActivePath = null;
1062
- navItemsLocal.forEach((item, index) => {
1063
- if (!item.isDropDown && item.onClick && typeof item.onClick === "function") {
1064
- const itemUrlData = extractUrlFromOnClick(item.onClick);
1065
- if (itemUrlData && currentUrlMatches(itemUrlData, currentPath, currentSearch)) {
1066
- foundActivePath = `menu-${index}`;
1067
- }
1068
- }
1069
- if (item.options && item.options.length > 0) {
1070
- item.options.forEach((option, optionsIndex) => {
1071
- if (option.onClick && typeof option.onClick === "function") {
1072
- const optionUrlData = extractUrlFromOnClick(option.onClick);
1073
- if (optionUrlData && currentUrlMatches(optionUrlData, currentPath, currentSearch)) {
1074
- const menuKey = `menu-${index}`;
1075
- newOpenMenus.add(menuKey);
1076
- foundActivePath = `menu-${index}-option-${optionsIndex}`;
1077
- if (option.options && option.options.length > 0) {
1078
- option.options.forEach((subOption, subIndex) => {
1079
- const subOptionUrlData = extractUrlFromOnClick(subOption.onClick);
1080
- if (subOptionUrlData && currentUrlMatches(subOptionUrlData, currentPath, currentSearch)) {
1081
- const subMenuKey = `menu-${index}-option-${optionsIndex}`;
1082
- newOpenMenus.add(subMenuKey);
1083
- foundActivePath = `menu-${index}-option-${optionsIndex}-sub-${subOption.label}`;
1084
- }
1085
- });
1086
- }
1087
- }
1088
- }
1089
- });
1090
- }
1091
- });
1092
- if (foundActivePath) {
1093
- setOpenMenus(newOpenMenus);
1094
- setActiveMenuPath(foundActivePath);
1095
- }
1096
- }, [navItemsLocal]);
1097
- const [currentUrl, setCurrentUrl] = (0, import_react12.useState)(
1098
- () => window.location.pathname + window.location.search
1099
- );
1100
- (0, import_react12.useEffect)(() => {
1101
- detectAndSetActiveMenu();
1102
- setCurrentUrl(window.location.pathname + window.location.search);
1103
- }, [detectAndSetActiveMenu]);
1104
- (0, import_react12.useEffect)(() => {
1105
- let lastUrl = window.location.pathname + window.location.search;
1106
- const handleLocationChange = () => {
1107
- const newUrl = window.location.pathname + window.location.search;
1108
- if (newUrl !== lastUrl) {
1109
- lastUrl = newUrl;
1110
- setCurrentUrl(newUrl);
1111
- detectAndSetActiveMenu();
1112
- }
1113
- };
1114
- window.addEventListener("popstate", handleLocationChange);
1115
- const checkInterval = setInterval(() => {
1116
- const newUrl = window.location.pathname + window.location.search;
1117
- if (newUrl !== lastUrl) {
1118
- handleLocationChange();
1119
- }
1120
- }, 250);
1121
- return () => {
1122
- window.removeEventListener("popstate", handleLocationChange);
1123
- clearInterval(checkInterval);
1124
- };
1125
- }, [detectAndSetActiveMenu]);
1126
- (0, import_react12.useEffect)(() => {
1127
- detectAndSetActiveMenu();
1128
- }, [currentUrl, detectAndSetActiveMenu]);
1129
- const toggleMobileMenu = () => {
1130
- setIsMobileMenuOpen(!isMobileMenuOpen);
1131
- };
1132
- const closeMobileMenu = () => {
1133
- setIsMobileMenuOpen(false);
1134
- };
1135
- return /* @__PURE__ */ import_react12.default.createElement(import_react12.default.Fragment, null, /* @__PURE__ */ import_react12.default.createElement("div", { className: "fixed top-0 left-0 w-full z-50 flex items-center justify-between px-4 py-3 bg-white dark:bg-[#18181b] border-b border-gray-200 dark:border-[#303036] shadow-lg md:hidden", id: `${id}-div-1` }, /* @__PURE__ */ import_react12.default.createElement(
1136
- "button",
1137
- {
1138
- onClick: toggleMobileMenu,
1139
- className: "p-2 rounded-lg hover:bg-gray-50 dark:hover:bg-[#27272a] transition-colors",
1140
- "aria-label": "Toggle menu",
1141
- id: `${id}-button-1`
1142
- },
1143
- isMobileMenuOpen ? /* @__PURE__ */ import_react12.default.createElement(import_lucide_react6.X, { className: "w-6 h-6 text-gray-700 dark:text-[#f4f4f5cc]" }) : /* @__PURE__ */ import_react12.default.createElement(import_lucide_react6.Menu, { className: "w-6 h-6 text-gray-700 dark:text-[#f4f4f5cc]" })
1144
- ), /* @__PURE__ */ import_react12.default.createElement("div", { className: "flex-1 flex justify-center", id: `${id}-div-2` }, sideBarLogoLocal && /* @__PURE__ */ import_react12.default.createElement(
1145
- "img",
1146
- {
1147
- src: sideBarLogoLocal,
1148
- alt: "sidebarLogo",
1149
- width: 208,
1150
- height: 40,
1151
- className: "object-contain",
1152
- id: `${id}-img-1`
1153
- }
1154
- )), /* @__PURE__ */ import_react12.default.createElement("div", { className: "w-10", id: `${id}-div-3` })), isMobileMenuOpen && /* @__PURE__ */ import_react12.default.createElement(
1155
- "div",
1156
- {
1157
- className: "fixed inset-0 bg-black/80 bg-opacity-50 z-40 md:hidden",
1158
- onClick: closeMobileMenu,
1159
- id: `${id}-div-4`
1160
- }
1161
- ), /* @__PURE__ */ import_react12.default.createElement(
1162
- "div",
1163
- {
1164
- className: `fixed top-0 left-0 md:relative w-[320px] transition-all ease-in-out delay-100 bg-white dark:bg-[#18181b] border-r border-gray-200 dark:border-[#303036] flex flex-col p-4 pt-20 md:pt-4 h-full max-h-[100vh] xs:max-md:z-40 md:max-lg:w-[280px] ${isMobileMenuOpen ? "translate-x-0" : "-translate-x-full md:translate-x-0"}`,
1165
- id: `${id}-div-5`
1166
- },
1167
- /* @__PURE__ */ import_react12.default.createElement("div", { className: "p-2 mb-2 hidden md:block", id: `${id}-div-6` }, /* @__PURE__ */ import_react12.default.createElement("div", { className: "flex items-center justify-center w-full h-[60px] mb-2", id: `${id}-div-7` }, sideBarLogoLocal && /* @__PURE__ */ import_react12.default.createElement(
1168
- "img",
1169
- {
1170
- src: sideBarLogoLocal,
1171
- alt: "sidebarLogo",
1172
- width: 108,
1173
- height: 40,
1174
- className: "object-contain",
1175
- id: `${id}-img-2`
1176
- }
1177
- ))),
1178
- /* @__PURE__ */ import_react12.default.createElement("div", { className: "mb-4", id: `${id}-div-8` }),
1179
- /* @__PURE__ */ import_react12.default.createElement("div", { className: "overflow-y-auto scrollbar-hide", id: `${id}-div-9` }, /* @__PURE__ */ import_react12.default.createElement("div", { id: `${id}-div-10` }, navItemsLocal == null ? void 0 : navItemsLocal.map((item, index) => {
1180
- const menuKey = `menu-${index}`;
1181
- const isOpen = isMenuOpen(menuKey);
1182
- const isActive = activeMenuPath === menuKey;
1183
- return /* @__PURE__ */ import_react12.default.createElement("div", { key: index, className: "", id: `${id}-div-11` }, /* @__PURE__ */ import_react12.default.createElement(
1184
- "div",
1185
- {
1186
- className: `flex items-center gap-3 p-2.5 hover:bg-[#f4f4f5] dark:hover:bg-[#27272a] text-gray-700 dark:text-[#f4f4f5cc] cursor-pointer rounded-lg ml-2 mr-2 transition-colors duration-200 ${isActive ? "bg-[#f4f4f5] dark:bg-[#27272a]" : ""}`,
1187
- onClick: (e) => handleMenuClick(item, index, e),
1188
- id: `${id}-div-12`
1189
- },
1190
- /* @__PURE__ */ import_react12.default.createElement("div", { className: "text-primary", id: `${id}-div-13` }, /* @__PURE__ */ import_react12.default.createElement(item.Icon, { width: 20, height: 20, id: `${id}-icon-1` })),
1191
- /* @__PURE__ */ import_react12.default.createElement("span", { className: "!font-medium !text-[16px] !text-[#000] dark:text-[#f4f4f5cc]", id: `${id}-span-1` }, item.label),
1192
- item.isDropDown && /* @__PURE__ */ import_react12.default.createElement("div", { className: `ml-auto transition-all delay-75 ${isOpen ? "rotate-180" : ""}`, id: `${id}-div-14` }, /* @__PURE__ */ import_react12.default.createElement(import_lucide_react6.ChevronDown, { width: 20, height: 20, className: "text-gray-500 dark:text-gray-400" }))
1193
- ), item.options && item.options.length > 0 && /* @__PURE__ */ import_react12.default.createElement(
1194
- "div",
1195
- {
1196
- className: `ml-[20px] overflow-hidden flex flex-col transition-all duration-200 ${isOpen ? "max-h-[1000px] min-h-[50px]" : "max-h-0"}`,
1197
- id: `${id}-div-15`
1198
- },
1199
- item.options.map((options, optionsIndex) => {
1200
- const subMenuKey = `menu-${index}-option-${optionsIndex}`;
1201
- const isSubMenuOpen = isMenuOpen(subMenuKey);
1202
- const isSubActive = activeMenuPath === subMenuKey || (activeMenuPath == null ? void 0 : activeMenuPath.startsWith(`${subMenuKey}-`));
1203
- const isDisabled = options.isDisabled;
1204
- return /* @__PURE__ */ import_react12.default.createElement("div", { key: optionsIndex, className: "", id: `${id}-div-16-${optionsIndex}` }, /* @__PURE__ */ import_react12.default.createElement(
1205
- "div",
1206
- {
1207
- className: `group flex items-center gap-3 py-2 px-3 ml-4 mr-2 rounded-md transition-colors duration-200 ${isDisabled ? "cursor-not-allowed opacity-70 text-gray-400 dark:text-gray-500" : `hover:bg-[#f4f4f5] dark:hover:bg-[#27272a] text-gray-600 dark:text-[#a1a1aa] cursor-pointer ${isSubActive ? "bg-[#f4f4f5] dark:bg-[#27272a]" : ""}`}`,
1208
- onClick: (e) => {
1209
- if (isDisabled) {
1210
- e.preventDefault();
1211
- return;
1212
- }
1213
- handleSubMenuClick(options, optionsIndex, index, e);
1214
- },
1215
- id: `${id}-div-17-${optionsIndex}`
1216
- },
1217
- /* @__PURE__ */ import_react12.default.createElement("div", { id: `${id}-div-18-${optionsIndex}` }),
1218
- /* @__PURE__ */ import_react12.default.createElement("span", { className: `!font-medium !text-[15px] ${isDisabled ? "!text-[#3f3f46cc] dark:!text-[#a1a1aa]" : "!text-[#3f3f46cc] dark:!text-[#a1a1aa]"}`, id: `${id}-span-2-${optionsIndex}` }, options.label),
1219
- options.isDropDown && /* @__PURE__ */ import_react12.default.createElement(
1220
- "div",
1221
- {
1222
- className: `ml-auto transition-all delay-75 ${isSubMenuOpen ? "rotate-180" : ""}`,
1223
- id: `${id}-div-19-${optionsIndex}`
1224
- },
1225
- /* @__PURE__ */ import_react12.default.createElement(import_lucide_react6.ChevronDown, { width: 18, height: 18, className: "text-gray-400 dark:text-gray-500" })
1226
- )
1227
- ), options.options && options.options.length > 0 && /* @__PURE__ */ import_react12.default.createElement(
1228
- "div",
1229
- {
1230
- className: `ml-[20px] overflow-hidden flex flex-col transition-all duration-200 ${isSubMenuOpen ? "max-h-[1000px] min-h-[50px]" : "max-h-0"}`,
1231
- id: `${id}-div-20-${optionsIndex}`
1232
- },
1233
- options.options.map((subOption, subIndex) => {
1234
- const isSubSubActive = activeMenuPath === `menu-${index}-option-${optionsIndex}-sub-${subOption.label}`;
1235
- return /* @__PURE__ */ import_react12.default.createElement(
1236
- "div",
1237
- {
1238
- key: subIndex,
1239
- className: `py-1.5 px-3 rounded-md hover:bg-[#f4f4f5] dark:hover:bg-[#27272a] text-gray-500 dark:text-[#71717a] font-medium text-base cursor-pointer ml-8 mr-2 transition-colors duration-200 ${isSubSubActive ? "bg-[#f4f4f5] dark:bg-[#27272a]" : ""}`,
1240
- onClick: (e) => handleSubSubMenuClick(subOption, index, optionsIndex, e),
1241
- id: `${id}-div-21-${subIndex}`
1242
- },
1243
- subOption.label
1244
- );
1245
- })
1246
- ));
1247
- })
1248
- ));
1249
- }))),
1250
- /* @__PURE__ */ import_react12.default.createElement("div", { className: "mt-auto bg-[#fafafa] dark:bg-[#18181b] sticky bottom-0 mt-2", id: `${id}-div-22` }, /* @__PURE__ */ import_react12.default.createElement(
1251
- "div",
1252
- {
1253
- className: "flex items-center justify-between p-2 rounded-lg hover:bg-[#f4f4f5] dark:hover:bg-[#27272a] cursor-pointer transition-colors duration-200",
1254
- onClick: () => {
1255
- window.location.href = "/profile";
1256
- },
1257
- id: `${id}-div-23`
1258
- },
1259
- /* @__PURE__ */ import_react12.default.createElement("div", { className: "flex items-center gap-3", id: `${id}-div-24` }, /* @__PURE__ */ import_react12.default.createElement("span", { className: "relative flex shrink-0 overflow-hidden dark:bg-[#27272a] rounded-full h-10 w-10", id: `${id}-span-3` }, /* @__PURE__ */ import_react12.default.createElement("span", { className: "flex h-full w-full items-center justify-center !text-[16px] !font-normal border border-gray-200 dark:border-[#303036] rounded-full bg-muted dark:text-white", id: `${id}-span-4` }, cookieUserName ? cookieUserName.split("")[0] : "A")), /* @__PURE__ */ import_react12.default.createElement("div", { id: `${id}-div-25` }, /* @__PURE__ */ import_react12.default.createElement("p", { className: "!font-semibold dark:text-white !text-[16px]", id: `${id}-p-1` }, cookieUserName ? cookieUserName : "Admin"), /* @__PURE__ */ import_react12.default.createElement("p", { className: "!text-[14px] !font-normal dark:text-[#f4f4f5cc]", id: `${id}-p-2` }, SCOPE_LABELS[scope] ?? scope)))
1260
- ))
1261
- ));
1262
- };
1263
-
1264
- // src/RightSheet/RightSheet.jsx
1265
- var import_react13 = __toESM(require("react"));
1266
- var RightSheet = ({
1267
- id = "right-sheet",
1268
- open,
1269
- setOpen,
1270
- children,
1271
- callBack,
1272
- actionLabel = "Save",
1273
- onAction = () => {
1274
- }
1275
- }) => {
1276
- const [visible, setVisible] = (0, import_react13.useState)(open);
1277
- (0, import_react13.useEffect)(() => {
1278
- if (open) {
1279
- document.body.style.overflow = "hidden";
1280
- setVisible(true);
1281
- }
1282
- return () => {
1283
- document.body.style.overflow = "auto";
1284
- };
1285
- }, [open]);
1286
- const handleClose = () => {
1287
- setVisible(false);
1288
- setTimeout(() => {
1289
- setOpen(false);
1290
- callBack();
1291
- }, 200);
1292
- };
1293
- const handleAction = () => {
1294
- onAction();
1295
- handleClose();
1296
- };
1297
- if (!visible) return null;
1298
- return /* @__PURE__ */ import_react13.default.createElement(
1299
- "div",
1300
- {
1301
- className: "fixed inset-0 overflow-x-hidden bg-black/80 sheetPopIn h-full overflow-auto ",
1302
- onClick: handleClose,
1303
- id: `${id}-div-1`
1304
- },
1305
- /* @__PURE__ */ import_react13.default.createElement(
1306
- "div",
1307
- {
1308
- className: `absolute flex flex-col right-0 top-0 min-h-full min-w-[100%] md:min-w-[576px]
1309
- ${visible ? "sheetRightSlide" : "transition-all duration-200 translate-x-[100%]"} justify-between bg-[#fff] dark:bg-[#18181b] dark:text-white`,
1310
- onClick: (e) => e.stopPropagation(),
1311
- id: `${id}-div-2`
1312
- },
1313
- /* @__PURE__ */ import_react13.default.createElement("div", { className: " min-h-full ", id: `${id}-div-3` }, children),
1314
- /* @__PURE__ */ import_react13.default.createElement("div", { className: "h-[90px] flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2 p-6 border-t sticky bottom-0 bg-white border-[#e6e6e6] dark:border-[#303036] dark:bg-[#18181b] dark:text-white", id: `${id}-div-4` }, /* @__PURE__ */ import_react13.default.createElement(CustomButton, { variant: "SECONDARY", onClick: () => handleClose(), id: `${id}-custom-button-1` }, "Cancel"), /* @__PURE__ */ import_react13.default.createElement(CustomButton, { variant: "SECONDARY", onClick: handleAction, id: `${id}-custom-button-2` }, actionLabel))
1315
- )
1316
- );
1317
- };
1318
-
1319
- // src/Table/CustomTable.jsx
1320
- var import_react14 = __toESM(require("react"));
1321
- var CustomTable = ({
1322
- id = "custom-table",
1323
- tableHeader,
1324
- setIsAllChecked,
1325
- isAllChecked,
1326
- children,
1327
- isHideCheckbox = "false"
1328
- }) => {
1329
- return /* @__PURE__ */ import_react14.default.createElement("div", { className: "border border-[#e5e5e5] dark:border-[#303036] rounded-lg overflow-x-auto", id: `${id}-div-1` }, /* @__PURE__ */ import_react14.default.createElement("div", { className: "w-full relative overflow-x-auto", id: `${id}-div-2` }, /* @__PURE__ */ import_react14.default.createElement("table", { className: "w-full caption-bottom text-sm overflow-x-auto bg-white dark:bg-[#18181b] table-fixed border-collapse", id: `${id}-table-1` }, /* @__PURE__ */ import_react14.default.createElement("thead", { className: "border-b border-[#e5e5e5] dark:border-[#303036] dark:bg-[#18181b]", id: `${id}-thead-1` }, /* @__PURE__ */ import_react14.default.createElement(
1330
- "tr",
1331
- {
1332
- className: "transition-colors text-[#737373] hover:bg-muted/50 \r\n data-[state=selected]:bg-muted",
1333
- id: `${id}-tr-1`
1334
- },
1335
- !isHideCheckbox && /* @__PURE__ */ import_react14.default.createElement("th", { className: "px-4 py-3 text-left w-[50px]", id: `${id}-th-1` }, /* @__PURE__ */ import_react14.default.createElement(
1336
- CustomCheckbox,
1337
- {
1338
- checked: isAllChecked,
1339
- onChange: () => {
1340
- setIsAllChecked(!isAllChecked);
1341
- },
1342
- id: `${id}-custom-checkbox-1`
1343
- }
1344
- )),
1345
- tableHeader.map((header, index) => {
1346
- return /* @__PURE__ */ import_react14.default.createElement(
1347
- "th",
1348
- {
1349
- className: `text-[#737373] px-4 py-3 text-sm dark:bg-[#18181b] font-medium ${index == tableHeader.length - 1 ? "text-right" : "text-left"}`,
1350
- key: header + index,
1351
- id: `${id}-th-2-${index}`
1352
- },
1353
- header
1354
- );
1355
- })
1356
- )), /* @__PURE__ */ import_react14.default.createElement("tbody", { id: `${id}-tbody-1` }, children))));
1357
- };
1358
-
1359
- // src/Pagination/Pagination.jsx
1360
- var import_react15 = __toESM(require("react"));
1361
- var import_lucide_react7 = require("lucide-react");
1362
- var Pagination = ({
1363
- id = "pagination",
1364
- data = [],
1365
- component: Component,
1366
- itemsPerPage = 6,
1367
- itemsPerPageOptions = [5, 10, 20, 50, 100],
1368
- // Controlled props (optional)
1369
- currentPage: controlledCurrentPage,
1370
- onPageChange: controlledOnPageChange,
1371
- onItemsPerPageChange: controlledOnItemsPerPageChange,
1372
- // Legacy props for backward compatibility
1373
- totalPages,
1374
- totalItems: legacyTotalItems,
1375
- onPageChange: legacyOnPageChange,
1376
- onItemsPerPageChange: legacyOnItemsPerPageChange,
1377
- tableHeader,
1378
- isHideCheckbox,
1379
- callback,
1380
- isTable = false,
1381
- // Component props - any additional props to pass to the component
1382
- componentProps = {},
1383
- ...restProps
1384
- }) => {
1385
- const [internalCurrentPage, setInternalCurrentPage] = (0, import_react15.useState)(1);
1386
- const [internalItemsPerPage, setInternalItemsPerPage] = (0, import_react15.useState)(itemsPerPage);
1387
- const isControlled = controlledCurrentPage !== void 0;
1388
- const isItemsPerPageControlled = controlledOnItemsPerPageChange !== void 0;
1389
- const currentPage = isControlled ? controlledCurrentPage : internalCurrentPage;
1390
- const activeItemsPerPage = isItemsPerPageControlled ? itemsPerPage : internalItemsPerPage;
1391
- const totalItems = legacyTotalItems !== void 0 ? legacyTotalItems : data.length;
1392
- const calculatedTotalPages = (0, import_react15.useMemo)(() => {
1393
- if (totalItems > 0 && activeItemsPerPage > 0) {
1394
- return Math.ceil(totalItems / activeItemsPerPage);
1395
- }
1396
- return 1;
1397
- }, [totalItems, activeItemsPerPage]);
1398
- const paginatedData = (0, import_react15.useMemo)(() => {
1399
- if (!data || data.length === 0) return [];
1400
- const startIndex = (currentPage - 1) * activeItemsPerPage;
1401
- const endIndex = startIndex + activeItemsPerPage;
1402
- return data.slice(startIndex, endIndex);
1403
- }, [data, currentPage, activeItemsPerPage]);
1404
- (0, import_react15.useEffect)(() => {
1405
- if (!isControlled && currentPage > calculatedTotalPages && calculatedTotalPages > 0) {
1406
- setInternalCurrentPage(1);
1407
- }
1408
- }, [calculatedTotalPages, isControlled, currentPage]);
1409
- const getPageNumbers = () => {
1410
- const pages = [];
1411
- const maxVisible = 5;
1412
- let startPage = Math.max(1, currentPage - Math.floor(maxVisible / 2));
1413
- let endPage = Math.min(calculatedTotalPages, startPage + maxVisible - 1);
1414
- if (endPage - startPage < maxVisible - 1) {
1415
- startPage = Math.max(1, endPage - maxVisible + 1);
1416
- }
1417
- for (let i = startPage; i <= endPage; i++) {
1418
- pages.push(i);
1419
- }
1420
- return pages;
1421
- };
1422
- const handlePageChange = (page) => {
1423
- if (page >= 1 && page <= calculatedTotalPages) {
1424
- if (isControlled && controlledOnPageChange) {
1425
- controlledOnPageChange(page);
1426
- } else if (legacyOnPageChange) {
1427
- legacyOnPageChange(page);
1428
- } else {
1429
- setInternalCurrentPage(page);
1430
- }
1431
- }
1432
- };
1433
- const startItem = totalItems !== void 0 ? (currentPage - 1) * activeItemsPerPage + 1 : null;
1434
- const endItem = totalItems !== void 0 ? Math.min(currentPage * activeItemsPerPage, totalItems) : null;
1435
- const renderContent = () => {
1436
- if (Component) {
1437
- if (import_react15.default.isValidElement(Component)) {
1438
- const ComponentType = Component.type;
1439
- const elementProps = Component.props;
1440
- if (isTable) {
1441
- return /* @__PURE__ */ import_react15.default.createElement(
1442
- CustomTable,
1443
- {
1444
- tableHeader,
1445
- isHideCheckbox,
1446
- id: `${id}-custom-table-1`
1447
- },
1448
- data.map((item, index) => {
1449
- return /* @__PURE__ */ import_react15.default.createElement(
1450
- ComponentType,
1451
- {
1452
- key: item.id || item._id || index,
1453
- data: item,
1454
- ...elementProps,
1455
- ...componentProps,
1456
- ...restProps,
1457
- id: `${id}-component-type-1-${index}`
1458
- }
1459
- );
1460
- })
1461
- );
1462
- } else {
1463
- if (isTable) {
1464
- return /* @__PURE__ */ import_react15.default.createElement(
1465
- CustomTable,
1466
- {
1467
- tableHeader,
1468
- isHideCheckbox,
1469
- id: `${id}-custom-table-2`
1470
- },
1471
- paginatedData.map((item, index) => {
1472
- return /* @__PURE__ */ import_react15.default.createElement(
1473
- ComponentType,
1474
- {
1475
- key: item.id || item._id || index,
1476
- data: item,
1477
- ...elementProps,
1478
- ...componentProps,
1479
- ...restProps,
1480
- id: `${id}-component-type-2-${index}`
1481
- }
1482
- );
1483
- })
1484
- );
1485
- }
1486
- }
1487
- } else {
1488
- return /* @__PURE__ */ import_react15.default.createElement(
1489
- CustomTable,
1490
- {
1491
- tableHeader,
1492
- isHideCheckbox,
1493
- id: `${id}-custom-table-3`
1494
- },
1495
- paginatedData.map((item, index) => {
1496
- return /* @__PURE__ */ import_react15.default.createElement(
1497
- Component,
1498
- {
1499
- key: item.id || item._id || index,
1500
- data: item,
1501
- ...componentProps,
1502
- ...restProps,
1503
- id: `${id}-component-1-${index}`
1504
- }
1505
- );
1506
- })
1507
- );
1508
- }
1509
- }
1510
- return null;
1511
- };
1512
- return /* @__PURE__ */ import_react15.default.createElement(import_react15.default.Fragment, null, /* @__PURE__ */ import_react15.default.createElement(import_react15.default.Fragment, null, renderContent()), /* @__PURE__ */ import_react15.default.createElement("div", { className: "flex flex-col sm:flex-row justify-between items-center gap-4 px-4 py-3 border-t border-[#e5e5e5] dark:border-[#303036] bg-white dark:bg-[#18181b] z-10", id: `${id}-div-1` }, totalItems !== void 0 && /* @__PURE__ */ import_react15.default.createElement("div", { className: "text-sm text-[#737373] dark:text-white", id: `${id}-div-2` }, "Showing ", startItem, " to ", endItem, " of ", totalItems, " entries"), /* @__PURE__ */ import_react15.default.createElement("div", { className: "flex items-center gap-2", id: `${id}-div-3` }, /* @__PURE__ */ import_react15.default.createElement(
1513
- "button",
1514
- {
1515
- onClick: () => handlePageChange(1),
1516
- disabled: currentPage === 1,
1517
- className: `flex items-center justify-center w-9 h-9 rounded-md border border-[#e5e5e5] dark:border-[#303036] text-sm transition-colors ${currentPage === 1 ? "bg-gray-100 text-gray-400 cursor-not-allowed dark:bg-[#27272a] dark:text-gray-600" : "bg-white text-black hover:bg-gray-50 cursor-pointer dark:bg-[#18181b] dark:text-white dark:hover:bg-[#27272a]"}`,
1518
- title: "First page",
1519
- id: `${id}-button-1`
1520
- },
1521
- /* @__PURE__ */ import_react15.default.createElement(import_lucide_react7.ChevronsLeft, { size: 16 })
1522
- ), /* @__PURE__ */ import_react15.default.createElement(
1523
- "button",
1524
- {
1525
- onClick: () => handlePageChange(currentPage - 1),
1526
- disabled: currentPage === 1,
1527
- className: `flex items-center justify-center w-9 h-9 rounded-md border border-[#e5e5e5] dark:border-[#303036] text-sm transition-colors ${currentPage === 1 ? "bg-gray-100 text-gray-400 cursor-not-allowed dark:bg-[#27272a] dark:text-gray-600" : "bg-white text-black hover:bg-gray-50 cursor-pointer dark:bg-[#18181b] dark:text-white dark:hover:bg-[#27272a]"}`,
1528
- title: "Previous page",
1529
- id: `${id}-button-2`
1530
- },
1531
- /* @__PURE__ */ import_react15.default.createElement(import_lucide_react7.ChevronLeft, { size: 16 })
1532
- ), getPageNumbers().map((pageNum) => /* @__PURE__ */ import_react15.default.createElement(
1533
- "button",
1534
- {
1535
- key: pageNum,
1536
- onClick: () => handlePageChange(pageNum),
1537
- className: `flex items-center justify-center min-w-9 h-9 px-3 cursor-pointer rounded-md border border-[#e5e5e5] dark:border-[#303036] text-sm transition-colors ${currentPage === pageNum ? "bg-primary text-white border-primary dark:bg-primary" : "bg-white text-black hover:bg-gray-50 dark:bg-[#18181b] dark:text-white dark:hover:bg-[#27272a]"}`,
1538
- id: `${id}-button-3`
1539
- },
1540
- pageNum
1541
- )), /* @__PURE__ */ import_react15.default.createElement(
1542
- "button",
1543
- {
1544
- onClick: () => handlePageChange(currentPage + 1),
1545
- disabled: currentPage === calculatedTotalPages || calculatedTotalPages === 0,
1546
- className: `flex items-center justify-center w-9 h-9 rounded-md border border-[#e5e5e5] dark:border-[#303036] text-sm transition-colors ${currentPage === calculatedTotalPages || calculatedTotalPages === 0 ? "bg-gray-100 text-gray-400 cursor-not-allowed dark:bg-[#27272a] dark:text-gray-600" : "bg-white text-black hover:bg-gray-50 cursor-pointer dark:bg-[#18181b] dark:text-white dark:hover:bg-[#27272a]"}`,
1547
- title: "Next page",
1548
- id: `${id}-button-4`
1549
- },
1550
- /* @__PURE__ */ import_react15.default.createElement(import_lucide_react7.ChevronRight, { size: 16 })
1551
- ), /* @__PURE__ */ import_react15.default.createElement(
1552
- "button",
1553
- {
1554
- onClick: () => handlePageChange(calculatedTotalPages),
1555
- disabled: currentPage === calculatedTotalPages || calculatedTotalPages === 0,
1556
- className: `flex items-center justify-center w-9 h-9 rounded-md border border-[#e5e5e5] dark:border-[#303036] text-sm transition-colors ${currentPage === calculatedTotalPages || calculatedTotalPages === 0 ? "bg-gray-100 text-gray-400 cursor-not-allowed dark:bg-[#27272a] dark:text-gray-600" : "bg-white text-black hover:bg-gray-50 cursor-pointer dark:bg-[#18181b] dark:text-white dark:hover:bg-[#27272a]"}`,
1557
- title: "Last page",
1558
- id: `${id}-button-5`
1559
- },
1560
- /* @__PURE__ */ import_react15.default.createElement(import_lucide_react7.ChevronsRight, { size: 16 })
1561
- ))));
1562
- };
1563
- // Annotate the CommonJS export names for ESM import in node:
1564
- 0 && (module.exports = {
1565
- AppSideBar,
1566
- Chip,
1567
- CustomAutocomplete,
1568
- CustomButton,
1569
- CustomCheckbox,
1570
- CustomInput,
1571
- CustomSearch,
1572
- CustomSelect,
1573
- CustomSwitch,
1574
- CustomTable,
1575
- CustomTextarea,
1576
- CustomUpload,
1577
- Pagination,
1578
- ProgressBar,
1579
- RightSheet
1580
- });
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+
29
+ // src/index.js
30
+ var index_exports = {};
31
+ __export(index_exports, {
32
+ AppSideBar: () => AppSideBar,
33
+ Chip: () => Chip,
34
+ CustomAutocomplete: () => CustomAutocomplete,
35
+ CustomButton: () => CustomButton,
36
+ CustomCheckbox: () => CustomCheckbox,
37
+ CustomInput: () => CustomInput,
38
+ CustomSearch: () => CustomSearch,
39
+ CustomSelect: () => CustomSelect,
40
+ CustomSwitch: () => CustomSwitch,
41
+ CustomTable: () => CustomTable,
42
+ CustomTextarea: () => CustomTextarea,
43
+ CustomUpload: () => CustomUpload,
44
+ Pagination: () => Pagination,
45
+ ProgressBar: () => ProgressBar,
46
+ RightSheet: () => RightSheet
47
+ });
48
+ module.exports = __toCommonJS(index_exports);
49
+
50
+ // src/utils/cn.ts
51
+ var import_clsx = require("clsx");
52
+ var import_tailwind_merge = require("tailwind-merge");
53
+ function cn(...inputs) {
54
+ return (0, import_tailwind_merge.twMerge)((0, import_clsx.clsx)(inputs));
55
+ }
56
+
57
+ // src/Button.jsx
58
+ var import_react = __toESM(require("react"));
59
+ var variantStyles = {
60
+ PRIMARY: "bg-white dark:bg-[#18181b] dark:text-white",
61
+ SECONDARY: "bg-primary text-white dark:text-white",
62
+ DEFAULT: "bg-white text-black dark:text-white",
63
+ DANGER: "bg-[#ef4444] text-white dark:text-white"
64
+ };
65
+ var CustomButton = ({
66
+ id = "button",
67
+ variant = "DEFAULT",
68
+ children,
69
+ className,
70
+ onClick,
71
+ disabled = false,
72
+ icon
73
+ }) => {
74
+ return /* @__PURE__ */ import_react.default.createElement(
75
+ "div",
76
+ {
77
+ className: cn(
78
+ `cursor-pointer flex items-center py-2 px-3 min-h-10 justify-center border rounded-[6px] border-[#e5e5e5] dark:border-[#303036] ${variant == "DANGER" ? "bg-[#ef4444]" : "dark:bg-[#1d1d20]"} gap-2`,
79
+ variantStyles[variant],
80
+ className
81
+ ),
82
+ onClick,
83
+ id: `${id}-div-1`
84
+ },
85
+ icon && /* @__PURE__ */ import_react.default.createElement("div", { id: `${id}-div-2` }, icon),
86
+ children
87
+ );
88
+ };
89
+
90
+ // src/inputs/Autocomplete.jsx
91
+ var import_react2 = __toESM(require("react"));
92
+ var import_lucide_react = require("lucide-react");
93
+ var CustomAutocomplete = ({
94
+ id = "autocomplete",
95
+ label,
96
+ value,
97
+ onChange,
98
+ options,
99
+ placeholder = "Search & select...",
100
+ isRequired = false,
101
+ error,
102
+ heading,
103
+ disabled = false
104
+ }) => {
105
+ const [open, setOpen] = (0, import_react2.useState)(false);
106
+ const [search, setSearch] = (0, import_react2.useState)("");
107
+ const wrapperRef = (0, import_react2.useRef)(null);
108
+ const selectedOptions = options.filter((opt) => value.includes(opt.value));
109
+ const handleBlur = (e) => {
110
+ var _a;
111
+ if (!((_a = wrapperRef.current) == null ? void 0 : _a.contains(e.relatedTarget))) {
112
+ setOpen(false);
113
+ }
114
+ };
115
+ const filteredOptions = options.filter(
116
+ (opt) => opt.label.toLowerCase().includes(search.toLowerCase())
117
+ );
118
+ const toggleValue = (val) => {
119
+ if (value.includes(val)) {
120
+ onChange(value.filter((v) => v !== val));
121
+ } else {
122
+ onChange([...value, val]);
123
+ }
124
+ };
125
+ return /* @__PURE__ */ import_react2.default.createElement(
126
+ "div",
127
+ {
128
+ className: "flex flex-col w-full relative dark:bg-[#18181b] dark:text-white",
129
+ ref: wrapperRef,
130
+ tabIndex: disabled ? -1 : 0,
131
+ onBlur: handleBlur,
132
+ id: `${id}-div-1`
133
+ },
134
+ heading && /* @__PURE__ */ import_react2.default.createElement("h3", { className: "text-lg font-semibold leading-6 mb-1", id: `${id}-h3-1` }, heading),
135
+ label && /* @__PURE__ */ import_react2.default.createElement(
136
+ "label",
137
+ {
138
+ className: `font-[500] text-sm leading-5 mb-1 ${heading ? "text-[#737373]" : "text-black dark:text-white"}`,
139
+ id: `${id}-label-1`
140
+ },
141
+ label,
142
+ " ",
143
+ isRequired && /* @__PURE__ */ import_react2.default.createElement("span", { className: "text-red-500", id: `${id}-span-1` }, "*")
144
+ ),
145
+ /* @__PURE__ */ import_react2.default.createElement(
146
+ "div",
147
+ {
148
+ onClick: () => {
149
+ if (!disabled) setOpen((prev) => !prev);
150
+ },
151
+ className: `flex justify-between items-center flex-wrap gap-1 rounded-md px-3 py-2 text-sm transition border dark:border-[#303036] h-auto min-h-10 dark:bg-[#18181b] dark:text-white
152
+ ${disabled ? "bg-gray-100 cursor-not-allowed text-gray-400" : "cursor-text"}
153
+ ${error ? "border-red-500 bg-red-50" : "bg-white border-[hsl(0_0%_89.8%)] hover:border-gray-400 dark:bg-[#18181b] dark:text-white"}
154
+ `,
155
+ id: `${id}-div-2`
156
+ },
157
+ /* @__PURE__ */ import_react2.default.createElement("div", { className: "flex flex-wrap gap-1 flex-1", id: `${id}-div-3` }, selectedOptions.length > 0 ? selectedOptions.map((opt) => /* @__PURE__ */ import_react2.default.createElement(
158
+ "span",
159
+ {
160
+ key: opt.value,
161
+ className: "bg-[#F7FAFC] dark:bg-[#303036] border border-gray-300 px-2 dark:text-white py-0.5 rounded text-xs flex items-center gap-1",
162
+ id: `${id}-span-2`
163
+ },
164
+ opt.label,
165
+ /* @__PURE__ */ import_react2.default.createElement(
166
+ "button",
167
+ {
168
+ onClick: (e) => {
169
+ e.stopPropagation();
170
+ toggleValue(opt.value);
171
+ },
172
+ className: "text-gray-500 hover:text-gray-700 dark:text-white cursor-pointer dark:hover:text-white",
173
+ id: `${id}-button-1`
174
+ },
175
+ "\u2715"
176
+ )
177
+ )) : /* @__PURE__ */ import_react2.default.createElement("span", { className: "text-gray-400", id: `${id}-span-3` }, placeholder)),
178
+ /* @__PURE__ */ import_react2.default.createElement(
179
+ import_lucide_react.ChevronDown,
180
+ {
181
+ className: `w-4 h-4 text-gray-500 transition-transform ${open ? "rotate-180" : ""}`
182
+ }
183
+ )
184
+ ),
185
+ !disabled && open && /* @__PURE__ */ import_react2.default.createElement("div", { className: "absolute top-full mt-1 w-full bg-white border border-gray-200 rounded-lg shadow-lg z-10 max-h-60 overflow-y-auto dark:bg-[#18181b] dark:text-white", id: `${id}-div-4` }, /* @__PURE__ */ import_react2.default.createElement("div", { className: "flex items-center gap-2 p-2 border-b border-gray-200", id: `${id}-div-5` }, /* @__PURE__ */ import_react2.default.createElement(import_lucide_react.Search, { size: 16, className: "text-gray-400" }), /* @__PURE__ */ import_react2.default.createElement(
186
+ "input",
187
+ {
188
+ type: "text",
189
+ value: search,
190
+ onChange: (e) => setSearch(e.target.value),
191
+ placeholder: "Search...",
192
+ className: "flex-1 text-sm focus:outline-none",
193
+ id: `${id}-input-1`
194
+ }
195
+ )), /* @__PURE__ */ import_react2.default.createElement("ul", { id: `${id}-ul-1` }, filteredOptions.length > 0 ? filteredOptions.map((opt) => {
196
+ const selected = value.includes(opt.value);
197
+ return /* @__PURE__ */ import_react2.default.createElement(
198
+ "li",
199
+ {
200
+ key: opt.value,
201
+ onClick: () => toggleValue(opt.value),
202
+ className: `flex items-center gap-2 px-3 py-2 text-sm cursor-pointer hover:bg-[#F7FAFC] dark:hover:bg-[#303036] ${selected ? "bg-[#F7FAFC] dark:bg-[#303036] font-medium" : ""}`,
203
+ id: `${id}-li-1`
204
+ },
205
+ /* @__PURE__ */ import_react2.default.createElement(
206
+ "span",
207
+ {
208
+ className: `w-4 h-4 flex items-center justify-center border rounded-sm ${selected ? "bg-blue-600 border-blue-600 text-white" : "border-gray-300"}`,
209
+ id: `${id}-span-4`
210
+ },
211
+ selected && /* @__PURE__ */ import_react2.default.createElement(import_lucide_react.Check, { size: 14 })
212
+ ),
213
+ opt.label
214
+ );
215
+ }) : /* @__PURE__ */ import_react2.default.createElement("li", { className: "px-3 py-2 text-sm text-gray-400", id: `${id}-li-2` }, "No results found")))
216
+ );
217
+ };
218
+
219
+ // src/inputs/Checkbox.jsx
220
+ var import_react3 = __toESM(require("react"));
221
+ var CustomCheckbox = ({ id = "checkbox", onChange, checked }) => {
222
+ const handleChange = (e) => {
223
+ onChange(e.target.checked);
224
+ };
225
+ return /* @__PURE__ */ import_react3.default.createElement("label", { className: "inline-flex items-center cursor-pointer select-none", id: `${id}-label-1` }, /* @__PURE__ */ import_react3.default.createElement(
226
+ "input",
227
+ {
228
+ type: "checkbox",
229
+ checked,
230
+ onChange: handleChange,
231
+ className: "peer hidden",
232
+ id: `${id}-input-1`
233
+ }
234
+ ), /* @__PURE__ */ import_react3.default.createElement(
235
+ "span",
236
+ {
237
+ className: "\r\n w-4 h-4 flex items-center justify-center border-2 border-gray-400 rounded \r\n peer-checked:bg-primary peer-checked:border-primary\r\n transition-colors\r\n ",
238
+ id: `${id}-span-1`
239
+ },
240
+ checked && /* @__PURE__ */ import_react3.default.createElement(
241
+ "svg",
242
+ {
243
+ className: "w-4 h-4 text-white",
244
+ fill: "none",
245
+ stroke: "currentColor",
246
+ strokeWidth: "3",
247
+ viewBox: "0 0 24 24",
248
+ id: `${id}-svg-1`
249
+ },
250
+ /* @__PURE__ */ import_react3.default.createElement("path", { d: "M5 13l4 4L19 7", id: `${id}-path-1` })
251
+ )
252
+ ));
253
+ };
254
+
255
+ // src/inputs/Chip.jsx
256
+ var import_react4 = __toESM(require("react"));
257
+ var VARIANTS = {
258
+ PRIMARY: "bg-gray-100 text-black dark:bg-gray-800 dark:text-white",
259
+ GREEN: "bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-100",
260
+ RED: "bg-red-100 text-red-800 dark:bg-red-900 dark:text-red-100",
261
+ YELLOW: "bg-yellow-100 text-yellow-800 dark:bg-yellow-900 dark:text-yellow-100"
262
+ };
263
+ var Chip = ({ id = "chip", label, variant }) => {
264
+ return /* @__PURE__ */ import_react4.default.createElement(
265
+ "div",
266
+ {
267
+ className: `inline-flex text-[12px] items-center px-3 py-1 rounded-full ${VARIANTS[variant] || VARIANTS.PRIMARY} text-sm font-[600]`,
268
+ id: `${id}-div-1`
269
+ },
270
+ label
271
+ );
272
+ };
273
+
274
+ // src/inputs/CustomSwitch.jsx
275
+ var import_react5 = __toESM(require("react"));
276
+ var CustomSwitch = ({ id = "custom-switch", checked, onChange, label, description }) => {
277
+ return /* @__PURE__ */ import_react5.default.createElement("div", { id: `${id}-div-1` }, /* @__PURE__ */ import_react5.default.createElement(
278
+ "button",
279
+ {
280
+ type: "button",
281
+ role: "switch",
282
+ "aria-checked": checked,
283
+ onClick: () => onChange(!checked),
284
+ className: `relative inline-flex h-6 w-11 shrink-0 items-center rounded-full transition-colors ${checked ? "bg-black" : "bg-gray-300"}`,
285
+ id: `${id}-button-1`
286
+ },
287
+ /* @__PURE__ */ import_react5.default.createElement(
288
+ "span",
289
+ {
290
+ className: `inline-block h-4 w-4 transform rounded-full bg-white shadow transition ${checked ? "translate-x-6" : "translate-x-1"}`,
291
+ id: `${id}-span-1`
292
+ }
293
+ )
294
+ ), /* @__PURE__ */ import_react5.default.createElement("div", { className: "flex flex-col", id: `${id}-div-2` }, label && /* @__PURE__ */ import_react5.default.createElement("h3", { className: "font-[500] text-sm text-black mb-2", id: `${id}-h3-1` }, label), description && /* @__PURE__ */ import_react5.default.createElement("p", { className: "font-[500] text-sm text-[#737373]", id: `${id}-p-1` }, description)));
295
+ };
296
+
297
+ // src/inputs/Input.jsx
298
+ var import_react6 = __toESM(require("react"));
299
+ var CustomInput = ({
300
+ id = "input",
301
+ label,
302
+ isRequired,
303
+ value,
304
+ onChange,
305
+ placeholder,
306
+ disabled = false,
307
+ error,
308
+ heading
309
+ }) => {
310
+ return /* @__PURE__ */ import_react6.default.createElement("div", { className: "flex flex-col gap-1 w-full", id: `${id}-div-1` }, heading && /* @__PURE__ */ import_react6.default.createElement("h3", { className: "text-lg font-semibold", id: `${id}-h3-1` }, heading), /* @__PURE__ */ import_react6.default.createElement(
311
+ "label",
312
+ {
313
+ className: `font-[500] text-sm ${heading ? "text-[#737373]" : "text-black"} dark:text-white`,
314
+ id: `${id}-label-1`
315
+ },
316
+ label,
317
+ " ",
318
+ isRequired && /* @__PURE__ */ import_react6.default.createElement("span", { className: "text-red-500", id: `${id}-span-1` }, "*")
319
+ ), /* @__PURE__ */ import_react6.default.createElement(
320
+ "input",
321
+ {
322
+ className: `border border-gray-200 rounded-md h-10 px-4 py-2 w-full text-[14px]
323
+ focus:outline-2 outline-black dark:outline-white outline-offset-2
324
+ dark:bg-transparent dark:text-white dark:border-[#303036]
325
+ ${disabled ? "bg-gray-100 cursor-not-allowed text-gray-500 border-gray-300" : error ? "border-red-500 bg-red-50" : "bg-white border-[hsl(0_0%_89.8%)]"}
326
+ `,
327
+ value,
328
+ onChange: (e) => onChange == null ? void 0 : onChange(e.target.value),
329
+ placeholder,
330
+ disabled,
331
+ readOnly: disabled,
332
+ id: `${id}-input-1`
333
+ }
334
+ ));
335
+ };
336
+
337
+ // src/inputs/ProgressBar.jsx
338
+ var import_react7 = __toESM(require("react"));
339
+ var ProgressBar = ({ id = "progress-bar", step, totalSteps }) => {
340
+ const progress = step / totalSteps * 100;
341
+ return /* @__PURE__ */ import_react7.default.createElement("div", { className: "mb-6", id: `${id}-div-1` }, /* @__PURE__ */ import_react7.default.createElement("p", { className: "text-gray-600 text-sm mb-2", id: `${id}-p-1` }, "Step ", step, " of ", totalSteps), /* @__PURE__ */ import_react7.default.createElement("div", { className: "w-full bg-gray-200 rounded-full h-2", id: `${id}-div-2` }, /* @__PURE__ */ import_react7.default.createElement(
342
+ "div",
343
+ {
344
+ className: "bg-black h-2 rounded-full transition-all duration-300",
345
+ style: { width: `${progress}%` },
346
+ id: `${id}-div-3`
347
+ }
348
+ )));
349
+ };
350
+
351
+ // src/inputs/Search.jsx
352
+ var import_react8 = __toESM(require("react"));
353
+ var import_lucide_react2 = require("lucide-react");
354
+ var CustomSearch = ({
355
+ id = "search",
356
+ value,
357
+ onChange,
358
+ placeholder = "Search Markets..."
359
+ }) => {
360
+ return /* @__PURE__ */ import_react8.default.createElement("div", { className: "flex items-center border bg-transparent text-[14px] border-[hsl(0_0%_89.8%)] dark:border-[#303036] \r\n rounded-md h-10 px-2 w-full focus-within:outline-2 focus-within:outline-black focus-within:outline-offset-2 dark:text-white", id: `${id}-div-1` }, /* @__PURE__ */ import_react8.default.createElement(import_lucide_react2.Search, { width: 16, height: 16, color: "gray", className: "mr-2" }), /* @__PURE__ */ import_react8.default.createElement(
361
+ "input",
362
+ {
363
+ type: "text",
364
+ value,
365
+ onChange,
366
+ placeholder,
367
+ className: "bg-transparent w-full h-full focus:outline-none",
368
+ id: `${id}-input-1`
369
+ }
370
+ ));
371
+ };
372
+
373
+ // src/inputs/TextArea.jsx
374
+ var import_react9 = __toESM(require("react"));
375
+ var CustomTextarea = ({
376
+ id = "text-area",
377
+ label,
378
+ isRequired,
379
+ value,
380
+ onChange,
381
+ placeholder,
382
+ disabled = false,
383
+ error,
384
+ heading,
385
+ rows = 4
386
+ }) => {
387
+ return /* @__PURE__ */ import_react9.default.createElement("div", { className: "flex flex-col gap-1 w-full", id: `${id}-div-1` }, heading && /* @__PURE__ */ import_react9.default.createElement("h3", { className: "text-lg font-semibold", id: `${id}-h3-1` }, heading), /* @__PURE__ */ import_react9.default.createElement(
388
+ "label",
389
+ {
390
+ className: `font-[500] text-sm ${heading ? "text-[#737373]" : "text-black"}`,
391
+ id: `${id}-label-1`
392
+ },
393
+ label,
394
+ " ",
395
+ isRequired && /* @__PURE__ */ import_react9.default.createElement("span", { className: "text-red-500", id: `${id}-span-1` }, "*")
396
+ ), /* @__PURE__ */ import_react9.default.createElement(
397
+ "textarea",
398
+ {
399
+ rows,
400
+ className: `border rounded-md px-4 py-2 w-full text-[14px]
401
+ focus:outline-2 focus:outline-black focus:outline-offset-2
402
+ focus:ring-0 focus:shadow-none focus:border-black
403
+ ${disabled ? "bg-gray-100 text-gray-500 border-gray-300" : error ? "border-red-500 bg-red-50" : "bg-white border-[hsl(0_0%_89.8%)]"}
404
+ `,
405
+ value,
406
+ onChange: (e) => onChange == null ? void 0 : onChange(e.target.value),
407
+ placeholder,
408
+ disabled,
409
+ readOnly: disabled,
410
+ id: `${id}-textarea-1`
411
+ }
412
+ ));
413
+ };
414
+
415
+ // src/inputs/Upload.jsx
416
+ var import_react10 = __toESM(require("react"));
417
+ var import_lucide_react3 = require("lucide-react");
418
+ var CustomUpload = ({
419
+ id = "upload",
420
+ label = "Supporting documents",
421
+ description = "Drop items here or Browse Files",
422
+ accept = ".pdf,.jpg,.jpeg,.png",
423
+ maxSizeMB = 5,
424
+ onChange,
425
+ error,
426
+ value
427
+ }) => {
428
+ const inputRef = (0, import_react10.useRef)(null);
429
+ const handleFileSelect = (files) => {
430
+ if (!files || files.length === 0) return;
431
+ const selectedFile = files[0];
432
+ if (selectedFile.size > maxSizeMB * 1024 * 1024) {
433
+ alert(`File size must be less than ${maxSizeMB} MB`);
434
+ return;
435
+ }
436
+ onChange == null ? void 0 : onChange(selectedFile);
437
+ };
438
+ return /* @__PURE__ */ import_react10.default.createElement("div", { className: "flex flex-col gap-2 w-full", id: `${id}-div-1` }, label && /* @__PURE__ */ import_react10.default.createElement("label", { className: "text-sm font-medium", id: `${id}-label-1` }, label), /* @__PURE__ */ import_react10.default.createElement(
439
+ "div",
440
+ {
441
+ className: `border-2 border-dashed rounded-lg p-6 flex flex-col items-center justify-center text-center cursor-pointer transition
442
+ ${error ? "border-red-500 bg-red-50" : "border-gray-300 hover:border-gray-400 bg-gray-50"}`,
443
+ onClick: () => {
444
+ var _a;
445
+ return (_a = inputRef.current) == null ? void 0 : _a.click();
446
+ },
447
+ onDragOver: (e) => e.preventDefault(),
448
+ onDrop: (e) => {
449
+ e.preventDefault();
450
+ handleFileSelect(e.dataTransfer.files);
451
+ },
452
+ id: `${id}-div-2`
453
+ },
454
+ /* @__PURE__ */ import_react10.default.createElement(import_lucide_react3.Upload, { className: "w-6 h-6 text-gray-500 mb-2" }),
455
+ /* @__PURE__ */ import_react10.default.createElement("p", { className: "text-sm text-gray-700", id: `${id}-p-1` }, description),
456
+ /* @__PURE__ */ import_react10.default.createElement("p", { className: "text-xs text-gray-500 mt-1", id: `${id}-p-2` }, "File Supported: PDF/JPG/PNG, up to ", maxSizeMB, " MB"),
457
+ /* @__PURE__ */ import_react10.default.createElement(
458
+ "input",
459
+ {
460
+ ref: inputRef,
461
+ type: "file",
462
+ accept,
463
+ className: "hidden",
464
+ onChange: (e) => handleFileSelect(e.target.files),
465
+ id: `${id}-input-1`
466
+ }
467
+ )
468
+ ), value && /* @__PURE__ */ import_react10.default.createElement("span", { className: "text-sm truncate text-gray-500", id: `${id}-span-1` }, "Selected: ", value.name), error && /* @__PURE__ */ import_react10.default.createElement("p", { className: "text-xs text-red-500", id: `${id}-p-3` }, error));
469
+ };
470
+
471
+ // src/sideBar/SideBar.jsx
472
+ var import_lucide_react8 = require("lucide-react");
473
+ var import_react14 = __toESM(require("react"));
474
+
475
+ // ConstantUI.js
476
+ var import_lucide_react4 = require("lucide-react");
477
+ var encodedAuthData = localStorage.getItem("encodedAuthData");
478
+ var navItemsConstant = [
479
+ {
480
+ Icon: import_lucide_react4.Home,
481
+ label: "Home",
482
+ onClick: () => {
483
+ window.location.href = "/";
484
+ },
485
+ isDropDown: false
486
+ },
487
+ {
488
+ Icon: import_lucide_react4.Building,
489
+ label: "Consumer Ecosystem",
490
+ onClick: () => {
491
+ },
492
+ options: [
493
+ {
494
+ label: "Corporate",
495
+ onClick: () => {
496
+ window.location.href = "/corporate/";
497
+ }
498
+ },
499
+ {
500
+ label: "Trips",
501
+ onClick: () => {
502
+ window.location.href = "/trips/";
503
+ }
504
+ },
505
+ {
506
+ label: "Users",
507
+ onClick: () => {
508
+ window.location.href = "/users/users";
509
+ }
510
+ },
511
+ {
512
+ label: "Tags (Custom Variables)",
513
+ onClick: () => {
514
+ window.location.href = "/orgselector/?path=tag";
515
+ }
516
+ },
517
+ {
518
+ label: "Special Request",
519
+ onClick: () => {
520
+ window.location.href = "/orgselector/?path=special-requests";
521
+ }
522
+ },
523
+ {
524
+ label: "Support Tickets (Coming Soon)",
525
+ isDisabled: true
526
+ // onClick: () => {},
527
+ }
528
+ ],
529
+ isDropDown: true
530
+ },
531
+ {
532
+ Icon: import_lucide_react4.Banknote,
533
+ label: "Finance",
534
+ onClick: () => {
535
+ },
536
+ isDropDown: true,
537
+ options: [
538
+ {
539
+ label: "Credit Management",
540
+ onClick: () => {
541
+ window.location.href = "/finance/paymentsLedger/";
542
+ }
543
+ },
544
+ {
545
+ label: "Booking & Invoices",
546
+ onClick: () => {
547
+ window.location.href = "/finance/bookingHistory/";
548
+ }
549
+ }
550
+ ]
551
+ },
552
+ {
553
+ Icon: import_lucide_react4.DollarSign,
554
+ label: "Revenue Management",
555
+ onClick: () => {
556
+ },
557
+ isDropDown: true,
558
+ options: [
559
+ {
560
+ label: "Pricing Engine",
561
+ onClick: () => {
562
+ window.location.href = "/orgselector/?path=pricing-policy";
563
+ }
564
+ },
565
+ {
566
+ label: "Offers",
567
+ onClick: () => {
568
+ window.location.href = "/orgselector/?path=offer";
569
+ }
570
+ },
571
+ {
572
+ label: "Vouchers",
573
+ onClick: () => {
574
+ window.location.href = "/orgselector/?path=voucher";
575
+ }
576
+ }
577
+ ]
578
+ },
579
+ {
580
+ Icon: import_lucide_react4.Handshake,
581
+ label: "Supplier Ecosystem",
582
+ onClick: () => {
583
+ },
584
+ isDropDown: true,
585
+ options: [
586
+ {
587
+ label: "Suppliers List",
588
+ onClick: () => {
589
+ window.location.href = "/orgselector/?path=supplier-list";
590
+ }
591
+ },
592
+ {
593
+ label: "Supplier Deals",
594
+ onClick: () => {
595
+ window.location.href = "/supplierdeals/";
596
+ }
597
+ }
598
+ ]
599
+ },
600
+ {
601
+ Icon: import_lucide_react4.BarChart3,
602
+ label: "Reports",
603
+ onClick: () => {
604
+ },
605
+ isDropDown: true,
606
+ options: [
607
+ {
608
+ label: "Reports (Coming Soon)",
609
+ isDisabled: true
610
+ // onClick: () => {
611
+ // window.open("https://viz.jett.travel", "_blank");
612
+ // },
613
+ }
614
+ ]
615
+ },
616
+ {
617
+ Icon: import_lucide_react4.Cog,
618
+ label: "Settings",
619
+ onClick: () => {
620
+ },
621
+ isDropDown: true,
622
+ options: [
623
+ {
624
+ label: "Whitelabel",
625
+ onClick: () => {
626
+ window.location.href = "/whitelabel/";
627
+ }
628
+ },
629
+ {
630
+ label: "Markets",
631
+ onClick: () => {
632
+ window.location.href = "/market/";
633
+ }
634
+ },
635
+ {
636
+ label: "Users",
637
+ onClick: () => {
638
+ window.location.href = `/users/users?role=admin&auth=${encodedAuthData}`;
639
+ }
640
+ },
641
+ {
642
+ label: "Reports Configurations (Coming Soon)",
643
+ isDisabled: true
644
+ // onClick: () => {},
645
+ }
646
+ ]
647
+ }
648
+ ];
649
+ var additionalItemsConstant = [
650
+ {
651
+ Icon: import_lucide_react4.LifeBuoy,
652
+ label: "Help",
653
+ onClick: () => {
654
+ window.location.href = "/help";
655
+ }
656
+ }
657
+ ];
658
+
659
+ // src/sideBar/SideBar.jsx
660
+ var import_js_cookie = __toESM(require("js-cookie"));
661
+
662
+ // src/inputs/CustomSelect.jsx
663
+ var import_react11 = __toESM(require("react"));
664
+ var import_lucide_react5 = require("lucide-react");
665
+ var CustomSelect = ({
666
+ id = "custom-select",
667
+ label,
668
+ value,
669
+ onChange,
670
+ options,
671
+ placeholder = "Select...",
672
+ isRequired = false,
673
+ error,
674
+ heading,
675
+ disabled = false
676
+ }) => {
677
+ const [open, setOpen] = (0, import_react11.useState)(false);
678
+ const [search, setSearch] = (0, import_react11.useState)("");
679
+ const wrapperRef = (0, import_react11.useRef)(null);
680
+ const handleBlur = (e) => {
681
+ var _a;
682
+ if (!((_a = wrapperRef.current) == null ? void 0 : _a.contains(e.relatedTarget))) {
683
+ setOpen(false);
684
+ }
685
+ };
686
+ const filteredOptions = options.filter(
687
+ (opt) => opt.label.toLowerCase().includes(search.toLowerCase())
688
+ );
689
+ const handleSelect = (val) => {
690
+ onChange(val);
691
+ setOpen(false);
692
+ };
693
+ const selectedOption = options.find((opt) => opt.value === value);
694
+ return /* @__PURE__ */ import_react11.default.createElement(
695
+ "div",
696
+ {
697
+ className: "flex flex-col w-full relative",
698
+ ref: wrapperRef,
699
+ tabIndex: disabled ? -1 : 0,
700
+ onBlur: handleBlur,
701
+ id: `${id}-div-1`
702
+ },
703
+ heading && /* @__PURE__ */ import_react11.default.createElement("h3", { className: "text-lg font-semibold mb-1", id: `${id}-h3-1` }, heading),
704
+ label && /* @__PURE__ */ import_react11.default.createElement(
705
+ "label",
706
+ {
707
+ className: `font-medium text-sm mb-1 ${heading ? "text-[#737373] dark:text-white" : "text-black dark:text-white"}`,
708
+ id: `${id}-label-1`
709
+ },
710
+ label,
711
+ " ",
712
+ isRequired && /* @__PURE__ */ import_react11.default.createElement("span", { className: "text-red-500", id: `${id}-span-1` }, "*")
713
+ ),
714
+ /* @__PURE__ */ import_react11.default.createElement(
715
+ "div",
716
+ {
717
+ onClick: () => !disabled && setOpen((prev) => !prev),
718
+ className: `flex justify-between items-center rounded-md px-3 py-2 text-sm border h-10 cursor-pointer dark:border-[#303036] dark:bg-[#18181b] dark:text-white
719
+ ${disabled ? "bg-gray-100 text-gray-400" : "bg-white dark:bg-[#18181b] dark:text-white"}
720
+ ${error ? "border-red-500" : "border-gray-300"}
721
+ `,
722
+ id: `${id}-div-2`
723
+ },
724
+ /* @__PURE__ */ import_react11.default.createElement("span", { className: `${selectedOption ? "text-black dark:text-white" : "text-gray-400 dark:text-white"}`, id: `${id}-span-2` }, selectedOption ? selectedOption.label : placeholder),
725
+ /* @__PURE__ */ import_react11.default.createElement(
726
+ import_lucide_react5.ChevronDown,
727
+ {
728
+ className: `w-4 h-4 text-gray-500 transition-transform dark:text-white ${open ? "rotate-180" : ""}`
729
+ }
730
+ )
731
+ ),
732
+ open && !disabled && /* @__PURE__ */ import_react11.default.createElement("div", { className: "absolute top-full mt-1 w-full bg-white border border-gray-200 rounded-lg shadow-lg z-10 max-h-60 overflow-y-auto dark:bg-[#18181b] dark:text-white", id: `${id}-div-3` }, /* @__PURE__ */ import_react11.default.createElement("div", { className: "flex items-center gap-2 p-2 border-b border-gray-200", id: `${id}-div-4` }, /* @__PURE__ */ import_react11.default.createElement(import_lucide_react5.Search, { size: 16, className: "text-gray-400" }), /* @__PURE__ */ import_react11.default.createElement(
733
+ "input",
734
+ {
735
+ type: "text",
736
+ value: search,
737
+ onChange: (e) => setSearch(e.target.value),
738
+ placeholder: "Search...",
739
+ className: "flex-1 text-sm focus:outline-none",
740
+ id: `${id}-input-1`
741
+ }
742
+ )), /* @__PURE__ */ import_react11.default.createElement("ul", { id: `${id}-ul-1` }, filteredOptions.length > 0 ? filteredOptions.map((opt) => /* @__PURE__ */ import_react11.default.createElement(
743
+ "li",
744
+ {
745
+ key: opt.value,
746
+ onClick: () => handleSelect(opt.value),
747
+ className: `px-3 py-2 text-sm cursor-pointer hover:bg-gray-100 dark:hover:bg-[#27272a] ${value === opt.value ? "bg-gray-100 font-medium dark:bg-[#27272a] dark:text-white" : ""}`,
748
+ id: `${id}-li-1`
749
+ },
750
+ opt.label
751
+ )) : /* @__PURE__ */ import_react11.default.createElement("li", { className: "px-3 py-2 text-sm text-gray-400 dark:text-white", id: `${id}-li-2` }, "No results found")))
752
+ );
753
+ };
754
+
755
+ // src/utils/cookieHelpers.js
756
+ var JETT_ID_COOKIE_NAME = "jett-id";
757
+ function getCookie(name) {
758
+ if (typeof document === "undefined" || !document.cookie) return null;
759
+ const match = document.cookie.match(
760
+ new RegExp("(^|\\s)" + name + "=([^;]+)")
761
+ );
762
+ return match ? decodeURIComponent(match[2].trim()) : null;
763
+ }
764
+ function decodeBase64(value) {
765
+ try {
766
+ let base64 = value.replace(/-/g, "+").replace(/_/g, "/");
767
+ const pad = base64.length % 4;
768
+ if (pad) base64 += "=".repeat(4 - pad);
769
+ return atob(base64);
770
+ } catch {
771
+ return "";
772
+ }
773
+ }
774
+ function getJettIdCookieData() {
775
+ const raw = getCookie(JETT_ID_COOKIE_NAME);
776
+ if (!raw) return null;
777
+ try {
778
+ const decoded = decodeBase64(raw);
779
+ if (!decoded) return null;
780
+ const data = JSON.parse(decoded);
781
+ return data && typeof data === "object" ? data : null;
782
+ } catch {
783
+ return null;
784
+ }
785
+ }
786
+ function getLogoFromJettIdCookie() {
787
+ const data = getJettIdCookieData();
788
+ if (!(data == null ? void 0 : data.CDNBasePath)) return null;
789
+ const logoPath = (data.OrgLogo || data.TmcLogo || "").trim();
790
+ if (!logoPath) return null;
791
+ return {
792
+ logoPath,
793
+ CDNBasePath: data.CDNBasePath
794
+ };
795
+ }
796
+ function getScopeFromJettIdCookie() {
797
+ const data = getJettIdCookieData();
798
+ return (data == null ? void 0 : data.Scope) ?? null;
799
+ }
800
+ function getProfilesFromJettIdCookie(all) {
801
+ const data = getJettIdCookieData();
802
+ if (!(data == null ? void 0 : data.Profiles)) return [];
803
+ if (all) return data.Profiles;
804
+ return data.Profiles.filter((profile) => {
805
+ var _a;
806
+ return (_a = profile.Scope) == null ? void 0 : _a.endsWith("_ENTITY");
807
+ });
808
+ }
809
+ function buildLogoUrl(CDNBasePath, logoPath) {
810
+ const base = (CDNBasePath || "").replace(/\/$/, "");
811
+ const path = (logoPath || "").replace(/^\//, "");
812
+ if (!base || !path) return "";
813
+ return `${base}/${path}`;
814
+ }
815
+
816
+ // src/sideBar/SwitchProfileSection.jsx
817
+ var import_react13 = __toESM(require("react"));
818
+ var import_react_dom2 = require("react-dom");
819
+ var import_lucide_react7 = require("lucide-react");
820
+
821
+ // src/sideBar/LogoutConfirmModal.jsx
822
+ var import_react12 = __toESM(require("react"));
823
+ var import_react_dom = require("react-dom");
824
+ var import_lucide_react6 = require("lucide-react");
825
+ var LogoutConfirmModal = ({
826
+ id = "logout-confirm",
827
+ open,
828
+ onConfirm,
829
+ onCancel,
830
+ loading = false
831
+ }) => {
832
+ if (!open || typeof document === "undefined") return null;
833
+ const handleOverlayClick = (e) => {
834
+ if (e.target === e.currentTarget && !loading) onCancel();
835
+ };
836
+ return (0, import_react_dom.createPortal)(
837
+ /* @__PURE__ */ import_react12.default.createElement(
838
+ "div",
839
+ {
840
+ className: "fixed inset-0 z-[10000] flex items-center justify-center bg-black/50",
841
+ onClick: handleOverlayClick,
842
+ id: `${id}-overlay`
843
+ },
844
+ /* @__PURE__ */ import_react12.default.createElement("div", { className: "w-[360px] rounded-2xl bg-white dark:bg-[#18181b] p-6 text-center shadow-2xl", id: `${id}-dialog` }, /* @__PURE__ */ import_react12.default.createElement("div", { className: "mx-auto mb-4 flex h-16 w-16 items-center justify-center rounded-full bg-blue-50 dark:bg-blue-950/40", id: `${id}-icon` }, /* @__PURE__ */ import_react12.default.createElement(import_lucide_react6.LogOut, { className: "text-blue-600", width: 28, height: 28 })), /* @__PURE__ */ import_react12.default.createElement("p", { className: "!text-[22px] !font-semibold text-gray-900 dark:text-white" }, "Are you sure you want to logout?"), /* @__PURE__ */ import_react12.default.createElement("div", { className: "mt-6 flex gap-3" }, /* @__PURE__ */ import_react12.default.createElement(
845
+ "button",
846
+ {
847
+ type: "button",
848
+ onClick: onCancel,
849
+ disabled: loading,
850
+ className: "flex-1 no-wrap rounded-lg border border-gray-300 dark:border-[#303036] px-4 py-2 text-[14px] font-medium text-gray-700 dark:text-[#f4f4f5cc] cursor-pointer hover:bg-gray-50 dark:hover:bg-[#27272a] disabled:opacity-50 disabled:cursor-not-allowed transition-colors duration-200",
851
+ id: `${id}-cancel-button`
852
+ },
853
+ "No, Keep me in"
854
+ ), /* @__PURE__ */ import_react12.default.createElement(
855
+ "button",
856
+ {
857
+ type: "button",
858
+ onClick: onConfirm,
859
+ disabled: loading,
860
+ className: "flex-1 rounded-lg bg-red-600 px-4 py-2 text-[14px] font-medium text-white cursor-pointer hover:bg-red-700 disabled:opacity-50 disabled:cursor-not-allowed transition-colors duration-200",
861
+ id: `${id}-confirm-button`
862
+ },
863
+ loading ? "Logging out..." : "Yes, logout"
864
+ )))
865
+ ),
866
+ document.body
867
+ );
868
+ };
869
+
870
+ // src/utils/switchProfileEncryption.js
871
+ var import_node_forge = __toESM(require("node-forge"));
872
+ var RSA_MODULUS_BASE64 = "zktSGmyKa5SR8HO540HKTdgDPVmXafgGFrf4OYtRNApRssnt0hGoMU7Jitc/SVWbPstFshIi5XblbDL2NXWYhZtj4PWL4SKc1/bM02xxabPw/eFr3XAAPCF62WxAVPsJBbEoAB0AcOCeIcGHb+tzLtXQJAvOuIBsKLQiiB7/c9ltt5AVVM4si1RC3JsxpqcGTkgwnh+FMg8CFvLdHjh/oi789wj8zoGWLAdYSBBa8IoQgTuzZt1tft2LF0y4Ck3yT8F9TX5GbAiVXb0G9cM/hUmDNz/6xOvHuOfH5147tKDUNCT/sr5tEaLm5ePUmRdpoc5PZa04q1KGJ0rxf6T55E5pQ8Qh2EFr1yPyLh12wiSTRsnHwXwVsosbNNBBN3HdBOMklTQx2VJNDHpi19G+z4d1evlS8yDqNZe9QyRFKEsTd+xPg3ob3j/ObpYDOtXoMaw8fXWbvyG4MJTz7nWG5YL2s5oWSAFZ4mifgwOmM/OuTO/uholelws25k/a3+O/s5Xd/HOugBvpeb5azGLfMHrGvu6J9DSIVI28hfbaFm2+smjyLdS+5PWV2+hM9EQLgaw/euGx4Qhzo2nagLwl9+hNOZ2gjtNHJxJtbQJTNrE90d3mX2/yfxHzh8FiiAiraxiZCgdUQeEZbZNlAwQLHIYWazSqgmRhf4D1LGMMrak=";
873
+ var RSA_EXPONENT_BASE64 = "AQAB";
874
+ var convertModulusExponentToPem = (modulus, exponent) => {
875
+ const decodedModulus = import_node_forge.default.util.decode64(modulus);
876
+ const decodedExponent = import_node_forge.default.util.decode64(exponent);
877
+ const publicKey = import_node_forge.default.pki.setRsaPublicKey(
878
+ new import_node_forge.default.jsbn.BigInteger(import_node_forge.default.util.bytesToHex(decodedModulus), 16),
879
+ new import_node_forge.default.jsbn.BigInteger(import_node_forge.default.util.bytesToHex(decodedExponent), 16)
880
+ );
881
+ return import_node_forge.default.pki.publicKeyToPem(publicKey);
882
+ };
883
+ var cachedPemKey = null;
884
+ var getPemKey = () => {
885
+ if (!cachedPemKey) {
886
+ cachedPemKey = convertModulusExponentToPem(RSA_MODULUS_BASE64, RSA_EXPONENT_BASE64);
887
+ }
888
+ return cachedPemKey;
889
+ };
890
+ var encryptForSwitchProfile = (plainText) => {
891
+ const publicKey = import_node_forge.default.pki.publicKeyFromPem(getPemKey());
892
+ const encrypted = publicKey.encrypt(plainText, "RSAES-PKCS1-V1_5");
893
+ return import_node_forge.default.util.encode64(encrypted).replace(/\r?\n|\r/g, "");
894
+ };
895
+
896
+ // src/sideBar/SwitchProfileSection.jsx
897
+ var SwitchProfileSection = ({
898
+ id = "switch-profile",
899
+ open,
900
+ anchorRef,
901
+ onClose,
902
+ onManageProfile,
903
+ onProfileSwitch,
904
+ onTmcSettings,
905
+ onLogout
906
+ }) => {
907
+ const [position, setPosition] = (0, import_react13.useState)(null);
908
+ const [showLogoutConfirm, setShowLogoutConfirm] = (0, import_react13.useState)(false);
909
+ const [switchingProfileId, setSwitchingProfileId] = (0, import_react13.useState)(null);
910
+ (0, import_react13.useLayoutEffect)(() => {
911
+ if (!open || !(anchorRef == null ? void 0 : anchorRef.current)) return;
912
+ const updatePosition = () => {
913
+ const rect = anchorRef.current.getBoundingClientRect();
914
+ setPosition({
915
+ left: rect.right + 12,
916
+ bottom: window.innerHeight - rect.bottom
917
+ });
918
+ };
919
+ updatePosition();
920
+ window.addEventListener("resize", updatePosition);
921
+ window.addEventListener("scroll", updatePosition, true);
922
+ return () => {
923
+ window.removeEventListener("resize", updatePosition);
924
+ window.removeEventListener("scroll", updatePosition, true);
925
+ };
926
+ }, [open, anchorRef]);
927
+ if (!open && !showLogoutConfirm || typeof document === "undefined") return null;
928
+ const jettIdData = getJettIdCookieData();
929
+ const userName = (jettIdData == null ? void 0 : jettIdData.UserName) || "";
930
+ const userEmail = (jettIdData == null ? void 0 : jettIdData.UserEmail) || "";
931
+ const currentProfileId = jettIdData == null ? void 0 : jettIdData.ProfileId;
932
+ const allMarkets = getProfilesFromJettIdCookie(true);
933
+ const markets = allMarkets.length ? allMarkets : (jettIdData == null ? void 0 : jettIdData.EntityName) ? [{ ProfileId: currentProfileId, EntityName: jettIdData.EntityName }] : [];
934
+ const handleConfirmLogout = () => {
935
+ setShowLogoutConfirm(false);
936
+ onLogout == null ? void 0 : onLogout();
937
+ };
938
+ const buildRequestContext = () => ({
939
+ UserAgent: typeof navigator !== "undefined" ? navigator.userAgent : "Mozilla/5.0",
940
+ TrackingId: crypto.randomUUID(),
941
+ TransactionId: crypto.randomUUID(),
942
+ CountryCode: "IN",
943
+ IpAddress: "127.0.0.1"
944
+ // Client IP cannot be retrieved from browser
945
+ });
946
+ const handleProfileSwitch = async (profile) => {
947
+ var _a;
948
+ if (switchingProfileId) return;
949
+ setSwitchingProfileId(profile.ProfileId);
950
+ try {
951
+ const encryptedRequest = encryptForSwitchProfile(
952
+ JSON.stringify({
953
+ ProfileToken: profile.ProfileToken,
954
+ ProfileId: profile.ProfileId
955
+ })
956
+ );
957
+ const response = await fetch(`${window.location.origin}/auth/switch/profile`, {
958
+ method: "POST",
959
+ credentials: "include",
960
+ headers: { "Content-Type": "application/json" },
961
+ body: JSON.stringify({
962
+ Context: buildRequestContext(),
963
+ Request: encryptedRequest
964
+ })
965
+ }).then((res) => res.json());
966
+ if ((_a = response == null ? void 0 : response.Response) == null ? void 0 : _a.RedirectUrl) {
967
+ window.location.href = response.Response.RedirectUrl;
968
+ return;
969
+ }
970
+ setSwitchingProfileId(null);
971
+ onProfileSwitch == null ? void 0 : onProfileSwitch(profile);
972
+ } catch (error) {
973
+ console.error("Switch profile request failed:", error);
974
+ setSwitchingProfileId(null);
975
+ onProfileSwitch == null ? void 0 : onProfileSwitch(profile);
976
+ }
977
+ };
978
+ return /* @__PURE__ */ import_react13.default.createElement(import_react13.default.Fragment, null, open && (0, import_react_dom2.createPortal)(
979
+ /* @__PURE__ */ import_react13.default.createElement(import_react13.default.Fragment, null, /* @__PURE__ */ import_react13.default.createElement("div", { className: "fixed inset-0 z-[9999]", onClick: onClose, id: `${id}-backdrop` }), /* @__PURE__ */ import_react13.default.createElement(
980
+ "div",
981
+ {
982
+ className: "fixed w-[370px] max-h-[75vh] flex flex-col overflow-hidden bg-white dark:bg-[#18181b] rounded-xl shadow-xl border border-gray-200 dark:border-[#303036] z-[9999]",
983
+ style: position ? { left: position.left, bottom: position.bottom } : { left: -9999, bottom: 0 },
984
+ id: `${id}-panel`
985
+ },
986
+ /* @__PURE__ */ import_react13.default.createElement("div", { className: "flex items-center justify-between gap-3 p-4", id: `${id}-header` }, /* @__PURE__ */ import_react13.default.createElement("div", { className: "flex items-center gap-3 min-w-0", id: `${id}-header-user` }, /* @__PURE__ */ import_react13.default.createElement("span", { className: "relative flex shrink-0 overflow-hidden rounded-full h-10 w-10", id: `${id}-avatar` }, /* @__PURE__ */ import_react13.default.createElement("span", { className: "flex h-full w-full items-center justify-center !text-[16px] !font-normal border border-gray-200 dark:border-[#303036] rounded-full bg-muted dark:text-white" }, userName ? userName.charAt(0) : "A")), /* @__PURE__ */ import_react13.default.createElement("div", { className: "min-w-0", id: `${id}-header-text` }, /* @__PURE__ */ import_react13.default.createElement("p", { className: "!font-semibold dark:text-white !text-[15px] truncate" }, userName || "Admin"), /* @__PURE__ */ import_react13.default.createElement("p", { className: "!text-[13px] !font-normal text-gray-500 dark:text-[#f4f4f5cc] truncate" }, userEmail))), /* @__PURE__ */ import_react13.default.createElement(
987
+ "button",
988
+ {
989
+ type: "button",
990
+ onClick: onManageProfile,
991
+ className: "shrink-0 whitespace-nowrap rounded-md border border-gray-300 dark:border-[#303036] px-3 py-1.5 text-[11px] font-semibold uppercase tracking-wide text-gray-700 dark:text-[#f4f4f5cc] cursor-pointer hover:bg-gray-50 dark:hover:bg-[#27272a] transition-colors duration-200",
992
+ id: `${id}-manage-profile-button`
993
+ },
994
+ "Manage Profile"
995
+ )),
996
+ /* @__PURE__ */ import_react13.default.createElement("div", { className: "border-t border-gray-200 dark:border-[#303036]" }),
997
+ /* @__PURE__ */ import_react13.default.createElement("div", { className: "overflow-y-auto scrollbar-hide", id: `${id}-body` }, /* @__PURE__ */ import_react13.default.createElement("p", { className: "px-4 pt-3 pb-2 text-[11px] font-semibold tracking-wider text-gray-400 uppercase", id: `${id}-markets-label` }, "Your Markets"), /* @__PURE__ */ import_react13.default.createElement("div", { className: "flex flex-col gap-1 px-2 pb-2", id: `${id}-markets-list` }, markets.length === 0 && /* @__PURE__ */ import_react13.default.createElement("p", { className: "px-2 py-2 text-[13px] text-gray-400", id: `${id}-markets-empty` }, "No markets available"), markets.map((profile) => {
998
+ const isCurrent = profile.ProfileId === currentProfileId;
999
+ const isSwitching = switchingProfileId === profile.ProfileId;
1000
+ return /* @__PURE__ */ import_react13.default.createElement(
1001
+ "div",
1002
+ {
1003
+ key: profile.ProfileId,
1004
+ onClick: () => !isCurrent && handleProfileSwitch(profile),
1005
+ "aria-disabled": isSwitching,
1006
+ className: `flex items-center justify-between gap-2 rounded-lg p-3 cursor-pointer hover:bg-[#f4f4f5] dark:hover:bg-[#27272a] transition-colors duration-200 ${isCurrent ? "border border-gray-800 dark:border-white" : "border border-transparent"} ${isSwitching ? "opacity-50 pointer-events-none" : ""}`,
1007
+ id: `${id}-market-${profile.ProfileId}`
1008
+ },
1009
+ /* @__PURE__ */ import_react13.default.createElement("span", { className: "!font-medium !text-[14px] dark:text-[#f4f4f5cc] truncate" }, profile.EntityName),
1010
+ isCurrent && /* @__PURE__ */ import_react13.default.createElement("span", { className: "shrink-0 rounded-full bg-blue-600 px-2.5 py-0.5 text-[10px] font-bold uppercase tracking-wide text-white" }, "Logged In"),
1011
+ isSwitching && /* @__PURE__ */ import_react13.default.createElement("span", { className: "shrink-0 text-[11px] text-gray-400" }, "Switching...")
1012
+ );
1013
+ }))),
1014
+ /* @__PURE__ */ import_react13.default.createElement("div", { className: "border-t border-gray-200 dark:border-[#303036]" }),
1015
+ /* @__PURE__ */ import_react13.default.createElement("div", { className: "p-2", id: `${id}-footer` }, /* @__PURE__ */ import_react13.default.createElement(
1016
+ "div",
1017
+ {
1018
+ onClick: () => {
1019
+ onClose == null ? void 0 : onClose();
1020
+ setShowLogoutConfirm(true);
1021
+ },
1022
+ className: "flex items-center gap-3 rounded-lg p-3 cursor-pointer text-red-600 hover:bg-red-50 dark:hover:bg-[#27272a] transition-colors duration-200",
1023
+ id: `${id}-logout`
1024
+ },
1025
+ /* @__PURE__ */ import_react13.default.createElement(import_lucide_react7.LogOut, { width: 18, height: 18 }),
1026
+ /* @__PURE__ */ import_react13.default.createElement("span", { className: "!font-medium !text-[14px]" }, "Logout")
1027
+ ))
1028
+ )),
1029
+ document.body
1030
+ ), /* @__PURE__ */ import_react13.default.createElement(
1031
+ LogoutConfirmModal,
1032
+ {
1033
+ id: `${id}-logout-confirm`,
1034
+ open: showLogoutConfirm,
1035
+ onCancel: () => setShowLogoutConfirm(false),
1036
+ onConfirm: handleConfirmLogout
1037
+ }
1038
+ ));
1039
+ };
1040
+
1041
+ // src/sideBar/SideBar.jsx
1042
+ var SCOPE_LABELS = {
1043
+ TMC: "TMC Manager",
1044
+ TMC_ENTITY: "TMC Entity Manager"
1045
+ };
1046
+ var AppSideBar = ({
1047
+ id = "side-bar",
1048
+ username,
1049
+ navItems,
1050
+ additionalItems,
1051
+ sideBarLogo,
1052
+ onManageProfile,
1053
+ onProfileSwitch,
1054
+ onTmcSettings,
1055
+ onLogout
1056
+ }) => {
1057
+ var _a, _b;
1058
+ const profileCardRef = (0, import_react14.useRef)(null);
1059
+ const [authData, setAuthData] = (0, import_react14.useState)(null);
1060
+ const [cookieUserName, setCookieUserName] = (0, import_react14.useState)(null);
1061
+ const [scope, setScope] = (0, import_react14.useState)(null);
1062
+ const [selectedCountry, setSelectedCountry] = (0, import_react14.useState)("dubai");
1063
+ const [isMobileMenuOpen, setIsMobileMenuOpen] = (0, import_react14.useState)(false);
1064
+ const [isSwitchProfileOpen, setIsSwitchProfileOpen] = (0, import_react14.useState)(false);
1065
+ const [openMenus, setOpenMenus] = (0, import_react14.useState)(/* @__PURE__ */ new Set());
1066
+ const [activeMenuPath, setActiveMenuPath] = (0, import_react14.useState)(null);
1067
+ const [currAppearance, setCurrAppearance] = (0, import_react14.useState)("light");
1068
+ (0, import_react14.useEffect)(() => {
1069
+ setCurrAppearance("light");
1070
+ }, []);
1071
+ const countryOptions = [
1072
+ { label: "India", value: "india" },
1073
+ { label: "Dubai", value: "dubai" },
1074
+ { label: "Singapore", value: "singapore" },
1075
+ { label: "Qatar", value: "qatar" }
1076
+ ];
1077
+ const toggleMenu = (menuKey) => {
1078
+ setOpenMenus((prev) => {
1079
+ const newSet = new Set(prev);
1080
+ if (newSet.has(menuKey)) {
1081
+ newSet.delete(menuKey);
1082
+ } else {
1083
+ newSet.add(menuKey);
1084
+ }
1085
+ return newSet;
1086
+ });
1087
+ };
1088
+ const isMenuOpen = (menuKey) => {
1089
+ return openMenus.has(menuKey);
1090
+ };
1091
+ const handleMenuClick = (item, index, e) => {
1092
+ if (item.isDropDown) {
1093
+ e.preventDefault();
1094
+ const menuKey = `menu-${index}`;
1095
+ toggleMenu(menuKey);
1096
+ setActiveMenuPath(`menu-${index}`);
1097
+ } else {
1098
+ setActiveMenuPath(`menu-${index}`);
1099
+ if (item.onClick) {
1100
+ item.onClick(e);
1101
+ }
1102
+ closeMobileMenu();
1103
+ }
1104
+ };
1105
+ const handleSubMenuClick = (option, optionsIndex, parentIndex, e) => {
1106
+ const parentMenuKey = `menu-${parentIndex}`;
1107
+ setOpenMenus((prev) => {
1108
+ const newSet = new Set(prev);
1109
+ newSet.add(parentMenuKey);
1110
+ return newSet;
1111
+ });
1112
+ if (option.isDropDown) {
1113
+ e.preventDefault();
1114
+ const menuKey = `menu-${parentIndex}-option-${optionsIndex}`;
1115
+ toggleMenu(menuKey);
1116
+ setActiveMenuPath(`menu-${parentIndex}-option-${optionsIndex}`);
1117
+ } else {
1118
+ setActiveMenuPath(`menu-${parentIndex}-option-${optionsIndex}`);
1119
+ if (option.onClick) {
1120
+ option.onClick();
1121
+ }
1122
+ closeMobileMenu();
1123
+ }
1124
+ };
1125
+ const handleSubSubMenuClick = (subOption, parentIndex, optionsIndex, e) => {
1126
+ const parentMenuKey = `menu-${parentIndex}`;
1127
+ const subMenuKey = `menu-${parentIndex}-option-${optionsIndex}`;
1128
+ setOpenMenus((prev) => {
1129
+ const newSet = new Set(prev);
1130
+ newSet.add(parentMenuKey);
1131
+ newSet.add(subMenuKey);
1132
+ return newSet;
1133
+ });
1134
+ setActiveMenuPath(`menu-${parentIndex}-option-${optionsIndex}-sub-${subOption.label}`);
1135
+ if (subOption.onClick) {
1136
+ subOption.onClick();
1137
+ }
1138
+ closeMobileMenu();
1139
+ };
1140
+ (0, import_react14.useEffect)(() => {
1141
+ const storedAuthData = localStorage.getItem("authData");
1142
+ if (storedAuthData) {
1143
+ let parseData = JSON.parse(storedAuthData);
1144
+ setAuthData(parseData);
1145
+ }
1146
+ }, [localStorage.getItem("authData")]);
1147
+ (0, import_react14.useEffect)(() => {
1148
+ const jettIdData = getJettIdCookieData();
1149
+ if (jettIdData == null ? void 0 : jettIdData.UserName) {
1150
+ setCookieUserName(jettIdData.UserName);
1151
+ }
1152
+ const cookieScope = getScopeFromJettIdCookie();
1153
+ if (cookieScope) {
1154
+ setScope(cookieScope);
1155
+ }
1156
+ }, []);
1157
+ const extractUrlFromOnClick = (onClick) => {
1158
+ if (!onClick || typeof onClick !== "function") return null;
1159
+ const funcString = onClick.toString();
1160
+ let match = funcString.match(/window\.location\.href\s*=\s*`([^`]+)`/);
1161
+ if (!match) {
1162
+ match = funcString.match(/window\.location\.href\s*=\s*["']([^"']+)["']/);
1163
+ }
1164
+ if (match && match[1]) {
1165
+ try {
1166
+ if (match[1].startsWith("http://") || match[1].startsWith("https://")) {
1167
+ const url = new URL(match[1]);
1168
+ return {
1169
+ pathname: url.pathname,
1170
+ search: url.search,
1171
+ fullPath: url.pathname + url.search
1172
+ };
1173
+ }
1174
+ if (match[1].startsWith("/")) {
1175
+ const url = new URL(match[1], window.location.origin);
1176
+ return {
1177
+ pathname: url.pathname,
1178
+ search: url.search,
1179
+ fullPath: url.pathname + url.search
1180
+ };
1181
+ }
1182
+ return null;
1183
+ } catch {
1184
+ const pathMatch = match[1].match(/^([^?]+)(\?.*)?$/);
1185
+ if (pathMatch) {
1186
+ return {
1187
+ pathname: pathMatch[1],
1188
+ search: pathMatch[2] || "",
1189
+ fullPath: match[1]
1190
+ };
1191
+ }
1192
+ return null;
1193
+ }
1194
+ }
1195
+ return null;
1196
+ };
1197
+ const currentUrlMatches = (menuUrlData, currentPath, currentSearch) => {
1198
+ if (!menuUrlData || !currentPath) return false;
1199
+ const normalizedMenuPath = menuUrlData.pathname.replace(/\/$/, "") || "/";
1200
+ const normalizedCurrentPath = currentPath.replace(/\/$/, "") || "/";
1201
+ if (normalizedMenuPath === "/users/users" && normalizedCurrentPath === "/users/users") {
1202
+ const menuParams = new URLSearchParams(menuUrlData.search);
1203
+ const currentParams = new URLSearchParams(currentSearch);
1204
+ const menuRole = menuParams.get("role");
1205
+ const currentRole = currentParams.get("role");
1206
+ if (menuRole && currentRole) {
1207
+ return menuRole === currentRole;
1208
+ }
1209
+ if (menuRole && !currentRole || !menuRole && currentRole) {
1210
+ return false;
1211
+ }
1212
+ return true;
1213
+ }
1214
+ if (normalizedMenuPath === "/corporate" && normalizedCurrentPath.startsWith("/org/organizations")) {
1215
+ return true;
1216
+ }
1217
+ if (normalizedMenuPath === "/supplier" && normalizedCurrentPath === "/orgselector") {
1218
+ const currentPathParam = new URLSearchParams(currentSearch).get("path");
1219
+ if (currentPathParam === "supplier-list") {
1220
+ return true;
1221
+ }
1222
+ }
1223
+ if (normalizedMenuPath === "/supplierdeals" && normalizedCurrentPath === "/orgselector") {
1224
+ const currentPathParam = new URLSearchParams(currentSearch).get("path");
1225
+ if (currentPathParam === "supplier-deals") {
1226
+ return true;
1227
+ }
1228
+ }
1229
+ if (normalizedMenuPath === "/trips") {
1230
+ if (normalizedCurrentPath.startsWith("/tripdetails") || normalizedCurrentPath.startsWith("/offline")) {
1231
+ return true;
1232
+ }
1233
+ }
1234
+ if (normalizedMenuPath === "/orgselector" && menuUrlData.search) {
1235
+ const menuPathParam = new URLSearchParams(menuUrlData.search).get("path");
1236
+ if (menuPathParam) {
1237
+ const pathRouteMap = {
1238
+ "offer": "/offer/offer",
1239
+ "voucher": "/voucher/voucher",
1240
+ "tag": "/tags/tags",
1241
+ "special-requests": "/corporate/special-requests",
1242
+ "pricing-policy": "/policies/pricing-policy",
1243
+ "supplier-list": "/supplier",
1244
+ "users": "/users/users"
1245
+ // Consumer Ecosystem Users (no role param)
1246
+ };
1247
+ const expectedRoute = pathRouteMap[menuPathParam];
1248
+ if (expectedRoute) {
1249
+ if (normalizedCurrentPath === expectedRoute || normalizedCurrentPath.startsWith(expectedRoute + "/")) {
1250
+ if (menuPathParam === "users") {
1251
+ const currentParams = new URLSearchParams(currentSearch);
1252
+ const currentRole = currentParams.get("role");
1253
+ return currentRole !== "admin";
1254
+ }
1255
+ return true;
1256
+ }
1257
+ }
1258
+ }
1259
+ if (normalizedCurrentPath === "/orgselector") {
1260
+ const menuPathParam2 = new URLSearchParams(menuUrlData.search).get("path");
1261
+ const currentPathParam = new URLSearchParams(currentSearch).get("path");
1262
+ if (menuPathParam2 && currentPathParam) {
1263
+ return menuPathParam2 === currentPathParam;
1264
+ }
1265
+ }
1266
+ }
1267
+ if (normalizedMenuPath === normalizedCurrentPath) {
1268
+ if (menuUrlData.search) {
1269
+ const menuParams = new URLSearchParams(menuUrlData.search);
1270
+ const currentParams = new URLSearchParams(currentSearch);
1271
+ for (const [key, value] of menuParams.entries()) {
1272
+ if (key === "auth") {
1273
+ continue;
1274
+ }
1275
+ if (currentParams.get(key) !== value) {
1276
+ return false;
1277
+ }
1278
+ }
1279
+ return true;
1280
+ }
1281
+ return true;
1282
+ }
1283
+ if (normalizedCurrentPath.startsWith(normalizedMenuPath + "/")) {
1284
+ return true;
1285
+ }
1286
+ return false;
1287
+ };
1288
+ const navItemsLocal = navItems ?? navItemsConstant;
1289
+ const additionalItemsLocal = additionalItems ?? additionalItemsConstant;
1290
+ const logoFromCookie = getLogoFromJettIdCookie();
1291
+ const logoUrlFromCookie = logoFromCookie ? buildLogoUrl(logoFromCookie.CDNBasePath, logoFromCookie.logoPath) : null;
1292
+ const logoUrlFromUserInfo = ((_a = authData == null ? void 0 : authData.userInfo) == null ? void 0 : _a.CDNBasePath) && ((_b = authData == null ? void 0 : authData.userInfo) == null ? void 0 : _b.OrgLogo) ? buildLogoUrl(
1293
+ authData.userInfo.CDNBasePath,
1294
+ authData.userInfo.OrgLogo
1295
+ ) : null;
1296
+ const sideBarLogoLocal = sideBarLogo ?? logoUrlFromCookie ?? logoUrlFromUserInfo ?? null;
1297
+ const detectAndSetActiveMenu = (0, import_react14.useCallback)(() => {
1298
+ const currentPath = window.location.pathname;
1299
+ const currentSearch = window.location.search;
1300
+ const newOpenMenus = /* @__PURE__ */ new Set();
1301
+ let foundActivePath = null;
1302
+ navItemsLocal.forEach((item, index) => {
1303
+ if (!item.isDropDown && item.onClick && typeof item.onClick === "function") {
1304
+ const itemUrlData = extractUrlFromOnClick(item.onClick);
1305
+ if (itemUrlData && currentUrlMatches(itemUrlData, currentPath, currentSearch)) {
1306
+ foundActivePath = `menu-${index}`;
1307
+ }
1308
+ }
1309
+ if (item.options && item.options.length > 0) {
1310
+ item.options.forEach((option, optionsIndex) => {
1311
+ if (option.onClick && typeof option.onClick === "function") {
1312
+ const optionUrlData = extractUrlFromOnClick(option.onClick);
1313
+ if (optionUrlData && currentUrlMatches(optionUrlData, currentPath, currentSearch)) {
1314
+ const menuKey = `menu-${index}`;
1315
+ newOpenMenus.add(menuKey);
1316
+ foundActivePath = `menu-${index}-option-${optionsIndex}`;
1317
+ if (option.options && option.options.length > 0) {
1318
+ option.options.forEach((subOption, subIndex) => {
1319
+ const subOptionUrlData = extractUrlFromOnClick(subOption.onClick);
1320
+ if (subOptionUrlData && currentUrlMatches(subOptionUrlData, currentPath, currentSearch)) {
1321
+ const subMenuKey = `menu-${index}-option-${optionsIndex}`;
1322
+ newOpenMenus.add(subMenuKey);
1323
+ foundActivePath = `menu-${index}-option-${optionsIndex}-sub-${subOption.label}`;
1324
+ }
1325
+ });
1326
+ }
1327
+ }
1328
+ }
1329
+ });
1330
+ }
1331
+ });
1332
+ if (foundActivePath) {
1333
+ setOpenMenus(newOpenMenus);
1334
+ setActiveMenuPath(foundActivePath);
1335
+ }
1336
+ }, [navItemsLocal]);
1337
+ const [currentUrl, setCurrentUrl] = (0, import_react14.useState)(
1338
+ () => window.location.pathname + window.location.search
1339
+ );
1340
+ (0, import_react14.useEffect)(() => {
1341
+ detectAndSetActiveMenu();
1342
+ setCurrentUrl(window.location.pathname + window.location.search);
1343
+ }, [detectAndSetActiveMenu]);
1344
+ (0, import_react14.useEffect)(() => {
1345
+ let lastUrl = window.location.pathname + window.location.search;
1346
+ const handleLocationChange = () => {
1347
+ const newUrl = window.location.pathname + window.location.search;
1348
+ if (newUrl !== lastUrl) {
1349
+ lastUrl = newUrl;
1350
+ setCurrentUrl(newUrl);
1351
+ detectAndSetActiveMenu();
1352
+ }
1353
+ };
1354
+ window.addEventListener("popstate", handleLocationChange);
1355
+ const checkInterval = setInterval(() => {
1356
+ const newUrl = window.location.pathname + window.location.search;
1357
+ if (newUrl !== lastUrl) {
1358
+ handleLocationChange();
1359
+ }
1360
+ }, 250);
1361
+ return () => {
1362
+ window.removeEventListener("popstate", handleLocationChange);
1363
+ clearInterval(checkInterval);
1364
+ };
1365
+ }, [detectAndSetActiveMenu]);
1366
+ (0, import_react14.useEffect)(() => {
1367
+ detectAndSetActiveMenu();
1368
+ }, [currentUrl, detectAndSetActiveMenu]);
1369
+ const toggleMobileMenu = () => {
1370
+ setIsMobileMenuOpen(!isMobileMenuOpen);
1371
+ };
1372
+ const closeMobileMenu = () => {
1373
+ setIsMobileMenuOpen(false);
1374
+ };
1375
+ return /* @__PURE__ */ import_react14.default.createElement(import_react14.default.Fragment, null, /* @__PURE__ */ import_react14.default.createElement("div", { className: "fixed top-0 left-0 w-full z-50 flex items-center justify-between px-4 py-3 bg-white dark:bg-[#18181b] border-b border-gray-200 dark:border-[#303036] shadow-lg md:hidden", id: `${id}-div-1` }, /* @__PURE__ */ import_react14.default.createElement(
1376
+ "button",
1377
+ {
1378
+ onClick: toggleMobileMenu,
1379
+ className: "p-2 rounded-lg hover:bg-gray-50 dark:hover:bg-[#27272a] transition-colors",
1380
+ "aria-label": "Toggle menu",
1381
+ id: `${id}-button-1`
1382
+ },
1383
+ isMobileMenuOpen ? /* @__PURE__ */ import_react14.default.createElement(import_lucide_react8.X, { className: "w-6 h-6 text-gray-700 dark:text-[#f4f4f5cc]" }) : /* @__PURE__ */ import_react14.default.createElement(import_lucide_react8.Menu, { className: "w-6 h-6 text-gray-700 dark:text-[#f4f4f5cc]" })
1384
+ ), /* @__PURE__ */ import_react14.default.createElement("div", { className: "flex-1 flex justify-center", id: `${id}-div-2` }, sideBarLogoLocal && /* @__PURE__ */ import_react14.default.createElement(
1385
+ "img",
1386
+ {
1387
+ src: sideBarLogoLocal,
1388
+ alt: "sidebarLogo",
1389
+ width: 208,
1390
+ height: 40,
1391
+ className: "object-contain",
1392
+ id: `${id}-img-1`
1393
+ }
1394
+ )), /* @__PURE__ */ import_react14.default.createElement("div", { className: "w-10", id: `${id}-div-3` })), isMobileMenuOpen && /* @__PURE__ */ import_react14.default.createElement(
1395
+ "div",
1396
+ {
1397
+ className: "fixed inset-0 bg-black/80 bg-opacity-50 z-40 md:hidden",
1398
+ onClick: closeMobileMenu,
1399
+ id: `${id}-div-4`
1400
+ }
1401
+ ), /* @__PURE__ */ import_react14.default.createElement(
1402
+ "div",
1403
+ {
1404
+ className: `fixed top-0 left-0 md:relative w-[320px] transition-all ease-in-out delay-100 bg-white dark:bg-[#18181b] border-r border-gray-200 dark:border-[#303036] flex flex-col p-4 pt-20 md:pt-4 h-full max-h-[100vh] xs:max-md:z-40 md:max-lg:w-[280px] ${isMobileMenuOpen ? "translate-x-0" : "-translate-x-full md:translate-x-0"}`,
1405
+ id: `${id}-div-5`
1406
+ },
1407
+ /* @__PURE__ */ import_react14.default.createElement("div", { className: "p-2 mb-2 hidden md:block", id: `${id}-div-6` }, /* @__PURE__ */ import_react14.default.createElement("div", { className: "flex items-center justify-center w-full h-[60px] mb-2", id: `${id}-div-7` }, sideBarLogoLocal && /* @__PURE__ */ import_react14.default.createElement(
1408
+ "img",
1409
+ {
1410
+ src: sideBarLogoLocal,
1411
+ alt: "sidebarLogo",
1412
+ width: 108,
1413
+ height: 40,
1414
+ className: "object-contain",
1415
+ id: `${id}-img-2`
1416
+ }
1417
+ ))),
1418
+ /* @__PURE__ */ import_react14.default.createElement("div", { className: "mb-4", id: `${id}-div-8` }),
1419
+ /* @__PURE__ */ import_react14.default.createElement("div", { className: "overflow-y-auto scrollbar-hide", id: `${id}-div-9` }, /* @__PURE__ */ import_react14.default.createElement("div", { id: `${id}-div-10` }, navItemsLocal == null ? void 0 : navItemsLocal.map((item, index) => {
1420
+ const menuKey = `menu-${index}`;
1421
+ const isOpen = isMenuOpen(menuKey);
1422
+ const isActive = activeMenuPath === menuKey;
1423
+ return /* @__PURE__ */ import_react14.default.createElement("div", { key: index, className: "", id: `${id}-div-11` }, /* @__PURE__ */ import_react14.default.createElement(
1424
+ "div",
1425
+ {
1426
+ className: `flex items-center gap-3 p-2.5 hover:bg-[#f4f4f5] dark:hover:bg-[#27272a] text-gray-700 dark:text-[#f4f4f5cc] cursor-pointer rounded-lg ml-2 mr-2 transition-colors duration-200 ${isActive ? "bg-[#f4f4f5] dark:bg-[#27272a]" : ""}`,
1427
+ onClick: (e) => handleMenuClick(item, index, e),
1428
+ id: `${id}-div-12`
1429
+ },
1430
+ /* @__PURE__ */ import_react14.default.createElement("div", { className: "text-primary", id: `${id}-div-13` }, /* @__PURE__ */ import_react14.default.createElement(item.Icon, { width: 20, height: 20, id: `${id}-icon-1` })),
1431
+ /* @__PURE__ */ import_react14.default.createElement("span", { className: "!font-medium !text-[16px] !text-[#000] dark:text-[#f4f4f5cc]", id: `${id}-span-1` }, item.label),
1432
+ item.isDropDown && /* @__PURE__ */ import_react14.default.createElement("div", { className: `ml-auto transition-all delay-75 ${isOpen ? "rotate-180" : ""}`, id: `${id}-div-14` }, /* @__PURE__ */ import_react14.default.createElement(import_lucide_react8.ChevronDown, { width: 20, height: 20, className: "text-gray-500 dark:text-gray-400" }))
1433
+ ), item.options && item.options.length > 0 && /* @__PURE__ */ import_react14.default.createElement(
1434
+ "div",
1435
+ {
1436
+ className: `ml-[20px] overflow-hidden flex flex-col transition-all duration-200 ${isOpen ? "max-h-[1000px] min-h-[50px]" : "max-h-0"}`,
1437
+ id: `${id}-div-15`
1438
+ },
1439
+ item.options.map((options, optionsIndex) => {
1440
+ const subMenuKey = `menu-${index}-option-${optionsIndex}`;
1441
+ const isSubMenuOpen = isMenuOpen(subMenuKey);
1442
+ const isSubActive = activeMenuPath === subMenuKey || (activeMenuPath == null ? void 0 : activeMenuPath.startsWith(`${subMenuKey}-`));
1443
+ const isDisabled = options.isDisabled;
1444
+ return /* @__PURE__ */ import_react14.default.createElement("div", { key: optionsIndex, className: "", id: `${id}-div-16-${optionsIndex}` }, /* @__PURE__ */ import_react14.default.createElement(
1445
+ "div",
1446
+ {
1447
+ className: `group flex items-center gap-3 py-2 px-3 ml-4 mr-2 rounded-md transition-colors duration-200 ${isDisabled ? "cursor-not-allowed opacity-70 text-gray-400 dark:text-gray-500" : `hover:bg-[#f4f4f5] dark:hover:bg-[#27272a] text-gray-600 dark:text-[#a1a1aa] cursor-pointer ${isSubActive ? "bg-[#f4f4f5] dark:bg-[#27272a]" : ""}`}`,
1448
+ onClick: (e) => {
1449
+ if (isDisabled) {
1450
+ e.preventDefault();
1451
+ return;
1452
+ }
1453
+ handleSubMenuClick(options, optionsIndex, index, e);
1454
+ },
1455
+ id: `${id}-div-17-${optionsIndex}`
1456
+ },
1457
+ /* @__PURE__ */ import_react14.default.createElement("div", { id: `${id}-div-18-${optionsIndex}` }),
1458
+ /* @__PURE__ */ import_react14.default.createElement("span", { className: `!font-medium !text-[15px] ${isDisabled ? "!text-[#3f3f46cc] dark:!text-[#a1a1aa]" : "!text-[#3f3f46cc] dark:!text-[#a1a1aa]"}`, id: `${id}-span-2-${optionsIndex}` }, options.label),
1459
+ options.isDropDown && /* @__PURE__ */ import_react14.default.createElement(
1460
+ "div",
1461
+ {
1462
+ className: `ml-auto transition-all delay-75 ${isSubMenuOpen ? "rotate-180" : ""}`,
1463
+ id: `${id}-div-19-${optionsIndex}`
1464
+ },
1465
+ /* @__PURE__ */ import_react14.default.createElement(import_lucide_react8.ChevronDown, { width: 18, height: 18, className: "text-gray-400 dark:text-gray-500" })
1466
+ )
1467
+ ), options.options && options.options.length > 0 && /* @__PURE__ */ import_react14.default.createElement(
1468
+ "div",
1469
+ {
1470
+ className: `ml-[20px] overflow-hidden flex flex-col transition-all duration-200 ${isSubMenuOpen ? "max-h-[1000px] min-h-[50px]" : "max-h-0"}`,
1471
+ id: `${id}-div-20-${optionsIndex}`
1472
+ },
1473
+ options.options.map((subOption, subIndex) => {
1474
+ const isSubSubActive = activeMenuPath === `menu-${index}-option-${optionsIndex}-sub-${subOption.label}`;
1475
+ return /* @__PURE__ */ import_react14.default.createElement(
1476
+ "div",
1477
+ {
1478
+ key: subIndex,
1479
+ className: `py-1.5 px-3 rounded-md hover:bg-[#f4f4f5] dark:hover:bg-[#27272a] text-gray-500 dark:text-[#71717a] font-medium text-base cursor-pointer ml-8 mr-2 transition-colors duration-200 ${isSubSubActive ? "bg-[#f4f4f5] dark:bg-[#27272a]" : ""}`,
1480
+ onClick: (e) => handleSubSubMenuClick(subOption, index, optionsIndex, e),
1481
+ id: `${id}-div-21-${subIndex}`
1482
+ },
1483
+ subOption.label
1484
+ );
1485
+ })
1486
+ ));
1487
+ })
1488
+ ));
1489
+ }))),
1490
+ /* @__PURE__ */ import_react14.default.createElement("div", { ref: profileCardRef, className: "relative mt-auto bg-[#fafafa] dark:bg-[#18181b] sticky bottom-0 mt-2", id: `${id}-div-22` }, /* @__PURE__ */ import_react14.default.createElement(
1491
+ "div",
1492
+ {
1493
+ className: "group flex items-center justify-between p-2 rounded-lg hover:bg-[#f4f4f5] dark:hover:bg-[#27272a] cursor-pointer transition-colors duration-200",
1494
+ onClick: () => setIsSwitchProfileOpen((prev) => !prev),
1495
+ id: `${id}-div-23`
1496
+ },
1497
+ /* @__PURE__ */ import_react14.default.createElement("div", { className: "flex items-center gap-3", id: `${id}-div-24` }, /* @__PURE__ */ import_react14.default.createElement("span", { className: "relative flex shrink-0 overflow-hidden dark:bg-[#27272a] rounded-full h-10 w-10", id: `${id}-span-3` }, /* @__PURE__ */ import_react14.default.createElement("span", { className: "flex h-full w-full items-center justify-center !text-[16px] !font-normal border border-gray-200 dark:border-[#303036] rounded-full bg-muted dark:text-white", id: `${id}-span-4` }, cookieUserName ? cookieUserName.split("")[0] : "A")), /* @__PURE__ */ import_react14.default.createElement("div", { id: `${id}-div-25` }, /* @__PURE__ */ import_react14.default.createElement("p", { className: "!font-semibold dark:text-white !text-[16px]", id: `${id}-p-1` }, cookieUserName ? cookieUserName : "Admin"), /* @__PURE__ */ import_react14.default.createElement("p", { className: "!text-[14px] !font-normal dark:text-[#f4f4f5cc]", id: `${id}-p-2` }, SCOPE_LABELS[scope] ?? scope))),
1498
+ /* @__PURE__ */ import_react14.default.createElement(
1499
+ "span",
1500
+ {
1501
+ className: "opacity-0 group-hover:opacity-100 transition-opacity duration-200 !text-[14px] !font-bold text-blue-600 dark:text-blue-400 hover:underline",
1502
+ id: `${id}-span-switch`
1503
+ },
1504
+ "Switch"
1505
+ )
1506
+ ), /* @__PURE__ */ import_react14.default.createElement(
1507
+ SwitchProfileSection,
1508
+ {
1509
+ id: `${id}-switch-profile`,
1510
+ open: isSwitchProfileOpen,
1511
+ anchorRef: profileCardRef,
1512
+ onClose: () => setIsSwitchProfileOpen(false),
1513
+ onManageProfile: () => {
1514
+ setIsSwitchProfileOpen(false);
1515
+ window.location.href = "/profile";
1516
+ },
1517
+ onProfileSwitch: (profile) => {
1518
+ setIsSwitchProfileOpen(false);
1519
+ onProfileSwitch == null ? void 0 : onProfileSwitch(profile);
1520
+ },
1521
+ onTmcSettings: () => {
1522
+ setIsSwitchProfileOpen(false);
1523
+ onTmcSettings == null ? void 0 : onTmcSettings();
1524
+ },
1525
+ onLogout: () => {
1526
+ setIsSwitchProfileOpen(false);
1527
+ if (onLogout) {
1528
+ onLogout();
1529
+ } else {
1530
+ window.dispatchEvent(new Event("logout"));
1531
+ }
1532
+ }
1533
+ }
1534
+ ))
1535
+ ));
1536
+ };
1537
+
1538
+ // src/RightSheet/RightSheet.jsx
1539
+ var import_react15 = __toESM(require("react"));
1540
+ var RightSheet = ({
1541
+ id = "right-sheet",
1542
+ open,
1543
+ setOpen,
1544
+ children,
1545
+ callBack,
1546
+ actionLabel = "Save",
1547
+ onAction = () => {
1548
+ }
1549
+ }) => {
1550
+ const [visible, setVisible] = (0, import_react15.useState)(open);
1551
+ (0, import_react15.useEffect)(() => {
1552
+ if (open) {
1553
+ document.body.style.overflow = "hidden";
1554
+ setVisible(true);
1555
+ }
1556
+ return () => {
1557
+ document.body.style.overflow = "auto";
1558
+ };
1559
+ }, [open]);
1560
+ const handleClose = () => {
1561
+ setVisible(false);
1562
+ setTimeout(() => {
1563
+ setOpen(false);
1564
+ callBack();
1565
+ }, 200);
1566
+ };
1567
+ const handleAction = () => {
1568
+ onAction();
1569
+ handleClose();
1570
+ };
1571
+ if (!visible) return null;
1572
+ return /* @__PURE__ */ import_react15.default.createElement(
1573
+ "div",
1574
+ {
1575
+ className: "fixed inset-0 overflow-x-hidden bg-black/80 sheetPopIn h-full overflow-auto ",
1576
+ onClick: handleClose,
1577
+ id: `${id}-div-1`
1578
+ },
1579
+ /* @__PURE__ */ import_react15.default.createElement(
1580
+ "div",
1581
+ {
1582
+ className: `absolute flex flex-col right-0 top-0 min-h-full min-w-[100%] md:min-w-[576px]
1583
+ ${visible ? "sheetRightSlide" : "transition-all duration-200 translate-x-[100%]"} justify-between bg-[#fff] dark:bg-[#18181b] dark:text-white`,
1584
+ onClick: (e) => e.stopPropagation(),
1585
+ id: `${id}-div-2`
1586
+ },
1587
+ /* @__PURE__ */ import_react15.default.createElement("div", { className: " min-h-full ", id: `${id}-div-3` }, children),
1588
+ /* @__PURE__ */ import_react15.default.createElement("div", { className: "h-[90px] flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2 p-6 border-t sticky bottom-0 bg-white border-[#e6e6e6] dark:border-[#303036] dark:bg-[#18181b] dark:text-white", id: `${id}-div-4` }, /* @__PURE__ */ import_react15.default.createElement(CustomButton, { variant: "SECONDARY", onClick: () => handleClose(), id: `${id}-custom-button-1` }, "Cancel"), /* @__PURE__ */ import_react15.default.createElement(CustomButton, { variant: "SECONDARY", onClick: handleAction, id: `${id}-custom-button-2` }, actionLabel))
1589
+ )
1590
+ );
1591
+ };
1592
+
1593
+ // src/Table/CustomTable.jsx
1594
+ var import_react16 = __toESM(require("react"));
1595
+ var CustomTable = ({
1596
+ id = "custom-table",
1597
+ tableHeader,
1598
+ setIsAllChecked,
1599
+ isAllChecked,
1600
+ children,
1601
+ isHideCheckbox = "false"
1602
+ }) => {
1603
+ return /* @__PURE__ */ import_react16.default.createElement("div", { className: "border border-[#e5e5e5] dark:border-[#303036] rounded-lg overflow-x-auto", id: `${id}-div-1` }, /* @__PURE__ */ import_react16.default.createElement("div", { className: "w-full relative overflow-x-auto", id: `${id}-div-2` }, /* @__PURE__ */ import_react16.default.createElement("table", { className: "w-full caption-bottom text-sm overflow-x-auto bg-white dark:bg-[#18181b] table-fixed border-collapse", id: `${id}-table-1` }, /* @__PURE__ */ import_react16.default.createElement("thead", { className: "border-b border-[#e5e5e5] dark:border-[#303036] dark:bg-[#18181b]", id: `${id}-thead-1` }, /* @__PURE__ */ import_react16.default.createElement(
1604
+ "tr",
1605
+ {
1606
+ className: "transition-colors text-[#737373] hover:bg-muted/50 \r\n data-[state=selected]:bg-muted",
1607
+ id: `${id}-tr-1`
1608
+ },
1609
+ !isHideCheckbox && /* @__PURE__ */ import_react16.default.createElement("th", { className: "px-4 py-3 text-left w-[50px]", id: `${id}-th-1` }, /* @__PURE__ */ import_react16.default.createElement(
1610
+ CustomCheckbox,
1611
+ {
1612
+ checked: isAllChecked,
1613
+ onChange: () => {
1614
+ setIsAllChecked(!isAllChecked);
1615
+ },
1616
+ id: `${id}-custom-checkbox-1`
1617
+ }
1618
+ )),
1619
+ tableHeader.map((header, index) => {
1620
+ return /* @__PURE__ */ import_react16.default.createElement(
1621
+ "th",
1622
+ {
1623
+ className: `text-[#737373] px-4 py-3 text-sm dark:bg-[#18181b] font-medium ${index == tableHeader.length - 1 ? "text-right" : "text-left"}`,
1624
+ key: header + index,
1625
+ id: `${id}-th-2-${index}`
1626
+ },
1627
+ header
1628
+ );
1629
+ })
1630
+ )), /* @__PURE__ */ import_react16.default.createElement("tbody", { id: `${id}-tbody-1` }, children))));
1631
+ };
1632
+
1633
+ // src/Pagination/Pagination.jsx
1634
+ var import_react17 = __toESM(require("react"));
1635
+ var import_lucide_react9 = require("lucide-react");
1636
+ var Pagination = ({
1637
+ id = "pagination",
1638
+ data = [],
1639
+ component: Component,
1640
+ itemsPerPage = 6,
1641
+ itemsPerPageOptions = [5, 10, 20, 50, 100],
1642
+ // Controlled props (optional)
1643
+ currentPage: controlledCurrentPage,
1644
+ onPageChange: controlledOnPageChange,
1645
+ onItemsPerPageChange: controlledOnItemsPerPageChange,
1646
+ // Legacy props for backward compatibility
1647
+ totalPages,
1648
+ totalItems: legacyTotalItems,
1649
+ onPageChange: legacyOnPageChange,
1650
+ onItemsPerPageChange: legacyOnItemsPerPageChange,
1651
+ tableHeader,
1652
+ isHideCheckbox,
1653
+ callback,
1654
+ isTable = false,
1655
+ // Component props - any additional props to pass to the component
1656
+ componentProps = {},
1657
+ ...restProps
1658
+ }) => {
1659
+ const [internalCurrentPage, setInternalCurrentPage] = (0, import_react17.useState)(1);
1660
+ const [internalItemsPerPage, setInternalItemsPerPage] = (0, import_react17.useState)(itemsPerPage);
1661
+ const isControlled = controlledCurrentPage !== void 0;
1662
+ const isItemsPerPageControlled = controlledOnItemsPerPageChange !== void 0;
1663
+ const currentPage = isControlled ? controlledCurrentPage : internalCurrentPage;
1664
+ const activeItemsPerPage = isItemsPerPageControlled ? itemsPerPage : internalItemsPerPage;
1665
+ const totalItems = legacyTotalItems !== void 0 ? legacyTotalItems : data.length;
1666
+ const calculatedTotalPages = (0, import_react17.useMemo)(() => {
1667
+ if (totalItems > 0 && activeItemsPerPage > 0) {
1668
+ return Math.ceil(totalItems / activeItemsPerPage);
1669
+ }
1670
+ return 1;
1671
+ }, [totalItems, activeItemsPerPage]);
1672
+ const paginatedData = (0, import_react17.useMemo)(() => {
1673
+ if (!data || data.length === 0) return [];
1674
+ const startIndex = (currentPage - 1) * activeItemsPerPage;
1675
+ const endIndex = startIndex + activeItemsPerPage;
1676
+ return data.slice(startIndex, endIndex);
1677
+ }, [data, currentPage, activeItemsPerPage]);
1678
+ (0, import_react17.useEffect)(() => {
1679
+ if (!isControlled && currentPage > calculatedTotalPages && calculatedTotalPages > 0) {
1680
+ setInternalCurrentPage(1);
1681
+ }
1682
+ }, [calculatedTotalPages, isControlled, currentPage]);
1683
+ const getPageNumbers = () => {
1684
+ const pages = [];
1685
+ const maxVisible = 5;
1686
+ let startPage = Math.max(1, currentPage - Math.floor(maxVisible / 2));
1687
+ let endPage = Math.min(calculatedTotalPages, startPage + maxVisible - 1);
1688
+ if (endPage - startPage < maxVisible - 1) {
1689
+ startPage = Math.max(1, endPage - maxVisible + 1);
1690
+ }
1691
+ for (let i = startPage; i <= endPage; i++) {
1692
+ pages.push(i);
1693
+ }
1694
+ return pages;
1695
+ };
1696
+ const handlePageChange = (page) => {
1697
+ if (page >= 1 && page <= calculatedTotalPages) {
1698
+ if (isControlled && controlledOnPageChange) {
1699
+ controlledOnPageChange(page);
1700
+ } else if (legacyOnPageChange) {
1701
+ legacyOnPageChange(page);
1702
+ } else {
1703
+ setInternalCurrentPage(page);
1704
+ }
1705
+ }
1706
+ };
1707
+ const startItem = totalItems !== void 0 ? (currentPage - 1) * activeItemsPerPage + 1 : null;
1708
+ const endItem = totalItems !== void 0 ? Math.min(currentPage * activeItemsPerPage, totalItems) : null;
1709
+ const renderContent = () => {
1710
+ if (Component) {
1711
+ if (import_react17.default.isValidElement(Component)) {
1712
+ const ComponentType = Component.type;
1713
+ const elementProps = Component.props;
1714
+ if (isTable) {
1715
+ return /* @__PURE__ */ import_react17.default.createElement(
1716
+ CustomTable,
1717
+ {
1718
+ tableHeader,
1719
+ isHideCheckbox,
1720
+ id: `${id}-custom-table-1`
1721
+ },
1722
+ data.map((item, index) => {
1723
+ return /* @__PURE__ */ import_react17.default.createElement(
1724
+ ComponentType,
1725
+ {
1726
+ key: item.id || item._id || index,
1727
+ data: item,
1728
+ ...elementProps,
1729
+ ...componentProps,
1730
+ ...restProps,
1731
+ id: `${id}-component-type-1-${index}`
1732
+ }
1733
+ );
1734
+ })
1735
+ );
1736
+ } else {
1737
+ if (isTable) {
1738
+ return /* @__PURE__ */ import_react17.default.createElement(
1739
+ CustomTable,
1740
+ {
1741
+ tableHeader,
1742
+ isHideCheckbox,
1743
+ id: `${id}-custom-table-2`
1744
+ },
1745
+ paginatedData.map((item, index) => {
1746
+ return /* @__PURE__ */ import_react17.default.createElement(
1747
+ ComponentType,
1748
+ {
1749
+ key: item.id || item._id || index,
1750
+ data: item,
1751
+ ...elementProps,
1752
+ ...componentProps,
1753
+ ...restProps,
1754
+ id: `${id}-component-type-2-${index}`
1755
+ }
1756
+ );
1757
+ })
1758
+ );
1759
+ }
1760
+ }
1761
+ } else {
1762
+ return /* @__PURE__ */ import_react17.default.createElement(
1763
+ CustomTable,
1764
+ {
1765
+ tableHeader,
1766
+ isHideCheckbox,
1767
+ id: `${id}-custom-table-3`
1768
+ },
1769
+ paginatedData.map((item, index) => {
1770
+ return /* @__PURE__ */ import_react17.default.createElement(
1771
+ Component,
1772
+ {
1773
+ key: item.id || item._id || index,
1774
+ data: item,
1775
+ ...componentProps,
1776
+ ...restProps,
1777
+ id: `${id}-component-1-${index}`
1778
+ }
1779
+ );
1780
+ })
1781
+ );
1782
+ }
1783
+ }
1784
+ return null;
1785
+ };
1786
+ return /* @__PURE__ */ import_react17.default.createElement(import_react17.default.Fragment, null, /* @__PURE__ */ import_react17.default.createElement(import_react17.default.Fragment, null, renderContent()), /* @__PURE__ */ import_react17.default.createElement("div", { className: "flex flex-col sm:flex-row justify-between items-center gap-4 px-4 py-3 border-t border-[#e5e5e5] dark:border-[#303036] bg-white dark:bg-[#18181b] z-10", id: `${id}-div-1` }, totalItems !== void 0 && /* @__PURE__ */ import_react17.default.createElement("div", { className: "text-sm text-[#737373] dark:text-white", id: `${id}-div-2` }, "Showing ", startItem, " to ", endItem, " of ", totalItems, " entries"), /* @__PURE__ */ import_react17.default.createElement("div", { className: "flex items-center gap-2", id: `${id}-div-3` }, /* @__PURE__ */ import_react17.default.createElement(
1787
+ "button",
1788
+ {
1789
+ onClick: () => handlePageChange(1),
1790
+ disabled: currentPage === 1,
1791
+ className: `flex items-center justify-center w-9 h-9 rounded-md border border-[#e5e5e5] dark:border-[#303036] text-sm transition-colors ${currentPage === 1 ? "bg-gray-100 text-gray-400 cursor-not-allowed dark:bg-[#27272a] dark:text-gray-600" : "bg-white text-black hover:bg-gray-50 cursor-pointer dark:bg-[#18181b] dark:text-white dark:hover:bg-[#27272a]"}`,
1792
+ title: "First page",
1793
+ id: `${id}-button-1`
1794
+ },
1795
+ /* @__PURE__ */ import_react17.default.createElement(import_lucide_react9.ChevronsLeft, { size: 16 })
1796
+ ), /* @__PURE__ */ import_react17.default.createElement(
1797
+ "button",
1798
+ {
1799
+ onClick: () => handlePageChange(currentPage - 1),
1800
+ disabled: currentPage === 1,
1801
+ className: `flex items-center justify-center w-9 h-9 rounded-md border border-[#e5e5e5] dark:border-[#303036] text-sm transition-colors ${currentPage === 1 ? "bg-gray-100 text-gray-400 cursor-not-allowed dark:bg-[#27272a] dark:text-gray-600" : "bg-white text-black hover:bg-gray-50 cursor-pointer dark:bg-[#18181b] dark:text-white dark:hover:bg-[#27272a]"}`,
1802
+ title: "Previous page",
1803
+ id: `${id}-button-2`
1804
+ },
1805
+ /* @__PURE__ */ import_react17.default.createElement(import_lucide_react9.ChevronLeft, { size: 16 })
1806
+ ), getPageNumbers().map((pageNum) => /* @__PURE__ */ import_react17.default.createElement(
1807
+ "button",
1808
+ {
1809
+ key: pageNum,
1810
+ onClick: () => handlePageChange(pageNum),
1811
+ className: `flex items-center justify-center min-w-9 h-9 px-3 cursor-pointer rounded-md border border-[#e5e5e5] dark:border-[#303036] text-sm transition-colors ${currentPage === pageNum ? "bg-primary text-white border-primary dark:bg-primary" : "bg-white text-black hover:bg-gray-50 dark:bg-[#18181b] dark:text-white dark:hover:bg-[#27272a]"}`,
1812
+ id: `${id}-button-3`
1813
+ },
1814
+ pageNum
1815
+ )), /* @__PURE__ */ import_react17.default.createElement(
1816
+ "button",
1817
+ {
1818
+ onClick: () => handlePageChange(currentPage + 1),
1819
+ disabled: currentPage === calculatedTotalPages || calculatedTotalPages === 0,
1820
+ className: `flex items-center justify-center w-9 h-9 rounded-md border border-[#e5e5e5] dark:border-[#303036] text-sm transition-colors ${currentPage === calculatedTotalPages || calculatedTotalPages === 0 ? "bg-gray-100 text-gray-400 cursor-not-allowed dark:bg-[#27272a] dark:text-gray-600" : "bg-white text-black hover:bg-gray-50 cursor-pointer dark:bg-[#18181b] dark:text-white dark:hover:bg-[#27272a]"}`,
1821
+ title: "Next page",
1822
+ id: `${id}-button-4`
1823
+ },
1824
+ /* @__PURE__ */ import_react17.default.createElement(import_lucide_react9.ChevronRight, { size: 16 })
1825
+ ), /* @__PURE__ */ import_react17.default.createElement(
1826
+ "button",
1827
+ {
1828
+ onClick: () => handlePageChange(calculatedTotalPages),
1829
+ disabled: currentPage === calculatedTotalPages || calculatedTotalPages === 0,
1830
+ className: `flex items-center justify-center w-9 h-9 rounded-md border border-[#e5e5e5] dark:border-[#303036] text-sm transition-colors ${currentPage === calculatedTotalPages || calculatedTotalPages === 0 ? "bg-gray-100 text-gray-400 cursor-not-allowed dark:bg-[#27272a] dark:text-gray-600" : "bg-white text-black hover:bg-gray-50 cursor-pointer dark:bg-[#18181b] dark:text-white dark:hover:bg-[#27272a]"}`,
1831
+ title: "Last page",
1832
+ id: `${id}-button-5`
1833
+ },
1834
+ /* @__PURE__ */ import_react17.default.createElement(import_lucide_react9.ChevronsRight, { size: 16 })
1835
+ ))));
1836
+ };
1837
+ // Annotate the CommonJS export names for ESM import in node:
1838
+ 0 && (module.exports = {
1839
+ AppSideBar,
1840
+ Chip,
1841
+ CustomAutocomplete,
1842
+ CustomButton,
1843
+ CustomCheckbox,
1844
+ CustomInput,
1845
+ CustomSearch,
1846
+ CustomSelect,
1847
+ CustomSwitch,
1848
+ CustomTable,
1849
+ CustomTextarea,
1850
+ CustomUpload,
1851
+ Pagination,
1852
+ ProgressBar,
1853
+ RightSheet
1854
+ });