"use client"; import { useState, useEffect } from "react"; import { motion, useMotionValue, useTransform, useSpring, useReducedMotion } from "framer-motion"; import Image from "next/image"; import { WaitlistForm } from "./waitlist-form"; import { DiaTextReveal } from "./ui/dia-text-reveal"; import { AgentParticleCanvas } from "./AgentParticleCanvas"; import { ShimmerButton } from "@/components/ui/shimmer-button"; import { useLanguage } from "./LanguageContext"; const HERO_FEATURE_BADGES = [ "heroBadgeCompat", "heroBadgeBilling", "heroBadgeCompare", "heroBadgeRouting", "heroBadgeDashboard", ] as const; export function HeroSection() { const reducedMotion = useReducedMotion(); const { t } = useLanguage(); const [variant, setVariant] = useState<"classic" | "intelligence">("classic"); // variant is used via setVariant; state read happens through useEffect re-renders void variant; const scrollToWaitlist = () => { const input = document.getElementById("email-input"); if (input) { input.scrollIntoView({ behavior: "smooth", block: "center" }); setTimeout(() => input.focus(), 850); } }; const scrollToModels = () => { document.getElementById("models")?.scrollIntoView({ behavior: "smooth", block: "start" }); }; const [isDesktop, setIsDesktop] = useState(false); const [mounted, setMounted] = useState(false); const [timeStr, setTimeStr] = useState(""); const [robotHovered, setRobotHovered] = useState(false); const [rawMouse, setRawMouse] = useState({ x: 0, y: 0 }); // Determine A/B test variant on client mount useEffect(() => { const init = setTimeout(() => { let savedVariant = localStorage.getItem("hubapi_hero_variant") as "classic" | "intelligence" | null; // Fallback: check cookie as well if (!savedVariant && typeof document !== "undefined") { const match = document.cookie.match(/(^|;)\s*hubapi_hero_variant\s*=\s*([^;]+)/); if (match) { savedVariant = match[2] as "classic" | "intelligence"; } } if (!savedVariant) { // 50/50 randomization const selected = Math.random() < 0.5 ? "classic" : "intelligence"; localStorage.setItem("hubapi_hero_variant", selected); if (typeof document !== "undefined") { document.cookie = `hubapi_hero_variant=${selected}; path=/; max-age=${60 * 60 * 24 * 365}`; } savedVariant = selected; } setVariant(savedVariant); }, 0); return () => clearTimeout(init); }, []); // Check viewport for applying interactive parallax vs mobile float useEffect(() => { const checkViewport = () => { setIsDesktop(window.innerWidth >= 1024); }; checkViewport(); window.addEventListener("resize", checkViewport); return () => window.removeEventListener("resize", checkViewport); }, []); // Update ticking clock on client only to prevent hydration mismatch useEffect(() => { const frame = requestAnimationFrame(() => { setMounted(true); }); const updateClock = () => { setTimeStr(new Date().toISOString().substring(11, 19)); }; updateClock(); const interval = setInterval(updateClock, 1000); return () => { cancelAnimationFrame(frame); clearInterval(interval); }; }, []); const disableThrusters = !!reducedMotion || (mounted && !isDesktop); // Parallax motion values const mouseX = useMotionValue(0); const mouseY = useMotionValue(0); // Smooth springs for the parallax const springConfig = { damping: 25, stiffness: 150, mass: 0.5 }; const smoothMouseX = useSpring(mouseX, springConfig); const smoothMouseY = useSpring(mouseY, springConfig); // Map mouse values to rotations (-6 to 6 degrees) const rotateX = useTransform(smoothMouseY, [-0.5, 0.5], [6, -6]); const rotateY = useTransform(smoothMouseX, [-0.5, 0.5], [-6, 6]); // Map mouse values to translations (-8px to 8px) const translateX = useTransform(smoothMouseX, [-0.5, 0.5], [-8, 8]); const translateY = useTransform(smoothMouseY, [-0.5, 0.5], [-8, 8]); const handleMouseMove = (e: React.MouseEvent) => { // Only apply parallax on desktop/when mouse is present if (!isDesktop || reducedMotion) return; const rect = e.currentTarget.getBoundingClientRect(); const x = (e.clientX - rect.left) / rect.width - 0.5; // -0.5 to 0.5 const y = (e.clientY - rect.top) / rect.height - 0.5; // -0.5 to 0.5 mouseX.set(x); mouseY.set(y); setRawMouse({ x, y }); }; const handleMouseLeave = () => { mouseX.set(0); mouseY.set(0); setRawMouse({ x: 0, y: 0 }); }; return (
{/* Dynamic Agent Neural Particle network canvas — behind content */}
{/* HUD Telemetry Overlays - Minimal & Highly Refined */}
{/* Symmetrical/Asymmetrical Sleek Gradient Vertical Accent */}
setRobotHovered(true)} onMouseLeave={() => { handleMouseLeave(); setRobotHovered(false); }} style={{ perspective: "1000px" }} >
); }