{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"animated-testimonials","type":"registry:ui","title":"Animated Testimonials","description":"A stack of tilted photo cards that shuffles to the active person while their quote blurs in word by word.","dependencies":["motion","lucide-react"],"registryDependencies":[],"files":[{"path":"registry/ui/animated-testimonials.tsx","type":"registry:ui","content":"\"use client\";\n\nimport { useCallback, useEffect, useState, type KeyboardEvent } from \"react\";\nimport { AnimatePresence, motion, useReducedMotion } from \"motion/react\";\nimport { ArrowLeft, ArrowRight } from \"lucide-react\";\n\nexport interface Testimonial {\n  quote: string;\n  name: string;\n  role: string;\n  src: string;\n}\n\nexport interface AnimatedTestimonialsProps {\n  testimonials: Testimonial[];\n  /** Advance automatically. Pauses while hovered or focused. */\n  autoplay?: boolean;\n  /** Ms between slides when autoplaying. */\n  interval?: number;\n  /** Seconds between each word of the quote appearing. */\n  wordDelay?: number;\n  className?: string;\n}\n\n// Deterministic tilt per card so SSR and client agree.\nconst tilt = (i: number) => ((i * 37) % 21) - 10;\n\nexport function AnimatedTestimonials({\n  testimonials,\n  autoplay = true,\n  interval = 5000,\n  wordDelay = 0.03,\n  className,\n}: AnimatedTestimonialsProps) {\n  const [active, setActive] = useState(0);\n  const [paused, setPaused] = useState(false);\n  const reduce = useReducedMotion();\n  const n = testimonials.length;\n\n  const go = useCallback((d: number) => setActive((a) => (a + d + n) % n), [n]);\n\n  useEffect(() => {\n    if (!autoplay || paused || n < 2) return;\n    const id = window.setTimeout(() => go(1), interval);\n    return () => window.clearTimeout(id);\n  }, [autoplay, paused, interval, go, n, active]);\n\n  const onKey = (e: KeyboardEvent) => {\n    if (e.key === \"ArrowRight\") go(1);\n    else if (e.key === \"ArrowLeft\") go(-1);\n  };\n\n  const t = testimonials[active];\n  if (!t) return null;\n\n  return (\n    <section\n      aria-roledescription=\"carousel\"\n      aria-label=\"Testimonials\"\n      onKeyDown={onKey}\n      onPointerEnter={() => setPaused(true)}\n      onPointerLeave={() => setPaused(false)}\n      onFocus={() => setPaused(true)}\n      onBlur={() => setPaused(false)}\n      className={`grid w-full items-center gap-10 md:grid-cols-[minmax(0,1fr)_minmax(0,1.2fr)] md:gap-14 ${className ?? \"\"}`}\n    >\n      <div className=\"relative mx-auto aspect-square w-full max-w-72\" aria-hidden>\n        {testimonials.map((item, i) => {\n          const on = i === active;\n          // Distance behind the active card, 0..n-1.\n          const depth = (i - active + n) % n;\n          return (\n            <motion.img\n              key={item.src + i}\n              src={item.src}\n              alt=\"\"\n              draggable={false}\n              className=\"absolute inset-0 size-full rounded-3xl object-cover shadow-[0_30px_60px_-25px_rgba(0,0,0,.8)]\"\n              initial={false}\n              animate={{\n                rotate: on ? 0 : tilt(i),\n                scale: on ? 1 : 0.92 - Math.min(depth, 3) * 0.02,\n                y: on ? 0 : -Math.min(depth, 3) * 6,\n                opacity: on ? 1 : depth > 3 ? 0 : 0.55,\n                zIndex: on ? n + 1 : n - depth,\n              }}\n              transition={reduce ? { duration: 0 } : { type: \"spring\", stiffness: 220, damping: 26 }}\n            />\n          );\n        })}\n      </div>\n\n      <div className=\"flex min-h-64 flex-col justify-between gap-8\">\n        <AnimatePresence mode=\"wait\" initial={false}>\n          <motion.div\n            key={active}\n            initial={{ opacity: 0, y: reduce ? 0 : 16 }}\n            animate={{ opacity: 1, y: 0 }}\n            exit={{ opacity: 0, y: reduce ? 0 : -16 }}\n            transition={{ duration: reduce ? 0 : 0.25, ease: \"easeOut\" }}\n            aria-live=\"polite\"\n          >\n            <h3 className=\"text-2xl font-semibold tracking-tight text-foreground\">{t.name}</h3>\n            <p className=\"mt-1 text-sm text-muted-foreground\">{t.role}</p>\n            <blockquote className=\"mt-6 text-lg leading-relaxed text-foreground/90\">\n              <span className=\"sr-only\">{t.quote}</span>\n              <span aria-hidden>\n                {t.quote.split(\" \").map((word, i) => (\n                  <motion.span\n                    key={i}\n                    className=\"inline-block\"\n                    initial={reduce ? false : { filter: \"blur(10px)\", opacity: 0, y: 6 }}\n                    animate={{ filter: \"blur(0px)\", opacity: 1, y: 0 }}\n                    transition={{ duration: 0.3, ease: \"easeOut\", delay: i * wordDelay }}\n                  >\n                    {word}&nbsp;\n                  </motion.span>\n                ))}\n              </span>\n            </blockquote>\n          </motion.div>\n        </AnimatePresence>\n\n        <div className=\"flex items-center gap-3\">\n          {[\n            { d: -1, label: \"Previous testimonial\", Icon: ArrowLeft },\n            { d: 1, label: \"Next testimonial\", Icon: ArrowRight },\n          ].map(({ d, label, Icon }) => (\n            <button\n              key={d}\n              type=\"button\"\n              aria-label={label}\n              onClick={() => go(d)}\n              className=\"group grid size-10 place-items-center rounded-full border border-border bg-muted text-foreground outline-none transition-colors hover:bg-card focus-visible:ring-2 focus-visible:ring-ring\"\n            >\n              <Icon\n                className={`size-5 transition-transform duration-300 ${d < 0 ? \"group-hover:-translate-x-0.5\" : \"group-hover:translate-x-0.5\"}`}\n              />\n            </button>\n          ))}\n          <span className=\"ml-2 font-mono text-xs tabular-nums text-muted-foreground\">\n            {String(active + 1).padStart(2, \"0\")} / {String(n).padStart(2, \"0\")}\n          </span>\n        </div>\n      </div>\n    </section>\n  );\n}\n"}]}