import { useState, useEffect, useRef } from "react"; const FONT_URL = "https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500;600;700&display=swap"; const TERMINAL_LINES = [ "INIT SEQUENCE 0x4F2A...", "AUTH TOKEN: ██████████████", "SCAN FREQ 847.221 MHz", "SECTOR [CLASSIFIED]", "NODE_ID NX-9912-DELTA", "TIMESTAMP 2025.03.06", "CLEARANCE LEVEL-OMEGA", "STATUS AUTHORIZED", "PAYLOAD ENCRYPTED", "UPLINK ACTIVE", "SIGNAL ████░░░░ 61%", "VERIFY SHA256:c0d3f", "MATRIX 7×7 LATTICE", "HASH 0xDEADBEEF", "PING 12.4ms OK", "TRACE DISABLED", "VAULT SEALED", "PROTOCOL OMEGA-9", "ENTROPY HIGH", "FRAME #00441", "BUFFER FLUSHED", "CIPHER AES-256", "RELAY PROXIED", "ECHO SILENT", "LOCK ENGAGED", "GRID REF 44.0N 76.2W", "KERNEL 3.14.159", "DAEMON RUNNING", "WATCHDOG ARMED", "ROUTE OBFUSCATED", ]; // ── Noise / grain canvas ────────────────────────────────────────────────────── function GrainOverlay({ strength = 0.18 }) { const canvasRef = useRef(); const tick = useRef(0); useEffect(() => { const canvas = canvasRef.current; if (!canvas) return; const ctx = canvas.getContext("2d"); let raf; const draw = () => { tick.current++; if (tick.current % 2 !== 0) { raf = requestAnimationFrame(draw); return; } const { width, height } = canvas; const img = ctx.createImageData(width, height); const d = img.data; for (let i = 0; i < d.length; i += 4) { const px = i / 4; const x = px % width; const y = Math.floor(px / width); const cx = x / width - 0.5, cy = y / height - 0.5; const dist = Math.sqrt(cx * cx + cy * cy); const vignette = Math.min(1, dist * 2.2); const noise = (Math.random() - 0.5) * 255 * (strength + vignette * 0.18); d[i] = d[i + 1] = d[i + 2] = 128 + noise; d[i + 3] = Math.floor(18 + vignette * 30); } ctx.putImageData(img, 0, 0); raf = requestAnimationFrame(draw); }; const resize = () => { canvas.width = canvas.offsetWidth; canvas.height = canvas.offsetHeight; }; resize(); draw(); window.addEventListener("resize", resize); return () => { cancelAnimationFrame(raf); window.removeEventListener("resize", resize); }; }, [strength]); return ( ); } // ── SVG geometric overlay ───────────────────────────────────────────────────── function GeometricOverlay() { return ( {[0.2, 0.4, 0.6, 0.8].map((t) => ( ))} {[0.25, 0.5, 0.75].map((t) => ( ))} ); } // ── Terminal code cascade ───────────────────────────────────────────────────── function TerminalMask() { const [offset, setOffset] = useState(0); const [glitch, setGlitch] = useState({ row: -1, px: 0 }); useEffect(() => { const iv = setInterval(() => { setOffset((o) => (o + 1) % TERMINAL_LINES.length); }, 120); const gv = setInterval(() => { setGlitch({ row: Math.floor(Math.random() * 18), px: (Math.random() - 0.5) * 8 }); setTimeout(() => setGlitch({ row: -1, px: 0 }), 80); }, 900); return () => { clearInterval(iv); clearInterval(gv); }; }, []); const visible = Array.from({ length: 20 }, (_, i) => TERMINAL_LINES[(offset + i) % TERMINAL_LINES.length] ); return (
{visible.map((line, i) => (
{i === 0 ? "▶ " : " "}{line}
))}
); } // ── Barcode SVG ─────────────────────────────────────────────────────────────── function Barcode() { const bars = Array.from({ length: 60 }, (_, i) => { const w = [1, 1, 2, 1, 3, 1, 2, 1, 1, 2][i % 10]; return { w, gap: [2, 1, 2, 3, 1, 2, 1, 2, 3, 1][i % 10] }; }); return ( {bars.reduce((acc, bar, i) => { const x = acc.x; acc.elements.push( ); acc.x += bar.w + bar.gap; return acc; }, { x: 2, elements: [] }).elements} ); } // ── TICKET SHELL with authentic physical edges ──────────────────────────────── // Renders the outer ticket shape as a single SVG clip-path with: // • Scalloped top & bottom edges (zigzag perforations) // • Semicircle punch-outs on both sides at the tear line // • Punched corner rounds // • A perforated dashed-border inner stroke function TicketShell({ children, stubHeight = 120 }) { const W = 460; // SVG viewBox width const H = 820; // SVG viewBox height const R = 14; // corner radius const PR = 9; // top/bottom diamond tooth size const SR = 11; // side diamond notch size (tear notch) const tearY = H - stubHeight; // Y where tear line sits // Diamond zigzag teeth left→right: dir=-1 teeth UP, dir=+1 teeth DOWN const zigzagLR = (x0, x1, y, dir) => { const count = Math.floor((x1 - x0) / (PR * 2.2)); const step = (x1 - x0) / count; let d = ""; for (let i = 0; i < count; i++) { const mx = x0 + i * step + step / 2; const ex = x0 + (i + 1) * step; d += ` L ${mx} ${y + dir * PR} L ${ex} ${y}`; } return d; }; // Diamond zigzag teeth right→left (bottom edge return) const zigzagRL = (x0, x1, y, dir) => { const count = Math.floor((x1 - x0) / (PR * 2.2)); const step = (x1 - x0) / count; let d = ""; for (let i = count - 1; i >= 0; i--) { const mx = x0 + i * step + step / 2; const ex = x0 + i * step; d += ` L ${mx} ${y + dir * PR} L ${ex} ${y}`; } return d; }; const pad = 2; const x0 = pad + R, x1 = W - pad - R; const y0 = pad, y1 = H - pad; // Right side semicircle at tearY (bites into card from right) // Left side semicircle at tearY (bites into card from left) const rightX = W - pad; const leftX = pad; // Build SVG path for clip const path = [ `M ${x0} ${y0}`, // top diamond zigzag edge → zigzagLR(x0, x1, y0, -1), // top-right corner `L ${W - pad - R} ${y0}`, `Q ${W - pad} ${y0} ${W - pad} ${y0 + R}`, // right side down to tear notch `L ${rightX} ${tearY - SR}`, // semi-diamond bite: two lines forming a V-point inward `L ${rightX - SR} ${tearY}`, `L ${rightX} ${tearY + SR}`, // right side continues down `L ${rightX} ${y1 - R}`, // bottom-right corner `Q ${rightX} ${y1} ${x1} ${y1}`, // bottom diamond zigzag edge ← `L ${x1} ${y1}`, zigzagRL(x0, x1, y1, 1), // bottom-left corner `L ${x0} ${y1}`, `Q ${leftX} ${y1} ${leftX} ${y1 - R}`, // left side up from bottom to tear notch `L ${leftX} ${tearY + SR}`, // semi-diamond bite: two lines forming a V-point inward from left `L ${leftX + SR} ${tearY}`, `L ${leftX} ${tearY - SR}`, // left side up to top `L ${leftX} ${y0 + R}`, // top-left corner `Q ${leftX} ${y0} ${x0} ${y0}`, `Z`, ].join(" "); const clipId = "ticket-clip"; const innerId = "ticket-inner"; return (
{/* SVG defs for clip path */} {/* Outer shadow/glow layer */}
{/* The actual ticket content clipped to shape */}
{/* SVG border drawn on top of content */} {/* Outer border */} {/* Inner inset border */} {/* Tear-line dashed rule */} {/* Tear scissors icon hint */} ✂ TEAR {/* Corner punch holes — diamond arrowhead shapes */} {[ [pad + 28, pad + 28], [W - pad - 28, pad + 28], [pad + 28, H - pad - 28], [W - pad - 28, H - pad - 28], ].map(([cx, cy], i) => { const ro = 9; const ri = 4.5; return ( ); })} {/* Perforation diamond dots along tear line */} {Array.from({ length: 18 }, (_, i) => { const spacing = (W - pad * 2 - SR * 2 - 20) / 17; const x = pad + SR + 10 + i * spacing; const r = 2.2; return ( ); })} {children}
); } // ── Main component ──────────────────────────────────────────────────────────── export default function CyberTicket() { const [pulse, setPulse] = useState(false); useEffect(() => { if (!document.getElementById("ibm-plex-mono")) { const link = document.createElement("link"); link.id = "ibm-plex-mono"; link.rel = "stylesheet"; link.href = FONT_URL; document.head.appendChild(link); } const iv = setInterval(() => setPulse((p) => !p), 1400); return () => clearInterval(iv); }, []); const STUB_H = 130; // px — must roughly match SVG tearY portion return (
{/* ambient radial glow */}
{/* ── background fill */}
{/* 1 ── TOP HEADER BAR */}
NEXUS PROTOCOL
CLASSIFIED ACCESS DOCUMENT
Ω-09
© 2025
{/* 2 ── BRANDING BLOCK */}
NEURAL
ACCESS
HIGH-CLEARANCE ADMISSION — SERIES 9 — OMEGA TIER
{/* 3 ── TERMINAL CIRCLE */}
{/* scan status pill */}
SIGNAL {pulse ? "ACTIVE" : "PINGING"}
{/* 4 ── INFO GRID */}
{[ { label: "BEARER", value: "AGENT_NX-44" }, { label: "ISSUED", value: "2025.03.06" }, { label: "CLEARANCE", value: "OMEGA / Ω" }, { label: "EXPIRES", value: "2025.12.31" }, { label: "SECTOR", value: "DELTA-9" }, { label: "NODE", value: "0xDEAD·BF9" }, ].map(({ label, value }) => (
{label}
{value}
))}
{/* subtle divider */}
{Array.from({ length: 3 }).map((_, i) => (
))} {Array.from({ length: 3 }).map((_, i) => (
))}
{/* ── STUB SECTION (below tear line) ── */} {/* Spacer to push stub below the scalloped tear cutout */}
{/* Barcode */}
NX-9912-DELTA-44-0x2F
{/* Stamp area */}
{["★", "◈", "▲"].map((icon, i) => ( {icon} ))}
ADMIT
ONE
{/* bottom vignette */}
{/* ambient page label */}
NEXUS PROTOCOL — DOCUMENT RENDER v9.1 — CLASSIFIED
); }