{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "backgrounds-stars",
  "type": "registry:ui",
  "title": "Stars Background",
  "description": "An interactive background featuring animated dots of varying sizes and speeds, simulating a dynamic and immersive starry space effect.",
  "dependencies": [
    "@animate-ui/react",
    "cn",
    "motion"
  ],
  "files": [
    {
      "path": "registry/backgrounds/stars/index.tsx",
      "type": "registry:ui",
      "target": "@components/animate-ui/backgrounds/stars.tsx",
      "content": "'use client';\n\nimport * as React from 'react';\nimport {\n  type HTMLMotionProps,\n  motion,\n  useInView,\n  useMotionValue,\n  useSpring,\n  type SpringOptions,\n  type Transition,\n} from 'motion/react';\n\nimport {\n  ReducedMotionConfig,\n  useShouldReduceMotion,\n} from '@animate-ui/react/utils/motion';\nimport { usePageVisible } from '@animate-ui/react/utils/use-page-visible';\nimport { cn } from 'cn';\n\nconst StarsInViewContext = React.createContext(true);\n\ntype StarLayerProps = HTMLMotionProps<'div'> & {\n  count: number;\n  size: number;\n  transition: Transition;\n  starColor: string;\n};\n\nfunction generateStars(count: number) {\n  const shadows: string[] = [];\n  for (let i = 0; i < count; i++) {\n    const x = Math.floor(Math.random() * 4000) - 2000;\n    const y = Math.floor(Math.random() * 4000) - 2000;\n    shadows.push(`${x}px ${y}px`);\n  }\n  return shadows.join(', ');\n}\n\nfunction StarLayerContent({\n  count = 1000,\n  size = 1,\n  transition = { repeat: Infinity, duration: 50, ease: 'linear' },\n  starColor = '#fff',\n  className,\n  ...props\n}: StarLayerProps) {\n  const firstRef = React.useRef<HTMLDivElement>(null);\n  const secondRef = React.useRef<HTMLDivElement>(null);\n\n  const inView = React.use(StarsInViewContext);\n  const pageVisible = usePageVisible();\n  const reduce = useShouldReduceMotion();\n  const playing = inView && pageVisible && !reduce;\n\n  React.useEffect(() => {\n    const boxShadow = generateStars(count);\n    if (firstRef.current) firstRef.current.style.boxShadow = boxShadow;\n    if (secondRef.current) secondRef.current.style.boxShadow = boxShadow;\n  }, [count]);\n\n  return (\n    <motion.div\n      data-slot=\"star-layer\"\n      initial={{ transform: 'translateY(0px)' }}\n      animate={{\n        transform: playing\n          ? ['translateY(0px)', 'translateY(-2000px)']\n          : 'translateY(0px)',\n      }}\n      transition={playing ? transition : { duration: 0 }}\n      className={cn('absolute top-0 left-0 w-full h-[2000px]', className)}\n      {...props}\n    >\n      <div\n        ref={firstRef}\n        className=\"absolute bg-transparent rounded-full\"\n        style={{ width: `${size}px`, height: `${size}px`, color: starColor }}\n      />\n      <div\n        ref={secondRef}\n        className=\"absolute bg-transparent rounded-full top-[2000px]\"\n        style={{ width: `${size}px`, height: `${size}px`, color: starColor }}\n      />\n    </motion.div>\n  );\n}\n\nfunction StarLayer(props: StarLayerProps) {\n  return (\n    <ReducedMotionConfig>\n      <StarLayerContent {...props} />\n    </ReducedMotionConfig>\n  );\n}\n\ntype StarsBackgroundProps = React.ComponentProps<'div'> & {\n  factor?: number;\n  speed?: number;\n  transition?: SpringOptions;\n  starColor?: string;\n  pointerEvents?: boolean;\n};\n\nfunction StarsBackgroundContent({\n  ref,\n  children,\n  className,\n  factor = 0.05,\n  speed = 50,\n  transition = { stiffness: 50, damping: 20 },\n  starColor = '#fff',\n  pointerEvents = true,\n  onMouseMove,\n  ...props\n}: StarsBackgroundProps) {\n  const containerRef = React.useRef<HTMLDivElement>(null);\n  React.useImperativeHandle(ref, () => containerRef.current as HTMLDivElement);\n  const inView = useInView(containerRef);\n  const reduce = useShouldReduceMotion();\n\n  const offsetX = useMotionValue(1);\n  const offsetY = useMotionValue(1);\n\n  const springX = useSpring(offsetX, transition);\n  const springY = useSpring(offsetY, transition);\n\n  const handleMouseMove = (e: React.MouseEvent<HTMLDivElement>) => {\n    onMouseMove?.(e);\n    if (reduce) return;\n    const rect = e.currentTarget.getBoundingClientRect();\n    const centerX = rect.left + rect.width / 2;\n    const centerY = rect.top + rect.height / 2;\n    offsetX.set(-(e.clientX - centerX) * factor);\n    offsetY.set(-(e.clientY - centerY) * factor);\n  };\n\n  return (\n    <div\n      ref={containerRef}\n      data-slot=\"stars-background\"\n      className={cn(\n        'relative size-full overflow-hidden bg-[radial-gradient(ellipse_at_bottom,_#262626_0%,_#000_100%)]',\n        className,\n      )}\n      {...props}\n      onMouseMove={handleMouseMove}\n    >\n      <StarsInViewContext value={inView}>\n        <motion.div\n          aria-hidden=\"true\"\n          style={{ x: springX, y: springY }}\n          className={cn({ 'pointer-events-none': !pointerEvents })}\n        >\n          <StarLayer\n            count={1000}\n            size={1}\n            transition={{ repeat: Infinity, duration: speed, ease: 'linear' }}\n            starColor={starColor}\n          />\n          <StarLayer\n            count={400}\n            size={2}\n            transition={{\n              repeat: Infinity,\n              duration: speed * 2,\n              ease: 'linear',\n            }}\n            starColor={starColor}\n          />\n          <StarLayer\n            count={200}\n            size={3}\n            transition={{\n              repeat: Infinity,\n              duration: speed * 3,\n              ease: 'linear',\n            }}\n            starColor={starColor}\n          />\n        </motion.div>\n      </StarsInViewContext>\n      {children}\n    </div>\n  );\n}\n\nfunction StarsBackground(props: StarsBackgroundProps) {\n  return (\n    <ReducedMotionConfig>\n      <StarsBackgroundContent {...props} />\n    </ReducedMotionConfig>\n  );\n}\n\nexport {\n  StarLayer,\n  StarsBackground,\n  type StarLayerProps,\n  type StarsBackgroundProps,\n};\n"
    }
  ]
}