@flytedan/flytebot-design-system 0.78.1 → 0.80.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -927,11 +927,16 @@ __export(index_exports, {
927
927
  Button: () => Button,
928
928
  CHANNELS: () => CHANNELS,
929
929
  CHANNEL_WEIGHTS: () => CHANNEL_WEIGHTS,
930
+ CHAT_CALL_DEADLINE_MS: () => CHAT_CALL_DEADLINE_MS,
930
931
  CHAT_UNAVAILABLE: () => CHAT_UNAVAILABLE,
932
+ CHAT_UNAVAILABLE_MESSAGE: () => CHAT_UNAVAILABLE_MESSAGE,
931
933
  COPIED_FEEDBACK_MS: () => COPIED_FEEDBACK_MS,
932
934
  CORNER_STACK_INSET_PROPERTY: () => CORNER_STACK_INSET_PROPERTY,
933
935
  CORNER_STACK_OFFSET_PROPERTY: () => CORNER_STACK_OFFSET_PROPERTY,
936
+ CSV_FAILED_FALLBACK: () => CSV_FAILED_FALLBACK,
937
+ CSV_KEPT_NOTE: () => CSV_KEPT_NOTE,
934
938
  Calendar: () => Calendar,
939
+ CallDeadlineError: () => CallDeadlineError,
935
940
  Card: () => Card,
936
941
  CardGrid: () => CardGrid,
937
942
  CardRow: () => CardRow,
@@ -944,6 +949,7 @@ __export(index_exports, {
944
949
  ChatSessionBar: () => ChatSessionBar,
945
950
  ChatTranscript: () => ChatTranscript,
946
951
  ChatTurn: () => ChatTurn,
952
+ ChatUnreachableError: () => ChatUnreachableError,
947
953
  Checkbox: () => Checkbox,
948
954
  Citations: () => Citations,
949
955
  Clamp: () => Clamp,
@@ -956,6 +962,7 @@ __export(index_exports, {
956
962
  CsiBadge: () => CsiBadge,
957
963
  CsiHero: () => CsiHero,
958
964
  CsiMeter: () => CsiMeter,
965
+ CsvCard: () => CsvCard,
959
966
  DEFAULT_PREFS: () => DEFAULT_PREFS,
960
967
  DEFAULT_STORAGE_KEY: () => DEFAULT_STORAGE_KEY,
961
968
  DEFAULT_TOAST_DURATION_MS: () => DEFAULT_TOAST_DURATION_MS,
@@ -968,9 +975,14 @@ __export(index_exports, {
968
975
  Dropzone: () => Dropzone,
969
976
  DropzoneKit: () => DropzoneKit,
970
977
  ENTITY_ROW_METRIC_WIDTH: () => ENTITY_ROW_METRIC_WIDTH,
978
+ EXPORT_FAILED_FALLBACK: () => EXPORT_FAILED_FALLBACK,
979
+ EXPORT_IDLE_POLL_INTERVAL_MS: () => EXPORT_IDLE_POLL_INTERVAL_MS,
980
+ EXPORT_KEPT_NOTE: () => EXPORT_KEPT_NOTE,
981
+ EXPORT_POLL_INTERVAL_MS: () => EXPORT_POLL_INTERVAL_MS,
971
982
  EmptyState: () => EmptyState,
972
983
  EntityRow: () => EntityRow,
973
984
  EntityRowMetrics: () => EntityRowMetrics,
985
+ ExportTray: () => ExportTray,
974
986
  FILE_VIEWER_CSV_ROW_LIMIT: () => FILE_VIEWER_CSV_ROW_LIMIT,
975
987
  FILE_VIEWER_TEXT_LIMIT: () => FILE_VIEWER_TEXT_LIMIT,
976
988
  FactList: () => FactList,
@@ -1013,6 +1025,7 @@ __export(index_exports, {
1013
1025
  Modal: () => Modal,
1014
1026
  ModeSwitch: () => ModeSwitch,
1015
1027
  ModelControls: () => ModelControls,
1028
+ NEW_THREAD_FAILED: () => NEW_THREAD_FAILED,
1016
1029
  NumberInput: () => NumberInput,
1017
1030
  OVERLAY_BREAKPOINT: () => OVERLAY_BREAKPOINT,
1018
1031
  OVERLAY_CEILING: () => OVERLAY_CEILING,
@@ -1026,7 +1039,9 @@ __export(index_exports, {
1026
1039
  PreferenceMeter: () => PreferenceMeter,
1027
1040
  ProfilePage: () => ProfilePage,
1028
1041
  ProgressBar: () => ProgressBar,
1042
+ QUERY_EMPTY_MESSAGE: () => QUERY_EMPTY_MESSAGE,
1029
1043
  QueryKit: () => QueryKit,
1044
+ QueryResultCard: () => QueryResultCard,
1030
1045
  QuotaRow: () => QuotaRow,
1031
1046
  ROOT_STEP: () => ROOT_STEP,
1032
1047
  Radio: () => Radio,
@@ -1060,6 +1075,7 @@ __export(index_exports, {
1060
1075
  StepList: () => StepList,
1061
1076
  SurroundSound: () => SurroundSound,
1062
1077
  Switch: () => Switch,
1078
+ THREADS_LOAD_FAILED: () => THREADS_LOAD_FAILED,
1063
1079
  Tabs: () => Tabs,
1064
1080
  Tag: () => Tag,
1065
1081
  TestModeBar: () => TestModeBar,
@@ -1089,9 +1105,13 @@ __export(index_exports, {
1089
1105
  computeNeedMore: () => computeNeedMore,
1090
1106
  computeVirtualWindow: () => computeVirtualWindow,
1091
1107
  copyToClipboard: () => copyToClipboard,
1108
+ createChatAdapter: () => createChatAdapter,
1109
+ createExportDownloader: () => createExportDownloader,
1092
1110
  createLocalStorageAppearanceStore: () => createLocalStorageAppearanceStore,
1093
1111
  createVersionStore: () => createVersionStore,
1094
1112
  eqFilter: () => eqFilter,
1113
+ exportStateOf: () => exportStateOf,
1114
+ exportToJob: () => exportToJob,
1095
1115
  extensionOf: () => extensionOf,
1096
1116
  extractClipboardFiles: () => extractClipboardFiles,
1097
1117
  filterFiles: () => filterFiles,
@@ -1110,7 +1130,9 @@ __export(index_exports, {
1110
1130
  importanceLevel: () => importanceLevel,
1111
1131
  importanceTokens: () => importanceTokens,
1112
1132
  installFlytedeskFavicon: () => installFlytedeskFavicon,
1133
+ isExpiredExport: () => isExpiredExport,
1113
1134
  isImage: () => isImage,
1135
+ isLiveExport: () => isLiveExport,
1114
1136
  isSystemMessage: () => isSystemMessage,
1115
1137
  isUsStateCode: () => isUsStateCode,
1116
1138
  isWithinLayerTree: () => isWithinLayerTree,
@@ -1135,9 +1157,12 @@ __export(index_exports, {
1135
1157
  useAppearancePrefs: () => useAppearancePrefs,
1136
1158
  useAppearanceStore: () => useAppearanceStore,
1137
1159
  useChatEngine: () => useChatEngine,
1160
+ useChatThreads: () => useChatThreads,
1138
1161
  useCopyToClipboard: () => useCopyToClipboard,
1139
1162
  useCornerStackSlot: () => useCornerStackSlot,
1140
1163
  useDocumentTitle: () => useDocumentTitle,
1164
+ useExpiryClock: () => useExpiryClock,
1165
+ useExportJobs: () => useExportJobs,
1141
1166
  useFeatureStatus: () => useFeatureStatus,
1142
1167
  useLayerZIndex: () => useLayerZIndex,
1143
1168
  useOverlayLayout: () => useOverlayLayout,
@@ -1148,6 +1173,7 @@ __export(index_exports, {
1148
1173
  useServerTable: () => useServerTable,
1149
1174
  useSessionContext: () => useSessionContext,
1150
1175
  useSheetOpenMark: () => useSheetOpenMark,
1176
+ useShownExport: () => useShownExport,
1151
1177
  useStackedLayer: () => useStackedLayer,
1152
1178
  useStagedFiles: () => useStagedFiles,
1153
1179
  useToast: () => useToast,
@@ -1155,6 +1181,7 @@ __export(index_exports, {
1155
1181
  validateFilterValue: () => validateFilterValue,
1156
1182
  visibleMessages: () => visibleMessages,
1157
1183
  watchAppearance: () => watchAppearance,
1184
+ withDeadline: () => withDeadline,
1158
1185
  writeQueryToUrl: () => writeQueryToUrl
1159
1186
  });
1160
1187
  module.exports = __toCommonJS(index_exports);
@@ -4441,6 +4468,7 @@ function RowActionCell({ action }) {
4441
4468
  return /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("td", { className: "fd-table-action", children: action ? /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(RowActionButton, { action, size: "sm" }) : null });
4442
4469
  }
4443
4470
  var cellOf = (c, row) => c.render ? c.render(row) : row[c.key];
4471
+ var cellClassOf = (c) => [c.numeric ? "is-num" : "", c.noWrap ? "fd-table-nowrap" : ""].filter(Boolean).join(" ") || void 0;
4444
4472
  var cardCellOf = (c, row) => c.phoneRender ? c.phoneRender(row) : cellOf(c, row);
4445
4473
  function rowInteraction(row, onRowClick) {
4446
4474
  if (!onRowClick) return {};
@@ -4524,7 +4552,7 @@ function DataTable({
4524
4552
  rowAction ? /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("th", { scope: "col", className: "fd-table-action-head", children: /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("span", { className: "fd-sr-only", children: "Actions" }) }) : null
4525
4553
  ] }) }),
4526
4554
  /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("tbody", { className: stale ? "fd-stale" : void 0, children: loading ? Array.from({ length: skeletonRows }).map((_, i) => /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)("tr", { children: [
4527
- columns.map((c) => /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("td", { className: c.numeric ? "is-num" : "", children: /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("span", { className: "fd-skel fd-skel-text", style: { display: "inline-block", height: 13, width: c.numeric ? 52 : i % 3 === 0 ? "72%" : "88%" } }) }, c.key)),
4555
+ columns.map((c) => /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("td", { className: cellClassOf(c), children: /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("span", { className: "fd-skel fd-skel-text", style: { display: "inline-block", height: 13, width: c.numeric ? 52 : i % 3 === 0 ? "72%" : "88%" } }) }, c.key)),
4528
4556
  rowAction ? /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("td", { className: "fd-table-action" }) : null
4529
4557
  ] }, i)) : rows.map((r) => /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)(
4530
4558
  "tr",
@@ -4533,7 +4561,7 @@ function DataTable({
4533
4561
  title: rowTitle ? rowTitle(r) : void 0,
4534
4562
  ...rowInteraction(r, onRowClick),
4535
4563
  children: [
4536
- columns.map((c) => /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("td", { className: c.numeric ? "is-num" : "", children: cellOf(c, r) }, c.key)),
4564
+ columns.map((c) => /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("td", { className: cellClassOf(c), children: cellOf(c, r) }, c.key)),
4537
4565
  rowAction ? /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(RowActionCell, { action: rowAction(r) }) : null
4538
4566
  ]
4539
4567
  },
@@ -4585,7 +4613,7 @@ function StackedRows({ columns, rows, rowKey, loading, stale, skeletonRows, sort
4585
4613
  ...rowInteraction(r, onRowClick),
4586
4614
  children: [
4587
4615
  /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("div", { className: "fd-dt-card-title", children: primary.map((c) => /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("span", { className: c.numeric ? "is-num" : void 0, children: cardCellOf(c, r) }, c.key)) }),
4588
- secondary.length ? /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("div", { className: "fd-dt-card-meta", children: secondary.map((c) => /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)("span", { className: c.numeric ? "is-num" : void 0, children: [
4616
+ secondary.length ? /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("div", { className: "fd-dt-card-meta", children: secondary.map((c) => /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)("span", { className: cellClassOf(c), children: [
4589
4617
  /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("span", { className: "fd-dt-card-label", children: c.label }),
4590
4618
  " ",
4591
4619
  cardCellOf(c, r)
@@ -15413,9 +15441,155 @@ function AgentChatPanel({
15413
15441
  );
15414
15442
  }
15415
15443
 
15416
- // src/components/files/FileViewer.tsx
15444
+ // src/components/chat/QueryResultCard.tsx
15417
15445
  var React81 = __toESM(require("react"), 1);
15418
15446
  var import_jsx_runtime108 = require("react/jsx-runtime");
15447
+ var STATUS2 = {
15448
+ queued: { label: "Queued", tone: "neutral" },
15449
+ running: { label: "Running", tone: "info" },
15450
+ done: { label: "Done", tone: "success" },
15451
+ failed: { label: "Failed", tone: "danger" },
15452
+ canceled: { label: "Stopped", tone: "neutral" }
15453
+ };
15454
+ var QUERY_EMPTY_MESSAGE = "No rows to show.";
15455
+ function useElapsed(status, startedAt) {
15456
+ const [now, setNow] = React81.useState(() => Date.now());
15457
+ const running = status === "running" && startedAt != null;
15458
+ React81.useEffect(() => {
15459
+ if (!running) return;
15460
+ const tick = setInterval(() => setNow(Date.now()), 1e3);
15461
+ return () => clearInterval(tick);
15462
+ }, [running]);
15463
+ if (!running) return null;
15464
+ return formatDuration(Math.max(0, now - Date.parse(startedAt)));
15465
+ }
15466
+ function QueryResultCard({
15467
+ title,
15468
+ status,
15469
+ startedAt,
15470
+ failureMessage,
15471
+ facts = [],
15472
+ columns,
15473
+ rows = [],
15474
+ rowKey = "id",
15475
+ actions
15476
+ }) {
15477
+ const { label, tone } = STATUS2[status];
15478
+ const elapsed = useElapsed(status, startedAt);
15479
+ const empty = status === "done" && facts.length === 0 && rows.length === 0;
15480
+ return /* @__PURE__ */ (0, import_jsx_runtime108.jsxs)("div", { className: "fd-stack fd-gap-sm", role: "group", "aria-label": `Query: ${title}`, children: [
15481
+ /* @__PURE__ */ (0, import_jsx_runtime108.jsxs)("div", { className: "fd-row fd-wrap fd-justify-between fd-align-center fd-gap-sm", children: [
15482
+ /* @__PURE__ */ (0, import_jsx_runtime108.jsx)("span", { className: "fd-body-sm", style: { overflowWrap: "anywhere", minWidth: 0 }, children: title }),
15483
+ /* @__PURE__ */ (0, import_jsx_runtime108.jsx)(Badge, { tone, dot: status === "running", children: elapsed === null ? label : `${label} \xB7 ${elapsed}` })
15484
+ ] }),
15485
+ failureMessage ? /* @__PURE__ */ (0, import_jsx_runtime108.jsx)("p", { className: "fd-body-sm fd-danger", children: failureMessage }) : null,
15486
+ facts.length === 0 ? null : /* @__PURE__ */ (0, import_jsx_runtime108.jsx)(FactList, { facts }),
15487
+ rows.length === 0 || !columns ? null : /* @__PURE__ */ (0, import_jsx_runtime108.jsx)(DataTable, { compact: true, columns, rows, rowKey }),
15488
+ empty ? /* @__PURE__ */ (0, import_jsx_runtime108.jsx)("p", { className: "fd-body-sm fd-muted", children: QUERY_EMPTY_MESSAGE }) : null,
15489
+ actions ? /* @__PURE__ */ (0, import_jsx_runtime108.jsx)("div", { className: "fd-row fd-wrap fd-gap-sm", children: actions }) : null
15490
+ ] });
15491
+ }
15492
+
15493
+ // src/components/chat/CsvCard.tsx
15494
+ var React83 = __toESM(require("react"), 1);
15495
+
15496
+ // src/kits/exports/exportState.ts
15497
+ var React82 = __toESM(require("react"), 1);
15498
+
15499
+ // src/kits/exports/exportJob.ts
15500
+ function isLiveExport(job) {
15501
+ return job.status === "PENDING" || job.status === "RUNNING";
15502
+ }
15503
+ function isExpiredExport(job, now) {
15504
+ return job.expiresAt !== null && Date.parse(job.expiresAt) <= now;
15505
+ }
15506
+
15507
+ // src/kits/exports/exportState.ts
15508
+ function exportStateOf(job, now) {
15509
+ switch (job.status) {
15510
+ case "PENDING":
15511
+ return "queued";
15512
+ case "RUNNING":
15513
+ return "preparing";
15514
+ case "FAILED":
15515
+ return "failed";
15516
+ case "SUCCEEDED":
15517
+ return isExpiredExport(job, now) ? "expired" : "ready";
15518
+ }
15519
+ }
15520
+ function useExpiryClock(job) {
15521
+ const [now, setNow] = React82.useState(() => Date.now());
15522
+ const { status, expiresAt } = job;
15523
+ React82.useEffect(() => {
15524
+ if (status !== "SUCCEEDED" || expiresAt === null) return;
15525
+ const wait = Date.parse(expiresAt) - Date.now();
15526
+ if (wait <= 0) return;
15527
+ const timer = setTimeout(() => setNow(Date.now()), wait);
15528
+ return () => clearTimeout(timer);
15529
+ }, [status, expiresAt]);
15530
+ return now;
15531
+ }
15532
+ function useLastListed(listed) {
15533
+ const [last, setLast] = React82.useState(listed);
15534
+ if (listed !== void 0 && listed !== last) setLast(listed);
15535
+ return listed ?? last;
15536
+ }
15537
+ function useShownExport(held, exports2, refresh2) {
15538
+ const lastListed = useLastListed(exports2.find((candidate) => candidate.id === held.id));
15539
+ const unlisted = isLiveExport(held) && lastListed === void 0;
15540
+ React82.useEffect(() => {
15541
+ if (unlisted) refresh2();
15542
+ }, [unlisted, refresh2]);
15543
+ return isLiveExport(held) && lastListed !== void 0 ? lastListed : held;
15544
+ }
15545
+
15546
+ // src/components/chat/CsvCard.tsx
15547
+ var import_jsx_runtime109 = require("react/jsx-runtime");
15548
+ var STATE = {
15549
+ queued: { label: "Queued", tone: "neutral" },
15550
+ preparing: { label: "Preparing", tone: "info" },
15551
+ ready: { label: "Ready", tone: "success" },
15552
+ expired: { label: "Expired", tone: "neutral" },
15553
+ failed: { label: "Failed", tone: "danger" }
15554
+ };
15555
+ var CSV_FAILED_FALLBACK = "The CSV could not be made.";
15556
+ var CSV_KEPT_NOTE = "Kept 24 hours";
15557
+ function CsvCard({ job, onDownload }) {
15558
+ const [downloading, setDownloading] = React83.useState(false);
15559
+ const now = useExpiryClock(job);
15560
+ const state = exportStateOf(job, now);
15561
+ const { label, tone } = STATE[state];
15562
+ const facts = job.rowCount === null ? [] : [{ label: "Rows", value: job.rowCount.toLocaleString("en-US") }];
15563
+ function download() {
15564
+ setDownloading(true);
15565
+ void onDownload(job.id).finally(() => setDownloading(false));
15566
+ }
15567
+ return /* @__PURE__ */ (0, import_jsx_runtime109.jsxs)("div", { className: "fd-stack fd-gap-sm", role: "group", "aria-label": `CSV: ${job.fileName}`, children: [
15568
+ /* @__PURE__ */ (0, import_jsx_runtime109.jsxs)("div", { className: "fd-row fd-wrap fd-justify-between fd-align-center fd-gap-sm", children: [
15569
+ /* @__PURE__ */ (0, import_jsx_runtime109.jsx)("span", { className: "fd-body-sm fd-mono", style: { overflowWrap: "anywhere", minWidth: 0 }, children: job.fileName }),
15570
+ /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(Badge, { tone, dot: state === "preparing", children: label })
15571
+ ] }),
15572
+ state === "failed" ? /* @__PURE__ */ (0, import_jsx_runtime109.jsx)("p", { className: "fd-body-sm fd-danger", children: job.failureMessage ?? CSV_FAILED_FALLBACK }) : null,
15573
+ facts.length === 0 ? null : /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(FactList, { facts }),
15574
+ state === "ready" ? /* @__PURE__ */ (0, import_jsx_runtime109.jsx)("p", { className: "fd-body-sm fd-muted", children: CSV_KEPT_NOTE }) : null,
15575
+ /* @__PURE__ */ (0, import_jsx_runtime109.jsx)("div", { className: "fd-row fd-wrap fd-gap-sm", children: /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
15576
+ Button,
15577
+ {
15578
+ size: "sm",
15579
+ variant: "secondary",
15580
+ icon: "download-simple",
15581
+ disabled: state !== "ready",
15582
+ loading: downloading,
15583
+ onClick: download,
15584
+ children: "Download"
15585
+ }
15586
+ ) })
15587
+ ] });
15588
+ }
15589
+
15590
+ // src/components/files/FileViewer.tsx
15591
+ var React84 = __toESM(require("react"), 1);
15592
+ var import_jsx_runtime110 = require("react/jsx-runtime");
15419
15593
  function previewKindOf(file) {
15420
15594
  const mime = (file.mime || "").toLowerCase();
15421
15595
  const ext = extensionOf(file.name || "");
@@ -15471,13 +15645,13 @@ function parseDelimited(text, delimiter) {
15471
15645
  return rows;
15472
15646
  }
15473
15647
  function usePreview(file, kind, resolveUrl) {
15474
- const [state, setState] = React81.useState({ status: "loading" });
15475
- const [attempt, setAttempt] = React81.useState(0);
15476
- const resolveRef = React81.useRef(resolveUrl);
15477
- React81.useEffect(() => {
15648
+ const [state, setState] = React84.useState({ status: "loading" });
15649
+ const [attempt, setAttempt] = React84.useState(0);
15650
+ const resolveRef = React84.useRef(resolveUrl);
15651
+ React84.useEffect(() => {
15478
15652
  resolveRef.current = resolveUrl;
15479
15653
  }, [resolveUrl]);
15480
- React81.useEffect(() => {
15654
+ React84.useEffect(() => {
15481
15655
  if (kind === "none") {
15482
15656
  setState({ status: "ready" });
15483
15657
  return;
@@ -15507,19 +15681,19 @@ function usePreview(file, kind, resolveUrl) {
15507
15681
  if (ac) ac.abort();
15508
15682
  };
15509
15683
  }, [file.id, kind, attempt]);
15510
- return { ...state, retry: React81.useCallback(() => setAttempt((a) => a + 1), []) };
15684
+ return { ...state, retry: React84.useCallback(() => setAttempt((a) => a + 1), []) };
15511
15685
  }
15512
15686
  function PreviewBody({ file, kind, state }) {
15513
- if (kind === "image") return /* @__PURE__ */ (0, import_jsx_runtime108.jsx)("img", { className: "fd-fv-image", src: state.url, alt: file.name || "Preview" });
15514
- if (kind === "pdf") return /* @__PURE__ */ (0, import_jsx_runtime108.jsx)("iframe", { className: "fd-fv-pdf", src: state.url, title: file.name || "PDF preview" });
15515
- if (kind === "markdown") return /* @__PURE__ */ (0, import_jsx_runtime108.jsx)(Markdown, { className: "fd-fv-markdown", source: state.text || "" });
15687
+ if (kind === "image") return /* @__PURE__ */ (0, import_jsx_runtime110.jsx)("img", { className: "fd-fv-image", src: state.url, alt: file.name || "Preview" });
15688
+ if (kind === "pdf") return /* @__PURE__ */ (0, import_jsx_runtime110.jsx)("iframe", { className: "fd-fv-pdf", src: state.url, title: file.name || "PDF preview" });
15689
+ if (kind === "markdown") return /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(Markdown, { className: "fd-fv-markdown", source: state.text || "" });
15516
15690
  if (kind === "json") {
15517
15691
  let pretty = state.text || "";
15518
15692
  try {
15519
15693
  pretty = JSON.stringify(JSON.parse(pretty), null, 2);
15520
15694
  } catch {
15521
15695
  }
15522
- return /* @__PURE__ */ (0, import_jsx_runtime108.jsx)(CodeBlock, { code: pretty, language: "json" });
15696
+ return /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(CodeBlock, { code: pretty, language: "json" });
15523
15697
  }
15524
15698
  if (kind === "csv") {
15525
15699
  const tsv = extensionOf(file.name || "") === "tsv" || (file.mime || "").toLowerCase().includes("tab-separated");
@@ -15527,12 +15701,12 @@ function PreviewBody({ file, kind, state }) {
15527
15701
  const head = rows[0] || [];
15528
15702
  const dataRows = rows.slice(1);
15529
15703
  const shown = dataRows.slice(0, FILE_VIEWER_CSV_ROW_LIMIT);
15530
- return /* @__PURE__ */ (0, import_jsx_runtime108.jsxs)("div", { className: "fd-fv-csv", children: [
15531
- /* @__PURE__ */ (0, import_jsx_runtime108.jsxs)("table", { className: "fd-fv-csv-table", children: [
15532
- /* @__PURE__ */ (0, import_jsx_runtime108.jsx)("thead", { children: /* @__PURE__ */ (0, import_jsx_runtime108.jsx)("tr", { children: head.map((c, i) => /* @__PURE__ */ (0, import_jsx_runtime108.jsx)("th", { children: c }, i)) }) }),
15533
- /* @__PURE__ */ (0, import_jsx_runtime108.jsx)("tbody", { children: shown.map((r, ri) => /* @__PURE__ */ (0, import_jsx_runtime108.jsx)("tr", { children: head.map((_, ci) => /* @__PURE__ */ (0, import_jsx_runtime108.jsx)("td", { children: r[ci] ?? "" }, ci)) }, ri)) })
15704
+ return /* @__PURE__ */ (0, import_jsx_runtime110.jsxs)("div", { className: "fd-fv-csv", children: [
15705
+ /* @__PURE__ */ (0, import_jsx_runtime110.jsxs)("table", { className: "fd-fv-csv-table", children: [
15706
+ /* @__PURE__ */ (0, import_jsx_runtime110.jsx)("thead", { children: /* @__PURE__ */ (0, import_jsx_runtime110.jsx)("tr", { children: head.map((c, i) => /* @__PURE__ */ (0, import_jsx_runtime110.jsx)("th", { children: c }, i)) }) }),
15707
+ /* @__PURE__ */ (0, import_jsx_runtime110.jsx)("tbody", { children: shown.map((r, ri) => /* @__PURE__ */ (0, import_jsx_runtime110.jsx)("tr", { children: head.map((_, ci) => /* @__PURE__ */ (0, import_jsx_runtime110.jsx)("td", { children: r[ci] ?? "" }, ci)) }, ri)) })
15534
15708
  ] }),
15535
- dataRows.length > FILE_VIEWER_CSV_ROW_LIMIT ? /* @__PURE__ */ (0, import_jsx_runtime108.jsxs)("p", { className: "fd-fv-csv-note fd-body-sm fd-muted", children: [
15709
+ dataRows.length > FILE_VIEWER_CSV_ROW_LIMIT ? /* @__PURE__ */ (0, import_jsx_runtime110.jsxs)("p", { className: "fd-fv-csv-note fd-body-sm fd-muted", children: [
15536
15710
  "Showing the first ",
15537
15711
  FILE_VIEWER_CSV_ROW_LIMIT.toLocaleString(),
15538
15712
  " of ",
@@ -15541,24 +15715,24 @@ function PreviewBody({ file, kind, state }) {
15541
15715
  ] }) : null
15542
15716
  ] });
15543
15717
  }
15544
- if (kind === "text") return /* @__PURE__ */ (0, import_jsx_runtime108.jsx)(CodeBlock, { code: state.text || "", language: extensionOf(file.name || "") || void 0 });
15545
- return /* @__PURE__ */ (0, import_jsx_runtime108.jsxs)("div", { className: "fd-fv-fallback", children: [
15546
- /* @__PURE__ */ (0, import_jsx_runtime108.jsx)("span", { className: "fd-fv-fallback-icon", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime108.jsx)("i", { className: "ph ph-" + iconForMime(file.mime, file.name) }) }),
15547
- /* @__PURE__ */ (0, import_jsx_runtime108.jsx)("span", { className: "fd-fv-fallback-title", children: "No preview available" }),
15548
- /* @__PURE__ */ (0, import_jsx_runtime108.jsxs)("span", { className: "fd-fv-fallback-meta", children: [
15718
+ if (kind === "text") return /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(CodeBlock, { code: state.text || "", language: extensionOf(file.name || "") || void 0 });
15719
+ return /* @__PURE__ */ (0, import_jsx_runtime110.jsxs)("div", { className: "fd-fv-fallback", children: [
15720
+ /* @__PURE__ */ (0, import_jsx_runtime110.jsx)("span", { className: "fd-fv-fallback-icon", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime110.jsx)("i", { className: "ph ph-" + iconForMime(file.mime, file.name) }) }),
15721
+ /* @__PURE__ */ (0, import_jsx_runtime110.jsx)("span", { className: "fd-fv-fallback-title", children: "No preview available" }),
15722
+ /* @__PURE__ */ (0, import_jsx_runtime110.jsxs)("span", { className: "fd-fv-fallback-meta", children: [
15549
15723
  file.mime || "Unknown type",
15550
15724
  file.size ? " \xB7 " + formatBytes(file.size) : ""
15551
15725
  ] })
15552
15726
  ] });
15553
15727
  }
15554
15728
  function FileViewer({ file, resolveUrl, sidePanel, sidePanelLabel = "Details", onClose, actions, className = "" }) {
15555
- const kind = React81.useMemo(() => previewKindOf(file), [file]);
15729
+ const kind = React84.useMemo(() => previewKindOf(file), [file]);
15556
15730
  const preview = usePreview(file, kind, resolveUrl);
15557
- const [tab, setTab] = React81.useState("preview");
15558
- const [downloading, setDownloading] = React81.useState(false);
15559
- const [downloadError, setDownloadError] = React81.useState(null);
15731
+ const [tab, setTab] = React84.useState("preview");
15732
+ const [downloading, setDownloading] = React84.useState(false);
15733
+ const [downloadError, setDownloadError] = React84.useState(null);
15560
15734
  const hasSide = sidePanel != null;
15561
- React81.useEffect(() => {
15735
+ React84.useEffect(() => {
15562
15736
  setTab("preview");
15563
15737
  }, [file.id]);
15564
15738
  const download = () => {
@@ -15574,29 +15748,29 @@ function FileViewer({ file, resolveUrl, sidePanel, sidePanelLabel = "Details", o
15574
15748
  a.remove();
15575
15749
  }).catch((err) => setDownloadError(err && err.message || "Download failed.")).finally(() => setDownloading(false));
15576
15750
  };
15577
- return /* @__PURE__ */ (0, import_jsx_runtime108.jsxs)(
15751
+ return /* @__PURE__ */ (0, import_jsx_runtime110.jsxs)(
15578
15752
  "section",
15579
15753
  {
15580
15754
  className: ["fd-fv", hasSide && tab === "side" ? "is-tab-side" : "is-tab-preview", className].filter(Boolean).join(" "),
15581
15755
  "aria-label": file.name || "File",
15582
15756
  children: [
15583
- /* @__PURE__ */ (0, import_jsx_runtime108.jsxs)("header", { className: "fd-fv-head", children: [
15584
- /* @__PURE__ */ (0, import_jsx_runtime108.jsx)("span", { className: "fd-fv-head-icon", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime108.jsx)("i", { className: "ph ph-" + iconForMime(file.mime, file.name) }) }),
15585
- /* @__PURE__ */ (0, import_jsx_runtime108.jsxs)("span", { className: "fd-fv-head-titles", children: [
15586
- /* @__PURE__ */ (0, import_jsx_runtime108.jsx)("span", { className: "fd-fv-head-title", title: file.name, children: file.name }),
15587
- /* @__PURE__ */ (0, import_jsx_runtime108.jsxs)("span", { className: "fd-fv-head-meta", children: [
15757
+ /* @__PURE__ */ (0, import_jsx_runtime110.jsxs)("header", { className: "fd-fv-head", children: [
15758
+ /* @__PURE__ */ (0, import_jsx_runtime110.jsx)("span", { className: "fd-fv-head-icon", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime110.jsx)("i", { className: "ph ph-" + iconForMime(file.mime, file.name) }) }),
15759
+ /* @__PURE__ */ (0, import_jsx_runtime110.jsxs)("span", { className: "fd-fv-head-titles", children: [
15760
+ /* @__PURE__ */ (0, import_jsx_runtime110.jsx)("span", { className: "fd-fv-head-title", title: file.name, children: file.name }),
15761
+ /* @__PURE__ */ (0, import_jsx_runtime110.jsxs)("span", { className: "fd-fv-head-meta", children: [
15588
15762
  file.mime || "Unknown type",
15589
15763
  file.size ? " \xB7 " + formatBytes(file.size) : ""
15590
15764
  ] })
15591
15765
  ] }),
15592
- /* @__PURE__ */ (0, import_jsx_runtime108.jsxs)("span", { className: "fd-fv-head-actions", children: [
15766
+ /* @__PURE__ */ (0, import_jsx_runtime110.jsxs)("span", { className: "fd-fv-head-actions", children: [
15593
15767
  actions,
15594
- /* @__PURE__ */ (0, import_jsx_runtime108.jsx)(Button, { variant: "secondary", size: "sm", icon: "download-simple", loading: downloading, onClick: download, children: "Download" }),
15595
- onClose ? /* @__PURE__ */ (0, import_jsx_runtime108.jsx)(IconButton, { icon: "x", label: "Close", onClick: onClose }) : null
15768
+ /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(Button, { variant: "secondary", size: "sm", icon: "download-simple", loading: downloading, onClick: download, children: "Download" }),
15769
+ onClose ? /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(IconButton, { icon: "x", label: "Close", onClick: onClose }) : null
15596
15770
  ] })
15597
15771
  ] }),
15598
- downloadError ? /* @__PURE__ */ (0, import_jsx_runtime108.jsx)("div", { className: "fd-fv-download-error", role: "alert", children: downloadError }) : null,
15599
- hasSide ? /* @__PURE__ */ (0, import_jsx_runtime108.jsx)(
15772
+ downloadError ? /* @__PURE__ */ (0, import_jsx_runtime110.jsx)("div", { className: "fd-fv-download-error", role: "alert", children: downloadError }) : null,
15773
+ hasSide ? /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(
15600
15774
  Tabs,
15601
15775
  {
15602
15776
  className: "fd-fv-tabs",
@@ -15605,19 +15779,19 @@ function FileViewer({ file, resolveUrl, sidePanel, sidePanelLabel = "Details", o
15605
15779
  onChange: (v) => setTab(v)
15606
15780
  }
15607
15781
  ) : null,
15608
- /* @__PURE__ */ (0, import_jsx_runtime108.jsxs)("div", { className: "fd-fv-body", children: [
15609
- /* @__PURE__ */ (0, import_jsx_runtime108.jsx)("div", { className: "fd-fv-preview", role: "region", "aria-label": "Preview of " + (file.name || "file"), children: /* @__PURE__ */ (0, import_jsx_runtime108.jsx)(
15782
+ /* @__PURE__ */ (0, import_jsx_runtime110.jsxs)("div", { className: "fd-fv-body", children: [
15783
+ /* @__PURE__ */ (0, import_jsx_runtime110.jsx)("div", { className: "fd-fv-preview", role: "region", "aria-label": "Preview of " + (file.name || "file"), children: /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(
15610
15784
  LoadingRegion,
15611
15785
  {
15612
15786
  state: preview.status === "loading" ? "loading" : preview.status === "error" ? "error" : "ready",
15613
15787
  error: preview.error,
15614
15788
  label: "Loading preview of " + (file.name || "file"),
15615
15789
  onRetry: preview.status === "error" ? preview.retry : void 0,
15616
- skeleton: /* @__PURE__ */ (0, import_jsx_runtime108.jsx)(Skeleton, { shape: "card", h: 220 }),
15617
- children: /* @__PURE__ */ (0, import_jsx_runtime108.jsx)(PreviewBody, { file, kind, state: preview })
15790
+ skeleton: /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(Skeleton, { shape: "card", h: 220 }),
15791
+ children: /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(PreviewBody, { file, kind, state: preview })
15618
15792
  }
15619
15793
  ) }),
15620
- hasSide ? /* @__PURE__ */ (0, import_jsx_runtime108.jsx)("div", { className: "fd-fv-side", role: "region", "aria-label": sidePanelLabel, children: sidePanel }) : null
15794
+ hasSide ? /* @__PURE__ */ (0, import_jsx_runtime110.jsx)("div", { className: "fd-fv-side", role: "region", "aria-label": sidePanelLabel, children: sidePanel }) : null
15621
15795
  ] })
15622
15796
  ]
15623
15797
  }
@@ -15625,8 +15799,8 @@ function FileViewer({ file, resolveUrl, sidePanel, sidePanelLabel = "Details", o
15625
15799
  }
15626
15800
 
15627
15801
  // src/components/files/FileBrowser.tsx
15628
- var React82 = __toESM(require("react"), 1);
15629
- var import_jsx_runtime109 = require("react/jsx-runtime");
15802
+ var React85 = __toESM(require("react"), 1);
15803
+ var import_jsx_runtime111 = require("react/jsx-runtime");
15630
15804
  function childrenOf(folders, parentId) {
15631
15805
  return folders.filter((f) => f.parentId === parentId).sort((a, b) => a.name.localeCompare(b.name));
15632
15806
  }
@@ -15698,8 +15872,8 @@ function FolderPickerMenu({
15698
15872
  }) {
15699
15873
  const panel = useInlinePanel();
15700
15874
  const { open: open2, setOpen, ref } = panel;
15701
- return /* @__PURE__ */ (0, import_jsx_runtime109.jsxs)("span", { className: "fd-fb-menu-anchor", ref, children: [
15702
- /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
15875
+ return /* @__PURE__ */ (0, import_jsx_runtime111.jsxs)("span", { className: "fd-fb-menu-anchor", ref, children: [
15876
+ /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(
15703
15877
  IconButton,
15704
15878
  {
15705
15879
  icon: "arrows-out-cardinal",
@@ -15711,9 +15885,9 @@ function FolderPickerMenu({
15711
15885
  onClick: () => setOpen((v) => !v)
15712
15886
  }
15713
15887
  ),
15714
- /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(InlinePanelSurface, { panel, align: "right", offset: 4, width: 220, maxHeight: 280, role: "menu", label, children: /* @__PURE__ */ (0, import_jsx_runtime109.jsxs)("div", { className: "fd-fb-menu", children: [
15715
- /* @__PURE__ */ (0, import_jsx_runtime109.jsx)("span", { className: "fd-overline fd-muted fd-fb-menu-title", children: "Move to\u2026" }),
15716
- destinations.map((d) => /* @__PURE__ */ (0, import_jsx_runtime109.jsxs)(
15888
+ /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(InlinePanelSurface, { panel, align: "right", offset: 4, width: 220, maxHeight: 280, role: "menu", label, children: /* @__PURE__ */ (0, import_jsx_runtime111.jsxs)("div", { className: "fd-fb-menu", children: [
15889
+ /* @__PURE__ */ (0, import_jsx_runtime111.jsx)("span", { className: "fd-overline fd-muted fd-fb-menu-title", children: "Move to\u2026" }),
15890
+ destinations.map((d) => /* @__PURE__ */ (0, import_jsx_runtime111.jsxs)(
15717
15891
  "button",
15718
15892
  {
15719
15893
  type: "button",
@@ -15725,7 +15899,7 @@ function FolderPickerMenu({
15725
15899
  setOpen(false);
15726
15900
  },
15727
15901
  children: [
15728
- /* @__PURE__ */ (0, import_jsx_runtime109.jsx)("i", { className: "ph ph-" + (d.id == null ? "house-simple" : "folder-simple"), "aria-hidden": "true" }),
15902
+ /* @__PURE__ */ (0, import_jsx_runtime111.jsx)("i", { className: "ph ph-" + (d.id == null ? "house-simple" : "folder-simple"), "aria-hidden": "true" }),
15729
15903
  d.name
15730
15904
  ]
15731
15905
  },
@@ -15735,8 +15909,8 @@ function FolderPickerMenu({
15735
15909
  ] });
15736
15910
  }
15737
15911
  function RowShell({ icon, name, meta, onOpen, draggableId, isDropTarget, onDropPayload, actions, className = "" }) {
15738
- const [over, setOver] = React82.useState(false);
15739
- const dragCounter = React82.useRef(0);
15912
+ const [over, setOver] = React85.useState(false);
15913
+ const dragCounter = React85.useRef(0);
15740
15914
  const dropHandlers = isDropTarget ? {
15741
15915
  onDragEnter: (e) => {
15742
15916
  if (!hasInternalPayload(e)) return;
@@ -15761,8 +15935,8 @@ function RowShell({ icon, name, meta, onOpen, draggableId, isDropTarget, onDropP
15761
15935
  if (payload && onDropPayload) onDropPayload(payload);
15762
15936
  }
15763
15937
  } : {};
15764
- return /* @__PURE__ */ (0, import_jsx_runtime109.jsxs)("div", { className: ["fd-fb-row", over ? "is-drop-target" : "", className].filter(Boolean).join(" "), ...dropHandlers, children: [
15765
- /* @__PURE__ */ (0, import_jsx_runtime109.jsxs)(
15938
+ return /* @__PURE__ */ (0, import_jsx_runtime111.jsxs)("div", { className: ["fd-fb-row", over ? "is-drop-target" : "", className].filter(Boolean).join(" "), ...dropHandlers, children: [
15939
+ /* @__PURE__ */ (0, import_jsx_runtime111.jsxs)(
15766
15940
  "button",
15767
15941
  {
15768
15942
  type: "button",
@@ -15771,26 +15945,26 @@ function RowShell({ icon, name, meta, onOpen, draggableId, isDropTarget, onDropP
15771
15945
  draggable: !!draggableId,
15772
15946
  onDragStart: draggableId ? (e) => writeDragPayload(e, draggableId) : void 0,
15773
15947
  children: [
15774
- /* @__PURE__ */ (0, import_jsx_runtime109.jsx)("span", { className: "fd-fb-row-icon", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime109.jsx)("i", { className: "ph ph-" + icon }) }),
15775
- /* @__PURE__ */ (0, import_jsx_runtime109.jsxs)("span", { className: "fd-fb-row-text", children: [
15776
- /* @__PURE__ */ (0, import_jsx_runtime109.jsx)("span", { className: "fd-fb-row-name", title: name, children: name }),
15777
- meta ? /* @__PURE__ */ (0, import_jsx_runtime109.jsx)("span", { className: "fd-fb-row-meta", children: meta }) : null
15948
+ /* @__PURE__ */ (0, import_jsx_runtime111.jsx)("span", { className: "fd-fb-row-icon", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime111.jsx)("i", { className: "ph ph-" + icon }) }),
15949
+ /* @__PURE__ */ (0, import_jsx_runtime111.jsxs)("span", { className: "fd-fb-row-text", children: [
15950
+ /* @__PURE__ */ (0, import_jsx_runtime111.jsx)("span", { className: "fd-fb-row-name", title: name, children: name }),
15951
+ meta ? /* @__PURE__ */ (0, import_jsx_runtime111.jsx)("span", { className: "fd-fb-row-meta", children: meta }) : null
15778
15952
  ] })
15779
15953
  ]
15780
15954
  }
15781
15955
  ),
15782
- actions ? /* @__PURE__ */ (0, import_jsx_runtime109.jsx)("span", { className: "fd-fb-row-actions", children: actions }) : null
15956
+ actions ? /* @__PURE__ */ (0, import_jsx_runtime111.jsx)("span", { className: "fd-fb-row-actions", children: actions }) : null
15783
15957
  ] });
15784
15958
  }
15785
15959
  function TreeNode({ folder, depth, folders, currentFolderId, onNavigate, onMoveInto, canMove }) {
15786
15960
  const kids = childrenOf(folders, folder.id);
15787
- const [expanded, setExpanded] = React82.useState(() => currentFolderId != null && isSelfOrDescendant(folders, folder.id, currentFolderId));
15788
- React82.useEffect(() => {
15961
+ const [expanded, setExpanded] = React85.useState(() => currentFolderId != null && isSelfOrDescendant(folders, folder.id, currentFolderId));
15962
+ React85.useEffect(() => {
15789
15963
  if (currentFolderId != null && isSelfOrDescendant(folders, folder.id, currentFolderId)) setExpanded(true);
15790
15964
  }, [currentFolderId, folder.id, folders]);
15791
15965
  const isCurrent = folder.id === currentFolderId;
15792
- return /* @__PURE__ */ (0, import_jsx_runtime109.jsxs)("div", { className: "fd-fb-tree-node", children: [
15793
- /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
15966
+ return /* @__PURE__ */ (0, import_jsx_runtime111.jsxs)("div", { className: "fd-fb-tree-node", children: [
15967
+ /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(
15794
15968
  RowShell,
15795
15969
  {
15796
15970
  icon: folder.id === currentFolderId ? "folder-open" : "folder-simple",
@@ -15800,7 +15974,7 @@ function TreeNode({ folder, depth, folders, currentFolderId, onNavigate, onMoveI
15800
15974
  isDropTarget: canMove,
15801
15975
  onDropPayload: (payload) => onMoveInto(payload, folder.id),
15802
15976
  className: ["fd-fb-tree-row", isCurrent ? "is-current" : ""].filter(Boolean).join(" "),
15803
- actions: kids.length ? /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
15977
+ actions: kids.length ? /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(
15804
15978
  IconButton,
15805
15979
  {
15806
15980
  icon: expanded ? "caret-down" : "caret-right",
@@ -15812,7 +15986,7 @@ function TreeNode({ folder, depth, folders, currentFolderId, onNavigate, onMoveI
15812
15986
  ) : void 0
15813
15987
  }
15814
15988
  ),
15815
- expanded && kids.length ? /* @__PURE__ */ (0, import_jsx_runtime109.jsx)("div", { className: "fd-fb-tree-children", style: { paddingLeft: 14 }, children: kids.map((k) => /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
15989
+ expanded && kids.length ? /* @__PURE__ */ (0, import_jsx_runtime111.jsx)("div", { className: "fd-fb-tree-children", style: { paddingLeft: 14 }, children: kids.map((k) => /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(
15816
15990
  TreeNode,
15817
15991
  {
15818
15992
  folder: k,
@@ -15851,15 +16025,15 @@ function FileBrowser({
15851
16025
  const canUpload = perm.canUpload !== false && !!onUpload;
15852
16026
  const canRemoveFile = perm.canRemoveFile !== false && !!onRemoveFile;
15853
16027
  const canDeleteFolder = perm.canDeleteFolder !== false && !!onDeleteFolder;
15854
- const [createOpen, setCreateOpen] = React82.useState(false);
15855
- const [createName, setCreateName] = React82.useState("");
15856
- const [renameTarget, setRenameTarget] = React82.useState(null);
15857
- const [renameValue, setRenameValue] = React82.useState("");
15858
- const [deleteTarget, setDeleteTarget] = React82.useState(null);
15859
- const uploadInputRef = React82.useRef(null);
15860
- const crumbFolders = React82.useMemo(() => ancestorsOf(folders, currentFolderId), [folders, currentFolderId]);
15861
- const subfolders = React82.useMemo(() => childrenOf(folders, currentFolderId), [folders, currentFolderId]);
15862
- const currentFiles = React82.useMemo(
16028
+ const [createOpen, setCreateOpen] = React85.useState(false);
16029
+ const [createName, setCreateName] = React85.useState("");
16030
+ const [renameTarget, setRenameTarget] = React85.useState(null);
16031
+ const [renameValue, setRenameValue] = React85.useState("");
16032
+ const [deleteTarget, setDeleteTarget] = React85.useState(null);
16033
+ const uploadInputRef = React85.useRef(null);
16034
+ const crumbFolders = React85.useMemo(() => ancestorsOf(folders, currentFolderId), [folders, currentFolderId]);
16035
+ const subfolders = React85.useMemo(() => childrenOf(folders, currentFolderId), [folders, currentFolderId]);
16036
+ const currentFiles = React85.useMemo(
15863
16037
  () => files.filter((f) => f.folderId === currentFolderId).sort((a, b) => a.name.localeCompare(b.name)),
15864
16038
  [files, currentFolderId]
15865
16039
  );
@@ -15898,10 +16072,10 @@ function FileBrowser({
15898
16072
  if (deleteTarget && onDeleteFolder) onDeleteFolder(deleteTarget);
15899
16073
  setDeleteTarget(null);
15900
16074
  };
15901
- const content = /* @__PURE__ */ (0, import_jsx_runtime109.jsxs)("div", { className: ["fd-fb", className].filter(Boolean).join(" "), children: [
15902
- /* @__PURE__ */ (0, import_jsx_runtime109.jsxs)("div", { className: "fd-fb-head", children: [
15903
- /* @__PURE__ */ (0, import_jsx_runtime109.jsxs)("nav", { className: "fd-fb-crumbs", "aria-label": "Folder path", children: [
15904
- /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
16075
+ const content = /* @__PURE__ */ (0, import_jsx_runtime111.jsxs)("div", { className: ["fd-fb", className].filter(Boolean).join(" "), children: [
16076
+ /* @__PURE__ */ (0, import_jsx_runtime111.jsxs)("div", { className: "fd-fb-head", children: [
16077
+ /* @__PURE__ */ (0, import_jsx_runtime111.jsxs)("nav", { className: "fd-fb-crumbs", "aria-label": "Folder path", children: [
16078
+ /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(
15905
16079
  BreadcrumbCrumb,
15906
16080
  {
15907
16081
  label: "Home",
@@ -15911,7 +16085,7 @@ function FileBrowser({
15911
16085
  onDropPayload: (p) => moveIntoFolder(p, null)
15912
16086
  }
15913
16087
  ),
15914
- crumbFolders.map((f, i) => /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
16088
+ crumbFolders.map((f, i) => /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(
15915
16089
  BreadcrumbCrumb,
15916
16090
  {
15917
16091
  label: f.name,
@@ -15923,11 +16097,11 @@ function FileBrowser({
15923
16097
  f.id
15924
16098
  ))
15925
16099
  ] }),
15926
- /* @__PURE__ */ (0, import_jsx_runtime109.jsxs)("span", { className: "fd-fb-actions", children: [
15927
- canCreateFolder ? /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(Button, { variant: "secondary", size: "sm", icon: "folder-simple-plus", onClick: openCreate, children: "New folder" }) : null,
15928
- canUpload ? /* @__PURE__ */ (0, import_jsx_runtime109.jsxs)(import_jsx_runtime109.Fragment, { children: [
15929
- /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(Button, { variant: "secondary", size: "sm", icon: "upload-simple", onClick: () => uploadInputRef.current && uploadInputRef.current.click(), children: "Upload" }),
15930
- /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
16100
+ /* @__PURE__ */ (0, import_jsx_runtime111.jsxs)("span", { className: "fd-fb-actions", children: [
16101
+ canCreateFolder ? /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(Button, { variant: "secondary", size: "sm", icon: "folder-simple-plus", onClick: openCreate, children: "New folder" }) : null,
16102
+ canUpload ? /* @__PURE__ */ (0, import_jsx_runtime111.jsxs)(import_jsx_runtime111.Fragment, { children: [
16103
+ /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(Button, { variant: "secondary", size: "sm", icon: "upload-simple", onClick: () => uploadInputRef.current && uploadInputRef.current.click(), children: "Upload" }),
16104
+ /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(
15931
16105
  "input",
15932
16106
  {
15933
16107
  ref: uploadInputRef,
@@ -15945,9 +16119,9 @@ function FileBrowser({
15945
16119
  ] }) : null
15946
16120
  ] })
15947
16121
  ] }),
15948
- /* @__PURE__ */ (0, import_jsx_runtime109.jsxs)("div", { className: "fd-fb-body", children: [
15949
- /* @__PURE__ */ (0, import_jsx_runtime109.jsxs)("div", { className: "fd-fb-tree", role: "region", "aria-label": "Folder tree", children: [
15950
- /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
16122
+ /* @__PURE__ */ (0, import_jsx_runtime111.jsxs)("div", { className: "fd-fb-body", children: [
16123
+ /* @__PURE__ */ (0, import_jsx_runtime111.jsxs)("div", { className: "fd-fb-tree", role: "region", "aria-label": "Folder tree", children: [
16124
+ /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(
15951
16125
  RowShell,
15952
16126
  {
15953
16127
  icon: "house-simple",
@@ -15958,7 +16132,7 @@ function FileBrowser({
15958
16132
  className: ["fd-fb-tree-row", currentFolderId == null ? "is-current" : ""].filter(Boolean).join(" ")
15959
16133
  }
15960
16134
  ),
15961
- childrenOf(folders, null).map((f) => /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
16135
+ childrenOf(folders, null).map((f) => /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(
15962
16136
  TreeNode,
15963
16137
  {
15964
16138
  folder: f,
@@ -15972,18 +16146,18 @@ function FileBrowser({
15972
16146
  f.id
15973
16147
  ))
15974
16148
  ] }),
15975
- /* @__PURE__ */ (0, import_jsx_runtime109.jsx)("div", { className: "fd-fb-main", role: "region", "aria-label": "Folder contents", children: /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
16149
+ /* @__PURE__ */ (0, import_jsx_runtime111.jsx)("div", { className: "fd-fb-main", role: "region", "aria-label": "Folder contents", children: /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(
15976
16150
  LoadingRegion,
15977
16151
  {
15978
16152
  state: loading ? "loading" : "ready",
15979
16153
  label: "Loading folder contents",
15980
- skeleton: /* @__PURE__ */ (0, import_jsx_runtime109.jsxs)("div", { className: "fd-stack", style: { gap: 8, padding: 12 }, children: [
15981
- /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(Skeleton, { h: 44, radius: "10px" }),
15982
- /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(Skeleton, { h: 44, radius: "10px" }),
15983
- /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(Skeleton, { h: 44, radius: "10px" })
16154
+ skeleton: /* @__PURE__ */ (0, import_jsx_runtime111.jsxs)("div", { className: "fd-stack", style: { gap: 8, padding: 12 }, children: [
16155
+ /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(Skeleton, { h: 44, radius: "10px" }),
16156
+ /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(Skeleton, { h: 44, radius: "10px" }),
16157
+ /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(Skeleton, { h: 44, radius: "10px" })
15984
16158
  ] }),
15985
- children: isEmpty ? /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(EmptyState, { icon: "folder-open", title: "This folder is empty", children: canUpload ? "Drop files here, or use Upload above." : "Nothing has been filed here yet." }) : /* @__PURE__ */ (0, import_jsx_runtime109.jsxs)("div", { className: "fd-fb-list", children: [
15986
- subfolders.map((f) => /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
16159
+ children: isEmpty ? /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(EmptyState, { icon: "folder-open", title: "This folder is empty", children: canUpload ? "Drop files here, or use Upload above." : "Nothing has been filed here yet." }) : /* @__PURE__ */ (0, import_jsx_runtime111.jsxs)("div", { className: "fd-fb-list", children: [
16160
+ subfolders.map((f) => /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(
15987
16161
  RowShell,
15988
16162
  {
15989
16163
  icon: "folder-simple",
@@ -15992,9 +16166,9 @@ function FileBrowser({
15992
16166
  draggableId: canMove ? { kind: "folder", id: f.id } : void 0,
15993
16167
  isDropTarget: canMove,
15994
16168
  onDropPayload: (p) => moveIntoFolder(p, f.id),
15995
- actions: /* @__PURE__ */ (0, import_jsx_runtime109.jsxs)(import_jsx_runtime109.Fragment, { children: [
15996
- canRenameFolder ? /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(IconButton, { icon: "pencil-simple", label: "Rename " + f.name, size: "sm", variant: "ghost", onClick: () => openRename(f) }) : null,
15997
- canMove ? /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
16169
+ actions: /* @__PURE__ */ (0, import_jsx_runtime111.jsxs)(import_jsx_runtime111.Fragment, { children: [
16170
+ canRenameFolder ? /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(IconButton, { icon: "pencil-simple", label: "Rename " + f.name, size: "sm", variant: "ghost", onClick: () => openRename(f) }) : null,
16171
+ canMove ? /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(
15998
16172
  FolderPickerMenu,
15999
16173
  {
16000
16174
  label: "Move " + f.name,
@@ -16002,12 +16176,12 @@ function FileBrowser({
16002
16176
  onPick: (target) => moveIntoFolder({ kind: "folder", id: f.id }, target)
16003
16177
  }
16004
16178
  ) : null,
16005
- canDeleteFolder ? /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(IconButton, { icon: "trash-simple", label: "Delete " + f.name, size: "sm", variant: "ghost", onClick: () => openDelete(f) }) : null
16179
+ canDeleteFolder ? /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(IconButton, { icon: "trash-simple", label: "Delete " + f.name, size: "sm", variant: "ghost", onClick: () => openDelete(f) }) : null
16006
16180
  ] })
16007
16181
  },
16008
16182
  f.id
16009
16183
  )),
16010
- currentFiles.map((file) => /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
16184
+ currentFiles.map((file) => /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(
16011
16185
  RowShell,
16012
16186
  {
16013
16187
  icon: iconForMime(file.mime, file.name),
@@ -16015,8 +16189,8 @@ function FileBrowser({
16015
16189
  meta: file.size ? formatBytes(file.size) : void 0,
16016
16190
  onOpen: onOpenFile ? () => onOpenFile(file) : void 0,
16017
16191
  draggableId: canMove ? { kind: "file", id: file.id } : void 0,
16018
- actions: /* @__PURE__ */ (0, import_jsx_runtime109.jsxs)(import_jsx_runtime109.Fragment, { children: [
16019
- canMove ? /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
16192
+ actions: /* @__PURE__ */ (0, import_jsx_runtime111.jsxs)(import_jsx_runtime111.Fragment, { children: [
16193
+ canMove ? /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(
16020
16194
  FolderPickerMenu,
16021
16195
  {
16022
16196
  label: "Move " + file.name,
@@ -16024,7 +16198,7 @@ function FileBrowser({
16024
16198
  onPick: (target) => onMoveFile && onMoveFile(file.id, target)
16025
16199
  }
16026
16200
  ) : null,
16027
- canRemoveFile ? /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(IconButton, { icon: "trash-simple", label: "Remove " + file.name, size: "sm", variant: "ghost", onClick: () => onRemoveFile && onRemoveFile(file) }) : null
16201
+ canRemoveFile ? /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(IconButton, { icon: "trash-simple", label: "Remove " + file.name, size: "sm", variant: "ghost", onClick: () => onRemoveFile && onRemoveFile(file) }) : null
16028
16202
  ] })
16029
16203
  },
16030
16204
  file.id
@@ -16033,10 +16207,10 @@ function FileBrowser({
16033
16207
  }
16034
16208
  ) })
16035
16209
  ] }),
16036
- /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(Modal, { open: createOpen, title: "New folder", onClose: () => setCreateOpen(false), footer: /* @__PURE__ */ (0, import_jsx_runtime109.jsxs)(import_jsx_runtime109.Fragment, { children: [
16037
- /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(Button, { variant: "secondary", onClick: () => setCreateOpen(false), children: "Cancel" }),
16038
- /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(Button, { onClick: submitCreate, disabled: !createName.trim(), children: "Create" })
16039
- ] }), children: /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
16210
+ /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(Modal, { open: createOpen, title: "New folder", onClose: () => setCreateOpen(false), footer: /* @__PURE__ */ (0, import_jsx_runtime111.jsxs)(import_jsx_runtime111.Fragment, { children: [
16211
+ /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(Button, { variant: "secondary", onClick: () => setCreateOpen(false), children: "Cancel" }),
16212
+ /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(Button, { onClick: submitCreate, disabled: !createName.trim(), children: "Create" })
16213
+ ] }), children: /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(
16040
16214
  "input",
16041
16215
  {
16042
16216
  className: "fd-fb-input",
@@ -16050,10 +16224,10 @@ function FileBrowser({
16050
16224
  autoFocus: true
16051
16225
  }
16052
16226
  ) }),
16053
- /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(Modal, { open: renameTarget != null, title: "Rename folder", onClose: () => setRenameTarget(null), footer: /* @__PURE__ */ (0, import_jsx_runtime109.jsxs)(import_jsx_runtime109.Fragment, { children: [
16054
- /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(Button, { variant: "secondary", onClick: () => setRenameTarget(null), children: "Cancel" }),
16055
- /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(Button, { onClick: submitRename, disabled: !renameValue.trim(), children: "Save" })
16056
- ] }), children: /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
16227
+ /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(Modal, { open: renameTarget != null, title: "Rename folder", onClose: () => setRenameTarget(null), footer: /* @__PURE__ */ (0, import_jsx_runtime111.jsxs)(import_jsx_runtime111.Fragment, { children: [
16228
+ /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(Button, { variant: "secondary", onClick: () => setRenameTarget(null), children: "Cancel" }),
16229
+ /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(Button, { onClick: submitRename, disabled: !renameValue.trim(), children: "Save" })
16230
+ ] }), children: /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(
16057
16231
  "input",
16058
16232
  {
16059
16233
  className: "fd-fb-input",
@@ -16067,22 +16241,22 @@ function FileBrowser({
16067
16241
  autoFocus: true
16068
16242
  }
16069
16243
  ) }),
16070
- /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
16244
+ /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(
16071
16245
  Modal,
16072
16246
  {
16073
16247
  open: deleteTarget != null,
16074
16248
  title: deleteTarget ? "Delete \u201C" + deleteTarget.name + "\u201D?" : "Delete folder?",
16075
16249
  description: "This can't be undone. The folder must be empty.",
16076
16250
  onClose: () => setDeleteTarget(null),
16077
- footer: /* @__PURE__ */ (0, import_jsx_runtime109.jsxs)(import_jsx_runtime109.Fragment, { children: [
16078
- /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(Button, { variant: "secondary", onClick: () => setDeleteTarget(null), children: "Cancel" }),
16079
- /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(Button, { variant: "danger", onClick: confirmDelete, children: "Delete" })
16251
+ footer: /* @__PURE__ */ (0, import_jsx_runtime111.jsxs)(import_jsx_runtime111.Fragment, { children: [
16252
+ /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(Button, { variant: "secondary", onClick: () => setDeleteTarget(null), children: "Cancel" }),
16253
+ /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(Button, { variant: "danger", onClick: confirmDelete, children: "Delete" })
16080
16254
  ] })
16081
16255
  }
16082
16256
  )
16083
16257
  ] });
16084
16258
  if (!canUpload) return content;
16085
- return /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(Dropzone, { className: "fd-fb-dropzone", onFiles: (picked) => onUpload && onUpload(picked, currentFolderId), label: "Drop files to upload", children: content });
16259
+ return /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(Dropzone, { className: "fd-fb-dropzone", onFiles: (picked) => onUpload && onUpload(picked, currentFolderId), label: "Drop files to upload", children: content });
16086
16260
  }
16087
16261
  function BreadcrumbCrumb({
16088
16262
  label,
@@ -16091,8 +16265,8 @@ function BreadcrumbCrumb({
16091
16265
  isDropTarget,
16092
16266
  onDropPayload
16093
16267
  }) {
16094
- const [over, setOver] = React82.useState(false);
16095
- const dragCounter = React82.useRef(0);
16268
+ const [over, setOver] = React85.useState(false);
16269
+ const dragCounter = React85.useRef(0);
16096
16270
  const dropHandlers = isDropTarget ? {
16097
16271
  onDragEnter: (e) => {
16098
16272
  if (!hasInternalPayload(e)) return;
@@ -16117,11 +16291,11 @@ function BreadcrumbCrumb({
16117
16291
  if (payload && onDropPayload) onDropPayload(payload);
16118
16292
  }
16119
16293
  } : {};
16120
- return /* @__PURE__ */ (0, import_jsx_runtime109.jsx)("span", { className: ["fd-fb-crumb", over ? "is-drop-target" : ""].filter(Boolean).join(" "), ...dropHandlers, children: isCurrent ? /* @__PURE__ */ (0, import_jsx_runtime109.jsx)("span", { className: "fd-fb-crumb-current", "aria-current": "page", children: label }) : /* @__PURE__ */ (0, import_jsx_runtime109.jsx)("button", { type: "button", className: "fd-fb-crumb-link", onClick, children: label }) });
16294
+ return /* @__PURE__ */ (0, import_jsx_runtime111.jsx)("span", { className: ["fd-fb-crumb", over ? "is-drop-target" : ""].filter(Boolean).join(" "), ...dropHandlers, children: isCurrent ? /* @__PURE__ */ (0, import_jsx_runtime111.jsx)("span", { className: "fd-fb-crumb-current", "aria-current": "page", children: label }) : /* @__PURE__ */ (0, import_jsx_runtime111.jsx)("button", { type: "button", className: "fd-fb-crumb-link", onClick, children: label }) });
16121
16295
  }
16122
16296
 
16123
16297
  // src/kits/query.ts
16124
- var React83 = __toESM(require("react"), 1);
16298
+ var React86 = __toESM(require("react"), 1);
16125
16299
 
16126
16300
  // src/kits/queryUrl.ts
16127
16301
  var historyUrlAdapter = {
@@ -16259,38 +16433,38 @@ function requestFor(params, query, paging, after) {
16259
16433
  }
16260
16434
  var toError = (e) => e instanceof Error ? e : new Error(String(e));
16261
16435
  function useServerTable({ endpoint, params, defaults, deps, prefsKey, paging = "page", url }) {
16262
- const [base] = React83.useState(() => {
16436
+ const [base] = React86.useState(() => {
16263
16437
  const store = PREFS || window.PlannerPrefs;
16264
16438
  const saved = prefsKey && store ? store.getTable(prefsKey) : {};
16265
16439
  return { ...DEFAULTS, ...defaults || {}, ...saved.pageSize ? { pageSize: saved.pageSize } : {}, ...saved.sort ? { sort: saved.sort, dir: saved.dir || "desc" } : {} };
16266
16440
  });
16267
- const [mountParams] = React83.useState(() => url ? (url.adapter ?? historyUrlAdapter).read() : null);
16268
- const address = React83.useRef(mountParams);
16269
- const [query, setQuery] = React83.useState(() => url && mountParams ? readQueryFromUrl(mountParams, url.scope, base, paging) : base);
16270
- const savePref = React83.useCallback((patch2) => {
16441
+ const [mountParams] = React86.useState(() => url ? (url.adapter ?? historyUrlAdapter).read() : null);
16442
+ const address = React86.useRef(mountParams);
16443
+ const [query, setQuery] = React86.useState(() => url && mountParams ? readQueryFromUrl(mountParams, url.scope, base, paging) : base);
16444
+ const savePref = React86.useCallback((patch2) => {
16271
16445
  const store = PREFS || window.PlannerPrefs;
16272
16446
  if (prefsKey && store) store.setTable(prefsKey, patch2);
16273
16447
  }, [prefsKey]);
16274
- const [res, setRes] = React83.useState(null);
16275
- const [loading, setLoading] = React83.useState(true);
16276
- const [loadingMore, setLoadingMore] = React83.useState(false);
16277
- const [failure, setFailure] = React83.useState(null);
16278
- const [reloadToken, setReloadToken] = React83.useState(0);
16279
- const moreController = React83.useRef(null);
16448
+ const [res, setRes] = React86.useState(null);
16449
+ const [loading, setLoading] = React86.useState(true);
16450
+ const [loadingMore, setLoadingMore] = React86.useState(false);
16451
+ const [failure, setFailure] = React86.useState(null);
16452
+ const [reloadToken, setReloadToken] = React86.useState(0);
16453
+ const moreController = React86.useRef(null);
16280
16454
  const depKey = (deps || []).join("|");
16281
16455
  const paramKey = JSON.stringify(params || {});
16282
16456
  const queryKey = JSON.stringify(query);
16283
- const lifetime = React83.useRef(null);
16284
- React83.useEffect(() => {
16457
+ const lifetime = React86.useRef(null);
16458
+ React86.useEffect(() => {
16285
16459
  const controller = new AbortController();
16286
16460
  lifetime.current = controller;
16287
16461
  return () => controller.abort();
16288
16462
  }, []);
16289
- const latest = React83.useRef({ res, loading, query, params, endpoint, url, base });
16290
- React83.useLayoutEffect(() => {
16463
+ const latest = React86.useRef({ res, loading, query, params, endpoint, url, base });
16464
+ React86.useLayoutEffect(() => {
16291
16465
  latest.current = { res, loading, query, params, endpoint, url, base };
16292
16466
  });
16293
- React83.useEffect(() => {
16467
+ React86.useEffect(() => {
16294
16468
  const controller = new AbortController();
16295
16469
  const { signal } = controller;
16296
16470
  setLoading(true);
@@ -16326,7 +16500,7 @@ function useServerTable({ endpoint, params, defaults, deps, prefsKey, paging = "
16326
16500
  };
16327
16501
  }, [endpoint, queryKey, paramKey, depKey, paging, reloadToken]);
16328
16502
  const adapter = url ? url.adapter ?? historyUrlAdapter : null;
16329
- React83.useEffect(() => {
16503
+ React86.useEffect(() => {
16330
16504
  if (!adapter) return;
16331
16505
  return adapter.subscribe((params2) => {
16332
16506
  const { url: u, base: b } = latest.current;
@@ -16676,16 +16850,219 @@ function createVersionStore(initialState, options) {
16676
16850
  }
16677
16851
 
16678
16852
  // src/kits/documentTitle.ts
16679
- var React84 = __toESM(require("react"), 1);
16853
+ var React87 = __toESM(require("react"), 1);
16680
16854
  function formatDocumentTitle(routeTitle, appName) {
16681
16855
  return [routeTitle, appName, "Flytedesk"].filter((part2) => !!part2 && part2.length > 0).join(" \xB7 ");
16682
16856
  }
16683
16857
  function useDocumentTitle(routeTitle, appName) {
16684
- React84.useEffect(() => {
16858
+ React87.useEffect(() => {
16685
16859
  if (typeof document === "undefined") return;
16686
16860
  document.title = formatDocumentTitle(routeTitle, appName);
16687
16861
  }, [routeTitle, appName]);
16688
16862
  }
16863
+
16864
+ // src/kits/chatTransport/deadline.ts
16865
+ var CHAT_CALL_DEADLINE_MS = 3e4;
16866
+ var CallDeadlineError = class extends Error {
16867
+ constructor(call, deadlineMs) {
16868
+ super(`${call} did not answer within ${deadlineMs}ms`);
16869
+ this.call = call;
16870
+ this.deadlineMs = deadlineMs;
16871
+ this.name = "CallDeadlineError";
16872
+ }
16873
+ call;
16874
+ deadlineMs;
16875
+ };
16876
+ function withDeadline(call, deadlineMs, work) {
16877
+ let timer;
16878
+ const deadline = new Promise((_resolve, reject) => {
16879
+ timer = setTimeout(() => reject(new CallDeadlineError(call, deadlineMs)), deadlineMs);
16880
+ });
16881
+ return Promise.race([work, deadline]).finally(() => clearTimeout(timer));
16882
+ }
16883
+
16884
+ // src/kits/chatTransport/chatAdapter.ts
16885
+ var CHAT_UNAVAILABLE_MESSAGE = "chat_unavailable";
16886
+ var ChatUnreachableError = class extends Error {
16887
+ constructor(message = CHAT_UNAVAILABLE_MESSAGE) {
16888
+ super(message);
16889
+ this.name = "ChatUnreachableError";
16890
+ }
16891
+ };
16892
+ function createChatAdapter(transport, { onTurnStarted, deadlineMs = CHAT_CALL_DEADLINE_MS } = {}) {
16893
+ const within = (call, work) => withDeadline(call, deadlineMs, work);
16894
+ const common = {
16895
+ async resolveThread(context) {
16896
+ try {
16897
+ const { thread_id } = await within("resolveThread", transport.resolveThread(context));
16898
+ return { thread_id };
16899
+ } catch {
16900
+ throw new Error(CHAT_UNAVAILABLE_MESSAGE);
16901
+ }
16902
+ },
16903
+ async getThread(threadId) {
16904
+ return { messages: await within("getThread", transport.getMessages(threadId)) };
16905
+ },
16906
+ cancelJob: transport.cancelTurn ? (jobId) => within("cancelJob", transport.cancelTurn(jobId)) : void 0
16907
+ };
16908
+ if (transport.streamTurn) {
16909
+ const { streamTurn } = transport;
16910
+ return {
16911
+ ...common,
16912
+ // The engine streams whenever `streamMessage` is present and calls neither of these for a turn that settles.
16913
+ // A streamed turn that answered a job id would have the engine poll one that does not exist: fail loudly.
16914
+ sendMessage: () => Promise.reject(new Error("A streaming chat starts its turns with streamMessage.")),
16915
+ getJob: () => Promise.reject(new Error("A streaming chat has no turn status to poll.")),
16916
+ async streamMessage(threadId, text, handlers, signal, attachments) {
16917
+ let started = false;
16918
+ const markStarted = () => {
16919
+ if (started) return;
16920
+ started = true;
16921
+ onTurnStarted?.();
16922
+ };
16923
+ const accepting = {
16924
+ onToken: (chunk) => (markStarted(), handlers.onToken(chunk)),
16925
+ onStep: handlers.onStep && ((step) => (markStarted(), handlers.onStep(step))),
16926
+ onThinking: handlers.onThinking && ((chunk) => (markStarted(), handlers.onThinking(chunk)))
16927
+ };
16928
+ let result;
16929
+ try {
16930
+ result = await streamTurn(threadId, text, accepting, signal, attachments);
16931
+ } catch (err) {
16932
+ if (err instanceof ChatUnreachableError) throw new Error(CHAT_UNAVAILABLE_MESSAGE);
16933
+ throw err;
16934
+ }
16935
+ if (result.job_id) throw new Error("A streamed turn must end with its final result, not a job to poll.");
16936
+ markStarted();
16937
+ return result;
16938
+ }
16939
+ };
16940
+ }
16941
+ const { startTurn, getTurn } = transport;
16942
+ return {
16943
+ ...common,
16944
+ // `signal` (the engine's Stop-button plumbing) is deliberately not wired to this call: it only starts a dispatch and
16945
+ // never streams, and aborting it could leave a dispatch started server-side with no job id for the engine to track.
16946
+ // Stop is `cancelJob`.
16947
+ async sendMessage(threadId, text, _signal, attachments) {
16948
+ const { jobId } = await within("sendMessage", startTurn(threadId, text, attachments));
16949
+ onTurnStarted?.();
16950
+ return { dispatched: true, job_id: jobId };
16951
+ },
16952
+ async getJob(jobId) {
16953
+ const status = await within("getJob", getTurn(jobId));
16954
+ return status ?? { status: "failed", error: "turn_not_found" };
16955
+ }
16956
+ };
16957
+ }
16958
+
16959
+ // src/kits/chatTransport/useChatThreads.ts
16960
+ var React88 = __toESM(require("react"), 1);
16961
+ var THREADS_LOAD_FAILED = "Your earlier conversations could not be loaded.";
16962
+ var NEW_THREAD_FAILED = "A new conversation could not be started.";
16963
+ function useChatThreads(transport, { deadlineMs = CHAT_CALL_DEADLINE_MS } = {}) {
16964
+ const toast = useToast();
16965
+ const [threads, setThreads] = React88.useState([]);
16966
+ const [reads, setReads] = React88.useState(0);
16967
+ const transportRef = useLatest(transport);
16968
+ const deadlineRef = useLatest(deadlineMs);
16969
+ const refresh2 = React88.useCallback(() => setReads((n) => n + 1), []);
16970
+ React88.useEffect(() => {
16971
+ const controller = new AbortController();
16972
+ const { signal } = controller;
16973
+ withDeadline("listThreads", deadlineRef.current, transportRef.current.listThreads(signal)).then(
16974
+ (listed) => {
16975
+ if (!signal.aborted) setThreads(listed);
16976
+ },
16977
+ () => {
16978
+ if (!signal.aborted) toast.show(THREADS_LOAD_FAILED, { tone: "error" });
16979
+ }
16980
+ );
16981
+ return () => controller.abort();
16982
+ }, [reads, toast, transportRef, deadlineRef]);
16983
+ const startNewThread = React88.useCallback(
16984
+ (onCreated) => withDeadline("createThread", deadlineRef.current, transportRef.current.createThread()).then(
16985
+ ({ thread_id }) => {
16986
+ onCreated(thread_id);
16987
+ refresh2();
16988
+ },
16989
+ () => toast.show(NEW_THREAD_FAILED, { tone: "error" })
16990
+ ),
16991
+ [deadlineRef, transportRef, refresh2, toast]
16992
+ );
16993
+ return { threads, refresh: refresh2, startNewThread };
16994
+ }
16995
+
16996
+ // src/kits/exports/downloadExport.ts
16997
+ function createExportDownloader({
16998
+ mintUrl,
16999
+ navigate = (url) => window.location.assign(url)
17000
+ }) {
17001
+ return (id) => mintUrl(id).then(
17002
+ (url) => {
17003
+ if (url) navigate(url);
17004
+ },
17005
+ () => {
17006
+ }
17007
+ );
17008
+ }
17009
+
17010
+ // src/kits/exports/useExportJobs.ts
17011
+ var React89 = __toESM(require("react"), 1);
17012
+ var EXPORT_POLL_INTERVAL_MS = 3e3;
17013
+ var EXPORT_IDLE_POLL_INTERVAL_MS = 3e4;
17014
+ function useExportJobs({ list, acknowledge }) {
17015
+ const [rows, setRows] = React89.useState([]);
17016
+ const listRef = useLatest(list);
17017
+ const acknowledgeRef = useLatest(acknowledge);
17018
+ const reload = React89.useCallback(
17019
+ () => listRef.current().then(
17020
+ (fresh) => setRows(fresh),
17021
+ () => {
17022
+ }
17023
+ ),
17024
+ [listRef]
17025
+ );
17026
+ React89.useEffect(() => {
17027
+ void reload();
17028
+ }, [reload]);
17029
+ const anyLive = rows.some(isLiveExport);
17030
+ React89.useEffect(() => {
17031
+ const timer = setInterval(() => void reload(), anyLive ? EXPORT_POLL_INTERVAL_MS : EXPORT_IDLE_POLL_INTERVAL_MS);
17032
+ return () => clearInterval(timer);
17033
+ }, [anyLive, reload]);
17034
+ const refresh2 = React89.useCallback(() => void reload(), [reload]);
17035
+ const ackExport = React89.useCallback(
17036
+ (id) => void acknowledgeRef.current(id).then(reload),
17037
+ [acknowledgeRef, reload]
17038
+ );
17039
+ return { exports: rows, ackExport, refresh: refresh2 };
17040
+ }
17041
+
17042
+ // src/kits/exports/ExportTray.tsx
17043
+ var React90 = __toESM(require("react"), 1);
17044
+ var import_jsx_runtime112 = require("react/jsx-runtime");
17045
+ var EXPORT_KEPT_NOTE = "Kept for 24 hours";
17046
+ var EXPORT_FAILED_FALLBACK = "Unknown error.";
17047
+ function exportToJob(job, onDownload) {
17048
+ const base = { id: job.id, title: job.title, note: job.note };
17049
+ if (job.status === "SUCCEEDED") {
17050
+ return {
17051
+ ...base,
17052
+ status: "done",
17053
+ action: { label: "Download", icon: "download-simple", onClick: () => onDownload(job.id) },
17054
+ doneNote: EXPORT_KEPT_NOTE
17055
+ };
17056
+ }
17057
+ if (job.status === "FAILED") {
17058
+ return { ...base, status: "failed", failureReason: job.failureMessage ?? EXPORT_FAILED_FALLBACK };
17059
+ }
17060
+ return { ...base, status: "active" };
17061
+ }
17062
+ function ExportTray({ exports: exports2, onDownload, onDismiss }) {
17063
+ const jobs2 = React90.useMemo(() => exports2.map((job) => exportToJob(job, onDownload)), [exports2, onDownload]);
17064
+ return /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(JobTray, { jobs: jobs2, onDismiss });
17065
+ }
16689
17066
  // Annotate the CommonJS export names for ESM import in node:
16690
17067
  0 && (module.exports = {
16691
17068
  AccountMenu,
@@ -16706,11 +17083,16 @@ function useDocumentTitle(routeTitle, appName) {
16706
17083
  Button,
16707
17084
  CHANNELS,
16708
17085
  CHANNEL_WEIGHTS,
17086
+ CHAT_CALL_DEADLINE_MS,
16709
17087
  CHAT_UNAVAILABLE,
17088
+ CHAT_UNAVAILABLE_MESSAGE,
16710
17089
  COPIED_FEEDBACK_MS,
16711
17090
  CORNER_STACK_INSET_PROPERTY,
16712
17091
  CORNER_STACK_OFFSET_PROPERTY,
17092
+ CSV_FAILED_FALLBACK,
17093
+ CSV_KEPT_NOTE,
16713
17094
  Calendar,
17095
+ CallDeadlineError,
16714
17096
  Card,
16715
17097
  CardGrid,
16716
17098
  CardRow,
@@ -16723,6 +17105,7 @@ function useDocumentTitle(routeTitle, appName) {
16723
17105
  ChatSessionBar,
16724
17106
  ChatTranscript,
16725
17107
  ChatTurn,
17108
+ ChatUnreachableError,
16726
17109
  Checkbox,
16727
17110
  Citations,
16728
17111
  Clamp,
@@ -16735,6 +17118,7 @@ function useDocumentTitle(routeTitle, appName) {
16735
17118
  CsiBadge,
16736
17119
  CsiHero,
16737
17120
  CsiMeter,
17121
+ CsvCard,
16738
17122
  DEFAULT_PREFS,
16739
17123
  DEFAULT_STORAGE_KEY,
16740
17124
  DEFAULT_TOAST_DURATION_MS,
@@ -16747,9 +17131,14 @@ function useDocumentTitle(routeTitle, appName) {
16747
17131
  Dropzone,
16748
17132
  DropzoneKit,
16749
17133
  ENTITY_ROW_METRIC_WIDTH,
17134
+ EXPORT_FAILED_FALLBACK,
17135
+ EXPORT_IDLE_POLL_INTERVAL_MS,
17136
+ EXPORT_KEPT_NOTE,
17137
+ EXPORT_POLL_INTERVAL_MS,
16750
17138
  EmptyState,
16751
17139
  EntityRow,
16752
17140
  EntityRowMetrics,
17141
+ ExportTray,
16753
17142
  FILE_VIEWER_CSV_ROW_LIMIT,
16754
17143
  FILE_VIEWER_TEXT_LIMIT,
16755
17144
  FactList,
@@ -16792,6 +17181,7 @@ function useDocumentTitle(routeTitle, appName) {
16792
17181
  Modal,
16793
17182
  ModeSwitch,
16794
17183
  ModelControls,
17184
+ NEW_THREAD_FAILED,
16795
17185
  NumberInput,
16796
17186
  OVERLAY_BREAKPOINT,
16797
17187
  OVERLAY_CEILING,
@@ -16805,7 +17195,9 @@ function useDocumentTitle(routeTitle, appName) {
16805
17195
  PreferenceMeter,
16806
17196
  ProfilePage,
16807
17197
  ProgressBar,
17198
+ QUERY_EMPTY_MESSAGE,
16808
17199
  QueryKit,
17200
+ QueryResultCard,
16809
17201
  QuotaRow,
16810
17202
  ROOT_STEP,
16811
17203
  Radio,
@@ -16839,6 +17231,7 @@ function useDocumentTitle(routeTitle, appName) {
16839
17231
  StepList,
16840
17232
  SurroundSound,
16841
17233
  Switch,
17234
+ THREADS_LOAD_FAILED,
16842
17235
  Tabs,
16843
17236
  Tag,
16844
17237
  TestModeBar,
@@ -16868,9 +17261,13 @@ function useDocumentTitle(routeTitle, appName) {
16868
17261
  computeNeedMore,
16869
17262
  computeVirtualWindow,
16870
17263
  copyToClipboard,
17264
+ createChatAdapter,
17265
+ createExportDownloader,
16871
17266
  createLocalStorageAppearanceStore,
16872
17267
  createVersionStore,
16873
17268
  eqFilter,
17269
+ exportStateOf,
17270
+ exportToJob,
16874
17271
  extensionOf,
16875
17272
  extractClipboardFiles,
16876
17273
  filterFiles,
@@ -16889,7 +17286,9 @@ function useDocumentTitle(routeTitle, appName) {
16889
17286
  importanceLevel,
16890
17287
  importanceTokens,
16891
17288
  installFlytedeskFavicon,
17289
+ isExpiredExport,
16892
17290
  isImage,
17291
+ isLiveExport,
16893
17292
  isSystemMessage,
16894
17293
  isUsStateCode,
16895
17294
  isWithinLayerTree,
@@ -16914,9 +17313,12 @@ function useDocumentTitle(routeTitle, appName) {
16914
17313
  useAppearancePrefs,
16915
17314
  useAppearanceStore,
16916
17315
  useChatEngine,
17316
+ useChatThreads,
16917
17317
  useCopyToClipboard,
16918
17318
  useCornerStackSlot,
16919
17319
  useDocumentTitle,
17320
+ useExpiryClock,
17321
+ useExportJobs,
16920
17322
  useFeatureStatus,
16921
17323
  useLayerZIndex,
16922
17324
  useOverlayLayout,
@@ -16927,6 +17329,7 @@ function useDocumentTitle(routeTitle, appName) {
16927
17329
  useServerTable,
16928
17330
  useSessionContext,
16929
17331
  useSheetOpenMark,
17332
+ useShownExport,
16930
17333
  useStackedLayer,
16931
17334
  useStagedFiles,
16932
17335
  useToast,
@@ -16934,6 +17337,7 @@ function useDocumentTitle(routeTitle, appName) {
16934
17337
  validateFilterValue,
16935
17338
  visibleMessages,
16936
17339
  watchAppearance,
17340
+ withDeadline,
16937
17341
  writeQueryToUrl
16938
17342
  });
16939
17343
  //# sourceMappingURL=index.cjs.map