'use client' import { GENERIC_SIM_ID, getPlugin } from '@/lib/simulators' import { ANIM_VIEWS, SIMULATOR_VIEWS } from '@/components/simulators' import { AnimPlayerShell } from '@/components/simulators/anim-player-shell' import { GenericFormulaView } from '@/components/simulators/generic-formula-view' import type { SimBlock } from '@/lib/interactive-page' /** Renders a `sim` block: catalog plugin (bespoke view) or generic formula. */ export function SimBlockView({ block, lang, }: { block: SimBlock lang: string }) { const sim = block.sim const fr = lang.startsWith('fr') const plugin = sim.simId === GENERIC_SIM_ID ? null : getPlugin(sim.simId) const kindLabel = plugin?.family === 'anim' ? fr ? 'Animation interactive' : 'Interactive animation' : fr ? 'Simulation interactive' : 'Interactive simulation' let title: string | undefined let body: React.ReactNode = null if (sim.simId === GENERIC_SIM_ID) { title = sim.title body = ( } lang={lang} /> ) } else { if (!plugin) { return (
{fr ? 'Simulateur indisponible' : 'Simulator unavailable'} ({sim.simId})
) } title = sim.title || (fr ? plugin.title.fr : plugin.title.en) if (plugin.family === 'anim') { const AnimScene = ANIM_VIEWS[sim.simId] if (!AnimScene) { return (
{fr ? 'Animation indisponible' : 'Animation unavailable'} ({sim.simId})
) } body = ( {(stepIndex) => } ) } else { const View = SIMULATOR_VIEWS[sim.simId] if (!View) { return (
{fr ? 'Simulateur indisponible' : 'Simulator unavailable'} ({sim.simId})
) } const preset = (sim as { preset?: Record }).preset body = ( ) } } return (

{title}

{kindLabel}
{body} {block.caption ? (
{block.caption}
) : null}
) }