"use client"; import { useEffect, useRef, useState } from "react"; import type { FirmwareInfo } from "@/lib/firmware"; import { cn } from "@/lib/utils"; const SCREEN_W = 320; const SCREEN_H = 240; /** Renders HTML on-device UI mock (preferred) — never uses raster covers. */ export function FirmwarePreview({ fw, className, title, }: { fw: FirmwareInfo; className?: string; title?: string; }) { const hostRef = useRef(null); const [scale, setScale] = useState(1); useEffect(() => { const el = hostRef.current; if (!el) return; const update = () => { const { width, height } = el.getBoundingClientRect(); if (width <= 0 || height <= 0) return; setScale(Math.min(width / SCREEN_W, height / SCREEN_H)); }; update(); const ro = new ResizeObserver(update); ro.observe(el); return () => ro.disconnect(); }, [fw.media.preview]); if (fw.media.preview) { return (