{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "modal-side-sheet",
  "type": "registry:component",
  "title": "Stacked Side Sheet",
  "description": "A side sheet for order details that opens a second sheet on top for refunds while the first one recedes behind it. Escape and Back peel the layers off one at a time.",
  "author": "Hyperblur <hello@hyperblur.dev>",
  "dependencies": [],
  "registryDependencies": [],
  "categories": [
    "modals",
    "side sheet",
    "drawer",
    "nested",
    "stack",
    "admin",
    "modal"
  ],
  "docs": "https://hyperblur.dev/effects/modal-side-sheet",
  "files": [
    {
      "path": "registry/hyperblur/modal-side-sheet.tsx",
      "type": "registry:component",
      "target": "components/hyperblur/modal-side-sheet.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nexport interface SideSheetItem {\n  name: string;\n  variant: string;\n  qty: number;\n  price: number;\n  tint?: string;\n}\n\nexport interface SideSheetOrder {\n  id: string;\n  customer: string;\n  email: string;\n  placed: string;\n  items: SideSheetItem[];\n  shipping: number;\n}\n\nexport interface ModalSideSheetProps 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  side?: \"right\" | \"left\";\n  order?: SideSheetOrder;\n  reasons?: string[];\n  currency?: string;\n  locale?: string;\n  onRefund?: (amount: number, reason: string) => void;\n  onFulfill?: (orderId: string) => void;\n  accent?: string;\n}\n\nconst defaultOrder: SideSheetOrder = {\n  id: \"4821\",\n  customer: \"Priya Raman\",\n  email: \"priya@fieldnotes.co\",\n  placed: \"Nov 6, 4:12 PM\",\n  items: [\n    { name: \"Merino Crew Sweater\", variant: \"Oat · M\", qty: 1, price: 98, tint: \"#c9b38f\" },\n    { name: \"Canvas Field Tote\", variant: \"Olive\", qty: 1, price: 42, tint: \"#6f7b4f\" },\n  ],\n  shipping: 8,\n};\n\nconst defaultReasons = [\"Damaged\", \"Wrong size\", \"Arrived late\", \"Changed mind\"];\n\nconst css = `\n.hb-xe3 { --hb-xe3-accent: #a78bfa; display: inline-block; box-sizing: border-box; color: #ededed; font-family: var(--font-sans, ui-sans-serif, system-ui, sans-serif); }\n.hb-xe3 *, .hb-xe3 *::before, .hb-xe3 *::after { box-sizing: border-box; }\n.hb-xe3[data-embedded] { position: relative; display: grid; place-items: center start; padding-left: 22px; width: 100%; height: 100%; min-height: 190px; border-radius: 16px; overflow: hidden; isolation: isolate; background: #0b0b0d; }\n.hb-xe3[data-embedded][data-side=\"left\"] { place-items: center end; padding: 0 22px 0 0; }\n.hb-xe3-trigger { display: inline-flex; align-items: center; gap: 8px; height: 34px; padding: 0 12px; border: 1px solid #2a2a30; border-radius: 9px; background: #141418; color: #e4e4e7; font: inherit; font-size: 13px; font-weight: 500; cursor: pointer; transition: border-color 0.2s ease, background-color 0.2s ease, transform 0.15s ease; }\n.hb-xe3-trigger:hover { border-color: #3a3a42; background: #18181d; }\n.hb-xe3-trigger:active { transform: scale(0.97); }\n.hb-xe3-trigger b { font-family: var(--font-mono, ui-monospace, monospace); font-weight: 500; font-size: 12px; color: #8b8b94; }\n.hb-xe3 button:focus-visible, .hb-xe3 input:focus-visible { outline: 2px solid var(--hb-xe3-accent); outline-offset: 2px; }\n.hb-xe3-layer { position: fixed; inset: 0; z-index: 1000; height: 100dvh; display: flex; justify-content: flex-end; overflow: hidden; }\n.hb-xe3[data-side=\"left\"] .hb-xe3-layer { justify-content: flex-start; }\n.hb-xe3[data-embedded] .hb-xe3-layer { position: absolute; height: auto; z-index: 2; }\n.hb-xe3-scrim { position: absolute; inset: 0; background: rgba(5, 5, 8, 0.55); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); animation: hb-xe3-fade 0.3s ease both; }\n.hb-xe3-layer[data-state=\"closed\"] .hb-xe3-scrim { animation: hb-xe3-fade-out 0.28s ease both; }\n.hb-xe3-stack { position: relative; width: min(420px, 100%); height: 100%; outline: none; animation: hb-xe3-in-r 0.48s cubic-bezier(0.16, 1, 0.3, 1) both; }\n.hb-xe3[data-side=\"left\"] .hb-xe3-stack { animation-name: hb-xe3-in-l; }\n.hb-xe3[data-embedded] .hb-xe3-stack { width: min(300px, 72%); }\n.hb-xe3-layer[data-state=\"closed\"] .hb-xe3-stack { animation: hb-xe3-out-r 0.28s cubic-bezier(0.5, 0, 0.75, 0) both; }\n.hb-xe3[data-side=\"left\"] .hb-xe3-layer[data-state=\"closed\"] .hb-xe3-stack { animation-name: hb-xe3-out-l; }\n.hb-xe3-sheet { position: absolute; inset: 0; display: flex; flex-direction: column; background: linear-gradient(180deg, #151519, #101013 40%); border-left: 1px solid #25252b; box-shadow: -30px 0 60px -30px rgba(0, 0, 0, 0.9); transition: transform 0.5s cubic-bezier(0.2, 0.9, 0.2, 1), filter 0.5s ease, border-radius 0.5s ease; transform-origin: center left; }\n.hb-xe3[data-side=\"left\"] .hb-xe3-sheet { border-left: 0; border-right: 1px solid #25252b; box-shadow: 30px 0 60px -30px rgba(0, 0, 0, 0.9); transform-origin: center right; }\n.hb-xe3-sheet[data-back=\"true\"] { transform: translateX(-26px) scale(0.94); filter: brightness(0.55); border-radius: 14px; overflow: hidden; }\n.hb-xe3[data-side=\"left\"] .hb-xe3-sheet[data-back=\"true\"] { transform: translateX(26px) scale(0.94); }\n.hb-xe3-sub { position: absolute; inset: 0; display: flex; flex-direction: column; background: linear-gradient(180deg, #17171c, #111114 45%); border-left: 1px solid #2c2c33; box-shadow: -24px 0 50px -20px rgba(0, 0, 0, 0.9); transform: translateX(104%); visibility: hidden; transition: transform 0.5s cubic-bezier(0.2, 0.9, 0.2, 1), visibility 0s linear 0.5s; }\n.hb-xe3[data-side=\"left\"] .hb-xe3-sub { transform: translateX(-104%); border-left: 0; border-right: 1px solid #2c2c33; }\n.hb-xe3-sub[data-open=\"true\"] { transform: none; visibility: visible; transition: transform 0.5s cubic-bezier(0.2, 0.9, 0.2, 1), visibility 0s; }\n.hb-xe3-head { flex: none; display: flex; align-items: center; gap: 10px; padding: 14px 14px 12px 16px; border-bottom: 1px solid #1f1f24; }\n.hb-xe3-eyebrow { display: block; color: #7d7d86; font-size: 11px; font-weight: 500; letter-spacing: 0.04em; text-transform: uppercase; }\n.hb-xe3-title { margin: 1px 0 0; font-family: var(--font-grotesk, inherit); font-size: 17px; font-weight: 600; letter-spacing: -0.02em; white-space: nowrap; }\n.hb-xe3-title span { color: #6e6e78; font-weight: 500; }\n.hb-xe3-pill { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; margin-left: auto; border-radius: 999px; background: rgba(245, 185, 66, 0.12); color: #f5c24a; font-size: 11px; font-weight: 600; white-space: nowrap; }\n.hb-xe3-pill::before { content: \"\"; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }\n.hb-xe3-pill[data-tone=\"done\"] { background: rgba(74, 210, 140, 0.12); color: #4fd18b; }\n.hb-xe3-pill[data-tone=\"refund\"] { background: color-mix(in srgb, var(--hb-xe3-accent) 16%, transparent); color: var(--hb-xe3-accent); }\n.hb-xe3-icon { flex: none; display: grid; place-items: center; width: 28px; height: 28px; border: 0; border-radius: 8px; background: transparent; color: #8b8b94; cursor: pointer; transition: background-color 0.15s ease, color 0.15s ease; }\n.hb-xe3-icon:hover { background: #1f1f25; color: #fff; }\n.hb-xe3-icon svg { width: 14px; height: 14px; }\n.hb-xe3-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 14px 16px; display: grid; align-content: start; gap: 14px; }\n.hb-xe3-who { display: flex; align-items: center; gap: 10px; padding: 10px; border: 1px solid #222228; border-radius: 12px; background: #0f0f12; }\n.hb-xe3-av { flex: none; display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: linear-gradient(135deg, #f0abfc, #818cf8); color: #160f25; font-size: 12px; font-weight: 700; }\n.hb-xe3-name { display: block; font-size: 13px; font-weight: 600; }\n.hb-xe3-muted { display: block; color: #7d7d86; font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }\n.hb-xe3-items { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }\n.hb-xe3-item { display: grid; grid-template-columns: 38px 1fr auto; gap: 10px; align-items: center; font-size: 13px; }\n.hb-xe3-thumb { height: 38px; border-radius: 9px; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08), inset 0 -10px 18px rgba(0, 0, 0, 0.25); }\n.hb-xe3-num { font-variant-numeric: tabular-nums; }\n.hb-xe3-sum { display: grid; gap: 6px; padding-top: 12px; border-top: 1px dashed #26262c; font-size: 12.5px; color: #9a9aa3; }\n.hb-xe3-sum div { display: flex; justify-content: space-between; }\n.hb-xe3-sum div:last-child { color: #ededed; font-size: 14px; font-weight: 600; }\n.hb-xe3-foot { flex: none; display: flex; gap: 8px; padding: 12px 16px 16px; border-top: 1px solid #1f1f24; }\n.hb-xe3-btn { flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 38px; padding: 0 12px; border: 1px solid #2b2b32; border-radius: 10px; background: #18181d; color: #e4e4e7; font: inherit; font-size: 13px; font-weight: 550; white-space: nowrap; cursor: pointer; transition: background-color 0.15s ease, transform 0.15s cubic-bezier(0.3, 0.7, 0.4, 1), opacity 0.2s ease; }\n.hb-xe3-btn:hover { background: #1f1f25; }\n.hb-xe3-btn:active { transform: scale(0.97); }\n.hb-xe3-btn:disabled { opacity: 0.45; cursor: not-allowed; }\n.hb-xe3-btn[data-primary] { border-color: transparent; background: #ededed; color: #0b0b0d; box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.1); }\n.hb-xe3-btn[data-primary]:hover { background: #fff; }\n.hb-xe3-btn[data-accent] { border-color: transparent; background: var(--hb-xe3-accent); color: #120c22; }\n.hb-xe3-btn svg { width: 14px; height: 14px; }\n.hb-xe3-label { margin: 0 0 7px; color: #8b8b94; font-size: 11.5px; font-weight: 500; }\n.hb-xe3-modes { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }\n.hb-xe3-mode { display: grid; gap: 2px; padding: 10px; border: 1px solid #26262c; border-radius: 11px; background: #121215; color: inherit; font: inherit; text-align: left; cursor: pointer; transition: border-color 0.2s ease, background-color 0.2s ease; }\n.hb-xe3-mode[aria-checked=\"true\"] { border-color: var(--hb-xe3-accent); background: color-mix(in srgb, var(--hb-xe3-accent) 9%, #121215); }\n.hb-xe3-mode b { font-size: 12.5px; font-weight: 600; }\n.hb-xe3-mode span { color: #8b8b94; font-size: 11.5px; font-variant-numeric: tabular-nums; }\n.hb-xe3-amount { display: flex; align-items: center; height: 38px; margin-top: 6px; padding: 0 10px; border: 1px solid #2b2b32; border-radius: 10px; background: #0d0d10; font-variant-numeric: tabular-nums; }\n.hb-xe3-amount:focus-within { border-color: var(--hb-xe3-accent); }\n.hb-xe3-amount span { color: #6e6e78; font-size: 13px; }\n.hb-xe3-amount input { flex: 1; min-width: 0; height: 100%; border: 0; background: transparent; color: #ededed; font: inherit; font-size: 14px; outline: none; padding-left: 4px; }\n.hb-xe3 .hb-xe3-amount input:focus-visible { outline: none; }\n.hb-xe3-chips { display: flex; flex-wrap: wrap; gap: 6px; }\n.hb-xe3-chip { height: 28px; padding: 0 10px; border: 1px solid #2b2b32; border-radius: 999px; background: transparent; color: #c4c4cc; font: inherit; font-size: 12px; cursor: pointer; transition: all 0.18s ease; }\n.hb-xe3-chip[aria-pressed=\"true\"] { border-color: transparent; background: #ededed; color: #0b0b0d; }\n.hb-xe3-done { display: grid; justify-items: center; gap: 8px; padding: 26px 0 8px; text-align: center; animation: hb-xe3-pop 0.5s cubic-bezier(0.2, 0.9, 0.2, 1.2) both; }\n.hb-xe3-done i { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; background: color-mix(in srgb, var(--hb-xe3-accent) 18%, transparent); color: var(--hb-xe3-accent); font-style: normal; }\n.hb-xe3-done svg { width: 20px; height: 20px; }\n.hb-xe3-done b { font-size: 14px; }\n@keyframes hb-xe3-fade { from { opacity: 0; } to { opacity: 1; } }\n@keyframes hb-xe3-fade-out { from { opacity: 1; } to { opacity: 0; } }\n@keyframes hb-xe3-in-r { from { transform: translateX(100%); } to { transform: none; } }\n@keyframes hb-xe3-in-l { from { transform: translateX(-100%); } to { transform: none; } }\n@keyframes hb-xe3-out-r { from { transform: none; } to { transform: translateX(100%); } }\n@keyframes hb-xe3-out-l { from { transform: none; } to { transform: translateX(-100%); } }\n@keyframes hb-xe3-pop { from { opacity: 0; transform: scale(0.9); } to { opacity: 1; transform: none; } }\n@media (prefers-reduced-motion: reduce) {\n  .hb-xe3-scrim, .hb-xe3-stack, .hb-xe3-done, .hb-xe3-layer[data-state=\"closed\"] .hb-xe3-stack, .hb-xe3-layer[data-state=\"closed\"] .hb-xe3-scrim { animation: none; }\n  .hb-xe3-layer[data-state=\"closed\"] { opacity: 0; }\n  .hb-xe3-sheet, .hb-xe3-sub, .hb-xe3-sub[data-open=\"true\"], .hb-xe3-btn, .hb-xe3-mode, .hb-xe3-chip, .hb-xe3-trigger, .hb-xe3-icon { 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(\n        (el) => el.getClientRects().length > 0 && !el.closest(\"[inert]\") && getComputedStyle(el).visibility !== \"hidden\",\n      );\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) || !items.includes(active as HTMLElement)) {\n        e.preventDefault();\n        (e.shiftKey ? last : first).focus();\n      } else if (e.shiftKey && active === first) {\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 ModalSideSheet({\n  open,\n  defaultOpen,\n  onOpenChange,\n  embedded = false,\n  trigger = \"View order\",\n  side = \"right\",\n  order = defaultOrder,\n  reasons = defaultReasons,\n  currency = \"USD\",\n  locale = \"en-US\",\n  onRefund,\n  onFulfill,\n  accent = \"#a78bfa\",\n  className = \"\",\n  style,\n  ...rest\n}: ModalSideSheetProps) {\n  const [inner, setInner] = React.useState(defaultOpen ?? embedded);\n  const isOpen = open ?? inner;\n  const [present, setPresent] = React.useState(isOpen);\n  const [nested, setNested] = React.useState(false);\n  const [status, setStatus] = React.useState<\"open\" | \"fulfilled\" | \"refunded\">(\"open\");\n  const [mode, setMode] = React.useState<\"full\" | \"partial\">(\"full\");\n  const [partial, setPartial] = React.useState(\"40.00\");\n  const [reason, setReason] = React.useState(reasons[0] ?? \"\");\n  const [phase, setPhase] = React.useState<\"form\" | \"busy\" | \"done\">(\"form\");\n  const userOpened = React.useRef(false);\n  const stack = React.useRef<HTMLDivElement>(null);\n  const refundBtn = React.useRef<HTMLButtonElement>(null);\n  const subFirst = React.useRef<HTMLButtonElement>(null);\n  const timers = React.useRef<number[]>([]);\n  const id = React.useId();\n\n  const money = React.useMemo(() => new Intl.NumberFormat(locale, { style: \"currency\", currency }), [locale, currency]);\n  const subtotal = order.items.reduce((s, i) => s + i.price * i.qty, 0);\n  const total = subtotal + order.shipping;\n  const parsed = Math.min(Math.max(Number.parseFloat(partial) || 0, 0), total);\n  const amount = mode === \"full\" ? total : parsed;\n\n  if (isOpen && !present) setPresent(true);\n\n  React.useEffect(() => {\n    const list = timers.current;\n    return () => list.forEach((t) => clearTimeout(t));\n  }, []);\n\n  const setOpen = React.useCallback(\n    (next: boolean) => {\n      if (next) userOpened.current = true;\n      else setNested(false);\n      if (open === undefined) setInner(next);\n      onOpenChange?.(next);\n    },\n    [open, onOpenChange],\n  );\n\n  const popNested = React.useCallback(() => {\n    setNested(false);\n    setPhase(\"form\");\n    timers.current.push(window.setTimeout(() => refundBtn.current?.focus({ preventScroll: true }), 30));\n  }, []);\n\n  const handleClose = React.useCallback(() => {\n    if (nested) popNested();\n    else setOpen(false);\n  }, [nested, popNested, setOpen]);\n\n  React.useEffect(() => {\n    if (isOpen || !present) return;\n    const t = setTimeout(() => setPresent(false), 300);\n    return () => clearTimeout(t);\n  }, [isOpen, present]);\n\n  useLayer(isOpen, embedded, stack, handleClose, userOpened);\n\n  function openNested() {\n    setNested(true);\n    setPhase(\"form\");\n    timers.current.push(window.setTimeout(() => subFirst.current?.focus({ preventScroll: true }), 60));\n  }\n\n  function submitRefund() {\n    if (amount <= 0 || phase !== \"form\") return;\n    setPhase(\"busy\");\n    timers.current.push(\n      window.setTimeout(() => {\n        setPhase(\"done\");\n        setStatus(\"refunded\");\n        onRefund?.(amount, reason);\n        timers.current.push(window.setTimeout(popNested, 1300));\n      }, 900),\n    );\n  }\n\n  const pill = status === \"fulfilled\" ? \"Fulfilled\" : status === \"refunded\" ? \"Refunded\" : \"Unfulfilled\";\n  const tone = status === \"fulfilled\" ? \"done\" : status === \"refunded\" ? \"refund\" : \"wait\";\n  const vars = { \"--hb-xe3-accent\": accent, ...style } as React.CSSProperties;\n  const closeIcon = (\n    <svg viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.8\" strokeLinecap=\"round\" aria-hidden=\"true\">\n      <path d=\"m3.5 3.5 9 9m0-9-9 9\" />\n    </svg>\n  );\n\n  return (\n    <div className={`hb-xe3 ${className}`} data-embedded={embedded || undefined} data-side={side} style={vars} {...rest}>\n      <style href=\"hb-xe3-css\" precedence=\"default\">{css}</style>\n      {trigger !== null && (\n        <button type=\"button\" className=\"hb-xe3-trigger\" aria-haspopup=\"dialog\" aria-expanded={isOpen} onClick={() => setOpen(true)}>\n          {trigger}\n          <b>#{order.id}</b>\n        </button>\n      )}\n      {present && (\n        <div className=\"hb-xe3-layer\" data-state={isOpen ? \"open\" : \"closed\"}>\n          <div className=\"hb-xe3-scrim\" onClick={() => setOpen(false)} aria-hidden=\"true\" />\n          <div ref={stack} role=\"dialog\" aria-modal=\"true\" aria-labelledby={`${id}-t`} tabIndex={-1} className=\"hb-xe3-stack\">\n            <section className=\"hb-xe3-sheet\" data-back={nested ? \"true\" : undefined} inert={nested}>\n              <header className=\"hb-xe3-head\">\n                <div style={{ minWidth: 0 }}>\n                  <span className=\"hb-xe3-eyebrow\">{order.placed}</span>\n                  <h2 id={`${id}-t`} className=\"hb-xe3-title\"><span>Order </span>#{order.id}</h2>\n                </div>\n                <span className=\"hb-xe3-pill\" data-tone={tone} aria-live=\"polite\">{pill}</span>\n                <button type=\"button\" className=\"hb-xe3-icon\" aria-label=\"Close\" onClick={() => setOpen(false)}>{closeIcon}</button>\n              </header>\n              <div className=\"hb-xe3-body\">\n                <div className=\"hb-xe3-who\">\n                  <span className=\"hb-xe3-av\" aria-hidden=\"true\">\n                    {order.customer.split(\" \").map((p) => p[0]).join(\"\").slice(0, 2)}\n                  </span>\n                  <span style={{ minWidth: 0 }}>\n                    <span className=\"hb-xe3-name\">{order.customer}</span>\n                    <span className=\"hb-xe3-muted\">{order.email}</span>\n                  </span>\n                </div>\n                <ul className=\"hb-xe3-items\">\n                  {order.items.map((it) => (\n                    <li key={it.name} className=\"hb-xe3-item\">\n                      <span className=\"hb-xe3-thumb\" style={{ background: `linear-gradient(150deg, ${it.tint ?? \"#555\"}, #1a1a1f)` }} aria-hidden=\"true\" />\n                      <span style={{ minWidth: 0 }}>\n                        <span className=\"hb-xe3-name\" style={{ fontWeight: 500 }}>{it.name}</span>\n                        <span className=\"hb-xe3-muted\">{it.variant} · Qty {it.qty}</span>\n                      </span>\n                      <span className=\"hb-xe3-num\">{money.format(it.price * it.qty)}</span>\n                    </li>\n                  ))}\n                </ul>\n                <div className=\"hb-xe3-sum\">\n                  <div><span>Subtotal</span><span className=\"hb-xe3-num\">{money.format(subtotal)}</span></div>\n                  <div><span>Shipping</span><span className=\"hb-xe3-num\">{money.format(order.shipping)}</span></div>\n                  <div><span>Total</span><span className=\"hb-xe3-num\">{money.format(total)}</span></div>\n                </div>\n              </div>\n              <footer className=\"hb-xe3-foot\">\n                <button ref={refundBtn} type=\"button\" className=\"hb-xe3-btn\" disabled={status === \"refunded\"} onClick={openNested}>\n                  Issue refund\n                </button>\n                <button\n                  type=\"button\"\n                  className=\"hb-xe3-btn\"\n                  data-primary=\"\"\n                  data-autofocus=\"\"\n                  disabled={status !== \"open\"}\n                  onClick={() => {\n                    setStatus(\"fulfilled\");\n                    onFulfill?.(order.id);\n                  }}\n                >\n                  {status === \"fulfilled\" ? (\n                    <>\n                      <svg viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\"><path d=\"m3.5 8.4 3 3 6-6.4\" /></svg>\n                      Fulfilled\n                    </>\n                  ) : (\n                    \"Mark as fulfilled\"\n                  )}\n                </button>\n              </footer>\n            </section>\n            <section className=\"hb-xe3-sub\" data-open={nested ? \"true\" : undefined} inert={!nested} aria-label=\"Refund\">\n              <header className=\"hb-xe3-head\">\n                <button ref={subFirst} type=\"button\" className=\"hb-xe3-icon\" aria-label=\"Back to order\" onClick={popNested}>\n                  <svg viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.8\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\">\n                    <path d=\"M10 3.5 5.5 8l4.5 4.5\" />\n                  </svg>\n                </button>\n                <div style={{ minWidth: 0 }}>\n                  <span className=\"hb-xe3-eyebrow\">Order #{order.id}</span>\n                  <h3 className=\"hb-xe3-title\">Issue refund</h3>\n                </div>\n              </header>\n              <div className=\"hb-xe3-body\">\n                {phase === \"done\" ? (\n                  <div className=\"hb-xe3-done\" role=\"status\">\n                    <i aria-hidden=\"true\">\n                      <svg viewBox=\"0 0 20 20\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2.2\" strokeLinecap=\"round\" strokeLinejoin=\"round\"><path d=\"m5 10.5 3.2 3.2L15 7\" /></svg>\n                    </i>\n                    <b>{money.format(amount)} refunded</b>\n                    <span className=\"hb-xe3-muted\">{order.customer} gets an email in a minute.</span>\n                  </div>\n                ) : (\n                  <>\n                    <div>\n                      <p className=\"hb-xe3-label\">Amount</p>\n                      <div className=\"hb-xe3-modes\" role=\"radiogroup\" aria-label=\"Refund amount\">\n                        <button type=\"button\" role=\"radio\" aria-checked={mode === \"full\"} className=\"hb-xe3-mode\" onClick={() => setMode(\"full\")}>\n                          <b>Full</b>\n                          <span>{money.format(total)}</span>\n                        </button>\n                        <button type=\"button\" role=\"radio\" aria-checked={mode === \"partial\"} className=\"hb-xe3-mode\" onClick={() => setMode(\"partial\")}>\n                          <b>Partial</b>\n                          <span>Custom amount</span>\n                        </button>\n                      </div>\n                      {mode === \"partial\" && (\n                        <label className=\"hb-xe3-amount\">\n                          <span>{currency}</span>\n                          <input\n                            inputMode=\"decimal\"\n                            aria-label=\"Refund amount\"\n                            value={partial}\n                            onChange={(e) => setPartial(e.target.value.replace(/[^0-9.]/g, \"\"))}\n                          />\n                        </label>\n                      )}\n                    </div>\n                    <div>\n                      <p className=\"hb-xe3-label\">Reason</p>\n                      <div className=\"hb-xe3-chips\">\n                        {reasons.map((r) => (\n                          <button key={r} type=\"button\" className=\"hb-xe3-chip\" aria-pressed={reason === r} onClick={() => setReason(r)}>\n                            {r}\n                          </button>\n                        ))}\n                      </div>\n                    </div>\n                  </>\n                )}\n              </div>\n              <footer className=\"hb-xe3-foot\">\n                <button\n                  type=\"button\"\n                  className=\"hb-xe3-btn\"\n                  data-accent=\"\"\n                  disabled={amount <= 0 || phase !== \"form\"}\n                  aria-busy={phase === \"busy\" || undefined}\n                  onClick={submitRefund}\n                >\n                  {phase === \"busy\" ? \"Refunding\" : phase === \"done\" ? \"Done\" : `Refund ${money.format(amount)}`}\n                </button>\n              </footer>\n            </section>\n          </div>\n        </div>\n      )}\n    </div>\n  );\n}\n"
    }
  ]
}