{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "autopilot-hero",
  "type": "registry:block",
  "title": "Autopilot Hero",
  "description": "Hero Section built with Autopilot (product demo cursor) and Release Pill (hover changelog badge): a cursor demos the product under the headline. A take on the product demo (interactive demo), cursor (custom cursor) and badge (pill). A hero where the product demos itself. Under the headline, an Autopilot cursor takes a 3am page, reads the trace, writes the fix and opens the pull request in a working incident console, and steps aside when a visitor reaches for the mouse. With a navbar and a Release Pill over the headline.",
  "author": "KeyframeUI <https://keyframeui.com>",
  "categories": [
    "blocks",
    "hero-sections",
    "hero",
    "product-demo",
    "cursor",
    "badge"
  ],
  "docs": "Live preview and the components it's built with: https://keyframeui.com/blocks/hero-sections/autopilot-hero",
  "dependencies": [
    "motion"
  ],
  "registryDependencies": [
    "https://keyframeui.com/r/autopilot.json",
    "https://keyframeui.com/r/release-pill.json"
  ],
  "files": [
    {
      "path": "components/autopilot-hero.tsx",
      "type": "registry:component",
      "content": "\"use client\";\n\nimport * as React from \"react\";\nimport { AnimatePresence, motion, useReducedMotion } from \"motion/react\";\n\nimport { Autopilot, type AutopilotChapter } from \"@/components/ui/autopilot\";\nimport { ReleasePill, type Release } from \"@/components/ui/release-pill\";\n\n/* ── Content ─────────────────────────────────────────────────\n * Everything you'd change to make the hero yours. The incident\n * console under the headline is plain markup further down; the\n * data it shows and the cursor's lines are here too.\n * ─────────────────────────────────────────────────────────── */\n\n/** The one accent: the cursor, the primary buttons and focus rings. */\nconst ACCENT = \"#6e56cf\";\n\nconst BRAND = { name: \"Nightjar\", href: \"#\" };\n\nconst NAV_LINKS = [\n  { label: \"Product\", href: \"#product\" },\n  { label: \"Customers\", href: \"#customers\" },\n  { label: \"Pricing\", href: \"#pricing\" },\n  { label: \"Docs\", href: \"#docs\" },\n];\n\nconst SIGN_IN = { label: \"Sign in\", href: \"#sign-in\" };\nconst NAV_CTA = { label: \"Start free\", href: \"#start\" };\n\nconst RELEASES: Release[] = [\n  {\n    version: \"v3.0\",\n    title: \"Autofix for Kubernetes\",\n    date: \"Oct 21\",\n    href: \"#changelog-v3-0\",\n    summary: \"Rolls back a bad deploy first, then opens the real fix as a pull request.\",\n  },\n  { version: \"v2.9\", title: \"Runbooks from Slack threads\", date: \"Oct 7\", href: \"#changelog-v2-9\" },\n  { version: \"v2.8\", title: \"OpenTelemetry traces\", date: \"Sep 23\", href: \"#changelog-v2-8\" },\n  { version: \"v2.7\", title: \"SOC 2 Type II\", date: \"Sep 9\", href: \"#changelog-v2-7\" },\n];\nconst CHANGELOG_HREF = \"#changelog\";\n\nconst HEADLINE = \"Sleep through the incident.\";\nconst SUBLINE =\n  \"Nightjar is the AI on-call engineer. It takes the page, reads the trace, writes the fix and opens the pull request. You review it over coffee.\";\nconst PRIMARY_CTA = { label: \"Try it on your repo\", href: \"#start\" };\nconst SECONDARY_CTA = { label: \"Book a demo\", href: \"#demo\" };\nconst FOOTNOTE = \"Free for 14 days. Works with GitHub, Datadog and PagerDuty.\";\n\n/* The incident console the cursor works in. */\n\nconst APP_URL = \"app.nightjar.dev/incidents\";\n\n/** The console's clock as the night goes on: waiting, investigating, fixed, shipped. */\nconst CLOCK = [\"3:12 AM\", \"3:13 AM\", \"3:15 AM\", \"3:16 AM\"];\n\ntype Severity = \"SEV-1\" | \"SEV-2\" | \"SEV-3\";\n\nconst INCIDENTS: { id: string; code: string; title: string; service: string; severity: Severity; opened: string }[] = [\n  { id: \"checkout\", code: \"INC-2041\", title: \"5xx spike on /v2/checkout\", service: \"checkout-api\", severity: \"SEV-1\", opened: \"now\" },\n  { id: \"search\", code: \"INC-2039\", title: \"Indexer queue lag over 90s\", service: \"search\", severity: \"SEV-3\", opened: \"26m\" },\n  { id: \"auth\", code: \"INC-2036\", title: \"p99 latency up on /token\", service: \"auth\", severity: \"SEV-3\", opened: \"1h\" },\n];\n\n/** What the console says about an incident nobody needs to wake up for. */\nconst WATCHING =\n  \"Below the paging threshold, so nobody gets woken up. Nightjar keeps watching and pages a human only if it gets worse.\";\n\nconst TRACE = {\n  total: 48, // ms\n  spans: [\n    { id: \"request\", name: \"POST /v2/checkout\", start: 0, end: 48, depth: 0 },\n    { id: \"auth\", name: \"auth.verify\", start: 2, end: 11, depth: 1 },\n    { id: \"cart\", name: \"cart.load\", start: 12, end: 29, depth: 1 },\n    { id: \"totals\", name: \"cart.totals\", start: 30, end: 33, depth: 2 },\n  ],\n  /** The span that threw, and what Nightjar found in it. */\n  cause: {\n    span: \"totals\",\n    error: \"TypeError: Cannot read properties of undefined (reading 'code')\",\n    at: \"applyTax · src/cart/totals.ts:42\",\n    finding: \"Since deploy #8812, 14 min ago. Carts saved before May have no currency.\",\n  },\n};\n\nconst FIX = {\n  file: \"src/cart/totals.ts\",\n  lines: [\n    { kind: \" \", n: 41, text: \"export function applyTax(cart: Cart) {\" },\n    { kind: \"-\", n: 42, text: \"  const rate = TAX_RATES[cart.currency.code];\" },\n    { kind: \"+\", n: 42, text: \"  const code = cart.currency?.code ?? DEFAULT_CURRENCY;\" },\n    { kind: \"+\", n: 43, text: \"  const rate = TAX_RATES[code];\" },\n    { kind: \" \", n: 44, text: \"  return cart.subtotal * (1 + rate);\" },\n  ],\n  title: \"Default the currency on legacy carts\",\n  number: 4821,\n  checks: \"3 checks passed\",\n};\n\n/** The cursor's label as it works. */\nconst SAYS = {\n  page: \"Paged: checkout is failing\",\n  trace: \"Reading the trace\",\n  cause: \"It broke in deploy #8812\",\n  fix: \"Writing the fix\",\n  title: \"Naming the pull request\",\n  open: \"Opening the pull request\",\n  done: \"Fixed. Back to sleep\",\n};\n\n/** The chapters, as the strip under the console names them. */\nconst CHAPTERS = [\"Page\", \"Trace\", \"Fix\", \"Ship\"];\n\n/* ── Hero ────────────────────────────────────────────────── */\n\ntype ConsoleState = {\n  /** The incident open in the console. */\n  incident: string | null;\n  /** The span picked in its trace. */\n  span: string | null;\n  /** The fix is written. */\n  fix: boolean;\n  /** The pull request's title, as typed. */\n  title: string;\n  /** The pull request is open. */\n  pr: boolean;\n};\n\nconst QUIET: ConsoleState = { incident: null, span: null, fix: false, title: \"\", pr: false };\nconst OPENED: ConsoleState = { ...QUIET, incident: \"checkout\" };\nconst FOUND: ConsoleState = { ...OPENED, span: TRACE.cause.span };\nconst WRITTEN: ConsoleState = { ...FOUND, fix: true, title: FIX.title };\n\nconst focusRing =\n  \"focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-(--accent)\";\n\nexport function AutopilotHero() {\n  const [state, setState] = React.useState(QUIET);\n  const update = (patch: Partial<ConsoleState>) => setState((current) => ({ ...current, ...patch }));\n\n  // Each chapter starts from a known state, so a takeover or a jump replays it cleanly.\n  const chapters: AutopilotChapter[] = [\n    {\n      title: CHAPTERS[0],\n      setup: () => setState(QUIET),\n      steps: [\n        { wait: 500 },\n        { move: \"incident-checkout\", say: SAYS.page },\n        { wait: 250 },\n        { click: \"incident-checkout\" },\n        { wait: 400 },\n      ],\n    },\n    {\n      title: CHAPTERS[1],\n      setup: () => setState(OPENED),\n      steps: [\n        { move: \"span-request\", say: SAYS.trace },\n        { wait: 350 },\n        { move: \"span-totals\" },\n        { click: \"span-totals\" },\n        { wait: 1100, say: SAYS.cause },\n      ],\n    },\n    {\n      title: CHAPTERS[2],\n      setup: () => setState(FOUND),\n      steps: [\n        { click: \"write-fix\", say: SAYS.fix },\n        { wait: 900 },\n        { type: FIX.title, into: \"pr-title\", say: SAYS.title },\n        { wait: 300 },\n      ],\n    },\n    {\n      title: CHAPTERS[3],\n      setup: () => setState(WRITTEN),\n      steps: [\n        { click: \"open-pr\", say: SAYS.open },\n        { wait: 1800, say: SAYS.done },\n      ],\n    },\n  ];\n\n  return (\n    <section\n      style={{ \"--accent\": ACCENT } as React.CSSProperties}\n      // The Release Pill draws with the shadcn theme colors; point them at this palette.\n      className=\"relative isolate overflow-hidden bg-white text-zinc-950 [--background:#ffffff] [--foreground:#09090b] [--muted-foreground:#71717a] dark:bg-zinc-950 dark:text-white dark:[--background:#09090b] dark:[--foreground:#fafafa] dark:[--muted-foreground:#a1a1aa]\"\n    >\n      <Backdrop />\n      <Navbar />\n\n      <div className=\"mx-auto max-w-6xl px-6 pt-12 text-center sm:pt-16\">\n        <ReleasePill releases={RELEASES} changelogHref={CHANGELOG_HREF} />\n        <h1 className=\"mx-auto mt-6 max-w-[13ch] text-5xl/[1.02] font-semibold tracking-[-0.035em] text-balance sm:text-6xl/[1] lg:text-7xl/[0.98]\">\n          {HEADLINE}\n        </h1>\n        <p className=\"mx-auto mt-6 max-w-2xl text-base/7 text-pretty text-zinc-600 sm:text-lg/8 dark:text-zinc-400\">\n          {SUBLINE}\n        </p>\n        <div className=\"mt-8 flex flex-wrap items-center justify-center gap-3\">\n          <a\n            href={PRIMARY_CTA.href}\n            className={`group inline-flex h-11 items-center gap-2 rounded-full bg-(--accent) px-5 text-sm font-medium text-white transition-[filter,scale] duration-150 hover:brightness-110 active:scale-[0.98] ${focusRing}`}\n          >\n            {PRIMARY_CTA.label}\n            <ArrowIcon className=\"size-4 transition-transform duration-200 group-hover:translate-x-0.5\" />\n          </a>\n          <a\n            href={SECONDARY_CTA.href}\n            className={`inline-flex h-11 items-center rounded-full bg-white/70 px-5 text-sm font-medium ring-1 ring-zinc-950/10 backdrop-blur-sm transition-colors hover:bg-zinc-950/[0.04] dark:bg-white/[0.04] dark:ring-white/15 dark:hover:bg-white/10 ${focusRing}`}\n          >\n            {SECONDARY_CTA.label}\n          </a>\n        </div>\n        <p className=\"mt-5 text-sm text-zinc-500\">{FOOTNOTE}</p>\n      </div>\n\n      <div className=\"mx-auto mt-10 max-w-6xl px-6 pb-20 sm:mt-12 sm:pb-24\">\n        <Autopilot\n          cursors={[{ id: \"agent\", label: BRAND.name, color: ACCENT, home: [0.7, 0.62] }]}\n          chapters={chapters}\n          chapterStrip\n          park=\"top-right\"\n          className=\"text-zinc-950 dark:text-white\"\n          stageClassName=\"overflow-hidden rounded-2xl border border-zinc-950/10 bg-white shadow-[0_32px_80px_-32px_rgb(9_9_11/0.35)] dark:border-white/10 dark:bg-zinc-900 dark:shadow-[0_32px_80px_-24px_rgb(0_0_0/0.9)]\"\n        >\n          <IncidentConsole state={state} update={update} />\n        </Autopilot>\n      </div>\n    </section>\n  );\n}\n\n/** A faint grid that fades out from the top, and a glow of the accent behind the console. */\nfunction Backdrop() {\n  return (\n    <div aria-hidden className=\"pointer-events-none absolute inset-0 -z-10\">\n      <div className=\"absolute inset-0 bg-[linear-gradient(to_right,rgb(9_9_11/0.06)_1px,transparent_1px),linear-gradient(to_bottom,rgb(9_9_11/0.06)_1px,transparent_1px)] bg-size-[56px_56px] [mask-image:radial-gradient(ellipse_75%_50%_at_50%_0%,#000_35%,transparent_100%)] dark:bg-[linear-gradient(to_right,rgb(255_255_255/0.07)_1px,transparent_1px),linear-gradient(to_bottom,rgb(255_255_255/0.07)_1px,transparent_1px)]\" />\n      <div className=\"absolute top-[46%] left-1/2 h-[26rem] w-[min(60rem,100%)] -translate-x-1/2 rounded-full bg-(--accent)/20 blur-[110px] dark:bg-(--accent)/30\" />\n    </div>\n  );\n}\n\n/* ── Navbar ──────────────────────────────────────────────── */\n\nfunction Navbar() {\n  const [open, setOpen] = React.useState(false);\n  const reduced = useReducedMotion();\n  const rootRef = React.useRef<HTMLElement>(null);\n  const buttonRef = React.useRef<HTMLButtonElement>(null);\n  const menuId = React.useId();\n\n  // Escape or a press outside closes the menu.\n  React.useEffect(() => {\n    if (!open) return;\n    const onKeyDown = (event: KeyboardEvent) => {\n      if (event.key !== \"Escape\") return;\n      setOpen(false);\n      buttonRef.current?.focus();\n    };\n    const onPointerDown = (event: PointerEvent) => {\n      if (!rootRef.current?.contains(event.target as Node)) setOpen(false);\n    };\n    document.addEventListener(\"keydown\", onKeyDown);\n    document.addEventListener(\"pointerdown\", onPointerDown);\n    return () => {\n      document.removeEventListener(\"keydown\", onKeyDown);\n      document.removeEventListener(\"pointerdown\", onPointerDown);\n    };\n  }, [open]);\n\n  return (\n    <header ref={rootRef} className=\"relative z-30 mx-auto max-w-6xl px-6\">\n      <div className=\"flex h-16 items-center justify-between gap-6\">\n        <a href={BRAND.href} className={`-m-1 flex items-center gap-2.5 rounded-lg p-1 font-semibold tracking-tight ${focusRing}`}>\n          <Logo />\n          {BRAND.name}\n        </a>\n\n        <nav aria-label=\"Main\" className=\"hidden items-center gap-1 text-sm md:flex\">\n          {NAV_LINKS.map((link) => (\n            <a\n              key={link.href}\n              href={link.href}\n              className={`rounded-full px-3 py-2 text-zinc-600 transition-colors hover:text-zinc-950 dark:text-zinc-400 dark:hover:text-white ${focusRing}`}\n            >\n              {link.label}\n            </a>\n          ))}\n        </nav>\n\n        <div className=\"hidden items-center gap-2 text-sm md:flex\">\n          <a\n            href={SIGN_IN.href}\n            className={`rounded-full px-3 py-2 text-zinc-600 transition-colors hover:text-zinc-950 dark:text-zinc-400 dark:hover:text-white ${focusRing}`}\n          >\n            {SIGN_IN.label}\n          </a>\n          <a\n            href={NAV_CTA.href}\n            className={`inline-flex h-9 items-center rounded-full bg-zinc-950 px-4 font-medium text-white transition-colors hover:bg-zinc-800 dark:bg-white dark:text-zinc-950 dark:hover:bg-zinc-200 ${focusRing}`}\n          >\n            {NAV_CTA.label}\n          </a>\n        </div>\n\n        <button\n          ref={buttonRef}\n          type=\"button\"\n          aria-expanded={open}\n          aria-controls={menuId}\n          aria-label={open ? \"Close menu\" : \"Open menu\"}\n          onClick={() => setOpen((value) => !value)}\n          className={`-mr-2 grid size-10 place-items-center rounded-full text-zinc-700 transition-colors hover:bg-zinc-950/5 md:hidden dark:text-zinc-300 dark:hover:bg-white/10 ${focusRing}`}\n        >\n          <MenuIcon open={open} />\n        </button>\n      </div>\n\n      <AnimatePresence initial={false}>\n        {open ? (\n          <motion.div\n            id={menuId}\n            initial={{ opacity: 0, y: reduced ? 0 : -6 }}\n            animate={{ opacity: 1, y: 0 }}\n            exit={{ opacity: 0, y: reduced ? 0 : -6 }}\n            transition={{ duration: reduced ? 0.12 : 0.2, ease: [0.22, 1, 0.36, 1] }}\n            className=\"absolute inset-x-4 top-14 rounded-2xl border border-zinc-950/10 bg-white p-2 shadow-[0_24px_48px_-16px_rgb(9_9_11/0.25)] md:hidden dark:border-white/10 dark:bg-zinc-900\"\n          >\n            <nav aria-label=\"Main\">\n              <ul>\n                {NAV_LINKS.map((link) => (\n                  <li key={link.href}>\n                    <a\n                      href={link.href}\n                      onClick={() => setOpen(false)}\n                      className={`flex h-11 items-center rounded-xl px-3 font-medium transition-colors hover:bg-zinc-950/[0.04] dark:hover:bg-white/5 ${focusRing}`}\n                    >\n                      {link.label}\n                    </a>\n                  </li>\n                ))}\n              </ul>\n            </nav>\n            <div className=\"mt-2 grid grid-cols-2 gap-2 border-t border-zinc-950/10 pt-2 dark:border-white/10\">\n              <a\n                href={SIGN_IN.href}\n                onClick={() => setOpen(false)}\n                className={`flex h-11 items-center justify-center rounded-xl text-sm font-medium ring-1 ring-zinc-950/10 dark:ring-white/15 ${focusRing}`}\n              >\n                {SIGN_IN.label}\n              </a>\n              <a\n                href={NAV_CTA.href}\n                onClick={() => setOpen(false)}\n                className={`flex h-11 items-center justify-center rounded-xl bg-zinc-950 text-sm font-medium text-white dark:bg-white dark:text-zinc-950 ${focusRing}`}\n              >\n                {NAV_CTA.label}\n              </a>\n            </div>\n          </motion.div>\n        ) : null}\n      </AnimatePresence>\n    </header>\n  );\n}\n\n/* ── Incident console ────────────────────────────────────── */\n\nfunction IncidentConsole({\n  state,\n  update,\n}: {\n  state: ConsoleState;\n  update: (patch: Partial<ConsoleState>) => void;\n}) {\n  const incident = INCIDENTS.find((item) => item.id === state.incident);\n  const step = state.pr ? 3 : state.fix ? 2 : state.incident ? 1 : 0;\n\n  return (\n    <div className=\"flex h-[36rem] flex-col text-left text-[13px] sm:h-[34rem] md:h-[31rem] lg:h-[30rem]\">\n      <div className=\"flex h-10 shrink-0 items-center gap-3 border-b border-zinc-950/10 px-4 dark:border-white/10\">\n        <span aria-hidden className=\"flex gap-1.5\">\n          <span className=\"size-2.5 rounded-full bg-zinc-950/10 dark:bg-white/15\" />\n          <span className=\"size-2.5 rounded-full bg-zinc-950/10 dark:bg-white/15\" />\n          <span className=\"size-2.5 rounded-full bg-zinc-950/10 dark:bg-white/15\" />\n        </span>\n        <span className=\"flex items-center gap-1.5 font-mono text-[11px] text-zinc-500 tabular-nums dark:text-zinc-400\">\n          <MoonIcon className=\"size-3\" />\n          {CLOCK[step]}\n        </span>\n        <span className=\"mx-auto hidden truncate rounded-md bg-zinc-950/[0.04] px-3 py-1 font-mono text-[11px] text-zinc-500 sm:block dark:bg-white/5 dark:text-zinc-400\">\n          {APP_URL}\n        </span>\n        {/* Kept clear for the cursor, which parks top right while the visitor has control. */}\n        <span aria-hidden className=\"w-16 shrink-0 sm:w-28\" />\n      </div>\n\n      <div className=\"grid min-h-0 flex-1 grid-rows-[auto_minmax(0,1fr)] lg:grid-cols-[17rem_minmax(0,1fr)] lg:grid-rows-1\">\n        <div className=\"border-b border-zinc-950/10 lg:border-r lg:border-b-0 dark:border-white/10\">\n          <p className=\"hidden items-center justify-between px-4 pt-4 pb-1.5 text-[11px] font-medium tracking-wide text-zinc-500 uppercase lg:flex dark:text-zinc-400\">\n            Open incidents\n            <span className=\"tabular-nums\">{INCIDENTS.length}</span>\n          </p>\n          <ul className=\"p-2\">\n            {INCIDENTS.map((item, i) => (\n              <li key={item.id} className={i > 0 ? \"hidden lg:block\" : undefined}>\n                <button\n                  type=\"button\"\n                  data-autopilot={`incident-${item.id}`}\n                  aria-current={state.incident === item.id ? \"true\" : undefined}\n                  onClick={() => update({ incident: item.id })}\n                  className={`flex w-full items-start gap-2.5 rounded-lg px-2.5 py-2 text-left transition-[background-color,scale] duration-150 hover:bg-zinc-950/[0.04] active:scale-[0.99] aria-[current=true]:bg-zinc-950/[0.06] data-[autopilot-hover]:bg-zinc-950/[0.04] data-[autopilot-press]:scale-[0.99] dark:hover:bg-white/5 dark:aria-[current=true]:bg-white/[0.08] dark:data-[autopilot-hover]:bg-white/5 ${focusRing}`}\n                >\n                  <SeverityDot severity={item.severity} live={i === 0 && !state.incident} />\n                  <span className=\"min-w-0 flex-1\">\n                    <span className=\"block truncate font-medium\">{item.title}</span>\n                    <span className=\"mt-0.5 block truncate text-[11px] text-zinc-500 dark:text-zinc-400\">\n                      {item.code} · {item.service} · {item.opened}\n                    </span>\n                  </span>\n                  <SeverityTag severity={item.severity} />\n                </button>\n              </li>\n            ))}\n          </ul>\n        </div>\n\n        <div className=\"min-h-0 p-3 sm:p-5\">\n          {!incident ? (\n            <Waiting />\n          ) : incident.id === OPENED.incident ? (\n            <Investigation state={state} update={update} />\n          ) : (\n            <Watching code={incident.code} title={incident.title} />\n          )}\n        </div>\n      </div>\n    </div>\n  );\n}\n\nfunction Waiting() {\n  return (\n    <div className=\"grid h-full place-items-center text-center\">\n      <div className=\"max-w-60\">\n        <span className=\"mx-auto grid size-10 place-items-center rounded-full bg-zinc-950/[0.04] text-zinc-500 dark:bg-white/5 dark:text-zinc-400\">\n          <MoonIcon className=\"size-4\" />\n        </span>\n        <p className=\"mt-3 font-medium\">{INCIDENTS.length} open incidents</p>\n        <p className=\"mt-1 text-zinc-500 dark:text-zinc-400\">One just paged. Open it to watch {BRAND.name} work.</p>\n      </div>\n    </div>\n  );\n}\n\nfunction Watching({ code, title }: { code: string; title: string }) {\n  return (\n    <div className=\"flex h-full flex-col rounded-xl border border-dashed border-zinc-950/15 p-4 dark:border-white/15\">\n      <p className=\"text-[11px] text-zinc-500 dark:text-zinc-400\">{code}</p>\n      <p className=\"mt-0.5 font-medium\">{title}</p>\n      <p className=\"mt-3 max-w-sm text-zinc-600 text-pretty dark:text-zinc-400\">{WATCHING}</p>\n      <svg aria-hidden viewBox=\"0 0 200 40\" preserveAspectRatio=\"none\" className=\"mt-auto h-16 w-full text-(--accent)\">\n        <polyline\n          points=\"0,30 20,28 40,31 60,26 80,27 100,22 120,24 140,19 160,21 180,18 200,20\"\n          fill=\"none\"\n          stroke=\"currentColor\"\n          strokeWidth=\"1.5\"\n          vectorEffect=\"non-scaling-stroke\"\n        />\n      </svg>\n    </div>\n  );\n}\n\nfunction Investigation({ state, update }: { state: ConsoleState; update: (patch: Partial<ConsoleState>) => void }) {\n  const incident = INCIDENTS.find((item) => item.id === OPENED.incident)!;\n  const status = state.pr\n    ? { label: \"Mitigated\", tone: \"bg-emerald-500/10 text-emerald-700 dark:text-emerald-300\", dot: \"bg-emerald-500\" }\n    : state.fix\n      ? { label: \"Fix ready\", tone: \"bg-(--accent)/10 text-(--accent) dark:text-[color-mix(in_oklab,var(--accent),white_45%)]\", dot: \"bg-(--accent)\" }\n      : { label: \"Investigating\", tone: \"bg-amber-500/10 text-amber-700 dark:text-amber-300\", dot: \"bg-amber-500\" };\n\n  return (\n    <div className=\"flex h-full flex-col gap-3 sm:gap-4\">\n      <div className=\"flex items-start justify-between gap-3\">\n        <div className=\"min-w-0\">\n          <p className=\"text-[11px] text-zinc-500 dark:text-zinc-400\">\n            {incident.code} · {incident.service}\n          </p>\n          <p className=\"mt-0.5 hidden truncate text-sm font-semibold lg:block\">{incident.title}</p>\n        </div>\n        <span\n          className={`inline-flex shrink-0 items-center gap-1.5 rounded-full px-2.5 py-1 text-[11px] font-medium ${status.tone}`}\n        >\n          <span aria-hidden className={`size-1.5 rounded-full ${status.dot}`} />\n          {status.label}\n        </span>\n      </div>\n\n      <div className=\"grid min-h-0 flex-1 grid-rows-[auto_minmax(0,1fr)] gap-3 md:grid-cols-2 md:grid-rows-1 md:gap-4\">\n        <TraceCard picked={state.span} folded={state.fix} onPick={(span) => update({ span })} />\n        <FixCard state={state} update={update} />\n      </div>\n    </div>\n  );\n}\n\nfunction TraceCard({\n  picked,\n  folded,\n  onPick,\n}: {\n  picked: string | null;\n  /** Below md, once the fix is written, the trace folds down to its finding to make room. */\n  folded: boolean;\n  onPick: (span: string) => void;\n}) {\n  const span = TRACE.spans.find((item) => item.id === picked);\n  const cause = TRACE.cause;\n\n  return (\n    <div className=\"flex min-h-0 flex-col overflow-hidden rounded-xl border border-zinc-950/10 bg-zinc-950/[0.015] dark:border-white/10 dark:bg-white/[0.02]\">\n      <div className=\"flex h-9 shrink-0 items-center justify-between gap-3 border-b border-zinc-950/10 px-3 dark:border-white/10\">\n        <span className=\"font-medium\">Trace</span>\n        <span className=\"truncate font-mono text-[11px] text-zinc-500 tabular-nums dark:text-zinc-400\">\n          {TRACE.total} ms · 500\n        </span>\n      </div>\n      <ul className={`p-1.5 ${folded ? \"max-md:hidden\" : \"\"}`}>\n        {TRACE.spans.map((item) => {\n          const failed = item.id === cause.span;\n          return (\n            <li key={item.id}>\n              <button\n                type=\"button\"\n                data-autopilot={`span-${item.id}`}\n                aria-pressed={picked === item.id}\n                onClick={() => onPick(item.id)}\n                className={`grid w-full grid-cols-[minmax(0,7.5rem)_minmax(0,1fr)_2.75rem] items-center gap-2 rounded-md px-2 py-1.5 text-left transition-colors hover:bg-zinc-950/[0.04] aria-pressed:bg-zinc-950/[0.06] data-[autopilot-hover]:bg-zinc-950/[0.04] dark:hover:bg-white/5 dark:aria-pressed:bg-white/[0.08] dark:data-[autopilot-hover]:bg-white/5 ${focusRing}`}\n              >\n                <span\n                  className={`truncate font-mono text-[11px] ${failed ? \"text-rose-600 dark:text-rose-400\" : \"\"}`}\n                  style={{ paddingLeft: item.depth * 10 }}\n                >\n                  {item.name}\n                </span>\n                <span aria-hidden className=\"relative h-1.5 rounded-full bg-zinc-950/[0.05] dark:bg-white/[0.06]\">\n                  <span\n                    className={`absolute inset-y-0 rounded-full ${failed ? \"bg-rose-500\" : \"bg-(--accent)/60\"}`}\n                    style={{\n                      left: `${(item.start / TRACE.total) * 100}%`,\n                      width: `max(4px, ${((item.end - item.start) / TRACE.total) * 100}%)`,\n                    }}\n                  />\n                </span>\n                <span className=\"text-right font-mono text-[11px] text-zinc-500 tabular-nums dark:text-zinc-400\">\n                  {item.end - item.start} ms\n                </span>\n              </button>\n            </li>\n          );\n        })}\n      </ul>\n      {span ? (\n        <div\n          className={`mx-1.5 mb-1.5 rounded-lg px-2.5 py-2 text-[12px] ${\n            span.id === cause.span\n              ? \"bg-rose-500/[0.07] dark:bg-rose-400/10\"\n              : \"bg-zinc-950/[0.03] dark:bg-white/[0.04]\"\n          } ${folded ? \"max-md:mt-1.5\" : \"\"}`}\n        >\n          {span.id === cause.span ? (\n            <>\n              <p className=\"font-mono text-[11px] leading-4 text-rose-700 dark:text-rose-300\">{cause.error}</p>\n              <p className=\"mt-1 hidden font-mono text-[11px] text-zinc-500 sm:block dark:text-zinc-400\">{cause.at}</p>\n              <p className=\"mt-1.5 text-zinc-600 text-pretty dark:text-zinc-300\">{cause.finding}</p>\n            </>\n          ) : (\n            <p className=\"text-zinc-600 dark:text-zinc-300\">\n              <span className=\"font-mono text-[11px]\">{span.name}</span> took {span.end - span.start} ms\n              with no errors.\n            </p>\n          )}\n        </div>\n      ) : null}\n    </div>\n  );\n}\n\nfunction FixCard({ state, update }: { state: ConsoleState; update: (patch: Partial<ConsoleState>) => void }) {\n  const reduced = useReducedMotion();\n  const found = state.span === TRACE.cause.span;\n  const canOpen = state.title.trim() !== \"\";\n\n  return (\n    <div className=\"flex min-h-0 flex-col overflow-hidden rounded-xl border border-zinc-950/10 bg-zinc-950/[0.015] dark:border-white/10 dark:bg-white/[0.02]\">\n      <div className=\"flex h-9 shrink-0 items-center justify-between gap-3 border-b border-zinc-950/10 px-3 dark:border-white/10\">\n        <span className=\"font-medium\">Fix</span>\n        <span className=\"truncate font-mono text-[11px] text-zinc-500 dark:text-zinc-400\">{FIX.file}</span>\n      </div>\n\n      {!state.fix ? (\n        <div className=\"flex flex-1 items-center justify-between gap-3 p-3 md:flex-col md:justify-center md:p-4 md:text-center\">\n          <p className=\"max-w-56 text-[12px] text-zinc-500 text-pretty md:text-[13px] dark:text-zinc-400\">\n            {found ? \"Root cause found. The fix is one line.\" : \"Pick the span that failed to see why.\"}\n          </p>\n          <button\n            type=\"button\"\n            data-autopilot=\"write-fix\"\n            onClick={() => update({ fix: true, span: TRACE.cause.span })}\n            className={`inline-flex h-8 shrink-0 items-center gap-1.5 rounded-full bg-(--accent) px-3.5 text-xs font-medium text-white transition-[filter,scale] duration-150 hover:brightness-110 active:scale-[0.97] data-[autopilot-hover]:brightness-110 data-[autopilot-press]:scale-[0.97] ${focusRing}`}\n          >\n            <SparkIcon className=\"size-3.5\" />\n            Write the fix\n          </button>\n        </div>\n      ) : (\n        <>\n          <div className=\"min-h-0 flex-1 overflow-hidden px-1.5 py-2 font-mono text-[11px] leading-[18px]\">\n            {FIX.lines.map((line, i) => (\n              <motion.div\n                key={i}\n                initial={reduced ? false : { opacity: 0, x: -6 }}\n                animate={{ opacity: 1, x: 0 }}\n                transition={{ duration: 0.25, delay: i * 0.07, ease: [0.22, 1, 0.36, 1] }}\n                className={`flex gap-2 rounded px-1.5 ${\n                  line.kind === \"+\"\n                    ? \"bg-emerald-500/10 text-emerald-800 dark:text-emerald-300\"\n                    : line.kind === \"-\"\n                      ? \"bg-rose-500/10 text-rose-800 dark:text-rose-300\"\n                      : \"text-zinc-600 dark:text-zinc-400\"\n                }`}\n              >\n                <span aria-hidden className=\"w-4 shrink-0 text-right text-zinc-400 tabular-nums select-none dark:text-zinc-500\">\n                  {line.n}\n                </span>\n                <span className=\"w-2 shrink-0 select-none\">{line.kind === \" \" ? \"\" : line.kind}</span>\n                <span className=\"min-w-0 truncate whitespace-pre\">{line.text}</span>\n              </motion.div>\n            ))}\n          </div>\n\n          <div className=\"shrink-0 border-t border-zinc-950/10 p-2 dark:border-white/10\">\n            {state.pr ? (\n              <motion.p\n                initial={reduced ? false : { opacity: 0, y: 4 }}\n                animate={{ opacity: 1, y: 0 }}\n                transition={{ duration: 0.3, ease: [0.22, 1, 0.36, 1] }}\n                className=\"flex h-8 items-center gap-2 px-1.5 text-[12px]\"\n              >\n                <PullRequestIcon className=\"size-3.5 text-emerald-600 dark:text-emerald-400\" />\n                <span className=\"font-medium\">#{FIX.number} opened</span>\n                <span className=\"truncate text-zinc-500 dark:text-zinc-400\">{FIX.checks}</span>\n              </motion.p>\n            ) : (\n              <div className=\"flex gap-2\">\n                <input\n                  data-autopilot=\"pr-title\"\n                  value={state.title}\n                  onChange={(event) => update({ title: event.target.value })}\n                  onKeyDown={(event) => {\n                    if (event.key === \"Enter\" && canOpen) update({ pr: true });\n                  }}\n                  placeholder=\"Pull request title\"\n                  aria-label=\"Pull request title\"\n                  className=\"h-8 min-w-0 flex-1 rounded-lg border border-zinc-950/10 bg-white px-2.5 text-base outline-none placeholder:text-zinc-400 focus:border-(--accent) focus:ring-3 focus:ring-(--accent)/20 data-[autopilot-focus]:border-(--accent) data-[autopilot-focus]:ring-3 data-[autopilot-focus]:ring-(--accent)/20 sm:text-xs dark:border-white/10 dark:bg-zinc-950\"\n                />\n                <button\n                  type=\"button\"\n                  data-autopilot=\"open-pr\"\n                  disabled={!canOpen}\n                  onClick={() => update({ pr: true })}\n                  className={`inline-flex h-8 shrink-0 items-center gap-1.5 rounded-lg bg-(--accent) px-3 text-xs font-medium text-white transition-[filter,scale,opacity] duration-150 hover:brightness-110 active:scale-[0.97] disabled:opacity-40 data-[autopilot-hover]:brightness-110 data-[autopilot-press]:scale-[0.97] ${focusRing}`}\n                >\n                  <PullRequestIcon className=\"size-3.5\" />\n                  Open PR\n                </button>\n              </div>\n            )}\n          </div>\n        </>\n      )}\n    </div>\n  );\n}\n\n/* ── Small parts ─────────────────────────────────────────── */\n\nconst SEVERITY: Record<Severity, { dot: string; tag: string }> = {\n  \"SEV-1\": { dot: \"bg-rose-500\", tag: \"bg-rose-500/10 text-rose-700 dark:text-rose-300\" },\n  \"SEV-2\": { dot: \"bg-amber-500\", tag: \"bg-amber-500/10 text-amber-700 dark:text-amber-300\" },\n  \"SEV-3\": { dot: \"bg-zinc-400\", tag: \"bg-zinc-950/5 text-zinc-600 dark:bg-white/10 dark:text-zinc-300\" },\n};\n\nfunction SeverityDot({ severity, live }: { severity: Severity; live: boolean }) {\n  return (\n    <span aria-hidden className=\"relative mt-1.5 flex size-2 shrink-0\">\n      {live ? (\n        <span\n          className={`absolute inset-0 animate-ping rounded-full opacity-60 motion-reduce:animate-none ${SEVERITY[severity].dot}`}\n        />\n      ) : null}\n      <span className={`relative size-2 rounded-full ${SEVERITY[severity].dot}`} />\n    </span>\n  );\n}\n\nfunction SeverityTag({ severity }: { severity: Severity }) {\n  return (\n    <span className={`shrink-0 rounded px-1.5 py-px font-mono text-[10px] leading-4 font-medium ${SEVERITY[severity].tag}`}>\n      {severity}\n    </span>\n  );\n}\n\nfunction Logo() {\n  return (\n    <span aria-hidden className=\"grid size-7 place-items-center rounded-lg bg-(--accent) text-white\">\n      <MoonIcon className=\"size-4\" />\n    </span>\n  );\n}\n\nfunction MoonIcon({ className }: { className?: string }) {\n  return (\n    <svg viewBox=\"0 0 16 16\" fill=\"currentColor\" aria-hidden className={className}>\n      <path d=\"M13.6 10.2A6 6 0 0 1 5.8 2.4a6 6 0 1 0 7.8 7.8Z\" />\n    </svg>\n  );\n}\n\nfunction ArrowIcon({ className }: { className?: string }) {\n  return (\n    <svg viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.75\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden className={className}>\n      <path d=\"M3 8h10M9 4l4 4-4 4\" />\n    </svg>\n  );\n}\n\nfunction SparkIcon({ className }: { className?: string }) {\n  return (\n    <svg viewBox=\"0 0 16 16\" fill=\"currentColor\" aria-hidden className={className}>\n      <path d=\"M8 1.5c.3 2.9 1.6 4.2 4.5 4.5-2.9.3-4.2 1.6-4.5 4.5-.3-2.9-1.6-4.2-4.5-4.5C6.4 5.7 7.7 4.4 8 1.5Z\" />\n      <path d=\"M12.5 10c.15 1.3.7 1.85 2 2-1.3.15-1.85.7-2 2-.15-1.3-.7-1.85-2-2 1.3-.15 1.85-.7 2-2Z\" />\n    </svg>\n  );\n}\n\nfunction PullRequestIcon({ className }: { className?: string }) {\n  return (\n    <svg viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.5\" strokeLinecap=\"round\" aria-hidden className={className}>\n      <circle cx=\"4\" cy=\"3.5\" r=\"1.5\" />\n      <circle cx=\"4\" cy=\"12.5\" r=\"1.5\" />\n      <circle cx=\"12\" cy=\"12.5\" r=\"1.5\" />\n      <path d=\"M4 5v6M12 11V6.5a2 2 0 0 0-2-2H7.5M9 3 7.5 4.5 9 6\" />\n    </svg>\n  );\n}\n\nfunction MenuIcon({ open }: { open: boolean }) {\n  return (\n    <svg viewBox=\"0 0 20 20\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.75\" strokeLinecap=\"round\" aria-hidden className=\"size-5\">\n      <path d={open ? \"M5 5l10 10\" : \"M3.5 7h13\"} />\n      <path d={open ? \"M15 5 5 15\" : \"M3.5 13h13\"} />\n    </svg>\n  );\n}\n"
    }
  ]
}