import type { SVGProps } from "react"; // Map of Linux distribution names to their SVG logo components. // 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", void: "#478061", nixos: "#7EBAE4", manjaro: "#35BF5C", }; 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 ( f ); } function ArchIcon(props: SVGProps) { return ( ); } function DefaultLinuxIcon(props: SVGProps) { // Tux-inspired simple penguin outline return ( ); } 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 ; }