@ai-matrx/records-ui 0.110.6 → 0.110.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -85,7 +85,7 @@ __export(src_exports, {
85
85
  DATA_BINDING_MISSING: () => DATA_BINDING_MISSING,
86
86
  DATA_BINDING_SHAPES: () => DATA_BINDING_SHAPES,
87
87
  DEFAULT_ACTION_ORIGIN: () => DEFAULT_ACTION_ORIGIN,
88
- DEFAULT_FIELDS: () => import_core2.DEFAULT_FIELDS,
88
+ DEFAULT_FIELDS: () => import_core3.DEFAULT_FIELDS,
89
89
  DEFAULT_FOOTER: () => DEFAULT_FOOTER,
90
90
  DEFAULT_VIEW_NAME: () => DEFAULT_VIEW_NAME,
91
91
  DUE_STATE_LABEL: () => DUE_STATE_LABEL,
@@ -308,7 +308,7 @@ __export(src_exports, {
308
308
  actorBadge: () => actorBadge,
309
309
  actorWords: () => actorWords,
310
310
  addDays: () => addDays,
311
- addFields: () => import_core2.addFields,
311
+ addFields: () => import_core3.addFields,
312
312
  announceTableArchived: () => announceTableArchived,
313
313
  applyLook: () => applyLook,
314
314
  archiveConfirmSentence: () => archiveConfirmSentence,
@@ -360,7 +360,7 @@ __export(src_exports, {
360
360
  dayAt: () => dayAt,
361
361
  dayKeyOf: () => dayKeyOf,
362
362
  daysBetween: () => daysBetween,
363
- declareTable: () => import_core2.declareTable,
363
+ declareTable: () => import_core3.declareTable,
364
364
  declareView: () => declareView,
365
365
  defaultBindingTemplate: () => defaultBindingTemplate,
366
366
  defaultViewOf: () => defaultViewOf,
@@ -391,7 +391,7 @@ __export(src_exports, {
391
391
  entityTitleColumn: () => entityTitleColumn,
392
392
  entityValueText: () => entityValueText,
393
393
  envelopeFor: () => envelopeFor,
394
- fieldDeclarationFor: () => import_core2.fieldDeclarationFor,
394
+ fieldDeclarationFor: () => import_core3.fieldDeclarationFor,
395
395
  fieldIsEditable: () => fieldIsEditable,
396
396
  fieldName: () => fieldName,
397
397
  fieldToken: () => fieldToken,
@@ -557,7 +557,7 @@ __export(src_exports, {
557
557
  titleRepeats: () => titleRepeats,
558
558
  toDropdownEntries: () => toDropdownEntries,
559
559
  toStripAndRows: () => toStripAndRows,
560
- tokenFor: () => import_core2.tokenFor,
560
+ tokenFor: () => import_core3.tokenFor,
561
561
  unknownRailLine: () => unknownRailLine,
562
562
  unknownViewLine: () => unknownViewLine,
563
563
  unreadableKeys: () => unreadableKeys,
@@ -1701,6 +1701,11 @@ function inColumnWords(error, fields) {
1701
1701
  }
1702
1702
 
1703
1703
  // src/askOnce.ts
1704
+ var import_core = require("@ai-matrx/records/core");
1705
+ var structureEpoch = 0;
1706
+ (0, import_core.onTableStructureChanged)(() => {
1707
+ structureEpoch += 1;
1708
+ });
1704
1709
  var asked = /* @__PURE__ */ new WeakMap();
1705
1710
  var byPerson = /* @__PURE__ */ new WeakMap();
1706
1711
  function heldFor(client) {
@@ -1731,7 +1736,7 @@ function askOnce(client, key, ask, freshMs) {
1731
1736
  const held = heldFor(client);
1732
1737
  const now = Date.now();
1733
1738
  const kept = held.get(key);
1734
- if (kept && now - kept.at <= freshMs) return kept.answer;
1739
+ if (kept && kept.epoch === structureEpoch && now - kept.at <= freshMs) return kept.answer;
1735
1740
  const answer = ask().then(
1736
1741
  (result) => {
1737
1742
  if (!result.ok) held.delete(key);
@@ -1742,17 +1747,18 @@ function askOnce(client, key, ask, freshMs) {
1742
1747
  throw thrown;
1743
1748
  }
1744
1749
  );
1745
- held.set(key, { at: now, answer });
1750
+ held.set(key, { at: now, epoch: structureEpoch, answer });
1746
1751
  return answer;
1747
1752
  }
1748
1753
  function forgetAsked(client, prefix) {
1749
1754
  const held = heldFor(client);
1750
1755
  for (const key of [...held.keys()]) if (key.startsWith(prefix)) held.delete(key);
1751
1756
  }
1752
- var FIELD_OPTIONS_FRESH_MS = 2e3;
1757
+ var FIELD_OPTIONS_FRESH_MS = 1e4;
1753
1758
  function fieldOptionsOnce(client, fieldId) {
1754
1759
  return askOnce(client, `field_options:${fieldId}`, () => client.fieldOptions({ field_id: fieldId }), FIELD_OPTIONS_FRESH_MS);
1755
1760
  }
1761
+ var ENRICH_CELLS_FRESH_MS = 5e3;
1756
1762
 
1757
1763
  // src/labels.tsx
1758
1764
  var import_react7 = require("react");
@@ -3608,7 +3614,7 @@ function useTableVersion(client, tableId, table) {
3608
3614
  }
3609
3615
 
3610
3616
  // src/writeOnTheWinningVersion.ts
3611
- var import_core = require("@ai-matrx/records/core");
3617
+ var import_core2 = require("@ai-matrx/records/core");
3612
3618
  function sameStoredValue(left, right) {
3613
3619
  if (left === right) return true;
3614
3620
  const empty = (v) => v === null || v === void 0 || v === "";
@@ -3626,7 +3632,7 @@ async function updateOnTheWinningVersion(client, recordId, patch, expectedVersio
3626
3632
  const send = (expected) => updateRecordAt(client, { record_id: recordId, patch, version: expected });
3627
3633
  const first = await send(expectedVersion);
3628
3634
  if (first.ok) return first;
3629
- const conflict = (0, import_core.asWriteConflict)(first.error, recordId);
3635
+ const conflict = (0, import_core2.asWriteConflict)(first.error, recordId);
3630
3636
  if (!conflict) return first;
3631
3637
  const untouched = base === "always" || Object.keys(patch).every((key) => sameStoredValue(conflict.contested_fields[key], base[key]));
3632
3638
  if (!untouched) return first;
@@ -3749,10 +3755,10 @@ async function saveTableDescription(client, tableId, text2) {
3749
3755
  // src/ReferenceBuilder.tsx
3750
3756
  var import_react18 = require("react");
3751
3757
  var import_react19 = require("@ai-matrx/records/react");
3752
- var import_core3 = require("@ai-matrx/records/core");
3758
+ var import_core4 = require("@ai-matrx/records/core");
3753
3759
 
3754
3760
  // src/createTable.ts
3755
- var import_core2 = require("@ai-matrx/records/core");
3761
+ var import_core3 = require("@ai-matrx/records/core");
3756
3762
 
3757
3763
  // src/tablePicking.tsx
3758
3764
  var import_react16 = require("react");
@@ -3925,7 +3931,7 @@ function ReferenceBuilder({
3925
3931
  if (!name || making) return;
3926
3932
  setMaking(true);
3927
3933
  setRefused(null);
3928
- const slug = (0, import_core2.tokenFor)(name);
3934
+ const slug = (0, import_core3.tokenFor)(name);
3929
3935
  const found = await client.tableFind({ slug });
3930
3936
  if (!found.ok) {
3931
3937
  setMaking(false);
@@ -3939,7 +3945,7 @@ function ReferenceBuilder({
3939
3945
  id = existing.id;
3940
3946
  bornName = tableName(existing);
3941
3947
  } else {
3942
- const made = await (0, import_core2.ensureTable)(client, {
3948
+ const made = await (0, import_core3.ensureTable)(client, {
3943
3949
  name,
3944
3950
  slug,
3945
3951
  titleField: "name",
@@ -3958,7 +3964,7 @@ function ReferenceBuilder({
3958
3964
  tables.reload();
3959
3965
  onChange({ targetTableId: id, display: null });
3960
3966
  };
3961
- const mayMakeTable = (0, import_core3.doorReady)(client.config, import_core3.DOORS.tableFind) && (0, import_core3.doorReady)(client.config, import_core3.DOORS.tableEnsure);
3967
+ const mayMakeTable = (0, import_core4.doorReady)(client.config, import_core4.DOORS.tableFind) && (0, import_core4.doorReady)(client.config, import_core4.DOORS.tableEnsure);
3962
3968
  const newTableButton = !mayMakeTable ? null : /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
3963
3969
  import_design_system9.Button,
3964
3970
  {
@@ -4357,7 +4363,7 @@ function PersonPicker({ field: field2, value, onChange, disabled, id, className,
4357
4363
 
4358
4364
  // src/gridEditing.tsx
4359
4365
  var import_react46 = require("react");
4360
- var import_core9 = require("@ai-matrx/records/core");
4366
+ var import_core10 = require("@ai-matrx/records/core");
4361
4367
  var import_react47 = require("@ai-matrx/records/react");
4362
4368
  var import_design_system25 = require("@ai-matrx/design-system");
4363
4369
 
@@ -7462,7 +7468,7 @@ var import_design_system24 = require("@ai-matrx/design-system");
7462
7468
  var import_react40 = require("react");
7463
7469
 
7464
7470
  // src/firstPage.ts
7465
- var import_core6 = require("@ai-matrx/records/core");
7471
+ var import_core7 = require("@ai-matrx/records/core");
7466
7472
  var import_uuid4 = require("@ai-matrx/kit/uuid");
7467
7473
 
7468
7474
  // src/groupReads.ts
@@ -7943,10 +7949,10 @@ var import_uuid3 = require("@ai-matrx/kit/uuid");
7943
7949
  var import_records16 = require("@ai-matrx/records");
7944
7950
 
7945
7951
  // ../entity-data/src/core/client.ts
7946
- var import_core5 = require("@ai-matrx/records/core");
7952
+ var import_core6 = require("@ai-matrx/records/core");
7947
7953
 
7948
7954
  // ../entity-data/src/core/errors.ts
7949
- var import_core4 = require("@ai-matrx/records/core");
7955
+ var import_core5 = require("@ai-matrx/records/core");
7950
7956
  var ENTITY_REFUSALS = {
7951
7957
  /** conflict_version: somebody else's write won. */
7952
7958
  MX001: "stale_write",
@@ -7970,7 +7976,7 @@ var ENTITY_REFUSALS = {
7970
7976
  MX016: "invalid_argument"
7971
7977
  };
7972
7978
  function mapEntityError(error, where) {
7973
- const mapped = (0, import_core4.mapPgError)(error, where);
7979
+ const mapped = (0, import_core5.mapPgError)(error, where);
7974
7980
  const state = mapped.sqlstate;
7975
7981
  if (state && /^MX\d{3}$/.test(state)) {
7976
7982
  const code = ENTITY_REFUSALS[state];
@@ -7992,7 +7998,7 @@ function refusal2(code, message, hint) {
7992
7998
  var OP_ID_HEADER = "x-matrx-op-id";
7993
7999
  var ENTITY_DOOR_SCHEMA = "platform";
7994
8000
  function createEntityClient(options) {
7995
- const source = (0, import_core5.asRecordsDataSource)(options.dataSource ?? options.supabase);
8001
+ const source = (0, import_core6.asRecordsDataSource)(options.dataSource ?? options.supabase);
7996
8002
  let warnedHeaderless = false;
7997
8003
  function withHeaders(pending, headers) {
7998
8004
  if (!headers) return;
@@ -8777,16 +8783,16 @@ var ABSENCE_WORD_LABEL = {
8777
8783
  };
8778
8784
 
8779
8785
  // src/values.tsx
8780
- var import_core8 = require("@ai-matrx/records/core");
8786
+ var import_core9 = require("@ai-matrx/records/core");
8781
8787
 
8782
8788
  // src/WholeValue.tsx
8783
8789
  var import_react41 = require("react");
8784
- var import_core7 = require("@ai-matrx/records/core");
8790
+ var import_core8 = require("@ai-matrx/records/core");
8785
8791
  var import_design_system20 = require("@ai-matrx/design-system");
8786
8792
  var import_jsx_runtime25 = require("react/jsx-runtime");
8787
8793
  var WHOLE_VALUE_UNBOUND = "The whole text is kept as a file, and this screen has no way to open files yet.";
8788
8794
  function wholeValueLine(pointer) {
8789
- return `Open the whole text (${(0, import_core7.wholeValueSize)(pointer)})`;
8795
+ return `Open the whole text (${(0, import_core8.wholeValueSize)(pointer)})`;
8790
8796
  }
8791
8797
  function WholeValueCell({ words: words2, pointer }) {
8792
8798
  const host = useRecordsUi();
@@ -8797,12 +8803,12 @@ function WholeValueCell({ words: words2, pointer }) {
8797
8803
  words2,
8798
8804
  "\u2026"
8799
8805
  ] }),
8800
- href ? host.Link ? host.Link({ href, children: line, className: "shrink-0 text-xs text-primary underline-offset-2 hover:underline" }) : /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("a", { className: "shrink-0 text-xs text-primary underline-offset-2 hover:underline", href, target: "_blank", rel: "noreferrer", children: line }) : /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("span", { className: "shrink-0 text-xs italic text-muted-foreground", title: WHOLE_VALUE_UNBOUND, children: `${(0, import_core7.wholeValueSize)(pointer)} in a file` })
8806
+ href ? host.Link ? host.Link({ href, children: line, className: "shrink-0 text-xs text-primary underline-offset-2 hover:underline" }) : /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("a", { className: "shrink-0 text-xs text-primary underline-offset-2 hover:underline", href, target: "_blank", rel: "noreferrer", children: line }) : /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("span", { className: "shrink-0 text-xs italic text-muted-foreground", title: WHOLE_VALUE_UNBOUND, children: `${(0, import_core8.wholeValueSize)(pointer)} in a file` })
8801
8807
  ] });
8802
8808
  }
8803
8809
  var WHOLE_VALUE_NOT_EDITABLE_HERE = "The whole text is kept as a file. Open it to read it; this screen cannot load it to edit.";
8804
8810
  function wholeValueOpening(pointer) {
8805
- return `Opening the whole text (${(0, import_core7.wholeValueSize)(pointer)})\u2026`;
8811
+ return `Opening the whole text (${(0, import_core8.wholeValueSize)(pointer)})\u2026`;
8806
8812
  }
8807
8813
  function useWholeText(pointer) {
8808
8814
  const host = useRecordsUi();
@@ -9498,7 +9504,7 @@ function renderValue(field2, value, document2, labels, stillWaitingFor, look) {
9498
9504
  if (isSignatureField(field2)) return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(SignatureValue, { value, fieldKey: field2.key, document: document2 });
9499
9505
  const newer = newerKindValue(field2, value);
9500
9506
  if (newer !== void 0) return newer;
9501
- const whole = typeof value === "string" ? (0, import_core8.wholeValueOf)(document2, field2.key) : null;
9507
+ const whole = typeof value === "string" ? (0, import_core9.wholeValueOf)(document2, field2.key) : null;
9502
9508
  if (whole) return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(WholeValueCell, { words: value, pointer: whole });
9503
9509
  const kind = editorKindFor(field2);
9504
9510
  if (kind === "relation" || kind === "entity_reference") {
@@ -9621,7 +9627,7 @@ function scalarText(field2, value, labels, stillWaitingFor) {
9621
9627
  function ProvenanceBadge({ document: document2, fieldKey }) {
9622
9628
  const envelope = envelopeFor(document2, fieldKey);
9623
9629
  if (!envelope?.src) return null;
9624
- if ((0, import_core8.wholeValueOf)(document2, fieldKey)) return null;
9630
+ if ((0, import_core9.wholeValueOf)(document2, fieldKey)) return null;
9625
9631
  const sources = document2?._sources;
9626
9632
  const source = sources?.[envelope.src];
9627
9633
  const label = source ? Object.values(source).map(String).join(" \xB7 ") : envelope.src;
@@ -9656,7 +9662,7 @@ function RecordValue({
9656
9662
  const newer = newerKindValue(field2, value, { inCell });
9657
9663
  if (newer !== void 0) return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(import_jsx_runtime30.Fragment, { children: newer });
9658
9664
  }
9659
- if (inCell && ui.grid === "merged" && ui.renderText && typeof value === "string" && value.trim() !== "" && editorKindFor(field2) === "long_text" && !shownAsOf(field2) && !(0, import_core8.wholeValueOf)(document2, field2.key) && !envelopeFor(document2, field2.key)?.absent && // A long-text cell holding a kind is drawn by the kind system below, not as markdown.
9665
+ if (inCell && ui.grid === "merged" && ui.renderText && typeof value === "string" && value.trim() !== "" && editorKindFor(field2) === "long_text" && !shownAsOf(field2) && !(0, import_core9.wholeValueOf)(document2, field2.key) && !envelopeFor(document2, field2.key)?.absent && // A long-text cell holding a kind is drawn by the kind system below, not as markdown.
9660
9666
  !kindValueOf(value)) {
9661
9667
  return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("span", { className: "block h-[1.5em] min-w-0 overflow-hidden whitespace-normal", "data-records-cell-text": "", children: ui.renderText(value, "cell") });
9662
9668
  }
@@ -9869,7 +9875,7 @@ function useGridEditing({ tableId, fields, rows, reload, reloadAfterWrite, canWr
9869
9875
  }
9870
9876
  const held = optimistic[cellKey(address.rowId, address.key)];
9871
9877
  const document2 = rows.find((r) => r.id === address.rowId)?.document;
9872
- const pointer = held === void 0 && typeof current === "string" ? (0, import_core9.wholeValueOf)(document2, address.key) : null;
9878
+ const pointer = held === void 0 && typeof current === "string" ? (0, import_core10.wholeValueOf)(document2, address.key) : null;
9873
9879
  if (pointer) {
9874
9880
  const read = host.readFileText;
9875
9881
  if (!read) return;
@@ -9980,7 +9986,7 @@ function useGridEditing({ tableId, fields, rows, reload, reloadAfterWrite, canWr
9980
9986
  delete next[id];
9981
9987
  return next;
9982
9988
  });
9983
- const conflict = (0, import_core9.asWriteConflict)(written.error, rowId);
9989
+ const conflict = (0, import_core10.asWriteConflict)(written.error, rowId);
9984
9990
  if (written.error.code === "stale_write") {
9985
9991
  if (conflict) rememberVersion(versions.current, rowId, conflict.current_version);
9986
9992
  else versions.current.delete(rowId);
@@ -10068,7 +10074,7 @@ function useGridEditing({ tableId, fields, rows, reload, reloadAfterWrite, canWr
10068
10074
  }
10069
10075
  const starting = shownValue2(next.rowId, next.key);
10070
10076
  const nextDocument = rows.find((r) => r.id === next.rowId)?.document;
10071
- if (typeof starting === "string" && optimistic[cellKey(next.rowId, next.key)] === void 0 && (0, import_core9.wholeValueOf)(nextDocument, next.key)) {
10077
+ if (typeof starting === "string" && optimistic[cellKey(next.rowId, next.key)] === void 0 && (0, import_core10.wholeValueOf)(nextDocument, next.key)) {
10072
10078
  setEditing(null);
10073
10079
  setDraft(null);
10074
10080
  typed2.current = null;
@@ -11089,7 +11095,7 @@ var import_react123 = require("react");
11089
11095
  var import_react124 = require("@ai-matrx/records/react");
11090
11096
  var import_records37 = require("@ai-matrx/records");
11091
11097
  var import_data_table13 = require("@ai-matrx/design-system/data-table");
11092
- var import_core19 = require("@ai-matrx/records/core");
11098
+ var import_core20 = require("@ai-matrx/records/core");
11093
11099
 
11094
11100
  // src/archiveWords.ts
11095
11101
  var import_format2 = require("@ai-matrx/kit/format");
@@ -11235,7 +11241,7 @@ function columnNameTakenLine(taken, noun = "column") {
11235
11241
  // src/FieldEditor.tsx
11236
11242
  var import_react65 = require("react");
11237
11243
  var import_react66 = require("@ai-matrx/records/react");
11238
- var import_core10 = require("@ai-matrx/records/core");
11244
+ var import_core11 = require("@ai-matrx/records/core");
11239
11245
  var import_design_system35 = require("@ai-matrx/design-system");
11240
11246
 
11241
11247
  // src/FormulaTextEditor.tsx
@@ -13056,7 +13062,7 @@ function FieldEditor(props) {
13056
13062
  return;
13057
13063
  }
13058
13064
  (0, import_react66.tableShapeChanged)(tableId);
13059
- for (const c of done.data.undo.cells_back) (0, import_core10.announceRecordChanged)(c.record_id);
13065
+ for (const c of done.data.undo.cells_back) (0, import_core11.announceRecordChanged)(c.record_id);
13060
13066
  const n = done.data.rehomed.reduce((sum, r) => sum + r.records, 0);
13061
13067
  setRehome({});
13062
13068
  setRehomed({ said: `Saved. ${n} ${n === 1 ? "record was" : "records were"} changed with the choices.`, undo: done.data.undo });
@@ -13478,7 +13484,7 @@ function FieldEditor(props) {
13478
13484
  return;
13479
13485
  }
13480
13486
  (0, import_react66.tableShapeChanged)(tableId);
13481
- for (const c of undo.cells_back) (0, import_core10.announceRecordChanged)(c.record_id);
13487
+ for (const c of undo.cells_back) (0, import_core11.announceRecordChanged)(c.record_id);
13482
13488
  setChoiceList(null);
13483
13489
  setChoiceListStart(null);
13484
13490
  setRehomed({ said: "Undone. The choices and the records that held them are back as they were.", undo: null });
@@ -16169,7 +16175,7 @@ function WholeTextDialog({
16169
16175
  }
16170
16176
 
16171
16177
  // src/pasteValues.ts
16172
- var import_core11 = require("@ai-matrx/records/core");
16178
+ var import_core12 = require("@ai-matrx/records/core");
16173
16179
  var import_records30 = require("@ai-matrx/records");
16174
16180
  function wordForStoredChoice(options, value) {
16175
16181
  if (options === void 0 || typeof value !== "string" || value === "") return null;
@@ -16248,7 +16254,7 @@ function planPastedBlock(args) {
16248
16254
  });
16249
16255
  accepted[key] = judged.value;
16250
16256
  }
16251
- const predicted = (0, import_core11.predictValueRefusals)(args.fields, accepted);
16257
+ const predicted = (0, import_core12.predictValueRefusals)(args.fields, accepted);
16252
16258
  for (const refusal4 of predicted) {
16253
16259
  const key = refusal4.field_key;
16254
16260
  if (key === void 0) continue;
@@ -17165,7 +17171,7 @@ var import_design_system51 = require("@ai-matrx/design-system");
17165
17171
  // src/RecordForm.tsx
17166
17172
  var import_react92 = require("react");
17167
17173
  var import_react93 = require("@ai-matrx/records/react");
17168
- var import_core13 = require("@ai-matrx/records/core");
17174
+ var import_core14 = require("@ai-matrx/records/core");
17169
17175
  var import_design_system50 = require("@ai-matrx/design-system");
17170
17176
  var import_text_case6 = require("@ai-matrx/kit/text-case");
17171
17177
 
@@ -17178,7 +17184,7 @@ var import_design_system49 = require("@ai-matrx/design-system");
17178
17184
  var import_react88 = require("react");
17179
17185
  var import_react89 = require("@ai-matrx/records/react");
17180
17186
  var import_design_system48 = require("@ai-matrx/design-system");
17181
- var import_core12 = require("@ai-matrx/records/core");
17187
+ var import_core13 = require("@ai-matrx/records/core");
17182
17188
  var import_jsx_runtime55 = require("react/jsx-runtime");
17183
17189
  function isEmptyValue(value) {
17184
17190
  return value === null || value === void 0 || value === "" || Array.isArray(value) && value.length === 0;
@@ -17250,7 +17256,7 @@ async function writeStandardRowValues(client, args) {
17250
17256
  { schema: config.schema ?? "custom" }
17251
17257
  );
17252
17258
  if (!old.error) return { ok: true };
17253
- const error = (0, import_core12.mapPgError)(old.error, "entityValueWrite");
17259
+ const error = (0, import_core13.mapPgError)(old.error, "entityValueWrite");
17254
17260
  return { ok: false, error: doorIsAbsent(error) && first && first.error.code !== "door_absent" ? first.error : error };
17255
17261
  }
17256
17262
  function doorIsAbsent(error) {
@@ -17831,7 +17837,7 @@ function CustomRecordForm({
17831
17837
  return out;
17832
17838
  }, [draft]);
17833
17839
  const predicted = (0, import_react92.useMemo)(
17834
- () => fields.data ? (0, import_core13.predictWriteRefusals)({ fields: fields.data, document: document2, ...recordType ? { recordType } : {} }) : [],
17840
+ () => fields.data ? (0, import_core14.predictWriteRefusals)({ fields: fields.data, document: document2, ...recordType ? { recordType } : {} }) : [],
17835
17841
  [fields.data, document2, recordType]
17836
17842
  );
17837
17843
  if (fields.error) return /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(RefusalNotice, { error: fields.error, className });
@@ -17881,7 +17887,7 @@ function CustomRecordForm({
17881
17887
  setEdit({
17882
17888
  saving: false,
17883
17889
  error: answered2.ok ? null : answered2.error,
17884
- conflict: answered2.ok ? null : (0, import_core13.asWriteConflict)(answered2.error, recordId)
17890
+ conflict: answered2.ok ? null : (0, import_core14.asWriteConflict)(answered2.error, recordId)
17885
17891
  });
17886
17892
  const moved = answered2.ok ? answered2.data : null;
17887
17893
  if (moved !== null) {
@@ -17990,7 +17996,7 @@ function FieldRow({
17990
17996
  }) {
17991
17997
  const id = `field-${field2.id}`;
17992
17998
  const storedWords = document2?.[field2.key];
17993
- const whole = typeof storedWords === "string" ? (0, import_core13.wholeValueOf)(document2, field2.key) : null;
17999
+ const whole = typeof storedWords === "string" ? (0, import_core14.wholeValueOf)(document2, field2.key) : null;
17994
18000
  return /* @__PURE__ */ (0, import_jsx_runtime57.jsxs)("div", { className: (0, import_design_system50.cn)("flex min-w-0 flex-col gap-1", whole && "sm:col-span-2"), children: [
17995
18001
  /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(FieldLabel, { field: field2, htmlFor: id, children: /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(ProvenanceBadge, { document: document2, fieldKey: field2.key }) }),
17996
18002
  whole ? (
@@ -18923,12 +18929,14 @@ function useEnrichCells(tableId, recordIds) {
18923
18929
  const [cells, setCells] = (0, import_react100.useState)(/* @__PURE__ */ new Map());
18924
18930
  const [error, setError] = (0, import_react100.useState)(null);
18925
18931
  const key = (recordIds ?? []).join(",");
18926
- const refresh = (0, import_react100.useCallback)(async () => {
18932
+ const load = (0, import_react100.useCallback)(async (fresh) => {
18927
18933
  if (!tableId || !recordIds || recordIds.length === 0) {
18928
18934
  setCells(/* @__PURE__ */ new Map());
18929
18935
  return;
18930
18936
  }
18931
- const answered = await client.enrichCells({ table_id: tableId, record_ids: recordIds });
18937
+ const asking = `enrich_cells:${tableId}:${key}`;
18938
+ if (fresh) forgetAsked(client, asking);
18939
+ const answered = await askOnce(client, asking, () => client.enrichCells({ table_id: tableId, record_ids: recordIds }), ENRICH_CELLS_FRESH_MS);
18932
18940
  if (!answered.ok) {
18933
18941
  setError(answered.error);
18934
18942
  return;
@@ -18938,9 +18946,10 @@ function useEnrichCells(tableId, recordIds) {
18938
18946
  for (const cell2 of answered.data) next.set(`${cell2.record_id}:${cell2.field_key}`, cell2);
18939
18947
  setCells(next);
18940
18948
  }, [client, tableId, key]);
18949
+ const refresh = (0, import_react100.useCallback)(() => load(true), [load]);
18941
18950
  (0, import_react100.useEffect)(() => {
18942
- void refresh();
18943
- }, [refresh]);
18951
+ void load(false);
18952
+ }, [load]);
18944
18953
  return { cells, refresh, error };
18945
18954
  }
18946
18955
  var NEVER2 = "Fill it in once and leave it alone";
@@ -20052,12 +20061,12 @@ function withOpenRecord(columns, onOpen, nameOf2, place = "end", hrefOf) {
20052
20061
  // src/ImportWizard.tsx
20053
20062
  var import_react105 = require("react");
20054
20063
  var import_react106 = require("@ai-matrx/records/react");
20055
- var import_core15 = require("@ai-matrx/records/core");
20064
+ var import_core16 = require("@ai-matrx/records/core");
20056
20065
  var import_design_system56 = require("@ai-matrx/design-system");
20057
20066
  var import_records34 = require("@ai-matrx/records");
20058
20067
 
20059
20068
  // src/importRuleCheck.ts
20060
- var import_core14 = require("@ai-matrx/records/core");
20069
+ var import_core15 = require("@ai-matrx/records/core");
20061
20070
  function checkImportRules(fields, rows, mapping, choiceOptions, relationNames) {
20062
20071
  const byKey = new Map(fields.map((f) => [f.key, f]));
20063
20072
  const verdicts = [];
@@ -20083,7 +20092,7 @@ function checkImportRules(fields, rows, mapping, choiceOptions, relationNames) {
20083
20092
  if ("unmatchedNames" in meant) return;
20084
20093
  if ("refusal" in meant) why = meant.refusal;
20085
20094
  else {
20086
- const predicted = (0, import_core14.predictValueRefusals)([field2], { [key]: meant.value }).filter(
20095
+ const predicted = (0, import_core15.predictValueRefusals)([field2], { [key]: meant.value }).filter(
20087
20096
  (p) => p.field_key === void 0 || p.field_key === key
20088
20097
  );
20089
20098
  if (predicted.length > 0) why = predicted[0].message;
@@ -20587,7 +20596,7 @@ function ImportWizard({ tableId, source, onDone, onWrote, className }) {
20587
20596
  try {
20588
20597
  const xlsx = file.name.toLowerCase().endsWith(".xlsx");
20589
20598
  const bytes = await file.arrayBuffer();
20590
- const result = xlsx ? await (0, import_core15.importXlsx)(bytes) : (0, import_core15.importCsv)(new TextDecoder().decode(bytes));
20599
+ const result = xlsx ? await (0, import_core16.importXlsx)(bytes) : (0, import_core16.importCsv)(new TextDecoder().decode(bytes));
20591
20600
  await planFrom(result, { name: file.name, bytes: file.size, hash: await sha256(bytes), format: xlsx ? "xlsx" : "csv" });
20592
20601
  } catch (thrown) {
20593
20602
  setProblem(
@@ -22596,7 +22605,7 @@ function useGroupLabel(fields, groupKey) {
22596
22605
  // src/gridUndo.tsx
22597
22606
  var import_react113 = require("react");
22598
22607
  var import_react114 = require("@ai-matrx/records/react");
22599
- var import_core16 = require("@ai-matrx/records/core");
22608
+ var import_core17 = require("@ai-matrx/records/core");
22600
22609
  var import_design_system58 = require("@ai-matrx/design-system");
22601
22610
  var import_data_table12 = require("@ai-matrx/design-system/data-table");
22602
22611
  var import_jsx_runtime68 = require("react/jsx-runtime");
@@ -22690,7 +22699,7 @@ function useGridUndo(args) {
22690
22699
  }
22691
22700
  forget(step2.cells.map((c) => ({ rowId: c.rowId, key: c.key })));
22692
22701
  for (const id of /* @__PURE__ */ new Set([...step2.cells.map((c) => c.rowId), ...step2.created ?? [], ...step2.archived ?? []])) {
22693
- (0, import_core16.announceRecordChanged)(id);
22702
+ (0, import_core17.announceRecordChanged)(id);
22694
22703
  }
22695
22704
  setHeld(() => {
22696
22705
  let stack = taken.stack;
@@ -23078,7 +23087,7 @@ function holdKeys() {
23078
23087
  // src/gridAssist.tsx
23079
23088
  var import_clipboard2 = require("@ai-matrx/kit/clipboard");
23080
23089
  var import_react117 = require("react");
23081
- var import_core17 = require("@ai-matrx/records/core");
23090
+ var import_core18 = require("@ai-matrx/records/core");
23082
23091
  var import_workspace = require("@ai-matrx/alchemy/react/workspace");
23083
23092
 
23084
23093
  // src/gridAgentContext.ts
@@ -23208,7 +23217,7 @@ function useGridAssist(args) {
23208
23217
  const copyRecordReference = (0, import_react117.useCallback)(
23209
23218
  (rowId) => {
23210
23219
  void (async () => {
23211
- const text2 = JSON.stringify({ __kind: (0, import_core17.tableKindSlug)(tableId), _record_id: rowId });
23220
+ const text2 = JSON.stringify({ __kind: (0, import_core18.tableKindSlug)(tableId), _record_id: rowId });
23212
23221
  if (!await (0, import_clipboard2.copyText)(text2)) {
23213
23222
  say2(false, "This browser did not let the page write to the clipboard.");
23214
23223
  return;
@@ -23264,7 +23273,7 @@ function useGridAssist(args) {
23264
23273
  if (!row) return;
23265
23274
  const document2 = row.document ?? {};
23266
23275
  const value = editing.valueFor(row, fieldOf2(key));
23267
- const pointer = typeof document2[key] === "string" ? (0, import_core17.wholeValueOf)(document2, key) : null;
23276
+ const pointer = typeof document2[key] === "string" ? (0, import_core18.wholeValueOf)(document2, key) : null;
23268
23277
  setWhole({ rowId, key, rowTitle: titleOf(row), value, pointer });
23269
23278
  },
23270
23279
  [rowOf, fieldOf2, titleOf, editing]
@@ -23360,7 +23369,7 @@ function useGridAssist(args) {
23360
23369
  // src/gridBulk.tsx
23361
23370
  var import_react118 = require("react");
23362
23371
  var import_react119 = require("@ai-matrx/records/react");
23363
- var import_core18 = require("@ai-matrx/records/core");
23372
+ var import_core19 = require("@ai-matrx/records/core");
23364
23373
  var import_design_system59 = require("@ai-matrx/design-system");
23365
23374
  var import_jsx_runtime70 = require("react/jsx-runtime");
23366
23375
  function countOf(n, one, many) {
@@ -23426,7 +23435,7 @@ function useGridBulk(args) {
23426
23435
  return null;
23427
23436
  }
23428
23437
  for (const result of done.data ?? []) if (result.op === "update") versions.wrote(result.id, result.version);
23429
- for (const change of changes) if ("record_id" in change && change.record_id) (0, import_core18.announceRecordChanged)(change.record_id);
23438
+ for (const change of changes) if ("record_id" in change && change.record_id) (0, import_core19.announceRecordChanged)(change.record_id);
23430
23439
  return done.data;
23431
23440
  },
23432
23441
  [client, tableId, versions, reload]
@@ -24586,7 +24595,7 @@ function GridBody({
24586
24595
  }))
24587
24596
  );
24588
24597
  editing.forget(cells);
24589
- for (const u of updates) (0, import_core19.announceRecordChanged)(u.row.recordId);
24598
+ for (const u of updates) (0, import_core20.announceRecordChanged)(u.row.recordId);
24590
24599
  const lines = updates.length + creates.length;
24591
24600
  undo.push({ label: `Pasted ${lines} ${lines === 1 ? "row" : "rows"}`, cells, created });
24592
24601
  const expected = [
@@ -24863,7 +24872,7 @@ function GridBody({
24863
24872
  const addRowHere = (0, import_react123.useCallback)(async (values) => {
24864
24873
  setAddRefused(null);
24865
24874
  if (formHosted && fields.data) {
24866
- const wouldRefuse = (0, import_core19.predictWriteRefusals)({ fields: fields.data, document: values ?? {} });
24875
+ const wouldRefuse = (0, import_core20.predictWriteRefusals)({ fields: fields.data, document: values ?? {} });
24867
24876
  if (wouldRefuse.length > 0) {
24868
24877
  setFormAsk((held) => ({ n: (held?.n ?? 0) + 1, initial: { ...values ?? {} } }));
24869
24878
  return;
@@ -26394,7 +26403,7 @@ function ConnectedRecordsTableCard({
26394
26403
  var import_download2 = require("@ai-matrx/kit/download");
26395
26404
  var import_react132 = require("react");
26396
26405
  var import_react133 = require("@ai-matrx/records/react");
26397
- var import_core20 = require("@ai-matrx/records/core");
26406
+ var import_core21 = require("@ai-matrx/records/core");
26398
26407
 
26399
26408
  // src/viewExport.ts
26400
26409
  var import_format5 = require("@ai-matrx/kit/format");
@@ -26461,7 +26470,7 @@ function toRows(fields, records, labels) {
26461
26470
  absent_reason: envelope?.absent ?? null,
26462
26471
  // A VALUE KEPT AS A FILE carries its pointer, so the export writes the whole text
26463
26472
  // (`withWholeValues`), never the first words passed off as the value.
26464
- source: (0, import_core20.wholeValueOf)(document2, field2.key)
26473
+ source: (0, import_core21.wholeValueOf)(document2, field2.key)
26465
26474
  };
26466
26475
  }
26467
26476
  return row;
@@ -26492,7 +26501,7 @@ async function rowsForFile(args) {
26492
26501
  );
26493
26502
  const lookup = ((field2, id) => labels(field2, id) ?? learned.get(`${field2.id}:${id}`) ?? null);
26494
26503
  const read = host.readFileText;
26495
- return (0, import_core20.withWholeValues)(toRows(all, records, lookup), read ? (fileId) => read({ fileId }) : null);
26504
+ return (0, import_core21.withWholeValues)(toRows(all, records, lookup), read ? (fileId) => read({ fileId }) : null);
26496
26505
  }
26497
26506
  function ExportMenu({ tableId, rows, label, className, view }) {
26498
26507
  const client = (0, import_react133.useRecordsClient)();
@@ -26531,7 +26540,7 @@ function ExportMenu({ tableId, rows, label, className, view }) {
26531
26540
  {
26532
26541
  size: "sm",
26533
26542
  variant: "outline",
26534
- onClick: () => void exported().then((rows2) => download(`${name}.csv`, "text/csv;charset=utf-8", (0, import_core20.exportCsv)(columns, rows2))).catch(
26543
+ onClick: () => void exported().then((rows2) => download(`${name}.csv`, "text/csv;charset=utf-8", (0, import_core21.exportCsv)(columns, rows2))).catch(
26535
26544
  (thrown) => setFailure(refusalFromThrown(thrown, "The CSV could not be written.", "Try again in a moment."))
26536
26545
  ),
26537
26546
  children: "CSV"
@@ -26552,7 +26561,7 @@ function ExportMenu({ tableId, rows, label, className, view }) {
26552
26561
  );
26553
26562
  setFailure(null);
26554
26563
  try {
26555
- exported().then((rows2) => (0, import_core20.exportXlsx)(columns, rows2, name)).then(
26564
+ exported().then((rows2) => (0, import_core21.exportXlsx)(columns, rows2, name)).then(
26556
26565
  (bytes) => download(
26557
26566
  `${name}.xlsx`,
26558
26567
  "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
@@ -26573,7 +26582,7 @@ function ExportMenu({ tableId, rows, label, className, view }) {
26573
26582
  sourceId: `records:${tableId}`,
26574
26583
  size: "xs",
26575
26584
  json: () => records.map((r) => r.document),
26576
- human: () => (0, import_core20.exportCsv)(columns, toRows(columns, records, labels))
26585
+ human: () => (0, import_core21.exportCsv)(columns, toRows(columns, records, labels))
26577
26586
  }
26578
26587
  ),
26579
26588
  viewHeld && "rows" in viewHeld && viewHeld.cut ? /* @__PURE__ */ (0, import_jsx_runtime75.jsx)("span", { className: "text-xs text-muted-foreground", children: cutWords(viewHeld.rows.length) }) : null,
@@ -26693,7 +26702,7 @@ var import_design_system74 = require("@ai-matrx/design-system");
26693
26702
  // src/TablesHome.tsx
26694
26703
  var import_react146 = require("react");
26695
26704
  var import_react147 = require("@ai-matrx/records/react");
26696
- var import_core21 = require("@ai-matrx/records/core");
26705
+ var import_core22 = require("@ai-matrx/records/core");
26697
26706
  var import_records42 = require("@ai-matrx/records");
26698
26707
  var import_design_system73 = require("@ai-matrx/design-system");
26699
26708
 
@@ -26854,7 +26863,7 @@ function columnsFrom(text2) {
26854
26863
  function fieldsForNewColumns(columns) {
26855
26864
  const keys = /* @__PURE__ */ new Set();
26856
26865
  return columns.map((column, i) => {
26857
- let key = (0, import_core2.tokenFor)(column.label) || `column_${i + 1}`;
26866
+ let key = (0, import_core3.tokenFor)(column.label) || `column_${i + 1}`;
26858
26867
  while (keys.has(key)) key = `${key}_${i + 1}`;
26859
26868
  keys.add(key);
26860
26869
  const base = { key, label: column.label, sort: (i + 1) * 10, required: false };
@@ -28429,7 +28438,7 @@ function TablesHome({ onOpenTable, organizationName, makingOnly = false, askedBy
28429
28438
  };
28430
28439
  }, [client]);
28431
28440
  const listed = facts.phase === "read" ? (0, import_records42.withTablePlacement)(
28432
- (0, import_core21.withTableFacts)(tables.data ?? [], facts.rows, me),
28441
+ (0, import_core22.withTableFacts)(tables.data ?? [], facts.rows, me),
28433
28442
  facts.rows
28434
28443
  ) : tables.data ?? [];
28435
28444
  const [showEverything, setShowEverything] = (0, import_react146.useState)(false);
@@ -28479,9 +28488,9 @@ function TablesHome({ onOpenTable, organizationName, makingOnly = false, askedBy
28479
28488
  if (!trimmed) return;
28480
28489
  setBusy(true);
28481
28490
  setError(null);
28482
- const result = await (0, import_core2.declareTable)(client, {
28491
+ const result = await (0, import_core3.declareTable)(client, {
28483
28492
  name: trimmed,
28484
- slug: (0, import_core2.tokenFor)(trimmed),
28493
+ slug: (0, import_core3.tokenFor)(trimmed),
28485
28494
  ...columns.length > 0 ? { fields: fieldsForNewColumns(columns) } : {}
28486
28495
  });
28487
28496
  setBusy(false);
@@ -28716,7 +28725,7 @@ function draftsFor(headers, rows) {
28716
28725
  function keysFor(labels) {
28717
28726
  const used = /* @__PURE__ */ new Set();
28718
28727
  return labels.map((label, i) => {
28719
- const base = (0, import_core2.tokenFor)(label) === "table" && !/table/i.test(label) ? `column_${i + 1}` : (0, import_core2.tokenFor)(label);
28728
+ const base = (0, import_core3.tokenFor)(label) === "table" && !/table/i.test(label) ? `column_${i + 1}` : (0, import_core3.tokenFor)(label);
28720
28729
  let key = base;
28721
28730
  let n = 2;
28722
28731
  while (used.has(key)) key = `${base}_${n++}`;
@@ -28812,7 +28821,7 @@ function SaveToTable({ source, shapeIndex = 0, onOpenTable, onSaved, onClose, cl
28812
28821
  const tableName2 = freeName(name ?? proposedName, (tables.data ?? []).map((t) => t.name));
28813
28822
  setPhase("making");
28814
28823
  try {
28815
- const born = await (0, import_core2.declareTable)(client, { name: tableName2, fields });
28824
+ const born = await (0, import_core3.declareTable)(client, { name: tableName2, fields });
28816
28825
  if (!born.ok) {
28817
28826
  setProblem(born.error);
28818
28827
  setPhase("ready");
@@ -38741,7 +38750,7 @@ var import_design_system105 = require("@ai-matrx/design-system");
38741
38750
  var import_react219 = require("react");
38742
38751
  var import_recharts = require("recharts");
38743
38752
  var import_records50 = require("@ai-matrx/records");
38744
- var import_core22 = require("@ai-matrx/records/core");
38753
+ var import_core23 = require("@ai-matrx/records/core");
38745
38754
  var import_design_system104 = require("@ai-matrx/design-system");
38746
38755
  var import_format10 = require("@ai-matrx/kit/format");
38747
38756
 
@@ -39203,7 +39212,7 @@ function pretty(n) {
39203
39212
  return Number.isInteger(n) ? n.toLocaleString() : n.toLocaleString(void 0, { maximumFractionDigits: 2 });
39204
39213
  }
39205
39214
  function asRefusal2(block) {
39206
- return (0, import_core22.mapPgError)(
39215
+ return (0, import_core23.mapPgError)(
39207
39216
  {
39208
39217
  message: block.refused ?? "",
39209
39218
  ...block.sqlstate ? { code: block.sqlstate } : {}
@@ -42111,7 +42120,7 @@ function SubscriptionsPanel({ tableId, activeRuleId, className }) {
42111
42120
  var import_clipboard9 = require("@ai-matrx/kit/clipboard");
42112
42121
  var import_design_system117 = require("@ai-matrx/design-system");
42113
42122
  var import_react237 = require("react");
42114
- var import_core23 = require("@dnd-kit/core");
42123
+ var import_core24 = require("@dnd-kit/core");
42115
42124
  var import_sortable = require("@dnd-kit/sortable");
42116
42125
  var import_utilities = require("@dnd-kit/utilities");
42117
42126
  var import_react238 = require("@ai-matrx/records/react");
@@ -43741,9 +43750,9 @@ function QuestionList({
43741
43750
  onQuestions,
43742
43751
  onQuestion
43743
43752
  }) {
43744
- const sensors = (0, import_core23.useSensors)(
43745
- (0, import_core23.useSensor)(import_core23.PointerSensor, { activationConstraint: { distance: 4 } }),
43746
- (0, import_core23.useSensor)(import_core23.KeyboardSensor, { coordinateGetter: import_sortable.sortableKeyboardCoordinates })
43753
+ const sensors = (0, import_core24.useSensors)(
43754
+ (0, import_core24.useSensor)(import_core24.PointerSensor, { activationConstraint: { distance: 4 } }),
43755
+ (0, import_core24.useSensor)(import_core24.KeyboardSensor, { coordinateGetter: import_sortable.sortableKeyboardCoordinates })
43747
43756
  );
43748
43757
  const askable = askableFields([...fields]);
43749
43758
  const unasked = askable.filter((f) => !draft.questions.some((q) => q.field === f.key));
@@ -43765,7 +43774,7 @@ function QuestionList({
43765
43774
  /* @__PURE__ */ (0, import_jsx_runtime133.jsx)("span", { className: "font-medium text-foreground", children: "Questions" }),
43766
43775
  /* @__PURE__ */ (0, import_jsx_runtime133.jsx)("span", { className: "tabular-nums", children: draft.questions.length })
43767
43776
  ] }),
43768
- /* @__PURE__ */ (0, import_jsx_runtime133.jsx)(import_core23.DndContext, { sensors, collisionDetection: import_core23.closestCenter, onDragEnd: dragEnd, children: /* @__PURE__ */ (0, import_jsx_runtime133.jsx)(import_sortable.SortableContext, { items: draft.questions.map((q) => q.field), strategy: import_sortable.verticalListSortingStrategy, children: draft.questions.map((question, index) => /* @__PURE__ */ (0, import_jsx_runtime133.jsx)(
43777
+ /* @__PURE__ */ (0, import_jsx_runtime133.jsx)(import_core24.DndContext, { sensors, collisionDetection: import_core24.closestCenter, onDragEnd: dragEnd, children: /* @__PURE__ */ (0, import_jsx_runtime133.jsx)(import_sortable.SortableContext, { items: draft.questions.map((q) => q.field), strategy: import_sortable.verticalListSortingStrategy, children: draft.questions.map((question, index) => /* @__PURE__ */ (0, import_jsx_runtime133.jsx)(
43769
43778
  QuestionRow,
43770
43779
  {
43771
43780
  index,
@@ -44761,7 +44770,7 @@ var import_react255 = require("@ai-matrx/records/react");
44761
44770
  var import_design_system126 = require("@ai-matrx/design-system");
44762
44771
 
44763
44772
  // src/DashboardGrid.tsx
44764
- var import_core24 = require("@dnd-kit/core");
44773
+ var import_core25 = require("@dnd-kit/core");
44765
44774
  var import_sortable2 = require("@dnd-kit/sortable");
44766
44775
  var import_utilities2 = require("@dnd-kit/utilities");
44767
44776
  var import_design_system123 = require("@ai-matrx/design-system");
@@ -44817,7 +44826,7 @@ function withBlockIds(blocks) {
44817
44826
  // src/DashboardGrid.tsx
44818
44827
  var import_jsx_runtime138 = require("react/jsx-runtime");
44819
44828
  var dashboardCollision = (args) => {
44820
- const under = (0, import_core24.pointerWithin)(args);
44829
+ const under = (0, import_core25.pointerWithin)(args);
44821
44830
  if (under.length > 0) return under;
44822
44831
  const at = args.collisionRect;
44823
44832
  return args.droppableContainers.flatMap((container) => {
@@ -44827,9 +44836,9 @@ var dashboardCollision = (args) => {
44827
44836
  }).sort((a, b) => a.data.value - b.data.value);
44828
44837
  };
44829
44838
  function DashboardGrid({ items, arranging, onMove, onSpan }) {
44830
- const sensors = (0, import_core24.useSensors)(
44831
- (0, import_core24.useSensor)(import_core24.PointerSensor, { activationConstraint: { distance: 4 } }),
44832
- (0, import_core24.useSensor)(import_core24.KeyboardSensor, { coordinateGetter: import_sortable2.sortableKeyboardCoordinates })
44839
+ const sensors = (0, import_core25.useSensors)(
44840
+ (0, import_core25.useSensor)(import_core25.PointerSensor, { activationConstraint: { distance: 4 } }),
44841
+ (0, import_core25.useSensor)(import_core25.KeyboardSensor, { coordinateGetter: import_sortable2.sortableKeyboardCoordinates })
44833
44842
  );
44834
44843
  const ids = items.map((item) => item.id);
44835
44844
  function dragEnd(event) {
@@ -44839,7 +44848,7 @@ function DashboardGrid({ items, arranging, onMove, onSpan }) {
44839
44848
  }
44840
44849
  const grid = /* @__PURE__ */ (0, import_jsx_runtime138.jsx)("div", { className: "grid grid-cols-1 gap-2 sm:grid-cols-12", children: items.map((item, index) => /* @__PURE__ */ (0, import_jsx_runtime138.jsx)(GridCell2, { item, index, arranging, onSpan }, item.id)) });
44841
44850
  if (!arranging) return grid;
44842
- return /* @__PURE__ */ (0, import_jsx_runtime138.jsx)(import_core24.DndContext, { sensors, collisionDetection: dashboardCollision, onDragEnd: dragEnd, children: /* @__PURE__ */ (0, import_jsx_runtime138.jsx)(import_sortable2.SortableContext, { items: ids, strategy: import_sortable2.rectSortingStrategy, children: grid }) });
44851
+ return /* @__PURE__ */ (0, import_jsx_runtime138.jsx)(import_core25.DndContext, { sensors, collisionDetection: dashboardCollision, onDragEnd: dragEnd, children: /* @__PURE__ */ (0, import_jsx_runtime138.jsx)(import_sortable2.SortableContext, { items: ids, strategy: import_sortable2.rectSortingStrategy, children: grid }) });
44843
44852
  }
44844
44853
  function GridCell2({
44845
44854
  item,
@@ -46052,7 +46061,7 @@ var import_react257 = require("@ai-matrx/records/react");
46052
46061
 
46053
46062
  // src/question.ts
46054
46063
  var import_records58 = require("@ai-matrx/records");
46055
- var import_core25 = require("@ai-matrx/records/core");
46064
+ var import_core26 = require("@ai-matrx/records/core");
46056
46065
  var QUESTION_OPS = ["count", "sum", "avg", "min", "max"];
46057
46066
  var QUESTION_LIMIT_DEFAULT = 25;
46058
46067
  var QUESTION_GROUP_CEILING = 200;
@@ -46304,7 +46313,7 @@ async function askAsOf(client, tableId, spec, fields, measures, keys) {
46304
46313
  },
46305
46314
  { schema: config.schema ?? "custom" }
46306
46315
  );
46307
- if (response.error) return { ok: false, error: (0, import_core25.mapPgError)(response.error, "askQuestion.asOf") };
46316
+ if (response.error) return { ok: false, error: (0, import_core26.mapPgError)(response.error, "askQuestion.asOf") };
46308
46317
  const rows2 = Array.isArray(response.data) ? response.data : [];
46309
46318
  const bad = rows2.find((r) => Number(r.not_numbers ?? 0) > 0);
46310
46319
  if (bad && m.op !== "count") {
@@ -46375,7 +46384,7 @@ function savedOf(row) {
46375
46384
  }
46376
46385
  async function questionsOf(client, tableId) {
46377
46386
  const response = await client.config.dataSource.schema("platform").from("saved_view").select("id, name, definition, visibility, version, created_by").eq("surface_key", QUESTION_SURFACE).eq("subject_id", tableId).is("deleted_at", null).order("name", { ascending: true });
46378
- if (response.error) return { ok: false, error: (0, import_core25.mapPgError)(response.error, "questionsOf") };
46387
+ if (response.error) return { ok: false, error: (0, import_core26.mapPgError)(response.error, "questionsOf") };
46379
46388
  const me = client.config.actor?.user_id ?? null;
46380
46389
  return {
46381
46390
  ok: true,
@@ -46404,7 +46413,7 @@ async function questionSave(client, args) {
46404
46413
  if (response.error.code === "23505") {
46405
46414
  return { ok: false, error: { code: "already_exists", message: `You already have a question called \u201C${name}\u201D.` } };
46406
46415
  }
46407
- return { ok: false, error: (0, import_core25.mapPgError)(response.error, "questionSave") };
46416
+ return { ok: false, error: (0, import_core26.mapPgError)(response.error, "questionSave") };
46408
46417
  }
46409
46418
  return { ok: true, data: response.data ? savedOf(response.data) : null };
46410
46419
  }
@@ -46414,7 +46423,7 @@ async function questionArchive(client, id, version) {
46414
46423
  { p_surface_key: QUESTION_SURFACE, p_id: id, ...version !== void 0 ? { p_expected_version: version } : {} },
46415
46424
  { schema: "public" }
46416
46425
  );
46417
- if (response.error) return { ok: false, error: (0, import_core25.mapPgError)(response.error, "questionArchive") };
46426
+ if (response.error) return { ok: false, error: (0, import_core26.mapPgError)(response.error, "questionArchive") };
46418
46427
  return { ok: true, data: response.data !== null };
46419
46428
  }
46420
46429
 
@@ -47273,7 +47282,7 @@ function TableAsk({ tableId, onOpenInQuestions }) {
47273
47282
  // src/PageScreen.tsx
47274
47283
  var import_react260 = require("react");
47275
47284
  var import_react261 = require("@ai-matrx/records/react");
47276
- var import_core26 = require("@ai-matrx/records/core");
47285
+ var import_core27 = require("@ai-matrx/records/core");
47277
47286
  var import_design_system129 = require("@ai-matrx/design-system");
47278
47287
  var import_jsx_runtime145 = require("react/jsx-runtime");
47279
47288
  var EDIT_LEVELS = /* @__PURE__ */ new Set(["edit_content", "editor", "admin", "owner"]);
@@ -47689,7 +47698,7 @@ function ListBlockView({
47689
47698
  ...sort.length > 0 ? { sort } : {}
47690
47699
  });
47691
47700
  const reload = page.reload;
47692
- (0, import_react260.useEffect)(() => (0, import_core26.onRecordChanged)(() => reload()), [reload]);
47701
+ (0, import_react260.useEffect)(() => (0, import_core27.onRecordChanged)(() => reload()), [reload]);
47693
47702
  const rows = nobodyIsMe ? [] : page.data?.rows ?? [];
47694
47703
  const columns = block.columns && block.columns.length > 0 ? block.columns.map((k) => all.find((f) => f.key === k)).filter((f) => !!f) : [...all].sort((a, b) => (a.sort ?? 100) - (b.sort ?? 100)).slice(0, DEFAULT_COLUMNS);
47695
47704
  const firstId = rows[0]?.id ?? null;
@@ -49224,7 +49233,7 @@ var import_design_system142 = require("@ai-matrx/design-system");
49224
49233
  var import_text_case19 = require("@ai-matrx/kit/text-case");
49225
49234
 
49226
49235
  // src/viewShare.ts
49227
- var import_core27 = require("@ai-matrx/records/core");
49236
+ var import_core28 = require("@ai-matrx/records/core");
49228
49237
  var NO_VIEW_REASON = "No saved view yet";
49229
49238
  function viewLink(tableId, viewId, origin) {
49230
49239
  return `${tableLink(tableId, origin)}?view=${encodeURIComponent(viewId)}`;
@@ -49260,7 +49269,7 @@ async function downloadViewCsv(args) {
49260
49269
  const columns = viewColumns(fields, view.presentation);
49261
49270
  const rows = await rowsForFile({ client, host, fields: columns, records: read.rows, labels });
49262
49271
  const name = fileNameOf(args.tableName) || "records";
49263
- download(`${name}.csv`, "text/csv;charset=utf-8", (0, import_core27.exportCsv)(columns, rows));
49272
+ download(`${name}.csv`, "text/csv;charset=utf-8", (0, import_core28.exportCsv)(columns, rows));
49264
49273
  host.notify?.success(read.cut ? cutWords(read.rows.length) : "CSV downloaded");
49265
49274
  }
49266
49275