// One slide as a TV shows it (plan step 5.6a): picture, video, text, menu board or blank (2026-11-21). Used by the
// player (terminal) and the manager's previews. Needs a parent with `container-type: size`.
// media(id) → { src, url, kind, width, height } | null (src: the address or the TV's kept copy)
// slide.extras: what the server added to its widgets by path (QR links, menus, slides inside stacks)
import { useEffect, useLayoutEffect, useRef, useState } from 'react'
import { boardPages, pageAt } from './logic.js'
import { BlankSlide, MenuSlide, TextSlide } from './Slides.jsx'
export function SlideView({ slide, media, venue, now, pages, page, onEnded, playing = true }) {
const x = slide.extras
return (
<>
{slide.kind === 'image' && }
{slide.kind === 'video' && }
{slide.kind === 'text' && }
{slide.kind === 'blank' && }
{slide.kind === 'menu' && }
>
)
}
/**
* A library slide drawn whole inside a stack's part (2026-11-21): scaled to the part (its sizes
* are the part's container units); a menu board pages by the clock for the part's own size, a
* video loops.
*/
function EmbeddedSlide({ slide, media, venue, now }) {
const ref = useRef(null)
const [size, setSize] = useState(null)
useLayoutEffect(() => {
const el = ref.current
if (!el) return undefined
const measure = () => setSize(s => (s && s.w === el.clientWidth && s.h === el.clientHeight ? s : { w: el.clientWidth, h: el.clientHeight }))
measure()
const ro = new ResizeObserver(measure)
ro.observe(el)
return () => ro.disconnect()
}, [])
const pages = slide.kind === 'menu' && size ? boardPages(slide, 0, size.w || 16, size.h || 9) : null
const page = pages ? pageAt(pages.length, slide.content?.page_seconds, now.getTime()) : 0
return (
{size && }
)
}
function ImageSlide({ content, media }) {
const m = content.media_id ? media(content.media_id) : null
return (
{m &&

}
)
}
function VideoSlide({ slide, media, onEnded, playing }) {
const c = slide.content || {}
const m = c.media_id ? media(c.media_id) : null
const ref = useRef(null)
useEffect(() => {
const v = ref.current
if (!v) return
if (playing) v.play?.().catch(() => {})
else v.pause?.()
}, [m?.src, playing])
return (
{m && }
)
}