/* global React, Logo, Btn, Icon */ const { useState, useEffect, useRef } = React; // Resolve URL prefix: pages in /servicios/* need '../' to reach root. // Centralised so every link in the Nav is consistent across depths. const ROOT = (typeof window !== 'undefined' && (window.location.pathname.includes('/servicios/') || window.location.pathname.includes('/blog/'))) ? '../' : ''; const SERVICES = [ { label: 'Ethical Hacking', href: ROOT + 'servicios/ethical-hacking.html', desc: 'Pentesting & Red Team' }, { label: 'Offensive Security', href: ROOT + 'servicios/offensive-security.html', desc: 'Adversary simulation' }, { label: 'Defensive Team', href: ROOT + 'servicios/defensive-team.html', desc: 'Blue Team & SOC' }, { label: 'DevSecOps', href: ROOT + 'servicios/devsecops.html', desc: 'Pipelines seguros' }, { label: 'GRC', href: ROOT + 'servicios/grc.html', desc: 'Gobierno, Riesgo y Cumplimiento' }, { label: 'Prevención de Riesgos', href: ROOT + 'servicios/prevencion-de-riesgos.html', desc: 'Análisis & continuidad' }, { label: 'Cyber Threat Intelligence', href: ROOT + 'servicios/cyber-threat-intelligence.html', desc: 'Dark Web & marca digital' }, ]; const Nav = () => { const [scrolled, setScrolled] = useState(false); const [openServices, setOpenServices] = useState(false); const closeT = useRef(null); useEffect(() => { const onScroll = () => setScrolled(window.scrollY > 12); window.addEventListener('scroll', onScroll); return () => window.removeEventListener('scroll', onScroll); }, []); // Top-level pages — all real files, all clean relative paths from any depth. // "Inicio" is rendered separately BEFORE the Servicios dropdown. // The rest follow after it. // On the home page, anchor links should be pure hashes so they scroll smoothly // instead of forcing a full page reload to a same-document URL. const onHome = typeof window !== 'undefined' && !window.location.pathname.includes('/servicios/'); const homeHref = onHome ? '#top' : ROOT + 'index.html'; const arianaHref = onHome ? '#ariana' : ROOT + 'index.html#ariana'; const casosHref = onHome ? '#casos' : ROOT + 'index.html#casos'; const homeLink = { label: 'Inicio', href: homeHref }; const links = [ { label: 'Ariana', href: arianaHref }, { label: 'Casos de uso', href: casosHref }, { label: 'Blog', href: ROOT + 'Blog.html' }, { label: 'Contacto', href: ROOT + 'contacto.html' }, ]; const openMenu = () => { clearTimeout(closeT.current); setOpenServices(true); }; const closeMenu = () => { closeT.current = setTimeout(() => setOpenServices(false), 120); }; return ( ); }; window.Nav = Nav;