@nivaro/react 0.3.58 → 0.3.60

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 (43) hide show
  1. package/dist/components/fields/RelationField.js +110 -80
  2. package/dist/full.css +1 -1
  3. package/dist/hooks/useRelationOptions.js +1 -0
  4. package/dist/hooks/useSessionRecorder.js +1 -1
  5. package/dist/index.d.ts +32 -1
  6. package/dist/index.js +523 -520
  7. package/dist/shared/components/CollectionBrowserView.js +2083 -2052
  8. package/dist/shared/components/DataTable.js +497 -465
  9. package/dist/shared/components/ItemEditForm.js +4430 -4282
  10. package/dist/shared/components/PageRenderer.js +537 -508
  11. package/dist/shared/components/QueryTable.js +74 -74
  12. package/dist/shared/components/WidgetSlot.js +543 -520
  13. package/dist/shared/components/alerts/AlertManagerView.js +269 -275
  14. package/dist/shared/components/alerts/types.js +37 -14
  15. package/dist/shared/components/item-edit/FieldRenderer.js +22 -20
  16. package/dist/shared/components/item-edit/GridBulkEditDialog.js +55 -54
  17. package/dist/shared/components/item-edit/InlineTableField.js +2461 -2421
  18. package/dist/shared/components/item-edit/M2MCombobox.js +141 -137
  19. package/dist/shared/components/item-edit/PlanGrid.js +876 -820
  20. package/dist/shared/components/item-edit/QuickCreateButton.js +323 -130
  21. package/dist/shared/components/item-edit/RelationCombobox.js +408 -375
  22. package/dist/shared/components/item-edit/RelationGroupedCombobox.js +255 -156
  23. package/dist/shared/components/item-edit/SummaryPanel.js +356 -343
  24. package/dist/shared/components/item-edit/duplicate-rehearsal.js +47 -0
  25. package/dist/shared/components/item-edit/line-midair.js +82 -75
  26. package/dist/shared/components/item-edit/save-outcome.js +6 -4
  27. package/dist/shared/components/panels/ItemLockBanner.js +212 -209
  28. package/dist/shared/components/panels/PipelinePanel.js +775 -737
  29. package/dist/shared/components/panels/RecordIntegrityBanner.js +114 -86
  30. package/dist/shared/components/panels/RevisionsPanel.js +313 -299
  31. package/dist/shared/components/pipeline/PipelineEditorView.js +26 -16
  32. package/dist/shared/components/queue/QueueQuickFilters.js +13 -13
  33. package/dist/shared/components/queue/QueueWorklist.js +978 -953
  34. package/dist/shared/components/queue/live-state-aspect.js +9 -5
  35. package/dist/shared/components/widgets/ReviewListWidget.js +152 -149
  36. package/dist/shared/lib/display-prefs.js +60 -52
  37. package/dist/shared/lib/draft-store.js +71 -48
  38. package/dist/shared/lib/expression.js +53 -53
  39. package/dist/shared/lib/list-page-memory.js +42 -20
  40. package/dist/shared/lib/money-input.js +45 -0
  41. package/dist/shared/lib/sanitize-html.js +10 -6
  42. package/dist/shared/lib/staged-row-labels.js +18 -0
  43. package/package.json +1 -1
@@ -1,235 +1,249 @@
1
1
  import { jsxs as h, jsx as s } from "react/jsx-runtime";
