@nivaro/react 0.3.99 → 0.3.101

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