{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "site-promo-modal",
  "type": "registry:component",
  "title": "Promo Modal",
  "description": "A promotional popup with a gradient artwork side, a delayed entrance and a don't-show-again checkbox. It closes with Escape or a click on the backdrop, and renders inside its own relative frame.",
  "author": "Hyperblur <hello@hyperblur.dev>",
  "dependencies": [],
  "registryDependencies": [],
  "categories": [
    "site",
    "popup",
    "modal",
    "promo",
    "offer",
    "dialog",
    "marketing"
  ],
  "docs": "https://hyperblur.dev/effects/site-promo-modal",
  "files": [
    {
      "path": "registry/hyperblur/site-promo-modal.tsx",
      "type": "registry:component",
      "target": "components/hyperblur/site-promo-modal.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nexport interface SitePromoModalProps\n  extends Omit<React.HTMLAttributes<HTMLDivElement>, \"title\"> {\n  open?: boolean;\n  defaultOpen?: boolean;\n  onOpenChange?: (open: boolean) => void;\n  delay?: number;\n  badge?: string;\n  title?: string;\n  description?: string;\n  cta?: string;\n  ctaHref?: string;\n  onCta?: () => void;\n  rememberLabel?: string;\n  storageKey?: string;\n  onDismiss?: (dontShowAgain: boolean) => void;\n  highlight?: string;\n  art?: React.ReactNode;\n  autoFocus?: boolean;\n  fixed?: boolean;\n  accent?: string;\n}\n\nconst css = `\n.hb-yf8 {\n  position: relative;\n  box-sizing: border-box;\n  width: 100%;\n  height: 100%;\n  overflow: hidden;\n  container-type: inline-size;\n  font-family: inherit;\n  color: #ededed;\n  outline: none;\n}\n.hb-yf8 *, .hb-yf8 *::before, .hb-yf8 *::after { box-sizing: border-box; font-family: inherit; }\n.hb-yf8[data-fixed=\"true\"] { position: fixed; inset: 0; z-index: 60; width: auto; height: auto; overflow: visible; pointer-events: none; }\n.hb-yf8-page { width: 100%; height: 100%; }\n.hb-yf8-overlay {\n  position: absolute;\n  inset: 0;\n  z-index: 5;\n  display: grid;\n  place-items: center;\n  padding: 10px;\n  background: rgba(5, 5, 7, 0.62);\n  backdrop-filter: blur(3px);\n  -webkit-backdrop-filter: blur(3px);\n  animation: hb-yf8-fade 0.25s ease both;\n}\n.hb-yf8[data-fixed=\"true\"] .hb-yf8-overlay { position: fixed; pointer-events: auto; padding: 20px; }\n.hb-yf8-overlay[data-state=\"closed\"] { animation: hb-yf8-fade-out 0.22s ease forwards; pointer-events: none; }\n.hb-yf8-dialog {\n  position: relative;\n  display: grid;\n  grid-template-columns: 38% minmax(0, 1fr);\n  width: 100%;\n  max-width: 520px;\n  max-height: 100%;\n  overflow: hidden;\n  background: #111111;\n  border: 1px solid #2a2a2a;\n  border-radius: 16px;\n  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6);\n  outline: none;\n  animation: hb-yf8-pop 0.42s cubic-bezier(0.22, 1.2, 0.36, 1) both;\n}\n.hb-yf8-overlay[data-state=\"closed\"] .hb-yf8-dialog { animation: hb-yf8-pop-out 0.22s ease forwards; }\n.hb-yf8-art {\n  position: relative;\n  display: grid;\n  place-items: center;\n  min-height: 100%;\n  overflow: hidden;\n  background: linear-gradient(155deg, var(--hb-yf8-a, #2f7bff) 0%, #6a3dff 62%, #c13fb8 120%);\n}\n.hb-yf8-blob { position: absolute; border-radius: 50%; filter: blur(14px); opacity: 0.55; animation: hb-yf8-drift 7s ease-in-out infinite alternate; }\n.hb-yf8-blob[data-n=\"1\"] { width: 90px; height: 90px; left: -26px; top: -22px; background: #9fd0ff; }\n.hb-yf8-blob[data-n=\"2\"] { width: 80px; height: 80px; right: -24px; bottom: -20px; background: #ff7ad9; animation-delay: -3s; }\n.hb-yf8-ring { position: absolute; width: 74%; aspect-ratio: 1; border: 1px dashed rgba(255, 255, 255, 0.5); border-radius: 50%; animation: hb-yf8-spin 28s linear infinite; }\n.hb-yf8-big { position: relative; z-index: 1; display: grid; justify-items: center; line-height: 1; text-align: center; color: #fff; text-shadow: 0 2px 18px rgba(20, 10, 60, 0.4); }\n.hb-yf8-big strong { font-size: 34px; font-weight: 700; letter-spacing: -0.03em; }\n.hb-yf8-big span { margin-top: 3px; font-size: 10px; font-weight: 600; letter-spacing: 0.18em; text-transform: uppercase; opacity: 0.9; }\n.hb-yf8-main { position: relative; display: flex; flex-direction: column; align-items: flex-start; min-width: 0; padding: 12px 14px 10px; }\n.hb-yf8-badge { margin: 0 0 5px; padding: 1px 8px; font-size: 10px; font-weight: 600; letter-spacing: 0.06em; line-height: 16px; text-transform: uppercase; color: #7fb3ff; background: rgba(47, 123, 255, 0.14); border: 1px solid rgba(47, 123, 255, 0.35); border-radius: 999px; }\n.hb-yf8-title { margin: 0 24px 3px 0; font-size: 15px; font-weight: 600; line-height: 1.2; letter-spacing: -0.015em; }\n.hb-yf8-desc { margin: 0 0 8px; font-size: 11.5px; line-height: 1.4; color: #a1a1a1; }\n.hb-yf8-cta {\n  display: inline-flex;\n  align-items: center;\n  justify-content: center;\n  gap: 6px;\n  height: 30px;\n  padding: 0 14px;\n  font-size: 12px;\n  font-weight: 600;\n  color: #0a0a0a;\n  text-decoration: none;\n  background: #ededed;\n  border: 0;\n  border-radius: 999px;\n  cursor: pointer;\n  transition: transform 0.15s ease, background-color 0.15s ease;\n}\n.hb-yf8-cta:hover { background: #ffffff; transform: translateY(-1px); }\n.hb-yf8-cta:active { transform: scale(0.97); }\n.hb-yf8-cta svg { width: 11px; height: 11px; }\n.hb-yf8-close { position: absolute; top: 8px; right: 8px; display: grid; place-items: center; width: 24px; height: 24px; margin: 0; padding: 0; color: #8f8f8f; background: transparent; border: 0; border-radius: 8px; cursor: pointer; transition: background-color 0.15s ease, color 0.15s ease; }\n.hb-yf8-close:hover { color: #ededed; background: rgba(255, 255, 255, 0.08); }\n.hb-yf8-close svg { width: 10px; height: 10px; }\n.hb-yf8-cta:focus-visible, .hb-yf8-close:focus-visible { outline: 2px solid var(--hb-yf8-a, #2f7bff); outline-offset: 2px; }\n.hb-yf8-remember { display: inline-flex; align-items: center; gap: 7px; margin-top: 8px; font-size: 11px; color: #8f8f8f; cursor: pointer; user-select: none; }\n.hb-yf8-remember:hover { color: #c8c8c8; }\n.hb-yf8-check { position: relative; width: 14px; height: 14px; margin: 0; appearance: none; -webkit-appearance: none; background: #171717; border: 1px solid #3a3a3a; border-radius: 4px; cursor: pointer; transition: background-color 0.15s ease, border-color 0.15s ease; }\n.hb-yf8-check:checked { background: var(--hb-yf8-a, #2f7bff); border-color: var(--hb-yf8-a, #2f7bff); }\n.hb-yf8-check:checked::after { content: \"\"; position: absolute; left: 4px; top: 1px; width: 3px; height: 7px; border: solid #fff; border-width: 0 1.6px 1.6px 0; transform: rotate(45deg); }\n.hb-yf8-check:focus-visible { outline: 2px solid var(--hb-yf8-a, #2f7bff); outline-offset: 2px; }\n@container (max-width: 300px) {\n  .hb-yf8-dialog { grid-template-columns: minmax(0, 1fr); }\n  .hb-yf8-art { display: none; }\n}\n@keyframes hb-yf8-fade { from { opacity: 0; } to { opacity: 1; } }\n@keyframes hb-yf8-fade-out { to { opacity: 0; } }\n@keyframes hb-yf8-pop { from { opacity: 0; transform: translateY(18px) scale(0.94); } to { opacity: 1; transform: none; } }\n@keyframes hb-yf8-pop-out { to { opacity: 0; transform: translateY(8px) scale(0.97); } }\n@keyframes hb-yf8-drift { from { transform: translate(0, 0); } to { transform: translate(14px, 10px); } }\n@keyframes hb-yf8-spin { to { transform: rotate(360deg); } }\n@media (prefers-reduced-motion: reduce) {\n  .hb-yf8-overlay, .hb-yf8-dialog, .hb-yf8-blob, .hb-yf8-ring { animation: none; }\n  .hb-yf8-overlay[data-state=\"closed\"], .hb-yf8-overlay[data-state=\"closed\"] .hb-yf8-dialog { animation: none; opacity: 0; }\n  .hb-yf8-cta, .hb-yf8-close, .hb-yf8-check { transition: none; }\n}\n`;\n\nfunction isBlocked(key?: string) {\n  if (!key) return false;\n  try {\n    return window.localStorage.getItem(key) === \"1\";\n  } catch {\n    return false;\n  }\n}\n\nfunction remember(key: string) {\n  try {\n    window.localStorage.setItem(key, \"1\");\n  } catch {\n    return false;\n  }\n  return true;\n}\n\nexport function SitePromoModal({\n  open,\n  defaultOpen = true,\n  onOpenChange,\n  delay = 0,\n  badge = \"Welcome offer\",\n  title = \"20% off your first order\",\n  description = \"Free shipping over $40, too.\",\n  cta = \"Claim my code\",\n  ctaHref = \"#\",\n  onCta,\n  rememberLabel = \"Don't show this again\",\n  storageKey,\n  onDismiss,\n  highlight = \"20%\",\n  art,\n  autoFocus = true,\n  fixed = false,\n  accent = \"#2f7bff\",\n  className = \"\",\n  style,\n  children,\n  onKeyDown,\n  ...rest\n}: SitePromoModalProps) {\n  const uid = React.useId();\n  const dialogRef = React.useRef<HTMLDivElement>(null);\n  const [inner, setInner] = React.useState(defaultOpen);\n  const [armed, setArmed] = React.useState(false);\n  const [dontShow, setDontShow] = React.useState(false);\n  const controlled = open !== undefined;\n  const isOpen = controlled ? open : inner;\n\n  React.useEffect(() => {\n    if (isOpen) {\n      const t = window.setTimeout(() => {\n        if (isBlocked(storageKey)) return;\n        setArmed(true);\n      }, Math.max(0, delay));\n      return () => window.clearTimeout(t);\n    }\n    const t = window.setTimeout(() => setArmed(false), 240);\n    return () => window.clearTimeout(t);\n  }, [isOpen, delay, storageKey]);\n\n  React.useEffect(() => {\n    if (armed && isOpen && autoFocus) dialogRef.current?.focus({ preventScroll: true });\n  }, [armed, isOpen, autoFocus]);\n\n  function close() {\n    if (dontShow && storageKey) remember(storageKey);\n    if (!controlled) setInner(false);\n    onOpenChange?.(false);\n    onDismiss?.(dontShow);\n  }\n\n  function handleKeyDown(e: React.KeyboardEvent<HTMLDivElement>) {\n    onKeyDown?.(e);\n    if (!armed || !isOpen) return;\n    if (e.key === \"Escape\") {\n      e.stopPropagation();\n      close();\n      return;\n    }\n    if (e.key === \"Tab\" && dialogRef.current) {\n      const nodes = Array.from(\n        dialogRef.current.querySelectorAll<HTMLElement>('a[href], button:not([disabled]), input:not([disabled])'),\n      );\n      if (nodes.length === 0) return;\n      const first = nodes[0];\n      const last = nodes[nodes.length - 1];\n      const at = document.activeElement;\n      if (e.shiftKey && (at === first || at === dialogRef.current)) {\n        e.preventDefault();\n        last.focus();\n      } else if (!e.shiftKey && at === last) {\n        e.preventDefault();\n        first.focus();\n      }\n    }\n  }\n\n  return (\n    <>\n      <style href=\"hb-site-promo-modal\" precedence=\"default\">{css}</style>\n      <div\n        className={`hb-yf8 ${className}`}\n        data-fixed={fixed}\n        tabIndex={-1}\n        style={{ \"--hb-yf8-a\": accent, ...style } as React.CSSProperties}\n        onKeyDown={handleKeyDown}\n        {...rest}\n      >\n        <div className=\"hb-yf8-page\">{children}</div>\n        {armed ? (\n          <div\n            className=\"hb-yf8-overlay\"\n            data-state={isOpen ? \"open\" : \"closed\"}\n            onPointerDown={(e) => {\n              if (e.target === e.currentTarget) close();\n            }}\n          >\n            <div\n              ref={dialogRef}\n              role=\"dialog\"\n              aria-modal=\"true\"\n              aria-labelledby={`${uid}-t`}\n              aria-describedby={`${uid}-d`}\n              tabIndex={-1}\n              className=\"hb-yf8-dialog\"\n            >\n              <div className=\"hb-yf8-art\" aria-hidden=\"true\">\n                {art ?? (\n                  <>\n                    <span className=\"hb-yf8-blob\" data-n=\"1\" />\n                    <span className=\"hb-yf8-blob\" data-n=\"2\" />\n                    <span className=\"hb-yf8-ring\" />\n                    <span className=\"hb-yf8-big\">\n                      <strong>{highlight}</strong>\n                      <span>off</span>\n                    </span>\n                  </>\n                )}\n              </div>\n              <div className=\"hb-yf8-main\">\n                <button type=\"button\" className=\"hb-yf8-close\" aria-label=\"Close\" onClick={close}>\n                  <svg viewBox=\"0 0 10 10\" fill=\"none\" aria-hidden=\"true\"><path d=\"M1.8 1.8l6.4 6.4M8.2 1.8l-6.4 6.4\" stroke=\"currentColor\" strokeWidth=\"1.5\" strokeLinecap=\"round\" /></svg>\n                </button>\n                {badge ? <p className=\"hb-yf8-badge\">{badge}</p> : null}\n                <h3 id={`${uid}-t`} className=\"hb-yf8-title\">{title}</h3>\n                <p id={`${uid}-d`} className=\"hb-yf8-desc\">{description}</p>\n                <a href={ctaHref} className=\"hb-yf8-cta\" onClick={onCta}>\n                  {cta}\n                  <svg viewBox=\"0 0 12 12\" fill=\"none\" aria-hidden=\"true\"><path d=\"M2.5 6h7M6.5 3l3 3-3 3\" stroke=\"currentColor\" strokeWidth=\"1.5\" strokeLinecap=\"round\" strokeLinejoin=\"round\" /></svg>\n                </a>\n                <label className=\"hb-yf8-remember\">\n                  <input\n                    type=\"checkbox\"\n                    className=\"hb-yf8-check\"\n                    checked={dontShow}\n                    onChange={(e) => setDontShow(e.target.checked)}\n                  />\n                  {rememberLabel}\n                </label>\n              </div>\n            </div>\n          </div>\n        ) : null}\n      </div>\n    </>\n  );\n}\n"
    }
  ]
}