/* Realistic mock data for Consensio prototype */

const CONSENSIO_DATA = {
  user: {
    name: 'Dr. Lena Aldana',
    role: 'lab_director',
    org: 'Northpoint Genomics',
    avatar: 'LA',
  },
  stats: {
    activeCases: 142,
    pendingReview: 23,
    newPublications: 8,
    requestsThisWeek: 5,
    solvedThisMonth: 11,
    avgTimeToReport: '4.2d',
  },
  projects: [
    { id: 'rd-program', name: 'RD Program — Cohort 7', cases: 86, solved: 31, pending: 14, owner: 'L. Aldana', updated: '2h ago', status: 'active' },
    { id: 'undiag-peds', name: 'Undiagnosed Pediatric Network', cases: 42, solved: 9, pending: 6, owner: 'M. Otieno', updated: '5h ago', status: 'active' },
    { id: 'neuromuscular', name: 'Neuromuscular Consortium', cases: 28, solved: 12, pending: 3, owner: 'J. Park', updated: '1d ago', status: 'active' },
    { id: 'cardio-rd', name: 'Cardio-RD Pilot', cases: 14, solved: 4, pending: 2, owner: 'S. Vetrova', updated: '3d ago', status: 'paused' },
  ],
  cases: [
    {
      id: 'rowe-2024-018', family: 'Rowe', proband: 'F-018-01', sex: 'F', age: '7y',
      phenotype: 'Hypotonia, global developmental delay, dysmorphic features',
      hpo: 6, status: 'in_review', priority: 'high',
      flags: [
        { type: 'PAPER',   gene: 'KMT2D', journal: 'Nat Genet',  match: 'High',
          title: 'Frameshift variants in KMT2D produce truncated transcripts that escape NMD',
          excerpt: 'In this study of 27 probands, p.Glu835Glyfs*66 was observed in 3 unrelated individuals with atypical Kabuki features and preserved facial gestalt, expanding the loss-of-function spectrum…',
          pmid: '40128771' },
        { type: 'REQUEST', requester: 'R. Mahalingam', date: 'May 19',
          message: 'Need update on functional evidence by May 24 for family meeting.' },
      ],
      variants: 1842, candidates: 4,
      updated: '14 min ago', assigned: 'L. Aldana',
    },
    {
      id: 'chen-2024-031', family: 'Chen', proband: 'F-031-01', sex: 'M', age: '4y',
      phenotype: 'Epileptic encephalopathy, regression',
      hpo: 11, status: 'solved', priority: 'normal',
      flags: [],
      variants: 1241, candidates: 1,
      updated: '2d ago', assigned: 'M. Otieno',
    },
    {
      id: 'darrow-2024-022', family: 'Darrow', proband: 'F-022-01', sex: 'M', age: '12y',
      phenotype: 'Progressive ataxia, optic atrophy',
      hpo: 4, status: 'pending', priority: 'high',
      flags: [
        { type: 'TIME', months: 14 },
      ],
      variants: 2104, candidates: 7,
      updated: '6h ago', assigned: 'J. Park',
    },
    {
      id: 'okafor-2024-025', family: 'Okafor', proband: 'F-025-01', sex: 'F', age: '2y',
      phenotype: 'Skeletal dysplasia, short stature',
      hpo: 8, status: 'in_review', priority: 'normal',
      flags: [
        { type: 'PAPER', gene: 'COL2A1', journal: 'Am J Hum Genet', match: 'Med',
          title: 'Expanded phenotypic spectrum of COL2A1 missense variants',
          excerpt: 'Re-evaluation of 142 reported COL2A1 variants identifies a subset of missense changes associated with milder skeletal phenotypes…',
          pmid: '39911284' },
      ],
      variants: 998, candidates: 3,
      updated: '1d ago', assigned: 'L. Aldana',
    },
    {
      id: 'maeda-2024-019', family: 'Maeda', proband: 'F-019-01', sex: 'M', age: '9y',
      phenotype: 'Immunodeficiency, recurrent infections',
      hpo: 7, status: 'in_review', priority: 'normal',
      flags: [],
      variants: 1502, candidates: 5,
      updated: '3d ago', assigned: 'S. Vetrova',
    },
    {
      id: 'bracco-2024-027', family: 'Bracco', proband: 'F-027-01', sex: 'F', age: '5mo',
      phenotype: 'Hypoglycemia, hepatomegaly, lactic acidosis',
      hpo: 9, status: 'pending', priority: 'urgent',
      flags: [
        { type: 'REQUEST', requester: 'A. Tellez', date: 'May 19',
          message: 'NICU clinical team requesting expedited classification — patient stable but on supportive care.' },
        { type: 'TIME', months: 6 },
      ],
      variants: 1733, candidates: 6,
      updated: '32 min ago', assigned: 'L. Aldana',
    },
    {
      id: 'haddad-2024-029', family: 'Haddad', proband: 'F-029-01', sex: 'M', age: '3y',
      phenotype: 'Microcephaly, seizures, motor delay',
      hpo: 5, status: 'in_review', priority: 'normal',
      flags: [
        { type: 'PAPER', gene: 'WDR45', journal: 'Brain', match: 'Low',
          title: 'WDR45-related neurodegeneration spectrum',
          excerpt: 'Recent cases broaden the WDR45 phenotype to include early-onset seizures without iron deposition on initial MRI…',
          pmid: '39772015' },
        { type: 'TIME', months: 9 },
      ],
      variants: 1620, candidates: 4,
      updated: '4d ago', assigned: 'J. Park',
    },
  ],
  // Rowe family detail
  rowe: {
    id: 'rowe-2024-018',
    family: 'Rowe',
    proband: { id: 'F-018-01', label: 'Proband', sex: 'F', age: '7y 2mo', affected: true, sequenced: 'WGS' },
    members: [
      { id: 'F-018-02', label: 'Mother',  sex: 'F', age: '36y', affected: false, sequenced: 'WGS' },
      { id: 'F-018-03', label: 'Father',  sex: 'M', age: '38y', affected: false, sequenced: 'WGS' },
      { id: 'F-018-04', label: 'Sibling', sex: 'M', age: '4y',  affected: false, sequenced: '—' },
    ],
    phenotype: [
      { hpo: 'HP:0001263', term: 'Global developmental delay', onset: 'Infantile' },
      { hpo: 'HP:0001252', term: 'Hypotonia', onset: 'Congenital' },
      { hpo: 'HP:0000252', term: 'Microcephaly', onset: 'Congenital' },
      { hpo: 'HP:0001249', term: 'Intellectual disability', onset: 'Childhood' },
      { hpo: 'HP:0000218', term: 'High palate', onset: 'Congenital' },
      { hpo: 'HP:0000490', term: 'Deeply set eye', onset: 'Childhood' },
    ].filter(p => p.term),
    aiSummary: {
      headline: '4 candidate variants prioritized across 3 genes. Strongest signal: KMT2D (Kabuki syndrome).',
      generatedAt: '2026-05-20 09:14 UTC',
      model: 'Consensio Reasoner v3.2',
      points: [
        { tone: 'info', text: 'Proband phenotype overlaps Kabuki syndrome 1 (MIM #147920) at 87% HPO concordance (5/6 terms matched).' },
        { tone: 'paper', text: '2 new publications since last review (Nakamura 2026, Eldridge 2025) refining KMT2D loss-of-function spectrum in atypical presentations.' },
        { tone: 'warning', text: 'De novo status not yet confirmed for variant 1; parental sequencing complete but trio call awaiting analyst sign-off.' },
        { tone: 'request', text: 'Referring clinician (Dr. R. Mahalingam) requested update on functional evidence by May 24.' },
      ],
    },
  },
  // Variants for Rowe family
  variants: [
    {
      rank: 1, gene: 'KMT2D', hgvs: 'c.2504delT', protein: 'p.Glu835Glyfs*66',
      chrom: '12:49419024', zygosity: 'Heterozygous', inheritance: 'De novo (provisional)',
      acmg: 'Pathogenic', acmgCriteria: ['PVS1', 'PS2_Mod', 'PM2_Sup'],
      gnomad: 'Absent', cadd: 35, revel: 0.89,
      omim: 'MIM #147920', condition: 'Kabuki syndrome 1',
      papers: 12, newPapers: 2,
      aiScore: 0.94,
    },
    {
      rank: 2, gene: 'MYT1L', hgvs: 'c.1456G>A', protein: 'p.Gly486Ser',
      chrom: '2:1893015', zygosity: 'Heterozygous', inheritance: 'Maternal',
      acmg: 'Likely Pathogenic', acmgCriteria: ['PM2', 'PP3', 'PP2'],
      gnomad: '1/251,478', cadd: 28, revel: 0.71,
      omim: 'MIM #613084', condition: 'Intellectual developmental disorder, autosomal dominant 39',
      papers: 4, newPapers: 0,
      aiScore: 0.62,
    },
    {
      rank: 3, gene: 'KMT2D', hgvs: 'c.10618C>T', protein: 'p.Arg3540Cys',
      chrom: '12:49037842', zygosity: 'Heterozygous', inheritance: 'Paternal',
      acmg: 'VUS', acmgCriteria: ['PM2', 'BP4'],
      gnomad: '3/251,478', cadd: 22, revel: 0.41,
      omim: 'MIM #147920', condition: 'Kabuki syndrome 1',
      papers: 1, newPapers: 0,
      aiScore: 0.31,
    },
    {
      rank: 4, gene: 'ANKRD11', hgvs: 'c.3970dupA', protein: 'p.Ser1324Lysfs*23',
      chrom: '16:89348224', zygosity: 'Heterozygous', inheritance: 'Unknown',
      acmg: 'VUS', acmgCriteria: ['PVS1_Mod', 'BS1'],
      gnomad: '12/251,478', cadd: 31, revel: 0.55,
      omim: 'MIM #148050', condition: 'KBG syndrome',
      papers: 6, newPapers: 1,
      aiScore: 0.28,
    },
  ],
  // AI evidence for the selected variant (variant 1, KMT2D c.2504delT)
  evidence: [
    { id: 'ev-1', kind: 'paper', source: 'Nakamura et al. 2026', pmid: '40128771', year: 2026, new: true, aiGenerated: true,
      assertion: 'Frameshift variants in exon 11 of KMT2D produce truncated transcripts that escape NMD in 60% of patient samples.',
      relevance: 'Direct', score: 0.92,
      criteria: ['PVS1'],
      tags: ['ai_generated'] },
    { id: 'ev-2', kind: 'paper', source: 'Eldridge et al. 2025', pmid: '39842016', year: 2025, new: true, aiGenerated: true,
      assertion: 'p.Glu835Glyfs*66 reported in 3 unrelated probands with atypical Kabuki features and preserved facial gestalt.',
      relevance: 'Direct', score: 0.96,
      criteria: ['PS4_Mod', 'PP4'],
      tags: ['ai_generated', 'verified'] },
    { id: 'ev-3', kind: 'paper', source: 'Sobreira et al. 2023', pmid: '37412901', year: 2023, new: false, aiGenerated: false,
      assertion: 'Loss-of-function variants in KMT2D account for ~75% of Kabuki syndrome 1 diagnoses.',
      relevance: 'Background', score: 0.74,
      criteria: [],
      tags: ['verified'] },
    { id: 'ev-4', kind: 'db', source: 'ClinVar', id_label: 'VCV001284923', new: false, aiGenerated: false,
      assertion: 'Submitted 2× as Pathogenic, 0× as VUS/Benign. 2-star review status.',
      relevance: 'Direct', score: 0.88,
      criteria: ['PP5'],
      tags: ['verified'] },
    { id: 'ev-5', kind: 'db', source: 'gnomAD v4.1', id_label: 'chr12-49419024-CT-C', new: false, aiGenerated: false,
      assertion: 'Absent from 807,162 alleles. Constraint pLI = 1.00, LOEUF = 0.08.',
      relevance: 'Direct', score: 0.85,
      criteria: ['PM2_Sup'],
      tags: ['verified'] },
    { id: 'ev-6', kind: 'func', source: 'DECIPHER', id_label: 'patient 411293', new: false, aiGenerated: true,
      assertion: 'Similar phenotype overlap (5/6 HPO terms) reported in a patient with adjacent frameshift variant.',
      relevance: 'Supporting', score: 0.68,
      criteria: [],
      tags: ['ai_generated', 'needs_review'] },
    { id: 'ev-7', kind: 'paper', source: 'Hatori et al. 2022', pmid: '36118742', year: 2022, new: false, aiGenerated: true,
      assertion: 'Conflicting interpretation: one cohort reported reduced penetrance for adjacent frameshifts. Excluded by analyst.',
      relevance: 'Conflicting', score: 0.31,
      criteria: [],
      tags: ['ai_generated', 'excluded'] },
  ],

  // ACMG/AMP 2015 + 2019 refinements dictionary
  acmgCriteria: {
    // Pathogenic
    PVS1:    { tier: 'PVS', label: 'Null variant', desc: 'Loss-of-function variant (nonsense, frameshift, ±1/2 splice, exon deletion) in a gene where LOF is a known mechanism of disease.' },
    PS1:     { tier: 'PS',  label: 'Same amino acid change', desc: 'Same amino acid change as a previously established pathogenic variant regardless of nucleotide change.' },
    PS2:     { tier: 'PS',  label: 'De novo (confirmed paternity & maternity)', desc: 'De novo in a patient with the disease and no family history. Both parents tested.' },
    PS2_Mod: { tier: 'PS',  label: 'De novo (moderate)', desc: 'De novo with one parent confirmed; downgraded from PS2.' },
    PS3:     { tier: 'PS',  label: 'Functional studies', desc: 'Well-established in vitro or in vivo functional studies show a damaging effect.' },
    PS4:     { tier: 'PS',  label: 'Case-control prevalence', desc: 'Prevalence in affected individuals significantly increased over controls.' },
    PS4_Mod: { tier: 'PS',  label: 'Case-control (moderate)', desc: 'Multiple unrelated probands with same phenotype; insufficient for full PS4 weight.' },
    PM1:     { tier: 'PM',  label: 'Mutational hotspot', desc: 'Located in a mutational hotspot or critical functional domain.' },
    PM2:     { tier: 'PM',  label: 'Absent from controls', desc: 'Absent from controls in gnomAD/ExAC (or extremely low frequency for recessive disorders).' },
    PM2_Sup: { tier: 'PM',  label: 'Absent (supporting)', desc: 'Absent or ultra-rare in population databases; downgraded.' },
    PM3:     { tier: 'PM',  label: 'In trans with pathogenic', desc: 'For recessive disorders: in trans with a pathogenic variant.' },
    PM4:     { tier: 'PM',  label: 'Protein length change', desc: 'Protein length change due to in-frame indels in a non-repeat region.' },
    PM5:     { tier: 'PM',  label: 'Novel missense at same residue', desc: 'Novel missense change at an amino acid residue where a different pathogenic missense was seen.' },
    PM6:     { tier: 'PM',  label: 'Assumed de novo', desc: 'Assumed de novo (parental confirmation incomplete).' },
    PP1:     { tier: 'PP',  label: 'Cosegregation', desc: 'Cosegregation with disease in multiple affected family members.' },
    PP2:     { tier: 'PP',  label: 'Missense in low-tolerance gene', desc: 'Missense in a gene with low rate of benign missense variation.' },
    PP3:     { tier: 'PP',  label: 'Computational evidence', desc: 'Multiple computational lines of evidence support a deleterious effect.' },
    PP4:     { tier: 'PP',  label: 'Phenotype highly specific', desc: 'Patient phenotype highly specific for a disease with a single genetic etiology.' },
    PP5:     { tier: 'PP',  label: 'Reputable source reports pathogenic', desc: 'Reputable source recently reports variant as pathogenic without primary evidence.' },
    // Benign
    BA1:     { tier: 'BA',  label: 'Standalone — common', desc: 'Allele frequency > 5% in population databases.' },
    BS1:     { tier: 'BS',  label: 'Higher than expected', desc: 'Allele frequency greater than expected for the disorder.' },
    BS2:     { tier: 'BS',  label: 'Observed in healthy', desc: 'Observed in healthy adults at an unexpected rate.' },
    BS3:     { tier: 'BS',  label: 'Functional studies (benign)', desc: 'Well-established functional studies show no damaging effect.' },
    BS4:     { tier: 'BS',  label: 'Lack of segregation', desc: 'Lack of segregation in affected family members.' },
    BP1:     { tier: 'BP',  label: 'Missense where truncating expected', desc: 'Missense variant in a gene where only truncating variants cause disease.' },
    BP2:     { tier: 'BP',  label: 'Observed in trans with pathogenic', desc: 'Observed in trans with a pathogenic variant for a dominant disorder.' },
    BP3:     { tier: 'BP',  label: 'In-frame indel in repeat', desc: 'In-frame indel in a repetitive region without known function.' },
    BP4:     { tier: 'BP',  label: 'Computational evidence (benign)', desc: 'Multiple lines of computational evidence suggest no impact.' },
    BP5:     { tier: 'BP',  label: 'Alternate cause', desc: 'Variant found in a case with an alternate molecular basis for disease.' },
    BP6:     { tier: 'BP',  label: 'Reputable source reports benign', desc: 'Reputable source recently reports variant as benign without primary evidence.' },
    BP7:     { tier: 'BP',  label: 'Silent / non-conserved', desc: 'Silent variant with no predicted splice impact and not conserved.' },
  },

  // Tag taxonomy on evidence rows
  evidenceTags: {
    ai_generated: { label: 'AI-generated', tone: 'paper',   dot: true,   icon: 'bolt' },
    verified:     { label: 'Verified',     tone: 'success', icon: 'check' },
    needs_review: { label: 'Needs review', tone: 'warning', dot: true   },
    excluded:     { label: 'Excluded',     tone: 'danger',  icon: 'x'    },
  },

  // Pedigree as data — Pedigree component is purely data-driven
  pedigree: {
    nodes: [
      { id: 'F-018-02', label: 'Mother',  sex: 'F', affected: false, carrier: false, deceased: false, generation: 1, x: 70,  y: 50,  parents: [] },
      { id: 'F-018-03', label: 'Father',  sex: 'M', affected: false, carrier: true,  deceased: false, generation: 1, x: 170, y: 50,  parents: [] },
      { id: 'F-018-01', label: 'Proband', sex: 'F', affected: true,  carrier: false, deceased: false, generation: 2, x: 80,  y: 125, parents: ['F-018-02', 'F-018-03'], proband: true, age: '7y' },
      { id: 'F-018-04', label: 'Sibling', sex: 'M', affected: false, carrier: false, deceased: false, generation: 2, x: 160, y: 125, parents: ['F-018-02', 'F-018-03'], age: '4y' },
    ],
  },

  // ── Ensembl VEP analyst payload ────────────────────────────────────────────
  // Mirrors the per-variant shape emitted by genomixLLM's parse_vep CLI:
  //   { variant_id, chrom, pos, ref, alt, most_severe_consequence,
  //     primary: { ...transcript, predictions: {...} },
  //     transcripts: [ ... ], colocated: [ ... ],
  //     clinvar: {...}, gnomad_af, regulatory: [...] }
  // Keyed by variant.rank so the EvidenceDrawer can look up by selectedRank.
  vepDetails: {
    1: {
      variant_id: '12:49419024:CT:C',
      chrom: '12', pos: 49419024, ref: 'CT', alt: 'C',
      most_severe_consequence: 'frameshift_variant',
      primary: {
        gene_symbol: 'KMT2D', gene_id: 'ENSG00000167548',
        transcript_id: 'ENST00000301067', biotype: 'protein_coding',
        impact: 'HIGH', consequence_terms: ['frameshift_variant'],
        hgvsc: 'ENST00000301067.13:c.2504delT',
        hgvsp: 'ENSP00000301067.7:p.Glu835Glyfs*66',
        exon: '11/54', intron: null,
        canonical: true, mane_select: 'NM_003482.4',
        mane_plus_clinical: null, is_mane: true,
        predictions: {
          sift: null, polyphen: null,
          cadd_phred: 35.0, cadd_raw: 4.82,
          revel: 0.89,
          alphamissense: null, // not scored for frameshift
          spliceai: { ag: 0.01, al: 0.00, dg: 0.00, dl: 0.02 },
        },
      },
      transcripts: [
        { gene_symbol: 'KMT2D', transcript_id: 'ENST00000301067', biotype: 'protein_coding',
          impact: 'HIGH', consequence_terms: ['frameshift_variant'],
          hgvsc: 'c.2504delT', hgvsp: 'p.Glu835Glyfs*66',
          exon: '11/54', canonical: true, is_mane: true, mane_select: 'NM_003482.4' },
        { gene_symbol: 'KMT2D', transcript_id: 'ENST00000549743', biotype: 'protein_coding',
          impact: 'HIGH', consequence_terms: ['frameshift_variant'],
          hgvsc: 'c.2504delT', hgvsp: 'p.Glu835Glyfs*66',
          exon: '11/52', canonical: false, is_mane: false },
        { gene_symbol: 'KMT2D', transcript_id: 'ENST00000550266', biotype: 'nonsense_mediated_decay',
          impact: 'HIGH', consequence_terms: ['frameshift_variant', 'NMD_transcript_variant'],
          hgvsc: 'c.2504delT', hgvsp: 'p.Glu835Glyfs*66',
          exon: '11/53', canonical: false, is_mane: false },
      ],
      colocated: [
        { id: 'VCV001284923', source: 'clinvar',
          clin_sig: ['pathogenic'],
          pubmed: ['40128771', '39842016'],
          phenotype_or_disease: 1,
          frequencies: {} },
        { id: 'rs1554985432', source: 'dbsnp', clin_sig: [], pubmed: [], frequencies: { gnomad: 0.0 } },
      ],
      clinvar: { id: 'VCV001284923', source: 'clinvar', clin_sig: ['pathogenic'], pubmed: ['40128771', '39842016'], frequencies: {} },
      gnomad_af: 0.0,
      regulatory: [],
    },
    2: {
      variant_id: '2:1893015:G:A',
      chrom: '2', pos: 1893015, ref: 'G', alt: 'A',
      most_severe_consequence: 'missense_variant',
      primary: {
        gene_symbol: 'MYT1L', gene_id: 'ENSG00000186487',
        transcript_id: 'ENST00000310225', biotype: 'protein_coding',
        impact: 'MODERATE', consequence_terms: ['missense_variant'],
        hgvsc: 'ENST00000310225.7:c.1456G>A',
        hgvsp: 'ENSP00000310225.7:p.Gly486Ser',
        exon: '8/25', canonical: true, mane_select: 'NM_015025.4', is_mane: true,
        predictions: {
          sift: { prediction: 'deleterious', score: 0.02 },
          polyphen: { prediction: 'probably_damaging', score: 0.967 },
          cadd_phred: 28.1, cadd_raw: 3.71,
          revel: 0.71,
          alphamissense: { score: 0.84, class: 'likely_pathogenic' },
          spliceai: null,
        },
      },
      transcripts: [
        { gene_symbol: 'MYT1L', transcript_id: 'ENST00000310225', biotype: 'protein_coding',
          impact: 'MODERATE', consequence_terms: ['missense_variant'],
          hgvsc: 'c.1456G>A', hgvsp: 'p.Gly486Ser',
          exon: '8/25', canonical: true, is_mane: true, mane_select: 'NM_015025.4' },
        { gene_symbol: 'MYT1L', transcript_id: 'ENST00000409580', biotype: 'protein_coding',
          impact: 'MODERATE', consequence_terms: ['missense_variant'],
          hgvsc: 'c.1456G>A', hgvsp: 'p.Gly486Ser',
          exon: '8/24', canonical: false, is_mane: false },
      ],
      colocated: [
        { id: 'rs746302154', source: 'dbsnp', clin_sig: [], pubmed: [],
          frequencies: { gnomad: 0.0000040, afr: 0.0, amr: 0.0, nfe: 0.0000088 } },
      ],
      clinvar: null,
      gnomad_af: 0.0000040,
      regulatory: [],
    },
    3: {
      variant_id: '12:49037842:C:T',
      chrom: '12', pos: 49037842, ref: 'C', alt: 'T',
      most_severe_consequence: 'missense_variant',
      primary: {
        gene_symbol: 'KMT2D', gene_id: 'ENSG00000167548',
        transcript_id: 'ENST00000301067', biotype: 'protein_coding',
        impact: 'MODERATE', consequence_terms: ['missense_variant'],
        hgvsc: 'ENST00000301067.13:c.10618C>T',
        hgvsp: 'ENSP00000301067.7:p.Arg3540Cys',
        exon: '39/54', canonical: true, mane_select: 'NM_003482.4', is_mane: true,
        predictions: {
          sift: { prediction: 'tolerated_low_confidence', score: 0.18 },
          polyphen: { prediction: 'benign', score: 0.124 },
          cadd_phred: 22.4, cadd_raw: 2.91,
          revel: 0.41,
          alphamissense: { score: 0.31, class: 'ambiguous' },
          spliceai: null,
        },
      },
      transcripts: [
        { gene_symbol: 'KMT2D', transcript_id: 'ENST00000301067', biotype: 'protein_coding',
          impact: 'MODERATE', consequence_terms: ['missense_variant'],
          hgvsc: 'c.10618C>T', hgvsp: 'p.Arg3540Cys',
          exon: '39/54', canonical: true, is_mane: true, mane_select: 'NM_003482.4' },
      ],
      colocated: [
        { id: 'rs765442310', source: 'dbsnp', clin_sig: [], pubmed: [],
          frequencies: { gnomad: 0.0000119, afr: 0.0, amr: 0.0, eas: 0.0, nfe: 0.0000175 } },
      ],
      clinvar: null,
      gnomad_af: 0.0000119,
      regulatory: [],
    },
    4: {
      variant_id: '16:89348224:T:TA',
      chrom: '16', pos: 89348224, ref: 'T', alt: 'TA',
      most_severe_consequence: 'frameshift_variant',
      primary: {
        gene_symbol: 'ANKRD11', gene_id: 'ENSG00000167522',
        transcript_id: 'ENST00000301030', biotype: 'protein_coding',
        impact: 'HIGH', consequence_terms: ['frameshift_variant'],
        hgvsc: 'ENST00000301030.10:c.3970dupA',
        hgvsp: 'ENSP00000301030.5:p.Ser1324Lysfs*23',
        exon: '9/13', canonical: true, mane_select: 'NM_013275.6', is_mane: true,
        predictions: {
          sift: null, polyphen: null,
          cadd_phred: 31.0, cadd_raw: 4.21,
          revel: 0.55,
          alphamissense: null,
          spliceai: null,
        },
      },
      transcripts: [
        { gene_symbol: 'ANKRD11', transcript_id: 'ENST00000301030', biotype: 'protein_coding',
          impact: 'HIGH', consequence_terms: ['frameshift_variant'],
          hgvsc: 'c.3970dupA', hgvsp: 'p.Ser1324Lysfs*23',
          exon: '9/13', canonical: true, is_mane: true, mane_select: 'NM_013275.6' },
        { gene_symbol: 'ANKRD11', transcript_id: 'ENST00000564404', biotype: 'protein_coding',
          impact: 'HIGH', consequence_terms: ['frameshift_variant'],
          hgvsc: 'c.3970dupA', hgvsp: 'p.Ser1324Lysfs*23',
          exon: '9/12', canonical: false, is_mane: false },
      ],
      colocated: [
        { id: 'rs1567432891', source: 'dbsnp', clin_sig: [], pubmed: [],
          frequencies: { gnomad: 0.0000477 } },
      ],
      clinvar: null,
      gnomad_af: 0.0000477,
      regulatory: [],
    },
  },
};

