/*!
* perfect-scrollbar v1.5.0
* Copyright 2020 Hyunje Jun, MDBootstrap and Contributors
* Licensed under MIT
*/
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self,t.PerfectScrollbar=e())}(this,function(){"use strict";function t(t){return getComputedStyle(t)}function e(t,e){for(var i in e){var r=e[i];"number"==typeof r&&(r+="px"),t.style[i]=r}return t}function i(t){var e=document.createElement("div");return e.className=t,e}function r(t,e){if(!p)throw new Error("No element matching method supported");return p.call(t,e)}function l(t){t.remove?t.remove():t.parentNode&&t.parentNode.removeChild(t)}function n(t,e){return Array.prototype.filter.call(t.children,function(t){return r(t,e)})}function o(t,e){var i=t.element.classList,r=b.state.scrolling(e);i.contains(r)?clearTimeout(g[e]):i.add(r)}function s(t,e){g[e]=setTimeout(function(){return t.isAlive&&t.element.classList.remove(b.state.scrolling(e))},t.settings.scrollingThreshold)}function a(t){if("function"==typeof window.CustomEvent)return new CustomEvent(t);var e=document.createEvent("CustomEvent");return e.initCustomEvent(t,!1,!1,undefined),e}function c(t,e,i,r,l){void 0===r&&(r=!0),void 0===l&&(l=!1);var n;if("top"===e)n=["contentHeight","containerHeight","scrollTop","y","up","down"];else{if("left"!==e)throw new Error("A proper axis should be provided");n=["contentWidth","containerWidth","scrollLeft","x","left","right"]}!function(t,e,i,r,l){var n=i[0],c=i[1],h=i[2],u=i[3],d=i[4],f=i[5];void 0===r&&(r=!0);void 0===l&&(l=!1);var p=t.element;t.reach[u]=null,p[h]<1&&(t.reach[u]="start");p[h]>t[n]-t[c]-1&&(t.reach[u]="end");e&&(p.dispatchEvent(a("ps-scroll-"+u)),e<0?p.dispatchEvent(a("ps-scroll-"+d)):e>0&&p.dispatchEvent(a("ps-scroll-"+f)),r&&function(t,e){o(t,e),s(t,e)}(t,u));t.reach[u]&&(e||l)&&p.dispatchEvent(a("ps-"+u+"-reach-"+t.reach[u]))}(t,i,n,r,l)}function h(t){return parseInt(t,10)||0}function u(t){var i=t.element,r=Math.floor(i.scrollTop),o=i.getBoundingClientRect();t.containerWidth=Math.ceil(o.width),t.containerHeight=Math.ceil(o.height),t.contentWidth=i.scrollWidth,t.contentHeight=i.scrollHeight,i.contains(t.scrollbarXRail)||(n(i,b.element.rail("x")).forEach(function(t){return l(t)}),i.appendChild(t.scrollbarXRail)),i.contains(t.scrollbarYRail)||(n(i,b.element.rail("y")).forEach(function(t){return l(t)}),i.appendChild(t.scrollbarYRail)),!t.settings.suppressScrollX&&t.containerWidth+t.settings.scrollXMarginOffset0))return!0}if(i&&o.overflowX.match(/(scroll|auto)/)){var a=n.scrollWidth-n.clientWidth;if(a>0&&(n.scrollLeft>0&&i<0||n.scrollLeft0))return!0}n=n.parentNode}return!1}(i.target,n,o)){var s=!1;e.settings.useBothWheelAxes?e.scrollbarYActive&&!e.scrollbarXActive?(o?r.scrollTop-=o*e.settings.wheelSpeed:r.scrollTop+=n*e.settings.wheelSpeed,s=!0):e.scrollbarXActive&&!e.scrollbarYActive&&(n?r.scrollLeft+=n*e.settings.wheelSpeed:r.scrollLeft-=o*e.settings.wheelSpeed,s=!0):(r.scrollTop-=o*e.settings.wheelSpeed,r.scrollLeft+=n*e.settings.wheelSpeed),u(e),(s=s||function(t,i){var l=Math.floor(r.scrollTop),n=0===r.scrollTop,o=l+r.offsetHeight===r.scrollHeight,s=0===r.scrollLeft,a=r.scrollLeft+r.offsetWidth===r.scrollWidth;return!(Math.abs(i)>Math.abs(t)?n||o:s||a)||!e.settings.wheelPropagation}(n,o))&&!i.ctrlKey&&(i.stopPropagation(),i.preventDefault())}}var r=e.element;"undefined"!=typeof window.onwheel?e.event.bind(r,"wheel",i):"undefined"!=typeof window.onmousewheel&&e.event.bind(r,"mousewheel",i)},touch:function(e){function i(t,i){a.scrollTop-=i,a.scrollLeft-=t,u(e)}function r(t){return t.targetTouches?t.targetTouches[0]:t}function l(t){return!(t.pointerType&&"pen"===t.pointerType&&0===t.buttons||(!t.targetTouches||1!==t.targetTouches.length)&&(!t.pointerType||"mouse"===t.pointerType||t.pointerType===t.MSPOINTER_TYPE_MOUSE))}function n(t){if(l(t)){var e=r(t);c.pageX=e.pageX,c.pageY=e.pageY,h=(new Date).getTime(),null!==f&&clearInterval(f)}}function o(n){if(l(n)){var o=r(n),s={pageX:o.pageX,pageY:o.pageY},u=s.pageX-c.pageX,f=s.pageY-c.pageY;if(function(e,i,r){if(!a.contains(e))return!1;for(var l=e;l&&l!==a;){if(l.classList.contains(b.element.consuming))return!0;var n=t(l);if(r&&n.overflowY.match(/(scroll|auto)/)){var o=l.scrollHeight-l.clientHeight;if(o>0&&(l.scrollTop>0&&r<0||l.scrollTop0))return!0}l=l.parentNode}return!1}(n.target,u,f))return;i(u,f),c=s;var p=(new Date).getTime(),g=p-h;g>0&&(d.x=u/g,d.y=f/g,h=p),function(t,i){var r=Math.floor(a.scrollTop),l=a.scrollLeft,n=Math.abs(t),o=Math.abs(i);if(o>n){if(i<0&&r===e.contentHeight-e.containerHeight||i>0&&0===r)return 0===window.scrollY&&i>0&&X.isChrome}else if(n>o&&(t<0&&l===e.contentWidth-e.containerWidth||t>0&&0===l))return!0;return!0}(u,f)&&n.preventDefault()}}function s(){e.settings.swipeEasing&&(clearInterval(f),f=setInterval(function(){e.isInitialized?clearInterval(f):d.x||d.y?Math.abs(d.x)<.01&&Math.abs(d.y)<.01?clearInterval(f):(i(30*d.x,30*d.y),d.x*=.8,d.y*=.8):clearInterval(f)},10))}if(X.supportsTouch||X.supportsIePointer){var a=e.element,c={},h=0,d={},f=null;X.supportsTouch?(e.event.bind(a,"touchstart",n),e.event.bind(a,"touchmove",o),e.event.bind(a,"touchend",s)):X.supportsIePointer&&(window.PointerEvent?(e.event.bind(a,"pointerdown",n),e.event.bind(a,"pointermove",o),e.event.bind(a,"pointerup",s)):window.MSPointerEvent&&(e.event.bind(a,"MSPointerDown",n),e.event.bind(a,"MSPointerMove",o),e.event.bind(a,"MSPointerUp",s)))}}},y=function(r,l){var n=this;if(void 0===l&&(l={}),"string"==typeof r&&(r=document.querySelector(r)),!r||!r.nodeName)throw new Error("no element is specified to initialize PerfectScrollbar");this.element=r,r.classList.add(b.main),this.settings={handlers:["click-rail","drag-thumb","keyboard","wheel","touch"],maxScrollbarLength:null,minScrollbarLength:null,scrollingThreshold:1e3,scrollXMarginOffset:0,scrollYMarginOffset:0,suppressScrollX:!1,suppressScrollY:!1,swipeEasing:!0,useBothWheelAxes:!1,wheelPropagation:!0,wheelSpeed:1};for(var o in l)this.settings[o]=l[o];this.containerWidth=null,this.containerHeight=null,this.contentWidth=null,this.contentHeight=null;var s=function(){return r.classList.add(b.state.focus)},a=function(){return r.classList.remove(b.state.focus)};this.isRtl="rtl"===t(r).direction,!0===this.isRtl&&r.classList.add(b.rtl),this.isNegativeScroll=function(){var t=r.scrollLeft,e=null;return r.scrollLeft=-1,e=r.scrollLeft<0,r.scrollLeft=t,e}(),this.negativeScrollAdjustment=this.isNegativeScroll?r.scrollWidth-r.clientWidth:0,this.event=new Y,this.ownerDocument=r.ownerDocument||document,this.scrollbarXRail=i(b.element.rail("x")),r.appendChild(this.scrollbarXRail),this.scrollbarX=i(b.element.thumb("x")),this.scrollbarXRail.appendChild(this.scrollbarX),this.scrollbarX.setAttribute("tabindex",0),this.event.bind(this.scrollbarX,"focus",s),this.event.bind(this.scrollbarX,"blur",a),this.scrollbarXActive=null,this.scrollbarXWidth=null,this.scrollbarXLeft=null;var c=t(this.scrollbarXRail);this.scrollbarXBottom=parseInt(c.bottom,10),isNaN(this.scrollbarXBottom)?(this.isScrollbarXUsingBottom=!1,this.scrollbarXTop=h(c.top)):this.isScrollbarXUsingBottom=!0,this.railBorderXWidth=h(c.borderLeftWidth)+h(c.borderRightWidth),e(this.scrollbarXRail,{display:"block"}),this.railXMarginWidth=h(c.marginLeft)+h(c.marginRight),e(this.scrollbarXRail,{display:""}),this.railXWidth=null,this.railXRatio=null,this.scrollbarYRail=i(b.element.rail("y")),r.appendChild(this.scrollbarYRail),this.scrollbarY=i(b.element.thumb("y")),this.scrollbarYRail.appendChild(this.scrollbarY),this.scrollbarY.setAttribute("tabindex",0),this.event.bind(this.scrollbarY,"focus",s),this.event.bind(this.scrollbarY,"blur",a),this.scrollbarYActive=null,this.scrollbarYHeight=null,this.scrollbarYTop=null;var d=t(this.scrollbarYRail);this.scrollbarYRight=parseInt(d.right,10),isNaN(this.scrollbarYRight)?(this.isScrollbarYUsingRight=!1,this.scrollbarYLeft=h(d.left)):this.isScrollbarYUsingRight=!0,this.scrollbarYOuterWidth=this.isRtl?function(e){var i=t(e);return h(i.width)+h(i.paddingLeft)+h(i.paddingRight)+h(i.borderLeftWidth)+h(i.borderRightWidth)}(this.scrollbarY):null,this.railBorderYWidth=h(d.borderTopWidth)+h(d.borderBottomWidth),e(this.scrollbarYRail,{display:"block"}),this.railYMarginHeight=h(d.marginTop)+h(d.marginBottom),e(this.scrollbarYRail,{display:""}),this.railYHeight=null,this.railYRatio=null,this.reach={x:r.scrollLeft<=0?"start":r.scrollLeft>=this.contentWidth-this.containerWidth?"end":null,y:r.scrollTop<=0?"start":r.scrollTop>=this.contentHeight-this.containerHeight?"end":null},this.isAlive=!0,this.settings.handlers.forEach(function(t){return w[t](n)}),this.lastScrollTop=Math.floor(r.scrollTop),this.lastScrollLeft=r.scrollLeft,this.event.bind(this.element,"scroll",function(t){return n.onScroll(t)}),u(this)};return y.prototype.update=function(){this.isAlive&&(this.negativeScrollAdjustment=this.isNegativeScroll?this.element.scrollWidth-this.element.clientWidth:0,e(this.scrollbarXRail,{display:"block"}),e(this.scrollbarYRail,{display:"block"}),this.railXMarginWidth=h(t(this.scrollbarXRail).marginLeft)+h(t(this.scrollbarXRail).marginRight),this.railYMarginHeight=h(t(this.scrollbarYRail).marginTop)+h(t(this.scrollbarYRail).marginBottom),e(this.scrollbarXRail,{display:"none"}),e(this.scrollbarYRail,{display:"none"}),u(this),c(this,"top",0,!1,!0),c(this,"left",0,!1,!0),e(this.scrollbarXRail,{display:""}),e(this.scrollbarYRail,{display:""}))},y.prototype.onScroll=function(t){this.isAlive&&(u(this),c(this,"top",this.element.scrollTop-this.lastScrollTop),c(this,"left",this.element.scrollLeft-this.lastScrollLeft),this.lastScrollTop=Math.floor(this.element.scrollTop),this.lastScrollLeft=this.element.scrollLeft)},y.prototype.destroy=function(){this.isAlive&&(this.event.unbindAll(),l(this.scrollbarX),l(this.scrollbarY),l(this.scrollbarXRail),l(this.scrollbarYRail),this.removePsClasses(),this.element=null,this.scrollbarX=null,this.scrollbarY=null,this.scrollbarXRail=null,this.scrollbarYRail=null,this.isAlive=!1)},y.prototype.removePsClasses=function(){this.element.className=this.element.className.split(" ").filter(function(t){return!t.match(/^ps([-_].+|)$/)}).join(" ")},y});