import { useState } from "react"; import { Check, ChevronDown, ChevronUp, Trash2, X } from "lucide-react"; import { Card } from "@/client/components/ui/card"; import { formatSampleBytes, shortValue } from "./format"; import type { PackStat } from "./types"; export type PackFilesCardProps = { packCount: number; packStats: PackStat[]; pending: Record; removePack: (packName: string) => Promise; }; function packKindLabel(kind: PackStat["kind"]): string { switch (kind) { case "compact": return "compact"; case "receive": return "receive"; default: return "legacy"; } } function PackRow({ packStat, pending, removePack, }: { packStat: PackStat; pending: Record; removePack: (packName: string) => Promise; }) { const packName = String(packStat.key).split("/").pop() || packStat.key; const canDelete = packStat.state === "superseded"; // Mirror the Index cell's icon-only treatment. The .refs sidecar is either present, // missing, or its status couldn't be determined — all descriptive context lives in // the tooltip so the table stays visually consistent across rows. const refStatus = packStat.refIndexStatus ?? "unknown"; const refSizeSuffix = refStatus === "present" && typeof packStat.refIndexSize === "number" ? ` (${formatSampleBytes(packStat.refIndexSize)})` : ""; const refTitle = refStatus === "present" ? `Reference sidecar is present in R2${refSizeSuffix}` : refStatus === "missing" ? "Reference sidecar is missing from R2" : "Reference sidecar status could not be checked"; return ( {shortValue(packName, 35)} {packStat.state} {packKindLabel(packStat.kind)} {packStat.tier} {packStat.objectCount} {formatSampleBytes(packStat.packSize)} {formatSampleBytes(packStat.indexSize)} {packStat.hasIndex ? (