@nivaro/react 0.3.24 → 0.3.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (27) hide show
  1. package/dist/hooks/useSessionRecorder.js +1 -1
  2. package/dist/index.d.ts +45 -26
  3. package/dist/shared/components/FilePreviewLightbox.js +56 -35
  4. package/dist/shared/components/ItemEditForm.js +4309 -4263
  5. package/dist/shared/components/PageRenderer.js +63 -62
  6. package/dist/shared/components/RecordReadView.js +229 -229
  7. package/dist/shared/components/ReportView.js +123 -120
  8. package/dist/shared/components/ai/AiMarkdown.js +168 -148
  9. package/dist/shared/components/chat/RoomParts.js +120 -119
  10. package/dist/shared/components/chat/chat-core.js +228 -224
  11. package/dist/shared/components/item-edit/FieldRenderer.js +333 -333
  12. package/dist/shared/components/item-edit/FieldRow.js +413 -394
  13. package/dist/shared/components/item-edit/GroupSection.js +637 -635
  14. package/dist/shared/components/item-edit/InlineGridField.js +89 -90
  15. package/dist/shared/components/item-edit/M2MCombobox.js +117 -116
  16. package/dist/shared/components/item-edit/QuickPicker.js +9 -9
  17. package/dist/shared/components/item-edit/RawEditSheet.js +80 -79
  18. package/dist/shared/components/item-edit/RelationCombobox.js +173 -167
  19. package/dist/shared/components/item-edit/RowMatchPanel.js +1 -1
  20. package/dist/shared/components/item-edit/m2m-invalidate.js +19 -0
  21. package/dist/shared/components/item-edit/record-lookups.js +15 -0
  22. package/dist/shared/components/item-edit/render-stability.js +147 -0
  23. package/dist/shared/components/layout-editor/FormMapButton.js +5 -4
  24. package/dist/shared/lib/picker-rank.js +21 -0
  25. package/dist/shared/lib/safe-href.js +10 -0
  26. package/dist/shared/lib/socket-realtime.js +107 -78
  27. package/package.json +6 -6
@@ -1,283 +1,285 @@
1
- import { jsx as e, jsxs as x, Fragment as wt } from "react/jsx-runtime";
2
- import { useQuery as de, useQueryClient as vt } from "@tanstack/react-query";
1
+ import { jsx as e, jsxs as x, Fragment as vt } from "react/jsx-runtime";
2
+ import { useQuery as ce, useQueryClient as St } from "@tanstack/react-query";
3
3
  import * as kt from "lucide-react";
