@arbidocs/react 0.4.146 → 0.4.150

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 (48) hide show
  1. package/dist/artifacts/index.cjs +17 -7
  2. package/dist/artifacts/index.cjs.map +1 -1
  3. package/dist/artifacts/index.d.cts +7 -1
  4. package/dist/artifacts/index.d.ts +7 -1
  5. package/dist/artifacts/index.js +11 -2
  6. package/dist/artifacts/index.js.map +1 -1
  7. package/dist/{chunk-MFMJHBJR.js → chunk-3XYIQZTH.js} +52 -3
  8. package/dist/chunk-3XYIQZTH.js.map +1 -0
  9. package/dist/{chunk-YIFUMQGA.cjs → chunk-IQIDM3KM.cjs} +10 -16
  10. package/dist/chunk-IQIDM3KM.cjs.map +1 -0
  11. package/dist/{chunk-KLPY2HUC.cjs → chunk-JFKWH6EP.cjs} +57 -2
  12. package/dist/chunk-JFKWH6EP.cjs.map +1 -0
  13. package/dist/{chunk-7AFGROHZ.js → chunk-JQ7Y723H.js} +11 -16
  14. package/dist/{chunk-7AFGROHZ.js.map → chunk-JQ7Y723H.js.map} +1 -1
  15. package/dist/{chunk-J3BYHBKW.js → chunk-KD7CKXWQ.js} +1721 -1427
  16. package/dist/chunk-KD7CKXWQ.js.map +1 -0
  17. package/dist/{chunk-65WT5PHA.cjs → chunk-L66ZJ2UI.cjs} +1733 -1425
  18. package/dist/chunk-L66ZJ2UI.cjs.map +1 -0
  19. package/dist/document-tools/index.cjs +31 -0
  20. package/dist/document-tools/index.cjs.map +1 -1
  21. package/dist/document-tools/index.d.cts +19 -1
  22. package/dist/document-tools/index.d.ts +19 -1
  23. package/dist/document-tools/index.js +30 -1
  24. package/dist/document-tools/index.js.map +1 -1
  25. package/dist/{index-2Y2MVegs.d.ts → index-BV7pBlgY.d.cts} +119 -6
  26. package/dist/{index-2Y2MVegs.d.cts → index-BV7pBlgY.d.ts} +119 -6
  27. package/dist/{index-3E0neHf_.d.cts → index-DyFzmDZ2.d.cts} +46 -1
  28. package/dist/{index-3E0neHf_.d.ts → index-DyFzmDZ2.d.ts} +46 -1
  29. package/dist/index.cjs +1705 -1218
  30. package/dist/index.cjs.map +1 -1
  31. package/dist/index.d.cts +1531 -304
  32. package/dist/index.d.ts +1531 -304
  33. package/dist/index.js +897 -573
  34. package/dist/index.js.map +1 -1
  35. package/dist/shell/index.cjs +33 -9
  36. package/dist/shell/index.d.cts +3 -1
  37. package/dist/shell/index.d.ts +3 -1
  38. package/dist/shell/index.js +1 -1
  39. package/dist/ui/index.cjs +174 -118
  40. package/dist/ui/index.d.cts +1 -1
  41. package/dist/ui/index.d.ts +1 -1
  42. package/dist/ui/index.js +1 -1
  43. package/package.json +3 -3
  44. package/dist/chunk-65WT5PHA.cjs.map +0 -1
  45. package/dist/chunk-J3BYHBKW.js.map +0 -1
  46. package/dist/chunk-KLPY2HUC.cjs.map +0 -1
  47. package/dist/chunk-MFMJHBJR.js.map +0 -1
  48. package/dist/chunk-YIFUMQGA.cjs.map +0 -1
@@ -6,7 +6,7 @@ import * as React from 'react';
6
6
  import React__default, { createContext, forwardRef, memo, useContext, useState, useRef, useEffect, useCallback, useId, useMemo, Fragment as Fragment$1 } from 'react';
7
7
  import { createPortal } from 'react-dom';
8
8
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
9
- import { ChevronDown, ChevronUp, Check, Circle, Search, MessageCircleMore, Loader2, Square, Mic, MoreVertical, BadgeCheck, MessageSquareLock, Info, FileQuestion, BookOpen, Upload, LogOut, LayoutGrid, Bell, MessageSquare, CircleUserRound, Wrench, CreditCard, ClipboardList, UserPlus, UserStar, Settings2, Users, User, NotebookPen, NotebookText, Building2, Contact, Scale, Tags, StickyNote, FolderPlus, Hash, EyeOff, Eye, CaptionsOff, FolderOpen, MessageSquareMore, MessageSquarePlus, MessageSquareText, MessageSquareOff, MessagesSquare, Columns3Cog, SquarePlus, SquareM, ChevronsDown, Bot, Calendar, Folder, List, SquareCheckBig, Minus, Plus, Share2, MessageSquareShare, ChevronsUpDown, X, AlertTriangle, FileX, SkipForward, XCircle, CheckCircle } from 'lucide-react';
9
+ import { ChevronDown, ChevronUp, Check, Circle, Search, MessageCircleMore, Loader2, Square, Mic, MoreVertical, BadgeCheck, MessageSquareLock, Info, FileQuestion, BookOpen, Upload, LogOut, LayoutGrid, Bell, MessageSquare, CircleUserRound, Wrench, CreditCard, ClipboardList, UserPlus, UserStar, Settings2, Users, User, NotebookPen, NotebookText, Building2, Contact, Scale, Tags, StickyNote, FolderPlus, Hash, EyeOff, Eye, CaptionsOff, FolderOpen, MessageSquareMore, MessageSquarePlus, MessageSquareText, MessageSquareOff, MessagesSquare, Columns3Cog, SquarePlus, SquareM, ChevronsDown, Bot, Calendar, Folder, List, SquareCheckBig, Minus, Plus, Share2, CheckCircle2, MessageSquareShare, ChevronsUpDown, X, AlertTriangle, FileX, SkipForward, XCircle, CheckCircle } from 'lucide-react';
10
10
  import * as SelectPrimitive from '@radix-ui/react-select';
11
11
  import * as AvatarPrimitive from '@radix-ui/react-avatar';
12
12
  import { cva } from 'class-variance-authority';
@@ -295,6 +295,333 @@ function IconToggle({
295
295
  ] }) : button
296
296
  ] });
297
297
  }
298
+ var ENTITY_MAPPINGS = {
299
+ PRODUCT: {
300
+ NAMES: {
301
+ SINGULAR: "ARBI Docs"
302
+ },
303
+ ICONS: {
304
+ DEFAULT: MessageSquareLock
305
+ }
306
+ },
307
+ SECTION: {
308
+ NAMES: {
309
+ SINGULAR: "Section"
310
+ },
311
+ ICONS: {
312
+ DEFAULT: ChevronsDown
313
+ }
314
+ },
315
+ WORKSPACE: {
316
+ NAMES: {
317
+ SINGULAR: "Workspace",
318
+ PLURAL: "Workspaces"
319
+ },
320
+ ICONS: {
321
+ DEFAULT: SquareM,
322
+ NEW: SquarePlus,
323
+ LIST: LayoutGrid,
324
+ SETTINGS: Columns3Cog
325
+ }
326
+ },
327
+ CONVERSATION: {
328
+ NAMES: {
329
+ SINGULAR: "Thread",
330
+ PLURAL: "Threads",
331
+ NEW: "New Thread"
332
+ },
333
+ ICONS: {
334
+ DEFAULT: MessagesSquare,
335
+ OFF: MessageSquareOff,
336
+ ACTIVE: MessageSquareText,
337
+ NEW: MessageSquarePlus,
338
+ LIST: MessageSquareMore
339
+ }
340
+ },
341
+ DOCUMENT: {
342
+ NAMES: {
343
+ SINGULAR: "File",
344
+ PLURAL: "Files"
345
+ },
346
+ ICONS: {
347
+ DEFAULT: FolderOpen,
348
+ OFF: CaptionsOff
349
+ }
350
+ },
351
+ VIEWER: {
352
+ NAMES: {
353
+ SINGULAR: "Viewer",
354
+ PLURAL: "Viewers"
355
+ },
356
+ ICONS: {
357
+ DEFAULT: Eye,
358
+ OFF: EyeOff
359
+ }
360
+ },
361
+ TAG: {
362
+ NAMES: {
363
+ SINGULAR: "Field",
364
+ PLURAL: "Fields"
365
+ },
366
+ ICONS: {
367
+ DEFAULT: Hash,
368
+ NEW: FolderPlus
369
+ }
370
+ },
371
+ ANNOTATION: {
372
+ NAMES: {
373
+ SINGULAR: "Annotation",
374
+ PLURAL: "Annotations"
375
+ },
376
+ ICONS: {
377
+ DEFAULT: StickyNote,
378
+ NEW: StickyNote
379
+ }
380
+ },
381
+ // A tag of any kind — what the Tags page lists. TAG stays "Field": the Files page's custom
382
+ // columns (labels and annotations as document fields) are named after it.
383
+ ANY_TAG: {
384
+ NAMES: {
385
+ SINGULAR: "Tag",
386
+ PLURAL: "Tags"
387
+ },
388
+ ICONS: {
389
+ DEFAULT: Tags
390
+ }
391
+ },
392
+ // The kinds of TAG (a tag's `kind`): a label files things; an issue is a point in dispute; a
393
+ // person and an organisation are entities the documents name; a saved search is a stored query.
394
+ LABEL: {
395
+ NAMES: {
396
+ SINGULAR: "Label",
397
+ PLURAL: "Labels"
398
+ },
399
+ ICONS: {
400
+ DEFAULT: Tags
401
+ }
402
+ },
403
+ ISSUE: {
404
+ NAMES: {
405
+ SINGULAR: "Issue",
406
+ PLURAL: "Issues"
407
+ },
408
+ ICONS: {
409
+ DEFAULT: Scale
410
+ }
411
+ },
412
+ PERSON: {
413
+ NAMES: {
414
+ SINGULAR: "Person",
415
+ PLURAL: "People"
416
+ },
417
+ ICONS: {
418
+ DEFAULT: Contact
419
+ }
420
+ },
421
+ ORGANISATION: {
422
+ NAMES: {
423
+ SINGULAR: "Organisation",
424
+ PLURAL: "Organisations"
425
+ },
426
+ ICONS: {
427
+ DEFAULT: Building2
428
+ }
429
+ },
430
+ SAVED_SEARCH: {
431
+ NAMES: {
432
+ SINGULAR: "Saved search",
433
+ PLURAL: "Saved searches"
434
+ },
435
+ ICONS: {
436
+ DEFAULT: Search
437
+ }
438
+ },
439
+ // A statement the workspace knows — a date, a decision, a preference — written by hand or kept by
440
+ // the assistant, optionally grounded in source passages (`facts`, fct-*). Distinct from
441
+ // ANNOTATION, a value attached TO a document; a fact is workspace-scoped and stands alone.
442
+ FACT: {
443
+ NAMES: {
444
+ SINGULAR: "Fact",
445
+ PLURAL: "Facts"
446
+ },
447
+ ICONS: {
448
+ DEFAULT: NotebookText,
449
+ NEW: NotebookPen
450
+ }
451
+ },
452
+ USER: {
453
+ NAMES: {
454
+ SINGULAR: "User",
455
+ PLURAL: "Users"
456
+ },
457
+ ICONS: {
458
+ DEFAULT: User,
459
+ NEW: UserPlus,
460
+ SETTINGS: Settings2
461
+ }
462
+ },
463
+ WORKSPACEUSER: {
464
+ NAMES: {
465
+ SINGULAR: "Member",
466
+ PLURAL: "Members"
467
+ },
468
+ ICONS: {
469
+ DEFAULT: User,
470
+ PLURAL: Users,
471
+ NEW: UserPlus,
472
+ SETTINGS: Settings2
473
+ }
474
+ },
475
+ CONTACT: {
476
+ NAMES: {
477
+ SINGULAR: "Contact",
478
+ PLURAL: "Contacts"
479
+ },
480
+ ICONS: {
481
+ // A starred person, not an address-book card: contacts here are the
482
+ // people you talk to, and the star reads as "your people".
483
+ DEFAULT: UserStar,
484
+ NEW: UserPlus
485
+ }
486
+ },
487
+ TASK: {
488
+ NAMES: {
489
+ SINGULAR: "Job",
490
+ PLURAL: "Jobs"
491
+ },
492
+ ICONS: {
493
+ DEFAULT: ClipboardList
494
+ }
495
+ },
496
+ PROJECT: {
497
+ NAMES: {
498
+ SINGULAR: "Project",
499
+ PLURAL: "Projects"
500
+ },
501
+ ICONS: {
502
+ DEFAULT: CreditCard
503
+ }
504
+ },
505
+ SKILL: {
506
+ NAMES: {
507
+ SINGULAR: "Skill",
508
+ PLURAL: "Skills"
509
+ },
510
+ ICONS: {
511
+ DEFAULT: Wrench
512
+ }
513
+ },
514
+ ACCOUNT: {
515
+ NAMES: {
516
+ SINGULAR: "Account"
517
+ },
518
+ ICONS: {
519
+ DEFAULT: CircleUserRound
520
+ }
521
+ },
522
+ NOTIFICATIONS: {
523
+ NAMES: {
524
+ SINGULAR: "Activity",
525
+ PLURAL: "Activities"
526
+ },
527
+ ICONS: {
528
+ DEFAULT: Bell
529
+ }
530
+ },
531
+ MESSAGE: {
532
+ NAMES: {
533
+ SINGULAR: "Message",
534
+ PLURAL: "Messages"
535
+ },
536
+ ICONS: {
537
+ DEFAULT: MessageSquare
538
+ }
539
+ },
540
+ NOTIFICATION: {
541
+ NAMES: {
542
+ SINGULAR: "Notification",
543
+ PLURAL: "Notifications"
544
+ },
545
+ ICONS: {
546
+ DEFAULT: Bell
547
+ }
548
+ },
549
+ APP: {
550
+ NAMES: {
551
+ SINGULAR: "Application",
552
+ PLURAL: "Applications"
553
+ },
554
+ ICONS: {
555
+ DEFAULT: LayoutGrid,
556
+ HOME: LayoutGrid,
557
+ LOGOUT: LogOut,
558
+ UPLOAD: Upload
559
+ }
560
+ },
561
+ HELP: {
562
+ NAMES: {
563
+ SINGULAR: "Help",
564
+ PLURAL: "Help"
565
+ },
566
+ ICONS: {
567
+ DEFAULT: MessageSquareLock,
568
+ DOCS: BookOpen,
569
+ FAQ: FileQuestion,
570
+ ABOUT: Info
571
+ }
572
+ },
573
+ USERSHIELD: {
574
+ NAMES: {
575
+ SINGULAR: "User Shield",
576
+ PLURAL: "User Shields"
577
+ },
578
+ ICONS: {
579
+ DEFAULT: MessageSquareLock
580
+ }
581
+ }
582
+ };
583
+ function configureEntityRegistry(overrides) {
584
+ for (const [type, def] of Object.entries(overrides)) {
585
+ const target = ENTITY_MAPPINGS[type];
586
+ if (!target) continue;
587
+ if (def?.NAMES) Object.assign(target.NAMES, def.NAMES);
588
+ if (def?.ICONS) Object.assign(target.ICONS, def.ICONS);
589
+ }
590
+ }
591
+ var getEntityIcon = (entityType, variant = "DEFAULT") => {
592
+ const icons = ENTITY_MAPPINGS[entityType]?.ICONS;
593
+ return icons?.[variant] || icons?.DEFAULT;
594
+ };
595
+ var getEntityLabel = (entityType, form = "SINGULAR") => {
596
+ const entityMapping = ENTITY_MAPPINGS[entityType];
597
+ if (!entityMapping) return "";
598
+ const names = entityMapping.NAMES;
599
+ const singularName = names.SINGULAR || "";
600
+ if (form === "NEW") return names.NEW !== void 0 ? names.NEW : "New " + singularName;
601
+ if (form === "SHORT")
602
+ return names.SHORT !== void 0 ? names.SHORT : singularName.substring(0, 3) + ".";
603
+ if (form === "PLURAL") return names.PLURAL !== void 0 ? names.PLURAL : singularName + "s";
604
+ return singularName;
605
+ };
606
+ var EntityIcon = ({ entityType, variant = "DEFAULT", ...props }) => {
607
+ const IconComponent = getEntityIcon(entityType, variant);
608
+ return IconComponent ? React__default.createElement(IconComponent, props) : null;
609
+ };
610
+ var VISIBILITY_ICONS = {
611
+ PRIVATE: MessageSquareLock,
612
+ SHARED: Users
613
+ };
614
+ var VisibilityIcon = ({
615
+ isShared,
616
+ className,
617
+ ...props
618
+ }) => {
619
+ const IconComponent = isShared ? VISIBILITY_ICONS.SHARED : VISIBILITY_ICONS.PRIVATE;
620
+ return React__default.createElement(IconComponent, {
621
+ ...props,
622
+ className: [isShared ? "text-secondary" : "text-primary", className].filter(Boolean).join(" ")
623
+ });
624
+ };
298
625
  var Select = SelectPrimitive.Root;
299
626
  var SelectGroup = SelectPrimitive.Group;
300
627
  var SelectValue = SelectPrimitive.Value;
@@ -424,7 +751,7 @@ function VisibilityToggle({
424
751
  tooltipInactive,
425
752
  tooltipMixed,
426
753
  label = "Visibility",
427
- workspaceLabel = "workspace",
754
+ workspaceLabel = getEntityLabel("WORKSPACE"),
428
755
  "data-testid": dataTestId
429
756
  }) {
430
757
  const itemsArray = useMemo(() => Array.isArray(items) ? items : [items], [items]);
@@ -497,6 +824,75 @@ function VisibilityToggle({
497
824
  }
498
825
  );
499
826
  }
827
+ var COLORS2 = {
828
+ text: "text-green-text",
829
+ bg: "bg-green-text"
830
+ };
831
+ function VerifiedToggle({
832
+ verified,
833
+ onToggle,
834
+ disabled = false,
835
+ showLabel = true,
836
+ showTooltip = true,
837
+ tooltipActive,
838
+ tooltipInactive,
839
+ "data-testid": dataTestId
840
+ }) {
841
+ return /* @__PURE__ */ jsx(
842
+ IconToggle,
843
+ {
844
+ icon: CheckCircle2,
845
+ isActive: verified,
846
+ onToggle,
847
+ colors: COLORS2,
848
+ disabled,
849
+ showLabel,
850
+ label: "Verified",
851
+ showTooltip,
852
+ tooltipActive: tooltipActive || "Verified by a human \u2014 click to unverify",
853
+ tooltipInactive: tooltipInactive || "Not verified \u2014 click to verify",
854
+ "data-testid": dataTestId
855
+ }
856
+ );
857
+ }
858
+
859
+ // src/lib/format-friendly-date.ts
860
+ function formatFriendlyDate(dateString, includeTime = true) {
861
+ if (!dateString) return "";
862
+ try {
863
+ if (dateString.includes("Today") || dateString.includes("Yesterday") || /\w+ \d+, \d+:\d+:\d+/.test(dateString)) {
864
+ return dateString;
865
+ }
866
+ if (/^\d{1,2}:\d{2}(:\d{2})?$/.test(dateString)) {
867
+ return dateString;
868
+ }
869
+ const date = new Date(dateString);
870
+ if (isNaN(date.getTime())) return dateString;
871
+ const timeOptions = { hour: "2-digit", minute: "2-digit" };
872
+ const timeString = date.toLocaleTimeString([], timeOptions);
873
+ const now = /* @__PURE__ */ new Date();
874
+ const today = now.toDateString();
875
+ const yesterday = new Date(now);
876
+ yesterday.setDate(yesterday.getDate() - 1);
877
+ if (date.toDateString() === today) {
878
+ return includeTime ? `Today, ${timeString}` : "today";
879
+ } else if (date.toDateString() === yesterday.toDateString()) {
880
+ return includeTime ? `Yesterday, ${timeString}` : "yesterday";
881
+ } else {
882
+ const dateOptions = {
883
+ month: "short",
884
+ day: "numeric"
885
+ };
886
+ if (date.getFullYear() !== now.getFullYear()) {
887
+ dateOptions.year = "numeric";
888
+ }
889
+ const formattedDate = date.toLocaleDateString([], dateOptions);
890
+ return includeTime ? `${formattedDate}, ${timeString}` : formattedDate;
891
+ }
892
+ } catch {
893
+ return dateString;
894
+ }
895
+ }
500
896
 
