@nivaro/react 0.3.112 → 0.3.113

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