@nivaro/react 0.3.58 → 0.3.60

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 (43) hide show
  1. package/dist/components/fields/RelationField.js +110 -80
  2. package/dist/full.css +1 -1
  3. package/dist/hooks/useRelationOptions.js +1 -0
  4. package/dist/hooks/useSessionRecorder.js +1 -1
  5. package/dist/index.d.ts +32 -1
  6. package/dist/index.js +523 -520
  7. package/dist/shared/components/CollectionBrowserView.js +2083 -2052
  8. package/dist/shared/components/DataTable.js +497 -465
  9. package/dist/shared/components/ItemEditForm.js +4430 -4282
  10. package/dist/shared/components/PageRenderer.js +537 -508
  11. package/dist/shared/components/QueryTable.js +74 -74
  12. package/dist/shared/components/WidgetSlot.js +543 -520
  13. package/dist/shared/components/alerts/AlertManagerView.js +269 -275
  14. package/dist/shared/components/alerts/types.js +37 -14
  15. package/dist/shared/components/item-edit/FieldRenderer.js +22 -20
  16. package/dist/shared/components/item-edit/GridBulkEditDialog.js +55 -54
  17. package/dist/shared/components/item-edit/InlineTableField.js +2461 -2421
  18. package/dist/shared/components/item-edit/M2MCombobox.js +141 -137
  19. package/dist/shared/components/item-edit/PlanGrid.js +876 -820
  20. package/dist/shared/components/item-edit/QuickCreateButton.js +323 -130
  21. package/dist/shared/components/item-edit/RelationCombobox.js +408 -375
  22. package/dist/shared/components/item-edit/RelationGroupedCombobox.js +255 -156
  23. package/dist/shared/components/item-edit/SummaryPanel.js +356 -343
  24. package/dist/shared/components/item-edit/duplicate-rehearsal.js +47 -0
  25. package/dist/shared/components/item-edit/line-midair.js +82 -75
  26. package/dist/shared/components/item-edit/save-outcome.js +6 -4
  27. package/dist/shared/components/panels/ItemLockBanner.js +212 -209
  28. package/dist/shared/components/panels/PipelinePanel.js +775 -737
  29. package/dist/shared/components/panels/RecordIntegrityBanner.js +114 -86
  30. package/dist/shared/components/panels/RevisionsPanel.js +313 -299
  31. package/dist/shared/components/pipeline/PipelineEditorView.js +26 -16
  32. package/dist/shared/components/queue/QueueQuickFilters.js +13 -13
  33. package/dist/shared/components/queue/QueueWorklist.js +978 -953
  34. package/dist/shared/components/queue/live-state-aspect.js +9 -5
  35. package/dist/shared/components/widgets/ReviewListWidget.js +152 -149
  36. package/dist/shared/lib/display-prefs.js +60 -52
  37. package/dist/shared/lib/draft-store.js +71 -48
  38. package/dist/shared/lib/expression.js +53 -53
  39. package/dist/shared/lib/list-page-memory.js +42 -20
  40. package/dist/shared/lib/money-input.js +45 -0
  41. package/dist/shared/lib/sanitize-html.js +10 -6
  42. package/dist/shared/lib/staged-row-labels.js +18 -0
  43. package/package.json +1 -1
@@ -1,26 +1,26 @@
1
1
  import { jsxs as l, jsx as t, Fragment as L } from "react/jsx-runtime";
2
- import { useQuery as B, useQueryClient as ee, useMutation as Q } from "@tanstack/react-query";
3
- import { Clock as Y, Search as Se, X as Ce, CalendarClock as _e, GitCompareArrows as Te, ChevronDown as Re, ChevronRight as je, MessageSquare as Ae, RotateCcw as de, ArrowRight as Le } from "lucide-react";
4
- import { useState as v, useRef as $e, useMemo as A, createContext as Oe, useEffect as qe, useContext as ce } from "react";
5
- import { toast as j } from "sonner";
2
+ import { useQuery as P, useQueryClient as ee, useMutation as Q } from "@tanstack/react-query";
3
+ import { Clock as Y, Search as Ce, X as _e, CalendarClock as Te, GitCompareArrows as Re, ChevronDown as je, ChevronRight as Ae, MessageSquare as Le, RotateCcw as ie, ArrowRight as $e } from "lucide-react";
4
+ import { useState as w, useRef as Oe, useMemo as R, createContext as De, useEffect as qe, useContext as ce } from "react";
5
+ import { toast as A } from "sonner";
6
6
  import { useNivaroClient as F } from "../../context.js";
7
- import { o2mSentence as De, activityPredicate as Fe, activityWhy as Ee, actorName as Pe } from "../../lib/activity-sentence.js";
8
- import { get as D, post as K } from "../../lib/commands.js";
9
- import { useLiveRecordQueries as Be } from "../../lib/live.js";
7
+ import { o2mSentence as Fe, activityPredicate as Ee, activityWhy as Be, actorName as Pe } from "../../lib/activity-sentence.js";
8
+ import { get as q, post as K } from "../../lib/commands.js";
9
+ import { useLiveRecordQueries as Ie } from "../../lib/live.js";
10
10
  import { restoreSkippedNote as se } from "../../lib/restore-skipped.js";
11
- import { cn as T, titleCase as me, toLocalDateString as Ie } from "../../lib/utils.js";
12
- import { useActivityLabels as Ke } from "../ActivityEntry.js";
13
- import { AgentBadge as Me } from "../AgentBadge.js";
14
- import { RelatedItemLabel as Ue } from "../item-edit/RelationCombobox.js";
11
+ import { cn as T, titleCase as me, toLocalDateString as Ke } from "../../lib/utils.js";
12
+ import { useActivityLabels as Me } from "../ActivityEntry.js";
13
+ import { AgentBadge as Ue } from "../AgentBadge.js";
14
+ import { RelatedItemLabel as We } from "../item-edit/RelationCombobox.js";
15
15
  import { UserAvatar as pe } from "../UserAvatar.js";
16
16
  import { Button as M } from "../ui/button.js";
