@ai-matrx/records-ui 0.93.67 → 0.93.69

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -2096,12 +2096,33 @@ function parseGrouping(raw) {
2096
2096
  const sub = level["field"];
2097
2097
  if (typeof sub !== "string" || sub.trim() === "") continue;
2098
2098
  const subOrder = level["order"];
2099
- then.push(
2100
- typeof subOrder === "string" && GROUP_ORDERS.includes(subOrder) ? { field: sub, order: subOrder } : { field: sub }
2101
- );
2099
+ const subGrain = level["grain"];
2100
+ then.push({
2101
+ field: sub,
2102
+ ...typeof subOrder === "string" && GROUP_ORDERS.includes(subOrder) ? { order: subOrder } : {},
2103
+ ...typeof subGrain === "string" && subGrain !== "" ? { grain: subGrain } : {}
2104
+ });
2102
2105
  }
2103
2106
  if (then.length > 0) out.then = then.slice(0, 2);
2104
2107
  }
2108
+ const grain = raw["grain"];
2109
+ if (typeof grain === "string" && grain !== "") out.grain = grain;
2110
+ const across = raw["across"];
2111
+ if (typeof across === "string" && across.trim() !== "") out.across = across;
2112
+ if (Array.isArray(raw["show"])) {
2113
+ const show = raw["show"].filter((k) => typeof k === "string" && k !== "");
2114
+ if (show.length > 0) out.show = show;
2115
+ }
2116
+ if (Array.isArray(raw["trail"])) {
2117
+ const trail = [];
2118
+ for (const step2 of raw["trail"]) {
2119
+ if (!isRecord(step2) || typeof step2["dim"] !== "string" || step2["dim"] === "") continue;
2120
+ const value = step2["value"];
2121
+ if (value !== null && typeof value !== "string") continue;
2122
+ trail.push({ dim: step2["dim"], value });
2123
+ }
2124
+ if (trail.length > 0) out.trail = trail;
2125
+ }
2105
2126
  return out;
2106
2127
  }
2107
2128
  function presentationIsEmpty(p) {
@@ -5238,12 +5259,12 @@ function OpenCell({
5238
5259
  }
5239
5260
 
5240
5261
  // src/Grid.tsx
5241
- import { useCallback as useCallback18, useEffect as useEffect32, useMemo as useMemo23, useRef as useRef16, useState as useState39 } from "react";
5262
+ import { useCallback as useCallback18, useEffect as useEffect33, useMemo as useMemo24, useRef as useRef16, useState as useState40 } from "react";
5242
5263
  import {
5243
5264
  useFields as useFields5,
5244
5265
  useRecordPage,
5245
5266
  useRecords as useRecords4,
5246
- useRecordsClient as useRecordsClient23,
5267
+ useRecordsClient as useRecordsClient24,
5247
5268
  useTable as useTable3
5248
5269
  } from "@ai-matrx/records/react";
5249
5270
  import { asPermissionLevel } from "@ai-matrx/records";
@@ -9272,11 +9293,236 @@ function AddFirstRowButton({ onAdd, busy }) {
9272
9293
  return /* @__PURE__ */ jsx32(Button20, { size: "sm", "data-records-add-first-row": "", disabled: busy, onClick: onAdd, children: busy ? "Adding\u2026" : "Add the first row" });
9273
9294
  }
9274
9295
 
9296
+ // src/gridDrill.tsx
9297
+ import { useEffect as useEffect23, useMemo as useMemo16, useState as useState27 } from "react";
9298
+ import { useRecordsClient as useRecordsClient15 } from "@ai-matrx/records/react";
9299
+ import { isRuleFilter as isRuleFilter2 } from "@ai-matrx/records";
9300
+ import {
9301
+ bucketWindow,
9302
+ drillRequests,
9303
+ parseDimensionRef,
9304
+ useDrillUrlState
9305
+ } from "@ai-matrx/design-system/data-table";
9306
+ var MEASURE_OPS = [
9307
+ { op: "sum", word: "Sum of", additive: true },
9308
+ { op: "avg", word: "Average", additive: false },
9309
+ { op: "min", word: "Lowest", additive: false },
9310
+ { op: "max", word: "Highest", additive: false },
9311
+ { op: "median", word: "Median", additive: false }
9312
+ ];
9313
+ var DIMENSION_KINDS = {
9314
+ select: "choice",
9315
+ checkbox: "boolean",
9316
+ text: "text",
9317
+ datetime: "time"
9318
+ };
9319
+ function drillDimensionsFor(fields, options) {
9320
+ const out = [];
9321
+ for (const field2 of fields) {
9322
+ const kind = DIMENSION_KINDS[String(editorKindFor(field2))];
9323
+ if (!kind) continue;
9324
+ if (field2.multi) continue;
9325
+ const dim = { key: field2.key, label: fieldName(field2), kind };
9326
+ if (kind === "text") dim.cardinality = "high";
9327
+ if (kind === "choice" && isChoiceField(field2)) {
9328
+ dim.labelFor = (value) => {
9329
+ if (value === null || value === "") return "No value";
9330
+ return optionFor(options.get(field2.key), value)?.label ?? value;
9331
+ };
9332
+ }
9333
+ out.push(dim);
9334
+ }
9335
+ return out;
9336
+ }
9337
+ function drillMeasuresFor(fields) {
9338
+ const out = [{ key: "count", label: "Count", additive: true }];
9339
+ for (const field2 of fields) {
9340
+ const kind = String(editorKindFor(field2));
9341
+ if (kind !== "number" && kind !== "currency" && kind !== "percent") continue;
9342
+ for (const m of MEASURE_OPS) {
9343
+ out.push({ key: `${m.op}_${field2.key}`, label: `${m.word} ${fieldName(field2)}`, additive: m.additive });
9344
+ }
9345
+ }
9346
+ return out;
9347
+ }
9348
+ function measureFor(key) {
9349
+ if (key === "count") return { op: "count" };
9350
+ const at = key.indexOf("_");
9351
+ if (at <= 0) return null;
9352
+ const op2 = key.slice(0, at);
9353
+ if (!MEASURE_OPS.some((m) => m.op === op2)) return null;
9354
+ return { op: op2, key: key.slice(at + 1) };
9355
+ }
9356
+ function questionFromGrouping(grouping) {
9357
+ if (!grouping) return { by: [], across: null, show: ["count"], where: [] };
9358
+ const ref = (field2, grain) => grain ? `${field2}:${grain}` : field2;
9359
+ const by = [ref(grouping.field, grouping.grain), ...(grouping.then ?? []).map((t) => ref(t.field, t.grain))];
9360
+ return {
9361
+ by,
9362
+ across: grouping.across ?? null,
9363
+ show: grouping.show && grouping.show.length > 0 ? grouping.show : ["count"],
9364
+ where: grouping.trail ?? []
9365
+ };
9366
+ }
9367
+ function groupingFromQuestion(question, held) {
9368
+ const [first, ...rest] = question.by.map(parseDimensionRef);
9369
+ if (!first) return void 0;
9370
+ const sameFirst = held?.field === first.key;
9371
+ return {
9372
+ field: first.key,
9373
+ ...first.grain ? { grain: first.grain } : {},
9374
+ ...sameFirst && held?.aggregates ? { aggregates: held.aggregates } : {},
9375
+ ...sameFirst && held?.order ? { order: held.order } : {},
9376
+ ...rest.length > 0 ? { then: rest.map((level) => ({ field: level.key, ...level.grain ? { grain: level.grain } : {} })) } : {},
9377
+ ...question.across ? { across: question.across } : {},
9378
+ ...question.show.length > 0 && !(question.show.length === 1 && question.show[0] === "count") ? { show: question.show } : {},
9379
+ ...question.where.length > 0 ? { trail: question.where } : {}
9380
+ };
9381
+ }
9382
+ function trailClause(fields, w) {
9383
+ const { key, grain } = parseDimensionRef(w.dim);
9384
+ const field2 = fields.find((f) => f.key === key);
9385
+ if (grain && w.value !== null) return { key, value: bucketWindow(w.value, grain), field: field2 };
9386
+ if (field2 && String(editorKindFor(field2)) === "checkbox" && (w.value === "true" || w.value === "false")) {
9387
+ return { key, value: w.value === "true", field: field2 };
9388
+ }
9389
+ return { key, value: w.value, field: field2 };
9390
+ }
9391
+ function filterWithTrail(fields, base, trail) {
9392
+ if (trail.length === 0) return base;
9393
+ if (!base || !isRuleFilter2(base)) {
9394
+ const flat = { ...base ?? {} };
9395
+ for (const w of trail) {
9396
+ const clause = trailClause(fields, w);
9397
+ flat[clause.key] = clause.value;
9398
+ }
9399
+ return flat;
9400
+ }
9401
+ const args = [base];
9402
+ for (const w of trail) {
9403
+ const clause = trailClause(fields, w);
9404
+ if (!clause.field) continue;
9405
+ const ref = { field: clause.field.id };
9406
+ const v = clause.value;
9407
+ if (v === null) args.push({ op: "not", args: [{ op: "present", args: [ref] }] });
9408
+ else if (typeof v === "object") {
9409
+ if (v.from) args.push({ op: "gte", args: [ref, { const: v.from }] });
9410
+ if (v.to) args.push({ op: "lt", args: [ref, { const: v.to }] });
9411
+ } else args.push({ op: "eq", args: [ref, { const: v }] });
9412
+ }
9413
+ return { op: "and", args };
9414
+ }
9415
+ function useDrillAnswers(args) {
9416
+ const client = useRecordsClient15();
9417
+ const { tableId, question, enabled, version } = args;
9418
+ const [answers, setAnswers] = useState27({});
9419
+ const [error, setError] = useState27(null);
9420
+ const askKey2 = JSON.stringify({ by: question.by, across: question.across ?? null, show: question.show, filter: args.filter ?? null });
9421
+ useEffect23(() => {
9422
+ if (!enabled || question.by.length === 0) return;
9423
+ const asked2 = JSON.parse(askKey2);
9424
+ const measures = asked2.show.map(measureFor).filter((m) => m !== null);
9425
+ if (!measures.some((m) => m.op === "count")) measures.unshift({ op: "count" });
9426
+ let cancelled = false;
9427
+ setAnswers({});
9428
+ setError(null);
9429
+ const requests = drillRequests({ by: asked2.by, across: asked2.across, show: asked2.show, where: [] });
9430
+ void Promise.all(
9431
+ requests.map(async (request) => {
9432
+ const time = request.by.find((ref) => parseDimensionRef(ref).grain !== null) ?? null;
9433
+ const plain = request.by.filter((ref) => ref !== time);
9434
+ const grain = time ? parseDimensionRef(time) : null;
9435
+ const got = await client.recordAggregate({
9436
+ table_id: tableId,
9437
+ groupBy: plain,
9438
+ measures,
9439
+ bucket: grain && grain.grain ? { key: grain.key, by: grain.grain } : null,
9440
+ ...asked2.filter ? { filter: asked2.filter } : {},
9441
+ limit: 200
9442
+ });
9443
+ if (!got.ok) return { request, error: got.error.message || "The groups could not be read." };
9444
+ const rows = (got.data ?? []).map((row) => {
9445
+ const groups = {};
9446
+ for (const ref of plain) groups[ref] = row.groups[ref] ?? null;
9447
+ if (time && grain) groups[time] = row.groups[grain.key] ?? null;
9448
+ return { groups, measures: row.measures, row_count: row.row_count };
9449
+ });
9450
+ return { request, rows };
9451
+ })
9452
+ ).then((results) => {
9453
+ if (cancelled) return;
9454
+ const failed = results.find((r) => "error" in r);
9455
+ if (failed) {
9456
+ setError(failed.error);
9457
+ return;
9458
+ }
9459
+ const out = {};
9460
+ for (const r of results) if ("rows" in r) out[r.request.key] = r.rows;
9461
+ setAnswers(out);
9462
+ });
9463
+ return () => {
9464
+ cancelled = true;
9465
+ };
9466
+ }, [client, tableId, askKey2, enabled, version, question.by.length]);
9467
+ return { answers, error };
9468
+ }
9469
+ function useGridDrillQuestion(args) {
9470
+ const { fields, presentation, filter } = args;
9471
+ const choiceKeys = useMemo16(() => fields.filter((f) => isChoiceField(f) && !f.multi).map((f) => f.key), [fields]);
9472
+ const options = useChoiceOptions(fields, args.enabled ? choiceKeys : []);
9473
+ const dimensions = useMemo16(() => drillDimensionsFor(fields, options), [fields, options]);
9474
+ const measures = useMemo16(() => drillMeasuresFor(fields), [fields]);
9475
+ const saved = useMemo16(() => questionFromGrouping(presentation.grouping), [presentation.grouping]);
9476
+ const url = useDrillUrlState({ fallback: saved });
9477
+ const question = useMemo16(() => {
9478
+ const known = (ref) => dimensions.some((d) => d.key === parseDimensionRef(ref).key);
9479
+ const show = url.question.show.filter((key) => measures.some((m) => m.key === key));
9480
+ return {
9481
+ ...url.question,
9482
+ by: url.question.by.filter(known),
9483
+ across: url.question.across && known(url.question.across) ? url.question.across : null,
9484
+ show: show.length > 0 ? show : ["count"],
9485
+ where: url.question.where.filter((w) => known(w.dim))
9486
+ };
9487
+ }, [url.question, dimensions, measures]);
9488
+ const enabled = args.enabled && dimensions.length > 0;
9489
+ const trailFilter = useMemo16(
9490
+ () => enabled ? filterWithTrail(fields, filter, question.where) : filter,
9491
+ [enabled, fields, filter, question.where]
9492
+ );
9493
+ return { enabled, dimensions, measures, question, setQuestion: url.setQuestion, trailFilter };
9494
+ }
9495
+ function useGridDrillConfig(args) {
9496
+ const { tableId, state, presentation, onPresentationChange, version } = args;
9497
+ const { enabled, dimensions, measures, question, setQuestion, trailFilter } = state;
9498
+ const { answers, error } = useDrillAnswers({ tableId, question, filter: trailFilter, version, enabled });
9499
+ return useMemo16(() => {
9500
+ if (!enabled) return null;
9501
+ return {
9502
+ dimensions,
9503
+ measures,
9504
+ question,
9505
+ answers,
9506
+ error,
9507
+ rootLabel: "All records",
9508
+ rowNoun: "record",
9509
+ onQuestionChange: (next) => {
9510
+ setQuestion(next);
9511
+ if (onPresentationChange) {
9512
+ const grouping = groupingFromQuestion(next, presentation.grouping);
9513
+ const { grouping: _dropped, ...rest } = presentation;
9514
+ onPresentationChange(grouping ? { ...rest, grouping } : rest);
9515
+ }
9516
+ }
9517
+ };
9518
+ }, [enabled, dimensions, measures, question, answers, error, setQuestion, onPresentationChange, presentation]);
9519
+ }
9520
+
9275
9521
  // src/Enrich.tsx
9276
- import { useCallback as useCallback12, useEffect as useEffect23, useMemo as useMemo16, useState as useState27 } from "react";
9522
+ import { useCallback as useCallback12, useEffect as useEffect24, useMemo as useMemo17, useState as useState28 } from "react";
9277
9523
  import {
9278
9524
  useFields as useFields3,
9279
- useRecordsClient as useRecordsClient15,
9525
+ useRecordsClient as useRecordsClient16,
9280
9526
  useTable as useTable2
9281
9527
  } from "@ai-matrx/records/react";
9282
9528
  import {
@@ -9373,9 +9619,9 @@ function EnrichBadge({ cell, onPin, className }) {
9373
9619
  ] });
9374
9620
  }
