{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "product-carousel-block",
  "title": "Product Carousel Block",
  "description": "A featured product carousel: one product per slide with a big title, specs, price and shop button, photos that glide in, autoplay with filling progress bars (pauses on hover, focus or the pause button), swipe and drag, arrow keys and prev / next buttons.",
  "dependencies": [
    "motion",
    "clsx",
    "tailwind-merge"
  ],
  "files": [
    {
      "path": "registry/new-york/product-carousel-block/product-carousel-block.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\nimport { AnimatePresence, animate, motion, useMotionValue, useReducedMotion, useTransform, type MotionValue } 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 CarouselSlide {\n  id: string;\n  eyebrow: string;\n  title: string;\n  description: string;\n  price: number;\n  compareAtPrice?: number;\n  image: string;\n  specs: string[];\n}\n\nexport interface ProductCarouselBlockProps {\n  slides?: CarouselSlide[];\n  /** Seconds per slide when autoplaying. */\n  interval?: number;\n  autoplay?: boolean;\n  currency?: string;\n  onShop?: (slide: CarouselSlide) => void;\n  theme?: \"dark\" | \"light\";\n  className?: string;\n}\n\nconst PALETTES = {\n  dark: { bg: \"#0A0A0A\", panel: \"#F1F1F1\", title: \"#111111\", muted: \"rgba(17,17,17,0.55)\", line: \"rgba(17,17,17,0.12)\", track: \"rgba(17,17,17,0.14)\", btnBg: \"#111111\", btnText: \"#FFFFFF\", accent: \"#2F9E44\", ring: \"rgba(17,17,17,0.5)\", outer: \"#FFFFFF\" },\n  light: { bg: \"#FFFFFF\", panel: \"#F1F1F1\", title: \"#111111\", muted: \"rgba(17,17,17,0.55)\", line: \"rgba(17,17,17,0.12)\", track: \"rgba(17,17,17,0.14)\", btnBg: \"#111111\", btnText: \"#FFFFFF\", accent: \"#2F9E44\", ring: \"rgba(17,17,17,0.5)\", outer: \"#111111\" },\n};\nconst SLIDES: CarouselSlide[] = [\n  { id: \"earbuds\", eyebrow: \"New · Audio\", title: \"Wireless Earbuds\", description: \"Noise cancelling that fits in a pocket. 30 hours with the case.\", price: 129, image: \"/demo/wireless-earbuds.webp\", specs: [\"ANC\", \"30h battery\", \"IPX4\"] },\n  { id: \"watch\", eyebrow: \"Best seller\", title: \"Minimal Watch\", description: \"A slim matte case on soft leather. Nothing on the dial you don't need.\", price: 79, compareAtPrice: 129, image: \"/demo/minimal-watch.webp\", specs: [\"40mm\", \"Quartz\", \"3 ATM\"] },\n  { id: \"shoes\", eyebrow: \"Running\", title: \"Running Shoes\", description: \"Light mesh, springy foam and grip for road and track.\", price: 99, compareAtPrice: 149, image: \"/demo/running-shoes.webp\", specs: [\"248 g\", \"8 mm drop\", \"Recycled mesh\"] },\n  { id: \"stand\", eyebrow: \"Desk setup\", title: \"Laptop Stand\", description: \"Raises your screen to eye level and folds flat for the bag.\", price: 49, compareAtPrice: 89, image: \"/demo/laptop-stand.webp\", specs: [\"Aluminium\", \"6 heights\", \"Folds flat\"] },\n];\n\nfunction Bar({ i, active, progress, done, color, track }: { i: number; active: number; progress: MotionValue<number>; done: boolean; color: string; track: string }) {\n  const width = useTransform(progress, (v) => `${(i === active ? v : done ? 1 : 0) * 100}%`);\n  return (\n    <span className=\"block h-[3px] w-full overflow-hidden rounded-full\" style={{ background: track }}>\n      <motion.span className=\"block h-full rounded-full\" style={{ width, background: color }} />\n    </span>\n  );\n}\n\nexport function ProductCarouselBlock({ slides = SLIDES, interval = 5, autoplay = true, currency = \"$\", onShop, theme = \"dark\", className }: ProductCarouselBlockProps) {\n  const p = PALETTES[theme];\n  const reduce = !!useReducedMotion();\n  const uid = React.useId();\n  const [index, setIndex] = React.useState(0);\n  const [dir, setDir] = React.useState(1);\n  const [paused, setPaused] = React.useState(false);\n  const progress = useMotionValue(0);\n  const slide = slides[index];\n\n  const go = React.useCallback(\n    (i: number, d?: number) => {\n      const n = (i + slides.length) % slides.length;\n      setDir(d ?? (n > index ? 1 : -1));\n      setIndex(n);\n      progress.set(0);\n    },\n    [slides.length, index, progress],\n  );\n\n  React.useEffect(() => {\n    if (!autoplay || paused || reduce) return;\n    const c = animate(progress, 1, { duration: interval * (1 - progress.get()), ease: \"linear\", onComplete: () => go(index + 1, 1) });\n    return () => c.stop();\n  }, [autoplay, paused, reduce, interval, index, go, progress]);\n\n  const ring = { [\"--tw-ring-color\" as string]: p.ring, [\"--tw-ring-offset-color\" as string]: p.panel } as React.CSSProperties;\n  const focus = \"outline-none focus-visible:ring-2 focus-visible:ring-offset-2\";\n  const money = (n: number) => `${currency}${n.toFixed(2)}`;\n\n  return (\n    <section className={cn(\"@container w-full\", className)} style={{ background: p.bg }} aria-roledescription=\"carousel\" aria-label=\"Featured products\">\n      <div className=\"mx-auto max-w-6xl px-4 py-10 @[640px]:px-8\">\n        <div\n          className=\"relative overflow-hidden rounded-[28px]\"\n          style={{ background: p.panel, color: p.title }}\n          onMouseEnter={() => setPaused(true)}\n          onMouseLeave={() => setPaused(false)}\n          onFocus={() => setPaused(true)}\n          onBlur={(e) => !e.currentTarget.contains(e.relatedTarget as Node) && setPaused(false)}\n          onKeyDown={(e) => {\n            if (e.key === \"ArrowRight\") go(index + 1, 1);\n            if (e.key === \"ArrowLeft\") go(index - 1, -1);\n          }}\n        >\n          <AnimatePresence mode=\"popLayout\" initial={false} custom={dir}>\n            <motion.div\n              key={slide.id}\n              role=\"group\"\n              aria-roledescription=\"slide\"\n              aria-label={`${index + 1} of ${slides.length}: ${slide.title}`}\n              className=\"grid min-h-[520px] grid-cols-1 @[820px]:min-h-[480px] @[820px]:grid-cols-[minmax(0,0.9fr)_minmax(0,1.1fr)]\"\n              drag={reduce ? false : \"x\"}\n              dragConstraints={{ left: 0, right: 0 }}\n              dragElastic={0.18}\n              onDragEnd={(_, info) => {\n                if (info.offset.x < -70 || info.velocity.x < -400) go(index + 1, 1);\n                else if (info.offset.x > 70 || info.velocity.x > 400) go(index - 1, -1);\n              }}\n              initial={reduce ? false : { opacity: 0 }}\n              animate={{ opacity: 1 }}\n              exit={reduce ? undefined : { opacity: 0 }}\n              transition={{ duration: 0.35 }}\n            >\n              <div className=\"relative z-[1] flex flex-col justify-center px-7 pt-8 pb-4 @[640px]:px-12 @[820px]:pb-16\">\n                <motion.p className=\"m-0 text-[12px] font-semibold tracking-[0.12em] uppercase\" style={{ color: p.accent }} initial={reduce ? false : { opacity: 0, x: dir * 30 }} animate={{ opacity: 1, x: 0 }} transition={{ duration: 0.45, delay: 0.05, ease: [0.22, 1, 0.36, 1] }}>\n                  {slide.eyebrow}\n                </motion.p>\n                <motion.h2 className=\"m-0 mt-3 text-[38px] leading-[1] font-semibold tracking-[-0.04em] @[640px]:text-[58px]\" initial={reduce ? false : { opacity: 0, x: dir * 50 }} animate={{ opacity: 1, x: 0 }} transition={{ duration: 0.5, delay: 0.1, ease: [0.22, 1, 0.36, 1] }}>\n                  {slide.title}\n                </motion.h2>\n                <motion.p className=\"m-0 mt-4 max-w-[34ch] text-[15px] leading-relaxed\" style={{ color: p.muted }} initial={reduce ? false : { opacity: 0, x: dir * 40 }} animate={{ opacity: 1, x: 0 }} transition={{ duration: 0.5, delay: 0.16, ease: [0.22, 1, 0.36, 1] }}>\n                  {slide.description}\n                </motion.p>\n                <motion.ul className=\"m-0 mt-5 flex list-none flex-wrap gap-1.5 p-0\" initial={reduce ? false : { opacity: 0 }} animate={{ opacity: 1 }} transition={{ delay: 0.25 }}>\n                  {slide.specs.map((s) => (\n                    <li key={s} className=\"rounded-full border px-3 py-1 text-[12px]\" style={{ borderColor: p.line, color: p.title }}>\n                      {s}\n                    </li>\n                  ))}\n                </motion.ul>\n                <motion.div className=\"mt-7 flex flex-wrap items-center gap-4\" initial={reduce ? false : { opacity: 0, y: 10 }} animate={{ opacity: 1, y: 0 }} transition={{ duration: 0.45, delay: 0.24 }}>\n                  <button type=\"button\" onClick={() => onShop?.(slide)} className={cn(\"group inline-flex h-12 cursor-pointer items-center gap-2 rounded-full border-0 px-6 text-[15px] font-semibold\", focus)} style={{ background: p.btnBg, color: p.btnText, ...ring }}>\n                    Shop now\n                    <span className=\"transition-transform group-hover:translate-x-1\" aria-hidden=\"true\">\n                      →\n                    </span>\n                  </button>\n                  <span className=\"flex items-baseline gap-2\">\n                    <span className=\"text-[22px] font-semibold tabular-nums\">{money(slide.price)}</span>\n                    {slide.compareAtPrice && (\n                      <span className=\"text-[14px] tabular-nums line-through\" style={{ color: p.muted }}>\n                        {money(slide.compareAtPrice)}\n                      </span>\n                    )}\n                  </span>\n                </motion.div>\n              </div>\n              <div className=\"relative min-h-[260px] select-none @[820px]:min-h-0\">\n                <motion.img\n                  src={slide.image}\n                  alt={slide.title}\n                  draggable={false}\n                  className=\"pointer-events-none absolute inset-0 h-full w-full object-contain object-center @[820px]:pb-14\"\n                  initial={reduce ? false : { scale: 1.12, x: dir * 80, opacity: 0 }}\n                  animate={{ scale: 1, x: 0, opacity: 1 }}\n                  transition={{ duration: 0.8, ease: [0.22, 1, 0.36, 1] }}\n                />\n                <motion.span key={`n-${slide.id}`} className=\"pointer-events-none absolute top-6 right-7 text-[96px] leading-none font-semibold tracking-[-0.05em] tabular-nums @[820px]:text-[140px]\" style={{ color: \"rgba(17,17,17,0.06)\" }} initial={reduce ? false : { y: 40, opacity: 0 }} animate={{ y: 0, opacity: 1 }} transition={{ duration: 0.6 }} aria-hidden=\"true\">\n                  0{index + 1}\n                </motion.span>\n              </div>\n            </motion.div>\n          </AnimatePresence>\n\n          {/* Controls */}\n          <div className=\"absolute right-0 bottom-0 left-0 z-[2] flex items-center gap-4 px-7 pb-6 @[640px]:px-12\">\n            <div className=\"flex flex-1 gap-2\" role=\"tablist\" aria-label=\"Choose a product\">\n              {slides.map((s, i) => (\n                <button key={s.id} type=\"button\" role=\"tab\" aria-selected={i === index} aria-label={s.title} onClick={() => go(i)} className={cn(\"flex-1 cursor-pointer rounded border-0 bg-transparent py-2\", focus)} style={ring}>\n                  <Bar i={i} active={index} progress={progress} done={i < index} color={p.title} track={p.track} />\n                  <span className=\"mt-2 hidden truncate text-left text-[11.5px] @[640px]:block\" style={{ color: i === index ? p.title : p.muted }}>\n                    {s.title}\n                  </span>\n                </button>\n              ))}\n            </div>\n            <div className=\"flex shrink-0 gap-2\">\n              <button type=\"button\" onClick={() => setPaused((x) => !x)} aria-label={paused ? \"Play slideshow\" : \"Pause slideshow\"} aria-pressed={paused} className={cn(\"grid h-10 w-10 cursor-pointer place-items-center rounded-full border bg-transparent\", focus)} style={{ borderColor: p.line, color: p.title, ...ring }}>\n                {paused ? (\n                  <svg width=\"12\" height=\"12\" viewBox=\"0 0 24 24\" fill=\"currentColor\" aria-hidden=\"true\">\n                    <path d=\"M7 4v16l13-8z\" />\n                  </svg>\n                ) : (\n                  <svg width=\"12\" height=\"12\" viewBox=\"0 0 24 24\" fill=\"currentColor\" aria-hidden=\"true\">\n                    <path d=\"M6 4h4v16H6zM14 4h4v16h-4z\" />\n                  </svg>\n                )}\n              </button>\n              {[-1, 1].map((d) => (\n                <button key={d} type=\"button\" onClick={() => go(index + d, d)} aria-label={d < 0 ? \"Previous slide\" : \"Next slide\"} aria-controls={`${uid}-live`} className={cn(\"grid h-10 w-10 cursor-pointer place-items-center rounded-full border-0\", focus)} style={{ background: p.btnBg, color: p.btnText, ...ring }}>\n                  <svg width=\"15\" height=\"15\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\">\n                    <path d={d < 0 ? \"M15 18 9 12l6-6\" : \"m9 18 6-6-6-6\"} />\n                  </svg>\n                </button>\n              ))}\n            </div>\n          </div>\n          <p id={`${uid}-live`} className=\"sr-only\" aria-live={paused ? \"polite\" : \"off\"}>\n            {slide.title}, {money(slide.price)}\n          </p>\n        </div>\n      </div>\n    </section>\n  );\n}\n\nexport default ProductCarouselBlock;\n",
      "type": "registry:component"
    }
  ],
  "type": "registry:component"
}