@ai-matrx/records-ui 0.58.0 → 0.60.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -51,6 +51,7 @@ __export(src_exports, {
51
51
  ChecklistTemplateEditor: () => ChecklistTemplateEditor,
52
52
  ChecklistsPanel: () => ChecklistsPanel,
53
53
  CommentThread: () => CommentThread,
54
+ ConditionGroup: () => ConditionGroup,
54
55
  ConditionRow: () => ConditionRow,
55
56
  CustomFieldsSection: () => CustomFieldsSection,
56
57
  DEFAULT_FIELDS: () => DEFAULT_FIELDS,
@@ -156,6 +157,7 @@ __export(src_exports, {
156
157
  actorBadge: () => actorBadge,
157
158
  actorWords: () => actorWords,
158
159
  addFields: () => addFields,
160
+ askableFields: () => askableFields,
159
161
  blockFromSpec: () => blockFromSpec,
160
162
  bodyForReading: () => bodyForReading,
161
163
  bodyFromKeys: () => bodyFromKeys,
@@ -164,6 +166,7 @@ __export(src_exports, {
164
166
  colorFromTheValue: () => colorFromTheValue,
165
167
  columnForField: () => columnForField,
166
168
  conditionInWords: () => conditionInWords,
169
+ conditionIsDrawable: () => conditionIsDrawable,
167
170
  conditionIsSimple: () => conditionIsSimple,
168
171
  conditionValue: () => conditionValue,
169
172
  controlFor: () => controlFor,
@@ -208,6 +211,7 @@ __export(src_exports, {
208
211
  presentationDocument: () => presentationDocument,
209
212
  presentationIsEmpty: () => presentationIsEmpty,
210
213
  previewLine: () => previewLine,
214
+ publiclyAnswerable: () => publiclyAnswerable,
211
215
  recordName: () => recordName,
212
216
  recordsDataSource: () => recordsDataSource,
213
217
  refusalForAPerson: () => refusalForAPerson,
@@ -244,7 +248,8 @@ __export(src_exports, {
244
248
  whatIsMissing: () => whatIsMissing,
245
249
  whatYouMayDo: () => whatYouMayDo,
246
250
  whatYouMayDoWithTable: () => whatYouMayDoWithTable,
247
- whenWords: () => whenWords
251
+ whenWords: () => whenWords,
252
+ whyNotAskable: () => whyNotAskable
248
253
  });
249
254
  module.exports = __toCommonJS(src_exports);
250
255
 
@@ -510,11 +515,17 @@ function recordName(document2, titleKey, fallback = "Untitled") {
510
515
  );
511
516
  for (const key of keys) {
512
517
  const value = data[key];
513
- if (typeof value === "string" && value.trim() !== "") return value.trim();
518
+ if (typeof value === "string" && value.trim() !== "" && !looksLikeId(value.trim())) {
519
+ return value.trim();
520
+ }
514
521
  if (typeof value === "number") return String(value);
515
522
  }
516
523
  return fallback;
517
524
  }
525
+ var RECORD_ID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
526
+ function looksLikeId(value) {
527
+ return typeof value === "string" && RECORD_ID.test(value.trim());
528
+ }
518
529
  function rowName(row, titleKey, fallback = "Untitled") {
519
530
  return recordName(row?.document, titleKey, fallback);
520
531
  }
@@ -4958,11 +4969,12 @@ function ValueOnTheOtherSide({
4958
4969
  }
4959
4970
 
4960
4971
  // src/StageRules.tsx
4961
- var import_react29 = require("react");
4962
- var import_react30 = require("@ai-matrx/records/react");
4972
+ var import_react30 = require("react");
4973
+ var import_react31 = require("@ai-matrx/records/react");
4963
4974
  var import_design_system15 = require("@ai-matrx/design-system");
4964
4975
 
4965
4976
  // src/Condition.tsx
4977
+ var import_react29 = require("react");
4966
4978
  var import_design_system14 = require("@ai-matrx/design-system");
4967
4979
  var import_jsx_runtime17 = require("react/jsx-runtime");
4968
4980
  var CONDITION_OPS = [
@@ -5092,6 +5104,155 @@ function ConditionRow({ lead, expr, fields, onChange, emptyLabel = "always", cla
5092
5104
  ] }) : null
5093
5105
  ] });
5094
5106
  }
5107
+ var JOINERS = [
5108
+ { op: "and", label: "All of these are true" },
5109
+ { op: "or", label: "Any of these is true" }
5110
+ ];
5111
+ function asNode(expr) {
5112
+ return expr && typeof expr === "object" && !Array.isArray(expr) ? expr : null;
5113
+ }
5114
+ function groupOf(expr) {
5115
+ const node = asNode(expr);
5116
+ if (!node) return null;
5117
+ const op = node["op"];
5118
+ if (op !== "and" && op !== "or") return null;
5119
+ const args = Array.isArray(node["args"]) ? node["args"] : [];
5120
+ return { op, args };
5121
+ }
5122
+ function conditionIsDrawable(expr, depth = 1) {
5123
+ if (expr === null || expr === void 0) return true;
5124
+ const group = groupOf(expr);
5125
+ if (!group) return conditionIsSimple(expr);
5126
+ if (group.args.length === 0) return true;
5127
+ return group.args.every((arg) => {
5128
+ const node = asNode(arg);
5129
+ if (node === null) return false;
5130
+ return conditionIsSimple(node) || depth > 0 && conditionIsDrawable(node, depth - 1);
5131
+ });
5132
+ }
5133
+ function clausesOf(expr) {
5134
+ const group = groupOf(expr);
5135
+ if (group) return group;
5136
+ return { op: "and", args: expr === null || expr === void 0 ? [] : [expr] };
5137
+ }
5138
+ function writeGroup(op, args) {
5139
+ const kept = args.filter((a) => a !== null && a !== void 0);
5140
+ if (kept.length === 0) return null;
5141
+ if (kept.length === 1) return kept[0];
5142
+ return { op, args: kept };
5143
+ }
5144
+ function ConditionGroup({
5145
+ lead,
5146
+ expr,
5147
+ fields,
5148
+ onChange,
5149
+ emptyLabel = "always",
5150
+ allowNesting = true,
5151
+ className
5152
+ }) {
5153
+ const { op, args } = clausesOf(expr);
5154
+ const [drafting, setDrafting] = (0, import_react29.useState)(false);
5155
+ const replaceAt = (index, next) => {
5156
+ const nextArgs = args.slice();
5157
+ if (next === null || next === void 0) nextArgs.splice(index, 1);
5158
+ else nextArgs[index] = next;
5159
+ onChange(writeGroup(op, nextArgs));
5160
+ };
5161
+ const joinWord = (index) => index === 0 ? lead : op === "and" ? "and" : "or";
5162
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: className ?? "flex flex-col gap-1 text-xs", "data-testid": "condition-group", children: [
5163
+ args.length > 1 ? /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "flex items-center gap-1", children: [
5164
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { className: "text-muted-foreground", children: lead }),
5165
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
5166
+ "select",
5167
+ {
5168
+ "aria-label": "How these conditions are joined",
5169
+ className: "h-8 rounded border bg-background px-1 text-xs",
5170
+ value: op,
5171
+ onChange: (e) => onChange(writeGroup(e.target.value, args)),
5172
+ children: JOINERS.map((j) => /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("option", { value: j.op, children: j.label }, j.op))
5173
+ }
5174
+ )
5175
+ ] }) : null,
5176
+ args.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
5177
+ ConditionRow,
5178
+ {
5179
+ lead,
5180
+ emptyLabel,
5181
+ expr: null,
5182
+ fields,
5183
+ onChange: (next) => onChange(next)
5184
+ }
5185
+ ) : args.map((arg, index) => {
5186
+ const nested = groupOf(arg);
5187
+ const key = `clause-${index}`;
5188
+ if (nested && allowNesting) {
5189
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: "ml-4 rounded border border-dashed p-1", "data-testid": "condition-nested-group", children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
5190
+ ConditionGroup,
5191
+ {
5192
+ lead: op === "and" ? "and also, any of:" : "or, all of:",
5193
+ expr: arg,
5194
+ fields,
5195
+ onChange: (next) => replaceAt(index, next),
5196
+ emptyLabel,
5197
+ allowNesting: false
5198
+ }
5199
+ ) }, key);
5200
+ }
5201
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
5202
+ ConditionRow,
5203
+ {
5204
+ lead: args.length > 1 ? joinWord(index) : lead,
5205
+ emptyLabel,
5206
+ expr: arg,
5207
+ fields,
5208
+ onChange: (next) => replaceAt(index, next)
5209
+ },
5210
+ key
5211
+ );
5212
+ }),
5213
+ drafting ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
5214
+ ConditionRow,
5215
+ {
5216
+ lead: op === "and" ? "and" : "or",
5217
+ emptyLabel,
5218
+ expr: null,
5219
+ fields,
5220
+ onChange: (next) => {
5221
+ if (next === null) return;
5222
+ setDrafting(false);
5223
+ onChange(writeGroup(op, [...args, next]));
5224
+ }
5225
+ }
5226
+ ) : null,
5227
+ args.length > 0 && !drafting ? /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "flex items-center gap-1", children: [
5228
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
5229
+ import_design_system14.Button,
5230
+ {
5231
+ size: "sm",
5232
+ variant: "ghost",
5233
+ className: "h-6 px-1 text-xs",
5234
+ "data-testid": "condition-add-clause",
5235
+ onClick: () => setDrafting(true),
5236
+ children: "Add another condition"
5237
+ }
5238
+ ),
5239
+ allowNesting && args.length > 1 && !args.some((a) => groupOf(a) !== null) ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
5240
+ import_design_system14.Button,
5241
+ {
5242
+ size: "sm",
5243
+ variant: "ghost",
5244
+ className: "h-6 px-1 text-xs",
5245
+ "data-testid": "condition-add-group",
5246
+ onClick: () => replaceAt(args.length - 1, {
5247
+ op: op === "and" ? "or" : "and",
5248
+ args: [args[args.length - 1]]
5249
+ }),
5250
+ children: "Group the last one"
5251
+ }
5252
+ ) : null
5253
+ ] }) : null
5254
+ ] });
5255
+ }
5095
5256
 
5096
5257
  // src/StageRules.tsx
5097
5258
  var import_jsx_runtime18 = require("react/jsx-runtime");
@@ -5125,38 +5286,38 @@ function draftOf(rule) {
5125
5286
  };
5126
5287
  }
