import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table"
import { HF_RELS, type Lineage, type Rel } from "@/lib/types"
import { relName, T } from "@/lib/i18n"
import { num as fmt, full } from "@/lib/format"
import { RelDot, relColor } from "@/components/rel"
/**
* Community models by type next to what Hugging Face's model tree shows. HF has only four types,
* so those come first with their own subtotal; the types HF has no place for follow, then the
* total. Types with nothing in them are left out.
*/
export function RelationTable({ L, order }: { L: Lineage; order: Rel[] }) {
const b = L.by_relation
const hfRels = HF_RELS.filter((r) => b[r].n > 0 || (L.hf_tree[r] ?? 0) > 0)
const extra = order.filter((r) => !HF_RELS.includes(r) && b[r].n > 0)
const max = Math.max(...order.map((r) => b[r].n))
const sum = (rs: Rel[], k: "n" | "dl30" | "dlall") => rs.reduce((a, r) => a + b[r][k], 0)
const hfSum = HF_RELS.reduce((a, r) => a + (L.hf_tree[r] ?? 0), 0)
const row = (r: Rel) => (