import React, { useEffect, useState } from "react"; import { Link, useLocation, Navigate } from "react-router-dom"; import { Menu, X, ChevronRight, Lock, Home, ExternalLink } from "lucide-react"; import { useAuth } from "@/contexts/AuthContext"; interface NavSpace { id: string; title: string; emoji: string; description: string; pages: NavPage[]; } interface NavPage { title: string; path: string; description?: string; } const spaces: NavSpace[] = [ { id: "space1", title: "START HERE", emoji: "🚀", description: "For All New Members", pages: [ { title: "Welcome", path: "/internal-docs", description: "Welcome to AeThex Ecosystem", }, { title: "Axiom Model", path: "/internal-docs/axiom-model", description: "Our 3-entity structure", }, { title: "Find Your Role", path: "/internal-docs/find-your-role", description: "Who are you in the ecosystem?", }, ], }, { id: "space2", title: "ECOSYSTEM-WIDE", emoji: "🌍", description: "Universal Rules", pages: [ { title: "Code of Conduct", path: "/internal-docs/code-of-conduct", description: "How we act", }, { title: "Communication Protocol", path: "/internal-docs/communication", description: "Discord, Slack, meetings", }, { title: "Meeting Cadence", path: "/internal-docs/meetings", description: "When & how we meet", }, { title: "Brand & Voice", path: "/internal-docs/brand", description: "How we talk publicly", }, { title: "Tech Stack", path: "/internal-docs/tech-stack", description: "Tools we use", }, ], }, { id: "space3", title: "THE FOUNDATION", emoji: "🏛️", description: "The Guardian", pages: [ { title: "Governance Model", path: "/internal-docs/foundation-governance", description: "The Parliament", }, { title: "Open-Source Protocol", path: "/internal-docs/foundation-protocol", description: "The AI Foundry", }, { title: "Community Programs", path: "/internal-docs/foundation-programs", description: "The University", }, ], }, { id: "space4", title: "THE CORP", emoji: "⚙️", description: "The Engine", pages: [ { title: "Product & Engineering", path: "/internal-docs/corp-product", description: "Development lifecycle", }, { title: "Product Blueprints", path: "/internal-docs/corp-blueprints", description: "The Factory", }, { title: "Client & Sales Ops", path: "/internal-docs/corp-clients", description: "Client onboarding & hiring", }, { title: "Platform Strategy", path: "/internal-docs/corp-platform", description: "The Monolith", }, ], }, { id: "space5", title: "PEOPLE & FINANCE", emoji: "👥", description: "Back Office", pages: [ { title: "Onboarding", path: "/internal-docs/onboarding", description: "New hire handbook", }, { title: "Finance & Payments", path: "/internal-docs/finance", description: "Invoicing & expenses", }, ], }, ]; interface InternalDocsLayoutProps { children: React.ReactNode; title?: string; description?: string; } // Map routes -> source file path so "Edit this page" can link to the component in the repo const SOURCE_MAP: Record = { "/internal-docs": "code/client/pages/internal-docs/Space1Welcome.tsx", "/internal-docs/axiom-model": "code/client/pages/internal-docs/Space1AxiomModel.tsx", "/internal-docs/find-your-role": "code/client/pages/internal-docs/Space1FindYourRole.tsx", "/internal-docs/code-of-conduct": "code/client/pages/internal-docs/Space2CodeOfConduct.tsx", "/internal-docs/communication": "code/client/pages/internal-docs/Space2Communication.tsx", "/internal-docs/meetings": "code/client/pages/internal-docs/Space2MeetingCadence.tsx", "/internal-docs/brand": "code/client/pages/internal-docs/Space2BrandVoice.tsx", "/internal-docs/tech-stack": "code/client/pages/internal-docs/Space2TechStack.tsx", "/internal-docs/foundation-governance": "code/client/pages/internal-docs/Space3FoundationGovernance.tsx", "/internal-docs/foundation-protocol": "code/client/pages/internal-docs/Space3OpenSourceProtocol.tsx", "/internal-docs/foundation-programs": "code/client/pages/internal-docs/Space3CommunityPrograms.tsx", "/internal-docs/corp-product": "code/client/pages/internal-docs/Space4ProductOps.tsx", "/internal-docs/corp-blueprints": "code/client/pages/internal-docs/Space4CorpBlueprints.tsx", "/internal-docs/corp-clients": "code/client/pages/internal-docs/Space4ClientOps.tsx", "/internal-docs/corp-platform": "code/client/pages/internal-docs/Space4PlatformStrategy.tsx", "/internal-docs/onboarding": "code/client/pages/internal-docs/Space5Onboarding.tsx", "/internal-docs/finance": "code/client/pages/internal-docs/Space5Finance.tsx", }; export default function InternalDocsLayout({ children, title, description, }: InternalDocsLayoutProps) { const { user, loading } = useAuth(); const [sidebarOpen, setSidebarOpen] = useState(false); const location = useLocation(); useEffect(() => { // Add copy buttons to code blocks const addCopyButtons = () => { document.querySelectorAll("pre").forEach((pre) => { if ((pre as HTMLElement).dataset.hasCopy === "true") return; (pre as HTMLElement).dataset.hasCopy = "true"; const btn = document.createElement("button"); btn.className = "copy-code-btn absolute right-3 top-3 bg-slate-800/70 text-slate-200 text-xs px-2 py-1 rounded-md hover:bg-slate-800"; btn.innerText = "Copy"; btn.onclick = async () => { const code = pre.querySelector("code")?.textContent || pre.textContent || ""; try { await navigator.clipboard.writeText(code); btn.innerText = "Copied"; setTimeout(() => (btn.innerText = "Copy"), 1500); } catch { btn.innerText = "Copy"; } }; (pre as HTMLElement).style.position = "relative"; (pre as HTMLElement).appendChild(btn); }); }; // Add heading anchors for h2/h3 const addAnchors = () => { const container = document.querySelector(".internal-docs-content"); if (!container) return; container.querySelectorAll("h2, h3").forEach((el) => { if ((el as HTMLElement).querySelector(".heading-anchor")) return; const text = (el.textContent || "").trim(); const id = text .toLowerCase() .replace(/[^a-z0-9]+/g, "-") .replace(/(^-|-$)/g, ""); (el as HTMLElement).id = id; const anchor = document.createElement("a"); anchor.className = "heading-anchor ml-2 text-slate-500 text-sm opacity-0 hover:opacity-100 transition-opacity"; anchor.href = `#${id}`; anchor.innerText = "#"; (el as HTMLElement).appendChild(anchor); }); }; addCopyButtons(); addAnchors(); const obs = new MutationObserver(() => { addCopyButtons(); addAnchors(); }); obs.observe( document.querySelector(".internal-docs-content") || document.body, { childList: true, subtree: true }, ); return () => obs.disconnect(); }, []); useEffect(() => { // close sidebar on navigation (mobile) setSidebarOpen(false); }, [location.pathname]); if (loading) { return (

Loading...

); } if (!user) { return ; } const isCurrentPage = (path: string) => location.pathname === path; const sourcePath = SOURCE_MAP[location.pathname]; const editUrl = sourcePath ? `https://github.com/AeThex-Corporation/aethex-forge/blob/main/${sourcePath}` : undefined; return (
{/* Sidebar */} {/* Main Content */}
{/* Mobile Header */}
← Back
{title && (

{title}

{description && (

{description}

)}
)}
{editUrl && ( Edit this page )}
{children}
{/* Footer */}

© 2025 AeThex. This is an internal operations hub. Information here is confidential and for authorized personnel only.

{/* Inline styles for print and copy button */}
); }