import { useState } from 'react' import { useNavigate } from 'react-router-dom' import { AnimatePresence, motion } from 'framer-motion' import { THREAT_SCENARIOS } from './scenarios' import { ThreatCinematic } from './ThreatDemo' import '../demo.css' const ACCENT = '#3BB586' // Isolated so useNavigate() is only ever invoked when this is actually mounted // under a — the embedded (no-router) instance never renders it. function BackToSiteButton() { const navigate = useNavigate() return ( ) } export default function ThreatDemosSlider({ embedded = false }: { embedded?: boolean } = {}) { const [idx, setIdx] = useState(0) const [dir, setDir] = useState(1) const scenario = THREAT_SCENARIOS[idx] const n = THREAT_SCENARIOS.length const go = (next: number) => { setDir(next > idx ? 1 : -1) setIdx((next + n) % n) } return (
{/* ── Top bar (reserved) — standalone /threat-demos only ── */} {!embedded && (
{scenario.title}
{idx + 1} / {n} · {scenario.product}
REC
)} {/* ── Stage (flex, holds the sliding players) ── */}
0 ? '100%' : '-100%' }} animate={{ x: 0 }} exit={{ x: dir > 0 ? '-100%' : '100%' }} transition={{ type: 'spring', stiffness: 260, damping: 30 }} style={{ position: 'absolute', inset: 0 }}> {/* Prev / Next arrows (inside the stage, vertically centred) */}
{/* ── Bottom: scenario tabs (reserved) — moves above the stage on mobile via .bd-demo-tabs media query ── */}
{THREAT_SCENARIOS.map((s, i) => ( ))}
) } function navBtn(side: 'left' | 'right'): React.CSSProperties { return { position: 'absolute', top: '50%', transform: 'translateY(-50%)', [side]: 16, zIndex: 70, width: 44, height: 44, borderRadius: '50%', background: 'rgba(0,0,0,.45)', backdropFilter: 'blur(10px)', border: '1px solid rgba(255,255,255,.14)', color: '#e8f4f3', fontSize: 22, lineHeight: 1, cursor: 'pointer', fontFamily: 'inherit', display: 'flex', alignItems: 'center', justifyContent: 'center', } as React.CSSProperties }