@tangle-network/sandbox-cli 0.21.64 → 0.21.66

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 (136) hide show
  1. package/README.md +32 -4
  2. package/SKILL.md +37 -5
  3. package/dist/graph-native-CS_TmaCK.mjs +1 -0
  4. package/dist/graph-viewer/Analytics-bWsqhurt.js +1001 -0
  5. package/dist/graph-viewer/{AnswerStrip-DhwqOyxI.js → AnswerStrip-COxV7gLW.js} +2 -2
  6. package/dist/graph-viewer/Checks-CQGmKcQ0.js +164 -0
  7. package/dist/graph-viewer/Conversations-DgCshBAf.js +627 -0
  8. package/dist/graph-viewer/{Files-DtZhf0ii.js → Files-CvIOGrAs.js} +81 -90
  9. package/dist/graph-viewer/LiveRun-DHmsr6F7.js +311 -0
  10. package/dist/graph-viewer/{Outputs-QET3nPPp.js → Outputs-rwBg_x36.js} +4 -4
  11. package/dist/graph-viewer/Overview-C150tkVa.js +194 -0
  12. package/dist/graph-viewer/{RunOverview-DJQDAMIx.js → RunOverview-CSqsunqf.js} +2 -2
  13. package/dist/graph-viewer/RunPage-F_prVwiV.js +286 -0
  14. package/dist/graph-viewer/Timeline-BFDywlmz.js +335 -0
  15. package/dist/graph-viewer/Today-BdDuqZGF.js +623 -0
  16. package/dist/graph-viewer/Topology-SAfGtd5u.js +238 -0
  17. package/dist/graph-viewer/Traces-BYqXaS_s.js +254 -0
  18. package/dist/graph-viewer/{WallPages-4d9QUZDq.js → WallPages-MM70VZrC.js} +48 -30
  19. package/dist/graph-viewer/agent-runtime.js +55 -55
  20. package/dist/graph-viewer/{data-BJmP7F1M.js → data-DTGmre1W.js} +31 -27
  21. package/dist/graph-viewer/harness-sessions.js +1 -1
  22. package/dist/graph-viewer/index.js +1357 -1392
  23. package/dist/graph-viewer/{lazy-pages-DM0cZM10.js → lazy-pages-BYuq_L_n.js} +9 -5
  24. package/dist/graph-viewer/{outputs-model-CGdvjkQh.js → outputs-model-CHTx8rMz.js} +2 -2
  25. package/dist/graph-viewer/{viewer/plain-words-CgvxtEOa.js → plain-words-BrMHl0On.js} +9 -4
  26. package/dist/graph-viewer/receipt.js +2 -2
  27. package/dist/graph-viewer/record-CsP_3NJS.js +612 -0
  28. package/dist/graph-viewer/record-part-CuT9Xw37.js +334 -0
  29. package/dist/graph-viewer/record.js +2 -336
  30. package/dist/graph-viewer/report-viewer.js +65 -65
  31. package/dist/graph-viewer/report.js +1 -1
  32. package/dist/graph-viewer/research-publication.js +1 -1
  33. package/dist/graph-viewer/{run-files-C1NgzM0l.js → run-files-BckQDdTD.js} +1 -1
  34. package/dist/graph-viewer/{run-receipt-Bvi4-KVM.js → run-receipt-Bt2iXJUy.js} +1 -0
  35. package/dist/graph-viewer/schemas/agent-workspace.play.v1.json +3 -0
  36. package/dist/graph-viewer/schemas/agent-workspace.plays.v1.json +2 -0
  37. package/dist/graph-viewer/schemas/agent-workspace.run.v1.json +1 -0
  38. package/dist/graph-viewer/styles.css +4559 -2385
  39. package/dist/graph-viewer/trace-spans.js +1 -1
  40. package/dist/graph-viewer/ui-xa5w5bEN.js +889 -0
  41. package/dist/graph-viewer/viewer/{AgentGraphCanvas-CMdOlSlh-4EervjeC.js → AgentGraphCanvas-B74GN1o6-BZEumF7-.js} +2610 -2707
  42. package/dist/graph-viewer/viewer/Analytics-E3XS570U.js +1002 -0
  43. package/dist/graph-viewer/viewer/{AnswerStrip-CGUyXuYH.js → AnswerStrip-B7xMU57A.js} +2 -2
  44. package/dist/graph-viewer/viewer/Checks-CJ5XSHbv.js +165 -0
  45. package/dist/graph-viewer/viewer/Conversations-AX8G7Qyl.js +904 -0
  46. package/dist/graph-viewer/viewer/Files-DxL1576V.js +630 -0
  47. package/dist/graph-viewer/viewer/LiveRun-B-BckyEj.js +820 -0
  48. package/dist/graph-viewer/viewer/{Outputs-CumGyjQo.js → Outputs-BoIpgfMv.js} +24 -23
  49. package/dist/graph-viewer/viewer/Overview-Dzg5XJgy.js +436 -0
  50. package/dist/graph-viewer/viewer/RunPage-NtevWXBs.js +285 -0
  51. package/dist/graph-viewer/viewer/{Scores-ZS16yk0n.js → Scores-Dgv4WePL.js} +3 -3
  52. package/dist/graph-viewer/viewer/Timeline-CzY3LVDu.js +335 -0
  53. package/dist/graph-viewer/viewer/Today-Bi9IIwuh.js +623 -0
  54. package/dist/graph-viewer/viewer/Topology-CzjqSFXH.js +239 -0
  55. package/dist/graph-viewer/viewer/Traces-CMX0H1VU.js +254 -0
  56. package/dist/graph-viewer/viewer/{WallPages-CzWpyIfp.js → WallPages-Clj4bORg.js} +50 -32
  57. package/dist/graph-viewer/viewer/addon-webgl-BSCscllv.js +4027 -0
  58. package/dist/graph-viewer/viewer/agent-record-BrP-ENHg.css +2 -0
  59. package/dist/graph-viewer/viewer/{bot-D6Nrej7Z.js → bot-BaQU59LG.js} +1 -1
  60. package/dist/graph-viewer/viewer/{chevron-right-D_5IKLxu.js → chevron-right-Xn05jYLT.js} +1 -1
  61. package/dist/graph-viewer/viewer/{createLucideIcon-yH0cxLMy.js → createLucideIcon-BSphcoOJ.js} +1 -1
  62. package/dist/graph-viewer/viewer/dashboard-D3JhmRhe-DSl0zhkw.js +371 -0
  63. package/dist/graph-viewer/viewer/{data-CkWfWr7i.js → data-CVHeKhrh.js} +144 -139
  64. package/dist/graph-viewer/viewer/dist-4_KJz8ZM.js +349 -0
  65. package/dist/graph-viewer/viewer/dist-Dy-wrdTt.js +1615 -0
  66. package/dist/graph-viewer/viewer/es2015-utW4DTOJ.js +3506 -0
  67. package/dist/graph-viewer/viewer/{final-output-kwY11u9X.js → final-output-BYT-g-9j.js} +1 -1
  68. package/dist/graph-viewer/viewer/flow-waterfall-model-DvrgPLGS-BdThSFH-.js +2696 -0
  69. package/dist/graph-viewer/viewer/git-branch-BzTbIcYL.js +28 -0
  70. package/dist/graph-viewer/viewer/{highlights-Btsi5OXl.js → highlights-DWeSCtiR.js} +4 -4
  71. package/dist/graph-viewer/viewer/jsx-runtime-DPT6sCLq.js +319 -0
  72. package/dist/graph-viewer/viewer/lazy-pages-ChiMJ8r_.js +803 -0
  73. package/dist/graph-viewer/viewer/{markdown-CX_sVrXB.js → markdown-lADwhD7y.js} +2324 -2608
  74. package/dist/graph-viewer/viewer/model-brand-bTcMjQtB-RSb7EbGB.js +476 -0
  75. package/dist/graph-viewer/viewer/{page-header-Brq611fd.js → page-header-QbUg8F8i.js} +12 -11
  76. package/dist/graph-viewer/{plain-words-CgvxtEOa.js → viewer/plain-words-BrMHl0On.js} +9 -4
  77. package/dist/graph-viewer/viewer/primitives-znfPK9NP-B6UO7uDr.js +346 -0
  78. package/dist/graph-viewer/viewer/react-DQ7E2Epi.js +4254 -0
  79. package/dist/graph-viewer/viewer/{react-dom-t1L4_-il.js → react-dom-BEusmvQH.js} +1 -1
  80. package/dist/graph-viewer/viewer/record-DZnT6SWN-H-ul3U3a.js +3523 -0
  81. package/dist/graph-viewer/viewer/record-W39D5MO-.js +1 -0
  82. package/dist/graph-viewer/viewer/record-part-CbweyYoV.js +335 -0
  83. package/dist/graph-viewer/viewer/{segmented-control-BaJmvTNd.js → segmented-control-Di1mbQlP.js} +27 -26
  84. package/dist/graph-viewer/viewer/{shiki-Qnby7Sh6.js → shiki-BfNNlmfZ.js} +15 -15
  85. package/dist/graph-viewer/viewer/status-meta-S0kV_RDp.js +273 -0
  86. package/dist/graph-viewer/viewer/{stream-tokenizer-CWtnjmRd.js → stream-tokenizer-B5wWaM3U.js} +12 -12
  87. package/dist/graph-viewer/viewer/{themes-1i1fzpRk.js → themes-DuRxHiga.js} +1 -1
  88. package/dist/graph-viewer/viewer/ui-Co03nZUX.js +889 -0
  89. package/dist/graph-viewer/viewer/utils-BuObIC0n.js +1815 -0
  90. package/dist/graph-viewer/viewer/workbench-E6_5q_oL.js +28351 -0
  91. package/dist/graph-viewer/viewer/workflows--mZpHYqo.js +3298 -0
  92. package/dist/graph-viewer/viewer/workspace-cKs9sGEO.js +2468 -0
  93. package/dist/graph-viewer/{workspace-model-Ewf17pTW.js → workspace-model-BkPl_J8E.js} +1 -1
  94. package/dist/graph-viewer/workspace-viewer.js +7452 -7489
  95. package/dist/graph-viewer/workspace.js +1 -1
  96. package/dist/index.mjs +27 -22
  97. package/package.json +14 -13
  98. package/dist/graph-viewer/Analytics-DFWW8Phh.js +0 -938
  99. package/dist/graph-viewer/Checks-qgqV4xgV.js +0 -155
  100. package/dist/graph-viewer/Conversations-CGB45kpj.js +0 -545
  101. package/dist/graph-viewer/LiveRun-C21wUKAY.js +0 -210
  102. package/dist/graph-viewer/Overview-BjeLsA2I.js +0 -506
  103. package/dist/graph-viewer/RunPage-CkkcBEUe.js +0 -258
  104. package/dist/graph-viewer/Timeline-C2Xolk0t.js +0 -293
  105. package/dist/graph-viewer/Today-BVVDtSVN.js +0 -660
  106. package/dist/graph-viewer/Topology-DO5XX8e4.js +0 -545
  107. package/dist/graph-viewer/Traces-BhMxjNgw.js +0 -259
  108. package/dist/graph-viewer/part-events-BrLrg_EV.js +0 -276
  109. package/dist/graph-viewer/record-part-CZal_IMH.js +0 -1408
  110. package/dist/graph-viewer/ui-D8QZRsC3.js +0 -938
  111. package/dist/graph-viewer/viewer/Analytics-DD__nbLm.js +0 -939
  112. package/dist/graph-viewer/viewer/Checks-Ds5M7eAW.js +0 -156
  113. package/dist/graph-viewer/viewer/Conversations-C1n0EBBd.js +0 -819
  114. package/dist/graph-viewer/viewer/Files-Cjr7NMU_.js +0 -448
  115. package/dist/graph-viewer/viewer/LiveRun-uPTkPSjo.js +0 -6772
  116. package/dist/graph-viewer/viewer/Overview-4Umk14_2.js +0 -507
  117. package/dist/graph-viewer/viewer/RunPage-DZlBW7Va.js +0 -257
  118. package/dist/graph-viewer/viewer/Timeline-BnK6-yBR.js +0 -294
  119. package/dist/graph-viewer/viewer/Today-a_-oNigi.js +0 -660
  120. package/dist/graph-viewer/viewer/Topology-CQPCLQT6.js +0 -546
  121. package/dist/graph-viewer/viewer/Traces-C0IGk0L4.js +0 -259
  122. package/dist/graph-viewer/viewer/WorkflowGraph-DZ3xejKE-jRXKeSrg.js +0 -1559
  123. package/dist/graph-viewer/viewer/agent-record-Dw772ROs.css +0 -2
  124. package/dist/graph-viewer/viewer/agent-timeline-Cs9Qbpvo.js +0 -1798
  125. package/dist/graph-viewer/viewer/dist-C1-7EfoW.js +0 -488
  126. package/dist/graph-viewer/viewer/file-text-m7a3piQF.js +0 -47
  127. package/dist/graph-viewer/viewer/jsx-runtime-DQWyJOhv.js +0 -2136
  128. package/dist/graph-viewer/viewer/lazy-pages-BowaGsg-.js +0 -20
  129. package/dist/graph-viewer/viewer/model-brand-bTcMjQtB-fagiBQam.js +0 -723
  130. package/dist/graph-viewer/viewer/popover-CvOAjlnk.js +0 -5329
  131. package/dist/graph-viewer/viewer/react-CY3IbSNO.js +0 -4262
  132. package/dist/graph-viewer/viewer/record-part-D3_Anfpe.js +0 -1329
  133. package/dist/graph-viewer/viewer/terminal-83J_I4Ne.js +0 -52
  134. package/dist/graph-viewer/viewer/ui-C9b1rIUH.js +0 -938
  135. package/dist/graph-viewer/viewer/workspace-CekmOBs3.js +0 -25100
  136. package/dist/graph-viewer/viewer/x-DOc2URqZ.js +0 -56
