@nivaro/react 0.3.51 → 0.3.53

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/dist/full.css +1 -1
  2. package/dist/hooks/useSessionRecorder.js +1 -1
  3. package/dist/index.d.ts +47 -3
  4. package/dist/shared/components/ItemEditForm.js +3885 -3847
  5. package/dist/shared/components/NotificationBell.js +163 -150
  6. package/dist/shared/components/PageRenderer.js +600 -549
  7. package/dist/shared/components/ProfileView.js +36 -34
  8. package/dist/shared/components/QueryStatStrip.js +96 -89
  9. package/dist/shared/components/QueryTable.js +214 -215
  10. package/dist/shared/components/ReportView.js +548 -529
  11. package/dist/shared/components/alerts/AlertManagerView.js +346 -320
  12. package/dist/shared/components/item-edit/CatalogPickerField.js +1300 -1219
  13. package/dist/shared/components/item-edit/FieldAffordances.js +145 -136
  14. package/dist/shared/components/item-edit/FieldRenderer.js +366 -326
  15. package/dist/shared/components/item-edit/InlineTableField.js +3047 -2932
  16. package/dist/shared/components/item-edit/NestedRelationEditor.js +149 -143
  17. package/dist/shared/components/item-edit/PlanGrid.js +718 -705
  18. package/dist/shared/components/item-edit/SummaryPanel.js +351 -337
  19. package/dist/shared/components/item-edit/line-qty.js +115 -53
  20. package/dist/shared/components/item-edit/save-refusal.js +18 -18
  21. package/dist/shared/components/item-edit/usePersonalDefaults.js +210 -207
  22. package/dist/shared/components/panels/CommentPanel.js +204 -197
  23. package/dist/shared/components/panels/ItemLockBanner.js +318 -291
  24. package/dist/shared/components/panels/PipelinePanel.js +1388 -1218
  25. package/dist/shared/components/panels/RecordIntegrityBanner.js +201 -172
  26. package/dist/shared/components/panels/RevisionsPanel.js +101 -106
  27. package/dist/shared/components/panels/TransitionRequirementsDialog.js +564 -534
  28. package/dist/shared/components/panels/requirement-side-effects.js +46 -29
  29. package/dist/shared/components/queue/QueueItemSheet.js +219 -146
  30. package/dist/shared/components/queue/QueueWorklist.js +738 -730
  31. package/dist/shared/components/widgets/ReviewListWidget.js +236 -201
  32. package/dist/shared/lib/activity-sentence.js +236 -227
  33. package/dist/shared/lib/record-ref.js +43 -34
  34. package/package.json +1 -1
