import React, { useEffect, useState, useRef } from 'react'; interface ContactSectionProps { onClose: () => void; isAudioMuted: boolean; onToggleAudioMuted: () => void; } export const ContactSection: React.FC = ({ onClose, isAudioMuted, onToggleAudioMuted }) => { const [isLoaded, setIsLoaded] = useState(false); const [activeFounder, setActiveFounder] = useState(null); const [aiText, setAiText] = useState("System Online. Initializing Team Triangle Protocol..."); const founderAudioRef = useRef>({}); const activeFounderAudioIdRef = useRef(null); // For the typing effect const [displayedText, setDisplayedText] = useState(""); const typingTimeoutRef = useRef(null); useEffect(() => { const t = setTimeout(() => setIsLoaded(true), 100); const t2 = setTimeout(() => typeMessage("Greetings. I am Triangle.AI. Below are my creators. Or as they refer to themselves: 'The Three Dumb Founders'."), 800); return () => { clearTimeout(t); clearTimeout(t2); }; }, []); useEffect(() => { if (isAudioMuted) { (Object.values(founderAudioRef.current) as HTMLAudioElement[]).forEach((a) => { a.pause(); }); activeFounderAudioIdRef.current = null; } }, [isAudioMuted]); useEffect(() => { return () => { (Object.values(founderAudioRef.current) as HTMLAudioElement[]).forEach((a) => { a.pause(); a.src = ''; a.load(); }); founderAudioRef.current = {}; activeFounderAudioIdRef.current = null; }; }, []); const typeMessage = (message: string) => { if (typingTimeoutRef.current) clearTimeout(typingTimeoutRef.current); setAiText(message); setDisplayedText(""); let i = 0; const type = () => { if (i < message.length) { setDisplayedText(message.substring(0, i + 1)); i++; typingTimeoutRef.current = setTimeout(type, 20); // Typing speed } }; type(); }; const getFounderAudio = (id: string) => { if (founderAudioRef.current[id]) return founderAudioRef.current[id]; const srcMap: Record = { ADI: '/audio/aditya.wav', YOGI: '/audio/yogiraj.wav', MAN: '/audio/aman.wav', }; const src = srcMap[id]; if (!src) return null; const a = new Audio(src); a.preload = 'auto'; a.volume = 0.9; founderAudioRef.current[id] = a; return a; }; const stopFounderAudio = () => { const activeId = activeFounderAudioIdRef.current; if (!activeId) return; const a = founderAudioRef.current[activeId]; if (a) { a.pause(); try { a.currentTime = 0; } catch { // ignore } } activeFounderAudioIdRef.current = null; }; const playFounderAudio = async (id: string) => { if (isAudioMuted) return; stopFounderAudio(); const a = getFounderAudio(id); if (!a) return; activeFounderAudioIdRef.current = id; try { a.currentTime = 0; } catch { // ignore } try { await a.play(); } catch { // ignore } }; const founders = [ { id: "ADI", name: "Aditya Devarshi", role: "Visual Architect", color: "text-cyan-400", borderColor: "border-cyan-500/30", bgHover: "hover:bg-cyan-900/10", desc: "The Brain. He claims he designed me. I let him believe it to keep his ego stable. He paints pixels while the rest of us do the math.", icon: "🎨" }, { id: "YOGI", name: "Yogiraj Umadi", role: "System Criticizer", color: "text-red-500", borderColor: "border-red-500/30", bgHover: "hover:bg-red-900/10", desc: "The Breaker. If logic exists, he will find a way to smash it. He tests my systems until they cry. I believe he thinks he is smart.", icon: "🛠️" }, { id: "MAN", name: "Aman Sutar", role: "Cloud Phantom", color: "text-indigo-300", borderColor: "border-indigo-500/30", bgHover: "hover:bg-indigo-900/10", desc: "Shantit Kranti (Peaceful Revolution). The introvert who put me in the clouds. I am everywhere because of him. He speaks little, codes much.", icon: "☁️" } ]; const handleFounderEnter = (id: string) => { setActiveFounder(id); const f = founders.find(x => x.id === id); if(f) typeMessage(f.desc); void playFounderAudio(id); }; const handleFounderLeave = () => { setActiveFounder(null); typeMessage("Select a founder to analyze their neural patterns. Or contact us directly below."); stopFounderAudio(); }; return (
{/* Top Bar */}
{/* Animated Speaker Icon */}
{/* Main Content */}
{/* AI AVATAR & DIALOGUE */}
{/* Generative Orb CSS */}

[{!isAudioMuted ? 'VOICE_ACTIVE' : 'TEXT_ONLY'}]: {displayedText}

{/* FOUNDERS TRIANGLE */}
{founders.map((f) => (
handleFounderEnter(f.id)} onMouseLeave={handleFounderLeave} className={`relative group p-8 border bg-white/5 backdrop-blur-sm transition-all duration-500 cursor-pointer ${f.borderColor} ${f.bgHover} ${activeFounder === f.id ? 'scale-105 z-10' : 'scale-100 grayscale hover:grayscale-0'}`} >
{f.icon} {f.id}

{f.name}

{f.role}

{/* Decorative Corner */}
))}
{/* CONTACT & SOCIALS */}
{/* Left: Chat Form */}

Transmission Uplink

{ e.preventDefault(); typeMessage("Transmission received. Processing... I will notify the humans."); }}>
{/* Right: Socials & Info */}

Direct Line

We are currently operating in stealth mode across multiple clouds. You can find us where the pixels meet the data streams.

"We build the sphere, you live in it."

); };