@constructive-io/ui 0.3.0 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -13,7 +13,7 @@ import { Radio as Radio$1 } from '@base-ui/react/radio';
13
13
  import { RadioGroup as RadioGroup$1 } from '@base-ui/react/radio-group';
14
14
  import { Switch as Switch$1 } from '@base-ui/react/switch';
15
15
  import { Select as Select$1 } from '@base-ui/react/select';
16
- import { ChevronsUpDownIcon, XCircle, XIcon, ChevronDown, SearchIcon, CheckIcon, Ellipsis, Pencil, Trash2, ChevronRight, ChevronUpIcon, ChevronDownIcon, CircleIcon, ChevronRightIcon, X, GripVerticalIcon, ChevronLeftIcon, MoreHorizontalIcon, LoaderCircleIcon, PanelLeftIcon, WandSparkles, AlertCircleIcon, InfoIcon, CheckCircleIcon, AlertTriangleIcon, Loader2, CircleAlert, CheckCircle2, Network, UserPlus } from 'lucide-react';
16
+ import { ChevronsUpDownIcon, XCircle, XIcon, ChevronDown, SearchIcon, CheckIcon, Ellipsis, Pencil, Trash2, ChevronRight, ChevronUpIcon, ChevronDownIcon, CircleIcon, ChevronRightIcon, X, GripVerticalIcon, ChevronLeftIcon, MoreHorizontalIcon, LoaderCircleIcon, PanelLeftIcon, WandSparkles, InfoIcon, CheckCircleIcon, AlertTriangleIcon, ClockIcon, LockIcon, GlobeIcon, PlusIcon, HardDriveIcon, Trash2Icon, ArrowUpIcon, ArrowDownIcon, ArrowUpDownIcon, UploadIcon, DownloadIcon, CopyIcon, PencilIcon, UploadCloudIcon, AlertCircleIcon, ShieldAlertIcon, InboxIcon, DatabaseIcon, Loader2, FileIcon, FileImageIcon, FileAudioIcon, FileVideoIcon, FileTypeIcon as FileTypeIcon$1, FileSpreadsheetIcon, FileArchiveIcon, FileTextIcon, CircleAlert, CheckCircle2, Network, UserPlus } from 'lucide-react';
17
17
  import { Progress as Progress$1 } from '@base-ui/react/progress';
18
18
  import { FormProvider, Controller, useFormContext, useFormState } from 'react-hook-form';
19
19
  import { Tooltip as Tooltip$1 } from '@base-ui/react/tooltip';
@@ -1682,6 +1682,19 @@ function DialogDescription({
1682
1682
  }
1683
1683
  );
1684
1684
  }
1685
+ function DialogPanel({ className, ...props }) {
1686
+ return /* @__PURE__ */ jsx(ScrollArea, { children: /* @__PURE__ */ jsx(
1687
+ "div",
1688
+ {
1689
+ className: cn(
1690
+ "px-6 in-[[data-slot=dialog-popup]:has([data-slot=dialog-header])]:pt-1 in-[[data-slot=dialog-popup]:not(:has([data-slot=dialog-header]))]:pt-6 in-[[data-slot=dialog-popup]:not(:has([data-slot=dialog-footer]))]:pb-6! in-[[data-slot=dialog-popup]:not(:has([data-slot=dialog-footer].border-t))]:pb-1 pb-6",
1691
+ className
1692
+ ),
1693
+ "data-slot": "dialog-panel",
1694
+ ...props
1695
+ }
1696
+ ) });
1697
+ }
1685
1698
  function AlertDialog({ ...props }) {
1686
1699
  return /* @__PURE__ */ jsx(AlertDialog$1.Root, { "data-slot": "alert-dialog", ...props });
1687
1700
  }
@@ -7224,37 +7237,94 @@ function DefaultCardSkeleton() {
7224
7237
  ] })
7225
7238
  ] });
7226
7239
  }
7227
- function showErrorToast(props) {
7228
- const { message, description, action, onDismiss } = props;
7229
- return toast.custom((t) => /* @__PURE__ */ jsx(
7230
- "div",
7231
- {
7232
- className: "bg-background text-foreground border-destructive/20 w-full rounded-md border px-4 py-3 shadow-lg\n sm:w-[var(--width)]",
7233
- children: /* @__PURE__ */ jsxs("div", { className: "flex gap-2", children: [
7234
- /* @__PURE__ */ jsxs("div", { className: "flex grow gap-3", children: [
7235
- /* @__PURE__ */ jsx(AlertCircleIcon, { className: "text-destructive mt-0.5 shrink-0", size: 16, "aria-hidden": "true" }),
7236
- /* @__PURE__ */ jsxs("div", { className: "flex grow flex-col gap-1", children: [
7237
- /* @__PURE__ */ jsx("p", { className: "text-destructive text-sm font-medium", children: message }),
7238
- description && /* @__PURE__ */ jsx("p", { className: "text-muted-foreground text-sm", children: description }),
7239
- action && /* @__PURE__ */ jsx("div", { className: "mt-2", children: /* @__PURE__ */ jsx("button", { className: "text-destructive text-sm font-medium hover:underline", onClick: action.onClick, children: action.label }) })
7240
- ] })
7240
+ var LONG_DESCRIPTION_THRESHOLD = 140;
7241
+ function isLongDescription(description) {
7242
+ if (!description) return false;
7243
+ return description.length > LONG_DESCRIPTION_THRESHOLD || description.includes("\n");
7244
+ }
7245
+ function ToastErrorContent({
7246
+ toastId,
7247
+ message,
7248
+ description,
7249
+ action,
7250
+ onDismiss
7251
+ }) {
7252
+ const [detailsOpen, setDetailsOpen] = useState(false);
7253
+ const [copied, setCopied] = useState(false);
7254
+ const showDetails = isLongDescription(description);
7255
+ const handleCopy = async () => {
7256
+ if (!description) return;
7257
+ try {
7258
+ await navigator.clipboard.writeText(description);
7259
+ setCopied(true);
7260
+ setTimeout(() => setCopied(false), 1500);
7261
+ } catch {
7262
+ }
7263
+ };
7264
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
7265
+ /* @__PURE__ */ jsx(
7266
+ "div",
7267
+ {
7268
+ className: "bg-background text-foreground border-destructive/20 w-full rounded-md border px-4 py-3 shadow-lg\n sm:w-[var(--width)]",
7269
+ children: /* @__PURE__ */ jsxs("div", { className: "flex gap-2", children: [
7270
+ /* @__PURE__ */ jsxs("div", { className: "flex min-w-0 grow gap-3", children: [
7271
+ /* @__PURE__ */ jsx(AlertCircleIcon, { className: "text-destructive mt-0.5 shrink-0", size: 16, "aria-hidden": "true" }),
7272
+ /* @__PURE__ */ jsxs("div", { className: "flex min-w-0 grow flex-col gap-1", children: [
7273
+ /* @__PURE__ */ jsx("p", { className: "text-destructive text-sm font-medium break-words", children: message }),
7274
+ description && /* @__PURE__ */ jsx("p", { className: "text-muted-foreground line-clamp-3 text-sm break-words", children: description }),
7275
+ (showDetails || action) && /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap gap-x-4 gap-y-1", children: [
7276
+ showDetails && /* @__PURE__ */ jsx(
7277
+ "button",
7278
+ {
7279
+ className: "text-muted-foreground hover:text-foreground text-xs font-medium underline underline-offset-2 decoration-dotted",
7280
+ onClick: () => setDetailsOpen(true),
7281
+ children: "View details"
7282
+ }
7283
+ ),
7284
+ action && /* @__PURE__ */ jsx(
7285
+ "button",
7286
+ {
7287
+ className: "text-destructive text-sm font-medium hover:underline",
7288
+ onClick: action.onClick,
7289
+ children: action.label
7290
+ }
7291
+ )
7292
+ ] })
7293
+ ] })
7294
+ ] }),
7295
+ /* @__PURE__ */ jsx(
7296
+ Button,
7297
+ {
7298
+ variant: "ghost",
7299
+ className: "group -my-1.5 -me-2 size-8 shrink-0 p-0 hover:bg-transparent",
7300
+ onClick: () => {
7301
+ toast.dismiss(toastId);
7302
+ onDismiss?.();
7303
+ },
7304
+ "aria-label": "Close error notification",
7305
+ children: /* @__PURE__ */ jsx(XIcon, { size: 16, className: "opacity-60 transition-opacity group-hover:opacity-100", "aria-hidden": "true" })
7306
+ }
7307
+ )
7308
+ ] })
7309
+ }
7310
+ ),
7311
+ showDetails && description && /* @__PURE__ */ jsx(Dialog, { open: detailsOpen, onOpenChange: setDetailsOpen, children: /* @__PURE__ */ jsxs(DialogPopup, { className: "max-w-2xl", children: [
7312
+ /* @__PURE__ */ jsx(DialogHeader, { children: /* @__PURE__ */ jsx(DialogTitle, { children: message }) }),
7313
+ /* @__PURE__ */ jsx(DialogPanel, { children: /* @__PURE__ */ jsx("pre", { className: "bg-muted text-foreground rounded-md p-3 text-xs break-words whitespace-pre-wrap", children: description }) }),
7314
+ /* @__PURE__ */ jsxs(DialogFooter, { children: [
7315
+ /* @__PURE__ */ jsxs(Button, { variant: "outline", size: "sm", onClick: handleCopy, children: [
7316
+ copied ? /* @__PURE__ */ jsx(CheckIcon, { size: 14, "aria-hidden": "true" }) : /* @__PURE__ */ jsx(CopyIcon, { size: 14, "aria-hidden": "true" }),
7317
+ copied ? "Copied" : "Copy"
7241
7318
  ] }),
7242
- /* @__PURE__ */ jsx(
7243
- Button,
7244
- {
7245
- variant: "ghost",
7246
- className: "group -my-1.5 -me-2 size-8 shrink-0 p-0 hover:bg-transparent",
7247
- onClick: () => {
7248
- toast.dismiss(t);
7249
- onDismiss?.();
7250
- },
7251
- "aria-label": "Close error notification",
7252
- children: /* @__PURE__ */ jsx(XIcon, { size: 16, className: "opacity-60 transition-opacity group-hover:opacity-100", "aria-hidden": "true" })
7253
- }
7254
- )
7319
+ /* @__PURE__ */ jsx(DialogClose, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "sm", children: "Close" }) })
7255
7320
  ] })
7256
- }
7257
- ));
7321
+ ] }) })
7322
+ ] });
7323
+ }
7324
+ function showErrorToast(props) {
7325
+ return toast.custom((t) => /* @__PURE__ */ jsx(ToastErrorContent, { toastId: t, ...props }), {
7326
+ duration: Infinity
7327
+ });
7258
7328
  }