2
- import { useQuery as C } from "@tanstack/react-query";
3
- import { ChevronDown as Ve, Loader2 as ce, AlertTriangle as ft, Search as mt, X as pt, Check as We } from "lucide-react";
4
- import { useState as E, useRef as j, useEffect as L, useId as gt, useLayoutEffect as bt, useMemo as T } from "react";
5
- import { createPortal as Ge } from "react-dom";
6
- import { useNivaroClient as Le, useItemEditAuth as ht, useStaleFieldReporter as xt } from "../../context.js";
7
- import { get as P, post as yt } from "../../lib/commands.js";
8
- import { compareByMatch as wt } from "../../lib/picker-rank.js";
9
- import { useRecordReader as Ze } from "../../lib/record-loader.js";
10
- import { useOnlineUsers as vt } from "../../lib/use-online-users.js";
11
- import { SearchHighlight as kt } from "../SearchHighlight.js";
12
- import { UserAvatar as Nt } from "../UserAvatar.js";
13
- import { userOptionFilter as St, matchesAllTokens as _t, cn as O } from "../../lib/utils.js";
14
- import { applyDisplayTemplate as S } from "./helpers.js";
15
- import { collidingIds as Lt, disambiguators as qt, isNamelessLabel as X, NAMELESS_LABEL as ee } from "./option-disambiguate.js";
16
- import { usePickerMissReport as $t } from "./picker-miss.js";
17
- import { useLatestSearch as Ct, narrowLocally as Et } from "./picker-search.js";
18
- import { retryRelatedRead as Rt, RelatedMissingLabel as Dt } from "./related-missing.js";
19
- function It(o) {
20
- return o.replace(/\(.*$/, "").trim().split(/\s+/).map((n) => n[0]).filter(Boolean).slice(0, 2).join("").toUpperCase() || "?";
2
+ import { useQuery as R } from "@tanstack/react-query";
3
+ import { ChevronDown as Qe, Loader2 as pe, AlertTriangle as wt, Search as kt, X as Nt, Check as Be } from "lucide-react";
4
+ import { useState as C, useRef as q, useEffect as _, useId as St, useLayoutEffect as et, useMemo as T } from "react";
5
+ import { createPortal as nt } from "react-dom";
6
+ import { useNivaroClient as Ce, useItemEditAuth as _t, useStaleFieldReporter as Lt } from "../../context.js";
7
+ import { get as H, post as $t } from "../../lib/commands.js";
8
+ import { compareByMatch as Et } from "../../lib/picker-rank.js";
9
+ import { useRecordReader as rt } from "../../lib/record-loader.js";
10
+ import { useOnlineUsers as qt } from "../../lib/use-online-users.js";
11
+ import { SearchHighlight as Rt } from "../SearchHighlight.js";
12
+ import { UserAvatar as Ct } from "../UserAvatar.js";
13
+ import { userOptionFilter as Dt, matchesAllTokens as At, cn as P } from "../../lib/utils.js";
14
+ import { applyDisplayTemplate as L } from "./helpers.js";
15
+ import { collidingIds as It, disambiguators as Kt, isNamelessLabel as Z, NAMELESS_LABEL as se } from "./option-disambiguate.js";
16
+ import { usePickerMissReport as jt } from "./picker-miss.js";
17
+ import { useLatestSearch as Ft, narrowLocally as Tt } from "./picker-search.js";
18
+ import { retryRelatedRead as ot, RelatedMissingLabel as st } from "./related-missing.js";
19
+ function Mt(o) {
20
+ return o.replace(/\(.*$/, "").trim().split(/\s+/).map((r) => r[0]).filter(Boolean).slice(0, 2).join("").toUpperCase() || "?";
21
21
  }
22
- function At(o) {
23
- const [n, f] = E(null), y = {
24
- onMouseEnter: (w) => {
22
+ function Ot(o) {
23
+ const [r, p] = C(null), x = {
24
+ onMouseEnter: (v) => {
25
25
  if (!o) return;
26
- const x = w.currentTarget.getBoundingClientRect(), p = window.innerHeight - x.bottom < 80;
27
- f({ x: x.left, y: p ? x.top - 58 : x.bottom + 4 });
26
+ const y = v.currentTarget.getBoundingClientRect(), b = window.innerHeight - y.bottom < 80;
27
+ p({ x: y.left, y: b ? y.top - 58 : y.bottom + 4 });
28
28
  },
29
- onMouseLeave: () => f(null)
30
- }, R = o && n ? Ge(
29
+ onMouseLeave: () => p(null)
30
+ }, D = o && r ? nt(
31
31
  /* @__PURE__ */ s(
32
32
  "div",
33
33
  {
34
- style: { position: "fixed", left: n.x, top: n.y, zIndex: 130 },
34
+ style: { position: "fixed", left: r.x, top: r.y, zIndex: 130 },
35
35
  className: "pointer-events-none max-w-[300px] rounded-md border border-amber-200 bg-amber-50 px-2.5 py-1.5 text-[11.5px] leading-snug text-amber-800 shadow-md dark:border-amber-500/40 dark:bg-[#2a2113] dark:text-amber-300",
36
36
  children: "Current value is not an available option — clear to pick another"
37
37
  }
38
38
  ),
39
39
  document.body
40
40
  ) : null;
41
- return { bind: y, tip: R };
41
+ return { bind: x, tip: D };
42
42
  }
43
- function Xe(o, n) {
44
- return o == null || o === "" || n == null || n === "" ? !1 : String(o) === String(n);
43
+ function tt(o, r) {
44
+ return o == null || o === "" || r == null || r === "" ? !1 : String(o) === String(r);
45
45
  }
46
- function Kt({
46
+ function Ut({
47
47
  collection: o,
48
- value: n,
49
- onChange: f,
50
- disabled: y,
51
- placeholder: R,
52
- extraFilter: w,
53
- autoSelectSingle: x,
54
- optionSort: p,
55
- requiredParent: U,
56
- facets: l,
57
- fieldKey: D,
58
- narrowedBy: i,
59
- pinned: d,
48
+ value: r,
49
+ onChange: p,
50
+ disabled: x,
51
+ placeholder: D,
52
+ extraFilter: v,
53
+ autoSelectSingle: y,
54
+ optionSort: b,
55
+ requiredParent: J,
56
+ facets: c,
57
+ fieldKey: A,
58
+ narrowedBy: l,
59
+ pinned: u,
60
60
  missPlacement: I,
61
- defaultOpen: Qe,
62
- onClose: qe
61
+ defaultOpen: it,
62
+ onClose: De
63
63
  }) {
64
- const H = Le(), $e = Ze(), [c, A] = E(Qe ?? !1), [u, de] = E(""), te = j(qe);
65
- te.current = qe;
66
- const Ce = j(c);
67
- L(() => {
64
+ const z = Ce(), Ae = rt(), [a, K] = C(it ?? !1), [d, ie] = C(""), ae = q(De);
65
+ ae.current = De;
66
+ const Ie = q(a);
67
+ _(() => {
68
68
  var e;
69
- Ce.current && !c && ((e = te.current) == null || e.call(te)), Ce.current = c;
70
- }, [c]);
71
- const [Be, et] = E(!1), M = Ct(u, Be), Ee = j(null), J = j(null), ue = j(null), ne = j(null), fe = gt(), [Re, F] = E(-1);
72
- L(() => {
73
- c ? setTimeout(() => {
74
- var e;
75
- return (e = Ee.current) == null ? void 0 : e.focus();
76
- }, 30) : de("");
77
- }, [c]);
78
- const me = () => {
69
+ Ie.current && !a && ((e = ae.current) == null || e.call(ae)), Ie.current = a;
70
+ }, [a]);
71
+ const [at, lt] = C(!1), M = Ft(d, at), Ke = q(null), Y = q(null), ge = q(null), Q = q(null), be = St(), [je, O] = C(-1), j = q(null), B = () => {
72
+ var t;
73
+ const e = Ke.current;
74
+ if (!e || document.activeElement === e) return;
75
+ e.focus({ preventScroll: !0 });
76
+ const n = e.value.length;
77
+ (t = e.setSelectionRange) == null || t.call(e, n, n);
78
+ };
79
+ _(() => {
80
+ a ? setTimeout(B, 30) : (ie(""), j.current = null);
81
+ }, [a]);
82
+ const he = () => {
79
83
  var e;
80
- A(!1), (e = ne.current) == null || e.focus();
84
+ K(!1), (e = Q.current) == null || e.focus();
81
85
  };
82
- L(() => {
83
- if (!c) return;
84
- const e = (r) => {
85
- var N, _, B;
86
- if (r.key !== "Escape") return;
86
+ _(() => {
87
+ if (!a) return;
88
+ const e = (n) => {
89
+ var S, $, oe;
90
+ if (n.key !== "Escape") return;
87
91
  const t = document.activeElement;
88
- (t === document.body || t && ((N = ue.current) != null && N.contains(t) || (_ = J.current) != null && _.contains(t))) && (r.preventDefault(), r.stopPropagation(), A(!1), (B = ne.current) == null || B.focus());
92
+ (t === document.body || t && ((S = ge.current) != null && S.contains(t) || ($ = Y.current) != null && $.contains(t))) && (n.preventDefault(), n.stopPropagation(), K(!1), (oe = Q.current) == null || oe.focus());
89
93
  };
90
94
  return window.addEventListener("keydown", e, !0), () => window.removeEventListener("keydown", e, !0);
91
- }, [c]), L(() => {
92
- if (!c) return;
93
- const e = (r) => {
94
- var a, N;
95
- const t = r.target;
96
- !t || t === document.body || (a = t.closest) != null && a.call(t, "[data-nvr-combobox-panel]") || (N = J.current) != null && N.contains(t) || A(!1);
95
+ }, [a]), _(() => {
96
+ if (!a) return;
97
+ const e = (n) => {
98
+ var i, S;
99
+ const t = n.target;
100
+ !t || t === document.body || (i = t.closest) != null && i.call(t, "[data-nvr-combobox-panel]") || (S = Y.current) != null && S.contains(t) || K(!1);
97
101
  };
98
102
  return document.addEventListener("focusin", e), () => document.removeEventListener("focusin", e);
99
- }, [c]), L(() => {
100
- if (!c) return;
101
- const e = (r) => {
102
- var a;
103
- const t = r.target;
104
- (a = t == null ? void 0 : t.closest) != null && a.call(t, "[data-nvr-combobox-panel]") || J.current && !J.current.contains(r.target) && A(!1);
103
+ }, [a]), _(() => {
104
+ if (!a) return;
105
+ const e = (n) => {
106
+ var i;
107
+ const t = n.target;
108
+ (i = t == null ? void 0 : t.closest) != null && i.call(t, "[data-nvr-combobox-panel]") || Y.current && !Y.current.contains(n.target) && K(!1);
105
109
  };
106
110
  return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
107
- }, [c]);
108
- const [De, pe] = E(null), [Ie, tt] = E(null);
109
- bt(() => {
110
- if (!c) {
111
- pe(null);
111
+ }, [a]);
112
+ const [ye, xe] = C(null), [ve, ct] = C(null);
113
+ et(() => {
114
+ if (!a) {
115
+ xe(null);
112
116
  return;
113
117
  }
114
118
  const e = () => {
115
- const r = J.current;
116
- if (!r) return;
117
- const t = r.getBoundingClientRect(), a = r.closest('[role="dialog"]') ?? document.body;
118
- tt(a);
119
- const N = window.innerHeight - t.bottom < 340 && t.top > window.innerHeight - t.bottom, _ = t.left, B = N ? t.top - 4 : t.bottom + 4, ze = {
119
+ const n = Y.current;
120
+ if (!n) return;
121
+ const t = n.getBoundingClientRect(), i = n.closest('[role="dialog"]') ?? document.body;
122
+ ct(i);
123
+ const S = window.innerHeight - t.bottom < 340 && t.top > window.innerHeight - t.bottom, $ = t.left, oe = S ? t.top - 4 : t.bottom + 4, Ge = {
120
124
  minWidth: t.width,
121
125
  zIndex: 120,
122
- ...N ? { transform: "translateY(-100%)" } : {}
126
+ ...S ? { transform: "translateY(-100%)" } : {}
123
127
  };
124
- if (a === document.body)
125
- pe({ position: "fixed", left: _, top: B, ...ze });
128
+ if (i === document.body)
129
+ xe({ position: "fixed", left: $, top: oe, ...Ge });
126
130
  else {
127
- const Ye = a.getBoundingClientRect();
128
- pe({ position: "absolute", left: _ - Ye.left, top: B - Ye.top, ...ze });
131
+ const Ze = i.getBoundingClientRect();
132
+ xe({ position: "absolute", left: $ - Ze.left, top: oe - Ze.top, ...Ge });
129
133
  }
130
134
  };
131
135
  return e(), window.addEventListener("scroll", e, !0), window.addEventListener("resize", e), () => {
132
136
  window.removeEventListener("scroll", e, !0), window.removeEventListener("resize", e);
133
137
  };
134
- }, [c]);
135
- const { data: ge, isPending: nt } = C({
138
+ }, [a]);
139
+ const Fe = a && !!ye && !!ve;
140
+ et(() => {
141
+ Fe && document.activeElement === Q.current && B();
142
+ }, [Fe]);
143
+ const { data: we, isPending: dt } = R({
136
144
  queryKey: ["col-meta", o],
137
- queryFn: () => H.request(P(`/collections/${o}`)).then((e) => e.data),
145
+ queryFn: () => z.request(H(`/collections/${o}`)).then((e) => e.data),
138
146
  staleTime: 3e5,
139
147
  retry: !1
140
- }), [be, rt] = E({}), { data: Ae = [] } = C({
148
+ }), [ke, ut] = C({}), { data: Te = [] } = R({
141
149
  queryKey: ["collection-meta", o],
142
- queryFn: () => H.request(
143
- P(`/collections/${o}`)
150
+ queryFn: () => z.request(
151
+ H(`/collections/${o}`)
144
152
  ).then(
145
153
  (e) => {
146
- var r;
147
- return ((r = e.data) == null ? void 0 : r.relations) ?? [];
154
+ var n;
155
+ return ((n = e.data) == null ? void 0 : n.relations) ?? [];
148
156
  }
149
157
  ),
150
- enabled: !!(l != null && l.length),
158
+ enabled: !!(c != null && c.length),
151
159
  staleTime: 10 * 6e4
152
- }), ot = T(() => {
160
+ }), ft = T(() => {
153
161
  const e = {};
154
- for (const r of l ?? []) {
155
- const t = Ae.find(
156
- (a) => a.many_collection === o && a.many_field === r.field && !a.junction_field
162
+ for (const n of c ?? []) {
163
+ const t = Te.find(
164
+ (i) => i.many_collection === o && i.many_field === n.field && !i.junction_field
157
165
  );
158
- t != null && t.one_collection && (e[r.field] = t.one_collection);
166
+ t != null && t.one_collection && (e[n.field] = t.one_collection);
159
167
  }
160
168
  return e;
161
- }, [l, Ae, o]), z = o === "nivaro_users", st = vt(z), Ke = ht().isAdmin, he = T(() => {
169
+ }, [c, Te, o]), W = o === "nivaro_users", mt = qt(W), Me = _t().isAdmin, Ne = T(() => {
162
170
  const e = [];
163
- z && e.push(St(Ke)), w && e.push(w);
164
- for (const [r, t] of Object.entries(be))
165
- t != null && t !== "" && e.push({ [r]: { _eq: t } });
171
+ W && e.push(Dt(Me)), v && e.push(v);
172
+ for (const [n, t] of Object.entries(ke))
173
+ t != null && t !== "" && e.push({ [n]: { _eq: t } });
166
174
  if (e.length !== 0)
167
175
  return e.length === 1 ? e[0] : { _and: e };
168
- }, [w, be, Ke]), re = (ge == null ? void 0 : ge.display_template) ?? (z ? "{{first_name}} {{last_name}} ({{email}})" : null), v = T(() => {
169
- if (!re) return;
170
- const e = [...re.matchAll(/\{\{([\w.]+)\}\}/g)].map((r) => r[1]);
176
+ }, [v, ke, Me]), le = (we == null ? void 0 : we.display_template) ?? (W ? "{{first_name}} {{last_name}} ({{email}})" : null), w = T(() => {
177
+ if (!le) return;
178
+ const e = [...le.matchAll(/\{\{([\w.]+)\}\}/g)].map((n) => n[1]);
171
179
  if (e.length)
172
180
  return ["id", ...e].join(",");
173
- }, [re]), q = he ? JSON.stringify(he) : void 0, Y = p && !/^-?label$/.test(p) ? p : void 0, {
174
- data: g,
175
- isFetching: V,
176
- isPlaceholderData: je
177
- } = C({
181
+ }, [le]), E = Ne ? JSON.stringify(Ne) : void 0, V = b && !/^-?label$/.test(b) ? b : void 0, {
182
+ data: m,
183
+ isFetching: X,
184
+ isPlaceholderData: Oe
185
+ } = R({
178
186
  queryKey: [
179
187
  "relation-opts",
180
188
  o,
181
189
  M,
182
- q,
183
- v,
184
- Y ?? ""
190
+ E,
191
+ w,
192
+ V ?? ""
185
193
  ],
186
- queryFn: () => H.request(
187
- P(`/items/${o}`, {
194
+ queryFn: () => z.request(
195
+ H(`/items/${o}`, {
188
196
  limit: 200,
189
197
  picker: "1",
190
- ...M ? { search: M } : {},
191
- ...q ? { filter: q } : {},
192
- ...v ? { fields: v } : {},
193
- ...Y ? { sort: Y } : {}
198
+ ...M.trim() ? { search: M.trim() } : {},
199
+ ...E ? { filter: E } : {},
200
+ ...w ? { fields: w } : {},
201
+ ...V ? { sort: V } : {}
194
202
  })
195
203
  ).then((e) => e.data ?? []),
196
204
  // Wait for the display template: it decides `fields`, and starting before
197
205
  // it lands sent the whole first page twice.
198
- enabled: c && !nt,
199
- staleTime: q ? 0 : 3e4,
206
+ enabled: a && !dt,
207
+ staleTime: E ? 0 : 3e4,
200
208
  // A new SEARCH keeps the previous answer on screen (narrowed locally below)
201
209
  // instead of blanking the list behind a spinner. A changed filter, sort or
202
210
  // template never does — those rows may no longer be allowed.
203
- placeholderData: (e, r) => {
204
- const t = r == null ? void 0 : r.queryKey;
211
+ placeholderData: (e, n) => {
212
+ const t = n == null ? void 0 : n.queryKey;
205
213
  if (!(!e || !t))
206
- return t[1] === o && t[3] === q && t[4] === v && t[5] === (Y ?? "") ? e : void 0;
214
+ return t[1] === o && t[3] === E && t[4] === w && t[5] === (V ?? "") ? e : void 0;
207
215
  }
208
216
  });
209
- L(() => et(V), [V]), $t({
217
+ _(() => lt(X), [X]), jt({
210
218
  placement: I,
211
- open: c,
219
+ open: a,
212
220
  search: M,
213
- settled: !V && !je && g !== void 0,
214
- count: (g == null ? void 0 : g.length) ?? 0
221
+ settled: !X && !Oe && m !== void 0,
222
+ count: (m == null ? void 0 : m.length) ?? 0
215
223
  });
216
- const { data: oe, isLoading: it } = C({
217
- queryKey: ["relation-single", o, String(n), v],
218
- queryFn: () => $e(o, n, v),
219
- enabled: !!n,
220
- staleTime: 6e4
221
- }), k = (d == null ? void 0 : d.id) != null && d.id !== "" ? String(d.id) : null, { data: K } = C({
222
- queryKey: ["relation-single", o, k ?? "", v],
223
- queryFn: () => $e(o, k, v).catch(
224
+ const {
225
+ data: ee,
226
+ isLoading: Ue,
227
+ error: pt,
228
+ isFetched: gt
229
+ } = R({
230
+ queryKey: ["relation-single", o, String(r), w],
231
+ queryFn: () => Ae(o, r, w),
232
+ enabled: !!r,
233
+ staleTime: 6e4,
234
+ retry: ot
235
+ }), bt = !!r && !Ue && gt && !ee, k = (u == null ? void 0 : u.id) != null && u.id !== "" ? String(u.id) : null, { data: F } = R({
236
+ queryKey: ["relation-single", o, k ?? "", w],
237
+ queryFn: () => Ae(o, k, w).catch(
224
238
  () => null
225
239
  ),
226
- enabled: !!k && c,
240
+ enabled: !!k && a,
227
241
  staleTime: 6e4
228
- }), at = JSON.stringify(w ? { _and: [{ id: { _eq: n } }, w] } : { id: { _eq: n } }), { data: se } = C({
229
- queryKey: ["relation-avail", o, String(n), q],
230
- queryFn: () => H.request(
231
- P(`/items/${o}`, {
232
- filter: at,
242
+ }), ht = JSON.stringify(v ? { _and: [{ id: { _eq: r } }, v] } : { id: { _eq: r } }), { data: ce } = R({
243
+ queryKey: ["relation-avail", o, String(r), E],
244
+ queryFn: () => z.request(
245
+ H(`/items/${o}`, {
246
+ filter: ht,
233
247
  picker: "1",
234
248
  limit: 1,
235
249
  fields: "id"
@@ -238,118 +252,135 @@ function Kt({
238
252
  // The pinned option is offered OUTSIDE the option filter (a type's generic
239
253
  // item is excluded from the general list on purpose), so a value that IS
240
254
  // the pin is available by construction — never probe it, never flag it.
241
- enabled: !!n && !!oe && String(n) !== k,
255
+ enabled: !!r && !!ee && String(r) !== k,
242
256
  staleTime: 3e4
243
- }), G = !!n && String(n) !== k && se !== void 0 && se.length === 0, ie = j(null), xe = j(!1), Te = `${o}|${q ?? ""}`, lt = () => {
244
- xe.current = !0, ie.current = Te, f(null);
245
- }, ae = n == null || n === "";
246
- L(() => {
247
- ae || (xe.current = !1);
248
- }, [ae]), L(() => {
249
- if (!x || y || !ae || xe.current) return;
250
- const e = Te;
251
- ie.current !== e && (ie.current = e, H.request(
252
- P(`/items/${o}`, {
257
+ }), te = !!r && String(r) !== k && ce !== void 0 && ce.length === 0, de = q(null), Se = q(!1), Pe = `${o}|${E ?? ""}`, yt = () => {
258
+ Se.current = !0, de.current = Pe, p(null);
259
+ }, ue = r == null || r === "";
260
+ _(() => {
261
+ ue || (Se.current = !1);
262
+ }, [ue]), _(() => {
263
+ if (!y || x || !ue || Se.current) return;
264
+ const e = Pe;
265
+ de.current !== e && (de.current = e, z.request(
266
+ H(`/items/${o}`, {
253
267
  limit: 2,
254
268
  picker: "1",
255
269
  fields: "id",
256
- ...q ? { filter: q } : {}
270
+ ...E ? { filter: E } : {}
257
271
  })
258
- ).then((r) => {
259
- var a;
260
- const t = r.data ?? [];
261
- t.length === 1 && ((a = t[0]) == null ? void 0 : a.id) != null && f(t[0].id);
272
+ ).then((n) => {
273
+ var i;
274
+ const t = n.data ?? [];
275
+ t.length === 1 && ((i = t[0]) == null ? void 0 : i.id) != null && p(t[0].id);
262
276
  }).catch(() => {
263
- ie.current = null;
277
+ de.current = null;
264
278
  }));
265
- }, [x, y, ae, o, q]);
266
- const m = re, ye = n && oe ? S(m, oe) : null, we = ye === null ? null : X(ye) ? ee : ye, ve = !je && u === M, ke = T(
267
- () => Et(
268
- g ?? [],
269
- (e) => S(m, e) || `#${e.id}`,
279
+ }, [y, x, ue, o, E]);
280
+ const g = le, _e = r && ee ? L(g, ee) : null, Le = _e === null ? null : Z(_e) ? se : _e, U = !Oe && d === M, $e = T(
281
+ () => Tt(
282
+ m ?? [],
283
+ (e) => L(g, e) || `#${e.id}`,
270
284
  // The server also reads a joined code by its parts ("2026-NNO-POWER"
271
285
  // finds 2026-WEST-NNO-HE-POWERING, services/search-synonyms.ts), so
272
286
  // the list narrowed while that search is out does too.
273
- u.replace(/[-_/]+/g, " "),
274
- ve
287
+ d.replace(/[-_/]+/g, " "),
288
+ U
275
289
  ),
276
- [g, m, u, ve]
277
- ), le = T(
278
- () => Lt(g ?? [], (e) => S(m, e) || `#${e.id}`),
279
- [g, m]
280
- ), { data: Z } = C({
281
- queryKey: ["relation-opts-dups", o, le.join(",")],
282
- queryFn: () => H.request(
283
- P(`/items/${o}`, {
284
- limit: le.length,
290
+ [m, g, d, U]
291
+ ), fe = T(
292
+ () => It(m ?? [], (e) => L(g, e) || `#${e.id}`),
293
+ [m, g]
294
+ ), { data: ne } = R({
295
+ queryKey: ["relation-opts-dups", o, fe.join(",")],
296
+ queryFn: () => z.request(
297
+ H(`/items/${o}`, {
298
+ limit: fe.length,
285
299
  picker: "1",
286
- filter: JSON.stringify({ id: { _in: le } }),
300
+ filter: JSON.stringify({ id: { _in: fe } }),
287
301
  fields: "*"
288
302
  })
289
303
  ).then((e) => e.data ?? []),
290
- enabled: c && le.length > 0 && !z,
304
+ enabled: a && fe.length > 0 && !W,
291
305
  staleTime: 6e4
292
- }), Me = T(() => {
293
- if (!(Z != null && Z.length)) return /* @__PURE__ */ new Map();
306
+ }), He = T(() => {
307
+ if (!(ne != null && ne.length)) return /* @__PURE__ */ new Map();
294
308
  const e = new Map(
295
- (g ?? []).map((t) => [
309
+ (m ?? []).map((t) => [
296
310
  String(t.id),
297
- (S(m, t) || `#${t.id}`).trim().toLowerCase()
311
+ (L(g, t) || `#${t.id}`).trim().toLowerCase()
298
312
  ])
299
- ), r = /* @__PURE__ */ new Map();
300
- for (const t of Z) {
301
- const a = e.get(String(t.id));
302
- a !== void 0 && r.set(a, [...r.get(a) ?? [], t]);
313
+ ), n = /* @__PURE__ */ new Map();
314
+ for (const t of ne) {
315
+ const i = e.get(String(t.id));
316
+ i !== void 0 && n.set(i, [...n.get(i) ?? [], t]);
303
317
  }
304
- return qt(
305
- [...r.values()],
306
- ((v == null ? void 0 : v.split(",")) ?? []).map((t) => t.split(".")[0])
318
+ return Kt(
319
+ [...n.values()],
320
+ ((w == null ? void 0 : w.split(",")) ?? []).map((t) => t.split(".")[0])
307
321
  );
308
- }, [Z, g, m, v]), ct = !!n && it && !oe, Fe = At(G), Oe = T(
309
- () => (g ?? []).some((e) => !X(S(m, e))),
310
- [g, m]
311
- ), Q = T(
312
- () => (Y ? [...ke] : [...ke].sort(
313
- (e, r) => wt(
314
- S(m, e),
315
- S(m, r),
316
- u,
317
- p === "-label"
322
+ }, [ne, m, g, w]), xt = !!r && Ue && !ee, Je = Ot(te), ze = T(
323
+ () => (m ?? []).some((e) => !Z(L(g, e))),
324
+ [m, g]
325
+ ), re = T(
326
+ () => (V ? [...$e] : [...$e].sort(
327
+ (e, n) => Et(
328
+ L(g, e),
329
+ L(g, n),
330
+ d,
331
+ b === "-label"
318
332
  )
319
333
  )).filter((e) => !k || String(e.id) !== k).filter(
320
- (e) => !Oe || String(e.id) === String(n) || !X(S(m, e))
334
+ (e) => !ze || String(e.id) === String(r) || !Z(L(g, e))
321
335
  ),
322
- [ke, Y, m, u, p, k, n, Oe]
323
- ), Pe = K && !X(S(m, K)) ? S(m, K) : ee, Ne = !!k && (!u.trim() || _t(
324
- `${K ? Pe : ""} ${(d == null ? void 0 : d.tag) ?? "Default"}`,
325
- u.replace(/[-_/]+/g, " ")
326
- )), W = Ne ? 1 : 0, $ = W + Q.length, b = Re >= $ ? $ - 1 : Re;
327
- L(() => {
328
- F(c && u.trim() ? W : -1);
329
- }, [c, u, W]);
330
- const Se = (e) => `${fe}-opt-${e}`, Ue = () => {
331
- const e = (K == null ? void 0 : K.id) ?? (d == null ? void 0 : d.id);
332
- Xe(n, e) || f(e), me();
333
- }, He = (e) => {
334
- Xe(n, e.id) || f(e.id), me();
335
- }, Je = (e) => {
336
- e < 0 || e >= $ || (e < W ? Ue() : He(Q[e - W]));
336
+ [$e, V, g, d, b, k, r, ze]
337
+ ), Ye = F && !Z(L(g, F)) ? L(g, F) : se, Ee = !!k && (!d.trim() || At(
338
+ `${F ? Ye : ""} ${(u == null ? void 0 : u.tag) ?? "Default"}`,
339
+ d.replace(/[-_/]+/g, " ")
340
+ )), G = Ee ? 1 : 0, N = G + re.length, f = je >= N ? N - 1 : je;
341
+ _(() => {
342
+ O(a && d.trim() ? G : -1);
343
+ }, [a, d, G]);
344
+ const qe = (e) => `${be}-opt-${e}`, We = () => {
345
+ const e = (F == null ? void 0 : F.id) ?? (u == null ? void 0 : u.id);
346
+ tt(r, e) || p(e), he();
347
+ }, Ve = (e) => {
348
+ tt(r, e.id) || p(e.id), he();
349
+ }, me = (e) => {
350
+ e < 0 || e >= N || (e < G ? We() : Ve(re[e - G]));
337
351
  };
338
- L(() => {
339
- var r, t;
340
- if (!c || b < 0) return;
341
- const e = (r = ue.current) == null ? void 0 : r.querySelector(`[data-nav-index="${b}"]`);
352
+ _(() => {
353
+ var n, t;
354
+ if (!a || f < 0) return;
355
+ const e = (n = ge.current) == null ? void 0 : n.querySelector(`[data-nav-index="${f}"]`);
342
356
  (t = e == null ? void 0 : e.scrollIntoView) == null || t.call(e, { block: "nearest" });
343
- }, [c, b]);
344
- const dt = (e) => {
345
- var r;
346
- e.key === "ArrowDown" ? (e.preventDefault(), $ > 0 && F(b < 0 ? 0 : Math.min(b + 1, $ - 1))) : e.key === "ArrowUp" ? (e.preventDefault(), $ > 0 && F(b <= 0 ? 0 : b - 1)) : e.key === "Home" && $ > 0 && !u ? (e.preventDefault(), F(0)) : e.key === "End" && $ > 0 && !u ? (e.preventDefault(), F($ - 1)) : e.key === "Enter" ? (e.preventDefault(), b >= 0 ? Je(b) : $ === 1 && Je(0)) : e.key === "Tab" && (A(!1), (r = ne.current) == null || r.focus());
347
- }, ut = (e) => {
348
- y || (!c && (e.key === "ArrowDown" || e.key === "ArrowUp") ? (e.preventDefault(), A(!0)) : !c && e.key.length === 1 && e.key !== " " && !e.ctrlKey && !e.metaKey && !e.altKey && (e.preventDefault(), A(!0), de(e.key)));
349
- }, _e = xt();
350
- return L(() => {
351
- !_e || !D || se === void 0 || _e(D, G);
352
- }, [_e, D, G, se]), U ? /* @__PURE__ */ h(
357
+ }, [a, f]), _(() => {
358
+ const e = j.current;
359
+ if (e !== null) {
360
+ if (!a || e !== d) {
361
+ j.current = null;
362
+ return;
363
+ }
364
+ U && (j.current = null, f >= 0 ? me(f) : N === 1 && m !== void 0 && me(0));
365
+ }
366
+ }, [a, d, U, f, N]);
367
+ const Xe = (e) => {
368
+ var n;
369
+ e.key === "ArrowDown" ? (e.preventDefault(), N > 0 && O(f < 0 ? 0 : Math.min(f + 1, N - 1))) : e.key === "ArrowUp" ? (e.preventDefault(), N > 0 && O(f <= 0 ? 0 : f - 1)) : e.key === "Home" && N > 0 && !d ? (e.preventDefault(), O(0)) : e.key === "End" && N > 0 && !d ? (e.preventDefault(), O(N - 1)) : e.key === "Enter" ? (e.preventDefault(), d.trim() && !U ? j.current = d : f >= 0 ? me(f) : N === 1 && U && m !== void 0 && me(0)) : e.key === "Tab" && (K(!1), (n = Q.current) == null || n.focus());
370
+ }, vt = (e) => {
371
+ if (x) return;
372
+ const n = e.key.length === 1 && !e.ctrlKey && !e.metaKey && !e.altKey && (a || e.key !== " ");
373
+ if (!a && (e.key === "ArrowDown" || e.key === "ArrowUp"))
374
+ e.preventDefault(), K(!0);
375
+ else if (n) {
376
+ e.preventDefault();
377
+ const t = e.key;
378
+ j.current = null, ie((i) => t === " " && (i === "" || i.endsWith(" ")) ? i : i + t), a ? B() : K(!0);
379
+ } else a && e.key === "Backspace" ? (e.preventDefault(), j.current = null, ie((t) => t.slice(0, -1)), B()) : a && (e.key === "Enter" || e.key === "ArrowDown" || e.key === "ArrowUp" || e.key === "Home" || e.key === "End") && (Xe(e), B());
380
+ }, Re = Lt();
381
+ return _(() => {
382
+ !Re || !A || ce === void 0 || Re(A, te);
383
+ }, [Re, A, te, ce]), J ? /* @__PURE__ */ h(
353
384
  "button",
354
385
  {
355
386
  type: "button",
@@ -358,71 +389,71 @@ function Kt({
358
389
  children: [
359
390
  /* @__PURE__ */ h("span", { className: "truncate text-muted-foreground", children: [
360
391
  "Select ",
361
- U,
392
+ J,
362
393
  " first"
363
394
  ] }),
364
- /* @__PURE__ */ s(Ve, { className: "h-4 w-4 shrink-0 opacity-50" })
395
+ /* @__PURE__ */ s(Qe, { className: "h-4 w-4 shrink-0 opacity-50" })
365
396
  ]
366
397
  }
367
398
  ) : (
368
399
  // Stale tooltip binds on the WRAPPER: a disabled trigger button swallows
369
400
  // mouse events, so a locked-but-stale field would never show the hint.
370
- /* @__PURE__ */ h("div", { ref: J, className: "relative", ...Fe.bind, children: [
401
+ /* @__PURE__ */ h("div", { ref: Y, className: "relative", ...Je.bind, children: [
371
402
  /* @__PURE__ */ h(
372
403
  "button",
373
404
  {
374
- ref: ne,
405
+ ref: Q,
375
406
  type: "button",
376
- disabled: y,
407
+ disabled: x,
377
408
  "aria-haspopup": "listbox",
378
- "aria-expanded": c,
379
- onClick: () => A((e) => !e),
380
- onKeyDown: ut,
381
- className: O(
409
+ "aria-expanded": a,
410
+ onClick: () => K((e) => !e),
411
+ onKeyDown: vt,
412
+ className: P(
382
413
  "flex h-9 w-full items-center justify-between gap-2 rounded-md border bg-background px-3 text-sm text-left hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-nvr-cyan/60 disabled:pointer-events-none disabled:opacity-50",
383
- G ? "border-amber-300 dark:border-amber-600" : "border-input"
414
+ te ? "border-amber-300 dark:border-amber-600" : "border-input"
384
415
  ),
385
416
  children: [
386
- ct ? /* @__PURE__ */ s(ce, { className: "h-3.5 w-3.5 animate-spin text-muted-foreground" }) : /* @__PURE__ */ h(
417
+ xt ? /* @__PURE__ */ s(pe, { className: "h-3.5 w-3.5 animate-spin text-muted-foreground" }) : /* @__PURE__ */ h(
387
418
  "span",
388
419
  {
389
- className: O(
420
+ className: P(
390
421
  "flex items-center gap-1.5 truncate min-w-0",
391
- (!we || we === ee) && "text-muted-foreground"
422
+ (!Le || Le === se) && "text-muted-foreground"
392
423
  ),
393
424
  children: [
394
- G && /* @__PURE__ */ s(ft, { className: "h-3.5 w-3.5 shrink-0 text-amber-500" }),
395
- /* @__PURE__ */ s("span", { className: "truncate", children: we ?? R ?? "Select…" })
425
+ te && /* @__PURE__ */ s(wt, { className: "h-3.5 w-3.5 shrink-0 text-amber-500" }),
426
+ bt ? /* @__PURE__ */ s(st, { error: pt, className: "truncate" }) : /* @__PURE__ */ s("span", { className: "truncate", children: Le ?? D ?? "Select…" })
396
427
  ]
397
428
  }
398
429
  ),
399
- /* @__PURE__ */ s(Ve, { className: "h-4 w-4 shrink-0 opacity-50" })
430
+ /* @__PURE__ */ s(Qe, { className: "h-4 w-4 shrink-0 opacity-50" })
400
431
  ]
401
432
  }
402
433
  ),
403
- Fe.tip,
404
- c && De && Ie && Ge(
434
+ Je.tip,
435
+ a && ye && ve && nt(
405
436
  /* @__PURE__ */ h(
406
437
  "div",
407
438
  {
408
- ref: ue,
439
+ ref: ge,
409
440
  "data-nvr-combobox-panel": "",
410
- style: De,
411
- className: O(
441
+ style: ye,
442
+ className: P(
412
443
  "nvr-pop-in rounded-md border border-border bg-popover shadow-md",
413
- l != null && l.length ? "w-[560px] max-w-[92vw]" : "min-w-[240px] w-max max-w-[360px]"
444
+ c != null && c.length ? "w-[560px] max-w-[92vw]" : "min-w-[240px] w-max max-w-[360px]"
414
445
  ),
415
446
  children: [
416
- !!(l != null && l.length) && /* @__PURE__ */ s("div", { className: "grid grid-cols-2 gap-2 border-b border-border bg-slate-50/60 p-2 dark:bg-muted/40", children: l.map((e) => {
417
- const r = ot[e.field];
418
- return r ? /* @__PURE__ */ h("div", { children: [
447
+ !!(c != null && c.length) && /* @__PURE__ */ s("div", { className: "grid grid-cols-2 gap-2 border-b border-border bg-slate-50/60 p-2 dark:bg-muted/40", children: c.map((e) => {
448
+ const n = ft[e.field];
449
+ return n ? /* @__PURE__ */ h("div", { children: [
419
450
  /* @__PURE__ */ s("p", { className: "mb-0.5 text-[10px] font-medium uppercase tracking-wide text-slate-400", children: e.label ?? e.field }),
420
451
  /* @__PURE__ */ s(
421
- Kt,
452
+ Ut,
422
453
  {
423
- collection: r,
424
- value: be[e.field] ?? null,
425
- onChange: (t) => rt((a) => ({ ...a, [e.field]: t })),
454
+ collection: n,
455
+ value: ke[e.field] ?? null,
456
+ onChange: (t) => ut((i) => ({ ...i, [e.field]: t })),
426
457
  placeholder: "Any",
427
458
  optionSort: e.sort,
428
459
  extraFilter: e.filter
@@ -431,154 +462,156 @@ function Kt({
431
462
  ] }, e.field) : null;
432
463
  }) }),
433
464
  /* @__PURE__ */ h("div", { className: "flex items-center border-b px-3", children: [
434
- /* @__PURE__ */ s(mt, { className: "mr-2 h-4 w-4 shrink-0 opacity-50" }),
465
+ /* @__PURE__ */ s(kt, { className: "mr-2 h-4 w-4 shrink-0 opacity-50" }),
435
466
  /* @__PURE__ */ s(
436
467
  "input",
437
468
  {
438
- ref: Ee,
439
- value: u,
440
- onChange: (e) => de(e.target.value),
441
- onKeyDown: dt,
469
+ ref: Ke,
470
+ value: d,
471
+ onChange: (e) => {
472
+ j.current = null, ie(e.target.value);
473
+ },
474
+ onKeyDown: Xe,
442
475
  role: "combobox",
443
476
  "aria-expanded": !0,
444
477
  "aria-autocomplete": "list",
445
- "aria-controls": `${fe}-list`,
446
- "aria-activedescendant": b >= 0 ? Se(b) : void 0,
478
+ "aria-controls": `${be}-list`,
479
+ "aria-activedescendant": f >= 0 ? qe(f) : void 0,
447
480
  placeholder: "Search…",
448
481
  className: "flex h-9 w-full bg-transparent py-3 text-[13px] outline-none placeholder:text-muted-foreground"
449
482
  }
450
483
  ),
451
- V && g !== void 0 && /* @__PURE__ */ s(
452
- ce,
484
+ X && m !== void 0 && /* @__PURE__ */ s(
485
+ pe,
453
486
  {
454
487
  "data-picker-searching": !0,
455
488
  className: "ml-2 h-3.5 w-3.5 shrink-0 animate-spin text-muted-foreground"
456
489
  }
457
490
  )
458
491
  ] }),
459
- /* @__PURE__ */ h("div", { id: `${fe}-list`, role: "listbox", className: "max-h-52 overflow-y-auto py-1", children: [
460
- !!n && !y && /* @__PURE__ */ h(
492
+ /* @__PURE__ */ h("div", { id: `${be}-list`, role: "listbox", className: "max-h-52 overflow-y-auto py-1", children: [
493
+ !!r && !x && /* @__PURE__ */ h(
461
494
  "button",
462
495
  {
463
496
  type: "button",
464
497
  tabIndex: -1,
465
498
  onClick: () => {
466
- lt(), me();
499
+ yt(), he();
467
500
  },
468
501
  className: "flex w-full items-center gap-2 px-3 py-1.5 text-[13px] text-slate-500 hover:bg-muted border-b border-slate-100 dark:text-slate-400 dark:border-border",
469
502
  children: [
470
- /* @__PURE__ */ s(pt, { className: "h-3.5 w-3.5 text-slate-400" }),
503
+ /* @__PURE__ */ s(Nt, { className: "h-3.5 w-3.5 text-slate-400" }),
471
504
  "Clear selection"
472
505
  ]
473
506
  }
474
507
  ),
475
- Ne && /* @__PURE__ */ h(
508
+ Ee && /* @__PURE__ */ h(
476
509
  "button",
477
510
  {
478
511
  type: "button",
479
512
  tabIndex: -1,
480
- id: Se(0),
513
+ id: qe(0),
481
514
  role: "option",
482
- "aria-selected": String(n) === k,
515
+ "aria-selected": String(r) === k,
483
516
  "data-nav-index": 0,
484
517
  "data-nvr-pinned-option": !0,
485
- onClick: Ue,
486
- onMouseMove: () => b !== 0 && F(0),
487
- className: O(
518
+ onClick: We,
519
+ onMouseMove: () => f !== 0 && O(0),
520
+ className: P(
488
521
  "flex w-full items-center gap-2 border-b border-slate-100 px-3 py-1.5 text-left text-[13px] hover:bg-nvr-cyan/10 dark:border-border",
489
- b === 0 ? "bg-nvr-cyan/10" : "bg-nvr-cyan/5"
522
+ f === 0 ? "bg-nvr-cyan/10" : "bg-nvr-cyan/5"
490
523
  ),
491
524
  children: [
492
525
  /* @__PURE__ */ s(
493
526
  "div",
494
527
  {
495
- className: O(
528
+ className: P(
496
529
  "flex h-4 w-4 shrink-0 items-center justify-center rounded-full border transition-colors",
497
- String(n) === k ? "border-nvr-cyan bg-nvr-cyan" : "border-slate-300"
530
+ String(r) === k ? "border-nvr-cyan bg-nvr-cyan" : "border-slate-300"
498
531
  ),
499
- children: String(n) === k && /* @__PURE__ */ s(We, { className: "h-2.5 w-2.5 text-white" })
532
+ children: String(r) === k && /* @__PURE__ */ s(Be, { className: "h-2.5 w-2.5 text-white" })
500
533
  }
501
534
  ),
502
- /* @__PURE__ */ s("span", { className: "min-w-0 flex-1 truncate", children: K === void 0 ? "Loading…" : Pe }),
503
- /* @__PURE__ */ s("span", { className: "shrink-0 rounded bg-nvr-cyan/15 px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-wide text-slate-700 dark:text-foreground", children: (d == null ? void 0 : d.tag) ?? "Default" })
535
+ /* @__PURE__ */ s("span", { className: "min-w-0 flex-1 truncate", children: F === void 0 ? "Loading…" : Ye }),
536
+ /* @__PURE__ */ s("span", { className: "shrink-0 rounded bg-nvr-cyan/15 px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-wide text-slate-700 dark:text-foreground", children: (u == null ? void 0 : u.tag) ?? "Default" })
504
537
  ]
505
538
  }
506
539
  ),
507
- g === void 0 && V ? /* @__PURE__ */ s("div", { className: "flex items-center justify-center py-4", children: /* @__PURE__ */ s(ce, { className: "h-4 w-4 animate-spin text-muted-foreground" }) }) : Q.length === 0 && !ve ? /* @__PURE__ */ s("p", { className: "px-3 py-2 text-[13px] text-muted-foreground", children: "Searching…" }) : Q.length === 0 ? Ne && u.trim() ? null : i && i.labels.length > 0 && !u.trim() ? /* @__PURE__ */ h("div", { className: "px-3 py-2 text-[12px] leading-5 text-muted-foreground", children: [
540
+ m === void 0 && X ? /* @__PURE__ */ s("div", { className: "flex items-center justify-center py-4", children: /* @__PURE__ */ s(pe, { className: "h-4 w-4 animate-spin text-muted-foreground" }) }) : re.length === 0 && !U ? /* @__PURE__ */ s("p", { className: "px-3 py-2 text-[13px] text-muted-foreground", children: "Searching…" }) : re.length === 0 ? Ee && d.trim() ? null : l && l.labels.length > 0 && !d.trim() ? /* @__PURE__ */ h("div", { className: "px-3 py-2 text-[12px] leading-5 text-muted-foreground", children: [
508
541
  /* @__PURE__ */ h("p", { children: [
509
542
  "No options for",
510
543
  " ",
511
- /* @__PURE__ */ s("span", { className: "font-medium text-foreground", children: i.labels.join(" · ") }),
512
- i.onClear ? " — clear one to widen the list:" : "."
544
+ /* @__PURE__ */ s("span", { className: "font-medium text-foreground", children: l.labels.join(" · ") }),
545
+ l.onClear ? " — clear one to widen the list:" : ". Change it, or ask an administrator to add options for it."
513
546
  ] }),
514
- i.onClear && /* @__PURE__ */ s("div", { className: "mt-1.5 flex flex-wrap gap-1.5", children: i.keys.map(
515
- (e, r) => i.clearable && !i.clearable.includes(e) ? null : /* @__PURE__ */ h(
547
+ l.onClear && /* @__PURE__ */ s("div", { className: "mt-1.5 flex flex-wrap gap-1.5", children: l.keys.map(
548
+ (e, n) => l.clearable && !l.clearable.includes(e) ? null : /* @__PURE__ */ h(
516
549
  "button",
517
550
  {
518
551
  type: "button",
519
552
  onClick: (t) => {
520
- var a;
521
- t.stopPropagation(), (a = i.onClear) == null || a.call(i, e);
553
+ var i;
554
+ t.stopPropagation(), (i = l.onClear) == null || i.call(l, e);
522
555
  },
523
556
  className: "rounded-md border border-border bg-background px-2 py-0.5 text-[11.5px] font-medium text-foreground transition-colors duration-150 hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-nvr-cyan",
524
557
  children: [
525
558
  "Clear ",
526
- i.labels[r] ?? e
559
+ l.labels[n] ?? e
527
560
  ]
528
561
  },
529
562
  e
530
563
  )
531
564
  ) })
532
- ] }) : /* @__PURE__ */ s("p", { className: "px-3 py-2 text-[13px] text-muted-foreground", children: u.trim() ? `No results for “${u.trim()}”` : "No results" }) : Q.map((e, r) => {
533
- const t = S(m, e), a = X(t) ? ee : t, N = String(e.id) === String(n), _ = r + W;
565
+ ] }) : /* @__PURE__ */ s("p", { className: "px-3 py-2 text-[13px] text-muted-foreground", children: d.trim() ? `No results for “${d.trim()}”` : "No results" }) : re.map((e, n) => {
566
+ const t = L(g, e), i = Z(t) ? se : t, S = String(e.id) === String(r), $ = n + G;
534
567
  return /* @__PURE__ */ h(
535
568
  "button",
536
569
  {
537
570
  type: "button",
538
571
  tabIndex: -1,
539
- id: Se(_),
572
+ id: qe($),
540
573
  role: "option",
541
- "aria-selected": N,
542
- "data-nav-index": _,
543
- onClick: () => He(e),
544
- onMouseMove: () => b !== _ && F(_),
545
- className: O(
574
+ "aria-selected": S,
575
+ "data-nav-index": $,
576
+ onClick: () => Ve(e),
577
+ onMouseMove: () => f !== $ && O($),
578
+ className: P(
546
579
  "flex w-full items-center gap-2 px-3 py-1.5 text-[13px] text-left hover:bg-muted",
547
- b === _ && "bg-muted"
580
+ f === $ && "bg-muted"
548
581
  ),
549
582
  children: [
550
583
  /* @__PURE__ */ s(
551
584
  "div",
552
585
  {
553
- className: O(
586
+ className: P(
554
587
  "flex h-4 w-4 shrink-0 items-center justify-center rounded-full border transition-colors",
555
- N ? "border-nvr-cyan bg-nvr-cyan" : "border-slate-300"
588
+ S ? "border-nvr-cyan bg-nvr-cyan" : "border-slate-300"
556
589
  ),
557
- children: N && /* @__PURE__ */ s(We, { className: "h-2.5 w-2.5 text-white" })
590
+ children: S && /* @__PURE__ */ s(Be, { className: "h-2.5 w-2.5 text-white" })
558
591
  }
559
592
  ),
560
- z && /* @__PURE__ */ s(
561
- Nt,
593
+ W && /* @__PURE__ */ s(
594
+ Ct,
562
595
  {
563
596
  userId: e.id,
564
597
  className: "h-4 w-4",
565
- fallback: /* @__PURE__ */ s("span", { className: "flex h-4 w-4 shrink-0 items-center justify-center rounded-full bg-nvr-cyan/20 text-[8px] font-bold text-nvr-navy dark:text-nvr-cyan", children: It(a) })
598
+ fallback: /* @__PURE__ */ s("span", { className: "flex h-4 w-4 shrink-0 items-center justify-center rounded-full bg-nvr-cyan/20 text-[8px] font-bold text-nvr-navy dark:text-nvr-cyan", children: Mt(i) })
566
599
  }
567
600
  ),
568
- z && st.has(String(e.id).toUpperCase()) && /* @__PURE__ */ s(
601
+ W && mt.has(String(e.id).toUpperCase()) && /* @__PURE__ */ s(
569
602
  "span",
570
603
  {
571
604
  className: "h-1.5 w-1.5 shrink-0 rounded-full bg-emerald-500",
572
605
  "data-tip": "Online now"
573
606
  }
574
607
  ),
575
- /* @__PURE__ */ s(kt, { text: a, query: u }),
576
- Me.has(String(e.id)) && /* @__PURE__ */ s(
608
+ /* @__PURE__ */ s(Rt, { text: i, query: d }),
609
+ He.has(String(e.id)) && /* @__PURE__ */ s(
577
610
  "span",
578
611
  {
579
612
  className: "ml-auto max-w-[45%] shrink-0 truncate pl-2 text-[11.5px] text-muted-foreground",
580
613
  "data-option-detail": !0,
581
- children: Me.get(String(e.id))
614
+ children: He.get(String(e.id))
582
615
  }
583
616
  )
584
617
  ]
@@ -587,109 +620,109 @@ function Kt({
587
620
  );
588
621
  })
589
622
  ] }),
590
- !V && /* @__PURE__ */ s(
591
- jt,
623
+ !X && /* @__PURE__ */ s(
624
+ Pt,
592
625
  {
593
626
  collection: o,
594
627
  search: M,
595
- filter: he,
596
- narrowedLabels: (i == null ? void 0 : i.labels) ?? [],
597
- auto: (g ?? []).length === 0 && !!M
628
+ filter: Ne,
629
+ narrowedLabels: (l == null ? void 0 : l.labels) ?? [],
630
+ auto: (m ?? []).length === 0 && !!M
598
631
  }
599
632
  )
600
633
  ]
601
634
  }
602
635
  ),
603
- Ie
636
+ ve
604
637
  )
605
638
  ] })
606
639
  );
607
640
  }
608
- function jt({
641
+ function Pt({
609
642
  collection: o,
610
- search: n,
611
- filter: f,
612
- narrowedLabels: y,
613
- auto: R
643
+ search: r,
644
+ filter: p,
645
+ narrowedLabels: x,
646
+ auto: D
614
647
  }) {
615
- const w = Le(), [x, p] = E(!1), U = f ? JSON.stringify(f) : "", { data: l, isFetching: D } = C({
616
- queryKey: ["picker-narrowing", o, n, U],
617
- queryFn: () => w.request(
618
- yt("/picker-narrowing", { collection: o, search: n, filter: f ?? null })
648
+ const v = Ce(), [y, b] = C(!1), J = p ? JSON.stringify(p) : "", { data: c, isFetching: A } = R({
649
+ queryKey: ["picker-narrowing", o, r, J],
650
+ queryFn: () => v.request(
651
+ $t("/picker-narrowing", { collection: o, search: r, filter: p ?? null })
619
652
  ).then((I) => I.data),
620
- enabled: x || R,
653
+ enabled: y || D,
621
654
  staleTime: 3e4,
622
655
  retry: !1
623
656
  });
624
- if (!x && !R)
657
+ if (!y && !D)
625
658
  return /* @__PURE__ */ s(
626
659
  "button",
627
660
  {
628
661
  type: "button",
629
662
  onClick: (I) => {
630
- I.stopPropagation(), p(!0);
663
+ I.stopPropagation(), b(!0);
631
664
  },
632
665
  className: "w-full border-t border-border px-3 py-1.5 text-left text-[11px] text-muted-foreground hover:text-foreground",
633
666
  "data-picker-narrowing-ask": !0,
634
667
  children: "Missing something?"
635
668
  }
636
669
  );
637
- if (D && !l)
670
+ if (A && !c)
638
671
  return /* @__PURE__ */ s("p", { className: "border-t border-border px-3 py-1.5 text-[11px] text-muted-foreground", children: "Checking what narrows this list…" });
639
- if (!l) return null;
640
- const i = [], d = n ? `match “${n}”` : "exist";
641
- return l.by_field_filter > 0 && i.push(
642
- `${l.by_field_filter.toLocaleString()} more ${d} but this field only offers ${y.length ? `records that fit ${y.join(" · ")}` : "records its filter allows"}.`
643
- ), l.by_exclusions > 0 && i.push(
644
- `${l.by_exclusions.toLocaleString()} ${l.by_exclusions === 1 ? "is" : "are"} hidden from pickers by an admin.`
645
- ), l.scopes.length > 0 && i.push(`Your ${l.scopes.join(", ")} access narrows what you can pick here.`), l.row_filter && i.push("Your role only sees some of these records."), i.length === 0 && i.push(
646
- n ? `Nothing else you can see matches “${n}”.` : "Nothing narrows this list — every record you can see is offered."
672
+ if (!c) return null;
673
+ const l = [], u = r ? `match “${r}”` : "exist";
674
+ return c.by_field_filter > 0 && l.push(
675
+ `${c.by_field_filter.toLocaleString()} more ${u} but this field only offers ${x.length ? `records that fit ${x.join(" · ")}` : "records its filter allows"}.`
676
+ ), c.by_exclusions > 0 && l.push(
677
+ `${c.by_exclusions.toLocaleString()} ${c.by_exclusions === 1 ? "is" : "are"} hidden from pickers by an admin.`
678
+ ), c.scopes.length > 0 && l.push(`Your ${c.scopes.join(", ")} access narrows what you can pick here.`), c.row_filter && l.push("Your role only sees some of these records."), l.length === 0 && l.push(
679
+ r ? `Nothing else you can see matches “${r}”.` : "Nothing narrows this list — every record you can see is offered."
647
680
  ), /* @__PURE__ */ s(
648
681
  "div",
649
682
  {
650
683
  className: "space-y-0.5 border-t border-border px-3 py-1.5 text-[11px] leading-4 text-muted-foreground",
651
684
  "data-picker-narrowing": !0,
652
- "data-picker-narrowing-field": l.by_field_filter,
653
- "data-picker-narrowing-excluded": l.by_exclusions,
654
- children: i.map((I) => /* @__PURE__ */ s("p", { children: I }, I))
685
+ "data-picker-narrowing-field": c.by_field_filter,
686
+ "data-picker-narrowing-excluded": c.by_exclusions,
687
+ children: l.map((I) => /* @__PURE__ */ s("p", { children: I }, I))
655
688
  }
656
689
  );
657
690
  }
658
- function tn({
691
+ function ln({
659
692
  collection: o,
660
- id: n,
661
- displayTemplate: f
693
+ id: r,
694
+ displayTemplate: p
662
695
  }) {
663
- const y = Le(), R = Ze(), w = o === "nivaro_files" || o === "directus_files", x = (() => {
664
- if (!f || !f.includes(".")) return null;
665
- const i = [...f.matchAll(/\{\{([^}]+)\}\}/g)].map((d) => d[1].trim());
666
- return i.length > 0 ? ["id", ...i].join(",") : null;
667
- })(), { data: p, isLoading: U, error: l } = C({
668
- queryKey: ["relation-single", o, String(n), x ?? ""],
669
- queryFn: () => w ? (
696
+ const x = Ce(), D = rt(), v = o === "nivaro_files" || o === "directus_files", y = (() => {
697
+ if (!p || !p.includes(".")) return null;
698
+ const l = [...p.matchAll(/\{\{([^}]+)\}\}/g)].map((u) => u[1].trim());
699
+ return l.length > 0 ? ["id", ...l].join(",") : null;
700
+ })(), { data: b, isLoading: J, error: c } = R({
701
+ queryKey: ["relation-single", o, String(r), y ?? ""],
702
+ queryFn: () => v ? (
670
703
  // The file's row, not its bytes: GET /files/:id downloads the whole
671
704
  // file (twice with the retry, 404 when storage lost it) only to read
672
705
  // its name, and a missing object left the raw id as the label.
673
- y.request(
674
- P(`/files/${encodeURIComponent(String(n))}/meta`)
675
- ).then((i) => i.data)
676
- ) : R(o, n, x),
677
- enabled: !!n && !!o,
706
+ x.request(
707
+ H(`/files/${encodeURIComponent(String(r))}/meta`)
708
+ ).then((l) => l.data)
709
+ ) : D(o, r, y),
710
+ enabled: !!r && !!o,
678
711
  staleTime: 6e4,
679
- retry: Rt
712
+ retry: ot
680
713
  });
681
- if (U) return /* @__PURE__ */ s(ce, { className: "h-3 w-3 animate-spin text-slate-400" });
682
- if (!p) return n == null || n === "" ? null : /* @__PURE__ */ s(Dt, { error: l });
683
- if (w) {
684
- const i = p.title || p.filename_download || p.filename_disk || String(n);
685
- return /* @__PURE__ */ s("span", { children: i });
714
+ if (J) return /* @__PURE__ */ s(pe, { className: "h-3 w-3 animate-spin text-slate-400" });
715
+ if (!b) return r == null || r === "" ? null : /* @__PURE__ */ s(st, { error: c });
716
+ if (v) {
717
+ const l = b.title || b.filename_download || b.filename_disk || String(r);
718
+ return /* @__PURE__ */ s("span", { children: l });
686
719
  }
687
- const D = S(f, p);
688
- return X(D) ? /* @__PURE__ */ s("span", { className: "italic text-muted-foreground", children: ee }) : /* @__PURE__ */ s("span", { children: D });
720
+ const A = L(p, b);
721
+ return Z(A) ? /* @__PURE__ */ s("span", { className: "italic text-muted-foreground", children: se }) : /* @__PURE__ */ s("span", { children: A });
689
722
  }
690
723
  export {
691
- tn as RelatedItemLabel,
692
- Kt as RelationCombobox,
693
- Xe as isSamePick,
694
- At as useStaleTip
724
+ ln as RelatedItemLabel,
725
+ Ut as RelationCombobox,
726
+ tt as isSamePick,
727
+ Ot as useStaleTip
695
728
  };