@nivaro/react 0.3.9 → 0.3.11

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.
Files changed (80) hide show
  1. package/dist/components/fields/FileField.js +20 -19
  2. package/dist/full.css +1 -1
  3. package/dist/hooks/useNivaroForm.js +129 -126
  4. package/dist/hooks/useSessionRecorder.js +1 -1
  5. package/dist/index.d.ts +103 -4
  6. package/dist/index.js +512 -501
  7. package/dist/shared/components/CollectionBrowserView.js +1632 -1564
  8. package/dist/shared/components/ConformanceView.js +36 -35
  9. package/dist/shared/components/ForceReloadBanner.js +58 -34
  10. package/dist/shared/components/ItemEditForm.js +4386 -4142
  11. package/dist/shared/components/JsonMapEditor.js +18 -17
  12. package/dist/shared/components/MatrixEditor.js +8 -7
  13. package/dist/shared/components/MyWorkView.js +32 -31
  14. package/dist/shared/components/PageRenderer.js +527 -479
  15. package/dist/shared/components/QueryStatStrip.js +74 -70
  16. package/dist/shared/components/RecordGridEditor.js +76 -75
  17. package/dist/shared/components/ReportView.js +818 -827
  18. package/dist/shared/components/SheetHeaderBody.js +16 -14
  19. package/dist/shared/components/ai/AiMemorySuggestions.js +15 -14
  20. package/dist/shared/components/ai/AskPanel.js +55 -54
  21. package/dist/shared/components/bulk/BulkActionButtons.js +30 -29
  22. package/dist/shared/components/bulk/PushBulkButtons.js +57 -56
  23. package/dist/shared/components/chat/SlashCommands.js +30 -29
  24. package/dist/shared/components/chat/chat-outbox.js +76 -75
  25. package/dist/shared/components/help-videos/recorder/useLeaveWarning.js +6 -5
  26. package/dist/shared/components/integrations/console/SignalCard.js +124 -123
  27. package/dist/shared/components/integrations/console/SnoozeMenu.js +24 -23
  28. package/dist/shared/components/item-edit/CatalogPickerField.js +1029 -933
  29. package/dist/shared/components/item-edit/CloneDialog.js +85 -78
  30. package/dist/shared/components/item-edit/FieldRenderer.js +161 -156
  31. package/dist/shared/components/item-edit/FieldRow.js +20 -19
  32. package/dist/shared/components/item-edit/FilePickerField.js +52 -40
  33. package/dist/shared/components/item-edit/GroupSection.js +221 -221
  34. package/dist/shared/components/item-edit/InlineGridField.js +41 -41
  35. package/dist/shared/components/item-edit/InlineTableField.js +2287 -2275
  36. package/dist/shared/components/item-edit/M2MCombobox.js +46 -44
  37. package/dist/shared/components/item-edit/MembershipSetField.js +24 -23
  38. package/dist/shared/components/item-edit/NestedRelationEditor.js +11 -11
  39. package/dist/shared/components/item-edit/QuickCreateButton.js +8 -7
  40. package/dist/shared/components/item-edit/QuickPicker.js +263 -216
  41. package/dist/shared/components/item-edit/RecordLiveSync.js +101 -100
  42. package/dist/shared/components/item-edit/RelationCombobox.js +285 -245
  43. package/dist/shared/components/item-edit/RichTextEditorImpl.js +42 -32
  44. package/dist/shared/components/item-edit/RowHistorySheet.js +130 -134
  45. package/dist/shared/components/item-edit/SummaryPanel.js +305 -279
  46. package/dist/shared/components/item-edit/helpers.js +133 -134
  47. package/dist/shared/components/item-edit/line-qty.js +57 -0
  48. package/dist/shared/components/item-edit/option-disambiguate.js +53 -0
  49. package/dist/shared/components/item-edit/staged-links.js +86 -0
  50. package/dist/shared/components/layout-editor/LayoutEditor.js +275 -274
  51. package/dist/shared/components/layout-editor/editors/cascade-rule-row.js +18 -17
  52. package/dist/shared/components/layout-editor/inspector/HelpTab.js +37 -36
  53. package/dist/shared/components/layout-editor/matrix/FieldStateMatrix.js +50 -49
  54. package/dist/shared/components/panels/AddendumLinesDiff.js +87 -90
  55. package/dist/shared/components/panels/CommentPanel.js +350 -315
  56. package/dist/shared/components/panels/ItemLockBanner.js +297 -230
  57. package/dist/shared/components/panels/PipelinePanel.js +719 -701
  58. package/dist/shared/components/profile/AiMemoryCard.js +15 -14
  59. package/dist/shared/components/profile/PersonAdminTools.js +70 -67
  60. package/dist/shared/components/queue/QueueItemSheet.js +36 -35
  61. package/dist/shared/components/queue/QueueQuickFilters.js +43 -41
  62. package/dist/shared/components/queue/QueueWorklist.js +1026 -957
  63. package/dist/shared/components/widgets/ReviewListWidget.js +99 -93
  64. package/dist/shared/lib/client-version.js +63 -0
  65. package/dist/shared/lib/force-reload.js +36 -0
  66. package/dist/shared/lib/load-error.js +11 -10
  67. package/dist/shared/lib/obligation-banner.js +14 -13
  68. package/dist/shared/lib/obligation-reason-text.js +13 -0
  69. package/dist/shared/lib/presence-live.js +54 -35
  70. package/dist/shared/lib/query-filter-seed.js +34 -11
  71. package/dist/shared/lib/record-outbox.js +76 -75
  72. package/dist/shared/lib/safe-error.js +39 -0
  73. package/dist/shared/lib/sanitize-html.js +24 -15
  74. package/dist/shared/lib/server-clock.js +11 -7
  75. package/dist/shared/lib/sheet-def.js +38 -22
  76. package/dist/shared/lib/unique-options.js +10 -0
  77. package/dist/shared/lib/unsaved-work.js +62 -0
  78. package/dist/shared/lib/utils.js +57 -43
  79. package/dist/shared/lib/validation-rules.js +58 -34
  80. package/package.json +1 -1
