@ai-matrx/records-ui 0.116.108 → 0.116.110

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
@@ -2904,6 +2904,7 @@ import {
2904
2904
  import {
2905
2905
  aiFieldPreset,
2906
2906
  presetInputs,
2907
+ defaultEnrichInputs,
2907
2908
  presetInstruction,
2908
2909
  presetsFor
2909
2910
  } from "@ai-matrx/records";
@@ -3255,6 +3256,7 @@ function EnrichPanel({ tableId, fieldId, className }) {
3255
3256
  });
3256
3257
  const chosen = setup.preset ? aiFieldPreset(setup.preset) : void 0;
3257
3258
  const readsPictures = presetInputs(setup.preset, attachmentColumns.map((f) => f.key));
3259
+ const readsRecord = readsPictures ?? defaultEnrichInputs(fields.data ?? [], target?.key ?? "");
3258
3260
  const applyPreset = (preset, answer) => {
3259
3261
  const reads = preset === "describe_image" ? attachmentColumns.map((f) => f.name ?? f.label) : void 0;
3260
3262
  const sentence2 = presetInstruction(preset, { answer, reads });
@@ -3339,7 +3341,7 @@ function EnrichPanel({ tableId, fieldId, className }) {
3339
3341
  review_interval_days: setup.every ? Number(setup.every) : null,
3340
3342
  enabled: false,
3341
3343
  // Describe image reads the table's attachment columns: name them, or the model is shown nothing.
3342
- ...readsPictures ? { inputs: readsPictures } : {}
3344
+ ...readsRecord.length > 0 ? { inputs: readsRecord } : {}
3343
3345
  }
3344
3346
  ),
3345
3347
  children: "Set it up"
@@ -4702,7 +4704,7 @@ function layoutPageCss(s) {
4702
4704
  }
4703
4705
 
4704
4706
  // src/DocTemplate.tsx
