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