{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "squeeze-carousel",
  "type": "registry:block",
  "title": "Squeeze Carousel",
  "description": "A canvas-driven news carousel: one wide active card with squeezed companions that stretch on hover and slide into place, with keyboard and screen-reader support and a scroll-snap mobile layout.",
  "dependencies": [
    "@radix-ui/react-slot",
    "@radix-ui/react-use-controllable-state",
    "lucide-react",
    "class-variance-authority"
  ],
  "registryDependencies": ["button"],
  "files": [
    {
      "path": "registry/abui/marketing/squeeze-carousel.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\nimport { Slot } from \"@radix-ui/react-slot\"\nimport { useControllableState } from \"@radix-ui/react-use-controllable-state\"\nimport { ArrowLeft, ArrowRight } from \"lucide-react\"\n\nimport { cn } from \"@/lib/utils\"\nimport { Button } from \"@/components/ui/button\"\n\n/**\n * SqueezeCarousel\n *\n * A \"what's happening\" style news carousel: one wide active card followed by progressively\n * narrower companions that stretch on hover and slide into place when you navigate.\n *\n * Desktop (>= sm): the image strip is a single <canvas>. Every card is clipped to a rounded\n * rectangle and its image is cover-fitted into a fixed 16:9 box centred on the card, so a\n * card looks squeezed rather than scaled. Card widths come from flex fractions of the width\n * left over after the primary 16:9 card, and every width, gap and offset is tweened with an\n * ease-out-expo curve when the active index changes.\n *\n * Mobile (< sm): a native scroll-snap list of cards with scale, parallax and fade driven by\n * scroll progress through CSS custom properties.\n *\n * Composition:\n *\n *   <SqueezeCarousel items={items}>\n *     <SqueezeCarouselHeader>\n *       <SqueezeCarouselHeading>\n *         <SqueezeCarouselTitle>What's happening</SqueezeCarouselTitle>\n *         <SqueezeCarouselDescription>See the latest from us.</SqueezeCarouselDescription>\n *       </SqueezeCarouselHeading>\n *       <SqueezeCarouselControls>\n *         <SqueezeCarouselPrevious />\n *         <SqueezeCarouselNext />\n *       </SqueezeCarouselControls>\n *     </SqueezeCarouselHeader>\n *     <SqueezeCarouselCanvas />\n *     <SqueezeCarouselDetails>{renderCopy}</SqueezeCarouselDetails>\n *     <SqueezeCarouselMobileList>{renderCopy}</SqueezeCarouselMobileList>\n *   </SqueezeCarousel>\n */\n\n/* -------------------------------------------------------------------------------------------------\n * Types\n * -----------------------------------------------------------------------------------------------*/\n\nexport interface SqueezeCarouselItem {\n  /** Stable identifier, used as the React key. */\n  id: string\n  /**\n   * Plain-text name of the item. Announced to screen readers (\"Item 2 of 8: …\") and used as\n   * the default `alt` text of the mobile image.\n   */\n  title: string\n  /** Image drawn on the desktop canvas. A 16:9 image of at least 1632×918 is recommended. */\n  src: string\n  /** Image used by the mobile card list. Defaults to `src`. A 336:350 crop is recommended. */\n  mobileSrc?: string\n  /** Alternative text for the mobile image. Defaults to `title`. Pass \"\" for decorative images. */\n  alt?: string\n  /**\n   * Horizontal offset in CSS pixels applied to the image while its card is collapsed. Use it\n   * to keep the focal point of the image inside the narrow column. Positive values move the\n   * image to the left. Default: 0.\n   */\n  collapsedOffsetX?: number\n  /**\n   * Link opened when the primary (fully revealed) card is clicked and no\n   * `SqueezeCarouselDetailAction` is registered for the item. When an action exists, clicking\n   * the card activates that action instead, so router links and analytics keep working.\n   */\n  href?: string\n}\n\nexport type SqueezeCarouselCrossOrigin = \"anonymous\" | \"use-credentials\"\n\nexport interface SqueezeCarouselNavigateOptions {\n  /** Move keyboard focus to the newly active item's action once it becomes active. */\n  focus?: boolean\n}\n\nexport type SqueezeCarouselRenderItem = (item: SqueezeCarouselItem, index: number) => React.ReactNode\n\n/* -------------------------------------------------------------------------------------------------\n * Canvas engine\n *\n * Framework-agnostic class that owns the <canvas>. It keeps a list of \"cards\" (one per visible\n * column), lays them out from a set of flex fractions, and tweens every card between layouts.\n * -----------------------------------------------------------------------------------------------*/\n\nconst SQUEEZE = {\n  /** Gap before a collapsed 8px sliver. */\n  smallCardGap: 8,\n  /** Gap before one of the four main columns. */\n  largeCardGap: 16,\n  /** Width of a collapsed sliver. */\n  smallCardWidth: 8,\n  /** Extra width given to a hovered sliver. */\n  smallCardHoverOffset: 3,\n  /** Share of the leftover width taken by columns 0..3 at rest. Column 0 adds this to its 16:9 base. */\n  flex: [-0.06, 0.61, 0.3, 0.15],\n  /** Shares used for the columns that are not hovered while another one is. */\n  flexSqueezed: [-0.12, 0.59, 0.28, 0.13],\n  /** Shares used for the hovered column. */\n  flexStretched: [0, 0.71, 0.4, 0.25],\n  /** Tween duration in ms. */\n  duration: 1000,\n  /** Tween duration in ms when the user prefers reduced motion. */\n  reducedMotionDuration: 200,\n  /** Default corner radius of every card. */\n  borderRadius: 6,\n  /** The primary column is sized from the canvas height at this ratio; images are cover-fitted into it. */\n  primaryAspectRatio: 16 / 9,\n  /** Cap on the share of the canvas width the primary column may take, so tall canvases keep companions. */\n  maxPrimaryShare: 0.75,\n  /** Maximum device pixel ratio used for the backing store. */\n  maxPixelRatio: 2,\n} as const\n\nconst clamp = (value: number, min: number, max: number) => Math.min(Math.max(value, min), max)\nconst lerp = (from: number, to: number, t: number) => from + (to - from) * t\nconst easeOutExpo = (t: number) => (t === 1 ? 1 : 1 - Math.pow(2, -10 * t))\nconst mod = (value: number, length: number) => ((value % length) + length) % length\n\ninterface EngineCard {\n  itemIndex: number\n  image: HTMLImageElement\n  x: number\n  width: number\n  leftGap: number\n  collapsedOffsetX: number\n  columnIndex: number\n  startWidth?: number\n  targetWidth?: number\n  startLeftGap?: number\n  targetLeftGap?: number\n  startCollapsedOffsetX?: number\n  targetCollapsedOffsetX?: number\n}\n\ninterface SqueezeCanvasEngineOptions {\n  canvas: HTMLCanvasElement\n  items: SqueezeCarouselItem[]\n  /** Item shown in the primary column on first paint. */\n  initialIndex?: number\n  /** Called when a non-primary column is clicked, with the number of steps to advance. */\n  onColumnClick: (steps: number) => void\n  /** Called when the primary (fully revealed) column is clicked. */\n  onPrimaryClick?: (event: MouseEvent) => void\n  prefersReducedMotion?: boolean\n  borderRadius?: number\n  crossOrigin?: SqueezeCarouselCrossOrigin\n}\n\nexport class SqueezeCanvasEngine {\n  /** Index of the item currently (or about to be) shown in the primary column. */\n  activeIndex: number\n\n  private readonly canvas: HTMLCanvasElement\n  private readonly ctx: CanvasRenderingContext2D\n  private readonly dpr: number\n  private readonly items: SqueezeCarouselItem[]\n  private readonly images: HTMLImageElement[]\n  private readonly collapsedOffsets: number[]\n  private readonly onColumnClick: (steps: number) => void\n  private readonly onPrimaryClick?: (event: MouseEvent) => void\n  private readonly prefersReducedMotion: boolean\n  private readonly borderRadius: number\n  private readonly animationDuration: number\n  private readonly resizeObserver: ResizeObserver | null\n\n  private cards: EngineCard[] = []\n  private numSmallCards = 3\n  private visibleCardsCount = 7\n  private totalGap = 0\n\n  private canvasWidth = 0\n  private canvasHeight = 0\n  private primaryBaseWidth = 0\n  private totalFlexWidth = 0\n  private imageWidth = 0\n\n  private flex: number[] = [...SQUEEZE.flex]\n  private hoveredColumn = -1\n  private columnIndexOffset = 0\n\n  private cardsOffsetX = 0\n  private startCardsOffsetX = 0\n  private targetCardsOffsetX = 0\n  private flexWidthOffset = 0\n  private startFlexWidthOffset = 0\n  private targetFlexWidthOffset = 0\n\n  private animationStartAt = 0\n  private animationFrame = 0\n  private resizeFrame = 0\n  private disposed = false\n\n  constructor({\n    canvas,\n    items,\n    initialIndex = 0,\n    onColumnClick,\n    onPrimaryClick,\n    prefersReducedMotion = false,\n    borderRadius = SQUEEZE.borderRadius,\n    crossOrigin,\n  }: SqueezeCanvasEngineOptions) {\n    const ctx = canvas.getContext(\"2d\")\n    if (!ctx) throw new Error(\"SqueezeCanvasEngine: 2D canvas context is not available\")\n\n    this.canvas = canvas\n    this.ctx = ctx\n    this.dpr = Math.min(window.devicePixelRatio || 1, SQUEEZE.maxPixelRatio)\n    this.items = items\n    this.onColumnClick = onColumnClick\n    this.onPrimaryClick = onPrimaryClick\n    this.prefersReducedMotion = prefersReducedMotion\n    this.borderRadius = borderRadius\n    this.animationDuration = prefersReducedMotion ? SQUEEZE.reducedMotionDuration : SQUEEZE.duration\n    this.activeIndex = items.length ? mod(initialIndex, items.length) : 0\n\n    this.collapsedOffsets = items.map(item => item.collapsedOffsetX ?? 0)\n    this.images = items.map(item => {\n      const image = new Image()\n      if (crossOrigin) image.crossOrigin = crossOrigin\n      image.decoding = \"async\"\n      image.src = item.src\n      image.onload = this.render\n      return image\n    })\n\n    this.numSmallCards = clamp(items.length - 4, 1, 3)\n    this.visibleCardsCount = 4 + this.numSmallCards\n    this.totalGap = SQUEEZE.smallCardGap * this.numSmallCards + 3 * SQUEEZE.largeCardGap\n\n    this.canvas.addEventListener(\"pointermove\", this.handlePointerMove)\n    this.canvas.addEventListener(\"pointerleave\", this.handlePointerLeave)\n    this.canvas.addEventListener(\"click\", this.handleClick)\n    document.addEventListener(\"visibilitychange\", this.render)\n\n    this.resizeObserver =\n      typeof ResizeObserver === \"undefined\"\n        ? null\n        : new ResizeObserver(() => {\n            cancelAnimationFrame(this.resizeFrame)\n            this.resizeFrame = requestAnimationFrame(this.resize)\n          })\n    this.resizeObserver?.observe(this.canvas)\n\n    this.measure()\n    this.cards = Array.from({ length: this.visibleCardsCount }, (_, column) => {\n      const itemIndex = mod(this.activeIndex + column, Math.max(items.length, 1))\n      return {\n        itemIndex,\n        image: this.images[itemIndex],\n        x: 0,\n        width: this.getCardWidth(column),\n        leftGap: column < 4 ? SQUEEZE.largeCardGap : SQUEEZE.smallCardGap,\n        collapsedOffsetX: column === 0 ? 0 : this.collapsedOffsets[itemIndex],\n        columnIndex: column,\n      }\n    })\n    this.render()\n  }\n\n  /** Advance by `delta` columns (negative values go backwards). */\n  navigate = (delta: number) => {\n    if (this.disposed || !this.items.length || delta === 0) return\n    this.activeIndex = mod(this.activeIndex + delta, this.items.length)\n    if (delta > 0) this.goToNext(delta)\n    else this.goToPrevious(-delta)\n  }\n\n  /** Jump to an item, taking the shortest direction around the loop. */\n  setActiveIndex = (index: number) => {\n    if (!this.items.length) return\n    const target = mod(index, this.items.length)\n    const forward = mod(target - this.activeIndex, this.items.length)\n    const backward = mod(this.activeIndex - target, this.items.length)\n    if (forward === 0) return\n    this.navigate(forward <= backward ? forward : -backward)\n  }\n\n  dispose = () => {\n    this.disposed = true\n    cancelAnimationFrame(this.animationFrame)\n    cancelAnimationFrame(this.resizeFrame)\n    this.resizeObserver?.disconnect()\n    this.canvas.removeEventListener(\"pointermove\", this.handlePointerMove)\n    this.canvas.removeEventListener(\"pointerleave\", this.handlePointerLeave)\n    this.canvas.removeEventListener(\"click\", this.handleClick)\n    document.removeEventListener(\"visibilitychange\", this.render)\n    this.images.forEach(image => {\n      image.onload = null\n      image.src = \"\"\n    })\n    this.ctx.clearRect(0, 0, this.canvasWidth, this.canvasHeight)\n    this.canvas.width = 0\n    this.canvas.height = 0\n    this.canvas.style.removeProperty(\"cursor\")\n  }\n\n  /* ---- layout ---------------------------------------------------------------------------------- */\n\n  private measure() {\n    const { width, height } = this.canvas.getBoundingClientRect()\n    this.canvas.width = Math.round(width * this.dpr)\n    this.canvas.height = Math.round(height * this.dpr)\n    this.ctx.setTransform(this.dpr, 0, 0, this.dpr, 0, 0)\n    this.canvasWidth = width\n    this.canvasHeight = height\n    const fixedWidth = this.totalGap + SQUEEZE.smallCardWidth * this.numSmallCards\n    this.primaryBaseWidth = Math.min(\n      height * SQUEEZE.primaryAspectRatio,\n      Math.max(0, (width - fixedWidth) * SQUEEZE.maxPrimaryShare),\n    )\n    this.totalFlexWidth = width - this.primaryBaseWidth - this.totalGap - SQUEEZE.smallCardWidth * this.numSmallCards\n    this.imageWidth = this.primaryBaseWidth + this.totalFlexWidth * SQUEEZE.flexStretched[0]\n  }\n\n  private resize = () => {\n    if (this.disposed) return\n    this.measure()\n    cancelAnimationFrame(this.animationFrame)\n    for (const card of this.cards) {\n      card.width = this.getCardWidth(card.columnIndex)\n      card.leftGap = card.columnIndex < 4 ? SQUEEZE.largeCardGap : SQUEEZE.smallCardGap\n    }\n    this.hoveredColumn = -1\n    this.updateFlex()\n  }\n\n  private getCardWidth(column: number) {\n    if (column < 0 || column > 3) {\n      const hoverOffset = this.hoveredColumn === column ? this.targetFlexWidthOffset : 0\n      return SQUEEZE.smallCardWidth + hoverOffset\n    }\n    const available = this.totalFlexWidth - this.targetFlexWidthOffset\n    if (column === 0) return this.primaryBaseWidth + available * this.flex[0]\n    return available * this.flex[column]\n  }\n\n  private updateFlex() {\n    const hovered = this.hoveredColumn\n    if (hovered >= 0 && hovered <= 3 && !this.prefersReducedMotion) {\n      this.flex = SQUEEZE.flex.map((_, column) =>\n        column === hovered ? SQUEEZE.flexStretched[column] : SQUEEZE.flexSqueezed[column],\n      )\n    } else {\n      this.flex = [...SQUEEZE.flex]\n    }\n    const clickable = hovered > 0 || (hovered === 0 && !!this.onPrimaryClick)\n    this.canvas.style.cursor = clickable ? \"pointer\" : \"\"\n    this.startAnimation()\n  }\n\n  /* ---- navigation ------------------------------------------------------------------------------ */\n\n  private goToPrevious(steps: number) {\n    for (let i = 0; i < steps; i += 1) {\n      const itemIndex = mod(this.cards[0].itemIndex - 1, this.items.length)\n      this.cards.unshift({\n        itemIndex,\n        image: this.images[itemIndex],\n        x: 0,\n        width: SQUEEZE.smallCardWidth,\n        leftGap: SQUEEZE.largeCardGap,\n        collapsedOffsetX: 0,\n        columnIndex: 0,\n      })\n    }\n    this.cards.forEach((card, index) => {\n      card.columnIndex = index + this.columnIndexOffset\n    })\n    this.startAnimation(steps)\n  }\n\n  private goToNext(steps: number) {\n    for (let i = 0; i < steps; i += 1) {\n      const itemIndex = mod(this.cards[this.cards.length - 1].itemIndex + 1, this.items.length)\n      this.cards.push({\n        itemIndex,\n        image: this.images[itemIndex],\n        x: 0,\n        width: SQUEEZE.smallCardWidth,\n        leftGap: SQUEEZE.smallCardGap,\n        collapsedOffsetX: this.collapsedOffsets[itemIndex],\n        columnIndex: 0,\n      })\n    }\n    this.columnIndexOffset -= steps\n    this.cards.forEach((card, index) => {\n      card.columnIndex = index + this.columnIndexOffset\n    })\n    this.startAnimation()\n  }\n\n  /* ---- animation ------------------------------------------------------------------------------- */\n\n  private startAnimation(prependedCards = 0) {\n    const slot = SQUEEZE.smallCardWidth + SQUEEZE.largeCardGap\n    this.startCardsOffsetX = this.cardsOffsetX - prependedCards * slot\n    this.targetCardsOffsetX = this.columnIndexOffset * slot\n    this.startFlexWidthOffset = this.flexWidthOffset\n    this.targetFlexWidthOffset = !this.prefersReducedMotion && this.hoveredColumn > 3 ? SQUEEZE.smallCardHoverOffset : 0\n\n    for (const card of this.cards) {\n      const column = card.columnIndex\n      card.startCollapsedOffsetX = card.collapsedOffsetX\n      card.targetCollapsedOffsetX = column === 0 ? 0 : this.collapsedOffsets[card.itemIndex]\n      card.startWidth = card.width\n      card.targetWidth = this.getCardWidth(column)\n      card.startLeftGap = card.leftGap\n      card.targetLeftGap = column < 4 ? SQUEEZE.largeCardGap : SQUEEZE.smallCardGap\n    }\n\n    this.animationStartAt = performance.now()\n    cancelAnimationFrame(this.animationFrame)\n    this.animationFrame = requestAnimationFrame(this.animate)\n  }\n\n  private animate = (now: number) => {\n    const progress = Math.min((now - this.animationStartAt) / this.animationDuration, 1)\n    const eased = easeOutExpo(progress)\n\n    this.cardsOffsetX = lerp(this.startCardsOffsetX, this.targetCardsOffsetX, eased)\n    this.flexWidthOffset = lerp(this.startFlexWidthOffset, this.targetFlexWidthOffset, eased)\n    for (const card of this.cards) {\n      card.collapsedOffsetX = lerp(\n        card.startCollapsedOffsetX ?? card.collapsedOffsetX,\n        card.targetCollapsedOffsetX ?? card.collapsedOffsetX,\n        eased,\n      )\n      card.width = lerp(card.startWidth ?? card.width, card.targetWidth ?? card.width, eased)\n      card.leftGap = lerp(card.startLeftGap ?? card.leftGap, card.targetLeftGap ?? card.leftGap, eased)\n    }\n\n    this.render()\n\n    if (eased < 1) {\n      this.animationFrame = requestAnimationFrame(this.animate)\n    } else {\n      this.finishAnimation()\n    }\n  }\n\n  private finishAnimation() {\n    const first = this.cards.findIndex(card => card.columnIndex === 0)\n    this.cards = this.cards.slice(Math.max(first, 0), Math.max(first, 0) + this.visibleCardsCount)\n    this.columnIndexOffset = 0\n    this.cardsOffsetX = 0\n    this.render()\n  }\n\n  /* ---- rendering ------------------------------------------------------------------------------- */\n\n  private render = () => {\n    if (this.disposed) return\n    this.cards.forEach((card, index) => {\n      card.x = index === 0 ? this.cardsOffsetX : this.cards[index - 1].x + this.cards[index - 1].width + card.leftGap\n    })\n    this.ctx.clearRect(0, 0, this.canvasWidth, this.canvasHeight)\n    for (const card of this.cards) {\n      if (card.x + card.width < 0 || card.x > this.canvasWidth) continue\n      this.renderCard(card)\n    }\n  }\n\n  private renderCard({ image, width, x, collapsedOffsetX }: EngineCard) {\n    if (!image.complete || image.naturalWidth === 0 || width <= 0) return\n\n    const { ctx, canvasHeight, imageWidth } = this\n    ctx.save()\n    this.clipRoundedColumn(x, width)\n\n    // Cover-fit the image into the fixed image box, then centre that box on the card.\n    const imageRatio = image.naturalWidth / image.naturalHeight\n    let drawWidth: number\n    let drawHeight: number\n    let boxOffsetX: number\n    let boxOffsetY: number\n    if (imageRatio > imageWidth / canvasHeight) {\n      drawHeight = canvasHeight\n      drawWidth = canvasHeight * imageRatio\n      boxOffsetX = (imageWidth - drawWidth) / 2\n      boxOffsetY = 0\n    } else {\n      drawWidth = imageWidth\n      drawHeight = imageWidth / imageRatio\n      boxOffsetX = 0\n      boxOffsetY = (canvasHeight - drawHeight) / 2\n    }\n    const drawX = boxOffsetX + (x + width / 2 - drawWidth / 2) - collapsedOffsetX\n    ctx.drawImage(image, drawX, boxOffsetY, drawWidth, drawHeight)\n    ctx.restore()\n  }\n\n  private clipRoundedColumn(x: number, width: number) {\n    const height = this.canvasHeight\n    const radius = clamp(this.borderRadius, 0, Math.min(width, height) / 2)\n    const path = new Path2D()\n    path.moveTo(x + radius, 0)\n    path.lineTo(x + width - radius, 0)\n    path.arcTo(x + width, 0, x + width, radius, radius)\n    path.lineTo(x + width, height - radius)\n    path.arcTo(x + width, height, x + width - radius, height, radius)\n    path.lineTo(x + radius, height)\n    path.arcTo(x, height, x, height - radius, radius)\n    path.lineTo(x, radius)\n    path.arcTo(x, 0, x + radius, 0, radius)\n    path.closePath()\n    this.ctx.clip(path)\n  }\n\n  /* ---- pointer --------------------------------------------------------------------------------- */\n\n  private columnAt(offsetX: number) {\n    return this.cards.find(card => card.x <= offsetX && offsetX <= card.x + card.width)?.columnIndex ?? -1\n  }\n\n  private handlePointerMove = (event: PointerEvent) => {\n    if (event.pointerType === \"touch\") return\n    const column = this.columnAt(event.offsetX)\n    if (column >= 0 && column !== this.hoveredColumn) {\n      this.hoveredColumn = column\n      this.updateFlex()\n    }\n  }\n\n  private handlePointerLeave = () => {\n    if (this.hoveredColumn === -1) return\n    this.hoveredColumn = -1\n    this.updateFlex()\n  }\n\n  private handleClick = (event: MouseEvent) => {\n    const column = this.columnAt(event.offsetX)\n    if (column > 0) this.onColumnClick(column)\n    else if (column === 0) this.onPrimaryClick?.(event)\n  }\n}\n\n/* -------------------------------------------------------------------------------------------------\n * Hooks\n * -----------------------------------------------------------------------------------------------*/\n\nfunction usePrefersReducedMotion() {\n  return React.useSyncExternalStore(\n    onChange => {\n      const query = window.matchMedia(\"(prefers-reduced-motion: reduce)\")\n      query.addEventListener(\"change\", onChange)\n      return () => query.removeEventListener(\"change\", onChange)\n    },\n    () => window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches,\n    () => false,\n  )\n}\n\n/** True once the element has come within `rootMargin` of the viewport. Never goes back to false. */\nfunction useNearViewport<T extends Element>(ref: React.RefObject<T | null>, rootMargin = \"3000px 0px\") {\n  const [isNear, setIsNear] = React.useState(false)\n  React.useEffect(() => {\n    const element = ref.current\n    if (!element || isNear) return\n    if (typeof IntersectionObserver === \"undefined\") {\n      setIsNear(true)\n      return\n    }\n    const observer = new IntersectionObserver(\n      entries => {\n        if (entries.some(entry => entry.isIntersecting)) {\n          setIsNear(true)\n          observer.disconnect()\n        }\n      },\n      { rootMargin },\n    )\n    observer.observe(element)\n    return () => observer.disconnect()\n  }, [ref, rootMargin, isNear])\n  return isNear\n}\n\nfunction composeRefs<T>(...refs: Array<React.Ref<T> | undefined>): React.RefCallback<T> {\n  return node => {\n    for (const ref of refs) {\n      if (typeof ref === \"function\") ref(node)\n      else if (ref) (ref as React.MutableRefObject<T | null>).current = node\n    }\n  }\n}\n\n/* -------------------------------------------------------------------------------------------------\n * Context\n * -----------------------------------------------------------------------------------------------*/\n\ninterface SqueezeCarouselContextValue {\n  items: SqueezeCarouselItem[]\n  count: number\n  activeIndex: number\n  activeIndexRef: React.MutableRefObject<number>\n  goTo: (index: number, options?: SqueezeCarouselNavigateOptions) => void\n  goToNext: (steps?: number, options?: SqueezeCarouselNavigateOptions) => void\n  goToPrevious: (steps?: number, options?: SqueezeCarouselNavigateOptions) => void\n  engineRef: React.MutableRefObject<SqueezeCanvasEngine | null>\n  actionRefs: React.MutableRefObject<Map<number, HTMLElement>>\n  titleId: string\n  borderRadius: number\n  imageHeight?: number\n  crossOrigin?: SqueezeCarouselCrossOrigin\n  prefersReducedMotion: boolean\n  onPrimaryClick: (event: MouseEvent) => void\n}\n\nconst SqueezeCarouselContext = React.createContext<SqueezeCarouselContextValue | null>(null)\n\nexport function useSqueezeCarousel() {\n  const context = React.useContext(SqueezeCarouselContext)\n  if (!context) throw new Error(\"SqueezeCarousel components must be used within <SqueezeCarousel>\")\n  return context\n}\n\ninterface SqueezeCarouselItemContextValue {\n  item: SqueezeCarouselItem\n  index: number\n  /** Which list this item is rendered in. Only the desktop details take part in focus management. */\n  surface: \"details\" | \"mobile\"\n}\n\nconst SqueezeCarouselItemContext = React.createContext<SqueezeCarouselItemContextValue | null>(null)\n\nexport function useSqueezeCarouselItem() {\n  const context = React.useContext(SqueezeCarouselItemContext)\n  if (!context) {\n    throw new Error(\n      \"SqueezeCarousel item components must be used within <SqueezeCarouselDetail> or <SqueezeCarouselMobileItem>\",\n    )\n  }\n  return context\n}\n\n/* -------------------------------------------------------------------------------------------------\n * Root\n * -----------------------------------------------------------------------------------------------*/\n\nexport interface SqueezeCarouselProps extends React.ComponentProps<\"section\"> {\n  /** Items to show. Keep the array reference stable (module scope or useMemo) to avoid re-creating the canvas. */\n  items: SqueezeCarouselItem[]\n  /** Controlled active item index. */\n  activeIndex?: number\n  /** Initial active item index for uncontrolled usage. @default 0 */\n  defaultActiveIndex?: number\n  /** Called whenever the active index changes, in both controlled and uncontrolled mode. */\n  onActiveIndexChange?: (index: number) => void\n  /** Corner radius of the cards in CSS pixels. Also exposed as `--squeeze-carousel-radius`. @default 6 */\n  borderRadius?: number\n  /**\n   * Height of the images as a percentage of the small viewport height (`svh`), for both the\n   * desktop canvas and the mobile cards. For example `50` makes the images exactly 50svh tall.\n   * When omitted the canvas keeps a 1232:460 aspect ratio and mobile cards 336:350.\n   */\n  imageHeight?: number\n  /**\n   * Called when the primary (fully revealed) card is clicked. Defaults to activating the item's\n   * `SqueezeCarouselDetailAction` (or opening `item.href`), with modifier keys opening a new tab.\n   */\n  onActiveItemClick?: (item: SqueezeCarouselItem, index: number, event: MouseEvent) => void\n  /** `crossOrigin` used when loading canvas images. Only needed if you read the canvas pixels back. */\n  crossOrigin?: SqueezeCarouselCrossOrigin\n  /** Text announced to screen readers when the active item changes. */\n  announce?: (item: SqueezeCarouselItem, index: number, count: number) => string\n}\n\nconst defaultAnnounce = (item: SqueezeCarouselItem, index: number, count: number) =>\n  `Item ${index + 1} of ${count}: ${item.title}`\n\nfunction SqueezeCarousel({\n  items,\n  activeIndex: activeIndexProp,\n  defaultActiveIndex = 0,\n  onActiveIndexChange,\n  borderRadius = SQUEEZE.borderRadius,\n  imageHeight,\n  onActiveItemClick,\n  crossOrigin,\n  announce = defaultAnnounce,\n  className,\n  style,\n  children,\n  ...props\n}: SqueezeCarouselProps) {\n  const count = items.length\n  const [activeIndexState, setActiveIndexState] = useControllableState({\n    prop: activeIndexProp,\n    defaultProp: defaultActiveIndex,\n    onChange: onActiveIndexChange,\n    caller: \"SqueezeCarousel\",\n  })\n  const activeIndex = count ? mod(activeIndexState, count) : 0\n\n  const titleId = React.useId()\n  const engineRef = React.useRef<SqueezeCanvasEngine | null>(null)\n  const actionRefs = React.useRef(new Map<number, HTMLElement>())\n  const activeIndexRef = React.useRef(activeIndex)\n  activeIndexRef.current = activeIndex\n  const prefersReducedMotion = usePrefersReducedMotion()\n  const [focusRequest, setFocusRequest] = React.useState(0)\n\n  const navigateBy = React.useCallback(\n    (delta: number, options?: SqueezeCarouselNavigateOptions) => {\n      if (!count) return\n      if (delta !== 0) {\n        engineRef.current?.navigate(delta)\n        setActiveIndexState(previous => mod((previous ?? 0) + delta, count))\n      }\n      if (options?.focus) setFocusRequest(request => request + 1)\n    },\n    [count, setActiveIndexState],\n  )\n\n  const goToNext = React.useCallback(\n    (steps = 1, options?: SqueezeCarouselNavigateOptions) => navigateBy(Math.abs(steps), options),\n    [navigateBy],\n  )\n  const goToPrevious = React.useCallback(\n    (steps = 1, options?: SqueezeCarouselNavigateOptions) => navigateBy(-Math.abs(steps), options),\n    [navigateBy],\n  )\n  const goTo = React.useCallback(\n    (index: number, options?: SqueezeCarouselNavigateOptions) => {\n      if (!count) return\n      const target = mod(index, count)\n      const current = activeIndexRef.current\n      const forward = mod(target - current, count)\n      const backward = mod(current - target, count)\n      navigateBy(forward <= backward ? forward : -backward, options)\n    },\n    [count, navigateBy],\n  )\n\n  // Keep the canvas in sync with controlled updates coming from outside.\n  React.useEffect(() => {\n    const engine = engineRef.current\n    if (engine && engine.activeIndex !== activeIndex) engine.setActiveIndex(activeIndex)\n  }, [activeIndex])\n\n  // Move focus to the active action after keyboard navigation.\n  React.useEffect(() => {\n    if (focusRequest === 0) return\n    actionRefs.current.get(activeIndex)?.focus()\n  }, [focusRequest, activeIndex])\n\n  // Clicking the primary card behaves like clicking the item's action.\n  const onActiveItemClickRef = React.useRef(onActiveItemClick)\n  onActiveItemClickRef.current = onActiveItemClick\n  const onPrimaryClick = React.useCallback(\n    (event: MouseEvent) => {\n      const index = activeIndexRef.current\n      const item = items[index]\n      if (!item) return\n      if (onActiveItemClickRef.current) {\n        onActiveItemClickRef.current(item, index, event)\n        return\n      }\n      const action = actionRefs.current.get(index)\n      const href = action?.getAttribute(\"href\") ?? item.href\n      if (event.metaKey || event.ctrlKey || event.shiftKey) {\n        if (href) window.open(href, \"_blank\", \"noopener\")\n        return\n      }\n      if (action) action.click()\n      else if (href) window.location.assign(href)\n    },\n    [items],\n  )\n\n  const value = React.useMemo<SqueezeCarouselContextValue>(\n    () => ({\n      items,\n      count,\n      activeIndex,\n      activeIndexRef,\n      goTo,\n      goToNext,\n      goToPrevious,\n      engineRef,\n      actionRefs,\n      titleId,\n      borderRadius,\n      imageHeight,\n      crossOrigin,\n      prefersReducedMotion,\n      onPrimaryClick,\n    }),\n    [\n      items,\n      count,\n      activeIndex,\n      goTo,\n      goToNext,\n      goToPrevious,\n      titleId,\n      borderRadius,\n      imageHeight,\n      crossOrigin,\n      prefersReducedMotion,\n      onPrimaryClick,\n    ],\n  )\n\n  const activeItem = items[activeIndex]\n\n  return (\n    <SqueezeCarouselContext.Provider value={value}>\n      <section\n        data-slot=\"squeeze-carousel\"\n        data-active-index={activeIndex}\n        aria-roledescription=\"carousel\"\n        aria-labelledby={titleId}\n        className={cn(\"flex w-full flex-col gap-8\", className)}\n        style={\n          {\n            \"--squeeze-carousel-radius\": `${borderRadius}px`,\n            ...(imageHeight !== undefined && { \"--squeeze-carousel-image-height\": `${imageHeight}svh` }),\n            ...style,\n          } as React.CSSProperties\n        }\n        {...props}\n      >\n        {children}\n        <div data-slot=\"squeeze-carousel-status\" aria-live=\"polite\" aria-atomic=\"true\" className=\"sr-only\">\n          {activeItem ? announce(activeItem, activeIndex, count) : null}\n        </div>\n      </section>\n    </SqueezeCarouselContext.Provider>\n  )\n}\n\n/* -------------------------------------------------------------------------------------------------\n * Header\n * -----------------------------------------------------------------------------------------------*/\n\nexport type SqueezeCarouselHeaderProps = React.ComponentProps<\"header\">\n\nfunction SqueezeCarouselHeader({ className, ...props }: SqueezeCarouselHeaderProps) {\n  return (\n    <header\n      data-slot=\"squeeze-carousel-header\"\n      className={cn(\"mb-2 flex items-end justify-between gap-16 lg:mb-0\", className)}\n      {...props}\n    />\n  )\n}\n\nexport type SqueezeCarouselHeadingProps = React.ComponentProps<\"div\">\n\nfunction SqueezeCarouselHeading({ className, ...props }: SqueezeCarouselHeadingProps) {\n  return (\n    <div data-slot=\"squeeze-carousel-heading\" className={cn(\"flex flex-col sm:mb-2 lg:mb-8\", className)} {...props} />\n  )\n}\n\nexport interface SqueezeCarouselTitleProps extends React.ComponentProps<\"h2\"> {\n  asChild?: boolean\n}\n\nconst headingLgClassName =\n  \"max-w-[43ch] text-pretty text-[1.375rem] font-light leading-[1.2] tracking-[-0.01em] sm:text-[1.75rem] sm:leading-[1.1] lg:text-[2rem] lg:leading-[1.07] lg:tracking-[-0.02em]\"\n\nfunction SqueezeCarouselTitle({ asChild, className, ...props }: SqueezeCarouselTitleProps) {\n  const { titleId } = useSqueezeCarousel()\n  const Comp = asChild ? Slot : \"h2\"\n  return (\n    <Comp\n      id={titleId}\n      data-slot=\"squeeze-carousel-title\"\n      className={cn(headingLgClassName, \"text-foreground\", className)}\n      {...props}\n    />\n  )\n}\n\nexport interface SqueezeCarouselDescriptionProps extends React.ComponentProps<\"p\"> {\n  asChild?: boolean\n}\n\nfunction SqueezeCarouselDescription({ asChild, className, ...props }: SqueezeCarouselDescriptionProps) {\n  const Comp = asChild ? Slot : \"p\"\n  return (\n    <Comp\n      data-slot=\"squeeze-carousel-description\"\n      className={cn(headingLgClassName, \"text-muted-foreground\", className)}\n      {...props}\n    />\n  )\n}\n\n/* -------------------------------------------------------------------------------------------------\n * Controls\n * -----------------------------------------------------------------------------------------------*/\n\nexport type SqueezeCarouselControlsProps = React.ComponentProps<\"div\">\n\nfunction SqueezeCarouselControls({ className, ...props }: SqueezeCarouselControlsProps) {\n  return (\n    <div\n      role=\"group\"\n      aria-label=\"Carousel navigation\"\n      data-slot=\"squeeze-carousel-controls\"\n      className={cn(\"hidden shrink-0 gap-2 sm:flex\", className)}\n      {...props}\n    />\n  )\n}\n\nexport type SqueezeCarouselNavButtonProps = React.ComponentProps<typeof Button>\n\nfunction useNavKeyDown(onKeyDown?: React.KeyboardEventHandler<HTMLButtonElement>) {\n  const { goToNext, goToPrevious } = useSqueezeCarousel()\n  return React.useCallback(\n    (event: React.KeyboardEvent<HTMLButtonElement>) => {\n      onKeyDown?.(event)\n      if (event.defaultPrevented) return\n      if (event.key === \"ArrowLeft\") {\n        event.preventDefault()\n        goToPrevious()\n      } else if (event.key === \"ArrowRight\") {\n        event.preventDefault()\n        goToNext()\n      }\n    },\n    [onKeyDown, goToNext, goToPrevious],\n  )\n}\n\nconst navButtonClassName = \"size-10 rounded-md [&_svg]:size-4\"\n\nfunction SqueezeCarouselPrevious({ className, children, onClick, onKeyDown, ...props }: SqueezeCarouselNavButtonProps) {\n  const { goToPrevious } = useSqueezeCarousel()\n  const handleKeyDown = useNavKeyDown(onKeyDown)\n  return (\n    <Button\n      type=\"button\"\n      variant=\"secondary\"\n      size=\"icon\"\n      aria-label=\"Previous slide\"\n      data-slot=\"squeeze-carousel-previous\"\n      className={cn(navButtonClassName, className)}\n      onClick={event => {\n        onClick?.(event)\n        if (!event.defaultPrevented) goToPrevious()\n      }}\n      onKeyDown={handleKeyDown}\n      {...props}\n    >\n      {children ?? <ArrowLeft aria-hidden=\"true\" />}\n    </Button>\n  )\n}\n\nfunction SqueezeCarouselNext({ className, children, onClick, onKeyDown, ...props }: SqueezeCarouselNavButtonProps) {\n  const { goToNext } = useSqueezeCarousel()\n  const handleKeyDown = useNavKeyDown(onKeyDown)\n  return (\n    <Button\n      type=\"button\"\n      variant=\"secondary\"\n      size=\"icon\"\n      aria-label=\"Next slide\"\n      data-slot=\"squeeze-carousel-next\"\n      className={cn(navButtonClassName, className)}\n      onClick={event => {\n        onClick?.(event)\n        if (!event.defaultPrevented) goToNext()\n      }}\n      onKeyDown={handleKeyDown}\n      {...props}\n    >\n      {children ?? <ArrowRight aria-hidden=\"true\" />}\n    </Button>\n  )\n}\n\n/* -------------------------------------------------------------------------------------------------\n * Canvas (desktop image strip)\n * -----------------------------------------------------------------------------------------------*/\n\nexport type SqueezeCarouselCanvasProps = React.ComponentProps<\"canvas\">\n\nfunction SqueezeCarouselCanvas({ className, ref, ...props }: SqueezeCarouselCanvasProps) {\n  const {\n    items,\n    engineRef,\n    activeIndexRef,\n    goToNext,\n    borderRadius,\n    imageHeight,\n    crossOrigin,\n    prefersReducedMotion,\n    onPrimaryClick,\n  } = useSqueezeCarousel()\n  const canvasRef = React.useRef<HTMLCanvasElement | null>(null)\n  const isNear = useNearViewport(canvasRef)\n  const goToNextRef = React.useRef(goToNext)\n  goToNextRef.current = goToNext\n  const onPrimaryClickRef = React.useRef(onPrimaryClick)\n  onPrimaryClickRef.current = onPrimaryClick\n\n  React.useEffect(() => {\n    const canvas = canvasRef.current\n    if (!canvas || !isNear || items.length === 0) return\n    const engine = new SqueezeCanvasEngine({\n      canvas,\n      items,\n      initialIndex: activeIndexRef.current,\n      onColumnClick: steps => goToNextRef.current(steps),\n      onPrimaryClick: event => onPrimaryClickRef.current(event),\n      prefersReducedMotion,\n      borderRadius,\n      crossOrigin,\n    })\n    engineRef.current = engine\n    return () => {\n      engine.dispose()\n      if (engineRef.current === engine) engineRef.current = null\n    }\n  }, [items, isNear, prefersReducedMotion, borderRadius, crossOrigin, engineRef, activeIndexRef])\n\n  return (\n    <canvas\n      ref={composeRefs(canvasRef, ref)}\n      data-slot=\"squeeze-carousel-canvas\"\n      aria-hidden=\"true\"\n      className={cn(\n        \"hidden w-full sm:block\",\n        imageHeight === undefined ? \"aspect-[1232/460]\" : \"h-[var(--squeeze-carousel-image-height)]\",\n        className,\n      )}\n      {...props}\n    />\n  )\n}\n\n/* -------------------------------------------------------------------------------------------------\n * Details (desktop copy under the canvas)\n * -----------------------------------------------------------------------------------------------*/\n\nexport interface SqueezeCarouselDetailsProps extends Omit<React.ComponentProps<\"div\">, \"children\"> {\n  /** Either static children or a render function called once per item. */\n  children?: React.ReactNode | SqueezeCarouselRenderItem\n}\n\nfunction SqueezeCarouselDetails({ className, children, ...props }: SqueezeCarouselDetailsProps) {\n  const { items } = useSqueezeCarousel()\n  return (\n    <div data-slot=\"squeeze-carousel-details\" className={cn(\"hidden min-w-0 sm:flex\", className)} {...props}>\n      {typeof children === \"function\"\n        ? items.map((item, index) => <React.Fragment key={item.id}>{children(item, index)}</React.Fragment>)\n        : children}\n    </div>\n  )\n}\n\nexport interface SqueezeCarouselDetailProps extends React.ComponentProps<\"div\"> {\n  /** Index of the item this detail belongs to. */\n  index: number\n}\n\nfunction SqueezeCarouselDetail({ index, className, style, ...props }: SqueezeCarouselDetailProps) {\n  const { items, activeIndex, count } = useSqueezeCarousel()\n  const item = items[index]\n  const active = index === activeIndex\n  const value = React.useMemo<SqueezeCarouselItemContextValue>(\n    () => ({ item, index, surface: \"details\" }),\n    [item, index],\n  )\n  if (!item) return null\n  return (\n    <SqueezeCarouselItemContext.Provider value={value}>\n      <div\n        role=\"group\"\n        aria-roledescription=\"slide\"\n        aria-label={`${index + 1} of ${count}`}\n        aria-hidden={!active}\n        data-slot=\"squeeze-carousel-detail\"\n        data-state={active ? \"active\" : \"inactive\"}\n        data-index={index}\n        className={cn(\n          \"grid w-full shrink-0 content-start items-start justify-between gap-8 transition-opacity duration-[120ms] ease-linear motion-reduce:transition-none lg:grid-cols-[1fr_auto]\",\n          \"data-[state=inactive]:pointer-events-none data-[state=inactive]:opacity-0\",\n          className,\n        )}\n        style={{ transform: `translateX(${-100 * index}%)`, ...style }}\n        {...props}\n      />\n    </SqueezeCarouselItemContext.Provider>\n  )\n}\n\n/* -------------------------------------------------------------------------------------------------\n * Item copy (shared by details and mobile cards)\n * -----------------------------------------------------------------------------------------------*/\n\nconst fadeWithScrollStyle: React.CSSProperties = { opacity: \"calc(1 - var(--squeeze-item-distance, 0))\" }\n\nexport type SqueezeCarouselDetailCopyProps = React.ComponentProps<\"div\">\n\nfunction SqueezeCarouselDetailCopy({ className, style, ...props }: SqueezeCarouselDetailCopyProps) {\n  const { surface } = useSqueezeCarouselItem()\n  const { prefersReducedMotion } = useSqueezeCarousel()\n  const mobile = surface === \"mobile\"\n  return (\n    <div\n      data-slot=\"squeeze-carousel-detail-copy\"\n      className={cn(!mobile && \"pr-28 lg:max-w-[calc(460px*16/9)] lg:pr-0\", className)}\n      style={mobile && !prefersReducedMotion ? { ...fadeWithScrollStyle, ...style } : style}\n      {...props}\n    />\n  )\n}\n\nconst headingSmClassName =\n  \"inline text-[1.125rem] font-light leading-[1.25] tracking-[-0.01em] sm:text-[1.25rem] sm:leading-[1.12] lg:text-[1.375rem] lg:leading-[1.1]\"\n\nexport interface SqueezeCarouselDetailTitleProps extends React.ComponentProps<\"h3\"> {\n  asChild?: boolean\n}\n\nfunction SqueezeCarouselDetailTitle({ asChild, className, ...props }: SqueezeCarouselDetailTitleProps) {\n  const Comp = asChild ? Slot : \"h3\"\n  return (\n    <Comp\n      data-slot=\"squeeze-carousel-detail-title\"\n      className={cn(headingSmClassName, \"text-foreground after:content-['_']\", className)}\n      {...props}\n    />\n  )\n}\n\nexport interface SqueezeCarouselDetailDescriptionProps extends React.ComponentProps<\"p\"> {\n  asChild?: boolean\n}\n\nfunction SqueezeCarouselDetailDescription({ asChild, className, ...props }: SqueezeCarouselDetailDescriptionProps) {\n  const Comp = asChild ? Slot : \"p\"\n  return (\n    <Comp\n      data-slot=\"squeeze-carousel-detail-description\"\n      className={cn(headingSmClassName, \"text-muted-foreground\", className)}\n      {...props}\n    />\n  )\n}\n\nexport type SqueezeCarouselDetailActionProps = React.ComponentProps<typeof Button>\n\nfunction SqueezeCarouselDetailAction({\n  className,\n  style,\n  onFocus,\n  onKeyDown,\n  ref,\n  ...props\n}: SqueezeCarouselDetailActionProps) {\n  const { index, surface } = useSqueezeCarouselItem()\n  const { activeIndex, count, goTo, goToNext, goToPrevious, actionRefs, prefersReducedMotion } = useSqueezeCarousel()\n  const mobile = surface === \"mobile\"\n  const active = index === activeIndex\n\n  const registerRef = React.useCallback(\n    (node: HTMLButtonElement | null) => {\n      if (mobile) return\n      if (node) actionRefs.current.set(index, node)\n      else actionRefs.current.delete(index)\n    },\n    [actionRefs, index, mobile],\n  )\n\n  return (\n    <Button\n      ref={composeRefs(registerRef, ref)}\n      variant=\"outline\"\n      data-slot=\"squeeze-carousel-detail-action\"\n      data-state={mobile ? undefined : active ? \"active\" : \"inactive\"}\n      tabIndex={mobile ? undefined : active ? 0 : -1}\n      className={cn(\n        \"group h-12 gap-2 rounded-md px-5 text-base font-medium\",\n        mobile && \"mt-auto self-start\",\n        className,\n      )}\n      style={mobile && !prefersReducedMotion ? { ...fadeWithScrollStyle, ...style } : style}\n      onFocus={event => {\n        onFocus?.(event)\n        if (!mobile && !event.defaultPrevented && !active) goTo(index)\n      }}\n      onKeyDown={event => {\n        onKeyDown?.(event)\n        if (mobile || event.defaultPrevented) return\n        switch (event.key) {\n          case \"ArrowLeft\":\n            event.preventDefault()\n            goToPrevious(1, { focus: true })\n            break\n          case \"ArrowRight\":\n            event.preventDefault()\n            goToNext(1, { focus: true })\n            break\n          case \"Home\":\n            event.preventDefault()\n            goTo(0, { focus: true })\n            break\n          case \"End\":\n            event.preventDefault()\n            goTo(count - 1, { focus: true })\n            break\n        }\n      }}\n      {...props}\n    />\n  )\n}\n\nexport type SqueezeCarouselActionIconProps = React.ComponentProps<\"svg\">\n\n/** Arrow whose shaft grows in when the parent `.group` is hovered. */\nfunction SqueezeCarouselActionIcon({ className, ...props }: SqueezeCarouselActionIconProps) {\n  const clipId = React.useId()\n  return (\n    <svg\n      data-slot=\"squeeze-carousel-action-icon\"\n      width=\"5\"\n      height=\"8\"\n      viewBox=\"0 0.5 5 8\"\n      fill=\"none\"\n      aria-hidden=\"true\"\n      className={cn(\"inline size-auto shrink-0 overflow-visible\", className)}\n      {...props}\n    >\n      <defs>\n        <clipPath id={clipId}>\n          <rect x=\"0\" y=\"0\" width=\"12\" height=\"9\" />\n        </clipPath>\n      </defs>\n      <g clipPath={`url(#${clipId})`}>\n        <g className=\"transition-transform duration-300 ease-[cubic-bezier(.25,1,.5,1)] group-hover:translate-x-1.5 motion-reduce:transition-none\">\n          <rect\n            className=\"opacity-0 transition-opacity duration-300 ease-[cubic-bezier(.25,1,.5,1)] group-hover:opacity-100 motion-reduce:transition-none\"\n            x=\"-10\"\n            y=\"3.375\"\n            width=\"13\"\n            height=\"1.75\"\n            fill=\"currentColor\"\n          />\n          <path\n            d=\"M4.84766 3.63379L5.45898 4.25L4.84766 4.86621L1.24219 8.49902L0 7.2666L2.99316 4.24902L0 1.23242L1.24219 0L4.84766 3.63379Z\"\n            fill=\"currentColor\"\n          />\n        </g>\n      </g>\n    </svg>\n  )\n}\n\n/* -------------------------------------------------------------------------------------------------\n * Mobile list (scroll-snap cards below the sm breakpoint)\n * -----------------------------------------------------------------------------------------------*/\n\nexport interface SqueezeCarouselMobileListProps extends Omit<React.ComponentProps<\"ul\">, \"children\"> {\n  /** Either static children or a render function called once per item. */\n  children?: React.ReactNode | SqueezeCarouselRenderItem\n}\n\nfunction SqueezeCarouselMobileList({ className, children, onScroll, ref, ...props }: SqueezeCarouselMobileListProps) {\n  const { items } = useSqueezeCarousel()\n  const listRef = React.useRef<HTMLUListElement | null>(null)\n  const frame = React.useRef(0)\n\n  const updateProgress = React.useCallback(() => {\n    const list = listRef.current\n    if (!list) return\n    const first = list.firstElementChild as HTMLElement | null\n    const gap = parseFloat(getComputedStyle(list).columnGap) || 0\n    const step = first ? first.offsetWidth + gap : list.clientWidth\n    list.style.setProperty(\"--squeeze-scroll-progress\", step > 0 ? String(list.scrollLeft / step) : \"0\")\n  }, [])\n\n  React.useEffect(() => {\n    updateProgress()\n    const list = listRef.current\n    if (!list || typeof ResizeObserver === \"undefined\") return\n    const observer = new ResizeObserver(updateProgress)\n    observer.observe(list)\n    return () => {\n      observer.disconnect()\n      cancelAnimationFrame(frame.current)\n    }\n  }, [updateProgress])\n\n  return (\n    <ul\n      ref={composeRefs(listRef, ref)}\n      role=\"list\"\n      data-slot=\"squeeze-carousel-mobile-list\"\n      className={cn(\n        \"flex snap-x snap-mandatory gap-4 overflow-x-auto overscroll-x-contain [scrollbar-width:none] [&::-webkit-scrollbar]:hidden sm:hidden\",\n        className,\n      )}\n      onScroll={event => {\n        onScroll?.(event)\n        cancelAnimationFrame(frame.current)\n        frame.current = requestAnimationFrame(updateProgress)\n      }}\n      {...props}\n    >\n      {typeof children === \"function\"\n        ? items.map((item, index) => <React.Fragment key={item.id}>{children(item, index)}</React.Fragment>)\n        : children}\n    </ul>\n  )\n}\n\nexport interface SqueezeCarouselMobileItemProps extends React.ComponentProps<\"li\"> {\n  /** Index of the item this card belongs to. */\n  index: number\n}\n\nfunction SqueezeCarouselMobileItem({ index, className, style, ...props }: SqueezeCarouselMobileItemProps) {\n  const { items } = useSqueezeCarousel()\n  const item = items[index]\n  const value = React.useMemo<SqueezeCarouselItemContextValue>(\n    () => ({ item, index, surface: \"mobile\" }),\n    [item, index],\n  )\n  if (!item) return null\n  return (\n    <SqueezeCarouselItemContext.Provider value={value}>\n      <li\n        data-slot=\"squeeze-carousel-mobile-item\"\n        data-index={index}\n        className={cn(\"flex shrink-0 basis-full snap-start flex-col gap-6\", className)}\n        style={\n          {\n            \"--squeeze-item-index\": String(index),\n            \"--squeeze-item-progress\":\n              \"clamp(-1, calc(var(--squeeze-item-index) - var(--squeeze-scroll-progress, 0)), 1)\",\n            \"--squeeze-item-distance\": \"max(var(--squeeze-item-progress), calc(-1 * var(--squeeze-item-progress)))\",\n            ...style,\n          } as React.CSSProperties\n        }\n        {...props}\n      />\n    </SqueezeCarouselItemContext.Provider>\n  )\n}\n\nexport type SqueezeCarouselMobileMediaProps = React.ComponentProps<\"div\">\n\n/** Image area of a mobile card. Renders the item's `mobileSrc` (or `src`) unless you pass children. */\nfunction SqueezeCarouselMobileMedia({ className, style, children, ...props }: SqueezeCarouselMobileMediaProps) {\n  const { item } = useSqueezeCarouselItem()\n  const { prefersReducedMotion, imageHeight } = useSqueezeCarousel()\n  return (\n    <div\n      data-slot=\"squeeze-carousel-mobile-media\"\n      className={cn(\n        \"pointer-events-none relative origin-center overflow-hidden rounded-[var(--squeeze-carousel-radius)] bg-muted\",\n        imageHeight === undefined ? \"aspect-[336/350]\" : \"h-[var(--squeeze-carousel-image-height)]\",\n        className,\n      )}\n      style={\n        {\n          \"--squeeze-card-scale\": \"calc(1 - var(--squeeze-item-distance, 0) * 0.05)\",\n          \"--squeeze-gap-offset\":\n            \"calc(((1 - var(--squeeze-card-scale)) * 50% + 7px / var(--squeeze-card-scale)) * var(--squeeze-item-progress, 0) * -1)\",\n          transform: \"translate3d(var(--squeeze-gap-offset), 0, 0) scale(var(--squeeze-card-scale))\",\n          ...style,\n        } as React.CSSProperties\n      }\n      {...props}\n    >\n      {children ?? (\n        // eslint-disable-next-line @next/next/no-img-element\n        <img\n          src={item.mobileSrc ?? item.src}\n          alt={item.alt ?? item.title}\n          loading=\"lazy\"\n          draggable={false}\n          data-slot=\"squeeze-carousel-mobile-image\"\n          className=\"absolute top-0 left-1/2 h-full w-full max-w-none object-cover select-none\"\n          style={{\n            transform: prefersReducedMotion\n              ? \"translate3d(-50%, 0, 0)\"\n              : \"translate3d(calc(-50% + (-30px * var(--squeeze-item-progress, 0))), 0, 0)\",\n          }}\n        />\n      )}\n    </div>\n  )\n}\n\n/* -------------------------------------------------------------------------------------------------\n * Exports\n * -----------------------------------------------------------------------------------------------*/\n\nexport {\n  SqueezeCarousel,\n  SqueezeCarouselHeader,\n  SqueezeCarouselHeading,\n  SqueezeCarouselTitle,\n  SqueezeCarouselDescription,\n  SqueezeCarouselControls,\n  SqueezeCarouselPrevious,\n  SqueezeCarouselNext,\n  SqueezeCarouselCanvas,\n  SqueezeCarouselDetails,\n  SqueezeCarouselDetail,\n  SqueezeCarouselDetailCopy,\n  SqueezeCarouselDetailTitle,\n  SqueezeCarouselDetailDescription,\n  SqueezeCarouselDetailAction,\n  SqueezeCarouselActionIcon,\n  SqueezeCarouselMobileList,\n  SqueezeCarouselMobileItem,\n  SqueezeCarouselMobileMedia,\n}\n",
      "type": "registry:component"
    },
    {
      "path": "components/ui/button.tsx",
      "content": "import * as React from \"react\"\nimport { Slot } from \"@radix-ui/react-slot\"\nimport { cva, type VariantProps } from \"class-variance-authority\"\n\nimport { cn } from \"@/lib/utils\"\n\nconst buttonVariants = cva(\n  \"cursor-pointer inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive\",\n  {\n    variants: {\n      variant: {\n        default: \"bg-primary text-primary-foreground hover:bg-primary/90\",\n        destructive:\n          \"bg-destructive text-white hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60\",\n        outline:\n          \"border bg-background shadow-xs hover:bg-accent dark:bg-input/30 dark:border-input dark:hover:bg-input/50\",\n        secondary: \"bg-secondary text-secondary-foreground hover:bg-secondary/80\",\n        ghost: \"hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50\",\n        link: \"text-primary underline-offset-4 hover:underline\",\n      },\n      size: {\n        default: \"h-9 px-4 py-2 has-[>svg]:px-3\",\n        sm: \"h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5\",\n        lg: \"h-10 rounded-md px-6 has-[>svg]:px-4\",\n        icon: \"size-9\",\n        \"icon-sm\": \"size-8\",\n        \"icon-lg\": \"size-10\",\n      },\n    },\n    defaultVariants: {\n      variant: \"default\",\n      size: \"default\",\n    },\n  },\n)\n\nfunction Button({\n  className,\n  variant,\n  size,\n  asChild = false,\n  ...props\n}: React.ComponentProps<\"button\"> &\n  VariantProps<typeof buttonVariants> & {\n    asChild?: boolean\n  }) {\n  const Comp = asChild ? Slot : \"button\"\n\n  return <Comp data-slot=\"button\" className={cn(buttonVariants({ variant, size, className }))} {...props} />\n}\n\nexport { Button, buttonVariants }\n",
      "type": "registry:ui",
      "target": ""
    }
  ]
}
