{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "faq-chat-thread",
  "type": "registry:component",
  "title": "FAQ Chat Thread",
  "description": "FAQ as a conversation: questions become visitor bubbles and the answers type out with a cursor. A numbered question list sits beside the thread, chips replace it on narrow containers.",
  "author": "Hyperblur <hello@hyperblur.dev>",
  "dependencies": [],
  "registryDependencies": [],
  "categories": [
    "faq",
    "faq",
    "chat",
    "typewriter",
    "questions",
    "conversation",
    "support"
  ],
  "docs": "https://hyperblur.dev/effects/faq-chat-thread",
  "files": [
    {
      "path": "registry/hyperblur/faq-chat-thread.tsx",
      "type": "registry:component",
      "target": "components/hyperblur/faq-chat-thread.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nexport interface FaqChatItem {\n  question: string;\n  answer: string;\n}\n\nexport interface FaqChatThreadProps extends Omit<React.HTMLAttributes<HTMLElement>, \"title\"> {\n  eyebrow?: string;\n  title?: string;\n  subtitle?: string;\n  items?: FaqChatItem[];\n  botName?: string;\n  speed?: number;\n  contact?: { label: string; href: string };\n  onAsk?: (item: FaqChatItem, index: number) => void;\n  accent?: string;\n}\n\nconst defaultItems: FaqChatItem[] = [\n  { question: \"Can I try it before paying?\", answer: \"Yes. Every workspace starts with a 14 day trial of the Team plan. No card needed, and you keep your data if you downgrade to Free.\" },\n  { question: \"How does billing work for guests?\", answer: \"Guests are free and unlimited. You only pay for members who can create or edit projects, billed monthly or yearly.\" },\n  { question: \"Where is my data stored?\", answer: \"In the region you pick at signup: Frankfurt, Virginia or Sydney. Data never leaves that region, and backups are encrypted with AES-256.\" },\n  { question: \"Can I export everything?\", answer: \"Any time, from Settings. You get a zip with Markdown files, CSVs for every table and the original attachments, usually in under a minute.\" },\n  { question: \"Do you offer discounts for nonprofits?\", answer: \"Registered nonprofits and schools get 60 percent off any paid plan. Write to us from your organization email and we will apply it within a day.\" },\n  { question: \"What happens if I cancel?\", answer: \"Your workspace switches to Free at the end of the billing period. Nothing is deleted, and you can upgrade again with one click.\" },\n];\n\nconst css = `\n.hb-yi7 {\n  --hb-yi7-accent: #10b981;\n  container-type: inline-size;\n  position: relative;\n  box-sizing: border-box;\n  width: 100%;\n  overflow: hidden;\n  isolation: isolate;\n  background: #0a0a0a;\n  color: #ededed;\n  font-family: inherit;\n  -webkit-font-smoothing: antialiased;\n}\n.hb-yi7 *, .hb-yi7 *::before, .hb-yi7 *::after { box-sizing: border-box; }\n.hb-yi7::before {\n  content: \"\"; position: absolute; z-index: -1; left: -10%; bottom: -40%; width: 60%; height: 90%;\n  background: radial-gradient(closest-side, color-mix(in srgb, var(--hb-yi7-accent) 16%, transparent), transparent);\n}\n.hb-yi7-inner { max-width: 1120px; margin: 0 auto; padding: 72px 20px 80px; display: grid; gap: 36px; }\n.hb-yi7-eyebrow { margin: 0 0 14px; font-size: 13px; font-weight: 500; color: var(--hb-yi7-accent); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }\n.hb-yi7-title { margin: 0; font-size: clamp(30px, 4.6cqi, 48px); line-height: 1.05; letter-spacing: -.04em; font-weight: 600; }\n.hb-yi7-sub { margin: 14px 0 0; max-width: 380px; font-size: 15px; line-height: 1.6; color: #8f8f8f; }\n.hb-yi7-list { list-style: none; margin: 28px 0 0; padding: 0; display: grid; gap: 4px; counter-reset: hb-yi7-n; }\n.hb-yi7-q {\n  width: 100%; display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: 12px; border: 1px solid transparent; background: transparent;\n  color: #c9c9c9; font: inherit; font-size: 14px; text-align: left; cursor: pointer; transition: background .2s, border-color .2s, color .2s;\n}\n.hb-yi7-q:hover:not(:disabled) { background: #121212; border-color: rgba(255, 255, 255, .08); color: #fff; }\n.hb-yi7-q:disabled { cursor: default; }\n.hb-yi7-q:focus-visible, .hb-yi7-reset:focus-visible, .hb-yi7-link:focus-visible { outline: 2px solid var(--hb-yi7-accent); outline-offset: 2px; }\n.hb-yi7-num {\n  display: grid; place-items: center; width: 24px; height: 24px; border-radius: 7px; flex: none; font-size: 11px; font-weight: 600;\n  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; color: #8f8f8f; border: 1px solid rgba(255, 255, 255, .1); background: #111;\n  transition: background .3s, color .3s, border-color .3s;\n}\n.hb-yi7-q[data-asked=\"true\"] { color: #6f6f6f; }\n.hb-yi7-q[data-asked=\"true\"] .hb-yi7-num { background: color-mix(in srgb, var(--hb-yi7-accent) 18%, transparent); border-color: color-mix(in srgb, var(--hb-yi7-accent) 40%, transparent); color: var(--hb-yi7-accent); }\n.hb-yi7-num svg { width: 12px; height: 12px; }\n.hb-yi7-q > svg { width: 14px; height: 14px; margin-left: auto; color: #5f5f5f; opacity: 0; transform: translateX(-4px); transition: opacity .2s, transform .2s; }\n.hb-yi7-q:hover:not(:disabled) > svg { opacity: 1; transform: none; }\n.hb-yi7-link { display: inline-flex; margin-top: 18px; font-size: 14px; color: #ededed; text-decoration: underline; text-decoration-color: rgba(255, 255, 255, .25); text-underline-offset: 4px; }\n.hb-yi7-link:hover { text-decoration-color: var(--hb-yi7-accent); }\n.hb-yi7-win {\n  position: relative; display: flex; flex-direction: column; min-width: 0; border-radius: 24px; overflow: hidden;\n  background: linear-gradient(180deg, #121212, #0d0d0d); border: 1px solid rgba(255, 255, 255, .08);\n  box-shadow: 0 1px 0 rgba(255, 255, 255, .06) inset, 0 40px 80px -40px rgba(0, 0, 0, .9);\n}\n.hb-yi7-bar { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid rgba(255, 255, 255, .07); }\n.hb-yi7-bot { position: relative; width: 34px; height: 34px; border-radius: 11px; display: grid; place-items: center; background: color-mix(in srgb, var(--hb-yi7-accent) 20%, #111); color: var(--hb-yi7-accent); border: 1px solid color-mix(in srgb, var(--hb-yi7-accent) 35%, transparent); }\n.hb-yi7-bot svg { width: 18px; height: 18px; }\n.hb-yi7-bot::after { content: \"\"; position: absolute; right: -2px; bottom: -2px; width: 9px; height: 9px; border-radius: 50%; background: #34d399; border: 2px solid #121212; }\n.hb-yi7-bar p { margin: 0; font-size: 14px; font-weight: 600; }\n.hb-yi7-bar small { display: block; font-size: 12px; font-weight: 400; color: #8f8f8f; }\n.hb-yi7-reset {\n  margin-left: auto; height: 30px; padding: 0 12px; border-radius: 9px; border: 1px solid rgba(255, 255, 255, .1); background: transparent;\n  color: #a1a1a1; font: inherit; font-size: 12px; cursor: pointer; transition: background .2s, color .2s;\n}\n.hb-yi7-reset:hover { background: #1a1a1a; color: #fff; }\n.hb-yi7-thread { height: 400px; overflow-y: auto; padding: 22px 18px; display: flex; flex-direction: column; gap: 10px; scroll-behavior: smooth; scrollbar-width: thin; scrollbar-color: #2a2a2a transparent; }\n.hb-yi7-day { align-self: center; margin-bottom: 6px; font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: #5f5f5f; }\n.hb-yi7-msg { max-width: 84%; padding: 11px 14px; border-radius: 18px; font-size: 14px; line-height: 1.55; animation: hb-yi7-in .4s cubic-bezier(.2, .8, .2, 1) both; }\n.hb-yi7-msg[data-from=\"user\"] {\n  align-self: flex-end; color: #04130d; font-weight: 500; border-bottom-right-radius: 6px;\n  background: linear-gradient(180deg, color-mix(in srgb, var(--hb-yi7-accent) 80%, #fff), var(--hb-yi7-accent));\n  box-shadow: 0 10px 24px -14px var(--hb-yi7-accent);\n  transform-origin: right bottom;\n}\n.hb-yi7-msg[data-from=\"bot\"] { align-self: flex-start; background: #1b1b1b; border: 1px solid rgba(255, 255, 255, .06); border-bottom-left-radius: 6px; color: #dedede; transform-origin: left bottom; }\n.hb-yi7-cursor { display: inline-block; width: 7px; height: 14px; margin-left: 2px; vertical-align: -2px; border-radius: 1px; background: var(--hb-yi7-accent); animation: hb-yi7-blink .9s steps(1) infinite; }\n.hb-yi7-dots { display: inline-flex; gap: 4px; padding: 3px 0; }\n.hb-yi7-dots i { width: 6px; height: 6px; border-radius: 50%; background: #7a7a7a; animation: hb-yi7-wave 1.1s infinite; }\n.hb-yi7-dots i:nth-child(2) { animation-delay: .14s; }\n.hb-yi7-dots i:nth-child(3) { animation-delay: .28s; }\n.hb-yi7-meta { align-self: flex-end; margin-top: -4px; font-size: 11px; color: #5f5f5f; }\n.hb-yi7-chips { display: flex; gap: 8px; padding: 12px 14px; border-top: 1px solid rgba(255, 255, 255, .07); overflow-x: auto; scrollbar-width: none; }\n.hb-yi7-chip {\n  flex: none; height: 34px; padding: 0 14px; border-radius: 999px; border: 1px solid rgba(255, 255, 255, .12); background: #141414;\n  color: #d4d4d4; font: inherit; font-size: 13px; cursor: pointer; transition: border-color .2s, color .2s, background .2s;\n}\n.hb-yi7-chip:hover:not(:disabled) { border-color: var(--hb-yi7-accent); color: #fff; }\n.hb-yi7-chip:disabled { opacity: .45; cursor: default; }\n.hb-yi7-chip:focus-visible { outline: 2px solid var(--hb-yi7-accent); outline-offset: 2px; }\n.hb-yi7-done { flex: 1; text-align: center; font-size: 13px; color: #8f8f8f; padding: 8px 0; }\n@keyframes hb-yi7-in { from { opacity: 0; transform: translateY(8px) scale(.96); } to { opacity: 1; transform: none; } }\n@keyframes hb-yi7-blink { 50% { opacity: 0; } }\n@keyframes hb-yi7-wave { 0%, 60%, 100% { transform: translateY(0); opacity: .45; } 30% { transform: translateY(-4px); opacity: 1; } }\n@container (min-width: 820px) {\n  .hb-yi7-inner { grid-template-columns: minmax(0, 380px) minmax(0, 1fr); gap: 64px; padding: 104px 32px 112px; align-items: start; }\n  .hb-yi7-thread { height: 440px; padding: 26px 24px; }\n  .hb-yi7-chips { display: none; }\n}\n@container (max-width: 819px) {\n  .hb-yi7-list { display: none; }\n}\n@media (prefers-reduced-motion: reduce) {\n  .hb-yi7-msg, .hb-yi7-cursor, .hb-yi7-dots i { animation: none; }\n  .hb-yi7-thread { scroll-behavior: auto; }\n  .hb-yi7-q, .hb-yi7-q > svg, .hb-yi7-num, .hb-yi7-chip { transition: none; }\n}\n`;\n\ntype Line = { key: string; from: \"user\" | \"bot\"; text: string };\n\nexport function FaqChatThread({\n  eyebrow = \"~/help --faq\",\n  title = \"Ask away. We have heard these before.\",\n  subtitle = \"The six questions we get every week, answered by the people who built Ledgerly. Tap one to see the reply.\",\n  items = defaultItems,\n  botName = \"Ledgerly help\",\n  speed = 1,\n  contact = { label: \"Still stuck? Message the team\", href: \"#\" },\n  onAsk,\n  accent = \"#10b981\",\n  className = \"\",\n  style,\n  ...rest\n}: FaqChatThreadProps) {\n  const [asked, setAsked] = React.useState<number[]>(() => (items.length ? [0] : []));\n  const [queue, setQueue] = React.useState<number | null>(() => (items.length > 1 ? 1 : null));\n  const [typing, setTyping] = React.useState(false);\n  const [live, setLive] = React.useState<{ index: number; text: string } | null>(null);\n  const threadRef = React.useRef<HTMLDivElement>(null);\n  const answer = items[queue ?? -1]?.answer;\n\n  React.useEffect(() => {\n    if (queue === null || answer === undefined) return;\n    const index = queue;\n    const text = answer;\n    const reduce = window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches;\n    const step = Math.max(1, Math.round(2 * speed));\n    const ids: number[] = [];\n    const finish = () => {\n      setTyping(false);\n      setLive(null);\n      setAsked((a) => (a.includes(index) ? a : [...a, index]));\n      setQueue(null);\n    };\n    ids.push(\n      window.setTimeout(() => {\n        if (reduce) {\n          finish();\n          return;\n        }\n        setTyping(true);\n        ids.push(\n          window.setTimeout(() => {\n            setTyping(false);\n            let n = 0;\n            const tick = () => {\n              n = Math.min(text.length, n + step);\n              if (n >= text.length) {\n                finish();\n                return;\n              }\n              setLive({ index, text: text.slice(0, n) });\n              ids.push(window.setTimeout(tick, 16));\n            };\n            tick();\n          }, 750),\n        );\n      }, 350),\n    );\n    return () => ids.forEach((t) => window.clearTimeout(t));\n  }, [queue, answer, speed]);\n\n  React.useEffect(() => {\n    const el = threadRef.current;\n    if (el) el.scrollTop = el.scrollHeight;\n  }, [asked, typing, live, queue]);\n\n  const busy = queue !== null;\n\n  const ask = (i: number) => {\n    if (busy || asked.includes(i)) return;\n    setQueue(i);\n    onAsk?.(items[i], i);\n  };\n\n  const reset = () => {\n    if (busy) return;\n    setAsked([]);\n  };\n\n  const lines: Line[] = [];\n  asked.forEach((i) => {\n    const it = items[i];\n    if (!it) return;\n    lines.push({ key: `q${i}`, from: \"user\", text: it.question });\n    lines.push({ key: `a${i}`, from: \"bot\", text: it.answer });\n  });\n\n  const remaining = items.map((it, i) => ({ it, i })).filter(({ i }) => !asked.includes(i) && i !== queue);\n  const vars = { \"--hb-yi7-accent\": accent, ...style } as React.CSSProperties;\n\n  const arrow = (\n    <svg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\">\n      <path d=\"M5 12h14M13 6l6 6-6 6\" />\n    </svg>\n  );\n\n  return (\n    <section className={`hb-yi7 ${className}`} style={vars} {...rest}>\n      <style href=\"hb-faq-chat-thread\" precedence=\"default\">{css}</style>\n      <div className=\"hb-yi7-inner\">\n        <div>\n          {eyebrow ? <p className=\"hb-yi7-eyebrow\">{eyebrow}</p> : null}\n          <h2 className=\"hb-yi7-title\">{title}</h2>\n          {subtitle ? <p className=\"hb-yi7-sub\">{subtitle}</p> : null}\n          <ol className=\"hb-yi7-list\">\n            {items.map((it, i) => {\n              const done = asked.includes(i) || queue === i;\n              return (\n                <li key={it.question}>\n                  <button type=\"button\" className=\"hb-yi7-q\" data-asked={done} disabled={busy && !done} aria-disabled={done} onClick={() => ask(i)}>\n                    <span className=\"hb-yi7-num\" aria-hidden=\"true\">\n                      {done ? (\n                        <svg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"3\" strokeLinecap=\"round\" strokeLinejoin=\"round\">\n                          <path d=\"M5 12.5l4.5 4.5L19 7.5\" />\n                        </svg>\n                      ) : (\n                        String(i + 1).padStart(2, \"0\")\n                      )}\n                    </span>\n                    {it.question}\n                    {done ? null : arrow}\n                  </button>\n                </li>\n              );\n            })}\n          </ol>\n          {contact ? (\n            <a className=\"hb-yi7-link\" href={contact.href}>\n              {contact.label}\n            </a>\n          ) : null}\n        </div>\n\n        <div className=\"hb-yi7-win\">\n          <div className=\"hb-yi7-bar\">\n            <span className=\"hb-yi7-bot\" aria-hidden=\"true\">\n              <svg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.8\" strokeLinecap=\"round\" strokeLinejoin=\"round\">\n                <path d=\"M4 5h16v11H9l-5 4z\" />\n                <path d=\"M9 10.5h.01M12 10.5h.01M15 10.5h.01\" />\n              </svg>\n            </span>\n            <p>\n              {botName}\n              <small>Answers instantly, humans on weekdays</small>\n            </p>\n            <button type=\"button\" className=\"hb-yi7-reset\" onClick={reset} disabled={busy}>\n              Clear\n            </button>\n          </div>\n          <div className=\"hb-yi7-thread\" ref={threadRef} role=\"log\" aria-live=\"polite\" aria-busy={busy}>\n            <span className=\"hb-yi7-day\">Today</span>\n            {lines.map((l) => (\n              <div key={l.key} className=\"hb-yi7-msg\" data-from={l.from}>\n                {l.text}\n              </div>\n            ))}\n            {queue !== null && items[queue] ? (\n              <>\n                <div key={`q${queue}`} className=\"hb-yi7-msg\" data-from=\"user\">\n                  {items[queue].question}\n                </div>\n                {typing ? (\n                  <div className=\"hb-yi7-msg\" data-from=\"bot\" aria-label=\"Typing\">\n                    <span className=\"hb-yi7-dots\">\n                      <i />\n                      <i />\n                      <i />\n                    </span>\n                  </div>\n                ) : live ? (\n                  <div className=\"hb-yi7-msg\" data-from=\"bot\">\n                    {live.text}\n                    <span className=\"hb-yi7-cursor\" aria-hidden=\"true\" />\n                  </div>\n                ) : null}\n              </>\n            ) : null}\n            {lines.length && queue === null ? <span className=\"hb-yi7-meta\">Read</span> : null}\n          </div>\n          <div className=\"hb-yi7-chips\" role=\"group\" aria-label=\"Suggested questions\">\n            {remaining.length ? (\n              remaining.map(({ it, i }) => (\n                <button key={it.question} type=\"button\" className=\"hb-yi7-chip\" disabled={busy} onClick={() => ask(i)}>\n                  {it.question}\n                </button>\n              ))\n            ) : (\n              <p className=\"hb-yi7-done\">That is every question. Need more? Message the team.</p>\n            )}\n          </div>\n        </div>\n      </div>\n    </section>\n  );\n}\n"
    }
  ]
}