import { useState, useRef, useCallback, useEffect } from 'react' import { Send } from 'lucide-react' import { cn } from '@/lib/utils' interface ScriptBuilderInputProps { onSend: (content: string) => void disabled: boolean placeholder?: string } export function ScriptBuilderInput({ onSend, disabled, placeholder = 'Describe the script you need...', }: ScriptBuilderInputProps) { const [value, setValue] = useState('') const textareaRef = useRef(null) const adjustHeight = useCallback(() => { const textarea = textareaRef.current if (!textarea) return textarea.style.height = 'auto' textarea.style.height = `${Math.min(textarea.scrollHeight, 120)}px` }, []) useEffect(() => { adjustHeight() }, [value, adjustHeight]) const handleSend = () => { const trimmed = value.trim() if (!trimmed || disabled) return onSend(trimmed) setValue('') } const handleKeyDown = (e: React.KeyboardEvent) => { if (e.key === 'Enter' && !e.shiftKey) { e.preventDefault() handleSend() } } const canSend = value.trim().length > 0 && !disabled return (