!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(t.Vue2PerfectScrollbar={})}(this,function(t){"use strict";function v(t){return getComputedStyle(t)}function d(t,e){for(var i in e){var r=e[i];"number"==typeof r&&(r+="px"),t.style[i]=r}return t}function p(t){var e=document.createElement("div");return e.className=t,e}var i="undefined"!=typeof Element&&(Element.prototype.matches||Element.prototype.webkitMatchesSelector||Element.prototype.mozMatchesSelector||Element.prototype.msMatchesSelector);function s(t,e){if(!i)throw new Error("No element matching method supported");return i.call(t,e)}function r(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 s(t,e)})}var m={main:"ps",element:{thumb:function(t){return"ps__thumb-"+t},rail:function(t){return"ps__rail-"+t},consuming:"ps__child--consume"},state:{focus:"ps--focus",clicking:"ps--clicking",active:function(t){return"ps--active-"+t},scrolling:function(t){return"ps--scrolling-"+t}}},l={x:null,y:null};function Y(t,e){var i=t.element.classList,r=m.state.scrolling(e);i.contains(r)?clearTimeout(l[e]):i.add(r)}function w(t,e){l[e]=setTimeout(function(){return t.isAlive&&t.element.classList.remove(m.state.scrolling(e))},t.settings.scrollingThreshold)}var o=function(t){this.element=t,this.handlers={}},e={isEmpty:{configurable:!0}};o.prototype.bind=function(t,e){void 0===this.handlers[t]&&(this.handlers[t]=[]),this.handlers[t].push(e),this.element.addEventListener(t,e,!1)},o.prototype.unbind=function(e,i){var r=this;this.handlers[e]=this.handlers[e].filter(function(t){return!(!i||t===i)||(r.element.removeEventListener(e,t,!1),!1)})},o.prototype.unbindAll=function(){for(var t in this.handlers)this.unbind(t)},e.isEmpty.get=function(){var e=this;return Object.keys(this.handlers).every(function(t){return 0===e.handlers[t].length})},Object.defineProperties(o.prototype,e);var f=function(){this.eventElements=[]};function b(t){if("function"==typeof window.CustomEvent)return new CustomEvent(t);var e=document.createEvent("CustomEvent");return e.initCustomEvent(t,!1,!1,void 0),e}f.prototype.eventElement=function(e){var t=this.eventElements.filter(function(t){return t.element===e})[0];return t||(t=new o(e),this.eventElements.push(t)),t},f.prototype.bind=function(t,e,i){this.eventElement(t).bind(e,i)},f.prototype.unbind=function(t,e,i){var r=this.eventElement(t);r.unbind(e,i),r.isEmpty&&this.eventElements.splice(this.eventElements.indexOf(r),1)},f.prototype.unbindAll=function(){this.eventElements.forEach(function(t){return t.unbindAll()}),this.eventElements=[]},f.prototype.once=function(t,e,i){var r=this.eventElement(t),n=function(t){r.unbind(e,n),i(t)};r.bind(e,n)};var a=function(t,e,i,r,n){var l;if(void 0===r&&(r=!0),void 0===n&&(n=!1),"top"===e)l=["contentHeight","containerHeight","scrollTop","y","up","down"];else{if("left"!==e)throw new Error("A proper axis should be provided");l=["contentWidth","containerWidth","scrollLeft","x","left","right"]}!function(t,e,i,r,n){var l=i[0],o=i[1],s=i[2],a=i[3],c=i[4],h=i[5];void 0===r&&(r=!0);void 0===n&&(n=!1);var u=t.element;t.reach[a]=null,u[s]<1&&(t.reach[a]="start");u[s]>t[l]-t[o]-1&&(t.reach[a]="end");e&&(u.dispatchEvent(b("ps-scroll-"+a)),e<0?u.dispatchEvent(b("ps-scroll-"+c)):0=t.railXWidth-t.scrollbarXWidth&&(t.scrollbarXLeft=t.railXWidth-t.scrollbarXWidth),t.scrollbarYTop>=t.railYHeight-t.scrollbarYHeight&&(t.scrollbarYTop=t.railYHeight-t.scrollbarYHeight),function(t,e){var i={width:e.railXWidth},r=Math.floor(t.scrollTop);e.isRtl?i.left=e.negativeScrollAdjustment+t.scrollLeft+e.containerWidth-e.contentWidth:i.left=t.scrollLeft;e.isScrollbarXUsingBottom?i.bottom=e.scrollbarXBottom-r:i.top=e.scrollbarXTop+r;d(e.scrollbarXRail,i);var n={top:r,height:e.railYHeight};e.isScrollbarYUsingRight?e.isRtl?n.right=e.contentWidth-(e.negativeScrollAdjustment+t.scrollLeft)-e.scrollbarYRight-e.scrollbarYOuterWidth:n.right=e.scrollbarYRight-t.scrollLeft:e.isRtl?n.left=e.negativeScrollAdjustment+t.scrollLeft+2*e.containerWidth-e.contentWidth-e.scrollbarYLeft-e.scrollbarYOuterWidth:n.left=e.scrollbarYLeft+t.scrollLeft;d(e.scrollbarYRail,n),d(e.scrollbarX,{left:e.scrollbarXLeft,width:e.scrollbarXWidth-e.railBorderXWidth}),d(e.scrollbarY,{top:e.scrollbarYTop,height:e.scrollbarYHeight-e.railBorderYWidth})}(e,t),t.scrollbarXActive?e.classList.add(m.state.active("x")):(e.classList.remove(m.state.active("x")),t.scrollbarXWidth=0,t.scrollbarXLeft=0,e.scrollLeft=0),t.scrollbarYActive?e.classList.add(m.state.active("y")):(e.classList.remove(m.state.active("y")),t.scrollbarYHeight=0,t.scrollbarYTop=0,e.scrollTop=0)};function c(t,e){return t.settings.minScrollbarLength&&(e=Math.max(e,t.settings.minScrollbarLength)),t.settings.maxScrollbarLength&&(e=Math.min(e,t.settings.maxScrollbarLength)),e}function h(e,t){var i=t[0],r=t[1],n=t[2],l=t[3],o=t[4],s=t[5],a=t[6],c=t[7],h=t[8],u=e.element,d=null,p=null,f=null;function b(t){u[a]=d+f*(t[n]-p),Y(e,c),X(e),t.stopPropagation(),t.preventDefault()}function g(){w(e,c),e[h].classList.remove(m.state.clicking),e.event.unbind(e.ownerDocument,"mousemove",b)}e.event.bind(e[o],"mousedown",function(t){d=u[a],p=t[n],f=(e[r]-e[i])/(e[l]-e[s]),e.event.bind(e.ownerDocument,"mousemove",b),e.event.once(e.ownerDocument,"mouseup",g),e[h].classList.add(m.state.clicking),t.stopPropagation(),t.preventDefault()})}var W={"click-rail":function(i){i.event.bind(i.scrollbarY,"mousedown",function(t){return t.stopPropagation()}),i.event.bind(i.scrollbarYRail,"mousedown",function(t){var e=t.pageY-window.pageYOffset-i.scrollbarYRail.getBoundingClientRect().top>i.scrollbarYTop?1:-1;i.element.scrollTop+=e*i.containerHeight,X(i),t.stopPropagation()}),i.event.bind(i.scrollbarX,"mousedown",function(t){return t.stopPropagation()}),i.event.bind(i.scrollbarXRail,"mousedown",function(t){var e=t.pageX-window.pageXOffset-i.scrollbarXRail.getBoundingClientRect().left>i.scrollbarXLeft?1:-1;i.element.scrollLeft+=e*i.containerWidth,X(i),t.stopPropagation()})},"drag-thumb":function(t){h(t,["containerWidth","contentWidth","pageX","railXWidth","scrollbarX","scrollbarXWidth","scrollLeft","x","scrollbarXRail"]),h(t,["containerHeight","contentHeight","pageY","railYHeight","scrollbarY","scrollbarYHeight","scrollTop","y","scrollbarYRail"])},keyboard:function(l){var o=l.element;l.event.bind(l.ownerDocument,"keydown",function(t){if(!(t.isDefaultPrevented&&t.isDefaultPrevented()||t.defaultPrevented)&&(s(o,":hover")||s(l.scrollbarX,":focus")||s(l.scrollbarY,":focus"))){var e,i=document.activeElement?document.activeElement:l.ownerDocument.activeElement;if(i){if("IFRAME"===i.tagName)i=i.contentDocument.activeElement;else for(;i.shadowRoot;)i=i.shadowRoot.activeElement;if(s(e=i,"input,[contenteditable]")||s(e,"select,[contenteditable]")||s(e,"textarea,[contenteditable]")||s(e,"button,[contenteditable]"))return}var r=0,n=0;switch(t.which){case 37:r=t.metaKey?-l.contentWidth:t.altKey?-l.containerWidth:-30;break;case 38:n=t.metaKey?l.contentHeight:t.altKey?l.containerHeight:30;break;case 39:r=t.metaKey?l.contentWidth:t.altKey?l.containerWidth:30;break;case 40:n=t.metaKey?-l.contentHeight:t.altKey?-l.containerHeight:-30;break;case 32:n=t.shiftKey?l.containerHeight:-l.containerHeight;break;case 33:n=l.containerHeight;break;case 34:n=-l.containerHeight;break;case 36:n=l.contentHeight;break;case 35:n=-l.contentHeight;break;default:return}l.settings.suppressScrollX&&0!==r||l.settings.suppressScrollY&&0!==n||(o.scrollTop-=n,o.scrollLeft+=r,X(l),function(t,e){var i=Math.floor(o.scrollTop);if(0===t){if(!l.scrollbarYActive)return!1;if(0===i&&0=l.contentHeight-l.containerHeight&&e<0)return!l.settings.wheelPropagation}var r=o.scrollLeft;if(0===e){if(!l.scrollbarXActive)return!1;if(0===r&&t<0||r>=l.contentWidth-l.containerWidth&&0Math.abs(s)?h||u:d||p)||!b.settings.wheelPropagation))&&!t.ctrlKey&&(t.stopPropagation(),t.preventDefault())}}void 0!==window.onwheel?b.event.bind(g,"wheel",t):void 0!==window.onmousewheel&&b.event.bind(g,"mousewheel",t)},touch:function(s){if(y.supportsTouch||y.supportsIePointer){var a=s.element,c={},h=0,u={},i=null;y.supportsTouch?(s.event.bind(a,"touchstart",t),s.event.bind(a,"touchmove",e),s.event.bind(a,"touchend",r)):y.supportsIePointer&&(window.PointerEvent?(s.event.bind(a,"pointerdown",t),s.event.bind(a,"pointermove",e),s.event.bind(a,"pointerup",r)):window.MSPointerEvent&&(s.event.bind(a,"MSPointerDown",t),s.event.bind(a,"MSPointerMove",e),s.event.bind(a,"MSPointerUp",r)))}function d(t,e){a.scrollTop-=e,a.scrollLeft-=t,X(s)}function p(t){return t.targetTouches?t.targetTouches[0]:t}function f(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 t(t){if(f(t)){var e=p(t);c.pageX=e.pageX,c.pageY=e.pageY,h=(new Date).getTime(),null!==i&&clearInterval(i)}}function e(t){if(f(t)){var e=p(t),i={pageX:e.pageX,pageY:e.pageY},r=i.pageX-c.pageX,n=i.pageY-c.pageY;if(function(t,e,i){if(!a.contains(t))return!1;for(var r=t;r&&r!==a;){if(r.classList.contains(m.element.consuming))return!0;var n=v(r);if([n.overflow,n.overflowX,n.overflowY].join("").match(/(scroll|auto)/)){var l=r.scrollHeight-r.clientHeight;if(0=this.contentWidth-this.containerWidth?"end":null,y:t.scrollTop<=0?"start":t.scrollTop>=this.contentHeight-this.containerHeight?"end":null},this.isAlive=!0,this.settings.handlers.forEach(function(t){return W[t](i)}),this.lastScrollTop=Math.floor(t.scrollTop),this.lastScrollLeft=t.scrollLeft,this.event.bind(this.element,"scroll",function(t){return i.onScroll(t)}),X(this)};u.prototype.update=function(){this.isAlive&&(this.negativeScrollAdjustment=this.isNegativeScroll?this.element.scrollWidth-this.element.clientWidth:0,d(this.scrollbarXRail,{display:"block"}),d(this.scrollbarYRail,{display:"block"}),this.railXMarginWidth=g(v(this.scrollbarXRail).marginLeft)+g(v(this.scrollbarXRail).marginRight),this.railYMarginHeight=g(v(this.scrollbarYRail).marginTop)+g(v(this.scrollbarYRail).marginBottom),d(this.scrollbarXRail,{display:"none"}),d(this.scrollbarYRail,{display:"none"}),X(this),a(this,"top",0,!1,!0),a(this,"left",0,!1,!0),d(this.scrollbarXRail,{display:""}),d(this.scrollbarYRail,{display:""}))},u.prototype.onScroll=function(t){this.isAlive&&(X(this),a(this,"top",this.element.scrollTop-this.lastScrollTop),a(this,"left",this.element.scrollLeft-this.lastScrollLeft),this.lastScrollTop=Math.floor(this.element.scrollTop),this.lastScrollLeft=this.element.scrollLeft)},u.prototype.destroy=function(){this.isAlive&&(this.event.unbindAll(),r(this.scrollbarX),r(this.scrollbarY),r(this.scrollbarXRail),r(this.scrollbarYRail),this.removePsClasses(),this.element=null,this.scrollbarX=null,this.scrollbarY=null,this.scrollbarXRail=null,this.scrollbarYRail=null,this.isAlive=!1)},u.prototype.removePsClasses=function(){this.element.className=this.element.className.split(" ").filter(function(t){return!t.match(/^ps([-_].+|)$/)}).join(" ")};var L={name:"PerfectScrollbar",props:{options:{type:Object,required:!1,default:function(){}},tag:{type:String,required:!1,default:"div"},watchOptions:{type:Boolean,required:!1,default:!1}},data:function(){return{ps:null}},watch:{watchOptions:function(t){!t&&this.watcher?this.watcher():this.createWatcher()}},mounted:function(){this.create(),this.watchOptions&&this.createWatcher()},updated:function(){this.update()},beforeDestroy:function(){this.destroy()},methods:{create:function(){this.ps&&this.$isServer||(this.ps=new u(this.$refs.container,this.options))},createWatcher:function(){var t=this;this.watcher=this.$watch("options",function(){t.destroy(),t.create()},{deep:!0})},update:function(){this.ps&&this.ps.update()},destroy:function(){this.ps&&(this.ps.destroy(),this.ps=null)}},render:function(t){return t(this.tag,{ref:"container",class:"ps",on:this.$listeners},this.$slots.default)}};function R(t,e){e&&(e.name&&"string"==typeof e.name&&(L.name=e.name),e.options&&"object"==typeof e.options&&(L.props.options.default=function(){return e.options}),e.tag&&"string"==typeof e.tag&&(L.props.tag.default=e.tag),e.watchOptions&&"boolean"==typeof e.watchOptions&&(L.props.watchOptions=e.watchOptions)),t.component(L.name,L)}t.install=R,t.PerfectScrollbar=L,t.default=R,Object.defineProperty(t,"__esModule",{value:!0})});