501
897
  // src/documents/media-error.ts
502
898
  function classifyMediaError(err, kind) {
@@ -2050,601 +2446,251 @@ function MarkMenu({
2050
2446
  else openWith("press");
2051
2447
  return;
2052
2448
  }
2053
- if (shouldClickRunPrimary && primary?.onSelect) {
2054
- e.preventDefault();
2055
- close();
2056
- primary.onSelect();
2057
- }
2058
- };
2059
- const handleMenuKeyDown = (e) => {
2060
- const list = rows();
2061
- const index = list.indexOf(document.activeElement);
2062
- let target;
2063
- if (e.key === "ArrowDown") target = list[(index + 1) % list.length];
2064
- else if (e.key === "ArrowUp") target = list[(index - 1 + list.length) % list.length];
2065
- else if (e.key === "Home") target = list[0];
2066
- else if (e.key === "End") target = list[list.length - 1];
2067
- else if (e.key === "Escape") {
2068
- e.preventDefault();
2069
- e.stopPropagation();
2070
- close(true);
2071
- return;
2072
- } else if (e.key === "Tab") {
2073
- close();
2074
- return;
2075
- }
2076
- if (target) {
2077
- e.preventDefault();
2078
- target.focus();
2079
- }
2080
- };
2081
- const choose = (item) => {
2082
- const wasKey = mode.current === "key";
2083
- close(wasKey);
2084
- item.onSelect?.();
2085
- };
2086
- const setTriggerRef = useCallback(
2087
- (el) => {
2088
- triggerRef.current = el;
2089
- if (typeof externalRef === "function") externalRef(el);
2090
- else if (externalRef) externalRef.current = el;
2091
- },
2092
- [externalRef]
2093
- );
2094
- const triggerProps = {
2095
- ref: setTriggerRef,
2096
- className,
2097
- "data-testid": testId,
2098
- "data-slot": "mark",
2099
- "aria-haspopup": "true",
2100
- "aria-expanded": open,
2101
- "aria-controls": open ? menuId : void 0,
2102
- onPointerDown: handlePointerDown,
2103
- onPointerEnter: handlePointerEnter,
2104
- onPointerMove: handlePointerMove,
2105
- onPointerLeave: handlePointerLeave,
2106
- onFocus: handleFocus,
2107
- onBlur: handleBlur,
2108
- onKeyDown: handleKeyDown,
2109
- onClick: handleClick,
2110
- ...rest
2111
- };
2112
- return /* @__PURE__ */ jsxs(Popover, { open: open && !isEmpty, children: [
2113
- /* @__PURE__ */ jsx(PopoverAnchor, { asChild: true, children: as === "a" ? /* @__PURE__ */ jsx("a", { href, ...triggerProps, children }) : /* @__PURE__ */ jsx("span", { role: "button", tabIndex: 0, ...triggerProps, children }) }),
2114
- /* @__PURE__ */ jsxs(
2115
- PopoverContent,
2116
- {
2117
- ref: contentRef,
2118
- id: menuId,
2119
- side,
2120
- align: "start",
2121
- sideOffset: 6,
2122
- collisionPadding: 8,
2123
- role: "group",
2124
- "data-testid": menuTestId,
2125
- "data-slot": "mark-menu",
2126
- className: "w-auto min-w-[12rem] max-w-[min(22rem,calc(100vw-1rem))] p-1",
2127
- onOpenAutoFocus: (e) => {
2128
- e.preventDefault();
2129
- if (focusFirstOnOpen.current) firstItem()?.focus();
2130
- },
2131
- onCloseAutoFocus: (e) => e.preventDefault(),
2132
- onEscapeKeyDown: (e) => {
2133
- e.preventDefault();
2134
- close(true);
2135
- },
2136
- onInteractOutside: (e) => {
2137
- if (triggerRef.current?.contains(e.target)) e.preventDefault();
2138
- },
2139
- onPointerEnter: clearTimer,
2140
- onPointerLeave: (e) => {
2141
- if (!isCoarse(e.pointerType) && mode.current === "hover")
2142
- schedule(() => close(), closeDelay);
2143
- },
2144
- children: [
2145
- preview && /* @__PURE__ */ jsx("div", { className: "px-2 py-1.5 text-sm", children: preview }),
2146
- ordered.length > 0 && /* @__PURE__ */ jsx("div", { role: "menu", "aria-label": menuLabel, onKeyDown: handleMenuKeyDown, children: ordered.map((item) => {
2147
- const rowClass = cn(
2148
- "flex w-full cursor-pointer items-center rounded-sm px-2 py-1.5 text-left text-sm outline-none transition-colors hover:bg-accent focus-visible:bg-accent pointer-coarse:min-h-11 pointer-coarse:px-3",
2149
- item.primary && "font-medium pointer-coarse:text-base",
2150
- item.destructive && "text-destructive"
2151
- );
2152
- return item.href && !item.onSelect ? /* @__PURE__ */ jsx(
2153
- "a",
2154
- {
2155
- role: "menuitem",
2156
- tabIndex: -1,
2157
- href: item.href,
2158
- className: rowClass,
2159
- "data-testid": item.testId,
2160
- onClick: () => close(),
2161
- children: item.label
2162
- },
2163
- item.id
2164
- ) : /* @__PURE__ */ jsx(
2165
- "button",
2166
- {
2167
- type: "button",
2168
- role: "menuitem",
2169
- tabIndex: -1,
2170
- className: rowClass,
2171
- "data-testid": item.testId,
2172
- onClick: () => choose(item),
2173
- children: item.label
2174
- },
2175
- item.id
2176
- );
2177
- }) })
2178
- ]
2179
- }
2180
- )
2181
- ] });
2182
- }
2183
- var Command = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
2184
- Command$1,
2185
- {
2186
- ref,
2187
- className: cn(
2188
- "flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",
2189
- className
2190
- ),
2191
- ...props
2192
- }
2193
- ));
2194
- Command.displayName = Command$1.displayName;
2195
- var CommandDialog = ({ children, ...props }) => {
2196
- return /* @__PURE__ */ jsx(Dialog, { ...props, children: /* @__PURE__ */ jsx(DialogContent, { className: "overflow-hidden p-0", children: /* @__PURE__ */ jsx(Command, { className: "[&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-group]]:px-2 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 [&_[cmdk-input]]:h-12 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-3 [&_[cmdk-item]_svg]:h-5 [&_[cmdk-item]_svg]:w-5", children }) }) });
2197
- };
2198
- var CommandInput = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxs("div", { className: "flex items-center border-b px-3", "data-cmdk-input-wrapper": "", children: [
2199
- /* @__PURE__ */ jsx(Search, { className: "mr-2 h-4 w-4 shrink-0 opacity-50" }),
2200
- /* @__PURE__ */ jsx(
2201
- Command$1.Input,
2202
- {
2203
- ref,
2204
- className: cn(
2205
- "flex h-10 pointer-coarse:h-11 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",
2206
- className
2207
- ),
2208
- ...props
2209
- }
2210
- )
2211
- ] }));
2212
- CommandInput.displayName = Command$1.Input.displayName;
2213
- var CommandList = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
2214
- Command$1.List,
2215
- {
2216
- ref,
2217
- className: cn("max-h-[min(300px,50dvh)] overflow-y-auto overflow-x-hidden", className),
2218
- ...props
2219
- }
2220
- ));
2221
- CommandList.displayName = Command$1.List.displayName;
2222
- var CommandEmpty = React.forwardRef((props, ref) => /* @__PURE__ */ jsx(Command$1.Empty, { ref, className: "py-6 text-center text-sm", ...props }));
2223
- CommandEmpty.displayName = Command$1.Empty.displayName;
2224
- var CommandGroup = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
2225
- Command$1.Group,
2226
- {
2227
- ref,
2228
- className: cn(
2229
- "overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-sm [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",
2230
- className
2231
- ),
2232
- ...props
2233
- }
2234
- ));
2235
- CommandGroup.displayName = Command$1.Group.displayName;
2236
- var CommandSeparator = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
2237
- Command$1.Separator,
2238
- {
2239
- ref,
2240
- className: cn("-mx-1 h-px bg-border", className),
2241
- ...props
2242
- }
2243
- ));
2244
- CommandSeparator.displayName = Command$1.Separator.displayName;
2245
- var CommandItem = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
2246
- Command$1.Item,
2247
- {
2248
- ref,
2249
- className: cn(
2250
- "relative flex cursor-default gap-2 select-none items-center rounded-sm px-2 py-1.5 pointer-coarse:min-h-11 text-sm outline-none data-[disabled=true]:pointer-events-none data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",
2251
- className
2252
- ),
2253
- ...props
2254
- }
2255
- ));
2256
- CommandItem.displayName = Command$1.Item.displayName;
2257
- var CommandShortcut = ({ className, ...props }) => {
2258
- return /* @__PURE__ */ jsx(
2259
- "span",
2260
- {
2261
- className: cn("ml-auto text-sm tracking-widest text-muted-foreground", className),
2262
- ...props
2263
- }
2264
- );
2265
- };
2266
- CommandShortcut.displayName = "CommandShortcut";
2267
- var AI_COMPONENTS = {
2268
- a: (p) => /* @__PURE__ */ jsx(
2269
- "a",
2270
- {
2271
- className: "text-ai-accent underline underline-offset-2",
2272
- target: "_blank",
2273
- rel: "noopener noreferrer",
2274
- ...p
2449
+ if (shouldClickRunPrimary && primary?.onSelect) {
2450
+ e.preventDefault();
2451
+ close();
2452
+ primary.onSelect();
2275
2453
  }
2276
- ),
2277
- // Redline marks: deletions in red strike, <ins>/<mark> additions accented.
2278
- del: (p) => /* @__PURE__ */ jsx("del", { className: "rounded bg-destructive/10 text-destructive decoration-destructive/60", ...p }),
2279
- ins: (p) => /* @__PURE__ */ jsx("ins", { className: "rounded bg-ai-accent-soft px-0.5 text-ai-accent no-underline", ...p }),
2280
- mark: (p) => /* @__PURE__ */ jsx("mark", { className: "rounded bg-ai-accent-soft px-0.5 text-ai-accent", ...p }),
2281
- thead: (p) => /* @__PURE__ */ jsx("thead", { className: "bg-secondary/60", ...p })
2282
- };
2283
- function AiMarkdown({
2284
- children,
2285
- className,
2286
- isStreaming,
2287
- allowHtml
2288
- }) {
2289
- return /* @__PURE__ */ jsx(
2290
- MarkdownRenderer,
2291
- {
2292
- className: className ?? "text-sm",
2293
- components: AI_COMPONENTS,
2294
- isStreaming,
2295
- allowHtml,
2296
- testId: "ai-markdown",
2297
- children
2454
+ };
2455
+ const handleMenuKeyDown = (e) => {
2456
+ const list = rows();
2457
+ const index = list.indexOf(document.activeElement);
2458
+ let target;
2459
+ if (e.key === "ArrowDown") target = list[(index + 1) % list.length];
2460
+ else if (e.key === "ArrowUp") target = list[(index - 1 + list.length) % list.length];
2461
+ else if (e.key === "Home") target = list[0];
2462
+ else if (e.key === "End") target = list[list.length - 1];
2463
+ else if (e.key === "Escape") {
2464
+ e.preventDefault();
2465
+ e.stopPropagation();
2466
+ close(true);
2467
+ return;
2468
+ } else if (e.key === "Tab") {
2469
+ close();
2470
+ return;
2298
2471
  }
2472
+ if (target) {
2473
+ e.preventDefault();
2474
+ target.focus();
2475
+ }
2476
+ };
2477
+ const choose = (item) => {
2478
+ const wasKey = mode.current === "key";
2479
+ close(wasKey);
2480
+ item.onSelect?.();
2481
+ };
2482
+ const setTriggerRef = useCallback(
2483
+ (el) => {
2484
+ triggerRef.current = el;
2485
+ if (typeof externalRef === "function") externalRef(el);
2486
+ else if (externalRef) externalRef.current = el;
2487
+ },
2488
+ [externalRef]
2299
2489
  );
2300
- }
2301
- var EntityPill = forwardRef(function EntityPill2({
2302
- icon,
2303
- label,
2304
- secondaryText,
2305
- size = "sm",
2306
- shape = "rounded",
2307
- className,
2308
- labelMaxWidth = "max-w-[320px]",
2309
- labelClassName,
2310
- fullWidth = false,
2311
- highlight = false,
2312
- onClick,
2313
- onIconClick,
2314
- onMoreClick,
2315
- moreContent,
2316
- href,
2317
- disabled = false,
2318
- tooltipContent,
2319
- tooltipSide = "bottom",
2320
- "data-testid": testId
2321
- }, ref) {
2322
- const shapeClass = shape === "pill" ? "rounded-full" : "rounded-md";
2323
- const sizeClasses2 = size === "base" ? "gap-1.5 px-1.5 py-0.5" : "gap-1 px-1";
2324
- const textSizeClass = size === "base" ? "text-base" : "text-sm";
2325
- const baseClasses = cn(
2326
- "group/pill items-center",
2327
- fullWidth ? "flex w-full" : "inline-flex",
2328
- sizeClasses2,
2329
- shapeClass,
2330
- "border border-transparent",
2331
- "transition-colors",
2332
- className
2333
- );
2334
- const interactiveClasses = "relative cursor-pointer hover:bg-muted pointer-coarse:after:absolute pointer-coarse:after:inset-x-0 pointer-coarse:after:-inset-y-3 pointer-coarse:after:content-['']";
2335
- const disabledClasses = "cursor-default opacity-60";
2336
- const highlightClasses = "bg-primary text-primary-foreground hover:bg-primary hover:text-primary-foreground";
2337
- const mainContent = /* @__PURE__ */ jsxs(Fragment, { children: [
2338
- onIconClick ? /* @__PURE__ */ jsx(
2339
- "span",
2490
+ const triggerProps = {
2491
+ ref: setTriggerRef,
2492
+ className,
2493
+ "data-testid": testId,
2494
+ "data-slot": "mark",
2495
+ "aria-haspopup": "true",
2496
+ "aria-expanded": open,
2497
+ "aria-controls": open ? menuId : void 0,
2498
+ onPointerDown: handlePointerDown,
2499
+ onPointerEnter: handlePointerEnter,
2500
+ onPointerMove: handlePointerMove,
2501
+ onPointerLeave: handlePointerLeave,
2502
+ onFocus: handleFocus,
2503
+ onBlur: handleBlur,
2504
+ onKeyDown: handleKeyDown,
2505
+ onClick: handleClick,
2506
+ ...rest
2507
+ };
2508
+ return /* @__PURE__ */ jsxs(Popover, { open: open && !isEmpty, children: [
2509
+ /* @__PURE__ */ jsx(PopoverAnchor, { asChild: true, children: as === "a" ? /* @__PURE__ */ jsx("a", { href, ...triggerProps, children }) : /* @__PURE__ */ jsx("span", { role: "button", tabIndex: 0, ...triggerProps, children }) }),
2510
+ /* @__PURE__ */ jsxs(
2511
+ PopoverContent,
2340
2512
  {
2341
- role: "button",
2342
- tabIndex: 0,
2343
- className: "flex-shrink-0 cursor-pointer hover:opacity-70 transition-opacity",
2344
- onClick: (e) => {
2345
- e.stopPropagation();
2346
- onIconClick(e);
2513
+ ref: contentRef,
2514
+ id: menuId,
2515
+ side,
2516
+ align: "start",
2517
+ sideOffset: 6,
2518
+ collisionPadding: 8,
2519
+ role: "group",
2520
+ "data-testid": menuTestId,
2521
+ "data-slot": "mark-menu",
2522
+ className: "w-auto min-w-[12rem] max-w-[min(22rem,calc(100vw-1rem))] p-1",
2523
+ onOpenAutoFocus: (e) => {
2524
+ e.preventDefault();
2525
+ if (focusFirstOnOpen.current) firstItem()?.focus();
2526
+ },
2527
+ onCloseAutoFocus: (e) => e.preventDefault(),
2528
+ onEscapeKeyDown: (e) => {
2529
+ e.preventDefault();
2530
+ close(true);
2531
+ },
2532
+ onInteractOutside: (e) => {
2533
+ if (triggerRef.current?.contains(e.target)) e.preventDefault();
2534
+ },
2535
+ onPointerEnter: clearTimer,
2536
+ onPointerLeave: (e) => {
2537
+ if (!isCoarse(e.pointerType) && mode.current === "hover")
2538
+ schedule(() => close(), closeDelay);
2347
2539
  },
2348
- children: icon
2349
- }
2350
- ) : icon,
2351
- /* @__PURE__ */ jsx(
2352
- "span",
2353
- {
2354
- className: cn(
2355
- textSizeClass,
2356
- "font-medium truncate leading-tight min-w-0",
2357
- labelMaxWidth,
2358
- labelClassName
2359
- ),
2360
- children: label
2361
- }
2362
- ),
2363
- secondaryText && /* @__PURE__ */ jsx("span", { className: "text-xs text-muted-foreground flex-shrink-0 leading-none", children: secondaryText })
2364
- ] });
2365
- const tooltipWrap = (content, tip, side = tooltipSide, triggerClassName, triggerProps) => /* @__PURE__ */ jsxs(Tooltip, { children: [
2366
- /* @__PURE__ */ jsx(
2367
- TooltipTrigger,
2368
- {
2369
- onFocusCapture: (e) => e.stopPropagation(),
2370
- className: triggerClassName,
2371
- ...triggerProps,
2372
- children: content
2373
- }
2374
- ),
2375
- /* @__PURE__ */ jsx(TooltipContent, { side, className: "p-2", children: tip })
2376
- ] });
2377
- const mainAreaClass = cn("inline-flex items-center gap-1", fullWidth && "min-w-0 flex-1");
2378
- const mainAreaTouchClass = cn(
2379
- mainAreaClass,
2380
- (onClick || href) && !disabled && "relative pointer-coarse:after:absolute pointer-coarse:after:inset-x-0 pointer-coarse:after:-inset-y-3 pointer-coarse:after:content-['']"
2381
- );
2382
- if (onMoreClick || moreContent) {
2383
- let mainArea;
2384
- if (tooltipContent) {
2385
- mainArea = tooltipWrap(
2386
- mainContent,
2387
- tooltipContent,
2388
- tooltipSide,
2389
- cn(mainAreaTouchClass, disabled && "opacity-60"),
2390
- {
2391
- type: "button",
2392
- onClick: href ? onClick : disabled ? void 0 : onClick,
2393
- disabled: disabled || void 0
2394
- }
2395
- );
2396
- } else if (href) {
2397
- mainArea = /* @__PURE__ */ jsx(
2398
- "a",
2399
- {
2400
- href,
2401
- target: "_blank",
2402
- rel: "noopener noreferrer",
2403
- className: mainAreaTouchClass,
2404
- onClick,
2405
- children: mainContent
2406
- }
2407
- );
2408
- } else if (onClick) {
2409
- mainArea = /* @__PURE__ */ jsx(
2410
- "button",
2411
- {
2412
- type: "button",
2413
- onClick: disabled ? void 0 : onClick,
2414
- disabled,
2415
- className: cn(
2416
- "relative inline-flex items-center gap-1 pointer-coarse:after:absolute pointer-coarse:after:inset-x-0 pointer-coarse:after:-inset-y-3 pointer-coarse:after:content-['']",
2417
- disabled && "opacity-60"
2418
- ),
2419
- children: mainContent
2420
- }
2421
- );
2422
- } else {
2423
- mainArea = /* @__PURE__ */ jsx("span", { className: mainAreaTouchClass, children: mainContent });
2424
- }
2425
- const moreArea = moreContent ? /* @__PURE__ */ jsx("span", { className: "flex-shrink-0 leading-none", children: moreContent }) : tooltipWrap(
2426
- /* @__PURE__ */ jsx(MoreVertical, { className: "w-3.5 h-3.5" }),
2427
- "Click for more",
2428
- tooltipSide,
2429
- "flex-shrink-0 leading-none text-muted-foreground hover:text-foreground",
2430
- {
2431
- type: "button",
2432
- onClick: (e) => {
2433
- e.stopPropagation();
2434
- onMoreClick?.(e);
2435
- }
2436
- }
2437
- );
2438
- return /* @__PURE__ */ jsxs(
2439
- "span",
2440
- {
2441
- ref,
2442
- className: cn(
2443
- baseClasses,
2444
- (onClick || href) && !disabled && "cursor-pointer hover:bg-muted",
2445
- highlight && highlightClasses
2446
- ),
2447
- "data-testid": testId,
2448
2540
  children: [
2449
- mainArea,
2450
- moreArea
2541
+ preview && /* @__PURE__ */ jsx("div", { className: "px-2 py-1.5 text-sm", children: preview }),
2542
+ ordered.length > 0 && /* @__PURE__ */ jsx("div", { role: "menu", "aria-label": menuLabel, onKeyDown: handleMenuKeyDown, children: ordered.map((item) => {
2543
+ const rowClass = cn(
2544
+ "flex w-full cursor-pointer items-center rounded-sm px-2 py-1.5 text-left text-sm outline-none transition-colors hover:bg-accent focus-visible:bg-accent pointer-coarse:min-h-11 pointer-coarse:px-3",
2545
+ item.primary && "font-medium pointer-coarse:text-base",
2546
+ item.destructive && "text-destructive"
2547
+ );
2548
+ return item.href && !item.onSelect ? /* @__PURE__ */ jsx(
2549
+ "a",
2550
+ {
2551
+ role: "menuitem",
2552
+ tabIndex: -1,
2553
+ href: item.href,
2554
+ className: rowClass,
2555
+ "data-testid": item.testId,
2556
+ onClick: () => close(),
2557
+ children: item.label
2558
+ },
2559
+ item.id
2560
+ ) : /* @__PURE__ */ jsx(
2561
+ "button",
2562
+ {
2563
+ type: "button",
2564
+ role: "menuitem",
2565
+ tabIndex: -1,
2566
+ className: rowClass,
2567
+ "data-testid": item.testId,
2568
+ onClick: () => choose(item),
2569
+ children: item.label
2570
+ },
2571
+ item.id
2572
+ );
2573
+ }) })
2451
2574
  ]
2452
2575
  }
2453
- );
2576
+ )
2577
+ ] });
2578
+ }
2579
+ var Command = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
2580
+ Command$1,
2581
+ {
2582
+ ref,
2583
+ className: cn(
2584
+ "flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",
2585
+ className
2586
+ ),
2587
+ ...props
2454
2588
  }
2455
- if (tooltipContent) {
2456
- if (href) {
2457
- return tooltipWrap(
2458
- /* @__PURE__ */ jsx(
2459
- "a",
2460
- {
2461
- href,
2462
- target: "_blank",
2463
- rel: "noopener noreferrer",
2464
- className: mainAreaClass,
2465
- onClick,
2466
- children: mainContent
2467
- }
2468
- ),
2469
- tooltipContent,
2470
- tooltipSide,
2471
- cn(baseClasses, interactiveClasses),
2472
- { "data-testid": testId }
2473
- );
2474
- }
2475
- return tooltipWrap(
2476
- mainContent,
2477
- tooltipContent,
2478
- tooltipSide,
2479
- cn(
2480
- baseClasses,
2481
- onClick && !disabled ? interactiveClasses : "",
2482
- disabled ? disabledClasses : "",
2483
- highlight && highlightClasses
2589
+ ));
2590
+ Command.displayName = Command$1.displayName;
2591
+ var CommandDialog = ({ children, ...props }) => {
2592
+ return /* @__PURE__ */ jsx(Dialog, { ...props, children: /* @__PURE__ */ jsx(DialogContent, { className: "overflow-hidden p-0", children: /* @__PURE__ */ jsx(Command, { className: "[&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-group]]:px-2 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 [&_[cmdk-input]]:h-12 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-3 [&_[cmdk-item]_svg]:h-5 [&_[cmdk-item]_svg]:w-5", children }) }) });
2593
+ };
2594
+ var CommandInput = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxs("div", { className: "flex items-center border-b px-3", "data-cmdk-input-wrapper": "", children: [
2595
+ /* @__PURE__ */ jsx(Search, { className: "mr-2 h-4 w-4 shrink-0 opacity-50" }),
2596
+ /* @__PURE__ */ jsx(
2597
+ Command$1.Input,
2598
+ {
2599
+ ref,
2600
+ className: cn(
2601
+ "flex h-10 pointer-coarse:h-11 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",
2602
+ className
2484
2603
  ),
2485
- {
2486
- type: "button",
2487
- ref,
2488
- onClick: onClick && !disabled ? onClick : void 0,
2489
- disabled: disabled || void 0,
2490
- "data-testid": testId
2491
- }
2492
- );
2604
+ ...props
2605
+ }
2606
+ )
2607
+ ] }));
2608
+ CommandInput.displayName = Command$1.Input.displayName;
2609
+ var CommandList = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
2610
+ Command$1.List,
2611
+ {
2612
+ ref,
2613
+ className: cn("max-h-[min(300px,50dvh)] overflow-y-auto overflow-x-hidden", className),
2614
+ ...props
2493
2615
  }
2494
- if (href) {
2495
- return /* @__PURE__ */ jsx(
2496
- "a",
2497
- {
2498
- ref,
2499
- href,
2500
- target: "_blank",
2501
- rel: "noopener noreferrer",
2502
- className: cn(baseClasses, interactiveClasses),
2503
- "data-testid": testId,
2504
- onClick,
2505
- children: mainContent
2506
- }
2507
- );
2616
+ ));
2617
+ CommandList.displayName = Command$1.List.displayName;
2618
+ var CommandEmpty = React.forwardRef((props, ref) => /* @__PURE__ */ jsx(Command$1.Empty, { ref, className: "py-6 text-center text-sm", ...props }));
2619
+ CommandEmpty.displayName = Command$1.Empty.displayName;
2620
+ var CommandGroup = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
2621
+ Command$1.Group,
2622
+ {
2623
+ ref,
2624
+ className: cn(
2625
+ "overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-sm [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",
2626
+ className
2627
+ ),
2628
+ ...props
2508
2629
  }
2509
- if (onClick) {
2510
- return /* @__PURE__ */ jsx(
2511
- "button",
2512
- {
2513
- ref,
2514
- type: "button",
2515
- onClick: disabled ? void 0 : onClick,
2516
- disabled,
2517
- className: cn(
2518
- baseClasses,
2519
- disabled ? disabledClasses : interactiveClasses,
2520
- highlight && highlightClasses
2521
- ),
2522
- "data-testid": testId,
2523
- children: mainContent
2524
- }
2525
- );
2630
+ ));
2631
+ CommandGroup.displayName = Command$1.Group.displayName;
2632
+ var CommandSeparator = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
2633
+ Command$1.Separator,
2634
+ {
2635
+ ref,
2636
+ className: cn("-mx-1 h-px bg-border", className),
2637
+ ...props
2526
2638
  }
2639
+ ));
2640
+ CommandSeparator.displayName = Command$1.Separator.displayName;
2641
+ var CommandItem = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
2642
+ Command$1.Item,
2643
+ {
2644
+ ref,
2645
+ className: cn(
2646
+ "relative flex cursor-default gap-2 select-none items-center rounded-sm px-2 py-1.5 pointer-coarse:min-h-11 text-sm outline-none data-[disabled=true]:pointer-events-none data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",
2647
+ className
2648
+ ),
2649
+ ...props
2650
+ }
2651
+ ));
2652
+ CommandItem.displayName = Command$1.Item.displayName;
2653
+ var CommandShortcut = ({ className, ...props }) => {
2527
2654
  return /* @__PURE__ */ jsx(
2528
2655
  "span",
2529
2656
  {
2530
- ref,
2531
- className: cn(baseClasses, highlight && highlightClasses),
2532
- "data-testid": testId,
2533
- children: mainContent
2657
+ className: cn("ml-auto text-sm tracking-widest text-muted-foreground", className),
2658
+ ...props
2534
2659
  }
2535
2660
  );
2536
- });
2537
- var TAG_TYPE_LABELS = {
2538
- checkbox: "Checkbox",
2539
- select: "Select",
2540
- number: "Number",
2541
- text: "Text",
2542
- folder: "Folder",
2543
- search: "Saved Search",
2544
- date: "Date",
2545
- assistant: "AI Assistant"
2546
- };
2547
- var TAG_TYPE_ICONS = {
2548
- checkbox: SquareCheckBig,
2549
- select: List,
2550
- number: Hash,
2551
- text: NotebookPen,
2552
- folder: Folder,
2553
- search: Search,
2554
- date: Calendar,
2555
- assistant: Bot
2556
- };
2557
- function getTagTypeIcon(type) {
2558
- return TAG_TYPE_ICONS[type ?? "text"] || NotebookPen;
2559
- }
2560
- function getTagTypeLabel(type) {
2561
- const t = type ?? "text";
2562
- return TAG_TYPE_LABELS[t] || t;
2563
- }
2564
- var BASE_COLORS = {
2565
- "0": "#10b981",
2566
- "1": "#3b82f6",
2567
- "2": "#8b5cf6",
2568
- "3": "#f43f5e",
2569
- "4": "#f59e0b",
2570
- "5": "#84cc16",
2571
- "6": "#a855f7",
2572
- "7": "#06b6d4",
2573
- "8": "#f97316",
2574
- "9": "#14b8a6",
2575
- a: "#ef4444",
2576
- b: "#6366f1",
2577
- c: "#ec4899",
2578
- d: "#22c55e",
2579
- e: "#eab308",
2580
- f: "#0ea5e9"
2581
2661
  };
