import { jsx as d } from "react/jsx-runtime";
import * as i from "react";
import { useAnimationControls as f } from "../../shop-minis-react/node_modules/.pnpm/motion@12.17.3_react-dom@19.1.0_react@19.1.0__react@19.1.0/node_modules/motion/dist/es/framer-motion/dist/es/animation/hooks/use-animation.js";
import { motion as y } from "../../shop-minis-react/node_modules/.pnpm/motion@12.17.3_react-dom@19.1.0_react@19.1.0__react@19.1.0/node_modules/motion/dist/es/framer-motion/dist/es/render/components/motion/proxy.js";
const L = ({
  children: u,
  onClick: a,
  stopPropagation: t = !1,
  ...l
}) => {
  const r = i.useRef(null), o = f(), { ref: w, ...p } = l, m = i.useCallback(
    (e) => {
      t && e.stopPropagation(), a?.(e);
    },
    [t, a]
  );
  return i.useEffect(() => {
    if (!t || !r.current) return;
    const e = r.current, s = (n) => {
      n.stopImmediatePropagation(), n.stopPropagation(), o.start({
        opacity: 0.7,
        transition: {
          opacity: { type: "tween", duration: 0.08, ease: "linear" }
        }
      });
    }, c = (n) => {
      n.stopImmediatePropagation(), n.stopPropagation(), o.start({
        opacity: 1,
        transition: {
          opacity: { type: "tween", duration: 0.08, ease: "linear" }
        }
      });
    };
    return e.addEventListener("pointerdown", s, !0), e.addEventListener("pointerup", c, !0), () => {
      e.removeEventListener("pointerdown", s, !0), e.removeEventListener("pointerup", c, !0);
    };
  }, [t, o]), /* @__PURE__ */ d(
    y.div,
    {
      ref: r,
      "data-touchable": "true",
      className: "flex w-full",
      animate: t ? o : void 0,
      whileTap: t ? void 0 : { opacity: 0.7 },
      transition: {
        opacity: { type: "tween", duration: 0.08, ease: "linear" }
      },
      onClick: m,
      style: {
        touchAction: t ? "manipulation" : void 0
      },
      ...p,
      children: u
    }
  );
};
export {
  L as Touchable
};
//# sourceMappingURL=touchable.js.map
