{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "poster-tunnel",
  "title": "Poster Tunnel",
  "description": "An endless tunnel lined with posters you fly through: hairline frames rush past, the far end dissolves into fog, scroll or drag to speed up or reverse, hover to slow down, and line indicators fly you to any poster.",
  "dependencies": [
    "clsx",
    "tailwind-merge"
  ],
  "files": [
    {
      "path": "registry/new-york/poster-tunnel/poster-tunnel.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\nimport { createPortal } from \"react-dom\";\nimport { clsx, type ClassValue } from \"clsx\";\nimport { twMerge } from \"tailwind-merge\";\n\nfunction cn(...inputs: ClassValue[]) {\n  return twMerge(clsx(inputs));\n}\n\nexport interface TunnelPoster {\n  src: string;\n  alt?: string;\n  title?: string;\n}\n\nexport type PosterTunnelTheme = \"dark\" | \"light\";\n\nexport interface PosterTunnelProps extends Omit<React.ComponentPropsWithoutRef<\"div\">, \"children\"> {\n  posters?: TunnelPoster[];\n  theme?: PosterTunnelTheme;\n  height?: number;\n  /** Poster size in px on wide screens; the tunnel scales down on narrow ones. */\n  posterWidth?: number;\n  posterHeight?: number;\n  /** Cruising speed in px per second along the tunnel; 0 holds still until scrolled. */\n  speed?: number;\n  /** Slow to a crawl while a poster is hovered, so it's easy to click. */\n  slowOnHover?: boolean;\n  wheelSensitivity?: number;\n  showFrames?: boolean;\n  showLines?: boolean;\n  enableLightbox?: boolean;\n}\n\nconst PALETTES = {\n  dark: {\n    background: \"#080808\",\n    frame: \"rgba(255,255,255,0.2)\",\n    text: \"rgba(255,255,255,0.9)\",\n    muted: \"rgba(255,255,255,0.42)\",\n    lineColor: \"rgba(255,255,255,0.25)\",\n    activeLineColor: \"#FFFFFF\",\n    posterInk: \"rgba(255,255,255,0.92)\",\n    posterScrim: \"linear-gradient(to top, rgba(0,0,0,0.65), rgba(0,0,0,0) 45%)\",\n    tile: \"#151515\",\n    glow: \"radial-gradient(ellipse 30% 30% at 50% 50%, rgba(8,8,8,1) 0%, rgba(8,8,8,0) 100%)\",\n    lightboxBackground: \"rgba(8,8,8,0.95)\",\n    controlColor: \"rgba(255,255,255,0.8)\",\n    emptyText: \"rgba(255,255,255,0.4)\",\n    emptyBorder: \"1.5px dashed rgba(255,255,255,0.15)\",\n  },\n  light: {\n    background: \"#F5F5F3\",\n    frame: \"rgba(0,0,0,0.16)\",\n    text: \"rgba(0,0,0,0.85)\",\n    muted: \"rgba(0,0,0,0.42)\",\n    lineColor: \"rgba(0,0,0,0.2)\",\n    activeLineColor: \"#000000\",\n    posterInk: \"rgba(255,255,255,0.95)\",\n    posterScrim: \"linear-gradient(to top, rgba(0,0,0,0.55), rgba(0,0,0,0) 45%)\",\n    tile: \"#E6E6E3\",\n    glow: \"radial-gradient(ellipse 30% 30% at 50% 50%, rgba(245,245,243,1) 0%, rgba(245,245,243,0) 100%)\",\n    lightboxBackground: \"rgba(255,255,255,0.96)\",\n    controlColor: \"rgba(0,0,0,0.75)\",\n    emptyText: \"rgba(0,0,0,0.4)\",\n    emptyBorder: \"1.5px dashed rgba(0,0,0,0.15)\",\n  },\n} as const;\n\nconst DEFAULT_POSTERS: TunnelPoster[] = [\n  { src: \"/demo/26.webp\", title: \"Breakaway\" },\n  { src: \"/demo/41.webp\", title: \"Mei Arai\" },\n  { src: \"/demo/29.webp\", title: \"First stride\" },\n  { src: \"/demo/3.webp\", title: \"Curtain study\" },\n  { src: \"/demo/35.webp\", title: \"Wind study\" },\n  { src: \"/demo/23.webp\", title: \"Climb\" },\n  { src: \"/demo/42.webp\", title: \"Kenji Ito\" },\n  { src: \"/demo/7.webp\", title: \"Pale stairwell\" },\n  { src: \"/demo/31.webp\", title: \"Into the bend\" },\n  { src: \"/demo/44.webp\", title: \"Sofia Marin\" },\n  { src: \"/demo/28.webp\", title: \"Rowing, 6 a.m.\" },\n  { src: \"/demo/36.webp\", title: \"Grey hour\" },\n  { src: \"/demo/24.webp\", title: \"Lift\" },\n  { src: \"/demo/45.webp\", title: \"Amara\" },\n  { src: \"/demo/34.webp\", title: \"Cadence\" },\n  { src: \"/demo/9.webp\", title: \"Bath\" },\n];\n\nconst clamp = (v: number, min: number, max: number) => Math.min(Math.max(v, min), max);\nconst mod = (v: number, m: number) => ((v % m) + m) % m;\nconst NEAR = 40;\n\ninterface Geo {\n  s: number;\n  W: number;\n  pw: number;\n  ph: number;\n  gap: number;\n  depth: number;\n  perspective: number;\n}\n\nfunction geometry(width: number, height: number, count: number, posterWidth: number, posterHeight: number): Geo {\n  const s = clamp(width / 900, 0.42, 1);\n  const pw = posterWidth * s;\n  const ph = posterHeight * s;\n  // Posters alternate walls, so each wall holds every other one at twice this gap.\n  const gap = pw * 0.78;\n  return { s, W: Math.max(width * 0.42, pw * 0.9), pw, ph, gap, depth: Math.max(count, 2) * gap, perspective: Math.max(height * 0.9, 420 * s) };\n}\n\n/** How far down the tunnel poster i sits (0 = at the camera, depth = the far end). */\nfunction travel(i: number, offset: number, g: Geo) {\n  return mod(i * g.gap - offset, g.depth);\n}\n\nfunction posterStyle(i: number, offset: number, g: Geo) {\n  const u = travel(i, offset, g);\n  const side = i % 2 ? 1 : -1;\n  const z = -(u + NEAR);\n  // Fade in out of the fog at the far end; gone just before passing the camera.\n  const far = clamp((g.depth - u) / (g.depth * 0.4), 0, 1);\n  const near = clamp((u - 10) / 60, 0, 1);\n  return {\n    u,\n    // One transform per poster straight under the perspective parent (no nested preserve-3d).\n    // Fixed precision so the server and browser print the same string.\n    transform: `translate3d(${(side * g.W).toFixed(2)}px, 0px, ${z.toFixed(2)}px) rotateY(${-side * 90}deg)`,\n    opacity: Number((far * far * near).toFixed(3)),\n  };\n}\n\nfunction frameStyle(j: number, frames: number, offset: number, g: Geo) {\n  const step = g.depth / frames;\n  const u = mod(j * step - offset, g.depth);\n  const fade = clamp((g.depth - u) / (g.depth * 0.5), 0, 1) * clamp((u - 20) / 120, 0, 1);\n  return { transform: `translate3d(0px, 0px, ${(-(u + NEAR)).toFixed(2)}px)`, opacity: Number(fade.toFixed(3)) };\n}\n\nexport function PosterTunnel({\n  posters = DEFAULT_POSTERS,\n  theme = \"dark\",\n  height = 600,\n  posterWidth = 290,\n  posterHeight = 390,\n  speed = 110,\n  slowOnHover = true,\n  wheelSensitivity = 1,\n  showFrames = true,\n  showLines = true,\n  enableLightbox = true,\n  className,\n  ...props\n}: PosterTunnelProps) {\n  const palette = PALETTES[theme];\n  const n = posters.length;\n  const frames = 12;\n  const rootRef = React.useRef<HTMLDivElement>(null);\n  const posterRefs = React.useRef<(HTMLDivElement | null)[]>([]);\n  const frameRefs = React.useRef<(HTMLDivElement | null)[]>([]);\n  const [width, setWidth] = React.useState(900);\n  const g = React.useMemo(() => geometry(width, height, n, posterWidth, posterHeight), [width, height, n, posterWidth, posterHeight]);\n\n  const motion = React.useRef({ offset: 0, v: speed, target: null as number | null, holdUntil: 0 });\n  const drag = React.useRef({ active: false, moved: false, x: 0, y: 0, lastT: 0, poster: null as number | null, vel: 0 });\n  const hovered = React.useRef<number | null>(null);\n  const [nearest, setNearest] = React.useState(0);\n  const wakeRef = React.useRef<() => void>(() => {});\n  const optsRef = React.useRef({ g, speed, slowOnHover, wheelSensitivity, n });\n  React.useEffect(() => {\n    optsRef.current = { g, speed, slowOnHover, wheelSensitivity, n };\n    wakeRef.current();\n  }, [g, speed, slowOnHover, wheelSensitivity, n]);\n\n  const [lightbox, setLightbox] = React.useState<number | null>(null);\n  const lightboxOpen = React.useRef(false);\n  const dialogRef = React.useRef<HTMLDivElement>(null);\n  const closeButtonRef = React.useRef<HTMLButtonElement>(null);\n  const lastFocusedRef = React.useRef<HTMLElement | null>(null);\n  React.useEffect(() => {\n    lightboxOpen.current = lightbox !== null;\n  }, [lightbox]);\n\n  React.useEffect(() => {\n    const el = rootRef.current;\n    if (!el) return;\n    const update = () => setWidth(el.clientWidth);\n    update();\n    const observer = new ResizeObserver(update);\n    observer.observe(el);\n    return () => observer.disconnect();\n  }, []);\n\n  React.useEffect(() => {\n    let raf: number | null = null;\n    let last = 0;\n    let inView = true;\n    const paint = () => {\n      const { g, n } = optsRef.current;\n      const m = motion.current;\n      let best = -1;\n      let bestU = Infinity;\n      posterRefs.current.forEach((el, i) => {\n        if (!el) return;\n        const st = posterStyle(i, m.offset, g);\n        el.style.transform = st.transform;\n        el.style.opacity = String(st.opacity);\n        el.style.visibility = st.opacity < 0.01 ? \"hidden\" : \"visible\";\n        el.style.zIndex = String(Math.round(10000 - st.u));\n        // The poster coming up next (comfortably in view, not already passing) names the readout.\n        if (st.u > g.gap * 1.1 && st.u < bestU) {\n          bestU = st.u;\n          best = i;\n        }\n      });\n      frameRefs.current.forEach((el, j) => {\n        if (!el) return;\n        const st = frameStyle(j, frames, m.offset, g);\n        el.style.transform = st.transform;\n        el.style.opacity = String(st.opacity);\n      });\n      if (best >= 0 && n) setNearest((cur) => (cur === best ? cur : best));\n    };\n    const tick = (now: number) => {\n      const dt = last ? Math.min((now - last) / 1000, 0.05) : 1 / 60;\n      last = now;\n      const { speed, slowOnHover } = optsRef.current;\n      const m = motion.current;\n      const d = drag.current;\n      if (m.target !== null) {\n        // Flying to a chosen poster: ease the offset there, then hold a moment before cruising again.\n        const diff = m.target - m.offset;\n        m.offset += diff * (1 - Math.pow(0.02, dt));\n        m.v = 0;\n        if (Math.abs(diff) < 0.5) {\n          m.offset = m.target;\n          m.target = null;\n          m.holdUntil = now + 1800;\n        }\n      } else if (!d.active) {\n        const cruise = lightboxOpen.current || now < m.holdUntil ? 0 : hovered.current !== null && slowOnHover ? speed * 0.1 : speed;\n        m.v += (cruise - m.v) * (1 - Math.pow(0.15, dt));\n        m.offset += m.v * dt;\n      }\n      paint();\n      const settled = m.target === null && !d.active && Math.abs(m.v) < 0.5 && (speed === 0 || lightboxOpen.current);\n      raf = inView && !settled ? requestAnimationFrame(tick) : null;\n      if (raf === null) last = 0;\n    };\n    wakeRef.current = () => {\n      if (raf === null && inView) raf = requestAnimationFrame(tick);\n    };\n    paint();\n    raf = requestAnimationFrame(tick);\n    const observer = new IntersectionObserver(([entry]) => {\n      inView = entry.isIntersecting;\n      if (inView) wakeRef.current();\n    });\n    if (rootRef.current) observer.observe(rootRef.current);\n    return () => {\n      if (raf) cancelAnimationFrame(raf);\n      observer.disconnect();\n    };\n  }, []);\n\n  React.useEffect(() => {\n    if (lightbox === null) wakeRef.current();\n  }, [lightbox]);\n\n  React.useEffect(() => {\n    const el = rootRef.current;\n    if (!el) return;\n    const onWheel = (e: WheelEvent) => {\n      const delta = Math.abs(e.deltaX) > Math.abs(e.deltaY) ? e.deltaX : e.deltaY;\n      // wheelSensitivity={0} hands the wheel back to the page.\n      if (!delta || !optsRef.current.wheelSensitivity) return;\n      e.preventDefault();\n      const m = motion.current;\n      m.target = null;\n      m.holdUntil = 0;\n      m.v = clamp(m.v + delta * 6 * optsRef.current.wheelSensitivity, -2400, 2400);\n      wakeRef.current();\n    };\n    const onDown = (e: PointerEvent) => {\n      // Leave the line indicators alone: capturing the pointer here would swallow their clicks.\n      if (e.button !== 0 || (e.target as HTMLElement).closest(\"button\")) return;\n      const posterEl = (e.target as HTMLElement).closest<HTMLElement>(\"[data-poster]\");\n      drag.current = { active: true, moved: false, x: e.clientX, y: e.clientY, lastT: e.timeStamp, poster: posterEl ? Number(posterEl.dataset.poster) : null, vel: 0 };\n      el.setPointerCapture(e.pointerId);\n      wakeRef.current();\n    };\n    const onMove = (e: PointerEvent) => {\n      const d = drag.current;\n      if (!d.active) {\n        if (e.pointerType !== \"mouse\") return;\n        const posterEl = (e.target as HTMLElement).closest<HTMLElement>(\"[data-poster]\");\n        const next = posterEl ? Number(posterEl.dataset.poster) : null;\n        if (next !== hovered.current) {\n          hovered.current = next;\n          el.querySelectorAll<HTMLElement>(\"[data-poster]\").forEach((p) => p.toggleAttribute(\"data-hover\", Number(p.dataset.poster) === next));\n          wakeRef.current();\n        }\n        return;\n      }\n      const dx = e.clientX - d.x;\n      const dy = e.clientY - d.y;\n      if (!d.moved && Math.hypot(dx, dy) < 6) return;\n      if (!d.moved) {\n        d.moved = true;\n        el.style.cursor = \"grabbing\";\n      }\n      // Pull down (or right) to fly forward: the posters come toward you.\n      const along = (Math.abs(dy) > Math.abs(dx) ? dy : dx) * 2.4;\n      const m = motion.current;\n      m.target = null;\n      m.offset += along;\n      const dt = Math.max((e.timeStamp - d.lastT) / 1000, 0.008);\n      d.vel = d.vel * 0.5 + (along / dt) * 0.5;\n      d.x = e.clientX;\n      d.y = e.clientY;\n      d.lastT = e.timeStamp;\n      wakeRef.current();\n    };\n    const onUp = (e: PointerEvent) => {\n      const d = drag.current;\n      if (!d.active) return;\n      d.active = false;\n      el.style.cursor = \"\";\n      const m = motion.current;\n      if (d.moved) {\n        m.v = e.timeStamp - d.lastT > 80 ? 0 : clamp(d.vel, -2400, 2400);\n      } else if (d.poster !== null && enableLightbox) setLightbox(d.poster);\n      wakeRef.current();\n    };\n    const onLeave = () => {\n      if (hovered.current === null) return;\n      hovered.current = null;\n      el.querySelectorAll<HTMLElement>(\"[data-hover]\").forEach((p) => p.removeAttribute(\"data-hover\"));\n      wakeRef.current();\n    };\n    el.addEventListener(\"wheel\", onWheel, { passive: false });\n    el.addEventListener(\"pointerdown\", onDown);\n    el.addEventListener(\"pointermove\", onMove);\n    el.addEventListener(\"pointerup\", onUp);\n    el.addEventListener(\"pointercancel\", onUp);\n    el.addEventListener(\"pointerleave\", onLeave);\n    return () => {\n      el.removeEventListener(\"wheel\", onWheel);\n      el.removeEventListener(\"pointerdown\", onDown);\n      el.removeEventListener(\"pointermove\", onMove);\n      el.removeEventListener(\"pointerup\", onUp);\n      el.removeEventListener(\"pointercancel\", onUp);\n      el.removeEventListener(\"pointerleave\", onLeave);\n    };\n  }, [enableLightbox]);\n\n  /** Fly so poster i sits 1.6 gaps ahead: the first spot past 1.1 gaps, so the readout names it (the one before is at 0.6). */\n  const flyTo = React.useCallback((i: number) => {\n    const { g } = optsRef.current;\n    const m = motion.current;\n    const wanted = g.gap * 1.6;\n    const u = travel(i, m.offset, g);\n    let delta = u - wanted;\n    if (delta < -g.depth / 2) delta += g.depth;\n    if (delta > g.depth / 2) delta -= g.depth;\n    m.target = m.offset + delta;\n    wakeRef.current();\n  }, []);\n\n  React.useEffect(() => {\n    if (lightbox === null) {\n      lastFocusedRef.current?.focus();\n      lastFocusedRef.current = null;\n      return;\n    }\n    lastFocusedRef.current = document.activeElement as HTMLElement | null;\n    closeButtonRef.current?.focus();\n    // eslint-disable-next-line react-hooks/exhaustive-deps\n  }, [lightbox !== null]);\n\n  React.useEffect(() => {\n    if (lightbox === null) return;\n    const onKey = (e: KeyboardEvent) => {\n      if (e.key === \"Escape\") setLightbox(null);\n      else if (e.key === \"ArrowRight\") setLightbox((i) => (i === null ? null : (i + 1) % n));\n      else if (e.key === \"ArrowLeft\") setLightbox((i) => (i === null ? null : (i - 1 + n) % n));\n      else if (e.key === \"Tab\") {\n        const focusables = Array.from(dialogRef.current?.querySelectorAll<HTMLElement>(\"button\") ?? []);\n        if (focusables.length === 0) return;\n        const first = focusables[0];\n        const last = focusables[focusables.length - 1];\n        if (e.shiftKey && document.activeElement === first) {\n          e.preventDefault();\n          last.focus();\n        } else if (!e.shiftKey && document.activeElement === last) {\n          e.preventDefault();\n          first.focus();\n        }\n      }\n    };\n    window.addEventListener(\"keydown\", onKey);\n    return () => window.removeEventListener(\"keydown\", onKey);\n  }, [lightbox, n]);\n\n  const onKeyDown = (e: React.KeyboardEvent) => {\n    if (lightbox !== null) return;\n    if (e.key === \"ArrowUp\" || e.key === \"ArrowRight\") flyTo((nearest + 1) % n);\n    else if (e.key === \"ArrowDown\" || e.key === \"ArrowLeft\") flyTo((nearest - 1 + n) % n);\n    else if ((e.key === \"Enter\" || e.key === \" \") && enableLightbox) setLightbox(nearest);\n    else return;\n    e.preventDefault();\n  };\n\n  if (n === 0) {\n    return (\n      <div className={cn(\"flex h-full w-full items-center justify-center rounded-xl\", className)} style={{ minHeight: 300, background: palette.background, border: palette.emptyBorder }} {...props}>\n        <span className=\"text-center text-sm leading-[1.6]\" style={{ color: palette.emptyText }}>\n          Add posters\n        </span>\n      </div>\n    );\n  }\n\n  const frameW = g.W * 2;\n  const frameH = g.ph * 1.32;\n  const current = posters[nearest];\n  const lines = Array.from({ length: n }, (_, i) => i);\n\n  return (\n    <div\n      ref={rootRef}\n      className={cn(\"relative w-full cursor-grab touch-none overflow-hidden outline-none select-none\", className)}\n      style={{ height, background: palette.background }}\n      tabIndex={0}\n      role=\"region\"\n      aria-roledescription=\"poster tunnel\"\n      aria-label=\"Poster tunnel. Scroll or drag to fly through, arrow keys to step between posters, Enter to open one.\"\n      onKeyDown={onKeyDown}\n      {...props}\n    >\n      <div className=\"absolute inset-0\" style={{ perspective: `${Math.round(g.perspective)}px`, perspectiveOrigin: \"50% 50%\" }}>\n        {showFrames &&\n          Array.from({ length: frames }, (_, j) => {\n            const st = frameStyle(j, frames, 0, g);\n            return (\n              <div\n                key={`f${j}`}\n                ref={(el) => {\n                  frameRefs.current[j] = el;\n                }}\n                className=\"pointer-events-none absolute top-1/2 left-1/2\"\n                style={{ width: frameW, height: frameH, marginLeft: -frameW / 2, marginTop: -frameH / 2, border: `1px solid ${palette.frame}`, transform: st.transform, opacity: st.opacity }}\n              />\n            );\n          })}\n        {posters.map((poster, i) => {\n          const st = posterStyle(i, 0, g);\n          return (\n            <div\n              key={i}\n              ref={(el) => {\n                posterRefs.current[i] = el;\n              }}\n              data-poster={i}\n              className=\"group absolute top-1/2 left-1/2\"\n              style={{ width: g.pw, height: g.ph, marginLeft: -g.pw / 2, marginTop: -g.ph / 2, transform: st.transform, opacity: st.opacity, zIndex: Math.round(10000 - st.u), visibility: st.opacity < 0.01 ? \"hidden\" : \"visible\", cursor: enableLightbox ? \"pointer\" : undefined }}\n            >\n              <div className=\"relative h-full w-full overflow-hidden\" style={{ borderRadius: 3, background: palette.tile }}>\n                <img src={poster.src} alt={poster.alt || poster.title || \"\"} draggable={false} decoding=\"async\" className=\"pointer-events-none block h-full w-full object-cover transition-[filter] duration-300 group-data-[hover]:brightness-110\" />\n                <div className=\"pointer-events-none absolute inset-0\" style={{ background: palette.posterScrim }} />\n                <div className=\"pointer-events-none absolute inset-x-0 bottom-0 flex items-end justify-between gap-2 p-[7%] text-[11px] leading-none\" style={{ color: palette.posterInk, fontSize: Math.max(9, 12 * g.s) }}>\n                  <span className=\"truncate tracking-[0.14em] uppercase\">{poster.title}</span>\n                  <span className=\"shrink-0 tabular-nums opacity-70\">{String(i + 1).padStart(2, \"0\")}</span>\n                </div>\n                <div className=\"pointer-events-none absolute inset-0 opacity-0 transition-opacity duration-300 group-data-[hover]:opacity-100\" style={{ boxShadow: `inset 0 0 0 1.5px ${palette.posterInk}`, borderRadius: 3 }} />\n              </div>\n            </div>\n          );\n        })}\n      </div>\n\n      {/* the far end dissolves into the background */}\n      <div className=\"pointer-events-none absolute inset-0\" style={{ background: palette.glow }} />\n\n      <div className=\"pointer-events-none absolute bottom-6 left-5 z-10 sm:bottom-8 sm:left-8\" aria-live=\"polite\">\n        <div className=\"text-[10px] tracking-[0.2em] tabular-nums\" style={{ color: palette.muted }}>\n          {String(nearest + 1).padStart(2, \"0\")} / {String(n).padStart(2, \"0\")}\n        </div>\n        {current.title && (\n          <div className=\"mt-1.5 text-[14px]\" style={{ color: palette.text }}>\n            {current.title}\n          </div>\n        )}\n      </div>\n\n      {showLines && (\n        <div className=\"absolute right-5 bottom-6 z-10 flex items-end gap-[5px] sm:right-8 sm:bottom-8\">\n          {lines.map((i) => {\n            const isActive = i === nearest;\n            return (\n              <button\n                key={i}\n                type=\"button\"\n                onClick={() => flyTo(i)}\n                aria-label={`Fly to ${posters[i].title ?? `poster ${i + 1}`}`}\n                aria-current={isActive ? \"true\" : undefined}\n                className=\"flex h-6 w-[5px] cursor-pointer items-end justify-center border-0 bg-transparent p-0\"\n              >\n                <span className=\"block transition-[height,background] duration-[250ms] ease-[ease]\" style={{ width: 1, height: isActive ? 20 : 12, background: isActive ? palette.activeLineColor : palette.lineColor }} />\n              </button>\n            );\n          })}\n        </div>\n      )}\n\n      {enableLightbox &&\n        lightbox !== null &&\n        createPortal(\n          <div ref={dialogRef} onClick={() => setLightbox(null)} role=\"dialog\" aria-modal=\"true\" aria-label=\"Poster preview\" className=\"fixed inset-0 z-[999999] flex flex-col items-center justify-center\" style={{ background: palette.lightboxBackground }}>\n            <button\n              ref={closeButtonRef}\n              onClick={(e) => {\n                e.stopPropagation();\n                setLightbox(null);\n              }}\n              aria-label=\"Close\"\n              className=\"absolute top-6 right-8 h-10 w-10 cursor-pointer border-0 bg-transparent text-[28px] leading-none\"\n              style={{ color: palette.controlColor }}\n            >\n              ×\n            </button>\n            {n > 1 && (\n              <>\n                <button\n                  onClick={(e) => {\n                    e.stopPropagation();\n                    setLightbox((lightbox - 1 + n) % n);\n                  }}\n                  aria-label=\"Previous\"\n                  className=\"absolute top-1/2 left-6 h-11 w-11 -translate-y-1/2 cursor-pointer border-0 bg-transparent text-[32px]\"\n                  style={{ color: palette.controlColor }}\n                >\n                  ‹\n                </button>\n                <button\n                  onClick={(e) => {\n                    e.stopPropagation();\n                    setLightbox((lightbox + 1) % n);\n                  }}\n                  aria-label=\"Next\"\n                  className=\"absolute top-1/2 right-6 h-11 w-11 -translate-y-1/2 cursor-pointer border-0 bg-transparent text-[32px]\"\n                  style={{ color: palette.controlColor }}\n                >\n                  ›\n                </button>\n              </>\n            )}\n            <img\n              src={posters[lightbox].src}\n              alt={posters[lightbox].alt || posters[lightbox].title || \"\"}\n              onClick={(e) => e.stopPropagation()}\n              className=\"max-w-[82%] object-contain\"\n              style={{ maxHeight: \"78%\", borderRadius: 4, boxShadow: \"0 20px 60px rgba(0,0,0,0.6)\" }}\n              draggable={false}\n            />\n            <div className=\"mt-5 flex items-baseline gap-3 text-[13px]\" style={{ color: palette.controlColor }} onClick={(e) => e.stopPropagation()}>\n              {posters[lightbox].title && <span>{posters[lightbox].title}</span>}\n              <span className=\"text-[11px] tracking-[0.16em] uppercase tabular-nums opacity-60\">\n                {String(lightbox + 1).padStart(2, \"0\")} / {String(n).padStart(2, \"0\")}\n              </span>\n            </div>\n          </div>,\n          document.body,\n        )}\n    </div>\n  );\n}\n",
      "type": "registry:component"
    }
  ],
  "type": "registry:component"
}