2582
- function getEntityColor(entityId) {
2583
- return BASE_COLORS[entityId[4]] || BASE_COLORS["0"];
2584
- }
2585
- function TagEntity({
2586
- tag,
2587
- size = "md",
2588
- className = "",
2589
- onClick,
2590
- showTooltip = true,
2591
- tooltipContent
2592
- }) {
2593
- const tagType = tag.tag_type?.type ?? "text";
2594
- const iconSize = size === "sm" ? 12 : size === "md" ? 14 : 16;
2595
- const Icon2 = getTagTypeIcon(tagType);
2596
- const sizeClasses2 = {
2597
- sm: "p-0.5",
2598
- md: "p-1",
2599
- lg: "p-1.5"
2600
- };
2601
- const tagColor = tag.color ?? getEntityColor(tag.external_id);
2602
- const iconElement = /* @__PURE__ */ jsx(
2603
- "span",
2662
+ CommandShortcut.displayName = "CommandShortcut";
2663
+ var AI_COMPONENTS = {
2664
+ a: (p) => /* @__PURE__ */ jsx(
2665
+ "a",
2604
2666
  {
2605
- className: `inline-flex items-center justify-center rounded-md text-white flex-shrink-0 ${sizeClasses2[size]}`,
2606
- style: { backgroundColor: tagColor },
2607
- children: /* @__PURE__ */ jsx(Icon2, { size: iconSize, className: "flex-shrink-0" })
2667
+ className: "text-ai-accent underline underline-offset-2",
2668
+ target: "_blank",
2669
+ rel: "noopener noreferrer",
2670
+ ...p
2608
2671
  }
2609
- );
2610
- const pillSize = size === "lg" ? "base" : "sm";
2611
- const defaultTooltip = /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2", children: [
2612
- /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
2613
- /* @__PURE__ */ jsx(
2614
- "span",
2615
- {
2616
- className: "inline-flex items-center justify-center rounded-md text-white p-1",
2617
- style: { backgroundColor: tagColor },
2618
- children: /* @__PURE__ */ jsx(Icon2, { size: 16 })
2619
- }
2620
- ),
2621
- /* @__PURE__ */ jsx("span", { className: "font-medium text-sm", children: tag.name })
2622
- ] }),
2623
- /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1.5 text-sm", children: [
2624
- /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
2625
- /* @__PURE__ */ jsx("span", { className: "text-muted-foreground", children: "Type:" }),
2626
- /* @__PURE__ */ jsx("span", { children: getTagTypeLabel(tagType) })
2627
- ] }),
2628
- tag.doctag_count != null && /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
2629
- /* @__PURE__ */ jsx("span", { className: "text-muted-foreground", children: "Documents:" }),
2630
- /* @__PURE__ */ jsx(Badge, { variant: "secondary", className: "h-5 min-w-[20px] justify-center", children: tag.doctag_count ?? 0 })
2631
- ] }),
2632
- tag.shared != null && /* @__PURE__ */ jsx("div", { className: "flex items-center gap-2", children: /* @__PURE__ */ jsx("span", { className: "text-muted-foreground", children: tag.shared ? "Shared" : "Private" }) })
2633
- ] })
2634
- ] });
2635
- const resolvedTooltip = showTooltip ? tooltipContent ?? defaultTooltip : void 0;
2672
+ ),
2673
+ // Redline marks: deletions in red strike, <ins>/<mark> additions accented.
2674
+ del: (p) => /* @__PURE__ */ jsx("del", { className: "rounded bg-destructive/10 text-destructive decoration-destructive/60", ...p }),
2675
+ ins: (p) => /* @__PURE__ */ jsx("ins", { className: "rounded bg-ai-accent-soft px-0.5 text-ai-accent no-underline", ...p }),
2676
+ mark: (p) => /* @__PURE__ */ jsx("mark", { className: "rounded bg-ai-accent-soft px-0.5 text-ai-accent", ...p }),
2677
+ thead: (p) => /* @__PURE__ */ jsx("thead", { className: "bg-secondary/60", ...p })
2678
+ };
2679
+ function AiMarkdown({
2680
+ children,
2681
+ className,
2682
+ isStreaming,
2683
+ allowHtml
2684
+ }) {
2636
2685
  return /* @__PURE__ */ jsx(
2637
- EntityPill,
2686
+ MarkdownRenderer,
2638
2687
  {
2639
- icon: iconElement,
2640
- label: tag.name,
2641
- size: pillSize,
2642
- shape: "rounded",
2643
- labelMaxWidth: "max-w-[180px]",
2644
- tooltipContent: resolvedTooltip,
2645
- onClick,
2646
- className,
2647
- "data-testid": `tag-entity-${tag.external_id}`
2688
+ className: className ?? "text-sm",
2689
+ components: AI_COMPONENTS,
2690
+ isStreaming,
2691
+ allowHtml,
2692
+ testId: "ai-markdown",
2693
+ children
2648
2694
  }
2649
2695
  );
2650
2696
  }
