window.CodeMirror=function(){function l(a,b){if(!(this instanceof l))return new l(a,b);this.options=b=b||{};for(var c in Hb)!b.hasOwnProperty(c)&&Hb.hasOwnProperty(c)&&(b[c]=Hb[c]);Ib(b);c=this.display=Fd(a,"string"==typeof b.value?0:b.value.first);c.wrapper.CodeMirror=this;Ac(this);b.autofocus&&!Jb&&G(this);this.state={keyMaps:[],overlays:[],modeGen:0,overwrite:!1,focused:!1,suppressEdits:!1,pasteIncoming:!1,draggingText:!1,highlight:new Kb};Bc(this);b.lineWrapping&&(this.display.wrapper.className+= " CodeMirror-wrap");var d=b.value;"string"==typeof d&&(d=new F(b.value,b.mode));p(this,Cc)(this,d);B&&setTimeout(K(W,this,!0),20);Gd(this);var e;try{e=document.activeElement==c.input}catch(f){}e||b.autofocus&&!Jb?setTimeout(K($,this),20):Lb(this);p(this,function(){for(var a in ia)if(ia.propertyIsEnumerable(a))ia[a](this,b[a],Dc);for(a=0;ab.maxLineLength&& (b.maxLineLength=e,b.maxLine=a)})}function Ib(a){for(var b=!1,c=0;c b.scroller.clientWidth,e=c>b.scroller.clientHeight;e?(b.scrollbarV.style.display="block",b.scrollbarV.style.bottom=d?Ga(b.measure)+"px":"0",b.scrollbarV.firstChild.style.height=c-b.scroller.clientHeight+b.scrollbarV.clientHeight+"px"):b.scrollbarV.style.display="";d?(b.scrollbarH.style.display="block",b.scrollbarH.style.right=e?Ga(b.measure)+"px":"0",b.scrollbarH.firstChild.style.width=b.scroller.scrollWidth-b.scroller.clientWidth+b.scrollbarH.clientWidth+"px"):b.scrollbarH.style.display="";d&&e? (b.scrollbarFiller.style.display="block",b.scrollbarFiller.style.height=b.scrollbarFiller.style.width=Ga(b.measure)+"px"):b.scrollbarFiller.style.display="";d&&a.options.coverGutterNextToScrollbar&&a.options.fixedGutter?(b.gutterFiller.style.display="block",b.gutterFiller.style.height=Ga(b.measure)+"px",b.gutterFiller.style.width=b.gutters.offsetWidth+"px"):b.gutterFiller.style.display="";Hd&&0===Ga(b.measure)&&(b.scrollbarV.style.minWidth=b.scrollbarH.style.minHeight=Id?"18px":"12px")}function Rb(a, b,c){var d=a.scroller.scrollTop,e=a.wrapper.clientHeight;"number"==typeof c?d=c:c&&(d=c.top,e=c.bottom-c.top);d=Math.floor(d-a.lineSpace.offsetTop);a=Math.ceil(d+e);return{from:cb(b,d),to:cb(b,a)}}function Ob(a){var b=a.display;if(b.alignWidgets||b.gutters.firstChild&&a.options.fixedGutter){for(var c=Sb(b)-b.scroller.scrollLeft+a.doc.scrollLeft,d=b.gutters.offsetWidth,e=c+"px",f=b.lineDiv.firstChild;f;f=f.nextSibling)if(f.alignable)for(var g=0,h=f.alignable;g=a.display.showingFrom&&g.to<=a.display.showingTo)break;b=[]}f&&(O(a,"update",a),(a.display.showingFrom!= d||a.display.showingTo!=e)&&O(a,"viewportChange",a,a.display.showingFrom,a.display.showingTo));return f}function Kd(a,b,c){var d=a.display,e=a.doc;if(d.wrapper.clientWidth){if(!(0==b.length&&c.from>d.showingFrom&&c.toh-d.showingFrom&&(h=Math.max(e.first,d.showingFrom));d.showingTo>c&&20>d.showingTo-c&&(c=Math.min(f,d.showingTo));if(Ha)for(h=H(ma(e,q(e,h)));c=i[0].to?[]:Ld(i,b);if(Ha)for(f=0;fb.from)b.to=j;else{i.splice(f--, 1);break}for(f=e=0;fc&&(b.to=c),b.from>=b.to?i.splice(f--,1):e+=b.to-b.from;if(e==c-h&&h==d.showingFrom&&c==d.showingTo)Hc(a);else{i.sort(function(a,b){return a.from-b.from});try{var k=document.activeElement}catch(m){}e<0.7*(c-h)&&(d.lineDiv.style.display="none");Md(a,h,c,i,g);d.lineDiv.style.display="";k&&(document.activeElement!=k&&k.offsetHeight)&&k.focus();if(h!=d.showingFrom||c!=d.showingTo||d.lastSizeC!=d.wrapper.clientHeight)d.lastSizeC=d.wrapper.clientHeight; d.showingFrom=h;d.showingTo=c;$a(a,100);k=d.lineDiv.offsetTop;for(e=d.lineDiv.firstChild;e;e=e.nextSibling)if(e.lineObj&&(ka?(g=e.offsetTop+e.offsetHeight,f=g-k,k=g):(f=y(e),f=f.bottom-f.top),g=e.lineObj.height-f,2>f&&(f=Da(d)),0.001g))if(M(e.lineObj,f),g=e.lineObj.widgets)for(f=0;f=j.to?f.push(j):(e.from>j.from&&f.push({from:j.from,to:e.from}),e.tos){for(;k.lineObj!=b;)k=f(k);i&&(e<=s&&k.lineNumber)&&Ic(k.lineNumber,""+a.options.lineNumberFormatter(s+a.options.firstLineNumber)); k=k.nextSibling}else{if(b.widgets)for(var o=0,q=k;q&&20>o;++o,q=q.nextSibling)if(q.lineObj==b&&/div/i.test(q.nodeName)){c=q;break}var o=a,r=s,I=c,q=Vb(o,b),p=b.gutterMarkers,Od=o.display;if(!o.options.lineNumbers&&!p&&!b.bgClass&&!b.wrapClass&&!b.widgets)h=q;else{if(I){I.alignable=null;for(var t=!0,v=0,w=I.firstChild,x;w;w=x)if(x=w.nextSibling,/\bCodeMirror-linewidget\b/.test(w.className)){for(var y=0,B=!0;yb&&(b=0);g.appendChild(n("div",null,"CodeMirror-selected","position: absolute; left: "+a+"px; top: "+b+"px; width: "+(null==c?h-a:c)+"px; height: "+(d-b)+"px"))}function c(c,d,f,g){var j=q(e,c),k=j.text.length,m=g?Infinity:-Infinity;Qd(Q(j),d||0,null==f?k:f,function(e,s,l){var q=eb(a,o(c,e),"div",j),n,p;e==s?(n=q,l=p=q.left):(n=eb(a,o(c,s-1),"div",j),"rtl"== l&&(l=q,q=n,n=l),l=q.left,p=n.right);3=a.display.showingTo)){var c=+new Date+a.options.workTime,d=pa(b.mode, Ia(a,b.frontier)),e=[],f;b.iter(b.frontier,Math.min(b.first+b.size,a.display.showingTo+500),function(g){if(b.frontier>=a.display.showingFrom){var h=g.styles;g.styles=Lc(a,g,d);for(var i=!h||h.length!=g.styles.length,j=0;!i&&jc){$a(a,a.options.workDelay);return true}});e.length&& p(a,function(){for(var a=0;ag;--f){if(f<=e.first)return e.first;var h=q(e,f-1);if(h.stateAfter)return f;h=qa(h.text,null,a.options.tabSize);if(null==d||c>h)d=f-1,c=h}return d}function Ia(a,b){var c=a.doc,d=a.display;if(!c.mode.startState)return!0;var e=Sd(a,b),f=e>c.first&&q(c,e-1).stateAfter,f=f?pa(c.mode,f):Nc(c.mode);c.iter(e,b,function(g){Mc(a,g,f);g.stateAfter=e==b-1||0==e%5||e>=d.showingFrom&&e< d.showingTo?pa(c.mode,f):null;++e});return f}function Wb(a,b,c,d){for(var e=-1,d=d||Xb(a,b),a=c;;a+=e){var f=d[a];if(f)break;0>e&&0==a&&(e=1)}return{left:ac?f.left:f.right,top:f.top,bottom:f.bottom}}function Yb(a,b){for(var c=a.display.measureLineCache,d=0;dk&&h;++k)j.appendChild(f.firstChild),--h;g.appendChild(j)}f.appendChild(g)}R(d.measure,f);i=y(d.lineDiv);h=[];g=Oc(b.text.length);j=f.offsetHeight;J&&d.measure.first!= f&&R(d.measure,f);for(c=0;cs||l=s||m<=C&&s>=l||Math.min(s,l)-Math.max(m,C)>=s-m>>1){h[k]=Math.min(m,C);h[k+1]=Math.max(s,l);break}}k==h.length&&h.push(m,s);m=f.right;d.measureRight&&(m=y(d.measureRight).left);g[c]={left:f.left-i.left,right:m-i.left,top:k}}for(c=0;cc.from?f(a-1):f(a,d)}d=d||q(a.doc,b.line);e||(e=Xb(a,d));var h=Q(d),b=b.ch;if(!h)return f(b);var i=$b(h,b),i=g(b,i);null!=ra&&(i.other=g(b,ra));return i}function hb(a,b,c){a=new o(a,b);c&&(a.outside= !0);return a}function ac(a,b,c){var d=a.doc,c=c+a.display.viewOffset;if(0>c)return hb(d.first,0,!0);var e=cb(d,c),f=d.first+d.size-1;if(e>f)return hb(d.first+d.size-1,q(d,f).text.length,!0);for(0>b&&(b=0);;){var f=q(d,e),e=Ud(a,f,e,b,c),g=(f=Fa(f))&&f.find();if(f&&e.ch>=g.from.ch)e=g.to.line;else return e}}function Ud(a,b,c,d,e){function f(d){d=P(a,o(c,d),"line",b,j);h=!0;if(g>d.bottom)return d.left-i;if(gq)return hb(c,C,n);for(;;){if(k?C==s||C==bc(b,s,1):1>=C-s){for(s=(d=d-ld){C=r;q=t;if(n=h)q+=1E3;m=p}else s=r,l=t,e=h,m-=p}}function Da(a){if(null!=a.cachedTextHeight)return a.cachedTextHeight;if(null==ca){ca=n("pre");for(var b=0;49>b;++b)ca.appendChild(document.createTextNode("x")), ca.appendChild(n("br"));ca.appendChild(document.createTextNode("x"))}R(a.measure,ca);b=ca.offsetHeight/50;3c.top+e+i.top)j=!0;else if(c.bottom+e+i.top>(window.innerHeight||document.documentElement.clientHeight))j= !1;if(null!=j&&!Wd){if(i="none"==d.cursor.style.display)d.cursor.style.display="",d.cursor.style.left=c.left+"px",d.cursor.style.top=c.top-d.viewOffset+"px";d.cursor.scrollIntoView(j);i&&(d.cursor.style.display="none")}}b.selectionChanged&&fb(a);a.state.focused&&b.updateInput&&W(a,b.userSelChange);c=b.maybeHiddenMarkers;d=b.maybeUnhiddenMarkers;if(c)for(j=0;jv.bottom?20:0;i&&setTimeout(p(e,function(){u==d&&(f.scroller.scrollTop+=i,c(a))}),50)}else{e.state.focused||$(e);m=h;b(h);var j=Rb(f,g);(h.line>=j.to||h.linej-400&&w(ob.pos,i)?(k="triple",z(a),setTimeout(K(G,e),20),ae(e,i.line)):pb&&pb.time>j-400&&w(pb.pos,i)?(k="double",ob={time:j,pos:i},z(a),j=fc(q(g,i.line).text,i),A(e.doc,j.from,j.to)):pb={time:j,pos:i};var m=i;if(e.options.dragDrop&&be&&!La(e)&& !w(h.from,h.to)&&!x(i,h.from)&&!x(h.to,i)&&"single"==k){var s=p(e,function(b){if(L)f.scroller.draggable=false;e.state.draggingText=false;T(document,"mouseup",s);T(f.scroller,"drop",s);if(Math.abs(a.clientX-b.clientX)+Math.abs(a.clientY-b.clientY)<10){z(b);A(e.doc,i);G(e)}});L&&(f.scroller.draggable=!0);e.state.draggingText=s;f.scroller.dragDrop&&f.scroller.dragDrop();t(document,"mouseup",s);t(f.scroller,"drop",s)}else{z(a);"single"==k&&A(e.doc,r(g,i));var C=h.from,l=h.to,n=i,v=y(f.wrapper),u=0,Jc= p(e,function(a){!B&&!Xc(a)?d(a):c(a)}),Kc=p(e,d);t(document,"mousemove",Jc);t(document,"mouseup",Kc)}}else(a.target||a.srcElement)==f.scroller&&z(a)}}function $d(a){var b=this;if(!(ea(b.display,a)||b.options.onDragEvent&&b.options.onDragEvent(b,Ma(a)))){z(a);var c=wa(b,a,!0),d=a.dataTransfer.files;if(c&&!La(b))if(d&&d.length&&window.FileReader&&window.File)for(var e=d.length,f=Array(e),g=0,a=function(a,d){var h=new FileReader;h.onload=function(){f[d]=h.result;++g==e&&(c=r(b.doc,c),va(b.doc,{from:c, to:c,text:da(f.join("\n")),origin:"paste"},"around"))};h.readAsText(a)},h=0;h=Math.floor(y(c.gutters).right))return!1; z(b);if(!xa(a,"gutterClick"))return!0;var g=y(c.lineDiv);if(e>g.bottom)return!0;e-=g.top-c.viewOffset;for(g=0;g=d){c=cb(a.doc,e);O(a,"gutterClick",a,c,a.options.gutters[g],b);break}}return!0}function Oa(a,b){2>Math.abs(a.doc.scrollTop-b)||(a.doc.scrollTop=b,ya||db(a,[],b),a.display.scroller.scrollTop!=b&&(a.display.scroller.scrollTop=b),a.display.scrollbarV.scrollTop!=b&&(a.display.scrollbarV.scrollTop=b),ya&&db(a,[]))} function ua(a,b,c){if(!(c?b==a.doc.scrollLeft:2>Math.abs(a.doc.scrollLeft-b)))if(b=Math.min(b,a.display.scroller.scrollWidth-a.display.scroller.clientWidth),a.doc.scrollLeft=b,Ob(a),a.display.scroller.scrollLeft!=b&&(a.display.scroller.scrollLeft=b),a.display.scrollbarH.scrollLeft!=b)a.display.scrollbarH.scrollLeft=b}function Vc(a,b){var c=b.wheelDeltaX,d=b.wheelDeltaY;null==c&&(b.detail&&b.axis==b.HORIZONTAL_AXIS)&&(c=b.detail);null==d&&b.detail&&b.axis==b.VERTICAL_AXIS?d=b.detail:null==d&&(d=b.wheelDelta); var e=a.display,f=e.scroller;if(c&&f.scrollWidth>f.clientWidth||d&&f.scrollHeight>f.clientHeight){if(d&&oa&&L)for(var g=b.target;g!=f;g=g.parentNode)if(g.lineObj){a.display.currentWheelTarget=g;break}if(c&&!ya&&!S&&null!=N)d&&Oa(a,Math.max(0,Math.min(f.scrollTop+d*N,f.scrollHeight-f.clientHeight))),ua(a,Math.max(0,Math.min(f.scrollLeft+c*N,f.scrollWidth-f.clientWidth))),z(b),e.wheelStartX=null;else{if(d&&null!=N){var g=d*N,h=a.doc.scrollTop,i=h+e.wrapper.clientHeight;0>g?h=Math.max(0,h+g-50):i=Math.min(a.doc.height, i+g+50);db(a,[],{top:h,bottom:i})}20>qb&&(null==e.wheelStartX?(e.wheelStartX=f.scrollLeft,e.wheelStartY=f.scrollTop,e.wheelDX=c,e.wheelDY=d,setTimeout(function(){if(e.wheelStartX!=null){var a=f.scrollLeft-e.wheelStartX,b=f.scrollTop-e.wheelStartY,a=b&&e.wheelDY&&b/e.wheelDY||a&&e.wheelDX&&a/e.wheelDX;e.wheelStartX=e.wheelStartY=null;if(a){N=(N*qb+a)/(qb+1);++qb}}},200)):(e.wheelDX+=c,e.wheelDY+=d))}}}function rb(a,b,c){if("string"==typeof b&&(b=ic[b],!b))return!1;a.display.pollingFast&&ec(a)&&(a.display.pollingFast= !1);var d=a.doc,e=d.sel.shift,f=!1;try{La(a)&&(a.state.suppressEdits=!0),c&&(d.sel.shift=!1),f=b(a)!=Yc}finally{d.sel.shift=e,a.state.suppressEdits=!1}return f}function Zc(a){var b=a.state.keyMaps.slice(0);a.options.extraKeys&&b.push(a.options.extraKeys);b.push(a.options.keyMap);return b}function $c(a,b){var c=jc(a.options.keyMap),d=c.auto;clearTimeout(ad);d&&!bd(b)&&(ad=setTimeout(function(){jc(a.options.keyMap)==c&&(a.options.keyMap=d.call?d.call(null,a):d)},50));var e=cd(b,!0),f=!1;if(!e)return!1; f=Zc(a);f=b.shiftKey?Pa("Shift-"+e,f,function(b){return rb(a,b,!0)})||Pa(e,f,function(b){if("string"==typeof b&&/^go[A-Z]/.test(b))return rb(a,b)}):Pa(e,f,function(b){return rb(a,b)});"stop"==f&&(f=!1);f&&(z(b),fb(a),J&&(b.oldKeyCode=b.keyCode,b.keyCode=0));return f}function ce(a,b,c){if(c=Pa("'"+c+"'",Zc(a),function(b){return rb(a,b,!0)}))z(b),fb(a);return c}function Wc(a){this.state.focused||$(this);B&&27==a.keyCode&&(a.returnValue=!1);if(!this.options.onKeyEvent||!this.options.onKeyEvent(this, Ma(a))){var b=a.keyCode;this.doc.sel.shift=16==b||a.shiftKey;var c=$c(this,a);S&&(kc=c?b:null,!c&&(88==b&&!Rc&&(oa?a.metaKey:a.ctrlKey))&&this.replaceSelection(""))}}function Zd(a){var b=this;if(!b.options.onKeyEvent||!b.options.onKeyEvent(b,Ma(a))){var c=a.keyCode,d=a.charCode;if(S&&c==kc)kc=null,z(a);else if(!(S&&(!a.which||10>a.which)||Nb)||!$c(b,a))c=String.fromCharCode(null==d?c:d),this.options.electricChars&&(this.doc.mode.electricChars&&this.options.smartIndent&&!La(this)&&-1b.to.line+d)return b=c.line-d,d=a.first+a.size-1,b>d?o(d,q(a,d).text.length):tb(c,q(a,b).text.length); if(c.line==b.to.line+d)return tb(c,E(b.text).length+(1==b.text.length?b.from.ch:0)+q(a,b.to.line).text.length-b.to.ch);a=c.line-b.from.line;return tb(c,b.text[a].length+(a?0:b.from.ch))}function nc(a,b,c){if(c&&"object"==typeof c)return{anchor:dd(a,b,c.anchor),head:dd(a,b,c.head)};if("start"==c)return{anchor:b.from,head:b.from};var d=mc(b);if("around"==c)return{anchor:b.from,head:d};if("end"==c)return{anchor:d,head:d};c=function(a){if(x(a,b.from))return a;if(!x(b.to,a))return d;var c=a.line+b.text.length- (b.to.line-b.from.line)-1,g=a.ch;a.line==b.to.line&&(g+=d.ch-b.to.ch);return o(c,g)};return{anchor:c(a.sel.anchor),head:c(a.sel.head)}}function de(a,b){var c={canceled:!1,from:b.from,to:b.to,text:b.text,origin:b.origin,update:function(b,c,f,g){b&&(this.from=r(a,b));c&&(this.to=r(a,c));f&&(this.text=f);void 0!==g&&(this.origin=g)},cancel:function(){this.canceled=!0}};D(a,"beforeChange",a,c);a.cm&&D(a.cm,"beforeChange",a.cm,c);return c.canceled?null:{from:c.from,to:c.to,text:c.text,origin:c.origin}} function va(a,b,c,d){if(a.cm){if(!a.cm.curOp)return p(a.cm,va)(a,b,c,d);if(a.cm.state.suppressEdits)return}if(xa(a,"beforeChange")||a.cm&&xa(a.cm,"beforeChange"))if(b=de(a,b),!b)return;if(d=ed&&!d&&ee(a,b.from,b.to)){for(var e=d.length-1;1<=e;--e)oc(a,{from:d[e].from,to:d[e].to,text:[""]});d.length&&oc(a,{from:d[0].from,to:d[0].to,text:b.text},c)}else oc(a,b,c)}function oc(a,b,c){c=nc(a,b,c);fd(a,b,c,a.cm?a.cm.curOp.id:NaN);Qa(a,b,c,pc(a,b));var d=[];za(a,function(a,c){!c&&-1==U(d,a.history)&&(gd(a.history, b),d.push(a.history));Qa(a,b,null,pc(a,b))})}function hd(a,b){if(!a.cm||!a.cm.state.suppressEdits){var c=a.history,d=("undo"==b?c.done:c.undone).pop();if(d){c.dirtyCounter+="undo"==b?-1:1;var e={changes:[],anchorBefore:d.anchorAfter,headBefore:d.headAfter,anchorAfter:d.anchorBefore,headAfter:d.headBefore};("undo"==b?c.undone:c.done).push(e);for(c=d.changes.length-1;0<=c;--c){var f=d.changes[c];f.origin=b;e.changes.push(qc(a,f));var g=c?nc(a,f,null):{anchor:d.anchorBefore,head:d.headBefore};Qa(a,f, g,id(a,f));var h=[];za(a,function(a,b){!b&&-1==U(h,a.history)&&(gd(a.history,f),h.push(a.history));Qa(a,f,null,id(a,f))})}}}}function jd(a,b){function c(a){return o(a.line+b,a.ch)}a.first+=b;a.cm&&u(a.cm,a.first,a.first,b);a.sel.head=c(a.sel.head);a.sel.anchor=c(a.sel.anchor);a.sel.from=c(a.sel.from);a.sel.to=c(a.sel.to)}function Qa(a,b,c,d){if(a.cm&&!a.cm.curOp)return p(a.cm,Qa)(a,b,c,d);if(b.to.linea.lastLine())){if(b.from.line< a.first){var e=b.text.length-1-(a.first-b.from.line);jd(a,e);b={from:o(a.first,0),to:o(b.to.line+e,b.to.ch),text:[E(b.text)],origin:b.origin}}e=a.lastLine();b.to.line>e&&(b={from:b.from,to:o(e,q(a,e).text.length),text:[b.text[0]],origin:b.origin});b.removed=rc(a,b.from,b.to);c||(c=nc(a,b,null));a.cm?fe(a.cm,b,d,c):sc(a,b,d,c)}}function fe(a,b,c,d){var e=a.doc,f=a.display,g=b.from,h=b.to,i=!1,j=g.line;a.options.lineWrapping||(j=H(ma(e,q(e,g.line))),e.iter(j,h.line+1,function(a){if(a==f.maxLine)return i= !0}));!x(e.sel.head,b.from)&&!x(b.to,e.sel.head)&&(a.curOp.cursorActivity=!0);sc(e,b,c,d,Ec(a));a.options.lineWrapping||(e.iter(j,g.line+b.text.length,function(a){var b=bb(e,a);if(b>f.maxLineLength){f.maxLine=a;f.maxLineLength=b;f.maxLineChanged=true;i=false}}),i&&(a.curOp.updateMaxLine=!0));e.frontier=Math.min(e.frontier,g.line);$a(a,400);u(a,g.line,h.line+1,b.text.length-(h.line-g.line)-1);if(xa(a,"change"))if(b={from:g,to:h,text:b.text,removed:b.removed,origin:b.origin},a.curOp.textChanged){for(a= a.curOp.textChanged;a.next;a=a.next);a.next=b}else a.curOp.textChanged=b}function Z(a,b,c,d,e){d||(d=c);if(x(d,c))var f=d,d=c,c=f;"string"==typeof b&&(b=da(b));va(a,{from:c,to:d,text:b,origin:e},null)}function o(a,b){if(!(this instanceof o))return new o(a,b);this.line=a;this.ch=b}function w(a,b){return a.line==b.line&&a.ch==b.ch}function x(a,b){return a.linec?o(c,q(a,c).text.length):tb(b,q(a,b.line).text.length)}function tb(a,b){var c=a.ch;return null==c||c>b?o(a.line,b):0>c?o(a.line,0):a}function Aa(a,b){return b>=a.first&&b=f.ch:j.to>f.ch))){if(d&&(D(k,"beforeCursorEnter"),k.explicitlyCleared))if(h.markedSpans){--i;continue}else break;if(k.atomic){i=k.find()[0>g?"from":"to"];if(w(i,f)&&(i.ch+=g,0>i.ch?i=i.line>a.first?r(a,o(i.line-1)): null:i.ch>h.text.length&&(i=i.linec&&(c=0);var h=f.scroller.clientHeight-ja,i=f.scroller.scrollTop,j={},a=a.doc.height+(f.mover.offsetHeight-f.lineSpace.offsetHeight),k=ca-10;ci+h&&(c=Math.min(c,(g?a:e)-h),c!=i&&(j.scrollTop=c));i=f.scroller.clientWidth-ja;c=f.scroller.scrollLeft;b+=f.gutters.offsetWidth;d+=f.gutters.offsetWidth;f=f.gutters.offsetWidth;e=bi+c-3&&(j.scrollLeft= d+10-i);return j}function vb(a,b,c){a.curOp.updateScrollPos={scrollLeft:null==b?a.doc.scrollLeft:b,scrollTop:null==c?a.doc.scrollTop:c}}function ld(a,b,c){var d=a.curOp.updateScrollPos||(a.curOp.updateScrollPos={scrollLeft:a.doc.scrollLeft,scrollTop:a.doc.scrollTop}),a=a.display.scroller;d.scrollTop=Math.max(0,Math.min(a.scrollHeight-a.clientHeight,d.scrollTop+c));d.scrollLeft=Math.max(0,Math.min(a.scrollWidth-a.clientWidth,d.scrollLeft+b))}function sb(a,b,c,d){var e=a.doc;c||(c="add");if("smart"== c)if(a.doc.mode.indent)var f=Ia(a,b);else c="prev";var g=a.options.tabSize,h=q(e,b),i=qa(h.text,null,g),j=h.text.match(/^\s*/)[0],k;if("smart"==c&&(k=a.doc.mode.indent(f,h.text.slice(j.length),h.text),k==Yc)){if(!d)return;c="prev"}"prev"==c?k=b>e.first?qa(q(e,b-1).text,null,g):0:"add"==c?k=i+a.options.indentUnit:"subtract"==c&&(k=i-a.options.indentUnit);k=Math.max(0,k);c="";d=0;if(a.options.indentWithTabs)for(e=Math.floor(k/g);e;--e)d+=g,c+="\t";d=a.first+a.size?b=j=!1:(g=b,b=i=q(a,b));if(b)h=e?(0>c?jb:ib)(i):0>c?i.text.length:0;else return j=!1}else h=d;return!0}var g=b.line,h=b.ch,b=c,i=q(a,g),j=!0;if("char"==d)f();else if("column"==d)f(!0); else if("word"==d||"group"==d)for(var k=null,d="group"==d,m=!0;!(0>c)||f(!m);m=!1){var s=i.text.charAt(h)||"\n",s=xb(s)?"w":!d?null:/\s/.test(s)?null:"p";if(k&&k!=s){0>c&&(c=1,f());break}s&&(k=s);if(0c?1.5:0.5)*Da(a.display))):"line"==d&&(g=0c?0>=g:g>=e.height){h.hitSide=!0;break}g+=5*c}return h}function fc(a,b){var c=b.ch,d=b.ch;if(a){!1===b.after||d==a.length?--c:++d;for(var e=a.charAt(c),e=xb(e)?xb:/\s/.test(e)?function(a){return/\s/.test(a)}:function(a){return!/\s/.test(a)&&!xb(a)};0=e:j.to>e);(i||(i=[])).push({from:j.from,to:m?null:j.to,marker:k})}}c=i;if(d)for(var h=0,s;h=f:i.to>f)||"bookmark"==j.type&&i.from==f&&(!g||i.marker.insertLeft))k=null==i.from||(j.inclusiveLeft? i.from<=f:i.fromb)&&(!d||d.widtha.options.maxHighlightLength?(f=!1,i.pos=Math.min(b.length,i.start+5E4),j=null):j=c.token(i,d);var k=i.current();i.start=i.pos; !f||h!=j?(g&&e(g,h),g=k,h=j):g+=k}g&&e(g,h)}function Lc(a,b,c){var d=[a.state.modeGen];td(a,b.text,a.doc.mode,c,function(a,b){d.push(a,b)});for(c=0;cm)){if(null!=x.to&&p>x.to&&(p=x.to,t=""),z.className&&(r+=" "+z.className),z.startStyle&&x.from==m&&(v+=" "+z.startStyle),z.endStyle&&x.to==p&&(t+=" "+z.endStyle),z.collapsed&&(!u||u.marker.widthm&&p>x.from&&(p=x.from);"bookmark"==z.type&&(x.from==m&&z.replacedWith)&&(w=z.replacedWith)}if(u&&(u.from||0)==m)if(xd(g,(null==u.to?k:u.to)-m,null!=u.from&&u.marker.replacedWith),null==u.to){j=u.marker.find();break a}w&&!u&&xd(g,0,w)}if(m>=k)break;for(w=Math.min(k,p);;){if(l){y= m+l.length;u||(x=y>w?l.slice(0,w-m):l,g.addToken(g,x,o?o+r:r,v,m+x.length==p?t:""));if(y>=w){l=l.slice(w-m);m=w;break}m=y;v=""}l=j[s++];o=ud(j[s++])}}else for(var s=1;sh&&gf-a.cm.options.historyEventDelay||"*"==b.origin.charAt(0)))){var h= E(g.changes);w(b.from,b.to)&&w(b.from,h.to)?h.to=mc(b):g.changes.push(qc(a,b));g.anchorAfter=c.anchor;g.headAfter=c.head}else{g={changes:[qc(a,b)],anchorBefore:a.sel.anchor,headBefore:a.sel.head,anchorAfter:c.anchor,headAfter:c.head};for(e.done.push(g);e.done.length>e.undoDepth;)e.done.shift();0>e.dirtyCounter?e.dirtyCounter=NaN:e.dirtyCounter++}e.lastTime=f;e.lastOp=d;e.lastOrigin=b.origin}function he(a){if(!a)return null;for(var b=0,c;b=b.offsetWidth&&2b||b==c&&f.to==b)d(Math.max(f.from,b),Math.min(f.to,c),1==f.level?"rtl":"ltr")}}function Zb(a){return a.level%2?a.from:a.to}function ib(a){return(a=Q(a))?a[0].level%2?a[0].to:a[0].from:0}function jb(a){var b=Q(a);return!b?a.text.length:Zb(E(b))}function Dd(a, b){var c=q(a.doc,b),d=ma(a.doc,c);d!=c&&(b=H(d));c=Q(d);d=!c?0:c[0].level%2?jb(d):ib(d);return o(b,d)}function pe(a,b){for(var c,d;c=Fa(d=q(a.doc,b));)b=c.find().to.line;c=Q(d);d=!c?d.text.length:c[0].level%2?ib(d):jb(d);return o(b,d)}function $b(a,b){for(var c=0,d;cb)return ra=null,c;if(e.from==b||e.to==b)if(null==d)d=c;else{var e=e.level,f=a[d].level,g=a[0].level,e=e==g?!0:f==g?!1:eg.from&&bb||b>a.text.length?null:b}var ya= /gecko\/\d/i.test(navigator.userAgent),B=/MSIE \d/.test(navigator.userAgent),ka=B&&(null==document.documentMode||8>document.documentMode),J=B&&(null==document.documentMode||9>document.documentMode),L=/WebKit\//.test(navigator.userAgent),qe=L&&/Qt\/\d+\.\d+/.test(navigator.userAgent),re=/Chrome\//.test(navigator.userAgent),S=/Opera\//.test(navigator.userAgent),hc=/Apple Computer/.test(navigator.vendor),Nb=/KHTML\//.test(navigator.userAgent),Hd=/Mac OS X 1\d\D([7-9]|\d\d)\D/.test(navigator.userAgent), Id=/Mac OS X 1\d\D([8-9]|\d\d)\D/.test(navigator.userAgent),Wd=/PhantomJS/.test(navigator.userAgent),Ba=/AppleWebKit/.test(navigator.userAgent)&&/Mobile\/\w+/.test(navigator.userAgent),Jb=Ba||/Android|webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(navigator.userAgent),oa=Ba||/Mac/.test(navigator.platform),se=/windows/i.test(navigator.platform),Wa=S&&navigator.userAgent.match(/Version\/(\d*\.\d*)/);Wa&&(Wa=Number(Wa[1]));var pd=oa&&(qe||S&&(null==Wa||12.11>Wa)),gc=ya||B&&!J,ed=!1,Ha=!1,ca, Vd=0,pb,ob,qb=0,N=null;B?N=-0.53:ya?N=15:re?N=-0.7:hc&&(N=-1/3);var ad,kc=null,lc;l.Pos=o;l.prototype={constructor:l,focus:function(){window.focus();G(this);$(this);Ka(this)},setOption:function(a,b){var c=this.options,d=c[a];c[a]==b&&"mode"!=a||(c[a]=b,ia.hasOwnProperty(a)&&p(this,ia[a])(this,b,d))},getOption:function(a){return this.options[a]},getDoc:function(){return this.doc},addKeyMap:function(a,b){this.state.keyMaps[b?"push":"unshift"](a)},removeKeyMap:function(a){for(var b=this.state.keyMaps, c=0;ci)&&a.top>b.offsetHeight?g=a.top-b.offsetHeight:a.bottom+b.offsetHeight<=i&&(g=a.bottom);h+b.offsetWidth>j&&(h=j-b.offsetWidth)}b.style.top=g+f.lineSpace.offsetTop+"px";b.style.left=b.style.right="";"right"==e?(h=f.sizer.clientWidth-b.offsetWidth,b.style.right="0px"):("left"==e?h=0:"middle"==e&&(h=(f.sizer.clientWidth-b.offsetWidth)/2),b.style.left=h+"px");c&&(a=mb(this,h,g,h+b.offsetWidth,g+b.offsetHeight), null!=a.scrollTop&&Oa(this,a.scrollTop),null!=a.scrollLeft&&ua(this,a.scrollLeft))},triggerOnKeyDown:p(null,Wc),execCommand:function(a){return ic[a](this)},findPosH:function(a,b,c,d){var e=1;0>b&&(e=-1,b=-b);for(var f=0,a=r(this.doc,a);fa?c.from:c.to;A(this.doc,c,c,a)}),deleteH:p(null,function(a,b){var c=this.doc.sel; w(c.from,c.to)?Z(this.doc,"",c.from,tc(this.doc,c.head,a,b,!1),"+delete"):Z(this.doc,"",c.from,c.to,"+delete");this.curOp.userSelChange=!0}),findPosV:function(a,b,c,d){var e=1;0>b&&(e=-1,b=-b);for(var f=0,a=r(this.doc,a);f=this.string.length},sol:function(){return 0==this.pos},peek:function(){return this.string.charAt(this.pos)||void 0},next:function(){if(this.posb},eatSpace:function(){for(var a=this.pos;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++this.pos;return this.pos>a},skipToEnd:function(){this.pos=this.string.length},skipTo:function(a){a=this.string.indexOf(a,this.pos);if(-1a.display.maxLineLength&&(a.display.maxLine=f,a.display.maxLineLength=g,a.display.maxLineChanged=!0);null!=c&&a&&u(a,c,d+1);this.lines.length=0;this.explicitlyCleared=!0;this.collapsed&&this.doc.cantEdit&&(this.doc.cantEdit=!1,a&&kd(a));b&&ta(a);O(this,"clear")}};ha.prototype.find=function(){for(var a,b,c=0;c=b.display.showingFrom&&a.from.linethis.size- b&&(c=[],this.collapse(c),this.children=[new Bb(c)],this.children[0].parent=this)},collapse:function(a){for(var b=0,c=this.children.length;b=this.children.length)){var a=this;do{var b=a.children.splice(a.children.length-5,5),b=new Va(b);if(a.parent){a.size-=b.size;a.height-=b.height;var c=U(a.parent.children,a);a.parent.children.splice(c+1,0,b)}else c=new Va(a.children),c.parent=a,a.children=[c,b],a=c;b.parent=a.parent}while(10=a.ch))b.push(e.marker.parent||e.marker)}return b},getAllMarks:function(){var a=[];this.iter(function(b){if(b=b.markedSpans)for(var c=0;ca)return b=a,!0;a-=d;++c});return r(this,o(c,b))},indexFromPos:function(a){var a=r(this,a),b=a.ch;if(a.linea.ch)return 0;this.iter(this.first,a.line,function(a){b+=a.text.length+1});return b},copy:function(a){var b=new F(xc(this,this.first,this.first+this.size),this.modeOption,this.first);b.scrollTop=this.scrollTop;b.scrollLeft=this.scrollLeft;b.sel={from:this.sel.from,to:this.sel.to,head:this.sel.head,anchor:this.sel.anchor, shift:this.sel.shift,extend:!1,goalColumn:this.sel.goalColumn};a&&(b.history.undoDepth=this.history.undoDepth,b.setHistory(this.getHistory()));return b},linkedDoc:function(a){a||(a={});var b=this.first,c=this.first+this.size;null!=a.from&&a.from>b&&(b=a.from);null!=a.to&&a.toU(ue,Za)&&(l.prototype[Za]=function(a){return function(){return a.apply(this.doc,arguments)}}(F.prototype[Za]));l.e_stop=Na;l.e_preventDefault=z;l.e_stopPropagation=Ad;var X,kb=0;l.on=t;l.off=T;l.signal=D;var ja=30,Yc=l.Pass={toString:function(){return"CodeMirror.Pass"}};Kb.prototype={set:function(a,b){clearTimeout(this.id);this.id=setTimeout(b,a)}};l.countColumn=qa;var Fb=[""],oe=/[\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/, cc=/[\u0300-\u036F\u0483-\u0487\u0488-\u0489\u0591-\u05BD\u05BF\u05C1-\u05C2\u05C4-\u05C5\u05C7\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7-\u06E8\u06EA-\u06ED\uA66F\uA670-\uA672\uA674-\uA67D\uA69F\udc00-\udfff]/;l.replaceGetRect=function(a){y=a};var be=function(){if(J)return!1;var a=n("div");return"draggable"in a||"dragDrop"in a}();ya?Ab=function(a,b){return 36==a.charCodeAt(b-1)&&39==a.charCodeAt(b)}:hc&&!/Version\/([6-9]|\d\d)\b/.test(navigator.userAgent)?Ab=function(a,b){return/\-[^ \-?]|\?[^ !\'\"\),.\-\/:;\?\]\}]/.test(a.slice(b- 1,b+1))}:L&&(Ab=function(a,b){return 1,:;][({[<]|\?[\w~`@#$%\^&*(_=+{[|><]/.test(a.slice(b-1,b+1))});var Gb,yc,da=3!="\n\nb".split(/\n/).length?function(a){for(var b=0,c=[],d=a.length;b<=d;){var e=a.indexOf("\n",b);-1==e&&(e=a.length);var f=a.slice(b,"\r"==a.charAt(e-1)?e-1:e),g=f.indexOf("\r");-1!=g?(c.push(f.slice(0,g)),b+=g+1):(c.push(f),b=e+1)}return c}:function(a){return a.split(/\r\n?|\n/)}; l.splitLines=da;var Xd=window.getSelection?function(a){try{return a.selectionStart!=a.selectionEnd}catch(b){return!1}}:function(a){try{var b=a.ownerDocument.selection.createRange()}catch(c){}return!b||b.parentElement()!=a?!1:0!=b.compareEndPoints("StartToEnd",b)},Rc=function(){var a=n("div");if("oncopy"in a)return!0;a.setAttribute("oncopy","return;");return"function"==typeof a.oncopy}(),ga={3:"Enter",8:"Backspace",9:"Tab",13:"Enter",16:"Shift",17:"Ctrl",18:"Alt",19:"Pause",20:"CapsLock",27:"Esc", 32:"Space",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"Left",38:"Up",39:"Right",40:"Down",44:"PrintScrn",45:"Insert",46:"Delete",59:";",91:"Mod",92:"Mod",93:"Mod",109:"-",107:"=",127:"Delete",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'",63276:"PageUp",63277:"PageDown",63275:"End",63273:"Home",63234:"Left",63232:"Up",63235:"Right",63233:"Down",63302:"Insert",63272:"Delete"};l.keyNames=ga;(function(){for(var a=0;10>a;a++)ga[a+48]=""+a;for(a=65;90>=a;a++)ga[a]= String.fromCharCode(a);for(a=1;12>=a;a++)ga[a+111]=ga[a+63235]="F"+a})();var ra,le=function(){function a(a){return 255>=a?b.charAt(a):1424<=a&&1524>=a?"R":1536<=a&&1791>=a?c.charAt(a-1536):1792<=a&&2220>=a?"r":"L"}var b="bbbbbbbbbtstwsbbbbbbbbbbbbbbssstwNN%%%NNNNNN,N,N1111111111NNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNbbbbbbsbbbbbbbbbbbbbbbbbbbbbbbbbb,N%%%%NNNNLNNNNN%%11NLNNN1LNNNNNLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLL",c="rrrrrrrrrrrr,rNNmmmmmmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmrrrrrrrnnnnnnnnnn%nnrrrmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmmmmmmNmmmmrrrrrrrrrrrrrrrrrr", d=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/,e=/[stwN]/,f=/[LRr]/,g=/[Lb1n]/,h=/[1n]/;return function(b){if(!d.test(b))return!1;for(var c=b.length,k=[],m=0,l;m