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