@@ -1,46 +1,49 @@
1
- import { jsx as e, jsxs as r, Fragment as ue } from "react/jsx-runtime";
2
- import { useQueryClient as ke, useQuery as ee, useMutation as ye } from "@tanstack/react-query";
3
- import { ArrowRight as ze, Loader2 as ae, Check as Re, GitBranch as Oe, AlertTriangle as Lt, ChevronDown as fe, Users as ft, Minus as Mt, UserPlus as Ut, X as ht, Zap as bt, Search as jt } from "lucide-react";
4
- import { useState as K, useRef as te, useEffect as de, useMemo as Fe, Suspense as xt, useCallback as It, lazy as Et } from "react";
5
- import { toast as Z } from "sonner";
6
- import { useNivaroClient as be, useItemEditAuth as Kt } from "../../context.js";
7
- import { get as se, post as he, del as Qt } from "../../lib/commands.js";
8
- import { errorToastOptions as gt, toastError as zt } from "../../lib/error-toast.js";
9
- import { useRecordSignalWhile as yt, useRecordSignalPeers as Wt, signalSentence as Ht } from "../../lib/presence-signals.js";
10
- import { RUN_TRANSITION_EVENT as Te } from "../../lib/run-transition.js";
11
- import { userErrorMessage as ve } from "../../lib/safe-error.js";
12
- import { serverNow as Vt } from "../../lib/server-clock.js";
13
- import { userCardQuery as Xt } from "../../lib/user-cards.js";
14
- import { cn as we, formatRelative as We, humanHours as Gt } from "../../lib/utils.js";
15
- import { PushReadinessChip as Yt } from "../integrations/RecordIntegrationPreview.js";
16
- import { useHeaderFold as Jt } from "../item-edit/HeaderTools.js";
17
- import { invalidateRecordInsights as qe, invalidateRecordData as Ne } from "../item-edit/RecordInsights.js";
18
- import { UserChip as wt } from "../item-edit/UserChip.js";
19
- import { OwnerAvatars as Zt } from "../queue/OwnerAvatars.js";
20
- import { UserAvatar as en } from "../UserAvatar.js";
21
- import { Button as G } from "../ui/button.js";
22
- import { DropdownMenu as Le, DropdownMenuTrigger as Me, DropdownMenuContent as Ue, DropdownMenuGroup as dt, DropdownMenuSeparator as ct, DropdownMenuItem as Ce, DropdownMenuLabel as tn } from "../ui/dropdown-menu.js";
23
- import { Popover as He, PopoverTrigger as Ve, PopoverContent as Xe } from "../ui/popover.js";
24
- import { Skeleton as oe } from "../ui/skeleton.js";
25
- import { TooltipProvider as vt, Tooltip as je, TooltipTrigger as Ie, TooltipContent as Ee } from "../ui/tooltip.js";
26
- import { isAccessRefusal as Nt, deniedToastAction as kt, WhyOwnersButton as nn } from "./AccessInsights.js";
27
- import { BranchLanes as rn } from "./BranchLanes.js";
28
- import { SlaClockLine as an } from "./SlaClock.js";
29
- const _t = Et(
30
- () => import("./TransitionRequirementsDialog.js").then((n) => ({
31
- default: n.TransitionRequirementsDialog
1
+ var Vt = Object.defineProperty;
2
+ var Xt = (t, e, i) => e in t ? Vt(t, e, { enumerable: !0, configurable: !0, writable: !0, value: i }) : t[e] = i;
3
+ var Ee = (t, e, i) => Xt(t, typeof e != "symbol" ? e + "" : e, i);
4
+ import { jsx as n, jsxs as s, Fragment as fe } from "react/jsx-runtime";
5
+ import { useQueryClient as Se, useQuery as te, useMutation as ke } from "@tanstack/react-query";
6
+ import { ArrowRight as Je, Loader2 as se, Check as Me, GitBranch as Ie, AlertTriangle as Yt, ChevronDown as xe, Users as vt, Minus as Jt, UserPlus as Zt, X as Nt, Zap as kt, Search as en } from "lucide-react";
7
+ import { useState as K, useRef as J, useEffect as ue, useMemo as Fe, Suspense as _t, useCallback as St, lazy as tn } from "react";
8
+ import { toast as ee } from "sonner";
9
+ import { useNivaroClient as he, useItemEditAuth as nn } from "../../context.js";
10
+ import { get as ie, post as ye, del as rn } from "../../lib/commands.js";
11
+ import { errorToastOptions as Ct, toastError as an } from "../../lib/error-toast.js";
12
+ import { useRecordSignalWhile as $t, useRecordSignalPeers as sn, signalSentence as ln } from "../../lib/presence-signals.js";
13
+ import { RUN_TRANSITION_EVENT as Ae } from "../../lib/run-transition.js";
14
+ import { userErrorMessage as $e } from "../../lib/safe-error.js";
15
+ import { serverNow as on } from "../../lib/server-clock.js";
16
+ import { userCardQuery as dn } from "../../lib/user-cards.js";
17
+ import { cn as _e, formatRelative as Ze, humanHours as cn } from "../../lib/utils.js";
18
+ import { PushReadinessChip as un } from "../integrations/RecordIntegrationPreview.js";
19
+ import { useHeaderFold as mn } from "../item-edit/HeaderTools.js";
20
+ import { invalidateRecordInsights as Be, invalidateRecordData as Te } from "../item-edit/RecordInsights.js";
21
+ import { UserChip as Tt } from "../item-edit/UserChip.js";
22
+ import { OwnerAvatars as pn } from "../queue/OwnerAvatars.js";
23
+ import { UserAvatar as fn } from "../UserAvatar.js";
24
+ import { Button as Y } from "../ui/button.js";
25
+ import { DropdownMenu as Qe, DropdownMenuTrigger as ze, DropdownMenuContent as We, DropdownMenuGroup as bt, DropdownMenuSeparator as gt, DropdownMenuItem as Pe, DropdownMenuLabel as hn } from "../ui/dropdown-menu.js";
26
+ import { Popover as et, PopoverTrigger as tt, PopoverContent as nt } from "../ui/popover.js";
27
+ import { Skeleton as me } from "../ui/skeleton.js";
28
+ import { TooltipProvider as qt, Tooltip as He, TooltipTrigger as Ge, TooltipContent as Ve } from "../ui/tooltip.js";
29
+ import { isAccessRefusal as Rt, deniedToastAction as Pt, WhyOwnersButton as bn } from "./AccessInsights.js";
30
+ import { BranchLanes as gn } from "./BranchLanes.js";
31
+ import { SlaClockLine as xn } from "./SlaClock.js";
32
+ const Dt = tn(
33
+ () => import("./TransitionRequirementsDialog.js").then((t) => ({
34
+ default: t.TransitionRequirementsDialog
32
35
  }))
33
36
  );
34
- function Ge(n, t) {
35
- const i = n || "System";
36
- return t.on_behalf_of_name ? `${i}, for ${t.on_behalf_of_name}` : i;
37
+ function rt(t, e) {
38
+ const i = t || "System";
39
+ return e.on_behalf_of_name ? `${i}, for ${e.on_behalf_of_name}` : i;
37
40
  }
38
- function sn(n) {
39
- if (n.transition) return null;
40
- const t = (n.comment ?? "").trim();
41
- if (!t.startsWith("{")) return null;
41
+ function yn(t) {
42
+ if (t.transition) return null;
43
+ const e = (t.comment ?? "").trim();
44
+ if (!e.startsWith("{")) return null;
42
45
  try {
43
- const i = JSON.parse(t);
46
+ const i = JSON.parse(e);
44
47
  if (i.action === "split")
45
48
  return `Split into ${Array.isArray(i.children) ? i.children.length : "parallel"} branches`;
46
49
  if (i.action === "join") return "Every branch finished — joined";
@@ -49,20 +52,20 @@ function sn(n) {
49
52
  }
50
53
  return null;
51
54
  }
52
- function $e(n) {
53
- return !(n.first_name || n.last_name || n.user_email);
55
+ function De(t) {
56
+ return !(t.first_name || t.last_name || t.user_email);
54
57
  }
55
- function Ke(n) {
56
- const t = (n.comment ?? "").trim().toLowerCase();
57
- return n.origin === "import" || t.startsWith("import:") ? "Imported" : n.origin === "integration" ? "By an integration" : /-state-sync$/.test(t) || t.startsWith("legacy-") ? "Synced from another system" : t === "state-merge" || t === "instance-migration" ? "Moved by an admin script" : "Moved automatically";
58
+ function Xe(t) {
59
+ const e = (t.comment ?? "").trim().toLowerCase();
60
+ return t.origin === "import" || e.startsWith("import:") ? "Imported" : t.origin === "integration" ? "By an integration" : /-state-sync$/.test(e) || e.startsWith("legacy-") ? "Synced from another system" : e === "state-merge" || e === "instance-migration" ? "Moved by an admin script" : "Moved automatically";
58
61
  }
59
- function Qe(n) {
60
- if (n.transition_text) return n.transition_text;
61
- if (n.transition_label) return `Rule: ${n.transition_label}`;
62
- const t = (n.comment ?? "").trim(), i = /^auto: (.+)$/i.exec(t);
63
- return i ? `Rule: ${i[1]}` : /-state-sync$/i.test(t) ? "The state was copied in from the system that owned this record" : /^instance-migration/i.test(t) ? "Moved when the pipeline was reshaped" : /^state-merge/i.test(t) ? "Moved when two states were merged" : null;
62
+ function Ye(t) {
63
+ if (t.transition_text) return t.transition_text;
64
+ if (t.transition_label) return `Rule: ${t.transition_label}`;
65
+ const e = (t.comment ?? "").trim(), i = /^auto: (.+)$/i.exec(e);
66
+ return i ? `Rule: ${i[1]}` : /-state-sync$/i.test(e) ? "The state was copied in from the system that owned this record" : /^instance-migration/i.test(e) ? "Moved when the pipeline was reshaped" : /^state-merge/i.test(e) ? "Moved when two states were merged" : null;
64
67
  }
65
- const ut = {
68
+ const xt = {
66
69
  validation: "the partner refused what we sent",
67
70
  not_found: "the partner could not find what we referred to",
68
71
  auth: "the partner refused our credentials",
@@ -70,227 +73,345 @@ const ut = {
70
73
  rate_limited: "the partner asked us to slow down",
71
74
  unknown: "the partner refused it"
72
75
  };
73
- function ln(n) {
74
- const t = Math.ceil((new Date(n).getTime() - Vt()) / 6e4);
75
- return !Number.isFinite(t) || t <= 0 ? "on the next check" : t < 60 ? `in ${t} min` : `in ${Math.round(t / 60)}h`;
76
+ function wn(t) {
77
+ const e = Math.ceil((new Date(t).getTime() - on()) / 6e4);
78
+ return !Number.isFinite(e) || e <= 0 ? "on the next check" : e < 60 ? `in ${e} min` : `in ${Math.round(e / 60)}h`;
76
79
  }
77
- function on({ held: n }) {
78
- return n.length === 0 ? null : /* @__PURE__ */ e(
80
+ function vn({ held: t }) {
81
+ return t.length === 0 ? null : /* @__PURE__ */ n(
79
82
  "div",
80
83
  {
81
84
  className: "space-y-2 border-b border-amber-100 bg-amber-50 px-5 py-3 dark:border-amber-500/20 dark:bg-amber-500/10",
82
85
  "data-pipeline-auto-held": !0,
83
- children: n.map((t) => {
84
- const i = t.transition_label ?? "An automatic move", a = ut[t.error_class ?? "unknown"] ?? ut.unknown;
85
- return /* @__PURE__ */ r("div", { className: "text-[12px] text-amber-800 dark:text-amber-300", children: [
86
- /* @__PURE__ */ r("p", { className: "font-medium", children: [
86
+ children: t.map((e) => {
87
+ const i = e.transition_label ?? "An automatic move", r = xt[e.error_class ?? "unknown"] ?? xt.unknown;
88
+ return /* @__PURE__ */ s("div", { className: "text-[12px] text-amber-800 dark:text-amber-300", children: [
89
+ /* @__PURE__ */ s("p", { className: "font-medium", children: [
87
90
  "Needs a person: ",
88
91
  i,
89
92
  " stopped retrying — ",
90
- a,
93
+ r,
91
94
  "."
92
95
  ] }),
93
- t.error && /* @__PURE__ */ e(
96
+ e.error && /* @__PURE__ */ n(
94
97
  "p",
95
98
  {
96
99
  className: "mt-0.5 line-clamp-2 break-words text-[11px] text-amber-700/90 dark:text-amber-300/80",
97
- "data-tip": t.error,
98
- children: t.error
100
+ "data-tip": e.error,
101
+ children: e.error
99
102
  }
100
103
  ),
101
- /* @__PURE__ */ r("p", { className: "mt-1 text-[11px] text-amber-700 dark:text-amber-400", children: [
102
- t.retry_at ? `It tries the same push again ${ln(t.retry_at)}. ` : "It will not send the same push again on its own. ",
104
+ /* @__PURE__ */ s("p", { className: "mt-1 text-[11px] text-amber-700 dark:text-amber-400", children: [
105
+ e.retry_at ? `It tries the same push again ${wn(e.retry_at)}. ` : "It will not send the same push again on its own. ",
103
106
  "Fix the record so what it sends changes, retry the push, or move the record by hand.",
104
- t.attempts > 1 ? ` ${t.attempts} attempts so far.` : ""
107
+ e.attempts > 1 ? ` ${e.attempts} attempts so far.` : ""
105
108
  ] })
106
- ] }, t.transition_id);
109
+ ] }, e.transition_id);
107
110
  })
108
111
  }
109
112
  );
110
113
  }
111
- function St(n) {
114
+ function Ft(t) {
112
115
  var i;
113
- const t = n == null ? void 0 : n.response;
114
- return ((t == null ? void 0 : t.code) ?? ((i = t == null ? void 0 : t.data) == null ? void 0 : i.code)) === "TRANSITION_DUPLICATE";
116
+ const e = t == null ? void 0 : t.response;
117
+ return ((e == null ? void 0 : e.code) ?? ((i = e == null ? void 0 : e.data) == null ? void 0 : i.code)) === "TRANSITION_DUPLICATE";
115
118
  }
116
- function Ct(n) {
119
+ function At(t) {
117
120
  var i;
118
- const t = n;
119
- return (t == null ? void 0 : t.status) === 422 && ((i = t.response) == null ? void 0 : i.error) === "TRANSITION_REQUIREMENTS" ? t.response.requirements ?? [] : null;
121
+ const e = t;
122
+ return (e == null ? void 0 : e.status) === 422 && ((i = e.response) == null ? void 0 : i.error) === "TRANSITION_REQUIREMENTS" ? e.response.requirements ?? [] : null;
120
123
  }
121
- function dn(n) {
122
- var a;
123
- const t = n == null ? void 0 : n.response, i = (t == null ? void 0 : t.code) ?? ((a = t == null ? void 0 : t.data) == null ? void 0 : a.code);
124
+ function Nn(t) {
125
+ var r;
126
+ const e = t == null ? void 0 : t.response, i = (e == null ? void 0 : e.code) ?? ((r = e == null ? void 0 : e.data) == null ? void 0 : r.code);
124
127
  return typeof i == "string" ? i : null;
125
128
  }
126
- const cn = {
129
+ const kn = {
127
130
  PRIORITY_REQUIRED: "priority"
128
131
  };
129
- function $t(n, t) {
130
- const i = dn(n), a = i ? cn[i] : void 0;
131
- return !i || !a ? null : { code: i, actionKey: a, transitionId: t.transition_id, comment: t.comment };
132
+ function Bt(t, e) {
133
+ const i = Nn(t), r = i ? kn[i] : void 0;
134
+ return !i || !r ? null : { code: i, actionKey: r, transitionId: e.transition_id, comment: e.comment };
132
135
  }
133
- const un = 600;
134
- function Tt(n) {
135
- const t = ke(), [i, a] = K(!1), p = te(!0);
136
- de(() => (p.current = !0, () => {
137
- p.current = !1;
136
+ const _n = 600;
137
+ function Mt(t) {
138
+ const e = Se(), [i, r] = K(!1), l = J(!0);
139
+ ue(() => (l.current = !0, () => {
140
+ l.current = !1;
138
141
  }), []);
139
- const d = te(n);
140
- d.current = n;
141
- const f = It(async () => {
142
- a(!0);
142
+ const o = J(t);
143
+ o.current = t;
144
+ const m = St(async () => {
145
+ r(!0);
143
146
  try {
144
- await t.refetchQueries({ queryKey: [...d.current], type: "active" });
147
+ await e.refetchQueries({ queryKey: [...o.current], type: "active" });
145
148
  } catch {
146
149
  }
147
- await new Promise((y) => setTimeout(y, un)), p.current && a(!1);
148
- }, [t]);
149
- return { settling: i, settle: f };
150
+ await new Promise((h) => setTimeout(h, _n)), l.current && r(!1);
151
+ }, [e]);
152
+ return { settling: i, settle: m };
150
153
  }
151
- function qt(n, t, i) {
154
+ const Ne = 1500;
155
+ class Sn {
156
+ constructor() {
157
+ Ee(this, "seen", null);
158
+ Ee(this, "fresh", /* @__PURE__ */ new Map());
159
+ }
160
+ /** Feed the ids on offer now. */
161
+ observe(e, i) {
162
+ const r = new Set(e.map((l) => String(l).toUpperCase()));
163
+ if (this.seen)
164
+ for (const l of r)
165
+ this.seen.has(l) || this.fresh.set(l, { at: i, hovered: !1, left: !1 });
166
+ for (const l of [...this.fresh.keys()]) r.has(l) || this.fresh.delete(l);
167
+ this.seen = r;
168
+ }
169
+ /** The pointer is on the button. */
170
+ enter(e, i) {
171
+ const r = this.fresh.get(String(e).toUpperCase());
172
+ r && !r.left && i - r.at < Ne && (r.hovered = !0);
173
+ }
174
+ /** The pointer left the button. */
175
+ leave(e) {
176
+ const i = this.fresh.get(String(e).toUpperCase());
177
+ i != null && i.hovered && (i.left = !0);
178
+ }
179
+ /** Still inert (no state change)? */
180
+ inert(e, i) {
181
+ const r = this.fresh.get(String(e).toUpperCase());
182
+ return r ? i - r.at < Ne || r.hovered && !r.left : !1;
183
+ }
184
+ /** A press: true = let it through. A press inside the window counts as the pointer being there. */
185
+ press(e, i) {
186
+ const r = String(e).toUpperCase(), l = this.fresh.get(r);
187
+ return l ? i - l.at < Ne ? (l.hovered = !0, l.left = !1, !1) : l.hovered && !l.left ? !1 : (this.fresh.delete(r), !0) : !0;
188
+ }
189
+ /** Inside its time window (drawn dimmed)? */
190
+ timed(e, i) {
191
+ const r = this.fresh.get(String(e).toUpperCase());
192
+ return !!r && i - r.at < Ne;
193
+ }
194
+ /** Any button still inside its time window? */
195
+ hasTimed(e) {
196
+ for (const i of this.fresh.values()) if (e - i.at < Ne) return !0;
197
+ return !1;
198
+ }
199
+ reset() {
200
+ this.seen = null, this.fresh.clear();
201
+ }
202
+ }
203
+ function Ot(t, e) {
204
+ const i = J(null);
205
+ i.current || (i.current = new Sn());
206
+ const r = i.current, l = J(e);
207
+ l.current !== e && (l.current = e, r.reset());
208
+ const [, o] = K(0), m = t ? t.join(",") : null;
209
+ return Fe(() => {
210
+ t && r.observe(t, Date.now());
211
+ }, [r, m]), ue(() => {
212
+ if (!r.hasTimed(Date.now())) return;
213
+ const h = setTimeout(() => o((_) => _ + 1), Ne + 20);
214
+ return () => clearTimeout(h);
215
+ }, [r, m]), {
216
+ dimmed: (h) => r.timed(h, Date.now()),
217
+ press: (h) => r.press(h, Date.now()),
218
+ bind: (h) => ({
219
+ onPointerEnter: () => r.enter(h, Date.now()),
220
+ onPointerMove: () => r.enter(h, Date.now()),
221
+ onPointerLeave: () => r.leave(h)
222
+ })
223
+ };
224
+ }
225
+ function Ut(t, e) {
226
+ return ["approval-brief", t, String(e)];
227
+ }
228
+ function Lt(t, e, i) {
229
+ return t.request(
230
+ ie(`/pipelines/instance/${e}/${i}/approval-brief`)
231
+ ).then((r) => r.data);
232
+ }
233
+ function Cn(t) {
234
+ return (t ?? []).filter((e) => e.tone === "warn" || e.tone === "danger");
235
+ }
236
+ const $n = 4e3;
237
+ function jt(t, e) {
238
+ const i = he(), r = Se();
239
+ return St(async () => {
240
+ try {
241
+ const l = await Promise.race([
242
+ r.fetchQuery({
243
+ queryKey: Ut(t, e),
244
+ queryFn: () => Lt(i, t, e),
245
+ staleTime: 0,
246
+ retry: !1
247
+ }),
248
+ new Promise((o) => setTimeout(() => o(null), $n))
249
+ ]);
250
+ return Cn(l == null ? void 0 : l.lines);
251
+ } catch {
252
+ return [];
253
+ }
254
+ }, [i, r, t, e]);
255
+ }
256
+ function Et({ lines: t }) {
257
+ return t.length === 0 ? null : /* @__PURE__ */ s(
258
+ "div",
259
+ {
260
+ "data-forward-warning": !0,
261
+ className: "rounded-md border border-amber-200 bg-amber-50 px-3 py-2 text-[12px] text-amber-800 dark:border-amber-500/30 dark:bg-amber-500/10 dark:text-amber-200",
262
+ children: [
263
+ t.map((e) => /* @__PURE__ */ s("p", { children: [
264
+ /* @__PURE__ */ n("span", { className: "font-semibold", children: e.label ? `${e.label}: ` : "" }),
265
+ e.text
266
+ ] }, `${e.label}:${e.text}`)),
267
+ /* @__PURE__ */ n("p", { className: "mt-1 text-[11.5px] text-amber-700/90 dark:text-amber-200/80", children: "Check this before you go on. You can still continue." })
268
+ ]
269
+ }
270
+ );
271
+ }
272
+ function Oe(t, e, i) {
152
273
  if (!i) return !1;
153
- const a = t.find(
154
- (d) => String(d.id).toUpperCase() === String(i).toUpperCase()
155
- ), p = t.find((d) => String(d.id).toUpperCase() === String(n.to_state).toUpperCase());
156
- return !!a && !!p && p.sort < a.sort;
274
+ const r = e.find(
275
+ (o) => String(o.id).toUpperCase() === String(i).toUpperCase()
276
+ ), l = e.find((o) => String(o.id).toUpperCase() === String(t.to_state).toUpperCase());
277
+ return !!r && !!l && l.sort < r.sort;
157
278
  }
158
- function Rt(n) {
159
- return n != null && n.instance ? (n.available_transitions ?? []).some(
160
- (t) => {
279
+ function It(t) {
280
+ return t != null && t.instance ? (t.available_transitions ?? []).some(
281
+ (e) => {
161
282
  var i;
162
- return qt(t, n.states ?? [], (i = n.instance) == null ? void 0 : i.current_state);
283
+ return Oe(e, t.states ?? [], (i = t.instance) == null ? void 0 : i.current_state);
163
284
  }
164
285
  ) : !1;
165
286
  }
166
- function Pt(n, t, i, a) {
167
- if (!a || a.size === 0) return n;
168
- const p = new Set([...a.keys()].map((d) => String(d).toUpperCase()));
169
- return n.filter(
170
- (d) => !(p.has(String(d.to_state).toUpperCase()) && qt(d, t, i))
287
+ function Kt(t, e, i, r) {
288
+ if (!r || r.size === 0) return t;
289
+ const l = new Set([...r.keys()].map((o) => String(o).toUpperCase()));
290
+ return t.filter(
291
+ (o) => !(l.has(String(o.to_state).toUpperCase()) && Oe(o, e, i))
171
292
  );
172
293
  }
173
- function At(n, t, i) {
174
- var N, R, b, x, k, B;
175
- const a = [...(n == null ? void 0 : n.available_transitions) ?? [], ...(n == null ? void 0 : n.all_transitions) ?? []].find(
176
- (M) => M.id === t
177
- ), p = i == null ? void 0 : i.data, d = ((N = p == null ? void 0 : p.new_state) == null ? void 0 : N.id) ?? ((R = p == null ? void 0 : p.instance) == null ? void 0 : R.current_state) ?? null, f = ((b = p == null ? void 0 : p.new_state) == null ? void 0 : b.label) ?? (a ? (k = (x = n == null ? void 0 : n.states) == null ? void 0 : x.find((M) => M.id === a.to_state)) == null ? void 0 : k.label : void 0) ?? null, y = ((B = n == null ? void 0 : n.instance) == null ? void 0 : B.current_state) ?? null;
178
- return y && d && String(y) === String(d) ? "Nothing moved" : a != null && a.label && f ? `${a.label} — now ${f}` : f ? `Moved to ${f}` : a != null && a.label ? `${a.label} done` : "Transition executed";
294
+ function Qt(t, e, i) {
295
+ var _, D, g, x, S, M;
296
+ const r = [...(t == null ? void 0 : t.available_transitions) ?? [], ...(t == null ? void 0 : t.all_transitions) ?? []].find(
297
+ (U) => U.id === e
298
+ ), l = i == null ? void 0 : i.data, o = ((_ = l == null ? void 0 : l.new_state) == null ? void 0 : _.id) ?? ((D = l == null ? void 0 : l.instance) == null ? void 0 : D.current_state) ?? null, m = ((g = l == null ? void 0 : l.new_state) == null ? void 0 : g.label) ?? (r ? (S = (x = t == null ? void 0 : t.states) == null ? void 0 : x.find((U) => U.id === r.to_state)) == null ? void 0 : S.label : void 0) ?? null, h = ((M = t == null ? void 0 : t.instance) == null ? void 0 : M.current_state) ?? null;
299
+ return h && o && String(h) === String(o) ? "Nothing moved" : r != null && r.label && m ? `${r.label} — now ${m}` : m ? `Moved to ${m}` : r != null && r.label ? `${r.label} done` : "Transition executed";
179
300
  }
180
- function Dt(n, t, i) {
181
- for (const a of [
301
+ function zt(t, e, i) {
302
+ for (const r of [
182
303
  "pipeline-owners-resolved",
183
304
  "pipeline-instance-owners",
184
305
  "pipeline-all-owners"
185
306
  ])
186
- n.invalidateQueries({ queryKey: [a, t, i] });
307
+ t.invalidateQueries({ queryKey: [r, e, i] });
187
308
  }
188
- function mn(n, t, i) {
189
- var y;
190
- if (!t) return null;
191
- const a = new Map(i.map((N) => [String(N.id).toUpperCase(), N.sort])), p = [...n].sort(
192
- (N, R) => new Date(R.timestamp).getTime() - new Date(N.timestamp).getTime()
309
+ function Tn(t, e, i) {
310
+ var h;
311
+ if (!e) return null;
312
+ const r = new Map(i.map((_) => [String(_.id).toUpperCase(), _.sort])), l = [...t].sort(
313
+ (_, D) => new Date(D.timestamp).getTime() - new Date(_.timestamp).getTime()
193
314
  )[0];
194
- if (!(p != null && p.from_state) || String(p.to_state).toUpperCase() !== String(t).toUpperCase() || !((y = p.comment) != null && y.trim()) || p.origin && p.origin !== "person") return null;
195
- const d = a.get(String(p.from_state).toUpperCase()), f = a.get(String(p.to_state).toUpperCase());
196
- return d == null || f == null || f >= d ? null : p;
315
+ if (!(l != null && l.from_state) || String(l.to_state).toUpperCase() !== String(e).toUpperCase() || !((h = l.comment) != null && h.trim()) || l.origin && l.origin !== "person") return null;
316
+ const o = r.get(String(l.from_state).toUpperCase()), m = r.get(String(l.to_state).toUpperCase());
317
+ return o == null || m == null || m >= o ? null : l;
197
318
  }
198
- function pn({ entry: n }) {
199
- const t = [n.first_name, n.last_name].filter(Boolean).join(" ") || n.user_email || "Someone";
200
- return /* @__PURE__ */ r(
319
+ function qn({ entry: t }) {
320
+ const e = [t.first_name, t.last_name].filter(Boolean).join(" ") || t.user_email || "Someone";
321
+ return /* @__PURE__ */ s(
201
322
  "div",
202
323
  {
203
324
  className: "mx-5 mt-3 rounded-lg border border-amber-200 bg-amber-50 px-3.5 py-2.5 dark:border-amber-500/30 dark:bg-amber-500/10",
204
325
  "data-send-back-notice": !0,
205
326
  children: [
206
- /* @__PURE__ */ r("p", { className: "text-[12px] font-medium text-amber-900 dark:text-amber-200", children: [
327
+ /* @__PURE__ */ s("p", { className: "text-[12px] font-medium text-amber-900 dark:text-amber-200", children: [
207
328
  "Sent back by ",
208
- Ge(t, n),
329
+ rt(e, t),
209
330
  " · ",
210
- We(n.timestamp)
331
+ Ze(t.timestamp)
211
332
  ] }),
212
- /* @__PURE__ */ e("p", { className: "mt-0.5 whitespace-pre-line text-[13px] text-amber-950 dark:text-amber-100", children: n.comment })
333
+ /* @__PURE__ */ n("p", { className: "mt-0.5 whitespace-pre-line text-[13px] text-amber-950 dark:text-amber-100", children: t.comment })
213
334
  ]
214
335
  }
215
336
  );
216
337
  }
217
- function Ot({
218
- collection: n,
219
- item: t,
338
+ function Wt({
339
+ collection: t,
340
+ item: e,
220
341
  offer: i,
221
- onFixed: a,
222
- onDismiss: p,
223
- className: d,
224
- style: f
342
+ onFixed: r,
343
+ onDismiss: l,
344
+ className: o,
345
+ style: m
225
346
  }) {
226
- const y = be(), N = ke(), [R, b] = K(""), { data: x, isLoading: k } = ee({
227
- queryKey: ["bulk-actions-available-one", n, i.actionKey],
228
- queryFn: async () => ((await y.request(se("/bulk-actions/available", { collection: n }))).data ?? []).find((F) => F.key === i.actionKey) ?? null,
347
+ const h = he(), _ = Se(), [D, g] = K(""), { data: x, isLoading: S } = te({
348
+ queryKey: ["bulk-actions-available-one", t, i.actionKey],
349
+ queryFn: async () => ((await h.request(ie("/bulk-actions/available", { collection: t }))).data ?? []).find((L) => L.key === i.actionKey) ?? null,
229
350
  staleTime: 6e4
230
- }), B = ye({
351
+ }), M = ke({
231
352
  mutationFn: async () => {
232
- var S, A;
233
- const O = { collection: n, ids: [t], reason: R.trim() || null }, j = ((x == null ? void 0 : x.source) === "extension" ? await y.request(he(`/bulk-actions/${i.actionKey}/execute`, O)) : await y.request(he("/bulk-actions/run", { ...O, key: i.actionKey }))).data ?? {};
234
- if ((x == null ? void 0 : x.source) !== "extension" && !(j.succeeded && j.succeeded > 0))
353
+ var F, A;
354
+ const B = { collection: t, ids: [e], reason: D.trim() || null }, E = ((x == null ? void 0 : x.source) === "extension" ? await h.request(ye(`/bulk-actions/${i.actionKey}/execute`, B)) : await h.request(ye("/bulk-actions/run", { ...B, key: i.actionKey }))).data ?? {};
355
+ if ((x == null ? void 0 : x.source) !== "extension" && !(E.succeeded && E.succeeded > 0))
235
356
  throw new Error(
236
- ((A = (S = j.errors) == null ? void 0 : S[0]) == null ? void 0 : A.error) || `${(x == null ? void 0 : x.label) ?? "The fix"} did not change the record`
357
+ ((A = (F = E.errors) == null ? void 0 : F[0]) == null ? void 0 : A.error) || `${(x == null ? void 0 : x.label) ?? "The fix"} did not change the record`
237
358
  );
238
359
  },
239
360
  onSuccess: () => {
240
- Ne(N, n, t), Z.success(`${(x == null ? void 0 : x.label) ?? "Done"} — trying again`), a();
361
+ Te(_, t, e), ee.success(`${(x == null ? void 0 : x.label) ?? "Done"} — trying again`), r();
241
362
  },
242
- onError: (O) => zt(O, `${(x == null ? void 0 : x.label) ?? "The fix"} failed`)
363
+ onError: (B) => an(B, `${(x == null ? void 0 : x.label) ?? "The fix"} failed`)
243
364
  });
244
- if (k || !x) return null;
245
- const M = !B.isPending && (!x.require_reason || R.trim().length > 0);
246
- return /* @__PURE__ */ r(
365
+ if (S || !x) return null;
366
+ const U = !M.isPending && (!x.require_reason || D.trim().length > 0);
367
+ return /* @__PURE__ */ s(
247
368
  "div",
248
369
  {
249
- className: we(
370
+ className: _e(
250
371
  "space-y-2 rounded-lg border border-amber-200 bg-amber-50 p-3 dark:border-amber-500/30 dark:bg-amber-950",
251
- d
372
+ o
252
373
  ),
253
- style: f,
374
+ style: m,
254
375
  "data-refusal-fix": i.code,
255
376
  children: [
256
- /* @__PURE__ */ r("p", { className: "text-[12px] text-amber-950 dark:text-amber-100", children: [
377
+ /* @__PURE__ */ s("p", { className: "text-[12px] text-amber-950 dark:text-amber-100", children: [
257
378
  "You can fix this here: ",
258
379
  x.label.toLowerCase(),
259
380
  " this record, then it is tried again."
260
381
  ] }),
261
- x.require_reason && /* @__PURE__ */ e(
382
+ x.require_reason && /* @__PURE__ */ n(
262
383
  "input",
263
384
  {
264
385
  type: "text",
265
- value: R,
266
- onChange: (O) => b(O.target.value),
386
+ value: D,
387
+ onChange: (B) => g(B.target.value),
267
388
  placeholder: "Reason (required)",
268
389
  "aria-label": "Reason",
269
390
  className: "w-full rounded-md border border-slate-200 bg-white px-3 py-1.5 text-[13px] placeholder-slate-400 focus:outline-none focus:ring-2 focus:ring-nvr-cyan/30 dark:border-border dark:bg-card"
270
391
  }
271
392
  ),
272
- /* @__PURE__ */ r("div", { className: "flex items-center justify-end gap-2", children: [
273
- /* @__PURE__ */ e(
274
- G,
393
+ /* @__PURE__ */ s("div", { className: "flex items-center justify-end gap-2", children: [
394
+ /* @__PURE__ */ n(
395
+ Y,
275
396
  {
276
397
  type: "button",
277
398
  size: "sm",
278
399
  variant: "ghost",
279
400
  className: "h-7 text-[12px]",
280
- onClick: p,
401
+ onClick: l,
281
402
  children: "Not now"
282
403
  }
283
404
  ),
284
- /* @__PURE__ */ r(
285
- G,
405
+ /* @__PURE__ */ s(
406
+ Y,
286
407
  {
287
408
  type: "button",
288
409
  size: "sm",
289
410
  className: "h-7 gap-1.5 text-[12px]",
290
- disabled: !M,
291
- onClick: () => B.mutate(),
411
+ disabled: !U,
412
+ onClick: () => M.mutate(),
292
413
  children: [
293
- B.isPending && /* @__PURE__ */ e(ae, { className: "h-3 w-3 animate-spin" }),
414
+ M.isPending && /* @__PURE__ */ n(se, { className: "h-3 w-3 animate-spin" }),
294
415
  x.label,
295
416
  ", then try again"
296
417
  ]
@@ -301,205 +422,205 @@ function Ot({
301
422
  }
302
423
  );
303
424
  }
304
- function ce({
305
- label: n,
306
- color: t,
425
+ function pe({
426
+ label: t,
427
+ color: e,
307
428
  small: i
308
429
  }) {
309
- return /* @__PURE__ */ e(
430
+ return /* @__PURE__ */ n(
310
431
  "span",
311
432
  {
312
433
  className: `nvr-state-pulse inline-flex items-center gap-1.5 rounded-full font-medium transition-colors duration-300 ${i ? "px-2 py-0.5 text-[11px]" : "px-2.5 py-1 text-[12px]"}`,
313
434
  style: {
314
- backgroundColor: t ? `${t}22` : "#f1f5f9",
315
- color: t ?? "#475569",
316
- border: `1px solid ${t ? `${t}44` : "#e2e8f0"}`
435
+ backgroundColor: e ? `${e}22` : "#f1f5f9",
436
+ color: e ?? "#475569",
437
+ border: `1px solid ${e ? `${e}44` : "#e2e8f0"}`
317
438
  },
318
- children: n
439
+ children: t
319
440
  },
320
- n
441
+ t
321
442
  );
322
443
  }
323
- function Be(n) {
324
- const t = Math.floor(n / 6e4);
325
- return t < 60 ? `${Math.max(1, t)}m` : Gt(n / 36e5);
444
+ function Ke(t) {
445
+ const e = Math.floor(t / 6e4);
446
+ return e < 60 ? `${Math.max(1, e)}m` : cn(t / 36e5);
326
447
  }
327
- function fn({
328
- history: n,
329
- completedAt: t
448
+ function Rn({
449
+ history: t,
450
+ completedAt: e
330
451
  }) {
331
- const i = [...n].sort(
332
- (f, y) => new Date(f.timestamp).getTime() - new Date(y.timestamp).getTime()
452
+ const i = [...t].sort(
453
+ (m, h) => new Date(m.timestamp).getTime() - new Date(h.timestamp).getTime()
333
454
  );
334
455
  if (i.length === 0) return null;
335
- const a = t ? new Date(t).getTime() : Date.now(), p = i.map((f, y) => {
336
- const N = new Date(f.timestamp).getTime(), R = y + 1 < i.length ? new Date(i[y + 1].timestamp).getTime() : a;
456
+ const r = e ? new Date(e).getTime() : Date.now(), l = i.map((m, h) => {
457
+ const _ = new Date(m.timestamp).getTime(), D = h + 1 < i.length ? new Date(i[h + 1].timestamp).getTime() : r;
337
458
  return {
338
- key: f.id,
339
- label: f.to_state_label,
340
- color: f.to_state_color,
341
- ms: Math.max(0, R - N),
342
- current: y === i.length - 1 && !t
459
+ key: m.id,
460
+ label: m.to_state_label,
461
+ color: m.to_state_color,
462
+ ms: Math.max(0, D - _),
463
+ current: h === i.length - 1 && !e
343
464
  };
344
- }).filter((f) => f.ms > 0 || f.current);
345
- if (p.length < 2) return null;
346
- const d = p.reduce((f, y) => f + y.ms, 0);
347
- return d <= 0 ? null : /* @__PURE__ */ r("div", { "data-state-timeline": !0, children: [
348
- /* @__PURE__ */ r("div", { className: "mb-1 flex items-center justify-between", children: [
349
- /* @__PURE__ */ e("p", { className: "text-[10px] font-semibold uppercase tracking-wide text-slate-400 dark:text-slate-500", children: "Time in step" }),
350
- /* @__PURE__ */ r("p", { className: "text-[10px] tabular-nums text-slate-400 dark:text-slate-500", children: [
351
- Be(d),
465
+ }).filter((m) => m.ms > 0 || m.current);
466
+ if (l.length < 2) return null;
467
+ const o = l.reduce((m, h) => m + h.ms, 0);
468
+ return o <= 0 ? null : /* @__PURE__ */ s("div", { "data-state-timeline": !0, children: [
469
+ /* @__PURE__ */ s("div", { className: "mb-1 flex items-center justify-between", children: [
470
+ /* @__PURE__ */ n("p", { className: "text-[10px] font-semibold uppercase tracking-wide text-slate-400 dark:text-slate-500", children: "Time in step" }),
471
+ /* @__PURE__ */ s("p", { className: "text-[10px] tabular-nums text-slate-400 dark:text-slate-500", children: [
472
+ Ke(o),
352
473
  " total",
353
- t ? "" : " · so far"
474
+ e ? "" : " · so far"
354
475
  ] })
355
476
  ] }),
356
- /* @__PURE__ */ e("div", { className: "flex h-4 w-full overflow-hidden rounded", children: p.map((f) => {
357
- const y = f.ms / d * 100;
358
- return /* @__PURE__ */ r(
477
+ /* @__PURE__ */ n("div", { className: "flex h-4 w-full overflow-hidden rounded", children: l.map((m) => {
478
+ const h = m.ms / o * 100;
479
+ return /* @__PURE__ */ s(
359
480
  "div",
360
481
  {
361
- "data-tip": `${f.label} — ${Be(f.ms)}${f.current ? " (current)" : ""}`,
482
+ "data-tip": `${m.label} — ${Ke(m.ms)}${m.current ? " (current)" : ""}`,
362
483
  className: "relative flex min-w-[8px] items-center overflow-hidden border-r border-white/60 last:border-r-0 dark:border-black/30",
363
484
  style: {
364
- width: `${y}%`,
365
- backgroundColor: f.color ? `${f.color}55` : "rgba(100,116,139,.25)"
485
+ width: `${h}%`,
486
+ backgroundColor: m.color ? `${m.color}55` : "rgba(100,116,139,.25)"
366
487
  },
367
488
  children: [
368
- y >= 14 && /* @__PURE__ */ r("span", { className: "truncate px-1.5 text-[9.5px] font-medium leading-none text-slate-700 dark:text-slate-200", children: [
369
- f.label,
489
+ h >= 14 && /* @__PURE__ */ s("span", { className: "truncate px-1.5 text-[9.5px] font-medium leading-none text-slate-700 dark:text-slate-200", children: [
490
+ m.label,
370
491
  " · ",
371
- Be(f.ms)
492
+ Ke(m.ms)
372
493
  ] }),
373
- f.current && /* @__PURE__ */ e(
494
+ m.current && /* @__PURE__ */ n(
374
495
  "span",
375
496
  {
376
497
  className: "absolute inset-y-0 right-0 w-[2px]",
377
- style: { backgroundColor: f.color ?? "#64748b" }
498
+ style: { backgroundColor: m.color ?? "#64748b" }
378
499
  }
379
500
  )
380
501
  ]
381
502
  },
382
- f.key
503
+ m.key
383
504
  );
384
505
  }) })
385
506
  ] });
386
507
  }
387
- function hn({
388
- states: n,
389
- allTransitions: t,
508
+ function Pn({
509
+ states: t,
510
+ allTransitions: e,
390
511
  availableTransitions: i,
391
- currentStateId: a,
392
- history: p,
393
- onPathIds: d,
394
- skippedStates: f
512
+ currentStateId: r,
513
+ history: l,
514
+ onPathIds: o,
515
+ skippedStates: m
395
516
  }) {
396
517
  var A;
397
- const y = te(null);
398
- de(() => {
399
- const c = y.current;
400
- if (!c || c.scrollWidth <= c.clientWidth) return;
401
- const _ = c.querySelector("[data-track-current]");
402
- if (!_) return;
403
- const l = c.getBoundingClientRect(), $ = _.getBoundingClientRect();
404
- c.scrollLeft += $.left + $.width / 2 - (l.left + l.width / 2);
405
- }, [a]);
406
- const N = new Set(p.map((c) => c.to_state)), R = n.find((c) => c.is_initial);
407
- R && R.id !== a && N.add(R.id);
408
- const b = (A = p[0]) == null ? void 0 : A.from_state;
409
- b && b !== a && N.add(b);
518
+ const h = J(null);
519
+ ue(() => {
520
+ const u = h.current;
521
+ if (!u || u.scrollWidth <= u.clientWidth) return;
522
+ const N = u.querySelector("[data-track-current]");
523
+ if (!N) return;
524
+ const d = u.getBoundingClientRect(), $ = N.getBoundingClientRect();
525
+ u.scrollLeft += $.left + $.width / 2 - (d.left + d.width / 2);
526
+ }, [r]);
527
+ const _ = new Set(l.map((u) => u.to_state)), D = t.find((u) => u.is_initial);
528
+ D && D.id !== r && _.add(D.id);
529
+ const g = (A = l[0]) == null ? void 0 : A.from_state;
530
+ g && g !== r && _.add(g);
410
531
  const x = (() => {
411
- if (d)
412
- return n.filter((h) => d.has(h.id) || N.has(h.id) || h.id === a).filter((h) => {
413
- const w = h.stage_visibility ?? "always";
414
- return w === "hide" ? !1 : w === "hide_unless_active" ? N.has(h.id) || h.id === a : !0;
415
- }).sort((h, w) => h.sort - w.sort);
416
- if (t.length === 0) {
417
- const h = /* @__PURE__ */ new Set([...N]);
418
- return a && h.add(a), n.filter((w) => h.has(w.id)).sort((w, I) => w.sort - I.sort);
532
+ if (o)
533
+ return t.filter((b) => o.has(b.id) || _.has(b.id) || b.id === r).filter((b) => {
534
+ const C = b.stage_visibility ?? "always";
535
+ return C === "hide" ? !1 : C === "hide_unless_active" ? _.has(b.id) || b.id === r : !0;
536
+ }).sort((b, C) => b.sort - C.sort);
537
+ if (e.length === 0) {
538
+ const b = /* @__PURE__ */ new Set([..._]);
539
+ return r && b.add(r), t.filter((C) => b.has(C.id)).sort((C, O) => C.sort - O.sort);
419
540
  }
420
- const c = new Set(
421
- p.filter((h) => h.from_state).map((h) => `${h.from_state}:${h.to_state}`)
422
- ), _ = new Set(p.map((h) => h.from_state).filter(Boolean)), l = t.filter((h) => h.from_state !== null), $ = /* @__PURE__ */ new Map();
423
- for (const h of l) {
424
- const w = h.from_state;
425
- if (_.has(w) && !c.has(`${w}:${h.to_state}`)) continue;
426
- const I = $.get(w) ?? [];
427
- I.push(h.to_state), $.set(w, I);
541
+ const u = new Set(
542
+ l.filter((b) => b.from_state).map((b) => `${b.from_state}:${b.to_state}`)
543
+ ), N = new Set(l.map((b) => b.from_state).filter(Boolean)), d = e.filter((b) => b.from_state !== null), $ = /* @__PURE__ */ new Map();
544
+ for (const b of d) {
545
+ const C = b.from_state;
546
+ if (N.has(C) && !u.has(`${C}:${b.to_state}`)) continue;
547
+ const O = $.get(C) ?? [];
548
+ O.push(b.to_state), $.set(C, O);
428
549
  }
429
- if (a) {
430
- const h = l.filter((w) => w.from_state === a).map((w) => w.to_state);
431
- $.set(a, [
432
- .../* @__PURE__ */ new Set([...i.map((w) => w.to_state), ...h])
550
+ if (r) {
551
+ const b = d.filter((C) => C.from_state === r).map((C) => C.to_state);
552
+ $.set(r, [
553
+ .../* @__PURE__ */ new Set([...i.map((C) => C.to_state), ...b])
433
554
  ]);
434
555
  }
435
- const T = /* @__PURE__ */ new Set(), L = n.filter((h) => h.is_initial).map((h) => h.id);
436
- for (; L.length; ) {
437
- const h = L.shift();
438
- if (!T.has(h)) {
439
- T.add(h);
440
- for (const w of $.get(h) ?? []) T.has(w) || L.push(w);
556
+ const R = /* @__PURE__ */ new Set(), w = t.filter((b) => b.is_initial).map((b) => b.id);
557
+ for (; w.length; ) {
558
+ const b = w.shift();
559
+ if (!R.has(b)) {
560
+ R.add(b);
561
+ for (const C of $.get(b) ?? []) R.has(C) || w.push(C);
441
562
  }
442
563
  }
443
- const Y = /* @__PURE__ */ new Set([...T, ...N]);
444
- return a && Y.add(a), n.filter((h) => Y.has(h.id)).filter((h) => {
445
- const w = h.stage_visibility ?? "always";
446
- return w === "hide" ? !1 : w === "hide_unless_active" ? N.has(h.id) || h.id === a : !0;
447
- }).sort((h, w) => h.sort - w.sort);
564
+ const G = /* @__PURE__ */ new Set([...R, ..._]);
565
+ return r && G.add(r), t.filter((b) => G.has(b.id)).filter((b) => {
566
+ const C = b.stage_visibility ?? "always";
567
+ return C === "hide" ? !1 : C === "hide_unless_active" ? _.has(b.id) || b.id === r : !0;
568
+ }).sort((b, C) => b.sort - C.sort);
448
569
  })();
449
570
  if (x.length < 2) return null;
450
- const k = new Map(x.map((c, _) => [c.id, _])), B = new Map(n.map((c) => [c.id, c.label]));
451
- function M(c, _) {
452
- const l = k.get(c);
453
- return l == null ? [] : [...p].filter(($) => {
571
+ const S = new Map(x.map((u, N) => [u.id, N])), M = new Map(t.map((u) => [u.id, u.label]));
572
+ function U(u, N) {
573
+ const d = S.get(u);
574
+ return d == null ? [] : [...l].filter(($) => {
454
575
  if (!$.from_state) return !1;
455
- const T = k.get($.from_state), L = k.get($.to_state);
456
- return T == null || L == null ? !1 : T === l && L > l || L === l && T > l;
457
- }).sort(($, T) => new Date($.timestamp).getTime() - new Date(T.timestamp).getTime());
576
+ const R = S.get($.from_state), w = S.get($.to_state);
577
+ return R == null || w == null ? !1 : R === d && w > d || w === d && R > d;
578
+ }).sort(($, R) => new Date($.timestamp).getTime() - new Date(R.timestamp).getTime());
458
579
  }
459
- function O(c) {
460
- var _, l, $, T;
461
- return $e(c) ? /* @__PURE__ */ e(bt, { className: "inline h-2.5 w-2.5", "aria-label": Ke(c) }) : ((((_ = c.first_name) == null ? void 0 : _[0]) ?? "") + (((l = c.last_name) == null ? void 0 : l[0]) ?? "")).toUpperCase() || ((T = ($ = c.user_email) == null ? void 0 : $[0]) == null ? void 0 : T.toUpperCase()) || "?";
580
+ function B(u) {
581
+ var N, d, $, R;
582
+ return De(u) ? /* @__PURE__ */ n(kt, { className: "inline h-2.5 w-2.5", "aria-label": Xe(u) }) : ((((N = u.first_name) == null ? void 0 : N[0]) ?? "") + (((d = u.last_name) == null ? void 0 : d[0]) ?? "")).toUpperCase() || ((R = ($ = u.user_email) == null ? void 0 : $[0]) == null ? void 0 : R.toUpperCase()) || "?";
462
583
  }
463
- function F(c) {
464
- return Ge([c.first_name, c.last_name].filter(Boolean).join(" ") || c.user_email, c);
584
+ function L(u) {
585
+ return rt([u.first_name, u.last_name].filter(Boolean).join(" ") || u.user_email, u);
465
586
  }
466
- const j = /* @__PURE__ */ new Map();
467
- for (const c of [...p].sort(
468
- (_, l) => new Date(_.timestamp).getTime() - new Date(l.timestamp).getTime()
587
+ const E = /* @__PURE__ */ new Map();
588
+ for (const u of [...l].sort(
589
+ (N, d) => new Date(N.timestamp).getTime() - new Date(d.timestamp).getTime()
469
590
  )) {
470
- if (!c.from_state) continue;
471
- const _ = k.get(c.from_state), l = k.get(c.to_state);
472
- if (!(_ == null || l == null || l <= _ + 1))
473
- for (let $ = _ + 1; $ < l; $++) {
474
- const T = x[$].id;
475
- !N.has(T) && !j.has(T) && j.set(T, c);
591
+ if (!u.from_state) continue;
592
+ const N = S.get(u.from_state), d = S.get(u.to_state);
593
+ if (!(N == null || d == null || d <= N + 1))
594
+ for (let $ = N + 1; $ < d; $++) {
595
+ const R = x[$].id;
596
+ !_.has(R) && !E.has(R) && E.set(R, u);
476
597
  }
477
598
  }
478
- function S(c) {
479
- const _ = B.get(c.from_state ?? "") ?? "the previous step", l = B.get(c.to_state) ?? "the next step", $ = $e(c) ? "it moved automatically" : `${F(c)} moved it`;
480
- return `Passed over on ${new Date(c.timestamp).toLocaleString()} — ${$} straight from ${_} to ${l}`;
599
+ function F(u) {
600
+ const N = M.get(u.from_state ?? "") ?? "the previous step", d = M.get(u.to_state) ?? "the next step", $ = De(u) ? "it moved automatically" : `${L(u)} moved it`;
601
+ return `Passed over on ${new Date(u.timestamp).toLocaleString()} — ${$} straight from ${N} to ${d}`;
481
602
  }
482
- return /* @__PURE__ */ e(vt, { delayDuration: 200, children: /* @__PURE__ */ e("div", { ref: y, className: "overflow-x-auto pt-1.5 pb-1", "data-state-track": !0, children: /* @__PURE__ */ e("div", { className: "flex w-full items-start", children: x.map((c, _) => {
483
- const l = c.id === a, $ = N.has(c.id), T = $ && !l, L = !$ && !l ? j.get(c.id) : void 0, Y = !$ && !l ? f == null ? void 0 : f.get(c.id) : void 0, h = L || Y ? [...L ? [S(L)] : [], ...Y ?? []] : void 0, w = h !== void 0, I = c.color ?? "#94a3b8", W = _ === x.length - 1, E = W ? null : x[_ + 1], re = E ? M(c.id, E.id) : [];
484
- return /* @__PURE__ */ r("div", { className: "flex flex-1 items-start", children: [
485
- /* @__PURE__ */ r("div", { className: "flex min-w-[76px] flex-1 flex-col items-center gap-1.5 px-1", children: [
486
- /* @__PURE__ */ e(
603
+ return /* @__PURE__ */ n(qt, { delayDuration: 200, children: /* @__PURE__ */ n("div", { ref: h, className: "overflow-x-auto pt-1.5 pb-1", "data-state-track": !0, children: /* @__PURE__ */ n("div", { className: "flex w-full items-start", children: x.map((u, N) => {
604
+ const d = u.id === r, $ = _.has(u.id), R = $ && !d, w = !$ && !d ? E.get(u.id) : void 0, G = !$ && !d ? m == null ? void 0 : m.get(u.id) : void 0, b = w || G ? [...w ? [F(w)] : [], ...G ?? []] : void 0, C = b !== void 0, O = u.color ?? "#94a3b8", Q = N === x.length - 1, V = Q ? null : x[N + 1], X = V ? U(u.id, V.id) : [];
605
+ return /* @__PURE__ */ s("div", { className: "flex flex-1 items-start", children: [
606
+ /* @__PURE__ */ s("div", { className: "flex min-w-[76px] flex-1 flex-col items-center gap-1.5 px-1", children: [
607
+ /* @__PURE__ */ n(
487
608
  "div",
488
609
  {
489
- "data-track-current": l || void 0,
490
- className: `flex h-7 w-7 shrink-0 items-center justify-center rounded-full ${l || T ? "nvr-fill-sweep" : ""}`,
491
- "data-tip": c.description || void 0,
610
+ "data-track-current": d || void 0,
611
+ className: `flex h-7 w-7 shrink-0 items-center justify-center rounded-full ${d || R ? "nvr-fill-sweep" : ""}`,
612
+ "data-tip": u.description || void 0,
492
613
  style: {
493
- backgroundColor: l || T ? I : w ? "transparent" : "#f1f5f9",
494
- border: l || T ? "none" : w ? "1.5px dashed #cbd5e1" : "1.5px solid #e2e8f0",
495
- boxShadow: l ? `0 0 0 3px white, 0 0 0 5px ${I}` : void 0
614
+ backgroundColor: d || R ? O : C ? "transparent" : "#f1f5f9",
615
+ border: d || R ? "none" : C ? "1.5px dashed #cbd5e1" : "1.5px solid #e2e8f0",
616
+ boxShadow: d ? `0 0 0 3px white, 0 0 0 5px ${O}` : void 0
496
617
  },
497
- children: T ? /* @__PURE__ */ e(Re, { className: "h-3.5 w-3.5 text-white", strokeWidth: 2.5 }) : l ? /* @__PURE__ */ e("div", { className: "h-2.5 w-2.5 rounded-full bg-white/80" }) : w ? /* @__PURE__ */ e(Mt, { className: "h-3 w-3 text-slate-400", strokeWidth: 2.5 }) : /* @__PURE__ */ e("div", { className: "h-2 w-2 rounded-full bg-slate-300" })
618
+ children: R ? /* @__PURE__ */ n(Me, { className: "h-3.5 w-3.5 text-white", strokeWidth: 2.5 }) : d ? /* @__PURE__ */ n("div", { className: "h-2.5 w-2.5 rounded-full bg-white/80" }) : C ? /* @__PURE__ */ n(Jt, { className: "h-3 w-3 text-slate-400", strokeWidth: 2.5 }) : /* @__PURE__ */ n("div", { className: "h-2 w-2 rounded-full bg-slate-300" })
498
619
  },
499
- l ? "cur" : T ? "done" : w ? "skip" : "todo"
620
+ d ? "cur" : R ? "done" : C ? "skip" : "todo"
500
621
  ),
501
- w ? /* @__PURE__ */ r(je, { children: [
502
- /* @__PURE__ */ e(Ie, { asChild: !0, children: /* @__PURE__ */ e(
622
+ C ? /* @__PURE__ */ s(He, { children: [
623
+ /* @__PURE__ */ n(Ge, { asChild: !0, children: /* @__PURE__ */ n(
503
624
  "span",
504
625
  {
505
626
  className: "w-full cursor-help break-words text-center leading-snug",
@@ -511,39 +632,39 @@ function hn({
511
632
  textDecoration: "line-through",
512
633
  textDecorationColor: "#cbd5e1"
513
634
  },
514
- children: c.label
635
+ children: u.label
515
636
  }
516
637
  ) }),
517
- /* @__PURE__ */ r(Ee, { className: "max-w-[260px]", children: [
518
- /* @__PURE__ */ e("p", { className: "text-[11px] font-medium", children: "Skipped for this record" }),
519
- h.length > 0 ? /* @__PURE__ */ e("ul", { className: "mt-1 space-y-0.5 text-[11px] opacity-90", children: h.map((o) => /* @__PURE__ */ e("li", { children: o }, o)) }) : /* @__PURE__ */ e("p", { className: "mt-1 text-[11px] opacity-90", children: "Its skip conditions are met." })
638
+ /* @__PURE__ */ s(Ve, { className: "max-w-[260px]", children: [
639
+ /* @__PURE__ */ n("p", { className: "text-[11px] font-medium", children: "Skipped for this record" }),
640
+ b.length > 0 ? /* @__PURE__ */ n("ul", { className: "mt-1 space-y-0.5 text-[11px] opacity-90", children: b.map((P) => /* @__PURE__ */ n("li", { children: P }, P)) }) : /* @__PURE__ */ n("p", { className: "mt-1 text-[11px] opacity-90", children: "Its skip conditions are met." })
520
641
  ] })
521
- ] }) : /* @__PURE__ */ e(
642
+ ] }) : /* @__PURE__ */ n(
522
643
  "span",
523
644
  {
524
645
  className: "w-full break-words text-center leading-snug",
525
646
  style: {
526
647
  fontSize: "11px",
527
- color: l ? I : T ? "#475569" : "#94a3b8",
528
- fontWeight: l ? 600 : T ? 500 : 400,
648
+ color: d ? O : R ? "#475569" : "#94a3b8",
649
+ fontWeight: d ? 600 : R ? 500 : 400,
529
650
  wordBreak: "break-word"
530
651
  },
531
- children: c.label
652
+ children: u.label
532
653
  }
533
654
  )
534
655
  ] }),
535
- !W && /* @__PURE__ */ r("div", { className: "mt-[13px] flex w-10 shrink-0 flex-col items-center gap-1.5", children: [
656
+ !Q && /* @__PURE__ */ s("div", { className: "mt-[13px] flex w-10 shrink-0 flex-col items-center gap-1.5", children: [
536
657
  (() => {
537
- const o = T ? `${I}55` : "#e8ecf0";
538
- return /* @__PURE__ */ r("div", { className: "flex w-full shrink-0 items-center", children: [
539
- /* @__PURE__ */ e(
658
+ const P = R ? `${O}55` : "#e8ecf0";
659
+ return /* @__PURE__ */ s("div", { className: "flex w-full shrink-0 items-center", children: [
660
+ /* @__PURE__ */ n(
540
661
  "div",
541
662
  {
542
663
  className: "h-0.5 flex-1 rounded-l-sm",
543
- style: { backgroundColor: o }
664
+ style: { backgroundColor: P }
544
665
  }
545
666
  ),
546
- /* @__PURE__ */ e(
667
+ /* @__PURE__ */ n(
547
668
  "div",
548
669
  {
549
670
  style: {
@@ -551,553 +672,553 @@ function hn({
551
672
  height: 0,
552
673
  borderTop: "3px solid transparent",
553
674
  borderBottom: "3px solid transparent",
554
- borderLeft: `5px solid ${o}`
675
+ borderLeft: `5px solid ${P}`
555
676
  }
556
677
  }
557
678
  )
558
679
  ] });
559
680
  })(),
560
- re.map((o) => {
561
- const ne = o.from_state !== c.id, J = Math.abs(
562
- (k.get(o.to_state) ?? 0) - (k.get(o.from_state ?? "") ?? 0)
563
- ) > 1 ? B.get(o.to_state) ?? "" : null;
564
- return /* @__PURE__ */ r(je, { children: [
565
- /* @__PURE__ */ e(Ie, { asChild: !0, children: /* @__PURE__ */ r("div", { className: "flex w-full cursor-default flex-col items-center gap-0.5", children: [
566
- /* @__PURE__ */ r(
681
+ X.map((P) => {
682
+ const Z = P.from_state !== u.id, z = Math.abs(
683
+ (S.get(P.to_state) ?? 0) - (S.get(P.from_state ?? "") ?? 0)
684
+ ) > 1 ? M.get(P.to_state) ?? "" : null;
685
+ return /* @__PURE__ */ s(He, { children: [
686
+ /* @__PURE__ */ n(Ge, { asChild: !0, children: /* @__PURE__ */ s("div", { className: "flex w-full cursor-default flex-col items-center gap-0.5", children: [
687
+ /* @__PURE__ */ s(
567
688
  "span",
568
689
  {
569
690
  className: "text-center font-mono text-[9px] font-semibold leading-none",
570
- style: { color: ne ? "#d97706" : "#475569" },
691
+ style: { color: Z ? "#d97706" : "#475569" },
571
692
  children: [
572
- ne && "↩ ",
573
- O(o)
693
+ Z && "↩ ",
694
+ B(P)
574
695
  ]
575
696
  }
576
697
  ),
577
- /* @__PURE__ */ e("span", { className: "text-[8.5px] leading-none text-slate-400", children: We(o.timestamp) })
698
+ /* @__PURE__ */ n("span", { className: "text-[8.5px] leading-none text-slate-400", children: Ze(P.timestamp) })
578
699
  ] }) }),
579
- /* @__PURE__ */ r(Ee, { side: "top", className: "space-y-0.5 text-[12px]", children: [
580
- $e(o) ? /* @__PURE__ */ r(ue, { children: [
581
- /* @__PURE__ */ r("p", { className: "font-medium", children: [
582
- ne ? "↩ Sent back · " : "",
583
- Ke(o)
700
+ /* @__PURE__ */ s(Ve, { side: "top", className: "space-y-0.5 text-[12px]", children: [
701
+ De(P) ? /* @__PURE__ */ s(fe, { children: [
702
+ /* @__PURE__ */ s("p", { className: "font-medium", children: [
703
+ Z ? "↩ Sent back · " : "",
704
+ Xe(P)
584
705
  ] }),
585
- Qe(o) && /* @__PURE__ */ e("p", { className: "max-w-[280px] text-muted-foreground", children: Qe(o) })
586
- ] }) : /* @__PURE__ */ r("p", { className: "font-medium", children: [
587
- ne ? "↩ Sent back by" : "Approved by",
706
+ Ye(P) && /* @__PURE__ */ n("p", { className: "max-w-[280px] text-muted-foreground", children: Ye(P) })
707
+ ] }) : /* @__PURE__ */ s("p", { className: "font-medium", children: [
708
+ Z ? "↩ Sent back by" : "Approved by",
588
709
  " ",
589
- F(o)
710
+ L(P)
590
711
  ] }),
591
- J && /* @__PURE__ */ r("p", { className: "text-muted-foreground", children: [
712
+ z && /* @__PURE__ */ s("p", { className: "text-muted-foreground", children: [
592
713
  "→ straight to ",
593
- J
714
+ z
594
715
  ] }),
595
- /* @__PURE__ */ e("p", { className: "text-muted-foreground", children: new Date(o.timestamp).toLocaleString() })
716
+ /* @__PURE__ */ n("p", { className: "text-muted-foreground", children: new Date(P.timestamp).toLocaleString() })
596
717
  ] })
597
- ] }, o.id);
718
+ ] }, P.id);
598
719
  })
599
720
  ] })
600
- ] }, c.id);
721
+ ] }, u.id);
601
722
  }) }) }) });
602
723
  }
603
- function bn({ history: n }) {
604
- return n.length === 0 ? /* @__PURE__ */ e("p", { className: "text-[12px] text-slate-400 italic", children: "No transitions yet." }) : /* @__PURE__ */ e("div", { className: "space-y-3", children: n.map((t) => {
605
- const i = $e(t), a = i ? Ke(t) : Ge([t.first_name, t.last_name].filter(Boolean).join(" ") || t.user_email, t), p = sn(t), d = t.comment && !i && !p ? t.comment : null, f = p ?? (i ? Qe(t) : null);
606
- return /* @__PURE__ */ r("div", { className: "flex items-start gap-2.5 text-[12px]", children: [
607
- /* @__PURE__ */ e("div", { className: "mt-1.5 h-1.5 w-1.5 shrink-0 rounded-full bg-slate-200" }),
608
- /* @__PURE__ */ r("div", { className: "flex-1 min-w-0", children: [
609
- /* @__PURE__ */ r("div", { className: "flex items-center gap-1.5 flex-wrap", children: [
610
- t.from_state_label ? /* @__PURE__ */ e(ce, { label: t.from_state_label, color: t.from_state_color, small: !0 }) : /* @__PURE__ */ e("span", { className: "text-[11px] text-slate-400 italic", children: "started" }),
611
- /* @__PURE__ */ e(ze, { className: "h-3 w-3 shrink-0 text-slate-300" }),
612
- /* @__PURE__ */ e(ce, { label: t.to_state_label, color: t.to_state_color, small: !0 })
724
+ function Dn({ history: t }) {
725
+ return t.length === 0 ? /* @__PURE__ */ n("p", { className: "text-[12px] text-slate-400 italic", children: "No transitions yet." }) : /* @__PURE__ */ n("div", { className: "space-y-3", children: t.map((e) => {
726
+ const i = De(e), r = i ? Xe(e) : rt([e.first_name, e.last_name].filter(Boolean).join(" ") || e.user_email, e), l = yn(e), o = e.comment && !i && !l ? e.comment : null, m = l ?? (i ? Ye(e) : null);
727
+ return /* @__PURE__ */ s("div", { className: "flex items-start gap-2.5 text-[12px]", children: [
728
+ /* @__PURE__ */ n("div", { className: "mt-1.5 h-1.5 w-1.5 shrink-0 rounded-full bg-slate-200" }),
729
+ /* @__PURE__ */ s("div", { className: "flex-1 min-w-0", children: [
730
+ /* @__PURE__ */ s("div", { className: "flex items-center gap-1.5 flex-wrap", children: [
731
+ e.from_state_label ? /* @__PURE__ */ n(pe, { label: e.from_state_label, color: e.from_state_color, small: !0 }) : /* @__PURE__ */ n("span", { className: "text-[11px] text-slate-400 italic", children: "started" }),
732
+ /* @__PURE__ */ n(Je, { className: "h-3 w-3 shrink-0 text-slate-300" }),
733
+ /* @__PURE__ */ n(pe, { label: e.to_state_label, color: e.to_state_color, small: !0 })
613
734
  ] }),
614
- d && /* @__PURE__ */ r("p", { className: "mt-1 text-slate-500 italic", children: [
735
+ o && /* @__PURE__ */ s("p", { className: "mt-1 text-slate-500 italic", children: [
615
736
  '"',
616
- d,
737
+ o,
617
738
  '"'
618
739
  ] }),
619
- /* @__PURE__ */ r(
740
+ /* @__PURE__ */ s(
620
741
  "p",
621
742
  {
622
743
  className: "mt-0.5 text-slate-400",
623
- "data-history-on-behalf": t.on_behalf_of_name ? t.on_behalf_of ?? "" : void 0,
744
+ "data-history-on-behalf": e.on_behalf_of_name ? e.on_behalf_of ?? "" : void 0,
624
745
  children: [
625
- i && /* @__PURE__ */ e(bt, { className: "mr-1 inline h-3 w-3", "aria-hidden": !0 }),
626
- a,
627
- f ? ` · ${f}` : "",
746
+ i && /* @__PURE__ */ n(kt, { className: "mr-1 inline h-3 w-3", "aria-hidden": !0 }),
747
+ r,
748
+ m ? ` · ${m}` : "",
628
749
  " · ",
629
- We(t.timestamp)
750
+ Ze(e.timestamp)
630
751
  ]
631
752
  }
632
753
  )
633
754
  ] })
634
- ] }, t.id);
755
+ ] }, e.id);
635
756
  }) });
636
757
  }
637
- function xn({ value: n, onChange: t }) {
638
- const i = be(), [a, p] = K(!1), [d, f] = K(""), [y, N] = K(""), R = te(null), b = te(null);
639
- de(() => {
640
- a ? setTimeout(() => {
641
- var S;
642
- return (S = R.current) == null ? void 0 : S.focus();
643
- }, 50) : f("");
644
- }, [a]), de(() => (b.current && clearTimeout(b.current), b.current = setTimeout(() => N(d), 250), () => {
645
- b.current && clearTimeout(b.current);
646
- }), [d]);
647
- const { data: x, isLoading: k } = ee({
648
- queryKey: ["users", "async-search", y],
758
+ function Fn({ value: t, onChange: e }) {
759
+ const i = he(), [r, l] = K(!1), [o, m] = K(""), [h, _] = K(""), D = J(null), g = J(null);
760
+ ue(() => {
761
+ r ? setTimeout(() => {
762
+ var F;
763
+ return (F = D.current) == null ? void 0 : F.focus();
764
+ }, 50) : m("");
765
+ }, [r]), ue(() => (g.current && clearTimeout(g.current), g.current = setTimeout(() => _(o), 250), () => {
766
+ g.current && clearTimeout(g.current);
767
+ }), [o]);
768
+ const { data: x, isLoading: S } = te({
769
+ queryKey: ["users", "async-search", h],
649
770
  queryFn: () => i.request(
650
- se("/users", {
771
+ ie("/users", {
651
772
  limit: 50,
652
773
  sort: "first_name",
653
- ...y ? { search: y } : {}
774
+ ...h ? { search: h } : {}
654
775
  })
655
- ).then((S) => S.data),
656
- enabled: a,
776
+ ).then((F) => F.data),
777
+ enabled: r,
657
778
  staleTime: 3e4
658
- }), { data: B } = ee({
659
- ...Xt(i, n),
660
- enabled: !!n,
779
+ }), { data: M } = te({
780
+ ...dn(i, t),
781
+ enabled: !!t,
661
782
  staleTime: 5 * 6e4
662
- }), M = x ?? [], O = B ?? M.find((S) => S.id === n) ?? null, F = O ? [O.first_name, O.last_name].filter(Boolean).join(" ").trim() || O.email : n ? "Selected person" : null, j = (S) => [S.first_name, S.last_name].filter(Boolean).join(" ").trim();
663
- return /* @__PURE__ */ r(He, { open: a, onOpenChange: p, children: [
664
- /* @__PURE__ */ r("div", { className: "relative flex h-8 w-full", children: [
665
- /* @__PURE__ */ e(Ve, { asChild: !0, children: /* @__PURE__ */ r(
783
+ }), U = x ?? [], B = M ?? U.find((F) => F.id === t) ?? null, L = B ? [B.first_name, B.last_name].filter(Boolean).join(" ").trim() || B.email : t ? "Selected person" : null, E = (F) => [F.first_name, F.last_name].filter(Boolean).join(" ").trim();
784
+ return /* @__PURE__ */ s(et, { open: r, onOpenChange: l, children: [
785
+ /* @__PURE__ */ s("div", { className: "relative flex h-8 w-full", children: [
786
+ /* @__PURE__ */ n(tt, { asChild: !0, children: /* @__PURE__ */ s(
666
787
  "button",
667
788
  {
668
789
  type: "button",
669
790
  className: "flex h-full w-full items-center justify-between gap-1.5 rounded-md border border-slate-200 bg-white px-2.5 text-left text-[13px] text-slate-700 hover:border-slate-300",
670
791
  children: [
671
- /* @__PURE__ */ e("span", { className: `flex-1 truncate ${F ? "" : "text-slate-400"}`, children: F ?? "Select a user…" }),
672
- /* @__PURE__ */ e(fe, { className: "h-3.5 w-3.5 shrink-0 text-slate-400" })
792
+ /* @__PURE__ */ n("span", { className: `flex-1 truncate ${L ? "" : "text-slate-400"}`, children: L ?? "Select a user…" }),
793
+ /* @__PURE__ */ n(xe, { className: "h-3.5 w-3.5 shrink-0 text-slate-400" })
673
794
  ]
674
795
  }
675
796
  ) }),
676
- n && /* @__PURE__ */ e(
797
+ t && /* @__PURE__ */ n(
677
798
  "button",
678
799
  {
679
800
  type: "button",
680
- onClick: (S) => {
681
- S.stopPropagation(), t("");
801
+ onClick: (F) => {
802
+ F.stopPropagation(), e("");
682
803
  },
683
804
  className: "absolute right-6 top-1/2 -translate-y-1/2 flex h-5 w-5 items-center justify-center rounded text-slate-400 hover:bg-slate-100 hover:text-slate-600 dark:hover:bg-muted dark:hover:text-slate-300",
684
- children: /* @__PURE__ */ e(ht, { className: "h-3 w-3" })
805
+ children: /* @__PURE__ */ n(Nt, { className: "h-3 w-3" })
685
806
  }
686
807
  )
687
808
  ] }),
688
- /* @__PURE__ */ r(Xe, { align: "start", className: "w-72 p-0", sideOffset: 4, children: [
689
- /* @__PURE__ */ e("div", { className: "border-b border-slate-100 px-2 py-1.5", children: /* @__PURE__ */ r("div", { className: "relative", children: [
690
- /* @__PURE__ */ e(jt, { className: "absolute left-2 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-slate-400" }),
691
- /* @__PURE__ */ e(
809
+ /* @__PURE__ */ s(nt, { align: "start", className: "w-72 p-0", sideOffset: 4, children: [
810
+ /* @__PURE__ */ n("div", { className: "border-b border-slate-100 px-2 py-1.5", children: /* @__PURE__ */ s("div", { className: "relative", children: [
811
+ /* @__PURE__ */ n(en, { className: "absolute left-2 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-slate-400" }),
812
+ /* @__PURE__ */ n(
692
813
  "input",
693
814
  {
694
- ref: R,
695
- value: d,
696
- onChange: (S) => f(S.target.value),
815
+ ref: D,
816
+ value: o,
817
+ onChange: (F) => m(F.target.value),
697
818
  placeholder: "Search users…",
698
819
  className: "h-7 w-full rounded-md bg-slate-50 pl-7 pr-2 text-[12px] placeholder-slate-400 focus:outline-none focus:ring-1 focus:ring-nvr-cyan/40"
699
820
  }
700
821
  )
701
822
  ] }) }),
702
- /* @__PURE__ */ e("div", { className: "max-h-56 overflow-y-auto py-1", children: k ? /* @__PURE__ */ r("div", { className: "flex items-center gap-2 px-3 py-2 text-[12px] text-slate-400", children: [
703
- /* @__PURE__ */ e(ae, { className: "h-3.5 w-3.5 animate-spin" }),
823
+ /* @__PURE__ */ n("div", { className: "max-h-56 overflow-y-auto py-1", children: S ? /* @__PURE__ */ s("div", { className: "flex items-center gap-2 px-3 py-2 text-[12px] text-slate-400", children: [
824
+ /* @__PURE__ */ n(se, { className: "h-3.5 w-3.5 animate-spin" }),
704
825
  "Loading…"
705
- ] }) : M.length === 0 ? /* @__PURE__ */ e("div", { className: "px-3 py-2 text-[12px] text-slate-400", children: "No results" }) : M.map((S) => {
706
- const A = j(S), c = A ? `${A} (${S.email})` : S.email, _ = S.id === n;
707
- return /* @__PURE__ */ r(
826
+ ] }) : U.length === 0 ? /* @__PURE__ */ n("div", { className: "px-3 py-2 text-[12px] text-slate-400", children: "No results" }) : U.map((F) => {
827
+ const A = E(F), u = A ? `${A} (${F.email})` : F.email, N = F.id === t;
828
+ return /* @__PURE__ */ s(
708
829
  "button",
709
830
  {
710
831
  type: "button",
711
832
  onClick: () => {
712
- t(S.id), p(!1);
833
+ e(F.id), l(!1);
713
834
  },
714
- className: `flex w-full items-center gap-2 px-3 py-1.5 text-left text-[12px] hover:bg-slate-50 ${_ ? "font-medium text-slate-800" : "text-slate-600"}`,
835
+ className: `flex w-full items-center gap-2 px-3 py-1.5 text-left text-[12px] hover:bg-slate-50 ${N ? "font-medium text-slate-800" : "text-slate-600"}`,
715
836
  children: [
716
- /* @__PURE__ */ e(
717
- Re,
837
+ /* @__PURE__ */ n(
838
+ Me,
718
839
  {
719
- className: `h-3.5 w-3.5 shrink-0 ${_ ? "text-nvr-cyan" : "opacity-0"}`
840
+ className: `h-3.5 w-3.5 shrink-0 ${N ? "text-nvr-cyan" : "opacity-0"}`
720
841
  }
721
842
  ),
722
- c
843
+ u
723
844
  ]
724
845
  },
725
- S.id
846
+ F.id
726
847
  );
727
848
  }) })
728
849
  ] })
729
850
  ] });
730
851
  }
731
- function mt({
732
- userId: n,
733
- name: t,
852
+ function yt({
853
+ userId: t,
854
+ name: e,
734
855
  email: i,
735
- initials: a
856
+ initials: r
736
857
  }) {
737
- return /* @__PURE__ */ e(wt, { userId: n, children: /* @__PURE__ */ r(
858
+ return /* @__PURE__ */ n(Tt, { userId: t, children: /* @__PURE__ */ s(
738
859
  "button",
739
860
  {
740
861
  type: "button",
741
- "aria-label": `${t} — profile`,
862
+ "aria-label": `${e} — profile`,
742
863
  className: "group/owner flex min-w-0 flex-1 items-center gap-2.5 rounded-md text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-nvr-cyan",
743
864
  children: [
744
- /* @__PURE__ */ e(
745
- en,
865
+ /* @__PURE__ */ n(
866
+ fn,
746
867
  {
747
- userId: n,
748
- alt: t,
868
+ userId: t,
869
+ alt: e,
749
870
  className: "h-6 w-6",
750
- fallback: /* @__PURE__ */ e("span", { className: "flex h-6 w-6 shrink-0 select-none items-center justify-center rounded-full bg-nvr-cyan/10 text-[10px] font-semibold text-nvr-navy/80 dark:bg-nvr-cyan/15 dark:text-nvr-cyan", children: a })
871
+ fallback: /* @__PURE__ */ n("span", { className: "flex h-6 w-6 shrink-0 select-none items-center justify-center rounded-full bg-nvr-cyan/10 text-[10px] font-semibold text-nvr-navy/80 dark:bg-nvr-cyan/15 dark:text-nvr-cyan", children: r })
751
872
  }
752
873
  ),
753
- /* @__PURE__ */ r("span", { className: "min-w-0 flex-1", children: [
754
- /* @__PURE__ */ e("span", { className: "block truncate text-[12px] font-medium text-slate-700 underline-offset-2 group-hover/owner:underline dark:text-slate-200", children: t }),
755
- /* @__PURE__ */ e("span", { className: "block truncate text-[11px] text-slate-400 dark:text-slate-500", children: i })
874
+ /* @__PURE__ */ s("span", { className: "min-w-0 flex-1", children: [
875
+ /* @__PURE__ */ n("span", { className: "block truncate text-[12px] font-medium text-slate-700 underline-offset-2 group-hover/owner:underline dark:text-slate-200", children: e }),
876
+ /* @__PURE__ */ n("span", { className: "block truncate text-[11px] text-slate-400 dark:text-slate-500", children: i })
756
877
  ] })
757
878
  ]
758
879
  }
759
880
  ) });
760
881
  }
761
- function gn({
762
- collection: n,
763
- item: t,
882
+ function An({
883
+ collection: t,
884
+ item: e,
764
885
  states: i,
765
- currentStateId: a,
766
- returned: p = !1
886
+ currentStateId: r,
887
+ returned: l = !1
767
888
  }) {
768
- var v, C, P;
769
- const d = be(), f = ke(), { isAdmin: y } = Kt(), [N, R] = K(!1), [b, x] = K(""), [k, B] = K(""), [M, O] = K(!1), F = ["pipeline-instance-owners", n, t], j = ["pipeline-owners-can-add", n, t], S = () => d.request(
770
- se(`/pipelines/instance/${n}/${t}/owners`)
771
- ).then((s) => {
772
- var D;
773
- return f.setQueryData(j, ((D = s.meta) == null ? void 0 : D.can_add) ?? null), s;
774
- }), { data: A, isLoading: c } = ee({
775
- queryKey: F,
776
- queryFn: () => S().then((s) => s.data)
777
- }), { data: _ } = ee({
778
- queryKey: j,
779
- queryFn: () => S().then((s) => {
780
- var D;
781
- return ((D = s.meta) == null ? void 0 : D.can_add) ?? null;
889
+ var ce, le, ne;
890
+ const o = he(), m = Se(), { isAdmin: h } = nn(), [_, D] = K(!1), [g, x] = K(""), [S, M] = K(""), [U, B] = K(!1), L = ["pipeline-instance-owners", t, e], E = ["pipeline-owners-can-add", t, e], F = () => o.request(
891
+ ie(`/pipelines/instance/${t}/${e}/owners`)
892
+ ).then((a) => {
893
+ var f;
894
+ return m.setQueryData(E, ((f = a.meta) == null ? void 0 : f.can_add) ?? null), a;
895
+ }), { data: A, isLoading: u } = te({
896
+ queryKey: L,
897
+ queryFn: () => F().then((a) => a.data)
898
+ }), { data: N } = te({
899
+ queryKey: E,
900
+ queryFn: () => F().then((a) => {
901
+ var f;
902
+ return ((f = a.meta) == null ? void 0 : f.can_add) ?? null;
782
903
  }),
783
- enabled: !c,
904
+ enabled: !u,
784
905
  staleTime: 3e4
785
- }), l = typeof _ == "boolean" ? _ : y, { data: $, isLoading: T } = ee({
786
- queryKey: ["pipeline-all-owners", n, t],
787
- queryFn: () => d.request(
788
- se(`/pipelines/instance/${n}/${t}/owners/all`)
789
- ).then((s) => s.data ?? null),
790
- enabled: !!a,
906
+ }), d = typeof N == "boolean" ? N : h, { data: $, isLoading: R } = te({
907
+ queryKey: ["pipeline-all-owners", t, e],
908
+ queryFn: () => o.request(
909
+ ie(`/pipelines/instance/${t}/${e}/owners/all`)
910
+ ).then((a) => a.data ?? null),
911
+ enabled: !!r,
791
912
  staleTime: 3e4
792
- }), L = new Set((A ?? []).map((s) => s.user)), Y = a ? (((v = $ == null ? void 0 : $[a]) == null ? void 0 : v.owners) ?? []).filter((s) => !L.has(s.id)) : [], h = Y.length + ((A == null ? void 0 : A.length) ?? 0), w = !!((C = i.find((s) => s.id === a)) != null && C.is_initial), I = !c && !T, { data: W } = ee({
793
- queryKey: ["pipeline-record-creator", n, t],
794
- queryFn: () => d.request(
795
- se(`/pipelines/instance/${n}/${t}/creator`)
796
- ).then((s) => s.data ?? null),
797
- enabled: w && I && h === 0,
913
+ }), w = new Set((A ?? []).map((a) => a.user)), G = r ? (((ce = $ == null ? void 0 : $[r]) == null ? void 0 : ce.owners) ?? []).filter((a) => !w.has(a.id)) : [], b = G.length + ((A == null ? void 0 : A.length) ?? 0), C = !!((le = i.find((a) => a.id === r)) != null && le.is_initial), O = !u && !R, { data: Q } = te({
914
+ queryKey: ["pipeline-record-creator", t, e],
915
+ queryFn: () => o.request(
916
+ ie(`/pipelines/instance/${t}/${e}/creator`)
917
+ ).then((a) => a.data ?? null),
918
+ enabled: C && O && b === 0,
798
919
  staleTime: 6e4
799
- }), E = w && h === 0 && (W != null && W.name) ? W : null, re = () => {
800
- f.invalidateQueries({ queryKey: F }), f.invalidateQueries({ queryKey: ["pipeline-instance", n, t] });
801
- }, o = ye({
802
- mutationFn: () => d.request(
803
- he(`/pipelines/instance/${n}/${t}/owners`, {
804
- user: b,
805
- state: k || void 0
920
+ }), V = C && b === 0 && (Q != null && Q.name) ? Q : null, X = () => {
921
+ m.invalidateQueries({ queryKey: L }), m.invalidateQueries({ queryKey: ["pipeline-instance", t, e] });
922
+ }, P = ke({
923
+ mutationFn: () => o.request(
924
+ ye(`/pipelines/instance/${t}/${e}/owners`, {
925
+ user: g,
926
+ state: S || void 0
806
927
  })
807
928
  ),
808
929
  onSuccess: () => {
809
- re(), x(""), B(""), R(!1), Z.success("Owner added");
930
+ X(), x(""), M(""), D(!1), ee.success("Owner added");
810
931
  },
811
932
  // The server's reason (a 403 says why), not a bare status phrase.
812
- onError: (s) => Z.error(ve(s, "Failed to add owner"))
813
- }), ne = ye({
814
- mutationFn: (s) => d.request(Qt(`/pipelines/instance-owners/${s.id}`)),
815
- onSuccess: (s, D) => {
816
- re();
817
- const H = [D.first_name, D.last_name].filter(Boolean).join(" ") || D.email;
818
- Z.success(`${H} removed as an owner`, {
933
+ onError: (a) => ee.error($e(a, "Failed to add owner"))
934
+ }), Z = ke({
935
+ mutationFn: (a) => o.request(rn(`/pipelines/instance-owners/${a.id}`)),
936
+ onSuccess: (a, f) => {
937
+ X();
938
+ const v = [f.first_name, f.last_name].filter(Boolean).join(" ") || f.email;
939
+ ee.success(`${v} removed as an owner`, {
819
940
  action: {
820
941
  label: "Undo",
821
- onClick: () => void d.request(
822
- he(`/pipelines/instance/${n}/${t}/owners`, {
823
- user: D.user,
824
- state: D.state || void 0
942
+ onClick: () => void o.request(
943
+ ye(`/pipelines/instance/${t}/${e}/owners`, {
944
+ user: f.user,
945
+ state: f.state || void 0
825
946
  })
826
- ).then(() => re()).catch((g) => Z.error(ve(g, "Could not add the owner back")))
947
+ ).then(() => X()).catch((T) => ee.error($e(T, "Could not add the owner back")))
827
948
  }
828
949
  });
829
950
  },
830
- onError: (s) => Z.error(ve(s, "Failed to remove owner"))
831
- }), J = (s) => {
832
- var g, Q;
833
- const D = ((g = s.first_name) == null ? void 0 : g[0]) ?? "", H = ((Q = s.last_name) == null ? void 0 : Q[0]) ?? "";
834
- return (`${D}${H}`.trim() || s.email[0] || "?").toUpperCase();
835
- }, m = (s) => {
836
- var D;
837
- return s ? ((D = i.find((H) => H.id === s || H.key === s)) == null ? void 0 : D.label) ?? s : null;
951
+ onError: (a) => ee.error($e(a, "Failed to remove owner"))
952
+ }), z = (a) => {
953
+ var T, y;
954
+ const f = ((T = a.first_name) == null ? void 0 : T[0]) ?? "", v = ((y = a.last_name) == null ? void 0 : y[0]) ?? "";
955
+ return (`${f}${v}`.trim() || a.email[0] || "?").toUpperCase();
956
+ }, p = (a) => {
957
+ var f;
958
+ return a ? ((f = i.find((v) => v.id === a || v.key === a)) == null ? void 0 : f.label) ?? a : null;
838
959
  };
839
- return /* @__PURE__ */ r("div", { children: [
840
- /* @__PURE__ */ r("div", { className: "mb-3 flex items-center justify-between", children: [
841
- /* @__PURE__ */ r("span", { className: "flex items-center gap-1.5 text-[11px] font-medium text-slate-400", children: [
842
- /* @__PURE__ */ e(ft, { className: "h-3.5 w-3.5" }),
960
+ return /* @__PURE__ */ s("div", { children: [
961
+ /* @__PURE__ */ s("div", { className: "mb-3 flex items-center justify-between", children: [
962
+ /* @__PURE__ */ s("span", { className: "flex items-center gap-1.5 text-[11px] font-medium text-slate-400", children: [
963
+ /* @__PURE__ */ n(vt, { className: "h-3.5 w-3.5" }),
843
964
  "Owners",
844
- c || T ? /* @__PURE__ */ e("span", { className: "inline-block h-3 w-4 animate-pulse rounded bg-slate-200 dark:bg-[hsl(var(--nvr-skeleton))]" }) : E ? null : /* @__PURE__ */ r("span", { className: "text-slate-300", children: [
965
+ u || R ? /* @__PURE__ */ n("span", { className: "inline-block h-3 w-4 animate-pulse rounded bg-slate-200 dark:bg-[hsl(var(--nvr-skeleton))]" }) : V ? null : /* @__PURE__ */ s("span", { className: "text-slate-300", children: [
845
966
  "(",
846
- h,
967
+ b,
847
968
  ")"
848
969
  ] })
849
970
  ] }),
850
- /* @__PURE__ */ r("span", { className: "flex items-center gap-3", children: [
851
- a && /* @__PURE__ */ e(nn, { collection: n, itemId: String(t) }),
852
- !N && l && /* @__PURE__ */ r(
971
+ /* @__PURE__ */ s("span", { className: "flex items-center gap-3", children: [
972
+ r && /* @__PURE__ */ n(bn, { collection: t, itemId: String(e) }),
973
+ !_ && d && /* @__PURE__ */ s(
853
974
  "button",
854
975
  {
855
976
  type: "button",
856
- onClick: () => R(!0),
977
+ onClick: () => D(!0),
857
978
  className: "flex items-center gap-1 text-[11px] text-slate-400 transition-colors hover:text-nvr-cyan",
858
979
  children: [
859
- /* @__PURE__ */ e(Ut, { className: "h-3 w-3" }),
980
+ /* @__PURE__ */ n(Zt, { className: "h-3 w-3" }),
860
981
  "Add"
861
982
  ]
862
983
  }
863
984
  )
864
985
  ] })
865
986
  ] }),
866
- c || T ? /* @__PURE__ */ r("div", { className: "flex items-center gap-2 py-1.5 text-[12px] text-slate-400", children: [
867
- /* @__PURE__ */ e(ae, { className: "h-3.5 w-3.5 animate-spin" }),
987
+ u || R ? /* @__PURE__ */ s("div", { className: "flex items-center gap-2 py-1.5 text-[12px] text-slate-400", children: [
988
+ /* @__PURE__ */ n(se, { className: "h-3.5 w-3.5 animate-spin" }),
868
989
  "Resolving owners…"
869
- ] }) : E ? /* @__PURE__ */ r("p", { className: "text-[12px] text-slate-500 dark:text-muted-foreground", children: [
870
- p ? "Back with" : "With",
990
+ ] }) : V ? /* @__PURE__ */ s("p", { className: "text-[12px] text-slate-500 dark:text-muted-foreground", children: [
991
+ l ? "Back with" : "With",
871
992
  " ",
872
- /* @__PURE__ */ e(wt, { userId: E.id, children: /* @__PURE__ */ e(
993
+ /* @__PURE__ */ n(Tt, { userId: V.id, children: /* @__PURE__ */ n(
873
994
  "button",
874
995
  {
875
996
  type: "button",
876
- "aria-label": `${E.name} — profile`,
997
+ "aria-label": `${V.name} — profile`,
877
998
  className: "rounded font-medium text-slate-700 underline-offset-2 hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-nvr-cyan dark:text-foreground",
878
- children: E.name
999
+ children: V.name
879
1000
  }
880
1001
  ) })
881
- ] }) : h === 0 ? /* @__PURE__ */ e("p", { className: "text-[12px] text-slate-400", children: "No owners assigned." }) : /* @__PURE__ */ r("div", { className: "space-y-px", children: [
882
- Y.map((s) => {
883
- var g, Q;
884
- const D = [s.first_name, s.last_name].filter(Boolean).join(" ") || s.email, H = (`${((g = s.first_name) == null ? void 0 : g[0]) ?? ""}${((Q = s.last_name) == null ? void 0 : Q[0]) ?? ""}`.trim() || s.email[0] || "?").toUpperCase();
885
- return /* @__PURE__ */ r(
1002
+ ] }) : b === 0 ? /* @__PURE__ */ n("p", { className: "text-[12px] text-slate-400", children: "No owners assigned." }) : /* @__PURE__ */ s("div", { className: "space-y-px", children: [
1003
+ G.map((a) => {
1004
+ var T, y;
1005
+ const f = [a.first_name, a.last_name].filter(Boolean).join(" ") || a.email, v = (`${((T = a.first_name) == null ? void 0 : T[0]) ?? ""}${((y = a.last_name) == null ? void 0 : y[0]) ?? ""}`.trim() || a.email[0] || "?").toUpperCase();
1006
+ return /* @__PURE__ */ s(
886
1007
  "div",
887
1008
  {
888
1009
  className: "-mx-2 flex items-center gap-2.5 rounded-md px-2 py-1.5 transition-colors hover:bg-slate-50 dark:hover:bg-white/5",
889
1010
  children: [
890
- /* @__PURE__ */ e(mt, { userId: s.id, name: D, email: s.email, initials: H }),
891
- s.queue_only ? /* @__PURE__ */ e(
1011
+ /* @__PURE__ */ n(yt, { userId: a.id, name: f, email: a.email, initials: v }),
1012
+ a.queue_only ? /* @__PURE__ */ n(
892
1013
  "span",
893
1014
  {
894
1015
  className: "shrink-0 rounded-full bg-slate-100 px-1.5 py-0.5 text-[10px] font-medium text-slate-500 dark:bg-slate-800 dark:text-slate-400",
895
1016
  "data-tip": "The record is in their queue, but only the step’s owners can move it",
896
1017
  children: "in their queue"
897
1018
  }
898
- ) : /* @__PURE__ */ e("span", { className: "shrink-0 rounded-full bg-nvr-cyan/10 px-1.5 py-0.5 text-[10px] font-medium text-nvr-navy/70 dark:text-nvr-cyan", children: "owner group" })
1019
+ ) : /* @__PURE__ */ n("span", { className: "shrink-0 rounded-full bg-nvr-cyan/10 px-1.5 py-0.5 text-[10px] font-medium text-nvr-navy/70 dark:text-nvr-cyan", children: "owner group" })
899
1020
  ]
900
1021
  },
901
- `group-${s.id}`
1022
+ `group-${a.id}`
902
1023
  );
903
1024
  }),
904
- (A ?? []).map((s) => /* @__PURE__ */ r(
1025
+ (A ?? []).map((a) => /* @__PURE__ */ s(
905
1026
  "div",
906
1027
  {
907
1028
  className: "group -mx-2 flex items-center gap-2.5 rounded-md px-2 py-1.5 transition-colors hover:bg-slate-50 dark:hover:bg-white/5",
908
1029
  children: [
909
- /* @__PURE__ */ e(
910
- mt,
1030
+ /* @__PURE__ */ n(
1031
+ yt,
911
1032
  {
912
- userId: s.user,
913
- name: [s.first_name, s.last_name].filter(Boolean).join(" ") || s.email,
914
- email: s.email,
915
- initials: J(s)
1033
+ userId: a.user,
1034
+ name: [a.first_name, a.last_name].filter(Boolean).join(" ") || a.email,
1035
+ email: a.email,
1036
+ initials: z(a)
916
1037
  }
917
1038
  ),
918
- /* @__PURE__ */ e("span", { className: "shrink-0 rounded-full bg-amber-50 px-1.5 py-0.5 text-[10px] font-medium text-amber-700 dark:bg-amber-500/10 dark:text-amber-400", children: "manual" }),
919
- /* @__PURE__ */ e("span", { className: "shrink-0 rounded-full bg-slate-100 px-1.5 py-0.5 text-[10px] text-slate-500", children: s.state ? m(s.state) : "all states" }),
920
- /* @__PURE__ */ e(
1039
+ /* @__PURE__ */ n("span", { className: "shrink-0 rounded-full bg-amber-50 px-1.5 py-0.5 text-[10px] font-medium text-amber-700 dark:bg-amber-500/10 dark:text-amber-400", children: "manual" }),
1040
+ /* @__PURE__ */ n("span", { className: "shrink-0 rounded-full bg-slate-100 px-1.5 py-0.5 text-[10px] text-slate-500", children: a.state ? p(a.state) : "all states" }),
1041
+ /* @__PURE__ */ n(
921
1042
  "button",
922
1043
  {
923
1044
  type: "button",
924
- "aria-label": `Remove ${[s.first_name, s.last_name].filter(Boolean).join(" ") || s.email} as an owner`,
925
- disabled: ne.isPending,
926
- onClick: () => ne.mutate(s),
1045
+ "aria-label": `Remove ${[a.first_name, a.last_name].filter(Boolean).join(" ") || a.email} as an owner`,
1046
+ disabled: Z.isPending,
1047
+ onClick: () => Z.mutate(a),
927
1048
  className: "shrink-0 rounded p-0.5 text-slate-300 opacity-0 transition-all hover:text-red-500 focus-visible:opacity-100 group-hover:opacity-100",
928
- children: /* @__PURE__ */ e(ht, { className: "h-3 w-3" })
1049
+ children: /* @__PURE__ */ n(Nt, { className: "h-3 w-3" })
929
1050
  }
930
1051
  )
931
1052
  ]
932
1053
  },
933
- s.id
1054
+ a.id
934
1055
  ))
935
1056
  ] }),
936
- N && /* @__PURE__ */ r("div", { className: "mt-3 space-y-2 rounded-lg border border-slate-200 bg-slate-50 dark:bg-slate-900/30 dark:border-border p-3", children: [
937
- /* @__PURE__ */ e("p", { className: "text-[11px] font-semibold text-slate-500", children: "Add owner" }),
938
- /* @__PURE__ */ e(xn, { value: b, onChange: x }),
939
- y ? /* @__PURE__ */ r(He, { open: M, onOpenChange: O, children: [
940
- /* @__PURE__ */ e(Ve, { asChild: !0, children: /* @__PURE__ */ r(
1057
+ _ && /* @__PURE__ */ s("div", { className: "mt-3 space-y-2 rounded-lg border border-slate-200 bg-slate-50 dark:bg-slate-900/30 dark:border-border p-3", children: [
1058
+ /* @__PURE__ */ n("p", { className: "text-[11px] font-semibold text-slate-500", children: "Add owner" }),
1059
+ /* @__PURE__ */ n(Fn, { value: g, onChange: x }),
1060
+ h ? /* @__PURE__ */ s(et, { open: U, onOpenChange: B, children: [
1061
+ /* @__PURE__ */ n(tt, { asChild: !0, children: /* @__PURE__ */ s(
941
1062
  "button",
942
1063
  {
943
1064
  type: "button",
944
1065
  className: "flex h-8 w-full items-center justify-between rounded-md border border-slate-200 bg-white px-2.5 text-left text-[13px] text-slate-700 transition-colors hover:border-slate-300 dark:border-border dark:bg-transparent dark:text-slate-300",
945
1066
  children: [
946
- /* @__PURE__ */ e("span", { className: "truncate", children: k ? ((P = i.find((s) => s.id === k)) == null ? void 0 : P.label) ?? k : "All states" }),
947
- /* @__PURE__ */ e(fe, { className: "h-3.5 w-3.5 shrink-0 text-slate-400" })
1067
+ /* @__PURE__ */ n("span", { className: "truncate", children: S ? ((ne = i.find((a) => a.id === S)) == null ? void 0 : ne.label) ?? S : "All states" }),
1068
+ /* @__PURE__ */ n(xe, { className: "h-3.5 w-3.5 shrink-0 text-slate-400" })
948
1069
  ]
949
1070
  }
950
1071
  ) }),
951
- /* @__PURE__ */ e(Xe, { align: "start", sideOffset: 4, className: "w-52 p-1", children: ["", ...i.map((s) => s.id)].map((s) => {
952
- var g;
953
- const D = s === "" ? "All states" : ((g = i.find((Q) => Q.id === s)) == null ? void 0 : g.label) ?? s;
954
- return /* @__PURE__ */ e(
1072
+ /* @__PURE__ */ n(nt, { align: "start", sideOffset: 4, className: "w-52 p-1", children: ["", ...i.map((a) => a.id)].map((a) => {
1073
+ var T;
1074
+ const f = a === "" ? "All states" : ((T = i.find((y) => y.id === a)) == null ? void 0 : T.label) ?? a;
1075
+ return /* @__PURE__ */ n(
955
1076
  "button",
956
1077
  {
957
1078
  type: "button",
958
- className: we(
1079
+ className: _e(
959
1080
  "flex w-full rounded px-2.5 py-1.5 text-left text-[13px] transition-colors hover:bg-slate-50 dark:hover:bg-white/5",
960
- k === s && "font-medium text-slate-800 dark:text-slate-200"
1081
+ S === a && "font-medium text-slate-800 dark:text-slate-200"
961
1082
  ),
962
1083
  onClick: () => {
963
- B(s), O(!1);
1084
+ M(a), B(!1);
964
1085
  },
965
- children: D
1086
+ children: f
966
1087
  },
967
- s
1088
+ a
968
1089
  );
969
1090
  }) })
970
- ] }) : /* @__PURE__ */ e("p", { className: "text-[11px] text-slate-500 dark:text-slate-400", children: "Hands off the current step." }),
971
- /* @__PURE__ */ r("div", { className: "flex items-center justify-end gap-2 pt-0.5", children: [
972
- /* @__PURE__ */ e(
973
- G,
1091
+ ] }) : /* @__PURE__ */ n("p", { className: "text-[11px] text-slate-500 dark:text-slate-400", children: "Hands off the current step." }),
1092
+ /* @__PURE__ */ s("div", { className: "flex items-center justify-end gap-2 pt-0.5", children: [
1093
+ /* @__PURE__ */ n(
1094
+ Y,
974
1095
  {
975
1096
  type: "button",
976
1097
  size: "sm",
977
1098
  variant: "ghost",
978
1099
  className: "h-7 text-[12px]",
979
1100
  onClick: () => {
980
- R(!1), x(""), B("");
1101
+ D(!1), x(""), M("");
981
1102
  },
982
1103
  children: "Cancel"
983
1104
  }
984
1105
  ),
985
- /* @__PURE__ */ e(
986
- G,
1106
+ /* @__PURE__ */ n(
1107
+ Y,
987
1108
  {
988
1109
  type: "button",
989
1110
  size: "sm",
990
1111
  className: "h-7 text-[12px]",
991
- disabled: !b || o.isPending,
992
- onClick: () => o.mutate(),
993
- children: o.isPending ? /* @__PURE__ */ e(ae, { className: "h-3.5 w-3.5 animate-spin" }) : "Add"
1112
+ disabled: !g || P.isPending,
1113
+ onClick: () => P.mutate(),
1114
+ children: P.isPending ? /* @__PURE__ */ n(se, { className: "h-3.5 w-3.5 animate-spin" }) : "Add"
994
1115
  }
995
1116
  )
996
1117
  ] })
997
1118
  ] })
998
1119
  ] });
999
1120
  }
1000
- const pt = {
1121
+ const wt = {
1001
1122
  out: "out of office",
1002
1123
  suspended: "suspended",
1003
1124
  redacted: "redacted"
1004
1125
  };
1005
- function yn({
1006
- collection: n,
1007
- item: t,
1126
+ function Bn({
1127
+ collection: t,
1128
+ item: e,
1008
1129
  states: i,
1009
- currentStateId: a
1130
+ currentStateId: r
1010
1131
  }) {
1011
- const p = be(), [d, f] = K(!1), { data: y, isLoading: N } = ee({
1012
- queryKey: ["pipeline-all-owners", n, t],
1013
- queryFn: () => p.request(
1014
- se(`/pipelines/instance/${n}/${t}/owners/all`)
1015
- ).then((b) => b.data ?? null),
1016
- enabled: d,
1132
+ const l = he(), [o, m] = K(!1), { data: h, isLoading: _ } = te({
1133
+ queryKey: ["pipeline-all-owners", t, e],
1134
+ queryFn: () => l.request(
1135
+ ie(`/pipelines/instance/${t}/${e}/owners/all`)
1136
+ ).then((g) => g.data ?? null),
1137
+ enabled: o,
1017
1138
  staleTime: 3e4
1018
- }), R = [...i].filter((b) => {
1139
+ }), D = [...i].filter((g) => {
1019
1140
  var x;
1020
- return !y || ((x = y[b.id]) == null ? void 0 : x.on_path) !== !1;
1021
- }).sort((b, x) => b.sort - x.sort);
1022
- return /* @__PURE__ */ r(He, { open: d, onOpenChange: f, children: [
1023
- /* @__PURE__ */ e(Ve, { asChild: !0, children: /* @__PURE__ */ e(
1141
+ return !h || ((x = h[g.id]) == null ? void 0 : x.on_path) !== !1;
1142
+ }).sort((g, x) => g.sort - x.sort);
1143
+ return /* @__PURE__ */ s(et, { open: o, onOpenChange: m, children: [
1144
+ /* @__PURE__ */ n(tt, { asChild: !0, children: /* @__PURE__ */ n(
1024
1145
  "button",
1025
1146
  {
1026
1147
  type: "button",
1027
1148
  title: "View approval chain",
1028
1149
  className: "flex h-6 w-6 items-center justify-center rounded text-slate-400 transition-colors hover:bg-slate-100 hover:text-slate-600 dark:hover:bg-muted dark:hover:text-slate-300",
1029
- onClick: (b) => b.stopPropagation(),
1030
- children: /* @__PURE__ */ e(ft, { className: "h-3.5 w-3.5" })
1150
+ onClick: (g) => g.stopPropagation(),
1151
+ children: /* @__PURE__ */ n(vt, { className: "h-3.5 w-3.5" })
1031
1152
  }
1032
1153
  ) }),
1033
- /* @__PURE__ */ r(Xe, { align: "end", sideOffset: 6, className: "w-[576px] p-0 overflow-hidden", children: [
1034
- /* @__PURE__ */ r("div", { className: "border-b border-slate-100 px-4 py-3", children: [
1035
- /* @__PURE__ */ e("p", { className: "text-[12px] font-semibold text-slate-700", children: "Approval Chain" }),
1036
- /* @__PURE__ */ e("p", { className: "text-[11px] text-slate-400 mt-0.5", children: "Owners per pipeline state" })
1154
+ /* @__PURE__ */ s(nt, { align: "end", sideOffset: 6, className: "w-[576px] p-0 overflow-hidden", children: [
1155
+ /* @__PURE__ */ s("div", { className: "border-b border-slate-100 px-4 py-3", children: [
1156
+ /* @__PURE__ */ n("p", { className: "text-[12px] font-semibold text-slate-700", children: "Approval Chain" }),
1157
+ /* @__PURE__ */ n("p", { className: "text-[11px] text-slate-400 mt-0.5", children: "Owners per pipeline state" })
1037
1158
  ] }),
1038
- /* @__PURE__ */ e("div", { className: "max-h-[504px] overflow-y-auto", children: N ? /* @__PURE__ */ e("div", { className: "space-y-px p-3", children: [1, 2, 3].map((b) => /* @__PURE__ */ e(oe, { className: "h-10 w-full" }, b)) }) : y ? /* @__PURE__ */ e("div", { className: "divide-y divide-slate-100 dark:divide-border/60", children: R.map((b) => {
1039
- var j, S, A, c, _;
1040
- const x = (((j = y[b.id]) == null ? void 0 : j.owners) ?? []).map((l) => ({
1041
- id: l.id,
1042
- name: [l.first_name, l.last_name].filter(Boolean).join(" ") || l.email
1043
- })), k = b.id === a, B = ((S = y[b.id]) == null ? void 0 : S.skipped) === !0 && !k, M = (((A = y[b.id]) == null ? void 0 : A.skip_reasons) ?? []).filter(Boolean), O = ((c = y[b.id]) == null ? void 0 : c.unavailable) ?? [], F = ((_ = y[b.id]) == null ? void 0 : _.blocked) === !0 && !B;
1044
- return /* @__PURE__ */ r(
1159
+ /* @__PURE__ */ n("div", { className: "max-h-[504px] overflow-y-auto", children: _ ? /* @__PURE__ */ n("div", { className: "space-y-px p-3", children: [1, 2, 3].map((g) => /* @__PURE__ */ n(me, { className: "h-10 w-full" }, g)) }) : h ? /* @__PURE__ */ n("div", { className: "divide-y divide-slate-100 dark:divide-border/60", children: D.map((g) => {
1160
+ var E, F, A, u, N;
1161
+ const x = (((E = h[g.id]) == null ? void 0 : E.owners) ?? []).map((d) => ({
1162
+ id: d.id,
1163
+ name: [d.first_name, d.last_name].filter(Boolean).join(" ") || d.email
1164
+ })), S = g.id === r, M = ((F = h[g.id]) == null ? void 0 : F.skipped) === !0 && !S, U = (((A = h[g.id]) == null ? void 0 : A.skip_reasons) ?? []).filter(Boolean), B = ((u = h[g.id]) == null ? void 0 : u.unavailable) ?? [], L = ((N = h[g.id]) == null ? void 0 : N.blocked) === !0 && !M;
1165
+ return /* @__PURE__ */ s(
1045
1166
  "div",
1046
1167
  {
1047
- className: we(
1168
+ className: _e(
1048
1169
  "flex items-center gap-3 px-4 py-2.5",
1049
1170
  // Hex-with-alpha rather than bg-nvr-cyan/N — the
1050
1171
  // nvr-cyan token is an opaque var() so Tailwind silently
1051
1172
  // drops opacity modifiers on it. Kept very light so the
1052
1173
  // tint doesn't clash with the state badge's own color.
1053
- k && "bg-nvr-cyan/[0.06] dark:bg-nvr-cyan/[0.11]",
1054
- B && "opacity-60",
1055
- F && "bg-red-50 dark:bg-red-500/10"
1174
+ S && "bg-nvr-cyan/[0.06] dark:bg-nvr-cyan/[0.11]",
1175
+ M && "opacity-60",
1176
+ L && "bg-red-50 dark:bg-red-500/10"
1056
1177
  ),
1057
- "data-chain-blocked": F ? "" : void 0,
1178
+ "data-chain-blocked": L ? "" : void 0,
1058
1179
  children: [
1059
- /* @__PURE__ */ e(ce, { label: b.label, color: b.color, small: !0 }),
1060
- /* @__PURE__ */ e("div", { className: "flex min-w-0 flex-1 flex-wrap items-center gap-x-2 gap-y-0.5", children: B ? (
1180
+ /* @__PURE__ */ n(pe, { label: g.label, color: g.color, small: !0 }),
1181
+ /* @__PURE__ */ n("div", { className: "flex min-w-0 flex-1 flex-wrap items-center gap-x-2 gap-y-0.5", children: M ? (
1061
1182
  // Radix tooltip with zero delay — native `title` waits on
1062
1183
  // the OS hover timer, and a truncated reason needs its
1063
1184
  // full text the moment the cursor lands on it.
1064
- /* @__PURE__ */ e(vt, { delayDuration: 0, children: /* @__PURE__ */ r(je, { children: [
1065
- /* @__PURE__ */ e(Ie, { asChild: !0, children: /* @__PURE__ */ r("div", { className: "flex min-w-0 flex-1 cursor-default items-center gap-2", children: [
1066
- /* @__PURE__ */ e("span", { className: "inline-flex shrink-0 items-center gap-1 rounded-full border border-dashed border-slate-300 px-2 py-0.5 text-[10.5px] font-medium text-slate-400 dark:border-slate-600 dark:text-slate-500", children: "Skipped" }),
1067
- M.length > 0 && /* @__PURE__ */ e("span", { className: "min-w-0 flex-1 truncate text-[11px] text-slate-400 dark:text-slate-500", children: M.join(" · ") })
1185
+ /* @__PURE__ */ n(qt, { delayDuration: 0, children: /* @__PURE__ */ s(He, { children: [
1186
+ /* @__PURE__ */ n(Ge, { asChild: !0, children: /* @__PURE__ */ s("div", { className: "flex min-w-0 flex-1 cursor-default items-center gap-2", children: [
1187
+ /* @__PURE__ */ n("span", { className: "inline-flex shrink-0 items-center gap-1 rounded-full border border-dashed border-slate-300 px-2 py-0.5 text-[10.5px] font-medium text-slate-400 dark:border-slate-600 dark:text-slate-500", children: "Skipped" }),
1188
+ U.length > 0 && /* @__PURE__ */ n("span", { className: "min-w-0 flex-1 truncate text-[11px] text-slate-400 dark:text-slate-500", children: U.join(" · ") })
1068
1189
  ] }) }),
1069
- /* @__PURE__ */ r(
1070
- Ee,
1190
+ /* @__PURE__ */ s(
1191
+ Ve,
1071
1192
  {
1072
1193
  side: "bottom",
1073
1194
  align: "start",
1074
1195
  className: "max-w-[420px] space-y-0.5 text-[11.5px] leading-snug",
1075
1196
  children: [
1076
- /* @__PURE__ */ e("p", { className: "text-slate-500 dark:text-slate-400", children: "The pipeline will pass through this state without stopping:" }),
1077
- M.length > 0 ? M.map((l) => /* @__PURE__ */ e("p", { children: l }, l)) : /* @__PURE__ */ e("p", { children: "Skip criteria currently match" })
1197
+ /* @__PURE__ */ n("p", { className: "text-slate-500 dark:text-slate-400", children: "The pipeline will pass through this state without stopping:" }),
1198
+ U.length > 0 ? U.map((d) => /* @__PURE__ */ n("p", { children: d }, d)) : /* @__PURE__ */ n("p", { children: "Skip criteria currently match" })
1078
1199
  ]
1079
1200
  }
1080
1201
  )
1081
1202
  ] }) })
1082
- ) : /* @__PURE__ */ r(ue, { children: [
1083
- /* @__PURE__ */ e(Zt, { owners: x, max: 10, emptyLabel: "—" }),
1084
- O.map((l) => /* @__PURE__ */ r(
1203
+ ) : /* @__PURE__ */ s(fe, { children: [
1204
+ /* @__PURE__ */ n(pn, { owners: x, max: 10, emptyLabel: "—" }),
1205
+ B.map((d) => /* @__PURE__ */ s(
1085
1206
  "span",
1086
1207
  {
1087
- "data-tip": `${l.name} is ${pt[l.reason] ?? l.reason}${l.delegate ? ` — ${l.delegate.name} covers${l.delegate.expires_at ? ` until ${new Date(l.delegate.expires_at).toLocaleDateString()}` : ""}` : " and nobody is covering"}`,
1088
- className: we(
1208
+ "data-tip": `${d.name} is ${wt[d.reason] ?? d.reason}${d.delegate ? ` — ${d.delegate.name} covers${d.delegate.expires_at ? ` until ${new Date(d.delegate.expires_at).toLocaleDateString()}` : ""}` : " and nobody is covering"}`,
1209
+ className: _e(
1089
1210
  "inline-flex items-center gap-1 rounded-full border px-1.5 py-0.5 text-[10.5px] font-medium",
1090
- l.delegate ? "border-amber-200 bg-amber-50 text-amber-800 dark:border-amber-500/30 dark:bg-amber-500/10 dark:text-amber-200" : "border-red-200 bg-red-50 text-red-700 dark:border-red-500/30 dark:bg-red-500/10 dark:text-red-300"
1211
+ d.delegate ? "border-amber-200 bg-amber-50 text-amber-800 dark:border-amber-500/30 dark:bg-amber-500/10 dark:text-amber-200" : "border-red-200 bg-red-50 text-red-700 dark:border-red-500/30 dark:bg-red-500/10 dark:text-red-300"
1091
1212
  ),
1092
1213
  children: [
1093
- l.name,
1094
- l.delegate ? /* @__PURE__ */ r(ue, { children: [
1214
+ d.name,
1215
+ d.delegate ? /* @__PURE__ */ s(fe, { children: [
1095
1216
  " → ",
1096
- l.delegate.name,
1097
- l.delegate.expires_at && /* @__PURE__ */ r("span", { className: "opacity-70", children: [
1217
+ d.delegate.name,
1218
+ d.delegate.expires_at && /* @__PURE__ */ s("span", { className: "opacity-70", children: [
1098
1219
  ", until",
1099
1220
  " ",
1100
- new Date(l.delegate.expires_at).toLocaleDateString(
1221
+ new Date(d.delegate.expires_at).toLocaleDateString(
1101
1222
  void 0,
1102
1223
  {
1103
1224
  month: "short",
@@ -1105,207 +1226,221 @@ function yn({
1105
1226
  }
1106
1227
  )
1107
1228
  ] })
1108
- ] }) : /* @__PURE__ */ r("span", { className: "opacity-80", children: [
1229
+ ] }) : /* @__PURE__ */ s("span", { className: "opacity-80", children: [
1109
1230
  " ",
1110
1231
  "· ",
1111
- pt[l.reason] ?? l.reason
1232
+ wt[d.reason] ?? d.reason
1112
1233
  ] })
1113
1234
  ]
1114
1235
  },
1115
- l.id
1236
+ d.id
1116
1237
  )),
1117
- F && /* @__PURE__ */ e("span", { className: "inline-flex items-center gap-1 rounded-full bg-red-600 px-2 py-0.5 text-[10.5px] font-semibold text-white", children: "No one can act here" })
1238
+ L && /* @__PURE__ */ n("span", { className: "inline-flex items-center gap-1 rounded-full bg-red-600 px-2 py-0.5 text-[10.5px] font-semibold text-white", children: "No one can act here" })
1118
1239
  ] }) })
1119
1240
  ]
1120
1241
  },
1121
- b.id
1242
+ g.id
1122
1243
  );
1123
- }) }) : /* @__PURE__ */ e("p", { className: "px-4 py-3 text-[12px] text-slate-400", children: "No pipeline configured." }) })
1244
+ }) }) : /* @__PURE__ */ n("p", { className: "px-4 py-3 text-[12px] text-slate-400", children: "No pipeline configured." }) })
1124
1245
  ] })
1125
1246
  ] });
1126
1247
  }
1127
- function Gn({
1128
- collection: n,
1129
- item: t,
1248
+ function pr({
1249
+ collection: t,
1250
+ item: e,
1130
1251
  defaultExpanded: i,
1131
- title: a,
1132
- showApprovalChain: p,
1133
- hideActionsCollapsed: d,
1134
- hideActionsExpanded: f,
1135
- onBeforeTransition: y,
1136
- addendumPending: N,
1137
- addendumView: R,
1138
- asRole: b
1252
+ title: r,
1253
+ showApprovalChain: l,
1254
+ hideActionsCollapsed: o,
1255
+ hideActionsExpanded: m,
1256
+ onBeforeTransition: h,
1257
+ addendumPending: _,
1258
+ addendumView: D,
1259
+ asRole: g
1139
1260
  }) {
1140
- return t === "new" ? null : /* @__PURE__ */ e(
1141
- wn,
1261
+ return e === "new" ? null : /* @__PURE__ */ n(
1262
+ Mn,
1142
1263
  {
1143
- collection: n,
1144
- item: t,
1264
+ collection: t,
1265
+ item: e,
1145
1266
  defaultExpanded: i,
1146
- title: a,
1147
- showApprovalChain: p,
1148
- hideActionsCollapsed: d,
1149
- hideActionsExpanded: f,
1150
- onBeforeTransition: y,
1151
- addendumPending: N,
1152
- addendumView: R,
1153
- asRole: b
1267
+ title: r,
1268
+ showApprovalChain: l,
1269
+ hideActionsCollapsed: o,
1270
+ hideActionsExpanded: m,
1271
+ onBeforeTransition: h,
1272
+ addendumPending: _,
1273
+ addendumView: D,
1274
+ asRole: g
1154
1275
  },
1155
- `${n}:${t}`
1276
+ `${t}:${e}`
1156
1277
  );
1157
1278
  }
1158
- function Bt({ collection: n, item: t }) {
1159
- const i = be(), { data: a } = ee({
1160
- queryKey: ["approval-brief", n, String(t)],
1161
- queryFn: () => i.request(se(`/pipelines/instance/${n}/${t}/approval-brief`)).then((d) => d.data),
1279
+ function Ht({ collection: t, item: e }) {
1280
+ const i = he(), { data: r } = te({
1281
+ queryKey: Ut(t, e),
1282
+ queryFn: () => Lt(i, t, e),
1162
1283
  staleTime: 3e4,
1163
1284
  retry: !1
1164
1285
  });
1165
- if (!a) return null;
1166
- const p = (d) => {
1167
- if (d == null || d === "") return "—";
1168
- const f = String(d);
1169
- return f.length > 36 ? `${f.slice(0, 36)}…` : f;
1286
+ if (!r) return null;
1287
+ const l = (o) => {
1288
+ if (o == null || o === "") return "—";
1289
+ const m = String(o);
1290
+ return m.length > 36 ? `${m.slice(0, 36)}…` : m;
1170
1291
  };
1171
- return /* @__PURE__ */ r("div", { className: "rounded-md border border-slate-200 bg-white px-3 py-2 text-[11.5px] dark:border-border dark:bg-card", children: [
1172
- /* @__PURE__ */ r("p", { className: "text-slate-500 dark:text-muted-foreground", children: [
1173
- /* @__PURE__ */ e("span", { className: "font-medium text-slate-700 dark:text-foreground", children: "Since entering this state" }),
1292
+ return /* @__PURE__ */ s("div", { className: "rounded-md border border-slate-200 bg-white px-3 py-2 text-[11.5px] dark:border-border dark:bg-card", children: [
1293
+ /* @__PURE__ */ s("p", { className: "text-slate-500 dark:text-muted-foreground", children: [
1294
+ /* @__PURE__ */ n("span", { className: "font-medium text-slate-700 dark:text-foreground", children: "Since entering this state" }),
1174
1295
  " ",
1175
1296
  "(",
1176
- a.days_in_state,
1297
+ r.days_in_state,
1177
1298
  "d ago):",
1178
1299
  " ",
1179
- a.changed_total === 0 && a.comments === 0 && a.addendums.count === 0 ? /* @__PURE__ */ e("span", { children: "no changes to this record." }) : /* @__PURE__ */ r(ue, { children: [
1180
- a.changed_total > 0 && /* @__PURE__ */ r("span", { children: [
1181
- a.changed_total,
1300
+ r.changed_total === 0 && r.comments === 0 && r.addendums.count === 0 ? /* @__PURE__ */ n("span", { children: "no changes to this record." }) : /* @__PURE__ */ s(fe, { children: [
1301
+ r.changed_total > 0 && /* @__PURE__ */ s("span", { children: [
1302
+ r.changed_total,
1182
1303
  " field",
1183
- a.changed_total === 1 ? "" : "s",
1304
+ r.changed_total === 1 ? "" : "s",
1184
1305
  " changed",
1185
- a.edited_by.length > 0 ? ` by ${a.edited_by.join(", ")}` : ""
1306
+ r.edited_by.length > 0 ? ` by ${r.edited_by.join(", ")}` : ""
1186
1307
  ] }),
1187
- a.comments > 0 && /* @__PURE__ */ r("span", { children: [
1188
- a.changed_total > 0 ? " · " : "",
1189
- a.comments,
1308
+ r.comments > 0 && /* @__PURE__ */ s("span", { children: [
1309
+ r.changed_total > 0 ? " · " : "",
1310
+ r.comments,
1190
1311
  " comment",
1191
- a.comments === 1 ? "" : "s"
1312
+ r.comments === 1 ? "" : "s"
1192
1313
  ] }),
1193
- a.addendums.count > 0 && /* @__PURE__ */ r("span", { children: [
1314
+ r.addendums.count > 0 && /* @__PURE__ */ s("span", { children: [
1194
1315
  " · ",
1195
- a.addendums.count,
1316
+ r.addendums.count,
1196
1317
  " addendum",
1197
- a.addendums.count === 1 ? "" : "s",
1198
- a.addendums.cost_impact !== 0 ? ` (${a.addendums.cost_impact > 0 ? "+" : ""}$${Math.abs(a.addendums.cost_impact).toLocaleString()})` : ""
1318
+ r.addendums.count === 1 ? "" : "s",
1319
+ r.addendums.cost_impact !== 0 ? ` (${r.addendums.cost_impact > 0 ? "+" : ""}$${Math.abs(r.addendums.cost_impact).toLocaleString()})` : ""
1199
1320
  ] })
1200
1321
  ] })
1201
1322
  ] }),
1202
- a.field_changes.length > 0 && /* @__PURE__ */ r("div", { className: "mt-1 space-y-0.5", children: [
1203
- a.field_changes.slice(0, 5).map((d) => /* @__PURE__ */ r(
1323
+ r.field_changes.length > 0 && /* @__PURE__ */ s("div", { className: "mt-1 space-y-0.5", children: [
1324
+ r.field_changes.slice(0, 5).map((o) => /* @__PURE__ */ s(
1204
1325
  "p",
1205
1326
  {
1206
1327
  className: "font-mono text-[10.5px] text-slate-500 dark:text-muted-foreground",
1207
1328
  children: [
1208
- d.field,
1329
+ o.field,
1209
1330
  ":",
1210
1331
  " ",
1211
- d.old !== void 0 && /* @__PURE__ */ r(ue, { children: [
1212
- /* @__PURE__ */ e("span", { className: "text-red-600 line-through dark:text-red-400", children: p(d.old) }),
1332
+ o.old !== void 0 && /* @__PURE__ */ s(fe, { children: [
1333
+ /* @__PURE__ */ n("span", { className: "text-red-600 line-through dark:text-red-400", children: l(o.old) }),
1213
1334
  " "
1214
1335
  ] }),
1215
- /* @__PURE__ */ e("span", { className: "text-emerald-600 dark:text-emerald-400", children: p(d.new) })
1336
+ /* @__PURE__ */ n("span", { className: "text-emerald-600 dark:text-emerald-400", children: l(o.new) })
1216
1337
  ]
1217
1338
  },
1218
- d.field
1339
+ o.field
1219
1340
  )),
1220
- a.field_changes.length > 5 && /* @__PURE__ */ r("p", { className: "text-[10.5px] text-slate-400", children: [
1341
+ r.field_changes.length > 5 && /* @__PURE__ */ s("p", { className: "text-[10.5px] text-slate-400", children: [
1221
1342
  "+",
1222
- a.field_changes.length - 5,
1343
+ r.field_changes.length - 5,
1223
1344
  " more — see History for the full trail"
1224
1345
  ] })
1225
1346
  ] }),
1226
- (a.lines ?? []).map((d) => /* @__PURE__ */ r(
1347
+ (r.lines ?? []).map((o) => /* @__PURE__ */ s(
1227
1348
  "p",
1228
1349
  {
1229
- "data-brief-line": d.label,
1350
+ "data-brief-line": o.label,
1230
1351
  className: "mt-1 text-slate-500 dark:text-muted-foreground",
1231
1352
  children: [
1232
- /* @__PURE__ */ e("span", { className: "font-medium text-slate-700 dark:text-foreground", children: d.label }),
1353
+ /* @__PURE__ */ n("span", { className: "font-medium text-slate-700 dark:text-foreground", children: o.label }),
1233
1354
  " ",
1234
- /* @__PURE__ */ e(
1355
+ /* @__PURE__ */ n(
1235
1356
  "span",
1236
1357
  {
1237
- className: d.tone === "danger" ? "text-red-700 dark:text-red-300" : d.tone === "warn" ? "text-amber-700 dark:text-amber-300" : "",
1238
- children: d.text
1358
+ className: o.tone === "danger" ? "text-red-700 dark:text-red-300" : o.tone === "warn" ? "text-amber-700 dark:text-amber-300" : "",
1359
+ children: o.text
1239
1360
  }
1240
1361
  )
1241
1362
  ]
1242
1363
  },
1243
- `${d.label}:${d.text}`
1364
+ `${o.label}:${o.text}`
1244
1365
  ))
1245
1366
  ] });
1246
1367
  }
1247
- function wn({
1248
- collection: n,
1249
- item: t,
1368
+ function Mn({
1369
+ collection: t,
1370
+ item: e,
1250
1371
  defaultExpanded: i,
1251
- title: a,
1252
- showApprovalChain: p,
1253
- hideActionsCollapsed: d,
1254
- hideActionsExpanded: f,
1255
- onBeforeTransition: y,
1256
- addendumPending: N,
1257
- addendumView: R,
1258
- asRole: b
1372
+ title: r,
1373
+ showApprovalChain: l,
1374
+ hideActionsCollapsed: o,
1375
+ hideActionsExpanded: m,
1376
+ onBeforeTransition: h,
1377
+ addendumPending: _,
1378
+ addendumView: D,
1379
+ asRole: g
1259
1380
  }) {
1260
- var tt, nt, rt;
1261
- const x = be(), k = ke(), [B, M] = K(""), [O, F] = K(null), [j, S] = K(!1), [A, c] = K(!1), [_, l] = K(null), [$, T] = K(null);
1262
- yt(n, t, "transition", !!O || !!_);
1263
- const L = Wt(n, t, "transition"), Y = te(!1);
1264
- de(() => {
1265
- !Y.current && i !== void 0 && (Y.current = !0, c(i));
1381
+ var ot, dt, ct;
1382
+ const x = he(), S = Se(), [M, U] = K(""), [B, L] = K(null), [E, F] = K(!1), [A, u] = K(!1), [N, d] = K(null), [$, R] = K(null), [w, G] = K([]), b = jt(t, String(e));
1383
+ $t(t, e, "transition", !!B || !!N);
1384
+ const C = sn(t, e, "transition"), O = J(!1);
1385
+ ue(() => {
1386
+ !O.current && i !== void 0 && (O.current = !0, u(i));
1266
1387
  }, [i]);
1267
- const h = te(!1), w = (u) => {
1268
- h.current || (h.current = !0, T(null), s.mutate(u, {
1269
- onSettled: (q, U) => {
1270
- if (U) {
1271
- h.current = !1;
1388
+ const Q = J(!1), V = (c) => {
1389
+ Q.current || (Q.current = !0, R(null), y.mutate(c, {
1390
+ onSettled: (q, I) => {
1391
+ if (I) {
1392
+ Q.current = !1;
1272
1393
  return;
1273
1394
  }
1274
- re().finally(() => {
1275
- h.current = !1;
1395
+ z().finally(() => {
1396
+ Q.current = !1;
1276
1397
  });
1277
1398
  }
1278
1399
  }));
1279
- }, I = async (u) => {
1280
- if (h.current) return;
1281
- if (O === u) {
1282
- F(null);
1400
+ }, X = async (c) => {
1401
+ var H;
1402
+ if (Q.current) return;
1403
+ if (B === c) {
1404
+ L(null);
1283
1405
  return;
1284
1406
  }
1285
- if (y) {
1286
- h.current = !0;
1287
- let z = !1;
1407
+ if (h) {
1408
+ Q.current = !0;
1409
+ let j = !1;
1288
1410
  try {
1289
- z = await y();
1411
+ j = await h();
1290
1412
  } finally {
1291
- h.current = !1;
1413
+ Q.current = !1;
1292
1414
  }
1293
- if (!z) return;
1415
+ if (!j) return;
1294
1416
  }
1295
- const q = (Q ?? []).find((z) => z.id === u), U = String((q == null ? void 0 : q.comment_mode) ?? "none");
1296
- if (U !== "optional" && U !== "required") {
1297
- w({ transition_id: u });
1417
+ const q = (ae ?? []).find((j) => j.id === c), I = String((q == null ? void 0 : q.comment_mode) ?? "none");
1418
+ if (I !== "optional" && I !== "required") {
1419
+ if (q && !Oe(q, (p == null ? void 0 : p.states) ?? [], (H = p == null ? void 0 : p.instance) == null ? void 0 : H.current_state)) {
1420
+ Q.current = !0;
1421
+ let j = [];
1422
+ try {
1423
+ j = await b();
1424
+ } finally {
1425
+ Q.current = !1;
1426
+ }
1427
+ if (j.length > 0) {
1428
+ G(j), L(c);
1429
+ return;
1430
+ }
1431
+ }
1432
+ V({ transition_id: c });
1298
1433
  return;
1299
1434
  }
1300
- F(u);
1301
- }, W = b ? ["pipeline-instance", n, t, b] : ["pipeline-instance", n, t], { settling: E, settle: re } = Tt(W), { data: o, isLoading: ne } = ee({
1302
- queryKey: W,
1435
+ G([]), L(c);
1436
+ }, P = g ? ["pipeline-instance", t, e, g] : ["pipeline-instance", t, e], { settling: Z, settle: z } = Mt(P), { data: p, isLoading: ce } = te({
1437
+ queryKey: P,
1303
1438
  queryFn: () => x.request(
1304
- se(
1305
- `/pipelines/instance/${n}/${t}${b ? `?as_role=${encodeURIComponent(b)}` : ""}`
1439
+ ie(
1440
+ `/pipelines/instance/${t}/${e}${g ? `?as_role=${encodeURIComponent(g)}` : ""}`
1306
1441
  )
1307
1442
  ).then(
1308
- (u) => u.data ?? {
1443
+ (c) => c.data ?? {
1309
1444
  instance: null,
1310
1445
  states: [],
1311
1446
  available_transitions: [],
@@ -1315,322 +1450,331 @@ function wn({
1315
1450
  }
1316
1451
  ),
1317
1452
  staleTime: 1e4
1318
- });
1319
- de(
1320
- () => k.getQueryCache().subscribe((u) => {
1321
- if (u.type !== "updated" || u.action.type !== "success") return;
1322
- const q = u.query.queryKey;
1323
- Array.isArray(q) && q[0] === "item" && q[1] === n && String(q[2]) === t && k.invalidateQueries({ queryKey: ["pipeline-instance", n, t] });
1453
+ }), le = Ot(
1454
+ p ? (p.available_transitions ?? []).map((c) => String(c.id)) : null,
1455
+ `${t}:${e}`
1456
+ );
1457
+ ue(
1458
+ () => S.getQueryCache().subscribe((c) => {
1459
+ if (c.type !== "updated" || c.action.type !== "success") return;
1460
+ const q = c.query.queryKey;
1461
+ Array.isArray(q) && q[0] === "item" && q[1] === t && String(q[2]) === e && S.invalidateQueries({ queryKey: ["pipeline-instance", t, e] });
1324
1462
  }),
1325
- [k, n, t]
1463
+ [S, t, e]
1326
1464
  );
1327
- const { data: J, isLoading: m } = ee({
1328
- queryKey: ["pipeline-all-owners", n, t],
1465
+ const { data: ne, isLoading: a } = te({
1466
+ queryKey: ["pipeline-all-owners", t, e],
1329
1467
  queryFn: () => x.request(
1330
- se(`/pipelines/instance/${n}/${t}/owners/all`)
1331
- ).then((u) => u.data ?? null),
1468
+ ie(`/pipelines/instance/${t}/${e}/owners/all`)
1469
+ ).then((c) => c.data ?? null),
1332
1470
  // Also when a send back is on offer: its target may be a chain step this record skipped.
1333
- enabled: (A || Rt(o)) && !!(o != null && o.instance),
1471
+ enabled: (A || It(p)) && !!(p != null && p.instance),
1334
1472
  staleTime: 3e4
1335
- }), v = Fe(() => {
1336
- if (!J) return null;
1337
- const u = Object.entries(J);
1338
- return u.length === 0 || u.every(([, q]) => q.on_path === void 0) ? null : new Set(u.filter(([, q]) => q.on_path !== !1).map(([q]) => q));
1339
- }, [J]), C = Fe(() => {
1340
- if (!J) return null;
1341
- const u = /* @__PURE__ */ new Map();
1342
- for (const [q, U] of Object.entries(J))
1343
- U.skipped && u.set(q, U.skip_reasons ?? []);
1344
- return u;
1345
- }, [J]), P = ye({
1346
- mutationFn: () => x.request(he(`/pipelines/instance/${n}/${t}/start`, {})),
1473
+ }), f = Fe(() => {
1474
+ if (!ne) return null;
1475
+ const c = Object.entries(ne);
1476
+ return c.length === 0 || c.every(([, q]) => q.on_path === void 0) ? null : new Set(c.filter(([, q]) => q.on_path !== !1).map(([q]) => q));
1477
+ }, [ne]), v = Fe(() => {
1478
+ if (!ne) return null;
1479
+ const c = /* @__PURE__ */ new Map();
1480
+ for (const [q, I] of Object.entries(ne))
1481
+ I.skipped && c.set(q, I.skip_reasons ?? []);
1482
+ return c;
1483
+ }, [ne]), T = ke({
1484
+ mutationFn: () => x.request(ye(`/pipelines/instance/${t}/${e}/start`, {})),
1347
1485
  onSuccess: () => {
1348
- k.invalidateQueries({ queryKey: W }), Z.success("Pipeline started");
1486
+ S.invalidateQueries({ queryKey: P }), ee.success("Pipeline started");
1349
1487
  },
1350
- onError: () => Z.error("Failed to start pipeline")
1351
- }), s = ye({
1488
+ onError: () => ee.error("Failed to start pipeline")
1489
+ }), y = ke({
1352
1490
  mutationFn: ({
1353
- transition_id: u,
1491
+ transition_id: c,
1354
1492
  comment: q,
1355
- reviewed: U
1493
+ reviewed: I
1356
1494
  }) => x.request(
1357
- he(`/pipelines/instance/${n}/${t}/transition`, {
1358
- transition_id: u,
1495
+ ye(`/pipelines/instance/${t}/${e}/transition`, {
1496
+ transition_id: c,
1359
1497
  comment: q,
1360
- ...U ? { reviewed: !0 } : {}
1498
+ ...I ? { reviewed: !0 } : {}
1361
1499
  })
1362
1500
  ),
1363
- onSuccess: (u, q) => {
1364
- k.invalidateQueries({ queryKey: W }), n === "nivaro_addendums" && k.invalidateQueries({ queryKey: ["addendums"] }), qe(k, n, String(t)), Ne(k, n, String(t)), Dt(k, n, String(t)), T(null), M(""), F(null), l(null), Z.success(At(o, q.transition_id, u));
1501
+ onSuccess: (c, q) => {
1502
+ S.invalidateQueries({ queryKey: P }), t === "nivaro_addendums" && S.invalidateQueries({ queryKey: ["addendums"] }), Be(S, t, String(e)), Te(S, t, String(e)), zt(S, t, String(e)), R(null), U(""), L(null), d(null), ee.success(Qt(p, q.transition_id, c));
1365
1503
  },
1366
- onError: (u, q) => {
1367
- if (St(u)) {
1368
- k.invalidateQueries({ queryKey: W });
1504
+ onError: (c, q) => {
1505
+ if (Ft(c)) {
1506
+ S.invalidateQueries({ queryKey: P });
1369
1507
  return;
1370
1508
  }
1371
- const U = Ct(u);
1372
- if (U) {
1373
- l((V) => ({
1374
- payload: U,
1509
+ const I = At(c);
1510
+ if (I) {
1511
+ d((j) => ({
1512
+ payload: I,
1375
1513
  transitionId: q.transition_id,
1376
1514
  comment: q.comment,
1377
- revision: ((V == null ? void 0 : V.revision) ?? 0) + 1
1515
+ revision: ((j == null ? void 0 : j.revision) ?? 0) + 1
1378
1516
  }));
1379
1517
  return;
1380
1518
  }
1381
- const z = u == null ? void 0 : u.response;
1382
- T($t(u, q)), Z.error(ve(u, "Failed to execute transition"), {
1519
+ const H = c == null ? void 0 : c.response;
1520
+ R(Bt(c, q)), ee.error($e(c, "Failed to execute transition"), {
1383
1521
  duration: 12e3,
1384
1522
  // What to do next + Copy details (lib/error-toast.ts); "Why?" below wins the action slot.
1385
- ...gt(u, { action: "Transition" }),
1523
+ ...Ct(c, { action: "Transition" }),
1386
1524
  // #1867: a refusal carries "Why?" — the role, owner or access rule
1387
1525
  // that stopped it, and who can change it.
1388
- ...Nt(u) ? {
1389
- action: kt(x, {
1390
- collection: n,
1391
- itemId: String(t),
1526
+ ...Rt(c) ? {
1527
+ action: Pt(x, {
1528
+ collection: t,
1529
+ itemId: String(e),
1392
1530
  action: "transition",
1393
1531
  transitionId: q.transition_id
1394
1532
  })
1395
1533
  } : {}
1396
- }), l(null), F(null), qe(k, n, String(t)), Ne(k, n, String(t)), (z == null ? void 0 : z.status) === 409 && k.invalidateQueries({ queryKey: W });
1534
+ }), d(null), L(null), Be(S, t, String(e)), Te(S, t, String(e)), (H == null ? void 0 : H.status) === 409 && S.invalidateQueries({ queryKey: P });
1397
1535
  }
1398
- }), D = te(I);
1399
- D.current = I;
1400
- const H = te((o == null ? void 0 : o.available_transitions) ?? []);
1401
- if (H.current = (o == null ? void 0 : o.available_transitions) ?? [], de(() => {
1402
- const u = (q) => {
1403
- const U = q.detail;
1404
- if (!U || U.claimed || U.collection !== n || String(U.item) !== String(t)) return;
1405
- U.claimed = !0;
1406
- const z = String(U.transition_id).toUpperCase(), V = H.current.find((pe) => String(pe.id).toUpperCase() === z);
1407
- if (!V) {
1408
- Z.error("That step is not available from where the record is now");
1536
+ }), oe = J(X);
1537
+ oe.current = X;
1538
+ const Ce = J((p == null ? void 0 : p.available_transitions) ?? []);
1539
+ if (Ce.current = (p == null ? void 0 : p.available_transitions) ?? [], ue(() => {
1540
+ const c = (q) => {
1541
+ const I = q.detail;
1542
+ if (!I || I.claimed || I.collection !== t || String(I.item) !== String(e)) return;
1543
+ I.claimed = !0;
1544
+ const H = String(I.transition_id).toUpperCase(), j = Ce.current.find((ge) => String(ge.id).toUpperCase() === H);
1545
+ if (!j) {
1546
+ ee.error("That step is not available from where the record is now");
1409
1547
  return;
1410
1548
  }
1411
- D.current(V.id);
1549
+ oe.current(j.id);
1412
1550
  };
1413
- return window.addEventListener(Te, u), () => window.removeEventListener(Te, u);
1414
- }, [n, t]), ne)
1415
- return /* @__PURE__ */ e("div", { className: "overflow-hidden rounded-xl border border-slate-200 bg-white dark:border-border dark:bg-card", children: /* @__PURE__ */ r("div", { className: "flex w-full items-center gap-2.5 px-5 py-3.5", children: [
1416
- /* @__PURE__ */ e(oe, { className: "h-3.5 w-3.5 shrink-0 rounded" }),
1417
- /* @__PURE__ */ e(oe, { className: "h-4 w-20" }),
1418
- /* @__PURE__ */ e(oe, { className: "h-[22px] w-40 rounded-full" }),
1419
- /* @__PURE__ */ e(oe, { className: "ml-auto h-3.5 w-3.5 rounded" })
1551
+ return window.addEventListener(Ae, c), () => window.removeEventListener(Ae, c);
1552
+ }, [t, e]), ce)
1553
+ return /* @__PURE__ */ n("div", { className: "overflow-hidden rounded-xl border border-slate-200 bg-white dark:border-border dark:bg-card", children: /* @__PURE__ */ s("div", { className: "flex w-full items-center gap-2.5 px-5 py-3.5", children: [
1554
+ /* @__PURE__ */ n(me, { className: "h-3.5 w-3.5 shrink-0 rounded" }),
1555
+ /* @__PURE__ */ n(me, { className: "h-4 w-20" }),
1556
+ /* @__PURE__ */ n(me, { className: "h-[22px] w-40 rounded-full" }),
1557
+ /* @__PURE__ */ n(me, { className: "ml-auto h-3.5 w-3.5 rounded" })
1420
1558
  ] }) });
1421
- if (!(o != null && o.binding)) return null;
1422
- const { instance: g, available_transitions: Q, history: ie, states: me } = o, _e = new Map((me ?? []).map((u) => [u.id, u])), xe = (g == null ? void 0 : g.current_state_obj) ?? null, le = O ? (Q ?? []).find((u) => u.id === O) : null, Pe = le ? _e.get(le.to_state) : null, Ft = g != null && g.completed_at && Q ? Q.filter(
1423
- (u) => u.from_state && String(u.from_state).toUpperCase() === String(g.current_state).toUpperCase()
1424
- ) : null, Ae = g != null && g.completed_at ? Ft ?? [] : Pt(
1425
- Q ?? [],
1426
- me ?? [],
1427
- g == null ? void 0 : g.current_state,
1428
- C
1429
- ), Ye = Ae.length > 0, Je = (u, q = !1) => {
1430
- const U = /* @__PURE__ */ new Map();
1431
- for (const z of u) {
1432
- const V = U.get(z.label) ?? [];
1433
- V.push(z), U.set(z.label, V);
1559
+ if (!(p != null && p.binding)) return null;
1560
+ const { instance: k, available_transitions: ae, history: de, states: be } = p, qe = new Map((be ?? []).map((c) => [c.id, c])), we = (k == null ? void 0 : k.current_state_obj) ?? null, re = B ? (ae ?? []).find((c) => c.id === B) : null, Ue = re ? qe.get(re.to_state) : null, Gt = k != null && k.completed_at && ae ? ae.filter(
1561
+ (c) => c.from_state && String(c.from_state).toUpperCase() === String(k.current_state).toUpperCase()
1562
+ ) : null, Le = k != null && k.completed_at ? Gt ?? [] : Kt(
1563
+ ae ?? [],
1564
+ be ?? [],
1565
+ k == null ? void 0 : k.current_state,
1566
+ v
1567
+ ), at = Le.length > 0, st = (c, q = !1) => {
1568
+ const I = /* @__PURE__ */ new Map();
1569
+ for (const H of c) {
1570
+ const j = I.get(H.label) ?? [];
1571
+ j.push(H), I.set(H.label, j);
1434
1572
  }
1435
- return Array.from(U.entries()).map(([z, V]) => {
1436
- var st, it;
1437
- const pe = ((st = V[0]) == null ? void 0 : st.color) ?? null, Se = V.some((X) => X.id === O), at = (X) => pe ? X ? { backgroundColor: pe, borderColor: pe } : { borderColor: pe, color: pe } : void 0;
1438
- if (V.length === 1) {
1439
- const X = V[0], ge = s.isPending && ((it = s.variables) == null ? void 0 : it.transition_id) === X.id;
1440
- return /* @__PURE__ */ r(
1441
- G,
1573
+ return Array.from(I.entries()).map(([H, j]) => {
1574
+ var mt, pt;
1575
+ const ge = ((mt = j[0]) == null ? void 0 : mt.color) ?? null, Re = j.some((W) => W.id === B), ut = (W) => ge ? W ? { backgroundColor: ge, borderColor: ge } : { borderColor: ge, color: ge } : void 0;
1576
+ if (j.length === 1) {
1577
+ const W = j[0], ve = y.isPending && ((pt = y.variables) == null ? void 0 : pt.transition_id) === W.id;
1578
+ return /* @__PURE__ */ s(
1579
+ Y,
1442
1580
  {
1443
1581
  size: "sm",
1444
- variant: Se ? "default" : "outline",
1445
- className: `${q ? "h-7 text-[11px]" : "text-[12px]"} gap-1.5`,
1446
- style: at(Se),
1447
- disabled: s.isPending || E,
1448
- onClick: () => I(X.id),
1582
+ variant: Re ? "default" : "outline",
1583
+ className: `${q ? "h-7 text-[11px]" : "text-[12px]"} gap-1.5 data-[fresh=true]:opacity-60`,
1584
+ style: ut(Re),
1585
+ disabled: y.isPending || Z,
1586
+ "aria-disabled": le.dimmed(W.id) || void 0,
1587
+ "data-fresh": le.dimmed(W.id) || void 0,
1588
+ ...le.bind(W.id),
1589
+ onClick: () => {
1590
+ le.press(W.id) && X(W.id);
1591
+ },
1449
1592
  children: [
1450
- ge && /* @__PURE__ */ e(ae, { className: "h-3 w-3 animate-spin" }),
1451
- z
1593
+ ve && /* @__PURE__ */ n(se, { className: "h-3 w-3 animate-spin" }),
1594
+ H
1452
1595
  ]
1453
1596
  },
1454
- z
1597
+ H
1455
1598
  );
1456
1599
  }
1457
- return /* @__PURE__ */ r(Le, { children: [
1458
- /* @__PURE__ */ e(Me, { asChild: !0, children: /* @__PURE__ */ r(
1459
- G,
1600
+ return /* @__PURE__ */ s(Qe, { children: [
1601
+ /* @__PURE__ */ n(ze, { asChild: !0, children: /* @__PURE__ */ s(
1602
+ Y,
1460
1603
  {
1461
1604
  size: "sm",
1462
- variant: Se ? "default" : "outline",
1605
+ variant: Re ? "default" : "outline",
1463
1606
  className: `${q ? "h-7 text-[11px]" : "text-[12px]"} gap-1.5`,
1464
- style: at(Se),
1465
- disabled: s.isPending || E,
1607
+ style: ut(Re),
1608
+ disabled: y.isPending || Z,
1466
1609
  children: [
1467
- z,
1468
- /* @__PURE__ */ e(fe, { className: "h-3 w-3" })
1610
+ H,
1611
+ /* @__PURE__ */ n(xe, { className: "h-3 w-3" })
1469
1612
  ]
1470
1613
  }
1471
1614
  ) }),
1472
- /* @__PURE__ */ e(Ue, { align: "start", children: [...V].sort(
1473
- (X, ge) => {
1474
- var lt, ot;
1475
- return (((lt = _e.get(X.to_state)) == null ? void 0 : lt.sort) ?? 999) - (((ot = _e.get(ge.to_state)) == null ? void 0 : ot.sort) ?? 999);
1615
+ /* @__PURE__ */ n(We, { align: "start", children: [...j].sort(
1616
+ (W, ve) => {
1617
+ var ft, ht;
1618
+ return (((ft = qe.get(W.to_state)) == null ? void 0 : ft.sort) ?? 999) - (((ht = qe.get(ve.to_state)) == null ? void 0 : ht.sort) ?? 999);
1476
1619
  }
1477
- ).map((X) => {
1478
- var ge;
1479
- return /* @__PURE__ */ r(Ce, { onSelect: () => I(X.id), children: [
1480
- X.color && /* @__PURE__ */ e(
1620
+ ).map((W) => {
1621
+ var ve;
1622
+ return /* @__PURE__ */ s(Pe, { onSelect: () => X(W.id), children: [
1623
+ W.color && /* @__PURE__ */ n(
1481
1624
  "span",
1482
1625
  {
1483
1626
  className: "mr-2 inline-block h-2 w-2 shrink-0 rounded-full",
1484
- style: { backgroundColor: X.color }
1627
+ style: { backgroundColor: W.color }
1485
1628
  }
1486
1629
  ),
1487
- ((ge = _e.get(X.to_state)) == null ? void 0 : ge.label) ?? X.to_state
1488
- ] }, X.id);
1630
+ ((ve = qe.get(W.to_state)) == null ? void 0 : ve.label) ?? W.to_state
1631
+ ] }, W.id);
1489
1632
  }) })
1490
- ] }, z);
1633
+ ] }, H);
1491
1634
  });
1492
- }, De = $ ? /* @__PURE__ */ e(
1493
- Ot,
1635
+ }, je = $ ? /* @__PURE__ */ n(
1636
+ Wt,
1494
1637
  {
1495
- collection: n,
1496
- item: String(t),
1638
+ collection: t,
1639
+ item: String(e),
1497
1640
  offer: $,
1498
- onDismiss: () => T(null),
1499
- onFixed: () => w({ transition_id: $.transitionId, comment: $.comment })
1641
+ onDismiss: () => R(null),
1642
+ onFixed: () => V({ transition_id: $.transitionId, comment: $.comment })
1500
1643
  }
1501
- ) : null, Ze = mn(ie ?? [], g == null ? void 0 : g.current_state, me ?? []), et = /* @__PURE__ */ r("div", { className: "space-y-3 rounded-lg border border-slate-200 bg-slate-50 dark:bg-slate-900/30 dark:border-border p-3.5", children: [
1502
- /* @__PURE__ */ r("div", { className: "flex flex-wrap items-center gap-2", children: [
1503
- /* @__PURE__ */ e("span", { className: "text-[11px] font-semibold text-slate-400", children: "Confirming" }),
1504
- le && /* @__PURE__ */ e("span", { className: "text-[12px] font-medium text-slate-700", children: le.label }),
1505
- xe && Pe && /* @__PURE__ */ r("div", { className: "ml-auto flex items-center gap-1.5", children: [
1506
- /* @__PURE__ */ e(ce, { label: xe.label, color: xe.color, small: !0 }),
1507
- /* @__PURE__ */ e(ze, { className: "h-3 w-3 shrink-0 text-slate-300" }),
1508
- /* @__PURE__ */ e(ce, { label: Pe.label, color: Pe.color, small: !0 })
1644
+ ) : null, it = Tn(de ?? [], k == null ? void 0 : k.current_state, be ?? []), lt = /* @__PURE__ */ s("div", { className: "space-y-3 rounded-lg border border-slate-200 bg-slate-50 dark:bg-slate-900/30 dark:border-border p-3.5", children: [
1645
+ /* @__PURE__ */ s("div", { className: "flex flex-wrap items-center gap-2", children: [
1646
+ /* @__PURE__ */ n("span", { className: "text-[11px] font-semibold text-slate-400", children: "Confirming" }),
1647
+ re && /* @__PURE__ */ n("span", { className: "text-[12px] font-medium text-slate-700", children: re.label }),
1648
+ we && Ue && /* @__PURE__ */ s("div", { className: "ml-auto flex items-center gap-1.5", children: [
1649
+ /* @__PURE__ */ n(pe, { label: we.label, color: we.color, small: !0 }),
1650
+ /* @__PURE__ */ n(Je, { className: "h-3 w-3 shrink-0 text-slate-300" }),
1651
+ /* @__PURE__ */ n(pe, { label: Ue.label, color: Ue.color, small: !0 })
1509
1652
  ] })
1510
1653
  ] }),
1511
- /* @__PURE__ */ e(Bt, { collection: n, item: t }),
1512
- /* @__PURE__ */ e(
1654
+ /* @__PURE__ */ n(Ht, { collection: t, item: e }),
1655
+ /* @__PURE__ */ n(Et, { lines: w }),
1656
+ /* @__PURE__ */ n(
1513
1657
  "input",
1514
1658
  {
1515
1659
  type: "text",
1516
- value: B,
1517
- onChange: (u) => M(u.target.value),
1518
- placeholder: String((le == null ? void 0 : le.comment_mode) ?? "") === "required" ? "Add a note (required)" : "Add a comment (optional)",
1660
+ value: M,
1661
+ onChange: (c) => U(c.target.value),
1662
+ placeholder: String((re == null ? void 0 : re.comment_mode) ?? "") === "required" ? "Add a note (required)" : "Add a comment (optional)",
1519
1663
  className: "w-full rounded-md border border-slate-200 bg-white px-3 py-1.5 text-[13px] placeholder-slate-400 focus:outline-none focus:ring-2 focus:ring-nvr-cyan/30"
1520
1664
  }
1521
1665
  ),
1522
- /* @__PURE__ */ r("div", { className: "flex items-center justify-end gap-2", children: [
1523
- /* @__PURE__ */ e(
1524
- G,
1666
+ /* @__PURE__ */ s("div", { className: "flex items-center justify-end gap-2", children: [
1667
+ /* @__PURE__ */ n(
1668
+ Y,
1525
1669
  {
1526
1670
  type: "button",
1527
1671
  size: "sm",
1528
1672
  variant: "ghost",
1529
1673
  className: "h-7 text-[12px]",
1530
- onClick: () => F(null),
1674
+ onClick: () => L(null),
1531
1675
  children: "Cancel"
1532
1676
  }
1533
1677
  ),
1534
- /* @__PURE__ */ e(
1535
- G,
1678
+ /* @__PURE__ */ n(
1679
+ Y,
1536
1680
  {
1537
1681
  type: "button",
1538
1682
  size: "sm",
1539
1683
  className: "h-7 gap-1.5 text-[12px]",
1540
- disabled: s.isPending || String((le == null ? void 0 : le.comment_mode) ?? "") === "required" && B.trim() === "",
1541
- onClick: () => w({
1542
- transition_id: O,
1543
- comment: B.trim() || void 0
1684
+ disabled: y.isPending || String((re == null ? void 0 : re.comment_mode) ?? "") === "required" && M.trim() === "",
1685
+ onClick: () => V({
1686
+ transition_id: B,
1687
+ comment: M.trim() || void 0
1544
1688
  }),
1545
- children: s.isPending ? /* @__PURE__ */ e(ae, { className: "h-3.5 w-3.5 animate-spin" }) : /* @__PURE__ */ r(ue, { children: [
1546
- /* @__PURE__ */ e("span", { children: "Confirm" }),
1547
- /* @__PURE__ */ e(Re, { className: "h-3 w-3" })
1689
+ children: y.isPending ? /* @__PURE__ */ n(se, { className: "h-3.5 w-3.5 animate-spin" }) : /* @__PURE__ */ s(fe, { children: [
1690
+ /* @__PURE__ */ n("span", { children: w.length > 0 && re ? `${re.label} anyway` : "Confirm" }),
1691
+ /* @__PURE__ */ n(Me, { className: "h-3 w-3" })
1548
1692
  ] })
1549
1693
  }
1550
1694
  )
1551
1695
  ] })
1552
1696
  ] });
1553
- return /* @__PURE__ */ r(ue, { children: [
1554
- /* @__PURE__ */ r(
1697
+ return /* @__PURE__ */ s(fe, { children: [
1698
+ /* @__PURE__ */ s(
1555
1699
  "div",
1556
1700
  {
1557
- className: `overflow-hidden rounded-xl border bg-white dark:bg-card ${R ? "border-amber-300 dark:border-amber-600/50" : "border-slate-200 dark:border-border"}`,
1701
+ className: `overflow-hidden rounded-xl border bg-white dark:bg-card ${D ? "border-amber-300 dark:border-amber-600/50" : "border-slate-200 dark:border-border"}`,
1558
1702
  children: [
1559
- /* @__PURE__ */ r(
1703
+ /* @__PURE__ */ s(
1560
1704
  "div",
1561
1705
  {
1562
1706
  role: "button",
1563
1707
  tabIndex: 0,
1564
- onClick: () => c((u) => !u),
1565
- onKeyDown: (u) => (u.key === "Enter" || u.key === " ") && c((q) => !q),
1708
+ onClick: () => u((c) => !c),
1709
+ onKeyDown: (c) => (c.key === "Enter" || c.key === " ") && u((q) => !q),
1566
1710
  className: "flex w-full cursor-pointer items-center gap-2.5 px-5 py-3.5 transition-colors hover:bg-slate-50/50 dark:hover:bg-white/[0.02]",
1567
1711
  children: [
1568
- /* @__PURE__ */ e(Oe, { className: "h-3.5 w-3.5 shrink-0 text-slate-400" }),
1569
- /* @__PURE__ */ e("span", { className: "text-[13px] font-medium text-slate-800 dark:text-slate-200", children: a || "Pipeline" }),
1570
- /* @__PURE__ */ r("div", { className: "flex items-center gap-1.5", children: [
1571
- R && /* @__PURE__ */ e("span", { className: "flex items-center gap-1 rounded-full border border-amber-200 bg-amber-50 px-2 py-0.5 text-[11px] font-medium text-amber-700 dark:border-amber-500/20 dark:bg-amber-500/10 dark:text-amber-400", children: "Addendum workflow" }),
1572
- xe && /* @__PURE__ */ e(ce, { label: xe.label, color: xe.color }),
1573
- (((tt = o == null ? void 0 : o.auto_held) == null ? void 0 : tt.length) ?? 0) > 0 && /* @__PURE__ */ r(
1712
+ /* @__PURE__ */ n(Ie, { className: "h-3.5 w-3.5 shrink-0 text-slate-400" }),
1713
+ /* @__PURE__ */ n("span", { className: "text-[13px] font-medium text-slate-800 dark:text-slate-200", children: r || "Pipeline" }),
1714
+ /* @__PURE__ */ s("div", { className: "flex items-center gap-1.5", children: [
1715
+ D && /* @__PURE__ */ n("span", { className: "flex items-center gap-1 rounded-full border border-amber-200 bg-amber-50 px-2 py-0.5 text-[11px] font-medium text-amber-700 dark:border-amber-500/20 dark:bg-amber-500/10 dark:text-amber-400", children: "Addendum workflow" }),
1716
+ we && /* @__PURE__ */ n(pe, { label: we.label, color: we.color }),
1717
+ (((ot = p == null ? void 0 : p.auto_held) == null ? void 0 : ot.length) ?? 0) > 0 && /* @__PURE__ */ s(
1574
1718
  "span",
1575
1719
  {
1576
1720
  className: "flex items-center gap-1 rounded-full border border-amber-200 bg-amber-50 px-2 py-0.5 text-[11px] font-medium text-amber-700 dark:border-amber-500/20 dark:bg-amber-500/10 dark:text-amber-400",
1577
- "data-tip": ((o == null ? void 0 : o.auto_held) ?? []).map((u) => `${u.transition_label ?? "Automatic move"}: ${u.error ?? "refused"}`).join(`
1721
+ "data-tip": ((p == null ? void 0 : p.auto_held) ?? []).map((c) => `${c.transition_label ?? "Automatic move"}: ${c.error ?? "refused"}`).join(`
1578
1722
  `),
1579
1723
  "data-pipeline-auto-held-pill": !0,
1580
1724
  children: [
1581
- /* @__PURE__ */ e(Lt, { className: "h-3 w-3 shrink-0" }),
1725
+ /* @__PURE__ */ n(Yt, { className: "h-3 w-3 shrink-0" }),
1582
1726
  "Needs a person"
1583
1727
  ]
1584
1728
  }
1585
1729
  ),
1586
- N && /* @__PURE__ */ r("span", { className: "flex items-center gap-1 rounded-full bg-amber-50 px-2 py-0.5 text-[11px] font-medium text-amber-700 border border-amber-200 dark:bg-amber-500/10 dark:text-amber-400 dark:border-amber-500/20", children: [
1587
- /* @__PURE__ */ e("span", { className: "h-1.5 w-1.5 rounded-full bg-amber-400 animate-pulse shrink-0" }),
1730
+ _ && /* @__PURE__ */ s("span", { className: "flex items-center gap-1 rounded-full bg-amber-50 px-2 py-0.5 text-[11px] font-medium text-amber-700 border border-amber-200 dark:bg-amber-500/10 dark:text-amber-400 dark:border-amber-500/20", children: [
1731
+ /* @__PURE__ */ n("span", { className: "h-1.5 w-1.5 rounded-full bg-amber-400 animate-pulse shrink-0" }),
1588
1732
  "Addendum in review"
1589
1733
  ] }),
1590
- L.length > 0 && /* @__PURE__ */ r(
1734
+ C.length > 0 && /* @__PURE__ */ s(
1591
1735
  "span",
1592
1736
  {
1593
1737
  className: "flex items-center gap-1 rounded-full border border-sky-200 bg-sky-50 px-2 py-0.5 text-[11px] font-medium text-sky-700 dark:border-sky-500/20 dark:bg-sky-500/10 dark:text-sky-300",
1594
1738
  "data-pipeline-approving": !0,
1595
1739
  children: [
1596
- /* @__PURE__ */ e("span", { className: "h-1.5 w-1.5 shrink-0 animate-pulse rounded-full bg-sky-400" }),
1597
- Ht(L, "approving")
1740
+ /* @__PURE__ */ n("span", { className: "h-1.5 w-1.5 shrink-0 animate-pulse rounded-full bg-sky-400" }),
1741
+ ln(C, "approving")
1598
1742
  ]
1599
1743
  }
1600
1744
  )
1601
1745
  ] }),
1602
- /* @__PURE__ */ r("div", { className: "ml-auto flex items-center gap-2", onClick: (u) => u.stopPropagation(), children: [
1603
- !A && Ye && !d && /* @__PURE__ */ e("div", { className: "flex flex-wrap items-center gap-1.5", children: Je(Ae, !0) }),
1604
- !A && !g && (o == null ? void 0 : o.binding) && /* @__PURE__ */ r(
1605
- G,
1746
+ /* @__PURE__ */ s("div", { className: "ml-auto flex items-center gap-2", onClick: (c) => c.stopPropagation(), children: [
1747
+ !A && at && !o && /* @__PURE__ */ n("div", { className: "flex flex-wrap items-center gap-1.5", children: st(Le, !0) }),
1748
+ !A && !k && (p == null ? void 0 : p.binding) && /* @__PURE__ */ s(
1749
+ Y,
1606
1750
  {
1607
1751
  size: "sm",
1608
1752
  variant: "outline",
1609
1753
  className: "h-7 gap-1.5 text-[11px]",
1610
- onClick: (u) => {
1611
- u.stopPropagation(), P.mutate();
1754
+ onClick: (c) => {
1755
+ c.stopPropagation(), T.mutate();
1612
1756
  },
1613
- disabled: P.isPending,
1757
+ disabled: T.isPending,
1614
1758
  children: [
1615
- P.isPending ? /* @__PURE__ */ e(ae, { className: "h-3 w-3 animate-spin" }) : /* @__PURE__ */ e(Oe, { className: "h-3 w-3" }),
1759
+ T.isPending ? /* @__PURE__ */ n(se, { className: "h-3 w-3 animate-spin" }) : /* @__PURE__ */ n(Ie, { className: "h-3 w-3" }),
1616
1760
  "Start"
1617
1761
  ]
1618
1762
  }
1619
1763
  ),
1620
- p && ((o == null ? void 0 : o.binding) || (o == null ? void 0 : o.instance)) && /* @__PURE__ */ e(
1621
- yn,
1764
+ l && ((p == null ? void 0 : p.binding) || (p == null ? void 0 : p.instance)) && /* @__PURE__ */ n(
1765
+ Bn,
1622
1766
  {
1623
- collection: n,
1624
- item: t,
1625
- states: me ?? [],
1626
- currentStateId: ((nt = o == null ? void 0 : o.instance) == null ? void 0 : nt.current_state) ?? null
1767
+ collection: t,
1768
+ item: e,
1769
+ states: be ?? [],
1770
+ currentStateId: ((dt = p == null ? void 0 : p.instance) == null ? void 0 : dt.current_state) ?? null
1627
1771
  }
1628
1772
  )
1629
1773
  ] }),
1630
- /* @__PURE__ */ e(
1631
- fe,
1774
+ /* @__PURE__ */ n(
1775
+ xe,
1632
1776
  {
1633
- className: we(
1777
+ className: _e(
1634
1778
  "h-3.5 w-3.5 shrink-0 text-slate-400 transition-transform duration-150",
1635
1779
  A && "rotate-180"
1636
1780
  )
@@ -1639,114 +1783,114 @@ function wn({
1639
1783
  ]
1640
1784
  }
1641
1785
  ),
1642
- !A && O && /* @__PURE__ */ e("div", { className: "border-t border-slate-100 dark:border-border/60 px-4 py-3", children: et }),
1643
- !A && De && /* @__PURE__ */ e("div", { className: "border-t border-slate-100 dark:border-border/60 px-4 py-3", children: De }),
1644
- Ze && !(g != null && g.completed_at) && /* @__PURE__ */ e(pn, { entry: Ze }),
1645
- A && /* @__PURE__ */ r("div", { className: "border-t border-slate-100 dark:border-border/60", children: [
1646
- /* @__PURE__ */ e(on, { held: (o == null ? void 0 : o.auto_held) ?? [] }),
1647
- N && /* @__PURE__ */ r("div", { className: "flex items-center gap-2 border-b border-amber-100 bg-amber-50 px-5 py-2.5 dark:border-amber-500/20 dark:bg-amber-500/10", children: [
1648
- /* @__PURE__ */ e("span", { className: "h-1.5 w-1.5 rounded-full bg-amber-400 shrink-0" }),
1649
- /* @__PURE__ */ e("p", { className: "text-[12px] text-amber-700 dark:text-amber-400", children: "An addendum is in review — coordinate transitions carefully." })
1786
+ !A && B && /* @__PURE__ */ n("div", { className: "border-t border-slate-100 dark:border-border/60 px-4 py-3", children: lt }),
1787
+ !A && je && /* @__PURE__ */ n("div", { className: "border-t border-slate-100 dark:border-border/60 px-4 py-3", children: je }),
1788
+ it && !(k != null && k.completed_at) && /* @__PURE__ */ n(qn, { entry: it }),
1789
+ A && /* @__PURE__ */ s("div", { className: "border-t border-slate-100 dark:border-border/60", children: [
1790
+ /* @__PURE__ */ n(vn, { held: (p == null ? void 0 : p.auto_held) ?? [] }),
1791
+ _ && /* @__PURE__ */ s("div", { className: "flex items-center gap-2 border-b border-amber-100 bg-amber-50 px-5 py-2.5 dark:border-amber-500/20 dark:bg-amber-500/10", children: [
1792
+ /* @__PURE__ */ n("span", { className: "h-1.5 w-1.5 rounded-full bg-amber-400 shrink-0" }),
1793
+ /* @__PURE__ */ n("p", { className: "text-[12px] text-amber-700 dark:text-amber-400", children: "An addendum is in review — coordinate transitions carefully." })
1650
1794
  ] }),
1651
- g ? /* @__PURE__ */ r("div", { className: "divide-y divide-slate-100 dark:divide-border/60", children: [
1652
- (me ?? []).length > 1 && /* @__PURE__ */ r("div", { className: "space-y-3 px-5 py-4", children: [
1653
- m ? (
1795
+ k ? /* @__PURE__ */ s("div", { className: "divide-y divide-slate-100 dark:divide-border/60", children: [
1796
+ (be ?? []).length > 1 && /* @__PURE__ */ s("div", { className: "space-y-3 px-5 py-4", children: [
1797
+ a ? (
1654
1798
  // Path pruning arrives with the owners query — rendering
1655
1799
  // the UNPRUNED track first meant every state briefly
1656
1800
  // showed, then snapped into formation. Hold a same-height
1657
1801
  // placeholder until the real shape is known.
1658
- /* @__PURE__ */ r("div", { className: "flex h-[52px] items-center gap-2", children: [
1659
- [0, 1, 2, 3, 4].map((u) => /* @__PURE__ */ r("span", { className: "flex items-center gap-2", children: [
1660
- /* @__PURE__ */ e(oe, { className: "h-7 w-7 rounded-full" }),
1661
- u < 4 && /* @__PURE__ */ e(oe, { className: "h-0.5 w-10" })
1662
- ] }, u)),
1663
- /* @__PURE__ */ e(oe, { className: "ml-2 h-3 w-24" })
1802
+ /* @__PURE__ */ s("div", { className: "flex h-[52px] items-center gap-2", children: [
1803
+ [0, 1, 2, 3, 4].map((c) => /* @__PURE__ */ s("span", { className: "flex items-center gap-2", children: [
1804
+ /* @__PURE__ */ n(me, { className: "h-7 w-7 rounded-full" }),
1805
+ c < 4 && /* @__PURE__ */ n(me, { className: "h-0.5 w-10" })
1806
+ ] }, c)),
1807
+ /* @__PURE__ */ n(me, { className: "ml-2 h-3 w-24" })
1664
1808
  ] })
1665
- ) : /* @__PURE__ */ e(
1666
- hn,
1809
+ ) : /* @__PURE__ */ n(
1810
+ Pn,
1667
1811
  {
1668
- states: me,
1669
- allTransitions: (o == null ? void 0 : o.all_transitions) ?? [],
1670
- availableTransitions: Q ?? [],
1671
- currentStateId: g.current_state,
1672
- history: ie ?? [],
1673
- onPathIds: v,
1674
- skippedStates: C
1812
+ states: be,
1813
+ allTransitions: (p == null ? void 0 : p.all_transitions) ?? [],
1814
+ availableTransitions: ae ?? [],
1815
+ currentStateId: k.current_state,
1816
+ history: de ?? [],
1817
+ onPathIds: f,
1818
+ skippedStates: v
1675
1819
  }
1676
1820
  ),
1677
- (o == null ? void 0 : o.branches) && /* @__PURE__ */ e(rn, { data: o.branches }),
1678
- /* @__PURE__ */ e(
1679
- fn,
1821
+ (p == null ? void 0 : p.branches) && /* @__PURE__ */ n(gn, { data: p.branches }),
1822
+ /* @__PURE__ */ n(
1823
+ Rn,
1680
1824
  {
1681
- history: ie ?? [],
1682
- completedAt: g.completed_at
1825
+ history: de ?? [],
1826
+ completedAt: k.completed_at
1683
1827
  }
1684
1828
  )
1685
1829
  ] }),
1686
- /* @__PURE__ */ r("div", { className: "space-y-3 px-5 py-4", children: [
1687
- !g.completed_at && /* @__PURE__ */ e(an, { collection: n, itemId: String(t) }),
1688
- /* @__PURE__ */ e(
1689
- gn,
1830
+ /* @__PURE__ */ s("div", { className: "space-y-3 px-5 py-4", children: [
1831
+ !k.completed_at && /* @__PURE__ */ n(xn, { collection: t, itemId: String(e) }),
1832
+ /* @__PURE__ */ n(
1833
+ An,
1690
1834
  {
1691
- collection: n,
1692
- item: t,
1693
- states: me ?? [],
1694
- currentStateId: ((rt = o == null ? void 0 : o.instance) == null ? void 0 : rt.current_state) ?? null,
1695
- returned: ((o == null ? void 0 : o.history) ?? []).some(
1696
- (u) => {
1835
+ collection: t,
1836
+ item: e,
1837
+ states: be ?? [],
1838
+ currentStateId: ((ct = p == null ? void 0 : p.instance) == null ? void 0 : ct.current_state) ?? null,
1839
+ returned: ((p == null ? void 0 : p.history) ?? []).some(
1840
+ (c) => {
1697
1841
  var q;
1698
- return !!u.from_state && u.to_state === ((q = o == null ? void 0 : o.instance) == null ? void 0 : q.current_state);
1842
+ return !!c.from_state && c.to_state === ((q = p == null ? void 0 : p.instance) == null ? void 0 : q.current_state);
1699
1843
  }
1700
1844
  )
1701
1845
  }
1702
1846
  )
1703
1847
  ] }),
1704
- Ye && !f && /* @__PURE__ */ r("div", { className: "space-y-3 px-5 py-4", children: [
1705
- /* @__PURE__ */ e("div", { className: "flex flex-wrap justify-end gap-2", children: Je(Ae) }),
1706
- O && et,
1707
- De
1848
+ at && !m && /* @__PURE__ */ s("div", { className: "space-y-3 px-5 py-4", children: [
1849
+ /* @__PURE__ */ n("div", { className: "flex flex-wrap justify-end gap-2", children: st(Le) }),
1850
+ B && lt,
1851
+ je
1708
1852
  ] }),
1709
- /* @__PURE__ */ r("div", { className: "px-5 py-3", children: [
1710
- /* @__PURE__ */ r(
1853
+ /* @__PURE__ */ s("div", { className: "px-5 py-3", children: [
1854
+ /* @__PURE__ */ s(
1711
1855
  "button",
1712
1856
  {
1713
1857
  type: "button",
1714
1858
  className: "flex items-center gap-1.5 text-[12px] text-slate-400 transition-colors hover:text-slate-600",
1715
- onClick: () => S((u) => !u),
1859
+ onClick: () => F((c) => !c),
1716
1860
  children: [
1717
- /* @__PURE__ */ e(
1718
- fe,
1861
+ /* @__PURE__ */ n(
1862
+ xe,
1719
1863
  {
1720
- className: we(
1864
+ className: _e(
1721
1865
  "h-3.5 w-3.5 transition-transform duration-200",
1722
- j && "rotate-180"
1866
+ E && "rotate-180"
1723
1867
  )
1724
1868
  }
1725
1869
  ),
1726
1870
  "Transition history",
1727
1871
  " ",
1728
- /* @__PURE__ */ r("span", { className: "tabular-nums", children: [
1872
+ /* @__PURE__ */ s("span", { className: "tabular-nums", children: [
1729
1873
  "(",
1730
- (ie == null ? void 0 : ie.length) ?? 0,
1874
+ (de == null ? void 0 : de.length) ?? 0,
1731
1875
  ")"
1732
1876
  ] })
1733
1877
  ]
1734
1878
  }
1735
1879
  ),
1736
- j && /* @__PURE__ */ e("div", { className: "mt-3", children: /* @__PURE__ */ e(bn, { history: ie ?? [] }) })
1880
+ E && /* @__PURE__ */ n("div", { className: "mt-3", children: /* @__PURE__ */ n(Dn, { history: de ?? [] }) })
1737
1881
  ] })
1738
- ] }) : /* @__PURE__ */ r("div", { className: "flex items-center justify-between gap-4 px-5 py-4", children: [
1739
- /* @__PURE__ */ e("p", { className: "text-[13px] text-slate-500", children: "Pipeline not started for this record." }),
1740
- /* @__PURE__ */ r(
1741
- G,
1882
+ ] }) : /* @__PURE__ */ s("div", { className: "flex items-center justify-between gap-4 px-5 py-4", children: [
1883
+ /* @__PURE__ */ n("p", { className: "text-[13px] text-slate-500", children: "Pipeline not started for this record." }),
1884
+ /* @__PURE__ */ s(
1885
+ Y,
1742
1886
  {
1743
1887
  size: "sm",
1744
1888
  variant: "outline",
1745
1889
  className: "shrink-0 gap-1.5 text-[12px]",
1746
- onClick: () => P.mutate(),
1747
- disabled: P.isPending,
1890
+ onClick: () => T.mutate(),
1891
+ disabled: T.isPending,
1748
1892
  children: [
1749
- P.isPending ? /* @__PURE__ */ e(ae, { className: "h-3.5 w-3.5 animate-spin" }) : /* @__PURE__ */ e(Oe, { className: "h-3.5 w-3.5" }),
1893
+ T.isPending ? /* @__PURE__ */ n(se, { className: "h-3.5 w-3.5 animate-spin" }) : /* @__PURE__ */ n(Ie, { className: "h-3.5 w-3.5" }),
1750
1894
  "Start Pipeline"
1751
1895
  ]
1752
1896
  }
@@ -1756,93 +1900,107 @@ function wn({
1756
1900
  ]
1757
1901
  }
1758
1902
  ),
1759
- _ && /* @__PURE__ */ e(xt, { fallback: null, children: /* @__PURE__ */ e(
1760
- _t,
1903
+ N && /* @__PURE__ */ n(_t, { fallback: null, children: /* @__PURE__ */ n(
1904
+ Dt,
1761
1905
  {
1762
- payload: _.payload,
1763
- transitionId: _.transitionId,
1764
- isRetry: _.revision > 1,
1906
+ payload: N.payload,
1907
+ transitionId: N.transitionId,
1908
+ isRetry: N.revision > 1,
1765
1909
  onSubmitted: () => (
1766
1910
  // mutateAsync so the dialog can stay busy until the transition
1767
1911
  // settles; the mutation's own onError/onSuccess handle the outcome.
1768
- s.mutateAsync({
1769
- transition_id: _.transitionId,
1770
- comment: _.comment,
1912
+ y.mutateAsync({
1913
+ transition_id: N.transitionId,
1914
+ comment: N.comment,
1771
1915
  reviewed: !0
1772
1916
  }).catch(() => {
1773
1917
  })
1774
1918
  ),
1775
- executing: s.isPending,
1776
- onClose: () => l(null)
1919
+ executing: y.isPending,
1920
+ onClose: () => d(null)
1777
1921
  },
1778
- _.revision
1922
+ N.revision
1779
1923
  ) })
1780
1924
  ] });
1781
1925
  }
1782
- function Yn({
1783
- collection: n,
1784
- item: t,
1926
+ function fr({
1927
+ collection: t,
1928
+ item: e,
1785
1929
  onBeforeTransition: i,
1786
- wrap: a = !0
1930
+ wrap: r = !0
1787
1931
  }) {
1788
- return t === "new" ? null : /* @__PURE__ */ e(
1789
- vn,
1932
+ return e === "new" ? null : /* @__PURE__ */ n(
1933
+ On,
1790
1934
  {
1791
- collection: n,
1792
- item: t,
1935
+ collection: t,
1936
+ item: e,
1793
1937
  onBeforeTransition: i,
1794
- wrap: a
1938
+ wrap: r
1795
1939
  }
1796
1940
  );
1797
1941
  }
1798
- function vn({
1799
- collection: n,
1800
- item: t,
1942
+ function On({
1943
+ collection: t,
1944
+ item: e,
1801
1945
  onBeforeTransition: i,
1802
- wrap: a = !0
1946
+ wrap: r = !0
1803
1947
  }) {
1804
- const p = be(), d = ke(), [f, y] = K(""), [N, R] = K(null), [b, x] = K(null), [k, B] = K(null);
1805
- yt(n, t, "transition", !!N || !!b);
1806
- const M = te(null), O = Jt(M, !a), F = te(!1), j = (m) => {
1807
- F.current || (F.current = !0, B(null), L.mutate(m, {
1808
- onSettled: (v, C) => {
1809
- if (C) {
1810
- F.current = !1;
1948
+ const l = he(), o = Se(), [m, h] = K(""), [_, D] = K(null), [g, x] = K(null), [S, M] = K(null), [U, B] = K([]), L = jt(t, String(e));
1949
+ $t(t, e, "transition", !!_ || !!g);
1950
+ const E = J(null), F = mn(E, !r), A = J(!1), u = (a) => {
1951
+ A.current || (A.current = !0, M(null), O.mutate(a, {
1952
+ onSettled: (f, v) => {
1953
+ if (v) {
1954
+ A.current = !1;
1811
1955
  return;
1812
1956
  }
1813
- _().finally(() => {
1814
- F.current = !1;
1957
+ R().finally(() => {
1958
+ A.current = !1;
1815
1959
  });
1816
1960
  }
1817
1961
  }));
1818
- }, S = async (m) => {
1819
- if (F.current) return;
1820
- if (N === m) {
1821
- R(null);
1962
+ }, N = async (a) => {
1963
+ var T;
1964
+ if (A.current) return;
1965
+ if (_ === a) {
1966
+ D(null);
1822
1967
  return;
1823
1968
  }
1824
1969
  if (i) {
1825
- F.current = !0;
1826
- let P = !1;
1970
+ A.current = !0;
1971
+ let y = !1;
1827
1972
  try {
1828
- P = await i();
1973
+ y = await i();
1829
1974
  } finally {
1830
- F.current = !1;
1975
+ A.current = !1;
1831
1976
  }
1832
- if (!P) return;
1977
+ if (!y) return;
1833
1978
  }
1834
- const v = (w ?? []).find((P) => P.id === m), C = String((v == null ? void 0 : v.comment_mode) ?? "none");
1835
- if (C !== "optional" && C !== "required") {
1836
- j({ transition_id: m });
1979
+ const f = (X ?? []).find((y) => y.id === a), v = String((f == null ? void 0 : f.comment_mode) ?? "none");
1980
+ if (v !== "optional" && v !== "required") {
1981
+ if (f && !Oe(f, (w == null ? void 0 : w.states) ?? [], (T = w == null ? void 0 : w.instance) == null ? void 0 : T.current_state)) {
1982
+ A.current = !0;
1983
+ let y = [];
1984
+ try {
1985
+ y = await L();
1986
+ } finally {
1987
+ A.current = !1;
1988
+ }
1989
+ if (y.length > 0) {
1990
+ B(y), D(a);
1991
+ return;
1992
+ }
1993
+ }
1994
+ u({ transition_id: a });
1837
1995
  return;
1838
1996
  }
1839
- R(m);
1840
- }, A = ["pipeline-instance", n, t], { settling: c, settle: _ } = Tt(A), { data: l } = ee({
1841
- queryKey: A,
1842
- queryFn: () => p.request(
1843
- se(`/pipelines/instance/${n}/${t}`)
1997
+ B([]), D(a);
1998
+ }, d = ["pipeline-instance", t, e], { settling: $, settle: R } = Mt(d), { data: w } = te({
1999
+ queryKey: d,
2000
+ queryFn: () => l.request(
2001
+ ie(`/pipelines/instance/${t}/${e}`)
1844
2002
  ).then(
1845
- (m) => m.data ?? {
2003
+ (a) => a.data ?? {
1846
2004
  instance: null,
1847
2005
  states: [],
1848
2006
  available_transitions: [],
@@ -1852,279 +2010,288 @@ function vn({
1852
2010
  }
1853
2011
  ),
1854
2012
  staleTime: 1e4
1855
- }), { data: $ } = ee({
1856
- queryKey: ["pipeline-all-owners", n, t],
1857
- queryFn: () => p.request(
1858
- se(`/pipelines/instance/${n}/${t}/owners/all`)
1859
- ).then((m) => m.data ?? null),
1860
- enabled: Rt(l),
2013
+ }), G = Ot(
2014
+ w ? (w.available_transitions ?? []).map((a) => String(a.id)) : null,
2015
+ `${t}:${e}`
2016
+ ), { data: b } = te({
2017
+ queryKey: ["pipeline-all-owners", t, e],
2018
+ queryFn: () => l.request(
2019
+ ie(`/pipelines/instance/${t}/${e}/owners/all`)
2020
+ ).then((a) => a.data ?? null),
2021
+ enabled: It(w),
1861
2022
  staleTime: 3e4
1862
- }), T = Fe(() => {
1863
- if (!$) return null;
1864
- const m = /* @__PURE__ */ new Map();
1865
- for (const [v, C] of Object.entries($))
1866
- C.skipped && m.set(v, C.skip_reasons ?? []);
1867
- return m;
1868
- }, [$]), L = ye({
2023
+ }), C = Fe(() => {
2024
+ if (!b) return null;
2025
+ const a = /* @__PURE__ */ new Map();
2026
+ for (const [f, v] of Object.entries(b))
2027
+ v.skipped && a.set(f, v.skip_reasons ?? []);
2028
+ return a;
2029
+ }, [b]), O = ke({
1869
2030
  mutationFn: ({
1870
- transition_id: m,
1871
- comment: v,
1872
- reviewed: C
1873
- }) => p.request(
1874
- he(`/pipelines/instance/${n}/${t}/transition`, {
1875
- transition_id: m,
1876
- comment: v,
1877
- ...C ? { reviewed: !0 } : {}
2031
+ transition_id: a,
2032
+ comment: f,
2033
+ reviewed: v
2034
+ }) => l.request(
2035
+ ye(`/pipelines/instance/${t}/${e}/transition`, {
2036
+ transition_id: a,
2037
+ comment: f,
2038
+ ...v ? { reviewed: !0 } : {}
1878
2039
  })
1879
2040
  ),
1880
- onSuccess: (m, v) => {
1881
- d.invalidateQueries({ queryKey: A }), n === "nivaro_addendums" && d.invalidateQueries({ queryKey: ["addendums"] }), qe(d, n, String(t)), Ne(d, n, String(t)), Dt(d, n, String(t)), B(null), y(""), R(null), x(null), Z.success(At(l, v.transition_id, m));
2041
+ onSuccess: (a, f) => {
2042
+ o.invalidateQueries({ queryKey: d }), t === "nivaro_addendums" && o.invalidateQueries({ queryKey: ["addendums"] }), Be(o, t, String(e)), Te(o, t, String(e)), zt(o, t, String(e)), M(null), h(""), D(null), x(null), ee.success(Qt(w, f.transition_id, a));
1882
2043
  },
1883
- onError: (m, v) => {
1884
- if (St(m)) {
1885
- d.invalidateQueries({ queryKey: A });
2044
+ onError: (a, f) => {
2045
+ if (Ft(a)) {
2046
+ o.invalidateQueries({ queryKey: d });
1886
2047
  return;
1887
2048
  }
1888
- const C = Ct(m);
1889
- if (C) {
1890
- x((s) => ({
1891
- payload: C,
1892
- transitionId: v.transition_id,
1893
- comment: v.comment,
1894
- revision: ((s == null ? void 0 : s.revision) ?? 0) + 1
2049
+ const v = At(a);
2050
+ if (v) {
2051
+ x((y) => ({
2052
+ payload: v,
2053
+ transitionId: f.transition_id,
2054
+ comment: f.comment,
2055
+ revision: ((y == null ? void 0 : y.revision) ?? 0) + 1
1895
2056
  }));
1896
2057
  return;
1897
2058
  }
1898
- const P = m == null ? void 0 : m.response;
1899
- B($t(m, v)), Z.error(ve(m, "Failed to execute transition"), {
2059
+ const T = a == null ? void 0 : a.response;
2060
+ M(Bt(a, f)), ee.error($e(a, "Failed to execute transition"), {
1900
2061
  duration: 12e3,
1901
2062
  // What to do next + Copy details (lib/error-toast.ts); "Why?" below wins the action slot.
1902
- ...gt(m, { action: "Transition" }),
2063
+ ...Ct(a, { action: "Transition" }),
1903
2064
  // #1867: a refusal carries "Why?" — the role, owner or access rule
1904
2065
  // that stopped it, and who can change it.
1905
- ...Nt(m) ? {
1906
- action: kt(p, {
1907
- collection: n,
1908
- itemId: String(t),
2066
+ ...Rt(a) ? {
2067
+ action: Pt(l, {
2068
+ collection: t,
2069
+ itemId: String(e),
1909
2070
  action: "transition",
1910
- transitionId: v.transition_id
2071
+ transitionId: f.transition_id
1911
2072
  })
1912
2073
  } : {}
1913
- }), x(null), R(null), qe(d, n, String(t)), Ne(d, n, String(t)), (P == null ? void 0 : P.status) === 409 && d.invalidateQueries({ queryKey: A });
2074
+ }), x(null), D(null), Be(o, t, String(e)), Te(o, t, String(e)), (T == null ? void 0 : T.status) === 409 && o.invalidateQueries({ queryKey: d });
1914
2075
  }
1915
- }), Y = te(S);
1916
- Y.current = S;
1917
- const h = te((l == null ? void 0 : l.available_transitions) ?? []);
1918
- if (h.current = (l == null ? void 0 : l.available_transitions) ?? [], de(() => {
1919
- const m = (v) => {
1920
- const C = v.detail;
1921
- if (!C || C.claimed || C.collection !== n || String(C.item) !== String(t)) return;
1922
- C.claimed = !0;
1923
- const P = String(C.transition_id).toUpperCase(), s = h.current.find((D) => String(D.id).toUpperCase() === P);
1924
- if (!s) {
1925
- Z.error("That step is not available from where the record is now");
2076
+ }), Q = J(N);
2077
+ Q.current = N;
2078
+ const V = J((w == null ? void 0 : w.available_transitions) ?? []);
2079
+ if (V.current = (w == null ? void 0 : w.available_transitions) ?? [], ue(() => {
2080
+ const a = (f) => {
2081
+ const v = f.detail;
2082
+ if (!v || v.claimed || v.collection !== t || String(v.item) !== String(e)) return;
2083
+ v.claimed = !0;
2084
+ const T = String(v.transition_id).toUpperCase(), y = V.current.find((oe) => String(oe.id).toUpperCase() === T);
2085
+ if (!y) {
2086
+ ee.error("That step is not available from where the record is now");
1926
2087
  return;
1927
2088
  }
1928
- Y.current(s.id);
2089
+ Q.current(y.id);
1929
2090
  };
1930
- return window.addEventListener(Te, m), () => window.removeEventListener(Te, m);
1931
- }, [n, t]), !(l != null && l.binding) || !(l != null && l.instance)) return null;
1932
- const w = Pt(
1933
- (l.available_transitions ?? []).filter(
1934
- (m) => !l.instance.completed_at || m.from_state && String(m.from_state).toUpperCase() === String(l.instance.current_state).toUpperCase()
2091
+ return window.addEventListener(Ae, a), () => window.removeEventListener(Ae, a);
2092
+ }, [t, e]), !(w != null && w.binding) || !(w != null && w.instance)) return null;
2093
+ const X = Kt(
2094
+ (w.available_transitions ?? []).filter(
2095
+ (a) => !w.instance.completed_at || a.from_state && String(a.from_state).toUpperCase() === String(w.instance.current_state).toUpperCase()
1935
2096
  ),
1936
- l.states ?? [],
1937
- l.instance.current_state,
1938
- l.instance.completed_at ? null : T
2097
+ w.states ?? [],
2098
+ w.instance.current_state,
2099
+ w.instance.completed_at ? null : C
1939
2100
  );
1940
- if (w.length === 0) return null;
1941
- const I = new Map((l.states ?? []).map((m) => [m.id, m])), W = l.instance.current_state_obj ?? null, E = N ? w.find((m) => m.id === N) : null, re = E ? I.get(E.to_state) : null, o = /* @__PURE__ */ new Map();
1942
- for (const m of w) {
1943
- const v = o.get(m.label) ?? [];
1944
- v.push(m), o.set(m.label, v);
2101
+ if (X.length === 0) return null;
2102
+ const P = new Map((w.states ?? []).map((a) => [a.id, a])), Z = w.instance.current_state_obj ?? null, z = _ ? X.find((a) => a.id === _) : null, p = z ? P.get(z.to_state) : null, ce = /* @__PURE__ */ new Map();
2103
+ for (const a of X) {
2104
+ const f = ce.get(a.label) ?? [];
2105
+ f.push(a), ce.set(a.label, f);
1945
2106
  }
1946
- const ne = (m) => [...m].sort(
1947
- (v, C) => {
1948
- var P, s;
1949
- return (((P = I.get(v.to_state)) == null ? void 0 : P.sort) ?? 999) - (((s = I.get(C.to_state)) == null ? void 0 : s.sort) ?? 999);
2107
+ const le = (a) => [...a].sort(
2108
+ (f, v) => {
2109
+ var T, y;
2110
+ return (((T = P.get(f.to_state)) == null ? void 0 : T.sort) ?? 999) - (((y = P.get(v.to_state)) == null ? void 0 : y.sort) ?? 999);
1950
2111
  }
1951
- ), J = (() => {
1952
- var C, P, s;
1953
- const m = (C = M.current) == null ? void 0 : C.getBoundingClientRect();
1954
- if (!m) return 600;
1955
- const v = (s = (P = M.current) == null ? void 0 : P.closest('[role="dialog"]')) == null ? void 0 : s.getBoundingClientRect();
1956
- return Math.max(260, Math.min(600, m.right - ((v == null ? void 0 : v.left) ?? 0) - 12));
2112
+ ), ne = (() => {
2113
+ var v, T, y;
2114
+ const a = (v = E.current) == null ? void 0 : v.getBoundingClientRect();
2115
+ if (!a) return 600;
2116
+ const f = (y = (T = E.current) == null ? void 0 : T.closest('[role="dialog"]')) == null ? void 0 : y.getBoundingClientRect();
2117
+ return Math.max(260, Math.min(600, a.right - ((f == null ? void 0 : f.left) ?? 0) - 12));
1957
2118
  })();
1958
- return /* @__PURE__ */ r("div", { ref: M, className: "relative", children: [
1959
- O ? /* @__PURE__ */ r(Le, { children: [
1960
- /* @__PURE__ */ e(Me, { asChild: !0, children: /* @__PURE__ */ r(
1961
- G,
2119
+ return /* @__PURE__ */ s("div", { ref: E, className: "relative", children: [
2120
+ F ? /* @__PURE__ */ s(Qe, { children: [
2121
+ /* @__PURE__ */ n(ze, { asChild: !0, children: /* @__PURE__ */ s(
2122
+ Y,
1962
2123
  {
1963
2124
  size: "sm",
1964
2125
  variant: "outline",
1965
2126
  className: "shrink-0 gap-1.5 text-[12px]",
1966
- disabled: L.isPending || c,
2127
+ disabled: O.isPending || $,
1967
2128
  "data-transitions-folded": !0,
1968
2129
  children: [
1969
- L.isPending && /* @__PURE__ */ e(ae, { className: "h-3 w-3 animate-spin" }),
2130
+ O.isPending && /* @__PURE__ */ n(se, { className: "h-3 w-3 animate-spin" }),
1970
2131
  "Actions",
1971
- /* @__PURE__ */ e(fe, { className: "h-3 w-3" })
2132
+ /* @__PURE__ */ n(xe, { className: "h-3 w-3" })
1972
2133
  ]
1973
2134
  }
1974
2135
  ) }),
1975
- /* @__PURE__ */ e(Ue, { align: "end", className: "min-w-[200px]", children: Array.from(o.entries()).map(
1976
- ([m, v], C, P) => v.length === 1 ? /* @__PURE__ */ r(dt, { children: [
1977
- C > 0 && P[C - 1][1].length > 1 && /* @__PURE__ */ e(ct, {}),
1978
- /* @__PURE__ */ r(Ce, { onSelect: () => S(v[0].id), children: [
1979
- v[0].color && /* @__PURE__ */ e(
2136
+ /* @__PURE__ */ n(We, { align: "end", className: "min-w-[200px]", children: Array.from(ce.entries()).map(
2137
+ ([a, f], v, T) => f.length === 1 ? /* @__PURE__ */ s(bt, { children: [
2138
+ v > 0 && T[v - 1][1].length > 1 && /* @__PURE__ */ n(gt, {}),
2139
+ /* @__PURE__ */ s(Pe, { onSelect: () => N(f[0].id), children: [
2140
+ f[0].color && /* @__PURE__ */ n(
1980
2141
  "span",
1981
2142
  {
1982
2143
  className: "mr-2 inline-block h-2 w-2 shrink-0 rounded-full",
1983
- style: { backgroundColor: v[0].color }
2144
+ style: { backgroundColor: f[0].color }
1984
2145
  }
1985
2146
  ),
1986
- m
2147
+ a
1987
2148
  ] })
1988
- ] }, m) : /* @__PURE__ */ r(dt, { children: [
1989
- C > 0 && /* @__PURE__ */ e(ct, {}),
1990
- /* @__PURE__ */ e(tn, { className: "text-[11px] text-muted-foreground", children: m }),
1991
- ne(v).map((s) => {
1992
- var D;
1993
- return /* @__PURE__ */ r(Ce, { onSelect: () => S(s.id), children: [
1994
- s.color && /* @__PURE__ */ e(
2149
+ ] }, a) : /* @__PURE__ */ s(bt, { children: [
2150
+ v > 0 && /* @__PURE__ */ n(gt, {}),
2151
+ /* @__PURE__ */ n(hn, { className: "text-[11px] text-muted-foreground", children: a }),
2152
+ le(f).map((y) => {
2153
+ var oe;
2154
+ return /* @__PURE__ */ s(Pe, { onSelect: () => N(y.id), children: [
2155
+ y.color && /* @__PURE__ */ n(
1995
2156
  "span",
1996
2157
  {
1997
2158
  className: "mr-2 inline-block h-2 w-2 shrink-0 rounded-full",
1998
- style: { backgroundColor: s.color }
2159
+ style: { backgroundColor: y.color }
1999
2160
  }
2000
2161
  ),
2001
- ((D = I.get(s.to_state)) == null ? void 0 : D.label) ?? s.to_state
2002
- ] }, s.id);
2162
+ ((oe = P.get(y.to_state)) == null ? void 0 : oe.label) ?? y.to_state
2163
+ ] }, y.id);
2003
2164
  })
2004
- ] }, m)
2165
+ ] }, a)
2005
2166
  ) })
2006
- ] }) : /* @__PURE__ */ e(
2167
+ ] }) : /* @__PURE__ */ n(
2007
2168
  "div",
2008
2169
  {
2009
- className: a ? "flex flex-wrap justify-end gap-2" : "flex shrink-0 items-center justify-end gap-2",
2010
- children: Array.from(o.entries()).map(([m, v]) => {
2011
- var D, H;
2012
- const C = ((D = v[0]) == null ? void 0 : D.color) ?? null, P = v.some((g) => g.id === N), s = (g) => C ? g ? { backgroundColor: C, borderColor: C } : { borderColor: C, color: C } : void 0;
2013
- if (v.length === 1) {
2014
- const g = v[0], Q = L.isPending && ((H = L.variables) == null ? void 0 : H.transition_id) === g.id, ie = /* @__PURE__ */ r(
2015
- G,
2170
+ className: r ? "flex flex-wrap justify-end gap-2" : "flex shrink-0 items-center justify-end gap-2",
2171
+ children: Array.from(ce.entries()).map(([a, f]) => {
2172
+ var oe, Ce;
2173
+ const v = ((oe = f[0]) == null ? void 0 : oe.color) ?? null, T = f.some((k) => k.id === _), y = (k) => v ? k ? { backgroundColor: v, borderColor: v } : { borderColor: v, color: v } : void 0;
2174
+ if (f.length === 1) {
2175
+ const k = f[0], ae = O.isPending && ((Ce = O.variables) == null ? void 0 : Ce.transition_id) === k.id, de = /* @__PURE__ */ s(
2176
+ Y,
2016
2177
  {
2017
2178
  size: "sm",
2018
- variant: P ? "default" : "outline",
2019
- className: "gap-1.5 text-[12px]",
2020
- style: s(P),
2021
- disabled: L.isPending || c,
2022
- onClick: () => S(g.id),
2179
+ variant: T ? "default" : "outline",
2180
+ className: "gap-1.5 text-[12px] data-[fresh=true]:opacity-60",
2181
+ style: y(T),
2182
+ disabled: O.isPending || $,
2183
+ "aria-disabled": G.dimmed(k.id) || void 0,
2184
+ "data-fresh": G.dimmed(k.id) || void 0,
2185
+ ...G.bind(k.id),
2186
+ onClick: () => {
2187
+ G.press(k.id) && N(k.id);
2188
+ },
2023
2189
  children: [
2024
- Q && /* @__PURE__ */ e(ae, { className: "h-3 w-3 animate-spin" }),
2025
- m
2190
+ ae && /* @__PURE__ */ n(se, { className: "h-3 w-3 animate-spin" }),
2191
+ a
2026
2192
  ]
2027
2193
  },
2028
- m
2194
+ a
2029
2195
  );
2030
- return g.pushes && g.pushes > 0 ? /* @__PURE__ */ r("span", { className: "relative inline-flex", children: [
2031
- ie,
2032
- /* @__PURE__ */ e(
2033
- Yt,
2196
+ return k.pushes && k.pushes > 0 ? /* @__PURE__ */ s("span", { className: "relative inline-flex", children: [
2197
+ de,
2198
+ /* @__PURE__ */ n(
2199
+ un,
2034
2200
  {
2035
- collection: n,
2036
- itemId: t,
2037
- transitionId: g.id,
2038
- label: m,
2201
+ collection: t,
2202
+ itemId: e,
2203
+ transitionId: k.id,
2204
+ label: a,
2039
2205
  compact: !0
2040
2206
  }
2041
2207
  )
2042
- ] }, m) : ie;
2208
+ ] }, a) : de;
2043
2209
  }
2044
- return /* @__PURE__ */ r(Le, { children: [
2045
- /* @__PURE__ */ e(Me, { asChild: !0, children: /* @__PURE__ */ r(
2046
- G,
2210
+ return /* @__PURE__ */ s(Qe, { children: [
2211
+ /* @__PURE__ */ n(ze, { asChild: !0, children: /* @__PURE__ */ s(
2212
+ Y,
2047
2213
  {
2048
2214
  size: "sm",
2049
- variant: P ? "default" : "outline",
2215
+ variant: T ? "default" : "outline",
2050
2216
  className: "gap-1.5 text-[12px]",
2051
- style: s(P),
2052
- disabled: L.isPending || c,
2217
+ style: y(T),
2218
+ disabled: O.isPending || $,
2053
2219
  children: [
2054
- m,
2055
- /* @__PURE__ */ e(fe, { className: "h-3 w-3" })
2220
+ a,
2221
+ /* @__PURE__ */ n(xe, { className: "h-3 w-3" })
2056
2222
  ]
2057
2223
  }
2058
2224
  ) }),
2059
- /* @__PURE__ */ e(Ue, { align: "start", children: ne(v).map((g) => {
2060
- var Q;
2061
- return /* @__PURE__ */ r(Ce, { onSelect: () => S(g.id), children: [
2062
- g.color && /* @__PURE__ */ e(
2225
+ /* @__PURE__ */ n(We, { align: "start", children: le(f).map((k) => {
2226
+ var ae;
2227
+ return /* @__PURE__ */ s(Pe, { onSelect: () => N(k.id), children: [
2228
+ k.color && /* @__PURE__ */ n(
2063
2229
  "span",
2064
2230
  {
2065
2231
  className: "mr-2 inline-block h-2 w-2 shrink-0 rounded-full",
2066
- style: { backgroundColor: g.color }
2232
+ style: { backgroundColor: k.color }
2067
2233
  }
2068
2234
  ),
2069
- ((Q = I.get(g.to_state)) == null ? void 0 : Q.label) ?? g.to_state
2070
- ] }, g.id);
2235
+ ((ae = P.get(k.to_state)) == null ? void 0 : ae.label) ?? k.to_state
2236
+ ] }, k.id);
2071
2237
  }) })
2072
- ] }, m);
2238
+ ] }, a);
2073
2239
  })
2074
2240
  }
2075
2241
  ),
2076
- N && /* @__PURE__ */ r(
2242
+ _ && /* @__PURE__ */ s(
2077
2243
  "div",
2078
2244
  {
2079
2245
  className: "absolute right-0 top-full z-50 mt-1 space-y-3 rounded-lg border border-slate-200 bg-white shadow-lg dark:bg-card dark:border-border p-3.5",
2080
- style: { width: J },
2246
+ style: { width: ne },
2081
2247
  children: [
2082
- /* @__PURE__ */ r("div", { className: "flex flex-wrap items-center gap-2", children: [
2083
- /* @__PURE__ */ e("span", { className: "text-[11px] font-semibold text-slate-400", children: "Confirming" }),
2084
- E && /* @__PURE__ */ e("span", { className: "text-[12px] font-medium text-slate-700", children: E.label }),
2085
- W && re && /* @__PURE__ */ r("div", { className: "ml-auto flex items-center gap-1.5", children: [
2086
- /* @__PURE__ */ e(ce, { label: W.label, color: W.color, small: !0 }),
2087
- /* @__PURE__ */ e(ze, { className: "h-3 w-3 shrink-0 text-slate-300" }),
2088
- /* @__PURE__ */ e(ce, { label: re.label, color: re.color, small: !0 })
2248
+ /* @__PURE__ */ s("div", { className: "flex flex-wrap items-center gap-2", children: [
2249
+ /* @__PURE__ */ n("span", { className: "text-[11px] font-semibold text-slate-400", children: "Confirming" }),
2250
+ z && /* @__PURE__ */ n("span", { className: "text-[12px] font-medium text-slate-700", children: z.label }),
2251
+ Z && p && /* @__PURE__ */ s("div", { className: "ml-auto flex items-center gap-1.5", children: [
2252
+ /* @__PURE__ */ n(pe, { label: Z.label, color: Z.color, small: !0 }),
2253
+ /* @__PURE__ */ n(Je, { className: "h-3 w-3 shrink-0 text-slate-300" }),
2254
+ /* @__PURE__ */ n(pe, { label: p.label, color: p.color, small: !0 })
2089
2255
  ] })
2090
2256
  ] }),
2091
- /* @__PURE__ */ e(Bt, { collection: n, item: t }),
2092
- /* @__PURE__ */ e(
2257
+ /* @__PURE__ */ n(Ht, { collection: t, item: e }),
2258
+ /* @__PURE__ */ n(Et, { lines: U }),
2259
+ /* @__PURE__ */ n(
2093
2260
  "input",
2094
2261
  {
2095
2262
  type: "text",
2096
- value: f,
2097
- onChange: (m) => y(m.target.value),
2098
- placeholder: String((E == null ? void 0 : E.comment_mode) ?? "") === "required" ? "Add a note (required)" : "Add a comment (optional)",
2263
+ value: m,
2264
+ onChange: (a) => h(a.target.value),
2265
+ placeholder: String((z == null ? void 0 : z.comment_mode) ?? "") === "required" ? "Add a note (required)" : "Add a comment (optional)",
2099
2266
  className: "w-full rounded-md border border-slate-200 bg-white px-3 py-1.5 text-[13px] placeholder-slate-400 focus:outline-none focus:ring-2 focus:ring-nvr-cyan/30"
2100
2267
  }
2101
2268
  ),
2102
- /* @__PURE__ */ r("div", { className: "flex items-center justify-end gap-2", children: [
2103
- /* @__PURE__ */ e(
2104
- G,
2269
+ /* @__PURE__ */ s("div", { className: "flex items-center justify-end gap-2", children: [
2270
+ /* @__PURE__ */ n(
2271
+ Y,
2105
2272
  {
2106
2273
  type: "button",
2107
2274
  size: "sm",
2108
2275
  variant: "ghost",
2109
2276
  className: "h-7 text-[12px]",
2110
- onClick: () => R(null),
2277
+ onClick: () => D(null),
2111
2278
  children: "Cancel"
2112
2279
  }
2113
2280
  ),
2114
- /* @__PURE__ */ e(
2115
- G,
2281
+ /* @__PURE__ */ n(
2282
+ Y,
2116
2283
  {
2117
2284
  type: "button",
2118
2285
  size: "sm",
2119
2286
  className: "h-7 gap-1.5 text-[12px]",
2120
- disabled: L.isPending || String((E == null ? void 0 : E.comment_mode) ?? "") === "required" && f.trim() === "",
2121
- onClick: () => j({
2122
- transition_id: N,
2123
- comment: f.trim() || void 0
2287
+ disabled: O.isPending || String((z == null ? void 0 : z.comment_mode) ?? "") === "required" && m.trim() === "",
2288
+ onClick: () => u({
2289
+ transition_id: _,
2290
+ comment: m.trim() || void 0
2124
2291
  }),
2125
- children: L.isPending ? /* @__PURE__ */ e(ae, { className: "h-3.5 w-3.5 animate-spin" }) : /* @__PURE__ */ r(ue, { children: [
2126
- /* @__PURE__ */ e("span", { children: "Confirm" }),
2127
- /* @__PURE__ */ e(Re, { className: "h-3 w-3" })
2292
+ children: O.isPending ? /* @__PURE__ */ n(se, { className: "h-3.5 w-3.5 animate-spin" }) : /* @__PURE__ */ s(fe, { children: [
2293
+ /* @__PURE__ */ n("span", { children: U.length > 0 && z ? `${z.label} anyway` : "Confirm" }),
2294
+ /* @__PURE__ */ n(Me, { className: "h-3 w-3" })
2128
2295
  ] })
2129
2296
  }
2130
2297
  )
@@ -2132,50 +2299,53 @@ function vn({
2132
2299
  ]
2133
2300
  }
2134
2301
  ),
2135
- k && !N && /* @__PURE__ */ e(
2136
- Ot,
2302
+ S && !_ && /* @__PURE__ */ n(
2303
+ Wt,
2137
2304
  {
2138
- collection: n,
2139
- item: String(t),
2140
- offer: k,
2305
+ collection: t,
2306
+ item: String(e),
2307
+ offer: S,
2141
2308
  className: "absolute right-0 top-full z-50 mt-1 shadow-lg",
2142
- style: { width: J },
2143
- onDismiss: () => B(null),
2144
- onFixed: () => j({ transition_id: k.transitionId, comment: k.comment })
2309
+ style: { width: ne },
2310
+ onDismiss: () => M(null),
2311
+ onFixed: () => u({ transition_id: S.transitionId, comment: S.comment })
2145
2312
  }
2146
2313
  ),
2147
- b && /* @__PURE__ */ e(xt, { fallback: null, children: /* @__PURE__ */ e(
2148
- _t,
2314
+ g && /* @__PURE__ */ n(_t, { fallback: null, children: /* @__PURE__ */ n(
2315
+ Dt,
2149
2316
  {
2150
- payload: b.payload,
2151
- transitionId: b.transitionId,
2152
- isRetry: b.revision > 1,
2317
+ payload: g.payload,
2318
+ transitionId: g.transitionId,
2319
+ isRetry: g.revision > 1,
2153
2320
  onSubmitted: () => (
2154
2321
  // mutateAsync so the dialog can stay busy until the transition
2155
2322
  // settles; the mutation's own onError/onSuccess handle the outcome.
2156
- L.mutateAsync({
2157
- transition_id: b.transitionId,
2158
- comment: b.comment,
2323
+ O.mutateAsync({
2324
+ transition_id: g.transitionId,
2325
+ comment: g.comment,
2159
2326
  reviewed: !0
2160
2327
  }).catch(() => {
2161
2328
  })
2162
2329
  ),
2163
- executing: L.isPending,
2330
+ executing: O.isPending,
2164
2331
  onClose: () => x(null)
2165
2332
  },
2166
- b.revision
2333
+ g.revision
2167
2334
  ) })
2168
2335
  ] });
2169
2336
  }
2170
2337
  export {
2171
- Gn as PipelinePanel,
2172
- Yn as PipelineTransitionButtons,
2173
- cn as REFUSAL_FIX_ACTIONS,
2174
- St as isDuplicateTransition,
2175
- mn as latestSendBack,
2176
- dn as refusalCode,
2177
- $t as refusalFixFor,
2178
- Ct as transitionRequirementsFromError,
2179
- At as transitionToastText,
2180
- Pt as withoutSkippedSendBacks
2338
+ Ne as FRESH_BUTTON_MS,
2339
+ Sn as FreshButtonGuard,
2340
+ pr as PipelinePanel,
2341
+ fr as PipelineTransitionButtons,
2342
+ kn as REFUSAL_FIX_ACTIONS,
2343
+ Cn as briefWarnings,
2344
+ Ft as isDuplicateTransition,
2345
+ Tn as latestSendBack,
2346
+ Nn as refusalCode,
2347
+ Bt as refusalFixFor,
2348
+ At as transitionRequirementsFromError,
2349
+ Qt as transitionToastText,
2350
+ Kt as withoutSkippedSendBacks
2181
2351
  };