@nivaro/react 0.3.117 → 0.3.118

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