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