@@ -1,1559 +0,0 @@
1
- import { i as e } from "./rolldown-runtime-DArdT4gl.js";
2
- import { i as t, t as n } from "./jsx-runtime-DQWyJOhv.js";
3
- import { S as r, x as i } from "./workspace-CekmOBs3.js";
4
- import { t as a } from "./createLucideIcon-yH0cxLMy.js";
5
- import { t as o } from "./x-DOc2URqZ.js";
6
- import { _ as s, a as c, c as l, d as u, f as d, g as f, h as p, i as m, l as h, m as g, n as ee, o as _, p as v, r as te, s as ne, t as y, u as b } from "./AgentGraphCanvas-CMdOlSlh-4EervjeC.js";
7
- import { A as re, C as ie, D as ae, E as x, F as oe, M as S, N as C, O as w, P as T, T as E, _ as D, b as se, c as ce, d as O, f as k, g as A, h as j, i as M, j as N, k as P, l as le, m as F, n as I, o as L, p as ue, r as de, s as R, u as z, v as fe, w as pe, x as B, y as me } from "./LiveRun-uPTkPSjo.js";
8
- //#region node_modules/.pnpm/lucide-react@1.61.0_@types+react@19.3.0_react@19.3.0/node_modules/lucide-react/dist/esm/icons/expand.mjs
9
- var V = {
10
- name: "expand",
11
- size: 24,
12
- node: [
13
- ["path", {
14
- d: "m15 15 6 6",
15
- key: "1s409w"
16
- }],
17
- ["path", {
18
- d: "m15 9 6-6",
19
- key: "ko1vev"
20
- }],
21
- ["path", {
22
- d: "M21 16v5h-5",
23
- key: "1ck2sf"
24
- }],
25
- ["path", {
26
- d: "M21 8V3h-5",
27
- key: "1qoq8a"
28
- }],
29
- ["path", {
30
- d: "M3 16v5h5",
31
- key: "1t08am"
32
- }],
33
- ["path", {
34
- d: "m3 21 6-6",
35
- key: "wwnumi"
36
- }],
37
- ["path", {
38
- d: "M3 8V3h5",
39
- key: "1ln10m"
40
- }],
41
- ["path", {
42
- d: "M9 9 3 3",
43
- key: "v551iv"
44
- }]
45
- ]
46
- };
47
- V.node;
48
- var he = a(V), H = {
49
- name: "plus",
50
- size: 24,
51
- node: [["path", {
52
- d: "M5 12h14",
53
- key: "1ays0h"
54
- }], ["path", {
55
- d: "M12 5v14",
56
- key: "s699le"
57
- }]]
58
- };
59
- H.node;
60
- var U = a(H), W = {
61
- name: "shrink",
62
- size: 24,
63
- node: [
64
- ["path", {
65
- d: "m15 15 6 6m-6-6v4.8m0-4.8h4.8",
66
- key: "17vawe"
67
- }],
68
- ["path", {
69
- d: "M9 19.8V15m0 0H4.2M9 15l-6 6",
70
- key: "chjx8e"
71
- }],
72
- ["path", {
73
- d: "M15 4.2V9m0 0h4.8M15 9l6-6",
74
- key: "lav6yq"
75
- }],
76
- ["path", {
77
- d: "M9 4.2V9m0 0H4.2M9 9 3 3",
78
- key: "1pxi2q"
79
- }]
80
- ]
81
- };
82
- W.node;
83
- var ge = a(W), G = n(), K = /* @__PURE__ */ e(t(), 1), q = "wfEdge", J = {
84
- left: g.Left,
85
- right: g.Right,
86
- top: g.Top,
87
- bottom: g.Bottom
88
- };
89
- function _e(e) {
90
- let t = Object.values(e);
91
- return t.length > 0 && t.every((e) => typeof e == "object" && !!e && "status" in e);
92
- }
93
- var Y = [
94
- "nodeState",
95
- "direction",
96
- "compact",
97
- "wrap",
98
- "edges",
99
- "reserveEdgeInsert",
100
- "itemCounts"
101
- ];
102
- function ve(e) {
103
- return e ? Y.some((t) => t in e) ? e : _e(e) ? { nodeState: e } : {} : {};
104
- }
105
- function ye(e, t) {
106
- let n = ve(t), r = n.nodeState, i = n.direction ?? "LR", a = n.compact ?? !1, o = A(e, {
107
- reserveRunState: r !== void 0,
108
- direction: i,
109
- compact: a,
110
- ...n.wrap ? { wrap: !0 } : {},
111
- ...n.edges ? { edges: n.edges } : {},
112
- ...n.reserveEdgeInsert ? { reserveEdgeInsert: !0 } : {},
113
- ...n.itemCounts ? { itemCounts: n.itemCounts } : {}
114
- }), s = i === "LR", c = s ? g.Right : g.Bottom, l = s ? g.Left : g.Top;
115
- return {
116
- error: o.error,
117
- compact: a,
118
- direction: i,
119
- ...o.spacing ? { spacing: o.spacing } : {},
120
- nodes: o.nodes.map((e) => ({
121
- id: e.id,
122
- type: "wfNode",
123
- position: e.position,
124
- width: e.width,
125
- height: e.height,
126
- deletable: !1,
127
- style: {
128
- width: e.width,
129
- height: e.height
130
- },
131
- sourcePosition: e.sourceSide ? J[e.sourceSide] : c,
132
- targetPosition: e.targetSide ? J[e.targetSide] : l,
133
- data: r?.[e.id] ? {
134
- ...e.data,
135
- state: r[e.id]
136
- } : e.data
137
- })),
138
- edges: o.edges.map((e) => {
139
- let t = e.whenLabel !== void 0 || e.backEdge === !0;
140
- return {
141
- id: e.id,
142
- source: e.source,
143
- target: e.target,
144
- type: t ? q : "smoothstep",
145
- data: {
146
- kind: e.kind,
147
- ...e.whenLabel === void 0 ? {} : { whenLabel: e.whenLabel },
148
- ...e.backEdge === !0 ? { backEdge: !0 } : {}
149
- }
150
- };
151
- })
152
- };
153
- }
154
- function be(e, t) {
155
- if (e === t) return !0;
156
- if (!e || !t) return !1;
157
- let n = Object.keys(e), r = Object.keys(t);
158
- return n.length === r.length && n.every((n) => e[n] === t[n]);
159
- }
160
- function xe(e, t, n) {
161
- return e.map((e) => {
162
- let r = t.get(e.id) ?? e.data, i = n?.[e.id], a = i ? {
163
- ...r,
164
- state: i
165
- } : r;
166
- return be(e.data.state, a.state) ? e : {
167
- ...e,
168
- data: a
169
- };
170
- });
171
- }
172
- function Se(e) {
173
- let t = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map(), r = (e) => typeof e == "string" && e !== "";
174
- for (let i of e ?? []) {
175
- let e = i.anchor === "node" ? r(i.node) ? t : null : i.anchor === "edge" && r(i.from) && r(i.to) ? n : null;
176
- if (!e) continue;
177
- let a = i.anchor === "node" ? i.node : T(i.from, i.to), o = e.get(a);
178
- o ? o.push(i) : e.set(a, [i]);
179
- }
180
- return {
181
- byNode: t,
182
- byEdge: n
183
- };
184
- }
185
- var Ce = 8, X = {
186
- control: {
187
- width: 10,
188
- height: 10
189
- },
190
- chip: {
191
- width: 80,
192
- height: 20
193
- }
194
- }, we = 2;
195
- function Te(e, t, n, r) {
196
- let i = n === "LR", a = i ? e.y : e.x, o = i ? e.x : e.y, s = i ? r.width : r.height, c = i ? r.height : r.width, l = t.filter((e) => {
197
- let t = (i ? e.x : e.y) - s, n = (i ? e.width : e.height) + s * 2;
198
- return o >= t && o <= t + n;
199
- });
200
- if (l.length === 0) return 0;
201
- let u = (e) => {
202
- let t = a;
203
- for (let n = 0; n <= we; n += 1) {
204
- let r = l.find((e) => {
205
- let n = (i ? e.y : e.x) - c, r = (i ? e.height : e.width) + c * 2;
206
- return t >= n && t <= n + r;
207
- });
208
- if (!r) return t - a;
209
- if (n === we) return null;
210
- let o = i ? r.y : r.x, s = i ? r.height : r.width;
211
- t = e > 0 ? o + s + c + Ce : o - c - Ce;
212
- }
213
- return null;
214
- }, d = u(-1), f = u(1);
215
- return d === null && f === null ? null : d === null ? f : f === null || Math.abs(d) <= Math.abs(f) ? d : f;
216
- }
217
- function Ee(e) {
218
- if (e.error || e.nodes.length < 3) return !1;
219
- let t = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map();
220
- for (let r of e.edges) {
221
- if (r.data?.whenLabel !== void 0 || r.data?.backEdge) return !0;
222
- t.set(r.source, (t.get(r.source) ?? 0) + 1), n.set(r.target, (n.get(r.target) ?? 0) + 1);
223
- }
224
- for (let e of t.values()) if (e > 1) return !0;
225
- for (let e of n.values()) if (e > 1) return !0;
226
- return !1;
227
- }
228
- function De(e, t) {
229
- return e.nodes.find((e) => e.id === t)?.data.config?.join === "any_failed" && !e.edges.some((e) => e.source === t);
230
- }
231
- function Oe(e, t) {
232
- return {
233
- "elk.algorithm": "layered",
234
- "elk.direction": e === "LR" ? "RIGHT" : "DOWN",
235
- "elk.edgeRouting": "ORTHOGONAL",
236
- "elk.layered.considerModelOrder.strategy": "NODES_AND_EDGES",
237
- "elk.layered.cycleBreaking.strategy": "MODEL_ORDER",
238
- "elk.layered.crossingMinimization.strategy": "LAYER_SWEEP",
239
- "elk.layered.nodePlacement.strategy": "BRANDES_KOEPF",
240
- "elk.layered.nodePlacement.bk.fixedAlignment": "BALANCED",
241
- "elk.layered.feedbackEdges": "true",
242
- "elk.layered.spacing.nodeNodeBetweenLayers": String(Math.max(t.rank, 40)),
243
- "elk.spacing.nodeNode": String(Math.max(t.cross, 20)),
244
- "elk.spacing.edgeNode": "14",
245
- "elk.spacing.edgeEdge": "10",
246
- "elk.layered.spacing.edgeNodeBetweenLayers": "14",
247
- "elk.layered.spacing.edgeEdgeBetweenLayers": "10",
248
- "elk.padding": "[top=0,left=0,bottom=0,right=0]",
249
- "elk.separateConnectedComponents": "false"
250
- };
251
- }
252
- function ke(e) {
253
- return {
254
- "elk.aspectRatio": String(e),
255
- "elk.layered.wrapping.strategy": "MULTI_EDGE",
256
- "elk.layered.wrapping.additionalEdgeSpacing": "16",
257
- "elk.layered.wrapping.correctionFactor": "1.0"
258
- };
259
- }
260
- function Ae(e, t, n, r) {
261
- if (n === "LR") {
262
- let n = r ? 38 : t / 2;
263
- return {
264
- inX: 0,
265
- inY: n,
266
- outX: e,
267
- outY: n
268
- };
269
- }
270
- let i = r ? 38 : e / 2;
271
- return {
272
- inX: i,
273
- inY: 0,
274
- outX: i,
275
- outY: t
276
- };
277
- }
278
- var je = 5, Me = 16;
279
- function Ne(e, t) {
280
- let n = [];
281
- for (let r of e.nodes) {
282
- if (r.data.kind !== "foreach") continue;
283
- let i = `${r.id}-b`, a = e.nodes.filter((e) => e.id.startsWith(i) && /^\d+$/.test(e.id.slice(i.length)));
284
- if (a.length < je) continue;
285
- let o = new Set(a.map((e) => e.id)), s = [...new Set(e.edges.filter((e) => o.has(e.source) && !o.has(e.target)).map((e) => e.target))], c = Math.max(...a.map((e) => e.width ?? 0)), l = Math.max(...a.map((e) => e.height ?? 0)), u = t === "LR" ? Math.ceil(Math.sqrt(a.length * 1.6)) : 2, d = Math.ceil(a.length / u);
286
- n.push({
287
- source: r.id,
288
- members: a.map((e) => e.id),
289
- targets: s,
290
- cols: u,
291
- cellW: c,
292
- cellH: l,
293
- width: u * c + (u - 1) * Me + 2 * Q,
294
- height: d * l + (d - 1) * Me + 2 * Q + ze
295
- });
296
- }
297
- return n;
298
- }
299
- var Z = (e) => `grid:${e}`;
300
- function Pe(e, t, n, r = !1, i = !0) {
301
- let a = e.spacing ?? {
302
- rank: 72,
303
- cross: 24
304
- }, o = Le(e, i), s = Ne(e, t), c = new Set(s.flatMap((e) => e.members)), l = t === "LR", u = (e) => {
305
- let n = e.width ?? 0, i = e.height ?? 0, a = Ae(n, i, t, r);
306
- return {
307
- id: e.id,
308
- width: n,
309
- height: i,
310
- layoutOptions: {
311
- "elk.portConstraints": "FIXED_POS",
312
- ...o.has(e.id) ? { "elk.layered.layering.layerConstraint": "LAST" } : {}
313
- },
314
- ports: [{
315
- id: `${e.id}:in`,
316
- x: a.inX,
317
- y: a.inY,
318
- width: 0,
319
- height: 0
320
- }, {
321
- id: `${e.id}:out`,
322
- x: a.outX,
323
- y: a.outY,
324
- width: 0,
325
- height: 0
326
- }]
327
- };
328
- }, d = (e) => ({
329
- id: Z(e.source),
330
- width: e.width,
331
- height: e.height,
332
- layoutOptions: { "elk.portConstraints": "FIXED_POS" },
333
- ports: [{
334
- id: `${Z(e.source)}:in`,
335
- x: l ? 0 : e.width / 2,
336
- y: l ? e.height / 2 : 0,
337
- width: 0,
338
- height: 0
339
- }, {
340
- id: `${Z(e.source)}:out`,
341
- x: l ? e.width : e.width / 2,
342
- y: l ? e.height / 2 : e.height,
343
- width: 0,
344
- height: 0
345
- }]
346
- });
347
- return {
348
- id: "root",
349
- layoutOptions: {
350
- ...Oe(t, a),
351
- ...n === void 0 ? {} : ke(n)
352
- },
353
- children: e.nodes.flatMap((e) => {
354
- let t = s.find((t) => t.members[0] === e.id);
355
- return t ? [d(t)] : c.has(e.id) ? [] : [u(e)];
356
- }),
357
- edges: [...e.edges.filter((e) => !o.has(e.target) && !c.has(e.source) && !c.has(e.target)).map((e) => ({
358
- id: e.id,
359
- sources: [`${e.source}:out`],
360
- targets: [`${e.target}:in`]
361
- })), ...s.flatMap((e) => [{
362
- id: `${Z(e.source)}:enter`,
363
- sources: [`${e.source}:out`],
364
- targets: [`${Z(e.source)}:in`]
365
- }, ...e.targets.filter((e) => !o.has(e)).map((t) => ({
366
- id: `${Z(e.source)}:leave:${t}`,
367
- sources: [`${Z(e.source)}:out`],
368
- targets: [`${t}:in`]
369
- }))])]
370
- };
371
- }
372
- function Fe(e) {
373
- let t = 0, n = {
374
- x: e[0].x,
375
- y: e[0].y
376
- };
377
- for (let r = 1; r < e.length; r += 1) {
378
- let i = e[r - 1], a = e[r], o = Math.hypot(a.x - i.x, a.y - i.y);
379
- o > t && (t = o, n = {
380
- x: (i.x + a.x) / 2,
381
- y: (i.y + a.y) / 2
382
- });
383
- }
384
- return n;
385
- }
386
- function Ie(e) {
387
- let t = [];
388
- for (let n of e.sections ?? []) t.push(n.startPoint, ...n.bendPoints ?? [], n.endPoint);
389
- return t;
390
- }
391
- function Le(e, t) {
392
- return t ? new Set(e.nodes.filter((t) => De(e, t.id)).map((e) => e.id)) : /* @__PURE__ */ new Set();
393
- }
394
- function Re(e, t, n, r = !0) {
395
- let i = /* @__PURE__ */ new Map();
396
- for (let e of t.children ?? []) {
397
- if (e.x === void 0 || e.y === void 0) return null;
398
- i.set(e.id, {
399
- x: e.x,
400
- y: e.y
401
- });
402
- }
403
- let a = Ne(e, n), o = [];
404
- for (let n of a) {
405
- let r = i.get(Z(n.source));
406
- if (!r) return null;
407
- n.members.forEach((e, t) => {
408
- let a = t % n.cols, o = Math.floor(t / n.cols);
409
- i.set(e, {
410
- x: r.x + Q + a * (n.cellW + Me),
411
- y: r.y + Q + ze + o * (n.cellH + Me)
412
- });
413
- });
414
- let a = e.nodes.find((e) => e.id === n.source)?.data.config?.maxConcurrency, s = e.compact && e.direction === "LR" ? (e) => ((e.width ?? 0) - 76) / 2 : () => 0, c = new Map(e.nodes.map((e) => [e.id, e])), l = (t.edges ?? []).filter((e) => e.id.startsWith(`${Z(n.source)}:`)).map((e) => {
415
- let t = Ie(e).map((e) => ({
416
- x: e.x,
417
- y: e.y
418
- })), n = c.get(e.sources[0].replace(/:out$/, "")), r = c.get(e.targets[0].replace(/:in$/, ""));
419
- return t.length >= 2 && n && (t[0].x -= s(n)), t.length >= 2 && r && (t[t.length - 1].x += s(r)), { points: t };
420
- }).filter((e) => e.points.length >= 2);
421
- o.push({
422
- id: `frame:${Z(n.source)}`,
423
- x: r.x,
424
- y: r.y,
425
- width: n.width,
426
- height: n.height,
427
- lanes: n.members.length,
428
- agents: n.members.filter((t) => e.nodes.find((e) => e.id === t)?.data.kind === "agent.run").length,
429
- forEach: typeof a == "number" ? { concurrency: a } : {},
430
- connectors: l
431
- });
432
- }
433
- let s = new Set(a.flatMap((e) => e.members));
434
- if (e.nodes.some((e) => !i.has(e.id))) return null;
435
- let c = /* @__PURE__ */ new Map();
436
- for (let e of t.edges ?? []) c.set(e.id, e);
437
- let l = Le(e, r), u = /* @__PURE__ */ new Map();
438
- for (let t of e.edges) l.has(t.target) && u.set(t.target, (u.get(t.target) ?? 0) + 1);
439
- let d = e.nodes.map((e) => {
440
- let t = u.get(e.id);
441
- return {
442
- ...e,
443
- position: i.get(e.id),
444
- ...t === void 0 ? {} : { data: {
445
- ...e.data,
446
- subtitle: `If any of ${t} step${t === 1 ? "" : "s"} fails`
447
- } }
448
- };
449
- }), f = e.edges.map((e) => {
450
- if (s.has(e.source) || s.has(e.target)) return {
451
- ...e,
452
- hidden: !0
453
- };
454
- if (u.has(e.target)) return {
455
- ...e,
456
- hidden: !0,
457
- ...e.data ? { data: {
458
- ...e.data,
459
- foldedFailureInput: !0
460
- } } : {}
461
- };
462
- let t = c.get(e.id), n = t ? Ie(t) : [];
463
- if (n.length < 2) return e;
464
- let r = i.get(e.source), a = i.get(e.target);
465
- return {
466
- ...e,
467
- type: q,
468
- data: {
469
- ...e.data ?? { kind: "spine" },
470
- route: {
471
- points: n.map((e) => ({
472
- x: e.x,
473
- y: e.y
474
- })),
475
- label: Fe(n),
476
- from: r,
477
- to: a
478
- }
479
- }
480
- };
481
- }), p = {
482
- ...e,
483
- nodes: d,
484
- edges: f,
485
- engine: "elk"
486
- }, m = [...o, ...Be(p)];
487
- return m.length > 0 ? {
488
- ...p,
489
- groups: m
490
- } : p;
491
- }
492
- var Q = 10, ze = 18;
493
- function Be(e) {
494
- let t = (e) => e.includes("|") ? null : e, n = e.edges.filter((e) => !e.data?.backEdge && !e.hidden), r = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map();
495
- for (let e of n) r.set(e.target, [...r.get(e.target) ?? [], e]), i.set(e.source, [...i.get(e.source) ?? [], e]);
496
- let a = new Map(e.nodes.map((e) => [e.id, e])), o = /* @__PURE__ */ new Map();
497
- for (let t of e.nodes) {
498
- if (S(t.id) !== null) continue;
499
- let e = r.get(t.id) ?? [];
500
- if (e.length === 0 || e.some((e) => e.data?.whenLabel !== void 0) || t.data.config && "if" in t.data.config) continue;
501
- let n = e.map((e) => e.source).sort().join("|");
502
- o.set(n, [...o.get(n) ?? [], t.id]);
503
- }
504
- let s = [];
505
- for (let [n, c] of o) {
506
- if (c.length < 2) continue;
507
- let o = /* @__PURE__ */ new Set();
508
- for (let t of c) {
509
- let n = t;
510
- o.add(n);
511
- for (let t = 0; t < e.nodes.length; t += 1) {
512
- let e = i.get(n) ?? [];
513
- if (e.length !== 1 || e[0].data?.whenLabel !== void 0) break;
514
- let t = e[0].target;
515
- if ((r.get(t) ?? []).length !== 1 || o.has(t)) break;
516
- let s = a.get(t)?.data.config;
517
- if (s && "if" in s) break;
518
- o.add(t), n = t;
519
- }
520
- }
521
- let l = [...o].map((e) => a.get(e)).filter(Boolean), u = Math.min(...l.map((e) => e.position.x)) - Q, d = Math.min(...l.map((e) => e.position.y)) - Q - ze, f = Math.max(...l.map((e) => e.position.x + (e.width ?? 0))) + Q, p = Math.max(...l.map((e) => e.position.y + (e.height ?? 0))) + Q;
522
- if (e.nodes.some((e) => {
523
- if (o.has(e.id)) return !1;
524
- let t = e.position.x + (e.width ?? 0), n = e.position.y + (e.height ?? 0);
525
- return e.position.x < f && t > u && e.position.y < p && n > d;
526
- })) continue;
527
- let m = t(n), h = m ? a.get(m) : void 0, g = h?.data.config?.maxConcurrency;
528
- s.push({
529
- ...h?.data.kind === "foreach" ? { forEach: typeof g == "number" ? { concurrency: g } : {} } : {},
530
- id: `frame:${n}`,
531
- x: u,
532
- y: d,
533
- width: f - u,
534
- height: p - d,
535
- lanes: c.length,
536
- agents: l.filter((e) => e.data.kind === "agent.run").length
537
- });
538
- }
539
- return s;
540
- }
541
- async function Ve(e, t, n, r = He, i = {}) {
542
- let a = i.foldFailureInputs ?? !0, o = await s();
543
- if (!o) return null;
544
- try {
545
- let i = Re(e, await o.layout(Pe(e, t, void 0, n, a)), t, a);
546
- if (!i) return null;
547
- let s = qe(i);
548
- if (t !== "LR" || We(e) < Ge || s < r * Ue) return i;
549
- let c = Re(e, await o.layout(Pe(e, t, r, n, a)), t, a);
550
- return c && Je(c, r) > Je(i, r) ? c : i;
551
- } catch {
552
- return null;
553
- }
554
- }
555
- var He = 2.2, Ue = 1.6;
556
- function We(e) {
557
- let t = Ne(e, "LR");
558
- return e.nodes.length - t.reduce((e, t) => e + t.members.length, 0) + t.length;
559
- }
560
- var Ge = 12;
561
- function Ke(e) {
562
- let t = e.nodes.flatMap((e) => [e.position.x, e.position.x + (e.width ?? 0)]), n = e.nodes.flatMap((e) => [e.position.y, e.position.y + (e.height ?? 0)]);
563
- return {
564
- width: Math.max(...t) - Math.min(...t),
565
- height: Math.max(...n) - Math.min(...n)
566
- };
567
- }
568
- function qe(e) {
569
- let { width: t, height: n } = Ke(e);
570
- return t / Math.max(n, 1);
571
- }
572
- function Je(e, t) {
573
- let { width: n, height: r } = Ke(e);
574
- return Math.min(t / Math.max(n, 1), 1 / Math.max(r, 1));
575
- }
576
- var Ye = { padding: "12px" };
577
- function Xe(e) {
578
- return e ? 1.5 : 1;
579
- }
580
- function Ze(e) {
581
- return e ? .55 : .35;
582
- }
583
- var Qe = .28;
584
- function $e(e, t) {
585
- return e.engine === "elk" && t === "LR" ? Qe : void 0;
586
- }
587
- function et(e) {
588
- if (e.length === 0) return {
589
- x: 0,
590
- y: 0,
591
- width: 0,
592
- height: 0
593
- };
594
- let t = Infinity, n = Infinity, r = -Infinity, i = -Infinity;
595
- for (let a of e) t = Math.min(t, a.position.x), n = Math.min(n, a.position.y), r = Math.max(r, a.position.x + (a.width ?? 0)), i = Math.max(i, a.position.y + (a.height ?? 0));
596
- return {
597
- x: t,
598
- y: n,
599
- width: r - t,
600
- height: i - n
601
- };
602
- }
603
- function tt(e) {
604
- let t = et(e.nodes);
605
- if (!e.groups || e.groups.length === 0) return t;
606
- let n = Math.min(t.x, ...e.groups.map((e) => e.x)), r = Math.min(t.y, ...e.groups.map((e) => e.y)), i = Math.max(t.x + t.width, ...e.groups.map((e) => e.x + e.width)), a = Math.max(t.y + t.height, ...e.groups.map((e) => e.y + e.height));
607
- return {
608
- x: n,
609
- y: r,
610
- width: i - n,
611
- height: a - r
612
- };
613
- }
614
- function nt(e, t, n, r, i) {
615
- let a = tt(e), o = rt(a, t, n, r, $e(e, i));
616
- if (i !== "TB") return o;
617
- let s = a.height * o.zoom > n ? Math.max(o.y, 44 - a.y * o.zoom) : o.y, c = e.nodes[0];
618
- if (!c || a.width * o.zoom <= t) return {
619
- ...o,
620
- y: s
621
- };
622
- let l = c.position.x + (c.width ?? 0) / 2;
623
- return {
624
- ...o,
625
- x: t / 2 - l * o.zoom,
626
- y: s
627
- };
628
- }
629
- function rt(e, t, n, r, i = Ze(r)) {
630
- let a = f(e, t, n, i, Xe(r), Ye.padding), o = (e, t) => e + Math.max(0, -(e + t * a.zoom));
631
- return {
632
- zoom: a.zoom,
633
- x: o(a.x, e.x),
634
- y: o(a.y, e.y)
635
- };
636
- }
637
- var it = {
638
- grow: .12,
639
- shrink: .75
640
- }, $ = (e, t, n) => e + (t - e) * n, at = (e) => e < .5 ? 4 * e * e * e : 1 - (-2 * e + 2) ** 3 / 2, ot = (0, K.createContext)("LR"), st = (0, K.createContext)(!1), ct = (0, K.createContext)(void 0), lt = (0, K.createContext)(!1), ut = (0, K.createContext)(!1), dt = (0, K.createContext)(/* @__PURE__ */ new Map()), ft = (0, K.createContext)(null), pt = (0, K.createContext)(null);
641
- function mt(e) {
642
- return e.data?.kind !== "fork" && S(e.source) === null;
643
- }
644
- var ht = "!h-2 !w-2 !min-w-0 !border-0 !bg-transparent opacity-0", gt = "!z-10 !h-2.5 !w-2.5 !min-w-0 !rounded-full !border !border-border !bg-muted-foreground/70 opacity-100 transition-opacity hover:!bg-primary";
645
- function _t(e, t) {
646
- let n = t ? (M.width - 76) / 2 : 0, r = (e, t) => ({
647
- left: e,
648
- top: t,
649
- right: "auto",
650
- bottom: "auto",
651
- transform: "translate(-50%, -50%)"
652
- });
653
- switch (e) {
654
- case g.Left: return r(n, 38);
655
- case g.Right: return r(n + 76, 38);
656
- case g.Top: return r(n + 38, 0);
657
- default: return r(n + 38, 76);
658
- }
659
- }
660
- function vt({ id: e, data: t, sourcePosition: n, targetPosition: r }) {
661
- let i = t, a = i.state, s = (0, K.useContext)(ot), l = (0, K.useContext)(st), u = (0, K.useContext)(lt), d = (0, K.useContext)(ut), f = (0, K.useContext)(ct), p = (0, K.useContext)(dt).get(e), m = oe(p), h = (0, K.useContext)(ft), ee = S(e) !== null, _ = f !== void 0 && f === e, v = s === "LR", te = r ?? (v ? g.Left : g.Top), ne = n ?? (v ? g.Right : g.Bottom), y = E(i.tone, i.kind), b = i.kind === "agent.run", x = b && a?.model ? re(a.model) : i.subtitle, C = b && a?.model ? a.model : i.model, w = u && i.tone !== "trigger", T = w ? a?.status ?? "queued" : a?.status, ce = B(a?.durationMs), A = se(a?.costUsd), M = b ? ie(a?.inputTokens, a?.outputTokens) : void 0, P = (() => {
662
- let e = a?.status === "failed" && a.error ? {
663
- text: a.error,
664
- tone: "error",
665
- label: "Error"
666
- } : a && a.status !== "failed" && a.outputPreview ? {
667
- text: a.outputPreview,
668
- tone: "default",
669
- label: "Output"
670
- } : null;
671
- if (!e) return null;
672
- let t = e.text.trim();
673
- if (!t) return null;
674
- let n = de(D(t, 240), b && e.tone !== "error");
675
- return n.kind === "empty" ? null : {
676
- shape: n,
677
- tone: e.tone,
678
- label: e.label
679
- };
680
- })(), fe = ee && h ? /* @__PURE__ */ (0, G.jsx)("button", {
681
- type: "button",
682
- "data-testid": "wf-trigger-delete",
683
- title: "Remove this trigger",
684
- "aria-label": "Remove this trigger",
685
- className: "nodrag nopan -m-1 flex h-6 w-6 shrink-0 items-center justify-center p-1 text-muted-foreground transition hover:text-[var(--surface-danger-text)]",
686
- onClick: (t) => {
687
- t.stopPropagation(), h(e);
688
- },
689
- children: /* @__PURE__ */ (0, G.jsx)("span", {
690
- className: "flex h-4 w-4 items-center justify-center rounded-full border border-border bg-card shadow-sm",
691
- children: /* @__PURE__ */ (0, G.jsx)(o, {
692
- size: 10,
693
- "aria-hidden": !0
694
- })
695
- })
696
- }) : null, V = d ? gt : ht, he = /* @__PURE__ */ (0, G.jsxs)(G.Fragment, { children: [!i.isRoot && /* @__PURE__ */ (0, G.jsx)(c, {
697
- type: "target",
698
- position: te,
699
- className: V,
700
- style: l ? _t(te, v) : void 0
701
- }), /* @__PURE__ */ (0, G.jsx)(c, {
702
- type: "source",
703
- position: ne,
704
- className: V,
705
- style: l ? _t(ne, v) : void 0
706
- })] }), H = It(l);
707
- if (l) return /* @__PURE__ */ (0, G.jsxs)("div", {
708
- className: `relative flex h-full w-full ${v ? "flex-col items-center" : "flex-row items-center"}`,
709
- children: [
710
- he,
711
- /* @__PURE__ */ (0, G.jsxs)("span", {
712
- "data-testid": "wf-node-card",
713
- className: "relative flex items-center justify-center rounded-xl border bg-card shadow-sm transition-colors",
714
- style: {
715
- width: 76,
716
- height: 76,
717
- ...a ? N(a.status) : m ? ae(m) : {
718
- borderColor: le,
719
- boxShadow: z
720
- },
721
- ..._ ? O : {}
722
- },
723
- children: [
724
- /* @__PURE__ */ (0, G.jsx)("span", {
725
- className: "wf-node-body-in flex items-center justify-center",
726
- children: /* @__PURE__ */ (0, G.jsx)(L, {
727
- kind: i.kind,
728
- provider: i.provider,
729
- model: C,
730
- accent: y,
731
- tile: 47
732
- })
733
- }),
734
- p && m && /* @__PURE__ */ (0, G.jsx)(R, {
735
- problems: p,
736
- className: "-left-1.5 -top-1.5 absolute"
737
- }),
738
- fe && /* @__PURE__ */ (0, G.jsx)("span", {
739
- className: "-right-1.5 -top-1.5 absolute",
740
- children: fe
741
- }),
742
- i.badge && !a && /* @__PURE__ */ (0, G.jsx)("span", {
743
- className: "-right-1.5 -top-1.5 absolute rounded-full border border-border bg-card px-1.5 py-[1px] font-medium text-[10px] text-muted-foreground",
744
- children: i.badge
745
- }),
746
- a && /* @__PURE__ */ (0, G.jsx)("span", {
747
- className: `-right-1 -top-1 absolute h-2.5 w-2.5 rounded-full border-2 ${a.status === "running" ? "animate-pulse" : ""}`,
748
- ...a.status === "running" ? { "data-motion": "essential" } : {},
749
- style: {
750
- background: k[a.status],
751
- borderColor: "hsl(var(--card))"
752
- },
753
- role: "img",
754
- "aria-label": ue[a.status]
755
- })
756
- ]
757
- }),
758
- /* @__PURE__ */ (0, G.jsxs)("div", {
759
- className: `wf-node-body-in min-w-0 ${v ? "mt-2 w-full px-1 text-center" : "ml-2 flex-1 text-left"}`,
760
- children: [
761
- /* @__PURE__ */ (0, G.jsx)("div", {
762
- className: "truncate font-semibold text-[12px] text-foreground leading-tight",
763
- style: H > 1 ? {
764
- fontSize: 12 * H,
765
- ...v ? { marginInline: -16 } : {}
766
- } : void 0,
767
- title: i.title,
768
- children: i.title
769
- }),
770
- x && H <= Ft && /* @__PURE__ */ (0, G.jsx)("div", {
771
- className: "truncate text-[11px] text-muted-foreground leading-tight",
772
- title: x,
773
- children: x
774
- }),
775
- (ce || A) && /* @__PURE__ */ (0, G.jsx)("div", {
776
- className: "truncate text-[10px] text-muted-foreground/90 leading-tight tabular-nums",
777
- children: [ce, A].filter(Boolean).join(" · ")
778
- })
779
- ]
780
- })
781
- ]
782
- });
783
- let U = (e) => /* @__PURE__ */ (0, G.jsxs)("div", {
784
- "data-testid": "wf-node-card",
785
- className: "relative flex h-full w-full flex-col overflow-hidden rounded-xl border bg-card shadow-sm transition-colors",
786
- style: {
787
- ...T ? N(T) : m ? ae(m) : {
788
- borderColor: le,
789
- boxShadow: z
790
- },
791
- ..._ ? O : {}
792
- },
793
- children: [
794
- he,
795
- /* @__PURE__ */ (0, G.jsx)("span", {
796
- "aria-hidden": !0,
797
- className: "pointer-events-none absolute inset-x-0 top-0 h-0.5",
798
- style: { background: `color-mix(in srgb, ${y} 70%, transparent)` }
799
- }),
800
- e
801
- ]
802
- }), W = /* @__PURE__ */ (0, G.jsxs)("div", {
803
- className: "flex shrink-0 items-center gap-2.5",
804
- children: [
805
- /* @__PURE__ */ (0, G.jsx)(L, {
806
- kind: i.kind,
807
- provider: i.provider,
808
- model: C,
809
- accent: y,
810
- tile: 34
811
- }),
812
- /* @__PURE__ */ (0, G.jsxs)("div", {
813
- className: "min-w-0 flex-1",
814
- children: [/* @__PURE__ */ (0, G.jsx)("div", {
815
- className: "truncate font-semibold text-[13px] text-foreground leading-tight",
816
- title: i.title,
817
- children: i.title
818
- }), x && /* @__PURE__ */ (0, G.jsx)("div", {
819
- className: "truncate text-[11px] text-muted-foreground leading-tight",
820
- title: x,
821
- children: x
822
- })]
823
- }),
824
- p && m && /* @__PURE__ */ (0, G.jsx)(R, { problems: p }),
825
- T ? /* @__PURE__ */ (0, G.jsx)(j, { status: T }) : i.badge && /* @__PURE__ */ (0, G.jsx)("span", {
826
- className: "shrink-0 rounded-full border border-border bg-surface-container-high px-2 py-[1px] font-medium text-[10px] text-muted-foreground",
827
- children: i.badge
828
- }),
829
- fe
830
- ]
831
- }), ge = T ? /* @__PURE__ */ (0, G.jsx)(F, {
832
- status: T,
833
- rounds: b ? a?.rounds : void 0,
834
- cost: A,
835
- tokens: M,
836
- elapsed: ce
837
- }) : null, q = (e) => i.description ? /* @__PURE__ */ (0, G.jsx)("p", {
838
- className: `mt-2 line-clamp-2 shrink-0 text-[11px] leading-snug ${e ? "text-foreground" : "text-muted-foreground"}`,
839
- title: i.description,
840
- children: i.description
841
- }) : null, J = T && !P && me(T) ? /* @__PURE__ */ (0, G.jsx)("div", {
842
- className: "mt-2 flex flex-1 items-center text-[11px] text-muted-foreground italic",
843
- children: me(T)
844
- }) : null, _e = (e) => P ? /* @__PURE__ */ (0, G.jsxs)("div", {
845
- className: "mt-2 min-h-0 grow shrink-0 rounded-lg border border-border bg-surface-container-high/60 px-2 py-1.5",
846
- children: [/* @__PURE__ */ (0, G.jsx)("div", {
847
- className: "mb-1 font-semibold text-[9px] text-muted-foreground uppercase tracking-[0.09em]",
848
- children: P.label
849
- }), /* @__PURE__ */ (0, G.jsx)(I, {
850
- shape: P.shape,
851
- tone: P.tone,
852
- rows: e
853
- })]
854
- }) : J, Y = (e, t = "") => /* @__PURE__ */ (0, G.jsx)("div", {
855
- className: `wf-node-body-in flex min-h-0 flex-1 flex-col overflow-hidden px-3.5 pt-2.5 pb-2 ${t}`,
856
- children: e
857
- });
858
- if (!w) return U(Y(/* @__PURE__ */ (0, G.jsxs)(G.Fragment, { children: [W, q(!1)] })));
859
- if (i.kind === "decision") return U(/* @__PURE__ */ (0, G.jsxs)(G.Fragment, { children: [Y(/* @__PURE__ */ (0, G.jsxs)(G.Fragment, { children: [/* @__PURE__ */ (0, G.jsxs)("div", {
860
- className: "flex shrink-0 items-start gap-2.5",
861
- children: [/* @__PURE__ */ (0, G.jsx)(L, {
862
- kind: i.kind,
863
- provider: i.provider,
864
- model: C,
865
- accent: y,
866
- tile: 34
867
- }), /* @__PURE__ */ (0, G.jsxs)("div", {
868
- className: "min-w-0 flex-1",
869
- children: [/* @__PURE__ */ (0, G.jsx)("div", {
870
- className: "truncate font-semibold text-[13px] text-foreground leading-tight",
871
- title: i.title,
872
- children: i.title
873
- }), /* @__PURE__ */ (0, G.jsxs)("div", {
874
- className: "mt-0.5 flex items-center gap-2",
875
- children: [x && /* @__PURE__ */ (0, G.jsx)("span", {
876
- className: "truncate text-[11px] text-muted-foreground leading-tight",
877
- title: x,
878
- children: x
879
- }), T && /* @__PURE__ */ (0, G.jsx)("span", {
880
- className: "ml-auto shrink-0",
881
- children: /* @__PURE__ */ (0, G.jsx)(j, { status: T })
882
- })]
883
- })]
884
- })]
885
- }), P && T === "failed" ? /* @__PURE__ */ (0, G.jsx)("div", {
886
- className: "mt-2 min-h-0 shrink-0",
887
- children: /* @__PURE__ */ (0, G.jsx)(I, {
888
- shape: P.shape,
889
- tone: P.tone,
890
- rows: 2
891
- })
892
- }) : q(!0)] })), ge] }));
893
- if (pe(i.kind)) return U(/* @__PURE__ */ (0, G.jsxs)(G.Fragment, { children: [Y(/* @__PURE__ */ (0, G.jsxs)(G.Fragment, { children: [W, /* @__PURE__ */ (0, G.jsx)("div", {
894
- className: "mt-1.5 min-h-0 shrink-0",
895
- children: P && /* @__PURE__ */ (0, G.jsx)(I, {
896
- shape: P.shape,
897
- tone: P.tone,
898
- rows: 1
899
- })
900
- })] }), "justify-center"), ge] }));
901
- if (b) {
902
- let e = [i.title, x].filter(Boolean).join(" · ");
903
- return U(/* @__PURE__ */ (0, G.jsxs)(G.Fragment, { children: [Y(/* @__PURE__ */ (0, G.jsxs)(G.Fragment, { children: [/* @__PURE__ */ (0, G.jsxs)("div", {
904
- className: "flex shrink-0 items-center gap-1.5",
905
- children: [
906
- /* @__PURE__ */ (0, G.jsx)(L, {
907
- kind: i.kind,
908
- provider: i.provider,
909
- model: C,
910
- accent: y,
911
- tile: 18
912
- }),
913
- /* @__PURE__ */ (0, G.jsx)("span", {
914
- className: "truncate font-medium text-[11px] text-muted-foreground",
915
- title: e,
916
- children: e
917
- }),
918
- /* @__PURE__ */ (0, G.jsx)("span", { className: "flex-1" }),
919
- T && /* @__PURE__ */ (0, G.jsx)(j, { status: T })
920
- ]
921
- }), /* @__PURE__ */ (0, G.jsx)("div", {
922
- className: "mt-2 min-h-0 flex-1 text-foreground leading-snug",
923
- children: P ? /* @__PURE__ */ (0, G.jsx)(I, {
924
- shape: P.shape,
925
- tone: P.tone,
926
- rows: 5
927
- }) : T && T !== "succeeded" && T !== "failed" && i.description ? /* @__PURE__ */ (0, G.jsx)("p", {
928
- className: "line-clamp-5 text-[11px] text-muted-foreground leading-snug",
929
- title: i.description,
930
- children: i.description
931
- }) : T && /* @__PURE__ */ (0, G.jsx)("span", {
932
- className: "text-muted-foreground italic",
933
- children: me(T)
934
- })
935
- })] })), ge] }));
936
- }
937
- return U(/* @__PURE__ */ (0, G.jsxs)(G.Fragment, { children: [Y(/* @__PURE__ */ (0, G.jsxs)(G.Fragment, { children: [W, _e(3)] })), ge] }));
938
- }
939
- function yt(e) {
940
- if (!e) return null;
941
- let t = ("changedTouches" in e ? e.changedTouches[0] : null) ?? ("clientX" in e ? e : null);
942
- return t ? {
943
- x: t.clientX,
944
- y: t.clientY
945
- } : null;
946
- }
947
- var bt = ".react-flow__pane, .react-flow__background";
948
- function xt(e, t) {
949
- if (!t) return !1;
950
- let n = typeof document > "u" ? null : document.elementFromPoint(e.x, e.y);
951
- return n?.matches(bt) ? t.contains(n) : !1;
952
- }
953
- var St = (0, K.createContext)([]);
954
- function Ct(e) {
955
- return d((0, K.useCallback)((t) => {
956
- let n = t.nodeLookup.get(e);
957
- return n ? n.position : null;
958
- }, [e]), (e, t) => e === t || e !== null && t !== null && wt(e, t));
959
- }
960
- function wt(e, t) {
961
- return Math.abs(e.x - t.x) < .5 && Math.abs(e.y - t.y) < .5;
962
- }
963
- var Tt = 8;
964
- function Et(e) {
965
- if (e.length === 0) return "";
966
- let t = `M ${e[0].x} ${e[0].y}`;
967
- for (let n = 1; n < e.length - 1; n += 1) {
968
- let r = e[n - 1], i = e[n], a = e[n + 1], o = Math.hypot(i.x - r.x, i.y - r.y), s = Math.hypot(a.x - i.x, a.y - i.y), c = Math.min(Tt, o / 2, s / 2);
969
- if (c < .5) {
970
- t += ` L ${i.x} ${i.y}`;
971
- continue;
972
- }
973
- let l = {
974
- x: i.x - (i.x - r.x) / o * c,
975
- y: i.y - (i.y - r.y) / o * c
976
- }, u = {
977
- x: i.x + (a.x - i.x) / s * c,
978
- y: i.y + (a.y - i.y) / s * c
979
- };
980
- t += ` L ${l.x} ${l.y} Q ${i.x} ${i.y} ${u.x} ${u.y}`;
981
- }
982
- let n = e[e.length - 1];
983
- return `${t} L ${n.x} ${n.y}`;
984
- }
985
- function Dt(e) {
986
- let t = e.slice(1).map((t, n) => Math.hypot(t.x - e[n].x, t.y - e[n].y)), n = t.reduce((e, t) => e + t, 0) / 2;
987
- for (let r = 0; r < t.length; r += 1) {
988
- if (n <= t[r] && t[r] > 0) {
989
- let i = n / t[r];
990
- return {
991
- x: e[r].x + (e[r + 1].x - e[r].x) * i,
992
- y: e[r].y + (e[r + 1].y - e[r].y) * i
993
- };
994
- }
995
- n -= t[r];
996
- }
997
- return e[e.length - 1] ?? {
998
- x: 0,
999
- y: 0
1000
- };
1001
- }
1002
- function Ot(e, t, n, r, i) {
1003
- let a = Ee(e), [o, s] = (0, K.useState)(null), [c, l] = (0, K.useState)(!1), u = (0, K.useRef)(null);
1004
- (0, K.useEffect)(() => {
1005
- if (!a || r === null) return;
1006
- let o = !0;
1007
- return Ve(e, t, n, r, { foldFailureInputs: i }).then((t) => {
1008
- o && s({
1009
- base: e,
1010
- graph: t ?? e
1011
- });
1012
- }), () => {
1013
- o = !1;
1014
- };
1015
- }, [
1016
- e,
1017
- t,
1018
- a,
1019
- r,
1020
- i
1021
- ]), (0, K.useEffect)(() => {
1022
- if (c) return;
1023
- let e = setTimeout(() => l(!0), kt);
1024
- return () => clearTimeout(e);
1025
- }, [c]);
1026
- let d, f;
1027
- a ? o?.base === e ? (d = o.graph, f = !0) : (d = u.current ?? e, f = !1) : (d = e, f = !0);
1028
- let p = f || u.current !== null || c;
1029
- return p && (u.current = d), {
1030
- graph: d,
1031
- ready: p
1032
- };
1033
- }
1034
- var kt = 600;
1035
- function At() {
1036
- let [e, t] = (0, K.useState)(null), n = (0, K.useRef)(null);
1037
- return [e, (0, K.useCallback)((e) => {
1038
- if (n.current?.disconnect(), n.current = null, !e) return;
1039
- let r = () => {
1040
- let { width: n, height: r } = e.getBoundingClientRect();
1041
- if (n === 0 || r === 0) return;
1042
- let i = n / r;
1043
- t(i < .9 ? .6 : i < 1.6 ? 1.2 : 2.2);
1044
- };
1045
- if (r(), typeof ResizeObserver > "u") {
1046
- t((e) => e ?? 2.2);
1047
- return;
1048
- }
1049
- n.current = new ResizeObserver(r), n.current.observe(e);
1050
- }, [])];
1051
- }
1052
- function jt(e) {
1053
- if (e.forEach) {
1054
- let t = e.forEach.concurrency;
1055
- return t !== void 0 && t < e.lanes ? `${e.lanes} items · ${t} at a time` : `${e.lanes} items in parallel`;
1056
- }
1057
- return e.agents > e.lanes ? `${e.lanes} parallel lanes · ${e.agents} agents` : e.agents === e.lanes ? `${e.lanes} agents in parallel` : `${e.lanes} in parallel`;
1058
- }
1059
- function Mt({ frames: e }) {
1060
- let t = e.flatMap((e) => e.connectors ?? []);
1061
- return /* @__PURE__ */ (0, G.jsxs)(l, { children: [t.length > 0 && /* @__PURE__ */ (0, G.jsxs)("svg", {
1062
- "aria-hidden": !0,
1063
- className: "pointer-events-none absolute top-0 left-0 overflow-visible",
1064
- style: { zIndex: -1 },
1065
- width: 1,
1066
- height: 1,
1067
- children: [/* @__PURE__ */ (0, G.jsx)("defs", { children: /* @__PURE__ */ (0, G.jsx)("marker", {
1068
- id: "wf-grid-arrow",
1069
- viewBox: "0 0 10 10",
1070
- refX: "9",
1071
- refY: "5",
1072
- markerWidth: "7",
1073
- markerHeight: "7",
1074
- orient: "auto-start-reverse",
1075
- children: /* @__PURE__ */ (0, G.jsx)("path", {
1076
- d: "M 0 0 L 10 5 L 0 10 z",
1077
- fill: Rt
1078
- })
1079
- }) }), t.map((e, t) => /* @__PURE__ */ (0, G.jsx)("path", {
1080
- d: Et(e.points),
1081
- fill: "none",
1082
- stroke: Rt,
1083
- strokeWidth: 1.75,
1084
- markerEnd: "url(#wf-grid-arrow)"
1085
- }, t))]
1086
- }), e.map((e) => /* @__PURE__ */ (0, G.jsx)("div", {
1087
- "data-testid": "wf-parallel-frame",
1088
- className: "pointer-events-none absolute rounded-xl border border-primary/30 border-dashed bg-primary/[0.04]",
1089
- style: {
1090
- transform: `translate(${e.x}px, ${e.y}px)`,
1091
- width: e.width,
1092
- height: e.height,
1093
- zIndex: -1
1094
- },
1095
- children: /* @__PURE__ */ (0, G.jsx)("span", {
1096
- className: "absolute top-1 left-2.5 font-medium text-[10px] text-primary/80 uppercase tracking-wide",
1097
- children: jt(e)
1098
- })
1099
- }, e.id))] });
1100
- }
1101
- var Nt = .75, Pt = 2.4, Ft = 1.25;
1102
- function It(e) {
1103
- return d((0, K.useCallback)((t) => {
1104
- if (!e) return 1;
1105
- let n = t.transform[2];
1106
- return n >= Nt ? 1 : Math.min(Pt, Math.round(Nt / n * 10) / 10);
1107
- }, [e]));
1108
- }
1109
- function Lt(e) {
1110
- if (!e) return null;
1111
- let t = {};
1112
- for (let n of Object.keys(e)) {
1113
- let e = /^a(\d+)-b(\d+)$/.exec(n);
1114
- if (!e) continue;
1115
- let r = Number(e[1]);
1116
- t[r] = Math.max(t[r] ?? 0, Number(e[2]) + 1);
1117
- }
1118
- let n = Object.entries(t).filter(([, e]) => e > 1);
1119
- return n.length > 0 ? JSON.stringify(Object.fromEntries(n)) : null;
1120
- }
1121
- var Rt = "color-mix(in srgb, hsl(var(--muted-foreground)) 38%, transparent)", zt = 40, Bt = "rounded-full border border-border bg-card/90 px-1.5 py-[1px] text-[10px] leading-tight backdrop-blur";
1122
- function Vt({ id: e, source: t, target: n, sourceX: r, sourceY: i, targetX: a, targetY: o, sourcePosition: s, targetPosition: c, data: l, markerEnd: u, style: d }) {
1123
- let f = (0, K.useContext)(pt), h = Ct(t), g = Ct(n), _ = l?.route, v = _ !== void 0 && h !== null && g !== null && wt(h, _.from) && wt(g, _.to), [te, ne, y] = p({
1124
- sourceX: r,
1125
- sourceY: i,
1126
- sourcePosition: s,
1127
- targetX: a,
1128
- targetY: o,
1129
- targetPosition: c
1130
- }), b = v ? [
1131
- {
1132
- x: r,
1133
- y: i
1134
- },
1135
- ..._.points.slice(1, -1),
1136
- {
1137
- x: a,
1138
- y: o
1139
- }
1140
- ] : [], re = v ? Et(b) : te, ie = v ? _.label ?? Dt(b) : {
1141
- x: ne,
1142
- y
1143
- }, ae = ie.x, x = ie.y, S = l?.backEdge === !0, C = l?.whenLabel, T = l?.maxNodeVisits, E = l?.problems, D = oe(E), se = l?.insertable === !0 && f !== null, O = (0, K.useContext)(St), k = (0, K.useContext)(ot), A = se || D ? Te({
1144
- x: ae,
1145
- y: x
1146
- }, O, k, D ? X.chip : X.control) : 0, j = A ?? 0, M = A === null, N = k === "LR", le = ae + (N ? 0 : j), F = x + (N ? j : 0);
1147
- return /* @__PURE__ */ (0, G.jsxs)(G.Fragment, { children: [/* @__PURE__ */ (0, G.jsx)(ee, {
1148
- id: e,
1149
- path: re,
1150
- markerEnd: u,
1151
- style: d
1152
- }), /* @__PURE__ */ (0, G.jsx)(m, { children: /* @__PURE__ */ (0, G.jsxs)("div", {
1153
- className: "nodrag nopan absolute flex flex-col items-center gap-0.5",
1154
- style: {
1155
- zIndex: 1,
1156
- transform: `translate(-50%, -50%) translate(${le}px, ${F}px)`
1157
- },
1158
- children: [
1159
- E && D && /* @__PURE__ */ (0, G.jsxs)("span", {
1160
- "data-testid": "wf-edge-problem",
1161
- "data-severity": D,
1162
- className: `${Bt} max-w-40 truncate ${M ? "" : "pointer-events-auto"}`,
1163
- style: w(D),
1164
- children: [/* @__PURE__ */ (0, G.jsx)("span", {
1165
- "aria-hidden": !0,
1166
- title: P(E),
1167
- children: E.length === 1 ? E[0].message : `${E.length} problems`
1168
- }), /* @__PURE__ */ (0, G.jsx)(ce, { problems: E })]
1169
- }),
1170
- C && /* @__PURE__ */ (0, G.jsx)("span", {
1171
- title: C,
1172
- className: `${Bt} max-w-40 truncate text-muted-foreground`,
1173
- children: C
1174
- }),
1175
- S && /* @__PURE__ */ (0, G.jsx)("span", {
1176
- title: T === void 0 ? "Loops back to a step that has already run" : `Loops back — each node runs at most ${T} time${T === 1 ? "" : "s"} per run`,
1177
- className: `${Bt} shrink-0 text-foreground`,
1178
- children: T === void 0 ? "↺" : `↺ ≤${T}`
1179
- }),
1180
- se && /* @__PURE__ */ (0, G.jsx)("button", {
1181
- type: "button",
1182
- "data-testid": "wf-edge-insert",
1183
- title: "Insert a step here",
1184
- "aria-label": "Insert a step here",
1185
- className: `flex h-5 w-5 items-center justify-center rounded-full border border-border bg-card text-muted-foreground shadow-sm backdrop-blur transition hover:border-primary hover:text-primary ${M ? "" : "pointer-events-auto"}`,
1186
- onClick: (e) => {
1187
- e.stopPropagation(), f(t, n);
1188
- },
1189
- children: /* @__PURE__ */ (0, G.jsx)(U, {
1190
- size: 12,
1191
- "aria-hidden": !0
1192
- })
1193
- })
1194
- ]
1195
- }) })] });
1196
- }
1197
- var Ht = { wfNode: vt }, Ut = { [q]: Vt };
1198
- function Wt(e, t, n) {
1199
- return e.map((e) => {
1200
- let r = t?.[e.target]?.status, i = fe(t ? r : void 0), a = e.data?.backEdge === !0;
1201
- return {
1202
- ...e,
1203
- animated: !a && r === "running",
1204
- style: {
1205
- strokeWidth: 1.75,
1206
- stroke: i,
1207
- ...a ? { strokeDasharray: "6 3" } : {}
1208
- },
1209
- markerEnd: {
1210
- type: v.ArrowClosed,
1211
- width: 15,
1212
- height: 15,
1213
- color: i
1214
- },
1215
- ...a && n !== void 0 && e.data ? { data: {
1216
- ...e.data,
1217
- maxNodeVisits: n
1218
- } } : {}
1219
- };
1220
- });
1221
- }
1222
- function Gt(e, t, n, r) {
1223
- return t.size === 0 && !e.some(n) ? e : e.map((e) => {
1224
- let i = t.get(e.id), a = oe(i), o = n(e);
1225
- if (!a && !o) return e;
1226
- let s = a && !r ? w(a).color : void 0;
1227
- return {
1228
- ...e,
1229
- type: q,
1230
- data: {
1231
- ...e.data ?? { kind: "spine" },
1232
- ...i ? { problems: i } : {},
1233
- ...o ? { insertable: !0 } : {}
1234
- },
1235
- ...s ? {
1236
- style: {
1237
- ...e.style,
1238
- stroke: s
1239
- },
1240
- markerEnd: e.markerEnd && typeof e.markerEnd == "object" ? {
1241
- ...e.markerEnd,
1242
- color: s
1243
- } : e.markerEnd
1244
- } : {}
1245
- };
1246
- });
1247
- }
1248
- function Kt({ yaml: e, variant: t = "full", direction: n, defaultCompact: a, onCompactChange: o, className: s, wrap: c = !1, nodeState: l, edges: d, maxNodeVisits: f, selectedNodeId: p, onNodeClick: m, onEdgeConnect: g, onEdgeDelete: ee, onEdgeClick: v, onEdgeInsert: re, onNodeInsert: ie, onTriggerAdd: ae, onTriggerDelete: oe, problems: S }) {
1249
- let w = g !== void 0, T = w ? re : void 0, E = T !== void 0, D = w ? ie : void 0, se = w ? ae : void 0, ce = w ? oe : void 0, O = t === "preview", [k, A] = (0, K.useState)(a ?? l === void 0), j = (0, K.useRef)(k), [M, N] = (0, K.useState)(!1), P = O || k, [le, F] = (0, K.useState)(P), I = (0, K.useRef)(null), L = (0, K.useRef)(null), [ue, de] = At(), R = n ?? (ue !== null && ue < .9 ? "TB" : "LR"), z = (0, K.useRef)(!1), [fe, pe] = (0, K.useState)(0), B = l !== void 0, me = (0, K.useMemo)(() => Lt(l), [l]), V = (0, K.useMemo)(() => me ? JSON.parse(me) : void 0, [me]), { graph: H, ready: W } = Ot((0, K.useMemo)(() => ye(e, {
1250
- nodeState: B ? {} : void 0,
1251
- direction: R,
1252
- compact: P,
1253
- wrap: c,
1254
- reserveEdgeInsert: E,
1255
- ...d ? { edges: d } : {},
1256
- ...V ? { itemCounts: V } : {}
1257
- }), [
1258
- e,
1259
- B,
1260
- R,
1261
- P,
1262
- c,
1263
- E,
1264
- d,
1265
- V
1266
- ]), R, P, ue, !w), q = H.compact ?? P, J = H.direction ?? R, _e = C(L, !H.error && H.nodes.length > 0), Y = (0, K.useMemo)(() => H.nodes.map((e) => ({
1267
- x: e.position.x,
1268
- y: e.position.y,
1269
- width: e.width ?? 0,
1270
- height: e.height ?? 0
1271
- })), [H]), ve = (0, K.useMemo)(() => Se(S), [S]), be = (0, K.useMemo)(() => Gt(Wt(H.edges, l, f), ve.byEdge, (e) => E && mt(e), B).map((e) => ({
1272
- ...e,
1273
- ...e.hidden && e.data?.foldedFailureInput && l?.[e.source]?.status === "failed" ? { hidden: !1 } : {},
1274
- deletable: w ? mt(e) : !1
1275
- })), [
1276
- H.edges,
1277
- l,
1278
- f,
1279
- w,
1280
- ve,
1281
- E,
1282
- B
1283
- ]), [Ce, X, we] = u(H.nodes), [Te, Ee, De] = b(be), Oe = (0, K.useRef)(Ce);
1284
- Oe.current = Ce;
1285
- let ke = (0, K.useRef)(l);
1286
- ke.current = l, (0, K.useEffect)(() => {
1287
- Ee(be);
1288
- }, [be, Ee]), (0, K.useEffect)(() => {
1289
- let e = new Map(H.nodes.map((e) => [e.id, e.data]));
1290
- X((t) => xe(t, e, l));
1291
- }, [
1292
- l,
1293
- H,
1294
- X
1295
- ]);
1296
- let Ae = (0, K.useRef)(!1), je = (0, K.useRef)(W);
1297
- (0, K.useEffect)(() => {
1298
- let e = W && !je.current;
1299
- je.current = W;
1300
- let t = (e) => {
1301
- let t = ke.current;
1302
- return t ? e.map((e) => t[e.id] ? {
1303
- ...e,
1304
- data: {
1305
- ...e.data,
1306
- state: t[e.id]
1307
- }
1308
- } : e) : e;
1309
- };
1310
- if (!Ae.current) {
1311
- Ae.current = !0, X(t(H.nodes)), F(q);
1312
- return;
1313
- }
1314
- let n = I.current, r = L.current?.getBoundingClientRect();
1315
- if (!n || !r || r.width === 0 || r.height === 0) {
1316
- X(t(H.nodes)), F(q);
1317
- return;
1318
- }
1319
- let i = nt(H, r.width, r.height, q, J);
1320
- z.current = !0;
1321
- let a = Oe.current, o = new Map(a.map((e) => [e.id, e])), s = a.length === H.nodes.length && H.nodes.every((e) => o.has(e.id));
1322
- if (e || !s || !x() || typeof requestAnimationFrame > "u") {
1323
- X(t(H.nodes)), F(q), n.setViewport(i);
1324
- return;
1325
- }
1326
- let c = setTimeout(() => F(q), 220 * (q ? it.shrink : it.grow)), l = n.getViewport(), u = performance.now(), d = requestAnimationFrame(function e(r) {
1327
- let a = Math.min(1, (r - u) / 220), s = at(a);
1328
- X(t(a >= 1 ? H.nodes : H.nodes.map((e) => {
1329
- let t = o.get(e.id);
1330
- if (!t || t.width === void 0 || t.height === void 0) return e;
1331
- let n = $(t.width, e.width ?? t.width, s), r = $(t.height, e.height ?? t.height, s);
1332
- return {
1333
- ...e,
1334
- position: {
1335
- x: $(t.position.x, e.position.x, s),
1336
- y: $(t.position.y, e.position.y, s)
1337
- },
1338
- width: n,
1339
- height: r,
1340
- style: {
1341
- ...e.style,
1342
- width: n,
1343
- height: r
1344
- }
1345
- };
1346
- }))), n.setViewport({
1347
- x: $(l.x, i.x, s),
1348
- y: $(l.y, i.y, s),
1349
- zoom: $(l.zoom, i.zoom, s)
1350
- }), a < 1 && (d = requestAnimationFrame(e));
1351
- });
1352
- return () => {
1353
- cancelAnimationFrame(d), clearTimeout(c);
1354
- };
1355
- }, [
1356
- H,
1357
- q,
1358
- X,
1359
- W,
1360
- J
1361
- ]);
1362
- let Me = (0, K.useRef)(H);
1363
- Me.current = H;
1364
- let Ne = (0, K.useRef)(q);
1365
- Ne.current = q;
1366
- let Z = (0, K.useRef)(J);
1367
- Z.current = J;
1368
- let Pe = (0, K.useCallback)(() => {
1369
- requestAnimationFrame(() => {
1370
- let e = I.current, t = L.current?.getBoundingClientRect();
1371
- if (!e || !t || t.width === 0 || t.height === 0) return;
1372
- let n = Me.current;
1373
- e.setViewport(nt(n, t.width, t.height, Ne.current, Z.current));
1374
- });
1375
- }, []);
1376
- (0, K.useEffect)(() => {
1377
- if (z.current) return;
1378
- let e = I.current, t = L.current?.getBoundingClientRect();
1379
- e && t && t.width !== 0 && t.height !== 0 && (e.setViewport(nt(H, t.width, t.height, q, J)), z.current = !0);
1380
- }, [
1381
- fe,
1382
- H,
1383
- q,
1384
- J
1385
- ]), (0, K.useEffect)(() => {
1386
- let e = L.current;
1387
- if (!e || typeof ResizeObserver > "u") return;
1388
- let t = new ResizeObserver(() => {
1389
- if (z.current) {
1390
- t.disconnect();
1391
- return;
1392
- }
1393
- pe((e) => e + 1);
1394
- });
1395
- return t.observe(e), () => t.disconnect();
1396
- }, []);
1397
- let Fe = (0, K.useRef)(M);
1398
- (0, K.useEffect)(() => {
1399
- if (Fe.current === M || (Fe.current = M, Pe(), !M)) return;
1400
- let e = (e) => {
1401
- e.key !== "Escape" || e.defaultPrevented || document.querySelector("[aria-modal=\"true\"]") || N(!1);
1402
- };
1403
- return window.addEventListener("keydown", e), () => window.removeEventListener("keydown", e);
1404
- }, [M, Pe]);
1405
- let Ie = (0, K.useCallback)((e, t) => {
1406
- m?.(t.id, t.data);
1407
- }, [m]), Le = (0, K.useCallback)((e, t) => {
1408
- if (!D || t.toNode || t.toHandle) return;
1409
- let n = t.fromNode, r = t.fromHandle;
1410
- if (!n || !r) return;
1411
- let i = yt(e);
1412
- i && xt(i, L.current) && D(n.id, r.type === "target" ? "before" : "after");
1413
- }, [D]), Re = (0, K.useCallback)((e) => {
1414
- if (e.key !== "Enter" && e.key !== " " || !(e.target instanceof HTMLElement)) return;
1415
- let t = e.target.closest(".react-flow__node")?.getAttribute("data-id");
1416
- if (!t) return;
1417
- let n = Oe.current.find((e) => e.id === t);
1418
- n && (e.preventDefault(), e.stopPropagation(), m?.(n.id, n.data));
1419
- }, [m]);
1420
- return H.error || H.nodes.length === 0 ? /* @__PURE__ */ (0, G.jsx)("div", {
1421
- className: `flex items-center justify-center rounded-lg border border-border border-dashed p-4 text-center text-muted-foreground text-xs ${s ?? ""}`,
1422
- children: H.error ?? "Nothing to show"
1423
- }) : /* @__PURE__ */ (0, G.jsx)(ot.Provider, {
1424
- value: J,
1425
- children: /* @__PURE__ */ (0, G.jsx)(st.Provider, {
1426
- value: le,
1427
- children: /* @__PURE__ */ (0, G.jsx)(lt.Provider, {
1428
- value: B,
1429
- children: /* @__PURE__ */ (0, G.jsx)(ct.Provider, {
1430
- value: p,
1431
- children: /* @__PURE__ */ (0, G.jsx)(ut.Provider, {
1432
- value: w,
1433
- children: /* @__PURE__ */ (0, G.jsx)(St.Provider, {
1434
- value: Y,
1435
- children: /* @__PURE__ */ (0, G.jsx)(dt.Provider, {
1436
- value: ve.byNode,
1437
- children: /* @__PURE__ */ (0, G.jsx)(ft.Provider, {
1438
- value: ce ?? null,
1439
- children: /* @__PURE__ */ (0, G.jsx)(pt.Provider, {
1440
- value: T ?? null,
1441
- children: /* @__PURE__ */ (0, G.jsx)("div", {
1442
- ref: (e) => {
1443
- L.current = e, de(e);
1444
- },
1445
- className: `wf-graph ${W ? "" : "opacity-0"} ${M ? "!fixed !inset-3 !z-40 !h-auto !w-auto overflow-hidden rounded-xl border border-border bg-background shadow-2xl" : s ?? ""}`,
1446
- "data-layout": W ? "ready" : "pending",
1447
- children: /* @__PURE__ */ (0, G.jsxs)(h, {
1448
- nodes: Ce,
1449
- edges: Te,
1450
- onNodesChange: we,
1451
- onEdgesChange: De,
1452
- nodeTypes: Ht,
1453
- edgeTypes: Ut,
1454
- colorMode: _e,
1455
- onInit: (e) => {
1456
- I.current = e, z.current || pe((e) => e + 1);
1457
- },
1458
- onNodeClick: m ? Ie : void 0,
1459
- onKeyDown: m ? Re : void 0,
1460
- proOptions: { hideAttribution: !0 },
1461
- nodesDraggable: !O,
1462
- nodesConnectable: w,
1463
- deleteKeyCode: w ? ["Backspace", "Delete"] : null,
1464
- edgesReconnectable: !1,
1465
- elementsSelectable: !O,
1466
- edgesFocusable: w,
1467
- onConnect: w ? (e) => {
1468
- e.source && e.target && g(e.source, e.target);
1469
- } : void 0,
1470
- onEdgesDelete: w ? (e) => {
1471
- for (let t of e) mt(t) && ee?.(t.source, t.target);
1472
- } : void 0,
1473
- onConnectEnd: D ? Le : void 0,
1474
- onEdgeClick: w ? (e, t) => {
1475
- mt(t) && v?.(t.source, t.target);
1476
- } : void 0,
1477
- zoomOnScroll: !1,
1478
- zoomOnPinch: !0,
1479
- zoomOnDoubleClick: !O,
1480
- panOnDrag: !0,
1481
- preventScrolling: !1,
1482
- minZoom: .2,
1483
- maxZoom: 1.5,
1484
- children: [
1485
- /* @__PURE__ */ (0, G.jsx)(y, {
1486
- gap: 18,
1487
- size: 1.4,
1488
- color: "hsl(var(--muted-foreground) / 0.38)"
1489
- }),
1490
- H.groups && H.groups.length > 0 && /* @__PURE__ */ (0, G.jsx)(Mt, { frames: H.groups }),
1491
- !O && H.nodes.length > zt && /* @__PURE__ */ (0, G.jsx)(_, {
1492
- pannable: !0,
1493
- zoomable: !0,
1494
- position: "bottom-left",
1495
- style: {
1496
- width: 168,
1497
- height: 104
1498
- },
1499
- className: "!hidden sm:!block",
1500
- ariaLabel: "Workflow overview"
1501
- }),
1502
- !O && /* @__PURE__ */ (0, G.jsxs)(G.Fragment, { children: [/* @__PURE__ */ (0, G.jsx)(te, {
1503
- showInteractive: !1,
1504
- position: "bottom-right",
1505
- fitViewOptions: { padding: Ye.padding }
1506
- }), /* @__PURE__ */ (0, G.jsxs)(ne, {
1507
- position: "top-left",
1508
- className: "flex items-center gap-1",
1509
- children: [
1510
- se && /* @__PURE__ */ (0, G.jsxs)("button", {
1511
- type: "button",
1512
- "data-testid": "wf-trigger-add",
1513
- onClick: se,
1514
- title: "Add a trigger",
1515
- "aria-label": "Add a trigger",
1516
- className: "flex items-center gap-1 rounded-md border border-border bg-card/80 px-2 py-1 text-[11px] text-muted-foreground shadow-sm backdrop-blur transition hover:text-foreground",
1517
- children: [/* @__PURE__ */ (0, G.jsx)(U, {
1518
- size: 12,
1519
- "aria-hidden": !0
1520
- }), "Trigger"]
1521
- }),
1522
- /* @__PURE__ */ (0, G.jsxs)("button", {
1523
- type: "button",
1524
- onClick: () => {
1525
- let e = !j.current;
1526
- j.current = e, A(e), o?.(e);
1527
- },
1528
- "aria-pressed": k,
1529
- title: k ? "Expand nodes" : "Collapse nodes",
1530
- className: "flex items-center gap-1 rounded-md border border-border bg-card/80 px-2 py-1 text-[11px] text-muted-foreground shadow-sm backdrop-blur transition hover:text-foreground",
1531
- children: [k ? /* @__PURE__ */ (0, G.jsx)(r, { size: 12 }) : /* @__PURE__ */ (0, G.jsx)(i, { size: 12 }), k ? "Expand" : "Compact"]
1532
- }),
1533
- /* @__PURE__ */ (0, G.jsxs)("button", {
1534
- type: "button",
1535
- "data-testid": "wf-fullscreen",
1536
- onClick: () => N((e) => !e),
1537
- "aria-pressed": M,
1538
- title: M ? "Exit full screen (Esc)" : "Full screen",
1539
- "aria-label": M ? "Exit full screen" : "Full screen",
1540
- className: "flex items-center gap-1 rounded-md border border-border bg-card/80 px-2 py-1 text-[11px] text-muted-foreground shadow-sm backdrop-blur transition hover:text-foreground",
1541
- children: [M ? /* @__PURE__ */ (0, G.jsx)(ge, { size: 12 }) : /* @__PURE__ */ (0, G.jsx)(he, { size: 12 }), M ? "Exit" : "Full screen"]
1542
- })
1543
- ]
1544
- })] })
1545
- ]
1546
- })
1547
- })
1548
- })
1549
- })
1550
- })
1551
- })
1552
- })
1553
- })
1554
- })
1555
- })
1556
- });
1557
- }
1558
- //#endregion
1559
- export { Kt as WorkflowGraph };