{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "pricing-credit-stack",
  "type": "registry:component",
  "title": "Pricing Credit Stack",
  "description": "Credit packs as a radio list next to a stack of coins that grows and drops new coins in as you pick a bigger pack, with bonus credits glowing on top. Below, live counts show what the credits buy.",
  "author": "Hyperblur <hello@hyperblur.dev>",
  "dependencies": [],
  "registryDependencies": [],
  "categories": [
    "pricing",
    "pricing",
    "credits",
    "top up",
    "bonus",
    "packs",
    "one-time"
  ],
  "docs": "https://hyperblur.dev/effects/pricing-credit-stack",
  "files": [
    {
      "path": "registry/hyperblur/pricing-credit-stack.tsx",
      "type": "registry:component",
      "target": "components/hyperblur/pricing-credit-stack.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nexport interface PricingCreditPack {\n  credits: number;\n  price: number;\n  bonus: number;\n  label?: string;\n}\n\nexport interface PricingCreditUse {\n  label: string;\n  cost: number;\n}\n\nexport interface PricingCreditStackProps extends Omit<React.HTMLAttributes<HTMLElement>, \"title\"> {\n  eyebrow?: string;\n  title?: string;\n  subtitle?: string;\n  packs?: PricingCreditPack[];\n  uses?: PricingCreditUse[];\n  currency?: string;\n  locale?: string;\n  selected?: number;\n  defaultSelected?: number;\n  onSelectedChange?: (index: number, pack: PricingCreditPack) => void;\n  onPurchase?: (pack: PricingCreditPack) => void;\n  buyLabel?: string;\n  accent?: string;\n}\n\nconst defaultPacks: PricingCreditPack[] = [\n  { credits: 1000, price: 10, bonus: 0 },\n  { credits: 5000, price: 45, bonus: 0.1 },\n  { credits: 15000, price: 120, bonus: 0.2, label: \"Popular\" },\n  { credits: 50000, price: 350, bonus: 0.3 },\n];\n\nconst defaultUses: PricingCreditUse[] = [\n  { label: \"image generations\", cost: 4 },\n  { label: \"minutes of voiceover\", cost: 25 },\n  { label: \"HD video clips\", cost: 120 },\n];\n\nconst TILES = 22;\n\nconst css = `\n.hb-vh8 {\n  --hb-vh8-accent: #f5a524;\n  container-type: inline-size;\n  position: relative;\n  box-sizing: border-box;\n  width: 100%;\n  background: #0a0a0a;\n  color: #ededed;\n  font-family: inherit;\n  -webkit-font-smoothing: antialiased;\n}\n.hb-vh8 *, .hb-vh8 *::before, .hb-vh8 *::after { box-sizing: border-box; }\n.hb-vh8-inner { max-width: 1040px; margin: 0 auto; padding: 64px 20px; }\n.hb-vh8-head { max-width: 560px; }\n.hb-vh8-eyebrow { display: inline-flex; align-items: center; gap: 8px; margin: 0 0 12px; color: color-mix(in srgb, var(--hb-vh8-accent) 70%, #fff); font-size: 13px; font-weight: 600; }\n.hb-vh8-eyebrow i { width: 14px; height: 14px; border-radius: 999px; background: radial-gradient(circle at 35% 30%, #fff6, transparent 50%), var(--hb-vh8-accent); box-shadow: inset 0 -2px 0 rgba(0, 0, 0, .25); font-style: normal; }\n.hb-vh8-title { margin: 0; font-family: var(--font-grotesk), var(--font-sans), sans-serif; font-size: clamp(28px, 4.4cqi, 44px); font-weight: 600; line-height: 1.06; letter-spacing: -.035em; text-wrap: balance; }\n.hb-vh8-sub { margin: 12px 0 0; color: #8f8f8f; font-size: 15px; line-height: 1.6; }\n.hb-vh8-body { display: grid; grid-template-columns: 1fr; gap: 16px; margin-top: 36px; }\n@container (min-width: 760px) { .hb-vh8-body { grid-template-columns: 260px 1fr; gap: 20px; } }\n.hb-vh8-vault {\n  position: relative;\n  display: flex;\n  flex-direction: column;\n  align-items: center;\n  justify-content: flex-end;\n  min-height: 300px;\n  padding: 24px 20px 20px;\n  border-radius: 22px;\n  border: 1px solid rgba(255, 255, 255, .08);\n  background:\n    radial-gradient(80% 50% at 50% 100%, color-mix(in srgb, var(--hb-vh8-accent) 18%, transparent), transparent 70%),\n    linear-gradient(180deg, #111113, #0c0c0e);\n  overflow: hidden;\n}\n.hb-vh8-stack { display: flex; flex-direction: column-reverse; align-items: center; gap: 3px; width: 120px; }\n.hb-vh8-coin {\n  width: 100%;\n  height: 8px;\n  border-radius: 999px;\n  background: linear-gradient(90deg, #3a3a40, #6b6b74 30%, #4a4a52 70%, #2e2e33);\n  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .25), 0 1px 0 rgba(0, 0, 0, .6);\n  animation: hb-vh8-drop .5s cubic-bezier(.3, 1.4, .5, 1) both;\n  animation-delay: calc(var(--i) * 22ms);\n}\n.hb-vh8-coin:nth-child(odd) { transform: translateX(2px); }\n.hb-vh8-coin[data-bonus=\"true\"] {\n  background: linear-gradient(90deg, color-mix(in srgb, var(--hb-vh8-accent) 55%, #000), var(--hb-vh8-accent) 30%, color-mix(in srgb, var(--hb-vh8-accent) 70%, #fff) 50%, color-mix(in srgb, var(--hb-vh8-accent) 60%, #000));\n  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .5), 0 0 12px -2px var(--hb-vh8-accent);\n}\n@keyframes hb-vh8-drop { from { opacity: 0; translate: 0 -60px; } to { opacity: 1; translate: 0 0; } }\n.hb-vh8-total { margin-top: 18px; text-align: center; }\n.hb-vh8-total strong { display: block; font-family: var(--font-grotesk), var(--font-sans), sans-serif; font-size: 32px; font-weight: 600; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }\n.hb-vh8-total span { color: #8f8f8f; font-size: 12.5px; }\n.hb-vh8-total b { color: color-mix(in srgb, var(--hb-vh8-accent) 70%, #fff); font-weight: 600; }\n.hb-vh8-side { display: flex; flex-direction: column; gap: 14px; }\n.hb-vh8-packs { display: grid; gap: 8px; }\n.hb-vh8-pack {\n  position: relative;\n  display: grid;\n  grid-template-columns: 22px 1fr auto;\n  align-items: center;\n  gap: 14px;\n  width: 100%;\n  padding: 14px 16px;\n  border-radius: 14px;\n  border: 1px solid rgba(255, 255, 255, .08);\n  background: #111113;\n  color: inherit;\n  font: inherit;\n  text-align: left;\n  cursor: pointer;\n  transition: border-color .25s ease, background-color .25s ease, transform .2s ease;\n}\n.hb-vh8-pack:hover { border-color: rgba(255, 255, 255, .16); background: #141416; }\n.hb-vh8-pack:active { transform: scale(.995); }\n.hb-vh8-pack:focus-visible { outline: 2px solid var(--hb-vh8-accent); outline-offset: 2px; }\n.hb-vh8-pack[aria-checked=\"true\"] { border-color: color-mix(in srgb, var(--hb-vh8-accent) 60%, transparent); background: color-mix(in srgb, var(--hb-vh8-accent) 7%, #111113); }\n.hb-vh8-radio { width: 18px; height: 18px; border-radius: 999px; border: 1.5px solid #4a4a52; display: grid; place-items: center; transition: border-color .2s ease; }\n.hb-vh8-radio::after { content: \"\"; width: 8px; height: 8px; border-radius: 999px; background: var(--hb-vh8-accent); transform: scale(0); transition: transform .3s cubic-bezier(.34, 1.56, .64, 1); }\n.hb-vh8-pack[aria-checked=\"true\"] .hb-vh8-radio { border-color: var(--hb-vh8-accent); }\n.hb-vh8-pack[aria-checked=\"true\"] .hb-vh8-radio::after { transform: scale(1); }\n.hb-vh8-pmain { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; min-width: 0; }\n.hb-vh8-pmain strong { font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; }\n.hb-vh8-bonus { height: 22px; padding: 0 8px; border-radius: 6px; background: color-mix(in srgb, var(--hb-vh8-accent) 16%, transparent); color: color-mix(in srgb, var(--hb-vh8-accent) 60%, #fff); font-size: 11.5px; font-weight: 600; line-height: 22px; font-variant-numeric: tabular-nums; }\n.hb-vh8-label { height: 22px; padding: 0 8px; border-radius: 6px; background: #ededed; color: #0a0a0a; font-size: 11px; font-weight: 700; line-height: 22px; text-transform: uppercase; letter-spacing: .04em; }\n.hb-vh8-unit { width: 100%; color: #6f6f6f; font-size: 12px; font-variant-numeric: tabular-nums; }\n.hb-vh8-pprice { font-size: 17px; font-weight: 650; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }\n.hb-vh8-uses { display: grid; grid-template-columns: repeat(var(--n), 1fr); gap: 8px; }\n.hb-vh8-use { padding: 12px 14px; border-radius: 12px; background: #0f0f11; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .06); }\n.hb-vh8-use strong { display: block; font-size: 18px; font-weight: 650; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }\n.hb-vh8-use strong span { display: inline-block; animation: hb-vh8-up .45s cubic-bezier(.2, .9, .3, 1.2); }\n@keyframes hb-vh8-up { from { opacity: 0; transform: translateY(50%); } to { opacity: 1; transform: none; } }\n.hb-vh8-use small { color: #8f8f8f; font-size: 12px; }\n.hb-vh8-buy {\n  display: inline-flex;\n  align-items: center;\n  justify-content: center;\n  gap: 10px;\n  height: 48px;\n  border: 0;\n  border-radius: 14px;\n  background: linear-gradient(180deg, color-mix(in srgb, var(--hb-vh8-accent) 80%, #fff), var(--hb-vh8-accent));\n  color: #1a1206;\n  font: inherit;\n  font-size: 15px;\n  font-weight: 650;\n  cursor: pointer;\n  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .45), 0 14px 30px -14px var(--hb-vh8-accent);\n  transition: filter .2s ease, transform .15s ease;\n}\n.hb-vh8-buy:hover { filter: brightness(1.06); }\n.hb-vh8-buy:active { transform: scale(.985); }\n.hb-vh8-buy:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }\n.hb-vh8-note { margin: 0; color: #6f6f6f; font-size: 12px; text-align: center; }\n@media (prefers-reduced-motion: reduce) {\n  .hb-vh8 *, .hb-vh8 *::before, .hb-vh8 *::after { animation: none !important; transition: none !important; }\n}\n`;\n\nexport function PricingCreditStack({\n  eyebrow = \"Credits\",\n  title = \"Top up once, create all month\",\n  subtitle = \"Credits never expire and work across every tool. Bigger packs come with bonus credits on top.\",\n  packs = defaultPacks,\n  uses = defaultUses,\n  currency = \"USD\",\n  locale = \"en-US\",\n  selected,\n  defaultSelected = 2,\n  onSelectedChange,\n  onPurchase,\n  buyLabel = \"Buy\",\n  accent = \"#f5a524\",\n  className = \"\",\n  style,\n  ...rest\n}: PricingCreditStackProps) {\n  const [inner, setInner] = React.useState(defaultSelected);\n  const current = Math.max(0, Math.min(packs.length - 1, selected ?? inner));\n  const pack = packs[current];\n  const refs = React.useRef<(HTMLButtonElement | null)[]>([]);\n\n  const money = React.useMemo(\n    () => new Intl.NumberFormat(locale, { style: \"currency\", currency, minimumFractionDigits: 0, maximumFractionDigits: 2 }),\n    [locale, currency],\n  );\n  const unitMoney = React.useMemo(\n    () => new Intl.NumberFormat(locale, { style: \"currency\", currency, minimumFractionDigits: 2, maximumFractionDigits: 2 }),\n    [locale, currency],\n  );\n  const num = React.useMemo(() => new Intl.NumberFormat(locale), [locale]);\n\n  const choose = (i: number) => {\n    if (selected === undefined) setInner(i);\n    onSelectedChange?.(i, packs[i]);\n  };\n\n  if (!pack) return null;\n  const bonusCredits = Math.round(pack.credits * pack.bonus);\n  const totalCredits = pack.credits + bonusCredits;\n  const maxTotal = Math.max(...packs.map((p) => p.credits * (1 + p.bonus)));\n  const tiles = Math.max(2, Math.round((totalCredits / maxTotal) * TILES));\n  const bonusTiles = pack.bonus > 0 ? Math.max(1, Math.round(tiles * (pack.bonus / (1 + pack.bonus)))) : 0;\n\n  return (\n    <section className={`hb-vh8 ${className}`} style={{ \"--hb-vh8-accent\": accent, ...style } as React.CSSProperties} {...rest}>\n      <style href=\"hb-pricing-credit-stack\" precedence=\"default\">{css}</style>\n      <div className=\"hb-vh8-inner\">\n        <div className=\"hb-vh8-head\">\n          {eyebrow ? <p className=\"hb-vh8-eyebrow\"><i aria-hidden=\"true\" />{eyebrow}</p> : null}\n          <h2 className=\"hb-vh8-title\">{title}</h2>\n          {subtitle ? <p className=\"hb-vh8-sub\">{subtitle}</p> : null}\n        </div>\n        <div className=\"hb-vh8-body\">\n          <div className=\"hb-vh8-vault\" aria-hidden=\"true\">\n            <div className=\"hb-vh8-stack\">\n              {Array.from({ length: tiles }, (_, i) => (\n                <span\n                  key={i}\n                  className=\"hb-vh8-coin\"\n                  data-bonus={i >= tiles - bonusTiles ? \"true\" : undefined}\n                  style={{ \"--i\": Math.max(0, i - 2) } as React.CSSProperties}\n                />\n              ))}\n            </div>\n            <div className=\"hb-vh8-total\">\n              <strong>{num.format(totalCredits)}</strong>\n              <span>credits{bonusCredits > 0 ? <> incl. <b>+{num.format(bonusCredits)} bonus</b></> : null}</span>\n            </div>\n          </div>\n          <div className=\"hb-vh8-side\">\n            <div className=\"hb-vh8-packs\" role=\"radiogroup\" aria-label=\"Credit packs\">\n              {packs.map((p, i) => (\n                <button\n                  key={p.credits}\n                  ref={(el) => { refs.current[i] = el; }}\n                  type=\"button\"\n                  role=\"radio\"\n                  aria-checked={i === current}\n                  tabIndex={i === current ? 0 : -1}\n                  className=\"hb-vh8-pack\"\n                  onClick={() => choose(i)}\n                  onKeyDown={(e) => {\n                    const d = e.key === \"ArrowDown\" || e.key === \"ArrowRight\" ? 1 : e.key === \"ArrowUp\" || e.key === \"ArrowLeft\" ? -1 : 0;\n                    if (!d) return;\n                    e.preventDefault();\n                    const n = (i + d + packs.length) % packs.length;\n                    choose(n);\n                    refs.current[n]?.focus();\n                  }}\n                >\n                  <span className=\"hb-vh8-radio\" aria-hidden=\"true\" />\n                  <span className=\"hb-vh8-pmain\">\n                    <strong>{num.format(p.credits)} credits</strong>\n                    {p.bonus > 0 ? <span className=\"hb-vh8-bonus\">+{Math.round(p.bonus * 100)}% bonus</span> : null}\n                    {p.label ? <span className=\"hb-vh8-label\">{p.label}</span> : null}\n                    <span className=\"hb-vh8-unit\">{unitMoney.format((p.price / (p.credits * (1 + p.bonus))) * 100)} per 100 credits</span>\n                  </span>\n                  <span className=\"hb-vh8-pprice\">{money.format(p.price)}</span>\n                </button>\n              ))}\n            </div>\n            {uses.length ? (\n              <div className=\"hb-vh8-uses\" style={{ \"--n\": uses.length } as React.CSSProperties} aria-live=\"polite\">\n                {uses.map((u) => {\n                  const count = Math.floor(totalCredits / u.cost);\n                  return (\n                    <div key={u.label} className=\"hb-vh8-use\">\n                      <strong><span key={count}>~{num.format(count)}</span></strong>\n                      <small>{u.label}</small>\n                    </div>\n                  );\n                })}\n              </div>\n            ) : null}\n            <button type=\"button\" className=\"hb-vh8-buy\" onClick={() => onPurchase?.(pack)}>\n              {buyLabel} {num.format(totalCredits)} credits for {money.format(pack.price)}\n            </button>\n            <p className=\"hb-vh8-note\">One-time payment. Unused credits roll over forever.</p>\n          </div>\n        </div>\n      </div>\n    </section>\n  );\n}\n"
    }
  ]
}