"use client"; import { ArrowRight, Bot, Check, ChevronDown, Paperclip } from "lucide-react"; import { useState, useRef, useCallback, useEffect } from "react"; import { Textarea } from "@/components/ui/textarea"; import { cn } from "@/lib/utils"; import { Button } from "@/components/ui/button"; import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger, } from "@/components/ui/dropdown-menu"; import { motion, AnimatePresence } from "framer-motion"; interface UseAutoResizeTextareaProps { minHeight: number; maxHeight?: number; } function useAutoResizeTextarea({ minHeight, maxHeight, }: UseAutoResizeTextareaProps) { const textareaRef = useRef(null); const adjustHeight = useCallback( (reset?: boolean) => { const textarea = textareaRef.current; if (!textarea) return; if (reset) { textarea.style.height = `${minHeight}px`; return; } textarea.style.height = `${minHeight}px`; const newHeight = Math.max( minHeight, Math.min( textarea.scrollHeight, maxHeight ?? Number.POSITIVE_INFINITY ) ); textarea.style.height = `${newHeight}px`; }, [minHeight, maxHeight] ); useEffect(() => { const textarea = textareaRef.current; if (textarea) { textarea.style.height = `${minHeight}px`; } }, [minHeight]); useEffect(() => { const handleResize = () => adjustHeight(); window.addEventListener("resize", handleResize); return () => window.removeEventListener("resize", handleResize); }, [adjustHeight]); return { textareaRef, adjustHeight }; } const OPENAI_ICON = ( <> OpenAI Icon Light OpenAI Icon Dark ); export function AI_Prompt() { const [value, setValue] = useState(""); const { textareaRef, adjustHeight } = useAutoResizeTextarea({ minHeight: 72, maxHeight: 300, }); const [selectedModel, setSelectedModel] = useState("GPT-4-1 Mini"); const AI_MODELS = [ "o3-mini", "Gemini 2.5 Flash", "Claude 3.5 Sonnet", "GPT-4-1 Mini", "GPT-4-1", ]; const MODEL_ICONS: Record = { "o3-mini": OPENAI_ICON, "Gemini 2.5 Flash": ( Gemini ), "Claude 3.5 Sonnet": ( <> Anthropic Icon Light Anthropic Icon Dark ), "GPT-4-1 Mini": OPENAI_ICON, "GPT-4-1": OPENAI_ICON, }; const handleKeyDown = (e: React.KeyboardEvent) => { if (e.key === "Enter" && !e.shiftKey && value.trim()) { e.preventDefault(); setValue(""); adjustHeight(true); // Here you can add message sending } }; return (