import e from"@babel/runtime/helpers/slicedToArray";import{jsx as r}from"react/jsx-runtime";import{useRef as n,useState as t,useCallback as o,useEffect as u}from"react";import i from"classnames";import a from"./OpacityDragTracker.scss.js";var m=function(m){var c=m.onDrag,s=m.onDragEnd,f=n(null),l=t(!1),v=e(l,2),d=v[0],p=v[1],g=o((function(e){e.preventDefault(),p(!1),null==s||s()}),[s]),D=o((function(e){e.preventDefault(),p(!0)}),[]),E=o((function(e){var r=e.currentTarget.getBoundingClientRect(),n=100*(e.clientX-r.left-5)/(r.width-10),t=Math.min(100,Math.max(0,n));null==c||c(t)}),[c]);return u((function(){if(d&&f.current){var e=f.current;return document.addEventListener("mouseup",g),e.addEventListener("mousemove",E),function(){document.removeEventListener("mouseup",g),e.removeEventListener("mousemove",E)}}}),[d,g,E]),r("div",{onMouseDown:D,ref:f,className:i(a.root,d&&a.dragging)})};export{m as OpacityDragTracker};
//# sourceMappingURL=OpacityDragtracker.js.map
