/* bloo.app — Validation status rendered from the sanitized benchmark export. */
(function () {
const { Button, Badge, Card, Alert } = window.BlooAppDesignSystem_ab7292;
const { PRODUCT, LINKS, EXT, Icons, S, trackEvent } = window.Site;
const { useT } = window.I18n;
const { IconArrow, IconCheck, IconTarget } = Icons;
const DATA = window.BlooBenchmarkData;

const B = {
  hero: { background: 'linear-gradient(180deg, var(--blue-50) 0%, var(--surface-card) 100%)', paddingTop: 68, paddingBottom: 62 },
  inner: { display: 'flex', flexDirection: 'column', gap: 17, alignItems: 'flex-start', maxWidth: 800 },
  h1: { fontFamily: 'var(--font-display)', fontWeight: 500, fontSize: 48, lineHeight: 1.08, letterSpacing: '-.03em', color: 'var(--text-strong)', margin: 0 },
  lede: { fontSize: 18.5, lineHeight: 1.56, color: 'var(--text-body)', maxWidth: 680, margin: 0 },
  metrics: { display: 'grid', gridTemplateColumns: 'repeat(4, 1fr)', gap: 16 },
  metric: { fontFamily: 'var(--font-display)', fontWeight: 600, fontSize: 34, color: 'var(--brand)', letterSpacing: '-.02em' },
  grid3: { display: 'grid', gridTemplateColumns: 'repeat(3, 1fr)', gap: 20 },
  grid2: { display: 'grid', gridTemplateColumns: 'repeat(2, 1fr)', gap: 20 },
  mono: { fontFamily: 'var(--font-mono)', fontSize: 11, letterSpacing: '.08em', color: 'var(--text-subtle)', textTransform: 'uppercase' },
  progress: { height: 8, borderRadius: 999, background: 'var(--surface-sunken)', border: '1px solid var(--border-subtle)', overflow: 'hidden' },
};

function Hero() {
  const { t } = useT();
  React.useEffect(() => { trackEvent('view_benchmark'); }, []);
  return <section style={B.hero}><div style={{ ...S.container, ...B.inner }} className="site-container"><div style={{ display: 'flex', gap: 8, flexWrap: 'wrap' }}><Badge tone="brand" dot>{t('Validation in progress', 'Validação em andamento')}</Badge><Badge>{DATA.packVersion}</Badge></div><h1 style={B.h1} className="site-h1-hero">{t('What has been verified, what remains open, and what stable must prove.', 'O que foi verificado, o que continua pendente e o que a versão estável precisa provar.')}</h1><p style={B.lede}>{t('This page is generated from the benchmark manifest and publishes verified results only. The fixture suite and offline installer pass today; repeated live-tool scores and real-PR calibration are still pending.', 'Esta página é gerada a partir do manifesto do benchmark e publica apenas resultados verificados. A suíte de fixtures e o instalador offline estão aprovados; as pontuações repetidas nas ferramentas e a calibração em PRs reais ainda estão pendentes.')}</p><div style={{ display: 'flex', gap: 12, flexWrap: 'wrap' }}><Button as="a" href={LINKS.freeRepo} {...EXT} trailingIcon={<IconArrow />} onClick={() => trackEvent('click_free_repo', { from: 'benchmark' })}>{t('Run the adaptive starter', 'Rodar o starter adaptativo')}</Button><Button as="a" href="product-ai-code-review.html#cohort" variant="secondary" onClick={() => trackEvent('join_beta', { from: 'benchmark' })}>{t('Join the cohort', 'Participar da coorte')}</Button></div></div></section>;
}

function Snapshot() {
  const { t } = useT();
  const p = DATA.progress;
  const metrics = [[DATA.fixtures.defective, t('seeded defective diffs', 'diffs com defeitos plantados')], [DATA.fixtures.clean, t('clean diffs', 'diffs limpos')], [DATA.fixtures.installAndUpdate, t('install/update cases', 'casos de instalação/atualização')], [p.liveToolRunsRequired, t('planned repeated live runs', 'rodadas repetidas planejadas')]];
  return <section style={{ ...S.section, paddingTop: 56, paddingBottom: 56, background: 'var(--surface-sunken)', borderTop: '1px solid var(--border-subtle)', borderBottom: '1px solid var(--border-subtle)' }}><div style={S.container} className="site-container"><div style={B.metrics} className="site-grid-4">{metrics.map(([n, label]) => <Card key={label} padding="lg" style={{ textAlign: 'center' }}><div style={B.metric}>{n}</div><p style={{ ...S.cardBody, marginTop: 5 }}>{label}</p></Card>)}</div></div></section>;
}

function Method() {
  const { t } = useT();
  const cards = [
    [t('Seeded defective diffs', 'Diffs com defeitos plantados'), t('Each case declares the expected issue, minimum severity, rule basis, and whether the finding is required.', 'Cada caso declara o problema esperado, a severidade mínima, a base da regra e se o achado é obrigatório.')],
    [t('Clean diffs', 'Diffs limpos'), t('Known-good changes measure false positives, severity inflation, and whether the review invents work to appear thorough.', 'Mudanças sabidamente boas medem falsos positivos, inflação de severidade e se a revisão inventa trabalho para parecer completa.')],
    [t('Repeated tools and real PRs', 'Ferramentas repetidas e PRs reais'), t('Every fixture runs three times in Claude, Cursor, and Copilot. Ten human-scored real pull requests then test transfer beyond synthetic cases.', 'Cada fixture roda três vezes no Claude, Cursor e Copilot. Depois, dez pull requests reais avaliados por humanos testam a transferência além dos casos sintéticos.')],
  ];
  return <section style={S.section}><div style={S.container} className="site-container"><div style={S.sectionHead}><span style={S.eyebrow}>{t('METHOD', 'MÉTODO')}</span><h2 style={S.h2}>{t('A release gate, not a marketing comparison.', 'Um critério de release, não uma comparação de marketing.')}</h2><p style={S.sectionSub}>{t('The benchmark measures recall, precision, clean-diff noise, duplicate findings, and irrelevant adapter activation. It does not assume a specialized review always wins.', 'O benchmark mede recall, precisão, ruído em diffs limpos, achados duplicados e ativação de adaptadores irrelevantes. Ele não presume que uma revisão especializada sempre vence.')}</p></div><div style={B.grid3} className="site-grid-3">{cards.map(([title, body]) => <Card key={title} padding="lg"><h3 style={S.h3}>{title}</h3><p style={{ ...S.cardBody, marginTop: 10 }}>{body}</p></Card>)}</div></div></section>;
}

function Coverage() {
  const { t } = useT();
  return <section style={{ ...S.section, background: 'var(--surface-sunken)', borderTop: '1px solid var(--border-subtle)', borderBottom: '1px solid var(--border-subtle)' }}><div style={S.container} className="site-container"><div style={S.sectionHead}><span style={S.eyebrow}>{t('FIXTURE COVERAGE', 'COBERTURA DOS FIXTURES')}</span><h2 style={S.h2}>{t('The defective set spans the risks the router claims to recognize.', 'O conjunto com defeitos cobre os riscos que o roteador afirma reconhecer.')}</h2></div><div style={{ ...B.grid3, maxWidth: 920, margin: '0 auto' }} className="site-grid-3">{DATA.fixtures.categories.map(([category, count]) => <Card key={category} padding="lg" style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between', gap: 16 }}><span style={{ fontWeight: 600, color: 'var(--text-strong)' }}>{category}</span><Badge tone="brand">{count}</Badge></Card>)}</div></div></section>;
}

function Progress() {
  const { t } = useT();
  const p = DATA.progress;
  const rows = [
    [t('Pack structure and source policy', 'Estrutura do pack e política de fontes'), t('Passed', 'Aprovado'), 'success', t('Canonical layer, wrappers, allowlist, fixtures, and source policy validate.', 'Camada canônica, wrappers, lista permitida, fixtures e política de fontes validados.')],
    [t('Offline install/update simulation', 'Simulação offline de instalação/atualização'), t('Passed', 'Aprovado'), 'success', t('Conditional adapters, migration, hashes, ownership, and idempotency validate.', 'Adaptadores condicionais, migração, hashes, propriedade e idempotência validados.')],
    [t('Repeated live-tool runs', 'Rodadas repetidas nas ferramentas'), `${p.liveToolRunsCompleted} / ${p.liveToolRunsRequired}`, 'warning', t('Three runs per fixture in each supported tool remain open.', 'Três rodadas por fixture em cada ferramenta suportada continuam pendentes.')],
    [t('Human-scored real pull requests', 'Pull requests reais avaliados por humanos'), `${p.realPullRequestsCompleted} / ${p.realPullRequestsRequired}`, 'warning', t('False positives, misses, routing, and severity must be calibrated on real work.', 'Falsos positivos, omissões, roteamento e severidade precisam ser calibrados em trabalho real.')],
  ];
  return <section style={S.section}><div style={S.container} className="site-container"><div style={S.sectionHead}><span style={S.eyebrow}>{t('CURRENT PROGRESS', 'PROGRESSO ATUAL')}</span><h2 style={S.h2}>{t('Automated foundations pass. Product-quality gates remain open.', 'As bases automatizadas passam. Os critérios de qualidade do produto continuam abertos.')}</h2></div><div style={{ maxWidth: 920, margin: '0 auto', display: 'flex', flexDirection: 'column', gap: 12 }}>{rows.map(([label, value, tone, note]) => <Card key={label} padding="lg"><div style={{ display: 'grid', gridTemplateColumns: '1.2fr .45fr 1.35fr', gap: 18, alignItems: 'center' }} className="validation-row"><strong style={{ color: 'var(--text-strong)' }}>{label}</strong><Badge tone={tone}>{value}</Badge><span style={{ color: 'var(--text-muted)', fontSize: 14 }}>{note}</span></div></Card>)}</div></div></section>;
}

function Gates() {
  const { t } = useT();
  const g = DATA.releaseGates;
  const gates = [[`${Math.round(g.blockerRecall * 100)}%`, t('minimum seeded blocker recall', 'recall mínimo de bloqueadores plantados')], [`${Math.round(g.highSeverityPrecision * 100)}%`, t('minimum BLOCKER / SHOULD-FIX precision', 'precisão mínima de BLOCKER / SHOULD-FIX')], [`≤ ${g.medianCleanFalsePositives}`, t('median false positive per clean diff', 'falso positivo mediano por diff limpo')], [`≤ ${Math.round(g.maximumDuplicateRate * 100)}%`, t('duplicate-finding rate', 'taxa de achados duplicados')], [`${g.irrelevantAdapterActivations}`, t('irrelevant adapter activations', 'ativações de adaptadores irrelevantes')], [`${g.minimumRealPullRequests}`, t('human-scored real pull requests', 'pull requests reais avaliados por humanos')]];
  return <section style={{ ...S.section, background: 'var(--surface-sunken)', borderTop: '1px solid var(--border-subtle)' }}><div style={S.container} className="site-container"><div style={S.sectionHead}><span style={S.eyebrow}>{t('STABLE RELEASE GATES', 'CRITÉRIOS PARA RELEASE ESTÁVEL')}</span><h2 style={S.h2}>{t('Stable is a measured state, not a date.', 'Estável é um estado medido, não uma data.')}</h2></div><div style={B.grid3} className="site-grid-3">{gates.map(([value, label]) => <Card key={label} variant="raised" padding="lg" style={{ textAlign: 'center' }}><div style={B.metric}>{value}</div><p style={{ ...S.cardBody, marginTop: 6 }}>{label}</p></Card>)}</div></div></section>;
}

function Results() {
  const { t } = useT();
  const results = DATA.verifiedResults;
  return <section style={S.section}><div style={S.container} className="site-container"><div style={S.sectionHead}><span style={S.eyebrow}>{t('VERIFIED LIVE RESULTS', 'RESULTADOS AO VIVO VERIFICADOS')}</span><h2 style={S.h2}>{t('No result is published before the run is recorded.', 'Nenhum resultado é publicado antes de a rodada ser registrada.')}</h2></div>{results.length ? <div>{results.map((result) => <Card key={result.id} padding="lg"><h3 style={S.h3}>{result.title}</h3></Card>)}</div> : <div style={{ maxWidth: 820, margin: '0 auto' }}><Alert tone="warning" title={t('Live result table intentionally empty', 'Tabela de resultados ao vivo intencionalmente vazia')}>{t('Verified rows will appear only after the repeated tool runs record the model, tool, date, expected finding, actual finding, misses, false positives, and reviewer verdict.', 'Linhas verificadas aparecerão apenas depois que as rodadas repetidas registrarem modelo, ferramenta, data, achado esperado, achado real, omissões, falsos positivos e veredito do avaliador.')}</Alert></div>}<div style={{ display: 'flex', gap: 12, flexWrap: 'wrap', justifyContent: 'center', marginTop: 26 }}><Button as="a" href={LINKS.freeRepo} {...EXT} trailingIcon={<IconArrow />} onClick={() => trackEvent('click_free_repo', { from: 'benchmark_results' })}>{t('Inspect the public starter', 'Inspecionar o starter público')}</Button><Button as="a" href="product-ai-code-review.html#cohort" variant="secondary">{t('Help run the real-PR cohort', 'Ajudar na coorte de PRs reais')}</Button></div></div></section>;
}

function BenchmarkContent() { return <><Hero /><Snapshot /><Method /><Coverage /><Progress /><Gates /><Results /></>; }
window.Pages = window.Pages || {};
window.Pages.benchmark = { Content: BenchmarkContent, label: 'Benchmark' };
})();
