@nivaro/react 0.3.98 → 0.3.100

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/dist/full.css +1 -1
  2. package/dist/hooks/useFormSchema.js +82 -85
  3. package/dist/hooks/useSessionRecorder.js +206 -175
  4. package/dist/index.d.ts +38 -13
  5. package/dist/index.js +182 -180
  6. package/dist/lib/commands.js +15 -11
  7. package/dist/shared/components/CollectionBrowserView.js +516 -503
  8. package/dist/shared/components/ItemEditForm.js +3021 -3019
  9. package/dist/shared/components/JobsTray.js +20 -16
  10. package/dist/shared/components/MyWorkView.js +133 -126
  11. package/dist/shared/components/NotificationBell.js +314 -288
  12. package/dist/shared/components/RecordCompare.js +38 -40
  13. package/dist/shared/components/RecordReadView.js +119 -119
  14. package/dist/shared/components/cbv/FoundElsewhere.js +61 -0
  15. package/dist/shared/components/item-edit/InlineGridField.js +45 -45
  16. package/dist/shared/components/item-edit/InlineTableField.js +750 -749
  17. package/dist/shared/components/item-edit/QuickPickerDialog.js +44 -44
  18. package/dist/shared/components/item-edit/RawEditSheet.js +122 -114
  19. package/dist/shared/components/item-edit/RelationCombobox.js +454 -378
  20. package/dist/shared/components/item-edit/SummaryPanel.js +56 -48
  21. package/dist/shared/components/item-edit/related-missing.js +75 -19
  22. package/dist/shared/components/notifications/NotificationCenterView.js +249 -226
  23. package/dist/shared/components/panels/AccessDeniedPanel.js +31 -28
  24. package/dist/shared/components/panels/BackgroundMove.js +175 -0
  25. package/dist/shared/components/panels/MoveAdvisory.js +204 -0
  26. package/dist/shared/components/panels/PipelinePanel.js +1450 -1219
  27. package/dist/shared/components/panels/RecordIntegrityBanner.js +113 -112
  28. package/dist/shared/lib/commands.js +18 -14
  29. package/dist/shared/lib/error-hints.js +1 -1
  30. package/dist/shared/lib/job-failure-text.js +12 -0
  31. package/dist/shared/lib/move-failure.js +9 -0
  32. package/dist/shared/lib/obligation-banner.js +15 -14
  33. package/dist/shared/lib/partner-failure.js +71 -0
  34. package/dist/shared/lib/prefetch.js +73 -73
  35. package/dist/shared/lib/replay-checkout.js +18 -13
  36. package/dist/shared/lib/replay-context.js +90 -77
  37. package/dist/shared/lib/replay-idle.js +21 -0
  38. package/dist/shared/lib/replay-socket.js +21 -17
  39. package/dist/shared/lib/rum.js +56 -51
  40. package/dist/shared/lib/safe-error.js +17 -13
  41. package/dist/shared/lib/stale-chunk.js +69 -26
  42. package/dist/shared/lib/system-collections.js +20 -0
  43. package/package.json +1 -1
