import { useRef as a } from "react";
import m from "../../../rc-util/es/hooks/useLayoutEffect.mjs";
var T = 14 / 15;
function L(i, h, l) {
  var n = a(!1), v = a(0), r = a(null), u = a(null), c, f = function(t) {
    if (n.current) {
      var E = Math.ceil(t.touches[0].pageY), o = v.current - E;
      v.current = E, l(o) && t.preventDefault(), clearInterval(u.current), u.current = setInterval(function() {
        o *= T, (!l(o, !0) || Math.abs(o) <= 0.1) && clearInterval(u.current);
      }, 16);
    }
  }, s = function() {
    n.current = !1, c();
  }, d = function(t) {
    c(), t.touches.length === 1 && !n.current && (n.current = !0, v.current = Math.ceil(t.touches[0].pageY), r.current = t.target, r.current.addEventListener("touchmove", f), r.current.addEventListener("touchend", s));
  };
  c = function() {
    r.current && (r.current.removeEventListener("touchmove", f), r.current.removeEventListener("touchend", s));
  }, m(function() {
    return i && h.current.addEventListener("touchstart", d), function() {
      var e;
      (e = h.current) === null || e === void 0 || e.removeEventListener("touchstart", d), c(), clearInterval(u.current);
    };
  }, [i]);
}
export {
  L as default
};
