"use client"; import { useTranslation } from "react-i18next"; import { Star, Trash2 } from "lucide-react"; import { kbHasLiveProgress, kbNeedsReindex, resolveKbStatus, resolveProgressPercent, type KnowledgeBase, } from "@/lib/knowledge-helpers"; import KbStatusDot from "./KbStatusDot"; interface KnowledgeBaseListItemProps { kb: KnowledgeBase; selected: boolean; onSelect: () => void; onSetDefault: () => void; onDelete: () => void; isReindexingLocally?: boolean; } export default function KnowledgeBaseListItem({ kb, selected, onSelect, onSetDefault, onDelete, isReindexingLocally = false, }: KnowledgeBaseListItemProps) { const { t } = useTranslation(); const status = resolveKbStatus(kb); const needsReindex = kbNeedsReindex(kb); const isLive = kbHasLiveProgress(kb) || isReindexingLocally; const isError = status === "error"; const isReady = status === "ready" && !needsReindex; const percent = resolveProgressPercent(kb.progress); const docCount = kb.statistics?.raw_documents ?? 0; const subtitle = needsReindex ? t("Needs reindex") : isError ? t("Error") : isLive ? percent > 0 ? t("Processing · {{percent}}%", { percent }) : t("Processing…") : isReady ? docCount === 1 ? t("Ready · {{count}} doc", { count: docCount }) : t("Ready · {{count}} docs", { count: docCount }) : status.replaceAll("_", " "); return (