!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self).EmblaCarouselWheelGestures=t()}(this,(function(){"use strict";function e(){return(e=Object.assign||function(e){for(var t=1;t=e;case"y":return Math.abs(o)>=e;case"z":return Math.abs(r)>=e;default:return!1}}(m,c)&&i.preventDefault(),p.isStarted?p.isMomentum&&m>Math.max(2,2*p.lastAbsDelta)&&(L(!0),A()):A(),0===m&&Object.is&&Object.is(i.deltaX,-0)?M=!0:(u=i,p.axisMovement=t(p.axisMovement,c),p.lastAbsDelta=m,p.scrollPointsToMerge.push({axisDelta:c,timeStamp:l}),w(),b({axisDelta:c,isStart:!p.isStartPublished}),p.isStartPublished=!0,j())},w=function(){var e;2===p.scrollPointsToMerge.length?(p.scrollPoints.unshift({axisDeltaSum:p.scrollPointsToMerge.map((function(e){return e.axisDelta})).reduce(t),timeStamp:(e=p.scrollPointsToMerge.map((function(e){return e.timeStamp})),e.reduce((function(e,t){return e+t}))/e.length)}),S(),p.scrollPointsToMerge.length=0,p.scrollPoints.length=1,p.isMomentum||T()):p.isStartPublished||y()},y=function(){var e;p.axisVelocity=(e=p.scrollPointsToMerge,e[e.length-1]).axisDelta.map((function(e){return e/p.willEndTimeout}))},S=function(){var e=p.scrollPoints,t=e[0],n=e[1];if(n&&t){var i=t.timeStamp-n.timeStamp;if(!(i<=0)){var o=t.axisDeltaSum.map((function(e){return e/i})),r=o.map((function(e,t){return e/(p.axisVelocity[t]||1)}));p.axisVelocity=o,p.accelerationFactors.push(r),D(i)}}},D=function(e){var t=10*Math.ceil(e/10)*1.2;p.isMomentum||(t=Math.max(100,2*t)),p.willEndTimeout=Math.min(1e3,Math.round(t))},P=function(e){return 0===e||e<=.96&&e>=.6},T=function(){if(p.accelerationFactors.length>=5){if(M&&(M=!1,n(p.axisVelocity)>=.2))return void O();var e=p.accelerationFactors.slice(-5);e.every((function(e){var t=!!e.reduce((function(e,t){return e&&e<1&&e===t?1:0})),n=e.filter(P).length===e.length;return t||n}))&&O(),p.accelerationFactors=e}},O=function(){p.isMomentum=!0},A=function(){(p={isStarted:!1,isStartPublished:!1,isMomentum:!1,startTime:0,lastAbsDelta:Infinity,axisMovement:[0,0,0],axisVelocity:[0,0,0],accelerationFactors:[],scrollPoints:[],scrollPointsToMerge:[],willEndTimeout:400}).isStarted=!0,p.startTime=Date.now(),c=void 0,M=!1},j=function(){clearTimeout(l),l=setTimeout(L,p.willEndTimeout)},L=function(e){void 0===e&&(e=!1),p.isStarted&&(b(p.isMomentum&&e?{isEnding:!0,isMomentumCancel:!0}:{isEnding:!0}),p.isMomentum=!1,p.isStarted=!1)},V=function(e){var t=[],n=function(n){n.removeEventListener("wheel",e),t=t.filter((function(e){return e!==n}))};return i({observe:function(i){return i.addEventListener("wheel",e,{passive:!1}),t.push(i),function(){return n(i)}},unobserve:n,disconnect:function(){t.forEach(n)}})}(g),C=V.observe,F=V.unobserve,W=V.disconnect;return x(s),i({on:f,off:d,observe:C,unobserve:F,disconnect:W,feedWheel:g,updateOptions:x})}({preventWheelAction:y,reverseSign:[!0,!0,!1]}),D=S.observe(w),P=S.on("wheel",(function(e){var t=e.axisDelta,n=t[0],i=t[1],o="x"===y?i:n,r=e.isEnding&&!e.isMomentum||e.isMomentum&&e.previous&&!e.previous.isMomentum;Math.abs("x"===y?n:i)>Math.abs(o)&&!T&&!e.isMomentum&&function(e){try{L(b=new MouseEvent("mousedown",e.event))}catch(e){return m()}T=!0,document.documentElement.addEventListener("mousemove",A,!0),document.documentElement.addEventListener("mouseup",A,!0),document.documentElement.addEventListener("mousedown",A,!0),l.wheelDraggingClass&&w.classList.add(l.wheelDraggingClass)}(e),T&&(r?function(e){T=!1,L(j("mouseup",e)),O(),l.wheelDraggingClass&&w.classList.remove(l.wheelDraggingClass)}(e):L(j("mousemove",e)))})),T=!1;function O(){document.documentElement.removeEventListener("mousemove",A,!0),document.documentElement.removeEventListener("mouseup",A,!0),document.documentElement.removeEventListener("mousedown",A,!0)}function A(e){T&&e.isTrusted&&e.stopImmediatePropagation()}function j(e,t){var n,i;if(y===E.options.axis){var o=t.axisMovement;n=o[0],i=o[1]}else{var r=t.axisMovement;i=r[0],n=r[1]}if(!E.options.skipSnaps&&!E.options.dragFree){var a=E.containerRect.width,s=E.containerRect.height;n=n<0?Math.max(n,-a):Math.min(n,a),i=i<0?Math.max(i,-s):Math.min(i,s)}return new MouseEvent(e,{clientX:b.clientX+n,clientY:b.clientY+i,screenX:b.screenX+n,screenY:b.screenY+i,movementX:n,movementY:i,button:0,bubbles:!0,cancelable:!0,composed:!0})}function L(e){f.containerNode().dispatchEvent(e)}m=function(){D(),P(),O()}},destroy:function(){return m()}}}return u.globalOptions=void 0,u})); //# sourceMappingURL=embla-carousel-wheel-gestures.umd.js.map