import React, { useState } from 'react'; import { Loader2 } from 'lucide-react'; import RemotionPreview from './RemotionPreview'; import Modal from './ui/Modal'; import SegmentedControl from './ui/SegmentedControl'; const ENTRANCE_OPTIONS = [ { value: 'spring', label: 'Bounce' }, { value: 'fade', label: 'Fade' }, { value: 'slide-up', label: 'Slide Up' }, { value: 'none', label: 'None' }, ]; // Must mirror hooks.py HOOK_STYLES. const HOOK_STYLES = [ { value: 'classic', label: 'Classic', box: 'rgba(255,255,255,0.94)', text: '#000' }, { value: 'dark', label: 'Dark', box: 'rgba(18,18,20,0.92)', text: '#fff' }, { value: 'yellow', label: 'Yellow', box: 'rgba(255,214,0,0.96)', text: '#000' }, { value: 'red', label: 'Red', box: 'rgba(220,38,38,0.96)', text: '#fff' }, { value: 'outline', label: 'Outline', box: 'transparent', text: '#fff', outline: true }, { value: 'outline_yellow', label: 'Outline+', box: 'transparent', text: '#FFD600', outline: true }, ]; const POSITION_OPTIONS = [ { value: 'top', label: 'top' }, { value: 'center', label: 'center' }, { value: 'bottom', label: 'bottom' }, ]; const SIZE_OPTIONS = [ { value: 'S', label: 'Small' }, { value: 'M', label: 'Medium' }, { value: 'L', label: 'Large' }, ]; // Last-used hook settings, restored on the next open (style always reset to // classic otherwise, which users read as the picker being broken). function loadHookPrefs() { try { return JSON.parse(localStorage.getItem('os_hook_prefs')) || {}; } catch { return {}; } } export default function HookModal({ isOpen, onClose, onGenerate, onRemove, isProcessing, videoUrl, initialText, durationInSeconds, existingSubtitles, hasCaptions, serverRender, burnedHook }) { const prefs = loadHookPrefs(); const [text, setText] = useState(initialText || 'POV: You are using the viral hook feature'); const [position, setPosition] = useState(prefs.position || 'top'); const [size, setSize] = useState(prefs.size || 'M'); const [style, setStyle] = useState(prefs.style || 'classic'); const [entranceAnimation, setEntranceAnimation] = useState(prefs.entranceAnimation || 'spring'); const [displayDuration, setDisplayDuration] = useState(5); if (!isOpen) return null; // Build hook config for Remotion preview const hookConfig = { text: text || 'Enter your text...', position, size, style, entranceAnimation, displayDurationSec: displayDuration, }; const useRemotionPreview = !!videoUrl; // Fallback preview logic (same as original) const getPositionClass = () => { switch (position) { case 'center': return 'items-center justify-center'; case 'bottom': return 'items-center justify-end pb-[20%]'; case 'top': default: return 'items-center justify-start pt-[20%]'; } }; const getSizeStyle = () => { switch (size) { case 'S': return { fontSize: '14px', maxWidth: '80%' }; case 'L': return { fontSize: '24px', maxWidth: '95%' }; case 'M': default: return { fontSize: '18px', maxWidth: '90%' }; } }; return (
{/* Left: Preview */}
{useRemotionPreview ? ( ) : ( <>
{/* Right: Controls */}
{/* Text Input */}

Text