9375
9621
  function useEnrichCells(tableId, recordIds) {
9376
- const client = useRecordsClient15();
9377
- const [cells, setCells] = useState27(/* @__PURE__ */ new Map());
9378
- const [error, setError] = useState27(null);
9622
+ const client = useRecordsClient16();
9623
+ const [cells, setCells] = useState28(/* @__PURE__ */ new Map());
9624
+ const [error, setError] = useState28(null);
9379
9625
  const key = (recordIds ?? []).join(",");
9380
9626
  const refresh = useCallback12(async () => {
9381
9627
  if (!tableId || !recordIds || recordIds.length === 0) {
@@ -9392,24 +9638,24 @@ function useEnrichCells(tableId, recordIds) {
9392
9638
  for (const cell of answered.data) next.set(`${cell.record_id}:${cell.field_key}`, cell);
9393
9639
  setCells(next);
9394
9640
  }, [client, tableId, key]);
9395
- useEffect23(() => {
9641
+ useEffect24(() => {
9396
9642
  void refresh();
9397
9643
  }, [refresh]);
9398
9644
  return { cells, refresh, error };
9399
9645
  }
9400
9646
  var NEVER = "Fill it in once and leave it alone";
9401
9647
  function EnrichPanel({ tableId, fieldId, className }) {
9402
- const client = useRecordsClient15();
9648
+ const client = useRecordsClient16();
9403
9649
  const host = useRecordsUi();
9404
9650
  const table = useTable2(tableId);
9405
9651
  const fields = useFields3(tableId);
9406
9652
  const rights = useTableRights(table.data);
9407
- const [rows, setRows] = useState27(null);
9408
- const [error, setError] = useState27(null);
9409
- const [busy, setBusy] = useState27(null);
9410
- const [outcome, setOutcome] = useState27(null);
9411
- const [preview, setPreview] = useState27(null);
9412
- const [draft, setDraft] = useState27({});
9653
+ const [rows, setRows] = useState28(null);
9654
+ const [error, setError] = useState28(null);
9655
+ const [busy, setBusy] = useState28(null);
9656
+ const [outcome, setOutcome] = useState28(null);
9657
+ const [preview, setPreview] = useState28(null);
9658
+ const [draft, setDraft] = useState28({});
9413
9659
  const load = useCallback12(async () => {
9414
9660
  const answered = await client.enrichments({ table_id: tableId });
9415
9661
  if (!answered.ok) {
@@ -9419,14 +9665,14 @@ function EnrichPanel({ tableId, fieldId, className }) {
9419
9665
  setError(null);
9420
9666
  setRows(answered.data);
9421
9667
  }, [client, tableId]);
9422
- useEffect23(() => {
9668
+ useEffect24(() => {
9423
9669
  void load();
9424
9670
  }, [load]);
9425
- const shown3 = useMemo16(
9671
+ const shown3 = useMemo17(
9426
9672
  () => fieldId ? (rows ?? []).filter((r) => r.field_id === fieldId) : rows ?? [],
9427
9673
  [rows, fieldId]
9428
9674
  );
9429
- const fieldByKey = useMemo16(() => {
9675
+ const fieldByKey = useMemo17(() => {
9430
9676
  const map = /* @__PURE__ */ new Map();
9431
9677
  for (const f of fields.data ?? []) map.set(f.key, f);
9432
9678
  return map;
@@ -9896,7 +10142,7 @@ function columnForField(field2, editing, mayWriteRow, whyNotRow, look, onAskWhoC
9896
10142
  }
9897
10143
 
9898
10144
  // src/PastePreview.tsx
9899
- import { useState as useState28 } from "react";
10145
+ import { useState as useState29 } from "react";
9900
10146
  import { Badge as Badge8, Button as Button23, Separator as Separator2 } from "@ai-matrx/design-system";
9901
10147
  import { Fragment as Fragment12, jsx as jsx35, jsxs as jsxs30 } from "react/jsx-runtime";
9902
10148
  function PastePreview({
@@ -9907,10 +10153,10 @@ function PastePreview({
9907
10153
  onCancel,
9908
10154
  onAddOptions
9909
10155
  }) {
9910
- const [busy, setBusy] = useState28(false);
9911
- const [outcome, setOutcome] = useState28(null);
9912
- const [adding, setAdding] = useState28(null);
9913
- const [addFailed, setAddFailed] = useState28(null);
10156
+ const [busy, setBusy] = useState29(false);
10157
+ const [outcome, setOutcome] = useState29(null);
10158
+ const [adding, setAdding] = useState29(null);
10159
+ const [addFailed, setAddFailed] = useState29(null);
9914
10160
  const nothingToDo = plan.cells === 0;
9915
10161
  return /* @__PURE__ */ jsx35(
9916
10162
  "div",
@@ -10093,8 +10339,8 @@ function confirmLabel(plan, noun, nounPlural) {
10093
10339
  }
10094
10340
 
10095
10341
  // src/gridActions.tsx
10096
- import { useCallback as useCallback13, useEffect as useEffect24, useMemo as useMemo17, useState as useState29 } from "react";
10097
- import { useRecordsClient as useRecordsClient16 } from "@ai-matrx/records/react";
10342
+ import { useCallback as useCallback13, useEffect as useEffect25, useMemo as useMemo18, useState as useState30 } from "react";
10343
+ import { useRecordsClient as useRecordsClient17 } from "@ai-matrx/records/react";
10098
10344
  import { actionRefusals } from "@ai-matrx/records";
10099
10345
  import { Button as Button24, ConfirmDialog as ConfirmDialog2, cn as cn19 } from "@ai-matrx/design-system";
10100
10346
  import { jsx as jsx36, jsxs as jsxs31 } from "react/jsx-runtime";
@@ -10103,10 +10349,10 @@ function rowActionsChanged(tableId) {
10103
10349
  for (const listener of actionListeners.get(tableId) ?? []) listener();
10104
10350
  }
10105
10351
  function useTableActions(tableId, enabled) {
10106
- const client = useRecordsClient16();
10107
- const [actions, setActions] = useState29([]);
10108
- const [error, setError] = useState29(null);
10109
- const [loaded, setLoaded] = useState29(false);
10352
+ const client = useRecordsClient17();
10353
+ const [actions, setActions] = useState30([]);
10354
+ const [error, setError] = useState30(null);
10355
+ const [loaded, setLoaded] = useState30(false);
10110
10356
  const reload = useCallback13(async () => {
10111
10357
  if (!enabled) return;
10112
10358
  const answered = await client.rowActions({ table_id: tableId });
@@ -10119,10 +10365,10 @@ function useTableActions(tableId, enabled) {
10119
10365
  setError(null);
10120
10366
  setActions(answered.data?.actions ?? []);
10121
10367
  }, [client, tableId, enabled]);
10122
- useEffect24(() => {
10368
+ useEffect25(() => {
10123
10369
  void reload();
10124
10370
  }, [reload]);
10125
- useEffect24(() => {
10371
+ useEffect25(() => {
10126
10372
  if (!enabled) return;
10127
10373
  const listener = () => void reload();
10128
10374
  const set = actionListeners.get(tableId) ?? /* @__PURE__ */ new Set();
@@ -10132,7 +10378,7 @@ function useTableActions(tableId, enabled) {
10132
10378
  set.delete(listener);
10133
10379
  };
10134
10380
  }, [tableId, enabled, reload]);
10135
- return useMemo17(() => {
10381
+ return useMemo18(() => {
10136
10382
  const isAgent = (a) => a.kind === "agent";
10137
10383
  return {
10138
10384
  runnable: actions.filter((a) => !isAgent(a) && a.runnable !== false && a.id),
@@ -10174,12 +10420,12 @@ function plural2(n, one, many) {
10174
10420
  return `${n} ${n === 1 ? one : many}`;
10175
10421
  }
10176
10422
  function useActionRunner(args) {
10177
- const client = useRecordsClient16();
10423
+ const client = useRecordsClient17();
10178
10424
  const { rows, fields, reload, noun, nounPlural } = args;
10179
10425
  const onRan = args.onRan;
10180
- const [asking, setAsking] = useState29(null);
10181
- const [busy, setBusy] = useState29(null);
10182
- const [outcome, setOutcome] = useState29(null);
10426
+ const [asking, setAsking] = useState30(null);
10427
+ const [busy, setBusy] = useState30(null);
10428
+ const [outcome, setOutcome] = useState30(null);
10183
10429
  const perform = useCallback13(
10184
10430
  async (action, ids) => {
10185
10431
  if (!action.id || ids.length === 0) return;
@@ -10448,8 +10694,8 @@ function useTableToolbarSheetExtras() {
10448
10694
  }
10449
10695
 
10450
10696
  // src/GridLayoutMenu.tsx
10451
- import { useEffect as useEffect25, useState as useState30 } from "react";
10452
- import { useRecordsClient as useRecordsClient17 } from "@ai-matrx/records/react";
10697
+ import { useEffect as useEffect26, useState as useState31 } from "react";
10698
+ import { useRecordsClient as useRecordsClient18 } from "@ai-matrx/records/react";
10453
10699
  import {
10454
10700
  Button as Button25,
10455
10701
  DropdownMenu as DropdownMenu2,
@@ -10464,12 +10710,12 @@ import {
10464
10710
  } from "@ai-matrx/design-system";
10465
10711
  import { Fragment as Fragment14, jsx as jsx39, jsxs as jsxs33 } from "react/jsx-runtime";
10466
10712
  function useStoreGridLayout(tableId) {
10467
- const client = useRecordsClient17();
10468
- const [answer, setAnswer] = useState30({
10713
+ const client = useRecordsClient18();
10714
+ const [answer, setAnswer] = useState31({
10469
10715
  layout: null,
10470
10716
  error: null
10471
10717
  });
10472
- useEffect25(() => {
10718
+ useEffect26(() => {
10473
10719
  let alive = true;
10474
10720
  void client.gridLayout({ table_id: tableId, view_id: null }).then((answered) => {
10475
10721
  if (!alive) return;
@@ -10567,7 +10813,7 @@ function GridLayoutMenu({
10567
10813
  }
10568
10814
 
10569
10815
  // src/gridActionsHeader.tsx
10570
- import { useState as useState33 } from "react";
10816
+ import { useState as useState34 } from "react";
10571
10817
  import {
10572
10818
  Button as Button27,
10573
10819
  Dialog as Dialog4,
@@ -10584,8 +10830,8 @@ import {
10584
10830
  } from "@ai-matrx/design-system";
10585
10831
 
10586
10832
  // src/RowActionsEditor.tsx
10587
- import { useCallback as useCallback14, useEffect as useEffect27, useMemo as useMemo18, useState as useState32 } from "react";
10588
- import { useFields as useFields4, useRecords as useRecords3, useRecordsClient as useRecordsClient19 } from "@ai-matrx/records/react";
10833
+ import { useCallback as useCallback14, useEffect as useEffect28, useMemo as useMemo19, useState as useState33 } from "react";
10834
+ import { useFields as useFields4, useRecords as useRecords3, useRecordsClient as useRecordsClient20 } from "@ai-matrx/records/react";
10589
10835
  import {
10590
10836
  Badge as Badge9,
10591
10837
  BasicInput as BasicInput11,
@@ -10602,8 +10848,8 @@ import {
10602
10848
  } from "@ai-matrx/design-system";
10603
10849
 
10604
10850
  // src/rowActionPreview.tsx
10605
- import { useEffect as useEffect26, useState as useState31 } from "react";
10606
- import { useRecordsClient as useRecordsClient18 } from "@ai-matrx/records/react";
10851
+ import { useEffect as useEffect27, useState as useState32 } from "react";
10852
+ import { useRecordsClient as useRecordsClient19 } from "@ai-matrx/records/react";
10607
10853
  import { cn as cn20 } from "@ai-matrx/design-system";
10608
10854
  import { jsx as jsx40, jsxs as jsxs34 } from "react/jsx-runtime";
10609
10855
  function isComputed(field2) {
@@ -10654,10 +10900,10 @@ var RESULT_WORDS = {
10654
10900
  unknown: "a value"
10655
10901
  };
10656
10902
  function useFormulaReadings(tableId, formulas) {
10657
- const client = useRecordsClient18();
10658
- const [readings, setReadings] = useState31({});
10903
+ const client = useRecordsClient19();
10904
+ const [readings, setReadings] = useState32({});
10659
10905
  const key = formulas.join("\0");
10660
- useEffect26(() => {
10906
+ useEffect27(() => {
10661
10907
  if (!tableId) return;
10662
10908
  let live = true;
10663
10909
  for (const text of formulas) {
@@ -10817,20 +11063,20 @@ function RowActionsSection({
10817
11063
  className,
10818
11064
  startAdding = false
10819
11065
  }) {
10820
- const client = useRecordsClient19();
11066
+ const client = useRecordsClient20();
10821
11067
  const fields = useFields4(tableId);
10822
11068
  const records = useRecords3(tableId, { pageSize: 20 });
10823
- const [actions, setActions] = useState32([]);
10824
- const [stale, setStale] = useState32(0);
10825
- const [loaded, setLoaded] = useState32(false);
10826
- const [readError, setReadError] = useState32(null);
10827
- const [saveError, setSaveError] = useState32(null);
10828
- const [saving, setSaving] = useState32(false);
10829
- const [editing, setEditing] = useState32(null);
10830
- const [retiring, setRetiring] = useState32(null);
10831
- const [retired, setRetired] = useState32(null);
10832
- const [colors, setColors] = useState32([]);
10833
- const [addStarted, setAddStarted] = useState32(false);
11069
+ const [actions, setActions] = useState33([]);
11070
+ const [stale, setStale] = useState33(0);
11071
+ const [loaded, setLoaded] = useState33(false);
11072
+ const [readError, setReadError] = useState33(null);
11073
+ const [saveError, setSaveError] = useState33(null);
11074
+ const [saving, setSaving] = useState33(false);
11075
+ const [editing, setEditing] = useState33(null);
11076
+ const [retiring, setRetiring] = useState33(null);
11077
+ const [retired, setRetired] = useState33(null);
11078
+ const [colors, setColors] = useState33([]);
11079
+ const [addStarted, setAddStarted] = useState33(false);
10834
11080
  const reload = useCallback14(async () => {
10835
11081
  const answered = await client.rowActions({ table_id: tableId });
10836
11082
  setLoaded(true);
@@ -10842,10 +11088,10 @@ function RowActionsSection({
10842
11088
  setActions(answered.data?.actions ?? []);
10843
11089
  setStale((answered.data?.stale ?? []).length);
10844
11090
  }, [client, tableId]);
10845
- useEffect27(() => {
11091
+ useEffect28(() => {
10846
11092
  void reload();
10847
11093
  }, [reload]);
10848
- useEffect27(() => {
11094
+ useEffect28(() => {
10849
11095
  let live = true;
10850
11096
  void client.tableDecorations({ table_id: tableId }).then((answered) => {
10851
11097
  if (live && answered.ok) setColors(answered.data?.colors ?? []);
@@ -10890,7 +11136,7 @@ function RowActionsSection({
10890
11136
  if (await declare2(next)) setRetired(null);
10891
11137
  };
10892
11138
  const allFields = fields.data ?? [];
10893
- useEffect27(() => {
11139
+ useEffect28(() => {
10894
11140
  if (!startAdding || addStarted || !loaded || readError) return;
10895
11141
  setAddStarted(true);
10896
11142
  setEditing("new");
@@ -11037,10 +11283,10 @@ function ActionForm({
11037
11283
  onSave,
11038
11284
  className
11039
11285
  }) {
11040
- const [draft, setDraft] = useState32(() => draftOf(original));
11286
+ const [draft, setDraft] = useState33(() => draftOf(original));
11041
11287
  const host = useRecordsUi();
11042
- const [previewId, setPreviewId] = useState32(rows[0]?.id ?? "");
11043
- const settable = useMemo18(() => settableFields(fields), [fields]);
11288
+ const [previewId, setPreviewId] = useState33(rows[0]?.id ?? "");
11289
+ const settable = useMemo19(() => settableFields(fields), [fields]);
11044
11290
  const previewRow = rows.find((r) => r.id === previewId) ?? rows[0] ?? null;
11045
11291
  const candidate = actionOf(draft, original);
11046
11292
  const complete = draft.steps.every((s) => s.field !== "");
@@ -11269,7 +11515,7 @@ function ActionsHeaderControls({
11269
11515
  mayManage,
11270
11516
  whyNotManage
11271
11517
  }) {
11272
- const [open, setOpen] = useState33(null);
11518
+ const [open, setOpen] = useState34(null);
11273
11519
  return /* @__PURE__ */ jsxs36(Fragment15, { children: [
11274
11520
  mayManage ? /* @__PURE__ */ jsx42(
11275
11521
  Button27,
@@ -11332,8 +11578,8 @@ function ActionsHeaderControls({
11332
11578
  }
11333
11579
 
11334
11580
  // src/gridUndo.tsx
11335
- import { useCallback as useCallback15, useEffect as useEffect28, useLayoutEffect, useMemo as useMemo19, useRef as useRef13, useState as useState34, useSyncExternalStore } from "react";
11336
- import { useRecordsClient as useRecordsClient20 } from "@ai-matrx/records/react";
11581
+ import { useCallback as useCallback15, useEffect as useEffect29, useLayoutEffect, useMemo as useMemo20, useRef as useRef13, useState as useState35, useSyncExternalStore } from "react";
11582
+ import { useRecordsClient as useRecordsClient21 } from "@ai-matrx/records/react";
11337
11583
  import { announceRecordChanged as announceRecordChanged2 } from "@ai-matrx/records/core";
11338
11584
  import { Button as Button28 } from "@ai-matrx/design-system";
11339
11585
  import { createUndoStack, popRedo, popUndo, pushUndo } from "@ai-matrx/design-system/data-table";
@@ -11353,13 +11599,13 @@ function changesFor(step2, direction) {
11353
11599
  return changes;
11354
11600
  }
11355
11601
  function useGridUndo(args) {
11356
- const client = useRecordsClient20();
11602
+ const client = useRecordsClient21();
11357
11603
  const { tableId, reload, forget } = args;
11358
- const [held, setHeld] = useState34(() => ({ stack: createUndoStack(args.depth ?? 100), steps: /* @__PURE__ */ new Map() }));
11604
+ const [held, setHeld] = useState35(() => ({ stack: createUndoStack(args.depth ?? 100), steps: /* @__PURE__ */ new Map() }));
11359
11605
  const heldRef = useRef13(held);
11360
11606
  heldRef.current = held;
11361
- const [busy, setBusy] = useState34(false);
11362
- const [notice, setNotice] = useState34(null);
11607
+ const [busy, setBusy] = useState35(false);
11608
+ const [notice, setNotice] = useState35(null);
11363
11609
  const counter = useRef13(0);
11364
11610
  const dismiss = useCallback15(() => setNotice(null), []);
11365
11611
  const push = useCallback15((step2) => {
@@ -11427,7 +11673,7 @@ function useGridUndo(args) {
11427
11673
  );
11428
11674
  const undo = useCallback15(() => apply("undo"), [apply]);
11429
11675
  const redo = useCallback15(() => apply("redo"), [apply]);
11430
- return useMemo19(
11676
+ return useMemo20(
11431
11677
  () => ({
11432
11678
  push,
11433
11679
  undo,
@@ -11450,7 +11696,7 @@ function useUndoSource(undo) {
11450
11696
  listeners: /* @__PURE__ */ new Set()
11451
11697
  });
11452
11698
  box.current.undo = undo;
11453
- const source = useMemo19(
11699
+ const source = useMemo20(
11454
11700
  () => ({
11455
11701
  face: () => box.current.face,
11456
11702
  subscribe: (listener) => {
@@ -11519,7 +11765,7 @@ function UndoRedoPair({ face, onUndo, onRedo }) {
11519
11765
  function UndoNotice({ undo }) {
11520
11766
  const notice = undo.notice;
11521
11767
  const dismiss = undo.dismiss;
11522
- useEffect28(() => {
11768
+ useEffect29(() => {
11523
11769
  if (!notice || notice.refusal) return;
11524
11770
  const timer = setTimeout(dismiss, 8e3);
11525
11771
  return () => clearTimeout(timer);
@@ -11551,7 +11797,7 @@ function undoKey(event) {
11551
11797
  }
11552
11798
 
11553
11799
  // src/gridAssist.tsx
11554
- import { useCallback as useCallback16, useEffect as useEffect30, useMemo as useMemo20, useRef as useRef14, useState as useState36 } from "react";
11800
+ import { useCallback as useCallback16, useEffect as useEffect31, useMemo as useMemo21, useRef as useRef14, useState as useState37 } from "react";
11555
11801
  import { wholeValueOf as wholeValueOf3 } from "@ai-matrx/records/core";
11556
11802
  import { useContentTransferCapabilities } from "@ai-matrx/design-system/content-transfer";
11557
11803
 
@@ -11621,7 +11867,7 @@ function gridContextKey(snapshot) {
11621
11867
  }
11622
11868
 
11623
11869
  // src/gridLongText.tsx
11624
- import { useEffect as useEffect29, useState as useState35 } from "react";
11870
+ import { useEffect as useEffect30, useState as useState36 } from "react";
11625
11871
  import {
11626
11872
  BasicTextarea as BasicTextarea7,
11627
11873
  Button as Button29,
@@ -11659,16 +11905,16 @@ function WholeTextDialog({
11659
11905
  onClose
11660
11906
  }) {
11661
11907
  const whole = useWholeText(target?.pointer ?? null);
11662
- const [draft, setDraft] = useState35(null);
11663
- const [cleanNote, setCleanNote] = useState35(null);
11908
+ const [draft, setDraft] = useState36(null);
11909
+ const [cleanNote, setCleanNote] = useState36(null);
11664
11910
  const renderText = useRecordsUi().renderText;
11665
- const [reading, setReading] = useState35(false);
11911
+ const [reading, setReading] = useState36(false);
11666
11912
  const startingText = target === null ? null : target.pointer ? whole.state === "ready" ? whole.text : null : typeof target.value === "string" ? target.value : target.value === null || target.value === void 0 ? "" : String(target.value);
11667
- useEffect29(() => {
11913
+ useEffect30(() => {
11668
11914
  setDraft(startingText);
11669
11915
  setCleanNote(null);
11670
11916
  }, [target?.rowId, target?.key, startingText]);
11671
- useEffect29(() => {
11917
+ useEffect30(() => {
11672
11918
  setReading(!mayWrite && Boolean(renderText));
11673
11919
  }, [target?.rowId, target?.key, mayWrite, renderText]);
11674
11920
  const open = target !== null;
@@ -11740,8 +11986,8 @@ import { jsx as jsx45 } from "react/jsx-runtime";
11740
11986
  function useGridAssist(args) {
11741
11987
  const { enabled, host, tableId, table, fields, rows, editing } = args;
11742
11988
  const reference = useContentTransferCapabilities().reference;
11743
- const [cursor, setCursor] = useState36(null);
11744
- const [whole, setWhole] = useState36(null);
11989
+ const [cursor, setCursor] = useState37(null);
11990
+ const [whole, setWhole] = useState37(null);
11745
11991
  const say2 = useCallback16(
11746
11992
  (ok, message) => ok ? host.notify?.success(message) : host.notify?.error(message),
11747
11993
  [host.notify]
@@ -11756,7 +12002,7 @@ function useGridAssist(args) {
11756
12002
  const lastKey = useRef14("");
11757
12003
  const editingAt = editing.editing;
11758
12004
  const draft = editing.draft;
11759
- useEffect30(() => {
12005
+ useEffect31(() => {
11760
12006
  if (!enabled || !onGridContext) return;
11761
12007
  const snapshot = gridContextSnapshot({
11762
12008
  tableId,
@@ -11795,7 +12041,7 @@ function useGridAssist(args) {
11795
12041
  [reference, say2]
11796
12042
  );
11797
12043
  const name = table ? tableName(table) : "";
11798
- const refFor = useMemo20(
12044
+ const refFor = useMemo21(
11799
12045
  () => ({
11800
12046
  table: () => ({
11801
12047
  id: `table:${tableId}`,
@@ -11931,8 +12177,8 @@ function useGridAssist(args) {
11931
12177
  }
11932
12178
 
11933
12179
  // src/gridBulk.tsx
11934
- import { useCallback as useCallback17, useMemo as useMemo21, useState as useState37 } from "react";
11935
- import { useRecordsClient as useRecordsClient21 } from "@ai-matrx/records/react";
12180
+ import { useCallback as useCallback17, useMemo as useMemo22, useState as useState38 } from "react";
12181
+ import { useRecordsClient as useRecordsClient22 } from "@ai-matrx/records/react";
11936
12182
  import { announceRecordChanged as announceRecordChanged3 } from "@ai-matrx/records/core";
11937
12183
  import {
11938
12184
  Button as Button30,
@@ -11986,10 +12232,10 @@ function planDuplicates(ids, rows, fields) {
11986
12232
  });
11987
12233
  }
11988
12234
  function useGridBulk(args) {
11989
- const client = useRecordsClient21();
12235
+ const client = useRecordsClient22();
11990
12236
  const { tableId, rows, fields, noun, nounPlural, reload, forget, pushUndo: pushUndo2 } = args;
11991
- const [busy, setBusy] = useState37(false);
11992
- const [refusal2, setRefusal] = useState37(null);
12237
+ const [busy, setBusy] = useState38(false);
12238
+ const [refusal2, setRefusal] = useState38(null);
11993
12239
  const send = useCallback17(
11994
12240
  async (changes) => {
11995
12241
  setBusy(true);
@@ -12054,11 +12300,11 @@ function BulkActions({
12054
12300
  nounPlural,
12055
12301
  onDone
12056
12302
  }) {
12057
- const typeable = useMemo21(() => fields.filter(fieldIsEditable), [fields]);
12058
- const [asking, setAsking] = useState37(null);
12059
- const [key, setKey] = useState37("");
12060
- const [value, setValue] = useState37(null);
12061
- const [confirmDelete, setConfirmDelete] = useState37(false);
12303
+ const typeable = useMemo22(() => fields.filter(fieldIsEditable), [fields]);
12304
+ const [asking, setAsking] = useState38(null);
12305
+ const [key, setKey] = useState38("");
12306
+ const [value, setValue] = useState38(null);
12307
+ const [confirmDelete, setConfirmDelete] = useState38(false);
12062
12308
  const field2 = typeable.find((f) => f.key === key) ?? typeable[0];
12063
12309
  const many = countOf(ids.length, noun, nounPlural);
12064
12310
  const open = (kind) => {
@@ -12159,8 +12405,8 @@ function BulkActions({
12159
12405
  }
12160
12406
 
12161
12407
  // src/handOrder.tsx
12162
- import { useEffect as useEffect31, useMemo as useMemo22, useRef as useRef15, useState as useState38 } from "react";
12163
- import { useRecordsClient as useRecordsClient22 } from "@ai-matrx/records/react";
12408
+ import { useEffect as useEffect32, useMemo as useMemo23, useRef as useRef15, useState as useState39 } from "react";
12409
+ import { useRecordsClient as useRecordsClient23 } from "@ai-matrx/records/react";
12164
12410
  import { stableFilterKey as stableFilterKey2 } from "@ai-matrx/records";
12165
12411
  import { Button as Button31, ConfirmDialog as ConfirmDialog4, Popover as Popover4, PopoverContent as PopoverContent4, PopoverTrigger as PopoverTrigger4, cn as cn22 } from "@ai-matrx/design-system";
12166
12412
 
@@ -12534,7 +12780,7 @@ function SortGlyph() {
12534
12780
  ] });
12535
12781
  }
12536
12782
  function SortStateControl({ label, line, attention = false, actions = [], mode }) {
12537
- const [open, setOpen] = useState38(false);
12783
+ const [open, setOpen] = useState39(false);
12538
12784
  return /* @__PURE__ */ jsxs40(Popover4, { open, onOpenChange: setOpen, children: [
12539
12785
  /* @__PURE__ */ jsx47(PopoverTrigger4, { asChild: true, children: /* @__PURE__ */ jsxs40(
12540
12786
  Button31,
@@ -12622,18 +12868,18 @@ function moveRow(list, from, to) {
12622
12868
  }
12623
12869
  var DOOR_PAGE_MAX = 500;
12624
12870
  function useHandOrderRows(args) {
12625
- const client = useRecordsClient22();
12871
+ const client = useRecordsClient23();
12626
12872
  const { viewId, active, page, pageSize } = args;
12627
12873
  const filter = args.filter && Object.keys(args.filter).length > 0 ? args.filter : null;
12628
12874
  const filterKey = filter ? stableFilterKey2(filter) : "";
12629
12875
  const filterNow = useRef15(filter);
12630
12876
  filterNow.current = filter;
12631
- const [answer, setAnswer] = useState38(null);
12632
- const [tick, setTick] = useState38(0);
12877
+ const [answer, setAnswer] = useState39(null);
12878
+ const [tick, setTick] = useState39(0);
12633
12879
  const limit = Math.max(1, Math.min(pageSize, DOOR_PAGE_MAX));
12634
12880
  const offset = Math.max(0, page) * limit;
12635
12881
  const key = `${viewId ?? ""}:${limit}:${offset}:${filterKey}`;
12636
- useEffect31(() => {
12882
+ useEffect32(() => {
12637
12883
  if (!active || !viewId) return;
12638
12884
  let cancelled = false;
12639
12885
  void client.readInViewOrder({ view_id: viewId, filter: filterNow.current, limit, offset }).then((result) => {
@@ -12646,7 +12892,7 @@ function useHandOrderRows(args) {
12646
12892
  cancelled = true;
12647
12893
  };
12648
12894
  }, [client, viewId, active, limit, offset, key, filterKey, args.version, tick]);
12649
- const rows = useMemo22(() => {
12895
+ const rows = useMemo23(() => {
12650
12896
  if (!active || !viewId || !answer || answer.key !== key) return null;
12651
12897
  if (answer.error) return null;
12652
12898
  return answer.rows;
@@ -12667,12 +12913,12 @@ function HandOrderDialog({
12667
12913
  more,
12668
12914
  onSaved
12669
12915
  }) {
12670
- const client = useRecordsClient22();
12671
- const [list, setList] = useState38([...items]);
12672
- const [dragging, setDragging] = useState38(null);
12673
- const [busy, setBusy] = useState38(false);
12674
- const [refused, setRefused] = useState38(null);
12675
- useEffect31(() => {
12916
+ const client = useRecordsClient23();
12917
+ const [list, setList] = useState39([...items]);
12918
+ const [dragging, setDragging] = useState39(null);
12919
+ const [busy, setBusy] = useState39(false);
12920
+ const [refused, setRefused] = useState39(null);
12921
+ useEffect32(() => {
12676
12922
  if (open) {
12677
12923
  setList([...items]);
12678
12924
  setRefused(null);
@@ -12748,6 +12994,7 @@ import { Fragment as Fragment18, jsx as jsx48, jsxs as jsxs41 } from "react/jsx-
12748
12994
  var NO_COLUMNS_YET = "This table has no columns yet";
12749
12995
  var NO_COLUMNS_WHY = "A column is what a record holds \u2014 a name, a date, an amount, a person. Add the first one and the grid appears with it; everything else on this page works the moment it exists.";
12750
12996
  var NO_SUMMARIES = Object.freeze({});
12997
+ var NO_DRILL_FIELDS = Object.freeze([]);
12751
12998
  var rowIdOf = (row) => row.id;
12752
12999
  function Grid({
12753
13000
  tableId,
@@ -12770,16 +13017,16 @@ function Grid({
12770
13017
  const toolbarSlot = useTableToolbarSlot();
12771
13018
  const fills = footer === "sticky";
12772
13019
  const host = useRecordsUi();
12773
- const client = useRecordsClient23();
13020
+ const client = useRecordsClient24();
12774
13021
  const table = useTable3(tableId);
12775
13022
  const fields = useFields5(tableId);
12776
13023
  const decorations = useTableDecorations(tableId, fields.data);
12777
- const mergedStyle = useMemo23(
13024
+ const mergedStyle = useMemo24(
12778
13025
  () => resolveTableStyle(decorations.data, fields.data ?? [], presentation.style),
12779
13026
  [decorations.data, fields.data, presentation.style]
12780
13027
  );
12781
13028
  const paintedChoices = useChoiceOptions(fields.data ?? [], choiceKeysIn(mergedStyle, fields.data ?? []));
12782
- const paint = useMemo23(
13029
+ const paint = useMemo24(
12783
13030
  () => paintByOption(mergedStyle, fields.data ?? [], paintedChoices, storedChoiceColorLookup(fields.data ?? [], colorFromTheValue)),
12784
13031
  [mergedStyle, fields.data, paintedChoices]
12785
13032
  );
@@ -12788,24 +13035,24 @@ function Grid({
12788
13035
  const toolbarFold2 = useTableToolbarFold();
12789
13036
  const sheetExtras = useTableToolbarSheetExtras();
12790
13037
  const rights = useTableRights(table.data);
12791
- const [heldOrder, setHeldOrder] = useState39(null);
13038
+ const [heldOrder, setHeldOrder] = useState40(null);
12792
13039
  const sortsKey = JSON.stringify(viewOrder?.sorts ?? []);
12793
- useEffect32(() => {
13040
+ useEffect33(() => {
12794
13041
  setHeldOrder(null);
12795
13042
  }, [viewOrder?.viewId, viewOrder?.order, sortsKey]);
12796
13043
  const viewId = viewOrder?.viewId ?? null;
12797
13044
  const order = heldOrder?.order ?? viewOrder?.order ?? null;
12798
13045
  const viewSorts = heldOrder?.sorts ?? viewOrder?.sorts ?? [];
12799
13046
  const manual = order === "manual" && viewId !== null;
12800
- const defaultSort = useMemo23(() => defaultSortOf(table.data, fields.data ?? []), [table.data, fields.data]);
12801
- const viewSort = useMemo23(() => {
13047
+ const defaultSort = useMemo24(() => defaultSortOf(table.data, fields.data ?? []), [table.data, fields.data]);
13048
+ const viewSort = useMemo24(() => {
12802
13049
  const first = viewSorts[0];
12803
13050
  if (!first) return null;
12804
13051
  return (fields.data ?? []).some((f) => f.key === first.field) ? { id: first.field, direction: first.direction } : null;
12805
13052
  }, [viewSorts, fields.data]);
12806
13053
  const openingSort = manual ? null : viewSort ?? defaultSort;
12807
13054
  const openingKey = openingSort ? `${openingSort.id}:${openingSort.direction}` : "none";
12808
- const [query, setQuery] = useState39(() => ({
13055
+ const [query, setQuery] = useState40(() => ({
12809
13056
  page: 1,
12810
13057
  pageSize,
12811
13058
  search: "",
@@ -12813,25 +13060,32 @@ function Grid({
12813
13060
  columnFilters: {},
12814
13061
  sort: openingSort
12815
13062
  }));
12816
- useEffect32(() => {
13063
+ useEffect33(() => {
12817
13064
  setQuery((held) => ({ ...held, sort: openingSort, page: 1 }));
12818
13065
  }, [openingKey]);
12819
13066
  const columnSort = query.sort;
12820
- const [page, setPage] = useState39(0);
12821
- const [searchTerm, setSearchTerm] = useState39("");
12822
- useEffect32(() => {
13067
+ const [page, setPage] = useState40(0);
13068
+ const [searchTerm, setSearchTerm] = useState40("");
13069
+ useEffect33(() => {
12823
13070
  if (!merged) return;
12824
13071
  const wanted = query.search.trim();
12825
13072
  if (wanted === searchTerm) return;
12826
13073
  const timer = setTimeout(() => setSearchTerm(wanted), 250);
12827
13074
  return () => clearTimeout(timer);
12828
13075
  }, [merged, query.search, searchTerm]);
12829
- const question = useMemo23(
13076
+ const question = useMemo24(
12830
13077
  () => merged ? storeQuestion(fields.data ?? [], filter, query.columnFilters) : { filter, refused: [] },
12831
13078
  [merged, fields.data, filter, query.columnFilters]
12832
13079
  );
13080
+ const drillState = useGridDrillQuestion({
13081
+ fields: fields.data ?? NO_DRILL_FIELDS,
13082
+ presentation,
13083
+ filter: question.filter,
13084
+ enabled: merged
13085
+ });
13086
+ const readFilter = drillState.enabled ? drillState.trailFilter : question.filter;
12833
13087
  const localQuestion = query.search.trim() !== "" || Object.values(query.columnFilters).some((value) => value !== void 0 && value !== null);
12834
- const clearQuestion = useMemo23(() => {
13088
+ const clearQuestion = useMemo24(() => {
12835
13089
  const external = Boolean(filter) && Boolean(onClearFilter);
12836
13090
  if (!localQuestion && !external) return void 0;
12837
13091
  return () => {
@@ -12839,18 +13093,18 @@ function Grid({
12839
13093
  if (external) onClearFilter?.();
12840
13094
  };
12841
13095
  }, [localQuestion, filter, onClearFilter]);
12842
- const pageSort = useMemo23(() => merged ? pageSortFor(fields.data ?? [], query.sort) : [], [merged, fields.data, query.sort]);
13096
+ const pageSort = useMemo24(() => merged ? pageSortFor(fields.data ?? [], query.sort) : [], [merged, fields.data, query.sort]);
12843
13097
  const classicRead = useRecords4(merged ? null : tableId, { pageSize, page, ...filter ? { filter } : {} });
12844
13098
  const serverRead = useRecordPage(merged && fields.data ? tableId : null, {
12845
13099
  pageSize: query.pageSize,
12846
13100
  page: Math.max(0, query.page - 1),
12847
- ...question.filter ? { filter: question.filter } : {},
13101
+ ...readFilter ? { filter: readFilter } : {},
12848
13102
  search: searchTerm,
12849
13103
  sort: pageSort,
12850
13104
  viewId: manual && pageSort.length === 0 ? viewId : null
12851
13105
  });
12852
13106
  const records = merged ? serverRead : classicRead;
12853
- const storeRows = useMemo23(() => records.data?.rows ?? [], [records.data]);
13107
+ const storeRows = useMemo24(() => records.data?.rows ?? [], [records.data]);
12854
13108
  const hand = useHandOrderRows({
12855
13109
  viewId,
12856
13110
  active: manual && !merged,
@@ -12859,15 +13113,15 @@ function Grid({
12859
13113
  filter: filter ?? null,
12860
13114
  version: records.data
12861
13115
  });
12862
- const pageRows = useMemo23(() => manual && !merged ? hand.rows ?? [] : storeRows, [manual, merged, hand.rows, storeRows]);
13116
+ const pageRows = useMemo24(() => manual && !merged ? hand.rows ?? [] : storeRows, [manual, merged, hand.rows, storeRows]);
12863
13117
  const added = useAddedRows({
12864
13118
  tableId,
12865
13119
  enabled: merged,
12866
13120
  pageRows,
12867
- pageKey: JSON.stringify([query.page, query.pageSize, searchTerm, pageSort, question.filter ?? null])
13121
+ pageKey: JSON.stringify([query.page, query.pageSize, searchTerm, pageSort, readFilter ?? null])
12868
13122
  });
12869
13123
  const rows = added.rows;
12870
- const rowIds = useMemo23(() => rows.map((row) => row.id), [rows]);
13124
+ const rowIds = useMemo24(() => rows.map((row) => row.id), [rows]);
12871
13125
  const askPerRow = Boolean(editable) && !host.rights && rights.known && !rights.write && rows.length > 0;
12872
13126
  const rowRights = useRowRights(rowIds, askPerRow);
12873
13127
  const mayWriteRow = useCallback18(
@@ -12901,7 +13155,7 @@ function Grid({
12901
13155
  });
12902
13156
  const editingNow = useRef16(editing);
12903
13157
  editingNow.current = editing;
12904
- const editingHandle = useMemo23(
13158
+ const editingHandle = useMemo24(
12905
13159
  () => new Proxy({}, {
12906
13160
  get: (_target, key) => editingNow.current[key]
12907
13161
  }),
@@ -12919,14 +13173,14 @@ function Grid({
12919
13173
  });
12920
13174
  };
12921
13175
  const storeLayout = useStoreGridLayout(tableId);
12922
- const [localLook, setLocalLook] = useState39(null);
12923
- const [localSummaries, setLocalSummaries] = useState39(null);
13176
+ const [localLook, setLocalLook] = useState40(null);
13177
+ const [localSummaries, setLocalSummaries] = useState40(null);
12924
13178
  const titleKey = table.data?.title_field ?? null;
12925
- const sortedKeys = useMemo23(
13179
+ const sortedKeys = useMemo24(
12926
13180
  () => lookColumnKeys([...fields.data ?? []].sort(compareFieldOrder).map((f) => f.key), titleKey),
12927
13181
  [fields.data, titleKey]
12928
13182
  );
12929
- const look = useMemo23(() => {
13183
+ const look = useMemo24(() => {
12930
13184
  const own2 = {
12931
13185
  rowHeight: presentation.rowHeight,
12932
13186
  frozen: presentation.frozen,
@@ -12938,8 +13192,8 @@ function Grid({
12938
13192
  return resolveLook(storeLayout.layout, own2, sortedKeys);
12939
13193
  }, [presentation, localLook, storeLayout.layout, sortedKeys]);
12940
13194
  const frozenList = look.frozen;
12941
- const frozenKeys = useMemo23(() => new Set(frozenList), [frozenList]);
12942
- const ordered = useMemo23(() => {
13195
+ const frozenKeys = useMemo24(() => new Set(frozenList), [frozenList]);
13196
+ const ordered = useMemo24(() => {
12943
13197
  const all = [...fields.data ?? []].sort(compareFieldOrder);
12944
13198
  if (frozenKeys.size === 0) return all;
12945
13199
  const pinned = frozenList.map((key) => all.find((f) => f.key === key)).filter((f) => f !== void 0);
@@ -12977,12 +13231,13 @@ function Grid({
12977
13231
  forget: editing.forget,
12978
13232
  pushUndo: undo.push
12979
13233
  });
12980
- const [selectedIds, setSelectedIds] = useState39([]);
13234
+ const [selectedIds, setSelectedIds] = useState40([]);
12981
13235
  const offerSelection = !readOnly && canWrite && (merged || tableActions.runnable.length > 0);
12982
- const [reordering, setReordering] = useState39(false);
13236
+ const [reordering, setReordering] = useState40(false);
12983
13237
  const chosenSummaries = localSummaries ?? presentation.summaries ?? NO_SUMMARIES;
12984
- const summaries = useColumnSummaries({ tableId, chosen: chosenSummaries, filter: question.filter, version: records.data });
12985
- const [duplicated, setDuplicated] = useState39(null);
13238
+ const summaries = useColumnSummaries({ tableId, chosen: chosenSummaries, filter: readFilter, version: records.data });
13239
+ const drillConfig = useGridDrillConfig({ tableId, state: drillState, presentation, onPresentationChange, version: records.data });
13240
+ const [duplicated, setDuplicated] = useState40(null);
12986
13241
  const duplicate = useCallback18(
12987
13242
  async (row) => {
12988
13243
  const document2 = row.document ?? {};
@@ -13021,7 +13276,7 @@ function Grid({
13021
13276
  },
13022
13277
  [client, fields.data, host, records, table.data, tableId, merged, added, manual, viewId, rows, viewOrder, hand, undo]
13023
13278
  );
13024
- const recordIds = useMemo23(() => rows.map((r) => r.id), [rows]);
13279
+ const recordIds = useMemo24(() => rows.map((r) => r.id), [rows]);
13025
13280
  const { cells: enrichCells, refresh: refreshEnrich } = useEnrichCells(tableId, recordIds);
13026
13281
  const pinCell = useCallback18(
13027
13282
  async (recordId, fieldKey, pinned) => {
@@ -13035,10 +13290,10 @@ function Grid({
13035
13290
  },
13036
13291
  [client, host, refreshEnrich]
13037
13292
  );
13038
- const [pastePlan, setPastePlan] = useState39(null);
13039
- const [deleting, setDeleting] = useState39(null);
13040
- const [deleteBusy, setDeleteBusy] = useState39(false);
13041
- const [archived, setArchived] = useState39(null);
13293
+ const [pastePlan, setPastePlan] = useState40(null);
13294
+ const [deleting, setDeleting] = useState40(null);
13295
+ const [deleteBusy, setDeleteBusy] = useState40(false);
13296
+ const [archived, setArchived] = useState40(null);
13042
13297
  const choiceOptions = useRef16(/* @__PURE__ */ new Map());
13043
13298
  const loadChoiceOptions = useCallback18(
13044
13299
  async (fieldList) => {
@@ -13054,7 +13309,7 @@ function Grid({
13054
13309
  },
13055
13310
  [client]
13056
13311
  );
13057
- const pasteableKeys = useMemo23(
13312
+ const pasteableKeys = useMemo24(
13058
13313
  () => ordered.filter((f) => fieldIsEditable(f)).map((f) => f.key),
13059
13314
  [ordered]
13060
13315
  );
@@ -13306,7 +13561,7 @@ function Grid({
13306
13561
  records.reload();
13307
13562
  return { written, readBack, missing, refusals };
13308
13563
  }, [pastePlan, client, tableId, records, merged, applyPasteAsOne]);
13309
- const columnIds = useMemo23(() => ordered.map((field2) => field2.key), [ordered]);
13564
+ const columnIds = useMemo24(() => ordered.map((field2) => field2.key), [ordered]);
13310
13565
  const writeLook = useCallback18(
13311
13566
  (next) => onPresentationChange?.(next),
13312
13567
  [onPresentationChange]
@@ -13338,7 +13593,7 @@ function Grid({
13338
13593
  [host, tableId, table.data, fields.data]
13339
13594
  );
13340
13595
  const hiddenKeys = presentation.hiddenFields;
13341
- const shownKeys = useMemo23(
13596
+ const shownKeys = useMemo24(
13342
13597
  () => hiddenKeys && hiddenKeys.length > 0 ? columnIds.filter((k) => !hiddenKeys.includes(k)) : columnIds,
13343
13598
  [columnIds, hiddenKeys]
13344
13599
  );
@@ -13411,7 +13666,7 @@ function Grid({
13411
13666
  choose: chooseSummary
13412
13667
  }
13413
13668
  });
13414
- const [addRefused, setAddRefused] = useState39(null);
13669
+ const [addRefused, setAddRefused] = useState40(null);
13415
13670
  const mayAddRow = merged && !readOnly && rights.write;
13416
13671
  const addRowHere = useCallback18(async () => {
13417
13672
  setAddRefused(null);
@@ -13430,13 +13685,13 @@ function Grid({
13430
13685
  const labelsNow = useRef16(labels);
13431
13686
  labelsNow.current = labels;
13432
13687
  const labelFor = useCallback18((field2, id) => labelsNow.current(field2, id), []);
13433
- useEffect32(() => {
13688
+ useEffect33(() => {
13434
13689
  for (const field2 of ordered) {
13435
13690
  if (!pointsAtRecords(field2)) continue;
13436
13691
  for (const row of rows) for (const id of idsOf(row.document?.[field2.key])) labels(field2, id);
13437
13692
  }
13438
13693
  }, [ordered, rows, labels]);
13439
- const fieldColumns = useMemo23(
13694
+ const fieldColumns = useMemo24(
13440
13695
  () => ordered.map((field2) => ({
13441
13696
  ...columnForField(
13442
13697
  // A formula's hover text names its columns as they are called NOW (review 2, C3).
@@ -13504,7 +13759,7 @@ function Grid({
13504
13759
  };
13505
13760
  const addColumnNow = useRef16(controls.addColumn);
13506
13761
  addColumnNow.current = controls.addColumn;
13507
- const bodyColumns = useMemo23(
13762
+ const bodyColumns = useMemo24(
13508
13763
  () => withAddRowCells(
13509
13764
  withSummaryCells(
13510
13765
  // THE ONE WAY A ROW OPENS ITS RECORD (VERIFIER-17): an Open control on the first cell,
@@ -13523,7 +13778,7 @@ function Grid({
13523
13778
  [fieldColumns, onOpenRecord, table.data, merged, mayAddRow]
13524
13779
  );
13525
13780
  const isRowSelectable = useCallback18((row) => row.id !== SUMMARY_ROW.id && mayWriteRow(row.id), [mayWriteRow]);
13526
- const copyConfig = useMemo23(
13781
+ const copyConfig = useMemo24(
13527
13782
  () => table.data ? gridCopyConfig({
13528
13783
  tableId,
13529
13784
  tableName: tableName(table.data),
@@ -13533,7 +13788,7 @@ function Grid({
13533
13788
  }) : null,
13534
13789
  [tableId, table.data, ordered, labelFor]
13535
13790
  );
13536
- const tableStyleProp = useMemo23(
13791
+ const tableStyleProp = useMemo24(
13537
13792
  () => tableStyleIsEmpty2(paint.style) ? null : {
13538
13793
  style: paint.style,
13539
13794
  // A choice is read as its OPTION (`paintByOption`): the rule, the value and the
@@ -13550,13 +13805,13 @@ function Grid({
13550
13805
  const offersRowActions = canWrite || Boolean(host.talkToRecord) || Boolean(!readOnly && host.runAgentAction && tableActions.agent.length > 0);
13551
13806
  const hasTalk = Boolean(host.talkToRecord);
13552
13807
  const hasAgent = Boolean(host.runAgentAction);
13553
- const headerActionList = useMemo23(
13808
+ const headerActionList = useMemo24(
13554
13809
  () => [...tableActions.runnable, ...tableActions.agent, ...tableActions.notRunnable],
13555
13810
  [tableActions.runnable, tableActions.agent, tableActions.notRunnable]
13556
13811
  );
13557
13812
  const mayManageActions = !readOnly && rights.structure;
13558
13813
  const whyNotManageActions = rights.why("structure");
13559
- const actionsHeader = useMemo23(
13814
+ const actionsHeader = useMemo24(
13560
13815
  () => /* @__PURE__ */ jsx48(
13561
13816
  ActionsHeaderControls,
13562
13817
  {
@@ -13636,8 +13891,8 @@ function Grid({
13636
13891
  );
13637
13892
  const headerHeld = useRef16(/* @__PURE__ */ new Map());
13638
13893
  const menuLatest = useRef16(/* @__PURE__ */ new Map());
13639
- const addColumnDef = useMemo23(() => addColumnColumn(() => addColumnNow.current()), []);
13640
- const drawnColumns = useMemo23(
13894
+ const addColumnDef = useMemo24(() => addColumnColumn(() => addColumnNow.current()), []);
13895
+ const drawnColumns = useMemo24(
13641
13896
  () => {
13642
13897
  const filterFor = controls.filterFor;
13643
13898
  const drawn = withHeaderMenus(
@@ -13652,10 +13907,10 @@ function Grid({
13652
13907
  const columnsHeld = useRef16(null);
13653
13908
  const columns = columnsHeld.current !== null && sameColumns(columnsHeld.current, drawnColumns) ? columnsHeld.current : drawnColumns;
13654
13909
  columnsHeld.current = columns;
13655
- const [localColumns, setLocalColumns] = useState39(
13910
+ const [localColumns, setLocalColumns] = useState40(
13656
13911
  null
13657
13912
  );
13658
- const [localWidths, setLocalWidths] = useState39(null);
13913
+ const [localWidths, setLocalWidths] = useState40(null);
13659
13914
  const changeLayout = useCallback18(
13660
13915
  (patch) => {
13661
13916
  setLocalLook((held) => ({ ...held ?? {}, ...patch }));
@@ -13669,7 +13924,7 @@ function Grid({
13669
13924
  [presentation, writeLook]
13670
13925
  );
13671
13926
  const widths = localWidths ?? presentation.widths;
13672
- const columnState = useMemo23(
13927
+ const columnState = useMemo24(
13673
13928
  () => ({
13674
13929
  order: controls.columns?.order ?? localColumns?.order ?? columnIds,
13675
13930
  hidden: controls.columns?.hidden ?? localColumns?.hidden ?? [],
@@ -13689,7 +13944,7 @@ function Grid({
13689
13944
  }),
13690
13945
  [columnIds, localColumns, widths, presentation, writeLook, controls.columns, fields.data]
13691
13946
  );
13692
- const groupingConfig = useMemo23(() => {
13947
+ const groupingConfig = useMemo24(() => {
13693
13948
  const view = presentation.grouping;
13694
13949
  const field2 = view?.field ?? null;
13695
13950
  if (field2 === null && !onPresentationChange) return null;
@@ -13725,7 +13980,7 @@ function Grid({
13725
13980
  };
13726
13981
  }, [presentation, onPresentationChange, writeLook, merged, phone]);
13727
13982
  const queryTotal = records.data?.total ?? rows.length;
13728
- const tableQuery = useMemo23(
13983
+ const tableQuery = useMemo24(
13729
13984
  () => merged ? {
13730
13985
  // THE STORE ANSWERS THE QUERY (tranche 6k): `data` is already the page.
13731
13986
  mode: "controlled",
@@ -13742,14 +13997,14 @@ function Grid({
13742
13997
  showAddLine ? added.busy : null,
13743
13998
  showSummaryLine ? [chosenSummaries, summaries.values, summaries.rowCount, summaries.loading] : null
13744
13999
  ]);
13745
- const footerRows = useMemo23(
14000
+ const footerRows = useMemo24(
13746
14001
  () => [...showAddLine ? [ADD_ROW] : [], ...showSummaryLine ? [SUMMARY_ROW] : []],
13747
14002
  // `footerFace`, `ordered` and the summaries' operations are what the footer's cells draw.
13748
14003
  // eslint-disable-next-line react-hooks/exhaustive-deps
13749
14004
  [showAddLine, showSummaryLine, footerFace, ordered, summaries.operations, summaries.askOperations]
13750
14005
  );
13751
14006
  const coverageTotal = typeof records.data?.total === "number" ? records.data.total : null;
13752
- const tableCoverage = useMemo23(
14007
+ const tableCoverage = useMemo24(
13753
14008
  () => ({
13754
14009
  answeredBy: merged ? "source" : "client",
13755
14010
  ...merged && coverageTotal !== null ? { matched: coverageTotal } : {},
@@ -13762,7 +14017,7 @@ function Grid({
13762
14017
  sheetNow.current = { merged, writeRange, editing, fields: fields.data ?? [], rows, mayWriteRow, notify: host.notify };
13763
14018
  const hasNotify = Boolean(host.notify);
13764
14019
  const readOnlyReason = !editable || !rights.known || rights.write ? "Editing is off here, so this table can be copied but not changed." : rights.why("write");
13765
- const spreadsheetConfig = useMemo23(
14020
+ const spreadsheetConfig = useMemo24(
13766
14021
  () => canWrite && editable ? {
13767
14022
  enabled: true,
13768
14023
  writableColumnIds: pasteableKeys,
@@ -13836,7 +14091,7 @@ function Grid({
13836
14091
  const editingBusy = editing.busy;
13837
14092
  const addRecord = editing.addRecord;
13838
14093
  const phoneSheetTools = merged && phone ? controls.sheetTools : null;
13839
- const tableToolbar = useMemo23(
14094
+ const tableToolbar = useMemo24(
13840
14095
  () => ({
13841
14096
  search: true,
13842
14097
  searchPlaceholder: "Search records",
@@ -14226,7 +14481,7 @@ function Grid({
14226
14481
  window: WINDOW_OFF,
14227
14482
  ...controls.contextMenu ? { contextMenu: controls.contextMenu } : {},
14228
14483
  spreadsheet: spreadsheetConfig,
14229
- ...groupingConfig ? { grouping: groupingConfig } : {},
14484
+ ...drillConfig ? { drill: drillConfig } : groupingConfig ? { grouping: groupingConfig } : {},
14230
14485
  columnState,
14231
14486
  ...look.rowHeight ? { rowHeight: look.rowHeight } : {},
14232
14487
  fitToWidth: look.fit === "fit",
@@ -14408,8 +14663,8 @@ function withHeaderMenus(columns, menuFor, filterFor) {
14408
14663
  }
14409
14664
 
14410
14665
  // src/ExportMenu.tsx
14411
- import { useState as useState40 } from "react";
14412
- import { useFields as useFields6, useRecords as useRecords5, useRecordsClient as useRecordsClient24 } from "@ai-matrx/records/react";
14666
+ import { useState as useState41 } from "react";
14667
+ import { useFields as useFields6, useRecords as useRecords5, useRecordsClient as useRecordsClient25 } from "@ai-matrx/records/react";
14413
14668
  import { exportCsv, exportXlsx, wholeValueOf as wholeValueOf4, withWholeValues } from "@ai-matrx/records/core";
14414
14669
  import { AlchemyMenu } from "@ai-matrx/alchemy/react";
14415
14670
  import { Button as Button33, cn as cn24 } from "@ai-matrx/design-system";
@@ -14444,11 +14699,11 @@ function download(name, mime, bytes) {
14444
14699
  URL.revokeObjectURL(url);
14445
14700
  }
14446
14701
  function ExportMenu({ tableId, rows, label, className }) {
14447
- const client = useRecordsClient24();
14702
+ const client = useRecordsClient25();
14448
14703
  const host = useRecordsUi();
14449
14704
  const fields = useFields6(tableId);
14450
14705
  const page = useRecords5(tableId, { pageSize: 500 });
14451
- const [failure, setFailure] = useState40(null);
14706
+ const [failure, setFailure] = useState41(null);
14452
14707
  const labels = useRecordLabels(fields.data ?? void 0);
14453
14708
  const records = rows ?? page.data?.rows ?? [];
14454
14709
  const name = label ?? "records";
@@ -14534,8 +14789,8 @@ function ExportMenu({ tableId, rows, label, className }) {
14534
14789
  }
14535
14790
 
14536
14791
  // src/ImportWizard.tsx
14537
- import { useCallback as useCallback19, useEffect as useEffect33, useMemo as useMemo24, useState as useState41 } from "react";
14538
- import { useFields as useFields7, useRecordsClient as useRecordsClient25, useTable as useTable4 } from "@ai-matrx/records/react";
14792
+ import { useCallback as useCallback19, useEffect as useEffect34, useMemo as useMemo25, useState as useState42 } from "react";
14793
+ import { useFields as useFields7, useRecordsClient as useRecordsClient26, useTable as useTable4 } from "@ai-matrx/records/react";
14539
14794
  import {
14540
14795
  importCsv,
14541
14796
  importXlsx
@@ -14616,36 +14871,36 @@ function lineInYourFile(dataRow) {
14616
14871
  return dataRow + 1;
14617
14872
  }
14618
14873
  function ImportWizard({ tableId, onDone, onWrote, className }) {
14619
- const client = useRecordsClient25();
14874
+ const client = useRecordsClient26();
14620
14875
  const table = useTable4(tableId);
14621
14876
  const fields = useFields7(tableId);
14622
14877
  const rights = useTableRights(table.data);
14623
- const [phase, setPhase] = useState41("waiting");
14624
- const [problem, setProblem] = useState41(null);
14625
- const [parsed, setParsed] = useState41(null);
14626
- const [rows, setRows] = useState41([]);
14627
- const [plan, setPlan] = useState41(null);
14628
- const [mapping, setMapping] = useState41({});
14629
- const [dedupeKey, setDedupeKey] = useState41("");
14630
- const [onDuplicate, setOnDuplicate] = useState41("skip");
14631
- const [unmapped, setUnmapped] = useState41("propose");
14632
- const [fileName, setFileName] = useState41("");
14633
- const [fileHash, setFileHash] = useState41(null);
14634
- const [fileBytes, setFileBytes] = useState41(null);
14635
- const [format, setFormat] = useState41("csv");
14636
- const [outcomes, setOutcomes] = useState41([]);
14637
- const [progress, setProgress] = useState41(0);
14638
- const [summary, setSummary] = useState41(null);
14639
- const [proposals, setProposals] = useState41([]);
14640
- const [alreadyRan, setAlreadyRan] = useState41(null);
14641
- const [columnsAdded, setColumnsAdded] = useState41(null);
14642
- const [show, setShow] = useState41("all");
14643
- const [ledger, setLedger] = useState41(null);
14644
- const [runs, setRuns] = useState41(null);
14645
- const [openRun, setOpenRun] = useState41(null);
14646
- const [runRows, setRunRows] = useState41(null);
14647
- const [runProblem, setRunProblem] = useState41(null);
14648
- const [runsProblem, setRunsProblem] = useState41(null);
14878
+ const [phase, setPhase] = useState42("waiting");
14879
+ const [problem, setProblem] = useState42(null);
14880
+ const [parsed, setParsed] = useState42(null);
14881
+ const [rows, setRows] = useState42([]);
14882
+ const [plan, setPlan] = useState42(null);
14883
+ const [mapping, setMapping] = useState42({});
14884
+ const [dedupeKey, setDedupeKey] = useState42("");
14885
+ const [onDuplicate, setOnDuplicate] = useState42("skip");
14886
+ const [unmapped, setUnmapped] = useState42("propose");
14887
+ const [fileName, setFileName] = useState42("");
14888
+ const [fileHash, setFileHash] = useState42(null);
14889
+ const [fileBytes, setFileBytes] = useState42(null);
14890
+ const [format, setFormat] = useState42("csv");
14891
+ const [outcomes, setOutcomes] = useState42([]);
14892
+ const [progress, setProgress] = useState42(0);
14893
+ const [summary, setSummary] = useState42(null);
14894
+ const [proposals, setProposals] = useState42([]);
14895
+ const [alreadyRan, setAlreadyRan] = useState42(null);
14896
+ const [columnsAdded, setColumnsAdded] = useState42(null);
14897
+ const [show, setShow] = useState42("all");
14898
+ const [ledger, setLedger] = useState42(null);
14899
+ const [runs, setRuns] = useState42(null);
14900
+ const [openRun, setOpenRun] = useState42(null);
14901
+ const [runRows, setRunRows] = useState42(null);
14902
+ const [runProblem, setRunProblem] = useState42(null);
14903
+ const [runsProblem, setRunsProblem] = useState42(null);
14649
14904
  const loadRuns = useCallback19(async () => {
14650
14905
  const answered = await client.imports({ table_id: tableId, limit: 10 });
14651
14906
  if (answered.ok) {
@@ -14653,7 +14908,7 @@ function ImportWizard({ tableId, onDone, onWrote, className }) {
14653
14908
  setRunsProblem(null);
14654
14909
  } else setRunsProblem(answered.error);
14655
14910
  }, [client, tableId]);
14656
- useEffect33(() => {
14911
+ useEffect34(() => {
14657
14912
  void loadRuns();
14658
14913
  }, [loadRuns]);
14659
14914
  const openRefusals = useCallback19(
@@ -14828,7 +15083,7 @@ function ImportWizard({ tableId, onDone, onWrote, className }) {
14828
15083
  onWrote?.(finished.data.rows_written);
14829
15084
  void loadRuns();
14830
15085
  }, [client, dedupeKey, fileBytes, fileHash, fileName, format, loadRuns, mapping, onDuplicate, onWrote, plan, rows, tableId, unmapped]);
14831
- const counts = useMemo24(() => {
15086
+ const counts = useMemo25(() => {
14832
15087
  let landed = 0;
14833
15088
  let duplicate = 0;
14834
15089
  let refused = 0;
@@ -14839,7 +15094,7 @@ function ImportWizard({ tableId, onDone, onWrote, className }) {
14839
15094
  }
14840
15095
  return { landed, duplicate, refused };
14841
15096
  }, [outcomes]);
14842
- const interesting = useMemo24(
15097
+ const interesting = useMemo25(
14843
15098
  () => outcomes.filter((o) => show === "all" ? o.outcome !== "landed" : o.outcome === show),
14844
15099
  [outcomes, show]
14845
15100
  );
@@ -14849,11 +15104,11 @@ function ImportWizard({ tableId, onDone, onWrote, className }) {
14849
15104
  const titleMissing = Boolean(titleKey) && titleMappedTo === null;
14850
15105
  const titleFieldLabel = (titleKey ? plan?.fields.find((f) => f.key === titleKey)?.label : null) || (titleKey ? declared2.find((f) => f.key === titleKey)?.label : null) || "the name column";
14851
15106
  const busy = phase === "reading" || phase === "planning" || phase === "declaring" || phase === "writing";
14852
- const ruleVerdicts = useMemo24(() => checkImportRules(declared2, rows, mapping), [declared2, rows, mapping]);
14853
- const ruleVerdictOf = useMemo24(() => new Map(ruleVerdicts.map((v) => [v.header, v])), [ruleVerdicts]);
15107
+ const ruleVerdicts = useMemo25(() => checkImportRules(declared2, rows, mapping), [declared2, rows, mapping]);
15108
+ const ruleVerdictOf = useMemo25(() => new Map(ruleVerdicts.map((v) => [v.header, v])), [ruleVerdicts]);
14854
15109
  const refusedByRules = ruleVerdicts.reduce((n, v) => n + v.refused, 0);
14855
- const [goAheadAnyway, setGoAheadAnyway] = useState41(false);
14856
- useEffect33(() => setGoAheadAnyway(false), [ruleVerdicts]);
15110
+ const [goAheadAnyway, setGoAheadAnyway] = useState42(false);
15111
+ useEffect34(() => setGoAheadAnyway(false), [ruleVerdicts]);
14857
15112
  const afterWrite = !busy && (phase === "done" || alreadyRan !== null || ledger !== null && ledger.seen > 0);
14858
15113
  return /* @__PURE__ */ jsxs43("div", { className: cn25("flex min-w-0 flex-col gap-2 text-xs", className), children: [
14859
15114
  /* @__PURE__ */ jsxs43("div", { className: "flex items-center gap-2", children: [
@@ -15247,12 +15502,12 @@ function ImportWizard({ tableId, onDone, onWrote, className }) {
15247
15502
  }
15248
15503
 
15249
15504
  // src/CustomFieldsSection.tsx
15250
- import { useEffect as useEffect34, useMemo as useMemo25, useRef as useRef17, useState as useState42 } from "react";
15505
+ import { useEffect as useEffect35, useMemo as useMemo26, useRef as useRef17, useState as useState43 } from "react";
15251
15506
  import {
15252
15507
  useEntityFieldMutation,
15253
15508
  useEntityFieldRights,
15254
15509
  useEntityRecord,
15255
- useRecordsClient as useRecordsClient26
15510
+ useRecordsClient as useRecordsClient27
15256
15511
  } from "@ai-matrx/records/react";
15257
15512
  import {
15258
15513
  BasicInput as BasicInput12,
@@ -15332,23 +15587,23 @@ function CustomFieldsSection({
15332
15587
  className,
15333
15588
  agentDoor
15334
15589
  }) {
15335
- const client = useRecordsClient26();
15590
+ const client = useRecordsClient27();
15336
15591
  const read = useEntityRecord(entityToken, recordId);
15337
15592
  const rights = useEntityFieldRights(entityToken);
15338
15593
  const mutation = useEntityFieldMutation();
15339
- const [editing, setEditing] = useState42(false);
15340
- const [adding, setAdding] = useState42(false);
15341
- const [newLabel, setNewLabel] = useState42("");
15342
- const [newType, setNewType] = useState42("text");
15343
- const [draft, setDraft] = useState42({});
15344
- const [removing, setRemoving] = useState42(null);
15345
- const fields = useMemo25(() => read.data?.fields ?? [], [read.data]);
15594
+ const [editing, setEditing] = useState43(false);
15595
+ const [adding, setAdding] = useState43(false);
15596
+ const [newLabel, setNewLabel] = useState43("");
15597
+ const [newType, setNewType] = useState43("text");
15598
+ const [draft, setDraft] = useState43({});
15599
+ const [removing, setRemoving] = useState43(null);
15600
+ const fields = useMemo26(() => read.data?.fields ?? [], [read.data]);
15346
15601
  const mayAdd = rights.data?.may_declare === true;
15347
15602
  const live = useRef17({ fields, rights: rights.data, loading: rights.loading, reload: read.reload, values: read.data?.custom ?? {} });
15348
- useEffect34(() => {
15603
+ useEffect35(() => {
15349
15604
  live.current = { fields, rights: rights.data, loading: rights.loading, reload: read.reload, values: read.data?.custom ?? {} };
15350
15605
  });
15351
- useEffect34(() => {
15606
+ useEffect35(() => {
15352
15607
  if (!agentDoor) return;
15353
15608
  const state = () => {
15354
15609
  const now = live.current;
@@ -15595,12 +15850,12 @@ function CustomFieldsSection({
15595
15850
  }
15596
15851
 
15597
15852
  // src/StageRules.tsx
15598
- import { useCallback as useCallback20, useEffect as useEffect35, useMemo as useMemo26, useState as useState44 } from "react";
15599
- import { useFields as useFields8, useRecordsClient as useRecordsClient27, useTable as useTable5 } from "@ai-matrx/records/react";
15853
+ import { useCallback as useCallback20, useEffect as useEffect36, useMemo as useMemo27, useState as useState45 } from "react";
15854
+ import { useFields as useFields8, useRecordsClient as useRecordsClient28, useTable as useTable5 } from "@ai-matrx/records/react";
15600
15855
  import { BasicInput as BasicInput14, BasicTextarea as BasicTextarea8, Button as Button37, Separator as Separator5, Skeleton as Skeleton3, cn as cn27 } from "@ai-matrx/design-system";
15601
15856
 
15602
15857
  // src/Condition.tsx
15603
- import { useState as useState43 } from "react";
15858
+ import { useState as useState44 } from "react";
15604
15859
  import { BasicInput as BasicInput13, Button as Button36 } from "@ai-matrx/design-system";
15605
15860
  import { Fragment as Fragment20, jsx as jsx52, jsxs as jsxs45 } from "react/jsx-runtime";
15606
15861
  var CONDITION_OPS = [
@@ -15818,7 +16073,7 @@ function ConditionGroup({
15818
16073
  className
15819
16074
  }) {
15820
16075
  const { joiner, args } = clausesOf(expr);
15821
- const [drafting, setDrafting] = useState43(null);
16076
+ const [drafting, setDrafting] = useState44(null);
15822
16077
  const nested = depth > 0;
15823
16078
  const replaceAt = (index, next) => {
15824
16079
  const nextArgs = args.slice();
@@ -15974,19 +16229,19 @@ function draftOf2(rule) {
15974
16229
  };
15975
16230
  }
15976
16231
  function StageRulesSection({ tableId, stage, className }) {
15977
- const client = useRecordsClient27();
16232
+ const client = useRecordsClient28();
15978
16233
  const table = useTable5(tableId);
15979
16234
  const rights = useTableRights(table.data);
15980
16235
  const fields = useFields8(tableId);
15981
- const [pipeline, setPipeline] = useState44(null);
15982
- const [enforcement, setEnforcement] = useState44(null);
15983
- const [asked2, setAsked] = useState44(false);
15984
- const [error, setError] = useState44(null);
15985
- const [chosen, setChosen] = useState44(stage ?? null);
15986
- const [draft, setDraft] = useState44(null);
15987
- const [preview, setPreview] = useState44(null);
15988
- const [previewError, setPreviewError] = useState44(null);
15989
- const [saving, setSaving] = useState44(false);
16236
+ const [pipeline, setPipeline] = useState45(null);
16237
+ const [enforcement, setEnforcement] = useState45(null);
16238
+ const [asked2, setAsked] = useState45(false);
16239
+ const [error, setError] = useState45(null);
16240
+ const [chosen, setChosen] = useState45(stage ?? null);
16241
+ const [draft, setDraft] = useState45(null);
16242
+ const [preview, setPreview] = useState45(null);
16243
+ const [previewError, setPreviewError] = useState45(null);
16244
+ const [saving, setSaving] = useState45(false);
15990
16245
  const load = useCallback20(async () => {
15991
16246
  const [read, mode] = await Promise.all([client.pipelineRead({ table_id: tableId }), client.stageRuleEnforcement()]);
15992
16247
  if (!read.ok) setError(read.error);
@@ -15994,18 +16249,18 @@ function StageRulesSection({ tableId, stage, className }) {
15994
16249
  if (mode.ok) setEnforcement(mode.data);
15995
16250
  setAsked(true);
15996
16251
  }, [client, tableId]);
15997
- useEffect35(() => {
16252
+ useEffect36(() => {
15998
16253
  void load();
15999
16254
  }, [load]);
16000
16255
  const stages = pipeline?.stages ?? [];
16001
16256
  const stageKey = chosen ?? stages.find((s) => !s.retired)?.key ?? null;
16002
16257
  const stageLabel = stages.find((s) => s.key === stageKey)?.label ?? stageKey ?? "";
16003
- const gates = useMemo26(() => stageKey ? gatesOf(pipeline, stageKey) : [], [pipeline, stageKey]);
16004
- const conditionFields = useMemo26(
16258
+ const gates = useMemo27(() => stageKey ? gatesOf(pipeline, stageKey) : [], [pipeline, stageKey]);
16259
+ const conditionFields = useMemo27(
16005
16260
  () => (fields.data ?? []).map((f) => ({ id: String(f.id), key: f.key, label: fieldName(f), field: f })),
16006
16261
  [fields.data]
16007
16262
  );
16008
- useEffect35(() => {
16263
+ useEffect36(() => {
16009
16264
  if (!draft || !stageKey || !draft.demands || Object.keys(draft.demands).length === 0) {
16010
16265
  setPreview(null);
16011
16266
  setPreviewError(null);
@@ -16188,7 +16443,7 @@ function Clause({
16188
16443
  fields,
16189
16444
  onChange
16190
16445
  }) {
16191
- const [replacing, setReplacing] = useState44(false);
16446
+ const [replacing, setReplacing] = useState45(false);
16192
16447
  const drawable = conditionIsDrawable(expr) || replacing;
16193
16448
  if (drawable) {
16194
16449
  return /* @__PURE__ */ jsx53(
@@ -16227,9 +16482,9 @@ function Clause({
16227
16482
  }
16228
16483
 
16229
16484
  // src/TableSettings.tsx
16230
- import { useEffect as useEffect36, useState as useState45 } from "react";
16485
+ import { useEffect as useEffect37, useState as useState46 } from "react";
16231
16486
  import {
16232
- useRecordsClient as useRecordsClient28,
16487
+ useRecordsClient as useRecordsClient29,
16233
16488
  useFieldMutation as useFieldMutation3,
16234
16489
  useFields as useFields9,
16235
16490
  useTable as useTable6,
@@ -16250,9 +16505,9 @@ function TableSettings({
16250
16505
  const rights = useTableRights(table.data);
16251
16506
  const shape = useFieldMutation3();
16252
16507
  const archive = useTableArchive(tableId);
16253
- const client = useRecordsClient28();
16508
+ const client = useRecordsClient29();
16254
16509
  const ui = useRecordsUi();
16255
- useEffect36(() => {
16510
+ useEffect37(() => {
16256
16511
  let live = true;
16257
16512
  void archive.preview().then((answer) => {
16258
16513
  if (live && answer?.in_progress) setAskingToDelete(true);
@@ -16261,10 +16516,10 @@ function TableSettings({
16261
16516
  live = false;
16262
16517
  };
16263
16518
  }, [tableId]);
16264
- const [editing, setEditing] = useState45(null);
16265
- const [askingToDelete, setAskingToDelete] = useState45(false);
16266
- const [askingToRemove, setAskingToRemove] = useState45(null);
16267
- const [enriching, setEnriching] = useState45(null);
16519
+ const [editing, setEditing] = useState46(null);
16520
+ const [askingToDelete, setAskingToDelete] = useState46(false);
16521
+ const [askingToRemove, setAskingToRemove] = useState46(null);
16522
+ const [enriching, setEnriching] = useState46(null);
16268
16523
  if (table.error) return /* @__PURE__ */ jsx54(RefusalNotice, { error: table.error, className });
16269
16524
  if (fields.error) return /* @__PURE__ */ jsx54(RefusalNotice, { error: fields.error, className });
16270
16525
  if (!rights.structure) return /* @__PURE__ */ jsx54("p", { className: cn28("text-xs text-muted-foreground", className), children: rights.why("structure") });
@@ -16453,22 +16708,22 @@ function TableSettings({
16453
16708
  }
16454
16709
 
16455
16710
  // src/Peek.tsx
16456
- import { useState as useState50 } from "react";
16457
- import { useFields as useFields11, useRecord as useRecord2, useRecordsClient as useRecordsClient32, useTable as useTable7 } from "@ai-matrx/records/react";
16711
+ import { useState as useState51 } from "react";
16712
+ import { useFields as useFields11, useRecord as useRecord2, useRecordsClient as useRecordsClient33, useTable as useTable7 } from "@ai-matrx/records/react";
16458
16713
  import { AlchemyMenu as AlchemyMenu2 } from "@ai-matrx/alchemy/react";
16459
16714
 
16460
16715
  // src/RecordChat.tsx
16461
- import { useEffect as useEffect37, useMemo as useMemo27, useState as useState46 } from "react";
16462
- import { useRecordsClient as useRecordsClient29 } from "@ai-matrx/records/react";
16716
+ import { useEffect as useEffect38, useMemo as useMemo28, useState as useState47 } from "react";
16717
+ import { useRecordsClient as useRecordsClient30 } from "@ai-matrx/records/react";
16463
16718
  import { Skeleton as Skeleton4, cn as cn29 } from "@ai-matrx/design-system";
16464
16719
  import { jsx as jsx55, jsxs as jsxs48 } from "react/jsx-runtime";
16465
16720
  var NO_CHAT_REASON = "Chatting about this record is not switched on here yet, so this panel is empty rather than showing a box that goes nowhere. It is on our list, not yours.";
16466
16721
  function RecordChat({ tableId, recordId, className }) {
16467
- const client = useRecordsClient29();
16722
+ const client = useRecordsClient30();
16468
16723
  const host = useRecordsUi();
16469
- const [scope, setScope] = useState46(null);
16470
- const [error, setError] = useState46(null);
16471
- useEffect37(() => {
16724
+ const [scope, setScope] = useState47(null);
16725
+ const [error, setError] = useState47(null);
16726
+ useEffect38(() => {
16472
16727
  let cancelled = false;
16473
16728
  setScope(null);
16474
16729
  setError(null);
@@ -16484,7 +16739,7 @@ function RecordChat({ tableId, recordId, className }) {
16484
16739
  cancelled = true;
16485
16740
  };
16486
16741
  }, [client, recordId]);
16487
- const context = useMemo27(() => {
16742
+ const context = useMemo28(() => {
16488
16743
  if (!scope) return null;
16489
16744
  return {
16490
16745
  surfaceKey: `records-ui:record-chat:${recordId}`,
@@ -16585,12 +16840,12 @@ function entriesFor(scope) {
16585
16840
  import { Button as Button41, Separator as Separator8, Skeleton as Skeleton5, cn as cn31 } from "@ai-matrx/design-system";
16586
16841
 
16587
16842
  // src/RecordForm.tsx
16588
- import { useEffect as useEffect39, useMemo as useMemo29, useRef as useRef18, useState as useState48 } from "react";
16843
+ import { useEffect as useEffect40, useMemo as useMemo30, useRef as useRef18, useState as useState49 } from "react";
16589
16844
  import {
16590
16845
  useFields as useFields10,
16591
16846
  useRecord,
16592
16847
  useRecordMutation,
16593
- useRecordsClient as useRecordsClient31
16848
+ useRecordsClient as useRecordsClient32
16594
16849
  } from "@ai-matrx/records/react";
16595
16850
  import { asWriteConflict as asWriteConflict3, predictWriteRefusals, wholeValueOf as wholeValueOf5 } from "@ai-matrx/records/core";
16596
16851
 
@@ -16628,8 +16883,8 @@ async function updateOnTheWinningVersion(client, recordId, patch, expectedVersio
16628
16883
  import { Button as Button39, Separator as Separator7, cn as cn30 } from "@ai-matrx/design-system";
16629
16884
 
16630
16885
  // src/systemTable.ts
16631
- import { useEffect as useEffect38, useMemo as useMemo28, useState as useState47 } from "react";
16632
- import { useRecordsClient as useRecordsClient30 } from "@ai-matrx/records/react";
16886
+ import { useEffect as useEffect39, useMemo as useMemo29, useState as useState48 } from "react";
16887
+ import { useRecordsClient as useRecordsClient31 } from "@ai-matrx/records/react";
16633
16888
  var inFlight = /* @__PURE__ */ new Map();
16634
16889
  async function ensureSystemTable(client, spec) {
16635
16890
  const cacheKey = `${client.config.organizationId}:${spec.slug}`;
@@ -16757,11 +17012,11 @@ async function declare(client, spec) {
16757
17012
  return { ok: true, data: table.data };
16758
17013
  }
16759
17014
  function useSystemTable(spec) {
16760
- const client = useRecordsClient30();
16761
- const [state, setState] = useState47({ tableId: null, loading: true, error: null });
17015
+ const client = useRecordsClient31();
17016
+ const [state, setState] = useState48({ tableId: null, loading: true, error: null });
16762
17017
  const slug = spec.slug;
16763
- const stable = useMemo28(() => spec, [slug]);
16764
- useEffect38(() => {
17018
+ const stable = useMemo29(() => spec, [slug]);
17019
+ useEffect39(() => {
16765
17020
  let cancelled = false;
16766
17021
  setState({ tableId: null, loading: true, error: null });
16767
17022
  void ensureSystemTable(client, stable).then((result) => {
@@ -16777,9 +17032,9 @@ function useSystemTable(spec) {
16777
17032
  return state;
16778
17033
  }
16779
17034
  function useRecordVersion(recordId) {
16780
- const client = useRecordsClient30();
16781
- const [version, setVersion] = useState47(null);
16782
- useEffect38(() => {
17035
+ const client = useRecordsClient31();
17036
+ const [version, setVersion] = useState48(null);
17037
+ useEffect39(() => {
16783
17038
  let cancelled = false;
16784
17039
  setVersion(null);
16785
17040
  if (!recordId) return;
@@ -16812,8 +17067,8 @@ function RecordForm({
16812
17067
  const fields = useFields10(tableId, recordType);
16813
17068
  const existing = useRecord(recordId ?? null);
16814
17069
  const mutation = useRecordMutation();
16815
- const client = useRecordsClient31();
16816
- const [edit, setEdit] = useState48({
17070
+ const client = useRecordsClient32();
17071
+ const [edit, setEdit] = useState49({
16817
17072
  saving: false,
16818
17073
  error: null,
16819
17074
  conflict: null
@@ -16827,15 +17082,15 @@ function RecordForm({
16827
17082
  setEdit((e) => ({ ...e, conflict: null }));
16828
17083
  }
16829
17084
  };
16830
- const [draft, setDraft] = useState48({});
16831
- const [touched, setTouched] = useState48(false);
16832
- const [changed, setChanged] = useState48({});
16833
- const [answered, setAnswered] = useState48(null);
17085
+ const [draft, setDraft] = useState49({});
17086
+ const [touched, setTouched] = useState49(false);
17087
+ const [changed, setChanged] = useState49({});
17088
+ const [answered, setAnswered] = useState49(null);
16834
17089
  const loaded = useRecordVersion(recordId ?? null);
16835
17090
  const loadedVersion = loaded.version;
16836
17091
  const changedRef = useRef18({});
16837
17092
  changedRef.current = changed;
16838
- useEffect39(() => {
17093
+ useEffect40(() => {
16839
17094
  const document3 = existing.data?.document;
16840
17095
  if (!document3) return;
16841
17096
  const mine = changedRef.current;
@@ -16845,7 +17100,7 @@ function RecordForm({
16845
17100
  return next;
16846
17101
  });
16847
17102
  }, [existing.data?.record_id, loadedVersion]);
16848
- const document2 = useMemo29(() => {
17103
+ const document2 = useMemo30(() => {
16849
17104
  const out = {};
16850
17105
  for (const [key, value] of Object.entries(draft)) {
16851
17106
  if (key.startsWith("_")) continue;
@@ -16853,7 +17108,7 @@ function RecordForm({
16853
17108
  }
16854
17109
  return out;
16855
17110
  }, [draft]);
16856
- const predicted = useMemo29(
17111
+ const predicted = useMemo30(
16857
17112
  () => fields.data ? predictWriteRefusals({ fields: fields.data, document: document2, ...recordType ? { recordType } : {} }) : [],
16858
17113
  [fields.data, document2, recordType]
16859
17114
  );
@@ -17036,7 +17291,7 @@ function asWords(value) {
17036
17291
  }
17037
17292
 
17038
17293
  // src/ShareControl.tsx
17039
- import { useEffect as useEffect40, useState as useState49 } from "react";
17294
+ import { useEffect as useEffect41, useState as useState50 } from "react";
17040
17295
  import { Button as Button40 } from "@ai-matrx/design-system";
17041
17296
  import { Fragment as Fragment22, jsx as jsx57, jsxs as jsxs50 } from "react/jsx-runtime";
17042
17297
  function useCanShare() {
@@ -17057,8 +17312,8 @@ function ShareControl({
17057
17312
  className
17058
17313
  }) {
17059
17314
  const host = useRecordsUi();
17060
- const [open, setOpen] = useState49(initiallyOpen);
17061
- useEffect40(() => {
17315
+ const [open, setOpen] = useState50(initiallyOpen);
17316
+ useEffect41(() => {
17062
17317
  if (initiallyOpen) setOpen(true);
17063
17318
  }, [initiallyOpen]);
17064
17319
  const asked2 = useRecordRights(may === void 0 ? subjectId : null);
@@ -17097,9 +17352,9 @@ function Peek({ tableId, recordId, onClose, className }) {
17097
17352
  const record = useRecord2(recordId, true);
17098
17353
  const may = useRecordRights(recordId);
17099
17354
  const host = useRecordsUi();
17100
- const organizationId = useRecordsClient32().config.organizationId;
17101
- const [editing, setEditing] = useState50(false);
17102
- const [talking, setTalking] = useState50(false);
17355
+ const organizationId = useRecordsClient33().config.organizationId;
17356
+ const [editing, setEditing] = useState51(false);
17357
+ const [talking, setTalking] = useState51(false);
17103
17358
  if (record.error) return /* @__PURE__ */ jsx58(RefusalNotice, { error: record.error, className });
17104
17359
  if (fields.error) return /* @__PURE__ */ jsx58(RefusalNotice, { error: fields.error, className });
17105
17360
  const document2 = record.data?.document;
@@ -17274,8 +17529,8 @@ var LOOK_WORDS = {
17274
17529
  };
17275
17530
 
17276
17531
  // src/ViewSwitcher.tsx
17277
- import { useEffect as useEffect44, useMemo as useMemo31, useState as useState54 } from "react";
17278
- import { useFields as useFields13, useRecords as useRecords6, useRecordsClient as useRecordsClient35 } from "@ai-matrx/records/react";
17532
+ import { useEffect as useEffect45, useMemo as useMemo32, useState as useState55 } from "react";
17533
+ import { useFields as useFields13, useRecords as useRecords6, useRecordsClient as useRecordsClient36 } from "@ai-matrx/records/react";
17279
17534
  import { stableFilterKey as stableFilterKey4 } from "@ai-matrx/records";
17280
17535
  import { Button as Button45, Skeleton as Skeleton7, cn as cn34 } from "@ai-matrx/design-system";
17281
17536
  import {
@@ -17284,11 +17539,11 @@ import {
17284
17539
  } from "@ai-matrx/design-system/data-table";
17285
17540
 
17286
17541
  // src/Pipeline.tsx
17287
- import { useCallback as useCallback21, useEffect as useEffect41, useMemo as useMemo30, useRef as useRef19, useState as useState51 } from "react";
17542
+ import { useCallback as useCallback21, useEffect as useEffect42, useMemo as useMemo31, useRef as useRef19, useState as useState52 } from "react";
17288
17543
  import {
17289
17544
  mayDrag,
17290
17545
  useFields as useFields12,
17291
- useRecordsClient as useRecordsClient33
17546
+ useRecordsClient as useRecordsClient34
17292
17547
  } from "@ai-matrx/records/react";
17293
17548
  import { stableFilterKey as stableFilterKey3 } from "@ai-matrx/records";
17294
17549
  import {
@@ -17380,30 +17635,30 @@ function PipelineBoard({
17380
17635
  dateFields,
17381
17636
  className
17382
17637
  }) {
17383
- const client = useRecordsClient33();
17638
+ const client = useRecordsClient34();
17384
17639
  const fields = useFields12(tableId);
17385
17640
  const ownDecorations = useTableDecorations(style ? null : tableId);
17386
- const cardStyle = useMemo30(
17641
+ const cardStyle = useMemo31(
17387
17642
  () => style ?? resolveTableStyle(ownDecorations.data, fields.data ?? [], void 0),
17388
17643
  [style, ownDecorations.data, fields.data]
17389
17644
  );
17390
- const [definition, setDefinition] = useState51(null);
17391
- const [columns, setColumns] = useState51([]);
17392
- const [error, setError] = useState51(null);
17393
- const [loading, setLoading] = useState51(true);
17394
- const [pending, setPending] = useState51({ kind: "none" });
17395
- const [waiting, setWaiting] = useState51(/* @__PURE__ */ new Map());
17396
- const [dragging, setDragging] = useState51(null);
17397
- const [over, setOver] = useState51(null);
17645
+ const [definition, setDefinition] = useState52(null);
17646
+ const [columns, setColumns] = useState52([]);
17647
+ const [error, setError] = useState52(null);
17648
+ const [loading, setLoading] = useState52(true);
17649
+ const [pending, setPending] = useState52({ kind: "none" });
17650
+ const [waiting, setWaiting] = useState52(/* @__PURE__ */ new Map());
17651
+ const [dragging, setDragging] = useState52(null);
17652
+ const [over, setOver] = useState52(null);
17398
17653
  const alive = useRef19(true);
17399
- const [selected, setSelected] = useState51(/* @__PURE__ */ new Set());
17654
+ const [selected, setSelected] = useState52(/* @__PURE__ */ new Set());
17400
17655
  const anchor = useRef19(null);
17401
- const [versions, setVersions] = useState51(null);
17402
- const [batch, setBatch] = useState51(/* @__PURE__ */ new Map());
17403
- const [batchSaid, setBatchSaid] = useState51(null);
17404
- const [batchError, setBatchError] = useState51(null);
17405
- const [moving, setMoving] = useState51(false);
17406
- useEffect41(() => {
17656
+ const [versions, setVersions] = useState52(null);
17657
+ const [batch, setBatch] = useState52(/* @__PURE__ */ new Map());
17658
+ const [batchSaid, setBatchSaid] = useState52(null);
17659
+ const [batchError, setBatchError] = useState52(null);
17660
+ const [moving, setMoving] = useState52(false);
17661
+ useEffect42(() => {
17407
17662
  alive.current = true;
17408
17663
  return () => {
17409
17664
  alive.current = false;
@@ -17428,10 +17683,10 @@ function PipelineBoard({
17428
17683
  setWaiting(held.ok ? new Map((held.data ?? []).map((p) => [p.record_id, p])) : /* @__PURE__ */ new Map());
17429
17684
  setColumns(board.ok ? board.data ?? [] : []);
17430
17685
  }, [client, tableId, measure, filterKey]);
17431
- useEffect41(() => {
17686
+ useEffect42(() => {
17432
17687
  void reload();
17433
17688
  }, [reload]);
17434
- useEffect41(() => {
17689
+ useEffect42(() => {
17435
17690
  const ids = rows.filter((r) => mayDrag(r.level)).map((r) => r.id);
17436
17691
  if (ids.length === 0) {
17437
17692
  setVersions({ ok: true, map: /* @__PURE__ */ new Map() });
@@ -17449,7 +17704,7 @@ function PipelineBoard({
17449
17704
  };
17450
17705
  }, [client, rows]);
17451
17706
  const stageKey = definition?.stage_field ?? null;
17452
- const cardsByStage = useMemo30(() => {
17707
+ const cardsByStage = useMemo31(() => {
17453
17708
  const map = /* @__PURE__ */ new Map();
17454
17709
  if (!stageKey) return map;
17455
17710
  for (const row of rows) {
@@ -17460,12 +17715,12 @@ function PipelineBoard({
17460
17715
  }, [rows, stageKey, definition?.stages]);
17461
17716
  const unplaced = cardsByStage.get(UNPLACED) ?? [];
17462
17717
  const all = fields.data ?? [];
17463
- const titleField = useMemo30(
17718
+ const titleField = useMemo31(
17464
17719
  () => cardTitleField(all, titleKey ?? null, [stageKey]),
17465
17720
  [all, stageKey, titleKey]
17466
17721
  );
17467
17722
  const unplacedLabels = useRecordLabels(titleField ? [titleField] : []);
17468
- const measurable = useMemo30(
17723
+ const measurable = useMemo31(
17469
17724
  () => all.filter((f) => ["number", "currency", "percentage"].includes(String(f.type ?? ""))),
17470
17725
  [all]
17471
17726
  );
@@ -17790,7 +18045,7 @@ function Held({
17790
18045
  onFill,
17791
18046
  onAsk
17792
18047
  }) {
17793
- const [draft, setDraft] = useState51({});
18048
+ const [draft, setDraft] = useState52({});
17794
18049
  if (pending.kind === "asking") {
17795
18050
  return /* @__PURE__ */ jsx60("p", { className: "px-2 py-1 text-xs text-muted-foreground", children: "Asking\u2026" });
17796
18051
  }
@@ -18028,8 +18283,8 @@ function batchSentence(moved, waiting, notMoved, label) {
18028
18283
  }
18029
18284
 
18030
18285
  // src/ViewNeeds.tsx
18031
- import { useEffect as useEffect42, useState as useState52 } from "react";
18032
- import { useFieldMutation as useFieldMutation4, useRecordsClient as useRecordsClient34, useTable as useTable8 } from "@ai-matrx/records/react";
18286
+ import { useEffect as useEffect43, useState as useState53 } from "react";
18287
+ import { useFieldMutation as useFieldMutation4, useRecordsClient as useRecordsClient35, useTable as useTable8 } from "@ai-matrx/records/react";
18033
18288
  import { BasicInput as BasicInput15, Button as Button44, Label as Label13 } from "@ai-matrx/design-system";
18034
18289
 
18035
18290
  // src/BuildOrAsk.tsx
@@ -18085,7 +18340,7 @@ function useAskedColumnLands(layout, tableId, fields, chosen, offerable, onMade)
18085
18340
  const wanted = askedFor.get(askKey(tableId, layout));
18086
18341
  const landed = wanted && !chosen ? offerable(fields).find((f) => fieldName(f).trim().toLowerCase() === wanted.trim().toLowerCase()) : void 0;
18087
18342
  const key = landed?.key ?? null;
18088
- useEffect42(() => {
18343
+ useEffect43(() => {
18089
18344
  if (!key) return;
18090
18345
  askedFor.delete(askKey(tableId, layout));
18091
18346
  onMade(key);
@@ -18098,12 +18353,12 @@ function ViewNeeds({ layout, tableId, fields, onMade, className }) {
18098
18353
  const rights = useTableRights(table.data);
18099
18354
  const host = useRecordsUi();
18100
18355
  const mutation = useFieldMutation4();
18101
- const client = useRecordsClient34();
18356
+ const client = useRecordsClient35();
18102
18357
  const taken = fields.map((f) => fieldName(f));
18103
- const [label, setLabel] = useState52(() => freeColumnName(need?.starter.label ?? "", taken));
18104
- const [options, setOptions] = useState52(() => [...need?.starter.options ?? []]);
18105
- const [refused, setRefused] = useState52(null);
18106
- const [pendingId, setPendingId] = useState52(null);
18358
+ const [label, setLabel] = useState53(() => freeColumnName(need?.starter.label ?? "", taken));
18359
+ const [options, setOptions] = useState53(() => [...need?.starter.options ?? []]);
18360
+ const [refused, setRefused] = useState53(null);
18361
+ const [pendingId, setPendingId] = useState53(null);
18107
18362
  if (!need) return null;
18108
18363
  const name = label.trim() === "" ? need.starter.label : label.trim();
18109
18364
  const choices = options.map((o) => o.trim()).filter((o) => o !== "");
@@ -18197,7 +18452,7 @@ function ViewNeeds({ layout, tableId, fields, onMade, className }) {
18197
18452
  }
18198
18453
 
18199
18454
  // src/GalleryCover.tsx
18200
- import { useEffect as useEffect43, useState as useState53 } from "react";
18455
+ import { useEffect as useEffect44, useState as useState54 } from "react";
18201
18456
  import { useOptionalRecordsClient as useOptionalRecordsClient7 } from "@ai-matrx/records/react";
18202
18457
  import { Fragment as Fragment25, jsx as jsx63 } from "react/jsx-runtime";
18203
18458
  function isImageAddress(value) {
@@ -18218,8 +18473,8 @@ function GalleryCover({ field: field2, value }) {
18218
18473
  function FileCover({ recordId }) {
18219
18474
  const client = useOptionalRecordsClient7();
18220
18475
  const host = useRecordsUi();
18221
- const [read, setRead] = useState53(null);
18222
- useEffect43(() => {
18476
+ const [read, setRead] = useState54(null);
18477
+ useEffect44(() => {
18223
18478
  let cancelled = false;
18224
18479
  if (!client) {
18225
18480
  setRead({ fileId: recordId, name: "" });
@@ -18252,18 +18507,18 @@ function FileCover({ recordId }) {
18252
18507
  import { Fragment as Fragment26, jsx as jsx64, jsxs as jsxs56 } from "react/jsx-runtime";
18253
18508
  var NO_FIELDS = [];
18254
18509
  function useViewRecords(view, pageSize = 200, filter, viewId) {
18255
- const client = useRecordsClient35();
18510
+ const client = useRecordsClient36();
18256
18511
  const table = useRecords6(view.ruleId ? null : view.subject, {
18257
18512
  pageSize,
18258
18513
  ...filter ? { filter } : {}
18259
18514
  });
18260
- const [ruled, setRuled] = useState54({
18515
+ const [ruled, setRuled] = useState55({
18261
18516
  rows: [],
18262
18517
  loading: Boolean(view.ruleId),
18263
18518
  error: null
18264
18519
  });
18265
18520
  const ruleId = view.ruleId ?? null;
18266
- useEffect44(() => {
18521
+ useEffect45(() => {
18267
18522
  if (!ruleId) return;
18268
18523
  let cancelled = false;
18269
18524
  setRuled({ rows: [], loading: true, error: null });
@@ -18279,7 +18534,7 @@ function useViewRecords(view, pageSize = 200, filter, viewId) {
18279
18534
  }, [client, ruleId, pageSize]);
18280
18535
  const asked2 = stableFilterKey4(filter ?? null);
18281
18536
  const fromView = asked2 !== "{}" && (asked2 === stableFilterKey4(view.where ?? null) || asked2 === stableFilterKey4(view.filters ?? null));
18282
- const tableRows = useMemo31(() => table.data?.rows ?? [], [table.data]);
18537
+ const tableRows = useMemo32(() => table.data?.rows ?? [], [table.data]);
18283
18538
  const manual = view.order === "manual" && Boolean(viewId) && !ruleId;
18284
18539
  const hand = useHandOrderRows({
18285
18540
  viewId: viewId ?? null,
@@ -18346,11 +18601,11 @@ function ViewSwitcher({
18346
18601
  className
18347
18602
  }) {
18348
18603
  const toolbarSlot = useTableToolbarSlot();
18349
- const [layout, setLayout] = useState54(view.layout);
18604
+ const [layout, setLayout] = useState55(view.layout);
18350
18605
  const hostLayouts = useRecordsUi().layouts ?? [];
18351
18606
  const drawnByHost = hostLayout ? hostLayouts.find((h) => h.id === hostLayout) ?? null : null;
18352
- const [local, setLocal] = useState54({});
18353
- useEffect44(() => {
18607
+ const [local, setLocal] = useState55({});
18608
+ useEffect45(() => {
18354
18609
  setLayout(view.layout);
18355
18610
  setLocal({});
18356
18611
  }, [view.layout, view.name, view.subject]);
@@ -18458,12 +18713,12 @@ function offerableFields(all, want) {
18458
18713
  });
18459
18714
  }
18460
18715
  function useStageField(tableId) {
18461
- const client = useRecordsClient35();
18462
- const [stage, setStage] = useState54({
18716
+ const client = useRecordsClient36();
18717
+ const [stage, setStage] = useState55({
18463
18718
  asked: false,
18464
18719
  key: null
18465
18720
  });
18466
- useEffect44(() => {
18721
+ useEffect45(() => {
18467
18722
  let cancelled = false;
18468
18723
  setStage({ asked: false, key: null });
18469
18724
  void client.tableStageField({ table_id: tableId }).then((r) => {
@@ -18502,7 +18757,7 @@ function Board({
18502
18757
  const records = useViewRecords(view, pageSize, filter, viewId ?? null);
18503
18758
  const stage = useStageField(view.subject);
18504
18759
  const decorations = useTableDecorations(view.subject);
18505
- const style = useMemo31(
18760
+ const style = useMemo32(
18506
18761
  () => resolveTableStyle(decorations.data, fields.data ?? [], view.presentation?.style),
18507
18762
  [decorations.data, fields.data, view.presentation?.style]
18508
18763
  );
@@ -18691,10 +18946,10 @@ function Kanban({
18691
18946
  note,
18692
18947
  style
18693
18948
  }) {
18694
- const groupFields = useMemo31(() => [groupField], [groupField]);
18949
+ const groupFields = useMemo32(() => [groupField], [groupField]);
18695
18950
  const labels = useRecordLabels(groupFields);
18696
18951
  const options = useChoiceOptions(groupFields, isChoiceField(groupField) ? [groupField.key] : []).get(groupField.key);
18697
- const columns = useMemo31(() => {
18952
+ const columns = useMemo32(() => {
18698
18953
  const map = /* @__PURE__ */ new Map();
18699
18954
  const order = (options ?? []).map((o) => o.label);
18700
18955
  for (const label of order) map.set(label, []);
@@ -18725,7 +18980,7 @@ function Calendar({
18725
18980
  note,
18726
18981
  style
18727
18982
  }) {
18728
- const { days, undated } = useMemo31(() => {
18983
+ const { days, undated } = useMemo32(() => {
18729
18984
  const byDay = /* @__PURE__ */ new Map();
18730
18985
  const without = [];
18731
18986
  for (const row of rows) {
@@ -18795,7 +19050,7 @@ function Gallery({
18795
19050
  onHiddenFieldsChange,
18796
19051
  remembered
18797
19052
  }) {
18798
- const hidden = useMemo31(() => new Set(hiddenFields ?? []), [hiddenFields]);
19053
+ const hidden = useMemo32(() => new Set(hiddenFields ?? []), [hiddenFields]);
18799
19054
  const shown3 = fields.filter((field2) => !hidden.has(field2.key));
18800
19055
  const imageField = imageKey ? fields.find((field2) => field2.key === imageKey) : void 0;
18801
19056
  const dims = GALLERY_SIZE[size];
@@ -18869,7 +19124,7 @@ function Card2({
18869
19124
  dates
18870
19125
  }) {
18871
19126
  const host = useRecordsUi();
18872
- const wanted = useMemo31(
19127
+ const wanted = useMemo32(
18873
19128
  () => field2 && pointsAtRecords(field2) ? [field2] : NO_FIELDS,
18874
19129
  [field2]
18875
19130
  );
@@ -18897,7 +19152,7 @@ function Card2({
18897
19152
  }
18898
19153
 
18899
19154
  // src/ArchivedView.tsx
18900
- import { useCallback as useCallback22, useEffect as useEffect45, useState as useState55 } from "react";
19155
+ import { useCallback as useCallback22, useEffect as useEffect46, useState as useState56 } from "react";
18901
19156
  import {
18902
19157
  ARCHIVE_LANES,
18903
19158
  ARCHIVE_LANE_LABEL,
@@ -18906,7 +19161,7 @@ import {
18906
19161
  archivedByLine,
18907
19162
  emptyArchiveLine
18908
19163
  } from "@ai-matrx/records";
18909
- import { useFields as useFields14, useRecordsClient as useRecordsClient36, useTable as useTable9 } from "@ai-matrx/records/react";
19164
+ import { useFields as useFields14, useRecordsClient as useRecordsClient37, useTable as useTable9 } from "@ai-matrx/records/react";
18910
19165
  import { Button as Button46, Skeleton as Skeleton8, cn as cn35 } from "@ai-matrx/design-system";
18911
19166
  import { jsx as jsx65, jsxs as jsxs57 } from "react/jsx-runtime";
18912
19167
  var ARCHIVE_MEANS = "Archiving never destroys anything. A record you remove from the grid waits here until somebody brings it back.";
@@ -18925,17 +19180,17 @@ function ArchivedView({
18925
19180
  onRestored,
18926
19181
  className
18927
19182
  }) {
18928
- const client = useRecordsClient36();
19183
+ const client = useRecordsClient37();
18929
19184
  const table = useTable9(tableId);
18930
19185
  const rights = useTableRights(table.data);
18931
19186
  const fields = useFields14(tableId);
18932
- const [lane, setLane] = useState55(laneFromHost ?? DEFAULT_ARCHIVE_LANE);
18933
- const [rows, setRows] = useState55([]);
18934
- const [loading, setLoading] = useState55(true);
18935
- const [error, setError] = useState55(null);
18936
- const [restoring, setRestoring] = useState55(null);
18937
- const [refusal2, setRefusal] = useState55(null);
18938
- useEffect45(() => {
19187
+ const [lane, setLane] = useState56(laneFromHost ?? DEFAULT_ARCHIVE_LANE);
19188
+ const [rows, setRows] = useState56([]);
19189
+ const [loading, setLoading] = useState56(true);
19190
+ const [error, setError] = useState56(null);
19191
+ const [restoring, setRestoring] = useState56(null);
19192
+ const [refusal2, setRefusal] = useState56(null);
19193
+ useEffect46(() => {
18939
19194
  if (laneFromHost) setLane(laneFromHost);
18940
19195
  }, [laneFromHost]);
18941
19196
  const read = useCallback22(async () => {
@@ -18950,7 +19205,7 @@ function ArchivedView({
18950
19205
  }
18951
19206
  setLoading(false);
18952
19207
  }, [client, tableId, lane, pageSize]);
18953
- useEffect45(() => {
19208
+ useEffect46(() => {
18954
19209
  void read();
18955
19210
  }, [read]);
18956
19211
  const pick = (next) => {
@@ -19032,13 +19287,13 @@ function ArchivedView({
19032
19287
  }
19033
19288
 
19034
19289
  // src/ArchivedDisclosure.tsx
19035
- import { useCallback as useCallback23, useEffect as useEffect46, useState as useState56 } from "react";
19290
+ import { useCallback as useCallback23, useEffect as useEffect47, useState as useState57 } from "react";
19036
19291
  import {
19037
19292
  emptyPortalArchiveLine,
19038
19293
  portalConfirmLine,
19039
19294
  portalTitleTypedBack
19040
19295
  } from "@ai-matrx/records";
19041
- import { useRecordsClient as useRecordsClient37 } from "@ai-matrx/records/react";
19296
+ import { useRecordsClient as useRecordsClient38 } from "@ai-matrx/records/react";
19042
19297
  import { BasicInput as BasicInput16, Button as Button47, Skeleton as Skeleton9, cn as cn36 } from "@ai-matrx/design-system";
19043
19298
  import { jsx as jsx66, jsxs as jsxs58 } from "react/jsx-runtime";
19044
19299
  var ARCHIVED_NEVER_DESTROYED = "Archiving never destroys anything. What you put away waits here until somebody brings it back.";
@@ -19050,7 +19305,7 @@ function ArchivedDisclosure({
19050
19305
  children,
19051
19306
  className
19052
19307
  }) {
19053
- const [open, setOpen] = useState56(defaultOpen);
19308
+ const [open, setOpen] = useState57(defaultOpen);
19054
19309
  const toggle = () => {
19055
19310
  const next = !open;
19056
19311
  setOpen(next);
@@ -19083,14 +19338,14 @@ function ArchivedPortals({
19083
19338
  defaultOpen,
19084
19339
  className
19085
19340
  }) {
19086
- const client = useRecordsClient37();
19087
- const [rows, setRows] = useState56(null);
19088
- const [error, setError] = useState56(null);
19089
- const [confirming, setConfirming] = useState56(null);
19090
- const [typed, setTyped] = useState56("");
19091
- const [restoring, setRestoring] = useState56(null);
19092
- const [refusal2, setRefusal] = useState56(null);
19093
- const [said, setSaid] = useState56(null);
19341
+ const client = useRecordsClient38();
19342
+ const [rows, setRows] = useState57(null);
19343
+ const [error, setError] = useState57(null);
19344
+ const [confirming, setConfirming] = useState57(null);
19345
+ const [typed, setTyped] = useState57("");
19346
+ const [restoring, setRestoring] = useState57(null);
19347
+ const [refusal2, setRefusal] = useState57(null);
19348
+ const [said, setSaid] = useState57(null);
19094
19349
  const read = useCallback23(async () => {
19095
19350
  const answered = await client.listPortals({ archived: "archived" });
19096
19351
  if (answered.ok) {
@@ -19101,7 +19356,7 @@ function ArchivedPortals({
19101
19356
  setError(answered.error);
19102
19357
  }
19103
19358
  }, [client]);
19104
- useEffect46(() => {
19359
+ useEffect47(() => {
19105
19360
  void read();
19106
19361
  }, [read, refreshToken]);
19107
19362
  const restore = async (portal) => {
@@ -19217,8 +19472,8 @@ function ArchivedPortals({
19217
19472
  }
19218
19473
 
19219
19474
  // src/ViewBar.tsx
19220
- import { useCallback as useCallback25, useEffect as useEffect47, useState as useState57 } from "react";
19221
- import { useRecordsClient as useRecordsClient38 } from "@ai-matrx/records/react";
19475
+ import { useCallback as useCallback25, useEffect as useEffect48, useState as useState58 } from "react";
19476
+ import { useRecordsClient as useRecordsClient39 } from "@ai-matrx/records/react";
19222
19477
  import { Badge as Badge12, Button as Button48, Input as Input2, Popover as Popover5, PopoverContent as PopoverContent5, PopoverTrigger as PopoverTrigger5, Skeleton as Skeleton10, cn as cn37 } from "@ai-matrx/design-system";
19223
19478
 
19224
19479
  // src/seedOnce.ts
@@ -19241,17 +19496,17 @@ function seedIsSatisfied(seed, views) {
19241
19496
  return seed.isDefault === true && views.some((v) => v.isDefault);
19242
19497
  }
19243
19498
  function ViewBar({ tableId, activeViewId, onActiveView, seed, settings, onViews, className }) {
19244
- const client = useRecordsClient38();
19499
+ const client = useRecordsClient39();
19245
19500
  const claimSeed = useSeedGuard();
19246
19501
  const table = useTable10(tableId);
19247
19502
  const rights = useTableRights(table.data);
19248
- const [views, setViews] = useState57(null);
19249
- const [error, setError] = useState57(null);
19250
- const [unavailable, setUnavailable] = useState57(false);
19251
- const [active, setActive] = useState57(activeViewId ?? null);
19252
- const [naming, setNaming] = useState57(false);
19253
- const [draftName, setDraftName] = useState57("");
19254
- const [open, setOpen] = useState57(false);
19503
+ const [views, setViews] = useState58(null);
19504
+ const [error, setError] = useState58(null);
19505
+ const [unavailable, setUnavailable] = useState58(false);
19506
+ const [active, setActive] = useState58(activeViewId ?? null);
19507
+ const [naming, setNaming] = useState58(false);
19508
+ const [draftName, setDraftName] = useState58("");
19509
+ const [open, setOpen] = useState58(false);
19255
19510
  const seedKey = JSON.stringify(seed ?? []);
19256
19511
  const readViews = useCallback25(async () => {
19257
19512
  const result = await client.views({ table_id: tableId });
@@ -19293,10 +19548,10 @@ function ViewBar({ tableId, activeViewId, onActiveView, seed, settings, onViews,
19293
19548
  setViews(mine);
19294
19549
  onViews?.(mine);
19295
19550
  }, [client, readViews, tableId, seedKey]);
19296
- useEffect47(() => {
19551
+ useEffect48(() => {
19297
19552
  void load();
19298
19553
  }, [load]);
19299
- useEffect47(() => {
19554
+ useEffect48(() => {
19300
19555
  if (!views || views.length === 0) return;
19301
19556
  const chosen = views.find((v) => v.id === (activeViewId ?? active)) ?? defaultViewOf(views) ?? views[0];
19302
19557
  if (chosen.id !== active) setActive(chosen.id);
@@ -19399,8 +19654,8 @@ function ViewBar({ tableId, activeViewId, onActiveView, seed, settings, onViews,
19399
19654
  }
19400
19655
 
19401
19656
  // src/ProposalRow.tsx
19402
- import { useState as useState58 } from "react";
19403
- import { useRecordsClient as useRecordsClient39 } from "@ai-matrx/records/react";
19657
+ import { useState as useState59 } from "react";
19658
+ import { useRecordsClient as useRecordsClient40 } from "@ai-matrx/records/react";
19404
19659
  import { Badge as Badge13, Button as Button49, cn as cn38 } from "@ai-matrx/design-system";
19405
19660
  import { jsx as jsx68, jsxs as jsxs60 } from "react/jsx-runtime";
19406
19661
  var ACT_WORD = PROPOSED_CHANGE_ACT_LABEL;
@@ -19413,10 +19668,10 @@ function ProposalRow({
19413
19668
  onSettled,
19414
19669
  className
19415
19670
  }) {
19416
- const client = useRecordsClient39();
19417
- const [settled, setSettled] = useState58(outcome ?? null);
19418
- const [busy, setBusy] = useState58(false);
19419
- const [confirming, setConfirming] = useState58(false);
19671
+ const client = useRecordsClient40();
19672
+ const [settled, setSettled] = useState59(outcome ?? null);
19673
+ const [busy, setBusy] = useState59(false);
19674
+ const [confirming, setConfirming] = useState59(false);
19420
19675
  async function applyThroughTheStore() {
19421
19676
  if (change.act === "add") {
19422
19677
  if (!change.table) {
@@ -19501,14 +19756,14 @@ function ProposalRow({
19501
19756
  }
19502
19757
 
19503
19758
  // src/ActionInbox.tsx
19504
- import { useCallback as useCallback27, useEffect as useEffect49, useMemo as useMemo33, useRef as useRef21, useState as useState60 } from "react";
19505
- import { useRecordsClient as useRecordsClient41 } from "@ai-matrx/records/react";
19759
+ import { useCallback as useCallback27, useEffect as useEffect50, useMemo as useMemo34, useRef as useRef21, useState as useState61 } from "react";
19760
+ import { useRecordsClient as useRecordsClient42 } from "@ai-matrx/records/react";
19506
19761
  import { Badge as Badge15, Button as Button51, Checkbox as Checkbox7, Skeleton as Skeleton12, cn as cn40 } from "@ai-matrx/design-system";
19507
19762
  import { toggleSelection as toggleSelection2 } from "@ai-matrx/design-system/data-table";
19508
19763
 
19509
19764
  // src/ChecklistRunner.tsx
19510
- import { useCallback as useCallback26, useEffect as useEffect48, useMemo as useMemo32, useState as useState59 } from "react";
19511
- import { useRecordsClient as useRecordsClient40, useTable as useTable11 } from "@ai-matrx/records/react";
19765
+ import { useCallback as useCallback26, useEffect as useEffect49, useMemo as useMemo33, useState as useState60 } from "react";
19766
+ import { useRecordsClient as useRecordsClient41, useTable as useTable11 } from "@ai-matrx/records/react";
19512
19767
  import { Badge as Badge14, BasicInput as BasicInput17, BasicTextarea as BasicTextarea9, Button as Button50, Skeleton as Skeleton11, cn as cn39 } from "@ai-matrx/design-system";
19513
19768
  import { Fragment as Fragment27, jsx as jsx69, jsxs as jsxs61 } from "react/jsx-runtime";
19514
19769
  var DUE_WORD = DUE_STATE_LABEL;
@@ -19522,16 +19777,16 @@ function ChecklistRunner({
19522
19777
  offerToStart,
19523
19778
  className
19524
19779
  }) {
19525
- const client = useRecordsClient40();
19780
+ const client = useRecordsClient41();
19526
19781
  const table = useTable11(tableId ?? null);
19527
19782
  const rights = useTableRights(table.data);
19528
- const [runs, setRuns] = useState59(null);
19529
- const [activeId, setActiveId] = useState59(runId ?? null);
19530
- const [steps, setSteps] = useState59(null);
19531
- const [templates, setTemplates] = useState59(null);
19532
- const [error, setError] = useState59(null);
19533
- const [busy, setBusy] = useState59(null);
19534
- const [said, setSaid] = useState59(null);
19783
+ const [runs, setRuns] = useState60(null);
19784
+ const [activeId, setActiveId] = useState60(runId ?? null);
19785
+ const [steps, setSteps] = useState60(null);
19786
+ const [templates, setTemplates] = useState60(null);
19787
+ const [error, setError] = useState60(null);
19788
+ const [busy, setBusy] = useState60(null);
19789
+ const [said, setSaid] = useState60(null);
19535
19790
  const mayStart = offerToStart ?? Boolean(recordId);
19536
19791
  const loadRuns = useCallback26(async () => {
19537
19792
  if (runId) {
@@ -19555,10 +19810,10 @@ function ChecklistRunner({
19555
19810
  (held) => held && answered.data.some((r) => r.run_id === held) ? held : answered.data[0]?.run_id ?? null
19556
19811
  );
19557
19812
  }, [client, includeClosed, recordId, runId, tableId]);
19558
- useEffect48(() => {
19813
+ useEffect49(() => {
19559
19814
  void loadRuns();
19560
19815
  }, [loadRuns]);
19561
- useEffect48(() => {
19816
+ useEffect49(() => {
19562
19817
  if (runId) setActiveId(runId);
19563
19818
  }, [runId]);
19564
19819
  const loadSteps = useCallback26(async () => {
@@ -19575,10 +19830,10 @@ function ChecklistRunner({
19575
19830
  setError(null);
19576
19831
  setSteps(answered.data);
19577
19832
  }, [client, activeId]);
19578
- useEffect48(() => {
19833
+ useEffect49(() => {
19579
19834
  void loadSteps();
19580
19835
  }, [loadSteps]);
19581
- useEffect48(() => {
19836
+ useEffect49(() => {
19582
19837
  if (!mayStart || !tableId) return;
19583
19838
  let cancelled = false;
19584
19839
  void client.checklistTemplates({ about_table_id: tableId, limit: 50 }).then((answered) => {
@@ -19640,7 +19895,7 @@ function ChecklistRunner({
19640
19895
  },
19641
19896
  [client, loadSteps]
19642
19897
  );
19643
- const active = useMemo32(
19898
+ const active = useMemo33(
19644
19899
  () => runs?.find((r) => r.run_id === activeId) ?? null,
19645
19900
  [runs, activeId]
19646
19901
  );
@@ -19713,9 +19968,9 @@ function StepRow({
19713
19968
  className
19714
19969
  }) {
19715
19970
  const host = useRecordsUi();
19716
- const [members, setMembers] = useState59(null);
19971
+ const [members, setMembers] = useState60(null);
19717
19972
  const unassigned = !step2.finished && !step2.assignee_user_id && Boolean(step2.role);
19718
- useEffect48(() => {
19973
+ useEffect49(() => {
19719
19974
  if (!unassigned || !onAssign || !host.members || members !== null) return;
19720
19975
  let alive = true;
19721
19976
  void host.members().then((roster) => {
@@ -19725,7 +19980,7 @@ function StepRow({
19725
19980
  alive = false;
19726
19981
  };
19727
19982
  }, [unassigned, onAssign, host, members]);
19728
- const [answer, setAnswer] = useState59("");
19983
+ const [answer, setAnswer] = useState60("");
19729
19984
  const key = step2.requires_key ?? (step2.requires === "note" ? "note" : null);
19730
19985
  const asksHere = step2.requires === "note" || step2.requires === "answer";
19731
19986
  const needsAnswer = asksHere && answer.trim().length === 0;
@@ -19817,11 +20072,11 @@ function StepRow({
19817
20072
  );
19818
20073
  }
19819
20074
  function useMyChecklistSteps(limit = 25) {
19820
- const client = useRecordsClient40();
20075
+ const client = useRecordsClient41();
19821
20076
  const me = client.config.actor.user_id ?? null;
19822
- const [steps, setSteps] = useState59([]);
19823
- const [loading, setLoading] = useState59(true);
19824
- const [error, setError] = useState59(null);
20077
+ const [steps, setSteps] = useState60([]);
20078
+ const [loading, setLoading] = useState60(true);
20079
+ const [error, setError] = useState60(null);
19825
20080
  const refresh = useCallback26(async () => {
19826
20081
  if (!me) {
19827
20082
  setSteps([]);
@@ -19850,7 +20105,7 @@ function useMyChecklistSteps(limit = 25) {
19850
20105
  setSteps(held);
19851
20106
  setLoading(false);
19852
20107
  }, [client, limit, me]);
19853
- useEffect48(() => {
20108
+ useEffect49(() => {
19854
20109
  void refresh();
19855
20110
  }, [refresh]);
19856
20111
  return { steps, loading, error, refresh };
@@ -19861,14 +20116,14 @@ function MyChecklistSteps({
19861
20116
  onSteps,
19862
20117
  actions
19863
20118
  }) {
19864
- const client = useRecordsClient40();
20119
+ const client = useRecordsClient41();
19865
20120
  const { steps: held, loading, error, refresh } = useMyChecklistSteps();
19866
- useEffect48(() => {
20121
+ useEffect49(() => {
19867
20122
  onSteps?.(held.map((s) => s.step_id));
19868
20123
  }, [held, onSteps]);
19869
20124
  const steps = onlyIds ? held.filter((s) => onlyIds.has(s.step_id)) : held;
19870
- const [busy, setBusy] = useState59(null);
19871
- const [refusal2, setRefusal] = useState59(null);
20125
+ const [busy, setBusy] = useState60(null);
20126
+ const [refusal2, setRefusal] = useState60(null);
19872
20127
  const complete = useCallback26(
19873
20128
  async (step2, evidence) => {
19874
20129
  setBusy(step2.step_id);
@@ -19909,14 +20164,14 @@ function MyChecklistSteps({
19909
20164
  ] });
19910
20165
  }
19911
20166
  function ChecklistsPanel({ tableId, onOpenRecord, className }) {
19912
- const client = useRecordsClient40();
20167
+ const client = useRecordsClient41();
19913
20168
  const table = useTable11(tableId);
19914
20169
  const rights = useTableRights(table.data);
19915
- const [templates, setTemplates] = useState59(null);
19916
- const [runs, setRuns] = useState59(null);
19917
- const [error, setError] = useState59(null);
19918
- const [editing, setEditing] = useState59(null);
19919
- const [openRun, setOpenRun] = useState59(null);
20170
+ const [templates, setTemplates] = useState60(null);
20171
+ const [runs, setRuns] = useState60(null);
20172
+ const [error, setError] = useState60(null);
20173
+ const [editing, setEditing] = useState60(null);
20174
+ const [openRun, setOpenRun] = useState60(null);
19920
20175
  const load = useCallback26(async () => {
19921
20176
  const [t, r] = await Promise.all([
19922
20177
  client.checklistTemplates({ about_table_id: tableId, limit: 100 }),
@@ -19931,7 +20186,7 @@ function ChecklistsPanel({ tableId, onOpenRecord, className }) {
19931
20186
  if (!r.ok) setRuns([]);
19932
20187
  else setRuns(r.data);
19933
20188
  }, [client, tableId]);
19934
- useEffect48(() => {
20189
+ useEffect49(() => {
19935
20190
  void load();
19936
20191
  }, [load]);
19937
20192
  if (templates === null) return /* @__PURE__ */ jsx69(Skeleton11, { className: cn39("h-40 w-full", className) });
@@ -20070,14 +20325,14 @@ function ChecklistTemplateEditor({
20070
20325
  onDone,
20071
20326
  className
20072
20327
  }) {
20073
- const client = useRecordsClient40();
20074
- const [name, setName] = useState59("");
20075
- const [rows, setRows] = useState59([{ ...EMPTY_ROW }]);
20076
- const [refusal2, setRefusal] = useState59(null);
20077
- const [error, setError] = useState59(null);
20078
- const [busy, setBusy] = useState59(false);
20079
- const [loading, setLoading] = useState59(Boolean(templateId));
20080
- useEffect48(() => {
20328
+ const client = useRecordsClient41();
20329
+ const [name, setName] = useState60("");
20330
+ const [rows, setRows] = useState60([{ ...EMPTY_ROW }]);
20331
+ const [refusal2, setRefusal] = useState60(null);
20332
+ const [error, setError] = useState60(null);
20333
+ const [busy, setBusy] = useState60(false);
20334
+ const [loading, setLoading] = useState60(Boolean(templateId));
20335
+ useEffect49(() => {
20081
20336
  if (!templateId) return;
20082
20337
  let cancelled = false;
20083
20338
  void client.checklistTemplateShape({ template_id: templateId }).then((answered) => {
@@ -20105,7 +20360,7 @@ function ChecklistTemplateEditor({
20105
20360
  cancelled = true;
20106
20361
  };
20107
20362
  }, [client, templateId]);
20108
- const spec = useMemo32(
20363
+ const spec = useMemo33(
20109
20364
  () => ({
20110
20365
  name: name.trim(),
20111
20366
  about_table_id: aboutTableId,
@@ -20114,7 +20369,7 @@ function ChecklistTemplateEditor({
20114
20369
  }),
20115
20370
  [aboutTableId, name, rows]
20116
20371
  );
20117
- useEffect48(() => {
20372
+ useEffect49(() => {
20118
20373
  if (spec.steps.length === 0 || spec.name.length === 0) {
20119
20374
  setRefusal(null);
20120
20375
  return;
@@ -20361,26 +20616,26 @@ function ActionInbox({
20361
20616
  onOpenRecord,
20362
20617
  className
20363
20618
  }) {
20364
- const client = useRecordsClient41();
20365
- const [showDecided, setShowDecided] = useState60(includeSettled);
20366
- const [groupBy, setGroupBy] = useState60(defaultGroupBy);
20367
- const [everyTable, setEveryTable] = useState60(false);
20368
- const [items, setItems] = useState60(null);
20369
- const [error, setError] = useState60(null);
20370
- const [outcome, setOutcome] = useState60({});
20371
- const [busy, setBusy] = useState60(null);
20372
- const [cursor, setCursor] = useState60(0);
20619
+ const client = useRecordsClient42();
20620
+ const [showDecided, setShowDecided] = useState61(includeSettled);
20621
+ const [groupBy, setGroupBy] = useState61(defaultGroupBy);
20622
+ const [everyTable, setEveryTable] = useState61(false);
20623
+ const [items, setItems] = useState61(null);
20624
+ const [error, setError] = useState61(null);
20625
+ const [outcome, setOutcome] = useState61({});
20626
+ const [busy, setBusy] = useState61(null);
20627
+ const [cursor, setCursor] = useState61(0);
20373
20628
  const listRef = useRef21(null);
20374
- const [selected, setSelected] = useState60(/* @__PURE__ */ new Set());
20629
+ const [selected, setSelected] = useState61(/* @__PURE__ */ new Set());
20375
20630
  const anchor = useRef21(null);
20376
- const [deciding, setDeciding] = useState60(false);
20377
- const [batchSaid, setBatchSaid] = useState60(null);
20378
- const [view, setView] = useState60("inbox");
20379
- const [counts, setCounts] = useState60(null);
20380
- const [snoozing, setSnoozing] = useState60(null);
20381
- const [pickAt, setPickAt] = useState60("");
20382
- const [said, setSaid] = useState60(null);
20383
- const [stepIds, setStepIds] = useState60(/* @__PURE__ */ new Set());
20631
+ const [deciding, setDeciding] = useState61(false);
20632
+ const [batchSaid, setBatchSaid] = useState61(null);
20633
+ const [view, setView] = useState61("inbox");
20634
+ const [counts, setCounts] = useState61(null);
20635
+ const [snoozing, setSnoozing] = useState61(null);
20636
+ const [pickAt, setPickAt] = useState61("");
20637
+ const [said, setSaid] = useState61(null);
20638
+ const [stepIds, setStepIds] = useState61(/* @__PURE__ */ new Set());
20384
20639
  const onSteps = useCallback27((ids) => setStepIds(new Set(ids)), []);
20385
20640
  const load = useCallback27(async () => {
20386
20641
  const [result, counted] = await Promise.all([
@@ -20396,25 +20651,25 @@ function ActionInbox({
20396
20651
  setError(null);
20397
20652
  setItems(result.data);
20398
20653
  }, [client, showDecided, view]);
20399
- useEffect49(() => {
20654
+ useEffect50(() => {
20400
20655
  void load();
20401
20656
  }, [load]);
20402
- const narrowed = useMemo33(() => {
20657
+ const narrowed = useMemo34(() => {
20403
20658
  const all = (items ?? []).filter((i) => !(view === "inbox" && i.kind === "assignment" && stepIds.has(i.item_id)));
20404
20659
  if (!tableId || everyTable) return all;
20405
20660
  return all.filter((i) => i.table_id === tableId);
20406
20661
  }, [items, tableId, everyTable, view, stepIds]);
20407
- const waitingIds = useMemo33(
20662
+ const waitingIds = useMemo34(
20408
20663
  () => new Set((items ?? []).filter((i) => i.kind === "assignment").map((i) => i.item_id)),
20409
20664
  [items]
20410
20665
  );
20411
- const groups = useMemo33(() => groupInbox(narrowed, groupBy), [narrowed, groupBy]);
20412
- const shown3 = useMemo33(() => groups.flatMap((g) => g.items), [groups]);
20666
+ const groups = useMemo34(() => groupInbox(narrowed, groupBy), [narrowed, groupBy]);
20667
+ const shown3 = useMemo34(() => groups.flatMap((g) => g.items), [groups]);
20413
20668
  const elsewhere = (items?.length ?? 0) - narrowed.length;
20414
- useEffect49(() => {
20669
+ useEffect50(() => {
20415
20670
  if (cursor >= shown3.length) setCursor(Math.max(0, shown3.length - 1));
20416
20671
  }, [shown3.length, cursor]);
20417
- useEffect49(() => {
20672
+ useEffect50(() => {
20418
20673
  const el = listRef.current?.querySelector(`[data-row="${cursor}"]`);
20419
20674
  el?.scrollIntoView({ block: "nearest" });
20420
20675
  }, [cursor, shown3.length]);
@@ -20434,12 +20689,12 @@ function ActionInbox({
20434
20689
  },
20435
20690
  [client, load]
20436
20691
  );
20437
- const [held, setHeld] = useState60({});
20692
+ const [held, setHeld] = useState61({});
20438
20693
  const holds2 = useRef21(/* @__PURE__ */ new Map());
20439
20694
  const lastHold = useRef21(null);
20440
20695
  const holdSeq = useRef21(0);
20441
- const [, tick] = useState60(0);
20442
- useEffect49(() => {
20696
+ const [, tick] = useState61(0);
20697
+ useEffect50(() => {
20443
20698
  if (Object.keys(held).length === 0) return;
20444
20699
  const t = setInterval(() => tick((n) => n + 1), 250);
20445
20700
  return () => clearInterval(t);
@@ -20484,7 +20739,7 @@ function ActionInbox({
20484
20739
  });
20485
20740
  setSaid({ text: entry.ids.length === 1 ? "Undone. It is waiting on you again, exactly as it was." : `Undone. All ${entry.ids.length} are waiting on you again, exactly as they were.`, undo: null });
20486
20741
  }, []);
20487
- useEffect49(() => {
20742
+ useEffect50(() => {
20488
20743
  const flush = () => {
20489
20744
  for (const entry of [...holds2.current.values()]) entry.commit();
20490
20745
  };
@@ -20495,7 +20750,7 @@ function ActionInbox({
20495
20750
  };
20496
20751
  }, []);
20497
20752
  const resumed = useRef21(false);
20498
- useEffect49(() => {
20753
+ useEffect50(() => {
20499
20754
  if (resumed.current || items === null || view !== "inbox") return;
20500
20755
  resumed.current = true;
20501
20756
  const kept = readHolds();
@@ -21098,25 +21353,25 @@ function ActionInbox({
21098
21353
  }
21099
21354
 
21100
21355
  // src/HistoryPanel.tsx
21101
- import { useCallback as useCallback28, useEffect as useEffect50, useRef as useRef22, useState as useState61 } from "react";
21356
+ import { useCallback as useCallback28, useEffect as useEffect51, useRef as useRef22, useState as useState62 } from "react";
21102
21357
  import {
21103
21358
  useFields as useFields15,
21104
21359
  useRecordChangeRevision,
21105
- useRecordsClient as useRecordsClient42,
21360
+ useRecordsClient as useRecordsClient43,
21106
21361
  useTable as useTable12
21107
21362
  } from "@ai-matrx/records/react";
21108
21363
  import { Badge as Badge16, Button as Button52, Skeleton as Skeleton13, cn as cn41 } from "@ai-matrx/design-system";
21109
21364
  import { jsx as jsx71, jsxs as jsxs63 } from "react/jsx-runtime";
21110
21365
  function HistoryPanel({ tableId, recordId, onAskAboutField, className }) {
21111
- const client = useRecordsClient42();
21366
+ const client = useRecordsClient43();
21112
21367
  const table = useTable12(tableId);
21113
21368
  const fields = useFields15(tableId);
21114
21369
  const rights = useTableRights(table.data);
21115
- const [entries, setEntries] = useState61(null);
21116
- const [error, setError] = useState61(null);
21117
- const [open, setOpen] = useState61(null);
21118
- const [pending, setPending] = useState61({ phase: "idle" });
21119
- const [said, setSaid] = useState61(null);
21370
+ const [entries, setEntries] = useState62(null);
21371
+ const [error, setError] = useState62(null);
21372
+ const [open, setOpen] = useState62(null);
21373
+ const [pending, setPending] = useState62({ phase: "idle" });
21374
+ const [said, setSaid] = useState62(null);
21120
21375
  const listRef = useRef22(null);
21121
21376
  const changed = useRecordChangeRevision(recordId);
21122
21377
  const load = useCallback28(async () => {
@@ -21128,7 +21383,7 @@ function HistoryPanel({ tableId, recordId, onAskAboutField, className }) {
21128
21383
  setError(null);
21129
21384
  setEntries(answered.data);
21130
21385
  }, [client, recordId, changed]);
21131
- useEffect50(() => {
21386
+ useEffect51(() => {
21132
21387
  void load();
21133
21388
  }, [load]);
21134
21389
  if (error) return /* @__PURE__ */ jsx71(RefusalNotice, { error, className });
@@ -21409,29 +21664,29 @@ function say(value, field2) {
21409
21664
  }
21410
21665
 
21411
21666
  // src/CommentThread.tsx
21412
- import { useCallback as useCallback29, useEffect as useEffect51, useMemo as useMemo34, useRef as useRef23, useState as useState62 } from "react";
21667
+ import { useCallback as useCallback29, useEffect as useEffect52, useMemo as useMemo35, useRef as useRef23, useState as useState63 } from "react";
21413
21668
  import {
21414
21669
  useFields as useFields16,
21415
- useRecordsClient as useRecordsClient43,
21670
+ useRecordsClient as useRecordsClient44,
21416
21671
  useTable as useTable13
21417
21672
  } from "@ai-matrx/records/react";
21418
21673
  import { Badge as Badge17, Button as Button53, Skeleton as Skeleton14, Textarea, cn as cn42 } from "@ai-matrx/design-system";
21419
21674
  import { jsx as jsx72, jsxs as jsxs64 } from "react/jsx-runtime";
21420
21675
  function CommentThread({ tableId, recordId, fieldKey, className }) {
21421
- const client = useRecordsClient43();
21676
+ const client = useRecordsClient44();
21422
21677
  const table = useTable13(tableId);
21423
21678
  const fields = useFields16(tableId);
21424
21679
  const host = useRecordsUi();
21425
- const [thread, setThread] = useState62(null);
21426
- const [error, setError] = useState62(null);
21427
- const [draft, setDraft] = useState62("");
21428
- const [replyTo, setReplyTo] = useState62(null);
21429
- const [busy, setBusy] = useState62(false);
21430
- const [said, setSaid] = useState62(null);
21431
- const [showResolved, setShowResolved] = useState62(false);
21432
- const [people, setPeople] = useState62([]);
21433
- const [mentionQuery, setMentionQuery] = useState62(null);
21434
- const [picked, setPicked] = useState62([]);
21680
+ const [thread, setThread] = useState63(null);
21681
+ const [error, setError] = useState63(null);
21682
+ const [draft, setDraft] = useState63("");
21683
+ const [replyTo, setReplyTo] = useState63(null);
21684
+ const [busy, setBusy] = useState63(false);
21685
+ const [said, setSaid] = useState63(null);
21686
+ const [showResolved, setShowResolved] = useState63(false);
21687
+ const [people, setPeople] = useState63([]);
21688
+ const [mentionQuery, setMentionQuery] = useState63(null);
21689
+ const [picked, setPicked] = useState63([]);
21435
21690
  const box = useRef23(null);
21436
21691
  const load = useCallback29(async () => {
21437
21692
  const answered = await client.commentThread({ record_id: recordId, include_resolved: showResolved });
@@ -21446,10 +21701,10 @@ function CommentThread({ tableId, recordId, fieldKey, className }) {
21446
21701
  mayResolve: answered.data.may_resolve
21447
21702
  });
21448
21703
  }, [client, recordId, showResolved]);
21449
- useEffect51(() => {
21704
+ useEffect52(() => {
21450
21705
  void load();
21451
21706
  }, [load]);
21452
- useEffect51(() => {
21707
+ useEffect52(() => {
21453
21708
  let alive = true;
21454
21709
  if (!host.members) return;
21455
21710
  void host.members().then((roster) => {
@@ -21466,7 +21721,7 @@ function CommentThread({ tableId, recordId, fieldKey, className }) {
21466
21721
  alive = false;
21467
21722
  };
21468
21723
  }, [host]);
21469
- const candidates = useMemo34(() => {
21724
+ const candidates = useMemo35(() => {
21470
21725
  if (mentionQuery === null) return [];
21471
21726
  const q = mentionQuery.trim().toLowerCase();
21472
21727
  return people.filter((p) => !picked.some((already) => already.userId === p.userId)).filter((p) => q === "" || (p.name ?? p.email ?? "").toLowerCase().includes(q)).slice(0, 6);
@@ -21652,10 +21907,10 @@ function Line({
21652
21907
  }
21653
21908
 
21654
21909
  // src/FieldHistoryPanel.tsx
21655
- import { useCallback as useCallback30, useEffect as useEffect52, useState as useState63 } from "react";
21910
+ import { useCallback as useCallback30, useEffect as useEffect53, useState as useState64 } from "react";
21656
21911
  import {
21657
21912
  useFields as useFields17,
21658
- useRecordsClient as useRecordsClient44,
21913
+ useRecordsClient as useRecordsClient45,
21659
21914
  useTable as useTable14
21660
21915
  } from "@ai-matrx/records/react";
21661
21916
  import { Badge as Badge18, Button as Button54, Skeleton as Skeleton15, cn as cn43 } from "@ai-matrx/design-system";
@@ -21668,14 +21923,14 @@ function FieldHistoryPanel({
21668
21923
  onOpenRecord,
21669
21924
  className
21670
21925
  }) {
21671
- const client = useRecordsClient44();
21926
+ const client = useRecordsClient45();
21672
21927
  const table = useTable14(tableId);
21673
21928
  const fields = useFields17(tableId);
21674
21929
  const rights = useTableRights(table.data);
21675
- const [rows, setRows] = useState63(null);
21676
- const [error, setError] = useState63(null);
21677
- const [pending, setPending] = useState63({ phase: "idle" });
21678
- const [said, setSaid] = useState63(null);
21930
+ const [rows, setRows] = useState64(null);
21931
+ const [error, setError] = useState64(null);
21932
+ const [pending, setPending] = useState64({ phase: "idle" });
21933
+ const [said, setSaid] = useState64(null);
21679
21934
  const load = useCallback30(async () => {
21680
21935
  const answered = await client.fieldHistory(
21681
21936
  recordId ? { table_id: tableId, field_key: fieldKey, record_id: recordId } : { table_id: tableId, field_key: fieldKey }
@@ -21687,7 +21942,7 @@ function FieldHistoryPanel({
21687
21942
  setError(null);
21688
21943
  setRows(answered.data);
21689
21944
  }, [client, tableId, fieldKey, recordId]);
21690
- useEffect52(() => {
21945
+ useEffect53(() => {
21691
21946
  void load();
21692
21947
  }, [load]);
21693
21948
  const label = (fields.data ?? []).find((f) => f.key === fieldKey)?.label || humanize(fieldKey);
@@ -21899,20 +22154,20 @@ function submissionStamp(args) {
21899
22154
  }
21900
22155
 
21901
22156
  // src/PortalBuilder.tsx
21902
- import { useCallback as useCallback34, useEffect as useEffect59, useMemo as useMemo37, useState as useState70 } from "react";
21903
- import { useRecordsClient as useRecordsClient51, useTables as useTables4 } from "@ai-matrx/records/react";
22157
+ import { useCallback as useCallback34, useEffect as useEffect60, useMemo as useMemo38, useState as useState71 } from "react";
22158
+ import { useRecordsClient as useRecordsClient52, useTables as useTables4 } from "@ai-matrx/records/react";
21904
22159
  import { BasicInput as BasicInput21, Button as Button60, Checkbox as Checkbox9, Label as Label16, Separator as Separator9, Skeleton as Skeleton20, cn as cn48 } from "@ai-matrx/design-system";
21905
22160
 
21906
22161
  // src/TablesHome.tsx
21907
- import { useCallback as useCallback33, useEffect as useEffect58, useState as useState69 } from "react";
21908
- import { useRecordsClient as useRecordsClient50, useTables as useTables3 } from "@ai-matrx/records/react";
22162
+ import { useCallback as useCallback33, useEffect as useEffect59, useState as useState70 } from "react";
22163
+ import { useRecordsClient as useRecordsClient51, useTables as useTables3 } from "@ai-matrx/records/react";
21909
22164
  import { withTableFacts } from "@ai-matrx/records/core";
21910
22165
  import { withTablePlacement } from "@ai-matrx/records";
21911
22166
  import { BasicInput as BasicInput20, Button as Button59, Skeleton as Skeleton19, cn as cn47 } from "@ai-matrx/design-system";
21912
22167
 
21913
22168
  // src/ExampleTables.tsx
21914
- import { useEffect as useEffect53, useState as useState64 } from "react";
21915
- import { useRecordsClient as useRecordsClient45 } from "@ai-matrx/records/react";
22169
+ import { useEffect as useEffect54, useState as useState65 } from "react";
22170
+ import { useRecordsClient as useRecordsClient46 } from "@ai-matrx/records/react";
21916
22171
  import { loadUseCase, summarize as summarize2, useCaseIds } from "@ai-matrx/records/use-cases";
21917
22172
  import { Button as Button55, Skeleton as Skeleton16, cn as cn44 } from "@ai-matrx/design-system";
21918
22173
  import { jsx as jsx74, jsxs as jsxs66 } from "react/jsx-runtime";
@@ -21921,12 +22176,12 @@ function ExampleTables({
21921
22176
  onClose,
21922
22177
  className
21923
22178
  }) {
21924
- const client = useRecordsClient45();
21925
- const [summaries, setSummaries] = useState64(null);
21926
- const [busy, setBusy] = useState64(null);
21927
- const [error, setError] = useState64(null);
21928
- const [built, setBuilt] = useState64(null);
21929
- useEffect53(() => {
22179
+ const client = useRecordsClient46();
22180
+ const [summaries, setSummaries] = useState65(null);
22181
+ const [busy, setBusy] = useState65(null);
22182
+ const [error, setError] = useState65(null);
22183
+ const [built, setBuilt] = useState65(null);
22184
+ useEffect54(() => {
21930
22185
  let alive = true;
21931
22186
  void Promise.all(useCaseIds().map(async (id) => summarize2(await loadUseCase(id)))).then((rows) => {
21932
22187
  if (alive) setSummaries(rows);
@@ -22001,23 +22256,23 @@ function ExampleTables({
22001
22256
  }
22002
22257
 
22003
22258
  // src/BookingSlots.tsx
22004
- import { useCallback as useCallback32, useEffect as useEffect56, useMemo as useMemo36, useState as useState67 } from "react";
22005
- import { useRecordsClient as useRecordsClient48, useMyLevels as useMyLevels2 } from "@ai-matrx/records/react";
22259
+ import { useCallback as useCallback32, useEffect as useEffect57, useMemo as useMemo37, useState as useState68 } from "react";
22260
+ import { useRecordsClient as useRecordsClient49, useMyLevels as useMyLevels2 } from "@ai-matrx/records/react";
22006
22261
  import { bookingPath as bookingPath2 } from "@ai-matrx/records";
22007
22262
  import { Badge as Badge19, Button as Button57, Skeleton as Skeleton18, cn as cn46 } from "@ai-matrx/design-system";
22008
22263
 
22009
22264
  // src/BookingBuilder.tsx
22010
- import { useCallback as useCallback31, useEffect as useEffect55, useMemo as useMemo35, useState as useState66 } from "react";
22011
- import { useFields as useFields18, useRecordsClient as useRecordsClient47, useTable as useTable15 } from "@ai-matrx/records/react";
22265
+ import { useCallback as useCallback31, useEffect as useEffect56, useMemo as useMemo36, useState as useState67 } from "react";
22266
+ import { useFields as useFields18, useRecordsClient as useRecordsClient48, useTable as useTable15 } from "@ai-matrx/records/react";
22012
22267
 
22013
22268
  // src/publish-gate.ts
22014
- import { useEffect as useEffect54, useState as useState65 } from "react";
22015
- import { useRecordsClient as useRecordsClient46 } from "@ai-matrx/records/react";
22269
+ import { useEffect as useEffect55, useState as useState66 } from "react";
22270
+ import { useRecordsClient as useRecordsClient47 } from "@ai-matrx/records/react";
22016
22271
  var PUBLISH_NEEDS_THE_STORE_ON = "This organization has its record store switched off, so publishing would hand you a link that opens nothing. An owner or an administrator turns it on under Database settings, on the unified data screen \u2014 everything you have already built here is kept and starts working the moment they do.";
22017
22272
  function usePublishGate() {
22018
- const client = useRecordsClient46();
22019
- const [storeOpen, setStoreOpen] = useState65(null);
22020
- useEffect54(() => {
22273
+ const client = useRecordsClient47();
22274
+ const [storeOpen, setStoreOpen] = useState66(null);
22275
+ useEffect55(() => {
22021
22276
  let alive = true;
22022
22277
  void (async () => {
22023
22278
  const answered = await client.storeIsOpen();
@@ -22130,36 +22385,36 @@ function draftWindows(availability) {
22130
22385
  });
22131
22386
  }
22132
22387
  function BookingBuilder({ tableId, bookingId, onSaved, onClose, className }) {
22133
- const client = useRecordsClient47();
22388
+ const client = useRecordsClient48();
22134
22389
  const publishGate = usePublishGate();
22135
22390
  const host = useRecordsUi();
22136
22391
  const table = useTable15(tableId);
22137
22392
  const rights = useTableRights(table.data);
22138
22393
  const fields = useFields18(tableId);
22139
- const [existing, setExisting] = useState66(null);
22140
- const [loaded, setLoaded] = useState66(false);
22141
- const [error, setError] = useState66(null);
22142
- const [saving, setSaving] = useState66(false);
22143
- const [publishing, setPublishing] = useState66(false);
22144
- const [copied, setCopied] = useState66(false);
22145
- const [title, setTitle] = useState66("");
22146
- const [minutes, setMinutes] = useState66(30);
22147
- const [buffer, setBuffer] = useState66(0);
22148
- const [lead, setLead] = useState66(120);
22149
- const [perDay, setPerDay] = useState66(8);
22150
- const [days, setDays] = useState66(30);
22151
- const [timezone, setTimezone] = useState66(() => ownTimeZone());
22152
- const [windows, setWindows] = useState66(() => draftWindows(null));
22153
- const [asked2, setAsked] = useState66([]);
22154
- const [confirmation, setConfirmation] = useState66("");
22155
- const [offer, setOffer] = useState66(null);
22156
- const [formId, setFormId] = useState66(bookingId ?? null);
22394
+ const [existing, setExisting] = useState67(null);
22395
+ const [loaded, setLoaded] = useState67(false);
22396
+ const [error, setError] = useState67(null);
22397
+ const [saving, setSaving] = useState67(false);
22398
+ const [publishing, setPublishing] = useState67(false);
22399
+ const [copied, setCopied] = useState67(false);
22400
+ const [title, setTitle] = useState67("");
22401
+ const [minutes, setMinutes] = useState67(30);
22402
+ const [buffer, setBuffer] = useState67(0);
22403
+ const [lead, setLead] = useState67(120);
22404
+ const [perDay, setPerDay] = useState67(8);
22405
+ const [days, setDays] = useState67(30);
22406
+ const [timezone, setTimezone] = useState67(() => ownTimeZone());
22407
+ const [windows, setWindows] = useState67(() => draftWindows(null));
22408
+ const [asked2, setAsked] = useState67([]);
22409
+ const [confirmation, setConfirmation] = useState67("");
22410
+ const [offer, setOffer] = useState67(null);
22411
+ const [formId, setFormId] = useState67(bookingId ?? null);
22157
22412
  const publicOrigin = host.publicOrigin ?? (typeof window === "undefined" ? "" : window.location.origin);
22158
- const askable = useMemo35(
22413
+ const askable = useMemo36(
22159
22414
  () => askableFields(fields.data ?? [], STORE_ANSWERS_THESE),
22160
22415
  [fields.data]
22161
22416
  );
22162
- const leftOut = useMemo35(
22417
+ const leftOut = useMemo36(
22163
22418
  () => whyNotAskable(fields.data ?? [], STORE_ANSWERS_THESE),
22164
22419
  [fields.data]
22165
22420
  );
@@ -22172,22 +22427,34 @@ function BookingBuilder({ tableId, bookingId, onSaved, onClose, className }) {
22172
22427
  }
22173
22428
  const mine = bookingId ? answered.data.find((p) => p.form_id === bookingId) ?? null : answered.data[0] ?? null;
22174
22429
  setExisting(mine);
22430
+ if (mine) {
22431
+ setFormId(mine.form_id);
22432
+ const pages = await client.forms({ table_id: tableId });
22433
+ const page = pages.ok ? pages.data.find((f) => f.form_id === mine.form_id) : void 0;
22434
+ const presentation = page?.presentation ?? {};
22435
+ const questions = Array.isArray(presentation["questions"]) ? presentation["questions"] : [];
22436
+ const keys = questions.map((q) => typeof q.field === "string" ? q.field : "").filter((k) => k !== "");
22437
+ if (keys.length > 0) setAsked(keys);
22438
+ const block = presentation["booking"];
22439
+ if (block && typeof block === "object" && Array.isArray(block.windows)) {
22440
+ setOffer(block);
22441
+ }
22442
+ }
22175
22443
  setLoaded(true);
22176
- if (mine) setFormId(mine.form_id);
22177
22444
  }, [client, tableId, bookingId]);
22178
- useEffect55(() => {
22445
+ useEffect56(() => {
22179
22446
  void load();
22180
22447
  }, [load]);
22181
- useEffect55(() => {
22448
+ useEffect56(() => {
22182
22449
  if (title !== "" || !table.data) return;
22183
22450
  setTitle(existing?.title ?? `Book a ${minutes}-minute ${singularNoun(table.data, "appointment")}`);
22184
22451
  }, [table.data, existing]);
22185
- useEffect55(() => {
22452
+ useEffect56(() => {
22186
22453
  if (!existing) return;
22187
22454
  setMinutes(existing.slot_minutes);
22188
22455
  if (existing.timezone && existing.timezone !== "UTC") setTimezone(existing.timezone);
22189
22456
  }, [existing]);
22190
- useEffect55(() => {
22457
+ useEffect56(() => {
22191
22458
  if (!offer) return;
22192
22459
  setWindows(draftWindows(offer));
22193
22460
  setMinutes(offer.slot_minutes);
@@ -22195,7 +22462,7 @@ function BookingBuilder({ tableId, bookingId, onSaved, onClose, className }) {
22195
22462
  setLead(offer.lead_minutes);
22196
22463
  setPerDay(offer.max_per_day);
22197
22464
  setDays(offer.days);
22198
- if (offer.timezone) setTimezone(offer.timezone);
22465
+ if (offer.timezone && offer.timezone !== "UTC") setTimezone(offer.timezone);
22199
22466
  }, [offer]);
22200
22467
  const availability = useCallback31(
22201
22468
  () => ({
@@ -22209,7 +22476,7 @@ function BookingBuilder({ tableId, bookingId, onSaved, onClose, className }) {
22209
22476
  }),
22210
22477
  [timezone, minutes, buffer, lead, perDay, days, windows]
22211
22478
  );
22212
- const [addingWho, setAddingWho] = useState66(false);
22479
+ const [addingWho, setAddingWho] = useState67(false);
22213
22480
  async function addWho() {
22214
22481
  setAddingWho(true);
22215
22482
  setError(null);
@@ -22228,8 +22495,8 @@ function BookingBuilder({ tableId, bookingId, onSaved, onClose, className }) {
22228
22495
  setAddingWho(false);
22229
22496
  setWhoAdded(true);
22230
22497
  }
22231
- const [whoAdded, setWhoAdded] = useState66(false);
22232
- useEffect55(() => {
22498
+ const [whoAdded, setWhoAdded] = useState67(false);
22499
+ useEffect56(() => {
22233
22500
  if (!whoAdded) return;
22234
22501
  const who = askable.filter((f) => isWhoField(f)).map((f) => f.key);
22235
22502
  if (who.length === 0) return;
@@ -22503,15 +22770,15 @@ function bookingSuggestion(tableName2) {
22503
22770
  var NO_ADMIN = "Opening a booking page lets people with no account take time in your calendar, so it needs the admin level on the table the appointments land in.";
22504
22771
  var STATE_WORDS = BOOKING_PAGE_STATE_LABEL;
22505
22772
  function BookingSlots({ tableId, activeBookingId, className }) {
22506
- const client = useRecordsClient48();
22773
+ const client = useRecordsClient49();
22507
22774
  const host = useRecordsUi();
22508
- const [pages, setPages] = useState67(null);
22509
- const [error, setError] = useState67(null);
22510
- const [busy, setBusy] = useState67(null);
22511
- const [copied, setCopied] = useState67(null);
22512
- const [shown3, setShown] = useState67(null);
22513
- const [building, setBuilding] = useState67(false);
22514
- const [changing, setChanging] = useState67(null);
22775
+ const [pages, setPages] = useState68(null);
22776
+ const [error, setError] = useState68(null);
22777
+ const [busy, setBusy] = useState68(null);
22778
+ const [copied, setCopied] = useState68(null);
22779
+ const [shown3, setShown] = useState68(null);
22780
+ const [building, setBuilding] = useState68(false);
22781
+ const [changing, setChanging] = useState68(null);
22515
22782
  const load = useCallback32(async () => {
22516
22783
  const answered = await client.bookings(tableId ? { table_id: tableId } : {});
22517
22784
  if (!answered.ok) {
@@ -22522,10 +22789,10 @@ function BookingSlots({ tableId, activeBookingId, className }) {
22522
22789
  setError(null);
22523
22790
  setPages(answered.data);
22524
22791
  }, [client, tableId]);
22525
- useEffect56(() => {
22792
+ useEffect57(() => {
22526
22793
  void load();
22527
22794
  }, [load]);
22528
- const subjectIds = useMemo36(
22795
+ const subjectIds = useMemo37(
22529
22796
  () => Array.from(
22530
22797
  /* @__PURE__ */ new Set([
22531
22798
  ...(pages ?? []).map((p) => p.table_id),
@@ -22734,22 +23001,22 @@ import {
22734
23001
  } from "@ai-matrx/records/core";
22735
23002
 
22736
23003
  // src/WhereItLives.tsx
22737
- import { useEffect as useEffect57, useState as useState68 } from "react";
23004
+ import { useEffect as useEffect58, useState as useState69 } from "react";
22738
23005
  import { moveConsequence } from "@ai-matrx/records";
22739
- import { useRecordsClient as useRecordsClient49 } from "@ai-matrx/records/react";
23006
+ import { useRecordsClient as useRecordsClient50 } from "@ai-matrx/records/react";
22740
23007
  import { Button as Button58, ErrorBox as ErrorBox2, Popover as Popover6, PopoverContent as PopoverContent6, PopoverTrigger as PopoverTrigger6 } from "@ai-matrx/design-system";
22741
23008
  import { jsx as jsx78, jsxs as jsxs70 } from "react/jsx-runtime";
22742
23009
  function WhereItLives({ tableId, knownOrganizationName, onMoved, variant = "header" }) {
22743
- const client = useRecordsClient49();
23010
+ const client = useRecordsClient50();
22744
23011
  const host = useRecordsUi();
22745
- const [answer, setAnswer] = useState68(null);
22746
- const [attempt, setAttempt] = useState68(0);
22747
- const [open, setOpen] = useState68(false);
22748
- const [armed, setArmed] = useState68(variant !== "row" || !knownOrganizationName);
22749
- const [choosing, setChoosing] = useState68(null);
22750
- const [moving, setMoving] = useState68(false);
22751
- const [said, setSaid] = useState68(null);
22752
- useEffect57(() => {
23012
+ const [answer, setAnswer] = useState69(null);
23013
+ const [attempt, setAttempt] = useState69(0);
23014
+ const [open, setOpen] = useState69(false);
23015
+ const [armed, setArmed] = useState69(variant !== "row" || !knownOrganizationName);
23016
+ const [choosing, setChoosing] = useState69(null);
23017
+ const [moving, setMoving] = useState69(false);
23018
+ const [said, setSaid] = useState69(null);
23019
+ useEffect58(() => {
22753
23020
  if (!armed) return;
22754
23021
  let alive = true;
22755
23022
  setAnswer(null);
@@ -22995,11 +23262,11 @@ function visibilityLaneFor(table) {
22995
23262
  return "organization";
22996
23263
  }
22997
23264
  function TablesHome({ onOpenTable, organizationName, makingOnly = false, askedBy, className }) {
22998
- const client = useRecordsClient50();
23265
+ const client = useRecordsClient51();
22999
23266
  const tables = useTables3();
23000
23267
  const me = client.config.actor.user_id ?? null;
23001
- const [facts, setFacts] = useState69({ phase: "reading" });
23002
- useEffect58(() => {
23268
+ const [facts, setFacts] = useState70({ phase: "reading" });
23269
+ useEffect59(() => {
23003
23270
  let alive = true;
23004
23271
  void client.tableFacts().then((answered) => {
23005
23272
  if (!alive) return;
@@ -23013,11 +23280,11 @@ function TablesHome({ onOpenTable, organizationName, makingOnly = false, askedBy
23013
23280
  withTableFacts(tables.data ?? [], facts.rows, me),
23014
23281
  facts.rows
23015
23282
  ) : tables.data ?? [];
23016
- const [showEverything, setShowEverything] = useState69(false);
23283
+ const [showEverything, setShowEverything] = useState70(false);
23017
23284
  const keptCount = listed.filter((t) => laneFor(t) === "app").length;
23018
- const [askedName, setAskedName] = useState69(null);
23285
+ const [askedName, setAskedName] = useState70(null);
23019
23286
  const firstTableId = listed[0]?.id ?? null;
23020
- useEffect58(() => {
23287
+ useEffect59(() => {
23021
23288
  if (organizationName || !firstTableId) return;
23022
23289
  let alive = true;
23023
23290
  void client.tableHome({ table_id: firstTableId }).then((answered) => {
@@ -23030,23 +23297,23 @@ function TablesHome({ onOpenTable, organizationName, makingOnly = false, askedBy
23030
23297
  const livesIn = organizationName || askedName;
23031
23298
  const isMine = (t) => Boolean(me) && laneFor(t) !== "system" && laneFor(t) !== "app" && t.created_by === me;
23032
23299
  const sectionsKnown = facts.phase !== "failed";
23033
- const [creating, setCreating] = useState69(false);
23034
- const [name, setName] = useState69("");
23035
- const [busy, setBusy] = useState69(false);
23036
- const [error, setError] = useState69(null);
23037
- const [importInto, setImportInto] = useState69(null);
23038
- const [examples, setExamples] = useState69(false);
23300
+ const [creating, setCreating] = useState70(false);
23301
+ const [name, setName] = useState70("");
23302
+ const [busy, setBusy] = useState70(false);
23303
+ const [error, setError] = useState70(null);
23304
+ const [importInto, setImportInto] = useState70(null);
23305
+ const [examples, setExamples] = useState70(false);
23039
23306
  const createAsked = askedBy?.create ?? 0;
23040
23307
  const examplesAsked = askedBy?.examples ?? 0;
23041
- useEffect58(() => {
23308
+ useEffect59(() => {
23042
23309
  if (createAsked > 0) setCreating(true);
23043
23310
  }, [createAsked]);
23044
- useEffect58(() => {
23311
+ useEffect59(() => {
23045
23312
  if (examplesAsked > 0) setExamples(true);
23046
23313
  }, [examplesAsked]);
23047
23314
  const hostButtons = askedBy !== void 0;
23048
- const [boards, setBoards] = useState69(null);
23049
- useEffect58(() => {
23315
+ const [boards, setBoards] = useState70(null);
23316
+ useEffect59(() => {
23050
23317
  if (makingOnly) return;
23051
23318
  let cancelled = false;
23052
23319
  void client.dashboards({}).then((result) => {
@@ -23225,21 +23492,21 @@ function TablesHome({ onOpenTable, organizationName, makingOnly = false, askedBy
23225
23492
  import { Fragment as Fragment33, jsx as jsx80, jsxs as jsxs72 } from "react/jsx-runtime";
23226
23493
  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.";
23227
23494
  function PortalBuilder({ tableId, portalId, onSaved, onClose, className }) {
23228
- const client = useRecordsClient51();
23495
+ const client = useRecordsClient52();
23229
23496
  const tables = useTables4();
23230
- const [title, setTitle] = useState70("");
23231
- const [clientTableId, setClientTableId] = useState70(null);
23232
- const [exposures, setExposures] = useState70({});
23233
- const [fieldsByTable, setFieldsByTable] = useState70({});
23234
- const [error, setError] = useState70(null);
23235
- const [saving, setSaving] = useState70(false);
23236
- const [savedId, setSavedId] = useState70(portalId ?? null);
23237
- const [existing, setExisting] = useState70(null);
23238
- const [loading, setLoading] = useState70(Boolean(portalId));
23239
- const [inviteEmail, setInviteEmail] = useState70("");
23240
- const [inviteRecordId, setInviteRecordId] = useState70("");
23241
- const [inviting, setInviting] = useState70(false);
23242
- const [invitationSaid, setInvitationSaid] = useState70(null);
23497
+ const [title, setTitle] = useState71("");
23498
+ const [clientTableId, setClientTableId] = useState71(null);
23499
+ const [exposures, setExposures] = useState71({});
23500
+ const [fieldsByTable, setFieldsByTable] = useState71({});
23501
+ const [error, setError] = useState71(null);
23502
+ const [saving, setSaving] = useState71(false);
23503
+ const [savedId, setSavedId] = useState71(portalId ?? null);
23504
+ const [existing, setExisting] = useState71(null);
23505
+ const [loading, setLoading] = useState71(Boolean(portalId));
23506
+ const [inviteEmail, setInviteEmail] = useState71("");
23507
+ const [inviteRecordId, setInviteRecordId] = useState71("");
23508
+ const [inviting, setInviting] = useState71(false);
23509
+ const [invitationSaid, setInvitationSaid] = useState71(null);
23243
23510
  const loadFields = useCallback34(
23244
23511
  async (id) => {
23245
23512
  if (fieldsByTable[id]) return;
@@ -23252,7 +23519,7 @@ function PortalBuilder({ tableId, portalId, onSaved, onClose, className }) {
23252
23519
  },
23253
23520
  [client, fieldsByTable]
23254
23521
  );
23255
- useEffect59(() => {
23522
+ useEffect60(() => {
23256
23523
  if (!portalId) return;
23257
23524
  void (async () => {
23258
23525
  const answered = await client.portalCard({ portal_id: portalId });
@@ -23266,7 +23533,7 @@ function PortalBuilder({ tableId, portalId, onSaved, onClose, className }) {
23266
23533
  setClientTableId(answered.data.client_table_id);
23267
23534
  })();
23268
23535
  }, [client, portalId]);
23269
- useEffect59(() => {
23536
+ useEffect60(() => {
23270
23537
  if (!tableId) return;
23271
23538
  setExposures(
23272
23539
  (prev) => prev[tableId] ? prev : {
@@ -23279,7 +23546,7 @@ function PortalBuilder({ tableId, portalId, onSaved, onClose, className }) {
23279
23546
  const cameFromPeople = Boolean(
23280
23547
  tableId && (fieldsByTable[tableId] ?? []).some((f) => editorKindFor(f) === "email")
23281
23548
  );
23282
- useEffect59(() => {
23549
+ useEffect60(() => {
23283
23550
  if (!tableId || portalId || clientTableId !== null || !cameFromPeople) return;
23284
23551
  setClientTableId(tableId);
23285
23552
  setExposures((prev) => {
@@ -23287,7 +23554,7 @@ function PortalBuilder({ tableId, portalId, onSaved, onClose, className }) {
23287
23554
  return rest;
23288
23555
  });
23289
23556
  }, [tableId, portalId, clientTableId, cameFromPeople]);
23290
- const ticked = useMemo37(() => Object.values(exposures).filter((e) => e.on), [exposures]);
23557
+ const ticked = useMemo38(() => Object.values(exposures).filter((e) => e.on), [exposures]);
23291
23558
  const tiesTo = useCallback34(
23292
23559
  (id) => (fieldsByTable[id] ?? []).filter(
23293
23560
  (f) => f.type === "relation" && f.relation_target === clientTableId
@@ -23527,8 +23794,8 @@ function PortalBuilder({ tableId, portalId, onSaved, onClose, className }) {
23527
23794
  }
23528
23795
 
23529
23796
  // src/PortalsPanel.tsx
23530
- import { useCallback as useCallback35, useEffect as useEffect61, useMemo as useMemo39, useState as useState72 } from "react";
23531
- import { useRecordsClient as useRecordsClient53 } from "@ai-matrx/records/react";
23797
+ import { useCallback as useCallback35, useEffect as useEffect62, useMemo as useMemo40, useState as useState73 } from "react";
23798
+ import { useRecordsClient as useRecordsClient54 } from "@ai-matrx/records/react";
23532
23799
  import {
23533
23800
  portalArchiveConsequence,
23534
23801
  portalConfirmLine as portalConfirmLine2,
@@ -23538,8 +23805,8 @@ import {
23538
23805
  import { Badge as Badge20, BasicInput as BasicInput23, Button as Button62, Separator as Separator10, Skeleton as Skeleton21, cn as cn50 } from "@ai-matrx/design-system";
23539
23806
 
23540
23807
  // src/PortalLookEditor.tsx
23541
- import { useEffect as useEffect60, useMemo as useMemo38, useState as useState71 } from "react";
23542
- import { useRecordsClient as useRecordsClient52 } from "@ai-matrx/records/react";
23808
+ import { useEffect as useEffect61, useMemo as useMemo39, useState as useState72 } from "react";
23809
+ import { useRecordsClient as useRecordsClient53 } from "@ai-matrx/records/react";
23543
23810
  import { BasicInput as BasicInput22, Button as Button61, cn as cn49 } from "@ai-matrx/design-system";
23544
23811
  import { STYLE_COLOR_LABELS as STYLE_COLOR_LABELS3, SWATCH_CLASS as SWATCH_CLASS2 } from "@ai-matrx/design-system/data-table";
23545
23812
  import { jsx as jsx81, jsxs as jsxs73 } from "react/jsx-runtime";
@@ -23567,20 +23834,20 @@ function candidateRows(card, available) {
23567
23834
  return rows;
23568
23835
  }
23569
23836
  function PortalLookEditor({ card, onSaved, className }) {
23570
- const client = useRecordsClient52();
23837
+ const client = useRecordsClient53();
23571
23838
  const stored = card.config?.style ?? {};
23572
- const [name, setName] = useState71(stored.display_name ?? "");
23573
- const [welcome, setWelcome] = useState71(stored.welcome ?? "");
23574
- const [logo, setLogo] = useState71(stored.logo_file_id ?? "");
23575
- const [accent, setAccent] = useState71(stored.accent ?? "");
23576
- const [links, setLinks] = useState71(stored.footer_links ?? []);
23577
- const [forms, setForms] = useState71(null);
23578
- const [busy, setBusy] = useState71(false);
23579
- const [error, setError] = useState71(null);
23580
- const [said, setSaid] = useState71(null);
23581
- const [formsError, setFormsError] = useState71(null);
23582
- const [formsUnread, setFormsUnread] = useState71(false);
23583
- useEffect60(() => {
23839
+ const [name, setName] = useState72(stored.display_name ?? "");
23840
+ const [welcome, setWelcome] = useState72(stored.welcome ?? "");
23841
+ const [logo, setLogo] = useState72(stored.logo_file_id ?? "");
23842
+ const [accent, setAccent] = useState72(stored.accent ?? "");
23843
+ const [links, setLinks] = useState72(stored.footer_links ?? []);
23844
+ const [forms, setForms] = useState72(null);
23845
+ const [busy, setBusy] = useState72(false);
23846
+ const [error, setError] = useState72(null);
23847
+ const [said, setSaid] = useState72(null);
23848
+ const [formsError, setFormsError] = useState72(null);
23849
+ const [formsUnread, setFormsUnread] = useState72(false);
23850
+ useEffect61(() => {
23584
23851
  let cancelled = false;
23585
23852
  void (async () => {
23586
23853
  try {
@@ -23600,7 +23867,7 @@ function PortalLookEditor({ card, onSaved, className }) {
23600
23867
  cancelled = true;
23601
23868
  };
23602
23869
  }, [card, client]);
23603
- const orgName = useMemo38(
23870
+ const orgName = useMemo39(
23604
23871
  () => card.style.from_organization.includes("display_name") ? card.style.display_name : null,
23605
23872
  [card.style]
23606
23873
  );
@@ -23862,18 +24129,18 @@ function stateWords(person) {
23862
24129
  }
23863
24130
  var PORTAL_SUGGESTION = "Let each of my customers sign in and see their own jobs and invoices, and nothing else.";
23864
24131
  function PortalsPanel({ tableId, activePortalId, className }) {
23865
- const client = useRecordsClient53();
24132
+ const client = useRecordsClient54();
23866
24133
  const host = useRecordsUi();
23867
- const [portals, setPortals] = useState72(null);
23868
- const [exposures, setExposures] = useState72([]);
23869
- const [listError, setListError] = useState72(null);
23870
- const [openId, setOpenId] = useState72(activePortalId ?? null);
23871
- useEffect61(() => {
24134
+ const [portals, setPortals] = useState73(null);
24135
+ const [exposures, setExposures] = useState73([]);
24136
+ const [listError, setListError] = useState73(null);
24137
+ const [openId, setOpenId] = useState73(activePortalId ?? null);
24138
+ useEffect62(() => {
23872
24139
  if (activePortalId) setOpenId(activePortalId);
23873
24140
  }, [activePortalId]);
23874
- const [building, setBuilding] = useState72(false);
23875
- const [adding, setAdding] = useState72(null);
23876
- const [archiveToken, setArchiveToken] = useState72(0);
24141
+ const [building, setBuilding] = useState73(false);
24142
+ const [adding, setAdding] = useState73(null);
24143
+ const [archiveToken, setArchiveToken] = useState73(0);
23877
24144
  const load = useCallback35(async () => {
23878
24145
  const [answered, mapped] = await Promise.all([client.portals(), client.portalTables()]);
23879
24146
  if (!answered.ok) {
@@ -23886,7 +24153,7 @@ function PortalsPanel({ tableId, activePortalId, className }) {
23886
24153
  setPortals(answered.data);
23887
24154
  setExposures(mapped.ok ? mapped.data : []);
23888
24155
  }, [client]);
23889
- useEffect61(() => {
24156
+ useEffect62(() => {
23890
24157
  void load();
23891
24158
  }, [load]);
23892
24159
  if (portals === null) return /* @__PURE__ */ jsx82(Skeleton21, { className: cn50("h-32 w-full", className) });
@@ -24042,12 +24309,12 @@ function ArchivePortalControl({
24042
24309
  portal,
24043
24310
  onArchived
24044
24311
  }) {
24045
- const client = useRecordsClient53();
24046
- const [asking, setAsking] = useState72(false);
24047
- const [typed, setTyped] = useState72("");
24048
- const [busy, setBusy] = useState72(false);
24049
- const [error, setError] = useState72(null);
24050
- const [said, setSaid] = useState72(null);
24312
+ const client = useRecordsClient54();
24313
+ const [asking, setAsking] = useState73(false);
24314
+ const [typed, setTyped] = useState73("");
24315
+ const [busy, setBusy] = useState73(false);
24316
+ const [error, setError] = useState73(null);
24317
+ const [said, setSaid] = useState73(null);
24051
24318
  const go = async () => {
24052
24319
  setBusy(true);
24053
24320
  setError(null);
@@ -24114,8 +24381,8 @@ function ArchivePortalControl({
24114
24381
  ] });
24115
24382
  }
24116
24383
  function CopyLink({ url, what }) {
24117
- const [copied, setCopied] = useState72(false);
24118
- const [shown3, setShown] = useState72(false);
24384
+ const [copied, setCopied] = useState73(false);
24385
+ const [shown3, setShown] = useState73(false);
24119
24386
  return /* @__PURE__ */ jsxs74(Fragment34, { children: [
24120
24387
  /* @__PURE__ */ jsx82(
24121
24388
  Button62,
@@ -24149,9 +24416,9 @@ function PortalDetail({
24149
24416
  origin,
24150
24417
  onChanged
24151
24418
  }) {
24152
- const client = useRecordsClient53();
24153
- const [card, setCard] = useState72(null);
24154
- const [error, setError] = useState72(null);
24419
+ const client = useRecordsClient54();
24420
+ const [card, setCard] = useState73(null);
24421
+ const [error, setError] = useState73(null);
24155
24422
  const load = useCallback35(async () => {
24156
24423
  const answered = await client.portalCard({ portal_id: portalId });
24157
24424
  if (!answered.ok) {
@@ -24162,7 +24429,7 @@ function PortalDetail({
24162
24429
  setError(null);
24163
24430
  setCard(answered.data);
24164
24431
  }, [client, portalId]);
24165
- useEffect61(() => {
24432
+ useEffect62(() => {
24166
24433
  void load();
24167
24434
  }, [load]);
24168
24435
  const revoke = useCallback35(
@@ -24279,11 +24546,11 @@ function People({
24279
24546
  origin
24280
24547
  }) {
24281
24548
  const here = origin ?? (typeof window === "undefined" ? "" : window.location.origin);
24282
- const [askingToRevoke, setAskingToRevoke] = useState72(null);
24283
- const [busy, setBusy] = useState72(false);
24284
- const [said, setSaid] = useState72(null);
24285
- const [error, setError] = useState72(null);
24286
- const [previewing, setPreviewing] = useState72(null);
24549
+ const [askingToRevoke, setAskingToRevoke] = useState73(null);
24550
+ const [busy, setBusy] = useState73(false);
24551
+ const [said, setSaid] = useState73(null);
24552
+ const [error, setError] = useState73(null);
24553
+ const [previewing, setPreviewing] = useState73(null);
24287
24554
  const revoke = useCallback35(
24288
24555
  async (person) => {
24289
24556
  setBusy(true);
@@ -24367,10 +24634,10 @@ function Preview({
24367
24634
  onPreview
24368
24635
  }) {
24369
24636
  const first = card.tables[0];
24370
- const [which, setWhich] = useState72(first?.table_id ?? null);
24371
- const [rows, setRows] = useState72(null);
24372
- const [error, setError] = useState72(null);
24373
- useEffect61(() => {
24637
+ const [which, setWhich] = useState73(first?.table_id ?? null);
24638
+ const [rows, setRows] = useState73(null);
24639
+ const [error, setError] = useState73(null);
24640
+ useEffect62(() => {
24374
24641
  if (!which) return;
24375
24642
  let cancelled = false;
24376
24643
  setRows(null);
@@ -24407,16 +24674,16 @@ function Preview({
24407
24674
  ] });
24408
24675
  }
24409
24676
  function Invite({ card, onInvited }) {
24410
- const client = useRecordsClient53();
24411
- const [rows, setRows] = useState72(null);
24412
- const [clientTable, setClientTable] = useState72(null);
24413
- const [search, setSearch] = useState72("");
24414
- const [picked, setPicked] = useState72(null);
24415
- const [email, setEmail] = useState72("");
24416
- const [busy, setBusy] = useState72(false);
24417
- const [said, setSaid] = useState72(null);
24418
- const [error, setError] = useState72(null);
24419
- useEffect61(() => {
24677
+ const client = useRecordsClient54();
24678
+ const [rows, setRows] = useState73(null);
24679
+ const [clientTable, setClientTable] = useState73(null);
24680
+ const [search, setSearch] = useState73("");
24681
+ const [picked, setPicked] = useState73(null);
24682
+ const [email, setEmail] = useState73("");
24683
+ const [busy, setBusy] = useState73(false);
24684
+ const [said, setSaid] = useState73(null);
24685
+ const [error, setError] = useState73(null);
24686
+ useEffect62(() => {
24420
24687
  let cancelled = false;
24421
24688
  void client.list({ table_id: card.client_table_id, limit: 200 }).then((answered) => {
24422
24689
  if (cancelled) return;
@@ -24434,7 +24701,7 @@ function Invite({ card, onInvited }) {
24434
24701
  cancelled = true;
24435
24702
  };
24436
24703
  }, [client, card.client_table_id]);
24437
- const options = useMemo39(() => {
24704
+ const options = useMemo40(() => {
24438
24705
  const all = (rows ?? []).map((row) => ({ id: row.id, name: rowNameIn(clientTable, row) }));
24439
24706
  const needle = search.trim().toLowerCase();
24440
24707
  return needle === "" ? all.slice(0, 25) : all.filter((o) => o.name.toLowerCase().includes(needle)).slice(0, 25);
@@ -24518,8 +24785,8 @@ function Invite({ card, onInvited }) {
24518
24785
  }
24519
24786
 
24520
24787
  // src/DigestScheduler.tsx
24521
- import { useCallback as useCallback36, useEffect as useEffect62, useMemo as useMemo40, useState as useState73 } from "react";
24522
- import { useRecordsClient as useRecordsClient54, useTable as useTable16 } from "@ai-matrx/records/react";
24788
+ import { useCallback as useCallback36, useEffect as useEffect63, useMemo as useMemo41, useState as useState74 } from "react";
24789
+ import { useRecordsClient as useRecordsClient55, useTable as useTable16 } from "@ai-matrx/records/react";
24523
24790
  import { hasQuietHours } from "@ai-matrx/records";
24524
24791
  import { BasicInput as BasicInput24, Button as Button63, Checkbox as Checkbox10, Label as Label17, Separator as Separator11, Skeleton as Skeleton22, cn as cn51 } from "@ai-matrx/design-system";
24525
24792
 
@@ -24579,43 +24846,43 @@ function DigestScheduler({
24579
24846
  className,
24580
24847
  existing
24581
24848
  }) {
24582
- const client = useRecordsClient54();
24849
+ const client = useRecordsClient55();
24583
24850
  const host = useRecordsUi();
24584
- const [views, setViews] = useState73(null);
24585
- const [cadences, setCadences] = useState73([]);
24586
- const [members, setMembers] = useState73(null);
24587
- const [error, setError] = useState73(null);
24851
+ const [views, setViews] = useState74(null);
24852
+ const [cadences, setCadences] = useState74([]);
24853
+ const [members, setMembers] = useState74(null);
24854
+ const [error, setError] = useState74(null);
24588
24855
  const was = scheduleParts(existing?.schedule);
24589
- const [viewId, setViewId] = useState73(
24856
+ const [viewId, setViewId] = useState74(
24590
24857
  existing?.saved_view_id ?? savedViewId ?? ""
24591
24858
  );
24592
- const [name, setName] = useState73(
24859
+ const [name, setName] = useState74(
24593
24860
  existing?.name ?? (subjectName?.trim() ? `${subjectName.trim()} summary` : "")
24594
24861
  );
24595
- const [cadence, setCadence] = useState73(
24862
+ const [cadence, setCadence] = useState74(
24596
24863
  ["hourly", "daily", "weekly"].includes(existing?.cadence ?? "") ? existing.cadence : "weekly"
24597
24864
  );
24598
- const [weekday, setWeekday] = useState73(was.day ?? "monday");
24599
- const [time, setTime] = useState73(was.time ?? "08:00");
24600
- const [timezone, setTimezone] = useState73(() => {
24865
+ const [weekday, setWeekday] = useState74(was.day ?? "monday");
24866
+ const [time, setTime] = useState74(was.time ?? "08:00");
24867
+ const [timezone, setTimezone] = useState74(() => {
24601
24868
  const kept = existing?.quiet_hours?.tz?.trim();
24602
24869
  return kept && kept.toUpperCase() !== "UTC" ? kept : ownTimeZone();
24603
24870
  });
24604
24871
  const table = useTable16(tableId);
24605
24872
  const tableName2 = table.data?.name?.trim() || null;
24606
- const [channel, setChannel] = useState73(
24873
+ const [channel, setChannel] = useState74(
24607
24874
  existing?.channel === "email" || existing?.channel === "sms" ? existing.channel : "in_app"
24608
24875
  );
24609
- const [quiet, setQuiet] = useState73(hasQuietHours(existing?.quiet_hours));
24610
- const [quietFrom, setQuietFrom] = useState73(existing?.quiet_hours?.start ?? "22:00");
24611
- const [quietTo, setQuietTo] = useState73(existing?.quiet_hours?.end ?? "07:00");
24612
- const [recipients, setRecipients] = useState73(
24876
+ const [quiet, setQuiet] = useState74(hasQuietHours(existing?.quiet_hours));
24877
+ const [quietFrom, setQuietFrom] = useState74(existing?.quiet_hours?.start ?? "22:00");
24878
+ const [quietTo, setQuietTo] = useState74(existing?.quiet_hours?.end ?? "07:00");
24879
+ const [recipients, setRecipients] = useState74(
24613
24880
  existing?.recipient_user_id ? [existing.recipient_user_id] : []
24614
24881
  );
24615
- const [saving, setSaving] = useState73(false);
24616
- const [outcomes, setOutcomes] = useState73(null);
24617
- const [preview, setPreview] = useState73(null);
24618
- const [previewing, setPreviewing] = useState73(false);
24882
+ const [saving, setSaving] = useState74(false);
24883
+ const [outcomes, setOutcomes] = useState74(null);
24884
+ const [preview, setPreview] = useState74(null);
24885
+ const [previewing, setPreviewing] = useState74(false);
24619
24886
  const load = useCallback36(async () => {
24620
24887
  const [saved, offered] = await Promise.all([
24621
24888
  // The store's own door onto `platform.saved_view`, narrowed in SQL to
@@ -24635,15 +24902,15 @@ function DigestScheduler({
24635
24902
  setMembers([]);
24636
24903
  }
24637
24904
  }, [client, tableId, host]);
24638
- useEffect62(() => {
24905
+ useEffect63(() => {
24639
24906
  void load();
24640
24907
  }, [load]);
24641
- const schedule = useMemo40(() => {
24908
+ const schedule = useMemo41(() => {
24642
24909
  if (cadence === "weekly") return `${weekday} ${time}`;
24643
24910
  if (cadence === "daily") return time;
24644
24911
  return null;
24645
24912
  }, [cadence, weekday, time]);
24646
- const quietHours = useMemo40(
24913
+ const quietHours = useMemo41(
24647
24914
  () => quiet ? { start: quietFrom, end: quietTo, tz: timezone } : { tz: timezone },
24648
24915
  [quiet, quietFrom, quietTo, timezone]
24649
24916
  );
@@ -24890,14 +25157,14 @@ function DigestScheduler({
24890
25157
  }
24891
25158
 
24892
25159
  // src/SubscriptionsPanel.tsx
24893
- import { useCallback as useCallback38, useEffect as useEffect64, useState as useState75 } from "react";
24894
- import { useRecordsClient as useRecordsClient56 } from "@ai-matrx/records/react";
25160
+ import { useCallback as useCallback38, useEffect as useEffect65, useState as useState76 } from "react";
25161
+ import { useRecordsClient as useRecordsClient57 } from "@ai-matrx/records/react";
24895
25162
  import { hasQuietHours as hasQuietHours2 } from "@ai-matrx/records";
24896
25163
  import { Badge as Badge21, Button as Button65, Skeleton as Skeleton24, Switch as Switch2, cn as cn53 } from "@ai-matrx/design-system";
24897
25164
 
24898
25165
  // src/WebhooksPanel.tsx
24899
- import { useCallback as useCallback37, useEffect as useEffect63, useState as useState74 } from "react";
24900
- import { useRecordsClient as useRecordsClient55, useTable as useTable17 } from "@ai-matrx/records/react";
25166
+ import { useCallback as useCallback37, useEffect as useEffect64, useState as useState75 } from "react";
25167
+ import { useRecordsClient as useRecordsClient56, useTable as useTable17 } from "@ai-matrx/records/react";
24901
25168
  import { BasicInput as BasicInput25, Button as Button64, Checkbox as Checkbox11, ConfirmDialog as ConfirmDialog6, Label as Label18, Skeleton as Skeleton23, cn as cn52 } from "@ai-matrx/design-system";
24902
25169
  import { jsx as jsx84, jsxs as jsxs76 } from "react/jsx-runtime";
24903
25170
  var WEBHOOK_EVENT_LABEL = {
@@ -24917,19 +25184,19 @@ function health(hook) {
24917
25184
  return "Nothing has changed since it was set up, so nothing has been sent yet.";
24918
25185
  }
24919
25186
  function WebhooksPanel({ tableId, className }) {
24920
- const client = useRecordsClient55();
25187
+ const client = useRecordsClient56();
24921
25188
  const table = useTable17(tableId);
24922
25189
  const rights = useTableRights(table.data);
24923
- const [hooks, setHooks] = useState74(null);
24924
- const [error, setError] = useState74(null);
24925
- const [adding, setAdding] = useState74(false);
24926
- const [url, setUrl] = useState74("");
24927
- const [description, setDescription] = useState74("");
24928
- const [events, setEvents] = useState74(DEFAULT_EVENTS);
24929
- const [busy, setBusy] = useState74(false);
24930
- const [declared2, setDeclared] = useState74(null);
24931
- const [stopping, setStopping] = useState74(null);
24932
- const [readRefused, setReadRefused] = useState74(null);
25190
+ const [hooks, setHooks] = useState75(null);
25191
+ const [error, setError] = useState75(null);
25192
+ const [adding, setAdding] = useState75(false);
25193
+ const [url, setUrl] = useState75("");
25194
+ const [description, setDescription] = useState75("");
25195
+ const [events, setEvents] = useState75(DEFAULT_EVENTS);
25196
+ const [busy, setBusy] = useState75(false);
25197
+ const [declared2, setDeclared] = useState75(null);
25198
+ const [stopping, setStopping] = useState75(null);
25199
+ const [readRefused, setReadRefused] = useState75(null);
24933
25200
  const load = useCallback37(async () => {
24934
25201
  const answered = await client.tableWebhooks({ table_id: tableId });
24935
25202
  if (!answered.ok) {
@@ -24942,7 +25209,7 @@ function WebhooksPanel({ tableId, className }) {
24942
25209
  setError(null);
24943
25210
  setHooks(answered.data ?? []);
24944
25211
  }, [client, tableId]);
24945
- useEffect63(() => {
25212
+ useEffect64(() => {
24946
25213
  void load();
24947
25214
  }, [load]);
24948
25215
  const declare2 = async () => {
@@ -25112,13 +25379,13 @@ function nextSummaryAt(subscription, now) {
25112
25379
  var CHANNEL_WORDS2 = SUBSCRIPTION_CHANNEL_LABEL;
25113
25380
  var DIGEST_SUGGESTION = "Email me a summary of this every Monday at 8 in the morning.";
25114
25381
  function SubscriptionsPanel({ tableId, activeRuleId, className }) {
25115
- const client = useRecordsClient56();
25116
- const [rows, setRows] = useState75(null);
25117
- const [error, setError] = useState75(null);
25118
- const [busy, setBusy] = useState75(null);
25119
- const [preview, setPreview] = useState75(null);
25120
- const [scheduling, setScheduling] = useState75(false);
25121
- const [changing, setChanging] = useState75(null);
25382
+ const client = useRecordsClient57();
25383
+ const [rows, setRows] = useState76(null);
25384
+ const [error, setError] = useState76(null);
25385
+ const [busy, setBusy] = useState76(null);
25386
+ const [preview, setPreview] = useState76(null);
25387
+ const [scheduling, setScheduling] = useState76(false);
25388
+ const [changing, setChanging] = useState76(null);
25122
25389
  const host = useRecordsUi();
25123
25390
  const load = useCallback38(async () => {
25124
25391
  const answered = await client.subscriptions({ table_id: tableId });
@@ -25130,7 +25397,7 @@ function SubscriptionsPanel({ tableId, activeRuleId, className }) {
25130
25397
  setError(null);
25131
25398
  setRows(answered.data);
25132
25399
  }, [client, tableId]);
25133
- useEffect64(() => {
25400
+ useEffect65(() => {
25134
25401
  void load();
25135
25402
  }, [load]);
25136
25403
  const flip = useCallback38(
@@ -25319,8 +25586,8 @@ function SubscriptionsPanel({ tableId, activeRuleId, className }) {
25319
25586
  }
25320
25587
 
25321
25588
  // src/FormBuilder.tsx
25322
- import { useCallback as useCallback41, useEffect as useEffect67, useMemo as useMemo42, useState as useState78 } from "react";
25323
- import { useFields as useFields20, useRecordsClient as useRecordsClient58, useTable as useTable19 } from "@ai-matrx/records/react";
25589
+ import { useCallback as useCallback41, useEffect as useEffect68, useMemo as useMemo43, useState as useState79 } from "react";
25590
+ import { useFields as useFields20, useRecordsClient as useRecordsClient59, useTable as useTable19 } from "@ai-matrx/records/react";
25324
25591
  import { publicFormPath } from "@ai-matrx/records";
25325
25592
  import {
25326
25593
  BasicInput as BasicInput26,
@@ -25333,7 +25600,7 @@ import {
25333
25600
  } from "@ai-matrx/design-system";
25334
25601
 
25335
25602
  // src/FormRunner.tsx
25336
- import { useCallback as useCallback39, useEffect as useEffect65, useMemo as useMemo41, useRef as useRef24, useState as useState76 } from "react";
25603
+ import { useCallback as useCallback39, useEffect as useEffect66, useMemo as useMemo42, useRef as useRef24, useState as useState77 } from "react";
25337
25604
  import { useFields as useFields19, useOptionalRecordsClient as useOptionalRecordsClient8 } from "@ai-matrx/records/react";
25338
25605
  import { Button as Button66, Progress, Skeleton as Skeleton25, cn as cn54 } from "@ai-matrx/design-system";
25339
25606
  import { Fragment as Fragment36, jsx as jsx86, jsxs as jsxs78 } from "react/jsx-runtime";
@@ -25426,16 +25693,16 @@ function FormStage({
25426
25693
  connected = false
25427
25694
  }) {
25428
25695
  const host = useRecordsUi();
25429
- const [answers, setAnswers] = useState76(() => ({ ...initialAnswers ?? {} }));
25430
- const [at, setAt] = useState76(0);
25431
- const [error, setError] = useState76(null);
25432
- const [refusal2, setRefusal] = useState76(null);
25433
- const [writing, setWriting] = useState76(false);
25434
- const [done, setDone] = useState76(null);
25435
- const [hidden, setHidden] = useState76({});
25696
+ const [answers, setAnswers] = useState77(() => ({ ...initialAnswers ?? {} }));
25697
+ const [at, setAt] = useState77(0);
25698
+ const [error, setError] = useState77(null);
25699
+ const [refusal2, setRefusal] = useState77(null);
25700
+ const [writing, setWriting] = useState77(false);
25701
+ const [done, setDone] = useState77(null);
25702
+ const [hidden, setHidden] = useState77({});
25436
25703
  const decoy = useRef24("");
25437
25704
  const stage = useRef24(null);
25438
- const questions = useMemo41(() => {
25705
+ const questions = useMemo42(() => {
25439
25706
  const byKey = new Map((fields ?? []).map((f) => [f.key, f]));
25440
25707
  return (form.questions ?? []).map((q) => {
25441
25708
  const field2 = byKey.get(q.field) ?? null;
@@ -25449,7 +25716,7 @@ function FormStage({
25449
25716
  };
25450
25717
  });
25451
25718
  }, [fields, form.questions]);
25452
- useEffect65(() => {
25719
+ useEffect66(() => {
25453
25720
  if (!whichAsked) return;
25454
25721
  if (!questions.some((q) => q.showIf)) return;
25455
25722
  let cancelled = false;
@@ -25493,7 +25760,7 @@ function FormStage({
25493
25760
  }, [whichAsked, questions, answers]);
25494
25761
  const live = questions.filter((q) => !hidden[q.key]);
25495
25762
  const told = useRef24(answers);
25496
- useEffect65(() => {
25763
+ useEffect66(() => {
25497
25764
  if (told.current === answers) return;
25498
25765
  told.current = answers;
25499
25766
  onAnswersChange?.(answers);
@@ -25504,7 +25771,7 @@ function FormStage({
25504
25771
  return v === void 0 || v === null || v === "";
25505
25772
  })?.key ?? null : null
25506
25773
  );
25507
- useEffect65(() => {
25774
+ useEffect66(() => {
25508
25775
  const key = resumeAt.current;
25509
25776
  if (!key) return;
25510
25777
  const i = live.findIndex((q) => q.key === key);
@@ -25570,7 +25837,7 @@ function FormStage({
25570
25837
  if (event.shiftKey) retreat();
25571
25838
  else advance();
25572
25839
  }
25573
- useEffect65(() => {
25840
+ useEffect66(() => {
25574
25841
  const input = stage.current?.querySelector(
25575
25842
  "input:not([tabindex='-1']), textarea, select, [role='combobox']"
25576
25843
  );
@@ -25681,7 +25948,7 @@ function ThankYou({ form, done, className }) {
25681
25948
  const host = useRecordsUi();
25682
25949
  const redirect = form.thankYou?.redirectUrl?.trim() || null;
25683
25950
  const going = redirect !== null && done !== "preview";
25684
- useEffect65(() => {
25951
+ useEffect66(() => {
25685
25952
  if (!going || !redirect) return;
25686
25953
  const timer = window.setTimeout(() => window.location.assign(redirect), REDIRECT_AFTER_MS);
25687
25954
  return () => window.clearTimeout(timer);
@@ -25709,7 +25976,7 @@ function Question({
25709
25976
  upload
25710
25977
  }) {
25711
25978
  const host = useRecordsUi();
25712
- const [uploadError, setUploadError] = useState76(null);
25979
+ const [uploadError, setUploadError] = useState77(null);
25713
25980
  const field2 = question.field;
25714
25981
  if (!field2) return null;
25715
25982
  const id = `form-${field2.key}`;
@@ -25745,24 +26012,24 @@ function Question({
25745
26012
  }
25746
26013
 
25747
26014
  // src/NotifyRuleEditor.tsx
25748
- import { useCallback as useCallback40, useEffect as useEffect66, useState as useState77 } from "react";
25749
- import { useRecordsClient as useRecordsClient57, useTable as useTable18 } from "@ai-matrx/records/react";
26015
+ import { useCallback as useCallback40, useEffect as useEffect67, useState as useState78 } from "react";
26016
+ import { useRecordsClient as useRecordsClient58, useTable as useTable18 } from "@ai-matrx/records/react";
25750
26017
  import { hasQuietHours as hasQuietHours3 } from "@ai-matrx/records";
25751
26018
  import { Button as Button67, Skeleton as Skeleton26, cn as cn55 } from "@ai-matrx/design-system";
25752
26019
  import { jsx as jsx87, jsxs as jsxs79 } from "react/jsx-runtime";
25753
26020
  var CADENCE_WORDS2 = SUBSCRIPTION_CADENCE_LABEL;
25754
26021
  var CHANNEL_WORDS3 = SUBSCRIPTION_CHANNEL_LABEL;
25755
26022
  function NotifyRuleEditor({ tableId, seed, chosenRuleId, onChoose, className }) {
25756
- const client = useRecordsClient57();
26023
+ const client = useRecordsClient58();
25757
26024
  const host = useRecordsUi();
25758
26025
  const table = useTable18(tableId);
25759
26026
  const rights = useTableRights(table.data);
25760
- const [subscriptions, setSubscriptions] = useState77(null);
25761
- const [cadences, setCadences] = useState77([]);
25762
- const [views, setViews] = useState77(null);
25763
- const [error, setError] = useState77(null);
25764
- const [busy, setBusy] = useState77(false);
25765
- const [stopping, setStopping] = useState77(null);
26027
+ const [subscriptions, setSubscriptions] = useState78(null);
26028
+ const [cadences, setCadences] = useState78([]);
26029
+ const [views, setViews] = useState78(null);
26030
+ const [error, setError] = useState78(null);
26031
+ const [busy, setBusy] = useState78(false);
26032
+ const [stopping, setStopping] = useState78(null);
25766
26033
  const load = useCallback40(async () => {
25767
26034
  const [held, offered] = await Promise.all([
25768
26035
  // THE PERSON'S OWN DOOR, not the notifier's. It answers what is addressed
@@ -25791,7 +26058,7 @@ function NotifyRuleEditor({ tableId, seed, chosenRuleId, onChoose, className })
25791
26058
  }
25792
26059
  setViews(listed.data.map((v) => ({ id: v.view_id, name: v.name })));
25793
26060
  }, [client, host, tableId]);
25794
- useEffect66(() => {
26061
+ useEffect67(() => {
25795
26062
  void load();
25796
26063
  }, [load]);
25797
26064
  const write = useCallback40(
@@ -25819,7 +26086,7 @@ function NotifyRuleEditor({ tableId, seed, chosenRuleId, onChoose, className })
25819
26086
  },
25820
26087
  [client, tableId]
25821
26088
  );
25822
- useEffect66(() => {
26089
+ useEffect67(() => {
25823
26090
  if (!subscriptions || !seed || seed.length === 0) return;
25824
26091
  const missing = seed.filter((s) => !subscriptions.some((held) => held.name === s.name));
25825
26092
  if (missing.length === 0) return;
@@ -26002,23 +26269,23 @@ function NotifyRuleEditor({ tableId, seed, chosenRuleId, onChoose, className })
26002
26269
  // src/FormBuilder.tsx
26003
26270
  import { Fragment as Fragment37, jsx as jsx88, jsxs as jsxs80 } from "react/jsx-runtime";
26004
26271
  function FormBuilder({ tableId, seed, activeFormId, onActiveForm, startWithOne, className }) {
26005
- const client = useRecordsClient58();
26272
+ const client = useRecordsClient59();
26006
26273
  const publishGate = usePublishGate();
26007
26274
  const host = useRecordsUi();
26008
26275
  const claimSeed = useSeedGuard();
26009
26276
  const table = useTable19(tableId);
26010
26277
  const rights = useTableRights(table.data);
26011
26278
  const fields = useFields20(tableId);
26012
- const [forms, setForms] = useState78(null);
26013
- const [error, setError] = useState78(null);
26014
- const [refused, setRefused] = useState78(null);
26015
- const [activeId, setActiveId] = useState78(activeFormId ?? null);
26016
- const [draft, setDraft] = useState78(null);
26017
- const [saving, setSaving] = useState78(false);
26018
- const [saved, setSaved] = useState78(null);
26019
- const [publishing, setPublishing] = useState78(false);
26020
- const [copied, setCopied] = useState78(false);
26021
- const [shownUrl, setShownUrl] = useState78(null);
26279
+ const [forms, setForms] = useState79(null);
26280
+ const [error, setError] = useState79(null);
26281
+ const [refused, setRefused] = useState79(null);
26282
+ const [activeId, setActiveId] = useState79(activeFormId ?? null);
26283
+ const [draft, setDraft] = useState79(null);
26284
+ const [saving, setSaving] = useState79(false);
26285
+ const [saved, setSaved] = useState79(null);
26286
+ const [publishing, setPublishing] = useState79(false);
26287
+ const [copied, setCopied] = useState79(false);
26288
+ const [shownUrl, setShownUrl] = useState79(null);
26022
26289
  const publicOrigin = host.publicOrigin ?? (typeof window === "undefined" ? "" : window.location.origin);
26023
26290
  const load = useCallback41(async () => {
26024
26291
  const answered = await client.forms({ table_id: tableId });
@@ -26047,17 +26314,17 @@ function FormBuilder({ tableId, seed, activeFormId, onActiveForm, startWithOne,
26047
26314
  setError(null);
26048
26315
  setForms(mine);
26049
26316
  }, [client, tableId, seed, claimSeed]);
26050
- useEffect67(() => {
26317
+ useEffect68(() => {
26051
26318
  void load();
26052
26319
  }, [load]);
26053
- useEffect67(() => {
26320
+ useEffect68(() => {
26054
26321
  if (!forms || forms.length === 0) return;
26055
26322
  const chosen = forms.find((f) => f.id === (activeFormId ?? activeId)) ?? forms[0];
26056
26323
  if (chosen.id !== activeId) setActiveId(chosen.id);
26057
26324
  setDraft(chosen);
26058
26325
  onActiveForm?.(chosen);
26059
26326
  }, [forms, activeFormId]);
26060
- const byKey = useMemo42(() => new Map((fields.data ?? []).map((f) => [f.key, f])), [fields.data]);
26327
+ const byKey = useMemo43(() => new Map((fields.data ?? []).map((f) => [f.key, f])), [fields.data]);
26061
26328
  function patch(change) {
26062
26329
  setDraft((prev) => prev ? { ...prev, ...change } : prev);
26063
26330
  setSaved(null);
@@ -26134,8 +26401,8 @@ function FormBuilder({ tableId, seed, activeFormId, onActiveForm, startWithOne,
26134
26401
  setActiveId(written.data);
26135
26402
  await load();
26136
26403
  }
26137
- const [started, setStarted] = useState78(false);
26138
- useEffect67(() => {
26404
+ const [started, setStarted] = useState79(false);
26405
+ useEffect68(() => {
26139
26406
  if (!startWithOne || started || forms === null || forms.length > 0) return;
26140
26407
  if (askableFields(fields.data ?? []).length === 0) return;
26141
26408
  if (!table.data && !table.error) return;
@@ -26618,7 +26885,7 @@ function positionBucket(windowFrom, grain, weekStart, position) {
26618
26885
  else d.setUTCFullYear(d.getUTCFullYear() + position, 0, 1);
26619
26886
  return `${d.getUTCFullYear()}-${String(d.getUTCMonth() + 1).padStart(2, "0")}-${String(d.getUTCDate()).padStart(2, "0")}T${m[4]}${m[5]}`;
26620
26887
  }
26621
- function bucketWindow(groupKey, value) {
26888
+ function bucketWindow2(groupKey, value) {
26622
26889
  const grain = BUCKET_SUFFIX.exec(groupKey)?.[1];
26623
26890
  const m = /^(\d{4})-(\d{2})-(\d{2})T(\d{2}:\d{2}:\d{2})(.*)$/.exec(value);
26624
26891
  if (!grain || !m) return null;
@@ -26635,17 +26902,17 @@ function bucketWindow(groupKey, value) {
26635
26902
 
26636
26903
  // src/chartFrame.tsx
26637
26904
  import {
26638
- useEffect as useEffect68,
26905
+ useEffect as useEffect69,
26639
26906
  useId as useId3,
26640
26907
  useRef as useRef25,
26641
- useState as useState79
26908
+ useState as useState80
26642
26909
  } from "react";
26643
26910
  import { cn as cn57 } from "@ai-matrx/design-system";
26644
26911
  import { jsx as jsx89, jsxs as jsxs81 } from "react/jsx-runtime";
26645
26912
  function useMeasuredWidth(fallback = 480) {
26646
26913
  const ref = useRef25(null);
26647
- const [width, setWidth] = useState79(fallback);
26648
- useEffect68(() => {
26914
+ const [width, setWidth] = useState80(fallback);
26915
+ useEffect69(() => {
26649
26916
  const node = ref.current;
26650
26917
  if (!node) return;
26651
26918
  const apply = () => {
@@ -26769,23 +27036,23 @@ function isSignatureField(field2) {
26769
27036
  }
26770
27037
 
26771
27038
  // src/DocTemplate.tsx
26772
- import { useCallback as useCallback42, useEffect as useEffect69, useState as useState80 } from "react";
26773
- import { useFields as useFields21, useRecordsClient as useRecordsClient59, useTable as useTable20 } from "@ai-matrx/records/react";
27039
+ import { useCallback as useCallback42, useEffect as useEffect70, useState as useState81 } from "react";
27040
+ import { useFields as useFields21, useRecordsClient as useRecordsClient60, useTable as useTable20 } from "@ai-matrx/records/react";
26774
27041
  import { BasicInput as BasicInput27, BasicTextarea as BasicTextarea12, Button as Button69, Label as Label20, Skeleton as Skeleton28, cn as cn58 } from "@ai-matrx/design-system";
26775
27042
  import { jsx as jsx90, jsxs as jsxs82 } from "react/jsx-runtime";
26776
27043
  function DocTemplate({ tableId, seed, activeTemplateId, onActiveTemplate, className }) {
26777
- const client = useRecordsClient59();
27044
+ const client = useRecordsClient60();
26778
27045
  const claimSeed = useSeedGuard();
26779
27046
  const table = useTable20(tableId);
26780
27047
  const rights = useTableRights(table.data);
26781
27048
  const fields = useFields21(tableId);
26782
- const [templates, setTemplates] = useState80(null);
26783
- const [error, setError] = useState80(null);
26784
- const [activeId, setActiveId] = useState80(activeTemplateId ?? null);
26785
- const [draftName, setDraftName] = useState80("");
26786
- const [draftBody, setDraftBody] = useState80("");
26787
- const [unresolved, setUnresolved] = useState80([]);
26788
- const [saving, setSaving] = useState80(false);
27049
+ const [templates, setTemplates] = useState81(null);
27050
+ const [error, setError] = useState81(null);
27051
+ const [activeId, setActiveId] = useState81(activeTemplateId ?? null);
27052
+ const [draftName, setDraftName] = useState81("");
27053
+ const [draftBody, setDraftBody] = useState81("");
27054
+ const [unresolved, setUnresolved] = useState81([]);
27055
+ const [saving, setSaving] = useState81(false);
26789
27056
  const load = useCallback42(async () => {
26790
27057
  const held = await client.docTemplates({ table_id: tableId });
26791
27058
  if (!held.ok) {
@@ -26817,10 +27084,10 @@ function DocTemplate({ tableId, seed, activeTemplateId, onActiveTemplate, classN
26817
27084
  setError(null);
26818
27085
  setTemplates(rows);
26819
27086
  }, [client, tableId, seed, fields.data]);
26820
- useEffect69(() => {
27087
+ useEffect70(() => {
26821
27088
  void load();
26822
27089
  }, [load]);
26823
- useEffect69(() => {
27090
+ useEffect70(() => {
26824
27091
  if (!templates || templates.length === 0) return;
26825
27092
  const chosen = templates.find((t) => t.id === (activeTemplateId ?? activeId)) ?? templates[0];
26826
27093
  if (chosen.id !== activeId) setActiveId(chosen.id);
@@ -26828,7 +27095,7 @@ function DocTemplate({ tableId, seed, activeTemplateId, onActiveTemplate, classN
26828
27095
  setDraftBody(chosen.body);
26829
27096
  onActiveTemplate?.(chosen);
26830
27097
  }, [templates, activeTemplateId]);
26831
- useEffect69(() => {
27098
+ useEffect70(() => {
26832
27099
  let cancelled = false;
26833
27100
  if (draftBody.trim() === "") {
26834
27101
  setUnresolved([]);
@@ -26953,17 +27220,17 @@ function DocTemplate({ tableId, seed, activeTemplateId, onActiveTemplate, classN
26953
27220
  }
26954
27221
 
26955
27222
  // src/DocRender.tsx
26956
- import { useCallback as useCallback43, useEffect as useEffect70, useRef as useRef26, useState as useState81 } from "react";
26957
- import { useRecordsClient as useRecordsClient60 } from "@ai-matrx/records/react";
27223
+ import { useCallback as useCallback43, useEffect as useEffect71, useRef as useRef26, useState as useState82 } from "react";
27224
+ import { useRecordsClient as useRecordsClient61 } from "@ai-matrx/records/react";
26958
27225
  import { Button as Button70, Skeleton as Skeleton29, cn as cn59 } from "@ai-matrx/design-system";
26959
27226
  import { jsx as jsx91, jsxs as jsxs83 } from "react/jsx-runtime";
26960
27227
  function DocRender({ templateId, recordId, filename, onRendered, className }) {
26961
- const client = useRecordsClient60();
26962
- const [preview, setPreview] = useState81(null);
26963
- const [renders, setRenders] = useState81(null);
26964
- const [showing, setShowing] = useState81(null);
26965
- const [error, setError] = useState81(null);
26966
- const [busy, setBusy] = useState81(null);
27228
+ const client = useRecordsClient61();
27229
+ const [preview, setPreview] = useState82(null);
27230
+ const [renders, setRenders] = useState82(null);
27231
+ const [showing, setShowing] = useState82(null);
27232
+ const [error, setError] = useState82(null);
27233
+ const [busy, setBusy] = useState82(null);
26967
27234
  const paper = useRef26(null);
26968
27235
  const load = useCallback43(async () => {
26969
27236
  const [body, held] = await Promise.all([
@@ -26982,7 +27249,7 @@ function DocRender({ templateId, recordId, filename, onRendered, className }) {
26982
27249
  setPreview(body.data);
26983
27250
  setRenders(held.data.filter((r) => r.template_id === templateId));
26984
27251
  }, [client, templateId, recordId]);
26985
- useEffect70(() => {
27252
+ useEffect71(() => {
26986
27253
  void load();
26987
27254
  }, [load]);
26988
27255
  async function freeze() {
@@ -27066,21 +27333,21 @@ function DocRender({ templateId, recordId, filename, onRendered, className }) {
27066
27333
  }
27067
27334
 
27068
27335
  // src/SignBlock.tsx
27069
- import { useCallback as useCallback44, useEffect as useEffect71, useState as useState82 } from "react";
27070
- import { useFields as useFields22, useRecordsClient as useRecordsClient61 } from "@ai-matrx/records/react";
27336
+ import { useCallback as useCallback44, useEffect as useEffect72, useState as useState83 } from "react";
27337
+ import { useFields as useFields22, useRecordsClient as useRecordsClient62 } from "@ai-matrx/records/react";
27071
27338
  import { BasicInput as BasicInput28, Button as Button71, Skeleton as Skeleton30, cn as cn60 } from "@ai-matrx/design-system";
27072
27339
  import { useTable as useTable21 } from "@ai-matrx/records/react";
27073
27340
  import { jsx as jsx92, jsxs as jsxs84 } from "react/jsx-runtime";
27074
27341
  function SignBlock({ tableId, recordId, render, className }) {
27075
- const client = useRecordsClient61();
27342
+ const client = useRecordsClient62();
27076
27343
  const table = useTable21(tableId);
27077
27344
  const rights = useTableRights(table.data);
27078
27345
  const fields = useFields22(tableId);
27079
- const [signatures, setSignatures] = useState82(null);
27080
- const [verdicts, setVerdicts] = useState82({});
27081
- const [error, setError] = useState82(null);
27082
- const [name, setName] = useState82("");
27083
- const [busy, setBusy] = useState82(false);
27346
+ const [signatures, setSignatures] = useState83(null);
27347
+ const [verdicts, setVerdicts] = useState83({});
27348
+ const [error, setError] = useState83(null);
27349
+ const [name, setName] = useState83("");
27350
+ const [busy, setBusy] = useState83(false);
27084
27351
  const load = useCallback44(async () => {
27085
27352
  const held = await client.docSignatures({ record_id: recordId });
27086
27353
  if (!held.ok) {
@@ -27096,7 +27363,7 @@ function SignBlock({ tableId, recordId, render, className }) {
27096
27363
  }
27097
27364
  setVerdicts(answers);
27098
27365
  }, [client, recordId]);
27099
- useEffect71(() => {
27366
+ useEffect72(() => {
27100
27367
  void load();
27101
27368
  }, [load]);
27102
27369
  async function sign(field2) {
@@ -27217,7 +27484,7 @@ function SignBlock({ tableId, recordId, render, className }) {
27217
27484
  }
27218
27485
 
27219
27486
  // src/ChartBlock.tsx
27220
- import { useMemo as useMemo43 } from "react";
27487
+ import { useMemo as useMemo44 } from "react";
27221
27488
  import {
27222
27489
  Bar,
27223
27490
  BarChart,
@@ -27312,7 +27579,7 @@ function ChartBlock({ block, subject, className }) {
27312
27579
  const grain = block.bucket?.by ?? null;
27313
27580
  const series = compared ? [primary, priorKey(primary)] : [primary];
27314
27581
  const target = kind === "stuck" ? null : block.target ?? null;
27315
- const points = useMemo43(() => {
27582
+ const points = useMemo44(() => {
27316
27583
  if (kind === "stuck") return [];
27317
27584
  const rows = block.rows ?? [];
27318
27585
  return rows.map((row, index) => {
@@ -27336,7 +27603,7 @@ function ChartBlock({ block, subject, className }) {
27336
27603
  };
27337
27604
  });
27338
27605
  }, [block.rows, kind, primary, compared, grain, windows]);
27339
- const config = useMemo43(() => {
27606
+ const config = useMemo44(() => {
27340
27607
  const out = {};
27341
27608
  out[primary] = {
27342
27609
  label: windows ? windowName(windows.window, windows.period) : primary.replace("_", " of "),
@@ -27363,7 +27630,7 @@ function ChartBlock({ block, subject, className }) {
27363
27630
  const filter = { ...block.filter ?? {} };
27364
27631
  if (windows) filter[windows.key] = { from: windows.window.from, to: windows.window.to };
27365
27632
  for (const [key, value] of Object.entries(point.groups)) {
27366
- const asWindow = typeof value === "string" ? bucketWindow(key, value) : null;
27633
+ const asWindow = typeof value === "string" ? bucketWindow2(key, value) : null;
27367
27634
  if (asWindow) filter[asWindow.key] = asWindow.window;
27368
27635
  else filter[key] = value;
27369
27636
  }
@@ -27669,8 +27936,8 @@ function onlyWholeNumbers(rows) {
27669
27936
  }
27670
27937
 
27671
27938
  // src/DashboardCanvas.tsx
27672
- import { useCallback as useCallback45, useEffect as useEffect72, useMemo as useMemo44, useState as useState83 } from "react";
27673
- import { useFields as useFields23, useRecordsClient as useRecordsClient62, useTable as useTable22 } from "@ai-matrx/records/react";
27939
+ import { useCallback as useCallback45, useEffect as useEffect73, useMemo as useMemo45, useState as useState84 } from "react";
27940
+ import { useFields as useFields23, useRecordsClient as useRecordsClient63, useTable as useTable22 } from "@ai-matrx/records/react";
27674
27941
  import {
27675
27942
  BasicInput as BasicInput29,
27676
27943
  Button as Button72,
@@ -27684,21 +27951,21 @@ import {
27684
27951
  } from "@ai-matrx/design-system";
27685
27952
  import { Fragment as Fragment39, jsx as jsx94, jsxs as jsxs86 } from "react/jsx-runtime";
27686
27953
  function DashboardCanvas({ tableId, activeDashboardId, filter, className }) {
27687
- const client = useRecordsClient62();
27954
+ const client = useRecordsClient63();
27688
27955
  const host = useRecordsUi();
27689
27956
  const table = useTable22(tableId);
27690
27957
  const rights = useTableRights(table.data);
27691
27958
  const fields = useFields23(tableId);
27692
- const [boards, setBoards] = useState83(null);
27693
- const [error, setError] = useState83(null);
27694
- const [activeId, setActiveId] = useState83(activeDashboardId ?? null);
27695
- const [askingToRemove, setAskingToRemove] = useState83(null);
27696
- const [run, setRun] = useState83(null);
27697
- const [running, setRunning] = useState83(false);
27698
- const [question, setQuestion] = useState83("");
27699
- const [asking, setAsking] = useState83(false);
27700
- const [scheduling, setScheduling] = useState83(false);
27701
- const [grain, setGrain] = useState83(null);
27959
+ const [boards, setBoards] = useState84(null);
27960
+ const [error, setError] = useState84(null);
27961
+ const [activeId, setActiveId] = useState84(activeDashboardId ?? null);
27962
+ const [askingToRemove, setAskingToRemove] = useState84(null);
27963
+ const [run, setRun] = useState84(null);
27964
+ const [running, setRunning] = useState84(false);
27965
+ const [question, setQuestion] = useState84("");
27966
+ const [asking, setAsking] = useState84(false);
27967
+ const [scheduling, setScheduling] = useState84(false);
27968
+ const [grain, setGrain] = useState84(null);
27702
27969
  const runArgs = (dashboard_id) => ({
27703
27970
  dashboard_id,
27704
27971
  ...filter ? { filter } : {},
@@ -27715,18 +27982,18 @@ function DashboardCanvas({ tableId, activeDashboardId, filter, className }) {
27715
27982
  setBoards(read);
27716
27983
  return read;
27717
27984
  }, [client, tableId]);
27718
- const [notKept, setNotKept] = useState83(null);
27719
- useEffect72(() => {
27985
+ const [notKept, setNotKept] = useState84(null);
27986
+ useEffect73(() => {
27720
27987
  void load();
27721
27988
  }, [load]);
27722
- useEffect72(() => {
27989
+ useEffect73(() => {
27723
27990
  if (!boards || boards.length === 0) return;
27724
27991
  const chosen = boards.find((d) => d.id === (activeDashboardId ?? activeId)) ?? boards[0];
27725
27992
  if (chosen.id !== activeId) setActiveId(chosen.id);
27726
27993
  }, [boards, activeDashboardId]);
27727
- const board = useMemo44(() => boards?.find((d) => d.id === activeId) ?? null, [boards, activeId]);
27994
+ const board = useMemo45(() => boards?.find((d) => d.id === activeId) ?? null, [boards, activeId]);
27728
27995
  const filterKey = JSON.stringify(filter ?? {});
27729
- useEffect72(() => {
27996
+ useEffect73(() => {
27730
27997
  if (!activeId) {
27731
27998
  setRun(null);
27732
27999
  return;
@@ -28181,10 +28448,10 @@ function TargetControl({
28181
28448
  onChange
28182
28449
  }) {
28183
28450
  const saved = !block.target ? "none" : "field" in block.target && block.target.field ? "field" : "value";
28184
- const [mode, setMode] = useState83(saved);
28451
+ const [mode, setMode] = useState84(saved);
28185
28452
  const savedValue = block.target && "value" in block.target && typeof block.target.value === "number" ? block.target.value : null;
28186
- const [draft, setDraft] = useState83(savedValue === null ? "" : String(savedValue));
28187
- useEffect72(() => {
28453
+ const [draft, setDraft] = useState84(savedValue === null ? "" : String(savedValue));
28454
+ useEffect73(() => {
28188
28455
  setMode(saved);
28189
28456
  setDraft(savedValue === null ? "" : String(savedValue));
28190
28457
  }, [saved, savedValue]);
@@ -28251,8 +28518,8 @@ function TargetControl({
28251
28518
  }
28252
28519
 
28253
28520
  // src/FormsPanel.tsx
28254
- import { useCallback as useCallback46, useEffect as useEffect73, useState as useState84 } from "react";
28255
- import { useRecordsClient as useRecordsClient63, useTable as useTable23 } from "@ai-matrx/records/react";
28521
+ import { useCallback as useCallback46, useEffect as useEffect74, useState as useState85 } from "react";
28522
+ import { useRecordsClient as useRecordsClient64, useTable as useTable23 } from "@ai-matrx/records/react";
28256
28523
  import { publicFormPath as publicFormPath2 } from "@ai-matrx/records";
28257
28524
  import { Badge as Badge22, Button as Button73, Skeleton as Skeleton32, cn as cn63 } from "@ai-matrx/design-system";
28258
28525
  import { Fragment as Fragment40, jsx as jsx95, jsxs as jsxs87 } from "react/jsx-runtime";
@@ -28264,19 +28531,19 @@ function formSuggestion(tableName2) {
28264
28531
  return `Make me a form that collects new ${subject} entries and tells me when somebody answers.`;
28265
28532
  }
28266
28533
  function FormsPanel({ tableId, activeFormId, className }) {
28267
- const client = useRecordsClient63();
28534
+ const client = useRecordsClient64();
28268
28535
  const publishGate = usePublishGate();
28269
28536
  const host = useRecordsUi();
28270
28537
  const table = useTable23(tableId);
28271
28538
  const rights = useTableRights(table.data);
28272
- const [forms, setForms] = useState84(null);
28273
- const [error, setError] = useState84(null);
28274
- const [busy, setBusy] = useState84(null);
28275
- const [copied, setCopied] = useState84(null);
28276
- const [building, setBuilding] = useState84(false);
28539
+ const [forms, setForms] = useState85(null);
28540
+ const [error, setError] = useState85(null);
28541
+ const [busy, setBusy] = useState85(null);
28542
+ const [copied, setCopied] = useState85(null);
28543
+ const [building, setBuilding] = useState85(false);
28277
28544
  const linked = activeFormId && forms !== null ? forms.find((f) => f.form_id === activeFormId) ?? null : null;
28278
28545
  const linkedMissing = Boolean(activeFormId) && forms !== null && linked === null;
28279
- useEffect73(() => {
28546
+ useEffect74(() => {
28280
28547
  if (linked && rights.structure) setBuilding(true);
28281
28548
  }, [linked, rights.structure]);
28282
28549
  const load = useCallback46(async () => {
@@ -28289,7 +28556,7 @@ function FormsPanel({ tableId, activeFormId, className }) {
28289
28556
  setError(null);
28290
28557
  setForms(answered.data);
28291
28558
  }, [client, tableId]);
28292
- useEffect73(() => {
28559
+ useEffect74(() => {
28293
28560
  void load();
28294
28561
  }, [load]);
28295
28562
  const toggle = useCallback46(
@@ -28306,7 +28573,7 @@ function FormsPanel({ tableId, activeFormId, className }) {
28306
28573
  },
28307
28574
  [client, load]
28308
28575
  );
28309
- const [shown3, setShown] = useState84(null);
28576
+ const [shown3, setShown] = useState85(null);
28310
28577
  const copy = useCallback46(async (url, formId) => {
28311
28578
  try {
28312
28579
  await navigator.clipboard.writeText(url);
@@ -28421,18 +28688,18 @@ function FormsPanel({ tableId, activeFormId, className }) {
28421
28688
  }
28422
28689
 
28423
28690
  // src/CaptureSheet.tsx
28424
- import { useCallback as useCallback48, useEffect as useEffect75, useRef as useRef28, useState as useState86 } from "react";
28425
- import { useFields as useFields24, useRecordsClient as useRecordsClient65, useTable as useTable24 } from "@ai-matrx/records/react";
28691
+ import { useCallback as useCallback48, useEffect as useEffect76, useRef as useRef28, useState as useState87 } from "react";
28692
+ import { useFields as useFields24, useRecordsClient as useRecordsClient66, useTable as useTable24 } from "@ai-matrx/records/react";
28426
28693
  import { Button as Button75, Input as Input4, Skeleton as Skeleton34, Textarea as Textarea3, cn as cn65 } from "@ai-matrx/design-system";
28427
28694
 
28428
28695
  // src/CaptureRun.tsx
28429
- import { useCallback as useCallback47, useEffect as useEffect74, useMemo as useMemo45, useRef as useRef27, useState as useState85 } from "react";
28696
+ import { useCallback as useCallback47, useEffect as useEffect75, useMemo as useMemo46, useRef as useRef27, useState as useState86 } from "react";
28430
28697
  import {
28431
28698
  coerceTypedAnswer as coerceTypedAnswer3,
28432
28699
  coercionLabel,
28433
28700
  openCaptureQueue
28434
28701
  } from "@ai-matrx/records";
28435
- import { useRecordsClient as useRecordsClient64 } from "@ai-matrx/records/react";
28702
+ import { useRecordsClient as useRecordsClient65 } from "@ai-matrx/records/react";
28436
28703
  import { Button as Button74, Input as Input3, Skeleton as Skeleton33, Textarea as Textarea2, cn as cn64 } from "@ai-matrx/design-system";
28437
28704
  import { jsx as jsx96, jsxs as jsxs88 } from "react/jsx-runtime";
28438
28705
  function controlFor(field2) {
@@ -28471,21 +28738,21 @@ function whereWeAre(timeoutMs = 4e3) {
28471
28738
  });
28472
28739
  }
28473
28740
  function CaptureRun({ sheetId, face: given, className }) {
28474
- const client = useRecordsClient64();
28741
+ const client = useRecordsClient65();
28475
28742
  const host = useRecordsUi();
28476
- const [face, setFace] = useState85(given);
28477
- const [loadFailed, setLoadFailed] = useState85(null);
28478
- const [at, setAt] = useState85(0);
28479
- const [answers, setAnswers] = useState85({});
28480
- const [files, setFiles] = useState85({});
28481
- const [missing, setMissing] = useState85(null);
28482
- const [done, setDone] = useState85(null);
28483
- const [counts, setCounts] = useState85({ waiting: 0, sending: 0, refused: 0, landed: 0 });
28484
- const [items, setItems] = useState85([]);
28485
- const [lastSynced, setLastSynced] = useState85(null);
28486
- const [sending, setSending] = useState85(false);
28743
+ const [face, setFace] = useState86(given);
28744
+ const [loadFailed, setLoadFailed] = useState86(null);
28745
+ const [at, setAt] = useState86(0);
28746
+ const [answers, setAnswers] = useState86({});
28747
+ const [files, setFiles] = useState86({});
28748
+ const [missing, setMissing] = useState86(null);
28749
+ const [done, setDone] = useState86(null);
28750
+ const [counts, setCounts] = useState86({ waiting: 0, sending: 0, refused: 0, landed: 0 });
28751
+ const [items, setItems] = useState86([]);
28752
+ const [lastSynced, setLastSynced] = useState86(null);
28753
+ const [sending, setSending] = useState86(false);
28487
28754
  const queueRef = useRef27(null);
28488
- useEffect74(() => {
28755
+ useEffect75(() => {
28489
28756
  const q2 = openCaptureQueue({
28490
28757
  onChange: (c, all) => {
28491
28758
  setCounts(c);
@@ -28523,7 +28790,7 @@ function CaptureRun({ sheetId, face: given, className }) {
28523
28790
  void q2.sync().then(() => void q2.lastSyncedAt().then(setLastSynced));
28524
28791
  return () => q2.dispose();
28525
28792
  }, [client, host]);
28526
- useEffect74(() => {
28793
+ useEffect75(() => {
28527
28794
  if (given !== void 0) return;
28528
28795
  let cancelled = false;
28529
28796
  void client.captureOpen({ sheet_id: sheetId }).then((res) => {
@@ -28535,7 +28802,7 @@ function CaptureRun({ sheetId, face: given, className }) {
28535
28802
  cancelled = true;
28536
28803
  };
28537
28804
  }, [client, given, sheetId]);
28538
- const questions = useMemo45(() => {
28805
+ const questions = useMemo46(() => {
28539
28806
  const asked2 = face?.presentation?.questions ?? [];
28540
28807
  if (asked2.length > 0) return asked2;
28541
28808
  return (face?.fields ?? []).map((f) => ({
@@ -28851,19 +29118,19 @@ function AdHocCaptureSheet({
28851
29118
  attachmentField,
28852
29119
  className
28853
29120
  }) {
28854
- const client = useRecordsClient65();
29121
+ const client = useRecordsClient66();
28855
29122
  const host = useRecordsUi();
28856
29123
  const table = useTable24(tableId);
28857
29124
  const fields = useFields24(tableId);
28858
- const [mode, setMode] = useState86("reading");
28859
- const [reading, setReading] = useState86("");
28860
- const [note, setNote] = useState86("");
28861
- const [fileId, setFileId] = useState86(null);
28862
- const [pending, setPending] = useState86(null);
28863
- const [saved, setSaved] = useState86([]);
28864
- const [error, setError] = useState86(null);
28865
- const [uploadError, setUploadError] = useState86(null);
28866
- const [flushing, setFlushing] = useState86(false);
29125
+ const [mode, setMode] = useState87("reading");
29126
+ const [reading, setReading] = useState87("");
29127
+ const [note, setNote] = useState87("");
29128
+ const [fileId, setFileId] = useState87(null);
29129
+ const [pending, setPending] = useState87(null);
29130
+ const [saved, setSaved] = useState87([]);
29131
+ const [error, setError] = useState87(null);
29132
+ const [uploadError, setUploadError] = useState87(null);
29133
+ const [flushing, setFlushing] = useState87(false);
28867
29134
  const queue = useRef28([]);
28868
29135
  const keep = useCallback48(
28869
29136
  async (next) => {
@@ -28873,7 +29140,7 @@ function AdHocCaptureSheet({
28873
29140
  },
28874
29141
  [host]
28875
29142
  );
28876
- useEffect75(() => {
29143
+ useEffect76(() => {
28877
29144
  let cancelled = false;
28878
29145
  void (async () => {
28879
29146
  const held = host.captureQueue ? await host.captureQueue.load() : [];
@@ -29052,17 +29319,17 @@ function AdHocCaptureSheet({
29052
29319
  }
29053
29320
 
29054
29321
  // src/PortalShell.tsx
29055
- import { useCallback as useCallback49, useEffect as useEffect76, useState as useState87 } from "react";
29056
- import { useRecordsClient as useRecordsClient66 } from "@ai-matrx/records/react";
29322
+ import { useCallback as useCallback49, useEffect as useEffect77, useState as useState88 } from "react";
29323
+ import { useRecordsClient as useRecordsClient67 } from "@ai-matrx/records/react";
29057
29324
  import { Button as Button76, Skeleton as Skeleton35, cn as cn66 } from "@ai-matrx/design-system";
29058
29325
  import { jsx as jsx98, jsxs as jsxs90 } from "react/jsx-runtime";
29059
29326
  function PortalShell({ tableId, form, resourceType = "record", className }) {
29060
- const client = useRecordsClient66();
29061
- const [card, setCard] = useState87(null);
29062
- const [reach, setReach] = useState87(null);
29063
- const [error, setError] = useState87(null);
29064
- const [open, setOpen] = useState87(null);
29065
- const [sending, setSending] = useState87(false);
29327
+ const client = useRecordsClient67();
29328
+ const [card, setCard] = useState88(null);
29329
+ const [reach, setReach] = useState88(null);
29330
+ const [error, setError] = useState88(null);
29331
+ const [open, setOpen] = useState88(null);
29332
+ const [sending, setSending] = useState88(false);
29066
29333
  const load = useCallback49(async () => {
29067
29334
  const who = await client.externalPrincipalCard();
29068
29335
  if (!who.ok) {
@@ -29078,7 +29345,7 @@ function PortalShell({ tableId, form, resourceType = "record", className }) {
29078
29345
  }
29079
29346
  setReach(reached.data.map((row) => row.resource_id));
29080
29347
  }, [client, resourceType]);
29081
- useEffect76(() => {
29348
+ useEffect77(() => {
29082
29349
  void load();
29083
29350
  }, [load]);
29084
29351
  if (error) {
@@ -29136,9 +29403,9 @@ function PortalShell({ tableId, form, resourceType = "record", className }) {
29136
29403
  ] });
29137
29404
  }
29138
29405
  function PortalRow({ tableId, recordId }) {
29139
- const client = useRecordsClient66();
29140
- const [title, setTitle] = useState87(null);
29141
- useEffect76(() => {
29406
+ const client = useRecordsClient67();
29407
+ const [title, setTitle] = useState88(null);
29408
+ useEffect77(() => {
29142
29409
  let cancelled = false;
29143
29410
  void client.recordRead({ record_id: recordId }).then((answered) => {
29144
29411
  if (cancelled) return;
@@ -29158,17 +29425,17 @@ function PortalRow({ tableId, recordId }) {
29158
29425
  }
29159
29426
 
29160
29427
  // src/PublicViewPage.tsx
29161
- import { useCallback as useCallback50, useEffect as useEffect77, useState as useState88 } from "react";
29162
- import { useRecordsClient as useRecordsClient67 } from "@ai-matrx/records/react";
29428
+ import { useCallback as useCallback50, useEffect as useEffect78, useState as useState89 } from "react";
29429
+ import { useRecordsClient as useRecordsClient68 } from "@ai-matrx/records/react";
29163
29430
  import { Skeleton as Skeleton36, cn as cn67 } from "@ai-matrx/design-system";
29164
29431
  import { jsx as jsx99, jsxs as jsxs91 } from "react/jsx-runtime";
29165
29432
  function PublicViewPage({ slug, className }) {
29166
- const client = useRecordsClient67();
29167
- const [binding, setBinding] = useState88(null);
29168
- const [rows, setRows] = useState88(null);
29169
- const [fields, setFields] = useState88(null);
29170
- const [error, setError] = useState88(null);
29171
- const [gap, setGap] = useState88(null);
29433
+ const client = useRecordsClient68();
29434
+ const [binding, setBinding] = useState89(null);
29435
+ const [rows, setRows] = useState89(null);
29436
+ const [fields, setFields] = useState89(null);
29437
+ const [error, setError] = useState89(null);
29438
+ const [gap, setGap] = useState89(null);
29172
29439
  const load = useCallback50(async () => {
29173
29440
  const notice = await client.worldPublishGapNotice();
29174
29441
  if (notice.ok) setGap(notice.data);
@@ -29202,7 +29469,7 @@ function PublicViewPage({ slug, className }) {
29202
29469
  }
29203
29470
  setRows([{ id: found.resource_id, document: read.data.document, level: "viewer", hidden: read.data.hidden }]);
29204
29471
  }, [client, slug]);
29205
- useEffect77(() => {
29472
+ useEffect78(() => {
29206
29473
  void load();
29207
29474
  }, [load]);
29208
29475
  if (error) return /* @__PURE__ */ jsx99(RefusalNotice, { error, className });
@@ -29239,8 +29506,8 @@ function PublicRow({ row, fields }) {
29239
29506
  }
29240
29507
 
29241
29508
  // src/EmbedFrame.tsx
29242
- import { useCallback as useCallback51, useEffect as useEffect78, useState as useState89 } from "react";
29243
- import { useRecordsClient as useRecordsClient68 } from "@ai-matrx/records/react";
29509
+ import { useCallback as useCallback51, useEffect as useEffect79, useState as useState90 } from "react";
29510
+ import { useRecordsClient as useRecordsClient69 } from "@ai-matrx/records/react";
29244
29511
  import { Button as Button77, Input as Input5, Skeleton as Skeleton37, Textarea as Textarea4, cn as cn68 } from "@ai-matrx/design-system";
29245
29512
  import { useTable as useTable25 } from "@ai-matrx/records/react";
29246
29513
  import { Fragment as Fragment42, jsx as jsx100, jsxs as jsxs92 } from "react/jsx-runtime";
@@ -29252,15 +29519,15 @@ function EmbedFrame({
29252
29519
  embedUrl,
29253
29520
  className
29254
29521
  }) {
29255
- const client = useRecordsClient68();
29522
+ const client = useRecordsClient69();
29256
29523
  const host = useRecordsUi();
29257
29524
  const table = useTable25(tableId);
29258
29525
  const rights = useTableRights(table.data);
29259
- const [origins, setOrigins] = useState89("");
29260
- const [secret, setSecret] = useState89(null);
29261
- const [tokenId, setTokenId] = useState89(null);
29262
- const [error, setError] = useState89(null);
29263
- const [busy, setBusy] = useState89(false);
29526
+ const [origins, setOrigins] = useState90("");
29527
+ const [secret, setSecret] = useState90(null);
29528
+ const [tokenId, setTokenId] = useState90(null);
29529
+ const [error, setError] = useState90(null);
29530
+ const [busy, setBusy] = useState90(false);
29264
29531
  const mode = formId ? "write" : "read";
29265
29532
  const parsed = origins.split(/[\s,]+/).map((o) => o.trim()).filter((o) => o.length > 0);
29266
29533
  const issue = useCallback51(async () => {
@@ -29346,13 +29613,13 @@ function EmbedFrame({
29346
29613
  ] });
29347
29614
  }
29348
29615
  function useEmbedHandshake(args) {
29349
- const client = useRecordsClient68();
29350
- const [binding, setBinding] = useState89(null);
29351
- const [error, setError] = useState89(null);
29352
- const [loading, setLoading] = useState89(true);
29616
+ const client = useRecordsClient69();
29617
+ const [binding, setBinding] = useState90(null);
29618
+ const [error, setError] = useState90(null);
29619
+ const [loading, setLoading] = useState90(true);
29353
29620
  const origin = args.origin ?? (typeof location === "undefined" ? "" : location.origin);
29354
29621
  const { secret, requiredMode } = args;
29355
- useEffect78(() => {
29622
+ useEffect79(() => {
29356
29623
  let cancelled = false;
29357
29624
  setLoading(true);
29358
29625
  setError(null);
@@ -29424,9 +29691,9 @@ function recordsDataSource(client, fallbackSchema = "custom") {
29424
29691
  }
29425
29692
 
29426
29693
  // src/TablePage.tsx
29427
- import { useCallback as useCallback52, useEffect as useEffect81, useRef as useRef30, useState as useState92 } from "react";
29694
+ import { useCallback as useCallback52, useEffect as useEffect82, useRef as useRef30, useState as useState93 } from "react";
29428
29695
  import { archivedByLine as archivedByLine2 } from "@ai-matrx/records";
29429
- import { useFields as useFields26, useRecordsClient as useRecordsClient69, useTable as useTable26 } from "@ai-matrx/records/react";
29696
+ import { useFields as useFields26, useRecordsClient as useRecordsClient70, useTable as useTable26 } from "@ai-matrx/records/react";
29430
29697
  import {
29431
29698
  BottomSheet,
29432
29699
  Button as Button79,
@@ -29447,7 +29714,7 @@ import {
29447
29714
  } from "@ai-matrx/design-system";
29448
29715
 
29449
29716
  // src/ViewFilter.tsx
29450
- import { useEffect as useEffect79, useMemo as useMemo46, useState as useState90 } from "react";
29717
+ import { useEffect as useEffect80, useMemo as useMemo47, useState as useState91 } from "react";
29451
29718
  import { Button as Button78, cn as cn69 } from "@ai-matrx/design-system";
29452
29719
  import { useFields as useFields25 } from "@ai-matrx/records/react";
29453
29720
  import { jsx as jsx102, jsxs as jsxs93 } from "react/jsx-runtime";
@@ -29461,14 +29728,14 @@ function conditionCount(expr) {
29461
29728
  }
29462
29729
  function ViewFilter({ tableId, view, onApply, className }) {
29463
29730
  const fields = useFields25(tableId);
29464
- const [open, setOpen] = useState90(false);
29731
+ const [open, setOpen] = useState91(false);
29465
29732
  const saved = view?.where ?? null;
29466
- const [draft, setDraft] = useState90(saved);
29733
+ const [draft, setDraft] = useState91(saved);
29467
29734
  const savedKey = JSON.stringify(saved);
29468
- useEffect79(() => {
29735
+ useEffect80(() => {
29469
29736
  setDraft(saved);
29470
29737
  }, [view?.id, savedKey]);
29471
- const conditionFields = useMemo46(
29738
+ const conditionFields = useMemo47(
29472
29739
  () => (fields.data ?? []).map((f) => ({ id: f.id, key: f.key, label: f.label || f.key, field: f })),
29473
29740
  [fields.data]
29474
29741
  );
@@ -29548,7 +29815,7 @@ function ViewFilter({ tableId, view, onApply, className }) {
29548
29815
  }
29549
29816
 
29550
29817
  // src/toolbarFit.ts
29551
- import { useEffect as useEffect80, useState as useState91 } from "react";
29818
+ import { useEffect as useEffect81, useState as useState92 } from "react";
29552
29819
  var FOLDED_GUESS = { look: 104, chooser: 96, tools: 120 };
29553
29820
  function toolbarFold(input) {
29554
29821
  const { available, needsNow, gap, folded } = input;
@@ -29599,8 +29866,8 @@ function rowNeeds(row) {
29599
29866
  return { needs: needs + gap * Math.max(0, pieces.length - 1), gap };
29600
29867
  }
29601
29868
  function useToolbarFit(row) {
29602
- const [fold, setFold] = useState91(0);
29603
- useEffect80(() => {
29869
+ const [fold, setFold] = useState92(0);
29870
+ useEffect81(() => {
29604
29871
  if (!row) return;
29605
29872
  const widths = {
29606
29873
  look: { full: null, folded: null },
@@ -29680,8 +29947,8 @@ function clippedEnds(scrollLeft, clientWidth, scrollWidth) {
29680
29947
  return start && end ? "both" : start ? "start" : end ? "end" : "none";
29681
29948
  }
29682
29949
  function useSlotScroll(slot) {
29683
- const [ends, setEnds] = useState91("none");
29684
- useEffect80(() => {
29950
+ const [ends, setEnds] = useState92("none");
29951
+ useEffect81(() => {
29685
29952
  if (!slot) return;
29686
29953
  let pending = 0;
29687
29954
  const read = () => {
@@ -29797,11 +30064,11 @@ function TableNotHere({
29797
30064
  leaveLabel,
29798
30065
  className
29799
30066
  }) {
29800
- const client = useRecordsClient69();
29801
- const [archived, setArchived] = useState92({ phase: "asking" });
29802
- const [restoring, setRestoring] = useState92(false);
29803
- const [refusal2, setRefusal] = useState92(null);
29804
- useEffect81(() => {
30067
+ const client = useRecordsClient70();
30068
+ const [archived, setArchived] = useState93({ phase: "asking" });
30069
+ const [restoring, setRestoring] = useState93(false);
30070
+ const [refusal2, setRefusal] = useState93(null);
30071
+ useEffect82(() => {
29805
30072
  let alive = true;
29806
30073
  void client.tableArchived({ table_id: tableId }).then((answered) => {
29807
30074
  if (!alive) return;
@@ -29988,15 +30255,15 @@ function TablePage({
29988
30255
  onShownViewChange,
29989
30256
  className
29990
30257
  }) {
29991
- const client = useRecordsClient69();
30258
+ const client = useRecordsClient70();
29992
30259
  const table = useTable26(tableId);
29993
30260
  const rights = useTableRights(table.data);
29994
30261
  const pageFields = useFields26(filter ? tableId : null);
29995
30262
  const askedInWords = filter ? filterInWords(filter, pageFields.data ?? []) : null;
29996
- const organizationId = useRecordsClient69().config.organizationId;
29997
- const [view, setView] = useState92(null);
29998
- const [looks, setLooks] = useState92(void 0);
29999
- useEffect81(() => {
30263
+ const organizationId = useRecordsClient70().config.organizationId;
30264
+ const [view, setView] = useState93(null);
30265
+ const [looks, setLooks] = useState93(void 0);
30266
+ useEffect82(() => {
30000
30267
  let live = true;
30001
30268
  setLooks(void 0);
30002
30269
  void readLooks(client, tableId).then((answered) => {
@@ -30009,7 +30276,7 @@ function TablePage({
30009
30276
  }, [client, tableId]);
30010
30277
  const look = view && looks ? looks[view.id] : void 0;
30011
30278
  const shown3 = view ? applyLook(view, look) : null;
30012
- const [viewsEpoch, setViewsEpoch] = useState92(0);
30279
+ const [viewsEpoch, setViewsEpoch] = useState93(0);
30013
30280
  const opening = openingRail(activeRecordId, activeRail);
30014
30281
  const hostLayouts = useRecordsUi().layouts ?? [];
30015
30282
  const hostLayoutFor = (asked2) => openingHostLayout(asked2, hostLayouts);
@@ -30017,30 +30284,30 @@ function TablePage({
30017
30284
  const savedFromLink = savedViewFromParam(activeView);
30018
30285
  const openedByPackage = openingView(hostFromLink || savedFromLink ? null : activeView, activeDashboardId);
30019
30286
  const opened = hostFromLink ? { ...openedByPackage, main: "records" } : openedByPackage;
30020
- const [hostLayout, setHostLayout] = useState92(hostFromLink);
30021
- const [views, setViews] = useState92(void 0);
30022
- const [pickedViewId, setPickedViewId] = useState92(savedFromLink);
30287
+ const [hostLayout, setHostLayout] = useState93(hostFromLink);
30288
+ const [views, setViews] = useState93(void 0);
30289
+ const [pickedViewId, setPickedViewId] = useState93(savedFromLink);
30023
30290
  const viewSeen = useRef30(null);
30024
- const [viewLinkMissed, setViewLinkMissed] = useState92(false);
30025
- const [layoutChosen, setLayoutChosen] = useState92(false);
30291
+ const [viewLinkMissed, setViewLinkMissed] = useState93(false);
30292
+ const [layoutChosen, setLayoutChosen] = useState93(false);
30026
30293
  const railAsked = typeof activeRail === "string" ? activeRail.trim() : "";
30027
30294
  const railUnknown = railAsked !== "" && railFromParam(railAsked) === null ? railAsked : null;
30028
30295
  const shareFromLink = railFromParam(activeRail) === "share";
30029
30296
  const canShare = useCanShare();
30030
30297
  const itemFor = (which) => railFromParam(activeRail) === which ? activeItemId ?? null : null;
30031
- const [asking, setAsking] = useState92(null);
30032
- const [layoutFromLink, setLayoutFromLink] = useState92(opened.layout);
30033
- const [surface, setSurface] = useState92({
30298
+ const [asking, setAsking] = useState93(null);
30299
+ const [layoutFromLink, setLayoutFromLink] = useState93(opened.layout);
30300
+ const [surface, setSurface] = useState93({
30034
30301
  main: opened.main,
30035
30302
  rail: opening.rail
30036
30303
  });
30037
30304
  const { main, rail } = surface;
30038
30305
  const setRail = (next) => setSurface((now) => ({ ...now, rail: next }));
30039
- const [openRecord, setOpenRecord] = useState92(opening.record);
30306
+ const [openRecord, setOpenRecord] = useState93(opening.record);
30040
30307
  const phone = useIsMobile2();
30041
- const [shareAsked, setShareAsked] = useState92(0);
30042
- const [toolbarSlot, setToolbarSlot] = useState92(null);
30043
- const [toolbarRow, setToolbarRow] = useState92(null);
30308
+ const [shareAsked, setShareAsked] = useState93(0);
30309
+ const [toolbarSlot, setToolbarSlot] = useState93(null);
30310
+ const [toolbarRow, setToolbarRow] = useState93(null);
30044
30311
  const toolbarFold2 = useToolbarFit(toolbarRow);
30045
30312
  const slotClipped = useSlotScroll(toolbarSlot);
30046
30313
  const face = tableOpening(view, hostLayouts.map((h) => h.id));
@@ -30048,7 +30315,7 @@ function TablePage({
30048
30315
  const chooserInline = !designated && !phone && toolbarFold2 < 2;
30049
30316
  const chooserCompact = !designated && !phone && toolbarFold2 >= 2;
30050
30317
  const controlsInSheet = phone && !designated;
30051
- useEffect81(() => {
30318
+ useEffect82(() => {
30052
30319
  if (face.kind !== "designated") return;
30053
30320
  if (hostFromLink || opened.layout || layoutChosen) return;
30054
30321
  setHostLayout(face.hostLayout);
@@ -30081,7 +30348,7 @@ function TablePage({
30081
30348
  const shownSignature = JSON.stringify(shownReport);
30082
30349
  const reportRef = useRef30(onShownViewChange);
30083
30350
  reportRef.current = onShownViewChange;
30084
- useEffect81(() => {
30351
+ useEffect82(() => {
30085
30352
  reportRef.current?.(JSON.parse(shownSignature));
30086
30353
  }, [shownSignature]);
30087
30354
  const pickLayout = (next) => {
@@ -30099,18 +30366,18 @@ function TablePage({
30099
30366
  onViewChanged?.(id);
30100
30367
  };
30101
30368
  const openedFromMenu = MENU.find((entry) => entry.press.main !== void 0 && entry.press.main === main) ?? MENU.find((entry) => entry.press.rail !== void 0 && entry.press.rail === rail) ?? null;
30102
- useEffect81(() => {
30369
+ useEffect82(() => {
30103
30370
  if (!activeRecordId) return;
30104
30371
  setOpenRecord(activeRecordId);
30105
30372
  setSurface((now) => ({ ...now, rail: "record" }));
30106
30373
  }, [activeRecordId]);
30107
- useEffect81(() => {
30374
+ useEffect82(() => {
30108
30375
  if (activeRecordId) return;
30109
30376
  const named = railFromParam(activeRail);
30110
30377
  if (named === null || named === "share") return;
30111
30378
  setSurface((now) => ({ ...now, rail: named }));
30112
30379
  }, [activeRail, activeRecordId]);
30113
- useEffect81(() => {
30380
+ useEffect82(() => {
30114
30381
  const host = hostLayoutFor(activeView);
30115
30382
  if (host) {
30116
30383
  setHostLayout(host);
@@ -30124,7 +30391,7 @@ function TablePage({
30124
30391
  setLayoutFromLink(isLayout ? named : null);
30125
30392
  setSurface((now) => ({ ...now, main: isLayout ? "records" : named }));
30126
30393
  }, [activeView]);
30127
- const [viewSaveRefused, setViewSaveRefused] = useState92(null);
30394
+ const [viewSaveRefused, setViewSaveRefused] = useState93(null);
30128
30395
  const patchView = useCallback52(
30129
30396
  async (asked2) => {
30130
30397
  const current = view;
@@ -30142,9 +30409,9 @@ function TablePage({
30142
30409
  [client, tableId, view, looks]
30143
30410
  );
30144
30411
  const lookShowing = Boolean(view && looks && lookDiffers(view, looks[view.id]));
30145
- const [lookRefused, setLookRefused] = useState92(null);
30146
- const [namingLook, setNamingLook] = useState92(false);
30147
- const [lookName, setLookName] = useState92("");
30412
+ const [lookRefused, setLookRefused] = useState93(null);
30413
+ const [namingLook, setNamingLook] = useState93(false);
30414
+ const [lookName, setLookName] = useState93("");
30148
30415
  const resetLook = async () => {
30149
30416
  const current = view;
30150
30417
  if (!current) return;
@@ -30202,7 +30469,7 @@ function TablePage({
30202
30469
  setPickedViewId(written.data);
30203
30470
  setViewsEpoch((n) => n + 1);
30204
30471
  };
30205
- const [designateRefused, setDesignateRefused] = useState92(null);
30472
+ const [designateRefused, setDesignateRefused] = useState93(null);
30206
30473
  const opensAs = view?.isDefault ? openingLayoutOf(view) : null;
30207
30474
  const canDesignate = Boolean(rights.write && view && layoutShowing && layoutShowing !== opensAs);
30208
30475
  const layoutShowingLabel = layoutShowing ? hostLayouts.find((h) => h.id === layoutShowing)?.label ?? (VIEW_LAYOUTS.includes(layoutShowing) ? LAYOUT_LABEL[layoutShowing] : layoutShowing) : "";