@nivaro/react 0.3.57 → 0.3.59

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