(function () { "use strict"; function loadEmbeddedData() { var el = document.getElementById("page-data"); if (!el) { throw new Error("Missing #page-data JSON script element"); } return JSON.parse(el.textContent); } function escapeHtml(str) { return String(str) .replace(/&/g, "&") .replace(//g, ">"); } function renderTwoConditionsChart(comp) { var svg = document.getElementById("two-conditions-svg"); if (!svg || !comp) return; svg.innerHTML = ""; var steps = comp.sampled_steps; var rVerdicts = comp.reasoning.verdicts; var dVerdicts = comp.direct.verdicts; var W = 860; var H = 300; var padL = 95; var padR = 36; var padT = 32; var padB = 48; var plotW = W - padL - padR; var plotH = H - padT - padB; var yLevels = { null: padT + plotH * 0.82, A: padT + plotH * 0.48, C: padT + plotH * 0.14, }; var ns = "http://www.w3.org/2000/svg"; var yLabels = [ { key: "C", label: "Verdict C (gold)" }, { key: "A", label: "Verdict A" }, { key: "null", label: "None (masked)" }, ]; yLabels.forEach(function (row) { var y = yLevels[row.key]; var line = document.createElementNS(ns, "line"); line.setAttribute("x1", String(padL)); line.setAttribute("x2", String(W - padR)); line.setAttribute("y1", String(y)); line.setAttribute("y2", String(y)); line.setAttribute("stroke", "#cbd5e1"); line.setAttribute("stroke-dasharray", row.key === "C" ? "none" : "4,4"); svg.appendChild(line); var txt = document.createElementNS(ns, "text"); txt.setAttribute("x", String(padL - 10)); txt.setAttribute("y", String(y + 4)); txt.setAttribute("text-anchor", "end"); txt.setAttribute("fill", row.key === "C" ? "#047857" : "#475569"); txt.setAttribute("font-weight", row.key === "C" ? "600" : "400"); txt.setAttribute("font-size", "11.5"); txt.textContent = row.label; svg.appendChild(txt); }); function xForStep(stepVal) { return padL + (stepVal / 255) * plotW; } steps.forEach(function (st) { var x = xForStep(st); var tick = document.createElementNS(ns, "line"); tick.setAttribute("x1", String(x)); tick.setAttribute("x2", String(x)); tick.setAttribute("y1", String(padT + plotH)); tick.setAttribute("y2", String(padT + plotH + 5)); tick.setAttribute("stroke", "#94a3b8"); svg.appendChild(tick); var lbl = document.createElementNS(ns, "text"); lbl.setAttribute("x", String(x)); lbl.setAttribute("y", String(H - 18)); lbl.setAttribute("text-anchor", "middle"); lbl.setAttribute("fill", "#475569"); lbl.setAttribute("font-size", "11"); lbl.textContent = String(st); svg.appendChild(lbl); }); var axisTitle = document.createElementNS(ns, "text"); axisTitle.setAttribute("x", String(padL + plotW / 2)); axisTitle.setAttribute("y", String(H - 3)); axisTitle.setAttribute("text-anchor", "middle"); axisTitle.setAttribute("fill", "#475569"); axisTitle.setAttribute("font-size", "11.5"); axisTitle.textContent = "Denoising step (0 to 255, sampled every 16 steps)"; svg.appendChild(axisTitle); function drawSeries(verdicts, color, yOffset, seriesLabel) { var pts = []; for (var i = 0; i < steps.length; i++) { var k = verdicts[i] === null ? "null" : String(verdicts[i]); var x = xForStep(steps[i]); var y = yLevels[k] + yOffset; pts.push(x.toFixed(1) + "," + y.toFixed(1)); } var poly = document.createElementNS(ns, "polyline"); poly.setAttribute("fill", "none"); poly.setAttribute("stroke", color); poly.setAttribute("stroke-width", "2.6"); poly.setAttribute("points", pts.join(" ")); svg.appendChild(poly); for (var j = 0; j < steps.length; j++) { var key = verdicts[j] === null ? "null" : String(verdicts[j]); var cx = xForStep(steps[j]); var cy = yLevels[key] + yOffset; var c = document.createElementNS(ns, "circle"); c.setAttribute("cx", cx.toFixed(1)); c.setAttribute("cy", cy.toFixed(1)); c.setAttribute("r", "4.8"); c.setAttribute("fill", color); c.setAttribute("stroke", "#ffffff"); c.setAttribute("stroke-width", "1.5"); c.style.cursor = "pointer"; (function (idx) { c.addEventListener("click", function () { var slider = document.getElementById("sample-step-slider"); if (slider) { slider.value = String(idx); updateStepInspector(comp, idx); } }); })(j); var title = document.createElementNS(ns, "title"); title.textContent = seriesLabel + " | step " + steps[j] + ": verdict=" + (verdicts[j] === null ? "None" : verdicts[j]); c.appendChild(title); svg.appendChild(c); } } drawSeries(dVerdicts, "#0284c7", -4, "Direct (Mercury_7175875)"); drawSeries(rVerdicts, "#ea580c", 4, "Reasoning (Mercury_LBS10610)"); } function updateStepInspector(comp, sampleIndex) { var idx = Math.max(0, Math.min(comp.sampled_steps.length - 1, Number(sampleIndex) || 0)); var stepNum = comp.sampled_steps[idx]; document.getElementById("sample-step-label").textContent = String(stepNum); var rPred = comp.reasoning.verdicts[idx]; var dPred = comp.direct.verdicts[idx]; document.getElementById("reasoning-step-verdict").textContent = "Verdict: " + (rPred === null ? "None" : rPred); document.getElementById("direct-step-verdict").textContent = "Verdict: " + (dPred === null ? "None" : dPred); document.getElementById("reasoning-step-text").textContent = comp.reasoning.texts[idx]; document.getElementById("direct-step-text").textContent = comp.direct.texts[idx]; } function renderResultsTable(rows) { var tbody = document.getElementById("results-64-tbody"); if (!tbody) return; tbody.innerHTML = ""; rows.forEach(function (r) { var tr = document.createElement("tr"); tr.innerHTML = "
" +
escapeHtml(r.condition) +
"" +
escapeHtml(c.label) +
"