"use client"; import { useState, KeyboardEvent, useEffect, useRef } from "react"; interface HeroInputProps { value: string; onChange: (value: string) => void; onSubmit: () => void; placeholder?: string; className?: string; showSearchFeatures?: boolean; } function isURL(str: string): boolean { // Check if string contains a dot and looks like a URL const urlPattern = /^(https?:\/\/)?([a-zA-Z0-9-]+\.)+[a-zA-Z]{2,}(\/.*)?$/; return urlPattern.test(str.trim()); } export default function HeroInput({ value, onChange, onSubmit, placeholder = "Describe what you want to build...", className = "", showSearchFeatures = true }: HeroInputProps) { const [isFocused, setIsFocused] = useState(false); const [showTiles, setShowTiles] = useState(false); const textareaRef = useRef(null); const isURLInput = showSearchFeatures ? isURL(value) : false; // Reset textarea height when value changes (especially when cleared) useEffect(() => { if (textareaRef.current) { textareaRef.current.style.height = 'auto'; textareaRef.current.style.height = textareaRef.current.scrollHeight + 'px'; } // Show tiles animation for search terms (only if search features are enabled) if (showSearchFeatures && value.trim() && !isURL(value) && isFocused) { setShowTiles(true); } else { setShowTiles(false); } }, [value, isFocused, showSearchFeatures]); const handleKeyDown = (e: KeyboardEvent) => { if (e.key === "Enter" && !e.shiftKey) { e.preventDefault(); onSubmit(); } }; return (