"use client";
'use strict';

var React = require('react');
var framerMotion = require('framer-motion');
var clsx = require('clsx');
var tailwindMerge = require('tailwind-merge');
var jsxRuntime = require('react/jsx-runtime');

function _interopNamespace(e) {
  if (e && e.__esModule) return e;
  var n = Object.create(null);
  if (e) {
    Object.keys(e).forEach(function (k) {
      if (k !== 'default') {
        var d = Object.getOwnPropertyDescriptor(e, k);
        Object.defineProperty(n, k, d.get ? d : {
          enumerable: true,
          get: function () { return e[k]; }
        });
      }
    });
  }
  n.default = e;
  return Object.freeze(n);
}

var React__namespace = /*#__PURE__*/_interopNamespace(React);

var __defProp = Object.defineProperty;
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
function cn(...inputs) {
  return tailwindMerge.twMerge(clsx.clsx(inputs));
}
__name(cn, "cn");
var DockContext = React__namespace.createContext({
  magnification: 60,
  distance: 140
});
var Dock = React__namespace.forwardRef(
  ({
    className,
    children,
    position = "bottom",
    magnification = 60,
    distance = 140
  }, ref) => {
    const positionClasses = {
      bottom: "bottom-0 left-1/2 -translate-x-1/2 flex-row",
      left: "left-0 top-1/2 -translate-y-1/2 flex-col",
      right: "right-0 top-1/2 -translate-y-1/2 flex-col"
    };
    return /* @__PURE__ */ jsxRuntime.jsx(DockContext.Provider, { value: { magnification, distance }, children: /* @__PURE__ */ jsxRuntime.jsx(
      "div",
      {
        ref,
        className: cn(
          "fixed z-50 flex items-end gap-1 rounded-2xl border border-white/10 bg-black/10 p-2 backdrop-blur-xl",
          "shadow-2xl shadow-black/20",
          "before:absolute before:inset-0 before:rounded-2xl before:bg-gradient-to-b before:from-white/10 before:to-transparent before:opacity-50",
          positionClasses[position],
          className
        ),
        children
      }
    ) });
  }
);
Dock.displayName = "Dock";
var DockItem = React__namespace.forwardRef(
  ({
    className,
    children,
    onClick,
    tooltip,
    magnification: itemMagnification,
    distance: itemDistance
  }, ref) => {
    const buttonRef = React__namespace.useRef(null);
    const { magnification: contextMagnification, distance: contextDistance } = React__namespace.useContext(DockContext);
    const magnification = itemMagnification ?? contextMagnification;
    const distance = itemDistance ?? contextDistance;
    const [isHovered, setIsHovered] = React__namespace.useState(false);
    const mouseX = framerMotion.useMotionValue(Infinity);
    const springConfig = { mass: 0.1, stiffness: 150, damping: 12 };
    const size = framerMotion.useSpring(
      framerMotion.useTransform(
        mouseX,
        [-distance, 0, distance],
        [48, 48 + magnification, 48]
      ),
      springConfig
    );
    const handleMouseMove = /* @__PURE__ */ __name((e) => {
      if (!buttonRef.current) return;
      const rect = buttonRef.current.getBoundingClientRect();
      const centerX = rect.left + rect.width / 2;
      mouseX.set(e.clientX - centerX);
    }, "handleMouseMove");
    const handleMouseLeave = /* @__PURE__ */ __name(() => {
      mouseX.set(Infinity);
      setIsHovered(false);
    }, "handleMouseLeave");
    return /* @__PURE__ */ jsxRuntime.jsxs(
      framerMotion.motion.div,
      {
        className: "relative",
        onMouseMove: handleMouseMove,
        onMouseLeave: handleMouseLeave,
        onMouseEnter: () => setIsHovered(true),
        children: [
          tooltip && isHovered && /* @__PURE__ */ jsxRuntime.jsxs(
            framerMotion.motion.div,
            {
              initial: { opacity: 0, y: 10, scale: 0.9 },
              animate: { opacity: 1, y: 0, scale: 1 },
              exit: { opacity: 0, y: 5, scale: 0.95 },
              transition: { duration: 0.15 },
              className: "absolute bottom-full left-1/2 mb-2 -translate-x-1/2 whitespace-nowrap rounded-lg bg-black/80 px-2 py-1 text-xs text-white backdrop-blur-md",
              children: [
                tooltip,
                /* @__PURE__ */ jsxRuntime.jsx("div", { className: "absolute -bottom-1 left-1/2 h-2 w-2 -translate-x-1/2 rotate-45 bg-black/80" })
              ]
            }
          ),
          /* @__PURE__ */ jsxRuntime.jsxs(
            framerMotion.motion.button,
            {
              ref: buttonRef,
              style: {
                width: size,
                height: size
              },
              whileTap: { scale: 0.9 },
              onClick,
              className: cn(
                "relative flex items-center justify-center rounded-xl bg-white/10 backdrop-blur-md transition-colors",
                "hover:bg-white/20",
                "focus:outline-none focus-visible:ring-2 focus-visible:ring-white/50",
                className
              ),
              children: [
                /* @__PURE__ */ jsxRuntime.jsx(
                  framerMotion.motion.div,
                  {
                    style: {
                      width: size,
                      height: size
                    },
                    className: "flex items-center justify-center",
                    children
                  }
                ),
                /* @__PURE__ */ jsxRuntime.jsx(
                  framerMotion.motion.div,
                  {
                    className: "absolute inset-0 rounded-xl",
                    style: {
                      background: "linear-gradient(135deg, rgba(255,255,255,0.1) 0%, rgba(255,255,255,0) 100%)"
                    }
                  }
                )
              ]
            }
          )
        ]
      }
    );
  }
);
DockItem.displayName = "DockItem";

exports.Dock = Dock;
exports.DockItem = DockItem;
