{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "database",
  "title": "database",
  "description": "Animated database icon",
  "dependencies": [
    "motion"
  ],
  "files": [
    {
      "path": "icons/database.tsx",
      "content": "'use client';\n\nimport type { Variants } from 'motion/react';\nimport { motion, useAnimation } from 'motion/react';\nimport type { HTMLAttributes } from 'react';\nimport { forwardRef } from 'react';\nimport { useIconAnimation } from '@/lib/use-icon-animation';\nimport { cn } from '@/lib/utils';\n\nexport interface DatabaseIconHandle {\n  startAnimation: () => void;\n  stopAnimation: () => void;\n}\n\ninterface DatabaseIconProps extends HTMLAttributes<HTMLDivElement> {\n  size?: number;\n}\n\nconst DATABASE_MIDDLE_PLATTER =\n  'M20 12C20 13.6569 16.4183 15 12 15C7.58172 15 4 13.6569 4 12';\nconst DATABASE_BOTTOM_PLATTER =\n  'M20 19C20 20.6569 16.4183 22 12 22C7.58172 22 4 20.6569 4 19';\n\n// A short read head scans each platter from top to bottom.\nconst scanPulseVariants: Variants = {\n  normal: { visibility: 'hidden', strokeDashoffset: 0.95 },\n  animate: (i: number) => ({\n    visibility: ['hidden', 'visible', 'visible', 'hidden'],\n    strokeDashoffset: [0.95, 0.95, -0.12, -0.12],\n    transition: {\n      duration: 0.38,\n      delay: i * 0.14,\n      times: [0, 0.08, 0.82, 1],\n      ease: 'linear',\n    },\n  }),\n};\n\n// Record fragments fill after the scan reaches their layer, then clear in reverse.\nconst recordLineVariants: Variants = {\n  normal: { pathLength: 0 },\n  animate: (i: number) => ({\n    pathLength: [0, 0, 1, 1, 0],\n    transition: {\n      duration: 0.72,\n      delay: i * 0.14,\n      times: [0, 0.2, 0.4, 0.76, 1],\n      ease: [0.77, 0, 0.175, 1],\n    },\n  }),\n};\n\nconst generatedGeometryVariants: Variants = {\n  normal: { visibility: 'hidden', transition: { duration: 0 } },\n  animate: { visibility: 'visible', transition: { duration: 0 } },\n};\n\nconst DatabaseIcon = forwardRef<DatabaseIconHandle, DatabaseIconProps>(\n  ({ onMouseEnter, onMouseLeave, className, size = 28, ...props }, ref) => {\n    const controls = useAnimation();\n    const { handleMouseEnter, handleMouseLeave } = useIconAnimation({\n      controls,\n      loops: false,\n      onMouseEnter,\n      onMouseLeave,\n      ref,\n    });\n\n    return (\n      <div\n        className={cn(className)}\n        onMouseEnter={handleMouseEnter}\n        onMouseLeave={handleMouseLeave}\n        {...props}\n      >\n        <svg\n          xmlns=\"http://www.w3.org/2000/svg\"\n          width={size}\n          height={size}\n          viewBox=\"0 0 24 24\"\n          fill=\"none\"\n          overflow=\"visible\"\n        >\n          <ellipse\n            cx=\"12\"\n            cy=\"5\"\n            rx=\"8\"\n            ry=\"3\"\n            stroke=\"currentColor\"\n            strokeWidth=\"1.5\"\n          />\n          <path\n            d=\"M7 10.842C7.60158 11.0229 8.27434 11.1718 9 11.282\"\n            stroke=\"currentColor\"\n            strokeLinecap=\"round\"\n            strokeWidth=\"1.5\"\n          />\n          <path\n            d={DATABASE_MIDDLE_PLATTER}\n            stroke=\"currentColor\"\n            strokeWidth=\"1.5\"\n          />\n          <path\n            d=\"M7 17.842C7.60158 18.0229 8.27434 18.1718 9 18.282\"\n            stroke=\"currentColor\"\n            strokeLinecap=\"round\"\n            strokeWidth=\"1.5\"\n          />\n          <path\n            d=\"M20 5V19C20 20.6569 16.4183 22 12 22C7.58172 22 4 20.6569 4 19V5\"\n            stroke=\"currentColor\"\n            strokeWidth=\"1.5\"\n          />\n          <motion.g\n            variants={generatedGeometryVariants}\n            animate={controls}\n            initial=\"normal\"\n          >\n            <motion.ellipse\n              cx=\"12\"\n              cy=\"5\"\n              rx=\"8\"\n              ry=\"3\"\n              pathLength=\"1\"\n              stroke=\"currentColor\"\n              strokeDasharray=\"0.18 0.82\"\n              strokeLinecap=\"round\"\n              strokeWidth=\"2.4\"\n              variants={scanPulseVariants}\n              custom={0}\n              animate={controls}\n              initial=\"normal\"\n            />\n            <motion.path\n              d={DATABASE_MIDDLE_PLATTER}\n              pathLength=\"1\"\n              stroke=\"currentColor\"\n              strokeDasharray=\"0.18 0.82\"\n              strokeLinecap=\"round\"\n              strokeWidth=\"2.4\"\n              variants={scanPulseVariants}\n              custom={1}\n              animate={controls}\n              initial=\"normal\"\n            />\n            <motion.path\n              d={DATABASE_BOTTOM_PLATTER}\n              pathLength=\"1\"\n              stroke=\"currentColor\"\n              strokeDasharray=\"0.18 0.82\"\n              strokeLinecap=\"round\"\n              strokeWidth=\"2.4\"\n              variants={scanPulseVariants}\n              custom={2}\n              animate={controls}\n              initial=\"normal\"\n            />\n            <motion.path\n              d=\"M10.5 11.4H12.25M13.75 11.4H16.5\"\n              stroke=\"currentColor\"\n              strokeLinecap=\"round\"\n              strokeWidth=\"1.5\"\n              variants={recordLineVariants}\n              custom={0}\n              animate={controls}\n              initial=\"normal\"\n            />\n            <motion.path\n              d=\"M10.5 18.4H14M15.5 18.4H17\"\n              stroke=\"currentColor\"\n              strokeLinecap=\"round\"\n              strokeWidth=\"1.5\"\n              variants={recordLineVariants}\n              custom={1}\n              animate={controls}\n              initial=\"normal\"\n            />\n          </motion.g>\n        </svg>\n      </div>\n    );\n  }\n);\n\nDatabaseIcon.displayName = 'DatabaseIcon';\n\nexport { DatabaseIcon };\n",
      "type": "registry:ui"
    },
    {
      "path": "lib/use-icon-animation.ts",
      "content": "'use client';\n\nimport type { LegacyAnimationControls } from 'motion/react';\nimport { useReducedMotion } from 'motion/react';\nimport type {\n  ForwardedRef,\n  MouseEventHandler,\n} from 'react';\nimport { useCallback, useImperativeHandle, useRef } from 'react';\n\nexport interface AnimatedIconHandle {\n  startAnimation: () => void;\n  stopAnimation: () => void;\n}\n\ninterface UseIconAnimationOptions {\n  controls: LegacyAnimationControls;\n  loops?: boolean;\n  onMouseEnter?: MouseEventHandler<HTMLDivElement>;\n  onMouseLeave?: MouseEventHandler<HTMLDivElement>;\n  ref: ForwardedRef<AnimatedIconHandle>;\n}\n\nexport function useIconAnimation({\n  controls,\n  loops = false,\n  onMouseEnter,\n  onMouseLeave,\n  ref,\n}: UseIconAnimationOptions) {\n  const shouldReduceMotion = useReducedMotion();\n  const isControlledRef = useRef(false);\n  const isPlayingRef = useRef(false);\n  const runRef = useRef(0);\n\n  const startAnimation = useCallback(() => {\n    if (shouldReduceMotion || isPlayingRef.current) return;\n\n    isPlayingRef.current = true;\n    const run = ++runRef.current;\n    controls.set('normal');\n    void controls.start('animate').then(() => {\n      if (runRef.current === run) isPlayingRef.current = false;\n    });\n  }, [controls, shouldReduceMotion]);\n\n  const stopAnimation = useCallback(() => {\n    if (!loops) return;\n\n    runRef.current++;\n    isPlayingRef.current = false;\n    void controls.start('normal');\n  }, [controls, loops]);\n\n  useImperativeHandle(\n    ref,\n    () => {\n      isControlledRef.current = true;\n      return { startAnimation, stopAnimation };\n    },\n    [startAnimation, stopAnimation]\n  );\n\n  const handleMouseEnter = useCallback<MouseEventHandler<HTMLDivElement>>(\n    (event) => {\n      onMouseEnter?.(event);\n      if (!isControlledRef.current) startAnimation();\n    },\n    [onMouseEnter, startAnimation]\n  );\n\n  const handleMouseLeave = useCallback<MouseEventHandler<HTMLDivElement>>(\n    (event) => {\n      onMouseLeave?.(event);\n      if (!isControlledRef.current) stopAnimation();\n    },\n    [onMouseLeave, stopAnimation]\n  );\n\n  return { handleMouseEnter, handleMouseLeave };\n}\n",
      "type": "registry:lib"
    }
  ],
  "type": "registry:ui"
}