@nivaro/react 0.2.51 → 0.2.53

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 (117) hide show
  1. package/dist/full.css +1 -1
  2. package/dist/hooks/useSessionRecorder.js +1 -1
  3. package/dist/index.d.ts +207 -6
  4. package/dist/index.js +442 -439
  5. package/dist/layout-editor.d.ts +80 -0
  6. package/dist/layout-editor.js +11 -0
  7. package/dist/shared/components/ItemEditForm.js +4015 -3835
  8. package/dist/shared/components/RecordDrilldownSheet.js +114 -97
  9. package/dist/shared/components/RecordReadView.js +637 -570
  10. package/dist/shared/components/ai/ExplainButton.js +1 -1
  11. package/dist/shared/components/item-edit/GroupSection.js +489 -466
  12. package/dist/shared/components/item-edit/HeaderBand.js +47 -44
  13. package/dist/shared/components/item-edit/M2MStagingContext.js +3 -3
  14. package/dist/shared/components/item-edit/O2MStagingContext.js +1 -1
  15. package/dist/shared/components/item-edit/RecordGrantTools.js +206 -0
  16. package/dist/shared/components/item-edit/StepsBar.js +49 -43
  17. package/dist/shared/components/item-edit/SummaryPanel.js +1 -1
  18. package/dist/shared/components/item-edit/config-update.js +6 -0
  19. package/dist/shared/components/item-edit/layout-editing-quiet.js +25 -0
  20. package/dist/shared/components/layout-editor/AddPanel.js +301 -0
  21. package/dist/shared/components/layout-editor/DesignNode.js +173 -0
  22. package/dist/shared/components/layout-editor/EditorCanvas.js +52 -0
  23. package/dist/shared/components/layout-editor/EditorTopBar.js +241 -0
  24. package/dist/shared/components/layout-editor/HistoryPanel.js +179 -0
  25. package/dist/shared/components/layout-editor/LayoutEditor.js +393 -0
  26. package/dist/shared/components/layout-editor/LayoutsRail.js +89 -0
  27. package/dist/shared/components/layout-editor/add-target.js +103 -0
  28. package/dist/shared/components/layout-editor/bundle-to-active.js +86 -0
  29. package/dist/shared/components/layout-editor/canvases/PdfCanvas.js +90 -0
  30. package/dist/shared/components/layout-editor/canvases/TableColumnsCanvas.js +246 -0
  31. package/dist/shared/components/layout-editor/collection-meta.js +22 -0
  32. package/dist/shared/components/layout-editor/design-canvas.js +81 -0
  33. package/dist/shared/components/layout-editor/design-context.js +21 -0
  34. package/dist/shared/components/layout-editor/dnd/LayoutDndProvider.js +225 -0
  35. package/dist/shared/components/layout-editor/dnd/collision.js +107 -0
  36. package/dist/shared/components/layout-editor/dnd/node.js +164 -0
  37. package/dist/shared/components/layout-editor/dnd/order.js +122 -0
  38. package/dist/shared/components/layout-editor/editors/DefaultValuesEditor.js +223 -0
  39. package/dist/shared/components/layout-editor/editors/QuickPickerStepsEditor.js +129 -0
  40. package/dist/shared/components/layout-editor/editors/ReadPresentationEditor.js +134 -0
  41. package/dist/shared/components/layout-editor/editors/RecordConditionsEditor.js +249 -0
  42. package/dist/shared/components/layout-editor/editors/RolesPicker.js +77 -0
  43. package/dist/shared/components/layout-editor/editors/cascade-filters.js +556 -0
  44. package/dist/shared/components/layout-editor/editors/cascade-rule-row.js +150 -0
  45. package/dist/shared/components/layout-editor/editors/controls.js +73 -0
  46. package/dist/shared/components/layout-editor/editors/editor-api.js +21 -0
  47. package/dist/shared/components/layout-editor/editors/editor-queries.js +25 -0
  48. package/dist/shared/components/layout-editor/editors/field-default-value.js +131 -0
  49. package/dist/shared/components/layout-editor/editors/grid-presets.js +310 -0
  50. package/dist/shared/components/layout-editor/editors/inline-display.js +157 -0
  51. package/dist/shared/components/layout-editor/editors/layout-picker.js +80 -0
  52. package/dist/shared/components/layout-editor/editors/layout-rows.js +55 -0
  53. package/dist/shared/components/layout-editor/editors/lock-conditions.js +109 -0
  54. package/dist/shared/components/layout-editor/editors/o2m-agg-field.js +25 -0
  55. package/dist/shared/components/layout-editor/editors/pdf-field-config.js +107 -0
  56. package/dist/shared/components/layout-editor/editors/report-widget-config.js +94 -0
  57. package/dist/shared/components/layout-editor/editors/row-rule-check.js +225 -0
  58. package/dist/shared/components/layout-editor/editors/row-rule-row.js +1353 -0
  59. package/dist/shared/components/layout-editor/editors/swap-config.js +245 -0
  60. package/dist/shared/components/layout-editor/focus-buffer.js +32 -0
  61. package/dist/shared/components/layout-editor/host.js +15 -0
  62. package/dist/shared/components/layout-editor/inspector/AdvancedTab.js +296 -0
  63. package/dist/shared/components/layout-editor/inspector/GridTab.js +767 -0
  64. package/dist/shared/components/layout-editor/inspector/GroupInspector.js +456 -0
  65. package/dist/shared/components/layout-editor/inspector/HeaderItemInspector.js +268 -0
  66. package/dist/shared/components/layout-editor/inspector/Inspector.js +332 -0
  67. package/dist/shared/components/layout-editor/inspector/LookTab.js +310 -0
  68. package/dist/shared/components/layout-editor/inspector/PickerTab.js +333 -0
  69. package/dist/shared/components/layout-editor/inspector/RulesTab.js +323 -0
  70. package/dist/shared/components/layout-editor/inspector/SlotInspector.js +179 -0
  71. package/dist/shared/components/layout-editor/inspector/SubtitleInspector.js +154 -0
  72. package/dist/shared/components/layout-editor/inspector/WidgetInspector.js +262 -0
  73. package/dist/shared/components/layout-editor/inspector/applies.js +27 -0
  74. package/dist/shared/components/layout-editor/inspector/field-context.js +134 -0
  75. package/dist/shared/components/layout-editor/inspector/interfaces.js +126 -0
  76. package/dist/shared/components/layout-editor/inspector/kit.js +595 -0
  77. package/dist/shared/components/layout-editor/inspector/model.js +307 -0
  78. package/dist/shared/components/layout-editor/overview/OverviewActions.js +15 -0
  79. package/dist/shared/components/layout-editor/overview/describe-conditions.js +121 -0
  80. package/dist/shared/components/layout-editor/overview/overview-api.js +141 -0
  81. package/dist/shared/components/layout-editor/overview/purpose.js +62 -0
  82. package/dist/shared/components/layout-editor/overview/record-count.js +65 -0
  83. package/dist/shared/components/layout-editor/panel-frame.js +99 -0
  84. package/dist/shared/components/layout-editor/panel-style.js +19 -0
  85. package/dist/shared/components/layout-editor/pickers/field-picker.js +230 -0
  86. package/dist/shared/components/layout-editor/pickers/icon-picker.js +233 -0
  87. package/dist/shared/components/layout-editor/pickers/relation-label.js +34 -0
  88. package/dist/shared/components/layout-editor/pickers/relation-picker.js +136 -0
  89. package/dist/shared/components/layout-editor/record-queries.js +15 -0
  90. package/dist/shared/components/layout-editor/settings/AddendumSection.js +52 -0
  91. package/dist/shared/components/layout-editor/settings/ButtonsSection.js +45 -0
  92. package/dist/shared/components/layout-editor/settings/DefaultsSection.js +67 -0
  93. package/dist/shared/components/layout-editor/settings/FormSettings.js +146 -0
  94. package/dist/shared/components/layout-editor/settings/InheritanceSection.js +37 -0
  95. package/dist/shared/components/layout-editor/settings/LayoutSection.js +70 -0
  96. package/dist/shared/components/layout-editor/settings/PdfSection.js +176 -0
  97. package/dist/shared/components/layout-editor/settings/ReadSection.js +79 -0
  98. package/dist/shared/components/layout-editor/settings/TextSetting.js +55 -0
  99. package/dist/shared/components/layout-editor/settings/ToggleSetting.js +33 -0
  100. package/dist/shared/components/layout-editor/settings/ToolsSection.js +179 -0
  101. package/dist/shared/components/layout-editor/settings/WhoSection.js +213 -0
  102. package/dist/shared/components/layout-editor/settings/controls.js +214 -0
  103. package/dist/shared/components/layout-editor/settings/section-props.js +17 -0
  104. package/dist/shared/components/layout-editor/settings/settings-api.js +151 -0
  105. package/dist/shared/components/layout-editor/settings/settings-registry.js +445 -0
  106. package/dist/shared/components/layout-editor/slot-names.js +20 -0
  107. package/dist/shared/components/layout-editor/summary-pref.js +21 -0
  108. package/dist/shared/components/layout-editor/useLayoutDraft.js +474 -0
  109. package/dist/shared/components/pipeline/relations.js +28 -23
  110. package/dist/shared/components/ui/popover.js +17 -17
  111. package/dist/shared/components/ui/scroll-area.js +38 -0
  112. package/dist/shared/hooks/useRelationOptions.js +60 -0
  113. package/dist/shared/lib/layout-grants.js +9 -0
  114. package/dist/shared/lib/layout-ops.js +348 -0
  115. package/dist/shared/lib/layout-slots.js +11 -7
  116. package/dist/shared/lib/request-gate.js +1 -1
  117. package/package.json +5 -1
