"use client" import { cn } from "@/lib/utils" interface GpuSwitchModeIndicatorProps { mode: "lxc" | "vm" | "unknown" isEditing?: boolean pendingMode?: "lxc" | "vm" | null onToggle?: (e: React.MouseEvent) => void className?: string compact?: boolean } export function GpuSwitchModeIndicator({ mode, isEditing = false, pendingMode = null, onToggle, className, compact = false, }: GpuSwitchModeIndicatorProps) { const displayMode = pendingMode ?? mode const isLxcActive = displayMode === "lxc" const isVmActive = displayMode === "vm" const hasChanged = pendingMode !== null && pendingMode !== mode const handleClick = (e: React.MouseEvent) => { e.stopPropagation() // Prevent card click propagation if (isEditing && onToggle) { onToggle(e) } } if (compact) { return (
{/* GPU Chip Icon */} {/* Chip pins */} GPU {/* Connection lines from GPU */} {/* Main line from GPU */} {/* Switch circle */} {/* LXC branch */} {/* VM branch */} {/* LXC Icon - Container */} LXC {/* VM Icon - Monitor/PC */} {/* Status text */} {isLxcActive ? "LXC" : isVmActive ? "VM" : "N/A"} {hasChanged && ( (pending) )}
) } return (
{/* GPU Chip Icon */} {/* Chip pins top */} {/* Chip pins bottom */} GPU {/* Connection lines */} {/* Main line from GPU to switch */} {/* Switch circle */} {/* Switch indicator inside circle */} {/* LXC branch - top */} {/* Active glow for LXC */} {isLxcActive && ( )} {/* VM branch - bottom */} {/* Active glow for VM */} {isVmActive && ( )} {/* LXC Icon - Container with layers */} {/* Container layers */} {/* Small dots on layers */} {/* LXC label */} LXC {/* VM Icon - Monitor/Desktop */} {/* Screen content */} {/* Stand */} {/* VM label */} VM {/* Status text and edit hint */}
{isLxcActive ? "LXC Mode" : isVmActive ? "VM Mode" : "Unknown"} {isLxcActive ? "Native Driver" : isVmActive ? "VFIO Passthrough" : ""} {isEditing && ( Click to toggle )} {hasChanged && ( Change pending )}
) }