{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "video-player",
  "title": "Video Player",
  "description": "A compact video player with keyboard shortcuts, chapter markers, seek previews, and volume control.",
  "dependencies": [
    "@solar-icons/react@^2.2.0",
    "cn@^0.3.0",
    "motion@^13.4.0"
  ],
  "registryDependencies": [
    "https://pastaui.com/r/pastaui-styles.json"
  ],
  "files": [
    {
      "path": "src/components/ai/video-player.tsx",
      "content": "import { MaximizeIcon as Maximize2Icon } from '@solar-icons/react/linear/maximize'\nimport { PauseIcon } from '@solar-icons/react/linear/pause'\nimport { PlayIcon } from '@solar-icons/react/linear/play'\nimport { Rewind10SecondsBackIcon as RewindIcon } from '@solar-icons/react/linear/rewind-10-seconds-back'\nimport { Rewind10SecondsForwardIcon as ForwardIcon } from '@solar-icons/react/linear/rewind-10-seconds-forward'\nimport { VolumeLoudIcon as Volume2Icon } from '@solar-icons/react/linear/volume-loud'\nimport { VolumeCrossIcon as VolumeMutedIcon } from '@solar-icons/react/linear/volume-cross'\nimport { AnimatePresence, MotionConfig, motion } from 'motion/react'\nimport * as React from 'react'\n\nimport { cn } from 'cn'\n\ninterface VideoChapter {\n  start: number\n  title: string\n}\n\ninterface VideoPlayerProps extends Omit<\n  React.ComponentProps<'section'>,\n  'title' | 'onVolumeChange'\n> {\n  chapters?: VideoChapter[]\n  currentTime: number\n  duration: number\n  onPlayingChange?: (playing: boolean) => void\n  onSeek?: (seconds: number) => void\n  onVolumeChange?: (volume: number) => void\n  playing?: boolean\n  poster?: React.ReactNode\n  subtitle?: string\n  title: React.ReactNode\n}\n\nfunction formatTime(seconds: number) {\n  const minutes = Math.floor(seconds / 60)\n  return `${minutes}:${Math.floor(seconds % 60)\n    .toString()\n    .padStart(2, '0')}`\n}\n\nconst controlSurface = 'bg-black/45'\n\nconst control =\n  'flex shrink-0 items-center justify-center rounded-md transition-[background-color,scale] duration-150 ease-out hover:bg-black/65 active:scale-[0.96] motion-reduce:active:scale-100 focus-visible:outline-2 focus-visible:outline-offset-4 focus-visible:outline-white'\n\nconst slider =\n  'block cursor-pointer appearance-none rounded-full outline-none focus-visible:ring-2 focus-visible:ring-white focus-visible:ring-offset-4 focus-visible:ring-offset-black/40 [&::-webkit-slider-thumb]:size-2.5 [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:rounded-full [&::-webkit-slider-thumb]:bg-white [&::-moz-range-thumb]:size-2.5 [&::-moz-range-thumb]:rounded-full [&::-moz-range-thumb]:border-0 [&::-moz-range-thumb]:bg-white'\n\nfunction VideoPlayer({\n  chapters = [],\n  className,\n  currentTime,\n  duration,\n  onPlayingChange,\n  onSeek,\n  onVolumeChange,\n  playing = false,\n  poster,\n  subtitle,\n  title,\n  ...props\n}: VideoPlayerProps) {\n  const playerRef = React.useRef<HTMLElement>(null)\n  const [volume, setVolume] = React.useState(0.7)\n  const [fullscreenError, setFullscreenError] = React.useState('')\n  const [idle, setIdle] = React.useState(false)\n  const [seekFlash, setSeekFlash] = React.useState<{ id: number; label: string } | null>(null)\n  const [hover, setHover] = React.useState<{ left: number; time: number } | null>(null)\n  const idleTimer = React.useRef(0)\n  const safeDuration = Math.max(0, duration)\n  const time = Math.max(0, Math.min(currentTime, safeDuration))\n  const progress = safeDuration ? (time / safeDuration) * 100 : 0\n  const sortedChapters = [...chapters].sort((a, b) => a.start - b.start)\n  const chapterAt = (seconds: number) =>\n    sortedChapters.filter((chapter) => chapter.start <= seconds).at(-1)\n  const currentChapter = chapterAt(time)\n\n  function changeVolume(value: number) {\n    setVolume(value)\n    onVolumeChange?.(value)\n  }\n\n  function wake() {\n    setIdle(false)\n    window.clearTimeout(idleTimer.current)\n    idleTimer.current = window.setTimeout(() => setIdle(true), 2200)\n  }\n\n  React.useEffect(() => {\n    if (!playing) return\n    idleTimer.current = window.setTimeout(() => setIdle(true), 2200)\n    return () => window.clearTimeout(idleTimer.current)\n  }, [playing])\n\n  React.useEffect(() => {\n    if (!seekFlash) return\n    const timer = window.setTimeout(() => setSeekFlash(null), 700)\n    return () => window.clearTimeout(timer)\n  }, [seekFlash])\n\n  function seekBy(seconds: number) {\n    onSeek?.(Math.max(0, Math.min(safeDuration, time + seconds)))\n    setSeekFlash({ id: Date.now(), label: seconds > 0 ? `+${seconds}s` : `${seconds}s` })\n    wake()\n  }\n\n  const hidden = playing && idle\n\n  function onKeyDown(event: React.KeyboardEvent<HTMLElement>) {\n    if ((event.target as HTMLElement).closest('input[aria-label=\"Volume\"]')) return\n    const key = event.key.toLowerCase()\n    const actions: Record<string, () => void> = {\n      ' ': () => onPlayingChange?.(!playing),\n      k: () => onPlayingChange?.(!playing),\n      arrowleft: () => seekBy(-10),\n      j: () => seekBy(-10),\n      arrowright: () => seekBy(10),\n      l: () => seekBy(10),\n      m: () => changeVolume(volume === 0 ? 0.7 : 0),\n      f: () => void toggleFullscreen(),\n    }\n    if (!actions[key] || event.metaKey || event.ctrlKey || event.altKey) return\n    if ((event.target as HTMLElement).tagName === 'BUTTON' && (key === ' ' || key === 'enter'))\n      return\n    event.preventDefault()\n    actions[key]()\n    wake()\n  }\n\n  async function toggleFullscreen() {\n    try {\n      if (document.fullscreenElement === playerRef.current) {\n        await document.exitFullscreen()\n      } else {\n        await playerRef.current?.requestFullscreen()\n      }\n      setFullscreenError('')\n    } catch {\n      setFullscreenError('Fullscreen is unavailable in this browser.')\n    }\n  }\n\n  return (\n    <MotionConfig reducedMotion=\"user\">\n      {/* The focusable player owns media keyboard shortcuts, like a native video element. */}\n      {/* oxlint-disable-next-line jsx-a11y/no-noninteractive-element-interactions */}\n      <section\n        ref={playerRef}\n        data-slot=\"video-player\"\n        data-idle={hidden || undefined}\n        onFocus={wake}\n        onKeyDown={onKeyDown}\n        onPointerMove={wake}\n        aria-keyshortcuts=\"Space K J L ArrowLeft ArrowRight M F\"\n        aria-label=\"Video player\"\n        // oxlint-disable-next-line jsx-a11y/no-noninteractive-tabindex\n        tabIndex={0}\n        className={cn(\n          'group/player relative isolate aspect-video min-h-64 overflow-hidden rounded-[16px] bg-neutral-950 font-sans text-sm font-[450] tracking-[-0.05px] text-white shadow-card outline-none focus-visible:ring-2 focus-visible:ring-ring data-idle:cursor-none sm:min-h-80',\n          className,\n        )}\n        {...props}\n      >\n        <div\n          className={cn(\n            'video-player-kenburns absolute inset-0 -z-20 [&>*]:size-full [&>*]:object-cover',\n            !playing && '[animation-play-state:paused]',\n          )}\n        >\n          {poster ?? (\n            <img\n              alt=\"Sunlight falling over a forested mountain valley\"\n              className=\"object-cover\"\n              src=\"https://images.unsplash.com/photo-1472396961693-142e6e269027?auto=format&fit=crop&w=1600&q=85\"\n            />\n          )}\n        </div>\n        <div className=\"pointer-events-none absolute inset-0 -z-10 bg-gradient-to-t from-black/75 via-black/10 to-black/25\" />\n\n        <div className=\"absolute inset-x-5 top-5 flex items-center justify-between gap-4 transition-[opacity,translate] duration-300 ease-[cubic-bezier(0.23,1,0.32,1)] group-data-idle/player:pointer-events-none group-data-idle/player:-translate-y-2 group-data-idle/player:opacity-0 sm:inset-x-7 sm:top-6\">\n          <button\n            aria-label=\"Toggle fullscreen\"\n            className={cn(controlSurface, control, 'size-8')}\n            onClick={() => void toggleFullscreen()}\n            type=\"button\"\n          >\n            <Maximize2Icon className=\"size-4\" />\n          </button>\n          <div className={cn(controlSurface, 'flex h-8 items-center gap-2 rounded-md px-3')}>\n            <input\n              aria-label=\"Volume\"\n              className={cn(slider, 'h-1 w-16')}\n              max={1}\n              min={0}\n              onChange={(event) => changeVolume(Number(event.target.value))}\n              step={0.01}\n              style={{\n                background: `linear-gradient(to right, white ${volume * 100}%, #ffffff40 ${volume * 100}%)`,\n              }}\n              type=\"range\"\n              value={volume}\n            />\n            <button\n              aria-label={volume === 0 ? 'Unmute' : 'Mute'}\n              className={cn(control, 'size-5')}\n              onClick={() => changeVolume(volume === 0 ? 0.7 : 0)}\n              type=\"button\"\n            >\n              <span className=\"grid *:col-start-1 *:row-start-1 *:transition-[opacity,scale] *:duration-150 *:ease-[cubic-bezier(0.23,1,0.32,1)] motion-reduce:*:transition-opacity\">\n                <Volume2Icon className={cn('size-4', volume === 0 && 'scale-75 opacity-0')} />\n                <VolumeMutedIcon className={cn('size-4', volume !== 0 && 'scale-75 opacity-0')} />\n              </span>\n            </button>\n          </div>\n        </div>\n\n        <div className=\"absolute inset-x-0 top-[45%] flex -translate-y-1/2 items-center justify-center gap-4 transition-[opacity,translate] duration-300 ease-[cubic-bezier(0.23,1,0.32,1)] group-data-idle/player:pointer-events-none group-data-idle/player:opacity-0\">\n          <button\n            aria-label=\"Rewind 10 seconds\"\n            className={cn(controlSurface, control, 'size-9')}\n            onClick={() => seekBy(-10)}\n            type=\"button\"\n          >\n            <RewindIcon className=\"size-5\" />\n          </button>\n          <AnimatePresence>\n            {seekFlash && (\n              <motion.span\n                animate={{ opacity: 1, y: -52 }}\n                className=\"pointer-events-none absolute left-1/2 -translate-x-1/2 rounded-full bg-black/55 px-2.5 py-1 text-xs font-medium tabular-nums backdrop-blur-sm\"\n                exit={{ opacity: 0, y: -64 }}\n                initial={{ opacity: 0, y: -40 }}\n                key={seekFlash.id}\n                transition={{ duration: 0.25, ease: [0.23, 1, 0.32, 1] }}\n              >\n                {seekFlash.label}\n              </motion.span>\n            )}\n          </AnimatePresence>\n          <button\n            aria-label={playing ? 'Pause video' : 'Play video'}\n            className={cn(controlSurface, control, 'relative size-12')}\n            onClick={() => onPlayingChange?.(!playing)}\n            type=\"button\"\n          >\n            <span className=\"grid *:col-start-1 *:row-start-1 *:transition-[opacity,scale] *:duration-150 *:ease-[cubic-bezier(0.23,1,0.32,1)] motion-reduce:*:transition-opacity\">\n              <PlayIcon\n                className={cn('ml-0.5 size-6 fill-current', playing && 'scale-75 opacity-0')}\n              />\n              <PauseIcon className={cn('size-6 fill-current', !playing && 'scale-75 opacity-0')} />\n            </span>\n            <motion.span\n              animate={{ opacity: 0, scale: 1.7 }}\n              className=\"pointer-events-none absolute inset-0 rounded-md border-2 border-white/70\"\n              initial={{ opacity: 0.8, scale: 1 }}\n              key={String(playing)}\n              transition={{ duration: 0.5, ease: 'easeOut' }}\n            />\n          </button>\n          <button\n            aria-label=\"Forward 10 seconds\"\n            className={cn(controlSurface, control, 'size-9')}\n            onClick={() => seekBy(10)}\n            type=\"button\"\n          >\n            <ForwardIcon className=\"size-5\" />\n          </button>\n        </div>\n\n        <div className=\"absolute inset-x-5 bottom-5 transition-[opacity,translate] duration-300 ease-[cubic-bezier(0.23,1,0.32,1)] group-data-idle/player:pointer-events-none group-data-idle/player:translate-y-2 group-data-idle/player:opacity-0 sm:inset-x-7 sm:bottom-6\">\n          {subtitle && (\n            <p className=\"mb-1 truncate text-xs leading-5 font-medium text-white/80 sm:text-sm\">\n              {subtitle}\n            </p>\n          )}\n          <h3 className=\"truncate card-heading\">{title}</h3>\n          <div className=\"relative mt-4\">\n            <AnimatePresence>\n              {hover && (\n                <motion.span\n                  animate={{ opacity: 1, y: 0 }}\n                  className=\"pointer-events-none absolute bottom-4 -translate-x-1/2 rounded-md bg-black/70 px-1.5 py-0.5 text-[11px] font-medium tabular-nums backdrop-blur-sm\"\n                  exit={{ opacity: 0, y: 4 }}\n                  initial={{ opacity: 0, y: 4 }}\n                  style={{ left: hover.left }}\n                  transition={{ duration: 0.15 }}\n                >\n                  {chapterAt(hover.time) && (\n                    <span className=\"block max-w-40 truncate text-white/80\">\n                      {chapterAt(hover.time)!.title}\n                    </span>\n                  )}\n                  {formatTime(hover.time)}\n                </motion.span>\n              )}\n            </AnimatePresence>\n            <input\n              onPointerLeave={() => setHover(null)}\n              onPointerMove={(event) => {\n                const box = event.currentTarget.getBoundingClientRect()\n                const ratio = Math.max(0, Math.min(1, (event.clientX - box.left) / box.width))\n                setHover({ left: ratio * box.width, time: ratio * safeDuration })\n              }}\n              aria-label=\"Video progress\"\n              aria-valuetext={`${formatTime(time)} of ${formatTime(safeDuration)}`}\n              className={cn(slider, 'h-1 w-full transition-[height] duration-150 hover:h-1.5')}\n              max={safeDuration}\n              min={0}\n              onChange={(event) => onSeek?.(Number(event.target.value))}\n              style={{\n                background: `linear-gradient(to right, white ${progress}%, #ffffff40 ${progress}%)`,\n              }}\n              type=\"range\"\n              value={time}\n            />\n            {safeDuration > 0 &&\n              sortedChapters\n                .filter((chapter) => chapter.start > 0 && chapter.start < safeDuration)\n                .map((chapter) => (\n                  <span\n                    aria-hidden=\"true\"\n                    className=\"pointer-events-none absolute top-1/2 h-2 w-0.5 -translate-x-1/2 -translate-y-1/2 bg-black/60\"\n                    key={chapter.start}\n                    style={{ left: `${(chapter.start / safeDuration) * 100}%` }}\n                  />\n                ))}\n          </div>\n          <div className=\"mt-2 flex justify-between text-[10px] leading-5 font-medium text-white/70 tabular-nums sm:text-xs\">\n            <span className=\"flex min-w-0 items-center gap-1.5\">\n              {formatTime(time)}\n              {currentChapter && (\n                <AnimatePresence initial={false} mode=\"popLayout\">\n                  <motion.span\n                    animate={{ opacity: 1, y: 0 }}\n                    className=\"truncate text-white/70\"\n                    exit={{ opacity: 0, y: -4 }}\n                    initial={{ opacity: 0, y: 4 }}\n                    key={currentChapter.title}\n                    transition={{ duration: 0.2, ease: [0.23, 1, 0.32, 1] }}\n                  >\n                    · {currentChapter.title}\n                  </motion.span>\n                </AnimatePresence>\n              )}\n            </span>\n            <span>{formatTime(safeDuration)}</span>\n          </div>\n          {fullscreenError && (\n            <output className=\"mt-2 block text-xs leading-5\">{fullscreenError}</output>\n          )}\n        </div>\n      </section>\n    </MotionConfig>\n  )\n}\n\nexport { VideoPlayer }\nexport type { VideoChapter, VideoPlayerProps }\nexport default VideoPlayer\n",
      "type": "registry:component",
      "target": "@components/ai/video-player.tsx"
    }
  ],
  "css": {
    ".video-player-kenburns": {
      "animation": "video-player-kenburns 24s ease-in-out infinite alternate"
    },
    "@keyframes video-player-kenburns": {
      "from": {
        "transform": "scale(1) translate(0, 0)"
      },
      "to": {
        "transform": "scale(1.12) translate(-2%, -1%)"
      }
    },
    "@media (prefers-reduced-motion: reduce)": {
      ".video-player-kenburns": {
        "animation": "none"
      }
    }
  },
  "type": "registry:component"
}