{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "email-composer",
  "title": "Email Composer",
  "description": "A minimal email draft with inline fields, a spacious message, and copy, expand, and send actions.",
  "dependencies": [
    "@solar-icons/react@^2.2.0",
    "cn@^0.3.0",
    "motion@^13.4.0"
  ],
  "registryDependencies": [
    "button",
    "https://pastaui.com/r/pastaui-styles.json"
  ],
  "files": [
    {
      "path": "src/components/ai/email-composer.tsx",
      "content": "import { CloseCircleIcon } from '@solar-icons/react/linear/close-circle'\nimport { LoaderIcon } from '@solar-icons/react/linear/loader'\nimport { AnimatePresence, MotionConfig, motion } from 'motion/react'\nimport * as React from 'react'\n\nimport { Button } from '@/components/ui/button'\nimport { cn } from 'cn'\n\ninterface EmailComposerProps extends Omit<React.ComponentProps<'form'>, 'onSubmit'> {\n  body: string\n  drafting?: boolean\n  onBodyChange?: (value: string) => void\n  onSubmit?: () => void | Promise<void>\n  onSubjectChange?: (value: string) => void\n  onRecipientsChange?: (value: string[]) => void\n  recipients: string[]\n  subject: string\n}\n\nconst ease = [0.23, 1, 0.32, 1] as const\nconst spring = { type: 'spring', stiffness: 500, damping: 30 } as const\nconst shimmer = 'agent-text-shimmer'\n\nfunction EmailComposer({\n  body,\n  className,\n  drafting = false,\n  onBodyChange,\n  onSubmit,\n  onSubjectChange,\n  onRecipientsChange,\n  recipients,\n  subject,\n  ...props\n}: EmailComposerProps) {\n  const id = React.useId()\n  const [draftRecipient, setDraftRecipient] = React.useState('')\n  const [sendState, setSendState] = React.useState<'idle' | 'sending' | 'sent'>('idle')\n  const fieldClassName =\n    'min-w-0 flex-1 rounded-sm bg-transparent py-4 text-sm text-muted-foreground outline-none placeholder:text-muted-foreground/60'\n  const list = recipients.filter((recipient) => recipient.trim())\n\n  async function send() {\n    if (!onSubmit || sendState !== 'idle') return\n    setSendState('sending')\n    try {\n      await onSubmit()\n      setSendState('sent')\n    } catch {\n      setSendState('idle')\n    }\n  }\n\n  function addRecipient(raw = draftRecipient) {\n    const value = raw.trim().replace(/,$/, '')\n    if (value && !list.includes(value)) onRecipientsChange?.([...list, value])\n    setDraftRecipient('')\n  }\n\n  React.useEffect(() => {\n    if (sendState !== 'sent') return\n    const timer = setTimeout(() => setSendState('idle'), 2200)\n    return () => clearTimeout(timer)\n  }, [sendState])\n\n  return (\n    <MotionConfig reducedMotion=\"user\">\n      <form\n        data-slot=\"email-composer\"\n        className={cn(\n          'overflow-hidden rounded-[16px] bg-card font-sans text-sm font-[450] tracking-[-0.05px] text-muted-foreground shadow-card',\n          className,\n        )}\n        onSubmit={(event) => {\n          event.preventDefault()\n          void send()\n        }}\n        {...props}\n      >\n        <header className=\"flex items-center justify-between gap-3 px-5 pt-4 pb-1 sm:px-6\">\n          <h3 className={cn('card-heading', drafting ? shimmer : 'text-muted-foreground')}>\n            {drafting ? 'Drafting email…' : 'Email'}\n          </h3>\n          <div className=\"flex items-center gap-1\">\n            <Button\n              className={cn(\n                'h-7 min-w-[4.75rem] overflow-hidden rounded-full border-0 px-3 shadow-[inset_0_1px_0_rgba(255,255,255,0.14),0_1px_2px_rgba(0,0,0,0.18)] shadow-none transition-[filter] duration-300 hover:brightness-110',\n                'bg-primary bg-linear-to-b from-[color-mix(in_oklch,var(--primary),var(--primary-foreground)_30%)] to-primary text-primary-foreground dark:bg-none',\n              )}\n              size=\"sm\"\n              variant=\"default\"\n              type=\"submit\"\n              disabled={\n                !onSubmit || drafting || !list.length || !body.trim() || sendState === 'sending'\n              }\n            >\n              <AnimatePresence initial={false} mode=\"popLayout\">\n                <motion.span\n                  animate={{ opacity: 1, y: 0 }}\n                  className=\"flex items-center gap-1.5\"\n                  exit={{ opacity: 0, y: -12 }}\n                  initial={{ opacity: 0, y: 12 }}\n                  key={sendState}\n                  transition={spring}\n                >\n                  {sendState === 'sending' && (\n                    <LoaderIcon className=\"size-3.5 animate-spin motion-reduce:animate-none\" />\n                  )}\n                  {sendState === 'sent' && (\n                    <svg aria-hidden=\"true\" className=\"size-3.5\" viewBox=\"0 0 16 16\">\n                      <motion.path\n                        animate={{ pathLength: 1 }}\n                        d=\"M3.5 8.5 6.5 11.5 12.5 5\"\n                        fill=\"none\"\n                        initial={{ pathLength: 0 }}\n                        stroke=\"currentColor\"\n                        strokeLinecap=\"round\"\n                        strokeLinejoin=\"round\"\n                        strokeWidth=\"2\"\n                        transition={{ delay: 0.1, duration: 0.3, ease }}\n                      />\n                    </svg>\n                  )}\n                  {sendState === 'idle' ? 'Send' : sendState === 'sending' ? 'Sending' : 'Sent'}\n                </motion.span>\n              </AnimatePresence>\n            </Button>\n          </div>\n        </header>\n        <div className=\"px-5 sm:px-6\">\n          <div className=\"flex items-start gap-4 border-b border-border/70\">\n            <label\n              className=\"w-20 shrink-0 pt-3.5 text-sm leading-5 text-muted-foreground/70\"\n              htmlFor={`${id}-recipients`}\n            >\n              Recipients\n            </label>\n            <div className=\"flex min-w-0 flex-1 flex-wrap items-center gap-1.5 py-2.5\">\n              <AnimatePresence initial={false} mode=\"popLayout\">\n                {list.map((recipient) => (\n                  <motion.span\n                    animate={{ opacity: 1, scale: 1 }}\n                    className=\"flex h-7 items-center gap-1.5 rounded-full bg-muted py-0.5 pr-1.5 pl-0.5 text-sm\"\n                    exit={{ opacity: 0, scale: 0.8 }}\n                    initial={{ opacity: 0, scale: 0.8 }}\n                    key={recipient}\n                    layout\n                    transition={spring}\n                  >\n                    <span className=\"flex size-6 items-center justify-center rounded-full bg-background text-[11px] font-medium uppercase\">\n                      {recipient[0]}\n                    </span>\n                    {recipient}\n                    {onRecipientsChange && (\n                      <button\n                        aria-label={`Remove ${recipient}`}\n                        className=\"rounded-full text-muted-foreground transition-colors hover:text-foreground\"\n                        onClick={() =>\n                          onRecipientsChange(list.filter((item) => item !== recipient))\n                        }\n                        type=\"button\"\n                      >\n                        <CloseCircleIcon className=\"size-4\" />\n                      </button>\n                    )}\n                  </motion.span>\n                ))}\n              </AnimatePresence>\n              <input\n                className={cn(\n                  fieldClassName,\n                  'h-7 py-0',\n                  list.length ? 'w-0 min-w-16' : 'min-w-32',\n                )}\n                id={`${id}-recipients`}\n                aria-label=\"Recipients\"\n                placeholder={list.length ? '' : 'Add recipients'}\n                value={draftRecipient}\n                readOnly={!onRecipientsChange}\n                onBlur={() => addRecipient()}\n                onChange={(event) =>\n                  event.target.value.endsWith(',')\n                    ? addRecipient(event.target.value)\n                    : setDraftRecipient(event.target.value)\n                }\n                onKeyDown={(event) => {\n                  if (event.key === 'Enter') {\n                    event.preventDefault()\n                    addRecipient()\n                  }\n                  if (event.key === 'Backspace' && !draftRecipient && list.length)\n                    onRecipientsChange?.(list.slice(0, -1))\n                }}\n              />\n            </div>\n          </div>\n          <div className=\"flex items-baseline gap-4 border-b border-border/70\">\n            <label\n              className=\"w-20 shrink-0 text-sm text-muted-foreground/70\"\n              htmlFor={`${id}-subject`}\n            >\n              Subject\n            </label>\n            <input\n              className={fieldClassName}\n              id={`${id}-subject`}\n              placeholder=\"Add a subject\"\n              value={subject}\n              readOnly={!onSubjectChange}\n              onChange={(event) => onSubjectChange?.(event.target.value)}\n            />\n          </div>\n          <textarea\n            aria-label=\"Email message\"\n            aria-busy={drafting}\n            className={cn(\n              'block min-h-64 w-full resize-none rounded-sm bg-transparent pt-4 pb-5 text-sm leading-[1.6] text-muted-foreground outline-none placeholder:text-muted-foreground/60',\n            )}\n            onChange={(event) => onBodyChange?.(event.target.value)}\n            readOnly={!onBodyChange || drafting}\n            placeholder=\"Write your message…\"\n            value={drafting ? `${body}▍` : body}\n          />\n        </div>\n        <output className=\"sr-only\">{sendState === 'sent' ? 'Email sent' : ''}</output>\n      </form>\n    </MotionConfig>\n  )\n}\n\nexport { EmailComposer }\nexport type { EmailComposerProps }\nexport default EmailComposer\n",
      "type": "registry:component",
      "target": "@components/ai/email-composer.tsx"
    }
  ],
  "css": {
    ".agent-text-shimmer": {
      "color": "transparent",
      "background-image": "linear-gradient( 90deg, var(--muted-foreground), var(--foreground), var(--muted-foreground) )",
      "background-size": "200% 100%",
      "background-clip": "text",
      "animation": "agent-text-shimmer 1.6s linear infinite"
    },
    "@keyframes agent-text-shimmer": {
      "from": {
        "background-position": "200% 0"
      },
      "to": {
        "background-position": "-200% 0"
      }
    },
    "@media (prefers-reduced-motion: reduce)": {
      ".agent-text-shimmer": {
        "color": "var(--muted-foreground)",
        "background-image": "none",
        "animation": "none"
      }
    }
  },
  "type": "registry:component"
}