@@ -3169,901 +3215,946 @@ var EmlIcon = ({ size = 16, className = "" }) => {
3169
3215
  stroke: FILE_TYPE_COLORS.eml,
3170
3216
  strokeWidth: "1",
3171
3217
  strokeLinecap: "round",
3172
- strokeLinejoin: "round"
3173
- }
3174
- ),
3175
- /* @__PURE__ */ jsx(
3176
- "path",
3177
- {
3178
- d: "M14 2v6h6",
3179
- fill: "none",
3180
- stroke: FILE_TYPE_COLORS.white,
3181
- strokeWidth: "1",
3182
- strokeLinecap: "round",
3183
- strokeLinejoin: "round"
3184
- }
3185
- ),
3186
- /* @__PURE__ */ jsx(
3187
- "rect",
3188
- {
3189
- x: "7",
3190
- y: "12",
3191
- width: "10",
3192
- height: "7",
3193
- rx: "1",
3194
- fill: "none",
3195
- stroke: "white",
3196
- strokeWidth: "1.2"
3197
- }
3198
- ),
3199
- /* @__PURE__ */ jsx("path", { d: "M7 13l5 3 5-3", fill: "none", stroke: "white", strokeWidth: "1.2", strokeLinejoin: "round" })
3200
- ]
3201
- }
3202
- );
3203
- };
3204
- var ArbiIcon = ({
3205
- size = 20,
3206
- className = "",
3207
- "aria-label": ariaLabel = "ARBI Docs",
3208
- "aria-hidden": ariaHidden = false
3209
- }) => {
3210
- return /* @__PURE__ */ jsx(
3211
- "img",
3212
- {
3213
- src: "/favicon.svg",
3214
- alt: ariaLabel,
3215
- className: `rounded object-contain ${className}`,
3216
- style: { width: size, height: size },
3217
- "aria-label": ariaLabel,
3218
- "aria-hidden": ariaHidden
3219
- }
3220
- );
3221
- };
3222
- var ArbiBotHeadIcon = ({ size = 24, className = "" }) => {
3223
- const maskId = useId();
3224
- return /* @__PURE__ */ jsxs(
3225
- "svg",
3226
- {
3227
- xmlns: "http://www.w3.org/2000/svg",
3228
- width: size,
3229
- height: size,
3230
- viewBox: "30 -5 190 190",
3231
- preserveAspectRatio: "xMidYMid meet",
3232
- className,
3233
- children: [
3234
- /* @__PURE__ */ jsx("defs", { children: /* @__PURE__ */ jsx("mask", { id: maskId, children: /* @__PURE__ */ jsxs("g", { transform: "translate(0,250) scale(0.1,-0.1)", children: [
3235
- /* @__PURE__ */ jsx("rect", { x: "0", y: "0", width: "2500", height: "2500", fill: "white" }),
3236
- /* @__PURE__ */ jsx("circle", { cx: "855", cy: "1715", r: "190", fill: "black" }),
3237
- /* @__PURE__ */ jsx("circle", { cx: "855", cy: "1715", r: "50", fill: "white" }),
3238
- /* @__PURE__ */ jsx("circle", { cx: "1665", cy: "1700", r: "190", fill: "black" }),
3239
- /* @__PURE__ */ jsx("circle", { cx: "1665", cy: "1700", r: "50", fill: "white" })
3240
- ] }) }) }),
3241
- /* @__PURE__ */ jsxs("g", { mask: `url(#${maskId})`, children: [
3242
- /* @__PURE__ */ jsx(
3243
- "g",
3244
- {
3245
- transform: "translate(0,250) scale(0.1,-0.1)",
3246
- fill: "currentColor",
3247
- stroke: "currentColor",
3248
- strokeWidth: "100",
3249
- children: /* @__PURE__ */ jsx("path", { d: "M1038 2434 c-217 -39 -406 -154 -522 -318 -121 -170 -176 -376 -103 -384 l27 -3 0 -106 c0 -88 -3 -108 -17 -118 -15 -11 -16 -18 -5 -66 44 -188 209 -369 420 -459 l65 -28 -74 -7 c-283 -26 -444 -152 -535 -418 -70 -204 -73 -507 -5 -507 4 0 12 75 19 168 18 263 68 419 167 530 78 87 224 162 263 134 9 -6 43 -26 76 -43 224 -117 802 -95 948 38 38 34 165 -22 253 -111 117 -119 168 -268 187 -549 6 -92 15 -167 19 -167 89 0 53 415 -54 627 -88 173 -238 270 -458 295 l-99 11 75 32 c201 88 367 274 406 454 10 47 9 56 -5 66 -13 10 -16 32 -16 118 l0 106 28 3 c91 10 -12 297 -165 459 -202 214 -544 307 -895 243z m472 -84 c170 -43 323 -140 416 -264 47 -61 117 -197 128 -248 l6 -28 -65 0 c-64 0 -65 1 -78 33 -43 102 -109 136 -262 137 l-110 0 -38 -40 c-25 -27 -46 -40 -65 -41 -134 -5 -394 1 -410 10 -11 6 -30 24 -42 41 l-21 30 -112 0 c-156 -1 -219 -33 -262 -136 -14 -34 -14 -34 -80 -34 -76 0 -74 -7 -30 103 96 243 311 406 595 452 118 20 319 13 430 -15z m-561 -505 c97 -50 126 -174 61 -263 -118 -163 -380 -23 -309 165 35 93 162 143 248 98z m799 -15 c129 -96 69 -304 -92 -318 -189 -16 -265 218 -106 326 48 33 149 29 198 -8z m272 -389 c0 -23 -45 -110 -86 -168 -245 -343 -856 -408 -1231 -130 -90 67 -213 236 -213 294 0 11 132 13 765 13 457 0 765 -4 765 -9z" })
3250
- }
3251
- ),
3252
- /* @__PURE__ */ jsxs("g", { transform: "translate(0,250) scale(0.1,-0.1)", fill: "currentColor", stroke: "none", children: [
3253
- /* @__PURE__ */ jsx("path", { d: "M785 1777 c-60 -60 -59 -134 1 -186 92 -82 236 9 204 128 -25 93 -138 125 -205 58z m161 -29 c7 -22 -19 -52 -40 -45 -21 7 -30 35 -17 51 19 23 48 20 57 -6z" }),
3254
- /* @__PURE__ */ jsx("path", { d: "M1591 1803 c-128 -67 -85 -243 60 -243 83 0 141 99 105 178 -32 69 -103 97 -165 65z m127 -59 c4 -25 -19 -47 -41 -38 -22 8 -30 34 -16 51 17 20 53 12 57 -13z" }),
3255
- /* @__PURE__ */ jsx("path", { d: "M843 1347 c-9 -15 9 -63 41 -108 148 -202 565 -209 730 -12 37 44 60 103 47 116 -13 13 -810 17 -818 4z" })
3256
- ] })
3257
- ] })
3258
- ]
3259
- }
3260
- );
3261
- };
3262
- function ThreadVisibilityIcon({
3263
- shared,
3264
- className,
3265
- ...props
3266
- }) {
3267
- const Icon2 = shared ? MessageSquareShare : MessageSquareLock;
3268
- return /* @__PURE__ */ jsx(Icon2, { ...props, className: cn(shared ? "text-secondary" : "text-primary", className) });
3269
- }
3270
- function getDocumentTitle(document2, defaultValue = "") {
3271
- if (!document2) return defaultValue;
3272
- return document2.doc_metadata?.title || document2.file_name || defaultValue;
3273
- }
3274
- var MAX_LABEL_CHARS = 30;
3275
- function clampLabel(text) {
3276
- return text.length > MAX_LABEL_CHARS ? `${text.slice(0, MAX_LABEL_CHARS).trimEnd()}\u2026` : text;
3277
- }
3278
- var IMAGE_EXTENSIONS = /* @__PURE__ */ new Set(["jpg", "jpeg", "png", "gif", "bmp", "tiff", "tif", "webp"]);
3279
- var VIDEO_EXTENSIONS = /* @__PURE__ */ new Set(["mp4", "mpeg", "mpg", "webm", "mov", "avi", "mkv"]);
3280
- var AUDIO_EXTENSIONS = /* @__PURE__ */ new Set(["mp3", "wav", "m4a", "aac", "ogg", "flac"]);
3281
- var EMAIL_EXTENSIONS = /* @__PURE__ */ new Set(["eml", "msg"]);
3282
- var DOCX_EXTENSIONS = /* @__PURE__ */ new Set(["doc", "docx", "odt", "rtf"]);
3283
- var XLSX_EXTENSIONS = /* @__PURE__ */ new Set(["xls", "xlsx", "csv", "ods"]);
3284
- var HTML_EXTENSIONS = /* @__PURE__ */ new Set(["html", "htm", "mhtml"]);
3285
- var TEXT_EXTENSIONS = /* @__PURE__ */ new Set([
3286
- "txt",
3287
- "text",
3288
- "md",
3289
- "markdown",
3290
- "log",
3291
- "json",
3292
- "xml",
3293
- "yaml",
3294
- "yml"
3295
- ]);
3296
- function getDocIcon(fileName, iconSize = 14) {
3297
- const ext = fileName?.split(".").pop()?.toLowerCase();
3298
- if (ext && VIDEO_EXTENSIONS.has(ext)) return /* @__PURE__ */ jsx(VidIcon, { size: iconSize, className: "flex-shrink-0" });
3299
- if (ext && AUDIO_EXTENSIONS.has(ext)) return /* @__PURE__ */ jsx(AudIcon, { size: iconSize, className: "flex-shrink-0" });
3300
- if (ext && IMAGE_EXTENSIONS.has(ext)) return /* @__PURE__ */ jsx(ImgIcon, { size: iconSize, className: "flex-shrink-0" });
3301
- if (ext && EMAIL_EXTENSIONS.has(ext)) return /* @__PURE__ */ jsx(EmlIcon, { size: iconSize, className: "flex-shrink-0" });
3302
- if (ext && DOCX_EXTENSIONS.has(ext)) return /* @__PURE__ */ jsx(DocIcon, { size: iconSize, className: "flex-shrink-0" });
3303
- if (ext && XLSX_EXTENSIONS.has(ext)) return /* @__PURE__ */ jsx(XlsIcon, { size: iconSize, className: "flex-shrink-0" });
3304
- if (ext && HTML_EXTENSIONS.has(ext)) return /* @__PURE__ */ jsx(HtmlIcon, { size: iconSize, className: "flex-shrink-0" });
3305
- if (ext && TEXT_EXTENSIONS.has(ext)) return /* @__PURE__ */ jsx(TxtIcon, { size: iconSize, className: "flex-shrink-0" });
3306
- return /* @__PURE__ */ jsx(PdfIcon, { size: iconSize, className: "flex-shrink-0" });
3307
- }
3308
- function DocumentEntity({
3309
- doc,
3310
- icon,
3311
- size = "sm",
3312
- labelMaxWidth,
3313
- labelClassName,
3314
- onClick,
3315
- onIconClick,
3316
- viewing,
3317
- iconBadge,
3318
- status,
3319
- actions,
3320
- tooltipContent,
3321
- className,
3322
- fullWidth,
3323
- noClamp,
3324
- "data-testid": testId
3325
- }) {
3326
- const title = getDocumentTitle(doc);
3327
- const ext = doc.file_name?.split(".").pop()?.toLowerCase();
3328
- const iconSize = size === "base" ? 16 : 14;
3329
- const eyeSizeClass = size === "base" ? "h-4 w-4" : "h-3.5 w-3.5";
3330
- const baseIcon = icon ?? getDocIcon(doc.file_name, iconSize);
3331
- const displayIcon = viewing || iconBadge ? /* @__PURE__ */ jsxs("span", { className: "relative inline-flex flex-shrink-0 items-center justify-center", children: [
3332
- viewing ? /* @__PURE__ */ jsx(Eye, { className: cn("text-primary-foreground", eyeSizeClass) }) : baseIcon,
3333
- iconBadge
3334
- ] }) : baseIcon;
3335
- const defaultTooltip = /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1 text-xs max-w-[440px]", children: [
3336
- doc.folder && // `flex-wrap` so a deep folder path wraps WITHIN the balloon instead of
3337
- // spilling out of it (each path segment is atomic and wraps as a unit;
3338
- // `min-w-0` + `break-all` lets a single over-long segment break too).
3339
- /* @__PURE__ */ jsxs("span", { className: "flex flex-wrap items-center gap-0.5 text-muted-foreground", children: [
3340
- /* @__PURE__ */ jsx(FolderOpen, { className: "h-3 w-3 text-yellow-600 shrink-0" }),
3341
- doc.folder.split("/").map((part, i, arr) => /* @__PURE__ */ jsxs("span", { className: "flex min-w-0 items-center gap-0.5", children: [
3342
- i > 0 && /* @__PURE__ */ jsx("span", { className: "text-muted-foreground/50 mx-0.5", children: "/" }),
3343
- /* @__PURE__ */ jsx("span", { className: `break-all ${i < arr.length - 1 ? "text-muted-foreground/70" : ""}`, children: part })
3344
- ] }, i))
3345
- ] }),
3346
- /* @__PURE__ */ jsxs("span", { className: "font-medium break-words", children: [
3347
- title,
3348
- ext ? `.${ext}` : ""
3349
- ] })
3350
- ] });
3351
- return /* @__PURE__ */ jsx(
3352
- EntityPill,
3353
- {
3354
- icon: displayIcon,
3355
- size,
3356
- label: fullWidth || noClamp ? title : clampLabel(title),
3357
- labelMaxWidth: labelMaxWidth ?? "max-w-[140px]",
3358
- labelClassName,
3359
- secondaryText: status,
3360
- fullWidth,
3361
- onClick,
3362
- onIconClick,
3363
- moreContent: actions,
3364
- className,
3365
- highlight: viewing,
3366
- "data-testid": testId,
3367
- tooltipContent: tooltipContent ?? defaultTooltip
3218
+ strokeLinejoin: "round"
3219
+ }
3220
+ ),
3221
+ /* @__PURE__ */ jsx(
3222
+ "path",
3223
+ {
3224
+ d: "M14 2v6h6",
3225
+ fill: "none",
3226
+ stroke: FILE_TYPE_COLORS.white,
3227
+ strokeWidth: "1",
3228
+ strokeLinecap: "round",
3229
+ strokeLinejoin: "round"
3230
+ }
3231
+ ),
3232
+ /* @__PURE__ */ jsx(
3233
+ "rect",
3234
+ {
3235
+ x: "7",
3236
+ y: "12",
3237
+ width: "10",
3238
+ height: "7",
3239
+ rx: "1",
3240
+ fill: "none",
3241
+ stroke: "white",
3242
+ strokeWidth: "1.2"
3243
+ }
3244
+ ),
3245
+ /* @__PURE__ */ jsx("path", { d: "M7 13l5 3 5-3", fill: "none", stroke: "white", strokeWidth: "1.2", strokeLinejoin: "round" })
3246
+ ]
3368
3247
  }
3369
3248
  );
3370
- }
3371
- var VARIANT_STYLES = {
3372
- "mine-paid": {
3373
- pill: "text-primary",
3374
- icon: "text-primary"
3375
- },
3376
- other: {
3377
- pill: "text-secondary",
3378
- icon: "text-secondary"
3379
- },
3380
- "mine-free": {
3381
- pill: "text-muted-foreground",
3382
- icon: "text-muted-foreground"
3383
- },
3384
- common: {
3385
- pill: "",
3386
- icon: "text-muted-foreground"
3387
- }
3388
3249
  };