4
- import { ChevronDown as St, Loader2 as Dt, User as $t, Mail as Ft } from "lucide-react";
5
- import rt, { useState as Q, useRef as ke, useEffect as ne } from "react";
6
- import { fieldDrilldownConfig as jt, useDrilldown as Ot, useOptionalNivaroClient as ue, useNavigation as qt } from "../../context.js";
7
- import { get as it, post as Bt } from "../../lib/commands.js";
8
- import { planFieldGrid as Lt, isEmptyValue as Ut, isFolded as Tt, readGroupStructure as It } from "../../lib/form-structure.js";
9
- import { reportSectionUse as st } from "../../lib/form-usage-beacon.js";
10
- import { useRecordReader as lt } from "../../lib/record-loader.js";
11
- import { choiceLabel as Mt, titleCase as at, cn as W, toLocalDateString as Se } from "../../lib/utils.js";
12
- import { DesignDropZone as Gt, designWrap as Vt } from "../layout-editor/DesignNode.js";
13
- import { useLayoutDesign as Pt, revealGroupKey as Ct } from "../layout-editor/design-context.js";
14
- import { GridGuides as we } from "../layout-editor/grid-guides.js";
15
- import { UserAvatar as Jt } from "../UserAvatar.js";
16
- import { DropdownMenu as Rt, DropdownMenuTrigger as zt, DropdownMenuContent as Kt, DropdownMenuItem as Ae } from "../ui/dropdown-menu.js";
17
- import { WidgetSlot as Ee } from "../WidgetSlot.js";
18
- import { FieldRow as ve } from "./FieldRow.js";
19
- import { FoldArea as Ht, RowGroupCell as Wt, rowMemberField as At } from "./form-structure-ui.js";
20
- import { useFormHelpVideos as Et, FormHelpVideoButton as Yt } from "./FormHelpVideoButton.js";
21
- import { applyDisplayTemplate as Qt, useContainerWidth as Zt, resolveColSpan as Ye } from "./helpers.js";
22
- import { SectionIntro as Xt } from "./LayoutContentBlock.js";
23
- import { UserChip as ot, OwnersInline as Qe, OwnersInlineCompact as en } from "./UserChip.js";
24
- import { UserRosterCluster as Un } from "./UserChip.js";
25
- function Ze(t) {
26
- if (typeof t != "string") return t ?? [];
4
+ import { ChevronDown as Dt, Loader2 as $t, User as Ft, Mail as jt } from "lucide-react";
5
+ import it, { useState as Y, useRef as ke, useEffect as ne, memo as Ot } from "react";
6
+ import { fieldDrilldownConfig as qt, useDrilldown as Bt, useOptionalNivaroClient as de, useNavigation as Lt } from "../../context.js";
7
+ import { get as st, post as Ut } from "../../lib/commands.js";
8
+ import { planFieldGrid as Mt, isEmptyValue as Tt, isFolded as Gt, readGroupStructure as It } from "../../lib/form-structure.js";
9
+ import { reportSectionUse as lt } from "../../lib/form-usage-beacon.js";
10
+ import { useRecordReader as at } from "../../lib/record-loader.js";
11
+ import { choiceLabel as Pt, titleCase as ot, cn as E, toLocalDateString as De } from "../../lib/utils.js";
12
+ import { DesignDropZone as Vt, designWrap as Ct } from "../layout-editor/DesignNode.js";
13
+ import { useLayoutDesign as Jt, revealGroupKey as Rt } from "../layout-editor/design-context.js";
14
+ import { GridGuides as ve } from "../layout-editor/grid-guides.js";
15
+ import { UserAvatar as zt } from "../UserAvatar.js";
16
+ import { DropdownMenu as Ht, DropdownMenuTrigger as Kt, DropdownMenuContent as Et, DropdownMenuItem as Ae } from "../ui/dropdown-menu.js";
17
+ import { WidgetSlot as Ye } from "../WidgetSlot.js";
18
+ import { FieldRow as Se } from "./FieldRow.js";
19
+ import { useFormHelpVideos as Wt, FormHelpVideoButton as At } from "./FormHelpVideoButton.js";
20
+ import { FoldArea as Yt, RowGroupCell as Qt, rowMemberField as Zt } from "./form-structure-ui.js";
21
+ import { applyDisplayTemplate as Xt, useContainerWidth as en, resolveColSpan as Qe } from "./helpers.js";
22
+ import { SectionIntro as tn } from "./LayoutContentBlock.js";
23
+ import { invalidateM2MFor as nn } from "./m2m-invalidate.js";
24
+ import { groupSectionPropsEqual as rn } from "./render-stability.js";
25
+ import { UserChip as ct, OwnersInline as Ze, OwnersInlineCompact as sn } from "./UserChip.js";
26
+ import { UserRosterCluster as Vn } from "./UserChip.js";
27
+ function Xe(n) {
28
+ if (typeof n != "string") return n ?? [];
27
29
  try {
28
- return JSON.parse(t);
30
+ return JSON.parse(n);
29
31
  } catch {
30
32
  return [];
31
33
  }
32
34
  }
33
- function tn({
34
- relCollection: t,
35
- relId: r,
35
+ function ln({
36
+ relCollection: n,
37
+ relId: t,
36
38
  entries: i,
37
- separator: u
39
+ separator: a
38
40
  }) {
39
- const s = ue(), l = lt(), n = String(r), m = i.some((g) => g.field.includes(".")) ? ["id", ...i.map((g) => g.field)].join(",") : null, { data: h } = de({
40
- queryKey: ["inline-display", t, n, m],
41
- queryFn: () => l(t, n, m),
42
- enabled: !!s && !!n,
41
+ const l = de(), o = at(), r = String(t), p = i.some((f) => f.field.includes(".")) ? ["id", ...i.map((f) => f.field)].join(",") : null, { data: m } = ce({
42
+ queryKey: ["inline-display", n, r, p],
43
+ queryFn: () => o(n, r, p),
44
+ enabled: !!l && !!r,
43
45
  staleTime: 6e4
44
46
  });
45
- if (!h) return null;
46
- const S = (g) => {
47
- let f = h;
48
- for (const y of g.split(".")) {
49
- if (f == null || typeof f != "object") return;
50
- f = f[y];
47
+ if (!m) return null;
48
+ const S = (f) => {
49
+ let b = m;
50
+ for (const y of f.split(".")) {
51
+ if (b == null || typeof b != "object") return;
52
+ b = b[y];
51
53
  }
52
- return f;
54
+ return b;
53
55
  };
54
- if (u != null) {
55
- const g = (O) => {
56
- const k = S(O.field);
56
+ if (a != null) {
57
+ const f = (F) => {
58
+ const k = S(F.field);
57
59
  if (k == null || k === "") return null;
58
- const D = O.format ?? "text";
60
+ const D = F.format ?? "text";
59
61
  if (D === "date" || D === "datetime")
60
62
  try {
61
- return Se(k);
63
+ return De(k);
62
64
  } catch {
63
65
  return String(k);
64
66
  }
65
67
  return D === "boolean" ? k ? "Yes" : "No" : String(k);
66
- }, f = [];
68
+ }, b = [];
67
69
  let y = [];
68
- for (const O of i)
69
- O.line_break && y.length > 0 ? (f.push(y), y = [O]) : y.push(O);
70
- y.length > 0 && f.push(y);
71
- const B = f.map(
72
- (O) => O.map((k) => {
73
- const D = g(k);
70
+ for (const F of i)
71
+ F.line_break && y.length > 0 ? (b.push(y), y = [F]) : y.push(F);
72
+ y.length > 0 && b.push(y);
73
+ const q = b.map(
74
+ (F) => F.map((k) => {
75
+ const D = f(k);
74
76
  return D ? { label: k.label ?? null, display: D } : null;
75
77
  }).filter(Boolean)
76
- ).filter((O) => O.length > 0);
77
- return B.length === 0 ? null : /* @__PURE__ */ e("div", { className: "mt-1", children: B.map((O, k) => (
78
+ ).filter((F) => F.length > 0);
79
+ return q.length === 0 ? null : /* @__PURE__ */ e("div", { className: "mt-1", children: q.map((F, k) => (
78
80
  // biome-ignore lint/suspicious/noArrayIndexKey: stable line order
79
- /* @__PURE__ */ e("p", { className: "text-[12px] text-slate-500 dark:text-slate-400", children: O.map((D, J) => (
81
+ /* @__PURE__ */ e("p", { className: "text-[12px] text-slate-500 dark:text-slate-400", children: F.map((D, M) => (
80
82
  // biome-ignore lint/suspicious/noArrayIndexKey: stable token order
81
- /* @__PURE__ */ x(rt.Fragment, { children: [
82
- J > 0 && u,
83
+ /* @__PURE__ */ x(it.Fragment, { children: [
84
+ M > 0 && a,
83
85
  D.label && /* @__PURE__ */ x("span", { className: "font-semibold text-slate-600 dark:text-slate-300", children: [
84
86
  D.label,
85
87
  ":"
86
88
  ] }),
87
89
  D.label ? " " : "",
88
90
  D.display
89
- ] }, J)
91
+ ] }, M)
90
92
  )) }, k)
91
93
  )) });
92
94
  }
93
- const o = i.map((g) => {
94
- const f = S(g.field);
95
- if (f == null || f === "") return null;
96
- const y = g.format ?? "text";
97
- let B;
95
+ const c = i.map((f) => {
96
+ const b = S(f.field);
97
+ if (b == null || b === "") return null;
98
+ const y = f.format ?? "text";
99
+ let q;
98
100
  if (y === "date" || y === "datetime")
99
101
  try {
100
- B = Se(f);
102
+ q = De(b);
101
103
  } catch {
102
- B = String(f);
104
+ q = String(b);
103
105
  }
104
- else y === "boolean" ? B = f ? "Yes" : "No" : B = String(f);
105
- return { label: g.label, display: B };
106
+ else y === "boolean" ? q = b ? "Yes" : "No" : q = String(b);
107
+ return { label: f.label, display: q };
106
108
  }).filter(Boolean);
107
- return o.length === 0 ? null : /* @__PURE__ */ e("div", { className: "mt-1 rounded border border-slate-200 bg-slate-50 dark:border-slate-700 dark:bg-slate-800/50 px-3 py-1.5 space-y-0.5", children: o.map((g, f) => (
109
+ return c.length === 0 ? null : /* @__PURE__ */ e("div", { className: "mt-1 rounded border border-slate-200 bg-slate-50 dark:border-slate-700 dark:bg-slate-800/50 px-3 py-1.5 space-y-0.5", children: c.map((f, b) => (
108
110
  // biome-ignore lint/suspicious/noArrayIndexKey: stable order from config
109
111
  /* @__PURE__ */ x("div", { className: "flex items-baseline gap-2", children: [
110
- g.label && /* @__PURE__ */ e("span", { className: "shrink-0 min-w-[56px] text-[10px] font-medium text-slate-400", children: g.label }),
111
- /* @__PURE__ */ e("span", { className: "text-[12px] text-slate-700 dark:text-slate-300 truncate", children: g.display })
112
- ] }, f)
112
+ f.label && /* @__PURE__ */ e("span", { className: "shrink-0 min-w-[56px] text-[10px] font-medium text-slate-400", children: f.label }),
113
+ /* @__PURE__ */ e("span", { className: "text-[12px] text-slate-700 dark:text-slate-300 truncate", children: f.display })
114
+ ] }, b)
113
115
  )) });
114
116
  }
115
- function nn(t) {
116
- if (!t) return null;
117
- const r = t.replace(/(^|-)([a-z])/g, (u, s, l) => l.toUpperCase()), i = kt[r];
117
+ function an(n) {
118
+ if (!n) return null;
119
+ const t = n.replace(/(^|-)([a-z])/g, (a, l, o) => o.toUpperCase()), i = kt[t];
118
120
  return i || null;
119
121
  }
120
- function Xe(t) {
121
- if (!t.options) return {};
122
- if (typeof t.options == "object") return t.options;
122
+ function et(n) {
123
+ if (!n.options) return {};
124
+ if (typeof n.options == "object") return n.options;
123
125
  try {
124
- return JSON.parse(t.options);
126
+ return JSON.parse(n.options);
125
127
  } catch {
126
128
  return {};
127
129
  }
128
130
  }
129
- function De(t, r) {
130
- if (t == null || t === "") return "—";
131
- if (typeof t == "boolean") return t ? "Yes" : "No";
132
- const i = (r == null ? void 0 : r.interface) ?? "", u = (() => {
131
+ function $e(n, t) {
132
+ if (n == null || n === "") return "—";
133
+ if (typeof n == "boolean") return n ? "Yes" : "No";
134
+ const i = (t == null ? void 0 : t.interface) ?? "", a = (() => {
133
135
  try {
134
- const n = r != null && r.options ? JSON.parse(String(r.options)) : null;
135
- return (n == null ? void 0 : n.display_format) ?? null;
136
+ const r = t != null && t.options ? JSON.parse(String(t.options)) : null;
137
+ return (r == null ? void 0 : r.display_format) ?? null;
136
138
  } catch {
137
139
  return null;
138
140
  }
139
141
  })();
140
- if (u) {
141
- const n = Number(t);
142
- if (u === "currency" && Number.isFinite(n))
143
- return n.toLocaleString(void 0, { style: "currency", currency: "USD" });
144
- if (u === "percent" && Number.isFinite(n)) return `${(n * 100).toFixed(1)}%`;
145
- if (/^0\.0+$/.test(u) && Number.isFinite(n)) return n.toFixed(u.length - 2);
146
- if (u === "date" && typeof t == "string") {
147
- const a = t.length === 10 ? /* @__PURE__ */ new Date(`${t}T00:00:00`) : new Date(t);
148
- if (!Number.isNaN(a.getTime())) return a.toLocaleDateString();
142
+ if (a) {
143
+ const r = Number(n);
144
+ if (a === "currency" && Number.isFinite(r))
145
+ return r.toLocaleString(void 0, { style: "currency", currency: "USD" });
146
+ if (a === "percent" && Number.isFinite(r)) return `${(r * 100).toFixed(1)}%`;
147
+ if (/^0\.0+$/.test(a) && Number.isFinite(r)) return r.toFixed(a.length - 2);
148
+ if (a === "date" && typeof n == "string") {
149
+ const s = n.length === 10 ? /* @__PURE__ */ new Date(`${n}T00:00:00`) : new Date(n);
150
+ if (!Number.isNaN(s.getTime())) return s.toLocaleDateString();
149
151
  }
150
- if (u === "datetime" && typeof t == "string") {
151
- const a = new Date(t);
152
- if (!Number.isNaN(a.getTime())) return a.toLocaleString();
152
+ if (a === "datetime" && typeof n == "string") {
153
+ const s = new Date(n);
154
+ if (!Number.isNaN(s.getTime())) return s.toLocaleString();
153
155
  }
154
156
  }
155
- if (i === "duration" && Number.isFinite(Number(t))) {
156
- const n = Number(t);
157
- return `${Math.floor(n / 60)}:${String(Math.round(n % 60)).padStart(2, "0")}`;
157
+ if (i === "duration" && Number.isFinite(Number(n))) {
158
+ const r = Number(n);
159
+ return `${Math.floor(r / 60)}:${String(Math.round(r % 60)).padStart(2, "0")}`;
158
160
  }
159
- if (i === "rating" && Number.isFinite(Number(t)))
160
- return `${"★".repeat(Number(t))} (${t}/5)`;
161
- if (i === "checklist" && typeof t == "string")
161
+ if (i === "rating" && Number.isFinite(Number(n)))
162
+ return `${"★".repeat(Number(n))} (${n}/5)`;
163
+ if (i === "checklist" && typeof n == "string")
162
164
  try {
163
- const n = JSON.parse(t);
164
- if (Array.isArray(n)) return `${n.filter((a) => a == null ? void 0 : a.done).length}/${n.length} done`;
165
+ const r = JSON.parse(n);
166
+ if (Array.isArray(r)) return `${r.filter((s) => s == null ? void 0 : s.done).length}/${r.length} done`;
165
167
  } catch {
166
168
  }
167
- if (i === "address" && typeof t == "string" && t.trim().startsWith("{"))
169
+ if (i === "address" && typeof n == "string" && n.trim().startsWith("{"))
168
170
  try {
169
- const n = JSON.parse(t);
170
- return [n.street, n.city, n.state, n.zip].filter(Boolean).join(", ") || "—";
171
+ const r = JSON.parse(n);
172
+ return [r.street, r.city, r.state, r.zip].filter(Boolean).join(", ") || "—";
171
173
  } catch {
172
174
  }
173
175
  if (i === "toggle" || i === "boolean")
174
- return t ? "Yes" : "No";
175
- if (typeof t == "object") {
176
- if (Array.isArray(t)) return t.length ? `${t.length} items` : "—";
176
+ return n ? "Yes" : "No";
177
+ if (typeof n == "object") {
178
+ if (Array.isArray(n)) return n.length ? `${n.length} items` : "—";
177
179
  try {
178
- return JSON.stringify(t);
180
+ return JSON.stringify(n);
179
181
  } catch {
180
- return String(t);
182
+ return String(n);
181
183
  }
182
184
  }
183
- const s = String(t);
184
- if (i === "datetime" || i === "date" || /^\d{4}-\d{2}-\d{2}T/.test(s) || /^\d{4}-\d{2}-\d{2}$/.test(s))
185
+ const l = String(n);
186
+ if (i === "datetime" || i === "date" || /^\d{4}-\d{2}-\d{2}T/.test(l) || /^\d{4}-\d{2}-\d{2}$/.test(l))
185
187
  try {
186
- let n = /^\d{4}-\d{2}-\d{2}$/.test(s) || i === "date";
187
- if (!n && (r != null && r.options))
188
+ let r = /^\d{4}-\d{2}-\d{2}$/.test(l) || i === "date";
189
+ if (!r && (t != null && t.options))
188
190
  try {
189
- const m = typeof r.options == "string" ? JSON.parse(r.options) : r.options;
190
- m && m.date_mode === "date" && (n = !0);
191
+ const p = typeof t.options == "string" ? JSON.parse(t.options) : t.options;
192
+ p && p.date_mode === "date" && (r = !0);
191
193
  } catch {
192
194
  }
193
- const a = s.match(/^(\d{4})-(\d{2})-(\d{2})(?:T00:00:00(?:\.000)?Z)?$/);
194
- return a ? new Date(Number(a[1]), Number(a[2]) - 1, Number(a[3])).toLocaleDateString() : n ? new Date(s).toLocaleDateString() : new Date(s).toLocaleString();
195
+ const s = l.match(/^(\d{4})-(\d{2})-(\d{2})(?:T00:00:00(?:\.000)?Z)?$/);
196
+ return s ? new Date(Number(s[1]), Number(s[2]) - 1, Number(s[3])).toLocaleDateString() : r ? new Date(l).toLocaleDateString() : new Date(l).toLocaleString();
195
197
  } catch {
196
198
  }
197
- if ((i === "select-dropdown" || i === "radio-buttons") && r) {
198
- const a = Xe(r).choices;
199
- if (Array.isArray(a)) {
200
- const m = a.find((h) => String(h.value) === s);
201
- if (m) return Mt(m.text);
199
+ if ((i === "select-dropdown" || i === "radio-buttons") && t) {
200
+ const s = et(t).choices;
201
+ if (Array.isArray(s)) {
202
+ const p = s.find((m) => String(m.value) === l);
203
+ if (p) return Pt(p.text);
202
204
  }
203
205
  }
204
- const l = Number(s);
205
- if (!Number.isNaN(l) && s !== "" && r) {
206
- const n = Xe(r), a = n.format, m = typeof n.unit == "string" ? n.unit.trim() : "";
207
- if (m && !a) {
208
- const h = new Intl.NumberFormat(void 0, { maximumFractionDigits: 2 }).format(l);
209
- if (m === "$")
206
+ const o = Number(l);
207
+ if (!Number.isNaN(o) && l !== "" && t) {
208
+ const r = et(t), s = r.format, p = typeof r.unit == "string" ? r.unit.trim() : "";
209
+ if (p && !s) {
210
+ const m = new Intl.NumberFormat(void 0, { maximumFractionDigits: 2 }).format(o);
211
+ if (p === "$")
210
212
  try {
211
213
  return new Intl.NumberFormat(void 0, { style: "currency", currency: "USD" }).format(
212
- l
214
+ o
213
215
  );
214
216
  } catch {
215
- return `$${h}`;
217
+ return `$${m}`;
216
218
  }
217
- return m === "%" ? `${h}%` : `${h} ${m}`;
219
+ return p === "%" ? `${m}%` : `${m} ${p}`;
218
220
  }
219
- if (a === "currency")
221
+ if (s === "currency")
220
222
  try {
221
223
  return new Intl.NumberFormat(void 0, {
222
224
  style: "currency",
223
- currency: n.currency || "USD"
224
- }).format(l);
225
+ currency: r.currency || "USD"
226
+ }).format(o);
225
227
  } catch {
226
228
  }
227
- if (a === "int")
228
- return new Intl.NumberFormat(void 0, { maximumFractionDigits: 0 }).format(l);
229
- if (a === "decimal") {
230
- const h = typeof n.precision == "number" ? n.precision : 2;
229
+ if (s === "int")
230
+ return new Intl.NumberFormat(void 0, { maximumFractionDigits: 0 }).format(o);
231
+ if (s === "decimal") {
232
+ const m = typeof r.precision == "number" ? r.precision : 2;
231
233
  return new Intl.NumberFormat(void 0, {
232
- minimumFractionDigits: h,
233
- maximumFractionDigits: h
234
- }).format(l);
234
+ minimumFractionDigits: m,
235
+ maximumFractionDigits: m
236
+ }).format(o);
235
237
  }
236
238
  }
237
- return !s.includes(" ") && !s.includes("@") && !/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(s) && !/^\d+$/.test(s) && (s.includes("_") || s.includes("-") || /^[a-z]/.test(s)) ? at(s) : s;
239
+ return !l.includes(" ") && !l.includes("@") && !/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(l) && !/^\d+$/.test(l) && (l.includes("_") || l.includes("-") || /^[a-z]/.test(l)) ? ot(l) : l;
238
240
  }
239
- function et({ userId: t }) {
240
- const r = ue(), { navigate: i, userUrl: u } = qt(), s = u ? u(t) : `/users/${t}`, { data: l } = de({
241
- queryKey: ["user-chip", t],
242
- queryFn: () => r.request(
243
- it(`/users/${t}`)
244
- ).then((m) => m.data ?? null),
245
- enabled: !!r && !!t,
241
+ function tt({ userId: n }) {
242
+ const t = de(), { navigate: i, userUrl: a } = Lt(), l = a ? a(n) : `/users/${n}`, { data: o } = ce({
243
+ queryKey: ["user-chip", n],
244
+ queryFn: () => t.request(
245
+ st(`/users/${n}`)
246
+ ).then((p) => p.data ?? null),
247
+ enabled: !!t && !!n,
246
248
  staleTime: 12e4
247
- }), n = l ? [l.first_name, l.last_name].filter(Boolean).join(" ") || l.email : t, a = n.split(" ").map((m) => m[0]).filter(Boolean).slice(0, 2).join("").toUpperCase();
248
- return /* @__PURE__ */ x(Rt, { children: [
249
- /* @__PURE__ */ e(zt, { asChild: !0, children: /* @__PURE__ */ x("span", { className: "inline-flex cursor-pointer items-center gap-1 rounded-full bg-slate-100 py-px pl-0.5 pr-2 hover:bg-slate-200 transition-colors", children: [
249
+ }), r = o ? [o.first_name, o.last_name].filter(Boolean).join(" ") || o.email : n, s = r.split(" ").map((p) => p[0]).filter(Boolean).slice(0, 2).join("").toUpperCase();
250
+ return /* @__PURE__ */ x(Ht, { children: [
251
+ /* @__PURE__ */ e(Kt, { asChild: !0, children: /* @__PURE__ */ x("span", { className: "inline-flex cursor-pointer items-center gap-1 rounded-full bg-slate-100 py-px pl-0.5 pr-2 hover:bg-slate-200 transition-colors", children: [
250
252
  /* @__PURE__ */ e(
251
- Jt,
253
+ zt,
252
254
  {
253
- userId: t,
255
+ userId: n,
254
256
  className: "h-4 w-4",
255
- fallback: /* @__PURE__ */ e("span", { className: "flex h-4 w-4 shrink-0 items-center justify-center rounded-full bg-nvr-cyan/20 text-[9px] font-bold text-nvr-navy dark:text-nvr-cyan", children: a })
257
+ fallback: /* @__PURE__ */ e("span", { className: "flex h-4 w-4 shrink-0 items-center justify-center rounded-full bg-nvr-cyan/20 text-[9px] font-bold text-nvr-navy dark:text-nvr-cyan", children: s })
256
258
  }
257
259
  ),
258
- /* @__PURE__ */ e("span", { className: "text-[11px] text-slate-600", children: n })
260
+ /* @__PURE__ */ e("span", { className: "text-[11px] text-slate-600", children: r })
259
261
  ] }) }),
260
- /* @__PURE__ */ x(Kt, { align: "start", className: "text-[12px]", children: [
261
- s && /* @__PURE__ */ x(
262
+ /* @__PURE__ */ x(Et, { align: "start", className: "text-[12px]", children: [
263
+ l && /* @__PURE__ */ x(
262
264
  Ae,
263
265
  {
264
266
  className: "gap-2 text-[12px] cursor-pointer",
265
- onSelect: () => i(s),
267
+ onSelect: () => i(l),
266
268
  children: [
267
- /* @__PURE__ */ e($t, { className: "h-3.5 w-3.5" }),
269
+ /* @__PURE__ */ e(Ft, { className: "h-3.5 w-3.5" }),
268
270
  " View profile"
269
271
  ]
270
272
  }
271
273
  ),
272
- (l == null ? void 0 : l.email) && /* @__PURE__ */ x(
274
+ (o == null ? void 0 : o.email) && /* @__PURE__ */ x(
273
275
  Ae,
274
276
  {
275
277
  className: "gap-2 text-[12px] cursor-pointer",
276
278
  onSelect: () => {
277
- window.location.href = `mailto:${l.email}`;
279
+ window.location.href = `mailto:${o.email}`;
278
280
  },
279
281
  children: [
280
- /* @__PURE__ */ e(Ft, { className: "h-3.5 w-3.5" }),
282
+ /* @__PURE__ */ e(jt, { className: "h-3.5 w-3.5" }),
281
283
  " Send email"
282
284
  ]
283
285
  }
@@ -285,39 +287,39 @@ function et({ userId: t }) {
285
287
  ] })
286
288
  ] });
287
289
  }
288
- function rn({
289
- collection: t,
290
- itemId: r,
290
+ function on({
291
+ collection: n,
292
+ itemId: t,
291
293
  layoutId: i,
292
- attachField: u,
293
- filenameTemplate: s,
294
- label: l
294
+ attachField: a,
295
+ filenameTemplate: l,
296
+ label: o
295
297
  }) {
296
- const n = ue(), a = vt(), [m, h] = Q(!1), S = async () => {
297
- if (!(!n || m || !u)) {
298
- h(!0);
298
+ const r = de(), s = St(), [p, m] = Y(!1), S = async () => {
299
+ if (!(!r || p || !a)) {
300
+ m(!0);
299
301
  try {
300
- await n.request(
301
- Bt(`/collection-layouts/${i}/generate-and-attach`, {
302
- collection: t,
303
- item_id: r,
304
- attach_field: u,
305
- filename_template: s ?? void 0
302
+ await r.request(
303
+ Ut(`/collection-layouts/${i}/generate-and-attach`, {
304
+ collection: n,
305
+ item_id: t,
306
+ attach_field: a,
307
+ filename_template: l ?? void 0
306
308
  })
307
- ), a.invalidateQueries({ queryKey: ["m2m-items"] }), a.invalidateQueries({ queryKey: ["items", t, r] });
309
+ ), nn(s, [t]), s.invalidateQueries({ queryKey: ["items", n, t] });
308
310
  } catch {
309
311
  } finally {
310
- h(!1);
312
+ m(!1);
311
313
  }
312
314
  }
313
- }, o = !u;
315
+ }, c = !a;
314
316
  return /* @__PURE__ */ x(
315
317
  "button",
316
318
  {
317
319
  type: "button",
318
320
  onClick: S,
319
- disabled: m || o,
320
- title: o ? "Configure PDF field in Data Model → Layouts" : void 0,
321
+ disabled: p || c,
322
+ title: c ? "Configure PDF field in Data Model → Layouts" : void 0,
321
323
  className: "inline-flex items-center gap-1.5 rounded-md border border-nvr-cyan/40 bg-nvr-cyan/10 px-3 py-1.5 text-[12px] font-medium text-nvr-navy hover:bg-nvr-cyan/20 disabled:cursor-not-allowed disabled:opacity-40 dark:text-nvr-cyan",
322
324
  children: [
323
325
  /* @__PURE__ */ x(
@@ -337,55 +339,55 @@ function rn({
337
339
  ]
338
340
  }
339
341
  ),
340
- m ? "Generating…" : l
342
+ p ? "Generating…" : o
341
343
  ]
342
344
  }
343
345
  );
344
346
  }
345
347
  function re({
346
- relCollection: t,
347
- id: r,
348
+ relCollection: n,
349
+ id: t,
348
350
  className: i
349
351
  }) {
350
- var f;
351
- const u = ue(), s = lt(), l = r != null && r !== "" ? String(r) : null, { data: n } = de({
352
- queryKey: ["col-meta-dt", t],
353
- queryFn: () => u.request(
354
- it(`/collections/${t}`)
352
+ var b;
353
+ const a = de(), l = at(), o = t != null && t !== "" ? String(t) : null, { data: r } = ce({
354
+ queryKey: ["col-meta-dt", n],
355
+ queryFn: () => a.request(
356
+ st(`/collections/${n}`)
355
357
  ).then((y) => y.data).catch(() => ({})),
356
- enabled: !!u && !!l,
358
+ enabled: !!a && !!o,
357
359
  staleTime: 3e5
358
- }), a = (((f = n == null ? void 0 : n.display_template) == null ? void 0 : f.match(/\{\{\s*[^}]+?\s*\}\}/g)) ?? []).map((y) => y.replace(/[{}\s]/g, "")).filter((y) => y.includes(".")), m = a.length ? ["id", ...a].join(",") : null, { data: h, isLoading: S } = de({
359
- queryKey: ["rel-display", t, l, m],
360
- queryFn: () => s(t, l, m),
361
- enabled: !!u && !!l && n !== void 0,
360
+ }), s = (((b = r == null ? void 0 : r.display_template) == null ? void 0 : b.match(/\{\{\s*[^}]+?\s*\}\}/g)) ?? []).map((y) => y.replace(/[{}\s]/g, "")).filter((y) => y.includes(".")), p = s.length ? ["id", ...s].join(",") : null, { data: m, isLoading: S } = ce({
361
+ queryKey: ["rel-display", n, o, p],
362
+ queryFn: () => l(n, o, p),
363
+ enabled: !!a && !!o && r !== void 0,
362
364
  staleTime: 6e4
363
365
  });
364
- if (!l) return /* @__PURE__ */ e("span", { children: "—" });
365
- if (S || u && n === void 0)
366
+ if (!o) return /* @__PURE__ */ e("span", { children: "—" });
367
+ if (S || a && r === void 0)
366
368
  return /* @__PURE__ */ e("span", { className: "animate-pulse h-3 w-20 rounded bg-slate-200 dark:bg-[hsl(var(--nvr-skeleton))] inline-block" });
367
- const o = i ?? "text-[13px] text-slate-700";
368
- if (!h) return /* @__PURE__ */ e("span", { className: o, children: l });
369
- const g = n != null && n.display_template ? Qt(n.display_template, h) : String(h.name ?? h.title ?? h.label ?? h.display_name ?? l);
370
- return /* @__PURE__ */ e("span", { className: o, children: g });
369
+ const c = i ?? "text-[13px] text-slate-700";
370
+ if (!m) return /* @__PURE__ */ e("span", { className: c, children: o });
371
+ const f = r != null && r.display_template ? Xt(r.display_template, m) : String(m.name ?? m.title ?? m.label ?? m.display_name ?? o);
372
+ return /* @__PURE__ */ e("span", { className: c, children: f });
371
373
  }
372
- function tt({ userId: t }) {
373
- return /* @__PURE__ */ e(ot, { userId: t, size: "compact" });
374
+ function nt({ userId: n }) {
375
+ return /* @__PURE__ */ e(ct, { userId: n, size: "compact" });
374
376
  }
375
- function nt({
376
- relCollection: t,
377
- id: r,
377
+ function rt({
378
+ relCollection: n,
379
+ id: t,
378
380
  drillConfig: i
379
381
  }) {
380
- const u = Ot(), s = /* @__PURE__ */ e(re, { relCollection: t, id: r });
381
- return !u || r == null || r === "" ? s : /* @__PURE__ */ e(
382
+ const a = Bt(), l = /* @__PURE__ */ e(re, { relCollection: n, id: t });
383
+ return !a || t == null || t === "" ? l : /* @__PURE__ */ e(
382
384
  "button",
383
385
  {
384
386
  type: "button",
385
- onClick: (n) => {
386
- n.stopPropagation(), u.open({
387
- collection: t,
388
- itemId: String(r),
387
+ onClick: (r) => {
388
+ r.stopPropagation(), a.open({
389
+ collection: n,
390
+ itemId: String(t),
389
391
  layoutId: (i == null ? void 0 : i.layout_id) ?? null,
390
392
  // Header drills open wide by default — the sheet renders the target's
391
393
  // full detail layout, which is unreadable in a narrow panel.
@@ -396,188 +398,188 @@ function nt({
396
398
  children: /* @__PURE__ */ e(
397
399
  re,
398
400
  {
399
- relCollection: t,
400
- id: r,
401
+ relCollection: n,
402
+ id: t,
401
403
  className: "text-[13px] text-slate-700 underline decoration-slate-300 underline-offset-[3px] group-hover/drill:decoration-[#0284c7] group-hover/drill:text-[#0284c7] dark:text-slate-200 dark:decoration-slate-600"
402
404
  }
403
405
  )
404
406
  }
405
407
  );
406
408
  }
407
- function sn(t) {
408
- const [r, i] = Q(!1), u = ke(!0), s = ke(JSON.stringify(t ?? null));
409
+ function cn(n) {
410
+ const [t, i] = Y(!1), a = ke(!0), l = ke(JSON.stringify(n ?? null));
409
411
  return ne(() => {
410
- const l = JSON.stringify(t ?? null);
411
- if (u.current) {
412
- u.current = !1, s.current = l;
412
+ const o = JSON.stringify(n ?? null);
413
+ if (a.current) {
414
+ a.current = !1, l.current = o;
413
415
  return;
414
416
  }
415
- if (l === s.current) return;
416
- s.current = l, i(!1);
417
- const n = window.setTimeout(() => i(!0), 0), a = window.setTimeout(() => i(!1), 1200);
417
+ if (o === l.current) return;
418
+ l.current = o, i(!1);
419
+ const r = window.setTimeout(() => i(!0), 0), s = window.setTimeout(() => i(!1), 1200);
418
420
  return () => {
419
- window.clearTimeout(n), window.clearTimeout(a);
421
+ window.clearTimeout(r), window.clearTimeout(s);
420
422
  };
421
- }, [t]), r ? "nvr-value-pulse" : "";
423
+ }, [n]), t ? "nvr-value-pulse" : "";
422
424
  }
423
- function On({
424
- field: t,
425
- val: r,
425
+ function Tn({
426
+ field: n,
427
+ val: t,
426
428
  relations: i,
427
- collection: u,
428
- displayFormat: s,
429
- textClassName: l
429
+ collection: a,
430
+ displayFormat: l,
431
+ textClassName: o
430
432
  }) {
431
- const n = sn(r), a = W(l ?? "text-[13px] text-slate-900 dark:text-slate-100", n), m = jt(t) ?? { enabled: !0, layout_id: null, width: null }, h = i.find(
432
- (o) => o.one_collection === u && o.one_field === t.field && o.junction_field
433
+ const r = cn(t), s = E(o ?? "text-[13px] text-slate-900 dark:text-slate-100", r), p = qt(n) ?? { enabled: !0, layout_id: null, width: null }, m = i.find(
434
+ (c) => c.one_collection === a && c.one_field === n.field && c.junction_field
433
435
  );
434
- if (h) {
435
- const o = i.find(
436
- (y) => y.many_collection === h.many_collection && y.many_field === h.junction_field
437
- ), g = o == null ? void 0 : o.one_collection, f = Array.isArray(r) ? r : r != null && r !== "" ? [r] : [];
438
- return !g || f.length === 0 ? /* @__PURE__ */ e("span", { className: "text-slate-300 dark:text-slate-600", children: "—" }) : g === "nivaro_users" ? /* @__PURE__ */ e("span", { className: "inline-flex flex-wrap gap-x-1 gap-y-0.5", children: f.map((y) => /* @__PURE__ */ e(tt, { userId: String(y) }, String(y))) }) : /* @__PURE__ */ e("span", { className: "inline-flex flex-wrap gap-x-1.5", children: f.map((y) => /* @__PURE__ */ e(
439
- nt,
436
+ if (m) {
437
+ const c = i.find(
438
+ (y) => y.many_collection === m.many_collection && y.many_field === m.junction_field
439
+ ), f = c == null ? void 0 : c.one_collection, b = Array.isArray(t) ? t : t != null && t !== "" ? [t] : [];
440
+ return !f || b.length === 0 ? /* @__PURE__ */ e("span", { className: "text-slate-300 dark:text-slate-600", children: "—" }) : f === "nivaro_users" ? /* @__PURE__ */ e("span", { className: "inline-flex flex-wrap gap-x-1 gap-y-0.5", children: b.map((y) => /* @__PURE__ */ e(nt, { userId: String(y) }, String(y))) }) : /* @__PURE__ */ e("span", { className: "inline-flex flex-wrap gap-x-1.5", children: b.map((y) => /* @__PURE__ */ e(
441
+ rt,
440
442
  {
441
- relCollection: g,
443
+ relCollection: f,
442
444
  id: y,
443
- drillConfig: m
445
+ drillConfig: p
444
446
  },
445
447
  String(y)
446
448
  )) });
447
449
  }
448
450
  const S = i.find(
449
- (o) => o.many_collection === u && o.many_field === t.field && !o.junction_field
451
+ (c) => c.many_collection === a && c.many_field === n.field && !c.junction_field
450
452
  );
451
453
  if (S != null && S.one_collection) {
452
- const o = Array.isArray(r) ? r : r != null && r !== "" ? [r] : [];
453
- return o.length === 0 ? /* @__PURE__ */ e("span", { className: "text-slate-300 dark:text-slate-600", children: "—" }) : S.one_collection === "nivaro_users" ? /* @__PURE__ */ e("span", { className: "inline-flex flex-wrap gap-x-1 gap-y-0.5", children: o.map((g) => /* @__PURE__ */ e(tt, { userId: String(g) }, String(g))) }) : /* @__PURE__ */ e("span", { className: "inline-flex flex-wrap gap-x-1.5", children: o.map((g) => /* @__PURE__ */ e(
454
- nt,
454
+ const c = Array.isArray(t) ? t : t != null && t !== "" ? [t] : [];
455
+ return c.length === 0 ? /* @__PURE__ */ e("span", { className: "text-slate-300 dark:text-slate-600", children: "—" }) : S.one_collection === "nivaro_users" ? /* @__PURE__ */ e("span", { className: "inline-flex flex-wrap gap-x-1 gap-y-0.5", children: c.map((f) => /* @__PURE__ */ e(nt, { userId: String(f) }, String(f))) }) : /* @__PURE__ */ e("span", { className: "inline-flex flex-wrap gap-x-1.5", children: c.map((f) => /* @__PURE__ */ e(
456
+ rt,
455
457
  {
456
458
  relCollection: S.one_collection,
457
- id: g,
458
- drillConfig: m
459
+ id: f,
460
+ drillConfig: p
459
461
  },
460
- String(g)
462
+ String(f)
461
463
  )) });
462
464
  }
463
- if (r == null || r === "")
465
+ if (t == null || t === "")
464
466
  return /* @__PURE__ */ e("span", { className: "text-slate-300 dark:text-slate-600", children: "—" });
465
- if (s && s !== "text") {
466
- const o = Number(r);
467
- if (s === "currency" && !isNaN(o))
468
- return /* @__PURE__ */ e("span", { className: `font-semibold ${a}`, children: new Intl.NumberFormat(void 0, {
467
+ if (l && l !== "text") {
468
+ const c = Number(t);
469
+ if (l === "currency" && !isNaN(c))
470
+ return /* @__PURE__ */ e("span", { className: `font-semibold ${s}`, children: new Intl.NumberFormat(void 0, {
469
471
  style: "currency",
470
472
  currency: "USD",
471
473
  minimumFractionDigits: 2
472
- }).format(o) });
473
- if (s === "integer" && !isNaN(o))
474
- return /* @__PURE__ */ e("span", { className: `font-semibold ${a}`, children: new Intl.NumberFormat(void 0, { maximumFractionDigits: 0 }).format(Math.round(o)) });
475
- if (s === "decimal" && !isNaN(o))
476
- return /* @__PURE__ */ e("span", { className: `font-semibold ${a}`, children: new Intl.NumberFormat(void 0, { maximumFractionDigits: 2 }).format(o) });
477
- if (s === "percent" && !isNaN(o))
478
- return /* @__PURE__ */ e("span", { className: `font-semibold ${a}`, children: new Intl.NumberFormat(void 0, { style: "percent", maximumFractionDigits: 1 }).format(
479
- o / 100
474
+ }).format(c) });
475
+ if (l === "integer" && !isNaN(c))
476
+ return /* @__PURE__ */ e("span", { className: `font-semibold ${s}`, children: new Intl.NumberFormat(void 0, { maximumFractionDigits: 0 }).format(Math.round(c)) });
477
+ if (l === "decimal" && !isNaN(c))
478
+ return /* @__PURE__ */ e("span", { className: `font-semibold ${s}`, children: new Intl.NumberFormat(void 0, { maximumFractionDigits: 2 }).format(c) });
479
+ if (l === "percent" && !isNaN(c))
480
+ return /* @__PURE__ */ e("span", { className: `font-semibold ${s}`, children: new Intl.NumberFormat(void 0, { style: "percent", maximumFractionDigits: 1 }).format(
481
+ c / 100
480
482
  ) });
481
- if (s === "date")
483
+ if (l === "date")
482
484
  try {
483
- return /* @__PURE__ */ e("span", { className: `font-semibold ${a}`, children: Se(r) });
485
+ return /* @__PURE__ */ e("span", { className: `font-semibold ${s}`, children: De(t) });
484
486
  } catch {
485
487
  }
486
- if (s === "datetime")
488
+ if (l === "datetime")
487
489
  try {
488
- return /* @__PURE__ */ e("span", { className: `font-semibold ${a}`, children: new Date(String(r)).toLocaleString() });
490
+ return /* @__PURE__ */ e("span", { className: `font-semibold ${s}`, children: new Date(String(t)).toLocaleString() });
489
491
  } catch {
490
492
  }
491
493
  }
492
- return /* @__PURE__ */ e("span", { className: `font-semibold ${a}`, children: De(r, t) });
494
+ return /* @__PURE__ */ e("span", { className: `font-semibold ${s}`, children: $e(t, n) });
493
495
  }
494
- function ln({
495
- summaryFields: t,
496
- fields: r,
496
+ function dn({
497
+ summaryFields: n,
498
+ fields: t,
497
499
  draft: i,
498
- relations: u,
499
- collection: s,
500
- itemId: l,
501
- ownersCollection: n,
502
- ownersItemId: a,
503
- ownersAssignment: m,
504
- m2mCounts: h,
500
+ relations: a,
501
+ collection: l,
502
+ itemId: o,
503
+ ownersCollection: r,
504
+ ownersItemId: s,
505
+ ownersAssignment: p,
506
+ m2mCounts: m,
505
507
  o2mCounts: S,
506
- o2mAggValues: o,
507
- summaryAggConfigs: g,
508
- o2mLoading: f,
508
+ o2mAggValues: c,
509
+ summaryAggConfigs: f,
510
+ o2mLoading: b,
509
511
  hideEmpty: y
510
512
  }) {
511
- const B = t.map((N) => typeof N == "string" ? N : N.field), O = y ? B.filter((N) => {
512
- if (N === "__owners__" || f != null && f.has(N) || o && N in o) return !0;
513
- if (h && N in h) return (h[N] ?? 0) > 0;
513
+ const q = n.map((N) => typeof N == "string" ? N : N.field), F = y ? q.filter((N) => {
514
+ if (N === "__owners__" || b != null && b.has(N) || c && N in c) return !0;
515
+ if (m && N in m) return (m[N] ?? 0) > 0;
514
516
  if (S && N in S) return (S[N] ?? 0) > 0;
515
- const U = i[N];
516
- return U != null && U !== "" && !(Array.isArray(U) && U.length === 0);
517
- }) : B;
518
- if (O.length === 0) return null;
519
- const k = "text-[9px] font-semibold uppercase tracking-wider text-slate-400 dark:text-slate-500 shrink-0", D = "text-[12px] font-semibold text-slate-700 dark:text-slate-300", J = "text-[12px] text-slate-300 dark:text-slate-600", R = "flex items-baseline gap-1.5", me = (N) => {
517
+ const T = i[N];
518
+ return T != null && T !== "" && !(Array.isArray(T) && T.length === 0);
519
+ }) : q;
520
+ if (F.length === 0) return null;
521
+ const k = "text-[9px] font-semibold uppercase tracking-wider text-slate-400 dark:text-slate-500 shrink-0", D = "text-[12px] font-semibold text-slate-700 dark:text-slate-300", M = "text-[12px] text-slate-300 dark:text-slate-600", R = "flex items-baseline gap-1.5", ue = (N) => {
520
522
  if (N === "__owners__") {
521
- const d = (m == null ? void 0 : m.label_override) || "Owners";
523
+ const d = (p == null ? void 0 : p.label_override) || "Owners";
522
524
  return /* @__PURE__ */ x("div", { className: "flex items-center gap-1.5", children: [
523
525
  /* @__PURE__ */ e("span", { className: k, children: d }),
524
526
  /* @__PURE__ */ e(
525
- en,
527
+ sn,
526
528
  {
527
- collection: n ?? s,
528
- itemId: a ?? l
529
+ collection: r ?? l,
530
+ itemId: s ?? o
529
531
  }
530
532
  )
531
533
  ] });
532
534
  }
533
- const U = t.find((d) => (typeof d == "string" ? d : d.field) === N), ie = U && typeof U != "string" ? U.label : void 0, A = r.find((d) => d.field === N), I = ie || (A == null ? void 0 : A.label) || N.replace(/_/g, " ").replace(/\b\w/g, (d) => d.toUpperCase());
534
- if (f != null && f.has(N))
535
+ const T = n.find((d) => (typeof d == "string" ? d : d.field) === N), me = T && typeof T != "string" ? T.label : void 0, H = t.find((d) => d.field === N), P = me || (H == null ? void 0 : H.label) || N.replace(/_/g, " ").replace(/\b\w/g, (d) => d.toUpperCase());
536
+ if (b != null && b.has(N))
535
537
  return /* @__PURE__ */ x("div", { className: "flex items-center gap-1.5", children: [
536
- /* @__PURE__ */ e("span", { className: k, children: I }),
537
- /* @__PURE__ */ e(Dt, { className: "h-3 w-3 animate-spin text-slate-300" })
538
+ /* @__PURE__ */ e("span", { className: k, children: P }),
539
+ /* @__PURE__ */ e($t, { className: "h-3 w-3 animate-spin text-slate-300" })
538
540
  ] });
539
- if (o && N in o) {
540
- const d = g == null ? void 0 : g[N], L = (d == null ? void 0 : d.label) || I, $ = o[N];
541
- let G;
541
+ if (c && N in c) {
542
+ const d = f == null ? void 0 : f[N], L = (d == null ? void 0 : d.label) || P, O = c[N];
543
+ let U;
542
544
  if ((d == null ? void 0 : d.agg) === "count")
543
- G = String($);
545
+ U = String(O);
544
546
  else {
545
- const K = d != null && d.field_options ? (() => {
547
+ const W = d != null && d.field_options ? (() => {
546
548
  try {
547
549
  return JSON.parse(d.field_options);
548
550
  } catch {
549
551
  return {};
550
552
  }
551
- })() : {}, E = K.format;
552
- if (E === "currency")
553
+ })() : {}, A = W.format;
554
+ if (A === "currency")
553
555
  try {
554
- G = new Intl.NumberFormat(void 0, {
556
+ U = new Intl.NumberFormat(void 0, {
555
557
  style: "currency",
556
- currency: K.currency || "USD"
557
- }).format($);
558
+ currency: W.currency || "USD"
559
+ }).format(O);
558
560
  } catch {
559
- G = $.toLocaleString(void 0, { maximumFractionDigits: 2 });
561
+ U = O.toLocaleString(void 0, { maximumFractionDigits: 2 });
560
562
  }
561
- else if (E === "int")
562
- G = new Intl.NumberFormat(void 0, { maximumFractionDigits: 0 }).format($);
563
- else if (E === "decimal") {
564
- const Y = typeof K.precision == "number" ? K.precision : 2;
565
- G = new Intl.NumberFormat(void 0, {
566
- minimumFractionDigits: Y,
567
- maximumFractionDigits: Y
568
- }).format($);
563
+ else if (A === "int")
564
+ U = new Intl.NumberFormat(void 0, { maximumFractionDigits: 0 }).format(O);
565
+ else if (A === "decimal") {
566
+ const Q = typeof W.precision == "number" ? W.precision : 2;
567
+ U = new Intl.NumberFormat(void 0, {
568
+ minimumFractionDigits: Q,
569
+ maximumFractionDigits: Q
570
+ }).format(O);
569
571
  } else
570
- G = $.toLocaleString(void 0, { maximumFractionDigits: 2 });
572
+ U = O.toLocaleString(void 0, { maximumFractionDigits: 2 });
571
573
  }
572
574
  return /* @__PURE__ */ x("div", { className: R, children: [
573
575
  /* @__PURE__ */ e("span", { className: k, children: L }),
574
- /* @__PURE__ */ e("span", { className: D, children: G })
576
+ /* @__PURE__ */ e("span", { className: D, children: U })
575
577
  ] });
576
578
  }
577
- if (h && N in h) {
578
- const d = h[N];
579
+ if (m && N in m) {
580
+ const d = m[N];
579
581
  return /* @__PURE__ */ x("div", { className: R, children: [
580
- /* @__PURE__ */ e("span", { className: k, children: I }),
582
+ /* @__PURE__ */ e("span", { className: k, children: P }),
581
583
  /* @__PURE__ */ x("span", { className: D, children: [
582
584
  d,
583
585
  " item",
@@ -588,7 +590,7 @@ function ln({
588
590
  if (S && N in S) {
589
591
  const d = S[N];
590
592
  return /* @__PURE__ */ x("div", { className: R, children: [
591
- /* @__PURE__ */ e("span", { className: k, children: I }),
593
+ /* @__PURE__ */ e("span", { className: k, children: P }),
592
594
  /* @__PURE__ */ x("span", { className: D, children: [
593
595
  d,
594
596
  " row",
@@ -596,22 +598,22 @@ function ln({
596
598
  ] })
597
599
  ] });
598
600
  }
599
- const j = i[N], M = u.find(
600
- (d) => d.many_collection === s && d.many_field === N && !d.junction_field
601
+ const j = i[N], G = a.find(
602
+ (d) => d.many_collection === l && d.many_field === N && !d.junction_field
601
603
  );
602
- if (M != null && M.one_collection) {
604
+ if (G != null && G.one_collection) {
603
605
  const d = Array.isArray(j) ? j : j != null && j !== "" ? [j] : [];
604
606
  return /* @__PURE__ */ x("div", { className: R, children: [
605
- /* @__PURE__ */ e("span", { className: k, children: I }),
606
- d.length === 0 ? /* @__PURE__ */ e("span", { className: J, children: "—" }) : M.one_collection === "nivaro_users" ? /* @__PURE__ */ e("span", { className: "inline-flex flex-wrap gap-x-1.5 gap-y-0.5", children: d.map((L) => /* @__PURE__ */ e(et, { userId: String(L) }, String(L))) }) : /* @__PURE__ */ e("span", { className: "inline-flex flex-wrap gap-x-1.5", children: d.map((L) => /* @__PURE__ */ e(re, { relCollection: M.one_collection, id: L }, String(L))) })
607
+ /* @__PURE__ */ e("span", { className: k, children: P }),
608
+ d.length === 0 ? /* @__PURE__ */ e("span", { className: M, children: "—" }) : G.one_collection === "nivaro_users" ? /* @__PURE__ */ e("span", { className: "inline-flex flex-wrap gap-x-1.5 gap-y-0.5", children: d.map((L) => /* @__PURE__ */ e(tt, { userId: String(L) }, String(L))) }) : /* @__PURE__ */ e("span", { className: "inline-flex flex-wrap gap-x-1.5", children: d.map((L) => /* @__PURE__ */ e(re, { relCollection: G.one_collection, id: L }, String(L))) })
607
609
  ] });
608
610
  }
609
611
  if (Array.isArray(j)) {
610
- const d = u.find(($) => $.many_field === N && $.junction_field), L = d == null ? void 0 : d.one_collection;
612
+ const d = a.find((O) => O.many_field === N && O.junction_field), L = d == null ? void 0 : d.one_collection;
611
613
  return /* @__PURE__ */ x("div", { className: R, children: [
612
- /* @__PURE__ */ e("span", { className: k, children: I }),
613
- j.length === 0 ? /* @__PURE__ */ e("span", { className: J, children: "—" }) : L ? /* @__PURE__ */ e("span", { className: "inline-flex flex-wrap gap-x-1.5 gap-y-0.5", children: j.map(
614
- ($) => L === "nivaro_users" ? /* @__PURE__ */ e(et, { userId: String($) }, String($)) : /* @__PURE__ */ e(re, { relCollection: L, id: $ }, String($))
614
+ /* @__PURE__ */ e("span", { className: k, children: P }),
615
+ j.length === 0 ? /* @__PURE__ */ e("span", { className: M, children: "—" }) : L ? /* @__PURE__ */ e("span", { className: "inline-flex flex-wrap gap-x-1.5 gap-y-0.5", children: j.map(
616
+ (O) => L === "nivaro_users" ? /* @__PURE__ */ e(tt, { userId: String(O) }, String(O)) : /* @__PURE__ */ e(re, { relCollection: L, id: O }, String(O))
615
617
  ) }) : /* @__PURE__ */ x("span", { className: D, children: [
616
618
  j.length,
617
619
  " item",
@@ -620,136 +622,136 @@ function ln({
620
622
  ] });
621
623
  }
622
624
  return /* @__PURE__ */ x("div", { className: R, children: [
623
- /* @__PURE__ */ e("span", { className: k, children: I }),
624
- j == null || j === "" ? /* @__PURE__ */ e("span", { className: J, children: "—" }) : /* @__PURE__ */ e("span", { className: D, children: De(j, A) })
625
+ /* @__PURE__ */ e("span", { className: k, children: P }),
626
+ j == null || j === "" ? /* @__PURE__ */ e("span", { className: M, children: "—" }) : /* @__PURE__ */ e("span", { className: D, children: $e(j, H) })
625
627
  ] });
626
628
  };
627
- return /* @__PURE__ */ e("div", { className: "flex flex-wrap items-baseline gap-x-5 gap-y-1.5 border-t border-slate-100 dark:border-border/60 bg-slate-50/50 dark:bg-white/[0.015] px-5 py-2.5", children: O.map((N) => /* @__PURE__ */ e(rt.Fragment, { children: me(N) }, N)) });
629
+ return /* @__PURE__ */ e("div", { className: "flex flex-wrap items-baseline gap-x-5 gap-y-1.5 border-t border-slate-100 dark:border-border/60 bg-slate-50/50 dark:bg-white/[0.015] px-5 py-2.5", children: F.map((N) => /* @__PURE__ */ e(it.Fragment, { children: ue(N) }, N)) });
628
630
  }
629
- function qn({
631
+ const Gn = Ot(function({
630
632
  group: t,
631
- fields: r,
632
- draft: i,
633
- onChange: u,
634
- relations: s,
635
- collection: l,
636
- itemId: n,
637
- errors: a,
633
+ fields: i,
634
+ draft: a,
635
+ onChange: l,
636
+ relations: o,
637
+ collection: r,
638
+ itemId: s,
639
+ errors: p,
638
640
  visibleFields: m,
639
- lockedFields: h,
640
- layoutAiEnabled: S,
641
- displayOnly: o,
642
- renderField: g,
643
- onCountChange: f,
644
- isNew: y,
645
- fieldValues: B,
646
- isOpen: O,
647
- onToggle: k,
648
- summaryFields: D,
649
- m2mCounts: J,
650
- o2mCounts: R,
651
- o2mAggValues: me,
652
- summaryAggConfigs: N,
653
- o2mLoading: U,
654
- footerSlot: ie,
655
- ownersCollection: A,
656
- ownersItemId: I,
657
- ownersAssignment: j,
658
- pdfAssignment: M,
659
- pdfAttachField: d,
660
- pdfFilenameTemplate: L,
661
- layoutId: $,
662
- hideEmptySummary: G,
663
- widgetAssignments: K,
664
- widgetApiBase: E,
665
- fieldInlineDisplay: Y,
641
+ lockedFields: S,
642
+ layoutAiEnabled: c,
643
+ displayOnly: f,
644
+ renderField: b,
645
+ onCountChange: y,
646
+ isNew: q,
647
+ fieldValues: F,
648
+ isOpen: k,
649
+ onToggle: D,
650
+ summaryFields: M,
651
+ m2mCounts: R,
652
+ o2mCounts: ue,
653
+ o2mAggValues: N,
654
+ summaryAggConfigs: T,
655
+ o2mLoading: me,
656
+ footerSlot: H,
657
+ ownersCollection: P,
658
+ ownersItemId: j,
659
+ ownersAssignment: G,
660
+ pdfAssignment: d,
661
+ pdfAttachField: L,
662
+ pdfFilenameTemplate: O,
663
+ layoutId: U,
664
+ hideEmptySummary: W,
665
+ widgetAssignments: A,
666
+ widgetApiBase: Q,
667
+ fieldInlineDisplay: pe,
666
668
  swapConfig: V,
667
- swapped: $e,
668
- onSwapToggle: Fe,
669
+ swapped: Fe,
670
+ onSwapToggle: je,
669
671
  alternateFields: Z,
670
- alternateWidths: pe,
671
- deferred: se,
672
- onFirstOpen: le
672
+ alternateWidths: fe,
673
+ deferred: ie,
674
+ onFirstOpen: se
673
675
  }) {
674
- var Ge;
675
- const [ct, dt] = Q(t.is_collapsed ?? !1), [ut, mt] = Q(!1), F = Pt(), H = (p, _) => Vt(F, p, _, { asChild: !0 }), ae = (p) => ({ kind: "slot", field: p, group_key: t.key }), je = !!(F != null && F.showHidden), [Oe, qe] = Q({}), { data: fe } = Et(l), X = (F == null ? void 0 : F.fold) ?? null, ee = (F == null ? void 0 : F.reveal) ?? null, [Be, he] = Q(null);
676
+ var Pe;
677
+ const [dt, ut] = Y(t.is_collapsed ?? !1), [mt, pt] = Y(!1), $ = Jt(), K = (h, _) => Ct($, h, _, { asChild: !0 }), le = (h) => ({ kind: "slot", field: h, group_key: t.key }), Oe = !!($ != null && $.showHidden), [qe, Be] = Y({}), { data: he } = Wt(r), X = ($ == null ? void 0 : $.fold) ?? null, ee = ($ == null ? void 0 : $.reveal) ?? null, [Le, be] = Y(null);
676
678
  ne(() => {
677
- X && he(!X.open);
679
+ X && be(!X.open);
678
680
  }, [X == null ? void 0 : X.seq]), ne(() => {
679
- ee && Ct(ee.target) === t.key && he(!1);
681
+ ee && Rt(ee.target) === t.key && be(!1);
680
682
  }, [ee == null ? void 0 : ee.seq]);
681
- const Le = k !== void 0, z = Be ?? (Le ? !O : ct);
683
+ const Ue = D !== void 0, z = Le ?? (Ue ? !k : dt);
682
684
  ne(() => {
683
- se && !z && (le == null || le(t.key));
684
- }, [se, z, le, t.key]);
685
- const be = Be !== null ? () => he((p) => !p) : Le ? k : () => dt((p) => !p), Ue = !F && $ != null, ge = () => {
686
- Ue && st({ layoutId: Number($), collection: l, kind: "opened", key: t.key });
687
- }, pt = () => {
688
- z && ge(), be == null || be();
689
- }, ft = !o && r.some((p) => a[p.field]), Te = F ? "always" : t.visibility_mode ?? "always";
690
- if (Te === "new_only" && !y || Te === "existing_only" && y) return null;
691
- const te = K ?? [], ht = !y && te.some((p) => p.widget_id != null && Oe[p.field] === void 0);
692
- let oe = !1;
693
- if (t.hide_when_empty && B && !F && (oe = B.every(
685
+ ie && !z && (se == null || se(t.key));
686
+ }, [ie, z, se, t.key]);
687
+ const ge = Le !== null ? () => be((h) => !h) : Ue ? D : () => ut((h) => !h), Me = !$ && U != null, xe = () => {
688
+ Me && lt({ layoutId: Number(U), collection: r, kind: "opened", key: t.key });
689
+ }, ft = () => {
690
+ z && xe(), ge == null || ge();
691
+ }, ht = !f && i.some((h) => p[h.field]), Te = $ ? "always" : t.visibility_mode ?? "always";
692
+ if (Te === "new_only" && !q || Te === "existing_only" && q) return null;
693
+ const te = A ?? [], bt = !q && te.some((h) => h.widget_id != null && qe[h.field] === void 0);
694
+ let ae = !1;
695
+ if (t.hide_when_empty && F && !$ && (ae = F.every(
694
696
  (_) => _ == null || _ === "" || Array.isArray(_) && _.length === 0
695
- ) && !ht && te.every((_) => !Oe[_.field])), oe && te.length === 0) return null;
696
- const xe = ke(null), ye = Zt(xe), Ie = nn(t.icon), bt = je ? r : r.filter((p) => !p.hidden), Me = (Ge = fe == null ? void 0 : fe.sections) == null ? void 0 : Ge[t.key], gt = Array.isArray(Me) && Me.length > 0, xt = (p) => gt ? /* @__PURE__ */ x("div", { className: "relative", children: [
697
- p,
697
+ ) && !bt && te.every((_) => !qe[_.field])), ae && te.length === 0) return null;
698
+ const ye = ke(null), Ne = en(ye), Ge = an(t.icon), gt = Oe ? i : i.filter((h) => !h.hidden), Ie = (Pe = he == null ? void 0 : he.sections) == null ? void 0 : Pe[t.key], xt = Array.isArray(Ie) && Ie.length > 0, yt = (h) => xt ? /* @__PURE__ */ x("div", { className: "relative", children: [
699
+ h,
698
700
  /* @__PURE__ */ e("span", { className: "absolute right-[52px] top-1/2 flex -translate-y-1/2", children: /* @__PURE__ */ e(
699
- Yt,
701
+ At,
700
702
  {
701
- collection: l,
703
+ collection: r,
702
704
  kind: "section",
703
705
  name: t.key,
704
706
  label: t.label || t.key
705
707
  }
706
708
  ) })
707
- ] }) : p, Ne = (p) => je && (p.hidden || !(m.has(p.field) || !m.size));
709
+ ] }) : h, _e = (h) => Oe && (h.hidden || !(m.has(h.field) || !m.size));
708
710
  return /* @__PURE__ */ x(
709
711
  "div",
710
712
  {
711
- "data-loads-on-open": se ? "" : void 0,
713
+ "data-loads-on-open": ie ? "" : void 0,
712
714
  "data-section-key": t.key,
713
- className: W(
715
+ className: E(
714
716
  "nvr-section-enter rounded-xl border border-slate-200 bg-white dark:bg-card dark:border-border",
715
- o && "bg-slate-50/60 dark:bg-slate-900/20",
716
- oe && "hidden"
717
+ f && "bg-slate-50/60 dark:bg-slate-900/20",
718
+ ae && "hidden"
717
719
  ),
718
- onPointerDownCapture: (p) => {
719
- var _, c;
720
- (c = (_ = p.target) == null ? void 0 : _.closest) != null && c.call(_, "[data-usage-header]") || ge();
720
+ onPointerDownCapture: (h) => {
721
+ var _, u;
722
+ (u = (_ = h.target) == null ? void 0 : _.closest) != null && u.call(_, "[data-usage-header]") || xe();
721
723
  },
722
- onFocusCapture: (p) => {
723
- var _, c;
724
- (c = (_ = p.target) == null ? void 0 : _.closest) != null && c.call(_, "[data-usage-header]") || ge();
724
+ onFocusCapture: (h) => {
725
+ var _, u;
726
+ (u = (_ = h.target) == null ? void 0 : _.closest) != null && u.call(_, "[data-usage-header]") || xe();
725
727
  },
726
728
  children: [
727
- Ue && !oe && /* @__PURE__ */ e(an, { layoutId: Number($), collection: l, sectionKey: t.key }),
728
- xt(
729
+ Me && !ae && /* @__PURE__ */ e(un, { layoutId: Number(U), collection: r, sectionKey: t.key }),
730
+ yt(
729
731
  /* @__PURE__ */ x(
730
732
  "button",
731
733
  {
732
734
  type: "button",
733
735
  "data-usage-header": "",
734
- onClick: pt,
735
- "data-design-group-header": F ? "" : void 0,
736
- className: W(
736
+ onClick: ft,
737
+ "data-design-group-header": $ ? "" : void 0,
738
+ className: E(
737
739
  "flex w-full items-center gap-2 px-5 py-3 text-left hover:bg-slate-50/50 dark:hover:bg-white/[0.02] rounded-t-xl",
738
740
  // Round the bottom only when nothing renders below the header — an
739
741
  // expanded body (or collapsed summary strip) square-joins it, and a
740
742
  // rounded hover overlay would leave see-through notches at the seam.
741
- z && !(D && D.length > 0) && "rounded-b-xl"
743
+ z && !(M && M.length > 0) && "rounded-b-xl"
742
744
  ),
743
745
  children: [
744
- Ie && /* @__PURE__ */ e(Ie, { className: "h-3.5 w-3.5 shrink-0 text-slate-400 dark:text-slate-500" }),
746
+ Ge && /* @__PURE__ */ e(Ge, { className: "h-3.5 w-3.5 shrink-0 text-slate-400 dark:text-slate-500" }),
745
747
  /* @__PURE__ */ e("span", { className: "font-medium text-[13px] shrink-0 text-slate-800 dark:text-slate-200", children: t.label }),
746
748
  /* @__PURE__ */ e("span", { className: "flex-1" }),
747
- ft && /* @__PURE__ */ e("span", { className: "nvr-pop h-2 w-2 rounded-full bg-destructive shrink-0" }),
749
+ ht && /* @__PURE__ */ e("span", { className: "nvr-pop h-2 w-2 rounded-full bg-destructive shrink-0" }),
748
750
  /* @__PURE__ */ e(
749
- St,
751
+ Dt,
750
752
  {
751
- "data-design-pass": F ? "" : void 0,
752
- className: W(
753
+ "data-design-pass": $ ? "" : void 0,
754
+ className: E(
753
755
  "h-4 w-4 text-slate-400 dark:text-slate-500 transition-transform duration-200",
754
756
  z && "-rotate-90"
755
757
  )
@@ -759,93 +761,93 @@ function qn({
759
761
  }
760
762
  )
761
763
  ),
762
- z && D && D.length > 0 && /* @__PURE__ */ e(
763
- ln,
764
+ z && M && M.length > 0 && /* @__PURE__ */ e(
765
+ dn,
764
766
  {
765
- summaryFields: D,
766
- fields: r,
767
- draft: i,
768
- relations: s,
769
- collection: l,
770
- itemId: n,
771
- ownersCollection: A,
772
- ownersItemId: I,
773
- ownersAssignment: j,
774
- m2mCounts: J,
775
- o2mCounts: R,
776
- o2mAggValues: me,
777
- summaryAggConfigs: N,
778
- o2mLoading: U,
779
- hideEmpty: !!t.summary_hide_empty || !!G
767
+ summaryFields: M,
768
+ fields: i,
769
+ draft: a,
770
+ relations: o,
771
+ collection: r,
772
+ itemId: s,
773
+ ownersCollection: P,
774
+ ownersItemId: j,
775
+ ownersAssignment: G,
776
+ m2mCounts: R,
777
+ o2mCounts: ue,
778
+ o2mAggValues: N,
779
+ summaryAggConfigs: T,
780
+ o2mLoading: me,
781
+ hideEmpty: !!t.summary_hide_empty || !!W
780
782
  }
781
783
  ),
782
- z && !se && t.hide_when_empty && te.length > 0 && /* @__PURE__ */ e("div", { className: "hidden", children: te.filter((p) => p.widget_id != null).map((p) => /* @__PURE__ */ e(
783
- Ee,
784
+ z && !ie && t.hide_when_empty && te.length > 0 && /* @__PURE__ */ e("div", { className: "hidden", children: te.filter((h) => h.widget_id != null).map((h) => /* @__PURE__ */ e(
785
+ Ye,
784
786
  {
785
- widgetId: p.widget_id,
786
- inputBindings: Ze(p.input_bindings),
787
- itemDraft: i,
787
+ widgetId: h.widget_id,
788
+ inputBindings: Xe(h.input_bindings),
789
+ itemDraft: a,
788
790
  frameless: !0,
789
- apiBase: E,
790
- onContentChange: (_) => qe(
791
- (c) => c[p.field] === _ ? c : { ...c, [p.field]: _ }
791
+ apiBase: Q,
792
+ onContentChange: (_) => Be(
793
+ (u) => u[h.field] === _ ? u : { ...u, [h.field]: _ }
792
794
  )
793
795
  },
794
- p.field
796
+ h.field
795
797
  )) }),
796
798
  !z && /* @__PURE__ */ x("div", { className: "nvr-expand-in border-t border-slate-100 px-5 py-4", children: [
797
- !o && /* @__PURE__ */ e(Xt, { group: t, className: "mb-3" }),
799
+ !f && /* @__PURE__ */ e(tn, { group: t, className: "mb-3" }),
798
800
  (() => {
799
- const p = Lt(bt, {
800
- rows: o ? [] : It(t.swap_config).rows,
801
- folded: (c) => !o && Tt(c._overrides),
802
- keep: (c) => !!c.required,
803
- filled: (c) => !Ut(i[c.field]) || !!a[c.field]
804
- }), _ = p.units.map(
805
- (c) => c.kind === "row" ? {
806
- _k: `row:${c.row.key}`,
807
- sort: c.members[0].sort ?? 0,
801
+ const h = Mt(gt, {
802
+ rows: f ? [] : It(t.swap_config).rows,
803
+ folded: (u) => !f && Gt(u._overrides),
804
+ keep: (u) => !!u.required,
805
+ filled: (u) => !Tt(a[u.field]) || !!p[u.field]
806
+ }), _ = h.units.map(
807
+ (u) => u.kind === "row" ? {
808
+ _k: `row:${u.row.key}`,
809
+ sort: u.members[0].sort ?? 0,
808
810
  _t: "row",
809
- row: c.row,
810
- members: c.members
811
- } : { _k: c.field.field, sort: c.field.sort ?? 0, _t: "field", f: c.field }
811
+ row: u.row,
812
+ members: u.members
813
+ } : { _k: u.field.field, sort: u.field.sort ?? 0, _t: "field", f: u.field }
812
814
  );
813
- j && _.push({
815
+ G && _.push({
814
816
  _k: "__owners__",
815
- sort: j.sort,
817
+ sort: G.sort,
816
818
  _t: "owners",
817
- slot: j
818
- }), M && _.push({
819
+ slot: G
820
+ }), d && _.push({
819
821
  _k: "__pdf__",
820
- sort: M.sort,
822
+ sort: d.sort,
821
823
  _t: "pdf",
822
- slot: M
824
+ slot: d
823
825
  });
824
- for (const c of K ?? [])
825
- _.push({ _k: c.field, sort: c.sort, _t: "widget", slot: c });
826
- return _.sort((c, q) => c.sort - q.sort), F && _.length === 0 && p.folded.length === 0 ? /* @__PURE__ */ e(Gt, {}) : o ? /* @__PURE__ */ x(
826
+ for (const u of A ?? [])
827
+ _.push({ _k: u.field, sort: u.sort, _t: "widget", slot: u });
828
+ return _.sort((u, B) => u.sort - B.sort), $ && _.length === 0 && h.folded.length === 0 ? /* @__PURE__ */ e(Vt, {}) : f ? /* @__PURE__ */ x(
827
829
  "div",
828
830
  {
829
- ref: xe,
830
- className: W(F && "relative", "grid grid-cols-12 gap-x-6 gap-y-3"),
831
+ ref: ye,
832
+ className: E($ && "relative", "grid grid-cols-12 gap-x-6 gap-y-3"),
831
833
  children: [
832
- /* @__PURE__ */ e(we, { gapClass: "gap-x-6" }),
833
- _.map((c) => {
834
- if (c._t === "owners") {
835
- const v = c.slot.col_span ?? 12;
836
- return H(
837
- ae("__owners__"),
834
+ /* @__PURE__ */ e(ve, { gapClass: "gap-x-6" }),
835
+ _.map((u) => {
836
+ if (u._t === "owners") {
837
+ const v = u.slot.col_span ?? 12;
838
+ return K(
839
+ le("__owners__"),
838
840
  /* @__PURE__ */ e(
839
841
  "div",
840
842
  {
841
843
  className: "min-w-0",
842
844
  style: { gridColumn: `span ${v}` },
843
845
  children: /* @__PURE__ */ e(
844
- Qe,
846
+ Ze,
845
847
  {
846
- collection: l,
847
- itemId: n,
848
- label: c.slot.label_override || "Owners"
848
+ collection: r,
849
+ itemId: s,
850
+ label: u.slot.label_override || "Owners"
849
851
  }
850
852
  )
851
853
  },
@@ -853,136 +855,136 @@ function qn({
853
855
  )
854
856
  );
855
857
  }
856
- if (c._t === "pdf" || c._t === "widget" || c._t === "row") return null;
857
- const q = c.f, b = s.find(
858
- (v) => v.many_collection === l && v.many_field === q.field && !v.junction_field
858
+ if (u._t === "pdf" || u._t === "widget" || u._t === "row") return null;
859
+ const B = u.f, g = o.find(
860
+ (v) => v.many_collection === r && v.many_field === B.field && !v.junction_field
859
861
  );
860
- return H(
861
- { kind: "field", field: q.field, group_key: t.key },
862
+ return K(
863
+ { kind: "field", field: B.field, group_key: t.key },
862
864
  /* @__PURE__ */ x(
863
865
  "div",
864
866
  {
865
867
  className: "min-w-0",
866
- style: { gridColumn: `span ${Ye(q.options, ye)}` },
868
+ style: { gridColumn: `span ${Qe(B.options, Ne)}` },
867
869
  children: [
868
- /* @__PURE__ */ e("dt", { className: "text-[11px] font-medium text-slate-400 truncate", children: q.label || at(q.field) }),
869
- /* @__PURE__ */ e("dd", { className: "mt-0.5 break-words", children: (b == null ? void 0 : b.one_collection) === "nivaro_users" ? (() => {
870
- const v = i[q.field], P = Array.isArray(v) ? v : v != null && v !== "" ? [v] : [];
871
- return P.length === 0 ? /* @__PURE__ */ e("span", { className: "text-[13px] text-slate-400", children: "—" }) : /* @__PURE__ */ e("div", { className: "flex flex-wrap gap-1.5", children: P.map((T) => /* @__PURE__ */ e(ot, { userId: String(T) }, String(T))) });
872
- })() : b != null && b.one_collection ? /* @__PURE__ */ e(re, { relCollection: b.one_collection, id: i[q.field] }) : /* @__PURE__ */ e("span", { className: "text-[13px] text-slate-700", children: De(i[q.field], q) }) })
870
+ /* @__PURE__ */ e("dt", { className: "text-[11px] font-medium text-slate-400 truncate", children: B.label || ot(B.field) }),
871
+ /* @__PURE__ */ e("dd", { className: "mt-0.5 break-words", children: (g == null ? void 0 : g.one_collection) === "nivaro_users" ? (() => {
872
+ const v = a[B.field], C = Array.isArray(v) ? v : v != null && v !== "" ? [v] : [];
873
+ return C.length === 0 ? /* @__PURE__ */ e("span", { className: "text-[13px] text-slate-400", children: "—" }) : /* @__PURE__ */ e("div", { className: "flex flex-wrap gap-1.5", children: C.map((I) => /* @__PURE__ */ e(ct, { userId: String(I) }, String(I))) });
874
+ })() : g != null && g.one_collection ? /* @__PURE__ */ e(re, { relCollection: g.one_collection, id: a[B.field] }) : /* @__PURE__ */ e("span", { className: "text-[13px] text-slate-700", children: $e(a[B.field], B) }) })
873
875
  ]
874
876
  },
875
- q.field
877
+ B.field
876
878
  )
877
879
  );
878
880
  })
879
881
  ]
880
882
  }
881
883
  ) : (() => {
882
- const c = (b) => {
883
- var Ke, He;
884
- if (b._t === "row")
884
+ const u = (g) => {
885
+ var Ke, Ee;
886
+ if (g._t === "row")
885
887
  return /* @__PURE__ */ e(
886
- Wt,
888
+ Qt,
887
889
  {
888
- row: b.row,
889
- members: b.members,
890
- containerWidth: ye,
891
- errors: a,
892
- renderMember: (w) => H(
890
+ row: g.row,
891
+ members: g.members,
892
+ containerWidth: Ne,
893
+ errors: p,
894
+ renderMember: (w) => K(
893
895
  { kind: "field", field: w.field, group_key: t.key },
894
896
  /* @__PURE__ */ e("div", { children: /* @__PURE__ */ e(
895
- ve,
897
+ Se,
896
898
  {
897
- field: At(w),
898
- draft: i,
899
- onChange: u,
900
- relations: s,
901
- collection: l,
902
- itemId: n,
903
- error: a[w.field],
899
+ field: Zt(w),
900
+ draft: a,
901
+ onChange: l,
902
+ relations: o,
903
+ collection: r,
904
+ itemId: s,
905
+ error: p[w.field],
904
906
  visible: m.has(w.field) || !m.size,
905
- forceVisible: Ne(w) || void 0,
906
- locked: h.has(w.field),
907
- layoutAiEnabled: S,
908
- renderField: g,
909
- onCountChange: f
907
+ forceVisible: _e(w) || void 0,
908
+ locked: S.has(w.field),
909
+ layoutAiEnabled: c,
910
+ renderField: b,
911
+ onCountChange: y
910
912
  }
911
913
  ) }, w.field)
912
914
  )
913
915
  },
914
- b._k
916
+ g._k
915
917
  );
916
- if (b._t === "owners") {
917
- const w = b.slot.col_span ?? 12;
918
- return H(
919
- ae("__owners__"),
918
+ if (g._t === "owners") {
919
+ const w = g.slot.col_span ?? 12;
920
+ return K(
921
+ le("__owners__"),
920
922
  /* @__PURE__ */ e("div", { style: { gridColumn: `span ${w}` }, children: /* @__PURE__ */ e(
921
- Qe,
923
+ Ze,
922
924
  {
923
- collection: l,
924
- itemId: n,
925
- label: b.slot.label_override || "Owners"
925
+ collection: r,
926
+ itemId: s,
927
+ label: g.slot.label_override || "Owners"
926
928
  }
927
929
  ) }, "__owners__")
928
930
  );
929
931
  }
930
- if (b._t === "pdf") {
931
- if (!$) return null;
932
- const w = b.slot.col_span ?? 12, C = ((Ke = b.slot.label_override) == null ? void 0 : Ke.trim()) || "Generate PDF";
933
- return H(
934
- ae("__pdf__"),
932
+ if (g._t === "pdf") {
933
+ if (!U) return null;
934
+ const w = g.slot.col_span ?? 12, J = ((Ke = g.slot.label_override) == null ? void 0 : Ke.trim()) || "Generate PDF";
935
+ return K(
936
+ le("__pdf__"),
935
937
  /* @__PURE__ */ e("div", { style: { gridColumn: `span ${w}` }, children: /* @__PURE__ */ e(
936
- rn,
938
+ on,
937
939
  {
938
- collection: l,
939
- itemId: n,
940
- layoutId: $,
941
- attachField: d ?? null,
942
- filenameTemplate: L,
943
- label: C
940
+ collection: r,
941
+ itemId: s,
942
+ layoutId: U,
943
+ attachField: L ?? null,
944
+ filenameTemplate: O,
945
+ label: J
944
946
  }
945
947
  ) }, "__pdf__")
946
948
  );
947
949
  }
948
- if (b._t === "widget") {
949
- if (!b.slot.widget_id) return null;
950
- const w = b.slot.col_span ?? 12, C = Ze(b.slot.input_bindings);
951
- return H(
952
- ae(b.slot.field),
950
+ if (g._t === "widget") {
951
+ if (!g.slot.widget_id) return null;
952
+ const w = g.slot.col_span ?? 12, J = Xe(g.slot.input_bindings);
953
+ return K(
954
+ le(g.slot.field),
953
955
  /* @__PURE__ */ e("div", { style: { gridColumn: `span ${w}` }, children: /* @__PURE__ */ e(
954
- Ee,
956
+ Ye,
955
957
  {
956
- widgetId: b.slot.widget_id,
957
- inputBindings: C,
958
- itemDraft: i,
959
- label: b.slot.label_override ?? void 0,
960
- defaultExpanded: b.slot.default_expanded ?? !0,
958
+ widgetId: g.slot.widget_id,
959
+ inputBindings: J,
960
+ itemDraft: a,
961
+ label: g.slot.label_override ?? void 0,
962
+ defaultExpanded: g.slot.default_expanded ?? !0,
961
963
  frameless: !0,
962
- apiBase: E,
963
- onContentChange: (We) => qe(
964
- (_e) => _e[b.slot.field] === We ? _e : { ..._e, [b.slot.field]: We }
964
+ apiBase: Q,
965
+ onContentChange: (We) => Be(
966
+ (we) => we[g.slot.field] === We ? we : { ...we, [g.slot.field]: We }
965
967
  )
966
968
  }
967
- ) }, b.slot.field)
969
+ ) }, g.slot.field)
968
970
  );
969
971
  }
970
- const v = b.f, P = Y == null ? void 0 : Y[v.field], T = P == null ? void 0 : P.entries, yt = (P == null ? void 0 : P.separator) ?? null, ce = i[v.field], Ve = ce != null && ce !== "", Pe = T != null && T.length && Ve ? ((He = s.find(
971
- (w) => w.many_collection === l && w.many_field === v.field && !w.junction_field
972
- )) == null ? void 0 : He.one_collection) ?? null : null, Ce = (V == null ? void 0 : V.enabled) && v.field === V.primary_field, Je = (() => {
973
- const w = i[(V == null ? void 0 : V.primary_field) ?? ""];
972
+ const v = g.f, C = pe == null ? void 0 : pe[v.field], I = C == null ? void 0 : C.entries, Nt = (C == null ? void 0 : C.separator) ?? null, oe = a[v.field], Ve = oe != null && oe !== "", Ce = I != null && I.length && Ve ? ((Ee = o.find(
973
+ (w) => w.many_collection === r && w.many_field === v.field && !w.junction_field
974
+ )) == null ? void 0 : Ee.one_collection) ?? null : null, Je = (V == null ? void 0 : V.enabled) && v.field === V.primary_field, Re = (() => {
975
+ const w = a[(V == null ? void 0 : V.primary_field) ?? ""];
974
976
  return w != null && w !== "";
975
- })(), Re = (Z ?? []).some((w) => {
976
- const C = i[w.field];
977
- return C != null && C !== "";
978
- }), Nt = Ce && Fe ? /* @__PURE__ */ x("span", { className: "inline-flex items-center gap-1.5", children: [
977
+ })(), ze = (Z ?? []).some((w) => {
978
+ const J = a[w.field];
979
+ return J != null && J !== "";
980
+ }), _t = Je && je ? /* @__PURE__ */ x("span", { className: "inline-flex items-center gap-1.5", children: [
979
981
  /* @__PURE__ */ e(
980
982
  "button",
981
983
  {
982
984
  type: "button",
983
- onClick: Fe,
985
+ onClick: je,
984
986
  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",
985
- children: $e ? V.back_label ?? "Back" : V.toggle_label ?? "Enter manually"
987
+ children: Fe ? V.back_label ?? "Back" : V.toggle_label ?? "Enter manually"
986
988
  }
987
989
  ),
988
990
  /* @__PURE__ */ x(
@@ -990,7 +992,7 @@ function qn({
990
992
  {
991
993
  className: [
992
994
  "inline-flex items-center gap-0.5 rounded px-1 py-0.5 text-[9px] font-medium",
993
- Je ? "bg-emerald-50 text-emerald-600 dark:bg-emerald-900/30 dark:text-emerald-400" : "bg-slate-100 text-slate-400 dark:bg-slate-800 dark:text-slate-500"
995
+ Re ? "bg-emerald-50 text-emerald-600 dark:bg-emerald-900/30 dark:text-emerald-400" : "bg-slate-100 text-slate-400 dark:bg-slate-800 dark:text-slate-500"
994
996
  ].join(" "),
995
997
  title: "Original field",
996
998
  children: [
@@ -999,7 +1001,7 @@ function qn({
999
1001
  {
1000
1002
  className: [
1001
1003
  "h-1.5 w-1.5 rounded-full",
1002
- Je ? "bg-emerald-500" : "bg-slate-300 dark:bg-slate-600"
1004
+ Re ? "bg-emerald-500" : "bg-slate-300 dark:bg-slate-600"
1003
1005
  ].join(" ")
1004
1006
  }
1005
1007
  ),
@@ -1012,7 +1014,7 @@ function qn({
1012
1014
  {
1013
1015
  className: [
1014
1016
  "inline-flex items-center gap-0.5 rounded px-1 py-0.5 text-[9px] font-medium",
1015
- Re ? "bg-emerald-50 text-emerald-600 dark:bg-emerald-900/30 dark:text-emerald-400" : "bg-slate-100 text-slate-400 dark:bg-slate-800 dark:text-slate-500"
1017
+ ze ? "bg-emerald-50 text-emerald-600 dark:bg-emerald-900/30 dark:text-emerald-400" : "bg-slate-100 text-slate-400 dark:bg-slate-800 dark:text-slate-500"
1016
1018
  ].join(" "),
1017
1019
  title: "Manual fields",
1018
1020
  children: [
@@ -1021,7 +1023,7 @@ function qn({
1021
1023
  {
1022
1024
  className: [
1023
1025
  "h-1.5 w-1.5 rounded-full",
1024
- Re ? "bg-emerald-500" : "bg-slate-300 dark:bg-slate-600"
1026
+ ze ? "bg-emerald-500" : "bg-slate-300 dark:bg-slate-600"
1025
1027
  ].join(" ")
1026
1028
  }
1027
1029
  ),
@@ -1029,61 +1031,61 @@ function qn({
1029
1031
  ]
1030
1032
  }
1031
1033
  )
1032
- ] }) : void 0, _t = Ce && $e && (Z != null && Z.length) ? /* @__PURE__ */ e("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__ */ e("div", { className: "grid grid-cols-2 gap-3", children: Z.map((w) => {
1033
- const C = (pe == null ? void 0 : pe[w.field]) ?? 2;
1034
- return /* @__PURE__ */ e("div", { style: { gridColumn: `span ${C}` }, children: /* @__PURE__ */ e(
1035
- ve,
1034
+ ] }) : void 0, wt = Je && Fe && (Z != null && Z.length) ? /* @__PURE__ */ e("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__ */ e("div", { className: "grid grid-cols-2 gap-3", children: Z.map((w) => {
1035
+ const J = (fe == null ? void 0 : fe[w.field]) ?? 2;
1036
+ return /* @__PURE__ */ e("div", { style: { gridColumn: `span ${J}` }, children: /* @__PURE__ */ e(
1037
+ Se,
1036
1038
  {
1037
1039
  field: w,
1038
- draft: i,
1039
- onChange: u,
1040
- relations: s,
1041
- collection: l,
1042
- itemId: n,
1043
- error: a[w.field],
1040
+ draft: a,
1041
+ onChange: l,
1042
+ relations: o,
1043
+ collection: r,
1044
+ itemId: s,
1045
+ error: p[w.field],
1044
1046
  visible: !0,
1045
1047
  forceVisible: !0,
1046
- locked: h.has(w.field),
1047
- layoutAiEnabled: S,
1048
- renderField: g,
1049
- onCountChange: f
1048
+ locked: S.has(w.field),
1049
+ layoutAiEnabled: c,
1050
+ renderField: b,
1051
+ onCountChange: y
1050
1052
  }
1051
1053
  ) }, w.field);
1052
- }) }) }) : void 0, ze = /* @__PURE__ */ e(
1053
- ve,
1054
+ }) }) }) : void 0, He = /* @__PURE__ */ e(
1055
+ Se,
1054
1056
  {
1055
1057
  field: v,
1056
- draft: i,
1057
- onChange: u,
1058
- relations: s,
1059
- collection: l,
1060
- itemId: n,
1061
- error: a[v.field],
1058
+ draft: a,
1059
+ onChange: l,
1060
+ relations: o,
1061
+ collection: r,
1062
+ itemId: s,
1063
+ error: p[v.field],
1062
1064
  visible: m.has(v.field) || !m.size,
1063
- forceVisible: Ne(v) || void 0,
1064
- locked: h.has(v.field),
1065
- layoutAiEnabled: S,
1066
- renderField: g,
1067
- onCountChange: f,
1068
- swapButton: Nt,
1069
- swapContent: _t
1065
+ forceVisible: _e(v) || void 0,
1066
+ locked: S.has(v.field),
1067
+ layoutAiEnabled: c,
1068
+ renderField: b,
1069
+ onCountChange: y,
1070
+ swapButton: _t,
1071
+ swapContent: wt
1070
1072
  }
1071
1073
  );
1072
- return H(
1074
+ return K(
1073
1075
  { kind: "field", field: v.field, group_key: t.key },
1074
1076
  /* @__PURE__ */ x(
1075
1077
  "div",
1076
1078
  {
1077
- style: { gridColumn: `span ${Ye(v.options, ye)}` },
1079
+ style: { gridColumn: `span ${Qe(v.options, Ne)}` },
1078
1080
  children: [
1079
- Ne(v) ? /* @__PURE__ */ e("div", { "data-design-hidden": "", className: "opacity-40", children: ze }) : ze,
1080
- (T == null ? void 0 : T.length) && Ve && Pe && /* @__PURE__ */ e(
1081
- tn,
1081
+ _e(v) ? /* @__PURE__ */ e("div", { "data-design-hidden": "", className: "opacity-40", children: He }) : He,
1082
+ (I == null ? void 0 : I.length) && Ve && Ce && /* @__PURE__ */ e(
1083
+ ln,
1082
1084
  {
1083
- relCollection: Pe,
1084
- relId: ce,
1085
- entries: T,
1086
- separator: yt
1085
+ relCollection: Ce,
1086
+ relId: oe,
1087
+ entries: I,
1088
+ separator: Nt
1087
1089
  }
1088
1090
  )
1089
1091
  ]
@@ -1091,39 +1093,39 @@ function qn({
1091
1093
  v.field
1092
1094
  )
1093
1095
  );
1094
- }, q = p.folded.map((b) => ({
1095
- _k: b.field,
1096
- sort: b.sort ?? 0,
1096
+ }, B = h.folded.map((g) => ({
1097
+ _k: g.field,
1098
+ sort: g.sort ?? 0,
1097
1099
  _t: "field",
1098
- f: b
1100
+ f: g
1099
1101
  }));
1100
- return /* @__PURE__ */ x(wt, { children: [
1102
+ return /* @__PURE__ */ x(vt, { children: [
1101
1103
  /* @__PURE__ */ x(
1102
1104
  "div",
1103
1105
  {
1104
- ref: xe,
1105
- className: W(F && "relative", "grid grid-cols-12 gap-4 items-start"),
1106
+ ref: ye,
1107
+ className: E($ && "relative", "grid grid-cols-12 gap-4 items-start"),
1106
1108
  children: [
1107
- /* @__PURE__ */ e(we, {}),
1108
- _.map(c)
1109
+ /* @__PURE__ */ e(ve, {}),
1110
+ _.map(u)
1109
1111
  ]
1110
1112
  }
1111
1113
  ),
1112
1114
  /* @__PURE__ */ e(
1113
- Ht,
1115
+ Yt,
1114
1116
  {
1115
- count: q.length,
1116
- open: ut,
1117
- forcedOpen: p.forcedOpen,
1118
- design: !!F,
1119
- onToggle: () => mt((b) => !b),
1117
+ count: B.length,
1118
+ open: mt,
1119
+ forcedOpen: h.forcedOpen,
1120
+ design: !!$,
1121
+ onToggle: () => pt((g) => !g),
1120
1122
  children: /* @__PURE__ */ x(
1121
1123
  "div",
1122
1124
  {
1123
- className: W(F && "relative", "grid grid-cols-12 gap-4 items-start"),
1125
+ className: E($ && "relative", "grid grid-cols-12 gap-4 items-start"),
1124
1126
  children: [
1125
- /* @__PURE__ */ e(we, {}),
1126
- q.map(c)
1127
+ /* @__PURE__ */ e(ve, {}),
1128
+ B.map(u)
1127
1129
  ]
1128
1130
  }
1129
1131
  )
@@ -1132,30 +1134,30 @@ function qn({
1132
1134
  ] });
1133
1135
  })();
1134
1136
  })(),
1135
- ie && /* @__PURE__ */ e("div", { className: "mt-4", children: ie })
1137
+ H && /* @__PURE__ */ e("div", { className: "mt-4", children: H })
1136
1138
  ] })
1137
1139
  ]
1138
1140
  }
1139
1141
  );
1140
- }
1141
- function an({
1142
- layoutId: t,
1143
- collection: r,
1142
+ }, rn);
1143
+ function un({
1144
+ layoutId: n,
1145
+ collection: t,
1144
1146
  sectionKey: i
1145
1147
  }) {
1146
1148
  return ne(() => {
1147
- st({ layoutId: t, collection: r, kind: "shown", key: i });
1148
- }, [t, r, i]), null;
1149
+ lt({ layoutId: n, collection: t, kind: "shown", key: i });
1150
+ }, [n, t, i]), null;
1149
1151
  }
1150
1152
  export {
1151
- qn as GroupSection,
1152
- tn as InlineDisplay,
1153
- Qe as OwnersInline,
1154
- en as OwnersInlineCompact,
1153
+ Gn as GroupSection,
1154
+ ln as InlineDisplay,
1155
+ Ze as OwnersInline,
1156
+ sn as OwnersInlineCompact,
1155
1157
  re as RelationCell,
1156
- On as StripFieldValue,
1157
- ot as UserChip,
1158
- Un as UserRosterCluster,
1159
- De as formatDisplayValue,
1160
- sn as useChangePulse
1158
+ Tn as StripFieldValue,
1159
+ ct as UserChip,
1160
+ Vn as UserRosterCluster,
1161
+ $e as formatDisplayValue,
1162
+ cn as useChangePulse
1161
1163
  };