@ai-matrx/records-ui 0.114.0 → 0.115.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -41,9 +41,7 @@ var NEEDS = {
41
41
  // custom.share_grant — passing your access on is an administrator's right
42
42
  share: "admin",
43
43
  // custom.field_declare / field_update / field_retire / table settings
44
- structure: "admin",
45
- // custom.field_declare / field_update / field_retire — the same rung; a lock takes it away, nothing else does
46
- schema: "admin"
44
+ structure: "admin"
47
45
  };
48
46
  function levelNeededFor(what) {
49
47
  return NEEDS[what];
@@ -61,8 +59,7 @@ function sentenceFor(what, level) {
61
59
  organise: "organise this",
62
60
  remove: "delete this",
63
61
  share: "pass this on to somebody else",
64
- structure: "change the columns of this table",
65
- schema: "change the columns of this table"
62
+ structure: "change the columns of this table"
66
63
  };
67
64
  return `You are ${have} here, and it takes ${need} to ${doing[what]}. Ask somebody who is Admin on it to move you up.`;
68
65
  }
@@ -78,7 +75,6 @@ function whatYouMayDo(level, known = true) {
78
75
  remove: may("remove"),
79
76
  share: may("share"),
80
77
  structure: may("structure"),
81
- schema: may("schema"),
82
78
  why: (what) => known ? sentenceFor(what, level) : NOT_YET
83
79
  };
84
80
  }
@@ -90,16 +86,15 @@ function whatYouMayDoWithTable(table, level, known) {
90
86
  return {
91
87
  ...base2,
92
88
  structure: false,
93
- schema: false,
94
- why: (what) => what === "structure" || what === "schema" ? KERNEL_REASON : base2.why(what)
89
+ why: (what) => what === "structure" ? KERNEL_REASON : base2.why(what)
95
90
  };
96
91
  }
97
92
  function tableIsLocked(table) {
98
93
  return table?.metadata?.["locked"] === true;
99
94
  }
100
- var DATABASE_LOCKED_REASON = "This database is locked, so its columns cannot be added, renamed, changed or deleted. Unlock it to change them.";
95
+ var DATABASE_LOCKED_REASON = "This database is locked, so its columns and settings are read-only. Unlock it to change them.";
101
96
  function lockedStructure(base2) {
102
- return { ...base2, schema: false, why: (what) => what === "schema" ? DATABASE_LOCKED_REASON : base2.why(what) };
97
+ return { ...base2, structure: false, why: (what) => what === "structure" ? DATABASE_LOCKED_REASON : base2.why(what) };
103
98
  }
104
99
 
105
100
  // src/host.tsx
@@ -135,40 +130,40 @@ function quiet(may, say2) {
135
130
  }
136
131
  function useTableRights(table) {
137
132
  const host = useRecordsUi();
138
- const asked2 = useTableRightsAsked(table, host);
139
- return useMemo(() => quiet(asked2, host.sayLevelNeeded), [asked2, host.sayLevelNeeded]);
133
+ const asked3 = useTableRightsAsked(table, host);
134
+ return useMemo(() => quiet(asked3, host.sayLevelNeeded), [asked3, host.sayLevelNeeded]);
140
135
  }
141
136
  function useTableRightsAsked(table, host) {
142
137
  const bound2 = Boolean(host.rights);
143
- const asked2 = useMyLevel(bound2 || !table ? null : table.id);
138
+ const asked3 = useMyLevel(bound2 || !table ? null : table.id);
144
139
  return useMemo(() => {
145
140
  if (!table) return NO_RIGHTS;
146
141
  if (host.rights) return host.rights(table);
147
- if (asked2.loading) return tableRights(NOT_ANSWERED_YET);
148
- const level = asked2.error ? null : asked2.data;
142
+ if (asked3.loading) return tableRights(NOT_ANSWERED_YET);
143
+ const level = asked3.error ? null : asked3.data;
149
144
  return tableRights(whatYouMayDoWithTable(table, level, true));
150
- }, [host, table, bound2, asked2.loading, asked2.error, asked2.data]);
145
+ }, [host, table, bound2, asked3.loading, asked3.error, asked3.data]);
151
146
  }
152
147
  function useRecordRights(recordId) {
153
- const asked2 = useMyLevel(recordId);
148
+ const asked3 = useMyLevel(recordId);
154
149
  const say2 = useRecordsUi().sayLevelNeeded;
155
150
  return useMemo(() => {
156
151
  if (!recordId) return NOT_ANSWERED_YET;
157
- if (asked2.loading) return NOT_ANSWERED_YET;
158
- if (asked2.error) return quiet(whatYouMayDo(null, true), say2);
159
- return quiet(whatYouMayDo(asked2.data, true), say2);
160
- }, [recordId, asked2.loading, asked2.error, asked2.data, say2]);
152
+ if (asked3.loading) return NOT_ANSWERED_YET;
153
+ if (asked3.error) return quiet(whatYouMayDo(null, true), say2);
154
+ return quiet(whatYouMayDo(asked3.data, true), say2);
155
+ }, [recordId, asked3.loading, asked3.error, asked3.data, say2]);
161
156
  }
162
157
  function useRowRights(rowIds, enabled) {
163
- const asked2 = useMyLevels(enabled ? rowIds : []);
158
+ const asked3 = useMyLevels(enabled ? rowIds : []);
164
159
  const say2 = useRecordsUi().sayLevelNeeded;
165
160
  return useMemo(() => {
166
161
  if (!enabled) return () => null;
167
- if (asked2.loading) return () => NOT_ANSWERED_YET;
168
- if (asked2.error) return () => quiet(whatYouMayDo(null, true), say2);
169
- const held = asked2.data ?? {};
162
+ if (asked3.loading) return () => NOT_ANSWERED_YET;
163
+ if (asked3.error) return () => quiet(whatYouMayDo(null, true), say2);
164
+ const held = asked3.data ?? {};
170
165
  return (rowId) => quiet(whatYouMayDo(held[rowId] ?? null, true), say2);
171
- }, [enabled, asked2.loading, asked2.error, asked2.data, say2]);
166
+ }, [enabled, asked3.loading, asked3.error, asked3.data, say2]);
172
167
  }
173
168
 
174
169
  // src/settingsAgent.ts
@@ -469,8 +464,8 @@ function isObject(value) {
469
464
  return typeof value === "object" && value !== null && !Array.isArray(value);
470
465
  }
471
466
  function columnNamed(name, fields) {
472
- const asked2 = name.trim().replace(/^\{|\}$/g, "").toLowerCase();
473
- return fields.find((f) => f.id === name) ?? fields.find((f) => f.key.toLowerCase() === asked2) ?? fields.find((f) => fieldName(f).toLowerCase() === asked2);
467
+ const asked3 = name.trim().replace(/^\{|\}$/g, "").toLowerCase();
468
+ return fields.find((f) => f.id === name) ?? fields.find((f) => f.key.toLowerCase() === asked3) ?? fields.find((f) => fieldName(f).toLowerCase() === asked3);
474
469
  }