window.CONSENSIO_DATA = CONSENSIO_DATA;

// VEP detail selector: look up parsed VEP record for a candidate variant by rank
window.getVepDetails = function getVepDetails(rank) {
  return (CONSENSIO_DATA.vepDetails || {})[rank] || null;
};

// ── Generate large evidence fixtures for the virtualized table ──────────────
// One row per (variant × paper/db reference). ~16 rows per variant → ~64 total.
(function() {
  const journals = ['Nat Genet', 'AJHG', 'Brain', 'JCI', 'Mol Cell', 'NEJM', 'Cell Rep', 'Hum Mol Genet', 'Hum Mutat', 'Genome Res', 'Cell', 'eLife'];
  const authorsPool = ['Nakamura', 'Eldridge', 'Sobreira', 'Hatori', 'Park', 'Tanaka', 'Mendez', 'O\u2019Connor', 'Patel', 'Singh', 'Chen', 'Aroujo', 'Bauer', 'Ito', 'Rosenberg', 'Krishnamurthy', 'Lopez', 'Wei', 'Eklund', 'Maes'];
  const mutTypes = ['Frameshift', 'Missense', 'Nonsense', 'Splice±2', 'In-frame del', 'Start loss', 'Synon. (splice)'];
  const inh = ['De novo', 'Maternal', 'Paternal', 'AR', 'AD', 'Unknown', 'XL'];
  const zyg = ['Het', 'Hom', 'Het/Het', 'Hemi'];
  const phenos = ['Global DD', 'Hypotonia', 'Seizures', 'Microcephaly', 'Ataxia', 'Optic atrophy', 'Dysmorphism', 'Hypoglycemia', 'Cardiac', 'Skeletal'];
  const assays = ['Yeast complem.', 'Patient fibroblasts', 'Mouse KO', 'CRISPR KD', 'iPSC neurons', 'Zebrafish CRISPR', 'Splicing reporter', '\u2014'];
  const matchScores = ['High', 'Medium', 'Low'];

  const rows = [];
  let id = 0;
  CONSENSIO_DATA.variants.forEach((v, vi) => {
    const N = 16; // rows per variant
    for (let i = 0; i < N; i++) {
      const k = vi * 23 + i * 17;
      const isPaper = (k % 6) !== 0;
      const a1 = authorsPool[(k * 3) % authorsPool.length];
      const a2 = authorsPool[(k * 5 + 7) % authorsPool.length];
      id++;
      rows.push({
        id: 'ev-' + id,
        kind: isPaper ? 'paper' : (k % 12 === 0 ? 'db' : 'func'),
        pmid: isPaper ? String(36000000 + (k * 17341) % 4000000) : null,
        source: isPaper ? `${a1} & ${a2}` : (k % 12 === 0 ? 'ClinVar' : 'DECIPHER'),
        journal: isPaper ? journals[(k + i) % journals.length] : null,
        year: 2018 + (k % 8),
        gene: v.gene,
        hgvs: v.hgvs,
        protein: v.protein,
        mutType: mutTypes[(k + i) % mutTypes.length],
        inheritance: inh[(k + vi) % inh.length],
        zygosity: zyg[(k) % zyg.length],
        phenotype: phenos[(k + i + vi) % phenos.length],
        assay: assays[(k * 3 + i) % assays.length],
        match: matchScores[(k + i * 2) % matchScores.length],
        matchPct: 0.50 + ((k * 11) % 50) / 100, // 0.50–0.99
        tags: (k % 4 === 0 ? ['ai_generated'] : (k % 4 === 1 ? ['verified'] : (k % 7 === 0 ? ['needs_review'] : (k % 11 === 0 ? ['excluded'] : [])))),
        variantRank: v.rank,
        notes: (k % 9 === 0) ? 1 : 0,
        new: (k % 13 === 0),
        aiGenerated: (k % 3 === 0),
      });
    }
  });
  CONSENSIO_DATA.evidenceFixtures = rows;
})();
