!function(t){"object"==typeof exports&&"object"==typeof module?t(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],t):t(CodeMirror)}(function(h){"use strict";function i(t,e,o){this.orientation=e,this.scroll=o,this.screen=this.total=this.size=1,this.pos=0,this.node=document.createElement("div"),this.node.className=t+"-"+e,this.inner=this.node.appendChild(document.createElement("div"));var r=this;function i(t){var e=h.wheelEventPixels(t)["horizontal"==r.orientation?"x":"y"],o=r.pos;r.moveTo(r.pos+e),r.pos!=o&&h.e_preventDefault(t)}h.on(this.inner,"mousedown",function(t){if(1==t.which){h.e_preventDefault(t);var e="horizontal"==r.orientation?"pageX":"pageY",o=t[e],i=r.pos;h.on(document,"mousemove",s),h.on(document,"mouseup",n)}function n(){h.off(document,"mousemove",s),h.off(document,"mouseup",n)}function s(t){if(1!=t.which)return n();r.moveTo(i+(t[e]-o)*(r.total/r.size))}}),h.on(this.node,"click",function(t){h.e_preventDefault(t);var e,o=r.inner.getBoundingClientRect();e="horizontal"==r.orientation?t.clientX<o.left?-1:t.clientX>o.right?1:0:t.clientY<o.top?-1:t.clientY>o.bottom?1:0,r.moveTo(r.pos+e*r.screen)}),h.on(this.node,"mousewheel",i),h.on(this.node,"DOMMouseScroll",i)}i.prototype.setPos=function(t,e){return t<0&&(t=0),t>this.total-this.screen&&(t=this.total-this.screen),!(!e&&t==this.pos)&&(this.pos=t,this.inner.style["horizontal"==this.orientation?"left":"top"]=t*(this.size/this.total)+"px",!0)},i.prototype.moveTo=function(t){this.setPos(t)&&this.scroll(t,this.orientation)};function o(t,e,o){this.addClass=t,this.horiz=new i(t,"horizontal",o),e(this.horiz.node),this.vert=new i(t,"vertical",o),e(this.vert.node),this.width=null}i.prototype.update=function(t,e,o){var i=this.screen!=e||this.total!=t||this.size!=o;i&&(this.screen=e,this.total=t,this.size=o);var n=this.screen*(this.size/this.total);n<10&&(this.size-=10-n,n=10),this.inner.style["horizontal"==this.orientation?"width":"height"]=n+"px",this.setPos(this.pos,i)},o.prototype.update=function(t){if(null==this.width){var e=window.getComputedStyle?window.getComputedStyle(this.horiz.node):this.horiz.node.currentStyle;e&&(this.width=parseInt(e.height))}var o=this.width||0,i=t.scrollWidth>t.clientWidth+1,n=t.scrollHeight>t.clientHeight+1;return this.vert.node.style.display=n?"block":"none",this.horiz.node.style.display=i?"block":"none",n&&(this.vert.update(t.scrollHeight,t.clientHeight,t.viewHeight-(i?o:0)),this.vert.node.style.bottom=i?o+"px":"0"),i&&(this.horiz.update(t.scrollWidth,t.clientWidth,t.viewWidth-(n?o:0)-t.barLeft),this.horiz.node.style.right=n?o+"px":"0",this.horiz.node.style.left=t.barLeft+"px"),{right:n?o:0,bottom:i?o:0}},o.prototype.setScrollTop=function(t){this.vert.setPos(t)},o.prototype.setScrollLeft=function(t){this.horiz.setPos(t)},o.prototype.clear=function(){var t=this.horiz.node.parentNode;t.removeChild(this.horiz.node),t.removeChild(this.vert.node)},h.scrollbarModel.simple=function(t,e){return new o("CodeMirror-simplescroll",t,e)},h.scrollbarModel.overlay=function(t,e){return new o("CodeMirror-overlayscroll",t,e)}});