@nivaro/react 0.3.90 → 0.3.91

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.
@@ -7,7 +7,7 @@ import { toast as _e } from "sonner";
7
7
  import { useNivaroClient as jg, useApiFetchConfig as Ag, ItemEditAuthContext as qg, useItemNavigation as Tg, useRecordSurface as Af, useNavigation as Ig, ReimportHandlerContext as Eg, RelationPathDataContext as Pg, ParentDraftContext as Lg, GridFlushContext as Mg, StaleFieldReportContext as Kg } from "../context.js";
8
8
  import { useSlowReason as Dg } from "../hooks/useSlowReason.js";
9
9
  import { formatApiPayload as Bg } from "../lib/api-payload.js";
10
- import { get as se, post as on, del as mr, patch as mi, put as zg } from "../lib/commands.js";
10
+ import { get as se, post as ln, del as mr, patch as mi, put as zg } from "../lib/commands.js";
11
11
  import { prefillSignature as Wg, loadDraft as Qg, draftHasContent as $l, draftMatchesPrefill as Vg, deleteDraft as vs, draftCreatedAs as Hg, draftFilledBack as Ug, markDraftCreated as Jg, draftKey as Gg, keepDraftSavedAt as Yg, lineBasesForDraft as Zg, saveDraft as Xg, draftPersistDecision as ey } from "../lib/draft-store.js";
12
12
  import { editLockLockedFields as ty } from "../lib/edit-lock-fields.js";
13
13
  import { entryConfigOf as ny } from "../lib/entry-config.js";
@@ -80,7 +80,7 @@ import { HeaderTools as r0, HeaderToolGroup as s0, HeaderMenu as i0 } from "./it
80
80
  import { HighlightedCode as o0 } from "./item-edit/HighlightedCode.js";
81
81
  import { staleDraftConflicts as a0, restoredDraftCollisions as l0, clientMidairError as d0, conflictsNeedingPerson as Df, saveIsEcho as c0, resolveHeaderCollision as u0 } from "./item-edit/header-midair.js";
82
82
  import { useHeaderPathPreview as f0 } from "./item-edit/header-path-preview.js";
83
- import { parseJson as Un, getCascadeFilters as Bf, SYSTEM_FIELDS as Xt, isSentinelKey as Tr, applyDisplayTemplate as Tl, useContainerWidth as m0, resolveColSpan as Il } from "./item-edit/helpers.js";
83
+ import { parseJson as Un, getCascadeFilters as Bf, SYSTEM_FIELDS as tn, isSentinelKey as Tr, applyDisplayTemplate as Tl, useContainerWidth as m0, resolveColSpan as Il } from "./item-edit/helpers.js";
84
84
  import { evalClientFormula as p0 } from "./item-edit/InlineTableField.js";
85
85
  import { LayoutContentBlock as h0, SectionIntro as g0 } from "./item-edit/LayoutContentBlock.js";
86
86
  import { deferredSections as y0 } from "./item-edit/lazy-sections.js";
@@ -149,7 +149,7 @@ import { MoveToStatePanel as rv } from "./panels/MoveToStatePanel.js";
149
149
  import { FormSkeleton as sv } from "./Skeletons.js";
150
150
  import { SlowNoticeView as em } from "./SlowNotice.js";
151
151
  import { TipLayer as iv } from "./TipLayer.js";
152
- import { Button as Zt } from "./ui/button.js";
152
+ import { Button as en } from "./ui/button.js";
153
153
  import { Dialog as yi, DialogContent as _i, DialogHeader as bi, DialogTitle as vi, DialogBody as wi, DialogFooter as Vo } from "./ui/dialog.js";
154
154
  import { Popover as wm, PopoverTrigger as km, PopoverContent as xm } from "./ui/popover.js";
155
155
  import { Skeleton as hi } from "./ui/skeleton.js";
@@ -430,14 +430,14 @@ function xv({
430
430
  )) == null ? void 0 : ue.one_collection) ?? null;
431
431
  }, Gn = (H, ue) => (ue == null ? void 0 : ue.label) || be(H.replace(/_/g, " ")), Er = new Map((F ?? []).map((H) => [H.field, H])), hr = [];
432
432
  for (const H of F ?? [])
