import { C as r } from "./base-PQGakkrl.js";
import { C as i } from "./index-BnerInzC.js";
class a {
  optionsDrag;
  _isDragging;
  _bindRunDragStart;
  _bindRunDragIng;
  _bindRunDragEnd;
  constructor(n, t) {
    this.optionsDrag = t, this._isDragging = !1, this._init(n);
  }
  _init(n) {
    this._bindRunDragStart = this._runDragStart.bind(this), this._bindRunDragIng = this._runDraggIng.bind(this), this._bindRunDragEnd = this._runDragEnd.bind(this), i.onListener(n, "mousedown", this._bindRunDragStart), i.onListener(n, "touchstart", this._bindRunDragStart);
  }
  _runDragStart(n) {
    if (this._isDragging) return;
    const t = i.getClientXY(n);
    let s = !0;
    this.optionsDrag.start && (s = this.optionsDrag.start(n, t)), s = r.isBoolean(s) ? s : !0, s ? (n.preventDefault(), n.stopPropagation(), document.onselectstart = () => !1, document.ondragstart = () => !1, this._isDragging = !0, i.onListener(window, "mousemove", this._bindRunDragIng), i.onListener(window, "touchmove", this._bindRunDragIng), i.onListener(window, "mouseup", this._bindRunDragEnd), i.onListener(window, "touchend", this._bindRunDragEnd), i.onListener(window, "contextmenu", this._bindRunDragEnd)) : this._isDragging = !1;
  }
  _runDraggIng(n) {
    if (!this._isDragging) return;
    const t = i.getClientXY(n);
    this.optionsDrag.ing && this.optionsDrag.ing(n, t);
  }
  _runDragEnd(n) {
    if (!this._isDragging) return;
    this._isDragging = !1;
    const t = i.getClientXY(n);
    this.optionsDrag.end && this.optionsDrag.end(n, t), this._offListener();
  }
  _offListener() {
    i.offListener(window, "mousemove", this._bindRunDragIng), i.offListener(window, "touchmove", this._bindRunDragIng), i.offListener(window, "mouseup", this._bindRunDragEnd), i.offListener(window, "touchend", this._bindRunDragEnd), i.offListener(window, "contextmenu", this._bindRunDragEnd);
  }
  end() {
    this._isDragging = !1, this._offListener();
  }
}
export {
  a as D
};
//# sourceMappingURL=drag-CzfhSB0g.js.map
