{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "ds-direction-aware-hover",
  "files": [
    {
      "path": "components/ds/ds-direction-aware-hover.tsx",
      "content": "\"use client\"\n\nimport React, { useRef, useState } from \"react\"\nimport { cn } from \"@/lib/utils\"\n\n// ── Types ──\n\nexport interface DirectionAwareHoverProps extends React.HTMLAttributes<HTMLDivElement> {\n  /** Background image URL */\n  imageSrc: string\n  /** Alternative text for the image */\n  imageAlt?: string\n  /** Extra classes for the image */\n  imageClassName?: string\n  /** Animated overlay content */\n  children: React.ReactNode\n}\n\n// ── Component ──\n\nexport const DirectionAwareHover = React.forwardRef<\n  HTMLDivElement,\n  DirectionAwareHoverProps\n>(\n  (\n    {\n      imageSrc,\n      imageAlt = \"\",\n      imageClassName,\n      children,\n      className,\n      onMouseEnter,\n      onMouseLeave,\n      ...props\n    },\n    ref\n  ) => {\n    const internalRef = useRef<HTMLDivElement>(null)\n    const [direction, setDirection] = useState<\n      \"top\" | \"bottom\" | \"left\" | \"right\" | \"\"\n    >(\"\")\n    const [isHovered, setIsHovered] = useState(false)\n\n    // Calculates which side the mouse entered/exited\n    const getDirection = (\n      ev: React.MouseEvent<HTMLDivElement>,\n      obj: HTMLElement\n    ) => {\n      const { width: w, height: h, left, top } = obj.getBoundingClientRect()\n      // Normalizes the coordinates\n      const x = ev.clientX - left - (w / 2) * (w > h ? h / w : 1)\n      const y = ev.clientY - top - (h / 2) * (h > w ? w / h : 1)\n      // Calculates the angle\n      const d = Math.round(Math.atan2(y, x) / 1.57079633 + 5) % 4\n      return d\n    }\n\n    const handleMouseEnter = (e: React.MouseEvent<HTMLDivElement>) => {\n      if (!internalRef.current) return\n      const dir = getDirection(e, internalRef.current)\n      switch (dir) {\n        case 0:\n          setDirection(\"top\")\n          break\n        case 1:\n          setDirection(\"right\")\n          break\n        case 2:\n          setDirection(\"bottom\")\n          break\n        case 3:\n          setDirection(\"left\")\n          break\n      }\n      setIsHovered(true)\n      onMouseEnter?.(e)\n    }\n\n    const handleMouseLeave = (e: React.MouseEvent<HTMLDivElement>) => {\n      if (!internalRef.current) return\n      setIsHovered(false)\n      // We keep the direction so the exit animation occurs on the same axis,\n      // but move the overlay back outside.\n      onMouseLeave?.(e)\n    }\n\n    // Defines the initial class (outside the container) based on direction\n    const getInitialTranslate = () => {\n      if (isHovered) return \"translate-x-0 translate-y-0\"\n      switch (direction) {\n        case \"top\":\n          return \"-translate-y-full translate-x-0\"\n        case \"bottom\":\n          return \"translate-y-full translate-x-0\"\n        case \"left\":\n          return \"-translate-x-full translate-y-0\"\n        case \"right\":\n          return \"translate-x-full translate-y-0\"\n        default:\n          return \"opacity-0\"\n      }\n    }\n\n    return (\n      <div\n        ref={(node: HTMLDivElement) => {\n          internalRef.current = node\n          if (typeof ref === \"function\") ref(node)\n          else if (ref) ref.current = node\n        }}\n        className={cn(\n          \"group relative overflow-hidden rounded-lg bg-transparent\",\n          className\n        )}\n        onMouseEnter={handleMouseEnter}\n        onMouseLeave={handleMouseLeave}\n        {...props}\n      >\n        <div className=\"relative h-full w-full\">\n          {/* eslint-disable-next-line @next/next/no-img-element */}\n          <img\n            src={imageSrc}\n            alt={imageAlt}\n            loading=\"lazy\"\n            decoding=\"async\"\n            className={cn(\n              \"h-full w-full object-cover transition-transform duration-500\",\n              isHovered ? \"scale-110\" : \"scale-100\",\n              imageClassName\n            )}\n          />\n          <div\n            className={cn(\n              \"absolute inset-0 z-10 flex flex-col bg-background/80 text-foreground backdrop-blur-sm transition-all duration-300 ease-out focus-within:translate-x-0 focus-within:translate-y-0 focus-within:opacity-100\",\n              getInitialTranslate()\n            )}\n          >\n            {children}\n          </div>\n        </div>\n      </div>\n    )\n  }\n)\n\nDirectionAwareHover.displayName = \"DirectionAwareHover\"\n",
      "type": "registry:ui"
    }
  ],
  "type": "registry:ui"
}