5127
5288
  function StageRulesSection({ tableId, stage, className }) {
5128
- const client = (0, import_react30.useRecordsClient)();
5129
- const table = (0, import_react30.useTable)(tableId);
5289
+ const client = (0, import_react31.useRecordsClient)();
5290
+ const table = (0, import_react31.useTable)(tableId);
5130
5291
  const rights = useTableRights(table.data);
5131
- const fields = (0, import_react30.useFields)(tableId);
5132
- const [pipeline, setPipeline] = (0, import_react29.useState)(null);
5133
- const [enforcement, setEnforcement] = (0, import_react29.useState)(null);
5134
- const [asked, setAsked] = (0, import_react29.useState)(false);
5135
- const [error, setError] = (0, import_react29.useState)(null);
5136
- const [chosen, setChosen] = (0, import_react29.useState)(stage ?? null);
5137
- const [draft, setDraft] = (0, import_react29.useState)(null);
5138
- const [preview, setPreview] = (0, import_react29.useState)(null);
5139
- const [previewError, setPreviewError] = (0, import_react29.useState)(null);
5140
- const [saving, setSaving] = (0, import_react29.useState)(false);
5141
- const load = (0, import_react29.useCallback)(async () => {
5292
+ const fields = (0, import_react31.useFields)(tableId);
5293
+ const [pipeline, setPipeline] = (0, import_react30.useState)(null);
5294
+ const [enforcement, setEnforcement] = (0, import_react30.useState)(null);
5295
+ const [asked, setAsked] = (0, import_react30.useState)(false);
5296
+ const [error, setError] = (0, import_react30.useState)(null);
5297
+ const [chosen, setChosen] = (0, import_react30.useState)(stage ?? null);
5298
+ const [draft, setDraft] = (0, import_react30.useState)(null);
5299
+ const [preview, setPreview] = (0, import_react30.useState)(null);
5300
+ const [previewError, setPreviewError] = (0, import_react30.useState)(null);
5301
+ const [saving, setSaving] = (0, import_react30.useState)(false);
5302
+ const load = (0, import_react30.useCallback)(async () => {
5142
5303
  const [read, mode] = await Promise.all([client.pipelineRead({ table_id: tableId }), client.stageRuleEnforcement()]);
5143
5304
  if (!read.ok) setError(read.error);
5144
5305
  else setPipeline(read.data);
5145
5306
  if (mode.ok) setEnforcement(mode.data);
5146
5307
  setAsked(true);
5147
5308
  }, [client, tableId]);
5148
- (0, import_react29.useEffect)(() => {
5309
+ (0, import_react30.useEffect)(() => {
5149
5310
  void load();
5150
5311
  }, [load]);
5151
5312
  const stages = pipeline?.stages ?? [];
5152
5313
  const stageKey = chosen ?? stages.find((s) => !s.retired)?.key ?? null;
5153
5314
  const stageLabel = stages.find((s) => s.key === stageKey)?.label ?? stageKey ?? "";
5154
- const gates = (0, import_react29.useMemo)(() => stageKey ? gatesOf(pipeline, stageKey) : [], [pipeline, stageKey]);
5155
- const conditionFields = (0, import_react29.useMemo)(
5315
+ const gates = (0, import_react30.useMemo)(() => stageKey ? gatesOf(pipeline, stageKey) : [], [pipeline, stageKey]);
5316
+ const conditionFields = (0, import_react30.useMemo)(
5156
5317
  () => (fields.data ?? []).map((f) => ({ id: String(f.id), key: f.key, label: fieldName(f) })),
5157
5318
  [fields.data]
5158
5319
  );
5159
- (0, import_react29.useEffect)(() => {
5320
+ (0, import_react30.useEffect)(() => {
5160
5321
  if (!draft || !stageKey || !draft.demands || Object.keys(draft.demands).length === 0) {
5161
5322
  setPreview(null);
5162
5323
  setPreviewError(null);
@@ -5339,15 +5500,15 @@ function Clause({
5339
5500
  fields,
5340
5501
  onChange
5341
5502
  }) {
5342
- const [replacing, setReplacing] = (0, import_react29.useState)(false);
5343
- const drawable = conditionIsSimple(expr) || replacing;
5503
+ const [replacing, setReplacing] = (0, import_react30.useState)(false);
5504
+ const drawable = conditionIsDrawable(expr) || replacing;
5344
5505
  if (drawable) {
5345
5506
  return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
5346
- ConditionRow,
5507
+ ConditionGroup,
5347
5508
  {
5348
5509
  lead,
5349
5510
  emptyLabel,
5350
- expr: replacing && !conditionIsSimple(expr) ? null : expr,
5511
+ expr: replacing && !conditionIsDrawable(expr) ? null : expr,
5351
5512
  fields,
5352
5513
  onChange
5353
5514
  }
@@ -5378,8 +5539,8 @@ function Clause({
5378
5539
  }
5379
5540
 
5380
5541
  // src/TableSettings.tsx
5381
- var import_react31 = require("react");
5382
- var import_react32 = require("@ai-matrx/records/react");
5542
+ var import_react32 = require("react");
5543
+ var import_react33 = require("@ai-matrx/records/react");
5383
5544
  var import_design_system16 = require("@ai-matrx/design-system");
5384
5545
  var import_jsx_runtime19 = require("react/jsx-runtime");
5385
5546
  function TableSettings({
@@ -5390,15 +5551,15 @@ function TableSettings({
5390
5551
  onDeleted,
5391
5552
  className
5392
5553
  }) {
5393
- const table = (0, import_react32.useTable)(tableId);
5394
- const fields = (0, import_react32.useFields)(tableId);
5554
+ const table = (0, import_react33.useTable)(tableId);
5555
+ const fields = (0, import_react33.useFields)(tableId);
5395
5556
  const rights = useTableRights(table.data);
5396
- const mutation = (0, import_react32.useRecordMutation)();
5397
- const shape = (0, import_react32.useFieldMutation)();
5398
- const [editing, setEditing] = (0, import_react31.useState)(null);
5399
- const [askingToDelete, setAskingToDelete] = (0, import_react31.useState)(false);
5400
- const [askingToRemove, setAskingToRemove] = (0, import_react31.useState)(null);
5401
- const [enriching, setEnriching] = (0, import_react31.useState)(null);
5557
+ const mutation = (0, import_react33.useRecordMutation)();
5558
+ const shape = (0, import_react33.useFieldMutation)();
5559
+ const [editing, setEditing] = (0, import_react32.useState)(null);
5560
+ const [askingToDelete, setAskingToDelete] = (0, import_react32.useState)(false);
5561
+ const [askingToRemove, setAskingToRemove] = (0, import_react32.useState)(null);
5562
+ const [enriching, setEnriching] = (0, import_react32.useState)(null);
5402
5563
  if (table.error) return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(RefusalNotice, { error: table.error, className });
5403
5564
  if (fields.error) return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(RefusalNotice, { error: fields.error, className });
5404
5565
  if (!rights.structure) return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("p", { className: (0, import_design_system16.cn)("text-xs text-muted-foreground", className), children: rights.why("structure") });
@@ -5569,22 +5730,22 @@ function TableSettings({
5569
5730
  }
5570
5731
 
5571
5732
  // src/Peek.tsx
5572
- var import_react40 = require("react");
5573
- var import_react41 = require("@ai-matrx/records/react");
5574
- var import_react42 = require("@ai-matrx/alchemy/react");
5733
+ var import_react41 = require("react");
5734
+ var import_react42 = require("@ai-matrx/records/react");
5735
+ var import_react43 = require("@ai-matrx/alchemy/react");
5575
5736
 
5576
5737
  // src/RecordChat.tsx
5577
- var import_react33 = require("react");
5578
- var import_react34 = require("@ai-matrx/records/react");
5738
+ var import_react34 = require("react");
5739
+ var import_react35 = require("@ai-matrx/records/react");
5579
5740
  var import_design_system17 = require("@ai-matrx/design-system");
5580
5741
  var import_jsx_runtime20 = require("react/jsx-runtime");
5581
5742
  var NO_CHAT_REASON = "No chat port is bound, so this panel is absent rather than showing a composer that goes nowhere. Bind `chat` on <RecordsUiProvider> with your host's own chat surface \u2014 in AI Matrx that is `AgentConversationColumn`, launched through a Mandate \u2014 and this panel becomes that surface with this record as its context. This package deliberately ships no second chat UI.";
5582
5743
  function RecordChat({ tableId, recordId, className }) {
5583
- const client = (0, import_react34.useRecordsClient)();
5744
+ const client = (0, import_react35.useRecordsClient)();
5584
5745
  const host = useRecordsUi();
5585
- const [scope, setScope] = (0, import_react33.useState)(null);
5586
- const [error, setError] = (0, import_react33.useState)(null);
5587
- (0, import_react33.useEffect)(() => {
5746
+ const [scope, setScope] = (0, import_react34.useState)(null);
5747
+ const [error, setError] = (0, import_react34.useState)(null);
5748
+ (0, import_react34.useEffect)(() => {
5588
5749
  let cancelled = false;
5589
5750
  setScope(null);
5590
5751
  setError(null);
@@ -5600,7 +5761,7 @@ function RecordChat({ tableId, recordId, className }) {
5600
5761
  cancelled = true;
5601
5762
  };
5602
5763
  }, [client, recordId]);
5603
- const context = (0, import_react33.useMemo)(() => {
5764
+ const context = (0, import_react34.useMemo)(() => {
5604
5765
  if (!scope) return null;
5605
5766
  return {
5606
5767
  surfaceKey: `records-ui:record-chat:${recordId}`,
@@ -5701,14 +5862,14 @@ function entriesFor(scope) {
5701
5862
  var import_design_system20 = require("@ai-matrx/design-system");
5702
5863
 
5703
5864
  // src/RecordForm.tsx
5704
- var import_react37 = require("react");
5705
- var import_react38 = require("@ai-matrx/records/react");
5865
+ var import_react38 = require("react");
5866
+ var import_react39 = require("@ai-matrx/records/react");
5706
5867
  var import_core5 = require("@ai-matrx/records/core");
5707
5868
  var import_design_system18 = require("@ai-matrx/design-system");
5708
5869
 
5709
5870
  // src/systemTable.ts
5710
- var import_react35 = require("react");
5711
- var import_react36 = require("@ai-matrx/records/react");
5871
+ var import_react36 = require("react");
5872
+ var import_react37 = require("@ai-matrx/records/react");
5712
5873
  var inFlight = /* @__PURE__ */ new Map();
5713
5874
  async function ensureSystemTable(client, spec) {
5714
5875
  const cacheKey = `${client.config.organizationId}:${spec.slug}`;
@@ -5836,11 +5997,11 @@ async function declare(client, spec) {
5836
5997
  return { ok: true, data: table.data };
5837
5998
  }
5838
5999
  function useSystemTable(spec) {
5839
- const client = (0, import_react36.useRecordsClient)();
5840
- const [state, setState] = (0, import_react35.useState)({ tableId: null, loading: true, error: null });
6000
+ const client = (0, import_react37.useRecordsClient)();
6001
+ const [state, setState] = (0, import_react36.useState)({ tableId: null, loading: true, error: null });
5841
6002
  const slug = spec.slug;
5842
- const stable = (0, import_react35.useMemo)(() => spec, [slug]);
5843
- (0, import_react35.useEffect)(() => {
6003
+ const stable = (0, import_react36.useMemo)(() => spec, [slug]);
6004
+ (0, import_react36.useEffect)(() => {
5844
6005
  let cancelled = false;
5845
6006
  setState({ tableId: null, loading: true, error: null });
5846
6007
  void ensureSystemTable(client, stable).then((result) => {
@@ -5856,9 +6017,9 @@ function useSystemTable(spec) {
5856
6017
  return state;
5857
6018
  }
5858
6019
  function useRecordVersion(recordId) {
5859
- const client = (0, import_react36.useRecordsClient)();
5860
- const [version, setVersion] = (0, import_react35.useState)(null);
5861
- (0, import_react35.useEffect)(() => {
6020
+ const client = (0, import_react37.useRecordsClient)();
6021
+ const [version, setVersion] = (0, import_react36.useState)(null);
6022
+ (0, import_react36.useEffect)(() => {
5862
6023
  let cancelled = false;
5863
6024
  setVersion(null);
5864
6025
  if (!recordId) return;
@@ -5888,18 +6049,18 @@ function RecordForm({
5888
6049
  className
5889
6050
  }) {
5890
6051
  const host = useRecordsUi();
5891
- const fields = (0, import_react38.useFields)(tableId, recordType);
5892
- const existing = (0, import_react38.useRecord)(recordId ?? null);
5893
- const mutation = (0, import_react38.useRecordMutation)();
5894
- const [draft, setDraft] = (0, import_react37.useState)({});
5895
- const [touched, setTouched] = (0, import_react37.useState)(false);
6052
+ const fields = (0, import_react39.useFields)(tableId, recordType);
6053
+ const existing = (0, import_react39.useRecord)(recordId ?? null);
6054
+ const mutation = (0, import_react39.useRecordMutation)();
6055
+ const [draft, setDraft] = (0, import_react38.useState)({});
6056
+ const [touched, setTouched] = (0, import_react38.useState)(false);
5896
6057
  const loaded = useRecordVersion(recordId ?? null);
5897
6058
  const loadedVersion = loaded.version;
5898
- (0, import_react37.useEffect)(() => {
6059
+ (0, import_react38.useEffect)(() => {
5899
6060
  const document3 = existing.data?.document;
5900
6061
  if (document3) setDraft({ ...document3 });
5901
6062
  }, [existing.data?.record_id, loadedVersion]);
5902
- const document2 = (0, import_react37.useMemo)(() => {
6063
+ const document2 = (0, import_react38.useMemo)(() => {
5903
6064
  const out = {};
5904
6065
  for (const [key, value] of Object.entries(draft)) {
5905
6066
  if (key.startsWith("_")) continue;
@@ -5907,7 +6068,7 @@ function RecordForm({
5907
6068
  }
5908
6069
  return out;
5909
6070
  }, [draft]);
5910
- const predicted = (0, import_react37.useMemo)(
6071
+ const predicted = (0, import_react38.useMemo)(
5911
6072
  () => fields.data ? (0, import_core5.predictWriteRefusals)({ fields: fields.data, document: document2, ...recordType ? { recordType } : {} }) : [],
5912
6073
  [fields.data, document2, recordType]
5913
6074
  );
@@ -6022,7 +6183,7 @@ function asWords(value) {
6022
6183
  }
6023
6184
 
6024
6185
  // src/ShareControl.tsx
6025
- var import_react39 = require("react");
6186
+ var import_react40 = require("react");
6026
6187
  var import_design_system19 = require("@ai-matrx/design-system");
6027
6188
  var import_jsx_runtime22 = require("react/jsx-runtime");
6028
6189
  function useCanShare() {
@@ -6042,7 +6203,7 @@ function ShareControl({
6042
6203
  className
6043
6204
  }) {
6044
6205
  const host = useRecordsUi();
6045
- const [open, setOpen] = (0, import_react39.useState)(false);
6206
+ const [open, setOpen] = (0, import_react40.useState)(false);
6046
6207
  const asked = useRecordRights(may === void 0 ? subjectId : null);
6047
6208
  const mayShare = may ?? asked.share;
6048
6209
  if (!host.share) return null;
@@ -6074,14 +6235,14 @@ function ShareControl({
6074
6235
  // src/Peek.tsx
6075
6236
  var import_jsx_runtime23 = require("react/jsx-runtime");
6076
6237
  function Peek({ tableId, recordId, onClose, className }) {
6077
- const table = (0, import_react41.useTable)(tableId);
6078
- const fields = (0, import_react41.useFields)(tableId);
6079
- const record = (0, import_react41.useRecord)(recordId, true);
6238
+ const table = (0, import_react42.useTable)(tableId);
6239
+ const fields = (0, import_react42.useFields)(tableId);
6240
+ const record = (0, import_react42.useRecord)(recordId, true);
6080
6241
  const may = useRecordRights(recordId);
6081
6242
  const host = useRecordsUi();
6082
- const organizationId = (0, import_react41.useRecordsClient)().config.organizationId;
6083
- const [editing, setEditing] = (0, import_react40.useState)(false);
6084
- const [talking, setTalking] = (0, import_react40.useState)(false);
6243
+ const organizationId = (0, import_react42.useRecordsClient)().config.organizationId;
6244
+ const [editing, setEditing] = (0, import_react41.useState)(false);
6245
+ const [talking, setTalking] = (0, import_react41.useState)(false);
6085
6246
  if (record.error) return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(RefusalNotice, { error: record.error, className });
6086
6247
  if (fields.error) return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(RefusalNotice, { error: fields.error, className });
6087
6248
  const document2 = record.data?.document;
@@ -6091,7 +6252,7 @@ function Peek({ tableId, recordId, onClose, className }) {
6091
6252
  /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: "flex items-center gap-2", children: [
6092
6253
  /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("h3", { className: "min-w-0 flex-1 truncate text-sm font-medium", children: record.loading && !document2 ? /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_design_system20.Skeleton, { className: "h-4 w-40" }) : title }),
6093
6254
  /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
6094
- import_react42.AlchemyMenu,
6255
+ import_react43.AlchemyMenu,
6095
6256
  {
6096
6257
  label: title || "Record",
6097
6258
  sourceId: `record:${recordId}`,
@@ -6284,13 +6445,13 @@ function parseSorts(raw) {
6284
6445
  }
6285
6446
 
6286
6447
  // src/ViewSwitcher.tsx
6287
- var import_react45 = require("react");
6288
- var import_react46 = require("@ai-matrx/records/react");
6448
+ var import_react46 = require("react");
6449
+ var import_react47 = require("@ai-matrx/records/react");
6289
6450
  var import_design_system22 = require("@ai-matrx/design-system");
6290
6451
 
6291
6452
  // src/Pipeline.tsx
6292
- var import_react43 = require("react");
6293
- var import_react44 = require("@ai-matrx/records/react");
6453
+ var import_react44 = require("react");
6454
+ var import_react45 = require("@ai-matrx/records/react");
6294
6455
  var import_design_system21 = require("@ai-matrx/design-system");
6295
6456
  var import_jsx_runtime24 = require("react/jsx-runtime");
6296
6457
  var UNPLACED = "\0unplaced";
@@ -6323,24 +6484,24 @@ function PipelineBoard({
6323
6484
  onMoved,
6324
6485
  className
6325
6486
  }) {
6326
- const client = (0, import_react44.useRecordsClient)();
6327
- const fields = (0, import_react44.useFields)(tableId);
6328
- const [definition, setDefinition] = (0, import_react43.useState)(null);
6329
- const [columns, setColumns] = (0, import_react43.useState)([]);
6330
- const [error, setError] = (0, import_react43.useState)(null);
6331
- const [loading, setLoading] = (0, import_react43.useState)(true);
6332
- const [pending, setPending] = (0, import_react43.useState)({ kind: "none" });
6333
- const [waiting, setWaiting] = (0, import_react43.useState)(/* @__PURE__ */ new Map());
6334
- const [dragging, setDragging] = (0, import_react43.useState)(null);
6335
- const [over, setOver] = (0, import_react43.useState)(null);
6336
- const alive = (0, import_react43.useRef)(true);
6337
- (0, import_react43.useEffect)(() => {
6487
+ const client = (0, import_react45.useRecordsClient)();
6488
+ const fields = (0, import_react45.useFields)(tableId);
6489
+ const [definition, setDefinition] = (0, import_react44.useState)(null);
6490
+ const [columns, setColumns] = (0, import_react44.useState)([]);
6491
+ const [error, setError] = (0, import_react44.useState)(null);
6492
+ const [loading, setLoading] = (0, import_react44.useState)(true);
6493
+ const [pending, setPending] = (0, import_react44.useState)({ kind: "none" });
6494
+ const [waiting, setWaiting] = (0, import_react44.useState)(/* @__PURE__ */ new Map());
6495
+ const [dragging, setDragging] = (0, import_react44.useState)(null);
6496
+ const [over, setOver] = (0, import_react44.useState)(null);
6497
+ const alive = (0, import_react44.useRef)(true);
6498
+ (0, import_react44.useEffect)(() => {
6338
6499
  alive.current = true;
6339
6500
  return () => {
6340
6501
  alive.current = false;
6341
6502
  };
6342
6503
  }, []);
6343
- const reload = (0, import_react43.useCallback)(async () => {
6504
+ const reload = (0, import_react44.useCallback)(async () => {
6344
6505
  setLoading(true);
6345
6506
  const [read, board, held] = await Promise.all([
6346
6507
  client.pipelineRead({ table_id: tableId }),
@@ -6358,11 +6519,11 @@ function PipelineBoard({
6358
6519
  setWaiting(held.ok ? new Map((held.data ?? []).map((p) => [p.record_id, p])) : /* @__PURE__ */ new Map());
6359
6520
  setColumns(board.ok ? board.data ?? [] : []);
6360
6521
  }, [client, tableId, measure]);
6361
- (0, import_react43.useEffect)(() => {
6522
+ (0, import_react44.useEffect)(() => {
6362
6523
  void reload();
6363
6524
  }, [reload]);
6364
6525
  const stageKey = definition?.stage_field ?? null;
6365
- const cardsByStage = (0, import_react43.useMemo)(() => {
6526
+ const cardsByStage = (0, import_react44.useMemo)(() => {
6366
6527
  const map = /* @__PURE__ */ new Map();
6367
6528
  if (!stageKey) return map;
6368
6529
  for (const row of rows) {
@@ -6373,15 +6534,16 @@ function PipelineBoard({
6373
6534
  }, [rows, stageKey, definition?.stages]);
6374
6535
  const unplaced = cardsByStage.get(UNPLACED) ?? [];
6375
6536
  const all = fields.data ?? [];
6376
- const titleField = (0, import_react43.useMemo)(
6537
+ const titleField = (0, import_react44.useMemo)(
6377
6538
  () => all.find((f) => f.key !== stageKey) ?? all[0],
6378
6539
  [all, stageKey]
6379
6540
  );
6380
- const measurable = (0, import_react43.useMemo)(
6541
+ const unplacedLabels = useRecordLabels(titleField ? [titleField] : []);
6542
+ const measurable = (0, import_react44.useMemo)(
6381
6543
  () => all.filter((f) => ["number", "currency", "percentage"].includes(String(f.type ?? ""))),
6382
6544
  [all]
6383
6545
  );
6384
- const drop = (0, import_react43.useCallback)(
6546
+ const drop = (0, import_react44.useCallback)(
6385
6547
  async (recordId, to) => {
6386
6548
  setOver(null);
6387
6549
  setDragging(null);
@@ -6420,7 +6582,7 @@ function PipelineBoard({
6420
6582
  },
6421
6583
  [client, onMoved, reload]
6422
6584
  );
6423
- const askForApproval = (0, import_react43.useCallback)(
6585
+ const askForApproval = (0, import_react44.useCallback)(
6424
6586
  async (recordId, to) => {
6425
6587
  const moved = await client.pipelineMove({ record_id: recordId, to });
6426
6588
  if (!alive.current) return;
@@ -6434,7 +6596,7 @@ function PipelineBoard({
6434
6596
  },
6435
6597
  [client, reload]
6436
6598
  );
6437
- const moveWith = (0, import_react43.useCallback)(
6599
+ const moveWith = (0, import_react44.useCallback)(
6438
6600
  async (recordId, to, also) => {
6439
6601
  const moved = await client.pipelineMove({ record_id: recordId, to, also });
6440
6602
  if (!alive.current) return;
@@ -6547,7 +6709,7 @@ function PipelineBoard({
6547
6709
  unplaced.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("p", { className: "text-xs text-muted-foreground", "data-testid": "pipeline-unplaced", children: [
6548
6710
  unplaced.length === 1 ? "One record is" : `${unplaced.length} records are`,
6549
6711
  " not in any of these columns \u2014 ",
6550
- unplaced.slice(0, 3).map((r) => rowName(r, titleField?.key ?? null, "Untitled")).join(", "),
6712
+ unplaced.slice(0, 3).map((r) => unplacedName(r, titleField, unplacedLabels)).join(", "),
6551
6713
  unplaced.length > 3 ? ` and ${unplaced.length - 3} more` : "",
6552
6714
  ". Their stage is not one this pipeline offers, so nothing here can draw them; open one from the grid to move it."
6553
6715
  ] }) : null
@@ -6563,7 +6725,7 @@ function Held({
6563
6725
  onFill,
6564
6726
  onAsk
6565
6727
  }) {
6566
- const [draft, setDraft] = (0, import_react43.useState)({});
6728
+ const [draft, setDraft] = (0, import_react44.useState)({});
6567
6729
  if (pending.kind === "asking") {
6568
6730
  return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("p", { className: "px-2 py-1 text-xs text-muted-foreground", children: "Asking\u2026" });
6569
6731
  }
@@ -6650,7 +6812,7 @@ function Card({
6650
6812
  stages
6651
6813
  }) {
6652
6814
  const labels = useRecordLabels(field ? [field] : []);
6653
- const draggable = (0, import_react44.mayDrag)(record.level);
6815
+ const draggable = (0, import_react45.mayDrag)(record.level);
6654
6816
  const label = field ? scalarText(field, (record.document ?? {})[field.key], labels) : rowName(record, null, "Untitled");
6655
6817
  return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(
6656
6818
  "button",
@@ -6684,20 +6846,24 @@ function Card({
6684
6846
  }
6685
6847
  );
6686
6848
  }
6849
+ function unplacedName(record, field, labels) {
6850
+ if (!field) return rowName(record, null, "Untitled");
6851
+ return scalarText(field, (record.document ?? {})[field.key], labels);
6852
+ }
6687
6853
 
6688
6854
  // src/ViewSwitcher.tsx
6689
6855
  var import_jsx_runtime25 = require("react/jsx-runtime");
6690
6856
  var NO_FIELDS = [];
6691
6857
  function useViewRecords(view, pageSize = 200) {
6692
- const client = (0, import_react46.useRecordsClient)();
6693
- const table = (0, import_react46.useRecords)(view.ruleId ? null : view.subject, { pageSize });
6694
- const [ruled, setRuled] = (0, import_react45.useState)({
6858
+ const client = (0, import_react47.useRecordsClient)();
6859
+ const table = (0, import_react47.useRecords)(view.ruleId ? null : view.subject, { pageSize });
6860
+ const [ruled, setRuled] = (0, import_react46.useState)({
6695
6861
  rows: [],
6696
6862
  loading: Boolean(view.ruleId),
6697
6863
  error: null
6698
6864
  });
6699
6865
  const ruleId = view.ruleId ?? null;
6700
- (0, import_react45.useEffect)(() => {
6866
+ (0, import_react46.useEffect)(() => {
6701
6867
  if (!ruleId) return;
6702
6868
  let cancelled = false;
6703
6869
  setRuled({ rows: [], loading: true, error: null });
@@ -6747,9 +6913,9 @@ function ViewSwitcher({
6747
6913
  pageSize = 200,
6748
6914
  className
6749
6915
  }) {
6750
- const [layout, setLayout] = (0, import_react45.useState)(view.layout);
6751
- const [local, setLocal] = (0, import_react45.useState)({});
6752
- (0, import_react45.useEffect)(() => {
6916
+ const [layout, setLayout] = (0, import_react46.useState)(view.layout);
6917
+ const [local, setLocal] = (0, import_react46.useState)({});
6918
+ (0, import_react46.useEffect)(() => {
6753
6919
  setLayout(view.layout);
6754
6920
  setLocal({});
6755
6921
  }, [view.layout, view.name, view.subject]);
@@ -6809,12 +6975,12 @@ function offerableFields(all, want) {
6809
6975
  });
6810
6976
  }
6811
6977
  function useStageField(tableId) {
6812
- const client = (0, import_react46.useRecordsClient)();
6813
- const [stage, setStage] = (0, import_react45.useState)({
6978
+ const client = (0, import_react47.useRecordsClient)();
6979
+ const [stage, setStage] = (0, import_react46.useState)({
6814
6980
  asked: false,
6815
6981
  key: null
6816
6982
  });
6817
- (0, import_react45.useEffect)(() => {
6983
+ (0, import_react46.useEffect)(() => {
6818
6984
  let cancelled = false;
6819
6985
  setStage({ asked: false, key: null });
6820
6986
  void client.tableStageField({ table_id: tableId }).then((r) => {
@@ -6845,7 +7011,7 @@ function Board({
6845
7011
  onOpenRecord,
6846
7012
  onMoved
6847
7013
  }) {
6848
- const fields = (0, import_react46.useFields)(view.subject);
7014
+ const fields = (0, import_react47.useFields)(view.subject);
6849
7015
  const records = useViewRecords(view, pageSize);
6850
7016
  const stage = useStageField(view.subject);
6851
7017
  if (fields.error) return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(RefusalNotice, { error: fields.error });
@@ -6955,9 +7121,9 @@ function Kanban({
6955
7121
  onOpenRecord,
6956
7122
  note
6957
7123
  }) {
6958
- const groupFields = (0, import_react45.useMemo)(() => [groupField], [groupField]);
7124
+ const groupFields = (0, import_react46.useMemo)(() => [groupField], [groupField]);
6959
7125
  const labels = useRecordLabels(groupFields);
6960
- const columns = (0, import_react45.useMemo)(() => {
7126
+ const columns = (0, import_react46.useMemo)(() => {
6961
7127
  const map = /* @__PURE__ */ new Map();
6962
7128
  for (const row of rows) {
6963
7129
  const raw = (row.document ?? {})[groupField.key];
@@ -6984,7 +7150,7 @@ function Calendar({
6984
7150
  onOpenRecord,
6985
7151
  note
6986
7152
  }) {
6987
- const { days, undated } = (0, import_react45.useMemo)(() => {
7153
+ const { days, undated } = (0, import_react46.useMemo)(() => {
6988
7154
  const byDay = /* @__PURE__ */ new Map();
6989
7155
  const without = [];
6990
7156
  for (const row of rows) {
@@ -7057,7 +7223,7 @@ function Card2({
7057
7223
  onOpenRecord
7058
7224
  }) {
7059
7225
  const host = useRecordsUi();
7060
- const wanted = (0, import_react45.useMemo)(
7226
+ const wanted = (0, import_react46.useMemo)(
7061
7227
  () => field && pointsAtRecords(field) ? [field] : NO_FIELDS,
7062
7228
  [field]
7063
7229
  );
@@ -7079,15 +7245,15 @@ function Card2({
7079
7245
  }
7080
7246
 
7081
7247
  // src/ViewBar.tsx
7082
- var import_react48 = require("react");
7083
- var import_react49 = require("@ai-matrx/records/react");
7248
+ var import_react49 = require("react");
7249
+ var import_react50 = require("@ai-matrx/records/react");
7084
7250
  var import_design_system23 = require("@ai-matrx/design-system");
7085
7251
 
7086
7252
  // src/seedOnce.ts
7087
- var import_react47 = require("react");
7253
+ var import_react48 = require("react");
7088
7254
  function useSeedGuard() {
7089
- const claimed = (0, import_react47.useRef)(/* @__PURE__ */ new Set());
7090
- return (0, import_react47.useCallback)((name) => {
7255
+ const claimed = (0, import_react48.useRef)(/* @__PURE__ */ new Set());
7256
+ return (0, import_react48.useCallback)((name) => {
7091
7257
  if (claimed.current.has(name)) return false;
7092
7258
  claimed.current.add(name);
7093
7259
  return true;
@@ -7095,22 +7261,22 @@ function useSeedGuard() {
7095
7261
  }
7096
7262
 
7097
7263
  // src/ViewBar.tsx
7098
- var import_react50 = require("@ai-matrx/records/react");
7264
+ var import_react51 = require("@ai-matrx/records/react");
7099
7265
  var import_jsx_runtime26 = require("react/jsx-runtime");
7100
7266
  var SAVED_VIEWS_UNAVAILABLE = "Saved views are not available in this organization right now, so the layout you pick here is not being kept. Everything else on this table works as usual.";
7101
7267
  function ViewBar({ tableId, activeViewId, onActiveView, seed, className }) {
7102
- const client = (0, import_react49.useRecordsClient)();
7268
+ const client = (0, import_react50.useRecordsClient)();
7103
7269
  const claimSeed = useSeedGuard();
7104
- const table = (0, import_react50.useTable)(tableId);
7270
+ const table = (0, import_react51.useTable)(tableId);
7105
7271
  const rights = useTableRights(table.data);
7106
7272
  const home = useSystemTable(VIEW_TABLE);
7107
- const [views, setViews] = (0, import_react48.useState)(null);
7108
- const [error, setError] = (0, import_react48.useState)(null);
7109
- const [active, setActive] = (0, import_react48.useState)(activeViewId ?? null);
7110
- const [naming, setNaming] = (0, import_react48.useState)(false);
7111
- const [draftName, setDraftName] = (0, import_react48.useState)("");
7273
+ const [views, setViews] = (0, import_react49.useState)(null);
7274
+ const [error, setError] = (0, import_react49.useState)(null);
7275
+ const [active, setActive] = (0, import_react49.useState)(activeViewId ?? null);
7276
+ const [naming, setNaming] = (0, import_react49.useState)(false);
7277
+ const [draftName, setDraftName] = (0, import_react49.useState)("");
7112
7278
  const viewTableId = home.tableId;
7113
- const load = (0, import_react48.useCallback)(async () => {
7279
+ const load = (0, import_react49.useCallback)(async () => {
7114
7280
  if (!viewTableId) return;
7115
7281
  const result = await client.list({ table_id: viewTableId, limit: 500 });
7116
7282
  if (!result.ok) {
@@ -7142,10 +7308,10 @@ function ViewBar({ tableId, activeViewId, onActiveView, seed, className }) {
7142
7308
  setError(null);
7143
7309
  setViews(mine);
7144
7310
  }, [client, viewTableId, tableId, seed]);
7145
- (0, import_react48.useEffect)(() => {
7311
+ (0, import_react49.useEffect)(() => {
7146
7312
  void load();
7147
7313
  }, [load]);
7148
- (0, import_react48.useEffect)(() => {
7314
+ (0, import_react49.useEffect)(() => {
7149
7315
  if (!views || views.length === 0) return;
7150
7316
  const chosen = views.find((v) => v.id === (activeViewId ?? active)) ?? views.find((v) => v.isDefault) ?? views[0];
7151
7317
  if (chosen.id !== active) setActive(chosen.id);
@@ -7219,8 +7385,8 @@ function ViewBar({ tableId, activeViewId, onActiveView, seed, className }) {
7219
7385
  }
7220
7386
 
7221
7387
  // src/ProposalRow.tsx
7222
- var import_react51 = require("react");
7223
- var import_react52 = require("@ai-matrx/records/react");
7388
+ var import_react52 = require("react");
7389
+ var import_react53 = require("@ai-matrx/records/react");
7224
7390
  var import_design_system24 = require("@ai-matrx/design-system");
7225
7391
  var import_jsx_runtime27 = require("react/jsx-runtime");
7226
7392
  var ACT_WORD = {
@@ -7237,10 +7403,10 @@ function ProposalRow({
7237
7403
  onSettled,
7238
7404
  className
7239
7405
  }) {
7240
- const client = (0, import_react52.useRecordsClient)();
7241
- const [settled, setSettled] = (0, import_react51.useState)(outcome ?? null);
7242
- const [busy, setBusy] = (0, import_react51.useState)(false);
7243
- const [confirming, setConfirming] = (0, import_react51.useState)(false);
7406
+ const client = (0, import_react53.useRecordsClient)();
7407
+ const [settled, setSettled] = (0, import_react52.useState)(outcome ?? null);
7408
+ const [busy, setBusy] = (0, import_react52.useState)(false);
7409
+ const [confirming, setConfirming] = (0, import_react52.useState)(false);
7244
7410
  async function applyThroughTheStore() {
7245
7411
  if (change.act === "add") {
7246
7412
  if (!change.table) {
@@ -7325,13 +7491,13 @@ function ProposalRow({
7325
7491
  }
7326
7492
 
7327
7493
  // src/ActionInbox.tsx
7328
- var import_react55 = require("react");
7329
- var import_react56 = require("@ai-matrx/records/react");
7494
+ var import_react56 = require("react");
7495
+ var import_react57 = require("@ai-matrx/records/react");
7330
7496
  var import_design_system26 = require("@ai-matrx/design-system");
7331
7497
 
7332
7498
  // src/ChecklistRunner.tsx
7333
- var import_react53 = require("react");
7334
- var import_react54 = require("@ai-matrx/records/react");
7499
+ var import_react54 = require("react");
7500
+ var import_react55 = require("@ai-matrx/records/react");
7335
7501
  var import_design_system25 = require("@ai-matrx/design-system");
7336
7502
  var import_jsx_runtime28 = require("react/jsx-runtime");
7337
7503
  var DUE_WORD = {
@@ -7358,18 +7524,18 @@ function ChecklistRunner({
7358
7524
  offerToStart,
7359
7525
  className
7360
7526
  }) {
7361
- const client = (0, import_react54.useRecordsClient)();
7362
- const table = (0, import_react54.useTable)(tableId ?? null);
7527
+ const client = (0, import_react55.useRecordsClient)();
7528
+ const table = (0, import_react55.useTable)(tableId ?? null);
7363
7529
  const rights = useTableRights(table.data);
7364
- const [runs, setRuns] = (0, import_react53.useState)(null);
7365
- const [activeId, setActiveId] = (0, import_react53.useState)(runId ?? null);
7366
- const [steps, setSteps] = (0, import_react53.useState)(null);
7367
- const [templates, setTemplates] = (0, import_react53.useState)(null);
7368
- const [error, setError] = (0, import_react53.useState)(null);
7369
- const [busy, setBusy] = (0, import_react53.useState)(null);
7370
- const [said, setSaid] = (0, import_react53.useState)(null);
7530
+ const [runs, setRuns] = (0, import_react54.useState)(null);
7531
+ const [activeId, setActiveId] = (0, import_react54.useState)(runId ?? null);
7532
+ const [steps, setSteps] = (0, import_react54.useState)(null);
7533
+ const [templates, setTemplates] = (0, import_react54.useState)(null);
7534
+ const [error, setError] = (0, import_react54.useState)(null);
7535
+ const [busy, setBusy] = (0, import_react54.useState)(null);
7536
+ const [said, setSaid] = (0, import_react54.useState)(null);
7371
7537
  const mayStart = offerToStart ?? Boolean(recordId);
7372
- const loadRuns = (0, import_react53.useCallback)(async () => {
7538
+ const loadRuns = (0, import_react54.useCallback)(async () => {
7373
7539
  if (runId) {
7374
7540
  setRuns(null);
7375
7541
  return;
@@ -7391,13 +7557,13 @@ function ChecklistRunner({
7391
7557
  (held) => held && answered.data.some((r) => r.run_id === held) ? held : answered.data[0]?.run_id ?? null
7392
7558
  );
7393
7559
  }, [client, includeClosed, recordId, runId, tableId]);
7394
- (0, import_react53.useEffect)(() => {
7560
+ (0, import_react54.useEffect)(() => {
7395
7561
  void loadRuns();
7396
7562
  }, [loadRuns]);
7397
- (0, import_react53.useEffect)(() => {
7563
+ (0, import_react54.useEffect)(() => {
7398
7564
  if (runId) setActiveId(runId);
7399
7565
  }, [runId]);
7400
- const loadSteps = (0, import_react53.useCallback)(async () => {
7566
+ const loadSteps = (0, import_react54.useCallback)(async () => {
7401
7567
  if (!activeId) {
7402
7568
  setSteps(null);
7403
7569
  return;
@@ -7411,10 +7577,10 @@ function ChecklistRunner({
7411
7577
  setError(null);
7412
7578
  setSteps(answered.data);
7413
7579
  }, [client, activeId]);
7414
- (0, import_react53.useEffect)(() => {
7580
+ (0, import_react54.useEffect)(() => {
7415
7581
  void loadSteps();
7416
7582
  }, [loadSteps]);
7417
- (0, import_react53.useEffect)(() => {
7583
+ (0, import_react54.useEffect)(() => {
7418
7584
  if (!mayStart || !tableId) return;
7419
7585
  let cancelled = false;
7420
7586
  void client.checklistTemplates({ about_table_id: tableId, limit: 50 }).then((answered) => {
@@ -7425,7 +7591,7 @@ function ChecklistRunner({
7425
7591
  cancelled = true;
7426
7592
  };
7427
7593
  }, [client, mayStart, tableId]);
7428
- const start = (0, import_react53.useCallback)(
7594
+ const start = (0, import_react54.useCallback)(
7429
7595
  async (templateId) => {
7430
7596
  setBusy(templateId);
7431
7597
  setSaid(null);
@@ -7447,7 +7613,7 @@ function ChecklistRunner({
7447
7613
  },
7448
7614
  [client, loadRuns, recordId]
7449
7615
  );
7450
- const complete = (0, import_react53.useCallback)(
7616
+ const complete = (0, import_react54.useCallback)(
7451
7617
  async (step2, evidence) => {
7452
7618
  setBusy(step2.step_id);
7453
7619
  setSaid(null);
@@ -7464,7 +7630,7 @@ function ChecklistRunner({
7464
7630
  },
7465
7631
  [client, loadSteps, loadRuns]
7466
7632
  );
7467
- const active = (0, import_react53.useMemo)(
7633
+ const active = (0, import_react54.useMemo)(
7468
7634
  () => runs?.find((r) => r.run_id === activeId) ?? null,
7469
7635
  [runs, activeId]
7470
7636
  );
@@ -7534,7 +7700,7 @@ function StepRow({
7534
7700
  onComplete,
7535
7701
  className
7536
7702
  }) {
7537
- const [answer, setAnswer] = (0, import_react53.useState)("");
7703
+ const [answer, setAnswer] = (0, import_react54.useState)("");
7538
7704
  const key = step2.requires_key ?? (step2.requires === "note" ? "note" : null);
7539
7705
  const asksHere = step2.requires === "note" || step2.requires === "answer";
7540
7706
  const needsAnswer = asksHere && answer.trim().length === 0;
@@ -7607,12 +7773,12 @@ function StepRow({
7607
7773
  );
7608
7774
  }
7609
7775
  function useMyChecklistSteps(limit = 25) {
7610
- const client = (0, import_react54.useRecordsClient)();
7776
+ const client = (0, import_react55.useRecordsClient)();
7611
7777
  const me = client.config.actor.user_id ?? null;
7612
- const [steps, setSteps] = (0, import_react53.useState)([]);
7613
- const [loading, setLoading] = (0, import_react53.useState)(true);
7614
- const [error, setError] = (0, import_react53.useState)(null);
7615
- const refresh = (0, import_react53.useCallback)(async () => {
7778
+ const [steps, setSteps] = (0, import_react54.useState)([]);
7779
+ const [loading, setLoading] = (0, import_react54.useState)(true);
7780
+ const [error, setError] = (0, import_react54.useState)(null);
7781
+ const refresh = (0, import_react54.useCallback)(async () => {
7616
7782
  if (!me) {
7617
7783
  setSteps([]);
7618
7784
  setLoading(false);
@@ -7640,17 +7806,17 @@ function useMyChecklistSteps(limit = 25) {
7640
7806
  setSteps(held);
7641
7807
  setLoading(false);
7642
7808
  }, [client, limit, me]);
7643
- (0, import_react53.useEffect)(() => {
7809
+ (0, import_react54.useEffect)(() => {
7644
7810
  void refresh();
7645
7811
  }, [refresh]);
7646
7812
  return { steps, loading, error, refresh };
7647
7813
  }
7648
7814
  function MyChecklistSteps({ className }) {
7649
- const client = (0, import_react54.useRecordsClient)();
7815
+ const client = (0, import_react55.useRecordsClient)();
7650
7816
  const { steps, loading, error, refresh } = useMyChecklistSteps();
7651
- const [busy, setBusy] = (0, import_react53.useState)(null);
7652
- const [refusal, setRefusal] = (0, import_react53.useState)(null);
7653
- const complete = (0, import_react53.useCallback)(
7817
+ const [busy, setBusy] = (0, import_react54.useState)(null);
7818
+ const [refusal, setRefusal] = (0, import_react54.useState)(null);
7819
+ const complete = (0, import_react54.useCallback)(
7654
7820
  async (step2, evidence) => {
7655
7821
  setBusy(step2.step_id);
7656
7822
  const answered = await client.checklistStepComplete({ step_id: step2.step_id, evidence });
@@ -7685,15 +7851,15 @@ function MyChecklistSteps({ className }) {
7685
7851
  ] });
7686
7852
  }
7687
7853
  function ChecklistsPanel({ tableId, onOpenRecord, className }) {
7688
- const client = (0, import_react54.useRecordsClient)();
7689
- const table = (0, import_react54.useTable)(tableId);
7854
+ const client = (0, import_react55.useRecordsClient)();
7855
+ const table = (0, import_react55.useTable)(tableId);
7690
7856
  const rights = useTableRights(table.data);
7691
- const [templates, setTemplates] = (0, import_react53.useState)(null);
7692
- const [runs, setRuns] = (0, import_react53.useState)(null);
7693
- const [error, setError] = (0, import_react53.useState)(null);
7694
- const [editing, setEditing] = (0, import_react53.useState)(null);
7695
- const [openRun, setOpenRun] = (0, import_react53.useState)(null);
7696
- const load = (0, import_react53.useCallback)(async () => {
7857
+ const [templates, setTemplates] = (0, import_react54.useState)(null);
7858
+ const [runs, setRuns] = (0, import_react54.useState)(null);
7859
+ const [error, setError] = (0, import_react54.useState)(null);
7860
+ const [editing, setEditing] = (0, import_react54.useState)(null);
7861
+ const [openRun, setOpenRun] = (0, import_react54.useState)(null);
7862
+ const load = (0, import_react54.useCallback)(async () => {
7697
7863
  const [t, r] = await Promise.all([
7698
7864
  client.checklistTemplates({ about_table_id: tableId, limit: 100 }),
7699
7865
  client.checklistRuns({ about_table_id: tableId, includeClosed: true, limit: 100 })
@@ -7707,7 +7873,7 @@ function ChecklistsPanel({ tableId, onOpenRecord, className }) {
7707
7873
  if (!r.ok) setRuns([]);
7708
7874
  else setRuns(r.data);
7709
7875
  }, [client, tableId]);
7710
- (0, import_react53.useEffect)(() => {
7876
+ (0, import_react54.useEffect)(() => {
7711
7877
  void load();
7712
7878
  }, [load]);
7713
7879
  if (templates === null) return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(import_design_system25.Skeleton, { className: (0, import_design_system25.cn)("h-40 w-full", className) });
@@ -7846,14 +8012,14 @@ function ChecklistTemplateEditor({
7846
8012
  onDone,
7847
8013
  className
7848
8014
  }) {
7849
- const client = (0, import_react54.useRecordsClient)();
7850
- const [name, setName] = (0, import_react53.useState)("");
7851
- const [rows, setRows] = (0, import_react53.useState)([{ ...EMPTY_ROW }]);
7852
- const [refusal, setRefusal] = (0, import_react53.useState)(null);
7853
- const [error, setError] = (0, import_react53.useState)(null);
7854
- const [busy, setBusy] = (0, import_react53.useState)(false);
7855
- const [loading, setLoading] = (0, import_react53.useState)(Boolean(templateId));
7856
- (0, import_react53.useEffect)(() => {
8015
+ const client = (0, import_react55.useRecordsClient)();
8016
+ const [name, setName] = (0, import_react54.useState)("");
8017
+ const [rows, setRows] = (0, import_react54.useState)([{ ...EMPTY_ROW }]);
8018
+ const [refusal, setRefusal] = (0, import_react54.useState)(null);
8019
+ const [error, setError] = (0, import_react54.useState)(null);
8020
+ const [busy, setBusy] = (0, import_react54.useState)(false);
8021
+ const [loading, setLoading] = (0, import_react54.useState)(Boolean(templateId));
8022
+ (0, import_react54.useEffect)(() => {
7857
8023
  if (!templateId) return;
7858
8024
  let cancelled = false;
7859
8025
  void client.checklistTemplateShape({ template_id: templateId }).then((answered) => {
@@ -7881,7 +8047,7 @@ function ChecklistTemplateEditor({
7881
8047
  cancelled = true;
7882
8048
  };
7883
8049
  }, [client, templateId]);
7884
- const spec = (0, import_react53.useMemo)(
8050
+ const spec = (0, import_react54.useMemo)(
7885
8051
  () => ({
7886
8052
  name: name.trim(),
7887
8053
  about_table_id: aboutTableId,
@@ -7890,7 +8056,7 @@ function ChecklistTemplateEditor({
7890
8056
  }),
7891
8057
  [aboutTableId, name, rows]
7892
8058
  );
7893
- (0, import_react53.useEffect)(() => {
8059
+ (0, import_react54.useEffect)(() => {
7894
8060
  if (spec.steps.length === 0 || spec.name.length === 0) {
7895
8061
  setRefusal(null);
7896
8062
  return;
@@ -7904,7 +8070,7 @@ function ChecklistTemplateEditor({
7904
8070
  cancelled = true;
7905
8071
  };
7906
8072
  }, [client, spec]);
7907
- const save = (0, import_react53.useCallback)(async () => {
8073
+ const save = (0, import_react54.useCallback)(async () => {
7908
8074
  setBusy(true);
7909
8075
  const answered = await client.checklistDeclare({
7910
8076
  spec,
@@ -8069,14 +8235,14 @@ var DUE_WORD2 = {
8069
8235
  finished: "Finished"
8070
8236
  };
8071
8237
  function ActionInbox({ tableId, includeSettled = false, onOpenRecord, className }) {
8072
- const client = (0, import_react56.useRecordsClient)();
8073
- const [items, setItems] = (0, import_react55.useState)(null);
8074
- const [error, setError] = (0, import_react55.useState)(null);
8075
- const [outcome, setOutcome] = (0, import_react55.useState)({});
8076
- const [busy, setBusy] = (0, import_react55.useState)(null);
8077
- const [cursor, setCursor] = (0, import_react55.useState)(0);
8078
- const listRef = (0, import_react55.useRef)(null);
8079
- const load = (0, import_react55.useCallback)(async () => {
8238
+ const client = (0, import_react57.useRecordsClient)();
8239
+ const [items, setItems] = (0, import_react56.useState)(null);
8240
+ const [error, setError] = (0, import_react56.useState)(null);
8241
+ const [outcome, setOutcome] = (0, import_react56.useState)({});
8242
+ const [busy, setBusy] = (0, import_react56.useState)(null);
8243
+ const [cursor, setCursor] = (0, import_react56.useState)(0);
8244
+ const listRef = (0, import_react56.useRef)(null);
8245
+ const load = (0, import_react56.useCallback)(async () => {
8080
8246
  const result = await client.workInbox({ limit: 200, includeDecided: includeSettled });
8081
8247
  if (!result.ok) {
8082
8248
  setError(result.error);
@@ -8086,22 +8252,22 @@ function ActionInbox({ tableId, includeSettled = false, onOpenRecord, className
8086
8252
  setError(null);
8087
8253
  setItems(result.data);
8088
8254
  }, [client, includeSettled]);
8089
- (0, import_react55.useEffect)(() => {
8255
+ (0, import_react56.useEffect)(() => {
8090
8256
  void load();
8091
8257
  }, [load]);
8092
- const shown = (0, import_react55.useMemo)(() => {
8258
+ const shown = (0, import_react56.useMemo)(() => {
8093
8259
  const all = items ?? [];
8094
8260
  if (!tableId) return all;
8095
8261
  return all.filter((i) => i.kind !== "assignment" || i.subject_kind !== "record" || true);
8096
8262
  }, [items, tableId]);
8097
- (0, import_react55.useEffect)(() => {
8263
+ (0, import_react56.useEffect)(() => {
8098
8264
  if (cursor >= shown.length) setCursor(Math.max(0, shown.length - 1));
8099
8265
  }, [shown.length, cursor]);
8100
- (0, import_react55.useEffect)(() => {
8266
+ (0, import_react56.useEffect)(() => {
8101
8267
  const el = listRef.current?.querySelector(`[data-row="${cursor}"]`);
8102
8268
  el?.scrollIntoView({ block: "nearest" });
8103
8269
  }, [cursor, shown.length]);
8104
- const decide = (0, import_react55.useCallback)(
8270
+ const decide = (0, import_react56.useCallback)(
8105
8271
  async (item, approve) => {
8106
8272
  if (item.kind === "assignment") return;
8107
8273
  setBusy(item.item_id);
@@ -8116,14 +8282,14 @@ function ActionInbox({ tableId, includeSettled = false, onOpenRecord, className
8116
8282
  },
8117
8283
  [client, load]
8118
8284
  );
8119
- const open = (0, import_react55.useCallback)(
8285
+ const open = (0, import_react56.useCallback)(
8120
8286
  (item) => {
8121
8287
  if (!onOpenRecord || !item.subject_id) return;
8122
8288
  onOpenRecord(item.subject_id, tableId ?? item.subject_id);
8123
8289
  },
8124
8290
  [onOpenRecord, tableId]
8125
8291
  );
8126
- const onKeyDown = (0, import_react55.useCallback)(
8292
+ const onKeyDown = (0, import_react56.useCallback)(
8127
8293
  (event) => {
8128
8294
  const item = shown[cursor];
8129
8295
  const key = event.key;
@@ -8223,22 +8389,22 @@ function ActionInbox({ tableId, includeSettled = false, onOpenRecord, className
8223
8389
  }
8224
8390
 
8225
8391
  // src/HistoryPanel.tsx
8226
- var import_react57 = require("react");
8227
- var import_react58 = require("@ai-matrx/records/react");
8392
+ var import_react58 = require("react");
8393
+ var import_react59 = require("@ai-matrx/records/react");
8228
8394
  var import_design_system27 = require("@ai-matrx/design-system");
8229
8395
  var import_jsx_runtime30 = require("react/jsx-runtime");
8230
8396
  function HistoryPanel({ tableId, recordId, onAskAboutField, className }) {
8231
- const client = (0, import_react58.useRecordsClient)();
8232
- const table = (0, import_react58.useTable)(tableId);
8233
- const fields = (0, import_react58.useFields)(tableId);
8397
+ const client = (0, import_react59.useRecordsClient)();
8398
+ const table = (0, import_react59.useTable)(tableId);
8399
+ const fields = (0, import_react59.useFields)(tableId);
8234
8400
  const rights = useTableRights(table.data);
8235
- const [entries, setEntries] = (0, import_react57.useState)(null);
8236
- const [error, setError] = (0, import_react57.useState)(null);
8237
- const [open, setOpen] = (0, import_react57.useState)(null);
8238
- const [pending, setPending] = (0, import_react57.useState)({ phase: "idle" });
8239
- const [said, setSaid] = (0, import_react57.useState)(null);
8240
- const listRef = (0, import_react57.useRef)(null);
8241
- const load = (0, import_react57.useCallback)(async () => {
8401
+ const [entries, setEntries] = (0, import_react58.useState)(null);
8402
+ const [error, setError] = (0, import_react58.useState)(null);
8403
+ const [open, setOpen] = (0, import_react58.useState)(null);
8404
+ const [pending, setPending] = (0, import_react58.useState)({ phase: "idle" });
8405
+ const [said, setSaid] = (0, import_react58.useState)(null);
8406
+ const listRef = (0, import_react58.useRef)(null);
8407
+ const load = (0, import_react58.useCallback)(async () => {
8242
8408
  const answered = await client.recordHistory({ record_id: recordId });
8243
8409
  if (!answered.ok) {
8244
8410
  setError(answered.error);
@@ -8247,7 +8413,7 @@ function HistoryPanel({ tableId, recordId, onAskAboutField, className }) {
8247
8413
  setError(null);
8248
8414
  setEntries(answered.data);
8249
8415
  }, [client, recordId]);
8250
- (0, import_react57.useEffect)(() => {
8416
+ (0, import_react58.useEffect)(() => {
8251
8417
  void load();
8252
8418
  }, [load]);
8253
8419
  if (error) return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(RefusalNotice, { error, className });
@@ -8528,27 +8694,27 @@ function say(value, field) {
8528
8694
  }
8529
8695
 
8530
8696
  // src/CommentThread.tsx
8531
- var import_react59 = require("react");
8532
- var import_react60 = require("@ai-matrx/records/react");
8697
+ var import_react60 = require("react");
8698
+ var import_react61 = require("@ai-matrx/records/react");
8533
8699
  var import_design_system28 = require("@ai-matrx/design-system");
8534
8700
  var import_jsx_runtime31 = require("react/jsx-runtime");
8535
8701
  function CommentThread({ tableId, recordId, fieldKey, className }) {
8536
- const client = (0, import_react60.useRecordsClient)();
8537
- const table = (0, import_react60.useTable)(tableId);
8538
- const fields = (0, import_react60.useFields)(tableId);
8702
+ const client = (0, import_react61.useRecordsClient)();
8703
+ const table = (0, import_react61.useTable)(tableId);
8704
+ const fields = (0, import_react61.useFields)(tableId);
8539
8705
  const host = useRecordsUi();
8540
- const [thread, setThread] = (0, import_react59.useState)(null);
8541
- const [error, setError] = (0, import_react59.useState)(null);
8542
- const [draft, setDraft] = (0, import_react59.useState)("");
8543
- const [replyTo, setReplyTo] = (0, import_react59.useState)(null);
8544
- const [busy, setBusy] = (0, import_react59.useState)(false);
8545
- const [said, setSaid] = (0, import_react59.useState)(null);
8546
- const [showResolved, setShowResolved] = (0, import_react59.useState)(false);
8547
- const [people, setPeople] = (0, import_react59.useState)([]);
8548
- const [mentionQuery, setMentionQuery] = (0, import_react59.useState)(null);
8549
- const [picked, setPicked] = (0, import_react59.useState)([]);
8550
- const box = (0, import_react59.useRef)(null);
8551
- const load = (0, import_react59.useCallback)(async () => {
8706
+ const [thread, setThread] = (0, import_react60.useState)(null);
8707
+ const [error, setError] = (0, import_react60.useState)(null);
8708
+ const [draft, setDraft] = (0, import_react60.useState)("");
8709
+ const [replyTo, setReplyTo] = (0, import_react60.useState)(null);
8710
+ const [busy, setBusy] = (0, import_react60.useState)(false);
8711
+ const [said, setSaid] = (0, import_react60.useState)(null);
8712
+ const [showResolved, setShowResolved] = (0, import_react60.useState)(false);
8713
+ const [people, setPeople] = (0, import_react60.useState)([]);
8714
+ const [mentionQuery, setMentionQuery] = (0, import_react60.useState)(null);
8715
+ const [picked, setPicked] = (0, import_react60.useState)([]);
8716
+ const box = (0, import_react60.useRef)(null);
8717
+ const load = (0, import_react60.useCallback)(async () => {
8552
8718
  const answered = await client.commentThread({ record_id: recordId, include_resolved: showResolved });
8553
8719
  if (!answered.ok) {
8554
8720
  setError(answered.error);
@@ -8561,10 +8727,10 @@ function CommentThread({ tableId, recordId, fieldKey, className }) {
8561
8727
  mayResolve: answered.data.may_resolve
8562
8728
  });
8563
8729
  }, [client, recordId, showResolved]);
8564
- (0, import_react59.useEffect)(() => {
8730
+ (0, import_react60.useEffect)(() => {
8565
8731
  void load();
8566
8732
  }, [load]);
8567
- (0, import_react59.useEffect)(() => {
8733
+ (0, import_react60.useEffect)(() => {
8568
8734
  let alive = true;
8569
8735
  if (!host.members) return;
8570
8736
  void host.members().then((roster) => {
@@ -8581,7 +8747,7 @@ function CommentThread({ tableId, recordId, fieldKey, className }) {
8581
8747
  alive = false;
8582
8748
  };
8583
8749
  }, [host]);
8584
- const candidates = (0, import_react59.useMemo)(() => {
8750
+ const candidates = (0, import_react60.useMemo)(() => {
8585
8751
  if (mentionQuery === null) return [];
8586
8752
  const q = mentionQuery.trim().toLowerCase();
8587
8753
  return people.filter((p) => !picked.some((already) => already.userId === p.userId)).filter((p) => q === "" || (p.name ?? p.email ?? "").toLowerCase().includes(q)).slice(0, 6);
@@ -8767,8 +8933,8 @@ function Line({
8767
8933
  }
8768
8934
 
8769
8935
  // src/FieldHistoryPanel.tsx
8770
- var import_react61 = require("react");
8771
- var import_react62 = require("@ai-matrx/records/react");
8936
+ var import_react62 = require("react");
8937
+ var import_react63 = require("@ai-matrx/records/react");
8772
8938
  var import_design_system29 = require("@ai-matrx/design-system");
8773
8939
  var import_jsx_runtime32 = require("react/jsx-runtime");
8774
8940
  function FieldHistoryPanel({
@@ -8779,15 +8945,15 @@ function FieldHistoryPanel({
8779
8945
  onOpenRecord,
8780
8946
  className
8781
8947
  }) {
8782
- const client = (0, import_react62.useRecordsClient)();
8783
- const table = (0, import_react62.useTable)(tableId);
8784
- const fields = (0, import_react62.useFields)(tableId);
8948
+ const client = (0, import_react63.useRecordsClient)();
8949
+ const table = (0, import_react63.useTable)(tableId);
8950
+ const fields = (0, import_react63.useFields)(tableId);
8785
8951
  const rights = useTableRights(table.data);
8786
- const [rows, setRows] = (0, import_react61.useState)(null);
8787
- const [error, setError] = (0, import_react61.useState)(null);
8788
- const [pending, setPending] = (0, import_react61.useState)({ phase: "idle" });
8789
- const [said, setSaid] = (0, import_react61.useState)(null);
8790
- const load = (0, import_react61.useCallback)(async () => {
8952
+ const [rows, setRows] = (0, import_react62.useState)(null);
8953
+ const [error, setError] = (0, import_react62.useState)(null);
8954
+ const [pending, setPending] = (0, import_react62.useState)({ phase: "idle" });
8955
+ const [said, setSaid] = (0, import_react62.useState)(null);
8956
+ const load = (0, import_react62.useCallback)(async () => {
8791
8957
  const answered = await client.fieldHistory(
8792
8958
  recordId ? { table_id: tableId, field_key: fieldKey, record_id: recordId } : { table_id: tableId, field_key: fieldKey }
8793
8959
  );
@@ -8798,7 +8964,7 @@ function FieldHistoryPanel({
8798
8964
  setError(null);
8799
8965
  setRows(answered.data);
8800
8966
  }, [client, tableId, fieldKey, recordId]);
8801
- (0, import_react61.useEffect)(() => {
8967
+ (0, import_react62.useEffect)(() => {
8802
8968
  void load();
8803
8969
  }, [load]);
8804
8970
  const label = (fields.data ?? []).find((f) => f.key === fieldKey)?.label || humanize(fieldKey);
@@ -8991,28 +9157,28 @@ function submissionStamp(args) {
8991
9157
  }
8992
9158
 
8993
9159
  // src/PortalBuilder.tsx
8994
- var import_react63 = require("react");
8995
- var import_react64 = require("@ai-matrx/records/react");
9160
+ var import_react64 = require("react");
9161
+ var import_react65 = require("@ai-matrx/records/react");
8996
9162
  var import_design_system30 = require("@ai-matrx/design-system");
8997
9163
  var import_jsx_runtime33 = require("react/jsx-runtime");
8998
9164
  var RESTATING_REPLACES = "Saving replaces what this portal shows: a table you untick stops being visible to every client the moment you save. Who is invited is not touched.";
8999
9165
  function PortalBuilder({ tableId, portalId, onSaved, onClose, className }) {
9000
- const client = (0, import_react64.useRecordsClient)();
9001
- const tables = (0, import_react64.useTables)();
9002
- const [title, setTitle] = (0, import_react63.useState)("");
9003
- const [clientTableId, setClientTableId] = (0, import_react63.useState)(null);
9004
- const [exposures, setExposures] = (0, import_react63.useState)({});
9005
- const [fieldsByTable, setFieldsByTable] = (0, import_react63.useState)({});
9006
- const [error, setError] = (0, import_react63.useState)(null);
9007
- const [saving, setSaving] = (0, import_react63.useState)(false);
9008
- const [savedId, setSavedId] = (0, import_react63.useState)(portalId ?? null);
9009
- const [existing, setExisting] = (0, import_react63.useState)(null);
9010
- const [loading, setLoading] = (0, import_react63.useState)(Boolean(portalId));
9011
- const [inviteEmail, setInviteEmail] = (0, import_react63.useState)("");
9012
- const [inviteRecordId, setInviteRecordId] = (0, import_react63.useState)("");
9013
- const [inviting, setInviting] = (0, import_react63.useState)(false);
9014
- const [invitationSaid, setInvitationSaid] = (0, import_react63.useState)(null);
9015
- const loadFields = (0, import_react63.useCallback)(
9166
+ const client = (0, import_react65.useRecordsClient)();
9167
+ const tables = (0, import_react65.useTables)();
9168
+ const [title, setTitle] = (0, import_react64.useState)("");
9169
+ const [clientTableId, setClientTableId] = (0, import_react64.useState)(null);
9170
+ const [exposures, setExposures] = (0, import_react64.useState)({});
9171
+ const [fieldsByTable, setFieldsByTable] = (0, import_react64.useState)({});
9172
+ const [error, setError] = (0, import_react64.useState)(null);
9173
+ const [saving, setSaving] = (0, import_react64.useState)(false);
9174
+ const [savedId, setSavedId] = (0, import_react64.useState)(portalId ?? null);
9175
+ const [existing, setExisting] = (0, import_react64.useState)(null);
9176
+ const [loading, setLoading] = (0, import_react64.useState)(Boolean(portalId));
9177
+ const [inviteEmail, setInviteEmail] = (0, import_react64.useState)("");
9178
+ const [inviteRecordId, setInviteRecordId] = (0, import_react64.useState)("");
9179
+ const [inviting, setInviting] = (0, import_react64.useState)(false);
9180
+ const [invitationSaid, setInvitationSaid] = (0, import_react64.useState)(null);
9181
+ const loadFields = (0, import_react64.useCallback)(
9016
9182
  async (id) => {
9017
9183
  if (fieldsByTable[id]) return;
9018
9184
  const answered = await client.fields({ table_id: id });
@@ -9024,7 +9190,7 @@ function PortalBuilder({ tableId, portalId, onSaved, onClose, className }) {
9024
9190
  },
9025
9191
  [client, fieldsByTable]
9026
9192
  );
9027
- (0, import_react63.useEffect)(() => {
9193
+ (0, import_react64.useEffect)(() => {
9028
9194
  if (!portalId) return;
9029
9195
  void (async () => {
9030
9196
  const answered = await client.portalCard({ portal_id: portalId });
@@ -9038,7 +9204,7 @@ function PortalBuilder({ tableId, portalId, onSaved, onClose, className }) {
9038
9204
  setClientTableId(answered.data.client_table_id);
9039
9205
  })();
9040
9206
  }, [client, portalId]);
9041
- (0, import_react63.useEffect)(() => {
9207
+ (0, import_react64.useEffect)(() => {
9042
9208
  if (!tableId) return;
9043
9209
  setExposures(
9044
9210
  (prev) => prev[tableId] ? prev : {
@@ -9048,8 +9214,8 @@ function PortalBuilder({ tableId, portalId, onSaved, onClose, className }) {
9048
9214
  );
9049
9215
  void loadFields(tableId);
9050
9216
  }, [tableId]);
9051
- const ticked = (0, import_react63.useMemo)(() => Object.values(exposures).filter((e) => e.on), [exposures]);
9052
- const tiesTo = (0, import_react63.useCallback)(
9217
+ const ticked = (0, import_react64.useMemo)(() => Object.values(exposures).filter((e) => e.on), [exposures]);
9218
+ const tiesTo = (0, import_react64.useCallback)(
9053
9219
  (id) => (fieldsByTable[id] ?? []).filter(
9054
9220
  (f) => f.type === "relation" && f.relation_target === clientTableId
9055
9221
  ),
@@ -9286,8 +9452,8 @@ function PortalBuilder({ tableId, portalId, onSaved, onClose, className }) {
9286
9452
  }
9287
9453
 
9288
9454
  // src/PortalsPanel.tsx
9289
- var import_react65 = require("react");
9290
- var import_react66 = require("@ai-matrx/records/react");
9455
+ var import_react66 = require("react");
9456
+ var import_react67 = require("@ai-matrx/records/react");
9291
9457
  var import_records6 = require("@ai-matrx/records");
9292
9458
  var import_design_system32 = require("@ai-matrx/design-system");
9293
9459
 
@@ -9352,13 +9518,13 @@ function stateWords(person) {
9352
9518
  }
9353
9519
  var PORTAL_SUGGESTION = "Let each of my customers sign in and see their own jobs and invoices, and nothing else.";
9354
9520
  function PortalsPanel({ tableId, className }) {
9355
- const client = (0, import_react66.useRecordsClient)();
9521
+ const client = (0, import_react67.useRecordsClient)();
9356
9522
  const host = useRecordsUi();
9357
- const [portals, setPortals] = (0, import_react65.useState)(null);
9358
- const [listError, setListError] = (0, import_react65.useState)(null);
9359
- const [openId, setOpenId] = (0, import_react65.useState)(null);
9360
- const [building, setBuilding] = (0, import_react65.useState)(false);
9361
- const load = (0, import_react65.useCallback)(async () => {
9523
+ const [portals, setPortals] = (0, import_react66.useState)(null);
9524
+ const [listError, setListError] = (0, import_react66.useState)(null);
9525
+ const [openId, setOpenId] = (0, import_react66.useState)(null);
9526
+ const [building, setBuilding] = (0, import_react66.useState)(false);
9527
+ const load = (0, import_react66.useCallback)(async () => {
9362
9528
  const answered = await client.portals();
9363
9529
  if (!answered.ok) {
9364
9530
  setListError(answered.error);
@@ -9368,7 +9534,7 @@ function PortalsPanel({ tableId, className }) {
9368
9534
  setListError(null);
9369
9535
  setPortals(answered.data);
9370
9536
  }, [client]);
9371
- (0, import_react65.useEffect)(() => {
9537
+ (0, import_react66.useEffect)(() => {
9372
9538
  void load();
9373
9539
  }, [load]);
9374
9540
  if (portals === null) return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(import_design_system32.Skeleton, { className: (0, import_design_system32.cn)("h-32 w-full", className) });
@@ -9450,8 +9616,8 @@ function PortalsPanel({ tableId, className }) {
9450
9616
  ] });
9451
9617
  }
9452
9618
  function CopyLink({ url }) {
9453
- const [copied, setCopied] = (0, import_react65.useState)(false);
9454
- const [shown, setShown] = (0, import_react65.useState)(false);
9619
+ const [copied, setCopied] = (0, import_react66.useState)(false);
9620
+ const [shown, setShown] = (0, import_react66.useState)(false);
9455
9621
  return /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(import_jsx_runtime35.Fragment, { children: [
9456
9622
  /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
9457
9623
  import_design_system32.Button,
@@ -9484,10 +9650,10 @@ function PortalDetail({
9484
9650
  tableId,
9485
9651
  onChanged
9486
9652
  }) {
9487
- const client = (0, import_react66.useRecordsClient)();
9488
- const [card, setCard] = (0, import_react65.useState)(null);
9489
- const [error, setError] = (0, import_react65.useState)(null);
9490
- const load = (0, import_react65.useCallback)(async () => {
9653
+ const client = (0, import_react67.useRecordsClient)();
9654
+ const [card, setCard] = (0, import_react66.useState)(null);
9655
+ const [error, setError] = (0, import_react66.useState)(null);
9656
+ const load = (0, import_react66.useCallback)(async () => {
9491
9657
  const answered = await client.portalCard({ portal_id: portalId });
9492
9658
  if (!answered.ok) {
9493
9659
  setError(answered.error);
@@ -9497,10 +9663,10 @@ function PortalDetail({
9497
9663
  setError(null);
9498
9664
  setCard(answered.data);
9499
9665
  }, [client, portalId]);
9500
- (0, import_react65.useEffect)(() => {
9666
+ (0, import_react66.useEffect)(() => {
9501
9667
  void load();
9502
9668
  }, [load]);
9503
- const revoke = (0, import_react65.useCallback)(
9669
+ const revoke = (0, import_react66.useCallback)(
9504
9670
  async (person) => {
9505
9671
  const answered = await client.portalRevoke({
9506
9672
  portal_id: portalId,
@@ -9513,7 +9679,7 @@ function PortalDetail({
9513
9679
  },
9514
9680
  [client, load, onChanged, portalId]
9515
9681
  );
9516
- const preview = (0, import_react65.useCallback)(
9682
+ const preview = (0, import_react66.useCallback)(
9517
9683
  async (person, subject) => {
9518
9684
  const answered = await client.portalPreview({
9519
9685
  portal_id: portalId,
@@ -9595,12 +9761,12 @@ function People({
9595
9761
  onRevoke,
9596
9762
  onPreview
9597
9763
  }) {
9598
- const [askingToRevoke, setAskingToRevoke] = (0, import_react65.useState)(null);
9599
- const [busy, setBusy] = (0, import_react65.useState)(false);
9600
- const [said, setSaid] = (0, import_react65.useState)(null);
9601
- const [error, setError] = (0, import_react65.useState)(null);
9602
- const [previewing, setPreviewing] = (0, import_react65.useState)(null);
9603
- const revoke = (0, import_react65.useCallback)(
9764
+ const [askingToRevoke, setAskingToRevoke] = (0, import_react66.useState)(null);
9765
+ const [busy, setBusy] = (0, import_react66.useState)(false);
9766
+ const [said, setSaid] = (0, import_react66.useState)(null);
9767
+ const [error, setError] = (0, import_react66.useState)(null);
9768
+ const [previewing, setPreviewing] = (0, import_react66.useState)(null);
9769
+ const revoke = (0, import_react66.useCallback)(
9604
9770
  async (person) => {
9605
9771
  setBusy(true);
9606
9772
  const answered = await onRevoke(person);
@@ -9677,10 +9843,10 @@ function Preview({
9677
9843
  onPreview
9678
9844
  }) {
9679
9845
  const first = card.tables[0];
9680
- const [which, setWhich] = (0, import_react65.useState)(first?.table_id ?? null);
9681
- const [rows, setRows] = (0, import_react65.useState)(null);
9682
- const [error, setError] = (0, import_react65.useState)(null);
9683
- (0, import_react65.useEffect)(() => {
9846
+ const [which, setWhich] = (0, import_react66.useState)(first?.table_id ?? null);
9847
+ const [rows, setRows] = (0, import_react66.useState)(null);
9848
+ const [error, setError] = (0, import_react66.useState)(null);
9849
+ (0, import_react66.useEffect)(() => {
9684
9850
  if (!which) return;
9685
9851
  let cancelled = false;
9686
9852
  setRows(null);
@@ -9717,16 +9883,16 @@ function Preview({
9717
9883
  ] });
9718
9884
  }
9719
9885
  function Invite({ card, onInvited }) {
9720
- const client = (0, import_react66.useRecordsClient)();
9721
- const [rows, setRows] = (0, import_react65.useState)(null);
9722
- const [titleKey, setTitleKey] = (0, import_react65.useState)(null);
9723
- const [search, setSearch] = (0, import_react65.useState)("");
9724
- const [picked, setPicked] = (0, import_react65.useState)(null);
9725
- const [email, setEmail] = (0, import_react65.useState)("");
9726
- const [busy, setBusy] = (0, import_react65.useState)(false);
9727
- const [said, setSaid] = (0, import_react65.useState)(null);
9728
- const [error, setError] = (0, import_react65.useState)(null);
9729
- (0, import_react65.useEffect)(() => {
9886
+ const client = (0, import_react67.useRecordsClient)();
9887
+ const [rows, setRows] = (0, import_react66.useState)(null);
9888
+ const [titleKey, setTitleKey] = (0, import_react66.useState)(null);
9889
+ const [search, setSearch] = (0, import_react66.useState)("");
9890
+ const [picked, setPicked] = (0, import_react66.useState)(null);
9891
+ const [email, setEmail] = (0, import_react66.useState)("");
9892
+ const [busy, setBusy] = (0, import_react66.useState)(false);
9893
+ const [said, setSaid] = (0, import_react66.useState)(null);
9894
+ const [error, setError] = (0, import_react66.useState)(null);
9895
+ (0, import_react66.useEffect)(() => {
9730
9896
  let cancelled = false;
9731
9897
  void client.list({ table_id: card.client_table_id, limit: 200 }).then((answered) => {
9732
9898
  if (cancelled) return;
@@ -9744,12 +9910,12 @@ function Invite({ card, onInvited }) {
9744
9910
  cancelled = true;
9745
9911
  };
9746
9912
  }, [client, card.client_table_id]);
9747
- const options = (0, import_react65.useMemo)(() => {
9913
+ const options = (0, import_react66.useMemo)(() => {
9748
9914
  const all = (rows ?? []).map((row) => ({ id: row.id, name: rowName(row, titleKey) }));
9749
9915
  const needle = search.trim().toLowerCase();
9750
9916
  return needle === "" ? all.slice(0, 25) : all.filter((o) => o.name.toLowerCase().includes(needle)).slice(0, 25);
9751
9917
  }, [rows, titleKey, search]);
9752
- const send = (0, import_react65.useCallback)(async () => {
9918
+ const send = (0, import_react66.useCallback)(async () => {
9753
9919
  if (!picked) return;
9754
9920
  setBusy(true);
9755
9921
  const answered = await client.portalInvite({
@@ -9828,8 +9994,8 @@ function Invite({ card, onInvited }) {
9828
9994
  }
9829
9995
 
9830
9996
  // src/DigestScheduler.tsx
9831
- var import_react67 = require("react");
9832
- var import_react68 = require("@ai-matrx/records/react");
9997
+ var import_react68 = require("react");
9998
+ var import_react69 = require("@ai-matrx/records/react");
9833
9999
  var import_design_system33 = require("@ai-matrx/design-system");
9834
10000
  var import_jsx_runtime36 = require("react/jsx-runtime");
9835
10001
  var WEEKDAYS = ["monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday"];
@@ -9853,27 +10019,27 @@ function DigestScheduler({
9853
10019
  onClose,
9854
10020
  className
9855
10021
  }) {
9856
- const client = (0, import_react68.useRecordsClient)();
10022
+ const client = (0, import_react69.useRecordsClient)();
9857
10023
  const host = useRecordsUi();
9858
- const [views, setViews] = (0, import_react67.useState)(null);
9859
- const [cadences, setCadences] = (0, import_react67.useState)([]);
9860
- const [members, setMembers] = (0, import_react67.useState)(null);
9861
- const [error, setError] = (0, import_react67.useState)(null);
9862
- const [viewId, setViewId] = (0, import_react67.useState)(savedViewId ?? "");
9863
- const [name, setName] = (0, import_react67.useState)(subjectName?.trim() ? `${subjectName.trim()} summary` : "");
9864
- const [cadence, setCadence] = (0, import_react67.useState)("weekly");
9865
- const [weekday, setWeekday] = (0, import_react67.useState)("monday");
9866
- const [time, setTime] = (0, import_react67.useState)("08:00");
9867
- const [channel, setChannel] = (0, import_react67.useState)("in_app");
9868
- const [quiet, setQuiet] = (0, import_react67.useState)(false);
9869
- const [quietFrom, setQuietFrom] = (0, import_react67.useState)("22:00");
9870
- const [quietTo, setQuietTo] = (0, import_react67.useState)("07:00");
9871
- const [recipients, setRecipients] = (0, import_react67.useState)([]);
9872
- const [saving, setSaving] = (0, import_react67.useState)(false);
9873
- const [outcomes, setOutcomes] = (0, import_react67.useState)(null);
9874
- const [preview, setPreview] = (0, import_react67.useState)(null);
9875
- const [previewing, setPreviewing] = (0, import_react67.useState)(false);
9876
- const load = (0, import_react67.useCallback)(async () => {
10024
+ const [views, setViews] = (0, import_react68.useState)(null);
10025
+ const [cadences, setCadences] = (0, import_react68.useState)([]);
10026
+ const [members, setMembers] = (0, import_react68.useState)(null);
10027
+ const [error, setError] = (0, import_react68.useState)(null);
10028
+ const [viewId, setViewId] = (0, import_react68.useState)(savedViewId ?? "");
10029
+ const [name, setName] = (0, import_react68.useState)(subjectName?.trim() ? `${subjectName.trim()} summary` : "");
10030
+ const [cadence, setCadence] = (0, import_react68.useState)("weekly");
10031
+ const [weekday, setWeekday] = (0, import_react68.useState)("monday");
10032
+ const [time, setTime] = (0, import_react68.useState)("08:00");
10033
+ const [channel, setChannel] = (0, import_react68.useState)("in_app");
10034
+ const [quiet, setQuiet] = (0, import_react68.useState)(false);
10035
+ const [quietFrom, setQuietFrom] = (0, import_react68.useState)("22:00");
10036
+ const [quietTo, setQuietTo] = (0, import_react68.useState)("07:00");
10037
+ const [recipients, setRecipients] = (0, import_react68.useState)([]);
10038
+ const [saving, setSaving] = (0, import_react68.useState)(false);
10039
+ const [outcomes, setOutcomes] = (0, import_react68.useState)(null);
10040
+ const [preview, setPreview] = (0, import_react68.useState)(null);
10041
+ const [previewing, setPreviewing] = (0, import_react68.useState)(false);
10042
+ const load = (0, import_react68.useCallback)(async () => {
9877
10043
  const [saved, offered] = await Promise.all([
9878
10044
  // The store's own door onto `platform.saved_view`, narrowed in SQL to
9879
10045
  // Tables this person can already open — never a grant on the table behind it.
@@ -9892,15 +10058,15 @@ function DigestScheduler({
9892
10058
  setMembers([]);
9893
10059
  }
9894
10060
  }, [client, tableId, host]);
9895
- (0, import_react67.useEffect)(() => {
10061
+ (0, import_react68.useEffect)(() => {
9896
10062
  void load();
9897
10063
  }, [load]);
9898
- const schedule = (0, import_react67.useMemo)(() => {
10064
+ const schedule = (0, import_react68.useMemo)(() => {
9899
10065
  if (cadence === "weekly") return `${weekday} ${time}`;
9900
10066
  if (cadence === "daily") return time;
9901
10067
  return null;
9902
10068
  }, [cadence, weekday, time]);
9903
- const quietHours = (0, import_react67.useMemo)(
10069
+ const quietHours = (0, import_react68.useMemo)(
9904
10070
  () => quiet ? { start: quietFrom, end: quietTo } : null,
9905
10071
  [quiet, quietFrom, quietTo]
9906
10072
  );
@@ -10122,8 +10288,8 @@ function DigestScheduler({
10122
10288
  }
10123
10289
 
10124
10290
  // src/SubscriptionsPanel.tsx
10125
- var import_react69 = require("react");
10126
- var import_react70 = require("@ai-matrx/records/react");
10291
+ var import_react70 = require("react");
10292
+ var import_react71 = require("@ai-matrx/records/react");
10127
10293
  var import_design_system34 = require("@ai-matrx/design-system");
10128
10294
  var import_jsx_runtime37 = require("react/jsx-runtime");
10129
10295
  function whenItFires(subscription) {
@@ -10138,14 +10304,14 @@ var CHANNEL_WORDS2 = {
10138
10304
  };
10139
10305
  var DIGEST_SUGGESTION = "Email me a summary of this every Monday at 8 in the morning.";
10140
10306
  function SubscriptionsPanel({ tableId, className }) {
10141
- const client = (0, import_react70.useRecordsClient)();
10142
- const [rows, setRows] = (0, import_react69.useState)(null);
10143
- const [error, setError] = (0, import_react69.useState)(null);
10144
- const [busy, setBusy] = (0, import_react69.useState)(null);
10145
- const [preview, setPreview] = (0, import_react69.useState)(null);
10146
- const [scheduling, setScheduling] = (0, import_react69.useState)(false);
10307
+ const client = (0, import_react71.useRecordsClient)();
10308
+ const [rows, setRows] = (0, import_react70.useState)(null);
10309
+ const [error, setError] = (0, import_react70.useState)(null);
10310
+ const [busy, setBusy] = (0, import_react70.useState)(null);
10311
+ const [preview, setPreview] = (0, import_react70.useState)(null);
10312
+ const [scheduling, setScheduling] = (0, import_react70.useState)(false);
10147
10313
  const host = useRecordsUi();
10148
- const load = (0, import_react69.useCallback)(async () => {
10314
+ const load = (0, import_react70.useCallback)(async () => {
10149
10315
  const answered = await client.subscriptions({ table_id: tableId });
10150
10316
  if (!answered.ok) {
10151
10317
  setError(answered.error);
@@ -10155,10 +10321,10 @@ function SubscriptionsPanel({ tableId, className }) {
10155
10321
  setError(null);
10156
10322
  setRows(answered.data);
10157
10323
  }, [client, tableId]);
10158
- (0, import_react69.useEffect)(() => {
10324
+ (0, import_react70.useEffect)(() => {
10159
10325
  void load();
10160
10326
  }, [load]);
10161
- const flip = (0, import_react69.useCallback)(
10327
+ const flip = (0, import_react70.useCallback)(
10162
10328
  async (subscription, on) => {
10163
10329
  setBusy(subscription.rule_id);
10164
10330
  const answered = await client.subscriptionMute({
@@ -10174,7 +10340,7 @@ function SubscriptionsPanel({ tableId, className }) {
10174
10340
  },
10175
10341
  [client, load]
10176
10342
  );
10177
- const showOne = (0, import_react69.useCallback)(
10343
+ const showOne = (0, import_react70.useCallback)(
10178
10344
  async (subscription) => {
10179
10345
  setBusy(subscription.rule_id);
10180
10346
  const answered = await client.subscriptionPreview({ rule_id: subscription.rule_id });
@@ -10307,14 +10473,14 @@ function SubscriptionsPanel({ tableId, className }) {
10307
10473
  }
10308
10474
 
10309
10475
  // src/FormBuilder.tsx
10310
- var import_react73 = require("react");
10311
- var import_react74 = require("@ai-matrx/records/react");
10476
+ var import_react74 = require("react");
10477
+ var import_react75 = require("@ai-matrx/records/react");
10312
10478
  var import_records7 = require("@ai-matrx/records");
10313
10479
  var import_design_system36 = require("@ai-matrx/design-system");
10314
10480
 
10315
10481
  // src/FormRunner.tsx
10316
- var import_react71 = require("react");
10317
- var import_react72 = require("@ai-matrx/records/react");
10482
+ var import_react72 = require("react");
10483
+ var import_react73 = require("@ai-matrx/records/react");
10318
10484
  var import_design_system35 = require("@ai-matrx/design-system");
10319
10485
  var import_jsx_runtime38 = require("react/jsx-runtime");
10320
10486
  function FormRunner(props) {
@@ -10324,10 +10490,10 @@ function FormRunner(props) {
10324
10490
  return /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(ConnectedFormRunner, { ...props });
10325
10491
  }
10326
10492
  function ConnectedFormRunner(props) {
10327
- const client = (0, import_react72.useOptionalRecordsClient)();
10328
- const fields = (0, import_react72.useFields)(props.form.subject);
10493
+ const client = (0, import_react73.useOptionalRecordsClient)();
10494
+ const fields = (0, import_react73.useFields)(props.form.subject);
10329
10495
  const { form, className } = props;
10330
- const submit = (0, import_react71.useCallback)(
10496
+ const submit = (0, import_react72.useCallback)(
10331
10497
  async (values) => {
10332
10498
  if (!client) {
10333
10499
  return {
@@ -10350,7 +10516,7 @@ function ConnectedFormRunner(props) {
10350
10516
  },
10351
10517
  [client, form]
10352
10518
  );
10353
- const evaluate = (0, import_react71.useCallback)(
10519
+ const evaluate = (0, import_react72.useCallback)(
10354
10520
  async (expr, values) => {
10355
10521
  if (!client) return null;
10356
10522
  const answered = await client.ruleEval({ expr, values });
@@ -10384,16 +10550,16 @@ function FormStage({
10384
10550
  connected = false
10385
10551
  }) {
10386
10552
  const host = useRecordsUi();
10387
- const [answers, setAnswers] = (0, import_react71.useState)({});
10388
- const [at, setAt] = (0, import_react71.useState)(0);
10389
- const [error, setError] = (0, import_react71.useState)(null);
10390
- const [refusal, setRefusal] = (0, import_react71.useState)(null);
10391
- const [writing, setWriting] = (0, import_react71.useState)(false);
10392
- const [done, setDone] = (0, import_react71.useState)(null);
10393
- const [hidden, setHidden] = (0, import_react71.useState)({});
10394
- const decoy = (0, import_react71.useRef)("");
10395
- const stage = (0, import_react71.useRef)(null);
10396
- const questions = (0, import_react71.useMemo)(() => {
10553
+ const [answers, setAnswers] = (0, import_react72.useState)({});
10554
+ const [at, setAt] = (0, import_react72.useState)(0);
10555
+ const [error, setError] = (0, import_react72.useState)(null);
10556
+ const [refusal, setRefusal] = (0, import_react72.useState)(null);
10557
+ const [writing, setWriting] = (0, import_react72.useState)(false);
10558
+ const [done, setDone] = (0, import_react72.useState)(null);
10559
+ const [hidden, setHidden] = (0, import_react72.useState)({});
10560
+ const decoy = (0, import_react72.useRef)("");
10561
+ const stage = (0, import_react72.useRef)(null);
10562
+ const questions = (0, import_react72.useMemo)(() => {
10397
10563
  const byKey = new Map((fields ?? []).map((f) => [f.key, f]));
10398
10564
  return (form.questions ?? []).map((q) => {
10399
10565
  const field = byKey.get(q.field) ?? null;
@@ -10407,7 +10573,7 @@ function FormStage({
10407
10573
  };
10408
10574
  });
10409
10575
  }, [fields, form.questions]);
10410
- (0, import_react71.useEffect)(() => {
10576
+ (0, import_react72.useEffect)(() => {
10411
10577
  let cancelled = false;
10412
10578
  const conditional = questions.filter((q) => q.showIf);
10413
10579
  if (conditional.length === 0 || !evaluate) return;
@@ -10441,7 +10607,7 @@ function FormStage({
10441
10607
  const v = answers[q.key];
10442
10608
  return q.required && (v === void 0 || v === null || v === "");
10443
10609
  });
10444
- const submit = (0, import_react71.useCallback)(async () => {
10610
+ const submit = (0, import_react72.useCallback)(async () => {
10445
10611
  if (preview) {
10446
10612
  setDone("preview");
10447
10613
  return;
@@ -10478,7 +10644,7 @@ function FormStage({
10478
10644
  if (event.shiftKey) retreat();
10479
10645
  else advance();
10480
10646
  }
10481
- (0, import_react71.useEffect)(() => {
10647
+ (0, import_react72.useEffect)(() => {
10482
10648
  const input = stage.current?.querySelector(
10483
10649
  "input:not([tabindex='-1']), textarea, select, [role='combobox']"
10484
10650
  );
@@ -10572,7 +10738,7 @@ function Question({
10572
10738
  onChange,
10573
10739
  upload
10574
10740
  }) {
10575
- const [uploadError, setUploadError] = (0, import_react71.useState)(null);
10741
+ const [uploadError, setUploadError] = (0, import_react72.useState)(null);
10576
10742
  const field = question.field;
10577
10743
  if (!field) return null;
10578
10744
  const id = `form-${field.key}`;
@@ -10604,26 +10770,48 @@ function Question({
10604
10770
  ] });
10605
10771
  }
10606
10772
 
10773
+ // src/publicQuestions.ts
10774
+ var CANNOT_ASK = {
10775
+ relation: "points at a record in another table, and somebody with no account cannot see that table to pick from it",
10776
+ member: "is a person in this organization, and somebody outside it has no way to choose one",
10777
+ attachment: "holds a file in your own store, and a public page has nowhere to put one yet",
10778
+ formula: "is worked out by the store, so there is nothing for anybody to answer",
10779
+ lookup: "is read through a relation, so the store fills it in",
10780
+ rollup: "is added up by the store, so there is nothing for anybody to answer"
10781
+ };
10782
+ function publiclyAnswerable(field) {
10783
+ return !(field.type in CANNOT_ASK);
10784
+ }
10785
+ function askableFields(fields, hidden = []) {
10786
+ return fields.filter((f) => publiclyAnswerable(f) && !hidden.includes(f.key));
10787
+ }
10788
+ function whyNotAskable(fields, hidden = []) {
10789
+ const left = fields.filter((f) => !publiclyAnswerable(f) && !hidden.includes(f.key));
10790
+ if (left.length === 0) return null;
10791
+ const said = left.map((f) => `${f.label || f.key} ${CANNOT_ASK[f.type]}`);
10792
+ return said.length === 1 ? `${said[0]}, so it is not offered here.` : `These are not offered here: ${said.join("; ")}.`;
10793
+ }
10794
+
10607
10795
  // src/FormBuilder.tsx
10608
10796
  var import_jsx_runtime39 = require("react/jsx-runtime");
10609
10797
  function FormBuilder({ tableId, seed, activeFormId, onActiveForm, className }) {
10610
- const client = (0, import_react74.useRecordsClient)();
10798
+ const client = (0, import_react75.useRecordsClient)();
10611
10799
  const host = useRecordsUi();
10612
10800
  const claimSeed = useSeedGuard();
10613
- const table = (0, import_react74.useTable)(tableId);
10801
+ const table = (0, import_react75.useTable)(tableId);
10614
10802
  const rights = useTableRights(table.data);
10615
- const fields = (0, import_react74.useFields)(tableId);
10616
- const [forms, setForms] = (0, import_react73.useState)(null);
10617
- const [error, setError] = (0, import_react73.useState)(null);
10618
- const [activeId, setActiveId] = (0, import_react73.useState)(activeFormId ?? null);
10619
- const [draft, setDraft] = (0, import_react73.useState)(null);
10620
- const [saving, setSaving] = (0, import_react73.useState)(false);
10621
- const [saved, setSaved] = (0, import_react73.useState)(null);
10622
- const [publishing, setPublishing] = (0, import_react73.useState)(false);
10623
- const [copied, setCopied] = (0, import_react73.useState)(false);
10624
- const [shownUrl, setShownUrl] = (0, import_react73.useState)(null);
10803
+ const fields = (0, import_react75.useFields)(tableId);
10804
+ const [forms, setForms] = (0, import_react74.useState)(null);
10805
+ const [error, setError] = (0, import_react74.useState)(null);
10806
+ const [activeId, setActiveId] = (0, import_react74.useState)(activeFormId ?? null);
10807
+ const [draft, setDraft] = (0, import_react74.useState)(null);
10808
+ const [saving, setSaving] = (0, import_react74.useState)(false);
10809
+ const [saved, setSaved] = (0, import_react74.useState)(null);
10810
+ const [publishing, setPublishing] = (0, import_react74.useState)(false);
10811
+ const [copied, setCopied] = (0, import_react74.useState)(false);
10812
+ const [shownUrl, setShownUrl] = (0, import_react74.useState)(null);
10625
10813
  const publicOrigin = host.publicOrigin ?? (typeof window === "undefined" ? "" : window.location.origin);
10626
- const load = (0, import_react73.useCallback)(async () => {
10814
+ const load = (0, import_react74.useCallback)(async () => {
10627
10815
  const answered = await client.forms({ table_id: tableId });
10628
10816
  if (!answered.ok) {
10629
10817
  setError(answered.error);
@@ -10650,17 +10838,17 @@ function FormBuilder({ tableId, seed, activeFormId, onActiveForm, className }) {
10650
10838
  setError(null);
10651
10839
  setForms(mine);
10652
10840
  }, [client, tableId, seed, claimSeed]);
10653
- (0, import_react73.useEffect)(() => {
10841
+ (0, import_react74.useEffect)(() => {
10654
10842
  void load();
10655
10843
  }, [load]);
10656
- (0, import_react73.useEffect)(() => {
10844
+ (0, import_react74.useEffect)(() => {
10657
10845
  if (!forms || forms.length === 0) return;
10658
10846
  const chosen = forms.find((f) => f.id === (activeFormId ?? activeId)) ?? forms[0];
10659
10847
  if (chosen.id !== activeId) setActiveId(chosen.id);
10660
10848
  setDraft(chosen);
10661
10849
  onActiveForm?.(chosen);
10662
10850
  }, [forms, activeFormId]);
10663
- const byKey = (0, import_react73.useMemo)(() => new Map((fields.data ?? []).map((f) => [f.key, f])), [fields.data]);
10851
+ const byKey = (0, import_react74.useMemo)(() => new Map((fields.data ?? []).map((f) => [f.key, f])), [fields.data]);
10664
10852
  function patch(change) {
10665
10853
  setDraft((prev) => prev ? { ...prev, ...change } : prev);
10666
10854
  setSaved(null);
@@ -10836,7 +11024,7 @@ function FormBuilder({ tableId, seed, activeFormId, onActiveForm, className }) {
10836
11024
  " fields"
10837
11025
  ] })
10838
11026
  ] }),
10839
- (fields.data ?? []).map((field) => {
11027
+ askableFields(fields.data ?? []).map((field) => {
10840
11028
  const index = draft.questions.findIndex((q) => q.field === field.key);
10841
11029
  const asked = index >= 0;
10842
11030
  const question = asked ? draft.questions[index] : null;
@@ -10888,6 +11076,7 @@ function FormBuilder({ tableId, seed, activeFormId, onActiveForm, className }) {
10888
11076
  ] }) : null
10889
11077
  ] }, field.id);
10890
11078
  }),
11079
+ whyNotAskable(fields.data ?? []) ? /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("p", { className: "text-xs text-muted-foreground", children: whyNotAskable(fields.data ?? []) }) : null,
10891
11080
  draft.questions.filter((q) => !byKey.has(q.field)).map((q) => /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("p", { className: "text-xs text-destructive", children: [
10892
11081
  'This form asks for "',
10893
11082
  q.field,
@@ -10954,13 +11143,13 @@ function Condition({
10954
11143
  onChange
10955
11144
  }) {
10956
11145
  return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
10957
- ConditionRow,
11146
+ ConditionGroup,
10958
11147
  {
10959
11148
  lead: "Ask only when",
10960
11149
  expr: question.showIf,
10961
11150
  fields: fieldKeys,
10962
11151
  onChange,
10963
- className: "col-span-2 flex items-center gap-1 text-xs"
11152
+ className: "col-span-2 flex flex-col gap-1 text-xs"
10964
11153
  }
10965
11154
  );
10966
11155
  }
@@ -11050,13 +11239,13 @@ function groupLabel(groups) {
11050
11239
  }
11051
11240
 
11052
11241
  // src/chartFrame.tsx
11053
- var import_react75 = require("react");
11242
+ var import_react76 = require("react");
11054
11243
  var import_design_system37 = require("@ai-matrx/design-system");
11055
11244
  var import_jsx_runtime40 = require("react/jsx-runtime");
11056
11245
  function useMeasuredWidth(fallback = 480) {
11057
- const ref = (0, import_react75.useRef)(null);
11058
- const [width, setWidth] = (0, import_react75.useState)(fallback);
11059
- (0, import_react75.useEffect)(() => {
11246
+ const ref = (0, import_react76.useRef)(null);
11247
+ const [width, setWidth] = (0, import_react76.useState)(fallback);
11248
+ (0, import_react76.useEffect)(() => {
11060
11249
  const node = ref.current;
11061
11250
  if (!node) return;
11062
11251
  const apply = () => {
@@ -11086,7 +11275,7 @@ function ChartFrame({
11086
11275
  children
11087
11276
  }) {
11088
11277
  const [ref, width] = useMeasuredWidth();
11089
- const chartId = `records-chart-${(0, import_react75.useId)().replace(/:/g, "")}`;
11278
+ const chartId = `records-chart-${(0, import_react76.useId)().replace(/:/g, "")}`;
11090
11279
  return /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
11091
11280
  "div",
11092
11281
  {
@@ -11180,24 +11369,24 @@ function isSignatureField(field) {
11180
11369
  }
11181
11370
 
11182
11371
  // src/DocTemplate.tsx
11183
- var import_react76 = require("react");
11184
- var import_react77 = require("@ai-matrx/records/react");
11372
+ var import_react77 = require("react");
11373
+ var import_react78 = require("@ai-matrx/records/react");
11185
11374
  var import_design_system38 = require("@ai-matrx/design-system");
11186
11375
  var import_jsx_runtime41 = require("react/jsx-runtime");
11187
11376
  function DocTemplate({ tableId, seed, activeTemplateId, onActiveTemplate, className }) {
11188
- const client = (0, import_react77.useRecordsClient)();
11377
+ const client = (0, import_react78.useRecordsClient)();
11189
11378
  const claimSeed = useSeedGuard();
11190
- const table = (0, import_react77.useTable)(tableId);
11379
+ const table = (0, import_react78.useTable)(tableId);
11191
11380
  const rights = useTableRights(table.data);
11192
- const fields = (0, import_react77.useFields)(tableId);
11193
- const [templates, setTemplates] = (0, import_react76.useState)(null);
11194
- const [error, setError] = (0, import_react76.useState)(null);
11195
- const [activeId, setActiveId] = (0, import_react76.useState)(activeTemplateId ?? null);
11196
- const [draftName, setDraftName] = (0, import_react76.useState)("");
11197
- const [draftBody, setDraftBody] = (0, import_react76.useState)("");
11198
- const [unresolved, setUnresolved] = (0, import_react76.useState)([]);
11199
- const [saving, setSaving] = (0, import_react76.useState)(false);
11200
- const load = (0, import_react76.useCallback)(async () => {
11381
+ const fields = (0, import_react78.useFields)(tableId);
11382
+ const [templates, setTemplates] = (0, import_react77.useState)(null);
11383
+ const [error, setError] = (0, import_react77.useState)(null);
11384
+ const [activeId, setActiveId] = (0, import_react77.useState)(activeTemplateId ?? null);
11385
+ const [draftName, setDraftName] = (0, import_react77.useState)("");
11386
+ const [draftBody, setDraftBody] = (0, import_react77.useState)("");
11387
+ const [unresolved, setUnresolved] = (0, import_react77.useState)([]);
11388
+ const [saving, setSaving] = (0, import_react77.useState)(false);
11389
+ const load = (0, import_react77.useCallback)(async () => {
11201
11390
  const held = await client.docTemplates({ table_id: tableId });
11202
11391
  if (!held.ok) {
11203
11392
  setError(held.error);
@@ -11228,10 +11417,10 @@ function DocTemplate({ tableId, seed, activeTemplateId, onActiveTemplate, classN
11228
11417
  setError(null);
11229
11418
  setTemplates(rows);
11230
11419
  }, [client, tableId, seed, fields.data]);
11231
- (0, import_react76.useEffect)(() => {
11420
+ (0, import_react77.useEffect)(() => {
11232
11421
  void load();
11233
11422
  }, [load]);
11234
- (0, import_react76.useEffect)(() => {
11423
+ (0, import_react77.useEffect)(() => {
11235
11424
  if (!templates || templates.length === 0) return;
11236
11425
  const chosen = templates.find((t) => t.id === (activeTemplateId ?? activeId)) ?? templates[0];
11237
11426
  if (chosen.id !== activeId) setActiveId(chosen.id);
@@ -11239,7 +11428,7 @@ function DocTemplate({ tableId, seed, activeTemplateId, onActiveTemplate, classN
11239
11428
  setDraftBody(chosen.body);
11240
11429
  onActiveTemplate?.(chosen);
11241
11430
  }, [templates, activeTemplateId]);
11242
- (0, import_react76.useEffect)(() => {
11431
+ (0, import_react77.useEffect)(() => {
11243
11432
  let cancelled = false;
11244
11433
  if (draftBody.trim() === "") {
11245
11434
  setUnresolved([]);
@@ -11359,19 +11548,19 @@ function DocTemplate({ tableId, seed, activeTemplateId, onActiveTemplate, classN
11359
11548
  }
11360
11549
 
11361
11550
  // src/DocRender.tsx
11362
- var import_react78 = require("react");
11363
- var import_react79 = require("@ai-matrx/records/react");
11551
+ var import_react79 = require("react");
11552
+ var import_react80 = require("@ai-matrx/records/react");
11364
11553
  var import_design_system39 = require("@ai-matrx/design-system");
11365
11554
  var import_jsx_runtime42 = require("react/jsx-runtime");
11366
11555
  function DocRender({ templateId, recordId, filename, onRendered, className }) {
11367
- const client = (0, import_react79.useRecordsClient)();
11368
- const [preview, setPreview] = (0, import_react78.useState)(null);
11369
- const [renders, setRenders] = (0, import_react78.useState)(null);
11370
- const [showing, setShowing] = (0, import_react78.useState)(null);
11371
- const [error, setError] = (0, import_react78.useState)(null);
11372
- const [busy, setBusy] = (0, import_react78.useState)(null);
11373
- const paper = (0, import_react78.useRef)(null);
11374
- const load = (0, import_react78.useCallback)(async () => {
11556
+ const client = (0, import_react80.useRecordsClient)();
11557
+ const [preview, setPreview] = (0, import_react79.useState)(null);
11558
+ const [renders, setRenders] = (0, import_react79.useState)(null);
11559
+ const [showing, setShowing] = (0, import_react79.useState)(null);
11560
+ const [error, setError] = (0, import_react79.useState)(null);
11561
+ const [busy, setBusy] = (0, import_react79.useState)(null);
11562
+ const paper = (0, import_react79.useRef)(null);
11563
+ const load = (0, import_react79.useCallback)(async () => {
11375
11564
  const [body, held] = await Promise.all([
11376
11565
  client.docRenderBody({ template_id: templateId, record_id: recordId }),
11377
11566
  client.docRenders({ record_id: recordId })
@@ -11388,7 +11577,7 @@ function DocRender({ templateId, recordId, filename, onRendered, className }) {
11388
11577
  setPreview(body.data);
11389
11578
  setRenders(held.data.filter((r) => r.template_id === templateId));
11390
11579
  }, [client, templateId, recordId]);
11391
- (0, import_react78.useEffect)(() => {
11580
+ (0, import_react79.useEffect)(() => {
11392
11581
  void load();
11393
11582
  }, [load]);
11394
11583
  async function freeze() {
@@ -11472,22 +11661,22 @@ function DocRender({ templateId, recordId, filename, onRendered, className }) {
11472
11661
  }
11473
11662
 
11474
11663
  // src/SignBlock.tsx
11475
- var import_react80 = require("react");
11476
- var import_react81 = require("@ai-matrx/records/react");
11477
- var import_design_system40 = require("@ai-matrx/design-system");
11664
+ var import_react81 = require("react");
11478
11665
  var import_react82 = require("@ai-matrx/records/react");
11666
+ var import_design_system40 = require("@ai-matrx/design-system");
11667
+ var import_react83 = require("@ai-matrx/records/react");
11479
11668
  var import_jsx_runtime43 = require("react/jsx-runtime");
11480
11669
  function SignBlock({ tableId, recordId, render, className }) {
11481
- const client = (0, import_react81.useRecordsClient)();
11482
- const table = (0, import_react82.useTable)(tableId);
11670
+ const client = (0, import_react82.useRecordsClient)();
11671
+ const table = (0, import_react83.useTable)(tableId);
11483
11672
  const rights = useTableRights(table.data);
11484
- const fields = (0, import_react81.useFields)(tableId);
11485
- const [signatures, setSignatures] = (0, import_react80.useState)(null);
11486
- const [verdicts, setVerdicts] = (0, import_react80.useState)({});
11487
- const [error, setError] = (0, import_react80.useState)(null);
11488
- const [name, setName] = (0, import_react80.useState)("");
11489
- const [busy, setBusy] = (0, import_react80.useState)(false);
11490
- const load = (0, import_react80.useCallback)(async () => {
11673
+ const fields = (0, import_react82.useFields)(tableId);
11674
+ const [signatures, setSignatures] = (0, import_react81.useState)(null);
11675
+ const [verdicts, setVerdicts] = (0, import_react81.useState)({});
11676
+ const [error, setError] = (0, import_react81.useState)(null);
11677
+ const [name, setName] = (0, import_react81.useState)("");
11678
+ const [busy, setBusy] = (0, import_react81.useState)(false);
11679
+ const load = (0, import_react81.useCallback)(async () => {
11491
11680
  const held = await client.docSignatures({ record_id: recordId });
11492
11681
  if (!held.ok) {
11493
11682
  setError(held.error);
@@ -11502,7 +11691,7 @@ function SignBlock({ tableId, recordId, render, className }) {
11502
11691
  }
11503
11692
  setVerdicts(answers);
11504
11693
  }, [client, recordId]);
11505
- (0, import_react80.useEffect)(() => {
11694
+ (0, import_react81.useEffect)(() => {
11506
11695
  void load();
11507
11696
  }, [load]);
11508
11697
  async function sign(field) {
@@ -11609,8 +11798,8 @@ function SignBlock({ tableId, recordId, render, className }) {
11609
11798
  }
11610
11799
 
11611
11800
  // src/NotifyRuleEditor.tsx
11612
- var import_react83 = require("react");
11613
- var import_react84 = require("@ai-matrx/records/react");
11801
+ var import_react84 = require("react");
11802
+ var import_react85 = require("@ai-matrx/records/react");
11614
11803
  var import_design_system41 = require("@ai-matrx/design-system");
11615
11804
  var import_jsx_runtime44 = require("react/jsx-runtime");
11616
11805
  var CADENCE_WORDS2 = {
@@ -11625,16 +11814,16 @@ var CHANNEL_WORDS3 = {
11625
11814
  sms: "by text"
11626
11815
  };
11627
11816
  function NotifyRuleEditor({ tableId, seed, className }) {
11628
- const client = (0, import_react84.useRecordsClient)();
11817
+ const client = (0, import_react85.useRecordsClient)();
11629
11818
  const host = useRecordsUi();
11630
- const table = (0, import_react84.useTable)(tableId);
11819
+ const table = (0, import_react85.useTable)(tableId);
11631
11820
  const rights = useTableRights(table.data);
11632
- const [subscriptions, setSubscriptions] = (0, import_react83.useState)(null);
11633
- const [cadences, setCadences] = (0, import_react83.useState)([]);
11634
- const [views, setViews] = (0, import_react83.useState)(null);
11635
- const [error, setError] = (0, import_react83.useState)(null);
11636
- const [busy, setBusy] = (0, import_react83.useState)(false);
11637
- const load = (0, import_react83.useCallback)(async () => {
11821
+ const [subscriptions, setSubscriptions] = (0, import_react84.useState)(null);
11822
+ const [cadences, setCadences] = (0, import_react84.useState)([]);
11823
+ const [views, setViews] = (0, import_react84.useState)(null);
11824
+ const [error, setError] = (0, import_react84.useState)(null);
11825
+ const [busy, setBusy] = (0, import_react84.useState)(false);
11826
+ const load = (0, import_react84.useCallback)(async () => {
11638
11827
  const [held, offered] = await Promise.all([
11639
11828
  // THE PERSON'S OWN DOOR, not the notifier's. It answers what is addressed
11640
11829
  // to them plus — only where they hold admin on this Table — anyone's over
@@ -11654,10 +11843,10 @@ function NotifyRuleEditor({ tableId, seed, className }) {
11654
11843
  if (host.savedViews) setViews(await host.savedViews());
11655
11844
  else setViews(null);
11656
11845
  }, [client, host, tableId]);
11657
- (0, import_react83.useEffect)(() => {
11846
+ (0, import_react84.useEffect)(() => {
11658
11847
  void load();
11659
11848
  }, [load]);
11660
- const write = (0, import_react83.useCallback)(
11849
+ const write = (0, import_react84.useCallback)(
11661
11850
  async (spec) => {
11662
11851
  const declared = await client.subscriptionDeclare({
11663
11852
  table_id: tableId,
@@ -11682,7 +11871,7 @@ function NotifyRuleEditor({ tableId, seed, className }) {
11682
11871
  },
11683
11872
  [client, tableId]
11684
11873
  );
11685
- (0, import_react83.useEffect)(() => {
11874
+ (0, import_react84.useEffect)(() => {
11686
11875
  if (!subscriptions || !seed || seed.length === 0) return;
11687
11876
  const missing = seed.filter((s) => !subscriptions.some((held) => held.name === s.name));
11688
11877
  if (missing.length === 0) return;
@@ -11825,7 +12014,7 @@ function NotifyRuleEditor({ tableId, seed, className }) {
11825
12014
  }
11826
12015
 
11827
12016
  // src/ChartBlock.tsx
11828
- var import_react85 = require("react");
12017
+ var import_react86 = require("react");
11829
12018
  var import_recharts = require("recharts");
11830
12019
  var import_records8 = require("@ai-matrx/records");
11831
12020
  var import_core6 = require("@ai-matrx/records/core");
@@ -11850,7 +12039,7 @@ function ChartBlock({ block, subject, className }) {
11850
12039
  const measures = block.measures && block.measures.length > 0 ? block.measures : [{ op: "count" }];
11851
12040
  const primary = (0, import_records8.measureKey)(measures[0]);
11852
12041
  const series = [primary];
11853
- const points = (0, import_react85.useMemo)(() => {
12042
+ const points = (0, import_react86.useMemo)(() => {
11854
12043
  if (kind === "stuck") return [];
11855
12044
  const rows = block.rows ?? [];
11856
12045
  return rows.map((row) => ({
@@ -11862,7 +12051,7 @@ function ChartBlock({ block, subject, className }) {
11862
12051
  n: row.row_count
11863
12052
  }));
11864
12053
  }, [block.rows, kind, series.join("|")]);
11865
- const config = (0, import_react85.useMemo)(() => {
12054
+ const config = (0, import_react86.useMemo)(() => {
11866
12055
  const out = {};
11867
12056
  series.forEach((key, index) => {
11868
12057
  out[key] = {
@@ -12123,25 +12312,25 @@ function Drawing({
12123
12312
  }
12124
12313
 
12125
12314
  // src/DashboardCanvas.tsx
12126
- var import_react86 = require("react");
12127
- var import_react87 = require("@ai-matrx/records/react");
12315
+ var import_react87 = require("react");
12316
+ var import_react88 = require("@ai-matrx/records/react");
12128
12317
  var import_design_system43 = require("@ai-matrx/design-system");
12129
12318
  var import_jsx_runtime46 = require("react/jsx-runtime");
12130
12319
  function DashboardCanvas({ tableId, activeDashboardId, filter, className }) {
12131
- const client = (0, import_react87.useRecordsClient)();
12320
+ const client = (0, import_react88.useRecordsClient)();
12132
12321
  const host = useRecordsUi();
12133
- const table = (0, import_react87.useTable)(tableId);
12322
+ const table = (0, import_react88.useTable)(tableId);
12134
12323
  const rights = useTableRights(table.data);
12135
- const fields = (0, import_react87.useFields)(tableId);
12136
- const [boards, setBoards] = (0, import_react86.useState)(null);
12137
- const [error, setError] = (0, import_react86.useState)(null);
12138
- const [activeId, setActiveId] = (0, import_react86.useState)(activeDashboardId ?? null);
12139
- const [run, setRun] = (0, import_react86.useState)(null);
12140
- const [running, setRunning] = (0, import_react86.useState)(false);
12141
- const [question, setQuestion] = (0, import_react86.useState)("");
12142
- const [asking, setAsking] = (0, import_react86.useState)(false);
12143
- const [scheduling, setScheduling] = (0, import_react86.useState)(false);
12144
- const load = (0, import_react86.useCallback)(async () => {
12324
+ const fields = (0, import_react88.useFields)(tableId);
12325
+ const [boards, setBoards] = (0, import_react87.useState)(null);
12326
+ const [error, setError] = (0, import_react87.useState)(null);
12327
+ const [activeId, setActiveId] = (0, import_react87.useState)(activeDashboardId ?? null);
12328
+ const [run, setRun] = (0, import_react87.useState)(null);
12329
+ const [running, setRunning] = (0, import_react87.useState)(false);
12330
+ const [question, setQuestion] = (0, import_react87.useState)("");
12331
+ const [asking, setAsking] = (0, import_react87.useState)(false);
12332
+ const [scheduling, setScheduling] = (0, import_react87.useState)(false);
12333
+ const load = (0, import_react87.useCallback)(async () => {
12145
12334
  const answered = await client.dashboards({ table_id: tableId });
12146
12335
  if (!answered.ok) {
12147
12336
  setError(answered.error);
@@ -12150,17 +12339,17 @@ function DashboardCanvas({ tableId, activeDashboardId, filter, className }) {
12150
12339
  setError(null);
12151
12340
  setBoards(answered.data.map(dashboardFromSummary));
12152
12341
  }, [client, tableId]);
12153
- (0, import_react86.useEffect)(() => {
12342
+ (0, import_react87.useEffect)(() => {
12154
12343
  void load();
12155
12344
  }, [load]);
12156
- (0, import_react86.useEffect)(() => {
12345
+ (0, import_react87.useEffect)(() => {
12157
12346
  if (!boards || boards.length === 0) return;
12158
12347
  const chosen = boards.find((d) => d.id === (activeDashboardId ?? activeId)) ?? boards[0];
12159
12348
  if (chosen.id !== activeId) setActiveId(chosen.id);
12160
12349
  }, [boards, activeDashboardId]);
12161
- const board = (0, import_react86.useMemo)(() => boards?.find((d) => d.id === activeId) ?? null, [boards, activeId]);
12350
+ const board = (0, import_react87.useMemo)(() => boards?.find((d) => d.id === activeId) ?? null, [boards, activeId]);
12162
12351
  const filterKey = JSON.stringify(filter ?? {});
12163
- (0, import_react86.useEffect)(() => {
12352
+ (0, import_react87.useEffect)(() => {
12164
12353
  if (!activeId) {
12165
12354
  setRun(null);
12166
12355
  return;
@@ -12178,7 +12367,7 @@ function DashboardCanvas({ tableId, activeDashboardId, filter, className }) {
12178
12367
  cancelled = true;
12179
12368
  };
12180
12369
  }, [client, activeId, filterKey]);
12181
- const declare2 = (0, import_react86.useCallback)(
12370
+ const declare2 = (0, import_react87.useCallback)(
12182
12371
  async (next, blocks) => {
12183
12372
  const written = await client.dashboardDeclare(
12184
12373
  dashboardDeclareArgs({ ...next, blocks }, tableId)
@@ -12224,7 +12413,7 @@ function DashboardCanvas({ tableId, activeDashboardId, filter, className }) {
12224
12413
  ]
12225
12414
  );
12226
12415
  }
12227
- const refresh = (0, import_react86.useCallback)(async () => {
12416
+ const refresh = (0, import_react87.useCallback)(async () => {
12228
12417
  if (!activeId) return;
12229
12418
  setRunning(true);
12230
12419
  const again = await client.dashboardRun({
@@ -12380,8 +12569,8 @@ function DashboardCanvas({ tableId, activeDashboardId, filter, className }) {
12380
12569
  }
12381
12570
 
12382
12571
  // src/FormsPanel.tsx
12383
- var import_react88 = require("react");
12384
- var import_react89 = require("@ai-matrx/records/react");
12572
+ var import_react89 = require("react");
12573
+ var import_react90 = require("@ai-matrx/records/react");
12385
12574
  var import_records9 = require("@ai-matrx/records");
12386
12575
  var import_design_system44 = require("@ai-matrx/design-system");
12387
12576
  var import_jsx_runtime47 = require("react/jsx-runtime");
@@ -12392,16 +12581,16 @@ function formSuggestion(tableName2) {
12392
12581
  return `Make me a form that collects new ${subject} entries and tells me when somebody answers.`;
12393
12582
  }
12394
12583
  function FormsPanel({ tableId, className }) {
12395
- const client = (0, import_react89.useRecordsClient)();
12584
+ const client = (0, import_react90.useRecordsClient)();
12396
12585
  const host = useRecordsUi();
12397
- const table = (0, import_react89.useTable)(tableId);
12586
+ const table = (0, import_react90.useTable)(tableId);
12398
12587
  const rights = useTableRights(table.data);
12399
- const [forms, setForms] = (0, import_react88.useState)(null);
12400
- const [error, setError] = (0, import_react88.useState)(null);
12401
- const [busy, setBusy] = (0, import_react88.useState)(null);
12402
- const [copied, setCopied] = (0, import_react88.useState)(null);
12403
- const [building, setBuilding] = (0, import_react88.useState)(false);
12404
- const load = (0, import_react88.useCallback)(async () => {
12588
+ const [forms, setForms] = (0, import_react89.useState)(null);
12589
+ const [error, setError] = (0, import_react89.useState)(null);
12590
+ const [busy, setBusy] = (0, import_react89.useState)(null);
12591
+ const [copied, setCopied] = (0, import_react89.useState)(null);
12592
+ const [building, setBuilding] = (0, import_react89.useState)(false);
12593
+ const load = (0, import_react89.useCallback)(async () => {
12405
12594
  const answered = await client.forms({ table_id: tableId });
12406
12595
  if (!answered.ok) {
12407
12596
  setError(answered.error);
@@ -12411,10 +12600,10 @@ function FormsPanel({ tableId, className }) {
12411
12600
  setError(null);
12412
12601
  setForms(answered.data);
12413
12602
  }, [client, tableId]);
12414
- (0, import_react88.useEffect)(() => {
12603
+ (0, import_react89.useEffect)(() => {
12415
12604
  void load();
12416
12605
  }, [load]);
12417
- const toggle = (0, import_react88.useCallback)(
12606
+ const toggle = (0, import_react89.useCallback)(
12418
12607
  async (form) => {
12419
12608
  setBusy(form.form_id);
12420
12609
  const wanted = form.published_at === null || form.closed_at !== null;
@@ -12428,8 +12617,8 @@ function FormsPanel({ tableId, className }) {
12428
12617
  },
12429
12618
  [client, load]
12430
12619
  );
12431
- const [shown, setShown] = (0, import_react88.useState)(null);
12432
- const copy = (0, import_react88.useCallback)(async (url, formId) => {
12620
+ const [shown, setShown] = (0, import_react89.useState)(null);
12621
+ const copy = (0, import_react89.useCallback)(async (url, formId) => {
12433
12622
  try {
12434
12623
  await navigator.clipboard.writeText(url);
12435
12624
  setCopied(formId);
@@ -12527,8 +12716,8 @@ function FormsPanel({ tableId, className }) {
12527
12716
  }
12528
12717
 
12529
12718
  // src/BookingBuilder.tsx
12530
- var import_react90 = require("react");
12531
- var import_react91 = require("@ai-matrx/records/react");
12719
+ var import_react91 = require("react");
12720
+ var import_react92 = require("@ai-matrx/records/react");
12532
12721
  var import_records10 = require("@ai-matrx/records");
12533
12722
  var import_design_system45 = require("@ai-matrx/design-system");
12534
12723
  var import_jsx_runtime48 = require("react/jsx-runtime");
@@ -12543,6 +12732,7 @@ var DAYS = [
12543
12732
  { weekday: 0, label: "Sun" }
12544
12733
  ];
12545
12734
  var LENGTHS = [15, 20, 30, 45, 60, 90, 120];
12735
+ var WORKING_WEEK = /* @__PURE__ */ new Set([1, 2, 3, 4, 5]);
12546
12736
  function draftWindows(availability) {
12547
12737
  return DAYS.map((day) => {
12548
12738
  const found = availability?.windows.find((w) => w.weekday === day.weekday);
@@ -12550,41 +12740,43 @@ function draftWindows(availability) {
12550
12740
  weekday: day.weekday,
12551
12741
  from: found?.from ?? "09:00",
12552
12742
  to: found?.to ?? "17:00",
12553
- on: Boolean(found)
12743
+ on: availability ? Boolean(found) : WORKING_WEEK.has(day.weekday)
12554
12744
  };
12555
12745
  });
12556
12746
  }
12557
12747
  function BookingBuilder({ tableId, bookingId, onSaved, onClose, className }) {
12558
- const client = (0, import_react91.useRecordsClient)();
12748
+ const client = (0, import_react92.useRecordsClient)();
12559
12749
  const host = useRecordsUi();
12560
- const table = (0, import_react91.useTable)(tableId);
12750
+ const table = (0, import_react92.useTable)(tableId);
12561
12751
  const rights = useTableRights(table.data);
12562
- const fields = (0, import_react91.useFields)(tableId);
12563
- const [existing, setExisting] = (0, import_react90.useState)(null);
12564
- const [loaded, setLoaded] = (0, import_react90.useState)(false);
12565
- const [error, setError] = (0, import_react90.useState)(null);
12566
- const [saving, setSaving] = (0, import_react90.useState)(false);
12567
- const [publishing, setPublishing] = (0, import_react90.useState)(false);
12568
- const [copied, setCopied] = (0, import_react90.useState)(false);
12569
- const [title, setTitle] = (0, import_react90.useState)("");
12570
- const [minutes, setMinutes] = (0, import_react90.useState)(30);
12571
- const [buffer, setBuffer] = (0, import_react90.useState)(0);
12572
- const [lead, setLead] = (0, import_react90.useState)(120);
12573
- const [perDay, setPerDay] = (0, import_react90.useState)(8);
12574
- const [days, setDays] = (0, import_react90.useState)(30);
12575
- const [windows, setWindows] = (0, import_react90.useState)(() => draftWindows(null));
12576
- const [asked, setAsked] = (0, import_react90.useState)([]);
12577
- const [confirmation, setConfirmation] = (0, import_react90.useState)("");
12578
- const [offer, setOffer] = (0, import_react90.useState)(null);
12579
- const [formId, setFormId] = (0, import_react90.useState)(bookingId ?? null);
12752
+ const fields = (0, import_react92.useFields)(tableId);
12753
+ const [existing, setExisting] = (0, import_react91.useState)(null);
12754
+ const [loaded, setLoaded] = (0, import_react91.useState)(false);
12755
+ const [error, setError] = (0, import_react91.useState)(null);
12756
+ const [saving, setSaving] = (0, import_react91.useState)(false);
12757
+ const [publishing, setPublishing] = (0, import_react91.useState)(false);
12758
+ const [copied, setCopied] = (0, import_react91.useState)(false);
12759
+ const [title, setTitle] = (0, import_react91.useState)("");
12760
+ const [minutes, setMinutes] = (0, import_react91.useState)(30);
12761
+ const [buffer, setBuffer] = (0, import_react91.useState)(0);
12762
+ const [lead, setLead] = (0, import_react91.useState)(120);
12763
+ const [perDay, setPerDay] = (0, import_react91.useState)(8);
12764
+ const [days, setDays] = (0, import_react91.useState)(30);
12765
+ const [windows, setWindows] = (0, import_react91.useState)(() => draftWindows(null));
12766
+ const [asked, setAsked] = (0, import_react91.useState)([]);
12767
+ const [confirmation, setConfirmation] = (0, import_react91.useState)("");
12768
+ const [offer, setOffer] = (0, import_react91.useState)(null);
12769
+ const [formId, setFormId] = (0, import_react91.useState)(bookingId ?? null);
12580
12770
  const publicOrigin = host.publicOrigin ?? (typeof window === "undefined" ? "" : window.location.origin);
12581
- const askable = (0, import_react90.useMemo)(
12582
- () => (fields.data ?? []).filter(
12583
- (f) => !STORE_ANSWERS_THESE.includes(f.key)
12584
- ),
12771
+ const askable = (0, import_react91.useMemo)(
12772
+ () => askableFields(fields.data ?? [], STORE_ANSWERS_THESE),
12585
12773
  [fields.data]
12586
12774
  );
12587
- const load = (0, import_react90.useCallback)(async () => {
12775
+ const leftOut = (0, import_react91.useMemo)(
12776
+ () => whyNotAskable(fields.data ?? [], STORE_ANSWERS_THESE),
12777
+ [fields.data]
12778
+ );
12779
+ const load = (0, import_react91.useCallback)(async () => {
12588
12780
  const answered = await client.bookings({ table_id: tableId });
12589
12781
  if (!answered.ok) {
12590
12782
  setError(answered.error);
@@ -12596,18 +12788,27 @@ function BookingBuilder({ tableId, bookingId, onSaved, onClose, className }) {
12596
12788
  setLoaded(true);
12597
12789
  if (mine) setFormId(mine.form_id);
12598
12790
  }, [client, tableId, bookingId]);
12599
- (0, import_react90.useEffect)(() => {
12791
+ (0, import_react91.useEffect)(() => {
12600
12792
  void load();
12601
12793
  }, [load]);
12602
- (0, import_react90.useEffect)(() => {
12794
+ (0, import_react91.useEffect)(() => {
12603
12795
  if (title !== "" || !table.data) return;
12604
12796
  setTitle(existing?.title ?? `Book a ${minutes}-minute ${table.data.name} appointment`);
12605
12797
  }, [table.data, existing]);
12606
- (0, import_react90.useEffect)(() => {
12798
+ (0, import_react91.useEffect)(() => {
12607
12799
  if (!existing) return;
12608
12800
  setMinutes(existing.slot_minutes);
12609
12801
  }, [existing]);
12610
- const availability = (0, import_react90.useCallback)(
12802
+ (0, import_react91.useEffect)(() => {
12803
+ if (!offer) return;
12804
+ setWindows(draftWindows(offer));
12805
+ setMinutes(offer.slot_minutes);
12806
+ setBuffer(offer.buffer_minutes);
12807
+ setLead(offer.lead_minutes);
12808
+ setPerDay(offer.max_per_day);
12809
+ setDays(offer.days);
12810
+ }, [offer]);
12811
+ const availability = (0, import_react91.useCallback)(
12611
12812
  () => ({
12612
12813
  slot_minutes: minutes,
12613
12814
  buffer_minutes: buffer,
@@ -12794,7 +12995,8 @@ function BookingBuilder({ tableId, bookingId, onSaved, onClose, className }) {
12794
12995
  ),
12795
12996
  fieldName(f)
12796
12997
  ] }, f.key)) }),
12797
- /* @__PURE__ */ (0, import_jsx_runtime48.jsx)("p", { className: "text-xs text-muted-foreground", children: "The time, whether it is booked or cancelled, and who it is with are filled in by the store \u2014 a booking page cannot ask a visitor for any of the three." })
12998
+ /* @__PURE__ */ (0, import_jsx_runtime48.jsx)("p", { className: "text-xs text-muted-foreground", children: "The time, whether it is booked or cancelled, and who it is with are filled in by the store \u2014 a booking page cannot ask a visitor for any of the three." }),
12999
+ leftOut ? /* @__PURE__ */ (0, import_jsx_runtime48.jsx)("p", { className: "text-xs text-muted-foreground", children: leftOut }) : null
12798
13000
  ] }),
12799
13001
  /* @__PURE__ */ (0, import_jsx_runtime48.jsxs)("label", { className: "flex flex-col gap-1", children: [
12800
13002
  /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(import_design_system45.Label, { className: "text-xs font-medium", children: "What they see after booking" }),
@@ -12859,8 +13061,8 @@ function BookingBuilder({ tableId, bookingId, onSaved, onClose, className }) {
12859
13061
  }
12860
13062
 
12861
13063
  // src/BookingSlots.tsx
12862
- var import_react92 = require("react");
12863
- var import_react93 = require("@ai-matrx/records/react");
13064
+ var import_react93 = require("react");
13065
+ var import_react94 = require("@ai-matrx/records/react");
12864
13066
  var import_records11 = require("@ai-matrx/records");
12865
13067
  var import_design_system46 = require("@ai-matrx/design-system");
12866
13068
  var import_jsx_runtime49 = require("react/jsx-runtime");
@@ -12877,15 +13079,15 @@ var STATE_WORDS = {
12877
13079
  full: "Every time you offered is taken."
12878
13080
  };
12879
13081
  function BookingSlots({ tableId, className }) {
12880
- const client = (0, import_react93.useRecordsClient)();
13082
+ const client = (0, import_react94.useRecordsClient)();
12881
13083
  const host = useRecordsUi();
12882
- const [pages, setPages] = (0, import_react92.useState)(null);
12883
- const [error, setError] = (0, import_react92.useState)(null);
12884
- const [busy, setBusy] = (0, import_react92.useState)(null);
12885
- const [copied, setCopied] = (0, import_react92.useState)(null);
12886
- const [shown, setShown] = (0, import_react92.useState)(null);
12887
- const [building, setBuilding] = (0, import_react92.useState)(false);
12888
- const load = (0, import_react92.useCallback)(async () => {
13084
+ const [pages, setPages] = (0, import_react93.useState)(null);
13085
+ const [error, setError] = (0, import_react93.useState)(null);
13086
+ const [busy, setBusy] = (0, import_react93.useState)(null);
13087
+ const [copied, setCopied] = (0, import_react93.useState)(null);
13088
+ const [shown, setShown] = (0, import_react93.useState)(null);
13089
+ const [building, setBuilding] = (0, import_react93.useState)(false);
13090
+ const load = (0, import_react93.useCallback)(async () => {
12889
13091
  const answered = await client.bookings(tableId ? { table_id: tableId } : {});
12890
13092
  if (!answered.ok) {
12891
13093
  setError(answered.error);
@@ -12895,15 +13097,15 @@ function BookingSlots({ tableId, className }) {
12895
13097
  setError(null);
12896
13098
  setPages(answered.data);
12897
13099
  }, [client, tableId]);
12898
- (0, import_react92.useEffect)(() => {
13100
+ (0, import_react93.useEffect)(() => {
12899
13101
  void load();
12900
13102
  }, [load]);
12901
- const subjectIds = (0, import_react92.useMemo)(
13103
+ const subjectIds = (0, import_react93.useMemo)(
12902
13104
  () => Array.from(new Set((pages ?? []).map((p) => p.table_id))),
12903
13105
  [pages]
12904
13106
  );
12905
- const levels = (0, import_react93.useMyLevels)(subjectIds);
12906
- const toggle = (0, import_react92.useCallback)(
13107
+ const levels = (0, import_react94.useMyLevels)(subjectIds);
13108
+ const toggle = (0, import_react93.useCallback)(
12907
13109
  async (page) => {
12908
13110
  setBusy(page.form_id);
12909
13111
  const wanted = page.published_at === null || page.closed_at !== null;
@@ -12917,7 +13119,7 @@ function BookingSlots({ tableId, className }) {
12917
13119
  },
12918
13120
  [client, load]
12919
13121
  );
12920
- const copy = (0, import_react92.useCallback)(async (url, formId) => {
13122
+ const copy = (0, import_react93.useCallback)(async (url, formId) => {
12921
13123
  try {
12922
13124
  await navigator.clipboard.writeText(url);
12923
13125
  setCopied(formId);
@@ -13052,14 +13254,14 @@ function nextInWords(page) {
13052
13254
  }
13053
13255
 
13054
13256
  // src/CaptureSheet.tsx
13055
- var import_react96 = require("react");
13056
- var import_react97 = require("@ai-matrx/records/react");
13257
+ var import_react97 = require("react");
13258
+ var import_react98 = require("@ai-matrx/records/react");
13057
13259
  var import_design_system48 = require("@ai-matrx/design-system");
13058
13260
 
13059
13261
  // src/CaptureRun.tsx
13060
- var import_react94 = require("react");
13262
+ var import_react95 = require("react");
13061
13263
  var import_records12 = require("@ai-matrx/records");
13062
- var import_react95 = require("@ai-matrx/records/react");
13264
+ var import_react96 = require("@ai-matrx/records/react");
13063
13265
  var import_design_system47 = require("@ai-matrx/design-system");
13064
13266
  var import_jsx_runtime50 = require("react/jsx-runtime");
13065
13267
  function controlFor(field) {
@@ -13098,21 +13300,21 @@ function whereWeAre(timeoutMs = 4e3) {
13098
13300
  });
13099
13301
  }
13100
13302
  function CaptureRun({ sheetId, face: given, className }) {
13101
- const client = (0, import_react95.useRecordsClient)();
13303
+ const client = (0, import_react96.useRecordsClient)();
13102
13304
  const host = useRecordsUi();
13103
- const [face, setFace] = (0, import_react94.useState)(given);
13104
- const [loadFailed, setLoadFailed] = (0, import_react94.useState)(null);
13105
- const [at, setAt] = (0, import_react94.useState)(0);
13106
- const [answers, setAnswers] = (0, import_react94.useState)({});
13107
- const [files, setFiles] = (0, import_react94.useState)({});
13108
- const [missing, setMissing] = (0, import_react94.useState)(null);
13109
- const [done, setDone] = (0, import_react94.useState)(null);
13110
- const [counts, setCounts] = (0, import_react94.useState)({ waiting: 0, sending: 0, refused: 0, landed: 0 });
13111
- const [items, setItems] = (0, import_react94.useState)([]);
13112
- const [lastSynced, setLastSynced] = (0, import_react94.useState)(null);
13113
- const [sending, setSending] = (0, import_react94.useState)(false);
13114
- const queueRef = (0, import_react94.useRef)(null);
13115
- (0, import_react94.useEffect)(() => {
13305
+ const [face, setFace] = (0, import_react95.useState)(given);
13306
+ const [loadFailed, setLoadFailed] = (0, import_react95.useState)(null);
13307
+ const [at, setAt] = (0, import_react95.useState)(0);
13308
+ const [answers, setAnswers] = (0, import_react95.useState)({});
13309
+ const [files, setFiles] = (0, import_react95.useState)({});
13310
+ const [missing, setMissing] = (0, import_react95.useState)(null);
13311
+ const [done, setDone] = (0, import_react95.useState)(null);
13312
+ const [counts, setCounts] = (0, import_react95.useState)({ waiting: 0, sending: 0, refused: 0, landed: 0 });
13313
+ const [items, setItems] = (0, import_react95.useState)([]);
13314
+ const [lastSynced, setLastSynced] = (0, import_react95.useState)(null);
13315
+ const [sending, setSending] = (0, import_react95.useState)(false);
13316
+ const queueRef = (0, import_react95.useRef)(null);
13317
+ (0, import_react95.useEffect)(() => {
13116
13318
  const q2 = (0, import_records12.openCaptureQueue)({
13117
13319
  onChange: (c, all) => {
13118
13320
  setCounts(c);
@@ -13150,7 +13352,7 @@ function CaptureRun({ sheetId, face: given, className }) {
13150
13352
  void q2.sync().then(() => void q2.lastSyncedAt().then(setLastSynced));
13151
13353
  return () => q2.dispose();
13152
13354
  }, [client, host]);
13153
- (0, import_react94.useEffect)(() => {
13355
+ (0, import_react95.useEffect)(() => {
13154
13356
  if (given !== void 0) return;
13155
13357
  let cancelled = false;
13156
13358
  void client.captureOpen({ sheet_id: sheetId }).then((res) => {
@@ -13162,7 +13364,7 @@ function CaptureRun({ sheetId, face: given, className }) {
13162
13364
  cancelled = true;
13163
13365
  };
13164
13366
  }, [client, given, sheetId]);
13165
- const questions = (0, import_react94.useMemo)(() => {
13367
+ const questions = (0, import_react95.useMemo)(() => {
13166
13368
  const asked = face?.presentation?.questions ?? [];
13167
13369
  if (asked.length > 0) return asked;
13168
13370
  return (face?.fields ?? []).map((f) => ({
@@ -13172,11 +13374,11 @@ function CaptureRun({ sheetId, face: given, className }) {
13172
13374
  required: f.required
13173
13375
  }));
13174
13376
  }, [face]);
13175
- const fieldOf = (0, import_react94.useCallback)(
13377
+ const fieldOf = (0, import_react95.useCallback)(
13176
13378
  (key) => (face?.fields ?? []).find((f) => f.key === key),
13177
13379
  [face]
13178
13380
  );
13179
- const sync = (0, import_react94.useCallback)(async () => {
13381
+ const sync = (0, import_react95.useCallback)(async () => {
13180
13382
  const q2 = queueRef.current;
13181
13383
  if (!q2) return;
13182
13384
  setSending(true);
@@ -13189,7 +13391,7 @@ function CaptureRun({ sheetId, face: given, className }) {
13189
13391
  setSending(false);
13190
13392
  }
13191
13393
  }, []);
13192
- const answered = (0, import_react94.useCallback)(
13394
+ const answered = (0, import_react95.useCallback)(
13193
13395
  (key) => {
13194
13396
  if (files[key]) return true;
13195
13397
  const v = answers[key];
@@ -13456,21 +13658,21 @@ function AdHocCaptureSheet({
13456
13658
  attachmentField,
13457
13659
  className
13458
13660
  }) {
13459
- const client = (0, import_react97.useRecordsClient)();
13661
+ const client = (0, import_react98.useRecordsClient)();
13460
13662
  const host = useRecordsUi();
13461
- const table = (0, import_react97.useTable)(tableId);
13462
- const fields = (0, import_react97.useFields)(tableId);
13463
- const [mode, setMode] = (0, import_react96.useState)("reading");
13464
- const [reading, setReading] = (0, import_react96.useState)("");
13465
- const [note, setNote] = (0, import_react96.useState)("");
13466
- const [fileId, setFileId] = (0, import_react96.useState)(null);
13467
- const [pending, setPending] = (0, import_react96.useState)(null);
13468
- const [saved, setSaved] = (0, import_react96.useState)([]);
13469
- const [error, setError] = (0, import_react96.useState)(null);
13470
- const [uploadError, setUploadError] = (0, import_react96.useState)(null);
13471
- const [flushing, setFlushing] = (0, import_react96.useState)(false);
13472
- const queue = (0, import_react96.useRef)([]);
13473
- const keep = (0, import_react96.useCallback)(
13663
+ const table = (0, import_react98.useTable)(tableId);
13664
+ const fields = (0, import_react98.useFields)(tableId);
13665
+ const [mode, setMode] = (0, import_react97.useState)("reading");
13666
+ const [reading, setReading] = (0, import_react97.useState)("");
13667
+ const [note, setNote] = (0, import_react97.useState)("");
13668
+ const [fileId, setFileId] = (0, import_react97.useState)(null);
13669
+ const [pending, setPending] = (0, import_react97.useState)(null);
13670
+ const [saved, setSaved] = (0, import_react97.useState)([]);
13671
+ const [error, setError] = (0, import_react97.useState)(null);
13672
+ const [uploadError, setUploadError] = (0, import_react97.useState)(null);
13673
+ const [flushing, setFlushing] = (0, import_react97.useState)(false);
13674
+ const queue = (0, import_react97.useRef)([]);
13675
+ const keep = (0, import_react97.useCallback)(
13474
13676
  async (next) => {
13475
13677
  queue.current = next;
13476
13678
  setPending(next);
@@ -13478,7 +13680,7 @@ function AdHocCaptureSheet({
13478
13680
  },
13479
13681
  [host]
13480
13682
  );
13481
- (0, import_react96.useEffect)(() => {
13683
+ (0, import_react97.useEffect)(() => {
13482
13684
  let cancelled = false;
13483
13685
  void (async () => {
13484
13686
  const held = host.captureQueue ? await host.captureQueue.load() : [];
@@ -13490,7 +13692,7 @@ function AdHocCaptureSheet({
13490
13692
  cancelled = true;
13491
13693
  };
13492
13694
  }, [host]);
13493
- const resolved = (0, import_react96.useCallback)(() => {
13695
+ const resolved = (0, import_react97.useCallback)(() => {
13494
13696
  const all = fields.data ?? [];
13495
13697
  return {
13496
13698
  reading: readingField ?? all.find((f) => f.type === "range")?.key ?? null,
@@ -13498,7 +13700,7 @@ function AdHocCaptureSheet({
13498
13700
  attachment: attachmentField ?? all.find((f) => f.format === "file" || f.format === "image")?.key ?? null
13499
13701
  };
13500
13702
  }, [attachmentField, fields.data, noteField, readingField, table.data]);
13501
- const flush = (0, import_react96.useCallback)(async () => {
13703
+ const flush = (0, import_react97.useCallback)(async () => {
13502
13704
  if (flushing || queue.current.length === 0) return;
13503
13705
  setFlushing(true);
13504
13706
  const left = [];
@@ -13657,18 +13859,18 @@ function AdHocCaptureSheet({
13657
13859
  }
13658
13860
 
13659
13861
  // src/PortalShell.tsx
13660
- var import_react98 = require("react");
13661
- var import_react99 = require("@ai-matrx/records/react");
13862
+ var import_react99 = require("react");
13863
+ var import_react100 = require("@ai-matrx/records/react");
13662
13864
  var import_design_system49 = require("@ai-matrx/design-system");
13663
13865
  var import_jsx_runtime52 = require("react/jsx-runtime");
13664
13866
  function PortalShell({ tableId, form, resourceType = "record", className }) {
13665
- const client = (0, import_react99.useRecordsClient)();
13666
- const [card, setCard] = (0, import_react98.useState)(null);
13667
- const [reach, setReach] = (0, import_react98.useState)(null);
13668
- const [error, setError] = (0, import_react98.useState)(null);
13669
- const [open, setOpen] = (0, import_react98.useState)(null);
13670
- const [sending, setSending] = (0, import_react98.useState)(false);
13671
- const load = (0, import_react98.useCallback)(async () => {
13867
+ const client = (0, import_react100.useRecordsClient)();
13868
+ const [card, setCard] = (0, import_react99.useState)(null);
13869
+ const [reach, setReach] = (0, import_react99.useState)(null);
13870
+ const [error, setError] = (0, import_react99.useState)(null);
13871
+ const [open, setOpen] = (0, import_react99.useState)(null);
13872
+ const [sending, setSending] = (0, import_react99.useState)(false);
13873
+ const load = (0, import_react99.useCallback)(async () => {
13672
13874
  const who = await client.externalPrincipalCard();
13673
13875
  if (!who.ok) {
13674
13876
  setError(who.error);
@@ -13683,7 +13885,7 @@ function PortalShell({ tableId, form, resourceType = "record", className }) {
13683
13885
  }
13684
13886
  setReach(reached.data.map((row) => row.resource_id));
13685
13887
  }, [client, resourceType]);
13686
- (0, import_react98.useEffect)(() => {
13888
+ (0, import_react99.useEffect)(() => {
13687
13889
  void load();
13688
13890
  }, [load]);
13689
13891
  if (error) {
@@ -13741,9 +13943,9 @@ function PortalShell({ tableId, form, resourceType = "record", className }) {
13741
13943
  ] });
13742
13944
  }
13743
13945
  function PortalRow({ tableId, recordId }) {
13744
- const client = (0, import_react99.useRecordsClient)();
13745
- const [title, setTitle] = (0, import_react98.useState)(null);
13746
- (0, import_react98.useEffect)(() => {
13946
+ const client = (0, import_react100.useRecordsClient)();
13947
+ const [title, setTitle] = (0, import_react99.useState)(null);
13948
+ (0, import_react99.useEffect)(() => {
13747
13949
  let cancelled = false;
13748
13950
  void client.recordRead({ record_id: recordId }).then((answered) => {
13749
13951
  if (cancelled) return;
@@ -13763,18 +13965,18 @@ function PortalRow({ tableId, recordId }) {
13763
13965
  }
13764
13966
 
13765
13967
  // src/PublicViewPage.tsx
13766
- var import_react100 = require("react");
13767
- var import_react101 = require("@ai-matrx/records/react");
13968
+ var import_react101 = require("react");
13969
+ var import_react102 = require("@ai-matrx/records/react");
13768
13970
  var import_design_system50 = require("@ai-matrx/design-system");
13769
13971
  var import_jsx_runtime53 = require("react/jsx-runtime");
13770
13972
  function PublicViewPage({ slug, className }) {
13771
- const client = (0, import_react101.useRecordsClient)();
13772
- const [binding, setBinding] = (0, import_react100.useState)(null);
13773
- const [rows, setRows] = (0, import_react100.useState)(null);
13774
- const [fields, setFields] = (0, import_react100.useState)(null);
13775
- const [error, setError] = (0, import_react100.useState)(null);
13776
- const [gap, setGap] = (0, import_react100.useState)(null);
13777
- const load = (0, import_react100.useCallback)(async () => {
13973
+ const client = (0, import_react102.useRecordsClient)();
13974
+ const [binding, setBinding] = (0, import_react101.useState)(null);
13975
+ const [rows, setRows] = (0, import_react101.useState)(null);
13976
+ const [fields, setFields] = (0, import_react101.useState)(null);
13977
+ const [error, setError] = (0, import_react101.useState)(null);
13978
+ const [gap, setGap] = (0, import_react101.useState)(null);
13979
+ const load = (0, import_react101.useCallback)(async () => {
13778
13980
  const notice = await client.worldPublishGapNotice();
13779
13981
  if (notice.ok) setGap(notice.data);
13780
13982
  const resolved = await client.resolvePublishBinding({ slug });
@@ -13807,7 +14009,7 @@ function PublicViewPage({ slug, className }) {
13807
14009
  }
13808
14010
  setRows([{ id: found.resource_id, document: read.data.document, level: "viewer", hidden: read.data.hidden }]);
13809
14011
  }, [client, slug]);
13810
- (0, import_react100.useEffect)(() => {
14012
+ (0, import_react101.useEffect)(() => {
13811
14013
  void load();
13812
14014
  }, [load]);
13813
14015
  if (error) return /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(RefusalNotice, { error, className });
@@ -13844,10 +14046,10 @@ function PublicRow({ row, fields }) {
13844
14046
  }
13845
14047
 
13846
14048
  // src/EmbedFrame.tsx
13847
- var import_react102 = require("react");
13848
- var import_react103 = require("@ai-matrx/records/react");
13849
- var import_design_system51 = require("@ai-matrx/design-system");
14049
+ var import_react103 = require("react");
13850
14050
  var import_react104 = require("@ai-matrx/records/react");
14051
+ var import_design_system51 = require("@ai-matrx/design-system");
14052
+ var import_react105 = require("@ai-matrx/records/react");
13851
14053
  var import_jsx_runtime54 = require("react/jsx-runtime");
13852
14054
  function EmbedFrame({
13853
14055
  tableId,
@@ -13857,18 +14059,18 @@ function EmbedFrame({
13857
14059
  embedUrl,
13858
14060
  className
13859
14061
  }) {
13860
- const client = (0, import_react103.useRecordsClient)();
14062
+ const client = (0, import_react104.useRecordsClient)();
13861
14063
  const host = useRecordsUi();
13862
- const table = (0, import_react104.useTable)(tableId);
14064
+ const table = (0, import_react105.useTable)(tableId);
13863
14065
  const rights = useTableRights(table.data);
13864
- const [origins, setOrigins] = (0, import_react102.useState)("");
13865
- const [secret, setSecret] = (0, import_react102.useState)(null);
13866
- const [tokenId, setTokenId] = (0, import_react102.useState)(null);
13867
- const [error, setError] = (0, import_react102.useState)(null);
13868
- const [busy, setBusy] = (0, import_react102.useState)(false);
14066
+ const [origins, setOrigins] = (0, import_react103.useState)("");
14067
+ const [secret, setSecret] = (0, import_react103.useState)(null);
14068
+ const [tokenId, setTokenId] = (0, import_react103.useState)(null);
14069
+ const [error, setError] = (0, import_react103.useState)(null);
14070
+ const [busy, setBusy] = (0, import_react103.useState)(false);
13869
14071
  const mode = formId ? "write" : "read";
13870
14072
  const parsed = origins.split(/[\s,]+/).map((o) => o.trim()).filter((o) => o.length > 0);
13871
- const issue = (0, import_react102.useCallback)(async () => {
14073
+ const issue = (0, import_react103.useCallback)(async () => {
13872
14074
  setBusy(true);
13873
14075
  setError(null);
13874
14076
  const minted = await client.anonTokenIssue({
@@ -13887,7 +14089,7 @@ function EmbedFrame({
13887
14089
  setTokenId(minted.data.token_id);
13888
14090
  host.notify?.success("Embed token issued. Copy it now \u2014 it is never shown again.");
13889
14091
  }, [client, formId, host, mode, parsed, recordId, savedViewId]);
13890
- const revoke = (0, import_react102.useCallback)(async () => {
14092
+ const revoke = (0, import_react103.useCallback)(async () => {
13891
14093
  if (!tokenId) return;
13892
14094
  setBusy(true);
13893
14095
  const done = await client.anonTokenRevoke({ token_id: tokenId });
@@ -13951,13 +14153,13 @@ function EmbedFrame({
13951
14153
  ] });
13952
14154
  }
13953
14155
  function useEmbedHandshake(args) {
13954
- const client = (0, import_react103.useRecordsClient)();
13955
- const [binding, setBinding] = (0, import_react102.useState)(null);
13956
- const [error, setError] = (0, import_react102.useState)(null);
13957
- const [loading, setLoading] = (0, import_react102.useState)(true);
14156
+ const client = (0, import_react104.useRecordsClient)();
14157
+ const [binding, setBinding] = (0, import_react103.useState)(null);
14158
+ const [error, setError] = (0, import_react103.useState)(null);
14159
+ const [loading, setLoading] = (0, import_react103.useState)(true);
13958
14160
  const origin = args.origin ?? (typeof location === "undefined" ? "" : location.origin);
13959
14161
  const { secret, requiredMode } = args;
13960
- (0, import_react102.useEffect)(() => {
14162
+ (0, import_react103.useEffect)(() => {
13961
14163
  let cancelled = false;
13962
14164
  setLoading(true);
13963
14165
  setError(null);
@@ -13979,7 +14181,7 @@ function useEmbedHandshake(args) {
13979
14181
  }
13980
14182
 
13981
14183
  // src/RecordsMount.tsx
13982
- var import_react105 = require("@ai-matrx/records/react");
14184
+ var import_react106 = require("@ai-matrx/records/react");
13983
14185
  var import_jsx_runtime55 = require("react/jsx-runtime");
13984
14186
  var STORE_DECIDES_REASON = "This host offers exactly what the record store says this person may do: the level comes back with the table on the read door, so a control they cannot use is never drawn in the first place.";
13985
14187
  function storeDecidesRights(_table) {
@@ -13993,7 +14195,7 @@ function RecordsMount({
13993
14195
  }) {
13994
14196
  const bound = { ...host ?? {} };
13995
14197
  void letTheStoreDecideRights;
13996
- return /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(import_react105.RecordsProvider, { config, children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(RecordsUiProvider, { value: bound, children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(RecordLabelProvider, { children }) }) });
14198
+ return /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(import_react106.RecordsProvider, { config, children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(RecordsUiProvider, { value: bound, children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(RecordLabelProvider, { children }) }) });
13997
14199
  }
13998
14200
  function personActor(userId) {
13999
14201
  return userId ? { actor: "user", user_id: userId } : { actor: "user" };
@@ -14012,8 +14214,8 @@ function recordsDataSource(client, fallbackSchema = "custom") {
14012
14214
  }
14013
14215
 
14014
14216
  // src/TablesHome.tsx
14015
- var import_react106 = require("react");
14016
- var import_react107 = require("@ai-matrx/records/react");
14217
+ var import_react107 = require("react");
14218
+ var import_react108 = require("@ai-matrx/records/react");
14017
14219
  var import_design_system52 = require("@ai-matrx/design-system");
14018
14220
 
14019
14221
  // src/createTable.ts
@@ -14149,15 +14351,15 @@ function laneFor(table) {
14149
14351
  return "organization";
14150
14352
  }
14151
14353
  function TablesHome({ onOpenTable, className }) {
14152
- const client = (0, import_react107.useRecordsClient)();
14153
- const tables = (0, import_react107.useTables)();
14154
- const [creating, setCreating] = (0, import_react106.useState)(false);
14155
- const [name, setName] = (0, import_react106.useState)("");
14156
- const [busy, setBusy] = (0, import_react106.useState)(false);
14157
- const [error, setError] = (0, import_react106.useState)(null);
14158
- const [importInto, setImportInto] = (0, import_react106.useState)(null);
14159
- const [boards, setBoards] = (0, import_react106.useState)(null);
14160
- (0, import_react106.useEffect)(() => {
14354
+ const client = (0, import_react108.useRecordsClient)();
14355
+ const tables = (0, import_react108.useTables)();
14356
+ const [creating, setCreating] = (0, import_react107.useState)(false);
14357
+ const [name, setName] = (0, import_react107.useState)("");
14358
+ const [busy, setBusy] = (0, import_react107.useState)(false);
14359
+ const [error, setError] = (0, import_react107.useState)(null);
14360
+ const [importInto, setImportInto] = (0, import_react107.useState)(null);
14361
+ const [boards, setBoards] = (0, import_react107.useState)(null);
14362
+ (0, import_react107.useEffect)(() => {
14161
14363
  let cancelled = false;
14162
14364
  void client.dashboards({}).then((result) => {
14163
14365
  if (cancelled) return;
@@ -14167,7 +14369,7 @@ function TablesHome({ onOpenTable, className }) {
14167
14369
  cancelled = true;
14168
14370
  };
14169
14371
  }, [client]);
14170
- const create = (0, import_react106.useCallback)(
14372
+ const create = (0, import_react107.useCallback)(
14171
14373
  async (mode) => {
14172
14374
  const trimmed = name.trim();
14173
14375
  if (!trimmed) return;
@@ -14291,8 +14493,8 @@ function TablesHome({ onOpenTable, className }) {
14291
14493
  }
14292
14494
 
14293
14495
  // src/TablePage.tsx
14294
- var import_react108 = require("react");
14295
- var import_react109 = require("@ai-matrx/records/react");
14496
+ var import_react109 = require("react");
14497
+ var import_react110 = require("@ai-matrx/records/react");
14296
14498
  var import_design_system53 = require("@ai-matrx/design-system");
14297
14499
  var import_jsx_runtime57 = require("react/jsx-runtime");
14298
14500
  var TABLE_NOT_REACHABLE = "This table is not in the organization you are working in, so there is nothing here to show. Switch to the organization that owns it and open it again \u2014 or it may have been deleted.";
@@ -14325,29 +14527,29 @@ function TablePage({
14325
14527
  activeRecordId,
14326
14528
  className
14327
14529
  }) {
14328
- const client = (0, import_react109.useRecordsClient)();
14329
- const table = (0, import_react109.useTable)(tableId);
14530
+ const client = (0, import_react110.useRecordsClient)();
14531
+ const table = (0, import_react110.useTable)(tableId);
14330
14532
  const rights = useTableRights(table.data);
14331
- const organizationId = (0, import_react109.useRecordsClient)().config.organizationId;
14332
- const [view, setView] = (0, import_react108.useState)(null);
14533
+ const organizationId = (0, import_react110.useRecordsClient)().config.organizationId;
14534
+ const [view, setView] = (0, import_react109.useState)(null);
14333
14535
  const opening = openingRail(activeRecordId);
14334
- const [asking, setAsking] = (0, import_react108.useState)(null);
14335
- const [surface, setSurface] = (0, import_react108.useState)({
14536
+ const [asking, setAsking] = (0, import_react109.useState)(null);
14537
+ const [surface, setSurface] = (0, import_react109.useState)({
14336
14538
  main: activeDashboardId ? "dashboards" : "records",
14337
14539
  rail: opening.rail
14338
14540
  });
14339
14541
  const { main, rail } = surface;
14340
14542
  const setRail = (next) => setSurface((now) => ({ ...now, rail: next }));
14341
- const [openRecord, setOpenRecord] = (0, import_react108.useState)(opening.record);
14543
+ const [openRecord, setOpenRecord] = (0, import_react109.useState)(opening.record);
14342
14544
  const viewVersion = useRecordVersion(view?.id ?? null);
14343
14545
  const press = (pressed) => setSurface((now) => chooseSurface(now, pressed));
14344
14546
  const show = (next) => press({ rail: next });
14345
- (0, import_react108.useEffect)(() => {
14547
+ (0, import_react109.useEffect)(() => {
14346
14548
  if (!activeRecordId) return;
14347
14549
  setOpenRecord(activeRecordId);
14348
14550
  setSurface((now) => ({ ...now, rail: "record" }));
14349
14551
  }, [activeRecordId]);
14350
- const patchView = (0, import_react108.useCallback)(
14552
+ const patchView = (0, import_react109.useCallback)(
14351
14553
  async (patch) => {
14352
14554
  const current = view;
14353
14555
  if (!current) return;