{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "product-highlight-block",
  "title": "Product Highlight Block",
  "description": "A featured product spotlight: a large photo with numbered hotspots that pulse and sync with a feature list, a floating caption card, rating, key stats, an optional add-on, an animated price and an add-to-cart button with loading and added states.",
  "dependencies": [
    "motion",
    "clsx",
    "tailwind-merge"
  ],
  "files": [
    {
      "path": "registry/new-york/product-highlight-block/product-highlight-block.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 HighlightFeature {\n  title: string;\n  body: string;\n  /** Hotspot position over the image, in percent. */\n  x: number;\n  y: number;\n}\n\nexport interface ProductHighlightBlockProps {\n  eyebrow?: string;\n  title?: string;\n  description?: string;\n  price?: number;\n  compareAtPrice?: number;\n  rating?: number;\n  reviewCount?: number;\n  image?: string;\n  features?: HighlightFeature[];\n  stats?: { value: string; label: string }[];\n  addOn?: { label: string; price: number };\n  currency?: string;\n  /** Return a Promise to keep the button in its loading state until the cart updates. */\n  onAddToCart?: (item: { title: string; total: number; addOn: boolean }) => void | Promise<void>;\n  theme?: \"dark\" | \"light\";\n  className?: string;\n}\n\nconst PALETTES = {\n  dark: { bg: \"#0A0A0A\", title: \"#FFFFFF\", muted: \"rgba(255,255,255,0.45)\", body: \"rgba(255,255,255,0.62)\", line: \"rgba(255,255,255,0.12)\", card: \"#161616\", photo: \"#F1F1F1\", buttonBg: \"#FFFFFF\", buttonText: \"#111111\", accent: \"#7CDE6A\", amber: \"#F5B544\", ring: \"rgba(255,255,255,0.5)\" },\n  light: { bg: \"#FFFFFF\", title: \"#111111\", muted: \"rgba(0,0,0,0.45)\", body: \"rgba(0,0,0,0.62)\", line: \"rgba(0,0,0,0.1)\", card: \"#F2F2F2\", photo: \"#F1F1F1\", buttonBg: \"#111111\", buttonText: \"#FFFFFF\", accent: \"#2F9E44\", amber: \"#B7791F\", ring: \"rgba(0,0,0,0.45)\" },\n};\nconst FEATURES: HighlightFeature[] = [\n  { title: \"Active noise cancelling\", body: \"Three microphones per bud cancel trains, traffic and open-plan chatter.\", x: 20, y: 58 },\n  { title: \"30 hours with the case\", body: \"Drop them in for a top-up: the pocket case holds three full charges.\", x: 50, y: 41 },\n  { title: \"Sweat and rain resistant\", body: \"IPX4 rated, with a secure fit that stays put on a run.\", x: 80, y: 60 },\n];\nconst STATS = [\n  { value: \"8h\", label: \"Per charge\" },\n  { value: \"5 min\", label: \"= 1h listening\" },\n  { value: \"4.8 g\", label: \"Per bud\" },\n];\n\nexport function ProductHighlightBlock({\n  eyebrow = \"Product of the month\",\n  title = \"Wireless Earbuds\",\n  description = \"Small enough to forget, quiet enough to focus. Noise cancelling, 30 hours with the case and a fit that stays put.\",\n  price = 129,\n  compareAtPrice,\n  rating = 4.8,\n  reviewCount = 1846,\n  image = \"/demo/wireless-earbuds.webp\",\n  features = FEATURES,\n  stats = STATS,\n  addOn = { label: \"Add a silicone case cover\", price: 15 },\n  currency = \"$\",\n  onAddToCart,\n  theme = \"dark\",\n  className,\n}: ProductHighlightBlockProps) {\n  const p = PALETTES[theme];\n  const reduce = !!useReducedMotion();\n  const uid = React.useId();\n  const [active, setActive] = React.useState(0);\n  const [withAddOn, setWithAddOn] = React.useState(false);\n  const [state, setState] = React.useState<\"idle\" | \"loading\" | \"added\">(\"idle\");\n  const [imgOk, setImgOk] = React.useState(true);\n  const total = price + (withAddOn ? addOn.price : 0);\n  const money = (n: number) => `${currency}${n.toFixed(2)}`;\n\n  React.useEffect(() => {\n    if (state !== \"added\") return;\n    const t = setTimeout(() => setState(\"idle\"), 2400);\n    return () => clearTimeout(t);\n  }, [state]);\n\n  const add = async () => {\n    if (state === \"loading\") return;\n    setState(\"loading\");\n    try {\n      await (onAddToCart ? onAddToCart({ title, total, addOn: withAddOn }) : new Promise((r) => setTimeout(r, reduce ? 0 : 700)));\n      setState(\"added\");\n    } catch {\n      setState(\"idle\");\n    }\n  };\n\n  const ring = { [\"--tw-ring-color\" as string]: p.ring, [\"--tw-ring-offset-color\" as string]: p.bg } as React.CSSProperties;\n  const focus = \"outline-none focus-visible:ring-2 focus-visible:ring-offset-2\";\n\n  return (\n    <section className={cn(\"@container w-full\", className)} style={{ background: p.bg, color: p.title }} aria-labelledby={`${uid}-title`}>\n      <div className=\"mx-auto grid max-w-6xl grid-cols-1 items-center gap-8 px-4 py-12 @[860px]:grid-cols-[minmax(0,1.05fr)_minmax(0,1fr)] @[860px]:gap-12 @[640px]:px-8\">\n        {/* Image with hotspots */}\n        <div className=\"relative aspect-square w-full overflow-hidden rounded-3xl\" style={{ background: p.photo }}>\n          {imgOk ? (\n            <motion.img src={image} alt={title} onError={() => setImgOk(false)} className=\"absolute inset-0 h-full w-full object-cover\" initial={reduce ? false : { scale: 1.04, opacity: 0 }} animate={{ scale: 1, opacity: 1 }} transition={{ duration: 0.8, ease: [0.22, 1, 0.36, 1] }} />\n          ) : (\n            <span className=\"absolute inset-0 grid place-items-center text-[64px] font-semibold text-black/15\">{title[0]}</span>\n          )}\n          {features.map((f, i) => {\n            const on = i === active;\n            return (\n              <button\n                key={f.title}\n                type=\"button\"\n                onClick={() => setActive(i)}\n                onMouseEnter={() => setActive(i)}\n                aria-label={`Feature ${i + 1}: ${f.title}`}\n                aria-pressed={on}\n                className={cn(\"absolute grid h-9 w-9 -translate-x-1/2 -translate-y-1/2 cursor-pointer place-items-center rounded-full border-0 p-0\", focus)}\n                style={{ left: `${f.x}%`, top: `${f.y}%`, ...ring }}\n              >\n                {!reduce && on && <motion.span className=\"absolute inset-0 rounded-full\" style={{ background: \"rgba(17,17,17,0.25)\" }} animate={{ scale: [1, 1.9], opacity: [0.6, 0] }} transition={{ repeat: Infinity, duration: 1.6, ease: \"easeOut\" }} />}\n                <motion.span className=\"relative grid h-7 w-7 place-items-center rounded-full text-[12px] font-semibold shadow-lg\" animate={{ scale: on ? 1.08 : 1, backgroundColor: on ? \"#111111\" : \"#FFFFFF\", color: on ? \"#FFFFFF\" : \"#111111\" }} transition={{ duration: reduce ? 0 : 0.2 }}>\n                  {i + 1}\n                </motion.span>\n              </button>\n            );\n          })}\n          <AnimatePresence mode=\"popLayout\" initial={false}>\n            <motion.div key={active} initial={reduce ? false : { opacity: 0, y: 8 }} animate={{ opacity: 1, y: 0 }} exit={reduce ? undefined : { opacity: 0, y: -6 }} transition={{ duration: 0.25 }} className=\"absolute right-3 bottom-3 left-3 rounded-2xl px-4 py-3 shadow-xl backdrop-blur-md @[480px]:right-auto @[480px]:max-w-[300px]\" style={{ background: \"rgba(255,255,255,0.86)\", color: \"#111\" }} aria-live=\"polite\">\n              <p className=\"m-0 text-[13px] font-semibold\">{features[active]?.title}</p>\n              <p className=\"m-0 mt-0.5 text-[12px] leading-snug text-black/60\">{features[active]?.body}</p>\n            </motion.div>\n          </AnimatePresence>\n        </div>\n\n        {/* Copy + buy */}\n        <div>\n          <p className=\"m-0 text-[12px] font-medium tracking-[0.12em] uppercase\" style={{ color: p.accent }}>\n            {eyebrow}\n          </p>\n          <h2 id={`${uid}-title`} className=\"m-0 mt-3 text-[34px] leading-[1.05] font-semibold tracking-[-0.03em] @[640px]:text-[44px]\">\n            {title}\n          </h2>\n          <div className=\"mt-3 flex items-center gap-2 text-[13px]\" style={{ color: p.muted }}>\n            <span className=\"flex gap-0.5\" role=\"img\" aria-label={`${rating} out of 5`}>\n              {[1, 2, 3, 4, 5].map((i) => (\n                <svg key={i} width=\"13\" height=\"13\" viewBox=\"0 0 24 24\" fill={i <= Math.round(rating) ? p.title : \"none\"} stroke={p.title} strokeWidth=\"1.6\" aria-hidden=\"true\">\n                  <path d=\"m12 3 2.7 5.6 6.1.9-4.4 4.3 1 6.1L12 17l-5.5 2.9 1-6.1L3.2 9.5l6.1-.9z\" />\n                </svg>\n              ))}\n            </span>\n            {rating.toFixed(1)} · {reviewCount.toLocaleString(\"en-US\")} reviews\n          </div>\n          <p className=\"m-0 mt-4 max-w-[46ch] text-[15px] leading-relaxed\" style={{ color: p.body }}>\n            {description}\n          </p>\n\n          <ol className=\"m-0 mt-6 flex list-none flex-col gap-1 p-0\">\n            {features.map((f, i) => (\n              <li key={f.title}>\n                <button type=\"button\" onClick={() => setActive(i)} onMouseEnter={() => setActive(i)} aria-pressed={i === active} className={cn(\"flex w-full cursor-pointer items-center gap-3 rounded-xl border-0 bg-transparent px-3 py-2.5 text-left transition-colors\", focus)} style={{ background: i === active ? p.card : \"transparent\", color: p.title, ...ring }}>\n                  <span className=\"grid h-6 w-6 shrink-0 place-items-center rounded-full text-[11px] font-semibold transition-colors\" style={{ background: i === active ? p.title : \"transparent\", color: i === active ? p.bg : p.muted, border: `1px solid ${i === active ? p.title : p.line}` }}>\n                    {i + 1}\n                  </span>\n                  <span className=\"text-[14px] font-medium\" style={{ color: i === active ? p.title : p.body }}>\n                    {f.title}\n                  </span>\n                </button>\n              </li>\n            ))}\n          </ol>\n\n          <dl className=\"m-0 mt-6 grid grid-cols-3 border-y py-4\" style={{ borderColor: p.line }}>\n            {stats.map((s, i) => (\n              <div key={s.label} className={cn(\"px-1\", i > 0 && \"border-l pl-4\")} style={{ borderColor: p.line }}>\n                <dt className=\"sr-only\">{s.label}</dt>\n                <dd className=\"m-0 text-[22px] font-semibold tracking-[-0.02em] tabular-nums\">{s.value}</dd>\n                <p className=\"m-0 text-[12px]\" style={{ color: p.muted }} aria-hidden=\"true\">\n                  {s.label}\n                </p>\n              </div>\n            ))}\n          </dl>\n\n          <label className=\"mt-5 flex cursor-pointer items-center gap-3 rounded-xl border px-3.5 py-3 has-[:focus-visible]:ring-2\" style={{ borderColor: withAddOn ? p.title : p.line, ...ring }}>\n            <input type=\"checkbox\" checked={withAddOn} onChange={(e) => setWithAddOn(e.target.checked)} className=\"h-4 w-4 cursor-pointer\" style={{ accentColor: p.title }} />\n            <span className=\"flex-1 text-[13.5px]\">{addOn.label}</span>\n            <span className=\"text-[13.5px] tabular-nums\" style={{ color: p.muted }}>\n              +{money(addOn.price)}\n            </span>\n          </label>\n\n          <div className=\"mt-5 flex flex-wrap items-center gap-4\">\n            <div className=\"flex items-baseline gap-2\">\n              <AnimatePresence mode=\"popLayout\" initial={false}>\n                <motion.span key={total} initial={reduce ? false : { opacity: 0, y: 8 }} animate={{ opacity: 1, y: 0 }} exit={reduce ? undefined : { opacity: 0, y: -8 }} className=\"text-[30px] font-semibold tracking-[-0.02em] tabular-nums\">\n                  {money(total)}\n                </motion.span>\n              </AnimatePresence>\n              {compareAtPrice && (\n                <span className=\"text-[15px] tabular-nums line-through\" style={{ color: p.muted }}>\n                  {money(compareAtPrice)}\n                </span>\n              )}\n            </div>\n            <span className=\"rounded-full px-2.5 py-1 text-[11.5px] font-medium\" style={{ background: `${p.amber}1F`, color: p.amber }}>\n              Free shipping · 30-day returns\n            </span>\n          </div>\n          <button type=\"button\" onClick={add} aria-live=\"polite\" className={cn(\"relative mt-4 flex h-12 w-full cursor-pointer items-center justify-center gap-2 overflow-hidden rounded-full border-0 text-[15px] font-semibold\", focus)} style={{ background: state === \"added\" ? p.accent : p.buttonBg, color: state === \"added\" ? \"#0A0A0A\" : p.buttonText, transition: \"background-color .25s\", ...ring }}>\n            <AnimatePresence mode=\"popLayout\" initial={false}>\n              <motion.span key={state} initial={reduce ? false : { opacity: 0, y: 12 }} animate={{ opacity: 1, y: 0 }} exit={reduce ? undefined : { opacity: 0, y: -12 }} transition={{ duration: 0.2 }} className=\"flex items-center gap-2\">\n                {state === \"loading\" ? (\n                  <>\n                    <motion.span className=\"h-4 w-4 rounded-full border-2 border-current border-t-transparent\" animate={reduce ? undefined : { rotate: 360 }} transition={{ repeat: Infinity, duration: 0.7, ease: \"linear\" }} aria-hidden=\"true\" />\n                    Adding…\n                  </>\n                ) : state === \"added\" ? (\n                  <>✓ Added to cart</>\n                ) : (\n                  <>Add to cart · {money(total)}</>\n                )}\n              </motion.span>\n            </AnimatePresence>\n          </button>\n        </div>\n      </div>\n    </section>\n  );\n}\n\nexport default ProductHighlightBlock;\n",
      "type": "registry:component"
    }
  ],
  "type": "registry:component"
}