import Link from 'next/link'; import { Badge, ClaimBadge } from '@/components/ui/badge'; import { SourceBadge } from '@/components/ui/source-badge'; import { fmtInt, fmtPct } from '@/lib/format'; import type { PathChain } from '@/lib/graph-model'; const SOURCE_SLUG_BY_ID: Record = { 'CI-SOURCE-00000006': 'civic', 'CI-SOURCE-00000015': 'chembl', 'CI-SOURCE-00000016': 'openfda', 'CI-SOURCE-00000004': 'clinicaltrials', 'CI-SOURCE-00000008': 'gdc', 'CI-SOURCE-00000017': 'cbioportal' }; function Arrow() { return ( → ); } /** * One cancer → gene → variant → drug → approval → trials chain, readable as a sentence. Each hop * keeps its own claim category: cohort frequency (observed), CIViC predictive edge (curated), * approval (regulatory), trial count (observed). Missing hops say so — nothing is filled in. */ export function PathChainView({ chain, compact = false, sourceSlugs }: { chain: PathChain; compact?: boolean; sourceSlugs?: Map }) { const slugOf = (id: string) => sourceSlugs?.get(id) ?? SOURCE_SLUG_BY_ID[id] ?? id; const g = chain.gene; const freq = g.frequency != null && g.casesAffected != null && g.casesProfiled != null ? `${fmtPct(g.frequency, g.frequency >= 0.1 ? 0 : 1)} (${fmtInt(g.casesAffected)} / ${fmtInt(g.casesProfiled)} cases${g.cohorts > 1 ? `, largest of ${g.cohorts} cohorts` : ''})` : null; return (
  • {g.symbol} {chain.variant.name} {chain.drug.name} {chain.approval ? ( <> {chain.approval.authority} {chain.approval.jurisdiction} {chain.approval.approvalDate ? {chain.approval.approvalDate} : (date not published)} {chain.approval.tumorAgnostic && !chain.approval.cancerId ? · tumour-agnostic : null} ) : null} {chain.trials ? ( <> {fmtInt(chain.trials.active)} active / {fmtInt(chain.trials.total)} trials ) : null}

    {chain.edge.evidenceLevel ? ( level {chain.edge.evidenceLevel} ) : ( level not stated )} {chain.edge.direction ?? 'direction unknown'} · support {fmtInt(chain.edge.supportCount)} {chain.edge.sourceIds.map((s) => ( ))} {!compact ? ( <> · {freq ? {g.symbol} altered in {freq} : cohort frequency not yet available for {g.symbol} in this cancer} {chain.approval ? ( <> · {chain.approval.status} {chain.approval.cancerName ? ` for ${chain.approval.cancerName}` : ''} {chain.approval.total > 1 ? ` (${fmtInt(chain.approval.total)} approval records)` : ''} ) : ( <> · no approval record in this cancer )} {chain.edge.contextNames.length ? ( <> · context: {chain.edge.contextNames.slice(0, 3).join(', ')} {chain.edge.contextNames.length > 3 ? ` +${chain.edge.contextNames.length - 3}` : ''} ) : null} ) : null}

  • ); }