/* Aligned benchmarks renderer. Plain JS, no dependencies. Reads window.BENCH_DATA from data.js. */ (function () { "use strict"; var D = window.BENCH_DATA; var app = document.getElementById("app"); var tip = document.getElementById("tooltip"); if (!D || !app) return; var VENDORS = ["openai", "anthropic", "google", "xai", "meta", "mistral", "deepseek", "qwen", "groq", "other"]; var MARK = "./sidebar-logo-a.svg"; var WORDMARK = "./aligned-ai-lockup-no-beta-54.png"; function esc(s) { return String(s == null ? "" : s).replace(/[&<>"']/g, function (c) { return { "&": "&", "<": "<", ">": ">", '"': """, "'": "'" }[c]; }); } function fmt(v) { return v === 100 || v === 0 ? v + "%" : Number(v).toFixed(1) + "%"; } function vendorLogo(v) { return "./" + (VENDORS.indexOf(v) >= 0 ? v : "other") + ".png"; } function hostOf(u) { try { return new URL(u).hostname.replace(/^www\./, ""); } catch (e) { return u; } } // Only boards with a real Aligned score are rendered. pending:true boards stay hidden. var boards = D.boards.filter(function (b) { return !b.pending && b.aligned && typeof b.aligned.score === "number" && isFinite(b.aligned.score); }); var byId = {}; boards.forEach(function (b) { byId[b.id] = b; }); // Rows for a board: Aligned plus any cited competitors, sorted honestly by score. function rows(b) { var hib = b.higherIsBetter !== false; var list = [{ model: "Aligned AI", vendor: "aligned", score: b.aligned.score, aligned: true }]; (b.competitors || []).forEach(function (c) { if (c && typeof c.score === "number" && isFinite(c.score) && c.source) list.push(c); }); list.sort(function (x, y) { return hib ? y.score - x.score : x.score - y.score; }); return list; } // "#N of M" (competition ranking: ties share a rank). Only when real competitors exist. function rank(b) { var r = rows(b); if (r.length < 2) return null; var hib = b.higherIsBetter !== false, a = b.aligned.score; var better = r.filter(function (x) { return !x.aligned && (hib ? x.score > a : x.score < a); }).length; return { n: b.aligned.rank || (better + 1), of: Math.max(r.length, b.fieldSize || 0) }; } function tag(cat) { var c = D.categories[cat] || {}; return '' + '' + esc(cat) + ""; } function chart(b) { var r = rows(b), rk = rank(b), hasComp = r.length > 1; var hib = b.higherIsBetter !== false; var list = r.map(function (x) { var n = x.aligned ? (rk ? rk.n : 1) : (typeof x.rank === "number" ? x.rank : 1 + r.filter(function (y) { return hib ? y.score > x.score : y.score < x.score; }).length); var w = Math.max(0, Math.min(100, x.score)); var tip = x.aligned ? 'data-tip-model="Aligned AI" data-tip-score="' + esc(fmt(x.score)) + '" data-tip-src="' + esc(b.aligned.sample || "Measured " + D.meta.measured) + '"' : 'data-tip-model="' + esc(x.model) + '" data-tip-score="' + esc(fmt(x.score)) + '" data-tip-src="' + esc("Source: " + (x.sourceLabel || hostOf(x.source))) + '"'; return '
  • ' + '#' + n + '' + '' + '' + esc(x.model) + (x.lab && !x.aligned ? '' + esc(x.lab) + '' : '') + '' + '' + '' + esc(fmt(x.score)) + '
  • '; }).join(""); var pendingSlot = hasComp ? "" : '
    Competitor scores pending
    '; return '
    ' + '
    ' + esc(b.unit) + (hib ? " · higher is better" : " · lower is better") + "" + (rk ? '#' + rk.n + " of " + rk.of + "" : "") + "
    " + (hasComp ? '
      ' + list + '
    ' : pendingSlot) + (rk && rk.of > r.length ? '

    Showing ' + r.length + ' of ' + rk.of + ' ranked models.

    ' : '') + "
    "; } function card(b) { var a = b.aligned, rk = rank(b), L = b.links || {}; var prov = ["Measured " + esc(D.meta.measured)]; if (a.sample) prov.push(esc(a.sample)); if (a.runId) prov.push("run " + esc(a.runId)); var links = []; if (L.dataset) links.push('' + esc(L.datasetLabel || "Dataset") + ""); if (L.paper) links.push('' + esc(L.paperLabel || "Paper") + ""); (L.extra || []).forEach(function (e) { links.push('' + esc(e.label) + ""); }); return '
    ' + '

    ' + esc(b.name) + "

    " + tag(b.category) + "
    " + '

    ' + esc(b.description) + "

    " + chart(b) + '
    Aligned AI' + esc(fmt(a.score)) + "" + (rk ? "· #" + rk.n + " of " + rk.of + "" : "") + ((b.competitors || []).length ? "" : 'Competitor scores pending') + "
    " + '
    ' + links.join(" · ") + "
    " + "
    "; } function hero() { var m = D.meta; var stats = m.headlineStats ? m.headlineStats.slice(0, 5).map(function (s) { return '' + '
    ' + esc(s.label) + "
    " + '
    ' + esc(s.value) + "
    " + (s.detail ? '
    ' + esc(s.detail) + "
    " : "") + "
    "; }).join("") : (m.headlineBoards || []).map(function (id) { return byId[id]; }).filter(Boolean).slice(0, 4).map(function (b) { var rk = rank(b); return '' + '
    ' + esc(b.name) + "
    " + '
    ' + (rk ? "#" + rk.n + " · " : "") + esc(fmt(b.aligned.score)) + "
    " + '
    ' + (b.aligned.sample ? esc(b.aligned.sample) : "Measured " + esc(m.measured)) + "
    "; }).join(""); var withComp = boards.filter(function (b) { return (b.competitors || []).length; }).length; var meta = ["Measured " + m.measured, boards.length + " boards", "Official graders", "Scores from Aligned AI's production pipeline", withComp ? withComp + " boards with competitor rankings" : "Competitor scores pending"]; return '
    ' + '
    Aligned AI' + "

    " + esc(m.title) + '

    ' + esc(m.badge) + "" + (m.preview ? 'Preview' : "") + "
    " + '
    ' + stats + "
    " + "
    "; } function strengths() { var items = (D.meta.strengths || []).filter(function (s) { return byId[s.id]; }).slice(0, 3); if (!items.length) return { html: "", ids: [] }; var html = '

    Where Aligned AI is strong

    ' + "

    Where Aligned AI ranks at or near the top of recent models.

    " + '
    ' + items.map(function (s) { var b = byId[s.id], rk = rank(b); return '

    ' + (rk ? "#" + rk.n + " of " + rk.of + " · " : "") + esc(fmt(b.aligned.score)) + " · " + esc(b.name) + "" + esc(s.why) + "

    " + card(b) + "
    "; }).join("") + "
    "; return { html: html, ids: items.map(function (s) { return s.id; }) }; } var state = { cat: "all" }; function suite(strengthIds) { var cats = []; boards.forEach(function (b) { if (cats.indexOf(b.category) < 0) cats.push(b.category); }); var order = Object.keys(D.categories); cats.sort(function (a, b) { return order.indexOf(a) - order.indexOf(b); }); var chips = '" + cats.map(function (c) { var n = boards.filter(function (b) { return b.category === c; }).length; return '"; }).join(""); // "All" shows every board except the three featured above (same as the previous page); a category shows all of its boards. var list = state.cat === "all" ? boards.filter(function (b) { return strengthIds.indexOf(b.id) < 0; }) : boards.filter(function (b) { return b.category === state.cat; }); return '

    Full suite

    ' + "

    Every scored board. The three featured above appear under their category filters. Each card states its sample size and shows its run ID, with links to the dataset and paper.

    " + '
    ' + chips + "
    " + '
    ' + list.map(card).join("") + "
    "; } function costSection() { var C = D.cost; if (!C) return ""; var all = [C.aligned]; C.groups.forEach(function (g) { g.rows.forEach(function (r) { all.push(r[2]); }); }); var max = Math.max.apply(null, all); function money(v) { return "$" + v.toFixed(5); } function row(name, vendor, v, isA) { return '' + esc(name) + '' + '' + '' + money(v) + '$' + (v * 1000).toFixed(2) + '' + '' + (isA ? "\u2014" : (v / C.aligned < 10 ? (v / C.aligned).toFixed(1) : Math.round(v / C.aligned)) + "\u00d7") + ''; } var body = C.groups.map(function (g, i) { return '' + esc(g.name) + '' + (i === 0 ? row("Aligned AI", "aligned", C.aligned, true) : "") + g.rows.map(function (r) { return row(r[0], r[1], r[2], false); }).join(""); }).join(""); return '

    ' + esc(C.title) + '[1]

    ' + esc(C.summary) + '

    ' + '
    ' + esc(C.explainer) + '
    ' + '' + body + '
    ModelPer answerPer 1,000
    answers
    vs.
    Aligned AI
    ' + '

    ' + esc(C.footnote) + '

    '; } function method() { return '

    Methodology

      ' + (D.meta.methodology || []).map(function (p) { return "
    1. " + esc(p) + "
    2. "; }).join("") + "
    "; } function footer() { return ''; } function render() { var st = strengths(); app.innerHTML = hero() + st.html + suite(st.ids) + costSection() + method() + footer(); } render(); // Chip filter (event delegation survives re-render). app.addEventListener("click", function (e) { var chip = e.target.closest(".chip"); if (chip) { state.cat = chip.getAttribute("data-cat"); var st = strengths(); var old = document.getElementById("suite"); var tmp = document.createElement("div"); tmp.innerHTML = suite(st.ids); old.replaceWith(tmp.firstChild); return; } var jump = e.target.closest("[data-jump]"); if (jump) { var el = document.getElementById("board-" + jump.getAttribute("data-jump")); if (el) { e.preventDefault(); el.scrollIntoView({ behavior: "smooth", block: "start" }); el.classList.add("flash"); setTimeout(function () { el.classList.remove("flash"); }, 1800); } } }); // Bar tooltip. function showTip(col) { tip.innerHTML = "" + esc(col.getAttribute("data-tip-model")) + ' ' + esc(col.getAttribute("data-tip-score")) + "" + '' + esc(col.getAttribute("data-tip-src")) + ""; var bar = col.querySelector(".bar").getBoundingClientRect(); tip.hidden = false; tip.style.left = Math.max(140, Math.min(window.innerWidth - 140, bar.left + bar.width / 2)) + "px"; tip.style.top = bar.top + "px"; requestAnimationFrame(function () { tip.classList.add("show"); }); } function hideTip() { tip.classList.remove("show"); } app.addEventListener("mouseover", function (e) { var c = e.target.closest(".lb-row"); if (c) showTip(c); }); app.addEventListener("mouseout", function (e) { var c = e.target.closest(".lb-row"); if (c && !c.contains(e.relatedTarget)) hideTip(); }); app.addEventListener("focusin", function (e) { var c = e.target.closest(".lb-row"); if (c) showTip(c); }); app.addEventListener("focusout", hideTip); window.addEventListener("scroll", hideTip, { passive: true }); })();