'use client'

export function FrameworkDistribution({ data }: { data: Record<string, number> }) {
  const total = Object.values(data).reduce((a, b) => a + b, 0)
  if (total === 0) return null

  const frameworkLabels: Record<string, string> = {
    go_test: 'Go Tests',
    pytest: 'Python (pytest)',
    jest: 'Jest (TS)',
    vitest: 'Vitest (SDK)',
    playwright: 'Playwright (E2E)',
    bqas_golden: 'BQAS Golden',
    bqas_rag: 'BQAS RAG',
    bqas_synthetic: 'BQAS Synthetic',
  }

  const frameworkColors: Record<string, string> = {
    go_test: 'bg-cyan-500',
    pytest: 'bg-yellow-500',
    jest: 'bg-blue-500',
    vitest: 'bg-orange-500',
    playwright: 'bg-purple-500',
    bqas_golden: 'bg-emerald-500',
    bqas_rag: 'bg-teal-500',
    bqas_synthetic: 'bg-amber-500',
  }

  return (
    <div className="space-y-3">
      {Object.entries(data)
        .sort((a, b) => b[1] - a[1])
        .map(([framework, count]) => (
          <div key={framework} className="flex items-center gap-3">
            <div className={`w-3 h-3 rounded-full ${frameworkColors[framework] || 'bg-slate-400'}`} />
            <span className="text-sm text-slate-600 flex-1">{frameworkLabels[framework] || framework}</span>
            <span className="text-sm font-medium text-slate-900">{count}</span>
            <span className="text-xs text-slate-400">({((count / total) * 100).toFixed(0)}%)</span>
          </div>
        ))}
    </div>
  )
}
