import React, { useState, useRef, useEffect } from 'react'; import { SendHorizontal, Loader2 } from 'lucide-react'; import { Language } from '../types'; import { TEXTS } from '../constants'; interface InputAreaProps { language: Language; onSend: (text: string) => void; isLoading: boolean; isOffTheRecord: boolean; onToggleOffTheRecord: () => void; } export const InputArea: React.FC = ({ language, onSend, isLoading, isOffTheRecord, onToggleOffTheRecord }) => { const [input, setInput] = useState(''); const textareaRef = useRef(null); const handleSubmit = (e?: React.FormEvent) => { e?.preventDefault(); if (input.trim() && !isLoading) { onSend(input); setInput(''); if (textareaRef.current) { textareaRef.current.style.height = 'auto'; } } }; const handleKeyDown = (e: React.KeyboardEvent) => { if (e.key === 'Enter' && !e.shiftKey) { e.preventDefault(); handleSubmit(); } }; const handleInput = (e: React.ChangeEvent) => { setInput(e.target.value); // Auto-resize e.target.style.height = 'auto'; e.target.style.height = `${Math.min(e.target.scrollHeight, 150)}px`; }; // Focus input on load useEffect(() => { textareaRef.current?.focus(); }, []); return (