3389
- function resolveVariant(relation, paid, hasCollaborators) {
3390
- if (relation === "common") return "common";
3391
- if (relation === "other") return "other";
3392
- if (relation === "mine") return paid ? "mine-paid" : "mine-free";
3393
- if (paid) return hasCollaborators ? "other" : "mine-paid";
3394
- return "mine-free";
3395
- }
3396
- function ProjectEntity({
3397
- name,
3398
- label,
3399
- icon,
3400
- subscription = "none",
3401
- hasCollaborators = false,
3402
- size = "sm",
3403
- className,
3404
- onClick,
3405
- relation,
3406
- isPaid,
3407
- tooltipContent
3408
- }) {
3409
- const paid = isPaid ?? (subscription === "active" || subscription === "past_due" || subscription === "dev");
3410
- const variant = resolveVariant(relation, paid, hasCollaborators);
3411
- const { pill, icon: iconClass } = VARIANT_STYLES[variant];
3412
- const iconSizeClass = size === "base" ? "h-4 w-4" : "h-3.5 w-3.5";
3413
- const iconNode = icon ?? /* @__PURE__ */ jsx(CreditCard, { className: cn(iconSizeClass, iconClass) });
3250
+ var ArbiIcon = ({
3251
+ size = 20,
3252
+ className = "",
3253
+ "aria-label": ariaLabel = "ARBI Docs",
3254
+ "aria-hidden": ariaHidden = false
3255
+ }) => {
3414
3256
  return /* @__PURE__ */ jsx(
3415
- EntityPill,
3257
+ "img",
3416
3258
  {
3417
- icon: iconNode,
3418
- label: label ?? name,
3419
- size,
3420
- shape: "rounded",
3421
- className: cn(pill, className),
3422
- onClick,
3423
- tooltipContent
3259
+ src: "/favicon.svg",
3260
+ alt: ariaLabel,
3261
+ className: `rounded object-contain ${className}`,
3262
+ style: { width: size, height: size },
3263
+ "aria-label": ariaLabel,
3264
+ "aria-hidden": ariaHidden
3424
3265
  }
3425
3266
  );
3426
- }
3427
- function VerifiedBadge({ className, label = "Identity verified" }) {
3428
- return /* @__PURE__ */ jsx(
3429
- BadgeCheck,
3267
+ };
3268
+ var ArbiBotHeadIcon = ({ size = 24, className = "" }) => {
3269
+ const maskId = useId();
3270
+ return /* @__PURE__ */ jsxs(
3271
+ "svg",
3430
3272
  {
3431
- role: "img",
3432
- "aria-label": label,
3433
- "data-testid": "verified-badge",
3434
- className: cn("h-3.5 w-3.5 shrink-0 text-sky-500", className),
3435
- children: /* @__PURE__ */ jsx("title", { children: label })
3273
+ xmlns: "http://www.w3.org/2000/svg",
3274
+ width: size,
3275
+ height: size,
3276
+ viewBox: "30 -5 190 190",
3277
+ preserveAspectRatio: "xMidYMid meet",
3278
+ className,
3279
+ children: [
3280
+ /* @__PURE__ */ jsx("defs", { children: /* @__PURE__ */ jsx("mask", { id: maskId, children: /* @__PURE__ */ jsxs("g", { transform: "translate(0,250) scale(0.1,-0.1)", children: [
3281
+ /* @__PURE__ */ jsx("rect", { x: "0", y: "0", width: "2500", height: "2500", fill: "white" }),
3282
+ /* @__PURE__ */ jsx("circle", { cx: "855", cy: "1715", r: "190", fill: "black" }),
3283
+ /* @__PURE__ */ jsx("circle", { cx: "855", cy: "1715", r: "50", fill: "white" }),
3284
+ /* @__PURE__ */ jsx("circle", { cx: "1665", cy: "1700", r: "190", fill: "black" }),
3285
+ /* @__PURE__ */ jsx("circle", { cx: "1665", cy: "1700", r: "50", fill: "white" })
3286
+ ] }) }) }),
3287
+ /* @__PURE__ */ jsxs("g", { mask: `url(#${maskId})`, children: [
3288
+ /* @__PURE__ */ jsx(
3289
+ "g",
3290
+ {
3291
+ transform: "translate(0,250) scale(0.1,-0.1)",
3292
+ fill: "currentColor",
3293
+ stroke: "currentColor",
3294
+ strokeWidth: "100",
3295
+ children: /* @__PURE__ */ jsx("path", { d: "M1038 2434 c-217 -39 -406 -154 -522 -318 -121 -170 -176 -376 -103 -384 l27 -3 0 -106 c0 -88 -3 -108 -17 -118 -15 -11 -16 -18 -5 -66 44 -188 209 -369 420 -459 l65 -28 -74 -7 c-283 -26 -444 -152 -535 -418 -70 -204 -73 -507 -5 -507 4 0 12 75 19 168 18 263 68 419 167 530 78 87 224 162 263 134 9 -6 43 -26 76 -43 224 -117 802 -95 948 38 38 34 165 -22 253 -111 117 -119 168 -268 187 -549 6 -92 15 -167 19 -167 89 0 53 415 -54 627 -88 173 -238 270 -458 295 l-99 11 75 32 c201 88 367 274 406 454 10 47 9 56 -5 66 -13 10 -16 32 -16 118 l0 106 28 3 c91 10 -12 297 -165 459 -202 214 -544 307 -895 243z m472 -84 c170 -43 323 -140 416 -264 47 -61 117 -197 128 -248 l6 -28 -65 0 c-64 0 -65 1 -78 33 -43 102 -109 136 -262 137 l-110 0 -38 -40 c-25 -27 -46 -40 -65 -41 -134 -5 -394 1 -410 10 -11 6 -30 24 -42 41 l-21 30 -112 0 c-156 -1 -219 -33 -262 -136 -14 -34 -14 -34 -80 -34 -76 0 -74 -7 -30 103 96 243 311 406 595 452 118 20 319 13 430 -15z m-561 -505 c97 -50 126 -174 61 -263 -118 -163 -380 -23 -309 165 35 93 162 143 248 98z m799 -15 c129 -96 69 -304 -92 -318 -189 -16 -265 218 -106 326 48 33 149 29 198 -8z m272 -389 c0 -23 -45 -110 -86 -168 -245 -343 -856 -408 -1231 -130 -90 67 -213 236 -213 294 0 11 132 13 765 13 457 0 765 -4 765 -9z" })
3296
+ }
3297
+ ),
3298
+ /* @__PURE__ */ jsxs("g", { transform: "translate(0,250) scale(0.1,-0.1)", fill: "currentColor", stroke: "none", children: [
3299
+ /* @__PURE__ */ jsx("path", { d: "M785 1777 c-60 -60 -59 -134 1 -186 92 -82 236 9 204 128 -25 93 -138 125 -205 58z m161 -29 c7 -22 -19 -52 -40 -45 -21 7 -30 35 -17 51 19 23 48 20 57 -6z" }),
3300
+ /* @__PURE__ */ jsx("path", { d: "M1591 1803 c-128 -67 -85 -243 60 -243 83 0 141 99 105 178 -32 69 -103 97 -165 65z m127 -59 c4 -25 -19 -47 -41 -38 -22 8 -30 34 -16 51 17 20 53 12 57 -13z" }),
3301
+ /* @__PURE__ */ jsx("path", { d: "M843 1347 c-9 -15 9 -63 41 -108 148 -202 565 -209 730 -12 37 44 60 103 47 116 -13 13 -810 17 -818 4z" })
3302
+ ] })
3303
+ ] })
3304
+ ]
3436
3305
  }
3437
3306
  );
3438
- }
3439
- var sizeClasses = {
3440
- xs: "h-5 w-5",
3441
- sm: "h-6 w-6",
3442
- md: "h-8 w-8",
3443
- lg: "h-10 w-10"
3444
- };
3445
- var textSizeClasses = {
3446
- xs: "text-xs",
3447
- sm: "text-xs",
3448
- md: "text-xs",
3449
- lg: "text-sm"
3450
- };
3451
- var presenceDotClasses = {
3452
- xs: "w-2 h-2 border",
3453
- sm: "w-2.5 h-2.5 border",
3454
- md: "w-3 h-3 border-2",
3455
- lg: "w-3.5 h-3.5 border-2"
3456
- };
3457
- var presencePositionClasses = {
3458
- xs: "-right-1 bottom-0",
3459
- sm: "-right-1 bottom-0",
3460
- md: "-right-1.5 -bottom-0.5",
3461
- lg: "-right-1.5 -bottom-0.5"
3462
- };
3463
- var PRESENCE_LABELS = {
3464
- connected: "Online",
3465
- connecting: "Connecting",
3466
- disconnected: "Offline",
3467
- error: "Connection problem",
3468
- hidden: "Status hidden"
3469
- };
3470
- var presenceColorClasses = {
3471
- connected: "bg-status-online",
3472
- connecting: "bg-status-connecting",
3473
- disconnected: "bg-status-away",
3474
- error: "bg-status-busy",
3475
- hidden: "bg-status-offline"
3476
3307
  };
3477
- var UserEntity = memo(function UserEntity2({
3478
- size = "md",
3479
- variant = "pill",
3308
+ function ThreadVisibilityIcon({
3309
+ shared,
3480
3310
  className,
3481
- showTooltip = true,
3482
- interactive = true,
3483
- hasUnreadMessages = false,
3484
- initials = "",
3485
- displayName = "",
3486
- picture,
3487
- avatarImageClassName,
3488
- colorClass = "",
3489
- isAgent = false,
3490
- isVerified = false,
3491
- agentStyle,
3492
- avatarStyle,
3493
- isMe = false,
3494
- displayStatus,
3311
+ ...props
3312
+ }) {
3313
+ const Icon2 = shared ? MessageSquareShare : MessageSquareLock;
3314
+ return /* @__PURE__ */ jsx(Icon2, { ...props, className: cn(shared ? "text-secondary" : "text-primary", className) });
3315
+ }
3316
+ var EntityPill = forwardRef(function EntityPill2({
3317
+ icon,
3318
+ label,
3319
+ secondaryText,
3320
+ size = "sm",
3321
+ shape = "rounded",
3322
+ className,
3323
+ labelMaxWidth = "max-w-[320px]",
3324
+ labelClassName,
3325
+ fullWidth = false,
3326
+ highlight = false,
3495
3327
  onClick,
3328
+ onIconClick,
3329
+ onMoreClick,
3330
+ moreContent,
3331
+ href,
3332
+ disabled = false,
3496
3333
  tooltipContent,
3497
- empty = false
3498
- }) {
3499
- if (empty) {
3500
- return /* @__PURE__ */ jsx(
3501
- Avatar,
3334
+ tooltipSide = "bottom",
3335
+ "data-testid": testId
3336
+ }, ref) {
3337
+ const shapeClass = shape === "pill" ? "rounded-full" : "rounded-md";
3338
+ const sizeClasses2 = size === "base" ? "gap-1.5 px-1.5 py-0.5" : "gap-1 px-1";
3339
+ const textSizeClass = size === "base" ? "text-base" : "text-sm";
3340
+ const baseClasses = cn(
3341
+ "group/pill items-center",
3342
+ fullWidth ? "flex w-full" : "inline-flex",
3343
+ sizeClasses2,
3344
+ shapeClass,
3345
+ "border border-transparent",
3346
+ "transition-colors",
3347
+ className
3348
+ );
3349
+ const interactiveClasses = "relative cursor-pointer hover:bg-muted pointer-coarse:after:absolute pointer-coarse:after:inset-x-0 pointer-coarse:after:-inset-y-3 pointer-coarse:after:content-['']";
3350
+ const disabledClasses = "cursor-default opacity-60";
3351
+ const highlightClasses = "bg-primary text-primary-foreground hover:bg-primary hover:text-primary-foreground";
3352
+ const mainContent = /* @__PURE__ */ jsxs(Fragment, { children: [
3353
+ onIconClick ? /* @__PURE__ */ jsx(
3354
+ "span",
3355
+ {
3356
+ role: "button",
3357
+ tabIndex: 0,
3358
+ className: "flex-shrink-0 cursor-pointer hover:opacity-70 transition-opacity",
3359
+ onClick: (e) => {
3360
+ e.stopPropagation();
3361
+ onIconClick(e);
3362
+ },
3363
+ children: icon
3364
+ }
3365
+ ) : icon,
3366
+ /* @__PURE__ */ jsx(
3367
+ "span",
3502
3368
  {
3503
- className: cn(sizeClasses[size], "border border-border", className),
3504
- "data-testid": "user-entity",
3505
- children: /* @__PURE__ */ jsx(AvatarFallback, { className: "bg-status-empty text-muted-foreground text-xs font-semibold", children: "?" })
3369
+ className: cn(
3370
+ textSizeClass,
3371
+ "font-medium truncate leading-tight min-w-0",
3372
+ labelMaxWidth,
3373
+ labelClassName
3374
+ ),
3375
+ children: label
3506
3376
  }
3507
- );
3508
- }
3509
- const agentBadge = isAgent ? /* @__PURE__ */ jsx(ArbiBotHeadIcon, { className: "w-3.5 h-3.5 text-muted-foreground" }) : void 0;
3510
- const canMessage = interactive && !isMe && !isAgent;
3511
- const showUnread = hasUnreadMessages && !isMe && !isAgent;
3512
- const surfaceStyle = avatarStyle ?? agentStyle;
3513
- const avatarCore = /* @__PURE__ */ jsxs(
3514
- Avatar,
3515
- {
3516
- className: cn(
3517
- sizeClasses[size],
3518
- isAgent ? "rounded-full border-2 border-dashed" : "border border-white"
3519
- ),
3520
- style: surfaceStyle,
3521
- "data-testid": "user-entity",
3522
- children: [
3523
- picture && /* @__PURE__ */ jsx(AvatarImage, { src: picture, alt: initials, className: avatarImageClassName }),
3524
- /* @__PURE__ */ jsx(
3525
- AvatarFallback,
3526
- {
3527
- className: cn(
3528
- textSizeClasses[size],
3529
- "font-semibold leading-none",
3530
- isAgent ? "rounded-full bg-transparent" : `text-white ${colorClass}`
3531
- ),
3532
- style: surfaceStyle,
3533
- children: initials
3534
- }
3535
- )
3536
- ]
3537
- }
3377
+ ),
3378
+ secondaryText && /* @__PURE__ */ jsx("span", { className: "text-xs text-muted-foreground flex-shrink-0 leading-none", children: secondaryText })
3379
+ ] });
3380
+ const tooltipWrap = (content, tip, side = tooltipSide, triggerClassName, triggerProps) => /* @__PURE__ */ jsxs(Tooltip, { children: [
3381
+ /* @__PURE__ */ jsx(
3382
+ TooltipTrigger,
3383
+ {
3384
+ onFocusCapture: (e) => e.stopPropagation(),
3385
+ className: triggerClassName,
3386
+ ...triggerProps,
3387
+ children: content
3388
+ }
3389
+ ),
3390
+ /* @__PURE__ */ jsx(TooltipContent, { side, className: "p-2", children: tip })
3391
+ ] });
3392
+ const mainAreaClass = cn("inline-flex items-center gap-1", fullWidth && "min-w-0 flex-1");
3393
+ const mainAreaTouchClass = cn(
3394
+ mainAreaClass,
3395
+ (onClick || href) && !disabled && "relative pointer-coarse:after:absolute pointer-coarse:after:inset-x-0 pointer-coarse:after:-inset-y-3 pointer-coarse:after:content-['']"
3538
3396
  );
3539
- const statusDot = showUnread || displayStatus ? /* @__PURE__ */ jsx(
3540
- "span",
3541
- {
3542
- className: cn(
3543
- "absolute rounded-full border-white",
3544
- presenceDotClasses[size],
3545
- presencePositionClasses[size],
3546
- !showUnread && displayStatus ? presenceColorClasses[displayStatus] : ""
3547
- ),
3548
- style: showUnread ? { backgroundColor: "#00adef" } : void 0,
3549
- "data-testid": "user-entity-presence",
3550
- role: "img",
3551
- "aria-label": showUnread ? "Unread messages" : PRESENCE_LABELS[displayStatus],
3552
- title: showUnread ? "Unread messages" : PRESENCE_LABELS[displayStatus]
3553
- }
3554
- ) : null;
3555
- const avatarElement = statusDot ? /* @__PURE__ */ jsxs(
3556
- "div",
3557
- {
3558
- className: cn(
3559
- "relative inline-block",
3560
- sizeClasses[size],
3561
- variant === "pill" ? "" : className
3562
- ),
3563
- children: [
3564
- avatarCore,
3565
- statusDot
3566
- ]
3567
- }
3568
- ) : /* @__PURE__ */ jsx("div", { className: cn("inline-block", variant === "pill" ? "" : className), children: avatarCore });
3569
- const pillAvatar = (
3570
- // shrink-0: when the pill is squeezed the NAME truncates away — the avatar
3571
- // must never collapse under it and overflow onto neighbouring text.
3572
- /* @__PURE__ */ jsxs("span", { className: cn("relative inline-block shrink-0", sizeClasses[size]), children: [
3573
- /* @__PURE__ */ jsx("span", { className: cn("block transition-opacity", canMessage && "group-hover/pill:opacity-0"), children: avatarCore }),
3574
- canMessage && /* @__PURE__ */ jsx(
3575
- "span",
3397
+ if (onMoreClick || moreContent) {
3398
+ let mainArea;
3399
+ if (tooltipContent) {
3400
+ mainArea = tooltipWrap(
3401
+ mainContent,
3402
+ tooltipContent,
3403
+ tooltipSide,
3404
+ cn(mainAreaTouchClass, disabled && "opacity-60"),
3576
3405
  {
3577
- "aria-hidden": true,
3578
- className: "absolute inset-0 flex items-center justify-center rounded-full bg-muted text-foreground opacity-0 transition-opacity group-hover/pill:opacity-100",
3579
- children: /* @__PURE__ */ jsx(MessageCircleMore, { className: size === "xs" ? "h-3 w-3" : "h-4 w-4" })
3406
+ type: "button",
3407
+ onClick: href ? onClick : disabled ? void 0 : onClick,
3408
+ disabled: disabled || void 0
3580
3409
  }
3581
- ),
3582
- statusDot
3583
- ] })
3584
- );
3585
- const resolvedTooltip = showTooltip ? tooltipContent : void 0;
3586
- if (variant === "pill") {
3587
- const row = /* @__PURE__ */ jsxs(Fragment, { children: [
3588
- pillAvatar,
3589
- displayName && /* @__PURE__ */ jsx("span", { className: "min-w-0 max-w-[320px] truncate text-sm leading-tight", children: displayName }),
3590
- isVerified && !isAgent && /* @__PURE__ */ jsx(VerifiedBadge, {}),
3591
- agentBadge
3592
- ] });
3593
- const rowClass = "group/pill inline-flex min-w-0 items-center gap-2";
3594
- const clickable = interactive && !!onClick;
3595
- const clickableClass = "relative cursor-pointer rounded-md px-1 py-0.5 -mx-1 transition-colors hover:bg-muted/60 pointer-coarse:after:absolute pointer-coarse:after:inset-x-0 pointer-coarse:after:-inset-y-3 pointer-coarse:after:content-['']";
3596
- if (resolvedTooltip) {
3597
- return /* @__PURE__ */ jsxs(Tooltip, { children: [
3598
- /* @__PURE__ */ jsx(
3599
- TooltipTrigger,
3600
- {
3601
- type: "button",
3602
- onClick: clickable ? onClick : void 0,
3603
- onFocusCapture: (e) => e.stopPropagation(),
3604
- className: cn(rowClass, clickable && clickableClass, className),
3605
- "data-testid": "user-entity-pill",
3606
- children: row
3607
- }
3608
- ),
3609
- /* @__PURE__ */ jsx(TooltipContent, { className: "p-2", children: resolvedTooltip })
3610
- ] });
3611
- }
3612
- if (clickable) {
3613
- return /* @__PURE__ */ jsx(
3410
+ );
3411
+ } else if (href) {
3412
+ mainArea = /* @__PURE__ */ jsx(
3413
+ "a",
3414
+ {
3415
+ href,
3416
+ target: "_blank",
3417
+ rel: "noopener noreferrer",
3418
+ className: mainAreaTouchClass,
3419
+ onClick,
3420
+ children: mainContent
3421
+ }
3422
+ );
3423
+ } else if (onClick) {
3424
+ mainArea = /* @__PURE__ */ jsx(
3614
3425
  "button",
3615
3426
  {
3616
3427
  type: "button",
3617
- onClick,
3618
- className: cn(rowClass, clickableClass, className),
3619
- "data-testid": "user-entity-pill",
3620
- children: row
3428
+ onClick: disabled ? void 0 : onClick,
3429
+ disabled,
3430
+ className: cn(
3431
+ "relative inline-flex items-center gap-1 pointer-coarse:after:absolute pointer-coarse:after:inset-x-0 pointer-coarse:after:-inset-y-3 pointer-coarse:after:content-['']",
3432
+ disabled && "opacity-60"
3433
+ ),
3434
+ children: mainContent
3621
3435
  }
3622
3436
  );
3437
+ } else {
3438
+ mainArea = /* @__PURE__ */ jsx("span", { className: mainAreaTouchClass, children: mainContent });
3623
3439
  }
3624
- return /* @__PURE__ */ jsx("span", { className: cn(rowClass, className), "data-testid": "user-entity-pill", children: row });
3625
- }
3626
- if (showTooltip) {
3627
- return /* @__PURE__ */ jsxs(Tooltip, { children: [
3628
- /* @__PURE__ */ jsx(
3629
- TooltipTrigger,
3630
- {
3631
- onFocusCapture: (e) => e.stopPropagation(),
3632
- className: "touch-hit inline-flex",
3633
- children: avatarElement
3440
+ const moreArea = moreContent ? /* @__PURE__ */ jsx("span", { className: "flex-shrink-0 leading-none", children: moreContent }) : tooltipWrap(
3441
+ /* @__PURE__ */ jsx(MoreVertical, { className: "w-3.5 h-3.5" }),
3442
+ "Click for more",
3443
+ tooltipSide,
3444
+ "flex-shrink-0 leading-none text-muted-foreground hover:text-foreground",
3445
+ {
3446
+ type: "button",
3447
+ onClick: (e) => {
3448
+ e.stopPropagation();
3449
+ onMoreClick?.(e);
3634
3450
  }
3635
- ),
3636
- /* @__PURE__ */ jsx(TooltipContent, { className: "p-2", children: tooltipContent })
3637
- ] });
3451
+ }
3452
+ );
3453
+ return /* @__PURE__ */ jsxs(
3454
+ "span",
3455
+ {
3456
+ ref,
3457
+ className: cn(
3458
+ baseClasses,
3459
+ (onClick || href) && !disabled && "cursor-pointer hover:bg-muted",
3460
+ highlight && highlightClasses
3461
+ ),
3462
+ "data-testid": testId,
3463
+ children: [
3464
+ mainArea,
3465
+ moreArea
3466
+ ]
3467
+ }
3468
+ );
3638
3469
  }
3639
- return avatarElement;
3640
- });
3641
- function AgentBadge({ className }) {
3642
- return /* @__PURE__ */ jsxs(
3643
- "span",
3644
- {
3645
- "data-testid": "agent-badge",
3646
- className: cn(
3647
- "inline-flex shrink-0 items-center gap-1 rounded-full border border-ai-accent/50",
3648
- "bg-ai-accent-soft px-2 py-0.5 text-xs font-bold uppercase tracking-wider text-ai-accent",
3649
- className
3650
- ),
3651
- children: [
3652
- /* @__PURE__ */ jsx(ArbiBotHeadIcon, { size: 14, className: "text-ai-accent" }),
3653
- "Agent"
3654
- ]
3655
- }
3656
- );
3657
- }
3658
- var PRESENCE_WORDS = {
3659
- connected: "Online",
3660
- connecting: "Connecting",
3661
- disconnected: "Offline",
3662
- error: "Connection problem",
3663
- hidden: null
3664
- };
3665
- function PresenceLabel({
3666
- status,
3667
- className
3668
- }) {
3669
- if (!status) return null;
3670
- const word = PRESENCE_WORDS[status];
3671
- if (!word) return null;
3672
- const online = status === "connected";
3673
- return /* @__PURE__ */ jsxs(
3674
- "span",
3675
- {
3676
- "data-testid": "presence-label",
3677
- className: cn("inline-flex shrink-0 items-center gap-1 text-xs", className),
3678
- children: [
3470
+ if (tooltipContent) {
3471
+ if (href) {
3472
+ return tooltipWrap(
3679
3473
  /* @__PURE__ */ jsx(
3680
- "span",
3474
+ "a",
3681
3475
  {
3682
- className: cn(
3683
- "size-1.5 rounded-full",
3684
- online ? "bg-status-online" : "bg-muted-foreground/50"
3685
- ),
3686
- "aria-hidden": "true"
3476
+ href,
3477
+ target: "_blank",
3478
+ rel: "noopener noreferrer",
3479
+ className: mainAreaClass,
3480
+ onClick,
3481
+ children: mainContent
3687
3482
  }
3688
3483
  ),
3689
- /* @__PURE__ */ jsx("span", { className: online ? "font-medium text-status-online" : "text-muted-foreground", children: word })
3690
- ]
3691
- }
3692
- );
3693
- }
3694
- var PACKAGE_BADGE_VARIANTS = [
3695
- "default",
3696
- "accent",
3697
- "secondary",
3698
- "destructive",
3699
- "outline"
3700
- ];
3701
- function isPackageBadgeVariant(v) {
3702
- return PACKAGE_BADGE_VARIANTS.some((known) => known === v);
3703
- }
3704
- function PackageStatusBadge({ variant, ...rest }) {
3705
- return /* @__PURE__ */ jsx(Badge, { variant: isPackageBadgeVariant(variant) ? variant : "outline", ...rest });
3706
- }
3707
- var registry = {
3708
- variants: {},
3709
- fallback: "outline",
3710
- Badge: PackageStatusBadge
3711
- };
3712
- function configureStatusRegistry(map, opts) {
3713
- Object.assign(registry.variants, map);
3714
- if (opts?.fallback) registry.fallback = opts.fallback;
3715
- if (opts?.Badge) registry.Badge = opts.Badge;
3716
- }
3717
- function getStatusVariant(status) {
3718
- return registry.variants[status] ?? registry.fallback;
3719
- }
3720
- function StatusPill({ status, label, variant, className, testId }) {
3721
- const Badge2 = registry.Badge;
3722
- return /* @__PURE__ */ jsx(Badge2, { variant: variant ?? getStatusVariant(status), className, "data-testid": testId, children: label ?? status });
3723
- }
3724
- var RAG_LABELS = { red: "At risk", amber: "Attention", green: "On track" };
3725
- function configureRagLabels(labels) {
3726
- RAG_LABELS = { ...RAG_LABELS, ...labels };
3727
- }
3728
- function RagDot({
3729
- rag,
3730
- withLabel,
3731
- className
3732
- }) {
3733
- const color = rag === "red" ? "bg-destructive" : rag === "amber" ? "bg-warning" : "bg-success";
3734
- return /* @__PURE__ */ jsxs("span", { className: cn("inline-flex items-center gap-1.5", className), "data-testid": `rag-${rag}`, children: [
3735
- /* @__PURE__ */ jsx("span", { className: cn("size-2 rounded-full", color) }),
3736
- withLabel && /* @__PURE__ */ jsx("span", { className: "text-xs text-muted-foreground", children: RAG_LABELS[rag] })
3737
- ] });
3738
- }
3739
- var ENTITY_MAPPINGS = {
3740
- PRODUCT: {
3741
- NAMES: {
3742
- SINGULAR: "ARBI Docs"
3743
- },
3744
- ICONS: {
3745
- DEFAULT: MessageSquareLock
3746
- }
3747
- },
3748
- SECTION: {
3749
- NAMES: {
3750
- SINGULAR: "Section"
3751
- },
3752
- ICONS: {
3753
- DEFAULT: ChevronsDown
3754
- }
3755
- },
3756
- WORKSPACE: {
3757
- NAMES: {
3758
- SINGULAR: "Workspace",
3759
- PLURAL: "Workspaces"
3760
- },
3761
- ICONS: {
3762
- DEFAULT: SquareM,
3763
- NEW: SquarePlus,
3764
- LIST: LayoutGrid,
3765
- SETTINGS: Columns3Cog
3766
- }
3767
- },
3768
- CONVERSATION: {
3769
- NAMES: {
3770
- SINGULAR: "Thread",
3771
- PLURAL: "Threads",
3772
- NEW: "New Thread"
3773
- },
3774
- ICONS: {
3775
- DEFAULT: MessagesSquare,
3776
- OFF: MessageSquareOff,
3777
- ACTIVE: MessageSquareText,
3778
- NEW: MessageSquarePlus,
3779
- LIST: MessageSquareMore
3780
- }
3781
- },
3782
- DOCUMENT: {
3783
- NAMES: {
3784
- SINGULAR: "File",
3785
- PLURAL: "Files"
3786
- },
3787
- ICONS: {
3788
- DEFAULT: FolderOpen,
3789
- OFF: CaptionsOff
3790
- }
3791
- },
3792
- VIEWER: {
3793
- NAMES: {
3794
- SINGULAR: "Viewer",
3795
- PLURAL: "Viewers"
3796
- },
3797
- ICONS: {
3798
- DEFAULT: Eye,
3799
- OFF: EyeOff
3800
- }
3801
- },
3802
- TAG: {
3803
- NAMES: {
3804
- SINGULAR: "Field",
3805
- PLURAL: "Fields"
3806
- },
3807
- ICONS: {
3808
- DEFAULT: Hash,
3809
- NEW: FolderPlus
3810
- }
3811
- },
3812
- ANNOTATION: {
3813
- NAMES: {
3814
- SINGULAR: "Annotation",
3815
- PLURAL: "Annotations"
3816
- },
3817
- ICONS: {
3818
- DEFAULT: StickyNote,
3819
- NEW: StickyNote
3820
- }
3821
- },
3822
- // A tag of any kind — what the Tags page lists. TAG stays "Field": the Files page's custom
3823
- // columns (labels and annotations as document fields) are named after it.
3824
- ANY_TAG: {
3825
- NAMES: {
3826
- SINGULAR: "Tag",
3827
- PLURAL: "Tags"
3828
- },
3829
- ICONS: {
3830
- DEFAULT: Tags
3831
- }
3832
- },
3833
- // The kinds of TAG (a tag's `kind`): a label files things; an issue is a point in dispute; a
3834
- // person and an organisation are entities the documents name; a saved search is a stored query.
3835
- LABEL: {
3836
- NAMES: {
3837
- SINGULAR: "Label",
3838
- PLURAL: "Labels"
3839
- },
3840
- ICONS: {
3841
- DEFAULT: Tags
3842
- }
3843
- },
3844
- ISSUE: {
3845
- NAMES: {
3846
- SINGULAR: "Issue",
3847
- PLURAL: "Issues"
3848
- },
3849
- ICONS: {
3850
- DEFAULT: Scale
3851
- }
3852
- },
3853
- PERSON: {
3854
- NAMES: {
3855
- SINGULAR: "Person",
3856
- PLURAL: "People"
3857
- },
3858
- ICONS: {
3859
- DEFAULT: Contact
3860
- }
3861
- },
3862
- ORGANISATION: {
3863
- NAMES: {
3864
- SINGULAR: "Organisation",
3865
- PLURAL: "Organisations"
3866
- },
3867
- ICONS: {
3868
- DEFAULT: Building2
3869
- }
3870
- },
3871
- SAVED_SEARCH: {
3872
- NAMES: {
3873
- SINGULAR: "Saved search",
3874
- PLURAL: "Saved searches"
3875
- },
3876
- ICONS: {
3877
- DEFAULT: Search
3878
- }
3879
- },
3880
- // Workspace knowledge the assistant retains and recalls — durable free text,
3881
- // optionally grounded in source passages. Distinct from ANNOTATION, which is
3882
- // attached TO a document field; a NOTE is workspace-scoped and stands alone.
3883
- // Stored server-side as `memories` (mem-*); "Note" is the user-facing name.
3884
- NOTE: {
3885
- NAMES: {
3886
- SINGULAR: "Note",
3887
- PLURAL: "Notes"
3888
- },
3889
- ICONS: {
3890
- DEFAULT: NotebookText,
3891
- NEW: NotebookPen
3484
+ tooltipContent,
3485
+ tooltipSide,
3486
+ cn(baseClasses, interactiveClasses),
3487
+ { "data-testid": testId }
3488
+ );
3892
3489
  }
3893
- },
3894
- USER: {
3895
- NAMES: {
3896
- SINGULAR: "User",
3897
- PLURAL: "Users"
3898
- },
3899
- ICONS: {
3900
- DEFAULT: User,
3901
- NEW: UserPlus,
3902
- SETTINGS: Settings2
3490
+ return tooltipWrap(
3491
+ mainContent,
3492
+ tooltipContent,
3493
+ tooltipSide,
3494
+ cn(
3495
+ baseClasses,
3496
+ onClick && !disabled ? interactiveClasses : "",
3497
+ disabled ? disabledClasses : "",
3498
+ highlight && highlightClasses
3499
+ ),
3500
+ {
3501
+ type: "button",
3502
+ ref,
3503
+ onClick: onClick && !disabled ? onClick : void 0,
3504
+ disabled: disabled || void 0,
3505
+ "data-testid": testId
3506
+ }
3507
+ );
3508
+ }
3509
+ if (href) {
3510
+ return /* @__PURE__ */ jsx(
3511
+ "a",
3512
+ {
3513
+ ref,
3514
+ href,
3515
+ target: "_blank",
3516
+ rel: "noopener noreferrer",
3517
+ className: cn(baseClasses, interactiveClasses),
3518
+ "data-testid": testId,
3519
+ onClick,
3520
+ children: mainContent
3521
+ }
3522
+ );
3523
+ }
3524
+ if (onClick) {
3525
+ return /* @__PURE__ */ jsx(
3526
+ "button",
3527
+ {
3528
+ ref,
3529
+ type: "button",
3530
+ onClick: disabled ? void 0 : onClick,
3531
+ disabled,
3532
+ className: cn(
3533
+ baseClasses,
3534
+ disabled ? disabledClasses : interactiveClasses,
3535
+ highlight && highlightClasses
3536
+ ),
3537
+ "data-testid": testId,
3538
+ children: mainContent
3539
+ }
3540
+ );
3541
+ }
3542
+ return /* @__PURE__ */ jsx(
3543
+ "span",
3544
+ {
3545
+ ref,
3546
+ className: cn(baseClasses, highlight && highlightClasses),
3547
+ "data-testid": testId,
3548
+ children: mainContent
3903
3549
  }
3904
- },
3905
- WORKSPACEUSER: {
3906
- NAMES: {
3907
- SINGULAR: "Member",
3908
- PLURAL: "Members"
3909
- },
3910
- ICONS: {
3911
- DEFAULT: User,
3912
- PLURAL: Users,
3913
- NEW: UserPlus,
3914
- SETTINGS: Settings2
3550
+ );
3551
+ });
3552
+ function getDocumentTitle(document2, defaultValue = "") {
3553
+ if (!document2) return defaultValue;
3554
+ return document2.doc_metadata?.title || document2.file_name || defaultValue;
3555
+ }
3556
+ var IMAGE_FILE_TYPES = /* @__PURE__ */ new Set(["png", "jpg", "jpeg", "gif", "bmp", "tiff", "webp"]);
3557
+ function isImageDocument(document2) {
3558
+ return !!document2?.file_type && IMAGE_FILE_TYPES.has(document2.file_type.toLowerCase());
3559
+ }
3560
+ var MAX_LABEL_CHARS = 30;
3561
+ function clampLabel(text) {
3562
+ return text.length > MAX_LABEL_CHARS ? `${text.slice(0, MAX_LABEL_CHARS).trimEnd()}\u2026` : text;
3563
+ }
3564
+ var IMAGE_EXTENSIONS = /* @__PURE__ */ new Set(["jpg", "jpeg", "png", "gif", "bmp", "tiff", "tif", "webp"]);
3565
+ var VIDEO_EXTENSIONS = /* @__PURE__ */ new Set(["mp4", "mpeg", "mpg", "webm", "mov", "avi", "mkv"]);
3566
+ var AUDIO_EXTENSIONS = /* @__PURE__ */ new Set(["mp3", "wav", "m4a", "aac", "ogg", "flac"]);
3567
+ var EMAIL_EXTENSIONS = /* @__PURE__ */ new Set(["eml", "msg"]);
3568
+ var DOCX_EXTENSIONS = /* @__PURE__ */ new Set(["doc", "docx", "odt", "rtf"]);
3569
+ var XLSX_EXTENSIONS = /* @__PURE__ */ new Set(["xls", "xlsx", "csv", "ods"]);
3570
+ var HTML_EXTENSIONS = /* @__PURE__ */ new Set(["html", "htm", "mhtml"]);
3571
+ var TEXT_EXTENSIONS = /* @__PURE__ */ new Set([
3572
+ "txt",
3573
+ "text",
3574
+ "md",
3575
+ "markdown",
3576
+ "log",
3577
+ "json",
3578
+ "xml",
3579
+ "yaml",
3580
+ "yml"
3581
+ ]);
3582
+ function getDocIcon(fileName, iconSize = 14) {
3583
+ const ext = fileName?.split(".").pop()?.toLowerCase();
3584
+ if (ext && VIDEO_EXTENSIONS.has(ext)) return /* @__PURE__ */ jsx(VidIcon, { size: iconSize, className: "flex-shrink-0" });
3585
+ if (ext && AUDIO_EXTENSIONS.has(ext)) return /* @__PURE__ */ jsx(AudIcon, { size: iconSize, className: "flex-shrink-0" });
3586
+ if (ext && IMAGE_EXTENSIONS.has(ext)) return /* @__PURE__ */ jsx(ImgIcon, { size: iconSize, className: "flex-shrink-0" });
3587
+ if (ext && EMAIL_EXTENSIONS.has(ext)) return /* @__PURE__ */ jsx(EmlIcon, { size: iconSize, className: "flex-shrink-0" });
3588
+ if (ext && DOCX_EXTENSIONS.has(ext)) return /* @__PURE__ */ jsx(DocIcon, { size: iconSize, className: "flex-shrink-0" });
3589
+ if (ext && XLSX_EXTENSIONS.has(ext)) return /* @__PURE__ */ jsx(XlsIcon, { size: iconSize, className: "flex-shrink-0" });
3590
+ if (ext && HTML_EXTENSIONS.has(ext)) return /* @__PURE__ */ jsx(HtmlIcon, { size: iconSize, className: "flex-shrink-0" });
3591
+ if (ext && TEXT_EXTENSIONS.has(ext)) return /* @__PURE__ */ jsx(TxtIcon, { size: iconSize, className: "flex-shrink-0" });
3592
+ return /* @__PURE__ */ jsx(PdfIcon, { size: iconSize, className: "flex-shrink-0" });
3593
+ }
3594
+ function DocumentEntity({
3595
+ doc,
3596
+ icon,
3597
+ size = "sm",
3598
+ labelMaxWidth,
3599
+ labelClassName,
3600
+ onClick,
3601
+ onIconClick,
3602
+ viewing,
3603
+ iconBadge,
3604
+ status,
3605
+ actions,
3606
+ tooltipContent,
3607
+ className,
3608
+ fullWidth,
3609
+ noClamp,
3610
+ "data-testid": testId
3611
+ }) {
3612
+ const title = getDocumentTitle(doc);
3613
+ const ext = doc.file_name?.split(".").pop()?.toLowerCase();
3614
+ const iconSize = size === "base" ? 16 : 14;
3615
+ const eyeSizeClass = size === "base" ? "h-4 w-4" : "h-3.5 w-3.5";
3616
+ const baseIcon = icon ?? getDocIcon(doc.file_name, iconSize);
3617
+ const displayIcon = viewing || iconBadge ? /* @__PURE__ */ jsxs("span", { className: "relative inline-flex flex-shrink-0 items-center justify-center", children: [
3618
+ viewing ? /* @__PURE__ */ jsx(Eye, { className: cn("text-primary-foreground", eyeSizeClass) }) : baseIcon,
3619
+ iconBadge
3620
+ ] }) : baseIcon;
3621
+ const defaultTooltip = /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1 text-xs max-w-[440px]", children: [
3622
+ doc.folder && // `flex-wrap` so a deep folder path wraps WITHIN the balloon instead of
3623
+ // spilling out of it (each path segment is atomic and wraps as a unit;
3624
+ // `min-w-0` + `break-all` lets a single over-long segment break too).
3625
+ /* @__PURE__ */ jsxs("span", { className: "flex flex-wrap items-center gap-0.5 text-muted-foreground", children: [
3626
+ /* @__PURE__ */ jsx(FolderOpen, { className: "h-3 w-3 text-yellow-600 shrink-0" }),
3627
+ doc.folder.split("/").map((part, i, arr) => /* @__PURE__ */ jsxs("span", { className: "flex min-w-0 items-center gap-0.5", children: [
3628
+ i > 0 && /* @__PURE__ */ jsx("span", { className: "text-muted-foreground/50 mx-0.5", children: "/" }),
3629
+ /* @__PURE__ */ jsx("span", { className: `break-all ${i < arr.length - 1 ? "text-muted-foreground/70" : ""}`, children: part })
3630
+ ] }, i))
3631
+ ] }),
3632
+ /* @__PURE__ */ jsxs("span", { className: "font-medium break-words", children: [
3633
+ title,
3634
+ ext ? `.${ext}` : ""
3635
+ ] })
3636
+ ] });
3637
+ return /* @__PURE__ */ jsx(
3638
+ EntityPill,
3639
+ {
3640
+ icon: displayIcon,
3641
+ size,
3642
+ label: fullWidth || noClamp ? title : clampLabel(title),
3643
+ labelMaxWidth: labelMaxWidth ?? "max-w-[140px]",
3644
+ labelClassName,
3645
+ secondaryText: status,
3646
+ fullWidth,
3647
+ onClick,
3648
+ onIconClick,
3649
+ moreContent: actions,
3650
+ className,
3651
+ highlight: viewing,
3652
+ "data-testid": testId,
3653
+ tooltipContent: tooltipContent ?? defaultTooltip
3915
3654
  }
3916
- },
3917
- CONTACT: {
3918
- NAMES: {
3919
- SINGULAR: "Contact",
3920
- PLURAL: "Contacts"
3921
- },
3922
- ICONS: {
3923
- // A starred person, not an address-book card: contacts here are the
3924
- // people you talk to, and the star reads as "your people".
3925
- DEFAULT: UserStar,
3926
- NEW: UserPlus
3655
+ );
3656
+ }
3657
+ var TAG_TYPE_LABELS = {
3658
+ checkbox: "Checkbox",
3659
+ select: "Select",
3660
+ number: "Number",
3661
+ text: "Text",
3662
+ folder: "Folder",
3663
+ search: "Saved Search",
3664
+ date: "Date",
3665
+ assistant: "AI Assistant"
3666
+ };
3667
+ var TAG_TYPE_ICONS = {
3668
+ checkbox: SquareCheckBig,
3669
+ select: List,
3670
+ number: Hash,
3671
+ text: NotebookPen,
3672
+ folder: Folder,
3673
+ search: Search,
3674
+ date: Calendar,
3675
+ assistant: Bot
3676
+ };
3677
+ function getTagTypeIcon(type) {
3678
+ return TAG_TYPE_ICONS[type ?? "text"] || NotebookPen;
3679
+ }
3680
+ function getTagTypeLabel(type) {
3681
+ const t = type ?? "text";
3682
+ return TAG_TYPE_LABELS[t] || t;
3683
+ }
3684
+ var BASE_COLORS = {
3685
+ "0": "#10b981",
3686
+ "1": "#3b82f6",
3687
+ "2": "#8b5cf6",
3688
+ "3": "#f43f5e",
3689
+ "4": "#f59e0b",
3690
+ "5": "#84cc16",
3691
+ "6": "#a855f7",
3692
+ "7": "#06b6d4",
3693
+ "8": "#f97316",
3694
+ "9": "#14b8a6",
3695
+ a: "#ef4444",
3696
+ b: "#6366f1",
3697
+ c: "#ec4899",
3698
+ d: "#22c55e",
3699
+ e: "#eab308",
3700
+ f: "#0ea5e9"
3701
+ };
3702
+ function getEntityColor(entityId) {
3703
+ return BASE_COLORS[entityId[4]] || BASE_COLORS["0"];
3704
+ }
3705
+ function TagEntity({
3706
+ tag,
3707
+ size = "md",
3708
+ className = "",
3709
+ onClick,
3710
+ showTooltip = true,
3711
+ tooltipContent
3712
+ }) {
3713
+ const tagType = tag.tag_type?.type ?? "text";
3714
+ const iconSize = size === "sm" ? 12 : size === "md" ? 14 : 16;
3715
+ const Icon2 = getTagTypeIcon(tagType);
3716
+ const sizeClasses2 = {
3717
+ sm: "p-0.5",
3718
+ md: "p-1",
3719
+ lg: "p-1.5"
3720
+ };
3721
+ const tagColor = tag.color ?? getEntityColor(tag.external_id);
3722
+ const iconElement = /* @__PURE__ */ jsx(
3723
+ "span",
3724
+ {
3725
+ className: `inline-flex items-center justify-center rounded-md text-white flex-shrink-0 ${sizeClasses2[size]}`,
3726
+ style: { backgroundColor: tagColor },
3727
+ children: /* @__PURE__ */ jsx(Icon2, { size: iconSize, className: "flex-shrink-0" })
3927
3728
  }
3928
- },
3929
- TASK: {
3930
- NAMES: {
3931
- SINGULAR: "Job",
3932
- PLURAL: "Jobs"
3933
- },
3934
- ICONS: {
3935
- DEFAULT: ClipboardList
3729
+ );
3730
+ const pillSize = size === "lg" ? "base" : "sm";
3731
+ const defaultTooltip = /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2", children: [
3732
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
3733
+ /* @__PURE__ */ jsx(
3734
+ "span",
3735
+ {
3736
+ className: "inline-flex items-center justify-center rounded-md text-white p-1",
3737
+ style: { backgroundColor: tagColor },
3738
+ children: /* @__PURE__ */ jsx(Icon2, { size: 16 })
3739
+ }
3740
+ ),
3741
+ /* @__PURE__ */ jsx("span", { className: "font-medium text-sm", children: tag.name })
3742
+ ] }),
3743
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1.5 text-sm", children: [
3744
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
3745
+ /* @__PURE__ */ jsx("span", { className: "text-muted-foreground", children: "Type:" }),
3746
+ /* @__PURE__ */ jsx("span", { children: getTagTypeLabel(tagType) })
3747
+ ] }),
3748
+ tag.doctag_count != null && /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
3749
+ /* @__PURE__ */ jsx("span", { className: "text-muted-foreground", children: "Documents:" }),
3750
+ /* @__PURE__ */ jsx(Badge, { variant: "secondary", className: "h-5 min-w-[20px] justify-center", children: tag.doctag_count ?? 0 })
3751
+ ] }),
3752
+ tag.shared != null && /* @__PURE__ */ jsx("div", { className: "flex items-center gap-2", children: /* @__PURE__ */ jsx("span", { className: "text-muted-foreground", children: tag.shared ? "Shared" : "Private" }) })
3753
+ ] })
3754
+ ] });
3755
+ const resolvedTooltip = showTooltip ? tooltipContent ?? defaultTooltip : void 0;
3756
+ return /* @__PURE__ */ jsx(
3757
+ EntityPill,
3758
+ {
3759
+ icon: iconElement,
3760
+ label: tag.name,
3761
+ size: pillSize,
3762
+ shape: "rounded",
3763
+ labelMaxWidth: "max-w-[180px]",
3764
+ tooltipContent: resolvedTooltip,
3765
+ onClick,
3766
+ className,
3767
+ "data-testid": `tag-entity-${tag.external_id}`
3936
3768
  }
3769
+ );
3770
+ }
3771
+
3772
+ // src/entities/tag-kinds.ts
3773
+ var KIND_ENTITY = {
3774
+ label: "LABEL",
3775
+ annotation: "ANNOTATION",
3776
+ search: "SAVED_SEARCH",
3777
+ issue: "ISSUE",
3778
+ person: "PERSON",
3779
+ organisation: "ORGANISATION"
3780
+ };
3781
+ function tagKindTitle(kind, { plural = false } = {}) {
3782
+ return getEntityLabel(KIND_ENTITY[kind], plural ? "PLURAL" : "SINGULAR");
3783
+ }
3784
+ function tagKindNouns(kind) {
3785
+ return {
3786
+ singular: tagKindTitle(kind).toLowerCase(),
3787
+ plural: tagKindTitle(kind, { plural: true }).toLowerCase()
3788
+ };
3789
+ }
3790
+ var VARIANT_STYLES = {
3791
+ "mine-paid": {
3792
+ pill: "text-primary",
3793
+ icon: "text-primary"
3937
3794
  },
3938
- PROJECT: {
3939
- NAMES: {
3940
- SINGULAR: "Project",
3941
- PLURAL: "Projects"
3942
- },
3943
- ICONS: {
3944
- DEFAULT: CreditCard
3945
- }
3795
+ other: {
3796
+ pill: "text-secondary",
3797
+ icon: "text-secondary"
3946
3798
  },
3947
- SKILL: {
3948
- NAMES: {
3949
- SINGULAR: "Skill",
3950
- PLURAL: "Skills"
3951
- },
3952
- ICONS: {
3953
- DEFAULT: Wrench
3954
- }
3799
+ "mine-free": {
3800
+ pill: "text-muted-foreground",
3801
+ icon: "text-muted-foreground"
3955
3802
  },
3956
- ACCOUNT: {
3957
- NAMES: {
3958
- SINGULAR: "Account"
3959
- },
3960
- ICONS: {
3961
- DEFAULT: CircleUserRound
3803
+ common: {
3804
+ pill: "",
3805
+ icon: "text-muted-foreground"
3806
+ }
3807
+ };
3808
+ function resolveVariant(relation, paid, hasCollaborators) {
3809
+ if (relation === "common") return "common";
3810
+ if (relation === "other") return "other";
3811
+ if (relation === "mine") return paid ? "mine-paid" : "mine-free";
3812
+ if (paid) return hasCollaborators ? "other" : "mine-paid";
3813
+ return "mine-free";
3814
+ }
3815
+ function ProjectEntity({
3816
+ name,
3817
+ label,
3818
+ icon,
3819
+ subscription = "none",
3820
+ hasCollaborators = false,
3821
+ size = "sm",
3822
+ className,
3823
+ onClick,
3824
+ relation,
3825
+ isPaid,
3826
+ tooltipContent
3827
+ }) {
3828
+ const paid = isPaid ?? (subscription === "active" || subscription === "past_due" || subscription === "dev");
3829
+ const variant = resolveVariant(relation, paid, hasCollaborators);
3830
+ const { pill, icon: iconClass } = VARIANT_STYLES[variant];
3831
+ const iconSizeClass = size === "base" ? "h-4 w-4" : "h-3.5 w-3.5";
3832
+ const iconNode = icon ?? /* @__PURE__ */ jsx(CreditCard, { className: cn(iconSizeClass, iconClass) });
3833
+ return /* @__PURE__ */ jsx(
3834
+ EntityPill,
3835
+ {
3836
+ icon: iconNode,
3837
+ label: label ?? name,
3838
+ size,
3839
+ shape: "rounded",
3840
+ className: cn(pill, className),
3841
+ onClick,
3842
+ tooltipContent
3962
3843
  }
3963
- },
3964
- NOTIFICATIONS: {
3965
- NAMES: {
3966
- SINGULAR: "Activity",
3967
- PLURAL: "Activities"
3968
- },
3969
- ICONS: {
3970
- DEFAULT: Bell
3844
+ );
3845
+ }
3846
+ function VerifiedBadge({ className, label = "Identity verified" }) {
3847
+ return /* @__PURE__ */ jsx(
3848
+ BadgeCheck,
3849
+ {
3850
+ role: "img",
3851
+ "aria-label": label,
3852
+ "data-testid": "verified-badge",
3853
+ className: cn("h-3.5 w-3.5 shrink-0 text-sky-500", className),
3854
+ children: /* @__PURE__ */ jsx("title", { children: label })
3971
3855
  }
3972
- },
3973
- MESSAGE: {
3974
- NAMES: {
3975
- SINGULAR: "Message",
3976
- PLURAL: "Messages"
3977
- },
3978
- ICONS: {
3979
- DEFAULT: MessageSquare
3856
+ );
3857
+ }
3858
+ var sizeClasses = {
3859
+ xs: "h-5 w-5",
3860
+ sm: "h-6 w-6",
3861
+ md: "h-8 w-8",
3862
+ lg: "h-10 w-10"
3863
+ };
3864
+ var textSizeClasses = {
3865
+ xs: "text-xs",
3866
+ sm: "text-xs",
3867
+ md: "text-xs",
3868
+ lg: "text-sm"
3869
+ };
3870
+ var presenceDotClasses = {
3871
+ xs: "w-2 h-2 border",
3872
+ sm: "w-2.5 h-2.5 border",
3873
+ md: "w-3 h-3 border-2",
3874
+ lg: "w-3.5 h-3.5 border-2"
3875
+ };
3876
+ var presencePositionClasses = {
3877
+ xs: "-right-1 bottom-0",
3878
+ sm: "-right-1 bottom-0",
3879
+ md: "-right-1.5 -bottom-0.5",
3880
+ lg: "-right-1.5 -bottom-0.5"
3881
+ };
3882
+ var PRESENCE_LABELS = {
3883
+ connected: "Online",
3884
+ connecting: "Connecting",
3885
+ disconnected: "Offline",
3886
+ error: "Connection problem",
3887
+ hidden: "Status hidden"
3888
+ };
3889
+ var presenceColorClasses = {
3890
+ connected: "bg-status-online",
3891
+ connecting: "bg-status-connecting",
3892
+ disconnected: "bg-status-away",
3893
+ error: "bg-status-busy",
3894
+ hidden: "bg-status-offline"
3895
+ };
3896
+ var UserEntity = memo(function UserEntity2({
3897
+ size = "md",
3898
+ variant = "pill",
3899
+ className,
3900
+ showTooltip = true,
3901
+ interactive = true,
3902
+ hasUnreadMessages = false,
3903
+ initials = "",
3904
+ displayName = "",
3905
+ picture,
3906
+ avatarImageClassName,
3907
+ colorClass = "",
3908
+ isAgent = false,
3909
+ isVerified = false,
3910
+ agentStyle,
3911
+ avatarStyle,
3912
+ isMe = false,
3913
+ displayStatus,
3914
+ onClick,
3915
+ tooltipContent,
3916
+ empty = false
3917
+ }) {
3918
+ if (empty) {
3919
+ return /* @__PURE__ */ jsx(
3920
+ Avatar,
3921
+ {
3922
+ className: cn(sizeClasses[size], "border border-border", className),
3923
+ "data-testid": "user-entity",
3924
+ children: /* @__PURE__ */ jsx(AvatarFallback, { className: "bg-status-empty text-muted-foreground text-xs font-semibold", children: "?" })
3925
+ }
3926
+ );
3927
+ }
3928
+ const agentBadge = isAgent ? /* @__PURE__ */ jsx(ArbiBotHeadIcon, { className: "w-3.5 h-3.5 text-muted-foreground" }) : void 0;
3929
+ const canMessage = interactive && !isMe && !isAgent;
3930
+ const showUnread = hasUnreadMessages && !isMe && !isAgent;
3931
+ const surfaceStyle = avatarStyle ?? agentStyle;
3932
+ const avatarCore = /* @__PURE__ */ jsxs(
3933
+ Avatar,
3934
+ {
3935
+ className: cn(
3936
+ sizeClasses[size],
3937
+ isAgent ? "rounded-full border-2 border-dashed" : "border border-white"
3938
+ ),
3939
+ style: surfaceStyle,
3940
+ "data-testid": "user-entity",
3941
+ children: [
3942
+ picture && /* @__PURE__ */ jsx(AvatarImage, { src: picture, alt: initials, className: avatarImageClassName }),
3943
+ /* @__PURE__ */ jsx(
3944
+ AvatarFallback,
3945
+ {
3946
+ className: cn(
3947
+ textSizeClasses[size],
3948
+ "font-semibold leading-none",
3949
+ isAgent ? "rounded-full bg-transparent" : `text-white ${colorClass}`
3950
+ ),
3951
+ style: surfaceStyle,
3952
+ children: initials
3953
+ }
3954
+ )
3955
+ ]
3980
3956
  }
3981
- },
3982
- NOTIFICATION: {
3983
- NAMES: {
3984
- SINGULAR: "Notification",
3985
- PLURAL: "Notifications"
3986
- },
3987
- ICONS: {
3988
- DEFAULT: Bell
3957
+ );
3958
+ const statusDot = showUnread || displayStatus ? /* @__PURE__ */ jsx(
3959
+ "span",
3960
+ {
3961
+ className: cn(
3962
+ "absolute rounded-full border-white",
3963
+ presenceDotClasses[size],
3964
+ presencePositionClasses[size],
3965
+ !showUnread && displayStatus ? presenceColorClasses[displayStatus] : ""
3966
+ ),
3967
+ style: showUnread ? { backgroundColor: "#00adef" } : void 0,
3968
+ "data-testid": "user-entity-presence",
3969
+ role: "img",
3970
+ "aria-label": showUnread ? "Unread messages" : PRESENCE_LABELS[displayStatus],
3971
+ title: showUnread ? "Unread messages" : PRESENCE_LABELS[displayStatus]
3989
3972
  }
3990
- },
3991
- APP: {
3992
- NAMES: {
3993
- SINGULAR: "Application",
3994
- PLURAL: "Applications"
3995
- },
3996
- ICONS: {
3997
- DEFAULT: LayoutGrid,
3998
- HOME: LayoutGrid,
3999
- LOGOUT: LogOut,
4000
- UPLOAD: Upload
3973
+ ) : null;
3974
+ const avatarElement = statusDot ? /* @__PURE__ */ jsxs(
3975
+ "div",
3976
+ {
3977
+ className: cn(
3978
+ "relative inline-block",
3979
+ sizeClasses[size],
3980
+ variant === "pill" ? "" : className
3981
+ ),
3982
+ children: [
3983
+ avatarCore,
3984
+ statusDot
3985
+ ]
4001
3986
  }
4002
- },
4003
- HELP: {
4004
- NAMES: {
4005
- SINGULAR: "Help",
4006
- PLURAL: "Help"
4007
- },
4008
- ICONS: {
4009
- DEFAULT: MessageSquareLock,
4010
- DOCS: BookOpen,
4011
- FAQ: FileQuestion,
4012
- ABOUT: Info
3987
+ ) : /* @__PURE__ */ jsx("div", { className: cn("inline-block", variant === "pill" ? "" : className), children: avatarCore });
3988
+ const pillAvatar = (
3989
+ // shrink-0: when the pill is squeezed the NAME truncates away — the avatar
3990
+ // must never collapse under it and overflow onto neighbouring text.
3991
+ /* @__PURE__ */ jsxs("span", { className: cn("relative inline-block shrink-0", sizeClasses[size]), children: [
3992
+ /* @__PURE__ */ jsx("span", { className: cn("block transition-opacity", canMessage && "group-hover/pill:opacity-0"), children: avatarCore }),
3993
+ canMessage && /* @__PURE__ */ jsx(
3994
+ "span",
3995
+ {
3996
+ "aria-hidden": true,
3997
+ className: "absolute inset-0 flex items-center justify-center rounded-full bg-muted text-foreground opacity-0 transition-opacity group-hover/pill:opacity-100",
3998
+ children: /* @__PURE__ */ jsx(MessageCircleMore, { className: size === "xs" ? "h-3 w-3" : "h-4 w-4" })
3999
+ }
4000
+ ),
4001
+ statusDot
4002
+ ] })
4003
+ );
4004
+ const resolvedTooltip = showTooltip ? tooltipContent : void 0;
4005
+ if (variant === "pill") {
4006
+ const row = /* @__PURE__ */ jsxs(Fragment, { children: [
4007
+ pillAvatar,
4008
+ displayName && /* @__PURE__ */ jsx("span", { className: "min-w-0 max-w-[320px] truncate text-sm leading-tight", children: displayName }),
4009
+ isVerified && !isAgent && /* @__PURE__ */ jsx(VerifiedBadge, {}),
4010
+ agentBadge
4011
+ ] });
4012
+ const rowClass = "group/pill inline-flex min-w-0 items-center gap-2";
4013
+ const clickable = interactive && !!onClick;
4014
+ const clickableClass = "relative cursor-pointer rounded-md px-1 py-0.5 -mx-1 transition-colors hover:bg-muted/60 pointer-coarse:after:absolute pointer-coarse:after:inset-x-0 pointer-coarse:after:-inset-y-3 pointer-coarse:after:content-['']";
4015
+ if (resolvedTooltip) {
4016
+ return /* @__PURE__ */ jsxs(Tooltip, { children: [
4017
+ /* @__PURE__ */ jsx(
4018
+ TooltipTrigger,
4019
+ {
4020
+ type: "button",
4021
+ onClick: clickable ? onClick : void 0,
4022
+ onFocusCapture: (e) => e.stopPropagation(),
4023
+ className: cn(rowClass, clickable && clickableClass, className),
4024
+ "data-testid": "user-entity-pill",
4025
+ children: row
4026
+ }
4027
+ ),
4028
+ /* @__PURE__ */ jsx(TooltipContent, { className: "p-2", children: resolvedTooltip })
4029
+ ] });
4013
4030
  }
4014
- },
4015
- USERSHIELD: {
4016
- NAMES: {
4017
- SINGULAR: "User Shield",
4018
- PLURAL: "User Shields"
4019
- },
4020
- ICONS: {
4021
- DEFAULT: MessageSquareLock
4031
+ if (clickable) {
4032
+ return /* @__PURE__ */ jsx(
4033
+ "button",
4034
+ {
4035
+ type: "button",
4036
+ onClick,
4037
+ className: cn(rowClass, clickableClass, className),
4038
+ "data-testid": "user-entity-pill",
4039
+ children: row
4040
+ }
4041
+ );
4022
4042
  }
4043
+ return /* @__PURE__ */ jsx("span", { className: cn(rowClass, className), "data-testid": "user-entity-pill", children: row });
4023
4044
  }
4024
- };
4025
- function configureEntityRegistry(overrides) {
4026
- for (const [type, def] of Object.entries(overrides)) {
4027
- const target = ENTITY_MAPPINGS[type];
4028
- if (!target) continue;
4029
- if (def?.NAMES) Object.assign(target.NAMES, def.NAMES);
4030
- if (def?.ICONS) Object.assign(target.ICONS, def.ICONS);
4045
+ if (showTooltip) {
4046
+ return /* @__PURE__ */ jsxs(Tooltip, { children: [
4047
+ /* @__PURE__ */ jsx(
4048
+ TooltipTrigger,
4049
+ {
4050
+ onFocusCapture: (e) => e.stopPropagation(),
4051
+ className: "touch-hit inline-flex",
4052
+ children: avatarElement
4053
+ }
4054
+ ),
4055
+ /* @__PURE__ */ jsx(TooltipContent, { className: "p-2", children: tooltipContent })
4056
+ ] });
4031
4057
  }
4058
+ return avatarElement;
4059
+ });
4060
+ function AgentBadge({ className }) {
4061
+ return /* @__PURE__ */ jsxs(
4062
+ "span",
4063
+ {
4064
+ "data-testid": "agent-badge",
4065
+ className: cn(
4066
+ "inline-flex shrink-0 items-center gap-1 rounded-full border border-ai-accent/50",
4067
+ "bg-ai-accent-soft px-2 py-0.5 text-xs font-bold uppercase tracking-wider text-ai-accent",
4068
+ className
4069
+ ),
4070
+ children: [
4071
+ /* @__PURE__ */ jsx(ArbiBotHeadIcon, { size: 14, className: "text-ai-accent" }),
4072
+ "Agent"
4073
+ ]
4074
+ }
4075
+ );
4032
4076
  }
4033
- var getEntityIcon = (entityType, variant = "DEFAULT") => {
4034
- const icons = ENTITY_MAPPINGS[entityType]?.ICONS;
4035
- return icons?.[variant] || icons?.DEFAULT;
4036
- };
4037
- var getEntityLabel = (entityType, form = "SINGULAR") => {
4038
- const entityMapping = ENTITY_MAPPINGS[entityType];
4039
- if (!entityMapping) return "";
4040
- const names = entityMapping.NAMES;
4041
- const singularName = names.SINGULAR || "";
4042
- if (form === "NEW") return names.NEW !== void 0 ? names.NEW : "New " + singularName;
4043
- if (form === "SHORT")
4044
- return names.SHORT !== void 0 ? names.SHORT : singularName.substring(0, 3) + ".";
4045
- if (form === "PLURAL") return names.PLURAL !== void 0 ? names.PLURAL : singularName + "s";
4046
- return singularName;
4047
- };
4048
- var EntityIcon = ({ entityType, variant = "DEFAULT", ...props }) => {
4049
- const IconComponent = getEntityIcon(entityType, variant);
4050
- return IconComponent ? React__default.createElement(IconComponent, props) : null;
4051
- };
4052
- var VISIBILITY_ICONS = {
4053
- PRIVATE: MessageSquareLock,
4054
- SHARED: Users
4077
+ var PRESENCE_WORDS = {
4078
+ connected: "Online",
4079
+ connecting: "Connecting",
4080
+ disconnected: "Offline",
4081
+ error: "Connection problem",
4082
+ hidden: null
4055
4083
  };
4056
- var VisibilityIcon = ({
4057
- isShared,
4058
- className,
4059
- ...props
4060
- }) => {
4061
- const IconComponent = isShared ? VISIBILITY_ICONS.SHARED : VISIBILITY_ICONS.PRIVATE;
4062
- return React__default.createElement(IconComponent, {
4063
- ...props,
4064
- className: [isShared ? "text-secondary" : "text-primary", className].filter(Boolean).join(" ")
4065
- });
4084
+ function PresenceLabel({
4085
+ status,
4086
+ className
4087
+ }) {
4088
+ if (!status) return null;
4089
+ const word = PRESENCE_WORDS[status];
4090
+ if (!word) return null;
4091
+ const online = status === "connected";
4092
+ return /* @__PURE__ */ jsxs(
4093
+ "span",
4094
+ {
4095
+ "data-testid": "presence-label",
4096
+ className: cn("inline-flex shrink-0 items-center gap-1 text-xs", className),
4097
+ children: [
4098
+ /* @__PURE__ */ jsx(
4099
+ "span",
4100
+ {
4101
+ className: cn(
4102
+ "size-1.5 rounded-full",
4103
+ online ? "bg-status-online" : "bg-muted-foreground/50"
4104
+ ),
4105
+ "aria-hidden": "true"
4106
+ }
4107
+ ),
4108
+ /* @__PURE__ */ jsx("span", { className: online ? "font-medium text-status-online" : "text-muted-foreground", children: word })
4109
+ ]
4110
+ }
4111
+ );
4112
+ }
4113
+ var PACKAGE_BADGE_VARIANTS = [
4114
+ "default",
4115
+ "accent",
4116
+ "secondary",
4117
+ "destructive",
4118
+ "outline"
4119
+ ];
4120
+ function isPackageBadgeVariant(v) {
4121
+ return PACKAGE_BADGE_VARIANTS.some((known) => known === v);
4122
+ }
4123
+ function PackageStatusBadge({ variant, ...rest }) {
4124
+ return /* @__PURE__ */ jsx(Badge, { variant: isPackageBadgeVariant(variant) ? variant : "outline", ...rest });
4125
+ }
4126
+ var registry = {
4127
+ variants: {},
4128
+ fallback: "outline",
4129
+ Badge: PackageStatusBadge
4066
4130
  };
4131
+ function configureStatusRegistry(map, opts) {
4132
+ Object.assign(registry.variants, map);
4133
+ if (opts?.fallback) registry.fallback = opts.fallback;
4134
+ if (opts?.Badge) registry.Badge = opts.Badge;
4135
+ }
4136
+ function getStatusVariant(status) {
4137
+ return registry.variants[status] ?? registry.fallback;
4138
+ }
4139
+ function StatusPill({ status, label, variant, className, testId }) {
4140
+ const Badge2 = registry.Badge;
4141
+ return /* @__PURE__ */ jsx(Badge2, { variant: variant ?? getStatusVariant(status), className, "data-testid": testId, children: label ?? status });
4142
+ }
4143
+ var RAG_LABELS = { red: "At risk", amber: "Attention", green: "On track" };
4144
+ function configureRagLabels(labels) {
4145
+ RAG_LABELS = { ...RAG_LABELS, ...labels };
4146
+ }
4147
+ function RagDot({
4148
+ rag,
4149
+ withLabel,
4150
+ className
4151
+ }) {
4152
+ const color = rag === "red" ? "bg-destructive" : rag === "amber" ? "bg-warning" : "bg-success";
4153
+ return /* @__PURE__ */ jsxs("span", { className: cn("inline-flex items-center gap-1.5", className), "data-testid": `rag-${rag}`, children: [
4154
+ /* @__PURE__ */ jsx("span", { className: cn("size-2 rounded-full", color) }),
4155
+ withLabel && /* @__PURE__ */ jsx("span", { className: "text-xs text-muted-foreground", children: RAG_LABELS[rag] })
4156
+ ] });
4157
+ }
4067
4158
 
4068
4159
  // src/entities/colors.ts
4069
4160
  var OPACITY_LIGHT = 0.15;
@@ -4189,6 +4280,209 @@ function agentAvatarColors(bgColorClass) {
4189
4280
  const color = BG_TO_COLOR[bgColorClass] || "#047857";
4190
4281
  return { borderColor: color, color };
4191
4282
  }
4283
+
4284
+ // src/entities/media-type.ts
4285
+ function getDottedExtension(fileName) {
4286
+ if (!fileName) return "";
4287
+ return fileName.substring(fileName.lastIndexOf(".")).toLowerCase();
4288
+ }
4289
+ var DOWNLOAD_ONLY_EXTENSIONS = /* @__PURE__ */ new Set([
4290
+ ".zip",
4291
+ ".rar",
4292
+ ".7z",
4293
+ ".tar",
4294
+ ".gz",
4295
+ ".exe",
4296
+ ".bin",
4297
+ ".dmg",
4298
+ ".iso",
4299
+ ".apk",
4300
+ ".msi",
4301
+ ".dll",
4302
+ ".so",
4303
+ ".psd",
4304
+ ".ai",
4305
+ ".sketch"
4306
+ ]);
4307
+ var IMAGE_EXTENSIONS2 = /* @__PURE__ */ new Set([
4308
+ ".jpg",
4309
+ ".jpeg",
4310
+ ".png",
4311
+ ".gif",
4312
+ ".bmp",
4313
+ ".tiff",
4314
+ ".tif",
4315
+ ".webp"
4316
+ ]);
4317
+ var VIDEO_EXTENSIONS2 = /* @__PURE__ */ new Set([".mp4", ".mpeg", ".mpg", ".webm", ".mov", ".avi", ".mkv"]);
4318
+ var AUDIO_EXTENSIONS2 = /* @__PURE__ */ new Set([".mp3", ".wav", ".m4a", ".aac", ".ogg", ".flac"]);
4319
+ function isImageFile(fileName) {
4320
+ return IMAGE_EXTENSIONS2.has(getDottedExtension(fileName));
4321
+ }
4322
+ function isVideoFile(fileName) {
4323
+ return VIDEO_EXTENSIONS2.has(getDottedExtension(fileName));
4324
+ }
4325
+ function isAudioFile(fileName) {
4326
+ return AUDIO_EXTENSIONS2.has(getDottedExtension(fileName));
4327
+ }
4328
+ function isMediaFile(fileName) {
4329
+ return isImageFile(fileName) || isVideoFile(fileName) || isAudioFile(fileName);
4330
+ }
4331
+ function usesOriginalBytesForViewer(fileName) {
4332
+ return isMediaFile(fileName);
4333
+ }
4334
+ function isDownloadOnlyFile(fileName) {
4335
+ return DOWNLOAD_ONLY_EXTENSIONS.has(getDottedExtension(fileName));
4336
+ }
4337
+
4338
+ // src/entities/file-type.ts
4339
+ var EXT_LABELS = {
4340
+ pdf: "PDF",
4341
+ // Word / docs
4342
+ doc: "Word",
4343
+ docx: "Word",
4344
+ rtf: "Word",
4345
+ odt: "Word",
4346
+ // Spreadsheets
4347
+ xls: "Excel",
4348
+ xlsx: "Excel",
4349
+ ods: "Excel",
4350
+ csv: "CSV",
4351
+ tsv: "CSV",
4352
+ // Slides
4353
+ ppt: "PowerPoint",
4354
+ pptx: "PowerPoint",
4355
+ odp: "PowerPoint",
4356
+ // Plain text / markup
4357
+ txt: "Text",
4358
+ log: "Text",
4359
+ md: "Markdown",
4360
+ markdown: "Markdown",
4361
+ html: "HTML",
4362
+ htm: "HTML",
4363
+ xml: "XML",
4364
+ json: "JSON",
4365
+ yaml: "YAML",
4366
+ yml: "YAML",
4367
+ // Email
4368
+ eml: "Email",
4369
+ msg: "Email",
4370
+ mbox: "Email",
4371
+ pst: "Outlook",
4372
+ ost: "Outlook",
4373
+ // Images
4374
+ jpg: "Image",
4375
+ jpeg: "Image",
4376
+ png: "Image",
4377
+ gif: "Image",
4378
+ bmp: "Image",
4379
+ tif: "Image",
4380
+ tiff: "Image",
4381
+ webp: "Image",
4382
+ svg: "Image",
4383
+ heic: "Image",
4384
+ heif: "Image",
4385
+ // Audio
4386
+ mp3: "Audio",
4387
+ wav: "Audio",
4388
+ m4a: "Audio",
4389
+ aac: "Audio",
4390
+ ogg: "Audio",
4391
+ flac: "Audio",
4392
+ opus: "Audio",
4393
+ // Video
4394
+ mp4: "Video",
4395
+ webm: "Video",
4396
+ mov: "Video",
4397
+ avi: "Video",
4398
+ mkv: "Video",
4399
+ // Archives
4400
+ zip: "Archive",
4401
+ tar: "Archive",
4402
+ gz: "Archive",
4403
+ rar: "Archive",
4404
+ "7z": "Archive"
4405
+ };
4406
+ var MIME_SUBTYPE_LABELS = {
4407
+ // PDF
4408
+ pdf: "PDF",
4409
+ "x-pdf": "PDF",
4410
+ // Word
4411
+ msword: "Word",
4412
+ "vnd.openxmlformats-officedocument.wordprocessingml.document": "Word",
4413
+ "vnd.oasis.opendocument.text": "Word",
4414
+ rtf: "Word",
4415
+ // Excel
4416
+ "vnd.ms-excel": "Excel",
4417
+ "vnd.openxmlformats-officedocument.spreadsheetml.sheet": "Excel",
4418
+ "vnd.oasis.opendocument.spreadsheet": "Excel",
4419
+ csv: "CSV",
4420
+ "tab-separated-values": "CSV",
4421
+ // PowerPoint
4422
+ "vnd.ms-powerpoint": "PowerPoint",
4423
+ "vnd.openxmlformats-officedocument.presentationml.presentation": "PowerPoint",
4424
+ "vnd.oasis.opendocument.presentation": "PowerPoint",
4425
+ // Plain text / markup
4426
+ plain: "Text",
4427
+ html: "HTML",
4428
+ xml: "XML",
4429
+ json: "JSON",
4430
+ markdown: "Markdown",
4431
+ "x-markdown": "Markdown",
4432
+ yaml: "YAML",
4433
+ "x-yaml": "YAML",
4434
+ // Email
4435
+ rfc822: "Email",
4436
+ "vnd.ms-outlook": "Email",
4437
+ // Archives
4438
+ zip: "Archive",
4439
+ "x-zip-compressed": "Archive",
4440
+ "x-tar": "Archive",
4441
+ gzip: "Archive",
4442
+ "x-7z-compressed": "Archive",
4443
+ "x-rar-compressed": "Archive"
4444
+ };
4445
+ var MIME_TYPE_LABELS = {
4446
+ image: "Image",
4447
+ audio: "Audio",
4448
+ video: "Video",
4449
+ text: "Text"
4450
+ };
4451
+ function lookupExt(ext) {
4452
+ return EXT_LABELS[ext.toLowerCase().replace(/^\./, "")];
4453
+ }
4454
+ function lookupMime(mime) {
4455
+ const base = mime.toLowerCase().split(";")[0].trim();
4456
+ const slash = base.indexOf("/");
4457
+ if (slash <= 0) return void 0;
4458
+ const top = base.slice(0, slash);
4459
+ const sub = base.slice(slash + 1);
4460
+ return MIME_SUBTYPE_LABELS[sub] ?? MIME_TYPE_LABELS[top];
4461
+ }
4462
+ function extFromFileName(fileName) {
4463
+ if (!fileName) return void 0;
4464
+ const dot = fileName.lastIndexOf(".");
4465
+ if (dot <= 0 || dot === fileName.length - 1) return void 0;
4466
+ return fileName.slice(dot + 1);
4467
+ }
4468
+ function friendlyFileType(fileType, fileName) {
4469
+ if (fileType) {
4470
+ const trimmed = fileType.trim();
4471
+ if (trimmed.includes("/")) {
4472
+ const fromMime = lookupMime(trimmed);
4473
+ if (fromMime) return fromMime;
4474
+ } else {
4475
+ const fromExt = lookupExt(trimmed);
4476
+ if (fromExt) return fromExt;
4477
+ }
4478
+ }
4479
+ const fnExt = extFromFileName(fileName);
4480
+ if (fnExt) {
4481
+ const fromExt = lookupExt(fnExt);
4482
+ if (fromExt) return fromExt;
4483
+ }
4484
+ return "Other";
4485
+ }
4192
4486
  function nameInitials(name) {
4193
4487
  const parts = name.trim().split(/\s+/).filter(Boolean);
4194
4488
  if (!parts.length) return "?";
@@ -4377,15 +4671,15 @@ var STATUS_LABEL = {
4377
4671
  indexing: "Indexing",
4378
4672
  analysing: "Analysing"
4379
4673
  };
4380
- var IMAGE_EXTENSIONS2 = /* @__PURE__ */ new Set(["jpg", "jpeg", "png", "gif", "bmp", "tiff", "tif", "webp"]);
4381
- var VIDEO_EXTENSIONS2 = /* @__PURE__ */ new Set(["mp4", "mpeg", "mpg", "webm", "mov", "avi", "mkv"]);
4382
- var AUDIO_EXTENSIONS2 = /* @__PURE__ */ new Set(["mp3", "wav", "m4a", "aac", "ogg", "flac"]);
4674
+ var IMAGE_EXTENSIONS3 = /* @__PURE__ */ new Set(["jpg", "jpeg", "png", "gif", "bmp", "tiff", "tif", "webp"]);
4675
+ var VIDEO_EXTENSIONS3 = /* @__PURE__ */ new Set(["mp4", "mpeg", "mpg", "webm", "mov", "avi", "mkv"]);
4676
+ var AUDIO_EXTENSIONS3 = /* @__PURE__ */ new Set(["mp3", "wav", "m4a", "aac", "ogg", "flac"]);
4383
4677
  var EMAIL_EXTENSIONS2 = /* @__PURE__ */ new Set(["eml", "msg"]);
4384
4678
  function fileIcon(fileName, size) {
4385
4679
  const ext = fileName?.split(".").pop()?.toLowerCase();
4386
- if (ext && VIDEO_EXTENSIONS2.has(ext)) return /* @__PURE__ */ jsx(VidIcon, { size });
4387
- if (ext && AUDIO_EXTENSIONS2.has(ext)) return /* @__PURE__ */ jsx(AudIcon, { size });
4388
- if (ext && IMAGE_EXTENSIONS2.has(ext)) return /* @__PURE__ */ jsx(ImgIcon, { size });
4680
+ if (ext && VIDEO_EXTENSIONS3.has(ext)) return /* @__PURE__ */ jsx(VidIcon, { size });
4681
+ if (ext && AUDIO_EXTENSIONS3.has(ext)) return /* @__PURE__ */ jsx(AudIcon, { size });
4682
+ if (ext && IMAGE_EXTENSIONS3.has(ext)) return /* @__PURE__ */ jsx(ImgIcon, { size });
4389
4683
  if (ext && EMAIL_EXTENSIONS2.has(ext)) return /* @__PURE__ */ jsx(EmlIcon, { size });
4390
4684
  return /* @__PURE__ */ jsx(PdfIcon, { size });
4391
4685
  }
@@ -4573,6 +4867,6 @@ function DocumentCard({
4573
4867
  );
4574
4868
  }
4575
4869
 
4576
- export { AUDIO_MIME_PREFERENCE, AgentBadge, AiMarkdown, ArbiBotHeadIcon, ArbiIcon, AudIcon, Avatar, AvatarFallback, AvatarImage, BASE_COLORS2 as BASE_COLORS, Badge, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, Checkbox, Collapsible, CollapsibleContent2 as CollapsibleContent, CollapsibleTrigger2 as CollapsibleTrigger, Command, CommandDialog, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandSeparator, CommandShortcut, DEFAULT_SEGMENTER_CONFIG, DebouncedInput, DictateProvider, DocIcon, DocumentCard, DocumentEntity, ENTITY_MAPPINGS, EmlIcon, EntityIcon, EntityPill, FILE_TYPE_COLORS, HoverCard, HoverCardContent, HoverCardTrigger, HtmlIcon, INITIAL_SEGMENTER_STATE, IconToggle, ImgIcon, InlineMicButton, Input, Label2 as Label, MarkMenu, MicRecordingOverlay, MicWaveformIndicator, NEUTRAL_GRAY2 as NEUTRAL_GRAY, PLACEHOLDER_COLOR, PassageCard, PdfIcon, Popover, PopoverAnchor, PopoverClose, PopoverContent, PopoverTrigger, PresenceLabel, Progress, ProjectEntity, RadioGroup, RadioGroupItem, RagDot, RelevanceDot, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Separator2 as Separator, ShieldIcon, Slider, StatusPill, Switch, TAG_TYPE_ICONS, TAG_TYPE_LABELS, Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, TableRow, Tabs, TabsContent, TabsList, TabsTrigger, TagEntity, Textarea, ThreadVisibilityIcon, Toggle, ToggleGroup, ToggleGroupItem, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, TxtIcon, UserEntity, UserMenu, VIDEO_MIME_PREFERENCE, VISIBILITY_ICONS, VerifiedBadge, VidIcon, VisibilityIcon, VisibilityToggle, XlsIcon, agentAvatarColors, badgeVariants, cardVariants, classifyMediaError, configureEntityRegistry, configureRagLabels, configureStatusRegistry, createChunkedRecorder, flushSegmenter, formatElapsed, getDocIcon, getEntityColor2 as getEntityColor, getEntityColorStyles, getEntityIcon, getEntityLabel, getStatusVariant, getTagTypeIcon, getTagTypeLabel, getWorkspaceColor, levelFromRms, pickRecorderMimeType, returnFocusToMark, stepSegmenter, toggleVariants, useAudioRecorder };
4577
- //# sourceMappingURL=chunk-J3BYHBKW.js.map
4578
- //# sourceMappingURL=chunk-J3BYHBKW.js.map
4870
+ export { AUDIO_MIME_PREFERENCE, AgentBadge, AiMarkdown, ArbiBotHeadIcon, ArbiIcon, AudIcon, Avatar, AvatarFallback, AvatarImage, BASE_COLORS2 as BASE_COLORS, Badge, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, Checkbox, Collapsible, CollapsibleContent2 as CollapsibleContent, CollapsibleTrigger2 as CollapsibleTrigger, Command, CommandDialog, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandSeparator, CommandShortcut, DEFAULT_SEGMENTER_CONFIG, DebouncedInput, DictateProvider, DocIcon, DocumentCard, DocumentEntity, ENTITY_MAPPINGS, EmlIcon, EntityIcon, EntityPill, FILE_TYPE_COLORS, HoverCard, HoverCardContent, HoverCardTrigger, HtmlIcon, INITIAL_SEGMENTER_STATE, IconToggle, ImgIcon, InlineMicButton, Input, Label2 as Label, MarkMenu, MicRecordingOverlay, MicWaveformIndicator, NEUTRAL_GRAY2 as NEUTRAL_GRAY, PLACEHOLDER_COLOR, PassageCard, PdfIcon, Popover, PopoverAnchor, PopoverClose, PopoverContent, PopoverTrigger, PresenceLabel, Progress, ProjectEntity, RadioGroup, RadioGroupItem, RagDot, RelevanceDot, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Separator2 as Separator, ShieldIcon, Slider, StatusPill, Switch, TAG_TYPE_ICONS, TAG_TYPE_LABELS, Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, TableRow, Tabs, TabsContent, TabsList, TabsTrigger, TagEntity, Textarea, ThreadVisibilityIcon, Toggle, ToggleGroup, ToggleGroupItem, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, TxtIcon, UserEntity, UserMenu, VIDEO_MIME_PREFERENCE, VISIBILITY_ICONS, VerifiedBadge, VerifiedToggle, VidIcon, VisibilityIcon, VisibilityToggle, XlsIcon, agentAvatarColors, badgeVariants, cardVariants, classifyMediaError, configureEntityRegistry, configureRagLabels, configureStatusRegistry, createChunkedRecorder, flushSegmenter, formatElapsed, formatFriendlyDate, friendlyFileType, getDocIcon, getDocumentTitle, getEntityColor2 as getEntityColor, getEntityColorStyles, getEntityIcon, getEntityLabel, getStatusVariant, getTagTypeIcon, getTagTypeLabel, getWorkspaceColor, isAudioFile, isDownloadOnlyFile, isImageDocument, isImageFile, isMediaFile, isVideoFile, levelFromRms, pickRecorderMimeType, returnFocusToMark, stepSegmenter, tagKindNouns, tagKindTitle, toggleVariants, useAudioRecorder, useDictateContext, usesOriginalBytesForViewer };
4871
+ //# sourceMappingURL=chunk-KD7CKXWQ.js.map
4872
+ //# sourceMappingURL=chunk-KD7CKXWQ.js.map