"use client"; import { useTranslations } from "next-intl"; import type { EncoderComparison } from "./compressionFlowModel"; const fmt = (n: number) => n.toLocaleString("en-US"); export function EncoderComparisonTable({ comparison }: { comparison: EncoderComparison }) { const t = useTranslations("compressionStudio"); if (!comparison || comparison.arraysCompared === 0) return null; const rows: Array<{ key: "gcf" | "toon" | "json"; label: string; size: { bytes: number; tokens: number } | null; }> = [ { key: "gcf", label: "GCF", size: comparison.gcf }, { key: "toon", label: "TOON", size: comparison.toonAvailable ? comparison.toon : null }, { key: "json", label: "JSON", size: comparison.json }, ].sort((a, b) => (a.size?.tokens ?? Infinity) - (b.size?.tokens ?? Infinity)); return (
{t("encoderComparison", { count: comparison.arraysCompared })}{" "} {t("encoderWinner", { winner: comparison.winner })}
{rows.map((r) => ( {r.size ? ( <> ) : ( )} ))}
{t("encoder")} {t("bytes")} {t("tokensCl100k")}
{r.label} {r.key === comparison.winner ? " ✓" : ""} {fmt(r.size.bytes)} {fmt(r.size.tokens)} n/a
); }