7259
7329
  function showInfoToast(props) {
7260
7330
  const { message, description, action, onDismiss } = props;
@@ -7857,6 +7927,1097 @@ function OrgChart(props) {
7857
7927
  return /* @__PURE__ */ jsx(ReactFlowProvider, { children: /* @__PURE__ */ jsx(OrgChartProvider, { editable: props.editable ?? true, children: /* @__PURE__ */ jsx(TooltipProvider, { children: /* @__PURE__ */ jsx(OrgChartInner, { ...props }) }) }) });
7858
7928
  }
7859
7929
 
7860
- export { Alert, AlertDescription, AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogPortal, AlertDialogTitle, AlertDialogTrigger, AlertTitle, Autocomplete, AutocompleteEmpty, AutocompleteInput, AutocompleteItem, AutocompletePopup, AutocompleteSeparator, Avatar, AvatarFallback, AvatarImage, Badge, Breadcrumb, BreadcrumbEllipsis, BreadcrumbItem, BreadcrumbLink, BreadcrumbList, BreadcrumbPage, BreadcrumbSeparator, Button, Calendar, Card, CardAction, CardContent, CardDescription, CardFooter, CardHeader, CardStackProvider, CardStackViewport, CardTitle, Checkbox, CheckboxGroup, Collapsible, CollapsiblePanel as CollapsibleContent, CollapsibleTrigger, Combobox, ComboboxContent, ComboboxEmpty, ComboboxGroup, ComboboxInput, ComboboxItem, ComboboxList, ComboboxSeparator, ComboboxTrigger, Command, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, DEFAULT_ANIMATION_CONFIG, DeferredCardContent, Dialog, DialogBackdrop, DialogClose, DialogPopup as DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogPortal, DialogTitle, DialogTrigger, Dock, DockIcon, Drawer, DrawerClose, DrawerContent, DrawerDescription, DrawerFooter, DrawerHeader, DrawerOverlay, DrawerPortal, DrawerTitle, DrawerTrigger, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, Field, FieldRow, FlickeringGrid, FlowZoomPanel, Form, FormControl, FormControl2 as FormControlComponent, FormDescription, FormField, FormItem, FormLabel, FormMessage, Input, InputGroup, InputGroupAddon, InputGroupInput, InputGroupText, InputGroupTextarea, JsonEditor, JsonInput, Label, ModalPortalScope, MotionGrid, MultiSelect, OrgChart, PORTAL_ROOT_ID, PageHeader, Pagination, PaginationContent, PaginationEllipsis, PaginationItem, PaginationLink, PaginationNext, PaginationPrevious, Popover, PopoverAnchor, PopoverContent, PopoverTrigger, PortalRoot, Progress, ProgressiveBlur, ProgressiveBlurScrollContainer, Radio, RadioGroup, Radio as RadioGroupItem, RangeCalendar, RecordPicker, ResizableHandle, ResizablePanel, ResizablePanelGroup, ResponsiveDiagram, ScrollArea, ScrollBar, Select, SelectPopup as SelectContent, SelectFieldItem, SelectGroup, SelectGroupLabel, SelectItem, SelectGroupLabel as SelectLabel, SelectPopup, SelectRichItem, SelectSeparator, SelectTrigger, SelectValue, Separator, Sheet, SheetClose, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetTitle, SheetTrigger, Sidebar, SidebarContent, SidebarFooter, SidebarGroup, SidebarGroupAction, SidebarGroupContent, SidebarGroupLabel, SidebarHeader, SidebarInput, SidebarInset, SidebarMenu, SidebarMenuAction, SidebarMenuBadge, SidebarMenuButton, SidebarMenuItem, SidebarMenuSkeleton, SidebarMenuSub, SidebarMenuSubButton, SidebarMenuSubItem, SidebarProvider, SidebarSeparator, SidebarTrigger, Skeleton, Slot, Slottable, StackBackdrop, StackCard, StackHeader, StackHeaderSlot, Stepper, StepperDescription, StepperIndicator, StepperItem, StepperSeparator, StepperTitle, StepperTrigger, Switch, Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, TableRow, Tabs, TabsContent, TabsList, TabsTrigger, Tags, TagsContent, TagsEmpty, TagsGroup, TagsInput, TagsItem, TagsList, TagsTrigger, TagsValue, Textarea, Toaster, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, UnlinkButton, alertVariants, backdropVariants, badgeVariants, buttonVariants, calculateResponsiveOffset, cardVariants, cn, composeRefs, createCardVariants, createOffsetTransition, createReducedMotionVariants, dockVariants, durations, easings, getCardOffset, getCardZIndex, getCascadeOffset, getResponsiveCardOffset, getSideBySideOffset, getVisibleCardIndices, isCardVisible, mergeProps, normalizeWidth, parseWidthToPixels, peekDragSpring, peekHoverSpring, peekSlideSpring, reducedMotionBackdropVariants, showErrorToast, showInfoToast, showSuccessToast, showWarningToast, snapBackSpring, springs, swipeDismissTransition, toast5 as toast, transitions, useCardIndex, useCardInjectedProps, useCardReady, useCardStack, useControllableState, useFloatingOverlayPortalProps, useFormField, useInModalOverlay, useIsMobile2 as useIsMobile, useIsTopCard, usePeekGestures, usePortalContainer, usePortalContext, useRootPortalContainer, useSidebar, useStackCards, useStackContext, useStackGestures, useStackLayoutMode, useStackResponsive, validateJson, variants };
7930
+ // src/components/storage/utils.ts
7931
+ function humanizeBytes(bytes) {
7932
+ if (bytes == null || Number.isNaN(bytes) || bytes < 0) return "\u2014";
7933
+ if (bytes === 0) return "0 B";
7934
+ const units = ["B", "KB", "MB", "GB", "TB", "PB"];
7935
+ const exponent = Math.min(Math.floor(Math.log(Math.abs(bytes)) / Math.log(1024)), units.length - 1);
7936
+ const value = bytes / 1024 ** exponent;
7937
+ const formatted = exponent === 0 ? String(Math.round(value)) : value.toFixed(1);
7938
+ return `${formatted} ${units[exponent]}`;
7939
+ }
7940
+ function formatDate(iso) {
7941
+ if (!iso) return "\u2014";
7942
+ const date = new Date(iso);
7943
+ if (Number.isNaN(date.getTime())) return "\u2014";
7944
+ return date.toLocaleDateString(void 0, {
7945
+ year: "numeric",
7946
+ month: "short",
7947
+ day: "numeric"
7948
+ });
7949
+ }
7950
+ function formatDateTime(iso) {
7951
+ if (!iso) return "\u2014";
7952
+ const date = new Date(iso);
7953
+ if (Number.isNaN(date.getTime())) return "\u2014";
7954
+ return date.toLocaleString(void 0, {
7955
+ year: "numeric",
7956
+ month: "short",
7957
+ day: "numeric",
7958
+ hour: "numeric",
7959
+ minute: "2-digit"
7960
+ });
7961
+ }
7962
+ function shortMimeLabel(mimeType) {
7963
+ if (!mimeType) return "\u2014";
7964
+ const lower = mimeType.toLowerCase();
7965
+ const known = {
7966
+ "application/pdf": "PDF",
7967
+ "application/zip": "ZIP",
7968
+ "application/x-zip-compressed": "ZIP",
7969
+ "application/gzip": "GZIP",
7970
+ "application/x-tar": "TAR",
7971
+ "application/json": "JSON",
7972
+ "application/msword": "DOC",
7973
+ "application/vnd.openxmlformats-officedocument.wordprocessingml.document": "DOCX",
7974
+ "application/vnd.ms-excel": "XLS",
7975
+ "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": "XLSX",
7976
+ "application/vnd.ms-powerpoint": "PPT",
7977
+ "application/vnd.openxmlformats-officedocument.presentationml.presentation": "PPTX",
7978
+ "text/csv": "CSV",
7979
+ "text/plain": "TXT",
7980
+ "text/markdown": "MD"
7981
+ };
7982
+ if (known[lower]) return known[lower];
7983
+ const subtype = lower.split("/")[1] ?? lower;
7984
+ const base = subtype.split("+")[0].replace(/^x-/, "");
7985
+ return base.toUpperCase();
7986
+ }
7987
+ function objectDisplayName(object) {
7988
+ return object.filename?.trim() || object.key;
7989
+ }
7990
+ function bucketDisplayName(bucket) {
7991
+ return bucket.key;
7992
+ }
7993
+ function resolveIcon(mimeType) {
7994
+ if (!mimeType) return FileIcon;
7995
+ const lower = mimeType.toLowerCase();
7996
+ if (lower.startsWith("image/")) return FileImageIcon;
7997
+ if (lower.startsWith("audio/")) return FileAudioIcon;
7998
+ if (lower.startsWith("video/")) return FileVideoIcon;
7999
+ if (lower === "application/pdf" || lower === "application/msword" || lower === "application/vnd.openxmlformats-officedocument.wordprocessingml.document") {
8000
+ return FileTypeIcon$1;
8001
+ }
8002
+ if (lower === "text/csv" || lower === "application/vnd.ms-excel" || lower === "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet") {
8003
+ return FileSpreadsheetIcon;
8004
+ }
8005
+ if (lower === "application/zip" || lower === "application/x-zip-compressed" || lower === "application/gzip" || lower === "application/x-tar" || lower === "application/x-7z-compressed" || lower === "application/x-rar-compressed") {
8006
+ return FileArchiveIcon;
8007
+ }
8008
+ if (lower.startsWith("text/") || lower === "application/json") return FileTextIcon;
8009
+ return FileIcon;
8010
+ }
8011
+ function FileTypeIcon({ mimeType, className, ...props }) {
8012
+ const Icon = resolveIcon(mimeType);
8013
+ return /* @__PURE__ */ jsx(Icon, { "aria-hidden": true, className: cn("size-4 shrink-0 text-muted-foreground", className), ...props });
8014
+ }
8015
+ var VISIBILITY_CONFIG = {
8016
+ public: { label: "Public", icon: GlobeIcon, variant: "secondary" },
8017
+ private: { label: "Private", icon: LockIcon, variant: "outline" },
8018
+ temp: { label: "Temp", icon: ClockIcon, variant: "warning" }
8019
+ };
8020
+ function VisibilityBadge({ visibility, size, className, hideIcon }) {
8021
+ const config = VISIBILITY_CONFIG[visibility];
8022
+ const Icon = config.icon;
8023
+ return /* @__PURE__ */ jsxs(Badge, { variant: config.variant, size, className: cn("gap-1", className), children: [
8024
+ !hideIcon && /* @__PURE__ */ jsx(Icon, { "aria-hidden": true }),
8025
+ config.label
8026
+ ] });
8027
+ }
8028
+ var STATUS_CONFIG = {
8029
+ requested: { label: "Requested", variant: "outline" },
8030
+ uploaded: { label: "Uploaded", variant: "secondary" },
8031
+ processed: { label: "Processed", variant: "success" }
8032
+ };
8033
+ function ObjectStatusBadge({ status, size, className }) {
8034
+ const config = STATUS_CONFIG[status];
8035
+ return /* @__PURE__ */ jsx(Badge, { variant: config.variant, size, className, children: config.label });
8036
+ }
8037
+ function BucketRailItem({ bucket, selected, onSelect }) {
8038
+ const unprovisioned = bucket.provisioned === false;
8039
+ return /* @__PURE__ */ jsxs(
8040
+ "button",
8041
+ {
8042
+ type: "button",
8043
+ "aria-current": selected ? "true" : void 0,
8044
+ onClick: () => onSelect(bucket.id),
8045
+ className: cn(
8046
+ `flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-sm outline-none transition-colors
8047
+ focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background`,
8048
+ selected ? "bg-accent text-accent-foreground" : "text-foreground hover:bg-muted/50"
8049
+ ),
8050
+ children: [
8051
+ /* @__PURE__ */ jsxs("div", { className: "flex min-w-0 flex-1 flex-col gap-0.5", children: [
8052
+ /* @__PURE__ */ jsx("span", { className: "truncate font-medium", children: bucketDisplayName(bucket) }),
8053
+ /* @__PURE__ */ jsxs("span", { className: "flex items-center gap-1.5", children: [
8054
+ /* @__PURE__ */ jsx(VisibilityBadge, { visibility: bucket.visibility, size: "sm" }),
8055
+ unprovisioned && /* @__PURE__ */ jsx("span", { className: "truncate text-[0.625rem] text-muted-foreground", children: "Not provisioned" })
8056
+ ] })
8057
+ ] }),
8058
+ bucket.objectCount != null && /* @__PURE__ */ jsx("span", { className: "shrink-0 text-xs tabular-nums text-muted-foreground", children: bucket.objectCount })
8059
+ ]
8060
+ }
8061
+ );
8062
+ }
8063
+ function BucketRail({ buckets, selectedBucketId, onSelectBucket, onNewBucket, className }) {
8064
+ return /* @__PURE__ */ jsxs("div", { className: cn("flex h-full min-h-0 flex-col", className), children: [
8065
+ /* @__PURE__ */ jsx(ScrollArea, { className: "min-h-0 flex-1", children: /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-0.5 p-2", children: buckets.map((bucket) => /* @__PURE__ */ jsx(
8066
+ BucketRailItem,
8067
+ {
8068
+ bucket,
8069
+ selected: bucket.id === selectedBucketId,
8070
+ onSelect: onSelectBucket
8071
+ },
8072
+ bucket.id
8073
+ )) }) }),
8074
+ /* @__PURE__ */ jsx(Separator, {}),
8075
+ /* @__PURE__ */ jsx("div", { className: "p-2", children: /* @__PURE__ */ jsxs(Button, { variant: "ghost", size: "sm", className: "w-full justify-start", onClick: onNewBucket, children: [
8076
+ /* @__PURE__ */ jsx(PlusIcon, { "aria-hidden": true }),
8077
+ "New bucket"
8078
+ ] }) })
8079
+ ] });
8080
+ }
8081
+ function StorageBreadcrumb({ bucketKey, segments = [], onNavigate, className }) {
8082
+ const hasSegments = segments.length > 0;
8083
+ return /* @__PURE__ */ jsx(Breadcrumb, { className: cn("min-w-0", className), children: /* @__PURE__ */ jsxs(BreadcrumbList, { className: "flex-nowrap", children: [
8084
+ /* @__PURE__ */ jsx(BreadcrumbItem, { className: "min-w-0", children: hasSegments ? /* @__PURE__ */ jsxs(
8085
+ BreadcrumbLink,
8086
+ {
8087
+ className: "inline-flex min-w-0 cursor-pointer items-center gap-1.5",
8088
+ onClick: () => onNavigate?.(null),
8089
+ children: [
8090
+ /* @__PURE__ */ jsx(HardDriveIcon, { className: "size-3.5 shrink-0", "aria-hidden": true }),
8091
+ /* @__PURE__ */ jsx("span", { className: "truncate", children: bucketKey })
8092
+ ]
8093
+ }
8094
+ ) : /* @__PURE__ */ jsxs(BreadcrumbPage, { className: "inline-flex min-w-0 items-center gap-1.5", children: [
8095
+ /* @__PURE__ */ jsx(HardDriveIcon, { className: "size-3.5 shrink-0", "aria-hidden": true }),
8096
+ /* @__PURE__ */ jsx("span", { className: "truncate", children: bucketKey })
8097
+ ] }) }),
8098
+ segments.map((segment, index) => {
8099
+ const isLast = index === segments.length - 1;
8100
+ return /* @__PURE__ */ jsxs(BreadcrumbItem, { className: "min-w-0", children: [
8101
+ /* @__PURE__ */ jsx(BreadcrumbSeparator, {}),
8102
+ isLast ? /* @__PURE__ */ jsx(BreadcrumbPage, { className: "truncate", children: segment.label }) : /* @__PURE__ */ jsx(
8103
+ BreadcrumbLink,
8104
+ {
8105
+ className: "cursor-pointer truncate",
8106
+ onClick: () => onNavigate?.(segment.path),
8107
+ children: segment.label
8108
+ }
8109
+ )
8110
+ ] }, segment.path);
8111
+ })
8112
+ ] }) });
8113
+ }
8114
+ var SORT_COLUMNS = [
8115
+ { value: "filename", label: "Name" },
8116
+ { value: "size", label: "Size" },
8117
+ { value: "createdAt", label: "Modified" },
8118
+ { value: "mimeType", label: "Type" }
8119
+ ];
8120
+ function ObjectToolbar({
8121
+ query,
8122
+ onQueryChange,
8123
+ sort,
8124
+ onSortChange,
8125
+ onUpload,
8126
+ selectedCount = 0,
8127
+ onBulkDelete,
8128
+ bulkDeleteProgress,
8129
+ onClearSelection,
8130
+ className
8131
+ }) {
8132
+ if (selectedCount > 0) {
8133
+ const isDeleting = bulkDeleteProgress != null && bulkDeleteProgress.done < bulkDeleteProgress.total;
8134
+ const failedCount = bulkDeleteProgress?.failed.length ?? 0;
8135
+ return /* @__PURE__ */ jsxs("div", { className: cn("flex h-9 items-center justify-between gap-2 rounded-lg border bg-muted/40 px-2", className), children: [
8136
+ /* @__PURE__ */ jsxs("span", { className: "flex items-center gap-2 text-sm font-medium tabular-nums", children: [
8137
+ selectedCount,
8138
+ " selected",
8139
+ failedCount > 0 && /* @__PURE__ */ jsxs("span", { className: "text-xs font-normal text-destructive", children: [
8140
+ failedCount,
8141
+ " failed"
8142
+ ] })
8143
+ ] }),
8144
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1.5", children: [
8145
+ /* @__PURE__ */ jsxs(Button, { variant: "destructive-outline", size: "sm", onClick: onBulkDelete, disabled: isDeleting, children: [
8146
+ /* @__PURE__ */ jsx(Trash2Icon, { "aria-hidden": true }),
8147
+ isDeleting ? `Deleting ${bulkDeleteProgress.done}/${bulkDeleteProgress.total}` : "Delete"
8148
+ ] }),
8149
+ /* @__PURE__ */ jsxs(Button, { variant: "ghost", size: "sm", onClick: onClearSelection, disabled: isDeleting, children: [
8150
+ /* @__PURE__ */ jsx(XIcon, { "aria-hidden": true }),
8151
+ "Clear"
8152
+ ] })
8153
+ ] })
8154
+ ] });
8155
+ }
8156
+ const activeColumn = SORT_COLUMNS.find((column) => column.value === sort.column);
8157
+ const DirectionIcon = sort.direction === "asc" ? ArrowUpIcon : ArrowDownIcon;
8158
+ return /* @__PURE__ */ jsxs("div", { className: cn("flex items-center gap-2", className), children: [
8159
+ /* @__PURE__ */ jsxs(InputGroup, { className: "max-w-xs flex-1", children: [
8160
+ /* @__PURE__ */ jsx(InputGroupAddon, { children: /* @__PURE__ */ jsx(SearchIcon, { "aria-hidden": true }) }),
8161
+ /* @__PURE__ */ jsx(
8162
+ InputGroupInput,
8163
+ {
8164
+ type: "search",
8165
+ placeholder: "Search files",
8166
+ value: query,
8167
+ onChange: (event) => onQueryChange(event.target.value)
8168
+ }
8169
+ )
8170
+ ] }),
8171
+ /* @__PURE__ */ jsxs(DropdownMenu, { children: [
8172
+ /* @__PURE__ */ jsx(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsxs(Button, { variant: "outline", size: "sm", children: [
8173
+ /* @__PURE__ */ jsx(ArrowUpDownIcon, { "aria-hidden": true }),
8174
+ /* @__PURE__ */ jsx("span", { className: "max-sm:sr-only", children: activeColumn?.label ?? "Sort" }),
8175
+ /* @__PURE__ */ jsx(DirectionIcon, { "aria-hidden": true, className: "opacity-70" })
8176
+ ] }) }),
8177
+ /* @__PURE__ */ jsxs(DropdownMenuContent, { align: "end", className: "min-w-44", children: [
8178
+ /* @__PURE__ */ jsx(DropdownMenuLabel, { children: "Sort by" }),
8179
+ /* @__PURE__ */ jsx(
8180
+ DropdownMenuRadioGroup,
8181
+ {
8182
+ value: sort.column,
8183
+ onValueChange: (value) => onSortChange({ ...sort, column: value }),
8184
+ children: SORT_COLUMNS.map((column) => /* @__PURE__ */ jsx(DropdownMenuRadioItem, { value: column.value, children: column.label }, column.value))
8185
+ }
8186
+ ),
8187
+ /* @__PURE__ */ jsx(DropdownMenuSeparator, {}),
8188
+ /* @__PURE__ */ jsx(DropdownMenuLabel, { children: "Direction" }),
8189
+ /* @__PURE__ */ jsxs(
8190
+ DropdownMenuRadioGroup,
8191
+ {
8192
+ value: sort.direction,
8193
+ onValueChange: (value) => onSortChange({ ...sort, direction: value }),
8194
+ children: [
8195
+ /* @__PURE__ */ jsx(DropdownMenuRadioItem, { value: "asc", children: "Ascending" }),
8196
+ /* @__PURE__ */ jsx(DropdownMenuRadioItem, { value: "desc", children: "Descending" })
8197
+ ]
8198
+ }
8199
+ )
8200
+ ] })
8201
+ ] }),
8202
+ /* @__PURE__ */ jsxs(Button, { size: "sm", onClick: onUpload, children: [
8203
+ /* @__PURE__ */ jsx(UploadIcon, { "aria-hidden": true }),
8204
+ "Upload"
8205
+ ] })
8206
+ ] });
8207
+ }
8208
+ function SortableHeader({ column, label, sort, onSortChange, className }) {
8209
+ const isActive = sort.column === column;
8210
+ const nextDirection = isActive && sort.direction === "asc" ? "desc" : "asc";
8211
+ const CaretIcon = sort.direction === "asc" ? ArrowUpIcon : ArrowDownIcon;
8212
+ return /* @__PURE__ */ jsx(TableHead, { className, children: /* @__PURE__ */ jsxs(
8213
+ "button",
8214
+ {
8215
+ type: "button",
8216
+ onClick: () => onSortChange({ column, direction: nextDirection }),
8217
+ "aria-label": `Sort by ${label}`,
8218
+ className: "-mx-1 inline-flex items-center gap-1 rounded px-1 outline-none hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring",
8219
+ children: [
8220
+ label,
8221
+ isActive && /* @__PURE__ */ jsx(CaretIcon, { className: "size-3.5", "aria-hidden": true })
8222
+ ]
8223
+ }
8224
+ ) });
8225
+ }
8226
+ var COLUMN_COUNT = 6;
8227
+ function ObjectTable({
8228
+ objects,
8229
+ selectedIds,
8230
+ onSelectionChange,
8231
+ sort,
8232
+ onSortChange,
8233
+ onOpenObject,
8234
+ onDownload,
8235
+ onCopyLink,
8236
+ onRename,
8237
+ onDelete,
8238
+ isLoading,
8239
+ emptyLabel = "No files",
8240
+ className
8241
+ }) {
8242
+ if (isLoading) {
8243
+ return /* @__PURE__ */ jsx(ObjectTableSkeleton, { className });
8244
+ }
8245
+ const selected = new Set(selectedIds);
8246
+ const allSelected = objects.length > 0 && selected.size === objects.length;
8247
+ const someSelected = selected.size > 0 && !allSelected;
8248
+ const toggleAll = (checked) => {
8249
+ onSelectionChange(checked ? objects.map((object) => object.id) : []);
8250
+ };
8251
+ const toggleOne = (objectId, checked) => {
8252
+ const next = new Set(selected);
8253
+ if (checked) next.add(objectId);
8254
+ else next.delete(objectId);
8255
+ onSelectionChange([...next]);
8256
+ };
8257
+ return /* @__PURE__ */ jsxs(Table, { className, children: [
8258
+ /* @__PURE__ */ jsx(TableHeader, { children: /* @__PURE__ */ jsxs(TableRow, { children: [
8259
+ /* @__PURE__ */ jsx(TableHead, { className: "w-10", children: /* @__PURE__ */ jsx(
8260
+ Checkbox,
8261
+ {
8262
+ "aria-label": "Select all files",
8263
+ checked: allSelected,
8264
+ indeterminate: someSelected,
8265
+ onCheckedChange: (checked) => toggleAll(checked === true)
8266
+ }
8267
+ ) }),
8268
+ /* @__PURE__ */ jsx(SortableHeader, { column: "filename", label: "Name", sort, onSortChange }),
8269
+ /* @__PURE__ */ jsx(SortableHeader, { column: "mimeType", label: "Type", sort, onSortChange }),
8270
+ /* @__PURE__ */ jsx(SortableHeader, { column: "size", label: "Size", sort, onSortChange, className: "text-right" }),
8271
+ /* @__PURE__ */ jsx(
8272
+ SortableHeader,
8273
+ {
8274
+ column: "createdAt",
8275
+ label: "Modified",
8276
+ sort,
8277
+ onSortChange,
8278
+ className: "text-right"
8279
+ }
8280
+ ),
8281
+ /* @__PURE__ */ jsx(TableHead, { className: "w-10" })
8282
+ ] }) }),
8283
+ /* @__PURE__ */ jsx(TableBody, { children: objects.length === 0 ? /* @__PURE__ */ jsx(TableRow, { className: "hover:bg-transparent", children: /* @__PURE__ */ jsx(TableCell, { colSpan: COLUMN_COUNT, className: "h-24 text-center text-sm text-muted-foreground", children: emptyLabel }) }) : objects.map((object) => {
8284
+ const isSelected = selected.has(object.id);
8285
+ return /* @__PURE__ */ jsxs(
8286
+ TableRow,
8287
+ {
8288
+ "data-state": isSelected ? "selected" : void 0,
8289
+ onClick: () => onOpenObject?.(object),
8290
+ className: "cursor-pointer",
8291
+ children: [
8292
+ /* @__PURE__ */ jsx(TableCell, { onClick: (event) => event.stopPropagation(), children: /* @__PURE__ */ jsx(
8293
+ Checkbox,
8294
+ {
8295
+ "aria-label": `Select ${objectDisplayName(object)}`,
8296
+ checked: isSelected,
8297
+ onCheckedChange: (checked) => toggleOne(object.id, checked === true)
8298
+ }
8299
+ ) }),
8300
+ /* @__PURE__ */ jsx(TableCell, { className: "max-w-0", children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
8301
+ /* @__PURE__ */ jsx(FileTypeIcon, { mimeType: object.mimeType }),
8302
+ /* @__PURE__ */ jsx("span", { className: "truncate font-medium", children: objectDisplayName(object) })
8303
+ ] }) }),
8304
+ /* @__PURE__ */ jsx(TableCell, { className: "text-muted-foreground", children: shortMimeLabel(object.mimeType) }),
8305
+ /* @__PURE__ */ jsx(TableCell, { className: "text-right tabular-nums", children: humanizeBytes(object.size) }),
8306
+ /* @__PURE__ */ jsx(TableCell, { className: "text-right tabular-nums text-muted-foreground", children: formatDate(object.createdAt) }),
8307
+ /* @__PURE__ */ jsx(TableCell, { onClick: (event) => event.stopPropagation(), children: /* @__PURE__ */ jsxs(DropdownMenu, { children: [
8308
+ /* @__PURE__ */ jsx(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon-sm", "aria-label": `Actions for ${objectDisplayName(object)}`, children: /* @__PURE__ */ jsx(MoreHorizontalIcon, { "aria-hidden": true }) }) }),
8309
+ /* @__PURE__ */ jsxs(DropdownMenuContent, { align: "end", children: [
8310
+ /* @__PURE__ */ jsxs(DropdownMenuItem, { onClick: () => onDownload?.(object), children: [
8311
+ /* @__PURE__ */ jsx(DownloadIcon, { className: "size-4", "aria-hidden": true }),
8312
+ "Download"
8313
+ ] }),
8314
+ /* @__PURE__ */ jsxs(DropdownMenuItem, { onClick: () => onCopyLink?.(object), children: [
8315
+ /* @__PURE__ */ jsx(CopyIcon, { className: "size-4", "aria-hidden": true }),
8316
+ "Copy link"
8317
+ ] }),
8318
+ /* @__PURE__ */ jsxs(DropdownMenuItem, { onClick: () => onRename?.(object), children: [
8319
+ /* @__PURE__ */ jsx(PencilIcon, { className: "size-4", "aria-hidden": true }),
8320
+ "Rename"
8321
+ ] }),
8322
+ /* @__PURE__ */ jsx(DropdownMenuSeparator, {}),
8323
+ /* @__PURE__ */ jsxs(DropdownMenuItem, { variant: "destructive", onClick: () => onDelete?.(object), children: [
8324
+ /* @__PURE__ */ jsx(Trash2Icon, { className: "size-4", "aria-hidden": true }),
8325
+ "Delete"
8326
+ ] })
8327
+ ] })
8328
+ ] }) })
8329
+ ]
8330
+ },
8331
+ object.id
8332
+ );
8333
+ }) })
8334
+ ] });
8335
+ }
8336
+ function ObjectTableSkeleton({ rows = 6, className }) {
8337
+ return /* @__PURE__ */ jsxs(Table, { className, children: [
8338
+ /* @__PURE__ */ jsx(TableHeader, { children: /* @__PURE__ */ jsxs(TableRow, { children: [
8339
+ /* @__PURE__ */ jsx(TableHead, { className: "w-10" }),
8340
+ /* @__PURE__ */ jsx(TableHead, { children: "Name" }),
8341
+ /* @__PURE__ */ jsx(TableHead, { children: "Type" }),
8342
+ /* @__PURE__ */ jsx(TableHead, { className: "text-right", children: "Size" }),
8343
+ /* @__PURE__ */ jsx(TableHead, { className: "text-right", children: "Modified" }),
8344
+ /* @__PURE__ */ jsx(TableHead, { className: "w-10" })
8345
+ ] }) }),
8346
+ /* @__PURE__ */ jsx(TableBody, { children: Array.from({ length: rows }).map((_, index) => (
8347
+ // Skeleton rows are positional and static; index key is acceptable here.
8348
+ /* @__PURE__ */ jsxs(TableRow, { className: "hover:bg-transparent", children: [
8349
+ /* @__PURE__ */ jsx(TableCell, { children: /* @__PURE__ */ jsx(Skeleton, { className: "size-4 rounded-[4px]" }) }),
8350
+ /* @__PURE__ */ jsx(TableCell, { children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
8351
+ /* @__PURE__ */ jsx(Skeleton, { className: "size-4" }),
8352
+ /* @__PURE__ */ jsx(Skeleton, { className: "h-4 w-40" })
8353
+ ] }) }),
8354
+ /* @__PURE__ */ jsx(TableCell, { children: /* @__PURE__ */ jsx(Skeleton, { className: "h-4 w-10" }) }),
8355
+ /* @__PURE__ */ jsx(TableCell, { className: "flex justify-end", children: /* @__PURE__ */ jsx(Skeleton, { className: "h-4 w-12" }) }),
8356
+ /* @__PURE__ */ jsx(TableCell, { children: /* @__PURE__ */ jsx(Skeleton, { className: "ml-auto h-4 w-20" }) }),
8357
+ /* @__PURE__ */ jsx(TableCell, { children: /* @__PURE__ */ jsx(Skeleton, { className: "size-4" }) })
8358
+ ] }, index)
8359
+ )) })
8360
+ ] });
8361
+ }
8362
+ function MetadataRow({ label, children }) {
8363
+ return /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-[7rem_1fr] items-start gap-2 py-1.5", children: [
8364
+ /* @__PURE__ */ jsx("dt", { className: "text-sm text-muted-foreground", children: label }),
8365
+ /* @__PURE__ */ jsx("dd", { className: "min-w-0 text-sm", children })
8366
+ ] });
8367
+ }
8368
+ function ObjectDetailBody({
8369
+ object,
8370
+ onDownload,
8371
+ onCopyLink,
8372
+ onRename,
8373
+ onDelete,
8374
+ isPreviewLoading
8375
+ }) {
8376
+ const displayName = objectDisplayName(object);
8377
+ const [isRenaming, setIsRenaming] = React19.useState(false);
8378
+ const [draftName, setDraftName] = React19.useState(displayName);
8379
+ const isImageType = object.mimeType.startsWith("image/");
8380
+ const isImage = isImageType && !!object.downloadUrl;
8381
+ const commitRename = () => {
8382
+ const trimmed = draftName.trim();
8383
+ if (trimmed && trimmed !== displayName) {
8384
+ onRename?.(object.id, trimmed);
8385
+ }
8386
+ setIsRenaming(false);
8387
+ };
8388
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
8389
+ /* @__PURE__ */ jsxs(SheetHeader, { className: "pb-3 text-left", children: [
8390
+ /* @__PURE__ */ jsx(SheetTitle, { className: "truncate pr-8", children: displayName }),
8391
+ /* @__PURE__ */ jsx(SheetDescription, { className: "truncate font-mono text-xs", children: object.key })
8392
+ ] }),
8393
+ /* @__PURE__ */ jsx("div", { className: "flex items-center justify-center rounded-lg border bg-muted/40 p-4", children: isImageType && isPreviewLoading ? /* @__PURE__ */ jsx(Skeleton, { className: "size-40 rounded-md" }) : isImage ? /* @__PURE__ */ jsx("img", { src: object.downloadUrl ?? void 0, alt: displayName, className: "size-40 rounded-md object-cover" }) : /* @__PURE__ */ jsx("div", { className: "flex size-40 items-center justify-center rounded-md bg-background", children: /* @__PURE__ */ jsx(FileTypeIcon, { mimeType: object.mimeType, className: "size-16 text-muted-foreground" }) }) }),
8394
+ /* @__PURE__ */ jsx("div", { className: "py-3", children: isRenaming ? /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
8395
+ /* @__PURE__ */ jsx(
8396
+ Input,
8397
+ {
8398
+ autoFocus: true,
8399
+ value: draftName,
8400
+ onChange: (event) => setDraftName(event.target.value),
8401
+ onKeyDown: (event) => {
8402
+ if (event.key === "Enter") commitRename();
8403
+ if (event.key === "Escape") setIsRenaming(false);
8404
+ },
8405
+ "aria-label": "New file name"
8406
+ }
8407
+ ),
8408
+ /* @__PURE__ */ jsx(Button, { size: "icon-sm", "aria-label": "Save name", onClick: commitRename, children: /* @__PURE__ */ jsx(CheckIcon, { "aria-hidden": true }) }),
8409
+ /* @__PURE__ */ jsx(Button, { size: "icon-sm", variant: "ghost", "aria-label": "Cancel rename", onClick: () => setIsRenaming(false), children: /* @__PURE__ */ jsx(XIcon, { "aria-hidden": true }) })
8410
+ ] }) : /* @__PURE__ */ jsxs(Button, { variant: "outline", size: "sm", className: "w-full justify-start", onClick: () => setIsRenaming(true), children: [
8411
+ /* @__PURE__ */ jsx(PencilIcon, { "aria-hidden": true }),
8412
+ "Rename"
8413
+ ] }) }),
8414
+ /* @__PURE__ */ jsx(Separator, {}),
8415
+ /* @__PURE__ */ jsxs("dl", { className: "py-2", children: [
8416
+ /* @__PURE__ */ jsx(MetadataRow, { label: "Filename", children: /* @__PURE__ */ jsx("span", { className: "block truncate", children: object.filename ?? "\u2014" }) }),
8417
+ /* @__PURE__ */ jsx(MetadataRow, { label: "Size", children: /* @__PURE__ */ jsx("span", { className: "tabular-nums", children: humanizeBytes(object.size) }) }),
8418
+ /* @__PURE__ */ jsx(MetadataRow, { label: "Type", children: /* @__PURE__ */ jsx("span", { className: "break-all", children: object.mimeType }) }),
8419
+ /* @__PURE__ */ jsx(MetadataRow, { label: "Modified", children: /* @__PURE__ */ jsx("span", { className: "tabular-nums", children: formatDateTime(object.updatedAt ?? object.createdAt) }) }),
8420
+ /* @__PURE__ */ jsx(MetadataRow, { label: "Key", children: /* @__PURE__ */ jsx("span", { className: "block truncate font-mono text-xs", children: object.key }) }),
8421
+ /* @__PURE__ */ jsx(MetadataRow, { label: "Visibility", children: /* @__PURE__ */ jsx(VisibilityBadge, { visibility: object.isPublic ? "public" : "private", size: "sm" }) }),
8422
+ object.status && /* @__PURE__ */ jsx(MetadataRow, { label: "Status", children: /* @__PURE__ */ jsx(ObjectStatusBadge, { status: object.status, size: "sm" }) })
8423
+ ] }),
8424
+ /* @__PURE__ */ jsx(Separator, {}),
8425
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2 pt-4", children: [
8426
+ /* @__PURE__ */ jsxs(Button, { onClick: () => onDownload?.(object), children: [
8427
+ /* @__PURE__ */ jsx(DownloadIcon, { "aria-hidden": true }),
8428
+ "Download"
8429
+ ] }),
8430
+ /* @__PURE__ */ jsxs(Button, { variant: "outline", onClick: () => onCopyLink?.(object), children: [
8431
+ /* @__PURE__ */ jsx(CopyIcon, { "aria-hidden": true }),
8432
+ "Copy link"
8433
+ ] }),
8434
+ /* @__PURE__ */ jsxs(AlertDialog, { children: [
8435
+ /* @__PURE__ */ jsx(AlertDialogTrigger, { asChild: true, children: /* @__PURE__ */ jsxs(Button, { variant: "destructive-outline", children: [
8436
+ /* @__PURE__ */ jsx(Trash2Icon, { "aria-hidden": true }),
8437
+ "Delete"
8438
+ ] }) }),
8439
+ /* @__PURE__ */ jsxs(AlertDialogContent, { children: [
8440
+ /* @__PURE__ */ jsxs(AlertDialogHeader, { children: [
8441
+ /* @__PURE__ */ jsx(AlertDialogTitle, { children: "Delete this file?" }),
8442
+ /* @__PURE__ */ jsx(AlertDialogDescription, { children: `"${displayName}" will be permanently removed. This action cannot be undone.` })
8443
+ ] }),
8444
+ /* @__PURE__ */ jsxs(AlertDialogFooter, { children: [
8445
+ /* @__PURE__ */ jsx(AlertDialogCancel, { children: "Cancel" }),
8446
+ /* @__PURE__ */ jsx(
8447
+ AlertDialogAction,
8448
+ {
8449
+ className: cn("bg-destructive text-destructive-foreground hover:bg-destructive/90"),
8450
+ onClick: () => onDelete?.(object.id),
8451
+ children: "Delete"
8452
+ }
8453
+ )
8454
+ ] })
8455
+ ] })
8456
+ ] })
8457
+ ] })
8458
+ ] });
8459
+ }
8460
+ function ObjectDetailSheet({
8461
+ object,
8462
+ open,
8463
+ onOpenChange,
8464
+ onDownload,
8465
+ onCopyLink,
8466
+ onRename,
8467
+ onDelete,
8468
+ isPreviewLoading
8469
+ }) {
8470
+ return /* @__PURE__ */ jsx(Sheet, { open, onOpenChange, children: /* @__PURE__ */ jsx(SheetContent, { side: "right", className: "w-full gap-0 sm:max-w-md", children: object && /* @__PURE__ */ jsx(
8471
+ ObjectDetailBody,
8472
+ {
8473
+ object,
8474
+ onDownload,
8475
+ onCopyLink,
8476
+ onRename,
8477
+ onDelete,
8478
+ isPreviewLoading
8479
+ },
8480
+ object.id
8481
+ ) }) });
8482
+ }
8483
+ function UploadDropzone({ onFiles, uploads, onCancel, accept, maxSize, className }) {
8484
+ const inputRef = React19.useRef(null);
8485
+ const [isDragging, setIsDragging] = React19.useState(false);
8486
+ const handleDrop = (event) => {
8487
+ event.preventDefault();
8488
+ setIsDragging(false);
8489
+ if (event.dataTransfer.files.length > 0) {
8490
+ onFiles(event.dataTransfer.files);
8491
+ }
8492
+ };
8493
+ return /* @__PURE__ */ jsxs("div", { className: cn("flex flex-col gap-3", className), children: [
8494
+ /* @__PURE__ */ jsxs(
8495
+ "div",
8496
+ {
8497
+ onDragOver: (event) => {
8498
+ event.preventDefault();
8499
+ setIsDragging(true);
8500
+ },
8501
+ onDragLeave: () => setIsDragging(false),
8502
+ onDrop: handleDrop,
8503
+ className: cn(
8504
+ `flex flex-col items-center justify-center gap-2 rounded-lg border border-dashed px-6 py-8 text-center
8505
+ transition-colors`,
8506
+ isDragging ? "border-primary bg-primary/5" : "border-input bg-muted/30"
8507
+ ),
8508
+ children: [
8509
+ /* @__PURE__ */ jsx("div", { className: "flex size-10 items-center justify-center rounded-full bg-muted text-muted-foreground", children: /* @__PURE__ */ jsx(UploadCloudIcon, { className: "size-5", "aria-hidden": true }) }),
8510
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-0.5", children: [
8511
+ /* @__PURE__ */ jsx("p", { className: "text-pretty text-sm font-medium", children: "Drag & drop files here" }),
8512
+ /* @__PURE__ */ jsxs("p", { className: "text-xs text-muted-foreground", children: [
8513
+ "or browse",
8514
+ maxSize ? ` \u2014 up to ${humanizeBytes(maxSize)} each` : ""
8515
+ ] })
8516
+ ] }),
8517
+ /* @__PURE__ */ jsx(Button, { type: "button", size: "sm", variant: "outline", onClick: () => inputRef.current?.click(), children: "Browse files" }),
8518
+ /* @__PURE__ */ jsx(
8519
+ "input",
8520
+ {
8521
+ ref: inputRef,
8522
+ type: "file",
8523
+ multiple: true,
8524
+ accept,
8525
+ className: "sr-only",
8526
+ onChange: (event) => {
8527
+ if (event.target.files && event.target.files.length > 0) {
8528
+ onFiles(event.target.files);
8529
+ }
8530
+ event.target.value = "";
8531
+ }
8532
+ }
8533
+ )
8534
+ ]
8535
+ }
8536
+ ),
8537
+ uploads && uploads.length > 0 && /* @__PURE__ */ jsx(UploadProgressList, { uploads, onCancel })
8538
+ ] });
8539
+ }
8540
+ function UploadProgressList({ uploads, onCancel, className }) {
8541
+ return /* @__PURE__ */ jsx("ul", { className: cn("flex flex-col gap-2", className), children: uploads.map((item) => {
8542
+ const isActive = item.status === "queued" || item.status === "uploading";
8543
+ const isError = item.status === "error";
8544
+ return /* @__PURE__ */ jsxs(
8545
+ "li",
8546
+ {
8547
+ className: "flex items-center gap-3 rounded-lg border bg-background px-3 py-2",
8548
+ children: [
8549
+ /* @__PURE__ */ jsx(
8550
+ FileTypeIcon,
8551
+ {
8552
+ mimeType: item.filename.includes(".") ? guessMimeFromName(item.filename) : "",
8553
+ className: cn(isError && "text-destructive")
8554
+ }
8555
+ ),
8556
+ /* @__PURE__ */ jsxs("div", { className: "flex min-w-0 flex-1 flex-col gap-1", children: [
8557
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-2", children: [
8558
+ /* @__PURE__ */ jsx("span", { className: "truncate text-sm font-medium", children: item.filename }),
8559
+ /* @__PURE__ */ jsx("span", { className: "shrink-0 text-xs tabular-nums text-muted-foreground", children: humanizeBytes(item.size) })
8560
+ ] }),
8561
+ isError ? /* @__PURE__ */ jsxs("span", { className: "flex items-center gap-1 text-xs text-destructive", children: [
8562
+ /* @__PURE__ */ jsx(AlertCircleIcon, { className: "size-3.5", "aria-hidden": true }),
8563
+ /* @__PURE__ */ jsx("span", { className: "truncate", children: item.error ?? "Upload failed" })
8564
+ ] }) : /* @__PURE__ */ jsx(
8565
+ Progress,
8566
+ {
8567
+ value: item.status === "done" ? 100 : item.progress,
8568
+ "aria-label": `${item.filename} ${item.progress}%`,
8569
+ className: "h-1.5"
8570
+ }
8571
+ )
8572
+ ] }),
8573
+ isActive && onCancel && /* @__PURE__ */ jsx(
8574
+ Button,
8575
+ {
8576
+ size: "icon-sm",
8577
+ variant: "ghost",
8578
+ "aria-label": `Cancel upload of ${item.filename}`,
8579
+ onClick: () => onCancel(item.id),
8580
+ children: /* @__PURE__ */ jsx(XIcon, { "aria-hidden": true })
8581
+ }
8582
+ )
8583
+ ]
8584
+ },
8585
+ item.id
8586
+ );
8587
+ }) });
8588
+ }
8589
+ function guessMimeFromName(filename) {
8590
+ const ext = filename.split(".").pop()?.toLowerCase() ?? "";
8591
+ const map = {
8592
+ png: "image/png",
8593
+ jpg: "image/jpeg",
8594
+ jpeg: "image/jpeg",
8595
+ gif: "image/gif",
8596
+ webp: "image/webp",
8597
+ svg: "image/svg+xml",
8598
+ pdf: "application/pdf",
8599
+ zip: "application/zip",
8600
+ csv: "text/csv",
8601
+ txt: "text/plain",
8602
+ md: "text/markdown",
8603
+ doc: "application/msword",
8604
+ docx: "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
8605
+ xls: "application/vnd.ms-excel",
8606
+ xlsx: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
8607
+ mp4: "video/mp4",
8608
+ mp3: "audio/mpeg"
8609
+ };
8610
+ return map[ext] ?? "";
8611
+ }
8612
+ var VISIBILITY_OPTIONS = [
8613
+ { value: "public", label: "Public", hint: "Anyone with the link can read objects." },
8614
+ { value: "private", label: "Private", hint: "Only authorized requests can read objects." },
8615
+ { value: "temp", label: "Temp", hint: "Short-lived objects, cleaned up automatically." }
8616
+ ];
8617
+ function toFormValue(initial) {
8618
+ return {
8619
+ key: initial?.key ?? "",
8620
+ visibility: initial?.visibility ?? "private",
8621
+ allowCustomKeys: initial?.allowCustomKeys ?? false,
8622
+ allowedMimeTypes: initial?.allowedMimeTypes ?? [],
8623
+ maxFileSize: initial?.maxFileSize ?? null,
8624
+ allowedOrigins: initial?.allowedOrigins ?? [],
8625
+ description: initial?.description ?? ""
8626
+ };
8627
+ }
8628
+ function BucketConfigForm({
8629
+ mode,
8630
+ initial,
8631
+ onSubmit,
8632
+ onCancel,
8633
+ onOpenChange,
8634
+ supportedFields
8635
+ }) {
8636
+ const [value, setValue] = React19.useState(() => toFormValue(initial));
8637
+ const supports = (field) => supportedFields?.[field] !== false;
8638
+ const keyMissing = mode === "create" && value.key.trim() === "";
8639
+ const handleSubmit = (event) => {
8640
+ event.preventDefault();
8641
+ if (keyMissing) return;
8642
+ onSubmit({ ...value, key: value.key.trim(), description: value.description.trim() });
8643
+ };
8644
+ const set = (field, fieldValue) => {
8645
+ setValue((prev) => ({ ...prev, [field]: fieldValue }));
8646
+ };
8647
+ return /* @__PURE__ */ jsxs("form", { onSubmit: handleSubmit, className: "flex min-h-0 flex-1 flex-col", children: [
8648
+ /* @__PURE__ */ jsxs(SheetHeader, { className: "text-left", children: [
8649
+ /* @__PURE__ */ jsx(SheetTitle, { children: mode === "create" ? "New bucket" : "Edit bucket" }),
8650
+ /* @__PURE__ */ jsx(SheetDescription, { children: mode === "create" ? "Configure a new storage bucket." : "Update this bucket\u2019s configuration." })
8651
+ ] }),
8652
+ /* @__PURE__ */ jsxs("div", { className: "-mx-4 flex min-h-0 flex-1 flex-col gap-5 overflow-y-auto px-4 py-2", children: [
8653
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1.5", children: [
8654
+ /* @__PURE__ */ jsx(Label, { htmlFor: "bucket-key", children: "Key" }),
8655
+ /* @__PURE__ */ jsx(
8656
+ Input,
8657
+ {
8658
+ id: "bucket-key",
8659
+ value: value.key,
8660
+ disabled: mode === "edit",
8661
+ placeholder: "my-bucket",
8662
+ "aria-invalid": keyMissing || void 0,
8663
+ onChange: (event) => set("key", event.target.value)
8664
+ }
8665
+ ),
8666
+ mode === "edit" && /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: "The key cannot be changed after creation." })
8667
+ ] }),
8668
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2", children: [
8669
+ /* @__PURE__ */ jsx(Label, { children: "Visibility" }),
8670
+ /* @__PURE__ */ jsx(
8671
+ RadioGroup,
8672
+ {
8673
+ value: value.visibility,
8674
+ onValueChange: (next) => set("visibility", next),
8675
+ className: "gap-2",
8676
+ children: VISIBILITY_OPTIONS.map((option) => /* @__PURE__ */ jsxs(
8677
+ Label,
8678
+ {
8679
+ htmlFor: `visibility-${option.value}`,
8680
+ className: "flex cursor-pointer items-start gap-2.5 rounded-lg border p-3 font-normal has-[:checked]:border-primary/50 has-[:checked]:bg-primary/5",
8681
+ children: [
8682
+ /* @__PURE__ */ jsx(Radio, { id: `visibility-${option.value}`, value: option.value, className: "mt-0.5" }),
8683
+ /* @__PURE__ */ jsxs("span", { className: "flex flex-col gap-0.5", children: [
8684
+ /* @__PURE__ */ jsx("span", { className: "text-sm font-medium", children: option.label }),
8685
+ /* @__PURE__ */ jsx("span", { className: "text-xs text-muted-foreground", children: option.hint })
8686
+ ] })
8687
+ ]
8688
+ },
8689
+ option.value
8690
+ ))
8691
+ }
8692
+ )
8693
+ ] }),
8694
+ supports("allowCustomKeys") && /* @__PURE__ */ jsxs(
8695
+ Label,
8696
+ {
8697
+ htmlFor: "allow-custom-keys",
8698
+ className: "flex cursor-pointer items-center justify-between gap-3 font-normal",
8699
+ children: [
8700
+ /* @__PURE__ */ jsxs("span", { className: "flex flex-col gap-0.5", children: [
8701
+ /* @__PURE__ */ jsx("span", { className: "text-sm font-medium", children: "Allow custom keys" }),
8702
+ /* @__PURE__ */ jsx("span", { className: "text-pretty text-xs text-muted-foreground", children: "Let clients choose object keys instead of generated ones." })
8703
+ ] }),
8704
+ /* @__PURE__ */ jsx(
8705
+ Switch,
8706
+ {
8707
+ id: "allow-custom-keys",
8708
+ checked: value.allowCustomKeys,
8709
+ onCheckedChange: (checked) => set("allowCustomKeys", checked)
8710
+ }
8711
+ )
8712
+ ]
8713
+ }
8714
+ ),
8715
+ supports("allowedMimeTypes") && /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1.5", children: [
8716
+ /* @__PURE__ */ jsx(Label, { children: "Allowed MIME types" }),
8717
+ /* @__PURE__ */ jsx(
8718
+ ChipsInput,
8719
+ {
8720
+ value: value.allowedMimeTypes,
8721
+ onChange: (next) => set("allowedMimeTypes", next),
8722
+ placeholder: "image/png, application/pdf\u2026",
8723
+ ariaLabel: "Allowed MIME types"
8724
+ }
8725
+ ),
8726
+ /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: "Leave empty to allow any type." })
8727
+ ] }),
8728
+ supports("maxFileSize") && /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1.5", children: [
8729
+ /* @__PURE__ */ jsx(Label, { htmlFor: "max-file-size", children: "Max file size" }),
8730
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
8731
+ /* @__PURE__ */ jsx(
8732
+ Input,
8733
+ {
8734
+ id: "max-file-size",
8735
+ type: "number",
8736
+ min: 0,
8737
+ inputMode: "numeric",
8738
+ className: "max-w-40",
8739
+ value: value.maxFileSize ?? "",
8740
+ placeholder: "Unlimited",
8741
+ onChange: (event) => set("maxFileSize", event.target.value === "" ? null : Number(event.target.value))
8742
+ }
8743
+ ),
8744
+ /* @__PURE__ */ jsx("span", { className: "text-sm text-muted-foreground", children: "bytes" })
8745
+ ] })
8746
+ ] }),
8747
+ supports("allowedOrigins") && /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1.5", children: [
8748
+ /* @__PURE__ */ jsx(Label, { children: "Allowed origins (CORS)" }),
8749
+ /* @__PURE__ */ jsx(
8750
+ ChipsInput,
8751
+ {
8752
+ value: value.allowedOrigins,
8753
+ onChange: (next) => set("allowedOrigins", next),
8754
+ placeholder: "https://example.com",
8755
+ ariaLabel: "Allowed origins"
8756
+ }
8757
+ )
8758
+ ] }),
8759
+ supports("description") && /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1.5", children: [
8760
+ /* @__PURE__ */ jsx(Label, { htmlFor: "bucket-description", children: "Description" }),
8761
+ /* @__PURE__ */ jsx(
8762
+ Textarea,
8763
+ {
8764
+ id: "bucket-description",
8765
+ value: value.description,
8766
+ placeholder: "What is this bucket for?",
8767
+ onChange: (event) => set("description", event.target.value)
8768
+ }
8769
+ )
8770
+ ] })
8771
+ ] }),
8772
+ /* @__PURE__ */ jsxs(SheetFooter, { className: "pt-3", children: [
8773
+ /* @__PURE__ */ jsx(
8774
+ Button,
8775
+ {
8776
+ type: "button",
8777
+ variant: "outline",
8778
+ onClick: () => {
8779
+ onCancel?.();
8780
+ onOpenChange(false);
8781
+ },
8782
+ children: "Cancel"
8783
+ }
8784
+ ),
8785
+ /* @__PURE__ */ jsx(Button, { type: "submit", disabled: keyMissing, children: mode === "create" ? "Create bucket" : "Save changes" })
8786
+ ] })
8787
+ ] });
8788
+ }
8789
+ function BucketConfigSheet({
8790
+ mode,
8791
+ initial,
8792
+ open,
8793
+ onOpenChange,
8794
+ onSubmit,
8795
+ onCancel,
8796
+ supportedFields
8797
+ }) {
8798
+ const formKey = `${mode}:${initial?.id ?? "new"}:${open}`;
8799
+ return /* @__PURE__ */ jsx(Sheet, { open, onOpenChange, children: /* @__PURE__ */ jsx(SheetContent, { side: "right", className: "w-full sm:max-w-md", children: /* @__PURE__ */ jsx(
8800
+ BucketConfigForm,
8801
+ {
8802
+ mode,
8803
+ initial,
8804
+ onSubmit,
8805
+ onCancel,
8806
+ onOpenChange,
8807
+ supportedFields
8808
+ },
8809
+ formKey
8810
+ ) }) });
8811
+ }
8812
+ function ChipsInput({ value, onChange, placeholder, ariaLabel }) {
8813
+ const [draft, setDraft] = React19.useState("");
8814
+ const commit = () => {
8815
+ const token = draft.trim().replace(/,$/, "").trim();
8816
+ if (token && !value.includes(token)) {
8817
+ onChange([...value, token]);
8818
+ }
8819
+ setDraft("");
8820
+ };
8821
+ const removeAt = (index) => {
8822
+ onChange(value.filter((_, current) => current !== index));
8823
+ };
8824
+ return /* @__PURE__ */ jsxs(
8825
+ "div",
8826
+ {
8827
+ className: cn(
8828
+ `flex min-h-9 flex-wrap items-center gap-1.5 rounded-lg border border-input bg-background px-2 py-1.5
8829
+ focus-within:border-primary/60 focus-within:ring-[3px] focus-within:ring-primary/35`
8830
+ ),
8831
+ children: [
8832
+ value.map((chip, index) => /* @__PURE__ */ jsxs(Badge, { variant: "secondary", className: "gap-1 pr-1", children: [
8833
+ /* @__PURE__ */ jsx("span", { className: "truncate", children: chip }),
8834
+ /* @__PURE__ */ jsx(
8835
+ "button",
8836
+ {
8837
+ type: "button",
8838
+ "aria-label": `Remove ${chip}`,
8839
+ onClick: () => removeAt(index),
8840
+ className: "inline-flex size-3.5 items-center justify-center rounded-xs hover:bg-foreground/10",
8841
+ children: /* @__PURE__ */ jsx(XIcon, { className: "size-3", "aria-hidden": true })
8842
+ }
8843
+ )
8844
+ ] }, chip)),
8845
+ /* @__PURE__ */ jsx(
8846
+ "input",
8847
+ {
8848
+ value: draft,
8849
+ onChange: (event) => setDraft(event.target.value),
8850
+ onKeyDown: (event) => {
8851
+ if (event.key === "Enter" || event.key === ",") {
8852
+ event.preventDefault();
8853
+ commit();
8854
+ } else if (event.key === "Backspace" && draft === "" && value.length > 0) {
8855
+ removeAt(value.length - 1);
8856
+ }
8857
+ },
8858
+ onBlur: commit,
8859
+ placeholder: value.length === 0 ? placeholder : void 0,
8860
+ "aria-label": ariaLabel,
8861
+ className: "min-w-24 flex-1 bg-transparent text-sm outline-none placeholder:text-muted-foreground/72"
8862
+ }
8863
+ )
8864
+ ]
8865
+ }
8866
+ );
8867
+ }
8868
+ var VARIANTS = {
8869
+ "no-buckets": {
8870
+ icon: HardDriveIcon,
8871
+ title: "No buckets yet",
8872
+ description: "Buckets organize your uploaded files. Create your first one to start storing objects.",
8873
+ actionLabel: "New bucket"
8874
+ },
8875
+ "not-provisioned": {
8876
+ icon: DatabaseIcon,
8877
+ title: "Storage not provisioned",
8878
+ description: "This database has buckets defined but storage has not been provisioned yet. Provision to enable uploads.",
8879
+ actionLabel: "Provision storage"
8880
+ },
8881
+ "empty-bucket": {
8882
+ icon: InboxIcon,
8883
+ title: "This bucket is empty",
8884
+ description: "Upload files to this bucket and they will appear here.",
8885
+ actionLabel: "Upload files"
8886
+ },
8887
+ "no-access": {
8888
+ icon: ShieldAlertIcon,
8889
+ title: "No access to storage",
8890
+ description: "You need to be an active member of this organization to view its storage. If you recently joined, an admin may still need to confirm your membership.",
8891
+ actionLabel: null,
8892
+ secondaryLabel: "Refresh"
8893
+ }
8894
+ };
8895
+ function StorageEmptyState({ variant, onAction, onSecondaryAction, className }) {
8896
+ const config = VARIANTS[variant];
8897
+ const Icon = config.icon;
8898
+ return /* @__PURE__ */ jsxs(
8899
+ "div",
8900
+ {
8901
+ className: cn(
8902
+ "flex h-full w-full flex-col items-center justify-center gap-4 px-6 py-12 text-center",
8903
+ className
8904
+ ),
8905
+ children: [
8906
+ /* @__PURE__ */ jsx("div", { className: "flex size-12 items-center justify-center rounded-full bg-muted text-muted-foreground", children: /* @__PURE__ */ jsx(Icon, { className: "size-6", "aria-hidden": true }) }),
8907
+ /* @__PURE__ */ jsxs("div", { className: "flex max-w-sm flex-col gap-1.5", children: [
8908
+ /* @__PURE__ */ jsx("h2", { className: "text-balance text-base font-semibold text-foreground", children: config.title }),
8909
+ /* @__PURE__ */ jsx("p", { className: "text-pretty text-sm text-muted-foreground", children: config.description })
8910
+ ] }),
8911
+ config.actionLabel && /* @__PURE__ */ jsx(Button, { onClick: onAction, size: "sm", children: config.actionLabel }),
8912
+ variant === "no-access" && config.secondaryLabel && /* @__PURE__ */ jsx(Button, { onClick: onSecondaryAction, size: "sm", variant: "outline", children: config.secondaryLabel })
8913
+ ]
8914
+ }
8915
+ );
8916
+ }
8917
+ function StorageBrowser({
8918
+ buckets,
8919
+ selectedBucketId,
8920
+ onSelectBucket,
8921
+ onNewBucket,
8922
+ objects,
8923
+ selectedIds,
8924
+ onSelectionChange,
8925
+ sort,
8926
+ onSortChange,
8927
+ query,
8928
+ onQueryChange,
8929
+ segments,
8930
+ onNavigate,
8931
+ onOpenObject,
8932
+ onUpload,
8933
+ onBulkDelete,
8934
+ bulkDeleteProgress,
8935
+ onClearSelection,
8936
+ onDownload,
8937
+ onCopyLink,
8938
+ onRename,
8939
+ onDelete,
8940
+ isLoading,
8941
+ emptyLabel,
8942
+ emptyState,
8943
+ onEmptyStateAction,
8944
+ onEmptyStateSecondaryAction,
8945
+ className
8946
+ }) {
8947
+ const selectedBucket = buckets.find((bucket) => bucket.id === selectedBucketId) ?? null;
8948
+ const paneTakeover = emptyState === "no-buckets" || emptyState === "no-access" || emptyState === "not-provisioned";
8949
+ const showSelectBucketPrompt = !paneTakeover && !selectedBucket && buckets.length > 0;
8950
+ return /* @__PURE__ */ jsxs("div", { className: cn("flex h-full min-h-0 overflow-hidden rounded-lg border bg-background", className), children: [
8951
+ /* @__PURE__ */ jsxs("aside", { className: "flex w-64 shrink-0 flex-col border-r", children: [
8952
+ /* @__PURE__ */ jsx("div", { className: "flex h-12 items-center px-3", children: /* @__PURE__ */ jsx("h2", { className: "text-sm font-semibold", children: "Buckets" }) }),
8953
+ /* @__PURE__ */ jsx(Separator, {}),
8954
+ /* @__PURE__ */ jsx(
8955
+ BucketRail,
8956
+ {
8957
+ buckets,
8958
+ selectedBucketId,
8959
+ onSelectBucket,
8960
+ onNewBucket,
8961
+ className: "min-h-0 flex-1"
8962
+ }
8963
+ )
8964
+ ] }),
8965
+ /* @__PURE__ */ jsx("section", { className: "flex min-w-0 flex-1 flex-col", children: showSelectBucketPrompt ? /* @__PURE__ */ jsx("div", { className: "flex h-full w-full flex-col items-center justify-center px-6 py-12 text-center", children: /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: "Select a bucket to view its files." }) }) : !selectedBucket || paneTakeover ? /* @__PURE__ */ jsx(
8966
+ StorageEmptyState,
8967
+ {
8968
+ variant: emptyState ?? "no-buckets",
8969
+ onAction: onEmptyStateAction ?? onNewBucket,
8970
+ onSecondaryAction: onEmptyStateSecondaryAction
8971
+ }
8972
+ ) : /* @__PURE__ */ jsxs(Fragment, { children: [
8973
+ /* @__PURE__ */ jsxs("header", { className: "flex min-h-12 items-center gap-2 px-4 py-2", children: [
8974
+ /* @__PURE__ */ jsx("h1", { className: "truncate text-sm font-semibold", children: bucketDisplayName(selectedBucket) }),
8975
+ /* @__PURE__ */ jsx(VisibilityBadge, { visibility: selectedBucket.visibility, size: "sm" }),
8976
+ /* @__PURE__ */ jsx("div", { className: "ml-auto", children: /* @__PURE__ */ jsx(
8977
+ ObjectToolbar,
8978
+ {
8979
+ query,
8980
+ onQueryChange,
8981
+ sort,
8982
+ onSortChange,
8983
+ onUpload,
8984
+ selectedCount: selectedIds.length,
8985
+ onBulkDelete: onBulkDelete ? () => onBulkDelete(selectedIds) : void 0,
8986
+ bulkDeleteProgress,
8987
+ onClearSelection
8988
+ }
8989
+ ) })
8990
+ ] }),
8991
+ (segments?.length ?? 0) > 0 && /* @__PURE__ */ jsx("div", { className: "px-4 pb-2", children: /* @__PURE__ */ jsx(
8992
+ StorageBreadcrumb,
8993
+ {
8994
+ bucketKey: bucketDisplayName(selectedBucket),
8995
+ segments,
8996
+ onNavigate
8997
+ }
8998
+ ) }),
8999
+ /* @__PURE__ */ jsx(Separator, {}),
9000
+ /* @__PURE__ */ jsx("div", { className: "min-h-0 flex-1 overflow-auto", children: emptyState === "empty-bucket" ? /* @__PURE__ */ jsx(StorageEmptyState, { variant: "empty-bucket", onAction: onEmptyStateAction ?? onUpload }) : /* @__PURE__ */ jsx(
9001
+ ObjectTable,
9002
+ {
9003
+ objects,
9004
+ selectedIds,
9005
+ onSelectionChange,
9006
+ sort,
9007
+ onSortChange,
9008
+ onOpenObject,
9009
+ onDownload,
9010
+ onCopyLink,
9011
+ onRename,
9012
+ onDelete,
9013
+ isLoading,
9014
+ emptyLabel
9015
+ }
9016
+ ) })
9017
+ ] }) })
9018
+ ] });
9019
+ }
9020
+
9021
+ export { Alert, AlertDescription, AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogPortal, AlertDialogTitle, AlertDialogTrigger, AlertTitle, Autocomplete, AutocompleteEmpty, AutocompleteInput, AutocompleteItem, AutocompletePopup, AutocompleteSeparator, Avatar, AvatarFallback, AvatarImage, Badge, Breadcrumb, BreadcrumbEllipsis, BreadcrumbItem, BreadcrumbLink, BreadcrumbList, BreadcrumbPage, BreadcrumbSeparator, BucketConfigSheet, BucketRail, Button, Calendar, Card, CardAction, CardContent, CardDescription, CardFooter, CardHeader, CardStackProvider, CardStackViewport, CardTitle, Checkbox, CheckboxGroup, Collapsible, CollapsiblePanel as CollapsibleContent, CollapsibleTrigger, Combobox, ComboboxContent, ComboboxEmpty, ComboboxGroup, ComboboxInput, ComboboxItem, ComboboxList, ComboboxSeparator, ComboboxTrigger, Command, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, DEFAULT_ANIMATION_CONFIG, DeferredCardContent, Dialog, DialogBackdrop, DialogClose, DialogPopup as DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogPortal, DialogTitle, DialogTrigger, Dock, DockIcon, Drawer, DrawerClose, DrawerContent, DrawerDescription, DrawerFooter, DrawerHeader, DrawerOverlay, DrawerPortal, DrawerTitle, DrawerTrigger, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, Field, FieldRow, FileTypeIcon, FlickeringGrid, FlowZoomPanel, Form, FormControl, FormControl2 as FormControlComponent, FormDescription, FormField, FormItem, FormLabel, FormMessage, Input, InputGroup, InputGroupAddon, InputGroupInput, InputGroupText, InputGroupTextarea, JsonEditor, JsonInput, Label, ModalPortalScope, MotionGrid, MultiSelect, COLUMN_COUNT as OBJECT_TABLE_COLUMN_COUNT, ObjectDetailSheet, ObjectStatusBadge, ObjectTable, ObjectTableSkeleton, ObjectToolbar, OrgChart, PORTAL_ROOT_ID, PageHeader, Pagination, PaginationContent, PaginationEllipsis, PaginationItem, PaginationLink, PaginationNext, PaginationPrevious, Popover, PopoverAnchor, PopoverContent, PopoverTrigger, PortalRoot, Progress, ProgressiveBlur, ProgressiveBlurScrollContainer, Radio, RadioGroup, Radio as RadioGroupItem, RangeCalendar, RecordPicker, ResizableHandle, ResizablePanel, ResizablePanelGroup, ResponsiveDiagram, ScrollArea, ScrollBar, Select, SelectPopup as SelectContent, SelectFieldItem, SelectGroup, SelectGroupLabel, SelectItem, SelectGroupLabel as SelectLabel, SelectPopup, SelectRichItem, SelectSeparator, SelectTrigger, SelectValue, Separator, Sheet, SheetClose, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetTitle, SheetTrigger, Sidebar, SidebarContent, SidebarFooter, SidebarGroup, SidebarGroupAction, SidebarGroupContent, SidebarGroupLabel, SidebarHeader, SidebarInput, SidebarInset, SidebarMenu, SidebarMenuAction, SidebarMenuBadge, SidebarMenuButton, SidebarMenuItem, SidebarMenuSkeleton, SidebarMenuSub, SidebarMenuSubButton, SidebarMenuSubItem, SidebarProvider, SidebarSeparator, SidebarTrigger, Skeleton, Slot, Slottable, StackBackdrop, StackCard, StackHeader, StackHeaderSlot, Stepper, StepperDescription, StepperIndicator, StepperItem, StepperSeparator, StepperTitle, StepperTrigger, StorageBreadcrumb, StorageBrowser, StorageEmptyState, Switch, Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, TableRow, Tabs, TabsContent, TabsList, TabsTrigger, Tags, TagsContent, TagsEmpty, TagsGroup, TagsInput, TagsItem, TagsList, TagsTrigger, TagsValue, Textarea, Toaster, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, UnlinkButton, UploadDropzone, UploadProgressList, VisibilityBadge, alertVariants, backdropVariants, badgeVariants, bucketDisplayName, buttonVariants, calculateResponsiveOffset, cardVariants, cn, composeRefs, createCardVariants, createOffsetTransition, createReducedMotionVariants, dockVariants, durations, easings, formatDate, formatDateTime, getCardOffset, getCardZIndex, getCascadeOffset, getResponsiveCardOffset, getSideBySideOffset, getVisibleCardIndices, humanizeBytes, isCardVisible, mergeProps, normalizeWidth, objectDisplayName, parseWidthToPixels, peekDragSpring, peekHoverSpring, peekSlideSpring, reducedMotionBackdropVariants, shortMimeLabel, showErrorToast, showInfoToast, showSuccessToast, showWarningToast, snapBackSpring, springs, swipeDismissTransition, toast5 as toast, transitions, useCardIndex, useCardInjectedProps, useCardReady, useCardStack, useControllableState, useFloatingOverlayPortalProps, useFormField, useInModalOverlay, useIsMobile2 as useIsMobile, useIsTopCard, usePeekGestures, usePortalContainer, usePortalContext, useRootPortalContainer, useSidebar, useStackCards, useStackContext, useStackGestures, useStackLayoutMode, useStackResponsive, validateJson, variants };
7861
9022
  //# sourceMappingURL=index.js.map
7862
9023
  //# sourceMappingURL=index.js.map