{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "checkout-subscription-upgrade",
  "type": "registry:component",
  "title": "Checkout Subscription Upgrade",
  "description": "A light plan upgrade screen comparing the current plan with the new one. A seat slider drives a proration breakdown whose figures count to their new values, next to the card on file and a confirm button.",
  "author": "Hyperblur <hello@hyperblur.dev>",
  "dependencies": [],
  "registryDependencies": [],
  "categories": [
    "checkout",
    "checkout",
    "upgrade",
    "proration",
    "seats",
    "subscription",
    "section"
  ],
  "docs": "https://hyperblur.dev/effects/checkout-subscription-upgrade",
  "files": [
    {
      "path": "registry/hyperblur/checkout-subscription-upgrade.tsx",
      "type": "registry:component",
      "target": "components/hyperblur/checkout-subscription-upgrade.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nexport interface UpgradePlan {\n  name: string;\n  price: number;\n  features: string[];\n}\n\nexport interface UpgradeValues {\n  plan: string;\n  seats: number;\n  dueToday: number;\n  nextInvoice: number;\n}\n\nexport interface CheckoutSubscriptionUpgradeProps extends Omit<React.HTMLAttributes<HTMLElement>, \"title\"> {\n  eyebrow?: string;\n  title?: string;\n  subtitle?: string;\n  currentPlan?: UpgradePlan;\n  newPlan?: UpgradePlan;\n  currentSeats?: number;\n  defaultSeats?: number;\n  maxSeats?: number;\n  daysRemaining?: number;\n  cycleDays?: number;\n  renewalDate?: string;\n  cardLabel?: string;\n  currency?: string;\n  onSeatsChange?: (seats: number) => void;\n  onChangeCard?: () => void;\n  onConfirm?: (values: UpgradeValues) => void;\n  accent?: string;\n}\n\nconst defaultCurrent: UpgradePlan = {\n  name: \"Starter\",\n  price: 10,\n  features: [\"5 projects\", \"Basic reports\", \"Email support\", \"7-day history\"],\n};\n\nconst defaultNew: UpgradePlan = {\n  name: \"Business\",\n  price: 22,\n  features: [\"Unlimited projects\", \"Custom reports and exports\", \"SAML single sign-on\", \"Priority support, 4 h\", \"Unlimited history\"],\n};\n\nfunction useTween(target: number) {\n  const [value, setValue] = React.useState(target);\n  const from = React.useRef(target);\n  React.useEffect(() => {\n    const start = from.current;\n    if (start === target) return;\n    const reduce = window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches;\n    let raf = 0;\n    let t0 = 0;\n    const step = (t: number) => {\n      if (!t0) t0 = t;\n      const p = reduce ? 1 : Math.min(1, (t - t0) / 450);\n      const v = start + (target - start) * (1 - Math.pow(1 - p, 3));\n      from.current = v;\n      setValue(v);\n      if (p < 1) raf = requestAnimationFrame(step);\n    };\n    raf = requestAnimationFrame(step);\n    return () => cancelAnimationFrame(raf);\n  }, [target]);\n  return value;\n}\n\nfunction Num({ value, format }: { value: number; format: (n: number) => string }) {\n  const v = useTween(value);\n  return <>{format(v)}</>;\n}\n\nconst css = `\n.hb-qg5 {\n  --hb-qg5-accent: #2f7bff;\n  container-type: inline-size;\n  position: relative;\n  box-sizing: border-box;\n  width: 100%;\n  overflow: hidden;\n  background: #f7f5ef;\n  color: #121622;\n  font-family: inherit;\n  -webkit-font-smoothing: antialiased;\n}\n.hb-qg5 *, .hb-qg5 *::before, .hb-qg5 *::after { box-sizing: border-box; }\n.hb-qg5-inner { max-width: 1120px; margin: 0 auto; padding: clamp(44px, 7cqw, 104px) clamp(16px, 4cqw, 32px); }\n.hb-qg5-eyebrow { display: inline-flex; align-items: center; gap: 8px; margin: 0; font-size: 12px; font-weight: 600; color: var(--hb-qg5-accent); background: color-mix(in srgb, var(--hb-qg5-accent) 10%, #fff); border: 1px solid color-mix(in srgb, var(--hb-qg5-accent) 25%, transparent); padding: 4px 10px; border-radius: 999px; }\n.hb-qg5-title { margin: 14px 0 0; font-size: clamp(28px, 4.4cqw, 44px); letter-spacing: -0.035em; line-height: 1.05; font-weight: 600; }\n.hb-qg5-sub { margin: 12px 0 0; color: #5b5f6b; font-size: 15px; line-height: 1.6; max-width: 560px; }\n.hb-qg5-grid { display: grid; gap: 20px; margin-top: 36px; align-items: start; }\n@container (min-width: 860px) { .hb-qg5-grid { grid-template-columns: minmax(0, 1fr) 380px; gap: 28px; } }\n.hb-qg5-plans { display: grid; gap: 12px; align-items: stretch; }\n@container (min-width: 560px) { .hb-qg5-plans { grid-template-columns: 1fr 36px 1fr; } }\n.hb-qg5-plan { border-radius: 18px; background: #fff; border: 1px solid rgba(18,22,34,.08); padding: 20px; box-shadow: 0 1px 2px rgba(18,22,34,.04); }\n.hb-qg5-plan[data-new=\"true\"] { border-color: var(--hb-qg5-accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--hb-qg5-accent) 12%, transparent), 0 20px 40px -24px color-mix(in srgb, var(--hb-qg5-accent) 60%, transparent); position: relative; }\n.hb-qg5-tag { font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: #8a8e99; }\n.hb-qg5-plan[data-new=\"true\"] .hb-qg5-tag { color: var(--hb-qg5-accent); }\n.hb-qg5-pname { margin: 6px 0 0; font-size: 20px; font-weight: 600; letter-spacing: -0.02em; }\n.hb-qg5-pprice { margin: 4px 0 14px; font-size: 13px; color: #5b5f6b; }\n.hb-qg5-pprice b { font-size: 26px; color: #121622; letter-spacing: -0.03em; font-weight: 600; }\n.hb-qg5-feat { list-style: none; margin: 0; padding: 14px 0 0; border-top: 1px dashed rgba(18,22,34,.12); display: grid; gap: 8px; font-size: 13px; color: #3a3f4b; }\n.hb-qg5-feat li { display: flex; gap: 8px; align-items: flex-start; }\n.hb-qg5-feat svg { width: 14px; height: 14px; flex: none; margin-top: 2px; color: #a3a7b1; }\n.hb-qg5-plan[data-new=\"true\"] .hb-qg5-feat svg { color: var(--hb-qg5-accent); }\n.hb-qg5-arrow { display: none; place-items: center; }\n@container (min-width: 560px) { .hb-qg5-arrow { display: grid; } }\n.hb-qg5-arrow span { width: 34px; height: 34px; border-radius: 50%; background: #121622; color: #fff; display: grid; place-items: center; animation: hb-qg5-nudge 2.2s ease-in-out infinite; }\n@keyframes hb-qg5-nudge { 50% { transform: translateX(3px); } }\n.hb-qg5-arrow svg { width: 14px; height: 14px; }\n.hb-qg5-seats { margin-top: 12px; border-radius: 18px; background: #fff; border: 1px solid rgba(18,22,34,.08); padding: 20px; }\n.hb-qg5-seathead { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; }\n.hb-qg5-seathead label { font-size: 14px; font-weight: 600; }\n.hb-qg5-seathead output { font-size: 13px; color: #5b5f6b; }\n.hb-qg5-seathead output b { font-size: 22px; color: #121622; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }\n.hb-qg5-range { -webkit-appearance: none; appearance: none; width: 100%; height: 28px; margin: 14px 0 6px; background: transparent; cursor: pointer; }\n.hb-qg5-range::-webkit-slider-runnable-track { height: 6px; border-radius: 3px; background: linear-gradient(90deg, var(--hb-qg5-accent) var(--hb-qg5-fill), rgba(18,22,34,.1) var(--hb-qg5-fill)); }\n.hb-qg5-range::-moz-range-track { height: 6px; border-radius: 3px; background: linear-gradient(90deg, var(--hb-qg5-accent) var(--hb-qg5-fill), rgba(18,22,34,.1) var(--hb-qg5-fill)); }\n.hb-qg5-range::-webkit-slider-thumb { -webkit-appearance: none; width: 22px; height: 22px; margin-top: -8px; border-radius: 50%; background: #fff; border: 2px solid var(--hb-qg5-accent); box-shadow: 0 2px 8px rgba(18,22,34,.2); transition: transform .15s; }\n.hb-qg5-range::-moz-range-thumb { width: 18px; height: 18px; border-radius: 50%; background: #fff; border: 2px solid var(--hb-qg5-accent); box-shadow: 0 2px 8px rgba(18,22,34,.2); }\n.hb-qg5-range:active::-webkit-slider-thumb { transform: scale(1.15); }\n.hb-qg5-range:focus-visible { outline: none; }\n.hb-qg5-range:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 5px color-mix(in srgb, var(--hb-qg5-accent) 25%, transparent); }\n.hb-qg5-range:focus-visible::-moz-range-thumb { box-shadow: 0 0 0 5px color-mix(in srgb, var(--hb-qg5-accent) 25%, transparent); }\n.hb-qg5-ticks { display: flex; justify-content: space-between; font-size: 11px; color: #8a8e99; font-variant-numeric: tabular-nums; }\n.hb-qg5-hint { margin: 12px 0 0; font-size: 12px; color: #5b5f6b; }\n.hb-qg5-sum { border-radius: 20px; background: #121622; color: #eef0f5; padding: 22px; box-shadow: 0 30px 60px -30px rgba(18,22,34,.6); position: relative; overflow: hidden; }\n.hb-qg5-sum::before { content: \"\"; position: absolute; right: -40%; top: -50%; width: 100%; height: 100%; background: radial-gradient(closest-side, color-mix(in srgb, var(--hb-qg5-accent) 45%, transparent), transparent); pointer-events: none; }\n.hb-qg5-sum h3 { margin: 0 0 16px; font-size: 15px; font-weight: 600; position: relative; }\n.hb-qg5-lines { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; position: relative; }\n.hb-qg5-lines li { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; color: #b7bcc9; font-variant-numeric: tabular-nums; }\n.hb-qg5-lines li small { display: block; font-size: 11px; color: #7d8394; margin-top: 2px; }\n.hb-qg5-lines li[data-credit=\"true\"] span:last-child { color: #6ee7b7; }\n.hb-qg5-due { display: flex; justify-content: space-between; align-items: baseline; margin-top: 16px; padding-top: 16px; border-top: 1px solid rgba(255,255,255,.1); position: relative; }\n.hb-qg5-due span { font-size: 13px; color: #b7bcc9; }\n.hb-qg5-due b { font-size: 32px; letter-spacing: -0.03em; font-weight: 600; font-variant-numeric: tabular-nums; }\n.hb-qg5-next { margin: 6px 0 0; font-size: 12px; color: #7d8394; position: relative; }\n.hb-qg5-card { margin-top: 18px; display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 12px; background: rgba(255,255,255,.05); border: 1px solid rgba(255,255,255,.08); position: relative; }\n.hb-qg5-chip { width: 38px; height: 26px; border-radius: 5px; background: linear-gradient(135deg, #e8eaf0, #9aa1b2); position: relative; flex: none; }\n.hb-qg5-chip::after { content: \"\"; position: absolute; left: 6px; top: 8px; width: 10px; height: 8px; border-radius: 2px; background: #c9a227; }\n.hb-qg5-card div { flex: 1; min-width: 0; font-size: 13px; }\n.hb-qg5-card small { display: block; font-size: 11px; color: #7d8394; }\n.hb-qg5-change { background: none; border: 0; color: #9ec2ff; font: inherit; font-size: 12px; cursor: pointer; padding: 4px; border-radius: 4px; }\n.hb-qg5-btn { margin-top: 16px; width: 100%; height: 50px; border: 0; border-radius: 12px; background: var(--hb-qg5-accent); color: #fff; font: inherit; font-size: 15px; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 10px; position: relative; box-shadow: inset 0 1px 0 rgba(255,255,255,.25), 0 10px 28px -10px var(--hb-qg5-accent); transition: filter .2s, transform .15s; }\n.hb-qg5-btn:hover { filter: brightness(1.08); }\n.hb-qg5-btn:active { transform: translateY(1px); }\n.hb-qg5-btn[disabled] { cursor: default; opacity: .85; }\n.hb-qg5-btn:focus-visible, .hb-qg5-change:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }\n.hb-qg5-spin { width: 16px; height: 16px; border-radius: 50%; border: 2px solid rgba(255,255,255,.35); border-top-color: #fff; animation: hb-qg5-rot .8s linear infinite; }\n@keyframes hb-qg5-rot { to { transform: rotate(360deg); } }\n.hb-qg5-fine { margin: 12px 0 0; font-size: 11px; color: #7d8394; text-align: center; position: relative; }\n.hb-qg5-okbar { margin-top: 16px; display: flex; gap: 10px; align-items: center; padding: 12px; border-radius: 12px; background: rgba(110,231,183,.12); border: 1px solid rgba(110,231,183,.3); color: #a7f3d0; font-size: 13px; position: relative; animation: hb-qg5-in .4s ease; }\n@keyframes hb-qg5-in { from { opacity: 0; transform: translateY(6px); } }\n.hb-qg5-okbar svg { width: 18px; height: 18px; flex: none; }\n@media (prefers-reduced-motion: reduce) {\n  .hb-qg5 *, .hb-qg5 *::before, .hb-qg5 *::after { animation: none !important; transition: none !important; }\n}\n`;\n\nfunction Check() {\n  return <svg viewBox=\"0 0 14 14\" fill=\"none\" aria-hidden=\"true\"><path d=\"M3 7.3l2.6 2.6L11 4.5\" stroke=\"currentColor\" strokeWidth=\"1.8\" strokeLinecap=\"round\" strokeLinejoin=\"round\" /></svg>;\n}\n\nexport function CheckoutSubscriptionUpgrade({\n  eyebrow = \"Upgrade\",\n  title = \"Move Halcyon Labs to Business\",\n  subtitle = \"You keep everything you have today. We credit the unused part of your Starter plan and only charge the difference for the rest of this cycle.\",\n  currentPlan = defaultCurrent,\n  newPlan = defaultNew,\n  currentSeats = 8,\n  defaultSeats = 12,\n  maxSeats = 50,\n  daysRemaining = 18,\n  cycleDays = 30,\n  renewalDate = \"Dec 1, 2026\",\n  cardLabel = \"Visa ending 4242\",\n  currency = \"USD\",\n  onSeatsChange,\n  onChangeCard,\n  onConfirm,\n  accent = \"#2f7bff\",\n  className = \"\",\n  style,\n  ...rest\n}: CheckoutSubscriptionUpgradeProps) {\n  const uid = React.useId();\n  const money = React.useMemo(() => new Intl.NumberFormat(\"en-US\", { style: \"currency\", currency }), [currency]);\n  const fmt = React.useCallback((n: number) => money.format(n), [money]);\n  const [seats, setSeats] = React.useState(Math.max(1, Math.min(maxSeats, defaultSeats)));\n  const [status, setStatus] = React.useState<\"idle\" | \"processing\" | \"done\">(\"idle\");\n  const timer = React.useRef<ReturnType<typeof setTimeout> | null>(null);\n\n  React.useEffect(() => () => {\n    if (timer.current) clearTimeout(timer.current);\n  }, []);\n\n  const ratio = daysRemaining / cycleDays;\n  const credit = Math.round(currentPlan.price * currentSeats * ratio * 100) / 100;\n  const charge = Math.round(newPlan.price * seats * ratio * 100) / 100;\n  const due = Math.max(0, Math.round((charge - credit) * 100) / 100);\n  const nextInvoice = newPlan.price * seats;\n  const fill = `${(((seats - 1) / Math.max(1, maxSeats - 1)) * 100).toFixed(2)}%`;\n\n  const confirm = () => {\n    if (status !== \"idle\") return;\n    setStatus(\"processing\");\n    timer.current = setTimeout(() => {\n      setStatus(\"done\");\n      onConfirm?.({ plan: newPlan.name, seats, dueToday: due, nextInvoice });\n    }, 1000);\n  };\n\n  const vars = { \"--hb-qg5-accent\": accent, ...style } as React.CSSProperties;\n\n  return (\n    <section className={`hb-qg5 ${className}`} style={vars} {...rest}>\n      <style href=\"hb-checkout-subscription-upgrade\" precedence=\"default\">{css}</style>\n      <div className=\"hb-qg5-inner\">\n        {eyebrow ? <p className=\"hb-qg5-eyebrow\">{eyebrow}</p> : null}\n        <h2 className=\"hb-qg5-title\">{title}</h2>\n        {subtitle ? <p className=\"hb-qg5-sub\">{subtitle}</p> : null}\n        <div className=\"hb-qg5-grid\">\n          <div>\n            <div className=\"hb-qg5-plans\">\n              <div className=\"hb-qg5-plan\">\n                <span className=\"hb-qg5-tag\">Current plan</span>\n                <h3 className=\"hb-qg5-pname\">{currentPlan.name}</h3>\n                <p className=\"hb-qg5-pprice\"><b>{fmt(currentPlan.price)}</b> per seat / month, {currentSeats} seats</p>\n                <ul className=\"hb-qg5-feat\">\n                  {currentPlan.features.map((f) => <li key={f}><Check />{f}</li>)}\n                </ul>\n              </div>\n              <div className=\"hb-qg5-arrow\" aria-hidden=\"true\">\n                <span><svg viewBox=\"0 0 14 14\" fill=\"none\"><path d=\"M3 7h8M7.5 3.5L11 7l-3.5 3.5\" stroke=\"currentColor\" strokeWidth=\"1.8\" strokeLinecap=\"round\" strokeLinejoin=\"round\" /></svg></span>\n              </div>\n              <div className=\"hb-qg5-plan\" data-new=\"true\">\n                <span className=\"hb-qg5-tag\">New plan</span>\n                <h3 className=\"hb-qg5-pname\">{newPlan.name}</h3>\n                <p className=\"hb-qg5-pprice\"><b>{fmt(newPlan.price)}</b> per seat / month</p>\n                <ul className=\"hb-qg5-feat\">\n                  {newPlan.features.map((f) => <li key={f}><Check />{f}</li>)}\n                </ul>\n              </div>\n            </div>\n            <div className=\"hb-qg5-seats\">\n              <div className=\"hb-qg5-seathead\">\n                <label htmlFor={`${uid}-seats`}>Seats on {newPlan.name}</label>\n                <output htmlFor={`${uid}-seats`}><b>{seats}</b> seats, {fmt(nextInvoice)} / month</output>\n              </div>\n              <input\n                id={`${uid}-seats`}\n                className=\"hb-qg5-range\"\n                type=\"range\"\n                min={1}\n                max={maxSeats}\n                value={seats}\n                disabled={status !== \"idle\"}\n                style={{ \"--hb-qg5-fill\": fill } as React.CSSProperties}\n                onChange={(e) => {\n                  const n = Number(e.target.value);\n                  setSeats(n);\n                  onSeatsChange?.(n);\n                }}\n              />\n              <div className=\"hb-qg5-ticks\" aria-hidden=\"true\"><span>1</span><span>{Math.round(maxSeats / 2)}</span><span>{maxSeats}</span></div>\n              <p className=\"hb-qg5-hint\">\n                {seats > currentSeats\n                  ? `${seats - currentSeats} new seats. Invite links go out after you confirm.`\n                  : seats < currentSeats\n                    ? `${currentSeats - seats} members will move to view-only access.`\n                    : \"Same seat count as today.\"}\n              </p>\n            </div>\n          </div>\n          <aside className=\"hb-qg5-sum\" aria-label=\"Payment summary\">\n            <h3>Proration</h3>\n            <ul className=\"hb-qg5-lines\">\n              <li>\n                <span>{newPlan.name}, {seats} seats<small>{daysRemaining} of {cycleDays} days left in cycle</small></span>\n                <span><Num value={charge} format={fmt} /></span>\n              </li>\n              <li data-credit=\"true\">\n                <span>Unused {currentPlan.name}<small>{currentSeats} seats, credited</small></span>\n                <span>-{fmt(credit)}</span>\n              </li>\n            </ul>\n            <div className=\"hb-qg5-due\">\n              <span>Due today</span>\n              <b aria-live=\"polite\"><Num value={due} format={fmt} /></b>\n            </div>\n            <p className=\"hb-qg5-next\">Then <Num value={nextInvoice} format={fmt} /> every month from {renewalDate}.</p>\n            <div className=\"hb-qg5-card\">\n              <span className=\"hb-qg5-chip\" aria-hidden=\"true\" />\n              <div>{cardLabel}<small>Card on file, expires 08 / 28</small></div>\n              <button type=\"button\" className=\"hb-qg5-change\" onClick={() => onChangeCard?.()}>Change</button>\n            </div>\n            {status === \"done\" ? (\n              <div className=\"hb-qg5-okbar\" role=\"status\">\n                <svg viewBox=\"0 0 18 18\" fill=\"none\" aria-hidden=\"true\"><circle cx=\"9\" cy=\"9\" r=\"8\" stroke=\"currentColor\" strokeWidth=\"1.5\" /><path d=\"M5.5 9.2l2.3 2.3L12.5 6.8\" stroke=\"currentColor\" strokeWidth=\"1.7\" strokeLinecap=\"round\" strokeLinejoin=\"round\" /></svg>\n                You are on {newPlan.name} with {seats} seats. Receipt sent to billing.\n              </div>\n            ) : (\n              <button type=\"button\" className=\"hb-qg5-btn\" onClick={confirm} disabled={status === \"processing\"}>\n                {status === \"processing\" ? <><span className=\"hb-qg5-spin\" aria-hidden=\"true\" />Upgrading</> : `Upgrade and pay ${fmt(due)}`}\n              </button>\n            )}\n            <p className=\"hb-qg5-fine\">Downgrade or cancel any time. Unused time is always credited.</p>\n          </aside>\n        </div>\n      </div>\n    </section>\n  );\n}\n"
    }
  ]
}