"use client"; import { useEffect, useRef, useState } from "react"; import { ArrowUpIcon, PlusIcon } from "lucide-react"; import { Button } from "@/components/ui/button"; import { cn } from "@/lib/utils"; type Props = { value?: string | undefined; onValueChange?: (value: string) => void; onSubmit?: (value: string) => void; placeholder?: string | undefined; }; export function PromptInput({ value: controlled, onValueChange, onSubmit, placeholder, }: Props) { const [internal, setInternal] = useState(""); const value = controlled ?? internal; const textareaRef = useRef(null); const setValue = (nextValue: string) => { if (onValueChange) onValueChange(nextValue); else setInternal(nextValue); }; useEffect(() => { void value; const el = textareaRef.current; if (!el) return; el.style.height = "auto"; el.style.height = `${Math.min(el.scrollHeight, 128)}px`; }, [value]); const handleSubmit = () => { const trimmed = value.trim(); if (!trimmed) return; onSubmit?.(trimmed); }; return (