475
470
  function settable(field2) {
476
471
  return field2.type !== "formula" && field2.source !== "formula";
@@ -1165,31 +1160,31 @@ var FILES = /* @__PURE__ */ new WeakMap();
1165
1160
  function signatureFilesOf(client, recordId) {
1166
1161
  let held = SOURCES.get(client);
1167
1162
  if (!held) SOURCES.set(client, held = /* @__PURE__ */ new Map());
1168
- let asked2 = held.get(recordId);
1169
- if (!asked2) {
1170
- asked2 = client.recordValuesVersioned({ record_id: recordId }).then((answered) => {
1163
+ let asked3 = held.get(recordId);
1164
+ if (!asked3) {
1165
+ asked3 = client.recordValuesVersioned({ record_id: recordId }).then((answered) => {
1171
1166
  if (!answered.ok) return {};
1172
1167
  return Object.fromEntries(answered.data.map((v) => [v.field_key, signatureFileOf(v.source)]));
1173
1168
  });
1174
- held.set(recordId, asked2);
1169
+ held.set(recordId, asked3);
1175
1170
  }
1176
- return asked2;
1171
+ return asked3;
1177
1172
  }
1178
1173
  function drawingOf(client, fileId) {
1179
1174
  let held = FILES.get(client);
1180
1175
  if (!held) FILES.set(client, held = /* @__PURE__ */ new Map());
1181
- let asked2 = held.get(fileId);
1182
- if (!asked2) {
1183
- asked2 = client.recordRead({ record_id: fileId }).then((answered) => {
1176
+ let asked3 = held.get(fileId);
1177
+ if (!asked3) {
1178
+ asked3 = client.recordRead({ record_id: fileId }).then((answered) => {
1184
1179
  if (!answered.ok) return { src: null, hostFileId: null };
1185
1180
  const doc = answered.data.document ?? {};
1186
1181
  const content = drawnSignatureOf(doc["content"]);
1187
1182
  const hostFileId = typeof doc["file_id"] === "string" && doc["file_id"] !== "" ? doc["file_id"] : null;
1188
1183
  return { src: content, hostFileId };
1189
1184
  });
1190
- held.set(fileId, asked2);
1185
+ held.set(fileId, asked3);
1191
1186
  }
1192
- return asked2;
1187
+ return asked3;
1193
1188
  }
1194
1189
  function DrawnImage({ src, inCell }) {
1195
1190
  return /* @__PURE__ */ jsx2(
@@ -1451,7 +1446,7 @@ function RecordLabelProvider({ children }) {
1451
1446
  const [iconsOf, setIconsOf] = useState2({});
1452
1447
  const [settled, setSettled] = useState2({});
1453
1448
  const [waitingLines, setWaitingLines] = useState2({});
1454
- const asked2 = useRef2(/* @__PURE__ */ new Set());
1449
+ const asked3 = useRef2(/* @__PURE__ */ new Set());
1455
1450
  const chased = useRef2(/* @__PURE__ */ new Set());
1456
1451
  const timers = useRef2(/* @__PURE__ */ new Map());
1457
1452
  const startWaitClock = useCallback((field2, target) => {
@@ -1489,8 +1484,8 @@ function RecordLabelProvider({ children }) {
1489
1484
  const want = useCallback(
1490
1485
  (field2) => {
1491
1486
  if (!pointsAtRecords(field2)) return;
1492
- if (asked2.current.has(field2.id)) return;
1493
- asked2.current.add(field2.id);
1487
+ if (asked3.current.has(field2.id)) return;
1488
+ asked3.current.add(field2.id);
1494
1489
  startWaitClock(field2, null);
1495
1490
  void (async () => {
1496
1491
  if (field2.type === "list") {
@@ -1581,7 +1576,7 @@ function RecordLabelProvider({ children }) {
1581
1576
  const once = choiceKeyName(field2.id, id);
1582
1577
  if (settled[field2.id] && !rereadFor.current.has(once)) {
1583
1578
  rereadFor.current.add(once);
1584
- asked2.current.delete(field2.id);
1579
+ asked3.current.delete(field2.id);
1585
1580
  want(field2);
1586
1581
  }
1587
1582
  return null;
@@ -2885,7 +2880,6 @@ function TableDetails({
2885
2880
  tableShapeChanged2(tableId);
2886
2881
  onSaved?.();
2887
2882
  };
2888
- const locked = table.metadata?.["locked"] === true;
2889
2883
  return /* @__PURE__ */ jsxs8("div", { className: "flex flex-col gap-2", "data-table-details": "", children: [
2890
2884
  /* @__PURE__ */ jsx10("span", { className: "font-medium", children: "About this table" }),
2891
2885
  /* @__PURE__ */ jsxs8("div", { className: "flex flex-col gap-1", children: [
@@ -2939,9 +2933,9 @@ function TableDetails({
2939
2933
  size: "sm",
2940
2934
  variant: "outline",
2941
2935
  disabled: busy,
2942
- onClick: () => void write(lockPatch(table, !locked), { metadata: table.metadata ?? {} }),
2936
+ onClick: () => void write(lockPatch(table, true), { metadata: table.metadata ?? {} }),
2943
2937
  "data-table-lock-on": "",
2944
- children: locked ? "Unlock" : "Lock"
2938
+ children: "Lock"
2945
2939
  }
2946
2940
  )
2947
2941
  ] }),
@@ -4789,8 +4783,8 @@ function FormulaTextEditor({
4789
4783
  const report = useRef8(onChecked);
4790
4784
  report.current = onChecked;
4791
4785
  useEffect11(() => {
4792
- const asked2 = text.trim();
4793
- if (asked2 === "") {
4786
+ const asked3 = text.trim();
4787
+ if (asked3 === "") {
4794
4788
  setParsed(null);
4795
4789
  setError(null);
4796
4790
  report.current(null);
@@ -4799,7 +4793,7 @@ function FormulaTextEditor({
4799
4793
  report.current(null);
4800
4794
  let cancelled = false;
4801
4795
  const timer = setTimeout(() => {
4802
- void client.formulaPreview({ table_id: tableId, record_id: sampled, text: asked2 }).then((previewed) => previewed.ok ? previewed : client.formulaParse({ table_id: tableId, text: asked2 })).then((answered) => {
4796
+ void client.formulaPreview({ table_id: tableId, record_id: sampled, text: asked3 }).then((previewed) => previewed.ok ? previewed : client.formulaParse({ table_id: tableId, text: asked3 })).then((answered) => {
4803
4797
  if (cancelled) return;
4804
4798
  if (!answered.ok) {
4805
4799
  setError(answered.error);
@@ -6834,8 +6828,10 @@ var RELATIVE_DAY_TERMS = [
6834
6828
  { kind: "past_days", label: "is in the past \u2026 days", takesDays: true }
6835
6829
  ];
6836
6830
  function relativeDayNode(fieldId, kind, days) {
6831
+ const zone2 = getPersonTimeZone();
6837
6832
  const window2 = { relative: kind };
6838
6833
  if (RELATIVE_DAY_TERMS.find((t) => t.kind === kind)?.takesDays) window2["n"] = days ?? 7;
6834
+ if (zone2) window2["tz"] = zone2;
6839
6835
  return { op: "within", args: [{ field: fieldId }, { const: window2 }] };
6840
6836
  }
6841
6837
  function relativeDayOf(expr) {
@@ -8505,8 +8501,8 @@ function FieldEditor(props) {
8505
8501
  const entityMutation = useEntityFieldMutation();
8506
8502
  const mutation = onEntity ? { saving: entityMutation.saving, error: entityMutation.error } : { saving: tableMutation.saving, error: tableMutation.error };
8507
8503
  const client = useRecordsClient11();
8508
- const mayShape = onEntity ? entityRights.data?.may_declare === true : tableRights2.schema;
8509
- const whyNot = onEntity ? entityRights.data?.reason ?? null : tableRights2.why("schema");
8504
+ const mayShape = onEntity ? entityRights.data?.may_declare === true : tableRights2.structure;
8505
+ const whyNot = onEntity ? entityRights.data?.reason ?? null : tableRights2.why("structure");
8510
8506
  const storeLabel = onEntity ? entityRights.data?.label ?? null : table.data?.name ?? null;
8511
8507
  const tableLabel = props.tableLabel ?? storeLabel;
8512
8508
  const offered = onEntity ? STANDARD_TABLE_FIELD_CHOICES : FIELD_TYPE_CHOICES;
@@ -10171,7 +10167,7 @@ function judgeTyped(field2, text, choices, nudge) {
10171
10167
  const allowOther = allowsOtherValues(field2);
10172
10168
  const parts = [];
10173
10169
  const add = [];
10174
- const ask = [];
10170
+ const ask2 = [];
10175
10171
  const notChoices = [];
10176
10172
  let keepOffered = allowOther;
10177
10173
  for (const word of words2) {
@@ -10182,16 +10178,16 @@ function judgeTyped(field2, text, choices, nudge) {
10182
10178
  parts.push(decided.words);
10183
10179
  if (decided.decision === "add") add.push(decided.words);
10184
10180
  else if (decided.decision === "ask") {
10185
- ask.push(decided.words);
10181
+ ask2.push(decided.words);
10186
10182
  keepOffered = keepOffered && decided.keepOffered;
10187
10183
  } else if (decided.decision === "not_a_choice") notChoices.push(decided.words);
10188
10184
  }
10189
10185
  }
10190
10186
  const valueOf2 = (list) => several ? list : list[0] ?? null;
10191
10187
  if (notChoices.length > 0) return { refusal: notAChoiceSentence(field2, notChoices), cancelOnly: true };
10192
- if (ask.length > 0) {
10188
+ if (ask2.length > 0) {
10193
10189
  return {
10194
- ask: { words: ask, keepOffered, onAdd: choiceAddition(valueOf2(parts), [...add, ...ask]), asTyped: valueOf2(parts) }
10190
+ ask: { words: ask2, keepOffered, onAdd: choiceAddition(valueOf2(parts), [...add, ...ask2]), asTyped: valueOf2(parts) }
10195
10191
  };
10196
10192
  }
10197
10193
  if (add.length > 0) return { value: choiceAddition(valueOf2(parts), add) };
@@ -11112,7 +11108,7 @@ function WhoChangedSource({
11112
11108
  const membersPort = host.members;
11113
11109
  const [answers, setAnswers] = useState33({});
11114
11110
  const [roster, setRoster] = useState33({});
11115
- const asked2 = useRef19(/* @__PURE__ */ new Set());
11111
+ const asked3 = useRef19(/* @__PURE__ */ new Set());
11116
11112
  useEffect23(() => {
11117
11113
  if (!membersPort) return;
11118
11114
  let cancelled = false;
@@ -11129,14 +11125,14 @@ function WhoChangedSource({
11129
11125
  cancelled = true;
11130
11126
  };
11131
11127
  }, [membersPort]);
11132
- const ask = useCallback9(
11128
+ const ask2 = useCallback9(
11133
11129
  (fieldKey, recordId) => {
11134
11130
  const key = `${recordId}|${fieldKey}`;
11135
- if (asked2.current.has(key)) return;
11136
- asked2.current.add(key);
11131
+ if (asked3.current.has(key)) return;
11132
+ asked3.current.add(key);
11137
11133
  void client.fieldHistory({ table_id: tableId, field_key: fieldKey, record_id: recordId, limit: 1 }).then((answered) => {
11138
11134
  if (!answered.ok) {
11139
- asked2.current.delete(key);
11135
+ asked3.current.delete(key);
11140
11136
  return;
11141
11137
  }
11142
11138
  setAnswers((now) => ({ ...now, [key]: { entry: answered.data[0] ?? null } }));
@@ -11147,11 +11143,11 @@ function WhoChangedSource({
11147
11143
  const value = useMemo13(
11148
11144
  () => ({
11149
11145
  answerFor: (fieldKey, recordId) => answers[`${recordId}|${fieldKey}`],
11150
- ask,
11146
+ ask: ask2,
11151
11147
  resolve: (userId) => roster[userId] ?? null,
11152
11148
  labelOf
11153
11149
  }),
11154
- [answers, ask, roster, labelOf]
11150
+ [answers, ask2, roster, labelOf]
11155
11151
  );
11156
11152
  return /* @__PURE__ */ jsx43(WhoChangedContext.Provider, { value, children });
11157
11153
  }
@@ -12100,7 +12096,7 @@ function WhoBadge({
12100
12096
  onPressedTwice
12101
12097
  }) {
12102
12098
  const who = useWhoChanged(field2.key, row.id);
12103
- const ask = who.ask;
12099
+ const ask2 = who.ask;
12104
12100
  return (
12105
12101
  // NEVER PART OF THE CELL'S TEXT (merged-grid review 2): its words are drawn from an attribute
12106
12102
  // by CSS, so copying the page, a range or the cell never carries "who?". It is a pointer
@@ -12117,7 +12113,7 @@ function WhoBadge({
12117
12113
  "aria-label": `Who changed ${fieldName(field2)}?`,
12118
12114
  title: who.sentence ?? `Who changed ${fieldName(field2)}? (Option-Shift-H)`,
12119
12115
  className: "hidden max-w-[9rem] shrink-0 select-none items-center truncate rounded px-1 text-[10px] leading-4 text-muted-foreground before:content-[attr(data-who-text)] hover:bg-muted in-data-[matrx-cell-active=true]:inline-flex",
12120
- onMouseEnter: ask,
12116
+ onMouseEnter: ask2,
12121
12117
  onClick: (event) => {
12122
12118
  event.preventDefault();
12123
12119
  event.stopPropagation();
@@ -13849,7 +13845,7 @@ function ActionConfirm({
13849
13845
  );
13850
13846
  }
13851
13847
  function rowActionMenuItems(args) {
13852
- const { rowId, actions, mayRun, whyNot, fields, run, ask } = args;
13848
+ const { rowId, actions, mayRun, whyNot, fields, run, ask: ask2 } = args;
13853
13849
  const items = actions.runnable.map((action3) => ({
13854
13850
  id: `row-action-${action3.id}`,
13855
13851
  label: `Run: ${action3.name}`,
@@ -13857,9 +13853,9 @@ function rowActionMenuItems(args) {
13857
13853
  disabledReason: mayRun ? void 0 : whyNot,
13858
13854
  onSelect: () => run(action3, rowId)
13859
13855
  }));
13860
- if (ask) {
13856
+ if (ask2) {
13861
13857
  for (const action3 of actions.agent) {
13862
- items.push({ id: `row-agent-${action3.id}`, label: `Ask: ${action3.name}`, icon: "zap", onSelect: () => ask(action3, rowId) });
13858
+ items.push({ id: `row-agent-${action3.id}`, label: `Ask: ${action3.name}`, icon: "zap", onSelect: () => ask2(action3, rowId) });
13863
13859
  }
13864
13860
  }
13865
13861
  for (const action3 of actions.notRunnable) {
@@ -14506,8 +14502,8 @@ function useColumnSummaries(args) {
14506
14502
  const filterKey = JSON.stringify(args.filter ?? {});
14507
14503
  useEffect33(() => {
14508
14504
  const entries = JSON.parse(chosenKey);
14509
- const asked2 = JSON.parse(filterKey);
14510
- const filter = Object.keys(asked2).length > 0 ? asked2 : void 0;
14505
+ const asked3 = JSON.parse(filterKey);
14506
+ const filter = Object.keys(asked3).length > 0 ? asked3 : void 0;
14511
14507
  if (entries.length === 0) {
14512
14508
  setValues({});
14513
14509
  setError(null);
@@ -15482,11 +15478,11 @@ function useMergedGridControls(args) {
15482
15478
  const [keys, filters, base2, searched] = JSON.parse(countQuestionKey);
15483
15479
  for (const key of keys) {
15484
15480
  const { [key]: _own, ...others } = filters;
15485
- const asked2 = storeQuestion(fieldsRef.current, base2 ?? void 0, others);
15481
+ const asked3 = storeQuestion(fieldsRef.current, base2 ?? void 0, others);
15486
15482
  void (0, askOnce_exports.askOnce)(
15487
15483
  client,
15488
- `value_counts:${tableId}:${key}:${searched}:${JSON.stringify(asked2.filter ?? null)}`,
15489
- () => client.recordAggregate({ table_id: tableId, groupBy: [key], measures: [{ op: "count" }], ...asked2.filter ? { filter: asked2.filter } : {}, ...searched ? { search: searched } : {}, limit: 500 }),
15484
+ `value_counts:${tableId}:${key}:${searched}:${JSON.stringify(asked3.filter ?? null)}`,
15485
+ () => client.recordAggregate({ table_id: tableId, groupBy: [key], measures: [{ op: "count" }], ...asked3.filter ? { filter: asked3.filter } : {}, ...searched ? { search: searched } : {}, limit: 500 }),
15490
15486
  VALUE_COUNTS_FRESH_MS
15491
15487
  ).then((answer) => {
15492
15488
  if (cancelled || !answer.ok) return;
@@ -15540,7 +15536,7 @@ function useMergedGridControls(args) {
15540
15536
  [notify]
15541
15537
  );
15542
15538
  const ctx = useMemo21(() => {
15543
- const mayStructure = rights.schema && editable;
15539
+ const mayStructure = rights.structure && editable;
15544
15540
  const summaries = args.summaries;
15545
15541
  const firstKey = fieldKeys[0];
15546
15542
  return {
@@ -15569,7 +15565,7 @@ function useMergedGridControls(args) {
15569
15565
  id: "col-duplicate",
15570
15566
  label: "Duplicate property",
15571
15567
  icon: "copy-plus",
15572
- disabledReason: mayStructure ? void 0 : editable ? rights.why("schema") : "Editing is off here.",
15568
+ disabledReason: mayStructure ? void 0 : editable ? rights.why("structure") : "Editing is off here.",
15573
15569
  // DUPLICATE PROPERTY (Notion N5): one door declares the copy right after this column and copies
15574
15570
  // every record's value into it (`custom.field_duplicate`); nothing to fill in, as in Notion.
15575
15571
  onSelect: () => {
@@ -15606,14 +15602,14 @@ function useMergedGridControls(args) {
15606
15602
  id: "table-row-label",
15607
15603
  label: "What names each record\u2026",
15608
15604
  icon: "tag",
15609
- disabledReason: mayStructure ? void 0 : editable ? rights.why("schema") : "Editing is off here.",
15605
+ disabledReason: mayStructure ? void 0 : editable ? rights.why("structure") : "Editing is off here.",
15610
15606
  onSelect: () => setLabelling(true)
15611
15607
  },
15612
15608
  {
15613
15609
  id: "table-row-actions",
15614
15610
  label: ROW_ACTIONS_MENU_LABEL,
15615
15611
  icon: "zap",
15616
- disabledReason: mayStructure ? void 0 : editable ? rights.why("schema") : "Editing is off here.",
15612
+ disabledReason: mayStructure ? void 0 : editable ? rights.why("structure") : "Editing is off here.",
15617
15613
  onSelect: () => setRowActionsOpen(true)
15618
15614
  },
15619
15615
  // CLEAN THE WHOLE TABLE AT ONCE (the Sheet's CellCleanupButton): every text column, one review.
@@ -15643,7 +15639,7 @@ function useMergedGridControls(args) {
15643
15639
  mayAddRecord: editable && rights.write,
15644
15640
  whyNotAdd: editable ? rights.why("write") : "Editing is off here.",
15645
15641
  mayStructure,
15646
- whyNotStructure: editable ? rights.why("schema") : "Editing is off here.",
15642
+ whyNotStructure: editable ? rights.why("structure") : "Editing is off here.",
15647
15643
  cleanable: (field2) => isTextColumn(field2),
15648
15644
  typeable: (columnId2) => {
15649
15645
  const field2 = fields.find((f) => f.key === columnId2);
@@ -15723,7 +15719,7 @@ function useMergedGridControls(args) {
15723
15719
  if (href) copyText16(new URL(href, window.location.origin).toString(), "The link");
15724
15720
  }
15725
15721
  } : {},
15726
- ...editable && rights.schema ? {
15722
+ ...editable && rights.structure ? {
15727
15723
  saveAsTemplate: (rowId) => {
15728
15724
  const row = rows.find((r) => r.id === rowId);
15729
15725
  if (row) setDialog({ kind: "template", row });
@@ -16175,7 +16171,7 @@ var ADDABLE_TYPE_SET = new Set(ADDABLE_TYPES.map((t) => t.value));
16175
16171
  function customFieldRequestProblems(requests, existingLabels) {
16176
16172
  const problems = [];
16177
16173
  const taken = new Set(existingLabels.map((l) => l.trim().toLowerCase()));
16178
- const asked2 = /* @__PURE__ */ new Set();
16174
+ const asked3 = /* @__PURE__ */ new Set();
16179
16175
  if (requests.length === 0) problems.push("Name at least one field to add.");
16180
16176
  requests.forEach((request, index) => {
16181
16177
  const at = requests.length > 1 ? `Field ${index + 1}: ` : "";
@@ -16208,8 +16204,8 @@ function customFieldRequestProblems(requests, existingLabels) {
16208
16204
  }
16209
16205
  const key = label.toLowerCase();
16210
16206
  if (taken.has(key)) problems.push(`${at}there is already a field named "${label}".`);
16211
- else if (asked2.has(key)) problems.push(`${at}"${label}" is asked for twice.`);
16212
- asked2.add(key);
16207
+ else if (asked3.has(key)) problems.push(`${at}"${label}" is asked for twice.`);
16208
+ asked3.add(key);
16213
16209
  });
16214
16210
  return problems;
16215
16211
  }
@@ -17023,15 +17019,15 @@ function useAddedRows(args) {
17023
17019
  setAnchors(/* @__PURE__ */ new Map());
17024
17020
  }, [pageKey, tableId]);
17025
17021
  const pinnedKey = added.map((r) => r.id).join(",");
17026
- const asked2 = useRef28(0);
17022
+ const asked3 = useRef28(0);
17027
17023
  useEffect40(() => {
17028
17024
  if (!enabled || added.length === 0) return;
17029
17025
  const onPage = new Set(pageRows.map((r) => r.id));
17030
17026
  const missing = added.filter((r) => !onPage.has(r.id)).map((r) => r.id);
17031
17027
  if (missing.length === 0) return;
17032
- const ticket = asked2.current += 1;
17028
+ const ticket = asked3.current += 1;
17033
17029
  void client.listByIds({ table_id: tableId, ids: missing }).then((answer) => {
17034
- if (ticket !== asked2.current || !answer.ok) return;
17030
+ if (ticket !== asked3.current || !answer.ok) return;
17035
17031
  const fresh = new Map(answer.data.map((r) => [r.id, r]));
17036
17032
  setAdded(
17037
17033
  (held) => held.flatMap((row) => {
@@ -17152,17 +17148,17 @@ function NewRecordControl({
17152
17148
  busy,
17153
17149
  onAdd,
17154
17150
  onCreated,
17155
- ask
17151
+ ask: ask2
17156
17152
  }) {
17157
17153
  const [formOpen, setFormOpen] = useState51(false);
17158
17154
  const [formInitial, setFormInitial] = useState51({});
17159
17155
  const seenAsk = useRef28(0);
17160
17156
  useEffect40(() => {
17161
- if (!ask || ask.n === seenAsk.current) return;
17162
- seenAsk.current = ask.n;
17163
- setFormInitial(ask.initial);
17157
+ if (!ask2 || ask2.n === seenAsk.current) return;
17158
+ seenAsk.current = ask2.n;
17159
+ setFormInitial(ask2.initial);
17164
17160
  setFormOpen(true);
17165
- }, [ask]);
17161
+ }, [ask2]);
17166
17162
  return /* @__PURE__ */ jsxs57(Fragment17, { children: [
17167
17163
  /* @__PURE__ */ jsxs57("div", { className: "inline-flex shrink-0", "data-records-new-record": "", children: [
17168
17164
  /* @__PURE__ */ jsx62(Button34, { size: "sm", className: "rounded-r-none", disabled: busy, onClick: onAdd, children: busy ? "Adding\u2026" : "New record" }),
@@ -17228,7 +17224,7 @@ import {
17228
17224
  drillRequestKey,
17229
17225
  parseDimensionRef
17230
17226
  } from "@ai-matrx/design-system/data-table";
17231
- var askId = (ask) => `${ask.outer ?? ""}|${ask.fact}`;
17227
+ var askId = (ask2) => `${ask2.outer ?? ""}|${ask2.fact}`;
17232
17228
  function valueOf(v) {
17233
17229
  return v === null || v === void 0 || v === "" ? null : String(v);
17234
17230
  }
@@ -17270,14 +17266,14 @@ function drillLevelAsks(args) {
17270
17266
  }
17271
17267
  return { attributes, focus, names };
17272
17268
  }
17273
- function drillLevelHeld(ask, rows) {
17269
+ function drillLevelHeld(ask2, rows) {
17274
17270
  const held = {};
17275
17271
  for (const row of rows) {
17276
17272
  if (row.kind !== "group" || !row.groups) continue;
17277
- const g = ask.outer ? valueOf(row.groups[ask.outer]) : "\0";
17273
+ const g = ask2.outer ? valueOf(row.groups[ask2.outer]) : "\0";
17278
17274
  if (g === null) continue;
17279
- const v = valueOf(row.groups[ask.fact]);
17280
- (held[g] ??= /* @__PURE__ */ new Map()).set(v, row.labels?.[ask.fact] ?? null);
17275
+ const v = valueOf(row.groups[ask2.fact]);
17276
+ (held[g] ??= /* @__PURE__ */ new Map()).set(v, row.labels?.[ask2.fact] ?? null);
17281
17277
  }
17282
17278
  return held;
17283
17279
  }
@@ -17301,20 +17297,20 @@ function useDrillLevelReads(args) {
17301
17297
  let cancelled = false;
17302
17298
  const parsed = JSON.parse(key);
17303
17299
  void Promise.all(
17304
- parsed.all.map(async (ask) => {
17305
- const by = ask.outer ? [ask.outer, ask.fact] : [ask.fact];
17300
+ parsed.all.map(async (ask2) => {
17301
+ const by = ask2.outer ? [ask2.outer, ask2.fact] : [ask2.fact];
17306
17302
  const got = await client.drillAsk({
17307
17303
  source: parsed.source,
17308
17304
  question: {
17309
17305
  by,
17310
17306
  show: ["count"],
17311
- where: ask.where,
17307
+ where: ask2.where,
17312
17308
  ...parsed.window ? { window: parsed.window } : {},
17313
17309
  ...parsed.lane ? { lane: parsed.lane } : {}
17314
17310
  }
17315
17311
  }).catch((e) => ({ ok: false, error: { message: e instanceof Error ? e.message : "" } }));
17316
- if (!got.ok) return { ask, rows: [], failed: refusalSentence(got.error) || "Not read" };
17317
- return { ask, rows: got.data.rows, failed: null };
17312
+ if (!got.ok) return { ask: ask2, rows: [], failed: refusalSentence(got.error) || "Not read" };
17313
+ return { ask: ask2, rows: got.data.rows, failed: null };
17318
17314
  })
17319
17315
  ).then((results) => {
17320
17316
  if (cancelled) return;
@@ -17333,41 +17329,41 @@ function useDrillLevelReads(args) {
17333
17329
  const ready = state.key === key;
17334
17330
  const dim = (k) => dimensions.find((d) => d.key === k);
17335
17331
  const outer2 = question.by[0] ?? null;
17336
- const attributes = asks.attributes.length === 0 || !outer2 ? void 0 : asks.attributes.map((ask) => {
17337
- const d = dim(ask.fact);
17338
- const why = ready ? state.failed[askId(ask)] : void 0;
17332
+ const attributes = asks.attributes.length === 0 || !outer2 ? void 0 : asks.attributes.map((ask2) => {
17333
+ const d = dim(ask2.fact);
17334
+ const why = ready ? state.failed[askId(ask2)] : void 0;
17339
17335
  return {
17340
- key: ask.fact,
17341
- label: d?.label ?? ask.fact,
17336
+ key: ask2.fact,
17337
+ label: d?.label ?? ask2.fact,
17342
17338
  ...d?.description ? { description: d.description } : {},
17343
17339
  ...why ? { error: why } : {},
17344
17340
  read: (groups) => {
17345
17341
  if (!ready) return void 0;
17346
17342
  const g = groups[outer2];
17347
- return g ? drillFactWords(state.held[askId(ask)]?.[g], d) : null;
17343
+ return g ? drillFactWords(state.held[askId(ask2)]?.[g], d) : null;
17348
17344
  }
17349
17345
  };
17350
17346
  });
17351
- const focusAttributes = asks.focus.length === 0 ? void 0 : asks.focus.map((ask) => {
17352
- const d = dim(ask.fact);
17353
- const why = ready ? state.failed[askId(ask)] : void 0;
17347
+ const focusAttributes = asks.focus.length === 0 ? void 0 : asks.focus.map((ask2) => {
17348
+ const d = dim(ask2.fact);
17349
+ const why = ready ? state.failed[askId(ask2)] : void 0;
17354
17350
  return {
17355
- key: ask.fact,
17356
- label: d?.label ?? ask.fact,
17357
- value: ready ? drillFactWords(state.held[askId(ask)]?.["\0"], d) : void 0,
17351
+ key: ask2.fact,
17352
+ label: d?.label ?? ask2.fact,
17353
+ value: ready ? drillFactWords(state.held[askId(ask2)]?.["\0"], d) : void 0,
17358
17354
  ...why ? { error: why } : {}
17359
17355
  };
17360
17356
  });
17361
17357
  const names = /* @__PURE__ */ new Map();
17362
17358
  if (ready) {
17363
- for (const ask of asks.names) {
17364
- if (!ask.outer) continue;
17365
- const out = names.get(ask.outer) ?? /* @__PURE__ */ new Map();
17366
- for (const [value, facts] of Object.entries(state.held[askId(ask)] ?? {})) {
17367
- const words2 = drillFactWords(facts, dim(ask.fact));
17359
+ for (const ask2 of asks.names) {
17360
+ if (!ask2.outer) continue;
17361
+ const out = names.get(ask2.outer) ?? /* @__PURE__ */ new Map();
17362
+ for (const [value, facts] of Object.entries(state.held[askId(ask2)] ?? {})) {
17363
+ const words2 = drillFactWords(facts, dim(ask2.fact));
17368
17364
  if (words2 && words2 !== "Several") out.set(value, words2);
17369
17365
  }
17370
- names.set(ask.outer, out);
17366
+ names.set(ask2.outer, out);
17371
17367
  }
17372
17368
  }
17373
17369
  return { attributes, focusAttributes, names };
@@ -17496,33 +17492,33 @@ function useDrillAnswers(args) {
17496
17492
  });
17497
17493
  useEffect42(() => {
17498
17494
  if (!enabled || !source || question.by.length === 0) return;
17499
- const asked2 = JSON.parse(askKey2);
17500
- const range = asked2.window && asked2.windowKey ? drillWindowRange(asked2.window) : null;
17501
- const compare = asked2.compare && range && asked2.windowKey ? {
17502
- against: asked2.compare,
17495
+ const asked3 = JSON.parse(askKey2);
17496
+ const range = asked3.window && asked3.windowKey ? drillWindowRange(asked3.window) : null;
17497
+ const compare = asked3.compare && range && asked3.windowKey ? {
17498
+ against: asked3.compare,
17503
17499
  from: range.from,
17504
17500
  to: range.to,
17505
- ...asked2.source.kind === "table" ? { key: asked2.windowKey } : {}
17501
+ ...asked3.source.kind === "table" ? { key: asked3.windowKey } : {}
17506
17502
  } : void 0;
17507
17503
  let cancelled = false;
17508
17504
  setAnswers({});
17509
17505
  setError(null);
17510
- const requests = drillRequests({ by: asked2.by, across: asked2.across, show: asked2.show, where: [] });
17506
+ const requests = drillRequests({ by: asked3.by, across: asked3.across, show: asked3.show, where: [] });
17511
17507
  void Promise.all(
17512
17508
  requests.map(async (request) => {
17513
- if (asked2.rule && asked2.source.kind === "table") {
17509
+ if (asked3.rule && asked3.source.kind === "table") {
17514
17510
  const time = request.by.find((ref) => parseDimensionRef2(ref).grain !== null) ?? null;
17515
17511
  const t = time ? parseDimensionRef2(time) : null;
17516
- const measures = asked2.show.map(storeMeasure).filter((m) => m !== null);
17512
+ const measures = asked3.show.map(storeMeasure).filter((m) => m !== null);
17517
17513
  if (t?.grain === "hour") return { request, error: "This table's periods start at a day; it cannot be read by the hour." };
17518
17514
  const got2 = await client.recordAggregate({
17519
- table_id: asked2.source.id,
17515
+ table_id: asked3.source.id,
17520
17516
  groupBy: request.by.filter((ref) => ref !== time),
17521
17517
  measures,
17522
17518
  bucket: t && t.grain ? { key: t.key, by: t.grain } : null,
17523
- filter: asked2.rule,
17519
+ filter: asked3.rule,
17524
17520
  limit: 200,
17525
- ...compare ? { compare: { against: compare.against, key: asked2.windowKey, from: compare.from, to: compare.to } } : {}
17521
+ ...compare ? { compare: { against: compare.against, key: asked3.windowKey, from: compare.from, to: compare.to } } : {}
17526
17522
  });
17527
17523
  if (!got2.ok) return { request, error: refusalSentence(got2.error) };
17528
17524
  return {
@@ -17546,13 +17542,13 @@ function useDrillAnswers(args) {
17546
17542
  };
17547
17543
  }
17548
17544
  const got = await client.drillAsk({
17549
- source: asked2.source,
17545
+ source: asked3.source,
17550
17546
  question: {
17551
17547
  by: request.by,
17552
- show: asked2.show,
17553
- where: asked2.where,
17554
- ...asked2.lane ? { lane: asked2.lane } : {},
17555
- ...range && asked2.windowKey ? { window: { key: asked2.windowKey, from: range.from, to: range.to } } : {},
17548
+ show: asked3.show,
17549
+ where: asked3.where,
17550
+ ...asked3.lane ? { lane: asked3.lane } : {},
17551
+ ...range && asked3.windowKey ? { window: { key: asked3.windowKey, from: range.from, to: range.to } } : {},
17556
17552
  ...compare ? { compare } : {}
17557
17553
  }
17558
17554
  });
@@ -20055,12 +20051,12 @@ function ImportWizard({ tableId, source, onDone, onWrote, className }) {
20055
20051
  }
20056
20052
  if (!skip) out[header] = ids.join("; ");
20057
20053
  }
20058
- for (const ask of dateAsks) {
20059
- const raw = String(row[ask.header] ?? "").trim();
20054
+ for (const ask2 of dateAsks) {
20055
+ const raw = String(row[ask2.header] ?? "").trim();
20060
20056
  if (raw === "") continue;
20061
- const day2 = ask.dates.read.get(at);
20062
- if (day2 !== void 0) out[ask.header] = day2;
20063
- else if ((dateMiss[ask.header] ?? "empty") === "empty") out[ask.header] = "";
20057
+ const day2 = ask2.dates.read.get(at);
20058
+ if (day2 !== void 0) out[ask2.header] = day2;
20059
+ else if ((dateMiss[ask2.header] ?? "empty") === "empty") out[ask2.header] = "";
20064
20060
  }
20065
20061
  sent.push(out);
20066
20062
  lines.push(combined?.lines[at]?.[0] ?? at + 1);
@@ -20074,8 +20070,8 @@ function ImportWizard({ tableId, source, onDone, onWrote, className }) {
20074
20070
  if (!plan) return;
20075
20071
  setProblem(null);
20076
20072
  if (nudge === "always_add" && rights.admin) {
20077
- for (const ask of newChoiceWords) {
20078
- if (!await addChoiceWords(ask.field, ask.words)) return;
20073
+ for (const ask2 of newChoiceWords) {
20074
+ if (!await addChoiceWords(ask2.field, ask2.words)) return;
20079
20075
  }
20080
20076
  }
20081
20077
  setOutcomes([]);
@@ -20083,12 +20079,12 @@ function ImportWizard({ tableId, source, onDone, onWrote, className }) {
20083
20079
  setProgress(0);
20084
20080
  setLedger(null);
20085
20081
  let index = relationIndex;
20086
- const toMerge = relationAsks.filter((ask) => choiceFor(ask.field.key).ambiguous === "merge" && ask.ambiguous.length > 0);
20082
+ const toMerge = relationAsks.filter((ask2) => choiceFor(ask2.field.key).ambiguous === "merge" && ask2.ambiguous.length > 0);
20087
20083
  if (toMerge.length > 0) {
20088
20084
  setPhase("linking");
20089
- for (const ask of toMerge) {
20090
- for (const [name] of ask.ambiguous) {
20091
- const hits = ask.index.byName.get(relationNameKey2(name)) ?? [];
20085
+ for (const ask2 of toMerge) {
20086
+ for (const [name] of ask2.ambiguous) {
20087
+ const hits = ask2.index.byName.get(relationNameKey2(name)) ?? [];
20092
20088
  const winner = hits[0];
20093
20089
  if (!winner) continue;
20094
20090
  for (const loser of hits.slice(1)) {
@@ -20112,15 +20108,15 @@ function ImportWizard({ tableId, source, onDone, onWrote, className }) {
20112
20108
  }
20113
20109
  index = reread;
20114
20110
  }
20115
- const toMake = relationAsks.filter((ask) => choiceFor(ask.field.key).unmatched === "create" && ask.unmatched.length > 0);
20111
+ const toMake = relationAsks.filter((ask2) => choiceFor(ask2.field.key).unmatched === "create" && ask2.unmatched.length > 0);
20116
20112
  if (toMake.length > 0) {
20117
20113
  setPhase("linking");
20118
- for (const ask of toMake) {
20119
- const title = ask.index.titleField;
20114
+ for (const ask2 of toMake) {
20115
+ const title = ask2.index.titleField;
20120
20116
  if (!title) continue;
20121
20117
  const made = await client.recordWriteMany({
20122
- table_id: ask.field.relation_target,
20123
- rows: ask.unmatched.map(([name]) => ({ [title]: name }))
20118
+ table_id: ask2.field.relation_target,
20119
+ rows: ask2.unmatched.map(([name]) => ({ [title]: name }))
20124
20120
  });
20125
20121
  if (!made.ok) {
20126
20122
  setProblem(made.error);
@@ -20601,20 +20597,20 @@ function ImportWizard({ tableId, source, onDone, onWrote, className }) {
20601
20597
  linesWord(repeats.map((r) => r.row + 1), lineWord),
20602
20598
  ")"
20603
20599
  ] }) : null,
20604
- newChoiceWords.map((ask) => {
20605
- const words2 = ask.words.map((w) => `\u201C${w}\u201D`).join(", ");
20606
- const column = fieldName(ask.field);
20600
+ newChoiceWords.map((ask2) => {
20601
+ const words2 = ask2.words.map((w) => `\u201C${w}\u201D`).join(", ");
20602
+ const column = fieldName(ask2.field);
20607
20603
  const canAdd = rights.admin && nudge !== "never_add";
20608
20604
  return /* @__PURE__ */ jsxs64(
20609
20605
  "div",
20610
20606
  {
20611
20607
  className: "flex flex-wrap items-center gap-2 rounded border border-amber-500/40 bg-amber-500/5 px-2 py-1.5",
20612
- "data-import-new-choices": ask.field.key,
20608
+ "data-import-new-choices": ask2.field.key,
20613
20609
  children: [
20614
20610
  /* @__PURE__ */ jsxs64("span", { children: [
20615
- ask.words.length === 1 ? `${words2} is not one of ${column}'s choices.` : `${words2} are not among ${column}'s choices.`,
20611
+ ask2.words.length === 1 ? `${words2} is not one of ${column}'s choices.` : `${words2} are not among ${column}'s choices.`,
20616
20612
  " ",
20617
- nudge === "always_add" && rights.admin ? `Your organization adds new choices without asking, so ${ask.words.length === 1 ? "it is" : "they are"} added when you import.` : canAdd ? `Add ${ask.words.length === 1 ? "it" : "them"}, or the rows that use ${ask.words.length === 1 ? "it" : "them"} are refused.` : `The rows that use ${ask.words.length === 1 ? "it" : "them"} are refused${rights.admin ? " (your organization does not add new choices from an import)" : " \u2014 only someone who manages this table can add choices"}.`
20613
+ nudge === "always_add" && rights.admin ? `Your organization adds new choices without asking, so ${ask2.words.length === 1 ? "it is" : "they are"} added when you import.` : canAdd ? `Add ${ask2.words.length === 1 ? "it" : "them"}, or the rows that use ${ask2.words.length === 1 ? "it" : "them"} are refused.` : `The rows that use ${ask2.words.length === 1 ? "it" : "them"} are refused${rights.admin ? " (your organization does not add new choices from an import)" : " \u2014 only someone who manages this table can add choices"}.`
20618
20614
  ] }),
20619
20615
  canAdd && nudge !== "always_add" ? /* @__PURE__ */ jsx69(
20620
20616
  Button39,
@@ -20622,26 +20618,26 @@ function ImportWizard({ tableId, source, onDone, onWrote, className }) {
20622
20618
  size: "sm",
20623
20619
  variant: "outline",
20624
20620
  disabled: busy || addingWords !== null,
20625
- onClick: () => void addChoiceWords(ask.field, ask.words),
20626
- children: addingWords === ask.field.key ? "Adding\u2026" : `Add to ${column}`
20621
+ onClick: () => void addChoiceWords(ask2.field, ask2.words),
20622
+ children: addingWords === ask2.field.key ? "Adding\u2026" : `Add to ${column}`
20627
20623
  }
20628
20624
  ) : null
20629
20625
  ]
20630
20626
  },
20631
- ask.field.key
20627
+ ask2.field.key
20632
20628
  );
20633
20629
  }),
20634
20630
  relationProblem ? /* @__PURE__ */ jsx69(RefusalNotice, { error: relationProblem }) : null,
20635
- relationAsks.map((ask) => {
20636
- const column = fieldName(ask.field);
20637
- const table2 = ask.index.tableName;
20638
- const choice = choiceFor(ask.field.key);
20639
- const setChoice = (patch) => setUnlinkedChoice((held) => ({ ...held, [ask.field.key]: { ...choice, ...patch } }));
20640
- const clean = ask.unmatched.length === 0 && ask.ambiguous.length === 0;
20631
+ relationAsks.map((ask2) => {
20632
+ const column = fieldName(ask2.field);
20633
+ const table2 = ask2.index.tableName;
20634
+ const choice = choiceFor(ask2.field.key);
20635
+ const setChoice = (patch) => setUnlinkedChoice((held) => ({ ...held, [ask2.field.key]: { ...choice, ...patch } }));
20636
+ const clean = ask2.unmatched.length === 0 && ask2.ambiguous.length === 0;
20641
20637
  return /* @__PURE__ */ jsxs64(
20642
20638
  "div",
20643
20639
  {
20644
- "data-import-relation": ask.field.key,
20640
+ "data-import-relation": ask2.field.key,
20645
20641
  className: cn37(
20646
20642
  "flex flex-col gap-1 rounded border px-2 py-1.5",
20647
20643
  clean ? "bg-muted/40" : "border-amber-500/40 bg-amber-500/5"
@@ -20650,21 +20646,21 @@ function ImportWizard({ tableId, source, onDone, onWrote, className }) {
20650
20646
  /* @__PURE__ */ jsxs64("span", { "data-import-relation-linked": "", children: [
20651
20647
  column,
20652
20648
  ": ",
20653
- ask.linked,
20649
+ ask2.linked,
20654
20650
  " of ",
20655
- ask.named,
20651
+ ask2.named,
20656
20652
  " rows link to ",
20657
20653
  table2,
20658
20654
  " by name"
20659
20655
  ] }),
20660
- ask.unmatched.length > 0 ? /* @__PURE__ */ jsxs64("div", { className: "flex flex-col gap-1", "data-import-relation-unmatched": "", children: [
20656
+ ask2.unmatched.length > 0 ? /* @__PURE__ */ jsxs64("div", { className: "flex flex-col gap-1", "data-import-relation-unmatched": "", children: [
20661
20657
  /* @__PURE__ */ jsxs64("span", { children: [
20662
20658
  "Not in ",
20663
20659
  table2,
20664
20660
  ":",
20665
20661
  " ",
20666
- ask.unmatched.slice(0, 6).map(([name, lines]) => `\u201C${name}\u201D (${linesWord(lines, lineWord)})`).join(", "),
20667
- ask.unmatched.length > 6 ? ` +${ask.unmatched.length - 6}` : ""
20662
+ ask2.unmatched.slice(0, 6).map(([name, lines]) => `\u201C${name}\u201D (${linesWord(lines, lineWord)})`).join(", "),
20663
+ ask2.unmatched.length > 6 ? ` +${ask2.unmatched.length - 6}` : ""
20668
20664
  ] }),
20669
20665
  /* @__PURE__ */ jsxs64("label", { className: "flex items-center gap-1", children: [
20670
20666
  /* @__PURE__ */ jsx69("span", { className: "text-muted-foreground", children: "Those rows" }),
@@ -20676,7 +20672,7 @@ function ImportWizard({ tableId, source, onDone, onWrote, className }) {
20676
20672
  disabled: busy,
20677
20673
  onChange: (picked) => setChoice({ unmatched: picked }),
20678
20674
  options: [
20679
- ...ask.index.titleField ? [{ value: "create", label: `add the names to ${table2}` }] : [],
20675
+ ...ask2.index.titleField ? [{ value: "create", label: `add the names to ${table2}` }] : [],
20680
20676
  { value: "empty", label: "import with no link" },
20681
20677
  { value: "skip", label: "are skipped" }
20682
20678
  ]
@@ -20684,13 +20680,13 @@ function ImportWizard({ tableId, source, onDone, onWrote, className }) {
20684
20680
  )
20685
20681
  ] })
20686
20682
  ] }) : null,
20687
- ask.ambiguous.length > 0 ? /* @__PURE__ */ jsxs64("div", { className: "flex flex-col gap-1", "data-import-relation-ambiguous": "", children: [
20683
+ ask2.ambiguous.length > 0 ? /* @__PURE__ */ jsxs64("div", { className: "flex flex-col gap-1", "data-import-relation-ambiguous": "", children: [
20688
20684
  /* @__PURE__ */ jsxs64("span", { children: [
20689
20685
  "More than one record in ",
20690
20686
  table2,
20691
20687
  ":",
20692
20688
  " ",
20693
- ask.ambiguous.slice(0, 6).map(([name, seen]) => `\u201C${name}\u201D \xD7${seen.count} (${linesWord(seen.lines, lineWord)})`).join(", ")
20689
+ ask2.ambiguous.slice(0, 6).map(([name, seen]) => `\u201C${name}\u201D \xD7${seen.count} (${linesWord(seen.lines, lineWord)})`).join(", ")
20694
20690
  ] }),
20695
20691
  /* @__PURE__ */ jsxs64("label", { className: "flex items-center gap-1", children: [
20696
20692
  /* @__PURE__ */ jsx69("span", { className: "text-muted-foreground", children: "Those rows" }),
@@ -20712,21 +20708,21 @@ function ImportWizard({ tableId, source, onDone, onWrote, className }) {
20712
20708
  ] }) : null
20713
20709
  ]
20714
20710
  },
20715
- ask.field.key
20711
+ ask2.field.key
20716
20712
  );
20717
20713
  }),
20718
- dateAsks.filter((ask) => ask.dates.unreadable.length > 0).map((ask) => {
20719
- const miss = ask.dates.unreadable;
20714
+ dateAsks.filter((ask2) => ask2.dates.unreadable.length > 0).map((ask2) => {
20715
+ const miss = ask2.dates.unreadable;
20720
20716
  const byWord = /* @__PURE__ */ new Map();
20721
20717
  for (const m of miss) byWord.set(m.raw, [...byWord.get(m.raw) ?? [], m.row + 1]);
20722
20718
  return /* @__PURE__ */ jsxs64(
20723
20719
  "div",
20724
20720
  {
20725
- "data-import-dates": ask.header,
20721
+ "data-import-dates": ask2.header,
20726
20722
  className: "flex flex-col gap-1 rounded border border-amber-500/40 bg-amber-500/5 px-2 py-1.5",
20727
20723
  children: [
20728
20724
  /* @__PURE__ */ jsxs64("span", { children: [
20729
- ask.label,
20725
+ ask2.label,
20730
20726
  ": ",
20731
20727
  miss.length,
20732
20728
  " ",
@@ -20741,10 +20737,10 @@ function ImportWizard({ tableId, source, onDone, onWrote, className }) {
20741
20737
  /* @__PURE__ */ jsx69(
20742
20738
  PickOne,
20743
20739
  {
20744
- label: `What cells of ${ask.header} that are not dates do`,
20745
- value: dateMiss[ask.header] ?? "empty",
20740
+ label: `What cells of ${ask2.header} that are not dates do`,
20741
+ value: dateMiss[ask2.header] ?? "empty",
20746
20742
  disabled: busy,
20747
- onChange: (picked) => setDateMiss((held) => ({ ...held, [ask.header]: picked })),
20743
+ onChange: (picked) => setDateMiss((held) => ({ ...held, [ask2.header]: picked })),
20748
20744
  options: [
20749
20745
  { value: "empty", label: "are left empty" },
20750
20746
  { value: "skip", label: "skip their rows" }
@@ -20754,7 +20750,7 @@ function ImportWizard({ tableId, source, onDone, onWrote, className }) {
20754
20750
  ] })
20755
20751
  ]
20756
20752
  },
20757
- ask.header
20753
+ ask2.header
20758
20754
  );
20759
20755
  }),
20760
20756
  ruleVerdicts.length > 0 ? /* @__PURE__ */ jsx69(
@@ -21724,13 +21720,13 @@ async function askColumnValues(inputs, args) {
21724
21720
  if (kind === "loaded") return null;
21725
21721
  const searched = args.search.trim();
21726
21722
  const { [args.columnId]: _own, ...others } = inputs.columnFilters;
21727
- const asked2 = storeQuestion(inputs.fields, inputs.filter, others);
21723
+ const asked3 = storeQuestion(inputs.fields, inputs.filter, others);
21728
21724
  const limit = Math.min(Math.max(args.limit, 1), MOST_VALUES);
21729
21725
  const answer = await inputs.client.recordAggregate({
21730
21726
  table_id: inputs.tableId,
21731
21727
  ...kind === "days" ? { bucket: { key: field2.key, by: "day" } } : { groupBy: [field2.key] },
21732
21728
  measures: [{ op: "count" }],
21733
- ...asked2.filter ? { filter: asked2.filter } : {},
21729
+ ...asked3.filter ? { filter: asked3.filter } : {},
21734
21730
  ...searched ? { search: searched } : {},
21735
21731
  limit: MOST_VALUES
21736
21732
  });
@@ -21743,7 +21739,7 @@ async function askColumnValues(inputs, args) {
21743
21739
  const unique = await inputs.client.recordAggregate({
21744
21740
  table_id: inputs.tableId,
21745
21741
  measures: [{ op: "unique", key: field2.key }],
21746
- ...asked2.filter ? { filter: asked2.filter } : {},
21742
+ ...asked3.filter ? { filter: asked3.filter } : {},
21747
21743
  ...searched ? { search: searched } : {}
21748
21744
  });
21749
21745
  if (unique.ok) {
@@ -21785,8 +21781,8 @@ function useGroupFacts(args) {
21785
21781
  }
21786
21782
  if (version === void 0 || version === null) return;
21787
21783
  const entries = JSON.parse(chosenKey);
21788
- const asked2 = JSON.parse(filterKey);
21789
- const filter = Object.keys(asked2).length > 0 ? asked2 : void 0;
21784
+ const asked3 = JSON.parse(filterKey);
21785
+ const filter = Object.keys(asked3).length > 0 ? asked3 : void 0;
21790
21786
  const measures = groupFactMeasures(Object.fromEntries(entries));
21791
21787
  let cancelled = false;
21792
21788
  void client.recordAggregate({ table_id: tableId, groupBy: [groupKey], measures, limit: 1e3, ...filter ? { filter } : {} }).then((answered) => {
@@ -23431,7 +23427,7 @@ function GridBody({
23431
23427
  if (appending || !embeddedMore) return;
23432
23428
  const requestAskKey = askKey2;
23433
23429
  setAppending(true);
23434
- const asked2 = await client.listPage({
23430
+ const asked3 = await client.listPage({
23435
23431
  table_id: tableId,
23436
23432
  ...pageFilter ? { filter: pageFilter } : {},
23437
23433
  search: pageSearch.trim() === "" ? null : pageSearch.trim(),
@@ -23442,8 +23438,8 @@ function GridBody({
23442
23438
  });
23443
23439
  if (embeddedAskKey.current !== requestAskKey) return;
23444
23440
  setAppending(false);
23445
- if (asked2.ok) {
23446
- setAppendedRows((held) => [...held, ...asked2.data.rows]);
23441
+ if (asked3.ok) {
23442
+ setAppendedRows((held) => [...held, ...asked3.data.rows]);
23447
23443
  setAppendedPhysicalPages((pages) => pages + 1);
23448
23444
  }
23449
23445
  }, [appending, embeddedMore, askKey2, client, tableId, pageFilter, pageSearch, pageSort, pageDoorViewId, nextEmbeddedPhysicalOffset]);
@@ -24411,7 +24407,7 @@ function GridBody({
24411
24407
  const offersRowActions = !embedded && (canWrite || Boolean(host.talkToRecord) || Boolean(!readOnly && host.runAgentAction && tableActions2.agent.length > 0));
24412
24408
  const hasTalk = Boolean(host.talkToRecord);
24413
24409
  const hasAgent = Boolean(host.runAgentAction);
24414
- const mayManageActions = !readOnly && rights.schema;
24410
+ const mayManageActions = !readOnly && rights.structure;
24415
24411
  const actionsHeader = useMemo35(
24416
24412
  () => /* @__PURE__ */ jsx77(ActionsHeaderControls, { ...mayManageActions ? { onAddColumn: () => addColumnNow.current() } : {} }),
24417
24413
  [mayManageActions]
@@ -24494,9 +24490,9 @@ function GridBody({
24494
24490
  (key) => holdByContent(headerHeld.current, `filter:${key}`, filterFor(key))
24495
24491
  );
24496
24492
  const pinnedPlus = offersRowActions && mayManageActions;
24497
- return merged && rights.schema && !readOnly && !pinnedPlus ? [...drawn, addColumnDef] : drawn;
24493
+ return merged && rights.structure && !readOnly && !pinnedPlus ? [...drawn, addColumnDef] : drawn;
24498
24494
  },
24499
- [bodyColumns, controls.headerMenuFor, controls.filterFor, merged, rights.schema, readOnly, addColumnDef, offersRowActions, mayManageActions]
24495
+ [bodyColumns, controls.headerMenuFor, controls.filterFor, merged, rights.structure, readOnly, addColumnDef, offersRowActions, mayManageActions]
24500
24496
  );
24501
24497
  const columnsHeld = useRef36(null);
24502
24498
  const columns = columnsHeld.current !== null && sameColumns(columnsHeld.current, drawnColumns) ? columnsHeld.current : drawnColumns;
@@ -24794,7 +24790,7 @@ function GridBody({
24794
24790
  }
24795
24791
  ) : null,
24796
24792
  viewId && viewOrder?.onPlaced && hasSeveralRows ? /* @__PURE__ */ jsx77(Button44, { size: "sm", variant: "ghost", onClick: () => setReordering(true), "data-records-reorder-open": "", children: "Reorder" }) : null,
24797
- !readOnly && rights.schema && onAddField ? /* @__PURE__ */ jsx77(AddFieldButton, { onClick: onAddField }) : null,
24793
+ !readOnly && rights.structure && onAddField ? /* @__PURE__ */ jsx77(AddFieldButton, { onClick: onAddField }) : null,
24798
24794
  embedded ? null : /* @__PURE__ */ jsx77(
24799
24795
  GridLayoutMenu,
24800
24796
  {
@@ -25111,7 +25107,7 @@ function GridBody({
25111
25107
  className: "flex flex-col items-start gap-2 rounded-md border border-dashed p-6",
25112
25108
  children: [
25113
25109
  /* @__PURE__ */ jsx77("p", { className: "text-sm font-medium", children: NO_COLUMNS_YET }),
25114
- rights.schema && onAddField ? /* @__PURE__ */ jsx77(Button44, { size: "sm", onClick: onAddField, children: "Add your first column" }) : /* @__PURE__ */ jsx77("p", { className: "max-w-prose text-xs text-muted-foreground", children: rights.why("schema") })
25110
+ rights.structure && onAddField ? /* @__PURE__ */ jsx77(Button44, { size: "sm", onClick: onAddField, children: "Add your first column" }) : /* @__PURE__ */ jsx77("p", { className: "max-w-prose text-xs text-muted-foreground", children: rights.why("structure") })
25115
25111
  ]
25116
25112
  }
25117
25113
  ) : /* @__PURE__ */ jsxs70(Fragment26, { children: [
@@ -25355,8 +25351,8 @@ function GridBody({
25355
25351
  }
25356
25352
  ) });
25357
25353
  }
25358
- function askWhenAColumnMenuIsReached(target, ask) {
25359
- if (target?.closest?.('[role="columnheader"], thead, [data-matrx-canonical-signature="column-menu"]')) ask();
25354
+ function askWhenAColumnMenuIsReached(target, ask2) {
25355
+ if (target?.closest?.('[role="columnheader"], thead, [data-matrx-canonical-signature="column-menu"]')) ask2();
25360
25356
  }
25361
25357
  var DETAIL_OFF = { enabled: false };
25362
25358
  var WINDOW_OFF = { enabled: false };
@@ -26265,9 +26261,9 @@ function whyNotAskable(fields, hidden = []) {
26265
26261
  const said2 = left.map((f) => `${f.label || f.key} ${CANNOT_ASK[f.type]}`);
26266
26262
  return said2.length === 1 ? `${said2[0]}, so it is not offered here.` : `These are not offered here: ${said2.join("; ")}.`;
26267
26263
  }
26268
- function requiredLeftUnasked(fields, asked2, storeFills = []) {
26264
+ function requiredLeftUnasked(fields, asked3, storeFills = []) {
26269
26265
  const missing = fields.filter(
26270
- (f) => f.required === true && !asked2.includes(f.key) && !storeFills.includes(f.key) && !COMPUTED.has(f.type)
26266
+ (f) => f.required === true && !asked3.includes(f.key) && !storeFills.includes(f.key) && !COMPUTED.has(f.type)
26271
26267
  );
26272
26268
  if (missing.length === 0) return null;
26273
26269
  const said2 = missing.map((f) => {
@@ -26369,7 +26365,7 @@ function BookingBuilder({ tableId, bookingId, onSaved, onClose, startNew, classN
26369
26365
  const [days, setDays] = useState67(30);
26370
26366
  const [timezone, setTimezone] = useState67(() => ownTimeZone());
26371
26367
  const [windows, setWindows] = useState67(() => draftWindows(null));
26372
- const [asked2, setAsked] = useState67([]);
26368
+ const [asked3, setAsked] = useState67([]);
26373
26369
  const [confirmation, setConfirmation] = useState67("");
26374
26370
  const [offer, setOffer] = useState67(null);
26375
26371
  const [formId, setFormId] = useState67(bookingId ?? null);
@@ -26379,7 +26375,7 @@ function BookingBuilder({ tableId, bookingId, onSaved, onClose, startNew, classN
26379
26375
  () => askableFields(fields.data ?? [], STORE_ANSWERS_THESE),
26380
26376
  [fields.data]
26381
26377
  );
26382
- const unfillable = requiredLeftUnasked(fields.data ?? [], asked2, STORE_ANSWERS_THESE);
26378
+ const unfillable = requiredLeftUnasked(fields.data ?? [], asked3, STORE_ANSWERS_THESE);
26383
26379
  const leftOut = useMemo38(
26384
26380
  () => whyNotAskable(fields.data ?? [], STORE_ANSWERS_THESE),
26385
26381
  [fields.data]
@@ -26447,7 +26443,7 @@ function BookingBuilder({ tableId, bookingId, onSaved, onClose, startNew, classN
26447
26443
  useEffect56(() => {
26448
26444
  if (startedAsking.current || !loaded || existing || formId || !fields.data) return;
26449
26445
  startedAsking.current = true;
26450
- if (asked2.length > 0) return;
26446
+ if (asked3.length > 0) return;
26451
26447
  const keys = askable.filter((f) => f.required || isWhoField(f)).map((f) => f.key);
26452
26448
  const first = askable[0]?.key;
26453
26449
  setAsked(keys.length > 0 ? keys : first ? [first] : []);
@@ -26486,7 +26482,7 @@ function BookingBuilder({ tableId, bookingId, onSaved, onClose, startNew, classN
26486
26482
  table_id: tableId,
26487
26483
  title: title.trim() === "" ? "Book a time" : title.trim(),
26488
26484
  // The Fields a visitor is asked for, in the order this screen shows them.
26489
- questions: asked2.map((key) => ({ field: key })),
26485
+ questions: asked3.map((key) => ({ field: key })),
26490
26486
  availability: availability(),
26491
26487
  presentation: {
26492
26488
  // THE SENTENCE AFTER THE BOOKING. It is the thank-you screen every other
@@ -26652,7 +26648,7 @@ function BookingBuilder({ tableId, bookingId, onSaved, onClose, startNew, classN
26652
26648
  /* @__PURE__ */ jsx83(
26653
26649
  Checkbox8,
26654
26650
  {
26655
- checked: asked2.includes(f.key),
26651
+ checked: asked3.includes(f.key),
26656
26652
  onCheckedChange: (on) => setAsked((prev) => on ? [...prev, f.key] : prev.filter((k) => k !== f.key))
26657
26653
  }
26658
26654
  ),
@@ -26843,7 +26839,7 @@ var ACTION_NO_ACCESS_REASON = "You don't have access";
26843
26839
  var ACTION_PLATFORM_TABLE_REASON = "Platform tables can't be changed here";
26844
26840
  function rightsReason(rights, what, table) {
26845
26841
  if (!rights.known) return ACTION_CHECKING_ACCESS_REASON;
26846
- if ((what === "structure" || what === "schema") && table?.is_kernel) return ACTION_PLATFORM_TABLE_REASON;
26842
+ if (what === "structure" && table?.is_kernel) return ACTION_PLATFORM_TABLE_REASON;
26847
26843
  if (rights[what]) return null;
26848
26844
  if (rights.level === null) return ACTION_NO_ACCESS_REASON;
26849
26845
  return `Needs ${LEVEL_WORD[levelNeededFor(what)]} access`;
@@ -26939,7 +26935,7 @@ function tableActions(input) {
26939
26935
  action({ id: "share", label: "Share\u2026", icon: "share-2", group: "share", verb: "share" }, "share", input, bind(host.share, table)),
26940
26936
  action({ id: "export", label: "Export\u2026", icon: "download", group: "share", verb: "export" }, "read", input, bind(host.export, table)),
26941
26937
  action({ id: "import", label: "Import\u2026", icon: "upload", group: "share", verb: "import" }, "structure", input, bind(host.import, table)),
26942
- action({ id: "add-column", label: ADD_FIELD_OPEN_LABEL, icon: "columns-3", group: "manage", rank: 1 }, "schema", input, bind(host.addColumn, table)),
26938
+ action({ id: "add-column", label: ADD_FIELD_OPEN_LABEL, icon: "columns-3", group: "manage", rank: 1 }, "structure", input, bind(host.addColumn, table)),
26943
26939
  action({ id: "settings", label: "Settings", icon: "settings", group: "manage", verb: "settings" }, "structure", input, bind(host.settings, table)),
26944
26940
  action({ id: "history", label: "History", icon: "history", group: "manage", verb: "history" }, "read", input, bind(host.history, table)),
26945
26941
  // custom.view_designate asks editor on the table — `canDesignate` in TablePage.
@@ -28538,7 +28534,7 @@ function StageRulesSection({ tableId, stage, className }) {
28538
28534
  const fields = useFields12(tableId);
28539
28535
  const [pipeline, setPipeline] = useState73(null);
28540
28536
  const [enforcement, setEnforcement] = useState73(null);
28541
- const [asked2, setAsked] = useState73(false);
28537
+ const [asked3, setAsked] = useState73(false);
28542
28538
  const [error, setError] = useState73(null);
28543
28539
  const [chosen, setChosen] = useState73(stage ?? null);
28544
28540
  const [draft, setDraft] = useState73(null);
@@ -28617,7 +28613,7 @@ function StageRulesSection({ tableId, stage, className }) {
28617
28613
  setPreview(null);
28618
28614
  await load();
28619
28615
  }
28620
- if (!asked2) return /* @__PURE__ */ jsx92(Skeleton9, { className: "h-24 w-full" });
28616
+ if (!asked3) return /* @__PURE__ */ jsx92(Skeleton9, { className: "h-24 w-full" });
28621
28617
  if (error && !pipeline) return /* @__PURE__ */ jsx92(RefusalNotice, { error });
28622
28618
  if (!pipeline?.is_pipeline) {
28623
28619
  return /* @__PURE__ */ jsxs83("div", { className: cn47("flex min-w-0 flex-col gap-2 text-xs", className), children: [
@@ -28807,20 +28803,20 @@ function tableNameProblem(typed2) {
28807
28803
  }
28808
28804
  function useRenameFromMenu() {
28809
28805
  const [open, setOpen] = useState74(false);
28810
- const asked2 = useRef38(false);
28811
- const ask = useCallback34(() => {
28812
- asked2.current = true;
28806
+ const asked3 = useRef38(false);
28807
+ const ask2 = useCallback34(() => {
28808
+ asked3.current = true;
28813
28809
  window.setTimeout(() => setOpen(true), 0);
28814
- window.setTimeout(() => asked2.current = false, 2e3);
28810
+ window.setTimeout(() => asked3.current = false, 2e3);
28815
28811
  }, []);
28816
28812
  const menuContentProps = {
28817
28813
  onCloseAutoFocus: (event) => {
28818
- if (!asked2.current) return;
28819
- asked2.current = false;
28814
+ if (!asked3.current) return;
28815
+ asked3.current = false;
28820
28816
  event.preventDefault();
28821
28817
  }
28822
28818
  };
28823
- return { open, setOpen, ask, menuContentProps };
28819
+ return { open, setOpen, ask: ask2, menuContentProps };
28824
28820
  }
28825
28821
  function TableRenameDialog({
28826
28822
  tableId,
@@ -29629,10 +29625,10 @@ function TableSettingsPanel({
29629
29625
  const archiveAskedSeen = useRef39(0);
29630
29626
  const panelReady = Boolean(table.data && fields.data && rights.structure);
29631
29627
  useEffect67(() => {
29632
- const ask = askToArchiveRef.current;
29633
- if (!panelReady || !ask || archiveAsked <= archiveAskedSeen.current) return;
29628
+ const ask2 = askToArchiveRef.current;
29629
+ if (!panelReady || !ask2 || archiveAsked <= archiveAskedSeen.current) return;
29634
29630
  archiveAskedSeen.current = archiveAsked;
29635
- void ask();
29631
+ void ask2();
29636
29632
  }, [archiveAsked, panelReady]);
29637
29633
  const [editing, setEditing] = useState80(null);
29638
29634
  const [askingToDelete, setAskingToDelete] = useState80(false);
@@ -29642,6 +29638,26 @@ function TableSettingsPanel({
29642
29638
  if (table.error) return /* @__PURE__ */ jsx99(RefusalNotice, { error: table.error, className });
29643
29639
  if (fields.error) return /* @__PURE__ */ jsx99(RefusalNotice, { error: fields.error, className });
29644
29640
  if (!rights.structure) {
29641
+ if (tableIsLocked(table.data)) {
29642
+ return /* @__PURE__ */ jsxs90("div", { className: cn50("flex flex-col items-start gap-2 text-xs text-muted-foreground", className), "data-table-locked": "", children: [
29643
+ /* @__PURE__ */ jsx99("p", { children: DATABASE_LOCKED_REASON }),
29644
+ /* @__PURE__ */ jsx99(
29645
+ Button61,
29646
+ {
29647
+ size: "sm",
29648
+ variant: "outline",
29649
+ onClick: () => {
29650
+ void saveTableLock(client, tableId, false).then((done) => {
29651
+ if (done.ok) table.reload();
29652
+ else ui.notify?.error(done.says);
29653
+ });
29654
+ },
29655
+ "data-table-unlock": "",
29656
+ children: "Unlock database"
29657
+ }
29658
+ )
29659
+ ] });
29660
+ }
29645
29661
  return /* @__PURE__ */ jsx99("p", { className: cn50("text-xs text-muted-foreground", className), children: rights.why("structure") });
29646
29662
  }
29647
29663
  const rows = [...fields.data ?? []].sort((a, b) => (a.sort ?? 0) - (b.sort ?? 0));
@@ -29741,26 +29757,8 @@ function TableSettingsPanel({
29741
29757
  /* @__PURE__ */ jsxs90("div", { className: "flex items-center gap-2", children: [
29742
29758
  /* @__PURE__ */ jsx99("span", { className: "font-medium", children: "Fields" }),
29743
29759
  /* @__PURE__ */ jsx99("span", { className: "text-muted-foreground", children: rows.length }),
29744
- /* @__PURE__ */ jsx99(Button61, { size: "sm", variant: "outline", className: "ml-auto", disabled: !rights.schema, onClick: () => setEditing("new"), children: "Add a field" })
29760
+ /* @__PURE__ */ jsx99(Button61, { size: "sm", variant: "outline", className: "ml-auto", onClick: () => setEditing("new"), children: "Add a field" })
29745
29761
  ] }),
29746
- tableIsLocked(table.data) ? /* @__PURE__ */ jsxs90("div", { className: "flex flex-wrap items-center gap-2 text-muted-foreground", "data-table-locked": "", children: [
29747
- /* @__PURE__ */ jsx99("span", { children: DATABASE_LOCKED_REASON }),
29748
- /* @__PURE__ */ jsx99(
29749
- Button61,
29750
- {
29751
- size: "sm",
29752
- variant: "outline",
29753
- onClick: () => {
29754
- void saveTableLock(client, tableId, false).then((done) => {
29755
- if (done.ok) table.reload();
29756
- else ui.notify?.error(done.says);
29757
- });
29758
- },
29759
- "data-table-unlock": "",
29760
- children: "Unlock database"
29761
- }
29762
- )
29763
- ] }) : null,
29764
29762
  shape.error ? /* @__PURE__ */ jsx99(RefusalNotice, { error: shape.error }) : null,
29765
29763
  askingToRemove ? /* @__PURE__ */ jsxs90("div", { className: "flex flex-wrap items-center gap-2 rounded border border-destructive/40 px-2 py-1.5", children: [
29766
29764
  /* @__PURE__ */ jsxs90("span", { className: "text-destructive", children: [
@@ -29779,7 +29777,7 @@ function TableSettingsPanel({
29779
29777
  ),
29780
29778
  /* @__PURE__ */ jsx99(Button61, { size: "sm", variant: "ghost", onClick: () => setAskingToRemove(null), children: "Keep it" })
29781
29779
  ] }) : null,
29782
- /* @__PURE__ */ jsx99("fieldset", { disabled: !rights.schema, className: "min-w-0 border-0 p-0", "data-columns-locked": rights.schema ? void 0 : "", children: /* @__PURE__ */ jsx99(
29780
+ /* @__PURE__ */ jsx99(
29783
29781
  ColumnsAtOnce,
29784
29782
  {
29785
29783
  rows,
@@ -29792,7 +29790,7 @@ function TableSettingsPanel({
29792
29790
  table.reload();
29793
29791
  }
29794
29792
  }
29795
- ) }),
29793
+ ),
29796
29794
  /* @__PURE__ */ jsx99(Separator8, {}),
29797
29795
  /* @__PURE__ */ jsx99(StageRulesSection, { tableId }),
29798
29796
  /* @__PURE__ */ jsx99(RowActionsSection, { tableId }),
@@ -30091,8 +30089,8 @@ function ShareControl({
30091
30089
  useEffect69(() => {
30092
30090
  if (initiallyOpen) setOpen(true);
30093
30091
  }, [initiallyOpen]);
30094
- const asked2 = useRecordRights(may === void 0 ? subjectId : null);
30095
- const mayShare = may ?? asked2.share;
30092
+ const asked3 = useRecordRights(may === void 0 ? subjectId : null);
30093
+ const mayShare = may ?? asked3.share;
30096
30094
  if (!host.share) return null;
30097
30095
  if (!mayShare) return whyNot ? /* @__PURE__ */ jsx102(ShareForSomebodyElse, { kind, whyNot, size, variant, className }) : null;
30098
30096
  return /* @__PURE__ */ jsxs93(Fragment37, { children: [
@@ -30580,7 +30578,7 @@ var LOOK_WORDS = {
30580
30578
  };
30581
30579
 
30582
30580
  // src/ViewSwitcher.tsx
30583
- import { useEffect as useEffect83, useMemo as useMemo58, useState as useState97 } from "react";
30581
+ import { useEffect as useEffect84, useMemo as useMemo58, useState as useState98 } from "react";
30584
30582
  import { mayDrag as mayDrag4, useFields as useFields18, useRecordPage as useRecordPage2, useRecordsClient as useRecordsClient66, useTable as useTable18 } from "@ai-matrx/records/react";
30585
30583
  import { isButtonField as isButtonField5, newerKindOf as newerKindOf7, stableFilterKey as stableFilterKey4 } from "@ai-matrx/records";
30586
30584
  import { Button as Button70, Select as Select17, SelectContent as SelectContent17, SelectItem as SelectItem17, SelectTrigger as SelectTrigger17, SelectValue as SelectValue17, cn as cn61 } from "@ai-matrx/design-system";
@@ -31212,14 +31210,14 @@ function PipelineBoard({
31212
31210
  setOver(null);
31213
31211
  setDragging(null);
31214
31212
  setPending({ kind: "asking", recordId, to });
31215
- const asked2 = await client.pipelineTransitionRefusal({ record_id: recordId, to });
31213
+ const asked3 = await client.pipelineTransitionRefusal({ record_id: recordId, to });
31216
31214
  if (!alive.current) return;
31217
- if (!asked2.ok) {
31218
- setPending({ kind: "clash", recordId, to, error: asked2.error });
31215
+ if (!asked3.ok) {
31216
+ setPending({ kind: "clash", recordId, to, error: asked3.error });
31219
31217
  onMoved?.();
31220
31218
  return;
31221
31219
  }
31222
- const verdict = asked2.data;
31220
+ const verdict = asked3.data;
31223
31221
  if (!verdict.allowed) {
31224
31222
  setPending(
31225
31223
  verdict.outcome === "needs_approval" ? { kind: "approval", recordId, to, verdict } : (verdict.missing ?? []).length > 0 ? { kind: "needs", recordId, to, verdict } : { kind: "refused", recordId, to, verdict }
@@ -31831,11 +31829,45 @@ function CardFieldsInline({ row, fields }) {
31831
31829
  }
31832
31830
 
31833
31831
  // src/CalendarView.tsx
31834
- import { useEffect as useEffect75, useMemo as useMemo52, useRef as useRef44, useState as useState89 } from "react";
31832
+ import { useEffect as useEffect76, useMemo as useMemo52, useRef as useRef44, useState as useState90 } from "react";
31835
31833
  import { mayDrag as mayDrag2 } from "@ai-matrx/records/react";
31836
31834
  import { Button as Button67, Select as Select13, SelectContent as SelectContent13, SelectItem as SelectItem13, SelectTrigger as SelectTrigger13, SelectValue as SelectValue13, cn as cn56 } from "@ai-matrx/design-system";
31837
31835
  import { CHOICE_CHIP_CLASS as CHOICE_CHIP_CLASS3 } from "@ai-matrx/design-system/data-table";
31838
31836
 
31837
+ // src/weekStart.ts
31838
+ import { useEffect as useEffect75, useState as useState89 } from "react";
31839
+ import { useOptionalRecordsClient as useOptionalRecordsClient13 } from "@ai-matrx/records/react";
31840
+ var DAYS2 = ["sunday", "monday", "tuesday", "wednesday", "thursday", "friday", "saturday"];
31841
+ function weekStartIndex(word) {
31842
+ const at = DAYS2.indexOf(String(word ?? "").trim().toLowerCase());
31843
+ return at < 0 ? 1 : at;
31844
+ }
31845
+ function daysSinceWeekStart(weekday, first) {
31846
+ return (weekday - first + 7) % 7;
31847
+ }
31848
+ var asked2 = /* @__PURE__ */ new WeakMap();
31849
+ function ask(client) {
31850
+ let p = asked2.get(client);
31851
+ if (!p) {
31852
+ p = client.aggCalendar().then((r) => r.ok ? weekStartIndex(r.data.week_start) : 1);
31853
+ asked2.set(client, p);
31854
+ }
31855
+ return p;
31856
+ }
31857
+ function useReaderWeekStart() {
31858
+ const client = useOptionalRecordsClient13();
31859
+ const [first, setFirst] = useState89(1);
31860
+ useEffect75(() => {
31861
+ if (!client) return;
31862
+ let live = true;
31863
+ void ask(client).then((n) => live && setFirst(n));
31864
+ return () => {
31865
+ live = false;
31866
+ };
31867
+ }, [client]);
31868
+ return first;
31869
+ }
31870
+
31839
31871
  // src/rowColorBy.tsx
31840
31872
  import { useMemo as useMemo51 } from "react";
31841
31873
  import { EMPTY_TABLE_STYLE, resolveRowColor as resolveRowColor2 } from "@ai-matrx/design-system/data-table";
@@ -32040,8 +32072,8 @@ function addDays2(key, n) {
32040
32072
  function daysBetween2(from, to) {
32041
32073
  return Math.round((dayDate(to).getTime() - dayDate(from).getTime()) / 864e5);
32042
32074
  }
32043
- function startOfWeek(key) {
32044
- return addDays2(key, -dayDate(key).getDay());
32075
+ function startOfWeek(key, first) {
32076
+ return addDays2(key, -daysSinceWeekStart(dayDate(key).getDay(), first));
32045
32077
  }
32046
32078
  function instant(value) {
32047
32079
  if (!hasTimePart(value)) return null;
@@ -32111,8 +32143,8 @@ function packOverlaps(blocks) {
32111
32143
  function useNarrow() {
32112
32144
  const query = "(max-width: 639px)";
32113
32145
  const read = () => typeof window !== "undefined" && typeof window.matchMedia === "function" && window.matchMedia(query).matches;
32114
- const [narrow, setNarrow] = useState89(read);
32115
- useEffect75(() => {
32146
+ const [narrow, setNarrow] = useState90(read);
32147
+ useEffect76(() => {
32116
32148
  if (typeof window === "undefined" || typeof window.matchMedia !== "function") return;
32117
32149
  const list = window.matchMedia(query);
32118
32150
  const on = () => setNarrow(list.matches);
@@ -32154,12 +32186,13 @@ function CalendarView({
32154
32186
  initialMode,
32155
32187
  className
32156
32188
  }) {
32189
+ const firstDay = useReaderWeekStart();
32157
32190
  const moves = useRecordMoves({ tableId, rows, onMoved });
32158
32191
  const narrow = useNarrow();
32159
- const [mode, setMode] = useState89(initialMode ?? (narrow ? "list" : "month"));
32192
+ const [mode, setMode] = useState90(initialMode ?? (narrow ? "list" : "month"));
32160
32193
  usePersonTimeZone();
32161
- const [anchor, setAnchor] = useState89(initialDate ?? dayKey(personWallNow()));
32162
- const [openDay, setOpenDay] = useState89(null);
32194
+ const [anchor, setAnchor] = useState90(initialDate ?? dayKey(personWallNow()));
32195
+ const [openDay, setOpenDay] = useState90(null);
32163
32196
  const titleFields = useMemo52(() => titleField ? [titleField] : [], [titleField]);
32164
32197
  const labels = useRecordLabels(titleFields);
32165
32198
  const all = fields ?? [];
@@ -32169,7 +32202,7 @@ function CalendarView({
32169
32202
  () => eligibleFieldFor("date", all, null, { far: farFields }).eligible.filter((f) => f.key !== dateField.key),
32170
32203
  [all, farFields, dateField.key]
32171
32204
  );
32172
- const [endPick, setEndPick] = useState89(void 0);
32205
+ const [endPick, setEndPick] = useState90(void 0);
32173
32206
  const endChosen = endPick !== void 0 ? endPick : endKey ?? void 0;
32174
32207
  const endUnusual = endChosen && !otherDates.some((f) => f.key === endChosen) ? all.find((f) => f.key === endChosen && f.key !== dateField.key) : void 0;
32175
32208
  const endField = endChosen === void 0 ? otherDates.length === 1 ? otherDates[0] : void 0 : otherDates.find((f) => f.key === endChosen) ?? endUnusual ?? void 0;
@@ -32178,13 +32211,13 @@ function CalendarView({
32178
32211
  const canMove = (row) => mayDrag2(row.level) && !startWorkedOut;
32179
32212
  const creates = canCreate && !startWorkedOut;
32180
32213
  const choiceFields = useMemo52(() => eligibleFieldFor("choice", all).eligible.filter(isChoiceField), [all]);
32181
- const [colorPick, setColorPick] = useState89(void 0);
32214
+ const [colorPick, setColorPick] = useState90(void 0);
32182
32215
  const colorKey = colorPick !== void 0 ? colorPick : style?.colorBy?.field ?? choiceFields[0]?.key ?? null;
32183
32216
  const colorOf = useRowColorBy(all, colorKey, style);
32184
- const [placedOver, setPlacedOver] = useState89(() => /* @__PURE__ */ new Map());
32185
- useEffect75(() => setPlacedOver(/* @__PURE__ */ new Map()), [rows]);
32217
+ const [placedOver, setPlacedOver] = useState90(() => /* @__PURE__ */ new Map());
32218
+ useEffect76(() => setPlacedOver(/* @__PURE__ */ new Map()), [rows]);
32186
32219
  const undoneCount = moves.undo.depth.forward;
32187
- useEffect75(() => {
32220
+ useEffect76(() => {
32188
32221
  if (undoneCount > 0) setPlacedOver(/* @__PURE__ */ new Map());
32189
32222
  }, [undoneCount]);
32190
32223
  const startOf = (row) => placedOver.has(row.id) ? placedOver.get(row.id).start : (row.document ?? {})[dateField.key];
@@ -32194,26 +32227,26 @@ function CalendarView({
32194
32227
  const without = [];
32195
32228
  for (const row of rows) {
32196
32229
  const start = startOf(row);
32197
- const firstDay = calendarDayOf(start);
32198
- if (!firstDay) {
32230
+ const firstDay2 = calendarDayOf(start);
32231
+ if (!firstDay2) {
32199
32232
  without.push(row);
32200
32233
  continue;
32201
32234
  }
32202
32235
  const end = endOf(row);
32203
32236
  const endDay = calendarDayOf(end);
32204
- const lastDay = endDay && endDay > firstDay ? addDays2(firstDay, Math.min(daysBetween2(firstDay, endDay), MAX_SPAN_DAYS)) : firstDay;
32237
+ const lastDay = endDay && endDay > firstDay2 ? addDays2(firstDay2, Math.min(daysBetween2(firstDay2, endDay), MAX_SPAN_DAYS)) : firstDay2;
32205
32238
  const at = instant(start);
32206
32239
  const endAt = instant(end);
32207
32240
  const minutes = at && endAt && endAt > at ? Math.round((endAt.getTime() - at.getTime()) / 6e4) : defaultMinutes;
32208
- out.push({ row, start, end, firstDay, lastDay, at, minutes });
32241
+ out.push({ row, start, end, firstDay: firstDay2, lastDay, at, minutes });
32209
32242
  }
32210
32243
  return { placed: out, undated: without };
32211
32244
  }, [rows, dateField.key, endField?.key, placedOver, defaultMinutes]);
32212
32245
  const titleOf = (row) => cardWords(row, titleField, labels).text;
32213
32246
  const rowById = (id) => rows.find((r) => r.id === id);
32214
32247
  const frame = useRef44(null);
32215
- const [focusOn, setFocusOn] = useState89(null);
32216
- useEffect75(() => {
32248
+ const [focusOn, setFocusOn] = useState90(null);
32249
+ useEffect76(() => {
32217
32250
  if (!focusOn) return;
32218
32251
  const button = frame.current?.querySelector(`[data-calendar-card="${focusOn}"] button`);
32219
32252
  button?.focus({ preventScroll: true });
@@ -32261,9 +32294,9 @@ function CalendarView({
32261
32294
  if (made) onOpenRecord?.(made);
32262
32295
  };
32263
32296
  const grabOffset = useRef44(0);
32264
- const [resizing, setResizing] = useState89(null);
32265
- const [ghost, setGhost] = useState89(null);
32266
- useEffect75(() => {
32297
+ const [resizing, setResizing] = useState90(null);
32298
+ const [ghost, setGhost] = useState90(null);
32299
+ useEffect76(() => {
32267
32300
  if (!ghost || typeof document === "undefined") return;
32268
32301
  const clear = () => setGhost(null);
32269
32302
  document.addEventListener("dragend", clear);
@@ -32402,7 +32435,7 @@ function CalendarView({
32402
32435
  window.addEventListener("pointermove", onMove);
32403
32436
  window.addEventListener("pointerup", onUp);
32404
32437
  };
32405
- const [selecting, setSelecting] = useState89(null);
32438
+ const [selecting, setSelecting] = useState90(null);
32406
32439
  const beginSelect = (day2) => (e) => {
32407
32440
  if (!creates || e.button !== 0) return;
32408
32441
  const slot = e.target.closest?.("[data-calendar-slot]");
@@ -32472,7 +32505,7 @@ function CalendarView({
32472
32505
  ] }, key);
32473
32506
  const today = dayKey(personWallNow());
32474
32507
  const anchorDate = dayDate(anchor);
32475
- const heading = mode === "week" ? weekHeading(startOfWeek(anchor)) : mode === "day" ? anchorDate.toLocaleDateString(void 0, { weekday: "long", month: "long", day: "numeric", year: "numeric" }) : anchorDate.toLocaleDateString(void 0, { month: "long", year: "numeric" });
32508
+ const heading = mode === "week" ? weekHeading(startOfWeek(anchor, firstDay)) : mode === "day" ? anchorDate.toLocaleDateString(void 0, { weekday: "long", month: "long", day: "numeric", year: "numeric" }) : anchorDate.toLocaleDateString(void 0, { month: "long", year: "numeric" });
32476
32509
  const step2 = (dir) => {
32477
32510
  if (mode === "week") setAnchor(addDays2(anchor, dir * 7));
32478
32511
  else if (mode === "day") setAnchor(addDays2(anchor, dir));
@@ -32523,7 +32556,7 @@ function CalendarView({
32523
32556
  ) : null;
32524
32557
  let body;
32525
32558
  if (mode === "month") {
32526
- const first = startOfWeek(dayKey(new Date(anchorDate.getFullYear(), anchorDate.getMonth(), 1)));
32559
+ const first = startOfWeek(dayKey(new Date(anchorDate.getFullYear(), anchorDate.getMonth(), 1)), firstDay);
32527
32560
  const weeks = Array.from({ length: 6 }, (_, w) => addDays2(first, w * 7));
32528
32561
  body = /* @__PURE__ */ jsx110("div", { className: "min-w-0 flex-1 overflow-x-auto", children: /* @__PURE__ */ jsxs101("div", { className: "min-w-[560px] border-l border-t", role: "grid", "aria-label": heading, "data-calendar-month": "", children: [
32529
32562
  /* @__PURE__ */ jsx110("div", { className: "grid grid-cols-7", role: "row", children: Array.from({ length: 7 }, (_, i) => addDays2(first, i)).map((d) => /* @__PURE__ */ jsx110("div", { role: "columnheader", className: "border-b border-r px-1 py-0.5 text-center text-xs text-muted-foreground", children: dayDate(d).toLocaleDateString(void 0, { weekday: "short" }) }, `h${d}`)) }),
@@ -32555,7 +32588,7 @@ function CalendarView({
32555
32588
  ))
32556
32589
  ] }) });
32557
32590
  } else if (mode === "week" || mode === "day") {
32558
- const first = mode === "day" ? anchor : startOfWeek(anchor);
32591
+ const first = mode === "day" ? anchor : startOfWeek(anchor, firstDay);
32559
32592
  const days = Array.from({ length: mode === "day" ? 1 : 7 }, (_, i) => addDays2(first, i));
32560
32593
  const allDay = (d) => placed.filter((p) => (!p.at || p.lastDay > p.firstDay) && p.firstDay <= d && p.lastDay >= d).sort(byTime);
32561
32594
  const timed = (d) => packOverlaps(
@@ -32811,12 +32844,12 @@ function WeekHours({
32811
32844
  overlay
32812
32845
  }) {
32813
32846
  const frame = useRef44(null);
32814
- useEffect75(() => {
32847
+ useEffect76(() => {
32815
32848
  if (frame.current) frame.current.scrollTop = 7 * HOUR_PX;
32816
32849
  }, []);
32817
32850
  usePersonTimeZone();
32818
- const [now, setNow] = useState89(() => personWallNow());
32819
- useEffect75(() => {
32851
+ const [now, setNow] = useState90(() => personWallNow());
32852
+ useEffect76(() => {
32820
32853
  const timer = setInterval(() => setNow(personWallNow()), 6e4);
32821
32854
  return () => clearInterval(timer);
32822
32855
  }, []);
@@ -32858,11 +32891,11 @@ function weekHeading(first) {
32858
32891
  }
32859
32892
 
32860
32893
  // src/TimelineView.tsx
32861
- import { useEffect as useEffect76, useMemo as useMemo53, useRef as useRef45, useState as useState90 } from "react";
32894
+ import { useEffect as useEffect77, useMemo as useMemo53, useRef as useRef45, useState as useState91 } from "react";
32862
32895
  import { mayDrag as mayDrag3 } from "@ai-matrx/records/react";
32863
32896
  import { Button as Button68, Select as Select14, SelectContent as SelectContent14, SelectItem as SelectItem14, SelectTrigger as SelectTrigger14, SelectValue as SelectValue14, cn as cn57 } from "@ai-matrx/design-system";
32864
32897
  import { CHOICE_CHIP_CLASS as CHOICE_CHIP_CLASS4 } from "@ai-matrx/design-system/data-table";
32865
- import { useOptionalRecordsClient as useOptionalRecordsClient13 } from "@ai-matrx/records/react";
32898
+ import { useOptionalRecordsClient as useOptionalRecordsClient14 } from "@ai-matrx/records/react";
32866
32899
  import { Fragment as Fragment44, jsx as jsx111, jsxs as jsxs102 } from "react/jsx-runtime";
32867
32900
  var TIMELINE_ZOOMS = ["day", "week", "month", "quarter"];
32868
32901
  var ZOOM_LABEL = { day: "Day", week: "Week", month: "Month", quarter: "Quarter" };
@@ -32935,13 +32968,13 @@ function packRows(bars) {
32935
32968
  return { ...bar, row };
32936
32969
  });
32937
32970
  }
32938
- function windowStart(anchor, zoom) {
32971
+ function windowStart(anchor, zoom, firstDay) {
32939
32972
  const from = dayAt(addDays(anchor, -WINDOW[zoom].lead));
32940
- if (zoom === "day" || zoom === "week") from.setDate(from.getDate() - from.getDay());
32973
+ if (zoom === "day" || zoom === "week") from.setDate(from.getDate() - daysSinceWeekStart(from.getDay(), firstDay));
32941
32974
  else from.setDate(1);
32942
32975
  return dayKeyOf(from);
32943
32976
  }
32944
- function scaleOf(start, days, zoom) {
32977
+ function scaleOf(start, days, zoom, firstDay) {
32945
32978
  const group = (key, label) => {
32946
32979
  const out = [];
32947
32980
  let current = "";
@@ -32964,7 +32997,7 @@ function scaleOf(start, days, zoom) {
32964
32997
  }
32965
32998
  if (zoom === "week") return { top: group(month, monthLong), bottom: group(dayKeyOf, (at) => String(at.getDate())) };
32966
32999
  if (zoom === "month") {
32967
- const weekOf = (at) => dayKeyOf(new Date(at.getFullYear(), at.getMonth(), at.getDate() - at.getDay()));
33000
+ const weekOf = (at) => dayKeyOf(new Date(at.getFullYear(), at.getMonth(), at.getDate() - daysSinceWeekStart(at.getDay(), firstDay)));
32968
33001
  return { top: group(month, monthLong), bottom: group(weekOf, (at) => at.toLocaleDateString(void 0, { month: "short", day: "numeric" })) };
32969
33002
  }
32970
33003
  return {
@@ -33000,14 +33033,14 @@ function TimelineView({
33000
33033
  className
33001
33034
  }) {
33002
33035
  const moves = useRecordMoves({ tableId, rows, onMoved });
33003
- const [zoom, setZoom] = useState90(initialZoom);
33036
+ const [zoom, setZoom] = useState91(initialZoom);
33004
33037
  usePersonTimeZone();
33005
33038
  const today = dayKeyOf(personWallNow());
33006
- const [anchor, setAnchor] = useState90(initialDate ?? today);
33039
+ const [anchor, setAnchor] = useState91(initialDate ?? today);
33007
33040
  const dates = useMemo53(() => offerableFields(fields, "date", { far: farFields }), [fields, farFields]);
33008
33041
  const has = (list, key) => key && list.some((f) => f.key === key) ? key : null;
33009
- const [picked, setPicked] = useState90({});
33010
- useEffect76(() => setPicked({}), [startKey, endKey, groupKey, colorKey]);
33042
+ const [picked, setPicked] = useState91({});
33043
+ useEffect77(() => setPicked({}), [startKey, endKey, groupKey, colorKey]);
33011
33044
  const named = (key) => key && fields.some((f) => f.key === key) ? key : null;
33012
33045
  const startChosen = "startKey" in picked ? picked.startKey ?? null : has(dates, startKey) ?? named(startKey) ?? onlyCandidate(dates);
33013
33046
  const endCandidates = useMemo53(() => dates.filter((f) => f.key !== startChosen), [dates, startChosen]);
@@ -33032,9 +33065,9 @@ function TimelineView({
33032
33065
  const canMove = (row) => mayDrag3(row.level) && !startWorkedOut;
33033
33066
  const colorOf = useRowColorBy(fields, colorChosen, style);
33034
33067
  const depField = useMemo53(() => dependencyFieldOf(fields, tableId), [fields, tableId]);
33035
- const knobClient = useOptionalRecordsClient13();
33036
- const [shiftDependents, setShiftDependents] = useState90(true);
33037
- useEffect76(() => {
33068
+ const knobClient = useOptionalRecordsClient14();
33069
+ const [shiftDependents, setShiftDependents] = useState91(true);
33070
+ useEffect77(() => {
33038
33071
  if (!depField || !knobClient) return;
33039
33072
  let live = true;
33040
33073
  void knobClient.timelineDependencyShift().then((got) => {
@@ -33049,15 +33082,15 @@ function TimelineView({
33049
33082
  const labels = useRecordLabels(labelFields);
33050
33083
  const titleOf = (row) => cardWords(row, titleField, labels).text;
33051
33084
  const groupOptions = useChoiceOptions(fields, groupField && isChoiceField(groupField) ? [groupField.key] : []).get(groupField?.key ?? "");
33052
- const [placedOver, setPlacedOver] = useState90(() => /* @__PURE__ */ new Map());
33053
- useEffect76(() => setPlacedOver(/* @__PURE__ */ new Map()), [rows]);
33085
+ const [placedOver, setPlacedOver] = useState91(() => /* @__PURE__ */ new Map());
33086
+ useEffect77(() => setPlacedOver(/* @__PURE__ */ new Map()), [rows]);
33054
33087
  const undoneCount = moves.undo.depth.forward;
33055
- useEffect76(() => {
33088
+ useEffect77(() => {
33056
33089
  if (undoneCount > 0) setPlacedOver(/* @__PURE__ */ new Map());
33057
33090
  }, [undoneCount]);
33058
33091
  const startOf = (row) => placedOver.has(row.id) ? placedOver.get(row.id).start : startField ? (row.document ?? {})[startField.key] : null;
33059
33092
  const endOf = (row) => !endField ? null : placedOver.has(row.id) ? placedOver.get(row.id).end : (row.document ?? {})[endField.key];
33060
- const [dragging, setDragging] = useState90(null);
33093
+ const [dragging, setDragging] = useState91(null);
33061
33094
  const { placed, unscheduled } = useMemo53(() => {
33062
33095
  const out = [];
33063
33096
  const without = [];
@@ -33196,14 +33229,15 @@ function TimelineView({
33196
33229
  void commit(row, patch, `${titleOf(row)} scheduled for ${calendarDayLabel(day2)}`);
33197
33230
  };
33198
33231
  const px = PX_PER_DAY[zoom];
33199
- const from = windowStart(anchor, zoom);
33232
+ const firstDay = useReaderWeekStart();
33233
+ const from = windowStart(anchor, zoom, firstDay);
33200
33234
  const days = WINDOW[zoom].days;
33201
33235
  const width = days * px;
33202
- const scale = useMemo53(() => scaleOf(from, days, zoom), [from, days, zoom]);
33236
+ const scale = useMemo53(() => scaleOf(from, days, zoom, firstDay), [from, days, zoom, firstDay]);
33203
33237
  const xOf = (day2) => daysBetween(from, day2) * px;
33204
33238
  const scroller = useRef45(null);
33205
33239
  const grouped = Boolean(groupField);
33206
- const [scrollX, setScrollX] = useState90(0);
33240
+ const [scrollX, setScrollX] = useState91(0);
33207
33241
  const frame = useRef45(null);
33208
33242
  const onScroll = () => {
33209
33243
  if (frame.current !== null) return;
@@ -33212,7 +33246,7 @@ function TimelineView({
33212
33246
  setScrollX(scroller.current?.scrollLeft ?? 0);
33213
33247
  });
33214
33248
  };
33215
- useEffect76(() => {
33249
+ useEffect77(() => {
33216
33250
  const el = scroller.current;
33217
33251
  if (!el) return;
33218
33252
  const label = el.querySelector("[data-timeline-label]")?.offsetWidth ?? 0;
@@ -33638,7 +33672,7 @@ function TimelineView({
33638
33672
  }
33639
33673
 
33640
33674
  // src/ViewNeeds.tsx
33641
- import { useEffect as useEffect77, useState as useState91 } from "react";
33675
+ import { useEffect as useEffect78, useState as useState92 } from "react";
33642
33676
  import { useFieldMutation as useFieldMutation6, useRecordsClient as useRecordsClient64, useTable as useTable17 } from "@ai-matrx/records/react";
33643
33677
  import { BasicInput as BasicInput20, Button as Button69, Label as Label18 } from "@ai-matrx/design-system";
33644
33678
  import { jsx as jsx112, jsxs as jsxs103 } from "react/jsx-runtime";
@@ -33659,7 +33693,7 @@ function useAskedColumnLands(layout, tableId, fields, chosen, offerable, onMade)
33659
33693
  const wanted = askedFor.get(askKey(tableId, layout));
33660
33694
  const landed = wanted && !chosen ? offerable(fields).find((f) => fieldName(f).trim().toLowerCase() === wanted.trim().toLowerCase()) : void 0;
33661
33695
  const key = landed?.key ?? null;
33662
- useEffect77(() => {
33696
+ useEffect78(() => {
33663
33697
  if (!key) return;
33664
33698
  askedFor.delete(askKey(tableId, layout));
33665
33699
  onMade(key);
@@ -33674,10 +33708,10 @@ function ViewNeeds({ layout, tableId, fields, onMade, className }) {
33674
33708
  const mutation = useFieldMutation6();
33675
33709
  const client = useRecordsClient64();
33676
33710
  const taken = fields.map((f) => fieldName(f));
33677
- const [label, setLabel] = useState91(() => freeColumnName(need?.starter.label ?? "", taken));
33678
- const [options, setOptions] = useState91(() => [...need?.starter.options ?? []]);
33679
- const [refused, setRefused] = useState91(null);
33680
- const [pendingId, setPendingId] = useState91(null);
33711
+ const [label, setLabel] = useState92(() => freeColumnName(need?.starter.label ?? "", taken));
33712
+ const [options, setOptions] = useState92(() => [...need?.starter.options ?? []]);
33713
+ const [refused, setRefused] = useState92(null);
33714
+ const [pendingId, setPendingId] = useState92(null);
33681
33715
  if (!need) return null;
33682
33716
  const name = label.trim() === "" ? need.starter.label : label.trim();
33683
33717
  const choices = options.map((o) => o.trim()).filter((o) => o !== "");
@@ -33771,8 +33805,8 @@ function ViewNeeds({ layout, tableId, fields, onMade, className }) {
33771
33805
  }
33772
33806
 
33773
33807
  // src/GalleryCover.tsx
33774
- import { useEffect as useEffect78, useState as useState92 } from "react";
33775
- import { useOptionalRecordsClient as useOptionalRecordsClient14 } from "@ai-matrx/records/react";
33808
+ import { useEffect as useEffect79, useState as useState93 } from "react";
33809
+ import { useOptionalRecordsClient as useOptionalRecordsClient15 } from "@ai-matrx/records/react";
33776
33810
  import { Fragment as Fragment45, jsx as jsx113 } from "react/jsx-runtime";
33777
33811
  function isImageAddress(value) {
33778
33812
  return typeof value === "string" && /^(https?:\/\/|\/|data:image\/)/i.test(value.trim());
@@ -33790,10 +33824,10 @@ function GalleryCover({ field: field2, value }) {
33790
33824
  return null;
33791
33825
  }
33792
33826
  function FileCover({ recordId }) {
33793
- const client = useOptionalRecordsClient14();
33827
+ const client = useOptionalRecordsClient15();
33794
33828
  const host = useRecordsUi();
33795
- const [read, setRead] = useState92(null);
33796
- useEffect78(() => {
33829
+ const [read, setRead] = useState93(null);
33830
+ useEffect79(() => {
33797
33831
  let cancelled = false;
33798
33832
  if (!client) {
33799
33833
  setRead({ fileId: recordId, name: "" });
@@ -34191,7 +34225,7 @@ function ListRow({
34191
34225
  }
34192
34226
 
34193
34227
  // src/ChartLayout.tsx
34194
- import { useEffect as useEffect82, useMemo as useMemo57, useState as useState96 } from "react";
34228
+ import { useEffect as useEffect83, useMemo as useMemo57, useState as useState97 } from "react";
34195
34229
  import { useRecordsClient as useRecordsClient65 } from "@ai-matrx/records/react";
34196
34230
  import { measureKey as measureKey4 } from "@ai-matrx/records";
34197
34231
  import { Select as Select16, SelectContent as SelectContent16, SelectItem as SelectItem16, SelectTrigger as SelectTrigger16, SelectValue as SelectValue16 } from "@ai-matrx/design-system";
@@ -34221,8 +34255,8 @@ import { cn as cn60 } from "@ai-matrx/design-system";
34221
34255
  import { formatCount as formatCount5 } from "@ai-matrx/kit/format";
34222
34256
 
34223
34257
  // src/linkWords.ts
34224
- import { useEffect as useEffect79, useMemo as useMemo55, useState as useState93 } from "react";
34225
- import { useOptionalRecordsClient as useOptionalRecordsClient15 } from "@ai-matrx/records/react";
34258
+ import { useEffect as useEffect80, useMemo as useMemo55, useState as useState94 } from "react";
34259
+ import { useOptionalRecordsClient as useOptionalRecordsClient16 } from "@ai-matrx/records/react";
34226
34260
 
34227
34261
  // src/charts.ts
34228
34262
  var CHART_KIND_LABEL = {
@@ -34432,14 +34466,14 @@ function bucketWindow2(groupKey, value) {
34432
34466
 
34433
34467
  // src/linkWords.ts
34434
34468
  function useLinkGroupNamer(block, tableId) {
34435
- const client = useOptionalRecordsClient15();
34469
+ const client = useOptionalRecordsClient16();
34436
34470
  const groupBy = block.kind === "stuck" ? [] : block.group_by ?? [];
34437
34471
  const rows = block.kind === "stuck" ? [] : block.rows ?? [];
34438
- const ask = JSON.stringify([tableId, groupBy, rows.map((r) => r.groups ?? null)]);
34439
- const [named, setNamed] = useState93({});
34440
- const [choices, setChoices] = useState93([]);
34472
+ const ask2 = JSON.stringify([tableId, groupBy, rows.map((r) => r.groups ?? null)]);
34473
+ const [named, setNamed] = useState94({});
34474
+ const [choices, setChoices] = useState94([]);
34441
34475
  const labels = useRecordLabels(choices);
34442
- useEffect79(() => {
34476
+ useEffect80(() => {
34443
34477
  if (!client || groupBy.length === 0 || rows.length === 0) return;
34444
34478
  let cancelled = false;
34445
34479
  void (async () => {
@@ -34466,7 +34500,7 @@ function useLinkGroupNamer(block, tableId) {
34466
34500
  return () => {
34467
34501
  cancelled = true;
34468
34502
  };
34469
- }, [client, ask]);
34503
+ }, [client, ask2]);
34470
34504
  return useMemo55(() => {
34471
34505
  if (Object.keys(named).length === 0 && choices.length === 0) return void 0;
34472
34506
  return (key, value) => {
@@ -34482,8 +34516,8 @@ function useLinkGroupNamer(block, tableId) {
34482
34516
  }
34483
34517
 
34484
34518
  // src/measureWords.ts
34485
- import { useEffect as useEffect80, useState as useState94 } from "react";
34486
- import { useOptionalRecordsClient as useOptionalRecordsClient16 } from "@ai-matrx/records/react";
34519
+ import { useEffect as useEffect81, useState as useState95 } from "react";
34520
+ import { useOptionalRecordsClient as useOptionalRecordsClient17 } from "@ai-matrx/records/react";
34487
34521
  import { humanizeIdentifier as humanizeIdentifier13 } from "@ai-matrx/kit/text-case";
34488
34522
  var OP_WORD = { sum: "Total", avg: "Average", min: "Lowest", max: "Highest" };
34489
34523
  function measureWords(key, fields) {
@@ -34498,10 +34532,10 @@ function measureWords(key, fields) {
34498
34532
  return word ? `${word} ${name.charAt(0).toLowerCase()}${name.slice(1)}` : `${humanizeIdentifier13(op2)} ${name}`;
34499
34533
  }
34500
34534
  function useMeasureWords(key, tableId) {
34501
- const client = useOptionalRecordsClient16();
34502
- const [fields, setFields] = useState94(null);
34535
+ const client = useOptionalRecordsClient17();
34536
+ const [fields, setFields] = useState95(null);
34503
34537
  const needs = key !== "count";
34504
- useEffect80(() => {
34538
+ useEffect81(() => {
34505
34539
  if (!client || !tableId || !needs) return;
34506
34540
  let cancelled = false;
34507
34541
  void client.fields({ table_id: tableId }).then((result) => {
@@ -34516,17 +34550,17 @@ function useMeasureWords(key, tableId) {
34516
34550
 
34517
34551
  // src/chartFrame.tsx
34518
34552
  import {
34519
- useEffect as useEffect81,
34553
+ useEffect as useEffect82,
34520
34554
  useId as useId4,
34521
34555
  useRef as useRef46,
34522
- useState as useState95
34556
+ useState as useState96
34523
34557
  } from "react";
34524
34558
  import { cn as cn59 } from "@ai-matrx/design-system";
34525
34559
  import { jsx as jsx116, jsxs as jsxs106 } from "react/jsx-runtime";
34526
34560
  function useMeasuredWidth(fallback = 480) {
34527
34561
  const ref = useRef46(null);
34528
- const [width, setWidth] = useState95(fallback);
34529
- useEffect81(() => {
34562
+ const [width, setWidth] = useState96(fallback);
34563
+ useEffect82(() => {
34530
34564
  const node = ref.current;
34531
34565
  if (!node) return;
34532
34566
  const apply = () => {
@@ -35141,12 +35175,12 @@ var isChartKind = (v) => v === "bar" || v === "line" || v === "donut";
35141
35175
  var isChartMeasure = (v) => v === "count" || v === "sum" || v === "avg";
35142
35176
  function chartQuestion(view, fields) {
35143
35177
  const kind = isChartKind(view.chartKind) ? view.chartKind : "bar";
35144
- const asked2 = isChartMeasure(view.chartMeasure) ? view.chartMeasure : "count";
35178
+ const asked3 = isChartMeasure(view.chartMeasure) ? view.chartMeasure : "count";
35145
35179
  const group = view.groupField ? fields.find((f) => f.key === view.groupField) : void 0;
35146
35180
  const measureField = view.measure ? fields.find((f) => f.key === view.measure) : void 0;
35147
- const needsField = asked2 !== "count";
35181
+ const needsField = asked3 !== "count";
35148
35182
  const fellBack = needsField && !measureField;
35149
- const measure = needsField && measureField ? { op: asked2, key: measureField.key } : { op: "count" };
35183
+ const measure = needsField && measureField ? { op: asked3, key: measureField.key } : { op: "count" };
35150
35184
  const dated = group ? DATE_TYPES.has(String(group.type)) : false;
35151
35185
  const bucket = group && dated && kind === "line" ? { key: group.key, by: "month" } : null;
35152
35186
  return { kind, groupBy: group && !bucket ? [group.key] : [], bucket, measure, fellBack };
@@ -35154,12 +35188,12 @@ function chartQuestion(view, fields) {
35154
35188
  function ChartLayout({ view, fields, filter, onChange, remembered }) {
35155
35189
  const client = useRecordsClient65();
35156
35190
  const q = useMemo57(() => chartQuestion(view, fields), [view, fields]);
35157
- const [state, setState] = useState96({ block: null, error: null });
35191
+ const [state, setState] = useState97({ block: null, error: null });
35158
35192
  const filterKey = JSON.stringify(filter ?? {});
35159
35193
  const qKey = JSON.stringify(q);
35160
- useEffect82(() => {
35194
+ useEffect83(() => {
35161
35195
  let cancelled = false;
35162
- const asked2 = JSON.parse(filterKey);
35196
+ const asked3 = JSON.parse(filterKey);
35163
35197
  const question = JSON.parse(qKey);
35164
35198
  void client.recordAggregate({
35165
35199
  table_id: view.subject,
@@ -35167,7 +35201,7 @@ function ChartLayout({ view, fields, filter, onChange, remembered }) {
35167
35201
  ...question.bucket ? { bucket: question.bucket } : {},
35168
35202
  measures: [question.measure],
35169
35203
  limit: 200,
35170
- ...Object.keys(asked2).length > 0 ? { filter: asked2 } : {}
35204
+ ...Object.keys(asked3).length > 0 ? { filter: asked3 } : {}
35171
35205
  }).then((answered) => {
35172
35206
  if (cancelled) return;
35173
35207
  if (!answered.ok) {
@@ -35231,9 +35265,9 @@ import { Fragment as Fragment47, jsx as jsx119, jsxs as jsxs109 } from "react/js
35231
35265
  var NO_FIELDS2 = [];
35232
35266
  function useViewRecords(view, pageSize = 200, filter, viewId) {
35233
35267
  const client = useRecordsClient66();
35234
- const [limit, setLimit] = useState97(pageSize);
35268
+ const [limit, setLimit] = useState98(pageSize);
35235
35269
  const questionKey = `${view.subject}|${stableFilterKey4(filter ?? null)}|${JSON.stringify(view.sorts ?? [])}`;
35236
- useEffect83(() => {
35270
+ useEffect84(() => {
35237
35271
  setLimit(pageSize);
35238
35272
  }, [questionKey, pageSize]);
35239
35273
  const storeSort = useMemo58(
@@ -35245,13 +35279,13 @@ function useViewRecords(view, pageSize = 200, filter, viewId) {
35245
35279
  ...filter ? { filter } : {},
35246
35280
  ...storeSort.length > 0 ? { sort: storeSort } : {}
35247
35281
  });
35248
- const [ruled, setRuled] = useState97({
35282
+ const [ruled, setRuled] = useState98({
35249
35283
  rows: [],
35250
35284
  loading: Boolean(view.ruleId),
35251
35285
  error: null
35252
35286
  });
35253
35287
  const ruleId = view.ruleId ?? null;
35254
- useEffect83(() => {
35288
+ useEffect84(() => {
35255
35289
  if (!ruleId) return;
35256
35290
  let cancelled = false;
35257
35291
  setRuled({ rows: [], loading: true, error: null });
@@ -35265,8 +35299,8 @@ function useViewRecords(view, pageSize = 200, filter, viewId) {
35265
35299
  cancelled = true;
35266
35300
  };
35267
35301
  }, [client, ruleId, pageSize]);
35268
- const asked2 = stableFilterKey4(filter ?? null);
35269
- const fromView = asked2 !== "{}" && (asked2 === stableFilterKey4(view.where ?? null) || asked2 === stableFilterKey4(view.filters ?? null));
35302
+ const asked3 = stableFilterKey4(filter ?? null);
35303
+ const fromView = asked3 !== "{}" && (asked3 === stableFilterKey4(view.where ?? null) || asked3 === stableFilterKey4(view.filters ?? null));
35270
35304
  const tableRows = useMemo58(() => table.data?.rows ?? [], [table.data]);
35271
35305
  const manual = view.order === "manual" && Boolean(viewId) && !ruleId;
35272
35306
  const hand = useHandOrderRows({
@@ -35318,7 +35352,7 @@ function useViewRecords(view, pageSize = 200, filter, viewId) {
35318
35352
  // sat over every board and gallery. A view of the whole table says nothing about it; a narrowed
35319
35353
  // one says how, in words a person uses.
35320
35354
  membership: [
35321
- ruleId ? "Showing the records this view's rule picks." : fromView ? "Showing the records this view's filter asks for." : asked2 !== "{}" ? "Showing only the records behind the number you clicked." : "",
35355
+ ruleId ? "Showing the records this view's rule picks." : fromView ? "Showing the records this view's filter asks for." : asked3 !== "{}" ? "Showing only the records behind the number you clicked." : "",
35322
35356
  manual ? HAND_ORDER_NOTE : ""
35323
35357
  ].filter(Boolean).join(" ")
35324
35358
  };
@@ -35365,9 +35399,9 @@ function ViewSwitcher({
35365
35399
  className
35366
35400
  }) {
35367
35401
  const pageSize = pageSizeAsked ?? (embedded ? EMBEDDED_PAGE_SIZE : 200);
35368
- const [layout, setLayout] = useState97(view.layout);
35369
- const [local, setLocal] = useState97({});
35370
- useEffect83(() => {
35402
+ const [layout, setLayout] = useState98(view.layout);
35403
+ const [local, setLocal] = useState98({});
35404
+ useEffect84(() => {
35371
35405
  setLayout(view.layout);
35372
35406
  setLocal({});
35373
35407
  }, [view.layout, view.name, view.subject]);
@@ -35463,8 +35497,8 @@ var UNUSUAL_FIELD_NOTE = "an unusual column to use here";
35463
35497
  function useFarFields(all) {
35464
35498
  const client = useRecordsClient66();
35465
35499
  const targets = lookupTargets(all).sort().join(",");
35466
- const [far, setFar] = useState97(() => /* @__PURE__ */ new Map());
35467
- useEffect83(() => {
35500
+ const [far, setFar] = useState98(() => /* @__PURE__ */ new Map());
35501
+ useEffect84(() => {
35468
35502
  let cancelled = false;
35469
35503
  const ids = targets ? targets.split(",") : [];
35470
35504
  if (ids.length === 0) {
@@ -35499,11 +35533,11 @@ function eligibleFieldFor(want, all, chosenKey, placing) {
35499
35533
  }
35500
35534
  function useStageField(tableId) {
35501
35535
  const client = useRecordsClient66();
35502
- const [stage, setStage] = useState97({
35536
+ const [stage, setStage] = useState98({
35503
35537
  asked: false,
35504
35538
  key: null
35505
35539
  });
35506
- useEffect83(() => {
35540
+ useEffect84(() => {
35507
35541
  let cancelled = false;
35508
35542
  setStage({ asked: false, key: null });
35509
35543
  void client.tableStageField({ table_id: tableId }).then((r) => {
@@ -35991,7 +36025,7 @@ function Kanban({
35991
36025
  for (const row of rows) for (const key of laneAxis.keysOf(row)) byLane.get(key)?.push(row);
35992
36026
  return laneAxis.names.map((name) => ({ name, rows: byLane.get(name) ?? [] })).filter((l) => !hideEmpty || l.rows.length > 0);
35993
36027
  }, [rows, laneAxis, hideEmpty]);
35994
- const [shutHere, setShutHere] = useState97([]);
36028
+ const [shutHere, setShutHere] = useState98([]);
35995
36029
  const shut = new Set(onLook ? board.boardLanesShut ?? [] : shutHere);
35996
36030
  const toggleLane = (name) => {
35997
36031
  const next = new Set(shut);
@@ -36333,8 +36367,8 @@ function RecordCard({
36333
36367
  }) {
36334
36368
  const host = useRecordsUi();
36335
36369
  const wanted = useMemo58(() => {
36336
- const asked2 = [field2 && pointsAtRecords(field2) ? field2 : null, parentField ?? null].filter((f) => f !== null);
36337
- return asked2.length > 0 ? asked2 : NO_FIELDS2;
36370
+ const asked3 = [field2 && pointsAtRecords(field2) ? field2 : null, parentField ?? null].filter((f) => f !== null);
36371
+ return asked3.length > 0 ? asked3 : NO_FIELDS2;
36338
36372
  }, [field2, parentField]);
36339
36373
  const labels = useRecordLabels(wanted);
36340
36374
  const { text: label, withheld } = cardWords(record, field2, labels);
@@ -36390,7 +36424,7 @@ function boardDefaultGroupField(eligible) {
36390
36424
  }
36391
36425
 
36392
36426
  // src/ArchivedView.tsx
36393
- import { useCallback as useCallback40, useEffect as useEffect84, useState as useState98 } from "react";
36427
+ import { useCallback as useCallback40, useEffect as useEffect85, useState as useState99 } from "react";
36394
36428
  import {
36395
36429
  ARCHIVE_LANES,
36396
36430
  ARCHIVE_LANE_LABEL,
@@ -36422,13 +36456,13 @@ function ArchivedView({
36422
36456
  const table = useTable19(tableId);
36423
36457
  const rights = useTableRights(table.data);
36424
36458
  const fields = useFields19(tableId);
36425
- const [lane, setLane] = useState98(laneFromHost ?? DEFAULT_ARCHIVE_LANE);
36426
- const [rows, setRows] = useState98([]);
36427
- const [loading, setLoading] = useState98(true);
36428
- const [error, setError] = useState98(null);
36429
- const [restoring, setRestoring] = useState98(null);
36430
- const [refusal3, setRefusal] = useState98(null);
36431
- useEffect84(() => {
36459
+ const [lane, setLane] = useState99(laneFromHost ?? DEFAULT_ARCHIVE_LANE);
36460
+ const [rows, setRows] = useState99([]);
36461
+ const [loading, setLoading] = useState99(true);
36462
+ const [error, setError] = useState99(null);
36463
+ const [restoring, setRestoring] = useState99(null);
36464
+ const [refusal3, setRefusal] = useState99(null);
36465
+ useEffect85(() => {
36432
36466
  if (laneFromHost) setLane(laneFromHost);
36433
36467
  }, [laneFromHost]);
36434
36468
  const read = useCallback40(async () => {
@@ -36443,7 +36477,7 @@ function ArchivedView({
36443
36477
  }
36444
36478
  setLoading(false);
36445
36479
  }, [client, tableId, lane, pageSize]);
36446
- useEffect84(() => {
36480
+ useEffect85(() => {
36447
36481
  void read();
36448
36482
  }, [read]);
36449
36483
  const pick = (next) => {
@@ -36530,10 +36564,10 @@ function retiredColumnLine(row) {
36530
36564
  }
36531
36565
  function RetiredColumns({ tableId, mayRestore, whyNot }) {
36532
36566
  const client = useRecordsClient67();
36533
- const [rows, setRows] = useState98(null);
36534
- const [error, setError] = useState98(null);
36535
- const [restoring, setRestoring] = useState98(null);
36536
- const [refusal3, setRefusal] = useState98(null);
36567
+ const [rows, setRows] = useState99(null);
36568
+ const [error, setError] = useState99(null);
36569
+ const [restoring, setRestoring] = useState99(null);
36570
+ const [refusal3, setRefusal] = useState99(null);
36537
36571
  const read = useCallback40(async () => {
36538
36572
  const answer = await client.fieldsRetired({ table_id: tableId });
36539
36573
  if (answer.ok) {
@@ -36544,7 +36578,7 @@ function RetiredColumns({ tableId, mayRestore, whyNot }) {
36544
36578
  setError(answer.error);
36545
36579
  }
36546
36580
  }, [client, tableId]);
36547
- useEffect84(() => {
36581
+ useEffect85(() => {
36548
36582
  void read();
36549
36583
  }, [read]);
36550
36584
  const restore = async (fieldId) => {
@@ -36589,7 +36623,7 @@ function RetiredColumns({ tableId, mayRestore, whyNot }) {
36589
36623
  }
36590
36624
 
36591
36625
  // src/ArchivedDisclosure.tsx
36592
- import { useCallback as useCallback41, useEffect as useEffect85, useState as useState99 } from "react";
36626
+ import { useCallback as useCallback41, useEffect as useEffect86, useState as useState100 } from "react";
36593
36627
  import {
36594
36628
  emptyPortalArchiveLine,
36595
36629
  portalConfirmLine,
@@ -36607,7 +36641,7 @@ function ArchivedDisclosure({
36607
36641
  children,
36608
36642
  className
36609
36643
  }) {
36610
- const [open, setOpen] = useState99(defaultOpen);
36644
+ const [open, setOpen] = useState100(defaultOpen);
36611
36645
  const toggle = () => {
36612
36646
  const next = !open;
36613
36647
  setOpen(next);
@@ -36641,13 +36675,13 @@ function ArchivedPortals({
36641
36675
  className
36642
36676
  }) {
36643
36677
  const client = useRecordsClient68();
36644
- const [rows, setRows] = useState99(null);
36645
- const [error, setError] = useState99(null);
36646
- const [confirming, setConfirming] = useState99(null);
36647
- const [typed2, setTyped] = useState99("");
36648
- const [restoring, setRestoring] = useState99(null);
36649
- const [refusal3, setRefusal] = useState99(null);
36650
- const [said2, setSaid] = useState99(null);
36678
+ const [rows, setRows] = useState100(null);
36679
+ const [error, setError] = useState100(null);
36680
+ const [confirming, setConfirming] = useState100(null);
36681
+ const [typed2, setTyped] = useState100("");
36682
+ const [restoring, setRestoring] = useState100(null);
36683
+ const [refusal3, setRefusal] = useState100(null);
36684
+ const [said2, setSaid] = useState100(null);
36651
36685
  const read = useCallback41(async () => {
36652
36686
  const answered = await client.listPortals({ archived: "archived" });
36653
36687
  if (answered.ok) {
@@ -36658,7 +36692,7 @@ function ArchivedPortals({
36658
36692
  setError(answered.error);
36659
36693
  }
36660
36694
  }, [client]);
36661
- useEffect85(() => {
36695
+ useEffect86(() => {
36662
36696
  void read();
36663
36697
  }, [read, refreshToken]);
36664
36698
  const restore = async (portal) => {
@@ -36774,7 +36808,7 @@ function ArchivedPortals({
36774
36808
  }
36775
36809
 
36776
36810
  // src/ViewBar.tsx
36777
- import { useCallback as useCallback43, useEffect as useEffect86, useRef as useRef48, useState as useState100 } from "react";
36811
+ import { useCallback as useCallback43, useEffect as useEffect87, useRef as useRef48, useState as useState101 } from "react";
36778
36812
  import { useRecordsClient as useRecordsClient69 } from "@ai-matrx/records/react";
36779
36813
  import { Badge as Badge15, Button as Button73, Input as Input6, Popover as Popover13, PopoverContent as PopoverContent13, PopoverTrigger as PopoverTrigger13, Skeleton as Skeleton15, cn as cn64 } from "@ai-matrx/design-system";
36780
36814
 
@@ -36836,18 +36870,18 @@ function ViewBar({ tableId, activeViewId, onActiveView, seed, settings, onViews,
36836
36870
  const table = useTable20(tableId);
36837
36871
  const rights = useTableRights(table.data);
36838
36872
  const notify = useRecordsUi().notify;
36839
- const [views, setViews] = useState100(() => initialViews ?? null);
36840
- const [error, setError] = useState100(null);
36841
- const [unavailable, setUnavailable] = useState100(false);
36842
- const [active, setActive] = useState100(() => {
36873
+ const [views, setViews] = useState101(() => initialViews ?? null);
36874
+ const [error, setError] = useState101(null);
36875
+ const [unavailable, setUnavailable] = useState101(false);
36876
+ const [active, setActive] = useState101(() => {
36843
36877
  if (!initialViews || initialViews.length === 0) return activeViewId ?? null;
36844
36878
  return (initialViews.find((v) => v.id === activeViewId) ?? defaultViewOf(initialViews) ?? initialViews[0]).id;
36845
36879
  });
36846
36880
  const readOnMount = useRef48(initialViews === void 0);
36847
- const [naming, setNaming] = useState100(false);
36848
- const [draftName, setDraftName] = useState100("");
36849
- const [open, setOpen] = useState100(false);
36850
- const [renaming, setRenaming] = useState100(null);
36881
+ const [naming, setNaming] = useState101(false);
36882
+ const [draftName, setDraftName] = useState101("");
36883
+ const [open, setOpen] = useState101(false);
36884
+ const [renaming, setRenaming] = useState101(null);
36851
36885
  const seedKey = JSON.stringify(seed ?? []);
36852
36886
  const readViews = useCallback43(async () => {
36853
36887
  const result = await client.views({ table_id: tableId });
@@ -36889,14 +36923,14 @@ function ViewBar({ tableId, activeViewId, onActiveView, seed, settings, onViews,
36889
36923
  setViews(mine);
36890
36924
  onViews?.(mine);
36891
36925
  }, [client, readViews, tableId, seedKey]);
36892
- useEffect86(() => {
36926
+ useEffect87(() => {
36893
36927
  if (!readOnMount.current) {
36894
36928
  readOnMount.current = true;
36895
36929
  return;
36896
36930
  }
36897
36931
  void load();
36898
36932
  }, [load]);
36899
- useEffect86(() => {
36933
+ useEffect87(() => {
36900
36934
  if (!views || views.length === 0) return;
36901
36935
  const chosen = views.find((v) => v.id === (activeViewId ?? active)) ?? defaultViewOf(views) ?? views[0];
36902
36936
  if (chosen.id !== active) setActive(chosen.id);
@@ -37124,7 +37158,7 @@ function ViewBar({ tableId, activeViewId, onActiveView, seed, settings, onViews,
37124
37158
  }
37125
37159
 
37126
37160
  // src/ProposalRow.tsx
37127
- import { useEffect as useEffect87, useRef as useRef49, useState as useState101 } from "react";
37161
+ import { useEffect as useEffect88, useRef as useRef49, useState as useState102 } from "react";
37128
37162
  import { useRecordsClient as useRecordsClient70 } from "@ai-matrx/records/react";
37129
37163
  import { Badge as Badge16, Button as Button74, cn as cn65 } from "@ai-matrx/design-system";
37130
37164
  import { jsx as jsx123, jsxs as jsxs113 } from "react/jsx-runtime";
@@ -37139,12 +37173,12 @@ function ProposalRow({
37139
37173
  className
37140
37174
  }) {
37141
37175
  const client = useRecordsClient70();
37142
- const [settled, setSettled] = useState101(outcome ?? null);
37143
- const [busy, setBusy] = useState101(false);
37144
- const [confirming, setConfirming] = useState101(false);
37176
+ const [settled, setSettled] = useState102(outcome ?? null);
37177
+ const [busy, setBusy] = useState102(false);
37178
+ const [confirming, setConfirming] = useState102(false);
37145
37179
  const drawnVersion = useRef49(null);
37146
37180
  const needsVersion = change.act === "update" && Boolean(change.record) && change.version === void 0 && !onApply && !settled;
37147
- useEffect87(() => {
37181
+ useEffect88(() => {
37148
37182
  if (needsVersion && change.record && !drawnVersion.current) drawnVersion.current = (0, recordVersions_exports.readVersionNow)(client, change.record);
37149
37183
  }, [needsVersion, change.record, client]);
37150
37184
  async function applyThroughTheStore() {
@@ -37232,14 +37266,14 @@ function ProposalRow({
37232
37266
  }
37233
37267
 
37234
37268
  // src/ActionInbox.tsx
37235
- import { useCallback as useCallback45, useEffect as useEffect89, useMemo as useMemo60, useRef as useRef50, useState as useState103 } from "react";
37269
+ import { useCallback as useCallback45, useEffect as useEffect90, useMemo as useMemo60, useRef as useRef50, useState as useState104 } from "react";
37236
37270
  import { useRecordsClient as useRecordsClient72 } from "@ai-matrx/records/react";
37237
37271
  import { Badge as Badge18, Button as Button76, Checkbox as Checkbox11, Skeleton as Skeleton17, cn as cn67 } from "@ai-matrx/design-system";
37238
37272
  import { toggleSelection as toggleSelection2 } from "@ai-matrx/design-system/data-table";
37239
37273
  import { formatAbsoluteDate, formatDurationMs } from "@ai-matrx/kit/format";
37240
37274
 
37241
37275
  // src/ChecklistRunner.tsx
37242
- import { useCallback as useCallback44, useEffect as useEffect88, useMemo as useMemo59, useState as useState102 } from "react";
37276
+ import { useCallback as useCallback44, useEffect as useEffect89, useMemo as useMemo59, useState as useState103 } from "react";
37243
37277
  import { useRecordsClient as useRecordsClient71, useTable as useTable21 } from "@ai-matrx/records/react";
37244
37278
  import { Badge as Badge17, BasicInput as BasicInput22, BasicTextarea as BasicTextarea9, Button as Button75, Skeleton as Skeleton16, cn as cn66 } from "@ai-matrx/design-system";
37245
37279
  import { humanizeIdentifier as humanizeIdentifier14 } from "@ai-matrx/kit/text-case";
@@ -37259,13 +37293,13 @@ function ChecklistRunner({
37259
37293
  const client = useRecordsClient71();
37260
37294
  const table = useTable21(tableId ?? null);
37261
37295
  const rights = useTableRights(table.data);
37262
- const [runs, setRuns] = useState102(null);
37263
- const [activeId, setActiveId] = useState102(runId ?? null);
37264
- const [steps, setSteps] = useState102(null);
37265
- const [templates, setTemplates] = useState102(null);
37266
- const [error, setError] = useState102(null);
37267
- const [busy, setBusy] = useState102(null);
37268
- const [said2, setSaid] = useState102(null);
37296
+ const [runs, setRuns] = useState103(null);
37297
+ const [activeId, setActiveId] = useState103(runId ?? null);
37298
+ const [steps, setSteps] = useState103(null);
37299
+ const [templates, setTemplates] = useState103(null);
37300
+ const [error, setError] = useState103(null);
37301
+ const [busy, setBusy] = useState103(null);
37302
+ const [said2, setSaid] = useState103(null);
37269
37303
  const mayStart = offerToStart ?? Boolean(recordId);
37270
37304
  const loadRuns = useCallback44(async () => {
37271
37305
  if (runId) {
@@ -37289,10 +37323,10 @@ function ChecklistRunner({
37289
37323
  (held) => held && answered.data.some((r) => r.run_id === held) ? held : answered.data[0]?.run_id ?? null
37290
37324
  );
37291
37325
  }, [client, includeClosed, recordId, runId, tableId]);
37292
- useEffect88(() => {
37326
+ useEffect89(() => {
37293
37327
  void loadRuns();
37294
37328
  }, [loadRuns]);
37295
- useEffect88(() => {
37329
+ useEffect89(() => {
37296
37330
  if (runId) setActiveId(runId);
37297
37331
  }, [runId]);
37298
37332
  const loadSteps = useCallback44(async () => {
@@ -37309,10 +37343,10 @@ function ChecklistRunner({
37309
37343
  setError(null);
37310
37344
  setSteps(answered.data);
37311
37345
  }, [client, activeId]);
37312
- useEffect88(() => {
37346
+ useEffect89(() => {
37313
37347
  void loadSteps();
37314
37348
  }, [loadSteps]);
37315
- useEffect88(() => {
37349
+ useEffect89(() => {
37316
37350
  if (!mayStart || !tableId) return;
37317
37351
  let cancelled = false;
37318
37352
  void client.checklistTemplates({ about_table_id: tableId, limit: 50 }).then((answered) => {
@@ -37444,9 +37478,9 @@ function StepRow({
37444
37478
  className
37445
37479
  }) {
37446
37480
  const host = useRecordsUi();
37447
- const [members, setMembers] = useState102(null);
37481
+ const [members, setMembers] = useState103(null);
37448
37482
  const unassigned = !step2.finished && !step2.assignee_user_id && Boolean(step2.role);
37449
- useEffect88(() => {
37483
+ useEffect89(() => {
37450
37484
  if (!unassigned || !onAssign || !host.members || members !== null) return;
37451
37485
  let alive = true;
37452
37486
  void host.members().then((roster) => {
@@ -37456,7 +37490,7 @@ function StepRow({
37456
37490
  alive = false;
37457
37491
  };
37458
37492
  }, [unassigned, onAssign, host, members]);
37459
- const [answer, setAnswer] = useState102("");
37493
+ const [answer, setAnswer] = useState103("");
37460
37494
  const key = step2.requires_key ?? (step2.requires === "note" ? "note" : null);
37461
37495
  const asksHere = step2.requires === "note" || step2.requires === "answer";
37462
37496
  const needsAnswer = asksHere && answer.trim().length === 0;
@@ -37550,9 +37584,9 @@ function StepRow({
37550
37584
  function useMyChecklistSteps(limit = 25) {
37551
37585
  const client = useRecordsClient71();
37552
37586
  const me = client.config.actor.user_id ?? null;
37553
- const [steps, setSteps] = useState102([]);
37554
- const [loading, setLoading] = useState102(true);
37555
- const [error, setError] = useState102(null);
37587
+ const [steps, setSteps] = useState103([]);
37588
+ const [loading, setLoading] = useState103(true);
37589
+ const [error, setError] = useState103(null);
37556
37590
  const refresh = useCallback44(async () => {
37557
37591
  if (!me) {
37558
37592
  setSteps([]);
@@ -37581,7 +37615,7 @@ function useMyChecklistSteps(limit = 25) {
37581
37615
  setSteps(held);
37582
37616
  setLoading(false);
37583
37617
  }, [client, limit, me]);
37584
- useEffect88(() => {
37618
+ useEffect89(() => {
37585
37619
  void refresh();
37586
37620
  }, [refresh]);
37587
37621
  return { steps, loading, error, refresh };
@@ -37594,12 +37628,12 @@ function MyChecklistSteps({
37594
37628
  }) {
37595
37629
  const client = useRecordsClient71();
37596
37630
  const { steps: held, loading, error, refresh } = useMyChecklistSteps();
37597
- useEffect88(() => {
37631
+ useEffect89(() => {
37598
37632
  onSteps?.(held.map((s) => s.step_id));
37599
37633
  }, [held, onSteps]);
37600
37634
  const steps = onlyIds ? held.filter((s) => onlyIds.has(s.step_id)) : held;
37601
- const [busy, setBusy] = useState102(null);
37602
- const [refusal3, setRefusal] = useState102(null);
37635
+ const [busy, setBusy] = useState103(null);
37636
+ const [refusal3, setRefusal] = useState103(null);
37603
37637
  const complete = useCallback44(
37604
37638
  async (step2, evidence) => {
37605
37639
  setBusy(step2.step_id);
@@ -37643,12 +37677,12 @@ function ChecklistsPanel({ tableId, onOpenRecord, className }) {
37643
37677
  const client = useRecordsClient71();
37644
37678
  const table = useTable21(tableId);
37645
37679
  const rights = useTableRights(table.data);
37646
- const [templates, setTemplates] = useState102(null);
37647
- const [runs, setRuns] = useState102(null);
37648
- const [error, setError] = useState102(null);
37649
- const [editing, setEditing] = useState102(null);
37650
- const [openRun, setOpenRun] = useState102(null);
37651
- const [archivedSaid, setArchivedSaid] = useState102(null);
37680
+ const [templates, setTemplates] = useState103(null);
37681
+ const [runs, setRuns] = useState103(null);
37682
+ const [error, setError] = useState103(null);
37683
+ const [editing, setEditing] = useState103(null);
37684
+ const [openRun, setOpenRun] = useState103(null);
37685
+ const [archivedSaid, setArchivedSaid] = useState103(null);
37652
37686
  const load = useCallback44(async () => {
37653
37687
  const [t, r] = await Promise.all([
37654
37688
  client.checklistTemplates({ about_table_id: tableId, limit: 100 }),
@@ -37663,7 +37697,7 @@ function ChecklistsPanel({ tableId, onOpenRecord, className }) {
37663
37697
  if (!r.ok) setRuns([]);
37664
37698
  else setRuns(r.data);
37665
37699
  }, [client, tableId]);
37666
- useEffect88(() => {
37700
+ useEffect89(() => {
37667
37701
  void load();
37668
37702
  }, [load]);
37669
37703
  if (templates === null) return /* @__PURE__ */ jsx124(Skeleton16, { className: cn66("h-40 w-full", className) });
@@ -37818,15 +37852,15 @@ function ChecklistTemplateEditor({
37818
37852
  className
37819
37853
  }) {
37820
37854
  const client = useRecordsClient71();
37821
- const [savedId, setSavedId] = useState102(templateId ?? null);
37822
- const [saved, setSaved] = useState102(false);
37823
- const [name, setName] = useState102("");
37824
- const [rows, setRows] = useState102([{ ...EMPTY_ROW }]);
37825
- const [refusal3, setRefusal] = useState102(null);
37826
- const [error, setError] = useState102(null);
37827
- const [busy, setBusy] = useState102(false);
37828
- const [loading, setLoading] = useState102(Boolean(templateId));
37829
- useEffect88(() => {
37855
+ const [savedId, setSavedId] = useState103(templateId ?? null);
37856
+ const [saved, setSaved] = useState103(false);
37857
+ const [name, setName] = useState103("");
37858
+ const [rows, setRows] = useState103([{ ...EMPTY_ROW }]);
37859
+ const [refusal3, setRefusal] = useState103(null);
37860
+ const [error, setError] = useState103(null);
37861
+ const [busy, setBusy] = useState103(false);
37862
+ const [loading, setLoading] = useState103(Boolean(templateId));
37863
+ useEffect89(() => {
37830
37864
  if (!templateId) return;
37831
37865
  let cancelled = false;
37832
37866
  void client.checklistTemplateShape({ template_id: templateId }).then((answered) => {
@@ -37863,8 +37897,8 @@ function ChecklistTemplateEditor({
37863
37897
  }),
37864
37898
  [aboutTableId, name, rows]
37865
37899
  );
37866
- useEffect88(() => setSaved(false), [spec]);
37867
- useEffect88(() => {
37900
+ useEffect89(() => setSaved(false), [spec]);
37901
+ useEffect89(() => {
37868
37902
  if (spec.steps.length === 0 || spec.name.length === 0) {
37869
37903
  setRefusal(null);
37870
37904
  return;
@@ -38126,25 +38160,25 @@ function ActionInbox({
38126
38160
  className
38127
38161
  }) {
38128
38162
  const client = useRecordsClient72();
38129
- const [showDecided, setShowDecided] = useState103(includeSettled);
38130
- const [groupBy, setGroupBy] = useState103(defaultGroupBy);
38131
- const [everyTable, setEveryTable] = useState103(false);
38132
- const [items, setItems] = useState103(null);
38133
- const [error, setError] = useState103(null);
38134
- const [outcome, setOutcome] = useState103({});
38135
- const [busy, setBusy] = useState103(null);
38136
- const [cursor, setCursor] = useState103(0);
38163
+ const [showDecided, setShowDecided] = useState104(includeSettled);
38164
+ const [groupBy, setGroupBy] = useState104(defaultGroupBy);
38165
+ const [everyTable, setEveryTable] = useState104(false);
38166
+ const [items, setItems] = useState104(null);
38167
+ const [error, setError] = useState104(null);
38168
+ const [outcome, setOutcome] = useState104({});
38169
+ const [busy, setBusy] = useState104(null);
38170
+ const [cursor, setCursor] = useState104(0);
38137
38171
  const listRef = useRef50(null);
38138
- const [selected, setSelected] = useState103(/* @__PURE__ */ new Set());
38172
+ const [selected, setSelected] = useState104(/* @__PURE__ */ new Set());
38139
38173
  const anchor = useRef50(null);
38140
- const [deciding, setDeciding] = useState103(false);
38141
- const [batchSaid, setBatchSaid] = useState103(null);
38142
- const [view, setView] = useState103("inbox");
38143
- const [counts, setCounts] = useState103(null);
38144
- const [snoozing, setSnoozing] = useState103(null);
38145
- const [pickAt, setPickAt] = useState103("");
38146
- const [said2, setSaid] = useState103(null);
38147
- const [stepIds, setStepIds] = useState103(/* @__PURE__ */ new Set());
38174
+ const [deciding, setDeciding] = useState104(false);
38175
+ const [batchSaid, setBatchSaid] = useState104(null);
38176
+ const [view, setView] = useState104("inbox");
38177
+ const [counts, setCounts] = useState104(null);
38178
+ const [snoozing, setSnoozing] = useState104(null);
38179
+ const [pickAt, setPickAt] = useState104("");
38180
+ const [said2, setSaid] = useState104(null);
38181
+ const [stepIds, setStepIds] = useState104(/* @__PURE__ */ new Set());
38148
38182
  const onSteps = useCallback45((ids) => setStepIds(new Set(ids)), []);
38149
38183
  const load = useCallback45(async () => {
38150
38184
  const [result, counted] = await Promise.all([
@@ -38160,7 +38194,7 @@ function ActionInbox({
38160
38194
  setError(null);
38161
38195
  setItems(result.data);
38162
38196
  }, [client, showDecided, view]);
38163
- useEffect89(() => {
38197
+ useEffect90(() => {
38164
38198
  void load();
38165
38199
  }, [load]);
38166
38200
  const narrowed = useMemo60(() => {
@@ -38175,10 +38209,10 @@ function ActionInbox({
38175
38209
  const groups = useMemo60(() => groupInbox(narrowed, groupBy), [narrowed, groupBy]);
38176
38210
  const shown4 = useMemo60(() => groups.flatMap((g) => g.items), [groups]);
38177
38211
  const elsewhere = (items?.length ?? 0) - narrowed.length;
38178
- useEffect89(() => {
38212
+ useEffect90(() => {
38179
38213
  if (cursor >= shown4.length) setCursor(Math.max(0, shown4.length - 1));
38180
38214
  }, [shown4.length, cursor]);
38181
- useEffect89(() => {
38215
+ useEffect90(() => {
38182
38216
  const list = listRef.current;
38183
38217
  const el = list?.querySelector(`[data-row="${cursor}"]`);
38184
38218
  if (list && el) scrollWithinList(list, el);
@@ -38199,12 +38233,12 @@ function ActionInbox({
38199
38233
  },
38200
38234
  [client, load]
38201
38235
  );
38202
- const [held, setHeld] = useState103({});
38236
+ const [held, setHeld] = useState104({});
38203
38237
  const holds2 = useRef50(/* @__PURE__ */ new Map());
38204
38238
  const lastHold = useRef50(null);
38205
38239
  const holdSeq = useRef50(0);
38206
- const [, tick] = useState103(0);
38207
- useEffect89(() => {
38240
+ const [, tick] = useState104(0);
38241
+ useEffect90(() => {
38208
38242
  if (Object.keys(held).length === 0) return;
38209
38243
  const t = setInterval(() => tick((n) => n + 1), 250);
38210
38244
  return () => clearInterval(t);
@@ -38249,7 +38283,7 @@ function ActionInbox({
38249
38283
  });
38250
38284
  setSaid({ text: entry.ids.length === 1 ? "Undone. It is waiting on you again, exactly as it was." : `Undone. All ${entry.ids.length} are waiting on you again, exactly as they were.`, undo: null });
38251
38285
  }, []);
38252
- useEffect89(() => {
38286
+ useEffect90(() => {
38253
38287
  const flush = () => {
38254
38288
  for (const entry of [...holds2.current.values()]) entry.commit();
38255
38289
  };
@@ -38260,7 +38294,7 @@ function ActionInbox({
38260
38294
  };
38261
38295
  }, []);
38262
38296
  const resumed = useRef50(false);
38263
- useEffect89(() => {
38297
+ useEffect90(() => {
38264
38298
  if (resumed.current || items === null || view !== "inbox") return;
38265
38299
  resumed.current = true;
38266
38300
  const kept = readHolds();
@@ -38880,7 +38914,7 @@ function ActionInbox({
38880
38914
  }
38881
38915
 
38882
38916
  // src/HistoryPanel.tsx
38883
- import { useCallback as useCallback46, useEffect as useEffect90, useRef as useRef51, useState as useState104 } from "react";
38917
+ import { useCallback as useCallback46, useEffect as useEffect91, useRef as useRef51, useState as useState105 } from "react";
38884
38918
  import {
38885
38919
  useFields as useFields20,
38886
38920
  useRecordChangeRevision,
@@ -38896,12 +38930,12 @@ function HistoryPanel({ tableId, recordId, onAskAboutField, className }) {
38896
38930
  const table = useTable22(tableId);
38897
38931
  const fields = useFields20(tableId);
38898
38932
  const rights = useTableRights(table.data);
38899
- const [entries, setEntries] = useState104(null);
38900
- const [error, setError] = useState104(null);
38901
- const [open, setOpen] = useState104(null);
38902
- const [pending, setPending] = useState104({ phase: "idle" });
38933
+ const [entries, setEntries] = useState105(null);
38934
+ const [error, setError] = useState105(null);
38935
+ const [open, setOpen] = useState105(null);
38936
+ const [pending, setPending] = useState105({ phase: "idle" });
38903
38937
  const seenAtPreview = useRef51(null);
38904
- const [said2, setSaid] = useState104(null);
38938
+ const [said2, setSaid] = useState105(null);
38905
38939
  const listRef = useRef51(null);
38906
38940
  const changed = useRecordChangeRevision(recordId);
38907
38941
  const load = useCallback46(async () => {
@@ -38913,7 +38947,7 @@ function HistoryPanel({ tableId, recordId, onAskAboutField, className }) {
38913
38947
  setError(null);
38914
38948
  setEntries(answered.data);
38915
38949
  }, [client, recordId, changed]);
38916
- useEffect90(() => {
38950
+ useEffect91(() => {
38917
38951
  void load();
38918
38952
  }, [load]);
38919
38953
  if (error) return /* @__PURE__ */ jsx126(RefusalNotice, { error, className });
@@ -38924,17 +38958,17 @@ function HistoryPanel({ tableId, recordId, onAskAboutField, className }) {
38924
38958
  async function startRestore(version, fieldKey) {
38925
38959
  setSaid(null);
38926
38960
  setPending({ phase: "asking", version, fieldKey });
38927
- const [asked2, seen] = await Promise.all([
38961
+ const [asked3, seen] = await Promise.all([
38928
38962
  client.restorePreview(fieldKey ? { record_id: recordId, version, field_key: fieldKey } : { record_id: recordId, version }),
38929
38963
  (0, recordVersions_exports.readVersionNow)(client, recordId)
38930
38964
  ]);
38931
38965
  seenAtPreview.current = seen;
38932
- if (!asked2.ok) {
38966
+ if (!asked3.ok) {
38933
38967
  setPending({ phase: "idle" });
38934
- setError(asked2.error);
38968
+ setError(asked3.error);
38935
38969
  return;
38936
38970
  }
38937
- setPending({ phase: "confirm", version, fieldKey, preview: asked2.data });
38971
+ setPending({ phase: "confirm", version, fieldKey, preview: asked3.data });
38938
38972
  }
38939
38973
  async function doRestore(version, fieldKey) {
38940
38974
  setPending({ phase: "writing", version, fieldKey });
@@ -39196,7 +39230,7 @@ function say(value, field2) {
39196
39230
  }
39197
39231
 
39198
39232
  // src/CommentThread.tsx
39199
- import { useCallback as useCallback47, useEffect as useEffect91, useMemo as useMemo61, useRef as useRef52, useState as useState105 } from "react";
39233
+ import { useCallback as useCallback47, useEffect as useEffect92, useMemo as useMemo61, useRef as useRef52, useState as useState106 } from "react";
39200
39234
  import {
39201
39235
  useFields as useFields21,
39202
39236
  useRecordsClient as useRecordsClient74,
@@ -39210,16 +39244,16 @@ function CommentThread({ tableId, recordId, fieldKey, className }) {
39210
39244
  const table = useTable23(tableId);
39211
39245
  const fields = useFields21(tableId);
39212
39246
  const host = useRecordsUi();
39213
- const [thread, setThread] = useState105(null);
39214
- const [error, setError] = useState105(null);
39215
- const [draft, setDraft] = useState105("");
39216
- const [replyTo, setReplyTo] = useState105(null);
39217
- const [busy, setBusy] = useState105(false);
39218
- const [said2, setSaid] = useState105(null);
39219
- const [showResolved, setShowResolved] = useState105(false);
39220
- const [people, setPeople] = useState105([]);
39221
- const [mentionQuery, setMentionQuery] = useState105(null);
39222
- const [picked, setPicked] = useState105([]);
39247
+ const [thread, setThread] = useState106(null);
39248
+ const [error, setError] = useState106(null);
39249
+ const [draft, setDraft] = useState106("");
39250
+ const [replyTo, setReplyTo] = useState106(null);
39251
+ const [busy, setBusy] = useState106(false);
39252
+ const [said2, setSaid] = useState106(null);
39253
+ const [showResolved, setShowResolved] = useState106(false);
39254
+ const [people, setPeople] = useState106([]);
39255
+ const [mentionQuery, setMentionQuery] = useState106(null);
39256
+ const [picked, setPicked] = useState106([]);
39223
39257
  const box = useRef52(null);
39224
39258
  const load = useCallback47(async () => {
39225
39259
  const answered = await client.commentThread({ record_id: recordId, include_resolved: showResolved });
@@ -39234,10 +39268,10 @@ function CommentThread({ tableId, recordId, fieldKey, className }) {
39234
39268
  mayResolve: answered.data.may_resolve
39235
39269
  });
39236
39270
  }, [client, recordId, showResolved]);
39237
- useEffect91(() => {
39271
+ useEffect92(() => {
39238
39272
  void load();
39239
39273
  }, [load]);
39240
- useEffect91(() => {
39274
+ useEffect92(() => {
39241
39275
  let alive = true;
39242
39276
  if (!host.members) return;
39243
39277
  void host.members().then((roster) => {
@@ -39440,7 +39474,7 @@ function Line2({
39440
39474
  }
39441
39475
 
39442
39476
  // src/FieldHistoryPanel.tsx
39443
- import { useCallback as useCallback48, useEffect as useEffect92, useRef as useRef53, useState as useState106 } from "react";
39477
+ import { useCallback as useCallback48, useEffect as useEffect93, useRef as useRef53, useState as useState107 } from "react";
39444
39478
  import {
39445
39479
  useFields as useFields22,
39446
39480
  useRecordsClient as useRecordsClient75,
@@ -39461,11 +39495,11 @@ function FieldHistoryPanel({
39461
39495
  const table = useTable24(tableId);
39462
39496
  const fields = useFields22(tableId);
39463
39497
  const rights = useTableRights(table.data);
39464
- const [rows, setRows] = useState106(null);
39465
- const [error, setError] = useState106(null);
39466
- const [pending, setPending] = useState106({ phase: "idle" });
39498
+ const [rows, setRows] = useState107(null);
39499
+ const [error, setError] = useState107(null);
39500
+ const [pending, setPending] = useState107({ phase: "idle" });
39467
39501
  const seenAtPreview = useRef53(null);
39468
- const [said2, setSaid] = useState106(null);
39502
+ const [said2, setSaid] = useState107(null);
39469
39503
  const load = useCallback48(async () => {
39470
39504
  const answered = await client.fieldHistory(
39471
39505
  recordId ? { table_id: tableId, field_key: fieldKey, record_id: recordId } : { table_id: tableId, field_key: fieldKey }
@@ -39477,7 +39511,7 @@ function FieldHistoryPanel({
39477
39511
  setError(null);
39478
39512
  setRows(answered.data);
39479
39513
  }, [client, tableId, fieldKey, recordId]);
39480
- useEffect92(() => {
39514
+ useEffect93(() => {
39481
39515
  void load();
39482
39516
  }, [load]);
39483
39517
  const label = (fields.data ?? []).find((f) => f.key === fieldKey)?.label || humanizeIdentifier17(fieldKey);
@@ -39486,17 +39520,17 @@ function FieldHistoryPanel({
39486
39520
  async function start(row) {
39487
39521
  setSaid(null);
39488
39522
  setPending({ phase: "asking", recordId: row.record_id, version: row.version });
39489
- const [asked2, seen] = await Promise.all([
39523
+ const [asked3, seen] = await Promise.all([
39490
39524
  client.restorePreview({ record_id: row.record_id, version: row.version, field_key: fieldKey }),
39491
39525
  (0, recordVersions_exports.readVersionNow)(client, row.record_id)
39492
39526
  ]);
39493
39527
  seenAtPreview.current = seen;
39494
- if (!asked2.ok) {
39528
+ if (!asked3.ok) {
39495
39529
  setPending({ phase: "idle" });
39496
- setError(asked2.error);
39530
+ setError(asked3.error);
39497
39531
  return;
39498
39532
  }
39499
- setPending({ phase: "confirm", recordId: row.record_id, version: row.version, preview: asked2.data });
39533
+ setPending({ phase: "confirm", recordId: row.record_id, version: row.version, preview: asked3.data });
39500
39534
  }
39501
39535
  async function confirm(recordOf2, version) {
39502
39536
  setPending({ phase: "writing", recordId: recordOf2, version });
@@ -39589,8 +39623,8 @@ function FieldHistoryPanel({
39589
39623
  import { FORM_FLOWS as FORM_FLOWS2, FORM_EMBEDS as FORM_EMBEDS2, formDeclareArgs as formDeclareArgs2, formFromSummary as formFromSummary4, formPresentation, formLookDocument as formLookDocument2, formLookFromDocument, submissionStamp as submissionStamp2, formEmbedSnippet as formEmbedSnippet2, formRoutes as formRoutes2, hiddenFromLink, endingsFromDocument, welcomeFromDocument, themeFromDocument } from "@ai-matrx/records/forms";
39590
39624
 
39591
39625
  // src/FormResultsPanel.tsx
39592
- import { useEffect as useEffect93, useMemo as useMemo62, useState as useState107 } from "react";
39593
- import { useFields as useFields23, useOptionalRecordsClient as useOptionalRecordsClient17 } from "@ai-matrx/records/react";
39626
+ import { useEffect as useEffect94, useMemo as useMemo62, useState as useState108 } from "react";
39627
+ import { useFields as useFields23, useOptionalRecordsClient as useOptionalRecordsClient18 } from "@ai-matrx/records/react";
39594
39628
  import { Button as Button80, Skeleton as Skeleton21, cn as cn71 } from "@ai-matrx/design-system";
39595
39629
  import { jsx as jsx129, jsxs as jsxs119 } from "react/jsx-runtime";
39596
39630
  var CHARTED_KINDS = /* @__PURE__ */ new Set(["select", "multi_select", "checkbox", "number", "currency", "percent", "member", "relation"]);
@@ -39613,12 +39647,12 @@ function answersBlock(question, title) {
39613
39647
  };
39614
39648
  }
39615
39649
  function FormResultsPanel({ form, className }) {
39616
- const client = useOptionalRecordsClient17();
39650
+ const client = useOptionalRecordsClient18();
39617
39651
  const fields = useFields23(form.subject);
39618
- const [results, setResults] = useState107(null);
39619
- const [error, setError] = useState107(null);
39620
- const [round, setRound] = useState107(0);
39621
- useEffect93(() => {
39652
+ const [results, setResults] = useState108(null);
39653
+ const [error, setError] = useState108(null);
39654
+ const [round, setRound] = useState108(0);
39655
+ useEffect94(() => {
39622
39656
  if (!client) {
39623
39657
  setError((0, refusals_exports.refusal)("not_supported", "Results are read from the record store, and this screen has none.", "Open the form inside the app."));
39624
39658
  return;
@@ -39716,7 +39750,7 @@ function FormResultsPanel({ form, className }) {
39716
39750
  }
39717
39751
 
39718
39752
  // src/PortalBuilder.tsx
39719
- import { useCallback as useCallback49, useEffect as useEffect94, useMemo as useMemo63, useRef as useRef54, useState as useState108 } from "react";
39753
+ import { useCallback as useCallback49, useEffect as useEffect95, useMemo as useMemo63, useRef as useRef54, useState as useState109 } from "react";
39720
39754
  import { useRecordsClient as useRecordsClient76, useTables as useTables4 } from "@ai-matrx/records/react";
39721
39755
  import { BasicInput as BasicInput23, Button as Button81, Checkbox as Checkbox12, Label as Label19, Separator as Separator10, Skeleton as Skeleton22, cn as cn72 } from "@ai-matrx/design-system";
39722
39756
  import { Fragment as Fragment51, jsx as jsx130, jsxs as jsxs120 } from "react/jsx-runtime";
@@ -39724,19 +39758,19 @@ var RESTATING_REPLACES = "Saving replaces what this portal shows: a table you un
39724
39758
  function PortalBuilder({ tableId, portalId, onSaved, onClose, className }) {
39725
39759
  const client = useRecordsClient76();
39726
39760
  const tables = useTables4();
39727
- const [title, setTitle] = useState108("");
39728
- const [clientTableId, setClientTableId] = useState108(null);
39729
- const [exposures, setExposures] = useState108({});
39730
- const [fieldsByTable, setFieldsByTable] = useState108({});
39731
- const [error, setError] = useState108(null);
39732
- const [saving, setSaving] = useState108(false);
39733
- const [savedId, setSavedId] = useState108(portalId ?? null);
39734
- const [existing, setExisting] = useState108(null);
39735
- const [loading, setLoading] = useState108(Boolean(portalId));
39736
- const [inviteEmail, setInviteEmail] = useState108("");
39737
- const [inviteRecordId, setInviteRecordId] = useState108("");
39738
- const [inviting, setInviting] = useState108(false);
39739
- const [invitationSaid, setInvitationSaid] = useState108(null);
39761
+ const [title, setTitle] = useState109("");
39762
+ const [clientTableId, setClientTableId] = useState109(null);
39763
+ const [exposures, setExposures] = useState109({});
39764
+ const [fieldsByTable, setFieldsByTable] = useState109({});
39765
+ const [error, setError] = useState109(null);
39766
+ const [saving, setSaving] = useState109(false);
39767
+ const [savedId, setSavedId] = useState109(portalId ?? null);
39768
+ const [existing, setExisting] = useState109(null);
39769
+ const [loading, setLoading] = useState109(Boolean(portalId));
39770
+ const [inviteEmail, setInviteEmail] = useState109("");
39771
+ const [inviteRecordId, setInviteRecordId] = useState109("");
39772
+ const [inviting, setInviting] = useState109(false);
39773
+ const [invitationSaid, setInvitationSaid] = useState109(null);
39740
39774
  const loadFields = useCallback49(
39741
39775
  async (id, fresh = false) => {
39742
39776
  if (fieldsByTable[id] && !fresh) return;
@@ -39749,7 +39783,7 @@ function PortalBuilder({ tableId, portalId, onSaved, onClose, className }) {
39749
39783
  },
39750
39784
  [client, fieldsByTable]
39751
39785
  );
39752
- useEffect94(() => {
39786
+ useEffect95(() => {
39753
39787
  if (!portalId) return;
39754
39788
  void (async () => {
39755
39789
  const answered = await client.portalCard({ portal_id: portalId });
@@ -39763,7 +39797,7 @@ function PortalBuilder({ tableId, portalId, onSaved, onClose, className }) {
39763
39797
  setClientTableId(answered.data.client_table_id);
39764
39798
  })();
39765
39799
  }, [client, portalId]);
39766
- useEffect94(() => {
39800
+ useEffect95(() => {
39767
39801
  if (!tableId) return;
39768
39802
  setExposures(
39769
39803
  (prev) => prev[tableId] ? prev : {
@@ -39776,7 +39810,7 @@ function PortalBuilder({ tableId, portalId, onSaved, onClose, className }) {
39776
39810
  const cameFromPeople = Boolean(
39777
39811
  tableId && (fieldsByTable[tableId] ?? []).some((f) => editorKindFor(f) === "email")
39778
39812
  );
39779
- useEffect94(() => {
39813
+ useEffect95(() => {
39780
39814
  if (!tableId || portalId || clientTableId !== null || !cameFromPeople) return;
39781
39815
  setClientTableId(tableId);
39782
39816
  setExposures((prev) => {
@@ -39791,7 +39825,7 @@ function PortalBuilder({ tableId, portalId, onSaved, onClose, className }) {
39791
39825
  ),
39792
39826
  [fieldsByTable, clientTableId]
39793
39827
  );
39794
- useEffect94(() => {
39828
+ useEffect95(() => {
39795
39829
  for (const e of Object.values(exposures)) {
39796
39830
  if (!e.on || e.namesVia.trim() !== "") continue;
39797
39831
  const ties = tiesTo(e.tableId);
@@ -39805,7 +39839,7 @@ function PortalBuilder({ tableId, portalId, onSaved, onClose, className }) {
39805
39839
  }));
39806
39840
  if (on) void loadFields(t.id);
39807
39841
  }
39808
- const [linking, setLinking] = useState108(null);
39842
+ const [linking, setLinking] = useState109(null);
39809
39843
  const linkingNow = useRef54(null);
39810
39844
  async function addLinkBack(id) {
39811
39845
  const clients = (tables.data ?? []).find((t) => t.id === clientTableId);
@@ -39834,7 +39868,7 @@ function PortalBuilder({ tableId, portalId, onSaved, onClose, className }) {
39834
39868
  setLinking(null);
39835
39869
  }
39836
39870
  const autoLinked = useRef54(/* @__PURE__ */ new Set());
39837
- useEffect94(() => {
39871
+ useEffect95(() => {
39838
39872
  if (linking !== null || !clientTableId) return;
39839
39873
  for (const e of Object.values(exposures)) {
39840
39874
  if (!e.on || !fieldsByTable[e.tableId] || autoLinked.current.has(e.tableId)) continue;
@@ -40108,7 +40142,7 @@ function clientNoun(table) {
40108
40142
 
40109
40143
  // src/PortalsPanel.tsx
40110
40144
  import { copyText as copyText7 } from "@ai-matrx/kit/clipboard";
40111
- import { useCallback as useCallback50, useEffect as useEffect96, useMemo as useMemo65, useState as useState110 } from "react";
40145
+ import { useCallback as useCallback50, useEffect as useEffect97, useMemo as useMemo65, useState as useState111 } from "react";
40112
40146
  import { useRecordsClient as useRecordsClient78 } from "@ai-matrx/records/react";
40113
40147
  import {
40114
40148
  portalArchiveConsequence,
@@ -40119,7 +40153,7 @@ import {
40119
40153
  import { Badge as Badge22, BasicInput as BasicInput25, Button as Button83, Separator as Separator11, Skeleton as Skeleton23, cn as cn75 } from "@ai-matrx/design-system";
40120
40154
 
40121
40155
  // src/PortalLookEditor.tsx
40122
- import { useEffect as useEffect95, useMemo as useMemo64, useState as useState109 } from "react";
40156
+ import { useEffect as useEffect96, useMemo as useMemo64, useState as useState110 } from "react";
40123
40157
  import { useRecordsClient as useRecordsClient77 } from "@ai-matrx/records/react";
40124
40158
  import { BasicInput as BasicInput24, Button as Button82, cn as cn74 } from "@ai-matrx/design-system";
40125
40159
 
@@ -40196,18 +40230,18 @@ function candidateRows(card, available) {
40196
40230
  function PortalLookEditor({ card, onSaved, className }) {
40197
40231
  const client = useRecordsClient77();
40198
40232
  const stored = card.config?.style ?? {};
40199
- const [name, setName] = useState109(stored.display_name ?? "");
40200
- const [welcome, setWelcome] = useState109(stored.welcome ?? "");
40201
- const [logo, setLogo] = useState109(stored.logo_file_id ?? "");
40202
- const [accent, setAccent] = useState109(stored.accent ?? "");
40203
- const [links, setLinks] = useState109(stored.footer_links ?? []);
40204
- const [forms, setForms] = useState109(null);
40205
- const [busy, setBusy] = useState109(false);
40206
- const [error, setError] = useState109(null);
40207
- const [said2, setSaid] = useState109(null);
40208
- const [formsError, setFormsError] = useState109(null);
40209
- const [formsUnread, setFormsUnread] = useState109(false);
40210
- useEffect95(() => {
40233
+ const [name, setName] = useState110(stored.display_name ?? "");
40234
+ const [welcome, setWelcome] = useState110(stored.welcome ?? "");
40235
+ const [logo, setLogo] = useState110(stored.logo_file_id ?? "");
40236
+ const [accent, setAccent] = useState110(stored.accent ?? "");
40237
+ const [links, setLinks] = useState110(stored.footer_links ?? []);
40238
+ const [forms, setForms] = useState110(null);
40239
+ const [busy, setBusy] = useState110(false);
40240
+ const [error, setError] = useState110(null);
40241
+ const [said2, setSaid] = useState110(null);
40242
+ const [formsError, setFormsError] = useState110(null);
40243
+ const [formsUnread, setFormsUnread] = useState110(false);
40244
+ useEffect96(() => {
40211
40245
  let cancelled = false;
40212
40246
  void (async () => {
40213
40247
  try {
@@ -40453,16 +40487,16 @@ var PORTAL_SUGGESTION = "Let each of my customers sign in and see their own jobs
40453
40487
  function PortalsPanel({ tableId, activePortalId, className }) {
40454
40488
  const client = useRecordsClient78();
40455
40489
  const host = useRecordsUi();
40456
- const [portals, setPortals] = useState110(null);
40457
- const [exposures, setExposures] = useState110([]);
40458
- const [listError, setListError] = useState110(null);
40459
- const [openId, setOpenId] = useState110(activePortalId ?? null);
40460
- useEffect96(() => {
40490
+ const [portals, setPortals] = useState111(null);
40491
+ const [exposures, setExposures] = useState111([]);
40492
+ const [listError, setListError] = useState111(null);
40493
+ const [openId, setOpenId] = useState111(activePortalId ?? null);
40494
+ useEffect97(() => {
40461
40495
  if (activePortalId) setOpenId(activePortalId);
40462
40496
  }, [activePortalId]);
40463
- const [building, setBuilding] = useState110(false);
40464
- const [adding, setAdding] = useState110(null);
40465
- const [archiveToken, setArchiveToken] = useState110(0);
40497
+ const [building, setBuilding] = useState111(false);
40498
+ const [adding, setAdding] = useState111(null);
40499
+ const [archiveToken, setArchiveToken] = useState111(0);
40466
40500
  const load = useCallback50(async () => {
40467
40501
  const [answered, mapped] = await Promise.all([client.portals(), client.portalTables()]);
40468
40502
  if (!answered.ok) {
@@ -40475,7 +40509,7 @@ function PortalsPanel({ tableId, activePortalId, className }) {
40475
40509
  setPortals(answered.data);
40476
40510
  setExposures(mapped.ok ? mapped.data : []);
40477
40511
  }, [client]);
40478
- useEffect96(() => {
40512
+ useEffect97(() => {
40479
40513
  void load();
40480
40514
  }, [load]);
40481
40515
  if (portals === null) return /* @__PURE__ */ jsx133(Skeleton23, { className: cn75("h-32 w-full", className) });
@@ -40632,11 +40666,11 @@ function ArchivePortalControl({
40632
40666
  onArchived
40633
40667
  }) {
40634
40668
  const client = useRecordsClient78();
40635
- const [asking, setAsking] = useState110(false);
40636
- const [typed2, setTyped] = useState110("");
40637
- const [busy, setBusy] = useState110(false);
40638
- const [error, setError] = useState110(null);
40639
- const [said2, setSaid] = useState110(null);
40669
+ const [asking, setAsking] = useState111(false);
40670
+ const [typed2, setTyped] = useState111("");
40671
+ const [busy, setBusy] = useState111(false);
40672
+ const [error, setError] = useState111(null);
40673
+ const [said2, setSaid] = useState111(null);
40640
40674
  const go = async () => {
40641
40675
  setBusy(true);
40642
40676
  setError(null);
@@ -40703,8 +40737,8 @@ function ArchivePortalControl({
40703
40737
  ] });
40704
40738
  }
40705
40739
  function CopyLink({ url, what }) {
40706
- const [copied, setCopied] = useState110(false);
40707
- const [shown4, setShown] = useState110(false);
40740
+ const [copied, setCopied] = useState111(false);
40741
+ const [shown4, setShown] = useState111(false);
40708
40742
  return /* @__PURE__ */ jsxs123(Fragment52, { children: [
40709
40743
  /* @__PURE__ */ jsx133(
40710
40744
  Button83,
@@ -40738,8 +40772,8 @@ function PortalDetail({
40738
40772
  onChanged
40739
40773
  }) {
40740
40774
  const client = useRecordsClient78();
40741
- const [card, setCard] = useState110(null);
40742
- const [error, setError] = useState110(null);
40775
+ const [card, setCard] = useState111(null);
40776
+ const [error, setError] = useState111(null);
40743
40777
  const load = useCallback50(async () => {
40744
40778
  const answered = await client.portalCard({ portal_id: portalId });
40745
40779
  if (!answered.ok) {
@@ -40750,7 +40784,7 @@ function PortalDetail({
40750
40784
  setError(null);
40751
40785
  setCard(answered.data);
40752
40786
  }, [client, portalId]);
40753
- useEffect96(() => {
40787
+ useEffect97(() => {
40754
40788
  void load();
40755
40789
  }, [load]);
40756
40790
  const revoke = useCallback50(
@@ -40867,11 +40901,11 @@ function People({
40867
40901
  origin
40868
40902
  }) {
40869
40903
  const here = origin ?? (typeof window === "undefined" ? "" : window.location.origin);
40870
- const [askingToRevoke, setAskingToRevoke] = useState110(null);
40871
- const [busy, setBusy] = useState110(false);
40872
- const [said2, setSaid] = useState110(null);
40873
- const [error, setError] = useState110(null);
40874
- const [previewing, setPreviewing] = useState110(null);
40904
+ const [askingToRevoke, setAskingToRevoke] = useState111(null);
40905
+ const [busy, setBusy] = useState111(false);
40906
+ const [said2, setSaid] = useState111(null);
40907
+ const [error, setError] = useState111(null);
40908
+ const [previewing, setPreviewing] = useState111(null);
40875
40909
  const revoke = useCallback50(
40876
40910
  async (person) => {
40877
40911
  setBusy(true);
@@ -40955,10 +40989,10 @@ function Preview({
40955
40989
  onPreview
40956
40990
  }) {
40957
40991
  const first = card.tables[0];
40958
- const [which, setWhich] = useState110(first?.table_id ?? null);
40959
- const [rows, setRows] = useState110(null);
40960
- const [error, setError] = useState110(null);
40961
- useEffect96(() => {
40992
+ const [which, setWhich] = useState111(first?.table_id ?? null);
40993
+ const [rows, setRows] = useState111(null);
40994
+ const [error, setError] = useState111(null);
40995
+ useEffect97(() => {
40962
40996
  if (!which) return;
40963
40997
  let cancelled = false;
40964
40998
  setRows(null);
@@ -40996,15 +41030,15 @@ function Preview({
40996
41030
  }
40997
41031
  function Invite({ card, onInvited }) {
40998
41032
  const client = useRecordsClient78();
40999
- const [rows, setRows] = useState110(null);
41000
- const [clientTable, setClientTable] = useState110(null);
41001
- const [search, setSearch] = useState110("");
41002
- const [picked, setPicked] = useState110(null);
41003
- const [email, setEmail] = useState110("");
41004
- const [busy, setBusy] = useState110(false);
41005
- const [said2, setSaid] = useState110(null);
41006
- const [error, setError] = useState110(null);
41007
- useEffect96(() => {
41033
+ const [rows, setRows] = useState111(null);
41034
+ const [clientTable, setClientTable] = useState111(null);
41035
+ const [search, setSearch] = useState111("");
41036
+ const [picked, setPicked] = useState111(null);
41037
+ const [email, setEmail] = useState111("");
41038
+ const [busy, setBusy] = useState111(false);
41039
+ const [said2, setSaid] = useState111(null);
41040
+ const [error, setError] = useState111(null);
41041
+ useEffect97(() => {
41008
41042
  let cancelled = false;
41009
41043
  void client.list({ table_id: card.client_table_id, limit: 200 }).then((answered) => {
41010
41044
  if (cancelled) return;
@@ -41215,13 +41249,13 @@ function FormLookFrame({ look, title, children, contained = false, showOwnerHead
41215
41249
  }
41216
41250
 
41217
41251
  // src/DigestScheduler.tsx
41218
- import { useCallback as useCallback51, useEffect as useEffect97, useMemo as useMemo66, useState as useState111 } from "react";
41252
+ import { useCallback as useCallback51, useEffect as useEffect98, useMemo as useMemo66, useState as useState112 } from "react";
41219
41253
  import { useRecordsClient as useRecordsClient79, useTable as useTable25 } from "@ai-matrx/records/react";
41220
41254
  import { hasQuietHours } from "@ai-matrx/records";
41221
41255
  import { BasicInput as BasicInput26, Button as Button84, Checkbox as Checkbox13, Label as Label20, Separator as Separator12, Skeleton as Skeleton24, cn as cn77 } from "@ai-matrx/design-system";
41222
41256
 
41223
41257
  // src/scheduleWords.ts
41224
- var DAYS2 = {
41258
+ var DAYS3 = {
41225
41259
  mon: "Mondays",
41226
41260
  tue: "Tuesdays",
41227
41261
  wed: "Wednesdays",
@@ -41234,7 +41268,7 @@ function scheduleWords(schedule, tz) {
41234
41268
  const words2 = (schedule ?? "").trim().toLowerCase().split(/\s+/).filter(Boolean);
41235
41269
  if (words2.length === 0) return null;
41236
41270
  const time = words2.find((w) => /^\d{1,2}:\d{2}$/.test(w)) ?? null;
41237
- const day2 = words2.map((w) => DAYS2[w.slice(0, 3)]).find(Boolean) ?? null;
41271
+ const day2 = words2.map((w) => DAYS3[w.slice(0, 3)]).find(Boolean) ?? null;
41238
41272
  const zone2 = tz?.trim() ? `${tz.trim()} time` : "UTC";
41239
41273
  const at = time ? `at ${time.padStart(5, "0")}, ${zone2}` : null;
41240
41274
  return [day2, at].filter(Boolean).join(" ") || null;
@@ -41278,41 +41312,41 @@ function DigestScheduler({
41278
41312
  }) {
41279
41313
  const client = useRecordsClient79();
41280
41314
  const host = useRecordsUi();
41281
- const [views, setViews] = useState111(null);
41282
- const [cadences, setCadences] = useState111([]);
41283
- const [members, setMembers] = useState111(null);
41284
- const [error, setError] = useState111(null);
41315
+ const [views, setViews] = useState112(null);
41316
+ const [cadences, setCadences] = useState112([]);
41317
+ const [members, setMembers] = useState112(null);
41318
+ const [error, setError] = useState112(null);
41285
41319
  const was = scheduleParts(existing?.schedule);
41286
- const [viewId, setViewId] = useState111(
41320
+ const [viewId, setViewId] = useState112(
41287
41321
  existing?.saved_view_id ?? savedViewId ?? ""
41288
41322
  );
41289
- const [name, setName] = useState111(
41323
+ const [name, setName] = useState112(
41290
41324
  existing?.name ?? (subjectName?.trim() ? `${subjectName.trim()} summary` : "")
41291
41325
  );
41292
- const [cadence, setCadence] = useState111(
41326
+ const [cadence, setCadence] = useState112(
41293
41327
  ["hourly", "daily", "weekly"].includes(existing?.cadence ?? "") ? existing.cadence : "weekly"
41294
41328
  );
41295
- const [weekday, setWeekday] = useState111(was.day ?? "monday");
41296
- const [time, setTime] = useState111(was.time ?? "08:00");
41297
- const [timezone, setTimezone] = useState111(() => {
41329
+ const [weekday, setWeekday] = useState112(was.day ?? "monday");
41330
+ const [time, setTime] = useState112(was.time ?? "08:00");
41331
+ const [timezone, setTimezone] = useState112(() => {
41298
41332
  const kept = existing?.quiet_hours?.tz?.trim();
41299
41333
  return kept && kept.toUpperCase() !== "UTC" ? kept : ownTimeZone();
41300
41334
  });
41301
41335
  const table = useTable25(tableId);
41302
41336
  const tableName2 = table.data?.name?.trim() || null;
41303
- const [channel, setChannel] = useState111(
41337
+ const [channel, setChannel] = useState112(
41304
41338
  existing?.channel === "email" || existing?.channel === "sms" ? existing.channel : "in_app"
41305
41339
  );
41306
- const [quiet2, setQuiet] = useState111(hasQuietHours(existing?.quiet_hours));
41307
- const [quietFrom, setQuietFrom] = useState111(existing?.quiet_hours?.start ?? "22:00");
41308
- const [quietTo, setQuietTo] = useState111(existing?.quiet_hours?.end ?? "07:00");
41309
- const [recipients, setRecipients] = useState111(
41340
+ const [quiet2, setQuiet] = useState112(hasQuietHours(existing?.quiet_hours));
41341
+ const [quietFrom, setQuietFrom] = useState112(existing?.quiet_hours?.start ?? "22:00");
41342
+ const [quietTo, setQuietTo] = useState112(existing?.quiet_hours?.end ?? "07:00");
41343
+ const [recipients, setRecipients] = useState112(
41310
41344
  existing?.recipient_user_id ? [existing.recipient_user_id] : []
41311
41345
  );
41312
- const [saving, setSaving] = useState111(false);
41313
- const [outcomes, setOutcomes] = useState111(null);
41314
- const [preview, setPreview] = useState111(null);
41315
- const [previewing, setPreviewing] = useState111(false);
41346
+ const [saving, setSaving] = useState112(false);
41347
+ const [outcomes, setOutcomes] = useState112(null);
41348
+ const [preview, setPreview] = useState112(null);
41349
+ const [previewing, setPreviewing] = useState112(false);
41316
41350
  const load = useCallback51(async () => {
41317
41351
  const [saved, offered] = await Promise.all([
41318
41352
  // The store's own door onto `platform.saved_view`, narrowed in SQL to
@@ -41332,7 +41366,7 @@ function DigestScheduler({
41332
41366
  setMembers([]);
41333
41367
  }
41334
41368
  }, [client, tableId, host]);
41335
- useEffect97(() => {
41369
+ useEffect98(() => {
41336
41370
  void load();
41337
41371
  }, [load]);
41338
41372
  const schedule = useMemo66(() => {
@@ -41587,13 +41621,13 @@ function DigestScheduler({
41587
41621
  }
41588
41622
 
41589
41623
  // src/SubscriptionsPanel.tsx
41590
- import { useCallback as useCallback53, useEffect as useEffect99, useState as useState113 } from "react";
41624
+ import { useCallback as useCallback53, useEffect as useEffect100, useState as useState114 } from "react";
41591
41625
  import { useRecordsClient as useRecordsClient81 } from "@ai-matrx/records/react";
41592
41626
  import { hasQuietHours as hasQuietHours2 } from "@ai-matrx/records";
41593
41627
  import { Badge as Badge23, Button as Button86, Skeleton as Skeleton26, Switch as Switch4, cn as cn79 } from "@ai-matrx/design-system";
41594
41628
 
41595
41629
  // src/WebhooksPanel.tsx
41596
- import { useCallback as useCallback52, useEffect as useEffect98, useState as useState112 } from "react";
41630
+ import { useCallback as useCallback52, useEffect as useEffect99, useState as useState113 } from "react";
41597
41631
  import { useRecordsClient as useRecordsClient80, useTable as useTable26 } from "@ai-matrx/records/react";
41598
41632
  import { BasicInput as BasicInput27, Button as Button85, Checkbox as Checkbox14, ConfirmDialog as ConfirmDialog7, Label as Label21, Skeleton as Skeleton25, cn as cn78 } from "@ai-matrx/design-system";
41599
41633
  import { jsx as jsx136, jsxs as jsxs126 } from "react/jsx-runtime";
@@ -41617,16 +41651,16 @@ function WebhooksPanel({ tableId, className }) {
41617
41651
  const client = useRecordsClient80();
41618
41652
  const table = useTable26(tableId);
41619
41653
  const rights = useTableRights(table.data);
41620
- const [hooks, setHooks] = useState112(null);
41621
- const [error, setError] = useState112(null);
41622
- const [adding, setAdding] = useState112(false);
41623
- const [url, setUrl] = useState112("");
41624
- const [description, setDescription] = useState112("");
41625
- const [events, setEvents] = useState112(DEFAULT_EVENTS);
41626
- const [busy, setBusy] = useState112(false);
41627
- const [declared2, setDeclared] = useState112(null);
41628
- const [stopping, setStopping] = useState112(null);
41629
- const [readRefused, setReadRefused] = useState112(null);
41654
+ const [hooks, setHooks] = useState113(null);
41655
+ const [error, setError] = useState113(null);
41656
+ const [adding, setAdding] = useState113(false);
41657
+ const [url, setUrl] = useState113("");
41658
+ const [description, setDescription] = useState113("");
41659
+ const [events, setEvents] = useState113(DEFAULT_EVENTS);
41660
+ const [busy, setBusy] = useState113(false);
41661
+ const [declared2, setDeclared] = useState113(null);
41662
+ const [stopping, setStopping] = useState113(null);
41663
+ const [readRefused, setReadRefused] = useState113(null);
41630
41664
  const load = useCallback52(async () => {
41631
41665
  const answered = await client.tableWebhooks({ table_id: tableId });
41632
41666
  if (!answered.ok) {
@@ -41639,7 +41673,7 @@ function WebhooksPanel({ tableId, className }) {
41639
41673
  setError(null);
41640
41674
  setHooks(answered.data ?? []);
41641
41675
  }, [client, tableId]);
41642
- useEffect98(() => {
41676
+ useEffect99(() => {
41643
41677
  void load();
41644
41678
  }, [load]);
41645
41679
  const declare2 = async () => {
@@ -41810,12 +41844,12 @@ var CHANNEL_WORDS2 = SUBSCRIPTION_CHANNEL_LABEL;
41810
41844
  var DIGEST_SUGGESTION = "Email me a summary of this every Monday at 8 in the morning.";
41811
41845
  function SubscriptionsPanel({ tableId, activeRuleId, className }) {
41812
41846
  const client = useRecordsClient81();
41813
- const [rows, setRows] = useState113(null);
41814
- const [error, setError] = useState113(null);
41815
- const [busy, setBusy] = useState113(null);
41816
- const [preview, setPreview] = useState113(null);
41817
- const [scheduling, setScheduling] = useState113(false);
41818
- const [changing, setChanging] = useState113(null);
41847
+ const [rows, setRows] = useState114(null);
41848
+ const [error, setError] = useState114(null);
41849
+ const [busy, setBusy] = useState114(null);
41850
+ const [preview, setPreview] = useState114(null);
41851
+ const [scheduling, setScheduling] = useState114(false);
41852
+ const [changing, setChanging] = useState114(null);
41819
41853
  const host = useRecordsUi();
41820
41854
  const load = useCallback53(async () => {
41821
41855
  const answered = await client.subscriptions({ table_id: tableId });
@@ -41827,7 +41861,7 @@ function SubscriptionsPanel({ tableId, activeRuleId, className }) {
41827
41861
  setError(null);
41828
41862
  setRows(answered.data);
41829
41863
  }, [client, tableId]);
41830
- useEffect99(() => {
41864
+ useEffect100(() => {
41831
41865
  void load();
41832
41866
  }, [load]);
41833
41867
  const flip = useCallback53(
@@ -42018,7 +42052,7 @@ function SubscriptionsPanel({ tableId, activeRuleId, className }) {
42018
42052
  // src/FormBuilder.tsx
42019
42053
  import { copyText as copyText8 } from "@ai-matrx/kit/clipboard";
42020
42054
  import { ErrorBox as ErrorBox7 } from "@ai-matrx/design-system";
42021
- import { useCallback as useCallback55, useEffect as useEffect101, useMemo as useMemo68, useRef as useRef56, useState as useState116 } from "react";
42055
+ import { useCallback as useCallback55, useEffect as useEffect102, useMemo as useMemo68, useRef as useRef56, useState as useState117 } from "react";
42022
42056
  import { DndContext, KeyboardSensor, PointerSensor, closestCenter, useSensor, useSensors } from "@dnd-kit/core";
42023
42057
  import { SortableContext, arrayMove, sortableKeyboardCoordinates, useSortable, verticalListSortingStrategy } from "@dnd-kit/sortable";
42024
42058
  import { CSS as CSS2 } from "@dnd-kit/utilities";
@@ -42035,7 +42069,7 @@ import {
42035
42069
  } from "@ai-matrx/design-system";
42036
42070
 
42037
42071
  // src/FormFlowEditor.tsx
42038
- import { useState as useState114 } from "react";
42072
+ import { useState as useState115 } from "react";
42039
42073
  import {
42040
42074
  BasicInput as BasicInput28,
42041
42075
  BasicTextarea as BasicTextarea10,
@@ -42144,7 +42178,7 @@ function QuestionLogic({
42144
42178
  const choiceFields = field2 && isChoiceField(field2) ? [field2] : [];
42145
42179
  const options = useChoiceOptions(choiceFields, choiceFields.map((f) => f.key));
42146
42180
  const choices = field2 ? (options.get(field2.key) ?? []).map((o) => ({ key: o.key, label: o.label })) : [];
42147
- const [answer, setAnswer] = useState114("");
42181
+ const [answer, setAnswer] = useState115("");
42148
42182
  const setJump = (i, part) => onChange({ jumps: jumps.map((j, k) => k === i ? { ...j, ...part } : j) });
42149
42183
  return /* @__PURE__ */ jsxs128("div", { className: "col-span-2 flex flex-col gap-1.5 text-xs", "data-records-form-logic": question.field, children: [
42150
42184
  jumps.map((jump, i) => /* @__PURE__ */ jsxs128("div", { className: "flex flex-col gap-1 rounded border border-dashed p-1.5", "data-records-form-jump": "", children: [
@@ -42214,7 +42248,7 @@ function parseHiddenFields(line) {
42214
42248
  return out;
42215
42249
  }
42216
42250
  function HiddenFieldsEditor({ value, onChange }) {
42217
- const [line, setLine] = useState114(value.join(", "));
42251
+ const [line, setLine] = useState115(value.join(", "));
42218
42252
  return /* @__PURE__ */ jsxs128("label", { className: "flex flex-col gap-1", "data-records-form-hidden-editor": "", children: [
42219
42253
  /* @__PURE__ */ jsx138(Label22, { className: "text-xs font-medium", children: "Hidden fields" }),
42220
42254
  /* @__PURE__ */ jsx138(
@@ -42265,8 +42299,8 @@ function ThemeEditor({
42265
42299
  var EMBED_LABELS = { inline: "Inline", popup: "Popup", slider: "Slider" };
42266
42300
  function EmbedSnippets({ url, label }) {
42267
42301
  const { copyText: copyText16 } = useClipboard();
42268
- const [kind, setKind] = useState114("inline");
42269
- const [copied, setCopied] = useState114(false);
42302
+ const [kind, setKind] = useState115("inline");
42303
+ const [copied, setCopied] = useState115(false);
42270
42304
  const snippet = formEmbedSnippet(kind, url, { label });
42271
42305
  return /* @__PURE__ */ jsxs128("section", { className: "flex flex-col gap-1.5 rounded border px-2.5 py-2", "aria-label": "Embed", "data-records-form-embed": "", children: [
42272
42306
  /* @__PURE__ */ jsxs128("div", { className: "flex items-center gap-2", children: [
@@ -42291,8 +42325,8 @@ function EmbedSnippets({ url, label }) {
42291
42325
  }
42292
42326
 
42293
42327
  // src/FormRunner.tsx
42294
- import { useCallback as useCallback54, useEffect as useEffect100, useMemo as useMemo67, useRef as useRef55, useState as useState115 } from "react";
42295
- import { useFields as useFields24, useOptionalRecordsClient as useOptionalRecordsClient18 } from "@ai-matrx/records/react";
42328
+ import { useCallback as useCallback54, useEffect as useEffect101, useMemo as useMemo67, useRef as useRef55, useState as useState116 } from "react";
42329
+ import { useFields as useFields24, useOptionalRecordsClient as useOptionalRecordsClient19 } from "@ai-matrx/records/react";
42296
42330
  import { Button as Button88, Label as Label23, Progress, Skeleton as Skeleton27, cn as cn80, formThemeClasses } from "@ai-matrx/design-system";
42297
42331
  import { answerRefusal, formRoutes, pipeAnswers, submissionStamp } from "@ai-matrx/records/forms";
42298
42332
  import { humanizeIdentifier as humanizeIdentifier18 } from "@ai-matrx/kit/text-case";
@@ -42307,7 +42341,7 @@ function FormRunner(props) {
42307
42341
  return /* @__PURE__ */ jsx139(ConnectedFormRunner, { ...props });
42308
42342
  }
42309
42343
  function ConnectedFormRunner(props) {
42310
- const client = useOptionalRecordsClient18();
42344
+ const client = useOptionalRecordsClient19();
42311
42345
  const fields = useFields24(props.form.subject);
42312
42346
  const { form, className } = props;
42313
42347
  const submit = useCallback54(
@@ -42397,18 +42431,18 @@ function FormStage({
42397
42431
  autoAdvance
42398
42432
  }) {
42399
42433
  const host = useRecordsUi();
42400
- const [answers, setAnswers] = useState115(() => ({ ...initialAnswers ?? {} }));
42401
- const [at, setAt] = useState115(0);
42402
- const [error, setError] = useState115(null);
42403
- const [refusal3, setRefusal] = useState115(null);
42404
- const [writing, setWriting] = useState115(false);
42405
- const [done, setDone] = useState115(null);
42406
- const [hidden, setHidden] = useState115({});
42407
- const [ending, setEnding] = useState115(null);
42408
- const [started, setStarted] = useState115(() => !form.welcome || resumed);
42434
+ const [answers, setAnswers] = useState116(() => ({ ...initialAnswers ?? {} }));
42435
+ const [at, setAt] = useState116(0);
42436
+ const [error, setError] = useState116(null);
42437
+ const [refusal3, setRefusal] = useState116(null);
42438
+ const [writing, setWriting] = useState116(false);
42439
+ const [done, setDone] = useState116(null);
42440
+ const [hidden, setHidden] = useState116({});
42441
+ const [ending, setEnding] = useState116(null);
42442
+ const [started, setStarted] = useState116(() => !form.welcome || resumed);
42409
42443
  const routes = formRoutes(form);
42410
- const [routeKnown, setRouteKnown] = useState115(() => !routes || !whichAsked);
42411
- const [stopped, setStopped] = useState115(null);
42444
+ const [routeKnown, setRouteKnown] = useState116(() => !routes || !whichAsked);
42445
+ const [stopped, setStopped] = useState116(null);
42412
42446
  const answersRef = useRef55(answers);
42413
42447
  answersRef.current = answers;
42414
42448
  const choose = autoAdvance ?? form.autoAdvance ?? true;
@@ -42431,7 +42465,7 @@ function FormStage({
42431
42465
  };
42432
42466
  });
42433
42467
  }, [fields, form.questions]);
42434
- useEffect100(() => {
42468
+ useEffect101(() => {
42435
42469
  if (!whichAsked) return;
42436
42470
  if (!routes) return;
42437
42471
  let cancelled = false;
@@ -42455,9 +42489,9 @@ function FormStage({
42455
42489
  }
42456
42490
  const next = {};
42457
42491
  let said2 = null;
42458
- for (const ask of told2.asks) {
42459
- next[ask.field] = ask.asked === false;
42460
- if (ask.said && !said2) said2 = ask.said;
42492
+ for (const ask2 of told2.asks) {
42493
+ next[ask2.field] = ask2.asked === false;
42494
+ if (ask2.said && !said2) said2 = ask2.said;
42461
42495
  }
42462
42496
  setHidden(next);
42463
42497
  setEnding(told2.ending ?? null);
@@ -42477,7 +42511,7 @@ function FormStage({
42477
42511
  }, [whichAsked, questions, answers]);
42478
42512
  const live = questions.filter((q) => !hidden[q.key]);
42479
42513
  const told = useRef55(answers);
42480
- useEffect100(() => {
42514
+ useEffect101(() => {
42481
42515
  if (told.current === answers) return;
42482
42516
  told.current = answers;
42483
42517
  onAnswersChange?.(answers);
@@ -42488,7 +42522,7 @@ function FormStage({
42488
42522
  return v === void 0 || v === null || v === "";
42489
42523
  })?.key ?? null : null
42490
42524
  );
42491
- useEffect100(() => {
42525
+ useEffect101(() => {
42492
42526
  const key = resumeAt.current;
42493
42527
  if (!key) return;
42494
42528
  const i = live.findIndex((q) => q.key === key);
@@ -42583,7 +42617,7 @@ function FormStage({
42583
42617
  return;
42584
42618
  }
42585
42619
  const next = {};
42586
- for (const ask of told2.asks) next[ask.field] = ask.asked === false;
42620
+ for (const ask2 of told2.asks) next[ask2.field] = ask2.asked === false;
42587
42621
  setHidden(next);
42588
42622
  setEnding(told2.ending ?? null);
42589
42623
  const onRoute = questions.filter((q) => !next[q.key]);
@@ -42597,9 +42631,9 @@ function FormStage({
42597
42631
  else void submit();
42598
42632
  }
42599
42633
  const routing = useRef55(false);
42600
- const [routingNow, setRoutingNow] = useState115(false);
42634
+ const [routingNow, setRoutingNow] = useState116(false);
42601
42635
  const typedAhead = useRef55("");
42602
- useEffect100(() => {
42636
+ useEffect101(() => {
42603
42637
  if (!routingNow) return;
42604
42638
  const hold = (event) => {
42605
42639
  if (!routing.current || event.metaKey || event.ctrlKey || event.altKey || event.isComposing) return;
@@ -42629,7 +42663,7 @@ function FormStage({
42629
42663
  }
42630
42664
  for (const key of held) target.dispatchEvent(new KeyboardEvent("keydown", { key, bubbles: true, cancelable: true }));
42631
42665
  }, [live, at]);
42632
- useEffect100(() => {
42666
+ useEffect101(() => {
42633
42667
  if (!routingNow) pourTypedAhead();
42634
42668
  }, [routingNow, at, pourTypedAhead]);
42635
42669
  const advanceRef = useRef55(advance);
@@ -42654,7 +42688,7 @@ function FormStage({
42654
42688
  if (event.shiftKey) retreat();
42655
42689
  else advance();
42656
42690
  }
42657
- useEffect100(() => {
42691
+ useEffect101(() => {
42658
42692
  const input = stage.current?.querySelector("[role='radio'][aria-checked='true']") ?? stage.current?.querySelector(
42659
42693
  "input:not([tabindex='-1']), textarea, select, [role='combobox'], [role='radio'], [role='checkbox']"
42660
42694
  );
@@ -42662,7 +42696,7 @@ function FormStage({
42662
42696
  pourTypedAhead();
42663
42697
  }, [index, done, started]);
42664
42698
  const startTold = useRef55(false);
42665
- useEffect100(() => {
42699
+ useEffect101(() => {
42666
42700
  if (startTold.current || !onStart) return;
42667
42701
  if (Object.values(answers).some((v) => v !== void 0 && v !== null && v !== "")) {
42668
42702
  startTold.current = true;
@@ -42670,7 +42704,7 @@ function FormStage({
42670
42704
  }
42671
42705
  }, [answers, onStart]);
42672
42706
  const shownTold = useRef55(/* @__PURE__ */ new Set());
42673
- useEffect100(() => {
42707
+ useEffect101(() => {
42674
42708
  if (!onQuestionShown || !started || done) return;
42675
42709
  for (const q of oneAtATime ? current ? [current] : [] : live) {
42676
42710
  if (shownTold.current.has(q.key)) continue;
@@ -42854,7 +42888,7 @@ function ThankYou({
42854
42888
  const title = rawTitle ? pipe(rawTitle) : rawTitle;
42855
42889
  const body = rawBody ? pipe(rawBody) : rawBody;
42856
42890
  const going = redirect !== null && done !== "preview";
42857
- useEffect100(() => {
42891
+ useEffect101(() => {
42858
42892
  if (!going || !redirect) return;
42859
42893
  const timer = window.setTimeout(() => window.location.assign(redirect), REDIRECT_AFTER_MS);
42860
42894
  return () => window.clearTimeout(timer);
@@ -42904,7 +42938,7 @@ function Question({
42904
42938
  upload
42905
42939
  }) {
42906
42940
  const host = useRecordsUi();
42907
- const [uploadError, setUploadError] = useState115(null);
42941
+ const [uploadError, setUploadError] = useState116(null);
42908
42942
  const field2 = question.field;
42909
42943
  if (!field2) return null;
42910
42944
  const id = `form-${field2.key}`;
@@ -43038,24 +43072,24 @@ function FormBuilder({ tableId, seed, activeFormId, onActiveForm, startWithOne,
43038
43072
  const table = useTable27(tableId);
43039
43073
  const rights = useTableRights(table.data);
43040
43074
  const fields = useFields25(tableId);
43041
- const [forms, setForms] = useState116(null);
43042
- const [error, setError] = useState116(null);
43043
- const [refused, setRefused] = useState116(null);
43044
- const [activeId, setActiveId] = useState116(activeFormId ?? null);
43045
- const [draft, setDraft] = useState116(null);
43046
- const [saving, setSaving] = useState116(false);
43047
- const [saved, setSaved] = useState116(null);
43048
- const [publishing, setPublishing] = useState116(false);
43049
- const [copied, setCopied] = useState116(false);
43050
- const [shownUrl, setShownUrl] = useState116(null);
43051
- const [lookOptions, setLookOptions] = useState116(null);
43052
- const [lookUnread, setLookUnread] = useState116(null);
43053
- const [orgKnobs, setOrgKnobs] = useState116(null);
43054
- const [restoredAt, setRestoredAt] = useState116(null);
43055
- const [showResults, setShowResults] = useState116(false);
43056
- const [adding, setAdding] = useState116(false);
43075
+ const [forms, setForms] = useState117(null);
43076
+ const [error, setError] = useState117(null);
43077
+ const [refused, setRefused] = useState117(null);
43078
+ const [activeId, setActiveId] = useState117(activeFormId ?? null);
43079
+ const [draft, setDraft] = useState117(null);
43080
+ const [saving, setSaving] = useState117(false);
43081
+ const [saved, setSaved] = useState117(null);
43082
+ const [publishing, setPublishing] = useState117(false);
43083
+ const [copied, setCopied] = useState117(false);
43084
+ const [shownUrl, setShownUrl] = useState117(null);
43085
+ const [lookOptions, setLookOptions] = useState117(null);
43086
+ const [lookUnread, setLookUnread] = useState117(null);
43087
+ const [orgKnobs, setOrgKnobs] = useState117(null);
43088
+ const [restoredAt, setRestoredAt] = useState117(null);
43089
+ const [showResults, setShowResults] = useState117(false);
43090
+ const [adding, setAdding] = useState117(false);
43057
43091
  const keysBeforeAdd = useRef56(null);
43058
- const [makeOnMount, setMakeOnMount] = useState116("waiting");
43092
+ const [makeOnMount, setMakeOnMount] = useState117("waiting");
43059
43093
  const publicOrigin = host.publicOrigin ?? (typeof window === "undefined" ? "" : window.location.origin);
43060
43094
  const load = useCallback55(async () => {
43061
43095
  const answered = await client.forms({ table_id: tableId });
@@ -43084,10 +43118,10 @@ function FormBuilder({ tableId, seed, activeFormId, onActiveForm, startWithOne,
43084
43118
  setError(null);
43085
43119
  setForms(mine);
43086
43120
  }, [client, tableId, seed, claimSeed]);
43087
- useEffect101(() => {
43121
+ useEffect102(() => {
43088
43122
  void load();
43089
43123
  }, [load]);
43090
- useEffect101(() => {
43124
+ useEffect102(() => {
43091
43125
  let cancelled = false;
43092
43126
  Promise.resolve().then(() => client.formKnobs()).then((r) => {
43093
43127
  if (!cancelled && r.ok) setOrgKnobs(r.data);
@@ -43096,7 +43130,7 @@ function FormBuilder({ tableId, seed, activeFormId, onActiveForm, startWithOne,
43096
43130
  cancelled = true;
43097
43131
  };
43098
43132
  }, [client]);
43099
- useEffect101(() => {
43133
+ useEffect102(() => {
43100
43134
  if (!forms || forms.length === 0) return;
43101
43135
  if (createOnMount && makeOnMount !== "made") return;
43102
43136
  const chosen = forms.find((f) => f.id === (activeFormId ?? activeId)) ?? forms[0];
@@ -43120,7 +43154,7 @@ function FormBuilder({ tableId, seed, activeFormId, onActiveForm, startWithOne,
43120
43154
  );
43121
43155
  const stored = useMemo68(() => draft ? (forms ?? []).find((f) => f.id === draft.id) ?? null : null, [draft, forms]);
43122
43156
  const dirty = Boolean(draft && stored && !sameForm(draft, stored));
43123
- useEffect101(() => {
43157
+ useEffect102(() => {
43124
43158
  if (!draft || !stored) return;
43125
43159
  const timer = window.setTimeout(() => {
43126
43160
  if (sameForm(draft, stored)) dropKeptDraft(draft.id);
@@ -43129,7 +43163,7 @@ function FormBuilder({ tableId, seed, activeFormId, onActiveForm, startWithOne,
43129
43163
  return () => window.clearTimeout(timer);
43130
43164
  }, [draft, stored]);
43131
43165
  const lookKey = draft ? JSON.stringify(formLookDocument(draft.look ?? null)) : null;
43132
- useEffect101(() => {
43166
+ useEffect102(() => {
43133
43167
  if (lookKey === null) return;
43134
43168
  let cancelled = false;
43135
43169
  const timer = window.setTimeout(() => {
@@ -43146,7 +43180,7 @@ function FormBuilder({ tableId, seed, activeFormId, onActiveForm, startWithOne,
43146
43180
  window.clearTimeout(timer);
43147
43181
  };
43148
43182
  }, [client, lookKey]);
43149
- useEffect101(() => {
43183
+ useEffect102(() => {
43150
43184
  const before = keysBeforeAdd.current;
43151
43185
  if (!before || !fields.data) return;
43152
43186
  const made = askableFields(fields.data).filter((f) => !before.has(f.key));
@@ -43243,10 +43277,10 @@ function FormBuilder({ tableId, seed, activeFormId, onActiveForm, startWithOne,
43243
43277
  await load();
43244
43278
  }
43245
43279
  async function create(name) {
43246
- const ask = askableFields(fields.data ?? []);
43247
- if (ask.length === 0) return false;
43280
+ const ask2 = askableFields(fields.data ?? []);
43281
+ if (ask2.length === 0) return false;
43248
43282
  const written = await client.formDeclare(
43249
- formDeclareArgs({ name, subject: tableId, questions: ask.map((f) => ({ field: f.key })) })
43283
+ formDeclareArgs({ name, subject: tableId, questions: ask2.map((f) => ({ field: f.key })) })
43250
43284
  );
43251
43285
  if (!written.ok) {
43252
43286
  setRefused(written.error);
@@ -43256,15 +43290,15 @@ function FormBuilder({ tableId, seed, activeFormId, onActiveForm, startWithOne,
43256
43290
  await load();
43257
43291
  return true;
43258
43292
  }
43259
- const [started, setStarted] = useState116(false);
43260
- useEffect101(() => {
43293
+ const [started, setStarted] = useState117(false);
43294
+ useEffect102(() => {
43261
43295
  if (!startWithOne || started || forms === null || forms.length > 0) return;
43262
43296
  if (askableFields(fields.data ?? []).length === 0) return;
43263
43297
  if (!table.data && !table.error) return;
43264
43298
  setStarted(true);
43265
43299
  void create(table.data?.name?.trim() ? `${table.data.name.trim()} form` : "Form 1");
43266
43300
  }, [startWithOne, started, forms, fields.data, create, table.data, table.error]);
43267
- useEffect101(() => {
43301
+ useEffect102(() => {
43268
43302
  if (!createOnMount || makeOnMount !== "waiting" || forms === null) return;
43269
43303
  if (!table.data && !table.error) return;
43270
43304
  if (askableFields(fields.data ?? []).length === 0) {
@@ -43684,7 +43718,7 @@ function QuestionList({
43684
43718
  );
43685
43719
  const askable = askableFields([...fields]);
43686
43720
  const unasked = askable.filter((f) => !draft.questions.some((q) => q.field === f.key));
43687
- const asked2 = draft.questions.map((q) => byKey.get(q.field)).filter((f) => Boolean(f)).map((f) => ({ id: String(f.id), key: f.key, label: draft.questions.find((q) => q.field === f.key)?.ask || fieldName(f), field: f }));
43721
+ const asked3 = draft.questions.map((q) => byKey.get(q.field)).filter((f) => Boolean(f)).map((f) => ({ id: String(f.id), key: f.key, label: draft.questions.find((q) => q.field === f.key)?.ask || fieldName(f), field: f }));
43688
43722
  const label = (key) => {
43689
43723
  const f = byKey.get(key);
43690
43724
  return draft.questions.find((q) => q.field === key)?.ask || (f ? fieldName(f) : key);
@@ -43709,8 +43743,8 @@ function QuestionList({
43709
43743
  question,
43710
43744
  field: byKey.get(question.field) ?? null,
43711
43745
  draft,
43712
- conditionFields: asked2.filter((f) => f.key !== question.field),
43713
- jumpFields: asked2,
43746
+ conditionFields: asked3.filter((f) => f.key !== question.field),
43747
+ jumpFields: asked3,
43714
43748
  label,
43715
43749
  onChange: (change) => onQuestion(index, change),
43716
43750
  onRemove: () => onQuestions(draft.questions.filter((q) => q.field !== question.field))
@@ -43756,7 +43790,7 @@ function QuestionRow({
43756
43790
  onRemove
43757
43791
  }) {
43758
43792
  const sortable = useSortable({ id: question.field });
43759
- const [open, setOpen] = useState116(true);
43793
+ const [open, setOpen] = useState117(true);
43760
43794
  const name = field2 ? fieldName(field2) : question.field;
43761
43795
  return /* @__PURE__ */ jsxs130(
43762
43796
  "div",
@@ -43850,13 +43884,13 @@ function NotifyOnAnswer({
43850
43884
  onNotify
43851
43885
  }) {
43852
43886
  const client = useRecordsClient82();
43853
- const [subs, setSubs] = useState116(null);
43854
- const [busy, setBusy] = useState116(false);
43855
- const [error, setError] = useState116(null);
43856
- const [said2, setSaid] = useState116(null);
43857
- const [url, setUrl] = useState116(notify?.webhookUrl ?? "");
43858
- useEffect101(() => setUrl(notify?.webhookUrl ?? ""), [notify?.webhookUrl]);
43859
- useEffect101(() => {
43887
+ const [subs, setSubs] = useState117(null);
43888
+ const [busy, setBusy] = useState117(false);
43889
+ const [error, setError] = useState117(null);
43890
+ const [said2, setSaid] = useState117(null);
43891
+ const [url, setUrl] = useState117(notify?.webhookUrl ?? "");
43892
+ useEffect102(() => setUrl(notify?.webhookUrl ?? ""), [notify?.webhookUrl]);
43893
+ useEffect102(() => {
43860
43894
  let cancelled = false;
43861
43895
  void client.subscriptions({ table_id: tableId }).then((r) => {
43862
43896
  if (!cancelled && r.ok) setSubs(r.data);
@@ -43987,7 +44021,7 @@ function NotifyOnAnswer({
43987
44021
  }
43988
44022
 
43989
44023
  // src/DocTemplate.tsx
43990
- import { useCallback as useCallback56, useEffect as useEffect102, useState as useState117 } from "react";
44024
+ import { useCallback as useCallback56, useEffect as useEffect103, useState as useState118 } from "react";
43991
44025
  import { useFields as useFields26, useRecordsClient as useRecordsClient83, useTable as useTable28 } from "@ai-matrx/records/react";
43992
44026
  import { BasicInput as BasicInput30, BasicTextarea as BasicTextarea12, Button as Button90, Label as Label25, Skeleton as Skeleton29, cn as cn82 } from "@ai-matrx/design-system";
43993
44027
  import { jsx as jsx141, jsxs as jsxs131 } from "react/jsx-runtime";
@@ -43997,13 +44031,13 @@ function DocTemplate({ tableId, seed, activeTemplateId, onActiveTemplate, classN
43997
44031
  const table = useTable28(tableId);
43998
44032
  const rights = useTableRights(table.data);
43999
44033
  const fields = useFields26(tableId);
44000
- const [templates, setTemplates] = useState117(null);
44001
- const [error, setError] = useState117(null);
44002
- const [activeId, setActiveId] = useState117(activeTemplateId ?? null);
44003
- const [draftName, setDraftName] = useState117("");
44004
- const [draftBody, setDraftBody] = useState117("");
44005
- const [unresolved, setUnresolved] = useState117([]);
44006
- const [saving, setSaving] = useState117(false);
44034
+ const [templates, setTemplates] = useState118(null);
44035
+ const [error, setError] = useState118(null);
44036
+ const [activeId, setActiveId] = useState118(activeTemplateId ?? null);
44037
+ const [draftName, setDraftName] = useState118("");
44038
+ const [draftBody, setDraftBody] = useState118("");
44039
+ const [unresolved, setUnresolved] = useState118([]);
44040
+ const [saving, setSaving] = useState118(false);
44007
44041
  const load = useCallback56(async () => {
44008
44042
  const held = await client.docTemplates({ table_id: tableId });
44009
44043
  if (!held.ok) {
@@ -44035,10 +44069,10 @@ function DocTemplate({ tableId, seed, activeTemplateId, onActiveTemplate, classN
44035
44069
  setError(null);
44036
44070
  setTemplates(rows);
44037
44071
  }, [client, tableId, seed, fields.data]);
44038
- useEffect102(() => {
44072
+ useEffect103(() => {
44039
44073
  void load();
44040
44074
  }, [load]);
44041
- useEffect102(() => {
44075
+ useEffect103(() => {
44042
44076
  if (!templates || templates.length === 0) return;
44043
44077
  const chosen = templates.find((t) => t.id === (activeTemplateId ?? activeId)) ?? templates[0];
44044
44078
  if (chosen.id !== activeId) setActiveId(chosen.id);
@@ -44046,7 +44080,7 @@ function DocTemplate({ tableId, seed, activeTemplateId, onActiveTemplate, classN
44046
44080
  setDraftBody(chosen.body);
44047
44081
  onActiveTemplate?.(chosen);
44048
44082
  }, [templates, activeTemplateId]);
44049
- useEffect102(() => {
44083
+ useEffect103(() => {
44050
44084
  let cancelled = false;
44051
44085
  if (draftBody.trim() === "") {
44052
44086
  setUnresolved([]);
@@ -44171,17 +44205,17 @@ function DocTemplate({ tableId, seed, activeTemplateId, onActiveTemplate, classN
44171
44205
  }
44172
44206
 
44173
44207
  // src/DocRender.tsx
44174
- import { useCallback as useCallback57, useEffect as useEffect103, useRef as useRef57, useState as useState118 } from "react";
44208
+ import { useCallback as useCallback57, useEffect as useEffect104, useRef as useRef57, useState as useState119 } from "react";
44175
44209
  import { useRecordsClient as useRecordsClient84 } from "@ai-matrx/records/react";
44176
44210
  import { Button as Button91, Skeleton as Skeleton30, cn as cn83 } from "@ai-matrx/design-system";
44177
44211
  import { jsx as jsx142, jsxs as jsxs132 } from "react/jsx-runtime";
44178
44212
  function DocRender({ templateId, recordId, filename, onRendered, className }) {
44179
44213
  const client = useRecordsClient84();
44180
- const [preview, setPreview] = useState118(null);
44181
- const [renders, setRenders] = useState118(null);
44182
- const [showing, setShowing] = useState118(null);
44183
- const [error, setError] = useState118(null);
44184
- const [busy, setBusy] = useState118(null);
44214
+ const [preview, setPreview] = useState119(null);
44215
+ const [renders, setRenders] = useState119(null);
44216
+ const [showing, setShowing] = useState119(null);
44217
+ const [error, setError] = useState119(null);
44218
+ const [busy, setBusy] = useState119(null);
44185
44219
  const paper = useRef57(null);
44186
44220
  const load = useCallback57(async () => {
44187
44221
  const [body, held] = await Promise.all([
@@ -44200,7 +44234,7 @@ function DocRender({ templateId, recordId, filename, onRendered, className }) {
44200
44234
  setPreview(body.data);
44201
44235
  setRenders(held.data.filter((r) => r.template_id === templateId));
44202
44236
  }, [client, templateId, recordId]);
44203
- useEffect103(() => {
44237
+ useEffect104(() => {
44204
44238
  void load();
44205
44239
  }, [load]);
44206
44240
  async function freeze() {
@@ -44287,7 +44321,7 @@ function DocRender({ templateId, recordId, filename, onRendered, className }) {
44287
44321
  }
44288
44322
 
44289
44323
  // src/SignBlock.tsx
44290
- import { useCallback as useCallback58, useEffect as useEffect104, useState as useState119 } from "react";
44324
+ import { useCallback as useCallback58, useEffect as useEffect105, useState as useState120 } from "react";
44291
44325
  import { useFields as useFields27, useRecordsClient as useRecordsClient85 } from "@ai-matrx/records/react";
44292
44326
  import { BasicInput as BasicInput31, Button as Button92, Skeleton as Skeleton31, cn as cn84 } from "@ai-matrx/design-system";
44293
44327
  import { useTable as useTable29 } from "@ai-matrx/records/react";
@@ -44297,11 +44331,11 @@ function SignBlock({ tableId, recordId, render, className }) {
44297
44331
  const table = useTable29(tableId);
44298
44332
  const rights = useTableRights(table.data);
44299
44333
  const fields = useFields27(tableId);
44300
- const [signatures, setSignatures] = useState119(null);
44301
- const [verdicts, setVerdicts] = useState119({});
44302
- const [error, setError] = useState119(null);
44303
- const [name, setName] = useState119("");
44304
- const [busy, setBusy] = useState119(false);
44334
+ const [signatures, setSignatures] = useState120(null);
44335
+ const [verdicts, setVerdicts] = useState120({});
44336
+ const [error, setError] = useState120(null);
44337
+ const [name, setName] = useState120("");
44338
+ const [busy, setBusy] = useState120(false);
44305
44339
  const load = useCallback58(async () => {
44306
44340
  const held = await client.docSignatures({ record_id: recordId });
44307
44341
  if (!held.ok) {
@@ -44317,7 +44351,7 @@ function SignBlock({ tableId, recordId, render, className }) {
44317
44351
  }
44318
44352
  setVerdicts(answers);
44319
44353
  }, [client, recordId]);
44320
- useEffect104(() => {
44354
+ useEffect105(() => {
44321
44355
  void load();
44322
44356
  }, [load]);
44323
44357
  async function sign(field2) {
@@ -44438,7 +44472,7 @@ function SignBlock({ tableId, recordId, render, className }) {
44438
44472
  }
44439
44473
 
44440
44474
  // src/NotifyRuleEditor.tsx
44441
- import { useCallback as useCallback59, useEffect as useEffect105, useState as useState120 } from "react";
44475
+ import { useCallback as useCallback59, useEffect as useEffect106, useState as useState121 } from "react";
44442
44476
  import { useRecordsClient as useRecordsClient86, useTable as useTable30 } from "@ai-matrx/records/react";
44443
44477
  import { hasQuietHours as hasQuietHours3 } from "@ai-matrx/records";
44444
44478
  import { Button as Button93, Skeleton as Skeleton32, cn as cn85 } from "@ai-matrx/design-system";
@@ -44450,12 +44484,12 @@ function NotifyRuleEditor({ tableId, seed, chosenRuleId, onChoose, className })
44450
44484
  const host = useRecordsUi();
44451
44485
  const table = useTable30(tableId);
44452
44486
  const rights = useTableRights(table.data);
44453
- const [subscriptions, setSubscriptions] = useState120(null);
44454
- const [cadences, setCadences] = useState120([]);
44455
- const [views, setViews] = useState120(null);
44456
- const [error, setError] = useState120(null);
44457
- const [busy, setBusy] = useState120(false);
44458
- const [stopping, setStopping] = useState120(null);
44487
+ const [subscriptions, setSubscriptions] = useState121(null);
44488
+ const [cadences, setCadences] = useState121([]);
44489
+ const [views, setViews] = useState121(null);
44490
+ const [error, setError] = useState121(null);
44491
+ const [busy, setBusy] = useState121(false);
44492
+ const [stopping, setStopping] = useState121(null);
44459
44493
  const load = useCallback59(async () => {
44460
44494
  const [held, offered] = await Promise.all([
44461
44495
  // THE PERSON'S OWN DOOR, not the notifier's. It answers what is addressed
@@ -44484,7 +44518,7 @@ function NotifyRuleEditor({ tableId, seed, chosenRuleId, onChoose, className })
44484
44518
  }
44485
44519
  setViews(listed.data.map((v) => ({ id: v.view_id, name: v.name })));
44486
44520
  }, [client, host, tableId]);
44487
- useEffect105(() => {
44521
+ useEffect106(() => {
44488
44522
  void load();
44489
44523
  }, [load]);
44490
44524
  const write = useCallback59(
@@ -44512,7 +44546,7 @@ function NotifyRuleEditor({ tableId, seed, chosenRuleId, onChoose, className })
44512
44546
  },
44513
44547
  [client, tableId]
44514
44548
  );
44515
- useEffect105(() => {
44549
+ useEffect106(() => {
44516
44550
  if (!subscriptions || !seed || seed.length === 0) return;
44517
44551
  const missing = seed.filter((s) => !subscriptions.some((held) => held.name === s.name));
44518
44552
  if (missing.length === 0) return;
@@ -44693,7 +44727,7 @@ function NotifyRuleEditor({ tableId, seed, chosenRuleId, onChoose, className })
44693
44727
  }
44694
44728
 
44695
44729
  // src/DashboardCanvas.tsx
44696
- import { useCallback as useCallback60, useEffect as useEffect107, useMemo as useMemo71, useState as useState123 } from "react";
44730
+ import { useCallback as useCallback60, useEffect as useEffect108, useMemo as useMemo71, useState as useState124 } from "react";
44697
44731
  import { useFields as useFields30, useRecordsClient as useRecordsClient88, useTable as useTable32 } from "@ai-matrx/records/react";
44698
44732
  import {
44699
44733
  BasicInput as BasicInput32,
@@ -44861,7 +44895,7 @@ function GridCell2({
44861
44895
  }
44862
44896
 
44863
44897
  // src/AddChart.tsx
44864
- import { useMemo as useMemo70, useState as useState122 } from "react";
44898
+ import { useMemo as useMemo70, useState as useState123 } from "react";
44865
44899
  import { useFields as useFields29, useRecordsClient as useRecordsClient87 } from "@ai-matrx/records/react";
44866
44900
  import {
44867
44901
  Button as Button95,
@@ -44873,7 +44907,7 @@ import {
44873
44907
  } from "@ai-matrx/design-system";
44874
44908
 
44875
44909
  // src/TablePickers.tsx
44876
- import { useEffect as useEffect106, useMemo as useMemo69, useState as useState121 } from "react";
44910
+ import { useEffect as useEffect107, useMemo as useMemo69, useState as useState122 } from "react";
44877
44911
  import { RecordsProvider as RecordsProvider2, useFields as useFields28, useRecords as useRecords7, useTable as useTable31 } from "@ai-matrx/records/react";
44878
44912
  import { Button as Button94, CreatablePicker as CreatablePicker2 } from "@ai-matrx/design-system";
44879
44913
 
@@ -44993,8 +45027,8 @@ function readTablesAnywhere(dataSource) {
44993
45027
  return read;
44994
45028
  }
44995
45029
  function useTablesAnywhere(dataSource) {
44996
- const [state, setState] = useState121({ loading: true, error: null, rows: [] });
44997
- useEffect106(() => {
45030
+ const [state, setState] = useState122({ loading: true, error: null, rows: [] });
45031
+ useEffect107(() => {
44998
45032
  let live = true;
44999
45033
  void readTablesAnywhere(dataSource).then((result) => {
45000
45034
  if (live) setState(result);
@@ -45071,7 +45105,7 @@ function ColumnValuesEditor({ tableId, value, onChange, disabled, addLabel }) {
45071
45105
  const all = useMemo69(() => fields.data ?? [], [fields.data]);
45072
45106
  const byKey = useMemo69(() => new Map(all.map((f) => [f.key, f])), [all]);
45073
45107
  const keys = Object.keys(value);
45074
- const [adding, setAdding] = useState121(false);
45108
+ const [adding, setAdding] = useState122(false);
45075
45109
  const optionsFor = (current) => all.filter((f) => f.key === current || !(f.key in value)).map((f) => ({ value: f.key, label: fieldName(f) }));
45076
45110
  const rename = (from, to) => {
45077
45111
  if (from === to) return;
@@ -45227,7 +45261,7 @@ function chartSpecFrom(args) {
45227
45261
  }
45228
45262
  function AddChart({ subject, onAdd, onClose }) {
45229
45263
  const client = useRecordsClient87();
45230
- const [tableId, setTableId] = useState122(subject);
45264
+ const [tableId, setTableId] = useState123(subject);
45231
45265
  const fields = useFields29(tableId);
45232
45266
  const all = useMemo70(() => onePerKey(fields.data ?? []), [fields.data]);
45233
45267
  const labels = useRecordLabels(all);
@@ -45235,11 +45269,11 @@ function AddChart({ subject, onAdd, onClose }) {
45235
45269
  const field2 = all.find((f) => f.key === key);
45236
45270
  return field2 ? scalarText(field2, value, labels) : String(value);
45237
45271
  };
45238
- const [measureKey5, setMeasureKey] = useState122("count");
45239
- const [splitKey, setSplitKey] = useState122("none");
45240
- const [kind, setKind] = useState122("auto");
45241
- const [filter, setFilter] = useState122({});
45242
- const [saving, setSaving] = useState122(false);
45272
+ const [measureKey5, setMeasureKey] = useState123("count");
45273
+ const [splitKey, setSplitKey] = useState123("none");
45274
+ const [kind, setKind] = useState123("auto");
45275
+ const [filter, setFilter] = useState123({});
45276
+ const [saving, setSaving] = useState123(false);
45243
45277
  const numbers = numberColumns(all);
45244
45278
  const choices = offerableFields(all, "choice");
45245
45279
  const dates = offerableFields(all, "date");
@@ -45386,20 +45420,20 @@ function DashboardCanvas({ tableId, activeDashboardId, filter, createOnMount, on
45386
45420
  const table = useTable32(tableId);
45387
45421
  const rights = useTableRights(table.data);
45388
45422
  const fields = useFields30(tableId);
45389
- const [boards, setBoards] = useState123(null);
45390
- const [pages, setPages] = useState123([]);
45391
- const [error, setError] = useState123(null);
45392
- const [activeId, setActiveId] = useState123(activeDashboardId ?? null);
45393
- const [madeOnMount, setMadeOnMount] = useState123("waiting");
45394
- const [askingToRemove, setAskingToRemove] = useState123(null);
45395
- const [run, setRun] = useState123(null);
45396
- const [running, setRunning] = useState123(false);
45397
- const [question, setQuestion] = useState123("");
45398
- const [asking, setAsking] = useState123(false);
45399
- const [scheduling, setScheduling] = useState123(false);
45400
- const [arranging, setArranging] = useState123(false);
45401
- const [adding, setAdding] = useState123(false);
45402
- const [grain, setGrain] = useState123(null);
45423
+ const [boards, setBoards] = useState124(null);
45424
+ const [pages, setPages] = useState124([]);
45425
+ const [error, setError] = useState124(null);
45426
+ const [activeId, setActiveId] = useState124(activeDashboardId ?? null);
45427
+ const [madeOnMount, setMadeOnMount] = useState124("waiting");
45428
+ const [askingToRemove, setAskingToRemove] = useState124(null);
45429
+ const [run, setRun] = useState124(null);
45430
+ const [running, setRunning] = useState124(false);
45431
+ const [question, setQuestion] = useState124("");
45432
+ const [asking, setAsking] = useState124(false);
45433
+ const [scheduling, setScheduling] = useState124(false);
45434
+ const [arranging, setArranging] = useState124(false);
45435
+ const [adding, setAdding] = useState124(false);
45436
+ const [grain, setGrain] = useState124(null);
45403
45437
  const runArgs = (dashboard_id) => ({
45404
45438
  dashboard_id,
45405
45439
  ...filter ? { filter } : {},
@@ -45417,11 +45451,11 @@ function DashboardCanvas({ tableId, activeDashboardId, filter, createOnMount, on
45417
45451
  setBoards(read);
45418
45452
  return read;
45419
45453
  }, [client, tableId]);
45420
- const [notKept, setNotKept] = useState123(null);
45421
- useEffect107(() => {
45454
+ const [notKept, setNotKept] = useState124(null);
45455
+ useEffect108(() => {
45422
45456
  void load();
45423
45457
  }, [load]);
45424
- useEffect107(() => {
45458
+ useEffect108(() => {
45425
45459
  if (!boards || boards.length === 0) return;
45426
45460
  if (createOnMount && madeOnMount !== "done") return;
45427
45461
  const chosen = boards.find((d) => d.id === (activeDashboardId ?? activeId)) ?? boards[0];
@@ -45429,7 +45463,7 @@ function DashboardCanvas({ tableId, activeDashboardId, filter, createOnMount, on
45429
45463
  }, [boards, activeDashboardId, madeOnMount]);
45430
45464
  const board = useMemo71(() => boards?.find((d) => d.id === activeId) ?? null, [boards, activeId]);
45431
45465
  const filterKey = JSON.stringify(filter ?? {});
45432
- useEffect107(() => {
45466
+ useEffect108(() => {
45433
45467
  if (!activeId) {
45434
45468
  setRun(null);
45435
45469
  return;
@@ -45499,7 +45533,7 @@ function DashboardCanvas({ tableId, activeDashboardId, filter, createOnMount, on
45499
45533
  ]
45500
45534
  );
45501
45535
  }
45502
- useEffect107(() => {
45536
+ useEffect108(() => {
45503
45537
  if (!createOnMount || madeOnMount !== "waiting" || boards === null || !fields.data) return;
45504
45538
  setMadeOnMount("making");
45505
45539
  void create().then(() => setMadeOnMount("done"));
@@ -45944,10 +45978,10 @@ function TargetControl({
45944
45978
  onChange
45945
45979
  }) {
45946
45980
  const saved = !block.target ? "none" : "field" in block.target && block.target.field ? "field" : "value";
45947
- const [mode, setMode] = useState123(saved);
45981
+ const [mode, setMode] = useState124(saved);
45948
45982
  const savedValue = block.target && "value" in block.target && typeof block.target.value === "number" ? block.target.value : null;
45949
- const [draft, setDraft] = useState123(savedValue === null ? "" : String(savedValue));
45950
- useEffect107(() => {
45983
+ const [draft, setDraft] = useState124(savedValue === null ? "" : String(savedValue));
45984
+ useEffect108(() => {
45951
45985
  setMode(saved);
45952
45986
  setDraft(savedValue === null ? "" : String(savedValue));
45953
45987
  }, [saved, savedValue]);
@@ -46015,7 +46049,7 @@ function TargetControl({
46015
46049
 
46016
46050
  // src/QuestionPanel.tsx
46017
46051
  import { copyText as copyText9 } from "@ai-matrx/kit/clipboard";
46018
- import { useEffect as useEffect108, useMemo as useMemo72, useRef as useRef59, useState as useState124 } from "react";
46052
+ import { useEffect as useEffect109, useMemo as useMemo72, useRef as useRef59, useState as useState125 } from "react";
46019
46053
  import { Badge as Badge24, BasicInput as BasicInput33, Button as Button97, Checkbox as Checkbox16, Label as Label26, Skeleton as Skeleton34, cn as cn88 } from "@ai-matrx/design-system";
46020
46054
  import { useFields as useFields31, useRecordsClient as useRecordsClient89 } from "@ai-matrx/records/react";
46021
46055
 
@@ -46069,9 +46103,9 @@ function QuestionPanel({ tableId, activeQuestionId, draft, className }) {
46069
46103
  const fields = useFields31(tableId);
46070
46104
  const all = useMemo72(() => fields.data ?? [], [fields.data]);
46071
46105
  const me = client.config.actor?.user_id ?? null;
46072
- const [hidden, setHidden] = useState124(null);
46073
- const [related, setRelated] = useState124({});
46074
- useEffect108(() => {
46106
+ const [hidden, setHidden] = useState125(null);
46107
+ const [related, setRelated] = useState125({});
46108
+ useEffect109(() => {
46075
46109
  if (all.length === 0) {
46076
46110
  if (!fields.loading) setHidden(/* @__PURE__ */ new Set());
46077
46111
  return;
@@ -46095,17 +46129,17 @@ function QuestionPanel({ tableId, activeQuestionId, draft, className }) {
46095
46129
  };
46096
46130
  }, [client, tableId, all, fields.loading]);
46097
46131
  const offered = useMemo72(() => hidden ? all.filter((f) => !hidden.has(f.key)) : [], [all, hidden]);
46098
- const [saved, setSaved] = useState124(null);
46099
- const [savedEpoch, setSavedEpoch] = useState124(0);
46100
- const [current, setCurrent] = useState124(null);
46101
- const [spec, setSpec] = useState124(question_exports.newQuestion);
46102
- const [name, setName] = useState124("");
46103
- const [shared, setShared] = useState124(true);
46104
- const [saveError, setSaveError] = useState124(null);
46105
- const [saving, setSaving] = useState124(false);
46106
- const [linkMissed, setLinkMissed] = useState124(false);
46132
+ const [saved, setSaved] = useState125(null);
46133
+ const [savedEpoch, setSavedEpoch] = useState125(0);
46134
+ const [current, setCurrent] = useState125(null);
46135
+ const [spec, setSpec] = useState125(question_exports.newQuestion);
46136
+ const [name, setName] = useState125("");
46137
+ const [shared, setShared] = useState125(true);
46138
+ const [saveError, setSaveError] = useState125(null);
46139
+ const [saving, setSaving] = useState125(false);
46140
+ const [linkMissed, setLinkMissed] = useState125(false);
46107
46141
  const openedFromLink = useRef59(false);
46108
- useEffect108(() => {
46142
+ useEffect109(() => {
46109
46143
  let live = true;
46110
46144
  void (0, question_exports.questionsOf)(client, tableId).then((answer2) => {
46111
46145
  if (!live) return;
@@ -46128,16 +46162,16 @@ function QuestionPanel({ tableId, activeQuestionId, draft, className }) {
46128
46162
  setShared(q ? q.shared : true);
46129
46163
  setSaveError(null);
46130
46164
  };
46131
- useEffect108(() => {
46165
+ useEffect109(() => {
46132
46166
  if (!draft) return;
46133
46167
  open(null);
46134
46168
  setSpec(draft);
46135
46169
  }, [draft]);
46136
46170
  const mine = !current || me !== null && current.createdBy === me;
46137
- const [answer, setAnswer] = useState124(null);
46138
- const [asking, setAsking] = useState124(false);
46171
+ const [answer, setAnswer] = useState125(null);
46172
+ const [asking, setAsking] = useState125(false);
46139
46173
  const specKey = JSON.stringify(spec);
46140
- useEffect108(() => {
46174
+ useEffect109(() => {
46141
46175
  if (all.length === 0) return;
46142
46176
  let live = true;
46143
46177
  setAsking(true);
@@ -46579,7 +46613,7 @@ function QuestionAnswerView({ tableId, spec, answer, fields, related = NO_RELATE
46579
46613
  }
46580
46614
 
46581
46615
  // src/TableAsk.tsx
46582
- import { useState as useState125 } from "react";
46616
+ import { useState as useState126 } from "react";
46583
46617
  import { BasicInput as BasicInput34, Button as Button98, Popover as Popover15, PopoverContent as PopoverContent15, PopoverTrigger as PopoverTrigger15, Skeleton as Skeleton35 } from "@ai-matrx/design-system";
46584
46618
  import { optionLabel as optionLabel4 } from "@ai-matrx/records";
46585
46619
  import { useFields as useFields32, useRecordsClient as useRecordsClient90 } from "@ai-matrx/records/react";
@@ -46802,10 +46836,10 @@ function TableAsk({ tableId, onOpenInQuestions }) {
46802
46836
  const client = useRecordsClient90();
46803
46837
  const fields = useFields32(tableId);
46804
46838
  const all = fields.data ?? [];
46805
- const [open, setOpen] = useState125(false);
46806
- const [words2, setWords] = useState125("");
46807
- const [said2, setSaid] = useState125({ kind: "idle" });
46808
- const ask = async () => {
46839
+ const [open, setOpen] = useState126(false);
46840
+ const [words2, setWords] = useState126("");
46841
+ const [said2, setSaid] = useState126({ kind: "idle" });
46842
+ const ask2 = async () => {
46809
46843
  if (words2.trim() === "" || all.length === 0) return;
46810
46844
  const choices = {};
46811
46845
  await Promise.all(
@@ -46829,7 +46863,7 @@ function TableAsk({ tableId, onOpenInQuestions }) {
46829
46863
  className: "flex items-center gap-1",
46830
46864
  onSubmit: (event) => {
46831
46865
  event.preventDefault();
46832
- void ask();
46866
+ void ask2();
46833
46867
  },
46834
46868
  children: [
46835
46869
  /* @__PURE__ */ jsx151(
@@ -46877,7 +46911,7 @@ function TableAsk({ tableId, onOpenInQuestions }) {
46877
46911
  }
46878
46912
 
46879
46913
  // src/PageScreen.tsx
46880
- import { useCallback as useCallback61, useEffect as useEffect109, useMemo as useMemo73, useState as useState126 } from "react";
46914
+ import { useCallback as useCallback61, useEffect as useEffect110, useMemo as useMemo73, useState as useState127 } from "react";
46881
46915
  import {
46882
46916
  useFields as useFields33,
46883
46917
  useRecordPage as useRecordPage3,
@@ -46903,18 +46937,18 @@ function PageScreen({
46903
46937
  const client = useRecordsClient91();
46904
46938
  const host = useRecordsUi();
46905
46939
  const organizationId = client.config.organizationId;
46906
- const [page, setPage] = useState126(null);
46907
- const [missing, setMissing] = useState126(false);
46908
- const [error, setError] = useState126(null);
46909
- const [level, setLevel] = useState126(null);
46910
- const [editing, setEditing] = useState126(startEditing);
46911
- const [run, setRun] = useState126(null);
46912
- const [saveError, setSaveError] = useState126(null);
46913
- const [askingToArchive, setAskingToArchive] = useState126(false);
46914
- const [selected, setSelected] = useState126({});
46915
- const [filterValues, setFilterValues] = useState126({});
46916
- const [mine, setMine] = useState126({});
46917
- const [making, setMaking] = useState126("waiting");
46940
+ const [page, setPage] = useState127(null);
46941
+ const [missing, setMissing] = useState127(false);
46942
+ const [error, setError] = useState127(null);
46943
+ const [level, setLevel] = useState127(null);
46944
+ const [editing, setEditing] = useState127(startEditing);
46945
+ const [run, setRun] = useState127(null);
46946
+ const [saveError, setSaveError] = useState127(null);
46947
+ const [askingToArchive, setAskingToArchive] = useState127(false);
46948
+ const [selected, setSelected] = useState127({});
46949
+ const [filterValues, setFilterValues] = useState127({});
46950
+ const [mine, setMine] = useState127({});
46951
+ const [making, setMaking] = useState127("waiting");
46918
46952
  const id = page?.id ?? pageId ?? null;
46919
46953
  const load = useCallback61(
46920
46954
  async (want) => {
@@ -46935,7 +46969,7 @@ function PageScreen({
46935
46969
  },
46936
46970
  [client]
46937
46971
  );
46938
- useEffect109(() => {
46972
+ useEffect110(() => {
46939
46973
  if (!newOnTable || pageId || making !== "waiting") return;
46940
46974
  setMaking("making");
46941
46975
  void client.dashboardDeclare({
@@ -46955,11 +46989,11 @@ function PageScreen({
46955
46989
  onCreated?.(made.data);
46956
46990
  });
46957
46991
  }, [client, newOnTable, pageId, making, load, onCreated]);
46958
- useEffect109(() => {
46992
+ useEffect110(() => {
46959
46993
  if (!pageId) return;
46960
46994
  void load(pageId);
46961
46995
  }, [pageId, load]);
46962
- useEffect109(() => {
46996
+ useEffect110(() => {
46963
46997
  if (!id) return;
46964
46998
  let live = true;
46965
46999
  void client.myLevels({ ids: [id], subject: "record" }).then((answered) => {
@@ -46971,7 +47005,7 @@ function PageScreen({
46971
47005
  }, [client, id]);
46972
47006
  const canEdit = level !== null && EDIT_LEVELS.has(level);
46973
47007
  const chartKey = page ? JSON.stringify(page.blocks.map((b) => b.id)) + page.version : "";
46974
- useEffect109(() => {
47008
+ useEffect110(() => {
46975
47009
  if (!page || page.blocks.length === 0) {
46976
47010
  setRun(null);
46977
47011
  return;
@@ -47216,8 +47250,8 @@ function AppletBlockView({ block }) {
47216
47250
  }
47217
47251
  function AppletPick({ value, onChange }) {
47218
47252
  const host = useRecordsUi();
47219
- const [options, setOptions] = useState126(null);
47220
- useEffect109(() => {
47253
+ const [options, setOptions] = useState127(null);
47254
+ useEffect110(() => {
47221
47255
  let live = true;
47222
47256
  host.applets?.list().then((apps) => live && setOptions(apps.map((a) => ({ value: a.id, label: a.name })))).catch(() => live && setOptions([]));
47223
47257
  return () => {
@@ -47253,8 +47287,8 @@ function ListBlockView({
47253
47287
  const table = useTable33(block.table_id);
47254
47288
  const fields = useFields33(block.table_id);
47255
47289
  const all = useMemo73(() => onePerKey3(fields.data ?? []), [fields.data]);
47256
- const [view, setView] = useState126(block.view_id ? "reading" : null);
47257
- useEffect109(() => {
47290
+ const [view, setView] = useState127(block.view_id ? "reading" : null);
47291
+ useEffect110(() => {
47258
47292
  if (!block.view_id) {
47259
47293
  setView(null);
47260
47294
  return;
@@ -47271,8 +47305,8 @@ function ListBlockView({
47271
47305
  };
47272
47306
  }, [client, block.table_id, block.view_id]);
47273
47307
  const meField = block.me_field ? all.find((f) => f.key === block.me_field) : void 0;
47274
- const [me, setMe] = useState126(null);
47275
- useEffect109(() => {
47308
+ const [me, setMe] = useState127(null);
47309
+ useEffect110(() => {
47276
47310
  if (!mine || !meField?.relation_target || !viewerUserId) {
47277
47311
  setMe(null);
47278
47312
  return;
@@ -47302,12 +47336,12 @@ function ListBlockView({
47302
47336
  ...sort.length > 0 ? { sort } : {}
47303
47337
  });
47304
47338
  const reload = page.reload;
47305
- useEffect109(() => onRecordChanged2(() => reload()), [reload]);
47339
+ useEffect110(() => onRecordChanged2(() => reload()), [reload]);
47306
47340
  const rows = nobodyIsMe ? [] : page.data?.rows ?? [];
47307
47341
  const columns = block.columns && block.columns.length > 0 ? block.columns.map((k) => all.find((f) => f.key === k)).filter((f) => !!f) : [...all].sort((a, b) => (a.sort ?? 100) - (b.sort ?? 100)).slice(0, DEFAULT_COLUMNS);
47308
47342
  const firstId = rows[0]?.id ?? null;
47309
47343
  const stillThere = selected !== null && rows.some((r) => r.id === selected);
47310
- useEffect109(() => {
47344
+ useEffect110(() => {
47311
47345
  if (page.loading || waiting) return;
47312
47346
  if (!stillThere) onSelect(firstId);
47313
47347
  }, [firstId, stillThere, page.loading, waiting]);
@@ -47370,11 +47404,11 @@ function ActionButton2({ block, recordId }) {
47370
47404
  const client = useRecordsClient91();
47371
47405
  const actionsRead = useRowActions2(block.action_id ? block.table_id : null);
47372
47406
  const action3 = !block.action_id ? null : actionsRead.data ? actionsRead.data.actions.find((a) => a.id === block.action_id) ?? null : actionsRead.loading ? "reading" : null;
47373
- const [asking, setAsking] = useState126(false);
47374
- const [running, setRunning] = useState126(false);
47375
- const [done, setDone] = useState126(null);
47376
- const [error, setError] = useState126(null);
47377
- useEffect109(() => {
47407
+ const [asking, setAsking] = useState127(false);
47408
+ const [running, setRunning] = useState127(false);
47409
+ const [done, setDone] = useState127(null);
47410
+ const [error, setError] = useState127(null);
47411
+ useEffect110(() => {
47378
47412
  setDone(null);
47379
47413
  setError(null);
47380
47414
  setAsking(false);
@@ -47413,9 +47447,9 @@ function ActionButton2({ block, recordId }) {
47413
47447
  }
47414
47448
  function FormBlockView({ block }) {
47415
47449
  const client = useRecordsClient91();
47416
- const [form, setForm] = useState126("reading");
47417
- const [sent, setSent] = useState126(0);
47418
- useEffect109(() => {
47450
+ const [form, setForm] = useState127("reading");
47451
+ const [sent, setSent] = useState127(0);
47452
+ useEffect110(() => {
47419
47453
  if (!block.form_id) {
47420
47454
  setForm(null);
47421
47455
  return;
@@ -47540,10 +47574,10 @@ function FieldPick({
47540
47574
  }
47541
47575
  function ListSettings({ block, onChange }) {
47542
47576
  const client = useRecordsClient91();
47543
- const [views, setViews] = useState126([]);
47577
+ const [views, setViews] = useState127([]);
47544
47578
  const fields = useFields33(block.table_id);
47545
47579
  const all = onePerKey3(fields.data ?? []);
47546
- useEffect109(() => {
47580
+ useEffect110(() => {
47547
47581
  let live = true;
47548
47582
  void client.views({ table_id: block.table_id }).then((answered) => {
47549
47583
  if (live) setViews(answered.ok ? answered.data : []);
@@ -47619,8 +47653,8 @@ function ActionPicker({ tableId, value, onChange }) {
47619
47653
  }
47620
47654
  function FormPicker({ tableId, value, onChange }) {
47621
47655
  const client = useRecordsClient91();
47622
- const [forms, setForms] = useState126([]);
47623
- useEffect109(() => {
47656
+ const [forms, setForms] = useState127([]);
47657
+ useEffect110(() => {
47624
47658
  let live = true;
47625
47659
  void client.forms({ table_id: tableId }).then((answered) => {
47626
47660
  if (live) setForms(answered.ok ? answered.data : []);
@@ -47666,7 +47700,7 @@ function onePerKey3(all) {
47666
47700
 
47667
47701
  // src/FormsPanel.tsx
47668
47702
  import { copyText as copyText10 } from "@ai-matrx/kit/clipboard";
47669
- import { useCallback as useCallback62, useEffect as useEffect110, useState as useState127 } from "react";
47703
+ import { useCallback as useCallback62, useEffect as useEffect111, useState as useState128 } from "react";
47670
47704
  import { useRecordsClient as useRecordsClient92, useTable as useTable34 } from "@ai-matrx/records/react";
47671
47705
  import { publicFormPath as publicFormPath2 } from "@ai-matrx/records";
47672
47706
  import { Badge as Badge25, Button as Button100, Skeleton as Skeleton37, cn as cn90 } from "@ai-matrx/design-system";
@@ -47684,15 +47718,15 @@ function FormsPanel({ tableId, activeFormId, className }) {
47684
47718
  const host = useRecordsUi();
47685
47719
  const table = useTable34(tableId);
47686
47720
  const rights = useTableRights(table.data);
47687
- const [forms, setForms] = useState127(null);
47688
- const [error, setError] = useState127(null);
47689
- const [busy, setBusy] = useState127(null);
47690
- const [copied, setCopied] = useState127(null);
47691
- const [building, setBuilding] = useState127(false);
47692
- const [archivedSaid, setArchivedSaid] = useState127(null);
47721
+ const [forms, setForms] = useState128(null);
47722
+ const [error, setError] = useState128(null);
47723
+ const [busy, setBusy] = useState128(null);
47724
+ const [copied, setCopied] = useState128(null);
47725
+ const [building, setBuilding] = useState128(false);
47726
+ const [archivedSaid, setArchivedSaid] = useState128(null);
47693
47727
  const linked = activeFormId && forms !== null ? forms.find((f) => f.form_id === activeFormId) ?? null : null;
47694
47728
  const linkedMissing = Boolean(activeFormId) && forms !== null && linked === null;
47695
- useEffect110(() => {
47729
+ useEffect111(() => {
47696
47730
  if (linked && rights.structure) setBuilding(true);
47697
47731
  }, [linked, rights.structure]);
47698
47732
  const load = useCallback62(async () => {
@@ -47705,7 +47739,7 @@ function FormsPanel({ tableId, activeFormId, className }) {
47705
47739
  setError(null);
47706
47740
  setForms(answered.data);
47707
47741
  }, [client, tableId]);
47708
- useEffect110(() => {
47742
+ useEffect111(() => {
47709
47743
  void load();
47710
47744
  }, [load]);
47711
47745
  const toggle = useCallback62(
@@ -47722,7 +47756,7 @@ function FormsPanel({ tableId, activeFormId, className }) {
47722
47756
  },
47723
47757
  [client, load]
47724
47758
  );
47725
- const [shown4, setShown] = useState127(null);
47759
+ const [shown4, setShown] = useState128(null);
47726
47760
  const copy = useCallback62(async (url, formId) => {
47727
47761
  if (await copyText10(url)) {
47728
47762
  setCopied(formId);
@@ -47850,12 +47884,12 @@ function FormsPanel({ tableId, activeFormId, className }) {
47850
47884
  }
47851
47885
 
47852
47886
  // src/CaptureSheet.tsx
47853
- import { useCallback as useCallback64, useEffect as useEffect112, useRef as useRef61, useState as useState129 } from "react";
47887
+ import { useCallback as useCallback64, useEffect as useEffect113, useRef as useRef61, useState as useState130 } from "react";
47854
47888
  import { useFields as useFields34, useRecordsClient as useRecordsClient94, useTable as useTable35 } from "@ai-matrx/records/react";
47855
47889
  import { Button as Button102, Input as Input8, Skeleton as Skeleton39, Textarea as Textarea8, cn as cn92 } from "@ai-matrx/design-system";
47856
47890
 
47857
47891
  // src/CaptureRun.tsx
47858
- import { useCallback as useCallback63, useEffect as useEffect111, useMemo as useMemo74, useRef as useRef60, useState as useState128 } from "react";
47892
+ import { useCallback as useCallback63, useEffect as useEffect112, useMemo as useMemo74, useRef as useRef60, useState as useState129 } from "react";
47859
47893
  import {
47860
47894
  coerceTypedAnswer as coerceTypedAnswer3,
47861
47895
  coercionLabel,
@@ -47902,19 +47936,19 @@ function whereWeAre(timeoutMs = 4e3) {
47902
47936
  function CaptureRun({ sheetId, face: given, className }) {
47903
47937
  const client = useRecordsClient93();
47904
47938
  const host = useRecordsUi();
47905
- const [face, setFace] = useState128(given);
47906
- const [loadFailed, setLoadFailed] = useState128(null);
47907
- const [at, setAt] = useState128(0);
47908
- const [answers, setAnswers] = useState128({});
47909
- const [files, setFiles] = useState128({});
47910
- const [missing, setMissing] = useState128(null);
47911
- const [done, setDone] = useState128(null);
47912
- const [counts, setCounts] = useState128({ waiting: 0, sending: 0, refused: 0, landed: 0 });
47913
- const [items, setItems] = useState128([]);
47914
- const [lastSynced, setLastSynced] = useState128(null);
47915
- const [sending, setSending] = useState128(false);
47939
+ const [face, setFace] = useState129(given);
47940
+ const [loadFailed, setLoadFailed] = useState129(null);
47941
+ const [at, setAt] = useState129(0);
47942
+ const [answers, setAnswers] = useState129({});
47943
+ const [files, setFiles] = useState129({});
47944
+ const [missing, setMissing] = useState129(null);
47945
+ const [done, setDone] = useState129(null);
47946
+ const [counts, setCounts] = useState129({ waiting: 0, sending: 0, refused: 0, landed: 0 });
47947
+ const [items, setItems] = useState129([]);
47948
+ const [lastSynced, setLastSynced] = useState129(null);
47949
+ const [sending, setSending] = useState129(false);
47916
47950
  const queueRef = useRef60(null);
47917
- useEffect111(() => {
47951
+ useEffect112(() => {
47918
47952
  const q2 = openCaptureQueue({
47919
47953
  onChange: (c, all) => {
47920
47954
  setCounts(c);
@@ -47952,7 +47986,7 @@ function CaptureRun({ sheetId, face: given, className }) {
47952
47986
  void q2.sync().then(() => void q2.lastSyncedAt().then(setLastSynced));
47953
47987
  return () => q2.dispose();
47954
47988
  }, [client, host]);
47955
- useEffect111(() => {
47989
+ useEffect112(() => {
47956
47990
  if (given !== void 0) return;
47957
47991
  let cancelled = false;
47958
47992
  void client.captureOpen({ sheet_id: sheetId }).then((res) => {
@@ -47965,8 +47999,8 @@ function CaptureRun({ sheetId, face: given, className }) {
47965
47999
  };
47966
48000
  }, [client, given, sheetId]);
47967
48001
  const questions = useMemo74(() => {
47968
- const asked2 = face?.presentation?.questions ?? [];
47969
- if (asked2.length > 0) return asked2;
48002
+ const asked3 = face?.presentation?.questions ?? [];
48003
+ if (asked3.length > 0) return asked3;
47970
48004
  return (face?.fields ?? []).map((f) => ({
47971
48005
  field: f.key,
47972
48006
  ask: f.label ?? f.key,
@@ -48284,15 +48318,15 @@ function AdHocCaptureSheet({
48284
48318
  const host = useRecordsUi();
48285
48319
  const table = useTable35(tableId);
48286
48320
  const fields = useFields34(tableId);
48287
- const [mode, setMode] = useState129("reading");
48288
- const [reading, setReading] = useState129("");
48289
- const [note, setNote] = useState129("");
48290
- const [fileId, setFileId] = useState129(null);
48291
- const [pending, setPending] = useState129(null);
48292
- const [saved, setSaved] = useState129([]);
48293
- const [error, setError] = useState129(null);
48294
- const [uploadError, setUploadError] = useState129(null);
48295
- const [flushing, setFlushing] = useState129(false);
48321
+ const [mode, setMode] = useState130("reading");
48322
+ const [reading, setReading] = useState130("");
48323
+ const [note, setNote] = useState130("");
48324
+ const [fileId, setFileId] = useState130(null);
48325
+ const [pending, setPending] = useState130(null);
48326
+ const [saved, setSaved] = useState130([]);
48327
+ const [error, setError] = useState130(null);
48328
+ const [uploadError, setUploadError] = useState130(null);
48329
+ const [flushing, setFlushing] = useState130(false);
48296
48330
  const queue = useRef61([]);
48297
48331
  const keep = useCallback64(
48298
48332
  async (next) => {
@@ -48302,7 +48336,7 @@ function AdHocCaptureSheet({
48302
48336
  },
48303
48337
  [host]
48304
48338
  );
48305
- useEffect112(() => {
48339
+ useEffect113(() => {
48306
48340
  let cancelled = false;
48307
48341
  void (async () => {
48308
48342
  const held = host.captureQueue ? await host.captureQueue.load() : [];
@@ -48481,17 +48515,17 @@ function AdHocCaptureSheet({
48481
48515
  }
48482
48516
 
48483
48517
  // src/PortalShell.tsx
48484
- import { useCallback as useCallback65, useEffect as useEffect113, useState as useState130 } from "react";
48518
+ import { useCallback as useCallback65, useEffect as useEffect114, useState as useState131 } from "react";
48485
48519
  import { useRecordsClient as useRecordsClient95 } from "@ai-matrx/records/react";
48486
48520
  import { Button as Button103, Skeleton as Skeleton40, cn as cn93 } from "@ai-matrx/design-system";
48487
48521
  import { jsx as jsx156, jsxs as jsxs145 } from "react/jsx-runtime";
48488
48522
  function PortalShell({ tableId, form, resourceType = "record", className }) {
48489
48523
  const client = useRecordsClient95();
48490
- const [card, setCard] = useState130(null);
48491
- const [reach, setReach] = useState130(null);
48492
- const [error, setError] = useState130(null);
48493
- const [open, setOpen] = useState130(null);
48494
- const [sending, setSending] = useState130(false);
48524
+ const [card, setCard] = useState131(null);
48525
+ const [reach, setReach] = useState131(null);
48526
+ const [error, setError] = useState131(null);
48527
+ const [open, setOpen] = useState131(null);
48528
+ const [sending, setSending] = useState131(false);
48495
48529
  const load = useCallback65(async () => {
48496
48530
  const who = await client.externalPrincipalCard();
48497
48531
  if (!who.ok) {
@@ -48507,7 +48541,7 @@ function PortalShell({ tableId, form, resourceType = "record", className }) {
48507
48541
  }
48508
48542
  setReach(reached.data.map((row) => row.resource_id));
48509
48543
  }, [client, resourceType]);
48510
- useEffect113(() => {
48544
+ useEffect114(() => {
48511
48545
  void load();
48512
48546
  }, [load]);
48513
48547
  if (error) {
@@ -48566,8 +48600,8 @@ function PortalShell({ tableId, form, resourceType = "record", className }) {
48566
48600
  }
48567
48601
  function PortalRow({ tableId, recordId }) {
48568
48602
  const client = useRecordsClient95();
48569
- const [title, setTitle] = useState130(null);
48570
- useEffect113(() => {
48603
+ const [title, setTitle] = useState131(null);
48604
+ useEffect114(() => {
48571
48605
  let cancelled = false;
48572
48606
  void client.recordRead({ record_id: recordId }).then((answered) => {
48573
48607
  if (cancelled) return;
@@ -48587,19 +48621,19 @@ function PortalRow({ tableId, recordId }) {
48587
48621
  }
48588
48622
 
48589
48623
  // src/PublicViewPage.tsx
48590
- import { useCallback as useCallback66, useEffect as useEffect114, useState as useState131 } from "react";
48624
+ import { useCallback as useCallback66, useEffect as useEffect115, useState as useState132 } from "react";
48591
48625
  import { useRecordsClient as useRecordsClient96 } from "@ai-matrx/records/react";
48592
48626
  import { Skeleton as Skeleton41, cn as cn94 } from "@ai-matrx/design-system";
48593
48627
  import { publicReadOf } from "@ai-matrx/records/forms";
48594
48628
  import { jsx as jsx157, jsxs as jsxs146 } from "react/jsx-runtime";
48595
48629
  function PublicViewPage({ slug, className }) {
48596
48630
  const client = useRecordsClient96();
48597
- const [binding, setBinding] = useState131(null);
48598
- const [rows, setRows] = useState131(null);
48599
- const [fields, setFields] = useState131(null);
48600
- const [error, setError] = useState131(null);
48601
- const [plan, setPlan] = useState131(null);
48602
- const [gap, setGap] = useState131(null);
48631
+ const [binding, setBinding] = useState132(null);
48632
+ const [rows, setRows] = useState132(null);
48633
+ const [fields, setFields] = useState132(null);
48634
+ const [error, setError] = useState132(null);
48635
+ const [plan, setPlan] = useState132(null);
48636
+ const [gap, setGap] = useState132(null);
48603
48637
  const load = useCallback66(async () => {
48604
48638
  const notice = await client.worldPublishGapNotice();
48605
48639
  if (notice.ok) setGap(notice.data);
@@ -48650,7 +48684,7 @@ function PublicViewPage({ slug, className }) {
48650
48684
  }
48651
48685
  setRows([{ id: chosen.recordId, document: read.data.document, level: "viewer", hidden: read.data.hidden }]);
48652
48686
  }, [client, slug]);
48653
- useEffect114(() => {
48687
+ useEffect115(() => {
48654
48688
  void load();
48655
48689
  }, [load]);
48656
48690
  if (error) return /* @__PURE__ */ jsx157(RefusalNotice, { error, className });
@@ -48688,7 +48722,7 @@ function PublicRow({ row, fields }) {
48688
48722
 
48689
48723
  // src/EmbedFrame.tsx
48690
48724
  import { copyText as copyText11 } from "@ai-matrx/kit/clipboard";
48691
- import { useCallback as useCallback67, useEffect as useEffect115, useState as useState132 } from "react";
48725
+ import { useCallback as useCallback67, useEffect as useEffect116, useState as useState133 } from "react";
48692
48726
  import { useRecordsClient as useRecordsClient97 } from "@ai-matrx/records/react";
48693
48727
  import { Button as Button104, Input as Input9, Skeleton as Skeleton42, Textarea as Textarea9, cn as cn95 } from "@ai-matrx/design-system";
48694
48728
  import { useTable as useTable36 } from "@ai-matrx/records/react";
@@ -48705,11 +48739,11 @@ function EmbedFrame({
48705
48739
  const host = useRecordsUi();
48706
48740
  const table = useTable36(tableId);
48707
48741
  const rights = useTableRights(table.data);
48708
- const [origins, setOrigins] = useState132("");
48709
- const [secret, setSecret] = useState132(null);
48710
- const [tokenId, setTokenId] = useState132(null);
48711
- const [error, setError] = useState132(null);
48712
- const [busy, setBusy] = useState132(false);
48742
+ const [origins, setOrigins] = useState133("");
48743
+ const [secret, setSecret] = useState133(null);
48744
+ const [tokenId, setTokenId] = useState133(null);
48745
+ const [error, setError] = useState133(null);
48746
+ const [busy, setBusy] = useState133(false);
48713
48747
  const mode = formId ? "write" : "read";
48714
48748
  const parsed = origins.split(/[\s,]+/).map((o) => o.trim()).filter((o) => o.length > 0);
48715
48749
  const issue = useCallback67(async () => {
@@ -48796,12 +48830,12 @@ function EmbedFrame({
48796
48830
  }
48797
48831
  function useEmbedHandshake(args) {
48798
48832
  const client = useRecordsClient97();
48799
- const [binding, setBinding] = useState132(null);
48800
- const [error, setError] = useState132(null);
48801
- const [loading, setLoading] = useState132(true);
48833
+ const [binding, setBinding] = useState133(null);
48834
+ const [error, setError] = useState133(null);
48835
+ const [loading, setLoading] = useState133(true);
48802
48836
  const origin = args.origin ?? (typeof location === "undefined" ? "" : location.origin);
48803
48837
  const { secret, requiredMode } = args;
48804
- useEffect115(() => {
48838
+ useEffect116(() => {
48805
48839
  let cancelled = false;
48806
48840
  setLoading(true);
48807
48841
  setError(null);
@@ -48824,7 +48858,7 @@ function useEmbedHandshake(args) {
48824
48858
 
48825
48859
  // src/TablePage.tsx
48826
48860
  import { copyText as copyText15 } from "@ai-matrx/kit/clipboard";
48827
- import { useCallback as useCallback69, useEffect as useEffect118, useMemo as useMemo78, useRef as useRef62, useState as useState140 } from "react";
48861
+ import { useCallback as useCallback69, useEffect as useEffect119, useMemo as useMemo78, useRef as useRef62, useState as useState141 } from "react";
48828
48862
  import { archivedByLine as archivedByLine2 } from "@ai-matrx/records";
48829
48863
  import { tableShapeChanged as tableShapeChanged14, useFields as useFields37, useRecordsClient as useRecordsClient99, useSeededAnswer, useTable as useTable37, useTableArchive as useTableArchive2 } from "@ai-matrx/records/react";
48830
48864
  import {
@@ -48867,7 +48901,7 @@ function subscribeCalendarAction(args) {
48867
48901
 
48868
48902
  // src/CalendarSubscribe.tsx
48869
48903
  import { copyText as copyText12 } from "@ai-matrx/kit/clipboard";
48870
- import { useState as useState133 } from "react";
48904
+ import { useState as useState134 } from "react";
48871
48905
 
48872
48906
  // src/asRefusal.ts
48873
48907
  function asRefusal3(e, fallback) {
@@ -48880,7 +48914,7 @@ import { Button as Button105, Dialog as Dialog15, DialogContent as DialogContent
48880
48914
  import { jsx as jsx159, jsxs as jsxs148 } from "react/jsx-runtime";
48881
48915
  function CalendarLinkOnce({ url }) {
48882
48916
  const notify = useRecordsUi().notify;
48883
- const [copied, setCopied] = useState133(false);
48917
+ const [copied, setCopied] = useState134(false);
48884
48918
  const copy = async () => {
48885
48919
  if (await copyText12(url)) {
48886
48920
  setCopied(true);
@@ -48918,9 +48952,9 @@ function CalendarSubscribeDialog({
48918
48952
  open,
48919
48953
  onOpenChange
48920
48954
  }) {
48921
- const [url, setUrl] = useState133(null);
48922
- const [busy, setBusy] = useState133(false);
48923
- const [error, setError] = useState133(null);
48955
+ const [url, setUrl] = useState134(null);
48956
+ const [busy, setBusy] = useState134(false);
48957
+ const [error, setError] = useState134(null);
48924
48958
  const make = async () => {
48925
48959
  setBusy(true);
48926
48960
  setError(null);
@@ -49042,13 +49076,13 @@ async function copyViewMarkdown(args) {
49042
49076
  }
49043
49077
 
49044
49078
  // src/RecordPanel.tsx
49045
- import { Fragment as Fragment65, useState as useState134 } from "react";
49079
+ import { Fragment as Fragment65, useState as useState135 } from "react";
49046
49080
  import { Button as Button106, Separator as Separator13 } from "@ai-matrx/design-system";
49047
49081
  import { useFields as useFields35, useRecord as useRecord4 } from "@ai-matrx/records/react";
49048
49082
  import { Fragment as Fragment66, jsx as jsx160, jsxs as jsxs149 } from "react/jsx-runtime";
49049
49083
  function RecordPanel({ tableId, recordId, onClose, onAskAboutField, onPage = false }) {
49050
49084
  const host = useRecordsUi();
49051
- const [asking, setAsking] = useState134(null);
49085
+ const [asking, setAsking] = useState135(null);
49052
49086
  return /* @__PURE__ */ jsxs149("div", { className: "space-y-3", "data-record-panel": recordId, children: [
49053
49087
  /* @__PURE__ */ jsx160(Peek, { tableId, recordId, onPage, ...onClose ? { onClose } : {} }),
49054
49088
  onPage ? /* @__PURE__ */ jsxs149(Fragment66, { children: [
@@ -49126,7 +49160,7 @@ function LinkedLists({ tableId, recordId }) {
49126
49160
  }
49127
49161
  function RecordAsk({ tableId, recordId }) {
49128
49162
  const host = useRecordsUi();
49129
- const [open, setOpen] = useState134(false);
49163
+ const [open, setOpen] = useState135(false);
49130
49164
  if (!host.chat) return null;
49131
49165
  return /* @__PURE__ */ jsxs149("section", { className: "flex min-w-0 flex-col gap-1.5", "data-record-ask": open ? "open" : "", children: [
49132
49166
  /* @__PURE__ */ jsx160(Separator13, {}),
@@ -49135,7 +49169,7 @@ function RecordAsk({ tableId, recordId }) {
49135
49169
  }
49136
49170
 
49137
49171
  // src/breakDown.tsx
49138
- import { useMemo as useMemo75, useState as useState135 } from "react";
49172
+ import { useMemo as useMemo75, useState as useState136 } from "react";
49139
49173
  import {
49140
49174
  Button as Button107,
49141
49175
  Dialog as Dialog16,
@@ -49175,7 +49209,7 @@ function BreakDownDialog({
49175
49209
  const source = useMemo75(() => ({ kind: "table", id: tableId }), [tableId]);
49176
49210
  const { def } = useDrillDefinition(open ? source : null);
49177
49211
  const dimensions = useMemo75(() => drillDimensionsOf(def, NO_LABELS), [def]);
49178
- const [picked, setPicked] = useState135(null);
49212
+ const [picked, setPicked] = useState136(null);
49179
49213
  const key = picked ?? held?.field ?? dimensions[0]?.key ?? "";
49180
49214
  return /* @__PURE__ */ jsx161(Dialog16, { open, onOpenChange, children: /* @__PURE__ */ jsxs150(DialogContent16, { "data-break-down": "", className: "max-w-sm", children: [
49181
49215
  /* @__PURE__ */ jsx161(DialogHeader16, { children: /* @__PURE__ */ jsx161(DialogTitle16, { children: "Break down by" }) }),
@@ -49202,7 +49236,7 @@ function BreakDownDialog({
49202
49236
 
49203
49237
  // src/TableReference.tsx
49204
49238
  import { copyText as copyText14 } from "@ai-matrx/kit/clipboard";
49205
- import { useCallback as useCallback68, useMemo as useMemo76, useState as useState136 } from "react";
49239
+ import { useCallback as useCallback68, useMemo as useMemo76, useState as useState137 } from "react";
49206
49240
  import { useContentTransferCapabilities as useContentTransferCapabilities2 } from "@ai-matrx/alchemy/react/workspace";
49207
49241
  import { Button as Button108, Dialog as Dialog17, DialogContent as DialogContent17, DialogHeader as DialogHeader17, DialogTitle as DialogTitle17 } from "@ai-matrx/design-system";
49208
49242
  import { jsx as jsx162, jsxs as jsxs151 } from "react/jsx-runtime";
@@ -49230,7 +49264,7 @@ function TableReferenceDialog({
49230
49264
  }) {
49231
49265
  const port = useContentTransferCapabilities2().reference;
49232
49266
  const notify = useRecordsUi().notify;
49233
- const [copied, setCopied] = useState136(null);
49267
+ const [copied, setCopied] = useState137(null);
49234
49268
  const choices = useMemo76(
49235
49269
  () => tableReferenceChoices(table.id, tableName(table)).filter((c) => port?.supports(c.reference)),
49236
49270
  [table, port]
@@ -49259,7 +49293,7 @@ function TableReferenceDialog({
49259
49293
 
49260
49294
  // src/TableDuplicate.tsx
49261
49295
  import { formatCount as formatCount7 } from "@ai-matrx/kit/format";
49262
- import { useState as useState137 } from "react";
49296
+ import { useState as useState138 } from "react";
49263
49297
  import { tableShapeChanged as tableShapeChanged13, useRecordsClient as useRecordsClient98 } from "@ai-matrx/records/react";
49264
49298
  import { Button as Button109, Dialog as Dialog18, DialogContent as DialogContent18, DialogFooter as DialogFooter11, DialogHeader as DialogHeader18, DialogTitle as DialogTitle18, ErrorBox as ErrorBox8, Input as Input10, Switch as Switch5 } from "@ai-matrx/design-system";
49265
49299
  import { Fragment as Fragment67, jsx as jsx163, jsxs as jsxs152 } from "react/jsx-runtime";
@@ -49274,9 +49308,9 @@ function duplicateProgressWords(p) {
49274
49308
  function TableDuplicateDialog({ tableId, name, open, onOpenChange, onDuplicated }) {
49275
49309
  const client = useRecordsClient98();
49276
49310
  const host = useRecordsUi();
49277
- const [typed2, setTyped] = useState137(() => copyNameFor(name));
49278
- const [withRecords, setWithRecords] = useState137(true);
49279
- const [phase, setPhase] = useState137({ kind: "asking" });
49311
+ const [typed2, setTyped] = useState138(() => copyNameFor(name));
49312
+ const [withRecords, setWithRecords] = useState138(true);
49313
+ const [phase, setPhase] = useState138({ kind: "asking" });
49280
49314
  const problem = tableNameProblem(typed2);
49281
49315
  const copying = phase.kind === "copying";
49282
49316
  const close = (next) => {
@@ -49361,7 +49395,7 @@ function TableDuplicateDialog({ tableId, name, open, onOpenChange, onDuplicated
49361
49395
  }
49362
49396
 
49363
49397
  // src/ViewFilter.tsx
49364
- import { useEffect as useEffect116, useMemo as useMemo77, useState as useState138 } from "react";
49398
+ import { useEffect as useEffect117, useMemo as useMemo77, useState as useState139 } from "react";
49365
49399
  import { Button as Button110, Popover as Popover16, PopoverContent as PopoverContent16, PopoverTrigger as PopoverTrigger16 } from "@ai-matrx/design-system";
49366
49400
  import { useFields as useFields36 } from "@ai-matrx/records/react";
49367
49401
  import { jsx as jsx164, jsxs as jsxs153 } from "react/jsx-runtime";
@@ -49375,11 +49409,11 @@ function conditionCount(expr) {
49375
49409
  }
49376
49410
  function ViewFilter({ tableId, view, onApply, className }) {
49377
49411
  const fields = useFields36(tableId);
49378
- const [open, setOpen] = useState138(false);
49412
+ const [open, setOpen] = useState139(false);
49379
49413
  const saved = view?.where ?? null;
49380
- const [draft, setDraft] = useState138(saved);
49414
+ const [draft, setDraft] = useState139(saved);
49381
49415
  const savedKey = JSON.stringify(saved);
49382
- useEffect116(() => {
49416
+ useEffect117(() => {
49383
49417
  setDraft(saved);
49384
49418
  }, [view?.id, savedKey]);
49385
49419
  const conditionFields = useMemo77(
@@ -49554,7 +49588,7 @@ function phoneTableActions(actions) {
49554
49588
  }
49555
49589
 
49556
49590
  // src/toolbarFit.ts
49557
- import { useEffect as useEffect117, useState as useState139 } from "react";
49591
+ import { useEffect as useEffect118, useState as useState140 } from "react";
49558
49592
  var FOLDED_GUESS = { look: 104, chooser: 96, tools: 120 };
49559
49593
  var SLOT_MIN = 36;
49560
49594
  function toolbarFold(input) {
@@ -49611,8 +49645,8 @@ function rowNeeds(row) {
49611
49645
  return { needs: needs + gap * Math.max(0, pieces.length - 1), gap };
49612
49646
  }
49613
49647
  function useToolbarFit(row) {
49614
- const [fold, setFold] = useState139(0);
49615
- useEffect117(() => {
49648
+ const [fold, setFold] = useState140(0);
49649
+ useEffect118(() => {
49616
49650
  if (!row) return;
49617
49651
  const widths = {
49618
49652
  look: { full: null, folded: null },
@@ -49696,8 +49730,8 @@ function clippedEnds(scrollLeft, clientWidth, scrollWidth) {
49696
49730
  return start && end ? "both" : start ? "start" : end ? "end" : "none";
49697
49731
  }
49698
49732
  function useSlotScroll(slot) {
49699
- const [ends, setEnds] = useState139("none");
49700
- useEffect117(() => {
49733
+ const [ends, setEnds] = useState140("none");
49734
+ useEffect118(() => {
49701
49735
  if (!slot) return;
49702
49736
  let pending = 0;
49703
49737
  const read = () => {
@@ -49807,12 +49841,12 @@ function filterInWords(filter, fields) {
49807
49841
  return `${parts.slice(0, -1).join(", ")} and ${parts[parts.length - 1]}`;
49808
49842
  }
49809
49843
  function cameFromLine(label, groupField, question) {
49810
- const asked2 = (question ?? "").trim();
49811
- if (asked2 === "") {
49844
+ const asked3 = (question ?? "").trim();
49845
+ if (asked3 === "") {
49812
49846
  const grouped = groupField ? " grouped into the same columns the chart used" : "";
49813
49847
  return `You came here from \u201C${label}\u201D. This is every record in this table${grouped} \u2014 that number was counted over all of them.`;
49814
49848
  }
49815
- return `You came here from \u201C${label}\u201D. These are only the records that number counted: ${asked2}. Everything else in this table is being held back \u2014 clear the filter to see all of it.`;
49849
+ return `You came here from \u201C${label}\u201D. These are only the records that number counted: ${asked3}. Everything else in this table is being held back \u2014 clear the filter to see all of it.`;
49816
49850
  }
49817
49851
  var TABLE_IS_ARCHIVED = "This table is archived. Its records are kept exactly as they were, and bringing it back puts it in everyone's list again.";
49818
49852
  function TableNotHere({
@@ -49822,10 +49856,10 @@ function TableNotHere({
49822
49856
  className
49823
49857
  }) {
49824
49858
  const client = useRecordsClient99();
49825
- const [archived, setArchived] = useState140({ phase: "asking" });
49826
- const [restoring, setRestoring] = useState140(false);
49827
- const [refusal3, setRefusal] = useState140(null);
49828
- useEffect118(() => {
49859
+ const [archived, setArchived] = useState141({ phase: "asking" });
49860
+ const [restoring, setRestoring] = useState141(false);
49861
+ const [refusal3, setRefusal] = useState141(null);
49862
+ useEffect119(() => {
49829
49863
  let alive = true;
49830
49864
  void client.tableArchived({ table_id: tableId }).then((answered) => {
49831
49865
  if (!alive) return;
@@ -49946,11 +49980,11 @@ var SHARE_NOT_YOURS_LINE = "The link asked to open this table's sharing, and onl
49946
49980
  function openingView(activeView, activeDashboardId) {
49947
49981
  const named = pageViewFromParam(activeView);
49948
49982
  if (named === null) {
49949
- const asked2 = typeof activeView === "string" ? activeView.trim() : "";
49983
+ const asked3 = typeof activeView === "string" ? activeView.trim() : "";
49950
49984
  return {
49951
49985
  main: activeDashboardId ? "dashboards" : "records",
49952
49986
  layout: null,
49953
- unknown: asked2 === "" ? null : asked2
49987
+ unknown: asked3 === "" ? null : asked3
49954
49988
  };
49955
49989
  }
49956
49990
  if (named === "dashboards") return { main: "dashboards", layout: null, unknown: null };
@@ -50039,14 +50073,14 @@ function TablePage({
50039
50073
  }
50040
50074
  );
50041
50075
  const seededViews = seededOpening && (seedViews ?? [defaultView(tableId)]).every((spec) => seedIsSatisfied(spec, seededOpening.views)) ? seededOpening.views : void 0;
50042
- const [view, setView] = useState140(() => {
50076
+ const [view, setView] = useState141(() => {
50043
50077
  if (!seededViews || seededViews.length === 0) return null;
50044
- const asked2 = savedViewFromParam(activeView);
50045
- return seededViews.find((v) => v.id === asked2) ?? defaultViewOf(seededViews) ?? seededViews[0];
50078
+ const asked3 = savedViewFromParam(activeView);
50079
+ return seededViews.find((v) => v.id === asked3) ?? defaultViewOf(seededViews) ?? seededViews[0];
50046
50080
  });
50047
- const [looks, setLooks] = useState140(() => seededViews ? seededOpening?.looks : void 0);
50081
+ const [looks, setLooks] = useState141(() => seededViews ? seededOpening?.looks : void 0);
50048
50082
  const looksSeededFor = useRef62(seededViews && seededOpening ? tableId : null);
50049
- useEffect118(() => {
50083
+ useEffect119(() => {
50050
50084
  if (looksSeededFor.current === tableId) {
50051
50085
  looksSeededFor.current = null;
50052
50086
  return;
@@ -50063,37 +50097,37 @@ function TablePage({
50063
50097
  }, [client, tableId]);
50064
50098
  const look = view && looks ? looks[view.id] : void 0;
50065
50099
  const shown4 = view ? applyLook(view, look) : null;
50066
- const [viewsEpoch, setViewsEpoch] = useState140(0);
50100
+ const [viewsEpoch, setViewsEpoch] = useState141(0);
50067
50101
  const opening = openingRail(activeRecordId, activeRail);
50068
50102
  const recordsUi = useRecordsUi();
50069
50103
  const savedFromLink = savedViewFromParam(activeView);
50070
50104
  const questionsFromLink = questionsFromParam(activeView);
50071
50105
  const openedByPackage = openingView(savedFromLink || questionsFromLink ? null : activeView, activeDashboardId);
50072
50106
  const opened = questionsFromLink ? { ...openedByPackage, main: "questions" } : openedByPackage;
50073
- const [views, setViews] = useState140(() => seededViews);
50074
- const [pickedViewId, setPickedViewId] = useState140(savedFromLink);
50107
+ const [views, setViews] = useState141(() => seededViews);
50108
+ const [pickedViewId, setPickedViewId] = useState141(savedFromLink);
50075
50109
  const viewSeen = useRef62(null);
50076
- const [viewLinkMissed, setViewLinkMissed] = useState140(false);
50110
+ const [viewLinkMissed, setViewLinkMissed] = useState141(false);
50077
50111
  const railAsked = typeof activeRail === "string" ? activeRail.trim() : "";
50078
50112
  const railUnknown = railAsked !== "" && railFromParam(railAsked) === null ? railAsked : null;
50079
50113
  const shareFromLink = railFromParam(activeRail) === "share";
50080
50114
  const canShare = useCanShare();
50081
50115
  const itemFor = (which) => railFromParam(activeRail) === which ? activeItemId ?? null : null;
50082
- const [asking, setAsking] = useState140(null);
50083
- const [layoutFromLink, setLayoutFromLink] = useState140(opened.layout);
50084
- const [surface, setSurface] = useState140({
50116
+ const [asking, setAsking] = useState141(null);
50117
+ const [layoutFromLink, setLayoutFromLink] = useState141(opened.layout);
50118
+ const [surface, setSurface] = useState141({
50085
50119
  main: opened.main,
50086
50120
  rail: opening.rail
50087
50121
  });
50088
50122
  const { main, rail } = surface;
50089
- const [questionDraft, setQuestionDraft] = useState140(null);
50123
+ const [questionDraft, setQuestionDraft] = useState141(null);
50090
50124
  const setRail = (next) => setSurface((now) => ({ ...now, rail: next }));
50091
- const [importEpoch, setImportEpoch] = useState140(0);
50092
- const [openRecord, setOpenRecord] = useState140(opening.record);
50125
+ const [importEpoch, setImportEpoch] = useState141(0);
50126
+ const [openRecord, setOpenRecord] = useState141(opening.record);
50093
50127
  const phone = useIsMobile2();
50094
- const [shareAsked, setShareAsked] = useState140(0);
50128
+ const [shareAsked, setShareAsked] = useState141(0);
50095
50129
  const { open: renameOpen, setOpen: setRenameOpen, ask: askRename, menuContentProps: renameMenuProps } = useRenameFromMenu();
50096
- const [archiveAsked, setArchiveAsked] = useState140(0);
50130
+ const [archiveAsked, setArchiveAsked] = useState141(0);
50097
50131
  const pageArchive = useTableArchive2(tableId);
50098
50132
  const archiveRunning = useRef62(false);
50099
50133
  const archiveFromMenu = useCallback69(async () => {
@@ -50125,14 +50159,14 @@ function TablePage({
50125
50159
  archiveRunning.current = false;
50126
50160
  }
50127
50161
  }, [pageArchive, client, tableId, table.data, recordsUi.notify]);
50128
- const [moveAsked, setMoveAsked] = useState140(0);
50129
- const [duplicateOpen, setDuplicateOpen] = useState140(false);
50130
- const [referenceOpen, setReferenceOpen] = useState140(false);
50131
- const [subscribeOpen, setSubscribeOpen] = useState140(false);
50132
- const [breakDownOpen, setBreakDownOpen] = useState140(false);
50162
+ const [moveAsked, setMoveAsked] = useState141(0);
50163
+ const [duplicateOpen, setDuplicateOpen] = useState141(false);
50164
+ const [referenceOpen, setReferenceOpen] = useState141(false);
50165
+ const [subscribeOpen, setSubscribeOpen] = useState141(false);
50166
+ const [breakDownOpen, setBreakDownOpen] = useState141(false);
50133
50167
  const canGetReference = useCanGetReference();
50134
- const [toolbarSlot, setToolbarSlot] = useState140(null);
50135
- const [toolbarRow, setToolbarRow] = useState140(null);
50168
+ const [toolbarSlot, setToolbarSlot] = useState141(null);
50169
+ const [toolbarRow, setToolbarRow] = useState141(null);
50136
50170
  const toolbarFold2 = useToolbarFit(toolbarRow);
50137
50171
  const slotClipped = useSlotScroll(toolbarSlot);
50138
50172
  const embedded = pagePresentation2 === "embedded";
@@ -50157,7 +50191,7 @@ function TablePage({
50157
50191
  const skeletonFace = skeletonLayoutFor(
50158
50192
  faceUnknown && !layoutFromLink ? rememberedFace ?? shownLayout : shownLayout
50159
50193
  );
50160
- useEffect118(() => {
50194
+ useEffect119(() => {
50161
50195
  if (embedded || faceUnknown || main !== "records" || opened.layout || !table.data) return;
50162
50196
  rememberLayout(tableId, shownLayout);
50163
50197
  }, [embedded, faceUnknown, main, shownLayout, tableId, table.data !== void 0]);
@@ -50177,7 +50211,7 @@ function TablePage({
50177
50211
  const shownSignature = JSON.stringify(shownReport);
50178
50212
  const reportRef = useRef62(onShownViewChange);
50179
50213
  reportRef.current = onShownViewChange;
50180
- useEffect118(() => {
50214
+ useEffect119(() => {
50181
50215
  reportRef.current?.(JSON.parse(shownSignature));
50182
50216
  }, [shownSignature]);
50183
50217
  const pickLayout = (next) => {
@@ -50186,25 +50220,25 @@ function TablePage({
50186
50220
  onViewChanged?.(addressForView(view, next));
50187
50221
  void patchView({ layout: next });
50188
50222
  };
50189
- useEffect118(() => {
50223
+ useEffect119(() => {
50190
50224
  if (!activeRecordId) return;
50191
50225
  setOpenRecord(activeRecordId);
50192
50226
  setSurface((now) => ({ ...now, rail: "record" }));
50193
50227
  }, [activeRecordId]);
50194
- useEffect118(() => {
50228
+ useEffect119(() => {
50195
50229
  if (activeRecordId) return;
50196
50230
  const named = railFromParam(activeRail);
50197
50231
  if (named === null || named === "share") return;
50198
50232
  setSurface((now) => ({ ...now, rail: named }));
50199
50233
  }, [activeRail, activeRecordId]);
50200
- useEffect118(() => {
50234
+ useEffect119(() => {
50201
50235
  const named = pageViewFromParam(activeView);
50202
50236
  if (named === null) return;
50203
50237
  const isLayout = named !== "dashboards" && named !== "archived";
50204
50238
  setLayoutFromLink(isLayout ? named : null);
50205
50239
  setSurface((now) => ({ ...now, main: isLayout ? "records" : named }));
50206
50240
  }, [activeView]);
50207
- const [viewSaveRefused, setViewSaveRefused] = useState140(null);
50241
+ const [viewSaveRefused, setViewSaveRefused] = useState141(null);
50208
50242
  const viewLocked = view?.presentation?.locked === true;
50209
50243
  const unlockView = useCallback69(async () => {
50210
50244
  const current = view;
@@ -50223,14 +50257,14 @@ function TablePage({
50223
50257
  recordsUi.notify?.success(VIEW_LOCKED_REASON, { label: "Unlock", run: () => void unlockView() });
50224
50258
  }, [recordsUi.notify, unlockView]);
50225
50259
  const patchView = useCallback69(
50226
- async (asked2) => {
50260
+ async (asked3) => {
50227
50261
  const current = view;
50228
50262
  if (!current) return;
50229
50263
  if (viewLocked) {
50230
50264
  sayLocked();
50231
50265
  return;
50232
50266
  }
50233
- const part = lookPart(asked2);
50267
+ const part = lookPart(asked3);
50234
50268
  if (Object.keys(part).length === 0) return;
50235
50269
  const before = looks?.[current.id];
50236
50270
  const next = { ...before ?? {}, ...part };
@@ -50238,13 +50272,13 @@ function TablePage({
50238
50272
  setViewSaveRefused(null);
50239
50273
  const kept = await keepLook(client, tableId, current.id, next);
50240
50274
  if (kept.ok) return;
50241
- setViewSaveRefused({ error: kept.error, patch: asked2, lookBefore: before });
50275
+ setViewSaveRefused({ error: kept.error, patch: asked3, lookBefore: before });
50242
50276
  },
50243
50277
  [client, tableId, view, looks, viewLocked, sayLocked]
50244
50278
  );
50245
50279
  const arrival = useRef62(viewAddress ?? null);
50246
- const [gridQuery, setGridQuery] = useState140(null);
50247
- const [addressResetEpoch, setAddressResetEpoch] = useState140(0);
50280
+ const [gridQuery, setGridQuery] = useState141(null);
50281
+ const [addressResetEpoch, setAddressResetEpoch] = useState141(0);
50248
50282
  const reportGrid = useCallback69((q) => {
50249
50283
  const next = { sort: q.sort, filters: q.filters, search: q.search, page: q.page };
50250
50284
  setGridQuery((held) => sameViewAddress(held, next) ? held : next);
@@ -50254,7 +50288,7 @@ function TablePage({
50254
50288
  [reportGrid, addressResetEpoch]
50255
50289
  );
50256
50290
  const hiddenApplied = useRef62(false);
50257
- useEffect118(() => {
50291
+ useEffect119(() => {
50258
50292
  const hidden = arrival.current?.hidden;
50259
50293
  if (hiddenApplied.current || !view || !looks || !hidden || hidden.length === 0) return;
50260
50294
  hiddenApplied.current = true;
@@ -50277,7 +50311,7 @@ function TablePage({
50277
50311
  const addressReportRef = useRef62(onViewAddressChange);
50278
50312
  addressReportRef.current = onViewAddressChange;
50279
50313
  const addressSent = useRef62(null);
50280
- useEffect118(() => {
50314
+ useEffect119(() => {
50281
50315
  if (!addressReady) return;
50282
50316
  if (addressSent.current === null && addressSignature === JSON.stringify(viewAddressToParams(arrival.current))) {
50283
50317
  addressSent.current = addressSignature;
@@ -50289,9 +50323,9 @@ function TablePage({
50289
50323
  }, [addressReady, addressSignature]);
50290
50324
  const queryShowing = !isViewAddressEmpty({ ...gridQuery ?? {}, hidden: [] });
50291
50325
  const lookShowing = Boolean(view && looks && (lookDiffers(view, looks[view.id]) || queryShowing));
50292
- const [lookRefused, setLookRefused] = useState140(null);
50293
- const [namingLook, setNamingLook] = useState140(false);
50294
- const [lookName, setLookName] = useState140("");
50326
+ const [lookRefused, setLookRefused] = useState141(null);
50327
+ const [namingLook, setNamingLook] = useState141(false);
50328
+ const [lookName, setLookName] = useState141("");
50295
50329
  const resetLook = async () => {
50296
50330
  const current = view;
50297
50331
  setAddressResetEpoch((n) => n + 1);
@@ -50354,7 +50388,7 @@ function TablePage({
50354
50388
  setPickedViewId(written.data);
50355
50389
  setViewsEpoch((n) => n + 1);
50356
50390
  };
50357
- const [designateRefused, setDesignateRefused] = useState140(null);
50391
+ const [designateRefused, setDesignateRefused] = useState141(null);
50358
50392
  const opensAs = view?.isDefault ? view.layout : null;
50359
50393
  const canDesignate = Boolean(
50360
50394
  rights.organise && view && layoutShowing && layoutShowing !== opensAs && storeKeepsLayout2(layoutShowing)
@@ -50568,16 +50602,16 @@ function TablePage({
50568
50602
  actionsRef.current = actions;
50569
50603
  const onActionsRef = useRef62(onActions);
50570
50604
  onActionsRef.current = onActions;
50571
- useEffect118(() => {
50605
+ useEffect119(() => {
50572
50606
  onActionsRef.current?.(actionsRef.current);
50573
50607
  });
50574
- useEffect118(() => {
50608
+ useEffect119(() => {
50575
50609
  const onKey = (event) => {
50576
- const asked2 = objectActionForKey(actionsRef.current, event);
50577
- if (!asked2) return;
50610
+ const asked3 = objectActionForKey(actionsRef.current, event);
50611
+ if (!asked3) return;
50578
50612
  event.preventDefault();
50579
- if (asked2.disabledReason !== void 0) recordsUi.notify?.error(`${asked2.label.replace(/…$/, "")}: ${asked2.disabledReason}`);
50580
- else void asked2.run();
50613
+ if (asked3.disabledReason !== void 0) recordsUi.notify?.error(`${asked3.label.replace(/…$/, "")}: ${asked3.disabledReason}`);
50614
+ else void asked3.run();
50581
50615
  };
50582
50616
  window.addEventListener("keydown", onKey);
50583
50617
  return () => window.removeEventListener("keydown", onKey);
@@ -51110,8 +51144,8 @@ var PUBLIC_READ_ONLY = "Public \xB7 read only";
51110
51144
  function usePublicReadOnly(client, organizationId, tableId, table, rights) {
51111
51145
  const readOnly = rights.known && rights.read && !rights.write;
51112
51146
  const marked = table?.published_to_web;
51113
- const [isPublic, setIsPublic] = useState140(false);
51114
- useEffect118(() => {
51147
+ const [isPublic, setIsPublic] = useState141(false);
51148
+ useEffect119(() => {
51115
51149
  if (!readOnly || !table) {
51116
51150
  setIsPublic(false);
51117
51151
  return;
@@ -51137,7 +51171,7 @@ function usePublicReadOnly(client, organizationId, tableId, table, rights) {
51137
51171
  import { formatCount as formatCount8 } from "@ai-matrx/kit/format";
51138
51172
  import { TapTargetSearchGroup as TapTargetSearchGroup2, TooltipProvider } from "@ai-matrx/design-system";
51139
51173
  import { MatrxTableCardShowMore as MatrxTableCardShowMore3 } from "@ai-matrx/design-system/data-table";
51140
- import { useEffect as useEffect119, useMemo as useMemo79, useRef as useRef63, useState as useState141 } from "react";
51174
+ import { useEffect as useEffect120, useMemo as useMemo79, useRef as useRef63, useState as useState142 } from "react";
51141
51175
  import { Button as Button112, ErrorBox as ErrorBox9, Input as Input12, cn as cn98 } from "@ai-matrx/design-system";
51142
51176
  import { SEED_FRESH_MS, useRecordsClient as useRecordsClient100, useSeededAnswerAt } from "@ai-matrx/records/react";
51143
51177
  import { Fragment as Fragment69, jsx as jsx167, jsxs as jsxs156 } from "react/jsx-runtime";
@@ -51154,8 +51188,8 @@ function EntityBoard({ entity, groupBy, cardFields, onOpenRecord, className }) {
51154
51188
  () => cardFields ? entity.columns.filter((c) => cardFields.includes(c.key)) : entity.columns.filter((c) => c !== title && c !== column && c.type !== "choice").slice(0, 2),
51155
51189
  [cardFields, entity.columns, title, column]
51156
51190
  );
51157
- const [refused, setRefused] = useState141(null);
51158
- const [over, setOver] = useState141(null);
51191
+ const [refused, setRefused] = useState142(null);
51192
+ const [over, setOver] = useState142(null);
51159
51193
  if (entity.error) return /* @__PURE__ */ jsx167("p", { className: "px-1 py-3 text-xs text-muted-foreground", children: `This board could not be read: ${entity.error}` });
51160
51194
  if (!entity.loading && !column) {
51161
51195
  return /* @__PURE__ */ jsx167("p", { className: "px-1 py-3 text-xs text-muted-foreground", children: `${entity.label ?? "This table"} has no choice column to make a board of.` });
@@ -51238,16 +51272,16 @@ function blockOfAnswer(answer, base2, by) {
51238
51272
  function EntityChartBlock({ source, kind, by, measure, title, where, organization, centerValue, variant, className }) {
51239
51273
  const client = useRecordsClient100();
51240
51274
  const m = measure ?? { op: "count" };
51241
- const ask = JSON.stringify([source.token, by ?? null, m, where ?? null, organization ?? null]);
51275
+ const ask2 = JSON.stringify([source.token, by ?? null, m, where ?? null, organization ?? null]);
51242
51276
  const question = entityChartQuestion({ by, measure, where, organization });
51243
51277
  const measures = [m.op === "count" ? { op: "count" } : { op: m.op, key: m.of }];
51244
51278
  const base2 = { title: title ?? "", kind, measures, group_by: by ? [by] : [] };
51245
- const seeded = useSeededAnswerAt(`entity-chart:${ask}`, (c) => c.drillAsk({ source, question }));
51246
- const [block, setBlock] = useState141(() => seeded ? blockOfAnswer({ ok: true, data: seeded.data }, base2, by) : null);
51247
- const seededFor = useRef63(seeded ? { ask: `${ask}|${kind}|${title ?? ""}`, at: seeded.at } : null);
51248
- useEffect119(() => {
51279
+ const seeded = useSeededAnswerAt(`entity-chart:${ask2}`, (c) => c.drillAsk({ source, question }));
51280
+ const [block, setBlock] = useState142(() => seeded ? blockOfAnswer({ ok: true, data: seeded.data }, base2, by) : null);
51281
+ const seededFor = useRef63(seeded ? { ask: `${ask2}|${kind}|${title ?? ""}`, at: seeded.at } : null);
51282
+ useEffect120(() => {
51249
51283
  const held = seededFor.current;
51250
- if (held && held.ask === `${ask}|${kind}|${title ?? ""}` && Date.now() - held.at < SEED_FRESH_MS) return;
51284
+ if (held && held.ask === `${ask2}|${kind}|${title ?? ""}` && Date.now() - held.at < SEED_FRESH_MS) return;
51251
51285
  seededFor.current = null;
51252
51286
  let cancelled = false;
51253
51287
  void client.drillAsk({ source, question }).then((answer) => {
@@ -51257,7 +51291,7 @@ function EntityChartBlock({ source, kind, by, measure, title, where, organizatio
51257
51291
  return () => {
51258
51292
  cancelled = true;
51259
51293
  };
51260
- }, [client, ask, kind, title]);
51294
+ }, [client, ask2, kind, title]);
51261
51295
  if (!block) {
51262
51296
  return /* @__PURE__ */ jsx167(RecordsSkeleton, { layout: "chart", embedded: variant === "bare", ...className ? { className } : {} });
51263
51297
  }
@@ -51290,20 +51324,20 @@ function EntityTablePageBody({
51290
51324
  actions,
51291
51325
  className
51292
51326
  }) {
51293
- const [typed2, setTyped] = useState141("");
51327
+ const [typed2, setTyped] = useState142("");
51294
51328
  const term = searchOverride ?? typed2;
51295
51329
  const entity = useEntityTable(source.token, { pageSize, search: term });
51296
- const [layout, setLayout] = useState141(opened);
51297
- useEffect119(() => setLayout(opened), [opened]);
51330
+ const [layout, setLayout] = useState142(opened);
51331
+ useEffect120(() => setLayout(opened), [opened]);
51298
51332
  const choose = (next) => {
51299
51333
  setLayout(next);
51300
51334
  onLayoutChange?.(next);
51301
51335
  };
51302
51336
  const boardable = entityChoiceColumns(entity.columns).length > 0;
51303
51337
  const nameColumn = entityNameColumn(entity.columns);
51304
- const [naming, setNaming] = useState141(null);
51305
- const [adding, setAdding] = useState141(false);
51306
- const [addRefused, setAddRefused] = useState141(null);
51338
+ const [naming, setNaming] = useState142(null);
51339
+ const [adding, setAdding] = useState142(false);
51340
+ const [addRefused, setAddRefused] = useState142(null);
51307
51341
  const add = async () => {
51308
51342
  const name = (naming ?? "").trim();
51309
51343
  if (!name || !nameColumn || adding) return;
@@ -51315,7 +51349,7 @@ function EntityTablePageBody({
51315
51349
  setNaming(null);
51316
51350
  onOpenRecord?.(made.id);
51317
51351
  };
51318
- const [question, setQuestion] = useState141(() => questionFromGrouping(void 0));
51352
+ const [question, setQuestion] = useState142(() => questionFromGrouping(void 0));
51319
51353
  const { config: drill } = useDrill({
51320
51354
  source,
51321
51355
  question,
@@ -51420,7 +51454,7 @@ function TablePage2(props) {
51420
51454
  }
51421
51455
 
51422
51456
  // src/DataBindingPicker.tsx
51423
- import { useEffect as useEffect120, useMemo as useMemo80 } from "react";
51457
+ import { useEffect as useEffect121, useMemo as useMemo80 } from "react";
51424
51458
  import { isEntityReferenceConfig } from "@ai-matrx/records";
51425
51459
  import { useFields as useFields38, useTable as useTable38 } from "@ai-matrx/records/react";
51426
51460
  import { BasicInput as BasicInput36, Button as Button113, CreatablePicker as CreatablePicker3, cn as cn99 } from "@ai-matrx/design-system";
@@ -51516,7 +51550,7 @@ function BindingDetails({
51516
51550
  const fields = useFields38(tableId);
51517
51551
  const fieldList = useMemo80(() => fields.data ?? [], [fields.data]);
51518
51552
  const shape = binding.semantic_type;
51519
- useEffect120(() => {
51553
+ useEffect121(() => {
51520
51554
  if (disabled || shape === "value" || binding.transform || fields.loading || fieldList.length === 0) return;
51521
51555
  onChange({
51522
51556
  ...binding,
@@ -51738,7 +51772,7 @@ function RecordNameWords({ tableId, recordId }) {
51738
51772
  }
51739
51773
 
51740
51774
  // src/HeldChangeDecision.tsx
51741
- import { useEffect as useEffect121, useState as useState142 } from "react";
51775
+ import { useEffect as useEffect122, useState as useState143 } from "react";
51742
51776
  import { RecordsProvider as RecordsProvider3, useRecordsClient as useRecordsClient101 } from "@ai-matrx/records/react";
51743
51777
  import { Button as Button114 } from "@ai-matrx/design-system";
51744
51778
  import { jsx as jsx171, jsxs as jsxs159 } from "react/jsx-runtime";
@@ -51751,10 +51785,10 @@ function Decision({
51751
51785
  approveLabel
51752
51786
  }) {
51753
51787
  const client = useRecordsClient101();
51754
- const [may, setMay] = useState142(null);
51755
- const [busy, setBusy] = useState142(null);
51756
- const [error, setError] = useState142(null);
51757
- useEffect121(() => {
51788
+ const [may, setMay] = useState143(null);
51789
+ const [busy, setBusy] = useState143(null);
51790
+ const [error, setError] = useState143(null);
51791
+ useEffect122(() => {
51758
51792
  let live = true;
51759
51793
  void client.workApprovalMayDecide({ approval_id: approvalId }).then((res) => {
51760
51794
  if (!live) return;
@@ -51787,14 +51821,14 @@ function Decision({
51787
51821
  }
51788
51822
 
51789
51823
  // src/CalendarLinks.tsx
51790
- import { useCallback as useCallback70, useEffect as useEffect122, useState as useState143 } from "react";
51824
+ import { useCallback as useCallback70, useEffect as useEffect123, useState as useState144 } from "react";
51791
51825
  import { Button as Button115 } from "@ai-matrx/design-system";
51792
51826
  import { jsx as jsx172, jsxs as jsxs160 } from "react/jsx-runtime";
51793
51827
  var day = (iso) => iso ? new Date(iso).toLocaleDateString(void 0, { year: "numeric", month: "short", day: "numeric" }) : null;
51794
51828
  function CalendarLinks({ port }) {
51795
- const [rows, setRows] = useState143(null);
51796
- const [error, setError] = useState143(null);
51797
- const [fresh, setFresh] = useState143(null);
51829
+ const [rows, setRows] = useState144(null);
51830
+ const [error, setError] = useState144(null);
51831
+ const [fresh, setFresh] = useState144(null);
51798
51832
  const load = useCallback70(async () => {
51799
51833
  try {
51800
51834
  setRows(await port.list());
@@ -51803,7 +51837,7 @@ function CalendarLinks({ port }) {
51803
51837
  setError(asRefusal3(e, "The links could not be read"));
51804
51838
  }
51805
51839
  }, [port]);
51806
- useEffect122(() => {
51840
+ useEffect123(() => {
51807
51841
  void load();
51808
51842
  }, [load]);
51809
51843
  const act = async (run) => {
@@ -51868,7 +51902,7 @@ function CalendarLinks({ port }) {
51868
51902
  }
51869
51903
 
51870
51904
  // src/TemplatePreview.tsx
51871
- import { useEffect as useEffect123, useMemo as useMemo81, useState as useState144 } from "react";
51905
+ import { useEffect as useEffect124, useMemo as useMemo81, useState as useState145 } from "react";
51872
51906
  import { templatePreview } from "@ai-matrx/records/memory";
51873
51907
  import { useRecordsClient as useRecordsClient102 } from "@ai-matrx/records/react";
51874
51908
  import { formFromSummary as formFromSummary3 } from "@ai-matrx/records/forms";
@@ -51880,7 +51914,7 @@ function TemplatePreview({ spec, today, initialTable, host, aside, booking, clas
51880
51914
  const preview = useTemplatePreview(spec, today);
51881
51915
  const bound2 = useMemo81(() => ({ ...host, sayLevelNeeded: false }), [host]);
51882
51916
  const first = preview.tables.find((t) => t.token === initialTable) ?? preview.tables[0];
51883
- const [active, setActive] = useState144(first?.id ?? null);
51917
+ const [active, setActive] = useState145(first?.id ?? null);
51884
51918
  const table = preview.tables.find((t) => t.id === active) ?? first;
51885
51919
  if (!table) return null;
51886
51920
  return /* @__PURE__ */ jsxs161("div", { className: ["flex min-w-0 flex-col gap-3", className].filter(Boolean).join(" "), "data-template-preview": preview.tables.length, children: [
@@ -51918,9 +51952,9 @@ function TemplatePreview({ spec, today, initialTable, host, aside, booking, clas
51918
51952
  }
51919
51953
  function PreviewForms({ preview, booking }) {
51920
51954
  const client = useRecordsClient102();
51921
- const [forms, setForms] = useState144(null);
51922
- const [pages, setPages] = useState144([]);
51923
- useEffect123(() => {
51955
+ const [forms, setForms] = useState145(null);
51956
+ const [pages, setPages] = useState145([]);
51957
+ useEffect124(() => {
51924
51958
  let gone = false;
51925
51959
  void client.forms().then((answered) => {
51926
51960
  if (!gone) setForms(answered.ok ? answered.data.map(formFromSummary3) : []);