import type { CompatLevel, TargetInfo } from "../types"; import { ModeBadge } from "./ModeBadge"; import { t } from "../i18n"; /** Canonical labels for the newer targets (backend label wins when present). */ export const TARGET_LABELS: Record = { linux_appimage: "Linux AppImage", arch_pkgbuild: "Arch Linux (PKGBUILD)", mcp: "MCP Server / Config", windows_portable: "Windows Portable", }; export function targetLabel(id: string, label?: string): string { return label || TARGET_LABELS[id] || id; } /** Real targets first, disabled stubs last (stable within each group). */ export function orderTargets(targets: TargetInfo[]): TargetInfo[] { return [...targets].sort((a, b) => Number(!!a.stub) - Number(!!b.stub)); } function CompatChip({ level, label }: { level: CompatLevel; label: string }) { const icon = level === "ok" ? "✓" : level === "warn" ? "⚠" : "✗"; return ( {icon} {label} ); } export function TargetPicker({ targets, selected, onChange, }: { targets: TargetInfo[]; selected: Set; onChange: (next: Set) => void; }) { const m = t(); const platform: Record = { linux_appimage: m.platformAppImage, arch_pkgbuild: m.platformPkgbuild, mcp: m.platformMcp, }; return (
{orderTargets(targets).map((tg) => { const disabled = !tg.available; const checked = selected.has(tg.id); const c = tg.compat; return (
{ const next = new Set(selected); if (e.target.checked) next.add(tg.id); else next.delete(tg.id); onChange(next); }} />
{platform[tg.id] ?
{platform[tg.id]}
: null}
{tg.reason}
{c ? (
{c.project ? ( ) : null} {c.apk ? ( ) : null} {c.gpu_local ? ( ) : null}
) : null} {tg.stub ?
{m.stubNote}
: null}
{disabled ? {m.unavailable} : null}
); })}
); }