"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),t=require("../utils/owner.js"),r=require("./use-disposables.js"),n=require("./use-event.js");exports.useActivePress=function(){let{disabled:i=!1}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},s=e.useRef(null),[o,u]=e.useState(!1),l=r.useDisposables(),c=n.useEvent((()=>{s.current=null,u(!1),l.dispose()})),p=n.useEvent((e=>{if(l.dispose(),null===s.current){s.current=e.currentTarget,u(!0);{let r=t.getOwnerDocument(e.currentTarget);l.addEventListener(r,"pointerup",c,!1),l.addEventListener(r,"pointermove",(e=>{if(s.current){let t=function(e){let t=e.width/2,r=e.height/2;return{top:e.clientY-r,right:e.clientX+t,bottom:e.clientY+r,left:e.clientX-t}}(e);u(function(e,t){return!(!e||!t||e.right<t.left||e.left>t.right||e.bottom<t.top||e.top>t.bottom)}(t,s.current.getBoundingClientRect()))}}),!1),l.addEventListener(r,"pointercancel",c,!1)}}}));return{pressed:o,pressProps:i?{}:{onPointerDown:p,onPointerUp:c,onClick:c}}};
//# sourceMappingURL=use-active-press.js.map
