{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "ai-search-results",
  "title": "AI Search Results Block",
  "description": "An AI search page: a question bar, an AI overview that shows searching, reading and writing steps before streaming an answer with numbered citations, ranked results with highlighted terms and type tabs, and a People also ask panel.",
  "dependencies": [
    "motion",
    "clsx",
    "tailwind-merge"
  ],
  "files": [
    {
      "path": "registry/new-york/ai-search-results/ai-search-results.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\nimport { AnimatePresence, motion, useReducedMotion } from \"motion/react\";\nimport { clsx, type ClassValue } from \"clsx\";\nimport { twMerge } from \"tailwind-merge\";\n\nfunction cn(...inputs: ClassValue[]) {\n  return twMerge(clsx(inputs));\n}\n\nexport interface SearchResult {\n  title: string;\n  url: string;\n  /** Shown as a breadcrumb, e.g. \"docs.acme.com › Security\". */\n  source: string;\n  snippet: string;\n  type?: string;\n  meta?: string;\n}\n\nexport interface SearchAnswer {\n  query: string;\n  /** Markdown-lite: paragraphs, \"- \" bullets, **bold** and [n] citations pointing at results (1-based). */\n  answer: string;\n  results: SearchResult[];\n  related?: { q: string; a: string }[];\n}\n\nexport interface AISearchResultsProps {\n  /** Canned searches. A typed query uses the closest one by shared words. */\n  searches?: SearchAnswer[];\n  /** Run a real search instead. */\n  onSearch?: (query: string) => Promise<SearchAnswer>;\n  /** Result type tabs. \"All\" is added first. */\n  types?: string[];\n  placeholder?: string;\n  /** Run the first search on load. */\n  autoRun?: boolean;\n  theme?: \"dark\" | \"light\";\n  className?: string;\n}\n\nconst PALETTES = {\n  dark: { bg: \"#0A0A0A\", text: \"#F5F4F1\", muted: \"rgba(245,244,241,0.62)\", faint: \"rgba(245,244,241,0.38)\", card: \"#121212\", border: \"rgba(255,255,255,0.09)\", hover: \"rgba(255,255,255,0.04)\", chip: \"rgba(255,255,255,0.06)\", on: \"#F5F4F1\", onText: \"#0A0A0A\", accent: \"#FB923C\", mark: \"rgba(251,146,60,0.18)\", ring: \"rgba(245,244,241,0.6)\", link: \"#F5F4F1\" },\n  light: { bg: \"#FAFAF8\", text: \"#0A0A0A\", muted: \"rgba(10,10,10,0.62)\", faint: \"rgba(10,10,10,0.42)\", card: \"#FFFFFF\", border: \"rgba(10,10,10,0.09)\", hover: \"rgba(10,10,10,0.03)\", chip: \"rgba(10,10,10,0.05)\", on: \"#0A0A0A\", onText: \"#FAFAF8\", accent: \"#EA580C\", mark: \"rgba(234,88,12,0.14)\", ring: \"rgba(10,10,10,0.5)\", link: \"#0A0A0A\" },\n};\nconst GRADIENT = \"linear-gradient(90deg,#FB923C,#EC4899,#8B5CF6,#3B82F6)\";\n\nconst DOCS = \"docs.nexora.io\";\nconst DEFAULT_SEARCHES: SearchAnswer[] = [\n  {\n    query: \"How do I rotate an API key without downtime?\",\n    answer:\n      \"Create the new key first, ship it, then revoke the old one. Nexora lets **two keys be active at the same time** for exactly this [1].\\n- **Create a second key** in Settings → API keys with the same scopes as the old one [1].\\n- **Deploy it** to every service, then watch the old key's Last used column until it stops moving [2].\\n- **Revoke the old key** once its last use is older than your longest job. Requests with a revoked key fail with a 401 within a minute [3].\\nGive new keys an expiry date so the next rotation is already on the calendar [4].\",\n    results: [\n      { title: \"Managing API keys\", url: \"#\", source: `${DOCS} › Security › API keys`, snippet: \"Each workspace can have up to 10 active keys. Create a key with its own scopes and expiry, rotate it without downtime and revoke it instantly.\", type: \"Docs\", meta: \"Updated 3 days ago\" },\n      { title: \"Zero-downtime key rotation\", url: \"#\", source: `${DOCS} › Guides`, snippet: \"Roll a new key out next to the old one, confirm traffic has moved using Last used, then revoke. Works with environment variables and secret managers.\", type: \"Guides\", meta: \"6 min read\" },\n      { title: \"Authentication errors (401)\", url: \"#\", source: `${DOCS} › Reference › Errors`, snippet: \"invalid_api_key means the key is unknown, expired or revoked. Revocation reaches every region within 60 seconds.\", type: \"Docs\", meta: \"Reference\" },\n      { title: \"API keys can now expire\", url: \"#\", source: \"nexora.io › Changelog\", snippet: \"Set an expiry when you create a key and we will email owners 14 days before it stops working.\", type: \"Guides\", meta: \"Oct 2026\" },\n      { title: \"Rotating keys stored in Kubernetes secrets\", url: \"#\", source: \"community.nexora.io › Ops\", snippet: \"We mount both keys during the rollout and flip a feature flag to switch. Zero failed requests across 40 services.\", type: \"Community\", meta: \"18 replies\" },\n      { title: \"nexora keys create\", url: \"#\", source: `${DOCS} › CLI`, snippet: \"Create an API key from the command line: nexora keys create --name ci --scopes write:events --expires 90d\", type: \"Docs\", meta: \"CLI\" },\n    ],\n    related: [\n      { q: \"How many API keys can be active at once?\", a: \"Up to 10 per workspace. Each one has its own scopes, expiry and Last used date.\" },\n      { q: \"Can I limit a key to read-only?\", a: \"Yes. Pick only read scopes such as read:events when you create it. Scopes cannot be widened later; create a new key instead.\" },\n      { q: \"Who gets notified when a key expires?\", a: \"The key's creator and every workspace owner, 14 days and 1 day before expiry.\" },\n    ],\n  },\n  {\n    query: \"Set up SAML single sign-on\",\n    answer:\n      \"SAML SSO is set up from **Settings → Security → Single sign-on** and takes about ten minutes [1].\\n- **Add Nexora as an app** in your identity provider using the ACS URL and entity ID shown on the page [1].\\n- **Upload the metadata XML** from your provider, or paste the sign-in URL and certificate by hand [2].\\n- **Test with one account**, then turn on Require SSO so passwords stop working for your domains [3].\\nKeep one owner outside SSO as a break-glass account in case your provider has an outage [2].\",\n    results: [\n      { title: \"Single sign-on with SAML 2.0\", url: \"#\", source: `${DOCS} › Security › SSO`, snippet: \"Connect any SAML 2.0 identity provider. You will need the ACS URL, the entity ID and your provider's metadata.\", type: \"Docs\", meta: \"Updated last week\" },\n      { title: \"SSO setup checklist\", url: \"#\", source: `${DOCS} › Guides`, snippet: \"Metadata, attribute mapping, a test login and a break-glass owner. Everything to check before you require SSO.\", type: \"Guides\", meta: \"4 min read\" },\n      { title: \"Requiring SSO for a domain\", url: \"#\", source: `${DOCS} › Security`, snippet: \"Once required, members of verified domains must sign in through your provider. Existing sessions end at their next refresh.\", type: \"Docs\", meta: \"Reference\" },\n      { title: \"SAML attribute mapping for groups\", url: \"#\", source: \"community.nexora.io › Identity\", snippet: \"Map your provider's groups attribute to Nexora roles so new hires land with the right access.\", type: \"Community\", meta: \"9 replies\" },\n    ],\n    related: [\n      { q: \"Which plans include SSO?\", a: \"Business and Enterprise. Trials can test SSO with up to 5 accounts.\" },\n      { q: \"Does SSO support automatic provisioning?\", a: \"Yes, through SCIM 2.0 on Enterprise. Users are created and removed as they change in your provider.\" },\n    ],\n  },\n  {\n    query: \"Why are my webhooks being retried?\",\n    answer:\n      \"A webhook is retried when your endpoint **does not answer with a 2xx status within 10 seconds** [1].\\n- **Timeouts** are the most common cause. Acknowledge first and do the slow work in a background job [2].\\n- **Redirects count as failures**, so point the endpoint at the final URL [1].\\n- **Signature checks** that reject the request return a 4xx and are retried too. Use the raw request body when you verify [3].\\nRetries back off for up to 3 days, and each attempt is listed in the delivery log with the response we got [1].\",\n    results: [\n      { title: \"Webhook delivery and retries\", url: \"#\", source: `${DOCS} › Webhooks`, snippet: \"We retry any non-2xx response or timeout with exponential backoff for up to 72 hours. Redirects are not followed.\", type: \"Docs\", meta: \"Updated 2 weeks ago\" },\n      { title: \"Handling webhooks in a queue\", url: \"#\", source: `${DOCS} › Guides`, snippet: \"Return 200 immediately, push the event onto a queue and process it in a worker to stay under the 10 second limit.\", type: \"Guides\", meta: \"7 min read\" },\n      { title: \"Verifying webhook signatures\", url: \"#\", source: `${DOCS} › Webhooks › Security`, snippet: \"Compute an HMAC of the raw body with your signing secret and compare it with the Nexora-Signature header.\", type: \"Docs\", meta: \"Reference\" },\n      { title: \"Duplicate events after deploys\", url: \"#\", source: \"community.nexora.io › Webhooks\", snippet: \"Our pods were killed mid-request during deploys. Graceful shutdown fixed the retries; idempotency keys fixed the duplicates.\", type: \"Community\", meta: \"12 replies\" },\n    ],\n    related: [\n      { q: \"Can I replay a failed webhook?\", a: \"Yes. Open the event in the delivery log and press Resend, or resend every failed event for an endpoint at once.\" },\n      { q: \"Are webhooks delivered in order?\", a: \"Not guaranteed. Use the created timestamp in the payload to order events.\" },\n    ],\n  },\n];\n\ntype Tok = { k: \"w\"; v: string; b: boolean } | { k: \"c\"; n: number } | { k: \"p\" } | { k: \"li\" };\nfunction tokenize(answer: string): Tok[] {\n  const out: Tok[] = [];\n  answer.split(\"\\n\").forEach((line) => {\n    const li = line.startsWith(\"- \");\n    out.push(li ? { k: \"li\" } : { k: \"p\" });\n    (li ? line.slice(2) : line).split(/(\\*\\*[^*]+\\*\\*|\\[\\d+\\])/).forEach((part) => {\n      if (!part) return;\n      const cite = part.match(/^\\[(\\d+)\\]$/);\n      if (cite) return void out.push({ k: \"c\", n: Number(cite[1]) });\n      const bold = part.startsWith(\"**\") && part.endsWith(\"**\");\n      (bold ? part.slice(2, -2) : part).split(/(?<=\\s)/).forEach((w) => w && out.push({ k: \"w\", v: w, b: bold }));\n    });\n  });\n  return out;\n}\n\nconst STOP = new Set([\"the\", \"a\", \"an\", \"to\", \"my\", \"i\", \"how\", \"do\", \"is\", \"are\", \"of\", \"with\", \"in\", \"on\", \"for\", \"and\", \"why\", \"what\", \"can\", \"set\", \"up\"]);\nconst words = (s: string) => s.toLowerCase().match(/[a-z0-9]+/g)?.filter((w) => !STOP.has(w)) ?? [];\n\ntype Phase = \"idle\" | \"searching\" | \"reading\" | \"writing\" | \"done\";\n\nexport function AISearchResults({ searches = DEFAULT_SEARCHES, onSearch, types = [\"Docs\", \"Guides\", \"Community\"], placeholder = \"Ask anything about Nexora…\", autoRun = true, theme = \"dark\", className }: AISearchResultsProps) {\n  const p = PALETTES[theme];\n  const reduce = !!useReducedMotion();\n  const uid = React.useId();\n  const [q, setQ] = React.useState(autoRun ? searches[0]?.query ?? \"\" : \"\");\n  const [data, setData] = React.useState<SearchAnswer | null>(null);\n  const [phase, setPhase] = React.useState<Phase>(\"idle\");\n  const [shown, setShown] = React.useState(0);\n  const [tab, setTab] = React.useState(\"All\");\n  const [hot, setHot] = React.useState<number | null>(null);\n  const [openQ, setOpenQ] = React.useState<number | null>(null);\n  const [vote, setVote] = React.useState<\"up\" | \"down\" | null>(null);\n  const [copied, setCopied] = React.useState(false);\n  const [elapsed, setElapsed] = React.useState(0);\n  const timers = React.useRef<ReturnType<typeof setTimeout>[]>([]);\n  const run = React.useRef(0);\n\n  const clear = () => {\n    timers.current.forEach((t) => clearTimeout(t));\n    timers.current = [];\n  };\n  React.useEffect(() => clear, []);\n  const later = (fn: () => void, ms: number) => timers.current.push(setTimeout(fn, ms));\n\n  const search = async (query: string) => {\n    const text = query.trim();\n    if (!text) return;\n    clear();\n    const id = ++run.current;\n    const started = Date.now();\n    setQ(text);\n    setTab(\"All\");\n    setVote(null);\n    setOpenQ(null);\n    setHot(null);\n    setShown(0);\n    setPhase(\"searching\");\n    let next: SearchAnswer;\n    if (onSearch) next = await onSearch(text);\n    else {\n      const want = words(text);\n      const best = [...searches].sort((a, b) => words(b.query).filter((w) => want.includes(w)).length - words(a.query).filter((w) => want.includes(w)).length)[0];\n      next = { ...best, query: text };\n    }\n    if (id !== run.current) return;\n    const toks = tokenize(next.answer);\n    setData(next);\n    if (reduce) {\n      setShown(toks.length);\n      setPhase(\"done\");\n      setElapsed((Date.now() - started) / 1000);\n      return;\n    }\n    later(() => setPhase(\"reading\"), 700);\n    later(() => setPhase(\"writing\"), 1500);\n    toks.forEach((_, i) => later(() => setShown(i + 1), 1500 + i * 28));\n    later(\n      () => {\n        setPhase(\"done\");\n        setElapsed((Date.now() - started) / 1000);\n      },\n      1550 + toks.length * 28,\n    );\n  };\n\n  const didAuto = React.useRef(false);\n  // Runs the first search once the section mounts (a ref callback, so there is no effect to re-run).\n  const autoStart = (el: HTMLElement | null) => {\n    if (!el || didAuto.current || !autoRun) return;\n    didAuto.current = true;\n    later(() => search(searches[0]?.query ?? \"\"), 400);\n  };\n\n  const toks = data ? tokenize(data.answer) : [];\n  const visible = toks.slice(0, shown);\n  const blocks: { li: boolean; toks: Tok[] }[] = [];\n  visible.forEach((t) => {\n    if (t.k === \"p\" || t.k === \"li\") blocks.push({ li: t.k === \"li\", toks: [] });\n    else blocks[blocks.length - 1]?.toks.push(t);\n  });\n  const cited = new Set(toks.filter((t): t is { k: \"c\"; n: number } => t.k === \"c\").map((t) => t.n));\n  const results = (data?.results ?? []).map((r, i) => ({ ...r, n: i + 1 })).filter((r) => tab === \"All\" || r.type === tab);\n  const showResults = phase === \"reading\" || phase === \"writing\" || phase === \"done\";\n  const terms = words(q);\n  const highlight = (s: string) =>\n    s.split(/(\\s+)/).map((w, i) => {\n      const clean = w.toLowerCase().replace(/[^a-z0-9]/g, \"\");\n      return clean && terms.some((t) => clean.startsWith(t)) ? (\n        <mark key={i} className=\"rounded-sm px-0.5\" style={{ background: p.mark, color: \"inherit\" }}>\n          {w}\n        </mark>\n      ) : (\n        w\n      );\n    });\n\n  const ring = { [\"--tw-ring-color\" as string]: p.ring, [\"--tw-ring-offset-color\" as string]: p.card } as React.CSSProperties;\n  const focus = \"outline-none focus-visible:ring-2 focus-visible:ring-offset-2\";\n  const steps: { id: Phase; label: string }[] = [\n    { id: \"searching\", label: phase === \"searching\" || !data ? \"Searching\" : `Searched ${data.results.length} sources` },\n    { id: \"reading\", label: \"Reading\" },\n    { id: \"writing\", label: \"Writing\" },\n  ];\n  const order: Phase[] = [\"idle\", \"searching\", \"reading\", \"writing\", \"done\"];\n  const stepState = (s: Phase) => (order.indexOf(phase) > order.indexOf(s) ? \"done\" : phase === s ? \"active\" : \"todo\");\n  const plain = data ? data.answer.replace(/\\*\\*/g, \"\").replace(/\\s?\\[\\d+\\]/g, \"\") : \"\";\n\n  const cite = (n: number, key: React.Key) => (\n    <a\n      key={key}\n      href={`#${uid}-r${n}`}\n      onMouseEnter={() => setHot(n)}\n      onMouseLeave={() => setHot(null)}\n      onFocus={() => setHot(n)}\n      onBlur={() => setHot(null)}\n      onClick={(e) => {\n        e.preventDefault();\n        const el = document.getElementById(`${uid}-r${n}`);\n        el?.scrollIntoView({ behavior: reduce ? \"auto\" : \"smooth\", block: \"nearest\" });\n        el?.querySelector(\"a\")?.focus({ preventScroll: true });\n      }}\n      aria-label={`Source ${n}: ${data?.results[n - 1]?.title ?? \"\"}`}\n      className={cn(\"mx-0.5 inline-flex h-[18px] min-w-[18px] items-center justify-center rounded-full px-1 align-[2px] text-[10.5px] font-semibold no-underline tabular-nums\", focus)}\n      style={{ background: hot === n ? p.accent : p.chip, color: hot === n ? p.onText : p.muted, ...ring }}\n    >\n      {n}\n    </a>\n  );\n\n  return (\n    <section ref={autoStart} className={cn(\"@container w-full\", className)} style={{ background: p.bg, color: p.text }}>\n      <div className=\"mx-auto max-w-6xl px-4 py-10 @[640px]:px-6 @[640px]:py-14\">\n        {/* Search bar */}\n        <form\n          role=\"search\"\n          onSubmit={(e) => {\n            e.preventDefault();\n            search(q);\n          }}\n          className=\"relative flex items-center gap-2 rounded-2xl border p-1.5 pl-4\"\n          style={{ background: p.card, borderColor: p.border }}\n        >\n          <span aria-hidden=\"true\" style={{ color: p.accent }}>\n            <svg width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" fill=\"currentColor\">\n              <path d=\"M12 2c.4 4.6 2.4 7.6 7 8-4.6.4-6.6 3.4-7 8-.4-4.6-2.4-7.6-7-8 4.6-.4 6.6-3.4 7-8Z\" />\n            </svg>\n          </span>\n          <label htmlFor={`${uid}-q`} className=\"sr-only\">\n            Question\n          </label>\n          <input id={`${uid}-q`} type=\"search\" value={q} onChange={(e) => setQ(e.target.value)} placeholder={placeholder} autoComplete=\"off\" className=\"h-10 min-w-0 flex-1 border-0 bg-transparent text-[15px] outline-none placeholder:opacity-60\" style={{ color: p.text }} />\n          <button type=\"submit\" disabled={!q.trim()} aria-label=\"Search\" className={cn(\"flex h-10 w-10 shrink-0 cursor-pointer items-center justify-center rounded-xl border-0 disabled:cursor-not-allowed disabled:opacity-40\", focus)} style={{ background: p.on, color: p.onText, ...ring }}>\n            <svg width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2.2\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\">\n              <path d=\"M5 12h14m-6-6 6 6-6 6\" />\n            </svg>\n          </button>\n          {phase !== \"idle\" && phase !== \"done\" && <motion.span className=\"absolute inset-x-6 -bottom-px h-px\" style={{ background: GRADIENT }} initial={{ scaleX: 0, opacity: 0 }} animate={{ scaleX: 1, opacity: 1 }} transition={{ duration: reduce ? 0 : 1.2 }} aria-hidden=\"true\" />}\n        </form>\n        <div className=\"mt-3 flex flex-wrap items-center gap-1.5 text-[12.5px]\" style={{ color: p.faint }}>\n          <span className=\"mr-1\">Try</span>\n          {searches.slice(0, 3).map((s) => (\n            <button key={s.query} type=\"button\" onClick={() => search(s.query)} className={cn(\"cursor-pointer rounded-full border px-2.5 py-1 text-[12.5px]\", focus)} style={{ borderColor: p.border, background: \"transparent\", color: p.muted, ...ring }}>\n              {s.query}\n            </button>\n          ))}\n        </div>\n\n        {phase === \"idle\" ? (\n          <div className=\"mt-10 rounded-2xl border border-dashed px-6 py-14 text-center text-[14px]\" style={{ borderColor: p.border, color: p.muted }}>\n            Ask a question to get an answer with sources.\n          </div>\n        ) : (\n          <div className=\"mt-6 grid gap-6 @[900px]:grid-cols-[minmax(0,1fr)_300px]\">\n            <div className=\"min-w-0\">\n              {/* AI overview */}\n              <div className=\"relative overflow-hidden rounded-2xl border p-5 @[640px]:p-6\" style={{ background: p.card, borderColor: p.border }} aria-busy={phase !== \"done\"}>\n                <div className=\"flex flex-wrap items-center justify-between gap-2\">\n                  <span className=\"flex items-center gap-2 text-[13px] font-medium\">\n                    <span style={{ color: p.accent }} aria-hidden=\"true\">\n                      ✦\n                    </span>\n                    AI overview\n                  </span>\n                  <span className=\"text-[12px] tabular-nums\" style={{ color: p.faint }}>\n                    {phase === \"done\" ? `${elapsed.toFixed(1)}s · ${cited.size} sources cited` : \"\"}\n                  </span>\n                </div>\n                <ol className=\"m-0 mt-3 flex list-none flex-wrap gap-1.5 p-0\" aria-label=\"Progress\">\n                  {steps.map((s) => {\n                    const st = stepState(s.id);\n                    return (\n                      <li key={s.id} className=\"flex items-center gap-1.5 rounded-full border px-2.5 py-1 text-[12px]\" style={{ borderColor: p.border, color: st === \"todo\" ? p.faint : p.muted }}>\n                        {st === \"done\" ? (\n                          <svg width=\"11\" height=\"11\" viewBox=\"0 0 16 16\" fill=\"none\" stroke={p.accent} strokeWidth=\"2.4\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\">\n                            <path d=\"m3 8.5 3 3 7-7\" />\n                          </svg>\n                        ) : st === \"active\" ? (\n                          <motion.span className=\"h-2.5 w-2.5 rounded-full border-2\" style={{ borderTopColor: \"transparent\", borderRightColor: p.accent, borderBottomColor: p.accent, borderLeftColor: p.accent }} animate={reduce ? undefined : { rotate: 360 }} transition={{ duration: 0.8, repeat: Infinity, ease: \"linear\" }} aria-hidden=\"true\" />\n                        ) : (\n                          <span className=\"h-2.5 w-2.5 rounded-full border\" style={{ borderColor: p.faint }} aria-hidden=\"true\" />\n                        )}\n                        {s.label}\n                        <span className=\"sr-only\">{st === \"done\" ? \", done\" : st === \"active\" ? \", in progress\" : \"\"}</span>\n                      </li>\n                    );\n                  })}\n                </ol>\n                <div className=\"mt-4 h-px w-full\" style={{ background: phase === \"done\" ? GRADIENT : p.border, opacity: phase === \"done\" ? 0.7 : 1 }} aria-hidden=\"true\" />\n\n                <div className=\"mt-4 min-h-[96px] text-[15px] leading-[1.7]\" aria-live=\"polite\">\n                  {phase === \"searching\" || phase === \"reading\" ? (\n                    <div className=\"flex flex-col gap-2.5 pt-1\" aria-hidden=\"true\">\n                      {[92, 100, 76].map((w, i) => (\n                        <motion.span key={i} className=\"h-3 rounded-full\" style={{ width: `${w}%`, background: p.chip }} animate={reduce ? undefined : { opacity: [0.5, 1, 0.5] }} transition={{ duration: 1.4, repeat: Infinity, delay: i * 0.15 }} />\n                      ))}\n                    </div>\n                  ) : (\n                    blocks.map((b, bi) =>\n                      b.li ? (\n                        <div key={bi} className=\"mt-2 flex gap-2.5\">\n                          <span className=\"mt-[11px] h-1.5 w-1.5 shrink-0 rounded-full\" style={{ background: p.accent }} aria-hidden=\"true\" />\n                          <p className=\"m-0\">{b.toks.map((t, i) => (t.k === \"c\" ? cite(t.n, i) : t.k === \"w\" ? (t.b ? <strong key={i} className=\"font-semibold\">{t.v}</strong> : <React.Fragment key={i}>{t.v}</React.Fragment>) : null))}</p>\n                        </div>\n                      ) : (\n                        <p key={bi} className={cn(\"m-0\", bi > 0 && \"mt-3\")}>\n                          {b.toks.map((t, i) => (t.k === \"c\" ? cite(t.n, i) : t.k === \"w\" ? (t.b ? <strong key={i} className=\"font-semibold\">{t.v}</strong> : <React.Fragment key={i}>{t.v}</React.Fragment>) : null))}\n                          {phase === \"writing\" && bi === blocks.length - 1 && <motion.span className=\"ml-0.5 inline-block h-[1em] w-[2px] align-[-2px]\" style={{ background: p.accent }} animate={reduce ? undefined : { opacity: [1, 0, 1] }} transition={{ duration: 0.9, repeat: Infinity }} aria-hidden=\"true\" />}\n                        </p>\n                      ),\n                    )\n                  )}\n                </div>\n\n                <AnimatePresence>\n                  {phase === \"done\" && (\n                    <motion.div initial={reduce ? false : { opacity: 0, y: 4 }} animate={{ opacity: 1, y: 0 }} className=\"mt-5 flex flex-wrap items-center justify-between gap-3\">\n                      <div className=\"flex items-center gap-1 rounded-full border p-1\" style={{ borderColor: p.border }}>\n                        {(\n                          [\n                            [\"copy\", copied ? \"Copied\" : \"Copy answer\", <path key=\"c\" d=\"M9 9h10v10H9zM5 15V5h10\" />],\n                            [\"up\", \"Helpful\", <path key=\"u\" d=\"M7 11v9H4v-9h3Zm0 0 4-7c1.5 0 2.5 1 2 3l-1 3h6a2 2 0 0 1 2 2.3l-1.2 6A2 2 0 0 1 16.8 20H7\" />],\n                            [\"down\", \"Not helpful\", <path key=\"d\" d=\"M7 13V4H4v9h3Zm0 0 4 7c1.5 0 2.5-1 2-3l-1-3h6a2 2 0 0 0 2-2.3l-1.2-6A2 2 0 0 0 16.8 4H7\" />],\n                          ] as const\n                        ).map(([id, label, d]) => {\n                          const on = (id === \"up\" || id === \"down\") && vote === id;\n                          return (\n                            <button\n                              key={id}\n                              type=\"button\"\n                              aria-label={label}\n                              title={label}\n                              aria-pressed={id === \"copy\" ? undefined : on}\n                              onClick={() => {\n                                if (id === \"copy\") {\n                                  navigator.clipboard?.writeText(plain).catch(() => {});\n                                  setCopied(true);\n                                  later(() => setCopied(false), 1600);\n                                } else setVote(on ? null : id);\n                              }}\n                              className={cn(\"flex h-7 w-7 cursor-pointer items-center justify-center rounded-full border-0\", focus)}\n                              style={{ background: on ? p.chip : \"transparent\", color: on ? p.accent : p.muted, ...ring }}\n                            >\n                              {id === \"copy\" && copied ? (\n                                <svg width=\"13\" height=\"13\" viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2.2\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\">\n                                  <path d=\"m3 8.5 3 3 7-7\" />\n                                </svg>\n                              ) : (\n                                <svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.8\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\">\n                                  {d}\n                                </svg>\n                              )}\n                            </button>\n                          );\n                        })}\n                      </div>\n                      {vote && (\n                        <span className=\"text-[12px]\" style={{ color: p.faint }} role=\"status\">\n                          Thanks for the feedback\n                        </span>\n                      )}\n                    </motion.div>\n                  )}\n                </AnimatePresence>\n              </div>\n\n              {/* Results */}\n              <div className=\"mt-6\">\n                <div role=\"tablist\" aria-label=\"Result type\" className=\"flex gap-1 overflow-x-auto border-b\" style={{ borderColor: p.border }}>\n                  {[\"All\", ...types].map((t) => {\n                    const on = tab === t;\n                    const n = (data?.results ?? []).filter((r) => t === \"All\" || r.type === t).length;\n                    return (\n                      <button key={t} type=\"button\" role=\"tab\" aria-selected={on} onClick={() => setTab(t)} className={cn(\"relative shrink-0 cursor-pointer border-0 bg-transparent px-3 pt-1 pb-2.5 text-[13px]\", focus)} style={{ color: on ? p.text : p.muted, ...ring }}>\n                        {t} <span style={{ color: p.faint }}>{showResults ? n : \"\"}</span>\n                        {on && <motion.span layoutId={`${uid}-tab`} className=\"absolute inset-x-2 -bottom-px h-[2px] rounded-full\" style={{ background: p.on }} transition={reduce ? { duration: 0 } : { type: \"spring\", stiffness: 500, damping: 36 }} />}\n                      </button>\n                    );\n                  })}\n                </div>\n                <ol className=\"m-0 list-none p-0\" aria-label=\"Results\">\n                  <AnimatePresence initial={false}>\n                    {showResults &&\n                      results.map((r, i) => (\n                        <motion.li key={`${data?.query}-${r.n}`} id={`${uid}-r${r.n}`} initial={reduce ? false : { opacity: 0, y: 6 }} animate={{ opacity: 1, y: 0 }} exit={reduce ? undefined : { opacity: 0, transition: { duration: 0.15 } }} transition={{ duration: 0.3, delay: reduce ? 0 : i * 0.06 }} className=\"relative -mx-3 rounded-xl px-3 py-4 transition-colors\" style={{ background: hot === r.n ? p.hover : \"transparent\", boxShadow: hot === r.n ? `inset 2px 0 0 ${p.accent}` : \"inset 0 0 0 rgba(0,0,0,0)\" }} onMouseEnter={() => setHot(r.n)} onMouseLeave={() => setHot(null)}>\n                          <div className=\"flex items-center gap-2 text-[12px]\" style={{ color: p.faint }}>\n                            <span className=\"flex h-5 w-5 items-center justify-center rounded-md text-[10px] font-bold uppercase\" style={{ background: p.chip, color: p.muted }} aria-hidden=\"true\">\n                              {r.source[0]}\n                            </span>\n                            <span className=\"min-w-0 truncate\">{r.source}</span>\n                            {cited.has(r.n) && (\n                              <span className=\"ml-auto shrink-0 rounded-full px-1.5 text-[10.5px] font-semibold tabular-nums\" style={{ background: p.chip, color: p.accent }} title=\"Cited in the overview\">\n                                {r.n}\n                              </span>\n                            )}\n                          </div>\n                          <a href={r.url} className={cn(\"mt-1.5 block w-fit rounded text-[16px] font-medium tracking-[-0.01em] underline-offset-4 hover:underline\", focus)} style={{ color: p.link, ...ring }}>\n                            {r.title}\n                          </a>\n                          <p className=\"m-0 mt-1 text-[14px] leading-[1.6]\" style={{ color: p.muted }}>\n                            {highlight(r.snippet)}\n                          </p>\n                          {(r.type || r.meta) && (\n                            <p className=\"m-0 mt-2 flex gap-2 text-[12px]\" style={{ color: p.faint }}>\n                              {r.type && <span>{r.type}</span>}\n                              {r.type && r.meta && <span aria-hidden=\"true\">·</span>}\n                              {r.meta && <span>{r.meta}</span>}\n                            </p>\n                          )}\n                        </motion.li>\n                      ))}\n                  </AnimatePresence>\n                </ol>\n                {showResults && results.length === 0 && (\n                  <p className=\"m-0 py-10 text-center text-[14px]\" style={{ color: p.muted }}>\n                    No {tab.toLowerCase()} results for this search.\n                  </p>\n                )}\n                {!showResults && (\n                  <div className=\"flex flex-col gap-5 py-5\" aria-hidden=\"true\">\n                    {[0, 1, 2].map((i) => (\n                      <div key={i} className=\"flex flex-col gap-2\">\n                        <span className=\"h-2.5 w-40 rounded-full\" style={{ background: p.chip }} />\n                        <span className=\"h-3.5 w-72 max-w-full rounded-full\" style={{ background: p.chip }} />\n                        <span className=\"h-2.5 w-full rounded-full\" style={{ background: p.chip }} />\n                      </div>\n                    ))}\n                  </div>\n                )}\n              </div>\n            </div>\n\n            {/* Related questions */}\n            {showResults && data?.related?.length ? (\n              <aside className=\"min-w-0 @[900px]:pt-1\" aria-label=\"Related questions\">\n                <h3 className=\"m-0 mb-2 text-[13px] font-medium\" style={{ color: p.muted }}>\n                  People also ask\n                </h3>\n                <ul className=\"m-0 list-none overflow-hidden rounded-2xl border p-0\" style={{ borderColor: p.border, background: p.card }}>\n                  {data.related.map((r, i) => {\n                    const on = openQ === i;\n                    return (\n                      <li key={r.q} className={cn(i > 0 && \"border-t\")} style={{ borderColor: p.border }}>\n                        <button type=\"button\" aria-expanded={on} aria-controls={`${uid}-rq${i}`} onClick={() => setOpenQ(on ? null : i)} className={cn(\"flex w-full cursor-pointer items-center justify-between gap-3 border-0 bg-transparent px-4 py-3.5 text-left text-[14px]\", focus, \"focus-visible:ring-inset\")} style={{ color: p.text, ...ring }}>\n                          {r.q}\n                          <motion.svg width=\"14\" height=\"14\" viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.8\" strokeLinecap=\"round\" className=\"shrink-0\" style={{ color: p.faint }} animate={{ rotate: on ? 45 : 0 }} transition={{ duration: reduce ? 0 : 0.2 }} aria-hidden=\"true\">\n                            <path d=\"M8 3v10M3 8h10\" />\n                          </motion.svg>\n                        </button>\n                        <AnimatePresence initial={false}>\n                          {on && (\n                            <motion.div id={`${uid}-rq${i}`} initial={reduce ? false : { height: 0, opacity: 0 }} animate={{ height: \"auto\", opacity: 1 }} exit={reduce ? undefined : { height: 0, opacity: 0 }} transition={{ duration: 0.22 }} className=\"overflow-hidden\">\n                              <p className=\"m-0 px-4 pb-4 text-[13.5px] leading-[1.6]\" style={{ color: p.muted }}>\n                                {r.a}\n                              </p>\n                              <button type=\"button\" onClick={() => search(r.q)} className={cn(\"mx-4 mb-4 cursor-pointer rounded-full border px-2.5 py-1 text-[12px]\", focus)} style={{ borderColor: p.border, background: \"transparent\", color: p.text, ...ring }}>\n                                Search this →\n                              </button>\n                            </motion.div>\n                          )}\n                        </AnimatePresence>\n                      </li>\n                    );\n                  })}\n                </ul>\n              </aside>\n            ) : null}\n          </div>\n        )}\n      </div>\n    </section>\n  );\n}\n\nexport default AISearchResults;\n",
      "type": "registry:component"
    }
  ],
  "type": "registry:component"
}