@nivaro/react 0.3.50 → 0.3.52

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 (29) hide show
  1. package/dist/hooks/useSessionRecorder.js +1 -1
  2. package/dist/index.d.ts +13 -3
  3. package/dist/shared/components/ItemEditForm.js +4801 -4666
  4. package/dist/shared/components/QueryTable.js +337 -324
  5. package/dist/shared/components/ReportView.js +105 -99
  6. package/dist/shared/components/alerts/AlertManagerView.js +327 -301
  7. package/dist/shared/components/item-edit/CatalogPickerField.js +1149 -1111
  8. package/dist/shared/components/item-edit/DraftRecoveryBanner.js +58 -53
  9. package/dist/shared/components/item-edit/FieldRenderer.js +227 -223
  10. package/dist/shared/components/item-edit/FieldRow.js +287 -265
  11. package/dist/shared/components/item-edit/FilePickerField.js +315 -307
  12. package/dist/shared/components/item-edit/InlineTableField.js +491 -466
  13. package/dist/shared/components/item-edit/RecordHeaderActions.js +76 -75
  14. package/dist/shared/components/item-edit/RecordLiveSync.js +93 -91
  15. package/dist/shared/components/item-edit/RelationCombobox.js +62 -60
  16. package/dist/shared/components/item-edit/SummaryPanel.js +287 -277
  17. package/dist/shared/components/item-edit/UserChip.js +233 -200
  18. package/dist/shared/components/item-edit/header-midair.js +51 -0
  19. package/dist/shared/components/item-edit/line-midair.js +76 -70
  20. package/dist/shared/components/panels/CommentPanel.js +290 -284
  21. package/dist/shared/components/panels/ItemLockBanner.js +30 -30
  22. package/dist/shared/components/panels/PipelinePanel.js +956 -901
  23. package/dist/shared/components/panels/TaskPanel.js +71 -61
  24. package/dist/shared/components/panels/TransitionRequirementsDialog.js +569 -439
  25. package/dist/shared/components/panels/requirement-side-effects.js +40 -0
  26. package/dist/shared/components/queue/QueueWorklist.js +141 -130
  27. package/dist/shared/lib/draft-store.js +48 -34
  28. package/dist/shared/lib/query-stats.js +60 -60
  29. package/package.json +1 -1
@@ -1,18 +1,18 @@
1
- import { jsxs as d, jsx as n } from "react/jsx-runtime";
2
- import { useQueryClient as Ge, useQueries as bt, useQuery as re, useMutation as gt } from "@tanstack/react-query";
1
+ import { jsxs as u, jsx as n } from "react/jsx-runtime";
2
+ import { useQueryClient as Ge, useQueries as bt, useQuery as le, useMutation as gt } from "@tanstack/react-query";
3
3
  import { Info as vt, Loader2 as wt, Sparkles as kt, Lock as _t, SlidersHorizontal as Nt, History as Ft, BellRing as Ct, Bell as Lt, Sigma as Rt } from "lucide-react";
4
- import { memo as St, useState as ve, useRef as S, useId as $t, useEffect as le, useCallback as He } from "react";
5
- import { toast as oe } from "sonner";
4
+ import { memo as St, useState as ve, useRef as $, useId as $t, useEffect as oe, useCallback as He } from "react";
5
+ import { toast as ae } from "sonner";
6
6
  import { useParentDraft as qt, useNivaroClient as ie } from "../../context.js";
7
7
  import { showsAiButton as At, AUTOFILL_CHECK_KEY as Tt, readAiFill as Et } from "../../lib/ai-fill.js";
8
8
  import { get as K, del as Pt, post as ge } from "../../lib/commands.js";
9
9
  import { toastError as jt } from "../../lib/error-toast.js";
10
- import { titleCase as Z, cn as j } from "../../lib/utils.js";
10
+ import { titleCase as I, cn as j } from "../../lib/utils.js";
11
11
  import { GlossaryLabel as We } from "../ai/GlossaryText.js";
12
- import { useFieldSource as Bt, FieldSourceInfo as Ot } from "../ConfigReadBack.js";
13
- import { Label as Dt } from "../ui/label.js";
14
- import { TooltipProvider as I, Tooltip as ee, TooltipTrigger as te, TooltipContent as ne } from "../ui/tooltip.js";
15
- import { useAddendumFields as Mt } from "./AddendumFieldContext.js";
12
+ import { useFieldSource as Bt, FieldSourceInfo as Dt } from "../ConfigReadBack.js";
13
+ import { Label as Mt } from "../ui/label.js";
14
+ import { TooltipProvider as ee, Tooltip as te, TooltipTrigger as ne, TooltipContent as re } from "../ui/tooltip.js";
15
+ import { useAddendumFields as Ot } from "./AddendumFieldContext.js";
16
16
  import { AutoIdPreviewField as Kt } from "./AutoIdPreviewField.js";
17
17
  import { FOCUSABLE as Ve } from "./entry/entry-keys.js";
18
18
  import { useFieldAffordances as Ut, useFieldContextMenu as Ht, usePresenceSoftLock as Wt, LockReasonBadge as Vt, PresenceSoftLockStrip as zt, RemoteChangeGhost as Gt } from "./FieldAffordances.js";
@@ -53,59 +53,62 @@ function Cn(c) {
53
53
  const e = c.interface ?? "";
54
54
  return Nn.has(e) || e.startsWith("relation-") || e.endsWith("-m2o") || e.endsWith("-m2m") ? !1 : !!(kn.has(c.type ?? "") || _n.has(e) || !e && c.type && !wn.has(c.type));
55
55
  }
