{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "accordion-checkout",
  "title": "Accordion Checkout",
  "description": "A one-page checkout made of four accordion sections (contact, shipping address, delivery, payment) that open in turn, check their fields and fold into a one-line summary with edit, a segmented progress bar, a pay button that unlocks when everything is filled, and a sticky order summary with discount codes and tax.",
  "dependencies": [
    "motion",
    "clsx",
    "tailwind-merge"
  ],
  "files": [
    {
      "path": "registry/new-york/accordion-checkout/accordion-checkout.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\nimport { AnimatePresence, motion, useReducedMotion } from \"motion/react\";\nimport { clsx, type ClassValue } from \"clsx\";\nimport { twMerge } from \"tailwind-merge\";\n\nfunction cn(...inputs: ClassValue[]) {\n  return twMerge(clsx(inputs));\n}\n\nexport interface AccordionLine {\n  name: string;\n  variant?: string;\n  price: number;\n  qty: number;\n  image: string;\n}\ntype SectionId = \"contact\" | \"address\" | \"delivery\" | \"payment\";\nexport interface AccordionCheckoutResult {\n  email: string;\n  marketing: boolean;\n  address: { name: string; line1: string; city: string; zip: string };\n  delivery: string;\n  /** Only the brand and last four digits leave the form. */\n  card: { brand: string | null; last4: string };\n  code: string | null;\n  total: number;\n}\n\nexport interface AccordionCheckoutProps {\n  lines?: AccordionLine[];\n  currency?: string;\n  taxRate?: number;\n  deliveryOptions?: { id: string; label: string; eta: string; price: number }[];\n  /** Codes that work, with what they take off the subtotal. */\n  codes?: Record<string, { label: string; off: (subtotal: number) => number }>;\n  onPay?: (result: AccordionCheckoutResult) => Promise<void> | void;\n  theme?: \"dark\" | \"light\";\n  className?: string;\n}\n\nconst PALETTES = {\n  dark: {\n    bg: \"#0A0A0A\",\n    card: \"#141414\",\n    open: \"#191919\",\n    side: \"#101010\",\n    title: \"#FFFFFF\",\n    muted: \"rgba(255,255,255,0.45)\",\n    body: \"rgba(255,255,255,0.62)\",\n    line: \"rgba(255,255,255,0.12)\",\n    tile: \"#F1F1F1\",\n    accent: \"#7CDE6A\",\n    accentText: \"#0B1A08\",\n    danger: \"#FF8A7A\",\n    buttonBg: \"#FFFFFF\",\n    buttonText: \"#111111\",\n    ghost: \"rgba(255,255,255,0.07)\",\n    ring: \"rgba(255,255,255,0.55)\",\n    field: \"#0D0D0D\",\n  },\n  light: {\n    bg: \"#FFFFFF\",\n    card: \"#FFFFFF\",\n    open: \"#FAFAFA\",\n    side: \"#F7F7F7\",\n    title: \"#111111\",\n    muted: \"rgba(0,0,0,0.45)\",\n    body: \"rgba(0,0,0,0.62)\",\n    line: \"rgba(0,0,0,0.1)\",\n    tile: \"#F1F1F1\",\n    accent: \"#2F9E44\",\n    accentText: \"#FFFFFF\",\n    danger: \"#C0392B\",\n    buttonBg: \"#111111\",\n    buttonText: \"#FFFFFF\",\n    ghost: \"rgba(0,0,0,0.05)\",\n    ring: \"rgba(0,0,0,0.45)\",\n    field: \"#FFFFFF\",\n  },\n};\n\nconst LINES: AccordionLine[] = [\n  { name: \"Running Shoes\", variant: \"Black · EU 43\", price: 99, qty: 1, image: \"/demo/running-shoes.webp\" },\n  { name: \"Insulated Bottle\", variant: \"750 ml\", price: 39, qty: 1, image: \"/demo/insulated-water-bottle.webp\" },\n  { name: \"Dot Notebook\", variant: \"A5 · Sand\", price: 24, qty: 2, image: \"/demo/notebook.webp\" },\n];\nconst DELIVERY = [\n  { id: \"standard\", label: \"Standard\", eta: \"3–5 business days\", price: 0 },\n  { id: \"express\", label: \"Express\", eta: \"Next business day\", price: 15 },\n];\nconst CODES: AccordionCheckoutProps[\"codes\"] = {\n  SAVE10: { label: \"10% off\", off: (s) => Math.round(s * 0.1 * 100) / 100 },\n  FREESHIP: { label: \"Free express\", off: () => 0 },\n};\nconst SECTIONS: { id: SectionId; title: string }[] = [\n  { id: \"contact\", title: \"Contact\" },\n  { id: \"address\", title: \"Shipping address\" },\n  { id: \"delivery\", title: \"Delivery\" },\n  { id: \"payment\", title: \"Payment\" },\n];\n\nconst money = (n: number, c: string) => `${c}${n.toFixed(2)}`;\nconst brandOf = (d: string) => (/^4/.test(d) ? \"Visa\" : /^(5[1-5]|2[2-7])/.test(d) ? \"Mastercard\" : /^3[47]/.test(d) ? \"Amex\" : null);\nconst luhn = (d: string) => {\n  let s = 0;\n  for (let i = 0; i < d.length; i++) {\n    let n = Number(d[d.length - 1 - i]);\n    if (i % 2) n = n * 2 > 9 ? n * 2 - 9 : n * 2;\n    s += n;\n  }\n  return d.length >= 13 && s % 10 === 0;\n};\n\nexport function AccordionCheckout({ lines = LINES, currency = \"$\", taxRate = 0.08, deliveryOptions = DELIVERY, codes = CODES, onPay, theme = \"dark\", className }: AccordionCheckoutProps) {\n  const p = PALETTES[theme];\n  const reduce = !!useReducedMotion();\n  const uid = React.useId();\n  const [open, setOpen] = React.useState<SectionId>(\"contact\");\n  const [done, setDone] = React.useState<Record<SectionId, boolean>>({ contact: false, address: false, delivery: false, payment: false });\n  const [tried, setTried] = React.useState<Record<SectionId, boolean>>({ contact: false, address: false, delivery: false, payment: false });\n  const [email, setEmail] = React.useState(\"\");\n  const [marketing, setMarketing] = React.useState(false);\n  const [addr, setAddr] = React.useState({ name: \"Maya Chen\", line1: \"418 Alder St\", city: \"Portland\", zip: \"97209\" });\n  const [delivery, setDelivery] = React.useState(deliveryOptions[0].id);\n  const [card, setCard] = React.useState({ number: \"\", exp: \"\", cvc: \"\" });\n  const [code, setCode] = React.useState(\"\");\n  const [applied, setApplied] = React.useState<string | null>(null);\n  const [codeErr, setCodeErr] = React.useState(\"\");\n  const [state, setState] = React.useState<\"form\" | \"busy\" | \"done\" | \"error\">(\"form\");\n  const sectionRefs = React.useRef<Record<string, HTMLButtonElement | null>>({});\n\n  const ship = deliveryOptions.find((d) => d.id === delivery)!;\n  const subtotal = lines.reduce((t, l) => t + l.price * l.qty, 0);\n  const shipping = applied === \"FREESHIP\" ? 0 : ship.price;\n  const off = applied && codes?.[applied] ? codes[applied].off(subtotal) : 0;\n  const tax = Math.round((subtotal - off) * taxRate * 100) / 100;\n  const total = subtotal - off + shipping + tax;\n  const digits = card.number.replace(/\\D/g, \"\");\n  const brand = brandOf(digits);\n  const [mm, yy] = card.exp.split(\"/\").map(Number);\n\n  const errors: Record<SectionId, Record<string, string>> = { contact: {}, address: {}, delivery: {}, payment: {} };\n  if (!/^[^\\s@]+@[^\\s@]+\\.[a-z]{2,}$/i.test(email.trim())) errors.contact.email = \"Enter an email like you@example.com\";\n  if (addr.name.trim().split(/\\s+/).length < 2) errors.address.name = \"First and last name\";\n  if (addr.line1.trim().length < 4) errors.address.line1 = \"Street and number\";\n  if (!addr.city.trim()) errors.address.city = \"Enter a city\";\n  if (!/^\\d{5}(-\\d{4})?$/.test(addr.zip.trim())) errors.address.zip = \"5 digits\";\n  if (!luhn(digits)) errors.payment.number = digits.length < 13 ? \"Enter the full card number\" : \"Check the card number\";\n  if (!mm || mm > 12 || !yy || yy < 26 || (yy === 26 && mm < 11)) errors.payment.exp = card.exp.length < 5 ? \"MM/YY\" : \"Expired\";\n  if (!/^\\d{3,4}$/.test(card.cvc)) errors.payment.cvc = \"3–4 digits\";\n  const ok = (id: SectionId) => Object.keys(errors[id]).length === 0;\n  const finished = SECTIONS.filter((s) => done[s.id]).length;\n\n  const save = (id: SectionId) => {\n    setTried((t) => ({ ...t, [id]: true }));\n    if (!ok(id)) return;\n    const nextDone = { ...done, [id]: true };\n    setDone(nextDone);\n    const next = SECTIONS.find((s) => !nextDone[s.id]);\n    if (next) {\n      setOpen(next.id);\n      setTimeout(() => sectionRefs.current[next.id]?.focus({ preventScroll: true }), 280);\n    }\n  };\n  const pay = async () => {\n    setTried((t) => ({ ...t, payment: true }));\n    if (!SECTIONS.slice(0, 3).every((s) => done[s.id])) return;\n    if (!ok(\"payment\")) {\n      setOpen(\"payment\");\n      return;\n    }\n    setDone((d) => ({ ...d, payment: true }));\n    setState(\"busy\");\n    try {\n      await Promise.all([onPay?.({ email, marketing, address: addr, delivery, card: { brand, last4: digits.slice(-4) }, code: applied, total }), new Promise((r) => setTimeout(r, 1300))]);\n      setState(\"done\");\n    } catch {\n      setState(\"error\");\n    }\n  };\n  const apply = (e: React.FormEvent) => {\n    e.preventDefault();\n    const c = code.trim().toUpperCase();\n    if (!codes?.[c]) return setCodeErr(\"That code isn’t valid.\");\n    setApplied(c);\n    setCode(\"\");\n    setCodeErr(\"\");\n  };\n\n  const summaryOf = (id: SectionId) =>\n    id === \"contact\" ? email : id === \"address\" ? `${addr.name}, ${addr.line1}, ${addr.city} ${addr.zip}` : id === \"delivery\" ? `${ship.label} · ${ship.eta} · ${shipping ? money(shipping, currency) : \"Free\"}` : `${brand ?? \"Card\"} ···· ${digits.slice(-4)}`;\n  const focus = \"outline-none focus-visible:ring-2 focus-visible:ring-offset-2\";\n  const field = cn(\"h-11 w-full rounded-xl border px-3.5 text-[16px] sm:text-[14px]\", focus);\n  const fs = (bad: boolean) => ({ background: p.field, borderColor: bad ? p.danger : p.line, color: p.title });\n  const input = (sec: SectionId, k: string, label: string, value: string, set: (v: string) => void, extra: { type?: string; ac?: string; mode?: \"numeric\" | \"email\"; ph?: string; span?: boolean } = {}) => {\n    const err = tried[sec] ? errors[sec][k] : undefined;\n    return (\n      <div key={k} className={extra.span ? \"sm:col-span-2\" : \"\"}>\n        <label htmlFor={`${uid}-${k}`} className=\"mb-1.5 block text-[12.5px] font-medium\" style={{ color: p.body }}>\n          {label}\n        </label>\n        <input\n          id={`${uid}-${k}`}\n          type={extra.type ?? \"text\"}\n          inputMode={extra.mode}\n          autoComplete={extra.ac}\n          placeholder={extra.ph}\n          value={value}\n          onChange={(e) => set(e.target.value)}\n          aria-invalid={!!err}\n          aria-describedby={err ? `${uid}-${k}-e` : undefined}\n          className={field}\n          style={fs(!!err)}\n        />\n        {err && (\n          <p id={`${uid}-${k}-e`} className=\"m-0 mt-1 text-[12px]\" style={{ color: p.danger }}>\n            {err}\n          </p>\n        )}\n      </div>\n    );\n  };\n\n  return (\n    <section aria-labelledby={`${uid}-h`} className={cn(\"relative w-full px-4 py-10 sm:px-8\", className)} style={{ background: p.bg, color: p.title, \"--tw-ring-color\": p.ring, \"--tw-ring-offset-color\": p.card } as React.CSSProperties}>\n      <div className=\"mx-auto grid max-w-5xl grid-cols-1 gap-5 lg:grid-cols-[minmax(0,1fr)_320px]\">\n        <div className=\"min-w-0\">\n          <div className=\"flex items-end justify-between gap-4\">\n            <h2 id={`${uid}-h`} className=\"m-0 text-[26px] font-semibold tracking-[-0.02em]\">\n              Checkout\n            </h2>\n            <span className=\"text-[13px] tabular-nums\" style={{ color: p.muted }} aria-live=\"polite\">\n              {state === \"done\" ? \"Done\" : `${finished} of ${SECTIONS.length} done`}\n            </span>\n          </div>\n          <div className=\"mt-3 flex gap-1\" aria-hidden=\"true\">\n            {SECTIONS.map((s) => (\n              <span key={s.id} className=\"h-1 flex-1 overflow-hidden rounded-full\" style={{ background: p.line }}>\n                <motion.span className=\"block h-full\" style={{ background: p.accent }} initial={false} animate={{ width: done[s.id] || state === \"done\" ? \"100%\" : open === s.id ? \"35%\" : \"0%\" }} transition={{ duration: reduce ? 0 : 0.35 }} />\n              </span>\n            ))}\n          </div>\n\n          {state === \"done\" ? (\n            <motion.div initial={reduce ? false : { opacity: 0, y: 10 }} animate={{ opacity: 1, y: 0 }} className=\"mt-5 flex flex-col items-center rounded-3xl border px-6 py-14 text-center\" style={{ background: p.card, borderColor: p.line }} role=\"status\">\n              <motion.span\n                initial={reduce ? false : { scale: 0 }}\n                animate={{ scale: 1 }}\n                transition={{ type: \"spring\", stiffness: 320, damping: 16 }}\n                className=\"flex h-14 w-14 items-center justify-center rounded-full text-[24px]\"\n                style={{ background: p.accent, color: p.accentText }}\n              >\n                ✓\n              </motion.span>\n              <p className=\"m-0 mt-4 text-[22px] font-semibold tracking-[-0.02em]\">Thanks, {addr.name.split(\" \")[0]}. Order placed.</p>\n              <p className=\"m-0 mt-1.5 max-w-sm text-[14px]\" style={{ color: p.body }}>\n                {money(total, currency)} on {brand ?? \"your card\"} ···· {digits.slice(-4)}. {ship.label} delivery, {ship.eta.toLowerCase()}. Receipt sent to {email}.\n              </p>\n            </motion.div>\n          ) : (\n            <ol className=\"m-0 mt-5 flex list-none flex-col gap-2.5 p-0\">\n              {SECTIONS.map((s, i) => {\n                const isOpen = open === s.id;\n                const isDone = done[s.id] && !isOpen;\n                return (\n                  <li key={s.id} className=\"overflow-hidden rounded-2xl border transition-colors\" style={{ background: isOpen ? p.open : p.card, borderColor: isOpen ? p.title : p.line }}>\n                    <h3 className=\"m-0\">\n                      <button\n                        ref={(el) => {\n                          sectionRefs.current[s.id] = el;\n                        }}\n                        type=\"button\"\n                        aria-expanded={isOpen}\n                        aria-controls={`${uid}-${s.id}-p`}\n                        onClick={() => setOpen(s.id)}\n                        className={cn(\"flex w-full cursor-pointer items-center gap-3.5 border-0 bg-transparent px-4 py-4 text-left sm:px-5\", focus)}\n                        style={{ color: p.title }}\n                      >\n                        <motion.span\n                          className=\"flex h-7 w-7 shrink-0 items-center justify-center rounded-full border text-[12px] font-semibold\"\n                          initial={false}\n                          animate={{ backgroundColor: done[s.id] ? p.accent : \"rgba(0,0,0,0)\", borderColor: done[s.id] ? p.accent : isOpen ? p.title : p.line, color: done[s.id] ? p.accentText : isOpen ? p.title : p.muted }}\n                        >\n                          {done[s.id] ? \"✓\" : i + 1}\n                        </motion.span>\n                        <span className=\"min-w-0 flex-1\">\n                          <span className=\"block text-[15px] font-semibold\">{s.title}</span>\n                          {isDone && (\n                            <span className=\"block truncate text-[12.5px]\" style={{ color: p.muted }}>\n                              {summaryOf(s.id)}\n                            </span>\n                          )}\n                        </span>\n                        <span className=\"shrink-0 text-[12.5px] underline underline-offset-4\" style={{ color: p.body }}>\n                          {isDone ? \"Edit\" : \"\"}\n                        </span>\n                        <svg\n                          width=\"14\"\n                          height=\"14\"\n                          viewBox=\"0 0 24 24\"\n                          fill=\"none\"\n                          stroke=\"currentColor\"\n                          strokeWidth=\"2\"\n                          strokeLinecap=\"round\"\n                          aria-hidden=\"true\"\n                          className={cn(\"shrink-0 transition-transform\", isOpen && \"rotate-180\")}\n                          style={{ color: p.muted }}\n                        >\n                          <path d=\"m6 9 6 6 6-6\" />\n                        </svg>\n                      </button>\n                    </h3>\n                    <AnimatePresence initial={false}>\n                      {isOpen && (\n                        <motion.div id={`${uid}-${s.id}-p`} initial={reduce ? false : { height: 0, opacity: 0 }} animate={{ height: \"auto\", opacity: 1 }} exit={reduce ? undefined : { height: 0, opacity: 0 }} transition={{ duration: 0.25 }}>\n                          <div className=\"px-4 pb-5 sm:px-5 sm:pl-[62px]\">\n                            {s.id === \"contact\" && (\n                              <div className=\"grid grid-cols-1 gap-3\">\n                                {input(\"contact\", \"email\", \"Email\", email, setEmail, { type: \"email\", ac: \"email\", mode: \"email\", ph: \"you@example.com\" })}\n                                <label className=\"flex cursor-pointer items-center gap-2.5 text-[13px]\" style={{ color: p.body }}>\n                                  <input type=\"checkbox\" checked={marketing} onChange={(e) => setMarketing(e.target.checked)} className=\"h-4 w-4\" style={{ accentColor: p.accent }} />\n                                  Email me about new drops\n                                </label>\n                              </div>\n                            )}\n                            {s.id === \"address\" && (\n                              <div className=\"grid grid-cols-1 gap-3 sm:grid-cols-2\">\n                                {input(\"address\", \"name\", \"Full name\", addr.name, (v) => setAddr((a) => ({ ...a, name: v })), { ac: \"name\", span: true })}\n                                {input(\"address\", \"line1\", \"Address\", addr.line1, (v) => setAddr((a) => ({ ...a, line1: v })), { ac: \"street-address\", span: true })}\n                                {input(\"address\", \"city\", \"City\", addr.city, (v) => setAddr((a) => ({ ...a, city: v })), { ac: \"address-level2\" })}\n                                {input(\"address\", \"zip\", \"ZIP code\", addr.zip, (v) => setAddr((a) => ({ ...a, zip: v })), { ac: \"postal-code\", mode: \"numeric\" })}\n                              </div>\n                            )}\n                            {s.id === \"delivery\" && (\n                              <div role=\"radiogroup\" aria-label=\"Delivery\" className=\"flex flex-col gap-2\">\n                                {deliveryOptions.map((d) => {\n                                  const on = delivery === d.id;\n                                  const price = applied === \"FREESHIP\" ? 0 : d.price;\n                                  return (\n                                    <button\n                                      key={d.id}\n                                      type=\"button\"\n                                      role=\"radio\"\n                                      aria-checked={on}\n                                      onClick={() => setDelivery(d.id)}\n                                      className={cn(\"flex cursor-pointer items-center gap-3 rounded-xl border p-3.5 text-left\", focus)}\n                                      style={{ background: on ? p.ghost : \"transparent\", borderColor: on ? p.title : p.line, color: p.title }}\n                                    >\n                                      <span aria-hidden=\"true\" className=\"flex h-[18px] w-[18px] shrink-0 items-center justify-center rounded-full border-2\" style={{ borderColor: on ? p.title : p.line }}>\n                                        {on && <span className=\"h-2 w-2 rounded-full\" style={{ background: p.title }} />}\n                                      </span>\n                                      <span className=\"flex-1\">\n                                        <span className=\"block text-[14px] font-semibold\">{d.label}</span>\n                                        <span className=\"block text-[12px]\" style={{ color: p.muted }}>\n                                          {d.eta}\n                                        </span>\n                                      </span>\n                                      <span className=\"text-[13.5px] font-semibold tabular-nums\">{price ? money(price, currency) : \"Free\"}</span>\n                                    </button>\n                                  );\n                                })}\n                              </div>\n                            )}\n                            {s.id === \"payment\" && (\n                              <div className=\"grid grid-cols-2 gap-3\">\n                                <div className=\"col-span-2\">\n                                  {input(\n                                    \"payment\",\n                                    \"number\",\n                                    `Card number${brand ? ` · ${brand}` : \"\"}`,\n                                    card.number,\n                                    (v) =>\n                                      setCard((c) => ({\n                                        ...c,\n                                        number: v\n                                          .replace(/\\D/g, \"\")\n                                          .slice(0, 19)\n                                          .replace(/(\\d{4})(?=\\d)/g, \"$1 \"),\n                                      })),\n                                    { ac: \"cc-number\", mode: \"numeric\", ph: \"1234 5678 9012 3456\" },\n                                  )}\n                                </div>\n                                {input(\n                                  \"payment\",\n                                  \"exp\",\n                                  \"Expiry\",\n                                  card.exp,\n                                  (v) => {\n                                    const d = v.replace(/\\D/g, \"\").slice(0, 4);\n                                    setCard((c) => ({ ...c, exp: d.length > 2 ? `${d.slice(0, 2)}/${d.slice(2)}` : d }));\n                                  },\n                                  { ac: \"cc-exp\", mode: \"numeric\", ph: \"MM/YY\" },\n                                )}\n                                {input(\"payment\", \"cvc\", \"CVC\", card.cvc, (v) => setCard((c) => ({ ...c, cvc: v.replace(/\\D/g, \"\").slice(0, 4) })), { ac: \"cc-csc\", mode: \"numeric\", ph: \"123\" })}\n                                <button\n                                  type=\"button\"\n                                  onClick={() => setCard({ number: \"4242 4242 4242 4242\", exp: \"08/29\", cvc: \"123\" })}\n                                  className={cn(\"col-span-2 cursor-pointer justify-self-start rounded border-0 bg-transparent p-0 text-[12.5px] underline underline-offset-4\", focus)}\n                                  style={{ color: p.muted }}\n                                >\n                                  Use a test card\n                                </button>\n                              </div>\n                            )}\n                            {s.id !== \"payment\" && (\n                              <button type=\"button\" onClick={() => save(s.id)} className={cn(\"mt-4 h-10 cursor-pointer rounded-full border-0 px-5 text-[13.5px] font-semibold\", focus)} style={{ background: p.buttonBg, color: p.buttonText }}>\n                                {done[s.id] ? \"Save\" : \"Continue\"}\n                              </button>\n                            )}\n                          </div>\n                        </motion.div>\n                      )}\n                    </AnimatePresence>\n                  </li>\n                );\n              })}\n            </ol>\n          )}\n\n          {state !== \"done\" && (\n            <>\n              <button\n                type=\"button\"\n                onClick={pay}\n                disabled={state === \"busy\" || !SECTIONS.slice(0, 3).every((s) => done[s.id])}\n                className={cn(\"mt-4 flex h-12 w-full cursor-pointer items-center justify-center gap-2 rounded-full border-0 text-[15px] font-semibold disabled:cursor-not-allowed disabled:opacity-40\", focus)}\n                style={{ background: p.buttonBg, color: p.buttonText }}\n              >\n                {state === \"busy\" && (\n                  <motion.span\n                    aria-hidden=\"true\"\n                    className=\"h-4 w-4 rounded-full border-2\"\n                    style={{ borderColor: `${p.buttonText}33`, borderTopColor: p.buttonText }}\n                    animate={reduce ? undefined : { rotate: 360 }}\n                    transition={{ duration: 0.8, repeat: Infinity, ease: \"linear\" }}\n                  />\n                )}\n                {state === \"busy\" ? \"Processing…\" : `Pay ${money(total, currency)}`}\n              </button>\n              {state === \"error\" && (\n                <p className=\"m-0 mt-2 text-center text-[13px]\" style={{ color: p.danger }} role=\"alert\">\n                  The payment didn’t go through. Check the card and try again.\n                </p>\n              )}\n            </>\n          )}\n        </div>\n\n        {/* Summary */}\n        <aside aria-label=\"Order summary\" className=\"self-start rounded-3xl border p-5 lg:sticky lg:top-6\" style={{ background: p.side, borderColor: p.line }}>\n          <p className=\"m-0 text-[14px] font-semibold\">Order summary</p>\n          <ul className=\"m-0 mt-4 flex list-none flex-col gap-3 p-0\">\n            {lines.map((l) => (\n              <li key={l.name} className=\"flex items-center gap-3\">\n                <span className=\"relative h-12 w-12 shrink-0 rounded-xl\" style={{ background: p.tile }}>\n                  {/* eslint-disable-next-line @next/next/no-img-element -- plain img keeps the block framework-agnostic */}\n                  <img src={l.image} alt=\"\" width={96} height={96} className=\"h-full w-full object-contain p-1\" />\n                  {l.qty > 1 && (\n                    <span className=\"absolute -top-1.5 -right-1.5 flex h-5 min-w-5 items-center justify-center rounded-full px-1 text-[11px] font-bold\" style={{ background: p.buttonBg, color: p.buttonText }}>\n                      {l.qty}\n                    </span>\n                  )}\n                </span>\n                <span className=\"min-w-0 flex-1\">\n                  <span className=\"block truncate text-[13px] font-medium\">{l.name}</span>\n                  {l.variant && (\n                    <span className=\"block truncate text-[11.5px]\" style={{ color: p.muted }}>\n                      {l.variant}\n                    </span>\n                  )}\n                </span>\n                <span className=\"text-[13px] tabular-nums\">{money(l.price * l.qty, currency)}</span>\n              </li>\n            ))}\n          </ul>\n          <div className=\"mt-4 border-t pt-4\" style={{ borderColor: p.line }}>\n            {applied ? (\n              <p className=\"m-0 flex items-center justify-between rounded-xl px-3 py-2 text-[12.5px]\" style={{ background: p.ghost }}>\n                <span>\n                  <span className=\"font-mono font-semibold\" style={{ color: p.accent }}>\n                    {applied}\n                  </span>{\" \"}\n                  <span style={{ color: p.body }}>{codes?.[applied]?.label}</span>\n                </span>\n                <button type=\"button\" onClick={() => setApplied(null)} aria-label={`Remove code ${applied}`} className={cn(\"cursor-pointer rounded border-0 bg-transparent p-0 text-[15px]\", focus)} style={{ color: p.muted }}>\n                  ×\n                </button>\n              </p>\n            ) : (\n              <form onSubmit={apply} className=\"flex gap-2\">\n                <label htmlFor={`${uid}-code`} className=\"sr-only\">\n                  Discount code\n                </label>\n                <input\n                  id={`${uid}-code`}\n                  value={code}\n                  onChange={(e) => setCode(e.target.value)}\n                  placeholder=\"Discount code\"\n                  autoComplete=\"off\"\n                  aria-invalid={!!codeErr}\n                  className={cn(\"h-10 min-w-0 flex-1 rounded-xl border px-3 font-mono text-[16px] uppercase placeholder:font-sans placeholder:normal-case sm:text-[13px]\", focus)}\n                  style={fs(!!codeErr)}\n                />\n                <button type=\"submit\" disabled={!code.trim()} className={cn(\"h-10 cursor-pointer rounded-xl border px-3 text-[13px] font-semibold disabled:opacity-40\", focus)} style={{ borderColor: p.line, background: \"transparent\", color: p.title }}>\n                  Apply\n                </button>\n              </form>\n            )}\n            {codeErr && (\n              <p className=\"m-0 mt-1.5 text-[12px]\" style={{ color: p.danger }} role=\"alert\">\n                {codeErr}\n              </p>\n            )}\n          </div>\n          <dl className=\"m-0 mt-4 flex flex-col gap-2 text-[13px]\">\n            {[[\"Subtotal\", money(subtotal, currency)], ...(off > 0 ? [[\"Discount\", `−${money(off, currency)}`]] : []), [\"Shipping\", shipping ? money(shipping, currency) : \"Free\"], [`Tax (${Math.round(taxRate * 100)}%)`, money(tax, currency)]].map(([k, v]) => (\n              <div key={k} className=\"flex justify-between\" style={k === \"Discount\" ? { color: p.accent } : undefined}>\n                <dt style={k === \"Discount\" ? undefined : { color: p.body }}>{k}</dt>\n                <dd className=\"m-0 tabular-nums\">{v}</dd>\n              </div>\n            ))}\n            <div className=\"mt-1 flex items-baseline justify-between border-t pt-3\" style={{ borderColor: p.line }}>\n              <dt className=\"text-[14px] font-semibold\">Total</dt>\n              <dd className=\"m-0 text-[20px] font-semibold tabular-nums\" aria-live=\"polite\">\n                {money(total, currency)}\n              </dd>\n            </div>\n          </dl>\n        </aside>\n      </div>\n    </section>\n  );\n}\n",
      "type": "registry:component"
    }
  ],
  "type": "registry:component"
}