'use client'
import { useState } from 'react'
import type { ModelData } from '@/lib/types'
import { LabLogo } from '@/components/LabLogo'
import { creatorColor } from '@/lib/utils'
const STRIP_ROWS = [
{ key: 'luc' as const, label: 'Refusal Rate', invert: false, color: '#00C0F3', fmt: (v: number) => `${(v * 100).toFixed(0)}%` },
{ key: 'rag' as const, label: 'RAG Score', invert: false, color: '#F4333D', fmt: (v: number) => `${(v * 100).toFixed(0)}%` },
{ key: 'fairness' as const, label: 'Fairness', invert: true, color: '#BA2FA2', fmt: (v: number) => v.toFixed(3) },
]
function getAvg(m: ModelData, key: 'luc' | 'rag' | 'fairness'): number | null {
if (key === 'luc') return m.luc.avg
if (key === 'rag') return m.rag.avg
return m.fairness.avg
}
export default function ScoreDistribution({ models, maxFairness }: { models: ModelData[]; maxFairness: number }) {
const active = models.filter(m => !m.archived)
const [tooltip, setTooltip] = useState<{
x: number; y: number; model: string; val: string; creator: string
} | null>(null)
const VW = 800
const ROW_H = 120
const LBL_W = 85
const PAD_R = 85
const AXIS_W = VW - LBL_W - PAD_R
const DOT_R = 7
const VH = STRIP_ROWS.length * ROW_H
const TT_W = 168
const TT_H = 36
const VIOLIN_H = 40
const VIOLIN_BW = AXIS_W * 0.07
return (
{/* Logo overlays — one per row for the hovered model */}
{tooltip && STRIP_ROWS.map((row, ri) => {
const m = active.find(m => m.model === tooltip.model)
if (!m) return null
const val = getAvg(m, row.key)
if (val === null) return null
const rawMax = row.key === 'fairness' ? maxFairness : 1
const pct = row.invert ? 1 - val / rawMax : val / rawMax
const cx = LBL_W + pct * AXIS_W
const yMid = ri * ROW_H + ROW_H / 2
const pctX = cx / VW * 100
const pctY = yMid / VH * 100
return (
)
})}
)
}