{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "keyboard",
  "type": "registry:ui",
  "registryDependencies": [],
  "dependencies": ["motion"],
  "devDependencies": [],
  "files": [
    {
      "path": "keyboard.tsx",
      "content": "\"use client\";\n\nimport { AnimatePresence, motion, useAnimation } from \"motion/react\";\nimport type { HTMLAttributes } from \"react\";\nimport {\n  forwardRef,\n  useCallback,\n  useEffect,\n  useImperativeHandle,\n  useRef,\n  useState,\n} from \"react\";\n\nimport { cn } from \"@/lib/utils\";\n\nexport interface KeyboardIconHandle {\n  startAnimation: () => void;\n  stopAnimation: () => void;\n}\n\ninterface KeyboardIconProps extends HTMLAttributes<HTMLDivElement> {\n  size?: number;\n}\n\nconst KEYBOARD_PATHS = [\n  { id: \"key1\", d: \"M10 8h.01\" },\n  { id: \"key2\", d: \"M12 12h.01\" },\n  { id: \"key3\", d: \"M14 8h.01\" },\n  { id: \"key4\", d: \"M16 12h.01\" },\n  { id: \"key5\", d: \"M18 8h.01\" },\n  { id: \"key6\", d: \"M6 8h.01\" },\n  { id: \"key7\", d: \"M7 16h10\" },\n  { id: \"key8\", d: \"M8 12h.01\" },\n];\n\nconst KeyboardIcon = forwardRef<KeyboardIconHandle, KeyboardIconProps>(\n  ({ onMouseEnter, onMouseLeave, className, size = 28, ...props }, ref) => {\n    const [isHovered, setIsHovered] = useState(false);\n    const controls = useAnimation();\n\n    const isControlledRef = useRef(false);\n\n    useImperativeHandle(ref, () => {\n      isControlledRef.current = true;\n\n      return {\n        startAnimation: () => setIsHovered(true),\n        stopAnimation: () => setIsHovered(false),\n      };\n    });\n\n    const handleMouseEnter = useCallback(\n      (e: React.MouseEvent<HTMLDivElement>) => {\n        if (isControlledRef.current) {\n          onMouseEnter?.(e);\n        } else {\n          setIsHovered(true);\n        }\n      },\n      [onMouseEnter]\n    );\n\n    const handleMouseLeave = useCallback(\n      (e: React.MouseEvent<HTMLDivElement>) => {\n        if (isControlledRef.current) {\n          onMouseLeave?.(e);\n        } else {\n          setIsHovered(false);\n        }\n      },\n      [onMouseLeave]\n    );\n\n    useEffect(() => {\n      const animateKeys = async () => {\n        if (isHovered) {\n          await controls.start((i) => ({\n            opacity: [1, 0.2, 1],\n            transition: {\n              duration: 1.5,\n              times: [0, 0.5, 1],\n              delay: i * 0.2 * Math.random(),\n              repeat: 1,\n              repeatType: \"reverse\",\n            },\n          }));\n        } else {\n          controls.stop();\n          controls.set({ opacity: 1 });\n        }\n      };\n\n      animateKeys();\n    }, [isHovered, controls]);\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          <rect height=\"16\" rx=\"2\" width=\"20\" x=\"2\" y=\"4\" />\n          <AnimatePresence>\n            {KEYBOARD_PATHS.map((path, index) => (\n              <motion.path\n                animate={controls}\n                custom={index}\n                d={path.d}\n                initial={{ opacity: 1 }}\n                key={path.id}\n              />\n            ))}\n          </AnimatePresence>\n        </svg>\n      </div>\n    );\n  }\n);\n\nKeyboardIcon.displayName = \"KeyboardIcon\";\n\nexport { KeyboardIcon };\n",
      "type": "registry:ui"
    }
  ]
}