4705
- import { jsx as jsx14, jsxs as jsxs12 } from "react/jsx-runtime";
4707
+ import { Fragment as Fragment3, jsx as jsx14, jsxs as jsxs12 } from "react/jsx-runtime";
4706
4708
  function DocTemplate({ tableId, seed, pageSettings, activeTemplateId, onActiveTemplate, className }) {
4707
4709
  const client = useRecordsClient13();
4708
4710
  const claimSeed = useSeedGuard();
@@ -4724,6 +4726,7 @@ function DocTemplate({ tableId, seed, pageSettings, activeTemplateId, onActiveTe
4724
4726
  };
4725
4727
  const [unresolved, setUnresolved] = useState14([]);
4726
4728
  const [saving, setSaving] = useState14(false);
4729
+ const [askingToRemove, setAskingToRemove] = useState14(false);
4727
4730
  const load = useCallback6(async () => {
4728
4731
  const held = await client.docTemplates({ table_id: tableId });
4729
4732
  if (!held.ok) {
@@ -4796,6 +4799,19 @@ function DocTemplate({ tableId, seed, pageSettings, activeTemplateId, onActiveTe
4796
4799
  setActiveId(saved.data);
4797
4800
  await load();
4798
4801
  }
4802
+ async function remove(templateId) {
4803
+ setAskingToRemove(false);
4804
+ const gone = await client.docTemplateDelete({ template_id: templateId });
4805
+ if (!gone.ok) {
4806
+ setError(gone.error);
4807
+ return;
4808
+ }
4809
+ setActiveId(null);
4810
+ setDraftName("");
4811
+ setDraftBody("");
4812
+ setDraftLayout({ ...EMPTY_LAYOUT });
4813
+ await load();
4814
+ }
4799
4815
  if (fields.error) return /* @__PURE__ */ jsx14(RefusalNotice, { error: fields.error, onRetry: fields.reload, className });
4800
4816
  if (error) {
4801
4817
  return /* @__PURE__ */ jsx14(
@@ -4848,7 +4864,18 @@ function DocTemplate({ tableId, seed, pageSettings, activeTemplateId, onActiveTe
4848
4864
  children: "New template"
4849
4865
  }
4850
4866
  ),
4851
- /* @__PURE__ */ jsx14(Button11, { size: "sm", className: "ml-auto", disabled: saving, onClick: () => void save(), children: saving ? "Saving\u2026" : "Save" })
4867
+ /* @__PURE__ */ jsxs12("span", { className: "ml-auto flex shrink-0 items-center gap-1", children: [
4868
+ activeId && askingToRemove ? /* @__PURE__ */ jsxs12(Fragment3, { children: [
4869
+ /* @__PURE__ */ jsxs12("span", { className: "text-xs text-destructive", children: [
4870
+ "Remove \\u201c",
4871
+ templates.find((t) => t.id === activeId)?.name ?? draftName,
4872
+ "\\u201d? Trash brings it back."
4873
+ ] }),
4874
+ /* @__PURE__ */ jsx14(Button11, { size: "sm", variant: "destructive", "data-doc-template-remove-confirm": "", onClick: () => void remove(activeId), children: "Remove it" }),
4875
+ /* @__PURE__ */ jsx14(Button11, { size: "sm", variant: "ghost", onClick: () => setAskingToRemove(false), children: "Keep it" })
4876
+ ] }) : activeId ? /* @__PURE__ */ jsx14(Button11, { size: "sm", variant: "ghost", "data-doc-template-remove": "", disabled: saving, onClick: () => setAskingToRemove(true), children: "Remove" }) : null,
4877
+ /* @__PURE__ */ jsx14(Button11, { size: "sm", disabled: saving, onClick: () => void save(), children: saving ? "Saving\u2026" : "Save" })
4878
+ ] })
4852
4879
  ] }),
4853
4880
  /* @__PURE__ */ jsxs12("label", { className: "flex flex-col gap-1", children: [
4854
4881
  /* @__PURE__ */ jsx14(Label3, { className: "text-xs font-medium", children: "Name" }),
@@ -6045,7 +6072,7 @@ import {
6045
6072
  DropdownMenuTrigger,
6046
6073
  cn as cn7
6047
6074
  } from "@ai-matrx/design-system";
6048
- import { Fragment as Fragment3, jsx as jsx20, jsxs as jsxs18 } from "react/jsx-runtime";
6075
+ import { Fragment as Fragment4, jsx as jsx20, jsxs as jsxs18 } from "react/jsx-runtime";
6049
6076
  var SUMMARY_ROW_ID = "__records_ui_summary__";
6050
6077
  var SUMMARY_ROW = {
6051
6078
  id: SUMMARY_ROW_ID,
@@ -6159,7 +6186,7 @@ function SummaryCell({
6159
6186
  chosen ? "text-foreground" : "text-muted-foreground opacity-0 hover:opacity-100 focus-visible:opacity-100 data-[state=open]:opacity-100"
6160
6187
  ),
6161
6188
  title: chosen && rowCount !== null ? `${label} of ${fieldName(field)}, over all ${rowCount} record${rowCount === 1 ? "" : "s"} \u2014 not only this page.` : `Summarize ${fieldName(field)}`,
6162
- children: chosen ? /* @__PURE__ */ jsxs18(Fragment3, { children: [
6189
+ children: chosen ? /* @__PURE__ */ jsxs18(Fragment4, { children: [
6163
6190
  /* @__PURE__ */ jsx20("span", { className: "text-muted-foreground", children: label }),
6164
6191
  summaries.withheld[field.key] ? (
6165
6192
  // AGG-WITHHELD: the store withheld this column from her — say so, never a bare dash.
@@ -6180,7 +6207,7 @@ function SummaryCell({
6180
6207
  },
6181
6208
  op
6182
6209
  )),
6183
- chosen ? /* @__PURE__ */ jsxs18(Fragment3, { children: [
6210
+ chosen ? /* @__PURE__ */ jsxs18(Fragment4, { children: [
6184
6211
  /* @__PURE__ */ jsx20(DropdownMenuSeparator, {}),
6185
6212
  /* @__PURE__ */ jsx20(DropdownMenuItem, { onSelect: () => onChoose(null), children: calculate ? "None" : "No summary" })
6186
6213
  ] }) : null
@@ -6773,7 +6800,7 @@ function hiddenToWrite(hidden, fields) {
6773
6800
  }
6774
6801
 
6775
6802
  // src/gridControls.tsx
6776
- import { Fragment as Fragment4, jsx as jsx24, jsxs as jsxs22 } from "react/jsx-runtime";
6803
+ import { Fragment as Fragment5, jsx as jsx24, jsxs as jsxs22 } from "react/jsx-runtime";
6777
6804
  var VALUE_COUNTS_FRESH_MS = 1e4;
6778
6805
  var CLEAN_TABLE_LABEL = "Clean table\u2026";
6779
6806
  function filterForValue(field, value) {
@@ -7371,7 +7398,7 @@ function useMergedGridControls(args) {
7371
7398
  [enabled, order, hidden, keepColumns]
7372
7399
  );
7373
7400
  const close = () => setDialog(null);
7374
- const dialogs = !enabled ? null : /* @__PURE__ */ jsxs22(Fragment4, { children: [
7401
+ const dialogs = !enabled ? null : /* @__PURE__ */ jsxs22(Fragment5, { children: [
7375
7402
  colors.dialogs,
7376
7403
  dialog?.kind === "access" && columnAccess ? columnAccess({
7377
7404
  tableId,
@@ -7666,7 +7693,7 @@ function useMergedGridControls(args) {
7666
7693
  columns: columnsControl,
7667
7694
  dialogs,
7668
7695
  addColumn: () => setDialog({ kind: "insert", anchor: null, side: "right" }),
7669
- sheetTools: enabled ? /* @__PURE__ */ jsxs22(Fragment4, { children: [
7696
+ sheetTools: enabled ? /* @__PURE__ */ jsxs22(Fragment5, { children: [
7670
7697
  colors.sheet,
7671
7698
  args.summaries ? /* @__PURE__ */ jsx24(
7672
7699
  SummarySheetControls,
@@ -7732,7 +7759,7 @@ import {
7732
7759
  DropdownMenuItem as DropdownMenuItem3,
7733
7760
  DropdownMenuTrigger as DropdownMenuTrigger3
7734
7761
  } from "@ai-matrx/design-system";
7735
- import { Fragment as Fragment5, jsx as jsx25, jsxs as jsxs23 } from "react/jsx-runtime";
7762
+ import { Fragment as Fragment6, jsx as jsx25, jsxs as jsxs23 } from "react/jsx-runtime";
7736
7763
  var ADD_ROW_ID = "__records_ui_add_row__";
7737
7764
  var ADD_ROW = {
7738
7765
  id: ADD_ROW_ID,
@@ -7894,7 +7921,7 @@ function NewRecordControl({
7894
7921
  setFormInitial(ask2.initial);
7895
7922
  setFormOpen(true);
7896
7923
  }, [ask2]);
7897
- return /* @__PURE__ */ jsxs23(Fragment5, { children: [
7924
+ return /* @__PURE__ */ jsxs23(Fragment6, { children: [
7898
7925
  /* @__PURE__ */ jsxs23("div", { className: "inline-flex shrink-0", "data-records-new-record": "", children: [
7899
7926
  /* @__PURE__ */ jsx25(Button21, { size: "sm", className: "rounded-r-none", disabled: busy, onClick: onAdd, children: busy ? "Adding\u2026" : "New record" }),
7900
7927
  /* @__PURE__ */ jsxs23(DropdownMenu3, { children: [
@@ -8909,7 +8936,7 @@ import {
8909
8936
  // src/ReverseColumns.tsx
8910
8937
  import { useFields as useFields7, useOptionalRecordsClient, useReverseColumns as useReverseColumns2, useReverseLinks, useTable as useTable9 } from "@ai-matrx/records/react";
8911
8938
  import { Button as Button23, Dialog as Dialog14, DialogContent as DialogContent14, DialogHeader as DialogHeader14, DialogTitle as DialogTitle14, Popover as Popover2, PopoverContent as PopoverContent2, PopoverTrigger as PopoverTrigger2, Separator, Skeleton as Skeleton8, cn as cn8 } from "@ai-matrx/design-system";
8912
- import { Fragment as Fragment6, jsx as jsx27, jsxs as jsxs25 } from "react/jsx-runtime";
8939
+ import { Fragment as Fragment7, jsx as jsx27, jsxs as jsxs25 } from "react/jsx-runtime";
8913
8940
  function reverseColumnId(column) {
8914
8941
  return `${REVERSE_COLUMN_PREFIX}${column.key}`;
8915
8942
  }
@@ -9131,7 +9158,7 @@ function ReverseLinksSections({ tableId, recordId }) {
9131
9158
  if (reverse.error) return reverse.error.code === "door_absent" ? null : /* @__PURE__ */ jsx27(RefusalNotice, { error: reverse.error });
9132
9159
  const columns = reverse.data ?? [];
9133
9160
  if (columns.length === 0) return null;
9134
- return /* @__PURE__ */ jsxs25(Fragment6, { children: [
9161
+ return /* @__PURE__ */ jsxs25(Fragment7, { children: [
9135
9162
  /* @__PURE__ */ jsx27(Separator, {}),
9136
9163
  /* @__PURE__ */ jsx27("div", { className: "flex flex-col gap-3", "data-records-reverse-sections": "", children: columns.map((column) => /* @__PURE__ */ jsx27(ReverseLinksSection, { tableId, recordId, column }, column.key)) })
9137
9164
  ] });
@@ -9314,10 +9341,10 @@ import { humanizeIdentifier as humanizeIdentifier6 } from "@ai-matrx/kit/text-ca
9314
9341
  // src/PastePreview.tsx
9315
9342
  import { useState as useState28 } from "react";
9316
9343
  import { Badge as Badge3, Button as Button24, Separator as Separator2 } from "@ai-matrx/design-system";
9317
- import { Fragment as Fragment7, jsx as jsx29, jsxs as jsxs27 } from "react/jsx-runtime";
9344
+ import { Fragment as Fragment8, jsx as jsx29, jsxs as jsxs27 } from "react/jsx-runtime";
9318
9345
  function keptWhileAway(outcome, readBackUnsent, readBackRefusal) {
9319
9346
  if (!readBackUnsent || outcome.written === 0) return outcome;
9320
- const values = outcome.readBack + outcome.missing;
9347
+ const values = outcome.readBack + outcome.missing + (outcome.waiting ?? 0);
9321
9348
  return {
9322
9349
  ...outcome,
9323
9350
  readBack: 0,
@@ -9329,7 +9356,9 @@ function keptWhileAway(outcome, readBackUnsent, readBackRefusal) {
9329
9356
  function outcomeSentence(outcome) {
9330
9357
  const waiting = outcome.waiting ?? 0;
9331
9358
  if (waiting > 0) {
9332
- return `${waiting} ${waiting === 1 ? "value is" : "values are"} saved on this computer and will be sent to the table when you are back online.`;
9359
+ const kept = `${waiting} ${waiting === 1 ? "value is" : "values are"} saved on this computer and will be sent to the table when you are back online.`;
9360
+ const rest = outcome.missing > 0 ? ` ${outcome.missing} could not be found afterwards.` : "";
9361
+ return outcome.readBack > 0 ? `${outcome.readBack} in the table. ${kept}${rest}` : `${kept}${rest}`;
9333
9362
  }
9334
9363
  const whole = outcome.missing === 0 && outcome.refusals.length === 0;
9335
9364
  return whole ? `All ${outcome.readBack} ${outcome.readBack === 1 ? "value is" : "values are"} in the table \u2014 read back out of it, not just accepted.` : `${outcome.readBack} of ${outcome.readBack + outcome.missing} values are in the table. The rest are not, and nothing was lost from what you copied \u2014 it is still on your clipboard.`;
@@ -9368,7 +9397,7 @@ function PastePreview({
9368
9397
  /* @__PURE__ */ jsx29("span", { className: "text-xs text-muted-foreground", "data-matrx-paste-summary": true, children: outcome ? `${outcome.readBack} ${outcome.readBack === 1 ? "value" : "values"} read back` : summarize(plan) })
9369
9398
  ] }),
9370
9399
  /* @__PURE__ */ jsx29(Separator2, {}),
9371
- outcome === null ? /* @__PURE__ */ jsxs27(Fragment7, { children: [
9400
+ outcome === null ? /* @__PURE__ */ jsxs27(Fragment8, { children: [
9372
9401
  nothingToDo ? /* @__PURE__ */ jsx29("p", { className: "text-sm", children: "Nothing in what you pasted can be written to this table. Every cell is listed below with the reason." }) : /* @__PURE__ */ jsxs27("p", { className: "text-sm", children: [
9373
9402
  sentence(plan, noun, nounPlural),
9374
9403
  " The values below are exactly what will be saved, written the way the grid writes them \u2014 a choice column shows the word and saves the option behind it."
@@ -9477,7 +9506,7 @@ function PastePreview({
9477
9506
  function Outcome({ outcome, onClose }) {
9478
9507
  const whole = outcome.missing === 0 && outcome.refusals.length === 0;
9479
9508
  const look = (outcome.waiting ?? 0) > 0 ? "waiting" : whole ? "whole" : "partial";
9480
- return /* @__PURE__ */ jsxs27(Fragment7, { children: [
9509
+ return /* @__PURE__ */ jsxs27(Fragment8, { children: [
9481
9510
  /* @__PURE__ */ jsx29("p", { className: "text-sm", "data-matrx-paste-outcome": look, children: outcomeSentence(outcome) }),
9482
9511
  outcome.refusals.length > 0 ? /* @__PURE__ */ jsx29("ul", { className: "flex flex-col gap-1", children: outcome.refusals.slice(0, 8).map((why, index) => /* @__PURE__ */ jsx29("li", { className: "text-xs text-muted-foreground", children: why }, index)) }) : null,
9483
9512
  /* @__PURE__ */ jsx29("div", { className: "flex justify-end pt-1", children: /* @__PURE__ */ jsx29(Button24, { size: "sm", onClick: onClose, autoFocus: true, children: "Close" }) })
@@ -9565,7 +9594,7 @@ import {
9565
9594
  cn as cn9
9566
9595
  } from "@ai-matrx/design-system";
9567
9596
  import { openOutbound } from "@ai-matrx/kit/outbound";
9568
- import { Fragment as Fragment8, jsx as jsx30, jsxs as jsxs28 } from "react/jsx-runtime";
9597
+ import { Fragment as Fragment9, jsx as jsx30, jsxs as jsxs28 } from "react/jsx-runtime";
9569
9598
  function duplicateValues(fields, document2) {
9570
9599
  const data = {};
9571
9600
  for (const field of fields) {
@@ -9685,7 +9714,7 @@ function ContextActionItem({ action: action2 }) {
9685
9714
  );
9686
9715
  }
9687
9716
  function ObjectActionContextMenuItems({ actions }) {
9688
- return /* @__PURE__ */ jsx30(Fragment8, { children: toDropdownEntries(actions).map((entry) => {
9717
+ return /* @__PURE__ */ jsx30(Fragment9, { children: toDropdownEntries(actions).map((entry) => {
9689
9718
  if (entry.kind === "separator") return /* @__PURE__ */ jsx30(ContextMenuSeparator, {}, entry.id);
9690
9719
  if (entry.kind === "item") return /* @__PURE__ */ jsx30(ContextActionItem, { action: entry.action }, entry.action.id);
9691
9720
  return /* @__PURE__ */ jsxs28(ContextMenuSub, { children: [
@@ -9844,7 +9873,7 @@ import { useRecordsClient as useRecordsClient26 } from "@ai-matrx/records/react"
9844
9873
  import { Button as Button25, Skeleton as Skeleton9, cn as cn10 } from "@ai-matrx/design-system";
9845
9874
  import { Button as ControlButton, Field as ControlField } from "@ai-matrx/design-system/controls";
9846
9875
  import { humanizeIdentifier as humanizeIdentifier5 } from "@ai-matrx/kit/text-case";
9847
- import { Fragment as Fragment9, jsx as jsx32, jsxs as jsxs29 } from "react/jsx-runtime";
9876
+ import { Fragment as Fragment10, jsx as jsx32, jsxs as jsxs29 } from "react/jsx-runtime";
9848
9877
  function endOfDayIso(day2, zone = getPersonTimeZone()) {
9849
9878
  const [y, m, d] = day2.split("-").map(Number);
9850
9879
  if (!zone) return new Date(y, m - 1, d, 23, 59, 59, 999).toISOString();
@@ -9988,7 +10017,7 @@ function AsOfReading({
9988
10017
  }
9989
10018
  return /* @__PURE__ */ jsx32("dl", { className: cn10(box, "grid grid-cols-[minmax(5rem,9rem)_1fr] content-start gap-x-3 gap-y-0.5 p-2 text-[11px]"), "data-records-as-of-reading": "", children: rows.map(({ field, was, now, differs }) => /* @__PURE__ */ jsxs29("div", { className: "contents", "data-as-of-field": field.key, "data-as-of-differs": differs ? "" : void 0, children: [
9990
10019
  /* @__PURE__ */ jsx32("dt", { className: "truncate text-muted-foreground", title: fieldName(field) || humanizeIdentifier5(field.key), children: fieldName(field) || humanizeIdentifier5(field.key) }),
9991
- /* @__PURE__ */ jsx32("dd", { className: cn10("min-w-0 truncate", differs && "rounded bg-amber-500/10 px-1"), children: differs ? /* @__PURE__ */ jsxs29(Fragment9, { children: [
10020
+ /* @__PURE__ */ jsx32("dd", { className: cn10("min-w-0 truncate", differs && "rounded bg-amber-500/10 px-1"), children: differs ? /* @__PURE__ */ jsxs29(Fragment10, { children: [
9992
10021
  /* @__PURE__ */ jsx32("span", { className: "font-medium", children: isEmpty(was) ? "nothing" : scalarText(field, was) }),
9993
10022
  /* @__PURE__ */ jsx32("span", { className: "mx-1 text-muted-foreground", children: "\u2192" }),
9994
10023
  /* @__PURE__ */ jsx32("span", { className: "text-muted-foreground", children: isEmpty(now) ? "nothing" : scalarText(field, now) }),
@@ -10087,14 +10116,14 @@ function Glyph() {
10087
10116
  // src/toolbarSlot.tsx
10088
10117
  import { createContext as createContext3, useContext as useContext4 } from "react";
10089
10118
  import { createPortal } from "react-dom";
10090
- import { Fragment as Fragment10, jsx as jsx34 } from "react/jsx-runtime";
10119
+ import { Fragment as Fragment11, jsx as jsx34 } from "react/jsx-runtime";
10091
10120
  var TableToolbarSlotContext = createContext3(void 0);
10092
10121
  function useTableToolbarSlot() {
10093
10122
  return useContext4(TableToolbarSlotContext);
10094
10123
  }
10095
10124
  function InTableToolbar({ children }) {
10096
10125
  const slot = useTableToolbarSlot();
10097
- if (slot === void 0) return /* @__PURE__ */ jsx34(Fragment10, { children });
10126
+ if (slot === void 0) return /* @__PURE__ */ jsx34(Fragment11, { children });
10098
10127
  if (slot === null) return null;
10099
10128
  return createPortal(children, slot);
10100
10129
  }
@@ -10122,7 +10151,7 @@ import {
10122
10151
  DropdownMenuSeparator as DropdownMenuSeparator2,
10123
10152
  DropdownMenuTrigger as DropdownMenuTrigger5
10124
10153
  } from "@ai-matrx/design-system";
10125
- import { Fragment as Fragment11, jsx as jsx35, jsxs as jsxs31 } from "react/jsx-runtime";
10154
+ import { Fragment as Fragment12, jsx as jsx35, jsxs as jsxs31 } from "react/jsx-runtime";
10126
10155
  function useStoreGridLayout(tableId) {
10127
10156
  const client = useRecordsClient28();
10128
10157
  const [answer, setAnswer] = useState32({
@@ -10219,7 +10248,7 @@ function GridLayoutMenu({
10219
10248
  ]
10220
10249
  }
10221
10250
  ) : null,
10222
- anyOwn ? /* @__PURE__ */ jsxs31(Fragment11, { children: [
10251
+ anyOwn ? /* @__PURE__ */ jsxs31(Fragment12, { children: [
10223
10252
  /* @__PURE__ */ jsx35(DropdownMenuSeparator2, {}),
10224
10253
  /* @__PURE__ */ jsx35(
10225
10254
  DropdownMenuItem4,
@@ -10237,10 +10266,10 @@ function GridLayoutMenu({
10237
10266
 
10238
10267
  // src/newRowValues.tsx
10239
10268
  import { createContext as createContext4, useContext as useContext5 } from "react";
10240
- import { Fragment as Fragment12, jsx as jsx36 } from "react/jsx-runtime";
10269
+ import { Fragment as Fragment13, jsx as jsx36 } from "react/jsx-runtime";
10241
10270
  var NewRowValuesContext = createContext4(null);
10242
10271
  function NewRowValuesProvider({ values, children }) {
10243
- if (!values || Object.keys(values).length === 0) return /* @__PURE__ */ jsx36(Fragment12, { children });
10272
+ if (!values || Object.keys(values).length === 0) return /* @__PURE__ */ jsx36(Fragment13, { children });
10244
10273
  return /* @__PURE__ */ jsx36(NewRowValuesContext.Provider, { value: values, children });
10245
10274
  }
10246
10275
  function useNewRowValues() {
@@ -10254,7 +10283,7 @@ function withNewRowValues(preset, data) {
10254
10283
  import { useCallback as useCallback15, useEffect as useEffect27, useRef as useRef12, useState as useState33 } from "react";
10255
10284
  import { Button as Button28 } from "@ai-matrx/design-system";
10256
10285
  import { formatCount as formatCount3 } from "@ai-matrx/kit/format";
10257
- import { Fragment as Fragment13, jsx as jsx37, jsxs as jsxs32 } from "react/jsx-runtime";
10286
+ import { Fragment as Fragment14, jsx as jsx37, jsxs as jsxs32 } from "react/jsx-runtime";
10258
10287
  var LOAD_ALL_AFTER = 1e3;
10259
10288
  var LOAD_ALL_CHUNK = 500;
10260
10289
  async function loadAllPages(fetchPage, onProgress, cancelled) {
@@ -10311,7 +10340,7 @@ function LoadAllLine({
10311
10340
  onBack
10312
10341
  }) {
10313
10342
  const n = formatCount3(total);
10314
- return /* @__PURE__ */ jsx37("div", { className: "flex items-center gap-2 px-2 py-1 text-xs text-muted-foreground", "data-records-load-all": "", children: state.rows ? /* @__PURE__ */ jsxs32(Fragment13, { children: [
10343
+ return /* @__PURE__ */ jsx37("div", { className: "flex items-center gap-2 px-2 py-1 text-xs text-muted-foreground", "data-records-load-all": "", children: state.rows ? /* @__PURE__ */ jsxs32(Fragment14, { children: [
10315
10344
  /* @__PURE__ */ jsxs32("span", { role: "status", children: [
10316
10345
  "All ",
10317
10346
  formatCount3(state.rows.length),
@@ -10323,7 +10352,7 @@ function LoadAllLine({
10323
10352
  formatCount3(state.loaded),
10324
10353
  " of ",
10325
10354
  n
10326
- ] }) : /* @__PURE__ */ jsxs32(Fragment13, { children: [
10355
+ ] }) : /* @__PURE__ */ jsxs32(Fragment14, { children: [
10327
10356
  /* @__PURE__ */ jsxs32(Button28, { size: "sm", variant: "ghost", className: "h-6 px-2 text-xs", onClick: onLoad, "data-records-load-all-start": "", children: [
10328
10357
  "Load all ",
10329
10358
  n
@@ -10670,7 +10699,7 @@ import { tableShapeChanged as tableShapeChanged3, useRecordsClient as useRecords
10670
10699
  import { announceRecordChanged } from "@ai-matrx/records/core";
10671
10700
  import { Button as Button30 } from "@ai-matrx/design-system";
10672
10701
  import { createUndoStack, popRedo, popUndo, pushUndo } from "@ai-matrx/design-system/data-table";
10673
- import { Fragment as Fragment14, jsx as jsx40, jsxs as jsxs35 } from "react/jsx-runtime";
10702
+ import { Fragment as Fragment15, jsx as jsx40, jsxs as jsxs35 } from "react/jsx-runtime";
10674
10703
  function changesFor(step2, direction, versions = /* @__PURE__ */ new Map()) {
10675
10704
  const byRow = /* @__PURE__ */ new Map();
10676
10705
  for (const cell of step2.cells) {
@@ -10835,7 +10864,7 @@ function UndoRedoLive({ source }) {
10835
10864
  }
10836
10865
  function UndoRedoPair({ face, onUndo, onRedo }) {
10837
10866
  const undo = { depth: { back: face.back, forward: face.forward }, busy: face.busy };
10838
- return /* @__PURE__ */ jsxs35(Fragment14, { children: [
10867
+ return /* @__PURE__ */ jsxs35(Fragment15, { children: [
10839
10868
  /* @__PURE__ */ jsxs35(
10840
10869
  Button30,
10841
10870
  {
@@ -11352,7 +11381,7 @@ import {
11352
11381
  DialogTitle as DialogTitle15,
11353
11382
  Label as Label8
11354
11383
  } from "@ai-matrx/design-system";
11355
- import { Fragment as Fragment15, jsx as jsx42, jsxs as jsxs36 } from "react/jsx-runtime";
11384
+ import { Fragment as Fragment16, jsx as jsx42, jsxs as jsxs36 } from "react/jsx-runtime";
11356
11385
  function countOf(n, one, many) {
11357
11386
  return `${n} ${n === 1 ? one : many}`;
11358
11387
  }
@@ -11509,8 +11538,8 @@ function BulkActions({
11509
11538
  children: label
11510
11539
  }
11511
11540
  ) }, kind2);
11512
- return /* @__PURE__ */ jsxs36(Fragment15, { children: [
11513
- typeable.length > 0 ? /* @__PURE__ */ jsxs36(Fragment15, { children: [
11541
+ return /* @__PURE__ */ jsxs36(Fragment16, { children: [
11542
+ typeable.length > 0 ? /* @__PURE__ */ jsxs36(Fragment16, { children: [
11514
11543
  writeButton("set", "Set a column", () => open("set")),
11515
11544
  writeButton("clear", "Clear a column", () => open("clear")),
11516
11545
  ids.length > 1 ? writeButton("fill", "Fill down", () => open("fill")) : null
@@ -11985,7 +12014,7 @@ var ViewAddressContext = createContext5(null);
11985
12014
  var useViewAddress = () => useContext6(ViewAddressContext);
11986
12015
 
11987
12016
  // src/Grid.tsx
11988
- import { Fragment as Fragment16, jsx as jsx46, jsxs as jsxs39 } from "react/jsx-runtime";
12017
+ import { Fragment as Fragment17, jsx as jsx46, jsxs as jsxs39 } from "react/jsx-runtime";
11989
12018
  if (typeof window !== "undefined" && typeof performance?.mark === "function") performance.mark("load:heavy:Records grid");
11990
12019
  var WRAP_COLUMN_CELL_CLASS = "[table_tbody_&&]:max-w-none! [table_tbody_&&]:whitespace-normal! [table_tbody_&&]:overflow-visible! [table_tbody_&&_*]:whitespace-normal! [table_tbody_&&]:break-words [table_tbody_&&_[data-matrx-cell-content]]:max-h-[3lh]! [table_tbody_&&_[data-matrx-cell-content]]:overflow-hidden";
11991
12020
  var embeddedPageAskKey = (tableId, search, sorts, filter, pageDoorViewId) => JSON.stringify([tableId, search, sorts, filter, pageDoorViewId]);
@@ -12802,15 +12831,19 @@ function GridBody({
12802
12831
  const readBackRefusal = reread.ok ? void 0 : `The rows were written and this could not read them back to check: ${refusalSentence(reread.error)}`;
12803
12832
  if (readBackRefusal !== void 0) refusals.push(readBackRefusal);
12804
12833
  const seen = new Map((reread.ok ? reread.data : []).map((r) => [r.id, r.document ?? {}]));
12834
+ const unsent = new Set((reread.ok ? reread.data : []).filter((r) => r.waiting).map((r) => r.id));
12835
+ let waiting = 0;
12805
12836
  for (const entry of expected) {
12806
12837
  const stored = seen.get(entry.recordId);
12807
12838
  for (const [key, value] of Object.entries(entry.document)) {
12808
- if (stored !== void 0 && storedValueAgrees(fieldOf.get(key), stored[key], value, choiceOptions.current.get(key))) readBack += 1;
12809
- else missing += 1;
12839
+ if (stored !== void 0 && storedValueAgrees(fieldOf.get(key), stored[key], value, choiceOptions.current.get(key))) {
12840
+ if (unsent.has(entry.recordId)) waiting += 1;
12841
+ else readBack += 1;
12842
+ } else missing += 1;
12810
12843
  }
12811
12844
  }
12812
12845
  records.reload();
12813
- return keptWhileAway({ written: lines2, readBack, missing, refusals }, !reread.ok && isUnsentWrite(reread.error), readBackRefusal);
12846
+ return keptWhileAway({ written: lines2, readBack, missing, refusals, waiting }, !reread.ok && isUnsentWrite(reread.error), readBackRefusal);
12814
12847
  },
12815
12848
  [rows, client, tableId, editing, undo, records, versions, fields.data]
12816
12849
  );
@@ -12889,6 +12922,8 @@ function GridBody({
12889
12922
  let missing = 0;
12890
12923
  const fieldOf = new Map((fields.data ?? []).map((f) => [f.key, f]));
12891
12924
  const seen = /* @__PURE__ */ new Map();
12925
+ const unsent = /* @__PURE__ */ new Set();
12926
+ let waiting = 0;
12892
12927
  const READ_BACK_PAGE = 500;
12893
12928
  let readBackRefusal;
12894
12929
  let readBackUnsent = false;
@@ -12902,6 +12937,7 @@ function GridBody({
12902
12937
  }
12903
12938
  for (const row of reread.data.rows) {
12904
12939
  seen.set(row.id, row.document ?? {});
12940
+ if (row.waiting) unsent.add(row.id);
12905
12941
  }
12906
12942
  if (reread.data.rows.length + (reread.data.locked ?? 0) < READ_BACK_PAGE) break;
12907
12943
  if (expected.every((e) => seen.has(e.recordId))) break;
@@ -12910,14 +12946,15 @@ function GridBody({
12910
12946
  const stored = seen.get(entry.recordId);
12911
12947
  for (const [key, value] of Object.entries(entry.document)) {
12912
12948
  if (stored !== void 0 && storedValueAgrees(fieldOf.get(key), stored[key], value, choiceOptions.current.get(key))) {
12913
- readBack += 1;
12949
+ if (unsent.has(entry.recordId)) waiting += 1;
12950
+ else readBack += 1;
12914
12951
  } else {
12915
12952
  missing += 1;
12916
12953
  }
12917
12954
  }
12918
12955
  }
12919
12956
  records.reload();
12920
- return keptWhileAway({ written, readBack, missing, refusals }, readBackUnsent, readBackRefusal);
12957
+ return keptWhileAway({ written, readBack, missing, refusals, waiting }, readBackUnsent, readBackRefusal);
12921
12958
  }, [pastePlan, client, tableId, records, merged, applyPasteAsOne, versions, fields.data]);
12922
12959
  const columnIds = useMemo27(() => ordered.map((field) => field.key), [ordered]);
12923
12960
  const lookWrites = useRef19(null);
@@ -13325,7 +13362,7 @@ function GridBody({
13325
13362
  [mayManageActions]
13326
13363
  );
13327
13364
  const rowStrip = useCallback21(
13328
- (row, writable) => /* @__PURE__ */ jsxs39(Fragment16, { children: [
13365
+ (row, writable) => /* @__PURE__ */ jsxs39(Fragment17, { children: [
13329
13366
  canWrite && writable ? tableActions2.runnable.map((action2) => /* @__PURE__ */ jsx46(
13330
13367
  ActionButton,
13331
13368
  {
@@ -13712,7 +13749,7 @@ function GridBody({
13712
13749
  * — the table's own (clear, copy/export, group, columns), these, the search, the sort and
13713
13750
  * the page's filter, layout and share — in ONE "Tools" sheet. Never dropped.
13714
13751
  */
13715
- actions: /* @__PURE__ */ jsxs39(Fragment16, { children: [
13752
+ actions: /* @__PURE__ */ jsxs39(Fragment17, { children: [
13716
13753
  merged && !embedded && !manual ? /* @__PURE__ */ jsx46(
13717
13754
  SortPanel,
13718
13755
  {
@@ -13775,7 +13812,7 @@ function GridBody({
13775
13812
  ...merged ? {
13776
13813
  overflow: {
13777
13814
  mode: phone ? "sheet" : toolbarFold2 >= 3 ? "menu" : "inline",
13778
- pinned: /* @__PURE__ */ jsxs39(Fragment16, { children: [
13815
+ pinned: /* @__PURE__ */ jsxs39(Fragment17, { children: [
13779
13816
  embedded ? null : /* @__PURE__ */ jsx46(UndoRedoLive, { source: undoSource }),
13780
13817
  !embedded && !readOnly && rights.write ? /* @__PURE__ */ jsx46(
13781
13818
  NewFromTemplateMenu,
@@ -14105,7 +14142,7 @@ function GridBody({
14105
14142
  }
14106
14143
  ) }) : /* @__PURE__ */ jsx46("p", { className: "text-xs text-muted-foreground", children: records.liveReason })
14107
14144
  ) : null,
14108
- structureLocked ? /* @__PURE__ */ jsx46(StructureLocked, {}) : noColumnsYet ? /* @__PURE__ */ jsx46(NoColumnsYet, { mayChangeColumns: rights.structure, onAddField, whyNot: rights.why("structure") }) : /* @__PURE__ */ jsxs39(Fragment16, { children: [
14145
+ structureLocked ? /* @__PURE__ */ jsx46(StructureLocked, {}) : noColumnsYet ? /* @__PURE__ */ jsx46(NoColumnsYet, { mayChangeColumns: rights.structure, onAddField, whyNot: rights.why("structure") }) : /* @__PURE__ */ jsxs39(Fragment17, { children: [
14109
14146
  pastedSource ? /* @__PURE__ */ jsxs39("div", { className: "flex flex-col gap-2 rounded-md border p-3", "data-records-grid-paste-import": "", children: [
14110
14147
  /* @__PURE__ */ jsx46(
14111
14148
  ImportWizard,
@@ -14167,7 +14204,7 @@ function GridBody({
14167
14204
  onSelectedIdsChange: setSelectedIds,
14168
14205
  noun,
14169
14206
  isRowSelectable,
14170
- actions: (_selected, ids) => /* @__PURE__ */ jsxs39(Fragment16, { children: [
14207
+ actions: (_selected, ids) => /* @__PURE__ */ jsxs39(Fragment17, { children: [
14171
14208
  merged ? /* @__PURE__ */ jsx46(
14172
14209
  BulkActions,
14173
14210
  {
@@ -14460,7 +14497,7 @@ import { Button as Button50 } from "@ai-matrx/design-system";
14460
14497
  import { useFields as useFields16, useOptionalRecordsClient as useOptionalRecordsClient2, useTable as useTable20 } from "@ai-matrx/records/react";
14461
14498
 
14462
14499
  // src/RecordPanel.tsx
14463
- import { Fragment as Fragment23, useEffect as useEffect48, useRef as useRef25, useState as useState56 } from "react";
14500
+ import { Fragment as Fragment24, useEffect as useEffect48, useRef as useRef25, useState as useState56 } from "react";
14464
14501
  import { Button as Button49, Separator as Separator4 } from "@ai-matrx/design-system";
14465
14502
  import { useFields as useFields15, useRecord as useRecord4 } from "@ai-matrx/records/react";
14466
14503
 
@@ -14880,7 +14917,7 @@ function ValuePeriods({
14880
14917
  import { copyText as copyText3 } from "@ai-matrx/kit/clipboard";
14881
14918
  import { useEffect as useEffect37, useState as useState45 } from "react";
14882
14919
  import { Button as Button37, Popover as Popover8, PopoverContent as PopoverContent8, PopoverTrigger as PopoverTrigger8 } from "@ai-matrx/design-system";
14883
- import { Fragment as Fragment17, jsx as jsx51, jsxs as jsxs44 } from "react/jsx-runtime";
14920
+ import { Fragment as Fragment18, jsx as jsx51, jsxs as jsxs44 } from "react/jsx-runtime";
14884
14921
  function useCanShare() {
14885
14922
  return typeof useRecordsUi().share === "function";
14886
14923
  }
@@ -14908,7 +14945,7 @@ function ShareControl({
14908
14945
  const mayShare = may ?? asked2.share;
14909
14946
  if (!host.share) return null;
14910
14947
  if (!mayShare) return whyNot ? /* @__PURE__ */ jsx51(ShareForSomebodyElse, { kind: kind2, whyNot, size, variant, className }) : null;
14911
- return /* @__PURE__ */ jsxs44(Fragment17, { children: [
14948
+ return /* @__PURE__ */ jsxs44(Fragment18, { children: [
14912
14949
  /* @__PURE__ */ jsx51(
14913
14950
  Button37,
14914
14951
  {
@@ -15182,7 +15219,7 @@ function bodyFieldOf(fields) {
15182
15219
  }
15183
15220
 
15184
15221
  // src/RecordBody.tsx
15185
- import { Fragment as Fragment18, jsx as jsx53, jsxs as jsxs46 } from "react/jsx-runtime";
15222
+ import { Fragment as Fragment19, jsx as jsx53, jsxs as jsxs46 } from "react/jsx-runtime";
15186
15223
  var BODY_COLUMN_NAME = "Notes";
15187
15224
  var BODY_SAVE_PAUSE_MS = 900;
15188
15225
  function RecordBody({ tableId, recordId, className }) {
@@ -15248,7 +15285,7 @@ function BodyEditor({ tableId, recordId, field }) {
15248
15285
  };
15249
15286
  if (!record.data) return null;
15250
15287
  const readOnly = !may.write;
15251
- return /* @__PURE__ */ jsxs46(Fragment18, { children: [
15288
+ return /* @__PURE__ */ jsxs46(Fragment19, { children: [
15252
15289
  /* @__PURE__ */ jsx53("div", { className: "flex h-4 items-center justify-end text-[11px] text-muted-foreground", "data-record-body-state": saving.phase, children: saving.phase === "saving" ? "Saving\u2026" : saving.phase === "saved" ? "Saved" : null }),
15253
15290
  host.editRichText ? host.editRichText({ value: stored, onChange, readOnly, placeholder: `Write in ${field.label || BODY_COLUMN_NAME}\u2026` }) : stored.trim() !== "" ? /* @__PURE__ */ jsx53(SafeMarkdown, { text: stored }) : null,
15254
15291
  saving.phase === "refused" ? /* @__PURE__ */ jsx53(RefusalNotice, { error: saving.error }) : null
@@ -15282,7 +15319,7 @@ function AddBody({ tableId }) {
15282
15319
  // src/Peek.tsx
15283
15320
  import { humanizeIdentifier as humanizeIdentifier9 } from "@ai-matrx/kit/text-case";
15284
15321
  import { momentZoneOptions } from "@ai-matrx/design-system/field-formats";
15285
- import { Fragment as Fragment19, jsx as jsx54, jsxs as jsxs47 } from "react/jsx-runtime";
15322
+ import { Fragment as Fragment20, jsx as jsx54, jsxs as jsxs47 } from "react/jsx-runtime";
15286
15323
  function drawnBelowOnPage(field, bodyKey) {
15287
15324
  return field.key === bodyKey || editorKindFor(field) === "relation";
15288
15325
  }
@@ -15373,7 +15410,7 @@ function Peek2({ tableId, recordId, onClose, className, onPage = false }) {
15373
15410
  ] }),
15374
15411
  whyNotWrite ? /* @__PURE__ */ jsx54("p", { className: "mt-1 text-[11px] text-muted-foreground", children: whyNotWrite }) : null
15375
15412
  ] })
15376
- ) : /* @__PURE__ */ jsxs47(Fragment19, { children: [
15413
+ ) : /* @__PURE__ */ jsxs47(Fragment20, { children: [
15377
15414
  /* @__PURE__ */ jsx54("h3", { className: "break-words text-sm font-medium leading-snug", "data-records-peek-title": "", title, children: record.loading && !document2 ? /* @__PURE__ */ jsx54(Skeleton13, { className: "h-4 w-40" }) : title }),
15378
15415
  /* @__PURE__ */ jsxs47("div", { className: "flex min-h-7 flex-wrap items-center gap-1", "data-records-peek-actions": "", children: [
15379
15416
  alchemy,
@@ -15386,7 +15423,7 @@ function Peek2({ tableId, recordId, onClose, className, onPage = false }) {
15386
15423
  whyNotWrite ? /* @__PURE__ */ jsx54("p", { className: "text-[11px] text-muted-foreground", children: whyNotWrite }) : null
15387
15424
  ] }),
15388
15425
  /* @__PURE__ */ jsx54(Separator3, {}),
15389
- talking && host.chat ? /* @__PURE__ */ jsxs47(Fragment19, { children: [
15426
+ talking && host.chat ? /* @__PURE__ */ jsxs47(Fragment20, { children: [
15390
15427
  /* @__PURE__ */ jsx54("section", { "data-record-ask": onPage ? "open" : void 0, className: "min-w-0", children: /* @__PURE__ */ jsx54(RecordChat, { tableId, recordId, className: "min-h-[22rem]" }) }),
15391
15428
  /* @__PURE__ */ jsx54(Separator3, {})
15392
15429
  ] }) : null,
@@ -15402,7 +15439,7 @@ function Peek2({ tableId, recordId, onClose, className, onPage = false }) {
15402
15439
  whyNot: may.why("write") ?? void 0,
15403
15440
  reload: () => record.reload(),
15404
15441
  className: cn16("grid grid-cols-[minmax(6rem,12rem)_1fr] gap-x-3 gap-y-0.5", onPage && "text-sm"),
15405
- renderLabel: (field) => /* @__PURE__ */ jsxs47(Fragment19, { children: [
15442
+ renderLabel: (field) => /* @__PURE__ */ jsxs47(Fragment20, { children: [
15406
15443
  fieldName(field),
15407
15444
  /* @__PURE__ */ jsx54(ProvenanceBadge, { document: document2, fieldKey: field.key }),
15408
15445
  /* @__PURE__ */ jsx54(ValueAlternates, { recordId, field, document: document2, canWrite: may.write, onChosen: () => record.reload() }),
@@ -15436,11 +15473,11 @@ function Peek2({ tableId, recordId, onClose, className, onPage = false }) {
15436
15473
  }
15437
15474
  ),
15438
15475
  onPage ? null : /* @__PURE__ */ jsx54(ReverseLinksSections, { tableId, recordId }),
15439
- record.data?.computedUnavailable ? /* @__PURE__ */ jsxs47(Fragment19, { children: [
15476
+ record.data?.computedUnavailable ? /* @__PURE__ */ jsxs47(Fragment20, { children: [
15440
15477
  /* @__PURE__ */ jsx54(Separator3, {}),
15441
15478
  /* @__PURE__ */ jsx54("p", { className: "text-muted-foreground", children: "Calculated columns are not shown: that part of the record is not readable from your seat. Everything above is the record as it stands." })
15442
15479
  ] }) : null,
15443
- computedShown.length ? /* @__PURE__ */ jsxs47(Fragment19, { children: [
15480
+ computedShown.length ? /* @__PURE__ */ jsxs47(Fragment20, { children: [
15444
15481
  /* @__PURE__ */ jsx54(Separator3, {}),
15445
15482
  /* @__PURE__ */ jsxs47("div", { className: "flex flex-col gap-1", children: [
15446
15483
  /* @__PURE__ */ jsx54("span", { className: "font-medium", children: "Calculated columns" }),
@@ -15616,7 +15653,8 @@ var VERB_WORDS = {
15616
15653
  rename: "Renamed",
15617
15654
  delete: "Removed"
15618
15655
  };
15619
- function migrationWords(verb) {
15656
+ function migrationWords(verb, targetKind) {
15657
+ if (verb === "retype" && targetKind === "record") return "Moved to another table";
15620
15658
  return VERB_WORDS[verb] ?? humanizeIdentifier10(verb);
15621
15659
  }
15622
15660
  function useMigrationLog(recordId) {
@@ -15669,12 +15707,12 @@ function MigrationLog({ entries, readError, canUndo, whyNotUndo, onUndone, class
15669
15707
  return;
15670
15708
  }
15671
15709
  const removed = back.data.removed ? " The record it made is archived, so no copy is left behind." : "";
15672
- await onUndone(`${migrationWords(entry.verb)} undone.${removed}`);
15710
+ await onUndone(`${migrationWords(entry.verb, entry.target_kind)} undone.${removed}`);
15673
15711
  }
15674
15712
  return /* @__PURE__ */ jsxs49("section", { "aria-label": "Migration log", className: cn17("flex flex-col gap-1", className), "data-records-migration-log": "", children: [
15675
15713
  /* @__PURE__ */ jsx56("h4", { className: "text-xs font-medium", children: "Migration log" }),
15676
15714
  /* @__PURE__ */ jsx56("ul", { className: "flex flex-col divide-y rounded border text-xs", children: entries.map((entry) => /* @__PURE__ */ jsxs49("li", { "data-migration-id": entry.id, className: "flex items-center gap-2 px-2 py-1.5", children: [
15677
- /* @__PURE__ */ jsx56("span", { className: "shrink-0 font-medium", children: migrationWords(entry.verb) }),
15715
+ /* @__PURE__ */ jsx56("span", { className: "shrink-0 font-medium", children: migrationWords(entry.verb, entry.target_kind) }),
15678
15716
  /* @__PURE__ */ jsx56("span", { className: "min-w-0 flex-1 truncate text-muted-foreground", title: entry.note ? withoutInternalCodes(entry.note) : void 0, children: entry.note ? withoutInternalCodes(entry.note) : "" }),
15679
15717
  /* @__PURE__ */ jsx56("span", { className: "min-w-28 shrink-0 whitespace-nowrap text-right text-muted-foreground", title: new Date(entry.applied_at).toLocaleString(), children: whenText(entry.applied_at) }),
15680
15718
  entry.undone_at ? /* @__PURE__ */ jsx56("span", { className: "w-14 shrink-0 text-right text-muted-foreground", children: "Undone" }) : canUndo ? /* @__PURE__ */ jsx56(
@@ -15695,7 +15733,7 @@ function MigrationLog({ entries, readError, canUndo, whyNotUndo, onUndone, class
15695
15733
 
15696
15734
  // src/HistoryPanel.tsx
15697
15735
  import { momentZoneOptions as momentZoneOptions2 } from "@ai-matrx/design-system/field-formats";
15698
- import { Fragment as Fragment20, jsx as jsx57, jsxs as jsxs50 } from "react/jsx-runtime";
15736
+ import { Fragment as Fragment21, jsx as jsx57, jsxs as jsxs50 } from "react/jsx-runtime";
15699
15737
  function HistoryPanel({ tableId, recordId, onAskAboutField, className }) {
15700
15738
  usePeopleTick();
15701
15739
  const client = useRecordsClient43();
@@ -15858,6 +15896,7 @@ function HistoryPanel({ tableId, recordId, onAskAboutField, className }) {
15858
15896
  VersionRow,
15859
15897
  {
15860
15898
  entry,
15899
+ madeBy: entry.migration_id ? (shape.entries ?? []).find((m) => m.id === entry.migration_id) ?? null : null,
15861
15900
  byKey,
15862
15901
  expanded: open === entry.version,
15863
15902
  onToggle: () => setOpen(open === entry.version ? null : entry.version),
@@ -15891,6 +15930,7 @@ function HistoryPanel({ tableId, recordId, onAskAboutField, className }) {
15891
15930
  }
15892
15931
  function VersionRow({
15893
15932
  entry,
15933
+ madeBy,
15894
15934
  byKey,
15895
15935
  expanded,
15896
15936
  onToggle,
@@ -15942,7 +15982,7 @@ function VersionRow({
15942
15982
  children: [
15943
15983
  /* @__PURE__ */ jsxs50("span", { className: "flex min-w-0 items-baseline gap-1.5", children: [
15944
15984
  /* @__PURE__ */ jsx57(Who, { actor: entry.actor, changes: entry.changes }),
15945
- /* @__PURE__ */ jsx57("span", { className: "shrink-0 text-muted-foreground", children: verbWords(operationWords(entry.operation_label)) }),
15985
+ /* @__PURE__ */ jsx57("span", { className: "shrink-0 text-muted-foreground", children: verbWords(madeBy ? migrationWords(madeBy.verb, madeBy.target_kind) : operationWords(entry.operation_label)) }),
15946
15986
  entry.undoable ? /* @__PURE__ */ jsx57(Badge4, { variant: "secondary", className: "min-w-0 shrink truncate text-[10px]", title: "part of a bigger change", children: "part of a bigger change" }) : null,
15947
15987
  /* @__PURE__ */ jsxs50("span", { className: "ml-auto flex shrink-0 items-baseline gap-1.5 whitespace-nowrap text-muted-foreground", children: [
15948
15988
  /* @__PURE__ */ jsxs50("span", { className: "tabular-nums", children: [
@@ -16053,9 +16093,9 @@ function ChangeLine({
16053
16093
  return /* @__PURE__ */ jsxs50("li", { "data-change-key": change.key, className: "flex items-baseline gap-2 text-[11px]", children: [
16054
16094
  /* @__PURE__ */ jsx57("span", { className: "w-24 shrink-0 truncate font-medium", title: change.label, children: change.label || humanizeIdentifier11(change.key) }),
16055
16095
  /* @__PURE__ */ jsxs50("span", { className: "min-w-0 flex-1 truncate", children: [
16056
- /* @__PURE__ */ jsx57("span", { className: "text-muted-foreground line-through", children: say(change.before, field) }),
16096
+ /* @__PURE__ */ jsx57("span", { className: "text-muted-foreground line-through", children: change.before_words ?? say(change.before, field) }),
16057
16097
  /* @__PURE__ */ jsx57("span", { className: "mx-1 text-muted-foreground", children: "\u2192" }),
16058
- /* @__PURE__ */ jsx57("strong", { className: "font-medium", children: say(change.after, field) })
16098
+ /* @__PURE__ */ jsx57("strong", { className: "font-medium", children: change.after_words ?? say(change.after, field) })
16059
16099
  ] }),
16060
16100
  change.rule ? /* @__PURE__ */ jsxs50(Badge4, { variant: "outline", className: "shrink-0 text-[10px]", title: "Worked out by a rule", children: [
16061
16101
  "rule v",
@@ -16111,7 +16151,7 @@ function ConfirmUndo({
16111
16151
  "?"
16112
16152
  ] }) : /* @__PURE__ */ jsx57("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." }),
16113
16153
  /* @__PURE__ */ jsxs50("div", { className: "flex flex-wrap gap-1", children: [
16114
- conflicts.length ? /* @__PURE__ */ jsxs50(Fragment20, { children: [
16154
+ conflicts.length ? /* @__PURE__ */ jsxs50(Fragment21, { children: [
16115
16155
  clean.length ? /* @__PURE__ */ jsx57(Button43, { size: "sm", className: "h-6 px-2 text-[11px]", onClick: () => onConfirm(false), children: "Undo the rest, keep newer edits" }) : null,
16116
16156
  /* @__PURE__ */ jsx57(
16117
16157
  Button43,
@@ -16143,9 +16183,9 @@ function ConfirmRestore({
16143
16183
  /* @__PURE__ */ jsx57("ul", { className: "flex flex-col gap-0.5", children: preview.changes.map((change) => /* @__PURE__ */ jsxs50("li", { className: "text-[11px]", children: [
16144
16184
  /* @__PURE__ */ jsx57("span", { className: "font-medium", children: change.label }),
16145
16185
  " ",
16146
- /* @__PURE__ */ jsx57("span", { className: "text-muted-foreground", children: say(change.before, void 0) }),
16186
+ /* @__PURE__ */ jsx57("span", { className: "text-muted-foreground", children: change.before_words ?? say(change.before, void 0) }),
16147
16187
  /* @__PURE__ */ jsx57("span", { className: "mx-1 text-muted-foreground", children: "\u2192" }),
16148
- /* @__PURE__ */ jsx57("strong", { className: "font-medium", children: change.after === null || change.after === void 0 ? "cleared" : say(change.after, void 0) })
16188
+ /* @__PURE__ */ jsx57("strong", { className: "font-medium", children: change.after === null || change.after === void 0 ? "cleared" : change.after_words ?? say(change.after, void 0) })
16149
16189
  ] }, change.key)) }),
16150
16190
  /* @__PURE__ */ jsx57("p", { className: "text-[11px] text-muted-foreground", children: "It is saved as a new version. Nothing in the history is erased, and this can be put back too." }),
16151
16191
  /* @__PURE__ */ jsxs50("div", { className: "flex gap-1", children: [
@@ -16255,7 +16295,7 @@ function FormulaHistoryList({ recordId, fieldKey, label, onClose, className }) {
16255
16295
 
16256
16296
  // src/FieldHistoryPanel.tsx
16257
16297
  import { humanizeIdentifier as humanizeIdentifier12 } from "@ai-matrx/kit/text-case";
16258
- import { Fragment as Fragment21, jsx as jsx59, jsxs as jsxs52 } from "react/jsx-runtime";
16298
+ import { Fragment as Fragment22, jsx as jsx59, jsxs as jsxs52 } from "react/jsx-runtime";
16259
16299
  var COMPUTED_FIELD_TYPES = /* @__PURE__ */ new Set(["formula", "rollup", "lookup"]);
16260
16300
  function FieldHistoryPanel(props) {
16261
16301
  const fields = useFields13(props.tableId);
@@ -16377,7 +16417,7 @@ function FieldValueHistory({
16377
16417
  /* @__PURE__ */ jsx59("span", { className: "mx-1 text-muted-foreground", children: "\u2192" }),
16378
16418
  /* @__PURE__ */ jsx59("strong", { className: "font-medium", children: say(row.after, void 0) })
16379
16419
  ] }),
16380
- /* @__PURE__ */ jsx59("span", { className: "shrink-0 text-muted-foreground", children: row.actor.kind === "agent" ? /* @__PURE__ */ jsxs52(Fragment21, { children: [
16420
+ /* @__PURE__ */ jsx59("span", { className: "shrink-0 text-muted-foreground", children: row.actor.kind === "agent" ? /* @__PURE__ */ jsxs52(Fragment22, { children: [
16381
16421
  /* @__PURE__ */ jsx59(Badge6, { variant: "outline", className: "mr-1 text-[10px]", children: "agent" }),
16382
16422
  (() => {
16383
16423
  const said2 = agentWords(row.actor, []);
@@ -16443,7 +16483,7 @@ import { useRecordsClient as useRecordsClient46, useTable as useTable18 } from "
16443
16483
  import { Badge as Badge7, BasicInput as BasicInput6, BasicTextarea as BasicTextarea4, Button as Button46, Skeleton as Skeleton17, cn as cn21 } from "@ai-matrx/design-system";
16444
16484
  import { Select as Select3 } from "@ai-matrx/design-system/controls";
16445
16485
  import { humanizeIdentifier as humanizeIdentifier13 } from "@ai-matrx/kit/text-case";
16446
- import { Fragment as Fragment22, jsx as jsx60, jsxs as jsxs53 } from "react/jsx-runtime";
16486
+ import { Fragment as Fragment23, jsx as jsx60, jsxs as jsxs53 } from "react/jsx-runtime";
16447
16487
  var DUE_WORD = DUE_STATE_LABEL;
16448
16488
  var REQUIRES_WORD = CHECKLIST_REQUIREMENT_LABEL;
16449
16489
  var NO_TEMPLATES = "No checklists yet.";
@@ -16918,7 +16958,7 @@ function ChecklistsPanel({ tableId, onOpenRecord, className }) {
16918
16958
  /* @__PURE__ */ jsxs53("p", { className: "mt-1 text-xs", children: [
16919
16959
  /* @__PURE__ */ jsx60("span", { className: "font-medium", children: t.steps }),
16920
16960
  " steps",
16921
- t.roles > 0 ? /* @__PURE__ */ jsxs53(Fragment22, { children: [
16961
+ t.roles > 0 ? /* @__PURE__ */ jsxs53(Fragment23, { children: [
16922
16962
  " \xB7 ",
16923
16963
  /* @__PURE__ */ jsx60("span", { className: "font-medium", children: t.roles }),
16924
16964
  " roles"
@@ -16943,7 +16983,7 @@ function ChecklistsPanel({ tableId, onOpenRecord, className }) {
16943
16983
  }
16944
16984
  ) : null
16945
16985
  ] }, t.template_id)) }),
16946
- runs && runs.length > 0 ? /* @__PURE__ */ jsxs53(Fragment22, { children: [
16986
+ runs && runs.length > 0 ? /* @__PURE__ */ jsxs53(Fragment23, { children: [
16947
16987
  /* @__PURE__ */ jsx60("h4", { className: "text-xs font-medium text-muted-foreground", children: "Runs" }),
16948
16988
  /* @__PURE__ */ jsx60("ul", { className: "flex flex-col gap-1.5", "data-testid": "checklist-runs", children: runs.map((run) => /* @__PURE__ */ jsxs53("li", { className: "rounded border p-2 text-xs", children: [
16949
16989
  /* @__PURE__ */ jsxs53("div", { className: "flex items-center gap-2", children: [
@@ -17539,17 +17579,21 @@ function RecordFollow({ recordId, className }) {
17539
17579
  }
17540
17580
 
17541
17581
  // src/RecordPanel.tsx
17542
- import { Fragment as Fragment24, jsx as jsx63, jsxs as jsxs56 } from "react/jsx-runtime";
17582
+ import { Fragment as Fragment25, jsx as jsx63, jsxs as jsxs56 } from "react/jsx-runtime";
17543
17583
  function RecordPanel({ tableId, recordId, onClose, onAskAboutField, onPage = false, neighbors, onStep, expanded, onToggleExpand, full, onToggleFull }) {
17544
17584
  const host = useRecordsUi();
17545
17585
  const [asking, setAsking] = useState56(null);
17546
17586
  const record = useRecord4(recordId, true, { tableId });
17547
17587
  const answered = Boolean(record.data) && !record.error;
17548
17588
  const panelRef = useRef25(null);
17589
+ const opened = useRef25(false);
17549
17590
  useEffect48(() => {
17550
17591
  if (onPage) return;
17551
17592
  const panel = panelRef.current;
17593
+ const first = !opened.current;
17594
+ opened.current = true;
17552
17595
  if (!panel || panel.contains(document.activeElement)) return;
17596
+ if (!first && document.activeElement instanceof Element && document.activeElement.closest("[data-matrx-table-spreadsheet]")) return;
17553
17597
  panel.focus({ preventScroll: true });
17554
17598
  }, [recordId, onPage]);
17555
17599
  return /* @__PURE__ */ jsxs56(
@@ -17579,13 +17623,13 @@ function RecordPanel({ tableId, recordId, onClose, onAskAboutField, onPage = fal
17579
17623
  children: [
17580
17624
  neighbors && onStep ? /* @__PURE__ */ jsx63(RecordStepper, { neighbors, onStep: (to) => onStep(to), expanded, onToggleExpand, full, onToggleFull }) : null,
17581
17625
  /* @__PURE__ */ jsx63(Peek2, { tableId, recordId, onPage, ...onClose ? { onClose } : {} }),
17582
- answered ? /* @__PURE__ */ jsxs56(Fragment24, { children: [
17583
- onPage ? /* @__PURE__ */ jsxs56(Fragment24, { children: [
17626
+ answered ? /* @__PURE__ */ jsxs56(Fragment25, { children: [
17627
+ onPage ? /* @__PURE__ */ jsxs56(Fragment25, { children: [
17584
17628
  /* @__PURE__ */ jsx63(RecordBody, { tableId, recordId }),
17585
17629
  /* @__PURE__ */ jsx63(LinkedLists, { tableId, recordId }),
17586
17630
  /* @__PURE__ */ jsx63(ReverseLinksSections, { tableId, recordId })
17587
17631
  ] }) : null,
17588
- host.recordSections ? /* @__PURE__ */ jsxs56(Fragment23, { children: [
17632
+ host.recordSections ? /* @__PURE__ */ jsxs56(Fragment24, { children: [
17589
17633
  /* @__PURE__ */ jsx63(Separator4, {}),
17590
17634
  host.recordSections({ tableId, recordId })
17591
17635
  ] }) : null,
@@ -17681,12 +17725,12 @@ import {
17681
17725
  import { entityChartQuestion, entityTableQuery } from "@ai-matrx/records/first-page";
17682
17726
 
17683
17727
  // src/entityTable.tsx
17684
- import { Fragment as Fragment25, jsx as jsx64 } from "react/jsx-runtime";
17728
+ import { Fragment as Fragment26, jsx as jsx64 } from "react/jsx-runtime";
17685
17729
  function EntityDataScope({ children }) {
17686
17730
  const above = useOptionalEntityScope();
17687
17731
  const client = useRecordsClient49();
17688
17732
  const id = useId();
17689
- if (above) return /* @__PURE__ */ jsx64(Fragment25, { children });
17733
+ if (above) return /* @__PURE__ */ jsx64(Fragment26, { children });
17690
17734
  return /* @__PURE__ */ jsx64(EntityDataProvider, { dataSource: client.config.dataSource, activeOrganizationId: client.config.organizationId, portKey: `entity-data:${id}`, children });
17691
17735
  }
17692
17736
  var STORE_KEPT = /* @__PURE__ */ new Set(["deleted_at", "published_to_web", "published_to_web_at", "published_to_web_by"]);
@@ -17832,7 +17876,7 @@ function EntityGrid({
17832
17876
  }
17833
17877
 
17834
17878
  // src/RecordsTableCard.tsx
17835
- import { Fragment as Fragment26, jsx as jsx65, jsxs as jsxs57 } from "react/jsx-runtime";
17879
+ import { Fragment as Fragment27, jsx as jsx65, jsxs as jsxs57 } from "react/jsx-runtime";
17836
17880
  function RecordsTableCard(props) {
17837
17881
  const client = useOptionalRecordsClient2();
17838
17882
  if (!client) {
@@ -17874,14 +17918,14 @@ function EntityTableCardBody({
17874
17918
  ...edit ? { edit } : {},
17875
17919
  ...facts ? { facts } : {},
17876
17920
  ...entity.newer > 0 || headerActions ? {
17877
- headerActions: /* @__PURE__ */ jsxs57(Fragment26, { children: [
17921
+ headerActions: /* @__PURE__ */ jsxs57(Fragment27, { children: [
17878
17922
  entity.newer > 0 ? /* @__PURE__ */ jsx65(Button50, { size: "sm", variant: "ghost", onClick: entity.refresh, children: `${entity.newer.toLocaleString()} new` }) : null,
17879
17923
  headerActions
17880
17924
  ] })
17881
17925
  } : {},
17882
17926
  ...initialRows ? { initialRows } : {},
17883
17927
  ...className ? { className } : {},
17884
- children: entity.error ? /* @__PURE__ */ jsx65(MatrxTableCardEmpty, { message: `This table could not be read: ${entity.error}` }) : /* @__PURE__ */ jsxs57(Fragment26, { children: [
17928
+ children: entity.error ? /* @__PURE__ */ jsx65(MatrxTableCardEmpty, { message: `This table could not be read: ${entity.error}` }) : /* @__PURE__ */ jsxs57(Fragment27, { children: [
17885
17929
  /* @__PURE__ */ jsx65(EntityGrid, { entity, pageSize: batch, ...editable === void 0 ? {} : { editable } }),
17886
17930
  entity.hasMore ? /* @__PURE__ */ jsx65(
17887
17931
  MatrxTableCardShowMore2,
@@ -19001,7 +19045,7 @@ function useTableProposals(tableId, enabled) {
19001
19045
  import { useCallback as useCallback34, useEffect as useEffect56, useMemo as useMemo35, useState as useState66 } from "react";
19002
19046
  import { tableShapeChanged as tableShapeChanged9, useRecordsClient as useRecordsClient58 } from "@ai-matrx/records/react";
19003
19047
  import { Badge as Badge9, Button as Button56, Textarea as Textarea4, cn as cn27 } from "@ai-matrx/design-system";
19004
- import { Fragment as Fragment27, jsx as jsx73, jsxs as jsxs65 } from "react/jsx-runtime";
19048
+ import { Fragment as Fragment28, jsx as jsx73, jsxs as jsxs65 } from "react/jsx-runtime";
19005
19049
  var PERSON_KERNEL_TABLE = "11111111-0000-4000-8000-000000000005";
19006
19050
  var LEVEL_WORDS = { organization: "Organization", confidential: "Confidential" };
19007
19051
  function personColumns(fields) {
@@ -19094,7 +19138,7 @@ function TableAccessLevel({ tableId, fields }) {
19094
19138
  );
19095
19139
  }) })
19096
19140
  ] }) : null,
19097
- changed2 ? /* @__PURE__ */ jsxs65(Fragment27, { children: [
19141
+ changed2 ? /* @__PURE__ */ jsxs65(Fragment28, { children: [
19098
19142
  /* @__PURE__ */ jsx73(
19099
19143
  Textarea4,
19100
19144
  {
@@ -19457,7 +19501,7 @@ function ColumnsAtOnce({
19457
19501
  }
19458
19502
 
19459
19503
  // src/TableSettings.tsx
19460
- import { Fragment as Fragment28, jsx as jsx77, jsxs as jsxs69 } from "react/jsx-runtime";
19504
+ import { Fragment as Fragment29, jsx as jsx77, jsxs as jsxs69 } from "react/jsx-runtime";
19461
19505
  function TableSettings(props) {
19462
19506
  const ui = useRecordsUi();
19463
19507
  const client = useRecordsClient61();
@@ -19471,7 +19515,7 @@ function TableSettings(props) {
19471
19515
  [props.tableId, client, slots2]
19472
19516
  );
19473
19517
  const panel = /* @__PURE__ */ jsx77(SettingsAgentSlotsContext.Provider, { value: slots2, children: /* @__PURE__ */ jsx77(TableSettingsPanel, { ...props }) });
19474
- return ui.settingsAgent ? /* @__PURE__ */ jsx77(Fragment28, { children: ui.settingsAgent({ tableId: props.tableId, agent, children: panel }) }) : panel;
19518
+ return ui.settingsAgent ? /* @__PURE__ */ jsx77(Fragment29, { children: ui.settingsAgent({ tableId: props.tableId, agent, children: panel }) }) : panel;
19475
19519
  }
19476
19520
  function TableSettingsPanel({
19477
19521
  tableId,
@@ -19635,7 +19679,7 @@ function TableSettingsPanel({
19635
19679
  table.data ? /* @__PURE__ */ jsx77(TableAccessLevel, { tableId, fields: fields.data ?? [] }) : null,
19636
19680
  /* @__PURE__ */ jsx77(TableHistoryRetention, { tableId }),
19637
19681
  /* @__PURE__ */ jsx77(Separator6, {}),
19638
- levelHasShownTo2(table.data?.level) ? /* @__PURE__ */ jsxs69(Fragment28, { children: [
19682
+ levelHasShownTo2(table.data?.level) ? /* @__PURE__ */ jsxs69(Fragment29, { children: [
19639
19683
  /* @__PURE__ */ jsx77(NewRowsDefaults, { tableId }),
19640
19684
  /* @__PURE__ */ jsx77(Separator6, {})
19641
19685
  ] }) : null,
@@ -19695,7 +19739,7 @@ function TableSettingsPanel({
19695
19739
  /* @__PURE__ */ jsx77(Separator6, {}),
19696
19740
  /* @__PURE__ */ jsxs69("div", { className: "flex flex-col gap-1", children: [
19697
19741
  /* @__PURE__ */ jsx77("span", { className: "font-medium", children: "This table" }),
19698
- askingToDelete ? /* @__PURE__ */ jsxs69(Fragment28, { children: [
19742
+ askingToDelete ? /* @__PURE__ */ jsxs69(Fragment29, { children: [
19699
19743
  /* @__PURE__ */ jsx77("p", { className: "text-muted-foreground", "data-archive-confirm": "table", children: archiveConfirmSentence(table.data ? `the table \u201C${tableName(table.data)}\u201D` : "this table") }),
19700
19744
  /* @__PURE__ */ jsx77("p", { className: "text-muted-foreground", "data-archive-state": "", children: tableArchiveSentence({
19701
19745
  progress: archive.progress,
@@ -19705,10 +19749,10 @@ function TableSettingsPanel({
19705
19749
  slowedDown: archive.slowedDown,
19706
19750
  passesHere: archive.passes
19707
19751
  }) }),
19708
- /* @__PURE__ */ jsx77("div", { className: "flex gap-1", children: archive.running ? /* @__PURE__ */ jsxs69(Fragment28, { children: [
19752
+ /* @__PURE__ */ jsx77("div", { className: "flex gap-1", children: archive.running ? /* @__PURE__ */ jsxs69(Fragment29, { children: [
19709
19753
  /* @__PURE__ */ jsx77(Button60, { size: "sm", variant: "destructive", disabled: true, children: "Archiving\u2026" }),
19710
19754
  /* @__PURE__ */ jsx77(Button60, { size: "sm", variant: "ghost", onClick: () => archive.stop(), children: "Stop" })
19711
- ] }) : /* @__PURE__ */ jsxs69(Fragment28, { children: [
19755
+ ] }) : /* @__PURE__ */ jsxs69(Fragment29, { children: [
19712
19756
  /* @__PURE__ */ jsx77(Button60, { size: "sm", variant: "destructive", onClick: () => void startArchive(), children: archive.interrupted || archive.progress?.in_progress ? "Carry on archiving" : "Archive this table" }),
19713
19757
  /* @__PURE__ */ jsx77(Button60, { size: "sm", variant: "ghost", onClick: () => setAskingToDelete(false), children: "Keep it" })
19714
19758
  ] }) })
@@ -19916,7 +19960,7 @@ import { formatCount as formatCount7 } from "@ai-matrx/kit/format";
19916
19960
  import { useCallback as useCallback35, useEffect as useEffect62, useMemo as useMemo39, useRef as useRef29, useState as useState72 } from "react";
19917
19961
  import { useRecordsClient as useRecordsClient63 } from "@ai-matrx/records/react";
19918
19962
  import { Button as Button61 } from "@ai-matrx/design-system";
19919
- import { Fragment as Fragment29, jsx as jsx78, jsxs as jsxs70 } from "react/jsx-runtime";
19963
+ import { Fragment as Fragment30, jsx as jsx78, jsxs as jsxs70 } from "react/jsx-runtime";
19920
19964
  async function moveRecordValue(client, recordId, patch, expectedVersion) {
19921
19965
  const written = await (0, recordVersions_exports.updateRecordAt)(client, { record_id: recordId, patch, version: expectedVersion });
19922
19966
  return written.ok ? { ok: true, version: typeof written.data === "number" ? written.data : null } : { ok: false, error: written.error };
@@ -20070,7 +20114,7 @@ function useRecordMoves({
20070
20114
  versions.refresh([id]);
20071
20115
  onMoved?.();
20072
20116
  }, [versions, stale, onMoved]);
20073
- const notice = /* @__PURE__ */ jsxs70(Fragment29, { children: [
20117
+ const notice = /* @__PURE__ */ jsxs70(Fragment30, { children: [
20074
20118
  /* @__PURE__ */ jsx78(UndoNotice, { undo }),
20075
20119
  stale ? /* @__PURE__ */ jsxs70(
20076
20120
  "p",
@@ -20130,7 +20174,7 @@ import {
20130
20174
  } from "@ai-matrx/design-system/data-table";
20131
20175
 
20132
20176
  // src/CardDates.tsx
20133
- import { Fragment as Fragment30, jsx as jsx79, jsxs as jsxs71 } from "react/jsx-runtime";
20177
+ import { Fragment as Fragment31, jsx as jsx79, jsxs as jsxs71 } from "react/jsx-runtime";
20134
20178
  function cardDateFields(all, titleField, hiddenFields) {
20135
20179
  const hidden = new Set(hiddenFields ?? []);
20136
20180
  return all.filter(
@@ -20145,7 +20189,7 @@ function CardDates({ record, fields }) {
20145
20189
  return value !== null && value !== void 0 && value !== "";
20146
20190
  });
20147
20191
  if (held.length === 0) return null;
20148
- return /* @__PURE__ */ jsx79(Fragment30, { children: held.map((field) => /* @__PURE__ */ jsxs71(
20192
+ return /* @__PURE__ */ jsx79(Fragment31, { children: held.map((field) => /* @__PURE__ */ jsxs71(
20149
20193
  "span",
20150
20194
  {
20151
20195
  className: "mt-0.5 flex min-w-0 items-baseline gap-1 text-[11px] text-muted-foreground",
@@ -21090,7 +21134,7 @@ function lookupTargets(all) {
21090
21134
  }
21091
21135
 
21092
21136
  // src/CalendarView.tsx
21093
- import { Fragment as Fragment31, jsx as jsx82, jsxs as jsxs74 } from "react/jsx-runtime";
21137
+ import { Fragment as Fragment32, jsx as jsx82, jsxs as jsxs74 } from "react/jsx-runtime";
21094
21138
  var DRAG_TYPE = "application/x-records-card";
21095
21139
  var NONE = "__none__";
21096
21140
  var HOUR_PX = 44;
@@ -21593,7 +21637,7 @@ function CalendarView({
21593
21637
  ] })
21594
21638
  ] })
21595
21639
  ] });
21596
- const pickers = all.length > 0 ? /* @__PURE__ */ jsxs74(Fragment31, { children: [
21640
+ const pickers = all.length > 0 ? /* @__PURE__ */ jsxs74(Fragment32, { children: [
21597
21641
  otherDates.length > 0 || endUnusual ? picker("End", endField?.key ?? null, otherDates, (key) => {
21598
21642
  setEndPick(key);
21599
21643
  onEndFieldChange?.(key);
@@ -21605,7 +21649,7 @@ function CalendarView({
21605
21649
  ] }) : null;
21606
21650
  const toolbar = /* @__PURE__ */ jsxs74("div", { className: "flex flex-wrap items-center gap-2", children: [
21607
21651
  /* @__PURE__ */ jsx82(Button63, { size: "sm", variant: "outline", onClick: () => setAnchor(today), children: "Today" }),
21608
- mode !== "list" ? /* @__PURE__ */ jsxs74(Fragment31, { children: [
21652
+ mode !== "list" ? /* @__PURE__ */ jsxs74(Fragment32, { children: [
21609
21653
  /* @__PURE__ */ jsx82(Button63, { size: "sm", variant: "ghost", "aria-label": "Previous", onClick: () => step2(-1), children: "\u2039" }),
21610
21654
  /* @__PURE__ */ jsx82(Button63, { size: "sm", variant: "ghost", "aria-label": "Next", onClick: () => step2(1), children: "\u203A" }),
21611
21655
  /* @__PURE__ */ jsx82("h3", { className: "text-sm font-medium", "data-calendar-heading": "", children: heading })
@@ -21653,7 +21697,7 @@ function CalendarView({
21653
21697
  card: (p, key) => listCard(p, key),
21654
21698
  bar: (p, key) => /* @__PURE__ */ jsxs74("div", { ...dragSource(p.row), className: "relative h-full", children: [
21655
21699
  cardFace(p.row, null, "h-full"),
21656
- endField && canMove(p.row) ? /* @__PURE__ */ jsxs74(Fragment31, { children: [
21700
+ endField && canMove(p.row) ? /* @__PURE__ */ jsxs74(Fragment32, { children: [
21657
21701
  /* @__PURE__ */ jsx82("span", { role: "separator", "aria-label": "Drag to change the start", "data-calendar-edge": "start", className: "absolute inset-y-0 left-0 w-1.5 cursor-ew-resize", onPointerDown: beginStretch(p.row, p, "start") }),
21658
21702
  /* @__PURE__ */ jsx82("span", { role: "separator", "aria-label": "Drag to change the end", "data-calendar-edge": "end", className: "absolute inset-y-0 right-0 w-1.5 cursor-ew-resize", onPointerDown: beginStretch(p.row, p, "end") })
21659
21703
  ] }) : null
@@ -21690,7 +21734,7 @@ function CalendarView({
21690
21734
  today,
21691
21735
  timeDrop,
21692
21736
  onSlotPointerDown: creates ? beginSelect : void 0,
21693
- overlay: (d) => /* @__PURE__ */ jsxs74(Fragment31, { children: [
21737
+ overlay: (d) => /* @__PURE__ */ jsxs74(Fragment32, { children: [
21694
21738
  ghost && ghost.day === d && ghost.minute !== null ? /* @__PURE__ */ jsx82(
21695
21739
  "div",
21696
21740
  {
@@ -22106,7 +22150,7 @@ function taskListDay(day2, withYear) {
22106
22150
  }
22107
22151
 
22108
22152
  // src/TimelineView.tsx
22109
- import { Fragment as Fragment32, jsx as jsx83, jsxs as jsxs75 } from "react/jsx-runtime";
22153
+ import { Fragment as Fragment33, jsx as jsx83, jsxs as jsxs75 } from "react/jsx-runtime";
22110
22154
  var TIMELINE_ZOOMS = ["day", "week", "month", "quarter"];
22111
22155
  var ZOOM_LABEL = { day: "Day", week: "Week", month: "Month", quarter: "Quarter" };
22112
22156
  var PX_PER_DAY = { day: 96, week: 32, month: 10, quarter: 4 };
@@ -22810,7 +22854,7 @@ function TimelineView({
22810
22854
  startTime ? /* @__PURE__ */ jsx83("span", { className: "mr-1 tabular-nums text-[10px] opacity-75", "data-timeline-time": "", children: startTime }) : null,
22811
22855
  title
22812
22856
  ] })
22813
- ) : /* @__PURE__ */ jsxs75(Fragment32, { children: [
22857
+ ) : /* @__PURE__ */ jsxs75(Fragment33, { children: [
22814
22858
  startTime ? /* @__PURE__ */ jsx83("span", { className: "shrink-0 tabular-nums text-[10px] opacity-75", "data-timeline-time": "", children: startTime }) : null,
22815
22859
  /* @__PURE__ */ jsx83("span", { className: "min-w-0 truncate", children: title }),
22816
22860
  /* @__PURE__ */ jsx83(CardFieldsInline, { row: p.row, fields: cardFields })
@@ -22841,7 +22885,7 @@ function TimelineView({
22841
22885
  ] })
22842
22886
  ] })
22843
22887
  ] });
22844
- const settings = /* @__PURE__ */ jsxs75(Fragment32, { children: [
22888
+ const settings = /* @__PURE__ */ jsxs75(Fragment33, { children: [
22845
22889
  dates.length > 1 || !startField || !dates.some((f) => f.key === startChosen) ? picker("Start", startChosen, dates, (key) => setting({ startKey: key }), { none: false }) : null,
22846
22890
  endCandidates.length > 0 || endField && !endCandidates.includes(endField) ? picker("End", endChosen, endCandidates, (key) => setting({ endKey: key }), { kept: layoutKept }) : null,
22847
22891
  groupCandidates.length > 0 ? picker("Group by", groupChosen, groupCandidates, (key) => setting({ groupKey: key })) : null,
@@ -22860,7 +22904,7 @@ function TimelineView({
22860
22904
  /* @__PURE__ */ jsx83(DropdownMenuTrigger7, { asChild: true, children: /* @__PURE__ */ jsx83(Button64, { size: "sm", variant: "outline", className: ganttOn ? "bg-secondary" : void 0, title: "Gantt options", "data-timeline-gantt-menu": "", children: "Gantt" }) }),
22861
22905
  /* @__PURE__ */ jsxs75(DropdownMenuContent7, { align: "end", className: "min-w-48", children: [
22862
22906
  /* @__PURE__ */ jsx83(DropdownMenuCheckboxItem2, { checked: ganttOn, onCheckedChange: (on) => setGantt({ mode: on === true }), children: "Gantt view" }),
22863
- ganttOn ? /* @__PURE__ */ jsxs75(Fragment32, { children: [
22907
+ ganttOn ? /* @__PURE__ */ jsxs75(Fragment33, { children: [
22864
22908
  /* @__PURE__ */ jsx83(DropdownMenuSeparator3, {}),
22865
22909
  depField ? /* @__PURE__ */ jsx83(DropdownMenuCheckboxItem2, { checked: g.critical === true, onCheckedChange: (on) => setGantt({ critical: on === true }), children: "Critical path" }) : mayShape ? /* @__PURE__ */ jsx83(DropdownMenuItem6, { onSelect: () => void addDependencyField(), children: "Add dependencies" }) : null,
22866
22910
  mayShape || baseStartField && baseEndField ? /* @__PURE__ */ jsx83(DropdownMenuItem6, { disabled: ganttBusy, onSelect: () => void saveBaseline(), children: "Save baseline" }) : null,
@@ -23262,7 +23306,7 @@ function ViewNeeds({ layout, tableId, fields, onMade, className }) {
23262
23306
  // src/GalleryCover.tsx
23263
23307
  import { useEffect as useEffect68, useState as useState78 } from "react";
23264
23308
  import { useOptionalRecordsClient as useOptionalRecordsClient5 } from "@ai-matrx/records/react";
23265
- import { Fragment as Fragment33, jsx as jsx85 } from "react/jsx-runtime";
23309
+ import { Fragment as Fragment34, jsx as jsx85 } from "react/jsx-runtime";
23266
23310
  function isImageAddress(value) {
23267
23311
  return typeof value === "string" && /^(https?:\/\/|\/|data:image\/)/i.test(value.trim());
23268
23312
  }
@@ -23308,7 +23352,7 @@ function FileCover({ recordId }) {
23308
23352
  if (!host.fileImage) {
23309
23353
  return /* @__PURE__ */ jsx85("span", { className: "flex h-full w-full items-center justify-center p-1 text-center text-[10px] text-muted-foreground", children: COVER_NOT_DRAWN });
23310
23354
  }
23311
- return /* @__PURE__ */ jsx85(Fragment33, { children: host.fileImage({ fileId: read.fileId, alt: read.name }) });
23355
+ return /* @__PURE__ */ jsx85(Fragment34, { children: host.fileImage({ fileId: read.fileId, alt: read.name }) });
23312
23356
  }
23313
23357
 
23314
23358
  // src/board.ts
@@ -24329,7 +24373,7 @@ function ChartLegendContent({
24329
24373
  }
24330
24374
 
24331
24375
  // src/ChartBlock.tsx
24332
- import { Fragment as Fragment34, jsx as jsx90, jsxs as jsxs81 } from "react/jsx-runtime";
24376
+ import { Fragment as Fragment35, jsx as jsx90, jsxs as jsxs81 } from "react/jsx-runtime";
24333
24377
  var priorKey = (key) => `prior__${key}`;
24334
24378
  function Trend({ pct, aimingUp, className }) {
24335
24379
  if (pct === null || pct === void 0) return null;
@@ -24537,7 +24581,7 @@ function ChartBlock({ block, subject, tableName: tableName2, className, centerVa
24537
24581
  ] }),
24538
24582
  block.compare_refused ? /* @__PURE__ */ jsx90("p", { className: "px-1 text-xs text-muted-foreground", children: block.compare_refused }) : null,
24539
24583
  !block.refused && targetNote(target) ? /* @__PURE__ */ jsx90("p", { className: "px-1 text-xs text-muted-foreground", children: targetNote(target) }) : null,
24540
- block.refused ? /* @__PURE__ */ jsx90(RefusalNotice, { error: asRefusal2(block) }) : needs ? /* @__PURE__ */ jsx90("p", { className: "px-1 py-3 text-xs text-muted-foreground", children: needs }) : kind2 === "stuck" ? /* @__PURE__ */ jsx90(StuckList, { rows: block.rows ?? [] }) : points.length === 0 ? /* @__PURE__ */ jsx90("p", { className: "px-1 py-3 text-xs text-muted-foreground", children: "No groups came back, so there is nothing to draw yet." }) : /* @__PURE__ */ jsx90(Fragment34, { children: kind2 === "number" ? /* @__PURE__ */ jsx90(BigNumber, { points, measure: primary, onDrill: drill, block }) : kind2 === "table" ? /* @__PURE__ */ jsx90(GroupTable, { points, series, onDrill: drill }) : /* @__PURE__ */ jsxs81(Fragment34, { children: [
24584
+ block.refused ? /* @__PURE__ */ jsx90(RefusalNotice, { error: asRefusal2(block) }) : needs ? /* @__PURE__ */ jsx90("p", { className: "px-1 py-3 text-xs text-muted-foreground", children: needs }) : kind2 === "stuck" ? /* @__PURE__ */ jsx90(StuckList, { rows: block.rows ?? [] }) : points.length === 0 ? /* @__PURE__ */ jsx90("p", { className: "px-1 py-3 text-xs text-muted-foreground", children: "No groups came back, so there is nothing to draw yet." }) : /* @__PURE__ */ jsx90(Fragment35, { children: kind2 === "number" ? /* @__PURE__ */ jsx90(BigNumber, { points, measure: primary, onDrill: drill, block }) : kind2 === "table" ? /* @__PURE__ */ jsx90(GroupTable, { points, series, onDrill: drill }) : /* @__PURE__ */ jsxs81(Fragment35, { children: [
24541
24585
  /* @__PURE__ */ jsx90(
24542
24586
  Drawing,
24543
24587
  {
@@ -24572,7 +24616,7 @@ function BigNumber({
24572
24616
  const windows = block.compare ?? null;
24573
24617
  const target = block.target ?? null;
24574
24618
  const priorTotal = block.totals?.prior;
24575
- const body = /* @__PURE__ */ jsxs81(Fragment34, { children: [
24619
+ const body = /* @__PURE__ */ jsxs81(Fragment35, { children: [
24576
24620
  /* @__PURE__ */ jsxs81("span", { className: "flex items-baseline gap-2", children: [
24577
24621
  /* @__PURE__ */ jsx90("span", { className: "text-2xl font-semibold tabular-nums", children: total === null ? "\u2013" : pretty2(total) }),
24578
24622
  windows ? /* @__PURE__ */ jsx90(Trend, { pct: block.totals?.change_pct, aimingUp: !!target, className: "text-sm" }) : null
@@ -24617,7 +24661,7 @@ function Values({
24617
24661
  }) {
24618
24662
  const pretty2 = usePrettyWith(prettyPlain);
24619
24663
  return /* @__PURE__ */ jsx90("ul", { className: "flex flex-wrap gap-x-2 gap-y-0.5", children: points.map((point, at) => {
24620
- const text = /* @__PURE__ */ jsxs81(Fragment34, { children: [
24664
+ const text = /* @__PURE__ */ jsxs81(Fragment35, { children: [
24621
24665
  /* @__PURE__ */ jsx90(
24622
24666
  "span",
24623
24667
  {
@@ -24880,7 +24924,7 @@ function Drawing({
24880
24924
  showLegend ? /* @__PURE__ */ jsx90("ul", { className: "flex min-w-[8rem] max-w-md flex-1 basis-40 flex-col gap-0.5 overflow-y-auto overscroll-contain", style: { maxHeight: DONUT_LEGEND_MAX_PX }, "data-records-donut-legend": "", children: points.map((point, at) => {
24881
24925
  const value = point.values[series[0]] ?? 0;
24882
24926
  const share = total > 0 ? Math.round(value / total * 1e3) / 10 : 0;
24883
- const row = /* @__PURE__ */ jsxs81(Fragment34, { children: [
24927
+ const row = /* @__PURE__ */ jsxs81(Fragment35, { children: [
24884
24928
  /* @__PURE__ */ jsx90("span", { className: "h-2.5 w-2.5 shrink-0 rounded-[2px]", style: { background: String(config[point.label]?.color ?? SERIES_COLORS[at % SERIES_COLORS.length]) } }),
24885
24929
  /* @__PURE__ */ jsx90("span", { className: "min-w-0 flex-1 truncate", title: point.label, children: point.label }),
24886
24930
  /* @__PURE__ */ jsx90("span", { className: "tabular-nums", "data-records-donut-value": "", children: pretty2(value) }),
@@ -25022,10 +25066,10 @@ function Drawing({
25022
25066
  margin: { top: dataLabels && !horizontal ? 16 : 6, right: dataLabels && horizontal ? 40 : 6, bottom: 0, left: 0 },
25023
25067
  children: [
25024
25068
  /* @__PURE__ */ jsx90(CartesianGrid, { vertical: horizontal, horizontal: !horizontal }),
25025
- horizontal ? /* @__PURE__ */ jsxs81(Fragment34, { children: [
25069
+ horizontal ? /* @__PURE__ */ jsxs81(Fragment35, { children: [
25026
25070
  /* @__PURE__ */ jsx90(XAxis, { type: "number", ...axis }),
25027
25071
  /* @__PURE__ */ jsx90(YAxis, { type: "category", dataKey: "label", width: sideWidth, ...axis, tick: /* @__PURE__ */ jsx90(WrappedTick, { across: true, perLine: Math.max(4, Math.floor((sideWidth - 8) / TICK_CHAR_PX)), ...sideRows }) })
25028
- ] }) : /* @__PURE__ */ jsxs81(Fragment34, { children: [
25072
+ ] }) : /* @__PURE__ */ jsxs81(Fragment35, { children: [
25029
25073
  /* @__PURE__ */ jsx90(XAxis, { dataKey: "label", ...axis, interval: 0, height: 40, tick: /* @__PURE__ */ jsx90(WrappedTick, { ...planCategoryTicks((width - 56) / Math.max(points.length, 1)) }) }),
25030
25074
  /* @__PURE__ */ jsx90(YAxis, { width: 44, ...axis })
25031
25075
  ] }),
@@ -25158,7 +25202,7 @@ function onlyWholeNumbers(rows) {
25158
25202
  }
25159
25203
 
25160
25204
  // src/ChartLayout.tsx
25161
- import { Fragment as Fragment35, jsx as jsx91, jsxs as jsxs82 } from "react/jsx-runtime";
25205
+ import { Fragment as Fragment36, jsx as jsx91, jsxs as jsxs82 } from "react/jsx-runtime";
25162
25206
  var KIND_LABEL = { bar: "Bars", line: "Line", area: "Area", donut: "Donut", pie: "Pie", stacked: "Stacked bars", scatter: "Scatter" };
25163
25207
  var BASE_SHAPES = ["bar", "line", "donut"];
25164
25208
  var MEASURE_LABEL2 = { count: "Count", sum: "Sum", avg: "Average" };
@@ -25264,7 +25308,7 @@ function ChartLayout({ view, fields, filter, onChange, remembered }) {
25264
25308
  /* @__PURE__ */ jsx91(SelectTrigger6, { size: "sm", className: "h-7 w-auto min-w-[6rem] text-xs", "aria-label": "Chart measure", children: /* @__PURE__ */ jsx91(SelectValue6, {}) }),
25265
25309
  /* @__PURE__ */ jsx91(SelectContent6, { children: Object.keys(MEASURE_LABEL2).map((m) => /* @__PURE__ */ jsx91(SelectItem6, { value: m, children: MEASURE_LABEL2[m] }, m)) })
25266
25310
  ] }),
25267
- q.kind === "stacked" ? /* @__PURE__ */ jsxs82(Fragment35, { children: [
25311
+ q.kind === "stacked" ? /* @__PURE__ */ jsxs82(Fragment36, { children: [
25268
25312
  /* @__PURE__ */ jsx91("span", { className: "text-muted-foreground", children: "Stack by" }),
25269
25313
  /* @__PURE__ */ jsxs82(Select8, { value: view.columnField ?? "__none", onValueChange: (next) => onChange({ columnField: next === "__none" ? null : next }), children: [
25270
25314
  /* @__PURE__ */ jsx91(SelectTrigger6, { size: "sm", className: "h-7 w-auto min-w-[8rem] text-xs", "aria-label": "Chart stack by", children: /* @__PURE__ */ jsx91(SelectValue6, {}) }),
@@ -25274,7 +25318,7 @@ function ChartLayout({ view, fields, filter, onChange, remembered }) {
25274
25318
  ] })
25275
25319
  ] })
25276
25320
  ] }) : null,
25277
- q.kind === "scatter" ? /* @__PURE__ */ jsxs82(Fragment35, { children: [
25321
+ q.kind === "scatter" ? /* @__PURE__ */ jsxs82(Fragment36, { children: [
25278
25322
  /* @__PURE__ */ jsx91("span", { className: "text-muted-foreground", children: "Across" }),
25279
25323
  /* @__PURE__ */ jsxs82(Select8, { value: view.xField ?? "", onValueChange: (next) => onChange({ xField: next === "" ? null : next }), children: [
25280
25324
  /* @__PURE__ */ jsx91(SelectTrigger6, { size: "sm", className: "h-7 w-auto min-w-[8rem] text-xs", "aria-label": "Chart across field", children: /* @__PURE__ */ jsx91(SelectValue6, { placeholder: "A number field" }) }),
@@ -25309,7 +25353,7 @@ import { Select as Select9, SelectContent as SelectContent7, SelectItem as Selec
25309
25353
  import { Skeleton as Skeleton22 } from "@ai-matrx/design-system/skeleton";
25310
25354
  import { Tile as Tile2 } from "@ai-matrx/design-system/controls";
25311
25355
  import { formatCount as formatCount6 } from "@ai-matrx/kit/format";
25312
- import { Fragment as Fragment36, jsx as jsx92, jsxs as jsxs83 } from "react/jsx-runtime";
25356
+ import { Fragment as Fragment37, jsx as jsx92, jsxs as jsxs83 } from "react/jsx-runtime";
25313
25357
  var PIVOT_BOX = "min-h-[16rem]";
25314
25358
  function defaultPivotRows(fields) {
25315
25359
  return defaultChartGroup(fields) ?? fields.find((f) => !["attachment", "file", "formula", "button"].includes(String(f.type)))?.key ?? null;
@@ -25422,7 +25466,7 @@ function PivotLayout({ view, fields, filter, onChange, remembered }) {
25422
25466
  "Pivot rows",
25423
25467
  q.rowKey ?? "__none",
25424
25468
  (next) => onChange({ groupField: next === "__none" ? null : next }),
25425
- /* @__PURE__ */ jsxs83(Fragment36, { children: [
25469
+ /* @__PURE__ */ jsxs83(Fragment37, { children: [
25426
25470
  /* @__PURE__ */ jsx92(SelectItem7, { value: "__none", children: "Everything together" }),
25427
25471
  groupable.map((f) => /* @__PURE__ */ jsx92(SelectItem7, { value: f.key, children: fieldName(f) }, f.key))
25428
25472
  ] })
@@ -25432,7 +25476,7 @@ function PivotLayout({ view, fields, filter, onChange, remembered }) {
25432
25476
  "Pivot columns",
25433
25477
  q.colKey ?? "__none",
25434
25478
  (next) => onChange({ columnField: next === "__none" ? null : next }),
25435
- /* @__PURE__ */ jsxs83(Fragment36, { children: [
25479
+ /* @__PURE__ */ jsxs83(Fragment37, { children: [
25436
25480
  /* @__PURE__ */ jsx92(SelectItem7, { value: "__none", children: "No columns" }),
25437
25481
  groupable.filter((f) => f.key !== q.rowKey).map((f) => /* @__PURE__ */ jsx92(SelectItem7, { value: f.key, children: fieldName(f) }, f.key))
25438
25482
  ] })
@@ -25445,7 +25489,7 @@ function PivotLayout({ view, fields, filter, onChange, remembered }) {
25445
25489
  PIVOT_OPS.map((o) => /* @__PURE__ */ jsx92(SelectItem7, { value: o, children: PIVOT_OP_LABEL[o] }, o)),
25446
25490
  "6rem"
25447
25491
  ),
25448
- op !== "count" ? /* @__PURE__ */ jsxs83(Fragment36, { children: [
25492
+ op !== "count" ? /* @__PURE__ */ jsxs83(Fragment37, { children: [
25449
25493
  /* @__PURE__ */ jsx92("span", { className: "text-muted-foreground", children: "of" }),
25450
25494
  select(
25451
25495
  "Pivot measured field",
@@ -25460,7 +25504,7 @@ function PivotLayout({ view, fields, filter, onChange, remembered }) {
25460
25504
  PIVOT_OP_LABEL[op],
25461
25505
  " needs a number field \u2014 pick one above. Counting until then."
25462
25506
  ] }) : null,
25463
- state.error ? /* @__PURE__ */ jsx92(RefusalNotice, { error: state.error }) : !table ? /* @__PURE__ */ jsx92(Skeleton22, { className: cn37("w-full rounded-md", PIVOT_BOX), "data-records-pivot-loading": "" }) : /* @__PURE__ */ jsxs83(Fragment36, { children: [
25507
+ state.error ? /* @__PURE__ */ jsx92(RefusalNotice, { error: state.error }) : !table ? /* @__PURE__ */ jsx92(Skeleton22, { className: cn37("w-full rounded-md", PIVOT_BOX), "data-records-pivot-loading": "" }) : /* @__PURE__ */ jsxs83(Fragment37, { children: [
25464
25508
  /* @__PURE__ */ jsx92("div", { className: cn37("relative max-w-full overflow-auto rounded border", PIVOT_BOX), "data-records-pivot-scroll": "", children: /* @__PURE__ */ jsxs83("table", { className: "w-max min-w-full border-collapse text-xs tabular-nums", "data-records-pivot": "", children: [
25465
25509
  /* @__PURE__ */ jsx92("thead", { children: /* @__PURE__ */ jsxs83("tr", { className: "bg-muted/50", children: [
25466
25510
  /* @__PURE__ */ jsx92("th", { scope: "col", className: "sticky left-0 top-0 z-20 min-w-[7rem] max-w-[14rem] bg-muted px-2 py-1 text-left font-medium text-muted-foreground", children: measureName }),
@@ -25629,7 +25673,7 @@ function fitTransform(w, h, bw, bh, pad2 = 16) {
25629
25673
  }
25630
25674
 
25631
25675
  // src/OrgChartLayout.tsx
25632
- import { Fragment as Fragment37, jsx as jsx93, jsxs as jsxs84 } from "react/jsx-runtime";
25676
+ import { Fragment as Fragment38, jsx as jsx93, jsxs as jsxs84 } from "react/jsx-runtime";
25633
25677
  function selfLinkFields(fields, tableId) {
25634
25678
  return fields.filter((f) => f.type === "relation" && f.relation_target === tableId);
25635
25679
  }
@@ -25806,7 +25850,7 @@ function OrgChartLayout({ view, fields, rows, titleKey, openRecordId, onOpenReco
25806
25850
  layout: "stack",
25807
25851
  variant: "outline",
25808
25852
  wrapTitle: true,
25809
- title: /* @__PURE__ */ jsxs84(Fragment37, { children: [
25853
+ title: /* @__PURE__ */ jsxs84(Fragment38, { children: [
25810
25854
  /* @__PURE__ */ jsx93("span", { className: "truncate text-sm font-medium", children: rowName(node.row, titleField?.key ?? titleKey) }),
25811
25855
  lines.map((field) => {
25812
25856
  const value = (node.row.document ?? {})[field.key];
@@ -26148,7 +26192,7 @@ function placedSentence(total, placed, lookingUp, notFound, unplaceable) {
26148
26192
  }
26149
26193
 
26150
26194
  // src/MapLayout.tsx
26151
- import { Fragment as Fragment38, jsx as jsx95, jsxs as jsxs86 } from "react/jsx-runtime";
26195
+ import { Fragment as Fragment39, jsx as jsx95, jsxs as jsxs86 } from "react/jsx-runtime";
26152
26196
  var NO_PLACE_TEXT = "No map is installed in this app, so the places are listed.";
26153
26197
  var ADDRESS_HINT = /address|location|place|street|city|site|where/i;
26154
26198
  function defaultMapField(fields) {
@@ -26239,7 +26283,7 @@ function MapLayout({ view, fields, rows, titleKey, openRecordId, onOpenRecord, o
26239
26283
  /* @__PURE__ */ jsx95(SelectTrigger10, { size: "sm", className: "h-7 w-auto min-w-[8rem] text-xs", "aria-label": "Map location field", children: /* @__PURE__ */ jsx95(SelectValue10, { placeholder: "Choose a field" }) }),
26240
26284
  /* @__PURE__ */ jsx95(SelectContent10, { children: choices.map((f) => /* @__PURE__ */ jsx95(SelectItem10, { value: f.key, children: fieldName(f) }, f.key)) })
26241
26285
  ] }),
26242
- coordinateMode ? /* @__PURE__ */ jsxs86(Fragment38, { children: [
26286
+ coordinateMode ? /* @__PURE__ */ jsxs86(Fragment39, { children: [
26243
26287
  /* @__PURE__ */ jsx95("span", { className: "text-muted-foreground", children: "Longitude" }),
26244
26288
  /* @__PURE__ */ jsxs86(Select12, { value: lngKey ?? "", onValueChange: (next) => onChange({ mapLngField: next === "" ? null : next }), children: [
26245
26289
  /* @__PURE__ */ jsx95(SelectTrigger10, { size: "sm", className: "h-7 w-auto min-w-[8rem] text-xs", "aria-label": "Map longitude field", children: /* @__PURE__ */ jsx95(SelectValue10, { placeholder: "Choose a field" }) }),
@@ -26260,7 +26304,7 @@ function MapLayout({ view, fields, rows, titleKey, openRecordId, onOpenRecord, o
26260
26304
  picker,
26261
26305
  /* @__PURE__ */ jsxs86("div", { className: "flex flex-wrap items-center gap-x-3 text-xs text-muted-foreground", "aria-live": "polite", "data-records-map-status": "", children: [
26262
26306
  /* @__PURE__ */ jsx95("span", { children: sentence2 }),
26263
- lookup.couldNot ? /* @__PURE__ */ jsxs86(Fragment38, { children: [
26307
+ lookup.couldNot ? /* @__PURE__ */ jsxs86(Fragment39, { children: [
26264
26308
  /* @__PURE__ */ jsx95("span", { children: "Could not look up addresses just now." }),
26265
26309
  /* @__PURE__ */ jsx95(
26266
26310
  Button68,
@@ -26298,7 +26342,7 @@ function MapLayout({ view, fields, rows, titleKey, openRecordId, onOpenRecord, o
26298
26342
  }
26299
26343
 
26300
26344
  // src/ViewSwitcher.tsx
26301
- import { Fragment as Fragment39, jsx as jsx96, jsxs as jsxs87 } from "react/jsx-runtime";
26345
+ import { Fragment as Fragment40, jsx as jsx96, jsxs as jsxs87 } from "react/jsx-runtime";
26302
26346
  var NO_FIELDS2 = [];
26303
26347
  function useViewRecords(view, pageSize = 200, filter, viewId) {
26304
26348
  const client = useRecordsClient68();
@@ -26791,7 +26835,7 @@ function Board({
26791
26835
  note: records.membership,
26792
26836
  style,
26793
26837
  parentField: subItemsField(all, view.subject),
26794
- below: /* @__PURE__ */ jsxs87(Fragment39, { children: [
26838
+ below: /* @__PURE__ */ jsxs87(Fragment40, { children: [
26795
26839
  pager,
26796
26840
  /* @__PURE__ */ jsx96(
26797
26841
  CardFieldsPicker,
@@ -27363,7 +27407,7 @@ function MaybeRecordActionMenu({
27363
27407
  children,
27364
27408
  ...rest
27365
27409
  }) {
27366
- if (!tableId) return /* @__PURE__ */ jsx96(Fragment39, { children });
27410
+ if (!tableId) return /* @__PURE__ */ jsx96(Fragment40, { children });
27367
27411
  return /* @__PURE__ */ jsx96(RecordActionMenu, { tableId, ...rest, children });
27368
27412
  }
27369
27413
  function GallerySizeControl({
@@ -27531,7 +27575,7 @@ function RecordCard({
27531
27575
  color ? ROW_TINT_CLASS3[color] : void 0
27532
27576
  ),
27533
27577
  contentClassName: cn40("truncate px-2 py-1", host.density === "spacious" ? "py-2" : ""),
27534
- children: dates && dates.length > 0 || fields && fields.length > 0 || parentName ? /* @__PURE__ */ jsxs87(Fragment39, { children: [
27578
+ children: dates && dates.length > 0 || fields && fields.length > 0 || parentName ? /* @__PURE__ */ jsxs87(Fragment40, { children: [
27535
27579
  /* @__PURE__ */ jsx96("span", { className: "block truncate", children: label }),
27536
27580
  parentName ? /* @__PURE__ */ jsx96("span", { className: "block truncate text-muted-foreground", "data-records-card-parent": parentId ?? "", children: `Sub-item of ${parentName}` }) : null,
27537
27581
  dates && dates.length > 0 ? /* @__PURE__ */ jsx96(CardDates, { record, fields: dates }) : null,
@@ -27983,7 +28027,7 @@ function settingsToCopy(source, target) {
27983
28027
  }
27984
28028
 
27985
28029
  // src/ViewBar.tsx
27986
- import { Fragment as Fragment40, jsx as jsx99, jsxs as jsxs90 } from "react/jsx-runtime";
28030
+ import { Fragment as Fragment41, jsx as jsx99, jsxs as jsxs90 } from "react/jsx-runtime";
27987
28031
  var SAVED_VIEWS_UNAVAILABLE = "Saved views are not available in this organization right now, so the layout you pick here is not being kept. Everything else on this table works as usual.";
27988
28032
  var VIEW_CHIP_BOX = "h-8 w-32 shrink-0";
27989
28033
  function seedIsSatisfied(seed, views) {
@@ -28103,6 +28147,8 @@ function ViewBar({ tableId, activeViewId, onActiveView, seed, settings, onViews,
28103
28147
  if (!claimSeed(spec.name)) continue;
28104
28148
  const written = await declareView(client, { ...spec, subject: tableId });
28105
28149
  if (!written.ok) {
28150
+ const now = await readViews();
28151
+ if (now.ok && seedIsSatisfied(spec, now.data)) continue;
28106
28152
  setError(written.error);
28107
28153
  onViews?.(null);
28108
28154
  return;
@@ -28352,7 +28398,7 @@ function ViewBar({ tableId, activeViewId, onActiveView, seed, settings, onViews,
28352
28398
  ]
28353
28399
  }
28354
28400
  ),
28355
- rights.admin ? /* @__PURE__ */ jsxs90(Fragment40, { children: [
28401
+ rights.admin ? /* @__PURE__ */ jsxs90(Fragment41, { children: [
28356
28402
  /* @__PURE__ */ jsx99(ControlButton3, { variant: "quiet", className: "shrink-0 normal-case", "data-view-section-rename": "", onClick: () => setRenamingSection({ from: group.name, draft: group.name }), children: "Rename" }),
28357
28403
  /* @__PURE__ */ jsx99(ControlButton3, { variant: "danger", className: "shrink-0 normal-case", "data-view-section-delete": "", title: "The views stay; they leave the section", onClick: () => void renameSection(group.name, null), children: "Delete" })
28358
28404
  ] }) : null
@@ -28370,7 +28416,7 @@ function ViewBar({ tableId, activeViewId, onActiveView, seed, settings, onViews,
28370
28416
  setOpen(false);
28371
28417
  },
28372
28418
  title: /* @__PURE__ */ jsx99("span", { title: view.ruleId ? "Membership is this view's Rule" : "The whole table", children: view.name }),
28373
- end: /* @__PURE__ */ jsxs90(Fragment40, { children: [
28419
+ end: /* @__PURE__ */ jsxs90(Fragment41, { children: [
28374
28420
  view.presentation?.locked === true ? /* @__PURE__ */ jsx99(Badge12, { variant: "neutral", className: "shrink-0 px-1.5 py-0 text-[10px]", "data-view-locked": "", title: VIEW_LOCKED_REASON, children: "Locked" }) : null,
28375
28421
  view.personal ? /* @__PURE__ */ jsx99(Badge12, { variant: "neutral", className: "shrink-0 px-1.5 py-0 text-[10px]", "data-view-personal": "", title: "Only you see this view", children: "Personal" }) : null,
28376
28422
  view.isDefault ? /* @__PURE__ */ jsx99(Badge12, { variant: "neutral", className: "shrink-0 px-1.5 py-0 text-[10px]", "data-view-default": "", children: "Default" }) : null
@@ -28485,7 +28531,7 @@ function ViewBar({ tableId, activeViewId, onActiveView, seed, settings, onViews,
28485
28531
  ...(views ?? []).length > 1 ? { copySettings: () => setCopying(true) } : {}
28486
28532
  }, current.presentation?.locked === true, current.personal === true);
28487
28533
  const reasons = viewActionReasons(actions);
28488
- return /* @__PURE__ */ jsxs90(Fragment40, { children: [
28534
+ return /* @__PURE__ */ jsxs90(Fragment41, { children: [
28489
28535
  reasons.map((reason) => /* @__PURE__ */ jsx99("p", { className: "truncate px-2 py-1 text-xs text-muted-foreground", "data-view-actions-reason": "", title: reason, children: reason }, reason)),
28490
28536
  actions.map((action2) => /* @__PURE__ */ jsx99(
28491
28537
  Tile4,
@@ -28622,7 +28668,7 @@ import { Badge as Badge14, Button as Button74, Checkbox as Checkbox6, Skeleton a
28622
28668
  import { toggleSelection as toggleSelection2 } from "@ai-matrx/design-system/data-table";
28623
28669
  import { formatAbsoluteDate, formatDurationMs } from "@ai-matrx/kit/format";
28624
28670
  import { momentZoneOptions as momentZoneOptions3 } from "@ai-matrx/design-system/field-formats";
28625
- import { Fragment as Fragment41, jsx as jsx101, jsxs as jsxs92 } from "react/jsx-runtime";
28671
+ import { Fragment as Fragment42, jsx as jsx101, jsxs as jsxs92 } from "react/jsx-runtime";
28626
28672
  var ACTION_KINDS = ["approval", "assignment", "proposal"];
28627
28673
  var KIND_WORD = WORK_INBOX_KIND_LABEL;
28628
28674
  var DUE_WORD2 = DUE_STATE_LABEL;
@@ -29254,7 +29300,7 @@ function ActionInbox({
29254
29300
  /* @__PURE__ */ jsxs92("div", { className: "flex flex-col gap-0.5", "data-testid": "inbox-closed", children: [
29255
29301
  /* @__PURE__ */ jsxs92("p", { className: "text-[11px] text-muted-foreground", children: [
29256
29302
  item.state === "withdrawn" ? item.decided_by_name ? `Withdrawn when ${item.decided_by_name} archived it` : "Withdrawn when what it would change was archived" : `${WORK_APPROVAL_STATE_LABEL[item.state] ?? item.state}${item.decided_by_name ? ` by ${item.decided_by_name}` : ""}`,
29257
- item.decided_at ? /* @__PURE__ */ jsxs92(Fragment41, { children: [
29303
+ item.decided_at ? /* @__PURE__ */ jsxs92(Fragment42, { children: [
29258
29304
  " \xB7 ",
29259
29305
  /* @__PURE__ */ jsx101("time", { dateTime: item.decided_at, children: whenWords2(item.decided_at) })
29260
29306
  ] }) : null
@@ -29444,7 +29490,7 @@ function ActionInbox({
29444
29490
  onSteps,
29445
29491
  actions: (stepId) => {
29446
29492
  const title = items?.find((i) => i.item_id === stepId)?.title ?? "this step";
29447
- return /* @__PURE__ */ jsxs92(Fragment41, { children: [
29493
+ return /* @__PURE__ */ jsxs92(Fragment42, { children: [
29448
29494
  snoozing === stepId ? snoozeChoices().map((c) => /* @__PURE__ */ jsx101(
29449
29495
  Button74,
29450
29496
  {
@@ -29601,7 +29647,7 @@ import { useCallback as useCallback43, useEffect as useEffect84, useMemo as useM
29601
29647
  import { useRecordsClient as useRecordsClient74, useTables } from "@ai-matrx/records/react";
29602
29648
  import { BasicInput as BasicInput11, Button as Button76, Checkbox as Checkbox7, Label as Label10, Separator as Separator7, Skeleton as Skeleton28, cn as cn46 } from "@ai-matrx/design-system";
29603
29649
  import { Select as Select14 } from "@ai-matrx/design-system/controls";
29604
- import { Fragment as Fragment42, jsx as jsx103, jsxs as jsxs94 } from "react/jsx-runtime";
29650
+ import { Fragment as Fragment43, jsx as jsx103, jsxs as jsxs94 } from "react/jsx-runtime";
29605
29651
  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.";
29606
29652
  function PortalBuilder({ tableId, portalId, onSaved, onClose, className }) {
29607
29653
  const client = useRecordsClient74();
@@ -29836,7 +29882,7 @@ function PortalBuilder({ tableId, portalId, onSaved, onClose, className }) {
29836
29882
  ),
29837
29883
  /* @__PURE__ */ jsx103("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." })
29838
29884
  ] }),
29839
- clientTableId ? /* @__PURE__ */ jsxs94(Fragment42, { children: [
29885
+ clientTableId ? /* @__PURE__ */ jsxs94(Fragment43, { children: [
29840
29886
  /* @__PURE__ */ jsx103(Separator7, {}),
29841
29887
  /* @__PURE__ */ jsxs94("div", { className: "flex flex-col gap-2", children: [
29842
29888
  /* @__PURE__ */ jsx103(Label10, { className: "text-xs font-medium", children: "What they can see" }),
@@ -29943,7 +29989,7 @@ function PortalBuilder({ tableId, portalId, onSaved, onClose, className }) {
29943
29989
  " yet."
29944
29990
  ] }) : null
29945
29991
  ] }) : null,
29946
- savedId ? /* @__PURE__ */ jsxs94(Fragment42, { children: [
29992
+ savedId ? /* @__PURE__ */ jsxs94(Fragment43, { children: [
29947
29993
  /* @__PURE__ */ jsx103(Separator7, {}),
29948
29994
  /* @__PURE__ */ jsxs94("div", { className: "flex flex-col gap-2", children: [
29949
29995
  /* @__PURE__ */ jsx103(Label10, { className: "text-xs font-medium", children: "Invite a client" }),
@@ -30316,7 +30362,7 @@ function PortalLookEditor({ card, onSaved, className }) {
30316
30362
  }
30317
30363
 
30318
30364
  // src/PortalsPanel.tsx
30319
- import { Fragment as Fragment43, jsx as jsx106, jsxs as jsxs97 } from "react/jsx-runtime";
30365
+ import { Fragment as Fragment44, jsx as jsx106, jsxs as jsxs97 } from "react/jsx-runtime";
30320
30366
  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.";
30321
30367
  function revokeConsequence(person, portalTitle) {
30322
30368
  const who = person.client ? `${person.email} (${person.client})` : person.email;
@@ -30426,7 +30472,7 @@ function PortalsPanel({ tableId, activePortalId, className }) {
30426
30472
  buildLabel: elsewhere > 0 ? "Build a new portal" : "Build the portal",
30427
30473
  children: [
30428
30474
  "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.",
30429
- elsewhere > 0 ? /* @__PURE__ */ jsxs97(Fragment43, { children: [
30475
+ elsewhere > 0 ? /* @__PURE__ */ jsxs97(Fragment44, { children: [
30430
30476
  " ",
30431
30477
  "This table is not in",
30432
30478
  " ",
@@ -30554,7 +30600,7 @@ function ArchivePortalControl({
30554
30600
  if (said) {
30555
30601
  return /* @__PURE__ */ jsx106("span", { className: "text-xs text-muted-foreground", "data-testid": "portal-archived-said", children: said });
30556
30602
  }
30557
- return /* @__PURE__ */ jsxs97(Fragment43, { children: [
30603
+ return /* @__PURE__ */ jsxs97(Fragment44, { children: [
30558
30604
  /* @__PURE__ */ jsx106(
30559
30605
  Button78,
30560
30606
  {
@@ -30602,7 +30648,7 @@ function ArchivePortalControl({
30602
30648
  function CopyLink({ url, what }) {
30603
30649
  const [copied, setCopied] = useState96(false);
30604
30650
  const [shown4, setShown] = useState96(false);
30605
- return /* @__PURE__ */ jsxs97(Fragment43, { children: [
30651
+ return /* @__PURE__ */ jsxs97(Fragment44, { children: [
30606
30652
  /* @__PURE__ */ jsx106(
30607
30653
  Button78,
30608
30654
  {
@@ -30745,13 +30791,13 @@ function PortalCardView({
30745
30791
  ] })
30746
30792
  ] }, exposed.table_id))
30747
30793
  ] }),
30748
- look ? /* @__PURE__ */ jsxs97(Fragment43, { children: [
30794
+ look ? /* @__PURE__ */ jsxs97(Fragment44, { children: [
30749
30795
  /* @__PURE__ */ jsx106(Separator8, {}),
30750
30796
  look
30751
30797
  ] }) : null,
30752
30798
  /* @__PURE__ */ jsx106(Separator8, {}),
30753
30799
  /* @__PURE__ */ jsx106(People, { card, onRevoke, onPreview, origin }),
30754
- invite ? /* @__PURE__ */ jsxs97(Fragment43, { children: [
30800
+ invite ? /* @__PURE__ */ jsxs97(Fragment44, { children: [
30755
30801
  /* @__PURE__ */ jsx106(Separator8, {}),
30756
30802
  invite
30757
30803
  ] }) : null
@@ -30950,7 +30996,7 @@ function Invite({ card, onInvited }) {
30950
30996
  /* @__PURE__ */ jsx106("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." }),
30951
30997
  error ? /* @__PURE__ */ jsx106(RefusalNotice, { error }) : null,
30952
30998
  said ? /* @__PURE__ */ jsx106("p", { className: "text-xs text-muted-foreground", children: said }) : null,
30953
- rows === null ? /* @__PURE__ */ jsx106(Skeleton29, { className: "h-9 w-full" }) : /* @__PURE__ */ jsxs97(Fragment43, { children: [
30999
+ rows === null ? /* @__PURE__ */ jsx106(Skeleton29, { className: "h-9 w-full" }) : /* @__PURE__ */ jsxs97(Fragment44, { children: [
30954
31000
  /* @__PURE__ */ jsx106(
30955
31001
  BasicInput13,
30956
31002
  {
@@ -31139,7 +31185,7 @@ function scheduleWords(schedule, tz) {
31139
31185
  }
31140
31186
 
31141
31187
  // src/DigestScheduler.tsx
31142
- import { Fragment as Fragment44, jsx as jsx108, jsxs as jsxs99 } from "react/jsx-runtime";
31188
+ import { Fragment as Fragment45, jsx as jsx108, jsxs as jsxs99 } from "react/jsx-runtime";
31143
31189
  var WEEKDAYS = ["monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday"];
31144
31190
  var CADENCE_WORDS = {
31145
31191
  instant: "the moment something arrives",
@@ -31396,7 +31442,7 @@ function DigestScheduler({
31396
31442
  ] }),
31397
31443
  /* @__PURE__ */ jsxs99("div", { className: "flex flex-col gap-1.5", children: [
31398
31444
  /* @__PURE__ */ jsx108(Label11, { className: "text-xs font-medium", children: "Who to send it to" }),
31399
- members === null ? /* @__PURE__ */ jsx108(Skeleton30, { className: "h-8 w-full" }) : members.length === 0 ? /* @__PURE__ */ jsx108("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__ */ jsxs99(Fragment44, { children: [
31445
+ members === null ? /* @__PURE__ */ jsx108(Skeleton30, { className: "h-8 w-full" }) : members.length === 0 ? /* @__PURE__ */ jsx108("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__ */ jsxs99(Fragment45, { children: [
31400
31446
  /* @__PURE__ */ jsx108("div", { className: "flex flex-wrap gap-x-4 gap-y-1.5", children: members.map((m) => /* @__PURE__ */ jsxs99("label", { className: "flex items-center gap-1.5 text-xs", children: [
31401
31447
  /* @__PURE__ */ jsx108(
31402
31448
  Checkbox8,
@@ -31438,7 +31484,7 @@ function DigestScheduler({
31438
31484
  ),
31439
31485
  /* @__PURE__ */ jsx108("span", { className: "text-xs text-muted-foreground", children: "A send inside these hours waits until they end \u2014 it is never dropped." })
31440
31486
  ] }) : null,
31441
- outcomes ? /* @__PURE__ */ jsxs99(Fragment44, { children: [
31487
+ outcomes ? /* @__PURE__ */ jsxs99(Fragment45, { children: [
31442
31488
  /* @__PURE__ */ jsx108(Separator9, {}),
31443
31489
  /* @__PURE__ */ jsx108("div", { className: "flex flex-col gap-1.5", children: outcomes.map((o) => /* @__PURE__ */ jsx108("div", { className: "text-xs", children: o.ruleId ? /* @__PURE__ */ jsxs99("span", { children: [
31444
31490
  o.who,
@@ -31956,7 +32002,7 @@ import {
31956
32002
  FORM_EMBEDS,
31957
32003
  formEmbedSnippet
31958
32004
  } from "@ai-matrx/records/forms";
31959
- import { Fragment as Fragment45, jsx as jsx111, jsxs as jsxs102 } from "react/jsx-runtime";
32005
+ import { Fragment as Fragment46, jsx as jsx111, jsxs as jsxs102 } from "react/jsx-runtime";
31960
32006
  function freshEndingId(taken) {
31961
32007
  if (!taken.includes("ending")) return "ending";
31962
32008
  let n = 2;
@@ -32005,7 +32051,7 @@ function EndingsEditor({
32005
32051
  /* @__PURE__ */ jsx111(BasicTextarea6, { className: "col-span-2", rows: 2, "aria-label": "Ending message", placeholder: "Message", value: e.body ?? "", onChange: (ev) => patch(i, { body: ev.target.value || null }) }),
32006
32052
  /* @__PURE__ */ jsx111(BasicInput16, { type: "url", "aria-label": "Ending page", placeholder: "Then go to (optional) https://", value: e.redirectUrl ?? "", onChange: (ev) => patch(i, { redirectUrl: ev.target.value || null }) }),
32007
32053
  /* @__PURE__ */ jsx111(BasicInput16, { "aria-label": "Ending button", placeholder: "Continue", value: e.buttonLabel ?? "", onChange: (ev) => patch(i, { buttonLabel: ev.target.value || null }) }),
32008
- scored ? /* @__PURE__ */ jsxs102(Fragment45, { children: [
32054
+ scored ? /* @__PURE__ */ jsxs102(Fragment46, { children: [
32009
32055
  /* @__PURE__ */ jsx111(BasicInput16, { inputMode: "decimal", "aria-label": "Lowest score", placeholder: "From score", value: e.scoreMin ?? "", onChange: (ev) => patch(i, { scoreMin: numberOrNull(ev.target.value) }) }),
32010
32056
  /* @__PURE__ */ jsx111(BasicInput16, { inputMode: "decimal", "aria-label": "Highest score", placeholder: "To score", value: e.scoreMax ?? "", onChange: (ev) => patch(i, { scoreMax: numberOrNull(ev.target.value) }) })
32011
32057
  ] }) : null,
@@ -32201,7 +32247,7 @@ import { useFields as useFields24, useOptionalRecordsClient as useOptionalRecord
32201
32247
  import { Button as Button83, Label as Label14, Progress, Skeleton as Skeleton33, cn as cn54, formThemeClasses } from "@ai-matrx/design-system";
32202
32248
  import { answerRefusal, formRoutes, FORM_RUNNER_WORDS_EN, pipeAnswers, submissionStamp } from "@ai-matrx/records/forms";
32203
32249
  import { humanizeIdentifier as humanizeIdentifier16 } from "@ai-matrx/kit/text-case";
32204
- import { Fragment as Fragment46, jsx as jsx112, jsxs as jsxs103 } from "react/jsx-runtime";
32250
+ import { Fragment as Fragment47, jsx as jsx112, jsxs as jsxs103 } from "react/jsx-runtime";
32205
32251
  function authored(host, text, where) {
32206
32252
  return host.renderText ? host.renderText(text, where) : text;
32207
32253
  }
@@ -32801,7 +32847,7 @@ function ThankYou({
32801
32847
  ),
32802
32848
  ending?.pictureUrl ? /* @__PURE__ */ jsx112("img", { src: ending.pictureUrl, alt: "", className: "mb-3 max-h-48 w-full rounded-md object-cover" }) : null,
32803
32849
  /* @__PURE__ */ jsx112("h2", { className: "text-2xl font-semibold", "data-records-form-ending": ending?.id ?? "", children: title || words2.thankYou }),
32804
- body ? /* @__PURE__ */ jsxs103(Fragment46, { children: [
32850
+ body ? /* @__PURE__ */ jsxs103(Fragment47, { children: [
32805
32851
  done === "preview" ? /* @__PURE__ */ jsx112("p", { className: "mt-2 text-xs uppercase tracking-wide text-muted-foreground", children: "After a real send, people read:" }) : null,
32806
32852
  /* @__PURE__ */ jsx112("p", { className: "mt-2 text-base text-muted-foreground", children: authored(host, body, "form-thank-you") })
32807
32853
  ] }) : null,
@@ -32857,7 +32903,7 @@ function Question({
32857
32903
  field.unit ? /* @__PURE__ */ jsx112("span", { className: "text-sm text-foreground/70", children: field.unit }) : null
32858
32904
  ] }),
32859
32905
  question.help ? /* @__PURE__ */ jsx112("p", { className: cn54("text-muted-foreground", large ? "text-base" : "text-sm"), children: authored(host, question.help, "form-help") }) : null,
32860
- isAttachment && !upload ? /* @__PURE__ */ jsx112("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__ */ jsxs103(Fragment46, { children: [
32906
+ isAttachment && !upload ? /* @__PURE__ */ jsx112("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__ */ jsxs103(Fragment47, { children: [
32861
32907
  /* @__PURE__ */ jsx112(
32862
32908
  "input",
32863
32909
  {
@@ -33165,7 +33211,7 @@ import {
33165
33211
  } from "@ai-matrx/records/forms";
33166
33212
  import { OutboundLink } from "@ai-matrx/kit/outbound-react";
33167
33213
  import { momentZoneOptions as momentZoneOptions4 } from "@ai-matrx/design-system/field-formats";
33168
- import { Fragment as Fragment47, jsx as jsx114, jsxs as jsxs105 } from "react/jsx-runtime";
33214
+ import { Fragment as Fragment48, jsx as jsx114, jsxs as jsxs105 } from "react/jsx-runtime";
33169
33215
  function freshFormName(base, taken) {
33170
33216
  const names = new Set(taken.map((n) => n.trim().toLowerCase()));
33171
33217
  if (!names.has(base.toLowerCase())) return base;
@@ -33554,7 +33600,7 @@ function FormBuilder({ tableId, seed, activeFormId, onActiveForm, startWithOne,
33554
33600
  }
33555
33601
  )
33556
33602
  ] }) : null,
33557
- !draft ? /* @__PURE__ */ jsx114("p", { className: "text-xs text-muted-foreground", children: (fields.data ?? []).length === 0 ? "No fields yet" : "No form yet" }) : /* @__PURE__ */ jsxs105(Fragment47, { children: [
33603
+ !draft ? /* @__PURE__ */ jsx114("p", { className: "text-xs text-muted-foreground", children: (fields.data ?? []).length === 0 ? "No fields yet" : "No form yet" }) : /* @__PURE__ */ jsxs105(Fragment48, { children: [
33558
33604
  /* @__PURE__ */ jsx114(
33559
33605
  PublishRow,
33560
33606
  {
@@ -33836,7 +33882,7 @@ function PublishRow({
33836
33882
  children: busy ? "\u2026" : open ? "Unpublish" : unsaved ? "Save and publish" : "Publish"
33837
33883
  }
33838
33884
  ) : null,
33839
- state !== "draft" ? /* @__PURE__ */ jsxs105(Fragment47, { children: [
33885
+ state !== "draft" ? /* @__PURE__ */ jsxs105(Fragment48, { children: [
33840
33886
  /* @__PURE__ */ jsx114(
33841
33887
  OutboundLink,
33842
33888
  {
@@ -34202,7 +34248,7 @@ function NotifyOnAnswer({
34202
34248
  import { useCallback as useCallback50, useEffect as useEffect93, useRef as useRef44, useState as useState104 } from "react";
34203
34249
  import { useRecordsClient as useRecordsClient82 } from "@ai-matrx/records/react";
34204
34250
  import { Button as Button86, Skeleton as Skeleton35, cn as cn56 } from "@ai-matrx/design-system";
34205
- import { jsx as jsx115, jsxs as jsxs106 } from "react/jsx-runtime";
34251
+ import { Fragment as Fragment49, jsx as jsx115, jsxs as jsxs106 } from "react/jsx-runtime";
34206
34252
  function DocRender({ templateId, recordId, filename, onRendered, className }) {
34207
34253
  const client = useRecordsClient82();
34208
34254
  const [preview, setPreview] = useState104(null);
@@ -34210,6 +34256,8 @@ function DocRender({ templateId, recordId, filename, onRendered, className }) {
34210
34256
  const [showing, setShowing] = useState104(null);
34211
34257
  const [error, setError] = useState104(null);
34212
34258
  const [busy, setBusy] = useState104(null);
34259
+ const [askingToRemove, setAskingToRemove] = useState104(false);
34260
+ const [removed, setRemoved] = useState104(null);
34213
34261
  const paper = useRef44(null);
34214
34262
  const load = useCallback50(async () => {
34215
34263
  const [body, held] = await Promise.all([
@@ -34247,6 +34295,31 @@ function DocRender({ templateId, recordId, filename, onRendered, className }) {
34247
34295
  if (row) onRendered?.(row);
34248
34296
  }
34249
34297
  }
34298
+ async function remove(renderId) {
34299
+ setAskingToRemove(false);
34300
+ setBusy("remove");
34301
+ const gone = await client.docRenderDelete({ render_id: renderId });
34302
+ setBusy(null);
34303
+ if (!gone.ok) {
34304
+ setError(gone.error);
34305
+ return;
34306
+ }
34307
+ setShowing(null);
34308
+ setRemoved(renderId);
34309
+ await load();
34310
+ }
34311
+ async function undoRemove(renderId) {
34312
+ setBusy("remove");
34313
+ const back = await client.docRenderRestore({ render_id: renderId });
34314
+ setBusy(null);
34315
+ if (!back.ok) {
34316
+ setError(back.error);
34317
+ return;
34318
+ }
34319
+ setRemoved(null);
34320
+ await load();
34321
+ setShowing(renderId);
34322
+ }
34250
34323
  async function toPdf() {
34251
34324
  const element = paper.current;
34252
34325
  if (!element) return;
@@ -34305,6 +34378,14 @@ function DocRender({ templateId, recordId, filename, onRendered, className }) {
34305
34378
  render.id
34306
34379
  )),
34307
34380
  /* @__PURE__ */ jsxs106("span", { className: "ml-auto flex items-center gap-1", children: [
34381
+ frozen && askingToRemove ? /* @__PURE__ */ jsxs106(Fragment49, { children: [
34382
+ /* @__PURE__ */ jsx115("span", { className: "text-destructive", children: "This removes the saved version." }),
34383
+ /* @__PURE__ */ jsx115(Button86, { size: "sm", variant: "destructive", "data-doc-render-remove-confirm": "", disabled: busy !== null, onClick: () => void remove(frozen.id), children: "Remove it" }),
34384
+ /* @__PURE__ */ jsx115(Button86, { size: "sm", variant: "ghost", onClick: () => setAskingToRemove(false), children: "Keep it" })
34385
+ ] }) : frozen ? /* @__PURE__ */ jsx115(Button86, { size: "sm", variant: "ghost", "data-doc-render-remove": "", disabled: busy !== null, onClick: () => setAskingToRemove(true), children: "Remove" }) : removed ? /* @__PURE__ */ jsxs106(Fragment49, { children: [
34386
+ /* @__PURE__ */ jsx115("span", { className: "text-muted-foreground", children: "Removed." }),
34387
+ /* @__PURE__ */ jsx115(Button86, { size: "sm", variant: "ghost", "data-doc-render-undo": "", disabled: busy !== null, onClick: () => void undoRemove(removed), children: "Undo" })
34388
+ ] }) : null,
34308
34389
  /* @__PURE__ */ jsx115(Button86, { size: "sm", disabled: busy !== null, onClick: () => void freeze(), children: busy === "freeze" ? "Freezing\u2026" : "Freeze this version" }),
34309
34390
  /* @__PURE__ */ jsx115(Button86, { size: "sm", variant: "ghost", disabled: busy !== null, onClick: () => void toPdf(), children: busy === "pdf" ? "Making the PDF\u2026" : "PDF" })
34310
34391
  ] })
@@ -35317,7 +35398,7 @@ function pageById(pages, id) {
35317
35398
  }
35318
35399
 
35319
35400
  // src/DashboardCanvas.tsx
35320
- import { Fragment as Fragment48, jsx as jsx120, jsxs as jsxs111 } from "react/jsx-runtime";
35401
+ import { Fragment as Fragment50, jsx as jsx120, jsxs as jsxs111 } from "react/jsx-runtime";
35321
35402
  function DashboardCanvas({ tableId, activeDashboardId, filter, createOnMount, onCreated, className }) {
35322
35403
  const client = useRecordsClient86();
35323
35404
  const host = useRecordsUi();
@@ -35580,7 +35661,7 @@ function DashboardCanvas({ tableId, activeDashboardId, filter, createOnMount, on
35580
35661
  children: scheduling ? "Done" : "Send on a schedule"
35581
35662
  }
35582
35663
  ),
35583
- rights.admin && askingToRemove === board.id ? /* @__PURE__ */ jsxs111(Fragment48, { children: [
35664
+ rights.admin && askingToRemove === board.id ? /* @__PURE__ */ jsxs111(Fragment50, { children: [
35584
35665
  /* @__PURE__ */ jsx120("span", { className: "text-xs text-destructive", children: archiveConfirmSentence(`the dashboard \u201C${board.name}\u201D`) }),
35585
35666
  /* @__PURE__ */ jsx120(Button90, { size: "sm", variant: "destructive", onClick: () => void remove(board), children: "Remove it" }),
35586
35667
  /* @__PURE__ */ jsx120(Button90, { size: "sm", variant: "ghost", onClick: () => setAskingToRemove(null), children: "Keep it" })
@@ -35628,7 +35709,7 @@ function DashboardCanvas({ tableId, activeDashboardId, filter, createOnMount, on
35628
35709
  /* @__PURE__ */ jsx120(Button90, { size: "sm", disabled: !host.onReask || asking || question.trim() === "", onClick: () => void reask(), children: asking ? "Asking" : "Ask" })
35629
35710
  ] }) }) : null,
35630
35711
  notKept ? /* @__PURE__ */ jsx120("p", { role: "status", "data-records-dashboard-not-kept": "", className: "text-xs text-amber-700 dark:text-amber-400", children: notKept }) : null,
35631
- !board ? /* @__PURE__ */ jsx120("p", { className: "text-xs text-muted-foreground", children: rights.admin ? "No dashboards yet." : rights.why("structure") }) : run === null ? /* @__PURE__ */ jsx120(Skeleton38, { className: "h-64 w-full" }) : run.blocks.length === 0 ? /* @__PURE__ */ jsx120("p", { className: "text-xs text-muted-foreground", children: "No charts yet." }) : /* @__PURE__ */ jsxs111(Fragment48, { children: [
35712
+ !board ? /* @__PURE__ */ jsx120("p", { className: "text-xs text-muted-foreground", children: rights.admin ? "No dashboards yet." : rights.why("structure") }) : run === null ? /* @__PURE__ */ jsx120(Skeleton38, { className: "h-64 w-full" }) : run.blocks.length === 0 ? /* @__PURE__ */ jsx120("p", { className: "text-xs text-muted-foreground", children: "No charts yet." }) : /* @__PURE__ */ jsxs111(Fragment50, { children: [
35632
35713
  /* @__PURE__ */ jsx120(
35633
35714
  BlockGrid,
35634
35715
  {
@@ -35641,7 +35722,7 @@ function DashboardCanvas({ tableId, activeDashboardId, filter, createOnMount, on
35641
35722
  id: board.blocks[index]?.id ?? block.id ?? `block-${index}`,
35642
35723
  title: block.title,
35643
35724
  span: board.blocks[index]?.span ?? block.span,
35644
- body: /* @__PURE__ */ jsxs111(Fragment48, { children: [
35725
+ body: /* @__PURE__ */ jsxs111(Fragment50, { children: [
35645
35726
  spansTables ? /* @__PURE__ */ jsx120(ChartOfTable, { block, subject: tableId, table: board.blocks[index]?.subject ?? block.table_id ?? tableId }) : /* @__PURE__ */ jsx120(ChartBlock, { block, subject: tableId }),
35646
35727
  rights.admin && board.blocks[index] ? /* @__PURE__ */ jsx120(
35647
35728
  BlockSettingsMenu,
@@ -35747,7 +35828,7 @@ function GroupingPicker({
35747
35828
  return /* @__PURE__ */ jsx120("span", { className: "text-muted-foreground", children: "No columns to group by." });
35748
35829
  }
35749
35830
  const known = choices.some((c) => c.field.key === current);
35750
- return /* @__PURE__ */ jsxs111(Fragment48, { children: [
35831
+ return /* @__PURE__ */ jsxs111(Fragment50, { children: [
35751
35832
  /* @__PURE__ */ jsx120("label", { className: "text-muted-foreground", htmlFor: `block-group-${block.title}`, children: "Group by" }),
35752
35833
  /* @__PURE__ */ jsxs111(Select20, { value: known ? current : "", onValueChange: onPick, children: [
35753
35834
  /* @__PURE__ */ jsx120(
@@ -35844,7 +35925,7 @@ function CompareControl({
35844
35925
  // that has one does not lose it by being shown.
35845
35926
  (k) => k !== "range" || current === "range"
35846
35927
  );
35847
- return /* @__PURE__ */ jsxs111(Fragment48, { children: [
35928
+ return /* @__PURE__ */ jsxs111(Fragment50, { children: [
35848
35929
  /* @__PURE__ */ jsxs111(
35849
35930
  Select20,
35850
35931
  {
@@ -35906,7 +35987,7 @@ function TargetControl({
35906
35987
  if (draft.trim() === "" || !Number.isFinite(n) || n === savedValue) return;
35907
35988
  onChange({ value: n, label: label && saved === "value" ? label : "Target", ...per ? { per } : {} });
35908
35989
  }
35909
- return /* @__PURE__ */ jsxs111(Fragment48, { children: [
35990
+ return /* @__PURE__ */ jsxs111(Fragment50, { children: [
35910
35991
  /* @__PURE__ */ jsxs111(
35911
35992
  Select20,
35912
35993
  {
@@ -35971,7 +36052,7 @@ __reExport(question_exports, questions_star);
35971
36052
  import * as questions_star from "@ai-matrx/records/questions";
35972
36053
 
35973
36054
  // src/QuestionPanel.tsx
35974
- import { Fragment as Fragment49, jsx as jsx121, jsxs as jsxs112 } from "react/jsx-runtime";
36055
+ import { Fragment as Fragment51, jsx as jsx121, jsxs as jsxs112 } from "react/jsx-runtime";
35975
36056
  var OP_LABEL = { count: "Count", sum: "Sum", avg: "Average", min: "Smallest", max: "Largest" };
35976
36057
  var BUCKETS = [
35977
36058
  { value: "", label: "Exact date" },
@@ -36222,7 +36303,7 @@ function QuestionPanel({ tableId, activeQuestionId, draft, className }) {
36222
36303
  }
36223
36304
  ) : /* @__PURE__ */ jsx121("span", { className: "text-muted-foreground", children: "Now" })
36224
36305
  ] }),
36225
- spec.group ? /* @__PURE__ */ jsxs112(Fragment49, { children: [
36306
+ spec.group ? /* @__PURE__ */ jsxs112(Fragment51, { children: [
36226
36307
  /* @__PURE__ */ jsx121(Label17, { className: "pt-1.5 text-xs text-muted-foreground", children: "Sort" }),
36227
36308
  /* @__PURE__ */ jsxs112("div", { className: "flex flex-wrap items-center gap-1.5", children: [
36228
36309
  /* @__PURE__ */ jsx121(
@@ -36739,7 +36820,7 @@ function questionFromWords(text, fields, choices = {}) {
36739
36820
  }
36740
36821
 
36741
36822
  // src/TableAsk.tsx
36742
- import { Fragment as Fragment50, jsx as jsx122, jsxs as jsxs113 } from "react/jsx-runtime";
36823
+ import { Fragment as Fragment52, jsx as jsx122, jsxs as jsxs113 } from "react/jsx-runtime";
36743
36824
  function askExampleFor(fields) {
36744
36825
  const by = fields.find(isChoiceField);
36745
36826
  return by ? `count by ${fieldName(by)}` : "count";
@@ -36807,14 +36888,14 @@ function TableAsk({ tableId, onOpenInQuestions, viewId }) {
36807
36888
  ),
36808
36889
  /* @__PURE__ */ jsxs113("div", { className: said.kind === "idle" ? "hidden" : "flex min-h-32 flex-col gap-2", "data-table-ask-slot": "", children: [
36809
36890
  said.kind === "not-read" ? /* @__PURE__ */ jsx122("p", { className: "text-muted-foreground", role: "status", "data-table-ask-not-read": "", children: said.why }) : null,
36810
- said.kind === "asking" ? /* @__PURE__ */ jsxs113(Fragment50, { children: [
36891
+ said.kind === "asking" ? /* @__PURE__ */ jsxs113(Fragment52, { children: [
36811
36892
  /* @__PURE__ */ jsx122("p", { className: "truncate text-muted-foreground", children: said.reads }),
36812
36893
  /* @__PURE__ */ jsx122(Skeleton40, { className: "h-24 w-full", "data-table-ask-pending": "" })
36813
36894
  ] }) : null,
36814
36895
  said.kind === "agent-failed" ? /* @__PURE__ */ jsx122("div", { "data-table-ask-failed": "", children: /* @__PURE__ */ jsx122(RefusalNotice, { error: said.error }) }) : null,
36815
36896
  said.kind === "agent-answer" ? /* @__PURE__ */ jsx122(AgentAnswer, { tableId, answer: said.answer, fields: all }) : null,
36816
36897
  said.kind === "refused" ? /* @__PURE__ */ jsx122(RefusalNotice, { error: said.error }) : null,
36817
- said.kind === "answer" ? /* @__PURE__ */ jsxs113(Fragment50, { children: [
36898
+ said.kind === "answer" ? /* @__PURE__ */ jsxs113(Fragment52, { children: [
36818
36899
  /* @__PURE__ */ jsx122("p", { className: "truncate text-muted-foreground", title: said.reads, "data-table-ask-reads": "", children: said.reads }),
36819
36900
  /* @__PURE__ */ jsx122("div", { className: "max-h-64 overflow-y-auto", "data-table-ask-answer": "", children: /* @__PURE__ */ jsx122(QuestionAnswerView, { tableId, spec: said.spec, answer: said.answer, fields: all }) }),
36820
36901
  onOpenInQuestions ? /* @__PURE__ */ jsx122(
@@ -36956,7 +37037,7 @@ import { formatCount as formatCount8 } from "@ai-matrx/kit/format";
36956
37037
  import { BasicInput as BasicInput23, Button as Button93, Checkbox as Checkbox13, Skeleton as Skeleton41, cn as cn61 } from "@ai-matrx/design-system";
36957
37038
  import { Tile as Tile5 } from "@ai-matrx/design-system/controls";
36958
37039
  import { formFromSummary as formFromSummary2 } from "@ai-matrx/records/forms";
36959
- import { Fragment as Fragment51, jsx as jsx123, jsxs as jsxs114 } from "react/jsx-runtime";
37040
+ import { Fragment as Fragment53, jsx as jsx123, jsxs as jsxs114 } from "react/jsx-runtime";
36960
37041
  var InterfaceDoorContext = createContext7(null);
36961
37042
  var InterfaceDoorProvider = InterfaceDoorContext.Provider;
36962
37043
  function useInterfaceDoor() {
@@ -37038,7 +37119,7 @@ function sameRows(had, rows) {
37038
37119
  return had === rows || had !== void 0 && had.length === 0 && rows.length === 0;
37039
37120
  }
37040
37121
  function PageCanvas(props) {
37041
- return /* @__PURE__ */ jsxs114(Fragment51, { children: [
37122
+ return /* @__PURE__ */ jsxs114(Fragment53, { children: [
37042
37123
  /* @__PURE__ */ jsx123(PageCanvasBody, { ...props }),
37043
37124
  /* @__PURE__ */ jsx123(ReadRefusalDock, {})
37044
37125
  ] });
@@ -37258,7 +37339,7 @@ function AppletBlockView({ block }) {
37258
37339
  const host = useRecordsUi();
37259
37340
  if (!host.applets) return /* @__PURE__ */ jsx123(BlockNote, { children: "Applets open inside AI Matrx." });
37260
37341
  if (!block.app_id) return /* @__PURE__ */ jsx123(BlockNote, { children: "Choose an applet." });
37261
- return /* @__PURE__ */ jsx123(Fragment51, { children: host.applets.render(block.app_id) });
37342
+ return /* @__PURE__ */ jsx123(Fragment53, { children: host.applets.render(block.app_id) });
37262
37343
  }
37263
37344
  function AppletPick({ value, onChange }) {
37264
37345
  const host = useRecordsUi();
@@ -37487,12 +37568,12 @@ function NumberBlockView({ block, viewerUserId, extra }) {
37487
37568
  if (read.error) return /* @__PURE__ */ jsx123(RefusalLine, { error: read.error });
37488
37569
  const title = block.title ? /* @__PURE__ */ jsx123("p", { className: "truncate text-xs text-muted-foreground", "data-records-page-number-title": block.id, children: block.title }) : null;
37489
37570
  if (read.waiting || read.total === null) {
37490
- return /* @__PURE__ */ jsxs114(Fragment51, { children: [
37571
+ return /* @__PURE__ */ jsxs114(Fragment53, { children: [
37491
37572
  title,
37492
37573
  /* @__PURE__ */ jsx123(Skeleton41, { className: "h-12 w-24" })
37493
37574
  ] });
37494
37575
  }
37495
- return /* @__PURE__ */ jsxs114(Fragment51, { children: [
37576
+ return /* @__PURE__ */ jsxs114(Fragment53, { children: [
37496
37577
  title,
37497
37578
  /* @__PURE__ */ jsx123("p", { className: "text-3xl font-semibold tabular-nums", "data-records-page-number": block.id, children: formatCount8(read.total) })
37498
37579
  ] });
@@ -37597,7 +37678,7 @@ function DoorLayoutView({ block, door }) {
37597
37678
  layout: "stack",
37598
37679
  variant: "outline",
37599
37680
  wrapTitle: true,
37600
- title: /* @__PURE__ */ jsxs114(Fragment51, { children: [
37681
+ title: /* @__PURE__ */ jsxs114(Fragment53, { children: [
37601
37682
  block.image_field && typeof (row.document ?? {})[block.image_field] === "string" ? /* @__PURE__ */ jsx123("img", { src: (row.document ?? {})[block.image_field], alt: "", className: "h-28 w-full rounded object-cover" }) : null,
37602
37683
  columns.map((f) => /* @__PURE__ */ jsx123("span", { className: cn61("min-w-0 truncate", f.key === title?.key ? "text-sm font-medium" : "text-xs"), children: /* @__PURE__ */ jsx123(RecordValue, { field: f, value: (row.document ?? {})[f.key], document: row.document, withheld: row.hidden?.[f.key] ?? null, recordId: row.id, inCell: true }) }, f.key))
37603
37684
  ] }),
@@ -37676,7 +37757,7 @@ function ActionButton2({ block, recordId }) {
37676
37757
  else setError(ran.error);
37677
37758
  }
37678
37759
  return /* @__PURE__ */ jsxs114("div", { className: "flex flex-wrap items-center gap-2", "data-records-page-button": block.id, children: [
37679
- asking ? /* @__PURE__ */ jsxs114(Fragment51, { children: [
37760
+ asking ? /* @__PURE__ */ jsxs114(Fragment53, { children: [
37680
37761
  /* @__PURE__ */ jsx123("span", { className: "text-xs", children: `${label}?` }),
37681
37762
  /* @__PURE__ */ jsx123(Button93, { size: "sm", onClick: () => void runIt(), children: label }),
37682
37763
  /* @__PURE__ */ jsx123(Button93, { size: "sm", variant: "ghost", onClick: () => setAsking(false), children: "Cancel" })
@@ -37782,7 +37863,7 @@ function BlockSettings2({
37782
37863
  },
37783
37864
  `url-${block.url}`
37784
37865
  ) : null,
37785
- block.kind === "record" ? /* @__PURE__ */ jsxs114(Fragment51, { children: [
37866
+ block.kind === "record" ? /* @__PURE__ */ jsxs114(Fragment53, { children: [
37786
37867
  /* @__PURE__ */ jsx123(PickOne, { label: "Follows list", placeholder: "Choose a list", value: block.source, options: listOptions, onChange: (source) => onChange({ ...block, source }), className: "h-7 w-36" }),
37787
37868
  lists.find((l) => l.id === block.source) ? /* @__PURE__ */ jsx123(
37788
37869
  FieldGroupsEditor,
@@ -37793,7 +37874,7 @@ function BlockSettings2({
37793
37874
  }
37794
37875
  ) : null
37795
37876
  ] }) : null,
37796
- block.kind === "button" ? /* @__PURE__ */ jsxs114(Fragment51, { children: [
37877
+ block.kind === "button" ? /* @__PURE__ */ jsxs114(Fragment53, { children: [
37797
37878
  /* @__PURE__ */ jsx123(
37798
37879
  PickOne,
37799
37880
  {
@@ -37810,11 +37891,11 @@ function BlockSettings2({
37810
37891
  ),
37811
37892
  /* @__PURE__ */ jsx123(ActionPicker, { tableId: block.table_id, value: block.action_id, onChange: (action_id) => onChange({ ...block, action_id }) })
37812
37893
  ] }) : null,
37813
- block.kind === "form" ? /* @__PURE__ */ jsxs114(Fragment51, { children: [
37894
+ block.kind === "form" ? /* @__PURE__ */ jsxs114(Fragment53, { children: [
37814
37895
  /* @__PURE__ */ jsx123(TablePick, { value: block.table_id, onChange: (table_id) => onChange({ ...block, table_id, form_id: "" }) }),
37815
37896
  /* @__PURE__ */ jsx123(FormPicker, { tableId: block.table_id, value: block.form_id, onChange: (form_id) => onChange({ ...block, form_id }) })
37816
37897
  ] }) : null,
37817
- block.kind === "filter" ? /* @__PURE__ */ jsxs114(Fragment51, { children: [
37898
+ block.kind === "filter" ? /* @__PURE__ */ jsxs114(Fragment53, { children: [
37818
37899
  /* @__PURE__ */ jsx123(TablePick, { value: block.table_id, onChange: (table_id) => onChange({ ...block, table_id, field: "" }) }),
37819
37900
  /* @__PURE__ */ jsx123(FieldPick, { tableId: block.table_id, want: "choice", label: "Filter column", value: block.field, onChange: (field) => onChange({ ...block, field }) })
37820
37901
  ] }) : null,
@@ -37841,7 +37922,7 @@ function ScopeSettings({
37841
37922
  };
37842
37923
  }, [client, block.table_id]);
37843
37924
  const shown4 = block.columns && block.columns.length > 0 ? block.columns : shownColumns(all, void 0).map((f) => f.key);
37844
- return /* @__PURE__ */ jsxs114(Fragment51, { children: [
37925
+ return /* @__PURE__ */ jsxs114(Fragment53, { children: [
37845
37926
  /* @__PURE__ */ jsx123(
37846
37927
  TablePick,
37847
37928
  {
@@ -37852,7 +37933,7 @@ function ScopeSettings({
37852
37933
  }
37853
37934
  }
37854
37935
  ),
37855
- block.kind === "layout" ? /* @__PURE__ */ jsxs114(Fragment51, { children: [
37936
+ block.kind === "layout" ? /* @__PURE__ */ jsxs114(Fragment53, { children: [
37856
37937
  /* @__PURE__ */ jsx123(
37857
37938
  PickOne,
37858
37939
  {
@@ -37864,11 +37945,11 @@ function ScopeSettings({
37864
37945
  }
37865
37946
  ),
37866
37947
  block.layout === "kanban" ? /* @__PURE__ */ jsx123(FieldPick, { tableId: block.table_id, want: "choice", label: "Group by", value: block.group_field ?? "", onChange: (group_field) => onChange({ ...block, group_field }) }) : null,
37867
- block.layout === "calendar" || block.layout === "timeline" ? /* @__PURE__ */ jsxs114(Fragment51, { children: [
37948
+ block.layout === "calendar" || block.layout === "timeline" ? /* @__PURE__ */ jsxs114(Fragment53, { children: [
37868
37949
  /* @__PURE__ */ jsx123(FieldPick, { tableId: block.table_id, want: "date", label: "Date", value: block.date_field ?? "", onChange: (date_field) => onChange({ ...block, date_field }) }),
37869
37950
  /* @__PURE__ */ jsx123(FieldPick, { tableId: block.table_id, want: "date", label: "Ends", allowNone: "No end", value: block.end_field ?? "", onChange: (end_field) => onChange({ ...block, end_field: end_field || null }) })
37870
37951
  ] }) : null,
37871
- block.layout === "map" ? /* @__PURE__ */ jsxs114(Fragment51, { children: [
37952
+ block.layout === "map" ? /* @__PURE__ */ jsxs114(Fragment53, { children: [
37872
37953
  /* @__PURE__ */ jsx123(FieldPick, { tableId: block.table_id, want: "any", label: "Location", allowNone: "Pick a field", value: block.map_field ?? "", onChange: (map_field) => onChange({ ...block, map_field: map_field || null }) }),
37873
37954
  /* @__PURE__ */ jsx123(FieldPick, { tableId: block.table_id, want: "any", label: "Longitude", allowNone: "Not needed for an address", value: block.map_lng_field ?? "", onChange: (map_lng_field) => onChange({ ...block, map_lng_field: map_lng_field || null }) })
37874
37955
  ] }) : null,
@@ -37996,7 +38077,7 @@ function ListSettings({ block, onChange }) {
37996
38077
  };
37997
38078
  }, [client, block.table_id]);
37998
38079
  const shown4 = 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);
37999
- return /* @__PURE__ */ jsxs114(Fragment51, { children: [
38080
+ return /* @__PURE__ */ jsxs114(Fragment53, { children: [
38000
38081
  /* @__PURE__ */ jsx123(
38001
38082
  TablePick,
38002
38083
  {
@@ -38029,7 +38110,7 @@ function ListSettings({ block, onChange }) {
38029
38110
  onChange: (me_field) => onChange({ ...block, me_field: me_field || null })
38030
38111
  }
38031
38112
  ),
38032
- block.me_field ? /* @__PURE__ */ jsxs114(Fragment51, { children: [
38113
+ block.me_field ? /* @__PURE__ */ jsxs114(Fragment53, { children: [
38033
38114
  /* @__PURE__ */ jsxs114("label", { className: "flex items-center gap-1", children: [
38034
38115
  /* @__PURE__ */ jsx123(Checkbox13, { checked: block.me_default === true, onCheckedChange: (on) => onChange({ ...block, me_default: on === true }), "aria-label": "Starts on Assigned to me" }),
38035
38116
  "Starts on"
@@ -38082,7 +38163,7 @@ function FormPicker({ tableId, value, onChange }) {
38082
38163
  return /* @__PURE__ */ jsx123(PickOne, { label: "Form", placeholder: "Choose a form", value, options, onChange: (v) => onChange(v), className: "h-7 w-40" });
38083
38164
  }
38084
38165
  function ChartSettings({ chart, onChange }) {
38085
- return /* @__PURE__ */ jsxs114(Fragment51, { children: [
38166
+ return /* @__PURE__ */ jsxs114(Fragment53, { children: [
38086
38167
  /* @__PURE__ */ jsx123(TablePick, { value: chart.subject, onChange: (subject) => onChange({ ...chart, subject, groupBy: [] }) }),
38087
38168
  /* @__PURE__ */ jsx123(
38088
38169
  PickOne,
@@ -38132,7 +38213,7 @@ function escapeText2(text) {
38132
38213
  }
38133
38214
 
38134
38215
  // src/PageScreen.tsx
38135
- import { Fragment as Fragment52, jsx as jsx124, jsxs as jsxs115 } from "react/jsx-runtime";
38216
+ import { Fragment as Fragment54, jsx as jsx124, jsxs as jsxs115 } from "react/jsx-runtime";
38136
38217
  var EDIT_LEVELS = /* @__PURE__ */ new Set(["edit_content", "editor", "admin", "owner"]);
38137
38218
  function PageScreen({
38138
38219
  pageId,
@@ -38332,7 +38413,7 @@ function PageScreen({
38332
38413
  className: "h-8 w-40"
38333
38414
  }
38334
38415
  ),
38335
- /* @__PURE__ */ jsx124("span", { className: "ml-auto flex items-center gap-1", children: askingToArchive ? /* @__PURE__ */ jsxs115(Fragment52, { children: [
38416
+ /* @__PURE__ */ jsx124("span", { className: "ml-auto flex items-center gap-1", children: askingToArchive ? /* @__PURE__ */ jsxs115(Fragment54, { children: [
38336
38417
  /* @__PURE__ */ jsx124("span", { className: "text-destructive", children: archiveConfirmSentence(`the page \u201C${page.name}\u201D`) }),
38337
38418
  /* @__PURE__ */ jsx124(Button94, { size: "sm", variant: "destructive", onClick: () => void archive(), children: "Archive it" }),
38338
38419
  /* @__PURE__ */ jsx124(Button94, { size: "sm", variant: "ghost", onClick: () => setAskingToArchive(false), children: "Keep it" })
@@ -38359,7 +38440,7 @@ function PageScreen({
38359
38440
  import { useCallback as useCallback55, useEffect as useEffect101, useMemo as useMemo67, useRef as useRef47, useState as useState113 } from "react";
38360
38441
  import { useRecordsClient as useRecordsClient91 } from "@ai-matrx/records/react";
38361
38442
  import { BasicInput as BasicInput25, Button as Button95, Skeleton as Skeleton43, cn as cn63 } from "@ai-matrx/design-system";
38362
- import { Fragment as Fragment53, jsx as jsx125, jsxs as jsxs116 } from "react/jsx-runtime";
38443
+ import { Fragment as Fragment55, jsx as jsx125, jsxs as jsxs116 } from "react/jsx-runtime";
38363
38444
  var INTERFACE_COLOR_CLASS = {
38364
38445
  blue: "bg-blue-500 text-white",
38365
38446
  green: "bg-emerald-500 text-white",
@@ -38483,7 +38564,7 @@ function InterfaceScreen({
38483
38564
  const savePage = (nextPage) => void save(withDraftPage(shape, nextPage));
38484
38565
  const actions = /* @__PURE__ */ jsxs116("span", { className: "flex flex-wrap items-center gap-1", children: [
38485
38566
  builder ? /* @__PURE__ */ jsx125(Button95, { size: "sm", variant: editing ? "secondary" : "ghost", "aria-pressed": editing, onClick: () => setEditing((v) => !v), "data-records-interface-edit": "", children: editing ? "Done" : "Edit" }) : null,
38486
- changed2 ? /* @__PURE__ */ jsxs116(Fragment53, { children: [
38567
+ changed2 ? /* @__PURE__ */ jsxs116(Fragment55, { children: [
38487
38568
  /* @__PURE__ */ jsx125(Button95, { size: "sm", onClick: () => void save(publish(shape, (/* @__PURE__ */ new Date()).toISOString(), viewerUserId ?? null)), "data-records-interface-publish": "", children: "Publish" }),
38488
38569
  shape.published ? /* @__PURE__ */ jsx125(Button95, { size: "sm", variant: "ghost", onClick: () => void save(clearUnpublished(shape)), "data-records-interface-clear": "", children: "Clear changes" }) : null
38489
38570
  ] }) : null,
@@ -38582,7 +38663,7 @@ function InterfaceScreen({
38582
38663
  className: "h-8 w-28"
38583
38664
  }
38584
38665
  ),
38585
- page ? /* @__PURE__ */ jsxs116(Fragment53, { children: [
38666
+ page ? /* @__PURE__ */ jsxs116(Fragment55, { children: [
38586
38667
  /* @__PURE__ */ jsx125(
38587
38668
  BasicInput25,
38588
38669
  {
@@ -38628,7 +38709,7 @@ function InterfaceScreen({
38628
38709
  }
38629
38710
  ) : null
38630
38711
  ] }) : null,
38631
- /* @__PURE__ */ jsx125("span", { className: "ml-auto flex items-center gap-1", children: askingToArchive ? /* @__PURE__ */ jsxs116(Fragment53, { children: [
38712
+ /* @__PURE__ */ jsx125("span", { className: "ml-auto flex items-center gap-1", children: askingToArchive ? /* @__PURE__ */ jsxs116(Fragment55, { children: [
38632
38713
  /* @__PURE__ */ jsx125("span", { className: "text-destructive", children: archiveConfirmSentence(`the interface \u201C${read.name}\u201D`) }),
38633
38714
  /* @__PURE__ */ jsx125(
38634
38715
  Button95,
@@ -38675,7 +38756,7 @@ import { useRecordsClient as useRecordsClient92, useTable as useTable36 } from "
38675
38756
  import { publicFormPath as publicFormPath2 } from "@ai-matrx/records";
38676
38757
  import { Badge as Badge18, Button as Button96, Skeleton as Skeleton44, cn as cn64 } from "@ai-matrx/design-system";
38677
38758
  import { FORM_STATE_WORDS as FORM_STATE_WORDS2 } from "@ai-matrx/records/forms";
38678
- import { Fragment as Fragment54, jsx as jsx126, jsxs as jsxs117 } from "react/jsx-runtime";
38759
+ import { Fragment as Fragment56, jsx as jsx126, jsxs as jsxs117 } from "react/jsx-runtime";
38679
38760
  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.";
38680
38761
  var WHAT_A_FORM_IS = "A form uses this table's own fields, and its answers land here as ordinary records stamped with the form they came through.";
38681
38762
  var NO_ADMIN = "This table has no forms. Making one needs Full access on it, because a form decides what people with no account may add here.";
@@ -38817,12 +38898,12 @@ function FormsPanel({ tableId, activeFormId, asView = false, className }) {
38817
38898
  /* @__PURE__ */ jsxs117("p", { className: "mt-1.5 text-xs", children: [
38818
38899
  /* @__PURE__ */ jsx126("span", { className: "font-medium", children: form.in_table }),
38819
38900
  " in the table",
38820
- form.held > 0 ? /* @__PURE__ */ jsxs117(Fragment54, { children: [
38901
+ form.held > 0 ? /* @__PURE__ */ jsxs117(Fragment56, { children: [
38821
38902
  " \xB7 ",
38822
38903
  /* @__PURE__ */ jsx126("span", { className: "font-medium", children: form.held }),
38823
38904
  " waiting for someone"
38824
38905
  ] }) : null,
38825
- form.rejected > 0 ? /* @__PURE__ */ jsxs117(Fragment54, { children: [
38906
+ form.rejected > 0 ? /* @__PURE__ */ jsxs117(Fragment56, { children: [
38826
38907
  " \xB7 ",
38827
38908
  /* @__PURE__ */ jsx126("span", { className: "font-medium", children: form.rejected }),
38828
38909
  " turned away"
@@ -39277,7 +39358,7 @@ function CaptureRun({ sheetId, face: given, className }) {
39277
39358
 
39278
39359
  // src/CaptureSheet.tsx
39279
39360
  import { momentZoneOptions as momentZoneOptions6 } from "@ai-matrx/design-system/field-formats";
39280
- import { Fragment as Fragment55, jsx as jsx128, jsxs as jsxs119 } from "react/jsx-runtime";
39361
+ import { Fragment as Fragment57, jsx as jsx128, jsxs as jsxs119 } from "react/jsx-runtime";
39281
39362
  var CAPTURE_MODES = ["reading", "photo", "voice"];
39282
39363
  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.";
39283
39364
  function mintClientKey() {
@@ -39454,7 +39535,7 @@ function AdHocCaptureSheet({
39454
39535
  " ",
39455
39536
  /* @__PURE__ */ jsx128("code", { children: "attachmentField" }),
39456
39537
  "."
39457
- ] }) : /* @__PURE__ */ jsxs119(Fragment55, { children: [
39538
+ ] }) : /* @__PURE__ */ jsxs119(Fragment57, { children: [
39458
39539
  /* @__PURE__ */ jsx128(
39459
39540
  "input",
39460
39541
  {
@@ -39728,7 +39809,7 @@ import { useCallback as useCallback61, useEffect as useEffect107, useState as us
39728
39809
  import { useRecordsClient as useRecordsClient97 } from "@ai-matrx/records/react";
39729
39810
  import { Button as Button100, Input as Input9, Skeleton as Skeleton49, Textarea as Textarea7, cn as cn69 } from "@ai-matrx/design-system";
39730
39811
  import { useTable as useTable38 } from "@ai-matrx/records/react";
39731
- import { Fragment as Fragment56, jsx as jsx131, jsxs as jsxs122 } from "react/jsx-runtime";
39812
+ import { Fragment as Fragment58, jsx as jsx131, jsxs as jsxs122 } from "react/jsx-runtime";
39732
39813
  function EmbedFrame({
39733
39814
  tableId,
39734
39815
  formId,
@@ -39812,7 +39893,7 @@ function EmbedFrame({
39812
39893
  " will not pass."
39813
39894
  ] })
39814
39895
  ] }),
39815
- !secret ? /* @__PURE__ */ jsx131(Button100, { size: "sm", className: "self-start", disabled: busy || parsed.length === 0, onClick: () => void issue(), children: busy ? "Issuing\u2026" : "Issue embed" }) : /* @__PURE__ */ jsxs122(Fragment56, { children: [
39896
+ !secret ? /* @__PURE__ */ jsx131(Button100, { size: "sm", className: "self-start", disabled: busy || parsed.length === 0, onClick: () => void issue(), children: busy ? "Issuing\u2026" : "Issue embed" }) : /* @__PURE__ */ jsxs122(Fragment58, { children: [
39816
39897
  /* @__PURE__ */ jsx131("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." }),
39817
39898
  /* @__PURE__ */ jsx131(Textarea7, { "aria-label": "Embed snippet", readOnly: true, rows: 3, className: "font-mono text-[11px]", value: snippet ?? "" }),
39818
39899
  /* @__PURE__ */ jsxs122("div", { className: "flex gap-2", children: [
@@ -40344,7 +40425,7 @@ import { formatCount as formatCount9 } from "@ai-matrx/kit/format";
40344
40425
  import { useState as useState124 } from "react";
40345
40426
  import { tableShapeChanged as tableShapeChanged13, useRecordsClient as useRecordsClient98 } from "@ai-matrx/records/react";
40346
40427
  import { Button as Button104, Dialog as Dialog22, DialogContent as DialogContent22, DialogFooter as DialogFooter14, DialogHeader as DialogHeader22, DialogTitle as DialogTitle22, ErrorBox as ErrorBox4, Input as Input10, Switch as Switch9 } from "@ai-matrx/design-system";
40347
- import { Fragment as Fragment57, jsx as jsx136, jsxs as jsxs127 } from "react/jsx-runtime";
40428
+ import { Fragment as Fragment59, jsx as jsx136, jsxs as jsxs127 } from "react/jsx-runtime";
40348
40429
  function copyNameFor(name) {
40349
40430
  return `${name.trim() || "Table"} (copy)`;
40350
40431
  }
@@ -40437,7 +40518,7 @@ function TableDuplicateDialog({ tableId, name, organizationId, open, onOpenChang
40437
40518
  phase.kind === "refused" && phase.timedOut ? /* @__PURE__ */ jsx136(Button104, { variant: "outline", size: "sm", className: "self-start", "data-refusal-retry": "", onClick: () => void go(), children: "Try again" }) : null,
40438
40519
  problem && typed2 !== "" ? /* @__PURE__ */ jsx136("p", { className: "text-xs text-muted-foreground", children: problem }) : null
40439
40520
  ] }),
40440
- /* @__PURE__ */ jsx136(DialogFooter14, { children: phase.kind === "done" ? /* @__PURE__ */ jsx136(Button104, { onClick: () => openCopy(phase.copy), "data-table-duplicate-open": "", children: "Open the copy" }) : /* @__PURE__ */ jsxs127(Fragment57, { children: [
40521
+ /* @__PURE__ */ jsx136(DialogFooter14, { children: phase.kind === "done" ? /* @__PURE__ */ jsx136(Button104, { onClick: () => openCopy(phase.copy), "data-table-duplicate-open": "", children: "Open the copy" }) : /* @__PURE__ */ jsxs127(Fragment59, { children: [
40441
40522
  /* @__PURE__ */ jsx136(Button104, { variant: "ghost", disabled: copying, onClick: () => close(false), children: "Cancel" }),
40442
40523
  /* @__PURE__ */ jsx136(Button104, { disabled: copying || problem !== null, onClick: () => void go(), children: copying ? "Duplicating\u2026" : "Duplicate" })
40443
40524
  ] }) })
@@ -40969,7 +41050,7 @@ function useSlotScroll(slot) {
40969
41050
  // src/TablePage.tsx
40970
41051
  import { isUuidShape as isUuidShape4 } from "@ai-matrx/kit/uuid";
40971
41052
  import { openOutbound as openOutbound2 } from "@ai-matrx/kit/outbound";
40972
- import { Fragment as Fragment58, jsx as jsx140, jsxs as jsxs131 } from "react/jsx-runtime";
41053
+ import { Fragment as Fragment60, jsx as jsx140, jsxs as jsxs131 } from "react/jsx-runtime";
40973
41054
  var RAIL_TITLE = {
40974
41055
  settings: "Table settings",
40975
41056
  inbox: "Inbox",
@@ -41721,7 +41802,7 @@ function TablePage({
41721
41802
  ]
41722
41803
  }
41723
41804
  );
41724
- const sheetExtras = controlsInSheet && main === "records" && shownLayout === "grid" ? /* @__PURE__ */ jsxs131(Fragment58, { children: [
41805
+ const sheetExtras = controlsInSheet && main === "records" && shownLayout === "grid" ? /* @__PURE__ */ jsxs131(Fragment60, { children: [
41725
41806
  /* @__PURE__ */ jsx140("div", { className: "flex items-center gap-2 text-xs", "data-table-sheet-filter": "", "data-matrx-table-tools-keep-open": "", children: /* @__PURE__ */ jsx140(ViewFilter, { tableId, view: shown4, withheldKeys, onApply: (where) => void patchView({ where }) }) }),
41726
41807
  /* @__PURE__ */ jsx140("div", { role: "group", "aria-label": "Layout", className: "flex flex-wrap gap-1 pt-1", "data-table-sheet-layout": "", children: VIEW_LAYOUTS.map((option) => /* @__PURE__ */ jsx140(
41727
41808
  Button106,
@@ -41946,7 +42027,7 @@ function TablePage({
41946
42027
  return () => window.removeEventListener("keydown", onKey);
41947
42028
  }, [recordsUi]);
41948
42029
  const openedFromMenu = openedEntry ? { ...openedEntry, label: actions.find((a) => a.id === openedEntry.id)?.label ?? openedEntry.key } : null;
41949
- const pageActions = /* @__PURE__ */ jsxs131(Fragment58, { children: [
42030
+ const pageActions = /* @__PURE__ */ jsxs131(Fragment60, { children: [
41950
42031
  publicReadOnly ? /* @__PURE__ */ jsx140(Badge19, { variant: "neutral", className: "shrink-0", "data-public-read-only": "", children: PUBLIC_READ_ONLY }, "public-read-only") : null,
41951
42032
  !phone && rights.read && table.data ? /* @__PURE__ */ jsx140(
41952
42033
  TableAsk,
@@ -41974,7 +42055,7 @@ function TablePage({
41974
42055
  },
41975
42056
  `share-${shareAsked}`
41976
42057
  ) }, "share") : null,
41977
- phone ? /* @__PURE__ */ jsxs131(Fragment58, { children: [
42058
+ phone ? /* @__PURE__ */ jsxs131(Fragment60, { children: [
41978
42059
  !chooserInline && !chooserCompact && !embedded ? /* @__PURE__ */ jsxs131(DropdownMenu9, { children: [
41979
42060
  /* @__PURE__ */ jsx140(DropdownMenuTrigger9, { asChild: true, children: /* @__PURE__ */ jsx140(Button106, { size: "sm", variant: "ghost", "aria-label": "Layout", title: "Layout", "data-table-layout-menu": "", children: "Layout" }) }),
41980
42061
  /* @__PURE__ */ jsx140(DropdownMenuContent9, { align: "end", className: "w-56", children: layoutRadio })
@@ -41987,7 +42068,7 @@ function TablePage({
41987
42068
  /* @__PURE__ */ jsx140("circle", { cx: "19", cy: "12", r: "1.75" })
41988
42069
  ] }) }) }),
41989
42070
  /* @__PURE__ */ jsxs131(DropdownMenuContent9, { align: "end", className: "w-64", "data-table-menu-content": "", ...renameMenuProps, children: [
41990
- !chooserInline && !chooserCompact && !embedded ? /* @__PURE__ */ jsxs131(Fragment58, { children: [
42071
+ !chooserInline && !chooserCompact && !embedded ? /* @__PURE__ */ jsxs131(Fragment60, { children: [
41991
42072
  /* @__PURE__ */ jsx140(DropdownMenuLabel3, { className: "text-xs text-muted-foreground", children: "Layout" }),
41992
42073
  layoutRadio,
41993
42074
  /* @__PURE__ */ jsx140(DropdownMenuSeparator4, {})
@@ -42048,18 +42129,18 @@ function TablePage({
42048
42129
  rights.structure && table.data ? /* @__PURE__ */ jsx140(TableRenameDialog, { tableId, name: table.data.name, open: renameOpen, onOpenChange: setRenameOpen }, "rename") : null
42049
42130
  ] });
42050
42131
  const headerNode = header && !embedded ? header({ actions: table.data ? pageActions : null, tableName: table.data?.name ?? null }) : null;
42051
- if (table.error) return /* @__PURE__ */ jsxs131(Fragment58, { children: [
42132
+ if (table.error) return /* @__PURE__ */ jsxs131(Fragment60, { children: [
42052
42133
  headerNode,
42053
42134
  /* @__PURE__ */ jsx140(RefusalNotice, { error: table.error, onRetry: table.reload })
42054
42135
  ] });
42055
42136
  if (table.loading && !table.data) {
42056
- return /* @__PURE__ */ jsxs131(Fragment58, { children: [
42137
+ return /* @__PURE__ */ jsxs131(Fragment60, { children: [
42057
42138
  headerNode,
42058
42139
  /* @__PURE__ */ jsx140(TablePageSkeleton, { layout: skeletonFace, embedded, tableId, ...className ? { className } : {} })
42059
42140
  ] });
42060
42141
  }
42061
42142
  if (!table.data) {
42062
- return /* @__PURE__ */ jsxs131(Fragment58, { children: [
42143
+ return /* @__PURE__ */ jsxs131(Fragment60, { children: [
42063
42144
  headerNode,
42064
42145
  /* @__PURE__ */ jsx140(TableNotHere, { tableId, onLeave, leaveLabel, className })
42065
42146
  ] });
@@ -42072,11 +42153,11 @@ function TablePage({
42072
42153
  headerNode,
42073
42154
  /* @__PURE__ */ jsx140("div", { className: "flex min-h-0 min-w-0 flex-1 flex-col gap-2", children: structure.hidden || !structure.settled ? (
42074
42155
  /* THE TOOLBAR ROW'S HEIGHT IS KEPT (min-h-8), so the sentence lands exactly where the bar was. */
42075
- /* @__PURE__ */ jsxs131(Fragment58, { children: [
42156
+ /* @__PURE__ */ jsxs131(Fragment60, { children: [
42076
42157
  /* @__PURE__ */ jsx140("div", { className: TABLE_TOOLBAR_ROW_CLASS, "data-table-toolbar": "", "aria-hidden": "true" }),
42077
42158
  structure.hidden ? /* @__PURE__ */ jsx140(StructureLocked, {}) : /* @__PURE__ */ jsx140(RecordsSkeleton, { layout: skeletonFace, embedded })
42078
42159
  ] })
42079
- ) : /* @__PURE__ */ jsxs131(Fragment58, { children: [
42160
+ ) : /* @__PURE__ */ jsxs131(Fragment60, { children: [
42080
42161
  /* @__PURE__ */ jsx140(ImportNotice, { tableId, epoch: importEpoch, onOpenImport: () => setRail("import") }),
42081
42162
  /* @__PURE__ */ jsxs131(
42082
42163
  "div",
@@ -42570,7 +42651,7 @@ import { MatrxTableCardShowMore as MatrxTableCardShowMore3 } from "@ai-matrx/des
42570
42651
  import { useEffect as useEffect113, useMemo as useMemo74, useRef as useRef53, useState as useState129 } from "react";
42571
42652
  import { Button as Button107, ErrorBox as ErrorBox5, Input as Input12, cn as cn72 } from "@ai-matrx/design-system";
42572
42653
  import { SEED_FRESH_MS, useRecordsClient as useRecordsClient100, useSeededAnswerAt } from "@ai-matrx/records/react";
42573
- import { Fragment as Fragment59, jsx as jsx141, jsxs as jsxs132 } from "react/jsx-runtime";
42654
+ import { Fragment as Fragment61, jsx as jsx141, jsxs as jsxs132 } from "react/jsx-runtime";
42574
42655
  var entityTitleColumn = entityNameColumn;
42575
42656
  function shown3(v) {
42576
42657
  if (v === null || v === void 0 || v === "") return "";
@@ -42760,7 +42841,7 @@ function EntityTablePageBody({
42760
42841
  presentation === "page" ? /* @__PURE__ */ jsx141("h2", { className: "truncate text-base font-semibold", children: entity.label ?? (entity.loading ? "Loading\u2026" : "Table") }) : null,
42761
42842
  presentation === "page" ? /* @__PURE__ */ jsx141("span", { className: "text-xs tabular-nums text-muted-foreground", children: entity.loading || entity.total === null ? "" : formatCount10(entity.total) }) : null,
42762
42843
  /* @__PURE__ */ jsxs132("span", { className: "ml-auto flex items-center gap-1", children: [
42763
- boardable ? /* @__PURE__ */ jsxs132(Fragment59, { children: [
42844
+ boardable ? /* @__PURE__ */ jsxs132(Fragment61, { children: [
42764
42845
  /* @__PURE__ */ jsx141(Button107, { size: "sm", variant: layout === "grid" ? "secondary" : "ghost", "aria-pressed": layout === "grid", onClick: () => choose("grid"), children: "Table" }),
42765
42846
  /* @__PURE__ */ jsx141(Button107, { size: "sm", variant: layout === "board" ? "secondary" : "ghost", "aria-pressed": layout === "board", onClick: () => choose("board"), children: "Board" })
42766
42847
  ] }) : null,
@@ -42799,7 +42880,7 @@ function EntityTablePageBody({
42799
42880
  ] })
42800
42881
  ] }) : null,
42801
42882
  addRefused ? /* @__PURE__ */ jsx141(ErrorBox5, { 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,
42802
- entity.error ? /* @__PURE__ */ jsx141("p", { className: "px-1 py-3 text-xs text-muted-foreground", children: `This table could not be read: ${entity.error}` }) : layout === "board" && boardable ? /* @__PURE__ */ jsx141(EntityBoard, { entity, groupBy, onOpenRecord }) : /* @__PURE__ */ jsxs132(Fragment59, { children: [
42883
+ entity.error ? /* @__PURE__ */ jsx141("p", { className: "px-1 py-3 text-xs text-muted-foreground", children: `This table could not be read: ${entity.error}` }) : layout === "board" && boardable ? /* @__PURE__ */ jsx141(EntityBoard, { entity, groupBy, onOpenRecord }) : /* @__PURE__ */ jsxs132(Fragment61, { children: [
42803
42884
  presentation === "embedded" && searchBox ? /* @__PURE__ */ jsx141("div", { className: "flex min-w-0 items-center justify-end", "data-records-entity-search": "", children: /* @__PURE__ */ jsx141(TooltipProvider, { children: /* @__PURE__ */ jsx141(
42804
42885
  TapTargetSearchGroup2,
42805
42886
  {
@@ -43042,6 +43123,7 @@ import {
43042
43123
  import { MessageSquareIcon, PlusIcon as PlusIcon2, StickyNoteIcon } from "@ai-matrx/design-system/icons";
43043
43124
  import { readColorPair, readShadowPair, shadowWords } from "@ai-matrx/design-system/field-formats";
43044
43125
  import { Button as Button110, Tile as Tile6 } from "@ai-matrx/design-system/controls";
43126
+ import { sortAsFor as sortAsFor2 } from "@ai-matrx/records/first-page";
43045
43127
 
43046
43128
  // src/EntitySectionCard.tsx
43047
43129
  import { useState as useState132 } from "react";
@@ -43370,7 +43452,7 @@ function SectionEmpty({ empty }) {
43370
43452
  }
43371
43453
 
43372
43454
  // src/SectionCard.tsx
43373
- import { Fragment as Fragment60, jsx as jsx146, jsxs as jsxs136 } from "react/jsx-runtime";
43455
+ import { Fragment as Fragment62, jsx as jsx146, jsxs as jsxs136 } from "react/jsx-runtime";
43374
43456
  var SAVE_AFTER_MS = 500;
43375
43457
  var UNGROUPED2 = "";
43376
43458
  function findKey(fields, wanted) {
@@ -43388,16 +43470,22 @@ function sectionColumns(fields, titleField, props) {
43388
43470
  return { name, group, note, readsOn, values };
43389
43471
  }
43390
43472
  var NATURAL2 = new Intl.Collator(void 0, { numeric: true, sensitivity: "base" });
43391
- function orderedRows(rows, nameKey) {
43473
+ function orderedRows(rows, nameKey, direction = "asc") {
43392
43474
  if (!nameKey) return [...rows];
43393
43475
  const nameOf = (r) => String((r.document ?? {})[nameKey] ?? "");
43476
+ const sign = direction === "desc" ? -1 : 1;
43394
43477
  return [...rows].sort((a, b) => {
43395
43478
  const x = nameOf(a);
43396
43479
  const y = nameOf(b);
43397
43480
  if (x === "" || y === "") return x === "" ? y === "" ? 0 : 1 : -1;
43398
- return NATURAL2.compare(x, y);
43481
+ return sign * NATURAL2.compare(x, y);
43399
43482
  });
43400
43483
  }
43484
+ function tableSortedRows(rows, sort, fields) {
43485
+ const field = fields.find((f) => f.key === sort.id);
43486
+ if (!field || sortAsFor2(field) !== "text") return [...rows];
43487
+ return orderedRows(rows, sort.id, sort.direction);
43488
+ }
43401
43489
  function sectionGroups(rows, groupKey) {
43402
43490
  if (!groupKey) return [{ key: UNGROUPED2, rows: [...rows] }];
43403
43491
  const map = /* @__PURE__ */ new Map();
@@ -43567,14 +43655,14 @@ function ReadsOnPicker({
43567
43655
  const [value, change] = useDraft(stored, (next) => save(field, next));
43568
43656
  const on = typeof value === "string" && value.trim() !== "" ? value : null;
43569
43657
  const said = problem ? /* @__PURE__ */ jsx146("span", { className: "block truncate text-xs text-warning-ink", "data-records-reads-on-problem": problem, children: READS_ON_PROBLEM_WORDS[problem] }) : null;
43570
- if (!editable) return on ? /* @__PURE__ */ jsxs136(Fragment60, { children: [
43658
+ if (!editable) return on ? /* @__PURE__ */ jsxs136(Fragment62, { children: [
43571
43659
  /* @__PURE__ */ jsxs136("span", { className: "block truncate text-xs text-muted-foreground", children: [
43572
43660
  "on ",
43573
43661
  on
43574
43662
  ] }),
43575
43663
  said
43576
43664
  ] }) : null;
43577
- return /* @__PURE__ */ jsxs136(Fragment60, { children: [
43665
+ return /* @__PURE__ */ jsxs136(Fragment62, { children: [
43578
43666
  /* @__PURE__ */ jsxs136(Select23, { value: on ?? NOTHING, onValueChange: (v) => change(v === NOTHING ? null : v), children: [
43579
43667
  /* @__PURE__ */ jsx146(SelectTrigger16, { "aria-label": `${fieldName(field)} for this row`, className: "mt-1 h-6 w-auto max-w-full gap-1 border-0 bg-transparent px-0 text-xs text-muted-foreground shadow-none", children: /* @__PURE__ */ jsx146("span", { className: "truncate", children: on ? `on ${on}` : "on nothing" }) }),
43580
43668
  /* @__PURE__ */ jsxs136(SelectContent16, { children: [
@@ -43790,7 +43878,6 @@ function TableSectionCard(props) {
43790
43878
  const fieldsRead = useFields35(tableId);
43791
43879
  const tableSort = defaultSortOf(table.data ?? null, fieldsRead.data ?? []);
43792
43880
  const page = useRecordPage4(fieldsRead.data ? tableId : null, { pageSize: 200, ...tableSort ? { sort: [{ field: tableSort.id, direction: tableSort.direction }] } : {} });
43793
- const sortedByStore = tableSort !== null;
43794
43881
  const mutation = useRecordMutation3();
43795
43882
  const [adding, setAdding] = useState133(null);
43796
43883
  const [failed, setFailed] = useState133(null);
@@ -43802,7 +43889,7 @@ function TableSectionCard(props) {
43802
43889
  const readsOnField = cols.readsOn ? fields.find((f) => f.key === cols.readsOn) : void 0;
43803
43890
  const readsOnColorKey = cols.readsOn ? cols.values.find((f) => formatForField(f)?.options?.contrastWith?.readsOnField === cols.readsOn)?.key : void 0;
43804
43891
  const columns = columnsOf(cols.values);
43805
- const rows = sortedByStore ? page.data?.rows ?? [] : orderedRows(page.data?.rows ?? [], cols.name);
43892
+ const rows = tableSort ? tableSortedRows(page.data?.rows ?? [], tableSort, fields) : orderedRows(page.data?.rows ?? [], cols.name);
43806
43893
  const groups = sectionGroups(rows, cols.group);
43807
43894
  const level = rows[0]?.level ?? null;
43808
43895
  const mayWrite = !readOnly && (rows.length === 0 ? !readOnly : atLeast(level, "edit_content"));