import React, { useState, useEffect, useRef, useCallback } from 'react'; import './App.css'; import Nav from './components/Nav'; import Hero from './components/Hero'; import LiveDemo from './components/LiveDemo'; import Benchmarks from './components/Benchmarks'; import Architecture from './components/Architecture'; import WhatBreaks from './components/WhatBreaks'; import TechStack from './components/TechStack'; import ResumeBullet from './components/ResumeBullet'; import Footer from './components/Footer'; const SECTIONS = ['hero', 'features', 'benchmarks', 'demo', 'failure-analysis', 'tech-stack']; // Extract initial tab from URL hash (e.g. #demo/trigger) function getInitialDemoTab() { const hash = window.location.hash.replace('#', ''); const parts = hash.split('/'); if (parts[0] === 'demo' && parts[1]) { return parts[1]; // nl2sql, trigger, search, dashboard } return null; } function App() { const [activeSection, setActiveSection] = useState('hero'); const [initialDemoTab] = useState(getInitialDemoTab); const observerRef = useRef(null); const handleSectionInView = useCallback((sectionId) => { setActiveSection(sectionId); }, []); useEffect(() => { const observer = new IntersectionObserver( (entries) => { entries.forEach((entry) => { if (entry.isIntersecting) { handleSectionInView(entry.target.id); } }); }, { threshold: 0.3, rootMargin: '-80px 0px 0px 0px' } ); observerRef.current = observer; SECTIONS.forEach((id) => { const el = document.getElementById(id); if (el) observer.observe(el); }); return () => observer.disconnect(); }, [handleSectionInView]); // Handle initial hash navigation on mount useEffect(() => { const hash = window.location.hash.replace('#', ''); if (hash) { const sectionId = hash.split('/')[0]; const timer = setTimeout(() => { const el = document.getElementById(sectionId); if (el) el.scrollIntoView({ behavior: 'smooth' }); }, 500); return () => clearTimeout(timer); } }, []); const scrollToSection = (sectionId) => { const el = document.getElementById(sectionId); if (el) el.scrollIntoView({ behavior: 'smooth' }); // Update hash without triggering a scroll window.history.replaceState(null, '', `#${sectionId}`); }; return (