@ai-matrx/records-ui 0.115.47 → 0.115.49

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -999,29 +999,29 @@ function clauseFor(f, value, now = /* @__PURE__ */ new Date()) {
999
999
  }
1000
1000
  case "select": {
1001
1001
  const ticked = value.values ?? (value.value === "" ? [] : [value.value]);
1002
- const blank = ticked.includes(BLANK_VALUE);
1002
+ const blank2 = ticked.includes(BLANK_VALUE);
1003
1003
  const words2 = ticked.filter((w) => w !== BLANK_VALUE);
1004
- if (!blank && words2.length === 0) return value.negated ? null : { rule: constant(false) };
1004
+ if (!blank2 && words2.length === 0) return value.negated ? null : { rule: constant(false) };
1005
1005
  const present = op("present", field(f));
1006
1006
  const kind = String(editorKindFor(f));
1007
1007
  if (kind === "datetime" || kind === "date") {
1008
1008
  if (words2.length === 0) return { rule: value.negated ? present : not(present) };
1009
1009
  const holdsDays = String((f.config ?? {})["kind"] ?? "") === "date";
1010
- if (words2.length === 1 && !blank && !value.negated) return { flat: { [f.key]: dayWindow(words2[0], holdsDays) } };
1010
+ if (words2.length === 1 && !blank2 && !value.negated) return { flat: { [f.key]: dayWindow(words2[0], holdsDays) } };
1011
1011
  const leaves = words2.map((day2) => withinWindow(f, dayWindow(day2, holdsDays)));
1012
1012
  const anyDay = leaves.length === 1 ? leaves[0] : op("or", ...leaves);
1013
- if (!value.negated) return { rule: blank ? op("or", not(present), anyDay) : anyDay };
1014
- return { rule: blank ? op("and", present, not(anyDay)) : not(anyDay) };
1013
+ if (!value.negated) return { rule: blank2 ? op("or", not(present), anyDay) : anyDay };
1014
+ return { rule: blank2 ? op("and", present, not(anyDay)) : not(anyDay) };
1015
1015
  }
1016
1016
  const asStored = (w) => holdsNumbers(f) || kind === "rating" ? Number.isFinite(Number(w)) ? Number(w) : w : kind === "checkbox" && (w === "true" || w === "false") ? w === "true" : w;
1017
1017
  const stored = words2.map(asStored);
1018
1018
  const anyWord = stored.length === 0 ? null : stored.length === 1 ? op("eq", field(f), constant(stored[0])) : op("or", ...stored.map((w) => op("eq", field(f), constant(w))));
1019
1019
  if (!value.negated) {
1020
- if (!blank && stored.length === 1) return { flat: { [f.key]: stored[0] } };
1021
- if (!blank) return { rule: anyWord };
1020
+ if (!blank2 && stored.length === 1) return { flat: { [f.key]: stored[0] } };
1021
+ if (!blank2) return { rule: anyWord };
1022
1022
  return { rule: anyWord ? op("or", not(present), anyWord) : not(present) };
1023
1023
  }
1024
- if (blank) return { rule: anyWord ? op("and", present, not(anyWord)) : present };
1024
+ if (blank2) return { rule: anyWord ? op("and", present, not(anyWord)) : present };
1025
1025
  return { rule: op("or", not(present), not(anyWord)) };
1026
1026
  }
1027
1027
  case "boolean":