@@ -1,47 +1,50 @@
1
- var yn = Object.defineProperty;
2
- var wn = (t, e, r) => e in t ? yn(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r;
3
- var Ve = (t, e, r) => wn(t, typeof e != "symbol" ? e + "" : e, r);
4
- import { jsx as n, jsxs as i, Fragment as xe } from "react/jsx-runtime";
5
- import { useQueryClient as De, useQuery as oe, useMutation as Pe } from "@tanstack/react-query";
6
- import { ArrowRight as lt, Loader2 as me, Check as We, GitBranch as Xe, AlertTriangle as vn, ChevronDown as $e, Send as Ft, Users as At, Undo2 as kn, Minus as Nn, UserPlus as _n, X as Ot, Zap as Ut, Search as Sn } from "lucide-react";
7
- import { useState as I, useRef as ne, useEffect as fe, useMemo as Ie, Suspense as Et, useCallback as Lt, lazy as Cn } from "react";
8
- import { toast as Y } from "sonner";
9
- import { useNivaroClient as we, useItemEditAuth as Bt } from "../../context.js";
10
- import { get as ce, post as Te, del as $n } from "../../lib/commands.js";
11
- import { errorToastOptions as jt, toastError as Tn } from "../../lib/error-toast.js";
12
- import { OPEN_MOVE_STATE_EVENT as Nt } from "../../lib/move-state.js";
13
- import { useRecordSignalWhile as It, useRecordSignalPeers as qn, signalSentence as Mn } from "../../lib/presence-signals.js";
14
- import { RUN_TRANSITION_EVENT as Ke } from "../../lib/run-transition.js";
15
- import { userErrorMessage as Fe } from "../../lib/safe-error.js";
16
- import { serverNow as Rn } from "../../lib/server-clock.js";
17
- import { userCardQuery as Pn } from "../../lib/user-cards.js";
18
- import { cn as ye, titleCase as Dn, toLocalDateString as Fn, formatRelative as ot, formatDateTime as _t, humanHours as An } from "../../lib/utils.js";
19
- import { PushReadinessChip as On } from "../integrations/RecordIntegrationPreview.js";
20
- import { useHeaderFold as Un } from "../item-edit/HeaderTools.js";
21
- import { invalidateRecordInsights as Qe, invalidateRecordData as Ae } from "../item-edit/RecordInsights.js";
22
- import { UserChip as Kt } from "../item-edit/UserChip.js";
23
- import { OwnerAvatars as En } from "../queue/OwnerAvatars.js";
24
- import { UserAvatar as Ln } from "../UserAvatar.js";
25
- import { Button as ae } from "../ui/button.js";
26
- import { DropdownMenu as Ze, DropdownMenuTrigger as et, DropdownMenuContent as tt, DropdownMenuGroup as St, DropdownMenuSeparator as Ct, DropdownMenuItem as Be, DropdownMenuLabel as Bn } from "../ui/dropdown-menu.js";
27
- import { Popover as dt, PopoverTrigger as ct, PopoverContent as ut } from "../ui/popover.js";
28
- import { Skeleton as ke } from "../ui/skeleton.js";
29
- import { TooltipProvider as Qt, Tooltip as nt, TooltipTrigger as rt, TooltipContent as at } from "../ui/tooltip.js";
30
- import { isAccessRefusal as Wt, deniedToastAction as zt, WhyOwnersButton as jn } from "./AccessInsights.js";
31
- import { BranchLanes as In } from "./BranchLanes.js";
32
- import { landingState as Kn, landingSkipGroups as Qn, joinLabels as $t } from "./landing-state.js";
33
- import { MoveToStatePanel as Wn } from "./MoveToStatePanel.js";
34
- import { SlaClockLine as zn } from "./SlaClock.js";
35
- const Ht = Cn(
1
+ var jn = Object.defineProperty;
2
+ var Qn = (t, e, r) => e in t ? jn(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r;
3
+ var it = (t, e, r) => Qn(t, typeof e != "symbol" ? e + "" : e, r);
4
+ import { jsx as n, jsxs as i, Fragment as Se } from "react/jsx-runtime";
5
+ import { useQueryClient as ze, useQuery as be, useMutation as je } from "@tanstack/react-query";
6
+ import { ArrowRight as wt, Loader2 as ve, Check as tt, GitBranch as ot, AlertTriangle as Vt, ChevronDown as Fe, Send as Xt, Users as Yt, Undo2 as Kn, Minus as Wn, UserPlus as zn, X as Jt, Zap as Zt, Search as Hn } from "lucide-react";
7
+ import { useState as Q, useRef as de, useEffect as _e, useMemo as Je, Suspense as en, useCallback as tn, lazy as Gn, Fragment as Vn } from "react";
8
+ import { toast as V } from "sonner";
9
+ import { useNivaroClient as Pe, useItemEditAuth as nn } from "../../context.js";
10
+ import { get as ye, post as We, del as Xn } from "../../lib/commands.js";
11
+ import { errorToastOptions as rn, toastError as Yn } from "../../lib/error-toast.js";
12
+ import { OPEN_MOVE_STATE_EVENT as Lt } from "../../lib/move-state.js";
13
+ import { useRecordSignalWhile as an, useRecordSignalPeers as Jn, signalSentence as Zn } from "../../lib/presence-signals.js";
14
+ import { RUN_TRANSITION_EVENT as Ze } from "../../lib/run-transition.js";
15
+ import { partnerMoveFailure as sn } from "../../lib/move-failure.js";
16
+ import { userErrorMessage as Ae } from "../../lib/safe-error.js";
17
+ import { serverNow as er } from "../../lib/server-clock.js";
18
+ import { userCardQuery as tr } from "../../lib/user-cards.js";
19
+ import { cn as ge, titleCase as nr, toLocalDateString as rr, formatRelative as kt, formatDateTime as Et, humanHours as ar } from "../../lib/utils.js";
20
+ import { PushReadinessChip as sr } from "../integrations/RecordIntegrationPreview.js";
21
+ import { useHeaderFold as ir } from "../item-edit/HeaderTools.js";
22
+ import { invalidateRecordInsights as Ee, invalidateRecordData as Ie } from "../item-edit/RecordInsights.js";
23
+ import { UserChip as on } from "../item-edit/UserChip.js";
24
+ import { OwnerAvatars as or } from "../queue/OwnerAvatars.js";
25
+ import { UserAvatar as lr } from "../UserAvatar.js";
26
+ import { Button as ue } from "../ui/button.js";
27
+ import { DropdownMenu as ct, DropdownMenuTrigger as ut, DropdownMenuContent as mt, DropdownMenuGroup as It, DropdownMenuSeparator as pt, DropdownMenuItem as Xe, DropdownMenuLabel as dr } from "../ui/dropdown-menu.js";
28
+ import { Popover as Nt, PopoverTrigger as _t, PopoverContent as St } from "../ui/popover.js";
29
+ import { Skeleton as Me } from "../ui/skeleton.js";
30
+ import { TooltipProvider as ln, Tooltip as ft, TooltipTrigger as ht, TooltipContent as bt } from "../ui/tooltip.js";
31
+ import { isAccessRefusal as dn, deniedToastAction as cn, WhyOwnersButton as cr } from "./AccessInsights.js";
32
+ import { runningMovePoll as un, useRunEnded as mn, startedInBackground as pn, pendingOptIn as fn, sameMoveId as gt, runningMoveTip as ur, RunningMoveNotice as mr, MoveProblemNotice as pr } from "./BackgroundMove.js";
33
+ import { BranchLanes as fr } from "./BranchLanes.js";
34
+ import { landingState as hr, landingSkipGroups as br, joinLabels as jt } from "./landing-state.js";
35
+ import { distinctAdvisories as hn, MoveAdvisoryNotice as bn, REFUSAL_FIX_ACTIONS as gr, useRecordFixAction as xr } from "./MoveAdvisory.js";
36
+ import { MoveToStatePanel as vr } from "./MoveToStatePanel.js";
37
+ import { SlaClockLine as yr } from "./SlaClock.js";
38
+ const gn = Gn(
36
39
  () => import("./TransitionRequirementsDialog.js").then((t) => ({
37
40
  default: t.TransitionRequirementsDialog
38
41
  }))
39
42
  );
40
- function mt(t, e) {
43
+ function Ct(t, e) {
41
44
  const r = t || "System";
42
45
  return e.on_behalf_of_name ? `${r}, for ${e.on_behalf_of_name}` : r;
43
46
  }
44
- function Hn(t) {
47
+ function wr(t) {
45
48
  if (t.transition) return null;
46
49
  const e = (t.comment ?? "").trim();
47
50
  if (!e.startsWith("{")) return null;
@@ -55,20 +58,20 @@ function Hn(t) {
55
58
  }
56
59
  return null;
57
60
  }
58
- function je(t) {
61
+ function Ye(t) {
59
62
  return !(t.first_name || t.last_name || t.user_email);
60
63
  }
61
- function st(t) {
64
+ function xt(t) {
62
65
  const e = (t.comment ?? "").trim().toLowerCase();
63
66
  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";
64
67
  }
65
- function it(t) {
68
+ function vt(t) {
66
69
  if (t.transition_text) return t.transition_text;
67
70
  if (t.transition_label) return `Rule: ${t.transition_label}`;
68
71
  const e = (t.comment ?? "").trim(), r = /^auto: (.+)$/i.exec(e);
69
72
  return r ? `Rule: ${r[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;
70
73
  }
71
- const Tt = {
74
+ const Qt = {
72
75
  validation: "the partner refused what we sent",
73
76
  not_found: "the partner could not find what we referred to",
74
77
  auth: "the partner refused our credentials",
@@ -76,18 +79,18 @@ const Tt = {
76
79
  rate_limited: "the partner asked us to slow down",
77
80
  unknown: "the partner refused it"
78
81
  };
79
- function Gn(t) {
80
- const e = Math.ceil((new Date(t).getTime() - Rn()) / 6e4);
82
+ function kr(t) {
83
+ const e = Math.ceil((new Date(t).getTime() - er()) / 6e4);
81
84
  return !Number.isFinite(e) || e <= 0 ? "on the next check" : e < 60 ? `in ${e} min` : `in ${Math.round(e / 60)}h`;
82
85
  }
83
- function Vn({ held: t }) {
86
+ function Nr({ held: t }) {
84
87
  return t.length === 0 ? null : /* @__PURE__ */ n(
85
88
  "div",
86
89
  {
87
90
  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",
88
91
  "data-pipeline-auto-held": !0,
89
92
  children: t.map((e) => {
90
- const r = e.transition_label ?? "An automatic move", s = Tt[e.error_class ?? "unknown"] ?? Tt.unknown;
93
+ const r = e.transition_label ?? "An automatic move", s = Qt[e.error_class ?? "unknown"] ?? Qt.unknown;
91
94
  return /* @__PURE__ */ i("div", { className: "text-[12px] text-amber-800 dark:text-amber-300", children: [
92
95
  /* @__PURE__ */ i("p", { className: "font-medium", children: [
93
96
  "Needs a person: ",
@@ -105,7 +108,7 @@ function Vn({ held: t }) {
105
108
  }
106
109
  ),
107
110
  /* @__PURE__ */ i("p", { className: "mt-1 text-[11px] text-amber-700 dark:text-amber-400", children: [
108
- e.retry_at ? `It tries the same push again ${Gn(e.retry_at)}. ` : "It will not send the same push again on its own. ",
111
+ e.retry_at ? `It tries the same push again ${kr(e.retry_at)}. ` : "It will not send the same push again on its own. ",
109
112
  "Fix the record so what it sends changes, retry the push, or move the record by hand.",
110
113
  e.attempts > 1 ? ` ${e.attempts} attempts so far.` : ""
111
114
  ] })
@@ -114,75 +117,70 @@ function Vn({ held: t }) {
114
117
  }
115
118
  );
116
119
  }
117
- function Gt(t) {
120
+ function xn(t) {
118
121
  var r;
119
122
  const e = t == null ? void 0 : t.response;
120
123
  return ((e == null ? void 0 : e.code) ?? ((r = e == null ? void 0 : e.data) == null ? void 0 : r.code)) === "TRANSITION_DUPLICATE";
121
124
  }
122
- function Vt(t) {
125
+ function vn(t) {
123
126
  var r;
124
127
  const e = t;
125
128
  return (e == null ? void 0 : e.status) === 422 && ((r = e.response) == null ? void 0 : r.error) === "TRANSITION_REQUIREMENTS" ? e.response.requirements ?? [] : null;
126
129
  }
127
- function Xt(t) {
130
+ function nt(t) {
128
131
  var s;
129
132
  const e = t == null ? void 0 : t.response, r = (e == null ? void 0 : e.code) ?? ((s = e == null ? void 0 : e.data) == null ? void 0 : s.code);
130
133
  return typeof r == "string" ? r : null;
131
134
  }
132
- function Yt(t) {
133
- if (Xt(t) !== "RECORD_LOCKED") return null;
135
+ function yn(t) {
136
+ if (nt(t) !== "RECORD_LOCKED") return null;
134
137
  const e = t == null ? void 0 : t.response, r = e != null && e.data && typeof e.data == "object" ? e.data : e;
135
138
  if ((r == null ? void 0 : r.move_anyway) !== !0) return null;
136
139
  const s = typeof r.locked_by_name == "string" ? r.locked_by_name : null;
137
140
  return { message: typeof r.error == "string" && r.error.trim() ? r.error : `${s ?? "Someone else"} is editing this record right now.`, holder: s };
138
141
  }
139
- const Xn = {
140
- PRIORITY_REQUIRED: "priority",
141
- // A held record does not move forward (efp-ops hold-gate, army 11): taking
142
- // the hold off is one deliberate, noted step, then the move is tried again.
143
- ON_HOLD: "remove-hold"
144
- };
145
- function Jt(t, e) {
146
- const r = Xt(t), s = r ? Xn[r] : void 0;
147
- return !r || !s ? null : { code: r, actionKey: s, transitionId: e.transition_id, comment: e.comment };
142
+ function wn(t, e) {
143
+ var m, h, p;
144
+ const r = nt(t), s = t == null ? void 0 : t.response, o = ((m = s == null ? void 0 : s.fix) == null ? void 0 : m.action) ?? ((p = (h = s == null ? void 0 : s.data) == null ? void 0 : h.fix) == null ? void 0 : p.action), c = typeof o == "string" && o.trim() || (r ? gr[r] : void 0);
145
+ return !r || !c ? null : { code: r, actionKey: c, transitionId: e.transition_id, comment: e.comment };
148
146
  }
149
- const Yn = 600;
150
- function Zt(t) {
151
- const e = De(), [r, s] = I(!1), l = ne(!0);
152
- fe(() => (l.current = !0, () => {
153
- l.current = !1;
147
+ const _r = 600;
148
+ function kn(t) {
149
+ const e = ze(), [r, s] = Q(!1), o = de(!0);
150
+ _e(() => (o.current = !0, () => {
151
+ o.current = !1;
154
152
  }), []);
155
- const c = ne(t);
153
+ const c = de(t);
156
154
  c.current = t;
157
- const p = Lt(async () => {
155
+ const m = tn(async () => {
158
156
  s(!0);
159
157
  try {
160
158
  await e.refetchQueries({ queryKey: [...c.current], type: "active" });
161
159
  } catch {
162
160
  }
163
- await new Promise((b) => setTimeout(b, Yn)), l.current && s(!1);
161
+ await new Promise((h) => setTimeout(h, _r)), o.current && s(!1);
164
162
  }, [e]);
165
- return { settling: r, settle: p };
163
+ return { settling: r, settle: m };
166
164
  }
167
- const Me = 1500, qt = 4e3;
168
- class Jn {
165
+ const Ue = 1500, Kt = 4e3;
166
+ class Sr {
169
167
  constructor() {
170
- Ve(this, "seen", null);
171
- Ve(this, "fresh", /* @__PURE__ */ new Map());
168
+ it(this, "seen", null);
169
+ it(this, "fresh", /* @__PURE__ */ new Map());
172
170
  }
173
171
  /** Feed the ids on offer now. */
174
172
  observe(e, r) {
175
- const s = new Set(e.map((l) => String(l).toUpperCase()));
173
+ const s = new Set(e.map((o) => String(o).toUpperCase()));
176
174
  if (this.seen)
177
- for (const l of s)
178
- this.seen.has(l) || this.fresh.set(l, { at: r, hovered: !1, left: !1 });
179
- for (const l of [...this.fresh.keys()]) s.has(l) || this.fresh.delete(l);
175
+ for (const o of s)
176
+ this.seen.has(o) || this.fresh.set(o, { at: r, hovered: !1, left: !1 });
177
+ for (const o of [...this.fresh.keys()]) s.has(o) || this.fresh.delete(o);
180
178
  this.seen = s;
181
179
  }
182
180
  /** The pointer is on the button. */
183
181
  enter(e, r) {
184
182
  const s = this.fresh.get(String(e).toUpperCase());
185
- s && !s.left && r - s.at < Me && (s.hovered = !0);
183
+ s && !s.left && r - s.at < Ue && (s.hovered = !0);
186
184
  }
187
185
  /** The pointer left the button. */
188
186
  leave(e) {
@@ -192,101 +190,101 @@ class Jn {
192
190
  /** Still inert (no state change)? */
193
191
  inert(e, r) {
194
192
  const s = this.fresh.get(String(e).toUpperCase());
195
- return !s || r - s.at >= qt ? !1 : r - s.at < Me || s.hovered && !s.left;
193
+ return !s || r - s.at >= Kt ? !1 : r - s.at < Ue || s.hovered && !s.left;
196
194
  }
197
195
  /** A press: true = let it through. A press inside the window counts as the pointer being there. */
198
196
  press(e, r) {
199
- const s = String(e).toUpperCase(), l = this.fresh.get(s);
200
- return l ? r - l.at < Me ? (l.hovered = !0, l.left = !1, !1) : l.hovered && !l.left && r - l.at < qt ? !1 : (this.fresh.delete(s), !0) : !0;
197
+ const s = String(e).toUpperCase(), o = this.fresh.get(s);
198
+ return o ? r - o.at < Ue ? (o.hovered = !0, o.left = !1, !1) : o.hovered && !o.left && r - o.at < Kt ? !1 : (this.fresh.delete(s), !0) : !0;
201
199
  }
202
200
  /** Inside its time window (drawn dimmed)? */
203
201
  timed(e, r) {
204
202
  const s = this.fresh.get(String(e).toUpperCase());
205
- return !!s && r - s.at < Me;
203
+ return !!s && r - s.at < Ue;
206
204
  }
207
205
  /** Any button still inside its time window? */
208
206
  hasTimed(e) {
209
- for (const r of this.fresh.values()) if (e - r.at < Me) return !0;
207
+ for (const r of this.fresh.values()) if (e - r.at < Ue) return !0;
210
208
  return !1;
211
209
  }
212
210
  reset() {
213
211
  this.seen = null, this.fresh.clear();
214
212
  }
215
213
  }
216
- function en(t, e) {
217
- const r = ne(null);
218
- r.current || (r.current = new Jn());
219
- const s = r.current, l = ne(e);
220
- l.current !== e && (l.current = e, s.reset());
221
- const [, c] = I(0), p = t ? t.join(",") : null;
222
- return Ie(() => {
214
+ function Nn(t, e) {
215
+ const r = de(null);
216
+ r.current || (r.current = new Sr());
217
+ const s = r.current, o = de(e);
218
+ o.current !== e && (o.current = e, s.reset());
219
+ const [, c] = Q(0), m = t ? t.join(",") : null;
220
+ return Je(() => {
223
221
  t && s.observe(t, Date.now());
224
- }, [s, p]), fe(() => {
222
+ }, [s, m]), _e(() => {
225
223
  if (!s.hasTimed(Date.now())) return;
226
- const b = setTimeout(() => c((f) => f + 1), Me + 20);
227
- return () => clearTimeout(b);
228
- }, [s, p]), {
229
- dimmed: (b) => s.timed(b, Date.now()),
230
- press: (b) => s.press(b, Date.now()),
231
- bind: (b) => ({
232
- onPointerEnter: () => s.enter(b, Date.now()),
233
- onPointerMove: () => s.enter(b, Date.now()),
234
- onPointerLeave: () => s.leave(b)
224
+ const h = setTimeout(() => c((p) => p + 1), Ue + 20);
225
+ return () => clearTimeout(h);
226
+ }, [s, m]), {
227
+ dimmed: (h) => s.timed(h, Date.now()),
228
+ press: (h) => s.press(h, Date.now()),
229
+ bind: (h) => ({
230
+ onPointerEnter: () => s.enter(h, Date.now()),
231
+ onPointerMove: () => s.enter(h, Date.now()),
232
+ onPointerLeave: () => s.leave(h)
235
233
  })
236
234
  };
237
235
  }
238
- function tn(t, e) {
236
+ function _n(t, e) {
239
237
  return ["approval-brief", t, String(e)];
240
238
  }
241
- function nn(t, e, r) {
239
+ function Sn(t, e, r) {
242
240
  return t.request(
243
- ce(`/pipelines/instance/${e}/${r}/approval-brief`)
241
+ ye(`/pipelines/instance/${e}/${r}/approval-brief`)
244
242
  ).then((s) => s.data);
245
243
  }
246
- function Zn(t) {
244
+ function Cr(t) {
247
245
  return (t ?? []).filter((e) => e.tone === "warn" || e.tone === "danger");
248
246
  }
249
- function Mt(t) {
247
+ function Wt(t) {
250
248
  return `${(t.label ?? "").trim().toLowerCase()}|${(t.text ?? "").trim().toLowerCase()}`;
251
249
  }
252
- function er(t) {
250
+ function $r(t) {
253
251
  const e = Math.max(0, Math.floor(Number(t) || 0));
254
252
  return e === 0 ? "today" : e === 1 ? "1 day ago" : `${e} days ago`;
255
253
  }
256
- function tr(t, e, r = 40) {
257
- const s = (_) => _ == null || _ === "" ? "" : String(_), l = s(t), c = s(e), p = (_) => _ === "" ? "(empty)" : _;
258
- if (t === void 0) return { old: null, new: Ye(p(c), 0, r) };
259
- if (l.length <= r && c.length <= r) return { old: p(l), new: p(c) };
260
- let b = 0;
261
- for (; b < l.length && b < c.length && l[b] === c[b]; ) b++;
262
- const f = b > r / 2 ? b - Math.floor(r / 3) : 0;
263
- return { old: Ye(p(l), f, r), new: Ye(p(c), f, r) };
254
+ function Tr(t, e, r = 40) {
255
+ const s = (x) => x == null || x === "" ? "" : String(x), o = s(t), c = s(e), m = (x) => x === "" ? "(empty)" : x;
256
+ if (t === void 0) return { old: null, new: lt(m(c), 0, r) };
257
+ if (o.length <= r && c.length <= r) return { old: m(o), new: m(c) };
258
+ let h = 0;
259
+ for (; h < o.length && h < c.length && o[h] === c[h]; ) h++;
260
+ const p = h > r / 2 ? h - Math.floor(r / 3) : 0;
261
+ return { old: lt(m(o), p, r), new: lt(m(c), p, r) };
264
262
  }
265
- function Ye(t, e, r) {
266
- const s = Math.min(e, Math.max(0, t.length - r)), l = t.slice(s, s + r);
267
- return `${s > 0 ? "…" : ""}${l}${s + r < t.length ? "…" : ""}`;
263
+ function lt(t, e, r) {
264
+ const s = Math.min(e, Math.max(0, t.length - r)), o = t.slice(s, s + r);
265
+ return `${s > 0 ? "…" : ""}${o}${s + r < t.length ? "…" : ""}`;
268
266
  }
269
- const nr = 4e3;
270
- function rn(t, e) {
271
- const r = we(), s = De();
272
- return Lt(async () => {
267
+ const qr = 4e3;
268
+ function Cn(t, e) {
269
+ const r = Pe(), s = ze();
270
+ return tn(async () => {
273
271
  try {
274
- const l = await Promise.race([
272
+ const o = await Promise.race([
275
273
  s.fetchQuery({
276
- queryKey: tn(t, e),
277
- queryFn: () => nn(r, t, e),
274
+ queryKey: _n(t, e),
275
+ queryFn: () => Sn(r, t, e),
278
276
  staleTime: 0,
279
277
  retry: !1
280
278
  }),
281
- new Promise((c) => setTimeout(() => c(null), nr))
279
+ new Promise((c) => setTimeout(() => c(null), qr))
282
280
  ]);
283
- return Zn(l == null ? void 0 : l.lines);
281
+ return Cr(o == null ? void 0 : o.lines);
284
282
  } catch {
285
283
  return [];
286
284
  }
287
285
  }, [r, s, t, e]);
288
286
  }
289
- function an({ lines: t }) {
287
+ function $n({ lines: t }) {
290
288
  return t.length === 0 ? null : /* @__PURE__ */ i(
291
289
  "div",
292
290
  {
@@ -302,22 +300,22 @@ function an({ lines: t }) {
302
300
  }
303
301
  );
304
302
  }
305
- function Oe(t, e, r) {
303
+ function He(t, e, r) {
306
304
  if (!r) return !1;
307
305
  const s = e.find(
308
306
  (c) => String(c.id).toUpperCase() === String(r).toUpperCase()
309
- ), l = e.find((c) => String(c.id).toUpperCase() === String(t.to_state).toUpperCase());
310
- return !!s && !!l && l.sort < s.sort;
307
+ ), o = e.find((c) => String(c.id).toUpperCase() === String(t.to_state).toUpperCase());
308
+ return !!s && !!o && o.sort < s.sort;
311
309
  }
312
- function sn(t, e, r) {
313
- var l;
310
+ function $t(t, e, r) {
311
+ var o;
314
312
  if (!t) return !1;
315
- if ((((l = t.order_partners) == null ? void 0 : l.length) ?? 0) > 0) return !0;
316
- if (Oe(t, e, r)) return !1;
313
+ if ((((o = t.order_partners) == null ? void 0 : o.length) ?? 0) > 0) return !0;
314
+ if (He(t, e, r)) return !1;
317
315
  const s = e.find((c) => String(c.id).toUpperCase() === String(t.to_state).toUpperCase());
318
316
  return !!(s != null && s.is_terminal) && !/(^|_)cancel/i.test(String(s.key ?? ""));
319
317
  }
320
- const Rt = {
318
+ const zt = {
321
319
  red: "border-red-200 bg-red-50 text-red-800 dark:border-red-500/30 dark:bg-red-500/10 dark:text-red-300",
322
320
  amber: "border-amber-200 bg-amber-50 text-amber-800 dark:border-amber-500/30 dark:bg-amber-500/10 dark:text-amber-300",
323
321
  yellow: "border-yellow-200 bg-yellow-50 text-yellow-800 dark:border-yellow-500/30 dark:bg-yellow-500/10 dark:text-yellow-300",
@@ -325,14 +323,14 @@ const Rt = {
325
323
  blue: "border-sky-200 bg-sky-50 text-sky-800 dark:border-sky-500/30 dark:bg-sky-500/10 dark:text-sky-300",
326
324
  purple: "border-violet-200 bg-violet-50 text-violet-800 dark:border-violet-500/30 dark:bg-violet-500/10 dark:text-violet-300"
327
325
  };
328
- function rr({ flags: t }) {
329
- return !t || t.length === 0 ? null : /* @__PURE__ */ n(xe, { children: t.map((e) => /* @__PURE__ */ i(
326
+ function Mr({ flags: t }) {
327
+ return !t || t.length === 0 ? null : /* @__PURE__ */ n(Se, { children: t.map((e) => /* @__PURE__ */ i(
330
328
  "span",
331
329
  {
332
330
  "data-record-flag": e.name,
333
- className: ye(
331
+ className: ge(
334
332
  "inline-flex shrink-0 items-center gap-1 self-center rounded-full border px-2 py-0.5 text-[11px] font-semibold",
335
- Rt[e.color] ?? Rt.amber
333
+ zt[e.color] ?? zt.amber
336
334
  ),
337
335
  children: [
338
336
  /* @__PURE__ */ n("span", { className: "h-1.5 w-1.5 rounded-full bg-current", "aria-hidden": !0 }),
@@ -342,77 +340,77 @@ function rr({ flags: t }) {
342
340
  e.name
343
341
  )) });
344
342
  }
345
- function Pt(t) {
343
+ function Ht(t) {
346
344
  return t.replace(/\s+IIP$/i, "");
347
345
  }
348
- function ln({
346
+ function Tn({
349
347
  collection: t,
350
348
  item: e,
351
349
  tx: r
352
350
  }) {
353
- const s = we(), l = (r == null ? void 0 : r.order_partners) ?? [], { data: c } = oe({
351
+ const s = Pe(), o = (r == null ? void 0 : r.order_partners) ?? [], { data: c } = be({
354
352
  queryKey: ["push-preflight", t, e, "t", (r == null ? void 0 : r.id) ?? ""],
355
353
  queryFn: () => s.request(
356
- ce(`/integration-preview/${t}/${encodeURIComponent(e)}/preflight`, {
354
+ ye(`/integration-preview/${t}/${encodeURIComponent(e)}/preflight`, {
357
355
  transition_id: (r == null ? void 0 : r.id) ?? ""
358
356
  })
359
- ).then((f) => f.data),
360
- enabled: l.length > 0 && !!(r != null && r.id),
357
+ ).then((p) => p.data),
358
+ enabled: o.length > 0 && !!(r != null && r.id),
361
359
  staleTime: 2e4
362
360
  });
363
- if (l.length === 0) return null;
364
- const p = c != null && c.pushes ? c.pushes.filter((f) => f.status === "would_push" && l.includes(f.api_name)).map((f) => Pt(f.api_name)) : null, b = [...new Set(p ?? l.map(Pt))];
361
+ if (o.length === 0) return null;
362
+ const m = c != null && c.pushes ? c.pushes.filter((p) => p.status === "would_push" && o.includes(p.api_name)).map((p) => Ht(p.api_name)) : null, h = [...new Set(m ?? o.map(Ht))];
365
363
  return /* @__PURE__ */ i(
366
364
  "p",
367
365
  {
368
366
  "data-order-send-note": !0,
369
367
  className: "flex items-start gap-1.5 rounded-md border border-sky-200 bg-sky-50 px-2.5 py-1.5 text-[12px] text-sky-900 dark:border-sky-500/30 dark:bg-sky-500/10 dark:text-sky-200",
370
368
  children: [
371
- /* @__PURE__ */ n(Ft, { className: "mt-0.5 h-3.5 w-3.5 shrink-0", "aria-hidden": !0 }),
372
- p && p.length === 0 ? "Nothing is sent to a partner for this record — it only moves the record on." : `This places an order with ${b.join(" or ")}. It cannot be called back from here.`
369
+ /* @__PURE__ */ n(Xt, { className: "mt-0.5 h-3.5 w-3.5 shrink-0", "aria-hidden": !0 }),
370
+ m && m.length === 0 ? "Nothing is sent to a partner for this record — it only moves the record on." : `This places an order with ${h.join(" or ")}. It cannot be called back from here.`
373
371
  ]
374
372
  }
375
373
  );
376
374
  }
377
- function on(t) {
375
+ function qn(t) {
378
376
  return t != null && t.instance ? (t.available_transitions ?? []).some(
379
377
  (e) => {
380
378
  var r;
381
- return Oe(e, t.states ?? [], (r = t.instance) == null ? void 0 : r.current_state);
379
+ return He(e, t.states ?? [], (r = t.instance) == null ? void 0 : r.current_state);
382
380
  }
383
381
  ) : !1;
384
382
  }
385
- function dn(t, e, r, s) {
383
+ function Mn(t, e, r, s) {
386
384
  if (!s || s.size === 0) return t;
387
- const l = new Set([...s.keys()].map((c) => String(c).toUpperCase()));
385
+ const o = new Set([...s.keys()].map((c) => String(c).toUpperCase()));
388
386
  return t.filter(
389
- (c) => !(!c.to_previous && l.has(String(c.to_state).toUpperCase()) && Oe(c, e, r))
387
+ (c) => !(!c.to_previous && o.has(String(c.to_state).toUpperCase()) && He(c, e, r))
390
388
  );
391
389
  }
392
- function cn(t, e, r) {
393
- var f, _, v, y, $, A;
390
+ function Rn(t, e, r) {
391
+ var p, x, k, R, _, U;
394
392
  const s = [...(t == null ? void 0 : t.available_transitions) ?? [], ...(t == null ? void 0 : t.all_transitions) ?? []].find(
395
- (E) => E.id === e
396
- ), l = r == null ? void 0 : r.data, c = ((f = l == null ? void 0 : l.new_state) == null ? void 0 : f.id) ?? ((_ = l == null ? void 0 : l.instance) == null ? void 0 : _.current_state) ?? null, p = ((v = l == null ? void 0 : l.new_state) == null ? void 0 : v.label) ?? (s ? ($ = (y = t == null ? void 0 : t.states) == null ? void 0 : y.find((E) => E.id === s.to_state)) == null ? void 0 : $.label : void 0) ?? null, b = ((A = t == null ? void 0 : t.instance) == null ? void 0 : A.current_state) ?? null;
397
- return b && c && String(b) === String(c) ? "Nothing moved" : s != null && s.label && p ? `${s.label} — now ${p}` : p ? `Moved to ${p}` : s != null && s.label ? `${s.label} done` : "Transition executed";
393
+ (j) => j.id === e
394
+ ), o = r == null ? void 0 : r.data, c = ((p = o == null ? void 0 : o.new_state) == null ? void 0 : p.id) ?? ((x = o == null ? void 0 : o.instance) == null ? void 0 : x.current_state) ?? null, m = ((k = o == null ? void 0 : o.new_state) == null ? void 0 : k.label) ?? (s ? (_ = (R = t == null ? void 0 : t.states) == null ? void 0 : R.find((j) => j.id === s.to_state)) == null ? void 0 : _.label : void 0) ?? null, h = ((U = t == null ? void 0 : t.instance) == null ? void 0 : U.current_state) ?? null;
395
+ return h && c && String(h) === String(c) ? "Nothing moved" : s != null && s.label && m ? `${s.label} — now ${m}` : m ? `Moved to ${m}` : s != null && s.label ? `${s.label} done` : "Transition executed";
398
396
  }
399
- const ar = 1200;
400
- function un(t) {
397
+ const Rr = 1200;
398
+ function Pn(t) {
401
399
  const e = `nvr-move-${Math.random().toString(36).slice(2)}`;
402
400
  let r = !1;
403
401
  const s = setTimeout(() => {
404
- r = !0, Y.loading(`${(t == null ? void 0 : t.trim()) || "Moving"}…`, { id: e });
405
- }, ar);
402
+ r = !0, V.loading(`${(t == null ? void 0 : t.trim()) || "Moving"}…`, { id: e });
403
+ }, Rr);
406
404
  return {
407
405
  /** Options for the result toast: replaces the loading one when shown. */
408
406
  done: () => (clearTimeout(s), r ? { id: e, duration: 7e3 } : {}),
409
407
  /** An error toast of its own follows — drop the loading one. */
410
408
  fail: () => {
411
- clearTimeout(s), r && Y.dismiss(e);
409
+ clearTimeout(s), r && V.dismiss(e);
412
410
  }
413
411
  };
414
412
  }
415
- function mn(t, e, r) {
413
+ function et(t, e, r) {
416
414
  for (const s of [
417
415
  "pipeline-owners-resolved",
418
416
  "pipeline-instance-owners",
@@ -420,17 +418,65 @@ function mn(t, e, r) {
420
418
  ])
421
419
  t.invalidateQueries({ queryKey: [s, e, r] });
422
420
  }
423
- function sr(t, e, r) {
424
- var b;
421
+ function Pr(t, e, r) {
422
+ var h;
425
423
  if (!e) return null;
426
- const s = new Map(r.map((f) => [String(f.id).toUpperCase(), f.sort])), l = [...t].sort(
427
- (f, _) => new Date(_.timestamp).getTime() - new Date(f.timestamp).getTime()
424
+ const s = new Map(r.map((p) => [String(p.id).toUpperCase(), p.sort])), o = [...t].sort(
425
+ (p, x) => new Date(x.timestamp).getTime() - new Date(p.timestamp).getTime()
428
426
  )[0];
429
- if (!(l != null && l.from_state) || String(l.to_state).toUpperCase() !== String(e).toUpperCase() || !((b = l.comment) != null && b.trim()) || l.origin && l.origin !== "person") return null;
430
- const c = s.get(String(l.from_state).toUpperCase()), p = s.get(String(l.to_state).toUpperCase());
431
- return c == null || p == null || p >= c ? null : l;
427
+ if (!(o != null && o.from_state) || String(o.to_state).toUpperCase() !== String(e).toUpperCase() || !((h = o.comment) != null && h.trim()) || o.origin && o.origin !== "person") return null;
428
+ const c = s.get(String(o.from_state).toUpperCase()), m = s.get(String(o.to_state).toUpperCase());
429
+ return c == null || m == null || m >= c ? null : o;
430
+ }
431
+ function Ne({ className: t }) {
432
+ return /* @__PURE__ */ n(
433
+ Vt,
434
+ {
435
+ "aria-hidden": !0,
436
+ "data-move-blocked-mark": !0,
437
+ className: ge("h-3 w-3 shrink-0 text-amber-600 dark:text-amber-400", t)
438
+ }
439
+ );
432
440
  }
433
- function ir({ entry: t }) {
441
+ function Be(t, e = "button") {
442
+ return t.advisory ? {
443
+ "data-move-blocked": t.advisory.code,
444
+ "aria-description": t.advisory.message,
445
+ ...e === "button" ? { "data-tip": t.advisory.message } : {}
446
+ } : {};
447
+ }
448
+ const Fn = "border-amber-300 text-slate-700 dark:border-amber-500/40 dark:text-slate-200";
449
+ function yt({
450
+ moves: t,
451
+ nameOf: e
452
+ }) {
453
+ const r = hn(t);
454
+ return r.map(({ advisory: s, moves: o }) => /* @__PURE__ */ i(Vn, { children: [
455
+ /* @__PURE__ */ n(pt, {}),
456
+ /* @__PURE__ */ i(
457
+ "div",
458
+ {
459
+ "data-move-blocked-note": s.code,
460
+ className: "flex max-w-[280px] items-start gap-2 px-2 py-1.5 text-[11px] leading-snug text-slate-600 dark:text-slate-300",
461
+ children: [
462
+ /* @__PURE__ */ n(Ne, { className: "mt-0.5" }),
463
+ /* @__PURE__ */ i("span", { className: "min-w-0", children: [
464
+ s.message,
465
+ r.length > 1 && /* @__PURE__ */ i("span", { className: "mt-0.5 block text-amber-800/80 dark:text-amber-300/80", children: [
466
+ "Stops: ",
467
+ [...new Set(o.map(e))].join(", ")
468
+ ] })
469
+ ] })
470
+ ]
471
+ }
472
+ )
473
+ ] }, `${s.code}:${s.message}`));
474
+ }
475
+ function An(t, e, r) {
476
+ const s = String(t.comment_mode ?? "none");
477
+ return s === "optional" || s === "required" || $t(t, e, r);
478
+ }
479
+ function Fr({ entry: t }) {
434
480
  const e = [t.first_name, t.last_name].filter(Boolean).join(" ") || t.user_email || "Someone";
435
481
  return /* @__PURE__ */ i(
436
482
  "div",
@@ -439,7 +485,7 @@ function ir({ entry: t }) {
439
485
  "data-send-back-notice": !0,
440
486
  children: [
441
487
  /* @__PURE__ */ n(
442
- kn,
488
+ Kn,
443
489
  {
444
490
  "aria-hidden": !0,
445
491
  className: "mt-[3px] h-3.5 w-3.5 shrink-0 text-amber-600 dark:text-amber-400"
@@ -449,65 +495,54 @@ function ir({ entry: t }) {
449
495
  /* @__PURE__ */ n("p", { className: "whitespace-pre-line break-words text-[13px] leading-snug text-slate-800 dark:text-slate-100", children: t.comment }),
450
496
  /* @__PURE__ */ i("p", { className: "mt-0.5 text-[11.5px] text-amber-800/80 dark:text-amber-300/80", children: [
451
497
  "Sent back by ",
452
- mt(e, t),
498
+ Ct(e, t),
453
499
  " · ",
454
- ot(t.timestamp)
500
+ kt(t.timestamp)
455
501
  ] })
456
502
  ] })
457
503
  ]
458
504
  }
459
505
  );
460
506
  }
461
- function pn({
507
+ function On({
462
508
  collection: t,
463
509
  item: e,
464
510
  offer: r,
465
511
  onFixed: s,
466
- onDismiss: l,
512
+ onDismiss: o,
467
513
  className: c,
468
- style: p
514
+ style: m
469
515
  }) {
470
- const b = we(), f = De(), [_, v] = I(""), { data: y, isLoading: $ } = oe({
471
- queryKey: ["bulk-actions-available-one", t, r.actionKey],
472
- queryFn: async () => ((await b.request(ce("/bulk-actions/available", { collection: t }))).data ?? []).find((H) => H.key === r.actionKey) ?? null,
473
- staleTime: 6e4
474
- }), A = Pe({
475
- mutationFn: async () => {
476
- var T, P;
477
- const B = { collection: t, ids: [e], reason: _.trim() || null }, K = ((y == null ? void 0 : y.source) === "extension" ? await b.request(Te(`/bulk-actions/${r.actionKey}/execute`, B)) : await b.request(Te("/bulk-actions/run", { ...B, key: r.actionKey }))).data ?? {};
478
- if ((y == null ? void 0 : y.source) !== "extension" && !(K.succeeded && K.succeeded > 0))
479
- throw new Error(
480
- ((P = (T = K.errors) == null ? void 0 : T[0]) == null ? void 0 : P.error) || `${(y == null ? void 0 : y.label) ?? "The fix"} did not change the record`
481
- );
482
- },
516
+ const [h, p] = Q(""), { action: x, isLoading: k, run: R } = xr(t, e, r.actionKey), _ = je({
517
+ mutationFn: () => R(h),
483
518
  onSuccess: () => {
484
- Ae(f, t, e), Y.success(`${(y == null ? void 0 : y.label) ?? "Done"} — trying again`), s();
519
+ V.success(`${(x == null ? void 0 : x.label) ?? "Done"} — trying again`), s();
485
520
  },
486
- onError: (B) => Tn(B, `${(y == null ? void 0 : y.label) ?? "The fix"} failed`)
521
+ onError: (j) => Yn(j, `${(x == null ? void 0 : x.label) ?? "The fix"} failed`)
487
522
  });
488
- if ($ || !y) return null;
489
- const E = !A.isPending && (!y.require_reason || _.trim().length > 0);
523
+ if (k || !x) return null;
524
+ const U = !_.isPending && (!x.require_reason || h.trim().length > 0);
490
525
  return /* @__PURE__ */ i(
491
526
  "div",
492
527
  {
493
- className: ye(
528
+ className: ge(
494
529
  "space-y-2 rounded-lg border border-amber-200 bg-amber-50 p-3 dark:border-amber-500/30 dark:bg-amber-950",
495
530
  c
496
531
  ),
497
- style: p,
532
+ style: m,
498
533
  "data-refusal-fix": r.code,
499
534
  children: [
500
535
  /* @__PURE__ */ i("p", { className: "text-[12px] text-amber-950 dark:text-amber-100", children: [
501
536
  "You can fix this here: ",
502
- y.label,
537
+ x.label,
503
538
  ", then the move is tried again."
504
539
  ] }),
505
- y.require_reason && /* @__PURE__ */ n(
540
+ x.require_reason && /* @__PURE__ */ n(
506
541
  "input",
507
542
  {
508
543
  type: "text",
509
- value: _,
510
- onChange: (B) => v(B.target.value),
544
+ value: h,
545
+ onChange: (j) => p(j.target.value),
511
546
  placeholder: "Reason (required)",
512
547
  "aria-label": "Reason",
513
548
  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"
@@ -515,27 +550,27 @@ function pn({
515
550
  ),
516
551
  /* @__PURE__ */ i("div", { className: "flex items-center justify-end gap-2", children: [
517
552
  /* @__PURE__ */ n(
518
- ae,
553
+ ue,
519
554
  {
520
555
  type: "button",
521
556
  size: "sm",
522
557
  variant: "ghost",
523
558
  className: "h-7 text-[12px]",
524
- onClick: l,
559
+ onClick: o,
525
560
  children: "Not now"
526
561
  }
527
562
  ),
528
563
  /* @__PURE__ */ i(
529
- ae,
564
+ ue,
530
565
  {
531
566
  type: "button",
532
567
  size: "sm",
533
568
  className: "h-7 gap-1.5 text-[12px]",
534
- disabled: !E,
535
- onClick: () => A.mutate(),
569
+ disabled: !U,
570
+ onClick: () => _.mutate(),
536
571
  children: [
537
- A.isPending && /* @__PURE__ */ n(me, { className: "h-3 w-3 animate-spin" }),
538
- y.label,
572
+ _.isPending && /* @__PURE__ */ n(ve, { className: "h-3 w-3 animate-spin" }),
573
+ x.label,
539
574
  ", then try again"
540
575
  ]
541
576
  }
@@ -545,7 +580,7 @@ function pn({
545
580
  }
546
581
  );
547
582
  }
548
- function Ne({
583
+ function Re({
549
584
  label: t,
550
585
  color: e,
551
586
  small: r
@@ -564,187 +599,187 @@ function Ne({
564
599
  t
565
600
  );
566
601
  }
567
- function Je(t) {
602
+ function dt(t) {
568
603
  const e = Math.floor(t / 6e4);
569
- return e < 60 ? `${Math.max(1, e)}m` : An(t / 36e5);
604
+ return e < 60 ? `${Math.max(1, e)}m` : ar(t / 36e5);
570
605
  }
571
- function lr({
606
+ function Ar({
572
607
  history: t,
573
608
  completedAt: e
574
609
  }) {
575
610
  const r = [...t].sort(
576
- (p, b) => new Date(p.timestamp).getTime() - new Date(b.timestamp).getTime()
611
+ (m, h) => new Date(m.timestamp).getTime() - new Date(h.timestamp).getTime()
577
612
  );
578
613
  if (r.length === 0) return null;
579
- const s = e ? new Date(e).getTime() : Date.now(), l = r.map((p, b) => {
580
- const f = new Date(p.timestamp).getTime(), _ = b + 1 < r.length ? new Date(r[b + 1].timestamp).getTime() : s;
614
+ const s = e ? new Date(e).getTime() : Date.now(), o = r.map((m, h) => {
615
+ const p = new Date(m.timestamp).getTime(), x = h + 1 < r.length ? new Date(r[h + 1].timestamp).getTime() : s;
581
616
  return {
582
- key: p.id,
583
- label: p.to_state_label,
584
- color: p.to_state_color,
585
- ms: Math.max(0, _ - f),
586
- current: b === r.length - 1 && !e
617
+ key: m.id,
618
+ label: m.to_state_label,
619
+ color: m.to_state_color,
620
+ ms: Math.max(0, x - p),
621
+ current: h === r.length - 1 && !e
587
622
  };
588
- }).filter((p) => p.ms > 0 || p.current);
589
- if (l.length < 2) return null;
590
- const c = l.reduce((p, b) => p + b.ms, 0);
623
+ }).filter((m) => m.ms > 0 || m.current);
624
+ if (o.length < 2) return null;
625
+ const c = o.reduce((m, h) => m + h.ms, 0);
591
626
  return c <= 0 ? null : /* @__PURE__ */ i("div", { "data-state-timeline": !0, children: [
592
627
  /* @__PURE__ */ i("div", { className: "mb-1 flex items-center justify-between", children: [
593
628
  /* @__PURE__ */ n("p", { className: "text-[10px] font-semibold uppercase tracking-wide text-slate-400 dark:text-slate-500", children: "Time in step" }),
594
629
  /* @__PURE__ */ i("p", { className: "text-[10px] tabular-nums text-slate-400 dark:text-slate-500", children: [
595
- Je(c),
630
+ dt(c),
596
631
  " total",
597
632
  e ? "" : " · so far"
598
633
  ] })
599
634
  ] }),
600
- /* @__PURE__ */ n("div", { className: "flex h-4 w-full overflow-hidden rounded", children: l.map((p) => {
601
- const b = p.ms / c * 100;
635
+ /* @__PURE__ */ n("div", { className: "flex h-4 w-full overflow-hidden rounded", children: o.map((m) => {
636
+ const h = m.ms / c * 100;
602
637
  return /* @__PURE__ */ i(
603
638
  "div",
604
639
  {
605
- "data-tip": `${p.label} — ${Je(p.ms)}${p.current ? " (current)" : ""}`,
640
+ "data-tip": `${m.label} — ${dt(m.ms)}${m.current ? " (current)" : ""}`,
606
641
  className: "relative flex min-w-[8px] items-center overflow-hidden border-r border-white/60 last:border-r-0 dark:border-black/30",
607
642
  style: {
608
- width: `${b}%`,
609
- backgroundColor: p.color ? `${p.color}55` : "rgba(100,116,139,.25)"
643
+ width: `${h}%`,
644
+ backgroundColor: m.color ? `${m.color}55` : "rgba(100,116,139,.25)"
610
645
  },
611
646
  children: [
612
- b >= 14 && /* @__PURE__ */ i("span", { className: "truncate px-1.5 text-[9.5px] font-medium leading-none text-slate-700 dark:text-slate-200", children: [
613
- p.label,
647
+ h >= 14 && /* @__PURE__ */ i("span", { className: "truncate px-1.5 text-[9.5px] font-medium leading-none text-slate-700 dark:text-slate-200", children: [
648
+ m.label,
614
649
  " · ",
615
- Je(p.ms)
650
+ dt(m.ms)
616
651
  ] }),
617
- p.current && /* @__PURE__ */ n(
652
+ m.current && /* @__PURE__ */ n(
618
653
  "span",
619
654
  {
620
655
  className: "absolute inset-y-0 right-0 w-[2px]",
621
- style: { backgroundColor: p.color ?? "#64748b" }
656
+ style: { backgroundColor: m.color ?? "#64748b" }
622
657
  }
623
658
  )
624
659
  ]
625
660
  },
626
- p.key
661
+ m.key
627
662
  );
628
663
  }) })
629
664
  ] });
630
665
  }
631
- function or({
666
+ function Or({
632
667
  states: t,
633
668
  allTransitions: e,
634
669
  availableTransitions: r,
635
670
  currentStateId: s,
636
- history: l,
671
+ history: o,
637
672
  onPathIds: c,
638
- skippedStates: p
673
+ skippedStates: m
639
674
  }) {
640
- var L;
641
- const b = ne(null);
642
- fe(() => {
643
- const h = b.current;
644
- if (!h || h.scrollWidth <= h.clientWidth) return;
645
- const x = h.querySelector("[data-track-current]");
646
- if (!x) return;
647
- const w = h.getBoundingClientRect(), q = x.getBoundingClientRect();
648
- h.scrollLeft += q.left + q.width / 2 - (w.left + w.width / 2);
675
+ var K;
676
+ const h = de(null);
677
+ _e(() => {
678
+ const f = h.current;
679
+ if (!f || f.scrollWidth <= f.clientWidth) return;
680
+ const v = f.querySelector("[data-track-current]");
681
+ if (!v) return;
682
+ const g = f.getBoundingClientRect(), $ = v.getBoundingClientRect();
683
+ f.scrollLeft += $.left + $.width / 2 - (g.left + g.width / 2);
649
684
  }, [s]);
650
- const f = new Set(l.map((h) => h.to_state)), _ = t.find((h) => h.is_initial);
651
- _ && _.id !== s && f.add(_.id);
652
- const v = (L = l[0]) == null ? void 0 : L.from_state;
653
- v && v !== s && f.add(v);
654
- const y = (() => {
685
+ const p = new Set(o.map((f) => f.to_state)), x = t.find((f) => f.is_initial);
686
+ x && x.id !== s && p.add(x.id);
687
+ const k = (K = o[0]) == null ? void 0 : K.from_state;
688
+ k && k !== s && p.add(k);
689
+ const R = (() => {
655
690
  if (c)
656
- return t.filter((g) => c.has(g.id) || f.has(g.id) || g.id === s).filter((g) => {
657
- const k = g.stage_visibility ?? "always";
658
- return k === "hide" ? !1 : k === "hide_unless_active" ? f.has(g.id) || g.id === s : !0;
659
- }).sort((g, k) => g.sort - k.sort);
691
+ return t.filter((b) => c.has(b.id) || p.has(b.id) || b.id === s).filter((b) => {
692
+ const q = b.stage_visibility ?? "always";
693
+ return q === "hide" ? !1 : q === "hide_unless_active" ? p.has(b.id) || b.id === s : !0;
694
+ }).sort((b, q) => b.sort - q.sort);
660
695
  if (e.length === 0) {
661
- const g = /* @__PURE__ */ new Set([...f]);
662
- return s && g.add(s), t.filter((k) => g.has(k.id)).sort((k, G) => k.sort - G.sort);
696
+ const b = /* @__PURE__ */ new Set([...p]);
697
+ return s && b.add(s), t.filter((q) => b.has(q.id)).sort((q, ee) => q.sort - ee.sort);
663
698
  }
664
- const h = new Set(
665
- l.filter((g) => g.from_state).map((g) => `${g.from_state}:${g.to_state}`)
666
- ), x = new Set(l.map((g) => g.from_state).filter(Boolean)), w = e.filter((g) => g.from_state !== null), q = /* @__PURE__ */ new Map();
667
- for (const g of w) {
668
- const k = g.from_state;
669
- if (x.has(k) && !h.has(`${k}:${g.to_state}`)) continue;
670
- const G = q.get(k) ?? [];
671
- G.push(g.to_state), q.set(k, G);
699
+ const f = new Set(
700
+ o.filter((b) => b.from_state).map((b) => `${b.from_state}:${b.to_state}`)
701
+ ), v = new Set(o.map((b) => b.from_state).filter(Boolean)), g = e.filter((b) => b.from_state !== null), $ = /* @__PURE__ */ new Map();
702
+ for (const b of g) {
703
+ const q = b.from_state;
704
+ if (v.has(q) && !f.has(`${q}:${b.to_state}`)) continue;
705
+ const ee = $.get(q) ?? [];
706
+ ee.push(b.to_state), $.set(q, ee);
672
707
  }
673
708
  if (s) {
674
- const g = w.filter((k) => k.from_state === s).map((k) => k.to_state);
675
- q.set(s, [
676
- .../* @__PURE__ */ new Set([...r.map((k) => k.to_state), ...g])
709
+ const b = g.filter((q) => q.from_state === s).map((q) => q.to_state);
710
+ $.set(s, [
711
+ .../* @__PURE__ */ new Set([...r.map((q) => q.to_state), ...b])
677
712
  ]);
678
713
  }
679
- const o = /* @__PURE__ */ new Set(), Q = t.filter((g) => g.is_initial).map((g) => g.id);
680
- for (; Q.length; ) {
681
- const g = Q.shift();
682
- if (!o.has(g)) {
683
- o.add(g);
684
- for (const k of q.get(g) ?? []) o.has(k) || Q.push(k);
714
+ const T = /* @__PURE__ */ new Set(), X = t.filter((b) => b.is_initial).map((b) => b.id);
715
+ for (; X.length; ) {
716
+ const b = X.shift();
717
+ if (!T.has(b)) {
718
+ T.add(b);
719
+ for (const q of $.get(b) ?? []) T.has(q) || X.push(q);
685
720
  }
686
721
  }
687
- const X = /* @__PURE__ */ new Set([...o, ...f]);
688
- return s && X.add(s), t.filter((g) => X.has(g.id)).filter((g) => {
689
- const k = g.stage_visibility ?? "always";
690
- return k === "hide" ? !1 : k === "hide_unless_active" ? f.has(g.id) || g.id === s : !0;
691
- }).sort((g, k) => g.sort - k.sort);
722
+ const u = /* @__PURE__ */ new Set([...T, ...p]);
723
+ return s && u.add(s), t.filter((b) => u.has(b.id)).filter((b) => {
724
+ const q = b.stage_visibility ?? "always";
725
+ return q === "hide" ? !1 : q === "hide_unless_active" ? p.has(b.id) || b.id === s : !0;
726
+ }).sort((b, q) => b.sort - q.sort);
692
727
  })();
693
- if (y.length < 2) return null;
694
- const $ = y.findIndex((h) => h.id === s), A = new Map(y.map((h, x) => [h.id, x])), E = new Map(t.map((h) => [h.id, h.label]));
695
- function B(h, x) {
696
- const w = A.get(h);
697
- return w == null ? [] : [...l].filter((q) => {
698
- if (!q.from_state) return !1;
699
- const o = A.get(q.from_state), Q = A.get(q.to_state);
700
- return o == null || Q == null ? !1 : o === w && Q > w || Q < o && o - 1 === w;
701
- }).sort((q, o) => new Date(q.timestamp).getTime() - new Date(o.timestamp).getTime());
728
+ if (R.length < 2) return null;
729
+ const _ = R.findIndex((f) => f.id === s), U = new Map(R.map((f, v) => [f.id, v])), j = new Map(t.map((f) => [f.id, f.label]));
730
+ function ne(f, v) {
731
+ const g = U.get(f);
732
+ return g == null ? [] : [...o].filter(($) => {
733
+ if (!$.from_state) return !1;
734
+ const T = U.get($.from_state), X = U.get($.to_state);
735
+ return T == null || X == null ? !1 : T === g && X > g || X < T && T - 1 === g;
736
+ }).sort(($, T) => new Date($.timestamp).getTime() - new Date(T.timestamp).getTime());
702
737
  }
703
- function H(h) {
704
- var x, w, q, o;
705
- return je(h) ? /* @__PURE__ */ n(Ut, { className: "inline h-2.5 w-2.5", "aria-label": st(h) }) : ((((x = h.first_name) == null ? void 0 : x[0]) ?? "") + (((w = h.last_name) == null ? void 0 : w[0]) ?? "")).toUpperCase() || ((o = (q = h.user_email) == null ? void 0 : q[0]) == null ? void 0 : o.toUpperCase()) || "?";
738
+ function re(f) {
739
+ var v, g, $, T;
740
+ return Ye(f) ? /* @__PURE__ */ n(Zt, { className: "inline h-2.5 w-2.5", "aria-label": xt(f) }) : ((((v = f.first_name) == null ? void 0 : v[0]) ?? "") + (((g = f.last_name) == null ? void 0 : g[0]) ?? "")).toUpperCase() || ((T = ($ = f.user_email) == null ? void 0 : $[0]) == null ? void 0 : T.toUpperCase()) || "?";
706
741
  }
707
- function K(h) {
708
- return mt([h.first_name, h.last_name].filter(Boolean).join(" ") || h.user_email, h);
742
+ function ae(f) {
743
+ return Ct([f.first_name, f.last_name].filter(Boolean).join(" ") || f.user_email, f);
709
744
  }
710
- const T = /* @__PURE__ */ new Map();
711
- for (const h of [...l].sort(
712
- (x, w) => new Date(x.timestamp).getTime() - new Date(w.timestamp).getTime()
745
+ const F = /* @__PURE__ */ new Map();
746
+ for (const f of [...o].sort(
747
+ (v, g) => new Date(v.timestamp).getTime() - new Date(g.timestamp).getTime()
713
748
  )) {
714
- if (!h.from_state) continue;
715
- const x = A.get(h.from_state), w = A.get(h.to_state);
716
- if (!(x == null || w == null || w <= x + 1))
717
- for (let q = x + 1; q < w; q++) {
718
- const o = y[q].id;
719
- !f.has(o) && !T.has(o) && T.set(o, h);
749
+ if (!f.from_state) continue;
750
+ const v = U.get(f.from_state), g = U.get(f.to_state);
751
+ if (!(v == null || g == null || g <= v + 1))
752
+ for (let $ = v + 1; $ < g; $++) {
753
+ const T = R[$].id;
754
+ !p.has(T) && !F.has(T) && F.set(T, f);
720
755
  }
721
756
  }
722
- function P(h) {
723
- const x = E.get(h.from_state ?? "") ?? "the previous step", w = E.get(h.to_state) ?? "the next step", q = je(h) ? "it moved automatically" : `${K(h)} moved it`;
724
- return `Passed over on ${_t(h.timestamp)} — ${q} straight from ${x} to ${w}`;
757
+ function E(f) {
758
+ const v = j.get(f.from_state ?? "") ?? "the previous step", g = j.get(f.to_state) ?? "the next step", $ = Ye(f) ? "it moved automatically" : `${ae(f)} moved it`;
759
+ return `Passed over on ${Et(f.timestamp)} — ${$} straight from ${v} to ${g}`;
725
760
  }
726
- return /* @__PURE__ */ n(Qt, { delayDuration: 200, children: /* @__PURE__ */ n("div", { ref: b, className: "overflow-x-auto pt-1.5 pb-1", "data-state-track": !0, children: /* @__PURE__ */ n("div", { className: "flex w-full items-start", children: y.map((h, x) => {
727
- const w = h.id === s, q = f.has(h.id), o = q && !w && ($ < 0 || x < $), Q = q && !w && !o, X = !q && !w ? T.get(h.id) : void 0, g = !q && !w ? p == null ? void 0 : p.get(h.id) : void 0, k = X || g ? [...X ? [P(X)] : [], ...g ?? []] : void 0, G = k !== void 0, se = h.color ?? "#94a3b8", ee = x === y.length - 1, re = ee ? null : y[x + 1], z = re ? B(h.id, re.id) : [];
761
+ return /* @__PURE__ */ n(ln, { 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: R.map((f, v) => {
762
+ const g = f.id === s, $ = p.has(f.id), T = $ && !g && (_ < 0 || v < _), X = $ && !g && !T, u = !$ && !g ? F.get(f.id) : void 0, b = !$ && !g ? m == null ? void 0 : m.get(f.id) : void 0, q = u || b ? [...u ? [E(u)] : [], ...b ?? []] : void 0, ee = q !== void 0, W = f.color ?? "#94a3b8", ce = v === R.length - 1, xe = ce ? null : R[v + 1], le = xe ? ne(f.id, xe.id) : [];
728
763
  return /* @__PURE__ */ i("div", { className: "flex flex-1 items-start", children: [
729
764
  /* @__PURE__ */ i("div", { className: "flex min-w-[76px] flex-1 flex-col items-center gap-1.5 px-1", children: [
730
765
  /* @__PURE__ */ n(
731
766
  "div",
732
767
  {
733
- "data-track-current": w || void 0,
734
- className: `flex h-7 w-7 shrink-0 items-center justify-center rounded-full ${w || o ? "nvr-fill-sweep" : ""}`,
735
- "data-tip": Q ? `Passed before the record was sent back — it needs this step again.${h.description ? ` ${h.description}` : ""}` : h.description || void 0,
736
- "data-track-again": Q || void 0,
768
+ "data-track-current": g || void 0,
769
+ className: `flex h-7 w-7 shrink-0 items-center justify-center rounded-full ${g || T ? "nvr-fill-sweep" : ""}`,
770
+ "data-tip": X ? `Passed before the record was sent back — it needs this step again.${f.description ? ` ${f.description}` : ""}` : f.description || void 0,
771
+ "data-track-again": X || void 0,
737
772
  style: {
738
- backgroundColor: w || o ? se : G ? "transparent" : "#f1f5f9",
739
- border: w || o ? "none" : G ? "1.5px dashed #cbd5e1" : "1.5px solid #e2e8f0",
740
- boxShadow: w ? `0 0 0 3px white, 0 0 0 5px ${se}` : void 0
773
+ backgroundColor: g || T ? W : ee ? "transparent" : "#f1f5f9",
774
+ border: g || T ? "none" : ee ? "1.5px dashed #cbd5e1" : "1.5px solid #e2e8f0",
775
+ boxShadow: g ? `0 0 0 3px white, 0 0 0 5px ${W}` : void 0
741
776
  },
742
- children: o ? /* @__PURE__ */ n(We, { className: "h-3.5 w-3.5 text-white", strokeWidth: 2.5 }) : w ? /* @__PURE__ */ n("div", { className: "h-2.5 w-2.5 rounded-full bg-white/80" }) : G ? /* @__PURE__ */ n(Nn, { className: "h-3 w-3 text-slate-400", strokeWidth: 2.5 }) : /* @__PURE__ */ n("div", { className: "h-2 w-2 rounded-full bg-slate-300" })
777
+ children: T ? /* @__PURE__ */ n(tt, { className: "h-3.5 w-3.5 text-white", strokeWidth: 2.5 }) : g ? /* @__PURE__ */ n("div", { className: "h-2.5 w-2.5 rounded-full bg-white/80" }) : ee ? /* @__PURE__ */ n(Wn, { className: "h-3 w-3 text-slate-400", strokeWidth: 2.5 }) : /* @__PURE__ */ n("div", { className: "h-2 w-2 rounded-full bg-slate-300" })
743
778
  },
744
- w ? "cur" : o ? "done" : G ? "skip" : "todo"
779
+ g ? "cur" : T ? "done" : ee ? "skip" : "todo"
745
780
  ),
746
- G ? /* @__PURE__ */ i(nt, { children: [
747
- /* @__PURE__ */ n(rt, { asChild: !0, children: /* @__PURE__ */ n(
781
+ ee ? /* @__PURE__ */ i(ft, { children: [
782
+ /* @__PURE__ */ n(ht, { asChild: !0, children: /* @__PURE__ */ n(
748
783
  "span",
749
784
  {
750
785
  className: "w-full cursor-help break-words text-center leading-snug",
@@ -756,39 +791,39 @@ function or({
756
791
  textDecoration: "line-through",
757
792
  textDecorationColor: "#cbd5e1"
758
793
  },
759
- children: h.label
794
+ children: f.label
760
795
  }
761
796
  ) }),
762
- /* @__PURE__ */ i(at, { className: "max-w-[260px]", children: [
797
+ /* @__PURE__ */ i(bt, { className: "max-w-[260px]", children: [
763
798
  /* @__PURE__ */ n("p", { className: "text-[11px] font-medium", children: "Skipped for this record" }),
764
- k.length > 0 ? /* @__PURE__ */ n("ul", { className: "mt-1 space-y-0.5 text-[11px] opacity-90", children: k.map((C) => /* @__PURE__ */ n("li", { children: C }, C)) }) : /* @__PURE__ */ n("p", { className: "mt-1 text-[11px] opacity-90", children: "Its skip conditions are met." })
799
+ q.length > 0 ? /* @__PURE__ */ n("ul", { className: "mt-1 space-y-0.5 text-[11px] opacity-90", children: q.map((O) => /* @__PURE__ */ n("li", { children: O }, O)) }) : /* @__PURE__ */ n("p", { className: "mt-1 text-[11px] opacity-90", children: "Its skip conditions are met." })
765
800
  ] })
766
801
  ] }) : /* @__PURE__ */ n(
767
802
  "span",
768
803
  {
769
- className: ye(
804
+ className: ge(
770
805
  "w-full break-words text-center leading-snug",
771
- !w && !o && "text-slate-500 dark:text-slate-400"
806
+ !g && !T && "text-slate-500 dark:text-slate-400"
772
807
  ),
773
808
  style: {
774
809
  fontSize: "11px",
775
- color: w ? se : o ? "#475569" : void 0,
776
- fontWeight: w ? 600 : o ? 500 : 400,
810
+ color: g ? W : T ? "#475569" : void 0,
811
+ fontWeight: g ? 600 : T ? 500 : 400,
777
812
  wordBreak: "break-word"
778
813
  },
779
- children: h.label
814
+ children: f.label
780
815
  }
781
816
  )
782
817
  ] }),
783
- !ee && /* @__PURE__ */ i("div", { className: "mt-[13px] flex w-10 shrink-0 flex-col items-center gap-1.5", children: [
818
+ !ce && /* @__PURE__ */ i("div", { className: "mt-[13px] flex w-10 shrink-0 flex-col items-center gap-1.5", children: [
784
819
  (() => {
785
- const C = o ? `${se}55` : "#e8ecf0";
820
+ const O = T ? `${W}55` : "#e8ecf0";
786
821
  return /* @__PURE__ */ i("div", { className: "flex w-full shrink-0 items-center", children: [
787
822
  /* @__PURE__ */ n(
788
823
  "div",
789
824
  {
790
825
  className: "h-0.5 flex-1 rounded-l-sm",
791
- style: { backgroundColor: C }
826
+ style: { backgroundColor: O }
792
827
  }
793
828
  ),
794
829
  /* @__PURE__ */ n(
@@ -799,65 +834,65 @@ function or({
799
834
  height: 0,
800
835
  borderTop: "3px solid transparent",
801
836
  borderBottom: "3px solid transparent",
802
- borderLeft: `5px solid ${C}`
837
+ borderLeft: `5px solid ${O}`
803
838
  }
804
839
  }
805
840
  )
806
841
  ] });
807
842
  })(),
808
- z.map((C) => {
809
- const de = C.from_state !== h.id, J = Math.abs(
810
- (A.get(C.to_state) ?? 0) - (A.get(C.from_state ?? "") ?? 0)
811
- ) > 1 ? E.get(C.to_state) ?? "" : null;
812
- return /* @__PURE__ */ i(nt, { children: [
813
- /* @__PURE__ */ n(rt, { asChild: !0, children: /* @__PURE__ */ i("div", { className: "flex w-full cursor-default flex-col items-center gap-0.5", children: [
843
+ le.map((O) => {
844
+ const Y = O.from_state !== f.id, z = Math.abs(
845
+ (U.get(O.to_state) ?? 0) - (U.get(O.from_state ?? "") ?? 0)
846
+ ) > 1 ? j.get(O.to_state) ?? "" : null;
847
+ return /* @__PURE__ */ i(ft, { children: [
848
+ /* @__PURE__ */ n(ht, { asChild: !0, children: /* @__PURE__ */ i("div", { className: "flex w-full cursor-default flex-col items-center gap-0.5", children: [
814
849
  /* @__PURE__ */ i(
815
850
  "span",
816
851
  {
817
852
  className: "text-center font-mono text-[9px] font-semibold leading-none",
818
- style: { color: de ? "#d97706" : "#475569" },
853
+ style: { color: Y ? "#d97706" : "#475569" },
819
854
  children: [
820
- de && "↩ ",
821
- H(C)
855
+ Y && "↩ ",
856
+ re(O)
822
857
  ]
823
858
  }
824
859
  ),
825
- /* @__PURE__ */ n("span", { className: "text-[8.5px] leading-none text-slate-400", children: ot(C.timestamp) })
860
+ /* @__PURE__ */ n("span", { className: "text-[8.5px] leading-none text-slate-400", children: kt(O.timestamp) })
826
861
  ] }) }),
827
- /* @__PURE__ */ i(at, { side: "top", className: "space-y-0.5 text-[12px]", children: [
828
- je(C) ? /* @__PURE__ */ i(xe, { children: [
862
+ /* @__PURE__ */ i(bt, { side: "top", className: "space-y-0.5 text-[12px]", children: [
863
+ Ye(O) ? /* @__PURE__ */ i(Se, { children: [
829
864
  /* @__PURE__ */ i("p", { className: "font-medium", children: [
830
- de ? "↩ Sent back · " : "",
831
- st(C)
865
+ Y ? "↩ Sent back · " : "",
866
+ xt(O)
832
867
  ] }),
833
- it(C) && /* @__PURE__ */ n("p", { className: "max-w-[280px] text-muted-foreground", children: it(C) })
868
+ vt(O) && /* @__PURE__ */ n("p", { className: "max-w-[280px] text-muted-foreground", children: vt(O) })
834
869
  ] }) : /* @__PURE__ */ i("p", { className: "font-medium", children: [
835
- de ? "↩ Sent back by" : "Approved by",
870
+ Y ? "↩ Sent back by" : "Approved by",
836
871
  " ",
837
- K(C)
872
+ ae(O)
838
873
  ] }),
839
- J && /* @__PURE__ */ i("p", { className: "text-muted-foreground", children: [
874
+ z && /* @__PURE__ */ i("p", { className: "text-muted-foreground", children: [
840
875
  "→ straight to ",
841
- J
876
+ z
842
877
  ] }),
843
- /* @__PURE__ */ n("p", { className: "text-muted-foreground", children: _t(C.timestamp) })
878
+ /* @__PURE__ */ n("p", { className: "text-muted-foreground", children: Et(O.timestamp) })
844
879
  ] })
845
- ] }, C.id);
880
+ ] }, O.id);
846
881
  })
847
882
  ] })
848
- ] }, h.id);
883
+ ] }, f.id);
849
884
  }) }) }) });
850
885
  }
851
- function dr({ history: t }) {
886
+ function Dr({ history: t }) {
852
887
  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) => {
853
- const r = je(e), s = r ? st(e) : mt([e.first_name, e.last_name].filter(Boolean).join(" ") || e.user_email, e), l = Hn(e), c = e.comment && !r && !l ? e.comment : null, p = l ?? (r ? it(e) : null);
888
+ const r = Ye(e), s = r ? xt(e) : Ct([e.first_name, e.last_name].filter(Boolean).join(" ") || e.user_email, e), o = wr(e), c = e.comment && !r && !o ? e.comment : null, m = o ?? (r ? vt(e) : null);
854
889
  return /* @__PURE__ */ i("div", { className: "flex items-start gap-2.5 text-[12px]", children: [
855
890
  /* @__PURE__ */ n("div", { className: "mt-1.5 h-1.5 w-1.5 shrink-0 rounded-full bg-slate-200" }),
856
891
  /* @__PURE__ */ i("div", { className: "flex-1 min-w-0", children: [
857
892
  /* @__PURE__ */ i("div", { className: "flex items-center gap-1.5 flex-wrap", children: [
858
- e.from_state_label ? /* @__PURE__ */ n(Ne, { label: e.from_state_label, color: e.from_state_color, small: !0 }) : /* @__PURE__ */ n("span", { className: "text-[11px] text-slate-400 italic", children: "started" }),
859
- /* @__PURE__ */ n(lt, { className: "h-3 w-3 shrink-0 text-slate-300" }),
860
- /* @__PURE__ */ n(Ne, { label: e.to_state_label, color: e.to_state_color, small: !0 })
893
+ e.from_state_label ? /* @__PURE__ */ n(Re, { label: e.from_state_label, color: e.from_state_color, small: !0 }) : /* @__PURE__ */ n("span", { className: "text-[11px] text-slate-400 italic", children: "started" }),
894
+ /* @__PURE__ */ n(wt, { className: "h-3 w-3 shrink-0 text-slate-300" }),
895
+ /* @__PURE__ */ n(Re, { label: e.to_state_label, color: e.to_state_color, small: !0 })
861
896
  ] }),
862
897
  c && /* @__PURE__ */ i("p", { className: "mt-1 text-slate-500 italic", children: [
863
898
  '"',
@@ -870,11 +905,11 @@ function dr({ history: t }) {
870
905
  className: "mt-0.5 text-slate-400",
871
906
  "data-history-on-behalf": e.on_behalf_of_name ? e.on_behalf_of ?? "" : void 0,
872
907
  children: [
873
- r && /* @__PURE__ */ n(Ut, { className: "mr-1 inline h-3 w-3", "aria-hidden": !0 }),
908
+ r && /* @__PURE__ */ n(Zt, { className: "mr-1 inline h-3 w-3", "aria-hidden": !0 }),
874
909
  s,
875
- p ? ` · ${p}` : "",
910
+ m ? ` · ${m}` : "",
876
911
  " · ",
877
- ot(e.timestamp)
912
+ kt(e.timestamp)
878
913
  ]
879
914
  }
880
915
  )
@@ -882,42 +917,42 @@ function dr({ history: t }) {
882
917
  ] }, e.id);
883
918
  }) });
884
919
  }
885
- function cr({ value: t, onChange: e }) {
886
- const r = we(), [s, l] = I(!1), [c, p] = I(""), [b, f] = I(""), _ = ne(null), v = ne(null);
887
- fe(() => {
920
+ function Ur({ value: t, onChange: e }) {
921
+ const r = Pe(), [s, o] = Q(!1), [c, m] = Q(""), [h, p] = Q(""), x = de(null), k = de(null);
922
+ _e(() => {
888
923
  s ? setTimeout(() => {
889
- var T;
890
- return (T = _.current) == null ? void 0 : T.focus();
891
- }, 50) : p("");
892
- }, [s]), fe(() => (v.current && clearTimeout(v.current), v.current = setTimeout(() => f(c), 250), () => {
893
- v.current && clearTimeout(v.current);
924
+ var F;
925
+ return (F = x.current) == null ? void 0 : F.focus();
926
+ }, 50) : m("");
927
+ }, [s]), _e(() => (k.current && clearTimeout(k.current), k.current = setTimeout(() => p(c), 250), () => {
928
+ k.current && clearTimeout(k.current);
894
929
  }), [c]);
895
- const { data: y, isLoading: $ } = oe({
896
- queryKey: ["users", "async-search", b],
930
+ const { data: R, isLoading: _ } = be({
931
+ queryKey: ["users", "async-search", h],
897
932
  queryFn: () => r.request(
898
- ce("/users", {
933
+ ye("/users", {
899
934
  limit: 50,
900
935
  sort: "first_name",
901
- ...b ? { search: b } : {}
936
+ ...h ? { search: h } : {}
902
937
  })
903
- ).then((T) => T.data),
938
+ ).then((F) => F.data),
904
939
  enabled: s,
905
940
  staleTime: 3e4
906
- }), { data: A } = oe({
907
- ...Pn(r, t),
941
+ }), { data: U } = be({
942
+ ...tr(r, t),
908
943
  enabled: !!t,
909
944
  staleTime: 5 * 6e4
910
- }), E = y ?? [], B = A ?? E.find((T) => T.id === t) ?? null, H = B ? [B.first_name, B.last_name].filter(Boolean).join(" ").trim() || B.email : t ? "Selected person" : null, K = (T) => [T.first_name, T.last_name].filter(Boolean).join(" ").trim();
911
- return /* @__PURE__ */ i(dt, { open: s, onOpenChange: l, children: [
945
+ }), j = R ?? [], ne = U ?? j.find((F) => F.id === t) ?? null, re = ne ? [ne.first_name, ne.last_name].filter(Boolean).join(" ").trim() || ne.email : t ? "Selected person" : null, ae = (F) => [F.first_name, F.last_name].filter(Boolean).join(" ").trim();
946
+ return /* @__PURE__ */ i(Nt, { open: s, onOpenChange: o, children: [
912
947
  /* @__PURE__ */ i("div", { className: "relative flex h-8 w-full", children: [
913
- /* @__PURE__ */ n(ct, { asChild: !0, children: /* @__PURE__ */ i(
948
+ /* @__PURE__ */ n(_t, { asChild: !0, children: /* @__PURE__ */ i(
914
949
  "button",
915
950
  {
916
951
  type: "button",
917
952
  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",
918
953
  children: [
919
- /* @__PURE__ */ n("span", { className: `flex-1 truncate ${H ? "" : "text-slate-400"}`, children: H ?? "Select a user…" }),
920
- /* @__PURE__ */ n($e, { className: "h-3.5 w-3.5 shrink-0 text-slate-400" })
954
+ /* @__PURE__ */ n("span", { className: `flex-1 truncate ${re ? "" : "text-slate-400"}`, children: re ?? "Select a user…" }),
955
+ /* @__PURE__ */ n(Fe, { className: "h-3.5 w-3.5 shrink-0 text-slate-400" })
921
956
  ]
922
957
  }
923
958
  ) }),
@@ -925,64 +960,64 @@ function cr({ value: t, onChange: e }) {
925
960
  "button",
926
961
  {
927
962
  type: "button",
928
- onClick: (T) => {
929
- T.stopPropagation(), e("");
963
+ onClick: (F) => {
964
+ F.stopPropagation(), e("");
930
965
  },
931
966
  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",
932
- children: /* @__PURE__ */ n(Ot, { className: "h-3 w-3" })
967
+ children: /* @__PURE__ */ n(Jt, { className: "h-3 w-3" })
933
968
  }
934
969
  )
935
970
  ] }),
936
- /* @__PURE__ */ i(ut, { align: "start", className: "w-72 p-0", sideOffset: 4, children: [
971
+ /* @__PURE__ */ i(St, { align: "start", className: "w-72 p-0", sideOffset: 4, children: [
937
972
  /* @__PURE__ */ n("div", { className: "border-b border-slate-100 px-2 py-1.5", children: /* @__PURE__ */ i("div", { className: "relative", children: [
938
- /* @__PURE__ */ n(Sn, { className: "absolute left-2 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-slate-400" }),
973
+ /* @__PURE__ */ n(Hn, { className: "absolute left-2 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-slate-400" }),
939
974
  /* @__PURE__ */ n(
940
975
  "input",
941
976
  {
942
- ref: _,
977
+ ref: x,
943
978
  value: c,
944
- onChange: (T) => p(T.target.value),
979
+ onChange: (F) => m(F.target.value),
945
980
  placeholder: "Search users…",
946
981
  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"
947
982
  }
948
983
  )
949
984
  ] }) }),
950
- /* @__PURE__ */ n("div", { className: "max-h-56 overflow-y-auto py-1", children: $ ? /* @__PURE__ */ i("div", { className: "flex items-center gap-2 px-3 py-2 text-[12px] text-slate-400", children: [
951
- /* @__PURE__ */ n(me, { className: "h-3.5 w-3.5 animate-spin" }),
985
+ /* @__PURE__ */ n("div", { className: "max-h-56 overflow-y-auto py-1", children: _ ? /* @__PURE__ */ i("div", { className: "flex items-center gap-2 px-3 py-2 text-[12px] text-slate-400", children: [
986
+ /* @__PURE__ */ n(ve, { className: "h-3.5 w-3.5 animate-spin" }),
952
987
  "Loading…"
953
- ] }) : E.length === 0 ? /* @__PURE__ */ n("div", { className: "px-3 py-2 text-[12px] text-slate-400", children: "No results" }) : E.map((T) => {
954
- const P = K(T), L = P ? `${P} (${T.email})` : T.email, h = T.id === t;
988
+ ] }) : j.length === 0 ? /* @__PURE__ */ n("div", { className: "px-3 py-2 text-[12px] text-slate-400", children: "No results" }) : j.map((F) => {
989
+ const E = ae(F), K = E ? `${E} (${F.email})` : F.email, f = F.id === t;
955
990
  return /* @__PURE__ */ i(
956
991
  "button",
957
992
  {
958
993
  type: "button",
959
994
  onClick: () => {
960
- e(T.id), l(!1);
995
+ e(F.id), o(!1);
961
996
  },
962
- className: `flex w-full items-center gap-2 px-3 py-1.5 text-left text-[12px] hover:bg-slate-50 ${h ? "font-medium text-slate-800" : "text-slate-600"}`,
997
+ className: `flex w-full items-center gap-2 px-3 py-1.5 text-left text-[12px] hover:bg-slate-50 ${f ? "font-medium text-slate-800" : "text-slate-600"}`,
963
998
  children: [
964
999
  /* @__PURE__ */ n(
965
- We,
1000
+ tt,
966
1001
  {
967
- className: `h-3.5 w-3.5 shrink-0 ${h ? "text-nvr-cyan" : "opacity-0"}`
1002
+ className: `h-3.5 w-3.5 shrink-0 ${f ? "text-nvr-cyan" : "opacity-0"}`
968
1003
  }
969
1004
  ),
970
- L
1005
+ K
971
1006
  ]
972
1007
  },
973
- T.id
1008
+ F.id
974
1009
  );
975
1010
  }) })
976
1011
  ] })
977
1012
  ] });
978
1013
  }
979
- function Dt({
1014
+ function Gt({
980
1015
  userId: t,
981
1016
  name: e,
982
1017
  email: r,
983
1018
  initials: s
984
1019
  }) {
985
- return /* @__PURE__ */ n(Kt, { userId: t, children: /* @__PURE__ */ i(
1020
+ return /* @__PURE__ */ n(on, { userId: t, children: /* @__PURE__ */ i(
986
1021
  "button",
987
1022
  {
988
1023
  type: "button",
@@ -990,7 +1025,7 @@ function Dt({
990
1025
  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",
991
1026
  children: [
992
1027
  /* @__PURE__ */ n(
993
- Ln,
1028
+ lr,
994
1029
  {
995
1030
  userId: t,
996
1031
  alt: e,
@@ -1006,153 +1041,153 @@ function Dt({
1006
1041
  }
1007
1042
  ) });
1008
1043
  }
1009
- function ur({
1044
+ function Br({
1010
1045
  collection: t,
1011
1046
  item: e,
1012
1047
  states: r,
1013
1048
  currentStateId: s,
1014
- returned: l = !1
1049
+ returned: o = !1
1015
1050
  }) {
1016
- var he, be, d, _e;
1017
- const c = we(), p = De(), { isAdmin: b } = Bt(), [f, _] = I(!1), [v, y] = I(""), [$, A] = I(""), [E, B] = I(!1), H = ["pipeline-instance-owners", t, e], K = ["pipeline-owners-can-add", t, e], T = () => c.request(
1018
- ce(`/pipelines/instance/${t}/${e}/owners`)
1051
+ var se, G, qe, Oe;
1052
+ const c = Pe(), m = ze(), { isAdmin: h } = nn(), [p, x] = Q(!1), [k, R] = Q(""), [_, U] = Q(""), [j, ne] = Q(!1), re = ["pipeline-instance-owners", t, e], ae = ["pipeline-owners-can-add", t, e], F = () => c.request(
1053
+ ye(`/pipelines/instance/${t}/${e}/owners`)
1019
1054
  ).then((a) => {
1020
- var m;
1021
- return p.setQueryData(K, ((m = a.meta) == null ? void 0 : m.can_add) ?? null), a;
1022
- }), { data: P, isLoading: L } = oe({
1023
- queryKey: H,
1024
- queryFn: () => T().then((a) => a.data)
1025
- }), { data: h } = oe({
1026
- queryKey: K,
1027
- queryFn: () => T().then((a) => {
1028
- var m;
1029
- return ((m = a.meta) == null ? void 0 : m.can_add) ?? null;
1055
+ var I;
1056
+ return m.setQueryData(ae, ((I = a.meta) == null ? void 0 : I.can_add) ?? null), a;
1057
+ }), { data: E, isLoading: K } = be({
1058
+ queryKey: re,
1059
+ queryFn: () => F().then((a) => a.data)
1060
+ }), { data: f } = be({
1061
+ queryKey: ae,
1062
+ queryFn: () => F().then((a) => {
1063
+ var I;
1064
+ return ((I = a.meta) == null ? void 0 : I.can_add) ?? null;
1030
1065
  }),
1031
- enabled: !L,
1066
+ enabled: !K,
1032
1067
  staleTime: 3e4
1033
- }), x = typeof h == "boolean" ? h : b, { data: w, isLoading: q } = oe({
1068
+ }), v = typeof f == "boolean" ? f : h, { data: g, isLoading: $ } = be({
1034
1069
  queryKey: ["pipeline-all-owners", t, e],
1035
1070
  queryFn: () => c.request(
1036
- ce(`/pipelines/instance/${t}/${e}/owners/all`)
1071
+ ye(`/pipelines/instance/${t}/${e}/owners/all`)
1037
1072
  ).then((a) => a.data ?? null),
1038
1073
  enabled: !!s,
1039
1074
  staleTime: 3e4
1040
- }), o = new Set((P ?? []).map((a) => a.user)), Q = s ? (((he = w == null ? void 0 : w[s]) == null ? void 0 : he.owners) ?? []).filter((a) => !o.has(a.id)) : [], X = new Map(
1041
- (s ? ((be = w == null ? void 0 : w[s]) == null ? void 0 : be.unavailable) ?? [] : []).map((a) => [
1075
+ }), T = new Set((E ?? []).map((a) => a.user)), X = s ? (((se = g == null ? void 0 : g[s]) == null ? void 0 : se.owners) ?? []).filter((a) => !T.has(a.id)) : [], u = new Map(
1076
+ (s ? ((G = g == null ? void 0 : g[s]) == null ? void 0 : G.unavailable) ?? [] : []).map((a) => [
1042
1077
  String(a.id).toUpperCase(),
1043
1078
  a
1044
1079
  ])
1045
- ), g = Q.length + ((P == null ? void 0 : P.length) ?? 0), k = !!((d = r.find((a) => a.id === s)) != null && d.is_initial), G = !L && !q, { data: se } = oe({
1080
+ ), b = X.length + ((E == null ? void 0 : E.length) ?? 0), q = !!((qe = r.find((a) => a.id === s)) != null && qe.is_initial), ee = !K && !$, { data: W } = be({
1046
1081
  queryKey: ["pipeline-record-creator", t, e],
1047
1082
  queryFn: () => c.request(
1048
- ce(`/pipelines/instance/${t}/${e}/creator`)
1083
+ ye(`/pipelines/instance/${t}/${e}/creator`)
1049
1084
  ).then((a) => a.data ?? null),
1050
- enabled: k && G && g === 0,
1085
+ enabled: q && ee && b === 0,
1051
1086
  staleTime: 6e4
1052
- }), ee = k && g === 0 && (se != null && se.name) ? se : null, re = () => {
1053
- p.invalidateQueries({ queryKey: H }), p.invalidateQueries({ queryKey: ["pipeline-instance", t, e] });
1054
- }, z = Pe({
1087
+ }), ce = q && b === 0 && (W != null && W.name) ? W : null, xe = () => {
1088
+ m.invalidateQueries({ queryKey: re }), m.invalidateQueries({ queryKey: ["pipeline-instance", t, e] });
1089
+ }, le = je({
1055
1090
  mutationFn: () => c.request(
1056
- Te(`/pipelines/instance/${t}/${e}/owners`, {
1057
- user: v,
1058
- state: $ || void 0
1091
+ We(`/pipelines/instance/${t}/${e}/owners`, {
1092
+ user: k,
1093
+ state: _ || void 0
1059
1094
  })
1060
1095
  ),
1061
1096
  onSuccess: () => {
1062
- re(), y(""), A(""), _(!1), Y.success("Owner added");
1097
+ xe(), R(""), U(""), x(!1), V.success("Owner added");
1063
1098
  },
1064
1099
  // The server's reason (a 403 says why), not a bare status phrase.
1065
- onError: (a) => Y.error(Fe(a, "Failed to add owner"))
1066
- }), C = Pe({
1067
- mutationFn: (a) => c.request($n(`/pipelines/instance-owners/${a.id}`)),
1068
- onSuccess: (a, m) => {
1069
- re();
1070
- const N = [m.first_name, m.last_name].filter(Boolean).join(" ") || m.email;
1071
- Y.success(`${N} removed as an owner`, {
1100
+ onError: (a) => V.error(Ae(a, "Failed to add owner"))
1101
+ }), O = je({
1102
+ mutationFn: (a) => c.request(Xn(`/pipelines/instance-owners/${a.id}`)),
1103
+ onSuccess: (a, I) => {
1104
+ xe();
1105
+ const Z = [I.first_name, I.last_name].filter(Boolean).join(" ") || I.email;
1106
+ V.success(`${Z} removed as an owner`, {
1072
1107
  action: {
1073
1108
  label: "Undo",
1074
1109
  onClick: () => void c.request(
1075
- Te(`/pipelines/instance/${t}/${e}/owners`, {
1076
- user: m.user,
1077
- state: m.state || void 0
1110
+ We(`/pipelines/instance/${t}/${e}/owners`, {
1111
+ user: I.user,
1112
+ state: I.state || void 0
1078
1113
  })
1079
- ).then(() => re()).catch((D) => Y.error(Fe(D, "Could not add the owner back")))
1114
+ ).then(() => xe()).catch((J) => V.error(Ae(J, "Could not add the owner back")))
1080
1115
  }
1081
1116
  });
1082
1117
  },
1083
- onError: (a) => Y.error(Fe(a, "Failed to remove owner"))
1084
- }), de = (a) => {
1085
- var D, M;
1086
- const m = ((D = a.first_name) == null ? void 0 : D[0]) ?? "", N = ((M = a.last_name) == null ? void 0 : M[0]) ?? "";
1087
- return (`${m}${N}`.trim() || a.email[0] || "?").toUpperCase();
1088
- }, J = (a) => {
1089
- var m;
1090
- return a ? ((m = r.find((N) => N.id === a || N.key === a)) == null ? void 0 : m.label) ?? a : null;
1118
+ onError: (a) => V.error(Ae(a, "Failed to remove owner"))
1119
+ }), Y = (a) => {
1120
+ var J, fe;
1121
+ const I = ((J = a.first_name) == null ? void 0 : J[0]) ?? "", Z = ((fe = a.last_name) == null ? void 0 : fe[0]) ?? "";
1122
+ return (`${I}${Z}`.trim() || a.email[0] || "?").toUpperCase();
1123
+ }, z = (a) => {
1124
+ var I;
1125
+ return a ? ((I = r.find((Z) => Z.id === a || Z.key === a)) == null ? void 0 : I.label) ?? a : null;
1091
1126
  };
1092
1127
  return /* @__PURE__ */ i("div", { children: [
1093
1128
  /* @__PURE__ */ i("div", { className: "mb-3 flex items-center justify-between", children: [
1094
1129
  /* @__PURE__ */ i("span", { className: "flex items-center gap-1.5 text-[11px] font-medium text-slate-400", children: [
1095
- /* @__PURE__ */ n(At, { className: "h-3.5 w-3.5" }),
1130
+ /* @__PURE__ */ n(Yt, { className: "h-3.5 w-3.5" }),
1096
1131
  "Owners",
1097
- L || q ? /* @__PURE__ */ n("span", { className: "inline-block h-3 w-4 animate-pulse rounded bg-slate-200 dark:bg-[hsl(var(--nvr-skeleton))]" }) : ee ? null : /* @__PURE__ */ i("span", { className: "text-slate-300", children: [
1132
+ K || $ ? /* @__PURE__ */ n("span", { className: "inline-block h-3 w-4 animate-pulse rounded bg-slate-200 dark:bg-[hsl(var(--nvr-skeleton))]" }) : ce ? null : /* @__PURE__ */ i("span", { className: "text-slate-300", children: [
1098
1133
  "(",
1099
- g,
1134
+ b,
1100
1135
  ")"
1101
1136
  ] })
1102
1137
  ] }),
1103
1138
  /* @__PURE__ */ i("span", { className: "flex items-center gap-3", children: [
1104
- s && /* @__PURE__ */ n(jn, { collection: t, itemId: String(e) }),
1105
- !f && x && /* @__PURE__ */ i(
1139
+ s && /* @__PURE__ */ n(cr, { collection: t, itemId: String(e) }),
1140
+ !p && v && /* @__PURE__ */ i(
1106
1141
  "button",
1107
1142
  {
1108
1143
  type: "button",
1109
- onClick: () => _(!0),
1144
+ onClick: () => x(!0),
1110
1145
  className: "flex items-center gap-1 text-[11px] text-slate-400 transition-colors hover:text-nvr-cyan",
1111
1146
  children: [
1112
- /* @__PURE__ */ n(_n, { className: "h-3 w-3" }),
1147
+ /* @__PURE__ */ n(zn, { className: "h-3 w-3" }),
1113
1148
  "Add"
1114
1149
  ]
1115
1150
  }
1116
1151
  )
1117
1152
  ] })
1118
1153
  ] }),
1119
- L || q ? /* @__PURE__ */ i("div", { className: "flex items-center gap-2 py-1.5 text-[12px] text-slate-400", children: [
1120
- /* @__PURE__ */ n(me, { className: "h-3.5 w-3.5 animate-spin" }),
1154
+ K || $ ? /* @__PURE__ */ i("div", { className: "flex items-center gap-2 py-1.5 text-[12px] text-slate-400", children: [
1155
+ /* @__PURE__ */ n(ve, { className: "h-3.5 w-3.5 animate-spin" }),
1121
1156
  "Resolving owners…"
1122
- ] }) : ee ? /* @__PURE__ */ i("p", { className: "text-[12px] text-slate-500 dark:text-muted-foreground", children: [
1123
- l ? "Back with" : "With",
1157
+ ] }) : ce ? /* @__PURE__ */ i("p", { className: "text-[12px] text-slate-500 dark:text-muted-foreground", children: [
1158
+ o ? "Back with" : "With",
1124
1159
  " ",
1125
- /* @__PURE__ */ n(Kt, { userId: ee.id, children: /* @__PURE__ */ n(
1160
+ /* @__PURE__ */ n(on, { userId: ce.id, children: /* @__PURE__ */ n(
1126
1161
  "button",
1127
1162
  {
1128
1163
  type: "button",
1129
- "aria-label": `${ee.name} — profile`,
1164
+ "aria-label": `${ce.name} — profile`,
1130
1165
  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",
1131
- children: ee.name
1166
+ children: ce.name
1132
1167
  }
1133
1168
  ) })
1134
- ] }) : g === 0 ? /* @__PURE__ */ n("p", { className: "text-[12px] text-slate-400", children: "No owners assigned." }) : /* @__PURE__ */ i("div", { className: "space-y-px", children: [
1135
- Q.map((a) => {
1136
- var D, M;
1137
- const m = [a.first_name, a.last_name].filter(Boolean).join(" ") || a.email, N = (`${((D = a.first_name) == null ? void 0 : D[0]) ?? ""}${((M = a.last_name) == null ? void 0 : M[0]) ?? ""}`.trim() || a.email[0] || "?").toUpperCase();
1169
+ ] }) : b === 0 ? /* @__PURE__ */ n("p", { className: "text-[12px] text-slate-400", children: "No owners assigned." }) : /* @__PURE__ */ i("div", { className: "space-y-px", children: [
1170
+ X.map((a) => {
1171
+ var J, fe;
1172
+ const I = [a.first_name, a.last_name].filter(Boolean).join(" ") || a.email, Z = (`${((J = a.first_name) == null ? void 0 : J[0]) ?? ""}${((fe = a.last_name) == null ? void 0 : fe[0]) ?? ""}`.trim() || a.email[0] || "?").toUpperCase();
1138
1173
  return /* @__PURE__ */ i(
1139
1174
  "div",
1140
1175
  {
1141
1176
  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",
1142
1177
  children: [
1143
- /* @__PURE__ */ n(Dt, { userId: a.id, name: m, email: a.email, initials: N }),
1178
+ /* @__PURE__ */ n(Gt, { userId: a.id, name: I, email: a.email, initials: Z }),
1144
1179
  (() => {
1145
- const R = X.get(String(a.id).toUpperCase());
1146
- return R ? /* @__PURE__ */ n(
1180
+ const l = u.get(String(a.id).toUpperCase());
1181
+ return l ? /* @__PURE__ */ n(
1147
1182
  "span",
1148
1183
  {
1149
- "data-owner-unavailable": R.reason,
1150
- className: ye(
1184
+ "data-owner-unavailable": l.reason,
1185
+ className: ge(
1151
1186
  "shrink-0 rounded-full border px-1.5 py-0.5 text-[10px] font-medium",
1152
- R.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"
1187
+ 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"
1153
1188
  ),
1154
- "data-tip": R.delegate ? `${m} is ${Re[R.reason] ?? R.reason} — ${R.delegate.name} covers` : `${m} is ${Re[R.reason] ?? R.reason} and can't approve this step`,
1155
- children: R.delegate ? `${Re[R.reason] ?? R.reason} · ${R.delegate.name} covers` : Re[R.reason] ?? R.reason
1189
+ "data-tip": l.delegate ? `${I} is ${Le[l.reason] ?? l.reason} — ${l.delegate.name} covers` : `${I} is ${Le[l.reason] ?? l.reason} and can't approve this step`,
1190
+ children: l.delegate ? `${Le[l.reason] ?? l.reason} · ${l.delegate.name} covers` : Le[l.reason] ?? l.reason
1156
1191
  }
1157
1192
  ) : null;
1158
1193
  })(),
@@ -1169,31 +1204,31 @@ function ur({
1169
1204
  `group-${a.id}`
1170
1205
  );
1171
1206
  }),
1172
- (P ?? []).map((a) => /* @__PURE__ */ i(
1207
+ (E ?? []).map((a) => /* @__PURE__ */ i(
1173
1208
  "div",
1174
1209
  {
1175
1210
  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",
1176
1211
  children: [
1177
1212
  /* @__PURE__ */ n(
1178
- Dt,
1213
+ Gt,
1179
1214
  {
1180
1215
  userId: a.user,
1181
1216
  name: [a.first_name, a.last_name].filter(Boolean).join(" ") || a.email,
1182
1217
  email: a.email,
1183
- initials: de(a)
1218
+ initials: Y(a)
1184
1219
  }
1185
1220
  ),
1186
1221
  /* @__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" }),
1187
- /* @__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 ? J(a.state) : "all states" }),
1222
+ /* @__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 ? z(a.state) : "all states" }),
1188
1223
  /* @__PURE__ */ n(
1189
1224
  "button",
1190
1225
  {
1191
1226
  type: "button",
1192
1227
  "aria-label": `Remove ${[a.first_name, a.last_name].filter(Boolean).join(" ") || a.email} as an owner`,
1193
- disabled: C.isPending,
1194
- onClick: () => C.mutate(a),
1228
+ disabled: O.isPending,
1229
+ onClick: () => O.mutate(a),
1195
1230
  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",
1196
- children: /* @__PURE__ */ n(Ot, { className: "h-3 w-3" })
1231
+ children: /* @__PURE__ */ n(Jt, { className: "h-3 w-3" })
1197
1232
  }
1198
1233
  )
1199
1234
  ]
@@ -1201,36 +1236,36 @@ function ur({
1201
1236
  a.id
1202
1237
  ))
1203
1238
  ] }),
1204
- f && /* @__PURE__ */ i("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: [
1239
+ p && /* @__PURE__ */ i("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: [
1205
1240
  /* @__PURE__ */ n("p", { className: "text-[11px] font-semibold text-slate-500", children: "Add owner" }),
1206
- /* @__PURE__ */ n(cr, { value: v, onChange: y }),
1207
- b ? /* @__PURE__ */ i(dt, { open: E, onOpenChange: B, children: [
1208
- /* @__PURE__ */ n(ct, { asChild: !0, children: /* @__PURE__ */ i(
1241
+ /* @__PURE__ */ n(Ur, { value: k, onChange: R }),
1242
+ h ? /* @__PURE__ */ i(Nt, { open: j, onOpenChange: ne, children: [
1243
+ /* @__PURE__ */ n(_t, { asChild: !0, children: /* @__PURE__ */ i(
1209
1244
  "button",
1210
1245
  {
1211
1246
  type: "button",
1212
1247
  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",
1213
1248
  children: [
1214
- /* @__PURE__ */ n("span", { className: "truncate", children: $ ? ((_e = r.find((a) => a.id === $)) == null ? void 0 : _e.label) ?? $ : "All states" }),
1215
- /* @__PURE__ */ n($e, { className: "h-3.5 w-3.5 shrink-0 text-slate-400" })
1249
+ /* @__PURE__ */ n("span", { className: "truncate", children: _ ? ((Oe = r.find((a) => a.id === _)) == null ? void 0 : Oe.label) ?? _ : "All states" }),
1250
+ /* @__PURE__ */ n(Fe, { className: "h-3.5 w-3.5 shrink-0 text-slate-400" })
1216
1251
  ]
1217
1252
  }
1218
1253
  ) }),
1219
- /* @__PURE__ */ n(ut, { align: "start", sideOffset: 4, className: "w-52 p-1", children: ["", ...r.map((a) => a.id)].map((a) => {
1220
- var D;
1221
- const m = a === "" ? "All states" : ((D = r.find((M) => M.id === a)) == null ? void 0 : D.label) ?? a;
1254
+ /* @__PURE__ */ n(St, { align: "start", sideOffset: 4, className: "w-52 p-1", children: ["", ...r.map((a) => a.id)].map((a) => {
1255
+ var J;
1256
+ const I = a === "" ? "All states" : ((J = r.find((fe) => fe.id === a)) == null ? void 0 : J.label) ?? a;
1222
1257
  return /* @__PURE__ */ n(
1223
1258
  "button",
1224
1259
  {
1225
1260
  type: "button",
1226
- className: ye(
1261
+ className: ge(
1227
1262
  "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",
1228
- $ === a && "font-medium text-slate-800 dark:text-slate-200"
1263
+ _ === a && "font-medium text-slate-800 dark:text-slate-200"
1229
1264
  ),
1230
1265
  onClick: () => {
1231
- A(a), B(!1);
1266
+ U(a), ne(!1);
1232
1267
  },
1233
- children: m
1268
+ children: I
1234
1269
  },
1235
1270
  a
1236
1271
  );
@@ -1238,43 +1273,43 @@ function ur({
1238
1273
  ] }) : /* @__PURE__ */ n("p", { className: "text-[11px] text-slate-500 dark:text-slate-400", children: "Hands off the current step." }),
1239
1274
  /* @__PURE__ */ i("div", { className: "flex items-center justify-end gap-2 pt-0.5", children: [
1240
1275
  /* @__PURE__ */ n(
1241
- ae,
1276
+ ue,
1242
1277
  {
1243
1278
  type: "button",
1244
1279
  size: "sm",
1245
1280
  variant: "ghost",
1246
1281
  className: "h-7 text-[12px]",
1247
1282
  onClick: () => {
1248
- _(!1), y(""), A("");
1283
+ x(!1), R(""), U("");
1249
1284
  },
1250
1285
  children: "Cancel"
1251
1286
  }
1252
1287
  ),
1253
1288
  /* @__PURE__ */ n(
1254
- ae,
1289
+ ue,
1255
1290
  {
1256
1291
  type: "button",
1257
1292
  size: "sm",
1258
1293
  className: "h-7 text-[12px]",
1259
- disabled: !v || z.isPending,
1260
- onClick: () => z.mutate(),
1261
- children: z.isPending ? /* @__PURE__ */ n(me, { className: "h-3.5 w-3.5 animate-spin" }) : "Add"
1294
+ disabled: !k || le.isPending,
1295
+ onClick: () => le.mutate(),
1296
+ children: le.isPending ? /* @__PURE__ */ n(ve, { className: "h-3.5 w-3.5 animate-spin" }) : "Add"
1262
1297
  }
1263
1298
  )
1264
1299
  ] })
1265
1300
  ] })
1266
1301
  ] });
1267
1302
  }
1268
- function fn(t, e, r, s) {
1303
+ function Dn(t, e, r, s) {
1269
1304
  if (!t || !(r != null && r.length)) return null;
1270
- const c = new Map(r.map((f) => [String(f.id).toUpperCase(), f])).get(String(t.to_state).toUpperCase()), p = Number(e == null ? void 0 : e.sort);
1271
- if (!c || !Number.isFinite(p) || !(Number(c.sort) > p)) return null;
1272
- const b = Kn(String(t.to_state), r, s);
1273
- return b && b.skipped.length > 0 ? b : null;
1305
+ const c = new Map(r.map((p) => [String(p.id).toUpperCase(), p])).get(String(t.to_state).toUpperCase()), m = Number(e == null ? void 0 : e.sort);
1306
+ if (!c || !Number.isFinite(m) || !(Number(c.sort) > m)) return null;
1307
+ const h = hr(String(t.to_state), r, s);
1308
+ return h && h.skipped.length > 0 ? h : null;
1274
1309
  }
1275
- function hn({ landing: t }) {
1310
+ function Un({ landing: t }) {
1276
1311
  if (!t || t.skipped.length === 0) return null;
1277
- const e = Qn(t);
1312
+ const e = br(t);
1278
1313
  if (e.length === 1) {
1279
1314
  const r = e[0];
1280
1315
  return /* @__PURE__ */ i(
@@ -1287,7 +1322,7 @@ function hn({ landing: t }) {
1287
1322
  /* @__PURE__ */ n("span", { className: "font-medium", children: t.state.label }),
1288
1323
  " —",
1289
1324
  " ",
1290
- $t(r.labels),
1325
+ jt(r.labels),
1291
1326
  " ",
1292
1327
  r.labels.length === 1 ? "is" : "are",
1293
1328
  " skipped",
@@ -1309,114 +1344,114 @@ function hn({ landing: t }) {
1309
1344
  ". Skipped on the way:"
1310
1345
  ] }),
1311
1346
  /* @__PURE__ */ n("ul", { className: "mt-0.5 list-disc space-y-0.5 pl-4", children: e.map((r) => /* @__PURE__ */ i("li", { children: [
1312
- /* @__PURE__ */ n("span", { className: "font-medium", children: $t(r.labels) }),
1347
+ /* @__PURE__ */ n("span", { className: "font-medium", children: jt(r.labels) }),
1313
1348
  r.reason ? ` — ${r.reason}` : ""
1314
1349
  ] }, r.labels.join("|"))) })
1315
1350
  ]
1316
1351
  }
1317
1352
  );
1318
1353
  }
1319
- const Re = {
1354
+ const Le = {
1320
1355
  out: "out of office",
1321
1356
  suspended: "suspended",
1322
1357
  redacted: "redacted"
1323
1358
  };
1324
- function mr({
1359
+ function Lr({
1325
1360
  collection: t,
1326
1361
  item: e,
1327
1362
  states: r,
1328
1363
  currentStateId: s
1329
1364
  }) {
1330
- const l = we(), [c, p] = I(!1), { data: b, isLoading: f } = oe({
1365
+ const o = Pe(), [c, m] = Q(!1), { data: h, isLoading: p } = be({
1331
1366
  queryKey: ["pipeline-all-owners", t, e],
1332
- queryFn: () => l.request(
1333
- ce(`/pipelines/instance/${t}/${e}/owners/all`)
1334
- ).then((v) => v.data ?? null),
1367
+ queryFn: () => o.request(
1368
+ ye(`/pipelines/instance/${t}/${e}/owners/all`)
1369
+ ).then((k) => k.data ?? null),
1335
1370
  enabled: c,
1336
1371
  staleTime: 3e4
1337
- }), _ = [...r].filter((v) => {
1338
- var y;
1339
- return !b || ((y = b[v.id]) == null ? void 0 : y.on_path) !== !1;
1340
- }).sort((v, y) => v.sort - y.sort);
1341
- return /* @__PURE__ */ i(dt, { open: c, onOpenChange: p, children: [
1342
- /* @__PURE__ */ n(ct, { asChild: !0, children: /* @__PURE__ */ n(
1372
+ }), x = [...r].filter((k) => {
1373
+ var R;
1374
+ return !h || ((R = h[k.id]) == null ? void 0 : R.on_path) !== !1;
1375
+ }).sort((k, R) => k.sort - R.sort);
1376
+ return /* @__PURE__ */ i(Nt, { open: c, onOpenChange: m, children: [
1377
+ /* @__PURE__ */ n(_t, { asChild: !0, children: /* @__PURE__ */ n(
1343
1378
  "button",
1344
1379
  {
1345
1380
  type: "button",
1346
1381
  title: "View approval chain",
1347
1382
  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",
1348
- onClick: (v) => v.stopPropagation(),
1349
- children: /* @__PURE__ */ n(At, { className: "h-3.5 w-3.5" })
1383
+ onClick: (k) => k.stopPropagation(),
1384
+ children: /* @__PURE__ */ n(Yt, { className: "h-3.5 w-3.5" })
1350
1385
  }
1351
1386
  ) }),
1352
- /* @__PURE__ */ i(ut, { align: "end", sideOffset: 6, className: "w-[576px] p-0 overflow-hidden", children: [
1387
+ /* @__PURE__ */ i(St, { align: "end", sideOffset: 6, className: "w-[576px] p-0 overflow-hidden", children: [
1353
1388
  /* @__PURE__ */ i("div", { className: "border-b border-slate-100 px-4 py-3", children: [
1354
1389
  /* @__PURE__ */ n("p", { className: "text-[12px] font-semibold text-slate-700", children: "Approval Chain" }),
1355
1390
  /* @__PURE__ */ n("p", { className: "text-[11px] text-slate-400 mt-0.5", children: "Owners per pipeline state" })
1356
1391
  ] }),
1357
- /* @__PURE__ */ n("div", { className: "max-h-[504px] overflow-y-auto", children: f ? /* @__PURE__ */ n("div", { className: "space-y-px p-3", children: [1, 2, 3].map((v) => /* @__PURE__ */ n(ke, { className: "h-10 w-full" }, v)) }) : b ? /* @__PURE__ */ n("div", { className: "divide-y divide-slate-100 dark:divide-border/60", children: _.map((v) => {
1358
- var K, T, P, L, h;
1359
- const y = (((K = b[v.id]) == null ? void 0 : K.owners) ?? []).map((x) => ({
1360
- id: x.id,
1361
- name: [x.first_name, x.last_name].filter(Boolean).join(" ") || x.email
1362
- })), $ = v.id === s, A = ((T = b[v.id]) == null ? void 0 : T.skipped) === !0 && !$, E = (((P = b[v.id]) == null ? void 0 : P.skip_reasons) ?? []).filter(Boolean), B = ((L = b[v.id]) == null ? void 0 : L.unavailable) ?? [], H = ((h = b[v.id]) == null ? void 0 : h.blocked) === !0 && !A;
1392
+ /* @__PURE__ */ n("div", { className: "max-h-[504px] overflow-y-auto", children: p ? /* @__PURE__ */ n("div", { className: "space-y-px p-3", children: [1, 2, 3].map((k) => /* @__PURE__ */ n(Me, { className: "h-10 w-full" }, k)) }) : h ? /* @__PURE__ */ n("div", { className: "divide-y divide-slate-100 dark:divide-border/60", children: x.map((k) => {
1393
+ var ae, F, E, K, f;
1394
+ const R = (((ae = h[k.id]) == null ? void 0 : ae.owners) ?? []).map((v) => ({
1395
+ id: v.id,
1396
+ name: [v.first_name, v.last_name].filter(Boolean).join(" ") || v.email
1397
+ })), _ = k.id === s, U = ((F = h[k.id]) == null ? void 0 : F.skipped) === !0 && !_, j = (((E = h[k.id]) == null ? void 0 : E.skip_reasons) ?? []).filter(Boolean), ne = ((K = h[k.id]) == null ? void 0 : K.unavailable) ?? [], re = ((f = h[k.id]) == null ? void 0 : f.blocked) === !0 && !U;
1363
1398
  return /* @__PURE__ */ i(
1364
1399
  "div",
1365
1400
  {
1366
- className: ye(
1401
+ className: ge(
1367
1402
  "flex items-center gap-3 px-4 py-2.5",
1368
1403
  // Hex-with-alpha rather than bg-nvr-cyan/N — the
1369
1404
  // nvr-cyan token is an opaque var() so Tailwind silently
1370
1405
  // drops opacity modifiers on it. Kept very light so the
1371
1406
  // tint doesn't clash with the state badge's own color.
1372
- $ && "bg-nvr-cyan/[0.06] dark:bg-nvr-cyan/[0.11]",
1373
- A && "opacity-60",
1374
- H && "bg-red-50 dark:bg-red-500/10"
1407
+ _ && "bg-nvr-cyan/[0.06] dark:bg-nvr-cyan/[0.11]",
1408
+ U && "opacity-60",
1409
+ re && "bg-red-50 dark:bg-red-500/10"
1375
1410
  ),
1376
- "data-chain-blocked": H ? "" : void 0,
1411
+ "data-chain-blocked": re ? "" : void 0,
1377
1412
  children: [
1378
- /* @__PURE__ */ n(Ne, { label: v.label, color: v.color, small: !0 }),
1379
- /* @__PURE__ */ n("div", { className: "flex min-w-0 flex-1 flex-wrap items-center gap-x-2 gap-y-0.5", children: A ? (
1413
+ /* @__PURE__ */ n(Re, { label: k.label, color: k.color, small: !0 }),
1414
+ /* @__PURE__ */ n("div", { className: "flex min-w-0 flex-1 flex-wrap items-center gap-x-2 gap-y-0.5", children: U ? (
1380
1415
  // Radix tooltip with zero delay — native `title` waits on
1381
1416
  // the OS hover timer, and a truncated reason needs its
1382
1417
  // full text the moment the cursor lands on it.
1383
- /* @__PURE__ */ n(Qt, { delayDuration: 0, children: /* @__PURE__ */ i(nt, { children: [
1384
- /* @__PURE__ */ n(rt, { asChild: !0, children: /* @__PURE__ */ i("div", { className: "flex min-w-0 flex-1 cursor-default items-center gap-2", children: [
1418
+ /* @__PURE__ */ n(ln, { delayDuration: 0, children: /* @__PURE__ */ i(ft, { children: [
1419
+ /* @__PURE__ */ n(ht, { asChild: !0, children: /* @__PURE__ */ i("div", { className: "flex min-w-0 flex-1 cursor-default items-center gap-2", children: [
1385
1420
  /* @__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" }),
1386
- E.length > 0 && /* @__PURE__ */ n("span", { className: "min-w-0 flex-1 truncate text-[11px] text-slate-400 dark:text-slate-500", children: E.join(" · ") })
1421
+ j.length > 0 && /* @__PURE__ */ n("span", { className: "min-w-0 flex-1 truncate text-[11px] text-slate-400 dark:text-slate-500", children: j.join(" · ") })
1387
1422
  ] }) }),
1388
1423
  /* @__PURE__ */ i(
1389
- at,
1424
+ bt,
1390
1425
  {
1391
1426
  side: "bottom",
1392
1427
  align: "start",
1393
1428
  className: "max-w-[420px] space-y-0.5 text-[11.5px] leading-snug",
1394
1429
  children: [
1395
1430
  /* @__PURE__ */ n("p", { className: "text-slate-500 dark:text-slate-400", children: "The pipeline will pass through this state without stopping:" }),
1396
- E.length > 0 ? E.map((x) => /* @__PURE__ */ n("p", { children: x }, x)) : /* @__PURE__ */ n("p", { children: "Skip criteria currently match" })
1431
+ j.length > 0 ? j.map((v) => /* @__PURE__ */ n("p", { children: v }, v)) : /* @__PURE__ */ n("p", { children: "Skip criteria currently match" })
1397
1432
  ]
1398
1433
  }
1399
1434
  )
1400
1435
  ] }) })
1401
- ) : /* @__PURE__ */ i(xe, { children: [
1402
- /* @__PURE__ */ n(En, { owners: y, max: 10, emptyLabel: "—" }),
1403
- B.map((x) => /* @__PURE__ */ i(
1436
+ ) : /* @__PURE__ */ i(Se, { children: [
1437
+ /* @__PURE__ */ n(or, { owners: R, max: 10, emptyLabel: "—" }),
1438
+ ne.map((v) => /* @__PURE__ */ i(
1404
1439
  "span",
1405
1440
  {
1406
- "data-tip": `${x.name} is ${Re[x.reason] ?? x.reason}${x.delegate ? ` — ${x.delegate.name} covers${x.delegate.expires_at ? ` until ${Fn(x.delegate.expires_at)}` : ""}` : " and nobody is covering"}`,
1407
- className: ye(
1441
+ "data-tip": `${v.name} is ${Le[v.reason] ?? v.reason}${v.delegate ? ` — ${v.delegate.name} covers${v.delegate.expires_at ? ` until ${rr(v.delegate.expires_at)}` : ""}` : " and nobody is covering"}`,
1442
+ className: ge(
1408
1443
  "inline-flex items-center gap-1 rounded-full border px-1.5 py-0.5 text-[10.5px] font-medium",
1409
- x.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"
1444
+ v.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"
1410
1445
  ),
1411
1446
  children: [
1412
- x.name,
1413
- x.delegate ? /* @__PURE__ */ i(xe, { children: [
1447
+ v.name,
1448
+ v.delegate ? /* @__PURE__ */ i(Se, { children: [
1414
1449
  " → ",
1415
- x.delegate.name,
1416
- x.delegate.expires_at && /* @__PURE__ */ i("span", { className: "opacity-70", children: [
1450
+ v.delegate.name,
1451
+ v.delegate.expires_at && /* @__PURE__ */ i("span", { className: "opacity-70", children: [
1417
1452
  ", until",
1418
1453
  " ",
1419
- new Date(x.delegate.expires_at).toLocaleDateString(
1454
+ new Date(v.delegate.expires_at).toLocaleDateString(
1420
1455
  void 0,
1421
1456
  {
1422
1457
  month: "short",
@@ -1427,244 +1462,248 @@ function mr({
1427
1462
  ] }) : /* @__PURE__ */ i("span", { className: "opacity-80", children: [
1428
1463
  " ",
1429
1464
  "· ",
1430
- Re[x.reason] ?? x.reason
1465
+ Le[v.reason] ?? v.reason
1431
1466
  ] })
1432
1467
  ]
1433
1468
  },
1434
- x.id
1469
+ v.id
1435
1470
  )),
1436
- H && /* @__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" })
1471
+ re && /* @__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" })
1437
1472
  ] }) })
1438
1473
  ]
1439
1474
  },
1440
- v.id
1475
+ k.id
1441
1476
  );
1442
1477
  }) }) : /* @__PURE__ */ n("p", { className: "px-4 py-3 text-[12px] text-slate-400", children: "No pipeline configured." }) })
1443
1478
  ] })
1444
1479
  ] });
1445
1480
  }
1446
- function Hr({
1481
+ function Na({
1447
1482
  collection: t,
1448
1483
  item: e,
1449
1484
  defaultExpanded: r,
1450
1485
  title: s,
1451
- showApprovalChain: l,
1486
+ showApprovalChain: o,
1452
1487
  hideActionsCollapsed: c,
1453
- hideActionsExpanded: p,
1454
- onBeforeTransition: b,
1455
- addendumPending: f,
1456
- addendumView: _,
1457
- asRole: v
1488
+ hideActionsExpanded: m,
1489
+ onBeforeTransition: h,
1490
+ addendumPending: p,
1491
+ addendumView: x,
1492
+ asRole: k
1458
1493
  }) {
1459
1494
  return e === "new" ? null : /* @__PURE__ */ n(
1460
- pr,
1495
+ Er,
1461
1496
  {
1462
1497
  collection: t,
1463
1498
  item: e,
1464
1499
  defaultExpanded: r,
1465
1500
  title: s,
1466
- showApprovalChain: l,
1501
+ showApprovalChain: o,
1467
1502
  hideActionsCollapsed: c,
1468
- hideActionsExpanded: p,
1469
- onBeforeTransition: b,
1470
- addendumPending: f,
1471
- addendumView: _,
1472
- asRole: v
1503
+ hideActionsExpanded: m,
1504
+ onBeforeTransition: h,
1505
+ addendumPending: p,
1506
+ addendumView: x,
1507
+ asRole: k
1473
1508
  },
1474
1509
  `${t}:${e}`
1475
1510
  );
1476
1511
  }
1477
- function bn({
1512
+ function Bn({
1478
1513
  collection: t,
1479
1514
  item: e,
1480
1515
  omitLines: r
1481
1516
  }) {
1482
- const s = we(), { data: l } = oe({
1483
- queryKey: tn(t, e),
1484
- queryFn: () => nn(s, t, e),
1517
+ const s = Pe(), { data: o } = be({
1518
+ queryKey: _n(t, e),
1519
+ queryFn: () => Sn(s, t, e),
1485
1520
  staleTime: 3e4,
1486
1521
  retry: !1
1487
1522
  });
1488
- if (!l) return null;
1489
- const c = l.changed_by_people ?? l.changed_total, p = new Set((r ?? []).map(Mt)), b = (l.lines ?? []).filter((f) => !p.has(Mt(f)));
1523
+ if (!o) return null;
1524
+ const c = o.changed_by_people ?? o.changed_total, m = new Set((r ?? []).map(Wt)), h = (o.lines ?? []).filter((p) => !m.has(Wt(p)));
1490
1525
  return /* @__PURE__ */ i("div", { className: "rounded-md border border-slate-200 bg-white px-3 py-2 text-[11.5px] dark:border-border dark:bg-card", children: [
1491
1526
  /* @__PURE__ */ i("p", { className: "text-slate-500 dark:text-muted-foreground", children: [
1492
1527
  /* @__PURE__ */ n("span", { className: "font-medium text-slate-700 dark:text-foreground", children: "Since entering this state" }),
1493
1528
  " ",
1494
1529
  "(",
1495
- er(l.days_in_state),
1530
+ $r(o.days_in_state),
1496
1531
  "):",
1497
1532
  " ",
1498
- l.changed_total === 0 && l.comments === 0 && l.addendums.count === 0 ? /* @__PURE__ */ n("span", { children: "no changes to this record." }) : /* @__PURE__ */ i(xe, { children: [
1533
+ o.changed_total === 0 && o.comments === 0 && o.addendums.count === 0 ? /* @__PURE__ */ n("span", { children: "no changes to this record." }) : /* @__PURE__ */ i(Se, { children: [
1499
1534
  c > 0 && /* @__PURE__ */ i("span", { children: [
1500
1535
  c,
1501
1536
  " field",
1502
1537
  c === 1 ? "" : "s",
1503
1538
  " changed",
1504
- l.edited_by.length > 0 ? ` by ${l.edited_by.join(", ")}` : ""
1539
+ o.edited_by.length > 0 ? ` by ${o.edited_by.join(", ")}` : ""
1505
1540
  ] }),
1506
- c === 0 && l.changed_total > 0 && l.comments === 0 && l.addendums.count === 0 && /* @__PURE__ */ n("span", { children: "only values the record fills in itself changed." }),
1507
- l.comments > 0 && /* @__PURE__ */ i("span", { children: [
1541
+ c === 0 && o.changed_total > 0 && o.comments === 0 && o.addendums.count === 0 && /* @__PURE__ */ n("span", { children: "only values the record fills in itself changed." }),
1542
+ o.comments > 0 && /* @__PURE__ */ i("span", { children: [
1508
1543
  c > 0 ? " · " : "",
1509
- l.comments,
1544
+ o.comments,
1510
1545
  " comment",
1511
- l.comments === 1 ? "" : "s"
1546
+ o.comments === 1 ? "" : "s"
1512
1547
  ] }),
1513
- l.addendums.count > 0 && /* @__PURE__ */ i("span", { children: [
1548
+ o.addendums.count > 0 && /* @__PURE__ */ i("span", { children: [
1514
1549
  " · ",
1515
- l.addendums.count,
1550
+ o.addendums.count,
1516
1551
  " addendum",
1517
- l.addendums.count === 1 ? "" : "s",
1518
- l.addendums.cost_impact !== 0 ? ` (${l.addendums.cost_impact > 0 ? "+" : ""}$${Math.abs(l.addendums.cost_impact).toLocaleString()})` : ""
1552
+ o.addendums.count === 1 ? "" : "s",
1553
+ o.addendums.cost_impact !== 0 ? ` (${o.addendums.cost_impact > 0 ? "+" : ""}$${Math.abs(o.addendums.cost_impact).toLocaleString()})` : ""
1519
1554
  ] })
1520
1555
  ] })
1521
1556
  ] }),
1522
- l.field_changes.length > 0 && /* @__PURE__ */ i("div", { className: "mt-1 space-y-0.5", children: [
1523
- l.field_changes.slice(0, 5).map((f) => {
1524
- const _ = tr(f.old, f.new);
1557
+ o.field_changes.length > 0 && /* @__PURE__ */ i("div", { className: "mt-1 space-y-0.5", children: [
1558
+ o.field_changes.slice(0, 5).map((p) => {
1559
+ const x = Tr(p.old, p.new);
1525
1560
  return /* @__PURE__ */ i(
1526
1561
  "p",
1527
1562
  {
1528
- "data-brief-change": f.field,
1563
+ "data-brief-change": p.field,
1529
1564
  className: "text-[11px] text-slate-500 dark:text-muted-foreground",
1530
1565
  children: [
1531
- /* @__PURE__ */ n("span", { className: "font-medium text-slate-700 dark:text-foreground", children: f.label || Dn(f.field) }),
1532
- f.auto ? /* @__PURE__ */ n("span", { children: " (updated automatically)" }) : null,
1566
+ /* @__PURE__ */ n("span", { className: "font-medium text-slate-700 dark:text-foreground", children: p.label || nr(p.field) }),
1567
+ p.auto ? /* @__PURE__ */ n("span", { children: " (updated automatically)" }) : null,
1533
1568
  ":",
1534
1569
  " ",
1535
- _.old !== null && /* @__PURE__ */ i(xe, { children: [
1536
- /* @__PURE__ */ n("span", { className: "text-red-600 line-through dark:text-red-400", children: _.old }),
1570
+ x.old !== null && /* @__PURE__ */ i(Se, { children: [
1571
+ /* @__PURE__ */ n("span", { className: "text-red-600 line-through dark:text-red-400", children: x.old }),
1537
1572
  /* @__PURE__ */ n("span", { "aria-hidden": "true", children: " → " }),
1538
1573
  /* @__PURE__ */ n("span", { className: "sr-only", children: " changed to " })
1539
1574
  ] }),
1540
- /* @__PURE__ */ n("span", { className: "text-emerald-700 dark:text-emerald-400", children: _.new })
1575
+ /* @__PURE__ */ n("span", { className: "text-emerald-700 dark:text-emerald-400", children: x.new })
1541
1576
  ]
1542
1577
  },
1543
- f.field
1578
+ p.field
1544
1579
  );
1545
1580
  }),
1546
- l.field_changes.length > 5 && /* @__PURE__ */ i("p", { className: "text-[10.5px] text-slate-400", children: [
1581
+ o.field_changes.length > 5 && /* @__PURE__ */ i("p", { className: "text-[10.5px] text-slate-400", children: [
1547
1582
  "+",
1548
- l.field_changes.length - 5,
1583
+ o.field_changes.length - 5,
1549
1584
  " more — see History for the full trail"
1550
1585
  ] })
1551
1586
  ] }),
1552
- b.map((f) => /* @__PURE__ */ i(
1587
+ h.map((p) => /* @__PURE__ */ i(
1553
1588
  "p",
1554
1589
  {
1555
- "data-brief-line": f.label,
1590
+ "data-brief-line": p.label,
1556
1591
  className: "mt-1 text-slate-500 dark:text-muted-foreground",
1557
1592
  children: [
1558
- /* @__PURE__ */ n("span", { className: "font-medium text-slate-700 dark:text-foreground", children: f.label }),
1593
+ /* @__PURE__ */ n("span", { className: "font-medium text-slate-700 dark:text-foreground", children: p.label }),
1559
1594
  " ",
1560
1595
  /* @__PURE__ */ n(
1561
1596
  "span",
1562
1597
  {
1563
- className: f.tone === "danger" ? "text-red-700 dark:text-red-300" : f.tone === "warn" ? "text-amber-700 dark:text-amber-300" : "",
1564
- children: f.text
1598
+ className: p.tone === "danger" ? "text-red-700 dark:text-red-300" : p.tone === "warn" ? "text-amber-700 dark:text-amber-300" : "",
1599
+ children: p.text
1565
1600
  }
1566
1601
  )
1567
1602
  ]
1568
1603
  },
1569
- `${f.label}:${f.text}`
1604
+ `${p.label}:${p.text}`
1570
1605
  ))
1571
1606
  ] });
1572
1607
  }
1573
- function pr({
1608
+ function Er({
1574
1609
  collection: t,
1575
1610
  item: e,
1576
1611
  defaultExpanded: r,
1577
1612
  title: s,
1578
- showApprovalChain: l,
1613
+ showApprovalChain: o,
1579
1614
  hideActionsCollapsed: c,
1580
- hideActionsExpanded: p,
1581
- onBeforeTransition: b,
1582
- addendumPending: f,
1583
- addendumView: _,
1584
- asRole: v
1615
+ hideActionsExpanded: m,
1616
+ onBeforeTransition: h,
1617
+ addendumPending: p,
1618
+ addendumView: x,
1619
+ asRole: k
1585
1620
  }) {
1586
- var gt, xt, yt;
1587
- const y = we(), $ = De(), { isAdmin: A } = Bt(), [E, B] = I(0), H = ne(null);
1588
- fe(() => {
1589
- if (!A) return;
1590
- const u = (S) => {
1591
- const F = S.detail;
1592
- !F || F.claimed || F.collection !== t || String(F.item) !== String(e) || (F.claimed = !0, q(!0), B((W) => W + 1), setTimeout(
1621
+ var At, Ot, Dt;
1622
+ const R = Pe(), _ = ze(), { isAdmin: U } = nn(), [j, ne] = Q(0), re = de(null);
1623
+ _e(() => {
1624
+ if (!U) return;
1625
+ const d = (N) => {
1626
+ const C = N.detail;
1627
+ !C || C.claimed || C.collection !== t || String(C.item) !== String(e) || (C.claimed = !0, $(!0), ne((D) => D + 1), setTimeout(
1593
1628
  () => {
1594
- var W;
1595
- return (W = H.current) == null ? void 0 : W.scrollIntoView({ block: "center", behavior: "smooth" });
1629
+ var D;
1630
+ return (D = re.current) == null ? void 0 : D.scrollIntoView({ block: "center", behavior: "smooth" });
1596
1631
  },
1597
1632
  80
1598
1633
  ));
1599
1634
  };
1600
- return window.addEventListener(Nt, u), () => window.removeEventListener(Nt, u);
1601
- }, [A, t, e]);
1602
- const [K, T] = I(""), [P, L] = I(null), [h, x] = I(!1), [w, q] = I(!1), [o, Q] = I(null), [X, g] = I(null), [k, G] = I([]), se = rn(t, String(e));
1603
- It(t, e, "transition", !!P || !!o);
1604
- const ee = qn(t, e, "transition"), re = ne(!1);
1605
- fe(() => {
1606
- !re.current && r !== void 0 && (re.current = !0, q(r));
1635
+ return window.addEventListener(Lt, d), () => window.removeEventListener(Lt, d);
1636
+ }, [U, t, e]);
1637
+ const [ae, F] = Q(""), [E, K] = Q(null), [f, v] = Q(!1), [g, $] = Q(!1), [T, X] = Q(null), [u, b] = Q(null), [q, ee] = Q(null), [W, ce] = Q([]), xe = Cn(t, String(e));
1638
+ an(t, e, "transition", !!E || !!T);
1639
+ const le = Jn(t, e, "transition"), O = de(!1);
1640
+ _e(() => {
1641
+ !O.current && r !== void 0 && (O.current = !0, $(r));
1607
1642
  }, [r]);
1608
- const z = ne(!1), C = (u) => {
1609
- z.current || (z.current = !0, g(null), j.mutate(u, {
1610
- onSettled: (S, F) => {
1611
- if (F) {
1612
- z.current = !1;
1643
+ const Y = de(!1), z = (d) => {
1644
+ Y.current || (Y.current = !0, b(null), P.mutate(d, {
1645
+ onSettled: (N, C) => {
1646
+ if (C) {
1647
+ Y.current = !1;
1613
1648
  return;
1614
1649
  }
1615
- be().finally(() => {
1616
- z.current = !1;
1650
+ Oe().finally(() => {
1651
+ Y.current = !1;
1617
1652
  });
1618
1653
  }
1619
1654
  }));
1620
- }, de = async (u) => {
1621
- var Z, le;
1622
- if (z.current) return;
1623
- if (P === u) {
1624
- L(null);
1655
+ }, se = async (d, N) => {
1656
+ var pe, he;
1657
+ if (Y.current || a != null && a.running_move) return;
1658
+ if (E === d) {
1659
+ K(null);
1625
1660
  return;
1626
1661
  }
1627
- if (b) {
1628
- z.current = !0;
1629
- let te = !1;
1662
+ if (!(N != null && N.cleared) && ((a == null ? void 0 : a.available_transitions) ?? []).some((oe) => oe.id === d && oe.advisory)) {
1663
+ K(null), b(null), ee(d), _.invalidateQueries({ queryKey: ["pipeline-instance", t, e] });
1664
+ return;
1665
+ }
1666
+ if (ee(null), h) {
1667
+ Y.current = !0;
1668
+ let oe = !1;
1630
1669
  try {
1631
- te = await b();
1670
+ oe = await h();
1632
1671
  } finally {
1633
- z.current = !1;
1672
+ Y.current = !1;
1634
1673
  }
1635
- if (!te) return;
1674
+ if (!oe) return;
1636
1675
  }
1637
- const S = (ge ?? []).find((te) => te.id === u), F = String((S == null ? void 0 : S.comment_mode) ?? "none"), W = sn(S, (d == null ? void 0 : d.states) ?? [], (Z = d == null ? void 0 : d.instance) == null ? void 0 : Z.current_state);
1638
- if (F !== "optional" && F !== "required") {
1639
- if (S && !Oe(S, (d == null ? void 0 : d.states) ?? [], (le = d == null ? void 0 : d.instance) == null ? void 0 : le.current_state)) {
1640
- z.current = !0;
1641
- let te = [];
1676
+ const C = (H ?? []).find((oe) => oe.id === d), D = String((C == null ? void 0 : C.comment_mode) ?? "none"), te = $t(C, (a == null ? void 0 : a.states) ?? [], (pe = a == null ? void 0 : a.instance) == null ? void 0 : pe.current_state);
1677
+ if (D !== "optional" && D !== "required") {
1678
+ if (C && !He(C, (a == null ? void 0 : a.states) ?? [], (he = a == null ? void 0 : a.instance) == null ? void 0 : he.current_state)) {
1679
+ Y.current = !0;
1680
+ let oe = [];
1642
1681
  try {
1643
- te = await se();
1682
+ oe = await xe();
1644
1683
  } finally {
1645
- z.current = !1;
1684
+ Y.current = !1;
1646
1685
  }
1647
- if (te.length > 0 || W) {
1648
- G(te), L(u);
1686
+ if (oe.length > 0 || te) {
1687
+ ce(oe), K(d);
1649
1688
  return;
1650
1689
  }
1651
1690
  }
1652
- if (W) {
1653
- G([]), L(u);
1691
+ if (te) {
1692
+ ce([]), K(d);
1654
1693
  return;
1655
1694
  }
1656
- C({ transition_id: u });
1695
+ z({ transition_id: d });
1657
1696
  return;
1658
1697
  }
1659
- G([]), L(u);
1660
- }, J = v ? ["pipeline-instance", t, e, v] : ["pipeline-instance", t, e], { settling: he, settle: be } = Zt(J), { data: d, isLoading: _e } = oe({
1661
- queryKey: J,
1662
- queryFn: () => y.request(
1663
- ce(
1664
- `/pipelines/instance/${t}/${e}${v ? `?as_role=${encodeURIComponent(v)}` : ""}`
1698
+ ce([]), K(d);
1699
+ }, G = k ? ["pipeline-instance", t, e, k] : ["pipeline-instance", t, e], { settling: qe, settle: Oe } = kn(G), { data: a, isLoading: I } = be({
1700
+ queryKey: G,
1701
+ queryFn: () => R.request(
1702
+ ye(
1703
+ `/pipelines/instance/${t}/${e}${k ? `?as_role=${encodeURIComponent(k)}` : ""}`
1665
1704
  )
1666
1705
  ).then(
1667
- (u) => u.data ?? {
1706
+ (d) => d.data ?? {
1668
1707
  instance: null,
1669
1708
  states: [],
1670
1709
  available_transitions: [],
@@ -1673,441 +1712,530 @@ function pr({
1673
1712
  binding: null
1674
1713
  }
1675
1714
  ),
1676
- staleTime: 1e4
1677
- }), a = en(
1678
- d ? (d.available_transitions ?? []).map((u) => String(u.id)) : null,
1715
+ staleTime: 1e4,
1716
+ refetchInterval: (d) => un(d.state.data)
1717
+ });
1718
+ mn(!!(a != null && a.running_move), () => {
1719
+ Ee(_, t, String(e)), Ie(_, t, String(e)), et(_, t, String(e));
1720
+ });
1721
+ const Z = Nn(
1722
+ a ? (a.available_transitions ?? []).map((d) => String(d.id)) : null,
1679
1723
  `${t}:${e}`
1680
1724
  );
1681
- fe(
1682
- () => $.getQueryCache().subscribe((u) => {
1683
- if (u.type !== "updated" || u.action.type !== "success") return;
1684
- const S = u.query.queryKey;
1685
- Array.isArray(S) && S[0] === "item" && S[1] === t && String(S[2]) === e && $.invalidateQueries({ queryKey: ["pipeline-instance", t, e] });
1725
+ _e(
1726
+ () => _.getQueryCache().subscribe((d) => {
1727
+ if (d.type !== "updated" || d.action.type !== "success") return;
1728
+ const N = d.query.queryKey;
1729
+ Array.isArray(N) && N[0] === "item" && N[1] === t && String(N[2]) === e && _.invalidateQueries({ queryKey: ["pipeline-instance", t, e] });
1686
1730
  }),
1687
- [$, t, e]
1731
+ [_, t, e]
1688
1732
  );
1689
- const { data: m, isLoading: N } = oe({
1733
+ const { data: J, isLoading: fe } = be({
1690
1734
  queryKey: ["pipeline-all-owners", t, e],
1691
- queryFn: () => y.request(
1692
- ce(`/pipelines/instance/${t}/${e}/owners/all`)
1693
- ).then((u) => u.data ?? null),
1735
+ queryFn: () => R.request(
1736
+ ye(`/pipelines/instance/${t}/${e}/owners/all`)
1737
+ ).then((d) => d.data ?? null),
1694
1738
  // Also when a send back is on offer: its target may be a chain step this record skipped.
1695
1739
  // And while a move is being confirmed: the panel names where it really lands.
1696
- enabled: (w || on(d) || !!P) && !!(d != null && d.instance),
1740
+ enabled: (g || qn(a) || !!E) && !!(a != null && a.instance),
1697
1741
  staleTime: 3e4
1698
- }), D = Ie(() => {
1699
- if (!m) return null;
1700
- const u = Object.entries(m);
1701
- return u.length === 0 || u.every(([, S]) => S.on_path === void 0) ? null : new Set(u.filter(([, S]) => S.on_path !== !1).map(([S]) => S));
1702
- }, [m]), M = Ie(() => {
1703
- if (!m) return null;
1704
- const u = /* @__PURE__ */ new Map();
1705
- for (const [S, F] of Object.entries(m))
1706
- F.skipped && u.set(S, F.skip_reasons ?? []);
1707
- return u;
1708
- }, [m]), R = Pe({
1709
- mutationFn: () => y.request(Te(`/pipelines/instance/${t}/${e}/start`, {})),
1742
+ }), l = Je(() => {
1743
+ if (!J) return null;
1744
+ const d = Object.entries(J);
1745
+ return d.length === 0 || d.every(([, N]) => N.on_path === void 0) ? null : new Set(d.filter(([, N]) => N.on_path !== !1).map(([N]) => N));
1746
+ }, [J]), y = Je(() => {
1747
+ if (!J) return null;
1748
+ const d = /* @__PURE__ */ new Map();
1749
+ for (const [N, C] of Object.entries(J))
1750
+ C.skipped && d.set(N, C.skip_reasons ?? []);
1751
+ return d;
1752
+ }, [J]), w = je({
1753
+ mutationFn: () => R.request(We(`/pipelines/instance/${t}/${e}/start`, {})),
1710
1754
  onSuccess: () => {
1711
- $.invalidateQueries({ queryKey: J }), Y.success("Pipeline started");
1755
+ _.invalidateQueries({ queryKey: G }), V.success("Pipeline started");
1712
1756
  },
1713
- onError: () => Y.error("Failed to start pipeline")
1714
- }), j = Pe({
1757
+ onError: () => V.error("Failed to start pipeline")
1758
+ }), P = je({
1715
1759
  mutationFn: ({
1716
- transition_id: u,
1717
- comment: S,
1718
- reviewed: F,
1719
- lock_ack: W
1720
- }) => y.request(
1721
- Te(`/pipelines/instance/${t}/${e}/transition`, {
1722
- transition_id: u,
1723
- comment: S,
1724
- ...F ? { reviewed: !0 } : {},
1725
- ...W ? { lock_ack: !0 } : {}
1760
+ transition_id: d,
1761
+ comment: N,
1762
+ reviewed: C,
1763
+ lock_ack: D
1764
+ }) => R.request(
1765
+ We(`/pipelines/instance/${t}/${e}/transition`, {
1766
+ transition_id: d,
1767
+ comment: N,
1768
+ ...C ? { reviewed: !0 } : {},
1769
+ ...D ? { lock_ack: !0 } : {},
1770
+ ...fn(a == null ? void 0 : a.available_transitions, d)
1726
1771
  })
1727
1772
  ),
1728
- onMutate: (u) => {
1729
- var S;
1773
+ onMutate: (d) => {
1774
+ var N;
1730
1775
  return {
1731
- slow: un(
1732
- (S = [...(d == null ? void 0 : d.available_transitions) ?? [], ...(d == null ? void 0 : d.all_transitions) ?? []].find(
1733
- (F) => F.id === u.transition_id
1734
- )) == null ? void 0 : S.label
1776
+ slow: Pn(
1777
+ (N = [...(a == null ? void 0 : a.available_transitions) ?? [], ...(a == null ? void 0 : a.all_transitions) ?? []].find(
1778
+ (C) => C.id === d.transition_id
1779
+ )) == null ? void 0 : N.label
1735
1780
  )
1736
1781
  };
1737
1782
  },
1738
- onSuccess: (u, S, F) => {
1739
- $.invalidateQueries({ queryKey: J }), t === "nivaro_addendums" && $.invalidateQueries({ queryKey: ["addendums"] }), Qe($, t, String(e)), Ae($, t, String(e)), mn($, t, String(e)), g(null), T(""), L(null), Q(null), Y.success(cn(d, S.transition_id, u), F == null ? void 0 : F.slow.done());
1783
+ onSuccess: (d, N, C) => {
1784
+ _.invalidateQueries({ queryKey: G }), t === "nivaro_addendums" && _.invalidateQueries({ queryKey: ["addendums"] }), Ee(_, t, String(e)), Ie(_, t, String(e)), et(_, t, String(e)), b(null), F(""), K(null), X(null);
1785
+ const D = pn(d);
1786
+ D ? V.info(
1787
+ `${D.transition_label ?? "The move"} started. You will be told if it does not go through.`,
1788
+ C == null ? void 0 : C.slow.done()
1789
+ ) : V.success(Rn(a, N.transition_id, d), C == null ? void 0 : C.slow.done());
1740
1790
  },
1741
- onError: (u, S, F) => {
1742
- var te;
1743
- if (F == null || F.slow.fail(), Gt(u)) {
1744
- $.invalidateQueries({ queryKey: J });
1791
+ onError: (d, N, C) => {
1792
+ var oe, Ke;
1793
+ if (C == null || C.slow.fail(), xn(d)) {
1794
+ _.invalidateQueries({ queryKey: G });
1745
1795
  return;
1746
1796
  }
1747
- const W = Yt(u);
1748
- if (W) {
1749
- L(null);
1750
- const ve = ((te = [...(d == null ? void 0 : d.available_transitions) ?? [], ...(d == null ? void 0 : d.all_transitions) ?? []].find(
1751
- (Le) => Le.id === S.transition_id
1752
- )) == null ? void 0 : te.label) ?? "Move";
1753
- Y.warning(W.message, {
1797
+ if (nt(d) === "TRANSITION_RUNNING") {
1798
+ _.invalidateQueries({ queryKey: G }), K(null), X(null), V.info(Ae(d, "This move is already running on this record."));
1799
+ return;
1800
+ }
1801
+ const D = yn(d);
1802
+ if (D) {
1803
+ K(null);
1804
+ const ke = ((oe = [...(a == null ? void 0 : a.available_transitions) ?? [], ...(a == null ? void 0 : a.all_transitions) ?? []].find(
1805
+ (A) => A.id === N.transition_id
1806
+ )) == null ? void 0 : oe.label) ?? "Move";
1807
+ V.warning(D.message, {
1754
1808
  id: `nvr-locked-move:${t}:${String(e)}`,
1755
1809
  duration: 2e4,
1756
1810
  action: {
1757
- label: `${ve} anyway`,
1758
- onClick: () => C({ ...S, lock_ack: !0 })
1811
+ label: `${ke} anyway`,
1812
+ onClick: () => z({ ...N, lock_ack: !0 })
1759
1813
  },
1760
1814
  cancel: { label: "Wait", onClick: () => {
1761
1815
  } }
1762
1816
  });
1763
1817
  return;
1764
1818
  }
1765
- const Z = Vt(u);
1766
- if (Z) {
1767
- Q((ve) => ({
1768
- payload: Z,
1769
- transitionId: S.transition_id,
1770
- comment: S.comment,
1771
- revision: ((ve == null ? void 0 : ve.revision) ?? 0) + 1
1819
+ const te = vn(d);
1820
+ if (te) {
1821
+ X((ke) => ({
1822
+ payload: te,
1823
+ transitionId: N.transition_id,
1824
+ comment: N.comment,
1825
+ revision: ((ke == null ? void 0 : ke.revision) ?? 0) + 1
1772
1826
  }));
1773
1827
  return;
1774
1828
  }
1775
- const le = u == null ? void 0 : u.response;
1776
- g(Jt(u, S)), Y.error(Fe(u, "Failed to execute transition"), {
1829
+ const pe = d == null ? void 0 : d.response;
1830
+ b(wn(d, N));
1831
+ const he = sn(
1832
+ d,
1833
+ (Ke = [...(a == null ? void 0 : a.available_transitions) ?? [], ...(a == null ? void 0 : a.all_transitions) ?? []].find(
1834
+ (ke) => ke.id === N.transition_id
1835
+ )) == null ? void 0 : Ke.label
1836
+ );
1837
+ V.error((he == null ? void 0 : he.title) ?? Ae(d, "Failed to execute transition"), {
1777
1838
  duration: 12e3,
1778
1839
  // What to do next + Copy details (lib/error-toast.ts); "Why?" below wins the action slot.
1779
- ...jt(u, { action: "Transition" }),
1840
+ ...rn(d, { action: "Transition" }),
1841
+ ...he ? { description: he.description } : {},
1780
1842
  // #1867: a refusal carries "Why?" — the role, owner or access rule
1781
1843
  // that stopped it, and who can change it.
1782
- ...Wt(u) ? {
1783
- action: zt(y, {
1844
+ ...dn(d) ? {
1845
+ action: cn(R, {
1784
1846
  collection: t,
1785
1847
  itemId: String(e),
1786
1848
  action: "transition",
1787
- transitionId: S.transition_id
1849
+ transitionId: N.transition_id
1788
1850
  })
1789
1851
  } : {}
1790
- }), Q(null), L(null), Qe($, t, String(e)), Ae($, t, String(e)), (le == null ? void 0 : le.status) === 409 && $.invalidateQueries({ queryKey: J });
1852
+ }), X(null), K(null), Ee(_, t, String(e)), Ie(_, t, String(e)), (pe == null ? void 0 : pe.status) === 409 && _.invalidateQueries({ queryKey: G });
1791
1853
  }
1792
- }), ue = ne(de);
1793
- ue.current = de;
1794
- const U = ne((d == null ? void 0 : d.available_transitions) ?? []);
1795
- if (U.current = (d == null ? void 0 : d.available_transitions) ?? [], fe(() => {
1796
- const u = (S) => {
1797
- const F = S.detail;
1798
- if (!F || F.claimed || F.collection !== t || String(F.item) !== String(e)) return;
1799
- F.claimed = !0;
1800
- const W = String(F.transition_id).toUpperCase(), Z = U.current.find((le) => String(le.id).toUpperCase() === W);
1801
- if (!Z) {
1802
- Y.error("That step is not available from where the record is now");
1854
+ }), B = de(se);
1855
+ B.current = se;
1856
+ const ie = de((a == null ? void 0 : a.available_transitions) ?? []);
1857
+ if (ie.current = (a == null ? void 0 : a.available_transitions) ?? [], _e(() => {
1858
+ const d = (N) => {
1859
+ const C = N.detail;
1860
+ if (!C || C.claimed || C.collection !== t || String(C.item) !== String(e)) return;
1861
+ C.claimed = !0;
1862
+ const D = String(C.transition_id).toUpperCase(), te = ie.current.find((pe) => String(pe.id).toUpperCase() === D);
1863
+ if (!te) {
1864
+ V.error("That step is not available from where the record is now");
1803
1865
  return;
1804
1866
  }
1805
- ue.current(Z.id);
1867
+ B.current(te.id);
1806
1868
  };
1807
- return window.addEventListener(Ke, u), () => window.removeEventListener(Ke, u);
1808
- }, [t, e]), _e)
1869
+ return window.addEventListener(Ze, d), () => window.removeEventListener(Ze, d);
1870
+ }, [t, e]), I)
1809
1871
  return /* @__PURE__ */ n("div", { className: "overflow-hidden rounded-xl border border-slate-200 bg-white dark:border-border dark:bg-card", children: /* @__PURE__ */ i("div", { className: "flex w-full items-center gap-2.5 px-5 py-3.5", children: [
1810
- /* @__PURE__ */ n(ke, { className: "h-3.5 w-3.5 shrink-0 rounded" }),
1811
- /* @__PURE__ */ n(ke, { className: "h-4 w-20" }),
1812
- /* @__PURE__ */ n(ke, { className: "h-[22px] w-40 rounded-full" }),
1813
- /* @__PURE__ */ n(ke, { className: "ml-auto h-3.5 w-3.5 rounded" })
1872
+ /* @__PURE__ */ n(Me, { className: "h-3.5 w-3.5 shrink-0 rounded" }),
1873
+ /* @__PURE__ */ n(Me, { className: "h-4 w-20" }),
1874
+ /* @__PURE__ */ n(Me, { className: "h-[22px] w-40 rounded-full" }),
1875
+ /* @__PURE__ */ n(Me, { className: "ml-auto h-3.5 w-3.5 rounded" })
1814
1876
  ] }) });
1815
- if (!(d != null && d.binding)) return null;
1816
- const { instance: O, available_transitions: ge, history: Se, states: pe } = d, Ue = new Map((pe ?? []).map((u) => [u.id, u])), Ce = (O == null ? void 0 : O.current_state_obj) ?? null, ie = P ? (ge ?? []).find((u) => u.id === P) : null, gn = ie ? Ue.get(ie.to_state) : null, Ee = fn(ie, Ce, pe, m), ze = (Ee == null ? void 0 : Ee.state) ?? gn, xn = O != null && O.completed_at && ge ? ge.filter(
1817
- (u) => u.from_state && String(u.from_state).toUpperCase() === String(O.current_state).toUpperCase()
1818
- ) : null, He = O != null && O.completed_at ? xn ?? [] : dn(
1819
- ge ?? [],
1820
- pe ?? [],
1821
- O == null ? void 0 : O.current_state,
1822
- M
1823
- ), pt = He.length > 0, ft = (u, S = !1) => {
1824
- const F = /* @__PURE__ */ new Map();
1825
- for (const W of u) {
1826
- const Z = F.get(W.label) ?? [];
1827
- Z.push(W), F.set(W.label, Z);
1877
+ if (!(a != null && a.binding)) return null;
1878
+ const { instance: M, available_transitions: H, history: S, states: L } = a, Ce = new Map((L ?? []).map((d) => [d.id, d])), we = (M == null ? void 0 : M.current_state_obj) ?? null, me = E ? (H ?? []).find((d) => d.id === E) : null, Ln = me ? Ce.get(me.to_state) : null, Ge = Dn(me, we, L, J), rt = (Ge == null ? void 0 : Ge.state) ?? Ln, En = M != null && M.completed_at && H ? H.filter(
1879
+ (d) => d.from_state && String(d.from_state).toUpperCase() === String(M.current_state).toUpperCase()
1880
+ ) : null, De = M != null && M.completed_at ? En ?? [] : Mn(
1881
+ H ?? [],
1882
+ L ?? [],
1883
+ M == null ? void 0 : M.current_state,
1884
+ y
1885
+ ), at = De.length > 0, Tt = hn(De), Qe = q ? De.find((d) => d.id === q) : null, $e = (a == null ? void 0 : a.running_move) ?? null, Ve = $e ? null : (a == null ? void 0 : a.last_move_problem) ?? null, qt = Ve ? De.find((d) => gt(d.id, Ve.transition_id)) : null, Mt = (d, N = !1) => {
1886
+ const C = /* @__PURE__ */ new Map();
1887
+ for (const D of d) {
1888
+ const te = C.get(D.label) ?? [];
1889
+ te.push(D), C.set(D.label, te);
1828
1890
  }
1829
- return Array.from(F.entries()).map(([W, Z]) => {
1830
- var Le, wt;
1831
- const le = ((Le = Z[0]) == null ? void 0 : Le.color) ?? null, te = Z.some((V) => V.id === P), ve = (V) => le ? V ? { backgroundColor: le, borderColor: le } : { borderColor: le, color: le } : void 0;
1832
- if (Z.length === 1) {
1833
- const V = Z[0], qe = j.isPending && ((wt = j.variables) == null ? void 0 : wt.transition_id) === V.id;
1891
+ return Array.from(C.entries()).map(([D, te]) => {
1892
+ var Ke, ke;
1893
+ const pe = ((Ke = te[0]) == null ? void 0 : Ke.color) ?? null, he = te.some((A) => A.id === E), oe = (A) => pe ? A ? { backgroundColor: pe, borderColor: pe } : { borderColor: pe, color: pe } : void 0;
1894
+ if (te.length === 1) {
1895
+ const A = te[0], Te = P.isPending && ((ke = P.variables) == null ? void 0 : ke.transition_id) === A.id || gt($e == null ? void 0 : $e.transition_id, A.id);
1834
1896
  return /* @__PURE__ */ i(
1835
- ae,
1897
+ ue,
1836
1898
  {
1837
1899
  size: "sm",
1838
- variant: te ? "default" : "outline",
1839
- className: `${S ? "h-7 text-[11px]" : "text-[12px]"} gap-1.5 data-[fresh=true]:opacity-60`,
1840
- style: ve(te),
1841
- disabled: j.isPending || he,
1842
- "aria-disabled": a.dimmed(V.id) || void 0,
1843
- "data-fresh": a.dimmed(V.id) || void 0,
1844
- ...a.bind(V.id),
1900
+ variant: he && !A.advisory ? "default" : "outline",
1901
+ className: ge(
1902
+ N ? "h-7 text-[11px]" : "text-[12px]",
1903
+ "gap-1.5 data-[fresh=true]:opacity-60",
1904
+ A.advisory && Fn
1905
+ ),
1906
+ style: A.advisory ? void 0 : oe(he),
1907
+ disabled: P.isPending || qe || !!$e,
1908
+ "aria-disabled": Z.dimmed(A.id) || void 0,
1909
+ "data-fresh": Z.dimmed(A.id) || void 0,
1910
+ ...Z.bind(A.id),
1911
+ ...Be(A),
1845
1912
  onClick: () => {
1846
- a.press(V.id) && de(V.id);
1913
+ Z.press(A.id) && se(A.id);
1847
1914
  },
1848
1915
  children: [
1849
- qe && /* @__PURE__ */ n(me, { className: "h-3 w-3 animate-spin" }),
1850
- W
1916
+ Te ? /* @__PURE__ */ n(ve, { className: "h-3 w-3 animate-spin" }) : A.advisory && /* @__PURE__ */ n(Ne, {}),
1917
+ D
1851
1918
  ]
1852
1919
  },
1853
- W
1920
+ D
1854
1921
  );
1855
1922
  }
1856
- return /* @__PURE__ */ i(Ze, { children: [
1857
- /* @__PURE__ */ n(et, { asChild: !0, children: /* @__PURE__ */ i(
1858
- ae,
1923
+ return /* @__PURE__ */ i(ct, { children: [
1924
+ /* @__PURE__ */ n(ut, { asChild: !0, children: /* @__PURE__ */ i(
1925
+ ue,
1859
1926
  {
1860
1927
  size: "sm",
1861
- variant: te ? "default" : "outline",
1862
- className: `${S ? "h-7 text-[11px]" : "text-[12px]"} gap-1.5`,
1863
- style: ve(te),
1864
- disabled: j.isPending || he,
1928
+ variant: he ? "default" : "outline",
1929
+ className: `${N ? "h-7 text-[11px]" : "text-[12px]"} gap-1.5`,
1930
+ style: oe(he),
1931
+ disabled: P.isPending || qe || !!$e,
1865
1932
  children: [
1866
- W,
1867
- /* @__PURE__ */ n($e, { className: "h-3 w-3" })
1933
+ te.every((A) => A.advisory) && /* @__PURE__ */ n(Ne, {}),
1934
+ D,
1935
+ /* @__PURE__ */ n(Fe, { className: "h-3 w-3" })
1868
1936
  ]
1869
1937
  }
1870
1938
  ) }),
1871
- /* @__PURE__ */ n(tt, { align: "start", children: [...Z].sort(
1872
- (V, qe) => {
1873
- var vt, kt;
1874
- return (((vt = Ue.get(V.to_state)) == null ? void 0 : vt.sort) ?? 999) - (((kt = Ue.get(qe.to_state)) == null ? void 0 : kt.sort) ?? 999);
1875
- }
1876
- ).map((V) => {
1877
- var qe;
1878
- return /* @__PURE__ */ i(Be, { onSelect: () => de(V.id), children: [
1879
- V.color && /* @__PURE__ */ n(
1880
- "span",
1939
+ /* @__PURE__ */ i(mt, { align: "start", children: [
1940
+ [...te].sort(
1941
+ (A, Te) => {
1942
+ var Ut, Bt;
1943
+ return (((Ut = Ce.get(A.to_state)) == null ? void 0 : Ut.sort) ?? 999) - (((Bt = Ce.get(Te.to_state)) == null ? void 0 : Bt.sort) ?? 999);
1944
+ }
1945
+ ).map((A) => {
1946
+ var Te;
1947
+ return /* @__PURE__ */ i(
1948
+ Xe,
1881
1949
  {
1882
- className: "mr-2 inline-block h-2 w-2 shrink-0 rounded-full",
1883
- style: { backgroundColor: V.color }
1950
+ onSelect: () => se(A.id),
1951
+ ...Be(A, "menu"),
1952
+ children: [
1953
+ A.color && /* @__PURE__ */ n(
1954
+ "span",
1955
+ {
1956
+ className: "mr-2 inline-block h-2 w-2 shrink-0 rounded-full",
1957
+ style: { backgroundColor: A.color }
1958
+ }
1959
+ ),
1960
+ ((Te = Ce.get(A.to_state)) == null ? void 0 : Te.label) ?? A.to_state,
1961
+ A.advisory && /* @__PURE__ */ n(Ne, { className: "ml-auto" })
1962
+ ]
1963
+ },
1964
+ A.id
1965
+ );
1966
+ }),
1967
+ /* @__PURE__ */ n(
1968
+ yt,
1969
+ {
1970
+ moves: te,
1971
+ nameOf: (A) => {
1972
+ var Te;
1973
+ return ((Te = Ce.get(A.to_state)) == null ? void 0 : Te.label) ?? A.to_state;
1884
1974
  }
1885
- ),
1886
- ((qe = Ue.get(V.to_state)) == null ? void 0 : qe.label) ?? V.to_state
1887
- ] }, V.id);
1888
- }) })
1889
- ] }, W);
1975
+ }
1976
+ )
1977
+ ] })
1978
+ ] }, D);
1890
1979
  });
1891
- }, Ge = X ? /* @__PURE__ */ n(
1892
- pn,
1980
+ }, st = u ? /* @__PURE__ */ n(
1981
+ On,
1893
1982
  {
1894
1983
  collection: t,
1895
1984
  item: String(e),
1896
- offer: X,
1897
- onDismiss: () => g(null),
1898
- onFixed: () => C({ transition_id: X.transitionId, comment: X.comment })
1985
+ offer: u,
1986
+ onDismiss: () => b(null),
1987
+ onFixed: () => z({ transition_id: u.transitionId, comment: u.comment })
1899
1988
  }
1900
- ) : null, ht = sr(Se ?? [], O == null ? void 0 : O.current_state, pe ?? []), bt = /* @__PURE__ */ i("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: [
1989
+ ) : null, In = g && !m && !!M && at, Rt = (d) => /* @__PURE__ */ i(Se, { children: [
1990
+ Tt.map(({ advisory: N, moves: C }) => /* @__PURE__ */ n(
1991
+ bn,
1992
+ {
1993
+ collection: t,
1994
+ item: String(e),
1995
+ advisory: N,
1996
+ armedMove: Qe && C.some((D) => D.id === Qe.id) ? {
1997
+ id: Qe.id,
1998
+ label: Qe.label,
1999
+ confirms: An(Qe, L ?? [], M == null ? void 0 : M.current_state)
2000
+ } : null,
2001
+ stops: Tt.length > 1 ? [...new Set(C.map((D) => D.label))] : void 0,
2002
+ className: d ? "rounded-lg border border-amber-200/80 px-3 dark:border-amber-500/20" : void 0,
2003
+ onDismiss: () => ee(null),
2004
+ onFixed: (D) => {
2005
+ ee(null), _.invalidateQueries({ queryKey: G }), D && se(D.id, { cleared: !0 });
2006
+ }
2007
+ },
2008
+ `${N.code}:${N.message}`
2009
+ )),
2010
+ $e && /* @__PURE__ */ n(
2011
+ mr,
2012
+ {
2013
+ run: $e,
2014
+ className: d ? "rounded-lg border border-sky-200/80 px-3 dark:border-sky-500/20" : void 0
2015
+ }
2016
+ ),
2017
+ Ve && /* @__PURE__ */ n(
2018
+ pr,
2019
+ {
2020
+ problem: Ve,
2021
+ retryDisabled: P.isPending || qe,
2022
+ onRetry: qt ? () => void se(qt.id) : void 0,
2023
+ className: d ? "rounded-lg border border-amber-200/80 px-3 dark:border-amber-500/20" : void 0
2024
+ }
2025
+ )
2026
+ ] }), Pt = Pr(S ?? [], M == null ? void 0 : M.current_state, L ?? []), Ft = /* @__PURE__ */ i("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: [
1901
2027
  /* @__PURE__ */ i("div", { className: "flex flex-wrap items-center gap-2", children: [
1902
2028
  /* @__PURE__ */ n("span", { className: "text-[11px] font-semibold text-slate-400", children: "Confirming" }),
1903
- ie && /* @__PURE__ */ n("span", { className: "text-[12px] font-medium text-slate-700", children: ie.label }),
1904
- Ce && ze && /* @__PURE__ */ i("div", { className: "ml-auto flex items-center gap-1.5", children: [
1905
- /* @__PURE__ */ n(Ne, { label: Ce.label, color: Ce.color, small: !0 }),
1906
- /* @__PURE__ */ n(lt, { className: "h-3 w-3 shrink-0 text-slate-300" }),
1907
- /* @__PURE__ */ n(Ne, { label: ze.label, color: ze.color, small: !0 })
2029
+ me && /* @__PURE__ */ n("span", { className: "text-[12px] font-medium text-slate-700", children: me.label }),
2030
+ we && rt && /* @__PURE__ */ i("div", { className: "ml-auto flex items-center gap-1.5", children: [
2031
+ /* @__PURE__ */ n(Re, { label: we.label, color: we.color, small: !0 }),
2032
+ /* @__PURE__ */ n(wt, { className: "h-3 w-3 shrink-0 text-slate-300" }),
2033
+ /* @__PURE__ */ n(Re, { label: rt.label, color: rt.color, small: !0 })
1908
2034
  ] })
1909
2035
  ] }),
1910
- /* @__PURE__ */ n(hn, { landing: Ee }),
1911
- /* @__PURE__ */ n(ln, { collection: t, item: String(e), tx: ie }),
1912
- /* @__PURE__ */ n(bn, { collection: t, item: e, omitLines: k }),
1913
- /* @__PURE__ */ n(an, { lines: k }),
2036
+ /* @__PURE__ */ n(Un, { landing: Ge }),
2037
+ /* @__PURE__ */ n(Tn, { collection: t, item: String(e), tx: me }),
2038
+ /* @__PURE__ */ n(Bn, { collection: t, item: e, omitLines: W }),
2039
+ /* @__PURE__ */ n($n, { lines: W }),
1914
2040
  /* @__PURE__ */ n(
1915
2041
  "input",
1916
2042
  {
1917
2043
  type: "text",
1918
- value: K,
1919
- onChange: (u) => T(u.target.value),
1920
- placeholder: String((ie == null ? void 0 : ie.comment_mode) ?? "") === "required" ? "Add a note (required)" : "Add a comment (optional)",
2044
+ value: ae,
2045
+ onChange: (d) => F(d.target.value),
2046
+ placeholder: String((me == null ? void 0 : me.comment_mode) ?? "") === "required" ? "Add a note (required)" : "Add a comment (optional)",
1921
2047
  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"
1922
2048
  }
1923
2049
  ),
1924
2050
  /* @__PURE__ */ i("div", { className: "flex items-center justify-end gap-2", children: [
1925
2051
  /* @__PURE__ */ n(
1926
- ae,
2052
+ ue,
1927
2053
  {
1928
2054
  type: "button",
1929
2055
  size: "sm",
1930
2056
  variant: "ghost",
1931
2057
  className: "h-7 text-[12px]",
1932
- onClick: () => L(null),
2058
+ onClick: () => K(null),
1933
2059
  children: "Cancel"
1934
2060
  }
1935
2061
  ),
1936
2062
  /* @__PURE__ */ n(
1937
- ae,
2063
+ ue,
1938
2064
  {
1939
2065
  type: "button",
1940
2066
  size: "sm",
1941
2067
  className: "h-7 gap-1.5 text-[12px]",
1942
- disabled: j.isPending || String((ie == null ? void 0 : ie.comment_mode) ?? "") === "required" && K.trim() === "",
1943
- onClick: () => C({
1944
- transition_id: P,
1945
- comment: K.trim() || void 0
2068
+ disabled: P.isPending || !!$e || String((me == null ? void 0 : me.comment_mode) ?? "") === "required" && ae.trim() === "",
2069
+ onClick: () => z({
2070
+ transition_id: E,
2071
+ comment: ae.trim() || void 0
1946
2072
  }),
1947
- children: j.isPending ? /* @__PURE__ */ n(me, { className: "h-3.5 w-3.5 animate-spin" }) : /* @__PURE__ */ i(xe, { children: [
1948
- /* @__PURE__ */ n("span", { children: k.length > 0 && ie ? `${ie.label} anyway` : "Confirm" }),
1949
- /* @__PURE__ */ n(We, { className: "h-3 w-3" })
2073
+ children: P.isPending ? /* @__PURE__ */ n(ve, { className: "h-3.5 w-3.5 animate-spin" }) : /* @__PURE__ */ i(Se, { children: [
2074
+ /* @__PURE__ */ n("span", { children: W.length > 0 && me ? `${me.label} anyway` : "Confirm" }),
2075
+ /* @__PURE__ */ n(tt, { className: "h-3 w-3" })
1950
2076
  ] })
1951
2077
  }
1952
2078
  )
1953
2079
  ] })
1954
2080
  ] });
1955
- return /* @__PURE__ */ i(xe, { children: [
2081
+ return /* @__PURE__ */ i(Se, { children: [
1956
2082
  /* @__PURE__ */ i(
1957
2083
  "div",
1958
2084
  {
1959
- className: `overflow-hidden rounded-xl border bg-white dark:bg-card ${_ ? "border-amber-300 dark:border-amber-600/50" : "border-slate-200 dark:border-border"}`,
2085
+ className: `overflow-hidden rounded-xl border bg-white dark:bg-card ${x ? "border-amber-300 dark:border-amber-600/50" : "border-slate-200 dark:border-border"}`,
1960
2086
  children: [
1961
2087
  /* @__PURE__ */ i(
1962
2088
  "div",
1963
2089
  {
1964
2090
  role: "button",
1965
2091
  tabIndex: 0,
1966
- onClick: () => q((u) => !u),
1967
- onKeyDown: (u) => (u.key === "Enter" || u.key === " ") && q((S) => !S),
2092
+ onClick: () => $((d) => !d),
2093
+ onKeyDown: (d) => (d.key === "Enter" || d.key === " ") && $((N) => !N),
1968
2094
  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]",
1969
2095
  children: [
1970
- /* @__PURE__ */ n(Xe, { className: "h-3.5 w-3.5 shrink-0 text-slate-400" }),
2096
+ /* @__PURE__ */ n(ot, { className: "h-3.5 w-3.5 shrink-0 text-slate-400" }),
1971
2097
  /* @__PURE__ */ n("span", { className: "text-[13px] font-medium text-slate-800 dark:text-slate-200", children: s || "Pipeline" }),
1972
2098
  /* @__PURE__ */ i("div", { className: "flex items-center gap-1.5", children: [
1973
- _ && /* @__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" }),
1974
- Ce && /* @__PURE__ */ n(Ne, { label: Ce.label, color: Ce.color }),
1975
- /* @__PURE__ */ n(rr, { flags: d == null ? void 0 : d.flags }),
1976
- (((gt = d == null ? void 0 : d.auto_held) == null ? void 0 : gt.length) ?? 0) > 0 && /* @__PURE__ */ i(
2099
+ x && /* @__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" }),
2100
+ we && /* @__PURE__ */ n(Re, { label: we.label, color: we.color }),
2101
+ /* @__PURE__ */ n(Mr, { flags: a == null ? void 0 : a.flags }),
2102
+ (((At = a == null ? void 0 : a.auto_held) == null ? void 0 : At.length) ?? 0) > 0 && /* @__PURE__ */ i(
1977
2103
  "span",
1978
2104
  {
1979
2105
  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",
1980
- "data-tip": ((d == null ? void 0 : d.auto_held) ?? []).map((u) => `${u.transition_label ?? "Automatic move"}: ${u.error ?? "refused"}`).join(`
2106
+ "data-tip": ((a == null ? void 0 : a.auto_held) ?? []).map((d) => `${d.transition_label ?? "Automatic move"}: ${d.error ?? "refused"}`).join(`
1981
2107
  `),
1982
2108
  "data-pipeline-auto-held-pill": !0,
1983
2109
  children: [
1984
- /* @__PURE__ */ n(vn, { className: "h-3 w-3 shrink-0" }),
2110
+ /* @__PURE__ */ n(Vt, { className: "h-3 w-3 shrink-0" }),
1985
2111
  "Needs a person"
1986
2112
  ]
1987
2113
  }
1988
2114
  ),
1989
- f && /* @__PURE__ */ i("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: [
2115
+ p && /* @__PURE__ */ i("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: [
1990
2116
  /* @__PURE__ */ n("span", { className: "h-1.5 w-1.5 rounded-full bg-amber-400 animate-pulse shrink-0" }),
1991
2117
  "Addendum in review"
1992
2118
  ] }),
1993
- ee.length > 0 && /* @__PURE__ */ i(
2119
+ le.length > 0 && /* @__PURE__ */ i(
1994
2120
  "span",
1995
2121
  {
1996
2122
  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",
1997
2123
  "data-pipeline-approving": !0,
1998
2124
  children: [
1999
2125
  /* @__PURE__ */ n("span", { className: "h-1.5 w-1.5 shrink-0 animate-pulse rounded-full bg-sky-400" }),
2000
- Mn(ee, "approving")
2126
+ Zn(le, "approving")
2001
2127
  ]
2002
2128
  }
2003
2129
  )
2004
2130
  ] }),
2005
- /* @__PURE__ */ i("div", { className: "ml-auto flex items-center gap-2", onClick: (u) => u.stopPropagation(), children: [
2006
- !w && pt && !c && /* @__PURE__ */ n("div", { className: "flex flex-wrap items-center gap-1.5", children: ft(He, !0) }),
2007
- !w && !O && (d == null ? void 0 : d.binding) && /* @__PURE__ */ i(
2008
- ae,
2131
+ /* @__PURE__ */ i("div", { className: "ml-auto flex items-center gap-2", onClick: (d) => d.stopPropagation(), children: [
2132
+ !g && at && !c && /* @__PURE__ */ n("div", { className: "flex flex-wrap items-center gap-1.5", children: Mt(De, !0) }),
2133
+ !g && !M && (a == null ? void 0 : a.binding) && /* @__PURE__ */ i(
2134
+ ue,
2009
2135
  {
2010
2136
  size: "sm",
2011
2137
  variant: "outline",
2012
2138
  className: "h-7 gap-1.5 text-[11px]",
2013
- onClick: (u) => {
2014
- u.stopPropagation(), R.mutate();
2139
+ onClick: (d) => {
2140
+ d.stopPropagation(), w.mutate();
2015
2141
  },
2016
- disabled: R.isPending,
2142
+ disabled: w.isPending,
2017
2143
  children: [
2018
- R.isPending ? /* @__PURE__ */ n(me, { className: "h-3 w-3 animate-spin" }) : /* @__PURE__ */ n(Xe, { className: "h-3 w-3" }),
2144
+ w.isPending ? /* @__PURE__ */ n(ve, { className: "h-3 w-3 animate-spin" }) : /* @__PURE__ */ n(ot, { className: "h-3 w-3" }),
2019
2145
  "Start"
2020
2146
  ]
2021
2147
  }
2022
2148
  ),
2023
- l && ((d == null ? void 0 : d.binding) || (d == null ? void 0 : d.instance)) && /* @__PURE__ */ n(
2024
- mr,
2149
+ o && ((a == null ? void 0 : a.binding) || (a == null ? void 0 : a.instance)) && /* @__PURE__ */ n(
2150
+ Lr,
2025
2151
  {
2026
2152
  collection: t,
2027
2153
  item: e,
2028
- states: pe ?? [],
2029
- currentStateId: ((xt = d == null ? void 0 : d.instance) == null ? void 0 : xt.current_state) ?? null
2154
+ states: L ?? [],
2155
+ currentStateId: ((Ot = a == null ? void 0 : a.instance) == null ? void 0 : Ot.current_state) ?? null
2030
2156
  }
2031
2157
  )
2032
2158
  ] }),
2033
2159
  /* @__PURE__ */ n(
2034
- $e,
2160
+ Fe,
2035
2161
  {
2036
- className: ye(
2162
+ className: ge(
2037
2163
  "h-3.5 w-3.5 shrink-0 text-slate-400 transition-transform duration-150",
2038
- w && "rotate-180"
2164
+ g && "rotate-180"
2039
2165
  )
2040
2166
  }
2041
2167
  )
2042
2168
  ]
2043
2169
  }
2044
2170
  ),
2045
- !w && P && /* @__PURE__ */ n("div", { className: "border-t border-slate-100 dark:border-border/60 px-4 py-3", children: bt }),
2046
- !w && Ge && /* @__PURE__ */ n("div", { className: "border-t border-slate-100 dark:border-border/60 px-4 py-3", children: Ge }),
2047
- ht && !(O != null && O.completed_at) && /* @__PURE__ */ n(ir, { entry: ht }),
2048
- w && /* @__PURE__ */ i("div", { className: "border-t border-slate-100 dark:border-border/60", children: [
2049
- /* @__PURE__ */ n(Vn, { held: (d == null ? void 0 : d.auto_held) ?? [] }),
2050
- f && /* @__PURE__ */ i("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: [
2171
+ !In && Rt(!1),
2172
+ !g && E && /* @__PURE__ */ n("div", { className: "border-t border-slate-100 dark:border-border/60 px-4 py-3", children: Ft }),
2173
+ !g && st && /* @__PURE__ */ n("div", { className: "border-t border-slate-100 dark:border-border/60 px-4 py-3", children: st }),
2174
+ Pt && !(M != null && M.completed_at) && /* @__PURE__ */ n(Fr, { entry: Pt }),
2175
+ g && /* @__PURE__ */ i("div", { className: "border-t border-slate-100 dark:border-border/60", children: [
2176
+ /* @__PURE__ */ n(Nr, { held: (a == null ? void 0 : a.auto_held) ?? [] }),
2177
+ p && /* @__PURE__ */ i("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: [
2051
2178
  /* @__PURE__ */ n("span", { className: "h-1.5 w-1.5 rounded-full bg-amber-400 shrink-0" }),
2052
2179
  /* @__PURE__ */ n("p", { className: "text-[12px] text-amber-700 dark:text-amber-400", children: "An addendum is in review — coordinate transitions carefully." })
2053
2180
  ] }),
2054
- O ? /* @__PURE__ */ i("div", { className: "divide-y divide-slate-100 dark:divide-border/60", children: [
2055
- (pe ?? []).length > 1 && /* @__PURE__ */ i("div", { className: "space-y-3 px-5 py-4", children: [
2056
- N ? (
2181
+ M ? /* @__PURE__ */ i("div", { className: "divide-y divide-slate-100 dark:divide-border/60", children: [
2182
+ (L ?? []).length > 1 && /* @__PURE__ */ i("div", { className: "space-y-3 px-5 py-4", children: [
2183
+ fe ? (
2057
2184
  // Path pruning arrives with the owners query — rendering
2058
2185
  // the UNPRUNED track first meant every state briefly
2059
2186
  // showed, then snapped into formation. Hold a same-height
2060
2187
  // placeholder until the real shape is known.
2061
2188
  /* @__PURE__ */ i("div", { className: "flex h-[52px] items-center gap-2", children: [
2062
- [0, 1, 2, 3, 4].map((u) => /* @__PURE__ */ i("span", { className: "flex items-center gap-2", children: [
2063
- /* @__PURE__ */ n(ke, { className: "h-7 w-7 rounded-full" }),
2064
- u < 4 && /* @__PURE__ */ n(ke, { className: "h-0.5 w-10" })
2065
- ] }, u)),
2066
- /* @__PURE__ */ n(ke, { className: "ml-2 h-3 w-24" })
2189
+ [0, 1, 2, 3, 4].map((d) => /* @__PURE__ */ i("span", { className: "flex items-center gap-2", children: [
2190
+ /* @__PURE__ */ n(Me, { className: "h-7 w-7 rounded-full" }),
2191
+ d < 4 && /* @__PURE__ */ n(Me, { className: "h-0.5 w-10" })
2192
+ ] }, d)),
2193
+ /* @__PURE__ */ n(Me, { className: "ml-2 h-3 w-24" })
2067
2194
  ] })
2068
2195
  ) : /* @__PURE__ */ n(
2069
- or,
2196
+ Or,
2070
2197
  {
2071
- states: pe,
2072
- allTransitions: (d == null ? void 0 : d.all_transitions) ?? [],
2073
- availableTransitions: ge ?? [],
2074
- currentStateId: O.current_state,
2075
- history: Se ?? [],
2076
- onPathIds: D,
2077
- skippedStates: M
2198
+ states: L,
2199
+ allTransitions: (a == null ? void 0 : a.all_transitions) ?? [],
2200
+ availableTransitions: H ?? [],
2201
+ currentStateId: M.current_state,
2202
+ history: S ?? [],
2203
+ onPathIds: l,
2204
+ skippedStates: y
2078
2205
  }
2079
2206
  ),
2080
- (d == null ? void 0 : d.branches) && /* @__PURE__ */ n(In, { data: d.branches }),
2207
+ (a == null ? void 0 : a.branches) && /* @__PURE__ */ n(fr, { data: a.branches }),
2081
2208
  /* @__PURE__ */ n(
2082
- lr,
2209
+ Ar,
2083
2210
  {
2084
- history: Se ?? [],
2085
- completedAt: O.completed_at
2211
+ history: S ?? [],
2212
+ completedAt: M.completed_at
2086
2213
  }
2087
2214
  )
2088
2215
  ] }),
2089
2216
  /* @__PURE__ */ i("div", { className: "space-y-3 px-5 py-4", children: [
2090
- !O.completed_at && /* @__PURE__ */ n(zn, { collection: t, itemId: String(e) }),
2217
+ !M.completed_at && /* @__PURE__ */ n(yr, { collection: t, itemId: String(e) }),
2091
2218
  /* @__PURE__ */ n(
2092
- ur,
2219
+ Br,
2093
2220
  {
2094
2221
  collection: t,
2095
2222
  item: e,
2096
- states: pe ?? [],
2097
- currentStateId: ((yt = d == null ? void 0 : d.instance) == null ? void 0 : yt.current_state) ?? null,
2098
- returned: ((d == null ? void 0 : d.history) ?? []).some(
2099
- (u) => {
2100
- var S;
2101
- return !!u.from_state && u.to_state === ((S = d == null ? void 0 : d.instance) == null ? void 0 : S.current_state);
2223
+ states: L ?? [],
2224
+ currentStateId: ((Dt = a == null ? void 0 : a.instance) == null ? void 0 : Dt.current_state) ?? null,
2225
+ returned: ((a == null ? void 0 : a.history) ?? []).some(
2226
+ (d) => {
2227
+ var N;
2228
+ return !!d.from_state && d.to_state === ((N = a == null ? void 0 : a.instance) == null ? void 0 : N.current_state);
2102
2229
  }
2103
2230
  )
2104
2231
  }
2105
2232
  )
2106
2233
  ] }),
2107
- pt && !p && /* @__PURE__ */ i("div", { className: "space-y-3 px-5 py-4", children: [
2108
- /* @__PURE__ */ n("div", { className: "flex flex-wrap justify-end gap-2", children: ft(He) }),
2109
- P && bt,
2110
- Ge
2234
+ at && !m && /* @__PURE__ */ i("div", { className: "space-y-3 px-5 py-4", children: [
2235
+ Rt(!0),
2236
+ /* @__PURE__ */ n("div", { className: "flex flex-wrap justify-end gap-2", children: Mt(De) }),
2237
+ E && Ft,
2238
+ st
2111
2239
  ] }),
2112
2240
  /* @__PURE__ */ i("div", { className: "px-5 py-3", children: [
2113
2241
  /* @__PURE__ */ i(
@@ -2115,14 +2243,14 @@ function pr({
2115
2243
  {
2116
2244
  type: "button",
2117
2245
  className: "flex items-center gap-1.5 text-[12px] text-slate-400 transition-colors hover:text-slate-600",
2118
- onClick: () => x((u) => !u),
2246
+ onClick: () => v((d) => !d),
2119
2247
  children: [
2120
2248
  /* @__PURE__ */ n(
2121
- $e,
2249
+ Fe,
2122
2250
  {
2123
- className: ye(
2251
+ className: ge(
2124
2252
  "h-3.5 w-3.5 transition-transform duration-200",
2125
- h && "rotate-180"
2253
+ f && "rotate-180"
2126
2254
  )
2127
2255
  }
2128
2256
  ),
@@ -2130,24 +2258,24 @@ function pr({
2130
2258
  " ",
2131
2259
  /* @__PURE__ */ i("span", { className: "tabular-nums", children: [
2132
2260
  "(",
2133
- (Se == null ? void 0 : Se.length) ?? 0,
2261
+ (S == null ? void 0 : S.length) ?? 0,
2134
2262
  ")"
2135
2263
  ] })
2136
2264
  ]
2137
2265
  }
2138
2266
  ),
2139
- h && /* @__PURE__ */ n("div", { className: "mt-3", children: /* @__PURE__ */ n(dr, { history: Se ?? [] }) })
2267
+ f && /* @__PURE__ */ n("div", { className: "mt-3", children: /* @__PURE__ */ n(Dr, { history: S ?? [] }) })
2140
2268
  ] }),
2141
- A && (pe ?? []).length > 1 && /* @__PURE__ */ n("div", { className: "px-5 py-3", ref: H, children: /* @__PURE__ */ n(
2142
- Wn,
2269
+ U && (L ?? []).length > 1 && /* @__PURE__ */ n("div", { className: "px-5 py-3", ref: re, children: /* @__PURE__ */ n(
2270
+ vr,
2143
2271
  {
2144
2272
  collection: t,
2145
2273
  item: e,
2146
- states: pe ?? [],
2147
- currentStateId: O.current_state ?? null,
2148
- openSignal: E,
2274
+ states: L ?? [],
2275
+ currentStateId: M.current_state ?? null,
2276
+ openSignal: j,
2149
2277
  onMoved: () => {
2150
- $.invalidateQueries({ queryKey: J }), $.invalidateQueries({
2278
+ _.invalidateQueries({ queryKey: G }), _.invalidateQueries({
2151
2279
  queryKey: ["pipeline-instance", t, e]
2152
2280
  });
2153
2281
  }
@@ -2156,15 +2284,15 @@ function pr({
2156
2284
  ] }) : /* @__PURE__ */ i("div", { className: "flex items-center justify-between gap-4 px-5 py-4", children: [
2157
2285
  /* @__PURE__ */ n("p", { className: "text-[13px] text-slate-500", children: "Pipeline not started for this record." }),
2158
2286
  /* @__PURE__ */ i(
2159
- ae,
2287
+ ue,
2160
2288
  {
2161
2289
  size: "sm",
2162
2290
  variant: "outline",
2163
2291
  className: "shrink-0 gap-1.5 text-[12px]",
2164
- onClick: () => R.mutate(),
2165
- disabled: R.isPending,
2292
+ onClick: () => w.mutate(),
2293
+ disabled: w.isPending,
2166
2294
  children: [
2167
- R.isPending ? /* @__PURE__ */ n(me, { className: "h-3.5 w-3.5 animate-spin" }) : /* @__PURE__ */ n(Xe, { className: "h-3.5 w-3.5" }),
2295
+ w.isPending ? /* @__PURE__ */ n(ve, { className: "h-3.5 w-3.5 animate-spin" }) : /* @__PURE__ */ n(ot, { className: "h-3.5 w-3.5" }),
2168
2296
  "Start Pipeline"
2169
2297
  ]
2170
2298
  }
@@ -2174,37 +2302,37 @@ function pr({
2174
2302
  ]
2175
2303
  }
2176
2304
  ),
2177
- o && /* @__PURE__ */ n(Et, { fallback: null, children: /* @__PURE__ */ n(
2178
- Ht,
2305
+ T && /* @__PURE__ */ n(en, { fallback: null, children: /* @__PURE__ */ n(
2306
+ gn,
2179
2307
  {
2180
- payload: o.payload,
2181
- transitionId: o.transitionId,
2182
- isRetry: o.revision > 1,
2308
+ payload: T.payload,
2309
+ transitionId: T.transitionId,
2310
+ isRetry: T.revision > 1,
2183
2311
  onSubmitted: () => (
2184
2312
  // mutateAsync so the dialog can stay busy until the transition
2185
2313
  // settles; the mutation's own onError/onSuccess handle the outcome.
2186
- j.mutateAsync({
2187
- transition_id: o.transitionId,
2188
- comment: o.comment,
2314
+ P.mutateAsync({
2315
+ transition_id: T.transitionId,
2316
+ comment: T.comment,
2189
2317
  reviewed: !0
2190
2318
  }).catch(() => {
2191
2319
  })
2192
2320
  ),
2193
- executing: j.isPending,
2194
- onClose: () => Q(null)
2321
+ executing: P.isPending,
2322
+ onClose: () => X(null)
2195
2323
  },
2196
- o.revision
2324
+ T.revision
2197
2325
  ) })
2198
2326
  ] });
2199
2327
  }
2200
- function Gr({
2328
+ function _a({
2201
2329
  collection: t,
2202
2330
  item: e,
2203
2331
  onBeforeTransition: r,
2204
2332
  wrap: s = !0
2205
2333
  }) {
2206
2334
  return e === "new" ? null : /* @__PURE__ */ n(
2207
- fr,
2335
+ Ir,
2208
2336
  {
2209
2337
  collection: t,
2210
2338
  item: e,
@@ -2213,72 +2341,76 @@ function Gr({
2213
2341
  }
2214
2342
  );
2215
2343
  }
2216
- function fr({
2344
+ function Ir({
2217
2345
  collection: t,
2218
2346
  item: e,
2219
2347
  onBeforeTransition: r,
2220
2348
  wrap: s = !0
2221
2349
  }) {
2222
- const l = we(), c = De(), [p, b] = I(""), [f, _] = I(null), [v, y] = I(null), [$, A] = I(null), [E, B] = I([]), H = rn(t, String(e));
2223
- It(t, e, "transition", !!f || !!v);
2224
- const K = ne(null), T = Un(K, !s), P = ne(!1), L = (a) => {
2225
- P.current || (P.current = !0, A(null), k.mutate(a, {
2226
- onSettled: (m, N) => {
2227
- if (N) {
2228
- P.current = !1;
2350
+ const o = Pe(), c = ze(), [m, h] = Q(""), [p, x] = Q(null), [k, R] = Q(null), [_, U] = Q(null), [j, ne] = Q(null), [re, ae] = Q([]), F = Cn(t, String(e));
2351
+ an(t, e, "transition", !!p || !!k);
2352
+ const E = de(null), K = ir(E, !s), f = de(!1), v = (l) => {
2353
+ f.current || (f.current = !0, U(null), W.mutate(l, {
2354
+ onSettled: (y, w) => {
2355
+ if (w) {
2356
+ f.current = !1;
2229
2357
  return;
2230
2358
  }
2231
- q().finally(() => {
2232
- P.current = !1;
2359
+ X().finally(() => {
2360
+ f.current = !1;
2233
2361
  });
2234
2362
  }
2235
2363
  }));
2236
- }, h = async (a) => {
2237
- var M, R;
2238
- if (P.current) return;
2239
- if (f === a) {
2240
- _(null);
2364
+ }, g = async (l, y) => {
2365
+ var ie, M;
2366
+ if (f.current || u != null && u.running_move) return;
2367
+ if (p === l) {
2368
+ x(null);
2241
2369
  return;
2242
2370
  }
2243
- if (r) {
2244
- P.current = !0;
2245
- let j = !1;
2371
+ if (!(y != null && y.cleared) && ((u == null ? void 0 : u.available_transitions) ?? []).some((H) => H.id === l && H.advisory)) {
2372
+ x(null), U(null), ne(l), c.invalidateQueries({ queryKey: ["pipeline-instance", t, e] });
2373
+ return;
2374
+ }
2375
+ if (ne(null), r) {
2376
+ f.current = !0;
2377
+ let H = !1;
2246
2378
  try {
2247
- j = await r();
2379
+ H = await r();
2248
2380
  } finally {
2249
- P.current = !1;
2381
+ f.current = !1;
2250
2382
  }
2251
- if (!j) return;
2383
+ if (!H) return;
2252
2384
  }
2253
- const m = (ee ?? []).find((j) => j.id === a), N = String((m == null ? void 0 : m.comment_mode) ?? "none"), D = sn(m, (o == null ? void 0 : o.states) ?? [], (M = o == null ? void 0 : o.instance) == null ? void 0 : M.current_state);
2254
- if (N !== "optional" && N !== "required") {
2255
- if (m && !Oe(m, (o == null ? void 0 : o.states) ?? [], (R = o == null ? void 0 : o.instance) == null ? void 0 : R.current_state)) {
2256
- P.current = !0;
2257
- let j = [];
2385
+ const w = (le ?? []).find((H) => H.id === l), P = String((w == null ? void 0 : w.comment_mode) ?? "none"), B = $t(w, (u == null ? void 0 : u.states) ?? [], (ie = u == null ? void 0 : u.instance) == null ? void 0 : ie.current_state);
2386
+ if (P !== "optional" && P !== "required") {
2387
+ if (w && !He(w, (u == null ? void 0 : u.states) ?? [], (M = u == null ? void 0 : u.instance) == null ? void 0 : M.current_state)) {
2388
+ f.current = !0;
2389
+ let H = [];
2258
2390
  try {
2259
- j = await H();
2391
+ H = await F();
2260
2392
  } finally {
2261
- P.current = !1;
2393
+ f.current = !1;
2262
2394
  }
2263
- if (j.length > 0 || D) {
2264
- B(j), _(a);
2395
+ if (H.length > 0 || B) {
2396
+ ae(H), x(l);
2265
2397
  return;
2266
2398
  }
2267
2399
  }
2268
- if (D) {
2269
- B([]), _(a);
2400
+ if (B) {
2401
+ ae([]), x(l);
2270
2402
  return;
2271
2403
  }
2272
- L({ transition_id: a });
2404
+ v({ transition_id: l });
2273
2405
  return;
2274
2406
  }
2275
- B([]), _(a);
2276
- }, x = ["pipeline-instance", t, e], { settling: w, settle: q } = Zt(x), { data: o } = oe({
2277
- queryKey: x,
2278
- queryFn: () => l.request(
2279
- ce(`/pipelines/instance/${t}/${e}`)
2407
+ ae([]), x(l);
2408
+ }, $ = ["pipeline-instance", t, e], { settling: T, settle: X } = kn($), { data: u } = be({
2409
+ queryKey: $,
2410
+ queryFn: () => o.request(
2411
+ ye(`/pipelines/instance/${t}/${e}`)
2280
2412
  ).then(
2281
- (a) => a.data ?? {
2413
+ (l) => l.data ?? {
2282
2414
  instance: null,
2283
2415
  states: [],
2284
2416
  available_transitions: [],
@@ -2287,326 +2419,405 @@ function fr({
2287
2419
  binding: null
2288
2420
  }
2289
2421
  ),
2290
- staleTime: 1e4
2291
- }), Q = en(
2292
- o ? (o.available_transitions ?? []).map((a) => String(a.id)) : null,
2422
+ staleTime: 1e4,
2423
+ refetchInterval: (l) => un(l.state.data)
2424
+ });
2425
+ mn(!!(u != null && u.running_move), () => {
2426
+ Ee(c, t, String(e)), Ie(c, t, String(e)), et(c, t, String(e));
2427
+ });
2428
+ const b = Nn(
2429
+ u ? (u.available_transitions ?? []).map((l) => String(l.id)) : null,
2293
2430
  `${t}:${e}`
2294
- ), { data: X } = oe({
2431
+ ), { data: q } = be({
2295
2432
  queryKey: ["pipeline-all-owners", t, e],
2296
- queryFn: () => l.request(
2297
- ce(`/pipelines/instance/${t}/${e}/owners/all`)
2298
- ).then((a) => a.data ?? null),
2433
+ queryFn: () => o.request(
2434
+ ye(`/pipelines/instance/${t}/${e}/owners/all`)
2435
+ ).then((l) => l.data ?? null),
2299
2436
  // Also while a move is being confirmed: the panel names where it really lands.
2300
- enabled: on(o) || !!f,
2437
+ enabled: qn(u) || !!p,
2301
2438
  staleTime: 3e4
2302
- }), g = Ie(() => {
2303
- if (!X) return null;
2304
- const a = /* @__PURE__ */ new Map();
2305
- for (const [m, N] of Object.entries(X))
2306
- N.skipped && a.set(m, N.skip_reasons ?? []);
2307
- return a;
2308
- }, [X]), k = Pe({
2439
+ }), ee = Je(() => {
2440
+ if (!q) return null;
2441
+ const l = /* @__PURE__ */ new Map();
2442
+ for (const [y, w] of Object.entries(q))
2443
+ w.skipped && l.set(y, w.skip_reasons ?? []);
2444
+ return l;
2445
+ }, [q]), W = je({
2309
2446
  mutationFn: ({
2310
- transition_id: a,
2311
- comment: m,
2312
- reviewed: N,
2313
- lock_ack: D
2314
- }) => l.request(
2315
- Te(`/pipelines/instance/${t}/${e}/transition`, {
2316
- transition_id: a,
2317
- comment: m,
2318
- ...N ? { reviewed: !0 } : {},
2319
- ...D ? { lock_ack: !0 } : {}
2447
+ transition_id: l,
2448
+ comment: y,
2449
+ reviewed: w,
2450
+ lock_ack: P
2451
+ }) => o.request(
2452
+ We(`/pipelines/instance/${t}/${e}/transition`, {
2453
+ transition_id: l,
2454
+ comment: y,
2455
+ ...w ? { reviewed: !0 } : {},
2456
+ ...P ? { lock_ack: !0 } : {},
2457
+ ...fn(u == null ? void 0 : u.available_transitions, l)
2320
2458
  })
2321
2459
  ),
2322
- onMutate: (a) => {
2323
- var m;
2460
+ onMutate: (l) => {
2461
+ var y;
2324
2462
  return {
2325
- slow: un(
2326
- (m = [...(o == null ? void 0 : o.available_transitions) ?? [], ...(o == null ? void 0 : o.all_transitions) ?? []].find(
2327
- (N) => N.id === a.transition_id
2328
- )) == null ? void 0 : m.label
2463
+ slow: Pn(
2464
+ (y = [...(u == null ? void 0 : u.available_transitions) ?? [], ...(u == null ? void 0 : u.all_transitions) ?? []].find(
2465
+ (w) => w.id === l.transition_id
2466
+ )) == null ? void 0 : y.label
2329
2467
  )
2330
2468
  };
2331
2469
  },
2332
- onSuccess: (a, m, N) => {
2333
- c.invalidateQueries({ queryKey: x }), t === "nivaro_addendums" && c.invalidateQueries({ queryKey: ["addendums"] }), Qe(c, t, String(e)), Ae(c, t, String(e)), mn(c, t, String(e)), A(null), b(""), _(null), y(null), Y.success(cn(o, m.transition_id, a), N == null ? void 0 : N.slow.done());
2470
+ onSuccess: (l, y, w) => {
2471
+ c.invalidateQueries({ queryKey: $ }), t === "nivaro_addendums" && c.invalidateQueries({ queryKey: ["addendums"] }), Ee(c, t, String(e)), Ie(c, t, String(e)), et(c, t, String(e)), U(null), h(""), x(null), R(null);
2472
+ const P = pn(l);
2473
+ P ? V.info(
2474
+ `${P.transition_label ?? "The move"} started. You will be told if it does not go through.`,
2475
+ w == null ? void 0 : w.slow.done()
2476
+ ) : V.success(Rn(u, y.transition_id, l), w == null ? void 0 : w.slow.done());
2334
2477
  },
2335
- onError: (a, m, N) => {
2336
- var j;
2337
- if (N == null || N.slow.fail(), Gt(a)) {
2338
- c.invalidateQueries({ queryKey: x });
2478
+ onError: (l, y, w) => {
2479
+ var H, S;
2480
+ if (w == null || w.slow.fail(), xn(l)) {
2481
+ c.invalidateQueries({ queryKey: $ });
2339
2482
  return;
2340
2483
  }
2341
- const D = Yt(a);
2342
- if (D) {
2343
- _(null);
2344
- const ue = ((j = [...(o == null ? void 0 : o.available_transitions) ?? [], ...(o == null ? void 0 : o.all_transitions) ?? []].find(
2345
- (U) => U.id === m.transition_id
2346
- )) == null ? void 0 : j.label) ?? "Move";
2347
- Y.warning(D.message, {
2484
+ if (nt(l) === "TRANSITION_RUNNING") {
2485
+ c.invalidateQueries({ queryKey: $ }), x(null), R(null), V.info(Ae(l, "This move is already running on this record."));
2486
+ return;
2487
+ }
2488
+ const P = yn(l);
2489
+ if (P) {
2490
+ x(null);
2491
+ const L = ((H = [...(u == null ? void 0 : u.available_transitions) ?? [], ...(u == null ? void 0 : u.all_transitions) ?? []].find(
2492
+ (Ce) => Ce.id === y.transition_id
2493
+ )) == null ? void 0 : H.label) ?? "Move";
2494
+ V.warning(P.message, {
2348
2495
  id: `nvr-locked-move:${t}:${String(e)}`,
2349
2496
  duration: 2e4,
2350
2497
  action: {
2351
- label: `${ue} anyway`,
2352
- onClick: () => L({ ...m, lock_ack: !0 })
2498
+ label: `${L} anyway`,
2499
+ onClick: () => v({ ...y, lock_ack: !0 })
2353
2500
  },
2354
2501
  cancel: { label: "Wait", onClick: () => {
2355
2502
  } }
2356
2503
  });
2357
2504
  return;
2358
2505
  }
2359
- const M = Vt(a);
2360
- if (M) {
2361
- y((ue) => ({
2362
- payload: M,
2363
- transitionId: m.transition_id,
2364
- comment: m.comment,
2365
- revision: ((ue == null ? void 0 : ue.revision) ?? 0) + 1
2506
+ const B = vn(l);
2507
+ if (B) {
2508
+ R((L) => ({
2509
+ payload: B,
2510
+ transitionId: y.transition_id,
2511
+ comment: y.comment,
2512
+ revision: ((L == null ? void 0 : L.revision) ?? 0) + 1
2366
2513
  }));
2367
2514
  return;
2368
2515
  }
2369
- const R = a == null ? void 0 : a.response;
2370
- A(Jt(a, m)), Y.error(Fe(a, "Failed to execute transition"), {
2516
+ const ie = l == null ? void 0 : l.response;
2517
+ U(wn(l, y));
2518
+ const M = sn(
2519
+ l,
2520
+ (S = [...(u == null ? void 0 : u.available_transitions) ?? [], ...(u == null ? void 0 : u.all_transitions) ?? []].find(
2521
+ (L) => L.id === y.transition_id
2522
+ )) == null ? void 0 : S.label
2523
+ );
2524
+ V.error((M == null ? void 0 : M.title) ?? Ae(l, "Failed to execute transition"), {
2371
2525
  duration: 12e3,
2372
2526
  // What to do next + Copy details (lib/error-toast.ts); "Why?" below wins the action slot.
2373
- ...jt(a, { action: "Transition" }),
2527
+ ...rn(l, { action: "Transition" }),
2528
+ ...M ? { description: M.description } : {},
2374
2529
  // #1867: a refusal carries "Why?" — the role, owner or access rule
2375
2530
  // that stopped it, and who can change it.
2376
- ...Wt(a) ? {
2377
- action: zt(l, {
2531
+ ...dn(l) ? {
2532
+ action: cn(o, {
2378
2533
  collection: t,
2379
2534
  itemId: String(e),
2380
2535
  action: "transition",
2381
- transitionId: m.transition_id
2536
+ transitionId: y.transition_id
2382
2537
  })
2383
2538
  } : {}
2384
- }), y(null), _(null), Qe(c, t, String(e)), Ae(c, t, String(e)), (R == null ? void 0 : R.status) === 409 && c.invalidateQueries({ queryKey: x });
2539
+ }), R(null), x(null), Ee(c, t, String(e)), Ie(c, t, String(e)), (ie == null ? void 0 : ie.status) === 409 && c.invalidateQueries({ queryKey: $ });
2385
2540
  }
2386
- }), G = ne(h);
2387
- G.current = h;
2388
- const se = ne((o == null ? void 0 : o.available_transitions) ?? []);
2389
- if (se.current = (o == null ? void 0 : o.available_transitions) ?? [], fe(() => {
2390
- const a = (m) => {
2391
- const N = m.detail;
2392
- if (!N || N.claimed || N.collection !== t || String(N.item) !== String(e)) return;
2393
- N.claimed = !0;
2394
- const D = String(N.transition_id).toUpperCase(), M = se.current.find((R) => String(R.id).toUpperCase() === D);
2395
- if (!M) {
2396
- Y.error("That step is not available from where the record is now");
2541
+ }), ce = de(g);
2542
+ ce.current = g;
2543
+ const xe = de((u == null ? void 0 : u.available_transitions) ?? []);
2544
+ if (xe.current = (u == null ? void 0 : u.available_transitions) ?? [], _e(() => {
2545
+ const l = (y) => {
2546
+ const w = y.detail;
2547
+ if (!w || w.claimed || w.collection !== t || String(w.item) !== String(e)) return;
2548
+ w.claimed = !0;
2549
+ const P = String(w.transition_id).toUpperCase(), B = xe.current.find((ie) => String(ie.id).toUpperCase() === P);
2550
+ if (!B) {
2551
+ V.error("That step is not available from where the record is now");
2397
2552
  return;
2398
2553
  }
2399
- G.current(M.id);
2554
+ ce.current(B.id);
2400
2555
  };
2401
- return window.addEventListener(Ke, a), () => window.removeEventListener(Ke, a);
2402
- }, [t, e]), !(o != null && o.binding) || !(o != null && o.instance)) return null;
2403
- const ee = dn(
2404
- (o.available_transitions ?? []).filter(
2405
- (a) => !o.instance.completed_at || a.from_state && String(a.from_state).toUpperCase() === String(o.instance.current_state).toUpperCase()
2556
+ return window.addEventListener(Ze, l), () => window.removeEventListener(Ze, l);
2557
+ }, [t, e]), !(u != null && u.binding) || !(u != null && u.instance)) return null;
2558
+ const le = Mn(
2559
+ (u.available_transitions ?? []).filter(
2560
+ (l) => !u.instance.completed_at || l.from_state && String(l.from_state).toUpperCase() === String(u.instance.current_state).toUpperCase()
2406
2561
  ),
2407
- o.states ?? [],
2408
- o.instance.current_state,
2409
- o.instance.completed_at ? null : g
2562
+ u.states ?? [],
2563
+ u.instance.current_state,
2564
+ u.instance.completed_at ? null : ee
2410
2565
  );
2411
- if (ee.length === 0) return null;
2412
- const re = new Map((o.states ?? []).map((a) => [a.id, a])), z = o.instance.current_state_obj ?? null, C = f ? ee.find((a) => a.id === f) : null, de = C ? re.get(C.to_state) : null, J = fn(C, z, o.states ?? [], X), he = (J == null ? void 0 : J.state) ?? de, be = /* @__PURE__ */ new Map();
2413
- for (const a of ee) {
2414
- const m = be.get(a.label) ?? [];
2415
- m.push(a), be.set(a.label, m);
2566
+ if (le.length === 0) return null;
2567
+ const O = new Map((u.states ?? []).map((l) => [l.id, l])), Y = u.instance.current_state_obj ?? null, z = p ? le.find((l) => l.id === p) : null, se = j ? le.find((l) => l.id === j) : null, G = u.running_move ?? null, qe = G ? ur(G) : void 0, Oe = z ? O.get(z.to_state) : null, a = Dn(z, Y, u.states ?? [], q), I = (a == null ? void 0 : a.state) ?? Oe, Z = /* @__PURE__ */ new Map();
2568
+ for (const l of le) {
2569
+ const y = Z.get(l.label) ?? [];
2570
+ y.push(l), Z.set(l.label, y);
2416
2571
  }
2417
- const d = (a) => [...a].sort(
2418
- (m, N) => {
2419
- var D, M;
2420
- return (((D = re.get(m.to_state)) == null ? void 0 : D.sort) ?? 999) - (((M = re.get(N.to_state)) == null ? void 0 : M.sort) ?? 999);
2572
+ const J = (l) => [...l].sort(
2573
+ (y, w) => {
2574
+ var P, B;
2575
+ return (((P = O.get(y.to_state)) == null ? void 0 : P.sort) ?? 999) - (((B = O.get(w.to_state)) == null ? void 0 : B.sort) ?? 999);
2421
2576
  }
2422
- ), _e = (() => {
2423
- var N, D, M;
2424
- const a = (N = K.current) == null ? void 0 : N.getBoundingClientRect();
2425
- if (!a) return 600;
2426
- const m = (M = (D = K.current) == null ? void 0 : D.closest('[role="dialog"]')) == null ? void 0 : M.getBoundingClientRect();
2427
- return Math.max(260, Math.min(600, a.right - ((m == null ? void 0 : m.left) ?? 0) - 12));
2577
+ ), fe = (() => {
2578
+ var w, P, B;
2579
+ const l = (w = E.current) == null ? void 0 : w.getBoundingClientRect();
2580
+ if (!l) return 600;
2581
+ const y = (B = (P = E.current) == null ? void 0 : P.closest('[role="dialog"]')) == null ? void 0 : B.getBoundingClientRect();
2582
+ return Math.max(260, Math.min(600, l.right - ((y == null ? void 0 : y.left) ?? 0) - 12));
2428
2583
  })();
2429
- return /* @__PURE__ */ i("div", { ref: K, className: "relative", children: [
2430
- T ? /* @__PURE__ */ i(Ze, { children: [
2431
- /* @__PURE__ */ n(et, { asChild: !0, children: /* @__PURE__ */ i(
2432
- ae,
2584
+ return /* @__PURE__ */ i("div", { ref: E, className: "relative", "data-tip": qe, children: [
2585
+ K ? /* @__PURE__ */ i(ct, { children: [
2586
+ /* @__PURE__ */ n(ut, { asChild: !0, children: /* @__PURE__ */ i(
2587
+ ue,
2433
2588
  {
2434
2589
  size: "sm",
2435
2590
  variant: "outline",
2436
2591
  className: "shrink-0 gap-1.5 text-[12px]",
2437
- disabled: k.isPending || w,
2592
+ disabled: W.isPending || T || !!G,
2438
2593
  "data-transitions-folded": !0,
2439
2594
  children: [
2440
- k.isPending && /* @__PURE__ */ n(me, { className: "h-3 w-3 animate-spin" }),
2595
+ W.isPending || G ? /* @__PURE__ */ n(ve, { className: "h-3 w-3 animate-spin" }) : le.every((l) => l.advisory) && /* @__PURE__ */ n(Ne, {}),
2441
2596
  "Actions",
2442
- /* @__PURE__ */ n($e, { className: "h-3 w-3" })
2597
+ /* @__PURE__ */ n(Fe, { className: "h-3 w-3" })
2443
2598
  ]
2444
2599
  }
2445
2600
  ) }),
2446
- /* @__PURE__ */ n(tt, { align: "end", className: "min-w-[200px]", children: Array.from(be.entries()).map(
2447
- ([a, m], N, D) => m.length === 1 ? /* @__PURE__ */ i(St, { children: [
2448
- N > 0 && D[N - 1][1].length > 1 && /* @__PURE__ */ n(Ct, {}),
2449
- /* @__PURE__ */ i(Be, { onSelect: () => h(m[0].id), children: [
2450
- m[0].color && /* @__PURE__ */ n(
2451
- "span",
2601
+ /* @__PURE__ */ i(mt, { align: "end", className: "min-w-[200px]", children: [
2602
+ Array.from(Z.entries()).map(
2603
+ ([l, y], w, P) => y.length === 1 ? /* @__PURE__ */ i(It, { children: [
2604
+ w > 0 && P[w - 1][1].length > 1 && /* @__PURE__ */ n(pt, {}),
2605
+ /* @__PURE__ */ i(
2606
+ Xe,
2452
2607
  {
2453
- className: "mr-2 inline-block h-2 w-2 shrink-0 rounded-full",
2454
- style: { backgroundColor: m[0].color }
2608
+ onSelect: () => g(y[0].id),
2609
+ ...Be(y[0], "menu"),
2610
+ children: [
2611
+ y[0].color && /* @__PURE__ */ n(
2612
+ "span",
2613
+ {
2614
+ className: "mr-2 inline-block h-2 w-2 shrink-0 rounded-full",
2615
+ style: { backgroundColor: y[0].color }
2616
+ }
2617
+ ),
2618
+ l,
2619
+ y[0].advisory && /* @__PURE__ */ n(Ne, { className: "ml-auto" })
2620
+ ]
2455
2621
  }
2456
- ),
2457
- a
2458
- ] })
2459
- ] }, a) : /* @__PURE__ */ i(St, { children: [
2460
- N > 0 && /* @__PURE__ */ n(Ct, {}),
2461
- /* @__PURE__ */ n(Bn, { className: "text-[11px] text-muted-foreground", children: a }),
2462
- d(m).map((M) => {
2463
- var R;
2464
- return /* @__PURE__ */ i(Be, { onSelect: () => h(M.id), children: [
2465
- M.color && /* @__PURE__ */ n(
2466
- "span",
2622
+ )
2623
+ ] }, l) : /* @__PURE__ */ i(It, { children: [
2624
+ w > 0 && /* @__PURE__ */ n(pt, {}),
2625
+ /* @__PURE__ */ n(dr, { className: "text-[11px] text-muted-foreground", children: l }),
2626
+ J(y).map((B) => {
2627
+ var ie;
2628
+ return /* @__PURE__ */ i(
2629
+ Xe,
2467
2630
  {
2468
- className: "mr-2 inline-block h-2 w-2 shrink-0 rounded-full",
2469
- style: { backgroundColor: M.color }
2470
- }
2471
- ),
2472
- ((R = re.get(M.to_state)) == null ? void 0 : R.label) ?? M.to_state
2473
- ] }, M.id);
2474
- })
2475
- ] }, a)
2476
- ) })
2631
+ onSelect: () => g(B.id),
2632
+ ...Be(B, "menu"),
2633
+ children: [
2634
+ B.color && /* @__PURE__ */ n(
2635
+ "span",
2636
+ {
2637
+ className: "mr-2 inline-block h-2 w-2 shrink-0 rounded-full",
2638
+ style: { backgroundColor: B.color }
2639
+ }
2640
+ ),
2641
+ ((ie = O.get(B.to_state)) == null ? void 0 : ie.label) ?? B.to_state,
2642
+ B.advisory && /* @__PURE__ */ n(Ne, { className: "ml-auto" })
2643
+ ]
2644
+ },
2645
+ B.id
2646
+ );
2647
+ })
2648
+ ] }, l)
2649
+ ),
2650
+ /* @__PURE__ */ n(
2651
+ yt,
2652
+ {
2653
+ moves: le,
2654
+ nameOf: (l) => {
2655
+ var y, w;
2656
+ return (((y = Z.get(l.label)) == null ? void 0 : y.length) ?? 0) > 1 ? ((w = O.get(l.to_state)) == null ? void 0 : w.label) ?? l.to_state : l.label;
2657
+ }
2658
+ }
2659
+ )
2660
+ ] })
2477
2661
  ] }) : /* @__PURE__ */ n(
2478
2662
  "div",
2479
2663
  {
2480
2664
  className: s ? "flex flex-wrap justify-end gap-2" : "flex shrink-0 items-center justify-end gap-2",
2481
- children: Array.from(be.entries()).map(([a, m]) => {
2482
- var j, ue;
2483
- const N = m.some((U) => {
2484
- var O;
2485
- return (((O = U.order_partners) == null ? void 0 : O.length) ?? 0) > 0;
2486
- }), D = N ? null : ((j = m[0]) == null ? void 0 : j.color) ?? null, M = m.some((U) => U.id === f), R = (U) => D ? U ? { backgroundColor: D, borderColor: D } : { borderColor: D, color: D } : void 0;
2487
- if (m.length === 1) {
2488
- const U = m[0], O = k.isPending && ((ue = k.variables) == null ? void 0 : ue.transition_id) === U.id, ge = /* @__PURE__ */ i(
2489
- ae,
2665
+ children: Array.from(Z.entries()).map(([l, y]) => {
2666
+ var M, H;
2667
+ const w = y.some((S) => {
2668
+ var L;
2669
+ return (((L = S.order_partners) == null ? void 0 : L.length) ?? 0) > 0;
2670
+ }), P = w ? null : ((M = y[0]) == null ? void 0 : M.color) ?? null, B = y.some((S) => S.id === p), ie = (S) => P ? S ? { backgroundColor: P, borderColor: P } : { borderColor: P, color: P } : void 0;
2671
+ if (y.length === 1) {
2672
+ const S = y[0], L = gt(G == null ? void 0 : G.transition_id, S.id), Ce = W.isPending && ((H = W.variables) == null ? void 0 : H.transition_id) === S.id || L, we = /* @__PURE__ */ i(
2673
+ ue,
2490
2674
  {
2491
2675
  size: "sm",
2492
- variant: M ? "default" : "outline",
2493
- className: "gap-1.5 text-[12px] data-[fresh=true]:opacity-60",
2494
- style: R(M),
2495
- disabled: k.isPending || w,
2496
- "aria-disabled": Q.dimmed(U.id) || void 0,
2497
- "data-fresh": Q.dimmed(U.id) || void 0,
2498
- ...Q.bind(U.id),
2676
+ variant: B && !S.advisory ? "default" : "outline",
2677
+ className: ge(
2678
+ "gap-1.5 text-[12px] data-[fresh=true]:opacity-60",
2679
+ S.advisory && Fn
2680
+ ),
2681
+ style: S.advisory ? void 0 : ie(B),
2682
+ disabled: W.isPending || T || !!G,
2683
+ "data-move-running": L || void 0,
2684
+ "aria-disabled": b.dimmed(S.id) || void 0,
2685
+ "data-fresh": b.dimmed(S.id) || void 0,
2686
+ ...b.bind(S.id),
2687
+ ...Be(S),
2499
2688
  onClick: () => {
2500
- Q.press(U.id) && h(U.id);
2689
+ b.press(S.id) && g(S.id);
2501
2690
  },
2502
2691
  children: [
2503
- O ? /* @__PURE__ */ n(me, { className: "h-3 w-3 animate-spin" }) : N && /* @__PURE__ */ n(Ft, { className: "h-3 w-3", "aria-hidden": !0 }),
2504
- a
2692
+ Ce ? /* @__PURE__ */ n(ve, { className: "h-3 w-3 animate-spin" }) : S.advisory ? /* @__PURE__ */ n(Ne, {}) : w && /* @__PURE__ */ n(Xt, { className: "h-3 w-3", "aria-hidden": !0 }),
2693
+ l
2505
2694
  ]
2506
2695
  },
2507
- a
2696
+ l
2508
2697
  );
2509
- return U.pushes && U.pushes > 0 ? /* @__PURE__ */ i("span", { className: "relative inline-flex", children: [
2510
- ge,
2698
+ return S.pushes && S.pushes > 0 ? /* @__PURE__ */ i("span", { className: "relative inline-flex", children: [
2699
+ we,
2511
2700
  /* @__PURE__ */ n(
2512
- On,
2701
+ sr,
2513
2702
  {
2514
2703
  collection: t,
2515
2704
  itemId: e,
2516
- transitionId: U.id,
2517
- label: a,
2705
+ transitionId: S.id,
2706
+ label: l,
2518
2707
  compact: !0
2519
2708
  }
2520
2709
  )
2521
- ] }, a) : ge;
2710
+ ] }, l) : we;
2522
2711
  }
2523
- return /* @__PURE__ */ i(Ze, { children: [
2524
- /* @__PURE__ */ n(et, { asChild: !0, children: /* @__PURE__ */ i(
2525
- ae,
2712
+ return /* @__PURE__ */ i(ct, { children: [
2713
+ /* @__PURE__ */ n(ut, { asChild: !0, children: /* @__PURE__ */ i(
2714
+ ue,
2526
2715
  {
2527
2716
  size: "sm",
2528
- variant: M ? "default" : "outline",
2717
+ variant: B ? "default" : "outline",
2529
2718
  className: "gap-1.5 text-[12px]",
2530
- style: R(M),
2531
- disabled: k.isPending || w,
2719
+ style: ie(B),
2720
+ disabled: W.isPending || T || !!G,
2532
2721
  children: [
2533
- a,
2534
- /* @__PURE__ */ n($e, { className: "h-3 w-3" })
2722
+ y.every((S) => S.advisory) && /* @__PURE__ */ n(Ne, {}),
2723
+ l,
2724
+ /* @__PURE__ */ n(Fe, { className: "h-3 w-3" })
2535
2725
  ]
2536
2726
  }
2537
2727
  ) }),
2538
- /* @__PURE__ */ n(tt, { align: "start", children: d(m).map((U) => {
2539
- var O;
2540
- return /* @__PURE__ */ i(Be, { onSelect: () => h(U.id), children: [
2541
- U.color && /* @__PURE__ */ n(
2542
- "span",
2728
+ /* @__PURE__ */ i(mt, { align: "start", children: [
2729
+ J(y).map((S) => {
2730
+ var L;
2731
+ return /* @__PURE__ */ i(
2732
+ Xe,
2543
2733
  {
2544
- className: "mr-2 inline-block h-2 w-2 shrink-0 rounded-full",
2545
- style: { backgroundColor: U.color }
2734
+ onSelect: () => g(S.id),
2735
+ ...Be(S, "menu"),
2736
+ children: [
2737
+ S.color && /* @__PURE__ */ n(
2738
+ "span",
2739
+ {
2740
+ className: "mr-2 inline-block h-2 w-2 shrink-0 rounded-full",
2741
+ style: { backgroundColor: S.color }
2742
+ }
2743
+ ),
2744
+ ((L = O.get(S.to_state)) == null ? void 0 : L.label) ?? S.to_state,
2745
+ S.advisory && /* @__PURE__ */ n(Ne, { className: "ml-auto" })
2746
+ ]
2747
+ },
2748
+ S.id
2749
+ );
2750
+ }),
2751
+ /* @__PURE__ */ n(
2752
+ yt,
2753
+ {
2754
+ moves: y,
2755
+ nameOf: (S) => {
2756
+ var L;
2757
+ return ((L = O.get(S.to_state)) == null ? void 0 : L.label) ?? S.to_state;
2546
2758
  }
2547
- ),
2548
- ((O = re.get(U.to_state)) == null ? void 0 : O.label) ?? U.to_state
2549
- ] }, U.id);
2550
- }) })
2551
- ] }, a);
2759
+ }
2760
+ )
2761
+ ] })
2762
+ ] }, l);
2552
2763
  })
2553
2764
  }
2554
2765
  ),
2555
- f && /* @__PURE__ */ i(
2766
+ p && /* @__PURE__ */ i(
2556
2767
  "div",
2557
2768
  {
2558
2769
  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",
2559
- style: { width: _e },
2770
+ style: { width: fe },
2560
2771
  children: [
2561
2772
  /* @__PURE__ */ i("div", { className: "flex flex-wrap items-center gap-2", children: [
2562
2773
  /* @__PURE__ */ n("span", { className: "text-[11px] font-semibold text-slate-400", children: "Confirming" }),
2563
- C && /* @__PURE__ */ n("span", { className: "text-[12px] font-medium text-slate-700", children: C.label }),
2564
- z && he && /* @__PURE__ */ i("div", { className: "ml-auto flex items-center gap-1.5", children: [
2565
- /* @__PURE__ */ n(Ne, { label: z.label, color: z.color, small: !0 }),
2566
- /* @__PURE__ */ n(lt, { className: "h-3 w-3 shrink-0 text-slate-300" }),
2567
- /* @__PURE__ */ n(Ne, { label: he.label, color: he.color, small: !0 })
2774
+ z && /* @__PURE__ */ n("span", { className: "text-[12px] font-medium text-slate-700", children: z.label }),
2775
+ Y && I && /* @__PURE__ */ i("div", { className: "ml-auto flex items-center gap-1.5", children: [
2776
+ /* @__PURE__ */ n(Re, { label: Y.label, color: Y.color, small: !0 }),
2777
+ /* @__PURE__ */ n(wt, { className: "h-3 w-3 shrink-0 text-slate-300" }),
2778
+ /* @__PURE__ */ n(Re, { label: I.label, color: I.color, small: !0 })
2568
2779
  ] })
2569
2780
  ] }),
2570
- /* @__PURE__ */ n(hn, { landing: J }),
2571
- /* @__PURE__ */ n(ln, { collection: t, item: String(e), tx: C }),
2572
- /* @__PURE__ */ n(bn, { collection: t, item: e, omitLines: E }),
2573
- /* @__PURE__ */ n(an, { lines: E }),
2781
+ /* @__PURE__ */ n(Un, { landing: a }),
2782
+ /* @__PURE__ */ n(Tn, { collection: t, item: String(e), tx: z }),
2783
+ /* @__PURE__ */ n(Bn, { collection: t, item: e, omitLines: re }),
2784
+ /* @__PURE__ */ n($n, { lines: re }),
2574
2785
  /* @__PURE__ */ n(
2575
2786
  "input",
2576
2787
  {
2577
2788
  type: "text",
2578
- value: p,
2579
- onChange: (a) => b(a.target.value),
2580
- placeholder: String((C == null ? void 0 : C.comment_mode) ?? "") === "required" ? "Add a note (required)" : "Add a comment (optional)",
2789
+ value: m,
2790
+ onChange: (l) => h(l.target.value),
2791
+ placeholder: String((z == null ? void 0 : z.comment_mode) ?? "") === "required" ? "Add a note (required)" : "Add a comment (optional)",
2581
2792
  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"
2582
2793
  }
2583
2794
  ),
2584
2795
  /* @__PURE__ */ i("div", { className: "flex items-center justify-end gap-2", children: [
2585
2796
  /* @__PURE__ */ n(
2586
- ae,
2797
+ ue,
2587
2798
  {
2588
2799
  type: "button",
2589
2800
  size: "sm",
2590
2801
  variant: "ghost",
2591
2802
  className: "h-7 text-[12px]",
2592
- onClick: () => _(null),
2803
+ onClick: () => x(null),
2593
2804
  children: "Cancel"
2594
2805
  }
2595
2806
  ),
2596
2807
  /* @__PURE__ */ n(
2597
- ae,
2808
+ ue,
2598
2809
  {
2599
2810
  type: "button",
2600
2811
  size: "sm",
2601
2812
  className: "h-7 gap-1.5 text-[12px]",
2602
- disabled: k.isPending || String((C == null ? void 0 : C.comment_mode) ?? "") === "required" && p.trim() === "",
2603
- onClick: () => L({
2604
- transition_id: f,
2605
- comment: p.trim() || void 0
2813
+ disabled: W.isPending || !!G || String((z == null ? void 0 : z.comment_mode) ?? "") === "required" && m.trim() === "",
2814
+ onClick: () => v({
2815
+ transition_id: p,
2816
+ comment: m.trim() || void 0
2606
2817
  }),
2607
- children: k.isPending ? /* @__PURE__ */ n(me, { className: "h-3.5 w-3.5 animate-spin" }) : /* @__PURE__ */ i(xe, { children: [
2608
- /* @__PURE__ */ n("span", { children: E.length > 0 && C ? `${C.label} anyway` : "Confirm" }),
2609
- /* @__PURE__ */ n(We, { className: "h-3 w-3" })
2818
+ children: W.isPending ? /* @__PURE__ */ n(ve, { className: "h-3.5 w-3.5 animate-spin" }) : /* @__PURE__ */ i(Se, { children: [
2819
+ /* @__PURE__ */ n("span", { children: re.length > 0 && z ? `${z.label} anyway` : "Confirm" }),
2820
+ /* @__PURE__ */ n(tt, { className: "h-3 w-3" })
2610
2821
  ] })
2611
2822
  }
2612
2823
  )
@@ -2614,62 +2825,82 @@ function fr({
2614
2825
  ]
2615
2826
  }
2616
2827
  ),
2617
- $ && !f && /* @__PURE__ */ n(
2618
- pn,
2828
+ (se == null ? void 0 : se.advisory) && !p && /* @__PURE__ */ n(
2829
+ bn,
2830
+ {
2831
+ floating: !0,
2832
+ collection: t,
2833
+ item: String(e),
2834
+ advisory: se.advisory,
2835
+ armedMove: {
2836
+ id: se.id,
2837
+ label: se.label,
2838
+ confirms: An(se, u.states ?? [], u.instance.current_state)
2839
+ },
2840
+ className: "absolute right-0 top-full z-50 mt-1",
2841
+ style: { width: fe },
2842
+ onDismiss: () => ne(null),
2843
+ onFixed: (l) => {
2844
+ ne(null), c.invalidateQueries({ queryKey: $ }), l && g(l.id, { cleared: !0 });
2845
+ }
2846
+ }
2847
+ ),
2848
+ _ && !p && /* @__PURE__ */ n(
2849
+ On,
2619
2850
  {
2620
2851
  collection: t,
2621
2852
  item: String(e),
2622
- offer: $,
2853
+ offer: _,
2623
2854
  className: "absolute right-0 top-full z-50 mt-1 shadow-lg",
2624
- style: { width: _e },
2625
- onDismiss: () => A(null),
2626
- onFixed: () => L({ transition_id: $.transitionId, comment: $.comment })
2855
+ style: { width: fe },
2856
+ onDismiss: () => U(null),
2857
+ onFixed: () => v({ transition_id: _.transitionId, comment: _.comment })
2627
2858
  }
2628
2859
  ),
2629
- v && /* @__PURE__ */ n(Et, { fallback: null, children: /* @__PURE__ */ n(
2630
- Ht,
2860
+ k && /* @__PURE__ */ n(en, { fallback: null, children: /* @__PURE__ */ n(
2861
+ gn,
2631
2862
  {
2632
- payload: v.payload,
2633
- transitionId: v.transitionId,
2634
- isRetry: v.revision > 1,
2863
+ payload: k.payload,
2864
+ transitionId: k.transitionId,
2865
+ isRetry: k.revision > 1,
2635
2866
  onSubmitted: () => (
2636
2867
  // mutateAsync so the dialog can stay busy until the transition
2637
2868
  // settles; the mutation's own onError/onSuccess handle the outcome.
2638
- k.mutateAsync({
2639
- transition_id: v.transitionId,
2640
- comment: v.comment,
2869
+ W.mutateAsync({
2870
+ transition_id: k.transitionId,
2871
+ comment: k.comment,
2641
2872
  reviewed: !0
2642
2873
  }).catch(() => {
2643
2874
  })
2644
2875
  ),
2645
- executing: k.isPending,
2646
- onClose: () => y(null)
2876
+ executing: W.isPending,
2877
+ onClose: () => R(null)
2647
2878
  },
2648
- v.revision
2879
+ k.revision
2649
2880
  ) })
2650
2881
  ] });
2651
2882
  }
2652
2883
  export {
2653
- Me as FRESH_BUTTON_MS,
2654
- qt as FRESH_HOVER_MAX_MS,
2655
- Jn as FreshButtonGuard,
2656
- Hr as PipelinePanel,
2657
- Gr as PipelineTransitionButtons,
2658
- Xn as REFUSAL_FIX_ACTIONS,
2659
- rr as RecordFlagChips,
2660
- ar as SLOW_MOVE_MS,
2661
- sn as asksFirst,
2662
- er as briefAgeText,
2663
- tr as briefDiffPair,
2664
- Mt as briefLineKey,
2665
- Zn as briefWarnings,
2666
- Gt as isDuplicateTransition,
2667
- sr as latestSendBack,
2668
- Yt as lockedMoveOffer,
2669
- Xt as refusalCode,
2670
- Jt as refusalFixFor,
2671
- un as slowMoveToast,
2672
- Vt as transitionRequirementsFromError,
2673
- cn as transitionToastText,
2674
- dn as withoutSkippedSendBacks
2884
+ Ue as FRESH_BUTTON_MS,
2885
+ Kt as FRESH_HOVER_MAX_MS,
2886
+ Sr as FreshButtonGuard,
2887
+ Na as PipelinePanel,
2888
+ _a as PipelineTransitionButtons,
2889
+ gr as REFUSAL_FIX_ACTIONS,
2890
+ Mr as RecordFlagChips,
2891
+ Rr as SLOW_MOVE_MS,
2892
+ $t as asksFirst,
2893
+ $r as briefAgeText,
2894
+ Tr as briefDiffPair,
2895
+ Wt as briefLineKey,
2896
+ Cr as briefWarnings,
2897
+ xn as isDuplicateTransition,
2898
+ Pr as latestSendBack,
2899
+ yn as lockedMoveOffer,
2900
+ nt as refusalCode,
2901
+ wn as refusalFixFor,
2902
+ Pn as slowMoveToast,
2903
+ vn as transitionRequirementsFromError,
2904
+ Rn as transitionToastText,
2905
+ Mn as withoutSkippedSendBacks
2675
2906
  };