56
- function Ln(c, e, u, p) {
56
+ function Ln(c, e, i) {
57
+ return c.filter((p) => (i == null ? void 0 : i(p)) !== e);
58
+ }
59
+ function Rn(c, e, i, p) {
57
60
  const f = ie();
58
- return re({
59
- queryKey: ["field-lineage", c, e, u],
61
+ return le({
62
+ queryKey: ["field-lineage", c, e, i],
60
63
  queryFn: () => f.request(
61
- K(`/lineage/${c}/${encodeURIComponent(e)}/${u}`)
62
- ).then((a) => a.data),
64
+ K(`/lineage/${c}/${encodeURIComponent(e)}/${i}`)
65
+ ).then((s) => s.data),
63
66
  enabled: p,
64
67
  staleTime: 3e4
65
68
  });
66
69
  }
67
- function cr(c, e = "rows") {
68
- var l, _, b;
70
+ function dr(c, e = "rows") {
71
+ var l, w, g;
69
72
  if (c && (c.kind === "write" || c.kind === "read") && c.formula) {
70
- const m = (y) => typeof y == "number" ? y.toLocaleString(void 0, { maximumFractionDigits: 2 }) : y == null || y === "" ? "∅" : String(y);
71
- return `= ${c.formula.replace(/item\.([A-Za-z_][A-Za-z0-9_]*)/g, (y, o) => {
73
+ const m = (b) => typeof b == "number" ? b.toLocaleString(void 0, { maximumFractionDigits: 2 }) : b == null || b === "" ? "∅" : String(b);
74
+ return `= ${c.formula.replace(/item\.([A-Za-z_][A-Za-z0-9_]*)/g, (b, o) => {
72
75
  var x;
73
76
  return m((x = c.inputs) == null ? void 0 : x[o]);
74
77
  }).replace(/\s*-\s*/g, " − ").replace(/\s*\*\s*/g, " × ").replace(/\s*\/\s*/g, " ÷ ")}`;
75
78
  }
76
79
  if (!c || c.kind !== "rollup") return null;
77
- const u = (c.sources ?? []).reduce((m, i) => m + i.rows.length, 0), p = (c.sources ?? []).reduce((m, i) => {
78
- var y;
79
- return m + (((y = i.excluded) == null ? void 0 : y.length) ?? 0);
80
- }, 0), f = (b = (_ = (l = (c.sources ?? []).find((m) => {
81
- var i;
82
- return (i = m.excluded) == null ? void 0 : i.length;
83
- })) == null ? void 0 : l.excluded) == null ? void 0 : _[0]) == null ? void 0 : b.reason, a = [`= ${u} ${u === 1 ? e.replace(/s$/, "") : e}`];
84
- return p && a.push(
80
+ const i = (c.sources ?? []).reduce((m, a) => m + a.rows.length, 0), p = (c.sources ?? []).reduce((m, a) => {
81
+ var b;
82
+ return m + (((b = a.excluded) == null ? void 0 : b.length) ?? 0);
83
+ }, 0), f = (g = (w = (l = (c.sources ?? []).find((m) => {
84
+ var a;
85
+ return (a = m.excluded) == null ? void 0 : a.length;
86
+ })) == null ? void 0 : l.excluded) == null ? void 0 : w[0]) == null ? void 0 : g.reason, s = [`= ${i} ${i === 1 ? e.replace(/s$/, "") : e}`];
87
+ return p && s.push(
85
88
  `${p} excluded${f ? ` (${f.replace(/^does not match: /, "")})` : ""}`
86
- ), a.join(" · ");
89
+ ), s.join(" · ");
87
90
  }
88
- function Rn({
91
+ function Sn({
89
92
  collection: c,
90
93
  itemId: e,
91
- field: u
94
+ field: i
92
95
  }) {
93
- const [p, f] = ve(!1), a = S(null), { data: l, isLoading: _ } = Ln(c, e, u, p);
94
- le(() => {
96
+ const [p, f] = ve(!1), s = $(null), { data: l, isLoading: w } = Rn(c, e, i, p);
97
+ oe(() => {
95
98
  if (!p) return;
96
- const i = (y) => {
99
+ const a = (b) => {
97
100
  var o;
98
- (o = a.current) != null && o.contains(y.target) || f(!1);
101
+ (o = s.current) != null && o.contains(b.target) || f(!1);
99
102
  };
100
- return window.addEventListener("mousedown", i), () => window.removeEventListener("mousedown", i);
103
+ return window.addEventListener("mousedown", a), () => window.removeEventListener("mousedown", a);
101
104
  }, [p]);
102
- const b = (i) => i == null ? "—" : Number(i).toLocaleString(void 0, { maximumFractionDigits: 2 }), m = (l == null ? void 0 : l.stored_value) != null ? Number(l.stored_value) : null;
103
- return /* @__PURE__ */ d("div", { ref: a, className: "relative inline-flex", children: [
105
+ const g = (a) => a == null ? "—" : Number(a).toLocaleString(void 0, { maximumFractionDigits: 2 }), m = (l == null ? void 0 : l.stored_value) != null ? Number(l.stored_value) : null;
106
+ return /* @__PURE__ */ u("div", { ref: s, className: "relative inline-flex", children: [
104
107
  /* @__PURE__ */ n(
105
108
  "button",
106
109
  {
107
110
  type: "button",
108
- onClick: () => f((i) => !i),
111
+ onClick: () => f((a) => !a),
109
112
  title: "Where does this number come from?",
110
113
  className: j(
111
114
  "inline-flex items-center rounded p-0.5 transition-opacity",
@@ -115,40 +118,40 @@ function Rn({
115
118
  children: /* @__PURE__ */ n(Rt, { className: "h-3 w-3" })
116
119
  }
117
120
  ),
118
- p && /* @__PURE__ */ d("div", { className: "absolute left-0 top-full z-40 mt-1 max-h-[340px] w-[360px] overflow-y-auto rounded-lg border border-slate-200 bg-white p-2 shadow-lg dark:border-border dark:bg-card", children: [
121
+ p && /* @__PURE__ */ u("div", { className: "absolute left-0 top-full z-40 mt-1 max-h-[340px] w-[360px] overflow-y-auto rounded-lg border border-slate-200 bg-white p-2 shadow-lg dark:border-border dark:bg-card", children: [
119
122
  /* @__PURE__ */ n("p", { className: "mb-1 px-1 text-[10px] font-semibold uppercase tracking-wide text-slate-400", children: "Where this number comes from" }),
120
- _ && /* @__PURE__ */ n("p", { className: "px-1 py-2 text-[11.5px] text-slate-400", children: "Loading…" }),
121
- (l == null ? void 0 : l.kind) === "write" && /* @__PURE__ */ d("div", { className: "space-y-1 px-1 py-1", children: [
123
+ w && /* @__PURE__ */ n("p", { className: "px-1 py-2 text-[11.5px] text-slate-400", children: "Loading…" }),
124
+ (l == null ? void 0 : l.kind) === "write" && /* @__PURE__ */ u("div", { className: "space-y-1 px-1 py-1", children: [
122
125
  /* @__PURE__ */ n("p", { className: "font-mono text-[11px] text-slate-600 dark:text-slate-300", children: l.formula }),
123
- Object.entries(l.inputs ?? {}).map(([i, y]) => /* @__PURE__ */ d("p", { className: "text-[11.5px] text-slate-500 dark:text-muted-foreground", children: [
124
- /* @__PURE__ */ n("span", { className: "font-mono", children: i }),
126
+ Object.entries(l.inputs ?? {}).map(([a, b]) => /* @__PURE__ */ u("p", { className: "text-[11.5px] text-slate-500 dark:text-muted-foreground", children: [
127
+ /* @__PURE__ */ n("span", { className: "font-mono", children: a }),
125
128
  " = ",
126
- b(y)
127
- ] }, i)),
128
- /* @__PURE__ */ d("p", { className: "pt-1 text-[11.5px] font-medium text-slate-700 dark:text-slate-200", children: [
129
+ g(b)
130
+ ] }, a)),
131
+ /* @__PURE__ */ u("p", { className: "pt-1 text-[11.5px] font-medium text-slate-700 dark:text-slate-200", children: [
129
132
  "= ",
130
- b(l.stored_value)
133
+ g(l.stored_value)
131
134
  ] })
132
135
  ] }),
133
- (l == null ? void 0 : l.kind) === "rollup" && (l.sources ?? []).map((i, y) => {
136
+ (l == null ? void 0 : l.kind) === "rollup" && (l.sources ?? []).map((a, b) => {
134
137
  var o;
135
- return /* @__PURE__ */ d("div", { className: "mb-1.5", children: [
136
- /* @__PURE__ */ d("p", { className: "px-1 text-[10.5px] text-slate-400", children: [
137
- (i.aggregate ?? "sum").toUpperCase(),
138
- i.value_field ? ` of ${i.value_field}` : "",
138
+ return /* @__PURE__ */ u("div", { className: "mb-1.5", children: [
139
+ /* @__PURE__ */ u("p", { className: "px-1 text-[10.5px] text-slate-400", children: [
140
+ (a.aggregate ?? "sum").toUpperCase(),
141
+ a.value_field ? ` of ${a.value_field}` : "",
139
142
  " across ",
140
- i.collection,
141
- i.filtered ? " (filtered)" : ""
143
+ a.collection,
144
+ a.filtered ? " (filtered)" : ""
142
145
  ] }),
143
- i.error && /* @__PURE__ */ n("p", { className: "px-1 py-1 text-[11.5px] text-amber-600 dark:text-amber-400", children: i.error }),
144
- i.note && /* @__PURE__ */ n("p", { className: "px-1 py-1 text-[11.5px] text-slate-400", children: i.note }),
145
- i.rows.length > 0 && /* @__PURE__ */ n("div", { className: "mt-0.5 space-y-px", children: i.rows.map((x) => /* @__PURE__ */ d(
146
+ a.error && /* @__PURE__ */ n("p", { className: "px-1 py-1 text-[11.5px] text-amber-600 dark:text-amber-400", children: a.error }),
147
+ a.note && /* @__PURE__ */ n("p", { className: "px-1 py-1 text-[11.5px] text-slate-400", children: a.note }),
148
+ a.rows.length > 0 && /* @__PURE__ */ n("div", { className: "mt-0.5 space-y-px", children: a.rows.map((x) => /* @__PURE__ */ u(
146
149
  "div",
147
150
  {
148
151
  className: "flex items-baseline gap-2 rounded px-1 py-0.5 text-[11.5px] hover:bg-slate-50 dark:hover:bg-muted",
149
152
  children: [
150
153
  /* @__PURE__ */ n("span", { className: "min-w-0 flex-1 truncate text-slate-600 dark:text-slate-300", children: x.label }),
151
- /* @__PURE__ */ n("span", { className: "shrink-0 font-mono tabular-nums text-slate-800 dark:text-slate-100", children: b(x.value) }),
154
+ /* @__PURE__ */ n("span", { className: "shrink-0 font-mono tabular-nums text-slate-800 dark:text-slate-100", children: g(x.value) }),
152
155
  /* @__PURE__ */ n(
153
156
  "span",
154
157
  {
@@ -161,76 +164,76 @@ function Rn({
161
164
  },
162
165
  x.id
163
166
  )) }),
164
- i.truncated && /* @__PURE__ */ n("p", { className: "px-1 pt-0.5 text-[10.5px] text-amber-600 dark:text-amber-400", children: "Showing the first 200 rows — the subtotal covers only these." }),
165
- i.subtotal != null && /* @__PURE__ */ d("p", { className: "border-t border-slate-100 px-1 pt-1 text-right text-[11.5px] font-medium text-slate-700 dark:border-border dark:text-slate-200", children: [
167
+ a.truncated && /* @__PURE__ */ n("p", { className: "px-1 pt-0.5 text-[10.5px] text-amber-600 dark:text-amber-400", children: "Showing the first 200 rows — the subtotal covers only these." }),
168
+ a.subtotal != null && /* @__PURE__ */ u("p", { className: "border-t border-slate-100 px-1 pt-1 text-right text-[11.5px] font-medium text-slate-700 dark:border-border dark:text-slate-200", children: [
166
169
  "subtotal ",
167
- b(i.subtotal)
170
+ g(a.subtotal)
168
171
  ] }),
169
- (((o = i.excluded) == null ? void 0 : o.length) ?? 0) > 0 && /* @__PURE__ */ d("div", { className: "mt-1 rounded bg-slate-50 px-1 py-1 dark:bg-muted/40", children: [
170
- /* @__PURE__ */ d("p", { className: "text-[10.5px] text-slate-500 dark:text-muted-foreground", children: [
171
- i.excluded.length,
172
+ (((o = a.excluded) == null ? void 0 : o.length) ?? 0) > 0 && /* @__PURE__ */ u("div", { className: "mt-1 rounded bg-slate-50 px-1 py-1 dark:bg-muted/40", children: [
173
+ /* @__PURE__ */ u("p", { className: "text-[10.5px] text-slate-500 dark:text-muted-foreground", children: [
174
+ a.excluded.length,
172
175
  " excluded —",
173
176
  " ",
174
- i.excluded[0].reason.replace(/^does not match: /, "")
177
+ a.excluded[0].reason.replace(/^does not match: /, "")
175
178
  ] }),
176
- i.excluded.slice(0, 8).map((x) => /* @__PURE__ */ d(
179
+ a.excluded.slice(0, 8).map((x) => /* @__PURE__ */ u(
177
180
  "div",
178
181
  {
179
182
  className: "flex items-baseline gap-2 px-0.5 text-[11px] text-slate-400",
180
183
  children: [
181
184
  /* @__PURE__ */ n("span", { className: "min-w-0 flex-1 truncate line-through decoration-slate-300", children: x.label }),
182
- /* @__PURE__ */ n("span", { className: "shrink-0 font-mono tabular-nums", children: b(x.value) })
185
+ /* @__PURE__ */ n("span", { className: "shrink-0 font-mono tabular-nums", children: g(x.value) })
183
186
  ]
184
187
  },
185
188
  x.id
186
189
  )),
187
- i.excluded.length > 8 && /* @__PURE__ */ d("p", { className: "px-0.5 text-[10.5px] text-slate-400", children: [
190
+ a.excluded.length > 8 && /* @__PURE__ */ u("p", { className: "px-0.5 text-[10.5px] text-slate-400", children: [
188
191
  "+",
189
- i.excluded.length - 8,
192
+ a.excluded.length - 8,
190
193
  " more"
191
194
  ] })
192
195
  ] })
193
- ] }, y);
196
+ ] }, b);
194
197
  }),
195
- (l == null ? void 0 : l.kind) === "rollup" && m != null && /* @__PURE__ */ d("p", { className: "px-1 pt-0.5 text-right text-[11.5px] text-slate-500 dark:text-muted-foreground", children: [
198
+ (l == null ? void 0 : l.kind) === "rollup" && m != null && /* @__PURE__ */ u("p", { className: "px-1 pt-0.5 text-right text-[11.5px] text-slate-500 dark:text-muted-foreground", children: [
196
199
  "stored ",
197
- b(m),
200
+ g(m),
198
201
  (() => {
199
- const i = (l.sources ?? []).reduce((o, x) => o + (x.subtotal ?? 0), 0);
200
- return (l.sources ?? []).some((o) => o.truncated) ? null : Math.abs(i - m) < 0.01 ? /* @__PURE__ */ n("span", { className: "ml-1 text-emerald-600 dark:text-emerald-400", children: "✓ matches" }) : /* @__PURE__ */ n("span", { className: "ml-1 text-amber-600 dark:text-amber-400", children: "✕ differs from contributions" });
202
+ const a = (l.sources ?? []).reduce((o, x) => o + (x.subtotal ?? 0), 0);
203
+ return (l.sources ?? []).some((o) => o.truncated) ? null : Math.abs(a - m) < 0.01 ? /* @__PURE__ */ n("span", { className: "ml-1 text-emerald-600 dark:text-emerald-400", children: "✓ matches" }) : /* @__PURE__ */ n("span", { className: "ml-1 text-amber-600 dark:text-amber-400", children: "✕ differs from contributions" });
201
204
  })()
202
205
  ] })
203
206
  ] })
204
207
  ] });
205
208
  }
206
- function Sn({
209
+ function $n({
207
210
  collection: c,
208
211
  itemId: e,
209
- field: u,
212
+ field: i,
210
213
  formatValue: p,
211
214
  onRestore: f
212
215
  }) {
213
- const a = ie(), [l, _] = ve(!1), b = S(null), { data: m, isLoading: i } = re({
214
- queryKey: ["field-value-history", c, e, u],
215
- queryFn: () => a.request(K(`/field-history/${c}/${encodeURIComponent(e)}/${u}`)).then((o) => o.data ?? []),
216
+ const s = ie(), [l, w] = ve(!1), g = $(null), { data: m, isLoading: a } = le({
217
+ queryKey: ["field-value-history", c, e, i],
218
+ queryFn: () => s.request(K(`/field-history/${c}/${encodeURIComponent(e)}/${i}`)).then((o) => o.data ?? []),
216
219
  enabled: l,
217
220
  staleTime: 6e4
218
221
  });
219
- le(() => {
222
+ oe(() => {
220
223
  if (!l) return;
221
224
  const o = (x) => {
222
225
  var U;
223
- (U = b.current) != null && U.contains(x.target) || _(!1);
226
+ (U = g.current) != null && U.contains(x.target) || w(!1);
224
227
  };
225
228
  return window.addEventListener("mousedown", o), () => window.removeEventListener("mousedown", o);
226
229
  }, [l]);
227
- const y = (o, x) => x || (o == null || o === "" ? "—" : p ? p(o) : typeof o == "boolean" || o === "true" || o === "false" ? o === !0 || o === "true" ? "Yes" : "No" : typeof o == "string" && /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}/.test(o) ? new Date(o).toLocaleString() : typeof o == "object" ? JSON.stringify(o).slice(0, 60) : String(o).slice(0, 80));
228
- return /* @__PURE__ */ d("div", { ref: b, className: "relative inline-flex", children: [
230
+ const b = (o, x) => x || (o == null || o === "" ? "—" : p ? p(o) : typeof o == "boolean" || o === "true" || o === "false" ? o === !0 || o === "true" ? "Yes" : "No" : typeof o == "string" && /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}/.test(o) ? new Date(o).toLocaleString() : typeof o == "object" ? JSON.stringify(o).slice(0, 60) : String(o).slice(0, 80));
231
+ return /* @__PURE__ */ u("div", { ref: g, className: "relative inline-flex", children: [
229
232
  /* @__PURE__ */ n(
230
233
  "button",
231
234
  {
232
235
  type: "button",
233
- onClick: () => _((o) => !o),
236
+ onClick: () => w((o) => !o),
234
237
  title: "Value history",
235
238
  className: j(
236
239
  "inline-flex items-center rounded p-0.5 transition-opacity",
@@ -240,28 +243,28 @@ function Sn({
240
243
  children: /* @__PURE__ */ n(Ft, { className: "h-3 w-3" })
241
244
  }
242
245
  ),
243
- l && /* @__PURE__ */ d("div", { className: "absolute left-0 top-full z-40 mt-1 max-h-64 w-[300px] overflow-y-auto rounded-lg border border-slate-200 bg-white p-2 shadow-lg dark:border-border dark:bg-card", children: [
246
+ l && /* @__PURE__ */ u("div", { className: "absolute left-0 top-full z-40 mt-1 max-h-64 w-[300px] overflow-y-auto rounded-lg border border-slate-200 bg-white p-2 shadow-lg dark:border-border dark:bg-card", children: [
244
247
  /* @__PURE__ */ n("p", { className: "mb-1 px-1 text-[10px] font-semibold uppercase tracking-wide text-slate-400", children: "Value history" }),
245
- i ? /* @__PURE__ */ n("p", { className: "px-1 py-2 text-[11.5px] text-slate-400", children: "Loading…" }) : (m ?? []).length === 0 ? /* @__PURE__ */ n("p", { className: "px-1 py-2 text-[11.5px] text-slate-400", children: "No recorded changes for this field." }) : /* @__PURE__ */ n("div", { className: "space-y-1", children: (m ?? []).map((o, x) => /* @__PURE__ */ d(
248
+ a ? /* @__PURE__ */ n("p", { className: "px-1 py-2 text-[11.5px] text-slate-400", children: "Loading…" }) : (m ?? []).length === 0 ? /* @__PURE__ */ n("p", { className: "px-1 py-2 text-[11.5px] text-slate-400", children: "No recorded changes for this field." }) : /* @__PURE__ */ n("div", { className: "space-y-1", children: (m ?? []).map((o, x) => /* @__PURE__ */ u(
246
249
  "div",
247
250
  {
248
251
  className: "rounded px-1 py-1 text-[11.5px] leading-snug hover:bg-slate-50 dark:hover:bg-muted",
249
252
  children: [
250
- /* @__PURE__ */ d("span", { className: "flex items-baseline justify-between gap-2", children: [
251
- /* @__PURE__ */ n("span", { className: "font-medium text-slate-700 dark:text-slate-200", children: y(o.value, o.display) }),
253
+ /* @__PURE__ */ u("span", { className: "flex items-baseline justify-between gap-2", children: [
254
+ /* @__PURE__ */ n("span", { className: "font-medium text-slate-700 dark:text-slate-200", children: b(o.value, o.display) }),
252
255
  f && x > 0 && /* @__PURE__ */ n(
253
256
  "button",
254
257
  {
255
258
  type: "button",
256
259
  onClick: () => {
257
- f(o.value ?? null), _(!1);
260
+ f(o.value ?? null), w(!1);
258
261
  },
259
262
  className: "shrink-0 rounded border border-slate-200 px-1.5 py-px text-[10px] text-slate-500 hover:border-nvr-cyan/60 hover:text-nvr-navy dark:border-border dark:hover:text-nvr-cyan",
260
263
  children: "Restore"
261
264
  }
262
265
  )
263
266
  ] }),
264
- /* @__PURE__ */ d("span", { className: "block text-[10.5px] text-slate-400", children: [
267
+ /* @__PURE__ */ u("span", { className: "block text-[10.5px] text-slate-400", children: [
265
268
  o.action === "create" ? "initial value" : "changed",
266
269
  o.timestamp ? ` · ${new Date(o.timestamp).toLocaleString()}` : "",
267
270
  o.user_name ? ` · ${o.user_name}` : "",
@@ -273,7 +276,7 @@ function Sn({
273
276
  }
274
277
  )
275
278
  ] }),
276
- o.note && /* @__PURE__ */ d("span", { className: "block text-[10.5px] italic text-slate-500 dark:text-slate-400", children: [
279
+ o.note && /* @__PURE__ */ u("span", { className: "block text-[10.5px] italic text-slate-500 dark:text-slate-400", children: [
277
280
  "“",
278
281
  o.note,
279
282
  "”"
@@ -285,79 +288,79 @@ function Sn({
285
288
  ] })
286
289
  ] });
287
290
  }
288
- function $n({
291
+ function qn({
289
292
  collection: c,
290
293
  itemId: e,
291
- field: u
294
+ field: i
292
295
  }) {
293
- const p = ie(), f = Ge(), { data: a } = re({
296
+ const p = ie(), f = Ge(), { data: s } = le({
294
297
  queryKey: ["field-watch-config"],
295
- queryFn: () => p.request(K("/field-watches/config")).then((i) => i.data).catch(() => ({ enabled: !1 })),
298
+ queryFn: () => p.request(K("/field-watches/config")).then((a) => a.data).catch(() => ({ enabled: !1 })),
296
299
  staleTime: 5 * 6e4
297
- }), l = ["field-watch-self", c, e], { data: _ = [] } = re({
300
+ }), l = ["field-watch-self", c, e], { data: w = [] } = le({
298
301
  queryKey: l,
299
- queryFn: () => p.request(K("/field-watches/self", { collection: c, item_id: e })).then((i) => i.data ?? []).catch(() => []),
300
- enabled: !!(a != null && a.enabled),
302
+ queryFn: () => p.request(K("/field-watches/self", { collection: c, item_id: e })).then((a) => a.data ?? []).catch(() => []),
303
+ enabled: !!(s != null && s.enabled),
301
304
  staleTime: 6e4
302
- }), b = _.includes(u), m = gt({
303
- mutationFn: () => b ? p.request(
305
+ }), g = w.includes(i), m = gt({
306
+ mutationFn: () => g ? p.request(
304
307
  Pt(
305
- `/field-watches/self?collection=${encodeURIComponent(c)}&field=${encodeURIComponent(u)}&item_id=${encodeURIComponent(e)}`
308
+ `/field-watches/self?collection=${encodeURIComponent(c)}&field=${encodeURIComponent(i)}&item_id=${encodeURIComponent(e)}`
306
309
  )
307
- ) : p.request(ge("/field-watches/self", { collection: c, field: u, item_id: e })),
310
+ ) : p.request(ge("/field-watches/self", { collection: c, field: i, item_id: e })),
308
311
  onSuccess: () => {
309
- f.invalidateQueries({ queryKey: l }), oe.success(
310
- b ? "No longer watching this field" : "Watching — you will be notified when it changes"
312
+ f.invalidateQueries({ queryKey: l }), ae.success(
313
+ g ? "No longer watching this field" : "Watching — you will be notified when it changes"
311
314
  );
312
315
  },
313
- onError: () => oe.error("Could not update the watch")
316
+ onError: () => ae.error("Could not update the watch")
314
317
  });
315
- return a != null && a.enabled ? /* @__PURE__ */ n(
318
+ return s != null && s.enabled ? /* @__PURE__ */ n(
316
319
  "button",
317
320
  {
318
321
  type: "button",
319
322
  onClick: () => m.mutate(),
320
- title: b ? "Stop watching this field on this record" : "Watch this field on this record",
321
- "data-field-watch": u,
322
- className: `rounded p-0.5 transition-colors ${b ? "text-nvr-navy dark:text-nvr-cyan" : "text-slate-300 hover:text-slate-500"}`,
323
- children: b ? /* @__PURE__ */ n(Ct, { className: "h-3 w-3" }) : /* @__PURE__ */ n(Lt, { className: "h-3 w-3" })
323
+ title: g ? "Stop watching this field on this record" : "Watch this field on this record",
324
+ "data-field-watch": i,
325
+ className: `rounded p-0.5 transition-colors ${g ? "text-nvr-navy dark:text-nvr-cyan" : "text-slate-300 hover:text-slate-500"}`,
326
+ children: g ? /* @__PURE__ */ n(Ct, { className: "h-3 w-3" }) : /* @__PURE__ */ n(Lt, { className: "h-3 w-3" })
324
327
  }
325
328
  ) : null;
326
329
  }
327
- function qn(c) {
330
+ function An(c) {
328
331
  return c ? c.querySelector(
329
332
  'input:not([type=hidden]), textarea, [role="combobox"], [contenteditable="true"]'
330
333
  ) ?? c.querySelector("button") : null;
331
334
  }
332
- const dr = St(function({
335
+ const ur = St(function({
333
336
  field: e,
334
- draft: u,
337
+ draft: i,
335
338
  onChange: p,
336
339
  relations: f,
337
- collection: a,
340
+ collection: s,
338
341
  itemId: l,
339
- error: _,
340
- visible: b,
342
+ error: w,
343
+ visible: g,
341
344
  locked: m,
342
- layoutAiEnabled: i,
343
- renderField: y,
345
+ layoutAiEnabled: a,
346
+ renderField: b,
344
347
  onCountChange: o,
345
348
  swapButton: x,
346
349
  swapContent: U,
347
350
  forceVisible: Qe,
348
- autoFillTick: ae
351
+ autoFillTick: se
349
352
  }) {
350
- var Oe, De, Me, Ke;
351
- const H = Fn.has(e.interface ?? ""), N = qt(), g = rn(), we = Ge(), se = ie(), [ke, W] = ve(!1), s = Ut(), _e = Bt(e.field), V = S(null), z = $t(), ce = S(null), Ne = S(!1);
352
- le(() => {
353
- const t = Ne.current ? qn(ce.current) : null;
353
+ var De, Me, Oe, Ke;
354
+ const H = Fn.has(e.interface ?? ""), N = qt(), y = rn(), we = Ge(), ce = ie(), [ke, W] = ve(!1), d = Ut(), _e = Bt(e.field), V = $(null), z = $t(), de = $(null), Ne = $(!1);
355
+ oe(() => {
356
+ const t = Ne.current ? An(de.current) : null;
354
357
  if (!t || t.hasAttribute("aria-label")) return;
355
358
  t.id || (t.id = `${z}-control`);
356
359
  const r = t.tagName === "BUTTON" ? `${z} ${t.id}` : z;
357
360
  t.getAttribute("aria-labelledby") !== r && t.setAttribute("aria-labelledby", r);
358
361
  });
359
- const Fe = m && !H, Ce = S(null);
360
- le(() => {
362
+ const Fe = m && !H, Ce = $(null);
363
+ oe(() => {
361
364
  const t = Ce.current;
362
365
  if (!t) return;
363
366
  if (!Fe) {
@@ -366,7 +369,7 @@ const dr = St(function({
366
369
  }
367
370
  const r = typeof document < "u" ? document.activeElement : null;
368
371
  r instanceof HTMLElement && t.contains(r) && r.blur(), t.setAttribute("inert", "");
369
- }, [Fe, ae]);
372
+ }, [Fe, se]);
370
373
  const G = e.field, Le = He(
371
374
  (t) => {
372
375
  m || p(G, t);
@@ -375,33 +378,33 @@ const dr = St(function({
375
378
  ), Ye = He(
376
379
  (t) => o == null ? void 0 : o(G, t),
377
380
  [o, G]
378
- ), Je = S(void 0), Re = S(void 0), Se = S(void 0), $e = !m && !e.readonly && !e.computed_formula && !(e.hidden && !e.layout_assigned) && !ze(e), {
381
+ ), Je = $(void 0), Re = $(void 0), Se = $(void 0), $e = !m && !e.readonly && !e.computed_formula && !(e.hidden && !e.layout_assigned) && !ze(e), {
379
382
  onContextMenu: Xe,
380
383
  onKeyDown: Ze,
381
384
  menu: Ie,
382
385
  confirmSaveFrom: et,
383
- openedBy: de
386
+ openedBy: ue
384
387
  } = Ht({
385
388
  wrapperRef: V,
386
389
  field: e,
387
- value: u[e.field],
390
+ value: i[e.field],
388
391
  relations: f,
389
- collection: a,
392
+ collection: s,
390
393
  itemId: l,
391
- openRelated: s == null ? void 0 : s.openRelated,
394
+ openRelated: d == null ? void 0 : d.openRelated,
392
395
  editable: $e
393
- }), T = Wt(V), tt = sn(), qe = s == null ? void 0 : s.remoteChanges[e.field], B = s == null ? void 0 : s.lockReasons[e.field], A = s == null ? void 0 : s.applyToLines[e.field], C = gn(), nt = (C == null ? void 0 : C.applied(e.field)) ?? !1, Ae = (C == null ? void 0 : C.hintFor(e.field)) ?? null, ue = ln(C, e.field, $e), me = () => {
396
+ }), E = Wt(V), tt = sn(), qe = d == null ? void 0 : d.remoteChanges[e.field], B = d == null ? void 0 : d.lockReasons[e.field], T = d == null ? void 0 : d.applyToLines[e.field], C = gn(), nt = (C == null ? void 0 : C.applied(e.field)) ?? !1, Ae = (C == null ? void 0 : C.hintFor(e.field)) ?? null, me = ln(C, e.field, $e), pe = () => {
394
397
  var t, r;
395
- return ((t = ce.current) == null ? void 0 : t.querySelector(Ve)) ?? ((r = V.current) == null ? void 0 : r.querySelector(Ve));
396
- }, Q = At(e._overrides, i, Cn(e)), pe = !!(s != null && s.fromAutofill) && !!e._overrides && e._overrides[Tt] === !0;
398
+ return ((t = de.current) == null ? void 0 : t.querySelector(Ve)) ?? ((r = V.current) == null ? void 0 : r.querySelector(Ve));
399
+ }, Q = At(e._overrides, a, Cn(e)), he = !!(d != null && d.fromAutofill) && !!e._overrides && e._overrides[Tt] === !0;
397
400
  async function rt() {
398
401
  var t;
399
402
  if (Q.perField) return lt();
400
403
  W(!0);
401
404
  try {
402
- const r = await se.request(
405
+ const r = await ce.request(
403
406
  ge("/ai/generate", {
404
- collection: a,
407
+ collection: s,
405
408
  item_id: l !== "new" ? l : void 0,
406
409
  field: e.field
407
410
  })
@@ -413,41 +416,41 @@ const dr = St(function({
413
416
  }
414
417
  }
415
418
  async function lt() {
416
- var r, h, w, P;
419
+ var r, h, k, R;
417
420
  const t = {};
418
- for (const k of ((r = Et(e._overrides)) == null ? void 0 : r.tokens) ?? []) k in u && (t[k] = u[k]);
421
+ for (const _ of ((r = Et(e._overrides)) == null ? void 0 : r.tokens) ?? []) _ in i && (t[_] = i[_]);
419
422
  W(!0);
420
423
  try {
421
- const k = await se.request(
424
+ const _ = await ce.request(
422
425
  ge("/ai/field-fill", {
423
- collection: a,
424
- layout_id: (s == null ? void 0 : s.layoutId) ?? null,
426
+ collection: s,
427
+ layout_id: (d == null ? void 0 : d.layoutId) ?? null,
425
428
  field: e.field,
426
429
  item_id: l && l !== "new" ? l : null,
427
430
  values: t
428
431
  })
429
- ), F = (h = k.data) == null ? void 0 : h.value;
430
- typeof F == "string" && F !== "" ? p(e.field, F) : oe.info("The AI had nothing to write here"), (P = (w = k.data) == null ? void 0 : w.missing) != null && P.length && oe.info(`Filled without ${k.data.missing.join(", ")} (empty or not visible to you)`);
431
- } catch (k) {
432
- jt(k, "AI fill failed", { action: "Fill with AI" });
432
+ ), F = (h = _.data) == null ? void 0 : h.value;
433
+ typeof F == "string" && F !== "" ? p(e.field, F) : ae.info("The AI had nothing to write here"), (R = (k = _.data) == null ? void 0 : k.missing) != null && R.length && ae.info(`Filled without ${_.data.missing.join(", ")} (empty or not visible to you)`);
434
+ } catch (_) {
435
+ jt(_, "AI fill failed", { action: "Fill with AI" });
433
436
  } finally {
434
437
  W(!1);
435
438
  }
436
439
  }
437
- const E = Xt(e.dependency_config), Te = E.flatMap((t) => {
440
+ const P = Xt(e.dependency_config), Te = P.flatMap((t) => {
438
441
  const r = f.find(
439
- (w) => w.one_collection === a && w.one_field === t.parent_field
442
+ (k) => k.one_collection === s && k.one_field === t.parent_field
440
443
  );
441
444
  if (!r) return [];
442
445
  if (r.junction_field) return [{ rule: t, rel: r }];
443
446
  const h = f.find(
444
- (w) => w.many_collection === r.many_collection && w.id !== r.id
447
+ (k) => k.many_collection === r.many_collection && k.id !== r.id
445
448
  );
446
449
  return h != null && h.many_field ? [{ rule: t, rel: { ...r, junction_field: h.many_field } }] : [];
447
450
  }), ot = bt({
448
451
  queries: Te.map(({ rel: t }) => ({
449
452
  queryKey: ["m2m-items", t.many_collection, t.many_field, l],
450
- queryFn: () => se.request(
453
+ queryFn: () => ce.request(
451
454
  K(`/items/${t.many_collection}`, {
452
455
  filter: JSON.stringify({ [t.many_field]: { _eq: l } }),
453
456
  limit: 200,
@@ -457,23 +460,23 @@ const dr = St(function({
457
460
  enabled: !!l && l !== "new",
458
461
  staleTime: 3e4
459
462
  }))
460
- }), it = Object.fromEntries(
463
+ }), at = Object.fromEntries(
461
464
  Te.map(({ rule: t, rel: r }, h) => {
462
- var k;
463
- const w = r.one_field ?? `${r.many_collection}.${r.junction_field}`, P = (g == null ? void 0 : g.getStagedUnlinks(w)) ?? /* @__PURE__ */ new Set();
465
+ var _;
466
+ const k = r.one_field ?? `${r.many_collection}.${r.junction_field}`, R = (y == null ? void 0 : y.getStagedUnlinks(k)) ?? /* @__PURE__ */ new Set();
464
467
  return [
465
468
  t.parent_field,
466
- (((k = ot[h]) == null ? void 0 : k.data) ?? []).filter((F) => !P.has(F.id)).map((F) => F[r.junction_field])
469
+ (((_ = ot[h]) == null ? void 0 : _.data) ?? []).filter((F) => !R.has(F.id)).map((F) => F[r.junction_field])
467
470
  ];
468
471
  })
469
- ), Y = Mt()[e.field] ?? [];
470
- if (!Qe && (!b || !e.layout_assigned && (e.hidden || Zt.has(e.field))))
472
+ ), Y = Ot()[e.field] ?? [];
473
+ if (!Qe && (!g || !e.layout_assigned && (e.hidden || Zt.has(e.field))))
471
474
  return null;
472
- const he = u[e.field] ?? null, J = cn(e, tt), L = J.label ?? Z(e.field);
475
+ const xe = i[e.field] ?? null, J = cn(e, tt), L = J.label ?? I(e.field);
473
476
  Ne.current = L !== "";
474
- const $ = ze(e), Ee = $ ? null : dn(e), Pe = $ || !(l === "new" || !l || (Oe = N == null ? void 0 : N.dirtyFields) != null && Oe.has(e.field)) ? null : bn(e, u), at = !$ && !m && !e.readonly && ((De = e._overrides) == null ? void 0 : De.repeat_last) === !0, st = nn(e, u), ct = (Ke = (Me = It(e.options)) == null ? void 0 : Me.auto_id) == null ? void 0 : Ke.pattern, v = (() => {
477
+ const q = ze(e), Ee = q ? null : dn(e), Pe = q || !(l === "new" || !l || (De = N == null ? void 0 : N.dirtyFields) != null && De.has(e.field)) ? null : bn(e, i), it = !q && !m && !e.readonly && ((Me = e._overrides) == null ? void 0 : Me.repeat_last) === !0, st = nn(e, i), ct = (Ke = (Oe = It(e.options)) == null ? void 0 : Oe.auto_id) == null ? void 0 : Ke.pattern, v = (() => {
475
478
  const t = f.find(
476
- (h) => h.one_collection === a && h.one_field === e.field
479
+ (h) => h.one_collection === s && h.one_field === e.field
477
480
  );
478
481
  if (!t) return null;
479
482
  if (t.junction_field) return t;
@@ -481,47 +484,47 @@ const dr = St(function({
481
484
  (h) => h.many_collection === t.many_collection && h.id !== t.id
482
485
  );
483
486
  return r ? { ...t, junction_field: r.many_field } : null;
484
- })(), xe = v ? null : f.find((t) => t.many_collection === a && t.many_field === e.field) ?? null, fe = v ? f.find(
487
+ })(), fe = v ? null : f.find((t) => t.many_collection === s && t.many_field === e.field) ?? null, ye = v ? f.find(
485
488
  (t) => t.many_collection === v.many_collection && t.many_field === v.junction_field && t.id !== v.id
486
- ) ?? null : null, O = v ? v.one_field ?? `${v.many_collection}.${v.junction_field}` : null, je = O ? (g == null ? void 0 : g.getStagedLinks(O)) ?? [] : [], dt = v ? (we.getQueryData([
489
+ ) ?? null : null, D = v ? v.one_field ?? `${v.many_collection}.${v.junction_field}` : null, je = D ? (y == null ? void 0 : y.getStagedLinks(D)) ?? [] : [], dt = v ? (we.getQueryData([
487
490
  "m2m-items",
488
491
  v.many_collection,
489
492
  v.many_field,
490
493
  l
491
- ]) ?? []).map((t) => t[v.junction_field]) : [], ut = v ? je[0] ?? dt[0] ?? null : he, mt = (fe == null ? void 0 : fe.one_collection) ?? (xe == null ? void 0 : xe.one_collection) ?? void 0, X = (t) => {
494
+ ]) ?? []).map((t) => t[v.junction_field]) : [], ut = v ? je[0] ?? dt[0] ?? null : xe, mt = (ye == null ? void 0 : ye.one_collection) ?? (fe == null ? void 0 : fe.one_collection) ?? void 0, X = (t) => {
492
495
  var r;
493
- return ((N == null ? void 0 : N.collection) === a ? (r = N == null ? void 0 : N.fieldLabels) == null ? void 0 : r[t] : void 0) ?? Z(String(t));
494
- }, q = en({
495
- rules: E,
496
+ return ((N == null ? void 0 : N.collection) === s ? (r = N == null ? void 0 : N.fieldLabels) == null ? void 0 : r[t] : void 0) ?? I(String(t));
497
+ }, A = en({
498
+ rules: P,
496
499
  // A parent whose value THIS field's own pick derived must not narrow this
497
500
  // field's options — otherwise picking a region locks the region picker
498
501
  // into the zone the pick itself filled, and cross-zone changes read as
499
502
  // "No results".
500
503
  skipParent: (t) => {
501
504
  var r;
502
- return ((r = g == null ? void 0 : g.getDerivedOrigin) == null ? void 0 : r.call(g, t)) === e.field;
505
+ return ((r = y == null ? void 0 : y.getDerivedOrigin) == null ? void 0 : r.call(y, t)) === e.field;
503
506
  },
504
507
  parentValue: (t) => {
505
- if (u[t] != null) return u[t];
506
- const r = f.find((R) => R.one_collection === a && R.one_field === t);
508
+ if (i[t] != null) return i[t];
509
+ const r = f.find((S) => S.one_collection === s && S.one_field === t);
507
510
  if (!r) return null;
508
511
  let h = r;
509
512
  if (!h.junction_field) {
510
- const R = f.find(
513
+ const S = f.find(
511
514
  (Ue) => Ue.many_collection === r.many_collection && Ue.id !== r.id
512
515
  );
513
- if (R != null && R.many_field) h = { ...r, junction_field: R.many_field };
516
+ if (S != null && S.many_field) h = { ...r, junction_field: S.many_field };
514
517
  else return null;
515
518
  }
516
- const w = h.one_field ?? `${h.many_collection}.${h.junction_field}`, P = (g == null ? void 0 : g.getStagedLinks(w)) ?? [], k = it[t] ?? [], F = [...new Set([...P, ...k].map((R) => String(R)))];
519
+ const k = h.one_field ?? `${h.many_collection}.${h.junction_field}`, R = (y == null ? void 0 : y.getStagedLinks(k)) ?? [], _ = at[t] ?? [], F = [...new Set([...R, ..._].map((S) => String(S)))];
517
520
  return F.length === 0 ? null : F.length === 1 ? F[0] : F;
518
521
  },
519
522
  parentOptionFilter: (t) => {
520
523
  var h;
521
- const r = (N == null ? void 0 : N.collection) === a ? (h = N.fieldOptionFilters) == null ? void 0 : h[t] : void 0;
522
- return r ? vn(r, u, l) : void 0;
524
+ const r = (N == null ? void 0 : N.collection) === s ? (h = N.fieldOptionFilters) == null ? void 0 : h[t] : void 0;
525
+ return r ? vn(r, i, l) : void 0;
523
526
  }
524
- }), D = q.filter ? fn(Je, q.filter, yn) : q.filter, M = q.satisfiedParents.map(X), ye = q.satisfiedParents, pt = q.unsatisfiedParents.length ? X(q.unsatisfiedParents[0]) : null, be = q.missingRequiredParents, Be = be.length ? X(be[0]) : null;
527
+ }), M = A.filter ? fn(Je, A.filter, yn) : A.filter, O = A.satisfiedParents.map(X), Z = A.satisfiedParents, pt = A.unsatisfiedParents.length ? X(A.unsatisfiedParents[0]) : null, be = A.missingRequiredParents, Be = be.length ? X(be[0]) : null;
525
528
  function ht() {
526
529
  const t = Se.current;
527
530
  if (t && t.src === e) return t.value;
@@ -529,17 +532,24 @@ const dr = St(function({
529
532
  return Se.current = { src: e, value: r }, r;
530
533
  }
531
534
  function xt() {
532
- const t = JSON.stringify([M, ye]), r = Re.current;
533
- if (r && r.sig === t && r.onChange === p) return r.value;
534
- const h = {
535
- labels: M,
536
- keys: ye,
537
- onClear: (w) => p(w, null)
535
+ const t = Ln(
536
+ Z,
537
+ e.field,
538
+ y == null ? void 0 : y.getDerivedOrigin
539
+ ), r = JSON.stringify([O, Z, t]), h = Re.current;
540
+ if (h && h.sig === r && h.onChange === p) return h.value;
541
+ const k = {
542
+ labels: O,
543
+ keys: Z,
544
+ clearable: t,
545
+ onClear: t.length > 0 ? (R) => {
546
+ t.includes(R) && p(R, null);
547
+ } : void 0
538
548
  };
539
- return Re.current = { sig: t, onChange: p, value: h }, h;
549
+ return Re.current = { sig: r, onChange: p, value: k }, k;
540
550
  }
541
551
  function ft() {
542
- for (const t of ye) {
552
+ for (const t of Z) {
543
553
  const r = document.querySelector(`[data-field="${t}"]`);
544
554
  r && (r.scrollIntoView({ behavior: "smooth", block: "center" }), r.style.transition = "box-shadow 0.15s ease", r.style.boxShadow = "0 0 0 2px rgb(var(--nvr-cyan-rgb, 0 206 255)), 0 0 0 5px rgb(var(--nvr-cyan-rgb, 0 206 255) / 0.25)", r.style.borderRadius = "12px", setTimeout(() => {
545
555
  r.style.boxShadow = "none", setTimeout(() => {
@@ -549,87 +559,87 @@ const dr = St(function({
549
559
  }
550
560
  }
551
561
  const yt = () => {
552
- if (v && O) {
553
- for (const r of je) g == null || g.unstageLink(O, r);
562
+ if (v && D) {
563
+ for (const r of je) y == null || y.unstageLink(D, r);
554
564
  const t = we.getQueryData([
555
565
  "m2m-items",
556
566
  v.many_collection,
557
567
  v.many_field,
558
568
  l
559
569
  ]) ?? [];
560
- for (const r of t) g == null || g.stageUnlink(O, r.id);
570
+ for (const r of t) y == null || y.stageUnlink(D, r.id);
561
571
  } else
562
572
  p(e.field, null);
563
573
  };
564
574
  return (
565
575
  // biome-ignore lint/a11y/noStaticElementInteractions: the wrapper only hosts the field context menu (right-click / Shift+F10); the inputs inside stay the controls
566
- /* @__PURE__ */ d(
576
+ /* @__PURE__ */ u(
567
577
  "div",
568
578
  {
569
579
  ref: V,
570
580
  "data-field": e.field,
571
- "data-field-collection": a,
581
+ "data-field-collection": s,
572
582
  "data-field-interface": e.interface ?? void 0,
573
- "data-autofill-check": pe ? "" : void 0,
583
+ "data-autofill-check": he ? "" : void 0,
574
584
  className: j(
575
585
  "group/fieldrow space-y-1.5",
576
- pe && "rounded-md bg-amber-50/60 p-1.5 ring-1 ring-amber-300 dark:bg-amber-500/10 dark:ring-amber-500/40"
586
+ he && "rounded-md bg-amber-50/60 p-1.5 ring-1 ring-amber-300 dark:bg-amber-500/10 dark:ring-amber-500/40"
577
587
  ),
578
588
  onContextMenu: Xe,
579
589
  onKeyDown: Ze,
580
- onFocusCapture: T.onFocusCapture,
590
+ onFocusCapture: E.onFocusCapture,
581
591
  children: [
582
592
  Ie,
583
- E.length > 0 && /* @__PURE__ */ n(
593
+ P.length > 0 && /* @__PURE__ */ n(
584
594
  tn,
585
595
  {
586
- cascadeRules: E,
587
- cascadeFilter: D,
596
+ cascadeRules: P,
597
+ cascadeFilter: M,
588
598
  currentValue: ut,
589
599
  relatedCollection: mt,
590
600
  missingRequiredParents: be,
591
601
  onClear: yt
592
602
  }
593
603
  ),
594
- (L !== "" || Y.length > 0) && /* @__PURE__ */ d(
604
+ (L !== "" || Y.length > 0) && /* @__PURE__ */ u(
595
605
  "div",
596
606
  {
597
607
  className: "flex flex-wrap items-center gap-1.5 min-h-[1.5rem]",
598
- "data-pd-row": ue ? "" : void 0,
608
+ "data-pd-row": me ? "" : void 0,
599
609
  children: [
600
- L !== "" && /* @__PURE__ */ d(Dt, { id: z, "data-field-label": !0, className: "text-sm font-medium", children: [
601
- /* @__PURE__ */ n(We, { text: L, collection: a }),
610
+ L !== "" && /* @__PURE__ */ u(Mt, { id: z, "data-field-label": !0, className: "text-sm font-medium", children: [
611
+ /* @__PURE__ */ n(We, { text: L, collection: s }),
602
612
  e.required && /* @__PURE__ */ n("span", { className: "ml-0.5 text-destructive", children: "*" }),
603
613
  un(e) && /* @__PURE__ */ n(mn, {})
604
614
  ] }),
605
- J.note && /* @__PURE__ */ n(I, { delayDuration: 100, children: /* @__PURE__ */ d(ee, { children: [
606
- /* @__PURE__ */ n(te, { asChild: !0, children: /* @__PURE__ */ n(vt, { className: "h-3.5 w-3.5 shrink-0 cursor-help text-slate-400 hover:text-slate-600" }) }),
607
- /* @__PURE__ */ n(ne, { side: "top", className: "max-w-[240px] text-[12px]", children: (s == null ? void 0 : s.glossaryHelp) === !1 ? J.note : /* @__PURE__ */ n(We, { text: J.note, collection: a }) })
615
+ J.note && /* @__PURE__ */ n(ee, { delayDuration: 100, children: /* @__PURE__ */ u(te, { children: [
616
+ /* @__PURE__ */ n(ne, { asChild: !0, children: /* @__PURE__ */ n(vt, { className: "h-3.5 w-3.5 shrink-0 cursor-help text-slate-400 hover:text-slate-600" }) }),
617
+ /* @__PURE__ */ n(re, { side: "top", className: "max-w-[240px] text-[12px]", children: (d == null ? void 0 : d.glossaryHelp) === !1 ? J.note : /* @__PURE__ */ n(We, { text: J.note, collection: s }) })
608
618
  ] }) }),
609
- _e && /* @__PURE__ */ n(Ot, { source: _e, label: L }),
610
- !$ && l && l !== "new" && /* @__PURE__ */ n(
611
- Sn,
619
+ _e && /* @__PURE__ */ n(Dt, { source: _e, label: L }),
620
+ !q && l && l !== "new" && /* @__PURE__ */ n(
621
+ $n,
612
622
  {
613
- collection: a,
623
+ collection: s,
614
624
  itemId: l,
615
625
  field: e.field,
616
626
  onRestore: e.readonly ? void 0 : (t) => p(e.field, t)
617
627
  }
618
628
  ),
619
- !$ && l && l !== "new" && /* @__PURE__ */ n($n, { collection: a, itemId: l, field: e.field }),
620
- !$ && l && l !== "new" && /* @__PURE__ */ n(Qt, { field: e.field, label: L || Z(e.field) }),
621
- l && l !== "new" && st && /* @__PURE__ */ n(Rn, { collection: a, itemId: l, field: e.field }),
622
- at && /* @__PURE__ */ n(
629
+ !q && l && l !== "new" && /* @__PURE__ */ n(qn, { collection: s, itemId: l, field: e.field }),
630
+ !q && l && l !== "new" && /* @__PURE__ */ n(Qt, { field: e.field, label: L || I(e.field) }),
631
+ l && l !== "new" && st && /* @__PURE__ */ n(Sn, { collection: s, itemId: l, field: e.field }),
632
+ it && /* @__PURE__ */ n(
623
633
  pn,
624
634
  {
625
- collection: a,
635
+ collection: s,
626
636
  itemId: l,
627
637
  field: e.field,
628
- label: L || Z(e.field),
638
+ label: L || I(e.field),
629
639
  onFill: (t) => p(e.field, t)
630
640
  }
631
641
  ),
632
- !$ && Q.show && !(Q.perField && (m || e.readonly)) && /* @__PURE__ */ d(
642
+ !q && Q.show && !(Q.perField && (m || e.readonly)) && /* @__PURE__ */ u(
633
643
  "button",
634
644
  {
635
645
  type: "button",
@@ -644,7 +654,7 @@ const dr = St(function({
644
654
  ]
645
655
  }
646
656
  ),
647
- pe && /* @__PURE__ */ n(
657
+ he && /* @__PURE__ */ n(
648
658
  "span",
649
659
  {
650
660
  "data-tip": "People often change what the AI read from the document here — check it",
@@ -653,36 +663,36 @@ const dr = St(function({
653
663
  }
654
664
  ),
655
665
  x,
656
- A && !m && !e.readonly && /* @__PURE__ */ d(
666
+ T && !m && !e.readonly && /* @__PURE__ */ u(
657
667
  "button",
658
668
  {
659
669
  type: "button",
660
- onClick: () => A.onApply(u[e.field] ?? null),
661
- disabled: u[e.field] == null || u[e.field] === "" || A.count === 0,
670
+ onClick: () => T.onApply(i[e.field] ?? null),
671
+ disabled: i[e.field] == null || i[e.field] === "" || T.count === 0,
662
672
  "data-apply-to-lines": e.field,
663
- "data-tip": A.count === 0 ? "No lines yet — add lines first" : u[e.field] == null || u[e.field] === "" ? "Pick a value first" : A.count != null ? `Copy this value onto all ${A.count} lines (staged until you save)` : "Copy this value onto every line (staged until you save)",
673
+ "data-tip": T.count === 0 ? "No lines yet — add lines first" : i[e.field] == null || i[e.field] === "" ? "Pick a value first" : T.count != null ? `Copy this value onto all ${T.count} lines (staged until you save)` : "Copy this value onto every line (staged until you save)",
664
674
  className: "inline-flex items-center gap-1 rounded border border-nvr-cyan/40 px-1.5 py-0.5 text-[10.5px] font-medium text-[#0e7490] transition-colors hover:bg-nvr-cyan/10 disabled:cursor-not-allowed disabled:opacity-40 dark:text-nvr-cyan",
665
675
  children: [
666
- A.label ?? "Apply to lines",
676
+ T.label ?? "Apply to lines",
667
677
  " ↓"
668
678
  ]
669
679
  }
670
680
  ),
671
- Y.length > 0 && /* @__PURE__ */ n(I, { delayDuration: 100, children: /* @__PURE__ */ d(ee, { children: [
672
- /* @__PURE__ */ n(te, { asChild: !0, children: /* @__PURE__ */ d("span", { className: "inline-flex items-center gap-1 rounded-full bg-amber-50 px-1.5 py-0.5 text-[10px] font-medium text-amber-700 border border-amber-200 dark:bg-amber-500/10 dark:text-amber-400 dark:border-amber-500/20 cursor-default", children: [
681
+ Y.length > 0 && /* @__PURE__ */ n(ee, { delayDuration: 100, children: /* @__PURE__ */ u(te, { children: [
682
+ /* @__PURE__ */ n(ne, { asChild: !0, children: /* @__PURE__ */ u("span", { className: "inline-flex items-center gap-1 rounded-full bg-amber-50 px-1.5 py-0.5 text-[10px] font-medium text-amber-700 border border-amber-200 dark:bg-amber-500/10 dark:text-amber-400 dark:border-amber-500/20 cursor-default", children: [
673
683
  /* @__PURE__ */ n("span", { className: "h-1.5 w-1.5 rounded-full bg-amber-400 shrink-0" }),
674
684
  "addendum"
675
685
  ] }) }),
676
- /* @__PURE__ */ d(ne, { side: "top", className: "max-w-[220px] text-[12px]", children: [
677
- /* @__PURE__ */ d("p", { className: "font-medium mb-1", children: [
686
+ /* @__PURE__ */ u(re, { side: "top", className: "max-w-[220px] text-[12px]", children: [
687
+ /* @__PURE__ */ u("p", { className: "font-medium mb-1", children: [
678
688
  "In active addendum",
679
689
  Y.length > 1 ? "s" : "",
680
690
  ":"
681
691
  ] }),
682
- Y.map((t) => /* @__PURE__ */ d("p", { className: "text-slate-400", children: [
692
+ Y.map((t) => /* @__PURE__ */ u("p", { className: "text-slate-400", children: [
683
693
  t.title,
684
694
  " ",
685
- /* @__PURE__ */ d("span", { className: "capitalize", children: [
695
+ /* @__PURE__ */ u("span", { className: "capitalize", children: [
686
696
  "(",
687
697
  t.status,
688
698
  ")"
@@ -693,22 +703,22 @@ const dr = St(function({
693
703
  /* @__PURE__ */ n(
694
704
  Jt,
695
705
  {
696
- collection: a,
706
+ collection: s,
697
707
  kind: "field",
698
708
  name: e.field,
699
709
  label: L
700
710
  }
701
711
  ),
702
- (m || e.readonly) && B ? /* @__PURE__ */ n(Vt, { reason: B, onHover: s == null ? void 0 : s.onLockHover }) : m ? /* @__PURE__ */ n(I, { delayDuration: 200, children: /* @__PURE__ */ d(ee, { children: [
703
- /* @__PURE__ */ n(te, { asChild: !0, children: /* @__PURE__ */ n("span", { className: "inline-flex items-center text-amber-400 dark:text-amber-500", children: /* @__PURE__ */ n(_t, { className: "h-3 w-3" }) }) }),
704
- /* @__PURE__ */ n(ne, { side: "top", className: "text-[12px]", children: "This field is locked" })
712
+ (m || e.readonly) && B ? /* @__PURE__ */ n(Vt, { reason: B, onHover: d == null ? void 0 : d.onLockHover }) : m ? /* @__PURE__ */ n(ee, { delayDuration: 200, children: /* @__PURE__ */ u(te, { children: [
713
+ /* @__PURE__ */ n(ne, { asChild: !0, children: /* @__PURE__ */ n("span", { className: "inline-flex items-center text-amber-400 dark:text-amber-500", children: /* @__PURE__ */ n(_t, { className: "h-3 w-3" }) }) }),
714
+ /* @__PURE__ */ n(re, { side: "top", className: "text-[12px]", children: "This field is locked" })
705
715
  ] }) }) : null,
706
- E.length > 0 && (() => {
707
- const t = !!D && Object.keys(D).length > 0 && M.length > 0, r = E.map(
716
+ P.length > 0 && (() => {
717
+ const t = !!M && Object.keys(M).length > 0 && O.length > 0, r = P.map(
708
718
  (h) => X(String(h.parent_field))
709
719
  );
710
- return /* @__PURE__ */ n(I, { delayDuration: 100, children: /* @__PURE__ */ d(ee, { children: [
711
- /* @__PURE__ */ n(te, { asChild: !0, children: /* @__PURE__ */ n(
720
+ return /* @__PURE__ */ n(ee, { delayDuration: 100, children: /* @__PURE__ */ u(te, { children: [
721
+ /* @__PURE__ */ n(ne, { asChild: !0, children: /* @__PURE__ */ n(
712
722
  "button",
713
723
  {
714
724
  type: "button",
@@ -721,10 +731,10 @@ const dr = St(function({
721
731
  children: /* @__PURE__ */ n(Nt, { className: "h-3 w-3" })
722
732
  }
723
733
  ) }),
724
- /* @__PURE__ */ n(ne, { side: "top", className: "text-[12px]", children: t ? `Filtered by ${M.join(", ")} — click to highlight` : `Options filter by ${r.join(", ")} once set` })
734
+ /* @__PURE__ */ n(re, { side: "top", className: "text-[12px]", children: t ? `Filtered by ${O.join(", ")} — click to highlight` : `Options filter by ${r.join(", ")} once set` })
725
735
  ] }) });
726
736
  })(),
727
- ue && // Right-anchored: the personal-default control flush with the field's right edge
737
+ me && // Right-anchored: the personal-default control flush with the field's right edge
728
738
  // (it carries Make / Update / Clear itself — no ⋯ button; right-click and
729
739
  // Shift+F10 still open the field menu). The slot keeps one box whatever it shows,
730
740
  // so nothing to its left moves.
@@ -733,23 +743,23 @@ const dr = St(function({
733
743
  {
734
744
  field: e.field,
735
745
  label: L,
736
- state: ue,
737
- confirmOpen: de === "make" || de === "update" ? de : null,
746
+ state: me,
747
+ confirmOpen: ue === "make" || ue === "update" ? ue : null,
738
748
  onConfirm: (t, r) => (
739
749
  // After a save the button becomes "Your default": focus goes to the field.
740
- et(t, me, r)
750
+ et(t, pe, r)
741
751
  ),
742
752
  onUndo: () => {
743
753
  C == null || C.undo(e.field), requestAnimationFrame(() => {
744
754
  var t;
745
- return (t = me()) == null ? void 0 : t.focus();
755
+ return (t = pe()) == null ? void 0 : t.focus();
746
756
  });
747
757
  },
748
758
  onCleared: () => (
749
759
  // The Clear button is gone (and not a tab stop): focus goes to the field.
750
760
  requestAnimationFrame(() => {
751
761
  var t;
752
- return (t = me()) == null ? void 0 : t.focus();
762
+ return (t = pe()) == null ? void 0 : t.focus();
753
763
  })
754
764
  )
755
765
  }
@@ -757,22 +767,22 @@ const dr = St(function({
757
767
  ]
758
768
  }
759
769
  ),
760
- T.editor && !m && /* @__PURE__ */ n(
770
+ E.editor && !m && /* @__PURE__ */ n(
761
771
  zt,
762
772
  {
763
- editor: T.editor,
764
- confirming: T.confirming,
765
- onConfirm: T.confirm,
766
- onCancel: T.cancel
773
+ editor: E.editor,
774
+ confirming: E.confirming,
775
+ onConfirm: E.confirm,
776
+ onCancel: E.cancel
767
777
  }
768
778
  ),
769
779
  U ?? /* @__PURE__ */ n(
770
780
  "div",
771
781
  {
772
- ref: ce,
782
+ ref: de,
773
783
  className: j(m && !H && "cursor-not-allowed"),
774
784
  "data-tip": (m || e.readonly) && B ? B : void 0,
775
- onPointerEnter: (m || e.readonly) && B ? s == null ? void 0 : s.onLockHover : void 0,
785
+ onPointerEnter: (m || e.readonly) && B ? d == null ? void 0 : d.onLockHover : void 0,
776
786
  children: /* @__PURE__ */ n(
777
787
  "div",
778
788
  {
@@ -786,50 +796,61 @@ const dr = St(function({
786
796
  m && !H && "pointer-events-none opacity-60",
787
797
  // The ring lands with a 2px shake so the eye finds the field;
788
798
  // the animation runs once when the class is added.
789
- _ && "nvr-shake ring-1 ring-red-400 rounded-md",
790
- ae && "nvr-autofill-glow"
799
+ w && "nvr-shake ring-1 ring-red-400 rounded-md",
800
+ se && "nvr-autofill-glow"
791
801
  ),
792
- children: $ ? /* @__PURE__ */ n(hn, { field: e, values: u }) : ct ? /* @__PURE__ */ n(
802
+ children: q ? /* @__PURE__ */ n(hn, { field: e, values: i }) : ct ? /* @__PURE__ */ n(
793
803
  Kt,
794
804
  {
795
- collection: a,
805
+ collection: s,
796
806
  field: e,
797
- draft: u,
807
+ draft: i,
798
808
  itemId: l
799
809
  }
800
- ) : y ? y({
810
+ ) : b ? b({
801
811
  field: e,
802
- value: he,
812
+ value: xe,
803
813
  onChange: Le,
804
814
  disabled: m,
805
- collection: a,
815
+ collection: s,
806
816
  itemId: l,
807
817
  relations: f,
808
- cascadeFilter: D,
818
+ cascadeFilter: M,
809
819
  unsatisfiedParentLabel: pt,
810
820
  requiredParentLabel: Be
811
821
  }) : /* @__PURE__ */ n(
812
822
  Yt,
813
823
  {
814
824
  field: m && H ? ht() : e,
815
- value: he,
825
+ value: xe,
816
826
  onChange: Le,
817
827
  relations: f,
818
- collection: a,
828
+ collection: s,
819
829
  itemId: l,
820
- cascadeFilter: D,
830
+ cascadeFilter: M,
821
831
  requiredParentLabel: Be,
822
- narrowedBy: M.length > 0 ? xt() : void 0,
832
+ narrowedBy: O.length > 0 ? xt() : void 0,
823
833
  onCountChange: o ? Ye : void 0
824
834
  }
825
835
  )
826
836
  },
827
- ae ?? 0
837
+ se ?? 0
828
838
  )
829
839
  }
830
840
  ),
831
- Ee && /* @__PURE__ */ n(xn, { value: u[e.field], config: Ee }),
832
- !_ && Pe && // A soft (warning-only) rule the value breaks: said here, never blocks the save.
841
+ Ee && /* @__PURE__ */ n(xn, { value: i[e.field], config: Ee }),
842
+ w && // The message under the field: a red border alone never said WHY (Service End before
843
+ // Start, b01-N5). The form's summary at the top lists it too.
844
+ /* @__PURE__ */ n(
845
+ "p",
846
+ {
847
+ role: "alert",
848
+ "data-field-error": e.field,
849
+ className: "text-[11.5px] leading-snug text-red-600 dark:text-red-400",
850
+ children: w
851
+ }
852
+ ),
853
+ !w && Pe && // A soft (warning-only) rule the value breaks: said here, never blocks the save.
833
854
  /* @__PURE__ */ n(
834
855
  "p",
835
856
  {
@@ -843,10 +864,10 @@ const dr = St(function({
843
864
  Gt,
844
865
  {
845
866
  change: qe,
846
- onDismiss: () => s == null ? void 0 : s.dismissRemoteChange(e.field),
847
- onTakeTheirs: s != null && s.takeRemoteChange ? () => {
867
+ onDismiss: () => d == null ? void 0 : d.dismissRemoteChange(e.field),
868
+ onTakeTheirs: d != null && d.takeRemoteChange ? () => {
848
869
  var t;
849
- return (t = s.takeRemoteChange) == null ? void 0 : t.call(s, e.field);
870
+ return (t = d.takeRemoteChange) == null ? void 0 : t.call(d, e.field);
850
871
  } : void 0
851
872
  }
852
873
  )
@@ -856,7 +877,8 @@ const dr = St(function({
856
877
  );
857
878
  });
858
879
  export {
859
- dr as FieldRow,
860
- cr as lineageSummary,
861
- Ln as useFieldLineage
880
+ ur as FieldRow,
881
+ Ln as clearableParents,
882
+ dr as lineageSummary,
883
+ Rn as useFieldLineage
862
884
  };