@nivaro/react 0.3.57 → 0.3.59

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