import type { AMSUnit, AMSTray } from '../../api/client'; import { getFillBarColor } from '../../utils/amsHelpers'; function trayColorToCSS(color: string | null): string { if (!color) return '#808080'; return `#${color.slice(0, 6)}`; } function isTrayEmpty(tray: AMSTray): boolean { return !tray.tray_type || tray.tray_type === ''; } // Mirror of PrintersPage.getEmptySlotKind (#1694, #2527): 'physical' when // firmware confirms no spool, 'reset' when a spool is present but has no // tray_type (= loaded, slot just unconfigured — e.g. a non-RFID spool). // tray_exist_bits (exists) is authoritative when present; otherwise fall back // to the state=9/10 heuristic. function getEmptySlotKind(tray: AMSTray): 'physical' | 'reset' | null { if (tray.tray_type) return null; if (tray.exists === true) return 'reset'; if (tray.exists === false) return 'physical'; const state = tray.state ?? null; return state === 9 || state === 10 ? 'physical' : 'reset'; } function getAmsName(id: number): string { if (id <= 3) return `AMS ${String.fromCharCode(65 + id)}`; if (id >= 128 && id <= 135) return `AMS HT ${String.fromCharCode(65 + id - 128)}`; return `AMS ${id}`; } // --- SVG Icons (matching PrintersPage Bambu Lab style) --- function WaterDropEmpty({ className }: { className?: string }) { return ( ); } function WaterDropHalf({ className }: { className?: string }) { return ( ); } function WaterDropFull({ className }: { className?: string }) { return ( ); } function ThermometerEmpty({ className }: { className?: string }) { return ( ); } function ThermometerHalf({ className }: { className?: string }) { return ( ); } function ThermometerFull({ className }: { className?: string }) { return ( ); } // --- Threshold-colored indicators --- function HumidityIndicator({ humidity, goodThreshold = 40, fairThreshold = 60 }: { humidity: number; goodThreshold?: number; fairThreshold?: number }) { let textColor: string; let DropComponent: React.FC<{ className?: string }>; if (humidity <= goodThreshold) { textColor = '#22a352'; DropComponent = WaterDropEmpty; } else if (humidity <= fairThreshold) { textColor = '#d4a017'; DropComponent = WaterDropHalf; } else { textColor = '#c62828'; DropComponent = WaterDropFull; } return (