{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "shop-spin-configurator",
  "type": "registry:component",
  "title": "Shop Spin Configurator",
  "description": "A product detail where the bottle turns a full 360 degrees as you drag it, with view presets that rotate to front, side or back. Finish, size and a live laser engraving restyle the product as you type.",
  "author": "Hyperblur <hello@hyperblur.dev>",
  "dependencies": [],
  "registryDependencies": [],
  "categories": [
    "ecommerce",
    "ecommerce",
    "product",
    "360 view",
    "configurator",
    "engraving",
    "variants"
  ],
  "docs": "https://hyperblur.dev/effects/shop-spin-configurator",
  "files": [
    {
      "path": "registry/hyperblur/shop-spin-configurator.tsx",
      "type": "registry:component",
      "target": "components/hyperblur/shop-spin-configurator.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nexport interface SpinFinish {\n  name: string;\n  color: string;\n  stock: number;\n}\n\nexport interface SpinSize {\n  label: string;\n  price: number;\n  height: number;\n}\n\nexport interface SpinConfiguration {\n  finish: string;\n  size: string;\n  engraving: string;\n  total: number;\n}\n\nexport interface ShopSpinConfiguratorProps extends Omit<React.HTMLAttributes<HTMLElement>, \"title\"> {\n  brand?: string;\n  name?: string;\n  blurb?: string;\n  finishes?: SpinFinish[];\n  sizes?: SpinSize[];\n  engravingPrice?: number;\n  maxEngraving?: number;\n  currency?: string;\n  autoSpin?: boolean;\n  accent?: string;\n  onAddToCart?: (config: SpinConfiguration) => void;\n}\n\nconst defaultFinishes: SpinFinish[] = [\n  { name: \"Glacier\", color: \"#9cc3d8\", stock: 42 },\n  { name: \"Ember\", color: \"#d9643a\", stock: 4 },\n  { name: \"Moss\", color: \"#5d7552\", stock: 18 },\n  { name: \"Graphite\", color: \"#3a3d42\", stock: 63 },\n  { name: \"Sand\", color: \"#d8c3a0\", stock: 0 },\n];\n\nconst defaultSizes: SpinSize[] = [\n  { label: \"500 ml\", price: 34, height: 290 },\n  { label: \"750 ml\", price: 38, height: 350 },\n  { label: \"1 L\", price: 44, height: 410 },\n];\n\nconst css = `\n.hb-we11 {\n  --hb-we11-accent: #f97316;\n  box-sizing: border-box;\n  width: 100%;\n  container-type: inline-size;\n  background: #0b0b0b;\n  color: #ededed;\n  font-family: inherit;\n  -webkit-font-smoothing: antialiased;\n}\n.hb-we11 *, .hb-we11 *::before, .hb-we11 *::after { box-sizing: border-box; }\n.hb-we11-inner { display: grid; gap: clamp(24px, 4cqi, 48px); max-width: 1120px; margin: 0 auto; padding: clamp(48px, 7cqi, 96px) clamp(18px, 4cqi, 40px); }\n.hb-we11-media { display: grid; grid-template-columns: 64px minmax(0, 1fr); gap: 12px; min-width: 0; }\n.hb-we11-strip { display: grid; gap: 8px; align-content: start; }\n.hb-we11-th { position: relative; aspect-ratio: 1; padding: 0; border: 0; border-radius: 12px; cursor: pointer; overflow: hidden; background: #141414; box-shadow: inset 0 0 0 1px rgba(255,255,255,.08); transition: box-shadow .2s ease, transform .2s ease; }\n.hb-we11-th svg { width: 100%; height: 100%; display: block; }\n.hb-we11-th:hover { transform: translateY(-1px); }\n.hb-we11-th[aria-pressed=\"true\"] { box-shadow: inset 0 0 0 1.5px var(--hb-we11-accent); }\n.hb-we11-th:focus-visible { outline: 2px solid var(--hb-we11-accent); outline-offset: 2px; }\n.hb-we11-th span { position: absolute; left: 0; right: 0; bottom: 3px; font-size: 9.5px; color: #8f8f8f; text-align: center; }\n.hb-we11-stage { position: relative; aspect-ratio: 1; min-width: 0; border-radius: 24px; overflow: hidden; touch-action: pan-y; cursor: grab; outline: none;\n  background: radial-gradient(70% 60% at 50% 40%, #222 0%, #121212 70%); box-shadow: inset 0 0 0 1px rgba(255,255,255,.08), inset 0 1px 0 rgba(255,255,255,.05); }\n.hb-we11-stage[data-drag=\"true\"] { cursor: grabbing; }\n.hb-we11-stage:focus-visible { box-shadow: inset 0 0 0 2px var(--hb-we11-accent); }\n.hb-we11-stage > svg { position: absolute; inset: 0; width: 100%; height: 100%; }\n.hb-we11-hint { position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%); display: inline-flex; align-items: center; gap: 8px; height: 32px; padding: 0 14px; border-radius: 999px; background: rgba(10,10,10,.6); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); box-shadow: inset 0 0 0 1px rgba(255,255,255,.12); color: #d4d4d4; font-size: 12px; white-space: nowrap; pointer-events: none; }\n.hb-we11-hint b { font-family: var(--font-mono, ui-monospace, monospace); font-weight: 500; color: #fff; min-width: 34px; text-align: right; font-variant-numeric: tabular-nums; }\n.hb-we11-dial { position: absolute; left: 0; right: 0; top: 14px; height: 14px; overflow: hidden; mask-image: linear-gradient(90deg, transparent, #000 25%, #000 75%, transparent); -webkit-mask-image: linear-gradient(90deg, transparent, #000 25%, #000 75%, transparent); pointer-events: none; }\n.hb-we11-dial i { position: absolute; left: 0; top: 0; width: 200%; height: 100%; font-style: normal; background: repeating-linear-gradient(90deg, rgba(255,255,255,.35) 0 1px, transparent 1px 10px); transform: translateX(var(--hb-we11-dx)); }\n.hb-we11-dial::after { content: \"\"; position: absolute; left: 50%; top: 0; width: 2px; height: 14px; margin-left: -1px; border-radius: 2px; background: var(--hb-we11-accent); }\n.hb-we11-info { display: grid; gap: 22px; align-content: start; min-width: 0; }\n.hb-we11-brand { margin: 0 0 6px; color: #8f8f8f; font-size: 13px; font-weight: 500; }\n.hb-we11-name { margin: 0; font-family: var(--font-grotesk, inherit); font-size: clamp(26px, 3.6cqi, 38px); font-weight: 600; line-height: 1.05; letter-spacing: -.03em; }\n.hb-we11-blurb { margin: 10px 0 0; color: #a1a1a1; font-size: 14.5px; line-height: 1.6; max-width: 46ch; }\n.hb-we11-price { display: inline-block; font-size: 30px; font-weight: 650; letter-spacing: -.03em; font-variant-numeric: tabular-nums; animation: hb-we11-tick .45s cubic-bezier(.2,.8,.2,1) both; }\n.hb-we11-g { display: grid; gap: 10px; }\n.hb-we11-gl { display: flex; justify-content: space-between; gap: 12px; color: #8f8f8f; font-size: 13px; }\n.hb-we11-gl b { color: #ededed; font-weight: 500; }\n.hb-we11-stock { font-size: 12px; }\n.hb-we11-stock[data-low=\"true\"] { color: #fbbf24; }\n.hb-we11-stock[data-out=\"true\"] { color: #f87171; }\n.hb-we11-sw { display: flex; flex-wrap: wrap; gap: 10px; }\n.hb-we11-swb { position: relative; width: 40px; height: 40px; padding: 0; border: 0; border-radius: 50%; cursor: pointer; background: var(--hb-we11-c); box-shadow: inset 0 -6px 10px rgba(0,0,0,.3), inset 0 4px 8px rgba(255,255,255,.25), 0 0 0 1px rgba(255,255,255,.1); transition: transform .3s cubic-bezier(.3,1.5,.5,1); }\n.hb-we11-swb::after { content: \"\"; position: absolute; inset: -5px; border-radius: 50%; box-shadow: 0 0 0 2px var(--hb-we11-accent); opacity: 0; transform: scale(.85); transition: opacity .25s ease, transform .35s cubic-bezier(.3,1.5,.5,1); }\n.hb-we11-swb[aria-checked=\"true\"]::after { opacity: 1; transform: none; }\n.hb-we11-swb:hover { transform: scale(1.08); }\n.hb-we11-swb:disabled { cursor: not-allowed; opacity: .45; }\n.hb-we11-swb:disabled::before { content: \"\"; position: absolute; left: 50%; top: 4px; bottom: 4px; width: 2px; background: #f4f4f4; transform: rotate(45deg); border-radius: 2px; }\n.hb-we11-swb:focus-visible { outline: 2px solid var(--hb-we11-accent); outline-offset: 6px; }\n.hb-we11-sizes { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }\n.hb-we11-sz { display: grid; gap: 2px; justify-items: start; padding: 12px; border: 0; border-radius: 12px; cursor: pointer; text-align: left; font: inherit; color: #ededed; background: #141414; box-shadow: inset 0 0 0 1px rgba(255,255,255,.08); transition: box-shadow .2s ease, background .2s ease; }\n.hb-we11-sz b { font-size: 14px; font-weight: 600; }\n.hb-we11-sz span { color: #8f8f8f; font-size: 12px; font-variant-numeric: tabular-nums; }\n.hb-we11-sz[aria-checked=\"true\"] { background: color-mix(in srgb, var(--hb-we11-accent) 8%, #141414); box-shadow: inset 0 0 0 1.5px var(--hb-we11-accent); }\n.hb-we11-sz:focus-visible { outline: 2px solid var(--hb-we11-accent); outline-offset: 2px; }\n.hb-we11-eng { display: grid; gap: 10px; padding: 14px; border-radius: 14px; background: #121212; box-shadow: inset 0 0 0 1px rgba(255,255,255,.07); }\n.hb-we11-tg { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0; border: 0; background: none; cursor: pointer; color: #ededed; font: inherit; font-size: 14px; font-weight: 500; text-align: left; }\n.hb-we11-tg small { display: block; color: #8f8f8f; font-size: 12px; font-weight: 400; margin-top: 2px; }\n.hb-we11-sw2 { position: relative; flex: none; width: 40px; height: 24px; border-radius: 99px; background: #2a2a2a; transition: background .25s ease; }\n.hb-we11-sw2::after { content: \"\"; position: absolute; left: 3px; top: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.4); transition: transform .35s cubic-bezier(.3,1.5,.5,1); }\n.hb-we11-tg[aria-checked=\"true\"] .hb-we11-sw2 { background: var(--hb-we11-accent); }\n.hb-we11-tg[aria-checked=\"true\"] .hb-we11-sw2::after { transform: translateX(16px); }\n.hb-we11-tg:focus-visible { outline: 2px solid var(--hb-we11-accent); outline-offset: 4px; border-radius: 6px; }\n.hb-we11-in { display: flex; align-items: center; gap: 8px; height: 42px; padding: 0 12px; border-radius: 10px; background: #0b0b0b; box-shadow: inset 0 0 0 1px rgba(255,255,255,.1); animation: hb-we11-open .35s cubic-bezier(.2,.8,.2,1) both; }\n.hb-we11-in:focus-within { box-shadow: inset 0 0 0 1.5px var(--hb-we11-accent); }\n.hb-we11-in input { flex: 1; min-width: 0; height: 100%; border: 0; outline: none; background: none; color: #ededed; font-family: var(--font-mono, ui-monospace, monospace); font-size: 14px; letter-spacing: .14em; text-transform: uppercase; }\n.hb-we11-in span { color: #6b6b6b; font-size: 12px; font-variant-numeric: tabular-nums; }\n.hb-we11-sum { margin: 0; color: #a1a1a1; font-size: 13.5px; line-height: 1.55; }\n.hb-we11-sum b { color: #ededed; font-weight: 600; }\n.hb-we11-add { position: relative; display: flex; align-items: center; justify-content: center; gap: 10px; height: 52px; border: 0; border-radius: 14px; cursor: pointer; overflow: hidden; color: #140800; font: inherit; font-size: 15px; font-weight: 650; background: var(--hb-we11-accent); box-shadow: inset 0 1px 0 rgba(255,255,255,.35), 0 14px 30px -14px var(--hb-we11-accent); transition: transform .2s cubic-bezier(.2,.8,.2,1), filter .2s ease, background .3s ease, color .3s ease; }\n.hb-we11-add:hover:not(:disabled) { filter: brightness(1.07); transform: translateY(-1px); }\n.hb-we11-add:active:not(:disabled) { transform: scale(.985); }\n.hb-we11-add:disabled { opacity: .5; cursor: not-allowed; }\n.hb-we11-add[data-done=\"true\"] { background: #ededed; color: #0b0b0b; }\n.hb-we11-add:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }\n.hb-we11-add svg { width: 18px; height: 18px; }\n.hb-we11-add[data-done=\"true\"] svg path { stroke-dasharray: 20; stroke-dashoffset: 20; animation: hb-we11-check .45s .1s ease forwards; }\n.hb-we11-eng-text { font-family: var(--font-mono, ui-monospace, monospace); letter-spacing: .2em; }\n@keyframes hb-we11-tick { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }\n@keyframes hb-we11-open { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }\n@keyframes hb-we11-check { to { stroke-dashoffset: 0; } }\n@container (min-width: 860px) {\n  .hb-we11-inner { grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); align-items: start; }\n}\n@container (max-width: 480px) {\n  .hb-we11-media { grid-template-columns: 1fr; }\n  .hb-we11-strip { grid-template-columns: repeat(4, 1fr); order: 2; }\n}\n@media (prefers-reduced-motion: reduce) {\n  .hb-we11 *, .hb-we11 *::before, .hb-we11 *::after { transition: none !important; animation: none !important; }\n}\n`;\n\nfunction shade(hex: string, amt: number) {\n  const n = parseInt(hex.replace(\"#\", \"\"), 16);\n  const f = (c: number) => Math.max(0, Math.min(255, Math.round(c + (amt > 0 ? (255 - c) * amt : c * amt))));\n  const r = f((n >> 16) & 255);\n  const g = f((n >> 8) & 255);\n  const b = f(n & 255);\n  return `rgb(${r}, ${g}, ${b})`;\n}\n\nfunction Bottle({ angle, color, height, engraving, brand, uid, small }: { angle: number; color: string; height: number; engraving: string; brand: string; uid: string; small?: boolean }) {\n  const cx = 200;\n  const r = 64;\n  const bottom = 470;\n  const top = bottom - height;\n  const rad = (angle * Math.PI) / 180;\n  const ridges = Array.from({ length: 16 }, (_, i) => {\n    const t = rad + (i * Math.PI * 2) / 16;\n    const c = Math.cos(t);\n    return { x: cx + r * Math.sin(t), c };\n  }).filter((p) => p.c > 0.05);\n  const face = (offset: number) => {\n    const t = rad + offset;\n    return { x: cx + r * 0.92 * Math.sin(t), c: Math.cos(t) };\n  };\n  const logo = face(0);\n  const eng = face(0);\n  const g = `${uid}b${small ? \"s\" : \"l\"}`;\n  return (\n    <svg viewBox=\"0 0 400 520\" aria-hidden=\"true\">\n      <defs>\n        <linearGradient id={g} x1=\"0\" x2=\"1\">\n          <stop offset=\"0\" stopColor={shade(color, -0.55)} />\n          <stop offset=\".3\" stopColor={shade(color, 0.28)} />\n          <stop offset=\".42\" stopColor={shade(color, 0.05)} />\n          <stop offset=\".8\" stopColor={shade(color, -0.35)} />\n          <stop offset=\"1\" stopColor={shade(color, -0.6)} />\n        </linearGradient>\n        <linearGradient id={`${g}c`} x1=\"0\" x2=\"1\">\n          <stop offset=\"0\" stopColor=\"#111\" />\n          <stop offset=\".32\" stopColor=\"#4a4a4a\" />\n          <stop offset=\"1\" stopColor=\"#0d0d0d\" />\n        </linearGradient>\n      </defs>\n      <ellipse cx={cx} cy={bottom + 14} rx={r * 1.3} ry=\"10\" fill=\"rgba(0,0,0,.55)\" />\n      <path d={`M ${cx - r} ${top + 40} Q ${cx - r} ${top} ${cx - 40} ${top - 6} L ${cx + 40} ${top - 6} Q ${cx + r} ${top} ${cx + r} ${top + 40} L ${cx + r} ${bottom - 16} Q ${cx + r} ${bottom} ${cx + r - 16} ${bottom} L ${cx - r + 16} ${bottom} Q ${cx - r} ${bottom} ${cx - r} ${bottom - 16} Z`} fill={`url(#${g})`} />\n      <rect x={cx - 42} y={top - 58} width=\"84\" height=\"54\" rx=\"12\" fill={`url(#${g}c)`} />\n      <rect x={cx - 30} y={top - 74} width=\"60\" height=\"20\" rx=\"8\" fill={`url(#${g}c)`} />\n      <rect x={cx - r} y={bottom - 70} width={r * 2} height=\"26\" fill=\"rgba(0,0,0,.18)\" />\n      {ridges.map((p, i) => (\n        <rect key={i} x={(p.x - 1.2 * p.c).toFixed(2)} y={bottom - 68} width={(2.4 * p.c).toFixed(2)} height=\"22\" fill=\"rgba(255,255,255,.22)\" opacity={p.c.toFixed(2)} />\n      ))}\n      {logo.c > 0.08 ? (\n        <text\n          x=\"0\"\n          y=\"0\"\n          transform={`translate(${logo.x.toFixed(2)} ${(top + 80).toFixed(1)}) scale(${logo.c.toFixed(3)} 1)`}\n          textAnchor=\"middle\"\n          fill=\"rgba(255,255,255,.85)\"\n          fontSize=\"22\"\n          fontWeight=\"700\"\n          letterSpacing=\"4\"\n          fontFamily=\"inherit\"\n          opacity={Math.min(1, logo.c * 1.4).toFixed(2)}\n        >\n          {brand.toUpperCase()}\n        </text>\n      ) : null}\n      {engraving && eng.c > 0.08 ? (\n        <text\n          className=\"hb-we11-eng-text\"\n          x=\"0\"\n          y=\"0\"\n          transform={`translate(${eng.x.toFixed(2)} ${(bottom - 100).toFixed(1)}) scale(${(eng.c * Math.min(1, 9 / Math.max(1, engraving.length))).toFixed(3)} 1)`}\n          textAnchor=\"middle\"\n          fill=\"rgba(0,0,0,.45)\"\n          stroke=\"rgba(255,255,255,.25)\"\n          strokeWidth=\".6\"\n          fontSize=\"18\"\n          fontWeight=\"600\"\n          opacity={Math.min(1, eng.c * 1.4).toFixed(2)}\n        >\n          {engraving.toUpperCase()}\n        </text>\n      ) : null}\n      <rect x={cx - r + 10} y={top + 20} width=\"10\" height={height - 60} rx=\"5\" fill=\"rgba(255,255,255,.18)\" />\n    </svg>\n  );\n}\n\nconst presets = [\n  { label: \"Front\", angle: 0 },\n  { label: \"Side\", angle: 90 },\n  { label: \"Back\", angle: 180 },\n  { label: \"Three-quarter\", angle: 320 },\n];\n\nexport function ShopSpinConfigurator({\n  brand = \"Kova\",\n  name = \"Kova Everyday Bottle\",\n  blurb = \"Double-wall steel that keeps water cold for 24 hours. Drag the bottle to turn it, then make it yours with a laser engraving.\",\n  finishes = defaultFinishes,\n  sizes = defaultSizes,\n  engravingPrice = 8,\n  maxEngraving = 12,\n  currency = \"$\",\n  autoSpin = true,\n  accent = \"#f97316\",\n  onAddToCart,\n  className,\n  style,\n  ...rest\n}: ShopSpinConfiguratorProps) {\n  const uid = React.useId().replace(/:/g, \"\");\n  const firstOk = Math.max(0, finishes.findIndex((f) => f.stock > 0));\n  const [finishIdx, setFinishIdx] = React.useState(firstOk);\n  const [sizeIdx, setSizeIdx] = React.useState(Math.min(1, sizes.length - 1));\n  const [engraveOn, setEngraveOn] = React.useState(true);\n  const [text, setText] = React.useState(\"Maya\");\n  const [angle, setAngle] = React.useState(320);\n  const [dragging, setDragging] = React.useState(false);\n  const [done, setDone] = React.useState(false);\n  const stageRef = React.useRef<HTMLDivElement | null>(null);\n  const angleRef = React.useRef(320);\n  const touched = React.useRef(false);\n  const drag = React.useRef({ on: false, x: 0, a: 0 });\n  const tween = React.useRef(0);\n  const doneTimer = React.useRef(0);\n\n  const finish = finishes[finishIdx] ?? finishes[0];\n  const size = sizes[sizeIdx] ?? sizes[0];\n  const engraving = engraveOn ? text.trim().slice(0, maxEngraving) : \"\";\n  const total = size.price + (engraving ? engravingPrice : 0);\n\n  const setA = React.useCallback((a: number) => {\n    const v = ((a % 360) + 360) % 360;\n    angleRef.current = v;\n    setAngle(v);\n  }, []);\n\n  React.useEffect(() => {\n    const el = stageRef.current;\n    if (!autoSpin || !el) return;\n    if (window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches) return;\n    let raf = 0;\n    let last = 0;\n    let visible = true;\n    const io = new IntersectionObserver((e) => {\n      visible = e[0]?.isIntersecting ?? true;\n    });\n    io.observe(el);\n    const loop = (now: number) => {\n      const dt = last ? Math.min(64, now - last) : 0;\n      last = now;\n      if (visible && !touched.current) setA(angleRef.current + dt * 0.03);\n      if (!touched.current) raf = requestAnimationFrame(loop);\n    };\n    raf = requestAnimationFrame(loop);\n    return () => {\n      cancelAnimationFrame(raf);\n      io.disconnect();\n    };\n  }, [autoSpin, setA]);\n\n  React.useEffect(\n    () => () => {\n      cancelAnimationFrame(tween.current);\n      window.clearTimeout(doneTimer.current);\n    },\n    [],\n  );\n\n  const turnTo = (target: number) => {\n    touched.current = true;\n    cancelAnimationFrame(tween.current);\n    const from = angleRef.current;\n    let delta = ((target - from + 540) % 360) - 180;\n    if (Math.abs(delta) < 0.5) delta = 0;\n    if (window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches || delta === 0) {\n      setA(target);\n      return;\n    }\n    let start = -1;\n    const dur = 650;\n    const step = (now: number) => {\n      if (start < 0) start = now;\n      const t = Math.min(1, (now - start) / dur);\n      const e = 1 - Math.pow(1 - t, 3);\n      setA(from + delta * e);\n      if (t < 1) tween.current = requestAnimationFrame(step);\n    };\n    tween.current = requestAnimationFrame(step);\n  };\n\n  const onDown = (e: React.PointerEvent<HTMLDivElement>) => {\n    touched.current = true;\n    cancelAnimationFrame(tween.current);\n    drag.current = { on: true, x: e.clientX, a: angleRef.current };\n    e.currentTarget.setPointerCapture(e.pointerId);\n    setDragging(true);\n  };\n  const onMove = (e: React.PointerEvent<HTMLDivElement>) => {\n    if (!drag.current.on) return;\n    setA(drag.current.a - (e.clientX - drag.current.x) * 0.7);\n  };\n  const onUp = (e: React.PointerEvent<HTMLDivElement>) => {\n    if (!drag.current.on) return;\n    drag.current.on = false;\n    setDragging(false);\n    if (e.currentTarget.hasPointerCapture(e.pointerId)) e.currentTarget.releasePointerCapture(e.pointerId);\n  };\n\n  const add = () => {\n    if (!finish || finish.stock <= 0) return;\n    onAddToCart?.({ finish: finish.name, size: size.label, engraving, total });\n    setDone(true);\n    window.clearTimeout(doneTimer.current);\n    doneTimer.current = window.setTimeout(() => setDone(false), 2400);\n  };\n\n  const radioKeys = (e: React.KeyboardEvent, count: number, idx: number, set: (i: number) => void, ok: (i: number) => boolean = () => true) => {\n    const dir = e.key === \"ArrowRight\" || e.key === \"ArrowDown\" ? 1 : e.key === \"ArrowLeft\" || e.key === \"ArrowUp\" ? -1 : 0;\n    if (!dir) return;\n    e.preventDefault();\n    let n = idx;\n    for (let s = 0; s < count; s++) {\n      n = (n + dir + count) % count;\n      if (ok(n)) break;\n    }\n    set(n);\n    const group = (e.currentTarget as HTMLElement).parentElement;\n    group?.querySelectorAll<HTMLButtonElement>(\"button\")[n]?.focus();\n  };\n\n  const stockLabel = finish.stock <= 0 ? \"Sold out\" : finish.stock < 6 ? `Only ${finish.stock} left` : \"In stock\";\n  const rounded = Math.round(angle);\n\n  return (\n    <section\n      className={[\"hb-we11\", className].filter(Boolean).join(\" \")}\n      style={{ \"--hb-we11-accent\": accent, ...style } as React.CSSProperties}\n      {...rest}\n    >\n      <style href=\"hb-shop-spin-configurator\" precedence=\"default\">{css}</style>\n      <div className=\"hb-we11-inner\">\n        <div className=\"hb-we11-media\">\n          <div className=\"hb-we11-strip\" role=\"group\" aria-label=\"Views\">\n            {presets.map((p) => (\n              <button key={p.label} type=\"button\" className=\"hb-we11-th\" aria-pressed={Math.abs(((angle - p.angle + 540) % 360) - 180) < 4} aria-label={`${p.label} view`} onClick={() => turnTo(p.angle)}>\n                <Bottle angle={p.angle} color={finish.color} height={size.height} engraving={engraving} brand={brand} uid={`${uid}${p.angle}`} small />\n              </button>\n            ))}\n          </div>\n          <div\n            ref={stageRef}\n            className=\"hb-we11-stage\"\n            data-drag={dragging ? \"true\" : \"false\"}\n            role=\"slider\"\n            tabIndex={0}\n            aria-label={`Rotate ${name}`}\n            aria-valuemin={0}\n            aria-valuemax={359}\n            aria-valuenow={rounded}\n            aria-valuetext={`${rounded} degrees`}\n            onPointerDown={onDown}\n            onPointerMove={onMove}\n            onPointerUp={onUp}\n            onPointerCancel={onUp}\n            onKeyDown={(e) => {\n              if (e.key === \"ArrowRight\" || e.key === \"ArrowLeft\") {\n                e.preventDefault();\n                touched.current = true;\n                setA(angleRef.current + (e.key === \"ArrowRight\" ? -15 : 15));\n              } else if (e.key === \"Home\") {\n                e.preventDefault();\n                turnTo(0);\n              }\n            }}\n          >\n            <div className=\"hb-we11-dial\" aria-hidden=\"true\">\n              <i style={{ \"--hb-we11-dx\": `${(-((angle * 2) % 100)).toFixed(1)}px` } as React.CSSProperties} />\n            </div>\n            <Bottle angle={angle} color={finish.color} height={size.height} engraving={engraving} brand={brand} uid={uid} />\n            <span className=\"hb-we11-hint\" aria-hidden=\"true\">\n              <svg width=\"14\" height=\"14\" viewBox=\"0 0 16 16\" fill=\"none\"><path d=\"M2 8a6 3 0 0 0 12 0M12 6l2 2-2 2\" stroke=\"currentColor\" strokeWidth=\"1.4\" strokeLinecap=\"round\" strokeLinejoin=\"round\" /></svg>\n              Drag to turn\n              <b>{rounded}°</b>\n            </span>\n          </div>\n        </div>\n        <div className=\"hb-we11-info\">\n          <div>\n            <p className=\"hb-we11-brand\">{brand} · Drinkware</p>\n            <h2 className=\"hb-we11-name\">{name}</h2>\n            <p className=\"hb-we11-blurb\">{blurb}</p>\n          </div>\n          <span className=\"hb-we11-price\" key={total} aria-live=\"polite\">{currency}{total}</span>\n          <div className=\"hb-we11-g\">\n            <div className=\"hb-we11-gl\">\n              <span>Finish <b>{finish.name}</b></span>\n              <span className=\"hb-we11-stock\" data-low={finish.stock > 0 && finish.stock < 6 ? \"true\" : \"false\"} data-out={finish.stock <= 0 ? \"true\" : \"false\"}>{stockLabel}</span>\n            </div>\n            <div className=\"hb-we11-sw\" role=\"radiogroup\" aria-label=\"Finish\">\n              {finishes.map((f, i) => (\n                <button\n                  key={f.name}\n                  type=\"button\"\n                  role=\"radio\"\n                  aria-checked={i === finishIdx}\n                  aria-label={`${f.name}${f.stock <= 0 ? \", sold out\" : \"\"}`}\n                  tabIndex={i === finishIdx ? 0 : -1}\n                  disabled={f.stock <= 0}\n                  className=\"hb-we11-swb\"\n                  style={{ \"--hb-we11-c\": f.color } as React.CSSProperties}\n                  onClick={() => setFinishIdx(i)}\n                  onKeyDown={(e) => radioKeys(e, finishes.length, i, setFinishIdx, (n) => finishes[n].stock > 0)}\n                />\n              ))}\n            </div>\n          </div>\n          <div className=\"hb-we11-g\">\n            <div className=\"hb-we11-gl\"><span>Size <b>{size.label}</b></span></div>\n            <div className=\"hb-we11-sizes\" role=\"radiogroup\" aria-label=\"Size\">\n              {sizes.map((s, i) => (\n                <button\n                  key={s.label}\n                  type=\"button\"\n                  role=\"radio\"\n                  aria-checked={i === sizeIdx}\n                  tabIndex={i === sizeIdx ? 0 : -1}\n                  className=\"hb-we11-sz\"\n                  onClick={() => setSizeIdx(i)}\n                  onKeyDown={(e) => radioKeys(e, sizes.length, i, setSizeIdx)}\n                >\n                  <b>{s.label}</b>\n                  <span>{currency}{s.price}</span>\n                </button>\n              ))}\n            </div>\n          </div>\n          <div className=\"hb-we11-eng\">\n            <button type=\"button\" role=\"switch\" aria-checked={engraveOn} className=\"hb-we11-tg\" onClick={() => setEngraveOn((v) => !v)}>\n              <span>\n                Laser engraving\n                <small>Up to {maxEngraving} characters, +{currency}{engravingPrice}</small>\n              </span>\n              <span className=\"hb-we11-sw2\" aria-hidden=\"true\" />\n            </button>\n            {engraveOn ? (\n              <label className=\"hb-we11-in\">\n                <input\n                  value={text}\n                  maxLength={maxEngraving}\n                  aria-label=\"Engraving text\"\n                  placeholder=\"Your name\"\n                  onChange={(e) => {\n                    setText(e.target.value);\n                    turnTo(0);\n                  }}\n                />\n                <span>{text.length}/{maxEngraving}</span>\n              </label>\n            ) : null}\n          </div>\n          <p className=\"hb-we11-sum\">\n            <b>{name}</b>, {size.label} in {finish.name}{engraving ? <>, engraved <b>{engraving.toUpperCase()}</b></> : null}. Ships in {engraving ? \"3 days\" : \"1 day\"}.\n          </p>\n          <button type=\"button\" className=\"hb-we11-add\" data-done={done ? \"true\" : \"false\"} disabled={finish.stock <= 0} onClick={add} aria-live=\"polite\">\n            {done ? (\n              <>\n                <svg viewBox=\"0 0 20 20\" fill=\"none\" aria-hidden=\"true\"><path d=\"M5 10.5l3.2 3.2L15 7\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\" /></svg>\n                Added to cart\n              </>\n            ) : (\n              <>Add to cart · {currency}{total}</>\n            )}\n          </button>\n        </div>\n      </div>\n    </section>\n  );\n}\n"
    }
  ]
}