@arbidocs/blocks 0.4.154 → 0.4.155

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/dist/chunk-6HMCF4AJ.js +1720 -0
  2. package/dist/chunk-6HMCF4AJ.js.map +1 -0
  3. package/dist/{chunk-BDA3RHYD.cjs → chunk-MUDEL7UL.cjs} +25 -884
  4. package/dist/chunk-MUDEL7UL.cjs.map +1 -0
  5. package/dist/{chunk-RE7NULEY.js → chunk-W7CWGURO.js} +28 -873
  6. package/dist/chunk-W7CWGURO.js.map +1 -0
  7. package/dist/chunk-WV4TD2HZ.cjs +1785 -0
  8. package/dist/chunk-WV4TD2HZ.cjs.map +1 -0
  9. package/dist/connect/index.cjs +1178 -16
  10. package/dist/connect/index.cjs.map +1 -1
  11. package/dist/connect/index.d.ts +1 -0
  12. package/dist/connect/index.js +1160 -12
  13. package/dist/connect/index.js.map +1 -1
  14. package/dist/connect/viewer.cjs +40 -44
  15. package/dist/connect/viewer.cjs.map +1 -1
  16. package/dist/connect/viewer.js +2 -6
  17. package/dist/connect/viewer.js.map +1 -1
  18. package/dist/connection/files/DocumentSyncGlyph.d.ts +28 -0
  19. package/dist/connection/files/explorer/ConnectedFilesExplorer.d.ts +56 -0
  20. package/dist/connection/files/explorer/FileTiles.d.ts +87 -0
  21. package/dist/connection/files/index.d.ts +5 -0
  22. package/dist/connection/files/store.d.ts +27 -0
  23. package/dist/connection/files/support.d.ts +38 -0
  24. package/dist/files/DocStatusIcon.d.ts +5 -4
  25. package/dist/files/FailedStageIcon.d.ts +26 -0
  26. package/dist/files/folders/FolderProviderIcon.d.ts +29 -0
  27. package/dist/files/folders/folderPaths.d.ts +86 -0
  28. package/dist/files/folders/index.d.ts +2 -0
  29. package/dist/files/index.cjs +326 -238
  30. package/dist/files/index.d.ts +5 -0
  31. package/dist/files/index.js +2 -2
  32. package/dist/files/permissions.d.ts +28 -0
  33. package/dist/files/recently-deleted.d.ts +7 -0
  34. package/dist/files/visibility.d.ts +31 -0
  35. package/dist/index.cjs +38 -38
  36. package/dist/index.js +2 -2
  37. package/node_modules/@arbidocs/coedit/package.json +1 -1
  38. package/package.json +6 -5
  39. package/dist/chunk-BDA3RHYD.cjs.map +0 -1
  40. package/dist/chunk-JGOST4IL.js +0 -648
  41. package/dist/chunk-JGOST4IL.js.map +0 -1
  42. package/dist/chunk-RE7NULEY.js.map +0 -1
  43. package/dist/chunk-YAEXSCUW.cjs +0 -677
  44. package/dist/chunk-YAEXSCUW.cjs.map +0 -1