@@ -0,0 +1,1353 @@
1
+ import { jsxs as r, jsx as e, Fragment as ye } from "react/jsx-runtime";
2
+ import { useQuery as C } from "@tanstack/react-query";
3
+ import { ChevronRight as at, X as Ne, ChevronDown as lt, Check as rt } from "lucide-react";
4
+ import { useState as x, useMemo as ge } from "react";
5
+ import { cn as ie } from "../../../lib/utils.js";
6
+ import { extractTemplateFields as nt, renderDisplayTemplate as it } from "../../pipeline/relations.js";
7
+ import { Command as O, CommandInput as T, CommandList as S, CommandGroup as v, CommandItem as f } from "../../ui/command.js";
8
+ import { Popover as y, PopoverTrigger as N, PopoverContent as k } from "../../ui/popover.js";
9
+ import { tintCard as Qe } from "../panel-style.js";
10
+ import { useEditorApi as ke } from "./editor-api.js";
11
+ import { editorQueryKeys as We } from "./editor-queries.js";
12
+ const fe = /* @__PURE__ */ new Set([
13
+ "alias",
14
+ "o2m",
15
+ "m2m",
16
+ "m2a",
17
+ "presentation",
18
+ "group",
19
+ "divider"
20
+ ]), wt = /* @__PURE__ */ new Set([
21
+ "integer",
22
+ "bigInteger",
23
+ "decimal",
24
+ "float",
25
+ "money",
26
+ "smallmoney",
27
+ "tinyint",
28
+ "smallint",
29
+ "bigint"
30
+ ]);
31
+ function Ot(t, m, u) {
32
+ if (u < 0 || u >= t.length) return t;
33
+ const p = [...t], [n] = p.splice(m, 1);
34
+ return p.splice(u, 0, n), p;
35
+ }
36
+ function st(t) {
37
+ return t.replace(/_/g, " ").replace(/\b\w/g, (m) => m.toUpperCase());
38
+ }
39
+ function dt(t, m, u, p) {
40
+ if (p != null && p.some((o) => o.one_field === t || o.many_collection === t)) return "O2M";
41
+ if (u.some((o) => o.many_field === t)) return "M2O";
42
+ const n = (m ?? "").toLowerCase();
43
+ return ["string", "nvarchar", "varchar", "char", "text"].some((o) => n.includes(o)) ? "text" : ["integer", "bigint", "smallint", "tinyint"].some((o) => n === o) || n === "int" ? "number" : ["decimal", "float", "double", "real", "money", "numeric"].some((o) => n.includes(o)) ? "decimal" : n === "boolean" || n === "bit" ? "bool" : n.includes("datetime") || n === "timestamp" ? "datetime" : n === "date" ? "date" : n === "uuid" || n === "uniqueidentifier" ? "uuid" : n === "json" ? "json" : m ?? "";
44
+ }
45
+ const ct = /* @__PURE__ */ new Set(["__id__", "__entity__"]);
46
+ function He({
47
+ collection: t,
48
+ value: m,
49
+ isMulti: u,
50
+ onChange: p
51
+ }) {
52
+ const n = ke(), [o, d] = x(!1), [c, I] = x(""), h = m ? m.split(",").map((s) => s.trim()).filter(Boolean) : [], { data: K } = C({
53
+ // Namespaced: ['collection-meta', c] holds other shapes elsewhere.
54
+ queryKey: ["layout-editor", "collection-row", t],
55
+ queryFn: () => n.get(`/collections/${t}`).then((s) => s.data.data ?? {}),
56
+ enabled: !!t,
57
+ staleTime: 5 * 6e4
58
+ }), H = (K == null ? void 0 : K.display_template) ?? null, q = (H ? nt(H) : []).filter((s) => s !== "id"), { data: Q = [] } = C({
59
+ queryKey: ["via-pick-items", t, c, q.join(",")],
60
+ queryFn: () => n.get(`/items/${t}`, {
61
+ params: {
62
+ limit: 50,
63
+ ...c ? { search: c } : {},
64
+ ...q.length ? { fields: ["id", ...q].join(",") } : {}
65
+ }
66
+ }).then((s) => s.data.data ?? []),
67
+ enabled: !!t,
68
+ staleTime: 3e4
69
+ }), { data: J = [] } = C({
70
+ queryKey: ["via-pick-selected", t, h.join(","), q.join(",")],
71
+ queryFn: () => n.get(`/items/${t}`, {
72
+ params: {
73
+ filter: JSON.stringify({ id: { _in: h } }),
74
+ limit: h.length,
75
+ ...q.length ? { fields: ["id", ...q].join(",") } : {}
76
+ }
77
+ }).then((s) => s.data.data ?? []),
78
+ enabled: h.length > 0,
79
+ staleTime: 6e4
80
+ });
81
+ function U(s) {
82
+ return it(H, s);
83
+ }
84
+ function Y(s) {
85
+ if (u) {
86
+ const b = h.includes(s) ? h.filter((M) => M !== s) : [...h, s];
87
+ p(b.length ? b.join(",") : null);
88
+ } else
89
+ p(h[0] === s ? null : s), d(!1);
90
+ }
91
+ return /* @__PURE__ */ r("div", { className: "space-y-1", children: [
92
+ h.length > 0 && /* @__PURE__ */ e("div", { className: "flex flex-wrap gap-1", children: h.map((s) => {
93
+ const b = J.find((M) => String(M.id) === s);
94
+ return /* @__PURE__ */ r(
95
+ "span",
96
+ {
97
+ className: "inline-flex items-center gap-0.5 rounded bg-nvr-cyan/10 text-nvr-navy dark:text-nvr-cyan text-[12px] px-1.5 py-0.5",
98
+ children: [
99
+ b ? U(b) : s,
100
+ /* @__PURE__ */ e(
101
+ "button",
102
+ {
103
+ type: "button",
104
+ onClick: () => Y(s),
105
+ "aria-label": `Remove ${b ? U(b) : s}`,
106
+ className: "hover:text-red-600 dark:hover:text-red-400 ml-0.5",
107
+ children: "✕"
108
+ }
109
+ )
110
+ ]
111
+ },
112
+ s
113
+ );
114
+ }) }),
115
+ /* @__PURE__ */ r(y, { open: o, onOpenChange: d, children: [
116
+ /* @__PURE__ */ e(N, { asChild: !0, children: /* @__PURE__ */ e(
117
+ "button",
118
+ {
119
+ type: "button",
120
+ className: "w-full h-7 rounded border border-slate-200 bg-white px-2 text-[12px] text-left hover:border-slate-400 text-slate-500 dark:bg-card dark:border-border",
121
+ children: u ? "+ add record…" : h.length ? "change…" : "pick record…"
122
+ }
123
+ ) }),
124
+ /* @__PURE__ */ e(k, { className: "w-60 p-0", align: "start", children: /* @__PURE__ */ r(O, { children: [
125
+ /* @__PURE__ */ e(
126
+ T,
127
+ {
128
+ placeholder: "Search…",
129
+ className: "h-8 text-[12px]",
130
+ value: c,
131
+ onValueChange: I
132
+ }
133
+ ),
134
+ /* @__PURE__ */ e(S, { children: /* @__PURE__ */ e(v, { children: Q.map((s) => {
135
+ const b = String(s.id ?? ""), M = h.includes(b);
136
+ return /* @__PURE__ */ r(
137
+ f,
138
+ {
139
+ value: `${b} ${U(s)}`,
140
+ onSelect: () => Y(b),
141
+ className: "text-[12px]",
142
+ children: [
143
+ u && /* @__PURE__ */ e(
144
+ rt,
145
+ {
146
+ className: ie(
147
+ "h-3 w-3 mr-1 shrink-0",
148
+ M ? "opacity-100" : "opacity-0"
149
+ )
150
+ }
151
+ ),
152
+ U(s)
153
+ ]
154
+ },
155
+ b
156
+ );
157
+ }) }) })
158
+ ] }) })
159
+ ] })
160
+ ] });
161
+ }
162
+ function ot({
163
+ source: t,
164
+ index: m,
165
+ total: u,
166
+ m2oRels: p,
167
+ o2mRels: n,
168
+ parentContextFields: o,
169
+ onChange: d,
170
+ onRemove: c,
171
+ onMoveUp: I,
172
+ onMoveDown: h
173
+ }) {
174
+ var W, ce, te, A, oe;
175
+ const K = ke(), [H, le] = x(!1), [q, Q] = x(!1), [J, U] = x(!1), [Y, s] = x(!1), [b, M] = x(!1), [P, X] = x(""), D = t.source_type === "o2m_filtered", z = t.source_type === "parent_m2o", Z = t.source_hop ?? "m2o", B = t.source_type === "relation_field" ? ((W = p.find((l) => l.many_field === t.source_field)) == null ? void 0 : W.one_collection) ?? null : t.source_type === "o2m_first" ? ((ce = n.find((l) => l.one_field === t.source_field)) == null ? void 0 : ce.many_collection) ?? null : z ? t.source_one_collection ?? null : null, { data: xe } = C({
176
+ queryKey: ["field-config-all", B],
177
+ queryFn: () => K.get(`/field-config/${B}`).then(
178
+ (l) => l.data.data ?? []
179
+ ),
180
+ enabled: !!B && !D,
181
+ staleTime: 300 * 1e3
182
+ }), V = (xe ?? []).filter(
183
+ (l) => l.field !== "id" && !fe.has(l.type ?? "")
184
+ ).map((l) => ({
185
+ value: l.field,
186
+ label: l.label || l.field
187
+ })), R = ge(
188
+ () => (o ?? []).filter((l) => !!l.one_collection).map((l) => ({ value: l.field, label: l.label, one_collection: l.one_collection })),
189
+ [o]
190
+ ), G = D ? Z === "m2o" ? p.map((l) => ({ value: l.many_field, label: l.many_field })) : n.map((l) => ({ value: l.one_field, label: l.one_field })) : z ? R.map((l) => ({ value: l.value, label: l.label })) : t.source_type === "relation_field" ? p.map((l) => ({ value: l.many_field, label: l.many_field })) : n.map((l) => ({ value: l.one_field, label: l.one_field })), _ = D ? Z === "m2o" ? ((te = p.find((l) => l.many_field === t.source_field)) == null ? void 0 : te.one_collection) ?? null : ((A = n.find((l) => l.one_field === t.source_field)) == null ? void 0 : A.many_collection) ?? null : null, { data: re } = C({
191
+ queryKey: We.relationsFor(_),
192
+ queryFn: () => K.get(`/data-model/relations/for/${_}`).then((l) => l.data.data ?? []),
193
+ enabled: D && !!_ && !!t.source_field,
194
+ staleTime: 300 * 1e3
195
+ }), ee = ge(() => (re ?? []).filter(
196
+ (F) => F.one_collection === _ && F.many_collection && !F.junction_field
197
+ ).map((F) => ({ value: F.many_collection, label: F.many_collection })), [re, _]), { data: se } = C({
198
+ queryKey: ["field-config-all", t.o2m_collection],
199
+ queryFn: () => K.get(`/field-config/${t.o2m_collection}`).then(
200
+ (l) => l.data.data ?? []
201
+ ),
202
+ enabled: D && !!t.o2m_collection,
203
+ staleTime: 300 * 1e3
204
+ }), j = (se ?? []).filter((l) => !fe.has(l.type ?? "")).map((l) => ({
205
+ value: l.field,
206
+ label: l.label || l.field
207
+ })), L = j.filter(
208
+ (l) => l.value !== "id"
209
+ ), de = ge(
210
+ () => (o ?? []).map((l) => ({
211
+ value: `$parent.${l.field}`,
212
+ label: `$parent.${l.field}`
213
+ })),
214
+ [o]
215
+ );
216
+ return /* @__PURE__ */ r("div", { className: ie(Qe, "relative overflow-hidden"), children: [
217
+ /* @__PURE__ */ r("div", { className: "absolute top-1 right-1 flex items-center gap-px z-10", children: [
218
+ /* @__PURE__ */ e(
219
+ "button",
220
+ {
221
+ type: "button",
222
+ onClick: I,
223
+ disabled: m === 0,
224
+ "aria-label": "Move up",
225
+ className: "h-6 w-6 flex items-center justify-center text-slate-500 hover:text-slate-700 disabled:opacity-20 transition-colors rounded hover:bg-muted",
226
+ children: "↑"
227
+ }
228
+ ),
229
+ /* @__PURE__ */ e(
230
+ "button",
231
+ {
232
+ type: "button",
233
+ onClick: h,
234
+ disabled: m === u - 1,
235
+ "aria-label": "Move down",
236
+ className: "h-6 w-6 flex items-center justify-center text-slate-500 hover:text-slate-700 disabled:opacity-20 transition-colors rounded hover:bg-muted",
237
+ children: "↓"
238
+ }
239
+ ),
240
+ /* @__PURE__ */ e(
241
+ "button",
242
+ {
243
+ type: "button",
244
+ onClick: c,
245
+ "aria-label": "Remove",
246
+ className: "h-6 w-6 flex items-center justify-center text-slate-500 hover:text-red-600 dark:hover:text-red-400 transition-colors rounded hover:bg-red-50 dark:hover:bg-red-500/10",
247
+ children: /* @__PURE__ */ e(Ne, { className: "h-3.5 w-3.5" })
248
+ }
249
+ )
250
+ ] }),
251
+ /* @__PURE__ */ r("div", { className: "flex items-center gap-1.5 flex-wrap px-2 py-1.5 pr-20", children: [
252
+ /* @__PURE__ */ e("span", { className: "text-[12px] font-medium text-slate-500 w-4 text-right shrink-0 tabular-nums", children: m + 1 }),
253
+ /* @__PURE__ */ e(
254
+ ne,
255
+ {
256
+ value: t.source_type,
257
+ opts: [
258
+ { value: "relation_field", label: "M2O →" },
259
+ { value: "o2m_first", label: "O2M first →" },
260
+ { value: "o2m_filtered", label: "filtered child →" },
261
+ { value: "parent_m2o", label: "parent M2O →" }
262
+ ],
263
+ onChange: (l) => d({
264
+ source_type: l,
265
+ source_field: "",
266
+ source_related_field: "",
267
+ source_hop: "m2o"
268
+ })
269
+ }
270
+ ),
271
+ D && /* @__PURE__ */ e(
272
+ ne,
273
+ {
274
+ value: Z,
275
+ opts: [
276
+ { value: "m2o", label: "via M2O" },
277
+ { value: "o2m_first", label: "via O2M first" }
278
+ ],
279
+ onChange: (l) => d({ ...t, source_hop: l, source_field: "" })
280
+ }
281
+ ),
282
+ /* @__PURE__ */ r(y, { open: H, onOpenChange: le, children: [
283
+ /* @__PURE__ */ e(N, { asChild: !0, children: /* @__PURE__ */ e(
284
+ "button",
285
+ {
286
+ type: "button",
287
+ className: "h-7 rounded border border-slate-200 bg-white px-2 text-[12px] text-left truncate hover:border-slate-400 min-w-[70px] max-w-[110px] transition-colors dark:bg-background dark:border-border",
288
+ children: t.source_field || /* @__PURE__ */ e("span", { className: "text-slate-500", children: "field…" })
289
+ }
290
+ ) }),
291
+ /* @__PURE__ */ e(k, { className: "w-44 p-0", align: "start", children: /* @__PURE__ */ r(O, { children: [
292
+ /* @__PURE__ */ e(T, { placeholder: "Search…", className: "h-7 text-[12px]" }),
293
+ /* @__PURE__ */ e(S, { children: /* @__PURE__ */ e(v, { children: G.length === 0 ? /* @__PURE__ */ e("div", { className: "px-3 py-2 text-[12px] text-slate-500", children: "No relations" }) : G.map((l) => /* @__PURE__ */ e(
294
+ f,
295
+ {
296
+ value: l.value,
297
+ onSelect: () => {
298
+ var $;
299
+ const F = z ? (($ = R.find((pe) => pe.value === l.value)) == null ? void 0 : $.one_collection) ?? void 0 : void 0;
300
+ d({
301
+ ...t,
302
+ source_field: l.value,
303
+ source_related_field: "",
304
+ ...z ? { source_one_collection: F } : {}
305
+ }), le(!1);
306
+ },
307
+ className: "text-[12px]",
308
+ children: l.label
309
+ },
310
+ l.value
311
+ )) }) })
312
+ ] }) })
313
+ ] }),
314
+ !D && /* @__PURE__ */ r(ye, { children: [
315
+ /* @__PURE__ */ e("span", { className: "text-slate-500 shrink-0", children: "→" }),
316
+ /* @__PURE__ */ r(y, { open: q, onOpenChange: Q, children: [
317
+ /* @__PURE__ */ e(N, { asChild: !0, children: /* @__PURE__ */ e(
318
+ "button",
319
+ {
320
+ type: "button",
321
+ className: "h-7 rounded border border-slate-200 bg-white px-2 text-[12px] text-left truncate hover:border-slate-400 min-w-[70px] max-w-[110px] transition-colors dark:bg-background dark:border-border",
322
+ children: t.source_related_field ? ((oe = V.find(
323
+ (l) => l.value === t.source_related_field
324
+ )) == null ? void 0 : oe.label) ?? t.source_related_field : /* @__PURE__ */ e("span", { className: "text-slate-500", children: B ? "field…" : "—" })
325
+ }
326
+ ) }),
327
+ /* @__PURE__ */ e(k, { className: "w-44 p-0", align: "start", children: /* @__PURE__ */ r(O, { children: [
328
+ /* @__PURE__ */ e(T, { placeholder: "Search…", className: "h-7 text-[12px]" }),
329
+ /* @__PURE__ */ e(S, { children: /* @__PURE__ */ e(v, { children: V.length === 0 ? /* @__PURE__ */ e("div", { className: "px-3 py-2 text-[12px] text-slate-500", children: "No fields" }) : V.map((l) => /* @__PURE__ */ e(
330
+ f,
331
+ {
332
+ value: l.value,
333
+ onSelect: () => {
334
+ d({ ...t, source_related_field: l.value }), Q(!1);
335
+ },
336
+ className: "text-[12px]",
337
+ children: l.label
338
+ },
339
+ l.value
340
+ )) }) })
341
+ ] }) })
342
+ ] })
343
+ ] })
344
+ ] }),
345
+ D && /* @__PURE__ */ e("div", { className: "border-t border-slate-200/70 px-2 py-1.5 dark:border-white/[0.06]", children: /* @__PURE__ */ r("div", { className: "flex items-center gap-1.5 flex-wrap pl-5", children: [
346
+ /* @__PURE__ */ e("span", { className: "text-[12px] font-medium text-slate-500 shrink-0", children: "in" }),
347
+ /* @__PURE__ */ r(y, { open: Y, onOpenChange: s, children: [
348
+ /* @__PURE__ */ e(N, { asChild: !0, children: /* @__PURE__ */ e(
349
+ "button",
350
+ {
351
+ type: "button",
352
+ className: "h-7 rounded border border-slate-200 bg-white px-2 text-[12px] text-left truncate hover:border-slate-400 min-w-[100px] max-w-[140px] transition-colors dark:bg-card dark:border-border",
353
+ children: t.o2m_collection || /* @__PURE__ */ e("span", { className: "text-slate-500", children: _ ? "collection…" : "pick field first" })
354
+ }
355
+ ) }),
356
+ /* @__PURE__ */ e(k, { className: "w-48 p-0", align: "start", children: /* @__PURE__ */ r(O, { children: [
357
+ /* @__PURE__ */ e(T, { placeholder: "Search…", className: "h-7 text-[12px]" }),
358
+ /* @__PURE__ */ e(S, { children: /* @__PURE__ */ e(v, { children: ee.length === 0 ? /* @__PURE__ */ e("div", { className: "px-3 py-2 text-[12px] text-slate-500", children: _ ? "No child relations" : "Pick field first" }) : ee.map((l) => /* @__PURE__ */ e(
359
+ f,
360
+ {
361
+ value: l.value,
362
+ onSelect: () => {
363
+ d({
364
+ ...t,
365
+ o2m_collection: l.value,
366
+ filter_field: void 0,
367
+ source_related_field: ""
368
+ }), s(!1);
369
+ },
370
+ className: "text-[12px]",
371
+ children: l.label
372
+ },
373
+ l.value
374
+ )) }) })
375
+ ] }) })
376
+ ] }),
377
+ /* @__PURE__ */ e("span", { className: "text-[12px] text-slate-500 shrink-0", children: "where" }),
378
+ /* @__PURE__ */ r(y, { open: J, onOpenChange: U, children: [
379
+ /* @__PURE__ */ e(N, { asChild: !0, children: /* @__PURE__ */ e(
380
+ "button",
381
+ {
382
+ type: "button",
383
+ className: "h-7 rounded border border-slate-200 bg-white px-2 text-[12px] text-left truncate hover:border-slate-400 min-w-[80px] max-w-[110px] transition-colors dark:bg-card dark:border-border",
384
+ children: t.filter_field || /* @__PURE__ */ e("span", { className: "text-slate-500", children: "field…" })
385
+ }
386
+ ) }),
387
+ /* @__PURE__ */ e(k, { className: "w-44 p-0", align: "start", children: /* @__PURE__ */ r(O, { children: [
388
+ /* @__PURE__ */ e(T, { placeholder: "Search…", className: "h-7 text-[12px]" }),
389
+ /* @__PURE__ */ e(S, { children: /* @__PURE__ */ e(v, { children: j.length === 0 ? /* @__PURE__ */ e("div", { className: "px-3 py-2 text-[12px] text-slate-500", children: t.o2m_collection ? "No fields" : "Pick collection first" }) : j.map((l) => /* @__PURE__ */ e(
390
+ f,
391
+ {
392
+ value: l.value,
393
+ onSelect: () => {
394
+ d({ ...t, filter_field: l.value }), U(!1);
395
+ },
396
+ className: "text-[12px]",
397
+ children: l.label
398
+ },
399
+ l.value
400
+ )) }) })
401
+ ] }) })
402
+ ] }),
403
+ /* @__PURE__ */ e("span", { className: "text-[12px] text-slate-500 shrink-0", children: "=" }),
404
+ /* @__PURE__ */ r(
405
+ y,
406
+ {
407
+ open: b,
408
+ onOpenChange: (l) => {
409
+ M(l), l || X("");
410
+ },
411
+ children: [
412
+ /* @__PURE__ */ e(N, { asChild: !0, children: /* @__PURE__ */ e(
413
+ "button",
414
+ {
415
+ type: "button",
416
+ className: "h-7 rounded border border-slate-200 bg-white px-2 text-[12px] text-left truncate hover:border-slate-400 min-w-[100px] max-w-[150px] transition-colors font-mono dark:bg-card dark:border-border",
417
+ children: t.filter_value || /* @__PURE__ */ e("span", { className: "text-slate-500 font-sans", children: "value…" })
418
+ }
419
+ ) }),
420
+ /* @__PURE__ */ e(k, { className: "w-52 p-0", align: "start", children: /* @__PURE__ */ r(O, { shouldFilter: !1, children: [
421
+ /* @__PURE__ */ e(
422
+ T,
423
+ {
424
+ placeholder: "$parent.field or literal…",
425
+ className: "h-7 text-[12px]",
426
+ value: P,
427
+ onValueChange: X
428
+ }
429
+ ),
430
+ /* @__PURE__ */ r(S, { children: [
431
+ de.filter((l) => !P || l.value.includes(P)).length > 0 && /* @__PURE__ */ e(v, { heading: "Parent fields", children: de.filter((l) => !P || l.value.includes(P)).map((l) => /* @__PURE__ */ e(
432
+ f,
433
+ {
434
+ value: l.value,
435
+ onSelect: () => {
436
+ d({ ...t, filter_value: l.value }), M(!1), X("");
437
+ },
438
+ className: "text-[12px]",
439
+ children: l.label
440
+ },
441
+ l.value
442
+ )) }),
443
+ P && /* @__PURE__ */ e(v, { heading: "Use as literal", children: /* @__PURE__ */ e(
444
+ f,
445
+ {
446
+ value: `__use__${P}`,
447
+ onSelect: () => {
448
+ d({ ...t, filter_value: P }), M(!1), X("");
449
+ },
450
+ className: "text-[12px] font-mono",
451
+ children: P
452
+ }
453
+ ) })
454
+ ] })
455
+ ] }) })
456
+ ]
457
+ }
458
+ ),
459
+ /* @__PURE__ */ e("span", { className: "text-slate-500 shrink-0", children: "→" }),
460
+ /* @__PURE__ */ r(y, { open: q, onOpenChange: Q, children: [
461
+ /* @__PURE__ */ e(N, { asChild: !0, children: /* @__PURE__ */ e(
462
+ "button",
463
+ {
464
+ type: "button",
465
+ className: "h-7 rounded border border-slate-200 bg-white px-2 text-[12px] text-left truncate hover:border-slate-400 min-w-[80px] max-w-[110px] transition-colors dark:bg-card dark:border-border",
466
+ children: t.source_related_field || /* @__PURE__ */ e("span", { className: "text-slate-500", children: t.o2m_collection ? "field…" : "—" })
467
+ }
468
+ ) }),
469
+ /* @__PURE__ */ e(k, { className: "w-44 p-0", align: "start", children: /* @__PURE__ */ r(O, { children: [
470
+ /* @__PURE__ */ e(T, { placeholder: "Search…", className: "h-7 text-[12px]" }),
471
+ /* @__PURE__ */ e(S, { children: /* @__PURE__ */ e(v, { children: L.length === 0 ? /* @__PURE__ */ e("div", { className: "px-3 py-2 text-[12px] text-slate-500", children: t.o2m_collection ? "No fields" : "Enter collection first" }) : L.map((l) => /* @__PURE__ */ e(
472
+ f,
473
+ {
474
+ value: l.value,
475
+ onSelect: () => {
476
+ d({ ...t, source_related_field: l.value }), Q(!1);
477
+ },
478
+ className: "text-[12px]",
479
+ children: l.label
480
+ },
481
+ l.value
482
+ )) }) })
483
+ ] }) })
484
+ ] })
485
+ ] }) })
486
+ ] });
487
+ }
488
+ function ne({
489
+ value: t,
490
+ opts: m,
491
+ onChange: u,
492
+ className: p
493
+ }) {
494
+ var c;
495
+ const [n, o] = x(!1), d = ((c = m.find((I) => I.value === t)) == null ? void 0 : c.label) ?? t;
496
+ return /* @__PURE__ */ r(y, { open: n, onOpenChange: o, children: [
497
+ /* @__PURE__ */ e(N, { asChild: !0, children: /* @__PURE__ */ r(
498
+ "button",
499
+ {
500
+ type: "button",
501
+ className: ie(
502
+ "h-7 rounded border border-slate-200 bg-white px-2.5 text-[12px] text-slate-700 hover:border-slate-400 flex items-center gap-1 shrink-0 transition-colors dark:bg-card dark:border-border dark:text-foreground",
503
+ p
504
+ ),
505
+ children: [
506
+ d,
507
+ /* @__PURE__ */ e(lt, { className: "h-3 w-3 text-slate-500 ml-0.5 shrink-0" })
508
+ ]
509
+ }
510
+ ) }),
511
+ /* @__PURE__ */ e(k, { className: "w-auto min-w-[120px] p-1", align: "start", children: m.map((I) => /* @__PURE__ */ e(
512
+ "button",
513
+ {
514
+ type: "button",
515
+ onClick: () => {
516
+ u(I.value), o(!1);
517
+ },
518
+ className: ie(
519
+ "w-full text-left px-2.5 py-1.5 rounded text-[12px] hover:bg-muted transition-colors",
520
+ I.value === t ? "font-medium text-slate-900 bg-slate-50 dark:text-foreground dark:bg-muted" : "text-slate-700 dark:text-muted-foreground"
521
+ ),
522
+ children: I.label
523
+ },
524
+ I.value
525
+ )) })
526
+ ] });
527
+ }
528
+ function pt({
529
+ value: t,
530
+ fieldOpts: m,
531
+ onChange: u
532
+ }) {
533
+ var o;
534
+ const [p, n] = x(!1);
535
+ return /* @__PURE__ */ r(y, { open: p, onOpenChange: n, children: [
536
+ /* @__PURE__ */ e(N, { asChild: !0, children: /* @__PURE__ */ e(
537
+ "button",
538
+ {
539
+ type: "button",
540
+ className: "flex-1 h-7 rounded border border-slate-200 bg-white px-2 text-[12px] text-left truncate hover:border-slate-400 min-w-0 dark:bg-card dark:border-border",
541
+ children: t ? ((o = m.find((d) => d.value === t)) == null ? void 0 : o.label) ?? t : /* @__PURE__ */ e("span", { className: "text-slate-500", children: "field…" })
542
+ }
543
+ ) }),
544
+ /* @__PURE__ */ e(k, { className: "w-52 p-0", align: "start", children: /* @__PURE__ */ r(O, { children: [
545
+ /* @__PURE__ */ e(T, { placeholder: "Search…", className: "h-7 text-[12px]" }),
546
+ /* @__PURE__ */ e(S, { children: /* @__PURE__ */ e(v, { children: m.map((d) => /* @__PURE__ */ e(
547
+ f,
548
+ {
549
+ value: d.value,
550
+ onSelect: () => {
551
+ u(d.value), n(!1);
552
+ },
553
+ className: "text-[12px]",
554
+ children: d.label
555
+ },
556
+ d.value
557
+ )) }) })
558
+ ] }) })
559
+ ] });
560
+ }
561
+ function St({
562
+ rule: t,
563
+ childFields: m,
564
+ m2oRels: u,
565
+ o2mRels: p,
566
+ onChange: n,
567
+ onRemove: o,
568
+ portalContainer: d,
569
+ parentContextFields: c,
570
+ leading: I
571
+ }) {
572
+ var Ke, Me, De, Ve, Le, Ee, Re, Ae, Ue, Be;
573
+ const h = ke(), [K, H] = x(!t.trigger_field), [le, q] = x(!1), [Q, J] = x(!1), [U, Y] = x(!1), [s, b] = x(!1), [M, P] = x(!1), [X, D] = x(!1), [z, Z] = x(!1), [B, xe] = x(""), V = m.filter((a) => !p.some((i) => i.one_field === a.field)).map((a) => ({
574
+ value: a.field,
575
+ label: st(a.field),
576
+ hint: dt(a.field, a.type, u, p)
577
+ })).sort((a, i) => a.label.localeCompare(i.label)), R = !!t.trigger_field && t.trigger_field.startsWith("$parent."), G = !R && !!t.trigger_field && !!u.find((a) => a.many_field === t.trigger_field), _ = t.trigger_field ? ((Ke = u.find((a) => a.many_field === t.trigger_field)) == null ? void 0 : Ke.one_collection) ?? null : null, re = R ? ((Me = c == null ? void 0 : c.find((a) => `$parent.${a.field}` === t.trigger_field)) == null ? void 0 : Me.label) ?? t.trigger_field.slice(8) : null, ee = R ? ((De = c == null ? void 0 : c.find((a) => `$parent.${a.field}` === t.trigger_field)) == null ? void 0 : De.one_collection) ?? null : null, se = (t.trigger_related_field ?? "").split(".").filter(Boolean), j = se[0] ?? null, L = se[1] ?? null, { data: de } = C({
578
+ queryKey: ["field-config-all", _],
579
+ queryFn: () => h.get(`/field-config/${_}`).then(
580
+ (a) => a.data.data ?? []
581
+ ),
582
+ enabled: !!_ && (t.target_type === "relation_field" || G),
583
+ staleTime: 300 * 1e3
584
+ }), W = (de ?? []).filter(
585
+ (a) => a.field !== "id" && !fe.has(a.type ?? "")
586
+ ).map((a) => ({
587
+ value: a.field,
588
+ label: a.label || a.field
589
+ })), { data: ce } = C({
590
+ queryKey: We.relationsFor(_),
591
+ queryFn: () => h.get(`/data-model/relations/for/${_}`).then((a) => a.data.data ?? []),
592
+ enabled: !!_ && G,
593
+ staleTime: 300 * 1e3
594
+ }), te = j ? (ce ?? []).find(
595
+ (a) => a.many_collection === _ && a.many_field === j && !a.junction_field
596
+ ) : null, A = (te == null ? void 0 : te.one_collection) ?? null, { data: oe } = C({
597
+ queryKey: ["field-config-all", A],
598
+ queryFn: () => h.get(`/field-config/${A}`).then(
599
+ (a) => a.data.data ?? []
600
+ ),
601
+ enabled: !!A,
602
+ staleTime: 300 * 1e3
603
+ }), l = (oe ?? []).filter(
604
+ (a) => a.field !== "id" && !fe.has(a.type ?? "")
605
+ ).map((a) => ({
606
+ value: a.field,
607
+ label: a.label || a.field
608
+ })), F = t.target_field ? u.find(
609
+ (a) => a.many_field === t.target_field && !a.junction_field
610
+ ) : null, $ = (F == null ? void 0 : F.one_collection) ?? null, { data: pe } = C({
611
+ queryKey: ["field-config-all", $, "pick"],
612
+ queryFn: () => h.get(`/field-config/${$}`).then(
613
+ (a) => a.data.data ?? []
614
+ ),
615
+ enabled: !!$ && t.target_type === "pick",
616
+ staleTime: 300 * 1e3
617
+ }), be = ge(() => {
618
+ var E;
619
+ const a = pe ?? [], i = ["name", "title", "label", "display_name", "subject", "heading"], g = a.find((ue) => i.includes(ue.field));
620
+ if (g) return g.field;
621
+ const w = /* @__PURE__ */ new Set(["string", "text", "varchar", "nvarchar", "char"]);
622
+ return ((E = a.find((ue) => ue.field !== "id" && w.has(ue.type ?? ""))) == null ? void 0 : E.field) ?? null;
623
+ }, [pe]), { data: Ye } = C({
624
+ queryKey: ["row-rule-pick-items", $, B],
625
+ queryFn: () => {
626
+ const a = new URLSearchParams({ limit: "20" });
627
+ return B && a.set("search", B), h.get(`/items/${$}?${a}`).then((i) => i.data.data ?? []);
628
+ },
629
+ enabled: !!$ && t.target_type === "pick" && z,
630
+ staleTime: 30 * 1e3
631
+ }), we = Ye ?? [], { data: Oe } = C({
632
+ queryKey: ["row-rule-pick-value-item", $, t.target_value],
633
+ queryFn: () => h.get(`/items/${$}/${t.target_value}`).then((a) => a.data.data ?? null),
634
+ enabled: !!$ && t.target_type === "pick" && !!t.target_value,
635
+ staleTime: 300 * 1e3
636
+ }), _e = R ? ee : G ? _ : null, Se = !!_e && !!t.trigger_value && ["eq", "neq"].includes(t.trigger_op ?? ""), { data: ze } = C({
637
+ queryKey: ["row-rule-trigger-value-item", _e, t.trigger_value],
638
+ queryFn: () => h.get(`/items/${_e}/${t.trigger_value}`).then((a) => a.data.data ?? null),
639
+ enabled: Se,
640
+ staleTime: 300 * 1e3
641
+ });
642
+ function ve(a, i) {
643
+ if (!a) return i ?? null;
644
+ const w = ["name", "title", "label", "display_name", "subject", "heading"].find((E) => a[E] != null && String(a[E]).trim() !== "") ?? Object.keys(a).find(
645
+ (E) => E !== "id" && typeof a[E] == "string" && String(a[E]).trim() !== ""
646
+ );
647
+ return w ? String(a[w]) : i ?? null;
648
+ }
649
+ const Ge = !!t.trigger_related_field && (!A || !!L), Je = !!L && ct.has(L), Xe = !!t.trigger_op && !["null", "nnull"].includes(t.trigger_op), $e = t.target_type === "set" || t.target_type === "relation_field", Te = t.target_type === "relation_field" && !!_, Ze = t.target_type === "pick", ae = t.sources ?? [];
650
+ function qe(a, i) {
651
+ const g = [...ae], w = g[a];
652
+ g[a] = g[a + i], g[a + i] = w, n({ ...t, sources: g });
653
+ }
654
+ const he = R ? `↑ ${re ?? t.trigger_field.slice(8)}` : t.trigger_field ? ((Ve = V.find((a) => a.value === t.trigger_field)) == null ? void 0 : Ve.label) ?? t.trigger_field : null, Pe = {
655
+ eq: "=",
656
+ neq: "≠",
657
+ nnull: "≠ empty",
658
+ null: "is empty",
659
+ in: "in",
660
+ contains: "~"
661
+ }[t.trigger_op ?? "nnull"] ?? t.trigger_op ?? "", me = Se ? ve(ze, t.trigger_value) : t.trigger_value, je = me ? ` "${me.length > 20 ? `${me.slice(0, 20)}…` : me}"` : "", Ce = t.target_field ? ((Le = V.find((a) => a.value === t.target_field)) == null ? void 0 : Le.label) ?? t.target_field : null, Ie = t.target_type === "pick" && t.target_value ? ve(Oe, t.target_value) : null, Fe = {
662
+ set: "",
663
+ relation_field: "M2O",
664
+ precedence: "chain",
665
+ clear: "clear",
666
+ pick: ""
667
+ }, et = t.target_type === "pick" && Ie ? ` = ${Ie}` : "", tt = he && Ce ? `${he} ${Pe}${je} → ${Ce}${et}${Fe[t.target_type] ? ` · ${Fe[t.target_type]}` : ""}` : he ? `${he} ${Pe}${je} → ?` : "(new rule — click to configure)";
668
+ return /* @__PURE__ */ r("div", { className: ie(Qe, "overflow-hidden"), children: [
669
+ /* @__PURE__ */ r(
670
+ "div",
671
+ {
672
+ role: "button",
673
+ tabIndex: 0,
674
+ "aria-expanded": K,
675
+ className: "flex items-center gap-1.5 px-2.5 py-2 cursor-pointer select-none hover:bg-muted transition-colors",
676
+ onClick: () => H((a) => !a),
677
+ onKeyDown: (a) => {
678
+ a.target === a.currentTarget && (a.key === "Enter" || a.key === " ") && (a.preventDefault(), H((i) => !i));
679
+ },
680
+ children: [
681
+ I,
682
+ /* @__PURE__ */ e(
683
+ at,
684
+ {
685
+ className: `h-3.5 w-3.5 text-slate-500 shrink-0 transition-transform duration-150 ${K ? "rotate-90" : ""}`
686
+ }
687
+ ),
688
+ /* @__PURE__ */ e("span", { className: "flex-1 text-[12px] text-slate-600 truncate min-w-0 dark:text-muted-foreground", children: tt }),
689
+ t.only_if_empty && /* @__PURE__ */ e("span", { className: "shrink-0 rounded px-1 py-0.5 text-[12px] font-medium bg-amber-50 text-amber-700 border border-amber-100 dark:bg-amber-400/10 dark:text-amber-300 dark:border-amber-700/60", children: "fallback" }),
690
+ /* @__PURE__ */ e(
691
+ "button",
692
+ {
693
+ type: "button",
694
+ "aria-label": "Remove rule",
695
+ onClick: (a) => {
696
+ a.stopPropagation(), o();
697
+ },
698
+ className: "shrink-0 text-slate-500 hover:text-red-600 dark:hover:text-red-400 transition-colors ml-1 dark:text-muted-foreground",
699
+ children: /* @__PURE__ */ e(Ne, { className: "h-3.5 w-3.5" })
700
+ }
701
+ )
702
+ ]
703
+ }
704
+ ),
705
+ K && /* @__PURE__ */ r(ye, { children: [
706
+ /* @__PURE__ */ e("div", { className: "border-t border-slate-200/70 px-2.5 py-2 space-y-1.5 dark:border-white/[0.06]", children: /* @__PURE__ */ r("div", { className: "flex items-start gap-1.5", children: [
707
+ /* @__PURE__ */ e("span", { className: "text-[12px] font-semibold text-slate-500 mt-[7px] w-5 shrink-0", children: "IF" }),
708
+ /* @__PURE__ */ r("div", { className: "flex-1 min-w-0 space-y-1.5", children: [
709
+ /* @__PURE__ */ r(
710
+ "div",
711
+ {
712
+ className: "flex items-center gap-1.5",
713
+ "data-setting": "field.row_rules.trigger_field",
714
+ children: [
715
+ /* @__PURE__ */ r(y, { open: le, onOpenChange: q, children: [
716
+ /* @__PURE__ */ e(N, { asChild: !0, children: /* @__PURE__ */ e(
717
+ "button",
718
+ {
719
+ type: "button",
720
+ className: "flex-1 h-7 rounded border border-slate-200 bg-white px-2 text-[12px] text-left truncate hover:border-slate-400 min-w-0 dark:bg-card dark:border-border",
721
+ children: R ? /* @__PURE__ */ r("span", { className: "flex items-center gap-1", children: [
722
+ /* @__PURE__ */ e("span", { className: "text-[12px] bg-nvr-cyan/10 text-nvr-cyan rounded px-1 py-0.5 shrink-0", children: "parent" }),
723
+ re
724
+ ] }) : t.trigger_field ? ((Ee = V.find((a) => a.value === t.trigger_field)) == null ? void 0 : Ee.label) ?? t.trigger_field : /* @__PURE__ */ e("span", { className: "text-slate-500", children: "when field changes…" })
725
+ }
726
+ ) }),
727
+ /* @__PURE__ */ e(k, { className: "w-52 p-0", align: "start", container: d, children: /* @__PURE__ */ r(O, { children: [
728
+ /* @__PURE__ */ e(T, { placeholder: "Search…", className: "h-8 text-[12px]" }),
729
+ /* @__PURE__ */ r(S, { className: "max-h-[220px]", children: [
730
+ c && c.length > 0 && /* @__PURE__ */ e(v, { heading: "↑ Parent record", children: c.map((a) => /* @__PURE__ */ r(
731
+ f,
732
+ {
733
+ value: `parent ${a.label} ${a.field}`,
734
+ onSelect: () => {
735
+ n({
736
+ ...t,
737
+ trigger_field: `$parent.${a.field}`,
738
+ trigger_related_field: null
739
+ }), q(!1);
740
+ },
741
+ className: "text-[12px] flex items-center justify-between gap-2",
742
+ children: [
743
+ /* @__PURE__ */ e("span", { className: "truncate", children: a.label }),
744
+ /* @__PURE__ */ e("span", { className: "shrink-0 text-[12px] bg-nvr-cyan/10 text-nvr-cyan rounded px-1", children: "parent" })
745
+ ]
746
+ },
747
+ `$parent.${a.field}`
748
+ )) }),
749
+ /* @__PURE__ */ e(
750
+ v,
751
+ {
752
+ heading: c != null && c.length ? "Child record" : void 0,
753
+ children: V.map((a) => /* @__PURE__ */ r(
754
+ f,
755
+ {
756
+ value: `${a.label} ${a.value}`,
757
+ onSelect: () => {
758
+ n({
759
+ ...t,
760
+ trigger_field: a.value,
761
+ trigger_related_field: null
762
+ }), q(!1);
763
+ },
764
+ className: "text-[12px] flex items-center justify-between gap-2",
765
+ children: [
766
+ /* @__PURE__ */ e("span", { className: "truncate", children: a.label }),
767
+ a.hint && /* @__PURE__ */ e("span", { className: "shrink-0 rounded px-1 py-0.5 text-[12px] font-medium bg-slate-100 text-slate-500 dark:bg-muted", children: a.hint })
768
+ ]
769
+ },
770
+ a.value
771
+ ))
772
+ }
773
+ )
774
+ ] })
775
+ ] }) })
776
+ ] }),
777
+ !j && /* @__PURE__ */ e("span", { className: "contents", "data-setting": "field.row_rules.trigger_op", children: /* @__PURE__ */ e(
778
+ ne,
779
+ {
780
+ value: t.trigger_op ?? "nnull",
781
+ opts: [
782
+ { value: "nnull", label: "has value" },
783
+ { value: "null", label: "is empty" },
784
+ { value: "eq", label: "equals" },
785
+ { value: "neq", label: "≠" },
786
+ { value: "in", label: "in list" },
787
+ { value: "contains", label: "contains" }
788
+ ],
789
+ onChange: (a) => n({ ...t, trigger_op: a })
790
+ }
791
+ ) })
792
+ ]
793
+ }
794
+ ),
795
+ G && /* @__PURE__ */ r(
796
+ "div",
797
+ {
798
+ className: "flex items-center gap-1.5 flex-wrap",
799
+ "data-setting": "field.row_rules.trigger_related_field",
800
+ children: [
801
+ /* @__PURE__ */ e("span", { className: "text-[12px] text-slate-500 shrink-0", children: "via:" }),
802
+ /* @__PURE__ */ r(y, { open: s, onOpenChange: b, children: [
803
+ /* @__PURE__ */ e(N, { asChild: !0, children: /* @__PURE__ */ e(
804
+ "button",
805
+ {
806
+ type: "button",
807
+ className: "flex-1 h-7 rounded border border-slate-200 bg-white px-2 text-[12px] text-left truncate hover:border-slate-400 min-w-0 dark:bg-card dark:border-border",
808
+ children: j ? ((Re = W.find((a) => a.value === j)) == null ? void 0 : Re.label) ?? j : /* @__PURE__ */ e("span", { className: "text-slate-500 italic", children: "FK id (direct)" })
809
+ }
810
+ ) }),
811
+ /* @__PURE__ */ e(
812
+ k,
813
+ {
814
+ className: "w-48 p-0",
815
+ align: "start",
816
+ container: d,
817
+ children: /* @__PURE__ */ r(O, { children: [
818
+ /* @__PURE__ */ e(T, { placeholder: "Search…", className: "h-7 text-[12px]" }),
819
+ /* @__PURE__ */ e(S, { className: "max-h-[180px]", children: /* @__PURE__ */ r(v, { children: [
820
+ /* @__PURE__ */ e(
821
+ f,
822
+ {
823
+ value: "__none__",
824
+ onSelect: () => {
825
+ n({ ...t, trigger_related_field: null }), b(!1);
826
+ },
827
+ className: "text-[12px] text-slate-500 italic",
828
+ children: "FK id (direct)"
829
+ }
830
+ ),
831
+ W.map((a) => /* @__PURE__ */ e(
832
+ f,
833
+ {
834
+ value: a.value,
835
+ onSelect: () => {
836
+ n({ ...t, trigger_related_field: a.value }), b(!1);
837
+ },
838
+ className: "text-[12px]",
839
+ children: a.label
840
+ },
841
+ a.value
842
+ ))
843
+ ] }) })
844
+ ] })
845
+ }
846
+ )
847
+ ] }),
848
+ j && A && /* @__PURE__ */ r(ye, { children: [
849
+ /* @__PURE__ */ e("span", { className: "text-[12px] text-slate-500 shrink-0", children: "→" }),
850
+ /* @__PURE__ */ r(y, { open: M, onOpenChange: P, children: [
851
+ /* @__PURE__ */ e(N, { asChild: !0, children: /* @__PURE__ */ e(
852
+ "button",
853
+ {
854
+ type: "button",
855
+ className: "flex-1 h-7 rounded border border-slate-200 bg-white px-2 text-[12px] text-left truncate hover:border-slate-400 min-w-0 dark:bg-card dark:border-border",
856
+ children: L === "__entity__" || L === "__id__" ? /* @__PURE__ */ e("span", { className: "italic", children: "(entity)" }) : L ? ((Ae = l.find((a) => a.value === L)) == null ? void 0 : Ae.label) ?? L : /* @__PURE__ */ e("span", { className: "text-slate-500 italic", children: "field…" })
857
+ }
858
+ ) }),
859
+ /* @__PURE__ */ e(
860
+ k,
861
+ {
862
+ className: "w-48 p-0",
863
+ align: "start",
864
+ container: d,
865
+ children: /* @__PURE__ */ r(O, { children: [
866
+ /* @__PURE__ */ e(T, { placeholder: "Search…", className: "h-7 text-[12px]" }),
867
+ /* @__PURE__ */ e(S, { className: "max-h-[180px]", children: /* @__PURE__ */ r(v, { children: [
868
+ /* @__PURE__ */ e(
869
+ f,
870
+ {
871
+ value: "__entity__",
872
+ onSelect: () => {
873
+ n({
874
+ ...t,
875
+ trigger_related_field: `${j}.__entity__`,
876
+ trigger_value: null
877
+ }), P(!1);
878
+ },
879
+ className: "text-[12px] italic text-slate-500",
880
+ children: "(entity) — record picker"
881
+ }
882
+ ),
883
+ l.map((a) => /* @__PURE__ */ e(
884
+ f,
885
+ {
886
+ value: a.value,
887
+ onSelect: () => {
888
+ n({
889
+ ...t,
890
+ trigger_related_field: `${j}.${a.value}`,
891
+ trigger_value: null
892
+ }), P(!1);
893
+ },
894
+ className: "text-[12px]",
895
+ children: a.label
896
+ },
897
+ a.value
898
+ ))
899
+ ] }) })
900
+ ] })
901
+ }
902
+ )
903
+ ] })
904
+ ] }),
905
+ Ge && /* @__PURE__ */ e("span", { className: "contents", "data-setting": "field.row_rules.trigger_op", children: /* @__PURE__ */ e(
906
+ ne,
907
+ {
908
+ value: t.trigger_op ?? "nnull",
909
+ opts: [
910
+ { value: "nnull", label: "has value" },
911
+ { value: "null", label: "is empty" },
912
+ { value: "eq", label: "equals" },
913
+ { value: "neq", label: "≠" },
914
+ { value: "in", label: "in list" },
915
+ { value: "contains", label: "contains" }
916
+ ],
917
+ onChange: (a) => n({ ...t, trigger_op: a })
918
+ }
919
+ ) })
920
+ ]
921
+ }
922
+ ),
923
+ Xe && /* @__PURE__ */ e("div", { "data-setting": "field.row_rules.trigger_value", children: Je && A ? /* @__PURE__ */ e(
924
+ He,
925
+ {
926
+ collection: A,
927
+ value: t.trigger_value ?? null,
928
+ isMulti: t.trigger_op === "in",
929
+ onChange: (a) => n({ ...t, trigger_value: a })
930
+ }
931
+ ) : R && ee ? /* @__PURE__ */ e(
932
+ He,
933
+ {
934
+ collection: ee,
935
+ value: t.trigger_value ?? null,
936
+ isMulti: t.trigger_op === "in",
937
+ onChange: (a) => n({ ...t, trigger_value: a })
938
+ }
939
+ ) : /* @__PURE__ */ e(
940
+ "input",
941
+ {
942
+ type: "text",
943
+ value: t.trigger_value ?? "",
944
+ onChange: (a) => n({ ...t, trigger_value: a.target.value || null }),
945
+ placeholder: t.trigger_op === "in" ? "val1, val2 (comma-separated)" : "value (or $parent.field_name)",
946
+ className: "w-full h-7 rounded border border-slate-200 bg-white px-2 text-[12px] focus:outline-none focus:ring-1 focus:ring-nvr-cyan dark:bg-card dark:border-border"
947
+ }
948
+ ) }),
949
+ /* @__PURE__ */ r("div", { className: "space-y-1.5", "data-setting": "field.row_rules.trigger_fields", children: [
950
+ (t.trigger_fields ?? []).map((a, i) => /* @__PURE__ */ r("div", { className: "flex items-center gap-1", children: [
951
+ /* @__PURE__ */ e("span", { className: "text-[12px] text-slate-500 shrink-0 italic", children: "or" }),
952
+ /* @__PURE__ */ e(
953
+ pt,
954
+ {
955
+ value: a,
956
+ fieldOpts: V,
957
+ onChange: (g) => {
958
+ const w = [...t.trigger_fields ?? []];
959
+ w[i] = g, n({ ...t, trigger_fields: w });
960
+ }
961
+ }
962
+ ),
963
+ /* @__PURE__ */ e(
964
+ "button",
965
+ {
966
+ type: "button",
967
+ onClick: () => n({
968
+ ...t,
969
+ trigger_fields: (t.trigger_fields ?? []).filter((g, w) => w !== i)
970
+ }),
971
+ "aria-label": "Remove trigger field",
972
+ "data-tip": "Remove trigger field",
973
+ className: "inline-flex h-7 w-7 shrink-0 items-center justify-center rounded text-slate-500 transition-colors hover:bg-slate-100 hover:text-red-600 dark:hover:bg-muted dark:hover:text-red-400",
974
+ children: /* @__PURE__ */ e(Ne, { className: "h-3.5 w-3.5" })
975
+ }
976
+ )
977
+ ] }, i)),
978
+ t.trigger_field && /* @__PURE__ */ e(
979
+ "button",
980
+ {
981
+ type: "button",
982
+ onClick: () => n({ ...t, trigger_fields: [...t.trigger_fields ?? [], ""] }),
983
+ className: "text-[12px] text-nvr-cyan hover:underline",
984
+ children: "+ or when another field changes"
985
+ }
986
+ )
987
+ ] })
988
+ ] })
989
+ ] }) }),
990
+ /* @__PURE__ */ e("div", { className: "border-t border-slate-100 px-2.5 py-2 space-y-1.5 dark:border-border", children: /* @__PURE__ */ r("div", { className: "flex items-start gap-1.5", children: [
991
+ /* @__PURE__ */ e("span", { className: "text-[12px] font-semibold text-slate-500 mt-[7px] w-5 shrink-0", children: "SET" }),
992
+ /* @__PURE__ */ r("div", { className: "flex-1 min-w-0 space-y-1.5", children: [
993
+ /* @__PURE__ */ r("div", { className: "flex items-center gap-1.5", children: [
994
+ /* @__PURE__ */ r(y, { open: Q, onOpenChange: J, children: [
995
+ /* @__PURE__ */ e(N, { asChild: !0, children: /* @__PURE__ */ e(
996
+ "button",
997
+ {
998
+ type: "button",
999
+ "data-setting": "field.row_rules.target_field",
1000
+ className: "flex-1 h-7 rounded border border-slate-200 bg-white px-2 text-[12px] text-left truncate hover:border-slate-400 min-w-0 dark:bg-card dark:border-border",
1001
+ children: t.target_field ? ((Ue = V.find((a) => a.value === t.target_field)) == null ? void 0 : Ue.label) ?? t.target_field : /* @__PURE__ */ e("span", { className: "text-slate-500", children: "target field…" })
1002
+ }
1003
+ ) }),
1004
+ /* @__PURE__ */ e(k, { className: "w-52 p-0", align: "start", container: d, children: /* @__PURE__ */ r(O, { children: [
1005
+ /* @__PURE__ */ e(T, { placeholder: "Search…", className: "h-8 text-[12px]" }),
1006
+ /* @__PURE__ */ e(S, { className: "max-h-[180px]", children: /* @__PURE__ */ e(v, { children: V.map((a) => /* @__PURE__ */ r(
1007
+ f,
1008
+ {
1009
+ value: `${a.label} ${a.value}`,
1010
+ onSelect: () => {
1011
+ n({ ...t, target_field: a.value }), J(!1);
1012
+ },
1013
+ className: "text-[12px] flex items-center justify-between gap-2",
1014
+ children: [
1015
+ /* @__PURE__ */ e("span", { className: "truncate", children: a.label }),
1016
+ a.hint && /* @__PURE__ */ e("span", { className: "shrink-0 rounded px-1 py-0.5 text-[12px] font-medium bg-slate-100 text-slate-500 dark:bg-muted", children: a.hint })
1017
+ ]
1018
+ },
1019
+ a.value
1020
+ )) }) })
1021
+ ] }) })
1022
+ ] }),
1023
+ /* @__PURE__ */ e("span", { className: "contents", "data-setting": "field.row_rules.target_type", children: /* @__PURE__ */ e(
1024
+ ne,
1025
+ {
1026
+ value: t.target_type,
1027
+ opts: [
1028
+ { value: "set", label: "= literal" },
1029
+ { value: "pick", label: "= pick record" },
1030
+ { value: "relation_field", label: "= from M2O" },
1031
+ { value: "precedence", label: "= chain" },
1032
+ { value: "clear", label: "= clear" },
1033
+ { value: "lock", label: "🔒 lock (read-only while matched)" }
1034
+ ],
1035
+ onChange: (a) => n({
1036
+ ...t,
1037
+ target_type: a,
1038
+ target_value: null,
1039
+ sources: []
1040
+ })
1041
+ }
1042
+ ) })
1043
+ ] }),
1044
+ $e && Te && /* @__PURE__ */ r(y, { open: U, onOpenChange: Y, children: [
1045
+ /* @__PURE__ */ e(N, { asChild: !0, children: /* @__PURE__ */ e(
1046
+ "button",
1047
+ {
1048
+ type: "button",
1049
+ "data-setting": "field.row_rules.target_value",
1050
+ className: "w-full h-7 rounded border border-slate-200 bg-white px-2 text-[12px] text-left truncate hover:border-slate-400 dark:bg-card dark:border-border",
1051
+ children: t.target_value ? ((Be = W.find(
1052
+ (a) => a.value === t.target_value
1053
+ )) == null ? void 0 : Be.label) ?? t.target_value : /* @__PURE__ */ r("span", { className: "text-slate-500", children: [
1054
+ "field from ",
1055
+ _,
1056
+ "…"
1057
+ ] })
1058
+ }
1059
+ ) }),
1060
+ /* @__PURE__ */ e(k, { className: "w-52 p-0", align: "start", container: d, children: /* @__PURE__ */ r(O, { children: [
1061
+ /* @__PURE__ */ e(T, { placeholder: "Search…", className: "h-8 text-[12px]" }),
1062
+ /* @__PURE__ */ e(S, { className: "max-h-[180px]", children: /* @__PURE__ */ e(v, { children: W.length === 0 ? /* @__PURE__ */ e("div", { className: "px-3 py-2 text-[12px] text-slate-500", children: "No fields found" }) : W.map((a) => /* @__PURE__ */ e(
1063
+ f,
1064
+ {
1065
+ value: a.value,
1066
+ onSelect: () => {
1067
+ n({ ...t, target_value: a.value }), Y(!1);
1068
+ },
1069
+ className: "text-[12px]",
1070
+ children: a.label
1071
+ },
1072
+ a.value
1073
+ )) }) })
1074
+ ] }) })
1075
+ ] }),
1076
+ $e && !Te && /* @__PURE__ */ r("div", { className: "flex gap-1", "data-setting": "field.row_rules.target_value", children: [
1077
+ /* @__PURE__ */ e(
1078
+ "input",
1079
+ {
1080
+ type: "text",
1081
+ value: t.target_value ?? "",
1082
+ onChange: (a) => n({ ...t, target_value: a.target.value || null }),
1083
+ placeholder: t.target_type === "relation_field" ? "select an M2O trigger field first" : "value",
1084
+ className: "flex-1 h-7 rounded border border-slate-200 bg-white px-2 text-[12px] focus:outline-none focus:ring-1 focus:ring-nvr-cyan min-w-0 dark:bg-card dark:border-border",
1085
+ readOnly: t.target_type === "relation_field"
1086
+ }
1087
+ ),
1088
+ c && c.length > 0 && t.target_type === "set" && /* @__PURE__ */ r(y, { open: X, onOpenChange: D, children: [
1089
+ /* @__PURE__ */ e(N, { asChild: !0, children: /* @__PURE__ */ e(
1090
+ "button",
1091
+ {
1092
+ type: "button",
1093
+ title: "Use parent field value",
1094
+ className: "h-7 px-1.5 rounded border border-slate-200 bg-white text-[12px] text-nvr-cyan hover:border-nvr-cyan shrink-0 dark:bg-card dark:border-border",
1095
+ children: "↑"
1096
+ }
1097
+ ) }),
1098
+ /* @__PURE__ */ e(
1099
+ k,
1100
+ {
1101
+ className: "w-52 p-0",
1102
+ align: "end",
1103
+ container: d,
1104
+ children: /* @__PURE__ */ e(O, { children: /* @__PURE__ */ e(S, { className: "max-h-[180px]", children: /* @__PURE__ */ e(v, { heading: "Copy from parent", children: c.map((a) => /* @__PURE__ */ r(
1105
+ f,
1106
+ {
1107
+ value: `${a.label} ${a.field}`,
1108
+ onSelect: () => {
1109
+ n({ ...t, target_value: `$parent.${a.field}` }), D(!1);
1110
+ },
1111
+ className: "text-[12px] flex items-center justify-between gap-2",
1112
+ children: [
1113
+ /* @__PURE__ */ e("span", { className: "truncate", children: a.label }),
1114
+ /* @__PURE__ */ e("span", { className: "shrink-0 text-[12px] font-mono text-slate-500", children: a.field })
1115
+ ]
1116
+ },
1117
+ a.field
1118
+ )) }) }) })
1119
+ }
1120
+ )
1121
+ ] })
1122
+ ] }),
1123
+ Ze && ($ ? /* @__PURE__ */ r(y, { open: z, onOpenChange: Z, children: [
1124
+ /* @__PURE__ */ e(N, { asChild: !0, children: /* @__PURE__ */ e(
1125
+ "button",
1126
+ {
1127
+ type: "button",
1128
+ "data-setting": "field.row_rules.target_value",
1129
+ className: "w-full h-7 rounded border border-slate-200 bg-white px-2 text-[12px] text-left truncate hover:border-slate-400 dark:bg-card dark:border-border",
1130
+ children: t.target_value ? ve(
1131
+ Oe,
1132
+ t.target_value
1133
+ ) ?? String(t.target_value) : /* @__PURE__ */ r("span", { className: "text-slate-500", children: [
1134
+ "pick from ",
1135
+ $,
1136
+ "…"
1137
+ ] })
1138
+ }
1139
+ ) }),
1140
+ /* @__PURE__ */ e(
1141
+ k,
1142
+ {
1143
+ className: "w-56 p-0",
1144
+ align: "start",
1145
+ container: d,
1146
+ children: /* @__PURE__ */ r(O, { children: [
1147
+ /* @__PURE__ */ e(
1148
+ T,
1149
+ {
1150
+ placeholder: "Search…",
1151
+ className: "h-8 text-[12px]",
1152
+ value: B,
1153
+ onValueChange: xe
1154
+ }
1155
+ ),
1156
+ /* @__PURE__ */ e(S, { className: "max-h-[180px]", children: /* @__PURE__ */ e(v, { children: we.length === 0 ? /* @__PURE__ */ e("div", { className: "px-3 py-2 text-[12px] text-slate-500", children: "No records found" }) : we.map((a) => {
1157
+ const i = String(a.id), g = be && a[be] != null ? String(a[be]) : i;
1158
+ return /* @__PURE__ */ r(
1159
+ f,
1160
+ {
1161
+ value: `${g} ${i}`,
1162
+ onSelect: () => {
1163
+ n({ ...t, target_value: i }), Z(!1);
1164
+ },
1165
+ className: "text-[12px] flex items-center justify-between gap-2",
1166
+ children: [
1167
+ /* @__PURE__ */ e("span", { className: "truncate", children: g }),
1168
+ g !== i && /* @__PURE__ */ e("span", { className: "shrink-0 font-mono text-[12px] text-slate-500", children: i })
1169
+ ]
1170
+ },
1171
+ i
1172
+ );
1173
+ }) }) })
1174
+ ] })
1175
+ }
1176
+ )
1177
+ ] }) : /* @__PURE__ */ e("p", { className: "text-[12px] text-slate-500 italic", children: "Select an M2O target field first" })),
1178
+ t.target_type === "precedence" && /* @__PURE__ */ r("div", { className: "space-y-1.5 pt-0.5", "data-setting": "field.row_rules.sources", children: [
1179
+ /* @__PURE__ */ e("p", { className: "text-[12px] text-slate-500 font-medium", children: "Sources — first non-null wins:" }),
1180
+ ae.map((a, i) => /* @__PURE__ */ e(
1181
+ ot,
1182
+ {
1183
+ source: a,
1184
+ index: i,
1185
+ total: ae.length,
1186
+ m2oRels: u,
1187
+ o2mRels: p,
1188
+ parentContextFields: c,
1189
+ onChange: (g) => n({
1190
+ ...t,
1191
+ sources: ae.map((w, E) => E === i ? g : w)
1192
+ }),
1193
+ onRemove: () => n({ ...t, sources: ae.filter((g, w) => w !== i) }),
1194
+ onMoveUp: () => qe(i, -1),
1195
+ onMoveDown: () => qe(i, 1)
1196
+ },
1197
+ i
1198
+ )),
1199
+ /* @__PURE__ */ e(
1200
+ "button",
1201
+ {
1202
+ type: "button",
1203
+ onClick: () => n({
1204
+ ...t,
1205
+ sources: [
1206
+ ...ae,
1207
+ {
1208
+ source_type: "relation_field",
1209
+ source_field: "",
1210
+ source_related_field: ""
1211
+ }
1212
+ ]
1213
+ }),
1214
+ className: "text-[12px] text-nvr-cyan hover:text-nvr-cyan/80 font-medium transition-colors",
1215
+ children: "+ Add source"
1216
+ }
1217
+ )
1218
+ ] })
1219
+ ] })
1220
+ ] }) }),
1221
+ /* @__PURE__ */ r("div", { className: "border-t border-slate-100 px-2.5 py-1.5 bg-slate-50/50 dark:border-border dark:bg-muted/40", children: [
1222
+ /* @__PURE__ */ r(
1223
+ "label",
1224
+ {
1225
+ className: "flex items-center gap-2 cursor-pointer",
1226
+ "data-setting": "field.row_rules.only_if_empty",
1227
+ children: [
1228
+ /* @__PURE__ */ e(
1229
+ "input",
1230
+ {
1231
+ type: "checkbox",
1232
+ checked: !!t.only_if_empty,
1233
+ onChange: (a) => n({ ...t, only_if_empty: a.target.checked }),
1234
+ className: "h-3.5 w-3.5 accent-nvr-cyan"
1235
+ }
1236
+ ),
1237
+ /* @__PURE__ */ e("span", { className: "text-[12px] text-slate-600 dark:text-muted-foreground", children: "Only set if target is currently empty" })
1238
+ ]
1239
+ }
1240
+ ),
1241
+ t.target_type !== "lock" && /* @__PURE__ */ r(
1242
+ "label",
1243
+ {
1244
+ className: "mt-1 flex items-center gap-2 cursor-pointer",
1245
+ "data-setting": "field.row_rules.seed_only",
1246
+ children: [
1247
+ /* @__PURE__ */ e(
1248
+ "input",
1249
+ {
1250
+ type: "checkbox",
1251
+ checked: !!t.seed_only,
1252
+ onChange: (a) => n({ ...t, seed_only: a.target.checked }),
1253
+ className: "h-3.5 w-3.5 accent-nvr-cyan"
1254
+ }
1255
+ ),
1256
+ /* @__PURE__ */ e(
1257
+ "span",
1258
+ {
1259
+ className: "text-[12px] text-slate-600 dark:text-muted-foreground",
1260
+ "data-tip": "The target is an input this rule only seeds when empty (a project default). Re-run rules never blanks it to re-derive, and Data Integrity never reports it as drift.",
1261
+ children: "Seed only — target is an input, never re-derived"
1262
+ }
1263
+ )
1264
+ ]
1265
+ }
1266
+ ),
1267
+ t.target_type === "lock" && /* @__PURE__ */ r("div", { className: "mt-1 space-y-1", children: [
1268
+ /* @__PURE__ */ r(
1269
+ "label",
1270
+ {
1271
+ className: "flex items-center gap-2 cursor-pointer",
1272
+ "data-setting": "field.row_rules.except_admin",
1273
+ children: [
1274
+ /* @__PURE__ */ e(
1275
+ "input",
1276
+ {
1277
+ type: "checkbox",
1278
+ checked: t.except_admin === !0,
1279
+ onChange: (a) => {
1280
+ const i = { ...t };
1281
+ a.target.checked ? i.except_admin = !0 : delete i.except_admin, n(i);
1282
+ },
1283
+ className: "h-3.5 w-3.5 accent-nvr-cyan"
1284
+ }
1285
+ ),
1286
+ /* @__PURE__ */ e(
1287
+ "span",
1288
+ {
1289
+ className: "text-[12px] text-slate-600 dark:text-muted-foreground",
1290
+ "data-tip": "Admins (role admin_access) keep editing the field — the lock binds everyone else, in the grid and on API writes.",
1291
+ children: "Except admins — view only for non-admins"
1292
+ }
1293
+ )
1294
+ ]
1295
+ }
1296
+ ),
1297
+ /* @__PURE__ */ e(
1298
+ "input",
1299
+ {
1300
+ "data-setting": "field.row_rules.reason",
1301
+ value: t.reason ?? "",
1302
+ onChange: (a) => n({ ...t, reason: a.target.value || null }),
1303
+ placeholder: 'Lock message shown on hover (optional) — e.g. "set by the rules; ask an admin"',
1304
+ className: "h-7 w-full rounded border border-slate-200 bg-white px-2 text-[12px] dark:bg-card dark:border-border"
1305
+ }
1306
+ )
1307
+ ] }),
1308
+ t.target_type !== "lock" && /* @__PURE__ */ r(
1309
+ "label",
1310
+ {
1311
+ className: "mt-1 flex items-center gap-2 cursor-pointer",
1312
+ "data-setting": "field.row_rules.on_update",
1313
+ children: [
1314
+ /* @__PURE__ */ e(
1315
+ "input",
1316
+ {
1317
+ type: "checkbox",
1318
+ checked: t.on_update !== !1,
1319
+ onChange: (a) => {
1320
+ const i = { ...t };
1321
+ a.target.checked ? delete i.on_update : i.on_update = !1, n(i);
1322
+ },
1323
+ className: "h-3.5 w-3.5 accent-nvr-cyan"
1324
+ }
1325
+ ),
1326
+ /* @__PURE__ */ e(
1327
+ "span",
1328
+ {
1329
+ className: "text-[12px] text-slate-600 dark:text-muted-foreground",
1330
+ "data-tip": "On by default: an API PATCH that changes one of this rule's trigger fields re-derives the target, the same way the form does on edit (a target the caller sent explicitly still wins). Untick to run this rule on creates only.",
1331
+ children: "Re-run on API updates when a trigger field changes"
1332
+ }
1333
+ )
1334
+ ]
1335
+ }
1336
+ )
1337
+ ] })
1338
+ ] })
1339
+ ] });
1340
+ }
1341
+ export {
1342
+ wt as NUMERIC_FIELD_TYPES,
1343
+ pt as OrTriggerPicker,
1344
+ ot as PrecedenceSourceRow,
1345
+ fe as ROW_RULE_SKIP_TYPES,
1346
+ St as RowRuleRow,
1347
+ ne as SelectButton,
1348
+ ct as VIA_ID_MARKERS,
1349
+ He as ViaValuePicker,
1350
+ dt as fieldTypeHint,
1351
+ Ot as reorder,
1352
+ st as toFriendlyFieldLabel
1353
+ };