{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "sun-moon",
  "type": "registry:ui",
  "registryDependencies": [],
  "dependencies": ["motion"],
  "devDependencies": [],
  "files": [
    {
      "path": "sun-moon.tsx",
      "content": "\"use client\";\n\nimport type { Variants } from \"motion/react\";\nimport { motion, useAnimation } from \"motion/react\";\nimport type { HTMLAttributes } from \"react\";\nimport { forwardRef, useCallback, useImperativeHandle, useRef } from \"react\";\n\nimport { cn } from \"@/lib/utils\";\n\nexport interface SunMoonIconHandle {\n  startAnimation: () => void;\n  stopAnimation: () => void;\n}\n\ninterface SunMoonIconProps extends HTMLAttributes<HTMLDivElement> {\n  size?: number;\n}\n\nconst SUN_VARIANTS: Variants = {\n  normal: {\n    rotate: 0,\n  },\n  animate: {\n    rotate: [0, -5, 5, -2, 2, 0],\n    transition: {\n      duration: 1.5,\n      ease: \"easeInOut\",\n    },\n  },\n};\n\nconst MOON_VARIANTS: Variants = {\n  normal: { opacity: 1 },\n  animate: (i: number) => ({\n    opacity: [0, 1],\n    transition: { delay: i * 0.1, duration: 0.3 },\n  }),\n};\n\nconst SunMoonIcon = forwardRef<SunMoonIconHandle, SunMoonIconProps>(\n  ({ onMouseEnter, onMouseLeave, className, size = 28, ...props }, ref) => {\n    const sunControls = useAnimation();\n    const moonControls = useAnimation();\n    const isControlledRef = useRef(false);\n\n    useImperativeHandle(ref, () => {\n      isControlledRef.current = true;\n\n      return {\n        startAnimation: () => {\n          sunControls.start(\"animate\");\n          moonControls.start(\"animate\");\n        },\n        stopAnimation: () => {\n          sunControls.start(\"normal\");\n          moonControls.start(\"normal\");\n        },\n      };\n    });\n\n    const handleMouseEnter = useCallback(\n      (e: React.MouseEvent<HTMLDivElement>) => {\n        if (isControlledRef.current) {\n          onMouseEnter?.(e);\n        } else {\n          sunControls.start(\"animate\");\n          moonControls.start(\"animate\");\n        }\n      },\n      [sunControls, moonControls, onMouseEnter]\n    );\n\n    const handleMouseLeave = useCallback(\n      (e: React.MouseEvent<HTMLDivElement>) => {\n        if (isControlledRef.current) {\n          onMouseLeave?.(e);\n        } else {\n          sunControls.start(\"normal\");\n          moonControls.start(\"normal\");\n        }\n      },\n      [sunControls, moonControls, onMouseLeave]\n    );\n\n    return (\n      <div\n        className={cn(className)}\n        onMouseEnter={handleMouseEnter}\n        onMouseLeave={handleMouseLeave}\n        {...props}\n      >\n        <svg\n          fill=\"none\"\n          height={size}\n          stroke=\"currentColor\"\n          strokeLinecap=\"round\"\n          strokeLinejoin=\"round\"\n          strokeWidth=\"2\"\n          viewBox=\"0 0 24 24\"\n          width={size}\n          xmlns=\"http://www.w3.org/2000/svg\"\n        >\n          <motion.g\n            animate={sunControls}\n            initial=\"normal\"\n            variants={SUN_VARIANTS}\n          >\n            <path d=\"M12 8a2.83 2.83 0 0 0 4 4 4 4 0 1 1-4-4\" />\n          </motion.g>\n          {[\n            \"M12 2v2\",\n            \"M12 20v2\",\n            \"m4.9 4.9 1.4 1.4\",\n            \"m17.7 17.7 1.4 1.4\",\n            \"M2 12h2\",\n            \"M20 12h2\",\n            \"m6.3 17.7-1.4 1.4\",\n            \"m19.1 4.9-1.4 1.4\",\n          ].map((d, index) => (\n            <motion.path\n              animate={moonControls}\n              custom={index + 1}\n              d={d}\n              initial=\"normal\"\n              key={d}\n              variants={MOON_VARIANTS}\n            />\n          ))}\n        </svg>\n      </div>\n    );\n  }\n);\n\nSunMoonIcon.displayName = \"SunMoonIcon\";\n\nexport { SunMoonIcon };\n",
      "type": "registry:ui"
    }
  ]
}
