// Main app: orchestrates screens, director, talk track, keyboard function App() { const [screen, setScreen] = React.useState(1); const [autoAdvance, setAutoAdvance] = React.useState(false); const [showTalkTrack, setShowTalkTrack] = React.useState(false); const [directorOpen, setDirectorOpen] = React.useState(true); const [transitioning, setTransitioning] = React.useState(false); const [calling, setCalling] = React.useState(false); const goTo = React.useCallback((n) => { if (n < 1 || n > SCREENS.length) return; setScreen(n); }, []); const advance = React.useCallback(() => { setScreen(s => Math.min(s + 1, SCREENS.length)); }, []); // Email → WhatsApp: instant const onEmailAdvance = () => goTo(2); // Manage → WhatsApp via shimmer const onManageAdvance = () => { setTransitioning(true); setTimeout(() => { setTransitioning(false); goTo(3); }, 800); }; // WA → Tap to call const onWAAdvance = () => goTo(4); // Tap to call → Voice via calling overlay const onTapAdvance = () => { setCalling(true); setTimeout(() => { setCalling(false); goTo(5); }, 1500); }; // Voice → Copilot const onVoiceAdvance = () => goTo(6); // Copilot → Closing const onCopilotAdvance = () => goTo(7); React.useEffect(() => { const onKey = (e) => { if (e.key === 'd' || e.key === 'D') { setDirectorOpen(o => !o); return; } if (e.key === 't' || e.key === 'T') { setShowTalkTrack(s => !s); return; } if (e.key === 'r' || e.key === 'R') { setScreen(1); return; } if (e.key === 'ArrowRight' || e.key === ' ') { e.preventDefault(); const handlers = [null, onEmailAdvance, onManageAdvance, onWAAdvance, onTapAdvance, onVoiceAdvance, onCopilotAdvance]; if (screen <= 6) handlers[screen](); return; } if (e.key === 'ArrowLeft') { setScreen(s => Math.max(1, s - 1)); return; } const num = parseInt(e.key); if (num >= 1 && num <= 7) goTo(num); }; window.addEventListener('keydown', onKey); return () => window.removeEventListener('keydown', onKey); }, [screen]); // Auto-advance for non-animated screens React.useEffect(() => { if (!autoAdvance) return; let t; if (screen === 1) t = setTimeout(onEmailAdvance, 5000); if (screen === 2) t = setTimeout(onManageAdvance, 4000); if (screen === 4) t = setTimeout(onTapAdvance, 4000); return () => clearTimeout(t); }, [screen, autoAdvance]); const handleNextClick = () => { const handlers = [null, onEmailAdvance, onManageAdvance, onWAAdvance, onTapAdvance, onVoiceAdvance, onCopilotAdvance]; if (screen <= 6) handlers[screen](); }; return ( <>