!function(n){"function"==typeof define&&define.amd&&define.amd.jQuery?define(["jquery.touchSwipe.js"],n):n(jQuery)}(function(n){"use strict";function e(e){return!e||void 0!==e.allowPageScroll||void 0===e.swipe&&void 0===e.swipeStatus||(e.allowPageScroll=c),void 0!==e.click&&void 0===e.tap&&(e.tap=e.click),e||(e={}),e=n.extend({},n.fn.swipe.defaults,e),this.each(function(){var r=n(this),i=r.data(P);i||(i=new t(this,e),r.data(P,i))})}function t(e,t){function D(e){if(!(sn()||n(e.target).closest(t.excludedElements,Fn).length>0)){var r,i=e.originalEvent?e.originalEvent:e,o=O?i.touches[0]:i;return Vn=S,(O?zn=i.touches.length:e.preventDefault(),jn=0,Hn=null,qn=null,_n=0,Qn=0,Cn=0,Xn=1,Yn=0,Gn=gn(),Wn=Tn(),an(),!O||zn===t.fingers||t.fingers===T||q()?(hn(0,o),Zn=Pn(),2==zn&&(hn(1,i.touches[1]),Qn=Cn=En(Gn[0].start,Gn[1].start)),(t.swipeStatus||t.pinchStatus)&&(r=U(i,Vn))):r=!1,!1===r)?(Vn=y,U(i,Vn),r):(t.hold&&(ee=setTimeout(n.proxy(function(){Fn.trigger("hold",[i.target]),t.hold&&(r=t.hold.call(Fn,i,i.target))},this),t.longTapThreshold)),pn(!0),null)}}function L(n){var e=n.originalEvent?n.originalEvent:n;if(Vn!==m&&Vn!==y&&!cn()){var r,i=O?e.touches[0]:e,o=fn(i);if(Bn=Pn(),O&&(zn=e.touches.length),t.hold&&clearTimeout(ee),Vn=E,2==zn&&(0==Qn?(hn(1,e.touches[1]),Qn=Cn=En(Gn[0].start,Gn[1].start)):(fn(e.touches[1]),Cn=En(Gn[0].end,Gn[1].end),qn=yn(Gn[0].end,Gn[1].end)),Xn=mn(Qn,Cn),Yn=Math.abs(Qn-Cn)),zn===t.fingers||t.fingers===T||!O||q()){if(Hn=Mn(o.start,o.end),X(n,Hn),jn=On(o.start,o.end),_n=Sn(),wn(Hn,jn),(t.swipeStatus||t.pinchStatus)&&(r=U(e,Vn)),!t.triggerOnTouchEnd||t.triggerOnTouchLeave){var u=!0;if(t.triggerOnTouchLeave){var l=Dn(this);u=Ln(o.end,l)}!t.triggerOnTouchEnd&&u?Vn=N(E):t.triggerOnTouchLeave&&!u&&(Vn=N(m)),Vn!=y&&Vn!=m||U(e,Vn)}}else Vn=y,U(e,Vn);!1===r&&(Vn=y,U(e,Vn))}}function R(n){var e=n.originalEvent;return O&&e.touches.length>0?(ln(),!0):(cn()&&(zn=Kn),Bn=Pn(),_n=Sn(),_()||!H()?(Vn=y,U(e,Vn)):t.triggerOnTouchEnd||0==t.triggerOnTouchEnd&&Vn===E?(n.preventDefault(),Vn=m,U(e,Vn)):!t.triggerOnTouchEnd&&B()?(Vn=m,j(e,Vn,f)):Vn===E&&(Vn=y,U(e,Vn)),pn(!1),null)}function k(){zn=0,Bn=0,Zn=0,Qn=0,Cn=0,Xn=1,an(),pn(!1)}function A(n){var e=n.originalEvent;t.triggerOnTouchLeave&&(Vn=N(m),U(e,Vn))}function I(){Fn.unbind(kn,D),Fn.unbind(Un,k),Fn.unbind(An,L),Fn.unbind(In,R),Nn&&Fn.unbind(Nn,A),pn(!1)}function N(n){var e=n,r=C(),i=H(),o=_();return!r||o?e=y:!i||n!=E||t.triggerOnTouchEnd&&!t.triggerOnTouchLeave?!i&&n==m&&t.triggerOnTouchLeave&&(e=y):e=m,e}function U(n,e){var t=void 0;return z()||V()||W()||q()?((z()||V())&&(t=j(n,e,p)),(W()||q())&&!1!==t&&(t=j(n,e,h))):on()&&!1!==t?t=j(n,e,d):un()&&!1!==t?t=j(n,e,g):rn()&&!1!==t&&(t=j(n,e,f)),e===y&&k(n),e===m&&(O?0==n.touches.length&&k(n):k(n)),t}function j(e,c,s){var w=void 0;if(s==p){if(Fn.trigger("swipeStatus",[c,Hn||null,jn||0,_n||0,zn,Gn]),t.swipeStatus&&!1===(w=t.swipeStatus.call(Fn,e,c,Hn||null,jn||0,_n||0,zn,Gn)))return!1;if(c==m&&F()){if(Fn.trigger("swipe",[Hn,jn,_n,zn,Gn]),t.swipe&&!1===(w=t.swipe.call(Fn,e,Hn,jn,_n,zn,Gn)))return!1;switch(Hn){case r:Fn.trigger("swipeLeft",[Hn,jn,_n,zn,Gn]),t.swipeLeft&&(w=t.swipeLeft.call(Fn,e,Hn,jn,_n,zn,Gn));break;case i:Fn.trigger("swipeRight",[Hn,jn,_n,zn,Gn]),t.swipeRight&&(w=t.swipeRight.call(Fn,e,Hn,jn,_n,zn,Gn));break;case o:Fn.trigger("swipeUp",[Hn,jn,_n,zn,Gn]),t.swipeUp&&(w=t.swipeUp.call(Fn,e,Hn,jn,_n,zn,Gn));break;case u:Fn.trigger("swipeDown",[Hn,jn,_n,zn,Gn]),t.swipeDown&&(w=t.swipeDown.call(Fn,e,Hn,jn,_n,zn,Gn))}}}if(s==h){if(Fn.trigger("pinchStatus",[c,qn||null,Yn||0,_n||0,zn,Xn,Gn]),t.pinchStatus&&!1===(w=t.pinchStatus.call(Fn,e,c,qn||null,Yn||0,_n||0,zn,Xn,Gn)))return!1;if(c==m&&Y())switch(qn){case l:Fn.trigger("pinchIn",[qn||null,Yn||0,_n||0,zn,Xn,Gn]),t.pinchIn&&(w=t.pinchIn.call(Fn,e,qn||null,Yn||0,_n||0,zn,Xn,Gn));break;case a:Fn.trigger("pinchOut",[qn||null,Yn||0,_n||0,zn,Xn,Gn]),t.pinchOut&&(w=t.pinchOut.call(Fn,e,qn||null,Yn||0,_n||0,zn,Xn,Gn))}}return s==f?c!==y&&c!==m||(clearTimeout(ne),clearTimeout(ee),J()&&!nn()?($n=Pn(),ne=setTimeout(n.proxy(function(){$n=null,Fn.trigger("tap",[e.target]),t.tap&&(w=t.tap.call(Fn,e,e.target))},this),t.doubleTapThreshold)):($n=null,Fn.trigger("tap",[e.target]),t.tap&&(w=t.tap.call(Fn,e,e.target)))):s==d?c!==y&&c!==m||(clearTimeout(ne),$n=null,Fn.trigger("doubletap",[e.target]),t.doubleTap&&(w=t.doubleTap.call(Fn,e,e.target))):s==g&&(c!==y&&c!==m||(clearTimeout(ne),$n=null,Fn.trigger("longtap",[e.target]),t.longTap&&(w=t.longTap.call(Fn,e,e.target)))),w}function H(){var n=!0;return null!==t.threshold&&(n=jn>=t.threshold),n}function _(){var n=!1;return null!==t.cancelThreshold&&null!==Hn&&(n=vn(Hn)-jn>=t.cancelThreshold),n}function Q(){return null===t.pinchThreshold||Yn>=t.pinchThreshold}function C(){return!t.maxTimeThreshold||!(_n>=t.maxTimeThreshold)}function X(n,e){if(!1!==t.preventDefaultEvents)if(t.allowPageScroll===c)n.preventDefault();else{var l=t.allowPageScroll===s;switch(e){case r:(t.swipeLeft&&l||!l&&t.allowPageScroll!=w)&&n.preventDefault();break;case i:(t.swipeRight&&l||!l&&t.allowPageScroll!=w)&&n.preventDefault();break;case o:(t.swipeUp&&l||!l&&t.allowPageScroll!=v)&&n.preventDefault();break;case u:(t.swipeDown&&l||!l&&t.allowPageScroll!=v)&&n.preventDefault()}}}function Y(){var n=G(),e=Z(),t=Q();return n&&e&&t}function q(){return!!(t.pinchStatus||t.pinchIn||t.pinchOut)}function W(){return!(!Y()||!q())}function F(){var n=C(),e=H(),t=G(),r=Z();return!_()&&r&&t&&e&&n}function V(){return!!(t.swipe||t.swipeStatus||t.swipeLeft||t.swipeRight||t.swipeUp||t.swipeDown)}function z(){return!(!F()||!V())}function G(){return zn===t.fingers||t.fingers===T||!O}function Z(){return 0!==Gn[0].end.x}function B(){return!!t.tap}function J(){return!!t.doubleTap}function K(){return!!t.longTap}function $(){if(null==$n)return!1;var n=Pn();return J()&&n-$n<=t.doubleTapThreshold}function nn(){return $()}function en(){return(1===zn||!O)&&(isNaN(jn)||jnt.longTapThreshold&&jn=0?r:t<=360&&t>=315?r:t>=135&&t<=225?i:t>45&&t<135?u:o}function Pn(){return(new Date).getTime()}function Dn(e){e=n(e);var t=e.offset();return{left:t.left,right:t.left+e.outerWidth(),top:t.top,bottom:t.top+e.outerHeight()}}function Ln(n,e){return n.x>e.left&&n.xe.top&&n.y