@@ -17712,6 +17712,7 @@ function useMergedGridControls(args) {
17712
17712
  /* @__PURE__ */ jsx63(
17713
17713
  Dialog11,
17714
17714
  {
17715
+ modal: true,
17715
17716
  open: dialog?.kind === "retype",
17716
17717
  onOpenChange: (open) => {
17717
17718
  if (!open) close();
@@ -21464,7 +21465,10 @@ var IMPORT_KINDS = [
21464
21465
  { kind: "date", label: "Date" },
21465
21466
  { kind: "number", label: "Number" },
21466
21467
  { kind: "currency", label: "Money" },
21467
- { kind: "checkbox", label: "Checkbox" }
21468
+ { kind: "checkbox", label: "Checkbox" },
21469
+ { kind: "email", label: "Email" },
21470
+ { kind: "phone", label: "Phone" },
21471
+ { kind: "url", label: "Link" }
21468
21472
  ];
21469
21473
  function importKindOfPlan(type) {
21470
21474
  if (type === "text" || type === "long_text") return "text";
@@ -21472,6 +21476,7 @@ function importKindOfPlan(type) {
21472
21476
  if (type === "number" || type === "range" || type === "integer" || type === "decimal") return "number";
21473
21477
  if (type === "currency") return "currency";
21474
21478
  if (type === "checkbox" || type === "boolean") return "checkbox";
21479
+ if (type === "email" || type === "phone" || type === "url") return type;
21475
21480
  return null;
21476
21481
  }
21477
21482
  function declarationFor(kind) {
@@ -21509,6 +21514,19 @@ function exactDuplicateRows(rows, headers) {
21509
21514
  });
21510
21515
  return out;
21511
21516
  }
21517
+ var EMAIL = /^[^\s@]+@[^\s@]+\.[^\s@]{2,}$/;
21518
+ var PHONE = /^\+?[\d\s().-]{7,20}$/;
21519
+ var URLISH = /^(https?:\/\/|www\.)\S+$/i;
21520
+ function looksLike(rows, header) {
21521
+ const cells = rows.map((r) => String(r[header] ?? "").trim()).filter((c) => c !== "");
21522
+ if (cells.length < 2) return null;
21523
+ const share = (test) => cells.filter(test).length / cells.length;
21524
+ if (share((c) => EMAIL.test(c)) >= 0.6) return "email";
21525
+ if (share((c) => URLISH.test(c)) >= 0.6) return "url";
21526
+ const isPhone = (c) => PHONE.test(c) && /[\d]/.test(c) && c.replace(/\D/g, "").length >= 7 && c.replace(/\D/g, "").length <= 15 && /[()\s.+-]/.test(c);
21527
+ if (share(isPhone) >= 0.6) return "phone";
21528
+ return null;
21529
+ }
21512
21530
 
21513
21531
  // src/importCombine.ts
21514
21532
  import { relationNameKey } from "@ai-matrx/records";
@@ -22113,6 +22131,7 @@ function ImportWizard({ tableId, source, onDone, onWrote, autoRun, className })
22113
22131
  for (const c of plan?.columns ?? []) {
22114
22132
  const k = importKindOfPlan(c.type);
22115
22133
  out[c.header] = (k === "text" || c.type === "select") && looksLikeDates(effectiveRows, c.header) ? "date" : k;
22134
+ if (out[c.header] === "text") out[c.header] = looksLike(effectiveRows, c.header) ?? "text";
22116
22135
  if (combined?.multiValued.has(c.header) && (k === null || c.type === "select")) out[c.header] = "text";
22117
22136
  }
22118
22137
  return out;
@@ -22293,6 +22312,25 @@ function ImportWizard({ tableId, source, onDone, onWrote, autoRun, className })
22293
22312
  }
22294
22313
  setColumnsAdded(added);
22295
22314
  }
22315
+ if (makesColumns && plan) {
22316
+ const wantedKeys = plan.columns.map((c) => c.header).filter((h) => !leftOut.has(h)).map((h) => sendMapping[h]).filter((k) => Boolean(k));
22317
+ const now = await client.fields({ table_id: tableId });
22318
+ if (now.ok) {
22319
+ const order = new Map(wantedKeys.map((k, i) => [k, i]));
22320
+ const current = now.data.filter((f) => order.has(f.key)).sort((a, b) => (a.sort ?? 0) - (b.sort ?? 0)).map((f) => f.key);
22321
+ const inFileOrder = current.every((k, i) => k === wantedKeys.filter((w) => current.includes(w))[i]);
22322
+ if (!inFileOrder) {
22323
+ const slots = now.data.filter((f) => order.has(f.key)).map((f) => f.sort ?? 0).sort((a, b) => a - b);
22324
+ const byKey = new Map(now.data.map((f) => [f.key, f]));
22325
+ const present = wantedKeys.filter((k) => byKey.has(k));
22326
+ for (let i = 0; i < present.length; i += 1) {
22327
+ const f = byKey.get(present[i]);
22328
+ const to = slots[i] ?? (i + 1) * 10;
22329
+ if ((f.sort ?? 0) !== to) await client.fieldUpdate({ field_id: f.id, patch: { sort: to } });
22330
+ }
22331
+ }
22332
+ }
22333
+ }
22296
22334
  setPhase("writing");
22297
22335
  const opened = await client.importBegin({
22298
22336
  table_id: tableId,
@@ -23513,9 +23551,9 @@ var PERCENT = /^[+-]?\d+(?:\.\d+)?\s?%$/;
23513
23551
  var ISO_DATE = /^\d{4}-\d{2}-\d{2}(?:[T ]\d{2}:\d{2}(?::\d{2}(?:\.\d+)?)?(?:Z|[+-]\d{2}:?\d{2})?)?$/;
23514
23552
  var SLASH_DATE = /^\d{1,2}\/\d{1,2}\/\d{2,4}$/;
23515
23553
  var WORD_DATE = /^(?:\d{1,2}\s+)?(?:jan|feb|mar|apr|may|jun|jul|aug|sep|sept|oct|nov|dec)[a-z]*\.?\s+\d{1,2}(?:st|nd|rd|th)?,?\s+\d{4}$|^\d{1,2}\s+(?:jan|feb|mar|apr|may|jun|jul|aug|sep|sept|oct|nov|dec)[a-z]*\.?\s+\d{4}$/i;
23516
- var EMAIL = /^[^\s@]+@[^\s@]+\.[^\s@]{2,}$/;
23554
+ var EMAIL2 = /^[^\s@]+@[^\s@]+\.[^\s@]{2,}$/;
23517
23555
  var URL_WORD = /^https?:\/\/\S+$/i;
23518
- var PHONE = /^\+?[\d\s().-]{7,20}$/;
23556
+ var PHONE2 = /^\+?[\d\s().-]{7,20}$/;
23519
23557
  var YES = /* @__PURE__ */ new Set(["yes", "true", "y", "\u2713", "\u2714", "checked", "done"]);
23520
23558
  var NO = /* @__PURE__ */ new Set(["no", "false", "n", "\u2717", "\u2718", "unchecked", ""]);
23521
23559
  function isDate(v) {
@@ -23535,9 +23573,9 @@ function guessColumn(values) {
23535
23573
  }
23536
23574
  if (every((v) => PERCENT.test(v))) return { type: "percent" };
23537
23575
  if (every(isDate)) return { type: "datetime", kind: every((v) => !/\d:\d/.test(v)) ? "date" : "datetime" };
23538
- if (every((v) => EMAIL.test(v))) return { type: "email" };
23576
+ if (every((v) => EMAIL2.test(v))) return { type: "email" };
23539
23577
  if (every((v) => URL_WORD.test(v))) return { type: "url" };
23540
- if (every((v) => PHONE.test(v) && (v.match(/\d/g)?.length ?? 0) >= 7)) return { type: "phone" };
23578
+ if (every((v) => PHONE2.test(v) && (v.match(/\d/g)?.length ?? 0) >= 7)) return { type: "phone" };
23541
23579
  if (filled.some((v) => v.length > 120 || v.includes("\n"))) return { type: "long_text" };
23542
23580
  const distinct = [];
23543
23581
  for (const v of filled) if (!distinct.some((d) => d.toLowerCase() === v.toLowerCase())) distinct.push(v);
@@ -23894,7 +23932,7 @@ function noValueList(columnId2) {
23894
23932
  }
23895
23933
  function facetsFromGroups(columnId2, key, rows, limit, distinctCount, order = "count") {
23896
23934
  const counts = /* @__PURE__ */ new Map();
23897
- let blank = 0;
23935
+ let blank2 = 0;
23898
23936
  let total = 0;
23899
23937
  let maxLength = 0;
23900
23938
  let unlistable = 0;
@@ -23905,7 +23943,7 @@ function facetsFromGroups(columnId2, key, rows, limit, distinctCount, order = "c
23905
23943
  const said2 = raw === null || raw === void 0 ? "" : String(raw).trim();
23906
23944
  const text = order === "newest" && /^\d{4}-\d{2}-\d{2}/.test(said2) ? said2.slice(0, 10) : said2;
23907
23945
  if (text === "") {
23908
- blank += n;
23946
+ blank2 += n;
23909
23947
  continue;
23910
23948
  }
23911
23949
  maxLength = Math.max(maxLength, text.length);
@@ -23923,8 +23961,8 @@ function facetsFromGroups(columnId2, key, rows, limit, distinctCount, order = "c
23923
23961
  return {
23924
23962
  columnId: columnId2,
23925
23963
  totalRows: total,
23926
- filled: total - blank,
23927
- blank,
23964
+ filled: total - blank2,
23965
+ blank: blank2,
23928
23966
  distinctCount: known,
23929
23967
  maxLength,
23930
23968
  unlistable,
@@ -28352,7 +28390,7 @@ import { Button as Button59, Skeleton as Skeleton10, cn as cn47 } from "@ai-matr
28352
28390
 
28353
28391
  // src/NewTableStart.tsx
28354
28392
  import { useCallback as useCallback30, useMemo as useMemo42, useRef as useRef38, useState as useState74 } from "react";
28355
- import { useRecordsClient as useRecordsClient47 } from "@ai-matrx/records/react";
28393
+ import { tableShapeChanged as tableShapeChanged7, useRecordsClient as useRecordsClient47 } from "@ai-matrx/records/react";
28356
28394
  import {
28357
28395
  BasicInput as BasicInput15,
28358
28396
  Button as Button53,
@@ -28753,6 +28791,10 @@ function NewTableStart({
28753
28791
  onMade?.();
28754
28792
  setStep({ at: "wizard", tableId: result.data, source, made: true });
28755
28793
  }, [busy, client, fileName, importName, importReady, onMade, parsed, target]);
28794
+ const openImported = (tableId) => {
28795
+ tableShapeChanged7(tableId);
28796
+ onOpenTable?.(tableId);
28797
+ };
28756
28798
  const back = () => {
28757
28799
  setError(null);
28758
28800
  setStep({ at: "choose" });
@@ -28948,10 +28990,10 @@ function NewTableStart({
28948
28990
  /* @__PURE__ */ jsx92(Button53, { disabled: !importReady || busy, onClick: () => void continueImport(), "data-new-table-continue": "", children: busy ? "Creating\u2026" : "Next: columns" })
28949
28991
  ] });
28950
28992
  } else {
28951
- body = /* @__PURE__ */ jsx92("div", { "data-new-table-wizard": "", children: /* @__PURE__ */ jsx92(ImportWizard, { tableId: step2.tableId, source: step2.source, autoRun: step2.made, onDone: () => onOpenTable?.(step2.tableId) }) });
28993
+ body = /* @__PURE__ */ jsx92("div", { "data-new-table-wizard": "", children: /* @__PURE__ */ jsx92(ImportWizard, { tableId: step2.tableId, source: step2.source, autoRun: step2.made, onWrote: () => tableShapeChanged7(step2.tableId), onDone: () => openImported(step2.tableId) }) });
28952
28994
  footer = /* @__PURE__ */ jsxs81(Fragment32, { children: [
28953
28995
  !step2.made ? /* @__PURE__ */ jsx92(Button53, { variant: "ghost", className: "mr-auto", onClick: () => setStep({ at: "import" }), children: "Back" }) : null,
28954
- /* @__PURE__ */ jsx92(Button53, { variant: "outline", onClick: () => onOpenTable?.(step2.tableId), "data-new-table-open": "", children: "Open the table" })
28996
+ /* @__PURE__ */ jsx92(Button53, { variant: "outline", onClick: () => openImported(step2.tableId), "data-new-table-open": "", children: "Open the table" })
28955
28997
  ] });
28956
28998
  }
28957
28999
  return /* @__PURE__ */ jsxs81(
@@ -31172,7 +31214,7 @@ function Clause({
31172
31214
 
31173
31215
  // src/TableRename.tsx
31174
31216
  import { useCallback as useCallback35, useEffect as useEffect64, useRef as useRef40, useState as useState82 } from "react";
31175
- import { tableShapeChanged as tableShapeChanged7, useRecordsClient as useRecordsClient55 } from "@ai-matrx/records/react";
31217
+ import { tableShapeChanged as tableShapeChanged8, useRecordsClient as useRecordsClient55 } from "@ai-matrx/records/react";
31176
31218
  import {
31177
31219
  Button as Button62,
31178
31220
  Dialog as Dialog15,
@@ -31250,7 +31292,7 @@ function TableRenameDialog({
31250
31292
  setRefused(refusalSentence(written.error));
31251
31293
  return;
31252
31294
  }
31253
- tableShapeChanged7(tableId);
31295
+ tableShapeChanged8(tableId);
31254
31296
  onRenamed?.(next);
31255
31297
  onOpenChange(false);
31256
31298
  };
@@ -31399,7 +31441,7 @@ import {
31399
31441
  useFields as useFields17,
31400
31442
  useTable as useTable16,
31401
31443
  useTableArchive,
31402
- tableShapeChanged as tableShapeChanged10
31444
+ tableShapeChanged as tableShapeChanged11
31403
31445
  } from "@ai-matrx/records/react";
31404
31446
  import { Badge as Badge14, Button as Button67, Separator as Separator8, cn as cn52 } from "@ai-matrx/design-system";
31405
31447
 
@@ -31439,7 +31481,7 @@ function announceTableArchived({ notify, client, tableId, name, onRestored }) {
31439
31481
 
31440
31482
  // src/TableFoundation.tsx
31441
31483
  import { useEffect as useEffect65, useState as useState84 } from "react";
31442
- import { tableShapeChanged as tableShapeChanged8, useRecordsClient as useRecordsClient57 } from "@ai-matrx/records/react";
31484
+ import { tableShapeChanged as tableShapeChanged9, useRecordsClient as useRecordsClient57 } from "@ai-matrx/records/react";
31443
31485
  import { Switch as Switch3 } from "@ai-matrx/design-system";
31444
31486
  import { jsx as jsx104, jsxs as jsxs93 } from "react/jsx-runtime";
31445
31487
  function isFoundationTable(table) {
@@ -31467,7 +31509,7 @@ function TableFoundationSwitch({ tableId, table }) {
31467
31509
  setRefused(refusalSentence(written.error));
31468
31510
  return;
31469
31511
  }
31470
- tableShapeChanged8(tableId);
31512
+ tableShapeChanged9(tableId);
31471
31513
  };
31472
31514
  return /* @__PURE__ */ jsxs93("div", { className: "flex flex-col gap-1", "data-table-foundation": "", children: [
31473
31515
  /* @__PURE__ */ jsxs93("label", { className: "flex items-center gap-2", children: [
@@ -31490,7 +31532,7 @@ function TableFoundationSwitch({ tableId, table }) {
31490
31532
 
31491
31533
  // src/TableAccessLevel.tsx
31492
31534
  import { useCallback as useCallback36, useEffect as useEffect66, useMemo as useMemo47, useState as useState85 } from "react";
31493
- import { tableShapeChanged as tableShapeChanged9, useRecordsClient as useRecordsClient58 } from "@ai-matrx/records/react";
31535
+ import { tableShapeChanged as tableShapeChanged10, useRecordsClient as useRecordsClient58 } from "@ai-matrx/records/react";
31494
31536
  import { Badge as Badge12, Button as Button64, Textarea as Textarea5, cn as cn50 } from "@ai-matrx/design-system";
31495
31537
  import { Fragment as Fragment36, jsx as jsx105, jsxs as jsxs94 } from "react/jsx-runtime";
31496
31538
  var PERSON_KERNEL_TABLE = "11111111-0000-4000-8000-000000000005";
@@ -31544,7 +31586,7 @@ function TableAccessLevel({ tableId, fields }) {
31544
31586
  setRefused(refusalSentence(result.error));
31545
31587
  return;
31546
31588
  }
31547
- tableShapeChanged9(tableId);
31589
+ tableShapeChanged10(tableId);
31548
31590
  await load();
31549
31591
  };
31550
31592
  return /* @__PURE__ */ jsxs94("div", { className: "flex flex-col gap-2", "data-table-access-level": facts.level, "data-can-set": "", children: [
@@ -31834,10 +31876,10 @@ function ColumnsAtOnce({
31834
31876
  const orderMoved = rows.some((f, i) => f.id !== draft[i]?.id);
31835
31877
  const hiddenChanged = look ? JSON.stringify([...hidden].sort()) !== JSON.stringify([...look.hidden].sort()) : false;
31836
31878
  const lookChanged = Boolean(look) && (hiddenChanged || orderMoved && look.order !== null);
31837
- const blank = draft.find((d) => d.label.trim() === "");
31838
- const dirty = batch.length > 0 || lookChanged || Boolean(blank);
31879
+ const blank2 = draft.find((d) => d.label.trim() === "");
31880
+ const dirty = batch.length > 0 || lookChanged || Boolean(blank2);
31839
31881
  const save = async () => {
31840
- if (blank) return;
31882
+ if (blank2) return;
31841
31883
  setSaving(true);
31842
31884
  try {
31843
31885
  for (const one of batch) {
@@ -31950,7 +31992,7 @@ function ColumnsAtOnce({
31950
31992
  draft.length === 0 ? /* @__PURE__ */ jsx107("li", { className: "px-2 py-2 text-muted-foreground", children: "This table has no fields yet." }) : null
31951
31993
  ] }),
31952
31994
  dirty ? /* @__PURE__ */ jsxs96("div", { className: "flex flex-wrap items-center gap-2", "data-records-columns-save": "", children: [
31953
- /* @__PURE__ */ jsx107(Button66, { size: "sm", disabled: saving || Boolean(blank), onClick: () => void save(), children: saving ? "Saving\u2026" : "Save columns" }),
31995
+ /* @__PURE__ */ jsx107(Button66, { size: "sm", disabled: saving || Boolean(blank2), onClick: () => void save(), children: saving ? "Saving\u2026" : "Save columns" }),
31954
31996
  /* @__PURE__ */ jsx107(
31955
31997
  Button66,
31956
31998
  {
@@ -31964,7 +32006,7 @@ function ColumnsAtOnce({
31964
32006
  children: "Discard"
31965
32007
  }
31966
32008
  ),
31967
- blank ? /* @__PURE__ */ jsx107("span", { className: "text-muted-foreground", children: "Every column needs a name." }) : null
32009
+ blank2 ? /* @__PURE__ */ jsx107("span", { className: "text-muted-foreground", children: "Every column needs a name." }) : null
31968
32010
  ] }) : null
31969
32011
  ] });
31970
32012
  }
@@ -32069,9 +32111,9 @@ function TableSettingsPanel({
32069
32111
  tableId,
32070
32112
  name: finished.table_name || (table.data ? tableName(table.data) : "the table"),
32071
32113
  // Undo shows the table again where it is: the page re-reads it.
32072
- onRestored: () => tableShapeChanged10(tableId)
32114
+ onRestored: () => tableShapeChanged11(tableId)
32073
32115
  });
32074
- tableShapeChanged10(tableId);
32116
+ tableShapeChanged11(tableId);
32075
32117
  }
32076
32118
  };
32077
32119
  const askToArchive = async () => {
@@ -32130,8 +32172,8 @@ function TableSettingsPanel({
32130
32172
  open: true,
32131
32173
  onOpenChange: (open) => !open ? setDeliberate(null) : void 0,
32132
32174
  onArchived: () => {
32133
- announceTableArchived({ notify: ui.notify, client, tableId, name: tableName(table.data), onRestored: () => tableShapeChanged10(tableId) });
32134
- tableShapeChanged10(tableId);
32175
+ announceTableArchived({ notify: ui.notify, client, tableId, name: tableName(table.data), onRestored: () => tableShapeChanged11(tableId) });
32176
+ tableShapeChanged11(tableId);
32135
32177
  }
32136
32178
  }
32137
32179
  ) : null,
@@ -32642,7 +32684,7 @@ function ShareForSomebodyElse({
32642
32684
  import { useEffect as useEffect72, useRef as useRef43, useState as useState92 } from "react";
32643
32685
  import { Button as Button70, cn as cn54 } from "@ai-matrx/design-system";
32644
32686
  import { newerKindOf as newerKindOf6 } from "@ai-matrx/records";
32645
- import { tableShapeChanged as tableShapeChanged11, useFieldMutation as useFieldMutation5, useFields as useFields18, useRecord as useRecord2, useRecordsClient as useRecordsClient64, useTable as useTable18 } from "@ai-matrx/records/react";
32687
+ import { tableShapeChanged as tableShapeChanged12, useFieldMutation as useFieldMutation5, useFields as useFields18, useRecord as useRecord2, useRecordsClient as useRecordsClient64, useTable as useTable18 } from "@ai-matrx/records/react";
32646
32688
  import { Fragment as Fragment40, jsx as jsx113, jsxs as jsxs102 } from "react/jsx-runtime";
32647
32689
  var BODY_NAMES = /^(notes?|page|body|content|page content|details|description)$/i;
32648
32690
  function bodyFieldOf(fields) {
@@ -32736,7 +32778,7 @@ function AddBody({ tableId }) {
32736
32778
  "data-record-body-add": "",
32737
32779
  onClick: async () => {
32738
32780
  const made = await mutation.declare({ table_id: tableId, spec: { label: BODY_COLUMN_NAME, type: "rich_text" } });
32739
- if (made) tableShapeChanged11(tableId);
32781
+ if (made) tableShapeChanged12(tableId);
32740
32782
  },
32741
32783
  children: "Add notes"
32742
32784
  }
@@ -39049,7 +39091,7 @@ import {
39049
39091
  archivedByLine,
39050
39092
  emptyArchiveLine
39051
39093
  } from "@ai-matrx/records";
39052
- import { tableShapeChanged as tableShapeChanged12, useFields as useFields22, useRecordsClient as useRecordsClient72, useTable as useTable22 } from "@ai-matrx/records/react";
39094
+ import { tableShapeChanged as tableShapeChanged13, useFields as useFields22, useRecordsClient as useRecordsClient72, useTable as useTable22 } from "@ai-matrx/records/react";
39053
39095
  import { Button as Button78, Skeleton as Skeleton16, cn as cn63 } from "@ai-matrx/design-system";
39054
39096
  import { jsx as jsx129, jsxs as jsxs117 } from "react/jsx-runtime";
39055
39097
  var ARCHIVE_MEANS = "Archiving never destroys anything. A record you remove from the grid waits here until somebody brings it back.";
@@ -39206,7 +39248,7 @@ function RetiredColumns({ tableId, mayRestore, whyNot }) {
39206
39248
  setRefusal({ fieldId, error: done.error });
39207
39249
  return;
39208
39250
  }
39209
- tableShapeChanged12(tableId);
39251
+ tableShapeChanged13(tableId);
39210
39252
  await read();
39211
39253
  };
39212
39254
  if (error) return /* @__PURE__ */ jsx129(RefusalNotice, { error });
@@ -41743,6 +41785,41 @@ function ActionInbox({
41743
41785
 
41744
41786
  // src/HistoryPanel.tsx
41745
41787
  import { useCallback as useCallback47, useEffect as useEffect95, useRef as useRef53, useState as useState115 } from "react";
41788
+
41789
+ // src/undoChange.ts
41790
+ function blank(value) {
41791
+ return value === null || value === void 0 || value === "";
41792
+ }
41793
+ function sameValue2(a, b) {
41794
+ if (blank(a) || blank(b)) return blank(a) && blank(b);
41795
+ if (a === b) return true;
41796
+ if (typeof a !== "object" || typeof b !== "object") return false;
41797
+ if (Array.isArray(a) !== Array.isArray(b)) return false;
41798
+ const left = a;
41799
+ const right = b;
41800
+ const keys = /* @__PURE__ */ new Set([...Object.keys(left), ...Object.keys(right)]);
41801
+ for (const key of keys) if (!sameValue2(left[key], right[key])) return false;
41802
+ return true;
41803
+ }
41804
+ function planUndo(changes, current, only) {
41805
+ const doc = current ?? {};
41806
+ return changes.filter((change) => !only || change.key === only).map((change) => {
41807
+ const now = doc[change.key];
41808
+ const state = sameValue2(now, change.before) ? "already" : sameValue2(now, change.after) ? "clean" : "conflict";
41809
+ return { key: change.key, label: change.label, current: now, after: change.after, before: change.before, state };
41810
+ });
41811
+ }
41812
+ function undoPatch(lines, replaceLaterEdits) {
41813
+ const patch = {};
41814
+ for (const line of lines) {
41815
+ if (line.state === "already") continue;
41816
+ if (line.state === "conflict" && !replaceLaterEdits) continue;
41817
+ patch[line.key] = blank(line.before) ? null : line.before;
41818
+ }
41819
+ return patch;
41820
+ }
41821
+
41822
+ // src/HistoryPanel.tsx
41746
41823
  import {
41747
41824
  useFields as useFields23,
41748
41825
  useRecord as useRecord4,
@@ -42011,7 +42088,7 @@ function MigrationLog({ entries, readError, canUndo, whyNotUndo, onUndone, class
42011
42088
  }
42012
42089
 
42013
42090
  // src/HistoryPanel.tsx
42014
- import { jsx as jsx137, jsxs as jsxs125 } from "react/jsx-runtime";
42091
+ import { Fragment as Fragment53, jsx as jsx137, jsxs as jsxs125 } from "react/jsx-runtime";
42015
42092
  function HistoryPanel({ tableId, recordId, onAskAboutField, className }) {
42016
42093
  const client = useRecordsClient80();
42017
42094
  const table = useTable25(tableId);
@@ -42021,6 +42098,7 @@ function HistoryPanel({ tableId, recordId, onAskAboutField, className }) {
42021
42098
  const [error, setError] = useState115(null);
42022
42099
  const [open, setOpen] = useState115(null);
42023
42100
  const [pending, setPending] = useState115({ phase: "idle" });
42101
+ const [undo, setUndo] = useState115({ phase: "idle" });
42024
42102
  const seenAtPreview = useRef53(null);
42025
42103
  const [said2, setSaid] = useState115(null);
42026
42104
  const listRef = useRef53(null);
@@ -42070,6 +42148,37 @@ function HistoryPanel({ tableId, recordId, onAskAboutField, className }) {
42070
42148
  }
42071
42149
  setPending({ phase: "confirm", version, fieldKey, preview: asked3.data });
42072
42150
  }
42151
+ async function startUndo(entry, only) {
42152
+ setSaid(null);
42153
+ setPending({ phase: "idle" });
42154
+ setUndo({ phase: "asking", version: entry.version, only });
42155
+ const read = await client.recordRead({ record_id: recordId, withVersion: true });
42156
+ if (!read.ok) {
42157
+ setUndo({ phase: "idle" });
42158
+ setError(read.error);
42159
+ return;
42160
+ }
42161
+ const lines = planUndo(entry.changes, read.data.document, only);
42162
+ setUndo({ phase: "confirm", version: entry.version, only, lines, seen: read.data.version ?? await (0, recordVersions_exports.readVersionNow)(client, recordId) });
42163
+ }
42164
+ async function doUndo(replaceLaterEdits) {
42165
+ if (undo.phase !== "confirm") return;
42166
+ const { version, only, lines, seen } = undo;
42167
+ setUndo({ phase: "writing", version, only });
42168
+ const patch = undoPatch(lines, replaceLaterEdits);
42169
+ const written = await (0, recordVersions_exports.updateRecordAt)(client, { record_id: recordId, patch, version: seen });
42170
+ setUndo({ phase: "idle" });
42171
+ if (!written.ok) {
42172
+ setError(written.error);
42173
+ return;
42174
+ }
42175
+ const count = Object.keys(patch).length;
42176
+ const kept = lines.filter((line) => line.state === "conflict" && !replaceLaterEdits).length;
42177
+ setSaid(
42178
+ `Undone as version ${written.data}. ${count} ${count === 1 ? "value" : "values"} put back` + (kept ? `, ${kept} later ${kept === 1 ? "edit" : "edits"} kept` : "") + ". Every other field is as it was."
42179
+ );
42180
+ await load();
42181
+ }
42073
42182
  async function doRestore(version, fieldKey) {
42074
42183
  setPending({ phase: "writing", version, fieldKey });
42075
42184
  const written = await (0, recordVersions_exports.restoreAt)(client, { record_id: recordId, version, field_key: fieldKey, seenVersion: seenAtPreview.current });
@@ -42128,6 +42237,10 @@ function HistoryPanel({ tableId, recordId, onAskAboutField, className }) {
42128
42237
  canRestore: rights.write && entry.version >= newestMakerVersion && !(entry.migration_id && makerIds.has(entry.migration_id)),
42129
42238
  whyNotRestore: entry.migration_id && makerIds.has(entry.migration_id) ? `This version is a ${migrationWords(makers.find((m) => m.id === entry.migration_id)?.verb ?? "split").toLowerCase()}. Undo it in the Migration log below, so no copy is left behind.` : rights.write && entry.version < newestMakerVersion ? "A newer split still holds some of these values. Undo it in the Migration log below first, so no copy is left behind." : rights.why("write"),
42130
42239
  pending,
42240
+ undo,
42241
+ onUndo: (only) => void startUndo(entry, only),
42242
+ onUndoConfirm: (replace) => void doUndo(replace),
42243
+ onUndoCancel: () => setUndo({ phase: "idle" }),
42131
42244
  onRestore: (fieldKey) => void startRestore(entry.version, fieldKey),
42132
42245
  onConfirm: (fieldKey) => void doRestore(entry.version, fieldKey),
42133
42246
  onCancel: () => setPending({ phase: "idle" }),
@@ -42157,6 +42270,10 @@ function VersionRow({
42157
42270
  canRestore,
42158
42271
  whyNotRestore,
42159
42272
  pending,
42273
+ undo,
42274
+ onUndo,
42275
+ onUndoConfirm,
42276
+ onUndoCancel,
42160
42277
  onRestore,
42161
42278
  onConfirm,
42162
42279
  onCancel,
@@ -42164,6 +42281,9 @@ function VersionRow({
42164
42281
  }) {
42165
42282
  const mine = pending.phase !== "idle" && pending.version === entry.version;
42166
42283
  const confirming = mine && pending.phase === "confirm" ? pending : null;
42284
+ const canUndo = canRestore && entry.operation !== "insert" && entry.version > 1 && entry.changes.length > 0;
42285
+ const undoMine = undo.phase !== "idle" && undo.version === entry.version;
42286
+ const undoConfirming = undoMine && undo.phase === "confirm" ? undo : null;
42167
42287
  return /* @__PURE__ */ jsxs125("li", { className: "flex flex-col", children: [
42168
42288
  /* @__PURE__ */ jsxs125(
42169
42289
  "div",
@@ -42219,13 +42339,24 @@ function VersionRow({
42219
42339
  {
42220
42340
  change,
42221
42341
  field: byKey.get(change.key),
42222
- canRestore,
42223
- onRestore: () => onRestore(change.key),
42342
+ canRestore: canUndo,
42343
+ onRestore: () => onUndo(change.key),
42224
42344
  ...onAskAboutField ? { onAskAboutField } : {}
42225
42345
  },
42226
42346
  change.key
42227
42347
  )) }),
42228
- canRestore ? confirming ? /* @__PURE__ */ jsx137(
42348
+ undoConfirming ? /* @__PURE__ */ jsx137(ConfirmUndo, { lines: undoConfirming.lines, onConfirm: onUndoConfirm, onCancel: onUndoCancel }) : undoMine && undo.phase === "writing" ? /* @__PURE__ */ jsx137("p", { className: "text-[11px] text-muted-foreground", children: "Undoing\u2026" }) : canRestore && !confirming && !(mine && pending.phase === "writing") ? canUndo ? /* @__PURE__ */ jsx137("div", { className: "flex", children: /* @__PURE__ */ jsx137(
42349
+ Button86,
42350
+ {
42351
+ size: "sm",
42352
+ variant: "secondary",
42353
+ className: "h-6 px-2 text-[11px]",
42354
+ disabled: undoMine,
42355
+ onClick: () => onUndo(null),
42356
+ children: undoMine ? "Working out what would change\u2026" : "Undo this change"
42357
+ }
42358
+ ) }) : null : null,
42359
+ canRestore && !undoMine ? confirming ? /* @__PURE__ */ jsx137(
42229
42360
  ConfirmRestore,
42230
42361
  {
42231
42362
  preview: confirming.preview,
@@ -42307,9 +42438,64 @@ function ChangeLine({
42307
42438
  children: "Who changed this?"
42308
42439
  }
42309
42440
  ) : null,
42310
- canRestore ? /* @__PURE__ */ jsx137(Button86, { size: "sm", variant: "ghost", className: "h-5 shrink-0 px-1 text-[10px]", onClick: onRestore, children: "Put this one back" }) : null
42441
+ canRestore ? /* @__PURE__ */ jsx137(Button86, { size: "sm", variant: "ghost", className: "h-5 shrink-0 px-1 text-[10px]", onClick: onRestore, children: "Undo this one" }) : null
42311
42442
  ] });
42312
42443
  }
42444
+ function ConfirmUndo({
42445
+ lines,
42446
+ onConfirm,
42447
+ onCancel
42448
+ }) {
42449
+ const clean = lines.filter((line) => line.state === "clean");
42450
+ const conflicts = lines.filter((line) => line.state === "conflict");
42451
+ const already = lines.filter((line) => line.state === "already");
42452
+ const nothing = clean.length + conflicts.length === 0;
42453
+ return /* @__PURE__ */ jsxs125("div", { "data-undo-confirm": "", className: "flex flex-col gap-1 rounded border border-amber-500/40 bg-amber-500/5 p-2", children: [
42454
+ /* @__PURE__ */ jsx137("p", { className: "text-[11px] font-medium", children: nothing ? "Nothing to undo \u2014 every value this version changed already says what it said before." : `Undoing this would put back ${clean.length + conflicts.length} ${clean.length + conflicts.length === 1 ? "value" : "values"}:` }),
42455
+ /* @__PURE__ */ jsx137("ul", { className: "flex flex-col gap-0.5", children: [...clean, ...conflicts].map((line) => /* @__PURE__ */ jsxs125("li", { "data-undo-line": line.key, "data-undo-state": line.state, className: "text-[11px]", children: [
42456
+ /* @__PURE__ */ jsx137("span", { className: "font-medium", children: line.label }),
42457
+ " ",
42458
+ /* @__PURE__ */ jsx137("span", { className: "text-muted-foreground", children: say(line.current, void 0) }),
42459
+ /* @__PURE__ */ jsx137("span", { className: "mx-1 text-muted-foreground", children: "\u2192" }),
42460
+ /* @__PURE__ */ jsx137("strong", { className: "font-medium", children: blankSays(line.before) }),
42461
+ line.state === "conflict" ? /* @__PURE__ */ jsx137("span", { className: "ml-1 text-amber-700 dark:text-amber-400", children: "edited again since" }) : null
42462
+ ] }, line.key)) }),
42463
+ already.length ? /* @__PURE__ */ jsxs125("p", { className: "text-[11px] text-muted-foreground", children: [
42464
+ "Already back: ",
42465
+ already.map((line) => line.label).join(", "),
42466
+ "."
42467
+ ] }) : null,
42468
+ conflicts.length ? /* @__PURE__ */ jsxs125("p", { className: "text-[11px] text-muted-foreground", children: [
42469
+ conflicts.map((line) => line.label).join(", "),
42470
+ " ",
42471
+ conflicts.length === 1 ? "was" : "were",
42472
+ " edited again after this change. Keep the newer ",
42473
+ conflicts.length === 1 ? "edit" : "edits",
42474
+ ", or replace ",
42475
+ conflicts.length === 1 ? "it" : "them",
42476
+ "?"
42477
+ ] }) : /* @__PURE__ */ jsx137("p", { className: "text-[11px] text-muted-foreground", children: "It is saved as a new version. Nothing in the history is erased, and later edits to other fields stay." }),
42478
+ /* @__PURE__ */ jsxs125("div", { className: "flex flex-wrap gap-1", children: [
42479
+ conflicts.length ? /* @__PURE__ */ jsxs125(Fragment53, { children: [
42480
+ clean.length ? /* @__PURE__ */ jsx137(Button86, { size: "sm", className: "h-6 px-2 text-[11px]", onClick: () => onConfirm(false), children: "Undo the rest, keep newer edits" }) : null,
42481
+ /* @__PURE__ */ jsx137(
42482
+ Button86,
42483
+ {
42484
+ size: "sm",
42485
+ variant: clean.length ? "secondary" : "primary",
42486
+ className: "h-6 px-2 text-[11px]",
42487
+ onClick: () => onConfirm(true),
42488
+ children: "Replace newer edits too"
42489
+ }
42490
+ )
42491
+ ] }) : /* @__PURE__ */ jsx137(Button86, { size: "sm", className: "h-6 px-2 text-[11px]", disabled: nothing, onClick: () => onConfirm(false), children: "Yes, undo it" }),
42492
+ /* @__PURE__ */ jsx137(Button86, { size: "sm", variant: "ghost", className: "h-6 px-2 text-[11px]", onClick: onCancel, children: "Cancel" })
42493
+ ] })
42494
+ ] });
42495
+ }
42496
+ function blankSays(value) {
42497
+ return value === null || value === void 0 || value === "" ? "cleared" : say(value, void 0);
42498
+ }
42313
42499
  function ConfirmRestore({
42314
42500
  preview,
42315
42501
  busy,
@@ -42603,7 +42789,7 @@ import {
42603
42789
  } from "@ai-matrx/records/react";
42604
42790
  import { Badge as Badge21, Button as Button88, Skeleton as Skeleton24, cn as cn73 } from "@ai-matrx/design-system";
42605
42791
  import { humanizeIdentifier as humanizeIdentifier20 } from "@ai-matrx/kit/text-case";
42606
- import { Fragment as Fragment53, jsx as jsx139, jsxs as jsxs127 } from "react/jsx-runtime";
42792
+ import { Fragment as Fragment54, jsx as jsx139, jsxs as jsxs127 } from "react/jsx-runtime";
42607
42793
  function FieldHistoryPanel({
42608
42794
  tableId,
42609
42795
  fieldKey,
@@ -42638,11 +42824,12 @@ function FieldHistoryPanel({
42638
42824
  const label = (fields.data ?? []).find((f) => f.key === fieldKey)?.label || humanizeIdentifier20(fieldKey);
42639
42825
  if (error) return /* @__PURE__ */ jsx139(RefusalNotice, { error, className });
42640
42826
  if (!rows || fields.loading && !fields.data || table.loading && !table.data) return /* @__PURE__ */ jsx139(Skeleton24, { className: cn73("h-40 w-full", className) });
42641
- async function start(row) {
42827
+ async function start(row, back = false) {
42642
42828
  setSaid(null);
42643
- setPending({ phase: "asking", recordId: row.record_id, version: row.version });
42829
+ const target = back ? row.version - 1 : row.version;
42830
+ setPending({ phase: "asking", recordId: row.record_id, version: target, back });
42644
42831
  const [asked3, seen] = await Promise.all([
42645
- client.restorePreview({ record_id: row.record_id, version: row.version, field_key: fieldKey }),
42832
+ client.restorePreview({ record_id: row.record_id, version: target, field_key: fieldKey }),
42646
42833
  (0, recordVersions_exports.readVersionNow)(client, row.record_id)
42647
42834
  ]);
42648
42835
  seenAtPreview.current = seen;
@@ -42651,17 +42838,20 @@ function FieldHistoryPanel({
42651
42838
  setError(asked3.error);
42652
42839
  return;
42653
42840
  }
42654
- setPending({ phase: "confirm", recordId: row.record_id, version: row.version, preview: asked3.data });
42841
+ const laterEdit = back && asked3.data.changes.some((c) => c.key === fieldKey && !sameValue2(c.before, row.after));
42842
+ setPending({ phase: "confirm", recordId: row.record_id, version: target, preview: asked3.data, back, laterEdit });
42655
42843
  }
42656
- async function confirm(recordOf2, version) {
42657
- setPending({ phase: "writing", recordId: recordOf2, version });
42844
+ async function confirm(recordOf2, version, back = false) {
42845
+ setPending({ phase: "writing", recordId: recordOf2, version, back });
42658
42846
  const written = await (0, recordVersions_exports.restoreAt)(client, { record_id: recordOf2, version, field_key: fieldKey, seenVersion: seenAtPreview.current });
42659
42847
  setPending({ phase: "idle" });
42660
42848
  if (!written.ok) {
42661
42849
  setError(written.error);
42662
42850
  return;
42663
42851
  }
42664
- setSaid(`Put back as version ${written.data.version}. Every earlier version is still here.`);
42852
+ setSaid(
42853
+ back ? `Change undone as version ${written.data.version}. Other fields keep their later edits.` : `Put back as version ${written.data.version}. Every earlier version is still here.`
42854
+ );
42665
42855
  await load();
42666
42856
  }
42667
42857
  return /* @__PURE__ */ jsxs127("section", { className: cn73("flex min-h-0 flex-col gap-2", className), children: [
@@ -42679,8 +42869,10 @@ function FieldHistoryPanel({
42679
42869
  label,
42680
42870
  " has never been changed on anything you can see."
42681
42871
  ] }) : /* @__PURE__ */ jsx139("ol", { className: "flex min-h-0 flex-col divide-y overflow-y-auto rounded border", children: rows.map((row) => {
42682
- const mine = pending.phase !== "idle" && pending.recordId === row.record_id && pending.version === row.version;
42683
- const confirming = mine && pending.phase === "confirm" ? pending : null;
42872
+ const matches2 = (back) => pending.phase !== "idle" && pending.recordId === row.record_id && Boolean(pending.back) === back && pending.version === (back ? row.version - 1 : row.version);
42873
+ const mineValue = matches2(false);
42874
+ const mineBack = matches2(true);
42875
+ const confirming = (mineValue || mineBack) && pending.phase === "confirm" ? pending : null;
42684
42876
  return /* @__PURE__ */ jsxs127("li", { className: "flex flex-col", children: [
42685
42877
  /* @__PURE__ */ jsxs127("div", { className: "flex items-baseline gap-2 px-2 py-1.5 text-xs", children: [
42686
42878
  onOpenRecord ? /* @__PURE__ */ jsx139(
@@ -42699,7 +42891,7 @@ function FieldHistoryPanel({
42699
42891
  /* @__PURE__ */ jsx139("span", { className: "mx-1 text-muted-foreground", children: "\u2192" }),
42700
42892
  /* @__PURE__ */ jsx139("strong", { className: "font-medium", children: say(row.after, void 0) })
42701
42893
  ] }),
42702
- /* @__PURE__ */ jsx139("span", { className: "shrink-0 text-muted-foreground", children: row.actor.kind === "agent" ? /* @__PURE__ */ jsxs127(Fragment53, { children: [
42894
+ /* @__PURE__ */ jsx139("span", { className: "shrink-0 text-muted-foreground", children: row.actor.kind === "agent" ? /* @__PURE__ */ jsxs127(Fragment54, { children: [
42703
42895
  /* @__PURE__ */ jsx139(Badge21, { variant: "outline", className: "mr-1 text-[10px]", children: "agent" }),
42704
42896
  "for ",
42705
42897
  row.actor.on_behalf_of?.name ?? "a person",
@@ -42719,21 +42911,38 @@ function FieldHistoryPanel({
42719
42911
  size: "sm",
42720
42912
  variant: "ghost",
42721
42913
  className: "h-5 shrink-0 px-1 text-[10px]",
42722
- disabled: mine,
42914
+ disabled: mineValue,
42723
42915
  onClick: () => void start(row),
42724
42916
  children: "Put this back"
42725
42917
  }
42918
+ ) : null,
42919
+ rights.write && row.version > 1 ? /* @__PURE__ */ jsx139(
42920
+ Button88,
42921
+ {
42922
+ size: "sm",
42923
+ variant: "ghost",
42924
+ className: "h-5 shrink-0 px-1 text-[10px]",
42925
+ disabled: mineBack,
42926
+ onClick: () => void start(row, true),
42927
+ children: "Undo this change"
42928
+ }
42726
42929
  ) : null
42727
42930
  ] }),
42728
- confirming ? /* @__PURE__ */ jsx139("div", { className: "border-t px-2 py-2", children: /* @__PURE__ */ jsx139(
42729
- ConfirmRestore,
42730
- {
42731
- preview: confirming.preview,
42732
- busy: false,
42733
- onConfirm: () => void confirm(confirming.recordId, confirming.version),
42734
- onCancel: () => setPending({ phase: "idle" })
42735
- }
42736
- ) }) : null
42931
+ confirming ? /* @__PURE__ */ jsxs127("div", { className: "border-t px-2 py-2", children: [
42932
+ confirming.laterEdit ? /* @__PURE__ */ jsxs127("p", { "data-later-edit": "", className: "mb-1 text-[11px] font-medium text-amber-700 dark:text-amber-400", children: [
42933
+ label,
42934
+ " was edited again after this change. Undoing replaces that newer value; Cancel keeps it."
42935
+ ] }) : null,
42936
+ /* @__PURE__ */ jsx139(
42937
+ ConfirmRestore,
42938
+ {
42939
+ preview: confirming.preview,
42940
+ busy: false,
42941
+ onConfirm: () => void confirm(confirming.recordId, confirming.version, confirming.back === true),
42942
+ onCancel: () => setPending({ phase: "idle" })
42943
+ }
42944
+ )
42945
+ ] }) : null
42737
42946
  ] }, `${row.record_id}-${row.version}`);
42738
42947
  }) }),
42739
42948
  rights.write ? null : /* @__PURE__ */ jsx139("p", { className: "text-[11px] text-muted-foreground", children: rights.why("write") })
@@ -42874,7 +43083,7 @@ function FormResultsPanel({ form, className }) {
42874
43083
  import { useCallback as useCallback50, useEffect as useEffect99, useMemo as useMemo68, useRef as useRef56, useState as useState119 } from "react";
42875
43084
  import { useRecordsClient as useRecordsClient83, useTables as useTables4 } from "@ai-matrx/records/react";
42876
43085
  import { BasicInput as BasicInput23, Button as Button90, Checkbox as Checkbox14, Label as Label20, Separator as Separator10, Skeleton as Skeleton26, cn as cn75 } from "@ai-matrx/design-system";
42877
- import { Fragment as Fragment54, jsx as jsx141, jsxs as jsxs129 } from "react/jsx-runtime";
43086
+ import { Fragment as Fragment55, jsx as jsx141, jsxs as jsxs129 } from "react/jsx-runtime";
42878
43087
  var RESTATING_REPLACES = "Saving replaces what this portal shows: a table you untick stops being visible to every client the moment you save. Who is invited is not touched.";
42879
43088
  function PortalBuilder({ tableId, portalId, onSaved, onClose, className }) {
42880
43089
  const client = useRecordsClient83();
@@ -43094,7 +43303,7 @@ function PortalBuilder({ tableId, portalId, onSaved, onClose, className }) {
43094
43303
  ),
43095
43304
  /* @__PURE__ */ jsx141("span", { className: "text-xs text-muted-foreground", children: "One record in this table is one client. Their sign-in is a one-time link emailed to them \u2014 a portal never holds a password." })
43096
43305
  ] }),
43097
- clientTableId ? /* @__PURE__ */ jsxs129(Fragment54, { children: [
43306
+ clientTableId ? /* @__PURE__ */ jsxs129(Fragment55, { children: [
43098
43307
  /* @__PURE__ */ jsx141(Separator10, {}),
43099
43308
  /* @__PURE__ */ jsxs129("div", { className: "flex flex-col gap-2", children: [
43100
43309
  /* @__PURE__ */ jsx141(Label20, { className: "text-xs font-medium", children: "What they can see" }),
@@ -43201,7 +43410,7 @@ function PortalBuilder({ tableId, portalId, onSaved, onClose, className }) {
43201
43410
  " yet."
43202
43411
  ] }) : null
43203
43412
  ] }) : null,
43204
- savedId ? /* @__PURE__ */ jsxs129(Fragment54, { children: [
43413
+ savedId ? /* @__PURE__ */ jsxs129(Fragment55, { children: [
43205
43414
  /* @__PURE__ */ jsx141(Separator10, {}),
43206
43415
  /* @__PURE__ */ jsxs129("div", { className: "flex flex-col gap-2", children: [
43207
43416
  /* @__PURE__ */ jsx141(Label20, { className: "text-xs font-medium", children: "Invite a client" }),
@@ -43574,7 +43783,7 @@ function PortalLookEditor({ card, onSaved, className }) {
43574
43783
  }
43575
43784
 
43576
43785
  // src/PortalsPanel.tsx
43577
- import { Fragment as Fragment55, jsx as jsx144, jsxs as jsxs132 } from "react/jsx-runtime";
43786
+ import { Fragment as Fragment56, jsx as jsx144, jsxs as jsxs132 } from "react/jsx-runtime";
43578
43787
  var PORTAL_NOT_HERE_LINE = "The link named a portal this table is not part of \u2014 it may have been archived, or it shows other tables. The portals this table is in are listed here.";
43579
43788
  function revokeConsequence(person, portalTitle) {
43580
43789
  const who = person.client ? `${person.email} (${person.client})` : person.email;
@@ -43684,7 +43893,7 @@ function PortalsPanel({ tableId, activePortalId, className }) {
43684
43893
  buildLabel: elsewhere > 0 ? "Build a new portal" : "Build the portal",
43685
43894
  children: [
43686
43895
  "A portal is how one of your clients signs in and sees the records that name them \u2014 their jobs, their invoices \u2014 and nothing else.",
43687
- elsewhere > 0 ? /* @__PURE__ */ jsxs132(Fragment55, { children: [
43896
+ elsewhere > 0 ? /* @__PURE__ */ jsxs132(Fragment56, { children: [
43688
43897
  " ",
43689
43898
  "This table is not in",
43690
43899
  " ",
@@ -43812,7 +44021,7 @@ function ArchivePortalControl({
43812
44021
  if (said2) {
43813
44022
  return /* @__PURE__ */ jsx144("span", { className: "text-xs text-muted-foreground", "data-testid": "portal-archived-said", children: said2 });
43814
44023
  }
43815
- return /* @__PURE__ */ jsxs132(Fragment55, { children: [
44024
+ return /* @__PURE__ */ jsxs132(Fragment56, { children: [
43816
44025
  /* @__PURE__ */ jsx144(
43817
44026
  Button92,
43818
44027
  {
@@ -43860,7 +44069,7 @@ function ArchivePortalControl({
43860
44069
  function CopyLink({ url, what }) {
43861
44070
  const [copied, setCopied] = useState121(false);
43862
44071
  const [shown5, setShown] = useState121(false);
43863
- return /* @__PURE__ */ jsxs132(Fragment55, { children: [
44072
+ return /* @__PURE__ */ jsxs132(Fragment56, { children: [
43864
44073
  /* @__PURE__ */ jsx144(
43865
44074
  Button92,
43866
44075
  {
@@ -44003,13 +44212,13 @@ function PortalCardView({
44003
44212
  ] })
44004
44213
  ] }, exposed.table_id))
44005
44214
  ] }),
44006
- look ? /* @__PURE__ */ jsxs132(Fragment55, { children: [
44215
+ look ? /* @__PURE__ */ jsxs132(Fragment56, { children: [
44007
44216
  /* @__PURE__ */ jsx144(Separator11, {}),
44008
44217
  look
44009
44218
  ] }) : null,
44010
44219
  /* @__PURE__ */ jsx144(Separator11, {}),
44011
44220
  /* @__PURE__ */ jsx144(People, { card, onRevoke, onPreview, origin }),
44012
- invite ? /* @__PURE__ */ jsxs132(Fragment55, { children: [
44221
+ invite ? /* @__PURE__ */ jsxs132(Fragment56, { children: [
44013
44222
  /* @__PURE__ */ jsx144(Separator11, {}),
44014
44223
  invite
44015
44224
  ] }) : null
@@ -44208,7 +44417,7 @@ function Invite({ card, onInvited }) {
44208
44417
  /* @__PURE__ */ jsx144("p", { className: "text-xs text-muted-foreground", children: "Pick the client they are, and say where to send their sign-in link. They get nothing until they follow it." }),
44209
44418
  error ? /* @__PURE__ */ jsx144(RefusalNotice, { error }) : null,
44210
44419
  said2 ? /* @__PURE__ */ jsx144("p", { className: "text-xs text-muted-foreground", children: said2 }) : null,
44211
- rows === null ? /* @__PURE__ */ jsx144(Skeleton27, { className: "h-9 w-full" }) : /* @__PURE__ */ jsxs132(Fragment55, { children: [
44420
+ rows === null ? /* @__PURE__ */ jsx144(Skeleton27, { className: "h-9 w-full" }) : /* @__PURE__ */ jsxs132(Fragment56, { children: [
44212
44421
  /* @__PURE__ */ jsx144(
44213
44422
  BasicInput25,
44214
44423
  {
@@ -44396,7 +44605,7 @@ function scheduleWords(schedule, tz) {
44396
44605
  }
44397
44606
 
44398
44607
  // src/DigestScheduler.tsx
44399
- import { Fragment as Fragment56, jsx as jsx146, jsxs as jsxs134 } from "react/jsx-runtime";
44608
+ import { Fragment as Fragment57, jsx as jsx146, jsxs as jsxs134 } from "react/jsx-runtime";
44400
44609
  var WEEKDAYS = ["monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday"];
44401
44610
  var CADENCE_WORDS = {
44402
44611
  instant: "the moment something arrives",
@@ -44648,7 +44857,7 @@ function DigestScheduler({
44648
44857
  ] }),
44649
44858
  /* @__PURE__ */ jsxs134("div", { className: "flex flex-col gap-1.5", children: [
44650
44859
  /* @__PURE__ */ jsx146(Label21, { className: "text-xs font-medium", children: "Who to send it to" }),
44651
- members === null ? /* @__PURE__ */ jsx146(Skeleton28, { className: "h-8 w-full" }) : members.length === 0 ? /* @__PURE__ */ jsx146("p", { className: "text-xs text-muted-foreground", children: "Nobody else is offered here, so this will be addressed to you. Who the people are is the platform's answer and this screen reaches it through its host's `members` port, which is not bound here." }) : /* @__PURE__ */ jsxs134(Fragment56, { children: [
44860
+ members === null ? /* @__PURE__ */ jsx146(Skeleton28, { className: "h-8 w-full" }) : members.length === 0 ? /* @__PURE__ */ jsx146("p", { className: "text-xs text-muted-foreground", children: "Nobody else is offered here, so this will be addressed to you. Who the people are is the platform's answer and this screen reaches it through its host's `members` port, which is not bound here." }) : /* @__PURE__ */ jsxs134(Fragment57, { children: [
44652
44861
  /* @__PURE__ */ jsx146("div", { className: "flex flex-wrap gap-x-4 gap-y-1.5", children: members.map((m) => /* @__PURE__ */ jsxs134("label", { className: "flex items-center gap-1.5 text-xs", children: [
44653
44862
  /* @__PURE__ */ jsx146(
44654
44863
  Checkbox15,
@@ -44690,7 +44899,7 @@ function DigestScheduler({
44690
44899
  ),
44691
44900
  /* @__PURE__ */ jsx146("span", { className: "text-xs text-muted-foreground", children: "A send inside these hours waits until they end \u2014 it is never dropped." })
44692
44901
  ] }) : null,
44693
- outcomes ? /* @__PURE__ */ jsxs134(Fragment56, { children: [
44902
+ outcomes ? /* @__PURE__ */ jsxs134(Fragment57, { children: [
44694
44903
  /* @__PURE__ */ jsx146(Separator12, {}),
44695
44904
  /* @__PURE__ */ jsx146("div", { className: "flex flex-col gap-1.5", children: outcomes.map((o) => /* @__PURE__ */ jsx146("div", { className: "text-xs", children: o.ruleId ? /* @__PURE__ */ jsxs134("span", { children: [
44696
44905
  o.who,
@@ -45206,7 +45415,7 @@ import {
45206
45415
  FORM_EMBEDS,
45207
45416
  formEmbedSnippet
45208
45417
  } from "@ai-matrx/records/forms";
45209
- import { Fragment as Fragment57, jsx as jsx149, jsxs as jsxs137 } from "react/jsx-runtime";
45418
+ import { Fragment as Fragment58, jsx as jsx149, jsxs as jsxs137 } from "react/jsx-runtime";
45210
45419
  function freshEndingId(taken) {
45211
45420
  if (!taken.includes("ending")) return "ending";
45212
45421
  let n = 2;
@@ -45255,7 +45464,7 @@ function EndingsEditor({
45255
45464
  /* @__PURE__ */ jsx149(BasicTextarea10, { className: "col-span-2", rows: 2, "aria-label": "Ending message", placeholder: "Message", value: e.body ?? "", onChange: (ev) => patch(i, { body: ev.target.value || null }) }),
45256
45465
  /* @__PURE__ */ jsx149(BasicInput28, { type: "url", "aria-label": "Ending page", placeholder: "Then go to (optional) https://", value: e.redirectUrl ?? "", onChange: (ev) => patch(i, { redirectUrl: ev.target.value || null }) }),
45257
45466
  /* @__PURE__ */ jsx149(BasicInput28, { "aria-label": "Ending button", placeholder: "Continue", value: e.buttonLabel ?? "", onChange: (ev) => patch(i, { buttonLabel: ev.target.value || null }) }),
45258
- scored ? /* @__PURE__ */ jsxs137(Fragment57, { children: [
45467
+ scored ? /* @__PURE__ */ jsxs137(Fragment58, { children: [
45259
45468
  /* @__PURE__ */ jsx149(BasicInput28, { inputMode: "decimal", "aria-label": "Lowest score", placeholder: "From score", value: e.scoreMin ?? "", onChange: (ev) => patch(i, { scoreMin: numberOrNull(ev.target.value) }) }),
45260
45469
  /* @__PURE__ */ jsx149(BasicInput28, { inputMode: "decimal", "aria-label": "Highest score", placeholder: "To score", value: e.scoreMax ?? "", onChange: (ev) => patch(i, { scoreMax: numberOrNull(ev.target.value) }) })
45261
45470
  ] }) : null,
@@ -45451,7 +45660,7 @@ import { useFields as useFields27, useOptionalRecordsClient as useOptionalRecord
45451
45660
  import { Button as Button97, Label as Label24, Progress, Skeleton as Skeleton31, cn as cn83, formThemeClasses } from "@ai-matrx/design-system";
45452
45661
  import { answerRefusal, formRoutes, pipeAnswers, submissionStamp } from "@ai-matrx/records/forms";
45453
45662
  import { humanizeIdentifier as humanizeIdentifier21 } from "@ai-matrx/kit/text-case";
45454
- import { Fragment as Fragment58, jsx as jsx150, jsxs as jsxs138 } from "react/jsx-runtime";
45663
+ import { Fragment as Fragment59, jsx as jsx150, jsxs as jsxs138 } from "react/jsx-runtime";
45455
45664
  function authored(host, text, where) {
45456
45665
  return host.renderText ? host.renderText(text, where) : text;
45457
45666
  }
@@ -46025,7 +46234,7 @@ function ThankYou({
46025
46234
  ),
46026
46235
  ending?.pictureUrl ? /* @__PURE__ */ jsx150("img", { src: ending.pictureUrl, alt: "", className: "mb-3 max-h-48 w-full rounded-md object-cover" }) : null,
46027
46236
  /* @__PURE__ */ jsx150("h2", { className: "text-2xl font-semibold", "data-records-form-ending": ending?.id ?? "", children: title || "Thank you" }),
46028
- body ? /* @__PURE__ */ jsxs138(Fragment58, { children: [
46237
+ body ? /* @__PURE__ */ jsxs138(Fragment59, { children: [
46029
46238
  done === "preview" ? /* @__PURE__ */ jsx150("p", { className: "mt-2 text-xs uppercase tracking-wide text-muted-foreground", children: "After a real send, people read:" }) : null,
46030
46239
  /* @__PURE__ */ jsx150("p", { className: "mt-2 text-base text-muted-foreground", children: authored(host, body, "form-thank-you") })
46031
46240
  ] }) : null,
@@ -46081,7 +46290,7 @@ function Question({
46081
46290
  field2.unit ? /* @__PURE__ */ jsx150("span", { className: "text-sm text-foreground/70", children: field2.unit }) : null
46082
46291
  ] }),
46083
46292
  question.help ? /* @__PURE__ */ jsx150("p", { className: cn83("text-muted-foreground", large ? "text-base" : "text-sm"), children: authored(host, question.help, "form-help") }) : null,
46084
- isAttachment && !upload ? /* @__PURE__ */ jsx150("p", { className: "w-fit rounded border border-dashed px-2 py-0.5 text-xs text-muted-foreground", title: NO_UPLOAD_REASON, children: "File upload unavailable here" }) : isAttachment ? /* @__PURE__ */ jsxs138(Fragment58, { children: [
46293
+ isAttachment && !upload ? /* @__PURE__ */ jsx150("p", { className: "w-fit rounded border border-dashed px-2 py-0.5 text-xs text-muted-foreground", title: NO_UPLOAD_REASON, children: "File upload unavailable here" }) : isAttachment ? /* @__PURE__ */ jsxs138(Fragment59, { children: [
46085
46294
  /* @__PURE__ */ jsx150(
46086
46295
  "input",
46087
46296
  {
@@ -46125,7 +46334,7 @@ import {
46125
46334
  formFromSummary,
46126
46335
  formLookDocument
46127
46336
  } from "@ai-matrx/records/forms";
46128
- import { Fragment as Fragment59, jsx as jsx151, jsxs as jsxs139 } from "react/jsx-runtime";
46337
+ import { Fragment as Fragment60, jsx as jsx151, jsxs as jsxs139 } from "react/jsx-runtime";
46129
46338
  function freshFormName(base2, taken) {
46130
46339
  const names = new Set(taken.map((n) => n.trim().toLowerCase()));
46131
46340
  if (!names.has(base2.toLowerCase())) return base2;
@@ -46526,7 +46735,7 @@ function FormBuilder({ tableId, seed, activeFormId, onActiveForm, startWithOne,
46526
46735
  }
46527
46736
  )
46528
46737
  ] }) : null,
46529
- !draft ? /* @__PURE__ */ jsx151("p", { className: "text-xs text-muted-foreground", children: (fields.data ?? []).length === 0 ? "No fields yet" : "No form yet" }) : /* @__PURE__ */ jsxs139(Fragment59, { children: [
46738
+ !draft ? /* @__PURE__ */ jsx151("p", { className: "text-xs text-muted-foreground", children: (fields.data ?? []).length === 0 ? "No fields yet" : "No form yet" }) : /* @__PURE__ */ jsxs139(Fragment60, { children: [
46530
46739
  /* @__PURE__ */ jsx151(
46531
46740
  PublishRow,
46532
46741
  {
@@ -46777,7 +46986,7 @@ function PublishRow({
46777
46986
  children: busy ? "\u2026" : open ? "Unpublish" : unsaved ? "Save and publish" : "Publish"
46778
46987
  }
46779
46988
  ) : null,
46780
- state !== "draft" ? /* @__PURE__ */ jsxs139(Fragment59, { children: [
46989
+ state !== "draft" ? /* @__PURE__ */ jsxs139(Fragment60, { children: [
46781
46990
  /* @__PURE__ */ jsx151(
46782
46991
  "a",
46783
46992
  {
@@ -48218,7 +48427,7 @@ function combineFilter(base2, extra, fieldIdOf) {
48218
48427
  }
48219
48428
 
48220
48429
  // src/DashboardCanvas.tsx
48221
- import { Fragment as Fragment60, jsx as jsx158, jsxs as jsxs146 } from "react/jsx-runtime";
48430
+ import { Fragment as Fragment61, jsx as jsx158, jsxs as jsxs146 } from "react/jsx-runtime";
48222
48431
  function DashboardCanvas({ tableId, activeDashboardId, filter, createOnMount, onCreated, className }) {
48223
48432
  const client = useRecordsClient95();
48224
48433
  const host = useRecordsUi();
@@ -48471,7 +48680,7 @@ function DashboardCanvas({ tableId, activeDashboardId, filter, createOnMount, on
48471
48680
  children: scheduling ? "Done" : "Send on a schedule"
48472
48681
  }
48473
48682
  ),
48474
- rights.admin && askingToRemove === board.id ? /* @__PURE__ */ jsxs146(Fragment60, { children: [
48683
+ rights.admin && askingToRemove === board.id ? /* @__PURE__ */ jsxs146(Fragment61, { children: [
48475
48684
  /* @__PURE__ */ jsx158("span", { className: "text-xs text-destructive", children: archiveConfirmSentence(`the dashboard \u201C${board.name}\u201D`) }),
48476
48685
  /* @__PURE__ */ jsx158(Button104, { size: "sm", variant: "destructive", onClick: () => void remove(board), children: "Remove it" }),
48477
48686
  /* @__PURE__ */ jsx158(Button104, { size: "sm", variant: "ghost", onClick: () => setAskingToRemove(null), children: "Keep it" })
@@ -48519,7 +48728,7 @@ function DashboardCanvas({ tableId, activeDashboardId, filter, createOnMount, on
48519
48728
  /* @__PURE__ */ jsx158(Button104, { size: "sm", disabled: !host.onReask || asking || question.trim() === "", onClick: () => void reask(), children: asking ? "Asking" : "Ask" })
48520
48729
  ] }) }) : null,
48521
48730
  notKept ? /* @__PURE__ */ jsx158("p", { role: "status", "data-records-dashboard-not-kept": "", className: "text-xs text-amber-700 dark:text-amber-400", children: notKept }) : null,
48522
- !board ? /* @__PURE__ */ jsx158("p", { className: "text-xs text-muted-foreground", children: rights.admin ? "No dashboards yet." : rights.why("structure") }) : run === null ? /* @__PURE__ */ jsx158(Skeleton37, { className: "h-64 w-full" }) : run.blocks.length === 0 ? /* @__PURE__ */ jsx158("p", { className: "text-xs text-muted-foreground", children: "No charts yet." }) : /* @__PURE__ */ jsxs146(Fragment60, { children: [
48731
+ !board ? /* @__PURE__ */ jsx158("p", { className: "text-xs text-muted-foreground", children: rights.admin ? "No dashboards yet." : rights.why("structure") }) : run === null ? /* @__PURE__ */ jsx158(Skeleton37, { className: "h-64 w-full" }) : run.blocks.length === 0 ? /* @__PURE__ */ jsx158("p", { className: "text-xs text-muted-foreground", children: "No charts yet." }) : /* @__PURE__ */ jsxs146(Fragment61, { children: [
48523
48732
  /* @__PURE__ */ jsx158(
48524
48733
  DashboardGrid,
48525
48734
  {
@@ -48533,7 +48742,7 @@ function DashboardCanvas({ tableId, activeDashboardId, filter, createOnMount, on
48533
48742
  id: board.blocks[index]?.id ?? block.id ?? `block-${index}`,
48534
48743
  title: block.title,
48535
48744
  span: board.blocks[index]?.span ?? block.span,
48536
- body: /* @__PURE__ */ jsxs146(Fragment60, { children: [
48745
+ body: /* @__PURE__ */ jsxs146(Fragment61, { children: [
48537
48746
  spansTables ? /* @__PURE__ */ jsx158(ChartOfTable, { block, subject: tableId, table: board.blocks[index]?.subject ?? block.table_id ?? tableId }) : /* @__PURE__ */ jsx158(ChartBlock, { block, subject: tableId }),
48538
48747
  rights.admin && board.blocks[index] ? /* @__PURE__ */ jsx158(
48539
48748
  BlockSettingsMenu,
@@ -48640,7 +48849,7 @@ function GroupingPicker({
48640
48849
  return /* @__PURE__ */ jsx158("span", { className: "text-muted-foreground", children: "No columns to group by." });
48641
48850
  }
48642
48851
  const known = choices.some((c) => c.field.key === current);
48643
- return /* @__PURE__ */ jsxs146(Fragment60, { children: [
48852
+ return /* @__PURE__ */ jsxs146(Fragment61, { children: [
48644
48853
  /* @__PURE__ */ jsx158("label", { className: "text-muted-foreground", htmlFor: `block-group-${block.title}`, children: "Group by" }),
48645
48854
  /* @__PURE__ */ jsxs146(Select19, { value: known ? current : "", onValueChange: onPick, children: [
48646
48855
  /* @__PURE__ */ jsx158(
@@ -48737,7 +48946,7 @@ function CompareControl({
48737
48946
  // that has one does not lose it by being shown.
48738
48947
  (k) => k !== "range" || current === "range"
48739
48948
  );
48740
- return /* @__PURE__ */ jsxs146(Fragment60, { children: [
48949
+ return /* @__PURE__ */ jsxs146(Fragment61, { children: [
48741
48950
  /* @__PURE__ */ jsxs146(
48742
48951
  Select19,
48743
48952
  {
@@ -48799,7 +49008,7 @@ function TargetControl({
48799
49008
  if (draft.trim() === "" || !Number.isFinite(n) || n === savedValue) return;
48800
49009
  onChange({ value: n, label: label && saved === "value" ? label : "Target", ...per ? { per } : {} });
48801
49010
  }
48802
- return /* @__PURE__ */ jsxs146(Fragment60, { children: [
49011
+ return /* @__PURE__ */ jsxs146(Fragment61, { children: [
48803
49012
  /* @__PURE__ */ jsxs146(
48804
49013
  Select19,
48805
49014
  {
@@ -48864,7 +49073,7 @@ __reExport(question_exports, questions_star);
48864
49073
  import * as questions_star from "@ai-matrx/records/questions";
48865
49074
 
48866
49075
  // src/QuestionPanel.tsx
48867
- import { Fragment as Fragment61, jsx as jsx159, jsxs as jsxs147 } from "react/jsx-runtime";
49076
+ import { Fragment as Fragment62, jsx as jsx159, jsxs as jsxs147 } from "react/jsx-runtime";
48868
49077
  var OP_LABEL = { count: "Count", sum: "Sum", avg: "Average", min: "Smallest", max: "Largest" };
48869
49078
  var BUCKETS = [
48870
49079
  { value: "", label: "Exact date" },
@@ -49115,7 +49324,7 @@ function QuestionPanel({ tableId, activeQuestionId, draft, className }) {
49115
49324
  }
49116
49325
  ) : /* @__PURE__ */ jsx159("span", { className: "text-muted-foreground", children: "Now" })
49117
49326
  ] }),
49118
- spec.group ? /* @__PURE__ */ jsxs147(Fragment61, { children: [
49327
+ spec.group ? /* @__PURE__ */ jsxs147(Fragment62, { children: [
49119
49328
  /* @__PURE__ */ jsx159(Label27, { className: "pt-1.5 text-xs text-muted-foreground", children: "Sort" }),
49120
49329
  /* @__PURE__ */ jsxs147("div", { className: "flex flex-wrap items-center gap-1.5", children: [
49121
49330
  /* @__PURE__ */ jsx159(
@@ -49633,7 +49842,7 @@ function questionFromWords(text, fields, choices = {}) {
49633
49842
  }
49634
49843
 
49635
49844
  // src/TableAsk.tsx
49636
- import { Fragment as Fragment62, jsx as jsx160, jsxs as jsxs148 } from "react/jsx-runtime";
49845
+ import { Fragment as Fragment63, jsx as jsx160, jsxs as jsxs148 } from "react/jsx-runtime";
49637
49846
  function askExampleFor(fields) {
49638
49847
  const by = fields.find(isChoiceField);
49639
49848
  return by ? `count by ${fieldName(by)}` : "count";
@@ -49701,14 +49910,14 @@ function TableAsk({ tableId, onOpenInQuestions, viewId }) {
49701
49910
  ),
49702
49911
  /* @__PURE__ */ jsxs148("div", { className: said2.kind === "idle" ? "hidden" : "flex min-h-32 flex-col gap-2", "data-table-ask-slot": "", children: [
49703
49912
  said2.kind === "not-read" ? /* @__PURE__ */ jsx160("p", { className: "text-muted-foreground", role: "status", "data-table-ask-not-read": "", children: said2.why }) : null,
49704
- said2.kind === "asking" ? /* @__PURE__ */ jsxs148(Fragment62, { children: [
49913
+ said2.kind === "asking" ? /* @__PURE__ */ jsxs148(Fragment63, { children: [
49705
49914
  /* @__PURE__ */ jsx160("p", { className: "truncate text-muted-foreground", children: said2.reads }),
49706
49915
  /* @__PURE__ */ jsx160(Skeleton39, { className: "h-24 w-full", "data-table-ask-pending": "" })
49707
49916
  ] }) : null,
49708
49917
  said2.kind === "agent-failed" ? /* @__PURE__ */ jsx160("div", { "data-table-ask-failed": "", children: /* @__PURE__ */ jsx160(RefusalNotice, { error: said2.error }) }) : null,
49709
49918
  said2.kind === "agent-answer" ? /* @__PURE__ */ jsx160(AgentAnswer, { tableId, answer: said2.answer, fields: all, costPoints: said2.costPoints }) : null,
49710
49919
  said2.kind === "refused" ? /* @__PURE__ */ jsx160(RefusalNotice, { error: said2.error }) : null,
49711
- said2.kind === "answer" ? /* @__PURE__ */ jsxs148(Fragment62, { children: [
49920
+ said2.kind === "answer" ? /* @__PURE__ */ jsxs148(Fragment63, { children: [
49712
49921
  /* @__PURE__ */ jsx160("p", { className: "truncate text-muted-foreground", title: said2.reads, "data-table-ask-reads": "", children: said2.reads }),
49713
49922
  /* @__PURE__ */ jsx160("div", { className: "max-h-64 overflow-y-auto", "data-table-ask-answer": "", children: /* @__PURE__ */ jsx160(QuestionAnswerView, { tableId, spec: said2.spec, answer: said2.answer, fields: all }) }),
49714
49923
  onOpenInQuestions ? /* @__PURE__ */ jsx160(
@@ -49839,7 +50048,7 @@ import {
49839
50048
  import { onRecordChanged as onRecordChanged2 } from "@ai-matrx/records/core";
49840
50049
  import { BasicInput as BasicInput35, Button as Button107, Checkbox as Checkbox19, Skeleton as Skeleton40, cn as cn92 } from "@ai-matrx/design-system";
49841
50050
  import { formFromSummary as formFromSummary2 } from "@ai-matrx/records/forms";
49842
- import { Fragment as Fragment63, jsx as jsx161, jsxs as jsxs149 } from "react/jsx-runtime";
50051
+ import { Fragment as Fragment64, jsx as jsx161, jsxs as jsxs149 } from "react/jsx-runtime";
49843
50052
  var EDIT_LEVELS = /* @__PURE__ */ new Set(["edit_content", "editor", "admin", "owner"]);
49844
50053
  function PageScreen({
49845
50054
  pageId,
@@ -50058,7 +50267,7 @@ function PageScreen({
50058
50267
  className: "h-8 w-40"
50059
50268
  }
50060
50269
  ),
50061
- /* @__PURE__ */ jsx161("span", { className: "ml-auto flex items-center gap-1", children: askingToArchive ? /* @__PURE__ */ jsxs149(Fragment63, { children: [
50270
+ /* @__PURE__ */ jsx161("span", { className: "ml-auto flex items-center gap-1", children: askingToArchive ? /* @__PURE__ */ jsxs149(Fragment64, { children: [
50062
50271
  /* @__PURE__ */ jsx161("span", { className: "text-destructive", children: archiveConfirmSentence(`the page \u201C${page.name}\u201D`) }),
50063
50272
  /* @__PURE__ */ jsx161(Button107, { size: "sm", variant: "destructive", onClick: () => void archive(), children: "Archive it" }),
50064
50273
  /* @__PURE__ */ jsx161(Button107, { size: "sm", variant: "ghost", onClick: () => setAskingToArchive(false), children: "Keep it" })
@@ -50163,7 +50372,7 @@ function AppletBlockView({ block }) {
50163
50372
  const host = useRecordsUi();
50164
50373
  if (!host.applets) return /* @__PURE__ */ jsx161(BlockNote, { children: "Applets open inside AI Matrx." });
50165
50374
  if (!block.app_id) return /* @__PURE__ */ jsx161(BlockNote, { children: "Choose an applet." });
50166
- return /* @__PURE__ */ jsx161(Fragment63, { children: host.applets.render(block.app_id) });
50375
+ return /* @__PURE__ */ jsx161(Fragment64, { children: host.applets.render(block.app_id) });
50167
50376
  }
50168
50377
  function AppletPick({ value, onChange }) {
50169
50378
  const host = useRecordsUi();
@@ -50344,7 +50553,7 @@ function ActionButton2({ block, recordId }) {
50344
50553
  else setError(ran.error);
50345
50554
  }
50346
50555
  return /* @__PURE__ */ jsxs149("div", { className: "flex flex-wrap items-center gap-2", "data-records-page-button": block.id, children: [
50347
- asking ? /* @__PURE__ */ jsxs149(Fragment63, { children: [
50556
+ asking ? /* @__PURE__ */ jsxs149(Fragment64, { children: [
50348
50557
  /* @__PURE__ */ jsx161("span", { className: "text-xs", children: `${label}?` }),
50349
50558
  /* @__PURE__ */ jsx161(Button107, { size: "sm", onClick: () => void runIt(), children: label }),
50350
50559
  /* @__PURE__ */ jsx161(Button107, { size: "sm", variant: "ghost", onClick: () => setAsking(false), children: "Cancel" })
@@ -50436,7 +50645,7 @@ function BlockSettings2({
50436
50645
  ),
50437
50646
  block.kind === "list" ? /* @__PURE__ */ jsx161(ListSettings, { block, onChange }) : null,
50438
50647
  block.kind === "record" ? /* @__PURE__ */ jsx161(PickOne, { label: "Follows list", placeholder: "Choose a list", value: block.source, options: listOptions, onChange: (source) => onChange({ ...block, source }), className: "h-7 w-36" }) : null,
50439
- block.kind === "button" ? /* @__PURE__ */ jsxs149(Fragment63, { children: [
50648
+ block.kind === "button" ? /* @__PURE__ */ jsxs149(Fragment64, { children: [
50440
50649
  /* @__PURE__ */ jsx161(
50441
50650
  PickOne,
50442
50651
  {
@@ -50453,11 +50662,11 @@ function BlockSettings2({
50453
50662
  ),
50454
50663
  /* @__PURE__ */ jsx161(ActionPicker, { tableId: block.table_id, value: block.action_id, onChange: (action_id) => onChange({ ...block, action_id }) })
50455
50664
  ] }) : null,
50456
- block.kind === "form" ? /* @__PURE__ */ jsxs149(Fragment63, { children: [
50665
+ block.kind === "form" ? /* @__PURE__ */ jsxs149(Fragment64, { children: [
50457
50666
  /* @__PURE__ */ jsx161(TablePick, { value: block.table_id, onChange: (table_id) => onChange({ ...block, table_id, form_id: "" }) }),
50458
50667
  /* @__PURE__ */ jsx161(FormPicker, { tableId: block.table_id, value: block.form_id, onChange: (form_id) => onChange({ ...block, form_id }) })
50459
50668
  ] }) : null,
50460
- block.kind === "filter" ? /* @__PURE__ */ jsxs149(Fragment63, { children: [
50669
+ block.kind === "filter" ? /* @__PURE__ */ jsxs149(Fragment64, { children: [
50461
50670
  /* @__PURE__ */ jsx161(TablePick, { value: block.table_id, onChange: (table_id) => onChange({ ...block, table_id, field: "" }) }),
50462
50671
  /* @__PURE__ */ jsx161(FieldPick, { tableId: block.table_id, want: "choice", label: "Filter column", value: block.field, onChange: (field2) => onChange({ ...block, field: field2 }) })
50463
50672
  ] }) : null,
@@ -50504,7 +50713,7 @@ function ListSettings({ block, onChange }) {
50504
50713
  };
50505
50714
  }, [client, block.table_id]);
50506
50715
  const shown5 = block.columns && block.columns.length > 0 ? block.columns : [...all].sort((a, b) => (a.sort ?? 100) - (b.sort ?? 100)).slice(0, DEFAULT_COLUMNS).map((f) => f.key);
50507
- return /* @__PURE__ */ jsxs149(Fragment63, { children: [
50716
+ return /* @__PURE__ */ jsxs149(Fragment64, { children: [
50508
50717
  /* @__PURE__ */ jsx161(
50509
50718
  TablePick,
50510
50719
  {
@@ -50584,7 +50793,7 @@ function FormPicker({ tableId, value, onChange }) {
50584
50793
  return /* @__PURE__ */ jsx161(PickOne, { label: "Form", placeholder: "Choose a form", value, options, onChange: (v) => onChange(v), className: "h-7 w-40" });
50585
50794
  }
50586
50795
  function ChartSettings({ chart, onChange }) {
50587
- return /* @__PURE__ */ jsxs149(Fragment63, { children: [
50796
+ return /* @__PURE__ */ jsxs149(Fragment64, { children: [
50588
50797
  /* @__PURE__ */ jsx161(TablePick, { value: chart.subject, onChange: (subject) => onChange({ ...chart, subject, groupBy: [] }) }),
50589
50798
  /* @__PURE__ */ jsx161(
50590
50799
  PickOne,
@@ -50622,7 +50831,7 @@ import { useRecordsClient as useRecordsClient99, useTable as useTable37 } from "
50622
50831
  import { publicFormPath as publicFormPath2 } from "@ai-matrx/records";
50623
50832
  import { Badge as Badge25, Button as Button108, Skeleton as Skeleton41, cn as cn93 } from "@ai-matrx/design-system";
50624
50833
  import { FORM_STATE_WORDS as FORM_STATE_WORDS2 } from "@ai-matrx/records/forms";
50625
- import { Fragment as Fragment64, jsx as jsx162, jsxs as jsxs150 } from "react/jsx-runtime";
50834
+ import { Fragment as Fragment65, jsx as jsx162, jsxs as jsxs150 } from "react/jsx-runtime";
50626
50835
  var FORM_NOT_HERE_LINE = "The link named a form this table does not have \u2014 it may have been removed, or it belongs to another table. The forms this table does have are listed here.";
50627
50836
  var WHAT_A_FORM_IS = "A form asks for this table's own fields, and its answers land here as ordinary records stamped with the form they came through.";
50628
50837
  var NO_ADMIN2 = "This table has no forms. Making one needs the admin level on it, because a form decides what people with no account may add here.";
@@ -50758,12 +50967,12 @@ function FormsPanel({ tableId, activeFormId, className }) {
50758
50967
  /* @__PURE__ */ jsxs150("p", { className: "mt-1.5 text-xs", children: [
50759
50968
  /* @__PURE__ */ jsx162("span", { className: "font-medium", children: form.in_table }),
50760
50969
  " in the table",
50761
- form.held > 0 ? /* @__PURE__ */ jsxs150(Fragment64, { children: [
50970
+ form.held > 0 ? /* @__PURE__ */ jsxs150(Fragment65, { children: [
50762
50971
  " \xB7 ",
50763
50972
  /* @__PURE__ */ jsx162("span", { className: "font-medium", children: form.held }),
50764
50973
  " waiting for someone"
50765
50974
  ] }) : null,
50766
- form.rejected > 0 ? /* @__PURE__ */ jsxs150(Fragment64, { children: [
50975
+ form.rejected > 0 ? /* @__PURE__ */ jsxs150(Fragment65, { children: [
50767
50976
  " \xB7 ",
50768
50977
  /* @__PURE__ */ jsx162("span", { className: "font-medium", children: form.rejected }),
50769
50978
  " turned away"
@@ -51192,7 +51401,7 @@ function CaptureRun({ sheetId, face: given, className }) {
51192
51401
  }
51193
51402
 
51194
51403
  // src/CaptureSheet.tsx
51195
- import { Fragment as Fragment65, jsx as jsx164, jsxs as jsxs152 } from "react/jsx-runtime";
51404
+ import { Fragment as Fragment66, jsx as jsx164, jsxs as jsxs152 } from "react/jsx-runtime";
51196
51405
  var CAPTURE_MODES = ["reading", "photo", "voice"];
51197
51406
  var IN_MEMORY_QUEUE_REASON = "Anything you capture while offline is held only in this page until it can be sent, and it is lost if you close the tab. Keep this page open until you are back on a connection. It is said here rather than discovered later.";
51198
51407
  function mintClientKey() {
@@ -51369,7 +51578,7 @@ function AdHocCaptureSheet({
51369
51578
  " ",
51370
51579
  /* @__PURE__ */ jsx164("code", { children: "attachmentField" }),
51371
51580
  "."
51372
- ] }) : /* @__PURE__ */ jsxs152(Fragment65, { children: [
51581
+ ] }) : /* @__PURE__ */ jsxs152(Fragment66, { children: [
51373
51582
  /* @__PURE__ */ jsx164(
51374
51583
  "input",
51375
51584
  {
@@ -51643,7 +51852,7 @@ import { useCallback as useCallback68, useEffect as useEffect120, useState as us
51643
51852
  import { useRecordsClient as useRecordsClient104 } from "@ai-matrx/records/react";
51644
51853
  import { Button as Button112, Input as Input10, Skeleton as Skeleton46, Textarea as Textarea9, cn as cn98 } from "@ai-matrx/design-system";
51645
51854
  import { useTable as useTable39 } from "@ai-matrx/records/react";
51646
- import { Fragment as Fragment66, jsx as jsx167, jsxs as jsxs155 } from "react/jsx-runtime";
51855
+ import { Fragment as Fragment67, jsx as jsx167, jsxs as jsxs155 } from "react/jsx-runtime";
51647
51856
  function EmbedFrame({
51648
51857
  tableId,
51649
51858
  formId,
@@ -51727,7 +51936,7 @@ function EmbedFrame({
51727
51936
  " will not pass."
51728
51937
  ] })
51729
51938
  ] }),
51730
- !secret ? /* @__PURE__ */ jsx167(Button112, { size: "sm", className: "self-start", disabled: busy || parsed.length === 0, onClick: () => void issue(), children: busy ? "Issuing\u2026" : "Issue embed" }) : /* @__PURE__ */ jsxs155(Fragment66, { children: [
51939
+ !secret ? /* @__PURE__ */ jsx167(Button112, { size: "sm", className: "self-start", disabled: busy || parsed.length === 0, onClick: () => void issue(), children: busy ? "Issuing\u2026" : "Issue embed" }) : /* @__PURE__ */ jsxs155(Fragment67, { children: [
51731
51940
  /* @__PURE__ */ jsx167("p", { className: "rounded border px-2 py-1 text-xs text-muted-foreground", children: "Copy this now. Only its digest is stored, so nobody \u2014 including us \u2014 can show it to you again; if it is lost, issue a new one and replace the old." }),
51732
51941
  /* @__PURE__ */ jsx167(Textarea9, { "aria-label": "Embed snippet", readOnly: true, rows: 3, className: "font-mono text-[11px]", value: snippet ?? "" }),
51733
51942
  /* @__PURE__ */ jsxs155("div", { className: "flex gap-2", children: [
@@ -51777,7 +51986,7 @@ function useEmbedHandshake(args) {
51777
51986
  import { copyText as copyText15 } from "@ai-matrx/kit/clipboard";
51778
51987
  import { useCallback as useCallback70, useEffect as useEffect123, useMemo as useMemo82, useRef as useRef63, useState as useState150 } from "react";
51779
51988
  import { archivedByLine as archivedByLine2 } from "@ai-matrx/records";
51780
- import { tableShapeChanged as tableShapeChanged14, useFields as useFields39, useRecordsClient as useRecordsClient106, useSeededAnswer, useTable as useTable40, useTableArchive as useTableArchive2 } from "@ai-matrx/records/react";
51989
+ import { tableShapeChanged as tableShapeChanged15, useFields as useFields39, useRecordsClient as useRecordsClient106, useSeededAnswer, useTable as useTable40, useTableArchive as useTableArchive2 } from "@ai-matrx/records/react";
51781
51990
  import {
51782
51991
  Badge as Badge26,
51783
51992
  BottomSheet,
@@ -52039,16 +52248,16 @@ async function runTablePageAction(kind, args) {
52039
52248
  }
52040
52249
 
52041
52250
  // src/RecordPanel.tsx
52042
- import { Fragment as Fragment67, useState as useState144 } from "react";
52251
+ import { Fragment as Fragment68, useState as useState144 } from "react";
52043
52252
  import { Button as Button114, Separator as Separator13 } from "@ai-matrx/design-system";
52044
52253
  import { useFields as useFields37, useRecord as useRecord5 } from "@ai-matrx/records/react";
52045
- import { Fragment as Fragment68, jsx as jsx169, jsxs as jsxs157 } from "react/jsx-runtime";
52254
+ import { Fragment as Fragment69, jsx as jsx169, jsxs as jsxs157 } from "react/jsx-runtime";
52046
52255
  function RecordPanel({ tableId, recordId, onClose, onAskAboutField, onPage = false }) {
52047
52256
  const host = useRecordsUi();
52048
52257
  const [asking, setAsking] = useState144(null);
52049
52258
  return /* @__PURE__ */ jsxs157("div", { className: "space-y-3", "data-record-panel": recordId, children: [
52050
52259
  /* @__PURE__ */ jsx169(Peek, { tableId, recordId, onPage, ...onClose ? { onClose } : {} }),
52051
- onPage ? /* @__PURE__ */ jsxs157(Fragment68, { children: [
52260
+ onPage ? /* @__PURE__ */ jsxs157(Fragment69, { children: [
52052
52261
  /* @__PURE__ */ jsx169(RecordBody, { tableId, recordId }),
52053
52262
  /* @__PURE__ */ jsx169(LinkedLists, { tableId, recordId }),
52054
52263
  /* @__PURE__ */ jsx169(ReverseLinksSections, { tableId, recordId }),
@@ -52064,7 +52273,7 @@ function RecordPanel({ tableId, recordId, onClose, onAskAboutField, onPage = fal
52064
52273
  }
52065
52274
  ),
52066
52275
  !onAskAboutField && asking ? /* @__PURE__ */ jsx169(FieldHistoryPanel, { tableId, fieldKey: asking, recordId, onClose: () => setAsking(null) }) : null,
52067
- host.recordSections ? /* @__PURE__ */ jsxs157(Fragment67, { children: [
52276
+ host.recordSections ? /* @__PURE__ */ jsxs157(Fragment68, { children: [
52068
52277
  /* @__PURE__ */ jsx169(Separator13, {}),
52069
52278
  host.recordSections({ tableId, recordId })
52070
52279
  ] }) : null,
@@ -52257,9 +52466,9 @@ function TableReferenceDialog({
52257
52466
  // src/TableDuplicate.tsx
52258
52467
  import { formatCount as formatCount7 } from "@ai-matrx/kit/format";
52259
52468
  import { useState as useState147 } from "react";
52260
- import { tableShapeChanged as tableShapeChanged13, useRecordsClient as useRecordsClient105 } from "@ai-matrx/records/react";
52469
+ import { tableShapeChanged as tableShapeChanged14, useRecordsClient as useRecordsClient105 } from "@ai-matrx/records/react";
52261
52470
  import { Button as Button117, Dialog as Dialog20, DialogContent as DialogContent20, DialogFooter as DialogFooter13, DialogHeader as DialogHeader20, DialogTitle as DialogTitle20, ErrorBox as ErrorBox8, Input as Input11, Switch as Switch7 } from "@ai-matrx/design-system";
52262
- import { Fragment as Fragment69, jsx as jsx172, jsxs as jsxs160 } from "react/jsx-runtime";
52471
+ import { Fragment as Fragment70, jsx as jsx172, jsxs as jsxs160 } from "react/jsx-runtime";
52263
52472
  function copyNameFor(name) {
52264
52473
  return `${name.trim() || "Table"} (copy)`;
52265
52474
  }
@@ -52297,7 +52506,7 @@ function TableDuplicateDialog({ tableId, name, open, onOpenChange, onDuplicated
52297
52506
  setPhase({ kind: "refused", sentence: refusalSentence(made.error) });
52298
52507
  return;
52299
52508
  }
52300
- tableShapeChanged13(made.data.table.id);
52509
+ tableShapeChanged14(made.data.table.id);
52301
52510
  setPhase({ kind: "done", copy: made.data });
52302
52511
  host.notify?.success(`Made ${made.data.table.name}`);
52303
52512
  };
@@ -52350,7 +52559,7 @@ function TableDuplicateDialog({ tableId, name, open, onOpenChange, onDuplicated
52350
52559
  phase.kind === "refused" ? /* @__PURE__ */ jsx172(ErrorBox8, { children: phase.sentence }) : null,
52351
52560
  problem && typed2 !== "" ? /* @__PURE__ */ jsx172("p", { className: "text-xs text-muted-foreground", children: problem }) : null
52352
52561
  ] }),
52353
- /* @__PURE__ */ jsx172(DialogFooter13, { children: phase.kind === "done" ? /* @__PURE__ */ jsx172(Button117, { onClick: () => openCopy(phase.copy), "data-table-duplicate-open": "", children: "Open the copy" }) : /* @__PURE__ */ jsxs160(Fragment69, { children: [
52562
+ /* @__PURE__ */ jsx172(DialogFooter13, { children: phase.kind === "done" ? /* @__PURE__ */ jsx172(Button117, { onClick: () => openCopy(phase.copy), "data-table-duplicate-open": "", children: "Open the copy" }) : /* @__PURE__ */ jsxs160(Fragment70, { children: [
52354
52563
  /* @__PURE__ */ jsx172(Button117, { variant: "ghost", disabled: copying, onClick: () => close(false), children: "Cancel" }),
52355
52564
  /* @__PURE__ */ jsx172(Button117, { disabled: copying || problem !== null, onClick: () => void go(), children: copying ? "Duplicating\u2026" : "Duplicate" })
52356
52565
  ] }) })
@@ -52737,7 +52946,7 @@ function useSlotScroll(slot) {
52737
52946
 
52738
52947
  // src/TablePage.tsx
52739
52948
  import { isUuidShape as isUuidShape3 } from "@ai-matrx/kit/uuid";
52740
- import { Fragment as Fragment70, jsx as jsx175, jsxs as jsxs163 } from "react/jsx-runtime";
52949
+ import { Fragment as Fragment71, jsx as jsx175, jsxs as jsxs163 } from "react/jsx-runtime";
52741
52950
  var RAIL_TITLE = {
52742
52951
  settings: "Table settings",
52743
52952
  inbox: "Inbox",
@@ -53114,9 +53323,9 @@ function TablePage({
53114
53323
  client,
53115
53324
  tableId,
53116
53325
  name: finished.table_name || table.data?.name || "the table",
53117
- onRestored: () => tableShapeChanged14(tableId)
53326
+ onRestored: () => tableShapeChanged15(tableId)
53118
53327
  });
53119
- tableShapeChanged14(tableId);
53328
+ tableShapeChanged15(tableId);
53120
53329
  return;
53121
53330
  }
53122
53331
  setSurface((now) => ({ ...now, main: "records", rail: "settings" }));
@@ -53386,7 +53595,7 @@ function TablePage({
53386
53595
  children: VIEW_LAYOUTS.map((option) => /* @__PURE__ */ jsx175(DropdownMenuRadioItem3, { value: option, children: LAYOUT_LABEL[option] }, option))
53387
53596
  }
53388
53597
  );
53389
- const sheetExtras = controlsInSheet && main === "records" && shownLayout === "grid" ? /* @__PURE__ */ jsxs163(Fragment70, { children: [
53598
+ const sheetExtras = controlsInSheet && main === "records" && shownLayout === "grid" ? /* @__PURE__ */ jsxs163(Fragment71, { children: [
53390
53599
  /* @__PURE__ */ jsx175("div", { className: "flex items-center gap-2 text-xs", "data-table-sheet-filter": "", "data-matrx-table-tools-keep-open": "", children: /* @__PURE__ */ jsx175(ViewFilter, { tableId, view: shown5, onApply: (where) => void patchView({ where }) }) }),
53391
53600
  /* @__PURE__ */ jsx175("div", { role: "group", "aria-label": "Layout", className: "flex flex-wrap gap-1 pt-1", "data-table-sheet-layout": "", children: VIEW_LAYOUTS.map((option) => /* @__PURE__ */ jsx175(
53392
53601
  Button119,
@@ -53606,7 +53815,7 @@ function TablePage({
53606
53815
  return () => window.removeEventListener("keydown", onKey);
53607
53816
  }, [recordsUi]);
53608
53817
  const openedFromMenu = openedEntry ? { ...openedEntry, label: actions.find((a) => a.id === openedEntry.id)?.label ?? openedEntry.key } : null;
53609
- const pageActions = /* @__PURE__ */ jsxs163(Fragment70, { children: [
53818
+ const pageActions = /* @__PURE__ */ jsxs163(Fragment71, { children: [
53610
53819
  publicReadOnly ? /* @__PURE__ */ jsx175(Badge26, { variant: "neutral", className: "shrink-0", "data-public-read-only": "", children: PUBLIC_READ_ONLY }, "public-read-only") : null,
53611
53820
  !phone && rights.read && table.data ? /* @__PURE__ */ jsx175(
53612
53821
  TableAsk,
@@ -53634,7 +53843,7 @@ function TablePage({
53634
53843
  },
53635
53844
  `share-${shareAsked}`
53636
53845
  ) }, "share") : null,
53637
- phone ? /* @__PURE__ */ jsxs163(Fragment70, { children: [
53846
+ phone ? /* @__PURE__ */ jsxs163(Fragment71, { children: [
53638
53847
  !chooserInline && !chooserCompact && !embedded ? /* @__PURE__ */ jsxs163(DropdownMenu10, { children: [
53639
53848
  /* @__PURE__ */ jsx175(DropdownMenuTrigger10, { asChild: true, children: /* @__PURE__ */ jsx175(Button119, { size: "sm", variant: "ghost", "aria-label": "Layout", title: "Layout", "data-table-layout-menu": "", children: "Layout" }) }),
53640
53849
  /* @__PURE__ */ jsx175(DropdownMenuContent10, { align: "end", className: "w-56", children: layoutRadio })
@@ -53647,7 +53856,7 @@ function TablePage({
53647
53856
  /* @__PURE__ */ jsx175("circle", { cx: "19", cy: "12", r: "1.75" })
53648
53857
  ] }) }) }),
53649
53858
  /* @__PURE__ */ jsxs163(DropdownMenuContent10, { align: "end", className: "w-64", "data-table-menu-content": "", ...renameMenuProps, children: [
53650
- !chooserInline && !chooserCompact && !embedded ? /* @__PURE__ */ jsxs163(Fragment70, { children: [
53859
+ !chooserInline && !chooserCompact && !embedded ? /* @__PURE__ */ jsxs163(Fragment71, { children: [
53651
53860
  /* @__PURE__ */ jsx175(DropdownMenuLabel3, { className: "text-xs text-muted-foreground", children: "Layout" }),
53652
53861
  layoutRadio,
53653
53862
  /* @__PURE__ */ jsx175(DropdownMenuSeparator5, {})
@@ -53707,18 +53916,18 @@ function TablePage({
53707
53916
  rights.structure && table.data ? /* @__PURE__ */ jsx175(TableRenameDialog, { tableId, name: table.data.name, open: renameOpen, onOpenChange: setRenameOpen }, "rename") : null
53708
53917
  ] });
53709
53918
  const headerNode = header && !embedded ? header({ actions: table.data ? pageActions : null, tableName: table.data?.name ?? null }) : null;
53710
- if (table.error) return /* @__PURE__ */ jsxs163(Fragment70, { children: [
53919
+ if (table.error) return /* @__PURE__ */ jsxs163(Fragment71, { children: [
53711
53920
  headerNode,
53712
53921
  /* @__PURE__ */ jsx175(RefusalNotice, { error: table.error })
53713
53922
  ] });
53714
53923
  if (table.loading && !table.data) {
53715
- return /* @__PURE__ */ jsxs163(Fragment70, { children: [
53924
+ return /* @__PURE__ */ jsxs163(Fragment71, { children: [
53716
53925
  headerNode,
53717
53926
  /* @__PURE__ */ jsx175(TablePageSkeleton, { layout: skeletonFace, embedded, tableId, ...className ? { className } : {} })
53718
53927
  ] });
53719
53928
  }
53720
53929
  if (!table.data) {
53721
- return /* @__PURE__ */ jsxs163(Fragment70, { children: [
53930
+ return /* @__PURE__ */ jsxs163(Fragment71, { children: [
53722
53931
  headerNode,
53723
53932
  /* @__PURE__ */ jsx175(TableNotHere, { tableId, onLeave, leaveLabel, className })
53724
53933
  ] });
@@ -53730,11 +53939,11 @@ function TablePage({
53730
53939
  headerNode,
53731
53940
  /* @__PURE__ */ jsx175("div", { className: "flex min-h-0 min-w-0 flex-1 flex-col gap-2", children: structure.hidden || !structure.settled ? (
53732
53941
  /* THE TOOLBAR ROW'S HEIGHT IS KEPT (min-h-8), so the sentence lands exactly where the bar was. */
53733
- /* @__PURE__ */ jsxs163(Fragment70, { children: [
53942
+ /* @__PURE__ */ jsxs163(Fragment71, { children: [
53734
53943
  /* @__PURE__ */ jsx175("div", { className: TABLE_TOOLBAR_ROW_CLASS, "data-table-toolbar": "", "aria-hidden": "true" }),
53735
53944
  structure.hidden ? /* @__PURE__ */ jsx175(StructureLocked, {}) : /* @__PURE__ */ jsx175(RecordsSkeleton, { layout: skeletonFace, embedded })
53736
53945
  ] })
53737
- ) : /* @__PURE__ */ jsxs163(Fragment70, { children: [
53946
+ ) : /* @__PURE__ */ jsxs163(Fragment71, { children: [
53738
53947
  /* @__PURE__ */ jsx175(ImportNotice, { tableId, epoch: importEpoch, onOpenImport: () => setRail("import") }),
53739
53948
  /* @__PURE__ */ jsxs163(
53740
53949
  "div",
@@ -54191,7 +54400,7 @@ import { MatrxTableCardShowMore as MatrxTableCardShowMore3 } from "@ai-matrx/des
54191
54400
  import { useEffect as useEffect124, useMemo as useMemo83, useRef as useRef64, useState as useState151 } from "react";
54192
54401
  import { Button as Button120, ErrorBox as ErrorBox9, Input as Input13, cn as cn101 } from "@ai-matrx/design-system";
54193
54402
  import { SEED_FRESH_MS, useRecordsClient as useRecordsClient107, useSeededAnswerAt } from "@ai-matrx/records/react";
54194
- import { Fragment as Fragment71, jsx as jsx176, jsxs as jsxs164 } from "react/jsx-runtime";
54403
+ import { Fragment as Fragment72, jsx as jsx176, jsxs as jsxs164 } from "react/jsx-runtime";
54195
54404
  var entityTitleColumn = entityNameColumn;
54196
54405
  function shown4(v) {
54197
54406
  if (v === null || v === void 0 || v === "") return "";
@@ -54380,7 +54589,7 @@ function EntityTablePageBody({
54380
54589
  presentation === "page" ? /* @__PURE__ */ jsx176("h2", { className: "truncate text-base font-semibold", children: entity.label ?? (entity.loading ? "Loading\u2026" : "Table") }) : null,
54381
54590
  presentation === "page" ? /* @__PURE__ */ jsx176("span", { className: "text-xs tabular-nums text-muted-foreground", children: entity.loading || entity.total === null ? "" : formatCount8(entity.total) }) : null,
54382
54591
  /* @__PURE__ */ jsxs164("span", { className: "ml-auto flex items-center gap-1", children: [
54383
- boardable ? /* @__PURE__ */ jsxs164(Fragment71, { children: [
54592
+ boardable ? /* @__PURE__ */ jsxs164(Fragment72, { children: [
54384
54593
  /* @__PURE__ */ jsx176(Button120, { size: "sm", variant: layout === "grid" ? "secondary" : "ghost", "aria-pressed": layout === "grid", onClick: () => choose("grid"), children: "Table" }),
54385
54594
  /* @__PURE__ */ jsx176(Button120, { size: "sm", variant: layout === "board" ? "secondary" : "ghost", "aria-pressed": layout === "board", onClick: () => choose("board"), children: "Board" })
54386
54595
  ] }) : null,
@@ -54419,7 +54628,7 @@ function EntityTablePageBody({
54419
54628
  ] })
54420
54629
  ] }) : null,
54421
54630
  addRefused ? /* @__PURE__ */ jsx176(ErrorBox9, { className: "rounded border border-destructive/40 px-1.5 py-1 text-xs text-destructive", message: addRefused, operation: "Add a row", origin: "records-ui/entityViews" }) : null,
54422
- entity.error ? /* @__PURE__ */ jsx176("p", { className: "px-1 py-3 text-xs text-muted-foreground", children: `This table could not be read: ${entity.error}` }) : layout === "board" && boardable ? /* @__PURE__ */ jsx176(EntityBoard, { entity, groupBy, onOpenRecord }) : /* @__PURE__ */ jsxs164(Fragment71, { children: [
54631
+ entity.error ? /* @__PURE__ */ jsx176("p", { className: "px-1 py-3 text-xs text-muted-foreground", children: `This table could not be read: ${entity.error}` }) : layout === "board" && boardable ? /* @__PURE__ */ jsx176(EntityBoard, { entity, groupBy, onOpenRecord }) : /* @__PURE__ */ jsxs164(Fragment72, { children: [
54423
54632
  presentation === "embedded" && searchBox ? /* @__PURE__ */ jsx176("div", { className: "flex min-w-0 items-center justify-end", "data-records-entity-search": "", children: /* @__PURE__ */ jsx176(TooltipProvider, { children: /* @__PURE__ */ jsx176(
54424
54633
  TapTargetSearchGroup2,
54425
54634
  {
@@ -54713,13 +54922,13 @@ function BindingDetails({
54713
54922
 
54714
54923
  // src/PickedSummaries.tsx
54715
54924
  import { useFields as useFields41, useRecord as useRecord6, useTable as useTable42 } from "@ai-matrx/records/react";
54716
- import { Fragment as Fragment72, jsx as jsx179, jsxs as jsxs166 } from "react/jsx-runtime";
54925
+ import { Fragment as Fragment73, jsx as jsx179, jsxs as jsxs166 } from "react/jsx-runtime";
54717
54926
  function TableNameText({ dataSource, tableId }) {
54718
54927
  const tables = useTablesAnywhere(dataSource);
54719
- if (!tableId) return /* @__PURE__ */ jsx179(Fragment72, { children: "\u2014" });
54720
- if (tables.loading) return /* @__PURE__ */ jsx179(Fragment72, { children: "\u2026" });
54721
- if (tables.error) return /* @__PURE__ */ jsx179(Fragment72, { children: "Couldn't load the table's name" });
54722
- return /* @__PURE__ */ jsx179(Fragment72, { children: tables.rows.find((t) => t.table_id === tableId)?.table_name ?? "\u2014" });
54928
+ if (!tableId) return /* @__PURE__ */ jsx179(Fragment73, { children: "\u2014" });
54929
+ if (tables.loading) return /* @__PURE__ */ jsx179(Fragment73, { children: "\u2026" });
54930
+ if (tables.error) return /* @__PURE__ */ jsx179(Fragment73, { children: "Couldn't load the table's name" });
54931
+ return /* @__PURE__ */ jsx179(Fragment73, { children: tables.rows.find((t) => t.table_id === tableId)?.table_name ?? "\u2014" });
54723
54932
  }
54724
54933
  function ColumnValuesText({
54725
54934
  dataSource,
@@ -54727,15 +54936,15 @@ function ColumnValuesText({
54727
54936
  tableId,
54728
54937
  value
54729
54938
  }) {
54730
- if (!tableId) return /* @__PURE__ */ jsx179(Fragment72, { children: "\u2014" });
54939
+ if (!tableId) return /* @__PURE__ */ jsx179(Fragment73, { children: "\u2014" });
54731
54940
  return /* @__PURE__ */ jsx179(
54732
54941
  TableScope,
54733
54942
  {
54734
54943
  dataSource,
54735
54944
  userId,
54736
54945
  tableId,
54737
- fallback: /* @__PURE__ */ jsx179(Fragment72, { children: "\u2026" }),
54738
- unavailable: /* @__PURE__ */ jsx179(Fragment72, { children: "Couldn't load this table's columns" }),
54946
+ fallback: /* @__PURE__ */ jsx179(Fragment73, { children: "\u2026" }),
54947
+ unavailable: /* @__PURE__ */ jsx179(Fragment73, { children: "Couldn't load this table's columns" }),
54739
54948
  children: /* @__PURE__ */ jsx179(RecordLabelProvider, { children: /* @__PURE__ */ jsx179(ColumnValuesWords, { tableId, value }) })
54740
54949
  }
54741
54950
  );
@@ -54743,8 +54952,8 @@ function ColumnValuesText({
54743
54952
  function ColumnValuesWords({ tableId, value }) {
54744
54953
  const fields = useFields41(tableId);
54745
54954
  const labels = useRecordLabels(fields.data ?? void 0);
54746
- if (fields.loading) return /* @__PURE__ */ jsx179(Fragment72, { children: "\u2026" });
54747
- if (fields.error) return /* @__PURE__ */ jsx179(Fragment72, { children: "Couldn't load this table's columns" });
54955
+ if (fields.loading) return /* @__PURE__ */ jsx179(Fragment73, { children: "\u2026" });
54956
+ if (fields.error) return /* @__PURE__ */ jsx179(Fragment73, { children: "Couldn't load this table's columns" });
54748
54957
  const parts = [];
54749
54958
  for (const [key, stored] of Object.entries(value)) {
54750
54959
  if (key.startsWith("_")) continue;
@@ -54758,7 +54967,7 @@ function ColumnValuesWords({ tableId, value }) {
54758
54967
  ] }, key)
54759
54968
  );
54760
54969
  }
54761
- return parts.length ? /* @__PURE__ */ jsx179(Fragment72, { children: parts }) : /* @__PURE__ */ jsx179(Fragment72, { children: "\u2014" });
54970
+ return parts.length ? /* @__PURE__ */ jsx179(Fragment73, { children: parts }) : /* @__PURE__ */ jsx179(Fragment73, { children: "\u2014" });
54762
54971
  }
54763
54972
  function RecordNameText({
54764
54973
  dataSource,
@@ -54766,15 +54975,15 @@ function RecordNameText({
54766
54975
  tableId,
54767
54976
  recordId
54768
54977
  }) {
54769
- if (!tableId || !recordId) return /* @__PURE__ */ jsx179(Fragment72, { children: "\u2014" });
54978
+ if (!tableId || !recordId) return /* @__PURE__ */ jsx179(Fragment73, { children: "\u2014" });
54770
54979
  return /* @__PURE__ */ jsx179(
54771
54980
  TableScope,
54772
54981
  {
54773
54982
  dataSource,
54774
54983
  userId,
54775
54984
  tableId,
54776
- fallback: /* @__PURE__ */ jsx179(Fragment72, { children: "\u2026" }),
54777
- unavailable: /* @__PURE__ */ jsx179(Fragment72, { children: "Couldn't load this record" }),
54985
+ fallback: /* @__PURE__ */ jsx179(Fragment73, { children: "\u2026" }),
54986
+ unavailable: /* @__PURE__ */ jsx179(Fragment73, { children: "Couldn't load this record" }),
54778
54987
  children: /* @__PURE__ */ jsx179(RecordNameWords, { tableId, recordId })
54779
54988
  }
54780
54989
  );
@@ -54782,10 +54991,10 @@ function RecordNameText({
54782
54991
  function RecordNameWords({ tableId, recordId }) {
54783
54992
  const table = useTable42(tableId);
54784
54993
  const record = useRecord6(recordId);
54785
- if (record.loading || table.loading) return /* @__PURE__ */ jsx179(Fragment72, { children: "\u2026" });
54786
- if (record.error) return /* @__PURE__ */ jsx179(Fragment72, { children: "Couldn't load this record" });
54787
- if (!record.data) return /* @__PURE__ */ jsx179(Fragment72, { children: "A record you cannot open" });
54788
- return /* @__PURE__ */ jsx179(Fragment72, { children: recordName(record.data.document, table.data?.title_field ?? null) });
54994
+ if (record.loading || table.loading) return /* @__PURE__ */ jsx179(Fragment73, { children: "\u2026" });
54995
+ if (record.error) return /* @__PURE__ */ jsx179(Fragment73, { children: "Couldn't load this record" });
54996
+ if (!record.data) return /* @__PURE__ */ jsx179(Fragment73, { children: "A record you cannot open" });
54997
+ return /* @__PURE__ */ jsx179(Fragment73, { children: recordName(record.data.document, table.data?.title_field ?? null) });
54789
54998
  }
54790
54999
 
54791
55000
  // src/HeldChangeDecision.tsx