import { onMounted as c, onUnmounted as v, unref as r } from "vue";
function y(o, i) {
  function u(e, t) {
    const n = r(o);
    if (!n)
      return;
    const d = `translate(${t.x - e.x}px, ${t.y - e.y}px)`;
    n.style.setProperty("transform", d), i(t);
  }
  function s(e) {
    const t = (n) => u(e, n);
    document.addEventListener("mousemove", t), document.addEventListener(
      "mouseup",
      () => {
        const n = r(o);
        document.removeEventListener("mousemove", t), n && (n.style.setProperty("transition", "all .3s ease-in-out"), n.style.removeProperty("transform"), n.addEventListener("transitionend", () => {
          n.style.removeProperty("transition");
        }));
      },
      { once: !0 }
    );
  }
  function m() {
    var e;
    (e = r(o)) == null || e.addEventListener("mousedown", s);
  }
  function a() {
    var e;
    (e = r(o)) == null || e.removeEventListener("mousedown", s);
  }
  c(m), v(a);
}
export {
  y as useDraggable
};
//# sourceMappingURL=useDraggable.js.map
