/* global React, HashBadge, AttestationStatePill */ /* ========================================================= COMMAND PALETTE (⌘K) — fuzzy search over attestations, surfaces, actions ========================================================= */ function CommandPalette({ open, onClose, onNav }) { const [query, setQuery] = React.useState(""); const [sel, setSel] = React.useState(0); const inputRef = React.useRef(null); React.useEffect(() => { if (open && inputRef.current) { inputRef.current.focus(); setQuery(""); setSel(0); } }, [open]); const items = React.useMemo(() => { const all = [ { type: "surface", id: "fraud", label: "Fraud Decision Audit", sub: "surface · 1", action: () => onNav("fraud") }, { type: "surface", id: "sca", label: "SCA / 3DS Attestation", sub: "surface · 2", action: () => onNav("sca") }, { type: "surface", id: "orch", label: "Orchestration Audit", sub: "surface · 3", action: () => onNav("orch") }, { type: "surface", id: "settle", label: "Settlement Gate", sub: "surface · 4", action: () => onNav("settle") }, { type: "surface", id: "flow", label: "Dispute → CE 3.0 Flow", sub: "surface · 5", action: () => onNav("flow") }, { type: "att", id: "ATT-7F4A2C91", label: "ATT-7F4A2C91 · APPROVE · €82.40", sub: "fraud · finalized · 14:22:07.384", action: () => onNav("fraud") }, { type: "att", id: "ATT-7F4A2C90", label: "ATT-7F4A2C90 · DECLINE · €1,240.00", sub: "fraud · finalized · 14:22:07.312", action: () => onNav("fraud") }, { type: "att", id: "ATT-7F4A2C8F", label: "ATT-7F4A2C8F · STEP_UP · €340.10", sub: "fraud · witnessed · 14:22:07.294", action: () => onNav("fraud") }, { type: "att", id: "ATT-7F4A2C8D", label: "ATT-7F4A2C8D · DECLINE · €500.00", sub: "fraud · finalized · 14:22:07.140", action: () => onNav("fraud") }, { type: "att", id: "3DS-9A41C2E7", label: "3DS-9A41C2E7 · passkey · ECI 05", sub: "SCA · finalized · 14:22:06.998", action: () => onNav("sca") }, { type: "att", id: "ROUTE-44C812", label: "ROUTE-44C812 · Adyen selected · €1,240", sub: "orch · finalized", action: () => onNav("orch") }, { type: "att", id: "STL-B0C1-4421", label: "STL-B0C1-4421 · €14.2M batch", sub: "settle · threshold", action: () => onNav("settle") }, { type: "action", id: "theme", label: "Toggle theme (light / dark)", sub: "appearance", action: () => { const r = document.documentElement; r.setAttribute("data-theme", r.getAttribute("data-theme") === "light" ? "dark" : "light"); } }, { type: "action", id: "export", label: "Build evidence pack", sub: "dispute flow · CE 3.0", action: () => onNav("flow") }, { type: "action", id: "replay", label: "Replay last fraud decision", sub: "re-verify proof", action: () => onNav("fraud") }, { type: "action", id: "signer", label: "View signer identity", sub: "HSM · EIP-712", action: () => { if (window.__openSignerOverlay) window.__openSignerOverlay(); } }, { type: "action", id: "shortcuts",label: "Show keyboard shortcuts", sub: "help", action: () => {} }, ]; if (!query) return all; const q = query.toLowerCase(); return all.filter(i => i.label.toLowerCase().includes(q) || i.sub.toLowerCase().includes(q) || i.id.toLowerCase().includes(q)); }, [query, onNav]); React.useEffect(() => { setSel(0); }, [query]); const onKeyDown = e => { if (e.key === "Escape") { onClose(); return; } if (e.key === "ArrowDown") { e.preventDefault(); setSel(s => Math.min(s + 1, items.length - 1)); return; } if (e.key === "ArrowUp") { e.preventDefault(); setSel(s => Math.max(s - 1, 0)); return; } if (e.key === "Enter" && items[sel]) { items[sel].action(); onClose(); } }; if (!open) return null; const typeIcons = { surface: "◈", att: "◆", action: "▸" }; const typeColors = { surface: "var(--ak-accent)", att: "var(--ak-state-signed-fg)", action: "var(--ak-fg-2)" }; return (