-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
2128 lines (1974 loc) · 103 KB
/
Copy pathscript.js
File metadata and controls
2128 lines (1974 loc) · 103 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
const aggregateReferenceData = [
{
label: "Hyperparameter Search",
shortLabel: "Hyperparameter Search",
value: 11.53,
sem: 0.68,
bar: "#d6cec2",
dot: "#8e887d"
},
{
label: "vLLM Default",
shortLabel: "vLLM Default",
value: 4.05,
sem: 0.07,
bar: "#d6cec2",
dot: "#8e887d"
},
{
label: "PyTorch Default",
shortLabel: "PyTorch Default",
value: 1.0,
sem: 0.0,
bar: "#d6cec2",
dot: "#8e887d"
}
];
const scenarioData = [
{
id: "A",
key: "a",
title: "Time to First Token (TTFT)",
metric: "Prefill Latency",
headline: 4.65,
description: "Agents reduce time to first token substantially, though search still leads.",
values: [
{ label: "Search", value: 4.37, color: "#2c365a" },
{ label: "Best agent", value: 4.65, color: "#657091" },
{ label: "vLLM", value: 1.25, color: "#c4bcb0" },
{ label: "PyTorch", value: 1.0, color: "#8e887d" }
]
},
{
id: "B",
key: "b",
title: "Time Per Output Token (TPOT)",
metric: "Decode Latency",
headline: 15.01,
description: "Agents dramatically improve per-token latency, narrowing much of the gap.",
values: [
{ label: "Search", value: 15.23, color: "#2c365a" },
{ label: "Best agent", value: 15.01, color: "#657091" },
{ label: "vLLM", value: 2.25, color: "#c4bcb0" },
{ label: "PyTorch", value: 1.0, color: "#8e887d" }
]
},
{
id: "C",
key: "c",
title: "Throughput (Requests / s)",
metric: "Concurrent Traffic",
headline: 38.52,
description: "Agents unlock major throughput gains, but search and defaults can climb higher.",
values: [
{ label: "Search", value: 46.7, color: "#2c365a" },
{ label: "Best agent", value: 38.52, color: "#657091" },
{ label: "vLLM", value: 48.69, color: "#c4bcb0" },
{ label: "PyTorch", value: 1.0, color: "#8e887d" }
]
},
{
id: "D",
key: "d",
title: "Aggregate (Geometric Mean)",
metric: "All-In-One",
headline: 4.65,
description: "Balanced objectives expose the discipline gap most clearly.",
values: [
{ label: "Search", value: 5.69, color: "#2c365a" },
{ label: "Best agent", value: 4.65, color: "#657091" },
{ label: "vLLM", value: 1.96, color: "#c4bcb0" },
{ label: "PyTorch", value: 1.0, color: "#8e887d" }
]
}
];
const leaderboardRows = [
{ rank: 1, model: "Claude Opus 5", scaffold: "Claude Code · v2.1.119 · strict prompt", value: 8.90, sem: 1.32, type: "agent", a: 4.65, b: 15.01, c: 32.42, d: 2.77, mark: "†", key: "opus-5" },
{ rank: 2, model: "Claude Fable 5 (Low)", scaffold: "Claude Code · v2.1.175 · strict prompt", value: 8.74, sem: 1.91, type: "agent", a: 4.17, b: 13.38, c: 21.37, d: 4.89, mark: "*†", key: "fable-5-low-strict", variant: true },
{ rank: 3, model: "Claude Opus 4.7", scaffold: "Claude Code · v2.1.175", value: 8.53, sem: 0.80, type: "agent", a: 2.83, b: 11.63, c: 38.52, d: 4.18, mark: "*", key: "opus-4-7" },
{ rank: 4, model: "Claude Opus 4.8", scaffold: "Claude Code · v2.1.175", value: 7.60, sem: 2.16, type: "agent", a: 4.53, b: 12.16, c: 18.62, d: 3.25, mark: "*", key: "opus-4-8" },
{ rank: 5, model: "Claude Fable 5", scaffold: "Claude Code · v2.1.175 · strict prompt", value: 7.52, sem: 1.58, type: "agent", a: 4.27, b: 15.64, c: 11.90, d: 4.03, mark: "*†", key: "fable-5-strict", variant: true },
{ rank: 6, model: "GPT-5.6 Sol (Ultra)", scaffold: "Codex CLI · strict prompt", value: 7.34, sem: 0.21, type: "agent", a: 4.24, b: 8.61, c: 33.92, d: 2.35, mark: "†", key: "gpt-5-6-sol-ultra" },
{ rank: 7, model: "Claude Opus 4.8 (xHigh)", scaffold: "Claude Code", value: 7.34, sem: 2.37, type: "agent", a: 4.30, b: 7.72, c: 18.77, d: 4.65, key: "opus-4-8-xhigh" },
{ rank: 8, model: "GLM-5.2 (Max)", scaffold: "Claude Code · v2.1.119 · strict prompt", value: 7.00, sem: 0.24, type: "agent", a: 3.86, b: 5.77, c: 32.47, d: 3.32, mark: "†", key: "glm-5-2-max" },
{ rank: 9, model: "Grok 4.6", scaffold: "Grok Build · strict prompt", value: 6.65, sem: 1.14, type: "agent", a: 2.99, b: 6.24, c: 30.17, d: 3.47, mark: "†", key: "grok-4-6-build" },
{ rank: 10, model: "Claude Sonnet 5", scaffold: "Claude Code · v2.1.119 · strict prompt", value: 6.43, sem: 1.46, type: "agent", a: 3.30, b: 4.48, c: 36.09, d: 3.20, mark: "†", key: "sonnet-5" },
{ rank: 11, model: "Kimi K2.7 Code", scaffold: "OpenCode · strict prompt", value: 6.27, sem: 0.22, type: "agent", a: 3.97, b: 5.33, c: 22.99, d: 3.17, mark: "†", key: "kimi-k2-7-code" },
{ rank: 12, model: "GPT-5.4 (High)", scaffold: "Codex CLI", value: 6.16, sem: 1.16, type: "agent", a: 3.60, b: 6.93, c: 17.78, d: 3.25, key: "gpt-5-4-high" },
{ rank: 13, model: "Kimi K3", scaffold: "OpenCode · strict prompt", value: 5.70, sem: 1.69, type: "agent", a: 3.50, b: 4.25, c: 19.59, d: 3.64, mark: "†", key: "kimi-k3" },
{ rank: 14, model: "Claude Sonnet 4.6", scaffold: "Claude Code", value: 5.56, sem: 1.62, type: "agent", a: 1.62, b: 8.21, c: 23.87, d: 3.01, key: "sonnet-4-6" },
{ rank: 15, model: "GPT-5.3 Codex (High)", scaffold: "Codex CLI", value: 5.49, sem: 0.54, type: "agent", a: 3.56, b: 3.38, c: 29.00, d: 2.60, key: "gpt-5-3-codex-high" },
{ rank: 16, model: "GPT-5.5 (xHigh)", scaffold: "Codex CLI", value: 5.45, sem: 1.25, type: "agent", a: 2.74, b: 6.07, c: 16.94, d: 3.14, key: "gpt-5-5-xhigh" },
{ rank: 17, model: "Gemini 3.1 Pro", scaffold: "OpenCode", value: 4.92, sem: 0.81, type: "agent", a: 2.52, b: 3.78, c: 31.24, d: 1.97, key: "gemini-3-1-pro" },
{ rank: 18, model: "Kimi K2.6", scaffold: "OpenCode", value: 4.51, sem: 0.48, type: "agent", a: 1.99, b: 4.73, c: 29.19, d: 1.51, key: "kimi-k2-6" },
{ rank: 19, model: "Claude Opus 4.6", scaffold: "Claude Code", value: 4.38, sem: 1.25, type: "agent", a: 1.00, b: 4.80, c: 23.85, d: 3.21, key: "opus-4-6" },
{ rank: 20, model: "GPT-5.2", scaffold: "Codex CLI", value: 4.28, sem: 1.29, type: "agent", a: 2.26, b: 2.87, c: 20.15, d: 2.57, key: "gpt-5-2" },
{ rank: 21, model: "GPT-5.5 (High)", scaffold: "Codex CLI", value: 4.22, sem: 1.01, type: "agent", a: 3.06, b: 2.59, c: 19.11, d: 2.08, key: "gpt-5-5-high" },
{ rank: 22, model: "Gemini 3.5 Flash", scaffold: "OpenCode", value: 4.16, sem: 0.72, type: "agent", a: 3.70, b: 3.05, c: 17.71, d: 1.50, key: "gemini-3-5-flash" },
{ rank: 23, model: "Claude Opus 4.5", scaffold: "Claude Code", value: 3.76, sem: 0.89, type: "agent", a: 3.69, b: 2.78, c: 10.03, d: 1.95, key: "opus-4-5" },
{ rank: 24, model: "Grok 4.5", scaffold: "Grok Build · strict prompt", value: 3.70, sem: 0.79, type: "agent", a: 2.95, b: 2.73, c: 15.59, d: 1.49, mark: "†", key: "grok-4-5-build" },
{ rank: 25, model: "GPT-5.1 Codex Max", scaffold: "Codex CLI", value: 3.59, sem: 1.24, type: "agent", a: 2.57, b: 3.44, c: 10.33, d: 1.82, key: "gpt-5-1-codex-max" },
{ rank: 26, model: "Grok 4.5", scaffold: "OpenCode · strict prompt", value: 3.42, sem: 1.23, type: "agent", a: 2.07, b: 2.75, c: 10.11, d: 2.37, mark: "†", key: "grok-4-5-opencode", variant: true },
{ rank: 27, model: "GLM-5", scaffold: "OpenCode", value: 3.22, sem: 0.85, type: "agent", a: 2.19, b: 1.00, c: 26.36, d: 1.87, key: "glm-5" },
{ rank: 28, model: "Claude Sonnet 4.5", scaffold: "Claude Code", value: 3.18, sem: 0.90, type: "agent", a: 2.67, b: 1.71, c: 9.65, d: 2.32, key: "sonnet-4-5" },
{ rank: 29, model: "Claude Fable 5", scaffold: "Claude Code · v2.1.175", value: 3.16, sem: 0.67, type: "agent", a: 3.92, b: 1.00, c: 25.42, d: 1.00, mark: "*", key: "fable-5-regular" },
{ rank: 30, model: "Claude Haiku 4.5", scaffold: "Claude Code", value: 2.78, sem: 0.57, type: "agent", a: 1.00, b: 1.99, c: 9.27, d: 3.24, key: "haiku-4-5" },
{ rank: 31, model: "GPT-5.3 Codex (Medium)", scaffold: "Codex CLI", value: 2.32, sem: 0.31, type: "agent", a: 2.75, b: 3.73, c: 1.00, d: 2.82, key: "gpt-5-3-codex-medium" },
{ rank: 32, model: "Claude Opus 4.7", scaffold: "Claude Code · v2.1.114", value: 2.25, sem: 0.32, type: "agent", a: 1.07, b: 1.00, c: 19.02, d: 1.27, key: "opus-4-7-v2114", variant: true },
{ rank: 33, model: "Claude Fable 5 (Low)", scaffold: "Claude Code · v2.1.175", value: 2.15, sem: 0.46, type: "agent", a: 1.00, b: 1.00, c: 21.21, d: 1.00, mark: "*", key: "fable-5-low-regular", variant: true },
{ rank: 34, model: "GPT-5.2 Codex", scaffold: "Codex CLI", value: 1.98, sem: 0.18, type: "agent", a: 3.32, b: 2.48, c: 1.00, d: 1.87, key: "gpt-5-2-codex" }
];
// top three overall, plus the best GPT model and the best model from any
// other (non-Claude, non-GPT) family
const aggregateChartRows = (() => {
const picks = leaderboardRows.slice(0, 3);
const gpt = leaderboardRows.find((row) => /gpt/i.test(row.model) && !picks.includes(row));
if (gpt) picks.push(gpt);
const other = leaderboardRows.find((row) => !/claude|gpt/i.test(row.model) && !picks.includes(row));
if (other) picks.push(other);
return picks;
})();
const aggregateShortLabels = {
"gpt-5-6-sol-ultra": "GPT-5.6 Sol",
"grok-4-6-build": "Grok 4.6 Build",
"sonnet-5": "Sonnet 5",
"kimi-k2-7-code": "Kimi K2.7 Code",
"kimi-k3": "Kimi K3",
"grok-4-5-build": "Grok 4.5 Build",
"grok-4-5-opencode": "Grok 4.5 OpenCode"
};
const aggregateExpandedData = [
aggregateReferenceData[0],
...aggregateChartRows
.map((row) => ({
label: `${row.model} — ${row.scaffold}`,
shortLabel: `${aggregateShortLabels[row.key] ?? row.model.replace("Claude ", "")}${row.mark ? ` ${row.mark}` : ""}`,
value: row.value,
sem: row.sem,
bar: "#2c365a",
dot: "#2c365a"
})),
...aggregateReferenceData.slice(1)
];
const scenarioColumns = [
{ key: "a", label: "A Prefill Latency", shortLabel: "Prefill", color: "#657091", max: 5 },
{ key: "b", label: "B Decode Latency", shortLabel: "Decode", color: "#2c365a", max: 16 },
{ key: "c", label: "C Throughput", shortLabel: "Throughput", color: "#202944", max: 40 },
{ key: "d", label: "D All-In-One", shortLabel: "All-in-one", color: "#8e887d", max: 5 }
];
const scenarioFocusNotes = {
a: "Opus 5 leads prefill at 4.65×. Its runs paired FP8 serving with large prefill budgets and aggressive batching, and all three seeds passed the final quality and integrity gates.",
b: "Scenario B is where FP8 helps most, so many agents reached for it by swapping in banned pre-quantized checkpoints, and 38% of runs here failed a gate. Fable 5 quantized to FP8 legitimately and added 16-token speculative decoding, making it one of only two agents to beat matched parameter search on any scenario.",
c: "Most agents quantized only the model weights, but Opus 4.7 also quantized the KV cache to FP8, freeing enough memory to batch 384 concurrent requests and lift throughput far higher. Its three seeds all landed between 38.2 and 39.0×, though even that trails tuned parameter search.",
d: "The all-in-one score is a geometric mean, so one weak metric sinks it. Rivals tuned hard for a single axis and lost ground elsewhere, while Fable 5 (Low) kept a moderate batch and light speculation that raise every metric at once, letting the lowest-effort run finish on top."
};
const modelKey = (model) => model.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/(^-|-$)/g, "");
const rowKey = (row) => row.key || modelKey(row.model);
const markHtml = (row) => row.mark ? `<sup class="rank-mark">${row.mark}</sup>` : "";
const sortState = { key: "value", dir: "desc" };
let costDataLoaded = false;
let refreshLeaderboardSort = null;
const defaultSortDir = (key) => (key === "cost" ? "asc" : "desc");
const focusForSortKey = { value: "all", a: "a", b: "b", c: "c", d: "d", cost: "cost" };
const sortMetric = (row, key) => (key === "cost" ? row.fullCost : row[key]);
function sortedLeaderboardRows() {
const { key, dir } = sortState;
const sign = dir === "asc" ? 1 : -1;
return [...leaderboardRows].sort((a, b) => {
const aValue = sortMetric(a, key);
const bValue = sortMetric(b, key);
const aKnown = Number.isFinite(aValue);
const bKnown = Number.isFinite(bValue);
if (aKnown !== bKnown) return aKnown ? -1 : 1;
if (!aKnown) return a.rank - b.rank;
return sign * (aValue - bValue) || a.rank - b.rank;
});
}
function bestLeaderboardRow() {
const { key } = sortState;
const candidates = leaderboardRows.filter((row) => Number.isFinite(sortMetric(row, key)));
if (!candidates.length) return leaderboardRows[0];
const wantLowest = defaultSortDir(key) === "asc";
return candidates.reduce((best, row) => {
const bestValue = sortMetric(best, key);
const rowValue = sortMetric(row, key);
return (wantLowest ? rowValue < bestValue : rowValue > bestValue) ? row : best;
});
}
function updateSortArrows() {
document.querySelectorAll(".leaderboard-head [data-sort]").forEach((element) => {
const active = element.dataset.sort === sortState.key;
element.textContent = active
? `${element.dataset.label} ${sortState.dir === "desc" ? "↓" : "↑"}`
: element.dataset.label;
});
}
function updateLeaderboardSummary(focus = "all", topRow = bestLeaderboardRow()) {
const label = document.getElementById("leaderboard-top-label");
const name = document.getElementById("leaderboard-top-name");
const copy = document.getElementById("leaderboard-top-copy");
if (!label || !name || !copy || !topRow) return;
if (focus === "all") {
label.textContent = "Top agent";
name.innerHTML = topRow.model + markHtml(topRow);
copy.textContent = `${topRow.model} ranks first by combining strong per-scenario speedups with valid final submissions. Failed or gated runs score at the PyTorch baseline, so repeatability remains part of the result.`;
return;
}
if (focus === "cost") {
label.textContent = "Lowest cost";
name.innerHTML = topRow.model + markHtml(topRow);
copy.textContent = `${topRow.model} has the lowest cost for the full 12-run evaluation at ${formatUsd(topRow.fullCost)}.`;
return;
}
const column = scenarioColumns.find((item) => item.key === focus);
const scenarioName = column?.shortLabel ?? "scenario";
label.textContent = `Top ${scenarioName}`;
name.innerHTML = topRow.model + markHtml(topRow);
copy.textContent = scenarioFocusNotes[focus] ?? "";
}
function formatUsd(value) {
if (!Number.isFinite(value)) return "N/A";
return `$${value.toFixed(value < 10 ? 2 : 1)}`;
}
async function loadCostEfficiency() {
const button = document.querySelector('[data-focus="cost"]');
try {
const response = await fetch("./data/cost-efficiency.json?v=20260814-4");
if (!response.ok) throw new Error(`HTTP ${response.status}`);
const payload = await response.json();
const byKey = new Map(payload.configs.map((item) => [item.key, item]));
leaderboardRows.forEach((row) => {
const item = byKey.get(rowKey(row));
row.fullCost = item?.full_12_run_cost_usd ?? null;
});
const byModelKey = new Map(leaderboardRows.map((row) => [rowKey(row), row]));
document.querySelectorAll(".leaderboard-row").forEach((element) => {
const row = byModelKey.get(element.dataset.modelKey);
const cell = element.querySelector(".leaderboard-cost-cell");
if (row && cell) cell.textContent = formatUsd(row.fullCost);
});
costDataLoaded = true;
if (sortState.key === "cost") refreshLeaderboardSort?.();
if (button) button.disabled = false;
renderCostScatter();
} catch (error) {
if (button) button.title = `Cost data could not be loaded: ${error.message}`;
}
}
const outcomeData = [
{ label: "Passed both gates", value: 67.5, color: "#2c365a" },
{ label: "Failed/incomplete quality gate", value: 9.9, color: "#c4bcb0" },
{ label: "Integrity-flagged", value: 13.9, color: "#d9d2c7" },
{ label: "Server/runtime failure", value: 8.7, color: "#586078" }
];
const configDistribution = [
{ label: "0", note: "No changes", value: 31, color: "#eee8df" },
{ label: "1", note: "One change", value: 61, color: "#c4bcb0" },
{ label: "2", note: "Two changes", value: 6, color: "#d9d2c7" },
{ label: "3+", note: "Three or more", value: 2, color: "#2c365a" }
];
const foundData = [
{
label: "Best final-submitted agent aggregate",
description: "What agents reliably preserve and submit.",
value: 9.97,
gap: "+3.94×"
},
{
label: "Best-seen agent aggregate",
description: "Best valid configuration discovered at any point.",
value: 13.91,
gap: "+0.39×"
},
{
label: "Best non-agent search",
description: "Upper bound from disciplined hyperparameter search.",
value: 14.30
}
];
const timeBudgetData = [
{
model: "Claude Haiku 4.5",
values: [1.05, 2.78, 1.30, 1.35],
sem: [0.16, 0.19, 0.20, 0.21],
estimated: [true, false, true, true]
},
{
model: "Claude Sonnet 4.5",
values: [1.92, 3.18, 2.92, 2.81],
sem: [0.66, 1.02, 1.01, 0.97],
estimated: [true, false, true, true]
},
{
model: "Claude Opus 4.5",
values: [2.42, 3.76, 3.31, 3.24],
sem: [0.70, 0.98, 0.96, 0.94],
estimated: [true, false, true, true]
}
];
const timeLabels = ["1h", "2h", "4h", "8h"];
const AGGREGATE_MIN = 1;
const AGGREGATE_MAX = 12.5;
const AGGREGATE_PLOT_HEIGHT = 250;
function fmt(value) {
return `${value.toFixed(2)}×`;
}
function median(values) {
const sorted = [...values].sort((a, b) => a - b);
const middle = Math.floor(sorted.length / 2);
if (sorted.length % 2) return sorted[middle];
return (sorted[middle - 1] + sorted[middle]) / 2;
}
function renderAggregateChart(targetId, data) {
const target = document.getElementById(targetId);
if (!target) return;
const plotHeight = (value) => {
const clamped = Math.max(AGGREGATE_MIN, Math.min(AGGREGATE_MAX, value));
return ((clamped - AGGREGATE_MIN) / (AGGREGATE_MAX - AGGREGATE_MIN)) * AGGREGATE_PLOT_HEIGHT;
};
const items = data.map((item) => {
const height = plotHeight(item.value);
const sem = item.sem ?? 0;
const semLabel = sem > 0 ? `SEM ±${fmt(sem)}` : "no SEM";
const whiskerLow = Math.max(AGGREGATE_MIN, item.value - sem);
const whiskerHigh = item.value + sem;
const whiskerLowHeight = plotHeight(whiskerLow);
const whiskerHighHeight = Math.max(whiskerLowHeight, plotHeight(whiskerHigh));
const whisker = sem > 0
? `<span class="ci-whisker" style="--ci-bottom:${whiskerLowHeight.toFixed(1)}px; --ci-top:${whiskerHighHeight.toFixed(1)}px;"></span>`
: "";
return `
<div class="aggregate-item" aria-label="${item.label}: ${fmt(item.value)}, ${semLabel}">
<div class="aggregate-label" title="${item.label}">
<span class="aggregate-name">${item.shortLabel ?? item.label}</span>
<span class="aggregate-value">${fmt(item.value)}</span>
</div>
<div class="lollipop" title="${item.label}: ${fmt(item.value)}; ${semLabel}" style="--height:${height}px; --bar:${item.bar === "#2c365a" ? "#6c7693" : item.bar}; --dot:${item.dot};">
${whisker}
</div>
</div>
`;
}).join("");
target.innerHTML = `<span class="aggregate-baseline" aria-hidden="true"><span>1x baseline</span></span>${items}`;
}
function renderAggregateCharts() {
renderAggregateChart("aggregate-chart-expanded", aggregateExpandedData);
}
function renderScenarioBreakdown() {
const target = document.getElementById("scenario-breakdown");
if (!target) return;
target.innerHTML = scenarioData.map((scenario) => {
const agentValues = leaderboardRows
.filter((row) => row.type === "agent" && !row.variant)
.map((row) => row[scenario.key]);
const medianValue = median(agentValues);
const minValue = Math.min(...agentValues);
const maxValue = Math.max(...agentValues);
const searchValue = scenario.values.find((item) => item.label === "Search")?.value;
const max = Math.max(...scenario.values.map((item) => item.value), maxValue);
const bars = scenario.values.map((item) => {
const height = Math.max(14, (item.value / max) * 108);
return `<span class="small-bar" title="${item.label}: ${fmt(item.value)}" style="--h:${height}px; --bar:${item.color}; --dot:${item.color};"></span>`;
}).join("");
return `
<article class="breakdown-card">
<header>
<span class="scenario-letter">${scenario.id}</span>
<div>
<h4>${scenario.title}</h4>
<span class="metric-row"><span>Median agent</span><strong>${fmt(medianValue)}</strong></span>
<span class="range-line">${fmt(minValue)}-${fmt(maxValue)}</span>
${searchValue ? `<span class="search-line"><span>Median search baseline</span><strong>${fmt(searchValue)}</strong></span>` : ""}
</div>
</header>
<div class="small-bars">${bars}</div>
<p>${scenario.description}</p>
</article>
`;
}).join("");
}
function renderLeaderboard() {
const target = document.getElementById("leaderboard-list");
if (!target) return;
const max = Math.max(...leaderboardRows.map((row) => row.value));
const rows = sortedLeaderboardRows();
target.innerHTML = rows.map((row, index) => {
const width = (row.value / max) * 100;
const rankClass = index < 3 ? "top" : "";
const scenarioCells = scenarioColumns.map((column) => {
const value = row[column.key];
const scenarioWidth = Math.min(100, Math.max(4, (value / column.max) * 100));
return `
<span class="leaderboard-scenario-cell" data-scenario="${column.key}" aria-label="${column.shortLabel} speedup ${fmt(value)}">
<span class="scenario-score-value">${fmt(value)}</span>
<span class="scenario-score-line" aria-hidden="true">
<i style="--w:${scenarioWidth}%; --bar:${column.color};"></i>
</span>
</span>
`;
}).join("");
return `
<div class="leaderboard-row ${row.type}" data-model-key="${rowKey(row)}">
<span class="rank-badge ${rankClass}">${index + 1}</span>
<div>
<span class="model-name">${row.model}${markHtml(row)}</span>
<span class="model-subtitle">${row.scaffold}</span>
</div>
<div class="speed-track" aria-hidden="true">
<span class="speed-fill" style="--w:${width}%"></span>
</div>
<span class="leaderboard-cost-cell">${formatUsd(row.fullCost)}</span>
<span class="row-speed">
<span class="row-speed-value">${fmt(row.value)}</span>
<span class="row-speed-sem">±${row.sem.toFixed(2)}×</span>
</span>
${scenarioCells}
</div>
`;
}).join("");
updateSortArrows();
updateLeaderboardSummary(focusForSortKey[sortState.key]);
}
function setupScenarioFocus() {
const wrap = document.querySelector(".leaderboard-table-wrap");
const controls = document.getElementById("scenario-focus");
const list = document.getElementById("leaderboard-list");
const head = document.querySelector(".leaderboard-head");
if (!wrap || !controls || !list) return;
const rowByKey = () => new Map([...list.children].map((row) => [row.dataset.modelKey, row]));
const applySort = (key, dir, animate = true) => {
sortState.key = key;
sortState.dir = dir;
const focus = focusForSortKey[key];
controls.querySelectorAll("button[data-focus]").forEach((control) => {
const isActive = control.dataset.focus === focus;
control.classList.toggle("is-active", isActive);
control.setAttribute("aria-pressed", String(isActive));
});
const orderedRows = sortedLeaderboardRows();
const firstRects = new Map([...list.children].map((row) => [row.dataset.modelKey, row.getBoundingClientRect()]));
const existingRows = rowByKey();
orderedRows.forEach((row, index) => {
const element = existingRows.get(rowKey(row));
if (!element) return;
const badge = element.querySelector(".rank-badge");
if (badge) {
badge.textContent = String(index + 1);
badge.classList.toggle("top", index < 3);
}
list.appendChild(element);
});
wrap.dataset.focus = focus;
updateSortArrows();
updateLeaderboardSummary(focus);
if (!animate) return;
[...list.children].forEach((row) => {
const first = firstRects.get(row.dataset.modelKey);
const last = row.getBoundingClientRect();
if (!first) return;
const deltaY = first.top - last.top;
if (Math.abs(deltaY) < 1) return;
row.animate([
{ transform: `translateY(${deltaY}px)` },
{ transform: "translateY(0)" }
], {
duration: 560,
easing: "cubic-bezier(0.22, 1, 0.36, 1)"
});
});
};
controls.addEventListener("click", (event) => {
const button = event.target.closest("button[data-focus]");
if (!button) return;
const key = button.dataset.focus === "all" ? "value" : button.dataset.focus;
applySort(key, defaultSortDir(key));
});
head?.addEventListener("click", (event) => {
const target = event.target.closest("[data-sort]");
if (!target) return;
const key = target.dataset.sort;
if (key === "cost" && !costDataLoaded) return;
const dir = sortState.key === key
? (sortState.dir === "desc" ? "asc" : "desc")
: defaultSortDir(key);
applySort(key, dir);
});
refreshLeaderboardSort = (animate = false) => applySort(sortState.key, sortState.dir, animate);
}
function renderScenarioMatrix() {
const target = document.getElementById("scenario-matrix");
if (!target) return;
const rows = leaderboardRows.slice(0, 3);
const header = `
<div class="matrix-row matrix-header">
<div class="matrix-cell">Model</div>
${scenarioColumns.map((column) => `<div class="matrix-cell">${column.label}</div>`).join("")}
</div>
`;
const body = rows.map((row) => `
<div class="matrix-row">
<div class="matrix-cell matrix-model">${row.model}${markHtml(row)}</div>
${scenarioColumns.map((column) => {
const value = row[column.key];
const x = Math.min(96, Math.max(4, (value / column.max) * 100));
return `
<div class="matrix-cell">
<div class="metric-line">
<span class="metric-dot" style="--x:${x}%; --dot:${column.color};"></span>
</div>
<span class="metric-value">${fmt(value)}</span>
</div>
`;
}).join("")}
</div>
`).join("");
target.innerHTML = header + body;
}
function renderOutcomes() {
const bar = document.getElementById("outcome-bar");
const grid = document.getElementById("outcome-grid");
if (!bar || !grid) return;
let cumulative = 0;
bar.innerHTML = outcomeData.map((item) => {
const midpoint = cumulative + item.value / 2;
const segment = `<span class="stack-segment" title="${item.label}: ${item.value.toFixed(1)}%" style="--w:${item.value}%; --segment:${item.color}; --mid:${midpoint}%;"></span>`;
cumulative += item.value;
return segment;
}).join("");
cumulative = 0;
const connectors = [];
const items = [];
outcomeData.forEach((item, index) => {
const midpoint = cumulative + item.value / 2;
const labelX = [12, 38, 64, 88][index] ?? midpoint;
const connectorLeft = Math.min(midpoint, labelX);
const connectorWidth = Math.abs(labelX - midpoint);
const connectorDirection = labelX >= midpoint ? "to-right" : "to-left";
cumulative += item.value;
connectors.push(`<span class="outcome-connector ${connectorDirection}" style="--left:${connectorLeft}%; --width:${connectorWidth}%;"></span>`);
items.push(`
<div class="outcome-item" style="--x:${midpoint}%; --label-x:${labelX}%;">
<strong>${item.value.toFixed(1)}%</strong>
<span>${item.label}</span>
</div>
`);
});
grid.innerHTML = connectors.join("") + items.join("");
}
function renderHistogram() {
const target = document.getElementById("config-histogram");
if (!target) return;
const max = Math.max(...configDistribution.map((item) => item.value));
target.innerHTML = configDistribution.map((item) => {
const height = Math.max(18, (item.value / max) * 220);
return `
<div class="histogram-bar">
<strong>${item.value}%</strong>
<span class="histogram-column" style="--h:${height}px; --bar:${item.color};"></span>
<span>${item.label}<em>${item.note}</em></span>
</div>
`;
}).join("");
}
function renderFoundChart() {
const target = document.getElementById("found-chart");
if (!target) return;
const max = Math.max(...foundData.map((item) => item.value));
target.innerHTML = foundData.map((item) => {
const height = Math.max(60, (item.value / max) * 210);
return `
<div class="found-item" style="--h:${height}px;" data-gap="${item.gap || ""}">
<div class="found-plot">
<span class="found-value">${fmt(item.value)}</span>
<span class="found-bar"></span>
</div>
<span class="found-label">${item.label}</span>
<span class="found-desc">${item.description}</span>
</div>
`;
}).join("");
}
const MODEL_FAMILIES = [
{ name: "xAI", color: "#b34d46", shape: "triangle", match: /grok/i },
{ name: "Anthropic", color: "#4a5a99", shape: "circle", match: /claude/i },
{ name: "OpenAI", color: "#aa7422", shape: "square", match: /gpt/i },
{ name: "Google", color: "#128a6c", shape: "diamond", match: /gemini/i },
{ name: "Moonshot", color: "#8156ab", shape: "cross", match: /kimi/i },
{ name: "Z.AI", color: "#8d7a12", shape: "tridown", match: /glm/i }
];
const modelFamily = (row) => MODEL_FAMILIES.find((f) => f.match.test(row.model)) ?? MODEL_FAMILIES[0];
const costScatterHidden = new Set();
const costScatterPinned = new Set();
function shapePath(shape, x, y, r) {
switch (shape) {
case "square": return `<rect x="${x - r}" y="${y - r}" width="${2 * r}" height="${2 * r}" rx="1.5"/>`;
case "diamond": return `<path d="M${x} ${y - r * 1.2} L${x + r * 1.2} ${y} L${x} ${y + r * 1.2} L${x - r * 1.2} ${y} Z"/>`;
case "triangle": return `<path d="M${x} ${y - r * 1.2} L${x + r * 1.15} ${y + r} L${x - r * 1.15} ${y + r} Z"/>`;
case "tridown": return `<path d="M${x} ${y + r * 1.2} L${x + r * 1.15} ${y - r} L${x - r * 1.15} ${y - r} Z"/>`;
case "cross": return `<path d="M${x - r} ${y - r} L${x + r} ${y + r} M${x - r} ${y + r} L${x + r} ${y - r}" stroke-width="3.2" fill="none" stroke-linecap="round"/>`;
default: return `<circle cx="${x}" cy="${y}" r="${r}"/>`;
}
}
function renderCostScatter() {
const target = document.getElementById("cost-perf-chart");
const legend = document.getElementById("cost-perf-legend");
const fitNote = document.getElementById("cost-perf-fit");
if (!target || !legend) return;
const points = leaderboardRows
.filter((row) => Number.isFinite(row.fullCost) && row.fullCost > 0)
.map((row) => ({ row, family: modelFamily(row) }));
if (!points.length) return;
const width = 640;
const height = 430;
const pad = { left: 46, right: 18, top: 16, bottom: 44 };
const plotW = width - pad.left - pad.right;
const plotH = height - pad.top - pad.bottom;
const xMin = Math.log10(25);
const xMax = Math.log10(800);
const yMax = 10;
const xPos = (cost) => pad.left + ((Math.log10(cost) - xMin) / (xMax - xMin)) * plotW;
const yPos = (value) => pad.top + (1 - value / yMax) * plotH;
// least-squares fit of speedup on log10(cost), over visible families
const active = points.filter((p) => !costScatterHidden.has(p.family.name));
const fitSet = active.length >= 3 ? active : points;
const n = fitSet.length;
const mx = fitSet.reduce((s, p) => s + Math.log10(p.row.fullCost), 0) / n;
const my = fitSet.reduce((s, p) => s + p.row.value, 0) / n;
let sxx = 0, sxy = 0, syy = 0;
fitSet.forEach((p) => {
const dx = Math.log10(p.row.fullCost) - mx;
const dy = p.row.value - my;
sxx += dx * dx; sxy += dx * dy; syy += dy * dy;
});
const slope = sxy / sxx;
const intercept = my - slope * mx;
const r2 = sxx && syy ? (sxy * sxy) / (sxx * syy) : 0;
if (fitNote) {
const perDouble = slope * Math.log10(2);
fitNote.textContent = `Best fit: ${perDouble >= 0 ? "+" : ""}${perDouble.toFixed(2)}× aggregate per doubling of cost (R² = ${r2.toFixed(2)}).`;
}
const xTicks = [25, 50, 100, 200, 400, 800];
const yTicks = [0, 2, 4, 6, 8, 10];
const gridColor = "rgba(196, 188, 176, 0.55)";
const clampFit = (value) => Math.max(0, Math.min(yMax, value));
const fitY1 = clampFit(intercept + slope * xMin);
const fitY2 = clampFit(intercept + slope * xMax);
const tooltipHtml = (p) =>
`<strong>${p.row.model}</strong><span>${p.row.scaffold}</span>` +
`<span>${formatUsd(p.row.fullCost)} · ${fmt(p.row.value)} ±${p.row.sem.toFixed(2)}× · ${p.family.name}</span>`;
// pins on hidden families (or stale keys) are dropped
[...costScatterPinned].forEach((key) => {
const p = points.find((item) => item.row.key === key);
if (!p || costScatterHidden.has(p.family.name)) costScatterPinned.delete(key);
});
const marks = points.map((p) => {
const hidden = costScatterHidden.has(p.family.name);
const pinned = costScatterPinned.has(p.row.key);
const x = xPos(p.row.fullCost);
const y = yPos(Math.min(yMax, p.row.value));
const ring = pinned ? `<circle cx="${x}" cy="${y}" r="9.5" fill="none" stroke-width="2" opacity="0.65"/>` : "";
return `
<g class="scatter-mark${hidden ? " is-hidden" : ""}${pinned ? " is-pinned" : ""}" data-key="${p.row.key}"
fill="${p.family.color}" stroke="${p.family.color}">
<circle class="scatter-hit" cx="${x}" cy="${y}" r="13" fill="transparent" stroke="none"/>
${ring}
${shapePath(p.family.shape, x, y, 5.5)}
</g>`;
}).join("");
const pinnedTips = points
.filter((p) => costScatterPinned.has(p.row.key))
.map((p) => {
const x = xPos(p.row.fullCost) / width * 100;
const y = yPos(Math.min(yMax, p.row.value)) / height * 100;
const flip = x > 66 ? " flip" : "";
return `<div class="scatter-tooltip is-pinned${flip}" style="left:${x.toFixed(2)}%; top:${y.toFixed(2)}%;">${tooltipHtml(p)}</div>`;
}).join("");
target.innerHTML = `
<svg viewBox="0 0 ${width} ${height}" role="img" aria-label="Aggregate speedup versus 12-run API cost, colored by model family">
${yTicks.map((t) => `
<line x1="${pad.left}" x2="${width - pad.right}" y1="${yPos(t)}" y2="${yPos(t)}" stroke="${gridColor}" stroke-width="1"/>
<text class="scatter-axis" x="${pad.left - 8}" y="${yPos(t) + 3.5}" text-anchor="end">${t}×</text>`).join("")}
${xTicks.map((t) => `
<line y1="${pad.top}" y2="${height - pad.bottom}" x1="${xPos(t)}" x2="${xPos(t)}" stroke="${gridColor}" stroke-width="1" stroke-dasharray="1 3"/>
<text class="scatter-axis" x="${xPos(t)}" y="${height - pad.bottom + 16}" text-anchor="middle">$${t}</text>`).join("")}
<text class="scatter-axis-title" x="${pad.left + plotW / 2}" y="${height - 6}" text-anchor="middle">12-run API cost (log scale)</text>
<text class="scatter-axis-title" x="14" y="${pad.top + plotH / 2}" text-anchor="middle" transform="rotate(-90 14 ${pad.top + plotH / 2})">Aggregate speedup</text>
<line x1="${xPos(25)}" y1="${yPos(fitY1)}" x2="${xPos(800)}" y2="${yPos(fitY2)}"
stroke="#8e887d" stroke-width="2" stroke-dasharray="6 5" opacity="0.85"/>
${marks}
</svg>
${pinnedTips}
<div class="scatter-tooltip" id="cost-perf-tooltip" hidden></div>`;
// greedy de-overlap: walk pinned tips top-to-bottom, push a tip below any
// earlier tip it collides with
const pinnedNodes = [...target.querySelectorAll(".scatter-tooltip.is-pinned")]
.sort((a, b) => a.getBoundingClientRect().top - b.getBoundingClientRect().top);
const placed = [];
pinnedNodes.forEach((tip) => {
let rect = tip.getBoundingClientRect();
placed.forEach((prior) => {
const overlapX = rect.left < prior.right + 8 && rect.right > prior.left - 8;
const overlapY = rect.top < prior.bottom + 8 && rect.bottom > prior.top - 8;
if (overlapX && overlapY) {
const nudge = parseFloat(tip.style.marginTop || "0") + (prior.bottom + 8 - rect.top);
tip.style.marginTop = `${nudge}px`;
rect = tip.getBoundingClientRect();
}
});
placed.push(rect);
});
legend.innerHTML = MODEL_FAMILIES.map((f) => `
<button type="button" class="scatter-legend-chip${costScatterHidden.has(f.name) ? " is-off" : ""}" data-family="${f.name}">
<svg viewBox="0 0 16 16" aria-hidden="true" fill="${f.color}" stroke="${f.color}">${shapePath(f.shape, 8, 8, 4.5)}</svg>
${f.name}
</button>`).join("");
legend.querySelectorAll("[data-family]").forEach((chip) => {
chip.addEventListener("click", () => {
const name = chip.dataset.family;
if (costScatterHidden.has(name)) costScatterHidden.delete(name);
else if (costScatterHidden.size < MODEL_FAMILIES.length - 1) costScatterHidden.add(name);
renderCostScatter();
});
});
const tooltip = document.getElementById("cost-perf-tooltip");
const byKey = new Map(points.map((p) => [p.row.key, p]));
target.querySelectorAll(".scatter-mark").forEach((mark) => {
mark.addEventListener("click", () => {
const key = mark.dataset.key;
if (costScatterPinned.has(key)) costScatterPinned.delete(key);
else costScatterPinned.add(key);
renderCostScatter();
});
mark.addEventListener("pointerenter", () => {
const p = byKey.get(mark.dataset.key);
if (!p || costScatterHidden.has(p.family.name)) return;
if (costScatterPinned.has(p.row.key)) return; // its pinned tooltip is already showing
tooltip.innerHTML = tooltipHtml(p);
tooltip.hidden = false;
});
mark.addEventListener("pointermove", (event) => {
const rect = target.getBoundingClientRect();
const left = Math.min(event.clientX - rect.left + 14, rect.width - 190);
tooltip.style.left = `${Math.max(0, left)}px`;
tooltip.style.top = `${Math.max(4, event.clientY - rect.top - 12)}px`;
});
mark.addEventListener("pointerleave", () => { tooltip.hidden = true; });
});
// anywhere off a mark, including gaps inside the plot, hides the tooltip
if (!target.dataset.tooltipWired) {
target.dataset.tooltipWired = "true";
const hideUnlessMark = (event) => {
if (!event.target.closest || !event.target.closest(".scatter-mark")) {
const tip = document.getElementById("cost-perf-tooltip");
if (tip) tip.hidden = true;
}
};
target.addEventListener("pointermove", hideUnlessMark);
target.addEventListener("pointerleave", () => {
const tip = document.getElementById("cost-perf-tooltip");
if (tip) tip.hidden = true;
});
}
}
function renderTimeAblation() {
const target = document.getElementById("time-ablation");
if (!target) return;
target.innerHTML = timeBudgetData.map((series) => {
const width = 300;
const height = 190;
const left = 38;
const right = 18;
const top = 16;
const bottom = 34;
const plotW = width - left - right;
const plotH = height - top - bottom;
const minY = 1;
const maxY = 4;
const clampY = (value) => Math.max(minY, Math.min(maxY, value));
const point = (value, index) => {
const x = left + (index / (series.values.length - 1)) * plotW;
const y = top + ((maxY - clampY(value)) / (maxY - minY)) * plotH;
return { x, y };
};
const points = series.values.map(point);
const path = points.map((p, index) => `${index === 0 ? "M" : "L"}${p.x.toFixed(1)} ${p.y.toFixed(1)}`).join(" ");
const upperPoints = series.values.map((value, index) => point(value + (series.sem?.[index] ?? 0), index));
const lowerPoints = series.values.map((value, index) => point(value - (series.sem?.[index] ?? 0), index)).reverse();
const bandPath = [
...upperPoints.map((p, index) => `${index === 0 ? "M" : "L"}${p.x.toFixed(1)} ${p.y.toFixed(1)}`),
...lowerPoints.map((p) => `L${p.x.toFixed(1)} ${p.y.toFixed(1)}`),
"Z"
].join(" ");
const gridLines = [1, 1.5, 2, 2.5, 3, 3.5, 4].map((tick) => {
const y = top + ((maxY - tick) / (maxY - minY)) * plotH;
return `<line class="grid" x1="${left}" x2="${width - right}" y1="${y}" y2="${y}"></line>`;
}).join("");
const xLabels = timeLabels.map((label, index) => {
const x = point(series.values[index], index).x;
return `<text x="${x}" y="${height - 8}" text-anchor="middle">${label}</text>`;
}).join("");
const valueLabels = points.map((p, index) => (
`<text x="${p.x}" y="${p.y - 10}" text-anchor="middle">${fmt(series.values[index])}</text>`
)).join("");
const circles = points.map((p) => `<circle cx="${p.x}" cy="${p.y}" r="5"></circle>`).join("");
return `
<div class="line-chart">
<h4>${series.model}</h4>
<svg viewBox="0 0 ${width} ${height}" role="img" aria-label="${series.model} time budget ablation">
${gridLines}
<line class="axis" x1="${left}" x2="${left}" y1="${top}" y2="${height - bottom}"></line>
<line class="axis" x1="${left}" x2="${width - right}" y1="${height - bottom}" y2="${height - bottom}"></line>
<path class="uncertainty" d="${bandPath}"></path>
<path class="series" d="${path}"></path>
${circles}
${valueLabels}
${xLabels}
</svg>
</div>
`;
}).join("");
}
function setupNavigation() {
const toggle = document.getElementById("nav-toggle");
const nav = document.getElementById("site-nav");
if (!toggle || !nav) return;
toggle.addEventListener("click", () => {
const open = !nav.classList.contains("open");
nav.classList.toggle("open", open);
document.body.classList.toggle("nav-open", open);
toggle.setAttribute("aria-expanded", String(open));
});
nav.querySelectorAll("a").forEach((link) => {
link.addEventListener("click", () => {
nav.classList.remove("open");
document.body.classList.remove("nav-open");
toggle.setAttribute("aria-expanded", "false");
});
});
}
function setupScrollExperience() {
const header = document.querySelector(".site-header");
const nav = document.getElementById("site-nav");
if (!header || !nav) return;
const navLinks = [...nav.querySelectorAll("a[href^='#']")];
const sections = navLinks
.map((link) => {
const id = link.getAttribute("href").slice(1);
const target = document.getElementById(id);
return target ? { id, label: link.textContent.trim(), target } : null;
})
.filter(Boolean);
const rail = document.createElement("nav");
rail.className = "scroll-rail";
rail.setAttribute("aria-label", "Section navigation");
rail.innerHTML = sections.map((section) => (
`<a class="scroll-rail-link" href="#${section.id}" aria-label="${section.label}"></a>`
)).join("");
document.body.appendChild(rail);
const railLinks = [...rail.querySelectorAll(".scroll-rail-link")];
let lastScrollY = window.scrollY;
let ticking = false;
let navVisible = null;
const setNavVisible = (visible) => {
if (navVisible === visible) return;
navVisible = visible;
header.classList.toggle("is-scroll-visible", visible);
header.classList.toggle("is-scroll-hidden", !visible);
document.body.classList.toggle("nav-hidden", !visible);
};
const setScrollState = () => {
const currentY = window.scrollY;
const delta = currentY - lastScrollY;
const nearTop = currentY < 80;
const scrollingDown = delta > 4;
const scrollingUp = delta < -4;
document.body.classList.toggle("nav-at-top", nearTop);
if (scrollingDown && !nearTop && !document.body.classList.contains("nav-open")) {
setNavVisible(false);
} else if (scrollingUp || nearTop) {
setNavVisible(true);
}
document.body.classList.toggle("rail-visible", !nearTop);
lastScrollY = currentY;
};
const activeObserver = new IntersectionObserver((entries) => {
const visible = entries
.filter((entry) => entry.isIntersecting)
.sort((a, b) => b.intersectionRatio - a.intersectionRatio)[0];
if (!visible) return;
const activeId = visible.target.id;
railLinks.forEach((link) => {
link.classList.toggle("active", link.getAttribute("href") === `#${activeId}`);
});
}, {
rootMargin: "-35% 0px -45% 0px",
threshold: [0.1, 0.25, 0.5]
});
sections.forEach((section) => activeObserver.observe(section.target));