{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "modal-success-check",
  "type": "registry:component",
  "title": "Success Check Modal",
  "description": "A payment success modal that draws its ring and check, throws a small spark burst and counts the amount up. The receipt-style card ends in a perforated edge with a staggered list of details.",
  "author": "Hyperblur <hello@hyperblur.dev>",
  "dependencies": [],
  "registryDependencies": [],
  "categories": [
    "modals",
    "success",
    "check",
    "payment",
    "receipt",
    "celebration",
    "modal"
  ],
  "docs": "https://hyperblur.dev/effects/modal-success-check",
  "files": [
    {
      "path": "registry/hyperblur/modal-success-check.tsx",
      "type": "registry:component",
      "target": "components/hyperblur/modal-success-check.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nexport interface SuccessDetail {\n  label: string;\n  value: string;\n}\n\nexport interface ModalSuccessCheckProps extends Omit<React.HTMLAttributes<HTMLDivElement>, \"title\"> {\n  open?: boolean;\n  defaultOpen?: boolean;\n  onOpenChange?: (open: boolean) => void;\n  embedded?: boolean;\n  trigger?: React.ReactNode;\n  title?: string;\n  message?: string;\n  amount?: number;\n  currency?: string;\n  locale?: string;\n  details?: SuccessDetail[];\n  doneLabel?: string;\n  receiptLabel?: string;\n  onDone?: () => void;\n  onReceipt?: () => void;\n  accent?: string;\n}\n\nconst defaultDetails: SuccessDetail[] = [\n  { label: \"Paid to\", value: \"Northwind Studio\" },\n  { label: \"Invoice\", value: \"INV-2048\" },\n  { label: \"Method\", value: \"Visa •• 4242\" },\n  { label: \"Date\", value: \"Nov 7, 2026 · 2:14 PM\" },\n];\n\nconst palette = [\"var(--hb-xe12-accent)\", \"#fde047\", \"#60a5fa\", \"#f472b6\", \"#ffffff\"];\n\nconst sparks = Array.from({ length: 16 }, (_, i) => {\n  const h = Math.imul(i + 7, 2654435761) >>> 0;\n  const j = Math.imul(i + 3, 1597334677) >>> 0;\n  return {\n    a: (i * 22.5 + ((h % 100) / 100) * 12 - 6).toFixed(1),\n    d: (36 + (j % 18)).toFixed(0),\n    s: (3 + (h % 4)).toFixed(0),\n    c: palette[(h >>> 3) % palette.length],\n    r: (h >>> 5) % 2 === 0,\n  };\n});\n\nconst css = `\n.hb-xe12 { --hb-xe12-accent: #22c55e; display: inline-block; box-sizing: border-box; color: #ededed; font-family: var(--font-sans, ui-sans-serif, system-ui, sans-serif); }\n.hb-xe12 *, .hb-xe12 *::before, .hb-xe12 *::after { box-sizing: border-box; }\n.hb-xe12[data-embedded] { position: relative; display: grid; place-items: center; width: 100%; height: 100%; min-height: 190px; border-radius: 16px; overflow: hidden; isolation: isolate; background: radial-gradient(70% 60% at 50% 30%, color-mix(in srgb, var(--hb-xe12-accent) 9%, transparent), transparent 70%), #0a0a0a; }\n.hb-xe12-trigger { display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 18px; border: 0; border-radius: 11px; background: linear-gradient(180deg, #fafafa, #e4e4e7); color: #0a0a0a; font: inherit; font-size: 14px; font-weight: 650; font-variant-numeric: tabular-nums; cursor: pointer; box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.12), 0 10px 24px -12px rgba(255, 255, 255, 0.35); transition: transform 0.15s cubic-bezier(0.3, 0.7, 0.4, 1); }\n.hb-xe12-trigger:active { transform: scale(0.97); }\n.hb-xe12-trigger svg { width: 14px; height: 14px; }\n.hb-xe12 button:focus-visible { outline: 2px solid var(--hb-xe12-accent); outline-offset: 2px; }\n.hb-xe12-layer { position: fixed; inset: 0; z-index: 1000; height: 100dvh; display: grid; place-items: center; padding: 16px; }\n.hb-xe12[data-embedded] .hb-xe12-layer { position: absolute; height: auto; z-index: 2; padding: 10px; }\n.hb-xe12-scrim { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.66); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); animation: hb-xe12-fade 0.3s ease both; }\n.hb-xe12-layer[data-state=\"closed\"] .hb-xe12-scrim { animation: hb-xe12-fade-out 0.24s ease both; }\n.hb-xe12-panel { position: relative; width: 100%; max-width: 360px; max-height: 100%; overflow: auto; padding: 26px 22px 30px; border-radius: 20px 20px 6px 6px; background: linear-gradient(180deg, #171717, #121212 60%); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06), 0 40px 90px -30px rgba(0, 0, 0, 0.95); text-align: center; outline: none; -webkit-mask: radial-gradient(circle 6px at 50% 100%, transparent 98%, #000) 50% 100% / 18px 100% repeat-x; mask: radial-gradient(circle 6px at 50% 100%, transparent 98%, #000) 50% 100% / 18px 100% repeat-x; animation: hb-xe12-in 0.5s cubic-bezier(0.16, 1, 0.3, 1) both; }\n.hb-xe12-layer[data-state=\"closed\"] .hb-xe12-panel { animation: hb-xe12-out 0.24s ease both; }\n.hb-xe12-mark { position: relative; width: 68px; height: 68px; margin: 0 auto 14px; }\n.hb-xe12-glow { position: absolute; inset: -14px; border-radius: 50%; background: radial-gradient(circle, color-mix(in srgb, var(--hb-xe12-accent) 35%, transparent), transparent 65%); animation: hb-xe12-glow 1.2s 0.4s ease-out both; }\n.hb-xe12-mark svg { position: relative; width: 100%; height: 100%; overflow: visible; }\n.hb-xe12-disc { fill: color-mix(in srgb, var(--hb-xe12-accent) 14%, #121212); transform-origin: 34px 34px; animation: hb-xe12-disc 0.5s cubic-bezier(0.3, 0.7, 0.4, 1.4) both; }\n.hb-xe12-ring { fill: none; stroke: var(--hb-xe12-accent); stroke-width: 3; stroke-linecap: round; stroke-dasharray: 189; stroke-dashoffset: 189; transform: rotate(-90deg); transform-origin: 34px 34px; animation: hb-xe12-draw 0.6s 0.1s cubic-bezier(0.65, 0, 0.35, 1) forwards; }\n.hb-xe12-tick { fill: none; stroke: var(--hb-xe12-accent); stroke-width: 4; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 36; stroke-dashoffset: 36; animation: hb-xe12-draw 0.38s 0.55s cubic-bezier(0.65, 0, 0.35, 1) forwards; }\n.hb-xe12-spark { position: absolute; top: 50%; left: 50%; width: var(--hb-xe12-s); height: var(--hb-xe12-s); margin: calc(var(--hb-xe12-s) / -2) 0 0 calc(var(--hb-xe12-s) / -2); border-radius: 50%; background: var(--hb-xe12-c); opacity: 0; transform: rotate(var(--hb-xe12-a)) translateY(0); animation: hb-xe12-burst 0.8s 0.7s cubic-bezier(0.1, 0.8, 0.3, 1) both; }\n.hb-xe12-spark[data-r=\"true\"] { border-radius: 1px; width: 2px; height: calc(var(--hb-xe12-s) * 2.2); }\n.hb-xe12-title { margin: 0; font-size: 16px; font-weight: 600; letter-spacing: -0.012em; animation: hb-xe12-rise 0.5s 0.5s cubic-bezier(0.2, 0.9, 0.25, 1) both; }\n.hb-xe12-amount { margin: 6px 0 0; font-family: var(--font-grotesk, inherit); font-size: 34px; font-weight: 600; letter-spacing: -0.035em; font-variant-numeric: tabular-nums; animation: hb-xe12-rise 0.5s 0.58s cubic-bezier(0.2, 0.9, 0.25, 1) both; }\n.hb-xe12-msg { margin: 4px 0 0; color: #8f8f8f; font-size: 12.5px; line-height: 1.5; animation: hb-xe12-rise 0.5s 0.66s cubic-bezier(0.2, 0.9, 0.25, 1) both; }\n.hb-xe12-list { margin: 18px 0 0; padding: 14px 0 0; border-top: 1px dashed #2a2a2a; display: grid; gap: 8px; text-align: left; }\n.hb-xe12-row { display: flex; justify-content: space-between; gap: 12px; font-size: 12.5px; animation: hb-xe12-rise 0.45s calc(0.75s + var(--hb-xe12-i) * 0.06s) cubic-bezier(0.2, 0.9, 0.25, 1) both; }\n.hb-xe12-row dt { color: #7d7d7d; }\n.hb-xe12-row dd { margin: 0; color: #e4e4e4; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }\n.hb-xe12-foot { display: flex; gap: 8px; margin-top: 20px; animation: hb-xe12-rise 0.45s 1s cubic-bezier(0.2, 0.9, 0.25, 1) both; }\n.hb-xe12-btn { flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 38px; border: 1px solid #2a2a2a; border-radius: 10px; background: transparent; color: #d4d4d4; font: inherit; font-size: 13px; font-weight: 550; cursor: pointer; transition: background-color 0.15s ease, transform 0.15s cubic-bezier(0.3, 0.7, 0.4, 1); }\n.hb-xe12-btn:hover { background: #1c1c1c; }\n.hb-xe12-btn:active { transform: scale(0.97); }\n.hb-xe12-btn[data-primary] { border-color: transparent; background: var(--hb-xe12-accent); color: #04140a; box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3), 0 8px 20px -10px var(--hb-xe12-accent); }\n.hb-xe12-btn[data-primary]:hover { background: color-mix(in srgb, var(--hb-xe12-accent) 88%, #fff); }\n.hb-xe12-btn svg { width: 13px; height: 13px; }\n.hb-xe12[data-embedded] .hb-xe12-panel { padding: 18px 18px 24px; }\n.hb-xe12[data-embedded] .hb-xe12-mark { width: 52px; height: 52px; margin-bottom: 10px; }\n.hb-xe12[data-embedded] .hb-xe12-amount { font-size: 28px; margin-top: 4px; }\n.hb-xe12[data-embedded] .hb-xe12-list { margin-top: 12px; padding-top: 10px; }\n.hb-xe12[data-embedded] .hb-xe12-foot { margin-top: 14px; }\n@keyframes hb-xe12-fade { from { opacity: 0; } to { opacity: 1; } }\n@keyframes hb-xe12-fade-out { from { opacity: 1; } to { opacity: 0; } }\n@keyframes hb-xe12-in { from { opacity: 0; transform: translateY(18px) scale(0.96); } to { opacity: 1; transform: none; } }\n@keyframes hb-xe12-out { from { opacity: 1; } to { opacity: 0; transform: translateY(8px) scale(0.98); } }\n@keyframes hb-xe12-disc { from { transform: scale(0); } to { transform: scale(1); } }\n@keyframes hb-xe12-draw { to { stroke-dashoffset: 0; } }\n@keyframes hb-xe12-glow { 0% { opacity: 0; transform: scale(0.6); } 40% { opacity: 1; } 100% { opacity: 0.35; transform: scale(1); } }\n@keyframes hb-xe12-burst { 0% { opacity: 1; transform: rotate(var(--hb-xe12-a)) translateY(-20px) scale(1); } 70% { opacity: 1; } 100% { opacity: 0; transform: rotate(var(--hb-xe12-a)) translateY(calc(var(--hb-xe12-d) * -1px)) scale(0.4); } }\n@keyframes hb-xe12-rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }\n@media (prefers-reduced-motion: reduce) {\n  .hb-xe12-scrim, .hb-xe12-panel, .hb-xe12-glow, .hb-xe12-disc, .hb-xe12-title, .hb-xe12-amount, .hb-xe12-msg, .hb-xe12-row, .hb-xe12-foot, .hb-xe12-layer[data-state=\"closed\"] .hb-xe12-panel, .hb-xe12-layer[data-state=\"closed\"] .hb-xe12-scrim { animation: none; }\n  .hb-xe12-ring, .hb-xe12-tick { animation: none; stroke-dashoffset: 0; }\n  .hb-xe12-spark { animation: none; opacity: 0; }\n  .hb-xe12-layer[data-state=\"closed\"] { opacity: 0; }\n  .hb-xe12-btn, .hb-xe12-trigger { transition: none; }\n}\n`;\n\nconst focusable =\n  'a[href],button:not(:disabled),input:not(:disabled),select:not(:disabled),textarea:not(:disabled),[tabindex]:not([tabindex=\"-1\"])';\n\nfunction useLayer(\n  open: boolean,\n  embedded: boolean,\n  panel: React.RefObject<HTMLElement | null>,\n  onClose: () => void,\n  userOpened: React.RefObject<boolean>,\n) {\n  const closeRef = React.useRef(onClose);\n  React.useEffect(() => {\n    closeRef.current = onClose;\n  });\n  React.useEffect(() => {\n    if (!open) return;\n    const node = panel.current;\n    const steal = !embedded || userOpened.current;\n    const previous = document.activeElement as HTMLElement | null;\n    const html = document.documentElement;\n    const overflow = html.style.overflow;\n    if (!embedded) html.style.overflow = \"hidden\";\n    if (steal && node) {\n      const target = node.querySelector<HTMLElement>(\"[data-autofocus]\") ?? node.querySelector<HTMLElement>(focusable) ?? node;\n      target.focus({ preventScroll: true });\n    }\n    const onKey = (e: KeyboardEvent) => {\n      if (!node) return;\n      if (embedded && !node.contains(document.activeElement)) return;\n      if (e.key === \"Escape\") {\n        e.preventDefault();\n        closeRef.current();\n        return;\n      }\n      if (e.key !== \"Tab\") return;\n      const items = Array.from(node.querySelectorAll<HTMLElement>(focusable)).filter((el) => el.getClientRects().length > 0);\n      if (!items.length) {\n        e.preventDefault();\n        node.focus();\n        return;\n      }\n      const first = items[0];\n      const last = items[items.length - 1];\n      const active = document.activeElement;\n      if (!node.contains(active)) {\n        e.preventDefault();\n        first.focus();\n      } else if (e.shiftKey && (active === first || active === node)) {\n        e.preventDefault();\n        last.focus();\n      } else if (!e.shiftKey && active === last) {\n        e.preventDefault();\n        first.focus();\n      }\n    };\n    document.addEventListener(\"keydown\", onKey);\n    return () => {\n      document.removeEventListener(\"keydown\", onKey);\n      if (!embedded) html.style.overflow = overflow;\n      if (steal && previous && previous.isConnected && previous !== document.body) previous.focus({ preventScroll: true });\n    };\n  }, [open, embedded, panel, userOpened]);\n}\n\nexport function ModalSuccessCheck({\n  open,\n  defaultOpen,\n  onOpenChange,\n  embedded = false,\n  trigger,\n  title = \"Payment successful\",\n  message = \"A receipt is on its way to ana@northwind.studio.\",\n  amount = 1284,\n  currency = \"USD\",\n  locale = \"en-US\",\n  details = defaultDetails,\n  doneLabel = \"Done\",\n  receiptLabel = \"View receipt\",\n  onDone,\n  onReceipt,\n  accent = \"#22c55e\",\n  className = \"\",\n  style,\n  ...rest\n}: ModalSuccessCheckProps) {\n  const [inner, setInner] = React.useState(defaultOpen ?? embedded);\n  const isOpen = open ?? inner;\n  const [present, setPresent] = React.useState(isOpen);\n  const [run, setRun] = React.useState(0);\n  const [shown, setShown] = React.useState(amount);\n  const userOpened = React.useRef(false);\n  const panel = React.useRef<HTMLDivElement>(null);\n  const id = React.useId();\n  const money = React.useMemo(() => new Intl.NumberFormat(locale, { style: \"currency\", currency }), [locale, currency]);\n\n  if (isOpen && !present) setPresent(true);\n\n  const setOpen = React.useCallback(\n    (next: boolean) => {\n      if (next) {\n        userOpened.current = true;\n        setRun((r) => r + 1);\n      }\n      if (open === undefined) setInner(next);\n      onOpenChange?.(next);\n    },\n    [open, onOpenChange],\n  );\n  const close = React.useCallback(() => setOpen(false), [setOpen]);\n\n  React.useEffect(() => {\n    if (isOpen || !present) return;\n    const t = setTimeout(() => setPresent(false), 260);\n    return () => clearTimeout(t);\n  }, [isOpen, present]);\n\n  React.useEffect(() => {\n    if (!isOpen) return;\n    const still = window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches;\n    let frame = 0;\n    let start = 0;\n    const tick = (t: number) => {\n      if (!start) start = t;\n      const elapsed = t - start - 520;\n      const p = still ? 1 : Math.min(Math.max(elapsed / 950, 0), 1);\n      const eased = 1 - Math.pow(1 - p, 4);\n      setShown(Math.round(amount * eased * 100) / 100);\n      if (p < 1) frame = requestAnimationFrame(tick);\n    };\n    frame = requestAnimationFrame(tick);\n    return () => cancelAnimationFrame(frame);\n  }, [isOpen, run, amount]);\n\n  useLayer(isOpen, embedded, panel, close, userOpened);\n\n  const vars = { \"--hb-xe12-accent\": accent, ...style } as React.CSSProperties;\n\n  return (\n    <div className={`hb-xe12 ${className}`} data-embedded={embedded || undefined} style={vars} {...rest}>\n      <style href=\"hb-xe12-css\" precedence=\"default\">{css}</style>\n      {trigger !== null && (\n        <button type=\"button\" className=\"hb-xe12-trigger\" aria-haspopup=\"dialog\" aria-expanded={isOpen} onClick={() => setOpen(true)}>\n          <svg viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.8\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\">\n            <rect x=\"4\" y=\"7\" width=\"8\" height=\"6.5\" rx=\"1.5\" />\n            <path d=\"M5.8 7V5.2a2.2 2.2 0 0 1 4.4 0V7\" />\n          </svg>\n          {trigger ?? `Pay ${money.format(amount)}`}\n        </button>\n      )}\n      {present && (\n        <div className=\"hb-xe12-layer\" data-state={isOpen ? \"open\" : \"closed\"}>\n          <div className=\"hb-xe12-scrim\" onClick={close} aria-hidden=\"true\" />\n          <div\n            key={run}\n            ref={panel}\n            role=\"dialog\"\n            aria-modal=\"true\"\n            aria-labelledby={`${id}-t`}\n            aria-describedby={message ? `${id}-d` : undefined}\n            tabIndex={-1}\n            className=\"hb-xe12-panel\"\n          >\n            <div className=\"hb-xe12-mark\" aria-hidden=\"true\">\n              <span className=\"hb-xe12-glow\" />\n              {sparks.map((s, i) => (\n                <span\n                  key={i}\n                  className=\"hb-xe12-spark\"\n                  data-r={s.r ? \"true\" : undefined}\n                  style={{ \"--hb-xe12-a\": `${s.a}deg`, \"--hb-xe12-d\": s.d, \"--hb-xe12-s\": `${s.s}px`, \"--hb-xe12-c\": s.c } as React.CSSProperties}\n                />\n              ))}\n              <svg viewBox=\"0 0 68 68\">\n                <circle className=\"hb-xe12-disc\" cx=\"34\" cy=\"34\" r=\"30\" />\n                <circle className=\"hb-xe12-ring\" cx=\"34\" cy=\"34\" r=\"30\" />\n                <path className=\"hb-xe12-tick\" d=\"m22.5 34.5 7.8 7.8L46 27\" />\n              </svg>\n            </div>\n            <h2 id={`${id}-t`} className=\"hb-xe12-title\">{title}</h2>\n            <p className=\"hb-xe12-amount\" aria-label={money.format(amount)}>{money.format(shown)}</p>\n            {message && <p id={`${id}-d`} className=\"hb-xe12-msg\">{message}</p>}\n            {details.length > 0 && (\n              <dl className=\"hb-xe12-list\">\n                {details.map((d, i) => (\n                  <div key={d.label} className=\"hb-xe12-row\" style={{ \"--hb-xe12-i\": i } as React.CSSProperties}>\n                    <dt>{d.label}</dt>\n                    <dd>{d.value}</dd>\n                  </div>\n                ))}\n              </dl>\n            )}\n            <div className=\"hb-xe12-foot\">\n              <button type=\"button\" className=\"hb-xe12-btn\" onClick={() => onReceipt?.()}>\n                <svg viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.7\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\">\n                  <path d=\"M4 2.5h8v11l-2-1.2-2 1.2-2-1.2-2 1.2ZM6.5 6h3M6.5 8.5h3\" />\n                </svg>\n                {receiptLabel}\n              </button>\n              <button\n                type=\"button\"\n                className=\"hb-xe12-btn\"\n                data-primary=\"\"\n                data-autofocus=\"\"\n                onClick={() => {\n                  onDone?.();\n                  close();\n                }}\n              >\n                {doneLabel}\n              </button>\n            </div>\n          </div>\n        </div>\n      )}\n    </div>\n  );\n}\n"
    }
  ]
}