import { cn } from '@/lib/cn'; import type { Comparability, IdentityConfidence } from '@/lib/types'; import { COMPARABILITY_LABEL, IDENTITY_LABEL, opennessLabel, TRUST_LONG, trustShort } from './shared'; const base = 'inline-flex items-center gap-1 whitespace-nowrap rounded-[3px] px-1.5 py-[1px] text-[11px] font-medium leading-4 tracking-wide'; const TRUST_CLS: Record = { 'official-benchmark': 'text-tier-1 bg-positive-soft', 'peer-reviewed': 'text-tier-1 bg-positive-soft', 'independent-evaluator': 'text-tier-2 bg-accent-soft', 'official-model-card': 'text-tier-3 bg-warning-soft', community: 'text-tier-3 bg-warning-soft', unverified: 'text-tier-4 bg-surface-2', }; /** Trust level of a benchmark row (who produced the score). */ export function TrustBadge({ level, label, className }: { level: string | null | undefined; label?: string | null; className?: string }) { if (!level) return null; return ( {trustShort(level, label)} ); } const COMP_CLS: Record = { comparable: 'text-positive bg-positive-soft', 'partially-comparable': 'text-warning bg-warning-soft', 'not-comparable': 'text-danger bg-danger-soft' }; /** Comparability of a row vs the group leader (or of a compare dimension). `reasons` go in the title. */ export function ComparabilityBadge({ level, reasons, className, short = false }: { level: Comparability | string | null | undefined; reasons?: string[]; className?: string; short?: boolean }) { if (!level) return null; const l = level as Comparability; const text = COMPARABILITY_LABEL[l] ?? level; return ( {short ? text.replace('Partially comparable', 'Partial').replace('Not comparable', 'Not comp.') : text} ); } const ID_CLS: Record = { high: 'text-positive bg-positive-soft', medium: 'text-warning bg-warning-soft', low: 'text-danger bg-danger-soft' }; /** identity_confidence of a model row: how sure AI Atlas is that this entry is one real model release. */ export function IdentityBadge({ level, className, hideHigh = true }: { level: IdentityConfidence | string | null | undefined; className?: string; hideHigh?: boolean }) { if (!level || (hideHigh && level === 'high')) return null; const l = level as IdentityConfidence; return ( {IDENTITY_LABEL[l] ?? level} ); } /** Artifact kind chip (checkpoint · quantization · conversion · packaging). */ export function ArtifactKindChip({ kind, className }: { kind: string | null | undefined; className?: string }) { if (!kind) return null; return {kind}; } /** Small config chip; task keys read stronger than condition keys. */ export function ConfigChipEl({ k, v, kind, className }: { k: string; v: string; kind: 'task' | 'condition' | 'other'; className?: string }) { return ( {k} {v} ); } /** Yes / No / — (unknown) for licence and openness dimensions. */ export function Tri({ v, yes = 'Yes', no = 'No' }: { v: boolean | null | undefined; yes?: string; no?: string }) { if (v === true) return {yes}; if (v === false) return {no}; return ( — ); } const OPEN_CLS: Record = { 'open-source': 'text-positive bg-positive-soft', 'open-weights': 'text-positive bg-positive-soft', 'restricted-weights': 'text-warning bg-warning-soft', restricted: 'text-warning bg-warning-soft', proprietary: 'text-ink-2 bg-surface-2', unknown: 'text-ink-3 bg-surface-2' }; /** Openness chip with the 1.1 ontology labels (Open source · Open weights · Restricted weights · Closed). */ export function OpennessChip({ openness, label, className }: { openness: string | null | undefined; label?: string | null; className?: string }) { if (!openness) return null; return {label ?? opennessLabel(openness)}; }