import { ArrowDown, ArrowRight, CornerLeftUp, RotateCcw } from 'lucide-react' import type { ReactNode } from 'react' import { boxState } from '@/lib/architecture' import { SERIES } from '@/lib/chart' import type { ArchBox, ArchDiagram, SystemId } from '@/lib/types' import { cn } from '@/lib/utils' /** The chapter's diagram, drawn by hand (owner, 9d redo: a few boxes, no crossing lines, * one level of detail per diagram). `lit`: the boxes the step being read talks about, * or null when no step is active (nothing dimmed). */ export function Diagram({ diagram, lit }: { diagram: ArchDiagram; lit: string[] | null }) { if (diagram.kind === 'grid') return const b = (id: string, className?: string) => switch (diagram.kind) { case 'documents': return (
{['oap', 'opcf', 'laws'].map((id) => b(id))}
{b('corpus', 'mx-auto w-2/3')}
) case 'prepare': return ( {b('docs', 'mx-auto w-1/2')} {b('parse', 'mx-auto w-1/2')}
System A {b('windows')}
Systems B and C {b('sections')} {b('refs')}
{b('index', 'mx-auto w-1/2')}
) case 'answer': return ( {b('passages', 'mx-auto w-2/3')} {b('answer', 'mx-auto w-2/3')}
{b('check')} {b('retry')}
{b('reply', 'mx-auto w-2/3')}
) case 'measure': return (
{b('tuning')} {b('heldout')}

tunes the systems

{b('grading')} {b('stats')} {b('results')}
) } } /** System A | B | C as aligned columns, the same steps on the same rows (small * multiples): a step a system does not have is an empty dashed slot, so the * differences show at a glance. A row lights up when the step being read names it. */ function EvidenceGrid({ diagram, lit }: { diagram: Extract; lit: string[] | null }) { const systems: SystemId[] = ['a', 'b', 'c'] return (
{systems.map((s) => (
{diagram.columns[s].title} {diagram.columns[s].name}
))} {diagram.rows.map((row) => { const state = boxState(row.id, lit) return (
{row.label} {systems.map((s) => { const cell = row.cells[s] return cell ? ( ) : (
—
) })}
) })} Final test {systems.map((s) => (
{diagram.results[s].accuracy} correct · {diagram.results[s].time}
))}
) } function Box({ box, state, className, compact, again }: { box: ArchBox; state: 'lit' | 'dim' | 'plain'; className?: string; compact?: boolean; again?: boolean }) { return (
{again && } {box.title} {box.sub && {box.sub}}
) } function Stack({ children }: { children: ReactNode }) { return
{children}
} function Down() { return (
) } function Tag({ children }: { children: ReactNode }) { return

{children}

}