import { h } from 'preact'; import htm from 'htm'; const html = htm.bind(h); function DeviceCard({ id, device, onSelect }) { const { info, status } = device; const np = status?.nowPlaying; const isPlaying = np?.PlayStatus === 'PLAY_STATE'; const isStandby = !np || np.Source === 'STANDBY'; return html`
onSelect(id)}>
${info?.Name || id}
${info?.Type || ''}
${!isStandby && html`
${isPlaying ? '▶' : '⏸'} ${np.Track || np.StationName || np.Source} ${np.Artist && html` — ${np.Artist}`}
`} ${isStandby && html`
Standby
`}
`; } export function DeviceList({ devices, onSelect, onDiscover }) { const entries = Object.entries(devices); return html` ${entries.length === 0 ? html`

No devices found on your network.

` : html`
${entries.map(([id, device]) => html` <${DeviceCard} key=${id} id=${id} device=${device} onSelect=${onSelect} /> `)}
` } `; }