---
import BrandLogo from './BrandLogo.astro';
import PalettePicker from './PalettePicker.astro';
import Icon from './Icon.astro';
import { url } from '../lib/url';
const MAIN_SITE = 'https://daemon-sec.xyz';
// This site's source, on the read-only Git mirror (browse, or `git clone`).
const SOURCE = 'https://git.daemon-sec.xyz/daemon-sec-lotl/';
/**
* The masthead, in the main site's grammar (daemon-sec.xyz `Masthead`): a
* shared brand logo on the left, numbered mono nav in the centre, and the action
* cluster on the right. Each nav entry owns a hue and its index wears it, so
* the bar reads as the colour legend the rest of the site keys back to.
*
* The nav entries and the search / theme / mobile wiring are the cheat-sheet
* site's own — `[data-search-open]`, `[data-theme-toggle]` and
* `[data-mobile-nav-toggle]` are bound in scripts/app.ts and SearchModal.
*/
const NAV: { n: string; label: string; href: string; acc: string; exact?: boolean }[] = [
{ n: '01', label: 'Catalog', href: url('catalog'), acc: 'love' },
{ n: '02', label: 'GTFOBins', href: url('gtfobins'), acc: 'foam' },
{ n: '03', label: 'LOLBAS', href: url('lolbas'), acc: 'iris' },
{ n: '04', label: 'WADComs', href: url('wadcoms'), acc: 'gold' },
{ n: '05', label: 'LOOBins', href: url('loobins'), acc: 'rose' },
{ n: '06', label: 'DÆMON', href: url('daemon'), acc: 'love' },
{ n: '07', label: 'Credits', href: url('credits'), acc: 'pine' },
];
/* Trailing slashes are `ignore`d by the build, so both spellings of a path
reach here and an exact match would leave the bar saying nowhere. */
const here = Astro.url.pathname.replace(/\/+$/, '') || '/';
const isActive = (href: string, exact?: boolean) => {
const target = href.replace(/\/+$/, '') || '/';
return exact ? here === target : here === target || here.startsWith(target + '/');
};
---
<header class="mast site-header">
<div class="archive mast__row">
<a class="mast__brand dmn-brand-link" href={url('')} aria-label="DAEMON//SEC — home">
<BrandLogo />
</a>
<nav class="mast__nav" aria-label="Sections">
{NAV.map((item) => (
<a
class="mast__navitem"
href={item.href}
style={`--acc: var(--${item.acc});`}
aria-current={isActive(item.href, item.exact) ? 'page' : undefined}
>
<span class="n">{item.n}</span><span class="lbl">{item.label}</span>
<span class="rule" aria-hidden="true"></span>
</a>
))}
</nav>
<div class="mast__actions">
<span class="mast__status" aria-hidden="true">
<span class="dmn-dot" style="--dot: var(--love);"><i class="dmn-anim-pulse"></i><u class="dmn-anim-ring"></u></span>
<span>Offline · Pagefind</span>
</span>
<button class="mast__icon" data-search-open type="button" aria-label="Search the vault">
<Icon name="search" /><kbd>/</kbd>
</button>
<button class="mast__icon mast__mode" data-theme-toggle type="button" aria-label="Dark mode">
<span class="icon-sun"><Icon name="sun" /></span>
<span class="icon-moon"><Icon name="moon" /></span>
</button>
<PalettePicker />
<a class="mast__icon" href={SOURCE} target="_blank" rel="noopener" aria-label="Source code on git.daemon-sec.xyz" title="Source · git.daemon-sec.xyz"><Icon name="branch" /></a>
<a class="mast__icon" href={MAIN_SITE} rel="noopener" aria-label="Back to DÆMON — main site"><Icon name="external" /></a>
<button
class="mast__burger"
data-mobile-nav-toggle
type="button"
aria-label="Open navigation"
aria-controls="mobile-primary-nav"
aria-expanded="false"
>
<i></i><i></i><i></i>
</button>
</div>
</div>
<nav id="mobile-primary-nav" class="mast__mobile" data-mobile-nav aria-label="Primary mobile" hidden>
{NAV.map((item) => (
<a
href={item.href}
style={`--acc: var(--${item.acc});`}
aria-current={isActive(item.href, item.exact) ? 'page' : undefined}
>
<span class="n">{item.n}</span>{item.label}
<span class="arrow" aria-hidden="true">→</span>
</a>
))}
<a href={MAIN_SITE} rel="noopener">
<span class="n" style="--acc: var(--foam);">↗</span>Main site
<span class="arrow" aria-hidden="true" style="--acc: var(--foam);">↗</span>
</a>
<a href={SOURCE} target="_blank" rel="noopener">
<span class="n" style="--acc: var(--gold);">↗</span>Source
<span class="arrow" aria-hidden="true" style="--acc: var(--gold);">↗</span>
</a>
</nav>
</header>