{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "form-subscribe-inline",
  "type": "registry:component",
  "title": "Inline Subscribe",
  "description": "A one line newsletter field where the button sweeps across the input while it subscribes, then turns into a confirmation with a shortcut to the right inbox. Invalid emails shake and raise a tooltip.",
  "author": "Hyperblur <hello@hyperblur.dev>",
  "dependencies": [],
  "registryDependencies": [],
  "categories": [
    "forms",
    "form",
    "newsletter",
    "subscribe",
    "email",
    "inline",
    "morph"
  ],
  "docs": "https://hyperblur.dev/effects/form-subscribe-inline",
  "files": [
    {
      "path": "registry/hyperblur/form-subscribe-inline.tsx",
      "type": "registry:component",
      "target": "components/hyperblur/form-subscribe-inline.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nexport interface FormSubscribeInlineProps extends Omit<React.HTMLAttributes<HTMLDivElement>, \"onSubmit\"> {\n  placeholder?: string;\n  buttonLabel?: string;\n  frequencies?: string[];\n  readers?: string;\n  accent?: string;\n  delay?: number;\n  onSubmit?: (email: string, frequency: string) => void | Promise<void>;\n}\n\nconst css = `\n.hb-xh8 {\n  --hb-xh8-a: #ff4f8b;\n  --hb-xh8-bw: 118px;\n  box-sizing: border-box;\n  width: 100%;\n  max-width: 420px;\n  font-family: inherit;\n  color: #ededed;\n}\n.hb-xh8 *, .hb-xh8 *::before, .hb-xh8 *::after { box-sizing: border-box; }\n.hb-xh8-form { position: relative; }\n.hb-xh8-row {\n  position: relative;\n  display: flex;\n  align-items: center;\n  height: 50px;\n  padding: 4px;\n  border: 1px solid #2a2a2a;\n  border-radius: 14px;\n  background: linear-gradient(180deg, #121212, #0d0d0d);\n  box-shadow: inset 0 1px 0 rgba(255,255,255,0.05), 0 12px 30px -14px rgba(0,0,0,0.9);\n  transition: border-color 0.2s ease, box-shadow 0.2s ease;\n}\n.hb-xh8-row:focus-within { border-color: color-mix(in srgb, var(--hb-xh8-a) 70%, #2a2a2a); box-shadow: inset 0 1px 0 rgba(255,255,255,0.05), 0 0 0 4px color-mix(in srgb, var(--hb-xh8-a) 16%, transparent), 0 12px 30px -14px rgba(0,0,0,0.9); }\n.hb-xh8-row[data-bad=\"a\"], .hb-xh8-row[data-bad=\"b\"] { border-color: #f05260; animation: hb-xh8-shake 0.42s cubic-bezier(0.36, 0.07, 0.19, 0.97); }\n.hb-xh8-row[data-bad=\"b\"] { animation-name: hb-xh8-shake-b; }\n.hb-xh8-ico { display: grid; place-items: center; width: 34px; flex: none; color: #6b6b6b; transition: color 0.2s ease; }\n.hb-xh8-row:focus-within .hb-xh8-ico { color: var(--hb-xh8-a); }\n.hb-xh8-ico svg { width: 17px; height: 17px; }\n.hb-xh8-in { flex: 1; min-width: 0; height: 100%; padding: 0 calc(var(--hb-xh8-bw) + 8px) 0 2px; border: 0; outline: 0; background: transparent; color: #ededed; font: inherit; font-size: 14px; }\n.hb-xh8-in::placeholder { color: #575757; }\n.hb-xh8-btn {\n  position: absolute;\n  top: 4px;\n  right: 4px;\n  bottom: 4px;\n  z-index: 2;\n  width: var(--hb-xh8-bw);\n  border: 0;\n  border-radius: 10px;\n  background: linear-gradient(180deg, color-mix(in srgb, var(--hb-xh8-a) 88%, #fff), var(--hb-xh8-a));\n  color: #fff;\n  font: inherit;\n  font-size: 13.5px;\n  font-weight: 600;\n  cursor: pointer;\n  box-shadow: inset 0 1px 0 rgba(255,255,255,0.35), 0 6px 16px -6px var(--hb-xh8-a);\n  transition: transform 0.15s cubic-bezier(0.3, 0.7, 0.4, 1), filter 0.2s ease, opacity 0.2s ease;\n}\n.hb-xh8-btn:hover { filter: brightness(1.08); }\n.hb-xh8-btn:active { transform: scale(0.97); }\n.hb-xh8-btn:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }\n.hb-xh8-cover {\n  position: absolute;\n  inset: 4px;\n  z-index: 3;\n  display: flex;\n  align-items: center;\n  gap: 10px;\n  padding: 0 8px 0 14px;\n  border-radius: 10px;\n  background: linear-gradient(180deg, color-mix(in srgb, var(--hb-xh8-a) 88%, #fff), var(--hb-xh8-a));\n  color: #fff;\n  font-size: 13.5px;\n  font-weight: 500;\n  overflow: hidden;\n  clip-path: inset(0 0 0 calc(100% - var(--hb-xh8-bw)) round 10px);\n  opacity: 0;\n  pointer-events: none;\n  transition: clip-path 0.6s cubic-bezier(0.76, 0, 0.24, 1), opacity 0.15s ease, background 0.5s ease;\n}\n.hb-xh8[data-s=\"loading\"] .hb-xh8-cover, .hb-xh8[data-s=\"done\"] .hb-xh8-cover { clip-path: inset(0 0 0 0 round 10px); opacity: 1; pointer-events: auto; }\n.hb-xh8[data-s=\"done\"] .hb-xh8-cover { background: linear-gradient(180deg, #1b2a20, #142019); color: #c9f7da; box-shadow: inset 0 0 0 1px rgba(61,220,132,0.3); }\n.hb-xh8-prog { position: absolute; left: 0; bottom: 0; height: 2px; width: 100%; background: rgba(255,255,255,0.8); transform-origin: left; animation: hb-xh8-prog var(--hb-xh8-d) cubic-bezier(0.4, 0, 0.2, 1) both; }\n.hb-xh8-dots { display: inline-flex; gap: 3px; }\n.hb-xh8-dots i { width: 4px; height: 4px; border-radius: 50%; background: currentColor; animation: hb-xh8-dot 1s ease-in-out infinite; }\n.hb-xh8-dots i:nth-child(2) { animation-delay: 0.15s; }\n.hb-xh8-dots i:nth-child(3) { animation-delay: 0.3s; }\n.hb-xh8-ok { flex: none; width: 22px; height: 22px; border-radius: 50%; background: #3ddc84; display: grid; place-items: center; animation: hb-xh8-pop 0.4s 0.1s cubic-bezier(0.34, 1.56, 0.64, 1) both; }\n.hb-xh8-ok svg { width: 12px; height: 12px; stroke: #062b15; stroke-dasharray: 16; stroke-dashoffset: 16; animation: hb-xh8-draw 0.35s 0.35s ease-out forwards; }\n.hb-xh8-txt { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }\n.hb-xh8-txt b { color: #fff; font-weight: 600; }\n.hb-xh8-mail { flex: none; display: inline-flex; align-items: center; gap: 5px; height: 30px; padding: 0 10px; border-radius: 8px; background: rgba(61,220,132,0.14); color: #a6f3c4; font-size: 12px; font-weight: 600; text-decoration: none; border: 0; cursor: pointer; font-family: inherit; transition: background 0.2s ease; }\n.hb-xh8-mail:hover { background: rgba(61,220,132,0.24); }\n.hb-xh8-mail:focus-visible { outline: 2px solid #3ddc84; outline-offset: 1px; }\n.hb-xh8-mail svg { width: 12px; height: 12px; }\n.hb-xh8-tip { position: absolute; left: 30px; bottom: calc(100% + 8px); z-index: 4; padding: 6px 10px; border-radius: 8px; background: #f05260; color: #fff; font-size: 12px; font-weight: 500; white-space: nowrap; box-shadow: 0 8px 18px -8px rgba(240,82,96,0.8); animation: hb-xh8-tip 0.3s cubic-bezier(0.34, 1.56, 0.64, 1); }\n.hb-xh8-tip::after { content: \"\"; position: absolute; left: 14px; top: 100%; border: 5px solid transparent; border-top-color: #f05260; }\n.hb-xh8-meta { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 10px; font-size: 12px; color: #7a7a7a; }\n.hb-xh8-freq { display: inline-flex; padding: 2px; border: 1px solid #242424; border-radius: 8px; background: #0e0e0e; }\n.hb-xh8-freq button { height: 24px; padding: 0 9px; border: 0; border-radius: 6px; background: transparent; color: #7f7f7f; font: inherit; font-size: 11.5px; cursor: pointer; transition: background 0.2s ease, color 0.2s ease; }\n.hb-xh8-freq button[aria-checked=\"true\"] { background: #1f1f1f; color: #f0f0f0; box-shadow: inset 0 1px 0 rgba(255,255,255,0.06); }\n.hb-xh8-freq button:focus-visible { outline: 2px solid var(--hb-xh8-a); }\n.hb-xh8-who { display: inline-flex; align-items: center; gap: 8px; min-width: 0; }\n.hb-xh8-who span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }\n.hb-xh8-avs { display: inline-flex; flex: none; }\n.hb-xh8-avs i { width: 18px; height: 18px; margin-left: -6px; border-radius: 50%; border: 2px solid #0a0a0a; }\n.hb-xh8-avs i:first-child { margin-left: 0; }\n.hb-xh8-undo { padding: 0; border: 0; background: none; color: #a1a1a1; font: inherit; font-size: 12px; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; text-decoration-color: #444; }\n.hb-xh8-undo:hover { color: #fff; }\n.hb-xh8-undo:focus-visible { outline: 2px solid var(--hb-xh8-a); outline-offset: 2px; border-radius: 3px; }\n@keyframes hb-xh8-shake { 10%, 90% { transform: translateX(-1px); } 20%, 80% { transform: translateX(2px); } 30%, 50%, 70% { transform: translateX(-5px); } 40%, 60% { transform: translateX(5px); } }\n@keyframes hb-xh8-shake-b { 10%, 90% { transform: translateX(-1px); } 20%, 80% { transform: translateX(2px); } 30%, 50%, 70% { transform: translateX(-5px); } 40%, 60% { transform: translateX(5px); } }\n@keyframes hb-xh8-prog { from { transform: scaleX(0); } to { transform: scaleX(1); } }\n@keyframes hb-xh8-dot { 0%, 100% { opacity: 0.35; } 50% { opacity: 1; } }\n@keyframes hb-xh8-pop { from { transform: scale(0); } to { transform: scale(1); } }\n@keyframes hb-xh8-draw { to { stroke-dashoffset: 0; } }\n@keyframes hb-xh8-tip { from { opacity: 0; transform: translateY(6px) scale(0.9); } to { opacity: 1; transform: none; } }\n@media (prefers-reduced-motion: reduce) {\n  .hb-xh8 *, .hb-xh8 *::before, .hb-xh8 *::after { animation: none !important; transition: none !important; }\n  .hb-xh8-ok svg { stroke-dashoffset: 0; }\n}\n`;\n\nconst emailRe = /^[^\\s@]+@[^\\s@]+\\.[^\\s@]{2,}$/;\n\nconst inboxes: Record<string, { label: string; href: string }> = {\n  \"gmail.com\": { label: \"Open Gmail\", href: \"https://mail.google.com/mail/u/0/#inbox\" },\n  \"googlemail.com\": { label: \"Open Gmail\", href: \"https://mail.google.com/mail/u/0/#inbox\" },\n  \"outlook.com\": { label: \"Open Outlook\", href: \"https://outlook.live.com/mail/0/\" },\n  \"hotmail.com\": { label: \"Open Outlook\", href: \"https://outlook.live.com/mail/0/\" },\n  \"live.com\": { label: \"Open Outlook\", href: \"https://outlook.live.com/mail/0/\" },\n  \"icloud.com\": { label: \"Open iCloud\", href: \"https://www.icloud.com/mail\" },\n  \"proton.me\": { label: \"Open Proton\", href: \"https://mail.proton.me\" },\n  \"yahoo.com\": { label: \"Open Yahoo\", href: \"https://mail.yahoo.com\" },\n};\n\nconst avatarColors = [\"linear-gradient(135deg,#ff9a8b,#ff6a88)\", \"linear-gradient(135deg,#7f7fd5,#86a8e7)\", \"linear-gradient(135deg,#f6d365,#fda085)\", \"linear-gradient(135deg,#84fab0,#8fd3f4)\"];\n\nexport function FormSubscribeInline({\n  placeholder = \"you@studio.com\",\n  buttonLabel = \"Subscribe\",\n  frequencies = [\"Weekly\", \"Monthly\"],\n  readers = \"Join 12,400 designers\",\n  accent = \"#ff4f8b\",\n  delay = 1300,\n  onSubmit,\n  className,\n  style,\n  ...rest\n}: FormSubscribeInlineProps) {\n  const uid = React.useId();\n  const [email, setEmail] = React.useState(\"\");\n  const [freq, setFreq] = React.useState(frequencies[0] ?? \"\");\n  const [status, setStatus] = React.useState<\"idle\" | \"loading\" | \"done\">(\"idle\");\n  const [bad, setBad] = React.useState(0);\n  const input = React.useRef<HTMLInputElement>(null);\n  const mail = React.useRef<HTMLButtonElement>(null);\n\n  const domain = email.split(\"@\")[1]?.toLowerCase() ?? \"\";\n  const inbox = inboxes[domain];\n  const message = !email.trim() ? \"Enter your email first\" : \"That email is missing something\";\n\n  const submit = async (e: React.FormEvent) => {\n    e.preventDefault();\n    if (status !== \"idle\") return;\n    if (!emailRe.test(email.trim())) {\n      setBad((n) => n + 1);\n      input.current?.focus();\n      return;\n    }\n    setBad(0);\n    setStatus(\"loading\");\n    try {\n      await Promise.all([Promise.resolve(onSubmit?.(email.trim(), freq)), new Promise((r) => window.setTimeout(r, delay))]);\n      setStatus(\"done\");\n      window.requestAnimationFrame(() => mail.current?.focus({ preventScroll: true }));\n    } catch {\n      setStatus(\"idle\");\n      setBad((n) => n + 1);\n    }\n  };\n\n  const reset = () => {\n    setStatus(\"idle\");\n    window.requestAnimationFrame(() => input.current?.focus());\n  };\n\n  return (\n    <div className={[\"hb-xh8\", className].filter(Boolean).join(\" \")} data-s={status} style={{ ...style, \"--hb-xh8-a\": accent, \"--hb-xh8-d\": `${delay}ms` } as React.CSSProperties} {...rest}>\n      <style href=\"hb-form-subscribe-inline\" precedence=\"default\">{css}</style>\n      <form className=\"hb-xh8-form\" onSubmit={submit} noValidate>\n        {bad > 0 ? <span className=\"hb-xh8-tip\" key={bad} role=\"alert\" id={`${uid}-tip`}>{message}</span> : null}\n        <div className=\"hb-xh8-row\" data-bad={bad ? (bad % 2 ? \"a\" : \"b\") : undefined}>\n          <span className=\"hb-xh8-ico\" aria-hidden=\"true\">\n            <svg viewBox=\"0 0 20 20\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.5\" strokeLinecap=\"round\" strokeLinejoin=\"round\">\n              <rect x=\"2.5\" y=\"4.5\" width=\"15\" height=\"11\" rx=\"2.5\" />\n              <path d=\"m3.5 6 6.5 5 6.5-5\" />\n            </svg>\n          </span>\n          <input\n            ref={input}\n            className=\"hb-xh8-in\"\n            type=\"email\"\n            autoComplete=\"email\"\n            aria-label=\"Email address\"\n            placeholder={placeholder}\n            value={email}\n            disabled={status !== \"idle\"}\n            onChange={(e) => { setEmail(e.target.value); if (bad) setBad(0); }}\n            aria-invalid={bad > 0 ? true : undefined}\n            aria-describedby={bad > 0 ? `${uid}-tip` : undefined}\n          />\n          <button type=\"submit\" className=\"hb-xh8-btn\" tabIndex={status === \"idle\" ? 0 : -1}>{buttonLabel}</button>\n          <div className=\"hb-xh8-cover\" aria-live=\"polite\">\n            {status === \"loading\" ? (\n              <>\n                <span className=\"hb-xh8-txt\">Adding you to the list</span>\n                <span className=\"hb-xh8-dots\" aria-hidden=\"true\"><i /><i /><i /></span>\n                <span className=\"hb-xh8-prog\" aria-hidden=\"true\" />\n              </>\n            ) : null}\n            {status === \"done\" ? (\n              <>\n                <span className=\"hb-xh8-ok\" aria-hidden=\"true\">\n                  <svg viewBox=\"0 0 12 12\" fill=\"none\" strokeWidth=\"2.2\" strokeLinecap=\"round\" strokeLinejoin=\"round\"><path d=\"m2.5 6.2 2.3 2.3 4.7-5\" /></svg>\n                </span>\n                <span className=\"hb-xh8-txt\">Confirm via <b>{email.trim()}</b></span>\n                {inbox ? (\n                  <a className=\"hb-xh8-mail\" href={inbox.href} target=\"_blank\" rel=\"noreferrer\">\n                    {inbox.label}\n                    <svg viewBox=\"0 0 12 12\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.6\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\"><path d=\"M4 8 8 4M5 4h3v3\" /></svg>\n                  </a>\n                ) : (\n                  <button ref={mail} type=\"button\" className=\"hb-xh8-mail\" onClick={reset}>Edit</button>\n                )}\n              </>\n            ) : null}\n          </div>\n        </div>\n      </form>\n      <div className=\"hb-xh8-meta\">\n        <span className=\"hb-xh8-who\">\n          <span className=\"hb-xh8-avs\" aria-hidden=\"true\">\n            {avatarColors.map((c) => <i key={c} style={{ background: c }} />)}\n          </span>\n          <span>{status === \"done\" ? `${freq} issue, every ${freq === \"Monthly\" ? \"first Tuesday\" : \"Thursday\"}` : readers}</span>\n        </span>\n        {status === \"done\" ? (\n          <button type=\"button\" className=\"hb-xh8-undo\" onClick={reset}>Use another email</button>\n        ) : (\n          <span className=\"hb-xh8-freq\" role=\"radiogroup\" aria-label=\"Frequency\">\n            {frequencies.map((f) => (\n              <button key={f} type=\"button\" role=\"radio\" aria-checked={freq === f} onClick={() => setFreq(f)}>{f}</button>\n            ))}\n          </span>\n        )}\n      </div>\n    </div>\n  );\n}\n"
    }
  ]
}