// App — top-level router. Hash-based: #/projects, #/project/, #/manufacturing, etc. function App() { const [route, setRoute] = useState({ page: "home" }); const [lang, setLang] = useState("en"); const [tweaksTick, setTweaksTick] = useState(0); // Push to URL hash; restore on back/forward. useEffect(() => { const toHash = (r) => { if (r.page === "home") return "#/"; if (r.page === "project" && r.id) return `#/project/${r.id}`; if (r.page === "projects" && r.sector) return `#/projects/${r.sector.toLowerCase().replace(/ /g, "-").replace("&", "and")}`; return `#/${r.page}`; }; const hash = toHash(route); if (window.location.hash !== hash) window.history.replaceState(null, "", hash); window.scrollTo({ top: 0, behavior: "instant" }); }, [route]); useEffect(() => { const fromHash = () => { const h = window.location.hash.replace(/^#\/?/, ""); if (!h) return { page: "home" }; const parts = h.split("/"); if (parts[0] === "project" && parts[1]) return { page: "project", id: parts[1] }; return { page: parts[0] }; }; const onPop = () => setRoute(fromHash()); window.addEventListener("popstate", onPop); // Initial hash if (window.location.hash) setRoute(fromHash()); return () => window.removeEventListener("popstate", onPop); }, []); // Listen to tweaks changes useEffect(() => { const h = () => setTweaksTick(t => t + 1); window.addEventListener("gli-tweaks-change", h); return () => window.removeEventListener("gli-tweaks-change", h); }, []); const tweaks = window.__gliTweaks || { heroVariant: "lobby", showFactoryStats: true }; // Set RTL on AR useEffect(() => { document.documentElement.dir = lang === "ar" ? "rtl" : "ltr"; }, [lang]); const renderPage = () => { switch (route.page) { case "home": return ; case "projects": return ; case "project": return ; case "sectors": return ; case "manufacturing": return ; case "capabilities": return ; case "about": return ; case "contact": return ; default: return ; } }; return (
); } const root = ReactDOM.createRoot(document.getElementById("root")); root.render();