{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "inline-rewrite-helper",
  "title": "Inline Rewrite Helper",
  "description": "An inline writing assistant with tone selection, async rewrite integration, editable drafts and accept or discard actions.",
  "dependencies": [
    "motion",
    "lucide-react",
    "clsx",
    "tailwind-merge"
  ],
  "files": [
    {
      "path": "registry/new-york/inline-rewrite-helper/inline-rewrite-helper.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\nimport { ArrowUpRight, Check, Sparkles, X, AlignLeft, Scissors, Smile } from \"lucide-react\";\nimport { clsx } from \"clsx\";\nimport { twMerge } from \"tailwind-merge\";\n\nexport type RewriteTone = \"Clearer\" | \"Shorter\" | \"Friendlier\";\nexport interface InlineRewriteHelperProps {\n  defaultValue?: string;\n  onRewrite?: (text: string, tone: RewriteTone) => string | Promise<string>;\n  onAccept?: (text: string) => void;\n  theme?: \"dark\" | \"light\";\n  className?: string;\n}\n\nexport function InlineRewriteHelper({ defaultValue = \"We wanted to reach out to let you know that the new workspace is now ready for you and your team to start using.\", onRewrite, onAccept, theme = \"dark\", className }: InlineRewriteHelperProps) {\n  const [text, setText] = React.useState(defaultValue);\n  const [tone, setTone] = React.useState<RewriteTone>(\"Clearer\");\n  const [suggestion, setSuggestion] = React.useState<string | null>(null);\n  const [busy, setBusy] = React.useState(false);\n  const [error, setError] = React.useState(\"\");\n  const [accepted, setAccepted] = React.useState(false);\n  const request = React.useRef(0);\n  const id = React.useId();\n  React.useEffect(() => () => { request.current++; }, []);\n  async function rewrite() {\n    const token = ++request.current;\n    setBusy(true); setError(\"\"); setAccepted(false); setSuggestion(null);\n    try {\n      const result = onRewrite ? await onRewrite(text, tone) : ({ Clearer: \"Your new workspace is ready. You and your team can start using it today.\", Shorter: \"Your team’s new workspace is ready to use.\", Friendlier: \"Your new workspace is ready! Bring your team along and make yourselves at home.\" })[tone];\n      if (token === request.current) {\n        if (!result.trim()) throw new Error(\"No suggestion returned. Try again.\");\n        setSuggestion(result);\n      }\n    } catch (cause) { if (token === request.current) setError(cause instanceof Error ? cause.message : \"Could not rewrite this text. Please try again.\"); }\n    finally { if (token === request.current) setBusy(false); }\n  }\n  const button = \"inline-flex items-center justify-center gap-2 rounded-full border border-current/[0.09] px-4 py-2.5 text-xs transition-colors hover:bg-current/5 focus-visible:outline-2 focus-visible:outline-[var(--ai-accent)] disabled:opacity-40\";\n  const palette = { \"--ai-accent\": theme === \"dark\" ? \"#b5a1ff\" : \"#7052bd\" } as React.CSSProperties;\n  return <section style={palette} aria-label=\"Inline rewrite helper\" className={twMerge(clsx(\"mx-auto w-full max-w-xl rounded-[24px] border border-current/[0.09] font-sans antialiased [font-family:Inter,ui-sans-serif,system-ui,sans-serif]\", theme === \"dark\" ? \"bg-[#0a0a0a] text-[#f2f2f2]\" : \"bg-[#fafafa] text-[#171717]\", className))}>\n    <header className=\"flex items-center gap-3 px-6 pb-4 pt-6\"><span className=\"flex size-8 items-center justify-center rounded-xl border border-current/10 bg-current/[0.03]\"><Sparkles size={14} className=\"text-[var(--ai-accent)]\" /></span><div><h3 className=\"text-[14px] font-medium tracking-[-0.025em]\">A better way to say it</h3><p className=\"mt-0.5 text-[11px] opacity-40\">Your voice. A little more clarity.</p></div></header>\n    <div className=\"px-6 pb-5\"><div className=\"overflow-hidden rounded-2xl border border-current/[0.09] bg-current/[0.02]\">\n      <div className=\"flex items-center justify-between px-4 pt-4\"><label htmlFor={id} className=\"text-[10px] font-medium opacity-45\">ORIGINAL</label><span className=\"text-[10px] tabular-nums opacity-30\">{text.trim() ? text.trim().split(/\\s+/).length : 0} words</span></div>\n      <textarea id={id} value={text} disabled={busy} onChange={e => { setText(e.target.value); setSuggestion(null); setAccepted(false); }} className=\"block min-h-36 w-full resize-y bg-transparent px-4 pb-4 pt-3 text-[14px] leading-[1.8] tracking-[-0.015em] outline-none focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-[var(--ai-accent)]\" />\n      <div className=\"flex flex-wrap items-center gap-1 border-t border-current/[0.07] p-2\" role=\"group\" aria-label=\"Rewrite tone\">{([\"Clearer\", \"Shorter\", \"Friendlier\"] as RewriteTone[]).map((t, i) => {\n        const Icon = [AlignLeft, Scissors, Smile][i];\n        return <button key={t} type=\"button\" aria-pressed={tone === t} disabled={busy} onClick={() => { setTone(t); setSuggestion(null); }} className={clsx(\"flex items-center gap-1.5 rounded-lg px-2.5 py-2 text-[11px] transition-colors focus-visible:outline-2 focus-visible:outline-[var(--ai-accent)] disabled:opacity-40\", tone === t ? \"bg-current/[0.08]\" : \"opacity-40 hover:bg-current/[0.04] hover:opacity-80\")}><Icon size={12} />{t}</button>;\n      })}</div>\n    </div>\n    <div className=\"mt-4 flex items-center justify-between gap-3\"><span className=\"text-[10px] opacity-35\">Keep the meaning. Find the words.</span><button type=\"button\" disabled={busy || !text.trim()} onClick={rewrite} className={button + (theme === \"dark\" ? \" shrink-0 border-transparent bg-[#f2f2f2] text-[#0a0a0a] hover:bg-white\" : \" shrink-0 border-transparent bg-[#171717] text-white hover:bg-[#333]\")}><span>{busy ? \"Rewriting…\" : \"Rewrite\"}</span><ArrowUpRight size={14} /></button></div>\n      {!onRewrite && <p className=\"mt-3 text-[10px] opacity-40\">Demo mode · sample suggestions for the example draft.</p>}\n      {error && <p role=\"alert\" className=\"mt-4 text-xs text-red-400\">{error}</p>}\n      {suggestion !== null && <div className=\"relative mt-5 overflow-hidden rounded-2xl border border-[var(--ai-accent)]/20 bg-[var(--ai-accent)]/[0.04] p-5\"><p className=\"text-[11px] opacity-45\">SUGGESTED REWRITE</p><p className=\"mt-3 whitespace-pre-wrap text-[14px] leading-[1.8] tracking-[-0.015em]\">{suggestion}</p><div className=\"mt-5 flex flex-wrap gap-2\"><button type=\"button\" className={button} onClick={() => { setText(suggestion); setSuggestion(null); setAccepted(true); onAccept?.(suggestion); }}><Check size={13} />Accept rewrite</button><button type=\"button\" className={button} onClick={() => setSuggestion(null)}><X size={13} />Discard</button></div></div>}\n      <p role=\"status\" className={clsx(\"text-[11px] opacity-50\", (busy || accepted) && \"mt-3\")}>{busy ? \"Preparing your suggestion…\" : accepted ? \"Rewrite applied to your draft.\" : \"\"}</p>\n    </div>\n  </section>;\n}\nexport default InlineRewriteHelper;\n",
      "type": "registry:component"
    }
  ],
  "type": "registry:component"
}