433
- et(L[H.field], ne[H.field]) || L[H.field] !== void 0 && hr.push({
433
+ tt(L[H.field], ne[H.field]) || L[H.field] !== void 0 && hr.push({
434
434
  key: H.field,
435
435
  label: Gn(H.field, H),
436
436
  from: ne[H.field],
437
437
  to: L[H.field]
438
438
  });
439
439
  for (const H of Object.keys(L))
440
- Er.has(H) || H.startsWith("__") || et(L[H], ne[H]) || hr.push({ key: H, label: H, from: ne[H], to: L[H] });
440
+ Er.has(H) || H.startsWith("__") || tt(L[H], ne[H]) || hr.push({ key: H, label: H, from: ne[H], to: L[H] });
441
441
  const xs = (H) => {
442
442
  var qt;
443
443
  const ue = q.find((Yn) => Yn.one_collection === N && Yn.one_field === H);
@@ -516,7 +516,7 @@ function xv({
516
516
  }
517
517
  );
518
518
  }
519
- function et(i, k) {
519
+ function tt(i, k) {
520
520
  return i === k || i == null && k == null ? !0 : i == null || k == null ? !1 : typeof i == "string" && typeof k == "number" || typeof i == "number" && typeof k == "string" ? String(i) === String(k) : JSON.stringify(i) === JSON.stringify(k);
521
521
  }
522
522
  function Sv(i, k) {
@@ -541,7 +541,7 @@ function dm(i, k) {
541
541
  return N ?? i;
542
542
  }
543
543
  function Nv(i, k, N, q) {
544
- return new Set(i.filter((F) => k.has(F) && !et(N[F], q[F])));
544
+ return new Set(i.filter((F) => k.has(F) && !tt(N[F], q[F])));
545
545
  }
546
546
  function Vl(i) {
547
547
  const k = i.options, N = typeof k == "string" ? (() => {
@@ -575,7 +575,7 @@ function Cv(i, k, N) {
575
575
  }
576
576
  function Rv(i, k) {
577
577
  const N = i === "" ? null : i, q = k === "" ? null : k;
578
- if (et(N, q)) return !0;
578
+ if (tt(N, q)) return !0;
579
579
  const F = (le) => typeof le == "number" ? le : typeof le == "string" && /^\s*-?\d+(\.\d+)?\s*$/.test(le) ? Number(le) : Number.NaN, L = F(N), ne = F(q);
580
580
  return Number.isFinite(L) && Number.isFinite(ne) && L === ne;
581
581
  }
@@ -583,7 +583,7 @@ function Ov(i, k) {
583
583
  return Object.keys(i).some((N) => !N.startsWith("__") && !Rv(i[N], k[N]));
584
584
  }
585
585
  function Fv(i, k, N, q) {
586
- return i.some((F) => k.has(F) && !et(N[F], q[F]));
586
+ return i.some((F) => k.has(F) && !tt(N[F], q[F]));
587
587
  }
588
588
  function jv(i, k, N, q) {
589
589
  return i[0] !== "o2m-rows" || String(i[3]) !== String(k) || i.length === 5 && i[4] === "" || !Array.isArray(q) || !Array.isArray(N) ? !1 : i.length === 4 ? q.length !== N.length : q.length > N.length;
@@ -621,7 +621,7 @@ const cm = "Add at least one line";
621
621
  function qv(i, k, N) {
622
622
  if (i) return !1;
623
623
  const q = k.filter(
624
- (F) => !F.hidden && !Xt.has(F.field) && !Tr(F.field) && F.layout_assigned !== !1
624
+ (F) => !F.hidden && !tn.has(F.field) && !Tr(F.field) && F.layout_assigned !== !1
625
625
  );
626
626
  return q.length > 0 && q.every((F) => N(F.field));
627
627
  }
@@ -641,7 +641,7 @@ function Ev(i) {
641
641
  }
642
642
  function Pv(i, k) {
643
643
  return Object.keys(k).filter(
644
- (N) => !N.startsWith("__") && Object.hasOwn(i, N) && i[N] !== void 0 && !et(i[N], k[N])
644
+ (N) => !N.startsWith("__") && Object.hasOwn(i, N) && i[N] !== void 0 && !tt(i[N], k[N])
645
645
  );
646
646
  }
647
647
  function Lv(i, k) {
@@ -894,16 +894,16 @@ function mm({
894
894
  onHeaderWidgets: Ho,
895
895
  autofillProposalId: Fm,
896
896
  onAutofillConsumed: jm,
897
- initialImportResult: Lt,
898
- initialValues: Mt,
897
+ initialImportResult: Mt,
898
+ initialValues: Kt,
899
899
  initialLinks: Kn,
900
900
  initialRows: Zn,
901
901
  rehearseCopiedLines: Am = !1,
902
- design: Kt,
902
+ design: Dt,
903
903
  layoutEditing: Gl = !1
904
904
  }) {
905
905
  var Vu, Hu, Uu, Ju, Gu, Yu, Zu, Xu, ef, tf, nf, rf, sf, of, af, lf, df, cf, uf, ff, mf, pf, hf, gf, yf, _f, bf, vf, wf;
906
- const I = Kt != null, Be = (Kt == null ? void 0 : Kt.context) ?? null, Uo = Be != null, $n = !!(Be != null && Be.showHidden), R = jg(), $i = jy(), Dn = Ag(), { isAdmin: Rt, userId: Le } = Rg(qg), nt = qb(i, Rt), Yl = Tg(), [qm, Zl] = P(!1), Bn = ((Hu = (Vu = nt.preview) == null ? void 0 : Vu.layout) == null ? void 0 : Hu.slug) ?? N, X = fg(), Tm = ((Uu = Kt == null ? void 0 : Kt.record) == null ? void 0 : Uu.id) != null ? String(Kt.record.id) : void 0, Jo = k ?? (I ? Tm : void 0), p = Jo ?? "new", m = !Jo || Jo === "new", [Xn] = P(Sy), { data: Im } = $t({
906
+ const I = Dt != null, Be = (Dt == null ? void 0 : Dt.context) ?? null, Uo = Be != null, $n = !!(Be != null && Be.showHidden), R = jg(), $i = jy(), Dn = Ag(), { isAdmin: Rt, userId: Le } = Rg(qg), rt = qb(i, Rt), Yl = Tg(), [qm, Zl] = P(!1), Bn = ((Hu = (Vu = rt.preview) == null ? void 0 : Vu.layout) == null ? void 0 : Hu.slug) ?? N, X = fg(), Tm = ((Uu = Dt == null ? void 0 : Dt.record) == null ? void 0 : Uu.id) != null ? String(Dt.record.id) : void 0, Jo = k ?? (I ? Tm : void 0), p = Jo ?? "new", m = !Jo || Jo === "new", [Xn] = P(Sy), { data: Im } = $t({
907
907
  // Desktop keeps the key the host's own /active read shares (admin ItemEdit).
908
908
  queryKey: [
909
909
  "active-layout",
@@ -921,8 +921,8 @@ function mm({
921
921
  ).then((e) => e.data).catch(() => null),
922
922
  staleTime: 6e4,
923
923
  enabled: !I
924
- }), w = I ? Kt.layout : Im, Dt = ((Ju = w == null ? void 0 : w.layout) == null ? void 0 : Ju.id) ?? null, [Xl, ed] = P(() => /* @__PURE__ */ new Set());
925
- z(() => ed(/* @__PURE__ */ new Set()), [i, p, Dt]);
924
+ }), w = I ? Dt.layout : Im, Bt = ((Ju = w == null ? void 0 : w.layout) == null ? void 0 : Ju.id) ?? null, [Xl, ed] = P(() => /* @__PURE__ */ new Set());
925
+ z(() => ed(/* @__PURE__ */ new Set()), [i, p, Bt]);
926
926
  const Ns = A(
927
927
  () => y0(w, Xl, { design: I }),
928
928
  [w, Xl, I]
@@ -935,18 +935,18 @@ function mm({
935
935
  ).then((e) => e.data).catch(() => null),
936
936
  staleTime: 6e4,
937
937
  enabled: !m && !I
938
- }), Kr = I ? Kt.layout.assignments : null, {
938
+ }), Kr = I ? Dt.layout.assignments : null, {
939
939
  data: Ci,
940
940
  isLoading: Zv,
941
941
  isFetched: Ri
942
942
  } = $t({
943
- queryKey: Kr ? ["layout-editor", "field-config", i, Kr] : ["field-config", i, Dt],
943
+ queryKey: Kr ? ["layout-editor", "field-config", i, Kr] : ["field-config", i, Bt],
944
944
  queryFn: () => Kr ? R.request(
945
- on(`/field-config/${i}/project`, { assignments: Kr })
945
+ ln(`/field-config/${i}/project`, { assignments: Kr })
946
946
  ).then((e) => e.data ?? []) : R.request(
947
947
  se(
948
948
  `/field-config/${i}`,
949
- Dt ? { layout_id: String(Dt) } : void 0
949
+ Bt ? { layout_id: String(Bt) } : void 0
950
950
  )
951
951
  ).then((e) => e.data ?? []),
952
952
  staleTime: 6e4,
@@ -1050,7 +1050,7 @@ function mm({
1050
1050
  const n = (t == null ? void 0 : t.status) ?? ((r = t == null ? void 0 : t.response) == null ? void 0 : r.status);
1051
1051
  return n === 403 || n === 404 ? !1 : e < 2;
1052
1052
  }
1053
- }), de = I ? Kt.record ?? void 0 : na, cd = A(
1053
+ }), de = I ? Dt.record ?? void 0 : na, cd = A(
1054
1054
  () => I ? null : Hy(w, { isNew: m }),
1055
1055
  [I, w, m]
1056
1056
  ), Ti = Dg({
@@ -1062,7 +1062,7 @@ function mm({
1062
1062
  if (m || !zn) return !1;
1063
1063
  const e = (zn == null ? void 0 : zn.status) ?? ((t = zn == null ? void 0 : zn.response) == null ? void 0 : t.status);
1064
1064
  return e === 403 || e === 404;
1065
- })(), ud = ra && !de, Bt = de != null, [M, pt] = P({}), U = $({}), sa = $(!1), Ii = $(!1), qe = $(/* @__PURE__ */ new Set()), Fs = $(0), br = $(/* @__PURE__ */ new Map()), ia = $(/* @__PURE__ */ new Map()), Wm = A(
1065
+ })(), ud = ra && !de, zt = de != null, [M, pt] = P({}), U = $({}), sa = $(!1), Ii = $(!1), qe = $(/* @__PURE__ */ new Set()), Fs = $(0), br = $(/* @__PURE__ */ new Map()), ia = $(/* @__PURE__ */ new Map()), Wm = A(
1066
1066
  () => ({
1067
1067
  register: (e, t) => {
1068
1068
  ia.current.set(e, t);
@@ -1072,15 +1072,15 @@ function mm({
1072
1072
  }
1073
1073
  }),
1074
1074
  []
1075
- ), [tt, hn] = P({}), Ei = $(/* @__PURE__ */ new Map()), [fd, md] = P(!1), [Qm, Vm] = P(!1), [Hm, Um] = P(""), pd = $({});
1075
+ ), [nt, hn] = P({}), Ei = $(/* @__PURE__ */ new Map()), [fd, md] = P(!1), [Qm, Vm] = P(!1), [Hm, Um] = P(""), pd = $({});
1076
1076
  z(() => {
1077
1077
  const e = pd.current;
1078
- if (pd.current = tt, fd) return;
1079
- const t = E0(e, tt);
1078
+ if (pd.current = nt, fd) return;
1079
+ const t = E0(e, nt);
1080
1080
  if (!t) return;
1081
1081
  const n = (j ?? []).find((r) => r.field === t.field);
1082
1082
  Um(`${(n == null ? void 0 : n.label) || be(t.field)}: ${t.message}`);
1083
- }, [tt]);
1083
+ }, [nt]);
1084
1084
  const [hd, Wr] = P(null), [Jm, gd] = P(!1), [Gm, Pi] = P(!1), [Ym, yd] = P(!1), _t = $(null), [Me, Qr] = P(null);
1085
1085
  z(() => {
1086
1086
  if (!Me || Me.current !== void 0 || m || p == null) return;
@@ -1154,14 +1154,14 @@ function mm({
1154
1154
  () => x != null && x.read_mode_toggle ? Pf(x.summary_mode_rules) : null,
1155
1155
  [x == null ? void 0 : x.read_mode_toggle, x == null ? void 0 : x.summary_mode_rules]
1156
1156
  ), [Xm, ep] = P(null), fa = `${i}|${String(p)}`, Ur = I || m || x !== void 0 && (!vr || Xm === fa), vt = Gg(i, p, Le), Sd = A(
1157
- () => m && (Mt || Kn || Zn) ? Wg({
1158
- v: Mt ?? null,
1157
+ () => m && (Kt || Kn || Zn) ? Wg({
1158
+ v: Kt ?? null,
1159
1159
  l: Kn ?? null,
1160
1160
  r: Zn ?? null
1161
1161
  }) : null,
1162
- [m, Mt, Kn, Zn]
1163
- ), [en, Jr] = P({ state: I ? "none" : "checking" }), Nd = $(en);
1164
- Nd.current = en;
1162
+ [m, Kt, Kn, Zn]
1163
+ ), [nn, Jr] = P({ state: I ? "none" : "checking" }), Nd = $(nn);
1164
+ Nd.current = nn;
1165
1165
  const [tp, np] = P(!1), [As, rp] = P(null), wr = $(!1), [ma, $d] = P(!1);
1166
1166
  z(() => {
1167
1167
  const e = (t) => {
@@ -1220,7 +1220,7 @@ function mm({
1220
1220
  // colleague's save took that save as its baseline, and its own save then
1221
1221
  // wrote over the newer value with no 409. One small read per open — once the
1222
1222
  // record has answered (army 10: beside the read it 404'd for a missing record).
1223
- enabled: !m && !!p && Bt,
1223
+ enabled: !m && !!p && zt,
1224
1224
  // The baseline only moves when the form adopts the server's values (its
1225
1225
  // own save, a remote change it took in) — those invalidate it. Refetching
1226
1226
  // on its own (stale + window focus) moved it past another tab's save while
@@ -1255,7 +1255,7 @@ function mm({
1255
1255
  }, []), [je, rr] = P(
1256
1256
  /* @__PURE__ */ new Map()
1257
1257
  ), to = $(/* @__PURE__ */ new Map()), [ze, kr] = P(/* @__PURE__ */ new Map()), [We, no] = P(/* @__PURE__ */ new Map()), Ad = $(() => {
1258
- }), [Es, pp] = P(() => /* @__PURE__ */ new Set()), ba = $(/* @__PURE__ */ new Map()), an = A(
1258
+ }), [Es, pp] = P(() => /* @__PURE__ */ new Set()), ba = $(/* @__PURE__ */ new Map()), dn = A(
1259
1259
  () => ({
1260
1260
  noteEditIntent: () => Ad.current(),
1261
1261
  noteLineDraft: (e, t) => pp((n) => {
@@ -1313,19 +1313,19 @@ function mm({
1313
1313
  })
1314
1314
  }),
1315
1315
  [je, ze, We]
1316
- ), [qd, Xr] = P([]), Td = $(!1), va = $(!1), wa = $({}), [Ge, es] = P(/* @__PURE__ */ new Map()), [at, Ps] = P(/* @__PURE__ */ new Map()), xr = $(
1316
+ ), [qd, Xr] = P([]), Td = $(!1), va = $(!1), wa = $({}), [Ye, es] = P(/* @__PURE__ */ new Map()), [at, Ps] = P(/* @__PURE__ */ new Map()), xr = $(
1317
1317
  null
1318
- ), Ls = $(/* @__PURE__ */ new Map()), tn = $(0), Ms = $(/* @__PURE__ */ new Map()), Fn = $(/* @__PURE__ */ new Map()), ts = $(/* @__PURE__ */ new Map()), ka = (e) => R_(
1318
+ ), Ls = $(/* @__PURE__ */ new Map()), rn = $(0), Ms = $(/* @__PURE__ */ new Map()), Fn = $(/* @__PURE__ */ new Map()), ts = $(/* @__PURE__ */ new Map()), ka = (e) => R_(
1319
1319
  {
1320
1320
  touched: qe.current,
1321
1321
  seq: br.current,
1322
1322
  next: () => ++Fs.current
1323
1323
  },
1324
1324
  e,
1325
- { crossFill: tn.current, notPerson: Ot.current }
1325
+ { crossFill: rn.current, notPerson: Ot.current }
1326
1326
  ), xe = A(
1327
1327
  () => ({
1328
- getStagedLinks: (e) => Ge.get(e) ?? [],
1328
+ getStagedLinks: (e) => Ye.get(e) ?? [],
1329
1329
  getStagedUnlinks: (e) => at.get(e) ?? /* @__PURE__ */ new Set(),
1330
1330
  getDerivedOrigin: (e) => Fn.current.get(e) ?? null,
1331
1331
  stageLink: (e, t) => {
@@ -1335,7 +1335,7 @@ function mm({
1335
1335
  if (l === o) return s;
1336
1336
  const c = new Map(s);
1337
1337
  return c.set(e, l), c;
1338
- }), tn.current === 0) {
1338
+ }), rn.current === 0) {
1339
1339
  const s = Ls.current.get(e);
1340
1340
  s && (Ot.current === 0 && (ka(s), Fn.current.delete(s), Tt.current.delete(s), Gr.current.delete(e), Ui.current(s)), (n = xr.current) == null || n.call(xr, s, t), (r = wt.current) == null || r.call(wt, s, t));
1341
1341
  }
@@ -1344,7 +1344,7 @@ function mm({
1344
1344
  if (Ps((n) => {
1345
1345
  const r = new Map(n), s = new Set(r.get(e));
1346
1346
  return s.add(t), r.set(e, s), r;
1347
- }), tn.current === 0 && Ot.current === 0) {
1347
+ }), rn.current === 0 && Ot.current === 0) {
1348
1348
  const n = Ls.current.get(e);
1349
1349
  n && ka(n);
1350
1350
  }
@@ -1356,7 +1356,7 @@ function mm({
1356
1356
  e,
1357
1357
  (r.get(e) ?? []).filter((s) => String(s).toLowerCase() !== String(t).toLowerCase())
1358
1358
  ), r;
1359
- }), tn.current === 0 && Ot.current === 0) {
1359
+ }), rn.current === 0 && Ot.current === 0) {
1360
1360
  const n = Ls.current.get(e);
1361
1361
  n && (ka(n), Fn.current.delete(n), Tt.current.delete(n), Gr.current.delete(e), Ui.current(n));
1362
1362
  }
@@ -1366,7 +1366,7 @@ function mm({
1366
1366
  return s.delete(t), r.set(e, s), r;
1367
1367
  })
1368
1368
  }),
1369
- [Ge, at]
1369
+ [Ye, at]
1370
1370
  ), ns = ce(
1371
1371
  async (e) => {
1372
1372
  U.current = { ...U.current, ...e.values }, pt((r) => ({ ...r, ...e.values }));
@@ -1409,7 +1409,7 @@ function mm({
1409
1409
  });
1410
1410
  }
1411
1411
  for (const d of e.lines)
1412
- an.queueRow(r.many_collection, r.many_field, {
1412
+ dn.queueRow(r.many_collection, r.many_field, {
1413
1413
  ...d.values,
1414
1414
  ...d.nested ? {
1415
1415
  [e.nested_relation ? `__o2m_${d.nested.field}` : d.nested.field]: d.nested.rows
@@ -1446,7 +1446,7 @@ function mm({
1446
1446
  }
1447
1447
  Xr(t);
1448
1448
  },
1449
- [i, D, an, xe, j, R]
1449
+ [i, D, dn, xe, j, R]
1450
1450
  ), Ks = $(null), [hp, gp] = P(!1), yp = ce(
1451
1451
  async (e) => {
1452
1452
  Ks.current = {
@@ -1487,7 +1487,7 @@ function mm({
1487
1487
  for (const r of Object.keys(t)) qe.current.add(r);
1488
1488
  },
1489
1489
  [ns, j]
1490
- ), [rt, ro] = P(null), [so, Id] = P(!1), Ed = ce(
1490
+ ), [st, ro] = P(null), [so, Id] = P(!1), Ed = ce(
1491
1491
  async (e, t) => {
1492
1492
  const n = t.reimport;
1493
1493
  if (!n) return;
@@ -1646,13 +1646,13 @@ function mm({
1646
1646
  }
1647
1647
  const S = `import:${t.template_name || "file"}:${t.file_id ?? ""}`;
1648
1648
  for (const y of s)
1649
- an.cancelPendingDelete(u, f, y);
1649
+ dn.cancelPendingDelete(u, f, y);
1650
1650
  for (const y of h)
1651
- an.queueRow(u, f, { ...y, _change_reason: S });
1651
+ dn.queueRow(u, f, { ...y, _change_reason: S });
1652
1652
  for (const y of e.updates)
1653
- an.queueEdit(u, f, y.id, y.changes);
1653
+ dn.queueEdit(u, f, y.id, y.changes);
1654
1654
  for (const y of e.deletes)
1655
- an.queueDelete(u, f, y);
1655
+ dn.queueDelete(u, f, y);
1656
1656
  if (o.lines === "upsert" || o.lines === "upsert_delete") {
1657
1657
  const y = om(t), T = /* @__PURE__ */ new Map();
1658
1658
  for (const Y of r)
@@ -1706,7 +1706,7 @@ function mm({
1706
1706
  fe.push(String(B.id)), V.set(re, fe);
1707
1707
  }
1708
1708
  for (const B of oe)
1709
- an.queueEdit(u, f, B.id, {
1709
+ dn.queueEdit(u, f, B.id, {
1710
1710
  [`__nested_ops_${Y}`]: {
1711
1711
  created: B.members,
1712
1712
  updated: [],
@@ -1794,14 +1794,14 @@ function mm({
1794
1794
  message: `Re-import: ${e.updates.length} updates · ${e.creates.length} new · ${e.deletes.length} deletes · ${e.matchedUnchanged} unchanged`
1795
1795
  }), Xr(c);
1796
1796
  },
1797
- [i, D, an, xe, R, p, j]
1797
+ [i, D, dn, xe, R, p, j]
1798
1798
  ), xa = $(!1), [Sa, Pd] = P(null);
1799
1799
  z(() => {
1800
- if (!m || !Mt && !Kn && !Zn || xa.current)
1800
+ if (!m || !Kt && !Kn && !Zn || xa.current)
1801
1801
  return;
1802
1802
  xa.current = !0;
1803
- const { __links: e, ...t } = Mt ?? {};
1804
- if (Mt) {
1803
+ const { __links: e, ...t } = Kt ?? {};
1804
+ if (Kt) {
1805
1805
  pt((s) => ({ ...t, ...s })), U.current = { ...t, ...U.current };
1806
1806
  const r = Object.entries(t).filter(
1807
1807
  ([, s]) => s != null && s !== ""
@@ -1820,15 +1820,15 @@ function mm({
1820
1820
  !s.has(o) && l.length && s.set(o, [...l]);
1821
1821
  return s;
1822
1822
  }), On(!0);
1823
- }, [m, Mt, Kn, Zn]), z(() => {
1823
+ }, [m, Kt, Kn, Zn]), z(() => {
1824
1824
  if (!(!Sa || !nd)) {
1825
1825
  Pd(null);
1826
1826
  for (const [e, t] of Sa)
1827
1827
  U.current[e] === t && io.current(e, t);
1828
1828
  }
1829
1829
  }, [Sa, nd]), z(() => {
1830
- !m || !Lt || Td.current || (Lt.lines.length > 0 || Object.keys(Lt.m2m ?? {}).length > 0) && !yr || Lt.lines.length > 0 && !Ri || (Td.current = !0, ns(Lt));
1831
- }, [m, Lt, yr, Ri, ns]), z(() => {
1830
+ !m || !Mt || Td.current || (Mt.lines.length > 0 || Object.keys(Mt.m2m ?? {}).length > 0) && !yr || Mt.lines.length > 0 && !Ri || (Td.current = !0, ns(Mt));
1831
+ }, [m, Mt, yr, Ri, ns]), z(() => {
1832
1832
  if (!de) return;
1833
1833
  const e = $e.current, t = Object.keys(e).length === 0, n = Date.now() - ca.current < 8e3;
1834
1834
  if (!t && !n) {
@@ -1841,14 +1841,14 @@ function mm({
1841
1841
  Hr((h) => {
1842
1842
  const v = { ...h };
1843
1843
  for (const S of r) {
1844
- const y = o(S) && !et(U.current[S], de[S]);
1844
+ const y = o(S) && !tt(U.current[S], de[S]);
1845
1845
  !y && !c.includes(S) || (v[S] = y ? { was: e[S], by: g, at: u, theirs: de[S], conflict: !0 } : { was: e[S], by: g, at: u });
1846
1846
  }
1847
1847
  return v;
1848
1848
  }), Fv(r, s, U.current, de) || X.invalidateQueries({ queryKey: ["collision-base", i, p] });
1849
1849
  for (const h of r) o(h) || qe.current.delete(h);
1850
1850
  if ([...qe.current].some(
1851
- (h) => !et(U.current[h], de[h])
1851
+ (h) => !tt(U.current[h], de[h])
1852
1852
  )) {
1853
1853
  $e.current = de;
1854
1854
  const h = { ...U.current };
@@ -1860,28 +1860,28 @@ function mm({
1860
1860
  }
1861
1861
  $e.current = de, U.current = de, pt(de), On(Ai.current);
1862
1862
  }, [de]);
1863
- const ln = A(() => {
1863
+ const cn = A(() => {
1864
1864
  const e = $e.current, t = [];
1865
1865
  for (const f of Object.keys(M))
1866
- f.startsWith("__") || qe.current.has(f) && (et(M[f], e[f]) || t.push(f));
1867
- const n = (f, h) => [...f.values()].reduce((v, S) => v + h(S), 0), r = n(je, (f) => f.length), s = n(ze, (f) => f.size), o = n(We, (f) => f.size), l = Uf(Ge, Hi.current(Ge)), c = n(at, (f) => f.size), d = t.length + r + s + o + l + c, g = [];
1866
+ f.startsWith("__") || qe.current.has(f) && (tt(M[f], e[f]) || t.push(f));
1867
+ const n = (f, h) => [...f.values()].reduce((v, S) => v + h(S), 0), r = n(je, (f) => f.length), s = n(ze, (f) => f.size), o = n(We, (f) => f.size), l = Uf(Ye, Hi.current(Ye)), c = n(at, (f) => f.size), d = t.length + r + s + o + l + c, g = [];
1868
1868
  t.length && g.push(`${t.length} field${t.length === 1 ? "" : "s"}`);
1869
1869
  const u = r + s + o;
1870
1870
  return u && g.push(`${u} line${u === 1 ? "" : "s"}`), l + c && g.push(`${l + c} link${l + c === 1 ? "" : "s"}`), { fields: t, rows: r, edits: s, deletes: o, links: l, unlinks: c, total: d, text: g.join(", ") };
1871
- }, [M, je, ze, We, Ge, at]), zt = Ue || ln.total > 0, Na = $(async () => !1);
1872
- n_(zt, "Unsaved record changes", () => Na.current()), z(() => {
1873
- xs == null || xs(zt, ln), window.dispatchEvent(
1871
+ }, [M, je, ze, We, Ye, at]), Wt = Ue || cn.total > 0, Na = $(async () => !1);
1872
+ n_(Wt, "Unsaved record changes", () => Na.current()), z(() => {
1873
+ xs == null || xs(Wt, cn), window.dispatchEvent(
1874
1874
  new CustomEvent("nvr:form-unsaved", {
1875
- detail: { collection: i, item: m ? "new" : String(p), ...ln }
1875
+ detail: { collection: i, item: m ? "new" : String(p), ...cn }
1876
1876
  })
1877
1877
  );
1878
- }, [zt, ln]), z(() => {
1879
- if (!zt) return;
1878
+ }, [Wt, cn]), z(() => {
1879
+ if (!Wt) return;
1880
1880
  const e = (t) => {
1881
- r_() || (t.preventDefault(), t.returnValue = ln.text ? `You have unsaved changes: ${ln.text}.` : "You have unsaved changes.");
1881
+ r_() || (t.preventDefault(), t.returnValue = cn.text ? `You have unsaved changes: ${cn.text}.` : "You have unsaved changes.");
1882
1882
  };
1883
1883
  return window.addEventListener("beforeunload", e), () => window.removeEventListener("beforeunload", e);
1884
- }, [zt, ln.text]);
1884
+ }, [Wt, cn.text]);
1885
1885
  const Ld = m || !!de;
1886
1886
  z(() => {
1887
1887
  if (!Ld || I || As === vt) return;
@@ -1901,13 +1901,13 @@ function mm({
1901
1901
  if (!o || !$l(o) || m && !Vg(o, Sd) || // A new form seeded by a file import (Import BID Template, BOM Upload)
1902
1902
  // IS the person's starting point: an older draft offered over it
1903
1903
  // would mix an abandoned form into the import (army11 f1).
1904
- m && Lt) {
1904
+ m && Mt) {
1905
1905
  Jr({ state: "none" });
1906
1906
  return;
1907
1907
  }
1908
1908
  const l = $e.current, c = {};
1909
1909
  for (const [u, f] of Object.entries(o.fields ?? {}))
1910
- et(f, l[u]) || (c[u] = f);
1910
+ tt(f, l[u]) || (c[u] = f);
1911
1911
  const d = { ...o, fields: c };
1912
1912
  if (!$l(d)) {
1913
1913
  vs(vt), Jr({ state: "none" });
@@ -1929,17 +1929,17 @@ function mm({
1929
1929
  },
1930
1930
  []
1931
1931
  ), z(() => {
1932
- if (Ds.current = null, Na.current = async () => !1, en.state !== "none" || As !== vt) return;
1932
+ if (Ds.current = null, Na.current = async () => !1, nn.state !== "none" || As !== vt) return;
1933
1933
  const e = async (n = !1) => {
1934
1934
  if (Ds.current = null, rs.current) return !n;
1935
- const r = Hi.current(Ge), s = je.size + ze.size + We.size + (r.size ? Uf(Ge, r) : Ge.size) + at.size, o = je.size + ze.size + We.size, l = ey({ isDirty: Ue, forReload: n, staged: s, stagedLines: o });
1935
+ const r = Hi.current(Ye), s = je.size + ze.size + We.size + (r.size ? Uf(Ye, r) : Ye.size) + at.size, o = je.size + ze.size + We.size, l = ey({ isDirty: Ue, forReload: n, staged: s, stagedLines: o });
1936
1936
  if (l === "hold") return !1;
1937
1937
  if (l === "drop")
1938
1938
  return vs(vt), Le && wr.current && (wr.current = !1, R.request(mr(`/drafts/${i}/${m ? "new" : String(p)}`)).catch(() => {
1939
1939
  })), !0;
1940
1940
  const c = $e.current, d = {}, g = {};
1941
1941
  for (const [y, T] of Object.entries(U.current))
1942
- y.startsWith("__") || et(T, c[y]) || m && !qe.current.has(y) && !pa.current.has(y) || (d[y] = T, g[y] = c[y]);
1942
+ y.startsWith("__") || tt(T, c[y]) || m && !qe.current.has(y) && !pa.current.has(y) || (d[y] = T, g[y] = c[y]);
1943
1943
  const u = Object.keys(d).filter((y) => !qe.current.has(y)), f = (y, T) => Object.fromEntries([...y.entries()].map(([Q, Y]) => [Q, T(Y)])), h = Yg(
1944
1944
  {
1945
1945
  key: vt,
@@ -1965,7 +1965,7 @@ function mm({
1965
1965
  (y, T) => ht.current.get(`${y}:${T}`)
1966
1966
  ),
1967
1967
  pending_deletes: f(We, (y) => [...y]),
1968
- m2m_links: f(Ge, (y) => [...y]),
1968
+ m2m_links: f(Ye, (y) => [...y]),
1969
1969
  m2m_unlinks: f(at, (y) => [...y]),
1970
1970
  ...m ? { prefill_sig: Sd } : {}
1971
1971
  },
@@ -1991,7 +1991,7 @@ function mm({
1991
1991
  const t = setTimeout(() => void e(), 800);
1992
1992
  return () => clearTimeout(t);
1993
1993
  }, [
1994
- en.state,
1994
+ nn.state,
1995
1995
  As,
1996
1996
  vt,
1997
1997
  Ue,
@@ -1999,7 +1999,7 @@ function mm({
1999
1999
  je,
2000
2000
  ze,
2001
2001
  We,
2002
- Ge,
2002
+ Ye,
2003
2003
  at,
2004
2004
  m,
2005
2005
  p,
@@ -2064,8 +2064,8 @@ function mm({
2064
2064
  }), Jr({ state: "none" });
2065
2065
  }, [vt, Le, R, i, m, p]);
2066
2066
  z(() => {
2067
- en.state !== "offer" || en.createdId != null || !Ue || qe.current.size === 0 || (Jr({ state: "none" }), _e("Your newer changes replace the older draft"));
2068
- }, [en, Ue]), z(() => {
2067
+ nn.state !== "offer" || nn.createdId != null || !Ue || qe.current.size === 0 || (Jr({ state: "none" }), _e("Your newer changes replace the older draft"));
2068
+ }, [nn, Ue]), z(() => {
2069
2069
  var r;
2070
2070
  if (!m || w === void 0 || va.current) return;
2071
2071
  const e = (r = w == null ? void 0 : w.layout) == null ? void 0 : r.default_values;
@@ -2101,9 +2101,9 @@ function mm({
2101
2101
  }, [m, w, D, yr, i, xe]);
2102
2102
  const Kd = $(!1);
2103
2103
  z(() => {
2104
- if (!m || !Mt || Kd.current || !yr) return;
2104
+ if (!m || !Kt || Kd.current || !yr) return;
2105
2105
  Kd.current = !0;
2106
- const e = Kv(Mt, D, i);
2106
+ const e = Kv(Kt, D, i);
2107
2107
  if (e.length === 0) return;
2108
2108
  Ot.current += 1;
2109
2109
  try {
@@ -2114,7 +2114,7 @@ function mm({
2114
2114
  }
2115
2115
  const t = new Set(e.map((r) => r.field)), n = (r) => Object.fromEntries(Object.entries(r).filter(([s]) => !t.has(s)));
2116
2116
  U.current = n(U.current), pt((r) => n(r));
2117
- }, [m, Mt, D, yr, i, xe]);
2117
+ }, [m, Kt, D, yr, i, xe]);
2118
2118
  const $a = A(
2119
2119
  () => (j ?? []).filter(
2120
2120
  (e) => e.interface === "relation-path" && e.field.includes(".") && !Ns.fields.has(e.field)
@@ -2127,7 +2127,7 @@ function mm({
2127
2127
  paths: $a.join(",")
2128
2128
  })
2129
2129
  ).then((e) => e.data ?? {}),
2130
- enabled: !m && Bt && $a.length > 0,
2130
+ enabled: !m && zt && $a.length > 0,
2131
2131
  staleTime: 3e4
2132
2132
  }), wp = A(() => {
2133
2133
  if (!ss) return null;
@@ -2164,7 +2164,7 @@ function mm({
2164
2164
  fields: `id,${e.junctionField}`
2165
2165
  })
2166
2166
  ).then((t) => t.data ?? []),
2167
- enabled: !!p && !m && Bt,
2167
+ enabled: !!p && !m && zt,
2168
2168
  staleTime: 3e4
2169
2169
  }))
2170
2170
  }), Qe = A(() => {
@@ -2176,11 +2176,11 @@ function mm({
2176
2176
  (s == null ? void 0 : s.isSuccess) ?? !1,
2177
2177
  s == null ? void 0 : s.data,
2178
2178
  n.junctionField,
2179
- Ge.get(n.stagingKey),
2179
+ Ye.get(n.stagingKey),
2180
2180
  at.get(n.stagingKey)
2181
2181
  );
2182
2182
  }), e;
2183
- }, [ie, Dd, Ge, at, p, m]), sr = $(Qe);
2183
+ }, [ie, Dd, Ye, at, p, m]), sr = $(Qe);
2184
2184
  sr.current = Qe;
2185
2185
  const Bd = $(/* @__PURE__ */ new Map()), zd = $(/* @__PURE__ */ new Map()), Wd = () => Object.fromEntries(
2186
2186
  Object.entries(sr.current ?? {}).map(([e, t]) => [
@@ -2253,14 +2253,14 @@ function mm({
2253
2253
  (e) => {
2254
2254
  const t = Ms.current.get(e);
2255
2255
  if (!t) return [];
2256
- tn.current += 1;
2256
+ rn.current += 1;
2257
2257
  try {
2258
2258
  for (const n of t) {
2259
2259
  for (const r of n.ids) xe.unstageLink(n.stagingKey, r);
2260
2260
  Fn.current.get(n.parent) === e && Fn.current.delete(n.parent);
2261
2261
  }
2262
2262
  } finally {
2263
- tn.current -= 1;
2263
+ rn.current -= 1;
2264
2264
  }
2265
2265
  return Ms.current.delete(e), t.map((n) => ({ parent: n.parent, ids: n.ids.map(String) }));
2266
2266
  },
@@ -2388,12 +2388,12 @@ function mm({
2388
2388
  G = Re;
2389
2389
  }
2390
2390
  const fe = [];
2391
- tn.current += 1;
2391
+ rn.current += 1;
2392
2392
  try {
2393
2393
  for (const Re of G)
2394
2394
  V.has(Re) || (xe.stageLink(E.stagingKey, Re), fe.push(Re));
2395
2395
  } finally {
2396
- tn.current -= 1;
2396
+ rn.current -= 1;
2397
2397
  }
2398
2398
  oo(o, K, E.stagingKey, fe);
2399
2399
  for (const Re of G)
@@ -2468,29 +2468,29 @@ function mm({
2468
2468
  fields: `id,${E.junction_field}`
2469
2469
  })
2470
2470
  ).then((B) => B.data ?? [])).map((B) => B[E.junction_field]).filter((B) => B != null), Z = (E, V) => {
2471
- var Ze, Hn;
2471
+ var Xe, Hn;
2472
2472
  let B = V;
2473
2473
  const re = ie.get(E);
2474
2474
  if (!re) return;
2475
2475
  const fe = new Set(
2476
- (((Ze = sr.current[E]) == null ? void 0 : Ze.ids) ?? []).map((Gt) => String(Gt))
2476
+ (((Xe = sr.current[E]) == null ? void 0 : Xe.ids) ?? []).map((Zt) => String(Zt))
2477
2477
  );
2478
2478
  if (fe.size > 0) return;
2479
- const Re = (j ?? []).find((Gt) => Gt.field === E), fn = (Hn = Un(
2479
+ const Re = (j ?? []).find((Zt) => Zt.field === E), fn = (Hn = Un(
2480
2480
  (Re == null ? void 0 : Re.options) ?? null
2481
2481
  )) == null ? void 0 : Hn.max_values;
2482
2482
  if (fn != null && B.length > fn) {
2483
- const Gt = fm(g[E], B);
2484
- if (Gt.length === 0 || Gt.length > fn) return;
2485
- B = Gt;
2483
+ const Zt = fm(g[E], B);
2484
+ if (Zt.length === 0 || Zt.length > fn) return;
2485
+ B = Zt;
2486
2486
  }
2487
2487
  const ot = [];
2488
- tn.current += 1;
2488
+ rn.current += 1;
2489
2489
  try {
2490
- for (const Gt of B)
2491
- fe.has(String(Gt)) || (xe.stageLink(re.stagingKey, Gt), ot.push(String(Gt)));
2490
+ for (const Zt of B)
2491
+ fe.has(String(Zt)) || (xe.stageLink(re.stagingKey, Zt), ot.push(String(Zt)));
2492
2492
  } finally {
2493
- tn.current -= 1;
2493
+ rn.current -= 1;
2494
2494
  }
2495
2495
  oo(e, E, re.stagingKey, ot);
2496
2496
  };
@@ -2557,10 +2557,10 @@ function mm({
2557
2557
  z(() => {
2558
2558
  if (!m || Yd.current || !xa.current || (j ?? []).length === 0 || D.length === 0) return;
2559
2559
  Yd.current = !0;
2560
- const { __links: e, ...t } = Mt ?? {};
2560
+ const { __links: e, ...t } = Kt ?? {};
2561
2561
  for (const [n, r] of Object.entries(t))
2562
2562
  r == null || r === "" || (jn(n, r), wt.current(n, r));
2563
- }, [m, j, D, Mt, jn]), xr.current = jn;
2563
+ }, [m, j, D, Kt, jn]), xr.current = jn;
2564
2564
  const Zd = ce(
2565
2565
  (e, t, n = !1) => {
2566
2566
  var c, d;
@@ -2617,7 +2617,7 @@ function mm({
2617
2617
  c[d.target_field] = !(n != null && n.fillEmptyOnly) && g === void 0 && Sp(d.target_field, e, u) ? null : u;
2618
2618
  }
2619
2619
  R.request(
2620
- on("/field-rules/evaluate", {
2620
+ ln("/field-rules/evaluate", {
2621
2621
  collection: i,
2622
2622
  trigger_field: e,
2623
2623
  trigger_value: l,
@@ -2664,17 +2664,17 @@ function mm({
2664
2664
  ec.current = !0;
2665
2665
  for (const [e, t] of Oa)
2666
2666
  Ra.current[e] = {
2667
- links: Ge.get(t.stagingKey),
2667
+ links: Ye.get(t.stagingKey),
2668
2668
  unlinks: at.get(t.stagingKey)
2669
2669
  };
2670
2670
  return;
2671
2671
  }
2672
2672
  for (const [e, t] of Oa) {
2673
- const n = Ge.get(t.stagingKey), r = at.get(t.stagingKey), s = Ra.current[e];
2673
+ const n = Ye.get(t.stagingKey), r = at.get(t.stagingKey), s = Ra.current[e];
2674
2674
  s && s.links === n && s.unlinks === r || (Ra.current[e] = { links: n, unlinks: r }, Qd(e) && Ws(e, Bs(e) ?? []));
2675
2675
  }
2676
2676
  }, [
2677
- Ge,
2677
+ Ye,
2678
2678
  at,
2679
2679
  Oa,
2680
2680
  Bs,
@@ -2689,8 +2689,8 @@ function mm({
2689
2689
  const _n = ce(
2690
2690
  (e, t) => {
2691
2691
  var o;
2692
- if (I || sa.current && !Ii.current || et(U.current[e], t)) return;
2693
- qe.current.add(e), tn.current === 0 && Fn.current.delete(e), (o = An.current) == null || o.call(An), br.current.set(e, ++Fs.current);
2692
+ if (I || sa.current && !Ii.current || tt(U.current[e], t)) return;
2693
+ qe.current.add(e), rn.current === 0 && Fn.current.delete(e), (o = An.current) == null || o.call(An), br.current.set(e, ++Fs.current);
2694
2694
  const n = { ...U.current, [e]: t };
2695
2695
  for (const l of j ?? [])
2696
2696
  if (l.dependency_config)
@@ -2749,14 +2749,14 @@ function mm({
2749
2749
  },
2750
2750
  [ie]
2751
2751
  ), ja = A(() => {
2752
- const e = /* @__PURE__ */ new Set(), { __links: t, ...n } = Mt ?? {};
2752
+ const e = /* @__PURE__ */ new Set(), { __links: t, ...n } = Kt ?? {};
2753
2753
  for (const r of Object.keys(n)) e.add(r);
2754
2754
  for (const r of Object.keys(t ?? {})) e.add(r);
2755
2755
  for (const r of Object.keys(Kn ?? {})) e.add(r);
2756
- for (const r of Object.keys((Lt == null ? void 0 : Lt.values) ?? {})) e.add(r);
2757
- for (const r of Object.keys((Lt == null ? void 0 : Lt.m2m) ?? {})) e.add(r);
2756
+ for (const r of Object.keys((Mt == null ? void 0 : Mt.values) ?? {})) e.add(r);
2757
+ for (const r of Object.keys((Mt == null ? void 0 : Mt.m2m) ?? {})) e.add(r);
2758
2758
  return e;
2759
- }, [Mt, Kn, Lt]), rc = ce(
2759
+ }, [Kt, Kn, Mt]), rc = ce(
2760
2760
  (e) => {
2761
2761
  var n;
2762
2762
  if (ja.has(e)) return !0;
@@ -2803,13 +2803,13 @@ function mm({
2803
2803
  return;
2804
2804
  }
2805
2805
  const s = (u) => Array.isArray(u) ? u : Cl(u) ? [] : [u], o = s(t), l = new Set(o.map(String)), c = s(n).map(String).filter((u) => !l.has(u)), d = (lo.current.get(e) ?? ((g = sr.current[e]) == null ? void 0 : g.ids) ?? []).map(String);
2806
- tn.current += 1;
2806
+ rn.current += 1;
2807
2807
  try {
2808
2808
  for (const u of c) xe.unstageLink(r.stagingKey, u);
2809
2809
  for (const u of o)
2810
2810
  d.includes(String(u)) || xe.stageLink(r.stagingKey, u);
2811
2811
  } finally {
2812
- tn.current -= 1;
2812
+ rn.current -= 1;
2813
2813
  }
2814
2814
  lo.current.set(e, [
2815
2815
  .../* @__PURE__ */ new Set([...d.filter((u) => !c.includes(u)), ...l])
@@ -2828,7 +2828,7 @@ function mm({
2828
2828
  revalidate: sc.revalidate,
2829
2829
  disabled: I || tp,
2830
2830
  enabled: !I && nc.size > 0,
2831
- ready: m && !I && w !== void 0 && Ri && yr && en.state === "none" && As === vt && // The draft check ran for the real person (the auth id can arrive a render late; the
2831
+ ready: m && !I && w !== void 0 && Ri && yr && nn.state === "none" && As === vt && // The draft check ran for the real person (the auth id can arrive a render late; the
2832
2832
  // anonymous key's check never saw their server draft).
2833
2833
  !!Le,
2834
2834
  resetKey: `${i}:${p}`,
@@ -2899,7 +2899,7 @@ function mm({
2899
2899
  ).then((t) => t.data ?? []),
2900
2900
  select: (t) => t.length,
2901
2901
  // A grid only in a section that loads when opened waits for it (#2713).
2902
- enabled: !!p && !m && Bt && !Ns.fields.has(e.one_field),
2902
+ enabled: !!p && !m && zt && !Ns.fields.has(e.one_field),
2903
2903
  staleTime: 3e4
2904
2904
  }))
2905
2905
  }), qa = A(() => {
@@ -2925,7 +2925,7 @@ function mm({
2925
2925
  const qn = A(
2926
2926
  () => new Set(Ft.map((e) => e.one_field)),
2927
2927
  [Ft]
2928
- ), Wt = A(() => {
2928
+ ), Qt = A(() => {
2929
2929
  var t, n;
2930
2930
  const e = {};
2931
2931
  for (const r of Ft) {
@@ -2942,17 +2942,17 @@ function mm({
2942
2942
  return e;
2943
2943
  }, [Ft, qa, je, We, m]);
2944
2944
  z(() => {
2945
- Object.keys(tt).some(
2946
- (e) => qn.has(e) && (Wt[e] ?? 0) > 0
2945
+ Object.keys(nt).some(
2946
+ (e) => qn.has(e) && (Qt[e] ?? 0) > 0
2947
2947
  ) && hn((e) => {
2948
2948
  let t = !1;
2949
2949
  const n = { ...e };
2950
2950
  for (const r of Object.keys(e))
2951
- qn.has(r) && (Wt[r] ?? 0) > 0 && (delete n[r], t = !0);
2951
+ qn.has(r) && (Qt[r] ?? 0) > 0 && (delete n[r], t = !0);
2952
2952
  return t ? n : e;
2953
2953
  });
2954
- }, [Wt, qn]), z(() => {
2955
- dm(tt, M) !== tt && hn((e) => dm(e, M));
2954
+ }, [Qt, qn]), z(() => {
2955
+ dm(nt, M) !== nt && hn((e) => dm(e, M));
2956
2956
  }, [M]);
2957
2957
  const Sr = ce(
2958
2958
  (e, t) => {
@@ -2977,7 +2977,7 @@ function mm({
2977
2977
  ).catch(() => null),
2978
2978
  staleTime: 3e4,
2979
2979
  // After the record answered (army 10): a missing record's instance read only 404s.
2980
- enabled: Op && !m && !I && Bt
2980
+ enabled: Op && !m && !I && zt
2981
2981
  }), bn = Ta == null ? void 0 : Ta.edit_lock, gt = !I && !m && (bn == null ? void 0 : bn.locked) === !0 && bn.allowed === !1 ? ((Yu = bn.message) == null ? void 0 : Yu.trim()) || "This record is in approval — you can view it but not change it." : null, Ia = A(
2982
2982
  () => new Set((bn == null ? void 0 : bn.open_fields) ?? []),
2983
2983
  [bn == null ? void 0 : bn.open_fields]
@@ -2985,12 +2985,12 @@ function mm({
2985
2985
  z(() => {
2986
2986
  const e = oc.current;
2987
2987
  oc.current = gt;
2988
- const t = zt || Es.size > 0;
2988
+ const t = Wt || Es.size > 0;
2989
2989
  e || !gt || !t || m || I || p == null || Ry(i, String(p)) || _e.warning(Oy(gt), {
2990
2990
  id: Fy(i, String(p)),
2991
2991
  duration: 3e4
2992
2992
  });
2993
- }, [gt, zt, Es.size, m, I, i, p]);
2993
+ }, [gt, Wt, Es.size, m, I, i, p]);
2994
2994
  const Qs = !I && Jl && !m && !ud && !!(x != null && x.item_locking_enabled) && Ur && !bt && (!gt || Nr), Fp = Af().active, {
2995
2995
  lockHolder: Tn,
2996
2996
  acquired: Ea,
@@ -3016,9 +3016,9 @@ function mm({
3016
3016
  active: Si && Fp,
3017
3017
  // a10-4: a clean form (saved, or edits undone) lets the lock go. A line
3018
3018
  // editor still holding a typed change is not clean (army 11 f4 L1).
3019
- dirty: zt || Es.size > 0
3020
- }), Qt = ac || !!er || !!gt && !Nr;
3021
- sa.current = Qt && !m, z(
3019
+ dirty: Wt || Es.size > 0
3020
+ }), Vt = ac || !!er || !!gt && !Nr;
3021
+ sa.current = Vt && !m, z(
3022
3022
  () => X.getQueryCache().subscribe((e) => {
3023
3023
  var s, o, l, c;
3024
3024
  if (e.type !== "updated" || e.action.type !== "success") return;
@@ -3034,24 +3034,24 @@ function mm({
3034
3034
  [X, i, p]
3035
3035
  ), An.current = Qs && !Ea && !Tn ? () => void (Pa ? dc() : zp()) : null, z(() => {
3036
3036
  var e;
3037
- zt && ((e = An.current) == null || e.call(An));
3038
- }, [zt, Qs]);
3037
+ Wt && ((e = An.current) == null || e.call(An));
3038
+ }, [Wt, Qs]);
3039
3039
  const lt = (w == null ? void 0 : w.assignments) ?? [], La = lt.some((e) => e.lock_conditions), os = !!(x != null && x.addendums_enabled) && !m, fo = !m && Uy(vr), mo = !m && Jy(vr), cc = () => R.request(se("/users/me")).then((e) => e.data ?? null), Ma = La || os || fo || td.role, { data: Oe, isError: uc } = $t({
3040
3040
  queryKey: ["current-user-me"],
3041
3041
  queryFn: cc,
3042
3042
  staleTime: 5 * 6e4,
3043
3043
  enabled: Ma
3044
3044
  }), po = R0(i, m ? null : p, {
3045
- enabled: !Be && Bt,
3045
+ enabled: !Be && zt,
3046
3046
  eager: Rt
3047
- }), ho = (Kt == null ? void 0 : Kt.stateKey) ?? null, fc = () => R.request(se(`/pipelines/instance/${i}/${p}`)).then(
3047
+ }), ho = (Dt == null ? void 0 : Dt.stateKey) ?? null, fc = () => R.request(se(`/pipelines/instance/${i}/${p}`)).then(
3048
3048
  (e) => ic(e.data)
3049
3049
  ).catch(() => null), Ka = La || os || mo || td.state, { data: mc, isError: pc } = $t({
3050
3050
  queryKey: ["pipeline-instance-lock", i, p],
3051
3051
  queryFn: fc,
3052
3052
  staleTime: 3e4,
3053
3053
  // Waits for the record to answer, like the entry prefetch below (army 10).
3054
- enabled: Ka && !m && Bt && !ho
3054
+ enabled: Ka && !m && zt && !ho
3055
3055
  }), hc = w !== void 0;
3056
3056
  z(() => {
3057
3057
  !hc || Be || yb(i, { role: Ma, state: Ka });
@@ -3064,14 +3064,14 @@ function mm({
3064
3064
  staleTime: 5 * 6e4
3065
3065
  });
3066
3066
  }, [i, p]), z(() => {
3067
- if (m || Be || !Bt) return;
3067
+ if (m || Be || !zt) return;
3068
3068
  const e = Vf(i);
3069
3069
  e != null && e.state && X.prefetchQuery({
3070
3070
  queryKey: ["pipeline-instance-lock", i, p],
3071
3071
  queryFn: fc,
3072
3072
  staleTime: 3e4
3073
3073
  });
3074
- }, [i, p, Bt]);
3074
+ }, [i, p, zt]);
3075
3075
  const ke = A(
3076
3076
  () => ho ? {
3077
3077
  instance: { current_state: "__design_state__" },
@@ -3085,9 +3085,9 @@ function mm({
3085
3085
  }, [ke]), yo = A(
3086
3086
  () => ({
3087
3087
  stateKey: go,
3088
- roleId: I ? (Dr == null ? void 0 : Dr.roleId) ?? null : nt.roleId ?? (Oe == null ? void 0 : Oe.role) ?? null
3088
+ roleId: I ? (Dr == null ? void 0 : Dr.roleId) ?? null : rt.roleId ?? (Oe == null ? void 0 : Oe.role) ?? null
3089
3089
  }),
3090
- [go, I, Dr == null ? void 0 : Dr.roleId, nt.roleId, Oe == null ? void 0 : Oe.role]
3090
+ [go, I, Dr == null ? void 0 : Dr.roleId, rt.roleId, Oe == null ? void 0 : Oe.role]
3091
3091
  ), _o = A(() => {
3092
3092
  var e, t, n;
3093
3093
  if (!os) return !1;
@@ -3118,21 +3118,21 @@ function mm({
3118
3118
  x == null ? void 0 : x.addendum_allowed_states,
3119
3119
  Oe == null ? void 0 : Oe.role,
3120
3120
  ke
3121
- ]), { data: Vt = [] } = $t({
3121
+ ]), { data: Ht = [] } = $t({
3122
3122
  queryKey: ["addendums", i, p],
3123
3123
  queryFn: () => R.request(se(`/addendums/${i}/${p}`)).then((e) => e.data ?? []),
3124
- enabled: os && Bt,
3124
+ enabled: os && zt,
3125
3125
  staleTime: 3e4
3126
3126
  }), Wp = A(() => {
3127
3127
  const e = {};
3128
- for (const t of Vt)
3128
+ for (const t of Ht)
3129
3129
  if (!["approved", "rejected"].includes(t.status))
3130
3130
  for (const n of t.fields_schema ?? [])
3131
3131
  e[n] || (e[n] = []), e[n].push({ id: t.id, title: t.title, status: t.status });
3132
3132
  return e;
3133
- }, [Vt]), Da = A(
3134
- () => Vt.filter((e) => !["approved", "rejected"].includes(e.status)),
3135
- [Vt]
3133
+ }, [Ht]), Da = A(
3134
+ () => Ht.filter((e) => !["approved", "rejected"].includes(e.status)),
3135
+ [Ht]
3136
3136
  ), gc = $(!1);
3137
3137
  z(() => {
3138
3138
  var e;
@@ -3140,9 +3140,9 @@ function mm({
3140
3140
  }, [w, Da]);
3141
3141
  const as = A(() => {
3142
3142
  if (He === "original") return null;
3143
- const e = Vt.find((t) => t.id === He);
3143
+ const e = Ht.find((t) => t.id === He);
3144
3144
  return e != null && e.data ? Object.fromEntries(Object.entries(e.data).filter(([, t]) => !Array.isArray(t))) : null;
3145
- }, [He, Vt]), [ls, yc] = P(/* @__PURE__ */ new Map()), Vs = A(() => {
3145
+ }, [He, Ht]), [ls, yc] = P(/* @__PURE__ */ new Map()), Vs = A(() => {
3146
3146
  const e = /* @__PURE__ */ new Map();
3147
3147
  for (const t of j ?? [])
3148
3148
  if (!(t.computed_type !== "rollup" || !t.computed_formula))
@@ -3193,7 +3193,7 @@ function mm({
3193
3193
  ), cs = A(() => {
3194
3194
  const e = [];
3195
3195
  if (He !== "original") {
3196
- const t = Vt.find((n) => n.id === He);
3196
+ const t = Ht.find((n) => n.id === He);
3197
3197
  for (const [n, r] of Object.entries((t == null ? void 0 : t.data) ?? {})) {
3198
3198
  if (!Array.isArray(r)) continue;
3199
3199
  const s = (D ?? []).find(
@@ -3222,7 +3222,7 @@ function mm({
3222
3222
  ls,
3223
3223
  je,
3224
3224
  He,
3225
- Vt,
3225
+ Ht,
3226
3226
  D,
3227
3227
  i
3228
3228
  ]), kc = A(
@@ -3277,10 +3277,10 @@ function mm({
3277
3277
  }, []);
3278
3278
  Nc.current = (e) => $c(e);
3279
3279
  function $c(e) {
3280
- if (m || !et(U.current[e], $e.current[e])) return !0;
3280
+ if (m || !tt(U.current[e], $e.current[e])) return !0;
3281
3281
  const t = (j ?? []).find((n) => n.field === e);
3282
3282
  return Bf((t == null ? void 0 : t.dependency_config) ?? null).some(
3283
- (n) => !!n.parent_field && qe.current.has(n.parent_field) && !et(U.current[n.parent_field], $e.current[n.parent_field])
3283
+ (n) => !!n.parent_field && qe.current.has(n.parent_field) && !tt(U.current[n.parent_field], $e.current[n.parent_field])
3284
3284
  );
3285
3285
  }
3286
3286
  const Cc = A(() => {
@@ -3299,15 +3299,15 @@ function mm({
3299
3299
  }, [j, ls, xc, kc, M]), Wn = A(
3300
3300
  () => as ? { ...M, ...as } : M,
3301
3301
  [M, as]
3302
- ), st = He !== "original", dn = st ? "nivaro_addendums" : i, cn = st ? He : p, Gp = A(
3303
- () => st ? de ?? null : de ? { ...de, ...M } : M,
3304
- [st, de, M]
3302
+ ), Je = He !== "original", It = Je ? "nivaro_addendums" : i, Ut = Je ? He : p, Gp = A(
3303
+ () => Je ? de ?? null : de ? { ...de, ...M } : M,
3304
+ [Je, de, M]
3305
3305
  ), Yp = rb(
3306
3306
  i,
3307
3307
  m || I ? null : String(p),
3308
3308
  Gp,
3309
3309
  { fieldsLocked: !!gt && !Nr, valuesPending: !de }
3310
- ), [Zp, Rc] = P(null), ir = Vt.find((e) => e.id === He), Wa = !!ir && (["approved", "reverted"].includes(ir.status) || !Object.values(ir.data ?? {}).some((e) => Array.isArray(e) && e.length > 0)), { data: Qa } = $t({
3310
+ ), [Zp, Rc] = P(null), ir = Ht.find((e) => e.id === He), Wa = !!ir && (["approved", "reverted"].includes(ir.status) || !Object.values(ir.data ?? {}).some((e) => Array.isArray(e) && e.length > 0)), { data: Qa } = $t({
3311
3311
  queryKey: ["addendum-lines", He],
3312
3312
  queryFn: () => R.request(se(`/addendums/${He}/lines`)).then((e) => e.data ?? {}),
3313
3313
  enabled: Wa,
@@ -3325,7 +3325,7 @@ function mm({
3325
3325
  baseRows: n.before
3326
3326
  }
3327
3327
  ];
3328
- for (const t of Vt)
3328
+ for (const t of Ht)
3329
3329
  if (!["approved", "rejected", "reverted"].includes(t.status))
3330
3330
  for (const [n, r] of Object.entries(t.data ?? {}))
3331
3331
  !Array.isArray(r) || r.length === 0 || (e[n] || (e[n] = []), e[n].push({
@@ -3335,7 +3335,7 @@ function mm({
3335
3335
  rows: r
3336
3336
  }));
3337
3337
  return e;
3338
- }, [Vt, Wa, ir, Qa]), Va = A(() => !Bn || !w ? null : new Set(lt.map((e) => e.field)), [Bn, w, lt]), eh = A(
3338
+ }, [Ht, Wa, ir, Qa]), Va = A(() => !Bn || !w ? null : new Set(lt.map((e) => e.field)), [Bn, w, lt]), eh = A(
3339
3339
  () => (j ?? []).filter(
3340
3340
  (e) => !e.hidden && !e.field.startsWith("__") && !e.field.includes(".") && !D.some((t) => t.one_collection === i && t.one_field === e.field)
3341
3341
  ).map((e) => e.field).slice(0, 40),
@@ -3343,11 +3343,11 @@ function mm({
3343
3343
  ), Se = A(() => {
3344
3344
  if (!j) return [];
3345
3345
  if (Bn && w === void 0) return [];
3346
- const e = [...j].sort((s, o) => (s.sort ?? 0) - (o.sort ?? 0)), t = /* @__PURE__ */ new Set(), n = e.filter((s) => t.has(s.field) ? !1 : (t.add(s.field), !0)), r = nt.active ? n.filter((s) => !nt.hidden.has(s.field)) : n;
3346
+ const e = [...j].sort((s, o) => (s.sort ?? 0) - (o.sort ?? 0)), t = /* @__PURE__ */ new Set(), n = e.filter((s) => t.has(s.field) ? !1 : (t.add(s.field), !0)), r = rt.active ? n.filter((s) => !rt.hidden.has(s.field)) : n;
3347
3347
  return Va ? r.filter(
3348
- (s) => Va.has(s.field) || Xt.has(s.field) || Tr(s.field)
3348
+ (s) => Va.has(s.field) || tn.has(s.field) || Tr(s.field)
3349
3349
  ) : r;
3350
- }, [j, Va, Bn, w, nt.active, nt.hidden]), Ce = A(() => {
3350
+ }, [j, Va, Bn, w, rt.active, rt.hidden]), Ce = A(() => {
3351
3351
  const e = (w == null ? void 0 : w.groups) ?? [];
3352
3352
  return (I ? e : e.map((n) => ky(n, hm()))).sort((n, r) => n.sort - r.sort);
3353
3353
  }, [w, I]), $r = A(() => {
@@ -3392,7 +3392,7 @@ function mm({
3392
3392
  limit: 500
3393
3393
  })
3394
3394
  ).then((t) => t.data ?? []),
3395
- enabled: !!p && !m && Bt,
3395
+ enabled: !!p && !m && zt,
3396
3396
  staleTime: 3e4
3397
3397
  }))
3398
3398
  }), th = A(() => {
@@ -3458,14 +3458,14 @@ function mm({
3458
3458
  for (const n of e)
3459
3459
  !n.group_key || Tr(n.field) || (t[n.group_key] || (t[n.group_key] = []), t[n.group_key].find((r) => r.field === n.field) || t[n.group_key].push(n));
3460
3460
  return t;
3461
- }, [j]), Ht = A(
3461
+ }, [j]), Jt = A(
3462
3462
  () => Se.filter(
3463
- (e) => !e.group_key && !e.hidden && !Xt.has(e.field) && !Tr(e.field) && (Dt === null || e.layout_assigned !== !1)
3463
+ (e) => !e.group_key && !e.hidden && !tn.has(e.field) && !Tr(e.field) && (Bt === null || e.layout_assigned !== !1)
3464
3464
  ),
3465
- [Se, Dt]
3465
+ [Se, Bt]
3466
3466
  );
3467
3467
  A(
3468
- () => Se.filter((e) => Xt.has(e.field) || e.readonly),
3468
+ () => Se.filter((e) => tn.has(e.field) || e.readonly),
3469
3469
  [Se]
3470
3470
  );
3471
3471
  const wo = A(() => Ce.filter((e) => e.type === "container"), [Ce]), Cr = ce(
@@ -3495,7 +3495,7 @@ function mm({
3495
3495
  ), qc = A(
3496
3496
  () => Ce.filter((e) => e.type === "tab").sort((e, t) => e.sort - t.sort),
3497
3497
  [Ce]
3498
- ), Ut = A(
3498
+ ), Gt = A(
3499
3499
  () => Ce.filter((e) => e.type === "section" || e.type === "metadata"),
3500
3500
  [Ce]
3501
3501
  ), Tc = wo.length > 0, kt = jt.length > 0, ee = w == null ? void 0 : w.layout, Or = ee ? !!ee.ai_enabled : !0, Ha = A(() => {
@@ -3578,10 +3578,10 @@ function mm({
3578
3578
  }
3579
3579
  if (ko && !Ga.current) {
3580
3580
  Ga.current = !0;
3581
- const e = Ut.find((t) => !t.is_collapsed) ?? Ut[0];
3581
+ const e = Gt.find((t) => !t.is_collapsed) ?? Gt[0];
3582
3582
  e && Lc(e.id);
3583
3583
  }
3584
- }, [ko, Ut]);
3584
+ }, [ko, Gt]);
3585
3585
  const Dc = $(null), xo = (e) => {
3586
3586
  const t = document.querySelector(`[data-field="${e}"]`);
3587
3587
  t && (t.scrollIntoView({ behavior: "smooth", block: "center" }), t.style.transition = "box-shadow 0.15s ease", t.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)", t.style.borderRadius = "12px", setTimeout(() => {
@@ -3805,7 +3805,7 @@ ${r.join(`
3805
3805
  collection: i,
3806
3806
  itemId: p,
3807
3807
  // After the record answered (army 10: the comments read 404'd for a missing record).
3808
- enabled: !m && !I && ar && Bt,
3808
+ enabled: !m && !I && ar && zt,
3809
3809
  labelOf: gh,
3810
3810
  jump: yh
3811
3811
  }), Uc = $(Za);
@@ -3920,7 +3920,7 @@ ${r.join(`
3920
3920
  const r = n.get(e.id) ?? /* @__PURE__ */ new Set();
3921
3921
  return r.has(t) ? n : new Map(n).set(e.id, /* @__PURE__ */ new Set([...r, t]));
3922
3922
  });
3923
- }, [Ye, Gc] = P(() => {
3923
+ }, [Ze, Gc] = P(() => {
3924
3924
  var e;
3925
3925
  try {
3926
3926
  return localStorage.getItem(`nvr_tab_${i}`) ?? ((e = jt[0]) == null ? void 0 : e.key) ?? "__general__";
@@ -3942,14 +3942,14 @@ ${r.join(`
3942
3942
  const e = Xc.current;
3943
3943
  if (!e) return;
3944
3944
  const t = () => {
3945
- const r = e.querySelector(`[data-tab-key="${CSS.escape(Ye)}"]`);
3945
+ const r = e.querySelector(`[data-tab-key="${CSS.escape(Ze)}"]`);
3946
3946
  if (!r) return eu(null);
3947
3947
  eu({ left: r.offsetLeft, width: r.offsetWidth });
3948
3948
  };
3949
3949
  t();
3950
3950
  const n = typeof ResizeObserver < "u" ? new ResizeObserver(t) : null;
3951
3951
  return n == null || n.observe(e), () => n == null ? void 0 : n.disconnect();
3952
- }, [Ye]);
3952
+ }, [Ze]);
3953
3953
  const At = (e) => {
3954
3954
  if (Gc(e), Zc((t) => {
3955
3955
  if (t.has(e)) return t;
@@ -3973,15 +3973,15 @@ ${r.join(`
3973
3973
  l_({
3974
3974
  collection: i,
3975
3975
  itemId: m || I || !Pr ? null : String(p),
3976
- step: kt ? Ye : null,
3976
+ step: kt ? Ze : null,
3977
3977
  setStep: At
3978
3978
  });
3979
3979
  const No = Rb({
3980
3980
  enabled: !I,
3981
- layoutId: Dt != null ? Number(Dt) : null,
3981
+ layoutId: Bt != null ? Number(Bt) : null,
3982
3982
  collection: i,
3983
3983
  itemId: m ? null : String(p),
3984
- step: kt ? Ye : "__form__"
3984
+ step: kt ? Ze : "__form__"
3985
3985
  });
3986
3986
  function nl() {
3987
3987
  const e = Dc.current;
@@ -3990,10 +3990,10 @@ ${r.join(`
3990
3990
  const we = A(() => {
3991
3991
  if (!kt) return [];
3992
3992
  const e = [];
3993
- (un ? Ht.length > 0 : Ut.length > 0) && e.push({ key: "__general__", label: "General" });
3993
+ (un ? Jt.length > 0 : Gt.length > 0) && e.push({ key: "__general__", label: "General" });
3994
3994
  for (const t of jt) e.push({ key: t.key, label: t.label });
3995
3995
  return e;
3996
- }, [kt, Ut, jt, un, Ht]), tu = (e) => {
3996
+ }, [kt, Gt, jt, un, Jt]), tu = (e) => {
3997
3997
  if (e === null || e === "__ungrouped__") {
3998
3998
  un && we.some((n) => n.key === "__general__") && At("__general__");
3999
3999
  return;
@@ -4003,7 +4003,7 @@ ${r.join(`
4003
4003
  if (t.type === "tab" && t.container_id != null) {
4004
4004
  const n = Ce.find((r) => r.id === t.container_id);
4005
4005
  n && Ar(n, e);
4006
- } else t.type === "tab" && we.some((n) => n.key === e) ? Ye !== e && At(e) : (t.type === "section" || t.type === "metadata") && !un && we.some((n) => n.key === "__general__") && Ye !== "__general__" && At("__general__");
4006
+ } else t.type === "tab" && we.some((n) => n.key === e) ? Ze !== e && At(e) : (t.type === "section" || t.type === "metadata") && !un && we.some((n) => n.key === "__general__") && Ze !== "__general__" && At("__general__");
4007
4007
  }, nu = $(tu);
4008
4008
  nu.current = tu;
4009
4009
  const Ys = (Be == null ? void 0 : Be.reveal) ?? null;
@@ -4022,7 +4022,7 @@ ${r.join(`
4022
4022
  for (const s of Se) e.has(s.field) || e.set(s.field, t++);
4023
4023
  return e;
4024
4024
  }, [Se, Te, kt, we]), kh = (e, t) => (Zs.get(e) ?? 1e9) - (Zs.get(t) ?? 1e9), ru = A(() => {
4025
- const e = Object.keys(tt);
4025
+ const e = Object.keys(nt);
4026
4026
  if (e.length === 0) return [];
4027
4027
  const t = (n) => {
4028
4028
  var o;
@@ -4034,7 +4034,7 @@ ${r.join(`
4034
4034
  return s ? s.type === "tab" ? s.label ?? null : kt && we.some((l) => l.key === "__general__") ? "General" : s.label ?? null : null;
4035
4035
  };
4036
4036
  return e.sort((n, r) => (Zs.get(n) ?? 1e9) - (Zs.get(r) ?? 1e9)).map((n) => {
4037
- const r = Se.find((c) => c.field === n), s = tt[n], o = t(n);
4037
+ const r = Se.find((c) => c.field === n), s = nt[n], o = t(n);
4038
4038
  return {
4039
4039
  field: n,
4040
4040
  label: (s === cm && o && o !== "General" ? o : null) ?? ((r == null ? void 0 : r.label) || be(n)),
@@ -4042,7 +4042,7 @@ ${r.join(`
4042
4042
  location: o
4043
4043
  };
4044
4044
  });
4045
- }, [tt, Se, Te, Ce, kt, we, Zs]), su = $(!1);
4045
+ }, [nt, Se, Te, Ce, kt, we, Zs]), su = $(!1);
4046
4046
  z(() => {
4047
4047
  if (!(su.current || !kt))
4048
4048
  try {
@@ -4051,8 +4051,8 @@ ${r.join(`
4051
4051
  } catch {
4052
4052
  }
4053
4053
  }, [kt, we]), z(() => {
4054
- !kt || we.length === 0 || we.some((e) => e.key === Ye) || At(we[0].key);
4055
- }, [kt, we, Ye]);
4054
+ !kt || we.length === 0 || we.some((e) => e.key === Ze) || At(we[0].key);
4055
+ }, [kt, we, Ze]);
4056
4056
  const iu = $(!1);
4057
4057
  z(() => {
4058
4058
  var n;
@@ -4074,9 +4074,9 @@ ${r.join(`
4074
4074
  return l != null && l !== "" && l !== !1;
4075
4075
  });
4076
4076
  };
4077
- if (iu.current = !0, un && we.length > 0 && t(jt.find((r) => r.key === Ye))) {
4077
+ if (iu.current = !0, un && we.length > 0 && t(jt.find((r) => r.key === Ze))) {
4078
4078
  const r = we.find((s) => !t(jt.find((o) => o.key === s.key)));
4079
- r && r.key !== Ye && At(r.key);
4079
+ r && r.key !== Ze && At(r.key);
4080
4080
  }
4081
4081
  for (const r of Ce.filter((s) => s.type === "container" && Ua(s))) {
4082
4082
  const s = Ce.filter((d) => d.type === "tab" && d.container_id === r.id).sort((d, g) => d.sort - g.sort);
@@ -4086,7 +4086,7 @@ ${r.join(`
4086
4086
  const c = s.find((d) => !t(d));
4087
4087
  c && c.key !== o && Jc((d) => new Map(d).set(r.id, c.key));
4088
4088
  }
4089
- }, [m, un, de, we, jt, Ye, Ce, el]);
4089
+ }, [m, un, de, we, jt, Ze, Ce, el]);
4090
4090
  const xh = A(() => {
4091
4091
  const e = /* @__PURE__ */ new Set();
4092
4092
  if (!Ue) return e;
@@ -4097,13 +4097,13 @@ ${r.join(`
4097
4097
  const e = /* @__PURE__ */ new Set();
4098
4098
  for (const t of we) {
4099
4099
  if (m && !Yc.has(t.key)) continue;
4100
- (t.key === "__general__" ? un ? Ht : [...Ht, ...Ut.flatMap((s) => Te[s.key] ?? [])] : Te[t.key] ?? []).filter((s) => s.required && !s.hidden).every((s) => {
4100
+ (t.key === "__general__" ? un ? Jt : [...Jt, ...Gt.flatMap((s) => Te[s.key] ?? [])] : Te[t.key] ?? []).filter((s) => s.required && !s.hidden).every((s) => {
4101
4101
  if (ie.has(s.field)) {
4102
4102
  const l = Qe[s.field];
4103
4103
  return !l || l.ids.length > 0;
4104
4104
  }
4105
4105
  if (qn.has(s.field)) {
4106
- const l = Wt[s.field];
4106
+ const l = Qt[s.field];
4107
4107
  return l === void 0 || l > 0;
4108
4108
  }
4109
4109
  const o = M[s.field];
@@ -4113,8 +4113,8 @@ ${r.join(`
4113
4113
  return e;
4114
4114
  }, [
4115
4115
  we,
4116
- Ht,
4117
- Ut,
4116
+ Jt,
4117
+ Gt,
4118
4118
  Te,
4119
4119
  M,
4120
4120
  m,
@@ -4123,11 +4123,11 @@ ${r.join(`
4123
4123
  ie,
4124
4124
  Qe,
4125
4125
  qn,
4126
- Wt
4126
+ Qt
4127
4127
  ]);
4128
4128
  function Nh() {
4129
4129
  if (rh) {
4130
- const t = Ye === "__general__" ? un ? Ht : [...Ht, ...Ut.flatMap((r) => Te[r.key] ?? [])] : Te[Ye] ?? [], n = {};
4130
+ const t = Ze === "__general__" ? un ? Jt : [...Jt, ...Gt.flatMap((r) => Te[r.key] ?? [])] : Te[Ze] ?? [], n = {};
4131
4131
  for (const r of t)
4132
4132
  if (r.required && !r.hidden) {
4133
4133
  const s = M[r.field];
@@ -4138,7 +4138,7 @@ ${r.join(`
4138
4138
  return;
4139
4139
  }
4140
4140
  }
4141
- const e = we.findIndex((t) => t.key === Ye);
4141
+ const e = we.findIndex((t) => t.key === Ze);
4142
4142
  e < we.length - 1 && At(we[e + 1].key);
4143
4143
  }
4144
4144
  const Ie = lt.find((e) => e.field === "__pipeline__"), ou = A(() => {
@@ -4148,16 +4148,16 @@ ${r.join(`
4148
4148
  } catch {
4149
4149
  return {};
4150
4150
  }
4151
- }, [Ie]), dt = lt.find((e) => e.field === "__comments__"), ct = lt.find((e) => e.field === "__tasks__"), nn = lt.find((e) => e.field === "__addendums__"), kn = lt.find((e) => e.field === "__referenced_by__"), xn = lt.find((e) => e.field === "__related_records__"), Xs = lt.filter(
4151
+ }, [Ie]), dt = lt.find((e) => e.field === "__comments__"), ct = lt.find((e) => e.field === "__tasks__"), sn = lt.find((e) => e.field === "__addendums__"), kn = lt.find((e) => e.field === "__referenced_by__"), xn = lt.find((e) => e.field === "__related_records__"), Xs = lt.filter(
4152
4152
  (e) => e.field.startsWith("__widget_") && e.field.endsWith("__") && e.widget_id != null
4153
- ), ut = lt.find((e) => e.field === "__owners__"), Ve = lt.find((e) => e.field === "__pdf__"), It = Ve ? (() => {
4153
+ ), ut = lt.find((e) => e.field === "__owners__"), Ve = lt.find((e) => e.field === "__pdf__"), Et = Ve ? (() => {
4154
4154
  try {
4155
4155
  return typeof Ve.overrides == "string" ? JSON.parse(Ve.overrides) : Ve.overrides ?? {};
4156
4156
  } catch {
4157
4157
  return {};
4158
4158
  }
4159
- })() : null, Pn = (It == null ? void 0 : It.attach_to_field) ?? null, au = (It == null ? void 0 : It.filename_template) ?? null, ms = (Ve == null ? void 0 : Ve.group_key) ?? null, ei = !!(ms && Ce.some((e) => e.key === ms)), $h = (It == null ? void 0 : It.source_layout_id) ?? null, $o = !!(It != null && It.auto_generate_on_save), Ch = (It == null ? void 0 : It.overwrite_generated) !== !1, lr = async (e) => {
4160
- const t = (e == null ? void 0 : e.itemId) ?? p, n = (e == null ? void 0 : e.attachField) ?? Pn, r = (e == null ? void 0 : e.sourceLayoutId) ?? $h ?? Dt;
4159
+ })() : null, Pn = (Et == null ? void 0 : Et.attach_to_field) ?? null, au = (Et == null ? void 0 : Et.filename_template) ?? null, ms = (Ve == null ? void 0 : Ve.group_key) ?? null, ei = !!(ms && Ce.some((e) => e.key === ms)), $h = (Et == null ? void 0 : Et.source_layout_id) ?? null, $o = !!(Et != null && Et.auto_generate_on_save), Ch = (Et == null ? void 0 : Et.overwrite_generated) !== !1, lr = async (e) => {
4160
+ const t = (e == null ? void 0 : e.itemId) ?? p, n = (e == null ? void 0 : e.attachField) ?? Pn, r = (e == null ? void 0 : e.sourceLayoutId) ?? $h ?? Bt;
4161
4161
  if (!(_r || !n || !r || !t)) {
4162
4162
  ad(!0);
4163
4163
  try {
@@ -4206,8 +4206,8 @@ ${r.join(`
4206
4206
  }, ps = (ut == null ? void 0 : ut.group_key) ?? null, ti = !!(ps && Ce.some((e) => e.key === ps)), Rh = () => /* @__PURE__ */ a(
4207
4207
  yv,
4208
4208
  {
4209
- collection: dn,
4210
- item: cn,
4209
+ collection: It,
4210
+ item: Ut,
4211
4211
  title: (ut == null ? void 0 : ut.label_override) ?? void 0,
4212
4212
  defaultExpanded: (ut == null ? void 0 : ut.default_expanded) ?? !1
4213
4213
  }
@@ -4280,7 +4280,7 @@ ${r.join(`
4280
4280
  queryKey: ["last-touch", i, String(p)],
4281
4281
  queryFn: () => R.request(se(`/last-touch/${i}/${encodeURIComponent(String(p))}`)).then((e) => e.data ?? null).catch(() => null),
4282
4282
  // After the record answered (army 10: it 404'd beside a missing record's read).
4283
- enabled: !m && !!p && Bt,
4283
+ enabled: !m && !!p && zt,
4284
4284
  staleTime: 6e4,
4285
4285
  // The stale-record banner rides this read — one indexed row a minute without a live
4286
4286
  // socket, paused while the tab is hidden (react-query default).
@@ -4304,7 +4304,7 @@ ${r.join(`
4304
4304
  const s = (u) => {
4305
4305
  var v;
4306
4306
  if (ie.get(u.field)) return (((v = Qe[u.field]) == null ? void 0 : v.ids) ?? []).length > 0;
4307
- if (qn.has(u.field)) return (Wt[u.field] ?? 1) > 0;
4307
+ if (qn.has(u.field)) return (Qt[u.field] ?? 1) > 0;
4308
4308
  const h = M[u.field];
4309
4309
  return h != null && h !== "" && h !== !1;
4310
4310
  }, o = n.filter(s), l = n.filter((u) => !s(u)), c = r.filter((u) => !s(u)), d = n.length ? Math.round(o.length / n.length * 100) : 100;
@@ -4327,12 +4327,12 @@ ${r.join(`
4327
4327
  Qe,
4328
4328
  w,
4329
4329
  qn,
4330
- Wt,
4330
+ Qt,
4331
4331
  ol
4332
- ]), { data: Jt } = $t({
4332
+ ]), { data: Yt } = $t({
4333
4333
  queryKey: ["provenance", i, String(p)],
4334
4334
  queryFn: () => R.request(se(`/provenance/${i}/${encodeURIComponent(String(p))}`)).then((e) => e.data).catch(() => null),
4335
- enabled: !m && !!p && Bt,
4335
+ enabled: !m && !!p && zt,
4336
4336
  staleTime: 5 * 6e4
4337
4337
  }), hs = $(null), [al, Fo] = P(null);
4338
4338
  zi.current = it ?? null, z(() => {
@@ -4357,8 +4357,8 @@ ${r.join(`
4357
4357
  const e = (t = zi.current) == null ? void 0 : t.timestamp;
4358
4358
  e && (hs.current = e), Fo(null);
4359
4359
  }, []), ii = al ? $b({
4360
- dirty: zt,
4361
- editsDiffer: Cb(qe.current, M, de, et)
4360
+ dirty: Wt,
4361
+ editsDiffer: Cb(qe.current, M, de, tt)
4362
4362
  }) : null;
4363
4363
  z(() => {
4364
4364
  ii === "auto-refresh" && gu();
@@ -4451,14 +4451,14 @@ ${r.join(`
4451
4451
  }, [Ro, Ho]);
4452
4452
  const oi = A(() => {
4453
4453
  const e = (n) => !(n && (n.is_visible === 0 || n.is_visible === !1)), t = [
4454
- ...Ut.map((n) => ({ item: n, sort: n.sort, tie: 0 })),
4454
+ ...Gt.map((n) => ({ item: n, sort: n.sort, tie: 0 })),
4455
4455
  // Container groups sit alongside section groups in the order
4456
4456
  ...wo.map((n) => ({ item: n, sort: n.sort, tie: 0 })),
4457
4457
  {
4458
4458
  item: "__ungrouped__",
4459
4459
  sort: (() => {
4460
- const n = (w == null ? void 0 : w.ungrouped_sort) ?? Ut.length;
4461
- if (sl.size > 0 && Ht.some((r) => sl.has(r.field))) {
4460
+ const n = (w == null ? void 0 : w.ungrouped_sort) ?? Gt.length;
4461
+ if (sl.size > 0 && Jt.some((r) => sl.has(r.field))) {
4462
4462
  const r = [
4463
4463
  ue && Ie ? Ie.sort : null,
4464
4464
  jr && ct ? ct.sort : null,
@@ -4473,18 +4473,18 @@ ${r.join(`
4473
4473
  tie: 1
4474
4474
  }
4475
4475
  ];
4476
- ue && Ie && e(Ie) && t.push({ item: "__pipeline__", sort: Ie.sort, tie: 2 }), jr && ct && e(ct) && t.push({ item: "__tasks__", sort: ct.sort, tie: 3 }), ar && dt && e(dt) && t.push({ item: "__comments__", sort: dt.sort, tie: 4 }), x != null && x.addendums_enabled && !m && nn && e(nn) && t.push({ item: "__addendums__", sort: nn.sort, tie: 7 }), !m && kn && e(kn) && t.push({ item: "__referenced_by__", sort: kn.sort, tie: 8 }), !m && xn && e(xn) && t.push({ item: "__related_records__", sort: xn.sort, tie: 9 }), ue && ut && e(ut) && !ti && ps !== "__header__" && t.push({ item: "__owners__", sort: ut.sort, tie: 5 }), Ve && e(Ve) && !m && !ei && t.push({ item: "__pdf__", sort: Ve.sort, tie: 6 });
4476
+ ue && Ie && e(Ie) && t.push({ item: "__pipeline__", sort: Ie.sort, tie: 2 }), jr && ct && e(ct) && t.push({ item: "__tasks__", sort: ct.sort, tie: 3 }), ar && dt && e(dt) && t.push({ item: "__comments__", sort: dt.sort, tie: 4 }), x != null && x.addendums_enabled && !m && sn && e(sn) && t.push({ item: "__addendums__", sort: sn.sort, tie: 7 }), !m && kn && e(kn) && t.push({ item: "__referenced_by__", sort: kn.sort, tie: 8 }), !m && xn && e(xn) && t.push({ item: "__related_records__", sort: xn.sort, tie: 9 }), ue && ut && e(ut) && !ti && ps !== "__header__" && t.push({ item: "__owners__", sort: ut.sort, tie: 5 }), Ve && e(Ve) && !m && !ei && t.push({ item: "__pdf__", sort: Ve.sort, tie: 6 });
4477
4477
  for (const n of lt)
4478
4478
  If(n.field) && e(n) && t.push({ item: n.field, sort: n.sort, tie: 8 });
4479
4479
  return t.sort((n, r) => n.sort - r.sort || n.tie - r.tie).map((n) => n.item);
4480
4480
  }, [
4481
- Ut,
4481
+ Gt,
4482
4482
  wo,
4483
4483
  w,
4484
4484
  Ie,
4485
4485
  dt,
4486
4486
  ct,
4487
- nn,
4487
+ sn,
4488
4488
  ut,
4489
4489
  ti,
4490
4490
  ue,
@@ -4495,14 +4495,14 @@ ${r.join(`
4495
4495
  m,
4496
4496
  sl,
4497
4497
  x == null ? void 0 : x.addendums_enabled,
4498
- Ht,
4498
+ Jt,
4499
4499
  ps,
4500
4500
  lt
4501
4501
  ]);
4502
4502
  function wu() {
4503
- const e = {}, t = (n) => !et(M[n], $e.current[n]);
4503
+ const e = {}, t = (n) => !tt(M[n], $e.current[n]);
4504
4504
  for (const n of Se)
4505
- if (!(n.hidden || n.readonly || Xt.has(n.field) || Tr(n.field)) && n.layout_assigned !== !1) {
4505
+ if (!(n.hidden || n.readonly || tn.has(n.field) || Tr(n.field)) && n.layout_assigned !== !1) {
4506
4506
  if (n.required) {
4507
4507
  if (n.field in Aa)
4508
4508
  Aa[n.field] === 0 && (e[n.field] = "This field is required");
@@ -4510,7 +4510,7 @@ ${r.join(`
4510
4510
  const r = Qe[n.field];
4511
4511
  r.known && r.ids.length === 0 && (e[n.field] = "This field is required");
4512
4512
  } else if (qn.has(n.field)) {
4513
- const r = Wt[n.field], s = Ft.find((d) => d.one_field === n.field), o = s ? `${s.many_collection}.${s.many_field}` : "", l = We.get(o), c = s ? Ki(String(s.many_collection), String(s.many_field)).filter(
4513
+ const r = Qt[n.field], s = Ft.find((d) => d.one_field === n.field), o = s ? `${s.many_collection}.${s.many_field}` : "", l = We.get(o), c = s ? Ki(String(s.many_collection), String(s.many_field)).filter(
4514
4514
  (d) => !(l != null && l.has(String(d.id)))
4515
4515
  ).length : 0;
4516
4516
  r !== void 0 && r === 0 && c === 0 && (e[n.field] = cm);
@@ -4550,7 +4550,7 @@ ${r.join(`
4550
4550
  const r = O_(n, M[n.field], n.label ?? be(n.field));
4551
4551
  r && (e[n.field] = r);
4552
4552
  }
4553
- if (!e[n.field] && k0.has(n.type) && (m || !et(M[n.field], $e.current[n.field]))) {
4553
+ if (!e[n.field] && k0.has(n.type) && (m || !tt(M[n.field], $e.current[n.field]))) {
4554
4554
  const r = x0(M[n.field], {
4555
4555
  type: n.type,
4556
4556
  label: n.label || be(n.field)
@@ -4599,7 +4599,7 @@ ${r.join(`
4599
4599
  const e = [];
4600
4600
  if (!m) {
4601
4601
  const r = Se.filter(
4602
- (s) => !Xt.has(s.field) && !s.readonly && s.field in M && !et(M[s.field], $e.current[s.field])
4602
+ (s) => !tn.has(s.field) && !s.readonly && s.field in M && !tt(M[s.field], $e.current[s.field])
4603
4603
  ).map((s) => s.field);
4604
4604
  r.length && e.push({ collection: i, changedFields: r });
4605
4605
  }
@@ -4680,7 +4680,7 @@ ${r.join(`
4680
4680
  const Mh = A(
4681
4681
  () => new Set(
4682
4682
  Se.filter(
4683
- (e) => e.required && !e.hidden && !e.readonly && !Xt.has(e.field) && !Tr(e.field) && e.layout_assigned !== !1
4683
+ (e) => e.required && !e.hidden && !e.readonly && !tn.has(e.field) && !Tr(e.field) && e.layout_assigned !== !1
4684
4684
  ).map((e) => e.field)
4685
4685
  ),
4686
4686
  [Se]
@@ -4702,7 +4702,7 @@ ${r.join(`
4702
4702
  if (m || _t.current) return null;
4703
4703
  const e = new Set(
4704
4704
  Se.filter(
4705
- (n) => !Xt.has(n.field) && n.field in M && !et(M[n.field], $e.current[n.field])
4705
+ (n) => !tn.has(n.field) && n.field in M && !tt(M[n.field], $e.current[n.field])
4706
4706
  ).map((n) => n.field)
4707
4707
  );
4708
4708
  if (!e.size) return null;
@@ -4725,7 +4725,7 @@ ${r.join(`
4725
4725
  }
4726
4726
  function jo() {
4727
4727
  if (!er) {
4728
- if (Qt && !m) {
4728
+ if (Vt && !m) {
4729
4729
  _e.info(
4730
4730
  gt ?? `${(Tn == null ? void 0 : Tn.locked_by_name) ?? "Someone else"} is editing this record — nothing was saved`
4731
4731
  );
@@ -4815,7 +4815,7 @@ ${r.join(`
4815
4815
  }, { body: n, aliases: r } = q_(U.current, e, t);
4816
4816
  if (Object.keys(r).length === 0) return [];
4817
4817
  try {
4818
- const s = await R.request(on(`/items/${i}?dry_run=1`, n));
4818
+ const s = await R.request(ln(`/items/${i}?dry_run=1`, n));
4819
4819
  return T_(e, s == null ? void 0 : s.nested, r);
4820
4820
  } catch {
4821
4821
  return [];
@@ -4874,12 +4874,12 @@ ${r.join(`
4874
4874
  }, l = Hf({
4875
4875
  collection: i,
4876
4876
  relations: D,
4877
- links: Ge,
4877
+ links: Ye,
4878
4878
  unlinks: at,
4879
4879
  payload: {},
4880
4880
  isNew: m,
4881
4881
  committed: o
4882
- }), c = [...Ge.entries()].filter(([b]) => !l.has(b)), d = [...at.entries()].filter(([b]) => !l.has(b)), g = c.some(([, b]) => b.length > 0) || d.some(([, b]) => b.size > 0), u = {}, f = m ? Nb({
4882
+ }), c = [...Ye.entries()].filter(([b]) => !l.has(b)), d = [...at.entries()].filter(([b]) => !l.has(b)), g = c.some(([, b]) => b.length > 0) || d.some(([, b]) => b.size > 0), u = {}, f = m ? Nb({
4883
4883
  collection: i,
4884
4884
  relations: D,
4885
4885
  rows: je,
@@ -4896,8 +4896,8 @@ ${r.join(`
4896
4896
  }).map(([b]) => b)
4897
4897
  )
4898
4898
  }) : /* @__PURE__ */ new Set(), h = [...je.entries()].filter(([b, O]) => O.length > 0 && !f.has(b)).map(([b]) => b), v = [...ze.entries()].filter(([, b]) => b.size > 0).map(([b]) => b), S = [...We.entries()].filter(([, b]) => b.size > 0).map(([b]) => b), y = U.current, T = m ? Se.filter(
4899
- (b) => !Xt.has(b.field) && !b.readonly && b.field in y
4900
- ).length : Se.filter((b) => Xt.has(b.field) || b.readonly || !(b.field in y) ? !1 : !et(y[b.field], $e.current[b.field])).length, Q = m ? `${T} field${T !== 1 ? "s" : ""} set` : T === 0 ? "No field changes" : `${T} field${T !== 1 ? "s" : ""} changed`;
4899
+ (b) => !tn.has(b.field) && !b.readonly && b.field in y
4900
+ ).length : Se.filter((b) => tn.has(b.field) || b.readonly || !(b.field in y) ? !1 : !tt(y[b.field], $e.current[b.field])).length, Q = m ? `${T} field${T !== 1 ? "s" : ""} set` : T === 0 ? "No field changes" : `${T} field${T !== 1 ? "s" : ""} changed`;
4901
4901
  let Y = 0, oe = 0;
4902
4902
  for (const [, b] of c) Y += b.length;
4903
4903
  for (const [, b] of d) oe += b.size;
@@ -4982,14 +4982,14 @@ ${r.join(`
4982
4982
  ve("main", { status: "running" });
4983
4983
  const K = {}, E = $e.current, V = U.current;
4984
4984
  for (const b of Se) {
4985
- if (Xt.has(b.field) || b.readonly || !(b.field in V)) continue;
4985
+ if (tn.has(b.field) || b.readonly || !(b.field in V)) continue;
4986
4986
  const O = V[b.field], J = E[b.field];
4987
- (m || !et(O, J)) && (K[b.field] = O);
4987
+ (m || !tt(O, J)) && (K[b.field] = O);
4988
4988
  }
4989
4989
  if (m) {
4990
4990
  const b = (kf = w == null ? void 0 : w.layout) == null ? void 0 : kf.default_values;
4991
4991
  for (const O of Object.keys(b ?? {})) {
4992
- if (O in K || !(O in V) || O.startsWith("__") || O.includes(".") || Xt.has(O)) continue;
4992
+ if (O in K || !(O in V) || O.startsWith("__") || O.includes(".") || tn.has(O)) continue;
4993
4993
  const J = V[O];
4994
4994
  J === void 0 || Array.isArray(J) || (j ?? []).some((me) => me.field === O) && (K[O] = J);
4995
4995
  }
@@ -4997,7 +4997,7 @@ ${r.join(`
4997
4997
  if (Object.assign(K, u), Hf({
4998
4998
  collection: i,
4999
4999
  relations: D,
5000
- links: Ge,
5000
+ links: Ye,
5001
5001
  unlinks: at,
5002
5002
  payload: K,
5003
5003
  isNew: m,
@@ -5016,7 +5016,7 @@ ${r.join(`
5016
5016
  let B;
5017
5017
  try {
5018
5018
  if (m) {
5019
- const b = await R.request(on(`/items/${i}`, K)), O = ((Sf = b == null ? void 0 : b.data) == null ? void 0 : Sf.id) ?? ((Nf = b == null ? void 0 : b.meta) == null ? void 0 : Nf.id);
5019
+ const b = await R.request(ln(`/items/${i}`, K)), O = ((Sf = b == null ? void 0 : b.data) == null ? void 0 : Sf.id) ?? ((Nf = b == null ? void 0 : b.meta) == null ? void 0 : Nf.id);
5020
5020
  if (t(b), O == null) throw new um();
5021
5021
  B = String(O);
5022
5022
  } else if (Object.keys(K).some((b) => !b.startsWith("_"))) {
@@ -5065,10 +5065,10 @@ ${r.join(`
5065
5065
  conflicts: J.conflicts,
5066
5066
  payload: K,
5067
5067
  decided: zr.current
5068
- }), Je = ae.length > 0 ? ae : J.conflicts, pe = {};
5069
- for (const Ee of Je) pe[Ee.field] = K[Ee.field];
5068
+ }), Ge = ae.length > 0 ? ae : J.conflicts, pe = {};
5069
+ for (const Ee of Ge) pe[Ee.field] = K[Ee.field];
5070
5070
  throw Qr({
5071
- conflicts: Je,
5071
+ conflicts: Ge,
5072
5072
  latest: J.latest,
5073
5073
  mine: pe,
5074
5074
  edit: El(K),
@@ -5078,7 +5078,7 @@ ${r.join(`
5078
5078
  if (!m && Ty(b) && Object.keys(K).some((ae) => !ae.startsWith("_"))) {
5079
5079
  const ae = {};
5080
5080
  for (const pe of Object.keys(K)) ae[pe] = E[pe] ?? null;
5081
- const Je = await Iy({
5081
+ const Ge = await Iy({
5082
5082
  collection: i,
5083
5083
  item: p,
5084
5084
  payload: K,
@@ -5086,10 +5086,10 @@ ${r.join(`
5086
5086
  baseRevision: typeof K._base_revision == "number" ? K._base_revision : null,
5087
5087
  changeReason: _t.current
5088
5088
  });
5089
- if (Je) {
5089
+ if (Ge) {
5090
5090
  const pe = !Rn.current;
5091
5091
  pe && (Rn.current = Ef(i, p));
5092
- for (const Ee of Object.keys(Je.payload)) Di.current.add(Ee);
5092
+ for (const Ee of Object.keys(Ge.payload)) Di.current.add(Ee);
5093
5093
  throw ve("main", {
5094
5094
  status: "error",
5095
5095
  error: "No connection — will save when you are back online"
@@ -5108,10 +5108,10 @@ ${r.join(`
5108
5108
  }), ye)
5109
5109
  No.markRefused({ [ye.field]: ye.message }), hn({ [ye.field]: ye.message }), setTimeout(() => En(ye.field), 150);
5110
5110
  else {
5111
- const ae = (te.fields ?? []).filter((Je) => ge.has(Je));
5111
+ const ae = (te.fields ?? []).filter((Ge) => ge.has(Ge));
5112
5112
  if (ae.length > 0) {
5113
- const Je = Object.fromEntries(ae.map((pe) => [pe, me]));
5114
- No.markRefused(Je), hn(Je), setTimeout(() => En(ae[0]), 150);
5113
+ const Ge = Object.fromEntries(ae.map((pe) => [pe, me]));
5114
+ No.markRefused(Ge), hn(Ge), setTimeout(() => En(ae[0]), 150);
5115
5115
  }
5116
5116
  }
5117
5117
  throw b;
@@ -5157,11 +5157,11 @@ ${r.join(`
5157
5157
  if (!ye) continue;
5158
5158
  const ae = D.find(
5159
5159
  (Ee) => Ee.many_collection === ye.many_collection && Ee.many_field === ye.junction_field && Ee.id !== ye.id
5160
- ), Je = j0(ae), pe = Je ? { [Je.field]: Je.value } : {};
5160
+ ), Ge = j0(ae), pe = Ge ? { [Ge.field]: Ge.value } : {};
5161
5161
  for (const Ee of ge)
5162
5162
  me.push(
5163
5163
  R.request(
5164
- on(`/items/${ye.many_collection}`, {
5164
+ ln(`/items/${ye.many_collection}`, {
5165
5165
  [ye.many_field]: B,
5166
5166
  [ye.junction_field]: Ee,
5167
5167
  ...pe
@@ -5177,7 +5177,7 @@ ${r.join(`
5177
5177
  const fe = m ? ya.current.trim() : "", Re = fe ? [...Zr, fe] : Zr;
5178
5178
  m && Re.length > 0 && await Promise.all(
5179
5179
  Re.map(
5180
- (b) => R.request(on("/comments", { collection: i, item: B, text: b })).catch(() => {
5180
+ (b) => R.request(ln("/comments", { collection: i, item: B, text: b })).catch(() => {
5181
5181
  })
5182
5182
  )
5183
5183
  ), to.current = /* @__PURE__ */ new Map();
@@ -5230,7 +5230,7 @@ ${r.join(`
5230
5230
  const ye = (pe, Ee) => {
5231
5231
  const yt = pe.line_number ?? pe.sort ?? null, Ke = ["item_description", "description", "name", "title", "label"].map((pn) => pe[pn]).find((pn) => typeof pn == "string" && pn.trim() !== ""), mn = `line ${yt != null && yt !== "" ? String(yt) : Ee + 1}`;
5232
5232
  return Ke ? `${mn} · ${Ke.length > 40 ? `${Ke.slice(0, 40)}…` : Ke}` : mn;
5233
- }, ae = [], Je = [];
5233
+ }, ae = [], Ge = [];
5234
5234
  try {
5235
5235
  let pe = 0;
5236
5236
  for (let yt = 0; yt < te.length; yt++) {
@@ -5239,13 +5239,13 @@ ${r.join(`
5239
5239
  detail: `Saving ${ye(Ke, yt)} (${yt + 1} of ${te.length})`
5240
5240
  }), await (async () => {
5241
5241
  var ur;
5242
- const mn = Object.entries(Ke).filter(([Xe]) => Xe.startsWith("__o2m_")), pn = Object.fromEntries(
5243
- Object.entries(Ke).filter(([Xe]) => !Xe.startsWith("__o2m_"))
5242
+ const mn = Object.entries(Ke).filter(([et]) => et.startsWith("__o2m_")), pn = Object.fromEntries(
5243
+ Object.entries(Ke).filter(([et]) => !et.startsWith("__o2m_"))
5244
5244
  );
5245
5245
  let mt = null;
5246
5246
  try {
5247
5247
  mt = await R.request(
5248
- on(`/items/${J}${s}`, {
5248
+ ln(`/items/${J}${s}`, {
5249
5249
  ...pn,
5250
5250
  [me]: B,
5251
5251
  // The record's change reason covers the lines it stages
@@ -5253,35 +5253,35 @@ ${r.join(`
5253
5253
  ..._t.current && !pn._change_reason ? { _change_reason: _t.current } : {}
5254
5254
  })
5255
5255
  );
5256
- } catch (Xe) {
5257
- const Ae = Al(Xe);
5256
+ } catch (et) {
5257
+ const Ae = Al(et);
5258
5258
  Ae ? (n = Ae, ae.push({
5259
5259
  label: ye(Ke, yt),
5260
5260
  error: "Waiting for a change reason"
5261
- })) : ae.push({ label: ye(Ke, yt), error: e(Xe) }), Je.push(Ke);
5261
+ })) : ae.push({ label: ye(Ke, yt), error: e(et) }), Ge.push(Ke);
5262
5262
  return;
5263
5263
  }
5264
- const Yt = (ur = mt == null ? void 0 : mt.data) == null ? void 0 : ur.id;
5265
- ve(O, (Xe) => {
5264
+ const Xt = (ur = mt == null ? void 0 : mt.data) == null ? void 0 : ur.id;
5265
+ ve(O, (et) => {
5266
5266
  var Ae;
5267
5267
  return {
5268
- progress: { done: (((Ae = Xe.progress) == null ? void 0 : Ae.done) ?? 0) + 1, total: te.length }
5268
+ progress: { done: (((Ae = et.progress) == null ? void 0 : Ae.done) ?? 0) + 1, total: te.length }
5269
5269
  };
5270
5270
  });
5271
- for (const [Xe, Ae] of mn) {
5272
- const Sn = Xe.slice(6), rn = D.find(
5271
+ for (const [et, Ae] of mn) {
5272
+ const Sn = et.slice(6), on = D.find(
5273
5273
  (fr) => fr.one_collection === J && fr.one_field === Sn
5274
5274
  ), Nn = Array.isArray(Ae) ? Ae : [];
5275
- if (Yt == null || !(rn != null && rn.many_collection) || !rn.many_field) {
5275
+ if (Xt == null || !(on != null && on.many_collection) || !on.many_field) {
5276
5276
  pe += Nn.length;
5277
5277
  continue;
5278
5278
  }
5279
5279
  for (const fr of Nn)
5280
5280
  try {
5281
5281
  await R.request(
5282
- on(`/items/${rn.many_collection}`, {
5282
+ ln(`/items/${on.many_collection}`, {
5283
5283
  ...fr,
5284
- [rn.many_field]: Yt
5284
+ [on.many_field]: Xt
5285
5285
  })
5286
5286
  );
5287
5287
  } catch {
@@ -5290,7 +5290,7 @@ ${r.join(`
5290
5290
  }
5291
5291
  })();
5292
5292
  }
5293
- Je.length > 0 && fn.set(b, Je);
5293
+ Ge.length > 0 && fn.set(b, Ge);
5294
5294
  const Ee = [];
5295
5295
  if (ae.length > 0) {
5296
5296
  const yt = te.length - ae.length;
@@ -5309,12 +5309,12 @@ ${r.join(`
5309
5309
  fn.set(b, te), ve(O, { status: "error", error: e(pe) }), Fe.current.linkProblems.push(e(pe)), Fe.current.childFailed = !0;
5310
5310
  }
5311
5311
  }
5312
- const Ze = new Map(ze), Hn = [];
5312
+ const Xe = new Map(ze), Hn = [];
5313
5313
  for (const b of v) {
5314
5314
  const O = `o2m:edit:${b}`, [J, me] = b.split("."), te = Ki(J, me), ge = ze.get(b) ?? /* @__PURE__ */ new Map();
5315
5315
  ve(O, { status: "running", progress: { done: 0, total: ge.size } });
5316
5316
  let ye = !1, ae = 0;
5317
- const Je = /* @__PURE__ */ new Map();
5317
+ const Ge = /* @__PURE__ */ new Map();
5318
5318
  await Promise.all(
5319
5319
  [...ge.entries()].map(async ([pe, Ee]) => {
5320
5320
  const yt = Object.entries(Ee).filter(
@@ -5332,33 +5332,33 @@ ${r.join(`
5332
5332
  mi(`/items/${J}/${pe}${s}`, zf(Ke, mt))
5333
5333
  ).then(() => {
5334
5334
  ht.current.delete(`${J}:${pe}`), Pl(R, J).forget(pe);
5335
- }).catch(async (Yt) => {
5335
+ }).catch(async (Xt) => {
5336
5336
  ye = !0, mn = !0;
5337
- const ur = Al(Yt), Xe = ur ? null : Ol(Yt);
5337
+ const ur = Al(Xt), et = ur ? null : Ol(Xt);
5338
5338
  if (ur)
5339
5339
  n = ur, ve(O, { status: "error", error: "Waiting for a change reason" });
5340
- else if (Xe) {
5340
+ else if (et) {
5341
5341
  const Ae = Ko(
5342
5342
  te,
5343
5343
  pe,
5344
5344
  null,
5345
5345
  (Nn) => pi(J, String(Nn.id))
5346
5346
  ), Sn = {};
5347
- for (const Nn of Xe.conflicts) Sn[Nn.field] = Ke[Nn.field];
5348
- const rn = {
5347
+ for (const Nn of et.conflicts) Sn[Nn.field] = Ke[Nn.field];
5348
+ const on = {
5349
5349
  key: b,
5350
5350
  rowId: pe,
5351
5351
  label: Ae,
5352
- conflicts: Xe.conflicts,
5353
- latest: Xe.latest,
5352
+ conflicts: et.conflicts,
5353
+ latest: et.latest,
5354
5354
  mine: Sn
5355
5355
  };
5356
- await xu(rn, J, pe, Ke), Hn.push(rn), ve(O, {
5356
+ await xu(on, J, pe, Ke), Hn.push(on), ve(O, {
5357
5357
  status: "error",
5358
5358
  error: `${Ae} was changed by someone else — pick which value wins`
5359
5359
  });
5360
5360
  } else {
5361
- const Ae = `${Ko(te, pe, null, (Sn) => pi(J, String(Sn.id)))}: ${e(Yt)}`;
5361
+ const Ae = `${Ko(te, pe, null, (Sn) => pi(J, String(Sn.id)))}: ${e(Xt)}`;
5362
5362
  Fe.current.childFailed = !0, Fe.current.childErrors = [
5363
5363
  ...Fe.current.childErrors ?? [],
5364
5364
  Ae
@@ -5367,45 +5367,45 @@ ${r.join(`
5367
5367
  });
5368
5368
  }
5369
5369
  if (mn) {
5370
- Je.set(pe, Ee), ve(O, (mt) => {
5371
- var Yt;
5370
+ Ge.set(pe, Ee), ve(O, (mt) => {
5371
+ var Xt;
5372
5372
  return {
5373
- progress: { done: (((Yt = mt.progress) == null ? void 0 : Yt.done) ?? 0) + 1, total: ge.size }
5373
+ progress: { done: (((Xt = mt.progress) == null ? void 0 : Xt.done) ?? 0) + 1, total: ge.size }
5374
5374
  };
5375
5375
  });
5376
5376
  return;
5377
5377
  }
5378
5378
  const pn = {};
5379
- for (const [mt, Yt] of yt) {
5380
- const ur = mt.slice(13), Xe = D.find(
5381
- (sn) => sn.one_collection === J && sn.one_field === ur
5382
- ), Ae = Yt, Sn = Ae.collection ?? (Xe == null ? void 0 : Xe.many_collection) ?? null, rn = Ae.collection ? null : (Xe == null ? void 0 : Xe.many_field) ?? null;
5383
- if (!Sn || !Ae.collection && !rn) {
5379
+ for (const [mt, Xt] of yt) {
5380
+ const ur = mt.slice(13), et = D.find(
5381
+ (an) => an.one_collection === J && an.one_field === ur
5382
+ ), Ae = Xt, Sn = Ae.collection ?? (et == null ? void 0 : et.many_collection) ?? null, on = Ae.collection ? null : (et == null ? void 0 : et.many_field) ?? null;
5383
+ if (!Sn || !Ae.collection && !on) {
5384
5384
  ae += Ae.created.length + Ae.updated.length + Ae.deleted.length, pn[mt] = Ae;
5385
5385
  continue;
5386
5386
  }
5387
5387
  const Nn = [], fr = [], Sl = [];
5388
5388
  await Promise.all(
5389
5389
  Ae.created.map(
5390
- (sn) => R.request(
5391
- on(
5390
+ (an) => R.request(
5391
+ ln(
5392
5392
  `/items/${Sn}`,
5393
- rn ? { ...sn, [rn]: pe } : sn
5393
+ on ? { ...an, [on]: pe } : an
5394
5394
  )
5395
5395
  ).catch(() => {
5396
- ae++, Nn.push(sn);
5396
+ ae++, Nn.push(an);
5397
5397
  })
5398
5398
  )
5399
5399
  ), await Promise.all(
5400
5400
  Ae.updated.map(
5401
- (sn) => R.request(mi(`/items/${Sn}/${sn.id}`, sn.changes)).catch(() => {
5402
- ae++, fr.push(sn);
5401
+ (an) => R.request(mi(`/items/${Sn}/${an.id}`, an.changes)).catch(() => {
5402
+ ae++, fr.push(an);
5403
5403
  })
5404
5404
  )
5405
5405
  ), await Promise.all(
5406
5406
  Ae.deleted.map(
5407
- (sn) => R.request(mr(`/items/${Sn}/${sn}`)).catch(() => {
5408
- ae++, Sl.push(sn);
5407
+ (an) => R.request(mr(`/items/${Sn}/${an}`)).catch(() => {
5408
+ ae++, Sl.push(an);
5409
5409
  })
5410
5410
  )
5411
5411
  ), (Nn.length || fr.length || Sl.length) && (pn[mt] = {
@@ -5415,20 +5415,20 @@ ${r.join(`
5415
5415
  ...Ae.collection ? { collection: Ae.collection } : {}
5416
5416
  });
5417
5417
  }
5418
- Object.keys(pn).length > 0 && Je.set(pe, pn), ve(O, (mt) => {
5419
- var Yt;
5418
+ Object.keys(pn).length > 0 && Ge.set(pe, pn), ve(O, (mt) => {
5419
+ var Xt;
5420
5420
  return {
5421
- progress: { done: (((Yt = mt.progress) == null ? void 0 : Yt.done) ?? 0) + 1, total: ge.size }
5421
+ progress: { done: (((Xt = mt.progress) == null ? void 0 : Xt.done) ?? 0) + 1, total: ge.size }
5422
5422
  };
5423
5423
  });
5424
5424
  })
5425
- ), Je.size > 0 ? Ze.set(b, Je) : Ze.delete(b), !ye && ae === 0 ? ve(O, { status: "done" }) : ye || (Fe.current.childFailed = !0, ve(O, {
5425
+ ), Ge.size > 0 ? Xe.set(b, Ge) : Xe.delete(b), !ye && ae === 0 ? ve(O, { status: "done" }) : ye || (Fe.current.childFailed = !0, ve(O, {
5426
5426
  status: "error",
5427
5427
  error: `${ae} nested row${ae !== 1 ? "s" : ""} failed`
5428
5428
  }));
5429
5429
  }
5430
- kr(Ze), n && (Wr(n), Fe.current.reasonWaiting = !0), Hn.length > 0 && (Fe.current.lineConflicts = Hn.length, Mi(Hn));
5431
- const Gt = new Map(We);
5430
+ kr(Xe), n && (Wr(n), Fe.current.reasonWaiting = !0), Hn.length > 0 && (Fe.current.lineConflicts = Hn.length, Mi(Hn));
5431
+ const Zt = new Map(We);
5432
5432
  for (const b of S) {
5433
5433
  const O = `o2m:del:${b}`, [J] = b.split("."), me = We.get(b) ?? /* @__PURE__ */ new Set();
5434
5434
  ve(O, { status: "running", progress: { done: 0, total: me.size } });
@@ -5449,14 +5449,14 @@ ${r.join(`
5449
5449
  };
5450
5450
  });
5451
5451
  })
5452
- ), te || (ve(O, { status: "done" }), Gt.delete(b));
5452
+ ), te || (ve(O, { status: "done" }), Zt.delete(b));
5453
5453
  }
5454
- if (no(Gt), m && yn.length > 0) {
5454
+ if (no(Zt), m && yn.length > 0) {
5455
5455
  ve("tasks", { status: "running" });
5456
5456
  const b = [];
5457
5457
  for (const O of yn)
5458
5458
  await R.request(
5459
- on("/tasks", {
5459
+ ln("/tasks", {
5460
5460
  collection: i,
5461
5461
  item: B,
5462
5462
  title: O.title,
@@ -5508,7 +5508,7 @@ ${r.join(`
5508
5508
  (v) => `${v.first_name ?? ""} ${v.last_name ?? ""}`.trim().toLowerCase() === f.toLowerCase()
5509
5509
  );
5510
5510
  h && await R.request(
5511
- on("/notifications", {
5511
+ ln("/notifications", {
5512
5512
  recipient: h.id,
5513
5513
  subject: `You were mentioned on ${i}/${e}`,
5514
5514
  message: "Mentioned in a note on this record.",
@@ -5553,7 +5553,7 @@ ${r.join(`
5553
5553
  const g = {};
5554
5554
  for (const u of d.fields) g[u] = U.current[u];
5555
5555
  R.request(
5556
- on(`/ai/extract-record/${d.id}/outcome`, { record_id: String(e), values: g })
5556
+ ln(`/ai/extract-record/${d.id}/outcome`, { record_id: String(e), values: g })
5557
5557
  ).catch(() => {
5558
5558
  });
5559
5559
  }
@@ -5618,7 +5618,7 @@ ${r.join(`
5618
5618
  return;
5619
5619
  }
5620
5620
  r > 0 ? Vh((s) => s + 1) : _e.success("Kept the newer values");
5621
- }, Uh = Af(), [To, li] = P(null), Cu = zt && Uh.active && !I && !St.isPending, Jh = Ig().navigate;
5621
+ }, Uh = Af(), [To, li] = P(null), Cu = Wt && Uh.active && !I && !St.isPending, Jh = Ig().navigate;
5622
5622
  $y(Cu, (e) => li({ go: e }), qo, Jh);
5623
5623
  const Ru = L ? () => {
5624
5624
  Cu ? li({ go: L }) : L();
@@ -5700,7 +5700,7 @@ ${r.join(`
5700
5700
  description: "Someone else saved this record after you opened it."
5701
5701
  }), !1;
5702
5702
  if (!wu()) return !1;
5703
- if (!P0({ isDirty: Ue, staged: ln })) return !0;
5703
+ if (!P0({ isDirty: Ue, staged: cn })) return !0;
5704
5704
  const e = ku();
5705
5705
  if (e)
5706
5706
  return Wr(e), !1;
@@ -5742,15 +5742,15 @@ ${r.join(`
5742
5742
  })
5743
5743
  } : {}
5744
5744
  })
5745
- }), [eg, Au] = P(!1), Nt = /* @__PURE__ */ new Set(), Et = /* @__PURE__ */ new Set();
5746
- if (Qt)
5747
- for (const e of j ?? []) Et.add(e.field);
5745
+ }), [eg, Au] = P(!1), Nt = /* @__PURE__ */ new Set(), Pt = /* @__PURE__ */ new Set();
5746
+ if (Vt)
5747
+ for (const e of j ?? []) Pt.add(e.field);
5748
5748
  if (Nr)
5749
5749
  for (const e of ty(
5750
5750
  (j ?? []).map((t) => t.field),
5751
5751
  Ia
5752
5752
  ))
5753
- Et.add(e);
5753
+ Pt.add(e);
5754
5754
  if (La) {
5755
5755
  const e = (Oe == null ? void 0 : Oe.role) ?? null, t = ((rf = ke == null ? void 0 : ke.instance) == null ? void 0 : rf.current_state) ?? null, n = t ? ((sf = ((ke == null ? void 0 : ke.states) ?? []).find((r) => r.id === t)) == null ? void 0 : sf.key) ?? null : null;
5756
5756
  for (const r of lt) {
@@ -5764,14 +5764,14 @@ ${r.join(`
5764
5764
  s.some((l) => {
5765
5765
  var c, d;
5766
5766
  return l.type === "pipeline_state" && ((c = l.state_keys) != null && c.length) ? l.state_keys.includes(n ?? "") : l.type === "role" && ((d = l.role_ids) != null && d.length) ? l.role_ids.includes(e ?? "") : !1;
5767
- }) && Et.add(r.field);
5767
+ }) && Pt.add(r.field);
5768
5768
  }
5769
5769
  }
5770
- if (nt.active) for (const e of nt.readonly) Et.add(e);
5770
+ if (rt.active) for (const e of rt.readonly) Pt.add(e);
5771
5771
  const qu = /* @__PURE__ */ new Set();
5772
5772
  if (!Rt)
5773
5773
  for (const e of j ?? [])
5774
- ((of = Un(e.options)) == null ? void 0 : of.admin_only_edit) === !0 && (qu.add(e.field), Et.add(e.field));
5774
+ ((of = Un(e.options)) == null ? void 0 : of.admin_only_edit) === !0 && (qu.add(e.field), Pt.add(e.field));
5775
5775
  const Tu = /* @__PURE__ */ new Map();
5776
5776
  {
5777
5777
  const e = Oe != null && Oe.role ? String(Oe.role).toUpperCase() : null, t = !!(Oe != null && Oe.role_admin_access);
@@ -5787,7 +5787,7 @@ ${r.join(`
5787
5787
  continue;
5788
5788
  }
5789
5789
  for (const s of lt)
5790
- s.group_key === n.key && !s.field.startsWith("__") && (Et.add(s.field), Tu.set(s.field, n.label || n.key));
5790
+ s.group_key === n.key && !s.field.startsWith("__") && (Pt.add(s.field), Tu.set(s.field, n.label || n.key));
5791
5791
  }
5792
5792
  }
5793
5793
  }
@@ -5795,7 +5795,7 @@ ${r.join(`
5795
5795
  for (const e of Ha)
5796
5796
  if (Us.has(e.key))
5797
5797
  for (const t of Te[e.key] ?? [])
5798
- Et.add(t.field), hl.has(t.field) || hl.set(t.field, `Hidden by a rule: ${e.label} shows when ${e.when}`);
5798
+ Pt.add(t.field), hl.has(t.field) || hl.set(t.field, `Hidden by a rule: ${e.label} shows when ${e.when}`);
5799
5799
  const ft = {};
5800
5800
  for (const [e, t] of Tu)
5801
5801
  ft[e] = `The "${t}" section is locked for your role`;
@@ -5803,7 +5803,7 @@ ${r.join(`
5803
5803
  {
5804
5804
  const e = ((af = ke == null ? void 0 : ke.instance) == null ? void 0 : af.current_state) ?? null, t = e ? ((ke == null ? void 0 : ke.states) ?? []).find((r) => r.id === e) ?? null : null, n = t ? ((lf = t.label) == null ? void 0 : lf.trim()) || be(t.key.replace(/_/g, " ")) : null;
5805
5805
  for (const r of lt)
5806
- if (!(!r.lock_conditions || !Et.has(r.field)))
5806
+ if (!(!r.lock_conditions || !Pt.has(r.field)))
5807
5807
  try {
5808
5808
  const s = JSON.parse(r.lock_conditions);
5809
5809
  s.some((o) => {
@@ -5815,19 +5815,19 @@ ${r.join(`
5815
5815
  for (const r of j ?? []) {
5816
5816
  const s = r.field;
5817
5817
  if (ft[s]) continue;
5818
- if (nt.active && nt.readonly.has(s)) {
5819
- ft[s] = `${((df = nt.preview) == null ? void 0 : df.role.name) ?? "This role"} cannot edit this field`;
5818
+ if (rt.active && rt.readonly.has(s)) {
5819
+ ft[s] = `${((df = rt.preview) == null ? void 0 : df.role.name) ?? "This role"} cannot edit this field`;
5820
5820
  continue;
5821
5821
  }
5822
5822
  if (gt && !Ia.has(s)) {
5823
5823
  ft[s] = gt;
5824
5824
  continue;
5825
5825
  }
5826
- if (Qt) {
5826
+ if (Vt) {
5827
5827
  ft[s] = `${(Tn == null ? void 0 : Tn.locked_by_name) ?? "Someone else"} is editing this record — read-only until the lock is released`;
5828
5828
  continue;
5829
5829
  }
5830
- if (st) {
5830
+ if (Je) {
5831
5831
  ft[s] = "Viewing an addendum — switch to the current record to edit";
5832
5832
  continue;
5833
5833
  }
@@ -5837,13 +5837,13 @@ ${r.join(`
5837
5837
  }
5838
5838
  if (!r.readonly) continue;
5839
5839
  const o = r._overrides ?? null;
5840
- r.computed_type === "rollup" ? ft[s] = "Calculated from related rows — change the rows, not this total" : r.computed_type === "write" ? ft[s] = r.computed_formula ? `Calculated: ${r.computed_formula}` : "Calculated on save from other fields" : r.interface === "relation-path" ? ft[s] = "Value from a related record — edit it there" : (o == null ? void 0 : o.readonly) === !0 ? ft[s] = "Read-only on this layout" : Xt.has(s) ? ft[s] = "Set by the system" : ft[s] = "Read-only field";
5840
+ r.computed_type === "rollup" ? ft[s] = "Calculated from related rows — change the rows, not this total" : r.computed_type === "write" ? ft[s] = r.computed_formula ? `Calculated: ${r.computed_formula}` : "Calculated on save from other fields" : r.interface === "relation-path" ? ft[s] = "Value from a related record — edit it there" : (o == null ? void 0 : o.readonly) === !0 ? ft[s] = "Read-only on this layout" : tn.has(s) ? ft[s] = "Set by the system" : ft[s] = "Read-only field";
5841
5841
  }
5842
5842
  }
5843
5843
  const tg = O0(ft, po.data), gl = qv(
5844
5844
  m,
5845
5845
  Se,
5846
- (e) => !!ft[e] || Et.has(e)
5846
+ (e) => !!ft[e] || Pt.has(e)
5847
5847
  ), Iu = {};
5848
5848
  for (const e of lt) {
5849
5849
  const t = typeof e.overrides == "string" ? Un(e.overrides) : e.overrides, n = t == null ? void 0 : t.apply_to_lines;
@@ -5851,7 +5851,7 @@ ${r.join(`
5851
5851
  const r = n.grid, s = n.target;
5852
5852
  Iu[e.field] = {
5853
5853
  label: n.label,
5854
- count: r in Wt ? Wt[r] : null,
5854
+ count: r in Qt ? Qt[r] : null,
5855
5855
  onApply: (o) => {
5856
5856
  const l = () => {
5857
5857
  const g = { collection: i, grid: r, target: s, value: o, handled: !1 };
@@ -5880,8 +5880,8 @@ ${r.join(`
5880
5880
  );
5881
5881
  return bm(r);
5882
5882
  }, di = {};
5883
- for (const e of ln.fields) di[e] = { from: $e.current[e] };
5884
- for (const [e, t] of Ge)
5883
+ for (const e of cn.fields) di[e] = { from: $e.current[e] };
5884
+ for (const [e, t] of Ye)
5885
5885
  t.length && (di[e] = { from: null, detail: `${t.length} linked` });
5886
5886
  for (const [e, t] of at)
5887
5887
  if (t.size) {
@@ -5892,7 +5892,7 @@ ${r.join(`
5892
5892
  };
5893
5893
  }
5894
5894
  const Mn = [];
5895
- for (const e of ln.fields)
5895
+ for (const e of cn.fields)
5896
5896
  Mn.push({
5897
5897
  key: `f:${e}`,
5898
5898
  kind: "field",
@@ -5913,7 +5913,7 @@ ${r.join(`
5913
5913
  kind: "row",
5914
5914
  label: _l(n),
5915
5915
  detail: `new line ${o + 1}${s.line_number != null ? ` (#${String(s.line_number)})` : ""}`,
5916
- onRevert: () => an.removeRow(n, r, o)
5916
+ onRevert: () => dn.removeRow(n, r, o)
5917
5917
  })
5918
5918
  );
5919
5919
  }
@@ -5927,7 +5927,7 @@ ${r.join(`
5927
5927
  label: _l(n),
5928
5928
  collection: n,
5929
5929
  detail: `${u}: ${g.map((f) => be(f.replace(/_/g, " "))).join(", ")}`,
5930
- onRevert: () => an.cancelPendingEdit(n, r, l),
5930
+ onRevert: () => dn.cancelPendingEdit(n, r, l),
5931
5931
  cells: g.map((f) => ({
5932
5932
  field: f,
5933
5933
  label: be(f.replace(/_/g, " ")),
@@ -5949,10 +5949,10 @@ ${r.join(`
5949
5949
  kind: "delete",
5950
5950
  label: _l(n),
5951
5951
  detail: pi(n, s) ?? "a line",
5952
- onRevert: () => an.cancelPendingDelete(n, r, s)
5952
+ onRevert: () => dn.cancelPendingDelete(n, r, s)
5953
5953
  });
5954
5954
  }
5955
- for (const [e, t] of Ge)
5955
+ for (const [e, t] of Ye)
5956
5956
  for (const n of t)
5957
5957
  Mn.push({
5958
5958
  key: `l:${e}:${String(n)}`,
@@ -5986,7 +5986,7 @@ ${r.join(`
5986
5986
  ), o = Eu.current;
5987
5987
  if (o === s) return;
5988
5988
  const l = !Zy(o, e);
5989
- if (Xy({ first: l, unsaved: zt, lineDrafts: Es.size })) return;
5989
+ if (Xy({ first: l, unsaved: Wt, lineDrafts: Es.size })) return;
5990
5990
  Eu.current = s;
5991
5991
  const c = e_(vr, {
5992
5992
  role: r,
@@ -5996,7 +5996,7 @@ ${r.join(`
5996
5996
  });
5997
5997
  l ? c === "summary" && ua(!0) : ua(c === "summary"), ep(e);
5998
5998
  }, [
5999
- zt,
5999
+ Wt,
6000
6000
  Es.size,
6001
6001
  fa,
6002
6002
  I,
@@ -6077,7 +6077,7 @@ ${r.join(`
6077
6077
  Eo,
6078
6078
  m
6079
6079
  ]
6080
- ), Pt = (e, t, n) => Jb(Be, e, t, n), bl = (e, t, n) => Pt(e, t, n), qr = (e, t) => {
6080
+ ), Lt = (e, t, n) => Jb(Be, e, t, n), bl = (e, t, n) => Lt(e, t, n), qr = (e, t) => {
6081
6081
  var n;
6082
6082
  return {
6083
6083
  kind: "slot",
@@ -6099,7 +6099,7 @@ ${r.join(`
6099
6099
  },
6100
6100
  t
6101
6101
  );
6102
- return r == null || e === "__ungrouped__" ? o : Pt(
6102
+ return r == null || e === "__ungrouped__" ? o : Lt(
6103
6103
  typeof e == "string" ? qr(e) : { kind: "group", key: e.key },
6104
6104
  o,
6105
6105
  { asChild: !0 }
@@ -6111,17 +6111,17 @@ ${r.join(`
6111
6111
  return /* @__PURE__ */ a(
6112
6112
  Bo,
6113
6113
  {
6114
- collection: dn,
6115
- item: cn,
6114
+ collection: It,
6115
+ item: Ut,
6116
6116
  title: (Ie == null ? void 0 : Ie.label_override) ?? void 0,
6117
6117
  defaultExpanded: (Ie == null ? void 0 : Ie.default_expanded) ?? !1,
6118
6118
  showApprovalChain: !!(Ie != null && Ie.show_approval_chain),
6119
6119
  hideActionsCollapsed: !!ou.hide_actions_collapsed,
6120
6120
  hideActionsExpanded: !!ou.hide_actions_expanded,
6121
6121
  onBeforeTransition: _s,
6122
- asRole: nt.roleId,
6123
- addendumPending: !st && Oi > 0 && !!(x != null && x.addendums_enabled),
6124
- addendumView: st
6122
+ asRole: rt.roleId,
6123
+ addendumPending: !Je && Oi > 0 && !!(x != null && x.addendums_enabled),
6124
+ addendumView: Je
6125
6125
  },
6126
6126
  "__pipeline__"
6127
6127
  );
@@ -6163,7 +6163,7 @@ ${r.join(`
6163
6163
  canCreate: _o,
6164
6164
  onActiveCountChange: Fi,
6165
6165
  onCreated: Co,
6166
- defaultExpanded: nn ? !!nn.default_expanded : !0
6166
+ defaultExpanded: sn ? !!sn.default_expanded : !0
6167
6167
  },
6168
6168
  "__addendums__"
6169
6169
  );
@@ -6267,9 +6267,9 @@ ${r.join(`
6267
6267
  }
6268
6268
  function Pu() {
6269
6269
  const e = $n ? Se.filter(
6270
- (t) => !t.group_key && !Xt.has(t.field) && !Tr(t.field) && (Dt === null || t.layout_assigned !== !1)
6271
- ) : Ht.filter((t) => !t.hidden);
6272
- return e.length === 0 ? null : Pt(
6270
+ (t) => !t.group_key && !tn.has(t.field) && !Tr(t.field) && (Bt === null || t.layout_assigned !== !1)
6271
+ ) : Jt.filter((t) => !t.hidden);
6272
+ return e.length === 0 ? null : Lt(
6273
6273
  { kind: "group", key: "__ungrouped__" },
6274
6274
  /* @__PURE__ */ a(
6275
6275
  "div",
@@ -6280,7 +6280,7 @@ ${r.join(`
6280
6280
  const r = Ln == null ? void 0 : Ln[n.field], s = r == null ? void 0 : r.entries, o = (r == null ? void 0 : r.separator) ?? null, l = M[n.field], c = l != null && l !== "", d = s != null && s.length && c ? ((g = D.find(
6281
6281
  (u) => u.many_collection === i && u.many_field === n.field && !u.junction_field
6282
6282
  )) == null ? void 0 : g.one_collection) ?? null : null;
6283
- return Pt(
6283
+ return Lt(
6284
6284
  vl(n),
6285
6285
  /* @__PURE__ */ _("div", { style: { gridColumn: `span ${Il(n.options, t)}` }, children: [
6286
6286
  Po(
@@ -6294,11 +6294,11 @@ ${r.join(`
6294
6294
  relations: D,
6295
6295
  collection: i,
6296
6296
  itemId: p,
6297
- error: tt[n.field],
6297
+ error: nt[n.field],
6298
6298
  autoFillTick: qs[n.field],
6299
6299
  visible: !0,
6300
6300
  forceVisible: dr(n) || void 0,
6301
- locked: Qt || Et.has(n.field) || He !== "original",
6301
+ locked: Vt || Pt.has(n.field) || He !== "original",
6302
6302
  layoutAiEnabled: Or,
6303
6303
  renderField: gr,
6304
6304
  onCountChange: Sr
@@ -6355,11 +6355,11 @@ ${r.join(`
6355
6355
  (y) => typeof y == "string" ? { field: y, width: 2 } : y
6356
6356
  ), d = l != null && l.enabled ? Mc.has((o == null ? void 0 : o.id) ?? -1) : !1, g = (Te[(o == null ? void 0 : o.key) ?? ""] ?? []).filter(
6357
6357
  (y) => $n || !y.hidden
6358
- ), u = !m && !!Dt && !!Ve && (ms === (o == null ? void 0 : o.key) || ms === e.key), f = /* @__PURE__ */ new Set(), h = /* @__PURE__ */ new Set();
6358
+ ), u = !m && !!Bt && !!Ve && (ms === (o == null ? void 0 : o.key) || ms === e.key), f = /* @__PURE__ */ new Set(), h = /* @__PURE__ */ new Set();
6359
6359
  for (const y of n) {
6360
6360
  if (m && !wh(e, y.key)) continue;
6361
6361
  const T = Te[y.key] ?? [];
6362
- T.some((C) => tt[C.field]) && h.add(y.key);
6362
+ T.some((C) => nt[C.field]) && h.add(y.key);
6363
6363
  const Y = T.filter((C) => C.required && !C.hidden);
6364
6364
  (Y.length === 0 || Y.every((C) => {
6365
6365
  if (ie.has(C.field)) {
@@ -6367,7 +6367,7 @@ ${r.join(`
6367
6367
  return !G || G.ids.length > 0;
6368
6368
  }
6369
6369
  if (qn.has(C.field)) {
6370
- const G = Wt[C.field];
6370
+ const G = Qt[C.field];
6371
6371
  return G === void 0 || G > 0;
6372
6372
  }
6373
6373
  const Z = M[C.field];
@@ -6391,7 +6391,7 @@ ${r.join(`
6391
6391
  embedded: !0
6392
6392
  }
6393
6393
  ) : /* @__PURE__ */ a("div", { className: "flex border-b border-slate-100", children: n.map(
6394
- (y) => Pt(
6394
+ (y) => Lt(
6395
6395
  { kind: "group", key: y.key },
6396
6396
  /* @__PURE__ */ a(
6397
6397
  "button",
@@ -6421,16 +6421,16 @@ ${r.join(`
6421
6421
  const ot = M[(l == null ? void 0 : l.primary_field) ?? ""];
6422
6422
  return ot != null && ot !== "";
6423
6423
  })(), re = c.some((ot) => {
6424
- const Ze = M[ot.field];
6425
- return Ze != null && Ze !== "";
6424
+ const Xe = M[ot.field];
6425
+ return Xe != null && Xe !== "";
6426
6426
  }), fe = V ? /* @__PURE__ */ _("span", { className: "inline-flex items-center gap-1.5", children: [
6427
6427
  /* @__PURE__ */ a(
6428
6428
  "button",
6429
6429
  {
6430
6430
  type: "button",
6431
6431
  onClick: () => Kc((ot) => {
6432
- const Ze = new Set(ot);
6433
- return Ze.has(o.id) ? Ze.delete(o.id) : Ze.add(o.id), Ze;
6432
+ const Xe = new Set(ot);
6433
+ return Xe.has(o.id) ? Xe.delete(o.id) : Xe.add(o.id), Xe;
6434
6434
  }),
6435
6435
  className: "inline-flex items-center rounded px-1.5 py-0.5 text-[10px] font-medium text-nvr-cyan hover:bg-nvr-cyan/10 transition-colors",
6436
6436
  children: d ? l.back_label ?? "Back" : l.toggle_label ?? "Enter manually"
@@ -6479,28 +6479,28 @@ ${r.join(`
6479
6479
  }
6480
6480
  )
6481
6481
  ] }) : void 0, Re = V && d ? /* @__PURE__ */ a("div", { className: "mt-2 rounded-lg border border-slate-200 bg-slate-50 dark:border-border dark:bg-slate-900/40 p-3", children: /* @__PURE__ */ a("div", { className: "grid grid-cols-2 gap-3", children: c.map((ot) => {
6482
- const Ze = (j ?? []).find((Hn) => Hn.field === ot.field);
6483
- return Ze ? /* @__PURE__ */ a("div", { style: { gridColumn: `span ${ot.width}` }, children: /* @__PURE__ */ a(
6482
+ const Xe = (j ?? []).find((Hn) => Hn.field === ot.field);
6483
+ return Xe ? /* @__PURE__ */ a("div", { style: { gridColumn: `span ${ot.width}` }, children: /* @__PURE__ */ a(
6484
6484
  ws,
6485
6485
  {
6486
- field: Ze,
6486
+ field: Xe,
6487
6487
  draft: Wn,
6488
6488
  onChange: _n,
6489
6489
  relations: D,
6490
6490
  collection: i,
6491
6491
  itemId: p,
6492
- error: tt[Ze.field],
6493
- autoFillTick: qs[Ze.field],
6492
+ error: nt[Xe.field],
6493
+ autoFillTick: qs[Xe.field],
6494
6494
  visible: !0,
6495
6495
  forceVisible: !0,
6496
- locked: Et.has(Ze.field) || He !== "original",
6496
+ locked: Pt.has(Xe.field) || He !== "original",
6497
6497
  layoutAiEnabled: Or,
6498
6498
  renderField: gr,
6499
6499
  onCountChange: Sr
6500
6500
  }
6501
- ) }, Ze.field) : null;
6501
+ ) }, Xe.field) : null;
6502
6502
  }) }) }) : void 0;
6503
- return Pt(
6503
+ return Lt(
6504
6504
  vl(Q),
6505
6505
  /* @__PURE__ */ _("div", { style: { gridColumn: `span ${Il(Q.options, Y)}` }, children: [
6506
6506
  Po(
@@ -6514,11 +6514,11 @@ ${r.join(`
6514
6514
  relations: D,
6515
6515
  collection: i,
6516
6516
  itemId: p,
6517
- error: tt[Q.field],
6517
+ error: nt[Q.field],
6518
6518
  autoFillTick: qs[Q.field],
6519
6519
  visible: Nt.has(Q.field) || !Nt.size,
6520
6520
  forceVisible: dr(Q, Nt.has(Q.field) || !Nt.size) || void 0,
6521
- locked: Et.has(Q.field) || He !== "original",
6521
+ locked: Pt.has(Q.field) || He !== "original",
6522
6522
  layoutAiEnabled: Or,
6523
6523
  renderField: gr,
6524
6524
  onCountChange: Sr,
@@ -6554,7 +6554,7 @@ ${r.join(`
6554
6554
  T = typeof y.input_bindings == "string" ? JSON.parse(y.input_bindings) : y.input_bindings ?? [];
6555
6555
  } catch {
6556
6556
  }
6557
- return Pt(
6557
+ return Lt(
6558
6558
  qr(y.field, y.group_key ?? null),
6559
6559
  /* @__PURE__ */ a("div", { className: "mt-4", children: /* @__PURE__ */ a(
6560
6560
  Do,
@@ -6571,7 +6571,7 @@ ${r.join(`
6571
6571
  { asChild: !0 }
6572
6572
  );
6573
6573
  }),
6574
- u && Pt(
6574
+ u && Lt(
6575
6575
  qr("__pdf__"),
6576
6576
  /* @__PURE__ */ a("div", { className: "mt-4 flex items-center gap-2", children: /* @__PURE__ */ _(
6577
6577
  "button",
@@ -6683,8 +6683,8 @@ ${r.join(`
6683
6683
  group: t,
6684
6684
  fields: l,
6685
6685
  ownersAssignment: c ? ut : void 0,
6686
- ownersCollection: dn,
6687
- ownersItemId: cn,
6686
+ ownersCollection: It,
6687
+ ownersItemId: Ut,
6688
6688
  pdfAssignment: d ? Ve : void 0,
6689
6689
  pdfAttachField: d ? Pn : void 0,
6690
6690
  pdfFilenameTemplate: d ? au : void 0,
@@ -6695,9 +6695,9 @@ ${r.join(`
6695
6695
  relations: D,
6696
6696
  collection: i,
6697
6697
  itemId: p,
6698
- errors: tt,
6698
+ errors: nt,
6699
6699
  visibleFields: Nt,
6700
- lockedFields: Et,
6700
+ lockedFields: Pt,
6701
6701
  layoutAiEnabled: Or,
6702
6702
  displayOnly: t.type === "metadata",
6703
6703
  renderField: gr,
@@ -6741,11 +6741,11 @@ ${r.join(`
6741
6741
  !Ie && ue && /* @__PURE__ */ a(
6742
6742
  Bo,
6743
6743
  {
6744
- collection: dn,
6745
- item: cn,
6744
+ collection: It,
6745
+ item: Ut,
6746
6746
  onBeforeTransition: _s,
6747
- addendumPending: !st && Oi > 0 && !!(x != null && x.addendums_enabled),
6748
- addendumView: st
6747
+ addendumPending: !Je && Oi > 0 && !!(x != null && x.addendums_enabled),
6748
+ addendumView: Je
6749
6749
  }
6750
6750
  ),
6751
6751
  !ct && jr && /* @__PURE__ */ a(
@@ -6773,7 +6773,7 @@ ${r.join(`
6773
6773
  }
6774
6774
  ),
6775
6775
  qt && /* @__PURE__ */ a(Bl, { collection: i, item: p }),
6776
- !nn && w !== void 0 && (x == null ? void 0 : x.addendums_enabled) && !m && /* @__PURE__ */ a(
6776
+ !sn && w !== void 0 && (x == null ? void 0 : x.addendums_enabled) && !m && /* @__PURE__ */ a(
6777
6777
  Qo,
6778
6778
  {
6779
6779
  collection: i,
@@ -6794,7 +6794,7 @@ ${r.join(`
6794
6794
  rows: e ? fy(e.swap_config).rows : [],
6795
6795
  folded: (n) => !!e && uy(n._overrides),
6796
6796
  keep: (n) => !!n.required,
6797
- filled: (n) => !Cl(Wn[n.field]) || !!tt[n.field]
6797
+ filled: (n) => !Cl(Wn[n.field]) || !!nt[n.field]
6798
6798
  });
6799
6799
  }
6800
6800
  function Ku(e, t, n, r) {
@@ -6804,8 +6804,8 @@ ${r.join(`
6804
6804
  row: e,
6805
6805
  members: t,
6806
6806
  containerWidth: n,
6807
- errors: tt,
6808
- renderMember: (s) => Pt(
6807
+ errors: nt,
6808
+ renderMember: (s) => Lt(
6809
6809
  { kind: "field", field: s.field, group_key: r },
6810
6810
  /* @__PURE__ */ a("div", { children: Po(
6811
6811
  dr(s, Nt.has(s.field) || !Nt.size),
@@ -6818,11 +6818,11 @@ ${r.join(`
6818
6818
  relations: D,
6819
6819
  collection: i,
6820
6820
  itemId: p,
6821
- error: tt[s.field],
6821
+ error: nt[s.field],
6822
6822
  autoFillTick: qs[s.field],
6823
6823
  visible: Nt.has(s.field) || !Nt.size,
6824
6824
  forceVisible: dr(s, Nt.has(s.field) || !Nt.size) || void 0,
6825
- locked: Et.has(s.field) || Qt || He !== "original",
6825
+ locked: Pt.has(s.field) || Vt || He !== "original",
6826
6826
  layoutAiEnabled: Or,
6827
6827
  renderField: gr,
6828
6828
  onCountChange: Sr
@@ -6852,7 +6852,7 @@ ${r.join(`
6852
6852
  );
6853
6853
  }
6854
6854
  function Lo(e, t = !1) {
6855
- const n = (e === "__general__" ? t ? Ht : [...Ht, ...Ut.flatMap((d) => Te[d.key] ?? [])] : Te[e] ?? []).filter((d) => $n || !d.hidden), r = ti && ps === e && ue, s = ei && ms === e && !m, o = Xs.filter((d) => (d.group_key ?? null) === e), l = Mu(
6855
+ const n = (e === "__general__" ? t ? Jt : [...Jt, ...Gt.flatMap((d) => Te[d.key] ?? [])] : Te[e] ?? []).filter((d) => $n || !d.hidden), r = ti && ps === e && ue, s = ei && ms === e && !m, o = Xs.filter((d) => (d.group_key ?? null) === e), l = Mu(
6856
6856
  e === "__general__" ? void 0 : Ce.find((d) => d.key === e),
6857
6857
  n
6858
6858
  ), c = l.units.map(
@@ -6890,7 +6890,7 @@ ${r.join(`
6890
6890
  );
6891
6891
  if (g._t === "owners") {
6892
6892
  const C = g.slot.col_span ?? 12;
6893
- return Pt(
6893
+ return Lt(
6894
6894
  qr("__owners__", g.slot.group_key ?? null),
6895
6895
  /* @__PURE__ */ a("div", { style: { gridColumn: `span ${C}` }, children: /* @__PURE__ */ a(
6896
6896
  gv,
@@ -6904,9 +6904,9 @@ ${r.join(`
6904
6904
  );
6905
6905
  }
6906
6906
  if (g._t === "pdf") {
6907
- if (!Dt) return null;
6907
+ if (!Bt) return null;
6908
6908
  const C = g.slot.col_span ?? 12, Z = ((Y = g.slot.label_override) == null ? void 0 : Y.trim()) || "Generate PDF", G = !Pn;
6909
- return Pt(
6909
+ return Lt(
6910
6910
  qr("__pdf__", g.slot.group_key ?? null),
6911
6911
  /* @__PURE__ */ a("div", { style: { gridColumn: `span ${C}` }, children: /* @__PURE__ */ _(
6912
6912
  "button",
@@ -6944,7 +6944,7 @@ ${r.join(`
6944
6944
  if (g._t === "widget") {
6945
6945
  if (!g.slot.widget_id) return null;
6946
6946
  const C = g.slot.col_span ?? 12;
6947
- return Pt(
6947
+ return Lt(
6948
6948
  qr(g.slot.field, g.slot.group_key ?? null),
6949
6949
  /* @__PURE__ */ a("div", { style: { gridColumn: `span ${C}` }, children: /* @__PURE__ */ a(
6950
6950
  Do,
@@ -6962,7 +6962,7 @@ ${r.join(`
6962
6962
  const f = g.f, h = Ln == null ? void 0 : Ln[f.field], v = h == null ? void 0 : h.entries, S = (h == null ? void 0 : h.separator) ?? null, y = M[f.field], T = y != null && y !== "", Q = v != null && v.length && T ? ((oe = D.find(
6963
6963
  (C) => C.many_collection === i && C.many_field === f.field && !C.junction_field
6964
6964
  )) == null ? void 0 : oe.one_collection) ?? null : null;
6965
- return Pt(
6965
+ return Lt(
6966
6966
  vl(f),
6967
6967
  /* @__PURE__ */ _("div", { style: { gridColumn: `span ${Il(f.options, u)}` }, children: [
6968
6968
  Po(
@@ -6976,11 +6976,11 @@ ${r.join(`
6976
6976
  relations: D,
6977
6977
  collection: i,
6978
6978
  itemId: p,
6979
- error: tt[f.field],
6979
+ error: nt[f.field],
6980
6980
  autoFillTick: qs[f.field],
6981
6981
  visible: !0,
6982
6982
  forceVisible: dr(f) || void 0,
6983
- locked: Qt || Et.has(f.field) || He !== "original",
6983
+ locked: Vt || Pt.has(f.field) || He !== "original",
6984
6984
  layoutAiEnabled: Or,
6985
6985
  renderField: gr,
6986
6986
  onCountChange: Sr
@@ -7010,7 +7010,7 @@ ${r.join(`
7010
7010
  I && c.length === 0 && (e !== "__general__" || t) && /* @__PURE__ */ a(Zf, {})
7011
7011
  ]
7012
7012
  },
7013
- Ye
7013
+ Ze
7014
7014
  );
7015
7015
  }
7016
7016
  const dg = (e) => {
@@ -7019,7 +7019,7 @@ ${r.join(`
7019
7019
  const r = new Set(n);
7020
7020
  return r.has(e) ? r.delete(e) : r.add(e), r;
7021
7021
  }), t) At(e);
7022
- else if (Ye === e) {
7022
+ else if (Ze === e) {
7023
7023
  const n = we.find((r) => r.key !== e);
7024
7024
  n && At(n.key);
7025
7025
  }
@@ -7035,11 +7035,11 @@ ${r.join(`
7035
7035
  function cg() {
7036
7036
  var t;
7037
7037
  const e = [
7038
- ...Ut.length > 0 ? [{ key: "__general__", label: "General" }] : [],
7038
+ ...Gt.length > 0 ? [{ key: "__general__", label: "General" }] : [],
7039
7039
  ...jt.map((n) => ({ key: n.key, label: n.label }))
7040
7040
  ];
7041
7041
  return /* @__PURE__ */ _("div", { "data-section-stack": "", className: "space-y-4", children: [
7042
- Ht.length > 0 && Pu(),
7042
+ Jt.length > 0 && Pu(),
7043
7043
  /* @__PURE__ */ _(
7044
7044
  "div",
7045
7045
  {
@@ -7047,7 +7047,7 @@ ${r.join(`
7047
7047
  className: "relative flex border-b border-slate-200 overflow-x-auto gap-1 px-1",
7048
7048
  children: [
7049
7049
  e.map((n) => {
7050
- const r = Object.keys(tt).some((o) => {
7050
+ const r = Object.keys(nt).some((o) => {
7051
7051
  const l = Se.find((c) => c.field === o);
7052
7052
  return (l == null ? void 0 : l.group_key) === n.key || !(l != null && l.group_key) && n.key === "__general__";
7053
7053
  }), s = /* @__PURE__ */ _(
@@ -7060,7 +7060,7 @@ ${r.join(`
7060
7060
  onClick: () => At(n.key),
7061
7061
  className: De(
7062
7062
  "whitespace-nowrap px-4 py-2.5 text-sm font-medium border-b-2 border-transparent transition-colors flex items-center gap-1.5",
7063
- Ye === n.key ? "text-primary" : "text-muted-foreground hover:text-foreground",
7063
+ Ze === n.key ? "text-primary" : "text-muted-foreground hover:text-foreground",
7064
7064
  (Rr == null ? void 0 : Rr.has(n.key)) && "opacity-40"
7065
7065
  ),
7066
7066
  children: [
@@ -7070,7 +7070,7 @@ ${r.join(`
7070
7070
  },
7071
7071
  n.key
7072
7072
  );
7073
- return n.key === "__general__" ? s : Pt({ kind: "group", key: n.key }, s, { asChild: !0, pass: !0 });
7073
+ return n.key === "__general__" ? s : Lt({ kind: "group", key: n.key }, s, { asChild: !0, pass: !0 });
7074
7074
  }),
7075
7075
  tl && /* @__PURE__ */ a(
7076
7076
  "span",
@@ -7087,16 +7087,16 @@ ${r.join(`
7087
7087
  rl ? e.map((n) => /* @__PURE__ */ _(Nl, { children: [
7088
7088
  xl(n.key, n.label),
7089
7089
  Lo(n.key)
7090
- ] }, n.key)) : Lo(Ye),
7091
- oi.filter((n) => typeof n == "string" && n !== "__ungrouped__").map((n) => Pt(qr(n), kl(n))),
7090
+ ] }, n.key)) : Lo(Ze),
7091
+ oi.filter((n) => typeof n == "string" && n !== "__ungrouped__").map((n) => Lt(qr(n), kl(n))),
7092
7092
  !Ie && ue && /* @__PURE__ */ a(
7093
7093
  Bo,
7094
7094
  {
7095
- collection: dn,
7096
- item: cn,
7095
+ collection: It,
7096
+ item: Ut,
7097
7097
  onBeforeTransition: _s,
7098
- addendumPending: !st && Oi > 0 && !!(x != null && x.addendums_enabled),
7099
- addendumView: st
7098
+ addendumPending: !Je && Oi > 0 && !!(x != null && x.addendums_enabled),
7099
+ addendumView: Je
7100
7100
  }
7101
7101
  ),
7102
7102
  !ct && jr && /* @__PURE__ */ a(
@@ -7124,7 +7124,7 @@ ${r.join(`
7124
7124
  }
7125
7125
  ),
7126
7126
  qt && /* @__PURE__ */ a(Bl, { collection: i, item: p }),
7127
- !nn && w !== void 0 && (x == null ? void 0 : x.addendums_enabled) && !m && /* @__PURE__ */ a(
7127
+ !sn && w !== void 0 && (x == null ? void 0 : x.addendums_enabled) && !m && /* @__PURE__ */ a(
7128
7128
  Qo,
7129
7129
  {
7130
7130
  collection: i,
@@ -7142,13 +7142,13 @@ ${r.join(`
7142
7142
  }
7143
7143
  function ug() {
7144
7144
  var c;
7145
- const e = we.findIndex((d) => d.key === Ye), t = e === we.length - 1, r = /* @__PURE__ */ a("div", { className: "mt-6 border-t border-slate-200 pt-4", children: /* @__PURE__ */ _("div", { className: "flex items-center justify-between gap-2", children: [
7145
+ const e = we.findIndex((d) => d.key === Ze), t = e === we.length - 1, r = /* @__PURE__ */ a("div", { className: "mt-6 border-t border-slate-200 pt-4", children: /* @__PURE__ */ _("div", { className: "flex items-center justify-between gap-2", children: [
7146
7146
  /* @__PURE__ */ _(
7147
7147
  "button",
7148
7148
  {
7149
7149
  type: "button",
7150
7150
  onClick: () => {
7151
- const d = we.findIndex((g) => g.key === Ye);
7151
+ const d = we.findIndex((g) => g.key === Ze);
7152
7152
  d > 0 && At(we[d - 1].key);
7153
7153
  },
7154
7154
  disabled: e === 0,
@@ -7171,7 +7171,7 @@ ${r.join(`
7171
7171
  {
7172
7172
  type: "button",
7173
7173
  onClick: () => jo(),
7174
- disabled: St.isPending || Qt || nt.active,
7174
+ disabled: St.isPending || Vt || rt.active,
7175
7175
  className: "inline-flex h-9 items-center gap-1.5 rounded-md bg-nvr-cyan px-3 text-[12px] font-medium text-white transition-colors hover:bg-nvr-cyan-dark disabled:opacity-50",
7176
7176
  children: [
7177
7177
  /* @__PURE__ */ a(Of, { className: "h-3.5 w-3.5" }),
@@ -7194,14 +7194,14 @@ ${r.join(`
7194
7194
  nm,
7195
7195
  {
7196
7196
  wrap: !1,
7197
- collection: dn,
7198
- item: cn,
7197
+ collection: It,
7198
+ item: Ut,
7199
7199
  onBeforeTransition: _s
7200
7200
  },
7201
- `${dn}:${cn}`
7201
+ `${It}:${Ut}`
7202
7202
  )
7203
7203
  ] })
7204
- ] }) }), s = jt.length > 0 ? Math.min(...jt.map((d) => d.sort)) : 1 / 0, o = oi.filter((d) => typeof d != "string" ? d.sort < s : d === "__pipeline__" ? !!(Ie && Ie.sort < s) : d === "__comments__" ? !!(dt && dt.sort < s) : d === "__tasks__" ? !!(ct && ct.sort < s) : d === "__addendums__" ? !!(nn && nn.sort < s) : !1), l = oi.filter((d) => d === "__ungrouped__" ? !1 : typeof d != "string" ? d.sort >= s : d === "__pipeline__" ? !(Ie && Ie.sort < s) : d === "__comments__" ? !(dt && dt.sort < s) : d === "__tasks__" ? !(ct && ct.sort < s) : d === "__addendums__" ? !(nn && nn.sort < s) : !1);
7204
+ ] }) }), s = jt.length > 0 ? Math.min(...jt.map((d) => d.sort)) : 1 / 0, o = oi.filter((d) => typeof d != "string" ? d.sort < s : d === "__pipeline__" ? !!(Ie && Ie.sort < s) : d === "__comments__" ? !!(dt && dt.sort < s) : d === "__tasks__" ? !!(ct && ct.sort < s) : d === "__addendums__" ? !!(sn && sn.sort < s) : !1), l = oi.filter((d) => d === "__ungrouped__" ? !1 : typeof d != "string" ? d.sort >= s : d === "__pipeline__" ? !(Ie && Ie.sort < s) : d === "__comments__" ? !(dt && dt.sort < s) : d === "__tasks__" ? !(ct && ct.sort < s) : d === "__addendums__" ? !(sn && sn.sort < s) : !1);
7205
7205
  return /* @__PURE__ */ _("div", { "data-section-stack": "", className: "nvr-stagger space-y-4 min-w-0 flex-1", children: [
7206
7206
  o.map((d, g) => {
7207
7207
  const u = typeof d == "string" ? d : d.key;
@@ -7212,11 +7212,11 @@ ${r.join(`
7212
7212
  {
7213
7213
  steps: we,
7214
7214
  hiddenSteps: Rr,
7215
- active: Ye,
7215
+ active: Ze,
7216
7216
  completed: Sh,
7217
7217
  dirtySteps: xh,
7218
7218
  errorSteps: new Set(
7219
- we.filter((d) => (Te[d.key] ?? []).some((g) => tt[g.field])).map((d) => d.key)
7219
+ we.filter((d) => (Te[d.key] ?? []).some((g) => nt[g.field])).map((d) => d.key)
7220
7220
  ),
7221
7221
  onStepClick: At
7222
7222
  }
@@ -7225,7 +7225,7 @@ ${r.join(`
7225
7225
  rl ? we.map((d) => /* @__PURE__ */ _(Nl, { children: [
7226
7226
  xl(d.key, d.label),
7227
7227
  Lo(d.key, !0)
7228
- ] }, d.key)) : Lo(Ye, !0),
7228
+ ] }, d.key)) : Lo(Ze, !0),
7229
7229
  l.map((d, g) => {
7230
7230
  const u = typeof d == "string" ? d : d.key;
7231
7231
  return wl(d, u ?? g);
@@ -7233,12 +7233,12 @@ ${r.join(`
7233
7233
  !Ie && ue && /* @__PURE__ */ a(
7234
7234
  Bo,
7235
7235
  {
7236
- collection: dn,
7237
- item: cn,
7236
+ collection: It,
7237
+ item: Ut,
7238
7238
  defaultExpanded: !1,
7239
7239
  onBeforeTransition: _s,
7240
- addendumPending: !st && Oi > 0 && !!(x != null && x.addendums_enabled),
7241
- addendumView: st
7240
+ addendumPending: !Je && Oi > 0 && !!(x != null && x.addendums_enabled),
7241
+ addendumView: Je
7242
7242
  }
7243
7243
  ),
7244
7244
  !ct && jr && /* @__PURE__ */ a(
@@ -7264,7 +7264,7 @@ ${r.join(`
7264
7264
  }
7265
7265
  ),
7266
7266
  qt && /* @__PURE__ */ a(Bl, { collection: i, item: p }),
7267
- !nn && w !== void 0 && (x == null ? void 0 : x.addendums_enabled) && !m && /* @__PURE__ */ a(
7267
+ !sn && w !== void 0 && (x == null ? void 0 : x.addendums_enabled) && !m && /* @__PURE__ */ a(
7268
7268
  Qo,
7269
7269
  {
7270
7270
  collection: i,
@@ -7374,8 +7374,8 @@ ${r.join(`
7374
7374
  return /* @__PURE__ */ a(
7375
7375
  Eg.Provider,
7376
7376
  {
7377
- value: m || Qt ? null : Ed,
7378
- children: /* @__PURE__ */ a(Pg.Provider, { value: wp, children: /* @__PURE__ */ a(__.Provider, { value: Xp, children: /* @__PURE__ */ a(b_.Provider, { value: He, children: /* @__PURE__ */ a(v_.Provider, { value: Wp, children: /* @__PURE__ */ a(Lg.Provider, { value: og, children: /* @__PURE__ */ a(Mg.Provider, { value: m ? null : Wm, children: /* @__PURE__ */ a(Kg.Provider, { value: Jp, children: /* @__PURE__ */ a(C_.Provider, { value: ig, children: /* @__PURE__ */ a(M0.Provider, { value: an, children: /* @__PURE__ */ a(K0.Provider, { value: Qp, children: /* @__PURE__ */ a(D0.Provider, { value: Vp, children: /* @__PURE__ */ a(A0.Provider, { value: xe, children: /* @__PURE__ */ _(
7377
+ value: m || Vt ? null : Ed,
7378
+ children: /* @__PURE__ */ a(Pg.Provider, { value: wp, children: /* @__PURE__ */ a(__.Provider, { value: Xp, children: /* @__PURE__ */ a(b_.Provider, { value: He, children: /* @__PURE__ */ a(v_.Provider, { value: Wp, children: /* @__PURE__ */ a(Lg.Provider, { value: og, children: /* @__PURE__ */ a(Mg.Provider, { value: m ? null : Wm, children: /* @__PURE__ */ a(Kg.Provider, { value: Jp, children: /* @__PURE__ */ a(C_.Provider, { value: ig, children: /* @__PURE__ */ a(M0.Provider, { value: dn, children: /* @__PURE__ */ a(K0.Provider, { value: Qp, children: /* @__PURE__ */ a(D0.Provider, { value: Vp, children: /* @__PURE__ */ a(A0.Provider, { value: xe, children: /* @__PURE__ */ _(
7379
7379
  Yv,
7380
7380
  {
7381
7381
  affordances: sg,
@@ -7395,7 +7395,7 @@ ${r.join(`
7395
7395
  children: /* @__PURE__ */ _(_i, { className: "max-w-md", "data-nvr-leave-ask": !0, children: [
7396
7396
  /* @__PURE__ */ a(bi, { children: /* @__PURE__ */ a(vi, { className: "text-[15px]", children: "Leave without saving?" }) }),
7397
7397
  /* @__PURE__ */ a(wi, { children: /* @__PURE__ */ _("p", { className: "text-[13px] text-slate-600 dark:text-slate-300", children: [
7398
- ln.text ? `You have unsaved changes: ${ln.text}.` : "You have unsaved changes.",
7398
+ cn.text ? `You have unsaved changes: ${cn.text}.` : "You have unsaved changes.",
7399
7399
  " ",
7400
7400
  "They stay on this device as a draft — open this",
7401
7401
  " ",
@@ -7404,7 +7404,7 @@ ${r.join(`
7404
7404
  ] }) }),
7405
7405
  /* @__PURE__ */ _(Vo, { children: [
7406
7406
  /* @__PURE__ */ a(
7407
- Zt,
7407
+ en,
7408
7408
  {
7409
7409
  variant: "outline",
7410
7410
  size: "sm",
@@ -7416,7 +7416,7 @@ ${r.join(`
7416
7416
  }
7417
7417
  ),
7418
7418
  /* @__PURE__ */ a(
7419
- Zt,
7419
+ en,
7420
7420
  {
7421
7421
  size: "sm",
7422
7422
  className: "bg-nvr-cyan text-white",
@@ -7487,7 +7487,7 @@ ${r.join(`
7487
7487
  ] }),
7488
7488
  /* @__PURE__ */ _(Vo, { children: [
7489
7489
  /* @__PURE__ */ a(
7490
- Zt,
7490
+ en,
7491
7491
  {
7492
7492
  variant: "outline",
7493
7493
  size: "sm",
@@ -7496,7 +7496,7 @@ ${r.join(`
7496
7496
  }
7497
7497
  ),
7498
7498
  /* @__PURE__ */ a(
7499
- Zt,
7499
+ en,
7500
7500
  {
7501
7501
  size: "sm",
7502
7502
  className: "bg-nvr-cyan text-white",
@@ -7514,47 +7514,47 @@ ${r.join(`
7514
7514
  /* @__PURE__ */ a(
7515
7515
  yi,
7516
7516
  {
7517
- open: !!rt,
7517
+ open: !!st,
7518
7518
  onOpenChange: (e) => {
7519
7519
  !e && !so && ro(null);
7520
7520
  },
7521
7521
  children: /* @__PURE__ */ _(_i, { children: [
7522
7522
  /* @__PURE__ */ a(bi, { children: /* @__PURE__ */ a(vi, { children: "Update this record from file" }) }),
7523
7523
  /* @__PURE__ */ _(wi, { className: "space-y-3", children: [
7524
- rt && /* @__PURE__ */ _("p", { className: "text-[12px] text-slate-500 dark:text-muted-foreground", children: [
7525
- rt.diff.updates.length,
7524
+ st && /* @__PURE__ */ _("p", { className: "text-[12px] text-slate-500 dark:text-muted-foreground", children: [
7525
+ st.diff.updates.length,
7526
7526
  " will update ·",
7527
7527
  " ",
7528
- rt.diff.creates.length,
7528
+ st.diff.creates.length,
7529
7529
  " new ·",
7530
7530
  " ",
7531
- rt.diff.deletes.length,
7531
+ st.diff.deletes.length,
7532
7532
  " will delete ·",
7533
7533
  " ",
7534
- rt.diff.matchedUnchanged,
7534
+ st.diff.matchedUnchanged,
7535
7535
  " unchanged"
7536
7536
  ] }),
7537
- (rt == null ? void 0 : rt.pendingNotice) && /* @__PURE__ */ a(
7537
+ (st == null ? void 0 : st.pendingNotice) && /* @__PURE__ */ a(
7538
7538
  "p",
7539
7539
  {
7540
7540
  role: "status",
7541
7541
  "data-reimport-pending-notice": !0,
7542
7542
  className: "rounded-md border border-amber-200 bg-amber-50 px-2.5 py-1.5 text-[12px] text-amber-900 dark:border-amber-500/30 dark:bg-amber-500/10 dark:text-amber-200",
7543
- children: rt.pendingNotice
7543
+ children: st.pendingNotice
7544
7544
  }
7545
7545
  ),
7546
- rt && /* @__PURE__ */ a(
7546
+ st && /* @__PURE__ */ a(
7547
7547
  p_,
7548
7548
  {
7549
- diff: rt.diff,
7549
+ diff: st.diff,
7550
7550
  fields: j ?? []
7551
7551
  }
7552
7552
  ),
7553
- rt && /* @__PURE__ */ a(Mf, { issues: rt.result.issues })
7553
+ st && /* @__PURE__ */ a(Mf, { issues: st.result.issues })
7554
7554
  ] }),
7555
7555
  /* @__PURE__ */ _(Vo, { children: [
7556
7556
  /* @__PURE__ */ a(
7557
- Zt,
7557
+ en,
7558
7558
  {
7559
7559
  variant: "outline",
7560
7560
  onClick: () => ro(null),
@@ -7563,15 +7563,15 @@ ${r.join(`
7563
7563
  }
7564
7564
  ),
7565
7565
  /* @__PURE__ */ a(
7566
- Zt,
7566
+ en,
7567
7567
  {
7568
7568
  onClick: async () => {
7569
- rt && (Id(!0), await _p(
7570
- rt.diff,
7571
- rt.result,
7572
- rt.template,
7573
- rt.existingRows,
7574
- rt.restored
7569
+ st && (Id(!0), await _p(
7570
+ st.diff,
7571
+ st.result,
7572
+ st.template,
7573
+ st.existingRows,
7574
+ st.restored
7575
7575
  ), Id(!1), ro(null));
7576
7576
  },
7577
7577
  disabled: so,
@@ -7683,24 +7683,24 @@ ${r.join(`
7683
7683
  ]
7684
7684
  }
7685
7685
  ),
7686
- Jt && !Jt.api && /* @__PURE__ */ a(
7686
+ Yt && !Yt.api && /* @__PURE__ */ a(
7687
7687
  "span",
7688
7688
  {
7689
7689
  "data-provenance-chip": !0,
7690
7690
  className: "inline-flex items-center gap-1 rounded-full border border-slate-200 bg-slate-50 px-1.5 py-px text-[9.5px] font-medium text-slate-500 dark:border-border dark:bg-muted dark:text-muted-foreground",
7691
- "data-tip": `${Jt.origin}${Jt.user_name ? ` · ${Jt.user_name}` : ""} · ${xi(Jt.timestamp)}`,
7692
- children: Jt.origin
7691
+ "data-tip": `${Yt.origin}${Yt.user_name ? ` · ${Yt.user_name}` : ""} · ${xi(Yt.timestamp)}`,
7692
+ children: Yt.origin
7693
7693
  }
7694
7694
  ),
7695
- (Jt == null ? void 0 : Jt.api) && /* @__PURE__ */ a(
7695
+ (Yt == null ? void 0 : Yt.api) && /* @__PURE__ */ a(
7696
7696
  Jv,
7697
7697
  {
7698
7698
  collection: i,
7699
7699
  itemId: String(p),
7700
- origin: Jt.origin,
7701
- userName: Jt.user_name,
7702
- timestamp: Jt.timestamp,
7703
- api: Jt.api
7700
+ origin: Yt.origin,
7701
+ userName: Yt.user_name,
7702
+ timestamp: Yt.timestamp,
7703
+ api: Yt.api
7704
7704
  }
7705
7705
  ),
7706
7706
  Rt && !m && p && !I && /* @__PURE__ */ a(
@@ -7779,7 +7779,7 @@ ${r.join(`
7779
7779
  onParsed: ns
7780
7780
  }
7781
7781
  ),
7782
- m && !Qt && /* @__PURE__ */ a(
7782
+ m && !Vt && /* @__PURE__ */ a(
7783
7783
  f_,
7784
7784
  {
7785
7785
  collection: i,
@@ -7788,7 +7788,7 @@ ${r.join(`
7788
7788
  onProposalConsumed: jm
7789
7789
  }
7790
7790
  ),
7791
- m && Vd.length > 0 && !Qt && /* @__PURE__ */ _(
7791
+ m && Vd.length > 0 && !Vt && /* @__PURE__ */ _(
7792
7792
  wm,
7793
7793
  {
7794
7794
  open: Hd,
@@ -8033,7 +8033,7 @@ ${r.join(`
8033
8033
  }
8034
8034
  ),
8035
8035
  Lm.map((e) => /* @__PURE__ */ _(
8036
- Zt,
8036
+ en,
8037
8037
  {
8038
8038
  type: "button",
8039
8039
  variant: "outline",
@@ -8132,7 +8132,7 @@ ${r.join(`
8132
8132
  ).then((f) => f.data ?? null).catch(() => null), s = r ? { ...r } : { ...M };
8133
8133
  if (r)
8134
8134
  for (const f of qe.current)
8135
- et(
8135
+ tt(
8136
8136
  M[f],
8137
8137
  $e.current[f]
8138
8138
  ) || (s[f] = M[f]);
@@ -8166,7 +8166,7 @@ ${r.join(`
8166
8166
  Sm(
8167
8167
  h,
8168
8168
  f.junctionField,
8169
- Ge.get(f.stagingKey),
8169
+ Ye.get(f.stagingKey),
8170
8170
  at.get(f.stagingKey)
8171
8171
  )
8172
8172
  ]
@@ -8344,7 +8344,7 @@ ${r.join(`
8344
8344
  Rt && /* @__PURE__ */ _(Ct, { children: [
8345
8345
  /* @__PURE__ */ a("div", { "data-nvr-menu-divider": !0 }),
8346
8346
  /* @__PURE__ */ _(
8347
- Zt,
8347
+ en,
8348
8348
  {
8349
8349
  type: "button",
8350
8350
  variant: "outline",
@@ -8360,7 +8360,7 @@ ${r.join(`
8360
8360
  }
8361
8361
  ),
8362
8362
  !m && /* @__PURE__ */ _(
8363
- Zt,
8363
+ en,
8364
8364
  {
8365
8365
  type: "button",
8366
8366
  variant: "outline",
@@ -8376,7 +8376,7 @@ ${r.join(`
8376
8376
  }
8377
8377
  ),
8378
8378
  !m && p && /* @__PURE__ */ _(
8379
- Zt,
8379
+ en,
8380
8380
  {
8381
8381
  type: "button",
8382
8382
  variant: "outline",
@@ -8384,16 +8384,18 @@ ${r.join(`
8384
8384
  "data-nvr-menu-close": !0,
8385
8385
  onClick: () => {
8386
8386
  t_({
8387
- collection: i,
8388
- item: String(p)
8387
+ // The viewed addendum's own pipeline,
8388
+ // else the record's.
8389
+ collection: It,
8390
+ item: String(Ut)
8389
8391
  }) || Pi(!0);
8390
8392
  },
8391
- title: "Put this record straight into a chosen pipeline state, with a reason. No transition steps run (admin)",
8393
+ title: Je ? "Put the addendum you are viewing straight into a chosen state of its pipeline, with a reason. No transition steps run (admin)" : "Put this record straight into a chosen pipeline state, with a reason. No transition steps run (admin)",
8392
8394
  className: "gap-1.5",
8393
8395
  "data-move-to-state-menu": !0,
8394
8396
  children: [
8395
8397
  /* @__PURE__ */ a(xg, { className: "h-3.5 w-3.5" }),
8396
- "Move to state…"
8398
+ Je ? "Move addendum to state…" : "Move to state…"
8397
8399
  ]
8398
8400
  }
8399
8401
  ),
@@ -8415,7 +8417,7 @@ ${r.join(`
8415
8417
  Qu && (eg ? /* @__PURE__ */ _(Ct, { children: [
8416
8418
  /* @__PURE__ */ a("span", { className: "text-sm text-muted-foreground", children: "Delete?" }),
8417
8419
  /* @__PURE__ */ a(
8418
- Zt,
8420
+ en,
8419
8421
  {
8420
8422
  type: "button",
8421
8423
  size: "sm",
@@ -8427,7 +8429,7 @@ ${r.join(`
8427
8429
  }
8428
8430
  ),
8429
8431
  /* @__PURE__ */ a(
8430
- Zt,
8432
+ en,
8431
8433
  {
8432
8434
  type: "button",
8433
8435
  size: "sm",
@@ -8437,7 +8439,7 @@ ${r.join(`
8437
8439
  }
8438
8440
  )
8439
8441
  ] }) : /* @__PURE__ */ _(
8440
- Zt,
8442
+ en,
8441
8443
  {
8442
8444
  type: "button",
8443
8445
  size: "sm",
@@ -8557,7 +8559,7 @@ ${r.join(`
8557
8559
  pu(!0);
8558
8560
  try {
8559
8561
  await R.request(
8560
- on("/record-templates", {
8562
+ ln("/record-templates", {
8561
8563
  collection: i,
8562
8564
  name: si.trim(),
8563
8565
  data: t,
@@ -8660,7 +8662,7 @@ ${r.join(`
8660
8662
  fieldConfig: j,
8661
8663
  draft: M,
8662
8664
  initial: $e.current,
8663
- m2mLinks: Ge,
8665
+ m2mLinks: Ye,
8664
8666
  m2mUnlinks: at,
8665
8667
  pendingRowCount: [...je.values()].reduce(
8666
8668
  (e, t) => e + t.length,
@@ -8672,13 +8674,13 @@ ${r.join(`
8672
8674
  }
8673
8675
  ),
8674
8676
  /* @__PURE__ */ _(
8675
- Zt,
8677
+ en,
8676
8678
  {
8677
8679
  type: "button",
8678
8680
  size: "sm",
8679
8681
  onClick: () => jo(),
8680
- disabled: St.isPending || Qt || nt.active || gl,
8681
- "data-tip": gl && !Qt ? "Every field here is locked — nothing to save" : void 0,
8682
+ disabled: St.isPending || Vt || rt.active || gl,
8683
+ "data-tip": gl && !Vt ? "Every field here is locked — nothing to save" : void 0,
8682
8684
  className: De(
8683
8685
  "gap-1.5 transition-colors duration-300",
8684
8686
  // Summary mode has nothing to save — the button would
@@ -8697,7 +8699,7 @@ ${r.join(`
8697
8699
  }
8698
8700
  )
8699
8701
  ] }),
8700
- !m && os && Vt.length > 0 && /* @__PURE__ */ _("div", { className: "relative", children: [
8702
+ !m && os && Ht.length > 0 && /* @__PURE__ */ _("div", { className: "relative", children: [
8701
8703
  /* @__PURE__ */ _(
8702
8704
  "button",
8703
8705
  {
@@ -8705,7 +8707,7 @@ ${r.join(`
8705
8707
  onClick: () => Zo((e) => !e),
8706
8708
  className: De(
8707
8709
  "flex h-9 items-center gap-1.5 rounded-md border px-3 text-[12px] font-medium transition-colors",
8708
- st ? "border-amber-300 bg-amber-50 text-amber-700 hover:bg-amber-100 dark:border-amber-500/40 dark:bg-amber-500/10 dark:text-amber-400" : "border-slate-200 bg-white text-slate-600 hover:bg-slate-50 dark:border-border dark:bg-card dark:text-slate-300"
8710
+ Je ? "border-amber-300 bg-amber-50 text-amber-700 hover:bg-amber-100 dark:border-amber-500/40 dark:bg-amber-500/10 dark:text-amber-400" : "border-slate-200 bg-white text-slate-600 hover:bg-slate-50 dark:border-border dark:bg-card dark:text-slate-300"
8709
8711
  ),
8710
8712
  title: "Choose which version the form and actions apply to",
8711
8713
  children: [
@@ -8714,11 +8716,11 @@ ${r.join(`
8714
8716
  {
8715
8717
  className: De(
8716
8718
  "h-1.5 w-1.5 shrink-0 rounded-full",
8717
- st ? "bg-amber-400" : "bg-slate-400"
8719
+ Je ? "bg-amber-400" : "bg-slate-400"
8718
8720
  )
8719
8721
  }
8720
8722
  ),
8721
- /* @__PURE__ */ a("span", { className: "max-w-[160px] truncate", children: st ? ((hf = Vt.find(
8723
+ /* @__PURE__ */ a("span", { className: "max-w-[160px] truncate", children: Je ? ((hf = Ht.find(
8722
8724
  (e) => e.id === He
8723
8725
  )) == null ? void 0 : hf.title) ?? "Addendum" : "Viewing: Current record" }),
8724
8726
  /* @__PURE__ */ a(fi, { className: "h-3 w-3 opacity-60" })
@@ -8743,7 +8745,7 @@ ${r.join(`
8743
8745
  ]
8744
8746
  }
8745
8747
  ),
8746
- Vt.map((e) => {
8748
+ Ht.map((e) => {
8747
8749
  var t, n;
8748
8750
  return /* @__PURE__ */ _(
8749
8751
  "button",
@@ -8787,15 +8789,15 @@ ${r.join(`
8787
8789
  })
8788
8790
  ] })
8789
8791
  ] }),
8790
- !m && ue && (!un || st) && /* @__PURE__ */ a(
8792
+ !m && ue && (!un || Je) && /* @__PURE__ */ a(
8791
8793
  nm,
8792
8794
  {
8793
8795
  wrap: !1,
8794
- collection: dn,
8795
- item: cn,
8796
+ collection: It,
8797
+ item: Ut,
8796
8798
  onBeforeTransition: _s
8797
8799
  },
8798
- `${dn}:${cn}`
8800
+ `${It}:${Ut}`
8799
8801
  )
8800
8802
  ] })
8801
8803
  ]
@@ -8944,17 +8946,17 @@ ${r.join(`
8944
8946
  open: !0,
8945
8947
  onOpenChange: (e) => !e && Pi(!1),
8946
8948
  children: /* @__PURE__ */ _(_i, { className: "max-w-lg", children: [
8947
- /* @__PURE__ */ a(bi, { children: /* @__PURE__ */ a(vi, { className: "text-[15px]", children: "Move to state" }) }),
8949
+ /* @__PURE__ */ a(bi, { children: /* @__PURE__ */ a(vi, { className: "text-[15px]", children: Je ? "Move addendum to state" : "Move to state" }) }),
8948
8950
  /* @__PURE__ */ a(wi, { children: /* @__PURE__ */ a(
8949
8951
  rv,
8950
8952
  {
8951
- collection: i,
8952
- item: String(p),
8953
+ collection: It,
8954
+ item: String(Ut),
8953
8955
  standalone: !0,
8954
8956
  onCancel: () => Pi(!1),
8955
8957
  onMoved: () => {
8956
8958
  Pi(!1), X.invalidateQueries({
8957
- queryKey: ["pipeline-instance", i]
8959
+ queryKey: ["pipeline-instance", It]
8958
8960
  }), X.invalidateQueries({
8959
8961
  queryKey: ["item", i, String(p)]
8960
8962
  });
@@ -9138,8 +9140,8 @@ ${r.join(`
9138
9140
  children: /* @__PURE__ */ a(
9139
9141
  hv,
9140
9142
  {
9141
- collection: dn,
9142
- itemId: cn
9143
+ collection: It,
9144
+ itemId: Ut
9143
9145
  }
9144
9146
  )
9145
9147
  }
@@ -9165,7 +9167,7 @@ ${r.join(`
9165
9167
  ),
9166
9168
  { asChild: !0 }
9167
9169
  );
9168
- const o = Qe[s.field], l = Cc.get(s.field), c = o ? o.ids : l ?? (s.field in vu ? vu[s.field] : Wn[s.field]), d = st && !o && (as != null && s.field in as && String(M[s.field] ?? "") !== String(as[s.field] ?? "") || l !== void 0 && Math.round(
9170
+ const o = Qe[s.field], l = Cc.get(s.field), c = o ? o.ids : l ?? (s.field in vu ? vu[s.field] : Wn[s.field]), d = Je && !o && (as != null && s.field in as && String(M[s.field] ?? "") !== String(as[s.field] ?? "") || l !== void 0 && Math.round(
9169
9171
  Number(M[s.field] ?? 0) * 100
9170
9172
  ) !== Math.round(l * 100)), u = (() => {
9171
9173
  const C = s.thresholds;
@@ -9233,7 +9235,7 @@ ${r.join(`
9233
9235
  textClassName: y
9234
9236
  }
9235
9237
  ),
9236
- (s.cmsField.computed_type === "rollup" || (s.cmsField.computed_type === "read" || s.cmsField.computed_type === "write") && S) && !m && !st && /* @__PURE__ */ a(
9238
+ (s.cmsField.computed_type === "rollup" || (s.cmsField.computed_type === "read" || s.cmsField.computed_type === "write") && S) && !m && !Je && /* @__PURE__ */ a(
9237
9239
  t0,
9238
9240
  {
9239
9241
  collection: i,
@@ -9276,7 +9278,7 @@ ${r.join(`
9276
9278
  })()
9277
9279
  }
9278
9280
  ),
9279
- s.cmsField && !s.cmsField.computed_type && !m && !st && /* @__PURE__ */ a(
9281
+ s.cmsField && !s.cmsField.computed_type && !m && !Je && /* @__PURE__ */ a(
9280
9282
  e0,
9281
9283
  {
9282
9284
  collection: i,
@@ -9424,17 +9426,17 @@ ${r.join(`
9424
9426
  ]
9425
9427
  }
9426
9428
  ),
9427
- !I && Dt != null && /* @__PURE__ */ a(d_, { layoutId: Dt }),
9429
+ !I && Bt != null && /* @__PURE__ */ a(d_, { layoutId: Bt }),
9428
9430
  qm && /* @__PURE__ */ a(
9429
9431
  Tb,
9430
9432
  {
9431
- roles: nt.roles,
9432
- roleId: nt.roleId,
9433
+ roles: rt.roles,
9434
+ roleId: rt.roleId,
9433
9435
  onChange: (e) => {
9434
- nt.setRoleId(e), e || Zl(!1);
9436
+ rt.setRoleId(e), e || Zl(!1);
9435
9437
  },
9436
- preview: nt.preview,
9437
- loading: nt.loading
9438
+ preview: rt.preview,
9439
+ loading: rt.loading
9438
9440
  }
9439
9441
  ),
9440
9442
  !m && gn && /* @__PURE__ */ a("div", { className: "nvr-expand-in", children: /* @__PURE__ */ a(
@@ -9476,21 +9478,21 @@ ${r.join(`
9476
9478
  ]
9477
9479
  }
9478
9480
  ),
9479
- en.state === "offer" && !(Qt && !m) && /* @__PURE__ */ a("div", { className: "nvr-expand-in", children: /* @__PURE__ */ a(
9481
+ nn.state === "offer" && !(Vt && !m) && /* @__PURE__ */ a("div", { className: "nvr-expand-in", children: /* @__PURE__ */ a(
9480
9482
  j_,
9481
9483
  {
9482
- draft: en.draft,
9484
+ draft: nn.draft,
9483
9485
  labelFor: (e) => {
9484
9486
  var t;
9485
9487
  return ((t = (j ?? []).find((n) => n.field === e)) == null ? void 0 : t.label) ?? "";
9486
9488
  },
9487
9489
  current: $e.current,
9488
- recordChanged: !!en.draft.base_updated_at && !!($e.current.date_updated ?? $e.current.updated_at) && String(
9490
+ recordChanged: !!nn.draft.base_updated_at && !!($e.current.date_updated ?? $e.current.updated_at) && String(
9489
9491
  $e.current.date_updated ?? $e.current.updated_at
9490
- ) !== en.draft.base_updated_at,
9492
+ ) !== nn.draft.base_updated_at,
9491
9493
  onRestore: bp,
9492
9494
  onDiscard: vp,
9493
- createdId: en.createdId,
9495
+ createdId: nn.createdId,
9494
9496
  collection: i,
9495
9497
  renderValue: (e, t) => {
9496
9498
  var n;
@@ -9538,8 +9540,8 @@ ${r.join(`
9538
9540
  /* @__PURE__ */ a(
9539
9541
  Mb,
9540
9542
  {
9541
- collection: dn,
9542
- itemId: String(cn)
9543
+ collection: It,
9544
+ itemId: String(Ut)
9543
9545
  }
9544
9546
  ),
9545
9547
  !m && p && !I && /* @__PURE__ */ a(
@@ -9652,7 +9654,7 @@ ${r.join(`
9652
9654
  `summary-grid-${e.field}`
9653
9655
  ) : null;
9654
9656
  },
9655
- gridCounts: Wt
9657
+ gridCounts: Qt
9656
9658
  }
9657
9659
  ) : kt ? un ? ug() : cg() : lg() : /* @__PURE__ */ _(
9658
9660
  "div",
@@ -9732,8 +9734,8 @@ ${r.join(`
9732
9734
  label: e.label
9733
9735
  })) : we,
9734
9736
  groupedMap: Te,
9735
- ungroupedFields: Ht,
9736
- sectionGroups: Ut.filter(
9737
+ ungroupedFields: Jt,
9738
+ sectionGroups: Gt.filter(
9737
9739
  (e) => e.type !== "metadata"
9738
9740
  ),
9739
9741
  draft: M,
@@ -9743,7 +9745,7 @@ ${r.join(`
9743
9745
  staging: xe,
9744
9746
  stagedO2MRows: je,
9745
9747
  stagedO2MDeletes: We,
9746
- errors: tt,
9748
+ errors: nt,
9747
9749
  staleFields: Sc,
9748
9750
  changedFields: di,
9749
9751
  aliasEmptiness: {
@@ -9753,7 +9755,7 @@ ${r.join(`
9753
9755
  ...Object.fromEntries(
9754
9756
  [...qn].map((e) => [
9755
9757
  e,
9756
- e in Wt ? Wt[e] === 0 : null
9758
+ e in Qt ? Qt[e] === 0 : null
9757
9759
  ])
9758
9760
  ),
9759
9761
  ...Object.fromEntries(