import{useRef as t}from"react";import{usePointerEvent as n,addPointerEvent as o}from"../events/use-pointer-event.js";import{isDragActive as r}from"./drag/utils/lock.js";import{AnimationType as i}from"../render/utils/types.js";import{useUnmountEffect as e}from"../utils/use-unmount-effect.js";import{isNodeOrChild as u}from"./utils/is-node-or-child.js";import{pipe as l}from"../../../../popmotion/dist/es/utils/pipe.js";function a(a,p){var c=a.onTap,s=a.onTapStart,m=a.onTapCancel,f=a.whileTap,d=c||s||m||f,v=t(!1),j=t(null);function w(){var t;null===(t=j.current)||void 0===t||t.call(j),j.current=null}function T(){var t;return w(),v.current=!1,null===(t=p.animationState)||void 0===t||t.setActive(i.Tap,!1),!r()}function g(t,n){T()&&(u(p.getInstance(),t.target)?null==c||c(t,n):null==m||m(t,n))}function S(t,n){T()&&(null==m||m(t,n))}n(p,"pointerdown",d?function(t,n){var r;w(),v.current||(v.current=!0,j.current=l(o(window,"pointerup",g),o(window,"pointercancel",S)),null==s||s(t,n),null===(r=p.animationState)||void 0===r||r.setActive(i.Tap,!0))}:void 0),e(w)}export{a as useTapGesture};
//# sourceMappingURL=use-tap-gesture.js.map
