import type { SVGProps } from "react"; /** * Linux distribution icons using official SVG paths from simple-icons. * Version strings from the agent look like "v1.0.0 (ubuntu/amd64)". */ const distroColors: Record = { ubuntu: "#E95420", debian: "#A81D33", centos: "#262577", rocky: "#10B981", alma: "#0F4266", alpine: "#0D597F", fedora: "#51A2DA", arch: "#1793D1", opensuse: "#73BA25", suse: "#73BA25", rhel: "#EE0000", redhat: "#EE0000", oracle: "#F80000", amazon: "#FF9900", amzn: "#FF9900", kali: "#557C94", mint: "#87CF3E", gentoo: "#54487A", manjaro: "#35BF5C", }; /* ---------- Official SVG logo components (simple-icons paths) ---------- */ function UbuntuIcon(props: SVGProps) { return ( ); } function DebianIcon(props: SVGProps) { return ( ); } function CentOSIcon(props: SVGProps) { return ( ); } function AlpineIcon(props: SVGProps) { return ( ); } function FedoraIcon(props: SVGProps) { return ( ); } function ArchIcon(props: SVGProps) { return ( ); } function LinuxIcon(props: SVGProps) { // Official Tux (Linux penguin) logo from simple-icons return ( ); } /* ---------- Exports ---------- */ type DistroIconProps = SVGProps & { distro: string; }; /** * Detect the Linux distro from a version string like "v1.0.0 (ubuntu/amd64)" * and return the normalized distro key. */ export function parseDistroFromVersion(version?: string): string { if (!version) return "linux"; const lower = version.toLowerCase(); // Try to extract from parenthetical format: (distro/arch) const match = lower.match(/\(([^/)\s]+)/); if (match) { return match[1].trim(); } // Fallback: check for known distro names anywhere in the string const knownDistros = [ "ubuntu", "debian", "centos", "rocky", "alma", "alpine", "fedora", "arch", "opensuse", "suse", "rhel", "redhat", "oracle", "amazon", "amzn", "kali", "mint", "gentoo", "void", "nixos", "manjaro", ]; for (const d of knownDistros) { if (lower.includes(d)) return d; } return "linux"; } /** * Returns a branded color for the detected distro. */ export function getDistroColor(distro: string): string { const key = distro.toLowerCase(); for (const [name, color] of Object.entries(distroColors)) { if (key.includes(name)) return color; } return "#6366F1"; // default indigo for unknown linux } /** * Render an SVG icon for the given Linux distribution. */ export function DistroIcon({ distro, ...props }: DistroIconProps) { const key = distro.toLowerCase(); if (key.includes("ubuntu")) return ; if (key.includes("debian")) return ; if (key.includes("centos") || key.includes("rocky") || key.includes("alma")) return ; if (key.includes("alpine")) return ; if (key.includes("fedora")) return ; if (key.includes("arch") || key.includes("manjaro")) return ; return ; }