@@ -0,0 +1,1720 @@
1
+ "use client";
2
+ import { LabelPickerList, DEFAULT_LABEL_MULTI_SELECT_LABELS } from './chunk-SDOEHEJP.js';
3
+ import { ActionLink } from './chunk-VF5EUAIV.js';
4
+ import { TONE_SURFACE } from './chunk-AUS3KBHJ.js';
5
+ import { testIdOr } from './chunk-7F6CBP3Z.js';
6
+ import { formatCount } from './chunk-OXF2IFXG.js';
7
+ import { AlertCircle, CircleSlash, BrainCircuit, LockKeyholeOpen, DatabaseZap, FileX, BookMarked, ListChevronsUpDown, FolderOpen, ChevronsUpDown, Check, Minus, Plus, X, ChevronDown, FolderPlus, UploadCloud, Mail, Folder, LoaderCircle, Sparkles, MoreHorizontal } from 'lucide-react';
8
+ import { cn, Button, Tooltip, TooltipTrigger, Slider, TooltipContent, Popover, PopoverTrigger, PopoverContent, Command, CommandInput, CommandList, CommandEmpty, CommandGroup, CommandItem, getDocumentTitle, getFileExtension, extensionFromMime, getEntityLabel, isAgent, getUserDisplayName, Checkbox, DropdownMenu, DropdownMenuTrigger, DropdownMenuContent, DropdownMenuSeparator, DropdownMenuSub, DropdownMenuSubTrigger, DropdownMenuSubContent, DropdownMenuItem } from '@arbidocs/react/ui';
9
+ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
10
+ import { forwardRef, memo, useMemo, useState, useRef, useEffect, useCallback } from 'react';
11
+ import { cva } from 'class-variance-authority';
12
+
13
+ function FilesFilterBar({ className, ...props }) {
14
+ return /* @__PURE__ */ jsx(
15
+ "div",
16
+ {
17
+ "data-slot": "files-filter-bar",
18
+ className: cn("flex min-w-0 flex-1 flex-nowrap items-center gap-2", className),
19
+ ...props
20
+ }
21
+ );
22
+ }
23
+ function FilesTagsButton({
24
+ onClick,
25
+ label = "Tags",
26
+ className,
27
+ testId
28
+ }) {
29
+ return /* @__PURE__ */ jsxs(
30
+ Button,
31
+ {
32
+ variant: "ghost",
33
+ size: "sm",
34
+ className: cn("h-8 shrink-0 gap-1.5 px-2 font-normal pointer-coarse:h-11", className),
35
+ onClick,
36
+ "data-testid": testIdOr(testId, { testId: "filter-bar-tags-button" }),
37
+ children: [
38
+ /* @__PURE__ */ jsx(BookMarked, { className: "h-3.5 w-3.5" }),
39
+ /* @__PURE__ */ jsx("span", { className: "text-sm max-[480px]:sr-only", children: label })
40
+ ]
41
+ }
42
+ );
43
+ }
44
+ function FilesViewCenter({ className, ...props }) {
45
+ return /* @__PURE__ */ jsx(
46
+ "div",
47
+ {
48
+ "data-slot": "files-view-center",
49
+ className: cn("@container flex min-w-[9.5rem] flex-1 items-center gap-2", className),
50
+ ...props
51
+ }
52
+ );
53
+ }
54
+ function FilesModalFooter({ children, className }) {
55
+ return /* @__PURE__ */ jsx(
56
+ "div",
57
+ {
58
+ "data-slot": "files-modal-footer",
59
+ className: cn(
60
+ // Sticks to the bottom of the modal's scrolling body so Close is always reachable.
61
+ "sticky bottom-0 z-40 flex justify-end gap-2 border-t border-border bg-background px-4 py-3 sm:px-6",
62
+ className
63
+ ),
64
+ children
65
+ }
66
+ );
67
+ }
68
+
69
+ // src/files/grid/row-density.ts
70
+ var LINE_PX = 14 * 1.35;
71
+ var CHROME = 18;
72
+ var MIN_LINES = 1;
73
+ var MAX_LINES = 10;
74
+ var rowHeightForLines = (lines) => Math.ceil(lines * LINE_PX + CHROME);
75
+ var linesForRowHeight = (height) => Math.max(MIN_LINES, Math.min(MAX_LINES, Math.floor((height - CHROME) / LINE_PX)));
76
+ var ROW_MIN = rowHeightForLines(MIN_LINES);
77
+ function RowDensityControl({
78
+ rowHeight,
79
+ onRowHeightChange,
80
+ testId = "documents-density"
81
+ }) {
82
+ const lines = linesForRowHeight(rowHeight);
83
+ const setLines = (next) => onRowHeightChange(rowHeightForLines(Math.max(MIN_LINES, Math.min(MAX_LINES, next))));
84
+ return /* @__PURE__ */ jsxs(Tooltip, { delayDuration: 300, children: [
85
+ /* @__PURE__ */ jsx(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsxs("div", { className: "flex h-7 items-center gap-1.5 rounded-md border border-input px-2 pointer-coarse:h-11", children: [
86
+ /* @__PURE__ */ jsx("span", { className: "hidden text-xs text-muted-foreground md:inline", children: "Rows" }),
87
+ /* @__PURE__ */ jsx(
88
+ "button",
89
+ {
90
+ type: "button",
91
+ "aria-label": "Shorter rows",
92
+ "data-testid": `${testId}-out`,
93
+ onClick: () => setLines(lines - 1),
94
+ disabled: lines <= MIN_LINES,
95
+ className: "flex items-center justify-center text-muted-foreground hover:text-foreground disabled:opacity-40 pointer-coarse:size-11",
96
+ children: /* @__PURE__ */ jsx(ListChevronsUpDown, { className: "h-4 w-4" })
97
+ }
98
+ ),
99
+ /* @__PURE__ */ jsx(
100
+ Slider,
101
+ {
102
+ value: [lines],
103
+ min: MIN_LINES,
104
+ max: MAX_LINES,
105
+ step: 1,
106
+ onValueChange: ([value]) => setLines(value),
107
+ "aria-label": "Row height",
108
+ "data-testid": testId,
109
+ className: "w-20"
110
+ }
111
+ )
112
+ ] }) }),
113
+ /* @__PURE__ */ jsxs(TooltipContent, { children: [
114
+ "Row height: ",
115
+ lines,
116
+ " line",
117
+ lines === 1 ? "" : "s"
118
+ ] })
119
+ ] });
120
+ }
121
+ function FolderBreadcrumb({
122
+ segments,
123
+ size = "xs"
124
+ }) {
125
+ const text = size === "sm" ? "text-sm" : "text-xs";
126
+ return /* @__PURE__ */ jsx("span", { "data-slot": "folder-breadcrumb", className: "min-w-0 truncate", children: segments.map((part, i, arr) => /* @__PURE__ */ jsxs("span", { className: "inline-flex items-center gap-0.5", children: [
127
+ i > 0 && /* @__PURE__ */ jsx("span", { className: `mx-0.5 ${text} text-muted-foreground/50`, children: "/" }),
128
+ /* @__PURE__ */ jsx("span", { className: i < arr.length - 1 ? `${text} text-muted-foreground` : "", children: part })
129
+ ] }, i)) });
130
+ }
131
+ function FolderCell({
132
+ folder,
133
+ segments,
134
+ icon,
135
+ isEditable,
136
+ picker,
137
+ className
138
+ }) {
139
+ const display = folder ? /* @__PURE__ */ jsxs(Fragment, { children: [
140
+ icon ?? /* @__PURE__ */ jsx(FolderOpen, { className: "h-3.5 w-3.5 flex-none shrink-0 text-muted-foreground" }),
141
+ /* @__PURE__ */ jsx(FolderBreadcrumb, { segments })
142
+ ] }) : /* @__PURE__ */ jsx("span", { className: "text-muted-foreground", children: "\u2014" });
143
+ const title = folder || void 0;
144
+ if (!isEditable) {
145
+ return /* @__PURE__ */ jsx(
146
+ "div",
147
+ {
148
+ "data-slot": "folder-cell",
149
+ title,
150
+ className: cn("flex h-full w-full min-w-0 items-center gap-1.5 text-sm", className),
151
+ children: display
152
+ }
153
+ );
154
+ }
155
+ return /* @__PURE__ */ jsxs(Popover, { children: [
156
+ /* @__PURE__ */ jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsx(
157
+ "button",
158
+ {
159
+ type: "button",
160
+ "data-slot": "folder-cell",
161
+ title,
162
+ className: cn(
163
+ "flex h-full w-full min-w-0 cursor-pointer items-center gap-1.5 text-left text-sm hover:text-primary",
164
+ className
165
+ ),
166
+ children: display
167
+ }
168
+ ) }),
169
+ /* @__PURE__ */ jsx(
170
+ PopoverContent,
171
+ {
172
+ className: "w-max min-w-[220px] max-w-[min(640px,92vw)] p-0",
173
+ align: "start",
174
+ side: "bottom",
175
+ sideOffset: 4,
176
+ children: picker
177
+ }
178
+ )
179
+ ] });
180
+ }
181
+ var FIELD_SURFACE = "rounded-md border border-input bg-muted/40 text-sm transition-colors hover:bg-background";
182
+ function FieldValue({ tone = "default", isMono, isTruncated, children }) {
183
+ return /* @__PURE__ */ jsx(
184
+ "span",
185
+ {
186
+ "data-slot": "field-value",
187
+ className: cn(
188
+ "text-sm",
189
+ tone === "strong" && "font-semibold",
190
+ tone === "muted" && "text-muted-foreground",
191
+ isMono && "font-mono",
192
+ isTruncated && "truncate"
193
+ ),
194
+ children
195
+ }
196
+ );
197
+ }
198
+ function FieldFolderSelect({ folder, picker }) {
199
+ return /* @__PURE__ */ jsxs(Popover, { children: [
200
+ /* @__PURE__ */ jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsxs(
201
+ "button",
202
+ {
203
+ type: "button",
204
+ "data-slot": "field-folder-select",
205
+ className: cn(
206
+ FIELD_SURFACE,
207
+ "flex h-9 w-full min-w-0 items-center gap-1.5 px-3 text-left hover:text-primary pointer-coarse:h-11"
208
+ ),
209
+ children: [
210
+ folder ? /* @__PURE__ */ jsxs(Fragment, { children: [
211
+ /* @__PURE__ */ jsx(FolderOpen, { className: "size-3.5 flex-none shrink-0 text-yellow-600" }),
212
+ /* @__PURE__ */ jsx(FolderBreadcrumb, { segments: folder.split("/"), size: "sm" })
213
+ ] }) : /* @__PURE__ */ jsx("span", { className: "text-muted-foreground", children: "\u2014" }),
214
+ /* @__PURE__ */ jsx(ChevronsUpDown, { className: "ml-auto size-3.5 shrink-0 opacity-50" })
215
+ ]
216
+ }
217
+ ) }),
218
+ /* @__PURE__ */ jsx(
219
+ PopoverContent,
220
+ {
221
+ className: "w-max min-w-[var(--radix-popover-trigger-width)] max-w-[min(640px,92vw)] p-0",
222
+ align: "start",
223
+ side: "bottom",
224
+ sideOffset: 4,
225
+ children: picker
226
+ }
227
+ )
228
+ ] });
229
+ }
230
+ function FieldFolderValue({ folder }) {
231
+ return /* @__PURE__ */ jsx("div", { className: "flex items-center gap-1.5 text-sm", children: folder ? /* @__PURE__ */ jsxs(Fragment, { children: [
232
+ /* @__PURE__ */ jsx(FolderOpen, { className: "size-3.5 shrink-0 text-yellow-600" }),
233
+ /* @__PURE__ */ jsx("span", { children: folder })
234
+ ] }) : /* @__PURE__ */ jsx("span", { className: "text-muted-foreground", children: "\u2014" }) });
235
+ }
236
+ function FieldLabelsSelect({
237
+ options,
238
+ appliedIds,
239
+ displayedIds = appliedIds,
240
+ onToggle,
241
+ onCreate,
242
+ emptyText = "Click to add",
243
+ labels
244
+ }) {
245
+ const applied = useMemo(
246
+ () => options.filter((o) => displayedIds.has(o.id)),
247
+ [options, displayedIds]
248
+ );
249
+ return /* @__PURE__ */ jsxs(Popover, { children: [
250
+ /* @__PURE__ */ jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsx(
251
+ "button",
252
+ {
253
+ type: "button",
254
+ "data-slot": "field-labels-select",
255
+ className: cn(
256
+ FIELD_SURFACE,
257
+ "flex min-h-9 w-full cursor-pointer items-center px-3 py-1.5 text-left pointer-coarse:min-h-11"
258
+ ),
259
+ children: /* @__PURE__ */ jsxs("div", { className: "flex min-h-[28px] flex-wrap items-center gap-1.5", children: [
260
+ applied.length === 0 && /* @__PURE__ */ jsx("span", { className: "text-sm italic text-muted-foreground", children: emptyText }),
261
+ applied.map((o) => /* @__PURE__ */ jsxs("span", { className: "inline-flex items-center gap-1 text-sm font-medium", children: [
262
+ /* @__PURE__ */ jsx(
263
+ "span",
264
+ {
265
+ className: "flex size-4 shrink-0 items-center justify-center rounded border-2",
266
+ style: { borderColor: o.color, backgroundColor: o.color },
267
+ children: /* @__PURE__ */ jsx(Check, { className: "size-3 text-white", strokeWidth: 3 })
268
+ }
269
+ ),
270
+ /* @__PURE__ */ jsx("span", { className: "max-w-[280px] truncate", children: o.name })
271
+ ] }, o.id))
272
+ ] })
273
+ }
274
+ ) }),
275
+ /* @__PURE__ */ jsx(PopoverContent, { className: "w-[360px] p-0", align: "start", side: "bottom", sideOffset: 4, children: /* @__PURE__ */ jsx(
276
+ LabelPickerList,
277
+ {
278
+ options,
279
+ appliedIds,
280
+ onToggle,
281
+ onCreate,
282
+ labels: { ...DEFAULT_LABEL_MULTI_SELECT_LABELS, ...labels }
283
+ }
284
+ ) })
285
+ ] });
286
+ }
287
+ function FieldNativeSelect({
288
+ value,
289
+ options,
290
+ onChange,
291
+ emptyLabel = "--",
292
+ ariaLabel
293
+ }) {
294
+ return /* @__PURE__ */ jsxs(
295
+ "select",
296
+ {
297
+ value,
298
+ "aria-label": ariaLabel,
299
+ onChange: (e) => onChange(e.target.value),
300
+ className: "h-9 w-full rounded-md border border-input bg-muted/40 px-3 text-sm transition-colors focus:bg-background focus:outline-none focus:ring-1 focus:ring-ring pointer-coarse:h-11",
301
+ children: [
302
+ /* @__PURE__ */ jsx("option", { value: "", children: emptyLabel }),
303
+ options.map((opt) => /* @__PURE__ */ jsx("option", { value: opt, children: opt }, opt))
304
+ ]
305
+ }
306
+ );
307
+ }
308
+ function FieldAttribution({ avatar, date, lines }) {
309
+ return /* @__PURE__ */ jsx("div", { className: "flex items-center gap-1", "data-slot": "field-attribution", children: /* @__PURE__ */ jsxs(Tooltip, { children: [
310
+ /* @__PURE__ */ jsx(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1", children: [
311
+ avatar,
312
+ /* @__PURE__ */ jsx("span", { className: "text-sm text-muted-foreground", children: date })
313
+ ] }) }),
314
+ /* @__PURE__ */ jsx(TooltipContent, { side: "bottom", children: lines.map((line, i) => /* @__PURE__ */ jsx("p", { className: "text-sm", children: line }, i)) })
315
+ ] }) });
316
+ }
317
+ function FieldWithAttribution({
318
+ attribution,
319
+ children
320
+ }) {
321
+ return /* @__PURE__ */ jsxs("div", { className: "group/doctag relative", "data-slot": "field-with-attribution", children: [
322
+ children,
323
+ /* @__PURE__ */ jsx("div", { className: "absolute right-0 top-0 bg-background/90 pl-2 opacity-0 transition-opacity group-focus-within/doctag:opacity-100 group-hover/doctag:opacity-100 pointer-coarse:opacity-100", children: attribution })
324
+ ] });
325
+ }
326
+ var FilterButton = ({ params, colId }) => {
327
+ const [isFilterActive, setIsFilterActive] = useState(false);
328
+ const btnRef = useRef(null);
329
+ useEffect(() => {
330
+ const check = () => setIsFilterActive(!!params.api.getFilterModel()[colId]);
331
+ check();
332
+ params.api.addEventListener("filterChanged", check);
333
+ return () => {
334
+ if (!params.api.isDestroyed()) params.api.removeEventListener("filterChanged", check);
335
+ };
336
+ }, [params.api, colId]);
337
+ return /* @__PURE__ */ jsx(
338
+ "span",
339
+ {
340
+ ref: btnRef,
341
+ role: "button",
342
+ "aria-label": "Filter",
343
+ onClick: (e) => {
344
+ e.stopPropagation();
345
+ if (btnRef.current) params.showFilter(btnRef.current);
346
+ },
347
+ className: `ag-header-icon ag-header-cell-filter-button ag-header-label-icon ${isFilterActive ? "ag-filter-active" : ""}`,
348
+ "aria-hidden": "false",
349
+ children: /* @__PURE__ */ jsx("span", { className: "ag-icon ag-icon-filter" })
350
+ }
351
+ );
352
+ };
353
+ var DEFAULT_FOLDER_PICKER_LABELS = {
354
+ none: "None",
355
+ removeFromFolder: "Remove from folder",
356
+ searchOrCreate: "Search or create...",
357
+ noFolders: "No folders yet",
358
+ create: (name) => `Create \u201C${name}\u201D`
359
+ };
360
+ function FolderPickerRow({
361
+ label,
362
+ icon,
363
+ count,
364
+ depth,
365
+ isActive,
366
+ muted,
367
+ checkbox,
368
+ indeterminate,
369
+ testId,
370
+ onClick
371
+ }) {
372
+ return /* @__PURE__ */ jsxs(
373
+ "button",
374
+ {
375
+ type: "button",
376
+ "data-testid": testId,
377
+ onClick,
378
+ role: checkbox ? "checkbox" : void 0,
379
+ "aria-checked": checkbox ? indeterminate ? "mixed" : isActive : void 0,
380
+ style: { paddingLeft: `${4 + depth * 14}px` },
381
+ className: cn(
382
+ // `[&:hover]:`, not `hover:`: the latter compiles behind `@media (hover: hover)`, so on a
383
+ // touchscreen whose PRIMARY pointer reports `hover: none` the row would never highlight
384
+ // even with a real mouse attached. The arbitrary selector has no media gate.
385
+ "flex w-full items-center gap-1 rounded-sm py-1 pr-2 text-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring [&:hover]:bg-accent pointer-coarse:min-h-11",
386
+ isActive && "bg-primary/10",
387
+ muted && !isActive && "text-muted-foreground"
388
+ ),
389
+ children: [
390
+ /* @__PURE__ */ jsx("span", { className: "flex w-4 shrink-0 items-center justify-center", children: checkbox ? /* @__PURE__ */ jsx(
391
+ "span",
392
+ {
393
+ className: cn(
394
+ "flex size-3.5 items-center justify-center rounded-[3px] border transition-colors",
395
+ isActive || indeterminate ? "border-primary bg-primary text-primary-foreground" : "border-muted-foreground/40"
396
+ ),
397
+ children: indeterminate ? /* @__PURE__ */ jsx(Minus, { className: "size-2.5" }) : isActive && /* @__PURE__ */ jsx(Check, { className: "size-2.5" })
398
+ }
399
+ ) : isActive && /* @__PURE__ */ jsx(Check, { className: "size-3.5 text-primary" }) }),
400
+ icon,
401
+ label !== "" && /* @__PURE__ */ jsx("span", { className: cn("min-w-0 truncate", isActive && "font-semibold text-primary"), children: label }),
402
+ count !== void 0 && /* @__PURE__ */ jsx("span", { className: "ml-auto pl-2 text-sm font-semibold text-muted-foreground", children: count })
403
+ ]
404
+ }
405
+ );
406
+ }
407
+ function FolderTree({
408
+ nodes,
409
+ unfiledCount,
410
+ value,
411
+ onChange,
412
+ showUnfiledAlways,
413
+ labels
414
+ }) {
415
+ const l = { ...DEFAULT_FOLDER_PICKER_LABELS, ...labels };
416
+ return /* @__PURE__ */ jsxs("div", { className: "max-h-[240px] overflow-y-auto", children: [
417
+ nodes.map((node) => /* @__PURE__ */ jsx(
418
+ FolderPickerRow,
419
+ {
420
+ label: node.label,
421
+ icon: node.icon,
422
+ count: node.count,
423
+ depth: node.depth,
424
+ isActive: value === node.path,
425
+ onClick: () => onChange(node.path)
426
+ },
427
+ node.path
428
+ )),
429
+ (unfiledCount > 0 || showUnfiledAlways) && /* @__PURE__ */ jsxs(Fragment, { children: [
430
+ nodes.length > 0 && /* @__PURE__ */ jsx("div", { className: "my-1 border-t border-border" }),
431
+ /* @__PURE__ */ jsx(
432
+ FolderPickerRow,
433
+ {
434
+ label: l.none,
435
+ count: unfiledCount,
436
+ depth: 0,
437
+ isActive: value === null,
438
+ muted: true,
439
+ onClick: () => onChange(null)
440
+ }
441
+ )
442
+ ] })
443
+ ] });
444
+ }
445
+ function FolderBreadcrumb2({ folder }) {
446
+ const parts = folder.split("/");
447
+ return /* @__PURE__ */ jsx("span", { className: "whitespace-nowrap", children: parts.map((part, i) => /* @__PURE__ */ jsxs("span", { className: "inline-flex items-center gap-0.5", children: [
448
+ i > 0 && /* @__PURE__ */ jsx("span", { className: "mx-0.5 text-sm text-muted-foreground/50", children: "/" }),
449
+ /* @__PURE__ */ jsx("span", { className: i < parts.length - 1 ? "text-sm text-muted-foreground" : "", children: part })
450
+ ] }, i)) });
451
+ }
452
+ function FolderCommandList({
453
+ folders,
454
+ value,
455
+ onSelect,
456
+ showRemove = false,
457
+ removeLabel,
458
+ placeholder,
459
+ autoFocus = true,
460
+ labels,
461
+ testIds
462
+ }) {
463
+ const l = { ...DEFAULT_FOLDER_PICKER_LABELS, ...labels };
464
+ const [search, setSearch] = useState("");
465
+ const trimmed = search.trim();
466
+ const matchesExisting = folders.some((f) => f.toLowerCase() === trimmed.toLowerCase());
467
+ const handleCreate = useCallback(
468
+ (name) => {
469
+ const next = name.trim();
470
+ if (!next) return;
471
+ onSelect(next);
472
+ setSearch("");
473
+ },
474
+ [onSelect]
475
+ );
476
+ return /* @__PURE__ */ jsxs(Command, { shouldFilter: true, children: [
477
+ /* @__PURE__ */ jsx(
478
+ CommandInput,
479
+ {
480
+ placeholder: placeholder ?? l.searchOrCreate,
481
+ value: search,
482
+ onValueChange: setSearch,
483
+ autoFocus,
484
+ onKeyDown: (e) => {
485
+ if (e.key === "Enter" && trimmed && !matchesExisting) {
486
+ e.preventDefault();
487
+ handleCreate(search);
488
+ }
489
+ }
490
+ }
491
+ ),
492
+ /* @__PURE__ */ jsxs(CommandList, { children: [
493
+ /* @__PURE__ */ jsx(CommandEmpty, { children: trimmed ? /* @__PURE__ */ jsxs(
494
+ "button",
495
+ {
496
+ type: "button",
497
+ "data-testid": testIdOr(testIds?.create, { testId: "folder-picker-create" }),
498
+ onClick: () => handleCreate(search),
499
+ onPointerDown: (e) => e.preventDefault(),
500
+ className: "flex w-full cursor-pointer items-center gap-1.5 rounded px-2 py-1.5 text-left text-sm text-primary hover:bg-accent pointer-coarse:min-h-11",
501
+ children: [
502
+ /* @__PURE__ */ jsx(Plus, { className: "size-3.5 shrink-0" }),
503
+ l.create(trimmed)
504
+ ]
505
+ }
506
+ ) : /* @__PURE__ */ jsx("span", { className: "text-muted-foreground", children: l.noFolders }) }),
507
+ /* @__PURE__ */ jsx(CommandGroup, { children: folders.map((folder) => /* @__PURE__ */ jsxs(
508
+ CommandItem,
509
+ {
510
+ value: folder,
511
+ "data-testid": testIdOr(testIds?.option?.(folder), {
512
+ testId: `folder-picker-option-${folder}`
513
+ }),
514
+ onSelect: () => onSelect(folder),
515
+ onPointerDown: (e) => e.preventDefault(),
516
+ className: "cursor-pointer text-sm",
517
+ children: [
518
+ /* @__PURE__ */ jsx(FolderOpen, { className: "mr-1.5 size-3.5 flex-none shrink-0 text-yellow-text" }),
519
+ /* @__PURE__ */ jsx(FolderBreadcrumb2, { folder }),
520
+ value === folder && /* @__PURE__ */ jsx("span", { className: "ml-auto flex-none text-sm text-primary", children: "\u2713" })
521
+ ]
522
+ },
523
+ folder
524
+ )) }),
525
+ trimmed && !matchesExisting && folders.length > 0 && /* @__PURE__ */ jsx(CommandGroup, { children: /* @__PURE__ */ jsxs(
526
+ CommandItem,
527
+ {
528
+ value: `__create__${trimmed}`,
529
+ "data-testid": testIdOr(testIds?.createOption, {
530
+ testId: "folder-picker-create-option"
531
+ }),
532
+ onSelect: () => handleCreate(search),
533
+ onPointerDown: (e) => e.preventDefault(),
534
+ className: "cursor-pointer text-sm text-primary",
535
+ children: [
536
+ /* @__PURE__ */ jsx(Plus, { className: "mr-1.5 size-3.5 shrink-0" }),
537
+ /* @__PURE__ */ jsx("span", { children: l.create(trimmed) })
538
+ ]
539
+ }
540
+ ) }),
541
+ showRemove && /* @__PURE__ */ jsx(CommandGroup, { children: /* @__PURE__ */ jsxs(
542
+ CommandItem,
543
+ {
544
+ value: "__none__",
545
+ "data-testid": testIdOr(testIds?.remove, { testId: "folder-picker-remove" }),
546
+ onSelect: () => onSelect(null),
547
+ onPointerDown: (e) => e.preventDefault(),
548
+ className: "cursor-pointer text-sm text-muted-foreground",
549
+ children: [
550
+ /* @__PURE__ */ jsx(X, { className: "mr-1 size-3.5 shrink-0" }),
551
+ /* @__PURE__ */ jsx("span", { children: removeLabel ?? l.removeFromFolder }),
552
+ value === null && /* @__PURE__ */ jsx("span", { className: "ml-auto flex-none text-sm text-primary", children: "\u2713" })
553
+ ]
554
+ }
555
+ ) })
556
+ ] })
557
+ ] });
558
+ }
559
+ var DEFAULT_FOLDER_FILTER_LABELS = {
560
+ all: "All",
561
+ newFolder: "New folder"
562
+ };
563
+ function FolderFilterButton({
564
+ label,
565
+ icon,
566
+ isActive,
567
+ open,
568
+ onOpenChange,
569
+ allCount,
570
+ onSelectAll,
571
+ onNewFolder,
572
+ children,
573
+ className,
574
+ labels,
575
+ testId,
576
+ newFolderTestId
577
+ }) {
578
+ const l = { ...DEFAULT_FOLDER_FILTER_LABELS, ...labels };
579
+ return /* @__PURE__ */ jsxs(Popover, { open, onOpenChange, children: [
580
+ /* @__PURE__ */ jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsxs(
581
+ Button,
582
+ {
583
+ variant: "ghost",
584
+ size: "sm",
585
+ "data-slot": "folder-filter-button",
586
+ "data-testid": testId,
587
+ className: cn(
588
+ "h-7 shrink-0 gap-1.5 px-2 text-sm font-normal pointer-coarse:h-10",
589
+ isActive && "bg-accent font-medium text-accent-foreground",
590
+ className
591
+ ),
592
+ children: [
593
+ icon ?? /* @__PURE__ */ jsx(
594
+ FolderOpen,
595
+ {
596
+ className: cn(
597
+ "h-3.5 w-3.5 shrink-0 text-muted-foreground",
598
+ isActive && "fill-muted-foreground/30"
599
+ )
600
+ }
601
+ ),
602
+ /* @__PURE__ */ jsx("span", { className: "max-w-[280px] truncate", children: label }),
603
+ /* @__PURE__ */ jsx(ChevronDown, { className: "h-4 w-4 text-foreground", strokeWidth: 2.5 })
604
+ ]
605
+ }
606
+ ) }),
607
+ /* @__PURE__ */ jsxs(
608
+ PopoverContent,
609
+ {
610
+ className: "w-max min-w-56 max-w-[480px] p-1 shadow-lg",
611
+ align: "start",
612
+ sideOffset: 4,
613
+ children: [
614
+ onSelectAll && /* @__PURE__ */ jsxs(Fragment, { children: [
615
+ /* @__PURE__ */ jsx(
616
+ FolderPickerRow,
617
+ {
618
+ label: l.all,
619
+ count: allCount,
620
+ depth: 0,
621
+ isActive: !isActive,
622
+ onClick: onSelectAll
623
+ }
624
+ ),
625
+ /* @__PURE__ */ jsx("div", { className: "my-1 border-t border-border" })
626
+ ] }),
627
+ children,
628
+ onNewFolder && /* @__PURE__ */ jsxs(Fragment, { children: [
629
+ /* @__PURE__ */ jsx("div", { className: "my-1 border-t border-border" }),
630
+ /* @__PURE__ */ jsxs(
631
+ "button",
632
+ {
633
+ type: "button",
634
+ onClick: onNewFolder,
635
+ "data-testid": testIdOr(newFolderTestId, { testId: "explorer-new-folder" }),
636
+ className: "flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-sm text-muted-foreground transition-colors hover:bg-accent hover:text-accent-foreground pointer-coarse:min-h-11",
637
+ children: [
638
+ /* @__PURE__ */ jsx(FolderPlus, { className: "h-3.5 w-3.5" }),
639
+ l.newFolder
640
+ ]
641
+ }
642
+ )
643
+ ] })
644
+ ]
645
+ }
646
+ )
647
+ ] });
648
+ }
649
+ function ExplorerFrame({ className, ...props }) {
650
+ return /* @__PURE__ */ jsx("div", { "data-slot": "explorer-frame", className: cn("flex h-full flex-col", className), ...props });
651
+ }
652
+ function ExplorerStage({ className, ...props }) {
653
+ return /* @__PURE__ */ jsx(
654
+ "div",
655
+ {
656
+ "data-slot": "explorer-stage",
657
+ className: cn("relative min-h-0 flex-1", className),
658
+ ...props
659
+ }
660
+ );
661
+ }
662
+ var ExplorerScroller = forwardRef(
663
+ function ExplorerScroller2({ className, ...props }, ref) {
664
+ return /* @__PURE__ */ jsx(
665
+ "div",
666
+ {
667
+ ref,
668
+ "data-slot": "explorer-scroller",
669
+ className: cn(
670
+ "h-full select-none overflow-auto px-4 py-4 [scrollbar-gutter:stable]",
671
+ className
672
+ ),
673
+ ...props
674
+ }
675
+ );
676
+ }
677
+ );
678
+ function ExplorerEmpty({ title, description }) {
679
+ return /* @__PURE__ */ jsxs(
680
+ "div",
681
+ {
682
+ "data-slot": "explorer-empty",
683
+ className: "flex h-full flex-col items-center justify-center gap-1 text-center text-muted-foreground",
684
+ children: [
685
+ /* @__PURE__ */ jsx("p", { className: "text-sm font-medium", children: title }),
686
+ /* @__PURE__ */ jsx("p", { className: "text-xs", children: description })
687
+ ]
688
+ }
689
+ );
690
+ }
691
+ var ExplorerMarquee = forwardRef(
692
+ function ExplorerMarquee2({ className, style, ...props }, ref) {
693
+ return /* @__PURE__ */ jsx(
694
+ "div",
695
+ {
696
+ ref,
697
+ "aria-hidden": true,
698
+ "data-slot": "explorer-marquee",
699
+ className: cn(
700
+ "pointer-events-none fixed z-30 border border-primary bg-primary/10",
701
+ className
702
+ ),
703
+ style: { display: "none", ...style },
704
+ ...props
705
+ }
706
+ );
707
+ }
708
+ );
709
+ function ExplorerDropOverlay({ label }) {
710
+ return /* @__PURE__ */ jsxs(
711
+ "div",
712
+ {
713
+ "data-slot": "explorer-drop-overlay",
714
+ className: "pointer-events-none absolute inset-2 z-20 flex flex-col items-center justify-center gap-2 rounded-lg border-2 border-dashed border-primary bg-accent/80 backdrop-blur-sm",
715
+ children: [
716
+ /* @__PURE__ */ jsx(UploadCloud, { className: "size-8 text-primary" }),
717
+ /* @__PURE__ */ jsx("p", { className: "text-sm font-medium text-primary", children: label })
718
+ ]
719
+ }
720
+ );
721
+ }
722
+ function ExplorerDragPreview({ icon, title, count }) {
723
+ const isMulti = count > 1;
724
+ return /* @__PURE__ */ jsxs("div", { "data-slot": "explorer-drag-preview", className: "relative", children: [
725
+ isMulti && /* @__PURE__ */ jsx(
726
+ "div",
727
+ {
728
+ "aria-hidden": true,
729
+ className: "absolute inset-0 translate-x-1.5 translate-y-1.5 rounded-lg border border-primary/30 bg-popover shadow-md"
730
+ }
731
+ ),
732
+ /* @__PURE__ */ jsxs("div", { className: "relative flex items-center gap-2 rounded-lg border border-primary/40 bg-popover px-3 py-2 shadow-lg", children: [
733
+ icon,
734
+ /* @__PURE__ */ jsx("span", { className: "max-w-[12rem] truncate text-sm font-medium", children: title }),
735
+ isMulti && /* @__PURE__ */ jsxs(
736
+ "span",
737
+ {
738
+ "data-slot": "explorer-drag-preview-count",
739
+ className: "whitespace-nowrap rounded-full bg-primary px-2 py-0.5 text-xs font-semibold text-primary-foreground",
740
+ children: [
741
+ count,
742
+ " items"
743
+ ]
744
+ }
745
+ )
746
+ ] })
747
+ ] });
748
+ }
749
+ function ExplorerLoadingTiles({
750
+ count = 18,
751
+ label = "Loading files",
752
+ testId,
753
+ className,
754
+ ...rest
755
+ }) {
756
+ return /* @__PURE__ */ jsx(
757
+ "div",
758
+ {
759
+ className: cn(
760
+ "grid gap-3 [grid-template-columns:repeat(auto-fill,minmax(150px,1fr))]",
761
+ className
762
+ ),
763
+ "aria-busy": "true",
764
+ "aria-label": label,
765
+ "data-slot": "explorer-loading-tiles",
766
+ ...rest,
767
+ "data-testid": testIdOr(testId, { testId: "explorer-loading-skeleton" }),
768
+ children: Array.from({ length: count }).map((_, i) => /* @__PURE__ */ jsx("div", { className: "aspect-[4/5] animate-pulse rounded-lg bg-muted" }, i))
769
+ }
770
+ );
771
+ }
772
+ function getExplorerDisplayName(doc) {
773
+ const title = getDocumentTitle(doc, doc.file_name ?? "Untitled");
774
+ if (getFileExtension(title)) return title;
775
+ const ext = getFileExtension(doc.file_name) || extensionFromMime(doc.file_type);
776
+ return ext ? `${title}.${ext}` : title;
777
+ }
778
+ function parseFolderSegments(folder) {
779
+ if (!folder) return [];
780
+ return folder.split("/").map((segment) => segment.trim()).filter(Boolean);
781
+ }
782
+ function joinFolderPath(segments) {
783
+ return segments.length > 0 ? segments.join("/") : null;
784
+ }
785
+ function startsWithPath(segments, prefix) {
786
+ if (segments.length < prefix.length) return false;
787
+ for (let i = 0; i < prefix.length; i++) {
788
+ if (segments[i] !== prefix[i]) return false;
789
+ }
790
+ return true;
791
+ }
792
+ function isExplorerDocument(doc) {
793
+ return !doc.parent_ext_id;
794
+ }
795
+ function collectFolderDocs(documents, path) {
796
+ if (path.length === 0) return documents.filter(isExplorerDocument);
797
+ return documents.filter(
798
+ (doc) => isExplorerDocument(doc) && startsWithPath(parseFolderSegments(doc.folder), path)
799
+ );
800
+ }
801
+ function compareFiles(a, b, sort) {
802
+ switch (sort) {
803
+ case "date": {
804
+ const at = a.created_at ? Date.parse(a.created_at) : 0;
805
+ const bt = b.created_at ? Date.parse(b.created_at) : 0;
806
+ return bt - at;
807
+ }
808
+ case "size": {
809
+ return (b.file_size ?? 0) - (a.file_size ?? 0);
810
+ }
811
+ case "name":
812
+ default:
813
+ return getDocumentTitle(a, a.file_name ?? "").localeCompare(
814
+ getDocumentTitle(b, b.file_name ?? ""),
815
+ void 0,
816
+ { numeric: true, sensitivity: "base" }
817
+ );
818
+ }
819
+ }
820
+ function sortExplorerFiles(docs, sort, reversed = false) {
821
+ const sorted = [...docs].sort((a, b) => compareFiles(a, b, sort));
822
+ return reversed ? sorted.reverse() : sorted;
823
+ }
824
+ function buildExplorerEntries(documents, currentPath, sort = "name", pendingFolders = []) {
825
+ const folderCounts = /* @__PURE__ */ new Map();
826
+ const files = [];
827
+ for (const doc of documents) {
828
+ const segments = parseFolderSegments(doc.folder);
829
+ if (!startsWithPath(segments, currentPath)) continue;
830
+ if (segments.length === currentPath.length) {
831
+ files.push(doc);
832
+ } else {
833
+ const childName = segments[currentPath.length];
834
+ folderCounts.set(childName, (folderCounts.get(childName) ?? 0) + 1);
835
+ }
836
+ }
837
+ const childNames = new Set(folderCounts.keys());
838
+ for (const pending of pendingFolders) {
839
+ const segments = parseFolderSegments(pending);
840
+ if (!startsWithPath(segments, currentPath)) continue;
841
+ if (segments.length > currentPath.length) childNames.add(segments[currentPath.length]);
842
+ }
843
+ const folders = Array.from(childNames).map((name) => ({
844
+ kind: "folder",
845
+ name,
846
+ path: [...currentPath, name],
847
+ count: folderCounts.get(name) ?? 0
848
+ })).sort((a, b) => a.name.localeCompare(b.name, void 0, { numeric: true, sensitivity: "base" }));
849
+ files.sort((a, b) => compareFiles(a, b, sort));
850
+ return { folders, files };
851
+ }
852
+ function searchExplorerDocuments(documents, query, sort = "name") {
853
+ const needle = query.trim().toLowerCase();
854
+ if (!needle) return [];
855
+ return documents.filter((doc) => {
856
+ if (!isExplorerDocument(doc)) return false;
857
+ const title = getDocumentTitle(doc, doc.file_name ?? "").toLowerCase();
858
+ const name = (doc.file_name ?? "").toLowerCase();
859
+ return title.includes(needle) || name.includes(needle);
860
+ }).sort((a, b) => compareFiles(a, b, sort));
861
+ }
862
+ function GmailMark({ className }) {
863
+ return /* @__PURE__ */ jsxs("svg", { viewBox: "0 0 256 193", className, "aria-hidden": "true", focusable: "false", children: [
864
+ /* @__PURE__ */ jsx(
865
+ "path",
866
+ {
867
+ fill: "#4285F4",
868
+ d: "M58.182 192.05V93.14L27.507 65.077 0 49.504v125.091c0 9.658 7.825 17.455 17.455 17.455z"
869
+ }
870
+ ),
871
+ /* @__PURE__ */ jsx(
872
+ "path",
873
+ {
874
+ fill: "#34A853",
875
+ d: "M197.818 192.05h40.727c9.659 0 17.455-7.826 17.455-17.455V49.505l-31.156 17.837-27.026 25.798z"
876
+ }
877
+ ),
878
+ /* @__PURE__ */ jsx(
879
+ "path",
880
+ {
881
+ fill: "#EA4335",
882
+ d: "m58.182 93.14-4.174-38.647 4.174-36.989L128 69.868l69.818-52.364 4.669 34.992-4.669 40.644L128 145.504z"
883
+ }
884
+ ),
885
+ /* @__PURE__ */ jsx(
886
+ "path",
887
+ {
888
+ fill: "#FBBC04",
889
+ d: "M197.818 17.504V93.14L256 49.504V26.231c0-21.585-24.64-33.89-41.89-20.945z"
890
+ }
891
+ ),
892
+ /* @__PURE__ */ jsx(
893
+ "path",
894
+ {
895
+ fill: "#C5221F",
896
+ d: "M0 49.504 26.759 69.574 58.182 93.14V17.504L41.89 5.286C24.61-7.66 0 4.646 0 26.231z"
897
+ }
898
+ )
899
+ ] });
900
+ }
901
+ function OutlookMark({ className }) {
902
+ return /* @__PURE__ */ jsxs("svg", { viewBox: "0 0 48 48", className, "aria-hidden": "true", focusable: "false", children: [
903
+ /* @__PURE__ */ jsx("path", { fill: "#0F6CBD", d: "M44 13H24v22h18.5A1.5 1.5 0 0 0 44 33.5z" }),
904
+ /* @__PURE__ */ jsx("path", { fill: "#28A8EA", d: "M24 15.5 44 13v3L24 27z" }),
905
+ /* @__PURE__ */ jsx("rect", { x: "4", y: "9", width: "21", height: "30", rx: "2.5", fill: "#0364B8" }),
906
+ /* @__PURE__ */ jsx("ellipse", { cx: "14.5", cy: "24", rx: "6.2", ry: "7", fill: "none", stroke: "#fff", strokeWidth: "3.1" })
907
+ ] });
908
+ }
909
+ function OneDriveMark({ className }) {
910
+ return /* @__PURE__ */ jsxs("svg", { viewBox: "0 0 256 165", className, "aria-hidden": "true", focusable: "false", children: [
911
+ /* @__PURE__ */ jsx(
912
+ "path",
913
+ {
914
+ fill: "#0364B8",
915
+ d: "M154.66056 110.681557 207.502052 60.1479482C196.525811 17.3487078 152.932256-8.44908883 110.132767 2.52715287 90.8589801 7.46999082 74.1187452 19.4179992 63.179535 36.0386895 63.9974594 36.0180612 154.66056 110.681557 154.66056 110.681557Z"
916
+ }
917
+ ),
918
+ /* @__PURE__ */ jsx(
919
+ "path",
920
+ {
921
+ fill: "#0078D4",
922
+ d: "M97.6181022 45.5520619 97.6156169 45.5607606C87.5186874 39.307156 75.8741386 36.001658 63.9972108 36.0177537 63.7228296 36.0177537 63.4531706 36.03521 63.1792865 36.0384409 27.8517142 36.4761088-.432413365 65.4695515.00500592252 100.797124.163570414 113.612018 4.16769663 126.083687 11.4981977 136.595916L90.6631356 126.680913 151.357298 77.7409022 97.6181022 45.5520619Z"
923
+ }
924
+ ),
925
+ /* @__PURE__ */ jsx(
926
+ "path",
927
+ {
928
+ fill: "#1490DF",
929
+ d: "M207.502052 60.1481967C206.340406 60.0706542 205.173043 60.016946 203.992011 60.016946 196.903085 60.010012 189.887973 61.4579693 183.381112 64.271122L183.379621 64.2656543 151.357547 77.7411507 186.65952 121.347877 249.770673 136.689364C263.390071 111.405536 253.93411 79.8683506 228.650281 66.2489531 222.117076 62.7297161 214.906119 60.6497377 207.502301 60.1484453L207.502301 60.1481967 207.502052 60.1481967Z"
930
+ }
931
+ ),
932
+ /* @__PURE__ */ jsx(
933
+ "path",
934
+ {
935
+ fill: "#28A8EA",
936
+ d: "M11.4981977 136.595916C23.4514253 153.781772 43.063467 164.023845 63.9974594 164.012918L203.991762 164.012918C223.115435 164.018377 240.697951 153.524291 249.770425 136.689862L151.357298 77.7409022 11.4981977 136.595916Z"
937
+ }
938
+ )
939
+ ] });
940
+ }
941
+ function SharePointMark({ className }) {
942
+ return /* @__PURE__ */ jsxs("svg", { viewBox: "0 0 48 48", className, "aria-hidden": "true", focusable: "false", children: [
943
+ /* @__PURE__ */ jsx("circle", { cx: "22", cy: "22", r: "20", fill: "#036C70" }),
944
+ /* @__PURE__ */ jsx("circle", { cx: "16", cy: "20", r: "12", fill: "#1A9BA1" }),
945
+ /* @__PURE__ */ jsx("circle", { cx: "26", cy: "30", r: "10", fill: "#37C6D0" }),
946
+ /* @__PURE__ */ jsx("circle", { cx: "33", cy: "22", r: "8", fill: "#fff", opacity: "0.15" })
947
+ ] });
948
+ }
949
+ function GoogleDriveMark({ className }) {
950
+ return /* @__PURE__ */ jsxs("svg", { viewBox: "0 0 87.3 78", className, "aria-hidden": "true", focusable: "false", children: [
951
+ /* @__PURE__ */ jsx(
952
+ "path",
953
+ {
954
+ fill: "#0066da",
955
+ d: "M6.6 66.85l3.85 6.65c.8 1.4 1.95 2.5 3.3 3.3l13.75-23.8H0c0 1.55.4 3.1 1.2 4.5z"
956
+ }
957
+ ),
958
+ /* @__PURE__ */ jsx(
959
+ "path",
960
+ {
961
+ fill: "#00ac47",
962
+ d: "M43.65 25L29.9 1.2c-1.35.8-2.5 1.9-3.3 3.3L1.2 48.5A9.06 9.06 0 0 0 0 53h27.5z"
963
+ }
964
+ ),
965
+ /* @__PURE__ */ jsx(
966
+ "path",
967
+ {
968
+ fill: "#ea4335",
969
+ d: "M73.55 76.8c1.35-.8 2.5-1.9 3.3-3.3l1.6-2.75L86.1 57.4c.8-1.4 1.2-2.95 1.2-4.5H59.798l5.85 11.5z"
970
+ }
971
+ ),
972
+ /* @__PURE__ */ jsx(
973
+ "path",
974
+ {
975
+ fill: "#00832d",
976
+ d: "M43.65 25L57.4 1.2C56.05.4 54.5 0 52.9 0H34.4c-1.6 0-3.15.45-4.5 1.2z"
977
+ }
978
+ ),
979
+ /* @__PURE__ */ jsx(
980
+ "path",
981
+ {
982
+ fill: "#2684fc",
983
+ d: "M59.8 53H27.5L13.75 76.8c1.35.8 2.9 1.2 4.5 1.2h50.8c1.6 0 3.15-.45 4.5-1.2z"
984
+ }
985
+ ),
986
+ /* @__PURE__ */ jsx(
987
+ "path",
988
+ {
989
+ fill: "#ffba00",
990
+ d: "M73.4 26.5L60.65 4.5c-.8-1.4-1.95-2.5-3.3-3.3L43.65 25l16.15 28h27.45c0-1.55-.4-3.1-1.2-4.5z"
991
+ }
992
+ )
993
+ ] });
994
+ }
995
+ function BoxMark({ className }) {
996
+ return /* @__PURE__ */ jsxs("svg", { viewBox: "0 0 48 48", className, "aria-hidden": "true", focusable: "false", children: [
997
+ /* @__PURE__ */ jsx("rect", { width: "48", height: "48", rx: "10", fill: "#0061D5" }),
998
+ /* @__PURE__ */ jsx(
999
+ "path",
1000
+ {
1001
+ fill: "none",
1002
+ stroke: "#fff",
1003
+ strokeWidth: "2.5",
1004
+ strokeLinejoin: "round",
1005
+ strokeLinecap: "round",
1006
+ d: "M24 13 36 19 36 29 24 35 12 29 12 19Z"
1007
+ }
1008
+ ),
1009
+ /* @__PURE__ */ jsx(
1010
+ "path",
1011
+ {
1012
+ fill: "none",
1013
+ stroke: "#fff",
1014
+ strokeWidth: "2.5",
1015
+ strokeLinejoin: "round",
1016
+ strokeLinecap: "round",
1017
+ d: "M12 19 24 25 36 19 M24 25 24 35"
1018
+ }
1019
+ )
1020
+ ] });
1021
+ }
1022
+ function DropboxMark({ className }) {
1023
+ return /* @__PURE__ */ jsx("svg", { viewBox: "0 0 48 48", className, "aria-hidden": "true", focusable: "false", children: /* @__PURE__ */ jsxs("g", { fill: "#0061FF", children: [
1024
+ /* @__PURE__ */ jsx("path", { d: "M12 6 0 14l12 8 12-8z" }),
1025
+ /* @__PURE__ */ jsx("path", { d: "M36 6 24 14l12 8 12-8z" }),
1026
+ /* @__PURE__ */ jsx("path", { d: "M0 30l12 8 12-8-12-8z" }),
1027
+ /* @__PURE__ */ jsx("path", { d: "M36 22 24 30l12 8 12-8z" }),
1028
+ /* @__PURE__ */ jsx("path", { d: "M12 40.5 24 33l12 7.5L24 48z" })
1029
+ ] }) });
1030
+ }
1031
+ function OneNoteMark({ className }) {
1032
+ return /* @__PURE__ */ jsxs("svg", { viewBox: "0 0 48 48", className, "aria-hidden": "true", focusable: "false", children: [
1033
+ /* @__PURE__ */ jsx("rect", { width: "48", height: "48", rx: "10", fill: "#7719AA" }),
1034
+ /* @__PURE__ */ jsx("rect", { x: "10", y: "10", width: "21", height: "28", rx: "2.5", fill: "#fff", opacity: "0.95" }),
1035
+ /* @__PURE__ */ jsx("rect", { x: "31", y: "15", width: "7", height: "5", rx: "1.5", fill: "#fff", opacity: "0.6" }),
1036
+ /* @__PURE__ */ jsx("rect", { x: "31", y: "22", width: "7", height: "5", rx: "1.5", fill: "#fff", opacity: "0.6" }),
1037
+ /* @__PURE__ */ jsx("rect", { x: "31", y: "29", width: "7", height: "5", rx: "1.5", fill: "#fff", opacity: "0.6" })
1038
+ ] });
1039
+ }
1040
+ function ClioMark({ className }) {
1041
+ return /* @__PURE__ */ jsxs("svg", { viewBox: "0 0 48 48", className, "aria-hidden": "true", focusable: "false", children: [
1042
+ /* @__PURE__ */ jsx("rect", { width: "48", height: "48", rx: "10", fill: "#00263E" }),
1043
+ /* @__PURE__ */ jsx(
1044
+ "path",
1045
+ {
1046
+ fill: "none",
1047
+ stroke: "#4FC3F7",
1048
+ strokeWidth: "4.5",
1049
+ strokeLinecap: "round",
1050
+ d: "M32 17a10 10 0 1 0 0 14"
1051
+ }
1052
+ )
1053
+ ] });
1054
+ }
1055
+ function VendorLogo({
1056
+ vendorKey,
1057
+ className = "h-4 w-4",
1058
+ product
1059
+ }) {
1060
+ if (product === "onedrive") return /* @__PURE__ */ jsx(OneDriveMark, { className });
1061
+ if (product === "googledrive") return /* @__PURE__ */ jsx(GoogleDriveMark, { className });
1062
+ if (product === "sharepoint") return /* @__PURE__ */ jsx(SharePointMark, { className });
1063
+ if (product === "box") return /* @__PURE__ */ jsx(BoxMark, { className });
1064
+ if (product === "dropbox") return /* @__PURE__ */ jsx(DropboxMark, { className });
1065
+ if (product === "onenote") return /* @__PURE__ */ jsx(OneNoteMark, { className });
1066
+ if (product === "clio") return /* @__PURE__ */ jsx(ClioMark, { className });
1067
+ if (vendorKey === "gmail") return /* @__PURE__ */ jsx(GmailMark, { className });
1068
+ if (vendorKey === "microsoft") return /* @__PURE__ */ jsx(OutlookMark, { className });
1069
+ if (vendorKey === "microsoft_sharepoint") return /* @__PURE__ */ jsx(SharePointMark, { className });
1070
+ if (vendorKey === "box") return /* @__PURE__ */ jsx(BoxMark, { className });
1071
+ if (vendorKey === "dropbox") return /* @__PURE__ */ jsx(DropboxMark, { className });
1072
+ if (vendorKey === "onenote") return /* @__PURE__ */ jsx(OneNoteMark, { className });
1073
+ if (vendorKey === "clio") return /* @__PURE__ */ jsx(ClioMark, { className });
1074
+ return /* @__PURE__ */ jsx(Mail, { className: `${className} text-muted-foreground`, "aria-hidden": "true" });
1075
+ }
1076
+ var PROVIDER_PREFIXES = [
1077
+ ["Outlook", { vendorKey: "microsoft" }],
1078
+ ["Gmail", { vendorKey: "gmail" }],
1079
+ ["OneDrive", { vendorKey: "microsoft", product: "onedrive" }],
1080
+ ["Google Drive", { vendorKey: "gmail", product: "googledrive" }]
1081
+ ];
1082
+ function providerForRoot(root) {
1083
+ for (const [prefix, props] of PROVIDER_PREFIXES) {
1084
+ if (root.startsWith(prefix)) return props;
1085
+ }
1086
+ return null;
1087
+ }
1088
+ function FolderProviderIcon({
1089
+ folderPath,
1090
+ className
1091
+ }) {
1092
+ const root = folderPath.split("/")[0];
1093
+ const provider = providerForRoot(root);
1094
+ if (!provider) return null;
1095
+ return /* @__PURE__ */ jsx(VendorLogo, { vendorKey: provider.vendorKey, product: provider.product, className });
1096
+ }
1097
+ function hasFolderProviderIcon(folderPath) {
1098
+ return providerForRoot(folderPath.split("/")[0]) !== null;
1099
+ }
1100
+ function formatFolderSegment(segment) {
1101
+ if (!providerForRoot(segment)) return segment;
1102
+ const account = segment.match(/\(([^)]*)\)/);
1103
+ return account ? account[1].trim() : "";
1104
+ }
1105
+
1106
+ // src/files/permissions.ts
1107
+ function canChangeVisibility(doc, currentUserExtId) {
1108
+ if (!doc || !currentUserExtId) return false;
1109
+ const isCurrentUserAgent = currentUserExtId.startsWith("agt-");
1110
+ const isCreatedByAgent = doc.created_by_ext_id?.startsWith("agt-") ?? false;
1111
+ return isCurrentUserAgent || isCreatedByAgent || doc.created_by_ext_id === currentUserExtId;
1112
+ }
1113
+ function canEditDocumentFields(doc, currentUserExtId, workspaceRole) {
1114
+ if (!doc || !currentUserExtId) return false;
1115
+ if (currentUserExtId.startsWith("agt-")) return true;
1116
+ if (workspaceRole === "owner" || workspaceRole === "collaborator") return true;
1117
+ return canChangeVisibility(doc, currentUserExtId);
1118
+ }
1119
+ function canDeleteDocument(doc, currentUserExtId, workspaceRole) {
1120
+ if (!doc || !currentUserExtId) return false;
1121
+ if (workspaceRole === "owner") return true;
1122
+ if (workspaceRole === "collaborator") return doc.created_by_ext_id === currentUserExtId;
1123
+ return false;
1124
+ }
1125
+
1126
+ // src/files/recently-deleted.ts
1127
+ var RECENTLY_DELETED_HINT = "You can restore it from Recently deleted (Settings > Storage) for at least 30 days.";
1128
+ var RECENTLY_DELETED_HINT_PLURAL = "You can restore them from Recently deleted (Settings > Storage) for at least 30 days.";
1129
+ var DEFAULT_EXPLORER_LABELS = {
1130
+ moreActions: "More actions",
1131
+ name: "Name",
1132
+ select: "Select",
1133
+ deselect: "Deselect",
1134
+ empty: "Empty",
1135
+ itemCount: (count) => formatCount(count, { one: "item", other: "items" }),
1136
+ processing: (count) => `${count} processing`,
1137
+ aiSummary: "AI Summary:",
1138
+ noSummary: "No AI summary is available for this document yet.",
1139
+ lastModifiedBy: "Last modified by",
1140
+ shared: "Shared",
1141
+ private: "Private"
1142
+ };
1143
+ function TileLink({
1144
+ href,
1145
+ label,
1146
+ onSelect
1147
+ }) {
1148
+ return /* @__PURE__ */ jsx(
1149
+ ActionLink,
1150
+ {
1151
+ href,
1152
+ onSelect,
1153
+ "aria-label": label,
1154
+ "data-slot": "explorer-tile-link",
1155
+ className: "absolute inset-0 z-10 rounded-lg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"
1156
+ }
1157
+ );
1158
+ }
1159
+ function isInsideTileLink(e) {
1160
+ return e.target instanceof Element && !!e.target.closest('[data-slot="explorer-tile-link"]');
1161
+ }
1162
+ function ExplorerMenu({
1163
+ items,
1164
+ testId,
1165
+ label,
1166
+ align,
1167
+ triggerClassName
1168
+ }) {
1169
+ return /* @__PURE__ */ jsxs(DropdownMenu, { children: [
1170
+ /* @__PURE__ */ jsx(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsx(
1171
+ "button",
1172
+ {
1173
+ type: "button",
1174
+ "aria-label": label,
1175
+ "data-testid": testId,
1176
+ onClick: (e) => e.stopPropagation(),
1177
+ onPointerDown: (e) => e.stopPropagation(),
1178
+ className: cn(
1179
+ "flex size-6 items-center justify-center rounded-md bg-background/90 text-muted-foreground backdrop-blur-sm transition hover:bg-background hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring data-[state=open]:bg-background data-[state=open]:text-foreground pointer-coarse:size-11",
1180
+ triggerClassName
1181
+ ),
1182
+ children: /* @__PURE__ */ jsx(MoreHorizontal, { className: "size-4" })
1183
+ }
1184
+ ) }),
1185
+ /* @__PURE__ */ jsx(
1186
+ DropdownMenuContent,
1187
+ {
1188
+ align,
1189
+ onClick: (e) => e.stopPropagation(),
1190
+ onPointerDown: (e) => e.stopPropagation(),
1191
+ className: "w-44",
1192
+ children: items.map((item) => /* @__PURE__ */ jsxs("div", { children: [
1193
+ item.separatorBefore && /* @__PURE__ */ jsx(DropdownMenuSeparator, {}),
1194
+ item.submenu ? /* @__PURE__ */ jsxs(DropdownMenuSub, { children: [
1195
+ /* @__PURE__ */ jsxs(DropdownMenuSubTrigger, { "data-testid": item.testId, children: [
1196
+ /* @__PURE__ */ jsx(item.icon, { className: "mr-2 size-4" }),
1197
+ item.label
1198
+ ] }),
1199
+ /* @__PURE__ */ jsx(DropdownMenuSubContent, { className: "w-52", children: item.submenu.map((sub) => /* @__PURE__ */ jsxs(DropdownMenuItem, { onSelect: sub.onSelect, "data-testid": sub.testId, children: [
1200
+ /* @__PURE__ */ jsx(sub.icon, { className: "mr-2 size-4" }),
1201
+ sub.label
1202
+ ] }, sub.id)) })
1203
+ ] }) : /* @__PURE__ */ jsxs(
1204
+ DropdownMenuItem,
1205
+ {
1206
+ onSelect: item.onSelect,
1207
+ "data-testid": item.testId,
1208
+ className: cn(item.destructive && "text-destructive focus:text-destructive"),
1209
+ children: [
1210
+ /* @__PURE__ */ jsx(item.icon, { className: "mr-2 size-4" }),
1211
+ item.label
1212
+ ]
1213
+ }
1214
+ )
1215
+ ] }, item.id))
1216
+ }
1217
+ )
1218
+ ] });
1219
+ }
1220
+ function RenameField({
1221
+ seed,
1222
+ testId,
1223
+ label,
1224
+ onCommit,
1225
+ onCancel,
1226
+ className
1227
+ }) {
1228
+ const doneRef = useRef(false);
1229
+ const commit = (value) => {
1230
+ if (doneRef.current) return;
1231
+ doneRef.current = true;
1232
+ const trimmed = value.trim();
1233
+ if (trimmed && trimmed !== seed) onCommit(trimmed);
1234
+ else onCancel();
1235
+ };
1236
+ return /* @__PURE__ */ jsx(
1237
+ "input",
1238
+ {
1239
+ autoFocus: true,
1240
+ defaultValue: seed,
1241
+ "data-testid": testId,
1242
+ "aria-label": label,
1243
+ onFocus: (e) => e.currentTarget.select(),
1244
+ onClick: (e) => e.stopPropagation(),
1245
+ onPointerDown: (e) => e.stopPropagation(),
1246
+ onDoubleClick: (e) => e.stopPropagation(),
1247
+ onKeyDown: (e) => {
1248
+ if (e.key === "Enter") {
1249
+ e.preventDefault();
1250
+ commit(e.currentTarget.value);
1251
+ } else if (e.key === "Escape") {
1252
+ e.preventDefault();
1253
+ doneRef.current = true;
1254
+ onCancel();
1255
+ }
1256
+ },
1257
+ onBlur: (e) => commit(e.currentTarget.value),
1258
+ className: cn(
1259
+ "w-full rounded-md border border-primary bg-background px-1 py-0.5 text-sm text-foreground outline-none",
1260
+ className
1261
+ )
1262
+ }
1263
+ );
1264
+ }
1265
+ function SelectCheckbox({
1266
+ selected,
1267
+ onToggle,
1268
+ labels,
1269
+ className
1270
+ }) {
1271
+ return /* @__PURE__ */ jsx(
1272
+ Checkbox,
1273
+ {
1274
+ checked: selected,
1275
+ onPointerDown: (e) => e.stopPropagation(),
1276
+ onClick: onToggle,
1277
+ "aria-label": selected ? labels.deselect : labels.select,
1278
+ className: cn(
1279
+ "size-6 rounded-md border-muted-foreground/60 bg-card transition data-[state=checked]:border-primary data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground pointer-coarse:size-9",
1280
+ selected ? "opacity-100" : "opacity-60 hover:opacity-100",
1281
+ className
1282
+ )
1283
+ }
1284
+ );
1285
+ }
1286
+ function ExplorerFileTile({
1287
+ id,
1288
+ title,
1289
+ density,
1290
+ selected,
1291
+ dragging,
1292
+ renaming,
1293
+ thumbnailUrl,
1294
+ renderFileIcon,
1295
+ progress,
1296
+ statusMarker,
1297
+ offlineMarker,
1298
+ entity,
1299
+ tooltip,
1300
+ menuItems,
1301
+ rootRef,
1302
+ rootProps,
1303
+ onOpen,
1304
+ href,
1305
+ labels,
1306
+ testIds,
1307
+ onSelect,
1308
+ onToggle,
1309
+ onCommitRename,
1310
+ onCancelRename
1311
+ }) {
1312
+ const l = { ...DEFAULT_EXPLORER_LABELS, ...labels };
1313
+ const [thumbFailed, setThumbFailed] = useState(false);
1314
+ const [thumbLandscape, setThumbLandscape] = useState(false);
1315
+ const showThumbnail = !!thumbnailUrl && !thumbFailed && !progress;
1316
+ const tile = /* @__PURE__ */ jsxs(
1317
+ "div",
1318
+ {
1319
+ ref: rootRef,
1320
+ ...rootProps,
1321
+ onClick: (e) => {
1322
+ if (href && isInsideTileLink(e)) {
1323
+ if (e.shiftKey) {
1324
+ e.preventDefault();
1325
+ onSelect(e);
1326
+ }
1327
+ return;
1328
+ }
1329
+ if (e.shiftKey || e.metaKey || e.ctrlKey) onSelect(e);
1330
+ else onOpen();
1331
+ },
1332
+ onDoubleClick: onOpen,
1333
+ "data-slot": "explorer-file-tile",
1334
+ "data-testid": testIdOr(testIds?.root, { testId: "explorer-file" }),
1335
+ "data-doc-id": id,
1336
+ className: cn(
1337
+ "group relative h-full cursor-default select-none overflow-hidden rounded-lg border transition",
1338
+ dragging && "opacity-40",
1339
+ selected ? "border-primary/30 bg-accent" : "border-border bg-muted hover:bg-muted/70"
1340
+ ),
1341
+ children: [
1342
+ href && /* @__PURE__ */ jsx(TileLink, { href, label: title, onSelect: onOpen }),
1343
+ showThumbnail ? /* @__PURE__ */ jsx(
1344
+ "img",
1345
+ {
1346
+ src: thumbnailUrl,
1347
+ alt: "",
1348
+ loading: "lazy",
1349
+ draggable: false,
1350
+ onError: () => setThumbFailed(true),
1351
+ onLoad: (e) => setThumbLandscape(e.currentTarget.naturalWidth > e.currentTarget.naturalHeight),
1352
+ className: cn(
1353
+ "absolute inset-0 size-full bg-card",
1354
+ thumbLandscape ? "object-contain" : "object-cover object-top"
1355
+ )
1356
+ }
1357
+ ) : /* @__PURE__ */ jsx("div", { className: "absolute inset-0 flex items-center justify-center", children: renderFileIcon(density === "list" ? 30 : 44) }),
1358
+ progress && /* @__PURE__ */ jsxs("div", { className: "absolute inset-0 z-10 flex flex-col items-center justify-center gap-1.5 bg-background/80 px-3", children: [
1359
+ /* @__PURE__ */ jsx(
1360
+ "div",
1361
+ {
1362
+ className: cn(
1363
+ "h-1.5 w-full rounded-sm",
1364
+ progress.queued ? "progress-bar-queued" : "progress-bar-processing"
1365
+ )
1366
+ }
1367
+ ),
1368
+ /* @__PURE__ */ jsx("span", { className: "text-xs font-medium text-primary", children: progress.label })
1369
+ ] }),
1370
+ /* @__PURE__ */ jsx(
1371
+ SelectCheckbox,
1372
+ {
1373
+ selected,
1374
+ onToggle,
1375
+ labels: l,
1376
+ className: "absolute left-1.5 top-1.5 z-20"
1377
+ }
1378
+ ),
1379
+ /* @__PURE__ */ jsx("div", { className: "absolute right-1.5 top-1.5 z-20", children: /* @__PURE__ */ jsx(
1380
+ ExplorerMenu,
1381
+ {
1382
+ items: menuItems,
1383
+ testId: testIdOr(testIds?.menu, { testId: "explorer-file-menu" }),
1384
+ label: l.moreActions,
1385
+ align: "start"
1386
+ }
1387
+ ) }),
1388
+ renaming ? /* @__PURE__ */ jsxs("div", { className: "absolute inset-x-0 bottom-0 z-20 flex items-center gap-1 bg-background/90 px-1.5 py-1 backdrop-blur-sm", children: [
1389
+ /* @__PURE__ */ jsx("span", { className: "shrink-0", children: renderFileIcon(13) }),
1390
+ /* @__PURE__ */ jsx(
1391
+ RenameField,
1392
+ {
1393
+ seed: title,
1394
+ testId: testIdOr(testIds?.renameInput, { testId: "explorer-rename-input" }),
1395
+ label: l.name,
1396
+ onCommit: onCommitRename,
1397
+ onCancel: onCancelRename,
1398
+ className: "flex-1 text-left"
1399
+ }
1400
+ )
1401
+ ] }) : /* @__PURE__ */ jsxs("div", { className: "absolute inset-x-1.5 bottom-1.5 z-20 flex flex-col gap-1", children: [
1402
+ (offlineMarker || statusMarker) && /* @__PURE__ */ jsxs("div", { className: "flex items-center", children: [
1403
+ offlineMarker,
1404
+ statusMarker && /* @__PURE__ */ jsx("div", { className: "ml-auto flex", children: statusMarker })
1405
+ ] }),
1406
+ entity
1407
+ ] })
1408
+ ]
1409
+ }
1410
+ );
1411
+ if (!tooltip) return tile;
1412
+ return /* @__PURE__ */ jsxs(Tooltip, { delayDuration: 500, children: [
1413
+ /* @__PURE__ */ jsx(TooltipTrigger, { asChild: true, children: tile }),
1414
+ /* @__PURE__ */ jsx(TooltipContent, { side: "bottom", sideOffset: 6, className: "p-2.5", children: tooltip })
1415
+ ] });
1416
+ }
1417
+ function ExplorerFolderTile({
1418
+ name,
1419
+ displayName,
1420
+ path,
1421
+ count,
1422
+ density,
1423
+ editing,
1424
+ selected,
1425
+ partiallySelected,
1426
+ processingCount = 0,
1427
+ isOver,
1428
+ icon,
1429
+ menuItems = [],
1430
+ rootRef,
1431
+ rootProps,
1432
+ onOpen,
1433
+ href,
1434
+ labels,
1435
+ testIds,
1436
+ onToggleSelect,
1437
+ onCommitName,
1438
+ onCancelName
1439
+ }) {
1440
+ const l = { ...DEFAULT_EXPLORER_LABELS, ...labels };
1441
+ const iconSize = density === "list" ? 34 : 48;
1442
+ const isEmpty = count === 0;
1443
+ const countLabel = isEmpty ? l.empty : l.itemCount(count);
1444
+ const joined = path.join("/");
1445
+ return /* @__PURE__ */ jsxs(
1446
+ "div",
1447
+ {
1448
+ ref: rootRef,
1449
+ ...rootProps,
1450
+ onClick: editing || href ? void 0 : onOpen,
1451
+ "data-slot": "explorer-folder-tile",
1452
+ "data-testid": testIdOr(testIds?.root, { testId: "explorer-folder" }),
1453
+ "data-folder-path": joined,
1454
+ title: name,
1455
+ className: cn(
1456
+ "group relative flex h-full cursor-pointer select-none flex-col items-center justify-center gap-1 rounded-lg p-2 text-center transition",
1457
+ isOver ? "bg-accent ring-2 ring-primary/40" : selected ? "bg-accent ring-1 ring-primary/30" : "bg-muted hover:bg-muted/70",
1458
+ isEmpty && !isOver && !selected && "opacity-70"
1459
+ ),
1460
+ children: [
1461
+ href && !editing && /* @__PURE__ */ jsx(TileLink, { href, label: displayName || name, onSelect: onOpen }),
1462
+ onToggleSelect && !isEmpty && /* @__PURE__ */ jsx(
1463
+ SelectCheckbox,
1464
+ {
1465
+ selected: !!selected,
1466
+ onToggle: onToggleSelect,
1467
+ labels: l,
1468
+ className: cn(
1469
+ "absolute left-1.5 top-1.5 z-20",
1470
+ partiallySelected && !selected && "opacity-100"
1471
+ )
1472
+ }
1473
+ ),
1474
+ menuItems.length > 0 && !editing && /* @__PURE__ */ jsx("div", { className: "absolute right-1 top-1 z-20", children: /* @__PURE__ */ jsx(
1475
+ ExplorerMenu,
1476
+ {
1477
+ items: menuItems,
1478
+ testId: testIdOr(testIds?.menu, { testId: "explorer-folder-menu" }),
1479
+ label: l.moreActions,
1480
+ align: "end"
1481
+ }
1482
+ ) }),
1483
+ icon ?? /* @__PURE__ */ jsx(
1484
+ Folder,
1485
+ {
1486
+ className: cn(
1487
+ "transition",
1488
+ isEmpty ? "text-yellow-text/50" : "fill-yellow-text/30 text-yellow-text group-hover:fill-yellow-text/40"
1489
+ ),
1490
+ size: iconSize
1491
+ }
1492
+ ),
1493
+ editing ? /* @__PURE__ */ jsx(
1494
+ RenameField,
1495
+ {
1496
+ seed: name,
1497
+ testId: testIdOr(testIds?.renameInput, { testId: "explorer-rename-input" }),
1498
+ label: l.name,
1499
+ onCommit: (next) => onCommitName?.(next),
1500
+ onCancel: () => onCancelName?.(),
1501
+ className: "text-center"
1502
+ }
1503
+ ) : displayName && /* @__PURE__ */ jsx(
1504
+ "span",
1505
+ {
1506
+ className: cn(
1507
+ "line-clamp-2 w-full break-words text-xs font-semibold leading-tight",
1508
+ isEmpty ? "text-foreground/60" : "text-foreground/90"
1509
+ ),
1510
+ children: displayName
1511
+ }
1512
+ ),
1513
+ /* @__PURE__ */ jsx("span", { className: "text-xs text-muted-foreground", children: countLabel }),
1514
+ processingCount > 0 && /* @__PURE__ */ jsxs(
1515
+ "span",
1516
+ {
1517
+ className: "inline-flex items-center gap-1 text-xs font-semibold text-primary",
1518
+ "data-testid": testIdOr(testIds?.processing, {
1519
+ testId: `explorer-folder-processing-${joined}`
1520
+ }),
1521
+ children: [
1522
+ /* @__PURE__ */ jsx(LoaderCircle, { className: "size-3 animate-spin" }),
1523
+ l.processing(processingCount)
1524
+ ]
1525
+ }
1526
+ )
1527
+ ]
1528
+ }
1529
+ );
1530
+ }
1531
+ function ExplorerFileTooltip({
1532
+ title,
1533
+ summary,
1534
+ modifiedLabel,
1535
+ modifiedByAvatar,
1536
+ shared,
1537
+ visibilityIcon,
1538
+ labels,
1539
+ uiLabels
1540
+ }) {
1541
+ const l = { ...DEFAULT_EXPLORER_LABELS, ...uiLabels };
1542
+ return /* @__PURE__ */ jsxs("div", { className: "max-w-xs space-y-2", children: [
1543
+ /* @__PURE__ */ jsx("div", { className: "break-words text-xs font-semibold leading-snug text-foreground", children: title }),
1544
+ /* @__PURE__ */ jsxs("div", { className: "space-y-1 border-t border-border pt-1.5", children: [
1545
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1 text-xs font-semibold text-foreground", children: [
1546
+ /* @__PURE__ */ jsx(Sparkles, { className: "size-3.5 shrink-0 text-yellow-text" }),
1547
+ l.aiSummary
1548
+ ] }),
1549
+ /* @__PURE__ */ jsx("p", { className: "line-clamp-6 text-xs leading-snug text-foreground/90", children: summary?.trim() || l.noSummary })
1550
+ ] }),
1551
+ (modifiedLabel || labels.length > 0) && /* @__PURE__ */ jsxs("div", { className: "space-y-1.5 border-t border-border pt-1.5", children: [
1552
+ modifiedLabel && /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-2 text-xs text-muted-foreground", children: [
1553
+ /* @__PURE__ */ jsxs("div", { className: "flex min-w-0 flex-wrap items-center gap-1", children: [
1554
+ /* @__PURE__ */ jsx("span", { children: l.lastModifiedBy }),
1555
+ modifiedByAvatar,
1556
+ /* @__PURE__ */ jsx("span", { children: modifiedLabel })
1557
+ ] }),
1558
+ /* @__PURE__ */ jsxs("div", { className: "flex shrink-0 items-center gap-1", children: [
1559
+ visibilityIcon,
1560
+ /* @__PURE__ */ jsx("span", { children: shared ? l.shared : l.private })
1561
+ ] })
1562
+ ] }),
1563
+ labels.length > 0 && /* @__PURE__ */ jsx("div", { className: "flex flex-wrap gap-1 pt-0.5", children: labels.map((label) => /* @__PURE__ */ jsx(
1564
+ "span",
1565
+ {
1566
+ className: "rounded bg-muted px-1.5 py-0.5 text-xs font-medium text-foreground/80",
1567
+ children: label
1568
+ },
1569
+ label
1570
+ )) })
1571
+ ] })
1572
+ ] });
1573
+ }
1574
+ var pill = cva(
1575
+ "inline-flex max-w-full items-center justify-center gap-1 rounded-full text-xs font-medium leading-none",
1576
+ {
1577
+ variants: {
1578
+ /** `icon` = glyph-only chip; `label` = text pill. */
1579
+ shape: { icon: "size-6 p-0 pointer-coarse:size-8", label: "h-6 px-2 pointer-coarse:h-8" },
1580
+ interactive: {
1581
+ true: "relative cursor-pointer pointer-coarse:after:absolute pointer-coarse:after:left-1/2 pointer-coarse:after:top-1/2 pointer-coarse:after:size-11 pointer-coarse:after:-translate-x-1/2 pointer-coarse:after:-translate-y-1/2 pointer-coarse:after:content-[''] hover:brightness-95 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
1582
+ false: ""
1583
+ }
1584
+ },
1585
+ defaultVariants: { shape: "label", interactive: false }
1586
+ }
1587
+ );
1588
+ function StatusPill({
1589
+ tone = "neutral",
1590
+ icon,
1591
+ label,
1592
+ progress,
1593
+ title,
1594
+ onClick,
1595
+ testId,
1596
+ className
1597
+ }) {
1598
+ const hasLabel = label !== void 0 && label !== null && label !== "";
1599
+ const classes = cn(
1600
+ pill({ shape: hasLabel ? "label" : "icon", interactive: !!onClick }),
1601
+ TONE_SURFACE[tone],
1602
+ progress && "h-auto min-h-6 flex-col gap-0 px-2 py-1",
1603
+ className
1604
+ );
1605
+ const body = /* @__PURE__ */ jsxs(Fragment, { children: [
1606
+ /* @__PURE__ */ jsxs("span", { className: "inline-flex max-w-full items-center gap-1", children: [
1607
+ icon,
1608
+ hasLabel && /* @__PURE__ */ jsx("span", { className: "truncate", children: label })
1609
+ ] }),
1610
+ progress && /* @__PURE__ */ jsx(
1611
+ "span",
1612
+ {
1613
+ "aria-hidden": true,
1614
+ "data-slot": "status-pill-progress",
1615
+ className: cn(
1616
+ "mt-0.5 block h-1 w-full min-w-10 shrink-0 rounded-sm",
1617
+ progress === "queued" ? "progress-bar-queued" : "progress-bar-processing"
1618
+ )
1619
+ }
1620
+ )
1621
+ ] });
1622
+ if (onClick) {
1623
+ return /* @__PURE__ */ jsx(
1624
+ "button",
1625
+ {
1626
+ type: "button",
1627
+ title,
1628
+ "aria-label": hasLabel ? void 0 : title,
1629
+ "data-slot": "status-pill",
1630
+ "data-testid": testId,
1631
+ className: classes,
1632
+ onClick: (e) => {
1633
+ e.stopPropagation();
1634
+ onClick();
1635
+ },
1636
+ onKeyDown: (e) => e.stopPropagation(),
1637
+ children: body
1638
+ }
1639
+ );
1640
+ }
1641
+ return /* @__PURE__ */ jsx(
1642
+ "span",
1643
+ {
1644
+ title,
1645
+ role: hasLabel || !title ? void 0 : "img",
1646
+ "aria-label": hasLabel ? void 0 : title,
1647
+ "data-slot": "status-pill",
1648
+ "data-testid": testId,
1649
+ className: classes,
1650
+ children: body
1651
+ }
1652
+ );
1653
+ }
1654
+ var STAGE_VARIANTS = {
1655
+ parsing: { Icon: FileX, title: "Parsing failed" },
1656
+ indexing: { Icon: DatabaseZap, title: "Indexing failed" },
1657
+ encrypting: { Icon: LockKeyholeOpen, title: "Encryption failed" },
1658
+ analysing: { Icon: BrainCircuit, title: "Analysis failed" },
1659
+ queued: { Icon: CircleSlash, title: "Failed before processing" },
1660
+ unknown: { Icon: AlertCircle, title: "Failed" }
1661
+ };
1662
+ var LEGACY_VARIANT = {
1663
+ Icon: AlertCircle,
1664
+ title: "Failed (stage unknown)"
1665
+ };
1666
+ function resolveVariant(stage) {
1667
+ if (stage == null) return LEGACY_VARIANT;
1668
+ return STAGE_VARIANTS[stage] ?? STAGE_VARIANTS.unknown;
1669
+ }
1670
+ var FailedStageIcon = memo(function FailedStageIcon2({
1671
+ stage,
1672
+ errorMessage,
1673
+ className = "w-4 h-4 text-red-text cursor-pointer hover:text-red-text",
1674
+ onClick
1675
+ }) {
1676
+ const { Icon, title } = resolveVariant(stage);
1677
+ const fullTitle = errorMessage ? `${title}: ${errorMessage}` : title;
1678
+ return /* @__PURE__ */ jsx("div", { title: fullTitle, children: /* @__PURE__ */ jsx(Icon, { className, onClick }) });
1679
+ });
1680
+ var MAX_NAMES_IN_CONFIRM = 5;
1681
+ function shareStateOf(items) {
1682
+ if (items.length === 0) return "private";
1683
+ const sharedCount = items.filter((item) => item.shared === true).length;
1684
+ if (sharedCount === items.length) return "shared";
1685
+ return sharedCount > 0 ? "mixed" : "private";
1686
+ }
1687
+ function shareTooltipFor(state, isSingle) {
1688
+ const workspace = getEntityLabel("WORKSPACE");
1689
+ const subject = isSingle ? "" : " all";
1690
+ if (state === "shared") return `Hide${subject} from ${workspace} members`;
1691
+ if (state === "mixed") return `Make all visible to ${workspace} members (some already shared)`;
1692
+ return `Make${subject} visible to ${workspace} members`;
1693
+ }
1694
+ function confirmHideFromMembers(confirm, count, members) {
1695
+ const workspace = getEntityLabel("WORKSPACE");
1696
+ const documentLabel = getEntityLabel("DOCUMENT", count === 1 ? "SINGULAR" : "PLURAL");
1697
+ const pronoun = count === 1 ? "it" : "them";
1698
+ const names = members.filter((member) => !isAgent(member.user)).map((member) => getUserDisplayName(member.user));
1699
+ const shown = names.slice(0, MAX_NAMES_IN_CONFIRM);
1700
+ const hiddenCount = names.length - shown.length;
1701
+ const listed = hiddenCount > 0 ? [...shown, `${hiddenCount} more`] : shown;
1702
+ const last = listed[listed.length - 1];
1703
+ const audienceList = listed.length > 2 ? `${listed.slice(0, -1).join(", ")}, and ${last}` : listed.join(" and ");
1704
+ const audience = names.length > 0 ? `Right now ${audienceList} can see ${pronoun}. ` : "";
1705
+ return confirm({
1706
+ message: `Hide ${count} ${documentLabel.toLowerCase()} from ${workspace} members? ${audience}They will no longer be able to see ${pronoun}.`,
1707
+ title: "Hide from members"
1708
+ });
1709
+ }
1710
+ function visibilityAudience(shared, workspaceLabel = getEntityLabel("WORKSPACE")) {
1711
+ return shared ? `Shared with ${workspaceLabel.toLowerCase()}` : "Private to you";
1712
+ }
1713
+ function visibilityToggleTooltip(shared) {
1714
+ const workspace = getEntityLabel("WORKSPACE").toLowerCase();
1715
+ return shared ? `${visibilityAudience(true)}: everyone in it can see this file. Click to make it private to you.` : `${visibilityAudience(false)}: only you can see this file. Click to share it with the ${workspace}.`;
1716
+ }
1717
+
1718
+ export { CHROME, DEFAULT_EXPLORER_LABELS, DEFAULT_FOLDER_FILTER_LABELS, DEFAULT_FOLDER_PICKER_LABELS, ExplorerDragPreview, ExplorerDropOverlay, ExplorerEmpty, ExplorerFileTile, ExplorerFileTooltip, ExplorerFolderTile, ExplorerFrame, ExplorerLoadingTiles, ExplorerMarquee, ExplorerScroller, ExplorerStage, FailedStageIcon, FieldAttribution, FieldFolderSelect, FieldFolderValue, FieldLabelsSelect, FieldNativeSelect, FieldValue, FieldWithAttribution, FilesFilterBar, FilesModalFooter, FilesTagsButton, FilesViewCenter, FilterButton, FolderBreadcrumb, FolderCell, FolderCommandList, FolderFilterButton, FolderPickerRow, FolderProviderIcon, FolderTree, LINE_PX, MAX_LINES, MIN_LINES, RECENTLY_DELETED_HINT, RECENTLY_DELETED_HINT_PLURAL, ROW_MIN, RowDensityControl, StatusPill, VendorLogo, buildExplorerEntries, canChangeVisibility, canDeleteDocument, canEditDocumentFields, collectFolderDocs, confirmHideFromMembers, formatFolderSegment, getExplorerDisplayName, hasFolderProviderIcon, isExplorerDocument, joinFolderPath, linesForRowHeight, parseFolderSegments, rowHeightForLines, searchExplorerDocuments, shareStateOf, shareTooltipFor, sortExplorerFiles, visibilityAudience, visibilityToggleTooltip };
1719
+ //# sourceMappingURL=chunk-6HMCF4AJ.js.map
1720
+ //# sourceMappingURL=chunk-6HMCF4AJ.js.map