@@ -4,10 +4,11 @@ import { RotateCcw as we, ChevronDown as ee } from "lucide-react";
4
4
  import { useMemo as $, useState as te, useEffect as Re, Fragment as be } from "react";
5
5
  import { get as L } from "../../lib/commands.js";
6
6
  import { numericIntlOptions as Ne } from "../../lib/format-value.js";
7
- import { formatDateTime as ke, formatRelative as ve, cn as j, titleCase as Je, formatDate as Pe } from "../../lib/utils.js";
8
- import { Sheet as He, SheetContent as Ve, SheetHeader as Qe, SheetTitle as We } from "../ui/sheet.js";
9
- import { applyDisplayTemplate as Se, SYSTEM_FIELDS as Ue } from "./helpers.js";
10
- function Ye(f) {
7
+ import { htmlToText as Je } from "../../lib/sanitize-html.js";
8
+ import { formatDateTime as ke, formatRelative as ve, cn as j, titleCase as Pe, formatDate as Ve } from "../../lib/utils.js";
9
+ import { Sheet as He, SheetContent as Qe, SheetHeader as We, SheetTitle as Ue } from "../ui/sheet.js";
10
+ import { applyDisplayTemplate as Se, SYSTEM_FIELDS as Ye } from "./helpers.js";
11
+ function Ge(f) {
11
12
  const { data: x } = ne({
12
13
  queryKey: ["nvr-machine-markers"],
13
14
  queryFn: () => f.request(L("/comments/machine-markers")).then((b) => b.data ?? []),
@@ -16,17 +17,17 @@ function Ye(f) {
16
17
  });
17
18
  return x ?? [];
18
19
  }
19
- function Ge(f) {
20
+ function Xe(f) {
20
21
  const x = String(f ?? "").trim();
21
22
  if (!/^import:/i.test(x)) return null;
22
23
  const b = x.slice(7), k = b.lastIndexOf(":"), v = (k >= 0 ? b.slice(0, k) : b).trim() || "a file", N = k >= 0 ? b.slice(k + 1).trim() : "", S = /^run-(\d+)$/i.exec(N);
23
24
  return { template: v, fileId: S || !N ? null : N, runId: S ? Number(S[1]) : null };
24
25
  }
25
- function Xe(f, x = []) {
26
+ function Ze(f, x = []) {
26
27
  var N, S;
27
28
  const b = String(f ?? "").trim();
28
29
  if (!b) return { kind: "none", text: "" };
29
- const k = Ge(b);
30
+ const k = Xe(b);
30
31
  if (k) return { kind: "machine", text: `Imported via ${k.template}`, fileId: k.fileId };
31
32
  const v = b.toLowerCase();
32
33
  for (const O of x) {
@@ -37,8 +38,8 @@ function Xe(f, x = []) {
37
38
  }
38
39
  return { kind: "reason", text: b };
39
40
  }
40
- const Ze = /* @__PURE__ */ new Set(["sort", "created", "updated", "created_at", "updated_at"]), T = (f) => f == null || f === "", et = (f, x) => T(f) && T(x) ? !0 : typeof f == "object" || typeof x == "object" ? JSON.stringify(f) === JSON.stringify(x) : String(f) === String(x);
41
- function tt(f) {
41
+ const et = /* @__PURE__ */ new Set(["sort", "created", "updated", "created_at", "updated_at"]), I = (f) => f == null || f === "", tt = (f, x) => I(f) && I(x) ? !0 : typeof f == "object" || typeof x == "object" ? JSON.stringify(f) === JSON.stringify(x) : String(f) === String(x);
42
+ function nt(f) {
42
43
  const x = f == null ? void 0 : f.options;
43
44
  if (!x) return {};
44
45
  if (typeof x == "string")
@@ -49,7 +50,7 @@ function tt(f) {
49
50
  }
50
51
  return x;
51
52
  }
52
- function ut({
53
+ function ft({
53
54
  open: f,
54
55
  onOpenChange: x,
55
56
  rowTitle: b,
@@ -61,79 +62,79 @@ function ut({
61
62
  parentField: F,
62
63
  m2oRelMap: D,
63
64
  relations: E,
64
- collection: M,
65
+ collection: q,
65
66
  m2oDisplays: P,
66
- client: q,
67
+ client: M,
67
68
  allowRestore: re,
68
69
  onRestore: _e,
69
70
  mode: $e = "row",
70
71
  rowLabel: z,
71
- focusRevisionId: C = null,
72
+ focusRevisionId: A = null,
72
73
  truncated: je = !1,
73
- onRestoreAllTo: oe,
74
- restoringAll: se = !1
74
+ onRestoreAllTo: se,
75
+ restoringAll: oe = !1
75
76
  }) {
76
- const ie = Ke(), ae = Ye(q), y = $e === "timeline", le = $(() => new Map(S.map((e) => [e.field, e])), [S]), H = $(() => {
77
+ const ie = Ke(), ae = Ge(M), y = $e === "timeline", le = $(() => new Map(S.map((e) => [e.field, e])), [S]), V = $(() => {
77
78
  const e = new Map(D);
78
79
  for (const t of E) {
79
80
  const n = t.many_field;
80
- !n || t.many_collection !== M || t.junction_field || !t.one_collection || e.has(n) || e.set(n, t);
81
+ !n || t.many_collection !== q || t.junction_field || !t.one_collection || e.has(n) || e.set(n, t);
81
82
  }
82
83
  return e;
83
- }, [D, E, M]), V = $(() => {
84
+ }, [D, E, q]), H = $(() => {
84
85
  const e = /* @__PURE__ */ new Map();
85
86
  return O.forEach((t, n) => e.set(t.field, n)), S.forEach((t, n) => {
86
87
  e.has(t.field) || e.set(t.field, O.length + n);
87
88
  }), e;
88
- }, [O, S]), Q = (e) => !Ue.has(e) && !Ze.has(e) && e !== F && !e.startsWith("__"), de = (e, t) => {
89
- const n = [...e].sort((s, l) => s.id - l.id), r = [];
90
- let o = null;
91
- for (const s of n) {
92
- const l = [s.first_name, s.last_name].filter(Boolean).join(" ") || s.user_email || "System", u = String(s.action ?? "").toLowerCase(), d = u === "create" ? "create" : u === "update" ? "update" : u === "delete" ? "delete" : "other", i = s.data ?? {}, p = [], m = [];
89
+ }, [O, S]), Q = (e) => !Ye.has(e) && !et.has(e) && e !== F && !e.startsWith("__"), de = (e, t) => {
90
+ const n = [...e].sort((o, l) => o.id - l.id), r = [];
91
+ let s = null;
92
+ for (const o of n) {
93
+ const l = [o.first_name, o.last_name].filter(Boolean).join(" ") || o.user_email || "System", u = String(o.action ?? "").toLowerCase(), d = u === "create" ? "create" : u === "update" ? "update" : u === "delete" ? "delete" : "other", i = o.data ?? {}, p = [], m = [];
93
94
  if (d === "delete") {
94
- const g = o ?? i;
95
- for (const [h, A] of Object.entries(g))
96
- !Q(h) || T(A) || m.push({ field: h, value: A });
97
- } else if (d === "create" || !o)
95
+ const g = s ?? i;
96
+ for (const [h, C] of Object.entries(g))
97
+ !Q(h) || I(C) || m.push({ field: h, value: C });
98
+ } else if (d === "create" || !s)
98
99
  for (const [g, h] of Object.entries(i))
99
- !Q(g) || T(h) || m.push({ field: g, value: h });
100
+ !Q(g) || I(h) || m.push({ field: g, value: h });
100
101
  else {
101
- const g = s.delta ? Object.keys(s.delta) : Object.keys(i);
102
+ const g = o.delta ? Object.keys(o.delta) : Object.keys(i);
102
103
  for (const h of g) {
103
104
  if (!Q(h)) continue;
104
- const A = s.delta ? s.delta[h] : i[h], ye = o[h];
105
- et(ye, A) || p.push({ field: h, before: ye, after: A });
105
+ const C = o.delta ? o.delta[h] : i[h], ye = s[h];
106
+ tt(ye, C) || p.push({ field: h, before: ye, after: C });
106
107
  }
107
108
  }
108
- const w = (g, h) => (V.get(g) ?? 9999) - (V.get(h) ?? 9999);
109
+ const w = (g, h) => (H.get(g) ?? 9999) - (H.get(h) ?? 9999);
109
110
  p.sort((g, h) => w(g.field, h.field)), m.sort((g, h) => w(g.field, h.field)), r.push({
110
- rev: s,
111
+ rev: o,
111
112
  kind: d,
112
113
  who: l,
113
114
  changes: p,
114
115
  snapshot: m,
115
- provenance: Xe(s.comment, ae),
116
+ provenance: Ze(o.comment, ae),
116
117
  row: t,
117
- before: o
118
- }), d !== "delete" && Object.keys(i).length > 0 && (o = i);
118
+ before: s
119
+ }), d !== "delete" && Object.keys(i).length > 0 && (s = i);
119
120
  }
120
121
  return r.reverse();
121
122
  }, _ = $(() => {
122
123
  if (!y) return de(v, null);
123
124
  const e = /* @__PURE__ */ new Map();
124
125
  for (const n of v) {
125
- const r = String(n.item_id ?? ""), o = e.get(r) ?? [];
126
- o.push(n), e.set(r, o);
126
+ const r = String(n.item_id ?? ""), s = e.get(r) ?? [];
127
+ s.push(n), e.set(r, s);
127
128
  }
128
129
  const t = [];
129
130
  for (const [n, r] of e) {
130
- const o = [...r].sort((d, i) => i.id - d.id)[0], s = String((o == null ? void 0 : o.action) ?? "").toLowerCase() === "delete", l = [...r].sort((d, i) => i.id - d.id).find((d) => Object.keys(d.data ?? {}).length > 0), u = (z == null ? void 0 : z(n, (l == null ? void 0 : l.data) ?? (o == null ? void 0 : o.data) ?? {})) ?? { title: `#${n}` };
131
+ const s = [...r].sort((d, i) => i.id - d.id)[0], o = String((s == null ? void 0 : s.action) ?? "").toLowerCase() === "delete", l = [...r].sort((d, i) => i.id - d.id).find((d) => Object.keys(d.data ?? {}).length > 0), u = (z == null ? void 0 : z(n, (l == null ? void 0 : l.data) ?? (s == null ? void 0 : s.data) ?? {})) ?? { title: `#${n}` };
131
132
  t.push(
132
- ...de(r, { itemId: n, title: u.title, subtitle: u.subtitle, deleted: s })
133
+ ...de(r, { itemId: n, title: u.title, subtitle: u.subtitle, deleted: o })
133
134
  );
134
135
  }
135
136
  return t.sort((n, r) => r.rev.id - n.rev.id), t;
136
- }, [v, V, F, y, z, ae]), B = $(() => {
137
+ }, [v, H, F, y, z, ae]), B = $(() => {
137
138
  if (!y)
138
139
  return _.map((n) => ({
139
140
  key: n.rev.id,
@@ -144,8 +145,8 @@ function ut({
144
145
  const e = [];
145
146
  let t = null;
146
147
  for (const n of _) {
147
- const r = n.rev.timestamp ? new Date(n.rev.timestamp).getTime() : NaN, o = t != null && t.lastAt ? new Date(t.lastAt).getTime() : NaN;
148
- t && t.who === n.who && Number.isFinite(r) && Number.isFinite(o) && Math.abs(o - r) <= 5e3 && !t.versions.some((l) => {
148
+ const r = n.rev.timestamp ? new Date(n.rev.timestamp).getTime() : NaN, s = t != null && t.lastAt ? new Date(t.lastAt).getTime() : NaN;
149
+ t && t.who === n.who && Number.isFinite(r) && Number.isFinite(s) && Math.abs(s - r) <= 5e3 && !t.versions.some((l) => {
149
150
  var u, d;
150
151
  return ((u = l.row) == null ? void 0 : u.itemId) === ((d = n.row) == null ? void 0 : d.itemId);
151
152
  }) && t ? (t.versions.push(n), t.lastAt = n.rev.timestamp) : (t = {
@@ -160,26 +161,26 @@ function ut({
160
161
  }, [_, y]), K = $(() => {
161
162
  const e = /* @__PURE__ */ new Map();
162
163
  for (const t of E)
163
- t.one_collection === M && t.one_field && e.set(t.one_field, t);
164
+ t.one_collection === q && t.one_field && e.set(t.one_field, t);
164
165
  return e;
165
- }, [E, M]), ce = (e, t) => {
166
+ }, [E, q]), ce = (e, t) => {
166
167
  if (t == null) return null;
167
168
  if (typeof t != "object") return String(t);
168
169
  const n = t;
169
170
  if (e.junction_field && n[e.junction_field] != null) return String(n[e.junction_field]);
170
- const r = Object.keys(n).filter((o) => o !== "id" && o !== e.many_field);
171
+ const r = Object.keys(n).filter((s) => s !== "id" && s !== e.many_field);
171
172
  return r.length === 1 && n[r[0]] != null && typeof n[r[0]] != "object" ? String(n[r[0]]) : n.id != null ? String(n.id) : null;
172
173
  }, R = $(() => {
173
174
  const e = /* @__PURE__ */ new Map(), t = (n, r) => {
174
175
  if (!Array.isArray(r)) return;
175
- const o = K.get(n);
176
- if (!o) return;
177
- const s = e.get(n) ?? /* @__PURE__ */ new Set();
176
+ const s = K.get(n);
177
+ if (!s) return;
178
+ const o = e.get(n) ?? /* @__PURE__ */ new Set();
178
179
  for (const l of r) {
179
- const u = ce(o, l);
180
- u != null && s.add(u);
180
+ const u = ce(s, l);
181
+ u != null && o.add(u);
181
182
  }
182
- s.size && e.set(n, s);
183
+ o.size && e.set(n, o);
183
184
  };
184
185
  for (const n of _) {
185
186
  for (const r of n.changes)
@@ -190,29 +191,29 @@ function ut({
190
191
  }, [_, K]), Oe = $(
191
192
  () => [...R.entries()].map(([e, t]) => `${e}:${[...t].sort().join(",")}`).sort().join("|"),
192
193
  [R]
193
- ), { data: Ie = {} } = ne({
194
- queryKey: ["row-history-alias-labels", M, Oe],
194
+ ), { data: Te = {} } = ne({
195
+ queryKey: ["row-history-alias-labels", q, Oe],
195
196
  queryFn: async () => {
196
197
  const e = {}, t = (n) => ie.fetchQuery({
197
198
  queryKey: ["collection-meta", n],
198
- queryFn: () => q.request(L(`/collections/${n}`)).then((r) => r.data),
199
+ queryFn: () => M.request(L(`/collections/${n}`)).then((r) => r.data),
199
200
  staleTime: 6e5
200
201
  });
201
202
  return await Promise.all(
202
203
  [...R.entries()].map(async ([n, r]) => {
203
- const o = K.get(n);
204
- if (!o) return;
205
- let s = null;
206
- if (o.junction_field && o.many_collection) {
207
- const m = await t(o.many_collection).catch(() => null), w = ((m == null ? void 0 : m.relations) ?? []).find(
208
- (g) => g.many_collection === o.many_collection && g.many_field === o.junction_field
204
+ const s = K.get(n);
205
+ if (!s) return;
206
+ let o = null;
207
+ if (s.junction_field && s.many_collection) {
208
+ const m = await t(s.many_collection).catch(() => null), w = ((m == null ? void 0 : m.relations) ?? []).find(
209
+ (g) => g.many_collection === s.many_collection && g.many_field === s.junction_field
209
210
  );
210
- s = (w == null ? void 0 : w.one_collection) ?? null;
211
+ o = (w == null ? void 0 : w.one_collection) ?? null;
211
212
  } else
212
- s = o.many_collection ?? null;
213
- if (!s) return;
214
- const l = await t(s).catch(() => null), u = (l == null ? void 0 : l.display_template) ?? void 0, d = u ? [...u.matchAll(/\{\{([\w.]+)\}\}/g)].map((m) => m[1]) : [], i = d.some((m) => m.includes(".")) ? ["id", ...d].join(",") : void 0, p = await q.request(
215
- L(`/items/${s}`, {
213
+ o = s.many_collection ?? null;
214
+ if (!o) return;
215
+ const l = await t(o).catch(() => null), u = (l == null ? void 0 : l.display_template) ?? void 0, d = u ? [...u.matchAll(/\{\{([\w.]+)\}\}/g)].map((m) => m[1]) : [], i = d.some((m) => m.includes(".")) ? ["id", ...d].join(",") : void 0, p = await M.request(
216
+ L(`/items/${o}`, {
216
217
  filter: JSON.stringify({ id: { _in: [...r] } }),
217
218
  limit: r.size,
218
219
  ...i ? { fields: i } : {}
@@ -231,11 +232,11 @@ function ut({
231
232
  }), J = $(() => {
232
233
  const e = /* @__PURE__ */ new Map(), t = (n, r) => {
233
234
  var l;
234
- if (T(r) || typeof r == "object") return;
235
- const o = H.get(n);
236
- if (!(o != null && o.one_collection) || (l = P[o.one_collection]) != null && l[String(r)]) return;
237
- const s = e.get(o.one_collection) ?? /* @__PURE__ */ new Set();
238
- s.add(String(r)), e.set(o.one_collection, s);
235
+ if (I(r) || typeof r == "object") return;
236
+ const s = V.get(n);
237
+ if (!(s != null && s.one_collection) || (l = P[s.one_collection]) != null && l[String(r)]) return;
238
+ const o = e.get(s.one_collection) ?? /* @__PURE__ */ new Set();
239
+ o.add(String(r)), e.set(s.one_collection, o);
239
240
  };
240
241
  for (const n of _) {
241
242
  for (const r of n.changes)
@@ -243,22 +244,22 @@ function ut({
243
244
  for (const r of n.snapshot) t(r.field, r.value);
244
245
  }
245
246
  return e;
246
- }, [_, H, P]), Te = $(
247
+ }, [_, V, P]), Ie = $(
247
248
  () => [...J.entries()].map(([e, t]) => `${e}:${[...t].sort().join(",")}`).sort().join("|"),
248
249
  [J]
249
250
  ), { data: Fe = {} } = ne({
250
- queryKey: ["row-history-labels", Te],
251
+ queryKey: ["row-history-labels", Ie],
251
252
  queryFn: async () => {
252
253
  const e = {};
253
254
  return await Promise.all(
254
255
  [...J.entries()].map(async ([t, n]) => {
255
256
  const r = await ie.fetchQuery({
256
257
  queryKey: ["collection-display-meta", t],
257
- queryFn: () => q.request(
258
+ queryFn: () => M.request(
258
259
  L(`/collections/${t}`)
259
260
  ).then((d) => d.data),
260
261
  staleTime: 6e5
261
- }), o = (r == null ? void 0 : r.display_template) ?? void 0, s = o ? [...o.matchAll(/\{\{([\w.]+)\}\}/g)].map((d) => d[1]) : [], l = s.some((d) => d.includes(".")) ? ["id", ...s].join(",") : void 0, u = await q.request(
262
+ }), s = (r == null ? void 0 : r.display_template) ?? void 0, o = s ? [...s.matchAll(/\{\{([\w.]+)\}\}/g)].map((d) => d[1]) : [], l = o.some((d) => d.includes(".")) ? ["id", ...o].join(",") : void 0, u = await M.request(
262
263
  L(`/items/${t}`, {
263
264
  filter: JSON.stringify({ id: { _in: [...n] } }),
264
265
  limit: n.size,
@@ -266,21 +267,21 @@ function ut({
266
267
  })
267
268
  ).then((d) => d.data ?? []);
268
269
  e[t] = {};
269
- for (const d of u) e[t][String(d.id)] = Se(o, d);
270
+ for (const d of u) e[t][String(d.id)] = Se(s, d);
270
271
  })
271
272
  ), e;
272
273
  },
273
274
  enabled: f && J.size > 0,
274
275
  staleTime: 5 * 6e4
275
- }), I = (e) => {
276
+ }), T = (e) => {
276
277
  const t = le.get(e);
277
- return (t == null ? void 0 : t.label) || Je(e);
278
+ return (t == null ? void 0 : t.label) || Pe(e);
278
279
  }, W = (e, t) => {
279
280
  var u, d;
280
- if (T(t)) return { text: "—" };
281
- const n = le.get(e), r = tt(n), o = H.get(e);
282
- if (o != null && o.one_collection) {
283
- const i = ((u = P[o.one_collection]) == null ? void 0 : u[String(t)]) ?? ((d = Fe[o.one_collection]) == null ? void 0 : d[String(t)]);
281
+ if (I(t)) return { text: "—" };
282
+ const n = le.get(e), r = nt(n), s = V.get(e);
283
+ if (s != null && s.one_collection) {
284
+ const i = ((u = P[s.one_collection]) == null ? void 0 : u[String(t)]) ?? ((d = Fe[s.one_collection]) == null ? void 0 : d[String(t)]);
284
285
  return i ? { text: i } : { text: `#${String(t)}`, mono: !0 };
285
286
  }
286
287
  if (typeof t == "boolean" || (n == null ? void 0 : n.type) === "boolean")
@@ -291,7 +292,7 @@ function ut({
291
292
  const m = t.map((w) => {
292
293
  var h;
293
294
  const g = ce(i, w);
294
- return g == null ? null : ((h = Ie[e]) == null ? void 0 : h[g]) ?? `#${g}`;
295
+ return g == null ? null : ((h = Te[e]) == null ? void 0 : h[g]) ?? `#${g}`;
295
296
  }).filter((w) => !!w);
296
297
  return m.length ? { text: m.join(", ") } : { text: "—" };
297
298
  }
@@ -301,7 +302,7 @@ function ut({
301
302
  };
302
303
  }
303
304
  if (typeof t == "object") return { text: JSON.stringify(t), mono: !0 };
304
- const s = (n == null ? void 0 : n.type) ?? "";
305
+ const o = (n == null ? void 0 : n.type) ?? "";
305
306
  if (r.format === "currency" && Number.isFinite(Number(t)))
306
307
  return {
307
308
  text: Number(t).toLocaleString("en-US", {
@@ -310,41 +311,36 @@ function ut({
310
311
  }),
311
312
  mono: !0
312
313
  };
313
- if (/^(date|dateTime|datetime|timestamp)$/i.test(s)) {
314
+ if (/^(date|dateTime|datetime|timestamp)$/i.test(o)) {
314
315
  const i = String(t);
315
- return { text: /^\d{4}-\d{2}-\d{2}$/.test(i) ? Pe(i) : ke(i), mono: !0 };
316
+ return { text: /^\d{4}-\d{2}-\d{2}$/.test(i) ? Ve(i) : ke(i), mono: !0 };
316
317
  }
317
- if (typeof t == "number" || /^(integer|decimal|float|bigInteger|money)$/i.test(s) && Number.isFinite(Number(t)))
318
+ if (typeof t == "number" || /^(integer|decimal|float|bigInteger|money)$/i.test(o) && Number.isFinite(Number(t)))
318
319
  return { text: Number(t).toLocaleString("en-US", Ne(r)), mono: !0 };
319
320
  const l = String(t);
320
- if (/<[a-z][\s\S]*>/i.test(l)) {
321
- const i = typeof document < "u" ? document.createElement("div") : null;
322
- if (i)
323
- return i.innerHTML = l, { text: (i.textContent || "").trim() || "—" };
324
- }
325
- return { text: l };
326
- }, [Me, qe] = te(/* @__PURE__ */ new Set()), Ce = (e) => qe((t) => {
321
+ return /<[a-z][\s\S]*>/i.test(l) ? { text: Je(l).trim() || "—" } : { text: l };
322
+ }, [qe, Me] = te(/* @__PURE__ */ new Set()), Ae = (e) => Me((t) => {
327
323
  const n = new Set(t);
328
324
  return n.has(e) ? n.delete(e) : n.add(e), n;
329
- }), [Ae, ue] = te(/* @__PURE__ */ new Set()), me = (e) => ue((t) => {
325
+ }), [Ce, ue] = te(/* @__PURE__ */ new Set()), me = (e) => ue((t) => {
330
326
  const n = new Set(t);
331
327
  return n.has(e) ? n.delete(e) : n.add(e), n;
332
328
  }), U = 4, [fe, Y] = te(null);
333
329
  Re(() => {
334
- if (!f || C == null || N) {
330
+ if (!f || A == null || N) {
335
331
  f || Y(null);
336
332
  return;
337
333
  }
338
- const e = B.find((r) => r.versions.some((o) => o.rev.id === C));
339
- e && e.versions.length > U && ue((r) => r.has(e.key) ? r : new Set(r).add(e.key)), Y(C);
334
+ const e = B.find((r) => r.versions.some((s) => s.rev.id === A));
335
+ e && e.versions.length > U && ue((r) => r.has(e.key) ? r : new Set(r).add(e.key)), Y(A);
340
336
  const t = window.setTimeout(() => {
341
- const r = document.querySelector(`[data-rev-id="${C}"]`);
337
+ const r = document.querySelector(`[data-rev-id="${A}"]`);
342
338
  r == null || r.scrollIntoView({ block: "center", behavior: "smooth" });
343
339
  }, 60), n = window.setTimeout(() => Y(null), 3200);
344
340
  return () => {
345
341
  window.clearTimeout(t), window.clearTimeout(n);
346
342
  };
347
- }, [f, C, N, B]);
343
+ }, [f, A, N, B]);
348
344
  const Le = (e) => {
349
345
  const t = y && e.row ? e.row.title : "this line";
350
346
  if (e.kind === "create") return `added ${t}`;
@@ -352,12 +348,12 @@ function ut({
352
348
  if (e.changes.length === 0)
353
349
  return !e.before && y ? `saved ${t}` : y ? `saved ${t} without changes` : "saved it without changes";
354
350
  const n = y ? ` on ${t}` : "";
355
- return e.changes.length === 1 ? `changed ${I(e.changes[0].field)}${n}` : e.changes.length === 2 ? `changed ${I(e.changes[0].field)} and ${I(e.changes[1].field)}${n}` : `changed ${e.changes.length} fields${n}`;
351
+ return e.changes.length === 1 ? `changed ${T(e.changes[0].field)}${n}` : e.changes.length === 2 ? `changed ${T(e.changes[0].field)} and ${T(e.changes[1].field)}${n}` : `changed ${e.changes.length} fields${n}`;
356
352
  }, De = (e) => {
357
- const t = e.versions.filter((l) => l.kind === "create").length, n = e.versions.filter((l) => l.kind === "delete").length, r = e.versions.length - t - n, o = [];
358
- t && o.push(`added ${t}`), r && o.push(`changed ${r}`), n && o.push(`deleted ${n}`);
359
- const s = e.versions.length;
360
- return `saved ${s} ${s === 1 ? "line" : "lines"} · ${o.join(", ")}`;
353
+ const t = e.versions.filter((l) => l.kind === "create").length, n = e.versions.filter((l) => l.kind === "delete").length, r = e.versions.length - t - n, s = [];
354
+ t && s.push(`added ${t}`), r && s.push(`changed ${r}`), n && s.push(`deleted ${n}`);
355
+ const o = e.versions.length;
356
+ return `saved ${o} ${o === 1 ? "line" : "lines"} · ${s.join(", ")}`;
361
357
  }, Ee = (e) => {
362
358
  var t, n;
363
359
  return {
@@ -365,7 +361,7 @@ function ut({
365
361
  rowDeleted: !!((n = e.row) != null && n.deleted)
366
362
  };
367
363
  }, he = (e) => {
368
- const t = Me.has(e.rev.id), n = 6, r = t ? e.snapshot : e.snapshot.slice(0, n), o = e.snapshot.length - r.length;
364
+ const t = qe.has(e.rev.id), n = 6, r = t ? e.snapshot : e.snapshot.slice(0, n), s = e.snapshot.length - r.length;
369
365
  return /* @__PURE__ */ c(Z, { children: [
370
366
  e.provenance.kind === "machine" && /* @__PURE__ */ c("p", { className: "mt-0.5 text-[11.5px] text-muted-foreground", children: [
371
367
  e.provenance.text,
@@ -387,10 +383,10 @@ function ut({
387
383
  /* @__PURE__ */ a("span", { className: "text-muted-foreground", children: "Reason: " }),
388
384
  e.provenance.text
389
385
  ] }),
390
- e.changes.length > 0 && /* @__PURE__ */ a("dl", { className: "mt-2 grid grid-cols-[minmax(96px,max-content)_1fr] gap-x-4 gap-y-1.5 text-[12px] leading-5", children: e.changes.map((s) => {
391
- const l = W(s.field, s.before), u = W(s.field, s.after);
386
+ e.changes.length > 0 && /* @__PURE__ */ a("dl", { className: "mt-2 grid grid-cols-[minmax(96px,max-content)_1fr] gap-x-4 gap-y-1.5 text-[12px] leading-5", children: e.changes.map((o) => {
387
+ const l = W(o.field, o.before), u = W(o.field, o.after);
392
388
  return /* @__PURE__ */ c(be, { children: [
393
- /* @__PURE__ */ a("dt", { className: "truncate text-muted-foreground", title: I(s.field), children: I(s.field) }),
389
+ /* @__PURE__ */ a("dt", { className: "truncate text-muted-foreground", title: T(o.field), children: T(o.field) }),
394
390
  /* @__PURE__ */ c("dd", { className: "flex min-w-0 flex-wrap items-baseline gap-x-1.5", children: [
395
391
  /* @__PURE__ */ a(
396
392
  "span",
@@ -416,7 +412,7 @@ function ut({
416
412
  }
417
413
  )
418
414
  ] })
419
- ] }, s.field);
415
+ ] }, o.field);
420
416
  }) }),
421
417
  e.snapshot.length > 0 && /* @__PURE__ */ c(Z, { children: [
422
418
  /* @__PURE__ */ a(
@@ -426,10 +422,10 @@ function ut({
426
422
  "mt-2 grid grid-cols-[minmax(96px,max-content)_1fr] gap-x-4 gap-y-1 text-[12px] leading-5",
427
423
  e.kind === "delete" && "text-muted-foreground"
428
424
  ),
429
- children: r.map((s) => {
430
- const l = W(s.field, s.value);
425
+ children: r.map((o) => {
426
+ const l = W(o.field, o.value);
431
427
  return /* @__PURE__ */ c(be, { children: [
432
- /* @__PURE__ */ a("dt", { className: "truncate text-muted-foreground", title: I(s.field), children: I(s.field) }),
428
+ /* @__PURE__ */ a("dt", { className: "truncate text-muted-foreground", title: T(o.field), children: T(o.field) }),
433
429
  /* @__PURE__ */ a(
434
430
  "dd",
435
431
  {
@@ -441,15 +437,15 @@ function ut({
441
437
  children: l.text
442
438
  }
443
439
  )
444
- ] }, s.field);
440
+ ] }, o.field);
445
441
  })
446
442
  }
447
443
  ),
448
- (o > 0 || t) && e.snapshot.length > n && /* @__PURE__ */ c(
444
+ (s > 0 || t) && e.snapshot.length > n && /* @__PURE__ */ c(
449
445
  "button",
450
446
  {
451
447
  type: "button",
452
- onClick: () => Ce(e.rev.id),
448
+ onClick: () => Ae(e.rev.id),
453
449
  className: "mt-1.5 inline-flex items-center gap-1 text-[11.5px] font-medium text-muted-foreground transition-colors duration-150 hover:text-foreground",
454
450
  "aria-expanded": t,
455
451
  children: [
@@ -463,7 +459,7 @@ function ut({
463
459
  "aria-hidden": "true"
464
460
  }
465
461
  ),
466
- t ? "Show fewer" : `Show ${o} more ${o === 1 ? "field" : "fields"}`
462
+ t ? "Show fewer" : `Show ${s} more ${s === 1 ? "field" : "fields"}`
467
463
  ]
468
464
  }
469
465
  )
@@ -481,9 +477,9 @@ function ut({
481
477
  var t;
482
478
  return G.get(((t = e.row) == null ? void 0 : t.itemId) ?? "") === e.rev.id;
483
479
  }, ge = (e, t) => {
484
- var o;
480
+ var s;
485
481
  if (!pe(e, t)) return null;
486
- const n = e.kind === "delete" || !!((o = e.row) != null && o.deleted), r = e.kind === "delete" ? Object.fromEntries(e.snapshot.map((s) => [s.field, s.value])) : e.rev.data;
482
+ const n = e.kind === "delete" || !!((s = e.row) != null && s.deleted), r = e.kind === "delete" ? Object.fromEntries(e.snapshot.map((o) => [o.field, o.value])) : e.rev.data;
487
483
  return /* @__PURE__ */ c(
488
484
  "button",
489
485
  {
@@ -509,9 +505,9 @@ function ut({
509
505
  ),
510
506
  !n && /* @__PURE__ */ a("span", { className: "absolute bottom-[-24px] top-[11px] w-px bg-border" })
511
507
  ] }), X = _.length, Be = y ? `${X} ${X === 1 ? "version" : "versions"} across ${G.size} ${G.size === 1 ? "line" : "lines"}` : `${v.length} ${v.length === 1 ? "version" : "versions"}`;
512
- return /* @__PURE__ */ a(He, { open: f, onOpenChange: x, children: /* @__PURE__ */ c(Ve, { className: "flex w-[560px] flex-col gap-0 p-0 sm:max-w-[560px]", children: [
513
- /* @__PURE__ */ c(Qe, { className: "shrink-0 border-b border-border px-6 pb-4 pt-5 text-left", children: [
514
- /* @__PURE__ */ a(We, { className: "text-[14px] font-semibold", children: y ? "Lines timeline" : "Row history" }),
508
+ return /* @__PURE__ */ a(He, { open: f, onOpenChange: x, children: /* @__PURE__ */ c(Qe, { className: "flex w-[560px] flex-col gap-0 p-0 sm:max-w-[560px]", children: [
509
+ /* @__PURE__ */ c(We, { className: "shrink-0 border-b border-border px-6 pb-4 pt-5 text-left", children: [
510
+ /* @__PURE__ */ a(Ue, { className: "text-[14px] font-semibold", children: y ? "Lines timeline" : "Row history" }),
515
511
  /* @__PURE__ */ c("p", { className: "mt-0.5 flex min-w-0 items-baseline gap-2 text-[12px] text-muted-foreground", children: [
516
512
  /* @__PURE__ */ a("span", { className: "shrink-0 font-medium text-foreground", children: b }),
517
513
  k && /* @__PURE__ */ a("span", { className: "truncate", children: k }),
@@ -531,21 +527,21 @@ function ut({
531
527
  /* @__PURE__ */ a("p", { className: "mt-1 text-[12px] text-muted-foreground", children: y ? "Every line added, changed or removed on this record will be listed here." : "Every save of this line will be listed here with what changed." })
532
528
  ] }) : /* @__PURE__ */ a("ol", { className: "relative", children: B.map((e, t) => {
533
529
  var d;
534
- const n = t === 0, r = t === B.length - 1, o = e.at ? ke(e.at) : "", s = e.versions.length > 1, l = s && e.versions.length > U && !Ae.has(e.key), u = y && re && oe && !n && e.at ? /* @__PURE__ */ c(
530
+ const n = t === 0, r = t === B.length - 1, s = e.at ? ke(e.at) : "", o = e.versions.length > 1, l = o && e.versions.length > U && !Ce.has(e.key), u = y && re && se && !n && e.at ? /* @__PURE__ */ c(
535
531
  "button",
536
532
  {
537
533
  type: "button",
538
- disabled: se,
539
- onClick: () => oe(e.at),
534
+ disabled: oe,
535
+ onClick: () => se(e.at),
540
536
  className: "ml-auto inline-flex items-center gap-1 rounded-md px-1.5 py-0.5 text-[11px] font-medium text-muted-foreground transition-colors duration-150 hover:bg-muted hover:text-foreground disabled:opacity-50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-nvr-cyan",
541
537
  "data-tip": "Put every line back to how it stood right after this save — writes immediately",
542
538
  children: [
543
539
  /* @__PURE__ */ a(we, { className: "h-3 w-3", "aria-hidden": "true" }),
544
- se ? "Restoring…" : "All lines to here"
540
+ oe ? "Restoring…" : "All lines to here"
545
541
  ]
546
542
  }
547
543
  ) : null;
548
- if (!s) {
544
+ if (!o) {
549
545
  const i = e.versions[0], p = n;
550
546
  return /* @__PURE__ */ c(
551
547
  "li",
@@ -567,7 +563,7 @@ function ut({
567
563
  i.row.subtitle
568
564
  ] }),
569
565
  /* @__PURE__ */ a("span", { className: "text-muted-foreground", children: "·" }),
570
- /* @__PURE__ */ a("span", { className: "text-muted-foreground", "data-tip": o || void 0, children: i.rev.timestamp ? ve(i.rev.timestamp) : "" }),
566
+ /* @__PURE__ */ a("span", { className: "text-muted-foreground", "data-tip": s || void 0, children: i.rev.timestamp ? ve(i.rev.timestamp) : "" }),
571
567
  p && !y && /* @__PURE__ */ a("span", { className: "ml-auto rounded-full bg-nvr-cyan/10 px-2 py-px text-[10.5px] font-medium text-[#0b7ea6] dark:text-nvr-cyan", children: "Current" }),
572
568
  (pe(i, p) || u) && /* @__PURE__ */ c("span", { className: "ml-auto inline-flex items-center gap-1", children: [
573
569
  ge(i, p),
@@ -593,7 +589,7 @@ function ut({
593
589
  /* @__PURE__ */ a("span", { className: "font-semibold text-foreground", children: e.who }),
594
590
  /* @__PURE__ */ a("span", { className: "text-muted-foreground", children: De(e) }),
595
591
  /* @__PURE__ */ a("span", { className: "text-muted-foreground", children: "·" }),
596
- /* @__PURE__ */ a("span", { className: "text-muted-foreground", "data-tip": o || void 0, children: e.at ? ve(e.at) : "" }),
592
+ /* @__PURE__ */ a("span", { className: "text-muted-foreground", "data-tip": s || void 0, children: e.at ? ve(e.at) : "" }),
597
593
  u
598
594
  ] }),
599
595
  l ? /* @__PURE__ */ c(
@@ -633,7 +629,7 @@ function ut({
633
629
  children: ((p = i.row) == null ? void 0 : p.title) ?? "Line"
634
630
  }
635
631
  ),
636
- /* @__PURE__ */ a("span", { className: "text-muted-foreground", children: i.kind === "create" ? "added" : i.kind === "delete" ? "deleted" : i.changes.length === 0 ? "saved" : `${i.changes.map((w) => I(w.field)).slice(0, 3).join(
632
+ /* @__PURE__ */ a("span", { className: "text-muted-foreground", children: i.kind === "create" ? "added" : i.kind === "delete" ? "deleted" : i.changes.length === 0 ? "saved" : `${i.changes.map((w) => T(w.field)).slice(0, 3).join(
637
633
  ", "
638
634
  )}${i.changes.length > 3 ? ` +${i.changes.length - 3}` : ""}` }),
639
635
  ((m = i.row) == null ? void 0 : m.subtitle) && /* @__PURE__ */ c("span", { className: "truncate text-muted-foreground", children: [
@@ -671,8 +667,8 @@ function ut({
671
667
  ] }) });
672
668
  }
673
669
  export {
674
- ut as RowHistorySheet,
675
- Ge as parseImportStamp,
676
- Xe as provenanceOf,
677
- Ye as useMachineMarkers
670
+ ft as RowHistorySheet,
671
+ Xe as parseImportStamp,
672
+ Ze as provenanceOf,
673
+ Ge as useMachineMarkers
678
674
  };