@logickernel/bridge 0.5.0 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,1347 @@
1
+ 'use strict';
2
+
3
+ var React2 = require('react');
4
+ var reactSlot = require('@radix-ui/react-slot');
5
+ var classVarianceAuthority = require('class-variance-authority');
6
+ var LucideIcons = require('lucide-react');
7
+ var clsx = require('clsx');
8
+ var tailwindMerge = require('tailwind-merge');
9
+ var jsxRuntime = require('react/jsx-runtime');
10
+ var SheetPrimitive = require('@radix-ui/react-dialog');
11
+ var TooltipPrimitive = require('@radix-ui/react-tooltip');
12
+ var navigation = require('next/navigation');
13
+ var Link = require('next/link');
14
+ var CollapsiblePrimitive = require('@radix-ui/react-collapsible');
15
+ var react = require('next-auth/react');
16
+ var AvatarPrimitive = require('@radix-ui/react-avatar');
17
+ var DropdownMenuPrimitive = require('@radix-ui/react-dropdown-menu');
18
+
19
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
20
+
21
+ function _interopNamespace(e) {
22
+ if (e && e.__esModule) return e;
23
+ var n = Object.create(null);
24
+ if (e) {
25
+ Object.keys(e).forEach(function (k) {
26
+ if (k !== 'default') {
27
+ var d = Object.getOwnPropertyDescriptor(e, k);
28
+ Object.defineProperty(n, k, d.get ? d : {
29
+ enumerable: true,
30
+ get: function () { return e[k]; }
31
+ });
32
+ }
33
+ });
34
+ }
35
+ n.default = e;
36
+ return Object.freeze(n);
37
+ }
38
+
39
+ var React2__namespace = /*#__PURE__*/_interopNamespace(React2);
40
+ var LucideIcons__namespace = /*#__PURE__*/_interopNamespace(LucideIcons);
41
+ var SheetPrimitive__namespace = /*#__PURE__*/_interopNamespace(SheetPrimitive);
42
+ var TooltipPrimitive__namespace = /*#__PURE__*/_interopNamespace(TooltipPrimitive);
43
+ var Link__default = /*#__PURE__*/_interopDefault(Link);
44
+ var CollapsiblePrimitive__namespace = /*#__PURE__*/_interopNamespace(CollapsiblePrimitive);
45
+ var AvatarPrimitive__namespace = /*#__PURE__*/_interopNamespace(AvatarPrimitive);
46
+ var DropdownMenuPrimitive__namespace = /*#__PURE__*/_interopNamespace(DropdownMenuPrimitive);
47
+
48
+ // src/next/components/ui/sidebar.tsx
49
+ var MOBILE_BREAKPOINT = 768;
50
+ function useIsMobile() {
51
+ const [isMobile, setIsMobile] = React2__namespace.useState(void 0);
52
+ React2__namespace.useEffect(() => {
53
+ const mql = window.matchMedia(`(max-width: ${MOBILE_BREAKPOINT - 1}px)`);
54
+ const onChange = () => {
55
+ setIsMobile(window.innerWidth < MOBILE_BREAKPOINT);
56
+ };
57
+ mql.addEventListener("change", onChange);
58
+ setIsMobile(window.innerWidth < MOBILE_BREAKPOINT);
59
+ return () => mql.removeEventListener("change", onChange);
60
+ }, []);
61
+ return !!isMobile;
62
+ }
63
+ function cn(...inputs) {
64
+ return tailwindMerge.twMerge(clsx.clsx(inputs));
65
+ }
66
+ var buttonVariants = classVarianceAuthority.cva(
67
+ "inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",
68
+ {
69
+ variants: {
70
+ variant: {
71
+ default: "bg-primary text-primary-foreground hover:bg-primary/90",
72
+ destructive: "bg-destructive text-white hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",
73
+ outline: "border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50",
74
+ secondary: "bg-secondary text-secondary-foreground hover:bg-secondary/80",
75
+ ghost: "hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",
76
+ link: "text-primary underline-offset-4 hover:underline"
77
+ },
78
+ size: {
79
+ default: "h-9 px-4 py-2 has-[>svg]:px-3",
80
+ sm: "h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",
81
+ lg: "h-10 rounded-md px-6 has-[>svg]:px-4",
82
+ icon: "size-9",
83
+ "icon-sm": "size-8",
84
+ "icon-lg": "size-10"
85
+ }
86
+ },
87
+ defaultVariants: {
88
+ variant: "default",
89
+ size: "default"
90
+ }
91
+ }
92
+ );
93
+ function Button({
94
+ className,
95
+ variant,
96
+ size,
97
+ asChild = false,
98
+ ...props
99
+ }) {
100
+ const Comp = asChild ? reactSlot.Slot : "button";
101
+ return /* @__PURE__ */ jsxRuntime.jsx(
102
+ Comp,
103
+ {
104
+ "data-slot": "button",
105
+ className: cn(buttonVariants({ variant, size, className })),
106
+ ...props
107
+ }
108
+ );
109
+ }
110
+ function Sheet({ ...props }) {
111
+ return /* @__PURE__ */ jsxRuntime.jsx(SheetPrimitive__namespace.Root, { "data-slot": "sheet", ...props });
112
+ }
113
+ function SheetPortal({
114
+ ...props
115
+ }) {
116
+ return /* @__PURE__ */ jsxRuntime.jsx(SheetPrimitive__namespace.Portal, { "data-slot": "sheet-portal", ...props });
117
+ }
118
+ function SheetOverlay({
119
+ className,
120
+ ...props
121
+ }) {
122
+ return /* @__PURE__ */ jsxRuntime.jsx(
123
+ SheetPrimitive__namespace.Overlay,
124
+ {
125
+ "data-slot": "sheet-overlay",
126
+ className: cn(
127
+ "data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",
128
+ className
129
+ ),
130
+ ...props
131
+ }
132
+ );
133
+ }
134
+ function SheetContent({
135
+ className,
136
+ children,
137
+ side = "right",
138
+ ...props
139
+ }) {
140
+ return /* @__PURE__ */ jsxRuntime.jsxs(SheetPortal, { children: [
141
+ /* @__PURE__ */ jsxRuntime.jsx(SheetOverlay, {}),
142
+ /* @__PURE__ */ jsxRuntime.jsxs(
143
+ SheetPrimitive__namespace.Content,
144
+ {
145
+ "data-slot": "sheet-content",
146
+ className: cn(
147
+ "bg-background data-[state=open]:animate-in data-[state=closed]:animate-out fixed z-50 flex flex-col gap-4 shadow-lg transition ease-in-out data-[state=closed]:duration-300 data-[state=open]:duration-500",
148
+ side === "right" && "data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right inset-y-0 right-0 h-full w-3/4 border-l sm:max-w-sm",
149
+ side === "left" && "data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left inset-y-0 left-0 h-full w-3/4 border-r sm:max-w-sm",
150
+ side === "top" && "data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top inset-x-0 top-0 h-auto border-b",
151
+ side === "bottom" && "data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom inset-x-0 bottom-0 h-auto border-t",
152
+ className
153
+ ),
154
+ ...props,
155
+ children: [
156
+ children,
157
+ /* @__PURE__ */ jsxRuntime.jsxs(SheetPrimitive__namespace.Close, { className: "ring-offset-background focus:ring-ring data-[state=open]:bg-secondary absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none", children: [
158
+ /* @__PURE__ */ jsxRuntime.jsx(LucideIcons.XIcon, { className: "size-4" }),
159
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Close" })
160
+ ] })
161
+ ]
162
+ }
163
+ )
164
+ ] });
165
+ }
166
+ function SheetHeader({ className, ...props }) {
167
+ return /* @__PURE__ */ jsxRuntime.jsx(
168
+ "div",
169
+ {
170
+ "data-slot": "sheet-header",
171
+ className: cn("flex flex-col gap-1.5 p-4", className),
172
+ ...props
173
+ }
174
+ );
175
+ }
176
+ function SheetTitle({
177
+ className,
178
+ ...props
179
+ }) {
180
+ return /* @__PURE__ */ jsxRuntime.jsx(
181
+ SheetPrimitive__namespace.Title,
182
+ {
183
+ "data-slot": "sheet-title",
184
+ className: cn("text-foreground font-semibold", className),
185
+ ...props
186
+ }
187
+ );
188
+ }
189
+ function SheetDescription({
190
+ className,
191
+ ...props
192
+ }) {
193
+ return /* @__PURE__ */ jsxRuntime.jsx(
194
+ SheetPrimitive__namespace.Description,
195
+ {
196
+ "data-slot": "sheet-description",
197
+ className: cn("text-muted-foreground text-sm", className),
198
+ ...props
199
+ }
200
+ );
201
+ }
202
+ function Skeleton({ className, ...props }) {
203
+ return /* @__PURE__ */ jsxRuntime.jsx(
204
+ "div",
205
+ {
206
+ "data-slot": "skeleton",
207
+ className: cn("bg-accent animate-pulse rounded-md", className),
208
+ ...props
209
+ }
210
+ );
211
+ }
212
+ function TooltipProvider({
213
+ delayDuration = 0,
214
+ ...props
215
+ }) {
216
+ return /* @__PURE__ */ jsxRuntime.jsx(
217
+ TooltipPrimitive__namespace.Provider,
218
+ {
219
+ "data-slot": "tooltip-provider",
220
+ delayDuration,
221
+ ...props
222
+ }
223
+ );
224
+ }
225
+ function Tooltip({
226
+ ...props
227
+ }) {
228
+ return /* @__PURE__ */ jsxRuntime.jsx(TooltipProvider, { children: /* @__PURE__ */ jsxRuntime.jsx(TooltipPrimitive__namespace.Root, { "data-slot": "tooltip", ...props }) });
229
+ }
230
+ function TooltipTrigger({
231
+ ...props
232
+ }) {
233
+ return /* @__PURE__ */ jsxRuntime.jsx(TooltipPrimitive__namespace.Trigger, { "data-slot": "tooltip-trigger", ...props });
234
+ }
235
+ function TooltipContent({
236
+ className,
237
+ sideOffset = 0,
238
+ children,
239
+ ...props
240
+ }) {
241
+ return /* @__PURE__ */ jsxRuntime.jsx(TooltipPrimitive__namespace.Portal, { children: /* @__PURE__ */ jsxRuntime.jsxs(
242
+ TooltipPrimitive__namespace.Content,
243
+ {
244
+ "data-slot": "tooltip-content",
245
+ sideOffset,
246
+ className: cn(
247
+ "bg-foreground text-background animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-fit origin-(--radix-tooltip-content-transform-origin) rounded-md px-3 py-1.5 text-xs text-balance",
248
+ className
249
+ ),
250
+ ...props,
251
+ children: [
252
+ children,
253
+ /* @__PURE__ */ jsxRuntime.jsx(TooltipPrimitive__namespace.Arrow, { className: "bg-foreground fill-foreground z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]" })
254
+ ]
255
+ }
256
+ ) });
257
+ }
258
+ var SIDEBAR_COOKIE_NAME = "sidebar_state";
259
+ var SIDEBAR_COOKIE_MAX_AGE = 60 * 60 * 24 * 7;
260
+ var SIDEBAR_WIDTH = "16rem";
261
+ var SIDEBAR_WIDTH_MOBILE = "18rem";
262
+ var SIDEBAR_WIDTH_ICON = "3rem";
263
+ var SIDEBAR_KEYBOARD_SHORTCUT = "b";
264
+ var SidebarContext = React2__namespace.createContext(null);
265
+ function useSidebar() {
266
+ const context = React2__namespace.useContext(SidebarContext);
267
+ if (!context) {
268
+ throw new Error("useSidebar must be used within a SidebarProvider.");
269
+ }
270
+ return context;
271
+ }
272
+ function SidebarProvider({
273
+ defaultOpen = true,
274
+ open: openProp,
275
+ onOpenChange: setOpenProp,
276
+ className,
277
+ style,
278
+ children,
279
+ ...props
280
+ }) {
281
+ const isMobile = useIsMobile();
282
+ const [openMobile, setOpenMobile] = React2__namespace.useState(false);
283
+ const [_open, _setOpen] = React2__namespace.useState(defaultOpen);
284
+ const open = openProp ?? _open;
285
+ const setOpen = React2__namespace.useCallback(
286
+ (value) => {
287
+ const openState = typeof value === "function" ? value(open) : value;
288
+ if (setOpenProp) {
289
+ setOpenProp(openState);
290
+ } else {
291
+ _setOpen(openState);
292
+ }
293
+ document.cookie = `${SIDEBAR_COOKIE_NAME}=${openState}; path=/; max-age=${SIDEBAR_COOKIE_MAX_AGE}`;
294
+ },
295
+ [setOpenProp, open]
296
+ );
297
+ const toggleSidebar = React2__namespace.useCallback(() => {
298
+ return isMobile ? setOpenMobile((open2) => !open2) : setOpen((open2) => !open2);
299
+ }, [isMobile, setOpen, setOpenMobile]);
300
+ React2__namespace.useEffect(() => {
301
+ const handleKeyDown = (event) => {
302
+ if (event.key === SIDEBAR_KEYBOARD_SHORTCUT && (event.metaKey || event.ctrlKey)) {
303
+ event.preventDefault();
304
+ toggleSidebar();
305
+ }
306
+ };
307
+ window.addEventListener("keydown", handleKeyDown);
308
+ return () => window.removeEventListener("keydown", handleKeyDown);
309
+ }, [toggleSidebar]);
310
+ const state = open ? "expanded" : "collapsed";
311
+ const contextValue = React2__namespace.useMemo(
312
+ () => ({
313
+ state,
314
+ open,
315
+ setOpen,
316
+ isMobile,
317
+ openMobile,
318
+ setOpenMobile,
319
+ toggleSidebar
320
+ }),
321
+ [state, open, setOpen, isMobile, openMobile, setOpenMobile, toggleSidebar]
322
+ );
323
+ return /* @__PURE__ */ jsxRuntime.jsx(SidebarContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsxRuntime.jsx(TooltipProvider, { delayDuration: 0, children: /* @__PURE__ */ jsxRuntime.jsx(
324
+ "div",
325
+ {
326
+ "data-slot": "sidebar-wrapper",
327
+ style: {
328
+ "--sidebar-width": SIDEBAR_WIDTH,
329
+ "--sidebar-width-icon": SIDEBAR_WIDTH_ICON,
330
+ ...style
331
+ },
332
+ className: cn(
333
+ "group/sidebar-wrapper has-data-[variant=inset]:bg-sidebar flex min-h-svh w-full",
334
+ className
335
+ ),
336
+ ...props,
337
+ children
338
+ }
339
+ ) }) });
340
+ }
341
+ function Sidebar({
342
+ side = "left",
343
+ variant = "sidebar",
344
+ collapsible = "offcanvas",
345
+ className,
346
+ children,
347
+ ...props
348
+ }) {
349
+ const { isMobile, state, openMobile, setOpenMobile } = useSidebar();
350
+ if (collapsible === "none") {
351
+ return /* @__PURE__ */ jsxRuntime.jsx(
352
+ "div",
353
+ {
354
+ "data-slot": "sidebar",
355
+ className: cn(
356
+ "bg-sidebar text-sidebar-foreground flex h-full w-(--sidebar-width) flex-col",
357
+ className
358
+ ),
359
+ ...props,
360
+ children
361
+ }
362
+ );
363
+ }
364
+ if (isMobile) {
365
+ return /* @__PURE__ */ jsxRuntime.jsx(Sheet, { open: openMobile, onOpenChange: setOpenMobile, ...props, children: /* @__PURE__ */ jsxRuntime.jsxs(
366
+ SheetContent,
367
+ {
368
+ "data-sidebar": "sidebar",
369
+ "data-slot": "sidebar",
370
+ "data-mobile": "true",
371
+ className: "bg-sidebar text-sidebar-foreground w-(--sidebar-width) p-0 [&>button]:hidden",
372
+ style: {
373
+ "--sidebar-width": SIDEBAR_WIDTH_MOBILE
374
+ },
375
+ side,
376
+ children: [
377
+ /* @__PURE__ */ jsxRuntime.jsxs(SheetHeader, { className: "sr-only", children: [
378
+ /* @__PURE__ */ jsxRuntime.jsx(SheetTitle, { children: "Sidebar" }),
379
+ /* @__PURE__ */ jsxRuntime.jsx(SheetDescription, { children: "Displays the mobile sidebar." })
380
+ ] }),
381
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex h-full w-full flex-col", children })
382
+ ]
383
+ }
384
+ ) });
385
+ }
386
+ return /* @__PURE__ */ jsxRuntime.jsxs(
387
+ "div",
388
+ {
389
+ className: "group peer text-sidebar-foreground hidden md:block",
390
+ "data-state": state,
391
+ "data-collapsible": state === "collapsed" ? collapsible : "",
392
+ "data-variant": variant,
393
+ "data-side": side,
394
+ "data-slot": "sidebar",
395
+ children: [
396
+ /* @__PURE__ */ jsxRuntime.jsx(
397
+ "div",
398
+ {
399
+ "data-slot": "sidebar-gap",
400
+ className: cn(
401
+ "relative w-(--sidebar-width) bg-transparent transition-[width] duration-200 ease-linear",
402
+ "group-data-[collapsible=offcanvas]:w-0",
403
+ "group-data-[side=right]:rotate-180",
404
+ variant === "floating" || variant === "inset" ? "group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4)))]" : "group-data-[collapsible=icon]:w-(--sidebar-width-icon)"
405
+ )
406
+ }
407
+ ),
408
+ /* @__PURE__ */ jsxRuntime.jsx(
409
+ "div",
410
+ {
411
+ "data-slot": "sidebar-container",
412
+ className: cn(
413
+ "fixed inset-y-0 z-10 hidden h-svh w-(--sidebar-width) transition-[left,right,width] duration-200 ease-linear md:flex",
414
+ side === "left" ? "left-0 group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)]" : "right-0 group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)]",
415
+ // Adjust the padding for floating and inset variants.
416
+ variant === "floating" || variant === "inset" ? "p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4))+2px)]" : "group-data-[collapsible=icon]:w-(--sidebar-width-icon) group-data-[side=left]:border-r group-data-[side=right]:border-l",
417
+ className
418
+ ),
419
+ ...props,
420
+ children: /* @__PURE__ */ jsxRuntime.jsx(
421
+ "div",
422
+ {
423
+ "data-sidebar": "sidebar",
424
+ "data-slot": "sidebar-inner",
425
+ className: "bg-sidebar group-data-[variant=floating]:border-sidebar-border flex h-full w-full flex-col group-data-[variant=floating]:rounded-lg group-data-[variant=floating]:border group-data-[variant=floating]:shadow-sm",
426
+ children
427
+ }
428
+ )
429
+ }
430
+ )
431
+ ]
432
+ }
433
+ );
434
+ }
435
+ function SidebarTrigger({
436
+ className,
437
+ onClick,
438
+ ...props
439
+ }) {
440
+ const { toggleSidebar } = useSidebar();
441
+ return /* @__PURE__ */ jsxRuntime.jsxs(
442
+ Button,
443
+ {
444
+ "data-sidebar": "trigger",
445
+ "data-slot": "sidebar-trigger",
446
+ variant: "ghost",
447
+ size: "icon",
448
+ className: cn("size-7", className),
449
+ onClick: (event) => {
450
+ onClick?.(event);
451
+ toggleSidebar();
452
+ },
453
+ ...props,
454
+ children: [
455
+ /* @__PURE__ */ jsxRuntime.jsx(LucideIcons.PanelLeftIcon, {}),
456
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Toggle Sidebar" })
457
+ ]
458
+ }
459
+ );
460
+ }
461
+ function SidebarRail({ className, ...props }) {
462
+ const { toggleSidebar } = useSidebar();
463
+ return /* @__PURE__ */ jsxRuntime.jsx(
464
+ "button",
465
+ {
466
+ "data-sidebar": "rail",
467
+ "data-slot": "sidebar-rail",
468
+ "aria-label": "Toggle Sidebar",
469
+ tabIndex: -1,
470
+ onClick: toggleSidebar,
471
+ title: "Toggle Sidebar",
472
+ className: cn(
473
+ "hover:after:bg-sidebar-border absolute inset-y-0 z-20 hidden w-4 -translate-x-1/2 transition-all ease-linear group-data-[side=left]:-right-4 group-data-[side=right]:left-0 after:absolute after:inset-y-0 after:left-1/2 after:w-[2px] sm:flex",
474
+ "in-data-[side=left]:cursor-w-resize in-data-[side=right]:cursor-e-resize",
475
+ "[[data-side=left][data-state=collapsed]_&]:cursor-e-resize [[data-side=right][data-state=collapsed]_&]:cursor-w-resize",
476
+ "hover:group-data-[collapsible=offcanvas]:bg-sidebar group-data-[collapsible=offcanvas]:translate-x-0 group-data-[collapsible=offcanvas]:after:left-full",
477
+ "[[data-side=left][data-collapsible=offcanvas]_&]:-right-2",
478
+ "[[data-side=right][data-collapsible=offcanvas]_&]:-left-2",
479
+ className
480
+ ),
481
+ ...props
482
+ }
483
+ );
484
+ }
485
+ function SidebarInset({ className, ...props }) {
486
+ return /* @__PURE__ */ jsxRuntime.jsx(
487
+ "main",
488
+ {
489
+ "data-slot": "sidebar-inset",
490
+ className: cn(
491
+ "bg-background relative flex w-full flex-1 flex-col",
492
+ "px-4",
493
+ "md:peer-data-[variant=inset]:m-2 md:peer-data-[variant=inset]:ml-0 md:peer-data-[variant=inset]:rounded-xl md:peer-data-[variant=inset]:shadow-sm md:peer-data-[variant=inset]:peer-data-[state=collapsed]:ml-2",
494
+ className
495
+ ),
496
+ ...props
497
+ }
498
+ );
499
+ }
500
+ function SidebarHeader({ className, ...props }) {
501
+ return /* @__PURE__ */ jsxRuntime.jsx(
502
+ "div",
503
+ {
504
+ "data-slot": "sidebar-header",
505
+ "data-sidebar": "header",
506
+ className: cn("flex flex-col gap-2 p-2", className),
507
+ ...props
508
+ }
509
+ );
510
+ }
511
+ function SidebarFooter({ className, ...props }) {
512
+ return /* @__PURE__ */ jsxRuntime.jsx(
513
+ "div",
514
+ {
515
+ "data-slot": "sidebar-footer",
516
+ "data-sidebar": "footer",
517
+ className: cn("flex flex-col gap-2 p-2", className),
518
+ ...props
519
+ }
520
+ );
521
+ }
522
+ function SidebarContent({ className, ...props }) {
523
+ return /* @__PURE__ */ jsxRuntime.jsx(
524
+ "div",
525
+ {
526
+ "data-slot": "sidebar-content",
527
+ "data-sidebar": "content",
528
+ className: cn(
529
+ "flex min-h-0 flex-1 flex-col gap-2 overflow-auto group-data-[collapsible=icon]:overflow-hidden",
530
+ className
531
+ ),
532
+ ...props
533
+ }
534
+ );
535
+ }
536
+ function SidebarGroup({ className, ...props }) {
537
+ return /* @__PURE__ */ jsxRuntime.jsx(
538
+ "div",
539
+ {
540
+ "data-slot": "sidebar-group",
541
+ "data-sidebar": "group",
542
+ className: cn("relative flex w-full min-w-0 flex-col p-2", className),
543
+ ...props
544
+ }
545
+ );
546
+ }
547
+ function SidebarGroupLabel({
548
+ className,
549
+ asChild = false,
550
+ ...props
551
+ }) {
552
+ const Comp = asChild ? reactSlot.Slot : "div";
553
+ return /* @__PURE__ */ jsxRuntime.jsx(
554
+ Comp,
555
+ {
556
+ "data-slot": "sidebar-group-label",
557
+ "data-sidebar": "group-label",
558
+ className: cn(
559
+ "text-sidebar-foreground/70 ring-sidebar-ring flex h-8 shrink-0 items-center rounded-md px-2 text-xs font-medium outline-hidden transition-[margin,opacity] duration-200 ease-linear focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0",
560
+ "group-data-[collapsible=icon]:-mt-8 group-data-[collapsible=icon]:opacity-0",
561
+ className
562
+ ),
563
+ ...props
564
+ }
565
+ );
566
+ }
567
+ function SidebarMenu({ className, ...props }) {
568
+ return /* @__PURE__ */ jsxRuntime.jsx(
569
+ "ul",
570
+ {
571
+ "data-slot": "sidebar-menu",
572
+ "data-sidebar": "menu",
573
+ className: cn("flex w-full min-w-0 flex-col gap-1", className),
574
+ ...props
575
+ }
576
+ );
577
+ }
578
+ function SidebarMenuItem({ className, ...props }) {
579
+ return /* @__PURE__ */ jsxRuntime.jsx(
580
+ "li",
581
+ {
582
+ "data-slot": "sidebar-menu-item",
583
+ "data-sidebar": "menu-item",
584
+ className: cn("group/menu-item relative", className),
585
+ ...props
586
+ }
587
+ );
588
+ }
589
+ var sidebarMenuButtonVariants = classVarianceAuthority.cva(
590
+ "peer/menu-button flex w-full items-center gap-2 overflow-hidden rounded-md p-2 text-left text-sm outline-hidden ring-sidebar-ring transition-[width,height,padding] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 group-has-data-[sidebar=menu-action]/menu-item:pr-8 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-[active=true]:bg-sidebar-accent data-[active=true]:font-medium data-[active=true]:text-sidebar-accent-foreground data-[state=open]:hover:bg-sidebar-accent data-[state=open]:hover:text-sidebar-accent-foreground group-data-[collapsible=icon]:size-8! group-data-[collapsible=icon]:p-2! [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0",
591
+ {
592
+ variants: {
593
+ variant: {
594
+ default: "hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",
595
+ outline: "bg-background shadow-[0_0_0_1px_hsl(var(--sidebar-border))] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground hover:shadow-[0_0_0_1px_hsl(var(--sidebar-accent))]"
596
+ },
597
+ size: {
598
+ default: "h-8 text-sm",
599
+ sm: "h-7 text-xs",
600
+ lg: "h-12 text-sm group-data-[collapsible=icon]:p-0!"
601
+ }
602
+ },
603
+ defaultVariants: {
604
+ variant: "default",
605
+ size: "default"
606
+ }
607
+ }
608
+ );
609
+ function SidebarMenuButton({
610
+ asChild = false,
611
+ isActive = false,
612
+ variant = "default",
613
+ size = "default",
614
+ tooltip,
615
+ className,
616
+ ...props
617
+ }) {
618
+ const Comp = asChild ? reactSlot.Slot : "button";
619
+ const { isMobile, state } = useSidebar();
620
+ const button = /* @__PURE__ */ jsxRuntime.jsx(
621
+ Comp,
622
+ {
623
+ "data-slot": "sidebar-menu-button",
624
+ "data-sidebar": "menu-button",
625
+ "data-size": size,
626
+ "data-active": isActive,
627
+ className: cn(sidebarMenuButtonVariants({ variant, size }), className),
628
+ ...props
629
+ }
630
+ );
631
+ if (!tooltip) {
632
+ return button;
633
+ }
634
+ if (typeof tooltip === "string") {
635
+ tooltip = {
636
+ children: tooltip
637
+ };
638
+ }
639
+ return /* @__PURE__ */ jsxRuntime.jsxs(Tooltip, { children: [
640
+ /* @__PURE__ */ jsxRuntime.jsx(TooltipTrigger, { asChild: true, children: button }),
641
+ /* @__PURE__ */ jsxRuntime.jsx(
642
+ TooltipContent,
643
+ {
644
+ side: "right",
645
+ align: "center",
646
+ hidden: state !== "collapsed" || isMobile,
647
+ ...tooltip
648
+ }
649
+ )
650
+ ] });
651
+ }
652
+ function SidebarMenuSub({ className, ...props }) {
653
+ return /* @__PURE__ */ jsxRuntime.jsx(
654
+ "ul",
655
+ {
656
+ "data-slot": "sidebar-menu-sub",
657
+ "data-sidebar": "menu-sub",
658
+ className: cn(
659
+ "border-sidebar-border mx-3.5 flex min-w-0 translate-x-px flex-col gap-1 border-l px-2.5 py-0.5",
660
+ "group-data-[collapsible=icon]:hidden",
661
+ className
662
+ ),
663
+ ...props
664
+ }
665
+ );
666
+ }
667
+ function SidebarMenuSubItem({
668
+ className,
669
+ ...props
670
+ }) {
671
+ return /* @__PURE__ */ jsxRuntime.jsx(
672
+ "li",
673
+ {
674
+ "data-slot": "sidebar-menu-sub-item",
675
+ "data-sidebar": "menu-sub-item",
676
+ className: cn("group/menu-sub-item relative", className),
677
+ ...props
678
+ }
679
+ );
680
+ }
681
+ function SidebarMenuSubButton({
682
+ asChild = false,
683
+ size = "md",
684
+ isActive = false,
685
+ className,
686
+ ...props
687
+ }) {
688
+ const Comp = asChild ? reactSlot.Slot : "a";
689
+ return /* @__PURE__ */ jsxRuntime.jsx(
690
+ Comp,
691
+ {
692
+ "data-slot": "sidebar-menu-sub-button",
693
+ "data-sidebar": "menu-sub-button",
694
+ "data-size": size,
695
+ "data-active": isActive,
696
+ className: cn(
697
+ "text-sidebar-foreground ring-sidebar-ring hover:bg-sidebar-accent hover:text-sidebar-accent-foreground active:bg-sidebar-accent active:text-sidebar-accent-foreground [&>svg]:text-sidebar-accent-foreground flex h-7 min-w-0 -translate-x-px items-center gap-2 overflow-hidden rounded-md px-2 outline-hidden focus-visible:ring-2 disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0",
698
+ "data-[active=true]:bg-sidebar-accent data-[active=true]:text-sidebar-accent-foreground",
699
+ size === "sm" && "text-xs",
700
+ size === "md" && "text-sm",
701
+ "group-data-[collapsible=icon]:hidden",
702
+ className
703
+ ),
704
+ ...props
705
+ }
706
+ );
707
+ }
708
+ function Collapsible({
709
+ ...props
710
+ }) {
711
+ return /* @__PURE__ */ jsxRuntime.jsx(CollapsiblePrimitive__namespace.Root, { "data-slot": "collapsible", ...props });
712
+ }
713
+ function CollapsibleTrigger2({
714
+ ...props
715
+ }) {
716
+ return /* @__PURE__ */ jsxRuntime.jsx(
717
+ CollapsiblePrimitive__namespace.CollapsibleTrigger,
718
+ {
719
+ "data-slot": "collapsible-trigger",
720
+ ...props
721
+ }
722
+ );
723
+ }
724
+ function CollapsibleContent2({
725
+ ...props
726
+ }) {
727
+ return /* @__PURE__ */ jsxRuntime.jsx(
728
+ CollapsiblePrimitive__namespace.CollapsibleContent,
729
+ {
730
+ "data-slot": "collapsible-content",
731
+ ...props
732
+ }
733
+ );
734
+ }
735
+ var ICON_MAP = {
736
+ Home: LucideIcons__namespace.Home,
737
+ Users: LucideIcons__namespace.Users,
738
+ GalleryVerticalEnd: LucideIcons__namespace.GalleryVerticalEnd,
739
+ Settings: LucideIcons__namespace.Settings,
740
+ CreditCard: LucideIcons__namespace.CreditCard,
741
+ Building2: LucideIcons__namespace.Building2,
742
+ Check: LucideIcons__namespace.Check,
743
+ ChevronsUpDown: LucideIcons__namespace.ChevronsUpDown,
744
+ ChevronRight: LucideIcons__namespace.ChevronRight,
745
+ BadgeCheck: LucideIcons__namespace.BadgeCheck,
746
+ LogOut: LucideIcons__namespace.LogOut
747
+ // Add more icons as needed
748
+ };
749
+ function getIconComponent(icon) {
750
+ if (!icon) {
751
+ return void 0;
752
+ }
753
+ if (typeof icon !== "string") {
754
+ return icon;
755
+ }
756
+ return ICON_MAP[icon];
757
+ }
758
+ function NavMain({ items }) {
759
+ const pathname = navigation.usePathname();
760
+ const groups = [];
761
+ let currentGroup = {
762
+ items: []
763
+ };
764
+ items.forEach((item) => {
765
+ const iconComponent = getIconComponent(item.icon);
766
+ if (!item.url) {
767
+ if (currentGroup.items.length > 0 || currentGroup.label) {
768
+ groups.push(currentGroup);
769
+ }
770
+ currentGroup = {
771
+ label: { title: item.title, icon: iconComponent },
772
+ items: []
773
+ };
774
+ } else {
775
+ currentGroup.items.push({
776
+ title: item.title,
777
+ url: item.url,
778
+ icon: iconComponent,
779
+ isActive: item.isActive,
780
+ items: item.items
781
+ });
782
+ }
783
+ });
784
+ if (currentGroup.items.length > 0 || currentGroup.label) {
785
+ groups.push(currentGroup);
786
+ }
787
+ return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: groups.map((group, groupIndex) => /* @__PURE__ */ jsxRuntime.jsxs(SidebarGroup, { children: [
788
+ group.label && /* @__PURE__ */ jsxRuntime.jsxs(SidebarGroupLabel, { children: [
789
+ group.label.icon && /* @__PURE__ */ jsxRuntime.jsx(group.label.icon, { className: "mr-2" }),
790
+ group.label.title
791
+ ] }),
792
+ group.items.length > 0 && /* @__PURE__ */ jsxRuntime.jsx(SidebarMenu, { children: group.items.map((item) => {
793
+ const isActive = pathname === item.url || item.isActive;
794
+ const hasSubItems = item.items && item.items.length > 0;
795
+ if (hasSubItems) {
796
+ return /* @__PURE__ */ jsxRuntime.jsx(
797
+ Collapsible,
798
+ {
799
+ asChild: true,
800
+ defaultOpen: isActive,
801
+ className: "group/collapsible",
802
+ children: /* @__PURE__ */ jsxRuntime.jsxs(SidebarMenuItem, { children: [
803
+ /* @__PURE__ */ jsxRuntime.jsx(CollapsibleTrigger2, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsxs(
804
+ SidebarMenuButton,
805
+ {
806
+ tooltip: item.title,
807
+ isActive,
808
+ children: [
809
+ item.icon && /* @__PURE__ */ jsxRuntime.jsx(item.icon, {}),
810
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: item.title }),
811
+ /* @__PURE__ */ jsxRuntime.jsx(LucideIcons.ChevronRight, { className: "ml-auto transition-transform duration-200 group-data-[state=open]/collapsible:rotate-90" })
812
+ ]
813
+ }
814
+ ) }),
815
+ /* @__PURE__ */ jsxRuntime.jsx(CollapsibleContent2, { children: /* @__PURE__ */ jsxRuntime.jsx(SidebarMenuSub, { children: item.items?.map((subItem) => /* @__PURE__ */ jsxRuntime.jsx(SidebarMenuSubItem, { children: /* @__PURE__ */ jsxRuntime.jsx(SidebarMenuSubButton, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(Link__default.default, { href: subItem.url, children: /* @__PURE__ */ jsxRuntime.jsx("span", { children: subItem.title }) }) }) }, subItem.title)) }) })
816
+ ] })
817
+ },
818
+ item.title
819
+ );
820
+ }
821
+ return /* @__PURE__ */ jsxRuntime.jsx(SidebarMenuItem, { children: /* @__PURE__ */ jsxRuntime.jsx(
822
+ SidebarMenuButton,
823
+ {
824
+ asChild: true,
825
+ tooltip: item.title,
826
+ isActive,
827
+ children: /* @__PURE__ */ jsxRuntime.jsxs(Link__default.default, { href: item.url, children: [
828
+ item.icon && /* @__PURE__ */ jsxRuntime.jsx(item.icon, {}),
829
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: item.title })
830
+ ] })
831
+ }
832
+ ) }, item.title);
833
+ }) })
834
+ ] }, groupIndex)) });
835
+ }
836
+ function Avatar({
837
+ className,
838
+ ...props
839
+ }) {
840
+ return /* @__PURE__ */ jsxRuntime.jsx(
841
+ AvatarPrimitive__namespace.Root,
842
+ {
843
+ "data-slot": "avatar",
844
+ className: cn(
845
+ "relative flex size-8 shrink-0 overflow-hidden rounded-full",
846
+ className
847
+ ),
848
+ ...props
849
+ }
850
+ );
851
+ }
852
+ function AvatarImage({
853
+ className,
854
+ ...props
855
+ }) {
856
+ return /* @__PURE__ */ jsxRuntime.jsx(
857
+ AvatarPrimitive__namespace.Image,
858
+ {
859
+ "data-slot": "avatar-image",
860
+ className: cn("aspect-square size-full", className),
861
+ ...props
862
+ }
863
+ );
864
+ }
865
+ function AvatarFallback({
866
+ className,
867
+ ...props
868
+ }) {
869
+ return /* @__PURE__ */ jsxRuntime.jsx(
870
+ AvatarPrimitive__namespace.Fallback,
871
+ {
872
+ "data-slot": "avatar-fallback",
873
+ className: cn(
874
+ "bg-muted flex size-full items-center justify-center rounded-full",
875
+ className
876
+ ),
877
+ ...props
878
+ }
879
+ );
880
+ }
881
+ function DropdownMenu({
882
+ ...props
883
+ }) {
884
+ return /* @__PURE__ */ jsxRuntime.jsx(DropdownMenuPrimitive__namespace.Root, { "data-slot": "dropdown-menu", ...props });
885
+ }
886
+ function DropdownMenuTrigger({
887
+ ...props
888
+ }) {
889
+ return /* @__PURE__ */ jsxRuntime.jsx(
890
+ DropdownMenuPrimitive__namespace.Trigger,
891
+ {
892
+ "data-slot": "dropdown-menu-trigger",
893
+ ...props
894
+ }
895
+ );
896
+ }
897
+ function DropdownMenuContent({
898
+ className,
899
+ sideOffset = 4,
900
+ ...props
901
+ }) {
902
+ return /* @__PURE__ */ jsxRuntime.jsx(DropdownMenuPrimitive__namespace.Portal, { children: /* @__PURE__ */ jsxRuntime.jsx(
903
+ DropdownMenuPrimitive__namespace.Content,
904
+ {
905
+ "data-slot": "dropdown-menu-content",
906
+ sideOffset,
907
+ className: cn(
908
+ "bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 max-h-(--radix-dropdown-menu-content-available-height) min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border p-1 shadow-md",
909
+ className
910
+ ),
911
+ ...props
912
+ }
913
+ ) });
914
+ }
915
+ function DropdownMenuGroup({
916
+ ...props
917
+ }) {
918
+ return /* @__PURE__ */ jsxRuntime.jsx(DropdownMenuPrimitive__namespace.Group, { "data-slot": "dropdown-menu-group", ...props });
919
+ }
920
+ function DropdownMenuItem({
921
+ className,
922
+ inset,
923
+ variant = "default",
924
+ ...props
925
+ }) {
926
+ return /* @__PURE__ */ jsxRuntime.jsx(
927
+ DropdownMenuPrimitive__namespace.Item,
928
+ {
929
+ "data-slot": "dropdown-menu-item",
930
+ "data-inset": inset,
931
+ "data-variant": variant,
932
+ className: cn(
933
+ "focus:bg-accent focus:text-accent-foreground data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 dark:data-[variant=destructive]:focus:bg-destructive/20 data-[variant=destructive]:focus:text-destructive data-[variant=destructive]:*:[svg]:!text-destructive [&_svg:not([class*='text-'])]:text-muted-foreground relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 data-[inset]:pl-8 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
934
+ className
935
+ ),
936
+ ...props
937
+ }
938
+ );
939
+ }
940
+ function DropdownMenuLabel({
941
+ className,
942
+ inset,
943
+ ...props
944
+ }) {
945
+ return /* @__PURE__ */ jsxRuntime.jsx(
946
+ DropdownMenuPrimitive__namespace.Label,
947
+ {
948
+ "data-slot": "dropdown-menu-label",
949
+ "data-inset": inset,
950
+ className: cn(
951
+ "px-2 py-1.5 text-sm font-medium data-[inset]:pl-8",
952
+ className
953
+ ),
954
+ ...props
955
+ }
956
+ );
957
+ }
958
+ function DropdownMenuSeparator({
959
+ className,
960
+ ...props
961
+ }) {
962
+ return /* @__PURE__ */ jsxRuntime.jsx(
963
+ DropdownMenuPrimitive__namespace.Separator,
964
+ {
965
+ "data-slot": "dropdown-menu-separator",
966
+ className: cn("bg-border -mx-1 my-1 h-px", className),
967
+ ...props
968
+ }
969
+ );
970
+ }
971
+ function getInitials(name, email) {
972
+ if (name) {
973
+ const parts = name.trim().split(/\s+/);
974
+ if (parts.length >= 2) {
975
+ const first = parts[0];
976
+ const last = parts[parts.length - 1];
977
+ if (first && last && first[0] && last[0]) {
978
+ return (first[0] + last[0]).toUpperCase();
979
+ }
980
+ }
981
+ const firstChar2 = name[0];
982
+ if (firstChar2) {
983
+ return firstChar2.toUpperCase();
984
+ }
985
+ }
986
+ const firstChar = email[0];
987
+ if (firstChar) {
988
+ return firstChar.toUpperCase();
989
+ }
990
+ return "?";
991
+ }
992
+ function NavUser({ user }) {
993
+ const sidebar = useSidebar();
994
+ const isMobile = sidebar?.isMobile ?? false;
995
+ const router = navigation.useRouter();
996
+ const initials = getInitials(user.name, user.email);
997
+ const displayName = user.name || user.email;
998
+ const handleSignOut = async () => {
999
+ await react.signOut({ redirect: false });
1000
+ router.push("/auth/signin");
1001
+ router.refresh();
1002
+ };
1003
+ return /* @__PURE__ */ jsxRuntime.jsx(SidebarMenu, { children: /* @__PURE__ */ jsxRuntime.jsx(SidebarMenuItem, { children: /* @__PURE__ */ jsxRuntime.jsxs(DropdownMenu, { children: [
1004
+ /* @__PURE__ */ jsxRuntime.jsx(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsxs(
1005
+ SidebarMenuButton,
1006
+ {
1007
+ size: "lg",
1008
+ className: "data-[state=open]:bg-sidebar-accent data-[state=open]:text-sidebar-accent-foreground",
1009
+ children: [
1010
+ /* @__PURE__ */ jsxRuntime.jsxs(Avatar, { className: "h-8 w-8 rounded-lg", children: [
1011
+ /* @__PURE__ */ jsxRuntime.jsx(AvatarImage, { src: user.image || void 0, alt: displayName }),
1012
+ /* @__PURE__ */ jsxRuntime.jsx(AvatarFallback, { className: "rounded-lg", children: initials })
1013
+ ] }),
1014
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid flex-1 text-left text-sm leading-tight", children: [
1015
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate font-medium", children: displayName }),
1016
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate text-xs", children: user.email })
1017
+ ] }),
1018
+ /* @__PURE__ */ jsxRuntime.jsx(LucideIcons.ChevronsUpDown, { className: "ml-auto size-4" })
1019
+ ]
1020
+ }
1021
+ ) }),
1022
+ /* @__PURE__ */ jsxRuntime.jsxs(
1023
+ DropdownMenuContent,
1024
+ {
1025
+ className: "w-(--radix-dropdown-menu-trigger-width) min-w-56 rounded-lg",
1026
+ side: isMobile ? "bottom" : "right",
1027
+ align: "end",
1028
+ sideOffset: 4,
1029
+ children: [
1030
+ /* @__PURE__ */ jsxRuntime.jsx(DropdownMenuLabel, { className: "p-0 font-normal", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2 px-1 py-1.5 text-left text-sm", children: [
1031
+ /* @__PURE__ */ jsxRuntime.jsxs(Avatar, { className: "h-8 w-8 rounded-lg", children: [
1032
+ /* @__PURE__ */ jsxRuntime.jsx(AvatarImage, { src: user.image || void 0, alt: displayName }),
1033
+ /* @__PURE__ */ jsxRuntime.jsx(AvatarFallback, { className: "rounded-lg", children: initials })
1034
+ ] }),
1035
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid flex-1 text-left text-sm leading-tight", children: [
1036
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate font-medium", children: displayName }),
1037
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate text-xs", children: user.email })
1038
+ ] })
1039
+ ] }) }),
1040
+ /* @__PURE__ */ jsxRuntime.jsx(DropdownMenuSeparator, {}),
1041
+ /* @__PURE__ */ jsxRuntime.jsx(DropdownMenuGroup, { children: /* @__PURE__ */ jsxRuntime.jsxs(DropdownMenuItem, { children: [
1042
+ /* @__PURE__ */ jsxRuntime.jsx(LucideIcons.BadgeCheck, {}),
1043
+ "Account"
1044
+ ] }) }),
1045
+ /* @__PURE__ */ jsxRuntime.jsx(DropdownMenuSeparator, {}),
1046
+ /* @__PURE__ */ jsxRuntime.jsxs(DropdownMenuItem, { onClick: handleSignOut, children: [
1047
+ /* @__PURE__ */ jsxRuntime.jsx(LucideIcons.LogOut, {}),
1048
+ "Log out"
1049
+ ] })
1050
+ ]
1051
+ }
1052
+ )
1053
+ ] }) }) });
1054
+ }
1055
+ function TeamSwitcher({
1056
+ teams,
1057
+ organizationId
1058
+ }) {
1059
+ const sidebar = useSidebar();
1060
+ const isMobile = sidebar?.isMobile ?? false;
1061
+ const pathname = navigation.usePathname();
1062
+ const router = navigation.useRouter();
1063
+ const pathSegments = pathname.split("/");
1064
+ const isAppOrgRoute = pathname.startsWith("/app/") && pathSegments.length > 2 && pathSegments[2] !== "user";
1065
+ const pathOrgId = isAppOrgRoute ? pathSegments[2] : null;
1066
+ const currentOrgId = organizationId || (pathOrgId && teams.some((team) => team.id === pathOrgId) ? pathOrgId : null);
1067
+ const activeTeam = currentOrgId ? teams.find((team) => team.id === currentOrgId) : null;
1068
+ const handleTeamChange = (teamId) => {
1069
+ router.push(`/app/${teamId}/home`);
1070
+ router.refresh();
1071
+ };
1072
+ const teamsWithLogo = teams.map((org) => {
1073
+ const logoIcon = org.logo ? getIconComponent(org.logo) : LucideIcons.GalleryVerticalEnd;
1074
+ return {
1075
+ id: org.id,
1076
+ name: org.name,
1077
+ logo: logoIcon || LucideIcons.GalleryVerticalEnd,
1078
+ plan: org.plan || "Member"
1079
+ };
1080
+ });
1081
+ if (teamsWithLogo.length === 0) {
1082
+ return /* @__PURE__ */ jsxRuntime.jsx(SidebarMenu, { children: /* @__PURE__ */ jsxRuntime.jsx(SidebarMenuItem, { children: /* @__PURE__ */ jsxRuntime.jsxs(SidebarMenuButton, { size: "lg", className: "cursor-default", children: [
1083
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "bg-muted flex aspect-square size-8 items-center justify-center rounded-lg", children: /* @__PURE__ */ jsxRuntime.jsx(LucideIcons.GalleryVerticalEnd, { className: "size-4 text-muted-foreground" }) }),
1084
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid flex-1 text-left text-sm leading-tight", children: [
1085
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate font-medium text-muted-foreground", children: "No organizations" }),
1086
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate text-xs text-muted-foreground", children: "Join or create one" })
1087
+ ] })
1088
+ ] }) }) });
1089
+ }
1090
+ if (!activeTeam) {
1091
+ return /* @__PURE__ */ jsxRuntime.jsx(SidebarMenu, { children: /* @__PURE__ */ jsxRuntime.jsx(SidebarMenuItem, { children: /* @__PURE__ */ jsxRuntime.jsxs(DropdownMenu, { children: [
1092
+ /* @__PURE__ */ jsxRuntime.jsx(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsxs(
1093
+ SidebarMenuButton,
1094
+ {
1095
+ size: "lg",
1096
+ className: "data-[state=open]:bg-sidebar-accent data-[state=open]:text-sidebar-accent-foreground",
1097
+ children: [
1098
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "bg-muted flex aspect-square size-8 items-center justify-center rounded-lg", children: /* @__PURE__ */ jsxRuntime.jsx(LucideIcons.GalleryVerticalEnd, { className: "size-4 text-muted-foreground" }) }),
1099
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid flex-1 text-left text-sm leading-tight", children: [
1100
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate font-medium", children: "Organizations" }),
1101
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "truncate text-xs text-muted-foreground", children: [
1102
+ teamsWithLogo.length,
1103
+ " available"
1104
+ ] })
1105
+ ] }),
1106
+ /* @__PURE__ */ jsxRuntime.jsx(LucideIcons.ChevronsUpDown, { className: "ml-auto" })
1107
+ ]
1108
+ }
1109
+ ) }),
1110
+ /* @__PURE__ */ jsxRuntime.jsxs(
1111
+ DropdownMenuContent,
1112
+ {
1113
+ className: "w-(--radix-dropdown-menu-trigger-width) min-w-56 rounded-lg",
1114
+ align: "start",
1115
+ side: isMobile ? "bottom" : "right",
1116
+ sideOffset: 4,
1117
+ children: [
1118
+ /* @__PURE__ */ jsxRuntime.jsx(DropdownMenuLabel, { className: "text-muted-foreground text-xs", children: "Select an organization" }),
1119
+ teamsWithLogo.map((team) => /* @__PURE__ */ jsxRuntime.jsxs(
1120
+ DropdownMenuItem,
1121
+ {
1122
+ onClick: () => handleTeamChange(team.id),
1123
+ className: "gap-2 p-2",
1124
+ children: [
1125
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex size-6 items-center justify-center rounded-md border", children: /* @__PURE__ */ jsxRuntime.jsx(team.logo, { className: "size-3.5 shrink-0" }) }),
1126
+ team.name
1127
+ ]
1128
+ },
1129
+ team.id
1130
+ )),
1131
+ /* @__PURE__ */ jsxRuntime.jsx(DropdownMenuSeparator, {}),
1132
+ /* @__PURE__ */ jsxRuntime.jsxs(
1133
+ DropdownMenuItem,
1134
+ {
1135
+ className: "gap-2 p-2",
1136
+ onClick: () => router.push("/app/user/organizations"),
1137
+ children: [
1138
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex size-6 items-center justify-center rounded-md border bg-transparent", children: /* @__PURE__ */ jsxRuntime.jsx(LucideIcons.GalleryVerticalEnd, { className: "size-4" }) }),
1139
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-muted-foreground font-medium", children: "Manage organizations" })
1140
+ ]
1141
+ }
1142
+ )
1143
+ ]
1144
+ }
1145
+ )
1146
+ ] }) }) });
1147
+ }
1148
+ const activeTeamWithLogo = teamsWithLogo.find(
1149
+ (team) => team.id === currentOrgId
1150
+ );
1151
+ if (!activeTeamWithLogo) {
1152
+ return null;
1153
+ }
1154
+ return /* @__PURE__ */ jsxRuntime.jsx(SidebarMenu, { children: /* @__PURE__ */ jsxRuntime.jsx(SidebarMenuItem, { children: /* @__PURE__ */ jsxRuntime.jsxs(DropdownMenu, { children: [
1155
+ /* @__PURE__ */ jsxRuntime.jsx(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsxs(
1156
+ SidebarMenuButton,
1157
+ {
1158
+ size: "lg",
1159
+ className: "data-[state=open]:bg-sidebar-accent data-[state=open]:text-sidebar-accent-foreground",
1160
+ children: [
1161
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "bg-sidebar-primary text-sidebar-primary-foreground flex aspect-square size-8 items-center justify-center rounded-lg", children: /* @__PURE__ */ jsxRuntime.jsx(activeTeamWithLogo.logo, { className: "size-4" }) }),
1162
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid flex-1 text-left text-sm leading-tight", children: [
1163
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate font-medium", children: activeTeamWithLogo.name }),
1164
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate text-xs", children: activeTeamWithLogo.plan })
1165
+ ] }),
1166
+ /* @__PURE__ */ jsxRuntime.jsx(LucideIcons.ChevronsUpDown, { className: "ml-auto" })
1167
+ ]
1168
+ }
1169
+ ) }),
1170
+ /* @__PURE__ */ jsxRuntime.jsxs(
1171
+ DropdownMenuContent,
1172
+ {
1173
+ className: "w-(--radix-dropdown-menu-trigger-width) min-w-56 rounded-lg",
1174
+ align: "start",
1175
+ side: isMobile ? "bottom" : "right",
1176
+ sideOffset: 4,
1177
+ children: [
1178
+ /* @__PURE__ */ jsxRuntime.jsx(DropdownMenuLabel, { className: "text-muted-foreground text-xs", children: "Organizations" }),
1179
+ teamsWithLogo.map((team) => /* @__PURE__ */ jsxRuntime.jsxs(
1180
+ DropdownMenuItem,
1181
+ {
1182
+ onClick: () => handleTeamChange(team.id),
1183
+ className: "gap-2 p-2",
1184
+ children: [
1185
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex size-6 items-center justify-center rounded-md border", children: /* @__PURE__ */ jsxRuntime.jsx(team.logo, { className: "size-3.5 shrink-0" }) }),
1186
+ team.name,
1187
+ team.id === currentOrgId && /* @__PURE__ */ jsxRuntime.jsx(LucideIcons.Check, { className: "ml-auto h-4 w-4" })
1188
+ ]
1189
+ },
1190
+ team.id
1191
+ )),
1192
+ /* @__PURE__ */ jsxRuntime.jsx(DropdownMenuSeparator, {}),
1193
+ /* @__PURE__ */ jsxRuntime.jsxs(
1194
+ DropdownMenuItem,
1195
+ {
1196
+ className: "gap-2 p-2",
1197
+ onClick: () => router.push("/app/user/organizations"),
1198
+ children: [
1199
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex size-6 items-center justify-center rounded-md border bg-transparent", children: /* @__PURE__ */ jsxRuntime.jsx(LucideIcons.GalleryVerticalEnd, { className: "size-4" }) }),
1200
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-muted-foreground font-medium", children: "Manage organizations" })
1201
+ ]
1202
+ }
1203
+ )
1204
+ ]
1205
+ }
1206
+ )
1207
+ ] }) }) });
1208
+ }
1209
+ function useNavigation({
1210
+ organizationId,
1211
+ apiBaseUrl = "/api",
1212
+ enabled = true
1213
+ } = {}) {
1214
+ const [items, setItems] = React2.useState([]);
1215
+ const [organizations, setOrganizations] = React2.useState([]);
1216
+ const [user, setUser] = React2.useState(null);
1217
+ const [loading, setLoading] = React2.useState(false);
1218
+ const [error, setError] = React2.useState(null);
1219
+ React2.useEffect(() => {
1220
+ if (!enabled || !organizationId) {
1221
+ setItems([]);
1222
+ setOrganizations([]);
1223
+ setUser(null);
1224
+ return;
1225
+ }
1226
+ const fetchNavigation = async () => {
1227
+ setLoading(true);
1228
+ setError(null);
1229
+ try {
1230
+ const response = await fetch(
1231
+ `${apiBaseUrl}/navigation/${organizationId}`,
1232
+ {
1233
+ credentials: "include"
1234
+ // Include cookies for auth
1235
+ }
1236
+ );
1237
+ if (!response.ok) {
1238
+ if (response.status === 401) {
1239
+ throw new Error("Unauthorized");
1240
+ }
1241
+ if (response.status === 404) {
1242
+ throw new Error("Organization not found");
1243
+ }
1244
+ throw new Error(`Failed to fetch navigation: ${response.statusText}`);
1245
+ }
1246
+ const data = await response.json();
1247
+ setItems(data.items || []);
1248
+ setOrganizations(data.organizations || []);
1249
+ setUser(data.user || null);
1250
+ } catch (err) {
1251
+ const error2 = err instanceof Error ? err : new Error("Unknown error");
1252
+ setError(error2);
1253
+ setItems([]);
1254
+ setOrganizations([]);
1255
+ setUser(null);
1256
+ } finally {
1257
+ setLoading(false);
1258
+ }
1259
+ };
1260
+ fetchNavigation();
1261
+ }, [organizationId, apiBaseUrl, enabled]);
1262
+ return { items, organizations, user, loading, error };
1263
+ }
1264
+ function AppSidebar({
1265
+ user: userProp,
1266
+ organizationId,
1267
+ apiBaseUrl,
1268
+ ...props
1269
+ }) {
1270
+ const currentPathname = navigation.usePathname();
1271
+ const pathSegments = currentPathname.split("/");
1272
+ const isAppOrgRoute = currentPathname.startsWith("/app/") && pathSegments.length > 2 && pathSegments[2] !== "user";
1273
+ const pathOrgId = isAppOrgRoute ? pathSegments[2] : null;
1274
+ const {
1275
+ items: apiNavigationItems,
1276
+ organizations: apiOrganizations,
1277
+ user: navigationUser,
1278
+ loading: navigationLoading
1279
+ } = useNavigation({
1280
+ organizationId: organizationId || pathOrgId || void 0,
1281
+ apiBaseUrl,
1282
+ enabled: true
1283
+ });
1284
+ const user = navigationUser || userProp;
1285
+ const currentOrgId = organizationId || (pathOrgId && apiOrganizations.some((org) => org.id === pathOrgId) ? pathOrgId : void 0);
1286
+ let navigationItems = apiNavigationItems;
1287
+ if (currentOrgId && navigationItems.length > 0) {
1288
+ navigationItems = navigationItems.map((item) => ({
1289
+ ...item,
1290
+ url: item.url?.replace("{organizationId}", currentOrgId),
1291
+ items: item.items?.map((subItem) => ({
1292
+ ...subItem,
1293
+ url: subItem.url.replace("{organizationId}", currentOrgId)
1294
+ }))
1295
+ }));
1296
+ }
1297
+ const displayNavigationItems = currentOrgId ? navigationItems : [];
1298
+ return /* @__PURE__ */ jsxRuntime.jsxs(Sidebar, { collapsible: "icon", ...props, children: [
1299
+ /* @__PURE__ */ jsxRuntime.jsx(SidebarHeader, { children: /* @__PURE__ */ jsxRuntime.jsx(
1300
+ TeamSwitcher,
1301
+ {
1302
+ teams: apiOrganizations,
1303
+ organizationId: currentOrgId || void 0
1304
+ }
1305
+ ) }),
1306
+ /* @__PURE__ */ jsxRuntime.jsx(SidebarContent, { children: navigationLoading ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "p-4 text-sm text-muted-foreground", children: "Loading..." }) : /* @__PURE__ */ jsxRuntime.jsx(NavMain, { items: displayNavigationItems }) }),
1307
+ /* @__PURE__ */ jsxRuntime.jsx(SidebarFooter, { children: user ? /* @__PURE__ */ jsxRuntime.jsx(NavUser, { user }) : /* @__PURE__ */ jsxRuntime.jsx(SidebarMenu, { children: /* @__PURE__ */ jsxRuntime.jsx(SidebarMenuItem, { children: /* @__PURE__ */ jsxRuntime.jsxs(SidebarMenuButton, { size: "lg", disabled: true, children: [
1308
+ /* @__PURE__ */ jsxRuntime.jsx(Skeleton, { className: "h-8 w-8 rounded-lg" }),
1309
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid flex-1 gap-1 text-left text-sm", children: [
1310
+ /* @__PURE__ */ jsxRuntime.jsx(Skeleton, { className: "h-4 w-24" }),
1311
+ /* @__PURE__ */ jsxRuntime.jsx(Skeleton, { className: "h-3 w-32" })
1312
+ ] })
1313
+ ] }) }) }) }),
1314
+ /* @__PURE__ */ jsxRuntime.jsx(SidebarRail, {})
1315
+ ] });
1316
+ }
1317
+ function AppLayout({
1318
+ user,
1319
+ organizationId,
1320
+ apiBaseUrl,
1321
+ children
1322
+ }) {
1323
+ return /* @__PURE__ */ jsxRuntime.jsxs(SidebarProvider, { children: [
1324
+ /* @__PURE__ */ jsxRuntime.jsx(
1325
+ AppSidebar,
1326
+ {
1327
+ user,
1328
+ organizationId,
1329
+ apiBaseUrl
1330
+ }
1331
+ ),
1332
+ /* @__PURE__ */ jsxRuntime.jsxs(SidebarInset, { children: [
1333
+ /* @__PURE__ */ jsxRuntime.jsx(SidebarTrigger, {}),
1334
+ children
1335
+ ] })
1336
+ ] });
1337
+ }
1338
+
1339
+ exports.AppLayout = AppLayout;
1340
+ exports.AppSidebar = AppSidebar;
1341
+ exports.NavMain = NavMain;
1342
+ exports.NavUser = NavUser;
1343
+ exports.TeamSwitcher = TeamSwitcher;
1344
+ exports.getIconComponent = getIconComponent;
1345
+ exports.useNavigation = useNavigation;
1346
+ //# sourceMappingURL=components.cjs.map
1347
+ //# sourceMappingURL=components.cjs.map