@nivaro/react 0.3.48 → 0.3.50

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