"use client"; import * as React from "react"; import { Coins, Timer, Trophy, Type } from "lucide-react"; import { ProviderIcon } from "@/components/brand/provider-icon"; import { Badge } from "@/components/ui/badge"; import { criterionById, type Criterion, type WinnerResult } from "@/lib/arena/scoring"; import { formatDelta } from "@/lib/arena/metrics"; import { cn } from "@/lib/utils"; import { BlindAvatar } from "./blind"; interface Props { winner: WinnerResult; name: string; provider: string | null; /** Blind Arena, identity still hidden → neutral avatar and letter label. */ hidden?: boolean; blindIndex?: number; customCriteria?: Criterion[]; showCosts?: boolean; className?: string; } /** * Arena Winner card: shown once every response is final and at least one vote exists. * Most criteria won; ties go to the fastest first token. Deltas compare the winner with the mean of the others. */ export function WinnerCard({ winner, name, provider, hidden, blindIndex = 0, customCriteria = [], showCosts = true, className }: Props) { const criteria = winner.criteriaWon.map((id) => criterionById(id, customCriteria)); const d = winner.deltas; const better = (v: number | null) => (v === null ? null : v < 0); return (

Arena winner

{hidden ? : }

{name}

Won {criteria.length} of your criteri{criteria.length === 1 ? "on" : "a"} {winner.tieBreak === "fastest" ? " — tie broken by time to first token" : winner.tieBreak === "order" ? " — tie broken by order" : ""}.

    {criteria.map((c) => (
  • {c.label}
  • ))}
{d.others > 0 ? (
{showCosts ? } label="Δ cost" value={formatDelta(d.costUsd, "usd")} good={better(d.costUsd)} hint="vs. others" /> : null} } label="Δ TTFT" value={formatDelta(d.ttftMs, "ms")} good={better(d.ttftMs)} hint="vs. others" /> } label="Δ output" value={formatDelta(d.outputTokens, "tokens")} good={null} hint="vs. others" />
) : null}
); } function Delta({ icon, label, value, good, hint }: { icon: React.ReactNode; label: string; value: string; good: boolean | null; hint: string }) { return (
{icon} {label}
{value}
{hint}
); }