{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"testimonial-carousel","type":"registry:component","title":"Testimonial Carousel","description":"A testimonial carousel with a soft word-by-word quote reveal, a directional slide, an avatar picker, company wordmarks and score chips, and an autoplay hairline that pauses on hover, focus and drag. Swipe, drag or use the arrow keys.","dependencies":[],"registryDependencies":[],"files":[{"path":"components/viberdy/testimonial-carousel.tsx","content":"\"use client\";\n\nimport { Fragment, useEffect, useRef, useState, useSyncExternalStore } from \"react\";\nimport type { CSSProperties, KeyboardEvent as ReactKeyboardEvent, PointerEvent as ReactPointerEvent } from \"react\";\n\n/**\n * TestimonialCarousel — one large quote at a time.\n *\n * Words rise into place with a soft blur-in, the old quote slides away in the\n * direction of travel, and a hairline progress bar along the bottom edge runs\n * the autoplay clock (it pauses on hover, on focus, while dragging, off-screen\n * and in a hidden tab). Pick a quote from the avatar row, use the arrow\n * buttons or the arrow keys, or swipe and drag. Each quote can carry a\n * company wordmark (drawn as inline SVG) and a score chip. Respects\n * prefers-reduced-motion (calm fades, no autoplay). No dependencies beyond\n * React.\n */\n\nexport type Testimonial = {\n  quote: string;\n  name: string;\n  role: string;\n  /** Company name. Drawn as a small inline-SVG wordmark above the quote. */\n  company?: string;\n  /** 0 to 5. Shown as a star chip. */\n  score?: number;\n  /** Optional avatar image URL (https or a site path). Initials are used otherwise. */\n  avatar?: string;\n};\n\nexport type TestimonialCarouselProps = {\n  testimonials: Testimonial[];\n  autoAdvance?: boolean;\n  interval?: number;\n  /** \"inherit\" (default) is transparent and takes the page's text colour; \"dark\" paints an OLED card, \"light\" a white one. */\n  tone?: \"inherit\" | \"dark\" | \"light\";\n  /** A #rrggbb colour used for the progress bar, the stars and the active ring. */\n  accent?: string;\n  /** Replaces the default width cap (max-w-sm). */\n  className?: string;\n  /** Accessible name of the carousel. */\n  label?: string;\n};\n\nconst EASE = \"cubic-bezier(0.16, 1, 0.3, 1)\";\nconst HEX = /^#[0-9a-fA-F]{6}$/;\nconst DEFAULT_ACCENT = \"#ffb86b\";\nconst SWIPE_PX = 56;\nconst IMG_OK = /^(https?:\\/\\/|\\/(?![/\\\\]))/;\n\nconst CM = (pct: number) => \"color-mix(in srgb, currentColor \" + pct + \"%, transparent)\";\n\nconst RING_MASK: CSSProperties = {\n  padding: 1,\n  WebkitMask: \"linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0)\",\n  mask: \"linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0)\",\n  WebkitMaskComposite: \"xor\",\n  maskComposite: \"exclude\",\n};\n\nconst TONES = {\n  inherit: {\n    surface: \"transparent\",\n    line: CM(16),\n    chipLine: CM(18),\n    ink: \"currentColor\",\n    muted: CM(62),\n    track: CM(10),\n    wash: CM(7),\n    shadow: \"none\",\n    btn: \"tcar-btn\",\n    chip: \"\",\n    focus: \"\",\n  },\n  dark: {\n    surface: \"#0b0c0e\",\n    line: \"rgba(255,255,255,0.12)\",\n    chipLine: \"rgba(255,255,255,0.14)\",\n    ink: \"#f4f5f7\",\n    muted: \"rgba(255,255,255,0.58)\",\n    track: \"rgba(255,255,255,0.07)\",\n    wash: \"rgba(255,255,255,0.07)\",\n    shadow: \"0 40px 80px -40px rgba(0,0,0,0.85), 0 1px 0 rgba(255,255,255,0.04) inset\",\n    btn: \"bg-white/[0.05] text-white/60 hover:bg-white/10 hover:text-white focus-visible:!outline-white/80\",\n    chip: \"bg-white/[0.06]\",\n    focus: \"focus-visible:!outline-white/80 \",\n  },\n  light: {\n    surface: \"#ffffff\",\n    line: \"rgba(10,12,16,0.12)\",\n    chipLine: \"rgba(10,12,16,0.12)\",\n    ink: \"#0b0c0e\",\n    muted: \"rgba(10,12,16,0.6)\",\n    track: \"rgba(10,12,16,0.07)\",\n    wash: \"rgba(10,12,16,0.045)\",\n    shadow: \"0 1px 2px rgba(10,12,16,0.05), 0 24px 48px -28px rgba(10,12,16,0.22)\",\n    btn: \"bg-black/[0.04] text-black/55 hover:bg-black/[0.08] hover:text-black focus-visible:!outline-black/70\",\n    chip: \"bg-black/[0.04]\",\n    focus: \"focus-visible:!outline-black/70 \",\n  },\n} as const;\n\nconst CSS = [\n  \".tcar-btn{background:\" + CM(6) + \";color:\" + CM(66) + \"}\",\n  \".tcar-btn:hover{background:\" + CM(13) + \";color:currentColor}\",\n  \".tcar-inh :focus-visible{outline:2px solid currentColor!important;outline-offset:2px!important}\",\n  \".tcar-slide{grid-area:1/1;min-width:0}\",\n  \".tcar-slide[data-state=idle]{visibility:hidden}\",\n  \".tcar-slide[data-state=active]{animation:tcar-in 640ms \" + EASE + \" both}\",\n  \".tcar-slide[data-state=leaving]{animation:tcar-out 340ms cubic-bezier(0.5,0,1,1) both;pointer-events:none}\",\n  \".tcar-slide[data-state=active] .tcar-w{animation:tcar-w 780ms \" + EASE + \" both;animation-delay:var(--tc-d,0ms)}\",\n  \".tcar-slide[data-state=active] .tcar-meta{animation:tcar-up 640ms \" + EASE + \" both;animation-delay:var(--tc-d,0ms)}\",\n  \".tcar-prog{position:absolute;left:0;bottom:0;height:2px;width:100%;transform-origin:0 50%;animation:tcar-prog 3200ms linear both}\",\n  \"@keyframes tcar-in{from{opacity:0;transform:translate3d(calc(var(--tc-o,1)*30px),0,0)}to{opacity:1;transform:none}}\",\n  \"@keyframes tcar-out{from{opacity:1;transform:none}to{opacity:0;transform:translate3d(calc(var(--tc-o,1)*-30px),0,0)}}\",\n  \"@keyframes tcar-w{from{opacity:0;transform:translate3d(0,0.5em,0);filter:blur(6px)}to{opacity:1;transform:none;filter:blur(0)}}\",\n  \"@keyframes tcar-up{from{opacity:0;transform:translate3d(0,8px,0)}to{opacity:1;transform:none}}\",\n  \"@keyframes tcar-prog{from{transform:scaleX(0)}to{transform:scaleX(1)}}\",\n  \"@keyframes tcar-fade{from{opacity:0}to{opacity:1}}\",\n  \"@keyframes tcar-fadeout{from{opacity:1}to{opacity:0}}\",\n  \"@media (prefers-reduced-motion:reduce){\",\n  \".tcar-slide[data-state=active]{animation:tcar-fade 220ms ease both}\",\n  \".tcar-slide[data-state=leaving]{animation:tcar-fadeout 160ms ease both}\",\n  \".tcar-slide[data-state] .tcar-w,.tcar-slide[data-state] .tcar-meta{animation:none!important}\",\n  \".tcar-track{transition:none!important}\",\n  \"}\",\n].join(\"\\n\");\n\nfunction subscribeMotion(cb: () => void) {\n  const m = window.matchMedia(\"(prefers-reduced-motion: reduce)\");\n  m.addEventListener(\"change\", cb);\n  return () => m.removeEventListener(\"change\", cb);\n}\n\n/** True when the visitor asked for reduced motion. False on the server. */\nfunction useReducedMotion(): boolean {\n  return useSyncExternalStore(\n    subscribeMotion,\n    () => window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches,\n    () => false,\n  );\n}\n\nfunction hashOf(s: string): number {\n  let h = 5381;\n  for (let i = 0; i < s.length; i++) h = ((h << 5) + h + s.charCodeAt(i)) >>> 0;\n  return h;\n}\n\nfunction rgba(hex: string, a: number): string {\n  const n = parseInt(hex.slice(1), 16);\n  return \"rgba(\" + ((n >> 16) & 255) + \",\" + ((n >> 8) & 255) + \",\" + (n & 255) + \",\" + a + \")\";\n}\n\nfunction initialsOf(name: string): string {\n  const parts = name.replace(/[^\\p{L}\\p{N}\\s]/gu, \" \").split(/\\s+/).filter(Boolean);\n  const a = parts[0]?.[0] ?? \"?\";\n  const b = parts.length > 1 ? (parts[parts.length - 1]?.[0] ?? \"\") : \"\";\n  return (a + b).toUpperCase();\n}\n\n/** Six invented marks. The company name picks one, plus a type treatment. */\nfunction Mark({ seed }: { seed: number }) {\n  const common = { width: 16, height: 16, viewBox: \"0 0 16 16\", fill: \"none\", \"aria-hidden\": true } as const;\n  switch (seed % 6) {\n    case 0:\n      return (\n        <svg {...common}>\n          <circle cx=\"8\" cy=\"8\" r=\"5.6\" stroke=\"currentColor\" strokeWidth=\"1.8\" />\n          <circle cx=\"8\" cy=\"8\" r=\"1.9\" fill=\"currentColor\" />\n        </svg>\n      );\n    case 1:\n      return (\n        <svg {...common}>\n          <rect x=\"1.5\" y=\"2.5\" width=\"13\" height=\"3\" rx=\"1.5\" fill=\"currentColor\" />\n          <rect x=\"1.5\" y=\"6.5\" width=\"8.5\" height=\"3\" rx=\"1.5\" fill=\"currentColor\" />\n          <rect x=\"1.5\" y=\"10.5\" width=\"11\" height=\"3\" rx=\"1.5\" fill=\"currentColor\" />\n        </svg>\n      );\n    case 2:\n      return (\n        <svg {...common}>\n          <path d=\"M8 1.5 14.5 8 8 14.5 1.5 8Z\" stroke=\"currentColor\" strokeWidth=\"1.8\" strokeLinejoin=\"round\" />\n          <path d=\"M8 5.2 10.8 8 8 10.8 5.2 8Z\" fill=\"currentColor\" />\n        </svg>\n      );\n    case 3:\n      return (\n        <svg {...common}>\n          <path d=\"M1.5 12.5a6.5 6.5 0 0 1 13 0Z\" fill=\"currentColor\" />\n          <path d=\"M4.6 8.2a3.4 3.4 0 0 1 6.8 0\" stroke=\"currentColor\" strokeWidth=\"1.6\" strokeLinecap=\"round\" />\n        </svg>\n      );\n    case 4:\n      return (\n        <svg {...common}>\n          <path d=\"M1.5 13.5 6 3l4.5 10.5Z\" fill=\"currentColor\" />\n          <path d=\"M8.5 13.5 11.5 6.5l3 7Z\" fill=\"currentColor\" opacity=\"0.55\" />\n        </svg>\n      );\n    default:\n      return (\n        <svg {...common}>\n          <rect x=\"1.8\" y=\"1.8\" width=\"12.4\" height=\"12.4\" rx=\"4\" stroke=\"currentColor\" strokeWidth=\"1.8\" />\n          <path d=\"M5 11 11 5\" stroke=\"currentColor\" strokeWidth=\"1.8\" strokeLinecap=\"round\" />\n        </svg>\n      );\n  }\n}\n\nfunction Wordmark({ name }: { name: string }) {\n  const h = hashOf(name);\n  const look = (h >> 3) % 3;\n  const type =\n    look === 0\n      ? \"text-[15px] font-semibold tracking-[-0.02em]\"\n      : look === 1\n        ? \"text-[11px] font-semibold uppercase tracking-[0.2em]\"\n        : \"text-[15px] font-bold lowercase tracking-[-0.03em]\";\n  return (\n    <span className=\"inline-flex min-w-0 items-center gap-2\" role=\"img\" aria-label={name}>\n      <Mark seed={h} />\n      <span aria-hidden className={\"truncate py-[3px] leading-[1.2] \" + type}>\n        {name}\n      </span>\n    </span>\n  );\n}\n\nfunction Star({ color }: { color: string }) {\n  return (\n    <svg width=\"12\" height=\"12\" viewBox=\"0 0 16 16\" aria-hidden fill={color}>\n      <path d=\"M8 1.2l2.1 4.5 4.9.6-3.6 3.4.9 4.9L8 12.2 3.7 14.6l.9-4.9L1 6.3l4.9-.6Z\" />\n    </svg>\n  );\n}\n\nfunction Avatar({ t, tone }: { t: Testimonial; tone: \"dark\" | \"light\" }) {\n  const h = hashOf(t.name) % 360;\n  const bg =\n    tone === \"dark\"\n      ? \"linear-gradient(140deg, hsl(\" + h + \" 62% 58%), hsl(\" + ((h + 48) % 360) + \" 58% 32%))\"\n      : \"linear-gradient(140deg, hsl(\" + h + \" 78% 84%), hsl(\" + ((h + 48) % 360) + \" 70% 68%))\";\n  const src = t.avatar && IMG_OK.test(t.avatar) ? t.avatar : null;\n  return (\n    <span\n      className=\"flex h-full w-full items-center justify-center overflow-hidden rounded-full text-[12px] font-semibold tracking-[0.02em]\"\n      style={{ background: bg, color: tone === \"dark\" ? \"#fff\" : \"hsl(\" + h + \" 40% 16%)\" }}\n    >\n      {src ? (\n        // eslint-disable-next-line @next/next/no-img-element\n        <img src={src} alt=\"\" className=\"h-full w-full object-cover\" draggable={false} />\n      ) : (\n        initialsOf(t.name)\n      )}\n    </span>\n  );\n}\n\ntype Nav = { i: number; prev: number; dir: number; n: number };\n\n/**\n * A quote carousel: soft word-by-word reveal, directional slide, avatar picker,\n * autoplay with a hairline progress bar, swipe and keyboard.\n */\nexport function TestimonialCarousel({\n  testimonials,\n  autoAdvance = true,\n  interval = 3200,\n  tone = \"inherit\",\n  accent = DEFAULT_ACCENT,\n  className,\n  label = \"Testimonials\",\n}: TestimonialCarouselProps) {\n  const len = testimonials.length;\n  const T = tone === \"light\" ? TONES.light : tone === \"dark\" ? TONES.dark : TONES.inherit;\n  const acc = HEX.test(accent) ? accent : DEFAULT_ACCENT;\n  const reduced = useReducedMotion();\n\n  const [nav, setNav] = useState<Nav>({ i: 0, prev: -1, dir: 1, n: 0 });\n  const [userPaused, setUserPaused] = useState(false);\n  const [hover, setHover] = useState(false);\n  const [focused, setFocused] = useState(false);\n  const [dragging, setDragging] = useState(false);\n  const [inView, setInView] = useState(true);\n  const [tabVisible, setTabVisible] = useState(true);\n\n  const rootRef = useRef<HTMLElement>(null);\n  const trackRef = useRef<HTMLDivElement>(null);\n  const drag = useRef<{ id: number; x: number; k: number; dx: number; moving: boolean } | null>(null);\n\n  const cur = nav.i < len ? nav.i : 0;\n  const prevIdx = nav.prev >= 0 && nav.prev < len && nav.prev !== cur ? nav.prev : -1;\n\n  const go = (delta: number) => {\n    if (len < 2) return;\n    setNav((s) => {\n      const from = s.i < len ? s.i : 0;\n      return { i: (from + delta + len) % len, prev: from, dir: delta >= 0 ? 1 : -1, n: s.n + 1 };\n    });\n  };\n  const goTo = (j: number) => {\n    if (j === cur || j < 0 || j >= len) return;\n    setNav((s) => ({ i: j, prev: s.i < len ? s.i : 0, dir: j > cur ? 1 : -1, n: s.n + 1 }));\n  };\n\n  // Drop the leaving slide once its exit has played.\n  useEffect(() => {\n    if (nav.prev < 0) return;\n    const n = nav.n;\n    const id = setTimeout(() => setNav((s) => (s.n === n ? { ...s, prev: -1 } : s)), 700);\n    return () => clearTimeout(id);\n  }, [nav.n, nav.prev]);\n\n  // Sleep the autoplay clock off-screen and in a hidden tab.\n  useEffect(() => {\n    const el = rootRef.current;\n    if (!el) return;\n    const io = new IntersectionObserver((es) => {\n      const e = es[es.length - 1];\n      if (e) setInView(e.isIntersecting);\n    });\n    io.observe(el);\n    const vis = () => setTabVisible(document.visibilityState !== \"hidden\");\n    document.addEventListener(\"visibilitychange\", vis);\n    return () => {\n      io.disconnect();\n      document.removeEventListener(\"visibilitychange\", vis);\n    };\n  }, []);\n\n  const wants = autoAdvance && !reduced && len > 1;\n  const running = wants && !userPaused;\n  const holding = hover || focused || dragging || !inView || !tabVisible;\n  const ms = Math.max(1000, interval);\n\n  const onKeyDown = (e: ReactKeyboardEvent<HTMLElement>) => {\n    if (e.key === \"ArrowRight\") {\n      e.preventDefault();\n      go(1);\n    } else if (e.key === \"ArrowLeft\") {\n      e.preventDefault();\n      go(-1);\n    } else if (e.key === \"Home\" && len > 1) {\n      e.preventDefault();\n      goTo(0);\n    } else if (e.key === \"End\" && len > 1) {\n      e.preventDefault();\n      goTo(len - 1);\n    }\n  };\n\n  const moveLight = (e: ReactPointerEvent<HTMLElement>) => {\n    if (e.pointerType === \"touch\") return;\n    const el = e.currentTarget;\n    const r = el.getBoundingClientRect();\n    const k = el.offsetWidth / (r.width || 1);\n    el.style.setProperty(\"--tc-mx\", ((e.clientX - r.left) * k).toFixed(1) + \"px\");\n    el.style.setProperty(\"--tc-my\", ((e.clientY - r.top) * k).toFixed(1) + \"px\");\n    el.style.setProperty(\"--tc-lit\", \"1\");\n  };\n\n  const onDown = (e: ReactPointerEvent<HTMLDivElement>) => {\n    if (len < 2 || (e.pointerType === \"mouse\" && e.button !== 0)) return;\n    const r = e.currentTarget.getBoundingClientRect();\n    drag.current = { id: e.pointerId, x: e.clientX, k: e.currentTarget.offsetWidth / (r.width || 1), dx: 0, moving: false };\n  };\n  const onMove = (e: ReactPointerEvent<HTMLDivElement>) => {\n    const d = drag.current;\n    if (!d || d.id !== e.pointerId) return;\n    d.dx = (e.clientX - d.x) * d.k;\n    if (!d.moving && Math.abs(d.dx) > 6) {\n      d.moving = true;\n      e.currentTarget.setPointerCapture(e.pointerId);\n      setDragging(true);\n    }\n    if (d.moving) trackRef.current?.style.setProperty(\"--tc-dx\", (d.dx * 0.5).toFixed(1) + \"px\");\n  };\n  const endDrag = (e: ReactPointerEvent<HTMLDivElement>, commit: boolean) => {\n    const d = drag.current;\n    if (!d || d.id !== e.pointerId) return;\n    drag.current = null;\n    if (!d.moving) return;\n    trackRef.current?.style.setProperty(\"--tc-dx\", \"0px\");\n    setDragging(false);\n    if (commit && Math.abs(d.dx) >= SWIPE_PX) go(d.dx < 0 ? 1 : -1);\n  };\n\n  if (len === 0) return null;\n\n  const ring = (on: boolean): CSSProperties => ({\n    boxShadow: tone === \"inherit\" ? (on ? \"0 0 0 2px \" + acc : \"none\") : on ? \"0 0 0 2px \" + T.surface + \", 0 0 0 3.5px \" + acc : \"0 0 0 2px \" + T.surface,\n  });\n\n  return (\n    <>\n      <style>{CSS}</style>\n      <section\n        ref={rootRef}\n        role=\"region\"\n        aria-roledescription=\"carousel\"\n        aria-label={label}\n        onKeyDown={onKeyDown}\n        onPointerMove={moveLight}\n        onPointerLeave={(e) => e.currentTarget.style.setProperty(\"--tc-lit\", \"0\")}\n        onPointerEnter={(e) => {\n          if (e.pointerType !== \"touch\") setHover(true);\n        }}\n        onPointerOut={(e) => {\n          if (e.pointerType !== \"touch\" && !e.currentTarget.contains(e.relatedTarget as Node | null)) setHover(false);\n        }}\n        onFocus={() => setFocused(true)}\n        onBlur={(e) => {\n          if (!e.currentTarget.contains(e.relatedTarget as Node | null)) setFocused(false);\n        }}\n        className={\"@container relative w-full \" + (tone === \"inherit\" ? \"tcar-inh \" : \"\") + (className ?? \"max-w-sm\")}\n        style={{\n          borderRadius: 20,\n          padding: 1,\n          boxShadow: T.shadow,\n          ...(tone === \"inherit\" ? {} : { color: T.ink }),\n        }}\n      >\n        <div aria-hidden className=\"pointer-events-none absolute inset-0\" style={{ borderRadius: 20, ...RING_MASK, background: T.line }} />\n        <div\n          aria-hidden\n          className=\"pointer-events-none absolute inset-0\"\n          style={{\n            borderRadius: 20,\n            ...RING_MASK,\n            background: \"radial-gradient(260px circle at var(--tc-mx, 50%) var(--tc-my, 0px), \" + rgba(acc, 0.85) + \", \" + rgba(acc, 0.2) + \" 42%, transparent 72%)\",\n            opacity: \"var(--tc-lit, 0)\",\n            transition: \"opacity 350ms ease\",\n          }}\n        />\n        <div className=\"relative overflow-hidden\" style={{ borderRadius: 19, background: T.surface }}>\n          <div\n            aria-hidden\n            className=\"pointer-events-none absolute inset-0\"\n            style={{\n              background:\n                \"radial-gradient(420px circle at var(--tc-mx, 50%) var(--tc-my, 0px), \" + T.wash + \", transparent 62%)\",\n              opacity: \"var(--tc-lit, 0)\",\n              transition: \"opacity 350ms ease\",\n            }}\n          />\n          <div\n            aria-hidden\n            className=\"pointer-events-none absolute inset-0\"\n            style={{ background: \"radial-gradient(70% 55% at 0% 0%, \" + rgba(acc, 0.1) + \", transparent 70%)\" }}\n          />\n\n          <div className=\"relative flex flex-col gap-6 px-5 pb-6 pt-5 @md:gap-8 @md:px-8 @md:pb-8 @md:pt-7\">\n            <div\n              aria-live={running ? \"off\" : \"polite\"}\n              className={\"touch-pan-y \" + (dragging ? \"cursor-grabbing select-none\" : \"cursor-grab\")}\n              onPointerDown={onDown}\n              onPointerMove={onMove}\n              onPointerUp={(e) => endDrag(e, true)}\n              onPointerCancel={(e) => endDrag(e, false)}\n              onDragStart={(e) => e.preventDefault()}\n            >\n              <div\n                ref={trackRef}\n                className=\"tcar-track grid\"\n                style={{\n                  transform: \"translate3d(var(--tc-dx, 0px), 0, 0)\",\n                  transition: dragging ? \"none\" : \"transform 500ms \" + EASE,\n                }}\n              >\n                {testimonials.map((t, idx) => {\n                  const state = idx === cur ? \"active\" : idx === prevIdx ? \"leaving\" : \"idle\";\n                  const words = (\"“\" + t.quote + \"”\").split(/\\s+/);\n                  const metaDelay = Math.min(words.length * 24, 520) + 140;\n                  return (\n                    <div\n                      key={idx}\n                      role=\"group\"\n                      aria-roledescription=\"slide\"\n                      aria-label={idx + 1 + \" of \" + len}\n                      aria-hidden={state === \"idle\" ? true : undefined}\n                      data-state={state}\n                      className=\"tcar-slide flex flex-col gap-4 @md:gap-6\"\n                      style={{ \"--tc-o\": nav.dir } as CSSProperties}\n                    >\n                      {t.company || typeof t.score === \"number\" ? (\n                        <div className=\"flex items-center justify-between gap-3\">\n                          {t.company ? (\n                            <span style={{ color: T.muted }} className=\"min-w-0\">\n                              <Wordmark name={t.company} />\n                            </span>\n                          ) : (\n                            <span />\n                          )}\n                          {typeof t.score === \"number\" ? (\n                            <span\n                              className={\"inline-flex shrink-0 items-center gap-1.5 rounded-full px-2.5 py-1 text-[12px] font-medium tabular-nums leading-none \" + T.chip}\n                              style={{ border: \"1px solid \" + T.chipLine }}\n                            >\n                              <Star color={acc} />\n                              <span aria-hidden>{Math.max(0, Math.min(5, t.score)).toFixed(1)}</span>\n                              <span className=\"sr-only\">Rated {Math.max(0, Math.min(5, t.score)).toFixed(1)} out of 5</span>\n                            </span>\n                          ) : null}\n                        </div>\n                      ) : null}\n                      <p className=\"text-[18px] font-medium leading-[1.35] tracking-[-0.015em] @md:text-[27px] @md:leading-[1.28]\">\n                        {words.map((w, wi) => (\n                          <Fragment key={wi}>\n                            <span\n                              className=\"tcar-w inline-block\"\n                              style={{ \"--tc-d\": Math.min(wi * 24, 520) + 60 + \"ms\" } as CSSProperties}\n                            >\n                              {w}\n                            </span>{\" \"}\n                          </Fragment>\n                        ))}\n                      </p>\n                      <p\n                        className=\"tcar-meta text-[13px] leading-snug\"\n                        style={{ color: T.muted, \"--tc-d\": metaDelay + \"ms\" } as CSSProperties}\n                      >\n                        <span className=\"font-semibold\" style={{ color: T.ink }}>\n                          {t.name}\n                        </span>\n                        <span aria-hidden> · </span>\n                        <span className=\"sr-only\">, </span>\n                        {t.role}\n                      </p>\n                    </div>\n                  );\n                })}\n              </div>\n            </div>\n\n            {len > 1 ? (\n              <div className=\"flex flex-wrap items-center justify-between gap-x-3 gap-y-3\">\n                <div role=\"group\" aria-label=\"Choose a testimonial\" className=\"-m-1 flex flex-wrap items-center p-1\">\n                  {testimonials.map((t, idx) => {\n                    const on = idx === cur;\n                    return (\n                      <button\n                        key={idx}\n                        type=\"button\"\n                        aria-label={t.name + (t.company ? \", \" + t.company : \"\")}\n                        aria-current={on ? \"true\" : undefined}\n                        onClick={() => goTo(idx)}\n                        className={\n                          \"relative h-10 w-10 shrink-0 rounded-full transition-all duration-300 focus-visible:!z-20 focus-visible:!outline-2 focus-visible:!outline-offset-2 \" + (idx === 0 ? \"\" : tone === \"inherit\" ? \"ml-1 \" : \"-ml-2.5 @md:-ml-2 \") + +\n                          T.focus +\n                          (on ? \"z-10\" : \"brightness-[0.62] hover:z-10 hover:-translate-y-0.5 hover:brightness-100\")\n                        }\n                        style={{ ...ring(on), borderRadius: 999 }}\n                      >\n                        <Avatar t={t} tone={tone === \"light\" ? \"light\" : \"dark\"} />\n                      </button>\n                    );\n                  })}\n                </div>\n                <div className=\"ml-auto flex shrink-0 items-center gap-1\">\n                  {wants ? (\n                    <button\n                      type=\"button\"\n                      aria-label={userPaused ? \"Resume autoplay\" : \"Pause autoplay\"}\n                      onClick={() => setUserPaused((v) => !v)}\n                      className={\"flex h-10 w-10 items-center justify-center rounded-full transition-[background-color,color,transform] duration-200 active:scale-90 focus-visible:!outline-2 focus-visible:!outline-offset-2 \" + T.btn}\n                      style={{ border: \"1px solid \" + T.chipLine }}\n                    >\n                      <svg width=\"12\" height=\"12\" viewBox=\"0 0 12 12\" aria-hidden fill=\"currentColor\">\n                        {userPaused ? <path d=\"M3 1.8v8.4L10 6Z\" /> : <path d=\"M2.6 1.8h2.2v8.4H2.6ZM7.2 1.8h2.2v8.4H7.2Z\" />}\n                      </svg>\n                    </button>\n                  ) : null}\n                  {([-1, 1] as const).map((d) => (\n                    <button\n                      key={d}\n                      type=\"button\"\n                      aria-label={d < 0 ? \"Previous testimonial\" : \"Next testimonial\"}\n                      onClick={() => go(d)}\n                      className={\"flex h-10 w-10 items-center justify-center rounded-full transition-[background-color,color,transform] duration-200 active:scale-90 focus-visible:!outline-2 focus-visible:!outline-offset-2 \" + T.btn}\n                      style={{ border: \"1px solid \" + T.chipLine }}\n                    >\n                      <svg width=\"14\" height=\"14\" viewBox=\"0 0 16 16\" aria-hidden fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.8\" strokeLinecap=\"round\" strokeLinejoin=\"round\">\n                        <path d={d < 0 ? \"M10 3 5 8l5 5\" : \"M6 3l5 5-5 5\"} />\n                      </svg>\n                    </button>\n                  ))}\n                </div>\n              </div>\n            ) : null}\n          </div>\n\n          {running ? (\n            <>\n              <span aria-hidden className=\"absolute bottom-0 left-0 h-[2px] w-full\" style={{ background: T.track }} />\n              <span\n                key={nav.n + \"-\" + ms}\n                aria-hidden\n                className=\"tcar-prog\"\n                style={{\n                  background: acc,\n                  animationDuration: ms + \"ms\",\n                  animationPlayState: holding || userPaused ? \"paused\" : \"running\",\n                }}\n                onAnimationEnd={() => go(1)}\n              />\n            </>\n          ) : null}\n        </div>\n      </section>\n    </>\n  );\n}\n","type":"registry:component","target":"components/viberdy/testimonial-carousel.tsx"}],"meta":{"tier":"free","tags":["testimonial","carousel","quote","slider","reviews","swipe","autoplay"],"href":"https://viberdy.dev/library/testimonial-carousel","aiPrompt":"Create a React + Tailwind (v4) component named TestimonialCarousel. One self-contained \"use client\" file, React only (no framer-motion, no icon library; icons are inline SVG). Works on React 18 and 19.\n\nProps (all old props keep their meaning): testimonials: {quote, name, role, company?, score?, avatar?}[] (required); autoAdvance = true; interval = 3200 (ms, clamp to >= 1000); tone: \"inherit\" | \"dark\" | \"light\" = \"inherit\" (transparent, text from currentColor, borders/controls via color-mix(currentColor 6-18%, transparent), focus ring 2px currentColor; no avatar overlap since there is no surface to gap against); accent = \"#ffb86b\" (validate /^#[0-9a-fA-F]{6}$/, else default); className (replaces the default width cap \"max-w-sm\"); label = \"Testimonials\". An empty list renders nothing; one item hides the controls.\n\nStructure: a <section role=\"region\" aria-roledescription=\"carousel\"> with class \"@container relative w-full max-w-sm\". The outer shell has padding 1px and a 1px hairline drawn as a masked ring overlay (border-mask: padding 1px, mask content-box exclude) (dark rgba(255,255,255,0.12), light rgba(10,12,16,0.12)), radius 20; the inner surface has radius 19 (dark #0b0c0e, light #fff). The card paints its own colours with inline styles; do not use site tokens. Inner padding px-5 pt-5 pb-6, and px-8 pt-7 pb-8 from the @md container width.\n\nSlides: all slides sit in ONE CSS grid cell (grid-area 1/1) so the card is as tall as the tallest quote. States: active, leaving, idle (visibility hidden, aria-hidden). Each slide is role=\"group\" aria-roledescription=\"slide\" aria-label=\"n of N\". Top row: company wordmark (muted; inline SVG mark chosen from 6 invented geometric glyphs by a string hash, plus the name in one of 3 type treatments) on the left and a score chip on the right (1px border, rounded-full, 12px tabular numerals, a 12px accent star, sr-only \"Rated x out of 5\"). Quote: 18px (27px at @md) font-medium, leading 1.35, tracking -0.015em, wrapped in curly quotes. Attribution: 13px, name semibold in ink, role muted.\n\nMotion (CSS keyframes in an injected plain <style>, easing cubic-bezier(0.16,1,0.3,1)): the entering slide runs 640ms from translateX(dir*30px) and opacity 0; the leaving slide runs 340ms ease-in to translateX(-dir*30px) and opacity 0 and is removed after 700ms. Each word is an inline-block span (spaces between spans as text nodes) animating 780ms from opacity 0, translateY(0.5em), blur(6px), with delay 60ms + 24ms per word capped at 520ms; the attribution fades up after the last word. The track follows the pointer while dragging at 0.5x and springs back with a 500ms transition; releasing past 56px (measure in layout px: (clientX - rect.left) * offsetWidth / rect.width) goes to the next or previous slide. A drag starts after 6px of movement with pointer capture; touch-action is pan-y.\n\nAutoplay: a 2px accent bar along the card's bottom edge (over a faint track) animates scaleX 0 to 1, linear, over `interval`; its animationend advances to the next slide. It is re-keyed on every navigation. animation-play-state is paused while hovered (mouse), focused inside, dragging, off-screen (IntersectionObserver) or in a hidden tab (visibilitychange), or after the user pressed pause.\n\nControls: avatar buttons (40px circles overlapping by 10px (8px from the @md container width), a deterministic gradient from a hash of the name, initials, and an optional image only if the URL starts with https://, http:// or a single \"/\"); the active one has a 2px surface gap plus a 1.5px accent ring and full opacity, the others are dimmed with brightness(0.62) (not opacity, so overlaps stay opaque) and lift on hover. Then a pause/resume button (only when autoplay is on) and previous/next chevron buttons, all 40px, bordered, bg-white/5 (dark) or bg-black/4 (light), active:scale-90. Focus rings are important utilities (focus-visible:!outline-2 focus-visible:!outline-offset-2 plus a tone colour) because the host stylesheet may override outlines.\n\nPointer light: on mouse move write --tc-mx/--tc-my/--tc-lit CSS variables on the root (no re-renders): a soft radial wash across the surface and a bright accent arc on the hairline border. A static accent glow sits in the top-left corner.\n\nA11y: ArrowLeft/ArrowRight anywhere inside move between quotes, Home/End jump; aria-live is \"off\" while autoplay runs and \"polite\" otherwise. Reduced motion: slides crossfade in 220ms, words and attribution do not animate, the track does not follow with a transition, and autoplay (and the bar) is disabled.","license":"https://viberdy.dev/license"}}