import { useState } from 'react' import { useNavigate } from 'react-router-dom' import { AnimatePresence, motion } from 'framer-motion' import { THREAT_SCENARIOS, type ThreatScenario } from './scenarios' import { ThreatCinematic } from './ThreatDemo' import { LocationCinematic } from '../location/LocationDemo' import '../demo.css' const ACCENT = '#3BB586' // The slider mixes the threat-detection scenarios with the location/geofencing // demo, which has its own timeline and player rather than a ThreatScenario shape. type DemoSlide = | { kind: 'threat'; scenario: ThreatScenario } | { kind: 'location' } const DEMO_SLIDES: DemoSlide[] = [ ...THREAT_SCENARIOS.map((scenario) => ({ kind: 'threat' as const, scenario })), { kind: 'location' }, ] function slideId(s: DemoSlide): string { return s.kind === 'threat' ? s.scenario.id : 'location' } function slideTitle(s: DemoSlide): string { return s.kind === 'threat' ? s.scenario.title : 'Family Safe Zones' } function slideProduct(s: DemoSlide): string { return s.kind === 'threat' ? s.scenario.product : 'Mobile SDK' } // 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 slide = DEMO_SLIDES[idx] const n = DEMO_SLIDES.length const go = (next: number) => { setDir(next > idx ? 1 : -1) setIdx((next + n) % n) } return (
{/* ── Top bar (reserved) — standalone /threat-demos only ── */} {!embedded && (
{slideTitle(slide)}
{idx + 1} / {n} · {slideProduct(slide)}
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 }}> {slide.kind === 'threat' ? : } {/* Prev / Next arrows (inside the stage, vertically centred) */}
{/* ── Bottom: scenario tabs (reserved) — moves above the stage on mobile via .bd-demo-tabs media query ── */}
{DEMO_SLIDES.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 }