{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "hover-reply-toolbar",
  "title": "Hover Reply Toolbar",
  "description": "A floating message toolbar with keyboard and touch access, copy, editable AI reply suggestions and async reply submission.",
  "dependencies": [
    "motion",
    "lucide-react",
    "clsx",
    "tailwind-merge"
  ],
  "files": [
    {
      "path": "registry/new-york/hover-reply-toolbar/hover-reply-toolbar.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\nimport { motion, useReducedMotion } from \"motion/react\";\nimport { clsx } from \"clsx\";\nimport { twMerge } from \"tailwind-merge\";\nimport { Copy, Check, Reply, Sparkles, X, ArrowUpRight } from \"lucide-react\";\n\nexport interface HoverReplyToolbarProps {\n  author?: string;\n  message?: string;\n  time?: string;\n  alwaysVisible?: boolean;\n  onReply?: (reply: string) => void | Promise<void>;\n  onSuggest?: (message: string) => string | Promise<string>;\n  theme?: \"dark\" | \"light\";\n  className?: string;\n}\n\nconst SHEEN = \"linear-gradient(115deg,rgba(255,255,255,.08),rgba(255,255,255,.02) 30%,transparent 48%,rgba(255,255,255,.04) 74%,transparent),linear-gradient(180deg,rgba(255,255,255,.05),transparent 60%)\";\nfunction Island({ children, theme, active = false, warm = false, className }: { children: React.ReactNode; theme: \"dark\" | \"light\"; active?: boolean; warm?: boolean; className?: string }) {\n  const reduce = useReducedMotion();\n  return <motion.div layout={!reduce} transition={{ type: \"spring\", stiffness: 260, damping: 30 }} className={twMerge(clsx(\"relative isolate w-full rounded-[32px] border font-sans antialiased [font-family:Inter,ui-sans-serif,system-ui,sans-serif]\", theme === \"dark\" ? \"border-white/[0.09] bg-[#0E0E10] text-[#EDEDED]\" : \"border-black/[0.09] bg-[#f7f7f8] text-[#202023]\", className))} style={{ backgroundImage: SHEEN, boxShadow: theme === \"dark\" ? \"inset 0 1px 0 #ffffff1f,0 16px 48px #00000025\" : \"inset 0 1px 0 #ffffff,0 16px 48px #00000008\" }}>\n    <motion.div aria-hidden=\"true\" className=\"pointer-events-none absolute -inset-px rounded-[inherit]\" animate={{ opacity: active && !reduce ? [0.35, 0.8, 0.35] : active ? 0.5 : 0.18 }} transition={{ duration: 3, repeat: active && !reduce ? Infinity : 0 }} style={{ padding: 1, background: warm ? \"conic-gradient(from 40deg,transparent 10%,#FF7BD5 32%,#FFB86B 45%,transparent 65%)\" : \"conic-gradient(from 40deg,transparent 10%,#7CF3FF 32%,#6EA8FF 45%,#9B7BFF 55%,transparent 75%)\", mask: \"linear-gradient(#fff 0 0) content-box,linear-gradient(#fff 0 0)\", maskComposite: \"exclude\", WebkitMaskComposite: \"xor\" }} />\n    {children}\n  </motion.div>;\n}\nfunction Orb({ active = false, warm = false, size = 40 }: { active?: boolean; warm?: boolean; size?: number }) {\n  const reduce = useReducedMotion();\n  return <span aria-hidden=\"true\" className=\"relative inline-flex shrink-0 items-center justify-center\" style={{ width: size, height: size }}>\n    <motion.span className=\"absolute inset-0 rounded-full blur-md\" style={{ background: warm ? \"radial-gradient(circle,#ffb86b55,transparent 70%)\" : \"radial-gradient(circle,#9b7bff55,transparent 70%)\" }} animate={{ opacity: active && !reduce ? [0.3, 0.9, 0.3] : 0.3 }} transition={{ duration: 2.5, repeat: active && !reduce ? Infinity : 0 }} />\n    <motion.svg viewBox=\"0 0 40 40\" className=\"relative size-full\" animate={active && !reduce ? { rotate: [0, 12, 0] } : { rotate: 0 }} transition={{ duration: 5, repeat: active && !reduce ? Infinity : 0 }}>{Array.from({ length: 81 }, (_, i) => { const x = i % 9 - 4; const y = Math.floor(i / 9) - 4; const d = Math.hypot(x, y); return d <= 4.1 ? <circle key={i} cx={20 + x * 3.9} cy={20 + y * 3.9} r={Number((1 - d * .13).toFixed(3))} fill=\"currentColor\" opacity={Number((.95 - d * .16).toFixed(3))} /> : null; })}</motion.svg>\n  </span>;\n}\nconst action = \"inline-flex min-h-10 shrink-0 items-center justify-center gap-2 rounded-full border border-current/[0.12] px-4 text-[11px] transition-colors hover:bg-current/[0.06] focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[#9B7BFF] disabled:cursor-not-allowed disabled:opacity-35 motion-reduce:transition-none [&_svg]:shrink-0\";\n\nexport function HoverReplyToolbar({ author = \"Alex Morgan\", message = \"The new direction looks great. Can you share the updated prototype before our review tomorrow?\", time = \"Just now\", alwaysVisible = false, onReply, onSuggest, theme = \"dark\", className }: HoverReplyToolbarProps) {\n  const [open, setOpen] = React.useState(false);\n  const [draft, setDraft] = React.useState(\"\");\n  const [pending, setPending] = React.useState<\"suggest\" | \"send\" | null>(null);\n  const [copied, setCopied] = React.useState(false);\n  const [sent, setSent] = React.useState(false);\n  const [error, setError] = React.useState(\"\");\n  const generation = React.useRef(0);\n  const input = React.useRef<HTMLTextAreaElement>(null);\n  const timer = React.useRef<ReturnType<typeof setTimeout> | null>(null);\n  React.useEffect(() => () => { generation.current++; if (timer.current) clearTimeout(timer.current); }, []);\n  React.useEffect(() => { if (open) input.current?.focus(); }, [open]);\n  async function suggest() {\n    const token = ++generation.current;\n    setOpen(true); setPending(\"suggest\"); setError(\"\"); setSent(false);\n    try { const text = onSuggest ? await onSuggest(message) : \"Absolutely. I’ll share the updated prototype before tomorrow’s review. Looking forward to your thoughts!\";\n      if (token === generation.current) { if (!text.trim()) throw new Error(\"No reply returned. Please try again.\"); setDraft(text); }\n    } catch (e) { if (token === generation.current) setError(e instanceof Error ? e.message : \"Could not suggest a reply.\"); }\n    finally { if (token === generation.current) { setPending(null); input.current?.focus(); } }\n  }\n  async function send() {\n    if (!draft.trim() || pending) return;\n    const token = ++generation.current; setPending(\"send\"); setError(\"\");\n    try { await onReply?.(draft.trim()); if (token === generation.current) { setSent(true); setOpen(false); setDraft(\"\"); } }\n    catch (e) { if (token === generation.current) setError(e instanceof Error ? e.message : \"Could not send your reply.\"); }\n    finally { if (token === generation.current) setPending(null); }\n  }\n  async function copy() {\n    try { await navigator.clipboard.writeText(message); setCopied(true); if (timer.current) clearTimeout(timer.current); timer.current = setTimeout(() => setCopied(false), 1800); }\n    catch { setError(\"Copy unavailable. Select and copy the message manually.\"); }\n  }\n  return <div className={twMerge(\"mx-auto w-full max-w-[520px]\", className)}>\n    <div className=\"group relative pt-7\" onKeyDown={e => { if (e.key === \"Escape\" && !pending) setOpen(false); }}>\n      <Island theme={theme} active={pending !== null} className=\"p-5 sm:p-6\">\n        <div role=\"group\" aria-label=\"Message actions\" className={clsx(\"absolute right-4 top-0 z-10 -translate-y-1/2 transition-[opacity,transform] duration-200 motion-reduce:transition-none\", !alwaysVisible && !open && \"[@media(hover:hover)]:translate-y-0 [@media(hover:hover)]:opacity-0 [@media(hover:hover)]:group-hover:-translate-y-1/2 [@media(hover:hover)]:group-hover:opacity-100 [@media(hover:hover)]:group-focus-within:-translate-y-1/2 [@media(hover:hover)]:group-focus-within:opacity-100\")}>\n          <Island theme={theme} className=\"flex w-auto items-center gap-1 rounded-full p-1.5 shadow-xl\">\n            <button type=\"button\" className={action + \" border-transparent px-2.5\"} disabled={!!pending} onClick={() => { setOpen(true); setSent(false); }}><Reply size={17} />Reply</button>\n            <span className=\"h-4 w-px bg-current/10\" />\n            <button type=\"button\" className={action + \" border-transparent px-2.5\"} disabled={!!pending} onClick={suggest}><Sparkles size={17} className=\"text-[#b4a1ec]\" />{pending === \"suggest\" ? \"Thinking…\" : \"AI reply\"}</button>\n            <button type=\"button\" aria-label={copied ? \"Copied\" : \"Copy message\"} className={action + \" size-10 border-transparent p-0\"} onClick={copy}>{copied ? <Check size={17} /> : <Copy size={17} />}</button>\n          </Island>\n        </div>\n        <div className=\"flex items-center gap-3\"><span className=\"flex size-8 shrink-0 items-center justify-center rounded-full border border-current/10 bg-current/[0.04] text-[10px]\">{author.split(/\\s+/).slice(0, 2).map(n => n[0]).join(\"\")}</span><span className=\"text-[12px] font-medium\">{author}</span><span className=\"ml-auto text-[10px] opacity-35\">{time}</span></div>\n        <p className=\"mt-4 text-[14px] leading-[1.8] tracking-[-0.015em] opacity-75\">{message}</p>\n        {open && <div className=\"mt-5 border-t border-current/[0.08] pt-4\"><div className=\"mb-2 flex items-center justify-between\"><span className=\"flex items-center gap-2 text-[11px] opacity-55\"><Orb active={pending === \"suggest\"} size={28} />Your reply</span><button type=\"button\" disabled={!!pending} aria-label=\"Close reply\" onClick={() => setOpen(false)} className={action + \" size-9 min-h-9 border-transparent p-0\"}><X size={16} /></button></div><textarea ref={input} aria-label=\"Reply text\" value={draft} onChange={e => setDraft(e.target.value)} disabled={!!pending} placeholder=\"Write a thoughtful reply…\" className=\"min-h-24 w-full resize-y rounded-2xl border border-current/10 bg-current/[0.025] p-3 text-[13px] leading-6 outline-none focus:border-[#9B7BFF]/60\" /><div className=\"mt-3 flex items-center justify-between gap-3\"><span className=\"text-[10px] opacity-35\">{onReply ? \"Review before sending\" : \"Demo · reply stays in this preview\"}</span><button type=\"button\" disabled={!!pending || !draft.trim()} onClick={send} className={action + (theme === \"dark\" ? \" border-transparent bg-[#EDEDED] text-[#0E0E10] hover:bg-white\" : \" bg-[#202023] text-white hover:bg-[#333]\")}>{pending === \"send\" ? \"Sending…\" : onReply ? \"Send reply\" : \"Save reply\"}<ArrowUpRight size={17} /></button></div></div>}\n        {error && <p role=\"alert\" className=\"mt-3 text-[11px] text-red-400\">{error}</p>}\n        <p role=\"status\" className={clsx(\"text-[11px] opacity-50\", (sent || copied) && \"mt-3\")}>{sent ? onReply ? \"Reply sent.\" : \"Demo reply saved.\" : copied ? \"Message copied.\" : \"\"}</p>\n      </Island>\n      <p className=\"mt-4 text-center text-[10px] text-muted-foreground\">Hover over the message, or use Tab to reveal actions.</p>\n    </div>\n  </div>;\n}\nexport default HoverReplyToolbar;\n",
      "type": "registry:component"
    }
  ],
  "type": "registry:component"
}