export type DisplaySurface = "top" | "bottom"; const DISPLAY_SURFACE_EVENT = "healer-man:display-surface"; let currentSurface: DisplaySurface = "top"; export function requestDisplaySurface(surface: DisplaySurface): void { currentSurface = surface; window.dispatchEvent(new CustomEvent(DISPLAY_SURFACE_EVENT, { detail: surface })); } export function subscribeDisplaySurface(listener: (surface: DisplaySurface) => void): () => void { const onSurface = (event: Event) => { currentSurface = (event as CustomEvent).detail; listener(currentSurface); }; window.addEventListener(DISPLAY_SURFACE_EVENT, onSurface); return () => window.removeEventListener(DISPLAY_SURFACE_EVENT, onSurface); }