17
- import { Sheet as We, SheetTrigger as Ve, SheetContent as ze, SheetHeader as He, SheetTitle as Je } from "../ui/sheet.js";
18
- import { Skeleton as Qe } from "../ui/skeleton.js";
19
- import { IntegrationActivitySection as Ye } from "./IntegrationActivitySection.js";
20
- const G = (e) => e.id != null && (e.action === "create" || e.action === "update" || e.action === "delete" || e.action === "restore"), Ge = (e) => !G(e), O = (e) => {
17
+ import { Sheet as Ve, SheetTrigger as ze, SheetContent as He, SheetHeader as Je, SheetTitle as Qe } from "../ui/sheet.js";
18
+ import { Skeleton as Ye } from "../ui/skeleton.js";
19
+ import { IntegrationActivitySection as Ge } from "./IntegrationActivitySection.js";
20
+ const G = (e) => e.id != null && (e.action === "create" || e.action === "update" || e.action === "delete" || e.action === "restore"), Xe = (e) => !G(e), O = (e) => {
21
21
  var s;
22
22
  return e.id != null ? `r${e.id}` : `e${((s = e.event) == null ? void 0 : s.history_id) ?? ""}-${e.activity ?? ""}-${e.timestamp ?? ""}`;
23
- }, Xe = /* @__PURE__ */ new Set([
23
+ }, Ze = /* @__PURE__ */ new Set([
24
24
  "id",
25
25
  "created",
26
26
  "changed",
@@ -33,25 +33,25 @@ const G = (e) => e.id != null && (e.action === "create" || e.action === "update"
33
33
  "sort"
34
34
  ]);
35
35
  function ue(e, s) {
36
- const i = F(), { data: a } = B({
36
+ const d = F(), { data: a } = P({
37
37
  queryKey: ["revisions-field-meta", e],
38
38
  enabled: s,
39
39
  staleTime: 3e5,
40
40
  queryFn: async () => {
41
- const [o, d] = await Promise.all([
42
- i.request(D(`/field-config/${e}`)).then((n) => n.data ?? []).catch(() => []),
43
- i.request(
44
- D(`/collections/${e}`)
41
+ const [o, i] = await Promise.all([
42
+ d.request(q(`/field-config/${e}`)).then((n) => n.data ?? []).catch(() => []),
43
+ d.request(
44
+ q(`/collections/${e}`)
45
45
  ).then((n) => {
46
46
  var r;
47
47
  return ((r = n.data) == null ? void 0 : r.relations) ?? [];
48
48
  }).catch(() => [])
49
49
  ]);
50
- return { fields: o, relations: d };
50
+ return { fields: o, relations: i };
51
51
  }
52
52
  });
53
- return A(() => {
54
- const o = /* @__PURE__ */ new Map(), d = (n) => {
53
+ return R(() => {
54
+ const o = /* @__PURE__ */ new Map(), i = (n) => {
55
55
  const r = ((a == null ? void 0 : a.relations) ?? []).find(
56
56
  (m) => m.many_collection === e && m.many_field === n && m.junction_field == null
57
57
  );
@@ -63,17 +63,17 @@ function ue(e, s) {
63
63
  // Hidden fields are machine columns (e.g. the retired "workflow_state
64
64
  // (legacy)" a save still writes) — folded with the system fields, not
65
65
  // listed among what a person changed (army8 b01).
66
- system: Xe.has(n.field) || n.hidden === !0,
66
+ system: Ze.has(n.field) || n.hidden === !0,
67
67
  // layout_assigned is only stamped when the collection HAS an active
68
68
  // layout — absent means there's no layout to be off of.
69
69
  onLayout: n.layout_assigned !== !1,
70
- relatedCollection: d(n.field),
70
+ relatedCollection: i(n.field),
71
71
  dateOnly: String(n.type ?? "").toLowerCase() === "date"
72
72
  });
73
73
  return o;
74
74
  }, [a, e]);
75
75
  }
76
- function y(e, s) {
76
+ function k(e, s) {
77
77
  return e.get(s) ?? {
78
78
  // Unknown to the form = machine column. Still labeled, still reachable.
79
79
  label: me(s.replace(/[_-]/g, " ")),
@@ -81,42 +81,42 @@ function y(e, s) {
81
81
  onLayout: !1
82
82
  };
83
83
  }
84
- function Ze({ map: e, field: s }) {
85
- const i = y(e, s);
84
+ function et({ map: e, field: s }) {
85
+ const d = k(e, s);
86
86
  return /* @__PURE__ */ t(
87
87
  "span",
88
88
  {
89
89
  className: "text-[12px] font-medium text-slate-700 dark:text-slate-200",
90
90
  "data-tip": s,
91
91
  title: s,
92
- children: i.label
92
+ children: d.label
93
93
  }
94
94
  );
95
95
  }
96
- const ne = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}/, et = /^\d{4}-\d{2}-\d{2}(?:T00:00:00(?:\.0+)?Z)?$/;
97
- function tt(e, s = !1) {
96
+ const ne = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}/, tt = /^\d{4}-\d{2}-\d{2}(?:T00:00:00(?:\.0+)?Z)?$/;
97
+ function at(e, s = !1) {
98
98
  if (e == null || e === "") return "";
99
99
  if (typeof e == "boolean") return e ? "Yes" : "No";
100
- if (typeof e == "string" && (et.test(e) || s && ne.test(e)))
101
- return Ie(e);
100
+ if (typeof e == "string" && (tt.test(e) || s && ne.test(e)))
101
+ return Ke(e);
102
102
  if (typeof e == "string" && ne.test(e)) {
103
- const i = new Date(e);
104
- if (!Number.isNaN(i.getTime())) return i.toLocaleString();
103
+ const d = new Date(e);
104
+ if (!Number.isNaN(d.getTime())) return d.toLocaleString();
105
105
  }
106
106
  return typeof e == "object" ? JSON.stringify(e) : String(e);
107
107
  }
108
108
  function U(e) {
109
109
  return e == null ? "" : typeof e == "object" ? JSON.stringify(e) : String(e);
110
110
  }
111
- function at({ collection: e, id: s }) {
112
- const i = F(), { data: a } = B({
111
+ function rt({ collection: e, id: s }) {
112
+ const d = F(), { data: a } = P({
113
113
  queryKey: ["col-meta", e],
114
- queryFn: () => i.request(D(`/collections/${e}`)).then((o) => o.data),
114
+ queryFn: () => d.request(q(`/collections/${e}`)).then((o) => o.data),
115
115
  staleTime: 3e5,
116
116
  retry: !1
117
117
  });
118
118
  return /* @__PURE__ */ t("span", { title: `${e} #${String(s)}`, children: /* @__PURE__ */ t(
119
- Ue,
119
+ We,
120
120
  {
121
121
  collection: e,
122
122
  id: s,
@@ -124,19 +124,19 @@ function at({ collection: e, id: s }) {
124
124
  }
125
125
  ) });
126
126
  }
127
- function rt(e) {
127
+ function st(e) {
128
128
  return Z(e).join(" ");
129
129
  }
130
130
  const le = 160;
131
- function ie({
131
+ function de({
132
132
  value: e,
133
133
  tone: s,
134
- dateOnly: i
134
+ dateOnly: d
135
135
  }) {
136
- const [a, o] = v(!1), d = tt(e, i);
137
- if (d === "")
136
+ const [a, o] = w(!1), i = at(e, d);
137
+ if (i === "")
138
138
  return /* @__PURE__ */ t("span", { className: "text-[11.5px] italic text-slate-300 dark:text-slate-600", children: "empty" });
139
- const n = d.length > le, r = a || !n ? d : `${d.slice(0, le)}…`;
139
+ const n = i.length > le, r = a || !n ? i : `${i.slice(0, le)}…`;
140
140
  return /* @__PURE__ */ l("span", { className: "break-words text-[12px] leading-relaxed text-slate-700 dark:text-slate-300", children: [
141
141
  typeof e == "object" ? /* @__PURE__ */ t("span", { className: "font-mono text-[11px]", children: r }) : r,
142
142
  n && /* @__PURE__ */ t(
@@ -164,27 +164,27 @@ function I(e) {
164
164
  }
165
165
  return null;
166
166
  }
167
- function st({
167
+ function nt({
168
168
  before: e,
169
169
  after: s
170
170
  }) {
171
- const a = Array.from(/* @__PURE__ */ new Set([...Object.keys(e), ...Object.keys(s)])).sort().map((d) => {
172
- const n = d in e ? JSON.stringify(e[d]) : void 0, r = d in s ? JSON.stringify(s[d]) : void 0;
173
- return n === r ? null : { k: d, b: n, a: r };
171
+ const a = Array.from(/* @__PURE__ */ new Set([...Object.keys(e), ...Object.keys(s)])).sort().map((i) => {
172
+ const n = i in e ? JSON.stringify(e[i]) : void 0, r = i in s ? JSON.stringify(s[i]) : void 0;
173
+ return n === r ? null : { k: i, b: n, a: r };
174
174
  }).filter(Boolean);
175
175
  if (a.length === 0)
176
176
  return /* @__PURE__ */ t("span", { className: "text-[11px] italic text-slate-400", children: "keys reordered only" });
177
- const o = (d) => d == null ? void 0 : d.length > 80 ? `${d.slice(0, 80)}…` : d;
178
- return /* @__PURE__ */ t("div", { className: "space-y-0.5", "data-json-diff": !0, children: a.map(({ k: d, b: n, a: r }) => /* @__PURE__ */ l("p", { className: "text-[11.5px]", children: [
179
- /* @__PURE__ */ t("span", { className: "font-mono text-[10.5px] text-slate-500", children: d }),
177
+ const o = (i) => i == null ? void 0 : i.length > 80 ? `${i.slice(0, 80)}…` : i;
178
+ return /* @__PURE__ */ t("div", { className: "space-y-0.5", "data-json-diff": !0, children: a.map(({ k: i, b: n, a: r }) => /* @__PURE__ */ l("p", { className: "text-[11.5px]", children: [
179
+ /* @__PURE__ */ t("span", { className: "font-mono text-[10.5px] text-slate-500", children: i }),
180
180
  ":",
181
181
  " ",
182
182
  n !== void 0 && /* @__PURE__ */ t("span", { className: "text-rose-600 line-through dark:text-rose-400", children: o(n) }),
183
183
  n !== void 0 && r !== void 0 && " → ",
184
184
  r !== void 0 ? /* @__PURE__ */ t("span", { className: "text-emerald-700 dark:text-emerald-400", children: o(r) }) : /* @__PURE__ */ t("span", { className: "italic text-slate-400", children: " (removed)" })
185
- ] }, d)) });
185
+ ] }, i)) });
186
186
  }
187
- function nt({ field: e, ctl: s }) {
187
+ function lt({ field: e, ctl: s }) {
188
188
  return s.confirmField === e ? /* @__PURE__ */ l("span", { className: "inline-flex items-center gap-1", "data-revert-field-confirm": e, children: [
189
189
  /* @__PURE__ */ t("span", { className: "text-[10.5px] text-slate-500", children: "Revert?" }),
190
190
  /* @__PURE__ */ t(
@@ -215,7 +215,7 @@ function nt({ field: e, ctl: s }) {
215
215
  title: "Set the field back to this revision’s value",
216
216
  "data-revert-field": e,
217
217
  children: [
218
- /* @__PURE__ */ t(de, { className: "h-3 w-3" }),
218
+ /* @__PURE__ */ t(ie, { className: "h-3 w-3" }),
219
219
  "Revert"
220
220
  ]
221
221
  }
@@ -227,25 +227,25 @@ function X(e) {
227
227
  function Z(e) {
228
228
  return String(e ?? "").replace(/<[^>]*>/g, " ").replace(/&nbsp;/g, " ").replace(/&amp;/g, "&").replace(/&lt;/g, "<").replace(/&gt;/g, ">").split(/\s+/).filter(Boolean);
229
229
  }
230
- function lt(e, s) {
231
- const a = Z(e).slice(0, 600), o = Z(s).slice(0, 600), d = a.length, n = o.length, r = Array.from({ length: d + 1 }, () => new Array(n + 1).fill(0));
232
- for (let g = d - 1; g >= 0; g--)
230
+ function dt(e, s) {
231
+ const a = Z(e).slice(0, 600), o = Z(s).slice(0, 600), i = a.length, n = o.length, r = Array.from({ length: i + 1 }, () => new Array(n + 1).fill(0));
232
+ for (let g = i - 1; g >= 0; g--)
233
233
  for (let c = n - 1; c >= 0; c--)
234
234
  r[g][c] = a[g] === o[c] ? r[g + 1][c + 1] + 1 : Math.max(r[g + 1][c], r[g][c + 1]);
235
- const m = [], h = (g, c) => {
236
- const x = m[m.length - 1];
237
- x && x.type === g ? x.text += ` ${c}` : m.push({ text: c, type: g });
235
+ const m = [], x = (g, c) => {
236
+ const y = m[m.length - 1];
237
+ y && y.type === g ? y.text += ` ${c}` : m.push({ text: c, type: g });
238
238
  };
239
239
  let p = 0, u = 0;
240
- for (; p < d && u < n; )
241
- a[p] === o[u] ? (h("same", a[p]), p++, u++) : r[p + 1][u] >= r[p][u + 1] ? (h("del", a[p]), p++) : (h("ins", o[u]), u++);
242
- for (; p < d; ) h("del", a[p++]);
243
- for (; u < n; ) h("ins", o[u++]);
240
+ for (; p < i && u < n; )
241
+ a[p] === o[u] ? (x("same", a[p]), p++, u++) : r[p + 1][u] >= r[p][u + 1] ? (x("del", a[p]), p++) : (x("ins", o[u]), u++);
242
+ for (; p < i; ) x("del", a[p++]);
243
+ for (; u < n; ) x("ins", o[u++]);
244
244
  return m;
245
245
  }
246
- function it({ before: e, after: s }) {
247
- const i = lt(e, s);
248
- return /* @__PURE__ */ t("p", { className: "whitespace-pre-wrap break-words text-[12px] leading-relaxed text-slate-700 dark:text-slate-300", children: i.map(
246
+ function ot({ before: e, after: s }) {
247
+ const d = dt(e, s);
248
+ return /* @__PURE__ */ t("p", { className: "whitespace-pre-wrap break-words text-[12px] leading-relaxed text-slate-700 dark:text-slate-300", children: d.map(
249
249
  (a, o) => a.type === "same" ? (
250
250
  // biome-ignore lint/suspicious/noArrayIndexKey: static segment list
251
251
  /* @__PURE__ */ l("span", { children: [
@@ -281,46 +281,46 @@ function it({ before: e, after: s }) {
281
281
  )
282
282
  ) });
283
283
  }
284
- const ot = {
284
+ const it = {
285
285
  added: "bg-emerald-100 text-emerald-700 dark:bg-emerald-900/40 dark:text-emerald-400",
286
286
  removed: "bg-red-100 text-red-700 dark:bg-red-900/40 dark:text-red-400",
287
287
  changed: "bg-amber-100 text-amber-700 dark:bg-amber-900/40 dark:text-amber-400"
288
288
  };
289
- function dt(e, s, i) {
290
- const a = Array.from(/* @__PURE__ */ new Set([...Object.keys(e), ...Object.keys(s)])), o = (r) => r == null || r === "", d = a.map((r) => {
291
- const m = !(r in e) || o(e[r]), h = !(r in s) || o(s[r]);
292
- if (m && h) return null;
293
- const p = m ? "added" : h ? "removed" : U(e[r]) !== U(s[r]) ? "changed" : "unchanged";
289
+ function ct(e, s, d) {
290
+ const a = Array.from(/* @__PURE__ */ new Set([...Object.keys(e), ...Object.keys(s)])), o = (r) => r == null || r === "", i = a.map((r) => {
291
+ const m = !(r in e) || o(e[r]), x = !(r in s) || o(s[r]);
292
+ if (m && x) return null;
293
+ const p = m ? "added" : x ? "removed" : U(e[r]) !== U(s[r]) ? "changed" : "unchanged";
294
294
  return {
295
295
  field: r,
296
296
  status: p,
297
297
  before: e[r],
298
298
  after: s[r],
299
- system: y(i, r).system
299
+ system: k(d, r).system
300
300
  };
301
301
  }).filter(Boolean), n = (r) => {
302
- const m = y(i, r.field);
302
+ const m = k(d, r.field);
303
303
  return (m.system ? 8 : m.onLayout ? 0 : 4) + (r.status === "unchanged" ? 2 : 0);
304
304
  };
305
- return d.sort(
306
- (r, m) => n(r) - n(m) || y(i, r.field).label.localeCompare(y(i, m.field).label)
305
+ return i.sort(
306
+ (r, m) => n(r) - n(m) || k(d, r.field).label.localeCompare(k(d, m.field).label)
307
307
  );
308
308
  }
309
- function q({
309
+ function D({
310
310
  value: e,
311
311
  meta: s,
312
- tone: i
312
+ tone: d
313
313
  }) {
314
- return e == null || e === "" ? /* @__PURE__ */ t("span", { className: "text-[11.5px] italic text-slate-300 dark:text-slate-600", children: "empty" }) : s.relatedCollection && (typeof e == "string" || typeof e == "number") ? /* @__PURE__ */ t("span", { className: "break-words text-[12px] leading-relaxed text-slate-700 dark:text-slate-300", children: /* @__PURE__ */ t(at, { collection: s.relatedCollection, id: e }) }) : X(e) ? /* @__PURE__ */ t(ie, { value: rt(e), tone: i }) : /* @__PURE__ */ t(ie, { value: e, tone: i, dateOnly: s.dateOnly });
314
+ return e == null || e === "" ? /* @__PURE__ */ t("span", { className: "text-[11.5px] italic text-slate-300 dark:text-slate-600", children: "empty" }) : s.relatedCollection && (typeof e == "string" || typeof e == "number") ? /* @__PURE__ */ t("span", { className: "break-words text-[12px] leading-relaxed text-slate-700 dark:text-slate-300", children: /* @__PURE__ */ t(rt, { collection: s.relatedCollection, id: e }) }) : X(e) ? /* @__PURE__ */ t(de, { value: st(e), tone: d }) : /* @__PURE__ */ t(de, { value: e, tone: d, dateOnly: s.dateOnly });
315
315
  }
316
- function ct({
316
+ function mt({
317
317
  row: e,
318
318
  meta: s,
319
- fieldRevert: i,
319
+ fieldRevert: d,
320
320
  mode: a,
321
321
  hideStatusChips: o
322
322
  }) {
323
- const d = e.status === "changed" && (X(e.before) || X(e.after)), n = e.status === "changed" && I(e.before) && I(e.after);
323
+ const i = e.status === "changed" && (X(e.before) || X(e.after)), n = e.status === "changed" && I(e.before) && I(e.after);
324
324
  return /* @__PURE__ */ l(
325
325
  "div",
326
326
  {
@@ -331,110 +331,122 @@ function ct({
331
331
  "data-field-row": e.field,
332
332
  children: [
333
333
  /* @__PURE__ */ l("div", { className: "flex items-center gap-2", children: [
334
- /* @__PURE__ */ t(Ze, { map: s, field: e.field }),
334
+ /* @__PURE__ */ t(et, { map: s, field: e.field }),
335
335
  e.status !== "unchanged" && !o && /* @__PURE__ */ t(
336
336
  "span",
337
337
  {
338
338
  className: T(
339
339
  "rounded px-1 py-px text-[9px] font-semibold uppercase tracking-wide",
340
- ot[e.status]
340
+ it[e.status]
341
341
  ),
342
342
  children: e.status === "added" ? "set" : e.status
343
343
  }
344
344
  ),
345
- (e.status === "changed" || a === "changes" && e.status === "added") && i && e.field !== "id" && /* @__PURE__ */ t("span", { className: "ml-auto shrink-0", children: /* @__PURE__ */ t(nt, { field: e.field, ctl: i }) })
345
+ (e.status === "changed" || a === "changes" && e.status === "added") && d && e.field !== "id" && /* @__PURE__ */ t("span", { className: "ml-auto shrink-0", children: /* @__PURE__ */ t(lt, { field: e.field, ctl: d }) })
346
346
  ] }),
347
- /* @__PURE__ */ t("div", { className: "mt-1", children: d ? /* @__PURE__ */ t("div", { "data-richtext-diff": !0, children: /* @__PURE__ */ t(it, { before: e.before, after: e.after }) }) : n ? /* @__PURE__ */ t(
348
- st,
347
+ /* @__PURE__ */ t("div", { className: "mt-1", children: i ? /* @__PURE__ */ t("div", { "data-richtext-diff": !0, children: /* @__PURE__ */ t(ot, { before: e.before, after: e.after }) }) : n ? /* @__PURE__ */ t(
348
+ nt,
349
349
  {
350
350
  before: I(e.before),
351
351
  after: I(e.after)
352
352
  }
353
353
  ) : e.status === "changed" || e.status === "removed" ? /* @__PURE__ */ l("div", { className: "flex flex-wrap items-baseline gap-x-2 gap-y-0.5", children: [
354
- /* @__PURE__ */ t("span", { className: "max-w-full break-words text-[12px] text-rose-600 line-through decoration-rose-300 dark:text-rose-400", children: /* @__PURE__ */ t(q, { value: e.before, meta: y(s, e.field), tone: "before" }) }),
355
- /* @__PURE__ */ t(Le, { className: "h-3 w-3 shrink-0 self-center text-slate-300 dark:text-slate-600" }),
356
- /* @__PURE__ */ t(q, { value: e.after, meta: y(s, e.field), tone: "after" })
357
- ] }) : /* @__PURE__ */ t(q, { value: e.after ?? e.before, meta: y(s, e.field), tone: "after" }) })
354
+ /* @__PURE__ */ t("span", { className: "max-w-full break-words text-[12px] text-rose-600 line-through decoration-rose-300 dark:text-rose-400", children: /* @__PURE__ */ t(D, { value: e.before, meta: k(s, e.field), tone: "before" }) }),
355
+ /* @__PURE__ */ t($e, { className: "h-3 w-3 shrink-0 self-center text-slate-300 dark:text-slate-600" }),
356
+ /* @__PURE__ */ t(D, { value: e.after, meta: k(s, e.field), tone: "after" })
357
+ ] }) : /* @__PURE__ */ t(D, { value: e.after ?? e.before, meta: k(s, e.field), tone: "after" }) })
358
358
  ]
359
359
  }
360
360
  );
361
361
  }
362
- function mt({
362
+ function pt({
363
363
  before: e,
364
364
  after: s,
365
- meta: i,
365
+ meta: d,
366
366
  fieldRevert: a,
367
367
  mode: o,
368
- hideStatusChips: d
368
+ hideStatusChips: i,
369
+ ownFields: n
369
370
  }) {
370
- const [n, r] = v(!1), m = A(() => dt(e, s, i), [e, s, i]), h = o === "changes" ? m.filter((x) => x.status !== "unchanged") : m, p = n ? h : h.filter((x) => !x.system), u = h.length - p.length;
371
- if (h.length === 0)
371
+ const [r, m] = w(!1), x = R(() => ct(e, s, d), [e, s, d]), p = o === "changes" ? x.filter((h) => h.status !== "unchanged") : x, u = r ? p : p.filter((h) => !h.system), g = (h) => !!n && o === "changes" && !h.system && !n.has(h.field), c = u.filter(g), y = [...u.filter((h) => !g(h)), ...c], j = c.length ? y.length - c.length : -1, f = p.length - y.length;
372
+ if (p.length === 0)
372
373
  return /* @__PURE__ */ t("p", { className: "px-3 py-3 text-[12px] text-slate-400", children: o === "changes" ? "No field changes recorded." : "No snapshot data available." });
373
- const g = p.findIndex(
374
- (x) => !y(i, x.field).onLayout && !y(i, x.field).system
375
- ), c = p.some(
376
- (x) => y(i, x.field).onLayout && !y(i, x.field).system
374
+ const N = y.findIndex(
375
+ (h) => !g(h) && !k(d, h.field).onLayout && !k(d, h.field).system
376
+ ), S = y.some(
377
+ (h) => !g(h) && k(d, h.field).onLayout && !k(d, h.field).system
377
378
  );
378
379
  return /* @__PURE__ */ l("div", { className: "overflow-hidden rounded-lg border border-slate-200 bg-white dark:border-border dark:bg-card", children: [
379
- p.map((x, R) => /* @__PURE__ */ l("div", { children: [
380
- R === g && c && /* @__PURE__ */ l("div", { className: "border-b border-t border-slate-100 bg-slate-50/70 px-3 py-1.5 dark:border-border/60 dark:bg-muted/30", children: [
380
+ y.map((h, C) => /* @__PURE__ */ l("div", { children: [
381
+ C === j && /* @__PURE__ */ l(
382
+ "div",
383
+ {
384
+ "data-recalculated-between": !0,
385
+ className: "border-b border-t border-slate-100 bg-slate-50/70 px-3 py-1.5 dark:border-border/60 dark:bg-muted/30",
386
+ children: [
387
+ /* @__PURE__ */ t("p", { className: "text-[10.5px] font-semibold uppercase tracking-wide text-slate-500 dark:text-slate-400", children: "Recalculated since the save before" }),
388
+ /* @__PURE__ */ t("p", { className: "text-[10.5px] text-slate-500 dark:text-slate-400", children: "Not part of this edit — worked out automatically between the two saves." })
389
+ ]
390
+ }
391
+ ),
392
+ C === N && S && /* @__PURE__ */ l("div", { className: "border-b border-t border-slate-100 bg-slate-50/70 px-3 py-1.5 dark:border-border/60 dark:bg-muted/30", children: [
381
393
  /* @__PURE__ */ t("p", { className: "text-[10.5px] font-semibold uppercase tracking-wide text-slate-400", children: "Behind the scenes" }),
382
394
  /* @__PURE__ */ t("p", { className: "text-[10.5px] text-slate-400", children: "Not on the form — written automatically by rules, computed fields or integrations." })
383
395
  ] }),
384
396
  /* @__PURE__ */ t(
385
- ct,
397
+ mt,
386
398
  {
387
- row: x,
388
- meta: i,
399
+ row: h,
400
+ meta: d,
389
401
  fieldRevert: a,
390
402
  mode: o,
391
- hideStatusChips: d
403
+ hideStatusChips: i
392
404
  }
393
405
  )
394
- ] }, x.field)),
395
- u > 0 && /* @__PURE__ */ l(
406
+ ] }, h.field)),
407
+ f > 0 && /* @__PURE__ */ l(
396
408
  "button",
397
409
  {
398
410
  type: "button",
399
- onClick: () => r(!0),
411
+ onClick: () => m(!0),
400
412
  className: "w-full border-t border-slate-100 px-3 py-2 text-left text-[11.5px] text-slate-400 hover:text-slate-600 dark:border-border/60 dark:hover:text-slate-300",
401
413
  "data-show-system": !0,
402
414
  children: [
403
415
  "Show ",
404
- u,
416
+ f,
405
417
  " system field",
406
- u === 1 ? "" : "s",
418
+ f === 1 ? "" : "s",
407
419
  " (ids, timestamps, machine columns)"
408
420
  ]
409
421
  }
410
422
  ),
411
- u === 0 && n && h.some((x) => x.system) && /* @__PURE__ */ t(
423
+ f === 0 && r && p.some((h) => h.system) && /* @__PURE__ */ t(
412
424
  "button",
413
425
  {
414
426
  type: "button",
415
- onClick: () => r(!1),
427
+ onClick: () => m(!1),
416
428
  className: "w-full border-t border-slate-100 px-3 py-2 text-left text-[11.5px] text-slate-400 hover:text-slate-600 dark:border-border/60",
417
429
  children: "Hide system fields"
418
430
  }
419
431
  )
420
432
  ] });
421
433
  }
422
- const pt = {
434
+ const ut = {
423
435
  create: "bg-emerald-500",
424
436
  restore: "bg-emerald-500",
425
437
  update: "bg-nvr-cyan",
426
438
  delete: "bg-red-500"
427
- }, te = Oe(void 0);
428
- function P(e, s) {
429
- var i;
430
- return e.actor && e.actor.kind !== "person" ? Pe(e, s) : e.first_name || e.last_name ? [e.first_name, e.last_name].filter(Boolean).join(" ") : e.user_email ?? ((i = e.user_id) == null ? void 0 : i.slice(0, 8)) ?? "System";
439
+ }, te = De(void 0);
440
+ function B(e, s) {
441
+ var d;
442
+ return e.actor && e.actor.kind !== "person" ? Pe(e, s) : e.first_name || e.last_name ? [e.first_name, e.last_name].filter(Boolean).join(" ") : e.user_email ?? ((d = e.user_id) == null ? void 0 : d.slice(0, 8)) ?? "System";
431
443
  }
432
- function ut(e, s, i) {
433
- return e.action === "create" ? "created this record" : e.action === "restore" ? "restored this record from trash" : e.action === "delete" ? "deleted this record" : s > 0 ? `changed ${s} field${s === 1 ? "" : "s"}` : i > 0 ? "updated system fields" : "saved this record";
444
+ function ht(e, s, d) {
445
+ return e.action === "create" ? "created this record" : e.action === "restore" ? "restored this record from trash" : e.action === "delete" ? "deleted this record" : s > 0 ? `changed ${s} field${s === 1 ? "" : "s"}` : d > 0 ? "updated system fields" : "saved this record";
434
446
  }
435
- function ht({ revision: e, isLast: s }) {
436
- var h, p, u;
437
- const i = ce(te), a = e.event, o = (a == null ? void 0 : a.source) === "auto" || !e.user_id && (a == null ? void 0 : a.kind) === "transition", d = !o && ((h = a == null ? void 0 : a.on_behalf_of) != null && h.name) ? a.on_behalf_of.name : null, n = o ? "Automatic rule" : d ? `${P(e, i)}, for ${d}` : P(e, i);
447
+ function xt({ revision: e, isLast: s }) {
448
+ var x, p, u;
449
+ const d = ce(te), a = e.event, o = (a == null ? void 0 : a.source) === "auto" || !e.user_id && (a == null ? void 0 : a.kind) === "transition", i = !o && ((x = a == null ? void 0 : a.on_behalf_of) != null && x.name) ? a.on_behalf_of.name : null, n = o ? "Automatic rule" : i ? `${B(e, d)}, for ${i}` : B(e, d);
438
450
  let r;
439
451
  (a == null ? void 0 : a.kind) === "transition" && a.addendum ? r = /* @__PURE__ */ l(L, { children: [
440
452
  "moved",
@@ -480,8 +492,8 @@ function ht({ revision: e, isLast: s }) {
480
492
  ] }) : (a == null ? void 0 : a.kind) === "start" ? r = /* @__PURE__ */ l(L, { children: [
481
493
  "started the pipeline",
482
494
  e.comment ? ` — ${e.comment.replace(/^Started pipeline\s*[—-]?\s*/i, "")}` : ""
483
- ] }) : (p = e.action) != null && p.startsWith("o2m-") ? r = /* @__PURE__ */ t("span", { "data-revision-o2m": !0, children: e.o2m ? De(e.o2m) : `${e.action === "o2m-create" ? "added" : e.action === "o2m-delete" ? "removed" : "changed"} related rows` }) : r = /* @__PURE__ */ l(L, { children: [
484
- Fe({ ...e, item: null }, i),
495
+ ] }) : (p = e.action) != null && p.startsWith("o2m-") ? r = /* @__PURE__ */ t("span", { "data-revision-o2m": !0, children: e.o2m ? Fe(e.o2m) : `${e.action === "o2m-create" ? "added" : e.action === "o2m-delete" ? "removed" : "changed"} related rows` }) : r = /* @__PURE__ */ l(L, { children: [
496
+ Ee({ ...e, item: null }, d),
485
497
  e.comment ? ` — ${e.comment}` : ""
486
498
  ] });
487
499
  const m = e.timestamp ? new Date(e.timestamp).toLocaleTimeString([], { hour: "numeric", minute: "2-digit" }) : "—";
@@ -490,7 +502,7 @@ function ht({ revision: e, isLast: s }) {
490
502
  {
491
503
  className: "relative pl-9",
492
504
  "data-revision-event": (a == null ? void 0 : a.kind) ?? e.action ?? "",
493
- "data-revision-on-behalf": d ? (u = a == null ? void 0 : a.on_behalf_of) == null ? void 0 : u.id : void 0,
505
+ "data-revision-on-behalf": i ? (u = a == null ? void 0 : a.on_behalf_of) == null ? void 0 : u.id : void 0,
494
506
  children: [
495
507
  /* @__PURE__ */ t(
496
508
  "span",
@@ -548,77 +560,77 @@ function ht({ revision: e, isLast: s }) {
548
560
  }
549
561
  );
550
562
  }
551
- function xt({
563
+ function ft({
552
564
  revision: e,
553
565
  previousData: s,
554
- meta: i,
566
+ meta: d,
555
567
  onRollback: a,
556
568
  inlineTableFields: o,
557
- isLast: d
569
+ isLast: i
558
570
  }) {
559
- const n = F(), r = ce(te), m = Ee(e).reason, [h, p] = v(!1), [u, g] = v(!1), [c, x] = v("changes"), [R, b] = v(!1), [N, S] = v(null), w = e.action === "update", C = e.action === "create" || e.action === "restore", W = e.action === "delete", k = W ? e.data ?? {} : C ? {} : s ?? {}, $ = W ? {} : e.data ?? {}, { humanDelta: V, systemDelta: he } = A(() => {
560
- const f = e.delta ?? {};
571
+ const n = F(), r = ce(te), m = Be(e).reason, [x, p] = w(!1), [u, g] = w(!1), [c, y] = w("changes"), [j, f] = w(!1), [N, S] = w(null), h = e.action === "update", C = e.action === "create" || e.action === "restore", W = e.action === "delete", v = W ? e.data ?? {} : C ? {} : s ?? {}, $ = W ? {} : e.data ?? {}, { humanDelta: V, systemDelta: he } = R(() => {
572
+ const b = e.delta ?? {};
561
573
  let _ = 0, E = 0;
562
- for (const J of Object.keys(f)) {
563
- const ve = s == null ? void 0 : s[J], we = (e.data ?? {})[J];
564
- w && s && U(ve) === U(we) || (y(i, J).system ? E++ : _++);
574
+ for (const J of Object.keys(b)) {
575
+ const we = s == null ? void 0 : s[J], Se = (e.data ?? {})[J];
576
+ h && s && U(we) === U(Se) || (k(d, J).system ? E++ : _++);
565
577
  }
566
578
  return { humanDelta: _, systemDelta: E };
567
- }, [e, s, i, w]), xe = w || C, [z, fe] = v(null), be = ee(), [ge, ae] = v(null), re = Q({
568
- mutationFn: (f) => n.request(K(`/revisions/${e.id}/revert-field`, { field: f })),
569
- onSuccess: (f, _) => {
570
- ae(null), j.success(`Reverted ${y(i, _).label} to this revision's value`), be.invalidateQueries({ queryKey: ["revisions", e.collection, e.item] }), a == null || a();
579
+ }, [e, s, d, h]), xe = R(() => new Set(Object.keys(e.delta ?? {})), [e]), fe = h || C, [z, be] = w(null), ge = ee(), [ye, ae] = w(null), re = Q({
580
+ mutationFn: (b) => n.request(K(`/revisions/${e.id}/revert-field`, { field: b })),
581
+ onSuccess: (b, _) => {
582
+ ae(null), A.success(`Reverted ${k(d, _).label} to this revision's value`), ge.invalidateQueries({ queryKey: ["revisions", e.collection, e.item] }), a == null || a();
571
583
  },
572
- onError: () => j.error("Failed to revert field")
573
- }), ye = w || C ? {
574
- confirmField: ge,
584
+ onError: () => A.error("Failed to revert field")
585
+ }), Ne = h || C ? {
586
+ confirmField: ye,
575
587
  setConfirmField: ae,
576
- revert: (f) => re.mutate(f),
588
+ revert: (b) => re.mutate(b),
577
589
  pending: re.isPending
578
590
  } : void 0, H = Q({
579
591
  mutationFn: () => n.request(K(`/revisions/${e.id}/rollback`, {})),
580
- onSuccess: (f) => {
581
- g(!1), j.success("Rolled back to this revision");
582
- const _ = se(f);
583
- _ && j.warning(_, { duration: 1e4 }), o != null && o.length && e.timestamp && fe(e.timestamp), a == null || a();
592
+ onSuccess: (b) => {
593
+ g(!1), A.success("Rolled back to this revision");
594
+ const _ = se(b);
595
+ _ && A.warning(_, { duration: 1e4 }), o != null && o.length && e.timestamp && be(e.timestamp), a == null || a();
584
596
  },
585
- onError: () => j.error("Failed to rollback")
597
+ onError: () => A.error("Failed to rollback")
586
598
  });
587
- async function Ne(f) {
599
+ async function ke(b) {
588
600
  if (z) {
589
- S(f.field);
601
+ S(b.field);
590
602
  try {
591
603
  const _ = await n.request(
592
604
  K("/revisions/o2m-restore", {
593
- collection: f.relatedCollection,
594
- many_field: f.manyField,
595
- parent_id: f.parentId,
605
+ collection: b.relatedCollection,
606
+ many_field: b.manyField,
607
+ parent_id: b.parentId,
596
608
  target_timestamp: z
597
609
  })
598
610
  );
599
- j.success(`Restored ${f.label}`);
611
+ A.success(`Restored ${b.label}`);
600
612
  const E = se(_);
601
- E && j.warning(E, { duration: 1e4 });
613
+ E && A.warning(E, { duration: 1e4 });
602
614
  } catch {
603
- j.error(`Failed to restore ${f.label}`);
615
+ A.error(`Failed to restore ${b.label}`);
604
616
  } finally {
605
617
  S(null);
606
618
  }
607
619
  }
608
620
  }
609
- const ke = e.timestamp ? new Date(e.timestamp).toLocaleTimeString([], { hour: "numeric", minute: "2-digit" }) : "—";
621
+ const ve = e.timestamp ? new Date(e.timestamp).toLocaleTimeString([], { hour: "numeric", minute: "2-digit" }) : "—";
610
622
  return /* @__PURE__ */ l("div", { className: "relative pl-9", "data-revision-row": e.id, children: [
611
623
  /* @__PURE__ */ t(
612
624
  "span",
613
625
  {
614
626
  className: T(
615
627
  "absolute left-[11px] top-[18px] h-2.5 w-2.5 rounded-full ring-4 ring-white dark:ring-card",
616
- pt[e.action ?? ""] ?? "bg-slate-300"
628
+ ut[e.action ?? ""] ?? "bg-slate-300"
617
629
  ),
618
630
  "aria-hidden": !0
619
631
  }
620
632
  ),
621
- !d && /* @__PURE__ */ t(
633
+ !i && /* @__PURE__ */ t(
622
634
  "span",
623
635
  {
624
636
  className: "absolute bottom-0 left-[15.5px] top-[30px] w-px bg-slate-200 dark:bg-border",
@@ -629,7 +641,7 @@ function xt({
629
641
  "button",
630
642
  {
631
643
  type: "button",
632
- onClick: () => p((f) => !f),
644
+ onClick: () => p((b) => !b),
633
645
  className: "flex w-full items-center gap-2.5 rounded-md px-2 py-2.5 text-left transition-colors hover:bg-slate-50 dark:hover:bg-muted/40",
634
646
  children: [
635
647
  /* @__PURE__ */ t(
@@ -637,13 +649,13 @@ function xt({
637
649
  {
638
650
  userId: e.user_id,
639
651
  className: "h-6 w-6",
640
- fallback: /* @__PURE__ */ t("span", { className: "flex h-6 w-6 shrink-0 items-center justify-center rounded-full bg-nvr-cyan/10 text-[10px] font-semibold text-nvr-navy dark:text-nvr-cyan", children: P(e, r).split(" ").map((f) => f[0]).filter(Boolean).slice(0, 2).join("").toUpperCase() })
652
+ fallback: /* @__PURE__ */ t("span", { className: "flex h-6 w-6 shrink-0 items-center justify-center rounded-full bg-nvr-cyan/10 text-[10px] font-semibold text-nvr-navy dark:text-nvr-cyan", children: B(e, r).split(" ").map((b) => b[0]).filter(Boolean).slice(0, 2).join("").toUpperCase() })
641
653
  }
642
654
  ),
643
655
  /* @__PURE__ */ l("span", { className: "min-w-0 flex-1 truncate text-[12.5px] text-slate-700 dark:text-slate-200", children: [
644
- /* @__PURE__ */ t("span", { className: "font-medium", children: P(e, r) }),
656
+ /* @__PURE__ */ t("span", { className: "font-medium", children: B(e, r) }),
645
657
  " ",
646
- /* @__PURE__ */ t("span", { className: "text-slate-500 dark:text-slate-400", children: ut(e, V, he) }),
658
+ /* @__PURE__ */ t("span", { className: "text-slate-500 dark:text-slate-400", children: ht(e, V, he) }),
647
659
  m && /* @__PURE__ */ l(
648
660
  "span",
649
661
  {
@@ -657,54 +669,54 @@ function xt({
657
669
  }
658
670
  )
659
671
  ] }),
660
- /* @__PURE__ */ t(Me, { label: e.via_agent }),
672
+ /* @__PURE__ */ t(Ue, { label: e.via_agent }),
661
673
  /* @__PURE__ */ t(
662
674
  "span",
663
675
  {
664
676
  className: "shrink-0 text-[11px] tabular-nums text-slate-400",
665
677
  title: e.timestamp ? new Date(e.timestamp).toLocaleString() : void 0,
666
- children: ke
678
+ children: ve
667
679
  }
668
680
  ),
669
- h ? /* @__PURE__ */ t(Re, { className: "h-3.5 w-3.5 shrink-0 text-slate-400" }) : /* @__PURE__ */ t(je, { className: "h-3.5 w-3.5 shrink-0 text-slate-400" })
681
+ x ? /* @__PURE__ */ t(je, { className: "h-3.5 w-3.5 shrink-0 text-slate-400" }) : /* @__PURE__ */ t(Ae, { className: "h-3.5 w-3.5 shrink-0 text-slate-400" })
670
682
  ]
671
683
  }
672
684
  ),
673
- h && /* @__PURE__ */ l("div", { className: "space-y-2.5 px-2 pb-4 pt-1", children: [
685
+ x && /* @__PURE__ */ l("div", { className: "space-y-2.5 px-2 pb-4 pt-1", children: [
674
686
  /* @__PURE__ */ l("div", { className: "flex flex-wrap items-center justify-between gap-2", children: [
675
687
  /* @__PURE__ */ t("div", { className: "flex items-center overflow-hidden rounded-md border border-slate-200 dark:border-border", children: [
676
688
  ["changes", "What changed"],
677
689
  ["all", "Full record"]
678
- ].map(([f, _]) => /* @__PURE__ */ t(
690
+ ].map(([b, _]) => /* @__PURE__ */ t(
679
691
  "button",
680
692
  {
681
693
  type: "button",
682
- onClick: () => x(f),
694
+ onClick: () => y(b),
683
695
  className: T(
684
696
  "px-2.5 py-1 text-[11.5px] transition-colors",
685
- c === f ? "bg-nvr-cyan/10 font-medium text-nvr-navy dark:text-nvr-cyan" : "text-slate-400 hover:text-slate-600 dark:hover:text-slate-300"
697
+ c === b ? "bg-nvr-cyan/10 font-medium text-nvr-navy dark:text-nvr-cyan" : "text-slate-400 hover:text-slate-600 dark:hover:text-slate-300"
686
698
  ),
687
699
  children: _
688
700
  },
689
- f
701
+ b
690
702
  )) }),
691
703
  /* @__PURE__ */ l("div", { className: "flex items-center gap-1.5", children: [
692
704
  /* @__PURE__ */ l(
693
705
  "button",
694
706
  {
695
707
  type: "button",
696
- onClick: () => b((f) => !f),
708
+ onClick: () => f((b) => !b),
697
709
  className: T(
698
710
  "inline-flex items-center gap-1 rounded-md border px-2 py-1 text-[11.5px] transition-colors",
699
- R ? "border-nvr-cyan/40 text-nvr-navy dark:text-nvr-cyan" : "border-slate-200 text-slate-400 hover:text-slate-600 dark:border-border dark:hover:text-slate-300"
711
+ j ? "border-nvr-cyan/40 text-nvr-navy dark:text-nvr-cyan" : "border-slate-200 text-slate-400 hover:text-slate-600 dark:border-border dark:hover:text-slate-300"
700
712
  ),
701
713
  children: [
702
- /* @__PURE__ */ t(Ae, { className: "h-3 w-3" }),
714
+ /* @__PURE__ */ t(Le, { className: "h-3 w-3" }),
703
715
  "Notes"
704
716
  ]
705
717
  }
706
718
  ),
707
- xe && (u ? /* @__PURE__ */ l("span", { className: "inline-flex items-center gap-1.5", children: [
719
+ fe && (u ? /* @__PURE__ */ l("span", { className: "inline-flex items-center gap-1.5", children: [
708
720
  /* @__PURE__ */ t("span", { className: "text-[11px] text-slate-500", children: "Restore this version?" }),
709
721
  /* @__PURE__ */ t(
710
722
  M,
@@ -737,63 +749,64 @@ function xt({
737
749
  onClick: () => g(!0),
738
750
  title: "Set the whole record back to how it looked after this save",
739
751
  children: [
740
- /* @__PURE__ */ t(de, { className: "h-3 w-3" }),
752
+ /* @__PURE__ */ t(ie, { className: "h-3 w-3" }),
741
753
  "Restore this version"
742
754
  ]
743
755
  }
744
756
  ))
745
757
  ] })
746
758
  ] }),
747
- R && /* @__PURE__ */ t(Nt, { revisionId: e.id ?? "" }),
759
+ j && /* @__PURE__ */ t(kt, { revisionId: e.id ?? "" }),
748
760
  /* @__PURE__ */ t(
749
- mt,
761
+ pt,
750
762
  {
751
- before: k,
763
+ before: v,
752
764
  after: $,
753
- meta: i,
754
- fieldRevert: ye,
765
+ meta: d,
766
+ fieldRevert: Ne,
755
767
  mode: c,
756
- hideStatusChips: C
768
+ hideStatusChips: C,
769
+ ownFields: h && e.delta ? xe : null
757
770
  }
758
771
  ),
759
772
  z && o && o.length > 0 && /* @__PURE__ */ l("div", { className: "space-y-1.5 rounded-md border border-slate-100 bg-slate-50 p-2 dark:border-border dark:bg-muted/30", children: [
760
773
  /* @__PURE__ */ t("p", { className: "text-[10.5px] font-medium text-slate-500", children: "Also restore related rows?" }),
761
- o.map((f) => /* @__PURE__ */ l("div", { className: "flex items-center justify-between gap-2", children: [
762
- /* @__PURE__ */ t("span", { className: "text-[11.5px] text-slate-600 dark:text-slate-300", children: f.label }),
774
+ o.map((b) => /* @__PURE__ */ l("div", { className: "flex items-center justify-between gap-2", children: [
775
+ /* @__PURE__ */ t("span", { className: "text-[11.5px] text-slate-600 dark:text-slate-300", children: b.label }),
763
776
  /* @__PURE__ */ t(
764
777
  "button",
765
778
  {
766
779
  type: "button",
767
- disabled: N === f.field,
768
- onClick: () => Ne(f),
780
+ disabled: N === b.field,
781
+ onClick: () => ke(b),
769
782
  className: "rounded border border-nvr-cyan/40 px-2 py-0.5 text-[10.5px] font-medium text-nvr-cyan hover:bg-nvr-cyan/10 disabled:opacity-40",
770
- children: N === f.field ? "Restoring…" : "Restore"
783
+ children: N === b.field ? "Restoring…" : "Restore"
771
784
  }
772
785
  )
773
- ] }, f.field))
786
+ ] }, b.field))
774
787
  ] })
775
788
  ] })
776
789
  ] });
777
790
  }
778
- function ft({ data: e, meta: s }) {
779
- const [i, a] = v(null), [o, d] = v(""), [n, r] = v(""), [m, h] = v(""), p = A(() => {
791
+ function bt({ data: e, meta: s }) {
792
+ const [d, a] = w(null), [o, i] = w(""), [n, r] = w(""), [m, x] = w(""), p = R(() => {
780
793
  if (!o || !e) return null;
781
794
  const c = (/* @__PURE__ */ new Date(`${o}T23:59:59`)).getTime();
782
- return e.find((x) => x.timestamp && new Date(x.timestamp).getTime() <= c) ?? null;
783
- }, [o, e]), u = A(() => {
795
+ return e.find((y) => y.timestamp && new Date(y.timestamp).getTime() <= c) ?? null;
796
+ }, [o, e]), u = R(() => {
784
797
  if (!n || !m || !e) return null;
785
- const c = (/* @__PURE__ */ new Date(`${n}T23:59:59`)).getTime(), x = (/* @__PURE__ */ new Date(`${m}T23:59:59`)).getTime();
786
- if (x <= c) return { error: "The second date must be after the first" };
787
- const R = (k) => e.find(($) => $.timestamp && new Date($.timestamp).getTime() <= k) ?? null, b = R(c), N = R(x);
798
+ const c = (/* @__PURE__ */ new Date(`${n}T23:59:59`)).getTime(), y = (/* @__PURE__ */ new Date(`${m}T23:59:59`)).getTime();
799
+ if (y <= c) return { error: "The second date must be after the first" };
800
+ const j = (v) => e.find(($) => $.timestamp && new Date($.timestamp).getTime() <= v) ?? null, f = j(c), N = j(y);
788
801
  if (!N) return { error: "No snapshot exists at or before the second date" };
789
- const S = (b == null ? void 0 : b.data) ?? {}, w = N.data ?? {}, C = /* @__PURE__ */ new Map();
790
- for (const k of [...e].reverse()) {
791
- const $ = k.timestamp ? new Date(k.timestamp).getTime() : 0;
792
- if (!($ <= c || $ > x || !k.delta))
793
- for (const V of Object.keys(k.delta))
794
- C.set(V, { name: P(k), when: k.timestamp });
802
+ const S = (f == null ? void 0 : f.data) ?? {}, h = N.data ?? {}, C = /* @__PURE__ */ new Map();
803
+ for (const v of [...e].reverse()) {
804
+ const $ = v.timestamp ? new Date(v.timestamp).getTime() : 0;
805
+ if (!($ <= c || $ > y || !v.delta))
806
+ for (const V of Object.keys(v.delta))
807
+ C.set(V, { name: B(v), when: v.timestamp });
795
808
  }
796
- return { fields: [.../* @__PURE__ */ new Set([...Object.keys(S), ...Object.keys(w)])].filter((k) => String(S[k] ?? "") !== String(w[k] ?? "")).map((k) => ({ field: k, from: S[k], to: w[k], by: C.get(k) ?? null })) };
809
+ return { fields: [.../* @__PURE__ */ new Set([...Object.keys(S), ...Object.keys(h)])].filter((v) => String(S[v] ?? "") !== String(h[v] ?? "")).map((v) => ({ field: v, from: S[v], to: h[v], by: C.get(v) ?? null })) };
797
810
  }, [n, m, e]), g = "h-7 rounded-md border border-slate-200 bg-white px-2 text-[12px] dark:border-border dark:bg-card";
798
811
  return /* @__PURE__ */ l("div", { className: "space-y-2", children: [
799
812
  /* @__PURE__ */ l("div", { className: "flex items-center gap-1.5", children: [
@@ -801,13 +814,13 @@ function ft({ data: e, meta: s }) {
801
814
  "button",
802
815
  {
803
816
  type: "button",
804
- onClick: () => a(i === "asof" ? null : "asof"),
817
+ onClick: () => a(d === "asof" ? null : "asof"),
805
818
  className: T(
806
819
  "inline-flex items-center gap-1.5 rounded-md border px-2.5 py-1 text-[11.5px] transition-colors",
807
- i === "asof" || o ? "border-nvr-cyan/40 bg-nvr-cyan/5 font-medium text-nvr-navy dark:text-nvr-cyan" : "border-slate-200 text-slate-500 hover:text-slate-700 dark:border-border dark:text-slate-400 dark:hover:text-slate-200"
820
+ d === "asof" || o ? "border-nvr-cyan/40 bg-nvr-cyan/5 font-medium text-nvr-navy dark:text-nvr-cyan" : "border-slate-200 text-slate-500 hover:text-slate-700 dark:border-border dark:text-slate-400 dark:hover:text-slate-200"
808
821
  ),
809
822
  children: [
810
- /* @__PURE__ */ t(_e, { className: "h-3.5 w-3.5" }),
823
+ /* @__PURE__ */ t(Te, { className: "h-3.5 w-3.5" }),
811
824
  "View as of a date"
812
825
  ]
813
826
  }
@@ -816,19 +829,19 @@ function ft({ data: e, meta: s }) {
816
829
  "button",
817
830
  {
818
831
  type: "button",
819
- onClick: () => a(i === "compare" ? null : "compare"),
832
+ onClick: () => a(d === "compare" ? null : "compare"),
820
833
  className: T(
821
834
  "inline-flex items-center gap-1.5 rounded-md border px-2.5 py-1 text-[11.5px] transition-colors",
822
- i === "compare" || n && m ? "border-nvr-cyan/40 bg-nvr-cyan/5 font-medium text-nvr-navy dark:text-nvr-cyan" : "border-slate-200 text-slate-500 hover:text-slate-700 dark:border-border dark:text-slate-400 dark:hover:text-slate-200"
835
+ d === "compare" || n && m ? "border-nvr-cyan/40 bg-nvr-cyan/5 font-medium text-nvr-navy dark:text-nvr-cyan" : "border-slate-200 text-slate-500 hover:text-slate-700 dark:border-border dark:text-slate-400 dark:hover:text-slate-200"
823
836
  ),
824
837
  children: [
825
- /* @__PURE__ */ t(Te, { className: "h-3.5 w-3.5" }),
838
+ /* @__PURE__ */ t(Re, { className: "h-3.5 w-3.5" }),
826
839
  "Compare two dates"
827
840
  ]
828
841
  }
829
842
  )
830
843
  ] }),
831
- i === "asof" && /* @__PURE__ */ l("div", { className: "rounded-lg border border-slate-200 bg-slate-50/60 p-2.5 dark:border-border dark:bg-muted/20", children: [
844
+ d === "asof" && /* @__PURE__ */ l("div", { className: "rounded-lg border border-slate-200 bg-slate-50/60 p-2.5 dark:border-border dark:bg-muted/20", children: [
832
845
  /* @__PURE__ */ l("div", { className: "flex items-center gap-2", children: [
833
846
  /* @__PURE__ */ t("span", { className: "text-[11.5px] text-slate-500 dark:text-slate-400", children: "Show the record exactly as it was on" }),
834
847
  /* @__PURE__ */ t(
@@ -836,7 +849,7 @@ function ft({ data: e, meta: s }) {
836
849
  {
837
850
  type: "date",
838
851
  value: o,
839
- onChange: (c) => d(c.target.value),
852
+ onChange: (c) => i(c.target.value),
840
853
  className: g,
841
854
  "aria-label": "View record as of date",
842
855
  "data-as-of": !0
@@ -846,7 +859,7 @@ function ft({ data: e, meta: s }) {
846
859
  "button",
847
860
  {
848
861
  type: "button",
849
- onClick: () => d(""),
862
+ onClick: () => i(""),
850
863
  className: "text-[11px] text-slate-400 hover:text-slate-600 dark:hover:text-slate-300",
851
864
  children: "Clear"
852
865
  }
@@ -859,7 +872,7 @@ function ft({ data: e, meta: s }) {
859
872
  " ",
860
873
  p.timestamp ? new Date(p.timestamp).toLocaleString() : o
861
874
  ] }) }),
862
- /* @__PURE__ */ t("div", { className: "max-h-80 overflow-y-auto", children: Object.entries(p.data ?? {}).filter(([, c]) => c != null && c !== "").sort(([c], [x]) => y(s, c).label.localeCompare(y(s, x).label)).map(([c, x]) => /* @__PURE__ */ l(
875
+ /* @__PURE__ */ t("div", { className: "max-h-80 overflow-y-auto", children: Object.entries(p.data ?? {}).filter(([, c]) => c != null && c !== "").sort(([c], [y]) => k(s, c).label.localeCompare(k(s, y).label)).map(([c, y]) => /* @__PURE__ */ l(
863
876
  "div",
864
877
  {
865
878
  className: "flex items-start gap-3 border-b border-slate-100 px-2.5 py-1.5 last:border-0 dark:border-border/60",
@@ -869,17 +882,17 @@ function ft({ data: e, meta: s }) {
869
882
  {
870
883
  className: "w-[200px] shrink-0 text-[11.5px] font-medium text-slate-600 dark:text-slate-300",
871
884
  title: c,
872
- children: y(s, c).label
885
+ children: k(s, c).label
873
886
  }
874
887
  ),
875
- /* @__PURE__ */ t("span", { className: "break-words text-[11.5px] text-slate-700 dark:text-slate-300", children: /* @__PURE__ */ t(q, { value: x, meta: y(s, c), tone: "after" }) })
888
+ /* @__PURE__ */ t("span", { className: "break-words text-[11.5px] text-slate-700 dark:text-slate-300", children: /* @__PURE__ */ t(D, { value: y, meta: k(s, c), tone: "after" }) })
876
889
  ]
877
890
  },
878
891
  c
879
892
  )) })
880
893
  ] })
881
894
  ] }),
882
- i === "compare" && /* @__PURE__ */ l("div", { className: "rounded-lg border border-slate-200 bg-slate-50/60 p-2.5 dark:border-border dark:bg-muted/20", children: [
895
+ d === "compare" && /* @__PURE__ */ l("div", { className: "rounded-lg border border-slate-200 bg-slate-50/60 p-2.5 dark:border-border dark:bg-muted/20", children: [
883
896
  /* @__PURE__ */ l("div", { className: "flex flex-wrap items-center gap-2", children: [
884
897
  /* @__PURE__ */ t("span", { className: "text-[11.5px] text-slate-500 dark:text-slate-400", children: "What changed between" }),
885
898
  /* @__PURE__ */ t(
@@ -899,7 +912,7 @@ function ft({ data: e, meta: s }) {
899
912
  {
900
913
  type: "date",
901
914
  value: m,
902
- onChange: (c) => h(c.target.value),
915
+ onChange: (c) => x(c.target.value),
903
916
  className: g,
904
917
  "aria-label": "Compare to date",
905
918
  "data-diff-to": !0
@@ -910,7 +923,7 @@ function ft({ data: e, meta: s }) {
910
923
  {
911
924
  type: "button",
912
925
  onClick: () => {
913
- r(""), h("");
926
+ r(""), x("");
914
927
  },
915
928
  className: "text-[11px] text-slate-400 hover:text-slate-600 dark:hover:text-slate-300",
916
929
  children: "Clear"
@@ -945,7 +958,7 @@ function ft({ data: e, meta: s }) {
945
958
  {
946
959
  className: "text-[11.5px] font-medium text-slate-600 dark:text-slate-300",
947
960
  title: c.field,
948
- children: y(s, c.field).label
961
+ children: k(s, c.field).label
949
962
  }
950
963
  ),
951
964
  c.by && /* @__PURE__ */ l("span", { className: "shrink-0 text-[10.5px] text-slate-400", children: [
@@ -954,8 +967,8 @@ function ft({ data: e, meta: s }) {
954
967
  ] })
955
968
  ] }),
956
969
  /* @__PURE__ */ l("p", { className: "mt-0.5 flex flex-wrap items-baseline gap-x-2 break-words text-[11.5px]", children: [
957
- /* @__PURE__ */ t("span", { className: "text-red-500 line-through dark:text-red-400", children: /* @__PURE__ */ t(q, { value: c.from, meta: y(s, c.field), tone: "before" }) }),
958
- /* @__PURE__ */ t("span", { className: "text-emerald-600 dark:text-emerald-400", children: /* @__PURE__ */ t(q, { value: c.to, meta: y(s, c.field), tone: "after" }) })
970
+ /* @__PURE__ */ t("span", { className: "text-red-500 line-through dark:text-red-400", children: /* @__PURE__ */ t(D, { value: c.from, meta: k(s, c.field), tone: "before" }) }),
971
+ /* @__PURE__ */ t("span", { className: "text-emerald-600 dark:text-emerald-400", children: /* @__PURE__ */ t(D, { value: c.to, meta: k(s, c.field), tone: "after" }) })
959
972
  ] })
960
973
  ]
961
974
  },
@@ -967,7 +980,7 @@ function ft({ data: e, meta: s }) {
967
980
  ] })
968
981
  ] });
969
982
  }
970
- function bt(e) {
983
+ function gt(e) {
971
984
  return e ? new Date(e).toLocaleDateString([], {
972
985
  weekday: "short",
973
986
  month: "short",
@@ -975,48 +988,48 @@ function bt(e) {
975
988
  year: "numeric"
976
989
  }) : "Unknown date";
977
990
  }
978
- function gt({
991
+ function yt({
979
992
  collection: e,
980
993
  item: s,
981
- onRollback: i,
994
+ onRollback: d,
982
995
  inlineTableFields: a
983
996
  }) {
984
- const o = F(), d = ue(e, !0), { data: n, isLoading: r } = B({
997
+ const o = F(), i = ue(e, !0), { data: n, isLoading: r } = P({
985
998
  queryKey: ["revisions", e, s],
986
- queryFn: () => o.request(D("/revisions", { collection: e, item: s })).then((b) => b.data ?? []),
999
+ queryFn: () => o.request(q("/revisions", { collection: e, item: s })).then((f) => f.data ?? []),
987
1000
  staleTime: 3e4
988
1001
  }), m = ee();
989
- Be(e, s, [["revisions", e, s]], { client: m });
990
- const h = $e(null), p = A(() => {
1002
+ Ie(e, s, [["revisions", e, s]], { client: m });
1003
+ const x = Oe(null), p = R(() => {
991
1004
  if (!n) return /* @__PURE__ */ new Set();
992
- const b = n.map(O);
993
- if (!h.current)
994
- return h.current = new Set(b), /* @__PURE__ */ new Set();
995
- const N = h.current;
996
- return new Set(b.filter((S) => !N.has(S)));
997
- }, [n]), u = (n == null ? void 0 : n.length) ?? 0, g = A(() => (n ?? []).filter(G), [n]), c = A(
998
- () => (n ?? []).filter((b) => b.actor && b.actor.kind !== "person").map((b) => ({ action: b.action, user: b.user_id, actor: b.actor })),
1005
+ const f = n.map(O);
1006
+ if (!x.current)
1007
+ return x.current = new Set(f), /* @__PURE__ */ new Set();
1008
+ const N = x.current;
1009
+ return new Set(f.filter((S) => !N.has(S)));
1010
+ }, [n]), u = (n == null ? void 0 : n.length) ?? 0, g = R(() => (n ?? []).filter(G), [n]), c = R(
1011
+ () => (n ?? []).filter((f) => f.actor && f.actor.kind !== "person").map((f) => ({ action: f.action, user: f.user_id, actor: f.actor })),
999
1012
  [n]
1000
- ), x = Ke(c, { enabled: c.length > 0 }), R = A(() => {
1001
- const b = [];
1013
+ ), y = Me(c, { enabled: c.length > 0 }), j = R(() => {
1014
+ const f = [];
1002
1015
  for (const N of n ?? []) {
1003
- const S = bt(N.timestamp), w = b[b.length - 1];
1004
- w && w.day === S ? w.revisions.push(N) : b.push({ day: S, revisions: [N] });
1016
+ const S = gt(N.timestamp), h = f[f.length - 1];
1017
+ h && h.day === S ? h.revisions.push(N) : f.push({ day: S, revisions: [N] });
1005
1018
  }
1006
- return b;
1019
+ return f;
1007
1020
  }, [n]);
1008
- return r ? /* @__PURE__ */ t("div", { className: "space-y-2 pt-3", children: [1, 2, 3, 4].map((b) => /* @__PURE__ */ t(Qe, { className: "h-11 rounded-md" }, b)) }) : u === 0 ? /* @__PURE__ */ l("div", { className: "flex flex-col items-center py-16 text-center", children: [
1021
+ return r ? /* @__PURE__ */ t("div", { className: "space-y-2 pt-3", children: [1, 2, 3, 4].map((f) => /* @__PURE__ */ t(Ye, { className: "h-11 rounded-md" }, f)) }) : u === 0 ? /* @__PURE__ */ l("div", { className: "flex flex-col items-center py-16 text-center", children: [
1009
1022
  /* @__PURE__ */ t(Y, { className: "mb-2 h-8 w-8 text-slate-300 dark:text-slate-600" }),
1010
1023
  /* @__PURE__ */ t("p", { className: "text-[13px] font-medium text-slate-600 dark:text-slate-300", children: "No history yet" }),
1011
1024
  /* @__PURE__ */ t("p", { className: "mt-1 max-w-[38ch] text-[12px] text-slate-400", children: "Every save records who changed what — the trail will appear here." })
1012
- ] }) : /* @__PURE__ */ t(te.Provider, { value: x, children: /* @__PURE__ */ l("div", { className: "space-y-3 pt-3", children: [
1013
- /* @__PURE__ */ t(ft, { data: g, meta: d }),
1014
- g.length >= 3 && /* @__PURE__ */ t(kt, { revisions: g, meta: d }),
1015
- /* @__PURE__ */ t("div", { children: R.map((b) => /* @__PURE__ */ l("div", { children: [
1016
- /* @__PURE__ */ t("div", { className: "sticky top-0 z-10 -mx-6 border-b border-slate-100 bg-white px-6 py-1.5 dark:border-border/60 dark:bg-card", children: /* @__PURE__ */ t("span", { className: "text-[10.5px] font-semibold uppercase tracking-wide text-slate-400", children: b.day }) }),
1017
- b.revisions.map((N) => {
1018
- const S = (n ?? []).indexOf(N), w = S === ((n == null ? void 0 : n.length) ?? 1) - 1;
1019
- if (Ge(N))
1025
+ ] }) : /* @__PURE__ */ t(te.Provider, { value: y, children: /* @__PURE__ */ l("div", { className: "space-y-3 pt-3", children: [
1026
+ /* @__PURE__ */ t(bt, { data: g, meta: i }),
1027
+ g.length >= 3 && /* @__PURE__ */ t(vt, { revisions: g, meta: i }),
1028
+ /* @__PURE__ */ t("div", { children: j.map((f) => /* @__PURE__ */ l("div", { children: [
1029
+ /* @__PURE__ */ t("div", { className: "sticky top-0 z-10 -mx-6 border-b border-slate-100 bg-white px-6 py-1.5 dark:border-border/60 dark:bg-card", children: /* @__PURE__ */ t("span", { className: "text-[10.5px] font-semibold uppercase tracking-wide text-slate-400", children: f.day }) }),
1030
+ f.revisions.map((N) => {
1031
+ const S = (n ?? []).indexOf(N), h = S === ((n == null ? void 0 : n.length) ?? 1) - 1;
1032
+ if (Xe(N))
1020
1033
  return /* @__PURE__ */ l(
1021
1034
  "div",
1022
1035
  {
@@ -1026,7 +1039,7 @@ function gt({
1026
1039
  ),
1027
1040
  children: [
1028
1041
  p.has(O(N)) && /* @__PURE__ */ t(oe, {}),
1029
- /* @__PURE__ */ t(ht, { revision: N, isLast: w })
1042
+ /* @__PURE__ */ t(xt, { revision: N, isLast: h })
1030
1043
  ]
1031
1044
  },
1032
1045
  O(N)
@@ -1042,14 +1055,14 @@ function gt({
1042
1055
  children: [
1043
1056
  p.has(O(N)) && /* @__PURE__ */ t(oe, {}),
1044
1057
  /* @__PURE__ */ t(
1045
- xt,
1058
+ ft,
1046
1059
  {
1047
1060
  revision: N,
1048
1061
  previousData: (C == null ? void 0 : C.data) ?? null,
1049
- meta: d,
1050
- onRollback: i,
1062
+ meta: i,
1063
+ onRollback: d,
1051
1064
  inlineTableFields: a,
1052
- isLast: w
1065
+ isLast: h
1053
1066
  }
1054
1067
  )
1055
1068
  ]
@@ -1057,7 +1070,7 @@ function gt({
1057
1070
  O(N)
1058
1071
  );
1059
1072
  })
1060
- ] }, b.day)) })
1073
+ ] }, f.day)) })
1061
1074
  ] }) });
1062
1075
  }
1063
1076
  function oe() {
@@ -1073,18 +1086,18 @@ function oe() {
1073
1086
  )
1074
1087
  );
1075
1088
  }
1076
- function Kt({
1089
+ function Mt({
1077
1090
  collection: e,
1078
1091
  item: s,
1079
- onRollback: i,
1092
+ onRollback: d,
1080
1093
  triggerClassName: a,
1081
1094
  inlineTableFields: o,
1082
- open: d,
1095
+ open: i,
1083
1096
  onOpenChange: n,
1084
1097
  compact: r
1085
1098
  }) {
1086
- return /* @__PURE__ */ l(We, { open: d, onOpenChange: n, children: [
1087
- !(d !== void 0) && /* @__PURE__ */ t(Ve, { asChild: !0, children: /* @__PURE__ */ l(
1099
+ return /* @__PURE__ */ l(Ve, { open: i, onOpenChange: n, children: [
1100
+ !(i !== void 0) && /* @__PURE__ */ t(ze, { asChild: !0, children: /* @__PURE__ */ l(
1088
1101
  M,
1089
1102
  {
1090
1103
  variant: r ? "ghost" : "outline",
@@ -1098,42 +1111,42 @@ function Kt({
1098
1111
  ]
1099
1112
  }
1100
1113
  ) }),
1101
- /* @__PURE__ */ t(ze, { className: "w-[720px] overflow-y-auto p-0 sm:max-w-[92vw]", children: /* @__PURE__ */ l("div", { className: "p-6", children: [
1102
- /* @__PURE__ */ l(He, { children: [
1103
- /* @__PURE__ */ l(Je, { className: "flex items-center gap-2 text-base", children: [
1114
+ /* @__PURE__ */ t(He, { className: "w-[720px] overflow-y-auto p-0 sm:max-w-[92vw]", children: /* @__PURE__ */ l("div", { className: "p-6", children: [
1115
+ /* @__PURE__ */ l(Je, { children: [
1116
+ /* @__PURE__ */ l(Qe, { className: "flex items-center gap-2 text-base", children: [
1104
1117
  /* @__PURE__ */ t(Y, { className: "h-4 w-4 text-slate-400" }),
1105
1118
  "Revision history"
1106
1119
  ] }),
1107
1120
  /* @__PURE__ */ t("p", { className: "text-[12px] text-slate-400", children: "Who changed what, when — expand any entry to see the exact values, revert a single field, or restore the whole version." })
1108
1121
  ] }),
1109
- /* @__PURE__ */ t(yt, { collection: e, item: s }),
1110
- /* @__PURE__ */ t(Ye, { collection: e, item: String(s) }),
1122
+ /* @__PURE__ */ t(Nt, { collection: e, item: s }),
1123
+ /* @__PURE__ */ t(Ge, { collection: e, item: String(s) }),
1111
1124
  /* @__PURE__ */ t(
1112
- gt,
1125
+ yt,
1113
1126
  {
1114
1127
  collection: e,
1115
1128
  item: s,
1116
- onRollback: i,
1129
+ onRollback: d,
1117
1130
  inlineTableFields: o
1118
1131
  }
1119
1132
  )
1120
1133
  ] }) })
1121
1134
  ] });
1122
1135
  }
1123
- function yt({ collection: e, item: s }) {
1124
- const i = F(), a = ue(e, !0), [o, d] = v(""), [n, r] = v(""), { data: m, isFetching: h } = B({
1136
+ function Nt({ collection: e, item: s }) {
1137
+ const d = F(), a = ue(e, !0), [o, i] = w(""), [n, r] = w(""), { data: m, isFetching: x } = P({
1125
1138
  queryKey: ["rev-value-search", e, s, n],
1126
- queryFn: () => i.request(D("/revisions/value-search", { collection: e, item: s, q: n })).then((p) => p.data),
1139
+ queryFn: () => d.request(q("/revisions/value-search", { collection: e, item: s, q: n })).then((p) => p.data),
1127
1140
  enabled: n.length >= 2
1128
1141
  });
1129
1142
  return /* @__PURE__ */ l("div", { className: "mt-3", children: [
1130
1143
  /* @__PURE__ */ l("div", { className: "relative", children: [
1131
- /* @__PURE__ */ t(Se, { className: "pointer-events-none absolute left-2.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-slate-400" }),
1144
+ /* @__PURE__ */ t(Ce, { className: "pointer-events-none absolute left-2.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-slate-400" }),
1132
1145
  /* @__PURE__ */ t(
1133
1146
  "input",
1134
1147
  {
1135
1148
  value: o,
1136
- onChange: (p) => d(p.target.value),
1149
+ onChange: (p) => i(p.target.value),
1137
1150
  onKeyDown: (p) => {
1138
1151
  p.key === "Enter" && r(o.trim());
1139
1152
  },
@@ -1146,22 +1159,22 @@ function yt({ collection: e, item: s }) {
1146
1159
  {
1147
1160
  type: "button",
1148
1161
  onClick: () => {
1149
- d(""), r("");
1162
+ i(""), r("");
1150
1163
  },
1151
1164
  className: "absolute right-2 top-1/2 -translate-y-1/2 text-slate-400 hover:text-slate-600",
1152
1165
  "aria-label": "Clear search",
1153
- children: /* @__PURE__ */ t(Ce, { className: "h-3.5 w-3.5" })
1166
+ children: /* @__PURE__ */ t(_e, { className: "h-3.5 w-3.5" })
1154
1167
  }
1155
1168
  )
1156
1169
  ] }),
1157
- n && /* @__PURE__ */ t("div", { className: "mt-2 space-y-1.5 rounded-lg border border-slate-200 p-2.5 dark:border-border", children: h ? /* @__PURE__ */ t("p", { className: "text-[11.5px] text-slate-400", children: "Searching…" }) : ((m == null ? void 0 : m.matches) ?? []).length === 0 ? /* @__PURE__ */ l("p", { className: "text-[11.5px] text-slate-400", children: [
1170
+ n && /* @__PURE__ */ t("div", { className: "mt-2 space-y-1.5 rounded-lg border border-slate-200 p-2.5 dark:border-border", children: x ? /* @__PURE__ */ t("p", { className: "text-[11.5px] text-slate-400", children: "Searching…" }) : ((m == null ? void 0 : m.matches) ?? []).length === 0 ? /* @__PURE__ */ l("p", { className: "text-[11.5px] text-slate-400", children: [
1158
1171
  "“",
1159
1172
  n,
1160
1173
  "” never appears in this record’s recorded changes."
1161
1174
  ] }) : /* @__PURE__ */ l(L, { children: [
1162
1175
  m == null ? void 0 : m.matches.map((p) => /* @__PURE__ */ l("div", { className: "text-[11.5px]", children: [
1163
1176
  /* @__PURE__ */ t("p", { className: "text-slate-600 dark:text-slate-300", children: p.fields.map((u) => /* @__PURE__ */ l("span", { children: [
1164
- /* @__PURE__ */ t("span", { className: "font-medium", title: u.field, children: y(a, u.field).label }),
1177
+ /* @__PURE__ */ t("span", { className: "font-medium", title: u.field, children: k(a, u.field).label }),
1165
1178
  " ",
1166
1179
  "→ “",
1167
1180
  u.value.length > 60 ? `${u.value.slice(0, 60)}…` : u.value,
@@ -1181,22 +1194,22 @@ function yt({ collection: e, item: s }) {
1181
1194
  ] }) })
1182
1195
  ] });
1183
1196
  }
1184
- function Nt({ revisionId: e }) {
1185
- const s = F(), i = ee(), [a, o] = v(""), { data: d = [] } = B({
1197
+ function kt({ revisionId: e }) {
1198
+ const s = F(), d = ee(), [a, o] = w(""), { data: i = [] } = P({
1186
1199
  queryKey: ["revision-notes", String(e)],
1187
- queryFn: () => s.request(D("/comments", { collection: "nivaro_revisions", item: String(e) })).then((r) => r.data ?? []).catch(() => []),
1200
+ queryFn: () => s.request(q("/comments", { collection: "nivaro_revisions", item: String(e) })).then((r) => r.data ?? []).catch(() => []),
1188
1201
  staleTime: 3e4
1189
1202
  }), n = Q({
1190
1203
  mutationFn: () => s.request(
1191
1204
  K("/comments", { collection: "nivaro_revisions", item: String(e), text: a })
1192
1205
  ),
1193
1206
  onSuccess: () => {
1194
- o(""), i.invalidateQueries({ queryKey: ["revision-notes", String(e)] });
1207
+ o(""), d.invalidateQueries({ queryKey: ["revision-notes", String(e)] });
1195
1208
  },
1196
- onError: () => j.error("Note failed")
1209
+ onError: () => A.error("Note failed")
1197
1210
  });
1198
1211
  return /* @__PURE__ */ l("div", { className: "rounded-md border border-slate-100 bg-slate-50/60 p-2 dark:border-border/60 dark:bg-muted/30", children: [
1199
- d.map((r) => /* @__PURE__ */ l("p", { className: "text-[11.5px] text-slate-600 dark:text-slate-300", children: [
1212
+ i.map((r) => /* @__PURE__ */ l("p", { className: "text-[11.5px] text-slate-600 dark:text-slate-300", children: [
1200
1213
  r.text,
1201
1214
  " ",
1202
1215
  /* @__PURE__ */ l("span", { className: "text-[10px] text-slate-400", children: [
@@ -1237,21 +1250,21 @@ function Nt({ revisionId: e }) {
1237
1250
  )
1238
1251
  ] });
1239
1252
  }
1240
- function kt({
1253
+ function vt({
1241
1254
  revisions: e,
1242
1255
  meta: s
1243
1256
  }) {
1244
- const i = [...e].reverse(), [a, o] = v(!1), [d, n] = v(0);
1257
+ const d = [...e].reverse(), [a, o] = w(!1), [i, n] = w(0);
1245
1258
  qe(() => {
1246
1259
  if (!a) return;
1247
- if (d >= i.length - 1) {
1260
+ if (i >= d.length - 1) {
1248
1261
  o(!1);
1249
1262
  return;
1250
1263
  }
1251
- const h = setTimeout(() => n((p) => p + 1), 1600);
1252
- return () => clearTimeout(h);
1253
- }, [a, d, i.length]);
1254
- const r = i[d], m = r != null && r.delta ? Object.keys(r.delta).slice(0, 5).map((h) => y(s, h).label) : [];
1264
+ const x = setTimeout(() => n((p) => p + 1), 1600);
1265
+ return () => clearTimeout(x);
1266
+ }, [a, i, d.length]);
1267
+ const r = d[i], m = r != null && r.delta ? Object.keys(r.delta).slice(0, 5).map((x) => k(s, x).label) : [];
1255
1268
  return /* @__PURE__ */ l("div", { className: "rounded-md border border-slate-200 bg-slate-50/70 p-2 dark:border-border dark:bg-muted/30", children: [
1256
1269
  /* @__PURE__ */ l("div", { className: "flex items-center gap-2", children: [
1257
1270
  /* @__PURE__ */ t(
@@ -1259,7 +1272,7 @@ function kt({
1259
1272
  {
1260
1273
  type: "button",
1261
1274
  onClick: () => {
1262
- !a && d >= i.length - 1 && n(0), o((h) => !h);
1275
+ !a && i >= d.length - 1 && n(0), o((x) => !x);
1263
1276
  },
1264
1277
  className: "rounded-md bg-nvr-cyan px-2.5 py-1 text-[11.5px] font-semibold text-white",
1265
1278
  children: a ? "Pause" : "▶ Time-lapse"
@@ -1270,19 +1283,19 @@ function kt({
1270
1283
  {
1271
1284
  type: "range",
1272
1285
  min: 0,
1273
- max: Math.max(0, i.length - 1),
1274
- value: d,
1275
- onChange: (h) => {
1276
- o(!1), n(Number(h.target.value));
1286
+ max: Math.max(0, d.length - 1),
1287
+ value: i,
1288
+ onChange: (x) => {
1289
+ o(!1), n(Number(x.target.value));
1277
1290
  },
1278
1291
  className: "flex-1 accent-nvr-cyan",
1279
1292
  "aria-label": "History position"
1280
1293
  }
1281
1294
  ),
1282
1295
  /* @__PURE__ */ l("span", { className: "shrink-0 tabular-nums text-[11px] text-slate-400", children: [
1283
- d + 1,
1296
+ i + 1,
1284
1297
  "/",
1285
- i.length
1298
+ d.length
1286
1299
  ] })
1287
1300
  ] }),
1288
1301
  r && /* @__PURE__ */ l("p", { className: "mt-1 text-[11.5px] text-slate-600 dark:text-slate-300", children: [
@@ -1297,6 +1310,7 @@ function kt({
1297
1310
  ] });
1298
1311
  }
1299
1312
  export {
1300
- Kt as RevisionsPanel,
1301
- tt as displayValue
1313
+ pt as FieldChangeList,
1314
+ Mt as RevisionsPanel,
1315
+ at as displayValue
1302
1316
  };