@tangle-network/sandbox-cli 0.21.63 → 0.21.65

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 +31 -3
  2. package/SKILL.md +29 -1
  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 +10 -9
  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,4262 +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
- //#region node_modules/.pnpm/@tangle-network+charts@0.21.22_react@19.3.0/node_modules/@tangle-network/charts/dist/timeline-B7c-cede.js
4
- function r(e) {
5
- return String(e).replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
6
- }
7
- var i = [
8
- 281,
9
- 288,
10
- 466,
11
- 633,
12
- 642,
13
- 982,
14
- 644,
15
- 300,
16
- 365,
17
- 365,
18
- 501,
19
- 662,
20
- 288,
21
- 460,
22
- 288,
23
- 360,
24
- 631,
25
- 407,
26
- 610,
27
- 618,
28
- 646,
29
- 608,
30
- 620,
31
- 566,
32
- 619,
33
- 620,
34
- 288,
35
- 302,
36
- 662,
37
- 662,
38
- 662,
39
- 511,
40
- 966,
41
- 690,
42
- 654,
43
- 730,
44
- 722,
45
- 601,
46
- 590,
47
- 746,
48
- 743,
49
- 269,
50
- 571,
51
- 672,
52
- 565,
53
- 903,
54
- 753,
55
- 765,
56
- 639,
57
- 765,
58
- 644,
59
- 642,
60
- 646,
61
- 744,
62
- 690,
63
- 985,
64
- 682,
65
- 679,
66
- 629,
67
- 365,
68
- 360,
69
- 365,
70
- 471,
71
- 456,
72
- 323,
73
- 562,
74
- 612,
75
- 571,
76
- 612,
77
- 583,
78
- 370,
79
- 613,
80
- 591,
81
- 242,
82
- 242,
83
- 549,
84
- 242,
85
- 876,
86
- 591,
87
- 600,
88
- 612,
89
- 612,
90
- 376,
91
- 528,
92
- 327,
93
- 591,
94
- 562,
95
- 818,
96
- 546,
97
- 562,
98
- 552,
99
- 426,
100
- 333,
101
- 426,
102
- 662
103
- ], a = [
104
- 252,
105
- 321,
106
- 523,
107
- 644,
108
- 650,
109
- 1004,
110
- 663,
111
- 326,
112
- 373,
113
- 373,
114
- 540,
115
- 673,
116
- 319,
117
- 465,
118
- 319,
119
- 379,
120
- 660,
121
- 423,
122
- 623,
123
- 636,
124
- 666,
125
- 629,
126
- 640,
127
- 576,
128
- 640,
129
- 640,
130
- 319,
131
- 329,
132
- 673,
133
- 673,
134
- 673,
135
- 543,
136
- 999,
137
- 728,
138
- 659,
139
- 737,
140
- 722,
141
- 605,
142
- 588,
143
- 749,
144
- 746,
145
- 277,
146
- 580,
147
- 703,
148
- 565,
149
- 922,
150
- 759,
151
- 769,
152
- 645,
153
- 773,
154
- 652,
155
- 650,
156
- 660,
157
- 736,
158
- 728,
159
- 1020,
160
- 720,
161
- 713,
162
- 652,
163
- 373,
164
- 379,
165
- 373,
166
- 481,
167
- 469,
168
- 351,
169
- 574,
170
- 624,
171
- 583,
172
- 624,
173
- 591,
174
- 389,
175
- 625,
176
- 612,
177
- 262,
178
- 262,
179
- 569,
180
- 262,
181
- 900,
182
- 612,
183
- 609,
184
- 624,
185
- 624,
186
- 397,
187
- 549,
188
- 353,
189
- 612,
190
- 587,
191
- 839,
192
- 569,
193
- 588,
194
- 566,
195
- 455,
196
- 359,
197
- 455,
198
- 673
199
- ], o = {
200
- "·": 300,
201
- "×": 670,
202
- "—": 1e3,
203
- "–": 500,
204
- "…": 900,
205
- "≥": 670,
206
- "≤": 670,
207
- "±": 670,
208
- "→": 954,
209
- "−": 662
210
- }, s = 1.04;
211
- function c(e, t, n = "sans") {
212
- if (n === "mono") return e.length * .6 * t * s;
213
- let r = n === "sans-semibold" ? a : i, c = 0;
214
- for (let t of e) {
215
- let e = t.codePointAt(0) ?? 0;
216
- c += e >= 32 && e <= 126 ? r[e - 32] : o[t] ?? 620;
217
- }
218
- return c / 1e3 * t * s;
219
- }
220
- function l(e, t, n, r = "sans", i = 2) {
221
- let a = (e) => c(e, n, r) <= t, o = [], s = [], l = "", u = (e, t) => {
222
- o.push(l), s.push(t), l = e;
223
- };
224
- for (let t of e.split(/\s+/).filter(Boolean)) {
225
- let e = l ? `${l} ${t}` : t;
226
- if (a(e)) l = e;
227
- else if (a(t)) l ? u(t, " ") : l = t;
228
- else {
229
- let e = t.match(/[^\-/_·]+[\-/_·]?|[\-/_·]/g) ?? [t];
230
- for (let [t, n] of e.entries()) {
231
- let e = t === 0 ? " " : "", r = l ? `${l}${e}${n}` : n;
232
- a(r) || !l ? l = r : u(n, e);
233
- }
234
- }
235
- }
236
- if (l && o.push(l), o.length <= i && o.every(a)) return {
237
- lines: o,
238
- truncated: !1
239
- };
240
- let d = o.slice(0, i), f = o.slice(i - 1).reduce((e, t, n) => n === 0 ? t : `${e}${s[i - 2 + n]}${t}`, "");
241
- for (; f.length > 1 && !a(`${f}…`);) f = f.slice(0, -1);
242
- return d[i - 1] = `${f.trimEnd()}…`, {
243
- lines: d,
244
- truncated: !0
245
- };
246
- }
247
- function u(e, t, n, i, a) {
248
- return e.length === 1 ? `<text x="${t}" y="${n}" ${a}>${r(e[0])}</text>` : `<text x="${t}" y="${n}" ${a}>${e.map((e, n) => `<tspan x="${t}" dy="${n === 0 ? 0 : i}">${r(e)}</tspan>`).join("")}</text>`;
249
- }
250
- function d(e, t, n, r = "sans") {
251
- let i = [];
252
- for (let a of e) {
253
- let e = i[i.length - 1];
254
- e !== void 0 && c(`${e} · ${a}`, n, r) <= t ? i[i.length - 1] = `${e} · ${a}` : i.push(a);
255
- }
256
- return i;
257
- }
258
- function f(e, t, n = `${t}s`) {
259
- return e === 1 ? t : n;
260
- }
261
- function p(e) {
262
- return e.charAt(0).toUpperCase() + e.slice(1);
263
- }
264
- function m(e) {
265
- return e !== void 0 && Number.isFinite(e) && e > 720 ? Math.floor(e) : 720;
266
- }
267
- var h = (e) => Math.round(e * 100) / 100;
268
- function g(e, t, n) {
269
- let r = Math.ceil(t);
270
- return `<svg class="tgc-svg" xmlns="http://www.w3.org/2000/svg" width="${e}" height="${r}" viewBox="0 0 ${e} ${r}" aria-hidden="true" focusable="false">${n}</svg>`;
271
- }
272
- function _(e, t, n, r, i) {
273
- if (n <= 0) return "";
274
- let a = Math.min(4, r / 2, n);
275
- return `<path class="${i}" d="M${h(e)} ${h(t)}h${h(n - a)}a${a} ${a} 0 0 1 ${a} ${a}v${h(r - 2 * a)}a${a} ${a} 0 0 1 -${a} ${a}h-${h(n - a)}z"/>`;
276
- }
277
- function v(e, t, n, r, i, a = "") {
278
- return n <= 0 || r <= 0 ? "" : `<rect class="${i}" x="${h(e)}" y="${h(t)}" width="${h(n)}" height="${h(r)}"${a ? ` ${a}` : ""}/>`;
279
- }
280
- function y(e, t, n, r, i = 6) {
281
- if (!(n > 0) || !(r > 0)) return "";
282
- let a = "";
283
- for (let o = i / 2; o < n + r; o += i) {
284
- let i = Math.max(0, o - r), s = Math.min(n, o);
285
- a += `M${h(e + i)} ${h(t + o - i)}L${h(e + s)} ${h(t + o - s)}`;
286
- }
287
- return a;
288
- }
289
- function b(e, t, n, r, i) {
290
- return n <= 0 || r <= 0 ? "" : `<g class="${i}" data-hatched="true">${v(e, t, n, r, "tgc-hatch-bg")}<path class="tgc-hatch" d="${y(e, t, n, r)}"/></g>`;
291
- }
292
- function x(e, t, n, r, i) {
293
- return `<line class="${i}" x1="${h(e)}" y1="${h(t)}" x2="${h(n)}" y2="${h(r)}"/>`;
294
- }
295
- function S(e, t, n, r) {
296
- return `<circle class="${r}" cx="${h(e)}" cy="${h(t)}" r="${n}"/>`;
297
- }
298
- var C = [
299
- "circle",
300
- "square",
301
- "triangle",
302
- "diamond"
303
- ];
304
- function w(e, t, n, r) {
305
- let [i, a] = [h(t), h(n)];
306
- if (e === "square") {
307
- let e = h(r * .9);
308
- return `M${h(i - e)} ${h(a - e)}h${h(2 * e)}v${h(2 * e)}h${h(-2 * e)}z`;
309
- }
310
- if (e === "triangle") {
311
- let e = h(r * 1.2);
312
- return `M${i} ${h(a - e)}L${h(i + e)} ${h(a + e * .8)}L${h(i - e)} ${h(a + e * .8)}z`;
313
- }
314
- if (e === "diamond") {
315
- let e = h(r * 1.3);
316
- return `M${i} ${h(a - e)}L${h(i + e)} ${a}L${i} ${h(a + e)}L${h(i - e)} ${a}z`;
317
- }
318
- return `M${h(i - r)} ${a}a${r} ${r} 0 1 0 ${h(2 * r)} 0a${r} ${r} 0 1 0 ${h(-2 * r)} 0`;
319
- }
320
- function T(e, t) {
321
- return `<polyline class="${t}" points="${e.map(([e, t]) => `${h(e)},${h(t)}`).join(" ")}"/>`;
322
- }
323
- function E(e, t, n, i = {}) {
324
- let a = i.anchor && i.anchor !== "start" ? ` text-anchor="${i.anchor}"` : "", o = i.weight === 600 ? " font-weight=\"600\"" : "";
325
- return `<text class="${i.cls ?? "tgc-ink"}" x="${h(e)}" y="${h(t)}" font-size="${i.size ?? 12}"${a}${o}>${r(n)}</text>`;
326
- }
327
- function D(e, t) {
328
- return `<g><title>${r(e)}</title>${t}</g>`;
329
- }
330
- function O(e, t, n) {
331
- let i = t.map((e) => `<th scope="col"${e.numeric ? " class=\"tgc-n\"" : ""}>${r(e.label)}</th>`).join(""), a = n.map((e) => `<tr>${e.map((e, n) => n === 0 ? `<th scope="row">${r(e)}</th>` : `<td${t[n]?.numeric ? " class=\"tgc-n\"" : ""}>${r(e)}</td>`).join("")}</tr>`).join("");
332
- return `<table class="tgc-table"><caption>${r(e)}</caption><thead><tr>${i}</tr></thead><tbody>${a}</tbody></table>`;
333
- }
334
- var k = [
335
- "S",
336
- "A",
337
- "B",
338
- "C",
339
- "F"
340
- ], A = [
341
- "F",
342
- "C",
343
- "B",
344
- "A",
345
- "S"
346
- ];
347
- function j(e, t) {
348
- return A.indexOf(e) >= A.indexOf(t);
349
- }
350
- function M(e) {
351
- return `${Math.round(e * 100)}%`;
352
- }
353
- function N(e) {
354
- return e >= 100 ? `$${Math.round(e).toLocaleString("en-US")}` : e >= 1 ? `$${e.toFixed(2)}` : e >= .01 ? `$${e.toFixed(3)}` : `$${e.toFixed(4)}`;
355
- }
356
- function P(e) {
357
- let t = e / 1e3;
358
- return t < 60 ? `${Math.round(t)} s` : t < 3600 ? `${(t / 60).toFixed(1)} min` : `${(t / 3600).toFixed(1)} h`;
359
- }
360
- function F(e, t) {
361
- return `${e}/${t}`;
362
- }
363
- var I = {
364
- "task-cluster-bootstrap": "task-clustered bootstrap",
365
- "mcnemar-exact": "exact McNemar",
366
- wilson: "Wilson score"
367
- };
368
- function L(e) {
369
- return `${Math.round((e.level ?? 0) * 100)}% ${e.method ? I[e.method] : ""}`.trim();
370
- }
371
- function ee(e) {
372
- if (!e) return "no interval";
373
- let t = [e.level === null ? "level" : "", e.method === null ? "method" : ""].filter(Boolean);
374
- return t.length ? `the interval names no ${t.join(" or ")}` : e.method in I ? !Number.isFinite(e.level) || e.level <= 0 || e.level >= 1 ? "the interval level is outside 0–1" : !Number.isFinite(e.lower) || !Number.isFinite(e.upper) ? "the interval bounds are not finite" : e.lower <= e.upper ? null : "the interval bounds are out of order" : "the interval method is unknown";
375
- }
376
- function R(e) {
377
- return e === "descriptive" || e === "bootstrap";
378
- }
379
- function z(e, t) {
380
- return e === "none" ? t === 1 ? "1 unit" : `${t} units` : e === "insufficient" ? "too few units" : "";
381
- }
382
- function B(e) {
383
- return e.basis !== "unknown" && e.perSolvedUsd !== null && Number.isFinite(e.perSolvedUsd) && e.perSolvedUsd > 0 ? e.perSolvedUsd : null;
384
- }
385
- function V(e, t) {
386
- if (t === 0) return "no pass";
387
- let n = B(e);
388
- return n === null ? "unknown" : e.basis === "receipts" ? N(n) : `${N(n)} est.`;
389
- }
390
- function te(e) {
391
- return R(e.estimate) ? !Number.isFinite(e.rate) || e.rate < 0 || e.rate > 1 ? "rate is outside 0–1" : ee(e.interval) || (e.interval.method === "mcnemar-exact" ? "exact McNemar applies to paired comparisons, not rates" : e.estimate === "descriptive" && e.interval.method !== "wilson" ? `descriptive estimate does not support ${L(e.interval)}` : e.interval.lower < 0 || e.interval.upper > 1 ? "the rate interval is outside 0–1" : e.rate < e.interval.lower - 1e-6 || e.rate > e.interval.upper + 1e-6 ? "the rate falls outside its interval" : null) : `${e.estimate} estimate`;
392
- }
393
- function ne(e) {
394
- return !Number.isInteger(e.attempts) || e.attempts < 0 || !Number.isInteger(e.solved) || e.solved < 0 || e.solved > e.attempts ? "passed and attempt counts are invalid" : !Number.isFinite(e.rate) || e.rate < 0 || e.rate > 1 ? "rate is outside 0–1" : e.attempts > 0 && Math.abs(e.rate - e.solved / e.attempts) > 1e-6 ? "rate disagrees with passed/attempts" : e.attempts === 0 && e.rate !== 0 ? "rate has no attempts" : R(e.estimate) && e.attempts === 0 ? "drawable estimate has no attempts" : null;
395
- }
396
- function re(e) {
397
- if (e.length > 0 && e.every((e) => e.rank !== null && e.estimate === "bootstrap")) return [...e].sort((e, t) => e.rank - t.rank);
398
- let t = e.filter((e) => R(e.estimate)).sort((e, t) => t.rate - e.rate), n = e.filter((e) => !R(e.estimate)).sort((e, t) => t.attempts - e.attempts);
399
- return [...t, ...n];
400
- }
401
- function ie(e, t = 0, n = 0) {
402
- let r = e ? k.filter((t) => e[t] > 0).map((t) => `${e[t]}${t}`) : [];
403
- return n && r.push(`${n} flagged`), t && r.push(`${t}U`), r.join(" ");
404
- }
405
- function ae(e) {
406
- return e ? A.reduce((t, n) => t + e[n], 0) : 0;
407
- }
408
- function oe(e) {
409
- return "refused" in e;
410
- }
411
- var H = [
412
- "pass",
413
- "deadline",
414
- "died",
415
- "event",
416
- "release",
417
- "steer",
418
- "ruling",
419
- "wake"
420
- ], se = [
421
- "pass",
422
- "fail",
423
- "unknown"
424
- ], ce = [
425
- "after-pass",
426
- "idle",
427
- "missing",
428
- "blocked",
429
- "group"
430
- ], le = {
431
- release: "diamond",
432
- steer: "triangle",
433
- ruling: "square",
434
- wake: "circle"
435
- };
436
- function ue(e = [], t = [], n) {
437
- let r = (e) => !n || e >= n[0] && e <= n[1];
438
- for (let t of e) {
439
- if (!t || typeof t.label != "string" || !t.label.trim()) return "Every mark needs a label.";
440
- if (!H.includes(t.kind)) return `${t.label}: unknown mark kind.`;
441
- if (t.verdict !== void 0 && !se.includes(t.verdict)) return `${t.label}: a verdict is pass, fail or unknown.`;
442
- if (t.source !== void 0 && (typeof t.source != "string" || !t.source.trim())) return `${t.label}: a source needs a name.`;
443
- if (!Number.isFinite(t.at) || !r(t.at)) return `${t.label}: mark position must be finite and inside the axis domain.`;
444
- }
445
- for (let e of t) {
446
- if (!e || typeof e.label != "string" || !e.label.trim()) return "Every band needs a label.";
447
- if (!ce.includes(e.kind)) return `${e.label}: unknown band kind.`;
448
- if (!Number.isFinite(e.from) || !Number.isFinite(e.to) || (e.kind === "group" ? e.from > e.to : e.from >= e.to) || !r(e.from) || !r(e.to)) return `${e.label}: a band needs finite, increasing bounds inside the axis domain.`;
449
- }
450
- return null;
451
- }
452
- function de(e) {
453
- return e.kind === "event" && e.source === "gap";
454
- }
455
- function U(e) {
456
- return e.source ? `${e.label} · ${e.source}` : e.label;
457
- }
458
- function W(e) {
459
- return [
460
- e.kind,
461
- e.verdict,
462
- e.lane && `lane ${e.lane}`
463
- ].filter(Boolean).join(" · ");
464
- }
465
- function fe(e, t, n, r, i, a, o) {
466
- return e.map((e) => {
467
- if (e.kind === "group") return "";
468
- let s = a ? Math.max(e.from, a[0]) : e.from, c = a ? Math.min(e.to, a[1]) : e.to;
469
- if (c <= s) return "";
470
- let [l, u] = o ? o(s, c) : [t(s), t(c)], d = l, f = u - l, p = `tgc-band tgc-band-${e.kind}`, m = e.kind === "missing" ? b(d, n, f, r - n, p) : v(d, n, f, r - n, p) + (e.kind === "blocked" ? x(d, n, d + f, n, "tgc-band-wall") : "");
471
- return D(`${e.label}: ${i(e.from)} to ${i(e.to)}`, `<g data-band="${e.kind}">${m}</g>`);
472
- }).join("");
473
- }
474
- function pe(e = []) {
475
- return e.some((e) => e.kind === "group") ? 18 : 0;
476
- }
477
- function me(e, t, n, r, i, a, o, s) {
478
- return e.filter((e) => e.kind === "group").map((e) => {
479
- let c = s ? Math.max(e.from, s[0]) : e.from, u = s ? Math.min(e.to, s[1]) : e.to;
480
- if (u < c) return "";
481
- let [d, f] = t(c, u), p = f - d, m = p >= 24 ? l(e.label, p - 10, 12, "sans", 1).lines[0] : "", h = [d, f].filter((e) => e > i + .5 && e < a - .5).map((e) => x(e, n - 16, e, r, "tgc-group-edge")).join(""), g = x(d + 2, n - 3, f - 2, n - 3, "tgc-group-rule") + (m ? E(d + 3, n - 7, m, {
482
- size: 12,
483
- cls: "tgc-group-label"
484
- }) : "");
485
- return D(`${e.label}: ${o(e.from)} to ${o(e.to)}`, `<g data-band="group">${h}${g}</g>`);
486
- }).join("");
487
- }
488
- function he(e, t) {
489
- let n = [];
490
- for (let r of [...e].sort((e, t) => e.at - t.at)) {
491
- let e = t(r.at), i = n.at(-1), a = i?.marks[0], o = i && t(i.marks.at(-1).at);
492
- i && r.kind !== "ruling" && a.kind === r.kind && a.verdict === r.verdict && (e - o < 3 || e - o < 12 && U(a) === U(r)) ? i.marks.push(r) : n.push({
493
- x: e,
494
- marks: [r]
495
- });
496
- }
497
- return n;
498
- }
499
- function ge(e, t, n, r) {
500
- let i = r.rows ?? 3, a = Math.max(48, Math.min(200, (n - t) * .42)), o = Array.from({ length: i }, () => []), s = (e, t, n) => o[e].every(([e, r]) => n + 6 <= e || t >= r + 6), u = (e, r, u, d, f) => {
501
- let p = l(e, a, 12, "sans", 1).lines[0], m = c(p, 12);
502
- for (let e of f ? [d, d === "start" ? "end" : "start"] : [d]) {
503
- let [a, c] = e === "start" ? [r, r + m] : [u - m, u];
504
- if (!(a < t - 4 || c > n + 4)) {
505
- for (let t = 0; t < i; t++) if (s(t, a, c)) return o[t].push([a, c]), {
506
- row: t,
507
- x: e === "start" ? r : u,
508
- anchor: e,
509
- text: p
510
- };
511
- }
512
- }
513
- return null;
514
- }, [d, f] = r.window ?? [-Infinity, Infinity], p = [...(r.after ?? []).map((e) => u(`${U(e)} +${P(e.at - f)} →`, n, n, "end", !1)), ...(r.before ?? []).map((e) => u(`← ${U(e)} −${P(d - e.at)}`, t, t, "start", !1))].filter((e) => e !== null), m = /* @__PURE__ */ new Map();
515
- for (let r of [...e.filter((e) => !de(e.marks[0])), ...e.filter((e) => de(e.marks[0]))]) {
516
- let e = r.x > t + (n - t) * .62, i = u(U(r.marks[0]) + (r.marks.length > 1 ? ` (+${r.marks.length - 1})` : ""), r.x + 4, r.x - 4, e ? "end" : "start", !0);
517
- i && m.set(r, i);
518
- }
519
- return {
520
- placed: m,
521
- edges: p,
522
- rows: Math.max(0, ...[...m.values(), ...p].map((e) => e.row + 1))
523
- };
524
- }
525
- function G(e, t, n, r, i = {}) {
526
- return ge(he(e, t), n, r, i).rows;
527
- }
528
- function _e(e, t, n, r = 3.5) {
529
- let i = le[e];
530
- return i ? `<path class="tgc-mark-head" d="${w(i, t, n, r)}"/>` : "";
531
- }
532
- function K(e, t, n, r, i, a, o, s = n, c = {}) {
533
- let l = he(e, t), { placed: u, edges: d } = ge(l, i, a, c), f = (e) => s + 12 + e * 14, p = l.map((e) => {
534
- let { x: t, marks: i } = e, a = i[0], c = le[a.kind] !== void 0 && a.kind !== "ruling" || de(a), l = x(t, Math.min(n, s), t, c ? n + 4 : r, `tgc-mark tgc-mark-${a.kind}`);
535
- a.kind === "died" && (l += x(t - 4, r - 8, t + 4, r, "tgc-mark tgc-mark-died") + x(t - 4, r, t + 4, r - 8, "tgc-mark tgc-mark-died")), l += _e(a.kind, t, n + 4);
536
- let u = a.verdict ? ` data-verdict="${a.verdict}" class="tgc-verdict-${a.verdict}"` : "";
537
- return D(i.map((e) => `${U(e)}: ${o(e.at)}${e.verdict ? ` · ${e.verdict}` : ""}`).join("\n"), `<g data-mark="${a.kind}"${i.length > 1 ? ` data-merged="${i.length}"` : ""}${u}>${l}</g>`);
538
- }).join("");
539
- for (let e of l) {
540
- let t = u.get(e);
541
- t && (p += E(t.x, f(t.row), t.text, {
542
- size: 12,
543
- anchor: t.anchor,
544
- cls: "tgc-mark-label"
545
- }));
546
- }
547
- for (let e of d) p += `<g data-edge="${e.anchor === "end" ? "after" : "before"}">${E(e.x, f(e.row), e.text, {
548
- size: 12,
549
- anchor: e.anchor,
550
- cls: "tgc-mark-label tgc-mark-edge"
551
- })}</g>`;
552
- return p;
553
- }
554
- function ve(e, t, n, r) {
555
- if (!e.length && !t.length) return "";
556
- let i = [...e.map((e) => ({
557
- at: e.at,
558
- cells: [
559
- U(e),
560
- W(e),
561
- r(e.at),
562
- ""
563
- ]
564
- })), ...t.map((e) => ({
565
- at: e.from,
566
- cells: [
567
- e.label,
568
- e.kind === "missing" ? "no data" : e.kind,
569
- r(e.from),
570
- r(e.to)
571
- ]
572
- }))].sort((e, t) => e.at - t.at);
573
- return O(`Recorded events by ${n}`, [
574
- { label: "Event" },
575
- { label: "Kind" },
576
- {
577
- label: `${n} from`,
578
- numeric: !0
579
- },
580
- {
581
- label: `${n} to`,
582
- numeric: !0
583
- }
584
- ], i.map((e) => e.cells));
585
- }
586
- var q = "Vertical rules mark recorded events (solid: pass, dashed: deadline, cross: died, dotted: other; a diamond is a release, a triangle a steer, a square a ruling and a circle a wake, coloured by verdict when one is recorded); tinted spans are recorded periods, a wall-topped span is a system-wide block, and hatched spans have no data.", ye = [
587
- "ok",
588
- "quota",
589
- "lost",
590
- "rate-limit",
591
- "oom",
592
- "refused",
593
- "aborted",
594
- "other"
595
- ];
596
- Object.freeze(Object.fromEntries(ye.map((e) => [e, `var(--chart-outcome-${e === "aborted" ? "neutral" : e})`])));
597
- var be = [
598
- "solved",
599
- "not solved",
600
- "died",
601
- "stalled",
602
- "cancelled",
603
- "live",
604
- "never started"
605
- ], J = Object.freeze(Object.fromEntries(be.map((e) => [e, `var(--chart-ending-${e.replace(" ", "-")})`])));
606
- function xe(e) {
607
- return e === void 0 ? "" : Number.isInteger(e) && e >= 0 && e < 4 ? `tgc-checker-${e}` : "tgc-checker-other";
608
- }
609
- var Se = ye, Ce = (e) => new Date(e).toISOString().slice(11, 16), we = 6e4, Te = 864e5, Ee = [
610
- "Jan",
611
- "Feb",
612
- "Mar",
613
- "Apr",
614
- "May",
615
- "Jun",
616
- "Jul",
617
- "Aug",
618
- "Sep",
619
- "Oct",
620
- "Nov",
621
- "Dec"
622
- ], De = [
623
- 1,
624
- 2,
625
- 5,
626
- 10,
627
- 15,
628
- 30,
629
- 60,
630
- 120,
631
- 180,
632
- 360,
633
- 720,
634
- 1440,
635
- 2880,
636
- 10080
637
- ].map((e) => e * we);
638
- function Oe(e, t) {
639
- let n = t.id ?? "timeline";
640
- if (!e.length) return {
641
- id: n,
642
- refused: "No lanes recorded."
643
- };
644
- if (!t.measure?.trim()) return {
645
- id: n,
646
- refused: "A timeline needs a measure."
647
- };
648
- if (new Set(e.map((e) => e.id)).size !== e.length) return {
649
- id: n,
650
- refused: "Duplicate lane ids."
651
- };
652
- if (t.now !== void 0 && !Number.isFinite(t.now)) return {
653
- id: n,
654
- refused: "now must be a finite time."
655
- };
656
- let i = new Map(e.map((e) => [e.id, e]));
657
- for (let t of e) {
658
- let e = /* @__PURE__ */ new Set();
659
- for (let r = t; r.parent !== void 0; r = i.get(r.parent)) {
660
- if (!i.has(r.parent)) return {
661
- id: n,
662
- refused: `${r.label}: parent ${r.parent} is not a lane.`
663
- };
664
- if (e.has(r.id)) return {
665
- id: n,
666
- refused: `${t.label}: its parent chain loops back to ${r.label}.`
667
- };
668
- e.add(r.id);
669
- }
670
- if (t.depth !== void 0 && (!Number.isInteger(t.depth) || t.depth < 0)) return {
671
- id: n,
672
- refused: `${t.label}: depth must be a whole number of at least 0.`
673
- };
674
- }
675
- let a = /* @__PURE__ */ new Map(), o = (e) => a.get(e.id) ?? a.set(e.id, e.parent === void 0 ? e.depth ?? 0 : o(i.get(e.parent)) + 1).get(e.id);
676
- for (let t of e) {
677
- let e = o(t);
678
- if (t.depth !== void 0 && t.depth !== e) return {
679
- id: n,
680
- refused: `${t.label}: depth ${t.depth} is not one below its parent's ${e - 1}.`
681
- };
682
- }
683
- let s = e.flatMap((e) => e.spans.map((t) => ({
684
- lane: e,
685
- span: t
686
- })));
687
- for (let { lane: e, span: r } of s) {
688
- if (typeof r.state != "string" || !r.state.trim()) return {
689
- id: n,
690
- refused: `${e.label}: every span needs a state.`
691
- };
692
- if (!Number.isFinite(r.start) || r.end !== null && (!Number.isFinite(r.end) || r.end < r.start)) return {
693
- id: n,
694
- refused: `${e.label}: span times must be finite and end at or after their start.`
695
- };
696
- if (r.end === null && t.now === void 0) return {
697
- id: n,
698
- refused: `${e.label}: an open span needs now.`
699
- };
700
- if (r.end === null && t.now < r.start) return {
701
- id: n,
702
- refused: `${e.label}: an open span starts after now.`
703
- };
704
- }
705
- for (let t of e) for (let e of t.ticks ?? []) {
706
- if (!e || !Number.isFinite(e.at)) return {
707
- id: n,
708
- refused: `${t.label}: every tick needs a finite time.`
709
- };
710
- if (!Se.includes(e.outcome)) return {
711
- id: n,
712
- refused: `${t.label}: tick outcome ${String(e.outcome)} is not one of ${Se.join(", ")}.`
713
- };
714
- }
715
- let u = ue(t.marks, t.bands);
716
- if (u) return {
717
- id: n,
718
- refused: u
719
- };
720
- let d = t.marks ?? [], h = t.bands ?? [], _ = d.find((e) => e.lane !== void 0 && !i.has(e.lane));
721
- if (_) return {
722
- id: n,
723
- refused: `${_.label}: lane ${_.lane} is not a lane.`
724
- };
725
- let y = (e) => e.end ?? t.now, S = e.flatMap((e) => e.ticks ?? []), C = [
726
- ...s.flatMap(({ span: e }) => [e.start, y(e)]),
727
- ...S.map((e) => e.at),
728
- ...t.now === void 0 ? [] : [t.now]
729
- ], w = C.length ? C : [...d.map((e) => e.at), ...h.flatMap((e) => [e.from, e.to])];
730
- if (!w.length) return {
731
- id: n,
732
- refused: "No spans, ticks, marks or bands recorded."
733
- };
734
- let T = t.start ?? Math.min(...w), k = t.end ?? Math.max(...w);
735
- if (!Number.isFinite(T) || !Number.isFinite(k) || k <= T) return {
736
- id: n,
737
- refused: "The window needs two finite, increasing times."
738
- };
739
- if (C.some((e) => e < T || e > k)) return {
740
- id: n,
741
- refused: "A span, tick or now falls outside the recorded window."
742
- };
743
- let A = t.formatTime ?? Ce, j = t.formatTime ?? ((e) => e % Te === 0 ? `${Ee[new Date(e).getUTCMonth()]} ${new Date(e).getUTCDate()}` : Ce(e)), M = new Set(t.hatch ?? ["missing", "untraced"]), N = new Set(t.muted ?? ["idle"]), F = t.collapsed !== void 0, I = new Set(t.collapsed ?? []), L = /* @__PURE__ */ new Map();
744
- for (let t of e) L.set(t.parent, [...L.get(t.parent) ?? [], t]);
745
- let ee = (e) => (L.get(e.id) ?? []).flatMap((e) => [e, ...ee(e)]), R = [], z = (e) => {
746
- let t = ee(e), n = I.has(e.id) && t.length > 0, r = e.ticks, i = n && (r || t.some((e) => e.ticks)) ? [...r ?? [], ...t.flatMap((e) => e.ticks ?? [])] : r;
747
- R.push({
748
- lane: e,
749
- depth: a.get(e.id),
750
- children: (L.get(e.id) ?? []).length,
751
- hidden: n ? t.length : 0,
752
- folded: n,
753
- ticks: i
754
- }), n || (L.get(e.id) ?? []).forEach(z);
755
- };
756
- (L.get(void 0) ?? []).forEach(z);
757
- let B = new Map(R.map((e, t) => [e.lane.id, t])), V = (e) => {
758
- for (let t = i.get(e); t; t = t.parent === void 0 ? void 0 : i.get(t.parent)) if (B.has(t.id)) return B.get(t.id);
759
- return 0;
760
- }, te = (e) => e.at >= T && e.at <= k, ne = d.filter((e) => e.lane === void 0 && te(e)), re = d.filter((e) => e.lane !== void 0 && te(e)), ie = d.filter((e) => e.at < T), ae = d.filter((e) => e.at > k), oe = s.filter(({ span: e }) => e.end === null).length, H = s.filter(({ span: e }) => M.has(e.state)), se = H.reduce((e, { span: t }) => e + y(t) - t.start, 0), ce = (e) => {
761
- let t = /* @__PURE__ */ new Map();
762
- for (let n of e) t.set(n.outcome, (t.get(n.outcome) ?? 0) + 1);
763
- let n = t.get("ok") ?? 0, r = e.length - n, i = [...t].filter(([e]) => e !== "ok").sort((e, t) => t[1] - e[1]).map(([e, t]) => `${t} ${e}`).join(", ");
764
- return {
765
- ok: n,
766
- failed: r,
767
- why: i,
768
- text: `${n}✓ ${r}✗`,
769
- sentence: `${n} ok, ${r} failed${i ? ` (${i})` : ""}`
770
- };
771
- }, le = (e) => (e.detail ?? []).filter((e) => typeof e == "string" && e.trim()), de = (e, n) => [`${e.label}: ${n.state} ${A(n.start)} to ${n.end === null ? `now (${A(t.now)}, open)` : A(n.end)}, ${P(y(n) - n.start)}${n.note ? ` · ${n.note}` : ""}`, ...le(e)].join("\n"), W = R.some((e) => e.ticks !== void 0), he = W ? Math.max(...R.filter((e) => e.ticks).map((e) => c(ce(e.ticks).text, 12, "mono"))) : 0, ge = (e) => {
772
- let n = e === 358, i = n ? 10 : 12, a = (e) => 4 + e * i, o = (e) => a(e) + 11, s = (e) => e.hidden ? ` +${e.hidden}` : "", u = n ? 12 : Math.max(120, Math.min(Math.round(e * .34), Math.ceil(Math.max(...R.map((e) => o(e.depth) + c(e.lane.label + s(e), 12))) + 10))), d = n ? e - 12 : e - 16 - (he ? he + 10 : 0), p = (e) => u + (e - T) / (k - T) * (d - u), m = G(ne, p, u, d, {
773
- before: ie,
774
- after: ae,
775
- window: [T, k]
776
- }), _ = 8 + (m ? m * 14 + 6 : 0) + pe(h), S = n ? 40 : 24, C = _ + R.length * S, w = (e) => e + (n ? 19 : 5), O = fe(h, p, _, C, A, [T, k]) + me(h, (e, t) => [p(e), p(t)], _, C, u, d, A, [T, k]);
777
- for (let e of Ae(T, k, p, u, d, j)) O += x(p(e), _, p(e), C, "tgc-gridline") + E(p(e), C + 16, j(e), {
778
- size: 12,
779
- cls: "tgc-ink-muted tgc-num",
780
- anchor: "middle"
781
- });
782
- O += K(ne, p, _ - 8, C, u, d, A, 4, {
783
- before: ie,
784
- after: ae,
785
- window: [T, k]
786
- }), R.forEach((t, i) => {
787
- let { lane: d } = t, m = _ + i * S, h = m + (n ? 9 : 12), g = m + (n ? 13 : 16), x = d.parent === void 0 ? void 0 : B.get(d.parent);
788
- if (x !== void 0) {
789
- let e = a(t.depth - 1) + 3, r = n ? m + 2 : _ + x * S + 19;
790
- O += `<path class="tgc-tree" d="M${e} ${r}V${h}H${o(t.depth) - (t.children ? 13 : 3)}"/>`;
791
- }
792
- let C = t.ticks ? ce(t.ticks) : void 0, T = (n ? e - 12 - (C ? c(C.text, 12, "mono") + 8 : 0) : u - 8) - o(t.depth) - c(s(t), 12), E = l(d.label, Math.max(24, T), 12, "sans", 1).lines[0], k = `<text class="tgc-ink tgc-lane-label" x="${o(t.depth)}" y="${g}" font-size="12">${r(E)}${t.hidden ? `<tspan class="tgc-ink-muted">${r(s(t))}</tspan>` : ""}</text>`, j = t.children ? `<path class="tgc-caret" d="${t.folded ? `M${a(t.depth)} ${h - 4}l6 4l-6 4z` : `M${a(t.depth) - 1} ${h - 3}h8l-4 6z`}"/>` : "", P = [
793
- d.label,
794
- ...le(d),
795
- ...C ? [`Attempts: ${C.sentence}${t.hidden ? `, including ${t.hidden} folded ${f(t.hidden, "lane")}` : ""}`] : []
796
- ].join("\n"), I = F && t.children ? ` data-toggle="${r(d.id)}" class="tgc-lane-toggle" role="button" tabindex="0" aria-expanded="${!t.folded}" aria-label="${r(`${t.folded ? "Unfold" : "Fold"} ${d.label}`)}"` : "", L = I ? v(a(t.depth) - 3, m + 1, (n ? e - 12 : u - 4) - a(t.depth) + 3, n ? 16 : S - 2, "tgc-lane-hit", "rx=\"3\"") : "";
797
- O += `<g data-lane="${r(d.id)}" data-depth="${t.depth}"${t.folded ? ` data-folded="${t.hidden}"` : ""}><g${I}><title>${r(P)}</title>${L}${j}${k}</g>`;
798
- for (let e of d.spans) {
799
- let t = p(e.start), n = Math.max(1, p(y(e)) - t), r = M.has(e.state) ? b(t, w(m), n, 14, "tgc-span tgc-span-missing") : v(t, w(m), n, 14, `tgc-span${N.has(e.state) ? " tgc-span-muted" : ""}${e.end === null ? " tgc-span-open" : ""}`, "rx=\"2\"");
800
- O += D(de(d, e), `<g data-state="${e.state.replace(/[^a-z0-9-]/gi, "")}"${e.end === null ? " data-open=\"true\"" : ""}>${r}</g>`);
801
- }
802
- if (t.ticks?.length && (O += ke(t.ticks, d.label, p, w(m), 14, A)), C) {
803
- let r = n ? e - 12 : e - 16;
804
- O += D(`${d.label}: ${C.sentence}${t.hidden ? ` across ${t.hidden + 1} lanes` : ""}`, `<text class="tgc-num tgc-count" x="${r}" y="${g}" font-size="12" text-anchor="end">${C.ok}<tspan class="tgc-count-ok">✓</tspan> ${C.failed}<tspan class="tgc-count-failed">✗</tspan></text>`);
805
- }
806
- O += "</g>";
807
- });
808
- for (let e of re) {
809
- let t = _ + V(e.lane) * S, i = w(t) + 7, a = p(e.at), o = _e(e.kind, a, i, n ? 3 : 3.5) || x(a, w(t) - 3, a, w(t) + 14 + 3, `tgc-mark tgc-mark-${e.kind}`), s = e.verdict ? ` data-verdict="${e.verdict}" class="tgc-verdict-${e.verdict}"` : "";
810
- O += D(`${U(e)}: ${A(e.at)}${e.verdict ? ` · ${e.verdict}` : ""}`, `<g data-mark="${e.kind}" data-lane-mark="${r(e.lane)}"${s}>${o}</g>`);
811
- }
812
- return t.now !== void 0 && (O += x(p(t.now), _, p(t.now), C, "tgc-now") + E(p(t.now), C + 30, `now ${A(t.now)}`, {
813
- size: 12,
814
- cls: "tgc-ink tgc-num",
815
- anchor: p(t.now) > (u + d) / 2 ? "end" : "start"
816
- })), g(e, C + (t.now === void 0 ? 22 : 36), O);
817
- }, ye = ce(S), be = e.some((e) => e.parent !== void 0 || e.depth), J = F && R.some((e) => e.children), xe = be || S.length || e.some((e) => e.ticks || le(e).length) ? O(`${p(t.measure)}: lanes`, [
818
- { label: "Lane" },
819
- { label: "Started by" },
820
- {
821
- label: "Depth",
822
- numeric: !0
823
- },
824
- {
825
- label: "Attempts ok",
826
- numeric: !0
827
- },
828
- {
829
- label: "Attempts failed",
830
- numeric: !0
831
- },
832
- { label: "Failed by outcome" },
833
- { label: "Detail" }
834
- ], e.map((e) => {
835
- let t = e.ticks ? ce(e.ticks) : void 0;
836
- return [
837
- e.label,
838
- e.parent === void 0 ? "" : i.get(e.parent).label,
839
- String(a.get(e.id)),
840
- t ? String(t.ok) : "not recorded",
841
- t ? String(t.failed) : "not recorded",
842
- t?.why ?? "",
843
- le(e).join(" · ")
844
- ];
845
- })) : "";
846
- return {
847
- id: n,
848
- finding: `${p(t.measure)} across ${e.length} ${f(e.length, "lane")}, ${A(T)} to ${A(k)}.`,
849
- lede: `${s.length} recorded ${f(s.length, "span")}; ${oe} open${t.now === void 0 ? "" : ` at ${A(t.now)}`}; ${H.length} without data (${P(se)}).${S.length ? ` ${S.length} recorded ${f(S.length, "attempt")}: ${ye.sentence}.` : ""}`,
850
- read: [
851
- `Each lane shows its recorded spans on one time axis. Muted spans are ${[...N].join(", ") || "none"}; hatched spans have no data; an open span runs to now.`,
852
- ...be ? [`An indented lane was started by the lane its connector leads to${J ? "; a caret folds a lane's subtree, and a folded lane's ticks and counts include its subtree" : ""}.`] : [],
853
- ...W ? ["Each tick is one recorded attempt: ok ticks rise above the bar and failed ticks drop below it in their outcome's colour; the counts at the right are ok (✓) and failed (✗)."] : [],
854
- ...d.length + h.length ? [q] : []
855
- ].join(" "),
856
- svg: {
857
- wide: ge(m(t.width)),
858
- narrow: ge(358),
859
- ...J ? { interactive: !0 } : {}
860
- },
861
- table: xe + O(`${p(t.measure)} by lane`, [
862
- { label: "Lane" },
863
- { label: "State" },
864
- {
865
- label: "Start",
866
- numeric: !0
867
- },
868
- {
869
- label: "End",
870
- numeric: !0
871
- },
872
- {
873
- label: "Duration",
874
- numeric: !0
875
- },
876
- { label: "Note" }
877
- ], s.map(({ lane: e, span: t }) => [
878
- e.label,
879
- t.state,
880
- A(t.start),
881
- t.end === null ? "open" : A(t.end),
882
- P(y(t) - t.start),
883
- t.note ?? ""
884
- ])) + ve(d, h, "time", A),
885
- note: {
886
- method: `Recorded span start and end times as supplied by the producer; open spans are drawn to the supplied now. No span is inferred, merged or reordered.${S.length ? " Ticks are recorded attempts at their recorded times; ticks of one outcome within 2 px are drawn as one, with the count in its hover." : ""}`,
887
- n: `${s.length} spans${S.length ? ` and ${S.length} attempts` : ""} in ${e.length} lanes.`,
888
- exclusions: [...H.map(({ lane: e, span: t }) => `${e.label}: ${t.state} ${A(t.start)} to ${t.end === null ? "now" : A(t.end)} has no data.`), ...[...ie, ...ae].map((e) => `${U(e)} falls ${e.at < T ? `${P(T - e.at)} before` : `${P(e.at - k)} after`} the recorded window; it is named at the edge, not drawn.`)]
889
- }
890
- };
891
- }
892
- function ke(e, t, n, r, i, a) {
893
- let o = /* @__PURE__ */ new Map();
894
- for (let t of [...e].sort((e, t) => e.at - t.at)) {
895
- let e = `${t.outcome}|${Math.round(n(t.at) / 2)}`;
896
- o.set(e, [...o.get(e) ?? [], t]);
897
- }
898
- return `<g class="tgc-ticks">${[...o.values()].sort((e, t) => Number(e[0].outcome === "ok") - Number(t[0].outcome === "ok")).map((e) => {
899
- let o = e[0], s = e.at(-1), c = o.outcome === "ok", l = n(e.reduce((e, t) => e + t.at, 0) / e.length), u = /* @__PURE__ */ new Map();
900
- for (let t of e) t.note && u.set(t.note, (u.get(t.note) ?? 0) + 1);
901
- let d = [...u].sort((e, t) => t[1] - e[1])[0]?.[0];
902
- return D(`${t}: ${e.length > 1 ? `${e.length} × ` : ""}${o.outcome} ${a(o.at)}${e.length > 1 ? ` to ${a(s.at)}` : ""}${d ? ` · ${d.length > 160 ? `${d.slice(0, 159)}…` : d}` : ""}`, x(l, c ? r - 4 : r + i / 2, l, c ? r + i / 2 : r + i + 4, `tgc-tick tgc-tick-${o.outcome}`));
903
- }).join("")}</g>`;
904
- }
905
- function Ae(e, t, n, r, i, a) {
906
- let o = (e) => {
907
- let t = -Infinity;
908
- for (let o of e) {
909
- let e = c(a(o), 12, "mono"), s = n(o) - e / 2, l = n(o) + e / 2;
910
- if (s < r - 14 || l > i + 14 || s < t + 10) return !1;
911
- t = l;
912
- }
913
- return !0;
914
- };
915
- for (let n of De) {
916
- let r = [];
917
- for (let i = Math.ceil(e / n) * n; i <= t && r.length <= 12; i += n) r.push(i);
918
- if (r.length >= 2 && r.length <= 12 && o(r)) return r;
919
- }
920
- return o([e, t]) ? [e, t] : [e];
921
- }
922
- //#endregion
923
- //#region node_modules/.pnpm/@tangle-network+charts@0.21.22_react@19.3.0/node_modules/@tangle-network/charts/dist/react/index.js
924
- var Y = n(), X = /* @__PURE__ */ e(t(), 1);
925
- new Intl.NumberFormat("en-US", { maximumFractionDigits: 2 });
926
- var je = [
927
- "#8b7cf6",
928
- "#0ea5a0",
929
- "#c98500",
930
- "#e2508f",
931
- "#4a90e2"
932
- ], Me = (e) => e == null || !Number.isFinite(e) ? "—" : new Intl.NumberFormat("en-US", {
933
- notation: "compact",
934
- maximumFractionDigits: 1
935
- }).format(e), Ne = (e) => e === null || !Number.isFinite(e) ? "—" : `${Math.round(e * 100)}%`;
936
- function Pe() {
937
- let [e, t] = (0, X.useState)(null), [n, r] = (0, X.useState)({
938
- width: 0,
939
- em: 16
940
- });
941
- return (0, X.useEffect)(() => {
942
- if (!e) return;
943
- let t = new ResizeObserver(([t]) => r({
944
- width: Math.floor(t.contentRect.width),
945
- em: parseFloat(getComputedStyle(e).fontSize) || 16
946
- }));
947
- return t.observe(e), () => t.disconnect();
948
- }, [e]), [
949
- t,
950
- n.width,
951
- n.em
952
- ];
953
- }
954
- function Fe(e) {
955
- if (!(e > 0)) return {
956
- top: 1,
957
- ticks: [
958
- 0,
959
- .5,
960
- 1
961
- ]
962
- };
963
- let t = 10 ** Math.floor(Math.log10(e)), n = [
964
- 1,
965
- 2,
966
- 2.5,
967
- 5,
968
- 10
969
- ].map((e) => e * t).find((t) => t * 4 >= e) ?? t * 10, r = Math.ceil(e / n) * n;
970
- return {
971
- top: r,
972
- ticks: [
973
- 0,
974
- r / 2,
975
- r
976
- ]
977
- };
978
- }
979
- function Ie({ tip: e }) {
980
- return e ? /* @__PURE__ */ (0, Y.jsxs)("div", {
981
- className: "ov-tip",
982
- role: "tooltip",
983
- style: {
984
- left: e.x,
985
- top: e.y
986
- },
987
- children: [/* @__PURE__ */ (0, Y.jsx)("strong", { children: e.title }), e.lines.map((e) => /* @__PURE__ */ (0, Y.jsxs)("span", {
988
- className: "ov-tip-line",
989
- children: [
990
- e.color && /* @__PURE__ */ (0, Y.jsx)("i", { style: { background: e.color } }),
991
- /* @__PURE__ */ (0, Y.jsx)("span", { children: e.label }),
992
- /* @__PURE__ */ (0, Y.jsx)("b", { children: e.value })
993
- ]
994
- }, e.label))]
995
- }) : null;
996
- }
997
- function Le({ days: e, series: t, format: n = Me, rows: r = 13, missing: i = "No runs started", tick: a = (e) => e.slice(5), onOpen: o }) {
998
- let [s, c, l] = Pe(), u = Math.round(r * l), [d, f] = (0, X.useState)(null), p = e.map((e, n) => t.reduce((e, t) => e + (t.values[n] ?? 0), 0)), { top: m, ticks: h } = Fe(Math.max(...p)), g = Math.round(3.4 * l), _ = Math.round(1.8 * l), v = Math.max(0, c - g - 8), y = u - _ - 8, b = e.length ? v / e.length : 0, x = Math.max(3, b * .72), S = Math.max(1, Math.ceil(e.length / Math.max(1, Math.floor(v / (4.5 * l))))), C = Math.ceil(4.5 * l / Math.max(b, 1)), w = (e) => 8 + y - e / m * y;
999
- return /* @__PURE__ */ (0, Y.jsxs)("div", {
1000
- ref: s,
1001
- className: "ov-plot",
1002
- onMouseLeave: () => f(null),
1003
- children: [c > 0 && /* @__PURE__ */ (0, Y.jsxs)("svg", {
1004
- width: c,
1005
- height: u,
1006
- role: "img",
1007
- "aria-label": `${t.map((e) => e.name).join(", ")} per day`,
1008
- children: [h.map((e) => /* @__PURE__ */ (0, Y.jsxs)("g", { children: [/* @__PURE__ */ (0, Y.jsx)("line", {
1009
- x1: g,
1010
- x2: c - 8,
1011
- y1: w(e),
1012
- y2: w(e),
1013
- className: "ov-gridline"
1014
- }), /* @__PURE__ */ (0, Y.jsx)("text", {
1015
- x: g - l * .4,
1016
- y: w(e),
1017
- dominantBaseline: "middle",
1018
- className: "ov-axis",
1019
- textAnchor: "end",
1020
- children: n(e)
1021
- })] }, e)), e.map((r, s) => {
1022
- let d = 0, m = g + s * b + (b - x) / 2, h = () => f({
1023
- x: Math.min(g + s * b + b + 8, c - l * 14),
1024
- y: 8,
1025
- title: `${r} · ${t.every((e) => e.values[s] === null) ? i : n(p[s] ?? 0)}`,
1026
- lines: t.map((e) => ({
1027
- label: e.name,
1028
- value: e.values[s] === null ? i : n(e.values[s] ?? 0),
1029
- color: e.color
1030
- }))
1031
- });
1032
- return /* @__PURE__ */ (0, Y.jsxs)("g", {
1033
- role: o ? "button" : void 0,
1034
- tabIndex: o ? 0 : void 0,
1035
- "aria-label": o ? `Open ${r}` : void 0,
1036
- onFocus: o ? h : void 0,
1037
- onBlur: o ? () => f(null) : void 0,
1038
- onKeyDown: o ? (e) => {
1039
- (e.key === "Enter" || e.key === " ") && (e.preventDefault(), o(s));
1040
- } : void 0,
1041
- children: [
1042
- t.map((e) => {
1043
- let t = e.values[s] ?? 0;
1044
- if (!t) return null;
1045
- let n = w(d);
1046
- d += t;
1047
- let r = w(d);
1048
- return /* @__PURE__ */ (0, Y.jsx)("rect", {
1049
- x: m,
1050
- y: r,
1051
- width: x,
1052
- height: Math.max(2, n - r - 2),
1053
- rx: 2,
1054
- fill: e.color
1055
- }, e.name);
1056
- }),
1057
- (s === e.length - 1 || s % S === 0 && s + C <= e.length - 1) && /* @__PURE__ */ (0, Y.jsx)("text", {
1058
- x: m + x / 2,
1059
- y: u - l * .35,
1060
- className: "ov-axis",
1061
- textAnchor: "middle",
1062
- children: a(r)
1063
- }),
1064
- /* @__PURE__ */ (0, Y.jsx)("rect", {
1065
- x: g + s * b,
1066
- y: 8,
1067
- width: b,
1068
- height: y,
1069
- fill: "transparent",
1070
- style: o ? { cursor: "pointer" } : void 0,
1071
- onClick: o ? () => o(s) : void 0,
1072
- onMouseEnter: h
1073
- })
1074
- ]
1075
- }, r);
1076
- })]
1077
- }), /* @__PURE__ */ (0, Y.jsx)(Ie, { tip: d })]
1078
- });
1079
- }
1080
- function Re({ rows: e, format: t = Me, color: n = je[0], max: r, limit: i = 8 }) {
1081
- let a = r ?? Math.max(1, ...e.map((e) => e.value));
1082
- if (!e.length) return /* @__PURE__ */ (0, Y.jsx)("p", {
1083
- className: "ov-empty",
1084
- children: "Nothing recorded."
1085
- });
1086
- let o = e.slice(i);
1087
- return /* @__PURE__ */ (0, Y.jsxs)("ol", {
1088
- className: "ov-hbars",
1089
- children: [e.slice(0, i).map((e) => {
1090
- let r = e.title ?? `${e.label}: ${t(e.value)}`, i = /* @__PURE__ */ (0, Y.jsxs)(Y.Fragment, { children: [
1091
- /* @__PURE__ */ (0, Y.jsx)("span", {
1092
- className: "ov-hbar-label",
1093
- children: e.label
1094
- }),
1095
- /* @__PURE__ */ (0, Y.jsx)("span", {
1096
- className: "ov-hbar-track",
1097
- children: /* @__PURE__ */ (0, Y.jsx)("span", { style: {
1098
- width: `${Math.max(1, e.value / a * 100)}%`,
1099
- background: e.color ?? n
1100
- } })
1101
- }),
1102
- /* @__PURE__ */ (0, Y.jsx)("span", {
1103
- className: "ov-hbar-value",
1104
- children: t(e.value)
1105
- }),
1106
- e.note && /* @__PURE__ */ (0, Y.jsx)("span", {
1107
- className: "ov-hbar-note",
1108
- children: e.note
1109
- })
1110
- ] });
1111
- return /* @__PURE__ */ (0, Y.jsx)("li", { children: e.href ? /* @__PURE__ */ (0, Y.jsx)("a", {
1112
- href: e.href,
1113
- title: r,
1114
- children: i
1115
- }) : /* @__PURE__ */ (0, Y.jsx)("div", {
1116
- title: r,
1117
- children: i
1118
- }) }, e.label);
1119
- }), o.length > 0 && /* @__PURE__ */ (0, Y.jsxs)("li", {
1120
- className: "ov-hbars-more",
1121
- children: [
1122
- "+",
1123
- o.length,
1124
- " more · ",
1125
- t(o.reduce((e, t) => e + t.value, 0))
1126
- ]
1127
- })]
1128
- });
1129
- }
1130
- function ze({ series: e, format: t = Me, rows: n = 13, axis: r, marks: i = [], bands: a = [] }) {
1131
- let [o, s, c] = Pe(), l = Math.round(n * c), [u, d] = (0, X.useState)(null), f = ue(i, a);
1132
- if (f) throw RangeError(f);
1133
- let p = e.flatMap((e) => e.points);
1134
- if (!p.length) return /* @__PURE__ */ (0, Y.jsx)("p", {
1135
- className: "ov-empty",
1136
- children: "No history yet."
1137
- });
1138
- let m = [
1139
- ...p.map((e) => e[0]),
1140
- ...i.map((e) => e.at),
1141
- ...a.flatMap((e) => [e.from, e.to])
1142
- ], h = Math.min(...m), g = Math.max(...m), { top: _, ticks: v } = Fe(Math.max(...p.map((e) => e[1]))), y = Math.round(3.4 * c), b = Math.round(1.8 * c), x = Math.max(0, s - y - 10), S = l - b - 8, C = (e) => y + (g > h ? (e - h) / (g - h) * x : 0), T = (e) => 8 + S - e / _ * S, E = (e, t) => e.reduce((e, n) => Math.abs(n[0] - t) < Math.abs(e[0] - t) ? n : e, e[0]), D = (e) => new Date(e).toISOString().slice(5, 16).replace("T", " ");
1143
- return /* @__PURE__ */ (0, Y.jsxs)("div", {
1144
- ref: o,
1145
- className: "ov-plot",
1146
- onMouseMove: (e) => {
1147
- let t = e.currentTarget.getBoundingClientRect(), n = e.clientX - t.left;
1148
- d(n >= y ? h + (n - y) / Math.max(1, x) * (g - h) : null);
1149
- },
1150
- onMouseLeave: () => d(null),
1151
- children: [
1152
- s > 0 && /* @__PURE__ */ (0, Y.jsxs)("svg", {
1153
- width: s,
1154
- height: l,
1155
- role: "img",
1156
- "aria-label": e.map((e) => e.name).join(", "),
1157
- children: [
1158
- v.map((e) => /* @__PURE__ */ (0, Y.jsxs)("g", { children: [/* @__PURE__ */ (0, Y.jsx)("line", {
1159
- x1: y,
1160
- x2: s - 10,
1161
- y1: T(e),
1162
- y2: T(e),
1163
- className: "ov-gridline"
1164
- }), /* @__PURE__ */ (0, Y.jsx)("text", {
1165
- x: y - c * .4,
1166
- y: T(e),
1167
- dominantBaseline: "middle",
1168
- className: "ov-axis",
1169
- textAnchor: "end",
1170
- children: t(e)
1171
- })] }, e)),
1172
- [
1173
- h,
1174
- (h + g) / 2,
1175
- g
1176
- ].map((e, t) => /* @__PURE__ */ (0, Y.jsx)("text", {
1177
- x: C(e),
1178
- y: l - c * .35,
1179
- className: "ov-axis",
1180
- textAnchor: t === 0 ? "start" : t === 2 ? "end" : "middle",
1181
- children: r ? r(e) : D(e).slice(0, 5)
1182
- }, t)),
1183
- a.map((e, t) => /* @__PURE__ */ (0, Y.jsx)(Ve, {
1184
- band: e,
1185
- x: C(e.from),
1186
- y: 8,
1187
- width: C(e.to) - C(e.from),
1188
- height: S
1189
- }, `band-${t}`)),
1190
- e.map((e) => e.dots ? /* @__PURE__ */ (0, Y.jsx)("g", { children: e.points.map((t) => /* @__PURE__ */ (0, Y.jsx)("circle", {
1191
- cx: C(t[0]),
1192
- cy: T(t[1]),
1193
- r: Math.max(3, c / 5),
1194
- fill: e.color,
1195
- stroke: "var(--chart-live-surface, #fff)",
1196
- strokeWidth: 1.5
1197
- }, t[0])) }, e.name) : /* @__PURE__ */ (0, Y.jsxs)("g", {
1198
- "data-series": e.name,
1199
- "data-dash": e.dash ?? "solid",
1200
- "data-marker": e.marker,
1201
- children: [/* @__PURE__ */ (0, Y.jsx)("polyline", {
1202
- fill: "none",
1203
- stroke: e.color,
1204
- strokeWidth: Math.max(2, c / 8),
1205
- strokeLinejoin: "round",
1206
- strokeLinecap: e.dash === "dot" ? "round" : void 0,
1207
- strokeDasharray: Be(e.dash, c),
1208
- points: e.points.map((e) => `${C(e[0])},${T(e[1])}`).join(" ")
1209
- }), e.marker && (e.points.length <= 30 ? e.points : e.points.slice(-1)).map((t) => /* @__PURE__ */ (0, Y.jsx)("path", {
1210
- d: w(e.marker, C(t[0]), T(t[1]), Math.max(3, c / 5)),
1211
- fill: e.color,
1212
- stroke: "var(--chart-live-surface, var(--chart-canvas))",
1213
- strokeWidth: 1.5
1214
- }, t[0]))]
1215
- }, e.name)),
1216
- [...i].sort((e, t) => e.at - t.at).map((e, t) => /* @__PURE__ */ (0, Y.jsx)(He, {
1217
- mark: e,
1218
- x: C(e.at),
1219
- top: 8,
1220
- bottom: 8 + S,
1221
- row: t % 3,
1222
- em: c,
1223
- flip: C(e.at) > y + x * .62
1224
- }, `mark-${t}`)),
1225
- u !== null && /* @__PURE__ */ (0, Y.jsx)("line", {
1226
- x1: C(u),
1227
- x2: C(u),
1228
- y1: 8,
1229
- y2: 8 + S,
1230
- className: "ov-crosshair"
1231
- }),
1232
- u !== null && e.map((e) => {
1233
- let t = e.points.length ? E(e.points, u) : null;
1234
- return t ? /* @__PURE__ */ (0, Y.jsx)("circle", {
1235
- cx: C(t[0]),
1236
- cy: T(t[1]),
1237
- r: Math.max(4, c / 4),
1238
- fill: e.color,
1239
- stroke: "var(--chart-live-surface, #fff)",
1240
- strokeWidth: 2
1241
- }, e.name) : null;
1242
- })
1243
- ]
1244
- }),
1245
- u !== null && /* @__PURE__ */ (0, Y.jsx)(Ie, { tip: {
1246
- x: Math.min(C(u) + 10, s - c * 14),
1247
- y: 8,
1248
- title: r ? r(u) : D(u),
1249
- lines: e.filter((e) => e.points.length).map((e) => {
1250
- let n = E(e.points, u);
1251
- return {
1252
- label: e.label ? e.label(n[0]) : e.name,
1253
- value: t(n[1]),
1254
- color: e.color
1255
- };
1256
- })
1257
- } }),
1258
- e.length > 1 && e.some((e) => e.dash || e.marker) && /* @__PURE__ */ (0, Y.jsx)("ul", {
1259
- className: "ov-key",
1260
- "aria-label": "Series",
1261
- children: e.map((e) => /* @__PURE__ */ (0, Y.jsxs)("li", { children: [/* @__PURE__ */ (0, Y.jsxs)("svg", {
1262
- width: c * 2,
1263
- height: c,
1264
- "aria-hidden": "true",
1265
- children: [/* @__PURE__ */ (0, Y.jsx)("line", {
1266
- x1: 0,
1267
- x2: c * 2,
1268
- y1: c / 2,
1269
- y2: c / 2,
1270
- stroke: e.color,
1271
- strokeWidth: Math.max(2, c / 8),
1272
- strokeDasharray: Be(e.dash, c),
1273
- strokeLinecap: e.dash === "dot" ? "round" : void 0
1274
- }), e.marker && /* @__PURE__ */ (0, Y.jsx)("path", {
1275
- d: w(e.marker, c, c / 2, Math.max(3, c / 5)),
1276
- fill: e.color
1277
- })]
1278
- }), e.name] }, e.name))
1279
- }),
1280
- /* @__PURE__ */ (0, Y.jsx)(Ue, {
1281
- marks: i,
1282
- bands: a,
1283
- format: r ?? ((e) => D(e))
1284
- })
1285
- ]
1286
- });
1287
- }
1288
- function Be(e, t) {
1289
- return e === "dash" ? `${Math.round(t * .55)} ${Math.round(t * .3)}` : e === "dot" ? `0.1 ${Math.round(t * .35)}` : void 0;
1290
- }
1291
- function Ve({ band: e, x: t, y: n, width: r, height: i }) {
1292
- return /* @__PURE__ */ (0, Y.jsxs)("g", {
1293
- "data-band": e.kind,
1294
- "data-hatched": e.kind === "missing" ? "true" : void 0,
1295
- children: [
1296
- /* @__PURE__ */ (0, Y.jsx)("title", { children: e.label }),
1297
- /* @__PURE__ */ (0, Y.jsx)("rect", {
1298
- x: t,
1299
- y: n,
1300
- width: Math.max(0, r),
1301
- height: i,
1302
- className: e.kind === "missing" ? "ov-hatch-bg" : `ov-band ov-band-${e.kind}`
1303
- }),
1304
- e.kind === "missing" && /* @__PURE__ */ (0, Y.jsx)("path", {
1305
- d: y(t, n, r, i),
1306
- className: "ov-hatch"
1307
- })
1308
- ]
1309
- });
1310
- }
1311
- function He({ mark: e, x: t, top: n, bottom: r, row: i, em: a, flip: o }) {
1312
- let s = Math.max(3, a / 4), c = le[e.kind];
1313
- return /* @__PURE__ */ (0, Y.jsxs)("g", {
1314
- "data-mark": e.kind,
1315
- "data-verdict": e.verdict,
1316
- className: e.verdict ? `ov-verdict-${e.verdict}` : void 0,
1317
- children: [
1318
- /* @__PURE__ */ (0, Y.jsx)("title", { children: U(e) }),
1319
- /* @__PURE__ */ (0, Y.jsx)("line", {
1320
- x1: t,
1321
- x2: t,
1322
- y1: n,
1323
- y2: r,
1324
- className: `ov-mark ov-mark-${e.kind}`
1325
- }),
1326
- e.kind === "died" && /* @__PURE__ */ (0, Y.jsx)("path", {
1327
- d: `M${t - s} ${r - 2 * s}L${t + s} ${r}M${t - s} ${r}L${t + s} ${r - 2 * s}`,
1328
- className: "ov-mark ov-mark-died"
1329
- }),
1330
- c && /* @__PURE__ */ (0, Y.jsx)("path", {
1331
- d: w(c, t, n + s, s),
1332
- className: "ov-mark-head"
1333
- }),
1334
- /* @__PURE__ */ (0, Y.jsx)("text", {
1335
- x: o ? t - a * .3 : t + a * .3,
1336
- y: n + a * (.9 + i),
1337
- textAnchor: o ? "end" : "start",
1338
- className: "ov-mark-label",
1339
- children: U(e)
1340
- })
1341
- ]
1342
- });
1343
- }
1344
- function Ue({ marks: e, bands: t, format: n }) {
1345
- if (!e.length && !t.length) return null;
1346
- let r = [...e.map((e) => ({
1347
- at: e.at,
1348
- kind: e.kind,
1349
- text: `${U(e)} · ${n(e.at)}${e.verdict ? ` · ${e.verdict}` : ""}`
1350
- })), ...t.map((e) => ({
1351
- at: e.from,
1352
- kind: e.kind,
1353
- text: `${e.label} · ${n(e.from)} to ${n(e.to)}${e.kind === "missing" ? " · no data" : ""}`
1354
- }))].sort((e, t) => e.at - t.at);
1355
- return /* @__PURE__ */ (0, Y.jsx)("ul", {
1356
- className: "ov-events",
1357
- "aria-label": "Recorded events",
1358
- children: r.map((e, t) => /* @__PURE__ */ (0, Y.jsxs)("li", {
1359
- "data-kind": e.kind,
1360
- children: [/* @__PURE__ */ (0, Y.jsx)("i", {
1361
- className: `ov-event-swatch ov-event-${e.kind}`,
1362
- "aria-hidden": "true"
1363
- }), e.text]
1364
- }, t))
1365
- });
1366
- }
1367
- var We = [
1368
- "var(--chart-accent)",
1369
- "var(--chart-tier-c)",
1370
- "var(--chart-muted)"
1371
- ];
1372
- function Ge({ used: e, total: t, format: n = Me, tone: r, text: i, segments: a, untraced: o = "untraced" }) {
1373
- if (a) return /* @__PURE__ */ (0, Y.jsx)(Ke, {
1374
- segments: a,
1375
- total: t,
1376
- format: n,
1377
- text: i,
1378
- untraced: o
1379
- });
1380
- let s = e != null && t ? Math.min(1, e / t) : null;
1381
- return /* @__PURE__ */ (0, Y.jsxs)("div", {
1382
- className: "ov-meter",
1383
- children: [/* @__PURE__ */ (0, Y.jsx)("span", {
1384
- className: "ov-meter-track",
1385
- children: /* @__PURE__ */ (0, Y.jsx)("span", { style: {
1386
- width: `${(s ?? 0) * 100}%`,
1387
- background: r ?? (s !== null && s > .9 ? "var(--chart-live-danger, #d85050)" : s !== null && s > .7 ? "var(--chart-live-warning, #c98500)" : je[0])
1388
- } })
1389
- }), /* @__PURE__ */ (0, Y.jsx)("span", {
1390
- className: "ov-meter-text",
1391
- children: i ?? `${n(e ?? NaN)} of ${n(t ?? NaN)} · ${Ne(s)}`
1392
- })]
1393
- });
1394
- }
1395
- function Ke({ segments: e, total: t, format: n, text: r, untraced: i }) {
1396
- for (let t of e) if (t.value !== null && (!Number.isFinite(t.value) || t.value < 0)) throw RangeError(`${t.label}: a segment value must be a nonnegative finite number or null.`);
1397
- let a = e.reduce((e, t) => e + (t.value ?? 0), 0), o = t != null && Number.isFinite(t) && t > 0 ? t : null;
1398
- if (o !== null && a > o * (1 + 1e-9)) throw RangeError(`Segments sum to ${a}, more than the total ${o}.`);
1399
- let s = o === null ? 0 : o - a, c = [...e.map((e, t) => ({
1400
- ...e,
1401
- color: e.color ?? We[t % We.length],
1402
- remainder: !1
1403
- })), ...s > o * 1e-9 ? [{
1404
- label: i,
1405
- value: s,
1406
- kind: "untraced",
1407
- color: void 0,
1408
- remainder: !0
1409
- }] : []], l = (e) => o === null ? null : e / o;
1410
- return /* @__PURE__ */ (0, Y.jsxs)("div", {
1411
- className: "ov-meter",
1412
- "data-segmented": "true",
1413
- children: [
1414
- /* @__PURE__ */ (0, Y.jsx)("span", {
1415
- className: `ov-meter-track${o === null ? " ov-hatched" : ""}`,
1416
- "data-hatched": o === null ? "true" : void 0,
1417
- "aria-hidden": "true",
1418
- children: o !== null && c.filter((e) => e.value !== null && e.value > 0).map((e) => /* @__PURE__ */ (0, Y.jsx)("span", {
1419
- "data-segment": e.label,
1420
- "data-hatched": e.kind === "untraced" ? "true" : void 0,
1421
- className: e.kind === "untraced" ? "ov-hatched" : void 0,
1422
- style: {
1423
- width: `${e.value / o * 100}%`,
1424
- background: e.kind === "untraced" ? void 0 : e.color
1425
- }
1426
- }, e.label))
1427
- }),
1428
- /* @__PURE__ */ (0, Y.jsx)("ul", {
1429
- className: "ov-meter-key",
1430
- children: c.map((e) => /* @__PURE__ */ (0, Y.jsxs)("li", {
1431
- "data-segment": e.label,
1432
- children: [
1433
- /* @__PURE__ */ (0, Y.jsx)("i", {
1434
- className: e.kind === "untraced" || e.value === null ? "ov-hatched" : void 0,
1435
- style: e.kind === "untraced" || e.value === null ? void 0 : { background: e.color },
1436
- "aria-hidden": "true"
1437
- }),
1438
- /* @__PURE__ */ (0, Y.jsx)("span", { children: e.label }),
1439
- /* @__PURE__ */ (0, Y.jsx)("b", { children: e.value === null ? "not recorded" : `${n(e.value)}${o === null ? "" : ` · ${Ne(l(e.value))}`}` })
1440
- ]
1441
- }, e.label))
1442
- }),
1443
- /* @__PURE__ */ (0, Y.jsx)("span", {
1444
- className: "ov-meter-text",
1445
- children: r ?? (o === null ? "total not recorded" : `${n(a)} of ${n(o)} accounted · ${Ne(a / o)}`)
1446
- })
1447
- ]
1448
- });
1449
- }
1450
- function qe({ rows: e, lanes: t, colors: n, axis: r, span: i, marks: a = [], now: o, hatch: s = ["missing", "untraced"] }) {
1451
- let [c, l, u] = Pe(), [d, f] = (0, X.useState)(null), p = t ?? (e ?? []).map((e, t) => ({
1452
- id: `${e.label}-${t}`,
1453
- label: e.label,
1454
- spans: [{
1455
- start: e.start,
1456
- end: e.end,
1457
- state: e.state,
1458
- note: e.note
1459
- }]
1460
- })), m = ue(a);
1461
- if (m) throw RangeError(m);
1462
- if (o !== void 0 && !Number.isFinite(o)) throw RangeError("now must be a finite time.");
1463
- if (t) for (let e of p) for (let t of e.spans) {
1464
- if (!Number.isFinite(t.start) || t.end !== null && (!Number.isFinite(t.end) || t.end < t.start)) throw RangeError(`${e.label}: span times must be finite and end at or after their start.`);
1465
- if (t.end === null && (o === void 0 || o < t.start)) throw RangeError(`${e.label}: an open span needs a now at or after its start.`);
1466
- }
1467
- let h = p.flatMap((e) => e.spans);
1468
- if (!h.length) return /* @__PURE__ */ (0, Y.jsx)("p", {
1469
- className: "ov-empty",
1470
- children: "No agent has started."
1471
- });
1472
- let g = (e) => e.end ?? o, _ = Math.round(1.25 * u), v = Math.min(Math.round(13 * u), Math.round(l * .32)), b = a.length ? 4 + Math.round(Math.min(3, a.length) * u + .3 * u) : 4, x = Math.round(1.8 * u), S = b + p.length * _ + x, C = [
1473
- ...h.flatMap((e) => [e.start, g(e)]),
1474
- ...a.map((e) => e.at),
1475
- ...o === void 0 ? [] : [o]
1476
- ], w = Math.min(...C), T = Math.max(...C, w + 6e4), E = Math.max(0, l - v - 10), D = (e) => v + (e - w) / (T - w) * E, O = n.unknown ?? "var(--chart-live-faint, var(--chart-muted))", k = new Set(s), A = b + p.length * _;
1477
- return /* @__PURE__ */ (0, Y.jsxs)("div", {
1478
- ref: c,
1479
- className: "ov-plot",
1480
- onMouseLeave: () => f(null),
1481
- children: [
1482
- l > 0 && /* @__PURE__ */ (0, Y.jsxs)("svg", {
1483
- width: l,
1484
- height: S,
1485
- role: "img",
1486
- "aria-label": `${p.length} ${t ? "lanes" : "agents"} over time`,
1487
- children: [
1488
- [
1489
- 0,
1490
- .25,
1491
- .5,
1492
- .75,
1493
- 1
1494
- ].map((e) => /* @__PURE__ */ (0, Y.jsxs)("g", { children: [/* @__PURE__ */ (0, Y.jsx)("line", {
1495
- x1: v + e * E,
1496
- x2: v + e * E,
1497
- y1: b,
1498
- y2: A,
1499
- className: "ov-gridline"
1500
- }), /* @__PURE__ */ (0, Y.jsx)("text", {
1501
- x: v + e * E,
1502
- y: S - u * .35,
1503
- className: "ov-axis",
1504
- textAnchor: e === 0 ? "start" : e === 1 ? "end" : "middle",
1505
- children: r(w + e * (T - w))
1506
- })] }, e)),
1507
- p.map((e, t) => {
1508
- let r = b + t * _;
1509
- return /* @__PURE__ */ (0, Y.jsxs)("g", {
1510
- "data-lane": e.id,
1511
- children: [
1512
- /* @__PURE__ */ (0, Y.jsx)("rect", {
1513
- x: 0,
1514
- y: r,
1515
- width: l,
1516
- height: _,
1517
- fill: "transparent",
1518
- onMouseEnter: () => f({
1519
- x: Math.min(D(g(e.spans.at(-1) ?? { end: T })) + 8, l - u * 16),
1520
- y: Math.max(0, r - u),
1521
- title: e.label,
1522
- lines: e.spans.flatMap((e) => [{
1523
- label: e.end === null ? `${e.state} (open)` : e.state,
1524
- value: i(e.start, g(e)),
1525
- color: k.has(e.state) ? void 0 : n[e.state] ?? O
1526
- }, ...e.note ? [{
1527
- label: e.note,
1528
- value: ""
1529
- }] : []])
1530
- })
1531
- }),
1532
- /* @__PURE__ */ (0, Y.jsx)("text", {
1533
- x: v - u * .5,
1534
- y: r + _ / 2,
1535
- dominantBaseline: "middle",
1536
- textAnchor: "end",
1537
- className: "ov-axis ov-gantt-label",
1538
- children: e.label.length > 26 ? `${e.label.slice(0, 25)}…` : e.label
1539
- }),
1540
- e.spans.map((t, a) => {
1541
- let o = n[t.state] ?? O, s = D(t.start), c = Math.max(2, D(g(t)) - s), d = r + _ * .18, p = _ * .64, m = t.end === null;
1542
- return /* @__PURE__ */ (0, Y.jsx)("g", {
1543
- "data-state": t.state,
1544
- "data-open": m ? "true" : void 0,
1545
- "data-hatched": k.has(t.state) ? "true" : void 0,
1546
- onMouseEnter: () => f({
1547
- x: Math.min(s + c + 8, l - u * 16),
1548
- y: Math.max(0, r - u),
1549
- title: e.label,
1550
- lines: [{
1551
- label: m ? `${t.state} (open)` : t.state,
1552
- value: i(t.start, g(t)),
1553
- color: k.has(t.state) ? void 0 : o
1554
- }, ...t.note ? [{
1555
- label: t.note,
1556
- value: ""
1557
- }] : []]
1558
- }),
1559
- children: k.has(t.state) ? /* @__PURE__ */ (0, Y.jsxs)(Y.Fragment, { children: [/* @__PURE__ */ (0, Y.jsx)("rect", {
1560
- x: s,
1561
- y: d,
1562
- width: c,
1563
- height: p,
1564
- className: "ov-hatch-bg"
1565
- }), /* @__PURE__ */ (0, Y.jsx)("path", {
1566
- d: y(s, d, c, p, 4),
1567
- className: "ov-hatch"
1568
- })] }) : /* @__PURE__ */ (0, Y.jsx)("rect", {
1569
- x: s,
1570
- y: d,
1571
- width: c,
1572
- height: p,
1573
- rx: 2,
1574
- fill: o,
1575
- className: m ? "ov-gantt-open" : void 0
1576
- })
1577
- }, a);
1578
- })
1579
- ]
1580
- }, e.id);
1581
- }),
1582
- o !== void 0 && /* @__PURE__ */ (0, Y.jsx)("line", {
1583
- x1: D(o),
1584
- x2: D(o),
1585
- y1: b,
1586
- y2: A,
1587
- className: "ov-now",
1588
- "data-now": "true"
1589
- }),
1590
- [...a].sort((e, t) => e.at - t.at).map((e, t) => /* @__PURE__ */ (0, Y.jsx)(He, {
1591
- mark: e,
1592
- x: D(e.at),
1593
- top: 4,
1594
- bottom: A,
1595
- row: t % 3,
1596
- em: u,
1597
- flip: D(e.at) > v + E * .62
1598
- }, `mark-${t}`))
1599
- ]
1600
- }),
1601
- /* @__PURE__ */ (0, Y.jsx)(Ie, { tip: d }),
1602
- /* @__PURE__ */ (0, Y.jsx)(Ue, {
1603
- marks: a,
1604
- bands: [],
1605
- format: r
1606
- })
1607
- ]
1608
- });
1609
- }
1610
- var Je = 24, Ye = Je / 2;
1611
- function Xe({ value: e, bound: t = null, target: n, stretch: r = null, scale: i = "log", format: a = Me, tone: o = "var(--chart-live-accent, #8b7cf6)", titles: s = {}, label: c }) {
1612
- let [l, u] = Pe(), d = i === "log" && e > 0 && n.min > 0, f = (e) => d ? Math.log10(e) : e, p = [
1613
- e,
1614
- n.min,
1615
- n.max,
1616
- ...r ? [r.min, r.max] : []
1617
- ].map(f), m = Math.min(...p), h = Math.max(...p), g = Math.max((h - m) * .08, d ? .15 : Math.abs(h) * .05 || 1), _ = (e) => u ? (f(e) - (m - g)) / (h - m + 2 * g) * u : 0, v = (e) => ({
1618
- x: _(e.min),
1619
- w: Math.max(4, _(e.max) - _(e.min))
1620
- }), y = v(n), b = r ? v(r) : null, x = e < n.min ? _(n.min) : e > n.max ? _(n.max) : _(e), S = _(e), C = (e) => e.min === e.max ? `≈${a(e.min)}` : `${a(e.min)}–${a(e.max)}`, w = d && u ? Array.from({ length: Math.floor(h + g) - Math.ceil(m - g) + 1 }, (e, t) => Math.ceil(m - g) + t) : [], T = t === "upper" ? `M${S + 4},6 L${S - 4},${Ye} L${S + 4},18` : `M${S - 4},6 L${S + 4},${Ye} L${S - 4},18`;
1621
- return /* @__PURE__ */ (0, Y.jsx)("div", {
1622
- ref: l,
1623
- className: "ov-gap",
1624
- role: "img",
1625
- "aria-label": c ?? `${t === "upper" ? "≤" : t === "lower" ? "≥" : ""}${a(e)} against ${C(n)}`,
1626
- children: u > 0 && /* @__PURE__ */ (0, Y.jsxs)("svg", {
1627
- width: u,
1628
- height: Je,
1629
- viewBox: `0 0 ${u} ${Je}`,
1630
- "aria-hidden": !0,
1631
- children: [
1632
- /* @__PURE__ */ (0, Y.jsx)("line", {
1633
- className: "ov-gap-track",
1634
- x1: 0,
1635
- x2: u,
1636
- y1: Ye,
1637
- y2: Ye
1638
- }),
1639
- w.map((e) => /* @__PURE__ */ (0, Y.jsx)("line", {
1640
- className: "ov-gap-tick",
1641
- x1: _(10 ** e),
1642
- x2: _(10 ** e),
1643
- y1: 8,
1644
- y2: 16
1645
- }, e)),
1646
- b && /* @__PURE__ */ (0, Y.jsx)("rect", {
1647
- className: "ov-gap-stretch",
1648
- x: b.x,
1649
- y: 4,
1650
- width: b.w,
1651
- height: 16,
1652
- rx: 4,
1653
- children: /* @__PURE__ */ (0, Y.jsx)("title", { children: s.stretch ?? `stretch ${C(r)}` })
1654
- }),
1655
- /* @__PURE__ */ (0, Y.jsx)("rect", {
1656
- className: "ov-gap-target",
1657
- x: y.x,
1658
- y: 4,
1659
- width: y.w,
1660
- height: 16,
1661
- rx: 4,
1662
- children: /* @__PURE__ */ (0, Y.jsx)("title", { children: s.target ?? `target ${C(n)}` })
1663
- }),
1664
- Math.abs(x - S) > 1 && /* @__PURE__ */ (0, Y.jsx)("line", {
1665
- className: "ov-gap-span",
1666
- x1: S,
1667
- x2: x,
1668
- y1: Ye,
1669
- y2: Ye,
1670
- style: { stroke: o }
1671
- }),
1672
- /* @__PURE__ */ (0, Y.jsxs)("g", {
1673
- className: "ov-gap-value",
1674
- children: [
1675
- /* @__PURE__ */ (0, Y.jsx)("title", { children: s.value ?? `${t === "upper" ? "≤" : t === "lower" ? "≥" : ""}${a(e)}` }),
1676
- t ? /* @__PURE__ */ (0, Y.jsx)("path", {
1677
- d: T,
1678
- fill: "none",
1679
- stroke: o,
1680
- strokeWidth: 2,
1681
- strokeLinecap: "round",
1682
- strokeLinejoin: "round"
1683
- }) : /* @__PURE__ */ (0, Y.jsx)("circle", {
1684
- cx: S,
1685
- cy: Ye,
1686
- r: 5,
1687
- fill: o
1688
- }),
1689
- /* @__PURE__ */ (0, Y.jsx)("rect", {
1690
- x: S - 8,
1691
- y: 0,
1692
- width: 16,
1693
- height: Je,
1694
- fill: "transparent"
1695
- })
1696
- ]
1697
- })
1698
- ]
1699
- })
1700
- });
1701
- }
1702
- function Ze({ figure: e, presentation: t = "chart" }) {
1703
- let [n, r] = Pe(), i = r >= 720 ? Math.floor(r / 32) * 32 : 720, a = (0, X.useMemo)(() => typeof e == "function" ? e(i) : e, [e, i]);
1704
- if (oe(a)) return /* @__PURE__ */ (0, Y.jsx)("p", {
1705
- className: "ov-refusal",
1706
- role: "note",
1707
- "data-refused": a.id,
1708
- children: a.refused
1709
- });
1710
- let o = r > 0 && r < 720 ? a.svg.narrow ? "narrow" : "table" : "wide", s = o === "wide" ? a.svg.wide : o === "narrow" ? a.svg.narrow : a.table, c = [
1711
- a.note.method,
1712
- a.note.n,
1713
- ...a.note.exclusions
1714
- ].join(" ");
1715
- return /* @__PURE__ */ (0, Y.jsxs)("figure", {
1716
- ref: n,
1717
- className: "tgc-figure tgc-figure-chart tgc-figure-view",
1718
- "data-figure": a.id,
1719
- "data-layout": o,
1720
- "aria-label": a.finding,
1721
- children: [
1722
- t === "report" && /* @__PURE__ */ (0, Y.jsxs)(Y.Fragment, { children: [/* @__PURE__ */ (0, Y.jsx)("h3", {
1723
- className: "tgc-finding",
1724
- children: a.finding
1725
- }), /* @__PURE__ */ (0, Y.jsx)("p", {
1726
- className: "tgc-lede",
1727
- children: a.lede
1728
- })] }),
1729
- /* @__PURE__ */ (0, Y.jsx)("div", {
1730
- className: `tgc-view-plot tgc-view-${o}`,
1731
- role: a.svg.interactive ? "group" : "img",
1732
- "aria-label": `${a.finding} ${a.lede}`,
1733
- style: o === "narrow" ? { maxWidth: 358 } : void 0,
1734
- dangerouslySetInnerHTML: { __html: s }
1735
- }),
1736
- /* @__PURE__ */ (0, Y.jsxs)("details", {
1737
- className: "tgc-data",
1738
- children: [
1739
- /* @__PURE__ */ (0, Y.jsx)("summary", { children: "Data and method" }),
1740
- /* @__PURE__ */ (0, Y.jsx)("p", {
1741
- className: "tgc-lede",
1742
- children: a.lede
1743
- }),
1744
- /* @__PURE__ */ (0, Y.jsx)("p", {
1745
- className: "tgc-read",
1746
- children: a.read
1747
- }),
1748
- /* @__PURE__ */ (0, Y.jsx)("p", {
1749
- className: "tgc-read",
1750
- children: c
1751
- }),
1752
- /* @__PURE__ */ (0, Y.jsx)("div", {
1753
- className: "tgc-scroll",
1754
- role: "region",
1755
- "aria-label": `${a.finding} data`,
1756
- tabIndex: 0,
1757
- dangerouslySetInnerHTML: { __html: a.table }
1758
- })
1759
- ]
1760
- })
1761
- ]
1762
- });
1763
- }
1764
- var Qe = Object.freeze([
1765
- "var(--chart-category-1)",
1766
- "var(--chart-category-2)",
1767
- "var(--chart-category-3)",
1768
- "var(--chart-category-other)"
1769
- ]);
1770
- function $e(e, t) {
1771
- let n = document.createElement("span");
1772
- n.style.display = "none", e.appendChild(n);
1773
- let r = t.map((e) => (n.style.color = "", n.style.color = e, getComputedStyle(n).color || e));
1774
- return n.remove(), r;
1775
- }
1776
- function et(e, t, n) {
1777
- let [r, i, a, o] = t, s = Math.max(1, Math.ceil((a - r) / n)), c = Math.max(1, Math.ceil((o - i) / n)), l = /* @__PURE__ */ new Map();
1778
- for (let t = 0; t < e.length / 2; t++) {
1779
- let a = Math.min(s - 1, Math.max(0, Math.floor((e[t * 2] - r) / n))), o = Math.min(c - 1, Math.max(0, Math.floor((e[t * 2 + 1] - i) / n))) * s + a, u = l.get(o);
1780
- u ? u.push(t) : l.set(o, [t]);
1781
- }
1782
- return {
1783
- cols: s,
1784
- rows: c,
1785
- cell: n,
1786
- cells: l,
1787
- x0: r,
1788
- y0: i
1789
- };
1790
- }
1791
- function tt({ positions: e, radii: t, colors: n, palette: r, extent: i, rects: a, labels: o, dimmed: s, selected: c, minPixelRadius: l = 1.2, onHover: u, onSelect: d, describe: f, height: p = 560, ariaLabel: m }) {
1792
- let h = (0, X.useRef)(null), g = (0, X.useRef)(null), [_, v] = (0, X.useState)({
1793
- width: 0,
1794
- height: p
1795
- }), y = (0, X.useRef)({
1796
- scale: 1,
1797
- tx: 0,
1798
- ty: 0
1799
- }), b = (0, X.useRef)(""), x = (0, X.useRef)(0), [S, C] = (0, X.useState)(null), w = (0, X.useRef)([]), T = e.length / 2, E = (0, X.useMemo)(() => typeof t == "number" ? t : t.reduce((e, t) => t > e ? t : e, 0), [t]), D = (0, X.useMemo)(() => et(e, i, Math.max(E * 2, (i[2] - i[0]) / 200)), [
1800
- e,
1801
- i,
1802
- E
1803
- ]);
1804
- (0, X.useEffect)(() => {
1805
- if (!h.current) return;
1806
- let e = new ResizeObserver(([e]) => v({
1807
- width: Math.floor(e.contentRect.width),
1808
- height: p
1809
- }));
1810
- return e.observe(h.current), () => e.disconnect();
1811
- }, [p]);
1812
- let O = (0, X.useCallback)(() => {
1813
- let [e, t, n, r] = i, a = Math.min((_.width - 16) / Math.max(1e-9, n - e), (_.height - 16) / Math.max(1e-9, r - t));
1814
- y.current = {
1815
- scale: a,
1816
- tx: 8 - e * a + (_.width - 16 - (n - e) * a) / 2,
1817
- ty: 8 - t * a + (_.height - 16 - (r - t) * a) / 2
1818
- };
1819
- }, [i, _]), k = (0, X.useCallback)(() => {
1820
- x.current = 0;
1821
- let i = g.current;
1822
- if (!i || !_.width) return;
1823
- let u = performance.now(), d = window.devicePixelRatio || 1;
1824
- (i.width !== Math.round(_.width * d) || i.height !== Math.round(_.height * d)) && (i.width = Math.round(_.width * d), i.height = Math.round(_.height * d));
1825
- let f = i.getContext("2d");
1826
- if (!f) return;
1827
- !w.current.length && h.current && (w.current = $e(h.current, r));
1828
- let { scale: p, tx: m, ty: v } = y.current;
1829
- f.setTransform(d, 0, 0, d, 0, 0), f.clearRect(0, 0, _.width, _.height);
1830
- let b = h.current ? getComputedStyle(h.current) : null, S = b?.color || "#888";
1831
- if (a?.length) {
1832
- f.lineWidth = 1, f.font = "11px ui-sans-serif, system-ui, sans-serif";
1833
- for (let e of a) {
1834
- if (e.x1 <= e.x0) continue;
1835
- let t = e.x0 * p + m, n = e.y0 * p + v, r = (e.x1 - e.x0) * p, i = (e.y1 - e.y0) * p;
1836
- if (!(t > _.width || n > _.height || t + r < 0 || n + i < 0) && (f.globalAlpha = .35, f.strokeStyle = S, f.strokeRect(t + .5, n + .5, r, i), r > 36)) {
1837
- f.globalAlpha = .8, f.fillStyle = S;
1838
- let i = e.note ? `${e.label} · ${e.note}` : e.label;
1839
- f.save(), f.beginPath(), f.rect(t, n, r - 4, 16), f.clip(), f.fillText(i, t + 4, n + 12), f.restore();
1840
- }
1841
- }
1842
- f.globalAlpha = 1;
1843
- }
1844
- let C = /* @__PURE__ */ new Map(), E = new Path2D(), D = typeof t == "number" ? t : 0;
1845
- for (let r = 0; r < T; r++) {
1846
- let i = e[r * 2] * p + m, a = e[r * 2 + 1] * p + v;
1847
- if (i < -8 || a < -8 || i > _.width + 8 || a > _.height + 8) continue;
1848
- let o = Math.max(l, (typeof t == "number" ? D : t[r]) * p), c = s?.[r] ? E : C.get(n[r]) ?? C.set(n[r], new Path2D()).get(n[r]);
1849
- c.moveTo(i + o, a), c.arc(i, a, o, 0, Math.PI * 2);
1850
- }
1851
- f.globalAlpha = .18, f.fillStyle = S, f.fill(E), f.globalAlpha = .92;
1852
- for (let [e, t] of C) f.fillStyle = w.current[e] ?? S, f.fill(t);
1853
- if (f.globalAlpha = 1, c != null && c < T) {
1854
- let n = e[c * 2] * p + m, r = e[c * 2 + 1] * p + v, i = Math.max(4, (typeof t == "number" ? D : t[c]) * p + 3);
1855
- f.lineWidth = 2, f.strokeStyle = S, f.beginPath(), f.arc(n, r, i, 0, Math.PI * 2), f.stroke();
1856
- }
1857
- if (o?.length) {
1858
- f.font = "600 12px ui-sans-serif, system-ui, sans-serif", f.textAlign = "center", f.lineWidth = 3;
1859
- let e = b?.getPropertyValue("--dot-map-surface").trim() || b?.backgroundColor || "#161616", t = [];
1860
- for (let n of o) {
1861
- let r = n.x * p + m, i = n.y * p + v;
1862
- if (r < 0 || i < 0 || r > _.width || i > _.height) continue;
1863
- let a = f.measureText(n.text).width, o = [
1864
- r - a / 2 - 2,
1865
- i - 10,
1866
- r + a / 2 + 2,
1867
- i + 4
1868
- ];
1869
- t.some(([e, t, n, r]) => o[0] < n && o[2] > e && o[1] < r && o[3] > t) || (t.push(o), f.strokeStyle = e, f.strokeText(n.text, r, i), f.fillStyle = S, f.fillText(n.text, r, i));
1870
- }
1871
- f.textAlign = "start";
1872
- }
1873
- i.dataset.frameMs = (performance.now() - u).toFixed(2);
1874
- }, [
1875
- _,
1876
- e,
1877
- t,
1878
- n,
1879
- r,
1880
- a,
1881
- o,
1882
- s,
1883
- c,
1884
- T,
1885
- l
1886
- ]), A = (0, X.useCallback)(() => {
1887
- x.current ||= requestAnimationFrame(k);
1888
- }, [k]);
1889
- (0, X.useEffect)(() => {
1890
- w.current = [];
1891
- }, [r]), (0, X.useEffect)(() => {
1892
- if (!_.width) return;
1893
- let e = `${i.join(",")}:${_.width}x${_.height}`;
1894
- b.current !== e && (O(), b.current = e), A();
1895
- }, [
1896
- _,
1897
- i,
1898
- O,
1899
- A
1900
- ]), (0, X.useEffect)(() => A(), [A]), (0, X.useEffect)(() => () => cancelAnimationFrame(x.current), []);
1901
- let j = (0, X.useCallback)((n, r) => {
1902
- let i = g.current;
1903
- if (!i) return null;
1904
- let a = i.getBoundingClientRect(), { scale: o, tx: s, ty: c } = y.current, l = (n - a.left - s) / o, u = (r - a.top - c) / o, d = Math.floor((l - D.x0) / D.cell), f = Math.floor((u - D.y0) / D.cell), p = null, m = Infinity, h = Math.max(1, Math.ceil(6 / (o * D.cell)));
1905
- for (let n = -h; n <= h; n++) for (let r = -h; r <= h; r++) if (!(d + r < 0 || f + n < 0 || d + r >= D.cols || f + n >= D.rows)) for (let i of D.cells.get((f + n) * D.cols + (d + r)) ?? []) {
1906
- let n = e[i * 2] - l, r = e[i * 2 + 1] - u, a = n * n + r * r, s = Math.max(6 / o, typeof t == "number" ? t : t[i]);
1907
- a < m && a <= s * s && (m = a, p = i);
1908
- }
1909
- return p;
1910
- }, [
1911
- D,
1912
- e,
1913
- t
1914
- ]), M = (0, X.useRef)(null), N = (0, X.useRef)(/* @__PURE__ */ new Map()), P = (0, X.useRef)(null);
1915
- (0, X.useEffect)(() => {
1916
- let e = g.current;
1917
- if (!e) return;
1918
- let t = (t) => {
1919
- t.preventDefault();
1920
- let n = e.getBoundingClientRect(), r = t.clientX - n.left, i = t.clientY - n.top, a = Math.exp(-t.deltaY * .0015), o = y.current, s = Math.min(o.scale * 400, Math.max(o.scale * .0025, o.scale * a));
1921
- y.current = {
1922
- scale: s,
1923
- tx: r - (r - o.tx) / o.scale * s,
1924
- ty: i - (i - o.ty) / o.scale * s
1925
- }, A();
1926
- };
1927
- return e.addEventListener("wheel", t, { passive: !1 }), () => e.removeEventListener("wheel", t);
1928
- }, [A]);
1929
- let F = S ? f?.(S.index) ?? null : null;
1930
- return /* @__PURE__ */ (0, Y.jsxs)("div", {
1931
- ref: h,
1932
- className: "tgc-dot-map",
1933
- style: {
1934
- position: "relative",
1935
- height: p
1936
- },
1937
- "data-points": T,
1938
- children: [/* @__PURE__ */ (0, Y.jsx)("canvas", {
1939
- ref: g,
1940
- role: "img",
1941
- "aria-label": m,
1942
- tabIndex: 0,
1943
- style: {
1944
- width: "100%",
1945
- height: p,
1946
- display: "block",
1947
- touchAction: "none",
1948
- cursor: S ? "pointer" : "grab"
1949
- },
1950
- onPointerDown: (e) => {
1951
- if (N.current.set(e.pointerId, {
1952
- x: e.clientX,
1953
- y: e.clientY
1954
- }), N.current.size === 2) {
1955
- let [e, t] = [...N.current.values()];
1956
- P.current = {
1957
- distance: Math.hypot(e.x - t.x, e.y - t.y) || 1,
1958
- view: { ...y.current }
1959
- }, M.current = null;
1960
- } else M.current = {
1961
- x: e.clientX,
1962
- y: e.clientY,
1963
- moved: !1
1964
- };
1965
- e.currentTarget.setPointerCapture(e.pointerId);
1966
- },
1967
- onPointerMove: (e) => {
1968
- N.current.has(e.pointerId) && N.current.set(e.pointerId, {
1969
- x: e.clientX,
1970
- y: e.clientY
1971
- });
1972
- let t = P.current;
1973
- if (t && N.current.size === 2) {
1974
- let [n, r] = [...N.current.values()], i = e.currentTarget.getBoundingClientRect(), a = (n.x + r.x) / 2 - i.left, o = (n.y + r.y) / 2 - i.top, s = t.view.scale * ((Math.hypot(n.x - r.x, n.y - r.y) || 1) / t.distance);
1975
- y.current = {
1976
- scale: s,
1977
- tx: a - (a - t.view.tx) / t.view.scale * s,
1978
- ty: o - (o - t.view.ty) / t.view.scale * s
1979
- }, A();
1980
- return;
1981
- }
1982
- let n = M.current;
1983
- if (n) {
1984
- let t = e.clientX - n.x, r = e.clientY - n.y;
1985
- if (n.moved || Math.abs(t) + Math.abs(r) > 3) {
1986
- n.moved = !0, y.current = {
1987
- ...y.current,
1988
- tx: y.current.tx + t,
1989
- ty: y.current.ty + r
1990
- }, n.x = e.clientX, n.y = e.clientY, A();
1991
- return;
1992
- }
1993
- }
1994
- let r = j(e.clientX, e.clientY), i = e.currentTarget.getBoundingClientRect();
1995
- C(r === null ? null : {
1996
- index: r,
1997
- x: e.clientX - i.left,
1998
- y: e.clientY - i.top
1999
- }), u?.(r);
2000
- },
2001
- onPointerUp: (e) => {
2002
- if (N.current.delete(e.pointerId), P.current) {
2003
- N.current.size < 2 && (P.current = null), M.current = null;
2004
- return;
2005
- }
2006
- let t = M.current;
2007
- M.current = null, t && !t.moved && d?.(j(e.clientX, e.clientY));
2008
- },
2009
- onPointerCancel: (e) => {
2010
- N.current.delete(e.pointerId), N.current.size < 2 && (P.current = null), M.current = null;
2011
- },
2012
- onPointerLeave: () => {
2013
- C(null), u?.(null);
2014
- },
2015
- onDoubleClick: () => {
2016
- O(), A();
2017
- },
2018
- onKeyDown: (e) => {
2019
- let t = y.current, n = (e) => {
2020
- let n = _.width / 2, r = _.height / 2;
2021
- y.current = {
2022
- scale: t.scale * e,
2023
- tx: n - (n - t.tx) / t.scale * t.scale * e,
2024
- ty: r - (r - t.ty) / t.scale * t.scale * e
2025
- };
2026
- };
2027
- if (e.key === "+" || e.key === "=") n(1.4);
2028
- else if (e.key === "-") n(1 / 1.4);
2029
- else if (e.key === "0") O();
2030
- else if (e.key === "ArrowLeft") y.current = {
2031
- ...t,
2032
- tx: t.tx + 60
2033
- };
2034
- else if (e.key === "ArrowRight") y.current = {
2035
- ...t,
2036
- tx: t.tx - 60
2037
- };
2038
- else if (e.key === "ArrowUp") y.current = {
2039
- ...t,
2040
- ty: t.ty + 60
2041
- };
2042
- else if (e.key === "ArrowDown") y.current = {
2043
- ...t,
2044
- ty: t.ty - 60
2045
- };
2046
- else return;
2047
- e.preventDefault(), A();
2048
- }
2049
- }), S && F && /* @__PURE__ */ (0, Y.jsx)("div", {
2050
- className: "tgc-dot-map-tip",
2051
- role: "tooltip",
2052
- style: {
2053
- position: "absolute",
2054
- left: Math.min(S.x + 12, Math.max(0, _.width - 300)),
2055
- top: S.y + 12,
2056
- pointerEvents: "none"
2057
- },
2058
- children: F
2059
- })]
2060
- });
2061
- }
2062
- var nt = (e) => e?.split(" · ")[0], rt = (e) => e <= 0 ? 0 : (e - 1) % 5 + 1, it = (e) => e.status === "failed", Z = (e) => e.status === "running", at = (e) => Number.isFinite(e.startMs) && Number.isFinite(e.endMs) && e.endMs >= e.startMs;
2063
- function Q(e) {
2064
- if (!Number.isFinite(e) || e < 0) return "—";
2065
- if (e < 1e3) return `${Math.round(e)}ms`;
2066
- if (e < 1e4) return `${(e / 1e3).toFixed(1)}s`;
2067
- if (e < 6e4) return `${Math.round(e / 1e3)}s`;
2068
- if (e < 36e5) {
2069
- let t = Math.floor(e / 6e4), n = Math.round(e % 6e4 / 1e3);
2070
- return n === 60 ? `${t + 1}m` : n ? `${t}m ${n}s` : `${t}m`;
2071
- }
2072
- let t = Math.floor(e / 36e5), n = Math.round(e % 36e5 / 6e4);
2073
- return n === 60 ? `${t + 1}h` : `${t}h ${String(n).padStart(2, "0")}m`;
2074
- }
2075
- function ot(e) {
2076
- return e === 0 ? "$0.00" : e < .01 ? `$${e.toPrecision(1).replace(/0+$/, "")}` : `$${e.toFixed(2)}`;
2077
- }
2078
- function st(e) {
2079
- return e < 1e3 ? String(e) : e < 1e6 ? `${(e / 1e3).toFixed(1)}k` : `${(e / 1e6).toFixed(1)}M`;
2080
- }
2081
- function ct(e, t, n = 240) {
2082
- e.sort((e, t) => e.startMs - t.startMs);
2083
- let r = t;
2084
- for (let t = 0; t < 40; t++, r *= 2) {
2085
- let t = [], i = /* @__PURE__ */ new Map();
2086
- for (let n of e) {
2087
- let e = t[t.length - 1], a = Math.min(n.endMs, n.startMs + r * 4) - n.startMs, o = (e) => e.retry || e.kind === "failed", s = a < r || e !== void 0 && e.endMs - e.startMs < r;
2088
- if (e && !o(e) && !o(n) && e.tone === n.tone && n.startMs - e.endMs <= r && (e.kind === n.kind || s)) {
2089
- let t = i.get(e) ?? {
2090
- model: e.kind === "model" ? e.endMs - e.startMs : 0,
2091
- tool: e.kind === "tool" ? e.endMs - e.startMs : 0
2092
- };
2093
- t[n.kind === "model" ? "model" : "tool"] += a, i.set(e, t), e.endMs = Math.max(e.endMs, n.endMs), e.count += n.count, e.tool !== n.tool && (e.tool = void 0), n.costUsd !== void 0 && (e.costUsd = (e.costUsd ?? 0) + n.costUsd), e.kind = t.model >= t.tool ? "model" : "tool";
2094
- } else t.push({ ...n });
2095
- }
2096
- if (t.length <= n) return t;
2097
- }
2098
- return e;
2099
- }
2100
- function lt(e, t) {
2101
- let n = /* @__PURE__ */ new Set(), r = [...e.spans].map((e, t) => ({
2102
- span: e,
2103
- key: e.id ?? `span-${t}`
2104
- })).sort((e, t) => e.span.startMs - t.span.startMs).map(({ span: t, key: r }, i) => {
2105
- let a = r, o = i;
2106
- for (; n.has(a);) a = `${r}:${o++}`;
2107
- return n.add(a), {
2108
- id: a,
2109
- parentId: t.parentId,
2110
- name: t.name,
2111
- kind: t.kind,
2112
- durationLabel: at(t) ? `${Q(t.endMs - t.startMs)}${t.approx ? "~" : ""}` : "—",
2113
- approx: t.approx === !0,
2114
- ok: !it(t),
2115
- depth: 0,
2116
- hasChildren: !1,
2117
- span: t,
2118
- tone: -1,
2119
- descendants: 0,
2120
- segments: [],
2121
- own: [],
2122
- retry: t.retryOf !== void 0,
2123
- hasAgents: !1,
2124
- ...t.costBound === "lower" || t.costBound === void 0 && e.costBound === "lower" ? { costFloor: !0 } : {}
2125
- };
2126
- }), i = new Map(r.map((e) => [e.id, e])), a = /* @__PURE__ */ new Map();
2127
- for (let e of r) {
2128
- let t = /* @__PURE__ */ new Set([e.id]), n = e.parentId;
2129
- for (; n && i.has(n);) {
2130
- if (t.has(n)) {
2131
- e.parentId = void 0;
2132
- break;
2133
- }
2134
- t.add(n), n = i.get(n)?.parentId;
2135
- }
2136
- if (e.parentId && !i.has(e.parentId) && (e.parentId = void 0), e.parentId) {
2137
- let t = a.get(e.parentId) ?? [];
2138
- t.push(e), a.set(e.parentId, t);
2139
- }
2140
- }
2141
- let o = Math.max(1, Number.isFinite(e.totalMs) ? e.totalMs : 1), s = t ?? o / 900, c = [], l = 0, u = (e, t, n) => {
2142
- e.depth = t, e.tone = e.kind === "pipeline" ? l++ : n;
2143
- let r = a.get(e.id) ?? [];
2144
- e.hasChildren = r.length > 0, c.push(e);
2145
- let i = [], o = e.span.promptTokens !== void 0 || e.span.completionTokens !== void 0 || e.span.cachedTokens !== void 0, d = e.span.costUsd ?? 0, f = e.span.kind !== "model" || e.span.costUsd !== void 0;
2146
- for (let n of r) {
2147
- for (let r of u(n, t + 1, e.tone)) i.push(r);
2148
- e.descendants += 1 + n.descendants, n.kind === "pipeline" && (e.hasAgents = !0);
2149
- let r = n.hasChildren ? n.rollupCostUsd : n.span.costUsd;
2150
- r === void 0 ? (n.kind === "model" || n.hasChildren) && (f = !1) : d += r, n.kind !== "pipeline" && n.kind !== "waiting" && at(n.span) && e.own.push(pt(n));
2151
- }
2152
- Object.assign(e, ut(r));
2153
- let p = o ? {
2154
- prompt: e.span.promptTokens,
2155
- completion: e.span.completionTokens,
2156
- cached: e.span.cachedTokens
2157
- } : ft(r);
2158
- return p && (e.tokens = p), e.hasChildren && f && (e.rollupCostUsd = d), e.hasChildren && (e.segments = ct(i.map((e) => ({ ...e })), s), e.own = ct(e.own, s)), e.kind === "pipeline" || e.kind === "waiting" || !at(e.span) || i.push(pt(e)), i;
2159
- };
2160
- for (let e of r) e.parentId || u(e, 0, -1);
2161
- return c;
2162
- }
2163
- function ut(e) {
2164
- let t, n = [];
2165
- for (let r of e) if (r.kind !== "pipeline" && r.kind !== "waiting" && at(r.span)) {
2166
- if (t ??= {
2167
- model: 0,
2168
- tool: 0,
2169
- failed: 0,
2170
- retried: 0,
2171
- tools: {}
2172
- }, r.ok || t.failed++, r.retry && t.retried++, r.kind === "model") t.model++, Z(r.span) || n.push(r.span.endMs - r.span.startMs);
2173
- else {
2174
- t.tool++;
2175
- let e = nt(r.name) || r.kind;
2176
- t.tools[e] = (t.tools[e] ?? 0) + 1;
2177
- }
2178
- }
2179
- return t ? {
2180
- counts: t,
2181
- modelMs: n.sort((e, t) => e - t)
2182
- } : {};
2183
- }
2184
- function dt(e) {
2185
- let t;
2186
- for (let n of e) if (n.counts) {
2187
- t ??= {
2188
- model: 0,
2189
- tool: 0,
2190
- failed: 0,
2191
- retried: 0,
2192
- tools: {}
2193
- }, t.model += n.counts.model, t.tool += n.counts.tool, t.failed += n.counts.failed, t.retried += n.counts.retried;
2194
- for (let [e, r] of Object.entries(n.counts.tools)) t.tools[e] = (t.tools[e] ?? 0) + r;
2195
- }
2196
- let n = ft(e);
2197
- return {
2198
- ...t ? {
2199
- counts: t,
2200
- modelMs: e.flatMap((e) => e.modelMs ?? []).sort((e, t) => e - t)
2201
- } : {},
2202
- ...n ? { tokens: n } : {}
2203
- };
2204
- }
2205
- function ft(e) {
2206
- let t;
2207
- for (let n of e) for (let e of [
2208
- "prompt",
2209
- "completion",
2210
- "cached"
2211
- ]) {
2212
- let r = n.tokens?.[e];
2213
- r !== void 0 && ((t ??= {})[e] = (t[e] ?? 0) + r);
2214
- }
2215
- return t;
2216
- }
2217
- function pt(e) {
2218
- return {
2219
- startMs: e.span.startMs,
2220
- endMs: Z(e.span) ? Infinity : e.span.endMs,
2221
- kind: e.ok ? e.kind === "model" ? "model" : "tool" : "failed",
2222
- tone: e.tone,
2223
- id: e.id,
2224
- count: 1,
2225
- retry: e.retry,
2226
- name: e.name,
2227
- tool: nt(e.name),
2228
- ...e.span.costUsd === void 0 ? {} : { costUsd: e.span.costUsd },
2229
- ...!e.ok && e.kind === "model" ? { modelCall: !0 } : {}
2230
- };
2231
- }
2232
- function mt(e, t, n) {
2233
- let r = t.trim(), i = r.toLowerCase();
2234
- return new Set(e.filter((e) => n ? n(e.span, r) : `${e.name} ${e.span.detail ?? ""} ${e.kind} ${e.ok ? "" : "failed"} ${e.span.status ?? ""}`.toLowerCase().includes(i)).map((e) => e.id));
2235
- }
2236
- function ht(e, t, n, r) {
2237
- let i = new Map(e.map((e) => [e.id, e]));
2238
- if (t.trim()) {
2239
- let n = /* @__PURE__ */ new Set();
2240
- for (let a of mt(e, t, r)) {
2241
- let e = i.get(a);
2242
- for (; e && !n.has(e.id);) n.add(e.id), e = e.parentId ? i.get(e.parentId) : void 0;
2243
- }
2244
- return e.filter((e) => n.has(e.id));
2245
- }
2246
- let a = /* @__PURE__ */ new Set();
2247
- return e.filter((e) => {
2248
- let t = e.parentId !== void 0 && (n.has(e.parentId) || a.has(e.parentId));
2249
- return t && a.add(e.id), !t;
2250
- });
2251
- }
2252
- function gt(e, t) {
2253
- let n, r = -1;
2254
- for (let i of e) {
2255
- if (i.hasChildren || i.kind === "pipeline" || i.kind === "waiting" || i.durationLabel === "—" || i.span.startMs > t) continue;
2256
- let e = (Z(i.span) ? Math.max(i.span.endMs, t) : Math.min(i.span.endMs, t)) - i.span.startMs;
2257
- e > r && (n = i, r = e);
2258
- }
2259
- return n;
2260
- }
2261
- function _t(e) {
2262
- let t = /* @__PURE__ */ new Map();
2263
- for (let n of e) {
2264
- if (!n.parentId) continue;
2265
- let e = t.get(n.parentId);
2266
- e ? e.push(n) : t.set(n.parentId, [n]);
2267
- }
2268
- let n;
2269
- for (let r of e) {
2270
- if (r.parentId) continue;
2271
- let e = [], i = r.span.endMs;
2272
- for (let n = r; n;) e.push(n.id), i = Math.max(i, n.span.endMs), n = t.get(n.id)?.reduce((e, t) => !e || t.span.endMs > e.span.endMs ? t : e, void 0);
2273
- (!n || i > n.end) && (n = {
2274
- end: i,
2275
- chain: e
2276
- });
2277
- }
2278
- return new Set(n?.chain);
2279
- }
2280
- function vt(e, t) {
2281
- let n, r = -1, i, a = -1, o = 0, s = 0;
2282
- for (let c of e) {
2283
- if (c.durationLabel === "—" || c.span.startMs > t || c.kind !== "pipeline" || c.id.startsWith("family:") || c.id.startsWith("run:")) continue;
2284
- if (c.parentId !== void 0) {
2285
- let e = (Z(c.span) ? Math.max(c.span.endMs, t) : Math.min(c.span.endMs, t)) - c.span.startMs;
2286
- s += 1, e > r && (n = c, r = e);
2287
- }
2288
- let e = c.span.costUsd ?? c.rollupCostUsd;
2289
- e !== void 0 && (o += 1, e > a && (i = c, a = e));
2290
- }
2291
- return {
2292
- slowestId: s > 1 ? n?.id : void 0,
2293
- costliestId: o > 1 && a > 0 ? i?.id : void 0
2294
- };
2295
- }
2296
- function yt(e, t) {
2297
- let n = 0, r = -Infinity;
2298
- for (let i of e.own) {
2299
- let e = Math.max(i.startMs, r), a = Math.min(i.endMs, t);
2300
- a > e && (n += a - e), r = Math.max(r, Math.min(i.endMs, t));
2301
- }
2302
- return n;
2303
- }
2304
- function bt(e, t) {
2305
- let n = 0, r = 0, i = 0, a = 0, o = 0, s = !1, c = !1;
2306
- for (let l of e.spans) l.startMs > t || (l.kind === "model" && i++, l.kind === "tool" && a++, !(l.endMs > t) && (it(l) && o++, l.costUsd !== void 0 && (n += l.costUsd, s = !0), (l.promptTokens !== void 0 || l.completionTokens !== void 0) && (r += (l.promptTokens ?? 0) + (l.completionTokens ?? 0), c = !0)));
2307
- return {
2308
- costUsd: e.costUsd === void 0 ? void 0 : s ? n : e.costUsd,
2309
- tokens: c ? r : e.promptTokens + e.completionTokens,
2310
- modelCalls: e.modelCalls === void 0 ? void 0 : i,
2311
- toolCalls: e.toolCalls === void 0 ? void 0 : a,
2312
- errors: o
2313
- };
2314
- }
2315
- function xt(e, t) {
2316
- let n = t.costBasis === "list", r = n ? "Cost · list price" : "Cost";
2317
- if (e === void 0) return t.billedUsd === void 0 ? {
2318
- value: "—",
2319
- title: "No cost source: the harness recorded no cost and no price catalog was given",
2320
- label: r
2321
- } : {
2322
- value: `${ot(t.billedUsd)} billed`,
2323
- title: "No list price for these calls; billed is the seat charge",
2324
- label: r
2325
- };
2326
- let i = t.costCoverage, a = i !== void 0 && i.priced < i.total, o = !a && t.costBound === "upper";
2327
- return {
2328
- value: `${a || t.costBound === "lower" ? "≥" : o ? "≤" : n ? "≈" : ""}${ot(e)}${t.billedUsd === void 0 ? "" : ` · ${ot(t.billedUsd)} billed`}`,
2329
- title: [
2330
- a ? `${i.priced} of ${i.total} model calls priced` : i ? `all ${i.total} model calls priced` : "",
2331
- n ? "at the model catalog list price; not a bill" : "",
2332
- o ? "cached input is not split out, so it is priced as fresh input: at most this" : "",
2333
- t.costBound === "lower" ? "a floor: the producer reports at least this" : "",
2334
- t.billedUsd === void 0 ? "" : `billed ${ot(t.billedUsd)} (the seat charge)`
2335
- ].filter(Boolean).join("; "),
2336
- label: r
2337
- };
2338
- }
2339
- var St = (e) => e.replace(/[-\s]\d+$/, "");
2340
- function Ct(e, t, n) {
2341
- let r = e.length <= t, i = wt(e, /* @__PURE__ */ new Set()).filter((e) => e.id.startsWith("family:")).map((e) => e.id);
2342
- return new Set(i.filter((e) => r !== n.has(e)));
2343
- }
2344
- function wt(e, t) {
2345
- let n = /* @__PURE__ */ new Map();
2346
- for (let t of e) {
2347
- let e = t.parentId === void 0 ? `root:${t.id}` : St(t.name);
2348
- n.set(e, [...n.get(e) ?? [], t]);
2349
- }
2350
- let r = [], i = 0, a = (e) => e.tone <= 0 ? e.tone : ++i;
2351
- for (let [e, i] of n) {
2352
- if (i.length < 2) {
2353
- r.push(...i.map((e) => ({
2354
- ...e,
2355
- tone: a(e)
2356
- })));
2357
- continue;
2358
- }
2359
- let n = a(i[0]), o = `family:${e}`, s = Math.min(...i.map((e) => e.span.startMs)), c = Math.max(...i.map((e) => e.span.endMs)), l = i.some((e) => Z(e.span)), u = i.map((e) => e.span.costUsd ?? e.rollupCostUsd).filter((e) => e !== void 0), d = i.filter((e) => e.span.outcome ? e.span.outcome.tone === "failed" : !e.ok).length, f = i.every((e) => e.span.outcome && e.span.outcome.tone === i[0].span.outcome?.tone) ? i[0].span.outcome : void 0;
2360
- r.push({
2361
- costFloor: u.length < i.length || i.some((e) => e.costFloor),
2362
- id: o,
2363
- parentId: i[0].parentId,
2364
- name: e,
2365
- kind: "pipeline",
2366
- durationLabel: Q(c - s),
2367
- approx: i.some((e) => e.approx),
2368
- ok: d === 0,
2369
- depth: 0,
2370
- hasChildren: !0,
2371
- tone: n,
2372
- descendants: i.length,
2373
- segments: [],
2374
- retry: !1,
2375
- hasAgents: !1,
2376
- own: i.flatMap((e, t) => e.own.map((e) => ({
2377
- ...e,
2378
- tone: n,
2379
- alt: t % 2 == 1
2380
- }))).sort((e, t) => e.startMs - t.startMs),
2381
- ...u.length ? { rollupCostUsd: u.reduce((e, t) => e + t, 0) } : {},
2382
- ...dt(i),
2383
- span: {
2384
- id: o,
2385
- kind: "pipeline",
2386
- name: e,
2387
- startMs: s,
2388
- endMs: c,
2389
- status: l ? "running" : d ? "failed" : "done",
2390
- ...f ? { outcome: f } : {},
2391
- detail: i[0].span.detail,
2392
- meta: {
2393
- failedAgents: d,
2394
- costPartial: u.length < i.length,
2395
- members: i.map((e) => e.id)
2396
- }
2397
- }
2398
- }), t.has(o) && r.push(...i.map((e, t) => ({
2399
- ...e,
2400
- family: o,
2401
- inset: 1,
2402
- tone: n,
2403
- own: e.own.map((e) => ({
2404
- ...e,
2405
- tone: n,
2406
- alt: t % 2 == 1
2407
- }))
2408
- })));
2409
- }
2410
- return r;
2411
- }
2412
- function Tt(e) {
2413
- if (e.id.startsWith("family:")) {
2414
- let t = Number(e.span.meta?.failedAgents ?? 0);
2415
- return [`${e.descendants} agents`, ...t ? [`${t} failed`] : []];
2416
- }
2417
- if (e.id.startsWith("run:")) {
2418
- let t = e.own.filter((e) => e.kind === "failed").length;
2419
- return [t ? `${t} failed` : "all done"];
2420
- }
2421
- let t = e.counts?.model ?? 0, n = e.counts?.tool ?? 0;
2422
- return [
2423
- e.span.outcome?.label ?? (Z(e.span) ? "running" : e.ok ? e.kind === "pipeline" ? "" : "done" : "failed"),
2424
- t ? `${t} LLM ${t === 1 ? "call" : "calls"}` : "",
2425
- n ? `${n} tool ${n === 1 ? "call" : "calls"}` : ""
2426
- ].filter(Boolean);
2427
- }
2428
- function Et(e, t, n, r) {
2429
- let i = wt(e, n);
2430
- if (r.size === 0) return i;
2431
- let a = /* @__PURE__ */ new Map();
2432
- for (let e of t) e.parentId !== void 0 && r.has(e.parentId) && e.kind !== "pipeline" && a.set(e.parentId, [...a.get(e.parentId) ?? [], e]);
2433
- return i.flatMap((e) => r.has(e.id) ? [e, ...Dt(a.get(e.id) ?? []).map((t) => ({
2434
- ...t,
2435
- stepOf: e.id,
2436
- inset: (e.inset ?? 0) + 1,
2437
- tone: e.tone,
2438
- own: t.own.map((t) => ({
2439
- ...t,
2440
- tone: e.tone
2441
- }))
2442
- }))] : [e]);
2443
- }
2444
- function Dt(e) {
2445
- let t = [];
2446
- for (let n = 0; n < e.length;) {
2447
- let r = n;
2448
- for (; r < e.length && e[r].kind === e[n].kind && e[r].name === e[n].name;) r++;
2449
- let i = e.slice(n, r);
2450
- if (i.length < 3) {
2451
- t.push(...i), n = r;
2452
- continue;
2453
- }
2454
- let a = i[0], o = Math.min(...i.map((e) => e.span.startMs)), s = Math.max(...i.map((e) => e.span.endMs)), c = i.filter((e) => !e.ok).length, l = i.map((e) => e.span.costUsd ?? e.rollupCostUsd).filter((e) => e !== void 0), u = a.kind === "model" ? "model calls" : a.kind === "tool" ? `${a.name} calls` : `${a.name} steps`;
2455
- t.push({
2456
- ...a,
2457
- id: `run:${a.id}`,
2458
- name: `${i.length} ${u}`,
2459
- durationLabel: Q(s - o),
2460
- ok: c === 0,
2461
- hasChildren: !1,
2462
- descendants: 0,
2463
- segments: [],
2464
- ...ut(i),
2465
- tokens: ft(i),
2466
- own: i.map((e) => ({
2467
- startMs: e.span.startMs,
2468
- endMs: e.span.endMs,
2469
- kind: e.ok ? e.kind === "model" ? "model" : "tool" : "failed",
2470
- tone: a.tone,
2471
- id: e.id,
2472
- count: 1,
2473
- retry: e.retry,
2474
- name: e.name,
2475
- tool: nt(e.name)
2476
- })),
2477
- ...l.length ? { rollupCostUsd: l.reduce((e, t) => e + t, 0) } : {},
2478
- span: {
2479
- ...a.span,
2480
- id: `run:${a.id}`,
2481
- name: `${i.length} ${u}`,
2482
- startMs: o,
2483
- endMs: s,
2484
- status: c ? "failed" : a.span.status,
2485
- costUsd: void 0
2486
- }
2487
- }), n = r;
2488
- }
2489
- return t;
2490
- }
2491
- function Ot(e, t) {
2492
- let n = t.find((t) => t.id === e.id);
2493
- if (n) return n;
2494
- let r = t.find((t) => (t.span.meta?.members)?.includes(e.id));
2495
- return r ? {
2496
- ...e,
2497
- tone: r.tone
2498
- } : e;
2499
- }
2500
- var kt = (e, t) => `${e.costFloor ? "≥" : ""}${ot(t)}`, $ = (e, t) => /* @__PURE__ */ (0, Y.jsx)("svg", {
2501
- viewBox: "0 0 16 16",
2502
- width: "14",
2503
- height: "14",
2504
- fill: "none",
2505
- stroke: "currentColor",
2506
- strokeWidth: "1.5",
2507
- strokeLinecap: "round",
2508
- strokeLinejoin: "round",
2509
- "aria-hidden": !t || void 0,
2510
- role: t ? "img" : void 0,
2511
- "aria-label": t,
2512
- children: e
2513
- });
2514
- function At(e) {
2515
- let t = (e ?? "").toLowerCase();
2516
- if (/bash|shell|exec|terminal|command|run/.test(t)) return $(/* @__PURE__ */ (0, Y.jsxs)(Y.Fragment, { children: [/* @__PURE__ */ (0, Y.jsx)("rect", {
2517
- x: "2",
2518
- y: "3",
2519
- width: "12",
2520
- height: "10",
2521
- rx: "2"
2522
- }), /* @__PURE__ */ (0, Y.jsx)("path", { d: "m5 7 2 1.5L5 10M8.5 10.5h2.5" })] }));
2523
- if (/edit|write|patch|apply/.test(t)) return $(/* @__PURE__ */ (0, Y.jsx)("path", { d: "M3 13l1-3.5L10.5 3a1.4 1.4 0 0 1 2 2L6 11.5 3 13ZM9.5 4l2 2" }));
2524
- if (/grep|search|find|query/.test(t)) return $(/* @__PURE__ */ (0, Y.jsxs)(Y.Fragment, { children: [/* @__PURE__ */ (0, Y.jsx)("circle", {
2525
- cx: "7",
2526
- cy: "7",
2527
- r: "4.25"
2528
- }), /* @__PURE__ */ (0, Y.jsx)("path", { d: "m10.25 10.25 3.25 3.25" })] }));
2529
- if (/read|glob|list|ls|cat|file|view/.test(t)) return $(/* @__PURE__ */ (0, Y.jsxs)(Y.Fragment, { children: [/* @__PURE__ */ (0, Y.jsx)("path", { d: "M4 2.5h5l3 3v8H4z" }), /* @__PURE__ */ (0, Y.jsx)("path", { d: "M9 2.5v3h3M6 9h4M6 11h3" })] }));
2530
- if (/web|fetch|http|browser|url/.test(t)) return $(/* @__PURE__ */ (0, Y.jsxs)(Y.Fragment, { children: [/* @__PURE__ */ (0, Y.jsx)("circle", {
2531
- cx: "8",
2532
- cy: "8",
2533
- r: "5.5"
2534
- }), /* @__PURE__ */ (0, Y.jsx)("path", { d: "M2.5 8h11M8 2.5c2 2 2 9 0 11M8 2.5c-2 2-2 9 0 11" })] }));
2535
- if (/git|commit|branch|merge/.test(t)) return $(/* @__PURE__ */ (0, Y.jsxs)(Y.Fragment, { children: [
2536
- /* @__PURE__ */ (0, Y.jsx)("circle", {
2537
- cx: "5",
2538
- cy: "4",
2539
- r: "1.5"
2540
- }),
2541
- /* @__PURE__ */ (0, Y.jsx)("circle", {
2542
- cx: "5",
2543
- cy: "12",
2544
- r: "1.5"
2545
- }),
2546
- /* @__PURE__ */ (0, Y.jsx)("circle", {
2547
- cx: "11",
2548
- cy: "6",
2549
- r: "1.5"
2550
- }),
2551
- /* @__PURE__ */ (0, Y.jsx)("path", { d: "M5 5.5v5M11 7.5c0 2-3 2-6 3" })
2552
- ] }));
2553
- }
2554
- function jt({ kind: e, name: t }) {
2555
- if (e === "tool") {
2556
- let e = At(t);
2557
- if (e) return e;
2558
- }
2559
- switch (e) {
2560
- case "pipeline": return $(/* @__PURE__ */ (0, Y.jsxs)(Y.Fragment, { children: [
2561
- /* @__PURE__ */ (0, Y.jsx)("circle", {
2562
- cx: "8",
2563
- cy: "4",
2564
- r: "1.75"
2565
- }),
2566
- /* @__PURE__ */ (0, Y.jsx)("circle", {
2567
- cx: "4",
2568
- cy: "12",
2569
- r: "1.75"
2570
- }),
2571
- /* @__PURE__ */ (0, Y.jsx)("circle", {
2572
- cx: "12",
2573
- cy: "12",
2574
- r: "1.75"
2575
- }),
2576
- /* @__PURE__ */ (0, Y.jsx)("path", { d: "M8 5.75v2.5M8 8.25 4.8 10.6M8 8.25l3.2 2.35" })
2577
- ] }));
2578
- case "model": return $(/* @__PURE__ */ (0, Y.jsx)("path", { d: "M8 2.5c.5 2.8 2.2 4.6 5 5.5-2.8.9-4.5 2.7-5 5.5-.5-2.8-2.2-4.6-5-5.5 2.8-.9 4.5-2.7 5-5.5Z" }));
2579
- case "waiting": return $(/* @__PURE__ */ (0, Y.jsxs)(Y.Fragment, { children: [/* @__PURE__ */ (0, Y.jsx)("path", { d: "M4.5 2.5h7M4.5 13.5h7" }), /* @__PURE__ */ (0, Y.jsx)("path", { d: "M5.5 2.5c0 3 5 3 5 5.5s-5 2.5-5 5.5M10.5 2.5c0 3-5 3-5 5.5" })] }));
2580
- case "handoff": return $(/* @__PURE__ */ (0, Y.jsx)("path", { d: "M3 3v5.5a2 2 0 0 0 2 2h8M10.5 8l2.5 2.5-2.5 2.5" }));
2581
- default: return $(/* @__PURE__ */ (0, Y.jsx)("path", { d: "M10.2 2.8a3.2 3.2 0 0 0-4 4L2.8 10.2a1.4 1.4 0 0 0 2 2l3.4-3.4a3.2 3.2 0 0 0 4-4l-1.9 1.9-1.6-.4-.4-1.6 1.9-1.9Z" }));
2582
- }
2583
- }
2584
- var Mt = () => $(/* @__PURE__ */ (0, Y.jsx)("path", { d: "m6 4 4 4-4 4" })), Nt = () => $(/* @__PURE__ */ (0, Y.jsxs)(Y.Fragment, { children: [/* @__PURE__ */ (0, Y.jsx)("circle", {
2585
- cx: "7",
2586
- cy: "7",
2587
- r: "4.25"
2588
- }), /* @__PURE__ */ (0, Y.jsx)("path", { d: "m10.25 10.25 3.25 3.25" })] })), Pt = () => /* @__PURE__ */ (0, Y.jsx)("svg", {
2589
- viewBox: "0 0 16 16",
2590
- width: "14",
2591
- height: "14",
2592
- "aria-hidden": !0,
2593
- children: /* @__PURE__ */ (0, Y.jsx)("path", {
2594
- d: "M4.5 3.2v9.6a.6.6 0 0 0 .9.5l7.6-4.8a.6.6 0 0 0 0-1L5.4 2.7a.6.6 0 0 0-.9.5Z",
2595
- fill: "currentColor"
2596
- })
2597
- }), Ft = () => /* @__PURE__ */ (0, Y.jsxs)("svg", {
2598
- viewBox: "0 0 16 16",
2599
- width: "14",
2600
- height: "14",
2601
- "aria-hidden": !0,
2602
- children: [/* @__PURE__ */ (0, Y.jsx)("rect", {
2603
- x: "4",
2604
- y: "3",
2605
- width: "2.75",
2606
- height: "10",
2607
- rx: ".8",
2608
- fill: "currentColor"
2609
- }), /* @__PURE__ */ (0, Y.jsx)("rect", {
2610
- x: "9.25",
2611
- y: "3",
2612
- width: "2.75",
2613
- height: "10",
2614
- rx: ".8",
2615
- fill: "currentColor"
2616
- })]
2617
- }), It = () => $(/* @__PURE__ */ (0, Y.jsxs)(Y.Fragment, { children: [/* @__PURE__ */ (0, Y.jsx)("path", { d: "M3 8a5 5 0 1 0 1.5-3.55" }), /* @__PURE__ */ (0, Y.jsx)("path", { d: "M3 2.75V5.5h2.75" })] })), Lt = ({ label: e }) => $(/* @__PURE__ */ (0, Y.jsxs)(Y.Fragment, { children: [/* @__PURE__ */ (0, Y.jsx)("path", { d: "M12.5 8A4.5 4.5 0 1 1 11 4.6" }), /* @__PURE__ */ (0, Y.jsx)("path", { d: "M11.5 2v3h-3" })] }), e), Rt = ({ label: e }) => $(/* @__PURE__ */ (0, Y.jsx)("path", { d: "m4.5 4.5 7 7m0-7-7 7" }), e), zt = () => $(/* @__PURE__ */ (0, Y.jsx)("path", { d: "m4.5 4.5 7 7m0-7-7 7" })), Bt = () => $(/* @__PURE__ */ (0, Y.jsx)("path", { d: "M8 1.5v3M8 11.5v3M1.5 8h3M11.5 8h3M3.4 3.4l2.1 2.1M10.5 10.5l2.1 2.1M3.4 12.6l2.1-2.1M10.5 5.5l2.1-2.1" })), Vt = ({ label: e }) => $(/* @__PURE__ */ (0, Y.jsxs)(Y.Fragment, { children: [/* @__PURE__ */ (0, Y.jsx)("path", { d: "M8 2.5 14 13H2L8 2.5Z" }), /* @__PURE__ */ (0, Y.jsx)("path", { d: "M8 6.5v3M8 11.25v.01" })] }), e), Ht = () => $(/* @__PURE__ */ (0, Y.jsxs)(Y.Fragment, { children: [/* @__PURE__ */ (0, Y.jsx)("circle", {
2618
- cx: "7",
2619
- cy: "7",
2620
- r: "4.25"
2621
- }), /* @__PURE__ */ (0, Y.jsx)("path", { d: "m10.25 10.25 3.25 3.25M5 7h4M7 5v4" })] })), Ut = () => $(/* @__PURE__ */ (0, Y.jsxs)(Y.Fragment, { children: [/* @__PURE__ */ (0, Y.jsx)("circle", {
2622
- cx: "7",
2623
- cy: "7",
2624
- r: "4.25"
2625
- }), /* @__PURE__ */ (0, Y.jsx)("path", { d: "m10.25 10.25 3.25 3.25M5 7h4" })] })), Wt = () => $(/* @__PURE__ */ (0, Y.jsx)("path", { d: "M2.5 6V3.5a1 1 0 0 1 1-1H6M10 2.5h2.5a1 1 0 0 1 1 1V6M13.5 10v2.5a1 1 0 0 1-1 1H10M6 13.5H3.5a1 1 0 0 1-1-1V10" })), Gt = (e) => e.replace(/-/g, "‑"), Kt = {
2626
- pipeline: "Agent",
2627
- model: "LLM call",
2628
- tool: "Tool call",
2629
- waiting: "Waiting",
2630
- handoff: "Handoff"
2631
- }, qt = (e, t) => /* @__PURE__ */ (0, Y.jsxs)("span", {
2632
- title: `${e.toLocaleString()} ${t}`,
2633
- children: [
2634
- st(e),
2635
- " ",
2636
- t
2637
- ]
2638
- }), Jt = (e, t, n = `${t}s`) => `${e.toLocaleString()} ${e === 1 ? t : n}`, Yt = (e, t) => e[Math.min(e.length - 1, Math.ceil(t * e.length) - 1)], Xt = 4;
2639
- function Zt(e, t, n) {
2640
- let r = e.span, i = [];
2641
- r.detail && i.push([r.kind === "tool" ? "Provider" : "Model", r.detail]);
2642
- let a = Z(r) ? Math.max(r.endMs, t) : r.endMs;
2643
- i.push(["Duration", Number.isFinite(a - r.startMs) && a >= r.startMs ? Q(a - r.startMs) : "—"]), n && i.push(["Started", `+${Q(Math.max(0, r.startMs))}`]);
2644
- let o = e.tokens;
2645
- if (o) {
2646
- let e = [
2647
- ["prompt", "in"],
2648
- ["completion", "out"],
2649
- ["cached", "cached"]
2650
- ].flatMap(([e, t]) => o[e] === void 0 ? [] : [qt(o[e], t)]);
2651
- i.push(["Tokens", /* @__PURE__ */ (0, Y.jsx)("span", {
2652
- className: "fw-card-parts",
2653
- children: e.map((e, t) => /* @__PURE__ */ (0, Y.jsx)("span", { children: e }, t))
2654
- })]);
2655
- }
2656
- let s = e.modelMs;
2657
- s?.length && i.push(["LLM latency", /* @__PURE__ */ (0, Y.jsxs)("span", {
2658
- className: "fw-card-parts",
2659
- children: [/* @__PURE__ */ (0, Y.jsxs)("span", { children: [Q(Yt(s, .5)), " median"] }), s.length >= 10 && /* @__PURE__ */ (0, Y.jsxs)("span", { children: [Q(Yt(s, .95)), " p95"] })]
2660
- })]);
2661
- let c = r.costUsd ?? e.rollupCostUsd;
2662
- c !== void 0 && i.push(["Cost", kt(e, c)]);
2663
- let l = e.counts;
2664
- if (l?.model && i.push(["LLM calls", l.model.toLocaleString()]), l?.tool) {
2665
- let e = Object.entries(l.tools).sort(([e, t], [n, r]) => r - t || e.localeCompare(n)), t = e.length - Xt;
2666
- i.push(["Tool calls", /* @__PURE__ */ (0, Y.jsxs)(Y.Fragment, { children: [l.tool.toLocaleString(), /* @__PURE__ */ (0, Y.jsxs)("span", {
2667
- className: "fw-card-tools",
2668
- title: e.map(([e, t]) => `${e} ${t}`).join(", "),
2669
- children: [e.slice(0, t > 1 ? Xt : e.length).map(([e, t]) => /* @__PURE__ */ (0, Y.jsxs)("span", { children: [/* @__PURE__ */ (0, Y.jsx)("span", { children: e }), /* @__PURE__ */ (0, Y.jsx)("span", { children: t.toLocaleString() })] }, e)), t > 1 && /* @__PURE__ */ (0, Y.jsxs)("span", { children: [/* @__PURE__ */ (0, Y.jsxs)("span", { children: [t, " more tools"] }), /* @__PURE__ */ (0, Y.jsx)("span", { children: e.slice(Xt).reduce((e, [, t]) => e + t, 0).toLocaleString() })] })]
2670
- })] })]);
2671
- }
2672
- l?.failed && i.push(["Failures", Jt(l.failed, "failed step")]);
2673
- let u = r.marks?.filter((e) => e.kind === "restart").length ?? 0;
2674
- (l?.retried || u) && i.push(["Retries", [l?.retried ? Jt(l.retried, "step retried", "steps retried") : "", u ? Jt(u, "restart") : ""].filter(Boolean).join(" · ")]), n && e.hasChildren && i.push(["Steps", e.descendants.toLocaleString()]);
2675
- for (let e of r.facts ?? []) i.some(([t]) => t.toLowerCase() === e.label.toLowerCase()) || i.push([e.label, e.value]);
2676
- return i;
2677
- }
2678
- function Qt({ rows: e }) {
2679
- return /* @__PURE__ */ (0, Y.jsx)("dl", {
2680
- className: "fw-card-table",
2681
- children: e.map(([e, t]) => /* @__PURE__ */ (0, Y.jsxs)("div", { children: [/* @__PURE__ */ (0, Y.jsx)("dt", { children: e }), /* @__PURE__ */ (0, Y.jsx)("dd", { children: t })] }, e))
2682
- });
2683
- }
2684
- function $t({ id: e, row: t, agent: n, clockMs: r, left: i, top: a, pinned: o, onClose: s, renderIcon: c, compact: l }) {
2685
- let u = t.span, d = Z(u) ? "Running" : t.ok ? "Done" : "Failed", f = n && n.id !== t.id ? n : void 0, p = {
2686
- id: e,
2687
- role: o ? "dialog" : "tooltip",
2688
- "aria-label": o ? `${u.name} details` : void 0,
2689
- style: {
2690
- left: i,
2691
- top: a
2692
- },
2693
- onKeyDown: (e) => {
2694
- e.key === "Escape" && (e.stopPropagation(), s());
2695
- }
2696
- }, m = o && /* @__PURE__ */ (0, Y.jsx)("button", {
2697
- type: "button",
2698
- className: "fw-icon-button fw-card-close",
2699
- "aria-label": "Close details",
2700
- onClick: s,
2701
- autoFocus: !0,
2702
- children: /* @__PURE__ */ (0, Y.jsx)(zt, {})
2703
- });
2704
- if (l) {
2705
- let e = f ?? t, n = e.span.outcome, i = u.kind === "model" ? "Thinking" : Kt[u.kind], a = u.name && u.name.toLowerCase() !== i.toLowerCase() && u.name.toLowerCase() !== u.kind ? ` ${u.name}` : "", o = Z(u) ? Math.max(u.endMs, r) : u.endMs, s = f && u.endMs > u.startMs ? `${i}${a} · ${Q(o - u.startMs)}${t.ok ? "" : " · failed"}` : void 0, c = !f && u.output && u.output !== e.name ? u.output : void 0;
2706
- return /* @__PURE__ */ (0, Y.jsxs)("div", {
2707
- ...p,
2708
- className: "fw-card fw-card-compact",
2709
- "data-tone": rt(e.tone),
2710
- "data-outcome": n?.tone,
2711
- children: [
2712
- /* @__PURE__ */ (0, Y.jsxs)("div", {
2713
- className: "fw-card-agent",
2714
- children: [
2715
- /* @__PURE__ */ (0, Y.jsx)("span", {
2716
- className: "fw-agent-dot",
2717
- "aria-hidden": !0
2718
- }),
2719
- /* @__PURE__ */ (0, Y.jsx)("span", {
2720
- className: "fw-card-who",
2721
- children: Gt(e.name)
2722
- }),
2723
- n ? /* @__PURE__ */ (0, Y.jsx)("span", {
2724
- className: "fw-pill fw-pill-outcome",
2725
- "data-tone": "0",
2726
- "data-outcome": n.tone,
2727
- children: n.label
2728
- }) : /* @__PURE__ */ (0, Y.jsx)("span", {
2729
- className: `fw-pill fw-pill-${d.toLowerCase()}`,
2730
- children: d
2731
- }),
2732
- m
2733
- ]
2734
- }),
2735
- /* @__PURE__ */ (0, Y.jsx)(Qt, { rows: Zt(e, r, !1) }),
2736
- s && /* @__PURE__ */ (0, Y.jsx)("p", {
2737
- className: "fw-card-step",
2738
- children: s
2739
- }),
2740
- c && /* @__PURE__ */ (0, Y.jsx)("p", {
2741
- className: "fw-card-result",
2742
- children: c
2743
- })
2744
- ]
2745
- });
2746
- }
2747
- return /* @__PURE__ */ (0, Y.jsxs)("div", {
2748
- ...p,
2749
- className: "fw-card",
2750
- "data-tone": rt(t.tone),
2751
- children: [
2752
- f && /* @__PURE__ */ (0, Y.jsxs)("div", {
2753
- className: "fw-card-agent",
2754
- children: [/* @__PURE__ */ (0, Y.jsx)("span", {
2755
- className: "fw-agent-dot",
2756
- "aria-hidden": !0
2757
- }), f.name]
2758
- }),
2759
- /* @__PURE__ */ (0, Y.jsxs)("div", {
2760
- className: "fw-card-head",
2761
- children: [
2762
- /* @__PURE__ */ (0, Y.jsx)("span", {
2763
- className: "fw-icon-tile",
2764
- "aria-hidden": !0,
2765
- children: c?.(u) ?? /* @__PURE__ */ (0, Y.jsx)(jt, {
2766
- kind: u.kind,
2767
- name: u.name
2768
- })
2769
- }),
2770
- /* @__PURE__ */ (0, Y.jsx)("div", {
2771
- className: "fw-card-name",
2772
- children: Gt(u.name)
2773
- }),
2774
- /* @__PURE__ */ (0, Y.jsx)("span", {
2775
- className: `fw-pill fw-pill-${d.toLowerCase()}`,
2776
- children: d
2777
- }),
2778
- m
2779
- ]
2780
- }),
2781
- /* @__PURE__ */ (0, Y.jsx)(Qt, { rows: Zt(t, r, !0) }),
2782
- u.input && /* @__PURE__ */ (0, Y.jsxs)("div", {
2783
- className: "fw-card-text",
2784
- children: [/* @__PURE__ */ (0, Y.jsx)("div", {
2785
- className: "fw-card-label",
2786
- children: "Input"
2787
- }), /* @__PURE__ */ (0, Y.jsx)("p", { children: u.input })]
2788
- }),
2789
- u.output && /* @__PURE__ */ (0, Y.jsxs)("div", {
2790
- className: "fw-card-text",
2791
- children: [/* @__PURE__ */ (0, Y.jsx)("div", {
2792
- className: "fw-card-label",
2793
- children: t.ok ? "Output" : "Error"
2794
- }), /* @__PURE__ */ (0, Y.jsx)("p", { children: u.output })]
2795
- })
2796
- ]
2797
- });
2798
- }
2799
- var en = 0x9184e72a000, tn = (e, t) => ({
2800
- "--s": e,
2801
- "--e": Number.isFinite(t) ? t : en
2802
- }), nn = (e, t, n) => e.length * 7 + 8 + (t ? 80 : 0) + (n ? 90 : 0);
2803
- function rn({ mark: e, events: t, agentView: n, ending: r }) {
2804
- let i = e.kind === "failed" ? n && !r ? null : "fail" : e.retry ? "retry" : null, a = e.kind === "model" || e.modelCall, o = a ? void 0 : e.count === 1 ? e.name : e.tool, s = Number.isFinite(e.endMs) ? Q(e.endMs - e.startMs) : "", c = [s, e.costUsd ? ot(e.costUsd) : ""].filter(Boolean).join(" · ");
2805
- return /* @__PURE__ */ (0, Y.jsxs)("span", {
2806
- className: `fw-seg fw-seg-${e.kind}${e.alt ? " fw-seg-alt" : ""}`,
2807
- "data-tone": rt(e.tone),
2808
- style: tn(e.startMs, e.endMs),
2809
- title: e.name ? `${e.name}${e.count > 1 ? ` +${e.count - 1} more` : ""}${c ? ` · ${c}` : ""}` : void 0,
2810
- onPointerEnter: n ? (n) => t.onInspect(e.id, n.currentTarget, n.clientX) : void 0,
2811
- onClick: n ? (n) => {
2812
- n.stopPropagation(), t.onPin(e.id, n.currentTarget, n.clientX);
2813
- } : void 0,
2814
- children: [i && /* @__PURE__ */ (0, Y.jsx)("span", {
2815
- className: "fw-glyph",
2816
- "data-glyph": i,
2817
- children: i === "fail" ? /* @__PURE__ */ (0, Y.jsx)(Rt, {}) : /* @__PURE__ */ (0, Y.jsx)(Lt, {})
2818
- }), n && /* @__PURE__ */ (0, Y.jsxs)("span", {
2819
- className: "fw-seg-label",
2820
- children: [
2821
- /* @__PURE__ */ (0, Y.jsx)("span", {
2822
- className: "fw-seg-icon",
2823
- "aria-hidden": !0,
2824
- children: /* @__PURE__ */ (0, Y.jsx)(jt, {
2825
- kind: a ? "model" : "tool",
2826
- name: e.tool ?? e.name
2827
- })
2828
- }),
2829
- o && /* @__PURE__ */ (0, Y.jsx)("span", {
2830
- className: "fw-seg-name",
2831
- children: o
2832
- }),
2833
- e.count > 1 && o && /* @__PURE__ */ (0, Y.jsxs)("span", {
2834
- className: "fw-seg-chip",
2835
- children: ["×", e.count]
2836
- }),
2837
- s && /* @__PURE__ */ (0, Y.jsx)("span", {
2838
- className: "fw-seg-meta",
2839
- children: s
2840
- }),
2841
- e.costUsd ? /* @__PURE__ */ (0, Y.jsx)("span", {
2842
- className: "fw-seg-meta",
2843
- children: ot(e.costUsd)
2844
- }) : null
2845
- ]
2846
- })]
2847
- });
2848
- }
2849
- var an = (e, t) => Z(e.span) || e.span.startMs <= t && t < e.span.endMs;
2850
- function on(e, t) {
2851
- let n = e.span;
2852
- if (e.durationLabel === "—") return "—";
2853
- if (e.approx && n.endMs === n.startMs && !Z(n)) return n.costUsd === void 0 ? "" : kt(e, n.costUsd);
2854
- if (!Z(n) && t < n.endMs) return `${Q(Math.max(0, t - n.startMs))}${e.approx ? "~" : ""}`;
2855
- let r = Z(n) ? `${Q(Math.max(n.endMs, t) - n.startMs)}${e.approx ? "~" : ""}` : e.durationLabel, i = n.costUsd ?? (e.rollupCostUsd ? e.rollupCostUsd : void 0);
2856
- return i === void 0 ? r : `${r} · ${kt(e, i)}`;
2857
- }
2858
- var sn = (0, X.memo)(function(e) {
2859
- let { row: t, view: n, top: r, collapsed: i, searching: a, slowest: o, costliest: s, critical: c, matched: l, active: u, focusable: d, selected: f, sticky: p, clockMs: m, renderIcon: h, fillByAgent: g, motion: _ } = e, v = t.span, y = Z(v), b = n === "agents", x = t.hasChildren && i && !a, S = t.durationLabel === "—", C = t.kind === "pipeline", w = t.ok ? t.kind : "failed", T = C || t.hasChildren || t.id.startsWith("run:") ? x && !b ? t.segments : t.own : [], E = on(t, m), D = [...v.detail && v.detail !== e.sharedDetail ? [v.detail] : [], ...Tt(t).filter((t) => t !== e.sharedOutcome)], O = (n) => e.onInspect(t.id, n.currentTarget, n.clientX), k = b && t.id.startsWith("family:"), A = b && t.stepOf !== void 0, j = k || b && C && t.own.length > 0, M = b && !t.ok ? T.map((e) => e.kind).lastIndexOf("failed") : -1;
2860
- return /* @__PURE__ */ (0, Y.jsxs)("div", {
2861
- role: "row",
2862
- "data-span-id": t.id,
2863
- "data-span-kind": w,
2864
- "data-slowest": o || void 0,
2865
- "data-critical": c || void 0,
2866
- "data-search": a ? l ? "match" : "context" : void 0,
2867
- "data-running": y || void 0,
2868
- "aria-level": b ? void 0 : t.depth + 1,
2869
- "aria-expanded": t.hasChildren && !b ? !x : void 0,
2870
- "aria-selected": f,
2871
- tabIndex: d ? 0 : -1,
2872
- "data-tone": rt(t.tone),
2873
- "data-outcome": g ? void 0 : v.outcome?.tone,
2874
- className: `fw-row${u ? " fw-active" : ""}${p ? " fw-sticky-row" : ""}${C ? " fw-agent-row" : ""}${A ? " fw-step" : ""}${_?.enter === void 0 ? "" : " fw-enter"}${_?.settle ? " fw-settle" : ""}`,
2875
- style: {
2876
- "--row-y": `${r}px`,
2877
- "--fw-enter-delay": `${_?.enter ?? 0}ms`,
2878
- "--fw-end-w": `${nn(E, o, s)}px`
2879
- },
2880
- onFocus: (n) => {
2881
- n.target === n.currentTarget && e.onActivate(t);
2882
- },
2883
- onClick: (n) => {
2884
- if (e.onActivate(t), k) {
2885
- e.onToggle(t);
2886
- return;
2887
- }
2888
- let r = b ? n.currentTarget.querySelector(".fw-bar") : null;
2889
- r && e.onPin(t.id, r, n.target instanceof Element && n.target.closest(".fw-lane") ? n.clientX : void 0);
2890
- },
2891
- children: [/* @__PURE__ */ (0, Y.jsxs)("div", {
2892
- role: "gridcell",
2893
- className: "fw-label",
2894
- style: { "--depth": b ? t.inset ?? 0 : t.depth },
2895
- children: [
2896
- j && /* @__PURE__ */ (0, Y.jsx)("button", {
2897
- type: "button",
2898
- tabIndex: -1,
2899
- className: `fw-toggle${e.expanded ? " fw-open" : ""}`,
2900
- "aria-label": `${e.expanded ? "Collapse" : "Expand"} ${t.name}`,
2901
- "aria-expanded": !!e.expanded,
2902
- onClick: (n) => {
2903
- n.stopPropagation(), e.onToggle(t);
2904
- },
2905
- children: /* @__PURE__ */ (0, Y.jsx)(Mt, {})
2906
- }),
2907
- !b && /* @__PURE__ */ (0, Y.jsx)("span", {
2908
- className: "fw-guides",
2909
- "aria-hidden": !0
2910
- }),
2911
- !b && (t.hasChildren ? /* @__PURE__ */ (0, Y.jsx)("button", {
2912
- type: "button",
2913
- tabIndex: -1,
2914
- className: `fw-toggle${x ? "" : " fw-open"}`,
2915
- disabled: a,
2916
- "aria-label": `${x ? "Expand" : "Collapse"} ${t.name}`,
2917
- "aria-expanded": !x,
2918
- onClick: (n) => {
2919
- n.stopPropagation(), e.onToggle(t);
2920
- },
2921
- children: /* @__PURE__ */ (0, Y.jsx)(Mt, {})
2922
- }) : /* @__PURE__ */ (0, Y.jsx)("span", {
2923
- className: "fw-toggle-space",
2924
- "aria-hidden": !0
2925
- })),
2926
- b && !j && /* @__PURE__ */ (0, Y.jsx)("span", {
2927
- className: "fw-toggle-space",
2928
- "aria-hidden": !0
2929
- }),
2930
- (!b || A) && /* @__PURE__ */ (0, Y.jsx)("span", {
2931
- className: "fw-icon-tile",
2932
- "aria-hidden": !0,
2933
- children: h?.(v) ?? /* @__PURE__ */ (0, Y.jsx)(jt, {
2934
- kind: v.kind,
2935
- name: v.name
2936
- })
2937
- }),
2938
- /* @__PURE__ */ (0, Y.jsxs)("span", {
2939
- className: "fw-names",
2940
- title: `${t.name}${v.detail ? ` · ${v.detail}` : ""} · ${Kt[v.kind]}${y ? " · running" : ""}${t.ok ? "" : " · failed"}`,
2941
- children: [/* @__PURE__ */ (0, Y.jsxs)("span", {
2942
- className: `fw-span-name${C || t.hasChildren ? " fw-strong" : ""}`,
2943
- children: [
2944
- g && C && v.outcome ? /* @__PURE__ */ (0, Y.jsx)("span", {
2945
- className: "fw-agent-dot",
2946
- "data-tone": "0",
2947
- "data-outcome": v.outcome.tone,
2948
- title: v.outcome.label,
2949
- "aria-hidden": !0
2950
- }) : b && !A && /* @__PURE__ */ (0, Y.jsx)("span", {
2951
- className: "fw-agent-dot",
2952
- "aria-hidden": !0
2953
- }),
2954
- y && /* @__PURE__ */ (0, Y.jsx)("span", {
2955
- className: "fw-spinner",
2956
- role: "status",
2957
- "aria-label": "running"
2958
- }),
2959
- /* @__PURE__ */ (0, Y.jsx)("span", {
2960
- className: "fw-name-text",
2961
- children: t.name
2962
- })
2963
- ]
2964
- }), b && /* @__PURE__ */ (0, Y.jsxs)("span", {
2965
- className: "fw-subtitle",
2966
- children: [h && /* @__PURE__ */ (0, Y.jsx)("span", {
2967
- className: "fw-detail-icon",
2968
- "aria-hidden": !0,
2969
- children: h(v)
2970
- }), /* @__PURE__ */ (0, Y.jsxs)("span", {
2971
- className: "fw-subtitle-tail",
2972
- children: [/* @__PURE__ */ (0, Y.jsx)("span", {
2973
- className: "fw-subtitle-text",
2974
- children: D[0]
2975
- }), D.slice(1).map((e) => /* @__PURE__ */ (0, Y.jsxs)("span", {
2976
- className: "fw-subtitle-extra",
2977
- children: ["· ", e]
2978
- }, e))]
2979
- })]
2980
- })]
2981
- }),
2982
- x && /* @__PURE__ */ (0, Y.jsxs)("span", {
2983
- className: "fw-count",
2984
- "aria-label": `${t.descendants} hidden steps`,
2985
- children: ["+", t.descendants]
2986
- }),
2987
- !t.ok && !b && /* @__PURE__ */ (0, Y.jsx)("span", {
2988
- className: "fw-alert",
2989
- children: /* @__PURE__ */ (0, Y.jsx)(Vt, { label: "failed" })
2990
- })
2991
- ]
2992
- }), /* @__PURE__ */ (0, Y.jsx)("div", {
2993
- role: "gridcell",
2994
- className: "fw-lane",
2995
- "data-waterfall-track": !0,
2996
- "aria-label": `${Kt[v.kind]}, ${E}${o ? `, slowest ${b ? "agent" : "step"}` : ""}${s ? ", costliest agent" : ""}${c ? ", critical path" : ""}`,
2997
- children: S ? /* @__PURE__ */ (0, Y.jsx)("span", {
2998
- className: "fw-invalid",
2999
- children: "—"
3000
- }) : /* @__PURE__ */ (0, Y.jsxs)(Y.Fragment, { children: [
3001
- v.marks?.map((e) => /* @__PURE__ */ (0, Y.jsx)("span", {
3002
- className: "fw-mark",
3003
- "data-mark": e.kind,
3004
- style: tn(e.at, e.at),
3005
- title: e.label,
3006
- "aria-label": e.label,
3007
- role: "img"
3008
- }, `m-${e.at}-${e.label}`)),
3009
- /* @__PURE__ */ (0, Y.jsxs)("span", {
3010
- className: `fw-bar fw-k-${C ? "pipeline" : w}${t.approx ? " fw-approx" : ""}${T.length ? " fw-has-marks" : ""}${t.hasAgents ? " fw-has-agents" : ""}`,
3011
- "data-tone": rt(t.tone),
3012
- style: tn(v.startMs, y ? en : v.endMs),
3013
- onPointerEnter: O,
3014
- onPointerLeave: e.onLeave,
3015
- onClick: (n) => {
3016
- n.stopPropagation(), k ? e.onToggle(t) : e.onPin(t.id, n.currentTarget, n.clientX);
3017
- },
3018
- children: [!C && !t.ok && /* @__PURE__ */ (0, Y.jsx)("span", {
3019
- className: "fw-glyph",
3020
- children: /* @__PURE__ */ (0, Y.jsx)(Rt, {})
3021
- }), !C && t.ok && t.retry && /* @__PURE__ */ (0, Y.jsx)("span", {
3022
- className: "fw-glyph",
3023
- children: /* @__PURE__ */ (0, Y.jsx)(Lt, {})
3024
- })]
3025
- }),
3026
- T.map((t, n) => /* @__PURE__ */ (0, Y.jsx)(rn, {
3027
- mark: t,
3028
- events: e,
3029
- agentView: b,
3030
- ending: n === M
3031
- }, `${t.id}-${n}`)),
3032
- /* @__PURE__ */ (0, Y.jsxs)("span", {
3033
- className: "fw-end",
3034
- style: tn(v.startMs, y ? en : v.endMs),
3035
- children: [
3036
- /* @__PURE__ */ (0, Y.jsx)("span", {
3037
- className: "fw-duration",
3038
- children: E
3039
- }),
3040
- o && /* @__PURE__ */ (0, Y.jsx)("span", {
3041
- className: "fw-badge",
3042
- children: "Slowest"
3043
- }),
3044
- s && /* @__PURE__ */ (0, Y.jsx)("span", {
3045
- className: "fw-badge",
3046
- children: "Costliest"
3047
- })
3048
- ]
3049
- })
3050
- ] })
3051
- })]
3052
- });
3053
- }, (e, t) => e.row === t.row && e.view === t.view && e.top === t.top && e.collapsed === t.collapsed && e.searching === t.searching && e.slowest === t.slowest && e.costliest === t.costliest && e.critical === t.critical && e.matched === t.matched && e.active === t.active && e.focusable === t.focusable && e.selected === t.selected && e.sticky === t.sticky && e.motion === t.motion && e.renderIcon === t.renderIcon && e.fillByAgent === t.fillByAgent && e.sharedDetail === t.sharedDetail && e.sharedOutcome === t.sharedOutcome && e.expanded === t.expanded && (e.clockMs === t.clockMs || !an(e.row, e.clockMs) && !an(t.row, t.clockMs)));
3054
- function cn({ link: e, rowHeight: t, hot: n, short: r }) {
3055
- let i = Math.max(e.from, e.to), a = r ? Math.max(Math.min(e.from, e.to), i - 1) : Math.min(e.from, e.to), o = {
3056
- ...tn(e.atMs, e.atMs),
3057
- top: a * t + t / 2 + 5,
3058
- height: (i - a) * t - 5
3059
- };
3060
- return /* @__PURE__ */ (0, Y.jsx)("span", {
3061
- className: `fw-link fw-link-${e.dir}${n ? " fw-link-hot" : ""}`,
3062
- "data-tone": rt(e.tone),
3063
- style: o,
3064
- "aria-hidden": !0
3065
- });
3066
- }
3067
- var ln = 700, un = 20, dn = 200;
3068
- function fn(e) {
3069
- let t = (0, X.useRef)(null), n = (0, X.useRef)(/* @__PURE__ */ new Set()), r = (0, X.useRef)(/* @__PURE__ */ new Map()), [i, a] = (0, X.useState)(0), o = (0, X.useMemo)(() => {
3070
- let i = Date.now();
3071
- for (let [e, t] of r.current) t.until <= i && r.current.delete(e);
3072
- let a = t.current, o = 0;
3073
- for (let t of e) {
3074
- let e = Z(t.span);
3075
- !a || !a.has(t.id) ? r.current.set(t.id, {
3076
- enter: Math.min(o++ * un, dn),
3077
- until: i + ln + dn
3078
- }) : n.current.has(t.id) && !e && r.current.set(t.id, {
3079
- settle: !0,
3080
- until: i + ln
3081
- });
3082
- }
3083
- return t.current = new Set(e.map((e) => e.id)), n.current = new Set(e.filter((e) => Z(e.span)).map((e) => e.id)), new Map(r.current);
3084
- }, [e, i]);
3085
- return (0, X.useEffect)(() => {
3086
- if (o.size === 0) return;
3087
- let e = setTimeout(() => a((e) => e + 1), 920);
3088
- return () => clearTimeout(e);
3089
- }, [o]), o;
3090
- }
3091
- var pn = [
3092
- 1,
3093
- 2,
3094
- 5,
3095
- 10,
3096
- 20,
3097
- 50,
3098
- 100,
3099
- 200,
3100
- 500,
3101
- 1e3,
3102
- 2e3,
3103
- 5e3,
3104
- 1e4,
3105
- 15e3,
3106
- 3e4,
3107
- 6e4,
3108
- 12e4,
3109
- 3e5,
3110
- 6e5,
3111
- 9e5,
3112
- 18e5,
3113
- 36e5,
3114
- 72e5,
3115
- 108e5,
3116
- 216e5,
3117
- 432e5,
3118
- 864e5
3119
- ];
3120
- function mn(e, t = 72) {
3121
- let n = e * t;
3122
- return pn.find((e) => e >= n) ?? Math.ceil(n / 864e5) * 864e5;
3123
- }
3124
- function hn(e, t, n, r = 72) {
3125
- if (!(n > 0) || !(t > e)) return [0];
3126
- let i = mn((t - e) / n, r), a = [];
3127
- for (let n = Math.ceil(e / i) * i; n <= t && a.length < 400; n += i) a.push(n);
3128
- return a;
3129
- }
3130
- function gn(e) {
3131
- if (e === 0) return "0s";
3132
- if (e < 1e3) return `${Math.round(e)}ms`;
3133
- if (e < 6e4) return `${+(e / 1e3).toFixed(1)}s`;
3134
- if (e < 36e5) {
3135
- let t = Math.floor(e / 6e4), n = Math.round(e % 6e4 / 1e3);
3136
- return n ? `${t}m ${n}s` : `${t}m`;
3137
- }
3138
- let t = Math.floor(e / 36e5), n = Math.round(e % 36e5 / 6e4);
3139
- return n ? `${t}h ${n}m` : `${t}h`;
3140
- }
3141
- function _n(e, t, n, r) {
3142
- let i = e.endMs - e.startMs, a = Math.min(Math.max(50, i * t), Math.max(r, 50)), o = i > 0 ? (n - e.startMs) / i : .5;
3143
- return vn({
3144
- startMs: n - o * a,
3145
- endMs: n - o * a + a
3146
- }, r);
3147
- }
3148
- function vn(e, t) {
3149
- let n = e.endMs - e.startMs, r = Math.max(0, e.startMs);
3150
- return r + n > t && (r = Math.max(0, t - n)), {
3151
- startMs: r,
3152
- endMs: r + n
3153
- };
3154
- }
3155
- var yn = {
3156
- spans: 36,
3157
- agents: 40
3158
- }, bn = 8, xn = 4, Sn = 3;
3159
- function Cn(e, t, n) {
3160
- let r = new Map(e.map((e, t) => [e.id, t])), i = (i) => {
3161
- let a = i.parentId;
3162
- for (; a !== void 0;) {
3163
- let i = r.get(a);
3164
- if (i !== void 0 && (n === "spans" || e[i].kind === "pipeline")) return i;
3165
- a = t.get(a)?.parentId;
3166
- }
3167
- }, a = [], o = /* @__PURE__ */ new Set();
3168
- for (let t of e) {
3169
- let n = t.span.handoffTo === void 0 ? void 0 : r.get(t.span.handoffTo), s = t.kind === "pipeline" ? r.get(t.id) : i(t);
3170
- n !== void 0 && s !== void 0 && n !== s && (o.add(e[n].id), a.push({
3171
- id: `h-${t.id}`,
3172
- from: s,
3173
- to: n,
3174
- atMs: t.span.startMs,
3175
- tone: e[n].tone,
3176
- dir: n > s ? "down" : "up"
3177
- }));
3178
- }
3179
- for (let [t, r] of e.entries()) {
3180
- if (r.kind !== "pipeline" || r.parentId === void 0) continue;
3181
- let e = i(r);
3182
- e !== void 0 && (o.has(r.id) || a.push({
3183
- id: `s-${r.id}`,
3184
- from: e,
3185
- to: t,
3186
- atMs: r.span.startMs,
3187
- tone: r.tone,
3188
- dir: "down"
3189
- }), n === "agents" && !Z(r.span) && Number.isFinite(r.span.endMs) && a.push({
3190
- id: `r-${r.id}`,
3191
- from: t,
3192
- to: e,
3193
- atMs: r.span.endMs,
3194
- tone: r.tone,
3195
- dir: "up"
3196
- }));
3197
- }
3198
- return a;
3199
- }
3200
- function wn(e) {
3201
- let { rows: t, view: n, maxHeight: r, collapsed: i, searching: a, slowestId: o, activeId: s, selectedId: c, clockMs: l, window: u, trackPx: d, showCursor: f, zoomed: p } = e, m = yn[n], h = (0, X.useRef)(null), g = (0, X.useRef)(null), [_, v] = (0, X.useState)(0), [y, b] = (0, X.useState)(r), x = (0, X.useRef)(e);
3202
- x.current = e;
3203
- let S = (0, X.useRef)(0);
3204
- e.holdHeight || (S.current = 0);
3205
- let C = S.current = Math.max(S.current, Math.min(r, Math.max(t.length, 1) * m)), w = (0, X.useMemo)(() => Cn(t, e.byId, n), [
3206
- t,
3207
- e.byId,
3208
- n
3209
- ]), T = (0, X.useMemo)(() => a ? mt(t, e.query, e.matchSpan) : void 0, [
3210
- a,
3211
- t,
3212
- e.query,
3213
- e.matchSpan
3214
- ]), E = (0, X.useMemo)(() => new Map(t.map((e, t) => [e.id, t])), [t]), D = fn(t), [O, k] = (0, X.useState)(), A = (u.endMs - u.startMs) / Math.max(1, d), j = u.startMs + (d + (n === "spans" ? 72 : 0)) * A, M = hn(u.startMs, j, Math.max(1, d + (n === "spans" ? 72 : 0))), N = (0, X.useMemo)(() => {
3215
- let t = /* @__PURE__ */ new Map();
3216
- if (n === "agents") return t;
3217
- let r = -Infinity;
3218
- for (let n of [...e.markers ?? []].sort((e, t) => e.at - t.at)) {
3219
- let e = (n.at - u.startMs) / A, i = n.label.length * 7 + 16, a = e + i > d ? "left" : "right", o = a === "right" ? e : e - i;
3220
- e < 0 || e > d || o < r || (t.set(n, a), r = o + i + 8);
3221
- }
3222
- return t;
3223
- }, [
3224
- e.markers,
3225
- u.startMs,
3226
- A,
3227
- d,
3228
- n
3229
- ]);
3230
- (0, X.useEffect)(() => {
3231
- let e = h.current;
3232
- if (!e) return;
3233
- let t = new ResizeObserver(() => b(e.clientHeight));
3234
- return t.observe(e), () => t.disconnect();
3235
- }, []), (0, X.useEffect)(() => {
3236
- let e = g.current;
3237
- if (!e) return;
3238
- let t = (t) => {
3239
- let { window: n, trackPx: r, zoomed: i } = x.current, a = e.querySelector("[data-fw-track]");
3240
- if (!a) return;
3241
- let o = a.getBoundingClientRect(), s = (n.endMs - n.startMs) / Math.max(1, r);
3242
- if (t.ctrlKey || t.metaKey) {
3243
- t.preventDefault();
3244
- let e = n.startMs + (t.clientX - o.left - 12) * s;
3245
- x.current.onZoom(Math.exp(t.deltaY * .0025), e);
3246
- } else i && (t.shiftKey || Math.abs(t.deltaX) > Math.abs(t.deltaY)) && (t.preventDefault(), x.current.onPan((t.shiftKey ? t.deltaY : t.deltaX) * s));
3247
- };
3248
- return e.addEventListener("wheel", t, { passive: !1 }), () => e.removeEventListener("wheel", t);
3249
- }, []);
3250
- let F = Math.max(0, _ * xn - bn), I = Math.min(t.length, _ * xn + Math.ceil(y / m) + xn + bn), L = (e, r) => {
3251
- let i = (n === "spans" ? Math.min(Sn, t[e].depth) : 0) * m;
3252
- e * m - i < r.scrollTop ? r.scrollTop = Math.max(0, e * m - i) : (e + 1) * m > r.scrollTop + r.clientHeight && (r.scrollTop = (e + 1) * m - r.clientHeight);
3253
- }, ee = (0, X.useRef)(void 0);
3254
- (0, X.useEffect)(() => {
3255
- if (!c || c === ee.current) return;
3256
- let e = E.get(c);
3257
- e !== void 0 && h.current && (ee.current = c, L(e, h.current));
3258
- });
3259
- let R = (t) => {
3260
- let n = E.get(t), r = h.current;
3261
- n !== void 0 && r && (L(n, r), e.onActiveChange(t), requestAnimationFrame(() => r.querySelector(`.fw-canvas [data-span-id="${CSS.escape(t)}"]`)?.focus({ preventScroll: !0 })));
3262
- }, z = (r) => {
3263
- let o = E.get(s ?? "") ?? 0, c = t[o];
3264
- if (!c) return;
3265
- let l = Math.max(1, Math.floor(y / m) - 1), u = (e) => {
3266
- r.preventDefault(), R(t[Math.max(0, Math.min(t.length - 1, e))].id);
3267
- }, d = i.has(c.id) && !a;
3268
- switch (r.key) {
3269
- case "ArrowDown": return u(o + 1);
3270
- case "ArrowUp": return u(o - 1);
3271
- case "PageDown": return u(o + l);
3272
- case "PageUp": return u(o - l);
3273
- case "Home": return u(0);
3274
- case "End": return u(t.length - 1);
3275
- case "ArrowRight":
3276
- n === "spans" && c.hasChildren && d || n === "agents" && c.hasChildren ? (r.preventDefault(), e.onToggle(c)) : c.hasChildren && u(o + 1);
3277
- return;
3278
- case "ArrowLeft":
3279
- n === "spans" && c.hasChildren && !d ? (r.preventDefault(), e.onToggle(c)) : c.parentId !== void 0 && E.has(c.parentId) && u(E.get(c.parentId));
3280
- return;
3281
- case "Enter":
3282
- case " ": {
3283
- r.preventDefault();
3284
- let t = h.current?.querySelector(`[data-span-id="${CSS.escape(c.id)}"] .fw-bar`);
3285
- t && e.onPin(c.id, t);
3286
- }
3287
- }
3288
- }, B = /* @__PURE__ */ (0, Y.jsxs)("div", {
3289
- className: "fw-axis fw-axis-top",
3290
- children: [/* @__PURE__ */ (0, Y.jsxs)("div", {
3291
- className: "fw-axis-label",
3292
- children: [n === "spans" && /* @__PURE__ */ (0, Y.jsx)(Y.Fragment, { children: e.onExpandAll && /* @__PURE__ */ (0, Y.jsxs)("span", {
3293
- className: "fw-branch-controls",
3294
- children: [/* @__PURE__ */ (0, Y.jsx)("button", {
3295
- type: "button",
3296
- className: "fw-text-button",
3297
- onClick: e.onExpandAll,
3298
- children: "Expand all"
3299
- }), /* @__PURE__ */ (0, Y.jsx)("button", {
3300
- type: "button",
3301
- className: "fw-text-button",
3302
- onClick: e.onCollapseAll,
3303
- children: "Collapse all"
3304
- })]
3305
- }) }), /* @__PURE__ */ (0, Y.jsx)("span", {
3306
- role: "separator",
3307
- "aria-orientation": "vertical",
3308
- "aria-label": "Resize the step column",
3309
- tabIndex: 0,
3310
- className: "fw-resize",
3311
- "aria-valuenow": Math.round(e.nameWidth),
3312
- "aria-valuemin": 140,
3313
- "aria-valuemax": 560,
3314
- onPointerDown: (t) => {
3315
- let n = t.currentTarget, r = t.clientX, i = e.nameWidth;
3316
- n.setPointerCapture(t.pointerId);
3317
- let a = (t) => e.onNameWidth(i + t.clientX - r), o = () => {
3318
- n.removeEventListener("pointermove", a), n.removeEventListener("pointerup", o);
3319
- };
3320
- n.addEventListener("pointermove", a), n.addEventListener("pointerup", o);
3321
- },
3322
- onKeyDown: (t) => {
3323
- (t.key === "ArrowLeft" || t.key === "ArrowRight") && (t.preventDefault(), e.onNameWidth(e.nameWidth + (t.key === "ArrowLeft" ? -16 : 16)));
3324
- }
3325
- })]
3326
- }), /* @__PURE__ */ (0, Y.jsxs)("div", {
3327
- className: "fw-axis-track",
3328
- "data-fw-track": !0,
3329
- ref: e.onTrack,
3330
- onPointerDown: (t) => {
3331
- let n = t.currentTarget, r = n.getBoundingClientRect(), i = (e) => Math.max(0, u.startMs + (e - r.left - 12) * (u.endMs - u.startMs) / Math.max(1, d));
3332
- e.onScrub(i(t.clientX)), n.setPointerCapture(t.pointerId);
3333
- let a = (t) => e.onScrub(i(t.clientX)), o = () => {
3334
- n.removeEventListener("pointermove", a), n.removeEventListener("pointerup", o);
3335
- };
3336
- n.addEventListener("pointermove", a), n.addEventListener("pointerup", o);
3337
- },
3338
- title: "Drag to scrub",
3339
- children: [
3340
- M.map((e) => /* @__PURE__ */ (0, Y.jsx)("span", {
3341
- className: "fw-tick",
3342
- style: { "--s": e },
3343
- children: gn(e)
3344
- }, e)),
3345
- e.markers?.map((t) => /* @__PURE__ */ (0, Y.jsx)("button", {
3346
- type: "button",
3347
- className: "fw-event",
3348
- "data-tone": t.tone ?? "neutral",
3349
- style: { "--s": t.at },
3350
- title: t.kind ? `${t.kind}: ${t.label}` : t.label,
3351
- "aria-label": `Jump to ${t.kind ? `${t.kind} ` : ""}${t.label}`,
3352
- "aria-pressed": O === t,
3353
- onPointerDown: (e) => e.stopPropagation(),
3354
- onClick: () => {
3355
- if (O === t) {
3356
- k(void 0);
3357
- return;
3358
- }
3359
- k(t), e.onScrub(t.at);
3360
- }
3361
- }, `e-${t.at}-${t.label}`)),
3362
- e.pauses?.map((e) => {
3363
- let t = `${e.label} ${P(e.endMs - e.startMs)}${e.detail ? `: ${e.detail}` : ""}`;
3364
- return /* @__PURE__ */ (0, Y.jsx)("span", {
3365
- className: "fw-pause-mark",
3366
- style: {
3367
- "--s": e.startMs,
3368
- "--e": e.endMs
3369
- },
3370
- title: t,
3371
- "aria-label": t,
3372
- role: "img",
3373
- tabIndex: 0,
3374
- onPointerDown: (e) => e.stopPropagation()
3375
- }, `pm-${e.startMs}`);
3376
- }),
3377
- O && /* @__PURE__ */ (0, Y.jsx)("span", {
3378
- className: "fw-event-label",
3379
- "data-tone": O.tone ?? "neutral",
3380
- style: { "--s": O.at },
3381
- children: O.label
3382
- }),
3383
- f && /* @__PURE__ */ (0, Y.jsx)("span", {
3384
- className: "fw-cursor-handle",
3385
- "aria-hidden": !0
3386
- })
3387
- ]
3388
- })]
3389
- }), V = (t, r, u = !1) => /* @__PURE__ */ (0, Y.jsx)(sn, {
3390
- row: t,
3391
- view: n,
3392
- top: r * m,
3393
- collapsed: i.has(t.id),
3394
- searching: a,
3395
- slowest: t.id === o,
3396
- costliest: t.id === e.costliestId,
3397
- critical: e.criticalIds?.has(t.id),
3398
- matched: T?.has(t.id),
3399
- active: t.id === s,
3400
- focusable: !u && (t.id === s || (s === void 0 || !E.has(s)) && r === 0),
3401
- selected: t.id === c,
3402
- sticky: u,
3403
- motion: u ? void 0 : D.get(t.id),
3404
- clockMs: l,
3405
- renderIcon: e.renderIcon,
3406
- fillByAgent: e.fillByAgent,
3407
- sharedDetail: e.sharedDetail,
3408
- sharedOutcome: e.sharedOutcome,
3409
- expanded: e.expandedIds?.has(t.id),
3410
- onToggle: e.onToggle,
3411
- onInspect: e.onInspect,
3412
- onLeave: e.onLeave,
3413
- onPin: e.onPin,
3414
- onActivate: (t) => e.onActiveChange(t.id)
3415
- }, u ? `sticky-${t.id}` : t.id);
3416
- return /* @__PURE__ */ (0, Y.jsxs)("div", {
3417
- className: `fw-body fw-view-${n}${p ? " fw-zoomed" : ""}`,
3418
- ref: g,
3419
- children: [B, /* @__PURE__ */ (0, Y.jsxs)("div", {
3420
- className: "fw-viewport",
3421
- children: [
3422
- /* @__PURE__ */ (0, Y.jsxs)("div", {
3423
- className: "fw-gridlayer",
3424
- "aria-hidden": !0,
3425
- children: [
3426
- e.pauses?.map((e) => /* @__PURE__ */ (0, Y.jsx)("span", {
3427
- className: "fw-pause",
3428
- style: {
3429
- "--s": e.startMs,
3430
- "--e": e.endMs
3431
- }
3432
- }, `p-${e.startMs}`)),
3433
- M.map((e) => /* @__PURE__ */ (0, Y.jsx)("span", {
3434
- className: "fw-gridline",
3435
- style: { "--s": e }
3436
- }, e)),
3437
- e.markers?.map((e) => /* @__PURE__ */ (0, Y.jsx)("span", {
3438
- className: "fw-marker-line",
3439
- "data-tone": e.tone ?? "neutral",
3440
- style: { "--s": e.at }
3441
- }, `l-${e.at}-${e.label}`))
3442
- ]
3443
- }),
3444
- /* @__PURE__ */ (0, Y.jsxs)("div", {
3445
- ref: h,
3446
- role: "treegrid",
3447
- "aria-label": "Trace timeline",
3448
- "aria-rowcount": t.length,
3449
- "aria-multiselectable": !1,
3450
- tabIndex: -1,
3451
- className: "fw-scroller",
3452
- "data-primary-content": "",
3453
- style: {
3454
- height: C,
3455
- maxHeight: r
3456
- },
3457
- onKeyDown: z,
3458
- onScroll: (e) => {
3459
- let t = Math.floor(e.currentTarget.scrollTop / m / xn);
3460
- t !== _ && v(t);
3461
- },
3462
- children: [/* @__PURE__ */ (0, Y.jsxs)("div", {
3463
- className: "fw-canvas",
3464
- style: { height: t.length * m },
3465
- children: [/* @__PURE__ */ (0, Y.jsx)("div", {
3466
- className: "fw-links",
3467
- "aria-hidden": !0,
3468
- children: w.filter((e) => Math.max(e.from, e.to) >= F && Math.min(e.from, e.to) <= I).map((r) => {
3469
- let i = e.focusId !== void 0 && (t[r.from]?.id === e.focusId || t[r.to]?.id === e.focusId);
3470
- return n === "agents" && !i && r.id.startsWith("r-") ? null : /* @__PURE__ */ (0, Y.jsx)(cn, {
3471
- link: r,
3472
- rowHeight: m,
3473
- hot: i,
3474
- short: n === "agents" && !i
3475
- }, r.id);
3476
- })
3477
- }), t.slice(F, I).map((e, t) => V(e, F + t))]
3478
- }), t.length === 0 && /* @__PURE__ */ (0, Y.jsx)("p", {
3479
- role: "status",
3480
- className: "fw-empty",
3481
- children: e.emptyText
3482
- })]
3483
- }),
3484
- n === "spans" && /* @__PURE__ */ (0, Y.jsx)(Tn, {
3485
- scroller: h,
3486
- rows: t,
3487
- index: E,
3488
- rowHeight: m,
3489
- render: V
3490
- }),
3491
- e.markers?.length ? /* @__PURE__ */ (0, Y.jsx)("div", {
3492
- className: "fw-marker-layer",
3493
- children: e.markers.map((e) => /* @__PURE__ */ (0, Y.jsx)("span", {
3494
- className: "fw-marker",
3495
- "data-tone": e.tone ?? "neutral",
3496
- style: { "--s": e.at },
3497
- title: e.label,
3498
- children: N.has(e) && /* @__PURE__ */ (0, Y.jsx)("span", {
3499
- className: `fw-marker-label${N.get(e) === "left" ? " fw-marker-label-left" : ""}`,
3500
- children: e.label
3501
- })
3502
- }, `${e.at}-${e.label}`))
3503
- }) : null,
3504
- f && e.cursorLine !== !1 && /* @__PURE__ */ (0, Y.jsx)("div", {
3505
- className: "fw-cursor-layer",
3506
- "aria-hidden": !0,
3507
- children: /* @__PURE__ */ (0, Y.jsx)("span", { className: "fw-cursor" })
3508
- })
3509
- ]
3510
- })]
3511
- });
3512
- }
3513
- function Tn({ scroller: e, rows: t, index: n, rowHeight: r, render: i }) {
3514
- let [a, o] = (0, X.useState)(0);
3515
- (0, X.useEffect)(() => {
3516
- let t = e.current;
3517
- if (!t) return;
3518
- let n = () => o(t.scrollTop > 0 ? Math.floor(t.scrollTop / r) : -1);
3519
- return n(), t.addEventListener("scroll", n, { passive: !0 }), () => t.removeEventListener("scroll", n);
3520
- }, [e, r]);
3521
- let s = [];
3522
- if (a >= 0) {
3523
- let e = [], r = t[Math.min(t.length - 1, a + 1)];
3524
- for (; r?.parentId !== void 0;) {
3525
- let i = n.get(r.parentId);
3526
- if (i === void 0) break;
3527
- r = t[i], r && e.unshift(r);
3528
- }
3529
- for (let [t, r] of e.slice(-3).entries()) (n.get(r.id) ?? 0) < a + t + 1 && s.push(r);
3530
- }
3531
- return s.length ? /* @__PURE__ */ (0, Y.jsx)("div", {
3532
- className: "fw-sticky",
3533
- style: { height: s.length * r },
3534
- children: s.map((e, t) => i(e, t, !0))
3535
- }) : null;
3536
- }
3537
- var En = 100;
3538
- function Dn(e) {
3539
- let { root: t, slider: n, timeOutput: r, observedTotal: i, live: a, startedAt: o, snapshot: s, playing: c, speed: l, position: u, onPlaybackEnd: d, view: f, trackPx: p } = e, [m, h] = (0, X.useState)(u ?? i), g = (0, X.useRef)(Date.now()), _ = (0, X.useRef)(u ?? i), v = (0, X.useRef)(e);
3540
- v.current = e, (0, X.useEffect)(() => {
3541
- g.current = Date.now();
3542
- }, [s]);
3543
- let y = () => {
3544
- let { observedTotal: e, startedAt: t, live: n } = v.current;
3545
- return n ? Math.max(e, t === void 0 ? e + Date.now() - g.current : Date.now() - t) : e;
3546
- }, b = (e, i = y()) => {
3547
- let a = t.current;
3548
- if (!a) return;
3549
- let { startMs: o, endMs: s } = v.current.view(e), c = Math.max(1e-9, v.current.trackPx / Math.max(1, s - o));
3550
- a.style.setProperty("--fw-t", String(e)), a.style.setProperty("--fw-v0", String(o)), a.style.setProperty("--fw-k", String(c)), n.current && (n.current.max = String(Math.max(1, i, e)), n.current.value = String(e)), r.current && (r.current.textContent = Q(e));
3551
- };
3552
- return (0, X.useLayoutEffect)(() => {
3553
- if (u !== null && (_.current = u), !(a || c)) {
3554
- let e = u ?? i;
3555
- b(e), h(e);
3556
- return;
3557
- }
3558
- let e = 0, t = performance.now(), n = 0, r = (i) => {
3559
- let a = i - t;
3560
- t = i;
3561
- let o, s = y();
3562
- if (c) {
3563
- if (_.current = Math.min(s, _.current + a * v.current.speed), o = _.current, o >= s && !v.current.live) {
3564
- b(o, s), h(o), v.current.onPlaybackEnd(o);
3565
- return;
3566
- }
3567
- } else o = v.current.position ?? s;
3568
- b(o, s), i - n >= En && (n = i, h(o)), e = requestAnimationFrame(r);
3569
- };
3570
- return e = requestAnimationFrame(r), () => cancelAnimationFrame(e);
3571
- }, [
3572
- a,
3573
- c,
3574
- u,
3575
- i,
3576
- s
3577
- ]), (0, X.useLayoutEffect)(() => {
3578
- b(c ? _.current : u ?? (a ? y() : i));
3579
- }, [f, p]), {
3580
- clockMs: m,
3581
- limitMs: y,
3582
- positionMs: () => _.current
3583
- };
3584
- }
3585
- var On = [
3586
- .5,
3587
- 1,
3588
- 1.5,
3589
- 2,
3590
- 4
3591
- ];
3592
- function kn({ view: e, playing: t, limit: n, clockMs: r, speed: i, zoom: a, marks: o, slider: s, timeOutput: c, followLabel: l, onTogglePlay: u, onRestart: d, onSpeed: f, onScrub: p, onFollow: m, onZoom: h, onFit: g }) {
3593
- return /* @__PURE__ */ (0, Y.jsxs)("footer", {
3594
- className: "fw-playback",
3595
- children: [
3596
- /* @__PURE__ */ (0, Y.jsx)("button", {
3597
- type: "button",
3598
- className: "fw-round-button",
3599
- "aria-label": t ? "Pause" : "Play",
3600
- disabled: n === 0,
3601
- onClick: u,
3602
- children: t ? /* @__PURE__ */ (0, Y.jsx)(Ft, {}) : /* @__PURE__ */ (0, Y.jsx)(Pt, {})
3603
- }),
3604
- /* @__PURE__ */ (0, Y.jsx)("button", {
3605
- type: "button",
3606
- className: "fw-icon-button",
3607
- "aria-label": "Restart",
3608
- title: "Replay from the start",
3609
- disabled: n === 0,
3610
- onClick: d,
3611
- children: /* @__PURE__ */ (0, Y.jsx)(It, {})
3612
- }),
3613
- e === "agents" ? /* @__PURE__ */ (0, Y.jsx)("div", {
3614
- className: "fw-segmented",
3615
- role: "radiogroup",
3616
- "aria-label": "Playback speed",
3617
- children: [
3618
- 1,
3619
- 2,
3620
- 4
3621
- ].map((e) => /* @__PURE__ */ (0, Y.jsxs)("button", {
3622
- type: "button",
3623
- role: "radio",
3624
- "aria-checked": i === e,
3625
- onClick: () => f(e),
3626
- children: [e, "x"]
3627
- }, e))
3628
- }) : /* @__PURE__ */ (0, Y.jsxs)("label", {
3629
- className: "fw-speed",
3630
- children: [/* @__PURE__ */ (0, Y.jsx)("span", {
3631
- className: "fw-sr-only",
3632
- children: "Playback speed"
3633
- }), /* @__PURE__ */ (0, Y.jsx)("select", {
3634
- "aria-label": "Playback speed",
3635
- value: i,
3636
- onChange: (e) => f(Number(e.target.value)),
3637
- children: On.map((e) => /* @__PURE__ */ (0, Y.jsxs)("option", {
3638
- value: e,
3639
- children: [e, "x"]
3640
- }, e))
3641
- })]
3642
- }),
3643
- /* @__PURE__ */ (0, Y.jsxs)("div", {
3644
- className: "fw-overview",
3645
- children: [/* @__PURE__ */ (0, Y.jsxs)("div", {
3646
- className: "fw-overview-marks",
3647
- "aria-hidden": !0,
3648
- children: [o.map((e, t) => /* @__PURE__ */ (0, Y.jsx)("span", {
3649
- className: `fw-ov fw-seg-${e.kind}`,
3650
- "data-tone": rt(e.tone),
3651
- style: {
3652
- left: `${e.startMs / Math.max(1, n) * 100}%`,
3653
- width: `${Math.max(.15, (Math.min(e.endMs, n) - e.startMs) / Math.max(1, n) * 100)}%`
3654
- }
3655
- }, t)), a && /* @__PURE__ */ (0, Y.jsx)("span", {
3656
- className: "fw-brush",
3657
- style: {
3658
- left: `${a.startMs / n * 100}%`,
3659
- width: `${(a.endMs - a.startMs) / n * 100}%`
3660
- }
3661
- })]
3662
- }), /* @__PURE__ */ (0, Y.jsx)("input", {
3663
- ref: s,
3664
- "aria-label": "Playback position",
3665
- type: "range",
3666
- min: 0,
3667
- max: Math.max(1, n),
3668
- step: "any",
3669
- defaultValue: r,
3670
- disabled: n === 0,
3671
- className: "fw-slider",
3672
- style: { "--fw-progress": `${r / Math.max(1, n) * 100}%` },
3673
- onChange: (e) => p(Number(e.target.value))
3674
- })]
3675
- }),
3676
- /* @__PURE__ */ (0, Y.jsx)("output", {
3677
- ref: c,
3678
- className: "fw-time",
3679
- "aria-label": "Playback time",
3680
- children: Q(r)
3681
- }),
3682
- l && /* @__PURE__ */ (0, Y.jsx)("button", {
3683
- type: "button",
3684
- className: "fw-text-button",
3685
- onClick: m,
3686
- children: l
3687
- }),
3688
- /* @__PURE__ */ (0, Y.jsxs)("div", {
3689
- className: "fw-zoom",
3690
- role: "group",
3691
- "aria-label": "Zoom",
3692
- children: [
3693
- /* @__PURE__ */ (0, Y.jsx)("button", {
3694
- type: "button",
3695
- className: "fw-icon-button",
3696
- "aria-label": "Zoom out",
3697
- disabled: !a,
3698
- onClick: () => h(2),
3699
- children: /* @__PURE__ */ (0, Y.jsx)(Ut, {})
3700
- }),
3701
- /* @__PURE__ */ (0, Y.jsx)("button", {
3702
- type: "button",
3703
- className: "fw-icon-button",
3704
- "aria-label": "Zoom in",
3705
- disabled: n === 0,
3706
- onClick: () => h(.5),
3707
- children: /* @__PURE__ */ (0, Y.jsx)(Ht, {})
3708
- }),
3709
- /* @__PURE__ */ (0, Y.jsx)("button", {
3710
- type: "button",
3711
- className: "fw-icon-button",
3712
- "aria-label": "Fit the whole trace",
3713
- disabled: !a,
3714
- onClick: g,
3715
- children: /* @__PURE__ */ (0, Y.jsx)(Wt, {})
3716
- })
3717
- ]
3718
- })
3719
- ]
3720
- });
3721
- }
3722
- var An = 12, jn = 20, Mn = 12, Nn = {
3723
- spans: 120,
3724
- agents: 176
3725
- }, Pn = {
3726
- spans: 320,
3727
- agents: 240
3728
- };
3729
- function Fn(e, t, n) {
3730
- let [r, i] = (0, X.useState)(n), a = e === void 0 ? r : e, o = (0, X.useRef)(a);
3731
- o.current = a;
3732
- let s = (0, X.useRef)(t);
3733
- s.current = t;
3734
- let c = e !== void 0;
3735
- return [a, (0, X.useCallback)((e) => {
3736
- let t = typeof e == "function" ? e(o.current) : e;
3737
- o.current = t, c || i(t), s.current?.(t);
3738
- }, [c])];
3739
- }
3740
- var In = 320;
3741
- function Ln(e) {
3742
- let t = /* @__PURE__ */ new Map();
3743
- for (let n of e) n && t.set(n, (t.get(n) ?? 0) + 1);
3744
- let [n, r] = [...t].sort((e, t) => t[1] - e[1])[0] ?? [];
3745
- return e.length > 1 && r !== void 0 && r >= 2 && r * 2 >= e.length ? n : void 0;
3746
- }
3747
- function Rn(e, t, n) {
3748
- let r = xt(t ? t.costUsd : e.costUsd, e), i = t ? t.tokens : e.promptTokens + e.completionTokens, a = t ? t.modelCalls : e.modelCalls, o = t ? t.errors : e.errors ?? e.spans.filter(it).length;
3749
- return {
3750
- cost: r,
3751
- tokens: i,
3752
- errors: o,
3753
- summary: [
3754
- ["Duration", Q(n)],
3755
- ...r.value === "—" ? [] : [[
3756
- r.label,
3757
- r.value,
3758
- r.title
3759
- ]],
3760
- [
3761
- "Tokens",
3762
- st(i),
3763
- `${i.toLocaleString()} tokens`
3764
- ],
3765
- [
3766
- "LLM calls",
3767
- a === void 0 ? "—" : a.toLocaleString(),
3768
- a === void 0 ? "Model output windows do not establish the number of LLM requests" : void 0
3769
- ],
3770
- [
3771
- "Tool calls",
3772
- (t ? t.toolCalls : e.toolCalls)?.toLocaleString() ?? "—",
3773
- (t ? t.toolCalls : e.toolCalls) === void 0 ? "The producer did not count tool calls" : void 0
3774
- ],
3775
- ["Errors", o.toLocaleString()]
3776
- ]
3777
- };
3778
- }
3779
- var zn = [
3780
- "ok",
3781
- "warn",
3782
- "failed",
3783
- "neutral"
3784
- ];
3785
- function Bn({ rows: e }) {
3786
- let t = (t) => e.some((e) => e.own.some((e) => e.kind === t) || e.span.kind === t), n = [
3787
- ["model", "Model call"],
3788
- ["tool", "Tool call"],
3789
- ["waiting", "Waiting"],
3790
- ["handoff", "Handoff"]
3791
- ].filter(([n]) => n === "waiting" ? e.some((e) => e.kind === "pipeline") : n === "handoff" ? e.some((e) => e.span.handoffTo || e.hasAgents) : t(n));
3792
- return n.length === 0 ? null : /* @__PURE__ */ (0, Y.jsx)("ul", {
3793
- className: "fw-legend fw-kinds",
3794
- "aria-label": "Key",
3795
- children: n.map(([e, t]) => /* @__PURE__ */ (0, Y.jsxs)("li", { children: [/* @__PURE__ */ (0, Y.jsx)("span", {
3796
- className: `fw-swatch-${e === "waiting" ? "wait" : e}`,
3797
- "aria-hidden": !0
3798
- }), t] }, e))
3799
- });
3800
- }
3801
- function Vn({ agents: e }) {
3802
- let t = /* @__PURE__ */ new Map();
3803
- for (let n of e) {
3804
- let e = n.span.outcome;
3805
- if (!e) continue;
3806
- let r = t.get(e.label) ?? {
3807
- tone: e.tone,
3808
- count: 0
3809
- };
3810
- r.count += 1, t.set(e.label, r);
3811
- }
3812
- if (t.size === 0) return null;
3813
- let n = e.reduce((e, t) => e + t.own.reduce((e, t) => e + (t.kind === "failed" ? t.count : 0), 0), 0);
3814
- return /* @__PURE__ */ (0, Y.jsxs)("ul", {
3815
- className: "fw-legend",
3816
- "aria-label": "Outcomes",
3817
- children: [[...t].sort(([e, t], [n, r]) => zn.indexOf(t.tone) - zn.indexOf(r.tone) || e.localeCompare(n)).map(([e, t]) => /* @__PURE__ */ (0, Y.jsxs)("li", { children: [
3818
- /* @__PURE__ */ (0, Y.jsx)("span", {
3819
- className: "fw-swatch",
3820
- "data-tone": "0",
3821
- "data-outcome": t.tone,
3822
- "aria-hidden": !0
3823
- }),
3824
- e,
3825
- " ",
3826
- /* @__PURE__ */ (0, Y.jsx)("b", { children: t.count })
3827
- ] }, e)), n > 0 && /* @__PURE__ */ (0, Y.jsxs)("li", { children: [
3828
- /* @__PURE__ */ (0, Y.jsx)("span", {
3829
- className: "fw-swatch-step",
3830
- "aria-hidden": !0,
3831
- children: /* @__PURE__ */ (0, Y.jsx)(Rt, {})
3832
- }),
3833
- "Failed step ",
3834
- /* @__PURE__ */ (0, Y.jsx)("b", { children: n })
3835
- ] })]
3836
- });
3837
- }
3838
- function Hn({ trace: e, live: t, startedAt: n, label: r = "Trace waterfall", defaultCollapsed: i = !1, defaultView: a = "spans", renderIcon: o, maxHeight: s, onSelect: c, markers: l, onTimeChange: u, agentFill: d, selectedId: f, onDeselect: p, description: m, summary: h = !0, criticalPath: g = !1, query: _, onQueryChange: v, collapsed: y, onCollapsedChange: b, zoom: x, onZoomChange: S, matchSpan: C }) {
3839
- let w = (0, X.useRef)(null), T = (0, X.useRef)(null), E = (0, X.useRef)(null), D = (0, X.useRef)(null), O = (0, X.useRef)(void 0), k = (0, X.useId)(), A = (0, X.useId)(), [j, M] = (0, X.useState)(a), [N, P] = Fn(_, v, ""), [F, I] = Fn(y, b, () => new Set(i ? e.spans.flatMap((e) => e.parentId ? [e.parentId] : []) : [])), [L, ee] = (0, X.useState)(1), [R, z] = (0, X.useState)(!1), [B, V] = (0, X.useState)(null), [te, ne] = Fn(x, S, null), [re, ie] = (0, X.useState)(Pn[a]), [ae, oe] = (0, X.useState)(0), [H, se] = (0, X.useState)(null), [ce, le] = (0, X.useState)(), [ue, de] = (0, X.useState)(null), U = Number.isFinite(e.totalMs) && e.totalMs >= 0 ? e.totalMs : 0, W = t ?? e.spans.some(Z), fe = d ?? "agent", pe = (0, X.useMemo)(() => Math.max(U, ...e.spans.map((e) => Number.isFinite(e.endMs) ? e.endMs : 0)), [e, U]), me = Math.max(40, ae - An - Math.min(Nn[j], ae * .3));
3840
- (0, X.useEffect)(() => {
3841
- if (!ue) return;
3842
- let e = new ResizeObserver(([e]) => oe(e.contentRect.width));
3843
- return e.observe(ue), () => e.disconnect();
3844
- }, [ue]);
3845
- let he = (0, X.useCallback)((e) => te ?? {
3846
- startMs: 0,
3847
- endMs: Math.max(pe, W ? e : 0, 1)
3848
- }, [
3849
- te,
3850
- pe,
3851
- W
3852
- ]), ge = Dn({
3853
- root: w,
3854
- slider: E,
3855
- timeOutput: D,
3856
- observedTotal: pe,
3857
- live: W,
3858
- startedAt: n,
3859
- snapshot: e,
3860
- playing: R,
3861
- speed: L,
3862
- position: B,
3863
- onPlaybackEnd: (e) => {
3864
- z(!1), V(e);
3865
- },
3866
- view: he,
3867
- trackPx: me
3868
- }), G = ge.clockMs, _e = he(G), K = Math.max(pe, W ? G : 0), ve = 2 ** Math.round(Math.log2(Math.max(1, (_e.endMs - _e.startMs) / Math.max(200, me) * 1.5))), q = (0, X.useMemo)(() => lt({
3869
- ...e,
3870
- totalMs: pe
3871
- }, ve), [
3872
- e,
3873
- pe,
3874
- ve
3875
- ]), ye = (0, X.useMemo)(() => new Map(q.map((e) => [e.id, e])), [q]), be = (0, X.useMemo)(() => _t(q), [q]), J = (0, X.useMemo)(() => {
3876
- let e = q.filter((e) => e.kind === "pipeline");
3877
- return e.length ? e : q.filter((e) => !e.parentId);
3878
- }, [q]), xe = Ln(J.map((e) => e.span.detail)), Se = Ln(J.map((e) => e.span.outcome?.label)), [Ce, we] = (0, X.useState)(/* @__PURE__ */ new Set()), Te = (0, X.useMemo)(() => Ct(J, Mn, Ce), [J, Ce]), [Ee, De] = (0, X.useState)(/* @__PURE__ */ new Set()), Oe = (0, X.useMemo)(() => j === "agents" ? Et(J, q, Te, Ee) : ht(q, N, F, C), [
3879
- j,
3880
- J,
3881
- q,
3882
- Te,
3883
- Ee,
3884
- N,
3885
- F,
3886
- C
3887
- ]), ke = j === "spans" ? gt(q, G) : void 0, Ae = (0, X.useMemo)(() => j === "agents" ? vt(Oe, G) : {}, [
3888
- j,
3889
- Oe,
3890
- G
3891
- ]), je = s ?? (j === "agents" ? yn.agents * jn : 640), Me = (0, X.useRef)(!1);
3892
- (0, X.useLayoutEffect)(() => {
3893
- if (j !== "agents" || Me.current || !w.current) return;
3894
- let e = 0;
3895
- for (let t of w.current.querySelectorAll(".fw-view-agents .fw-row:not(.fw-sticky-row) .fw-name-text")) {
3896
- let n = t.closest(".fw-label");
3897
- n && (e = Math.max(e, t.scrollWidth + n.clientWidth - t.clientWidth));
3898
- }
3899
- e > 0 && ie(Math.max(140, Math.min(560, Math.ceil(e) + 16)));
3900
- }, [j, J]), (0, X.useEffect)(() => {
3901
- let e = (e) => {
3902
- let t = document.activeElement, n = w.current?.contains(t);
3903
- if ((e.metaKey || e.ctrlKey) && e.key.toLowerCase() === "f") {
3904
- let r = Array.from(document.querySelectorAll("[data-flow-waterfall]")).find((e) => e.getClientRects().length > 0);
3905
- if (!n && (t !== document.body || r !== w.current)) return;
3906
- e.preventDefault(), j === "agents" && M("spans"), requestAnimationFrame(() => {
3907
- T.current?.focus(), T.current?.select();
3908
- });
3909
- return;
3910
- }
3911
- if (!(!n || t instanceof HTMLInputElement || t instanceof HTMLSelectElement || e.metaKey || e.ctrlKey || e.altKey)) {
3912
- if (e.key === "+" || e.key === "=") Ne(.5);
3913
- else if (e.key === "-" || e.key === "_") Ne(2);
3914
- else if (e.key === "0") ne(null);
3915
- else if (e.key === "Escape" && (H || f)) H && Ge(), p?.();
3916
- else if ((e.key === "n" || e.key === "p") && l?.length) {
3917
- let t = l.map((e) => e.at).sort((e, t) => e - t), n = e.key === "n" ? t.find((e) => e > G + 1) : [...t].reverse().find((e) => e < G - 1);
3918
- n !== void 0 && (e.preventDefault(), Ke(n));
3919
- }
3920
- }
3921
- };
3922
- return document.addEventListener("keydown", e), () => document.removeEventListener("keydown", e);
3923
- }), (0, X.useEffect)(() => {
3924
- if (!H?.pinned) return;
3925
- let e = (e) => {
3926
- let t = e.target;
3927
- t?.closest(".fw-card") || t?.closest(".fw-bar, .fw-seg") || se(null);
3928
- };
3929
- return document.addEventListener("pointerdown", e), () => document.removeEventListener("pointerdown", e);
3930
- }, [H?.pinned]);
3931
- let Ne = (e, t) => ne((n) => {
3932
- let r = n ?? he(G), i = _n(r, e, t ?? (r.startMs + r.endMs) / 2, K);
3933
- return i.endMs - i.startMs >= K - 1 ? null : i;
3934
- }), Pe = (0, X.useRef)(0), Fe = (e) => {
3935
- let t = e.span, n = he(G), r = n.endMs - n.startMs, i = Z(t) ? Math.max(t.endMs, G) : t.endMs;
3936
- if (j !== "spans" || !Number.isFinite(i) || (i - t.startMs) / Math.max(1, r) > .25) return;
3937
- let a = Math.max((i - t.startMs) * .15, 500, (r / 8 - (i - t.startMs)) / 2), o = vn({
3938
- startMs: t.startMs - a,
3939
- endMs: i + a
3940
- }, K);
3941
- if (cancelAnimationFrame(Pe.current), globalThis.matchMedia?.("(prefers-reduced-motion: reduce)").matches) {
3942
- ne(o);
3943
- return;
3944
- }
3945
- let s = performance.now(), c = (e) => {
3946
- let t = Math.min(1, (e - s) / 320), r = 1 - (1 - t) ** 3;
3947
- ne({
3948
- startMs: n.startMs + (o.startMs - n.startMs) * r,
3949
- endMs: n.endMs + (o.endMs - n.endMs) * r
3950
- }), t < 1 && (Pe.current = requestAnimationFrame(c));
3951
- };
3952
- Pe.current = requestAnimationFrame(c);
3953
- }, Ie = (e) => ne((t) => t && vn({
3954
- startMs: t.startMs + e,
3955
- endMs: t.endMs + e
3956
- }, K)), Le = (0, X.useRef)({
3957
- toggle: (e) => {},
3958
- pin: (e, t, n) => {},
3959
- inspect: (e, t, n) => {}
3960
- }), Re = (e) => {
3961
- let t = (t) => new Set(t.has(e.id) ? [...t].filter((t) => t !== e.id) : [...t, e.id]);
3962
- if (e.id.startsWith("family:")) {
3963
- we(t);
3964
- return;
3965
- }
3966
- if (c?.(e.span), j === "agents") {
3967
- De(t), le(e.id);
3968
- return;
3969
- }
3970
- F.has(e.id) && Fe(e), I((t) => {
3971
- let n = new Set(t);
3972
- return n.has(e.id) ? n.delete(e.id) : n.add(e.id), n;
3973
- });
3974
- };
3975
- Le.current.toggle = Re;
3976
- let ze = (0, X.useCallback)((e) => Le.current.toggle(e), []), Be = (e, t, n, r) => {
3977
- let i = w.current?.getBoundingClientRect();
3978
- if (!i) return;
3979
- let a = t.getBoundingClientRect(), o = Math.min(In, i.width - 16), s = Math.max(8, Math.min((r ?? a.left + 24) - i.left - 24, i.width - o - 8));
3980
- clearTimeout(O.current), se({
3981
- target: e,
3982
- pinned: n,
3983
- left: s,
3984
- anchorTop: a.top - i.top,
3985
- anchorBottom: a.bottom - i.top,
3986
- above: j === "agents"
3987
- });
3988
- };
3989
- (0, X.useLayoutEffect)(() => {
3990
- if (!H || H.fitted || !w.current) return;
3991
- let e = document.getElementById(A)?.getBoundingClientRect();
3992
- if (!e) return;
3993
- let t = w.current.getBoundingClientRect().top, n = {
3994
- above: H.anchorTop - 16,
3995
- below: globalThis.innerHeight - (t + H.anchorBottom) - 16
3996
- }, r = H.above ? n.above : n.below, i = H.above ? n.below : n.above, a = e.height <= r || e.height > i && r >= i ? H.above : !H.above;
3997
- se({
3998
- ...H,
3999
- fitted: !0,
4000
- above: a,
4001
- top: a ? Math.max(8, H.anchorTop - 8 - e.height) : H.anchorBottom + 8
4002
- });
4003
- }, [H, A]), Le.current.inspect = (e, t, n) => {
4004
- H?.pinned || Be(e, t, !1, n);
4005
- };
4006
- let Ve = (0, X.useCallback)((e, t, n) => Le.current.inspect(e, t, n), []), He = (0, X.useCallback)(() => {
4007
- clearTimeout(O.current), O.current = setTimeout(() => se((e) => e?.pinned ? e : null), 140);
4008
- }, []);
4009
- (0, X.useEffect)(() => {
4010
- if (!H || H.pinned) return;
4011
- let e = (e) => {
4012
- e.target?.closest(".fw-bar, .fw-seg, .fw-card") || He();
4013
- };
4014
- return document.addEventListener("pointermove", e), () => document.removeEventListener("pointermove", e);
4015
- }, [H, He]), Le.current.pin = (e, t, n) => {
4016
- if (H?.pinned && H.target === e) {
4017
- Ge();
4018
- return;
4019
- }
4020
- Be(e, t, !0, n);
4021
- let r = ye.get(e);
4022
- r && (c?.(r.span), Fe(r));
4023
- };
4024
- let Ue = (0, X.useCallback)((e, t, n) => Le.current.pin(e, t, n), []), We = f ?? (H?.pinned ? H.target : void 0), Ge = () => {
4025
- let e = H?.target;
4026
- se(null), e && w.current?.querySelector(`.fw-canvas [data-span-id="${CSS.escape(e)}"]`)?.focus({ preventScroll: !0 });
4027
- }, Ke = (0, X.useCallback)((e) => {
4028
- z(!1), V(Math.min(e, ge.limitMs()));
4029
- }, [ge]), qe = (0, X.useRef)(u);
4030
- qe.current = u, (0, X.useEffect)(() => {
4031
- qe.current?.(B);
4032
- }, [B]);
4033
- let Je = () => {
4034
- if (R) {
4035
- V(ge.positionMs()), z(!1);
4036
- return;
4037
- }
4038
- (B === null || B >= K - 1) && V(0), z(!0);
4039
- }, Ye = B !== null || R, { errors: Xe, summary: Ze } = Rn(e, Ye ? bt(e, G) : void 0, Ye ? G : K), Qe = J.reduce((e, t) => e + yt(t, K), 0), $e = K > 0 ? Qe / K : 0, et = !W && !e.spans.some(Z), tt = (e) => e && Ot(e, Oe), nt = tt(H ? ye.get(H.target) : void 0), rt = nt && (() => {
4040
- for (let e = nt; e; e = e.parentId ? ye.get(e.parentId) : void 0) if (e.kind === "pipeline") return tt(e);
4041
- })(), it = W || B !== null || R || j === "agents", at = (0, X.useMemo)(() => q.filter((e) => !e.parentId).flatMap((e) => e.hasChildren ? e.segments : e.kind === "pipeline" ? [] : [{
4042
- startMs: e.span.startMs,
4043
- endMs: e.span.endMs,
4044
- kind: e.ok ? "tool" : "failed",
4045
- tone: e.tone,
4046
- id: e.id,
4047
- count: 1,
4048
- retry: !1
4049
- }]), [q]), Q = /* @__PURE__ */ (0, Y.jsx)(kn, {
4050
- view: j,
4051
- playing: R,
4052
- limit: K,
4053
- clockMs: G,
4054
- speed: L,
4055
- zoom: te,
4056
- marks: at,
4057
- slider: E,
4058
- timeOutput: D,
4059
- followLabel: B === null ? void 0 : W ? "Follow live" : "Show full trace",
4060
- onTogglePlay: Je,
4061
- onRestart: () => {
4062
- V(0), z(!1);
4063
- },
4064
- onSpeed: ee,
4065
- onScrub: Ke,
4066
- onFollow: () => {
4067
- V(null), z(!1);
4068
- },
4069
- onZoom: Ne,
4070
- onFit: () => ne(null)
4071
- });
4072
- return /* @__PURE__ */ (0, Y.jsxs)("section", {
4073
- ref: w,
4074
- "data-flow-waterfall": !0,
4075
- "aria-label": r,
4076
- className: `fw-root fw-root-${j} fw-fill-${fe}`,
4077
- "data-selection": f ? "" : void 0,
4078
- style: {
4079
- "--fw-name-w": `${re}px`,
4080
- "--fw-pad": `${An}px`,
4081
- "--fw-row-h": `${yn[j]}px`
4082
- },
4083
- children: [
4084
- /* @__PURE__ */ (0, Y.jsxs)("header", {
4085
- className: "fw-heading",
4086
- children: [/* @__PURE__ */ (0, Y.jsxs)("div", {
4087
- className: "fw-title-block",
4088
- children: [
4089
- /* @__PURE__ */ (0, Y.jsxs)("div", {
4090
- className: "fw-title-line",
4091
- children: [
4092
- /* @__PURE__ */ (0, Y.jsx)("span", {
4093
- className: "fw-title-glyph",
4094
- "aria-hidden": !0,
4095
- children: /* @__PURE__ */ (0, Y.jsx)(Bt, {})
4096
- }),
4097
- /* @__PURE__ */ (0, Y.jsx)("h3", {
4098
- className: "fw-title",
4099
- children: r
4100
- }),
4101
- m && /* @__PURE__ */ (0, Y.jsx)("p", {
4102
- className: "fw-description",
4103
- title: m,
4104
- children: m
4105
- }),
4106
- W && /* @__PURE__ */ (0, Y.jsx)("span", {
4107
- className: "fw-state fw-state-live",
4108
- children: "Live"
4109
- })
4110
- ]
4111
- }),
4112
- j === "agents" && /* @__PURE__ */ (0, Y.jsxs)("p", {
4113
- className: "fw-headline",
4114
- "aria-live": "polite",
4115
- children: [
4116
- et && /* @__PURE__ */ (0, Y.jsx)("span", {
4117
- className: "fw-done-mark",
4118
- "aria-label": "done",
4119
- children: "✓"
4120
- }),
4121
- J.length,
4122
- " ",
4123
- J.length === 1 ? "agent" : "agents",
4124
- xe ? ` · ${J.every((e) => e.span.detail === xe) ? "" : "mostly "}${xe}` : "",
4125
- et && $e >= 1.05 ? ` · ${$e.toFixed(1)}x parallel` : ""
4126
- ]
4127
- }),
4128
- /* @__PURE__ */ (0, Y.jsxs)("div", {
4129
- className: "fw-legends",
4130
- children: [/* @__PURE__ */ (0, Y.jsx)(Vn, { agents: J }), j === "agents" && /* @__PURE__ */ (0, Y.jsx)(Bn, { rows: q })]
4131
- })
4132
- ]
4133
- }), /* @__PURE__ */ (0, Y.jsxs)("div", {
4134
- className: "fw-tools",
4135
- children: [/* @__PURE__ */ (0, Y.jsx)("div", {
4136
- className: "fw-views",
4137
- role: "radiogroup",
4138
- "aria-label": "Trace view",
4139
- children: ["agents", "spans"].map((e) => /* @__PURE__ */ (0, Y.jsx)("button", {
4140
- type: "button",
4141
- role: "radio",
4142
- "aria-checked": j === e,
4143
- disabled: j === e,
4144
- className: "fw-view-button",
4145
- onClick: () => {
4146
- M(e), ie(Pn[e]), se(null);
4147
- },
4148
- children: e === "agents" ? "Agents" : "Steps"
4149
- }, e))
4150
- }), j === "spans" && /* @__PURE__ */ (0, Y.jsxs)("div", {
4151
- className: "fw-search",
4152
- children: [
4153
- /* @__PURE__ */ (0, Y.jsx)("label", {
4154
- htmlFor: k,
4155
- className: "fw-sr-only",
4156
- children: "Search trace"
4157
- }),
4158
- /* @__PURE__ */ (0, Y.jsx)("span", {
4159
- className: "fw-search-glyph",
4160
- "aria-hidden": !0,
4161
- children: /* @__PURE__ */ (0, Y.jsx)(Nt, {})
4162
- }),
4163
- /* @__PURE__ */ (0, Y.jsx)("input", {
4164
- ref: T,
4165
- id: k,
4166
- type: "search",
4167
- value: N,
4168
- placeholder: "Search",
4169
- "aria-keyshortcuts": "Meta+f Control+f",
4170
- onChange: (e) => P(e.target.value),
4171
- onKeyDown: (e) => {
4172
- e.key === "Escape" && (P(""), e.stopPropagation());
4173
- },
4174
- className: "fw-search-input"
4175
- })
4176
- ]
4177
- })]
4178
- })]
4179
- }),
4180
- h && /* @__PURE__ */ (0, Y.jsx)("dl", {
4181
- className: "fw-summary",
4182
- children: Ze.map(([e, t, n]) => /* @__PURE__ */ (0, Y.jsxs)("div", {
4183
- className: e === "Errors" && Xe > 0 ? "fw-has-errors" : void 0,
4184
- children: [/* @__PURE__ */ (0, Y.jsx)("dt", { children: e }), /* @__PURE__ */ (0, Y.jsx)("dd", {
4185
- className: "fw-value",
4186
- title: n,
4187
- children: t
4188
- })]
4189
- }, e))
4190
- }),
4191
- j === "agents" && Q,
4192
- /* @__PURE__ */ (0, Y.jsx)(wn, {
4193
- rows: Oe,
4194
- byId: ye,
4195
- totalRows: q.length,
4196
- view: j,
4197
- maxHeight: je,
4198
- collapsed: F,
4199
- searching: !!N.trim(),
4200
- query: N,
4201
- matchSpan: C,
4202
- pauses: e.pauses,
4203
- cursorLine: B !== null || R,
4204
- sharedDetail: xe,
4205
- sharedOutcome: Se,
4206
- expandedIds: j === "agents" ? /* @__PURE__ */ new Set([...Te, ...Ee]) : void 0,
4207
- holdHeight: W,
4208
- slowestId: ke?.id ?? Ae.slowestId,
4209
- costliestId: Ae.costliestId,
4210
- criticalIds: g && j === "spans" ? be : void 0,
4211
- activeId: ce,
4212
- selectedId: We,
4213
- focusId: rt?.id ?? (j === "agents" ? ce : void 0),
4214
- clockMs: G,
4215
- window: _e,
4216
- trackPx: me,
4217
- showCursor: it,
4218
- markers: l,
4219
- fillByAgent: fe !== "outcome",
4220
- zoomed: te !== null,
4221
- renderIcon: o,
4222
- emptyText: q.length === 0 ? "No spans yet. Waiting for trace events." : `No matching steps for “${N}”.`,
4223
- onToggle: ze,
4224
- onInspect: Ve,
4225
- onLeave: He,
4226
- onPin: Ue,
4227
- onActivate: (e) => le(e.id),
4228
- onActiveChange: le,
4229
- onScrub: Ke,
4230
- onZoom: Ne,
4231
- onPan: Ie,
4232
- nameWidth: re,
4233
- onNameWidth: (e) => {
4234
- Me.current = !0, ie(Math.max(140, Math.min(560, e)));
4235
- },
4236
- onTrack: de,
4237
- onExpandAll: q.some((e) => e.hasChildren) ? () => I(/* @__PURE__ */ new Set()) : void 0,
4238
- onCollapseAll: () => I(new Set(q.filter((e) => e.hasChildren).map((e) => e.id)))
4239
- }),
4240
- H && nt && /* @__PURE__ */ (0, Y.jsx)("div", {
4241
- className: `fw-card-anchor${H.above && H.top === void 0 ? " fw-card-above" : ""}`,
4242
- onPointerEnter: () => clearTimeout(O.current),
4243
- onPointerLeave: H.pinned ? void 0 : He,
4244
- children: /* @__PURE__ */ (0, Y.jsx)($t, {
4245
- id: A,
4246
- row: nt,
4247
- agent: rt,
4248
- clockMs: G,
4249
- left: H.left,
4250
- top: H.top ?? (H.above ? H.anchorTop - 8 : H.anchorBottom + 8),
4251
- pinned: H.pinned,
4252
- onClose: Ge,
4253
- renderIcon: o,
4254
- compact: j === "agents"
4255
- })
4256
- }),
4257
- j === "spans" && Q
4258
- ]
4259
- });
4260
- }
4261
- //#endregion
4262
- export { u as $, ue as A, G as B, fe as C, P as D, R as E, _ as F, T as G, M as H, ee as I, re as J, ne as K, L, d as M, pe as N, r as O, b as P, E as Q, F as R, V as S, K as T, B as U, w as V, f as W, g as X, v as Y, O as Z, ye as _, Hn as a, D as at, xe as b, Re as c, J as d, c as et, be as f, I as g, se as h, Ze as i, Oe as it, ve as j, z as k, ze as l, C as m, Le as n, ie as nt, qe as o, m as ot, q as p, te as q, tt as r, ae as rt, Xe as s, l as st, Qe as t, j as tt, Ge as u, k as v, me as w, S as x, p as y, x as z };