@nivaro/react 0.3.49 → 0.3.51

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